Repository navigation
Extract fork-only handlers out of ws.ts and server.ts - #178
Merged
Merged
Conversation
ws.ts now has upstream's shape: layerWsRpc with upstream's indentation, handler order, and helper order, minus the uncarried surfaces, with each remaining difference marked Coder:. The 17 fork-only methods, their helpers, the merge-request link guard, and the helper stdio frame check move to coderWs.ts, which ws.ts merges in at one return hook. The Files list, read, and write handlers in ws.ts are upstream's again; coderWs.ts wraps them behind the same thread root verification, so upstream changes to them reach the code that runs. An identity withPullRequestViewer shim makes the merge-request handlers upstream's. The served method set is byte-identical, and every handler and helper is the old code after normalizing whitespace (the Files wrappers with upstream's handler inlined reproduce the old ones), except two deliberate adoptions of upstream: terminalAttach fails its stream on a setup error, as upstream's pingdotgg#9791 does (a fix an earlier sync missed), and upstream's span annotations are back on the eight carried handlers that had them; with no tracer they export nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
server.ts is upstream's file minus the uncarried surfaces: it keeps upstream's declarations, under upstream's names, for the layers the helper uses, with three Coder: changes in place (settings expose the secret store, the VCS status broadcaster takes the demand-only background policy, the terminal shares its PTY adapter and process runner). One Coder: export block hands them to coderServer.ts, which holds the fork-only layers, the startup sequence, StorageCleanup placement, the T3 tool bridge binding, and makeCoderRuntimeLayer. The helper imports makeCoderRuntimeLayer from coderServer.ts. No behavior change. Every layer expression is the old one renamed, except three that differ only in how they reach shared leaves: the merge-request service lists its independent providers in upstream's order; text generation takes the provider registry from the outer graph instead of providing the same memoized layer again; and Git workflow takes upstream's layerGit, which adds the already built Git driver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Transport and RPC handlers seam now says that ws.ts and server.ts are upstream's files minus the cut surfaces, names the in-place Coder: changes they keep, and points the fork-only methods, the Files root verification, the T3 tool bridge binding, the agent-session scanner, and StorageCleanup placement at coderWs.ts and coderServer.ts. The sync checklist's conflict magnets say how to resolve the two files now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Moves the fork's own code out of
apps/server/src/ws.tsandapps/server/src/server.tsinto sibling files, so both become upstream's file minus the cut surfaces, and upstream edits to the carried code merge cleanly.Against the merge-base
dacd2cb649:ws.tsserver.tsLayout
ws.tskeeps upstream'slayerWsRpc, indentation, handler order, and helper order. Its handler object is typed byCoderWsRpcGroupminusCODER_WS_METHODS. OneCoder:return hook merges in the handlers fromcoderWs.ts.coderWs.tsholds:server.tskeeps upstream's declarations, under upstream's names, for the layers the helper uses. It has three in-placeCoder:changes: settings also provide the secret store, the VCS status broadcaster takes the demand-only background policy, and the terminal shares its PTY adapter and process runner. OneCoder:export block hands these layers tocoderServer.ts, soserver.tsimports nothing from the fork.coderServer.tsholds the fork-only layers,CoderRuntimeStartupwith the T3 tool bridge binding, theStorageCleanupplacement, andmakeCoderRuntimeLayer. The helper now importsmakeCoderRuntimeLayerfrom it.Inventory of the old diff
ws.ts: editor/config discovery, chat-attachment persistence, auth access, client-origin and analytics readers, ACP registry, device, preview, usage, self-update, relay, diagnostics, and the/wsroute.server.ts: HTTP, auth, cloud/tunnel, telemetry, usage, preview, and device layers;layerMakeServer; the upstream runtime composition.coderWs.ts.coderServer.ts.Coder:. Inws.ts, most had no marker before.ws.ts: dispatch and launch (no command queue or client analytics; merge-request link check), thestreamContextprovides, scheduled-task webhook visibility,loadServerConfigandserverGetConfig, provider refresh, settings update,projectsMutate, server config and lifecycle streams, the stdio frame checks, and the failure-context cases.server.ts: the three changes listed under Layout.ws.ts:terminalAttachnow has upstream'scatchCausefrom feat(auth): allow passive terminal observation pingdotgg/t3code#9791, a fix an earlier sync missed.withPullRequestVieweris an identity function, which makes all 22 merge-request handlers match upstream exactly.Served-method proof
I listed the
[WS_METHODS.x]and[ORCHESTRATION_V2_WS_METHODS.x]keys served before (ws.ts) and after (ws.ts+coderWs.ts).CoderWsRpcGroup. The finalCoderWsRpcGroup.ofcall also enforces completeness at typecheck.terminalAttachand the five whose only difference was the annotation.Every layer expression is the old one renamed, except three. Each differs only in how it reaches shared leaves:
layerGit.Effect memoizes these leaves, and each service has a single provider in the graph, so the instances are identical.
apps/coder-helper/src/bin.test.tsbuilds the full runtime in a real helper process and servesserverGetConfigandsubscribeShell; it passes.Merge replay
For each past sync, I merged the upstream commit into the pre-sync fork commit twice: once as it was, and once with the new layout rebuilt at that commit. Then I ran
scripts/sync-resolve-deleted.mjsand counted conflict blocks.ws.tsbefore → afterserver.tsbefore → afterdacd2cb649(latest)98beed1a22b6aa268b12The
server.tsconflicts that remain are upstream edits inside regions the fork deletes.docs/internals/sync.mdnow says to port them intocoderServer.ts. Merging the next upstream batch (4f63275ac7), which doesn't touch either file, is conflict-free before and after.Verification
pnpm typecheck:serverandpnpm typecheck:helperpass; the focusedws,ws.projects,V1ImportBoundary, andcoderEnvironmenttests pass.pnpm typecheck:server,typecheck:helper,typecheck:gateway,knip:check, andpnpm buildall exit 0.pnpm test:coderon HEAD: exits 0. The first run hit the documented flakyserverSettingswatcher timeout; that test passes alone, and the rerun exited 0.V1ImportBoundary.test.tslistscoderServer.tsandcoderWs.tsas the importers now.sync.md's conflict magnets describe the new layout.sync.mdnow passesvp fmt.🤖 Generated with Claude Code