Skip to content

fix(tui): bind home/end to line start/end in input#25355

Open
euxaristia wants to merge 2 commits intoanomalyco:devfrom
euxaristia:fix/home-end-line-jump
Open

fix(tui): bind home/end to line start/end in input#25355
euxaristia wants to merge 2 commits intoanomalyco:devfrom
euxaristia:fix/home-end-line-jump

Conversation

@euxaristia
Copy link
Copy Markdown

@euxaristia euxaristia commented May 1, 2026

Issue for this PR

Closes #14899

(Overlaps with the older PR #19135, which targets packages/opencode/src/config/config.ts — keybind defaults have since moved to packages/opencode/src/config/keybinds.ts, so #19135 no longer applies cleanly. This PR updates the current source-of-truth file plus all 18 docs and the in-app tips view; happy to defer to #19135 if its author rebases.)

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

In the default keybinds, home and end (sent by the dedicated Home/End keys on PC layouts and by fn+left / fn+right on Apple keyboards) were claimed by two actions at once:

  • messages_first: "ctrl+g,home" / messages_last: "ctrl+alt+g,end" — message-history navigation.
  • input_buffer_home: "home" / input_buffer_end: "end" — jump to start/end of the entire input buffer.

So pressing them in the input did anything except what every other terminal app does — jump to the start/end of the current line. (Issue #14899 reports exactly this: "Nothing happens (it tries to scroll the message history…)".)

The fix moves bindings to match the universal convention used by GNU readline, every major terminal app, and every text editor:

Action Before After
messages_first ctrl+g,home ctrl+g
messages_last ctrl+alt+g,end ctrl+alt+g
input_line_home ctrl+a ctrl+a,home
input_line_end ctrl+e ctrl+e,end
input_select_line_home ctrl+shift+a ctrl+shift+a,shift+home
input_select_line_end ctrl+shift+e ctrl+shift+e,shift+end
input_buffer_home home ctrl+home
input_buffer_end end ctrl+end
input_select_buffer_home shift+home ctrl+shift+home
input_select_buffer_end shift+end ctrl+shift+end

Why these new buffer-jump bindings work: ctrl+home / ctrl+end is the long-standing buffer-jump convention in essentially every text editor (VS Code, JetBrains, Sublime). Users who already customized any of these in their tui.json keep their override — defaults are only applied when a key is absent.

Other touched files:

  • All 18 keybinds.mdx files (English + 17 locales) updated so the published default table matches keybinds.ts.
  • tips-view.tsx — two tips that said "Press Ctrl+G or Home" / "Press Ctrl+Alt+G or End" updated to drop the now-removed alias.

How did you verify your code works?

  • Ran bun turbo typecheck from the repo root — all 13 packages pass.
  • Manually verified in the TUI on Ubuntu (Linux 7.0.0-15-generic) with an Apple Magic Keyboard:
    • fn+left / fn+right (which the terminal sends as Home/End) now move the caret to line start/end inside a multi-line prompt instead of scrolling the conversation.
    • ctrl+home / ctrl+end jump to the start/end of the entire input buffer.
    • shift+home / shift+end extend selection to line start/end; ctrl+shift+home / ctrl+shift+end extend to buffer start/end.
    • ctrl+g / ctrl+alt+g still navigate message-history first/last.

Screenshots / recordings

Not applicable — no visual changes; the only user-visible text change is the two tip strings, which are covered in the diff.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • This PR was authored manually and follows standard English conventions for capitalization, punctuation, and readability.

Previously home/end (sent by fn+left/right on Apple keyboards and the
Home/End keys on PC layouts) were claimed by both messages_first/last
and input_buffer_home/end, so pressing them in the input jumped through
the message history instead of the current line. Move home/end onto
input_line_home/end (the standard convention in terminals and editors)
and shift the buffer-jump bindings to ctrl+home/ctrl+end (and
ctrl+shift+home/end for selection). Drop the home/end aliases from the
message-navigation bindings; ctrl+g and ctrl+alt+g still work for those.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

The following comment was made by an LLM, it may be inaccurate:

Found a potential duplicate:

PR #19135: "fix(opencode): restore Home/End prompt navigation in TUI"

Both PRs seem to be addressing keybinding behavior for Home/End keys in the terminal UI. Check if #19135 is already merged or if it overlaps with your changes.

The two tips referencing Home/End for conversation navigation are no
longer accurate now that those aliases were removed from messages_first
and messages_last in the previous commit.
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

"home" and "end" keys are bound twice

1 participant