Skip to content

fix(transport): handle terminal_not_found in attach() to unblock connecting state (#21344) - #21350

Draft
LesleyMurfin wants to merge 2 commits into
stablyai:mainfrom
LesleyMurfin:fix/21344-attach-terminal-not-found-unblock
Draft

LesleyMurfin wants to merge 2 commits into
stablyai:mainfrom
LesleyMurfin:fix/21344-attach-terminal-not-found-unblock

Conversation

@LesleyMurfin

@LesleyMurfin LesleyMurfin commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When reconnecting or re-attaching to a remote terminal session that has terminated or been reaped by the remote host daemon, the server returns terminal_not_found. Previously, the client's attachment logic surfaced an error message but never cleared its internal connecting = true flag. This left the UI in a permanent connecting state with an infinite loading spinner. This fix ensures that when terminal_not_found occurs during attach(), connecting is reset to false, the terminal is marked as ended, and recovery state is emitted so the UI unblocks and transitions cleanly.

What Changed

  • remote-runtime-pty-transport.ts:
    • In attach(), when resolvePersistedHostPane() returns null (due to terminal_not_found), set connecting = false, terminalEnded = true, and call emitRecoveryState() prior to surfacing the error.
    • Added terminal_not_found to isRemoteTerminalGoneMessage() to ensure that asynchronous terminal absence tokens are treated as definitive lifecycle exits.
  • remote-runtime-pty-transport-expired-pane-recovery.test.ts: Added a regression test verifying that encountering terminal_not_found during attach() immediately unblocks the connecting state and transitions the transport recovery phase to 'ended'.

Why

Without resetting connecting and transitioning to ended, getRecoveryState().phase permanently resolves to 'connecting'. As a result, the terminal surface is stuck behind an infinite loading spinner, retry buttons and manual recovery paths are disabled, and listeners are left dangling.

Linked Issue

Architectural Context (RFC #21556)

  • Roadmap Phase: Step 3: Reconnect & Attach (Gap 6)
  • Severity / Priority: P1 (High)
  • Why It Ties into the Lifecycle: When re-attaching to a terminal that exited while disconnected, the remote daemon returns terminal_not_found. The client transport was swallowing this error and leaving connecting: true latched permanently.
  • System Impact: Unblocks the client UI from an infinite loading spinner and immediately emits terminal ended/closed state so the reconciler can recover.
  • Master Tracking RFC: Part of stablyai/orca#21556

Fixes #21344
Relates to #20922, #20923

Visual Proof

N/A - Transport state machine unblocking and lifecycle transition fix.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Ran vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-expired-pane-recovery.test.ts:

  • 6 tests passed.

AI Disclosure

Claude 3.5 Sonnet / Antigravity via Revive Labs development harness.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)

This branch has not been deployed

No deployments
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.

[Bug]: remote-runtime-pty-transport attach() latches in connecting state forever on terminal_not_found

1 participant