Skip to content

fix(shortcuts): sync overrides across browser tabs - #1827

Merged
devswha merged 1 commit into
mainfrom
fix/shortcut-overrides-cross-tab
Oct 24, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/shortcut-overrides-cross-tab

Conversation

@devswha

@devswha devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner

What it does

When you change a keyboard shortcut in Settings, every other tab of Ovis already open in the same browser now uses the new binding right away, without a reload. Before, an already-open tab kept the old shortcuts until it was reloaded.

Why

Shortcut overrides are per browser and device (one localStorage record), but each tab read them only on load. SettingsProvider now listens for the browser's storage event on the settings record and takes only shortcutOverrides from it. It writes nothing back, so there is no echo between tabs, and the tab's other in-memory settings are left alone. A storage.clear() (key null) or a removed record returns the shortcuts to their defaults.

Refs #1179

How it was verified

  • src/lib/settings.hook.test.ts: another tab's save updates a mounted consumer without a write and without touching other settings; a removed record or clear() restores the defaults; unrelated keys are ignored. The reviewer's mutation runs showed that removing the listener, the key filter or the null-key branch makes these tests fail.
  • Two-tab check on the demo build in Chromium: tab A records ⌥⌘B for Toggle sidebar. An already-open desktop tab (1180px) and a phone-width tab (390px) list the new chord live, and the desktop tab toggles the sidebar with it. Neither tab wrote anything back, an unrelated setting (terminalFontSize) kept its value, and the pages logged no errors. The same check on origin/main fails the three live-update steps.
  • bun run check fast passed.
  • Reviews: omo-native-code-reviewer approved it with no HIGH or MEDIUM findings. Codex (gpt-6-astra) found nothing.

Known and unchanged: a stale tab's next save of any other device setting still writes its own older copies of the non-shortcut settings. That is outside this change and can be a follow-up.

Refresh shortcut overrides in mounted settings consumers when another tab changes local storage. Preserve unrelated settings and avoid writing the incoming change back.

Refs #1179
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1a83fc4 and 56703ab.

Files selected for processing: 3
  • changelog.d/shortcut-overrides-cross-tab.md
  • src/lib/settings.hook.test.ts
  • src/lib/settings.ts
  • 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: review-work report. Overall: PASSED.

Lane Verdict Confidence
Manual QA (3 rows, artifacts kept) PASS -
Code review (omo-native-code-reviewer, programming and remove-ai-slops) PASS -
Gate review (another model) APPROVE MODERATE-HIGH

Manual QA

Code review

  • The listener reloads storage through loadSettings() and never reads newValue. Malformed JSON or a record of the wrong shape gives in-memory defaults, and nothing is written.
  • It reacts only to localStorage and to the exact key. A shortcut being recorded loses no edit, and the listener is removed on unmount.
  • Six mutants each break the tests: no listener, no key filter, no null branch, replacing all settings, writing back, and reading newValue.

Gate review

  • Traced paths: live keyboard consumers, an open Settings dialog, recording, reset, stale-tab saves, private storage, malformed records, filtering and cleanup.
  • No echo between tabs, and the other in-memory settings are left alone.

Follow-ups (MINOR)

  • No test asserts the storageArea filter or the unmount cleanup.
  • A stale tab's next save of another device setting still writes its own older copy of the other settings. The PR states this limitation and leaves it unchanged.

All required checks are green and no review thread is open.

CodeRabbit did not review this PR (rate-limited). The gate review above stands in for it.

@devswha
devswha merged commit 055e820 into main Oct 24, 2026
9 checks passed
@devswha
devswha deleted the fix/shortcut-overrides-cross-tab branch October 24, 2026 10:59
devswha added a commit that referenced this pull request Oct 28, 2026
…name (#1179) (#2187)

## What it does
Settings → Phone & devices → Devices keeps the "This device" badge in
one piece beside a device's name on a phone. Before, at 390 px the pill
beside "iPhone · Safari" broke between its two words: "THIS" at the end
of the name's line and "DEVICE" on the next (#1179, item 1).

## Why
`.devices-current` was a plain inline span, so the line breaker split it
like any text. It is now `display: inline-block`: an atomic inline box
is never split across lines, so beside a name that fills the line it
moves to the next line whole. Its own words still wrap inside it when
the column is narrower than the pill (a 320 px phone in Japanese with
the row's Revoke? open), so it never runs under the row's buttons. This
is how chip-style labels behave in the apps we compare against (the
GitHub and Linear label chips, iOS Settings' badges): a chip moves as a
unit and is never cut across two lines.

A first version also had `white-space: nowrap`; Codex's review showed it
could overflow a narrow column (MEDIUM), so it was dropped.

## The other items in #1179, checked on main d9050a0
- **2. Shortcut overrides across tabs**: fixed by #1827.
- **3. Split view after "Close this half"**: not reproduced. A probe on
the isolated test herdr closed a half in six layouts (two tabs with each
half active, closing left or right; one tab drawn in both halves,
closing either; one single-pane tab in both halves). After each close,
`.xterm` count equalled the remaining tab's panes, `document.hasFocus()`
was true and no "Paused while you use another window" banner showed,
also 2.5 s later (past `RELEASE_AFTER_MS`).
- **4. Phone tap while reconnecting**: not reproduced. At 390 px with
touch emulation, the socket was dropped and refused (`routeWebSocket`)
until the pane showed "Reconnecting to Ovis…". A tap on the grid then
focused `xterm-helper-textarea` in both the auto and the line input
modes, and typed text showed as "Input held" in the banner.
- **5. PSReadLine colours on the light theme**: these are PowerShell's
own colours for a dark background; the mirrored pane draws what the
program sends. No change.

Closes #1179

## How it was verified
- `scripts/device-security-demo-regression.ts` (the watching-device
block) now sets the current device's name, in place, to every prefix of
a long name and checks the pill is one box, one line high as beside a
one-letter name. It then narrows the name column to the pill's widest
word plus its margin and checks the pill stays inside it. Mutation runs:
the old CSS fails the first check at 390; the `nowrap` version fails the
second; this change passes at 390 and 1440, light and dark, and Korean
at 390.
- `bun run check fast`: success on 2c99503 (7925 pass, 0 fail).
- Reviews: omo-native-code-reviewer (found the rect-count check could
not see a pill wrapping inside its own box; fixed with the height check)
and Codex Sol 6.1 Fast xhigh (MEDIUM above, fixed; re-review PASS on
2c99503).
devswha added a commit that referenced this pull request Oct 31, 2026
…stays (#2485) (#2486)

<!-- See CONTRIBUTING.md for checks, translations, contract tests and
the changelog (a file in changelog.d/, never CHANGELOG.md). -->

## Change

Closes #2485.

An open Ovis tab kept the settings it had loaded. The next time it saved
any setting, it wrote all of them back to `localStorage`, which undid
any change another tab of the same browser had made since. Reproduced on
origin/main 653613c in headless Chromium against an isolated server:
tab A set Chat width to Wide and turned on the Artifacts chip, then tab
B (already open) raised the terminal font size. After a reload, Chat
width was `default` and the Artifacts chip was off.

`SettingsProvider.update` (`src/lib/settings.ts`) now writes only the
settings this tab changed, laid over what is stored now
(`loadSettings()`). A setting counts as this tab's change when it
differs from the tab's current state, or from `stored`: the tab's state
at its last load or successful save. So:
- a value handed to `update` that the tab already holds, such as one
from preferences sync, does not overwrite another tab's newer value;
- a change whose save failed (a full quota, private mode) is written
with the tab's next successful save;
- #1827's live shortcut sync is unchanged, and `stored` follows the
shortcuts it takes in.

Trade-off: in a stale tab, choosing the option it already shows (for
example Chat width Default, while another tab chose Wide) writes
nothing, because that is not a change from this tab's point of view. The
tab still shows its own value until it reloads. Device settings are not
pushed live into other open tabs; that would move layout under the
reader (the proposal's other option).

The shared settings on the server already sync by diff
(`preferencesSync.ts`) and are not touched here. #2374 (a change lost on
reload within 600 ms) is a separate mechanism with its own PR.

## Validation

- Failing first: `src/lib/settings.hook.test.ts` gains 3 cases; on
main's `settings.ts`, the two cross-tab cases fail ("default"/"system"
written over the other tab's values), and they pass with the fix.
- `scripts/settings-tabs-regression.ts` (new, also in
`ui-contexts-checks.ts`): a two-tab Chromium check through the real
Settings dialog. Fails on main (`chatWidth: 'default',
composerArtifacts: 'false'` after the reload) and passes with the fix:
`bun run check run --build bun scripts/settings-tabs-regression.ts`.
- `HERDR_TEST_MODE=unit bun test src/lib/settings.hook.test.ts
src/lib/settings.test.ts src/lib/preferencesSync.hook.test.ts`: 127
pass.
- `bun run check fast`: pass (on the final source).
- Not run: `check full` and the whole `test:ui` suite (CI runs it).
- Reviews: omo code review APPROVE (its MEDIUM on the browser check,
which could pass without tab B saving, is fixed; it now waits for the
exact stepped size). Codex Terra: 3 MEDIUM. Two are fixed: a value
already held no longer overwrites the other tab's (new test), and a
failed save is kept for the next one (new test). One is declined: two
tabs saving in the same instant can still race, because `localStorage`
has no read-merge-write transaction. That window is a few microseconds
on one event loop, against the whole time a tab stays open before.
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.

1 participant