-
Notifications
You must be signed in to change notification settings - Fork 67
feat(frontend): persist model selection by mode (chat/code) #784
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
base: main
Are you sure you want to change the base?
Conversation
- Add mode-specific model persistence in localStorage - Chat and code modes now remember their own model selections independently - When switching teams, try to restore saved model preference if compatible - If saved model is not compatible with new team's protocol, clear selection - Add saveLastModelByMode and getLastModelByMode functions in userPreferences - Pass taskType prop to ModelSelector for mode-aware persistence
📝 WalkthroughWalkthroughThe PR implements per-mode model selection persistence, allowing chat and code task types to maintain separate last-selected model preferences. It adds storage utilities, introduces a taskType prop propagated through components, and updates ModelSelector's initialization and restoration logic to respect mode-specific preferences and protocol compatibility. Changes
Sequence Diagram(s)sequenceDiagram
participant Component as React Component<br/>(ChatInputControls/<br/>TaskShareHandler)
participant ModelSelector
participant StorageUtil as userPreferences.ts<br/>(getLastModelByMode)
participant LocalStorage as localStorage
Component->>ModelSelector: Mount with taskType prop<br/>('chat' | 'code')
rect rgb(200, 220, 255)
Note over ModelSelector,LocalStorage: On Mount / Team Change
ModelSelector->>StorageUtil: getLastModelByMode(taskType)
StorageUtil->>LocalStorage: Read saved model<br/>for specific mode
LocalStorage-->>StorageUtil: Return ModelPreference<br/>or null
StorageUtil-->>ModelSelector: ModelPreference with<br/>modelId & modelType
end
rect rgb(220, 255, 220)
Note over ModelSelector: Compatibility Check
ModelSelector->>ModelSelector: Validate protocol<br/>compatibility with<br/>current team/config
end
alt Compatible Model Found
ModelSelector->>ModelSelector: Restore saved model
else No Compatible Model
ModelSelector->>ModelSelector: Clear selection or<br/>set default
end
rect rgb(255, 240, 200)
Note over Component,LocalStorage: On Model Selection
Component->>ModelSelector: User selects model
ModelSelector->>StorageUtil: saveLastModelByMode<br/>(modelId, taskType, modelType)
StorageUtil->>LocalStorage: Write mode-specific<br/>model data
LocalStorage-->>StorageUtil: ✓ Stored
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
🧰 Additional context used📓 Path-based instructions (5)**/*.{py,ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
frontend/src/**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
frontend/src/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
frontend/**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
frontend/src/**/*.{tsx,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (2)📚 Learning: 2025-12-29T10:42:55.732ZApplied to files:
📚 Learning: 2025-12-18T02:09:09.776ZApplied to files:
🧬 Code graph analysis (1)frontend/src/features/tasks/components/selector/ModelSelector.tsx (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
🔇 Additional comments (13)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Changes
New Functions in
userPreferences.tssaveLastModelByMode(modelId, mode, modelType)- Save model preference for specific modegetLastModelByMode(mode)- Get saved model preference for specific modeclearModelPreferenceByMode(mode)- Clear model preference for specific modewegent_last_model_id_chat,wegent_last_model_type_chat,wegent_last_model_id_code,wegent_last_model_type_codeModelSelector Modifications
taskTypeprop to support mode-aware persistenceComponent Updates
ChatInputControls.tsx- AddedtaskTypeprop and passed to ModelSelectorChatInputCard.tsx- PasstaskTypeto ChatInputControlsTaskShareHandler.tsx- AddedtaskTypebased onisCodeTaskCreateGroupChatDialog.tsx- AddedtaskType="chat"for group chat creationTest Plan
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.