Skip to content

refactor(engine): canonical /api/posts wire + post-* SSE events#152

Merged
benvinegar merged 1 commit into
mainfrom
feat/engine-post-wire
Jun 26, 2026
Merged

refactor(engine): canonical /api/posts wire + post-* SSE events#152
benvinegar merged 1 commit into
mainfrom
feat/engine-post-wire

Conversation

@benvinegar

Copy link
Copy Markdown
Member

What

Completes the surface→post wire migration inside the engine's own first-party traffic. Previously the new /api/posts routes and publish_post tools landed additively while the running viewer still used the legacy /api/surfaces paths and surface-* SSE events. This points the frontend at the canonical wire.

  • Viewer fetches (viewer/src/state.ts, viewer/src/Card.tsx): /api/surfaces/:id/api/posts/:id, /api/sessions/:id/surfaces/api/sessions/:id/posts.
  • SSE events: server/events.ts union + server/app.ts broadcasts now emit post-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:

  • legacy routes /api/surfaces*, /s/:id, /session/:id/s/:surfaceId, /api/sessions/:id/surfaces, and /api/snippets*
  • MCP tools publish_surface / update_surface / list_surfaces (with their parts field)
  • the surfaceId / surfaceTitle comment-feedback wire fields and the surface comment body key

Removing those is a later, telemetry-gated step. Alias tests in test/api.test.ts / test/cli.test.ts are unchanged and still pass.

Gates

  • npm run typecheck — PASS
  • npm 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

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>
@benvinegar benvinegar merged commit fdc5b3e into main Jun 26, 2026
9 checks passed
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.

1 participant