Skip to content

feat: add ask_user_question for mid-turn clarification - #408

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/ask-user-question
Aug 19, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/ask-user-question

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Why

The agent currently has to guess when a task is underspecified, or dump free-form questions into the transcript. Other CLIs (Claude Code, Codex, OpenCode, DeepSeek Harness) pause the turn with a structured questionnaire. Forge already had WaitReason::Clarification / Selection stubs and composer routing for them, but no producer.

This PR

Adds a model-callable ask_user_question tool that pauses the turn on WaitReason::Question until the user answers.

  • 1–4 questions, 0 or 2–4 options, optional multi-select
  • Host always adds Other; answers come back as compact JSON (id / selected / custom)
  • Inline transcript prompt, same visual language as approval (not a boxed card)
  • Composer text while waiting is a custom/Other answer, not a new task
  • YOLO / auto-approve do not answer these
  • Subagents cannot ask; they get a tool error
  • Resume restores the wait from a tagged journal envelope

Test plan

  • cargo test --package forge-types --lib ask_user_question
  • cargo test --package forge-tools --lib ask_user_question
  • cargo test --package forge-tools --test all_tools
  • cargo test --package forge-core --lib ask_user_question
  • cargo test --package forge-tui --lib app::tests::questions
  • cargo clippy on the touched crates (-D warnings)
  • In a real session, ask the agent to pick between two approaches and confirm the inline prompt, Other via composer, and Esc skip

Let the model pause a turn and collect structured answers instead of
guessing. Subagents cannot ask; YOLO/auto-approve do not answer.
@github-actions
github-actions Bot enabled auto-merge (squash) August 19, 2026 19:24
@github-actions
github-actions Bot merged commit 407aeff into main Aug 19, 2026
8 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
Let the model pause a turn and collect structured answers instead of
guessing. Subagents cannot ask; YOLO/auto-approve do not answer.
mohitranka added a commit that referenced this pull request Aug 22, 2026
Four problems, one of them a bug. `wrap` trims leading whitespace, so folding
the selection marker into the wrapped string meant every unselected row lost
its two columns of indent and sat left of the one under the cursor — the list
did not line up as a list. The marker is now its own span.

The options are numbered. `handle_question_menu_key` has accepted 1-9 since
the feature landed and nothing on screen ever said so, which is the same
defect as `esc to interrupt`: a working key nobody could discover.

Every option shows its description, not only the selected one. Comparing three
options is the whole activity, and a description that appears only under the
cursor makes the reader arrow up and down to do it. Descriptions are capped at
two lines: with one per option the card grows by the option count, and five
long ones push the question itself off a short pane.

The card is framed like the approval card. This reverses an assertion from
#408 ("question must not render as a boxed card") which arrived with no stated
reason; the two prompts are the same thing to the operator — the agent has
stopped and cannot continue without them — and looked like unrelated
components. Raised with the author before changing it.

The height estimate is now measured by rendering, as the approval card's
already is. The old constant said 8 rows for a card that is 14, and an
under-budget scrolls its own title off.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM
mohitranka added a commit that referenced this pull request Aug 22, 2026
* fix(tui): tell heading levels apart and lift the language chip out of the code rail

Every markdown heading pushed the same bold style and ignored its level, so
H1, H2 and H3 rendered pixel-identically and a structured answer read flat.
Rank now reads by weight and value — H1/H2 stay primary text, H3 and below
step down to secondary, and H1 gets a rule under it — never by hue, which
`theme::heading` reserves for brand.

The fenced-code language chip went through `code_row`, which put it inside
the gutter with the code tint, so it rendered as `▌ rust` — a line of code
that says "rust". It now caps the block from outside the rail, right-aligned.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): fade the unsettled tail of a streaming answer

`settled_prefix_len` already computes which suffix of the stream buffer later
bytes can still re-render — an open fence, a list a further item can re-space,
a half-written paragraph. Nothing on screen said so: text that was about to be
re-laid-out looked exactly as final as text that was done.

The unsettled tail now paints one step down in value and brightens as it
settles, so the answer visibly sets while it streams. Fading is paint only —
the characters are unchanged, pinned by a test against a one-shot render — and
the caret keeps full brightness, because it marks the one part that is alive.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): replace the footer shimmer with a travelling wave meter

While a turn ran, the only moving pixel in the application was one character
of the word "Working" changing colour in the bottom-right corner. That is
motion in the strictest sense and nothing more: at a glance the footer looked
as static as the frozen transcript above it.

A five-cell wave now takes the lifecycle dot's place while working. It yields
to the model id rather than truncating it — an animation is worth fewer
columns than a readable `deepseek-…flash-free` — and drops out entirely on
narrow rows, ahead of the token unit label.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): a live turn line, an advertised interrupt, and a visible end to a turn

A capture of a real turn had eleven consecutive identical frames — eight
seconds in which a stalled renderer and a hung provider looked exactly alike.
The only indicator lived in the footer, ninety columns from the text being
read, and said "Working" for every phase of every turn.

While a turn runs the transcript now carries one animated line where the
answer is about to appear: a spinner, the phase verb taken from the BusyPhase
that was already tracked and then flattened, elapsed counting from zero, and
how much has arrived. Esc has been bound since forever and nothing ever said
so; the hint now rides that line, and its appearing and disappearing is itself
a liveness cue. When the turn ends the line resolves in place into a
terminator: how long it took, how much came back, how many tools ran.

Volume is reported in characters, not tokens. No provider reports token usage
while the stream is open, and an estimate dressed up as a measurement is worse
than an exact count of something else; the footer still shows real API-reported
tokens once the turn ends.

Two things the wiring turned up: `timing.started` is reset at every
continuation, so a turn that ran three tools reported the age of its last step
as its duration — `turn_started` now survives step boundaries — and the
conversation render cache keyed banners by count alone, so one turn summary
replacing another never repainted.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): collapse spent reasoning to one line

Reasoning was permanent. A turn that ran three tools left three dim
paragraphs strewn between its tool rows, none of which the reader still needed
— the newest one is the only one describing what is happening now.

Every reasoning block but the newest now folds to a single line saying it
happened and how long it took. Ctrl+O, already the transcript's "show me
everything" affordance, brings them all back in full.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* fix(tui): one unit of vertical rhythm between transcript blocks

Every block opened with a leading blank and closed with a pair, so gaps
doubled and tripled down the transcript: it read as a list of far-apart items
rather than a conversation, and a screen held noticeably less of it.

Blocks now close with a single blank, and reasoning closes with none at all —
the tool call it produced hugs the line that explains it, which is the one
adjacency in the transcript that actually means something.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): hold a short conversation against the composer

A transcript shorter than its pane painted from the top, which left the newest
line — the one being written — stranded in the middle of the screen with a
screenful of nothing under it. Every other coding CLI keeps the live edge next
to the input, because that is where the reader is already looking.

The pane now sinks its content to the bottom once a conversation has started.
The home splash still opens at the top: it is a landing page, not a turn.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): drain stream deltas at a bounded rate

A provider can hand over a whole paragraph in one event, and the transcript
painted it whole: a capture went from nothing to four bullets between two
adjacent frames, which reads as a teleport rather than a stream.

The preview now has a revealed offset that advances in wall time — on the
event tick and on each delta paint, never in `draw`, which must not mutate
state. Ordinary streaming is well under the cap and untouched; only bursts are
spread out, and a catch-up floor keeps the text from ever falling more than
1.2s behind the provider however large the burst.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): retry a transient model failure, and count the backoff down on screen

forge classified provider errors as retryable and then never retried one:
`ModelError::is_retryable` had no callers in the turn loop, so a network blip
or a 503 ended the whole turn. Silence during a stall is also indistinguishable
from a hang, which is why the wait belongs on screen rather than in the
activity log.

A step is now re-issued up to twice, backing off 1s then 2s, and only when
nothing has streamed yet — re-issuing after partial output would duplicate
text the reader has already seen. The live turn line counts the wait down
("Retrying in 2s · attempt 3 of 3") and Esc still interrupts it.

A retry spends one slot of the max-turns budget, since it re-enters the step
loop. Worth knowing; not worth a second budget to track it.

MockModelClient now carries a typed error instead of forcing every scripted
failure to Transport, so a test can pin behaviour that depends on whether the
failure is retryable. Two edge tests asserting a terminal failure were using
errors that are now legitimately retried; they name a 400, so they now send
one.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): show what the sandbox actually said, not the category it belongs to

The approval card explained the sandbox in general and this command not at
all. Five lines of policy, identical for every command in that category,
taller than the command they were about — and the first line was clipped
mid-word ("confined to the wo") because the row clipped instead of wrapping.

forge already had the evidence. A sandbox denial carries the command's own
output in `ToolError::SandboxDenied::content`, and `finish_tool_application`
discarded it: the pattern bound `reason` and matched the rest with `..`. It is
now split from the appended category text and carried to the card on
`HitlPayload::failure`, where it leads:

    The sandbox refused it: bash: /tmp/x: Operation not permitted
    Asked because blocked by the sandbox: writes are confined to the…

The category explanation stays — a prompt with no stated reason reads as
arbitrary — but drops to one elided line once the sandbox's own words are
above it, and keeps three when they are not. The policy-gated prompt has no
refusal to quote, since nothing ran; it keeps the longer form.

The clipping was a width bug: the lead shares the row with the text it
introduces, and the wrap width did not allow for it, so the first line ran
past the border and lost its tail. Both leads now come out of the width. The
test reassembles the reason from the rendered rows and fails on the old
behaviour, losing "directory".

Also drops the runner's `[process exited with code 1]` footer from the quoted
evidence: not something the sandbox said, and it displaced a line of the real
error inside the three-line cap.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): name what each approval option grants, and let a refusal say why

Three of the four options were vague about the thing they decide. "Remember
similar commands this session" asked the operator to approve a rule they could
not read — the pattern was in an elided detail column, rendered as
"Would match: rm -f …". The strongest grant available was the session, and a
refusal could only be silent.

The label now carries the grant: "Allow bash(git push *) this session". Beside
it is the same pattern for good — `A` writes it to the personal permissions
file, mirroring what the network prompt already did for hosts. The session
grant is applied alongside it, since a rule written to the file is not reloaded
mid-session and the next matching call would otherwise prompt again.

"Don't run, and say why" refuses and takes a line for the agent.
`resolve_hitl_with_feedback` has been in core all along with no caller; it now
has one. The note is collected from the composer, which normally rejects input
while an approval is pending (`classify_input`) — the exception is scoped to a
note the operator was explicitly asked for, is taken before the line is
classified, and clears itself if the approval resolves any other way.

Shortcuts follow one rule: the shifted letter is the wider form of the same
decision. `a` grants for the session and `A` for good, `n` refuses and `N`
refuses with a note. Nothing destructive hides behind a shift.

The bool that carried "remember this" became `ApprovalGrant::{Once, Session,
Always}`; two states could not express three.

Known gap: the card is two rows taller, and in a narrow sidebar that scrolls
its own title off. The compact path already drops the reason and the inline
consequences at that width and should drop these two rows too, but the menu is
built where the render width is not known, and caching a width from `draw` is
the side-effect-in-draw pattern this codebase has ruled out. Left for a
follow-up rather than bodged; one test now renders at 160x40 for that reason.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): make the question prompt read as a list of choices

Four problems, one of them a bug. `wrap` trims leading whitespace, so folding
the selection marker into the wrapped string meant every unselected row lost
its two columns of indent and sat left of the one under the cursor — the list
did not line up as a list. The marker is now its own span.

The options are numbered. `handle_question_menu_key` has accepted 1-9 since
the feature landed and nothing on screen ever said so, which is the same
defect as `esc to interrupt`: a working key nobody could discover.

Every option shows its description, not only the selected one. Comparing three
options is the whole activity, and a description that appears only under the
cursor makes the reader arrow up and down to do it. Descriptions are capped at
two lines: with one per option the card grows by the option count, and five
long ones push the question itself off a short pane.

The card is framed like the approval card. This reverses an assertion from
#408 ("question must not render as a boxed card") which arrived with no stated
reason; the two prompts are the same thing to the operator — the agent has
stopped and cannot continue without them — and looked like unrelated
components. Raised with the author before changing it.

The height estimate is now measured by rendering, as the approval card's
already is. The old constant said 8 rows for a card that is 14, and an
under-budget scrolls its own title off.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): keep one plan card, and record each revision as a line

Every `update_plan` call printed the whole checklist again, so a turn that
revised its plan three times left three near-identical lists stacked down the
transcript, at jittering widths. Codex does the same thing; it reads as a
flipbook of one list.

A plan is state, and state belongs in one place. The newest call keeps the
card, and the card it replaces becomes the one line that says what changed —
"Plan updated · 1 of 3 done · Implement the planned changes" — left at the
position that update happened, which is where history wants it. Three calls
now leave one card and two lines instead of three lists.

The record keeps how far the superseded plan had got, so scrolling back
through a long turn still shows the shape of its progress without repeating
the steps at each point.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): show what ran under each plan step

A checklist states intent. A step marked [✓] is the model's word for it, and
the transcript had no way to check the claim without scrolling back through
the activity log to see what happened between one plan update and the next.

Each step now carries the tool calls made while it was the step in progress:

    [✓] Read README and list crates
        read_file README.md, ls crates
    [►] Mark inspection step complete

Attribution is by observation, not by the model's say-so — the transcript
builder tags every tool result with whichever step was `InProgress` when it
arrived. Evidence is keyed by step text so it survives a revision that
completes or reorders steps, and is dropped with any step the model removed.

Subjects are shortened to a filename or the first two words of a command, and
capped at three per step with the rest counted. A step that ran nine commands
should read as a list of subjects, not as a second activity log inside the
card.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): dock the plan when its card scrolls out of view

Measured on a turn that recorded a plan and then wrote thirty lines of answer,
sampling the pane every 0.5s: the plan card was on screen for 8 frames out of
70 — about four seconds — and gone for the rest of the turn and after it.
Nothing on screen then said a plan existed, which step was running, or how far
in it was. Recovering it means scrolling up, which drops you out of follow
mode: during a turn you could watch the work or the plan, never both.

The card still lives inline where it was announced. Once it is above the
window, its one-row stand-in takes the top of the pane:

    ↑ Plan  ▓▓░░  2/4  ·  Wire the toggle into the settings pane

The arrow says where the real thing is; scroll back to it and the row gives
way to the card. Nothing is spent while the card is visible, which is what
made this preferable to a strip that holds a row of height forever.

Two things worth knowing about the implementation:

The card is found by rendering it standalone and matching its first and last
rows against what was produced, rather than threading a line index out of the
block loop — that loop feeds three cached entry points and a tail window, and
an index would have to be kept correct through all of them.

Follow mode renders only a tail window, so a plan far enough back is not in
the rendered lines at all — which is exactly when it most needs docking. The
first cut treated "not found" as "no plan" and the dock never appeared in a
live run; a plan whose block was trimmed by the window is now docked on that
basis alone.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM
mohitranka added a commit that referenced this pull request Sep 11, 2026
Let the model pause a turn and collect structured answers instead of
guessing. Subagents cannot ask; YOLO/auto-approve do not answer.
mohitranka added a commit that referenced this pull request Sep 11, 2026
* fix(tui): tell heading levels apart and lift the language chip out of the code rail

Every markdown heading pushed the same bold style and ignored its level, so
H1, H2 and H3 rendered pixel-identically and a structured answer read flat.
Rank now reads by weight and value — H1/H2 stay primary text, H3 and below
step down to secondary, and H1 gets a rule under it — never by hue, which
`theme::heading` reserves for brand.

The fenced-code language chip went through `code_row`, which put it inside
the gutter with the code tint, so it rendered as `▌ rust` — a line of code
that says "rust". It now caps the block from outside the rail, right-aligned.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): fade the unsettled tail of a streaming answer

`settled_prefix_len` already computes which suffix of the stream buffer later
bytes can still re-render — an open fence, a list a further item can re-space,
a half-written paragraph. Nothing on screen said so: text that was about to be
re-laid-out looked exactly as final as text that was done.

The unsettled tail now paints one step down in value and brightens as it
settles, so the answer visibly sets while it streams. Fading is paint only —
the characters are unchanged, pinned by a test against a one-shot render — and
the caret keeps full brightness, because it marks the one part that is alive.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): replace the footer shimmer with a travelling wave meter

While a turn ran, the only moving pixel in the application was one character
of the word "Working" changing colour in the bottom-right corner. That is
motion in the strictest sense and nothing more: at a glance the footer looked
as static as the frozen transcript above it.

A five-cell wave now takes the lifecycle dot's place while working. It yields
to the model id rather than truncating it — an animation is worth fewer
columns than a readable `deepseek-…flash-free` — and drops out entirely on
narrow rows, ahead of the token unit label.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): a live turn line, an advertised interrupt, and a visible end to a turn

A capture of a real turn had eleven consecutive identical frames — eight
seconds in which a stalled renderer and a hung provider looked exactly alike.
The only indicator lived in the footer, ninety columns from the text being
read, and said "Working" for every phase of every turn.

While a turn runs the transcript now carries one animated line where the
answer is about to appear: a spinner, the phase verb taken from the BusyPhase
that was already tracked and then flattened, elapsed counting from zero, and
how much has arrived. Esc has been bound since forever and nothing ever said
so; the hint now rides that line, and its appearing and disappearing is itself
a liveness cue. When the turn ends the line resolves in place into a
terminator: how long it took, how much came back, how many tools ran.

Volume is reported in characters, not tokens. No provider reports token usage
while the stream is open, and an estimate dressed up as a measurement is worse
than an exact count of something else; the footer still shows real API-reported
tokens once the turn ends.

Two things the wiring turned up: `timing.started` is reset at every
continuation, so a turn that ran three tools reported the age of its last step
as its duration — `turn_started` now survives step boundaries — and the
conversation render cache keyed banners by count alone, so one turn summary
replacing another never repainted.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): collapse spent reasoning to one line

Reasoning was permanent. A turn that ran three tools left three dim
paragraphs strewn between its tool rows, none of which the reader still needed
— the newest one is the only one describing what is happening now.

Every reasoning block but the newest now folds to a single line saying it
happened and how long it took. Ctrl+O, already the transcript's "show me
everything" affordance, brings them all back in full.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* fix(tui): one unit of vertical rhythm between transcript blocks

Every block opened with a leading blank and closed with a pair, so gaps
doubled and tripled down the transcript: it read as a list of far-apart items
rather than a conversation, and a screen held noticeably less of it.

Blocks now close with a single blank, and reasoning closes with none at all —
the tool call it produced hugs the line that explains it, which is the one
adjacency in the transcript that actually means something.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): hold a short conversation against the composer

A transcript shorter than its pane painted from the top, which left the newest
line — the one being written — stranded in the middle of the screen with a
screenful of nothing under it. Every other coding CLI keeps the live edge next
to the input, because that is where the reader is already looking.

The pane now sinks its content to the bottom once a conversation has started.
The home splash still opens at the top: it is a landing page, not a turn.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): drain stream deltas at a bounded rate

A provider can hand over a whole paragraph in one event, and the transcript
painted it whole: a capture went from nothing to four bullets between two
adjacent frames, which reads as a teleport rather than a stream.

The preview now has a revealed offset that advances in wall time — on the
event tick and on each delta paint, never in `draw`, which must not mutate
state. Ordinary streaming is well under the cap and untouched; only bursts are
spread out, and a catch-up floor keeps the text from ever falling more than
1.2s behind the provider however large the burst.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): retry a transient model failure, and count the backoff down on screen

forge classified provider errors as retryable and then never retried one:
`ModelError::is_retryable` had no callers in the turn loop, so a network blip
or a 503 ended the whole turn. Silence during a stall is also indistinguishable
from a hang, which is why the wait belongs on screen rather than in the
activity log.

A step is now re-issued up to twice, backing off 1s then 2s, and only when
nothing has streamed yet — re-issuing after partial output would duplicate
text the reader has already seen. The live turn line counts the wait down
("Retrying in 2s · attempt 3 of 3") and Esc still interrupts it.

A retry spends one slot of the max-turns budget, since it re-enters the step
loop. Worth knowing; not worth a second budget to track it.

MockModelClient now carries a typed error instead of forcing every scripted
failure to Transport, so a test can pin behaviour that depends on whether the
failure is retryable. Two edge tests asserting a terminal failure were using
errors that are now legitimately retried; they name a 400, so they now send
one.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): show what the sandbox actually said, not the category it belongs to

The approval card explained the sandbox in general and this command not at
all. Five lines of policy, identical for every command in that category,
taller than the command they were about — and the first line was clipped
mid-word ("confined to the wo") because the row clipped instead of wrapping.

forge already had the evidence. A sandbox denial carries the command's own
output in `ToolError::SandboxDenied::content`, and `finish_tool_application`
discarded it: the pattern bound `reason` and matched the rest with `..`. It is
now split from the appended category text and carried to the card on
`HitlPayload::failure`, where it leads:

    The sandbox refused it: bash: /tmp/x: Operation not permitted
    Asked because blocked by the sandbox: writes are confined to the…

The category explanation stays — a prompt with no stated reason reads as
arbitrary — but drops to one elided line once the sandbox's own words are
above it, and keeps three when they are not. The policy-gated prompt has no
refusal to quote, since nothing ran; it keeps the longer form.

The clipping was a width bug: the lead shares the row with the text it
introduces, and the wrap width did not allow for it, so the first line ran
past the border and lost its tail. Both leads now come out of the width. The
test reassembles the reason from the rendered rows and fails on the old
behaviour, losing "directory".

Also drops the runner's `[process exited with code 1]` footer from the quoted
evidence: not something the sandbox said, and it displaced a line of the real
error inside the three-line cap.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): name what each approval option grants, and let a refusal say why

Three of the four options were vague about the thing they decide. "Remember
similar commands this session" asked the operator to approve a rule they could
not read — the pattern was in an elided detail column, rendered as
"Would match: rm -f …". The strongest grant available was the session, and a
refusal could only be silent.

The label now carries the grant: "Allow bash(git push *) this session". Beside
it is the same pattern for good — `A` writes it to the personal permissions
file, mirroring what the network prompt already did for hosts. The session
grant is applied alongside it, since a rule written to the file is not reloaded
mid-session and the next matching call would otherwise prompt again.

"Don't run, and say why" refuses and takes a line for the agent.
`resolve_hitl_with_feedback` has been in core all along with no caller; it now
has one. The note is collected from the composer, which normally rejects input
while an approval is pending (`classify_input`) — the exception is scoped to a
note the operator was explicitly asked for, is taken before the line is
classified, and clears itself if the approval resolves any other way.

Shortcuts follow one rule: the shifted letter is the wider form of the same
decision. `a` grants for the session and `A` for good, `n` refuses and `N`
refuses with a note. Nothing destructive hides behind a shift.

The bool that carried "remember this" became `ApprovalGrant::{Once, Session,
Always}`; two states could not express three.

Known gap: the card is two rows taller, and in a narrow sidebar that scrolls
its own title off. The compact path already drops the reason and the inline
consequences at that width and should drop these two rows too, but the menu is
built where the render width is not known, and caching a width from `draw` is
the side-effect-in-draw pattern this codebase has ruled out. Left for a
follow-up rather than bodged; one test now renders at 160x40 for that reason.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): make the question prompt read as a list of choices

Four problems, one of them a bug. `wrap` trims leading whitespace, so folding
the selection marker into the wrapped string meant every unselected row lost
its two columns of indent and sat left of the one under the cursor — the list
did not line up as a list. The marker is now its own span.

The options are numbered. `handle_question_menu_key` has accepted 1-9 since
the feature landed and nothing on screen ever said so, which is the same
defect as `esc to interrupt`: a working key nobody could discover.

Every option shows its description, not only the selected one. Comparing three
options is the whole activity, and a description that appears only under the
cursor makes the reader arrow up and down to do it. Descriptions are capped at
two lines: with one per option the card grows by the option count, and five
long ones push the question itself off a short pane.

The card is framed like the approval card. This reverses an assertion from
#408 ("question must not render as a boxed card") which arrived with no stated
reason; the two prompts are the same thing to the operator — the agent has
stopped and cannot continue without them — and looked like unrelated
components. Raised with the author before changing it.

The height estimate is now measured by rendering, as the approval card's
already is. The old constant said 8 rows for a card that is 14, and an
under-budget scrolls its own title off.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): keep one plan card, and record each revision as a line

Every `update_plan` call printed the whole checklist again, so a turn that
revised its plan three times left three near-identical lists stacked down the
transcript, at jittering widths. Codex does the same thing; it reads as a
flipbook of one list.

A plan is state, and state belongs in one place. The newest call keeps the
card, and the card it replaces becomes the one line that says what changed —
"Plan updated · 1 of 3 done · Implement the planned changes" — left at the
position that update happened, which is where history wants it. Three calls
now leave one card and two lines instead of three lists.

The record keeps how far the superseded plan had got, so scrolling back
through a long turn still shows the shape of its progress without repeating
the steps at each point.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): show what ran under each plan step

A checklist states intent. A step marked [✓] is the model's word for it, and
the transcript had no way to check the claim without scrolling back through
the activity log to see what happened between one plan update and the next.

Each step now carries the tool calls made while it was the step in progress:

    [✓] Read README and list crates
        read_file README.md, ls crates
    [►] Mark inspection step complete

Attribution is by observation, not by the model's say-so — the transcript
builder tags every tool result with whichever step was `InProgress` when it
arrived. Evidence is keyed by step text so it survives a revision that
completes or reorders steps, and is dropped with any step the model removed.

Subjects are shortened to a filename or the first two words of a command, and
capped at three per step with the rest counted. A step that ran nine commands
should read as a list of subjects, not as a second activity log inside the
card.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): dock the plan when its card scrolls out of view

Measured on a turn that recorded a plan and then wrote thirty lines of answer,
sampling the pane every 0.5s: the plan card was on screen for 8 frames out of
70 — about four seconds — and gone for the rest of the turn and after it.
Nothing on screen then said a plan existed, which step was running, or how far
in it was. Recovering it means scrolling up, which drops you out of follow
mode: during a turn you could watch the work or the plan, never both.

The card still lives inline where it was announced. Once it is above the
window, its one-row stand-in takes the top of the pane:

    ↑ Plan  ▓▓░░  2/4  ·  Wire the toggle into the settings pane

The arrow says where the real thing is; scroll back to it and the row gives
way to the card. Nothing is spent while the card is visible, which is what
made this preferable to a strip that holds a row of height forever.

Two things worth knowing about the implementation:

The card is found by rendering it standalone and matching its first and last
rows against what was produced, rather than threading a line index out of the
block loop — that loop feeds three cached entry points and a tail window, and
an index would have to be kept correct through all of them.

Follow mode renders only a tail window, so a plan far enough back is not in
the rendered lines at all — which is exactly when it most needs docking. The
first cut treated "not found" as "no plan" and the dock never appeared in a
live run; a plan whose block was trimmed by the window is now docked on that
basis alone.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM
mohitranka added a commit that referenced this pull request Sep 11, 2026
Let the model pause a turn and collect structured answers instead of
guessing. Subagents cannot ask; YOLO/auto-approve do not answer.
mohitranka added a commit that referenced this pull request Sep 11, 2026
* fix(tui): tell heading levels apart and lift the language chip out of the code rail

Every markdown heading pushed the same bold style and ignored its level, so
H1, H2 and H3 rendered pixel-identically and a structured answer read flat.
Rank now reads by weight and value — H1/H2 stay primary text, H3 and below
step down to secondary, and H1 gets a rule under it — never by hue, which
`theme::heading` reserves for brand.

The fenced-code language chip went through `code_row`, which put it inside
the gutter with the code tint, so it rendered as `▌ rust` — a line of code
that says "rust". It now caps the block from outside the rail, right-aligned.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): fade the unsettled tail of a streaming answer

`settled_prefix_len` already computes which suffix of the stream buffer later
bytes can still re-render — an open fence, a list a further item can re-space,
a half-written paragraph. Nothing on screen said so: text that was about to be
re-laid-out looked exactly as final as text that was done.

The unsettled tail now paints one step down in value and brightens as it
settles, so the answer visibly sets while it streams. Fading is paint only —
the characters are unchanged, pinned by a test against a one-shot render — and
the caret keeps full brightness, because it marks the one part that is alive.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): replace the footer shimmer with a travelling wave meter

While a turn ran, the only moving pixel in the application was one character
of the word "Working" changing colour in the bottom-right corner. That is
motion in the strictest sense and nothing more: at a glance the footer looked
as static as the frozen transcript above it.

A five-cell wave now takes the lifecycle dot's place while working. It yields
to the model id rather than truncating it — an animation is worth fewer
columns than a readable `deepseek-…flash-free` — and drops out entirely on
narrow rows, ahead of the token unit label.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): a live turn line, an advertised interrupt, and a visible end to a turn

A capture of a real turn had eleven consecutive identical frames — eight
seconds in which a stalled renderer and a hung provider looked exactly alike.
The only indicator lived in the footer, ninety columns from the text being
read, and said "Working" for every phase of every turn.

While a turn runs the transcript now carries one animated line where the
answer is about to appear: a spinner, the phase verb taken from the BusyPhase
that was already tracked and then flattened, elapsed counting from zero, and
how much has arrived. Esc has been bound since forever and nothing ever said
so; the hint now rides that line, and its appearing and disappearing is itself
a liveness cue. When the turn ends the line resolves in place into a
terminator: how long it took, how much came back, how many tools ran.

Volume is reported in characters, not tokens. No provider reports token usage
while the stream is open, and an estimate dressed up as a measurement is worse
than an exact count of something else; the footer still shows real API-reported
tokens once the turn ends.

Two things the wiring turned up: `timing.started` is reset at every
continuation, so a turn that ran three tools reported the age of its last step
as its duration — `turn_started` now survives step boundaries — and the
conversation render cache keyed banners by count alone, so one turn summary
replacing another never repainted.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): collapse spent reasoning to one line

Reasoning was permanent. A turn that ran three tools left three dim
paragraphs strewn between its tool rows, none of which the reader still needed
— the newest one is the only one describing what is happening now.

Every reasoning block but the newest now folds to a single line saying it
happened and how long it took. Ctrl+O, already the transcript's "show me
everything" affordance, brings them all back in full.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* fix(tui): one unit of vertical rhythm between transcript blocks

Every block opened with a leading blank and closed with a pair, so gaps
doubled and tripled down the transcript: it read as a list of far-apart items
rather than a conversation, and a screen held noticeably less of it.

Blocks now close with a single blank, and reasoning closes with none at all —
the tool call it produced hugs the line that explains it, which is the one
adjacency in the transcript that actually means something.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): hold a short conversation against the composer

A transcript shorter than its pane painted from the top, which left the newest
line — the one being written — stranded in the middle of the screen with a
screenful of nothing under it. Every other coding CLI keeps the live edge next
to the input, because that is where the reader is already looking.

The pane now sinks its content to the bottom once a conversation has started.
The home splash still opens at the top: it is a landing page, not a turn.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): drain stream deltas at a bounded rate

A provider can hand over a whole paragraph in one event, and the transcript
painted it whole: a capture went from nothing to four bullets between two
adjacent frames, which reads as a teleport rather than a stream.

The preview now has a revealed offset that advances in wall time — on the
event tick and on each delta paint, never in `draw`, which must not mutate
state. Ordinary streaming is well under the cap and untouched; only bursts are
spread out, and a catch-up floor keeps the text from ever falling more than
1.2s behind the provider however large the burst.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): retry a transient model failure, and count the backoff down on screen

forge classified provider errors as retryable and then never retried one:
`ModelError::is_retryable` had no callers in the turn loop, so a network blip
or a 503 ended the whole turn. Silence during a stall is also indistinguishable
from a hang, which is why the wait belongs on screen rather than in the
activity log.

A step is now re-issued up to twice, backing off 1s then 2s, and only when
nothing has streamed yet — re-issuing after partial output would duplicate
text the reader has already seen. The live turn line counts the wait down
("Retrying in 2s · attempt 3 of 3") and Esc still interrupts it.

A retry spends one slot of the max-turns budget, since it re-enters the step
loop. Worth knowing; not worth a second budget to track it.

MockModelClient now carries a typed error instead of forcing every scripted
failure to Transport, so a test can pin behaviour that depends on whether the
failure is retryable. Two edge tests asserting a terminal failure were using
errors that are now legitimately retried; they name a 400, so they now send
one.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): show what the sandbox actually said, not the category it belongs to

The approval card explained the sandbox in general and this command not at
all. Five lines of policy, identical for every command in that category,
taller than the command they were about — and the first line was clipped
mid-word ("confined to the wo") because the row clipped instead of wrapping.

forge already had the evidence. A sandbox denial carries the command's own
output in `ToolError::SandboxDenied::content`, and `finish_tool_application`
discarded it: the pattern bound `reason` and matched the rest with `..`. It is
now split from the appended category text and carried to the card on
`HitlPayload::failure`, where it leads:

    The sandbox refused it: bash: /tmp/x: Operation not permitted
    Asked because blocked by the sandbox: writes are confined to the…

The category explanation stays — a prompt with no stated reason reads as
arbitrary — but drops to one elided line once the sandbox's own words are
above it, and keeps three when they are not. The policy-gated prompt has no
refusal to quote, since nothing ran; it keeps the longer form.

The clipping was a width bug: the lead shares the row with the text it
introduces, and the wrap width did not allow for it, so the first line ran
past the border and lost its tail. Both leads now come out of the width. The
test reassembles the reason from the rendered rows and fails on the old
behaviour, losing "directory".

Also drops the runner's `[process exited with code 1]` footer from the quoted
evidence: not something the sandbox said, and it displaced a line of the real
error inside the three-line cap.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): name what each approval option grants, and let a refusal say why

Three of the four options were vague about the thing they decide. "Remember
similar commands this session" asked the operator to approve a rule they could
not read — the pattern was in an elided detail column, rendered as
"Would match: rm -f …". The strongest grant available was the session, and a
refusal could only be silent.

The label now carries the grant: "Allow bash(git push *) this session". Beside
it is the same pattern for good — `A` writes it to the personal permissions
file, mirroring what the network prompt already did for hosts. The session
grant is applied alongside it, since a rule written to the file is not reloaded
mid-session and the next matching call would otherwise prompt again.

"Don't run, and say why" refuses and takes a line for the agent.
`resolve_hitl_with_feedback` has been in core all along with no caller; it now
has one. The note is collected from the composer, which normally rejects input
while an approval is pending (`classify_input`) — the exception is scoped to a
note the operator was explicitly asked for, is taken before the line is
classified, and clears itself if the approval resolves any other way.

Shortcuts follow one rule: the shifted letter is the wider form of the same
decision. `a` grants for the session and `A` for good, `n` refuses and `N`
refuses with a note. Nothing destructive hides behind a shift.

The bool that carried "remember this" became `ApprovalGrant::{Once, Session,
Always}`; two states could not express three.

Known gap: the card is two rows taller, and in a narrow sidebar that scrolls
its own title off. The compact path already drops the reason and the inline
consequences at that width and should drop these two rows too, but the menu is
built where the render width is not known, and caching a width from `draw` is
the side-effect-in-draw pattern this codebase has ruled out. Left for a
follow-up rather than bodged; one test now renders at 160x40 for that reason.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): make the question prompt read as a list of choices

Four problems, one of them a bug. `wrap` trims leading whitespace, so folding
the selection marker into the wrapped string meant every unselected row lost
its two columns of indent and sat left of the one under the cursor — the list
did not line up as a list. The marker is now its own span.

The options are numbered. `handle_question_menu_key` has accepted 1-9 since
the feature landed and nothing on screen ever said so, which is the same
defect as `esc to interrupt`: a working key nobody could discover.

Every option shows its description, not only the selected one. Comparing three
options is the whole activity, and a description that appears only under the
cursor makes the reader arrow up and down to do it. Descriptions are capped at
two lines: with one per option the card grows by the option count, and five
long ones push the question itself off a short pane.

The card is framed like the approval card. This reverses an assertion from
#408 ("question must not render as a boxed card") which arrived with no stated
reason; the two prompts are the same thing to the operator — the agent has
stopped and cannot continue without them — and looked like unrelated
components. Raised with the author before changing it.

The height estimate is now measured by rendering, as the approval card's
already is. The old constant said 8 rows for a card that is 14, and an
under-budget scrolls its own title off.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): keep one plan card, and record each revision as a line

Every `update_plan` call printed the whole checklist again, so a turn that
revised its plan three times left three near-identical lists stacked down the
transcript, at jittering widths. Codex does the same thing; it reads as a
flipbook of one list.

A plan is state, and state belongs in one place. The newest call keeps the
card, and the card it replaces becomes the one line that says what changed —
"Plan updated · 1 of 3 done · Implement the planned changes" — left at the
position that update happened, which is where history wants it. Three calls
now leave one card and two lines instead of three lists.

The record keeps how far the superseded plan had got, so scrolling back
through a long turn still shows the shape of its progress without repeating
the steps at each point.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): show what ran under each plan step

A checklist states intent. A step marked [✓] is the model's word for it, and
the transcript had no way to check the claim without scrolling back through
the activity log to see what happened between one plan update and the next.

Each step now carries the tool calls made while it was the step in progress:

    [✓] Read README and list crates
        read_file README.md, ls crates
    [►] Mark inspection step complete

Attribution is by observation, not by the model's say-so — the transcript
builder tags every tool result with whichever step was `InProgress` when it
arrived. Evidence is keyed by step text so it survives a revision that
completes or reorders steps, and is dropped with any step the model removed.

Subjects are shortened to a filename or the first two words of a command, and
capped at three per step with the rest counted. A step that ran nine commands
should read as a list of subjects, not as a second activity log inside the
card.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM

* feat(tui): dock the plan when its card scrolls out of view

Measured on a turn that recorded a plan and then wrote thirty lines of answer,
sampling the pane every 0.5s: the plan card was on screen for 8 frames out of
70 — about four seconds — and gone for the rest of the turn and after it.
Nothing on screen then said a plan existed, which step was running, or how far
in it was. Recovering it means scrolling up, which drops you out of follow
mode: during a turn you could watch the work or the plan, never both.

The card still lives inline where it was announced. Once it is above the
window, its one-row stand-in takes the top of the pane:

    ↑ Plan  ▓▓░░  2/4  ·  Wire the toggle into the settings pane

The arrow says where the real thing is; scroll back to it and the row gives
way to the card. Nothing is spent while the card is visible, which is what
made this preferable to a strip that holds a row of height forever.

Two things worth knowing about the implementation:

The card is found by rendering it standalone and matching its first and last
rows against what was produced, rather than threading a line index out of the
block loop — that loop feeds three cached entry points and a tail window, and
an index would have to be kept correct through all of them.

Follow mode renders only a tail window, so a plan far enough back is not in
the rendered lines at all — which is exactly when it most needs docking. The
first cut treated "not found" as "no plan" and the dock never appeared in a
live run; a plan whose block was trimmed by the window is now docked on that
basis alone.

Claude-Session: https://claude.ai/code/session_01PRJa3oW3o66f48FynE3MoM
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.

1 participant