Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion desktop/tabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,14 @@ func (a *App) CloseTab(tabID string) error {
a.mu.Unlock()
return fmt.Errorf("cannot close the last tab")
}
// Snapshot the session state before removing the tab from a.tabs.
// This closes a race window with DeleteSession: if Snapshot runs
// after delete(a.tabs, tabID), a concurrent DeleteSession can delete
// the session files, and the deferred Snapshot recreates them.
if tab.Ctrl != nil {
_ = tab.Ctrl.Snapshot()
}

ordered := a.orderedTabIDsLocked()
closedIndex := -1
for i, id := range ordered {
Expand Down Expand Up @@ -1280,7 +1288,6 @@ func (a *App) CloseTab(tabID string) error {

// Tear down outside the lock.
if tab.Ctrl != nil {
_ = tab.Ctrl.Snapshot()
if tab.hasActiveRuntimeWork() && a.detachSessionRuntime(tab) {
return nil
}
Expand Down
Loading