From 50f3e74d0589c8b6120d329ca35dfe74ef94e5e0 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Tue, 10 Feb 2026 15:28:42 -0600 Subject: [PATCH] fix(app): task tool rendering --- packages/app/src/pages/directory-layout.tsx | 9 ++ packages/ui/src/components/message-part.tsx | 102 ++++++++++++++------ packages/ui/src/context/data.tsx | 8 ++ 3 files changed, 87 insertions(+), 32 deletions(-) diff --git a/packages/app/src/pages/directory-layout.tsx b/packages/app/src/pages/directory-layout.tsx index b2a17b96b..f36bb7ab4 100644 --- a/packages/app/src/pages/directory-layout.tsx +++ b/packages/app/src/pages/directory-layout.tsx @@ -54,6 +54,13 @@ export default function Layout(props: ParentProps) { navigate(`/${params.dir}/session/${sessionID}`) } + const sessionHref = (sessionID: string) => { + if (params.dir) return `/${params.dir}/session/${sessionID}` + return `/session/${sessionID}` + } + + const syncSession = (sessionID: string) => sync.session.sync(sessionID) + return ( {props.children} diff --git a/packages/ui/src/components/message-part.tsx b/packages/ui/src/components/message-part.tsx index 83847a533..3f61b3186 100644 --- a/packages/ui/src/components/message-part.tsx +++ b/packages/ui/src/components/message-part.tsx @@ -877,6 +877,74 @@ ToolRegistry.register({ const data = useData() const i18n = useI18n() const childSessionId = () => props.metadata.sessionId as string | undefined + + const href = createMemo(() => { + const sessionId = childSessionId() + if (!sessionId) return + + const direct = data.sessionHref?.(sessionId) + if (direct) return direct + + if (typeof window === "undefined") return + const path = window.location.pathname + const idx = path.indexOf("/session") + if (idx === -1) return + return `${path.slice(0, idx)}/session/${sessionId}` + }) + + createEffect(() => { + const sessionId = childSessionId() + if (!sessionId) return + const sync = data.syncSession + if (!sync) return + Promise.resolve(sync(sessionId)).catch(() => undefined) + }) + + const handleLinkClick = (e: MouseEvent) => { + const sessionId = childSessionId() + const url = href() + if (!sessionId || !url) return + + e.stopPropagation() + + if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return + + const nav = data.navigateToSession + if (!nav || typeof window === "undefined") return + + e.preventDefault() + const before = window.location.pathname + window.location.search + window.location.hash + nav(sessionId) + setTimeout(() => { + const after = window.location.pathname + window.location.search + window.location.hash + if (after === before) window.location.assign(url) + }, 50) + } + + const trigger = () => ( +
+
+ + {i18n.t("ui.tool.agent", { type: props.input.subagent_type || props.tool })} + + + + + {(url) => ( + + {props.input.description} + + )} + + + {props.input.description} + + + +
+
+ ) + const childToolParts = createMemo(() => { const sessionId = childSessionId() if (!sessionId) return [] @@ -924,13 +992,6 @@ ToolRegistry.register({ }) } - const handleSubtitleClick = () => { - const sessionId = childSessionId() - if (sessionId && data.navigateToSession) { - data.navigateToSession(sessionId) - } - } - const renderChildToolPart = () => { const toolData = childToolPart() if (!toolData) return null @@ -958,21 +1019,7 @@ ToolRegistry.register({ <> - - } - > + }> {renderChildToolPart()}
@@ -991,16 +1038,7 @@ ToolRegistry.register({ - +
void export type NavigateToSessionFn = (sessionID: string) => void +export type SessionHrefFn = (sessionID: string) => string + +export type SyncSessionFn = (sessionID: string) => void | Promise + export const { use: useData, provider: DataProvider } = createSimpleContext({ name: "Data", init: (props: { @@ -57,6 +61,8 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({ onQuestionReply?: QuestionReplyFn onQuestionReject?: QuestionRejectFn onNavigateToSession?: NavigateToSessionFn + onSessionHref?: SessionHrefFn + onSyncSession?: SyncSessionFn }) => { return { get store() { @@ -69,6 +75,8 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({ replyToQuestion: props.onQuestionReply, rejectQuestion: props.onQuestionReject, navigateToSession: props.onNavigateToSession, + sessionHref: props.onSessionHref, + syncSession: props.onSyncSession, } }, })