Fix tab persistence in Claude IDE - persist closed tabs to localStorage
Implement localStorage persistence for closed session and project tabs. When users close tabs, they now remain closed after page refresh. Changes: - session-tabs.js: Add closedSessions tracking with localStorage - project-manager.js: Add closedProjects tracking with localStorage - Filter out closed tabs on load - Persist state whenever tabs are closed Fixes issue where closed tabs would reappear on page refresh. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,8 @@ class SessionTabs {
|
||||
this.sessions = [];
|
||||
this.activeSessionId = null;
|
||||
this.initialized = false;
|
||||
this.closedSessions = new Set(); // Track closed session IDs
|
||||
this.STORAGE_KEY = 'claude_ide_closed_sessions';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,16 +32,48 @@ class SessionTabs {
|
||||
if (this.initialized) return;
|
||||
|
||||
console.log('[SessionTabs] Initializing...');
|
||||
this.loadClosedSessions();
|
||||
this.render();
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load closed sessions from localStorage
|
||||
*/
|
||||
loadClosedSessions() {
|
||||
try {
|
||||
const stored = localStorage.getItem(this.STORAGE_KEY);
|
||||
if (stored) {
|
||||
const closedIds = JSON.parse(stored);
|
||||
this.closedSessions = new Set(closedIds);
|
||||
console.log('[SessionTabs] Loaded', this.closedSessions.size, 'closed sessions from storage');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[SessionTabs] Error loading closed sessions:', error);
|
||||
this.closedSessions = new Set();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save closed sessions to localStorage
|
||||
*/
|
||||
saveClosedSessions() {
|
||||
try {
|
||||
const closedIds = Array.from(this.closedSessions);
|
||||
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(closedIds));
|
||||
console.log('[SessionTabs] Saved', closedIds.length, 'closed sessions to storage');
|
||||
} catch (error) {
|
||||
console.error('[SessionTabs] Error saving closed sessions:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sessions for current project
|
||||
*/
|
||||
setSessions(sessions) {
|
||||
this.sessions = sessions || [];
|
||||
console.log('[SessionTabs] Set', this.sessions.length, 'sessions');
|
||||
// Filter out closed sessions
|
||||
this.sessions = (sessions || []).filter(s => !this.closedSessions.has(s.id));
|
||||
console.log('[SessionTabs] Set', this.sessions.length, 'sessions (filtered out', (sessions || []).length - this.sessions.length, 'closed)');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,6 +225,10 @@ class SessionTabs {
|
||||
|
||||
console.log('[SessionTabs] Closing session:', sessionId);
|
||||
|
||||
// Add to closed sessions set and persist
|
||||
this.closedSessions.add(sessionId);
|
||||
this.saveClosedSessions();
|
||||
|
||||
// Note: This just removes the tab from view
|
||||
// The session still exists on the server
|
||||
this.sessions = this.sessions.filter(s => s.id !== sessionId);
|
||||
|
||||
Reference in New Issue
Block a user