From 3f2bfded418368b3c08cf36f7fe58dc1e328c59a Mon Sep 17 00:00:00 2001 From: Henry Li Date: Fri, 16 Jan 2026 09:37:04 +0800 Subject: [PATCH] feat: enable edit context options --- .../app/workspace/chats/[thread_id]/page.tsx | 2 + .../src/components/workspace/input-box.tsx | 116 +++++++++++++++++- 2 files changed, 113 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/workspace/chats/[thread_id]/page.tsx b/frontend/src/app/workspace/chats/[thread_id]/page.tsx index 47faa64..44d5e0e 100644 --- a/frontend/src/app/workspace/chats/[thread_id]/page.tsx +++ b/frontend/src/app/workspace/chats/[thread_id]/page.tsx @@ -114,6 +114,8 @@ export default function ChatPage() { className="max-w-(--container-width-md)" autoFocus={isNewThread} status={thread.isLoading ? "streaming" : "ready"} + context={threadContext} + onContextChange={setThreadContext} onSubmit={handleSubmit} onStop={handleStop} /> diff --git a/frontend/src/components/workspace/input-box.tsx b/frontend/src/components/workspace/input-box.tsx index d8cd5b2..aaf4607 100644 --- a/frontend/src/components/workspace/input-box.tsx +++ b/frontend/src/components/workspace/input-box.tsx @@ -1,6 +1,6 @@ import type { ChatStatus } from "ai"; -import { LightbulbIcon, LightbulbOffIcon } from "lucide-react"; -import { useCallback, type ComponentProps } from "react"; +import { CheckIcon, LightbulbIcon, LightbulbOffIcon } from "lucide-react"; +import { useCallback, useMemo, useState, type ComponentProps } from "react"; import { PromptInput, @@ -11,23 +11,70 @@ import { PromptInputTextarea, type PromptInputMessage, } from "@/components/ai-elements/prompt-input"; +import type { AgentThreadContext } from "@/core/threads"; import { cn } from "@/lib/utils"; +import { + ModelSelector, + ModelSelectorContent, + ModelSelectorInput, + ModelSelectorItem, + ModelSelectorList, + ModelSelectorLogo, + ModelSelectorName, + ModelSelectorTrigger, + type ModelSelectorLogoProps, +} from "../ai-elements/model-selector"; + import { Tooltip } from "./tooltip"; +const AVAILABLE_MODELS = [ + { name: "deepseek-v3.2", displayName: "DeepSeek v3.2", provider: "deepseek" }, + { + name: "doubao-seed-1.8", + displayName: "Doubao Seed 1.8", + provider: "doubao", + }, +]; + export function InputBox({ className, autoFocus, status = "ready", + context, + onContextChange, onSubmit, onStop, ...props }: Omit, "onSubmit"> & { assistantId?: string | null; status?: ChatStatus; + context: AgentThreadContext; + onContextChange?: (context: AgentThreadContext) => void; onSubmit?: (message: PromptInputMessage) => void; onStop?: () => void; }) { + const [modelDialogOpen, setModelDialogOpen] = useState(false); + const selectedModel = useMemo( + () => AVAILABLE_MODELS.find((m) => m.name === context.model), + [context.model], + ); + const handleModelSelect = useCallback( + (model: string) => { + onContextChange?.({ + ...context, + model, + }); + setModelDialogOpen(false); + }, + [onContextChange, context], + ); + const handleThinkingToggle = useCallback(() => { + onContextChange?.({ + ...context, + thinking_enabled: !context.thinking_enabled, + }); + }, [onContextChange, context]); const handleSubmit = useCallback( async (message: PromptInputMessage) => { if (status === "streaming") { @@ -62,13 +109,72 @@ export function InputBox({
- - - + +
Thinking is enabled
+
Click to disable thinking
+
+ ) : ( +
+
Thinking is disabled
+
Click to enable thinking
+
+ ) + } + > + + {context.thinking_enabled ? ( + + ) : ( + + )}
+ + + + + + {selectedModel?.displayName} + + + + + + + {AVAILABLE_MODELS.map((m) => ( + handleModelSelect(m.name)} + > + + {m.displayName} + {m.name === context.model ? ( + + ) : ( +
+ )} + + ))} + + +