refactor(engine): canonical /api/posts wire + post-* SSE events#152
Merged
Conversation
The viewer now fetches the canonical /api/posts(/:id) and /api/sessions/:id/posts paths instead of the legacy /api/surfaces aliases, and the live feed emits and listens for post-created/updated/deleted instead of surface-*. Server and viewer ship together, so the SSE event-type flip is in lockstep. Strictly first-party: every external-facing alias is retained as a deprecated shim — the legacy /api/surfaces + /s/ routes, /api/snippets, the publish_surface/ update_surface/list_surfaces MCP tools, and the surfaceId/surfaceTitle comment feedback wire fields are all unchanged. Removing those stays a separate, telemetry-gated step. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
What
Completes the surface→post wire migration inside the engine's own first-party traffic. Previously the new
/api/postsroutes andpublish_posttools landed additively while the running viewer still used the legacy/api/surfacespaths andsurface-*SSE events. This points the frontend at the canonical wire.viewer/src/state.ts,viewer/src/Card.tsx):/api/surfaces/:id→/api/posts/:id,/api/sessions/:id/surfaces→/api/sessions/:id/posts.server/events.tsunion +server/app.tsbroadcasts now emitpost-created/updated/deleted; the viewer's feed handler listens for them. Server and viewer ship in one package, so the flip is atomic.e2e/viewer.spec.ts: route-interception regex updated to the canonical path.Strictly first-party — all external aliases retained
Nothing third parties depend on was touched. Still registered as deprecated shims:
/api/surfaces*,/s/:id,/session/:id/s/:surfaceId,/api/sessions/:id/surfaces, and/api/snippets*publish_surface/update_surface/list_surfaces(with theirpartsfield)surfaceId/surfaceTitlecomment-feedback wire fields and thesurfacecomment body keyRemoving those is a later, telemetry-gated step. Alias tests in
test/api.test.ts/test/cli.test.tsare unchanged and still pass.Gates
npm run typecheck— PASSnpm test— PASS (261/261)npm run test:e2e— chromium PASS (68/68, incl. live SSE-driven DOM updates + post CRUD). WebKit project can't launch in this environment (missing host browser deps), unrelated to the change.Changeset:
.changeset/engine-post-wire.md(sideshow: minor).🤖 Generated with Claude Code