Overview of Zustand Stores in TOKENICODE
mainTOKENICODE uses Zustand for state management, distributed across several specialized stores. Some stores are persisted (e.g., to localStorage or disk), while others are transient.
| Store | Purpose | Persisted |
|---|---|---|
chatStore | Messages, streaming, session meta/status, per-tab cache, permission state | No |
sessionStore | Session list, selection, drafts, stdin→tab routing, custom names, pin/archive | No |
settingsStore | Theme, colorTheme, locale, model, mode, layout, font, thinkingLevel, update state | Yes (localStorage) |
fileStore | File tree, preview, edit buffer, changed files, recent projects | No |
agentStore | Agent tree (multi-agent), phase tracking, per-tab cache | No |
commandStore | Unified commands (built-in + custom + skills), prefix mode | No |
skillStore | Skills CRUD, enable/disable, content editing | No |
providerStore | Multi-provider API config (base URL, key, model mappings) | Yes (providers.json on disk) |
setupStore | CLI install/login progress | No |
mcpStore | MCP servers from ~/.claude.json | No |
Tab-Switching Pattern: The chatStore and agentStore implement saveToCache(tabId) and restoreFromCache(tabId) to allow seamless switching between different chat sessions/tabs.