nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Composer input box is clipped on the left in terminals narrower than 40 columns

Open addyCooks opened this issue 2 months ago • 1 comments

Description

In a terminal narrower than 40 columns, the composer's left border, the > prompt marker, and the first several characters of the placeholder/typed text are cut off and invisible. This is a regression-adjacent edge case in the responsive layout work from #948 (closed), the box's own minimum-width floor isn't clamped against the actual terminal width.

Note: This is specific to feature/new-ui's responsive composer layout. Please target any fix at feature/new-ui, not main.

Parent: #907 Related: #948 (Responsive and Centered Terminal Layout, closed; this is an edge case that slips through it)

Environment

  • Any terminal/pane narrower than 40 columns, e.g. a vertical tmux split, a narrow VS Code integrated terminal panel, or a manually resized window on an otherwise-normal 80-column screen.

Steps to Reproduce

  1. Start Nanocoder on feature/new-ui.
  2. Resize the terminal (or open it in a pane) narrower than 40 columns, try ~30 and ~20 columns.
  3. Look at the composer/input box.

Expected Behavior

The input box should adapt to the available width, shrinking further, dropping its border, or truncating gracefully, while keeping the prompt marker and the start of the typed/placeholder text visible.

Actual Behavior

The box's left edge (border, > marker, first characters) is pushed off-screen and invisible. Captured frames:

30x10 terminal -> "sk anything..." (border, ">", and "A" from "Ask..." are gone) 20x8 terminal -> "ything..." (most of the placeholder is gone) 44x20 (control, above the floor) -> complete box, nothing missing

Root Cause

source/components/user-input.tsx:47,119,1019, promptWidth = Math.max(40, actualWidth - 4) enforces a 40-column minimum width for the box, but that box is centered (alignItems="center") inside a parent whose actual width can be smaller than 40. When the child is wider than its parent, Ink centers it anyway, producing a negative left offset, and drops whatever falls off the left edge instead of the right.

Suggested Fix

Clamp promptWidth to the terminal's actual width instead of only enforcing a floor:

const promptWidth = Math.min(actualWidth, Math.max(40, actualWidth - 4));

Consider also dropping the rounded border below roughly 24 columns, since a bordered box can't fit much else at that width.

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs on the latest feature/new-ui

addyCooks avatar Sep 12 '26 06:09 addyCooks

Hey @akramcodez,
I’m interested in working on this.... could you assign the issue to me : )

addyCooks avatar Sep 12 '26 06:09 addyCooks