Skip to content

fix(tui): keep session context visible above the question prompt - #48949

Open
omryMen wants to merge 3 commits into
anomalyco:devfrom
omryMen:question-panel-height
Open

omryMen wants to merge 3 commits into
anomalyco:devfrom
omryMen:question-panel-height

Conversation

@omryMen

@omryMen omryMen commented Sep 14, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #37173

Type of change

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

What does this PR do?

The question prompt grows to fit its content. Ask a long question and it covers the transcript, hiding the work the agent just did, which is the context you need to answer. #37173 describes where that leaves you: hit escape to read anything, which cancels the questions, then ask the agent to repeat itself. The body doesn't scroll either, so anything past the viewport is just gone.

So the panel is capped now, and the question body sits in a scrollbox. Options and controls live outside it with flexShrink={0} and stay put.

Capping it alone gives you the opposite problem. A one-line question reserves the whole budget and leaves a gap above the options, 14 rows for 1 row of text on a 40-row terminal. So maxHeight on the scrollbox is whichever is smaller, the budget or the rows the question actually renders.

Two things make that row count wrong if you skip them. The sidebar opens on its own past 120 columns and eats 42, so the question is rendering into a narrower column than dimensions().width implies (same math as contentWidth in session/index.tsx). And a long paragraph wraps over many rows, so the count divides by that width and rounds up, since wrapping breaks on whitespace and not at the exact boundary. Round down and you clip the body. Round up and the scrollbox has a little slack, which nobody notices.

The history reserve is a percentage, not a fixed row count. Fixed starved the body on short terminals.

Worth flagging: #37173 asks for a show/hide toggle. This goes the other way and keeps enough context on screen that there's nothing to toggle. Say the word if you'd rather have the explicit control.

How did you verify your code works?

Rendered QuestionPrompt with testRender at fixed sizes and read viewport.height and scrollHeight off the scrollbox. Marker line above the prompt to confirm history survives:

Terminal Question Viewport Content Scrolls
100×40 short 1 1 no
180×40 short, sidebar open 1 1 no
100×40 long 14 80 yes
180×40 long, sidebar open 14 40 yes
100×20 long 5 80 yes
180×40 multi-select 1 1 no

History, options and controls stayed on screen in all six. Before the change the two short cases reported a viewport of 14 for 1 row of content.

Then a real session: failing command, then a ~1200 word question. Error stays visible, body scrolls, options don't move. Short question sits right on top of its options with no gap.

bun typecheck passes in packages/tui.

One thing if this code ever moves. The new memos read multi() and are declared after it. Solid evaluates memos eagerly at setup, so pointing at a later const throws a temporal dead zone error at runtime and tsc says nothing. Found that the hard way.

Screenshots / recordings

Short question, after. Text sits directly on its options:

┃  Should I continue with the current implementation?
┃
┃  1. Continue
┃     Proceed with the current implementation
┃  2. Stop
┃     Halt the current implementation
┃  ↑↓ select  enter submit  esc dismiss

Long question, after. Failing command still visible above, scrollbar mark on the right, options pinned:

┃  $ ls /definitely-does-not-exist-layout-check
┃  ls: /definitely-does-not-exist-layout-check: No such file or directory

   → Asked 1 question

┃  Context for the decision: we are at the final go/no-go gate for the     ▀
┃  Helios production rollout, the coordinated release that moves the
┃  payments-adjacent surface of our platform from the legacy monolithic
┃  session stack onto the new distributed identity and storage
┃  ... (scrolls)
┃
┃  1. Approve rollout
┃  2. Pause and investigate
┃  3. Roll back
┃  ↑↓ select  enter submit  esc dismiss

Before the fix the short case had 13 blank rows sitting between the question text and option 1.

Checklist

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

The question prompt grew to whatever height its content needed, so a long
question covered the transcript and hid the work the agent had just done.
The only escape was to dismiss the prompt and ask the agent to repeat itself.
The body also had no scroll region, so text past the viewport was unreachable.

Bound the panel to a proportional share of the terminal and move the question
body into a scrollbox. Options and controls stay fixed below it.

Size the body to the rows it actually renders rather than to the full budget,
otherwise a one-line question still reserves the maximum and leaves a wide gap
above the options. Counting has to account for the sidebar, which auto-opens
past 120 columns and takes 42 of them, and for wrapping, since one long
paragraph occupies many rows. The estimate rounds up: undercounting clips the
body, overcounting only leaves the scrollbox some slack.

Fixes anomalyco#37173
@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 Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

No way to hide questions or read text

1 participant