Skip to content

Conversation

@craigvandotcom
Copy link

Summary

Persist the active tab selection (sessions/inbox/settings) to the server via the existing KV API, enabling:

  • Tab state survives browser refresh
  • Tab state syncs across devices
  • Automatic conflict resolution with version control

Changes

New files

  • sources/hooks/useTabState.ts - Hook for persistent tab state management
    • Loads initial tab state from server on mount
    • Saves tab changes to server with optimistic updates
    • Handles version conflicts gracefully
    • Falls back to 'sessions' if no saved state

Modified files

  • sources/components/MainView.tsx - Use new hook instead of useState
  • sources/components/TabBar.tsx - Re-export TabType from hook

Implementation Details

Uses the existing UserKVStore API (/v1/kv) with:

  • Key: ui:active-tab
  • Value: Tab name string (sessions, inbox, settings)
  • Version-based optimistic concurrency control

Test plan

  • Open app, select "inbox" tab
  • Refresh browser → should restore "inbox" tab
  • Open app on another device → should show same tab
  • Switch tabs rapidly → should handle without errors

Breaking changes

None - this is additive functionality.


🤖 Generated with Claude Code

Persist active tab selection to server via KV API, enabling:
- Tab state survives browser refresh
- Tab state syncs across devices
- Automatic conflict resolution with version control

New files:
- sources/hooks/useTabState.ts - Hook for persistent tab state

Modified files:
- sources/components/MainView.tsx - Use new hook instead of useState
- sources/components/TabBar.tsx - Re-export TabType from hook

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant