Repository navigation
Closed
Description
Problem Statement
Tab state (open tabs, active tab, tab order) is lost when the application restarts. Users expect their tab configuration to persist across sessions, similar to how browsers remember open tabs.
Current State
What Exists:
- ✅ Tab state in memory (
navigation.tsstore) - ✅ Tab creation and management
What's Missing:
- ❌ Persistence layer for tab state
- ❌ Loading tab state on application startup
- ❌ Saving tab state on changes
Proposed Solution
Implement a persistence service that:
- Saves tab state to localStorage (or Tauri's store for desktop)
- Loads saved state on application mount
- Handles migration if tab structure changes
- Debounces saves to avoid excessive writes
Main Components Affected
New Files:
/packages/desktop-app/src/lib/services/tab-persistence-service.ts- Persistence logic
Modified Files:
/packages/desktop-app/src/lib/stores/navigation.ts- Add persistence hooks/packages/desktop-app/src/lib/components/layout/app-shell.svelte- Load state on mount
Implementation Approach
// tab-persistence-service.ts
export interface PersistedTabState {
version: 1;
tabs: Array<{
id: string;
title: string;
type: string;
content: any;
closeable: boolean;
}>;
activeTabId: string;
}
export class TabPersistenceService {
private static STORAGE_KEY = 'nodespace:tab-state';
static async save(state: TabState): Promise<void> {
const persisted: PersistedTabState = {
version: 1,
tabs: state.tabs,
activeTabId: state.activeTabId
};
// Use Tauri store for desktop, localStorage for web
if (window.__TAURI__) {
await window.__TAURI__.invoke('save_tab_state', { state: persisted });
} else {
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(persisted));
}
}
static async load(): Promise<PersistedTabState | null> {
// Implementation...
}
}Acceptance Criteria
- Tab state persists across application restarts
- Active tab is restored correctly
- Tab order is preserved
- Invalid/corrupted state is handled gracefully (fallback to default)
- Debounced saves prevent excessive writes (e.g., 500ms debounce)
- Migration strategy for future tab structure changes
Estimated Effort
3-4 hours
- Service implementation: 1.5 hours
- Integration with store: 1 hour
- Migration and error handling: 1 hour
- Testing: 30 minutes
Dependencies
- Requires: Implement Tab/Pane Management UI (Phases 4-8) #206 (EPIC)
- Should follow: Implement nodespace:// Link Navigation with Dynamic Tab Creation #297 (Link Navigation), Tab UI Controls: Hover-to-Show Close Button #298 (Tab Controls)
Priority
Medium - Nice-to-have UX improvement, not blocking core functionality
Activity
feat(tabs): Add tab state persistence to localStorage (Issue #299)
fix(tabs): Address all code review findings for tab persistence (Issue …
Tab State Persistence (localStorage/Tauri) (#379)
Tab State Persistence (localStorage/Tauri) (#379)
Tab State Persistence (localStorage/Tauri) (#379)
Tab State Persistence (localStorage/Tauri) (#379)