refactor(desktop): migrate storage to tRPC, fix race condition

Merged
KI
1y ago
+688-492

Summary

  • Migrate tabs and theme storage from raw IPC handlers to tRPC
  • Fix race condition where electron-store (theme) and lowdb (tabs) competed for the same app-state.json file
  • Remove electron-store dependency entirely

Changes

  • Add tRPC uiState router with tabs.get/set and theme.get/set procedures
  • Create trpc-storage adapter for Zustand persist middleware
  • Update tabs and theme stores to use tRPC-based storage
  • Fix appState.update() bug (lowdb's JSONFilePreset doesn't have update method)
  • Add layout field to tab Zod schema to preserve MosaicNode layouts

Test plan

  • Verify tabs persist and restore correctly after app restart
  • Verify theme changes persist and restore correctly
  • Verify pane layouts (splits) are preserved
  • Verify no race conditions between tabs and theme saves

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced centralized UI state persistence for tabs and theme preferences.
    • Enhanced notification system with improved workspace context derivation.
  • Improvements

    • Refactored terminal session identification for better pane tracking and stability.
    • Upgraded app state persistence layer for improved reliability.
  • Chores

    • Migrated storage backend to a new internal persistence system.

✏️ Tip: You can customize this high-level summary in your review settings.