Skip to content

fix(cli): wrap AskUserQuestion options instead of truncating at terminal width (#4610) - #4615

Merged
me2seeks merged 1 commit into
apache:mainfrom
me2seeks:fix/4610-tui-question-option-wrap
Sep 3, 2026
Merged

fix(cli): wrap AskUserQuestion options instead of truncating at terminal width (#4610)#4615
me2seeks merged 1 commit into
apache:mainfrom
me2seeks:fix/4610-tui-question-option-wrap

Conversation

@me2seeks

@me2seeks me2seeks commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

When the agent asks a question via AskUserQuestion, option rows were hard-truncated at the terminal width — no wrap, no ellipsis, no way to read the tail. Users had to pick between protocol-compatibility strategies from half a sentence (see the issue screenshot).

UserQuestionOverlay now wraps option rows (and the question title) with pi-tui's ANSI-aware wrapTextWithAnsi: continuation lines indent under the option body, and the active row's highlight band covers every wrapped line. Because wrapping can outgrow the overlay's maxHeight — pi-tui clips overflow from the bottom, which would silently drop the free-text input row — the runner passes a live row budget (terminal.rows - margin, re-read per render so resize stays correct) and the overlay degrades gracefully when over budget: title capped at two lines, each option clamped to an equal share with a visible , so the hint, every option, the input row, and the divider always render.

Fixes #4610

Verification

  • packages/cli full suite: 757 tests, 0 fail — including 9 new tests in pi-tui-user-question-option.test.ts (CJK wrap content preservation, continuation indent, full-band highlight via exact ansi.reverse equality so it is color-level independent, SGR re-open across wrap points, ellipsis clamp, and render()-level budget assembly) and the 175 pre-existing pi-tui-runner.test.ts screen tests.
  • tsc -p packages/cli/tsconfig.json clean; biome check clean on changed files.
  • Manual: rendered the screenshot's long CJK options at width 40 — full text survives across wrapped rows (test pins this).

Review focus

Two rounds of adversarial sub-agent review were run against this diff. First pass found the missing height budget (major) and colorless-CI-vacuous assertions (minor), both fixed. Second pass found the title-cap ellipsis was dead code on already-padded lines (fixed via clampRowsWithEllipsis) and confirmed the remaining edge: a terminal too short for one row per option still overflows and falls back to the pre-existing pi-tui clip — never worse than before.

AI use

  • Generative tooling made a substantive contribution

Tool(s) and scope: Maka (AI agent) authored the full change: issue triage, design, implementation, tests, and two adversarial review rounds (also AI, with human-supervised fixes).

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above

@github-actions github-actions Bot added the effort/M Under 500 readable lines label Sep 3, 2026

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one correctness issue in the resize path.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

Comment thread packages/cli/src/pi-tui-runner.ts
…nal width (apache#4610)

Long option rows were hard-cut at the overlay width with no wrap, no
ellipsis, and no way to read the tail — users had to answer protocol
compatibility questions from half a sentence. Wrap option rows (and the
question title) with pi-tui's ANSI-aware wrapTextWithAnsi: continuation
lines indent under the option body, and the active row's highlight band
covers every wrapped line.

The overlay's row budget reads terminal.rows live, and the bottom-picker
overlay cap is now '100%' instead of a rows value frozen at open time:
pi-tui re-resolves it against the live terminal height on every composite,
so a question opened on a short terminal still shows its wrapped options,
input row, and divider after the terminal grows (review on apache#4615).

Generated-by: Maka (AI agent)
@me2seeks
me2seeks force-pushed the fix/4610-tui-question-option-wrap branch from 852dc4a to f00cdc5 Compare September 3, 2026 06:56

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head f00cdc58e2620137bda32939ae1cc0f6346aa55a.

The resize defect is closed. The bottom overlay now uses a percentage cap that the compositor resolves against the current terminal height, while the question surface reads its row budget on every render. The small-to-large terminal regression exercises the previously failing path and preserves both the free-text row and the full option text after growth.

I found no blocking or non-blocking correctness findings on this head. The exact-head test check is green and the current-main merge result is clean.


Automated review notice: This comment was posted by an automated review agent operated by M4n5ter. It is not an independent human review and does not replace one.

@me2seeks
me2seeks merged commit 69d6523 into apache:main Sep 3, 2026
1 check passed
ggbdpq pushed a commit to ggbdpq/maka that referenced this pull request Sep 4, 2026
…nal width (apache#4610) (apache#4615)

Long option rows were hard-cut at the overlay width with no wrap, no
ellipsis, and no way to read the tail — users had to answer protocol
compatibility questions from half a sentence. Wrap option rows (and the
question title) with pi-tui's ANSI-aware wrapTextWithAnsi: continuation
lines indent under the option body, and the active row's highlight band
covers every wrapped line.

The overlay's row budget reads terminal.rows live, and the bottom-picker
overlay cap is now '100%' instead of a rows value frozen at open time:
pi-tui re-resolves it against the live terminal height on every composite,
so a question opened on a short terminal still shows its wrapped options,
input row, and divider after the terminal grows (review on apache#4615).

Generated-by: Maka (AI agent)

Generated-by: GLM-5.3-Flash (ZCode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(cli): AskUserQuestion options hard-truncate at terminal width — long options unreadable

3 participants