Skip to content

feat(web): add create PR and archive thread keybindings - #5443

Open
leo-mathurin wants to merge 1 commit into
pingdotgg:mainfrom
leo-mathurin:feat/create-pr-and-archive-keybindings
Open

feat(web): add create PR and archive thread keybindings#5443
leo-mathurin wants to merge 1 commit into
pingdotgg:mainfrom
leo-mathurin:feat/create-pr-and-archive-keybindings

Conversation

@leo-mathurin

@leo-mathurin leo-mathurin commented Aug 5, 2026

Copy link
Copy Markdown

What changed

Two new keybinding commands:

Command Default when
git.createPullRequest mod+shift+p !terminalFocus && gitCanCreatePr
thread.archive mod+shift+a !terminalFocus

thread.archive archives the thread you are currently on and lands you in a new draft in the same project, reusing the existing archiveThread action so the running-turn refusal and the archived-thread refresh behave exactly as they do from the sidebar.

git.createPullRequest opens a PR for the thread's ref.

Why the PR shortcut is gated

The shortcut is deliberately narrower than the existing "Create PR" menu item. That item accepts unpushed work and offers to commit and push first. A keyboard shortcut that did the same could publish commits the user had not decided to push, from a single mistyped chord.

So the shortcut only arms once the ref has nothing left to send: no working tree changes, an upstream configured, aheadCount and behindCount both zero, no PR already open, and something to propose against the default ref. While work is still uncommitted or unpushed the shortcut does nothing and the user goes through the menu, which explains what it is about to do.

This is expressed as a new gitCanCreatePr when-clause variable. It is supplied by GitActionsControl, which already owns the git status for the active thread. Routing the shortcut through the global handler in routes/_chat.tsx instead would have needed a second status subscription just to evaluate the gate.

aheadOfDefaultCount is optional on the wire, so a server old enough to omit it falls back to "not on the default ref". That keeps the shortcut alive there and lets the server reject the action if the ref turns out to have nothing to propose.

Collision check

mod+shift+p does not collide with mod+p (file picker), which matches unshifted only. There is a regression test for this.

Tests

  • GitActionsControl.logic.test.ts: the full gate matrix, including each negative branch and the missing-aheadOfDefaultCount fallback.
  • keybindings.test.ts: resolution of both commands, the gitCanCreatePr and terminalFocus gating, and the mod+p collision check.

On screenshots

CONTRIBUTING asks for before/after images on UI changes. There is nothing visual to show here: no new UI, no changed layout. The only rendered surface is Settings > Keybindings, which picks both rows up automatically from the existing label derivation, so they read as "Git: Create Pull Request" and "Thread: Archive" with no per-command wiring. Happy to add a short video of the shortcuts firing if that would help.

I read the "not actively accepting contributions" note and did not open an issue first. Close this if it is not wanted, no hard feelings.


Note

Low Risk
Keyboard-only UX on top of existing git and archive flows; PR shortcut is intentionally conservative to avoid accidental publishes.

Overview
Adds two keyboard shortcuts: mod+shift+p runs git.createPullRequest, and mod+shift+a runs thread.archive on the open thread (via existing archiveThread, with error toasts on failure).

The PR shortcut is stricter than the source-control “Create PR” menu: it only arms when gitCanCreatePr is true—clean worktree, upstream in sync (no ahead/behind), no open PR, and commits ahead of the default ref (with a fallback when aheadOfDefaultCount is missing). Uncommitted or unpushed work leaves the chord inert so a mistype cannot push or open a PR. GitActionsControl owns the listener and supplies gitCanCreatePr from git status already loaded there; _chat.tsx is not used for this command.

Defaults, contract command IDs, user docs, and tests cover the gate matrix, when gating (including terminal focus), and that unshifted mod+p still opens the file picker.

Reviewed by Cursor Bugbot for commit bfd8302. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add git.createPullRequest and thread.archive keybindings

  • Adds mod+shift+p to trigger the create PR action from the active thread, gated by a new gitCanCreatePr context key that requires a clean, synced branch with upstream and no open PR.
  • Adds mod+shift+a to archive the active thread; shows an error toast on failure. Both shortcuts are suppressed when terminal focus is active.
  • Implements canCreatePrFromPushedWork in GitActionsControl.logic.ts to compute gitCanCreatePr and wires the keydown handler into GitActionsControl.tsx.
  • Documents both shortcuts and the gitCanCreatePr context key in keybindings.md.

Macroscope summarized bfd8302.

Adds two commands to the keybindings system:

- `git.createPullRequest` (`mod+shift+p`) opens a pull request for the
  thread's ref.
- `thread.archive` (`mod+shift+a`) archives the thread you are looking at.

The PR shortcut is deliberately narrower than the "Create PR" menu item.
That item accepts unpushed work and pushes first; the shortcut only arms
once the ref has nothing left to send, so a stray keypress can never
publish commits the user has not pushed yet. This is expressed as a new
`gitCanCreatePr` when-clause variable, supplied by the control that
already owns the thread's git status.

`mod+shift+p` does not collide with `mod+p` (file picker), which matches
unshifted only.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 471d4728-352a-4696-99bd-700db2a7825c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Aug 5, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces two new keyboard shortcuts (mod+shift+p for PR creation, mod+shift+a for archiving) that add new user-facing capabilities. While well-tested and the underlying actions exist, new feature additions from a first-time contributor warrant human review.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant