perf(subagent): read saved task history by loaded turns (#6634)
This commit is contained in:
1 parent
1196698ecb
commit
eb8546c321
20 files changed
+893
-97
No files matched your search
@@ -485,6 +485,17 @@ export function ThreadShell({
|
||||
const { t } = useTranslation();
|
||||
const chatId = session?.chatId ?? null;
|
||||
const historyKey = temporary ? null : session?.key ?? null;
|
||||
const [visibleWindow, setVisibleWindow] = useState<{ key: string | null; turnIds: string[]; hasMessages: boolean } | null>(null);
|
||||
const reportVisibleMessages = useCallback((messages: UIMessage[]) => {
|
||||
// Saved results attach to turns, so only the rendered user turns matter here.
|
||||
const turnIds = [...new Set(messages.flatMap((message) => (
|
||||
message.role === "user" && message.turnId ? [message.turnId] : []
|
||||
)))];
|
||||
setVisibleWindow((current) => current?.key === historyKey && current.hasMessages === (messages.length > 0)
|
||||
&& current.turnIds.length === turnIds.length
|
||||
&& current.turnIds.every((turnId, index) => turnId === turnIds[index])
|
||||
? current : { key: historyKey, turnIds, hasMessages: messages.length > 0 });
|
||||
}, [historyKey]);
|
||||
const previewSessionKey = session?.key ?? null;
|
||||
const mentionSessions = useMemo(
|
||||
() => sessions.filter((candidate) => candidate.key !== historyKey).map((candidate) => {
|
||||
@@ -1527,6 +1538,8 @@ export function ThreadShell({
|
||||
sessionKey={session?.key ?? null}
|
||||
liveEvents={webuiCapabilities.includes("webui.subagents.events.v1")}
|
||||
historyEnabled={webuiCapabilities.includes("webui.subagents.history.v1")}
|
||||
turnIds={visibleWindow?.key === historyKey ? visibleWindow.turnIds : []}
|
||||
windowReady={messagesReady && visibleWindow?.key === historyKey && (!initialHistoryLoading || visibleWindow.hasMessages)}
|
||||
active={composerActive}
|
||||
enabled={!temporary && !!session?.key.startsWith("websocket:") && webuiCapabilities.includes("webui.subagents.v1")}>
|
||||
<section ref={setSidebarHost} style={{ "--sidebar-enter-width": `${sidebarEnterWidth}px`, "--sidebar-enter-mobile-width": sidebarEnterWidth ? "100%" : "0px" } as CSSProperties} data-preview-open={sidebarOpen || undefined} className="thread-preview-layout relative flex min-h-0 flex-1 overflow-hidden">
|
||||
@@ -1573,6 +1586,7 @@ export function ThreadShell({
|
||||
activeTurnStartedHere={activeTurnStartedHere}
|
||||
conversationKey={historyKey}
|
||||
conversationReady={messagesReady}
|
||||
onVisibleMessagesChange={reportVisibleMessages}
|
||||
showScrollToBottomButton={!!session}
|
||||
cliApps={cliApps}
|
||||
mcpPresets={mcpPresets}
|
||||
|
||||
Reference in new issue
Block a user