fix(webui): hide live activity timer on narrow screens
This commit is contained in:
1 parent
5537bdabd3
commit
b9b491e74c
6 files changed
+95
-96
No files matched your search
@@ -55,6 +55,7 @@ import { formControlFocusClassName } from "@/components/ui/form-control";
|
||||
import { useFileEditDisplayMode } from "@/hooks/useFileEditDisplayMode";
|
||||
import { useLocalPreferences } from "@/hooks/useLocalPreferences";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import { useMediaQuery } from "@/hooks/useMediaQuery";
|
||||
import { usePageVisibility } from "@/hooks/usePageVisibility";
|
||||
import { useThreadVisibility } from "@/hooks/useThreadVisibility";
|
||||
import type { FileEditDisplayMode } from "@/lib/local-preferences";
|
||||
@@ -251,6 +252,7 @@ function FoldedAgentActivity({
|
||||
}: AgentActivityClusterProps) {
|
||||
const { t } = useTranslation();
|
||||
const { activityMode, fileEditDisplayMode } = useLocalPreferences();
|
||||
const mobile = useMediaQuery("(max-width: 639px)");
|
||||
const pageVisible = usePageVisibility();
|
||||
const threadVisible = useThreadVisibility();
|
||||
const activityMessages = useMemo(() => coalesceActivityMessages(messages), [messages]);
|
||||
@@ -322,6 +324,11 @@ function FoldedAgentActivity({
|
||||
);
|
||||
const activityDuration = formatActivityDuration(durationMs);
|
||||
const showActivityPreview = isTurnStreaming && hasVisibleActivity && !outerExpanded && !hideHeader && !retryStatus;
|
||||
const preview = useMemo(() => {
|
||||
if (!showActivityPreview) return null;
|
||||
const row = latestActivityRow(activityMessages, fileEditsByMessage, cliAppsByName, mcpPresetsByName);
|
||||
return row ? <LatestActivityWheel row={row} visible={pageVisible && threadVisible} /> : null;
|
||||
}, [showActivityPreview, activityMessages, fileEditsByMessage, cliAppsByName, mcpPresetsByName, pageVisible, threadVisible]);
|
||||
const workingLabel = (duration: string) => t("message.activityWorkingFor", {
|
||||
duration,
|
||||
defaultValue: "Working for {{duration}}",
|
||||
@@ -356,7 +363,7 @@ function FoldedAgentActivity({
|
||||
defaultValue: "{{error}} Retrying",
|
||||
})
|
||||
: isTurnStreaming
|
||||
? workingLabel(activityDuration)
|
||||
? mobile ? t("message.agentActivity.working") : workingLabel(activityDuration)
|
||||
: durationMs <= 0
|
||||
? t("message.activityWorked", { defaultValue: "Worked" })
|
||||
: t("message.activityWorkedFor", {
|
||||
@@ -409,15 +416,8 @@ function FoldedAgentActivity({
|
||||
collapseLabel={t("message.collapseActivity")}
|
||||
contentId={detailsId}
|
||||
label={activityLabel}
|
||||
preview={showActivityPreview ? (
|
||||
<CollapsedActivityPreview
|
||||
messages={activityMessages}
|
||||
fileEditsByMessage={fileEditsByMessage}
|
||||
cliAppsByName={cliAppsByName}
|
||||
mcpPresetsByName={mcpPresetsByName}
|
||||
visible={pageVisible && threadVisible}
|
||||
/>
|
||||
) : undefined}
|
||||
preview={preview}
|
||||
compactPreview={mobile && preview !== null}
|
||||
hasDetails={hasVisibleActivity}
|
||||
onToggle={toggleOuter}
|
||||
>
|
||||
@@ -501,61 +501,54 @@ 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} />;
|
||||
function latestActivityRow(
|
||||
messages: UIMessage[],
|
||||
fileEditsByMessage: Map<string, FileEditSummary[]>,
|
||||
cliAppsByName: Map<string, CliAppInfo>,
|
||||
mcpPresetsByName: Map<string, McpPresetInfo>,
|
||||
) {
|
||||
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} />;
|
||||
}
|
||||
return null;
|
||||
}, [messages, fileEditsByMessage, cliAppsByName, mcpPresetsByName]);
|
||||
|
||||
return row ? <LatestActivityWheel row={row} visible={visible} /> : null;
|
||||
});
|
||||
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;
|
||||
}
|
||||
|
||||
const ActivityMessageTimeline = memo(function ActivityMessageTimeline({
|
||||
messages,
|
||||
|
||||
@@ -34,7 +34,7 @@ export function LatestActivityWheel({ row, visible }: { row: ReactElement; visib
|
||||
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"
|
||||
className="relative h-6 min-w-0 overflow-hidden pe-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}
|
||||
|
||||
@@ -12,6 +12,7 @@ interface ThinkingReasoningShellProps {
|
||||
contentId?: string;
|
||||
label: string;
|
||||
preview?: ReactNode;
|
||||
compactPreview?: boolean;
|
||||
children: ReactNode;
|
||||
hasDetails?: boolean;
|
||||
onToggle: () => void;
|
||||
@@ -26,6 +27,7 @@ export function ThinkingReasoningShell({
|
||||
contentId: providedContentId,
|
||||
label,
|
||||
preview,
|
||||
compactPreview = false,
|
||||
children,
|
||||
hasDetails = true,
|
||||
onToggle,
|
||||
@@ -36,7 +38,7 @@ export function ThinkingReasoningShell({
|
||||
if (expanded && !hasExpanded) setHasExpanded(true);
|
||||
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",
|
||||
compactPreview && "col-start-1 row-start-1",
|
||||
);
|
||||
const labelClassName = "min-w-0 truncate text-[12px] font-normal leading-4 tabular-nums";
|
||||
const headerLabel = (
|
||||
@@ -52,7 +54,7 @@ export function ThinkingReasoningShell({
|
||||
<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>
|
||||
{headerLabel}
|
||||
{!compactPreview && headerLabel}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
@@ -64,8 +66,8 @@ export function ThinkingReasoningShell({
|
||||
data-block-context-expanded={contextual && expanded ? true : undefined}
|
||||
>
|
||||
{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",
|
||||
"min-h-7 items-center",
|
||||
compactPreview ? "grid grid-cols-1" : "flex gap-1.5",
|
||||
)}>
|
||||
{hasDetails ? (
|
||||
<button
|
||||
@@ -96,7 +98,11 @@ export function ThinkingReasoningShell({
|
||||
{headerContent}
|
||||
</div>
|
||||
)}
|
||||
{preview}
|
||||
{preview ? (
|
||||
<div className={cn("min-w-0 flex-1", compactPreview && "pointer-events-none col-start-1 row-start-1 ms-7")}>
|
||||
{preview}
|
||||
</div>
|
||||
) : null}
|
||||
</div> : null}
|
||||
|
||||
{hasDetails ? (
|
||||
|
||||
Reference in new issue
Block a user