Skip to content

test(runtime): cover remote terminal retirement across paired viewers - #10053

Merged
OrcaWin merged 1 commit into
mainfrom
sta-2115-remote-terminal-respawn
Jul 23, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
sta-2115-remote-terminal-respawn

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a deterministic cross-boundary regression test joining host-authoritative terminal retirement with two independent viewer mirrors
  • assert one durable flush, one same-epoch higher-version publication, persisted tab/layout removal, reconnect replay, and stale-publication rejection
  • record the byte-identical oracle as red before fix(terminal): make remote agent sessions host-authoritative #9687, red on fix(runtime): prune stale headless session tabs #9053, and green on current main
  • document headed desktop pairing as the primary live topology, headless serve as secondary parity, and SSH/relay as provider-specific coverage

Findings

Current main already contains the durable host-side lifecycle fix from #9687 and related reconnect/ownership work. PR #9053 fails this harness because its stale-headless pruning retains the pinned persisted surface, so #9053 should be closed or superseded rather than adopted.

Related: #9352 and STA-2115.

Validation

  • 336 focused runtime, provider, transport, retirement, and viewer reconciliation tests
  • pnpm typecheck
  • pnpm check:reliability-gates
  • pnpm check:max-lines-ratchet
  • targeted oxlint and git diff --check
  • secondary build-backed headless encrypted-pairing repro with a real daemon PTY

Remaining gaps

  • no live headed Orca desktop server plus separate persistent paired-client journey for this issue
  • no live WSL, physical SSH, Windows, Linux, or mobile viewer run; those paths retain deterministic contract/fault-injection coverage

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an E2E unit test for remote terminal tab retirement after host PTY exit. The test verifies retirement publication versions, empty terminal tabs, workspace cleanup, viewer reconciliation, and prevention of stale publication resurrection. The reliability gate now includes the test command and file, assertion references, topology coverage labels, execution evidence, updated red-green results, and documented live-environment gaps.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and testing, but misses required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing sections with screenshot status, cross-platform review details, security findings, and any platform-specific notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: adding remote terminal retirement coverage across paired viewers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@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: 2

🧹 Nitpick comments (1)
tests/e2e/remote-terminal-tab-retirement.unit.test.ts (1)

194-207: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Non-obvious stale/replay sequence would benefit from a short explanatory comment.

This block exercises a subtle invariant (an exact-current-replay of the already-applied retirement publication is allowed, but the older live publication stays rejected even after acceptReplayedWebSessionTabsSnapshot). A one-line "why" comment would help future readers avoid mistaking the repeated toBe(false) checks for redundancy.

Based on coding guidelines: "Add concise, ideally one-line comments only for non-obvious code, explaining why rather than how."

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 852d5c7b-bed4-4f0e-9684-c1b0e5d3ce96

📥 Commits

Reviewing files that changed from the base of the PR and between 4fce2de and 0972478.

📒 Files selected for processing (2)
  • config/reliability-gates.jsonc
  • tests/e2e/remote-terminal-tab-retirement.unit.test.ts

Comment on lines +106 to +116
terminalLayoutsByTabId: {
[TAB_ID]: {
root: { type: 'leaf', leafId: LEAF_ID },
activeLeafId: LEAF_ID,
expandedLeafId: null,
ptyIdsByLeafId: { [LEAF_ID]: PTY_ID }
}
},
sleepingAgentSessionsByPaneKey: { [`${TAB_ID}:${LEAF_ID}`]: {} as never }
}
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Retirement isn't asserted to clear sleepingAgentSessionsByPaneKey.

The fixture seeds sleepingAgentSessionsByPaneKey[${TAB_ID}:${LEAF_ID}] for the exact pane being retired, but no assertion after onPtyExit verifies this entry is removed. Since the test's stated purpose is durable retirement of the surface, a stale sleeping-agent-session entry for a permanently retired pane would go undetected.

🐛 Suggested additional assertion
     expect(session.tabsByWorktree[WORKTREE_ID]).toEqual([])
     expect(session.terminalLayoutsByTabId[TAB_ID]).toBeUndefined()
+    expect(session.sleepingAgentSessionsByPaneKey[`${TAB_ID}:${LEAF_ID}`]).toBeUndefined()

Also applies to: 191-192

Comment on lines +132 to +138
const runtime = new OrcaRuntimeService({
getWorkspaceSession: () => session,
setWorkspaceSession: (next) => {
session = next
},
flushOrThrow
} as never)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify OrcaRuntimeService's constructor parameter shape matches the fixture.
ast-grep run --pattern 'class OrcaRuntimeService {
  constructor($_) {
    $$$
  }
}' --lang typescript src/main/runtime/orca-runtime.ts

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files matching orca-runtime/orca runtime:\n'
fd -i 'orca.*runtime|runtime.*orca|orca' . | sed -n '1,120p'

printf '\nTest file snippets:\n'
if [ -f tests/e2e/remote-terminal-tab-retirement.unit.test.ts ]; then
  wc -l tests/e2e/remote-terminal-tab-retirement.unit.test.ts
  sed -n '1,230p' tests/e2e/remote-terminal-tab-retirement.unit.test.ts | cat -n
fi

printf '\nSearch OrcaRuntimeService references:\n'
rg -n "OrcaRuntimeService|constructor\\(" -S . --glob '!node_modules' --glob '!dist' --glob '!build' | sed -n '1,200p'

Repository: stablyai/orca

Length of output: 50370


Avoid as never on the OrcaRuntimeService test double.

as never disables TypeScript checking of this dependency object, so typo’d property names or mismatched callbacks in the test fixture would compile despite bypassing the real constructor contract. Use a safer typed cast, for example as unknown as ConstructorParameters<typeof OrcaRuntimeService>[0].

@OrcaWin
OrcaWin merged commit 8cb0b8d into main Jul 23, 2026
2 checks passed
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.

1 participant