Skip to content

Implement message dispatching and handling for Claude agent interactions#4674

Open
TylerLeonhardt wants to merge 1 commit intomainfrom
tyler/mechanical-firefly
Open

Implement message dispatching and handling for Claude agent interactions#4674
TylerLeonhardt wants to merge 1 commit intomainfrom
tyler/mechanical-firefly

Conversation

@TylerLeonhardt
Copy link
Member

This should make messaging handling in Claude a little easier to manage and test.

This should make messaging handling in Claude a little easier to manage and test.
Copilot AI review requested due to automatic review settings March 25, 2026 01:44
@TylerLeonhardt TylerLeonhardt self-assigned this Mar 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors Claude session message handling by introducing a centralized dispatcher for Claude Agent SDK message types, making the message-processing logic easier to reason about and unit test.

Changes:

  • Added claudeMessageDispatch.ts to route SDK messages to focused handlers (assistant/user/result/compact boundary) and share per-loop state.
  • Updated claudeCodeAgent.ts to use the dispatcher instead of inlining message handling logic.
  • Added comprehensive unit tests for dispatching and individual handlers in claudeMessageDispatch.spec.ts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/extension/chatSessions/claude/node/claudeCodeAgent.ts Replaces inline message-type branching with dispatchMessage(...) invocation to centralize handling.
src/extension/chatSessions/claude/common/claudeMessageDispatch.ts Introduces dispatch + handler functions for SDK message types, including tool span tracking and TodoWrite forwarding.
src/extension/chatSessions/claude/common/test/claudeMessageDispatch.spec.ts Adds unit coverage for dispatch routing, handler behavior, and known/unknown message key logging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants