Summary
When a workspace pane is closed, its currently-open tabs are not persisted unless the user has explicitly saved (Ctrl+S / the save button). Any tab opened since the last explicit save is therefore not present in the persisted dock-layout, so reopening the workspace does not restore it. The design owner has noted that autosave-on-close is not a current requirement; this issue is split out of #1340 (which covers a separate document-restore failure) so it can be tracked independently and prioritised later.
Root Cause
The pane-close path MainWindowViewModel.CloseWorkspaceCommand → OnCloseWorkspace → CloseWorkspacePaneAsync → RemoveWorkspacePaneAsync (features\Phantom.Workspaces\ViewModels\MainWindowViewModel.cs:2288-2329) disposes the pane but never persists it. The only persistence entrypoint is the explicit save: WorkspacePaneViewModel.SaveCommand → SaveAsync → SaveWorkspacePaneAsync → WriteBackWorkspaceTabs (MainWindowViewModel.cs:2786-2903, 2905-2906); WriteBackWorkspaceTabs has exactly one caller (the explicit save). Because RemoveWorkspacePaneAsync does not call it, tabs opened since the last explicit save are never written to the workspace entity's dock-layout, and are absent on the next reopen.
Affected Files
| File |
Contribution |
features\Phantom.Workspaces\ViewModels\MainWindowViewModel.cs |
RemoveWorkspacePaneAsync (:2288-2329) disposes without persisting; WriteBackWorkspaceTabs (:2786-2903) single-caller (explicit save only); SaveWorkspacePaneAsync (:2905-2906) |
features\Phantom.Workspaces\ViewModels\WorkspacePaneViewModel.cs |
SaveCommand/SaveAsync — the only persistence trigger today |
Design / Fix (deferred — not a current requirement)
If/when autosave-on-close is desired, have the pane-close path persist the pane's tabs before disposal — e.g. await WriteBackWorkspaceTabs(pane) (or the post-#1341 equivalent on WorkspacePaneViewModel) inside RemoveWorkspacePaneAsync before pane.DisposeAsync(). Consider whether this should be unconditional or gated (dirty-tracking / a setting), since unconditionally writing on every close changes current save semantics. Note: after #1341 relocates per-pane persistence onto WorkspacePaneViewModel, the natural home for this is a pane-level SaveOnCloseAsync.
Expected Tests
| Test Name |
Class |
What It Verifies |
RemoveWorkspacePaneAsync_WithUnsavedTabs_PersistsTabsBeforeDisposal |
MainWindowIntegrationTests |
Closing a pane with unsaved tabs writes them back before disposal (once implemented) |
WorkspaceReopen_AfterCloseWithoutExplicitSave_RestoresTabsOpenedSinceLastSave |
MainWindowIntegrationTests |
Reopen restores tabs that were opened after the last explicit save |
Summary
When a workspace pane is closed, its currently-open tabs are not persisted unless the user has explicitly saved (Ctrl+S / the save button). Any tab opened since the last explicit save is therefore not present in the persisted
dock-layout, so reopening the workspace does not restore it. The design owner has noted that autosave-on-close is not a current requirement; this issue is split out of #1340 (which covers a separate document-restore failure) so it can be tracked independently and prioritised later.Root Cause
The pane-close path
MainWindowViewModel.CloseWorkspaceCommand→OnCloseWorkspace→CloseWorkspacePaneAsync→RemoveWorkspacePaneAsync(features\Phantom.Workspaces\ViewModels\MainWindowViewModel.cs:2288-2329) disposes the pane but never persists it. The only persistence entrypoint is the explicit save:WorkspacePaneViewModel.SaveCommand→SaveAsync→SaveWorkspacePaneAsync→WriteBackWorkspaceTabs(MainWindowViewModel.cs:2786-2903, 2905-2906);WriteBackWorkspaceTabshas exactly one caller (the explicit save). BecauseRemoveWorkspacePaneAsyncdoes not call it, tabs opened since the last explicit save are never written to the workspace entity'sdock-layout, and are absent on the next reopen.Affected Files
features\Phantom.Workspaces\ViewModels\MainWindowViewModel.csRemoveWorkspacePaneAsync(:2288-2329) disposes without persisting;WriteBackWorkspaceTabs(:2786-2903) single-caller (explicit save only);SaveWorkspacePaneAsync(:2905-2906)features\Phantom.Workspaces\ViewModels\WorkspacePaneViewModel.csSaveCommand/SaveAsync— the only persistence trigger todayDesign / Fix (deferred — not a current requirement)
If/when autosave-on-close is desired, have the pane-close path persist the pane's tabs before disposal — e.g.
await WriteBackWorkspaceTabs(pane)(or the post-#1341 equivalent onWorkspacePaneViewModel) insideRemoveWorkspacePaneAsyncbeforepane.DisposeAsync(). Consider whether this should be unconditional or gated (dirty-tracking / a setting), since unconditionally writing on every close changes current save semantics. Note: after #1341 relocates per-pane persistence ontoWorkspacePaneViewModel, the natural home for this is a pane-levelSaveOnCloseAsync.Expected Tests
RemoveWorkspacePaneAsync_WithUnsavedTabs_PersistsTabsBeforeDisposalMainWindowIntegrationTestsWorkspaceReopen_AfterCloseWithoutExplicitSave_RestoresTabsOpenedSinceLastSaveMainWindowIntegrationTests