Conversation
Layout reactivity hung off the clamped box width, while actualWidth was a raw render-time read of process.stdout.columns with no subscription of its own. A resize that left boxWidth unchanged - anything below 44 or above 204 columns - produced no re-render, so the welcome screen, input box, status bar and session selector kept rendering for a terminal size that no longer existed. The raw column count is now the reactive state and boxWidth derives from it, so every resize reaches every consumer through the same single shared listener. Closes Nano-Collective#1328.
nc-review: comments — 3 nits@addyCooks — a few things worth a look, none blocking. The PR correctly resolves #1328 by making the raw column count the reactive state and deriving ⚪ nit · The new ⚪ nit · Both new tests wait for the post-resize re-render with ⚪ nit ·
🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
The second resize test resized 100 to 140 columns, which neither clamps, so it never covered the regression for direct useTerminalWidth callers. It now resizes 250 to 350 - both clamp to 200 - and counts renders rather than distinct values, since an effect keyed on an unchanged width would never fire. Both tests now poll for the resize to propagate instead of sleeping a fixed 20ms. Verified both fail against the pre-fix hook. Also records why useResponsiveTerminal derives boxWidth from its own subscription rather than calling useTerminalWidth.
The unit-test job failed in source/commands/stats.spec.tsx, a pre-existing stale-closure bug in StatsDisplay arrow-key handling that this branch does not touch. Empty commit to get a clean run.
|
The failing
The test polls the frame as its readiness signal, so its second Nothing on this branch touches Fix is up separately in #1379; |
Closes #1328
Description
useResponsiveTerminalreturnedactualWidthas a raw render-time read ofprocess.stdout.columns, with no subscription of its own. The only reactive state was the clampedboxWidth(max(min(columns - 4, 200), 40)), so a resize that leftboxWidthunchanged produced no re-render at all:boxWidthpins to 40Resize anywhere inside those bands and every consumer welcome screen, input box, status bar, session selector kept rendering for the old terminal, so lines got cut off mid-word and boxes sat misaligned.
Fix: the raw column count becomes the reactive state, and
boxWidthderives from it.useTerminalWidthanduseResponsiveTerminalnow both read the same subscribed value, and nothing readsprocess.stdout.columnsduring render. The single sharedresizelistener is unchanged, so there is still exactly one stdout listener regardless of how many consumers mount.boxWidthhad been computed in two places; it is now computed once.Recording
Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Manual Testing
Checklist