Skip to content

Closing a workspace pane does not persist its open tabs (no autosave on close; tabs opened since last Ctrl+S are lost on reopen) #1345

Description

@JoshuaRowePhantom

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.CloseWorkspaceCommandOnCloseWorkspaceCloseWorkspacePaneAsyncRemoveWorkspacePaneAsync (features\Phantom.Workspaces\ViewModels\MainWindowViewModel.cs:2288-2329) disposes the pane but never persists it. The only persistence entrypoint is the explicit save: WorkspacePaneViewModel.SaveCommandSaveAsyncSaveWorkspacePaneAsyncWriteBackWorkspaceTabs (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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdiagnosedRoot cause identified

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions