Skip to content

fix(daemon): re-probe terminal width on every serve request - #36

Merged
axisrow merged 1 commit into
mainfrom
fix/serve-width-reprobe
Sep 28, 2026
Merged

axisrow merged 1 commit into
mainfrom
fix/serve-width-reprobe

Conversation

@axisrow

@axisrow axisrow commented Sep 28, 2026

Copy link
Copy Markdown
Owner

What

Follow-up to the P2 review finding on #35: createProcessServeDependencies().resolveTerminalWidth now calls resetTerminalWidthCache() before each probe, so a long-lived --serve process picks up terminal resizes instead of serving the memoized width from the first request.

Why

getTerminalWidth memoizes its probe at process scope (hasProbed/cachedWidth), deliberately, for the one-shot-per-repaint model. In --serve the process lives across requests, so the memo never went stale-checked: an 80→120-column resize after the first request kept returning 80 on every subsequent request, even with terminalWidthCacheTtlSeconds: 0 (reproduced under both Node and Bun; a fresh process correctly saw 120).

Verification

  • New regression test in serve.test.ts: set CCSTATUSLINE_WIDTH=80, resolve, set 120, resolve again → 120 (fails without the reset, since the memo short-circuits before the env override).
  • Full serve file: 6 pass; bun run lint clean.

🤖 Generated with Claude Code

getTerminalWidth memoizes its probe process-globally, so in a
long-lived --serve process a terminal resize after the first request
kept serving the stale width forever, even with
terminalWidthCacheTtlSeconds: 0 (80->120 resize reproduced: serve
kept 80, a fresh process saw 120). Reset the memo before each
request via the existing resetTerminalWidthCache seam, and add a
regression test asserting the new width is picked up.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@axisrow
axisrow merged commit 9d5f7e6 into main Sep 28, 2026
3 checks passed
@axisrow
axisrow deleted the fix/serve-width-reprobe branch September 28, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant