fix(tui): make user_prompt elicitation dialog scrollable#2509
Merged
dgageot merged 1 commit intodocker:mainfrom Apr 27, 2026
Merged
Conversation
Fixes docker#2495. When `user_prompt` opens an elicitation pop-up with many enum items (or many fields, or a long message) the dialog overflowed the bottom of the terminal with no way to access the clipped content — neither visually nor for keyboard navigation. The body region (message + fields, or message + free-form input) is now rendered inside a scrollview, capped at 80% of the terminal height (max 40 rows). Title/separator stay fixed at the top, the help line stays fixed at the bottom. - The scrollview consumes mouse wheel, scrollbar drag, and PgUp/PgDn/Home/End. Up/Down keep their existing role of cycling enum/boolean selections. - Auto-scroll keeps the focused field's active line visible: Tab / Shift-Tab brings the new field into view, and Up/Down inside an enum/boolean keeps the selected option in view even when the field itself is taller than the viewport. Submit-with-error focuses and scrolls to the offending field. - Mouse clicks translate the absolute Y through the current scroll offset before mapping to a field/option, so clicks on visible options still work when the dialog is scrolled. - The help line gains a "pgup/pgdn scroll" hint when scrolling is active. - A single layout() method computes geometry (dialog width, viewport, body lines, per-field line offsets) shared by View() and Position(), so layout math lives in exactly one place. - buildBody tracks line offsets incrementally to stay O(N) in the number of fields. Tests cover long enums (30 options on a 20-row terminal), many fields below the fold (15 fields on an 18-row terminal), and small content that should not show a scrollbar. Assisted-By: docker-agent
trungutt
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2495.
When `user_prompt` opens an elicitation pop-up with many enum items (or many fields, or a long message), the dialog overflowed the bottom of the terminal with no way to access the clipped content — neither visually nor for keyboard navigation.
What changed
The body region (message + fields, or message + free-form input) is now rendered inside a scrollview, capped at 80% of the terminal height (max 40 rows). Title/separator stay fixed at the top, the help line stays fixed at the bottom.
Tests
New unit tests in `pkg/tui/dialog/elicitation_test.go`:
All existing tests still pass; `golangci-lint run ./...` is clean.
How to test manually
```yaml
/tmp/triage.yaml
version: "2"
agents:
root:
model: openai/gpt-5
description: Triage tester
instruction: |
As soon as the user says anything, call user_prompt EXACTLY ONCE with a
'category' enum field whose 12 options are long incident-triage labels.
toolsets:
- type: user_prompt
```
```sh
./bin/cagent run /tmp/triage.yaml
type any message → dialog appears with a scrollbar; Up/Down/PgUp/PgDn navigate;
all 12 items are reachable; mouse wheel & scrollbar drag work.
```