Skip to content

Add shell snapshot queries for orchestration state - #1973

Merged
juliusmarminge merged 13 commits into
mainfrom
t3code/granular-snapshot-sync
Apr 13, 2026
Merged

Add shell snapshot queries for orchestration state#1973
juliusmarminge merged 13 commits into
mainfrom
t3code/granular-snapshot-sync

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Apr 13, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds shell-oriented snapshot/query APIs for projects and threads, including per-thread shell summaries and detail lookups.
  • Extends the projection pipeline to maintain derived thread summary fields like latest user message time, pending approvals, pending user input, and actionable proposed plans.
  • Updates WebSocket and client state handling to consume the new orchestration snapshot shapes.
  • Adds migration support for the new projection thread summary columns and expands test coverage across server and web layers.

Testing

  • bun fmt
  • bun lint
  • bun typecheck
  • bun run test

Note

High Risk
High risk because it changes the orchestration WebSocket contract (replacing snapshot/replay/domain-event flows with subscribeShell/subscribeThread) and adds new projection-derived persisted summary columns that affect read-model correctness and client state sync.

Overview
Introduces lightweight orchestration “shell” reads and streaming updates. The server adds ProjectionSnapshotQuery.getShellSnapshot, getProjectShellById, getThreadShellById, and getThreadDetailById, plus WS RPCs orchestration.subscribeShell (snapshot + incremental shell events) and orchestration.subscribeThread (per-thread detail snapshot + live thread events), removing the prior getSnapshot/replay/domain-event subscription usage in the WS layer.

Persists and maintains per-thread shell summary fields. The projection pipeline now derives and stores latestUserMessageAt, pending approval/user-input counts, and actionable proposed-plan state into new projection_threads columns (migration 023_ProjectionThreadShellSummary), and refreshes these on relevant thread events.

Updates the web client to consume shell snapshots and opt-in thread detail. Client runtime replaces snapshot/replay recovery with shell subscription bootstrapping, applies shell events into the store via new syncServerShellSnapshot/applyShellEvent, adds targeted thread detail syncing via syncServerThreadDetail, and keeps active thread detail subscriptions warm with retainThreadDetailSubscription (idle eviction + capped cache). Authentication gate handling is adjusted to rely on router context, and tests are updated/added accordingly.

Reviewed by Cursor Bugbot for commit fa28310. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Replace orchestration snapshot/replay RPC with shell snapshot stream subscriptions

  • Removes getSnapshot, replayEvents, and onDomainEvent from the orchestration WebSocket surface and replaces them with subscribeShell and subscribeThread streaming endpoints defined in contracts/src/orchestration.ts and rpc.ts.
  • Adds getShellSnapshot, getProjectShellById, getThreadShellById, and getThreadDetailById to ProjectionSnapshotQuery, backed by new SQL queries in ProjectionSnapshotQuery.ts.
  • Extends the projection pipeline in ProjectionPipeline.ts to maintain thread summary columns (latestUserMessageAt, pendingApprovalCount, pendingUserInputCount, hasActionableProposedPlan) on relevant events; migration 023_ProjectionThreadShellSummary.ts adds these columns to projection_threads.
  • Updates the client-side environment connection in connection.ts and store in store.ts to bootstrap from a shell snapshot stream and apply incremental shell events instead of replaying domain events.
  • Adds per-thread detail subscription caching in service.ts with ref-counted retain/release and idle eviction after 2 minutes; ChatView retains a subscription while a server thread is viewed.
  • Risk: getSnapshot, replayEvents, and onDomainEvent are fully removed; any client that has not migrated to subscribeShell/subscribeThread will break.

Macroscope summarized fa28310.

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

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants