fix(terminal): resize grid terminals to tile size#301
Merged
Conversation
Issue: Grid mode kept the full-view column count after PR #298, so output was clipped. Switching between grid and full could still disturb Claude Code history because Architect was bypassing Ghostty's prompt-redraw resize path. Solution: Recompute terminal dimensions from the stable view mode and include the cwd bar in grid height calculations. Resize in Ghostty's order by setting the PTY winsize before resizing ghostty-vt, letting shells redraw prompts when they opt in.
There was a problem hiding this comment.
Pull request overview
Adjusts how terminal PTY/VT sizes are computed and applied so grid tiles wrap to their visible content area (including grid font scaling and CWD bar space), and so resize ordering better matches Ghostty’s behavior to avoid history/prompt corruption during grid/full toggles (fixes #299).
Changes:
- Compute grid-mode backing terminal size from the rendered tile area (including grid scaling and per-cell CWD bar reserved height).
- Reorder resize application to set PTY winsize first, then resize the ghostty-vt model; apply resizes only in stable modes.
- Update/extend layout tests and ensure layout module tests are included in
zig test.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/main.zig |
Imports app/layout.zig in the root test block so layout tests run. |
src/app/runtime.zig |
Adds tile-aware render-height adjustment, stable-mode resize gating, and a per-frame “apply layout if changed” path. |
src/app/layout.zig |
Implements per-mode terminal sizing and updates resize logic + tests for new behavior. |
docs/ARCHITECTURE.md |
Updates architecture notes to reflect new terminal resize ordering and grid sizing behavior. |
README.md |
Updates feature bullet to reflect grid/full tracking of terminal dimensions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Issue: PR #301 review comments flagged inconsistent initial PTY pixel sizing, avoidable stable-frame resize work, and grid-sized terminal calculations during animation states. Solution: Use DPI-scaled padding for the initial winsize and initialize from the actual startup view mode. Limit grid height adjustment and grid-sized terminal calculations to stable grid mode, and return early when stable-layout cell dimensions are unchanged.
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.
Solution
Grid mode now computes the backing terminal size from the rendered tile instead of reusing full-view dimensions. The calculation includes grid font scaling and the cwd bar's reserved height, so the PTY and ghostty-vt width match the content area that is actually visible.
The resize path follows Ghostty's order: update the PTY winsize first, then resize ghostty-vt. That lets shells and agent CLIs that redraw on SIGWINCH handle prompt reflow normally instead of fighting a locally preserved prompt. Layout resizes are applied only in stable grid/full states, so expand/collapse animation frames do not churn the terminal model.
Fixes #299
Test plan