Repository navigation
Commit 6bdc05f
fix(channels): focus a moved thread tab in the same task as its placement
Fixes the Linux WebKit flake in navigation-thread-history.spec.mjs
"dragging thread tabs reorders and crosses panes without losing the
reply", seen on PR #930 (run 38344091833) and PR #920 (run 38331018192)
with the identical `toHaveCount(0)` failure on the side pane's last tab.
Cause: `moveBy` and the drag `move` in useConversationTabs placed the tab
with `tabState.moveTab` and then focused it where it landed from a
`requestAnimationFrame`. On a loaded runner that frame arrives late. The
trace shows the first `Alt+Shift+ArrowLeft` commit at 177949 ms with the
moved tab in main at tabindex -1, the test focusing the remaining side tab
at 177960, and the stale frame then pulling focus back to the main tab
(it flips to tabindex 0 in the post-press snapshot) before the second
press at 177976. That press therefore reached a main-pane tab at index 0,
where `moveBy` returns without moving, and the side tab stayed. The same
race hits a user who moves a tab and touches anything else within a
frame; it is a product defect, so the spec is unchanged.
Fix: `placeTab` commits the move with `flushSync` and focuses the tab's
re-inserted element immediately, in the same keydown/pointerup task.
Both callers use it; nothing is deferred, so a later frame cannot take
focus away from wherever the user moved it.
Browser cases added/removed: none. One colocated Vitest regression:
a keyboard move leaves focus on the placed tab synchronously and a later
frame does not take it back; it fails on the previous code at the first
assertion (focus still on body) and passes with the fix.
Fail-then-pass: a scratch spec held every rAF callback and released it
between the test's `focus()` and `keyboard.press`, mirroring the CI
ordering. Before: 4/4 failed (2 WebKit, 2 Chromium) with the identical
`Expected: 0 / Received: 1`. After: 6/6 passed. An 80 ms delay probe was
racy (1 of 8 failed) and was replaced by the gate.
Validation (macOS, Playwright 1.63 engines): navigation-thread-history
spec 5x WebKit 50/50, 3x Chromium 30/30; vitest src/bundled/channels +
src/features/panels 564/564; tsc and biome clean. Deferred: hosted CI on
Linux WebKit; a green run does not prove the flake is gone.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Matt Toohey <[email protected]>1 parent 03b73ec commit 6bdc05f
2 files changed
Lines changed: 73 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
80 | 139 | | |
81 | 140 | | |
82 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
312 | 323 | | |
313 | 324 | | |
314 | 325 | | |
| |||
326 | 337 | | |
327 | 338 | | |
328 | 339 | | |
329 | | - | |
| 340 | + | |
330 | 341 | | |
331 | 342 | | |
332 | 343 | | |
333 | 344 | | |
334 | 345 | | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | 346 | | |
343 | 347 | | |
344 | 348 | | |
| |||
366 | 370 | | |
367 | 371 | | |
368 | 372 | | |
369 | | - | |
| 373 | + | |
370 | 374 | | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | 375 | | |
379 | 376 | | |
380 | 377 | | |
| |||
0 commit comments