feat(frontend): 同步 agent 页面头部并保留本地行为

This commit is contained in:
肖应宇 2026-03-29 00:11:01 +08:00
parent a0ce3d8b08
commit 7071ead062
3 changed files with 11 additions and 9 deletions

View File

@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
"use client";
import type { UseStream } from "@langchain/langgraph-sdk/react";
import { BotIcon, PlusSquare } from "lucide-react";
import { useParams, useRouter } from "next/navigation";
import { useCallback } from "react";
@ -23,6 +22,7 @@ import { useAgent } from "@/core/agents";
import { useI18n } from "@/core/i18n/hooks";
import { useNotification } from "@/core/notification/hooks";
import { useLocalSettings } from "@/core/settings";
import type { AgentThreadState } from "@/core/threads";
import { useThreadStream } from "@/core/threads/hooks";
import { textOfMessage } from "@/core/threads/utils";
import { env } from "@/env";
@ -82,6 +82,7 @@ export default function AgentChatPage() {
const handleStop = useCallback(async () => {
await thread.stop();
}, [thread]);
const legacyThread = thread as unknown as UseStream<AgentThreadState>;
return (
<ThreadContext.Provider value={{ thread }}>
@ -104,7 +105,7 @@ export default function AgentChatPage() {
</div>
<div className="flex w-full items-center text-sm font-medium">
<ThreadTitle threadId={threadId} thread={thread} />
<ThreadTitle threadId={threadId} thread={legacyThread} />
</div>
<div className="mr-4 flex items-center">
<Tooltip content={t.agents.newChat}>
@ -129,7 +130,7 @@ export default function AgentChatPage() {
<MessageList
className={cn("size-full", !isNewThread && "pt-10")}
threadId={threadId}
thread={thread}
thread={legacyThread}
/>
</div>
@ -158,7 +159,6 @@ export default function AgentChatPage() {
<InputBox
className={cn("bg-background/5 w-full -translate-y-4")}
isNewThread={isNewThread}
threadId={threadId}
autoFocus={isNewThread}
status={
thread.error

View File

@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
"use client";
import type { UseStream } from "@langchain/langgraph-sdk/react";
import { ArrowLeftIcon, BotIcon, CheckCircleIcon } from "lucide-react";
import { useRouter } from "next/navigation";
import { useCallback, useMemo, useState } from "react";
@ -20,6 +19,7 @@ import { ThreadContext } from "@/components/workspace/messages/context";
import type { Agent } from "@/core/agents";
import { checkAgentName, getAgent } from "@/core/agents/api";
import { useI18n } from "@/core/i18n/hooks";
import type { AgentThreadState } from "@/core/threads";
import { useThreadStream } from "@/core/threads/hooks";
import { uuid } from "@/core/utils/uuid";
import { cn } from "@/lib/utils";
@ -120,6 +120,7 @@ export default function NewAgentPage() {
);
// ── Shared header ──────────────────────────────────────────────────────────
const legacyThread = thread as unknown as UseStream<AgentThreadState>;
const header = (
<header className="flex shrink-0 items-center gap-3 border-b px-4 py-3">
@ -199,7 +200,7 @@ export default function NewAgentPage() {
<MessageList
className="size-full pt-10"
threadId={threadId}
thread={thread}
thread={legacyThread}
/>
</div>

View File

@ -38,7 +38,8 @@
"**/*.tsx",
"**/*.cjs",
"**/*.js",
".next/types/**/*.ts"
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": ["node_modules", "generated", "imports"]
}