Skip to content

fix(desktop): skip Electron's visibility listener on a destroyed window - #10398

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/desktop-destroyed-window-visibility
Nov 25, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/desktop-destroyed-window-visibility

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #10396, which merged before this last change landed.

#10396 dropped a closed window's visibility listeners so a macOS show (occlusion change) delivered after the window is gone no longer reaches Electron's own visibilityChanged listener, whose isVisible() call on the dead window throws "Object has been destroyed" as an uncaught main-process exception during quit. In the CI experiment (#10394, terminal-cancel relaunch-and-quit loops) that cut the rate from 7/960 to 2/960 launches: some late shows arrive after the window is destroyed but before its closed listeners run, so removing them on closed is too late.

This wraps Electron's listener on show, hide, minimize, maximize and restore instead, from browser-window-created (which Electron emits right after subscribing it, so it is the only listener there), and skips it once win.isDestroyed(). Visibility tracking for a live window is unchanged.

Type of Change

  • Bug fix

Testing

  • window.test.ts: on an Electron-wired window, visibility is still tracked while it lives, and a show/hide delivered after it is destroyed (with no closed in between) no longer throws. The second fails with the isDestroyed guard reverted.
  • Desktop unit tests for window and observability, type-check, biome.
  • CI experiment experiment: trace desktop fatal main-process errors (do not merge) #10394 reruns the 960 relaunch-and-quit loops with this change.

Checklist

  • Code follows project style
  • Tests added that fail without the fix
  • No prod data

🤖 Generated with Claude Code

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@vercel

vercel Bot commented Nov 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 25, 2026 3:21am UTC

Request Review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Replaces cleanup on closed with a check that skips Electron’s visibility listener once its window is destroyed.

  • Visibility events keep working for live windows and stop after destruction.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Browser window created] --> B[Wrap existing visibility listeners]
  B --> C[Visibility event arrives]
  C --> D{Window destroyed?}
  D -->|No| E[Call original listener]
  D -->|Yes| F[Skip original listener]
Loading

Reviews (1) · Last reviewed commit: "fix(desktop): skip Electron's visibility..." · Reviewed by Greptile

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit e49e733 into staging Nov 25, 2026
51 checks passed

This branch was previously deployed

1 inactive deployment
Preview — c2fdbe08 Deployed Nov 25, 2026 by vercel[bot]
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