Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: a hidden Chat with files panel stays hidden after the first message (#13999)

Michael Han4ebc263832e5
diff --git a/studio/frontend/src/features/rag/components/thread-documents-bar.tsx b/studio/frontend/src/features/rag/components/thread-documents-bar.tsx
index 0f548484036..072f0f699da 100644
--- a/studio/frontend/src/features/rag/components/thread-documents-bar.tsx
+++ b/studio/frontend/src/features/rag/components/thread-documents-bar.tsx
@@ -276,6 +276,9 @@ const HEADER_ICON = { width: 16, height: 16 } as const;
const CompactCardsContext = createContext(false);
+/** The chat the files bar last showed, across remounts. */
+let panelThreadItemId: string | null = null;
+
function HeaderTip({ label, children }: { label: string; children: ReactElement }) {
return (
<Tooltip>
@@ -1182,10 +1185,13 @@ export function ThreadDocumentsBar({
// Keyed by the list item id, stable while a new chat materializes, so only a real switch drops the queue.
const threadItemId = useAuiState(({ threadListItem }) => threadListItem.id);
- // A hidden panel comes back in the next chat.
- // biome-ignore lint/correctness/useExhaustiveDependencies: resets on a chat switch
+ // A hidden panel comes back in the next chat. Keyed outside the component: sending the first
+ // message moves the composer, which remounts this bar in the same chat.
useEffect(() => {
- useChatRuntimeStore.getState().setRagPanelHidden(false);
+ if (panelThreadItemId !== null && panelThreadItemId !== threadItemId) {
+ useChatRuntimeStore.getState().setRagPanelHidden(false);
+ }
+ panelThreadItemId = threadItemId;
}, [threadItemId]);
const { enqueue: queueAttach, queued } = useUploadQueue<RagUploadItem>(
attach,
diff --git a/studio/frontend/tests/rag-panel-hide.test.ts b/studio/frontend/tests/rag-panel-hide.test.ts
index 6a1c1fcd14c..305bec0ca24 100644
--- a/studio/frontend/tests/rag-panel-hide.test.ts
+++ b/studio/frontend/tests/rag-panel-hide.test.ts
@@ -21,7 +21,11 @@ test("the panel X hides the panel instead of turning RAG off", () => {
test("turning RAG on, picking a source or switching chats shows the panel again", () => {
assert.match(store, /ragEnabled,\n\s*ragPanelHidden: false,/);
assert.match(store, /ragSource,\n\s*ragPanelHidden: false,/);
- assert.match(bar, /setRagPanelHidden\(false\);\n\s*\}, \[threadItemId\]\);/);
+ // Only a real chat switch: a remount in the same chat (the first send moves the composer) keeps it hidden.
+ assert.match(
+ bar,
+ /if \(panelThreadItemId !== null && panelThreadItemId !== threadItemId\) \{\n\s*useChatRuntimeStore\.getState\(\)\.setRagPanelHidden\(false\);\n\s*\}\n\s*panelThreadItemId = threadItemId;/,
+ );
assert.match(thread, /if \(ragEnabled && ragPanelHidden\) \{\n\s*setRagPanelHidden\(false\);\n\s*return;/);
// Compare's + menu too: the regular view stays mounted behind it.
assert.match(