Skip to content

test(e2e): mount-authority spec polls through the host's "can't answer yet" terminal list - #30743

Merged
nwparker merged 2 commits into
mainfrom
nwparker/e2e-mount-authority-unavailable-poll
Oct 19, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/e2e-mount-authority-unavailable-poll

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​43
Prod 0 0 0 0

ELI5

One end-to-end test asks Orca for its terminal list again and again until the list looks right. For a split second while a workspace first opens, Orca answers "I can't say yet", which is on purpose. The test treated that answer as a crash and stopped asking, so it failed on slow CI machines. The test now waits through that answer and keeps asking.

What Changed

The mechanism, confirmed by instrumenting a local build: when the workspace is first activated, the renderer publishes its newly mounted tabs before their panes have attached, so every leaf carries ptyId: null. The host's remount guard (isLeafRemountingLivePty, from #29252) keeps an existing binding only when ptyController.hasPty already knows the PTY, and at that moment it doesn't yet. For one graph update (about 10–60 ms locally) every terminal in the workspace, including the untouched canary, reads as unbound. While the adoption spawns are in flight, terminal.list refuses with terminal_surface_ownership_unavailable (pty-terminal-summary.ts:60) instead of reporting them as orphans. Playwright's expect.poll retries failed matchers but ends immediately when the polled callback throws, so a single refusal failed the test.

The change:

  • tests/e2e/helpers/terminal-inventory-observation.ts: readFreshTerminalInventory already treated terminal_liveness_unavailable as "no observation yet". It now treats terminal_surface_ownership_unavailable the same way.
  • The spec's readWorktreeTerminals goes through that helper. All three of its callers are polls whose matchers reject an empty or undefined read.

Why

  • The refusal is the host's documented answer while it can't yet name a live PTY's pane. A test that polls for the settled state should poll through it, just as this helper already polls through the liveness refusal.
  • I chose to reuse the existing helper rather than add a try/catch to this one spec. Its two other callers are also polls, so they get the same protection.
  • I didn't change the host's remount guard in this PR. The roughly 10 ms window in which every terminal reads as unbound is a separate, low-impact product transient that predates today's merges. It isn't what failed the test, and changing what the host publishes needs its own review.

Is main broken? No. On current main (36913fd) the spec passed 6 of 6 and 8 of 8 locally with the layout-owner switch on, and 6 of 6 with it off. The job that failed is advisory (not in verify.needs) and was added today (#30582), which is why this test, which has always been timing-dependent, has only now started showing up on unrelated PRs. No recent merge caused it.

Linked Issue

N/A (CI flake found on #30728 and #30734)

Visual Proof

N/A: test-only change, with no UI or behavior change.

Testing

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

On macOS, with headless Electron and ORCA_BACKGROUND_LAUNCH=1:

  • Reproduced deterministically: I injected two terminal_surface_ownership_unavailable refusals into terminal.list right after activation. The spec as it is on main fails with exactly the CI error. With this fix, the same injection passes.
  • Instrumented a tight terminal.list loop across activation. In both switch modes, all three terminals read ORPHAN for about 10 ms right after the first-mount graph publish, and the host logged knows: false from hasPty for every leaf.
  • Ran the unmodified fixed spec three times with the layout-owner switch on: 3 of 3 passed.
  • Added terminal-inventory-observation.unit.test.ts: it fails on main for the ownership refusal and passes with the fix.
  • Ran the full "static analysis and typecheck" job steps locally, including all ratchets: all passed.

AI Disclosure

Review

  • Codex (gpt-6.1-sol, high): no findings.
  • Opus: no blocking findings. Its one nit, that a comment said "null" where the code returns undefined, is fixed.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Test-only change. It has no security, platform, SSH, mobile or wire impact.

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)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…terminal list

First-mount adoption briefly makes terminal.list refuse with
terminal_surface_ownership_unavailable. Thrown out of an expect.poll
callback, that ended the poll instead of retrying it, so the spec failed
whenever a slow runner's probe landed in that window.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 16886f4f-7f4e-497f-aeff-a8e0011a2e05
📥 Commits

Reviewing files that changed from the base of the PR and between 36913fd and 21bbed5.

📒 Files selected for processing: 3
  • tests/e2e/helpers/terminal-inventory-observation.ts
  • tests/e2e/helpers/terminal-inventory-observation.unit.test.ts
  • tests/e2e/live-background-terminal-mount-authority.spec.ts

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

📝 Walkthrough

The inventory helper now returns null for errors containing terminal_liveness_unavailable or terminal_surface_ownership_unavailable. It continues to throw other errors. The live terminal mount test uses the helper and tolerates unavailable inventory results during polling.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 21bbe

The updated test retries transient inventory refusals without weakening its initial terminal check. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the end-to-end mount-authority spec and its retry behavior for temporarily unavailable terminal-list responses.
Description check Passed The description is complete and focused. It explains the failure, the mechanism, the rationale, the exact code changes, testing evidence, scope, and checklist status. The Linked Issue section says N/A…
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.
Full details: Description check

Explanation

The description is complete and focused. It explains the failure, the mechanism, the rationale, the exact code changes, testing evidence, scope, and checklist status. The Linked Issue section says N/A despite the template requesting an issue link, but the explanation of the CI flake provides sufficient context for this test-only change.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · 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.

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