feat(renderer): adapt content to viewport#20
Merged
kunchenguid merged 6 commits intomainfrom Apr 3, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_contentKey changes made
buildContentCellsnow acceptsavailableHeight, builds the content as explicit sections, and drops optional sections in priority order: ASCII art, eyebrow, agent message, then prompt.buildFrameCellsnow relies onbuildContentCellsfor viewport-aware sizing and removes the oldfitContentRowstruncation helper.src/renderer.test.tsadds 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)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, andbuildFrameCellsthen pads the gap back with empties; trim section padding before removing rendered sections.src/renderer.ts:317 -agentis pruned beforeprompt, 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.