Feature: Implement Seamless Account Switching #111
Labels
No labels
Epic 5
MCP
P1
PR-0
PR-1
api
api-layer
architecture
area:backend
area:frontend
arrow
authentication
backend
bug
chat
client
clipboard
common-module
compose
cross-cutting
cross-cutting-requirement
data-layer
data-models
database
desktop-client
documentation
duplicate
enhancement
epic
epic-1
epic-2
epic-3
epic-4
epic-5
epic-6
epic-7
epic-llm-config
error-handling
feature
frontend
good first issue
help wanted
implementation
infrastructure
installer
invalid
kotlin
ktor
llm
medium-priority
message
multiplatform
needs-review
needs-triage
packaging
performance
phase-1
phase-2
phase-3
phase-4
phase-5
phase3
phase:3
priority: high
question
refactor
refactoring
resource-sharing
security
server
server-module
services
session
session-management
settings
setup
shutdown
state
storage
streaming
sub-issue
tests
tooling
type:task
ui
ui/ux
user-accounts
user-management
ux
viewmodel
websocket
windows
windows-integration
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Torvian.eu/chatbot#111
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Feature: Implement Seamless Account Switching
Issue Type: Feature Request
Priority: High
Labels:
feature,authentication,storage,ui/ux,refactoringExecutive Summary
This issue outlines the work required to implement seamless account switching functionality, allowing users to switch between multiple accounts without logging out. This feature necessitates significant architectural changes across the storage layer, authentication system, and UI components.
User Story Reference
NF.S20 - Switch Between User Accounts
Acceptance Criteria
Current Architecture Highlights
The current system is designed for a single active user session. This means:
dek.json,tokens.enc) without support for multiple concurrent user sessions.StateFlow<AuthState>.Implementation Plan
The implementation will be broken down into the following phases:
Phase 1: Foundation (Storage Layer)
app/src/commonMain/kotlin/eu/torvian/chatbot/app/service/auth/TokenStorage.kt,app/src/commonMain/kotlin/eu/torvian/chatbot/app/service/auth/FileSystemTokenStorage.ktTokenStorageinterface and refactorFileSystemTokenStorageto support multiple accounts, including a new directory structure ({baseUserDataStoragePath}/accounts/{userId}/), anaccount_index.jsonfile, and migration logic for existing users.Phase 2: Repository Layer
app/src/commonMain/kotlin/eu/torvian/chatbot/app/repository/AuthRepository.kt,app/src/commonMain/kotlin/eu/torvian/chatbot/app/repository/impl/DefaultAuthRepository.ktAuthRepositoryfor getting available accounts and switching between them. UpdateDefaultAuthRepositoryto implement this logic, including updating the_authStateand modifying logout behavior.Phase 3: ViewModel Layer
app/src/commonMain/kotlin/eu/torvian/chatbot/app/viewmodel/auth/AuthViewModel.ktAuthViewModelto manage and expose available accounts, and provide methods for switching and removing accounts. Load available accounts on initialization.Phase 4: UI Components
app/src/commonMain/kotlin/eu/torvian/chatbot/app/compose/MainApplicationFlow.kt, newAccountSwitcherDialog.ktUserMenuinMainApplicationFlowto include a "Switch Account" option. Create a newAccountSwitcherDialogcomponent to display and manage available accounts. Integrate the dialog into the main application flow.Phase 5: Data Isolation
AccountSwitchedEventto theEventBusand updating relevant ViewModels (e.g.,SessionListViewModel,ChatViewModel) to clear cached data and reload information when an account switch occurs.Phase 6: Testing & Polish
Risks and Challenges
Recommended Testing Strategy
FileSystemTokenStorage(multi-account storage, migration, index management) andDefaultAuthRepository(account management, switching, logout).Additional Recommendations
Total Estimated Effort
17-24 days (3-4 weeks)