Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(shortcuts): move the window toggle off the macOS close-window chord (#501)
Lan6bc810c0bed4
diff --git a/apps/desktop/electron/main/application-menu.ts b/apps/desktop/electron/main/application-menu.tsindex e99372a89..e23f9ad5e 100644--- a/apps/desktop/electron/main/application-menu.ts+++ b/apps/desktop/electron/main/application-menu.ts@@ -120,10 +120,11 @@ export function buildApplicationMenuTemplate({] satisfies MenuItemConstructorOptions[]): []),{ type: "separator" },- // One window-visibility key (D438): `Mod+W` hides the window the user- // is looking at and brings a hidden or tray-minimized window back. The- // retired `Mod+Shift+W` summon item is gone; the label is- // locale-resolved at render time.+ // One window-visibility key (D438, rebound by D439): `Alt+Shift+W`+ // hides the window the user is looking at and brings a hidden or+ // tray-minimized window back. The key is process-wide, so it avoids the+ // macOS close-window chord `Mod+W`. The retired `Mod+Shift+W` summon+ // item is gone; the label is locale-resolved at render time.{label: labels.menu.toggleWindow,accelerator: accelerator("toggleWindow"),diff --git a/apps/desktop/electron/main/bootstrap/launcher.ts b/apps/desktop/electron/main/bootstrap/launcher.tsindex 3fb8a1213..1c561f074 100644--- a/apps/desktop/electron/main/bootstrap/launcher.ts+++ b/apps/desktop/electron/main/bootstrap/launcher.ts@@ -256,10 +256,12 @@ export function createLauncher({}/**- * Register the merged window toggle (D438). The default `Mod+W` runs the same- * toggle the menu item and the renderer run: it hides the window the user is- * looking at, or brings a hidden/minimized-to-tray window back into focus.- * The retired `Mod+Shift+W` summon binding is no longer registered.+ * Register the merged window toggle (D438, rebound by D439). The default+ * `Alt+Shift+W` runs the same toggle the menu item and the renderer run: it+ * hides the window the user is looking at, or brings a hidden/minimized-to-tray+ * window back into focus. The key is process-wide, so it deliberately avoids+ * `Mod+W` — macOS spends that chord on its own close-window command. The+ * retired `Mod+Shift+W` summon binding is not registered either.*/function applyToggleWindowShortcut(keybindings?: KeybindingOverrides) {const shortcut = KEYBOARD_SHORTCUTS.find(diff --git a/apps/desktop/test/plugin-shortcuts.test.mjs b/apps/desktop/test/plugin-shortcuts.test.mjsindex 3fb25f712..583d9b267 100644--- a/apps/desktop/test/plugin-shortcuts.test.mjs+++ b/apps/desktop/test/plugin-shortcuts.test.mjs@@ -225,9 +225,9 @@ test("a system-reserved binding is refused", () => {test("without a live source the app's shipped defaults are refused", () => {for (const platform of ["linux", "darwin"]) {const { registry, calls } = fakePlatform({ platform });- // D438: the app spends `Mod+W` on the window toggle, and the retired- // `Mod+Shift+W` summon chord is free again.- for (const accelerator of ["Alt+Space", "Mod+W"]) {+ // D438/D439: the app spends `Alt+Shift+W` on the window toggle, and neither+ // retired chord (`Mod+W`, `Mod+Shift+W`) is held by anyone.+ for (const accelerator of ["Alt+Space", "Alt+Shift+W"]) {refusal(() =>registry.register({@@ -244,18 +244,39 @@ test("without a live source the app's shipped defaults are refused", () => {}});+test("the macOS close-window chord is reserved, not merely unbound", () => {+ const { registry, calls } = fakePlatform({+ platform: "darwin",+ hostBindings: () => [],+ });+ // `Mod+W` is macOS's own close-window command. It is no longer the app's+ // default (D439), and it stays off-limits to plugins as well, so the platform+ // keeps the chord it owns.+ refusal(+ () =>+ registry.register({+ pluginId: PLUGIN_ID,+ id: "voice.close",+ accelerator: "Mod+W",+ command: VOICE_COMMAND,+ }),+ "SHORTCUT_CONFLICT",+ );+ assert.deepEqual(calls.registered, []);+});+test("the live host bindings decide, not the shipped defaults", () => {- // The user rebound the window toggle, so `Mod+W` is free again while+ // The user rebound the window toggle, so `Alt+Shift+W` is free again while// whatever the app now holds is refused instead.const { registry, calls } = fakePlatform({ hostBindings: () => ["Mod+Shift+W"] });const freedDefault = registry.register({pluginId: PLUGIN_ID,id: "voice.pushToTalk",- accelerator: "Mod+W",+ accelerator: "Alt+Shift+W",command: VOICE_COMMAND,});- assert.equal(freedDefault.accelerator, "Mod+W");+ assert.equal(freedDefault.accelerator, "Alt+Shift+W");refusal(() =>@@ -268,7 +289,7 @@ test("the live host bindings decide, not the shipped defaults", () => {"SHORTCUT_CONFLICT",);// `register` receives Electron's platform spelling of the canonical binding.- assert.deepEqual(calls.registered, ["Control+W"]);+ assert.deepEqual(calls.registered, ["Alt+Shift+W"]);});test("an empty live report still falls back to the shipped defaults", () => {diff --git a/apps/desktop/test/window-menu.test.mjs b/apps/desktop/test/window-menu.test.mjsindex 705193bc7..eae46b1f4 100644--- a/apps/desktop/test/window-menu.test.mjs+++ b/apps/desktop/test/window-menu.test.mjs@@ -96,7 +96,8 @@ test("macOS application menu routes shell commands and preserves native roles",}assert.match(menuSource, /function nativeAction\(/);// The File menu's window item is the merged visibility toggle (D438): its- // accelerator is the toggle's `Mod+W` and its click is that native action.+ // accelerator is the toggle's own binding (D438, rebound by D439) and its+ // click is that native action.assert.match(menuSource, /accelerator\("toggleWindow"\)/);assert.match(menuSource, /labels\.menu\.toggleWindow/);for (const action of [diff --git a/apps/desktop/test/window-toggle-shortcut.test.mjs b/apps/desktop/test/window-toggle-shortcut.test.mjsindex 3248285da..dda568a48 100644--- a/apps/desktop/test/window-toggle-shortcut.test.mjs+++ b/apps/desktop/test/window-toggle-shortcut.test.mjs@@ -30,8 +30,12 @@ register(pathToFileURL(join(here, "helpers/ts-import-hooks.mjs")));const { windowToggleAction } = await import("../electron/main/bootstrap/window-visibility.ts");-const { KEYBOARD_SHORTCUTS, KEYBOARD_SHORTCUT_IDS, migrateKeybindingOverrides } =- await import("../../../packages/shared/src/keyboard-shortcuts.ts");+const {+ KEYBOARD_SHORTCUTS,+ KEYBOARD_SHORTCUT_IDS,+ isReservedKeybinding,+ migrateKeybindingOverrides,+} = await import("../../../packages/shared/src/keyboard-shortcuts.ts");const { catalogs, flattenCatalog } = await import("../../../packages/i18n/src/index.ts");@@ -66,16 +70,27 @@ function toggleActionFor({ visible, minimized, focused }) {});}-test("the catalog ships one window toggle on Mod+W, with no summon chord", () => {+test("the catalog ships one window toggle on Alt+Shift+W, with no summon chord", () => {assert.ok(KEYBOARD_SHORTCUT_IDS.includes("toggleWindow"));assert.equal(KEYBOARD_SHORTCUT_IDS.includes("summonWindow"), false);assert.equal(KEYBOARD_SHORTCUT_IDS.includes("closeWindow"), false);+ const toggle = KEYBOARD_SHORTCUTS.find((shortcut) => shortcut.id === "toggleWindow");+ assert.equal(toggle.defaultBinding, "Alt+Shift+W");+ assert.equal(toggle.macDefaultBinding, undefined);const windowGroup = KEYBOARD_SHORTCUTS.filter((shortcut) => shortcut.group === "window");+ // D439: the toggle is registered process-wide, so it must avoid the chords+ // the platform owns: `Mod+W` closes a window on macOS and `Mod+Shift+W` is the+ // retired summon key. Neither is a shipped default any more.+ assert.equal(+ KEYBOARD_SHORTCUTS.some((shortcut) => shortcut.defaultBinding === "Mod+W"),+ false,+ );assert.equal(KEYBOARD_SHORTCUTS.some((shortcut) => shortcut.defaultBinding === "Mod+Shift+W"),false,);+ assert.equal(isReservedKeybinding("Mod+W", "darwin"), true);assert.deepEqual(windowGroup.map((shortcut) => shortcut.id),["toggleWindow", "resetZoom", "zoomIn", "zoomOut", "toggleFullScreen"],@@ -125,7 +140,7 @@ test("the launcher registers the toggle accelerator and nothing else", () => {["openPluginLauncher", "toggleWindow"],);// The plugin registry refuses what the app now holds: `Alt+Space` and the- // `Mod+W` toggle.+ // `Alt+Shift+W` toggle.assert.match(registrySource,/HOST_GLOBAL_SHORTCUT_IDS = \["openPluginLauncher", "toggleWindow"\] as const/,@@ -146,13 +161,18 @@ test("the shell key, the menu item, and the accelerator run one action", () => {test("stored legacy overrides are folded where each process reads them", () => {assert.match(lifecycleSource, /migrateKeybindingOverrides\(/);assert.match(storeSource, /migrateKeybindingOverrides\(settingsRaw\.keybindings\)/);- // The two cases the migration exists for: a user who customized the old close- // key, and one who customized the old summon key.+ // The cases the migration exists for: a user who customized the old close+ // key, one who customized the old summon key, a profile that froze the+ // short-lived `Mod+W` toggle default (D439), and an untouched profile.assert.deepEqual(migrateKeybindingOverrides({ closeWindow: "Mod+Shift+Q" }), {toggleWindow: "Mod+Shift+Q",});- assert.deepEqual(migrateKeybindingOverrides({ summonWindow: "Alt+Shift+W" }), {- toggleWindow: "Alt+Shift+W",+ assert.deepEqual(migrateKeybindingOverrides({ summonWindow: "Ctrl+Alt+W" }), {+ toggleWindow: "Ctrl+Alt+W",+ });+ assert.deepEqual(migrateKeybindingOverrides({ toggleWindow: "Mod+W" }), undefined);+ assert.deepEqual(migrateKeybindingOverrides({ toggleWindow: "Ctrl+Alt+T" }), {+ toggleWindow: "Ctrl+Alt+T",});assert.deepEqual(migrateKeybindingOverrides({}), undefined);});diff --git a/docs/adr/0211-plan-safe-plugin-actions.md b/docs/adr/0211-plan-safe-plugin-actions.mdindex f69b5a83e..cdb3b3941 100644--- a/docs/adr/0211-plan-safe-plugin-actions.md+++ b/docs/adr/0211-plan-safe-plugin-actions.md@@ -4,8 +4,8 @@- Date: 2026-09-10- Deciders: PI-Desktop core- Amended by: D438 (the window-summon shortcut in §7 becomes one- window-visibility toggle on `Mod+W`; the plan-safe plugin-action opt-in is- unchanged)+ window-visibility toggle) and D439 (that toggle ships on `Alt+Shift+W`+ because macOS owns `Cmd+W`; the plan-safe plugin-action opt-in is unchanged)- Related: ADR 0052, ADR 0053, ADR 0170, E2E-PLAN-005## Context@@ -108,11 +108,13 @@ is the symmetrical counterpart to `closeWindow`: closing a window hidesit to the tray or minimizes it; summoning brings the same window back tofocus.-*(Amended by D438: the catalog now ships one `toggleWindow` id on `Mod+W`-instead of the `summonWindow` / `closeWindow` pair, the retired `Mod+Shift+W`-chord is registered by nothing, and stored overrides for the two retired ids-are folded into the toggle on read. Hiding is `Window.hide()` and never the-close path.)*+*(Amended by D438: the catalog now ships one `toggleWindow` id instead of the+`summonWindow` / `closeWindow` pair, the retired `Mod+Shift+W` chord is+registered by nothing, and stored overrides for the two retired ids are folded+into the toggle on read. Hiding is `Window.hide()` and never the close path.+Amended again by D439: the toggle ships on `Alt+Shift+W`, not on the `Mod+W`+this ADR's D438 amendment first named, because the key is registered+process-wide and macOS spends `Cmd+W` on its own close-window command.)*## Consequencesdiff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.mdindex 1d6e94c59..434119385 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -183,11 +183,12 @@ a usage tab.on Windows/Linux; its native global registration follows the same override.An unbound launcher disables Electron registration, the Windows host hook,and the focused-window fallback- - the window-visibility row is one toggle on `Cmd/Ctrl + W`: it hides a+ - the window-visibility row is one toggle on `Alt + Shift + W`: it hides avisible, focused window to the tray and brings a hidden or minimized windowback. It is the only window key — the retired `Cmd/Ctrl + Shift + W` summon- row is gone — and a stored `closeWindow`/`summonWindow` override is folded- into it when the map is read (D438)+ row is gone — and it avoids `Cmd/Ctrl + W` because macOS spends that chord+ on its own close-window command; a stored `closeWindow`/`summonWindow`+ override is folded into it when the map is read (D438, D439)### Model configuration (`agent` tab)- **Defaults** card: a compact settings row shows the provider name and exactdiff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex 110ef6280..d52fb2bd0 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -15,7 +15,7 @@| `Cmd/Ctrl + Shift + P` | Open command palette | Global (D014) || `Cmd/Ctrl + N` | New chat/session | Global || `Cmd/Ctrl + O` | Open project | Global |-| `Cmd/Ctrl + W` | Show or hide the window (toggle) | Global (D438); hides to the tray, never quits |+| `Alt + Shift + W` | Show or hide the window (toggle) | OS-global (D439); hides to the tray, never quits || `Cmd/Ctrl + ,` | Open settings | Global || `Cmd/Ctrl + B` | Toggle sidebar | Global || `Cmd/Ctrl + J` | Toggle work panel | Global; active session |@@ -74,13 +74,16 @@the panel's normal activation instead of issuing a second applicationactivation or window-stack move. The launcher always opens on the displaynearest the pointer.-- The window visibility key is one toggle (`Cmd/Ctrl + W`): a visible, focused- window hides to the tray, and anything else — hidden, minimized, or behind- another application — is shown and focused. Hiding never enters the close- path, so it raises no close-behaviour prompt, destroys nothing, and never- quits the app. The retired `Cmd/Ctrl + Shift + W` summon chord is not- registered, and stored `closeWindow`/`summonWindow` overrides are folded into- the toggle when the map is read (D438).+- The window visibility key is one toggle (`Alt + Shift + W`): a visible,+ focused window hides to the tray, and anything else — hidden, minimized, or+ behind another application — is shown and focused. Hiding never enters the+ close path, so it raises no close-behaviour prompt, destroys nothing, and+ never quits the app. The key is globally registered, so it deliberately+ avoids `Cmd/Ctrl + W`, which macOS spends on its own close-window command and+ which would be taken from every application if the app claimed it. The+ retired `Cmd/Ctrl + Shift + W` summon chord is not registered either, and+ stored `closeWindow`/`summonWindow` overrides are folded into the toggle when+ the map is read (D438, D439).### 1.5 Plugin launcher shortcutsdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 316512b9f..57b297119 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -4383,7 +4383,7 @@ identify the platform validation still needed.inactive. 11) Press and release Ctrl/Command alone, confirm an IME candidate,and hold the back/forward chord long enough to generate repeats.12) With the main window focused, press the window-visibility chord- `Cmd/Ctrl + W` and confirm the window hides to the tray with no+ `Alt + Shift + W` and confirm the window hides to the tray with noclose-behaviour prompt and with the app still running; from anotherapplication, press it again and confirm the window returns and focuses.13) Seed one profile with a stored customized `closeWindow` binding and one@@ -4401,11 +4401,13 @@ identify the platform validation still needed.individual and global reset restore the shared defaults; Keyboard shortcuts isits own Settings destination. Modifier-only and IME keydowns dispatch nothing,and a held history chord traverses only once per physical press. The- window-visibility key is one toggle on `Cmd/Ctrl + W` — a visible, focused+ window-visibility key is one toggle on `Alt + Shift + W` — a visible, focusedwindow hides to the tray, anything else shows and focuses — and it neverenters the close path, so it raises no close-behaviour prompt and never quits;- the retired `Cmd/Ctrl + Shift + W` chord registers nothing, and a stored- `closeWindow`/`summonWindow` override folds into the toggle (D438).+ it is globally registered and deliberately avoids `Cmd/Ctrl + W`, which macOS+ spends on its own close-window command; the retired `Cmd/Ctrl + Shift + W`+ chord registers nothing, and a stored `closeWindow`/`summonWindow` override+ folds into the toggle (D438, D439).- **Specs linked**: `04-ux/06-settings-ia.md`, `04-ux/07-ui-design-system.md`,`03-runtime/01-ipc-protocol.md`- **Acceptance**: F (settings persistence), Quality (keyboard accessibility)@@ -7335,14 +7337,14 @@ identify the platform validation still needed.`Alt+Shift+V` and inspect the answer. 5) Disable and uninstall A and confirmthe accelerator becomes free and B can take it; repeat after terminating A'sruntime (crash) and while A's panel is closed. 6) Attempt the app's own- launcher accelerator `Alt+Space`, the `Mod+W` window toggle, a+ launcher accelerator `Alt+Space`, the `Alt+Shift+W` window toggle, areserved binding such as `Mod+C`, an invalid accelerator, and a ninthshortcut for one plugin.- **Expected**: Only A's own command runs for the accelerator; a shortcut whose`command` is not registered by the plugin is refused with `INVALID_ARGUMENT`.B receives a refusal (`registered: false`, code `SHORTCUT_CONFLICT`) and keepsno accelerator while A holds it. The host's own `Alt+Space` launcher and- `Mod+W` window-toggle shortcuts and OS-reserved bindings are refused with+ `Alt+Shift+W` window-toggle shortcuts and OS-reserved bindings are refused with`SHORTCUT_CONFLICT` or `SHORTCUT_UNAVAILABLE`; an invalid accelerator isrefused with `INVALID_ACCELERATOR` and the ninth per-plugin shortcut with`LIMIT_EXCEEDED`. Disabling, unloading, or crashing a plugin releases everydiff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.mdindex 332f5ce30..a6928066a 100644--- a/docs/spec/07-plugins/03-plugin-api.md+++ b/docs/spec/07-plugins/03-plugin-api.md@@ -804,7 +804,7 @@ command belonging to that plugin.`command` must already be registered by the calling plugin; anything else fails`INVALID_ARGUMENT`. An accelerator reserved by the operating system, onePI-Desktop itself currently spends (by default `Alt+Space` opens the plugin-launcher and `Mod+W` shows or hides the window; once the user rebinds one of+launcher and `Alt+Shift+W` shows or hides the window; once the user rebinds one ofthem, the freed accelerator is available again), or one held by another pluginis refused rather than taken over, and a refused re-registration leaves theprevious binding in place.diff --git a/docs/spec/07-plugins/04-plugin-security.md b/docs/spec/07-plugins/04-plugin-security.mdindex cce193b74..b298ccce1 100644--- a/docs/spec/07-plugins/04-plugin-security.md+++ b/docs/spec/07-plugins/04-plugin-security.md@@ -397,7 +397,7 @@ stream, so there is no keylogger-shaped surface and no way to see the keys theuser types. A plugin may only map an accelerator to one of its own registeredcommands, and an accelerator the OS reserves, that PI-Desktop itself currentlyspends (the plugin-launcher and window-toggle bindings, `Alt+Space` and-`Mod+W` by default; a user rebinding one frees it for plugins), or that+`Alt+Shift+W` by default; a user rebinding one frees it for plugins), or thatanother plugin holds is refused with`LIMIT_EXCEEDED` (at most 8 per plugin) instead of being taken over. A triggerruns exactly that one command. Register, unregister, and trigger are auditeddiff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex 7d83ae5ac..289bdc08f 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -4569,8 +4569,9 @@ D193, and D194.## 2026-09-10 — Plan-safe plugin actions and summon-window shortcut (D384)-*(superseded by D438 for the summon-window shortcut; the plan-safe plugin-action opt-in below stays)*+*(the summon-window half is superseded by D438, which replaced the pair, and by+D439, which moved the toggle off the macOS close-window chord; the plan-safe+plugin-action opt-in below stays)*- Plan and Goal modes could not invoke plugin tools at all, even forread-only actions like fetching a URL through the bundled Browser@@ -4585,6 +4586,9 @@ action opt-in below stays)*declares `["navigate", "snapshot", "screenshot", "console"]`; themutating actions stay Agent-only. The shortcut catalog gains`summonWindow` (`Mod+Shift+W`) in the `window` group, paired with+ `closeWindow` (`Mod+W`), and the desktop main process registers it+ through `globalShortcut` and the native menu. See ADR 0211 and+ E2E-PLAN-005.## 2026-09-17 — One window toggle replaces the summon/close pair (#360, D438)@@ -4595,13 +4599,13 @@ action opt-in below stays)*so D438 supersedes exactly that half of D384; the plan-safe plugin-actionopt-in from the same decision is untouched. The numbering skips D435 and D437,which other in-flight work already claims.-- The catalog ships one `toggleWindow` id in the `window` group, default- `Mod+W` on every platform. `closeWindow` and `summonWindow` leave- `KEYBOARD_SHORTCUT_IDS`, so the retired `Mod+Shift+W` chord is spent on- nothing: it is not a shipped default, not registered with `globalShortcut`,- not a settings row, and not a menu accelerator. The plugin shortcut registry- therefore now refuses `Alt+Space` and `Mod+W`, and the freed `Mod+Shift+W`- becomes available to plugins.+- The catalog ships one `toggleWindow` id in the `window` group, and+ `closeWindow` and `summonWindow` leave `KEYBOARD_SHORTCUT_IDS`, so neither+ retired chord is spent on anything: neither is a shipped default, registered+ with `globalShortcut`, a settings row, or a menu accelerator, and the freed+ `Mod+Shift+W` becomes available to plugins again. D439 later moved the+ toggle's own default off `Mod+W`, which D438 had chosen; the merged id, the+ toggle semantics, and the migration below are unchanged by that.- Pressing the key is a decision, not a close. `windowToggleAction` hides avisible, focused window through `Window.hide()` and otherwise shows andfocuses it (hidden, minimized, or behind another application all count as@@ -4618,7 +4622,7 @@ action opt-in below stays)*no surface can act on the retired ids. The rules are ordered and idempotent:an existing `toggleWindow` override wins unchanged; otherwise the firstretired entry that carries a *binding* wins, `closeWindow` first because- `Mod+W` is the key the toggle keeps; a retired entry that is only `null` is+ hiding is the toggle's primary job; a retired entry that is only `null` ishonoured when no binding competes, so an explicit unbind is never replaced bya shipped default; and a stored value equal to its own retired default carriesno intent (the settings UI deletes overrides that match a shipped default), so@@ -4634,9 +4638,37 @@ action opt-in below stays)*`07-plugins/04-plugin-security.md`, `03-runtime/01-ipc-protocol.md`(`NATIVE_MENU_ACTIONS`), E2E-072, and`apps/desktop/test/window-toggle-shortcut.test.mjs`.- `closeWindow` (`Mod+W`), and the desktop main process registers it- through `globalShortcut` and the native menu. See ADR 0211 and- E2E-PLAN-005.++## 2026-09-17 — The window toggle avoids the macOS close-window chord (#360, D439)++- D438 merged the pair onto `Mod+W`, but that binding cannot be the default of a+ *process-wide* accelerator: macOS spends `Cmd+W` on its own close-window+ command, so claiming it globally takes the chord away from every other+ application instead of only closing this window. `Mod+W` is therefore the one+ key the toggle must not hold.+- The catalog now ships `toggleWindow` on `Alt+Shift+W` — no platform modifier,+ so it is one chord on macOS, Windows, and Linux — which collides with no+ shipped default, no reserved editing chord, and no platform command. The+ merge, the hide/show semantics, and the fold of the retired+ `closeWindow`/`summonWindow` overrides stay exactly as D438 defined them.+- On macOS `Mod+W` is now also refused to plugins (`isReservedKeybinding`), so+ the platform keeps the chord it owns even though the app no longer uses it.+- A stored `toggleWindow` value that only repeats a default this release ships+ or already superseded carries no user intent, so the fold drops it: a profile+ that persisted the short-lived `Mod+W` default moves to `Alt+Shift+W` instead+ of freezing the macOS chord, while a real rebind (`Ctrl+Alt+T`) and an+ explicit unbind (`null`) survive untouched, and a retired customization still+ wins over a dropped superseded default.+- The number is D439 because D435 and D437 were already claimed by other+ in-flight work. **Note**: this log currently carries two `D438` entries — the+ window-toggle merge above (#360, the pre-rebind decision) and the Git-checkout+ decision (ADR 0273) near the end of the file. The latter was appended after the+ toggle's D438 had merged, so its number needs to move to D440 or the next free+ id; this entry does not rewrite another decision's text.+- See ADR 0211 (amended again), `04-ux/09-interaction-patterns.md` §1.1 and+ §1.4, `04-ux/06-settings-ia.md` (shortcuts tab), `07-plugins/03-plugin-api.md`,+ `07-plugins/04-plugin-security.md`, E2E-072, and+ `apps/desktop/test/window-toggle-shortcut.test.mjs`.## 2026-09-10 — Remove diagnostic timing log streams (D385)diff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.mdindex 89986a485..91f100921 100644--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md@@ -121,10 +121,11 @@ Token 用量**不是设置目的地**(D335 / ADR 0173)。已完成回合历- 插件启动器在 macOS 默认为 `Option + Space`,在 Windows/Linux 默认为`Alt + Space`;本机全局注册遵循相同覆盖。未绑定时会同时关闭 Electron 注册、Windows host hook 和聚焦窗口后备- - 窗口可见性只有一行、一个开关键 `Cmd/Ctrl + W`:把可见且在前台的窗口隐藏到+ - 窗口可见性只有一行、一个开关键 `Alt + Shift + W`:把可见且在前台的窗口隐藏到托盘,把已隐藏或已最小化的窗口调回来。它是唯一的窗口键 —— 已弃用的- `Cmd/Ctrl + Shift + W` 呼出组合键已移除 —— 读取配置映射时,已存储的- `closeWindow` / `summonWindow` 覆盖项会并入它(D438)+ `Cmd/Ctrl + Shift + W` 呼出组合键已移除 —— 并且避开 `Cmd/Ctrl + W`,因为+ macOS 把它用于自己的关闭窗口命令;读取配置映射时,已存储的+ `closeWindow` / `summonWindow` 覆盖项会并入它(D438、D439)### 模型配置(`agent` 选项卡)- **Studio Hero**:提供商计数、就绪计数和当前默认 provider/model 摘要diff --git a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md b/docs/zh-CN/spec/04-ux/09-interaction-patterns.mdindex 5e27ea53f..694a2e825 100644--- a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md+++ b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md@@ -18,7 +18,7 @@| `Cmd/Ctrl + Shift + P` | 打开命令面板 | 全球 (D014) || `Cmd/Ctrl + N` | 新 chat/session | 全球 || `Cmd/Ctrl + O` | 打开项目 | 全球 |-| `Cmd/Ctrl + W` | 呼出或隐藏窗口(切换) | 全局(D438);隐藏到托盘,绝不退出 |+| `Alt + Shift + W` | 呼出或隐藏窗口(切换) | 系统级全局(D439);隐藏到托盘,绝不退出 || `Cmd/Ctrl + ,` | 打开设置 | 全球 || `Cmd/Ctrl + B` | 切换侧边栏 | 全球 || `Cmd/Ctrl + J` | 打开工作面板 | 全球;活动会话 |@@ -70,11 +70,13 @@专注。如果钩子无法被安装,聚焦窗口后备仍然可用。未绑定时会同时关闭钩子和聚焦窗口后备。自定义绑定继续使用 Electron 的全局快捷方式 API。启动器始终在最靠近指针的显示屏上打开。-- 窗口可见性只有一个开关键(`Cmd/Ctrl + W`):可见且在前台的窗口隐藏到托盘,+- 窗口可见性只有一个开关键(`Alt + Shift + W`):可见且在前台的窗口隐藏到托盘,其余情况 —— 已隐藏、已最小化或被其它应用挡在后面 —— 显示并获得焦点。隐藏不走关闭路径,因此不会弹出关闭行为询问、不会销毁窗口,也绝不会退出应用。- 已弃用的 `Cmd/Ctrl + Shift + W` 呼出组合键不再注册;读取配置映射时,- 已存储的 `closeWindow` / `summonWindow` 覆盖项会并入该开关键(D438)。+ 该键是系统级全局注册,因此刻意避开 `Cmd/Ctrl + W` —— macOS 把它用于自己的+ 关闭窗口命令,应用一旦占用就会从所有应用程序手里把它抢走。已弃用的+ `Cmd/Ctrl + Shift + W` 呼出组合键同样不再注册;读取配置映射时,已存储的+ `closeWindow` / `summonWindow` 覆盖项会并入该开关键(D438、D439)。### 1. 5 插件启动器快捷方式diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex 0f22169f0..a0ae0965b 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -2924,10 +2924,11 @@ PI-Desktop 图标;两个表面都不会暴露库存 Electron 名称或图标状态,不参与冲突、不响应旧或默认组合、可跨重启保存,并会移除 macOS 加速器和Windows 启动器后备层;单项和全局恢复都返回共享默认值。仅修饰符和 IME 按键不会发送命令,长按历史组合每次物理按压只遍历一次。窗口可见性只有一个开关键- `Cmd/Ctrl + W` —— 可见且在前台的窗口隐藏到托盘,其余情况显示并获得焦点 ——- 且绝不走关闭路径,因此不会弹出关闭行为询问、也不会退出应用;已弃用的+ `Alt + Shift + W` —— 可见且在前台的窗口隐藏到托盘,其余情况显示并获得焦点 ——+ 且绝不走关闭路径,因此不会弹出关闭行为询问、也不会退出应用;该键刻意避开+ `Cmd/Ctrl + W`,因为 macOS 把它用于自己的关闭窗口命令;已弃用的`Cmd/Ctrl + Shift + W` 组合键不再注册,已存储的 `closeWindow` / `summonWindow`- 覆盖项会并入该开关键(D438)。+ 覆盖项会并入该开关键(D438、D439)。- **链接规格**:`04-ux/06-settings-ia.md`、`04-ux/07-ui-design-system.md`、`03-runtime/01-ipc-protocol.md`- **接受**:F(设置持久性)、质量(键盘可访问性)diff --git a/docs/zh-CN/spec/07-plugins/03-plugin-api.md b/docs/zh-CN/spec/07-plugins/03-plugin-api.mdindex 60d34bdcf..c97f84685 100644--- a/docs/zh-CN/spec/07-plugins/03-plugin-api.md+++ b/docs/zh-CN/spec/07-plugins/03-plugin-api.md@@ -660,7 +660,7 @@ type PluginGlobalShortcut = {`command` 必须已经由调用插件注册;否则以 `INVALID_ARGUMENT` 失败。被操作系统保留、被 PI-Desktop 自己当前占用(默认 `Alt+Space` 打开插件启动器、-`Mod+W` 呼出或隐藏窗口;用户改绑后释放出来的加速键可以再次被插件使用)或+`Alt+Shift+W` 呼出或隐藏窗口;用户改绑后释放出来的加速键可以再次被插件使用)或已被另一个插件持有的加速键会被拒绝而不是被抢走,被拒绝的重新注册会保留原来的绑定。拒绝是返回的结果,不是抛出的异常:`registerGlobalShortcut` 以 `registered: false` 解析,并带 `error` 为diff --git a/docs/zh-CN/spec/07-plugins/04-plugin-security.md b/docs/zh-CN/spec/07-plugins/04-plugin-security.mdindex 309d811f8..f8f6a38bb 100644--- a/docs/zh-CN/spec/07-plugins/04-plugin-security.md+++ b/docs/zh-CN/spec/07-plugins/04-plugin-security.md@@ -318,7 +318,7 @@ MCP 调用相同的 IPC 校验、生命周期检查、完成事件和审计条Electron 的 `globalShortcut`;插件永远拿不到键盘钩子、`before-input-event`、原始输入设备或按键事件流,所以不存在键盘记录器形状的表面,也无法看到用户按下的键。插件只能把加速键映射到自己已注册的一条命令;被操作系统保留、被-PI-Desktop 自己当前占用(默认是 `Alt+Space` 与 `Mod+W`;用户改绑后+PI-Desktop 自己当前占用(默认是 `Alt+Space` 与 `Alt+Shift+W`;用户改绑后即可释放给插件)或已被另一个插件持有的加速键会被拒绝,返回 `SHORTCUT_CONFLICT` / `SHORTCUT_UNAVAILABLE` /`INVALID_ACCELERATOR` / `LIMIT_EXCEEDED`(每个插件最多 8 条),而不是被抢走。diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex b3109d52d..ef5ec6e8a 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -4294,11 +4294,12 @@ that amendment are retired by ADR 0268; the upstream work-panel lifecycle stays.`closeWindow`(`Mod+W`)的「对称键」,并由 `04-ux/09-interaction-patterns.md` §1.1记载 —— 因此 D438 取代 D384 的这一半;同一条决策里的插件 Plan 安全动作选项不受影响。编号跳过 D435 与 D437,因为其它在途工作已先占用。-- 快捷键目录现在只保留 `window` 组里的一个 `toggleWindow`,各平台默认值都是 `Mod+W`。- `closeWindow` 与 `summonWindow` 已从 `KEYBOARD_SHORTCUT_IDS` 移除,因此被弃用的- `Mod+Shift+W` 不再被任何东西占用:它既不是随应用发布的默认值,也不会注册到- `globalShortcut`,既不是设置行,也不是菜单加速键。插件快捷键注册表因此改为拒绝- `Alt+Space` 与 `Mod+W`,而被释放出来的 `Mod+Shift+W` 可以交给插件使用。+- 快捷键目录现在只保留 `window` 组里的一个 `toggleWindow`;`closeWindow` 与+ `summonWindow` 已从 `KEYBOARD_SHORTCUT_IDS` 移除,因此两个退役组合键都不再被任何+ 东西占用:它们既不是随应用发布的默认值,也不会注册到 `globalShortcut`,既不是设置行,+ 也不是菜单加速键,而被释放出来的 `Mod+Shift+W` 可以重新交给插件使用。D439 后来把+ 开关键自己的默认值从 D438 选的 `Mod+W` 挪开;合并后的 id、切换语义与下面的迁移规则+ 都不受这次改键影响。- 按下这个键是一次判定,而不是一次关闭。`windowToggleAction` 对可见且在前台的窗口执行`Window.hide()`,其余情况显示并获得焦点(已隐藏、已最小化、被其它应用挡在后面都算「不可见」)。`Window.hide()` 就是隐藏的全部路径,所以 Windows/Linux 的关闭行为询问、@@ -4309,7 +4310,7 @@ that amendment are retired by ADR 0268; the upstream work-panel lifecycle stays.`migrateKeybindingOverrides` 在读取时就折叠映射 —— Electron 主进程在注册加速键和构建菜单之前,渲染层 store 在任何消费方看到它之前 —— 因此没有任何表面会按退役 id 行事。规则有序且幂等:已存在的 `toggleWindow` 覆盖原样胜出;否则第一个带*绑定值*的退役项胜出,- `closeWindow` 优先,因为 `Mod+W` 正是开关键保留的那个键;只有在没有绑定值竞争时,+ `closeWindow` 优先,因为隐藏才是开关键的主要职责;只有在没有绑定值竞争时,仅写入 `null` 的退役项才被尊重,所以明确的「未绑定」不会被随应用发布的默认值顶替;与自身退役默认值相同的存储值不携带任何意图(设置界面会删除等于发布默认值的覆盖项),因此 `Mod+W`/`Mod+Shift+W` 这类值会被丢弃而不是被复活。存储本身不做改写:折叠后的映射@@ -4330,3 +4331,27 @@ that amendment are retired by ADR 0268; the upstream work-panel lifecycle stays.- 主进程新增可加的 `project/cloneCheckout({ url, parentPath })`:它克隆到显式指定的父目录并返回 `{ path, name }`,不更改当前工作空间、也不弹出选择器。`project/clone` 为首页切换器保留原有的原生选择器行为。- 项目创建语义不变:两种来源调用同一个项目 slice 助手,`project-group/create` 仍写入唯一的持久记录,检出目录成为同一逻辑项目组的主要根(ADR 0233)。- 渲染器加一条窄的主进程能力:协议、schema、host RPC、权限、存储与偏好均无变化。见 ADR 0273、`03-runtime/01-ipc-protocol.md` §9、`04-ux/08-component-spec.md` 与 E2E-258。++## 2026-09-17 —— 窗口开关键避开 macOS 的关闭窗口组合键(#360,D439)++- D438 把两个键合并到了 `Mod+W`,但这个键不能作为*系统级*全局加速键的默认值:+ macOS 把 `Cmd+W` 用于自己的「关闭窗口」命令,全局占用它等于从所有其它应用程序+ 手里把这个组合键抢走,而不只是关闭本窗口。因此 `Mod+W` 正是开关键唯一不能持有的键。+- 快捷键目录现在把 `toggleWindow` 发布在 `Alt+Shift+W` 上 —— 不含平台修饰键,因此在+ macOS、Windows 与 Linux 上是同一个组合键 —— 它与任何发布默认值、保留的编辑组合键+ 以及平台命令都不冲突。合并本身、隐藏/显示语义、以及退役的+ `closeWindow`/`summonWindow` 覆盖项的折叠规则,完全保持 D438 定义的样子。+- 在 macOS 上 `Mod+W` 现在也拒绝交给插件(`isReservedKeybinding`),因此即使应用不再+ 使用它,平台仍然独占它自己的这个组合键。+- 只重复「本版本发布默认值」或「已被取代的默认值」的 `toggleWindow` 存储值不携带用户+ 意图,折叠时会丢弃:曾经持久化过那个短命 `Mod+W` 默认值的配置会迁移到+ `Alt+Shift+W`,而不是把 macOS 的组合键冻结住;真实改绑(`Ctrl+Alt+T`)与明确的+ 「未绑定」(`null`)原样保留,退役项的自定义值也仍然优先于被丢弃的旧默认值。+- 编号取 D439,因为 D435 与 D437 已被其它在途工作占用。**注意**:本日志当前有两处+ `D438` —— 本文件上方的窗口开关键合并决策(#360,重绑前)与紧随其后的 Git 检出决策+ (ADR 0273)。后者是在开关键 D438 合入之后才追加的,编号需要由其作者改到 D440 或+ 之后的可用号;本条不代为改写他人决策正文。+- 见 ADR 0211(再次修订)、`04-ux/09-interaction-patterns.md` §1.1 与 §1.4、+ `04-ux/06-settings-ia.md`(快捷键选项卡)、`07-plugins/03-plugin-api.md`、+ `07-plugins/04-plugin-security.md`、E2E-072 与+ `apps/desktop/test/window-toggle-shortcut.test.mjs`。diff --git a/packages/shared/src/keyboard-shortcuts.test.ts b/packages/shared/src/keyboard-shortcuts.test.tsindex 7a4ebe53e..282721d31 100644--- a/packages/shared/src/keyboard-shortcuts.test.ts+++ b/packages/shared/src/keyboard-shortcuts.test.ts@@ -15,7 +15,7 @@ import {} from "./keyboard-shortcuts.js";describe("keyboard shortcut mapping", () => {- it("declares one window toggle in the window group with a Mod+W default", () => {+ it("declares one window toggle in the window group on the Alt+Shift+W default", () => {expect(KEYBOARD_SHORTCUT_IDS).toContain("toggleWindow");// D438: the summon/close pair is gone from the catalog, so nothing can// register the retired `Mod+Shift+W` chord any more.@@ -26,10 +26,18 @@ describe("keyboard shortcut mapping", () => {);expect(toggle).toBeDefined();expect(toggle!.group).toBe("window");- expect(toggle!.defaultBinding).toBe("Mod+W");- expect(resolveKeybinding(toggle!, undefined, "darwin")).toBe("Mod+W");- expect(resolveKeybinding(toggle!, undefined, "win32")).toBe("Mod+W");- expect(resolveKeybinding(toggle!, undefined, "linux")).toBe("Mod+W");+ expect(toggle!.defaultBinding).toBe("Alt+Shift+W");+ expect(resolveKeybinding(toggle!, undefined, "darwin")).toBe("Alt+Shift+W");+ expect(resolveKeybinding(toggle!, undefined, "win32")).toBe("Alt+Shift+W");+ expect(resolveKeybinding(toggle!, undefined, "linux")).toBe("Alt+Shift+W");+ // D439: the key is registered process-wide, so it must not be a chord the+ // platform owns. `Mod+W` closes a window on macOS and the app no longer+ // spends it anywhere.+ expect(+ KEYBOARD_SHORTCUTS.some((shortcut) => shortcut.defaultBinding === "Mod+W"),+ ).toBe(false);+ expect(isReservedKeybinding("Mod+W", "darwin")).toBe(true);+ expect(isReservedKeybinding("Alt+Shift+W", "darwin")).toBe(false);// One key, one binding: no shipped default may collide with it.for (const shortcut of KEYBOARD_SHORTCUTS) {if (shortcut.id === "toggleWindow") continue;@@ -199,15 +207,16 @@ describe("keyboard shortcut mapping", () => {});});-describe("retired window keybindings migrate into the toggle (D438)", () => {- it("leaves users who never customized a window key on the new default", () => {+describe("retired window keybindings migrate into the toggle (D438, D439)", () => {+ const toggle = () => KEYBOARD_SHORTCUTS.find((s) => s.id === "toggleWindow")!;++ it("leaves users who never customized a window key on the shipped default", () => {expect(migrateKeybindingOverrides(undefined)).toBeUndefined();expect(migrateKeybindingOverrides(null)).toBeUndefined();expect(migrateKeybindingOverrides({})).toBeUndefined();- const toggle = KEYBOARD_SHORTCUTS.find((s) => s.id === "toggleWindow")!;expect(- resolveKeybinding(toggle, migrateKeybindingOverrides({}), "darwin"),- ).toBe("Mod+W");+ resolveKeybinding(toggle(), migrateKeybindingOverrides({}), "darwin"),+ ).toBe("Alt+Shift+W");});it("carries a customized close binding onto the toggle key", () => {@@ -225,15 +234,15 @@ describe("retired window keybindings migrate into the toggle (D438)", () => {it("merges a customized summon binding into the toggle", () => {expect(- migrateKeybindingOverrides({ summonWindow: "Alt+Shift+W" }),- ).toEqual({ toggleWindow: "Alt+Shift+W" });+ migrateKeybindingOverrides({ summonWindow: "Ctrl+Alt+W" }),+ ).toEqual({ toggleWindow: "Ctrl+Alt+W" });});it("prefers the close entry when both retired keys were customized", () => {expect(migrateKeybindingOverrides({closeWindow: "Mod+Shift+Q",- summonWindow: "Alt+Shift+W",+ summonWindow: "Ctrl+Alt+W",}),).toEqual({ toggleWindow: "Mod+Shift+Q" });});@@ -244,8 +253,8 @@ describe("retired window keybindings migrate into the toggle (D438)", () => {});// A live binding still wins over a retired unbind.expect(- migrateKeybindingOverrides({ closeWindow: null, summonWindow: "Alt+Shift+W" }),- ).toEqual({ toggleWindow: "Alt+Shift+W" });+ migrateKeybindingOverrides({ closeWindow: null, summonWindow: "Ctrl+Alt+W" }),+ ).toEqual({ toggleWindow: "Ctrl+Alt+W" });});it("ignores stored values that only repeat a retired default", () => {@@ -260,6 +269,49 @@ describe("retired window keybindings migrate into the toggle (D438)", () => {).toBeUndefined();});+ it("frees a frozen Mod+W toggle so D439's default can apply", () => {+ // A release before D439 shipped `Mod+W`; the settings UI only stores a+ // binding a user actually chose, so an equal-to-old-default value carries no+ // intent and must not pin the toggle to the macOS close-window chord.+ expect(migrateKeybindingOverrides({ toggleWindow: "Mod+W" })).toBeUndefined();+ expect(+ resolveKeybinding(+ toggle(),+ migrateKeybindingOverrides({ toggleWindow: "Mod+W" }),+ "darwin",+ ),+ ).toBe("Alt+Shift+W");+ // A retired customization still wins over the dropped superseded default,+ // and a real customization is never rewritten.+ expect(+ migrateKeybindingOverrides({+ toggleWindow: "Mod+W",+ closeWindow: "Mod+Shift+Q",+ }),+ ).toEqual({ toggleWindow: "Mod+Shift+Q" });+ expect(+ migrateKeybindingOverrides({ toggleWindow: "Ctrl+Alt+T" }),+ ).toEqual({ toggleWindow: "Ctrl+Alt+T" });+ });++ it("drops a folded binding that lands on the shipped default", () => {+ // `Alt+Shift+W` is the current default, so it must not be persisted as an+ // override either — otherwise a later default change could never reach the+ // user again.+ expect(+ migrateKeybindingOverrides({ toggleWindow: "Alt+Shift+W" }),+ ).toBeUndefined();+ // The same value on a *retired* entry is kept as a genuine customization of+ // that retired key unless it repeats the current default too.+ expect(+ migrateKeybindingOverrides({ summonWindow: "Alt+Shift+W" }),+ ).toBeUndefined();+ // An explicit unbind is intent and always survives.+ expect(migrateKeybindingOverrides({ toggleWindow: null })).toEqual({+ toggleWindow: null,+ });+ });+it("is idempotent and never rewrites a later rebind", () => {const once = migrateKeybindingOverrides({closeWindow: "Mod+Shift+Q",@@ -268,9 +320,9 @@ describe("retired window keybindings migrate into the toggle (D438)", () => {expect(once).toEqual({ toggleWindow: "Mod+Shift+T" });expect(migrateKeybindingOverrides(once)).toEqual(once);expect(- migrateKeybindingOverrides(migrateKeybindingOverrides({- summonWindow: "Alt+Shift+W",- })),- ).toEqual({ toggleWindow: "Alt+Shift+W" });+ migrateKeybindingOverrides(+ migrateKeybindingOverrides({ summonWindow: "Ctrl+Alt+W" }),+ ),+ ).toEqual({ toggleWindow: "Ctrl+Alt+W" });});});diff --git a/packages/shared/src/keyboard-shortcuts.ts b/packages/shared/src/keyboard-shortcuts.tsindex fd8d61d2e..130f022d5 100644--- a/packages/shared/src/keyboard-shortcuts.ts+++ b/packages/shared/src/keyboard-shortcuts.ts@@ -53,7 +53,7 @@ export const KEYBOARD_SHORTCUTS: readonly KeyboardShortcutDefinition[] = [{ id: "toggleSidebar", group: "navigation", defaultBinding: "Mod+B" },{ id: "openWorkPanel", group: "navigation", defaultBinding: "Mod+J" },{ id: "abort", group: "agent", defaultBinding: "Mod+Period" },- { id: "toggleWindow", group: "window", defaultBinding: "Mod+W" },+ { id: "toggleWindow", group: "window", defaultBinding: "Alt+Shift+W" },{ id: "resetZoom", group: "window", defaultBinding: "Mod+0" },{ id: "zoomIn", group: "window", defaultBinding: "Mod+Equal" },{ id: "zoomOut", group: "window", defaultBinding: "Mod+Minus" },@@ -76,33 +76,46 @@ export type PersistedKeybindingOverrides = Record<>;/**- * Shortcut ids that the window toggle replaced (D438). Their stored overrides- * are folded into `toggleWindow` by `migrateKeybindingOverrides`.+ * Shortcut ids the window toggle replaced (D438). Both are retired outright, so+ * a stored override for either is folded into `toggleWindow` by+ * `migrateKeybindingOverrides` instead of being dropped.*/const RETIRED_WINDOW_SHORTCUTS = [- // The key the toggle keeps: `Mod+W` was the binding that hid the window, and- // it stays the binding that hides it.+ // Hiding is the toggle's primary job, so a customized close binding outranks+ // a customized summon binding.{ id: "closeWindow", defaultBinding: "Mod+W" },- // Retired outright: nothing summons the window with `Mod+Shift+W` any more.{ id: "summonWindow", defaultBinding: "Mod+Shift+W" },] as const;+/**+ * Defaults the window toggle shipped before the current one (D439). A stored+ * value that only repeats one of them carries no user intent, so the toggle+ * falls back to the default this release ships instead of freezing a superseded+ * key — which is what keeps `Mod+W`, the platform's own close-window chord, out+ * of a process-wide registration.+ */+const SUPERSEDED_TOGGLE_DEFAULTS = ["Mod+W"] as const;+/*** Fold the retired `closeWindow` / `summonWindow` overrides into the single- * `toggleWindow` entry (D438), for a persisted `settings.keybindings` map.+ * `toggleWindow` entry (D438) for a persisted `settings.keybindings` map, and+ * drop a stored toggle value that only repeats a default this release ships or+ * already superseded (D439).** Rules, in order:*- * - an existing `toggleWindow` override wins as it is, so the migration is- * idempotent and never rewrites a later rebind;+ * - an existing `toggleWindow` override is kept as it is, so the migration is+ * idempotent and never rewrites a later rebind — unless it only names the+ * current default or a superseded one, which carries no user intent;* - otherwise the first retired entry that carries a *binding* wins, in the- * order above. `closeWindow` comes first because `Mod+W` is the key the- * toggle keeps;+ * order above. Both are retired outright, and `closeWindow` comes first+ * because hiding is the toggle's primary job;* - a retired entry that is only `null` (the user unbound it) is honoured after* that: the toggle stays unbound instead of resurrecting a shipped default;* - a stored value equal to its retired default carries no intent (the* settings UI deletes overrides that match the shipped default), so it is- * ignored and the new default applies.+ * ignored and the new default applies. The same holds for a folded binding+ * that lands on the current or a superseded default.*/export function migrateKeybindingOverrides(overrides:@@ -121,15 +134,41 @@ export function migrateKeybindingOverrides(if (RETIRED_WINDOW_SHORTCUTS.some((retired) => retired.id === id)) continue;migrated[id] = binding;}+ // A stored toggle value that only repeats the current default or a superseded+ // one is "no intent": drop it so the fold below still sees a retired+ // customization, and the current default otherwise.+ if (+ Object.prototype.hasOwnProperty.call(migrated, "toggleWindow") &&+ !carriesToggleIntent(migrated.toggleWindow)+ ) {+ delete migrated.toggleWindow;+ }if (!Object.prototype.hasOwnProperty.call(migrated, "toggleWindow")) {const inherited = inheritedToggleBinding(legacy);- if (inherited !== undefined) migrated.toggleWindow = inherited;+ if (inherited === null) migrated.toggleWindow = null;+ else if (inherited !== undefined && carriesToggleIntent(inherited)) {+ migrated.toggleWindow = inherited;+ }}return Object.keys(migrated).length > 0? (migrated as KeybindingOverrides): undefined;}+/** True for `null` (an explicit unbind) and for any binding a user chose. */+function carriesToggleIntent(value: string | null): boolean {+ if (value === null) return true;+ const binding = normalizeKeybinding(value);+ if (!binding) return false;+ const definition = KEYBOARD_SHORTCUTS.find(+ (shortcut) => shortcut.id === "toggleWindow",+ );+ if (definition && binding === normalizeKeybinding(definition.defaultBinding)) {+ return false;+ }+ return !SUPERSEDED_TOGGLE_DEFAULTS.some((superseded) => superseded === binding);+}+function inheritedToggleBinding(legacy: Record<string, string | null | undefined>,): string | null | undefined {@@ -292,6 +331,10 @@ export function isReservedKeybinding(if (platform === "darwin") {common.add("Mod+Q");common.add("Mod+H");+ // macOS spends Cmd+W on its own close-window command. The app used to+ // register it process-wide as the window toggle; since D439 that binding is+ // neither the default nor available to anyone else.+ common.add("Mod+W");} else {common.add("Mod+Y");common.add("Alt+F4");