Skip to content

Commit b672c3b

Browse files
authored
Merge pull request #787 from web3dev1337/fix/worktree-visibility-persistence
fix: preserve worktree visibility state across workspace tab switches
2 parents 55c4316 + 6a9f563 commit b672c3b

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Fix: Worktree Visibility Persistence (Issue #786)
2+
3+
## User Request
4+
Fix GitHub issue #786: "Closed worktrees become visible again after switching workspaces"
5+
6+
When a user closes/hides worktrees in a workspace, switches to a different workspace, then switches back, the previously closed worktrees are restored to visible. The closed/hidden state should persist across workspace switches.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Plan
2+
3+
## Root Cause
4+
In `client/app.js`, the `workspace-changed` handler for existing tabs calls `handleInitialSessions(sessions)` AFTER `switchTab()` restores the tab's saved visibility state. `handleInitialSessions` checks `this.lastSessionsWorkspaceId` vs `this.currentWorkspace.id` to decide whether to preserve visibility. Since `lastSessionsWorkspaceId` still points to the previous workspace, it treats this as a workspace change and resets all terminals to visible.
5+
6+
## Fix
7+
Set `this.lastSessionsWorkspaceId = workspace.id` before calling `handleInitialSessions` in the existing-tab branch. This makes `handleInitialSessions` treat it as a same-workspace refresh, preserving the visibility state restored from the tab.
8+
9+
## Files Changed
10+
- `client/app.js` - Added 3 lines (comment + assignment) before `handleInitialSessions` call in existing-tab branch of `workspace-changed` handler
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Progress
2+
3+
- [x] Read CODEBASE_DOCUMENTATION.md
4+
- [x] Investigate bug in workspace-tab-manager.js and app.js
5+
- [x] Identify root cause in workspace-changed handler
6+
- [x] Implement fix in client/app.js
7+
- [x] Run syntax check
8+
- [x] Commit, push, and create PR

client/app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,11 @@ class ClaudeOrchestrator {
14441444
// Pre-fetch worktree-specific configs for all terminals
14451445
await this.prefetchWorktreeConfigs(workspace, sessions);
14461446

1447+
// CRITICAL: Set lastSessionsWorkspaceId BEFORE handleInitialSessions so that
1448+
// it treats this as a same-workspace refresh and preserves the worktree
1449+
// visibility state that was just restored from the tab (fix #786).
1450+
this.lastSessionsWorkspaceId = workspace.id;
1451+
14471452
this.handleInitialSessions(sessions);
14481453

14491454
// Update workspace switcher

0 commit comments

Comments
 (0)