Skip to content

fix(settings): backport phone pairing close repair - #15

Merged
christso merged 2 commits into
christso/mainfrom
fix/settings-pairing-close-backport
Nov 5, 2026
Merged

christso merged 2 commits into
christso/mainfrom
fix/settings-pairing-close-backport

Conversation

@christso

@christso christso commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

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

  • Exact fork baseline with the upstream's two new history regressions: 14 passed, two expected failures. Backported history files: 54 passed.
  • 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.
  • Focused code review and independent adversarial read: no findings. The precision follow-up was separately checked for guard fidelity. The combined deployment candidate with the two message improvements passes 10,625 fast tests.
  • All required hosted checks are green, including Integration and browser after the unchanged relay browser test passed on retry. A clean local relay end-to-end run also passed. Native Windows/macOS and physical-phone checks were not run locally.

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


Compound Engineering

Co-authored-by: Hako [email protected]

devswha and others added 2 commits November 5, 2026 12:28
…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.
@christso

christso commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

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 947f8aee3b05ef151e2a95fec70f17ee8865cf3f: fast checks passed (10,613 tests, zero failures, 41 skips), 54 focused history tests passed, and the five-configuration device-security browser matrix passed. The baseline fails both new upstream history regressions; the backport passes them. All required hosted jobs except the other-browser aggregate passed on the first run. That aggregate timed out on an unchanged relay test waiting for a transient connecting screen after deliberately stopping the relay; it is rerunning. Merge will wait for the required checks.

@christso

christso commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

The failed-job retry completed successfully on unchanged reviewed head 947f8aee3b05ef151e2a95fec70f17ee8865cf3f. All required hosted checks are now green, including the full other-browser suite and Integration and browser aggregate. A clean isolated local relay end-to-end run also passed the shell, reconnect/revocation and media/isolation journeys. No additional product or test changes were needed for the retry, and no review threads remain unresolved.

@christso
christso merged commit df1c489 into christso/main Nov 5, 2026
20 of 22 checks passed
@christso
christso deleted the fix/settings-pairing-close-backport branch November 5, 2026 02:59
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.

2 participants