Repository navigation
fix(terminal): skip redundant focus work and unchanged PTY resizes - #123
Merged
gsvprharsha merged 3 commits intoSep 20, 2026
Merged
Conversation
Refocusing after idle always scheduled fit plus a resize_pty IPC plus a full-row repaint, even with identical dims, and restore callbacks never coalesced. Cache last-sent PTY dims per session and skip the IPC when unchanged, coalesce restore fits into one pending slot, and repaint fully only after the page was hidden. WebGL reacquire, mobile-driven dims, initial font fit and terminal content paths are unchanged.
… failures Latch the hidden flag until focus consumes recovery so an early visible event cannot skip the restore repaint. Invalidate cached PTY dims on mobile-control acquisition so takeback always reasserts. Route all queued rAF fits/refreshes through a per-mount restore controller that cancels frames and neuters callbacks on dispose, so stale restores cannot run against a remounted session. Failed resize_pty invalidates only its own cached request, preserving newer updates. Reacquisition after WebGL context loss self-paints via xterm setRenderer, verified in the bundled addon source.
Retain only pending frame ids in the restore controller so cancellation touches live callbacks and the set cannot grow across the mount lifetime. Add a deferred-failure regression test where resize A stays pending while B succeeds: A's late rejection must not clobber B's cached dimensions, and newer changes still send.
|
@bferanmi806-sketch is attempting to deploy a commit to the Tempest OSS Team on Vercel. A member of the Team first needs to authorize it. |
bferanmi806-sketch
marked this pull request as ready for review
September 19, 2026 22:15
gsvprharsha
approved these changes
Sep 20, 2026
gsvprharsha
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed: policy/controller split, lifecycle guards, IPC scoping and latch semantics all verified. CI green. LGTM.
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.
Draft fix for #28 (idle refocus hitch on low-end systems); holding for review, not closing the issue yet.
Root cause: every window refocus on a visible terminal pane unconditionally scheduled fit plus a resize_pty IPC plus a full-row repaint, with zero change detection. The backend resizes unconditionally too, so each refocus cost an IPC round-trip plus ConPTY resize and shell repaint even when pixel-identical. Restore callbacks (focus, unhide, relayout) never coalesced, and N mounted panes each ran the sequence. webglPool.acquire was already idempotent and session timers already clear-then-set, so neither is the cause.
Implementation:
Test results:
Outstanding manual profiling: no live measurement of the 1-2s hitch and no interactive tauri dev run in this environment. Suggested: idle the app, Alt-Tab refocus (expect no resize_pty traffic, instant response) vs minimize-restore (expect one full repaint), rapid focus bouncing, split-pane restore, phone takeback sizing, and actual WebGL context-loss recovery on low-end hardware.
Ref: #28