Skip to content

fix(prompt): support ESC to skip PR creation#85

Merged
boneskull merged 1 commit intomainfrom
fix/esc-key-skip
Apr 13, 2026
Merged

fix(prompt): support ESC to skip PR creation#85
boneskull merged 1 commit intomainfrom
fix/esc-key-skip

Conversation

@boneskull
Copy link
Copy Markdown
Owner

Summary

  • Fixes ESC key doing nothing when prompted to create a PR during gh stack submit
  • Both ESC and Ctrl+C now correctly skip PR creation
  • Corrects the skip message from (user pressed ESC) to (skipped) — accurate regardless of which key was used

Root cause

huh v1.0.0's default KeyMap.Quit only binds ctrl+c. ESC is not wired to quit at the form level, so it was silently ignored.

InputWithSkip was calling huh.NewInput().Run(), which internally wraps the field in a new form with the default keymap. The fix builds the form manually with a custom keymap that adds esc alongside ctrl+c as quit keys.

Notes

  • charmbracelet/bubbles (already an indirect dep via huh) is promoted to a direct dependency since we now import its key sub-package explicitly.

Closes #78

huh v1.0.0's default `KeyMap.Quit` binding only includes `ctrl+c`;
pressing ESC at the form level was silently ignored.

Fix `InputWithSkip` to build the form manually with a custom keymap
that adds `esc` alongside `ctrl+c` as quit keys, so both gestures
trigger `huh.ErrUserAborted` and skip PR creation cleanly.

Also corrects the fallout message from "(user pressed ESC)" to
"(skipped)", which is accurate regardless of which key was used.

`charmbracelet/bubbles` (already an indirect dep) is promoted to
direct because we now import its `key` sub-package explicitly.

Closes #78
@claude
Copy link
Copy Markdown

claude bot commented Apr 13, 2026

Claude finished @boneskull's task in 1m 8s —— View job


Code Review

  • Gather context
  • Read changed files
  • Review changes
  • Post feedback

The fix is correct and well-targeted. The root cause analysis in the PR description is accurate: huh.NewInput().Run() internally wraps the field in a default-keymapped form where ESC is unbound at the form level, so it was silently swallowed.

internal/prompt/prompt.go — core fix

The approach is idiomatic for huh:

km := huh.NewDefaultKeyMap()
km.Quit = key.NewBinding(
    key.WithKeys("ctrl+c", "esc"),
    key.WithHelp("esc/ctrl+c", "skip"),
)

Starting from huh.NewDefaultKeyMap() is the right call — it inherits all other bindings and only overrides Quit, so navigation, editing, and other form keys continue to work as expected. huh.ErrUserAborted is the correct sentinel to check for both quit keys.

WithShowHelp(false) preserves the previous UX (no footer help bar), which is fine since the Description field already communicates the skip hint to the user. The help text on the binding ("esc/ctrl+c skip") would only appear if WithShowHelp(true) were set.

cmd/submit.go — two minor stale comments

The skip message fix ((skipped) instead of (user pressed ESC)) is correct. However, two doc comments were not updated:

  1. cmd/submit.go:50ErrPRSkipped is returned when a user skips PR creation by pressing ESC.
    ESC is now one of two quit keys; Ctrl+C also returns this error. Fix this →

  2. cmd/submit.go:455where skipped is true if user pressed ESC
    Same stale phrasing. Fix this →

go.mod — correct

Promoting charmbracelet/bubbles from indirect to direct is appropriate given the explicit import of github.com/charmbracelet/bubbles/key in prompt.go.


Summary: The fix is correct and the implementation is clean. Only two minor doc comment nits remain — both say "pressing ESC" where "ESC or Ctrl+C" would now be accurate.

@boneskull boneskull merged commit bfce25d into main Apr 13, 2026
9 checks passed
@boneskull boneskull deleted the fix/esc-key-skip branch April 13, 2026 01:45
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.

ESC does not skip submission of a new PR

1 participant