Skip to content
This repository was archived by the owner on May 1, 2026. It is now read-only.

fix: short-circuit init visibleLogs when clamp hits zero#581

Merged
WcaleNieWolny merged 1 commit into
mainfrom
fix/init-visible-logs-zero-clamp
Apr 9, 2026
Merged

fix: short-circuit init visibleLogs when clamp hits zero#581
WcaleNieWolny merged 1 commit into
mainfrom
fix/init-visible-logs-zero-clamp

Conversation

@WcaleNieWolny
Copy link
Copy Markdown
Contributor

Summary

  • [1,2,3].slice(-0) returns the entire array because -0 coerces to 0, so the previous snapshot.logs.slice(-Math.max(0, rows - 14 - diffPanelHeight)) showed the full log list on terminals that were too short to fit any log lines after the code diff panel landed (PR feat: show code change diff panel during init onboarding step 5 #580).
  • Compute the clamp into visibleLogCount and explicitly short-circuit to [] when it hits zero, so a zero-budget viewport renders no logs instead of every log.

Test plan

  • Resize terminal so rows - 14 - diffPanelHeight <= 0 during init step 5 and confirm no log lines are rendered (prompt + spinner + diff panel only).
  • Resize terminal taller and confirm the most recent visibleLogCount lines are still shown.
  • Run bun run build — passes.

`[1,2,3].slice(-0)` returns the entire array because `-0` coerces to `0`,
so the previous `slice(-Math.max(0, rows - 14 - diffPanelHeight))` showed
the full log list on terminals that were too short to fit any log lines
after the code diff panel. Compute the clamp into a named variable and
explicitly short-circuit to `[]` when it hits zero.
@WcaleNieWolny WcaleNieWolny merged commit 0e0ea83 into main Apr 9, 2026
13 checks passed
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 9, 2026

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant