feat(claude-code): add model selection for the claude-code engine#434
Open
r-sayar wants to merge 2 commits into
Open
feat(claude-code): add model selection for the claude-code engine#434r-sayar wants to merge 2 commits into
r-sayar wants to merge 2 commits into
Conversation
libsignal and @electron/node-gyp were pinned to commit hashes that no longer exist on any branch, causing `yarn install` to fail for anyone without those exact SHAs in their local git cache. Replaced the resolved SHA pins with branch-head references so the lockfile resolves cleanly on a fresh clone. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Allows users to choose which Claude model the claude-code engine uses instead of always relying on the CLI default (claude-sonnet-4-6). Changes: - authStore: add `claudeCodeModel` field to the credentials blob with `loadClaudeCodeModel` / `saveClaudeCodeModel` helpers - apiKeyIpc: register `settings:claude-code:model:get/set` IPC handlers - preload/shell: expose `getModel` / `setModel` on the claudeCode API - globals.d.ts: add TypeScript types for the new IPC methods - runEngine: load the saved model for the claude-code engine path and populate SpawnContext.model - adapter: pass `--model <id>` to the claude CLI when a model is set (omitted when null so the CLI default is preserved) - ConnectionsPane: add a model <select> under the Anthropic card, visible when connected; persists immediately on change Available options: Haiku 4.5, Sonnet 4.5, Sonnet 4.6, Opus 4.5, Opus 4.7, and a "Default" option that omits the flag entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/src/main/settings/apiKeyIpc.ts">
<violation number="1" location="app/src/main/settings/apiKeyIpc.ts:582">
P2: `handleClaudeCodeModelSet` accepts renderer-provided `model` without runtime validation (no `assertString` or allowlist check), unlike every other IPC handler in this file that validates user input before persisting. This risks invalid persisted state and downstream CLI invocation with malformed `--model` values.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Fix all with cubic | Re-trigger cubic
Comment on lines
+582
to
+586
| async function handleClaudeCodeModelSet( | ||
| _e: Electron.IpcMainInvokeEvent, | ||
| model: string | null, | ||
| ): Promise<void> { | ||
| mainLogger.info('apiKeyIpc.claudeCode.model.set', { model }); |
There was a problem hiding this comment.
P2: handleClaudeCodeModelSet accepts renderer-provided model without runtime validation (no assertString or allowlist check), unlike every other IPC handler in this file that validates user input before persisting. This risks invalid persisted state and downstream CLI invocation with malformed --model values.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/settings/apiKeyIpc.ts, line 582:
<comment>`handleClaudeCodeModelSet` accepts renderer-provided `model` without runtime validation (no `assertString` or allowlist check), unlike every other IPC handler in this file that validates user input before persisting. This risks invalid persisted state and downstream CLI invocation with malformed `--model` values.</comment>
<file context>
@@ -570,6 +574,19 @@ async function handleClaudeCodeLogout(): Promise<{ opened: boolean; error?: stri
+ return { model };
+}
+
+async function handleClaudeCodeModelSet(
+ _e: Electron.IpcMainInvokeEvent,
+ model: string | null,
</file context>
Suggested change
| async function handleClaudeCodeModelSet( | |
| _e: Electron.IpcMainInvokeEvent, | |
| model: string | null, | |
| ): Promise<void> { | |
| mainLogger.info('apiKeyIpc.claudeCode.model.set', { model }); | |
| async function handleClaudeCodeModelSet( | |
| _e: Electron.IpcMainInvokeEvent, | |
| model: string | null, | |
| ): Promise<void> { | |
| const validated = model === null ? null : assertString(model, 'model', 160); | |
| mainLogger.info('apiKeyIpc.claudeCode.model.set', { model: validated }); | |
| await saveClaudeCodeModel(validated); | |
| } |
Collaborator
|
thanks! will take a look at this didnt add this yet bc I didn't get requests for it but clearly I should haha |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The claude-code engine currently passes no
--modelflag to theclaudeCLI, meaning every session uses whatever the CLI defaults to. This PR lets users pick a specific Claude model from the Settings panel.--modelflag entirely, preserving the CLI's current default (claude-sonnet-4-6).Changes
authStore.tsclaudeCodeModelfield to credentials blob +loadClaudeCodeModel/saveClaudeCodeModelapiKeyIpc.tssettings:claude-code:model:getandsettings:claude-code:model:setIPC handlerspreload/shell.tsgetModel/setModelon theclaudeCodeAPI bridgeglobals.d.tsrunEngine.tsclaude-codeengine path and populatesSpawnContext.modeladapter.ts--model <id>to the claude CLI when a model is set; omits it when nullConnectionsPane.tsx<select>under the Anthropic card, visible when connected; persists on changeTest plan
claude-sonnet-4-6)--modelflag🤖 Generated with Claude Code
Summary by cubic
Adds model selection to the
claude-codeengine so you can choose a Claude model in Settings; the engine passes--modelto theclaudeCLI when set and falls back to the CLI default otherwise. Also fixesyarn.lockto resolve install failures from stale git SHAs.New Features
claudewith--model <id>; "Default" omits the flag (CLI default isclaude-sonnet-4-6).Dependencies
yarn.lockfor@electron/node-gypandlibsignalwith branch heads to allow cleanyarn install.Written for commit 1e1c2bf. Summary will update on new commits. Review in cubic