Repository navigation
refactor: deliver watcher events and close requests only to their own window - #687
Merged
Merged
Conversation
Azganoth
enabled auto-merge (squash)
October 11, 2026 07:10
Azganoth
disabled auto-merge
October 11, 2026 07:16
Azganoth
enabled auto-merge (squash)
October 11, 2026 07:16
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.
Summary
The backend assumed one window. It held one native watcher per kind for the whole application, broadcast watcher events and close requests to every window, and tracked a single pending close request, so a second window's document watch replaced the first's and closing one of two windows destroyed both (#633). Watches and close requests now belong to their window, as groundwork for tabs (#641) and more windows (#642). With one window and one document, watching and closing behave as before.
decline_window_closecommand instead of a broadcast event, so the backend learns the window from the caller rather than from the message. Destroying a window clears its pending request.*) rather thanmain; every window loads the local frontend.Related Issue
Closes #640
Verification
watch_scopeRust tests: several document watches in one window start and stop independently, including a stop that arrives before or during its start; two windows' folder and document scopes do not displace each other, whether their numbers match or one window's are lower; stopping a window drops only its watches.windowRust tests: the close guard asks each window's frontend separately and closes only the window whose request went unanswered.useActiveDocumentWatcher: a watch closed before it was requested is never stopped, and a failed start is still stopped. The close-request handler and both watchers listen through their own window, which Tauri limits to events addressed to it;apptests cover declining through the command.pnpm check:frontendandpnpm check:backendpassed.Manually verified in a Windows 11 debug build with a temporary command that opened a second window, driven over the WebView2 DevTools protocol with an event recorder in each window:
Not verified: the desktop E2E suite locally, which CI runs. No scenario was added, since the E2E capability grants WebDriver access to
mainonly.Notes
A webview reload restarts the window's scope numbering while the backend still holds the old page's scopes, so a watch whose ID collides is refused until the window closes. Generations had the same limit before this change; it is left as is.