Skip to content
Source
Sign inSign up
pingdotgg/t3code

Add shell snapshot queries for orchestration state #1973

Mergedjuliusmarmingemerged 13 commits intomain fromrefs/pull/1973/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

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](https://cursor.com/bugbot) for commit fa28310bd84d4cda1a86d80f2558a2aca56ab1cd. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

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.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 07254fda-24a9-4d63-86f5-33bb2cb2151b

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `t3code/granular-snapshot-sync`

      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. @@ -726,0 +1014,21 @@
      1014+ updatedAt = maxIso(updatedAt, row.startedAt);
      1015+ }
      1016+ if (row.completedAt !== null) {
      1017+ updatedAt = maxIso(updatedAt, row.completedAt);
      1018+ }
      1019+ }
      1020+ for (const row of stateRows) {
      1021+ updatedAt = maxIso(updatedAt, row.updatedAt);
      1022+ }
      1023+
      1024+ const repositoryIdentities = new Map(
      1025+ yield* Effect.forEach(
      1026+ projectRows,
      1027+ (row) =>
      1028+ repositoryIdentityResolver
      1029+ .resolve(row.workspaceRoot)
      1030+ .pipe(Effect.map((identity) => [row.projectId, identity] as const)),
      1031+ { concurrency: repositoryIdentityResolutionConcurrency },
      1032+ ),
      1033+ );
      1034+ const latestTurnByThread = new Map(
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High Layers/ProjectionSnapshotQuery.ts:1034

      In getShellSnapshot, the latestTurnByThread Map constructor with latestTurnRows.map((row) => [row.threadId, mapLatestTurn(row)]) keeps the last entry when duplicate thread IDs exist. Since listLatestTurnRows orders by requested_at DESC, the last entry is the oldest turn, not the latest. This causes latestTurnByThread.get(row.threadId) to return stale turn data for threads. Use a loop with has() check like getSnapshot does to keep the first (newest) entry.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts around line 1034:
      
      In `getShellSnapshot`, the `latestTurnByThread` Map constructor with `latestTurnRows.map((row) => [row.threadId, mapLatestTurn(row)])` keeps the last entry when duplicate thread IDs exist. Since `listLatestTurnRows` orders by `requested_at DESC`, the last entry is the oldest turn, not the latest. This causes `latestTurnByThread.get(row.threadId)` to return stale turn data for threads. Use a loop with `has()` check like `getSnapshot` does to keep the first (newest) entry.
      
      Evidence trail:
      apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts lines 384-402 (listLatestTurnRows with ORDER BY thread_id ASC, requested_at DESC, turn_id DESC)
      apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts lines 1034-1036 (getShellSnapshot Map constructor pattern)
      apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts lines 761, 845-848 (getSnapshot loop with has() check pattern)
      @@ -78,6 +53,18 @@
      78- }
      53+ wait: () => promise,
      54+ resolve: () => {
      55+ resolve?.();
      56+ resolve = null;
      57+ reject = null;
      58+ },
      59+ reject: (error: unknown) => {
      60+ reject?.(error);
      61+ resolve = null;
      62+ reject = null;
      63+ },
      64+ reset: () => {
      65+ promise = new Promise<void>((nextResolve, nextReject) => {
      66+ resolve = nextResolve;
      67+ reject = nextReject;
      7968 });
      80- inFlight = nextInFlight;
      81- return inFlight;
      8269 },
      8370 };
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High runtime/connection.ts:64

      createBootstrapGate().reset() orphans pending waiters by overwriting resolve/reject with new promise resolvers, leaving the old promise forever pending. When onResubscribe triggers reset() at line 132, any caller awaiting ensureBootstrapped() hangs indefinitely. Consider rejecting the old promise before creating the new one, or tracking multiple pending waiters.

      -    reset: () => {
      -      promise = new Promise<void>((nextResolve, nextReject) => {
      -        resolve = nextResolve;
      -        reject = nextReject;
      -      });
      +    reset: () => {
      +      reject?.(new Error('Bootstrap reset'));
      +      promise = new Promise<void>((nextResolve, nextReject) => {
      +        resolve = nextResolve;
      +        reject = nextReject;
      +      });
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/web/src/environments/runtime/connection.ts around lines 64-70:
      
      `createBootstrapGate().reset()` orphans pending waiters by overwriting `resolve`/`reject` with new promise resolvers, leaving the old promise forever pending. When `onResubscribe` triggers `reset()` at line 132, any caller awaiting `ensureBootstrapped()` hangs indefinitely. Consider rejecting the old promise before creating the new one, or tracking multiple pending waiters.
      
      Evidence trail:
      apps/web/src/environments/runtime/connection.ts lines 43-67 (createBootstrapGate function), lines 62-66 (reset() implementation), lines 126-130 (onResubscribe calling reset()), line 145 (ensureBootstrapped returning bootstrapGate.wait())
    4. Cursor Bugbot has reviewed your changes and found 2 potential issues.

      Autofix Details

      Bugbot Autofix prepared fixes for both issues found in the latest run.

      • ✅ Fixed: Shell thread mapping omits pendingSourceProposedPlan
        • Added pendingSourceProposedPlan: thread.latestTurn?.sourceProposedPlan to the turnState object in mapThreadShell, matching the existing behavior of the full mapThread function.
      • ✅ Fixed: Redundant mapProjectShell duplicates existing mapProject function
        • Removed mapProjectShell and widened mapProject's parameter type to a union of both OrchestrationProject and OrchestrationProjectShell, eliminating the duplicated function.

      Create PR

      Or push these changes by commenting:

      @cursor push 5d58fee812
      Preview (pingdotgg/t3code@5d58fee812)
      diff --git a/apps/web/src/store.ts b/apps/web/src/store.ts
      --- a/apps/web/src/store.ts
      +++ b/apps/web/src/store.ts
      @@ -178,7 +178,9 @@
       }
       
       function mapProject(
      -  project: OrchestrationReadModel["projects"][number],
      +  project:
      +    | OrchestrationReadModel["projects"][number]
      +    | OrchestrationShellSnapshot["projects"][number],
         environmentId: EnvironmentId,
       ): Project {
         return {
      @@ -196,25 +198,6 @@
         };
       }
       
      -function mapProjectShell(
      -  project: OrchestrationShellSnapshot["projects"][number],
      -  environmentId: EnvironmentId,
      -): Project {
      -  return {
      -    id: project.id,
      -    environmentId,
      -    name: project.title,
      -    cwd: project.workspaceRoot,
      -    repositoryIdentity: project.repositoryIdentity ?? null,
      -    defaultModelSelection: project.defaultModelSelection
      -      ? normalizeModelSelection(project.defaultModelSelection)
      -      : null,
      -    createdAt: project.createdAt,
      -    updatedAt: project.updatedAt,
      -    scripts: mapProjectScripts(project.scripts),
      -  };
      -}
      -
       function mapThread(thread: OrchestrationThread, environmentId: EnvironmentId): Thread {
         return {
           id: thread.id,
      @@ -269,6 +252,7 @@
         const session = thread.session ? mapSession(thread.session) : null;
         const turnState: ThreadTurnState = {
           latestTurn: thread.latestTurn,
      +    pendingSourceProposedPlan: thread.latestTurn?.sourceProposedPlan,
         };
         const summary: SidebarThreadSummary = {
           id: thread.id,
      @@ -1156,7 +1140,7 @@
         snapshot: OrchestrationShellSnapshot,
         environmentId: EnvironmentId,
       ): EnvironmentState {
      -  const nextProjects = snapshot.projects.map((project) => mapProjectShell(project, environmentId));
      +  const nextProjects = snapshot.projects.map((project) => mapProject(project, environmentId));
         const nextThreadIds = new Set(snapshot.threads.map((thread) => thread.id));
         let nextState: EnvironmentState = {
           ...state,
      @@ -1734,7 +1718,7 @@
       ): EnvironmentState {
         switch (event.kind) {
           case "project-upserted": {
      -      const nextProject = mapProjectShell(event.project, environmentId);
      +      const nextProject = mapProject(event.project, environmentId);
             const existingProjectId =
               state.projectIds.find(
                 (projectId) =>
      You can send follow-ups to the cloud agent here.
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      2 blocking correctness issues found. This PR introduces a new orchestration shell snapshot subscription system with database schema changes, new RPC methods, and significant rework of client-side connection/subscription architecture. Two unresolved high-severity review comments identify potential bugs in turn data ordering and bootstrap gate reset logic that could cause stale state or client hangs.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. @cursor push 5d58fee812

    7. @cursor push 5d58fee812

    8. Cursor Bugbot has reviewed your changes and found 2 potential issues.

      There are 3 total unresolved issues (including 1 from previous review).

      Autofix Details

      Bugbot Autofix prepared a fix for 1 of the 2 issues found in the latest run.

      • ✅ Fixed: Reconnect double-reset can orphan bootstrap gate promise
        • Removed the redundant bootstrapGate.reset() call at the start of reconnect(), since the onResubscribe callback already calls reset() when the WebSocket reconnects, eliminating the race that could orphan the first promise.

      Create PR

      Or push these changes by commenting:

      @cursor push 5fd2394ed4
      Preview (pingdotgg/t3code@5fd2394ed4)
      diff --git a/apps/web/src/environments/runtime/connection.ts b/apps/web/src/environments/runtime/connection.ts
      --- a/apps/web/src/environments/runtime/connection.ts
      +++ b/apps/web/src/environments/runtime/connection.ts
      @@ -155,7 +155,6 @@
           client: input.client,
           ensureBootstrapped: () => bootstrapGate.wait(),
           reconnect: async () => {
      -      bootstrapGate.reset();
             try {
               await input.client.reconnect();
               await input.refreshMetadata?.();
      You can send follow-ups to the cloud agent here.
    9. Cursor Bugbot has reviewed your changes and found 2 potential issues.

      There are 5 total unresolved issues (including 3 from previous reviews).

      Autofix Details

      Bugbot Autofix prepared a fix for 1 of the 2 issues found in the latest run.

      • ✅ Fixed: Connection listener immediately removed preventing deferred subscription
        • Moved the connection listener cleanup to only happen when a subscription is already active or a connection was successfully found, preventing the listener from being torn down before a connection appears.

      Create PR

      Or push these changes by commenting:

      @cursor push a7153a6d26
      Preview (pingdotgg/t3code@a7153a6d26)
      diff --git a/apps/web/src/environments/runtime/service.ts b/apps/web/src/environments/runtime/service.ts
      --- a/apps/web/src/environments/runtime/service.ts
      +++ b/apps/web/src/environments/runtime/service.ts
      @@ -105,11 +105,11 @@
       }
       
       function attachThreadDetailSubscription(entry: ThreadDetailSubscriptionEntry): boolean {
      -  if (entry.unsubscribeConnectionListener !== null) {
      -    entry.unsubscribeConnectionListener();
      -    entry.unsubscribeConnectionListener = null;
      -  }
         if (entry.unsubscribe !== NOOP) {
      +    if (entry.unsubscribeConnectionListener !== null) {
      +      entry.unsubscribeConnectionListener();
      +      entry.unsubscribeConnectionListener = null;
      +    }
           return true;
         }
       
      @@ -118,6 +118,11 @@
           return false;
         }
       
      +  if (entry.unsubscribeConnectionListener !== null) {
      +    entry.unsubscribeConnectionListener();
      +    entry.unsubscribeConnectionListener = null;
      +  }
      +
         entry.unsubscribe = connection.client.orchestration.subscribeThread(
           { threadId: entry.threadId },
           (item) => {
      You can send follow-ups to the cloud agent here.
      apps/server/src/ws.ts line 297Resolvedby juliusmarminge
    10. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      There are 4 total unresolved issues (including 3 from previous reviews).

      Fix All in Cursor

      Bugbot Autofix prepared a fix for the issue found in the latest run.

      • ✅ Fixed: Duplicate toShellSnapshot helper across browser test files
        • Extracted toShellSnapshot and toShellThread into a shared apps/web/test/shellSnapshotHelpers.ts module and updated both browser test files to import from it, eliminating the duplication.

      Create PR

      Or push these changes by commenting:

      @cursor push 0d0776652a
      Preview (pingdotgg/t3code@0d0776652a)
      diff --git a/apps/web/src/components/ChatView.browser.tsx b/apps/web/src/components/ChatView.browser.tsx
      --- a/apps/web/src/components/ChatView.browser.tsx
      +++ b/apps/web/src/components/ChatView.browser.tsx
      @@ -45,6 +45,7 @@
       import { useTerminalStateStore } from "../terminalStateStore";
       import { useUiStateStore } from "../uiStateStore";
       import { createAuthenticatedSessionHandlers } from "../../test/authHttpHandlers";
      +import { toShellSnapshot, toShellThread } from "../../test/shellSnapshotHelpers";
       import { BrowserWsRpcHarness, type NormalizedWsRpcRequestBody } from "../../test/wsRpcHarness";
       
       import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
      @@ -385,46 +386,6 @@
         };
       }
       
      -function toShellThread(thread: OrchestrationReadModel["threads"][number]) {
      -  return {
      -    id: thread.id,
      -    projectId: thread.projectId,
      -    title: thread.title,
      -    modelSelection: thread.modelSelection,
      -    runtimeMode: thread.runtimeMode,
      -    interactionMode: thread.interactionMode,
      -    branch: thread.branch,
      -    worktreePath: thread.worktreePath,
      -    latestTurn: thread.latestTurn,
      -    createdAt: thread.createdAt,
      -    updatedAt: thread.updatedAt,
      -    archivedAt: thread.archivedAt,
      -    session: thread.session,
      -    latestUserMessageAt:
      -      thread.messages.findLast((message) => message.role === "user")?.createdAt ?? null,
      -    hasPendingApprovals: false,
      -    hasPendingUserInput: false,
      -    hasActionableProposedPlan: false,
      -  };
      -}
      -
      -function toShellSnapshot(snapshot: OrchestrationReadModel) {
      -  return {
      -    snapshotSequence: snapshot.snapshotSequence,
      -    projects: snapshot.projects.map((project) => ({
      -      id: project.id,
      -      title: project.title,
      -      workspaceRoot: project.workspaceRoot,
      -      defaultModelSelection: project.defaultModelSelection,
      -      scripts: project.scripts,
      -      createdAt: project.createdAt,
      -      updatedAt: project.updatedAt,
      -    })),
      -    threads: snapshot.threads.map(toShellThread),
      -    updatedAt: snapshot.updatedAt,
      -  };
      -}
      -
       function updateThreadSessionInSnapshot(
         snapshot: OrchestrationReadModel,
         threadId: ThreadId,
      
      diff --git a/apps/web/src/components/KeybindingsToast.browser.tsx b/apps/web/src/components/KeybindingsToast.browser.tsx
      --- a/apps/web/src/components/KeybindingsToast.browser.tsx
      +++ b/apps/web/src/components/KeybindingsToast.browser.tsx
      @@ -26,6 +26,7 @@
       import { getRouter } from "../router";
       import { useStore } from "../store";
       import { createAuthenticatedSessionHandlers } from "../../test/authHttpHandlers";
      +import { toShellSnapshot } from "../../test/shellSnapshotHelpers";
       import { BrowserWsRpcHarness } from "../../test/wsRpcHarness";
       
       vi.mock("../lib/gitStatusState", () => ({
      @@ -169,42 +170,6 @@
         };
       }
       
      -function toShellSnapshot(snapshot: OrchestrationReadModel) {
      -  return {
      -    snapshotSequence: snapshot.snapshotSequence,
      -    projects: snapshot.projects.map((project) => ({
      -      id: project.id,
      -      title: project.title,
      -      workspaceRoot: project.workspaceRoot,
      -      defaultModelSelection: project.defaultModelSelection,
      -      scripts: project.scripts,
      -      createdAt: project.createdAt,
      -      updatedAt: project.updatedAt,
      -    })),
      -    threads: snapshot.threads.map((thread) => ({
      -      id: thread.id,
      -      projectId: thread.projectId,
      -      title: thread.title,
      -      modelSelection: thread.modelSelection,
      -      runtimeMode: thread.runtimeMode,
      -      interactionMode: thread.interactionMode,
      -      branch: thread.branch,
      -      worktreePath: thread.worktreePath,
      -      latestTurn: thread.latestTurn,
      -      createdAt: thread.createdAt,
      -      updatedAt: thread.updatedAt,
      -      archivedAt: thread.archivedAt,
      -      session: thread.session,
      -      latestUserMessageAt:
      -        thread.messages.findLast((message) => message.role === "user")?.createdAt ?? null,
      -      hasPendingApprovals: false,
      -      hasPendingUserInput: false,
      -      hasActionableProposedPlan: false,
      -    })),
      -    updatedAt: snapshot.updatedAt,
      -  };
      -}
      -
       function buildFixture(): TestFixture {
         return {
           snapshot: createMinimalSnapshot(),
      
      diff --git a/apps/web/test/shellSnapshotHelpers.ts b/apps/web/test/shellSnapshotHelpers.ts
      new file mode 100644
      --- /dev/null
      +++ b/apps/web/test/shellSnapshotHelpers.ts
      @@ -1,0 +1,41 @@
      +import type { OrchestrationReadModel } from "@t3tools/contracts";
      +
      +export function toShellThread(thread: OrchestrationReadModel["threads"][number]) {
      +  return {
      +    id: thread.id,
      +    projectId: thread.projectId,
      +    title: thread.title,
      +    modelSelection: thread.modelSelection,
      +    runtimeMode: thread.runtimeMode,
      +    interactionMode: thread.interactionMode,
      +    branch: thread.branch,
      +    worktreePath: thread.worktreePath,
      +    latestTurn: thread.latestTurn,
      +    createdAt: thread.createdAt,
      +    updatedAt: thread.updatedAt,
      +    archivedAt: thread.archivedAt,
      +    session: thread.session,
      +    latestUserMessageAt:
      +      thread.messages.findLast((message) => message.role === "user")?.createdAt ?? null,
      +    hasPendingApprovals: false,
      +    hasPendingUserInput: false,
      +    hasActionableProposedPlan: false,
      +  };
      +}
      +
      +export function toShellSnapshot(snapshot: OrchestrationReadModel) {
      +  return {
      +    snapshotSequence: snapshot.snapshotSequence,
      +    projects: snapshot.projects.map((project) => ({
      +      id: project.id,
      +      title: project.title,
      +      workspaceRoot: project.workspaceRoot,
      +      defaultModelSelection: project.defaultModelSelection,
      +      scripts: project.scripts,
      +      createdAt: project.createdAt,
      +      updatedAt: project.updatedAt,
      +    })),
      +    threads: snapshot.threads.map(toShellThread),
      +    updatedAt: snapshot.updatedAt,
      +  };
      +}
      You can send follow-ups to the cloud agent here. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 24190180b2f828c6a240b15746e791f2c5c92564. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -171,0 +186,21 @@
      186+ projectId: thread.projectId,
      187+ title: thread.title,
      188+ modelSelection: thread.modelSelection,
      189+ runtimeMode: thread.runtimeMode,
      190+ interactionMode: thread.interactionMode,
      191+ branch: thread.branch,
      192+ worktreePath: thread.worktreePath,
      193+ latestTurn: thread.latestTurn,
      194+ createdAt: thread.createdAt,
      195+ updatedAt: thread.updatedAt,
      196+ archivedAt: thread.archivedAt,
      197+ session: thread.session,
      198+ latestUserMessageAt:
      199+ thread.messages.findLast((message) => message.role === "user")?.createdAt ?? null,
      200+ hasPendingApprovals: false,
      201+ hasPendingUserInput: false,
      202+ hasActionableProposedPlan: false,
      203+ })),
      204+ updatedAt: snapshot.updatedAt,
      205+ };
      206+}

      Duplicate toShellSnapshot helper across browser test files

      Low Severity

      The toShellSnapshot function (and in ChatView.browser.tsx the companion toShellThread) is duplicated verbatim across two browser test files. These are not test-isolation copies — they perform the identical mapping. Extracting a shared test helper would prevent divergence if the shell snapshot shape changes.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 24190180b2f828c6a240b15746e791f2c5c92564. Configure [here](https://www.cursor.com/dashboard/bugbot).
    11. Bugbot Autofix prepared fixes for both issues found in the latest run.

      • ✅ Fixed: Thread detail stream missing session-set event type
        • Added 'thread.session-set' to the isThreadDetailEvent type guard and runtime check so the subscribeThread live stream now forwards session status changes to clients.
      • ✅ Fixed: Shell snapshot missing repositoryIdentity field in project mapping
        • Added the missing repositoryIdentity: project.repositoryIdentity ?? null field to the toShellSnapshot test helpers in both ChatView.browser.tsx and KeybindingsToast.browser.tsx.

      Create PR

      Or push these changes by commenting:

      @cursor push 3a5dfb886a
      Preview (pingdotgg/t3code@3a5dfb886a)
      diff --git a/apps/server/src/ws.ts b/apps/server/src/ws.ts
      --- a/apps/server/src/ws.ts
      +++ b/apps/server/src/ws.ts
      @@ -71,7 +71,8 @@
             | "thread.proposed-plan-upserted"
             | "thread.activity-appended"
             | "thread.turn-diff-completed"
      -      | "thread.reverted";
      +      | "thread.reverted"
      +      | "thread.session-set";
         }
       > {
         return (
      @@ -79,7 +80,8 @@
           event.type === "thread.proposed-plan-upserted" ||
           event.type === "thread.activity-appended" ||
           event.type === "thread.turn-diff-completed" ||
      -    event.type === "thread.reverted"
      +    event.type === "thread.reverted" ||
      +    event.type === "thread.session-set"
         );
       }
       
      
      diff --git a/apps/web/src/components/ChatView.browser.tsx b/apps/web/src/components/ChatView.browser.tsx
      --- a/apps/web/src/components/ChatView.browser.tsx
      +++ b/apps/web/src/components/ChatView.browser.tsx
      @@ -415,6 +415,7 @@
             id: project.id,
             title: project.title,
             workspaceRoot: project.workspaceRoot,
      +      repositoryIdentity: project.repositoryIdentity ?? null,
             defaultModelSelection: project.defaultModelSelection,
             scripts: project.scripts,
             createdAt: project.createdAt,
      
      diff --git a/apps/web/src/components/KeybindingsToast.browser.tsx b/apps/web/src/components/KeybindingsToast.browser.tsx
      --- a/apps/web/src/components/KeybindingsToast.browser.tsx
      +++ b/apps/web/src/components/KeybindingsToast.browser.tsx
      @@ -176,6 +176,7 @@
             id: project.id,
             title: project.title,
             workspaceRoot: project.workspaceRoot,
      +      repositoryIdentity: project.repositoryIdentity ?? null,
             defaultModelSelection: project.defaultModelSelection,
             scripts: project.scripts,
             createdAt: project.createdAt,
      You can send follow-ups to the cloud agent here.
    12. @cursor push 3a5dfb886a

    13. juliusmarminge merged thisf7fa62a

    14. juliusmarminge closed this

Sign in to join this conversation.