Skip to content

fix(terminal): hold synchronized resize repaints#303

Merged
forketyfork merged 3 commits into
mainfrom
fix/grid-resize-scroll-from-top
May 5, 2026
Merged

fix(terminal): hold synchronized resize repaints#303
forketyfork merged 3 commits into
mainfrom
fix/grid-resize-scroll-from-top

Conversation

@forketyfork
Copy link
Copy Markdown
Owner

@forketyfork forketyfork commented May 5, 2026

Solution

Grid/full transitions should still resize the PTY so running agents receive SIGWINCH and can adapt to the new terminal dimensions. The problem was that Architect presented the child process's resize repaint while it was still in progress, which made long sessions appear to scroll down from the top.

This change tracks DEC synchronized output mode on each session and skips render/present while any visible session is synchronizing. The previous frame stays on screen until the app finishes repainting, with a one-second timeout so a stuck synchronized-output mode cannot freeze the view indefinitely.

The architecture notes now document the resize/render invariant: PTY resize remains real, but synchronized resize repaints are held until they settle.

Test plan

  • Start an Architect session with long scrollback or an active agent transcript, toggle grid/full in both directions, and confirm the terminal layout adapts to the new width without showing a top-to-bottom repaint.
  • Repeat with multiple visible grid sessions and confirm one synchronizing session does not leave the UI frozen after repaint completion.

Issue: Grid/full resize in v0.64.0 made long terminal histories visibly repaint from the top because child TUIs received SIGWINCH and Architect presented their resize output before it settled.

Solution: Keep the real PTY resize so agents learn the new dimensions, but suppress rendering while visible sessions are in DEC synchronized output mode. Track when mode 2026 starts and clear it after one second so a broken app cannot freeze the view.
@forketyfork forketyfork requested a review from Copilot May 5, 2026 06:29
@forketyfork forketyfork marked this pull request as ready for review May 5, 2026 06:29
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8fc3c349f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app/runtime.zig Outdated
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

This PR addresses a terminal UX issue during grid/full transitions by detecting DEC synchronized output mode and temporarily holding render/present so users don’t see an in-progress top-to-bottom repaint during resize-triggered repaints.

Changes:

  • Track per-session synchronized output state and start timestamp, with a 1s timeout to force-clear stuck mode.
  • Skip render/present while any visible session is in synchronized output mode; continue processing PTY output and expire stuck mode in the frame loop.
  • Document the resize/render invariant in the architecture notes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/session/state.zig Adds synchronized-output tracking/timeout logic plus unit tests around forced expiry.
src/app/runtime.zig Detects synchronized output across visible sessions and suppresses rendering/idle classification while holding.
docs/ARCHITECTURE.md Documents the new synchronized-output resize/render behavior and timeout.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/app/runtime.zig
@forketyfork forketyfork marked this pull request as draft May 5, 2026 06:38
@forketyfork forketyfork marked this pull request as ready for review May 5, 2026 06:39
Issue: Address PR #303 review comments about hidden sessions blocking full-view rendering and synchronized-output holds spinning the event loop.

Solution: Scope full-view holds to the focused session while keeping previous-session checks for transitions that render both sessions. Pace synchronized-output holds with an explicit frame sleep so the loop keeps processing output and timeouts without relying on vsync presentation.
Handle DECRQM in Architect's VT stream handler so apps can query synchronized output state. Unknown ANSI and private modes now get the standard ;0 reply.
@forketyfork forketyfork merged commit 63f8715 into main May 5, 2026
4 checks passed
@forketyfork forketyfork deleted the fix/grid-resize-scroll-from-top branch May 5, 2026 07:08
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.

2 participants