Repository navigation
refactor(server): move client command dispatch out of ws.ts - #112
Merged
Merged
Conversation
Thread bootstrap (create, worktree, setup script, context repositories), the startup command queue, and post-archive cleanup lived inside the WebSocket RPC closure, so the HTTP dispatch route skipped all of it. They now live in ClientCommandDispatcher, which both transports call. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
adampeterhiggins
force-pushed
the
ah/mcp-thread-write-operations
branch
from
October 1, 2026 08:28
c72016c to
c56b00c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack 1 of 8: agents operate T3 Code over MCP.
Thread bootstrap lived inside the per-connection WebSocket RPC closure in
ws.ts. That covers creating the thread, preparing the worktree, running the setup script, cloning context repositories, the startup command queue, and the session stop and terminal close after an archive. Anything else that dispatched a command skipped it. For example,POST /api/orchestration/dispatchhanded a bootstrapthread.turn.startstraight to the engine. The MCP write tools later in this stack need the same path.This moves that code into
ClientCommandDispatcher(apps/server/src/orchestration/ClientCommandDispatcher.ts).forOrigin(origin).dispatch(normalizedCommand)runs a command the way a client send does, and tags every server-generated step with the caller's origin.POST /api/orchestration/dispatchnow uses the dispatcher too, so a bootstrap turn over HTTP creates its thread like one over the WebSocket. A new test inserver.test.tscovers this; it fails against the old route.Testing:
tsconapps/serveris clean.server.test.ts+bin.test.ts: 234/235 pass.flushes more than one tool chunk before the synchronization markerfails onmainas well.Done by Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code