Repository navigation
fix(settings): backport phone pairing close repair - #15
Conversation
…vswha#2651) ## Change `scripts/device-security-demo-regression.ts:283` failed on GitHub-hosted runners: on devswha#2616 twice in one run, and once more on another of its runs, and on devswha#2636 once. In each case the page was at 390 px light, and Escape right after a fictional phone paired left Settings open (`.settings-dialog` never detached within 30 s). This is a product race, not a test flake. A person pressing Escape right after a phone pairs sees Settings stay open. At phone width the pairing closes the Connect a phone sheet by itself. An Escape in the next moments was lost in one of two ways: 1. **The sheet's Escape listener outlived the sheet.** `ConnectPhoneDialog` listens for Escape on the window, in the capture phase, and calls `stopPropagation()` and its own close. The listener is removed in a passive effect's cleanup, which runs after the sheet has left the page. An Escape in that gap was taken by a sheet that no longer existed, so Settings never heard it. Now the listener lets the key through once its surface is gone, because React detaches the ref before the passive cleanup. 2. **Settings stepped back from the wrong entry.** A closed sheet steps back off its history entry in the next task (`leaveSheet`, `setTimeout(0)`). If Settings closed before that step ran, its rewind of `go(-depth)` started from the sheet's entry. That entry copies Settings' own fields, so the rewind landed on Settings' list of pages and Settings stayed open. Now Settings steps over that entry too and takes over the sheet's step, through `sheetStep.takeLeaving` in `historyKeys.ts`, so the step never runs twice. How it was found: a probe sent Escape at fixed moments after the sheet left the DOM, on 2 cores with 2 CPU hogs. It sent the key in the mutation's own microtask, then after 1, 2 and 4 tasks, and also as Playwright's key press. The probe covered the first pairing and the second one, after Settings was reopened from the notice. On main, Escape within 2 tasks left Settings open 30 times out of 30. The first race showed the key seen in the window capture phase but never reaching Settings' listener. The second showed `go(-2)` issued from the sheet's entry. With this change, Settings closed 50 times out of 50. ## Tests `src/lib/sheetHistory.test.ts` adds two tests with both history modules on one browser. Each closes Settings while a sheet opened inside it is still stepping off its entry, once with the address unchanged and once with it changed. Both fail on main, where Settings stays on its list at depth 1. The changed-address test also fails if `takeLeaving` skips a sheet whose address changed. I checked that by mutating a scratch copy. ## Validation - `scripts/device-security-demo-regression.ts`: 22 consecutive passes out of 22 on 2 cores with 2 CPU hogs, with `UI_EVIDENCE_DIR` set as CI does, under `dori heavy`. An earlier head, 009f8920, which differed only in the changed-address case, passed 10 out of 10. - `bun test src/lib/sheetHistory.test.ts src/lib/settingsHistory.test.ts src/components/ConnectPhoneDialog.test.tsx`: 66 pass. - `bun run check fast`: success on 6db6150. - Reviews: - omo code reviewer: APPROVE after its HIGH was fixed. The `?query` test import broke the typecheck, and now uses a path variable. Its LOW-A (take a leaving sheet's step whatever its address) is applied. - Codex Terra: two rounds of REQUEST_CHANGES, both on the changed-address case. The first asked to respect `leaveSheet`'s changed-address rule; the second asked that Settings still close in that case. The final code closes Settings and steps back past that entry, as the omo reviewer recommended. The new test covers it. - Left as follow-ups: the guard in `ConnectPhoneDialog` has no unit test, because the test renderer gives no DOM refs; the browser script and the probe cover it. Also, once the sheet's own step back has started, Settings can still hear a step that isn't its own. That was already true on main and isn't seen in a browser. - Skipped: full check, Windows VM. (cherry picked from commit df86222)
Reuse SUBPIXEL for two geometry comparisons. A translating one-line badge differed by0.0000305px across coordinate boundaries, and a44px control measured43.9999389px. Preserve single-box and overflow checks.
|
Merge review: CodeRabbit did not review this fork PR. An agent reviewed the unchanged upstream six-file product backport and an independent adversarial read found no remaining issues. The four-line browser geometry follow-up was reviewed separately: it uses the existing 0.01px tolerance while preserving single-box, wrapping, overflow and control-size guards. No unresolved findings remain. Upstream attribution is retained in the commit and PR body. Final head |
|
The failed-job retry completed successfully on unchanged reviewed head |
Change
Settings can stay open when Escape is pressed just after a phone pairs. Backport the upstream repair so a detached phone sheet cannot swallow Escape and Settings steps past its closing sheet entry once.
The six-file product patch is unchanged from Hako's upstream merge. Two adjacent browser checks now use their existing 0.01px tolerance: animation produced a 0.0000305px difference for the same one-line badge and measured a 44px control at 43.99994px. Single-box, wrapping and overflow checks remain in place.
Validation
bun run check fast: 10,613 passed, zero failures, 41 repository skips; type/build/generated/workflow checks passed.scripts/device-security-demo-regression.ts: all five desktop/phone, light/dark and English/Korean configurations passed after the precision corrections. The original full-fork CI failure was the Settings-close timeout; baseline also exposed the strict floating-point assertions.Installed with #13 and #14 at
1b76b353. Deployment verification and native green recordings confirm the served revision and client, preserved configuration/pairing and successful message recovery tests.Related: devswha#2651
Related: #13, #14
Co-authored-by: Hako [email protected]