Skip to content

fix(core): save tab recovery state before disabling it on close - #11621

Open
uadhran wants to merge 1 commit into
Eugeny:masterfrom
uadhran:fix/11593-tab-recovery-final-save
Open

fix(core): save tab recovery state before disabling it on close#11621
uadhran wants to merge 1 commit into
Eugeny:masterfrom
uadhran:fix/11593-tab-recovery-final-save

Conversation

@uadhran

@uadhran uadhran commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Addresses #11593

Problem

AppService.closeWindow() set tabRecovery.enabled = false and then called saveTabs(). saveTabs() returns immediately when that flag is off, so the snapshot that is supposed to run on a clean close never wrote. Recovery on the next launch was whatever the last 1s/30s debounce had stored.

enabled = false is still required during teardown: closeAllTabs() destroys tabs and that would otherwise save an empty list over the snapshot.

Fix

Save first, then latch the flag off:

async closeWindow (): Promise<void> {
    await this.tabRecovery.saveTabs(this.tabs)
    this.tabRecovery.enabled = false
    if (await this.closeAllTabs()) {
        this.hostWindow.close()
    } else {
        this.tabRecovery.enabled = true
    }
}

saveTabs() is unchanged. If a tab blocks close, recovery is turned back on as before.

Verification

Ran the real saveTabs / closeWindow bodies:

  • save while enabled writes
  • save while disabled is a no-op
  • close writes current tab state, then disables
  • a follow-up save of [] does not wipe that snapshot
  • if a tab blocks close, recovery is re-enabled and the window stays open

eslint on app.service.ts is clean.

closeWindow() set tabRecovery.enabled = false and then called
saveTabs(), which returns immediately when disabled, so the final
snapshot never wrote. Save first, then latch the flag off so
teardown still cannot overwrite recovery with an empty tab list.

Addresses Eugeny#11593
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant