Skip to content

feat: add app.restorePreviousSession toggle to disable startup session restore - #13

Merged
evandhoffman merged 1 commit into
mainfrom
feat/restore-previous-session-toggle
Jun 20, 2026
Merged

feat: add app.restorePreviousSession toggle to disable startup session restore#13
evandhoffman merged 1 commit into
mainfrom
feat/restore-previous-session-toggle

Conversation

@evandhoffman

Copy link
Copy Markdown
Collaborator

What

Adds a user-facing setting to stop cmux from automatically restoring the previous launch (windows, workspaces, working directories, and terminal content) on startup.

Previously the only way to disable this was the undocumented CMUX_DISABLE_SESSION_RESTORE=1 env var — awkward for a GUI app. Now there's app.restorePreviousSession (default true, preserving today's behavior). When false:

  • The automatic startup restore is skipped; each launch opens a single fresh workspace seeded by app.defaultWorkspacePath.
  • The explicit Restore Previous Launch command (File menu / Command Palette / shortcut) still works — it's intentionally not gated, so you can pull the last session back on demand.

How

The gate lives in SessionRestorePolicy.shouldAttemptRestore() (Sources/SessionPersistence.swift), next to the existing CMUX_DISABLE_SESSION_RESTORE and automated-test gates, so all startup-restore suppression stays in one place. A restorePreviousSessionEnabled(defaults:) reader returns true when the key is unset (historical behavior).

Surfaces wired (mirrors the app.defaultWorkspacePath pattern from #5/#12)

  • AppCatalogSection.restorePreviousSessionDefaultsKey<Bool>
  • SessionRestorePolicy gate + default-true UserDefaults reader
  • cmux.json boolean mapping (CmuxSettingsJSONPathSupport)
  • JSON schema (web/data/cmux.schema.json)
  • Settings → App → Restore Previous Session toggle + settings-search entry
  • generated cmux.json template
  • localization en + ja (Resources/Localizable.xcstrings)
  • docs/configuration.md

Tests

Four regression tests in SessionPersistenceTests (a wired target), all passing locally:

  • default is true when unset; reader reflects stored value
  • shouldAttemptRestore(restorePreviousSessionEnabled: false) → skips restore
  • shouldAttemptRestore(restorePreviousSessionEnabled: true) → proceeds

Validation

  • xcodebuild Debug build: SUCCEEDED
  • 4 new tests: passed
  • pbxproj test-wiring lint: ok
  • Swift file-length budget: regenerated (AppSection.swift, SessionPersistence.swift, test file grew)
  • Localization audit: new Settings title/subtitle have en + ja; schema description is English-only description (matches defaultWorkspacePath precedent — no descriptionKey); template key and docs are not translatable UI strings.

https://claude.ai/code/session_01CNYr3XgjVDLsPNnPQxarn4

…n restore

cmux unconditionally restores the previous launch (windows, workspaces,
working directories, and terminal content) on startup. There was no
user-facing way to turn that off — only the undocumented
CMUX_DISABLE_SESSION_RESTORE=1 env var, which is awkward for a GUI app.

Add app.restorePreviousSession (default true, preserving current
behavior). When false, the automatic startup restore is skipped and each
launch opens a fresh workspace seeded by app.defaultWorkspacePath. The
explicit "Restore Previous Launch" command is intentionally unaffected —
it does not route through shouldAttemptRestore().

The gate lives in SessionRestorePolicy.shouldAttemptRestore(), alongside
the existing CMUX_DISABLE_SESSION_RESTORE / automated-test gates, so all
startup-restore suppression stays in one place.

Wired through every surface per repo conventions:
- AppCatalogSection.restorePreviousSession (DefaultsKey<Bool>)
- SessionRestorePolicy gate + UserDefaults reader (default true when unset)
- cmux.json boolean mapping (CmuxSettingsJSONPathSupport)
- JSON schema (web/data/cmux.schema.json)
- Settings → App toggle row + settings-search entry
- generated cmux.json template
- localization (en + ja) in Localizable.xcstrings
- docs/configuration.md
- regression tests (SessionPersistenceTests, wired target)

Claude-Session: https://claude.ai/code/session_01CNYr3XgjVDLsPNnPQxarn4
@evandhoffman
evandhoffman enabled auto-merge (squash) June 20, 2026 17:21
@evandhoffman
evandhoffman merged commit a12749d into main Jun 20, 2026
15 of 17 checks passed
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