Skip to content

feat(tui): scroll permission diff with pageup and pagedown - #58671

Open
yogo1212 wants to merge 1 commit into
anomalyco:devfrom
yogo1212:permission-diff-scroll
Open

yogo1212 wants to merge 1 commit into
anomalyco:devfrom
yogo1212:permission-diff-scroll

Conversation

@yogo1212

@yogo1212 yogo1212 commented Oct 24, 2026 •

Copy link
Copy Markdown

Issue for this PR

can't scroll diff view with mouse disabled.

side note:

using agents to installi git hooks to run code when it's not expected?
not cool.

also: my host doesn't have the tools to run the test. that's sandbox territory. just rely on the tests.

i can only hope that other parts of this software were written with slightly more awareness for security-issues.

Type of change

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

What does this PR do?

with the mouse disabled, there is currently no way to scroll proposed diffs.
this PR adds a keybind for scrolling the permission prompt.
in addition to that, use the fullscreen permissions prompt (ctrl-f by default) to be able to divert the input to the diff view

How did you verify your code works?

i started opencode from the local repo using bun (see the asciinema further down) and prompted the agent to propose a diff.
then, i opened the diff fullscreen using ctrl-f and scrolled up and down using the page up/down keys. i closed the fullscreen view again and scrolled the transcript using the same keys.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.
opencode.asciinema.txt

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.


Added by the opencode bot (AI-generated).

Fixes #50903

Related: #55748

Public API: adds TUI keybinds permission.prompt.scroll.up (pageup,kppageup) and permission.prompt.scroll.down (pagedown,kppagedown) (backwards compatible)

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Oct 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@yogo1212
yogo1212 force-pushed the permission-diff-scroll branch from 9d4d1ad to fe62e1b Compare October 24, 2026 09:51

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sound. In fullscreen (ctrl+f), the new keybinds scroll the permission diff. When the prompt is collapsed, the session's own page keys are left alone because the scroll commands are only registered while expanded. I checked this with your render test, which passes here and fails when copied onto the base branch. tsc -b for packages/tui and the nearby permission and session tests also pass. I couldn't get a live permission prompt in the TUI test harness, so a short before/after screenshot or recording in the description would help reviewers.

Public API: adds two TUI config keybinds, permission.prompt.scroll.up (default pageup) and permission.prompt.scroll.down (default pagedown). Nothing existing changes, so it is backwards compatible.

Small requests: drop the hand edit to packages/console/app/public/tui.json (see the inline comment). The added keybind.test.ts case only repeats the two default values, so it can go too; the render test already covers the behaviour.

Fixes #50903
Related: #55748

Comment thread packages/console/app/public/tui.json Outdated
],
"description": "Toggle permission prompt fullscreen"
},
"permission.prompt.scroll.up": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generated schema hasn't been updated since the v2 promotion: it's missing current keybinds such as session.page.up, diff.half_page.down and which-key.scroll.up. Adding only these two keys by hand makes up most of this PR's lines and leaves the file half-updated. I'd drop this file from the PR; refreshing it belongs in a separate regeneration.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add dialog.plugins.error to the list

Comment thread packages/tui/test/keybind.test.ts Outdated
})

test("permission prompt scrolling defaults to pageup and pagedown", () => {
expect(TuiKeybind.Definitions["permission.prompt.scroll.up"].default).toBe("pageup")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only repeats the two default values from keybind.ts, and permission-scroll.test.tsx already covers the behaviour. It can be dropped to keep the change small.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push only rebases the branch onto newer dev: the PR's own commit is unchanged. On the new head, the render test and tsc -b for packages/tui still pass. My two earlier points (the hand edit to packages/console/app/public/tui.json and the keybind.test.ts case that only repeats the defaults) still apply. Public API is the same as before: it adds the TUI keybinds permission.prompt.scroll.up (pageup) and permission.prompt.scroll.down (pagedown), which is backwards compatible.

@yogo1212
yogo1212 force-pushed the permission-diff-scroll branch from fe62e1b to f2b1f58 Compare October 24, 2026 10:56

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both earlier points are addressed: the hand edit to tui.json and the keybind.test.ts case are gone, and the rest of the change is the same. On the new head, the render test and tsc -b for packages/tui pass. Public API is unchanged from before: it adds the TUI keybinds permission.prompt.scroll.up (pageup) and permission.prompt.scroll.down (pagedown), which is backwards compatible. Nothing new to raise.

@yogo1212

yogo1212 commented Oct 24, 2026 •

Copy link
Copy Markdown
Author

two things i've kept out of this:

  1. the footer doesn't show the bindings for scrolling.
    i think that's reasonable.

  2. the scroll amount is smaller by convention (e.g. less or vim).
    this one uses .scrollBy(1, "viewport") which was chosen to not add more complexity.

other thing i'm not entirely happy about:

passing-through the scroller is a little clunky. honestly, i don't see a better way that keeps this change to a reasonable size. probably, some more groundwork before this could help but that is a decision for a maintainer.

@yogo1212
yogo1212 force-pushed the permission-diff-scroll branch from f2b1f58 to 4aab5d5 Compare October 24, 2026 11:05

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push only moves the branch onto a different dev commit; the PR's own commit is unchanged. On the new head, the render test and tsc -b for packages/tui pass. Both earlier points (the tui.json edit and the extra keybind.test.ts case) stay addressed. Public API is the same as before: it adds the TUI keybinds permission.prompt.scroll.up (pageup) and permission.prompt.scroll.down (pagedown), which is backwards compatible. Nothing new to raise.

@argszero

Copy link
Copy Markdown
Contributor

One measured gap: the two new defaults match only the plain page keys, so a numeric-keypad PageUp/PageDown scrolls nothing in the diff.

@opentui/core 0.6.8 decodes the kitty functional keys as kppageup (CSI 57421 u) and kppagedown (CSI 57422 u) — separate key names, not aliases of pageup/pagedown. Probing @opentui/keymap 0.6.8 on this head:

createKeyMatcher("pagedown")({ name: "kppagedown", ... }) // false
press("pagedown")    // the bound command ran once
press("kppagedown")  // the bound command never ran

Nothing normalizes them in between: the only key-name rewrite addon, registerBaseLayoutFallback, applies to non-ASCII or digit base codes, not to kp*.

Why it lands on this PR in particular: with the mouse disabled, the people who need these keys are on laptops, where PageUp/PageDown is often reachable only as NumLock-off keypad Page Up/Down (Fn+arrow or the keypad itself). Those presses arrive as kppageup/kppagedown and scroll nothing — the same "no way to scroll" outcome the report describes. It is also the class in #55533, where end is bound but NumPad End (kpend) does nothing.

The minimal change is one key per default:

"permission.prompt.scroll.up": keybind("pageup,kppageup", "Scroll permission diff up"),
"permission.prompt.scroll.down": keybind("pagedown,kppagedown", "Scroll permission diff down"),

That is the only place the key list lives — the commands are bound through the layer's bindings: array, so no other file changes. For context only: diff.page.up/diff.page.down have the same gap today, so if you prefer, treating both is consistent; the pre-existing one is not part of this change.

@yogo1212
yogo1212 force-pushed the permission-diff-scroll branch from 4aab5d5 to 4b1b2cc Compare October 25, 2026 18:25
@yogo1212

yogo1212 commented Oct 25, 2026 •

Copy link
Copy Markdown
Author

in the spirit of anticipatory obedience, i think adding the keybinds right now is the way to go - as this change might be missed while working on that other change. should be less work overall.

so no other file changes

i took the liberty to also adjust services/www/src/docs/content/cli/keybinds.mdx 😉

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push adds the keypad keys kppageup and kppagedown to the defaults. I checked them with a temporary copy of your render test that sends the keypad key codes: they scroll the diff in fullscreen, and do nothing while the prompt is collapsed. On the new head, the render test and tsc -b for packages/tui pass. Both earlier points stay addressed. Public API: adds the TUI keybinds permission.prompt.scroll.up (default pageup,kppageup) and permission.prompt.scroll.down (default pagedown,kppagedown), which is backwards compatible. Nothing new to raise.

@yogo1212

Copy link
Copy Markdown
Author

rebased

@yogo1212
yogo1212 force-pushed the permission-diff-scroll branch from 4b1b2cc to 60706d8 Compare October 30, 2026 12:54
@yogo1212
yogo1212 force-pushed the permission-diff-scroll branch from 60706d8 to 0560194 Compare November 6, 2026 14:57
@yogo1212

yogo1212 commented Nov 6, 2026

Copy link
Copy Markdown
Author

rebased

This branch has not been deployed

No deployments
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.

[FEATURE]: Permission prompt: diff preview not scrollable in compact view, keys not configurable

2 participants