Skip to content

Fix workspace name when restoring a workspace#118

Open
fvalenza wants to merge 1 commit intoMLFlexer:mainfrom
fvalenza:topic/restore_workspace_name
Open

Fix workspace name when restoring a workspace#118
fvalenza wants to merge 1 commit intoMLFlexer:mainfrom
fvalenza:topic/restore_workspace_name

Conversation

@fvalenza
Copy link
Copy Markdown

@fvalenza fvalenza commented Aug 21, 2025

Hello and thanks for this plugin !

Currently when restoring a workspace, it restores the state (tabs/panes/processes) without restoring the workspace name ( hence we are still on default workspace and in the spawned window, no traces of the name of restored worspace)

This PR shall fix this:

  • When opts.spawn_in_workspace is true -> add the restored workspace to the current instance of wezterm and switch to it
  • When opts.spawn_in_workspace is false -> spawn a new instance with the restored workspace's state + rename it accordingly so we can continue editing the same workspace (instead of manually renaming it).

Fixes #114

gcc42 added a commit to gcc42/resurrect.wezterm that referenced this pull request Jan 11, 2026
When restoring a workspace, the tabs/panes/processes were restored but
the workspace name remained 'default'. Now properly restores the original
workspace name using set_active_workspace or rename_workspace depending
on the spawn mode.

Fixes: MLFlexer#118
gcc42 added a commit to gcc42/resurrect.wezterm that referenced this pull request Jan 12, 2026
When restoring a workspace, the tabs/panes/processes were restored but
the workspace name remained 'default'. Now properly restores the original
workspace name using set_active_workspace or rename_workspace depending
on the spawn mode.

Includes mux fake implementations and regression test.

Fixes: MLFlexer#118
gcc42 added a commit to gcc42/resurrect.wezterm that referenced this pull request Jan 12, 2026
* docs: add critical code review and improvement plan

Review of unchanged files (fuzzy_loader, encryption, file_io, utils):
- Identified P0 security issues in shell command construction
- Found zero test coverage for encryption and fuzzy_loader
- Documented inconsistent error handling patterns
- Created prioritized improvement roadmap

* fix(workspace): restore workspace name after restore

When restoring a workspace, the tabs/panes/processes were restored but
the workspace name remained 'default'. Now properly restores the original
workspace name using set_active_workspace or rename_workspace depending
on the spawn mode.

Includes mux fake implementations and regression test.

Fixes: MLFlexer#118

* fix(file_io): wrap io.lines in pcall for graceful error handling

The load_json() function now catches errors when files don't exist
or can't be read, emits an error event, and returns nil instead of
throwing an exception.

* test: add utils and encryption test suites

utils_spec.lua (109 lines, 12 tests):
- Path normalization, string utilities, table utilities

encryption_spec.lua (47 lines, 2 tests):
- Command construction for age and gpg decrypt

* docs(CLAUDE): forbid force push without approval
micimize added a commit to micimize/resurrect.wezterm that referenced this pull request Mar 5, 2026
Addresses a crash loop caused by periodic auto-save capturing ghost SSH
domain tabs (stuck in "Connecting..." with empty cwd and zero dimensions)
into workspace JSON. On restore, these spawn broken tabs that cascade
into UI crashes.

Save-side safeguards:
- Add is_pane_healthy() to filter panes with nil/empty cwd, zero cell
  dimensions, or non-spawnable domains before tree construction
- Skip tabs with no healthy panes in window state serialization
- Skip windows with no valid tabs in workspace save
- Skip periodic save entirely when workspace is degraded
- Create .bak backup before overwriting state files

Restore-side safeguards:
- Add validate_pane_tree() to check cwd and domain validity, with
  recursive pruning of invalid subtrees
- Validate each tab before restoring, skip invalid ones
- Track restored_count independently from loop index for correct
  first-tab reuse logic
- Wrap per-window restore in pcall with state reset on failure
- Guard against empty tabs[1] access when spawning windows
- Fall back to .bak file when primary state file is invalid
- Nil guard on active_tab:activate() (latent upstream bug)

Upstream fixes incorporated:
- PR MLFlexer#127: nil pane guard in insert_panes() for symmetric layouts
- PR MLFlexer#123: use direct require("resurrect.state_manager") to fix
  circular module dependency in save actions
- PR MLFlexer#118: set active workspace after restore_workspace()

Wrap io.lines() in pcall in load_json() to handle missing files
gracefully instead of throwing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

doesn't open with correct workspace name

1 participant