File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,13 +75,18 @@ function ownDialog(): void {
7575function captureWorkspaces ( ) : void {
7676 const workspaces = getWorkspacesSnapshot ( ) . workspaces ;
7777 workspaceNames = workspaces . map ( ( workspace ) => workspace . name ) ;
78- const ids = new Set ( workspaces . map ( ( workspace ) => workspace . id ) ) ;
79- unsubscribeWorkspaces = subscribeToWorkspaces ( ( ) => {
78+ unsubscribeWorkspaces = watchWorkspaceMembership ( cancelQuit ) ;
79+ }
80+
81+ /** Both teardown consent gates keep the Workspace membership they asked about. */
82+ export function watchWorkspaceMembership ( onChange : ( ) => void ) : ( ) => void {
83+ const ids = new Set ( getWorkspacesSnapshot ( ) . workspaces . map ( workspace => workspace . id ) ) ;
84+ return subscribeToWorkspaces ( ( ) => {
8085 const current = getWorkspacesSnapshot ( ) . workspaces ;
8186 // A changed destination invalidates consent; focus, rename and order do not.
82- // Every exit from 'open' stops this watch, so no phase check is needed .
87+ // Each gate releases its watch before settling or committing .
8388 if ( current . length !== ids . size || current . some ( ( workspace ) => ! ids . has ( workspace . id ) ) ) {
84- cancelQuit ( ) ;
89+ onChange ( ) ;
8590 }
8691 } ) ;
8792}
Original file line number Diff line number Diff line change 11import { invoke } from "@tauri-apps/api/core" ;
2- import { getWorkspacesSnapshot , subscribeToWorkspaces } from "dormouse-lib/lib/workspace-store" ;
32import { listWallHandles } from "dormouse-lib/components/wall/wall-handles" ;
43import { cancelEditorClose , confirmToolEditorsClose } from "dormouse-lib/lib/tool-editor" ;
54import {
65 beginQuitProgress ,
76 dismissQuitConfirm ,
7+ watchWorkspaceMembership ,
88 type QuitConfirmIntent ,
99} from "./quit-confirm-store" ;
1010
@@ -164,13 +164,7 @@ export function createTeardownFlow(options: {
164164 const dirty = listWallHandles ( ) . flatMap ( ( wall ) => wall . dirtyToolIds ( ) ) ;
165165 if ( dirty . length ) {
166166 enter ( "confirming" ) ;
167- const ids = new Set ( getWorkspacesSnapshot ( ) . workspaces . map ( workspace => workspace . id ) ) ;
168- const mine = { stopWatching : subscribeToWorkspaces ( ( ) => {
169- const current = getWorkspacesSnapshot ( ) . workspaces ;
170- // The unsaved-file question precedes the running-work dialog, but
171- // its consent is already scoped to the Workspaces present now.
172- if ( current . length !== ids . size || current . some ( workspace => ! ids . has ( workspace . id ) ) ) cancel ( ) ;
173- } ) } ;
167+ const mine = { stopWatching : watchWorkspaceMembership ( cancel ) } ;
174168 editorWait = mine ;
175169 void confirmToolEditorsClose ( dirty ) . then ( ( accepted ) => {
176170 if ( editorWait !== mine ) return ;
You can’t perform that action at this time.
0 commit comments