Skip to content

fix(desktop): Remove unnecessary terminal refresh on window focus - #835

Merged
Kitenite merged 1 commit into
mainfrom
render-incorrect-location
Jan 19, 2026
Merged

Kitenite merged 1 commit into
mainfrom
render-incorrect-location

Conversation

@Kitenite

@Kitenite Kitenite commented Jan 19, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Remove aggressive terminal refresh logic that ran on every window focus event
  • Remove xterm.refresh(0, xterm.rows - 1) full repaint call
  • Remove clearTextureAtlas() call
  • Remove redundant window.focus event listener

Previously, every window focus triggered a full terminal repaint for ALL terminal panes. This was originally added to fix WebGL texture atlas corruption, but was overly aggressive - the WebGL addon already handles actual context loss via onContextLoss.

Now only visibilitychange handler remains to sync dimensions when returning from background (in case window was resized while minimized).

Test plan

  • Verify terminal renders correctly after alt-tabbing away and back
  • Verify terminal renders correctly after minimizing and restoring
  • Verify zsh autosuggestions render smoothly without glitches
  • Verify multiple terminal panes don't flicker on window focus

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced terminal window handling. Terminal now properly synchronizes dimensions and layout when the application becomes visible again after being in the background or hidden behind other windows. Improved overall reliability and visual consistency of the terminal interface.

✏️ Tip: You can customize this high-level summary in your review settings.

Remove aggressive refresh logic that ran on every window focus event:
- Removed xterm.refresh(0, xterm.rows - 1) full repaint
- Removed clearTextureAtlas() call
- Removed window focus event listener

Previously, every window focus triggered a full terminal repaint for ALL
terminal panes, which could cause visual glitches during rapid terminal
updates (e.g., zsh autosuggestions).

Now only visibilitychange handler remains to sync dimensions when
returning from background (in case window was resized while minimized).
@coderabbitai

coderabbitai Bot commented Jan 19, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Replaced a complex debounce-based WebGL atlas refresh mechanism triggered on window focus with a simpler visibilitychange event handler. The new flow calls fitAddon.fit() and conditionally updates PTY size if terminal dimensions changed. Removed focus event listener, texture atlas clearing, and explicit refresh logic.

Changes

Cohort / File(s) Summary
Terminal visibility refresh simplification
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
Replaced window focus handler and debounced texture atlas refresh with document visibilitychange listener. New handleVisibilityChange synchronizes terminal layout via fitAddon.fit() and resizes PTY if xterm dimensions (cols/rows) changed. Removed atlas clearing and explicit refresh calls; updated cleanup to remove focus event listener.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • AviPeltz

Poem

🐰 The window doth no longer chase its focus with glee,
Instead, visibility's gentle pulse sets the terminal free!
No atlas needs clearing, no refresh to implore—
One simple handler syncs all, and the code weighs much more!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: removing unnecessary terminal refresh on window focus, which matches the primary objective of the changeset.
Description check ✅ Passed The description includes a clear summary, rationale, and test plan, though it doesn't follow the exact template structure with sections like 'Related Issues', 'Type of Change', and 'Screenshots'.
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 docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@Kitenite
Kitenite merged commit 044c879 into main Jan 19, 2026
5 checks passed
@Kitenite
Kitenite deleted the render-incorrect-location branch January 19, 2026 21:31
@github-actions

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

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