feat(desktop/hotkeys): v1 directional pane focus + best-effort v1 override migrator

Merged
SA
7mo ago
+497-19

Summary

Two related hotkey fixes bundled together:

  • Restore directional pane focus in v1 workspaces. PR #3403 wired Cmd+Alt+Arrow spatial pane focus for v2 but skipped v1, leaving v1 with no keyboard pane navigation at all. Reimplements the spatial neighbor walker against v1's MosaicNode<string> tree (no cross-package coupling to v2's LayoutNode) and adds FOCUS_PANE_LEFT/RIGHT/UP/DOWN handlers to the v1 workspace route. Also teaches the recorder that Option is a legitimate app modifier on Mac (⌥⌫ etc.) and warns when an alt-only chord could mask typing special characters.

  • Best-effort migrator for v1 hotkey overrides. The v1 recorder stored chords from event.key — layout-dependent raw glyphs like meta+,, ctrl+shift+@, meta+alt+ª — while the new store matches on event.code names. The previous sanitizeOverride was strict (/^[a-z0-9]+$/) and silently dropped most real-world v1 entries. Extends it with a token rewrite pre-pass covering:

    • US-ANSI punctuation (,→comma, [→bracketleft, etc.)
    • Shifted glyphs (@→2, _→minus, ?→slash, etc.)
    • macOS Option dead-keys (ª→9, å→a, •→8, etc.)

    The Mac Option table is gated behind a navigator.keyboard.getLayoutMap() probe — on non-US Mac layouts (where Option+Q produces • instead of œ), the glyphs fall through and drop rather than silently rebind to the wrong physical key.

Coverage

Validated against three real leveldb / app-state dumps captured from the indigo-pentaceratops (v1.4.7), tray-polling-fix, and hotkeys-fixes worktrees — every captured chord is locked in as a parametric test case. 20/20 entries from the v1.4.7 blob now migrate successfully (17 rewritten + 3 null unassigns). 64 tests total in overrideSanitizer.test.ts.

Test plan

  • bun test apps/desktop/src/renderer/hotkeys/utils/overrideSanitizer.test.ts — 64 pass
  • bun run --filter=@superset/desktop typecheck — clean
  • bun run lint — clean
  • Smoke test v1 workspace: build 2×2 pane grid, verify Cmd+Alt+Arrow walks to the spatially adjacent pane, edges are no-ops
  • Smoke test v2 workspace: same chord still works (no v2 files touched)
  • Boot against an existing app-state.json with v1 overrides, confirm migration runs once and localStorage.getItem('hotkey-overrides') contains the rewritten entries
  • Verify on a non-US Mac layout (or swap layout via System Settings): dead-key glyphs drop instead of being mis-rewritten

Summary by cubic

Restores Cmd+Alt+Arrow directional pane focus in v1 workspaces and migrates v1 hotkey overrides to the v2 format so users keep their shortcuts. Adds Mac-specific recording logic and a safety warning for alt-only chords.

  • New Features

    • v1: Added spatial pane focus (left/right/up/down) using a Mosaic walker; binds FOCUS_PANE_LEFT/RIGHT/UP/DOWN and no-ops at edges.
    • Recorder: Accepts Option-only chords on macOS and warns that Option shortcuts may block typing special characters.
    • v2 behavior unchanged.
  • Migration

    • Converts v1 event.key chords (e.g., "meta+,", "ctrl+shift+@", "meta+alt+ª") to event.code names.
    • Rewrites US-ANSI punctuation and shifted glyphs; recovers macOS Option dead-keys only on US‑compatible layouts (via navigator.keyboard.getLayoutMap()).
    • Drops ambiguous non‑US dead‑key glyphs instead of misbinding.
    • Added focused tests covering real overrides.

Summary by CodeRabbit

  • New Features

    • Added directional pane navigation hotkeys (Focus Pane Left/Right/Up/Down) for easier workspace navigation.
    • Enhanced macOS keyboard support with improved Option key recognition for custom hotkeys.
  • Improvements

    • Better keyboard shortcut organization in settings with Navigation category.
    • Improved hotkey sanitization and keyboard layout detection.