Skip to content

fix(server): replay shell updates after projection read failures - #14047

Closed
voltcrash wants to merge 1 commit into
pingdotgg:mainfrom
voltcrash:t3code/fix-thinking-thread-state
Closed

voltcrash wants to merge 1 commit into
pingdotgg:mainfrom
voltcrash:t3code/fix-thinking-thread-state

Conversation

@voltcrash

@voltcrash voltcrash commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A fast first turn can finish while the new-thread draft is waiting for its shell update. If the server's coalesced shell projection read fails twice, subscribeShell currently drops that update. The client then has no reason to subscribe to the thread detail, so the draft can remain on “Thinking” until reload.

Fix

Keep the immediate projection read retry. If it also fails, return a typed subscription error instead of dropping the update. The client retries from its last applied shell cursor and replays the missing thread update. A regression test covers the failed subscription and successful replay.

Related to #14046. The reported trace shows a separate client IndexedDB failure, so this server-side fix does not close that issue.

Validation

  • vp test run apps/server/src/server.test.ts -t 'subscribeShell (replays a shell update|retries a transient)' (2 passed)
  • vp run --filter t3 typecheck
  • vp lint apps/server/src/ws.ts apps/server/src/server.test.ts (passed; existing warnings in the test file)
  • git diff --check upstream/main...HEAD

Generated by GPT-6-Sol in Codex via T3 Code.

Summary by CodeRabbit

  • Bug Fixes
    • Shell updates are no longer silently dropped when projection reads fail. Failed reads are retried once, and persistent failures are reported so subscriptions can be retried.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 28, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 28, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at fdb820e

Macroscope's review found this PR approvable — This is a focused server-side bug fix that preserves normal shell-stream behavior while allowing repeated projection read failures to surface through the existing retryable error path. A targeted regression test covers the failed subscription and subsequent replay, with no schema, deployment, default, or static-analysis changes.

Notes:

  • Diff unchanged. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1ae7f61e-3a8f-4b66-b5cd-bcbaac8198a0

📥 Commits

Reviewing files that changed from the base of the PR and between d15210c and fdb820e.

📒 Files selected for processing (2)
  • apps/server/src/server.test.ts
  • apps/server/src/ws.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Shell projection reads now retry once and propagate persistent failures as OrchestrationGetSnapshotError through the shell stream. A test checks that a failed subscription is followed by a successful subscription that emits the thread update.

Changes

Shell projection error handling

Layer / File(s) Summary
Retry and propagate projection errors
apps/server/src/ws.ts, apps/server/src/server.test.ts
Shell projection reads retry once. Persistent failures propagate as OrchestrationGetSnapshotError through projection and event coalescing. The test checks that the first subscription fails and a later subscription emits the thread update.

Priority: ⬆️ High

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: High

Suggested reviewers: t3dotgg, juliusmarminge

Merge Risk: ⚪ Minimal · up to fdb82

The shell subscription can retry from its last applied update after a projection-read failure. No outstanding issue identified here blocks merging after normal checks.

Architecture Summary

Architecture risk: 🟡 Medium · up to fdb82

The change affects 1 system.

Changed systems: apps/server

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — apps/server (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in apps/server/src/server.test.ts: Added a test with a single replayed thread event and a shell projection that fails on its first two reads, then returns the thread shell. It asserts that the first subscription fails after two attempts and that a subsequent subscription emits the thread update after the third read.
  • observed — Modified behavior in apps/server/src/ws.ts: toShellStreamEvent now declares OrchestrationGetSnapshotError as a possible failure instead of being infallible.
  • observed — Modified behavior in apps/server/src/ws.ts: retryShellProjectionRead now retries a failed projection read once and, if it still fails, maps the cause to OrchestrationGetSnapshotError. It no longer logs the failure and returns None, which previously dropped the stream item.
  • observed — Modified behavior in apps/server/src/ws.ts: projectUpsertOrRemove now propagates OrchestrationGetSnapshotError from the shared projection-read helper instead of declaring that it cannot fail.

Reliability and maintainability

  • inferred — Risk-relevant change factors for apps/server: blast_radius_1; blast_radius_2; direct_dependents_1; direct_dependents_2
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue [#14046] requires the client to recover the completed first turn instead of remaining in Thinking. apps/server/src/ws.ts now retries shell projection reads once and propagates `OrchestrationGe…
Out of Scope Changes check ✅ Passed The changes are limited to shell subscription error propagation and its regression test. Both changes support the recovery path for issue [#14046]. No unrelated production behavior or unrelated tests …
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Title check ✅ Passed The title clearly describes the primary change: replaying shell updates after projection read failures.
Description check ✅ Passed The description explains the problem, the fix, the regression test, validation results, and issue context. It does not use the template headings or include the checklist, but it provides the required …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@Jardo-51

Copy link
Copy Markdown
Contributor

Thanks for picking this up. The trace for #14046 is now posted in #14046 (comment), and it doesn't match the path this PR fixes.

  • No shell projection read failed. From 04:43:55 to 04:54 UTC the only failed server spans are unrelated source-control CLI probes. There are no failed projection reads and no orchestration shell projection refetch failed warning.
  • The client received and applied the shell update. EnvironmentShellState.applyItems ran at 04:52:30.556, and it triggered EnvironmentThreadState.make at 04:52:30.659.
  • The client failed after that. EnvironmentThreadState.make threw InvalidStateError: ... The database connection is closing. from web.connectionStorage.readDatabaseValue, because the browser's IndexedDB connection had been dead since the tab woke from sleep. The thread therefore never got a snapshot fetch or a subscribeThread until the reload.

With this PR applied, that occurrence would play out the same way. Dropping a shell update after two failed reads may still be worth fixing on its own, since it could produce the same symptom. Could you change Fixes #14046 to Related to #14046, so that merging this doesn't close the issue while the client-side cause is still open?

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 1, 2026 — with ChatGPT Codex Connector
@macroscopeapp
macroscopeapp Bot dismissed their stale review October 1, 2026 15:59

Dismissing prior approval to re-evaluate fdb820e

@maria-rcks

Copy link
Copy Markdown
Collaborator

Note

Written by claude-opus-5-5 on behalf of Maria

Hi! We are cleaning up open PRs, and this one appears to have been created with an older model (gpt-6-sol). If this change is really important, we recommend rebuilding the PR with a newer model if possible.

@maria-rcks maria-rcks closed this Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants