{"record":{"id":"66ed93730cba3d61","repo":"bytedance/deer-flow","slug":"no-context-selected","errorCode":null,"errorMessage":"No context selected","messagePattern":"No context selected","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"frontend/src/components/workspace/sidecar/sidecar-panel.tsx","lineNumber":326,"sourceCode":"        ...sidecar.context,\n        mode: nextMode,\n        reasoning_effort: reasoningEffortForMode(nextMode),\n      });\n    },\n    [sidecar, supportThinking],\n  );\n\n  const ensureSidecarThread = useCallback(\n    async (references: SidecarReference[]) => {\n      if (sidecar.sidecarThreadId) {\n        return sidecar.sidecarThreadId;\n      }\n      const restoredThreadId = await sidecar.restoreSidecarThread();\n      if (restoredThreadId) {\n        return restoredThreadId;\n      }\n      if (references.length === 0) {\n        throw new Error(t.sidecar.noContext);\n      }\n      setCreatingThread(true);\n      try {\n        const created = await createSidecarThread({\n          parentThreadId: sidecar.parentThreadId,\n          context: references.map((reference) => reference.context),\n        });\n        sidecar.setSidecarThreadId(created.thread_id);\n        return created.thread_id;\n      } finally {\n        setCreatingThread(false);\n      }\n    },\n    [sidecar, t.sidecar.noContext],\n  );\n\n  const submitToSidecarThread = useCallback(\n    async (","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/frontend/src/components/workspace/sidecar/sidecar-panel.tsx#L308-L344","documentation":"ensureSidecarThread lazily creates the sidecar (sub-thread) conversation: it returns the existing sidecarThreadId, or restores a persisted one, and only then creates a new thread with the passed references as context. If references is empty at that point, there is nothing to seed the sidecar with, so it throws the localized 'no context selected' error instead of creating an empty sidecar thread.","triggerScenarios":"The user triggers a sidecar action (e.g. 'ask about this' / quote into sidecar) with no selection, artifact, or message reference attached — references === [] — while sidecar.sidecarThreadId is unset and restoreSidecarThread() returned falsy (no prior sidecar thread persisted for this parent).","commonSituations":"UI race where the reference list has not loaded yet but the action button fired; a stale panel re-mounted after the sidecar thread was cleared; calling the sidecar send path programmatically without providing context references.","solutions":["Select a message quote, artifact, or file reference first, then trigger the sidecar action.","If the reference should exist, check that the component passes a non-empty SidecarReference[] array into the action handler.","If a previous sidecar thread should have been restored, verify the persisted parent thread id matches and restoreSidecarThread did not silently fail (check its console/network log).","Guard the action button with `disabled={references.length === 0}` when no sidecar thread exists yet."],"exampleFix":"// before\n<button onClick={() => sendToSidecar()}>Ask sidecar</button>\n\n// after\n<button\n  disabled={!sidecar.sidecarThreadId && references.length === 0}\n  onClick={() => sendToSidecar()}\n>\n  Ask sidecar\n</button>","handlingStrategy":"validation","validationCode":"if (!sidecar.sidecarThreadId && references.length === 0) {\n  toast.warn(t.sidecar.noContext);\n  return;\n}\nconst threadId = await ensureSidecarThread(references);","typeGuard":"function hasSidecarContext(\n  sidecar: { sidecarThreadId?: string | null },\n  references: SidecarReference[],\n): boolean {\n  return Boolean(sidecar.sidecarThreadId) || references.length > 0;\n}","tryCatchPattern":"try {\n  await ensureSidecarThread(references);\n} catch (e) {\n  if (e instanceof Error && e.message === t.sidecar.noContext) toast.warn(e.message);\n  else throw e;\n}","preventionTips":["Disable sidecar actions until at least one reference is attached or a sidecar thread exists.","Ensure restoreSidecarThread failures are visible in console so restoration bugs are not masked as 'no context'.","Never call ensureSidecarThread with a possibly-empty array from an event handler."],"tags":["sidecar","ui","react","validation"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}