Repository navigation
Description
Summary
With the /btw answer dialog open, PageUp and PageDown close the dialog instead of scrolling the answer. The same happens with ctrl+alt+f, the other default binding for session.page.down. j/k, the arrow keys, Home and End scroll the dialog correctly.
The dialog already implements page scrolling (the Answer component's useKeyboard handler in packages/tui/src/feature-plugins/prompt/btw.tsx), but the session-level session.page.up / session.page.down bindings still fire while the modal dialog is open, and that handler dismisses the dialog. Because a /btw answer cannot be reopened after its dialog closes (#50879), pressing PageUp/PageDown loses the answer.
Environment
- opencode version: 2.1.4 (
/usr/bin/opencode; the updater offers 2.2.0, whosebtw.tsxstill has the same dialog handler) - OS: Linux 6.18.58-1-lts x86_64 (Arch)
- Terminal:
TERM=xterm-256color,COLORTERM=truecolor,TERM_PROGRAMunset - Shell: /usr/bin/bash
- Install/channel: release binary
- Active plugins: none (no plugin entries in
~/.config/opencode/opencode.jsonor~/.config/opencode/cli.json)
Reproduction
- Open a session in the TUI.
- Run
/btw Output the integers from 1 to 30, each on its own line, with no headings and no other prose.and wait for the answer dialog. - Press PageUp or PageDown.
ctrl+alt+f (the other default binding for session.page.down) reproduces it too.
Expected Behavior
PageUp and PageDown scroll the answer by one page and the dialog stays open. End and Home keep jumping to the end and start of the answer. After the dialog closes, PageUp/PageDown scroll the session as before.
Actual Behavior
PageUp and PageDown dismiss the dialog, as if Escape were pressed. The answer is gone. j/k and the arrow keys scroll the answer, and Home/End jump to the start/end, all without closing it.
Additional Context
- The dialog footer only advertises
j/k ↑/↓, so the page keys are not discoverable even where they work. - The conflict is between the dialog's raw
useKeyboardhandler and the global session bindings.session.page.up/session.page.downdefault topageup/pagedown(plusctrl+alt+b/ctrl+alt+f), and those bindings dispatch while the modal dialog is open. - Verified by driving the real TUI in a 120x34 pty on 2.1.4:
- PageDown -> dialog closed.
ctrl+alt+f-> dialog closed.j/k-> answer scrolled, dialog stayed open.- End / Home -> answer jumped to bottom / top, dialog stayed open.
- With
session.page.upandsession.page.downset tononeincli.json, PageUp/PageDown scrolled the dialog and it stayed open.
- Workaround: set
session.page.upandsession.page.downtonone(or move them off PageUp/PageDown) incli.json. That restores page scrolling in/btw, but gives up PageUp/PageDown in the session, so it is not a satisfactory fix for users who page the transcript with those keys. - Related: [FEATURE]: a /btw answer is unrecoverable once its dialog closes #50879.
Activity
opencode-agent commentedon Oct 27, 2026
Thanks for the detailed report. I reproduced this on 2.1.4 and it still happens on the latest
dev(8697644).What I did: open a session, run
/btwwith a question whose answer is longer than the dialog, then press a key.j: the answer scrolls and the dialog stays open.ctrl+alt+f: the dialog closes right away and the answer is gone.The recording and screenshots below show this, and the script below reproduces it.
From the code, the cause appears to be that the session-wide
session.page.up/session.page.downbindings still run while the/btwdialog is open, and their handler closes any open dialog, so the dialog's own page-scroll handling never takes effect. Your workaround (setting those bindings tononeincli.json) fits that. Related: #50879 (a/btwanswer can't be recovered once its dialog closes), which is why this loses the answer.recording.mp4
Reproduction script (drive.ts)
Run it with opencode-drive:
opencode-drive run ./drive.ts. It drivesopencodefrom yourPATH; setOC_DEVto the path of an OpenCode checkout to run that from source instead.Aafimalek commentedon Oct 27, 2026
I reproduced the Page Down dismissal on Windows against dev using the TUI test renderer. I'd like to work on a focused fix and regression test. Could a maintainer assign this to me?