Skip to content

feat(term): open terminals in normal mode, hardcode q as close#324

Merged
barrettruth merged 1 commit intomainfrom
feat/q-close-terminals
Apr 19, 2026
Merged

feat(term): open terminals in normal mode, hardcode q as close#324
barrettruth merged 1 commit intomainfrom
feat/q-close-terminals

Conversation

@barrettruth
Copy link
Copy Markdown
Owner

Problem

Forge's terminal buffers (CI watch, checks live-tail) opened with `startinsert`, leaving the cursor in terminal mode. The `q` close keymap was only registered in normal mode, so pressing `q` right after the buffer opened sent a literal `q` to the underlying shell instead of closing the buffer — users had to `<C-\>q` to get out. The `keys.log.close` config key also existed as a customization point for an action ("close this viewer") that has a strong cross-vim convention (`q` in quickfix, help, diffview, trouble, fugitive) and doesn't benefit from being tunable.

Solution

Flip `term.open`'s default so terminals open in normal mode; callers that genuinely need insert mode can still pass `startinsert = true`. Hardcode `q` as the close key across terminal, static log, and summary buffers, and remove `keys.log.close` from config defaults, validation, and the `forge.LogViewerKeys` annotation. The rest of `keys.log` (navigation, browse, refresh) stays configurable since those are forge-specific and less conventional. Tests cover the new default (no insert unless requested) and verify `q` actually closes the buffer.

Forge terminal buffers (CI watch, checks live-tail) previously opened
with startinsert, which put the cursor in terminal mode. The q keymap
was wired in normal mode only, so q pressed immediately after the
terminal opened was sent to the underlying shell instead of closing the
buffer — a consistent UX wart reported in #310.

Flip the default so term.open stays in normal mode unless startinsert
is explicitly requested. This makes the q close keymap (and the existing
gx browse and <cr> enter keymaps) work immediately without any
<C-\><C-n> dance. For the commands we actually run (gh run watch, glab
ci trace, etc.) the terminal is a passive stream — users are reading,
not typing — so normal mode is the right default.

Also hardcode q as the close key for terminal, static log, and summary
buffers. Let users configure step/error navigation, browse, and refresh
via keys.log; close is conventional and across enough of vim
(quickfix/help/messages/diffview/trouble) that making it a config knob
added surface area without real value. keys.log.close is removed from
defaults, validation, and the forge.LogViewerKeys annotation. The
existing startinsert = false callsite in ops.lua is dropped since false
is now the default.

Closes #310
@barrettruth barrettruth merged commit 75bd7e1 into main Apr 19, 2026
1 check passed
@barrettruth barrettruth deleted the feat/q-close-terminals branch April 19, 2026 04:13
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