Skip to content

fix(main): migrate remaining window fan-outs to guarded broadcastToAllWindows - #937

Draft
h4yfans wants to merge 2 commits into
mainfrom
window-broadcast-fanout-remaining
Draft

fix(main): migrate remaining window fan-outs to guarded broadcastToAllWindows#937
h4yfans wants to merge 2 commits into
mainfrom
window-broadcast-fanout-remaining

Conversation

@h4yfans

@h4yfans h4yfans commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #935. Migrates the remaining ~30 unguarded BrowserWindow.getAllWindows() + webContents.send() fan-out sites in the main process to broadcastToAllWindows(channel, data?), which skips destroyed windows and webContents. Unguarded sends against destroyed short-lived windows (splash, quick capture, print/export) throw, and inside sync item handlers that throw rolls back the applied item's DB transaction.

Scope

  • ipc/: settings-handlers (8 sites incl. the zero-payload quick-capture:open shortcut callback), sync-attachment-handlers (4), auth-oauth-handlers (2), auth-device-handlers (2), sync-core, bookmarks, canvas, tags, saved-filters, journal, calendar, ai-inline, locale
  • vault/: index (4 sites), watcher, templates, rename-tracker, notes-io
  • sync/: crdt-writeback, linking-service, token-manager, item-handlers/settings-handler (kept its throw-swallowing try/catch — runs inside sync item application)
  • import/: import-context
  • root: test-hooks

Helper change: data param is now optional for the zero-payload quick-capture:open broadcast.

Left untouched by design: window-selection sites (find/filter/[0]/length/fromWebContents) in agent-handlers, agent-lazy-handlers, canvas-handlers close-listener bookkeeping, menu.ts, and all index.ts sites. Files covered by #935 are not touched here — no overlap, either PR can land first.

Test mocks: electron mocks returning bare { webContents: { send } } windows now need isDestroyed: () => false at window and webContents level (same idiom as #935); ~30 test files updated accordingly.

Verification

  • pnpm --filter @memry/desktop typecheck:node clean
  • pnpm --filter @memry/desktop test:main: 415 files / 4497 tests passed (one expectation updated: the zero-payload broadcast now sends an explicit undefined payload arg)
  • ESLint on changed files: 0 errors
  • pnpm docs:impact --base origin/main --strict green (apps/docs/src/architecture/ipc.md updated); pnpm docs:build green

Copilot AI review requested due to automatic review settings August 3, 2026 17:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

h4yfans added 2 commits August 3, 2026 20:17
…lWindows

Follow-up to #935: replace ~30 unguarded BrowserWindow.getAllWindows() +
webContents.send() fan-out sites across ipc/, vault/, sync/, import/, and
test-hooks with broadcastToAllWindows(), which skips destroyed windows and
webContents. Window-selection sites (find/filter/[0]/length) are untouched.
The helper's data param is now optional for the zero-payload
quick-capture:open broadcast. Test electron mocks gain isDestroyed guards
per the #935 idiom.
@h4yfans
h4yfans force-pushed the window-broadcast-fanout-remaining branch from 9c51ae4 to 18435ce Compare August 3, 2026 17:20
Copilot AI review requested due to automatic review settings August 3, 2026 17:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation test labels Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 18435ce.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.83673% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...s/desktop/src/main/ipc/sync-attachment-handlers.ts 50.00% 2 Missing ⚠️
apps/desktop/src/main/ipc/settings-handlers.ts 87.50% 1 Missing ⚠️
...op/src/main/sync/item-handlers/settings-handler.ts 85.71% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants