refactor(ui): replace middle-dot separators with clearer hierarchy (#6087)
* refactor(ui): replace middle-dot separators with clearer hierarchy * refactor(ui): use layout instead of punctuation separators
This commit is contained in:
1 parent
d6ddceed99
commit
7cb396788c
82 files changed
+433
-462
No files matched your search
@@ -346,14 +346,14 @@ function FoldedAgentActivity({
|
||||
const activityLabel = retryStatus?.state === "exhausted"
|
||||
? t("message.retryExhausted", {
|
||||
error: retryError,
|
||||
defaultValue: "{{error}} · ending turn",
|
||||
defaultValue: "{{error}}. Ending turn.",
|
||||
})
|
||||
: retryStatus?.state === "waiting"
|
||||
? t("message.retryWaiting", {
|
||||
error: retryError,
|
||||
seconds: retrySeconds,
|
||||
attempt: retryAttempt,
|
||||
defaultValue: "{{error}} · retrying in {{seconds}}s · attempt {{attempt}}",
|
||||
defaultValue: "{{error}}. Retrying in {{seconds}}s (attempt {{attempt}}).",
|
||||
})
|
||||
: isTurnStreaming
|
||||
? t("message.activityWorkingFor", {
|
||||
@@ -828,7 +828,9 @@ function ActivityTraceRow({
|
||||
icon={Icon}
|
||||
active={rowActive && trace.kind !== "done"}
|
||||
tone={status === "error" ? "error" : status === "done" ? "success" : "active"}
|
||||
label={formatActivityTarget(t, trace.label, trace.detail)}
|
||||
label={trace.kind === "search" ? trace.label : formatActivityTarget(t, trace.label, trace.detail)}
|
||||
detail={trace.kind === "search" ? trace.detail : trace.aside}
|
||||
detailClassName={trace.kind === "search" ? "whitespace-pre-line" : undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1251,16 +1253,18 @@ function CliRunRow({ run, active, app }: { run: CliRunSummary; active: boolean;
|
||||
const logoUrls = useMemo(() => logoFallbackUrls(app?.logo_url), [app?.logo_url]);
|
||||
const { logoUrl, onLogoError, onLogoLoad } = useLogoFallback(logoUrls);
|
||||
const displayName = app?.display_name || titleFromPresetName(run.name);
|
||||
const label = `${t(
|
||||
const label = t(
|
||||
`message.${failed ? "cliActivityFailedOne" : rowActive ? "cliActivityRunningOne" : "cliActivityRanOne"}`,
|
||||
{ name: displayName },
|
||||
)}${args ? ` · ${args}` : ""}`;
|
||||
);
|
||||
|
||||
return (
|
||||
<ActivityStep
|
||||
active={rowActive}
|
||||
tone={failed ? "error" : rowActive ? "active" : run.status === "done" ? "success" : "neutral"}
|
||||
label={label}
|
||||
detail={args}
|
||||
detailClassName="font-mono text-[12px]"
|
||||
marker={(
|
||||
<span
|
||||
data-testid={`activity-cli-logo-${run.name.toLowerCase()}`}
|
||||
@@ -1334,13 +1338,14 @@ function McpRunRow({ run, active, preset }: { run: McpRunSummary; active: boolea
|
||||
failed ? "error" : rowActive ? "running" : "done",
|
||||
t,
|
||||
);
|
||||
const label = `${formatActivityTarget(t, activity.action, activity.target ?? "")} · ${displayName}`;
|
||||
const label = formatActivityTarget(t, activity.action, activity.target ?? "");
|
||||
|
||||
return (
|
||||
<ActivityStep
|
||||
active={rowActive}
|
||||
tone={failed ? "error" : rowActive ? "active" : run.status === "done" ? "success" : "neutral"}
|
||||
label={label}
|
||||
detail={displayName}
|
||||
marker={(
|
||||
<span
|
||||
data-testid={`activity-mcp-logo-${run.presetName.toLowerCase()}`}
|
||||
|
||||
@@ -129,11 +129,11 @@ export function ModelPresetBadge({
|
||||
model: modelDetail ?? modelPresets[listedIndex]?.model,
|
||||
provider: provider || modelPresets[listedIndex]?.provider,
|
||||
};
|
||||
const tooltipLabel = needsSetup ? label : [...new Set([
|
||||
const tooltipParts = needsSetup ? [label] : [...new Set([
|
||||
label,
|
||||
modelDetail,
|
||||
providerLabel,
|
||||
].filter(Boolean))].join(" · ");
|
||||
].filter((part): part is string => Boolean(part)))];
|
||||
const presets = !activeName
|
||||
? modelPresets
|
||||
: listedIndex < 0
|
||||
@@ -459,9 +459,11 @@ export function ModelPresetBadge({
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip open={tooltipLabel !== label && tooltipOpen && !open && !motion} onOpenChange={setTooltipOpen}>
|
||||
<Tooltip open={tooltipParts.length > 1 && tooltipOpen && !open && !motion} onOpenChange={setTooltipOpen}>
|
||||
{badge}
|
||||
<TooltipContent side="top">{tooltipLabel}</TooltipContent>
|
||||
<TooltipContent side="top" className="max-w-[min(24rem,calc(100vw-2rem))] space-y-1 break-words">
|
||||
{tooltipParts.map((part, index) => <p key={part} className={index === 0 ? "font-medium" : "text-xs text-muted-foreground"}>{part}{index < tooltipParts.length - 1 ? " " : ""}</p>)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
);
|
||||
|
||||
@@ -186,7 +186,7 @@ export function SubagentTasksProvider({ client, sessionKey, token, enabled, live
|
||||
<SheetDescription className="flex items-center gap-2">
|
||||
{selected ? <><TaskStateIcon task={selected} />
|
||||
<span className={selected.state === "done" ? "sr-only" : undefined}>{t(`thread.subagents.states.${selected.state}`)}</span>
|
||||
<span className="tabular-nums">{selected.state !== "done" ? "· " : null}<TaskElapsed task={selected} /></span></> : null}
|
||||
<span className="tabular-nums"><TaskElapsed task={selected} /></span></> : null}
|
||||
</SheetDescription>
|
||||
</div>
|
||||
{selected && sessionKey ? <div className="min-h-0 flex-1 overflow-y-auto overscroll-contain py-5">
|
||||
@@ -313,9 +313,10 @@ function SubagentWork({ tasks, unlinked = false }: { tasks: ObservedSubagentTask
|
||||
className="flex w-full items-center gap-2.5 px-3 py-2.5 text-left text-xs text-muted-foreground hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring">
|
||||
<DelegationIcon className="h-3.5 w-3.5 shrink-0" aria-hidden />
|
||||
<span className="font-medium">{title}</span>
|
||||
<span className="ml-auto min-w-0 text-right">
|
||||
{summary}{activeCount ? ` · ${t("thread.subagents.running", { count: activeCount })}` : ""}
|
||||
{failedCount ? <span className="ml-2 text-destructive">{t("thread.subagents.needsReview", { count: failedCount })}</span> : null}
|
||||
<span className="ml-auto flex min-w-0 flex-wrap justify-end gap-x-2 text-right">
|
||||
<span>{summary}</span>{" "}
|
||||
{activeCount ? <span>{t("thread.subagents.running", { count: activeCount })}</span> : null}
|
||||
{failedCount ? <span className="text-destructive">{t("thread.subagents.needsReview", { count: failedCount })}</span> : null}
|
||||
</span>
|
||||
<ChevronDown className={`h-3.5 w-3.5 shrink-0 transition-transform ${open ? "rotate-180" : ""}`} aria-hidden />
|
||||
</button>
|
||||
|
||||
@@ -12,6 +12,8 @@ export interface ActivityStepProps {
|
||||
marker?: ReactNode;
|
||||
showMarker?: boolean;
|
||||
label: ReactNode;
|
||||
detail?: string;
|
||||
detailClassName?: string;
|
||||
tooltipContent?: ReactNode;
|
||||
ariaLabel?: string;
|
||||
active?: boolean;
|
||||
@@ -29,6 +31,8 @@ export function ActivityStep({
|
||||
marker,
|
||||
showMarker = true,
|
||||
label,
|
||||
detail,
|
||||
detailClassName,
|
||||
tooltipContent,
|
||||
ariaLabel,
|
||||
active = false,
|
||||
@@ -42,11 +46,13 @@ export function ActivityStep({
|
||||
}: ActivityStepProps) {
|
||||
const lineRef = useRef<HTMLDivElement>(null);
|
||||
const [hintOpen, setHintOpen] = useState(false);
|
||||
const textLabel = typeof label === "string" ? [label, detail].filter(Boolean).join("\n") : undefined;
|
||||
const line = (
|
||||
<div
|
||||
ref={lineRef}
|
||||
data-testid="activity-line"
|
||||
tabIndex={typeof label === "string" ? 0 : undefined}
|
||||
aria-label={detail && typeof label === "string" ? `${label}, ${detail}` : undefined}
|
||||
className="flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap"
|
||||
>
|
||||
<StreamingLabelSheen
|
||||
@@ -57,7 +63,12 @@ export function ActivityStep({
|
||||
labelClassName,
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
{detail ? (
|
||||
<span className="flex min-w-0 items-baseline gap-2">
|
||||
<span className="max-w-[70%] shrink-0 truncate">{label}</span>{" "}
|
||||
<span className={cn("min-w-0 flex-1 truncate font-normal text-muted-foreground", detailClassName)}>{detail}</span>
|
||||
</span>
|
||||
) : label}
|
||||
</StreamingLabelSheen>
|
||||
</div>
|
||||
);
|
||||
@@ -99,11 +110,11 @@ export function ActivityStep({
|
||||
<Tooltip open={hintOpen} onOpenChange={(open) => {
|
||||
const truncated = Array.from(lineRef.current?.querySelectorAll<HTMLElement>(".truncate") ?? [])
|
||||
.some((element) => element.scrollWidth > element.clientWidth);
|
||||
setHintOpen(open && (truncated || tooltipContent !== undefined && tooltipContent !== label));
|
||||
setHintOpen(open && (truncated || tooltipContent !== undefined && tooltipContent !== textLabel));
|
||||
}}>
|
||||
<TooltipTrigger asChild>{line}</TooltipTrigger>
|
||||
<TooltipContent side="top" className="max-w-[min(32rem,calc(100vw-2rem))] whitespace-pre-wrap break-words">
|
||||
{tooltipContent ?? label}
|
||||
{tooltipContent ?? textLabel}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
||||
@@ -37,14 +37,14 @@ export function GenericToolRun({ items }: { items: GenericToolRunItem[] }) {
|
||||
const { t } = useTranslation();
|
||||
const model = useMemo(() => buildModel(items, t), [items, t]);
|
||||
const action = formatActivityTarget(t, model.label, model.detail);
|
||||
const label = model.aside ? `${action} · ${model.aside}` : action;
|
||||
|
||||
return (
|
||||
<ActivityStep
|
||||
icon={model.status === "error" ? AlertCircle : model.icon}
|
||||
active={model.status === "running"}
|
||||
tone={model.status === "error" ? "error" : model.status === "done" ? "success" : "active"}
|
||||
label={label}
|
||||
label={action}
|
||||
detail={model.aside}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export function ThinkingReasoningShell({
|
||||
onClick={onToggle}
|
||||
aria-expanded={expanded}
|
||||
aria-controls={contentId}
|
||||
aria-label={expanded && collapseLabel ? `${label} · ${collapseLabel}` : label}
|
||||
aria-label={expanded && collapseLabel ? `${label}, ${collapseLabel}` : label}
|
||||
aria-live={active ? "polite" : undefined}
|
||||
>
|
||||
{headerContent}
|
||||
|
||||
@@ -32,7 +32,7 @@ export function WebActivityRow({
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
aria-label={`${title} · ${displayUrl}`}
|
||||
aria-label={`${title}, ${displayUrl}`}
|
||||
className="flex min-w-0 items-center gap-2 overflow-hidden text-foreground/82 hover:text-foreground"
|
||||
>
|
||||
<span className="min-w-0 truncate font-medium">{title}</span>
|
||||
|
||||
@@ -15,7 +15,7 @@ export function WebSearchRun({ run, turnActive }: { run: WebSearchRunModel; turn
|
||||
const { t } = useTranslation();
|
||||
const active = run.status === "running" && turnActive;
|
||||
const status = run.status === "running" && !turnActive ? "done" : run.status;
|
||||
const label = presentWebSearchAction(run.query, status, run.target, t);
|
||||
const presentation = presentWebSearchAction(run.query, status, run.target, t);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -23,7 +23,9 @@ export function WebSearchRun({ run, turnActive }: { run: WebSearchRunModel; turn
|
||||
icon={status === "error" ? AlertCircle : WebSearchIcon}
|
||||
active={active}
|
||||
tone={status === "error" ? "error" : status === "done" ? "success" : "active"}
|
||||
label={label}
|
||||
label={presentation.label}
|
||||
detail={presentation.detail}
|
||||
detailClassName="whitespace-pre-line"
|
||||
/>
|
||||
{run.sources.map((source) => (
|
||||
<WebActivityRow
|
||||
|
||||
@@ -56,16 +56,17 @@ export function formatActivityTarget(t: TFunction, action: string, target: strin
|
||||
: action;
|
||||
}
|
||||
|
||||
export function summarizeShellCommand(command: string, t: TFunction): string {
|
||||
export function summarizeShellCommand(command: string, t: TFunction): { detail: string; aside?: string } {
|
||||
const lines = redactShellCommand(command.replace(/\r\n/g, "\n"))
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean);
|
||||
const firstLine = compactActivityPath(lines[0] || t("message.agentActivity.command"));
|
||||
const firstPreview = truncateMiddle(firstLine, 92);
|
||||
return lines.length <= 1
|
||||
? firstPreview
|
||||
: `${firstPreview} · ${t("message.agentActivity.scriptLines", { count: lines.length })}`;
|
||||
return {
|
||||
detail: firstPreview,
|
||||
...(lines.length > 1 ? { aside: t("message.agentActivity.scriptLines", { count: lines.length }) } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function truncateMiddle(value: string, maxLength: number): string {
|
||||
|
||||
@@ -9,6 +9,7 @@ export interface TraceDescription {
|
||||
kind: "search" | "tool" | "done" | "trace";
|
||||
label: string;
|
||||
detail: string;
|
||||
aside?: string;
|
||||
icon?: "clock";
|
||||
url?: string;
|
||||
host?: string;
|
||||
@@ -33,8 +34,7 @@ export function describeTraceLine(
|
||||
const query = traceFieldFromArgs(args, ["query", "q", "text"]) || args;
|
||||
return {
|
||||
kind: "search",
|
||||
label: presentWebSearchAction(query, status, name === "x_search" ? "x" : "web", t),
|
||||
detail: "",
|
||||
...presentWebSearchAction(query, status, name === "x_search" ? "x" : "web", t),
|
||||
};
|
||||
}
|
||||
if (/fetch|read|open/i.test(name) || plainWebReadTrace) {
|
||||
@@ -108,7 +108,7 @@ function describeShellTrace(
|
||||
return {
|
||||
kind: "tool",
|
||||
label: activityStatus(t, status, "runningCommand", "ranCommand", "commandFailed"),
|
||||
detail: summarizeShellCommand(command, t),
|
||||
...summarizeShellCommand(command, t),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -78,12 +78,13 @@ function presentWebSearchQuery(query: string): WebSearchQueryPresentation {
|
||||
const scopes: string[] = [];
|
||||
const safeQuery = redactActivityText(query);
|
||||
const cleanQuery = safeQuery
|
||||
.replace(/(?:^|\s)site:([^\s]+)/gi, (_match, rawSite: string) => {
|
||||
.replace(/(^|\s)site:([^\s]+)/gi, (_match, prefix: string, rawSite: string) => {
|
||||
const scope = webSearchScope(rawSite);
|
||||
if (scope && !scopes.includes(scope)) scopes.push(scope);
|
||||
return " ";
|
||||
return prefix;
|
||||
})
|
||||
.replace(/\s+/g, " ")
|
||||
.replace(/[^\S\n]+/g, " ")
|
||||
.replace(/ *\n */g, "\n")
|
||||
.trim();
|
||||
|
||||
return {
|
||||
@@ -97,14 +98,16 @@ export function presentWebSearchAction(
|
||||
status: WebSearchStatus,
|
||||
target: WebSearchTarget = "web",
|
||||
t: TFunction,
|
||||
): string {
|
||||
): { label: string; detail: string } {
|
||||
const presentation = presentWebSearchQuery(query);
|
||||
const queryTarget = [presentation.scope, presentation.query].filter(Boolean).join(" · ");
|
||||
const key = status === "error" ? "searchFailed" : status === "running" ? "searching" : "searched";
|
||||
const searchTarget = target === "x"
|
||||
? (queryTarget ? `X · ${queryTarget}` : "X")
|
||||
: queryTarget || t("message.agentActivity.web");
|
||||
return t(`message.agentActivity.${key}`, { target: searchTarget });
|
||||
? ["X", presentation.scope].filter(Boolean).join(" ")
|
||||
: presentation.scope || t("message.agentActivity.web");
|
||||
return {
|
||||
label: t(`message.agentActivity.${key}`, { target: searchTarget }),
|
||||
detail: presentation.query,
|
||||
};
|
||||
}
|
||||
|
||||
function mergeWebSearchRun(
|
||||
|
||||
Reference in new issue
Block a user