Skip to content

fix(remote): don't classify a stale/gone remote handle as agent completion - #9263

Merged
OrcaWin merged 8 commits into
stablyai:mainfrom
xianjianlf2:fix/remote-disconnect-false-completion-9151
Jul 23, 2026
Merged

OrcaWin merged 8 commits into
stablyai:mainfrom
xianjianlf2:fix/remote-disconnect-false-completion-9151

Conversation

@xianjianlf2

@xianjianlf2 xianjianlf2 commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A paired or SSH runtime disconnect could be misclassified as a clean agent completion. The viewer collapsed an unreachable/stale remote handle into the same result as an authoritative inspection proving that the agent process had exited, which could trigger a false completion notification and attention state.

Closes #9151

Fix

  • Route process inspection to the runtime that owns the terminal, through its daemon or SSH relay to the PTY provider.
  • Return one atomic, discriminated inspection result so transport loss, stale handles, explicit stops, real process exits, and genuine idle completion remain distinct.
  • Treat transport or routing uncertainty as unknown evidence: clear any armed idle sample and require two fresh authoritative idle samples after recovery.
  • Keep daemon protocol compatibility explicit for mixed versions and fail safely when an owner cannot provide authoritative inspection.

Testing

  • Deterministic remote-completion authority oracle covering transport loss, reconnect recovery, explicit stop, real exit status, and genuine successful completion.
  • Revert check: the candidate passes all four oracle scenarios; reverting the fix reproduces three false-completion failures.
  • Focused regression suites: 10 files / 1,259 tests and 10 files / 404 tests passed on current main.
  • Typecheck, full lint, and all 47 reliability gates passed.
  • Headed macOS Orca server with a separately paired browser client exercised disconnect/reconnect and explicit stop; headless server parity also passed.

…etion

When a paired remote runtime connection drops, terminal.inspectProcess fails
with no_connected_pty / terminal_handle_stale / terminal_gone. That error was
swallowed into { foregroundProcess: null, hasChildProcesses: false } —
byte-for-byte the same result as a successful inspection confirming no agent
process — so two inspection cycles during a disconnect dispatched a confirmed
process-exit completion (orange attention + notification) while the remote
agent was still working.

Carry a discriminated 'unavailable: true' outcome from remote inspection and
have the completion coordinator treat it as unknown liveness: preserve agent
evidence and exit-arming state, back off like a failed inspection, and only
confirm exits from successful samples. Other inspection consumers keep their
existing no-process fallback behavior.

Closes stablyai#9151
@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Runtime terminal inspection results now expose unavailable: true for stale or gone remote handles. The completion coordinator treats these results as unknown liveness, increments inspection errors, schedules another poll, and skips recognition and completion detection. Related runtime and PTY inspection tests were updated. The remote-host-authority reliability gate now includes expanded disconnect/reconnect completion coverage, assertions, evidence, criteria, and known-gap descriptions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the problem, fix, and testing, but it is missing required template sections like Summary, Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections and briefly document screenshots or no visual change, AI review findings, security considerations, and any platform-specific notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code now treats unavailable remote inspections as unknown liveness and avoids completion logic, matching #9151's requirements.
Out of Scope Changes check ✅ Passed The added tests and reliability-gate updates are tied to the remote-completion bug and its regression coverage, with no clear unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is concise and accurately describes the main change: stale remote handles are no longer treated as agent completion.

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.

@AmethystLiang AmethystLiang self-assigned this Jul 18, 2026
@AmethystLiang
AmethystLiang self-requested a review July 18, 2026 16:47
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
xianjianlf2 and others added 4 commits July 22, 2026 23:25
…etion

When a paired remote runtime connection drops, terminal.inspectProcess fails
with no_connected_pty / terminal_handle_stale / terminal_gone. That error was
swallowed into { foregroundProcess: null, hasChildProcesses: false } —
byte-for-byte the same result as a successful inspection confirming no agent
process — so two inspection cycles during a disconnect dispatched a confirmed
process-exit completion (orange attention + notification) while the remote
agent was still working.

Carry a discriminated 'unavailable: true' outcome from remote inspection and
have the completion coordinator treat it as unknown liveness: preserve agent
evidence and exit-arming state, back off like a failed inspection, and only
confirm exits from successful samples. Other inspection consumers keep their
existing no-process fallback behavior.

Closes stablyai#9151

@OrcaWin OrcaWin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused report and initial fix. I reworked the final patch so completion inspection is owned by the runtime that actually owns the process:

  • transport loss and stale routing remain unknown rather than becoming idle evidence;
  • reconnect requires fresh authoritative samples before completion;
  • daemon, SSH relay, and local PTY providers share one atomic inspection contract;
  • the deterministic regression oracle fails when the fix is reverted and passes on the candidate.

Validated on current main with the focused suites, typecheck, full lint/reliability gates, a headed paired-client flow, and headless parity.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 27d06bb7-9140-44ac-818f-82bdc102a9c0

📥 Commits

Reviewing files that changed from the base of the PR and between ab38c96 and 78efd35.

📒 Files selected for processing (1)
  • config/reliability-gates.jsonc

"pnpm exec vitest run --config config/vitest.config.ts tests/e2e/remote-terminal-tab-retirement.unit.test.ts",
"pnpm test:repro:remote-agent-session",
"pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts src/main/runtime/terminal-orphan-owner.test.ts src/main/runtime/terminal-orphan-topology.test.ts src/renderer/src/runtime/web-session-terminal-orphan-recovery.test.ts src/renderer/src/runtime/web-session-terminal-orphan-mixed-version.test.ts src/renderer/src/runtime/web-session-tabs-sync.test.ts --maxWorkers=1"
"Manual headed paired-server journey: isolated Orca desktop host + separate paired web client + real Codex process + 20-second WebSocket fault + reconnect + explicit stop",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C3 'reliability-gates\.jsonc|commands.*reliability|reliability.*commands' \
  -g '*.{ts,tsx,js,mjs,cjs,json,jsonc,yml,yaml}' .

Repository: stablyai/orca

Length of output: 2262


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Candidate files:"
fd -a 'check-reliability-gates|reliability-gates' . | sed 's#^\./##'

echo
echo "check-reliability-gates outline:"
ast-grep outline config/scripts/check-reliability-gates.mjs 2>/dev/null || true

echo
echo "Relevant check file:"
cat -n config/scripts/check-reliability-gates.mjs

echo
echo "Gates around line 1432:"
sed -n '1380,1455p' config/reliability-gates.jsonc | cat -n | sed 's#^`#1432`+#'

echo
echo "Nearby commands/coverage/evidence structure:"
sed -n '1300,1370p' config/reliability-gates.jsonc | cat -n | sed 's#^`#1300`+#'
sed -n '1455,1505p' config/reliability-gates.jsonc | cat -n | sed 's#^`#1455`+#'

Repository: stablyai/orca

Length of output: 38187


Keep the manual journey out of commands.

check-reliability-gates.mjs treats commands as executable coverage and records evidence run command entries against it; moving this prose into coverageNotes/evidenceRuns avoids treating the manual description as a runnable gate command.

@OrcaWin OrcaWin closed this Jul 23, 2026
@OrcaWin OrcaWin reopened this Jul 23, 2026
@OrcaWin OrcaWin closed this Jul 23, 2026
@OrcaWin OrcaWin reopened this Jul 23, 2026
@OrcaWin
OrcaWin marked this pull request as draft July 23, 2026 07:44
@OrcaWin
OrcaWin marked this pull request as ready for review July 23, 2026 07:44
@OrcaWin
OrcaWin merged commit 7ab6014 into stablyai:main Jul 23, 2026
12 of 14 checks passed
brennanb2025 added a commit that referenced this pull request Jul 23, 2026
…s-access-other-apps-data-prompt-keeps-re

Both sides bumped the daemon protocol to 27 (main: completion-process
inspection #9263; this PR: preflight-cache replacement). Resolve by
moving this PR's replacement bump to 28 so main-built v27 daemons,
which lack the preflight fix, are also retired; completion inspection
stays gated at >=27 and v27 joins PREVIOUS_DAEMON_PROTOCOL_VERSIONS.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Remote disconnect is misclassified as agent completion

3 participants