Studio: hide RAG pill and Retrieval section for external providers

This commit is contained in:
Roland Tannous 2026-05-30 14:34:41 +04:00
commit ff0472cfc1
3 changed files with 34 additions and 27 deletions

View file

@ -1143,6 +1143,7 @@ const ImagesToggle: FC = () => {
// Master RAG switch (mirrors shared-composer); sidebar configures the rest.
const RagToggle: FC = () => {
const checkpoint = useChatRuntimeStore((s) => s.params.checkpoint);
const modelLoaded = useChatRuntimeStore(
(s) => !!s.params.checkpoint && !s.modelLoading,
);
@ -1151,8 +1152,10 @@ const RagToggle: FC = () => {
const ragSource = useChatRuntimeStore((s) => s.ragSource);
const setRagSource = useChatRuntimeStore((s) => s.setRagSource);
const supportsTools = useChatRuntimeStore((s) => s.supportsTools);
// RAG runs through the local search_knowledge_base tool, so it needs
// tool-calling support (mirrors shared-composer's ragDisabled).
// RAG runs through the local search_knowledge_base tool, so it's hidden
// entirely for external providers (whose request path doesn't execute
// local tools) and gated on tool-calling support otherwise.
if (parseExternalModelId(checkpoint) !== null) return null;
const disabled = !modelLoaded || !supportsTools;
return (
<button

View file

@ -1364,7 +1364,7 @@ export function ChatSettingsPanel({
</CollapsibleSection>
) : null}
{ragToolEnabled ? (
{ragToolEnabled && externalSelection == null ? (
<CollapsibleSection label="Retrieval" defaultOpen={true}>
<div className="flex flex-col gap-3 pt-1">
<div className="flex flex-col gap-1.5">

View file

@ -1494,31 +1494,35 @@ export function SharedComposer({
<span>Images</span>
</button>
)}
{/* Master RAG toggle; sidebar Retrieval section configures the rest. */}
<button
type="button"
disabled={ragDisabled}
onClick={() => {
const next = !ragToolEnabled;
setRagToolEnabled(next);
if (next && ragSource.kind === "off") {
setRagSource({ kind: "thread" });
{/* Master RAG toggle; sidebar Retrieval section configures the rest.
Hidden for external providers RAG runs through the local
search_knowledge_base tool, which only fires on local runtimes. */}
{!isExternalModel && (
<button
type="button"
disabled={ragDisabled}
onClick={() => {
const next = !ragToolEnabled;
setRagToolEnabled(next);
if (next && ragSource.kind === "off") {
setRagSource({ kind: "thread" });
}
}}
className="composer-pill-btn"
data-active={ragToolEnabled && !ragDisabled ? "true" : "false"}
aria-label={ragToolEnabled ? "Disable RAG" : "Enable RAG"}
title={
ragDisabled
? "RAG needs a model that supports tool calling"
: ragToolEnabled
? "RAG on — the model can search your attached documents"
: "Enable RAG — let the model search your documents"
}
}}
className="composer-pill-btn"
data-active={ragToolEnabled && !ragDisabled ? "true" : "false"}
aria-label={ragToolEnabled ? "Disable RAG" : "Enable RAG"}
title={
ragDisabled
? "RAG needs a model that supports tool calling"
: ragToolEnabled
? "RAG on — the model can search your attached documents"
: "Enable RAG — let the model search your documents"
}
>
<BookOpenIcon className="size-3.5" />
<span>RAG</span>
</button>
>
<BookOpenIcon className="size-3.5" />
<span>RAG</span>
</button>
)}
{showWebFetchPill && (
<button
type="button"