Skip to content
TypeScript

fix(web): thread details card gives titles room to read (#16746)

Theo Brownef60367b8cb5e
diff --git a/apps/web/src/components/chat/AgentElapsed.test.ts b/apps/web/src/components/chat/AgentElapsed.test.ts
new file mode 100644
index 00000000000..c79b64f16c6
--- /dev/null
+++ b/apps/web/src/components/chat/AgentElapsed.test.ts
@@ -0,0 +1,15 @@
+import { expect, it } from "vite-plus/test";
+
+import { formatCompactElapsedSeconds } from "./AgentElapsed";
+
+it.each([
+ [45, "45s"],
+ [90, "1m"],
+ [59 * 60 + 59, "59m"],
+ [60 * 60, "1h"],
+ [90 * 60, "1.5h"],
+ [119 * 60, "1.9h"],
+ [14 * 60 * 60 + 40 * 60, "14h"],
+])("formats %ss as %s", (seconds, label) => {
+ expect(formatCompactElapsedSeconds(seconds)).toBe(label);
+});
diff --git a/apps/web/src/components/chat/AgentElapsed.tsx b/apps/web/src/components/chat/AgentElapsed.tsx
index 801a23f2f44..e313fba63e5 100644
--- a/apps/web/src/components/chat/AgentElapsed.tsx
+++ b/apps/web/src/components/chat/AgentElapsed.tsx
@@ -16,15 +16,29 @@ function formatElapsedSeconds(totalSeconds: number): string {
return `${hours}h ${String(minutes % 60).padStart(2, "0")}m`;
}
+/** Short form for tight rows: "45s", "12m", "1.5h", "14h". Rounds down. */
+export function formatCompactElapsedSeconds(totalSeconds: number): string {
+ const seconds = Math.max(0, Math.floor(totalSeconds));
+ if (seconds < 60) return `${seconds}s`;
+ const minutes = Math.floor(seconds / 60);
+ if (minutes < 60) return `${minutes}m`;
+ if (minutes >= 600) return `${Math.floor(minutes / 60)}h`;
+ return `${Math.floor(minutes / 6) / 10}h`;
+}
+
/**
* Elapsed time for the current activation. Live agents self-tick via DOM
* writes (zero React commits per tick); settled agents freeze at completedAt.
+ * `compact` drops the smaller unit for narrow rows such as Lineage.
*/
export function AgentElapsed({
agent,
+ compact = false,
}: {
agent: Pick<RuntimeSubagent, "status" | "startedAt" | "completedAt">;
+ compact?: boolean;
}) {
+ const format = compact ? formatCompactElapsedSeconds : formatElapsedSeconds;
const textRef = useRef<HTMLSpanElement>(null);
const live = isOrchestrationV2WorkActive(agent.status);
const startedAt = agent.startedAt;
@@ -40,15 +54,15 @@ export function AgentElapsed({
{ status: agent.status, startedAt, completedAt },
Date.now(),
);
- textRef.current.textContent =
- elapsedMs === null ? "" : formatElapsedSeconds(elapsedMs / 1000);
+ const text = elapsedMs === null ? "" : format(elapsedMs / 1000);
+ if (textRef.current.textContent !== text) textRef.current.textContent = text;
}
};
update();
if (!live) return;
const id = setInterval(update, 1000);
return () => clearInterval(id);
- }, [live, startedAt, completedAt, agent.status]);
+ }, [live, startedAt, completedAt, agent.status, format]);
const elapsedMs = deriveSubagentElapsedMs(agent, 0);
if (elapsedMs === null) {
@@ -56,7 +70,7 @@ export function AgentElapsed({
}
return (
<span ref={textRef} className="tabular-nums">
- {formatElapsedSeconds(elapsedMs / 1000)}
+ {format(elapsedMs / 1000)}
</span>
);
}
diff --git a/apps/web/src/components/chat/ThreadDetailsControl.tsx b/apps/web/src/components/chat/ThreadDetailsControl.tsx
index 3169f801848..f14a52c1449 100644
--- a/apps/web/src/components/chat/ThreadDetailsControl.tsx
+++ b/apps/web/src/components/chat/ThreadDetailsControl.tsx
@@ -11,10 +11,9 @@ import {
THREAD_DETAILS_PANEL_SELECT_ROW_CLASS,
THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS,
THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS,
- THREAD_DETAILS_PANEL_LINK_SPLIT_ACTION_CLASS,
THREAD_DETAILS_PANEL_LINK_SPLIT_PRIMARY_CLASS,
- THREAD_DETAILS_PANEL_SPLIT_CHECKS_CLASS,
THREAD_DETAILS_PANEL_ICON_ACTION_CLASS,
+ THREAD_DETAILS_PANEL_META_ACTION_CLASS,
THREAD_DETAILS_PANEL_CHEVRON_CLASS,
} from "./threadDetailsPanelStyles";
import { ChevronDownIcon } from "lucide-react";
@@ -24,10 +23,9 @@ const parts = {
select: THREAD_DETAILS_PANEL_SELECT_ROW_CLASS,
primary: THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS,
secondary: THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS,
- action: THREAD_DETAILS_PANEL_LINK_SPLIT_ACTION_CLASS,
"link-primary": THREAD_DETAILS_PANEL_LINK_SPLIT_PRIMARY_CLASS,
- checks: THREAD_DETAILS_PANEL_SPLIT_CHECKS_CLASS,
icon: THREAD_DETAILS_PANEL_ICON_ACTION_CLASS,
+ meta: THREAD_DETAILS_PANEL_META_ACTION_CLASS,
};
/** Panel controls own their fixed density; toolbar controls use the standard Button variants. */
@@ -45,7 +43,7 @@ export function ThreadDetailsControl({
panel?: boolean;
part?: keyof typeof parts;
multiline?: boolean;
- tone?: "default" | "muted" | "destructive";
+ tone?: "default" | "muted" | "primary" | "destructive";
}) {
const control = useRender({
defaultTagName: "button",
@@ -58,6 +56,7 @@ export function ThreadDetailsControl({
parts[part],
multiline && "h-auto min-h-8 py-0.75 disabled:opacity-100 sm:h-auto",
tone === "muted" && "text-muted-foreground/70 hover:text-foreground/80",
+ tone === "primary" && "text-primary hover:text-primary",
tone === "destructive" &&
"text-destructive hover:text-destructive data-pressed:text-destructive",
className,
diff --git a/apps/web/src/components/chat/ThreadDetailsPrRow.tsx b/apps/web/src/components/chat/ThreadDetailsPrRow.tsx
index 9fc86281b15..f00d911e043 100644
--- a/apps/web/src/components/chat/ThreadDetailsPrRow.tsx
+++ b/apps/web/src/components/chat/ThreadDetailsPrRow.tsx
@@ -4,10 +4,11 @@ import { PullRequestGlyph } from "../pullRequest/pullRequestIcons";
* The thread details panel's pull request row: what the thread's pull request is, and the one
* thing worth doing to it right now.
*
- * The row itself opens the pull request in the right panel, exactly as it always has. Around
- * that, the host's richer answer collapses into a single trailing slot, ranked by what unblocks
- * the merge next: "Resolve" on conflicts, "Ready" on a draft, "Fix" under failing checks, and
- * "Merge" only once the branch is clean and its checks pass. While checks run the slot reports
+ * The row itself opens the pull request in the right panel, exactly as it always has. Once the
+ * host answers, the title gets the full first line and a second line carries the number, checks,
+ * watch, and a single action slot, ranked by what unblocks the merge next: "Resolve" on
+ * conflicts, "Ready" on a draft, "Fix" under failing checks, and "Merge" only once the branch is
+ * clean and its checks pass. While checks run the slot reports
* that instead — a merge offered mid-run would race the very runs that gate it. Everything else
* the host knows (title, state, checks tally, diff size) lives in the row's tooltip, so a hover
* answers what previously took opening the panel.
@@ -231,7 +232,7 @@ export function ThreadDetailsPrRow({
<PullRequestGlyph.pullRequest className={THREAD_DETAILS_PANEL_ICON_CLASS} />
);
- // Everything the host reported, at a glance. The row stays one line; the tooltip is where the
+ // Everything the host reported, at a glance. The rows stay short; the tooltip is where the
// rest of the answer lives — styled like the sidebar's thread tooltip, title above icon-led
// detail rows, so the two read as one family.
const rowTooltip =
@@ -344,83 +345,88 @@ export function ThreadDetailsPrRow({
}
: null;
- const rowContent = (
- <>
- {icon}
- <span className="min-w-0 flex-1 truncate text-left">{label}</span>
- </>
- );
-
// The server ends a watch when the pull request closes, so only an open one shows the eye.
- // It takes the row's rounded end when nothing follows it.
- const watchIsLast =
- detail === null ||
- ((checksRollup === null || conflicting || detail.isDraft) && trailingAction === null);
- const watchSegment =
- onStopWatching && (detail?.state ?? pr?.state ?? "open") === "open" ? (
- <>
- <span aria-hidden="true" className={THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS} />
- <Tooltip>
- <TooltipTrigger
- render={
- <ThreadDetailsControl
- type="button"
- variant="ghost"
- size="sm"
- part={watchIsLast ? "secondary" : "checks"}
- className="group/watch"
- aria-label={`Stop watching #${number}`}
- onClick={onStopWatching}
- />
- }
- >
- <EyeIcon aria-hidden className="size-4 group-hover/watch:hidden" />
- <EyeOffIcon aria-hidden className="hidden size-4 group-hover/watch:block" />
- </TooltipTrigger>
- <TooltipPopup side="top">
- Watching: the agent wakes when checks finish, someone comments, or the branch conflicts.
- Click to stop.
- </TooltipPopup>
- </Tooltip>
- </>
+ const watching =
+ onStopWatching !== undefined && (detail?.state ?? pr?.state ?? "open") === "open";
+ const watchControl = (part: "secondary" | "icon") =>
+ watching ? (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <ThreadDetailsControl
+ type="button"
+ variant="ghost"
+ size="sm"
+ part={part}
+ className="group/watch"
+ aria-label={`Stop watching #${number}`}
+ onClick={onStopWatching}
+ />
+ }
+ >
+ <EyeIcon
+ aria-hidden
+ className={cn(part === "icon" ? "size-3.5" : "size-4", "group-hover/watch:hidden")}
+ />
+ <EyeOffIcon
+ aria-hidden
+ className={cn(
+ part === "icon" ? "size-3.5" : "size-4",
+ "hidden group-hover/watch:block",
+ )}
+ />
+ </TooltipTrigger>
+ <TooltipPopup side="top">
+ Watching: the agent wakes when checks finish, someone comments, or the branch conflicts.
+ Click to stop.
+ </TooltipPopup>
+ </Tooltip>
) : null;
+ const openRow = (text: string, part: "row" | "link-primary") => (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <ThreadDetailsControl
+ type="button"
+ variant="ghost"
+ size="sm"
+ part={part}
+ aria-label={openAriaLabel}
+ onClick={onOpen}
+ />
+ }
+ >
+ {icon}
+ <span className="min-w-0 flex-1 truncate text-left">{text}</span>
+ </TooltipTrigger>
+ {rowTooltip}
+ </Tooltip>
+ );
+
+ const showChecks = detail !== null && checksRollup !== null && !conflicting && !detail.isDraft;
+
return (
<>
- {detail ? (
- <div className={THREAD_DETAILS_PANEL_LINK_SPLIT_GROUP_CLASS}>
- <Tooltip>
- <TooltipTrigger
- render={
- <ThreadDetailsControl
- type="button"
- variant="ghost"
- size="sm"
- part="link-primary"
- aria-label={openAriaLabel}
- onClick={onOpen}
- />
- }
- >
- {rowContent}
- </TooltipTrigger>
- {rowTooltip}
- </Tooltip>
- {watchSegment}
- {checksRollup !== null && !conflicting && !detail.isDraft ? (
- <>
- <span aria-hidden="true" className={THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS} />
+ {detail !== null && (showChecks || trailingAction !== null || watching) ? (
+ // Two lines so the title keeps the full row width: the number, checks, watch, and the
+ // next action sit underneath, aligned with the title text. The second line hugs its title
+ // and the block keeps space below, so stacked pull requests read as separate pairs.
+ <div className="pb-2">
+ {openRow(detail.title, "row")}
+ <div className="-mt-1 flex h-6 min-w-0 items-center gap-0.5 ps-9 pe-1 text-xs text-muted-foreground">
+ <span className="me-1 shrink-0 tabular-nums">#{number}</span>
+ {showChecks && checksRollup !== null ? (
<PullRequestChecksPopover
checksState={checksRollup}
checks={detail.checks}
variant="count"
- render={<ThreadDetailsControl part="checks" />}
+ render={<ThreadDetailsControl part="meta" />}
/>
- </>
- ) : null}
- {trailingAction ? (
- <>
- <span aria-hidden="true" className={THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS} />
+ ) : null}
+ {watchControl("icon")}
+ <span className="flex-1" />
+ {trailingAction ? (
<Tooltip>
<TooltipTrigger
render={
@@ -428,8 +434,8 @@ export function ThreadDetailsPrRow({
type="button"
variant="ghost"
size="sm"
- part="action"
- tone={trailingAction.destructive ? "destructive" : "default"}
+ part="meta"
+ tone={trailingAction.destructive ? "destructive" : "primary"}
disabled={actionPending || handoff !== null}
onClick={trailingAction.onClick}
/>
@@ -440,48 +446,17 @@ export function ThreadDetailsPrRow({
</TooltipTrigger>
<TooltipPopup side="top">{trailingAction.tooltip}</TooltipPopup>
</Tooltip>
- </>
- ) : null}
+ ) : null}
+ </div>
</div>
- ) : watchSegment ? (
+ ) : watching ? (
<div className={THREAD_DETAILS_PANEL_LINK_SPLIT_GROUP_CLASS}>
- <Tooltip>
- <TooltipTrigger
- render={
- <ThreadDetailsControl
- type="button"
- variant="ghost"
- size="sm"
- part="link-primary"
- aria-label={openAriaLabel}
- onClick={onOpen}
- />
- }
- >
- {rowContent}
- </TooltipTrigger>
- {rowTooltip}
- </Tooltip>
- {watchSegment}
+ {openRow(label, "link-primary")}
+ <span aria-hidden="true" className={THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS} />
+ {watchControl("secondary")}
</div>
) : (
- <Tooltip>
- <TooltipTrigger
- render={
- <ThreadDetailsControl
- type="button"
- variant="ghost"
- size="sm"
- part="row"
- aria-label={openAriaLabel}
- onClick={onOpen}
- />
- }
- >
- {rowContent}
- </TooltipTrigger>
- {rowTooltip}
- </Tooltip>
+ openRow(label, "row")
)}
{rowAction === "merge" ? (
<AlertDialog open={confirmingMerge} onOpenChange={(open) => setConfirmingMerge(open)}>
diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.agents.test.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.agents.test.tsx
index 6c7534d0488..6382520cdfa 100644
--- a/apps/web/src/components/chat/ThreadRelationshipsControl.agents.test.tsx
+++ b/apps/web/src/components/chat/ThreadRelationshipsControl.agents.test.tsx
@@ -238,9 +238,10 @@ it("shows the matching child agent details and refreshes them when the agent set
renderer.root.findByProps({ type: "button", "aria-expanded": false }).props.onClick(),
);
expect(text()).toContain("Checker");
- expect(text()).toContain("2m 15s");
+ // A started agent's row shows only its compact time; the icon carries the status.
+ expect(text()).toContain("Checker 2m");
expect(text()).not.toContain("(1)");
- expect(text()).toContain("Done");
+ expect(text()).not.toContain("Done");
expect(text()).not.toContain("running");
expect(text()).not.toContain("Worker");
await act(async () =>
diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
index cca32d57ab0..f56c1c92b56 100644
--- a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
+++ b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
@@ -25,6 +25,7 @@ import {
resolveLatestMergeBackRun,
} from "@t3tools/client-runtime/state/thread-workflows";
import type { EnvironmentId, OrchestrationV2ThreadShell, ThreadId } from "@t3tools/contracts";
+import { deriveSubagentElapsedMs } from "@t3tools/shared/orchestrationTiming";
import { groupBy } from "effect/Array";
import * as DateTime from "effect/DateTime";
import { useNavigate } from "@tanstack/react-router";
@@ -382,6 +383,7 @@ export function ThreadRelationshipsPanel(props: {
isSubagent && !isParent ? subagentsByThreadId.get(threadId) : undefined,
node?.thread,
);
+ const failed = status === "failed" || status === "error";
const canStop =
agent?.origin === "app_owned" &&
agent.startedAt &&
@@ -435,19 +437,21 @@ export function ThreadRelationshipsPanel(props: {
{threadTitle}
</span>
</span>
- {agent ? (
- agent.startedAt ? (
- <span
- className={`shrink-0 text-2xs font-normal tabular-nums text-muted-foreground ${canStop ? "group-hover:opacity-0 group-focus-within:opacity-0 pointer-coarse:opacity-0 [@media(hover:none)]:opacity-0" : ""}`}
- >
- <AgentElapsed agent={agent} />
- </span>
- ) : null
- ) : (
+ {agent ? null : (
<ArrowRightIcon className="size-3 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />
)}
- {!isMergeTarget ? (
- <span className="shrink-0 text-2xs text-muted-foreground">
+ {/* One trailing item keeps room for the title: the icon dot already
+ carries status, so an agent with a known time shows only that. */}
+ {agent && !failed && deriveSubagentElapsedMs(agent, 0) !== null ? (
+ <span
+ className={`shrink-0 text-2xs font-normal tabular-nums text-muted-foreground ${canStop ? "group-hover:opacity-0 group-focus-within:opacity-0 pointer-coarse:opacity-0 [@media(hover:none)]:opacity-0" : ""}`}
+ >
+ <AgentElapsed agent={agent} compact />
+ </span>
+ ) : !isMergeTarget ? (
+ <span
+ className={`shrink-0 text-2xs ${failed ? "text-destructive" : "text-muted-foreground"}`}
+ >
{threadRelationshipStatusLabel(status)}
</span>
) : null}
diff --git a/apps/web/src/components/chat/threadDetailsPanelStyles.ts b/apps/web/src/components/chat/threadDetailsPanelStyles.ts
index d3f81e8dddd..33c454e4232 100644
--- a/apps/web/src/components/chat/threadDetailsPanelStyles.ts
+++ b/apps/web/src/components/chat/threadDetailsPanelStyles.ts
@@ -29,9 +29,6 @@ export const THREAD_DETAILS_PANEL_LINK_SPLIT_GROUP_CLASS = `group/thread-details
export const THREAD_DETAILS_PANEL_LINK_SPLIT_PRIMARY_CLASS = `${THREAD_DETAILS_PANEL_CONTROL_CLASS} flex-1 justify-start rounded-e-none ${THREAD_DETAILS_PANEL_SPLIT_BUTTON_SURFACE_CLASS}`;
-/** The trailing half of a link split row when it carries a word ("Merge") rather than an icon. */
-export const THREAD_DETAILS_PANEL_LINK_SPLIT_ACTION_CLASS = `${THREAD_DETAILS_PANEL_CONTROL_CLASS} shrink-0 justify-center rounded-s-none text-primary ${THREAD_DETAILS_PANEL_SPLIT_BUTTON_SURFACE_CLASS}`;
-
export const THREAD_DETAILS_PANEL_LOCKED_ROW_CLASS = `h-8 w-full min-w-0 justify-start rounded-lg border border-transparent ${THREAD_DETAILS_PANEL_ROW_CONTENT_CLASS} text-[13px] font-medium text-foreground/80 sm:h-8 sm:text-[13px]`;
export const THREAD_DETAILS_PANEL_ICON_CLASS = "size-4 shrink-0 text-muted-foreground";
@@ -40,6 +37,9 @@ export const THREAD_DETAILS_PANEL_CHEVRON_CLASS = "size-4 shrink-0 text-muted-fo
export const THREAD_DETAILS_PANEL_ICON_ACTION_CLASS = `size-6 justify-center rounded-md border-transparent bg-transparent p-0 sm:size-6 ${THREAD_DETAILS_PANEL_ROW_SURFACE_CLASS}`;
+/** A small text control on a row's second line, such as a pull request's checks or next action. */
+export const THREAD_DETAILS_PANEL_META_ACTION_CLASS = `h-6 gap-1 rounded-md border-transparent px-1.5 text-xs font-medium text-muted-foreground ${THREAD_DETAILS_PANEL_ROW_SURFACE_CLASS}`;
+
export const THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS = `group/thread-details-action flex w-full items-center rounded-lg ${THREAD_DETAILS_PANEL_SPLIT_GROUP_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS = `${THREAD_DETAILS_PANEL_CONTROL_CLASS} flex-1 justify-start rounded-e-none ${THREAD_DETAILS_PANEL_SPLIT_BUTTON_SURFACE_CLASS}`;
@@ -47,5 +47,3 @@ export const THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS = `${THREAD_DETAILS_PANEL_
export const THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS = `${THREAD_DETAILS_PANEL_CONTROL_CLASS} w-8 justify-center rounded-s-none px-0 ${THREAD_DETAILS_PANEL_SPLIT_BUTTON_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS = "h-4 w-px shrink-0 bg-border/65";
-
-export const THREAD_DETAILS_PANEL_SPLIT_CHECKS_CLASS = `${THREAD_DETAILS_PANEL_CONTROL_CLASS} justify-center gap-1.5 rounded-none ${THREAD_DETAILS_PANEL_SPLIT_BUTTON_SURFACE_CLASS}`;
diff --git a/apps/web/src/components/pullRequest/PullRequestChecksPopover.tsx b/apps/web/src/components/pullRequest/PullRequestChecksPopover.tsx
index 1bb5240ebef..adbd9adc79e 100644
--- a/apps/web/src/components/pullRequest/PullRequestChecksPopover.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestChecksPopover.tsx
@@ -6,7 +6,6 @@ import type {
PullRequestRef,
ScopedThreadRef,
} from "@t3tools/contracts";
-import { ChevronDownIcon } from "lucide-react";
import { useState } from "react";
import { useOpenLink } from "~/browser/useOpenLink";
@@ -156,6 +155,9 @@ export function PullRequestChecksPopover({
const presentation = pullRequestChecksStatePresentation(checksState);
// Counts beat the rollup's own wording where they are known, the way GitHub's own header reads.
const runningCount = checks?.filter((check) => check.status === "pending").length ?? 0;
+ const failedCount =
+ checks?.filter((check) => check.status === "failure" || check.status === "cancelled").length ??
+ 0;
const summary = checks === undefined || stale ? null : summarizePullRequestChecks(checks);
return (
<Popover>
@@ -189,8 +191,9 @@ export function PullRequestChecksPopover({
<span className="tabular-nums">
{runningCount}/{checks.length}
</span>
+ ) : failedCount > 0 ? (
+ <span className="tabular-nums">{failedCount} failed</span>
) : null}
- <ChevronDownIcon aria-hidden className="size-3" />
</>
) : null}
</PopoverTrigger>