Skip to content

feat: add a command palette and shortcuts for the common commands - #57

Merged
Lars- merged 1 commit into
mainfrom
feat/command-palette
Nov 20, 2026
Merged

Lars- merged 1 commit into
mainfrom
feat/command-palette

Conversation

@Lars-

@Lars- Lars- commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Press Ctrl+Shift+P (Cmd+Shift+P on a Mac) for a command palette: type a few words of what you want to do and pick it with the arrows and Enter, or click it. It lists every button of the toolbar and what its right-click menus offer (pull with rebase, push to a remote, force push, push tags), the tabs (open a repository, new, close, next, previous), committing, and everything the right-click menu of the selected commit and its branches and tags offers, named after the commit (Commit 4a53126 › Cherry-pick commit, Commit 4a53126 › Reset current branch to this commit › Hard: discard all changes). A command that cannot run now is listed greyed out, so the list does not jump while you type.

The common commands also have a shortcut, shown next to them in the palette and in the tooltips of the toolbar:

Undo, redo Ctrl+Z, Ctrl+Shift+Z
Fetch, pull, push Ctrl+Shift+F, Ctrl+Shift+Down, Ctrl+Shift+Up
New branch, stash Ctrl+B, Ctrl+Shift+S
Refresh F5
Commit Ctrl+Enter
Open a repository Ctrl+O
New tab, close tab Ctrl+T, Ctrl+W
Next and previous tab Ctrl+Tab, Ctrl+Shift+Tab (the start screen counts as the last tab)

While a text field has the keyboard (the commit message, the search), the field keeps its keys (Ctrl+Z undoes typing, Ctrl+W deletes a word), apart from Ctrl+Enter, which commits. No shortcut works while a dialog is open. While git is busy, what a key or the palette runs waits its turn, as clicks in menus already do; only undo and redo wait until git is done, because what they do depends on where it leaves HEAD.

How it is built, with as little new code as it needs:

  • commands.rs names each command once, with its shortcut and its action (or None while it cannot run). The toolbar now draws its buttons from that same list, so the toolbar, the keys and the palette cannot drift apart.
  • The right-click menus of a commit and of a branch or tag became lists of (name, action) (graph::commit_items, graph::ref_items), drawn by one graph::menu, which puts items named submenu › item in a submenu. The sidebar's own menu helper is gone.
  • Copying the SHA is now an action (Action::Copy), so the palette can do it too; "Open a repository…" is Action::PickRepo, for the start screen's button and Ctrl+O alike. The form's commit is Workspace::commit, for the button and Ctrl+Enter.
  • Keys are read before a reload can start by itself in the frame, so a reload the watcher starts never swallows them.

This is part 1 of "Keyboard" on the roadmap; part 2 adds shortcuts in the views (stage and discard in a diff, next and previous file, close) and the start screen's clone and create.

How it is tested

  • the_command_palette_finds_a_command_by_words_of_its_name: Ctrl+Shift+P opens it with the keyboard in its field; "new br" lists only "New branch…", Enter opens the branch dialog and the branch gets made; words that match nothing say so, Enter then does nothing, and Escape closes the palette without reaching anything behind it.

  • the_command_palette_has_what_the_selected_commit_offers: with an older commit selected, "reset" lists its three resets; down and up go round at both ends while the keyboard stays in the field, and Enter on the hard reset asks first. "tag" lists the commit's tag to delete and "Create tag here…"; "Copy commit SHA" puts the full SHA on the clipboard; after the palette closes, Ctrl+Z undoes again.

  • shortcuts_run_commands_but_leave_a_text_field_its_keys: Ctrl+Z undoes a commit and Ctrl+Shift+Z redoes it (it fails when Ctrl+Z is checked first, since egui matches Ctrl+Shift+Z for it too); typing a message, Ctrl+T does nothing and Ctrl+Enter commits (it fails without the check on typing); then Ctrl+T, Ctrl+Tab, Ctrl+Shift+Tab and Ctrl+W open, go through and close the tabs.

  • while_git_is_busy_the_keyboard_queues_what_it_runs_apart_from_undo: with a reload running, stash, fetch and new branch can run and undo cannot; Ctrl+Shift+S then stashes.

  • All tests of the toolbar and the right-click menus pass unchanged.

  • Tried in the app on Linux with the demo repository: the palette from the keyboard, "reset" with the arrows, "new br" and Enter (the branch dialog), Ctrl+T and Ctrl+Tab, the shortcut in the Fetch tooltip, and Ctrl+Shift+F straight after switching tabs (it fetched).

  • cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass

  • It adds as little code as the change needs, and removes what it makes unnecessary

  • Nothing in it comes from GitKraken or another closed-source client (see CONTRIBUTING.md)

@Lars-
Lars- merged commit 72525b5 into main Nov 20, 2026
7 checks passed
@Lars- Lars- mentioned this pull request Nov 20, 2026
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