Skip to content

renderer: disable stale-frame resize guard for embedded#8

Open
shuhei0866 wants to merge 3 commits intomanaflow-ai:mainfrom
shuhei0866:draft/embedded-stale-frame-guard
Open

renderer: disable stale-frame resize guard for embedded#8
shuhei0866 wants to merge 3 commits intomanaflow-ai:mainfrom
shuhei0866:draft/embedded-stale-frame-guard

Conversation

@shuhei0866
Copy link

@shuhei0866 shuhei0866 commented Mar 8, 2026

Summary

Disable the stale-frame resize guard for the embedded runtime in renderer/generic.zig.

Problem

The generic renderer keeps the last presented frame on-screen during some resize transitions to avoid a transient blank flash while the resized cell buffers catch up.

That policy is reasonable for native hosts that may synchronously request display during resize.
For the embedded runtime, it can produce the opposite failure mode: the UI keeps repainting, but the terminal body visibly stays on a stale frame during resize.

Change

  • introduce use_stale_frame_guard
  • keep the existing guard for non-embedded runtimes
  • disable it for apprt.embedded

Why this layer

This is renderer presentation policy, not host event wiring.
The embedded host was already delivering:

  • resize events
  • redraw requests
  • input
  • PTY I/O

The remaining failure was that the renderer intentionally preferred the previous frame for a size-mismatch window that is acceptable in native hosts but wrong for the embedded host.

Validation

Validated from the cmux embedded host against the failure mode this branch was hitting:

  • before: terminal body stayed visually stale during resize even though GTK continued repainting
  • after: terminal body follows resize correctly and input remains usable

Notes

  • This is being opened first as a draft because it is part of the Ubuntu MVP integration path for cmux.
  • If this direction is accepted in the manaflow fork, I plan to come back and propose the same renderer-policy change upstream after going through Ghostty's vouch process.

Related draft PRs

This PR is one part of the Ghostty-side dependency chain for the Ubuntu/cmux MVP.

Scope split:

  • #8: renderer policy for apprt.embedded resize presentation
  • #9: Linux embedded host support for GtkGLArea / OpenGL bring-up

Summary by CodeRabbit

  • Bug Fixes
    • Prevented unintended frame presentation during synchronous callbacks in embedded runtimes, reducing redundant redraws.
    • Improved stability and consistency of redraws during window resize across runtime environments by gating presentation to appropriate conditions.

@coderabbitai
Copy link

coderabbitai bot commented Mar 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f7599ac1-e2a6-4b31-b21c-196943467475

📥 Commits

Reviewing files that changed from the base of the PR and between 702a962 and 4a2b594.

📒 Files selected for processing (1)
  • src/renderer/generic.zig

📝 Walkthrough

Walkthrough

Introduced a runtime-dependent guard in drawFrame that gates the presentLastTarget call during synchronous resizes. The guard (use_sync_stale_frame_guard) evaluates false for embedded runtimes and true otherwise; comments were added explaining the embedded-host behavior and rationale.

Changes

Cohort / File(s) Summary
Sync Redraw Guard Logic
src/renderer/generic.zig
Added use_sync_stale_frame_guard (based on apprt.runtime) and wrapped the presentLastTarget invocation so it only runs when the guard is true alongside existing sync, size_changed, and has_presented conditions; added explanatory comments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nudge a frame with careful paw,
Embedded hushes; others draw.
A tiny guard decides the fate,
Present or pause at the sync gate.
Hooray for frames — soft hop, no wait!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: disabling the stale-frame resize guard specifically for embedded runtimes in the renderer component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@shuhei0866
Copy link
Author

Upstream tracking issue: ghostty-org#11223

@shuhei0866
Copy link
Author

Upstream issue attempt: ghostty-org#11223. It was auto-closed by Ghostty's vouch policy, so for now this draft PR is the canonical review surface.

@shuhei0866 shuhei0866 marked this pull request as ready for review March 9, 2026 15:51
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@greptile-apps
Copy link

greptile-apps bot commented Mar 9, 2026

Greptile Summary

This PR disables the synchronous-draw stale-frame guard in renderer/generic.zig for the apprt.embedded runtime, preventing the terminal body from staying visually frozen on the previous frame while GTK continues issuing redraws during interactive resize.

Key changes:

  • Introduces a comptime use_sync_stale_frame_guard constant evaluated via switch (apprt.runtime)false for apprt.embedded, true for all other runtimes.
  • The synchronous stale-frame guard (sync + size-changed + has-presented → presentLastTarget()) is now correctly skipped for embedded hosts.
  • The change is narrow (one file, ~12 lines), comptime-safe, and zero-cost for non-embedded builds.
  • Author validation confirms the fix works: terminal body follows resize correctly with input remaining usable.

Confidence Score: 5/5

  • Safe to merge - narrow, targeted fix with validated results on embedded runtime.
  • The PR makes a focused, comptime-evaluated architectural change to disable the synchronous stale-frame guard for embedded hosts only. The change is zero-cost for non-embedded builds, correctly targets the identified problem (terminal visual staleness during interactive resize on embedded GTK), and has been validated to resolve the issue without regressions. The narrowness and runtime-specific conditioning minimize risk.
  • No files require special attention

Last reviewed commit: 702a962

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