-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(terminal): migrate from zustand for console terminal logs to indexedDb, incr limit from 5mb to ~GBs #2812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…exedDb, incr limit from 5mb to ~GBs
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR migrates console terminal logs from Zustand's default localStorage storage to IndexedDB using Key Changes:
Implementation Quality:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App as Application Load
participant Storage as storage.ts
participant IDB as IndexedDB
participant LS as localStorage
participant Store as Zustand Store
participant Component as Terminal/Chat Component
Note over App,Component: Initial Load & Migration
App->>Storage: Module loads
Storage->>Storage: Start migrateFromLocalStorage()
Storage->>IDB: Check MIGRATION_KEY
alt Not migrated yet
Storage->>LS: Get terminal-console-store
LS-->>Storage: Return old data
Storage->>IDB: Write terminal-console-store
Storage->>LS: Remove terminal-console-store
Storage->>IDB: Write MIGRATION_KEY flag
end
Storage->>Storage: Clear migrationPromise
Note over Store,Component: Store Hydration
App->>Store: Initialize useTerminalConsoleStore
Store->>Storage: getItem from storage
Storage->>Storage: Wait for migrationPromise
Storage->>IDB: Read persisted data
IDB-->>Storage: Return data
Storage-->>Store: Return persisted state
Store->>Store: Rehydrate entries and isOpen
Store->>Store: Trigger onFinishHydration callback
Store->>Store: Update hasHydrated flag
Note over Component: Component Render
Component->>Store: Subscribe to hasHydrated flag
Component->>Store: Subscribe to entries
alt Not hydrated
Component->>Component: Render with empty entries
else Hydrated
Component->>Component: Render with entriesFromStore
end
Note over Store,IDB: Adding New Console Entry
App->>Store: addConsole new entry
Store->>Store: Process and trim entries
Store->>Storage: setItem auto-persist
Storage->>IDB: Write updated data
IDB-->>Storage: Success
Component->>Component: Re-render with new entry
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 files reviewed, 3 comments
Summary
Type of Change
Testing
Tested manually
Checklist