Skip to content

fix(e2e): remove four real flake sources and one caret race - #20169

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-e2e-flakes
Sep 12, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-e2e-flakes

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

What

Five E2E specs were treated as "flaky main". Investigating each against CI history showed only some of them were.

Four are genuine flakes — each existed since 2026-08-27, ran in all six recent main runs, and failed exactly once. Each fails on a timing boundary the test cannot control:

Spec Root cause Fix
linear-url-workspace-entry Pasted before X selection ownership landed, so onPaste saw empty clipboard data and returned early Gate the paste on a clipboard read-back
native-chat-first-flush-race A bare waitForTimeout(1_500) is exactly UNFLUSHED_SETTLE_MS, so it straddled the boundary deciding which of two hydration paths carried the test Observe the not-yet-flushed read through the same IPC
orchestration-idle-mail-delivery Asserted a PTY to daemon to main round trip beats a 500 ms production heuristic Use the existing ORCA_E2E_ORCHESTRATION_POINTER_ENTER_DELAY_MS knob
tasks-page The probe timeout was the one figure in the file not derived from GITHUB_TASK_SEARCH_IDLE_MS Derive it, as the file already does for two other timings

No timeout was raised except tasks-page, which is called out below.

One real product bug

worktree.spec.ts was not a test problem. cancelLocalInputFocusFrame was destructured but only called in the emoji branch, so the caret-restore requestAnimationFrame stayed armed through ordinary typing. A late frame could yank the caret back to the post-emoji position mid-input and scramble the value.

This affects any fast typist, key repeat, or IME commit immediately after an emoji shortcode completes — not just tests. Fixed by cancelling the pending frame on the non-emoji onChange path.

One stale assertion, not a flake

slept-workspace-remount-wake looked like a 1-in-6 flake but is deterministic. #20025 changed remountTerminalTabForRecovery to return TerminalRecoveryRemountResult and updated the sibling call site in terminal-quick-command-pre-bind-recovery.spec.ts, but missed this one, which still compared the whole object to true.

Ancestry confirms it: the spec failed in the single run containing #20025 and passed in all five predating it. Typecheck cannot catch this because the call goes through window.__store inside page.evaluate.

Caveat

The tasks-page change is a timeout raise, just a derived one. It does not address the secondary mode where a keystroke gap above 750 ms commits a prefix and the assertion can then never match. The durable fix is an env-overridable idle constant.

Validation

  • pnpm tc — clean
  • pnpm run check:code-quality:changed — 0 findings across all three sub-gates, React Doctor included
  • pnpm test src/renderer/src/components/new-workspace/ — 18 files, 164 tests passing (covers the product change)

E2E itself is not run here; these are main-branch flakes and the proof is the CI history cited above.

Four E2E specs failed once each across six main runs. Each traces to a
timing boundary the test could not control, not to product instability:

- linear-url-workspace-entry: pasted before X selection ownership landed,
  delivering stale text. Gate on a clipboard read-back.
- native-chat-first-flush-race: a bare 1_500ms sleep is exactly
  UNFLUSHED_SETTLE_MS, so it straddled the boundary deciding which of two
  hydration paths carried the test. Observe the not-yet-flushed read
  instead; a notFound is never cached, so this cannot perturb hydration.
- orchestration-idle-mail-delivery: asserted that a PTY -> daemon -> main
  round trip beats a 500ms production heuristic. Use the existing
  ORCA_E2E_ORCHESTRATION_POINTER_ENTER_DELAY_MS knob.
- tasks-page: the probe timeout was the one figure in the file not derived
  from GITHUB_TASK_SEARCH_IDLE_MS.

worktree.spec.ts exposed a real product race rather than a test bug: the
emoji caret-restore frame stayed armed through ordinary typing, so a
late frame could yank the caret back mid-input. Cancel it on the
non-emoji onChange path.

Also repairs a stale assertion: #20025 changed
remountTerminalTabForRecovery to return a result object and updated the
sibling call site but missed this one, so the comparison to `true` could
never pass. It is a deterministic break, not a flake.
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview 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: e4233523-86c2-46f7-9c14-0229560eb175

📥 Commits

Reviewing files that changed from the base of the PR and between da5d555 and 4367ff9.

📒 Files selected for processing (6)
  • src/renderer/src/components/new-workspace/smart-workspace-name-input-surface.tsx
  • tests/e2e/linear-url-workspace-entry.spec.ts
  • tests/e2e/native-chat-first-flush-race.spec.ts
  • tests/e2e/orchestration-idle-mail-delivery.spec.ts
  • tests/e2e/slept-workspace-remount-wake.spec.ts
  • tests/e2e/tasks-page.spec.ts

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


📝 Walkthrough

Walkthrough

The renderer now cancels pending emoji cursor-restoration work before applying normal input updates. E2E tests now wait for asynchronous clipboard and IPC conditions, extend orchestration timing, derive task-search polling timeouts, and read the remount result object correctly.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 4367f

The targeted input and E2E synchronization changes are supported by the available checks, with no established merge-blocking risk.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the changes, root causes, scope, caveat, and validation results. However, it omits the required Linked Issue, Visual Proof or explicit N/A, checklist confirmations, and severa… Add the required template sections. Include a linked issue after Fixes #, provide visual proof or state N/A with a reason, complete the Testing checkboxes and platform details, address AI Disclosure, Review, Agent skill upstream boundar…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: four E2E flake fixes and one caret race fix.
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 explains the changes, root causes, scope, caveat, and validation results. However, it omits the required Linked Issue, Visual Proof or explicit N/A, checklist confirmations, and several template sections.

Resolution

Add the required template sections. Include a linked issue after Fixes #, provide visual proof or state N/A with a reason, complete the Testing checkboxes and platform details, address AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist items, and retain the existing change rationale and validation results.

  • 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 suggestion inline.

Reviewed changes

  • Product fix — emoji caret race (smart-workspace-name-input-surface.tsx): cancels the pending emoji caret requestAnimationFrame on the ordinary onChange path so a late frame can no longer reset the selection mid-typing. The only frame that sets a selection range is the emoji one, so cancelling here is safe.
  • linear-url-workspace-entry: pastes only after a clipboard read-back confirms the write landed and X selection ownership is established.
  • native-chat-first-flush-race: replaces the waitForTimeout(1_500) that sat exactly on UNFLUSHED_SETTLE_MS with a direct readSession poll observing the notFound miss.
  • orchestration-idle-mail-delivery: uses the existing ORCA_E2E_ORCHESTRATION_POINTER_ENTER_DELAY_MS knob so the PTY→daemon→main working-title round trip isn't bounded by the 500 ms production heuristic.
  • slept-workspace-remount-wake: reads .remounted from the TerminalRecoveryRemountResult object remountTerminalTabForRecovery now returns (call site missed by #20025).
  • tasks-page: derives the probe timeout from GITHUB_TASK_SEARCH_IDLE_MS (2 s → 4.5 s); the author calls out that this doesn't address the commit-prefix mode.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

return
}
// A pending emoji caret frame would otherwise yank the caret back mid-typing.
cancelLocalInputFocusFrame()

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 correctly stops the caret yank, but nothing in the suite pins it: SmartWorkspaceNameField.ime-enter.test.tsx only asserts the replaced value, so deleting this line leaves every test green. A focused regression test — complete a shortcode, dispatch a following input event, and assert the scheduled caret frame is cancelled or does not run — would keep a future refactor from reintroducing the race.

@brennanb2025
brennanb2025 merged commit 556a777 into main Sep 12, 2026
35 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/fix-e2e-flakes branch September 12, 2026 01:37
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