Repository navigation
fix(e2e): remove four real flake sources and one caret race - #20169
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe 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 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)
✅ Passed checks (3 passed)
Full details: Description checkExplanation 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
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes
- Product fix — emoji caret race (
smart-workspace-name-input-surface.tsx): cancels the pending emoji caretrequestAnimationFrameon the ordinaryonChangepath 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 thewaitForTimeout(1_500)that sat exactly onUNFLUSHED_SETTLE_MSwith a directreadSessionpoll observing thenotFoundmiss.orchestration-idle-mail-delivery: uses the existingORCA_E2E_ORCHESTRATION_POINTER_ENTER_DELAY_MSknob so the PTY→daemon→main working-title round trip isn't bounded by the 500 ms production heuristic.slept-workspace-remount-wake: reads.remountedfrom theTerminalRecoveryRemountResultobjectremountTerminalTabForRecoverynow returns (call site missed by #20025).tasks-page: derives the probe timeout fromGITHUB_TASK_SEARCH_IDLE_MS(2 s → 4.5 s); the author calls out that this doesn't address the commit-prefix mode.
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() |
There was a problem hiding this comment.
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.

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:
linear-url-workspace-entryonPastesaw empty clipboard data and returned earlynative-chat-first-flush-racewaitForTimeout(1_500)is exactlyUNFLUSHED_SETTLE_MS, so it straddled the boundary deciding which of two hydration paths carried the testorchestration-idle-mail-deliveryORCA_E2E_ORCHESTRATION_POINTER_ENTER_DELAY_MSknobtasks-pageGITHUB_TASK_SEARCH_IDLE_MSNo timeout was raised except
tasks-page, which is called out below.One real product bug
worktree.spec.tswas not a test problem.cancelLocalInputFocusFramewas destructured but only called in the emoji branch, so the caret-restorerequestAnimationFramestayed 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
onChangepath.One stale assertion, not a flake
slept-workspace-remount-wakelooked like a 1-in-6 flake but is deterministic. #20025 changedremountTerminalTabForRecoveryto returnTerminalRecoveryRemountResultand updated the sibling call site interminal-quick-command-pre-bind-recovery.spec.ts, but missed this one, which still compared the whole object totrue.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.__storeinsidepage.evaluate.Caveat
The
tasks-pagechange 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— cleanpnpm run check:code-quality:changed— 0 findings across all three sub-gates, React Doctor includedpnpm 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.