Skip to content

feat(renderer): adapt content to viewport#20

Merged
kunchenguid merged 6 commits intomainfrom
feat/responsive-height
Apr 3, 2026
Merged

feat(renderer): adapt content to viewport#20
kunchenguid merged 6 commits intomainfrom
feat/responsive-height

Conversation

@kunchenguid
Copy link
Copy Markdown
Owner

Summary

The renderer now sizes the content column against the available terminal height instead of trimming overflow after the full layout is built. That keeps the stats row visible on short terminals, preserves the intended section order, and lets long moon-history output use only the space that remains.

Risk Assessment: 🟡 Medium — Medium risk because the change is well-tested but alters core renderer pruning behavior and already has warning-level critique about losing important content on small terminals.

Architecture

flowchart TD
  subgraph content_layout["Content Layout"]
    direction TB
    build_content["buildContentCells (updated)"]
    section_policy["Section priority policy (added)"]
    title_rows["renderTitleCells (unchanged)"]
    stats_row["renderStatsCells (unchanged)"]
    agent_rows["renderAgentMessageCells (unchanged)"]
    moon_rows["renderMoonStripCells (unchanged)"]

    section_policy -->|"drops art, eyebrow, agent, then prompt"| build_content
    build_content -->|"uses title rows from"| title_rows
    build_content -->|"keeps stats row from"| stats_row
    build_content -->|"includes status text from"| agent_rows
    build_content -->|"trims oldest history from"| moon_rows
  end

  subgraph frame_assembly["Frame Assembly"]
    direction TB
    build_frame["buildFrameCells (updated)"]
    fit_rows["fitContentRows (removed)"]
    renderer_tests["renderer height tests (updated)"]

    fit_rows -->|"removed from sizing flow"| build_frame
    renderer_tests -->|"verifies viewport behavior for"| build_frame
    renderer_tests -->|"verifies degradation order for"| build_content
  end

  build_frame -->|"passes available height to"| build_content
Loading

Key changes made

  • buildContentCells now accepts availableHeight, builds the content as explicit sections, and drops optional sections in priority order: ASCII art, eyebrow, agent message, then prompt.
  • When space is still tight, empty spacer rows are removed and moon rows are reduced to the newest rows that fit, while non-moon content is preserved.
  • buildFrameCells now relies on buildContentCells for viewport-aware sizing and removes the old fitContentRows truncation helper.
  • src/renderer.test.ts adds coverage for full-height spacing, adaptive section removal, moon overflow behavior, and frame/content viewport parity.

How was this tested

  • npx vitest run src/renderer.test.ts (29/29 tests passed)
  • npm test (npm run build && vitest run) (26/26 test files passed, 253/253 tests passed)
  • Prettier and ESLint auto-fix/check passes completed successfully

Critique Comments

  • 🟡 src/renderer.ts:322 - This height policy removes whole sections before reclaiming spacer rows, so medium-height terminals lose visible content while blank rows remain. A 21-row viewport drops the entire ASCII logo to save one line, and buildFrameCells then pads the gap back with empties; trim section padding before removing rendered sections.
  • 🟡 src/renderer.ts:317 - agent is pruned before prompt, which hides the live status line on 15-17 row terminals while keeping the static prompt. On constrained screens the progress message is usually higher value than the original prompt, so this priority should be reversed or prompt padding should be collapsed first.

@kunchenguid kunchenguid merged commit 592d80b into main Apr 3, 2026
3 checks passed
@kunchenguid kunchenguid deleted the feat/responsive-height branch April 3, 2026 18:41
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