fix(agent): width-aware interactive prompt/status line (#209) - #211
Open
justrach wants to merge 1 commit into
Open
fix(agent): width-aware interactive prompt/status line (#209)#211justrach wants to merge 1 commit into
justrach wants to merge 1 commit into
Conversation
Agent.prompt emitted the full model/effort/provider/mode/cwd/context status line with no width budget, so a narrow terminal pane soft-wrapped it mid-badge (e.g. splitting `codex`) and left the cursor visually inside a label. readline.zig only reacts after the fact by moving the input to a fresh row; the status string had already wrapped. prompt() now budgets each segment against termCols(): the model plus the settings that disambiguate the cursor (effort, provider, mode badges) come first, and cwd/context/cache/cost are dropped when they no longer fit. The context meter outranks cwd for the budget (the urgent, changing signal near the compaction threshold) but still renders after cwd so the familiar order is kept when both fit. The line reserves the fixed frame plus a column of slack, so nothing but a model name longer than the pane can wrap; readline then gives the input its own row as before. The wcwidth-style dispWidth/codepointWidth table moves from repl.zig into term.zig (the shared terminal-utilities leaf) so the TUI table math and this budgeting share one definition; repl.zig delegates and keeps its #142 test. Tests: new scripts/test-pty-narrow-prompt.py drives a real 28-col PTY and asserts the line fits, badges stay whole, and cwd is dropped, while a wide pane still shows cwd; test-pty-repl.py widened to 200 cols so its badge-state session fits the full line; zig build test 184/184, zig fmt clean, full PTY suite green. Refs #209 Co-Authored-By: blackfloofie <265516171+blackfloofie@users.noreply.github.com>
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.
Problem
Agent.promptemitted the full model/effort/provider/mode/cwd/context status line with no width budget, so a narrow terminal pane soft-wrapped it mid-badge (e.g. splittingcodex) and left the cursor visually inside a label:readline.zigonly reacts afterward by moving the input to a fresh row; by then the status string has already wrapped.Fix
prompt()budgets each segment againsttermCols():cwd/context/cache/cost are dropped when they no longer fit.cwdfor the budget (it is the urgent, changing signal near the compaction threshold) but still renders aftercwd, so the familiar left-to-right order is kept when both fit.[…] ›) plus a column of slack, so nothing but a model name longer than the pane can wrap;readlinethen gives the input its own row as before.Progressive disclosure at increasing widths (captured from a real PTY):
The wcwidth-style
dispWidth/codepointWidthtable moves fromrepl.zigintoterm.zig(the shared terminal-utilities leaf) so the TUI table math and this budgeting share one definition;repl.zigdelegates and keeps its #142 test.Tests
scripts/test-pty-narrow-prompt.py— drives a real 28-col PTY and asserts the line fits, badges stay whole, andcwdis dropped, while a wide pane still showscwd.scripts/test-pty-repl.pywidened to 200 cols so its badge-state session fits the full line.zig build test184/184,zig fmtclean, full PTY suite green.Closes #209