feat(webui): show the latest activity in collapsed turns
This commit is contained in:
1 parent
5e9810c1ad
commit
83ad917d6b
26 files changed
+476
-115
No files matched your search
@@ -89,7 +89,7 @@ export function AppearanceSettingsView({ themePreference, onChangeTheme, localPr
|
||||
description={t(`settings.appearance.${localPrefs.activityMode === "auto" ? "autoHelp" : "expandedHelp"}`)}>
|
||||
<SegmentedControl<LocalActivityMode> value={localPrefs.activityMode}
|
||||
ariaLabel={t("settings.rows.activityMode")}
|
||||
options={[{ value: "auto", label: t("settings.values.auto") }, { value: "expanded", label: t("settings.values.expanded") }]}
|
||||
options={[{ value: "auto", label: t("settings.values.collapsed") }, { value: "expanded", label: t("settings.values.expanded") }]}
|
||||
onChange={(activityMode) => onChangeLocalPrefs((previous) => ({ ...previous, activityMode }))} />
|
||||
</SettingsRow>
|
||||
<div className="settings-group-divider">
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
@@ -26,6 +25,7 @@ import {
|
||||
compactActivityPath,
|
||||
formatActivityTarget,
|
||||
redactShellCommand,
|
||||
safeActivityDetail,
|
||||
} from "@/components/thread/activity/activity-text";
|
||||
import { FileEditGroup, type FileEditSummary } from "@/components/thread/activity/FileEditRow";
|
||||
import { GenericToolRun } from "@/components/thread/activity/GenericToolRun";
|
||||
@@ -37,14 +37,16 @@ import {
|
||||
type GenericToolStatus,
|
||||
parseGenericToolTrace,
|
||||
} from "@/components/thread/activity/generic-tool-model";
|
||||
import { LatestActivityWheel } from "@/components/thread/activity/LatestActivityWheel";
|
||||
import { ReasoningRow } from "@/components/thread/activity/ReasoningRow";
|
||||
import { compactReasoningPreview } from "@/components/thread/activity/reasoning-preview";
|
||||
import { describeMcpActivity } from "@/components/thread/activity/mcp-activity-model";
|
||||
import { ThinkingReasoningShell } from "@/components/thread/activity/ThinkingReasoningShell";
|
||||
import { WebActivityRow } from "@/components/thread/activity/WebActivityRow";
|
||||
import {
|
||||
describeTraceLine,
|
||||
} from "@/components/thread/activity/trace-activity-model";
|
||||
import { WebSearchRun } from "@/components/thread/activity/WebSearchRun";
|
||||
import { WebSearchActionRow, WebSearchRun } from "@/components/thread/activity/WebSearchRun";
|
||||
import { webSearchRunsByTraceLine } from "@/components/thread/activity/web-search-model";
|
||||
import {
|
||||
isReasoningOnlyAssistant,
|
||||
@@ -279,20 +281,12 @@ function FoldedAgentActivity({
|
||||
fileCount,
|
||||
} = countActivity(activityMessages, fileEdits, cliRuns, mcpRuns);
|
||||
|
||||
const [userToggledOuter, setUserToggledOuter] = useState(false);
|
||||
const [outerOpenLocal, setOuterOpenLocal] = useState(false);
|
||||
const [completionHoldOpen, setCompletionHoldOpen] = useState(false);
|
||||
const [outerOpenLocal, setOuterOpenLocal] = useState<boolean>();
|
||||
const [failedTraceDetailKey, setFailedTraceDetailKey] = useState<string | null>(null);
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
const wasTurnStreamingRef = useRef(isTurnStreaming);
|
||||
const wasTurnStreaming = wasTurnStreamingRef.current;
|
||||
const outerExpanded = expanded ?? (
|
||||
userToggledOuter
|
||||
? outerOpenLocal
|
||||
: activityMode === "expanded" || isTurnStreaming || completionHoldOpen || (wasTurnStreaming && !isTurnStreaming)
|
||||
);
|
||||
const outerExpanded = expanded ?? outerOpenLocal ?? (activityMode === "expanded");
|
||||
useEffect(() => {
|
||||
setUserToggledOuter(false);
|
||||
setOuterOpenLocal(undefined);
|
||||
}, [activityMode]);
|
||||
const deferredTraceRefs = useMemo(
|
||||
() => Array.from(new Set(
|
||||
@@ -327,6 +321,11 @@ function FoldedAgentActivity({
|
||||
startedAtMs,
|
||||
);
|
||||
const activityDuration = formatActivityDuration(durationMs);
|
||||
const showActivityPreview = isTurnStreaming && hasVisibleActivity && !outerExpanded && !hideHeader && !retryStatus;
|
||||
const workingLabel = (duration: string) => t("message.activityWorkingFor", {
|
||||
duration,
|
||||
defaultValue: "Working for {{duration}}",
|
||||
});
|
||||
const isCompletedDisclosure = !isTurnStreaming && expanded !== undefined;
|
||||
const retryError = retryStatus?.error_kind === "connection"
|
||||
? t("message.retryConnection", { defaultValue: "Connection failed" })
|
||||
@@ -357,10 +356,7 @@ function FoldedAgentActivity({
|
||||
defaultValue: "{{error}} Retrying",
|
||||
})
|
||||
: isTurnStreaming
|
||||
? t("message.activityWorkingFor", {
|
||||
duration: activityDuration,
|
||||
defaultValue: "Working for {{duration}}",
|
||||
})
|
||||
? workingLabel(activityDuration)
|
||||
: durationMs <= 0
|
||||
? t("message.activityWorked", { defaultValue: "Worked" })
|
||||
: t("message.activityWorkedFor", {
|
||||
@@ -373,9 +369,7 @@ function FoldedAgentActivity({
|
||||
onExpandedChange?.(!expanded);
|
||||
return;
|
||||
}
|
||||
const nextOpen = userToggledOuter ? !outerOpenLocal : !outerExpanded;
|
||||
setUserToggledOuter(true);
|
||||
setOuterOpenLocal(nextOpen);
|
||||
setOuterOpenLocal(!outerExpanded);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -391,19 +385,6 @@ function FoldedAgentActivity({
|
||||
return () => window.clearInterval(interval);
|
||||
}, [isTurnStreaming, pageVisible, threadVisible]);
|
||||
|
||||
useEffect(() => {
|
||||
const wasStreaming = wasTurnStreamingRef.current;
|
||||
wasTurnStreamingRef.current = isTurnStreaming;
|
||||
if (isTurnStreaming) {
|
||||
setCompletionHoldOpen(false);
|
||||
return undefined;
|
||||
}
|
||||
if (!wasStreaming || userToggledOuter) return undefined;
|
||||
setCompletionHoldOpen(true);
|
||||
const timeout = window.setTimeout(() => setCompletionHoldOpen(false), 300);
|
||||
return () => window.clearTimeout(timeout);
|
||||
}, [isTurnStreaming, userToggledOuter]);
|
||||
|
||||
if (!hasVisibleActivity && !isTurnStreaming) return null;
|
||||
|
||||
if (hasOnlyFileActivity && expanded === undefined) {
|
||||
@@ -428,6 +409,16 @@ function FoldedAgentActivity({
|
||||
collapseLabel={t("message.collapseActivity")}
|
||||
contentId={detailsId}
|
||||
label={activityLabel}
|
||||
reservedLabel={showActivityPreview ? workingLabel("00m 00s") : undefined}
|
||||
preview={showActivityPreview ? (
|
||||
<CollapsedActivityPreview
|
||||
messages={activityMessages}
|
||||
fileEditsByMessage={fileEditsByMessage}
|
||||
cliAppsByName={cliAppsByName}
|
||||
mcpPresetsByName={mcpPresetsByName}
|
||||
visible={pageVisible && threadVisible}
|
||||
/>
|
||||
) : undefined}
|
||||
hasDetails={hasVisibleActivity}
|
||||
onToggle={toggleOuter}
|
||||
>
|
||||
@@ -511,6 +502,62 @@ function traceLines(message: UIMessage): string[] {
|
||||
return message.content.trim() ? [message.content] : [];
|
||||
}
|
||||
|
||||
const CollapsedActivityPreview = memo(function CollapsedActivityPreview({
|
||||
messages, fileEditsByMessage, cliAppsByName, mcpPresetsByName, visible,
|
||||
}: {
|
||||
messages: UIMessage[];
|
||||
fileEditsByMessage: Map<string, FileEditSummary[]>;
|
||||
cliAppsByName: Map<string, CliAppInfo>;
|
||||
mcpPresetsByName: Map<string, McpPresetInfo>;
|
||||
visible: boolean;
|
||||
}) {
|
||||
const row = useMemo(() => {
|
||||
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
||||
const message = messages[index];
|
||||
if (isReasoningOnlyAssistant(message)) {
|
||||
return <ReasoningRow key={message.id} text={message.reasoning ?? ""} streaming={!!message.reasoningStreaming} />;
|
||||
}
|
||||
if (message.activityKind === "model" && message.content.trim()) {
|
||||
return <ActivityStep key={message.id} icon={Layers} label={safeActivityDetail(compactReasoningPreview(message.content))} />;
|
||||
}
|
||||
if (message.kind !== "trace") continue;
|
||||
const edit = fileEditsByMessage.get(message.id)?.at(-1);
|
||||
if (edit) return <FileEditGroup key={edit.key} edits={[edit]} displayMode="summary" />;
|
||||
const entry = activityTraceEntries(message).at(-1);
|
||||
const event = entry?.sessionEvent ?? message.toolEvents?.at(-1);
|
||||
const line = entry?.line ?? formatToolCallTrace(event);
|
||||
if (!line?.trim()) continue;
|
||||
const traceKey = canonicalToolTrace(line);
|
||||
const events = message.toolEvents ?? [];
|
||||
const matchingEvent = entry?.sessionEvent ?? [...events].reverse().find((item) => {
|
||||
const trace = formatToolCallTrace(item);
|
||||
return trace !== null && canonicalToolTrace(trace) === traceKey;
|
||||
});
|
||||
const key = `${message.id}:${matchingEvent?.call_id ?? traceKey}`;
|
||||
const search = webSearchRunsByTraceLine(events).get(traceKey);
|
||||
if (search) {
|
||||
const source = search.sources.at(-1);
|
||||
if (source) return <WebActivityRow key={`${key}:${source.href}`} {...source} />;
|
||||
return <WebSearchActionRow key={key} run={search} turnActive />;
|
||||
}
|
||||
if (matchingEvent && toolEventName(matchingEvent) === "exec_session") {
|
||||
return <ExecSessionRow key={key} event={matchingEvent} turnActive />;
|
||||
}
|
||||
const state = genericToolStateByTraceLine(message).get(traceKey);
|
||||
const cli = cliRunMapByTraceLine(message).get(traceKey) ?? parseCliRunTrace(line, state?.status);
|
||||
if (cli) return <CliRunRow key={key} run={cli} active app={cliAppsByName.get(cli.name.toLowerCase())} />;
|
||||
const mcp = mcpRunMapByTraceLine(message).get(traceKey) ?? parseMcpRunTrace(line, state?.status);
|
||||
if (mcp) return <McpRunRow key={key} run={mcp} active preset={mcpPresetsByName.get(mcp.presetName.toLowerCase())} />;
|
||||
const trace = parseGenericToolTrace(line);
|
||||
if (trace) return <GenericToolRun key={key} items={[{ trace, status: state?.status ?? "running", error: state?.error }]} />;
|
||||
return <ActivityTraceRow key={key} line={line} active state={state} />;
|
||||
}
|
||||
return null;
|
||||
}, [messages, fileEditsByMessage, cliAppsByName, mcpPresetsByName]);
|
||||
|
||||
return row ? <LatestActivityWheel row={row} visible={visible} /> : null;
|
||||
});
|
||||
|
||||
const ActivityMessageTimeline = memo(function ActivityMessageTimeline({
|
||||
messages,
|
||||
active,
|
||||
|
||||
@@ -52,6 +52,7 @@ export function ActivityStep({
|
||||
const textLabel = typeof label === "string" ? [label, detail].filter(Boolean).join("\n") : undefined;
|
||||
const activityMarker = (
|
||||
<span
|
||||
data-activity-marker=""
|
||||
className={cn(
|
||||
"flex h-5 w-[1.125rem] shrink-0 items-start justify-center pt-[3px]",
|
||||
markerLabel && ["rounded-sm", formControlFocusClassName],
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { useLayoutEffect, useRef, useState, type ReactElement } from "react";
|
||||
import { motion, useReducedMotion } from "motion/react";
|
||||
|
||||
const SLOW = 0.24;
|
||||
const FAST = 0.12;
|
||||
const rowClass = "flex h-6 min-w-0 items-center [&>*]:w-full";
|
||||
|
||||
export function LatestActivityWheel({ row, visible }: { row: ReactElement; visible: boolean }) {
|
||||
const reducedMotion = useReducedMotion();
|
||||
const canRoll = visible && !reducedMotion;
|
||||
const last = useRef({ row, time: -Infinity });
|
||||
const [frame, setFrame] = useState<{ key: ReactElement["key"]; previous?: ReactElement; duration?: number }>({ key: row.key });
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const previous = last.current;
|
||||
if (!canRoll) {
|
||||
last.current = { row, time: -Infinity };
|
||||
setFrame({ key: row.key });
|
||||
} else if (previous.row.key !== row.key) {
|
||||
const time = performance.now();
|
||||
setFrame({ previous: previous.row, key: row.key, duration: time - previous.time < 280 ? FAST : SLOW });
|
||||
last.current = { row, time };
|
||||
} else {
|
||||
// A tool's status or label can change without advancing the wheel.
|
||||
last.current = { ...previous, row };
|
||||
}
|
||||
}, [canRoll, row]);
|
||||
|
||||
const outgoing = canRoll && frame.key === row.key ? frame.previous : undefined;
|
||||
return (
|
||||
<div
|
||||
aria-hidden
|
||||
{...{ inert: "" }}
|
||||
data-testid="latest-activity-wheel"
|
||||
className="relative h-6 min-w-0 overflow-hidden pe-1 max-sm:ms-6 sm:flex-1 [mask-image:linear-gradient(transparent,black_10%,black_90%,transparent)] [&_[data-activity-marker]]:self-center [&_[data-activity-marker]]:items-center [&_[data-activity-marker]]:pt-0"
|
||||
>
|
||||
{canRoll ? <motion.div
|
||||
key={frame.key}
|
||||
initial={outgoing ? { y: "100%" } : false}
|
||||
animate={{ y: 0 }}
|
||||
transition={{ duration: outgoing ? frame.duration : 0, ease: [0.22, 0.7, 0.26, 1] }}
|
||||
onAnimationComplete={() => {
|
||||
if (outgoing) setFrame((current) => current === frame ? { key: frame.key } : current);
|
||||
}}
|
||||
>
|
||||
{outgoing ? <div className={`absolute inset-x-0 bottom-full ${rowClass}`}>{outgoing}</div> : null}
|
||||
<div className={rowClass}>{row}</div>
|
||||
</motion.div> : <div className={rowClass}>{row}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -11,6 +11,8 @@ interface ThinkingReasoningShellProps {
|
||||
collapseLabel?: string;
|
||||
contentId?: string;
|
||||
label: string;
|
||||
reservedLabel?: string;
|
||||
preview?: ReactNode;
|
||||
children: ReactNode;
|
||||
hasDetails?: boolean;
|
||||
onToggle: () => void;
|
||||
@@ -24,6 +26,8 @@ export function ThinkingReasoningShell({
|
||||
collapseLabel,
|
||||
contentId: providedContentId,
|
||||
label,
|
||||
reservedLabel,
|
||||
preview,
|
||||
children,
|
||||
hasDetails = true,
|
||||
onToggle,
|
||||
@@ -32,21 +36,30 @@ export function ThinkingReasoningShell({
|
||||
const contentId = providedContentId ?? generatedContentId;
|
||||
const [hasExpanded, setHasExpanded] = useState(expanded);
|
||||
if (expanded && !hasExpanded) setHasExpanded(true);
|
||||
const headerClassName = "touch-target inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-1.5";
|
||||
const headerClassName = cn(
|
||||
"touch-target inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-1.5",
|
||||
preview && "max-sm:self-start",
|
||||
);
|
||||
const labelClassName = "min-w-0 truncate text-[12px] font-normal leading-4";
|
||||
const headerLabel = (
|
||||
<span
|
||||
data-sheen-text={active ? label : undefined}
|
||||
className={cn(labelClassName, "text-muted-foreground", active && "streaming-text-sheen")}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
const headerContent = (
|
||||
<>
|
||||
<Activity className={cn("h-3.5 w-3.5 shrink-0", active ? "activity-current" : "text-muted-foreground")} strokeWidth={1.5} aria-hidden>
|
||||
{active ? <path className="activity-current-trace" pathLength={100} d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2" /> : null}
|
||||
</Activity>
|
||||
<span
|
||||
data-sheen-text={active ? label : undefined}
|
||||
className={cn(
|
||||
"min-w-0 truncate text-[12px] font-normal leading-4 text-muted-foreground",
|
||||
active && "streaming-text-sheen",
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
{reservedLabel ? (
|
||||
<span className="grid min-w-0 tabular-nums [&>span]:col-start-1 [&>span]:row-start-1">
|
||||
{headerLabel}
|
||||
<span className={cn(labelClassName, "invisible")} aria-hidden>{reservedLabel}</span>
|
||||
</span>
|
||||
) : headerLabel}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
@@ -57,7 +70,10 @@ export function ThinkingReasoningShell({
|
||||
data-block-context-rail={contextual && showHeader || undefined}
|
||||
data-block-context-expanded={contextual && expanded ? true : undefined}
|
||||
>
|
||||
{showHeader ? <div className="flex min-h-7 items-center gap-1.5">
|
||||
{showHeader ? <div className={cn(
|
||||
"flex min-h-7 items-center gap-1.5",
|
||||
preview && "max-sm:flex-col max-sm:items-stretch max-sm:gap-0",
|
||||
)}>
|
||||
{hasDetails ? (
|
||||
<button
|
||||
type="button"
|
||||
@@ -87,6 +103,7 @@ export function ThinkingReasoningShell({
|
||||
{headerContent}
|
||||
</div>
|
||||
)}
|
||||
{preview}
|
||||
</div> : null}
|
||||
|
||||
{hasDetails ? (
|
||||
|
||||
@@ -12,21 +12,9 @@ import {
|
||||
} from "@/components/thread/activity/web-search-model";
|
||||
|
||||
export function WebSearchRun({ run, turnActive }: { run: WebSearchRunModel; turnActive: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
const active = run.status === "running" && turnActive;
|
||||
const status = run.status === "running" && !turnActive ? "done" : run.status;
|
||||
const presentation = presentWebSearchAction(run.query, status, run.target, t);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ActivityStep
|
||||
icon={status === "error" ? AlertCircle : WebSearchIcon}
|
||||
active={active}
|
||||
tone={status === "error" ? "error" : status === "done" ? "success" : "active"}
|
||||
label={presentation.label}
|
||||
detail={presentation.detail}
|
||||
labelClassName={presentation.detail ? "max-w-[50%]" : undefined}
|
||||
/>
|
||||
<WebSearchActionRow run={run} turnActive={turnActive} />
|
||||
{run.sources.map((source) => (
|
||||
<WebActivityRow
|
||||
key={source.href}
|
||||
@@ -39,3 +27,21 @@ export function WebSearchRun({ run, turnActive }: { run: WebSearchRunModel; turn
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function WebSearchActionRow({ run, turnActive }: { run: WebSearchRunModel; turnActive: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
const active = run.status === "running" && turnActive;
|
||||
const status = run.status === "running" && !turnActive ? "done" : run.status;
|
||||
const presentation = presentWebSearchAction(run.query, status, run.target, t);
|
||||
|
||||
return (
|
||||
<ActivityStep
|
||||
icon={status === "error" ? AlertCircle : WebSearchIcon}
|
||||
active={active}
|
||||
tone={status === "error" ? "error" : status === "done" ? "success" : "active"}
|
||||
label={presentation.label}
|
||||
detail={presentation.detail}
|
||||
labelClassName={presentation.detail ? "max-w-[50%]" : undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -950,7 +950,7 @@
|
||||
"previewPlaceholder": "Where should we begin?",
|
||||
"process": "Activity display",
|
||||
"processHelp": "Choose how much detail appears as nanobot works.",
|
||||
"autoHelp": "Show progress while working; keep finished work compact.",
|
||||
"autoHelp": "Keep details collapsed by default. Show the latest activity while working.",
|
||||
"expandedHelp": "Keep activity details expanded by default.",
|
||||
"summaryHelp": "Show changed files and line counts.",
|
||||
"diffHelp": "Show code changes directly in the conversation.",
|
||||
@@ -1221,6 +1221,7 @@
|
||||
"defaultWorkspace": "Default workspace",
|
||||
"auto": "Auto",
|
||||
"default": "Default",
|
||||
"collapsed": "Collapsed",
|
||||
"expanded": "Expanded",
|
||||
"summary": "Summary",
|
||||
"diff": "Diff",
|
||||
|
||||
@@ -713,7 +713,7 @@
|
||||
"previewPlaceholder": "¿Por dónde empezamos?",
|
||||
"process": "Visualización de actividad",
|
||||
"processHelp": "Elige cuánto detalle se muestra mientras nanobot trabaja.",
|
||||
"autoHelp": "Muestra el progreso durante el trabajo y una vista compacta al terminar.",
|
||||
"autoHelp": "Mantén los detalles contraídos por defecto y muestra la actividad más reciente durante el trabajo.",
|
||||
"expandedHelp": "Mantén los detalles de actividad expandidos por defecto.",
|
||||
"summaryHelp": "Muestra los archivos modificados y el número de líneas.",
|
||||
"diffHelp": "Muestra los cambios de código directamente en la conversación.",
|
||||
@@ -830,6 +830,7 @@
|
||||
"unixSocket": "Socket Unix",
|
||||
"defaultWorkspace": "Espacio predeterminado",
|
||||
"auto": "Automático",
|
||||
"collapsed": "Contraído",
|
||||
"expanded": "Expandido",
|
||||
"default": "Predeterminado",
|
||||
"summary": "Resumen",
|
||||
|
||||
@@ -713,7 +713,7 @@
|
||||
"previewPlaceholder": "Par où commencer ?",
|
||||
"process": "Affichage de l’activité",
|
||||
"processHelp": "Choisissez le niveau de détail affiché pendant que nanobot travaille.",
|
||||
"autoHelp": "Affichez la progression en cours et gardez les activités terminées compactes.",
|
||||
"autoHelp": "Repliez les détails par défaut et affichez la dernière activité pendant le traitement.",
|
||||
"expandedHelp": "Gardez les détails de l’activité développés par défaut.",
|
||||
"summaryHelp": "Affichez les fichiers modifiés et le nombre de lignes.",
|
||||
"diffHelp": "Affichez les changements de code directement dans la conversation.",
|
||||
@@ -830,6 +830,7 @@
|
||||
"unixSocket": "Socket Unix",
|
||||
"defaultWorkspace": "Espace par défaut",
|
||||
"auto": "Automatique",
|
||||
"collapsed": "Replié",
|
||||
"expanded": "Développé",
|
||||
"default": "Par défaut",
|
||||
"summary": "Résumé",
|
||||
|
||||
@@ -713,7 +713,7 @@
|
||||
"previewPlaceholder": "Dari mana kita mulai?",
|
||||
"process": "Tampilan aktivitas",
|
||||
"processHelp": "Pilih seberapa banyak detail yang ditampilkan saat nanobot bekerja.",
|
||||
"autoHelp": "Tampilkan progres saat bekerja dan tampilan ringkas setelah selesai.",
|
||||
"autoHelp": "Ringkas detail secara default dan tampilkan aktivitas terbaru saat bekerja.",
|
||||
"expandedHelp": "Perluas detail aktivitas secara default.",
|
||||
"summaryHelp": "Tampilkan berkas yang diubah dan jumlah baris.",
|
||||
"diffHelp": "Tampilkan perubahan kode langsung dalam percakapan.",
|
||||
@@ -830,6 +830,7 @@
|
||||
"unixSocket": "Soket Unix",
|
||||
"defaultWorkspace": "Ruang kerja bawaan",
|
||||
"auto": "Otomatis",
|
||||
"collapsed": "Diringkas",
|
||||
"expanded": "Diperluas",
|
||||
"default": "Bawaan",
|
||||
"summary": "Ringkasan",
|
||||
|
||||
@@ -713,7 +713,7 @@
|
||||
"previewPlaceholder": "何から始めましょうか?",
|
||||
"process": "処理状況の表示",
|
||||
"processHelp": "nanobot の作業中に表示する詳細の量を選びます。",
|
||||
"autoHelp": "作業中は進捗を表示し、完了後はコンパクトにまとめます。",
|
||||
"autoHelp": "詳細は既定で折りたたみ、作業中は最新のアクティビティを表示します。",
|
||||
"expandedHelp": "処理の詳細を既定で展開します。",
|
||||
"summaryHelp": "変更されたファイルと行数を表示します。",
|
||||
"diffHelp": "コードの変更を会話内に直接表示します。",
|
||||
@@ -830,6 +830,7 @@
|
||||
"unixSocket": "Unix ソケット",
|
||||
"defaultWorkspace": "既定のワークスペース",
|
||||
"auto": "自動",
|
||||
"collapsed": "折りたたむ",
|
||||
"expanded": "展開",
|
||||
"default": "既定",
|
||||
"summary": "概要",
|
||||
|
||||
@@ -713,7 +713,7 @@
|
||||
"previewPlaceholder": "어디서부터 시작할까요?",
|
||||
"process": "활동 표시",
|
||||
"processHelp": "nanobot이 작업하는 동안 표시할 세부 정보의 양을 선택하세요.",
|
||||
"autoHelp": "작업 중에는 진행 상황을 표시하고, 완료 후에는 간결하게 표시합니다.",
|
||||
"autoHelp": "세부 정보는 기본으로 접고, 작업 중에는 최신 활동을 표시합니다.",
|
||||
"expandedHelp": "활동 세부 정보를 기본으로 펼쳐 둡니다.",
|
||||
"summaryHelp": "변경된 파일과 줄 수를 표시합니다.",
|
||||
"diffHelp": "코드 변경 내용을 대화에 바로 표시합니다.",
|
||||
@@ -830,6 +830,7 @@
|
||||
"unixSocket": "Unix 소켓",
|
||||
"defaultWorkspace": "기본 작업 공간",
|
||||
"auto": "자동",
|
||||
"collapsed": "접힘",
|
||||
"expanded": "펼침",
|
||||
"default": "기본값",
|
||||
"summary": "요약",
|
||||
|
||||
@@ -770,7 +770,7 @@
|
||||
"previewPlaceholder": "Por onde começamos?",
|
||||
"process": "Exibição de atividade",
|
||||
"processHelp": "Escolha o nível de detalhe exibido enquanto o nanobot trabalha.",
|
||||
"autoHelp": "Mostre o progresso durante o trabalho e uma visão compacta ao terminar.",
|
||||
"autoHelp": "Mantenha os detalhes recolhidos por padrão e mostre a atividade mais recente durante o trabalho.",
|
||||
"expandedHelp": "Mantenha os detalhes de atividade expandidos por padrão.",
|
||||
"summaryHelp": "Mostre os arquivos alterados e a contagem de linhas.",
|
||||
"diffHelp": "Mostre as alterações de código diretamente na conversa.",
|
||||
@@ -1040,6 +1040,7 @@
|
||||
"unixSocket": "Socket Unix",
|
||||
"defaultWorkspace": "Espaço de trabalho padrão",
|
||||
"auto": "Automático",
|
||||
"collapsed": "Recolhido",
|
||||
"expanded": "Expandido",
|
||||
"default": "Padrão",
|
||||
"summary": "Resumo",
|
||||
|
||||
@@ -713,7 +713,7 @@
|
||||
"previewPlaceholder": "Chúng ta nên bắt đầu từ đâu?",
|
||||
"process": "Hiển thị hoạt động",
|
||||
"processHelp": "Chọn mức độ chi tiết hiển thị khi nanobot làm việc.",
|
||||
"autoHelp": "Hiển thị tiến độ khi đang làm việc và thu gọn khi hoàn tất.",
|
||||
"autoHelp": "Mặc định thu gọn chi tiết và chỉ hiện hoạt động mới nhất khi đang làm việc.",
|
||||
"expandedHelp": "Mặc định mở rộng chi tiết hoạt động.",
|
||||
"summaryHelp": "Hiển thị các tệp đã thay đổi và số dòng.",
|
||||
"diffHelp": "Hiển thị thay đổi mã ngay trong cuộc trò chuyện.",
|
||||
@@ -830,6 +830,7 @@
|
||||
"unixSocket": "Socket Unix",
|
||||
"defaultWorkspace": "Không gian làm việc mặc định",
|
||||
"auto": "Tự động",
|
||||
"collapsed": "Thu gọn",
|
||||
"expanded": "Mở rộng",
|
||||
"default": "Mặc định",
|
||||
"summary": "Tóm tắt",
|
||||
|
||||
@@ -950,7 +950,7 @@
|
||||
"previewPlaceholder": "接下来,想聊点什么?",
|
||||
"process": "过程展示",
|
||||
"processHelp": "选择 nanobot 工作时展示多少细节。",
|
||||
"autoHelp": "工作时显示进度,结束后保持简洁。",
|
||||
"autoHelp": "默认收起明细,处理中显示最新一条。",
|
||||
"expandedHelp": "默认展开工具活动与子任务详情。",
|
||||
"summaryHelp": "显示修改文件和增删行数。",
|
||||
"diffHelp": "在对话中直接展示代码差异。",
|
||||
@@ -1221,6 +1221,7 @@
|
||||
"defaultWorkspace": "默认工作区",
|
||||
"auto": "自动",
|
||||
"default": "默认",
|
||||
"collapsed": "收起",
|
||||
"expanded": "展开",
|
||||
"summary": "概要",
|
||||
"diff": "修改内容",
|
||||
|
||||
@@ -713,7 +713,7 @@
|
||||
"previewPlaceholder": "接下來,想聊點什麼?",
|
||||
"process": "過程展示",
|
||||
"processHelp": "選擇 nanobot 工作時展示多少細節。",
|
||||
"autoHelp": "工作時顯示進度,結束後保持簡潔。",
|
||||
"autoHelp": "預設收合明細,處理中顯示最新一筆。",
|
||||
"expandedHelp": "預設展開工具活動與子任務詳情。",
|
||||
"summaryHelp": "顯示修改檔案和增刪行數。",
|
||||
"diffHelp": "在對話中直接展示程式碼差異。",
|
||||
@@ -830,6 +830,7 @@
|
||||
"unixSocket": "Unix 通訊端",
|
||||
"defaultWorkspace": "預設工作區",
|
||||
"auto": "自動",
|
||||
"collapsed": "收合",
|
||||
"expanded": "展開",
|
||||
"default": "預設",
|
||||
"summary": "概要",
|
||||
|
||||
@@ -8,6 +8,10 @@ import { setAppLanguage } from "@/i18n";
|
||||
import { DEFAULT_LOCAL_PREFS, LOCAL_PREFS_STORAGE_KEY, writeLocalPreferences } from "@/lib/local-preferences";
|
||||
import type { CliAppInfo, McpPresetInfo, UIMessage } from "@/lib/types";
|
||||
|
||||
function openLiveActivity() {
|
||||
fireEvent.click(screen.getByRole("button", { name: /^Working for / }));
|
||||
}
|
||||
|
||||
// These DOM tests exercise disclosure/source contracts; the real shadow renderer runs in browser tests.
|
||||
vi.mock("@/components/thread/activity/DiffSyntaxHighlight", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("@/components/thread/activity/DiffSyntaxHighlight")>();
|
||||
@@ -126,6 +130,7 @@ describe("AgentActivityCluster", () => {
|
||||
<AgentActivityCluster messages={messages} isTurnStreaming hasBodyBelow={false} />
|
||||
</ExecSessionCommandsContext.Provider>,
|
||||
);
|
||||
openLiveActivity();
|
||||
const rows = screen.getAllByTestId("activity-step").map((row) => row.textContent);
|
||||
expect(rows).toEqual([
|
||||
"Command was still running at the last check npm test --token ••••",
|
||||
@@ -144,6 +149,7 @@ describe("AgentActivityCluster", () => {
|
||||
traces: [line, legacy], createdAt: 1, toolEvents: [{ name: "exec_session", call_id: "check",
|
||||
arguments: { session_id: id }, phase: "end", result: "Exit code: 0\nElapsed: 2.0s" }] };
|
||||
render(<AgentActivityCluster messages={[message]} isTurnStreaming hasBodyBelow={false} />);
|
||||
openLiveActivity();
|
||||
expect(screen.getAllByTestId("activity-step").map((row) => row.textContent)).toEqual([
|
||||
"Command completed", "Reading file later.txt",
|
||||
]);
|
||||
@@ -160,6 +166,7 @@ describe("AgentActivityCluster", () => {
|
||||
{ name: "exec_session", call_id: "check-2", arguments: { session_id: id }, phase: "end", result: "Exit code: 0\nElapsed: 2.0s" },
|
||||
] };
|
||||
render(<AgentActivityCluster messages={[message]} isTurnStreaming hasBodyBelow={false} />);
|
||||
openLiveActivity();
|
||||
expect(screen.getAllByTestId("activity-step").map((row) => row.textContent)).toEqual([
|
||||
"Command was still running at the last check", "Command completed", "Reading file later.txt",
|
||||
]);
|
||||
@@ -195,6 +202,7 @@ describe("AgentActivityCluster", () => {
|
||||
</ExecSessionCommandsContext.Provider>;
|
||||
};
|
||||
const { rerender, container } = render(view(10));
|
||||
openLiveActivity();
|
||||
expect(screen.getAllByTestId("activity-step")).toHaveLength(5);
|
||||
expect(container).toHaveTextContent("Sent input test-a");
|
||||
expect(container).toHaveTextContent("Could not check command test-b");
|
||||
@@ -230,9 +238,9 @@ describe("AgentActivityCluster", () => {
|
||||
expect(container.innerHTML).not.toContain(id);
|
||||
});
|
||||
|
||||
it("honors the activity preference for standalone completed activity with manual overrides", () => {
|
||||
render(<AgentActivityCluster messages={activityMessages()} isTurnStreaming={false} hasBodyBelow={false} />);
|
||||
const disclosure = screen.getByRole("button", { name: /Worked/ });
|
||||
it.each([false, true])("honors the activity preference and manual overrides (streaming: %s)", (isTurnStreaming) => {
|
||||
render(<AgentActivityCluster messages={activityMessages()} isTurnStreaming={isTurnStreaming} hasBodyBelow={false} />);
|
||||
const disclosure = screen.getByRole("button", { name: /^(Working|Worked)/ });
|
||||
expect(disclosure).toHaveAttribute("aria-expanded", "false");
|
||||
act(() => { writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, activityMode: "expanded" }); });
|
||||
expect(disclosure).toHaveAttribute("aria-expanded", "true");
|
||||
@@ -288,6 +296,7 @@ describe("AgentActivityCluster", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
openLiveActivity();
|
||||
expect(screen.getByText(`Searched files “${query}”`)).toBeInTheDocument();
|
||||
expect(screen.getByText(`Reading file ${path}`)).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Using Blender, --json --background scene.blend")).toBeInTheDocument();
|
||||
@@ -416,6 +425,7 @@ describe("AgentActivityCluster", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
openLiveActivity();
|
||||
const block = screen.getByTestId("activity-model-message");
|
||||
await waitFor(() => expect(block.querySelector("strong")).not.toBeNull());
|
||||
expect(block.querySelector("strong")).toHaveTextContent("partial answer");
|
||||
@@ -433,6 +443,7 @@ describe("AgentActivityCluster", () => {
|
||||
};
|
||||
const view = render(<AgentActivityCluster {...props} />);
|
||||
const header = screen.getByRole("button", { name: /^(Working|Worked)/ });
|
||||
if (isTurnStreaming) fireEvent.click(header);
|
||||
const content = screen.getByTestId("agent-activity-content");
|
||||
|
||||
expect(header).toHaveClass("h-7", "gap-1.5", "px-1.5");
|
||||
@@ -474,6 +485,7 @@ describe("AgentActivityCluster", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
openLiveActivity();
|
||||
expect(screen.getByTestId("activity-reasoning-marker")).toHaveAttribute("data-state", "thinking");
|
||||
|
||||
rerender(
|
||||
@@ -494,8 +506,7 @@ describe("AgentActivityCluster", () => {
|
||||
await waitFor(() => expect(marker).toHaveClass("animate-in"));
|
||||
});
|
||||
|
||||
it("briefly shows completed activity, then auto-collapses before the answer", () => {
|
||||
vi.useFakeTimers();
|
||||
it("keeps untouched live details folded when work completes", () => {
|
||||
const liveReasoning: UIMessage = {
|
||||
id: "r-collapse",
|
||||
role: "assistant",
|
||||
@@ -505,40 +516,25 @@ describe("AgentActivityCluster", () => {
|
||||
isStreaming: true,
|
||||
createdAt: 1,
|
||||
};
|
||||
try {
|
||||
const { rerender } = render(
|
||||
<AgentActivityCluster
|
||||
messages={[liveReasoning]}
|
||||
isTurnStreaming
|
||||
hasBodyBelow
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByTestId("agent-activity-content")).toBeInTheDocument();
|
||||
const { rerender } = render(
|
||||
<AgentActivityCluster messages={[liveReasoning]} isTurnStreaming hasBodyBelow />,
|
||||
);
|
||||
expect(screen.getByRole("button", { name: /^Working for / })).toHaveAttribute("aria-expanded", "false");
|
||||
expect(screen.getByTestId("latest-activity-wheel")).toHaveTextContent("checking files");
|
||||
|
||||
rerender(
|
||||
<AgentActivityCluster
|
||||
messages={[{
|
||||
...liveReasoning,
|
||||
reasoningStreaming: false,
|
||||
isStreaming: false,
|
||||
}]}
|
||||
isTurnStreaming={false}
|
||||
hasBodyBelow
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByTestId("agent-activity-content")).toBeInTheDocument();
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(301);
|
||||
});
|
||||
expect(screen.queryByTestId("agent-activity-content")).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Worked" })).toHaveAttribute(
|
||||
"aria-expanded",
|
||||
"false",
|
||||
);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
rerender(
|
||||
<AgentActivityCluster
|
||||
messages={[{ ...liveReasoning, reasoningStreaming: false, isStreaming: false }]}
|
||||
isTurnStreaming={false}
|
||||
hasBodyBelow
|
||||
/>,
|
||||
);
|
||||
expect(screen.queryByTestId("latest-activity-wheel")).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId("agent-activity-content")).not.toBeInTheDocument();
|
||||
const disclosure = screen.getByRole("button", { name: "Worked" });
|
||||
expect(disclosure).toHaveAttribute("aria-expanded", "false");
|
||||
fireEvent.click(disclosure);
|
||||
expect(screen.getByTestId("agent-activity-content")).toHaveTextContent("checking files");
|
||||
});
|
||||
|
||||
|
||||
@@ -691,6 +687,7 @@ describe("AgentActivityCluster", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
openLiveActivity();
|
||||
assertBetween(screen.getByRole("img", { name: "Editing" }));
|
||||
|
||||
rerender(
|
||||
@@ -1323,6 +1320,7 @@ describe("AgentActivityCluster", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
openLiveActivity();
|
||||
const searchRow = screen.getByLabelText("Searched the web, nanobot architecture").closest('[data-testid="activity-step"]');
|
||||
const cliRow = screen.getByLabelText("Used Blender, --json project new").closest('[data-testid="activity-step"]');
|
||||
const fetchRow = screen.getByText("example.com/diagram").closest('[data-testid="activity-step"]');
|
||||
@@ -1369,6 +1367,7 @@ describe("AgentActivityCluster", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
openLiveActivity();
|
||||
expect(screen.getByLabelText("Searched the web, agent frameworks")).toBeInTheDocument();
|
||||
expect(screen.queryByText("2 sources")).not.toBeInTheDocument();
|
||||
|
||||
@@ -1732,6 +1731,7 @@ describe("AgentActivityCluster", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
openLiveActivity();
|
||||
expect(screen.getByText("File search complete *.tsx")).toBeInTheDocument();
|
||||
expect(screen.getByText("Listed files memory")).toBeInTheDocument();
|
||||
expect(screen.getByText("Searching files “dream_cursor”")).toBeInTheDocument();
|
||||
@@ -1760,6 +1760,7 @@ describe("AgentActivityCluster", () => {
|
||||
const view = render(
|
||||
<AgentActivityCluster messages={messages} isTurnStreaming hasBodyBelow={false} />,
|
||||
);
|
||||
openLiveActivity();
|
||||
const header = screen.getByText(/^Working for /);
|
||||
expect(header).toHaveAttribute("data-sheen-text", header.textContent);
|
||||
const tool = screen.getByText("Read file skills/weather/SKILL.md");
|
||||
@@ -2304,6 +2305,7 @@ describe("AgentActivityCluster", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
||||
expect(screen.getByText("Generated image")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("img", { name: "generated.png" })).not.toBeInTheDocument();
|
||||
});
|
||||
@@ -2461,6 +2463,9 @@ describe("AgentActivityCluster", () => {
|
||||
expect(container.innerHTML).not.toContain("sk-proj-1234567890-secret");
|
||||
expect(container.innerHTML).not.toContain("private-payload");
|
||||
expect(container.textContent).not.toMatch(/run_cli_app\(|browser_fill\(|third_party_sync\(/);
|
||||
openLiveActivity();
|
||||
expect(container.innerHTML).not.toMatch(/xoxb-1234567890-secret|mcp-private-value|sk-proj-1234567890-secret|private-payload/);
|
||||
expect(container.textContent).not.toMatch(/run_cli_app\(|browser_fill\(|third_party_sync\(/);
|
||||
expect(container.textContent).toMatch(/<redacted>|••••/);
|
||||
});
|
||||
});
|
||||
@@ -212,6 +212,7 @@ const LOCALIZED_SETTINGS_COPY_KEYS = [
|
||||
"settings.help.webuiDefaultAccess",
|
||||
"settings.values.light",
|
||||
"settings.values.dark",
|
||||
"settings.values.collapsed",
|
||||
"settings.values.expanded",
|
||||
"settings.values.enabled",
|
||||
"settings.values.disabled",
|
||||
|
||||
@@ -418,7 +418,7 @@ describe("ThreadMessages", () => {
|
||||
);
|
||||
|
||||
expect(screen.getByText("I will check that.")).toBe(paragraph);
|
||||
expect(screen.getByText(/working/i)).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: /^Working for / })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("projects a turn in causal order independently of streaming state", () => {
|
||||
@@ -717,8 +717,8 @@ describe("ThreadMessages", () => {
|
||||
...messages,
|
||||
{ id: "tool", role: "tool", kind: "trace", content: "web_search(query)", turnId: "automation", createdAt: now },
|
||||
]} isStreaming activeTurnId="automation" runStartedAt={(now - 3_000) / 1000} />);
|
||||
expect(screen.getByTestId("agent-activity-content")).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: /^Working for 3s/ })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Working for 3s" })).toHaveAttribute("aria-expanded", "false");
|
||||
expect(screen.getByTestId("latest-activity-wheel")).toBeInTheDocument();
|
||||
expect(screen.queryByTestId("activity-reasoning-marker")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -1502,6 +1502,7 @@ describe("ThreadMessages", () => {
|
||||
|
||||
render(<ThreadMessages messages={messages} isStreaming />);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: /^Working for / }));
|
||||
expect(screen.getByLabelText(/editing foo\.txt/i)).toBeInTheDocument();
|
||||
expect(screen.queryByLabelText(/edited foo\.txt/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user