From 7bf15cb777dbc5de3ab3a74693d89fd65a823520 Mon Sep 17 00:00:00 2001 From: Henry Li Date: Thu, 29 Jan 2026 15:48:50 +0800 Subject: [PATCH] feat: use "mode" instead of "thinking_enabled" and "is_plan_mode" --- .../app/workspace/chats/[thread_id]/page.tsx | 6 +- frontend/src/app/workspace/layout.tsx | 1 - .../src/components/workspace/input-box.tsx | 78 ++++++++----------- frontend/src/core/settings/local.ts | 10 ++- 4 files changed, 46 insertions(+), 49 deletions(-) diff --git a/frontend/src/app/workspace/chats/[thread_id]/page.tsx b/frontend/src/app/workspace/chats/[thread_id]/page.tsx index 5b217a1..d74515b 100644 --- a/frontend/src/app/workspace/chats/[thread_id]/page.tsx +++ b/frontend/src/app/workspace/chats/[thread_id]/page.tsx @@ -108,7 +108,11 @@ export default function ChatPage() { isNewThread, threadId, thread, - threadContext: settings.context, + threadContext: { + ...settings.context, + thinking_enabled: settings.context.mode !== "flash", + is_plan_mode: settings.context.mode === "pro", + }, afterSubmit() { router.push(pathOfThread(threadId!)); }, diff --git a/frontend/src/app/workspace/layout.tsx b/frontend/src/app/workspace/layout.tsx index 49c1d19..be2c0df 100644 --- a/frontend/src/app/workspace/layout.tsx +++ b/frontend/src/app/workspace/layout.tsx @@ -5,7 +5,6 @@ import { useCallback, useEffect, useState } from "react"; import { Toaster } from "sonner"; import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar"; -import { Overscroll } from "@/components/workspace/overscroll"; import { WorkspaceSidebar } from "@/components/workspace/workspace-sidebar"; import { useLocalSettings } from "@/core/settings"; diff --git a/frontend/src/components/workspace/input-box.tsx b/frontend/src/components/workspace/input-box.tsx index 0c28673..a65d9a2 100644 --- a/frontend/src/components/workspace/input-box.tsx +++ b/frontend/src/components/workspace/input-box.tsx @@ -62,10 +62,22 @@ export function InputBox({ assistantId?: string | null; status?: ChatStatus; disabled?: boolean; - context: Omit; + context: Omit< + AgentThreadContext, + "thread_id" | "is_plan_mode" | "thinking_enabled" + > & { + mode: "flash" | "thinking" | "pro" | undefined; + }; extraHeader?: React.ReactNode; isNewThread?: boolean; - onContextChange?: (context: Omit) => void; + onContextChange?: ( + context: Omit< + AgentThreadContext, + "thread_id" | "is_plan_mode" | "thinking_enabled" + > & { + mode: "flash" | "thinking" | "pro" | undefined; + }, + ) => void; onSubmit?: (message: PromptInputMessage) => void; onStop?: () => void; }) { @@ -74,13 +86,15 @@ export function InputBox({ const { models } = useModels(); const selectedModel = useMemo(() => { if (!context.model_name && models.length > 0) { + const model = models[0]!; setTimeout(() => { onContextChange?.({ ...context, - model_name: models[0]!.name, + model_name: model.name, + mode: model.supports_thinking ? "pro" : "flash", }); }, 0); - return models[0]!; + return model; } return models.find((m) => m.name === context.model_name); }, [context, models, onContextChange]); @@ -88,48 +102,22 @@ export function InputBox({ () => selectedModel?.supports_thinking ?? false, [selectedModel], ); - const mode = useMemo(() => { - if (context.is_plan_mode) { - return "pro"; - } - if (context.thinking_enabled) { - return "thinking"; - } - return "flash"; - }, [context.thinking_enabled, context.is_plan_mode]); const handleModelSelect = useCallback( (model_name: string) => { - const supports_thinking = selectedModel?.supports_thinking ?? false; onContextChange?.({ ...context, model_name, - thinking_enabled: supports_thinking && context.thinking_enabled, }); setModelDialogOpen(false); }, - [selectedModel?.supports_thinking, onContextChange, context], + [onContextChange, context], ); const handleModeSelect = useCallback( (mode: "flash" | "thinking" | "pro") => { - if (mode === "flash") { - onContextChange?.({ - ...context, - thinking_enabled: false, - is_plan_mode: false, - }); - } else if (mode === "thinking") { - onContextChange?.({ - ...context, - thinking_enabled: true, - is_plan_mode: false, - }); - } else if (mode === "pro") { - onContextChange?.({ - ...context, - thinking_enabled: true, - is_plan_mode: true, - }); - } + onContextChange?.({ + ...context, + mode, + }); }, [onContextChange, context], ); @@ -192,7 +180,7 @@ export function InputBox({ {t.inputBox.flashMode} @@ -212,7 +201,7 @@ export function InputBox({ {t.inputBox.flashModeDescription} - {mode === "flash" ? ( + {context.mode === "flash" ? ( ) : (
@@ -221,7 +210,7 @@ export function InputBox({ {supportThinking && ( {t.inputBox.reasoningMode} @@ -241,7 +231,7 @@ export function InputBox({ {t.inputBox.reasoningModeDescription}
- {mode === "thinking" ? ( + {context.mode === "thinking" ? ( ) : (
@@ -250,7 +240,7 @@ export function InputBox({ )} {t.inputBox.proMode} @@ -270,7 +260,7 @@ export function InputBox({ {t.inputBox.proModeDescription}
- {mode === "pro" ? ( + {context.mode === "pro" ? ( ) : (
diff --git a/frontend/src/core/settings/local.ts b/frontend/src/core/settings/local.ts index 7f8af3d..6d284fc 100644 --- a/frontend/src/core/settings/local.ts +++ b/frontend/src/core/settings/local.ts @@ -3,8 +3,7 @@ import type { AgentThreadContext } from "../threads"; export const DEFAULT_LOCAL_SETTINGS: LocalSettings = { context: { model_name: undefined, - thinking_enabled: true, - is_plan_mode: true, + mode: undefined, }, layout: { sidebar_collapsed: false, @@ -14,7 +13,12 @@ export const DEFAULT_LOCAL_SETTINGS: LocalSettings = { const LOCAL_SETTINGS_KEY = "deerflow.local-settings"; export interface LocalSettings { - context: Omit; + context: Omit< + AgentThreadContext, + "thread_id" | "is_plan_mode" | "thinking_enabled" + > & { + mode: "flash" | "thinking" | "pro" | undefined; + }; layout: { sidebar_collapsed: boolean; };