Add global favorite model for new chats#23
Conversation
…dotgg#1001) Co-authored-by: Julius Marminge <julius0216@outlook.com>
…dotgg#955) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
…d Linux) (pingdotgg#841) Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
…tgg#1006) Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com> Co-authored-by: codex <codex@users.noreply.github.com> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ingdotgg#988) Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
- ensure `chat.new` creates a fresh draft after a promoted draft thread - enforce terminal cap per split group (4) while allowing additional terminal groups - refine sidebar row selected/active styling via shared class-name logic and tests
- move chat-wide key handling into `_chat` route-level shortcut handler - extract reusable `useHandleNewThread` hook and `isTerminalFocused` helper - update browser WS fixture to support `terminalOpen` RPC shape
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… `useLocalStorage` helper (pingdotgg#662) Co-authored-by: Julius Marminge <julius0216@outlook.com>
… remover duplicação
# Conflicts: # apps/web/src/components/ChatView.tsx # apps/web/src/composer-logic.test.ts
- persist a single favorite provider/model in app settings - use favorite model as default for new local draft chats - add star toggle UI in model picker with toast feedback - cover favorite read/toggle behavior with app settings tests
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
apps/web/src/appSettings.ts
Outdated
| ): FavoriteModel | null { | ||
| const fav = settings.favoriteModel; | ||
| if (!fav || !fav.provider || !fav.model) return null; | ||
| const provider = fav.provider as ProviderKind; |
There was a problem hiding this comment.
Bug: Unsafe cast of fav.provider as ProviderKind can crash the app
getFavoriteModel casts fav.provider as ProviderKind (line 177) without validating the string is actually one of "codex" | "claudeCode" | "cursor". Since FavoriteModelSchema only validates provider as Schema.String, any arbitrary string stored in localStorage (via corruption, browser extensions, or manual editing) will pass schema validation.
When an invalid provider string reaches normalizeModelSlug, MODEL_SLUG_ALIASES_BY_PROVIDER[provider] returns undefined, and the subsequent aliases[trimmed] property access throws a TypeError, crashing the entire ChatView component tree during render.
Suggested fix: Either add a guard before the cast:
const VALID_PROVIDERS = new Set(["codex", "claudeCode", "cursor"]);
if (!VALID_PROVIDERS.has(fav.provider)) return null;Or change FavoriteModelSchema to use Schema.Literals(["codex", "claudeCode", "cursor"]) instead of Schema.String for the provider field.
Use Schema.Literals instead of Schema.String for the provider field in FavoriteModelSchema, ensuring invalid provider values from localStorage are rejected at the schema level. Add runtime guard in getFavoriteModel as defense-in-depth. Remove unsafe `as ProviderKind` casts in appSettings.ts and ChatView.tsx. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Files changed
apps/web/src/appSettings.ts—FavoriteModelschema +getFavoriteModel()/toggleFavoriteModel()helpersapps/web/src/appSettings.test.ts— 10 new unit testsapps/web/src/components/chat/ProviderModelPicker.tsx— Star icon UI with stopPropagation handlingapps/web/src/components/ChatView.tsx— Global favorite influences provider + model resolution for new threadsTest plan
bun run typecheck)bun run test)bun run lint)🤖 Generated with Claude Code