fix(frontend): preserve agent context in thread history routes (#1771)

* fix(frontend): preserve agent context in thread history routes

* fix(frontend): preserve agent thread fallback context

* style(frontend): format thread route utils test

---------

Co-authored-by: luoxiao6645 <luoxiao6645@gmail.com>
This commit is contained in:
2026-04-09 15:11:57 +08:00
committed by GitHub
parent 616caa92b1
commit 60e0abfdb8
6 changed files with 78 additions and 21 deletions
+22 -3
View File
@@ -1,9 +1,28 @@
import type { Message } from "@langchain/langgraph-sdk";
import type { AgentThread } from "./types";
import type { AgentThread, AgentThreadContext } from "./types";
export function pathOfThread(threadId: string) {
return `/workspace/chats/${threadId}`;
type ThreadRouteTarget =
| string
| Pick<AgentThread, "thread_id" | "context">
| {
thread_id: string;
context?: Pick<AgentThreadContext, "agent_name"> | null;
};
export function pathOfThread(
thread: ThreadRouteTarget,
context?: Pick<AgentThreadContext, "agent_name"> | null,
) {
const threadId = typeof thread === "string" ? thread : thread.thread_id;
const agentName =
typeof thread === "string"
? context?.agent_name
: thread.context?.agent_name;
return agentName
? `/workspace/agents/${encodeURIComponent(agentName)}/chats/${threadId}`
: `/workspace/chats/${threadId}`;
}
export function textOfMessage(message: Message) {