Repository navigation
fix(settings): keep a reopened Settings open when a step back lands late - #2023
Conversation
Two history traversals asked for before Settings opened could land after it and close it, so on a slow runner the demo regression waited 30 s for a dialog that was gone (#2000), and a fast close and reopen on a slow phone did the same: - Closing Settings steps back off its entries. Meanwhile the app's address bar writes the address on the entry being left, and that replaceState released Settings' claim on its step, so the late landing looked like a Back of the user's. A replaceState now lets go of the step only when it changes the Settings entry or the opening it belongs to. - A phone's sheet (the palette) closed by Escape steps back off its own entry. Settings opened before that step landed pushed over the sheet's entry, and the landing under it read as Back to the entry the sheet opened over. sheetHistory now answers whether a popstate is such a step (historyKeys' sheetStep, so neither module imports the other or changes their load order), and Settings then stays and makes its entries again. The demo regression holds each step until Settings is open again, and the page's timers with it, so it no longer depends on the runner's speed. Refs #2000
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Sheet-step event coordination src/lib/historyKeys.ts, src/lib/sheetHistory.ts, src/lib/sheetHistory.test.ts |
sheetHistory exposes whether a popstate event belongs to a sheet step. Tests cover event delivery and step-state reporting. |
Settings entry reconciliation src/lib/settingsHistory.ts, src/lib/settingsHistory.test.ts, src/lib/sheetHistory.test.ts |
settingsHistory tracks the sheet entry beneath Settings, preserves pending traversal for same-entry replacements, and handles matching sheet steps without treating them as user Back actions. Tests cover these traversal cases. |
Late-step regression and documentation scripts/settings-pages-demo-regression.ts, DESIGN.md, changelog.d/settings-reopen-late-step-back.md |
The browser regression holds history traversal while reopening Settings at desktop and phone widths. The design and changelog describe the late-step behavior. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Low
Possibly related PRs
- devswha/ovis#1947: Changes Settings traversal ownership; this PR continues that behavior with pending traversal release rules and delayed sheet-step coordination.
- devswha/ovis#1754: Moves the Settings history consumer into
useSettingsDialog; this PR changes traversal semantics used by that navigation hook.
Merge Risk: 
Minimal · up to 1e528
-
The late-step behavior is ready to merge after normal checks. The separately reported palette-result failure remains planned for a follow-up.
Pre-merge checks: 
3 · 
2
-
Failed checks: 2 warnings Passed checks: 3 passed-
Full details: Out of Scope Changes check
-
Explanation
The changed application code, shared history query, unit tests, regression coverage, design note, and changelog all support the two history-race fixes or document their behavior. The supplied changes do not show unrelated implementation such as the excluded
#2021cache failure or the pre-existing lightbox behavior.
-
Full details: Linked Issues check
-
Explanation
#2000remains an active flaky regression requirement. The PR implements and tests two delayed-history traversal fixes insettingsHistory.tsandsheetHistory.ts. However,openSettingsstill sends one shortcut press, and the PR reports a third failure path in which Settings remains visible after its X is clicked. The PR therefore does not establish a complete fix for the linked issue.Resolution
Add and test the follow-up fix for the remaining settings-search failure. Address the single shortcut attempt described by
#2000if that path is confirmed. Demonstrate thatscripts/settings-pages-demo-regression.tsno longer has the reported failure paths under the relevant load.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 6 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- 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.
Comment @coderabbitai help to get the list of available commands.
|
Merge pass: the Astra gate approved 1e528fe. Both late-traversal races are fixed, and real Back/Forward and the one-second deadline are unchanged. 70 focused tests pass, and three full settings-pages browser runs passed, including two pinned to two CPUs under load. Each relevant test fails when the production code is mutated. It merges once its CI is green and its turn comes in the queue. |
|
Merge pass review report. Overall: PASSED. This client change fixes two of the three races behind flake #2000. The Astra gate (omo-native-gate-reviewer, gpt-6-astra) approved 1e528fe. What it does.
Gate verification:
Overlap. |
## Change Fixes #2000, together with #2023 (merged). #2023 fixed the two app races behind #2000's timeout. The third way the check failed is in the test, not the app: on a phone, Settings is a sheet that rises from the bottom edge over 360 ms, and on a loaded runner the settings search check clicked Settings' X while it was still rising. The click landed where the X had been, on the header under it, so Settings never closed and the check waited 30 s for it to (`close()` in the settings search, about once in 30 runs under load). Evidence, from a traced run of the check under load (390px, Korean, palette query "OpenAI API 키"): the close click's target was the dialog's header, whose only text is the title "음성 입력". In every earlier close the target was the X's icon. Sampling the X's position every frame after Settings opens from that result shows it moves only vertically, during the sheet's rise (y 860 → 83.5 over about 360 ms, with a long spring tail). Neither the dialog, its body nor the page scrolls under it. The failing click came about 140 ms after the dialog appeared. The regression now clicks in a phone sheet only once its own animations have ended, through `sheetRisen(page, selector)` in `scripts/settings-page.ts`: - Settings, once opened (`openSettings`), and before each click on its X; - the command palette, before a result is clicked (it is a sheet on a phone too); - `openSettingsPage`, shared with other scripts, before it clicks a page. At desktop width there is no animation and the wait returns at once; on a phone it adds at most the rise. The wait reads the dialog's own animations, not its children's (an endless spinner inside cannot hold it), and is bounded by Playwright's timeout. The stress run of that first version failed once more, with a bare `waitForFunction` timeout in the desktop theme checks: the script reopened Settings right after closing it, before the close's step back had landed. A step landing over a second late is taken for the user's Back (`settingsHistory`'s landing deadline, kept on purpose since #630) and closes the Settings opened meanwhile. A scratch probe at 1280px showed it: with the step held 200 ms Settings stays open, held 1.5 s it closes. Every close followed by a reopen now waits for the step to land, as `closeSettings` already did: Escape in the theme checks, the X in the settings search, and the reload made with Settings open (through `historyHolds`, so a timeout there reports the history). Test-only: no app code changes. ## Validation - 4×30 of `bun scripts/settings-pages-demo-regression.ts` at once, in four separate checkouts, pinned to two cores under `dori heavy`, with #2023 underneath: 120 of 120 passed. Before these fixes, the same load failed 1 of 29 runs at the sheet's rise, and the first version failed 1 of 50 at a reopen before the close's step landed. - `bun run check fast`: pass. - Reviews: omo-native-code-reviewer approved after its findings were fixed: the X click right after `openSettings` in the late-step check and the palette's result clicks still raced the rise, and the reload with Settings open lacked the wait. Codex Sol found the same X click and the same reload, both fixed. Co-authored-by: mp <mp@local>
Change
Refs #2000. This fixes two of the three ways the check fails; a third is still being traced (see "Still open") and gets its own PR, which will close #2000. These two are proven and reviewed, so they ship now and take most of these flakes off other PRs' CI.
scripts/settings-pages-demo-regression.tstimed out on CI waiting for Settings to open (openSettings, line 29, from the settings search check). The check was right: two history traversals asked for before Settings opened could land after it and close it, a race any slow device has too, so the fix is in the app.src/lib/settingsHistory.ts). Closing Settings steps back off its entries, and the browser lands that traversal later. In the same commit the app's address bar rewrites the address on the entry being left (replaceStateon the same entry). The module took any foreign write as a reason to let go of its pending step. So when Settings opened again before the step landed, the late popstate looked like a Back of the user's and closed the reopened dialog. AreplaceStatenow lets go of the step only when it changes the Settings entry or the opening it belongs to; apushStatestill always does.src/lib/sheetHistory.ts,src/lib/historyKeys.ts). On a phone, the palette is a sheet with its own entry; closed by Escape, it steps back off that entry with a deferredhistory.back(). Settings opened from the shortcut before that step landed took over the sheet's entry, and the step landed on the entry under it, which Settings read as Back to where it opened.sheetHistorynow answers whether a popstate is such a step through a small shared query inhistoryKeys.ts, so neither module imports the other and their load order is unchanged. When the step lands on the entry that the sheet Settings took over opened over, Settings stays and makes its entries again. The check is anchored to that sheet: a sheet closing above an open Settings (a lightbox in a preview over Settings, a sheet over a#hashentry) is not taken for one.A trace of every history call, popstate, key press and dialog change, captured in failing runs under load, showed each race.
The one-second landing deadline (#630) is unchanged: Settings' own step that lands more than a second after it was asked for is still taken for the user's Back, as one may be. DESIGN.md now says so.
Tests
src/lib/settingsHistory.test.ts: the address written on the entry the step leaves keeps the step Settings' own; a write that changes the Settings entry still lets go of it; a closed sheet's step landing under Settings keeps it open (and closes it when it is no such step).src/lib/sheetHistory.test.ts:sheetStep.landsanswers before and after this module handles the event. A test with both real modules, loaded in the app's order, covers a peek under the palette, the palette's late step and Settings' X, then a lightbox closed in a preview over Settings, which must not bring Settings back. The fake history now dispatches one event per traversal, as browsers do.scripts/settings-pages-demo-regression.ts, newlateCloseStep: at 1440 and 390px, Settings is closed and opened again with its step held, and at 390px the palette is closed by Escape with its step held before Settings opens. Each held step goes to the entry it named when it was asked for (Navigation APItraverseTo), as a browser does. The page's timers set meanwhile start only once the step has landed, so the check does not depend on the runner's speed.Validation
bun scripts/settings-pages-demo-regression.tsat once, in four checkouts, pinned to two cores underdori heavy: 28 of 29 runs passed before the run was stopped; the one failure is the third path below, not either race fixed here. Before the second fix, the same load (four copies in one checkout) failed 5 of 8 runs: 4 traced to the palette's late step, 1 timed out closing Settings in the settings search, without a trace.bun run check fast: pass.back()call, choosing its target late; the guard first keyed on the previous state, which a peek's remade entry overwrites; and the guard first matched a sheet closing above Settings. Codex Sol raised the same last two from its own traversal harness, and found nothing on the final commit, where both of its repros pass.Still open
A third path fails about once in 30 runs under the same load: in the settings search check (Korean, in the failing run), Settings opened from a palette result does not detach within 30 s after its X is clicked. The failing run logged the dialog still visible 63 times. It appeared once, untraced, before the second fix too. I am tracing it with a history dump on failure; its fix goes in a follow-up PR that closes #2000.
Not in this PR
MISSING_EXPORTfrom the shared xterm cache. I hit it while stress-testing this, and CI's parallel browser workers may too.useSettingsDialogon that popstate). That predates this PR, and I have not reproduced it in a browser.