How changexbc/workbuddy-switch works
WorkBuddy Switch is a desktop and local-web account manager for WorkBuddy and CodeBuddy clients. The main workflow is to add or import accounts, inspect account/credit status, then switch a selected client’s credentials, optionally copying or synchronizing sessions. Separate workflows provide usage statistics, automatic CLI account rotation, and updates; the desktop app also hosts the Agent Companion session rail. The README documents these capabilities, while sampled source confirms the frontend/API boundary, background rotation, session-copy behavior, and desktop update service; unsampled subsystem wiring is shown only where documented.
Main entry points: lib.rs Core modules · api.ts Frontend API · App.tsx App shell · switch.rs Client switching
Components 26
User interface
- App shell
src/App.tsx - Account management
src/pages/AccountsPage.tsx - Credit statistics
src/pages/CreditStatsPage.tsx - Token statistics
src/pages/TokenStatsPage.tsx - Settings
src/pages/SettingsPage.tsx
Application runtime
- Frontend API
src/lib/api.ts - Tauri commands
src-tauri/src/commands.rs - Local web server
crates/wb-switch-server/src/api.rs - Core modules
crates/wb-switch-core/src/lib.rs
Accounts and clients
- Account and auth
crates/wb-switch-core/src/modules/account.rs - OAuth login
crates/wb-switch-core/src/modules/oauth.rs - Import and export
crates/wb-switch-core/src/modules/export_import.rs - Client switching
crates/wb-switch-core/src/modules/switch.rs - Session copy
crates/wb-switch-core/src/modules/session.rs - Session linking
crates/wb-switch-core/src/modules/session_link.rs - Client integrations
crates/wb-switch-core/src/modules
Usage and automation
- Credit expiry
crates/wb-switch-core/src/modules/credits.rs - Credit usage stats
crates/wb-switch-core/src/modules/credit_usage.rs - Token statistics
crates/wb-switch-core/src/modules/token_stats.rs - Automatic rotation
crates/wb-switch-core/src/modules/rotate.rs
Desktop services
- Agent Companion
src-tauri/src/companion.rs - Tray controls
src-tauri/src/tray.rs - Update service
src-tauri/src/update_service.rs
Other components
- User
- GitHub Releases
- Supported client apps
Connections 34
- User → App shell: uses
- App shell → Account management: routes to
- App shell → Credit statistics: routes to
- App shell → Token statistics: routes to
- App shell → Settings: routes to
- Account management → Frontend API: requests
- Credit statistics → Frontend API: requests
- Token statistics → Frontend API: requests
- Settings → Frontend API: requests
- Frontend API → Tauri commands: invokes
- Frontend API → Local web server: requests
- Tauri commands → Core modules: dispatches
- Local web server → Core modules: dispatches
- Core modules → OAuth login: provides login
- Core modules → Import and export: provides backup
- Core modules → Account and auth: reads/writes
- Core modules → Client switching: dispatches switch
- Client switching → Account and auth: reads credentials
- Client switching → Client integrations: updates clients
- Client integrations → Supported client apps: writes credentials
- Client switching → Session copy: copies sessions
- Session copy → Session linking: registers links
- Session linking → Account and auth: stores metadata
- Core modules → Credit expiry: queries expiry
- Core modules → Credit usage stats: loads usage
- Core modules → Token statistics: loads statistics
- Core modules → Automatic rotation: runs rotation
- Automatic rotation → Account and auth: selects account
- Automatic rotation → Client integrations: sets CLI default
- Tauri commands → Agent Companion: controls companion
- Tray controls → Agent Companion: toggles visibility
- Settings → Update service: requests update
- Update service → GitHub Releases: checks releases
- Update service → Tray controls: refreshes menu