From be65130a062ab3eba98234a2574eaa5130fe0409 Mon Sep 17 00:00:00 2001 From: Henry Li Date: Mon, 2 Feb 2026 09:05:24 +0800 Subject: [PATCH] feat: dynamic title --- frontend/src/app/layout.tsx | 2 +- .../app/workspace/chats/[thread_id]/page.tsx | 20 +++++++++++++++++++ frontend/src/app/workspace/chats/page.tsx | 7 ++++++- frontend/src/core/i18n/locales/en-US.ts | 8 ++++++++ frontend/src/core/i18n/locales/types.ts | 8 ++++++++ frontend/src/core/i18n/locales/zh-CN.ts | 8 ++++++++ 6 files changed, 51 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index 8a95128..60f2581 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -9,7 +9,7 @@ import { I18nProvider } from "@/core/i18n/context"; import { detectLocaleServer } from "@/core/i18n/server"; export const metadata: Metadata = { - title: "Welcome to DeerFlow", + title: "DeerFlow", description: "A LangChain-based framework for building super agents.", }; diff --git a/frontend/src/app/workspace/chats/[thread_id]/page.tsx b/frontend/src/app/workspace/chats/[thread_id]/page.tsx index 9babdcc..1f9cd26 100644 --- a/frontend/src/app/workspace/chats/[thread_id]/page.tsx +++ b/frontend/src/app/workspace/chats/[thread_id]/page.tsx @@ -119,6 +119,26 @@ export default function ChatPage() { return result; }, [thread, isNewThread]); + useEffect(() => { + const pageTitle = isNewThread + ? t.pages.newChat + : thread.values?.title && thread.values.title !== "Untitled" + ? thread.values.title + : t.pages.untitled; + if (thread.isThreadLoading) { + document.title = `Loading... - ${t.pages.appName}`; + } else { + document.title = `${pageTitle} - ${t.pages.appName}`; + } + }, [ + isNewThread, + t.pages.newChat, + t.pages.untitled, + t.pages.appName, + thread.values.title, + thread.isThreadLoading, + ]); + const [autoSelectFirstArtifact, setAutoSelectFirstArtifact] = useState(true); useEffect(() => { setArtifacts(thread.values.artifacts); diff --git a/frontend/src/app/workspace/chats/page.tsx b/frontend/src/app/workspace/chats/page.tsx index b6327f3..53a6613 100644 --- a/frontend/src/app/workspace/chats/page.tsx +++ b/frontend/src/app/workspace/chats/page.tsx @@ -1,7 +1,7 @@ "use client"; import Link from "next/link"; -import { useMemo, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { Input } from "@/components/ui/input"; import { ScrollArea } from "@/components/ui/scroll-area"; @@ -19,6 +19,11 @@ export default function ChatsPage() { const { t } = useI18n(); const { data: threads } = useThreads(); const [search, setSearch] = useState(""); + + useEffect(() => { + document.title = `${t.pages.chats} - ${t.pages.appName}`; + }, [t.pages.chats, t.pages.appName]); + const filteredThreads = useMemo(() => { return threads?.filter((thread) => { return titleOfThread(thread).toLowerCase().includes(search.toLowerCase()); diff --git a/frontend/src/core/i18n/locales/en-US.ts b/frontend/src/core/i18n/locales/en-US.ts index 22ec8ec..5f5d38d 100644 --- a/frontend/src/core/i18n/locales/en-US.ts +++ b/frontend/src/core/i18n/locales/en-US.ts @@ -100,6 +100,14 @@ export const enUS: Translations = { searchChats: "Search chats", }, + // Page titles (document title) + pages: { + appName: "DeerFlow", + chats: "Chats", + newChat: "New chat", + untitled: "Untitled", + }, + // Tool calls toolCalls: { moreSteps: (count: number) => `${count} more step${count === 1 ? "" : "s"}`, diff --git a/frontend/src/core/i18n/locales/types.ts b/frontend/src/core/i18n/locales/types.ts index ef51120..8b86a11 100644 --- a/frontend/src/core/i18n/locales/types.ts +++ b/frontend/src/core/i18n/locales/types.ts @@ -94,6 +94,14 @@ export interface Translations { searchChats: string; }; + // Page titles (document title) + pages: { + appName: string; + chats: string; + newChat: string; + untitled: string; + }; + // Tool calls toolCalls: { moreSteps: (count: number) => string; diff --git a/frontend/src/core/i18n/locales/zh-CN.ts b/frontend/src/core/i18n/locales/zh-CN.ts index ca4fdd8..a35f580 100644 --- a/frontend/src/core/i18n/locales/zh-CN.ts +++ b/frontend/src/core/i18n/locales/zh-CN.ts @@ -98,6 +98,14 @@ export const zhCN: Translations = { searchChats: "搜索对话", }, + // Page titles (document title) + pages: { + appName: "DeerFlow", + chats: "对话", + newChat: "新对话", + untitled: "未命名", + }, + // Tool calls toolCalls: { moreSteps: (count: number) => `查看其他 ${count} 个步骤`,