Skip to content

test: confirm running-command prompts when closing tabs - #18965

Merged
nwparker merged 7 commits into
mainfrom
nwparker/deflake-tab-close-confirmation
Sep 7, 2026
Merged

nwparker merged 7 commits into
mainfrom
nwparker/deflake-tab-close-confirmation

Conversation

@nwparker

@nwparker nwparker commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Tab tests can count before the first tab mounts and close a busy terminal without accepting its Stop and Close confirmation. Wait for the first rendered tab and handle that confirmation. Use normal menu-item clicks and check Markdown menu dismissal after editor readiness. Preserve tab-count, focus, keyboard-typing, and menu-hidden assertions.

Validation: all nine cases previously passed in Linux CI with #18982. That application fix is now merged; the branch includes current main and awaits final E2E, CI, and review.

@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: cebae2a5-7c40-4470-96a4-bf766ce16aa6

📥 Commits

Reviewing files that changed from the base of the PR and between af5918a and c71729e.

📒 Files selected for processing (1)
  • tests/e2e/tabs.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/tabs.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The end-to-end tab tests use a shared helper to close tabs. The helper handles the running-command confirmation dialog and waits for tab removal. Test setup verifies active-tab visibility. New Terminal and New Markdown menu-item clicks use normal actionability checks. The Markdown menu-item visibility assertion runs after the editor becomes visible.

Merge Risk: 🔵 Low · up to c7172

The tab E2E updates improve synchronization around closing busy terminals, but the confirmation-close path may still race subsequent assertions with tab removal. This is a bounded test-reliability risk that should be addressed before relying on these checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the test changes, motivation, preserved assertions, and validation status. However, it omits most required template sections, including the Linked Issue, Visual Proof, Testing… Complete the required PR template sections. Add the linked issue after Fixes #, attach before-and-after visual proof or state N/A with a reason, complete the Testing checklist with platforms and verification steps, complete the AI Discl…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly describes the main change: testing the confirmation prompt that appears when closing a running terminal tab.
Full details: Description check

Explanation

The description explains the test changes, motivation, preserved assertions, and validation status. However, it omits most required template sections, including the Linked Issue, Visual Proof, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Complete the required PR template sections. Add the linked issue after Fixes #, attach before-and-after visual proof or state N/A with a reason, complete the Testing checklist with platforms and verification steps, complete the AI Disclosure section as applicable, address Review, Agent skill upstream boundary, Notes, and Checklist items, and document the dependency on application PR #18982.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

@pullfrog pullfrog 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.

ℹ️ No critical issues — one minor robustness note inline.

Reviewed changes — a single-file E2E deflake that teaches the two tab-close specs to accept the running-command confirmation dialog instead of assuming an immediate close.

  • New closeTabFromTabBar helper — hovers the tab, clicks its close button, then waits for either the Stop running command? dialog or the tab's removal, confirming via the scoped Stop and Close button when prompted.
  • Two call sites updated — closing a tab removes it from the tab bar and closing the active tab activates a neighbor tab now route through the helper; their final DOM assertions (tab count drops, a neighbor takes data-active) are unchanged.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Comment thread tests/e2e/tabs.spec.ts
const tab = tabLocator(page, tabId)
await tab.hover()
await tab.getByRole('button', { name: /^Close tab /i }).click()
const confirmation = page.getByRole('dialog', { name: 'Stop running command?' })

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.

This hardcodes the command copy variant, whereas the sibling specs (terminal-tab-close-running-confirm.spec.ts, terminal-tab-close-running-confirm-mouse.spec.ts) match both Stop running command?|Stop this agent? via a closeDialogTitle regex. Correct for the two call sites here (both create plain terminal tabs), but a future agent-tab close routed through this helper would time out rather than match. Consider matching the canonical regex.

@nwparker
nwparker force-pushed the nwparker/deflake-tab-close-confirmation branch from def04a4 to 3f606c5 Compare September 6, 2026 00:52

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta — the render-readiness fix is correct. One minor nit from the prior review remains open.

Reviewed changes — since the prior review (def04a4), this commit adds a render-readiness guard to the Tabs beforeEach.

  • beforeEach render-readiness wait — after ensureTerminalVisible, the block now reads the active tab id from the store and asserts its [data-testid="sortable-tab"] element is visible before any test body runs. This closes the flake where tab-count specs counted zero tabs before the initial terminal rendered and then mistook the late-rendering initial tab for a duplicate created by Cmd/Ctrl+T or + → New Terminal.

The closeTabFromTabBar helper and its two call sites are unchanged. The previously flagged nit (the helper hardcodes the Stop running command? dialog copy rather than the canonical Stop running command?|Stop this agent? regex its sibling specs use) still stands and is the only outstanding item; it does not block merge.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

Run ID: 60c7e0d2-2c36-4017-8f1c-a8739f7b2cae

📥 Commits

Reviewing files that changed from the base of the PR and between b6ca8da and 97dcdf6.

📒 Files selected for processing (1)
  • tests/e2e/tabs.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment thread tests/e2e/tabs.spec.ts
})
.toBe(true)
if (await confirmation.isVisible()) {
await confirmation.getByRole('button', { name: 'Stop and Close', exact: true }).click()

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

Wait for tab removal after the confirmation click.

When the confirmation is visible, the poll stops before the tab is removed. After Stop and Close is clicked, this helper returns without waiting for tab.count() === 0. The callers can then measure stale tab state during the close animation. Add a second poll after the confirmation click.

Proposed fix
   if (await confirmation.isVisible()) {
     await confirmation.getByRole('button', { name: 'Stop and Close', exact: true }).click()
   }
+  await expect.poll(async () => (await tab.count()) === 0, {
+    timeout: 5_000,
+  }).toBe(true)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await confirmation.getByRole('button', { name: 'Stop and Close', exact: true }).click()
await confirmation.getByRole('button', { name: 'Stop and Close', exact: true }).click()
}
await expect.poll(async () => (await tab.count()) === 0, {
timeout: 5_000,
}).toBe(true)

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta — the forced-click removal is the right deflake.

Reviewed changes — since the prior review (3f606c5), this commit swaps the two menu-item click({ force: true }) calls for Playwright's normal actionability-checked click().

  • New Terminal menu item — now uses a plain click(), so Playwright waits for the menu item to settle instead of clicking mid-animation.
  • New Markdown menu item — same change, resolving the Linux CI flake during the menu entrance animation.

The closeTabFromTabBar helper, the beforeEach render-readiness guard, and the two close call sites are unchanged. The prior minor nit (the helper hardcodes the Stop running command? dialog copy) remains the only open item and does not block merge.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta — the startup-focus settle is the right deflake.

Reviewed changes — since the prior review (97dcdf6), this commit adds a single startup-focus settle wait to the shared Tabs beforeEach.

  • Initial-terminal focus settle — after ensureTerminalVisible and the existing tab-visibility assertion, the block now polls until the initial terminal tab holds keyboard focus (getFocusedTerminalTabId), so the New tab menu opens into a state focus can't dismiss.

The closeTabFromTabBar helper, its two call sites, and the forced-click removal are unchanged. The previously flagged nit (the helper hardcodes the Stop running command? dialog copy) remains the only open item and does not block merge.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

Important

The focus-event capture in this delta is diagnostic scaffolding for the Linux CI flake and should be stripped before the PR merges.

Reviewed changes — since the prior review (b11d6b8), this commit adds temporary focus-event instrumentation to the Tabs beforeEach to diagnose the remaining Linux CI menu-dismiss flake.

  • beforeEach focus-event recorder — installs a window.__deflakeMenuEvents ring buffer (150 entries) that captures focus/blur/focusin/focusout/pointerdown events plus HTMLElement.prototype.focus calls, recording stacks on focus calls.
  • afterEach failure dump — when a test does not reach its expected status, logs the captured events under a [deflake-menu-events] prefix for CI diagnosis.

⚠️ Diagnostic instrumentation is not for merge

The recorder monkey-patches HTMLElement.prototype.focus and installs capture-phase listeners for every Tabs test. That is the right tool for the diagnosis in flight, and it is per-test safe (the orcaPage/electronApp fixture launches a fresh Electron instance per test, so the patch and listeners do not accumulate). But it is debug scaffolding — the __deflakeMenuEvents capture, the focus patch, and the afterEach dump should be removed once Linux CI confirms the fix, not shipped in the merged suite.

Technical details
# Remove diagnostic focus capture before merge

## Affected sites
- tests/e2e/tabs.spec.ts:92-121 — `beforeEach` installs the `__deflakeMenuEvents` recorder and patches `HTMLElement.prototype.focus`
- tests/e2e/tabs.spec.ts:128-139 — `afterEach` dumps captured events on failure

## Required outcome
- Once the flake root cause is confirmed on Linux CI, the `Tabs` suite runs without any temporary focus capture: no `__deflakeMenuEvents`, no focus monkey-patch, no `[deflake-menu-events]` dump.

## Open questions for the human
- Is the plan to keep the instrumentation only until Linux CI is green, then revert it in this same PR, or will it live a few more commits?

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta — the diagnostic removal is the correct cleanup.

Reviewed changes — since the prior review (decb380), this commit strips the temporary focus-event instrumentation the prior review flagged as debug-only, and also drops the startup focus-settle poll.

  • Removed __deflakeMenuEvents diagnostic recorder — the window.__deflakeMenuEvents ring buffer, the HTMLElement.prototype.focus monkey-patch, and the [deflake-menu-events] afterEach failure dump are gone, resolving the prior ⚠️ that the instrumentation must not ship.
  • Removed the beforeEach focus-settle poll — the initial-terminal focus gate is gone after the root cause was identified as deferred layout focus; the actionability-based menu-item click()s and the render-readiness assertion are the retained deflakes. The menu-created-terminal focus assertion (tabs.spec.ts:135) is unchanged.

The one previously flagged minor nit (the closeTabFromTabBar helper hardcodes the Stop running command? dialog copy rather than the canonical Stop running command?|Stop this agent? regex its sibling specs use) remains open and unchanged; it does not block merge.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta — the assertion relocation is correct. One pre-existing minor nit remains open.

Reviewed changes — since the prior review (50ab6c9), commit 7c2976b relocates the New Markdown menu-dismissal assertion to after editor readiness.

  • Menu-dismissal assertion relocated — in clicking "+" then "New Markdown" focuses the editor, expect(newMarkdownMenuItem).toBeHidden({ timeout: 3_000 }) now runs after the file-creation and editor-visibility barriers instead of immediately after the menu-item click. This matches the Linux CI finding that the Radix menu stays mounted (visually closed) while the file is created and the editor is focused; the 3-second timeout and the focus/typing assertions are unchanged.

ℹ️ Nitpicks

  • The closeTabFromTabBar helper still hardcodes the Stop running command? dialog copy rather than the sibling specs' Stop running command?|Stop this agent? regex. Correct for the two current plain-terminal call sites, so it does not block merge.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@nwparker

nwparker commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@pullfrog Please review the current head c71729e6f63b0ebfd80fa981eaf7aabb1cbf0906 after its application prerequisites merged. The PR test diff is unchanged; the new commit merges current main. Current E2E evidence: the changed E2E job passed, https://github.com/stablyai/orca/actions/runs/34074706619. Please verify the current merge state rather than the historical prerequisite failures. I will require all final CI checks before merging.

@pullfrog pullfrog 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.

✅ No new issues introduced by this merge. The tests/e2e/tabs.spec.ts diff is unchanged, and the changed E2E job passed (https://github.com/stablyai/orca/actions/runs/34074706619).

Reviewed changes — since the prior review (7c2976b), the branch merged current main (c71729e6f); the PR's own test diff is unchanged.

  • Merged current main — a clean two-parent merge (7c2976b + af5918a) that pulls the reviewed application prerequisites (including #18982) onto the branch. The PR diff against main is still a single file, tests/e2e/tabs.spec.ts, byte-identical to what prior reviews covered.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit e9af947 into main Sep 7, 2026
34 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* test: wait for rendered tabs and handle busy close confirmation

* test: wait for create-menu item click actionability

* test: settle initial terminal focus before create-menu actions

* test: capture menu focus events for Linux CI diagnosis

* test: remove menu diagnostics after identifying deferred layout focus

* test: check Markdown menu dismissal after editor readiness
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