Skip to content

Ignore stale terminal RPC failures after Cloud transcript reattachment - #18037

Closed
azooz2003-bit wants to merge 12 commits into
mainfrom
fix/cloud-terminal-rpc-lifetime
Closed

azooz2003-bit wants to merge 12 commits into
mainfrom
fix/cloud-terminal-rpc-lifetime

Conversation

@azooz2003-bit

Copy link
Copy Markdown
Collaborator

Closing or redirecting a terminal transcript while Send, Stop, or Focus Terminal is waiting for an RPC reply can append the old failure to the replacement view. Fence these callbacks by disposal generation, attachment, target identity, and captured target IDs. Active attachments still report their own failures and preserve failed-send prompts for recovery.

Depends on #16065; this PR targets fix/cloud-terminal-rpc-deadline so its diff contains only the lifetime fix. Focus failures now use the same guarded action path and are emitted once.

Validation

  • Regression commit: 47d6d2975d5b841a2f24f7f5a815cb031bcefaff.
  • Fix commit: 25677e569383a99a9fd3a898328b19b85b069797.
  • From agent-chat, bun test/transcript-rpc-lifetime.test.ts: red with the regression commit's adapter (a disposed view must not receive a late terminal RPC failure), green with the fix. Covers Send, Stop, and Focus Terminal across disposal without a reader, redirection, mutable target IDs, and reattachment to identical targets; current failures still arrive.
  • bun test/terminal-rpc-errors.test.ts: passed, including prompt recovery and all 20 locales.
  • bun run check: passed (typecheck, 26 scripts, 44 tests across 13 bun:test files).
  • bun build src/main.tsx src/gallery-main.tsx --target browser --minify --splitting --outdir scratch/build-check --define 'process.env.NODE_ENV="production"': passed.
  • git diff --check 953efca947fb2f5901ec853da03acb04ed8ad49c..HEAD: passed.

No live Cloud instance or browser validation. The generic scripts/verify-local.py entrypoint is absent from this checkout; scoped Agent Chat checks ran instead.

Changelog

Fixed: Cloud Agent Chat ignores late terminal action failures after a transcript closes or switches attachments.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes Cloud Agent Chat terminal RPCs so they no longer hang past their deadline or surface stale failures after a transcript closes or switches attachments. Reopening a Cloud transcript now refreshes the terminal bindings when the agent session or surface changes.

Bug Fixes

  • Send, Stop, and Focus callbacks are fenced by disposal generation, attachment identity, and target identity; Focus failures are guarded and emitted once.
  • RPCs time out after 10 seconds even when the CLI ignores termination or keeps pipes open, and timeout errors render localized recovery copy across all 20 locales.
  • Reopening a transcript that moved terminals pins the new binding and ignores stale replies without restarting history.

Written for commit b80327e. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Terminal requests now time out after 10 seconds instead of hanging indefinitely, with a localized message advising you to try again.
    • Failures from outdated or detached terminal sessions no longer appear as errors in the current transcript.
    • Terminal error messages now retain relevant prompt context, while ordinary failures continue to show their diagnostic message.

Migrated from #16068 after correcting the PR author identity. The original head commit b80327e is preserved.

teamleaderleo and others added 12 commits September 30, 2026 11:07
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merge-main commit by scripts/merge-main.sh.
Merged by scripts/merge-main.sh: origin/main at 053ed11, the newest commit with green CI fast guards (1 newer skipped).

Merge-main-previous-head: 11ba56c
Merge-main-base: 053ed11
Merge-main commit by scripts/merge-main.sh.
Merged by scripts/merge-main.sh: origin/main at ea6e02b.

Resolved conflicts:
- Resources/Localizable.xcstrings: xcstrings key-level union

Merge-main-previous-head: 295b21a
Merge-main-base: ea6e02b
…rpc-lifetime

Preserve bounded terminal RPC deadlines and fence late failures to their transcript attachment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Keep main's agent chat localization additions alongside terminal RPC timeout copy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test: reproduce stale terminal focus when reopening a transcript

* fix: refresh terminal bindings when reopening Cloud transcripts

* test: keep terminal RPC fixture types stable across assertions
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: manaflow-ai/cmux/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1f49e214-ed88-4dc0-bab4-4f51fa4ca299
📥 Commits

Reviewing files that changed from the base of the PR and between ccefb63 and b80327e.

📒 Files selected for processing (13)
  • Resources/Localizable.xcstrings
  • agent-chat/adapters/transcript.ts
  • agent-chat/cmux-rpc.ts
  • agent-chat/server.ts
  • agent-chat/src/i18n.ts
  • agent-chat/src/session.ts
  • agent-chat/test/cmux-rpc-deadline.test.ts
  • agent-chat/test/fake-cmux-rpc.ts
  • agent-chat/test/i18n.test.ts
  • agent-chat/test/terminal-rpc-errors.test.ts
  • agent-chat/test/transcript-rpc-lifetime.test.ts
  • agent-chat/test/transcript-terminal-rebind.test.ts
  • agent-chat/types.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Note

Pull Request opener @azooz2003-bit is not an author or co-author of any commit in this PR (commit identities: teamleaderleo, claude). The CLA check will still proceed and requires every listed identity plus @azooz2003-bit to have signed.

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

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.

2 participants