Skip to content

fix(terminal): resize grid terminals to tile size#301

Merged
forketyfork merged 3 commits into
mainfrom
fix/grid-terminal-resize
May 4, 2026
Merged

fix(terminal): resize grid terminals to tile size#301
forketyfork merged 3 commits into
mainfrom
fix/grid-terminal-resize

Conversation

@forketyfork
Copy link
Copy Markdown
Owner

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

  • Run Architect with at least two terminals and open Claude Code in one of them.
  • Generate enough Claude Code output to span several rows, then switch grid -> full -> grid a few times.
  • Verify grid mode wraps within the visible tile and no right-side output is clipped.
  • Verify the full-mode history does not duplicate, drop, or shift Claude Code output after switching modes.
  • Repeat with a short terminal session and confirm grid mode still shows the existing content instead of an empty tile.

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.
@forketyfork forketyfork marked this pull request as ready for review May 4, 2026 06:03
@forketyfork forketyfork requested a review from Copilot May 4, 2026 06:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/app/runtime.zig Outdated
Comment thread src/app/runtime.zig
Comment thread src/app/runtime.zig
Comment thread src/app/layout.zig Outdated
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.
@forketyfork forketyfork merged commit 95d0005 into main May 4, 2026
4 checks passed
@forketyfork forketyfork deleted the fix/grid-terminal-resize branch May 4, 2026 06:46
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.

[Bug]: Full view toggles corrupt embedded agent terminal history

2 participants