Skip to content

Preserve all windows/workspaces on close, not just the last one#3407

Open
Jordy098 wants to merge 1 commit into
wavetermdev:mainfrom
Jordy098:feature/persist-terminal-cwd-across-restart
Open

Preserve all windows/workspaces on close, not just the last one#3407
Jordy098 wants to merge 1 commit into
wavetermdev:mainfrom
Jordy098:feature/persist-terminal-cwd-across-restart

Conversation

@Jordy098

@Jordy098 Jordy098 commented Jul 2, 2026

Copy link
Copy Markdown

Summary

  • Terminal blocks already persist their cwd (cmd:cwd meta, set via the OSC 7 shell-integration handler) and restore it when their shell relaunches — but that only helps if the Block/Workspace survives in the DB.
  • Closing a window while other windows are still open (or with window:savelastwindow off) always deleted that window's workspace/tabs/blocks on close, discarding any persisted cwd along with it. Only a single-window full app quit reliably survived a restart.
  • Adds a new setting window:restoreallwindows (default true) so every window is preserved on close, not just the last one, letting all previously-open terminal paths come back after a full app restart.

Test plan

  • Open 2+ windows, cd to different directories in each terminal block and let the prompt render (fires OSC 7 → cmd:cwd)
  • Close one window via the close button (not full quit) — its workspace should remain in the DB instead of being deleted
  • Quit the app fully and relaunch
  • Confirm all windows reopen with their terminals in the same working directory as before
  • Repeat with window:restoreallwindows set to false to confirm the legacy single-window behavior still works

Closing a window when other windows are still open (or when
window:savelastwindow is off) always deleted its workspace, tabs, and
blocks from the DB, discarding each terminal's persisted cwd along
with them. Only a single-window full app quit survived a restart.

Add window:restoreallwindows (default true) so every window is kept
on close, matching the existing per-block cmd:cwd persistence that
already restores a shell's working directory when its block relaunches.
@CLAassistant

CLAassistant commented Jul 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1795c356-e47a-47a9-9a1f-c2231dc32d89

📥 Commits

Reviewing files that changed from the base of the PR and between c99022c and 92be0c8.

📒 Files selected for processing (7)
  • docs/docs/config.mdx
  • emain/emain-window.ts
  • frontend/types/gotypes.d.ts
  • pkg/wconfig/defaultconfig/settings.json
  • pkg/wconfig/metaconsts.go
  • pkg/wconfig/settingsconfig.go
  • schema/settings.json

Walkthrough

This PR introduces a new boolean configuration key, window:restoreallwindows, which controls whether all open windows are preserved and restored on next launch. The change adds the key to the Go settings struct, config key constants, default settings JSON, JSON schema, TypeScript type definitions, and documentation. The window close handler in the Electron main process is updated to compute window preservation based on this new setting in combination with the existing window:savelastwindow setting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

Not applicable; changes are primarily configuration/schema additions and a small conditional logic refactor.

Related PRs

None identified.

Suggested labels: enhancement, configuration

Suggested reviewers: none identified

🐰 A whisker-twitch of a config so small,
One bool to save the windows, one and all,
Schema, types, and docs align,
Close handler learns a new design,
Hop along, the settings stand tall.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preserving all windows and workspaces on close instead of only the last window.
Description check ✅ Passed The description directly matches the implemented change and test plan for the new window restoration behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.1)
frontend/types/gotypes.d.ts

File contains syntax errors that prevent linting: Line 1880: Expected a property, or a signature but instead found '#'.; Line 1880: Expected an expression, or an assignment but instead found ':'.; Line 1880: Expected an expression but instead found ']'.; Line 2193: Expected a statement but instead found '}'.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

2 participants