Skip to content

fix(cli): account for wrapped working line in composer cursor offset - #7768

Open
innocarpe wants to merge 1 commit into
esengine:main-v2from
innocarpe:contrib/r12-tui-cursor
Open

fix(cli): account for wrapped working line in composer cursor offset#7768
innocarpe wants to merge 1 commit into
esengine:main-v2from
innocarpe:contrib/r12-tui-cursor

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

Summary

Fix #7537 (TUI composer cursor drifts outside the input box on narrow terminals while a turn is running):

Root cause: View() counted the working (spinner) line as exactly 1 row (rowsAboveBox++), but renders it with wrapStatusLine(working, boxW) — which wraps to 2+ rows on narrow terminals. The composer cursor math (cur.Y += viewport.Height() + rowsAboveBox + 1) then placed the cursor N−1 rows above the actual input box. The height budget (bottomRows/computeStatusLineCount) already counted wrapped rows — only rowsAboveBox was wrong.

Fix (3 hunks, no rendering change):

  • New helper workingLineRows(working, width) — wrapped-row count via the same wrapStatusLine/width the bottomRows path uses
  • View() uses it instead of the hardcoded 1; computeStatusLineCount now shares the helper (behavior identical)
  • composer_selection.go verified clean (textarea-internal viewport only)

Tests (headless, narrow-terminal): TestWorkingLineRowsWrapAccounting (pure-helper table) + TestWorkingLineWrapKeepsComposerCursorInBox — asserts cursor Y lands inside the composer box with a 2+ row wrapped working line; fails pre-fix, passes post-fix.

Issues

Fixes #7537

Verification

  • go test ./internal/cli/ — full suite pass
  • go vet / gofmt -l / go build ./cmd/reasonix — clean

Documentation impact

Documentation-impact: none - cursor positioning; no docs affected.

Cache impact

Cache-impact: none - TUI rendering only; no prompt/tool surface touched.
Cache-guard: N/A
System-prompt-review: N/A

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development tui Terminal UI / CLI (internal/cli, internal/control) labels Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TUI cursor moves out of boundaries while prompting

1 participant