studio: reflect pre-selected Search/Code tools when no model is loaded

The Search and Code pills only lit up when the tool was usable right now
(a model loaded and capable), so a tool turned on from the + menu showed
as off in the pill while the menu showed it on. toolsEnabled is persisted
and takes effect once a capable model loads, so the pill should reflect it.
The pills now disable only when a loaded model lacks the capability, and
otherwise reflect the selected state. Applied to the main and compare
composers.
This commit is contained in:
Unsloth 2026-05-29 03:17:39 -07:00
commit e56d69f528
2 changed files with 13 additions and 8 deletions

View file

@ -1137,7 +1137,9 @@ const WebSearchToggle: FC = () => {
? externalProviders.find((p) => p.id === externalSelection.providerId)
: undefined;
const isKimiExternal = selectedExternalProvider?.providerType === "kimi";
const disabled = !modelLoaded || !(supportsTools || supportsBuiltinWebSearch);
// Disable only when a loaded model lacks the capability; with no model the
// tool can still be pre-selected and reflected, matching the + menu.
const disabled = modelLoaded && !(supportsTools || supportsBuiltinWebSearch);
return (
<button
@ -1180,8 +1182,9 @@ const CodeToolsToggle: FC = () => {
);
const codeToolsEnabled = useChatRuntimeStore((s) => s.codeToolsEnabled);
const setCodeToolsEnabled = useChatRuntimeStore((s) => s.setCodeToolsEnabled);
const disabled =
!modelLoaded || !(supportsTools || supportsBuiltinCodeExecution);
// Disable only when a loaded model lacks the capability; with no model the
// tool can still be pre-selected and reflected, matching the + menu.
const disabled = modelLoaded && !(supportsTools || supportsBuiltinCodeExecution);
return (
<button

View file

@ -513,16 +513,18 @@ export function SharedComposer({
// and gate strictly on the provider builtin support.
const isGeminiImageTier =
isExternalGemini && supportsBuiltinImageGeneration;
// Disable only when a loaded model lacks the capability; with no model the
// tool can still be pre-selected and reflected, matching the + menu.
const searchDisabled =
!modelLoaded ||
modelLoaded &&
(isGeminiImageTier
? !supportsBuiltinWebSearch
: !(supportsTools || supportsBuiltinWebSearch));
const codeDisabled =
!modelLoaded ||
(isGeminiImageTier
? true
: !(supportsTools || supportsBuiltinCodeExecution)) ||
(modelLoaded &&
(isGeminiImageTier
? true
: !(supportsTools || supportsBuiltinCodeExecution))) ||
imageModeDisablesCode;
// Images pill is only ever lit on OpenAI cloud's Responses-API models
// and Gemini Nano Banana family. No local tool runtime fallback.