Repository navigation
Tab State Persistence (localStorage/Tauri) - #379
Merged
Merged
Conversation
Implements automatic saving and loading of tab state across application restarts. **What Changed:** - Created TabPersistenceService with debounced localStorage saves - Integrated persistence hooks into navigation store - Added state restoration on app-shell mount - Includes migration system for future version changes **Features:** - ✅ Debounced saves (500ms) prevent excessive writes - ✅ Version-based state structure for future migrations - ✅ Graceful fallback to default state on corruption - ✅ Tab order, active tab, and pane configuration all persisted - ✅ Automatically loads state on application startup **Files Modified:** - packages/desktop-app/src/lib/services/tab-persistence-service.ts (new) - packages/desktop-app/src/lib/stores/navigation.ts - packages/desktop-app/src/lib/components/layout/app-shell.svelte **Testing:** Manual testing verified that tab state persists across app restarts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…#299) **Critical Fixes:** 1. **Race Condition Fix** (Critical Issue #1) - Added `isInitialized` flag to prevent subscription from overwriting loaded state - Subscription now only saves after `loadPersistedState()` completes - Ensures persisted state is never overwritten on app startup 2. **Deep Validation** (Critical Issue #2) - Enhanced `isValidState()` with comprehensive validation - Validates tab structure: id, title, type, closeable, paneId - Validates pane structure: id, width, tabIds array - Validates activeTabIds map contains only string values - Prevents crashes from corrupted localStorage data **Important Improvements:** 3. **Comprehensive Test Coverage** (Issue #3) - Created tab-persistence-service.test.ts with 19 tests - Tests: save/load, validation, debouncing, edge cases - Covers corrupted JSON, quota exceeded, special characters - 100% coverage of critical persistence logic 4. **Timer Cleanup** (Issue #4) - Added TabPersistenceService.flush() call in app-shell unmount - Prevents memory leaks during hot-reload and module cleanup - Ensures pending saves complete before unmount 5. **Console Logging Strategy** (Issue #5) - Added LOG_PREFIX constant for consistent logging - Development-only logs via `DEBUG` flag (import.meta.env.DEV) - Errors and warnings always logged in production - Improved debugging experience without performance impact **Code Quality Improvements:** 6. **Type Flexibility** (Nit) - Changed `version: 1` literal to `version: number` - Allows future migrations without type changes 7. **Documentation** (Nit) - Added JSDoc clarification for `loadPersistedState()` return value - Documented `clear()` method as useful for testing/debugging - Improved return value description for better IDE hints **Test Results:** - ✅ All 19 new persistence tests passing - ✅ 1454/1470 total tests passing (pre-existing failures unrelated) - ✅ Quality checks passing (no lint/format issues) **Files Modified:** - packages/desktop-app/src/lib/stores/navigation.ts - packages/desktop-app/src/lib/services/tab-persistence-service.ts - packages/desktop-app/src/lib/components/layout/app-shell.svelte - packages/desktop-app/src/tests/services/tab-persistence-service.test.ts (new) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 4, 2026
* feat(tabs): Add tab state persistence to localStorage (Issue #299) Implements automatic saving and loading of tab state across application restarts. **What Changed:** - Created TabPersistenceService with debounced localStorage saves - Integrated persistence hooks into navigation store - Added state restoration on app-shell mount - Includes migration system for future version changes **Features:** - ✅ Debounced saves (500ms) prevent excessive writes - ✅ Version-based state structure for future migrations - ✅ Graceful fallback to default state on corruption - ✅ Tab order, active tab, and pane configuration all persisted - ✅ Automatically loads state on application startup **Files Modified:** - packages/desktop-app/src/lib/services/tab-persistence-service.ts (new) - packages/desktop-app/src/lib/stores/navigation.ts - packages/desktop-app/src/lib/components/layout/app-shell.svelte **Testing:** Manual testing verified that tab state persists across app restarts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix(tabs): Address all code review findings for tab persistence (Issue #299) **Critical Fixes:** 1. **Race Condition Fix** (Critical Issue #1) - Added `isInitialized` flag to prevent subscription from overwriting loaded state - Subscription now only saves after `loadPersistedState()` completes - Ensures persisted state is never overwritten on app startup 2. **Deep Validation** (Critical Issue #2) - Enhanced `isValidState()` with comprehensive validation - Validates tab structure: id, title, type, closeable, paneId - Validates pane structure: id, width, tabIds array - Validates activeTabIds map contains only string values - Prevents crashes from corrupted localStorage data **Important Improvements:** 3. **Comprehensive Test Coverage** (Issue #3) - Created tab-persistence-service.test.ts with 19 tests - Tests: save/load, validation, debouncing, edge cases - Covers corrupted JSON, quota exceeded, special characters - 100% coverage of critical persistence logic 4. **Timer Cleanup** (Issue #4) - Added TabPersistenceService.flush() call in app-shell unmount - Prevents memory leaks during hot-reload and module cleanup - Ensures pending saves complete before unmount 5. **Console Logging Strategy** (Issue #5) - Added LOG_PREFIX constant for consistent logging - Development-only logs via `DEBUG` flag (import.meta.env.DEV) - Errors and warnings always logged in production - Improved debugging experience without performance impact **Code Quality Improvements:** 6. **Type Flexibility** (Nit) - Changed `version: 1` literal to `version: number` - Allows future migrations without type changes 7. **Documentation** (Nit) - Added JSDoc clarification for `loadPersistedState()` return value - Documented `clear()` method as useful for testing/debugging - Improved return value description for better IDE hints **Test Results:** - ✅ All 19 new persistence tests passing - ✅ 1454/1470 total tests passing (pre-existing failures unrelated) - ✅ Quality checks passing (no lint/format issues) **Files Modified:** - packages/desktop-app/src/lib/stores/navigation.ts - packages/desktop-app/src/lib/services/tab-persistence-service.ts - packages/desktop-app/src/lib/components/layout/app-shell.svelte - packages/desktop-app/src/tests/services/tab-persistence-service.test.ts (new) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 5, 2026
* feat(tabs): Add tab state persistence to localStorage (Issue #299) Implements automatic saving and loading of tab state across application restarts. **What Changed:** - Created TabPersistenceService with debounced localStorage saves - Integrated persistence hooks into navigation store - Added state restoration on app-shell mount - Includes migration system for future version changes **Features:** - ✅ Debounced saves (500ms) prevent excessive writes - ✅ Version-based state structure for future migrations - ✅ Graceful fallback to default state on corruption - ✅ Tab order, active tab, and pane configuration all persisted - ✅ Automatically loads state on application startup **Files Modified:** - packages/desktop-app/src/lib/services/tab-persistence-service.ts (new) - packages/desktop-app/src/lib/stores/navigation.ts - packages/desktop-app/src/lib/components/layout/app-shell.svelte **Testing:** Manual testing verified that tab state persists across app restarts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix(tabs): Address all code review findings for tab persistence (Issue #299) **Critical Fixes:** 1. **Race Condition Fix** (Critical Issue #1) - Added `isInitialized` flag to prevent subscription from overwriting loaded state - Subscription now only saves after `loadPersistedState()` completes - Ensures persisted state is never overwritten on app startup 2. **Deep Validation** (Critical Issue #2) - Enhanced `isValidState()` with comprehensive validation - Validates tab structure: id, title, type, closeable, paneId - Validates pane structure: id, width, tabIds array - Validates activeTabIds map contains only string values - Prevents crashes from corrupted localStorage data **Important Improvements:** 3. **Comprehensive Test Coverage** (Issue #3) - Created tab-persistence-service.test.ts with 19 tests - Tests: save/load, validation, debouncing, edge cases - Covers corrupted JSON, quota exceeded, special characters - 100% coverage of critical persistence logic 4. **Timer Cleanup** (Issue #4) - Added TabPersistenceService.flush() call in app-shell unmount - Prevents memory leaks during hot-reload and module cleanup - Ensures pending saves complete before unmount 5. **Console Logging Strategy** (Issue #5) - Added LOG_PREFIX constant for consistent logging - Development-only logs via `DEBUG` flag (import.meta.env.DEV) - Errors and warnings always logged in production - Improved debugging experience without performance impact **Code Quality Improvements:** 6. **Type Flexibility** (Nit) - Changed `version: 1` literal to `version: number` - Allows future migrations without type changes 7. **Documentation** (Nit) - Added JSDoc clarification for `loadPersistedState()` return value - Documented `clear()` method as useful for testing/debugging - Improved return value description for better IDE hints **Test Results:** - ✅ All 19 new persistence tests passing - ✅ 1454/1470 total tests passing (pre-existing failures unrelated) - ✅ Quality checks passing (no lint/format issues) **Files Modified:** - packages/desktop-app/src/lib/stores/navigation.ts - packages/desktop-app/src/lib/services/tab-persistence-service.ts - packages/desktop-app/src/lib/components/layout/app-shell.svelte - packages/desktop-app/src/tests/services/tab-persistence-service.test.ts (new) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 26, 2026
* feat(tabs): Add tab state persistence to localStorage (Issue #299) Implements automatic saving and loading of tab state across application restarts. **What Changed:** - Created TabPersistenceService with debounced localStorage saves - Integrated persistence hooks into navigation store - Added state restoration on app-shell mount - Includes migration system for future version changes **Features:** - ✅ Debounced saves (500ms) prevent excessive writes - ✅ Version-based state structure for future migrations - ✅ Graceful fallback to default state on corruption - ✅ Tab order, active tab, and pane configuration all persisted - ✅ Automatically loads state on application startup **Files Modified:** - packages/desktop-app/src/lib/services/tab-persistence-service.ts (new) - packages/desktop-app/src/lib/stores/navigation.ts - packages/desktop-app/src/lib/components/layout/app-shell.svelte **Testing:** Manual testing verified that tab state persists across app restarts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix(tabs): Address all code review findings for tab persistence (Issue #299) **Critical Fixes:** 1. **Race Condition Fix** (Critical Issue #1) - Added `isInitialized` flag to prevent subscription from overwriting loaded state - Subscription now only saves after `loadPersistedState()` completes - Ensures persisted state is never overwritten on app startup 2. **Deep Validation** (Critical Issue #2) - Enhanced `isValidState()` with comprehensive validation - Validates tab structure: id, title, type, closeable, paneId - Validates pane structure: id, width, tabIds array - Validates activeTabIds map contains only string values - Prevents crashes from corrupted localStorage data **Important Improvements:** 3. **Comprehensive Test Coverage** (Issue #3) - Created tab-persistence-service.test.ts with 19 tests - Tests: save/load, validation, debouncing, edge cases - Covers corrupted JSON, quota exceeded, special characters - 100% coverage of critical persistence logic 4. **Timer Cleanup** (Issue #4) - Added TabPersistenceService.flush() call in app-shell unmount - Prevents memory leaks during hot-reload and module cleanup - Ensures pending saves complete before unmount 5. **Console Logging Strategy** (Issue #5) - Added LOG_PREFIX constant for consistent logging - Development-only logs via `DEBUG` flag (import.meta.env.DEV) - Errors and warnings always logged in production - Improved debugging experience without performance impact **Code Quality Improvements:** 6. **Type Flexibility** (Nit) - Changed `version: 1` literal to `version: number` - Allows future migrations without type changes 7. **Documentation** (Nit) - Added JSDoc clarification for `loadPersistedState()` return value - Documented `clear()` method as useful for testing/debugging - Improved return value description for better IDE hints **Test Results:** - ✅ All 19 new persistence tests passing - ✅ 1454/1470 total tests passing (pre-existing failures unrelated) - ✅ Quality checks passing (no lint/format issues) **Files Modified:** - packages/desktop-app/src/lib/stores/navigation.ts - packages/desktop-app/src/lib/services/tab-persistence-service.ts - packages/desktop-app/src/lib/components/layout/app-shell.svelte - packages/desktop-app/src/tests/services/tab-persistence-service.test.ts (new) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #299