From 36404a6cbbc2e18370ad57db97993a2212bcaa17 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sun, 23 Aug 2026 01:19:51 +0800 Subject: [PATCH] fix(keymap): Restart Server is bindable, like every other menu item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forty-five items in the app menu dispatch an action. Forty-four of them can be given a key; `RestartDaemon` could not, because it was missing from `default_bindings` and `make_binding` — so config.json dropped the name silently and the Keybindings page never listed it. Nothing else was missing. The gpui action is declared, the handler is wired, the app menu dispatches it and the palette runs it. Only the two table entries that make a name bindable were absent. This corrects a claim I made when I moved it out of the palette's chord lookup: I said then that making it bindable "means a gpui action and a handler, which is a feature rather than a fix". That was wrong — both already existed, and the app menu had been dispatching the action the whole time. Finding it took comparing the menu against the keymap rather than reading either alone. No default chord, like the sixty-odd others that ship unbound. The palette gets its chord lookup back, so once a key is on it the row shows it — which is the thing that lookup was doing wrong before and is now simply right. The shortcuts-page guard added earlier this session caught the last step without being asked: it failed on `RestartDaemon` the moment the action became bindable, which is what it is for. --- docs/reference/keyboard-shortcuts.mdx | 2 +- src/ui/keymap.rs | 10 ++++++++++ src/ui/palette.rs | 8 +------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/reference/keyboard-shortcuts.mdx b/docs/reference/keyboard-shortcuts.mdx index cb233367..7bae2e82 100644 --- a/docs/reference/keyboard-shortcuts.mdx +++ b/docs/reference/keyboard-shortcuts.mdx @@ -113,7 +113,7 @@ Keybindings**: | Panels | `ShowRightPanelInfo` · `ShowRightPanelChanges` · `ShowRightPanelFiles` | | Document | `ToggleDocumentFill` · `DocumentWidthThird` · `DocumentWidthHalf` · `DocumentWidthTwoThirds` | | SSH | `ToggleSftp` · `ShowSshForwards` · `OpenSshProfiles` | -| Application | `About` · `CheckForUpdates` · `OpenDocumentation` · `OpenDiscord` · `ReportIssue` · `ShowAll` · `ZoomWindow` | +| Application | `About` · `CheckForUpdates` · `OpenDocumentation` · `OpenDiscord` · `ReportIssue` · `ShowAll` · `ZoomWindow` · `RestartDaemon` | ## Rebinding syntax diff --git a/src/ui/keymap.rs b/src/ui/keymap.rs index 9e3bde13..4c24580b 100644 --- a/src/ui/keymap.rs +++ b/src/ui/keymap.rs @@ -465,6 +465,11 @@ pub(crate) fn default_bindings() -> Vec<(&'static str, &'static str)> { // Deliberately unbound. Docking is the default and Esc already gets the // terminal back, so a default chord here would only be one more thing // competing for a two-key combination nobody asked for. + // Bindable with no default chord, like the rest of this run. It is + // reachable from the app menu and the palette; leaving it out of + // this table was the one thing that made it the only menu item of + // forty-five a user could not put a key on. + ("RestartDaemon", ""), ("ToggleDocumentFill", ""), ("DocumentWidthThird", ""), ("DocumentWidthHalf", ""), @@ -654,6 +659,10 @@ fn authored_entry(action: &str) -> Option<(CommandGroup, String)> { t(L10nKey::AppMenuRightPanel).to_string(), ), "ToggleCodePanel" => (CommandGroup::View, t(L10nKey::AppMenuCodePanel).to_string()), + "RestartDaemon" => ( + CommandGroup::Application, + t(L10nKey::CmdRestartServer).to_string(), + ), "ToggleDocumentFill" => ( CommandGroup::View, t(L10nKey::CmdToggleDocumentFill).to_string(), @@ -1228,6 +1237,7 @@ fn make_binding(action: &str, keystroke: &str) -> Option { "ToggleSftp" => KeyBinding::new(keystroke, ToggleSftp, None), "ShowSshForwards" => KeyBinding::new(keystroke, ShowSshForwards, None), "ToggleCodePanel" => KeyBinding::new(keystroke, ToggleCodePanel, None), + "RestartDaemon" => KeyBinding::new(keystroke, RestartDaemon, None), "ToggleDocumentFill" => KeyBinding::new(keystroke, ToggleDocumentFill, None), "DocumentWidthThird" => KeyBinding::new(keystroke, DocumentWidthThird, None), "DocumentWidthHalf" => KeyBinding::new(keystroke, DocumentWidthHalf, None), diff --git a/src/ui/palette.rs b/src/ui/palette.rs index 350e4526..165202bd 100644 --- a/src/ui/palette.rs +++ b/src/ui/palette.rs @@ -302,6 +302,7 @@ impl CommandKind { ScmCommitAmend => "ScmCommitAmend", ScmRefresh => "ScmRefresh", ScmToggleGraph => "ScmToggleGraph", + RestartDaemon => "RestartDaemon", ScmPull => "ScmPull", ScmFetch => "ScmFetch", ScmSync => "ScmSync", @@ -309,12 +310,6 @@ impl CommandKind { OpenBranchPicker => "ScmCheckoutBranch", ToggleDiffViewMode => "ToggleDiffViewMode", // No keymap action of their own, so there is no shortcut to show. - // `RestartDaemon` is here rather than above because it named - // `"RestartDaemon"`, which the keymap has never bound: the lookup - // could only ever come back empty, and naming an action that does - // not exist reads like one that does. Restarting the server is - // palette-only for now; giving it a bindable action means a gpui - // action and a handler, which is a feature rather than a fix. CopyText | CutText | PasteText @@ -325,7 +320,6 @@ impl CommandKind { | OpenThemePicker | OpenSshConnectInput | OpenSshConnect(_) - | RestartDaemon | SetTheme(_) | ActivateTab(_) | ConnectSavedProfile(_)