Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export function TaskInput({
defaultInitialTaskMode,
lastUsedInitialTaskMode,
setLastUsedReasoningEffort,
setLastUsedModel,
} = useSettingsStore();

const editorRef = useRef<EditorHandle>(null);
Expand Down Expand Up @@ -493,9 +494,10 @@ export function TaskInput({
(value: string) => {
if (modelOption) {
setConfigOption(modelOption.id, value);
setLastUsedModel(value);
}
},
[modelOption, setConfigOption],
[modelOption, setConfigOption, setLastUsedModel],
);

const handleThoughtChange = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export function usePreviewConfig(
lastUsedInitialTaskMode,
defaultReasoningEffort,
lastUsedReasoningEffort,
lastUsedModel,
} = useSettingsStore.getState();

// Use the mode option's existing currentValue (set by the server
Expand Down Expand Up @@ -186,7 +187,20 @@ export function usePreviewConfig(
return opt;
});

setConfigOptions(withEffort);
const withModel = withEffort.map((opt) => {
if (opt.category !== "model" || opt.type !== "select") return opt;
if (!lastUsedModel) return opt;
const validValues = flattenValues(
opt.options as Array<{
value?: string;
options?: Array<{ value: string }>;
}>,
);
if (!validValues.includes(lastUsedModel)) return opt;
return { ...opt, currentValue: lastUsedModel } as SessionConfigOption;
});
Comment on lines +190 to +201
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Restored model doesn't recalculate effort options

withModel updates the model's currentValue but leaves the effort option's .options array and currentValue as the server returned them — calibrated to the server's default model, not the restored one. Because getReasoningEffortOptions returns model-specific sets (e.g. null for claude-haiku-4-5, 3 entries for claude-sonnet-4-6, 5 for claude-opus-4-6), a user who last picked claude-haiku-4-5 will see the effort selector the server injected for the default model, and a user who last picked claude-sonnet-4-6 when the server defaulted to an Opus model will see xhigh/max effort choices that Sonnet doesn't support. The interactive path in setConfigOption already handles this correctly by calling getReasoningEffortOptions(adapter, value) — the same call needs to happen here after the model is resolved, updating options and clamping currentValue (or removing the effort option entirely when the restored model returns null).

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/task-detail/hooks/usePreviewConfig.ts
Line: 190-201

Comment:
**Restored model doesn't recalculate effort options**

`withModel` updates the model's `currentValue` but leaves the effort option's `.options` array and `currentValue` as the server returned them — calibrated to the server's default model, not the restored one. Because `getReasoningEffortOptions` returns model-specific sets (e.g. `null` for `claude-haiku-4-5`, 3 entries for `claude-sonnet-4-6`, 5 for `claude-opus-4-6`), a user who last picked `claude-haiku-4-5` will see the effort selector the server injected for the default model, and a user who last picked `claude-sonnet-4-6` when the server defaulted to an Opus model will see `xhigh`/`max` effort choices that Sonnet doesn't support. The interactive path in `setConfigOption` already handles this correctly by calling `getReasoningEffortOptions(adapter, value)` — the same call needs to happen here after the model is resolved, updating `options` and clamping `currentValue` (or removing the effort option entirely when the restored model returns `null`).

How can I resolve this? If you propose a fix, please make it concise.


setConfigOptions(withModel);
setIsLoading(false);
})
.catch((error) => {
Expand Down