Hide subagent threads and simplify thread controls

- Remove subagent prefixes from titles and timeline labels
- Hide subagent threads in the sidebar and add parent-thread navigation
- Align thread details, picker, and git/script controls with panel styling
This commit is contained in:
Julius Marminge authored and maria-rcks committed 2026-08-03 11:45:05 -04:00
1 parent e0f509e5c0
commit 0ee3425c03
15 files changed
+294 -307

No files matched your search

@@ -308,7 +308,7 @@ layer("ProviderEventIngestorV2", (it) => {
const childThread: OrchestrationV2AppThread = {
...rootEvent.payload,
id: childThreadId,
title: "Subagent: inspect package",
title: "inspect package",
activeProviderThreadId: null,
lineage: {
parentThreadId: rootEvent.threadId,
@@ -34,7 +34,7 @@ export function subagentThreadTitle(input: {
return `${input.parentTitle} subagent ${input.ordinal}`;
}
const clipped = detail.length > 72 ? `${detail.slice(0, 69)}...` : detail;
return `Subagent: ${clipped}`;
return clipped;
}
export function makeSubagentChildThread(input: {
@@ -33,6 +33,7 @@ import { useAtomCommand } from "../state/use-atom-command";
import { vcsEnvironment } from "../state/vcs";
import { cn } from "../lib/utils";
import {
THREAD_DETAILS_PANEL_CHEVRON_CLASS,
THREAD_DETAILS_PANEL_ICON_CLASS,
THREAD_DETAILS_PANEL_ROW_CLASS,
} from "./chat/threadDetailsPanelStyles";
@@ -618,12 +619,9 @@ export function BranchToolbarBranchSelector({
? `Open ${sourceControlPresentation.terminology.singular} #${branchPr.number} (${branchPr.state}) in browser`
: "";
const openPrLink = useOpenPrLink();
const panelPrStateClass =
branchPr?.state === "open"
? "bg-emerald-500/10 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-300"
: branchPr?.state === "merged"
? "bg-violet-500/10 text-violet-700 dark:bg-violet-400/10 dark:text-violet-300"
: "bg-muted text-muted-foreground";
const panelPrLabel = branchPr
? `#${branchPr.number}${branchPr.title.trim() ? `: ${branchPr.title}` : ""}`
: "";
function renderPickerItem(itemValue: string, index: number) {
if (checkoutPullRequestItemValue && itemValue === checkoutPullRequestItemValue) {
@@ -772,7 +770,12 @@ export function BranchToolbarBranchSelector({
>
{triggerLabel}
</span>
<ChevronDownIcon className="size-3 shrink-0 opacity-50" />
<ChevronDownIcon
className={cn(
"size-3 shrink-0 opacity-50",
displayMode === "panel" && THREAD_DETAILS_PANEL_CHEVRON_CLASS,
)}
/>
</ComboboxTrigger>
{displayMode === "panel" && branchPr && branchPrStatus ? (
<Tooltip>
@@ -791,18 +794,7 @@ export function BranchToolbarBranchSelector({
<ChangeRequestStatusIcon
className={cn(THREAD_DETAILS_PANEL_ICON_CLASS, branchPrStatus.colorClass)}
/>
<span className="min-w-0 flex-1 truncate text-left">
View {sourceControlPresentation.terminology.shortLabel} #{branchPr.number}
</span>
<span
className={cn(
"inline-flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium capitalize leading-4",
panelPrStateClass,
)}
>
<span className="size-1.5 rounded-full bg-current opacity-75" aria-hidden="true" />
{branchPr.state}
</span>
<span className="min-w-0 flex-1 truncate text-left">{panelPrLabel}</span>
</TooltipTrigger>
<TooltipPopup side="top">{branchPrStatus.tooltip}</TooltipPopup>
</Tooltip>
@@ -90,6 +90,7 @@ import { resolvePathLinkTarget } from "~/terminal-links";
import { type DraftId, useComposerDraftStore } from "~/composerDraftStore";
import { readLocalApi } from "~/localApi";
import {
THREAD_DETAILS_PANEL_CHEVRON_CLASS,
THREAD_DETAILS_PANEL_ICON_CLASS,
THREAD_DETAILS_PANEL_ROW_CLASS,
THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
@@ -1675,8 +1676,8 @@ export default function GitActionsControl({
<>
{!isRepo ? (
<Button
variant="outline"
size="xs"
variant={isPanel ? "ghost" : "outline"}
className={isPanel ? THREAD_DETAILS_PANEL_ROW_CLASS : undefined}
disabled={initAction.isPending}
onClick={() => {
@@ -1720,7 +1721,7 @@ export default function GitActionsControl({
isPanel && THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS,
)}
size="xs"
variant="outline"
variant={isPanel ? "ghost" : "outline"}
/>
}
>
@@ -1744,7 +1745,7 @@ export default function GitActionsControl({
</Popover>
) : (
<Button
variant="outline"
variant={isPanel ? "ghost" : "outline"}
size="xs"
className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS : undefined}
disabled={isGitActionRunning || quickAction.disabled}
@@ -1782,13 +1783,16 @@ export default function GitActionsControl({
<Button
aria-label="Git action options"
size={isPanel ? "sm" : "icon-xs"}
variant="outline"
variant={isPanel ? "ghost" : "outline"}
className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS : undefined}
/>
}
disabled={isGitActionRunning}
>
<ChevronDownIcon aria-hidden="true" className="size-4" />
<ChevronDownIcon
aria-hidden="true"
className={isPanel ? THREAD_DETAILS_PANEL_CHEVRON_CLASS : "size-4"}
/>
</MenuTrigger>
<MenuPopup align="end" className="w-full">
{gitActionMenuItems.map((item) => {
@@ -72,6 +72,7 @@ import { Textarea } from "./ui/textarea";
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
import { cn } from "~/lib/utils";
import {
THREAD_DETAILS_PANEL_CHEVRON_CLASS,
THREAD_DETAILS_PANEL_ICON_CLASS,
THREAD_DETAILS_PANEL_ROW_CLASS,
THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
@@ -357,7 +358,7 @@ export default function ProjectScriptsControl({
render={
<Button
size="xs"
variant="outline"
variant={isPanel ? "ghost" : "outline"}
className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS : undefined}
aria-label={`Run ${primaryScript.name}`}
onClick={() => onRunScript(primaryScript)}
@@ -389,13 +390,15 @@ export default function ProjectScriptsControl({
render={
<Button
size={isPanel ? "sm" : "icon-xs"}
variant="outline"
variant={isPanel ? "ghost" : "outline"}
className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS : undefined}
aria-label="Script actions"
/>
}
>
<ChevronDownIcon className="size-4" />
<ChevronDownIcon
className={isPanel ? THREAD_DETAILS_PANEL_CHEVRON_CLASS : "size-4"}
/>
</MenuTrigger>
<MenuPopup align="end">
{scripts.map((script) => {
@@ -455,7 +458,7 @@ export default function ProjectScriptsControl({
render={
<Button
size="xs"
variant="outline"
variant={isPanel ? "ghost" : "outline"}
className={isPanel ? THREAD_DETAILS_PANEL_ROW_CLASS : undefined}
aria-label={isPanel ? "Add project script" : "Add action"}
onClick={openAddDialog}
@@ -10,8 +10,10 @@ import {
getFallbackThreadIdAfterDelete,
getVisibleThreadsForProject,
getProjectSortTimestamp,
getSidebarForkParentThreadId,
hasUnseenCompletion,
isContextMenuPointerDown,
isSidebarSubagentThread,
isTrailingDoubleClick,
orderItemsByPreferredIds,
resolveProjectStatusIndicator,
@@ -233,6 +235,46 @@ describe("resolveSidebarStageBadgeLabel", () => {
});
});
describe("sidebar thread lineage helpers", () => {
it("identifies subagent threads so the sidebar can hide them", () => {
const parentId = ThreadId.make("thread-parent");
const subagent = makeThreadFixture({
lineage: {
rootThreadId: parentId,
parentThreadId: parentId,
relationshipToParent: "subagent",
},
});
expect(isSidebarSubagentThread(subagent)).toBe(true);
expect(isSidebarSubagentThread(makeThreadFixture())).toBe(false);
});
it("resolves the parent thread for fork sidebar affordances", () => {
const parentId = ThreadId.make("thread-parent");
const fallbackParentId = ThreadId.make("thread-fallback-parent");
const runFork = makeThreadFixture({
forkedFrom: { type: "run", threadId: parentId, runId: "run-1" as never },
lineage: {
rootThreadId: parentId,
parentThreadId: fallbackParentId,
relationshipToParent: "fork",
},
});
const lineageFork = makeThreadFixture({
lineage: {
rootThreadId: parentId,
parentThreadId: fallbackParentId,
relationshipToParent: "fork",
},
});
expect(getSidebarForkParentThreadId(runFork)).toBe(parentId);
expect(getSidebarForkParentThreadId(lineageFork)).toBe(fallbackParentId);
expect(getSidebarForkParentThreadId(makeThreadFixture())).toBeNull();
});
});
function makeLatestRun(overrides?: {
completedAt?: string | null;
startedAt?: string | null;
+10 -62
View File
@@ -46,71 +46,19 @@ type LogicalSidebarProject = SidebarProject & {
export type ThreadTraversalDirection = "previous" | "next";
export async function archiveSelectedThreadEntries<
TEntry extends { readonly threadKey: string },
TResult extends { readonly _tag: "Success" | "Failure" },
>(input: {
entries: readonly TEntry[];
archive: (entry: TEntry, onArchived: () => void) => Promise<TResult>;
}): Promise<{
archivedThreadKeys: readonly string[];
mutationFailure: Extract<TResult, { readonly _tag: "Failure" }> | null;
followupFailures: readonly Extract<TResult, { readonly _tag: "Failure" }>[];
}> {
const archivedThreadKeys: string[] = [];
const followupFailures: Extract<TResult, { readonly _tag: "Failure" }>[] = [];
for (const entry of input.entries) {
let didArchive = false;
const result = await input.archive(entry, () => {
didArchive = true;
});
if (didArchive || result._tag === "Success") {
archivedThreadKeys.push(entry.threadKey);
}
if (result._tag === "Success") continue;
const failure = result as Extract<TResult, { readonly _tag: "Failure" }>;
if (didArchive) {
followupFailures.push(failure);
continue;
}
return { archivedThreadKeys, mutationFailure: failure, followupFailures };
}
return { archivedThreadKeys, mutationFailure: null, followupFailures };
export function isSidebarSubagentThread(thread: Pick<SidebarThreadSummary, "lineage">): boolean {
return thread.lineage.relationshipToParent === "subagent";
}
export function buildMultiSelectThreadContextMenuItems(input: {
count: number;
hasRunningThread: boolean;
}): readonly ContextMenuItem<"mark-unread" | "archive" | "delete">[] {
return [
{ id: "mark-unread", label: `Mark unread (${input.count})` },
{
id: "archive",
label: `Archive (${input.count})`,
disabled: input.hasRunningThread,
},
{ id: "delete", label: `Delete (${input.count})`, destructive: true },
];
}
export function buildBulkTitleRegenerationContextMenuItem(input: {
supportedCount: number;
actionableCount: number;
}): ContextMenuItem<"regenerate-title"> | null {
if (input.supportedCount === 0) return null;
if (input.actionableCount === 0) {
return {
id: "regenerate-title",
label: `Regenerating… (${input.supportedCount})`,
disabled: true,
};
export function getSidebarForkParentThreadId(
thread: Pick<SidebarThreadSummary, "forkedFrom" | "lineage">,
) {
if (thread.lineage.relationshipToParent !== "fork") {
return null;
}
return {
id: "regenerate-title",
label: `Regenerate titles (${input.actionableCount})`,
};
return thread.forkedFrom?.type === "run"
? thread.forkedFrom.threadId
: thread.lineage.parentThreadId;
}
export interface ThreadStatusPill {
+44 -4
View File
@@ -5,6 +5,7 @@ import {
CloudIcon,
ContainerIcon,
FolderPlusIcon,
GitForkIcon,
Globe2Icon,
LoaderIcon,
SearchIcon,
@@ -170,9 +171,9 @@ import {
import { useThreadSelectionStore } from "../threadSelectionStore";
import { openCommandPalette } from "../commandPaletteBus";
import {
archiveSelectedThreadEntries,
buildMultiSelectThreadContextMenuItems,
getSidebarForkParentThreadId,
getSidebarThreadIdsToPrewarm,
isSidebarSubagentThread,
resolveAdjacentThreadId,
isContextMenuPointerDown,
isTrailingDoubleClick,
@@ -367,6 +368,7 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
} = props;
const threadRef = scopeThreadRef(thread.environmentId, thread.id);
const threadKey = scopedThreadKey(threadRef);
const forkParentThreadId = getSidebarForkParentThreadId(thread);
const lastVisitedAt = useUiStateStore((state) => state.threadLastVisitedAtById[threadKey]);
const isSelected = useThreadSelectionStore((state) => state.selectedThreadKeys.has(threadKey));
const runningTerminalIds = useThreadRunningTerminalIds({
@@ -568,6 +570,15 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
},
[openPrLink, prStatus],
);
const handleOpenForkParentClick = useCallback(
(event: React.MouseEvent<HTMLButtonElement>) => {
if (forkParentThreadId === null) return;
event.preventDefault();
event.stopPropagation();
navigateToThread(scopeThreadRef(thread.environmentId, forkParentThreadId));
},
[forkParentThreadId, navigateToThread, thread.environmentId],
);
const handleRenameInputRef = useCallback(
(element: HTMLInputElement | null) => {
if (element && renamingInputRef.current !== element) {
@@ -678,6 +689,25 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
onContextMenu={handleRowContextMenu}
>
<div className="flex min-w-0 flex-1 items-center gap-1.5 text-left">
{forkParentThreadId !== null ? (
<Tooltip>
<TooltipTrigger
render={
<button
type="button"
data-thread-selection-safe
aria-label="Open parent thread"
className="inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground/55 outline-hidden transition-colors hover:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring"
onPointerDown={stopPropagationOnPointerDown}
onClick={handleOpenForkParentClick}
>
<GitForkIcon className="size-3.5" />
</button>
}
/>
<TooltipPopup side="top">Open parent thread</TooltipPopup>
</Tooltip>
) : null}
{prStatus && (
<Tooltip>
<TooltipTrigger
@@ -1164,6 +1194,10 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
});
const openPrLink = useOpenPrLink();
const sidebarThreads = useThreadShellsForProjectRefs(project.memberProjectRefs);
const visibleSidebarThreads = useMemo(
() => sidebarThreads.filter((thread) => !isSidebarSubagentThread(thread)),
[sidebarThreads],
);
const sidebarThreadByKey = useMemo(
() =>
new Map(
@@ -1179,7 +1213,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
// thread-list change).
const sidebarThreadByKeyRef = useRef(sidebarThreadByKey);
sidebarThreadByKeyRef.current = sidebarThreadByKey;
const projectThreads = sidebarThreads;
const projectThreads = visibleSidebarThreads;
const projectPreferenceKeys = useMemo(() => projectExpansionPreferenceKeys(project), [project]);
const projectExpanded = useUiStateStore((state) =>
resolveProjectExpanded(state.projectExpandedById, projectPreferenceKeys),
@@ -3139,6 +3173,9 @@ export default function Sidebar() {
const threadsByProjectKey = useMemo(() => {
const next = new Map<string, SidebarThreadSummary[]>();
for (const thread of sidebarThreads) {
if (isSidebarSubagentThread(thread)) {
continue;
}
const physicalKey =
projectPhysicalKeyByScopedRef.get(
scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId)),
@@ -3261,7 +3298,10 @@ export default function Sidebar() {
}, []);
const visibleThreads = useMemo(
() => sidebarThreads.filter((thread) => thread.archivedAt === null),
() =>
sidebarThreads.filter(
(thread) => thread.archivedAt === null && !isSidebarSubagentThread(thread),
),
[sidebarThreads],
);
const sortedProjects = useMemo(() => {
@@ -1,6 +1,5 @@
import { memo } from "react";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { SidebarTrigger } from "../ui/sidebar";
import { cn } from "~/lib/utils";
interface ChatHeaderProps {
@@ -20,7 +19,6 @@ export const ChatHeader = memo(function ChatHeader({
)}
>
<div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden sm:gap-3">
<SidebarTrigger className="size-7 shrink-0 md:hidden" />
<Tooltip>
<TooltipTrigger
render={
@@ -50,7 +50,7 @@ import {
EyeIcon,
GitForkIcon,
GlobeIcon,
HammerIcon,
type LucideIcon,
MessageCircleIcon,
MousePointerClickIcon,
PaintbrushIcon,
@@ -1268,11 +1268,15 @@ function ProposedPlanTimelineRow({
type V2EventTone = "muted" | "warning" | "danger" | "success";
function subagentDisplayTitle(title: string): string {
return title.replace(/^Subagent:\s*/i, "");
}
function v2EventPresentation(item: OrchestrationV2TurnItem): {
readonly label: string;
readonly detail: string | null;
readonly tone: V2EventTone;
readonly icon: typeof CircleAlertIcon;
readonly icon: LucideIcon;
} {
switch (item.type) {
case "error":
@@ -1310,7 +1314,7 @@ function v2EventPresentation(item: OrchestrationV2TurnItem): {
label: "Conversation fork",
detail: `Continues in ${item.targetThreadId}`,
tone: "muted",
icon: HammerIcon,
icon: GitForkIcon,
};
case "compaction": {
const tokenSummary =
@@ -1326,11 +1330,11 @@ function v2EventPresentation(item: OrchestrationV2TurnItem): {
}
case "subagent":
return {
label: item.title ?? "Subagent",
label: subagentDisplayTitle(item.title ?? "Subagent"),
detail: item.result ?? item.progress ?? item.prompt,
tone:
item.status === "failed" ? "danger" : item.status === "completed" ? "success" : "muted",
icon: HammerIcon,
icon: BotIcon,
};
case "approval_request":
return {
@@ -2138,7 +2142,6 @@ type WorkEntryIconName =
| "circle-alert"
| "eye"
| "globe"
| "hammer"
| "message-circle"
| "square-pen"
| "terminal"
@@ -2158,8 +2161,6 @@ function WorkEntryIconSvg({ name, className }: { name: WorkEntryIconName; classN
return <EyeIcon className={className} aria-hidden />;
case "globe":
return <GlobeIcon className={className} aria-hidden />;
case "hammer":
return <HammerIcon className={className} aria-hidden />;
case "message-circle":
return <MessageCircleIcon className={className} aria-hidden />;
case "square-pen":
@@ -2291,7 +2292,7 @@ function workEntryIconName(workEntry: TimelineWorkEntry): WorkEntryIconName {
case "dynamic_tool":
return "wrench";
case "subagent":
return "hammer";
return "bot";
}
return workToneIcon(workEntry.tone).iconName;
@@ -35,6 +35,7 @@ import { cn, isMacPlatform, isWindowsPlatform } from "~/lib/utils";
import { shellEnvironment } from "~/state/shell";
import { useAtomCommand } from "~/state/use-atom-command";
import {
THREAD_DETAILS_PANEL_CHEVRON_CLASS,
THREAD_DETAILS_PANEL_ICON_CLASS,
THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS,
@@ -248,7 +249,7 @@ export const OpenInPicker = memo(function OpenInPicker({
<Button
aria-label={compact ? "Open file in preferred editor" : primaryLabel}
size={isPanel ? "sm" : "xs"}
variant="outline"
variant={isPanel ? "ghost" : "outline"}
className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS : undefined}
disabled={!preferredEditor || !openInCwd}
onClick={() => openInEditor(preferredEditor)}
@@ -281,12 +282,15 @@ export const OpenInPicker = memo(function OpenInPicker({
<Button
aria-label="Choose editor"
size={isPanel ? "sm" : "icon-xs"}
variant="outline"
variant={isPanel ? "ghost" : "outline"}
className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS : undefined}
/>
}
>
<ChevronDownIcon aria-hidden="true" className="size-4" />
<ChevronDownIcon
aria-hidden="true"
className={isPanel ? THREAD_DETAILS_PANEL_CHEVRON_CLASS : "size-4"}
/>
</MenuTrigger>
<MenuPopup align="end">
{options.length === 0 && <MenuItem disabled>No installed editors found</MenuItem>}
@@ -68,40 +68,6 @@ export interface ThreadDetailsPanelProps {
onDeleteProjectScript: (scriptId: string) => Promise<ProjectScriptActionResult>;
}
function shortConnectionStatus(connection: EnvironmentConnectionPresentation | null): string {
switch (connection?.phase) {
case "connected":
return "Connected";
case "connecting":
return "Connecting";
case "reconnecting":
return "Reconnecting";
case "offline":
return "Offline";
case "error":
return "Connection issue";
case "available":
case undefined:
return "Available";
}
}
function connectionDotClass(connection: EnvironmentConnectionPresentation | null): string {
switch (connection?.phase) {
case "connected":
return "bg-success";
case "connecting":
case "reconnecting":
return "bg-warning animate-pulse";
case "error":
case "offline":
return "bg-destructive";
case "available":
case undefined:
return "bg-muted-foreground/50";
}
}
export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
const connectionIssue =
props.environmentConnection !== null &&
@@ -139,7 +105,7 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
"floating-glass-surface overflow-x-hidden rounded-[20px] border border-border",
props.mode === "inline"
? "max-h-full overflow-y-auto overscroll-contain [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
: "overflow-y-hidden",
: "max-h-[calc(100dvh-6.5rem)] overflow-y-auto overscroll-contain [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
)}
data-thread-details-card
>
@@ -151,28 +117,6 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
>
Workspace
</h3>
<div className="flex shrink-0 items-center gap-1">
<span className="inline-flex items-center gap-1.5 text-[11px] text-muted-foreground">
<span
className={cn(
"size-1.5 rounded-full",
connectionDotClass(props.environmentConnection),
)}
aria-hidden="true"
/>
{shortConnectionStatus(props.environmentConnection)}
</span>
{props.mode === "popover" && props.onClose ? (
<Button
size="icon-xs"
variant="ghost"
aria-label="Close thread details"
onClick={props.onClose}
>
<XIcon className="size-3.5" />
</Button>
) : null}
</div>
</div>
{connectionIssue ? (
@@ -271,7 +215,7 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
id="thread-details-version-control-heading"
className="text-[11px] font-medium text-muted-foreground"
>
Version control
Version Control
</h3>
</div>
<div className="flex flex-col px-2 pb-2.5">
@@ -298,7 +242,11 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
);
if (props.mode === "popover") {
return <div data-thread-details-panel="popover">{card}</div>;
return (
<div className="max-h-[calc(100dvh-6.5rem)]" data-thread-details-panel="popover">
{card}
</div>
);
}
return (
@@ -4,7 +4,6 @@ import { useNavigate } from "@tanstack/react-router";
import {
ArrowRightIcon,
BotIcon,
GitBranchIcon,
GitForkIcon,
GitMergeIcon,
LoaderCircleIcon,
@@ -20,7 +19,6 @@ import {
resolveMergeBackTargetThreadId,
type ThreadRelationshipEdge,
} from "../../lib/threadRelationships";
import { newThreadId } from "../../lib/utils";
import { buildThreadRouteParams } from "../../threadRoutes";
import { useThreadProjection, useThreadShells } from "../../state/entities";
import { threadEnvironment } from "../../state/threads";
@@ -29,6 +27,15 @@ import { cn } from "../../lib/utils";
import { Button } from "../ui/button";
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import {
THREAD_DETAILS_PANEL_ICON_CLASS,
THREAD_DETAILS_PANEL_ICON_ACTION_CLASS,
THREAD_DETAILS_PANEL_LINK_ROW_CLASS,
THREAD_DETAILS_PANEL_LINK_SPLIT_GROUP_CLASS,
THREAD_DETAILS_PANEL_LINK_SPLIT_PRIMARY_CLASS,
THREAD_DETAILS_PANEL_LINK_SPLIT_SECONDARY_CLASS,
THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS,
} from "./threadDetailsPanelStyles";
function relationshipLabel(edge: ThreadRelationshipEdge, currentThreadId: ThreadId) {
if (edge.kind === "transfer") return "Context transfer";
@@ -45,7 +52,13 @@ function statusDotClass(status: string | null): string {
return "bg-muted-foreground/45";
}
const MAX_VISIBLE_RELATIONSHIPS = 5;
function relationshipThreadTitle(input: {
readonly title: string;
readonly isSubagent: boolean;
}): string {
if (!input.isSubagent) return input.title;
return input.title.replace(/^Subagent:\s*/i, "");
}
export function ThreadRelationshipsPanel(props: {
readonly environmentId: EnvironmentId;
@@ -67,30 +80,10 @@ export function ThreadRelationshipsPanel(props: {
];
const graph = deriveThreadRelationshipGraph({ threads: shells, projection });
const navigate = useNavigate();
const forkFromRun = useAtomCommand(threadEnvironment.forkFromRun);
const mergeBack = useAtomCommand(threadEnvironment.mergeBack);
const stopSession = useAtomCommand(threadEnvironment.stopSession);
const [busyAction, setBusyAction] = useState<"fork" | "merge" | "detach" | null>(null);
const [busyAction, setBusyAction] = useState<"merge" | "detach" | null>(null);
const latestCompletedRun = projection?.runs.findLast((run) => run.status === "completed") ?? null;
const sourceProviderThread =
latestCompletedRun?.providerThreadId == null
? null
: (projection?.providerThreads.find(
(thread) => thread.id === latestCompletedRun.providerThreadId,
) ?? null);
const capabilities =
(sourceProviderThread === null
? null
: projection?.providerSessions.find(
(session) => session.id === sourceProviderThread.providerSessionId,
)?.capabilities) ?? null;
const canForkNatively =
capabilities?.threads.canForkThread === true &&
capabilities.threads.canForkFromTurn === true &&
capabilities.identity.nativeThreadIds === "strong";
const canFork =
latestCompletedRun !== null &&
(canForkNatively || capabilities?.context.supportsFullThreadHandoff === true);
const mergeTargetThreadId = resolveMergeBackTargetThreadId(projection);
const relationshipRows = immediateThreadRelationships(graph, props.threadId).toSorted(
(left, right) =>
@@ -103,7 +96,7 @@ export function ThreadRelationshipsPanel(props: {
(session) => session.status !== "stopped" && session.status !== "error",
) ?? false;
if (relationshipRows.length === 0 && !canFork && mergeTargetThreadId === null && !canDetach) {
if (relationshipRows.length === 0) {
return null;
}
@@ -114,23 +107,6 @@ export function ThreadRelationshipsPanel(props: {
});
};
const fork = async () => {
if (!latestCompletedRun || busyAction !== null) return;
setBusyAction("fork");
const targetThreadId = newThreadId();
const result = await forkFromRun({
environmentId: props.environmentId,
input: {
sourceThreadId: props.threadId,
targetThreadId,
runId: latestCompletedRun.id,
title: `${projection?.thread.title ?? "Thread"} fork`,
},
});
setBusyAction(null);
if (result._tag === "Success") openThread(targetThreadId);
};
const merge = async () => {
if (!latestCompletedRun || mergeTargetThreadId === null || busyAction !== null) return;
setBusyAction("merge");
@@ -156,8 +132,6 @@ export function ThreadRelationshipsPanel(props: {
setBusyAction(null);
};
const visibleRows = relationshipRows.slice(0, MAX_VISIBLE_RELATIONSHIPS);
const hiddenRelationshipCount = relationshipRows.length - visibleRows.length;
const parentTitle =
mergeTargetThreadId === null
? null
@@ -177,17 +151,6 @@ export function ThreadRelationshipsPanel(props: {
Lineage
</h3>
<div className="flex shrink-0 items-center gap-1">
{canFork ? (
<Button
size="xs"
variant="ghost"
disabled={busyAction !== null}
onClick={() => void fork()}
>
<GitForkIcon className="size-3" />
{busyAction === "fork" ? "Forking..." : "Fork"}
</Button>
) : null}
{canDetach ? (
<Menu>
<MenuTrigger
@@ -195,6 +158,7 @@ export function ThreadRelationshipsPanel(props: {
<Button
size="icon-xs"
variant="ghost"
className={THREAD_DETAILS_PANEL_ICON_ACTION_CLASS}
aria-label="More thread actions"
disabled={busyAction !== null}
/>
@@ -213,69 +177,73 @@ export function ThreadRelationshipsPanel(props: {
</div>
</div>
{visibleRows.length > 0 ? (
<ul>
{visibleRows.map(({ threadId, edge }) => {
{relationshipRows.length > 0 ? (
<ul className="m-0 list-none p-0">
{relationshipRows.map(({ threadId, edge }) => {
const node = graph.nodes.get(threadId);
const isSubagent = edge.kind === "subagent";
const isMergeTarget = threadId === mergeTargetThreadId;
const RelationshipIcon = isSubagent ? BotIcon : GitBranchIcon;
const RelationshipIcon = isSubagent ? BotIcon : GitForkIcon;
const relationship = relationshipLabel(edge, props.threadId);
const threadTitle = node?.thread?.title ?? threadId;
return (
<li
key={threadId}
className="group flex min-h-11 items-center rounded-lg transition-colors hover:bg-muted/65"
>
<Tooltip>
<TooltipTrigger
render={
<button
type="button"
disabled={node?.missing === true}
onClick={() => openThread(threadId)}
className="flex min-h-11 min-w-0 flex-1 cursor-pointer items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-left disabled:cursor-not-allowed disabled:opacity-55"
>
<span className="relative grid size-7 shrink-0 place-items-center rounded-md bg-muted text-muted-foreground">
<RelationshipIcon className="size-3.5" />
<span
className={cn(
"absolute -bottom-0.5 -right-0.5 size-2 rounded-full border-2 border-card",
statusDotClass(edge.status),
)}
aria-hidden="true"
/>
</span>
<span className="min-w-0 flex-1">
<span className="block truncate text-[13px] font-medium leading-4 text-foreground/85">
{threadTitle}
</span>
<span className="block truncate text-[11px] leading-4 text-muted-foreground">
{node?.missing
? "Unavailable"
: `${relationship}${edge.status ? ` · ${edge.status.replaceAll("_", " ")}` : ""}`}
</span>
</span>
<ArrowRightIcon className="size-3 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />
</button>
}
const threadTitle = relationshipThreadTitle({
title: node?.thread?.title ?? threadId,
isSubagent,
});
const relationshipContent = (
<>
<span className="relative -mx-0.5 grid size-4 shrink-0 place-items-center">
<RelationshipIcon className={THREAD_DETAILS_PANEL_ICON_CLASS} />
<span
className={cn(
"absolute -bottom-1 -right-1 size-2 rounded-full border-2 border-card",
statusDotClass(edge.status),
)}
aria-hidden="true"
/>
<TooltipPopup side="left">
{node?.missing
? "This related thread is unavailable"
: `Open ${relationship.toLowerCase()} in this chat`}
</TooltipPopup>
</Tooltip>
</span>
<span className="min-w-0 flex-1">
<span className="block truncate text-[13px] font-medium leading-4 text-foreground/85">
{threadTitle}
</span>
</span>
<ArrowRightIcon className="size-3 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />
</>
);
return (
<li key={threadId} className="group flex h-9 items-center rounded-lg">
{isMergeTarget ? (
<Tooltip>
<TooltipTrigger
render={
<span className="mr-1 inline-flex shrink-0">
<div className={THREAD_DETAILS_PANEL_LINK_SPLIT_GROUP_CLASS}>
<Tooltip>
<TooltipTrigger
render={
<Button
size="xs"
variant="outline"
className="gap-1 px-1.5 text-[11px]"
size="sm"
variant="ghost"
className={THREAD_DETAILS_PANEL_LINK_SPLIT_PRIMARY_CLASS}
disabled={node?.missing === true}
onClick={() => openThread(threadId)}
/>
}
>
{relationshipContent}
</TooltipTrigger>
<TooltipPopup side="left">
{node?.missing
? "This related thread is unavailable"
: `Open ${relationship.toLowerCase()} in this chat`}
</TooltipPopup>
</Tooltip>
<span
aria-hidden="true"
className={THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS}
/>
<Tooltip>
<TooltipTrigger
render={
<Button
size="sm"
variant="ghost"
className={THREAD_DETAILS_PANEL_LINK_SPLIT_SECONDARY_CLASS}
aria-label={
parentTitle
? `Merge back to ${parentTitle}`
@@ -289,32 +257,45 @@ export function ThreadRelationshipsPanel(props: {
) : (
<GitMergeIcon className="size-3" />
)}
{busyAction === "merge" ? "Merging" : "Merge back"}
</Button>
</span>
}
/>
<TooltipPopup side="left">
{latestCompletedRun === null
? "Complete a run in this fork before merging it back"
: parentTitle
? `Merge this conversation back into ${parentTitle}`
: "Merge this conversation back into its source"}
</TooltipPopup>
</Tooltip>
</div>
) : (
<Tooltip>
<TooltipTrigger
render={
<Button
size="sm"
variant="ghost"
disabled={node?.missing === true}
onClick={() => openThread(threadId)}
className={THREAD_DETAILS_PANEL_LINK_ROW_CLASS}
/>
}
/>
>
{relationshipContent}
</TooltipTrigger>
<TooltipPopup side="left">
{latestCompletedRun === null
? "Complete a run in this fork before merging it back"
: parentTitle
? `Merge this conversation back into ${parentTitle}`
: "Merge this conversation back into its source"}
{node?.missing
? "This related thread is unavailable"
: `Open ${relationship.toLowerCase()} in this chat`}
</TooltipPopup>
</Tooltip>
) : null}
)}
</li>
);
})}
</ul>
) : null}
{hiddenRelationshipCount > 0 ? (
<p className="px-2 pt-1 text-[10px] text-muted-foreground">
{hiddenRelationshipCount} more direct relationship
{hiddenRelationshipCount === 1 ? "" : "s"}
</p>
) : null}
</section>
);
}
@@ -1,11 +1,12 @@
import type { OrchestrationV2TurnItem, ThreadId } from "@t3tools/contracts";
import type { TimestampFormat } from "@t3tools/contracts/settings";
import {
BotIcon,
ExternalLinkIcon,
GitForkIcon,
HammerIcon,
MessageSquareIcon,
MinusIcon,
type LucideIcon,
XIcon,
ZapIcon,
} from "lucide-react";
@@ -117,8 +118,8 @@ export function V2LifecycleRow(props: {
return (
<RelatedThreadCard
itemType={item.type}
icon={HammerIcon}
title={item.title ?? "Subagent"}
icon={BotIcon}
title={subagentDisplayTitle(item.title ?? "Subagent")}
detail={item.result ?? item.progress ?? item.prompt}
badge={item.status}
threadId={item.childThreadId}
@@ -131,7 +132,7 @@ export function V2LifecycleRow(props: {
function RelatedThreadCard(props: {
readonly itemType: "subagent" | "thread_created";
readonly icon: typeof HammerIcon;
readonly icon: LucideIcon;
readonly title: string;
readonly detail: string;
readonly badge: string;
@@ -173,3 +174,7 @@ function RelatedThreadCard(props: {
</button>
);
}
function subagentDisplayTitle(title: string): string {
return title.replace(/^Subagent:\s*/i, "");
}
@@ -4,21 +4,42 @@
* The core control variants intentionally become denser at the `sm` breakpoint. The panel has
* its own fixed density, so every size and type override here includes its desktop counterpart.
*/
const THREAD_DETAILS_PANEL_FLAT_BUTTON_SURFACE_CLASS =
"shadow-none before:shadow-none not-disabled:not-active:not-data-pressed:before:shadow-none dark:not-disabled:before:shadow-none dark:not-disabled:not-active:not-data-pressed:before:shadow-none";
const THREAD_DETAILS_PANEL_RESTING_BUTTON_SURFACE_CLASS =
"bg-transparent shadow-none before:shadow-none not-disabled:not-active:not-data-pressed:before:shadow-none";
export const THREAD_DETAILS_PANEL_ROW_CLASS = `h-9 w-full justify-start gap-2.5 rounded-lg border-transparent bg-transparent px-2.5 text-[13px] font-medium text-foreground/80 sm:h-9 sm:text-[13px] ${THREAD_DETAILS_PANEL_FLAT_BUTTON_SURFACE_CLASS}`;
const THREAD_DETAILS_PANEL_HOVER_SURFACE_CLASS =
"hover:!bg-black/[0.055] data-pressed:!bg-black/[0.055] dark:hover:!bg-white/[0.075] dark:data-pressed:!bg-white/[0.075]";
const THREAD_DETAILS_PANEL_SPLIT_TARGET_HOVER_SURFACE_CLASS =
"hover:!bg-black/[0.07] data-pressed:!bg-black/[0.07] dark:hover:!bg-white/[0.11] dark:data-pressed:!bg-white/[0.11]";
const THREAD_DETAILS_PANEL_ROW_SURFACE_CLASS = `${THREAD_DETAILS_PANEL_RESTING_BUTTON_SURFACE_CLASS} ${THREAD_DETAILS_PANEL_HOVER_SURFACE_CLASS}`;
const THREAD_DETAILS_PANEL_SPLIT_BUTTON_SURFACE_CLASS = `${THREAD_DETAILS_PANEL_RESTING_BUTTON_SURFACE_CLASS} hover:bg-transparent data-pressed:bg-transparent`;
export const THREAD_DETAILS_PANEL_ROW_CLASS = `h-9 w-full justify-start gap-2.5 rounded-lg border-transparent bg-transparent px-2.5 text-[13px] font-medium text-foreground/80 sm:h-9 sm:text-[13px] ${THREAD_DETAILS_PANEL_ROW_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_LINK_ROW_CLASS = `flex h-9 min-w-0 flex-1 cursor-pointer items-center justify-start gap-2.5 rounded-lg border border-transparent bg-transparent px-2.5 text-left text-[13px] font-medium text-foreground/80 disabled:cursor-not-allowed disabled:opacity-55 sm:h-9 sm:text-[13px] ${THREAD_DETAILS_PANEL_ROW_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_LINK_SPLIT_GROUP_CLASS = `group/thread-details-link flex w-full items-center rounded-lg transition-colors ${THREAD_DETAILS_PANEL_HOVER_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_LINK_SPLIT_PRIMARY_CLASS = `flex h-9 min-w-0 flex-1 cursor-pointer items-center justify-start gap-2.5 rounded-e-none border border-transparent bg-transparent px-2.5 text-left text-[13px] font-medium text-foreground/80 shadow-none before:shadow-none disabled:cursor-not-allowed disabled:opacity-55 sm:h-9 sm:text-[13px] ${THREAD_DETAILS_PANEL_SPLIT_TARGET_HOVER_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_LINK_SPLIT_SECONDARY_CLASS = `h-9 w-8 shrink-0 rounded-s-none border-transparent bg-transparent px-0 text-[13px] font-medium text-foreground/80 shadow-none before:shadow-none sm:h-9 sm:w-8 sm:text-[13px] ${THREAD_DETAILS_PANEL_SPLIT_TARGET_HOVER_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_LOCKED_ROW_CLASS =
"h-9 w-full justify-start gap-2.5 rounded-lg border border-transparent px-2.5 text-[13px] font-medium text-foreground/80 sm:h-9 sm:text-[13px]";
export const THREAD_DETAILS_PANEL_ICON_CLASS = "size-4 shrink-0 text-muted-foreground";
export const THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS =
"group/thread-details-action flex w-full items-center rounded-lg transition-colors hover:bg-muted/65 focus-within:bg-muted/65";
export const THREAD_DETAILS_PANEL_CHEVRON_CLASS = "size-4 shrink-0 text-muted-foreground";
export const THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS = `h-9 min-w-0 flex-1 justify-start gap-2.5 rounded-e-none border-transparent bg-transparent px-2.5 pr-2 text-[13px] font-medium text-foreground/80 sm:h-9 sm:text-[13px] [&:hover]:bg-transparent [&[data-pressed]]:bg-transparent ${THREAD_DETAILS_PANEL_FLAT_BUTTON_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_ICON_ACTION_CLASS = `size-6 rounded-md border-transparent bg-transparent p-0 sm:size-6 ${THREAD_DETAILS_PANEL_ROW_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS = `h-9 w-8 rounded-s-none border-transparent bg-transparent px-0 sm:h-9 sm:w-8 [&:hover]:bg-transparent [&[data-pressed]]:bg-transparent ${THREAD_DETAILS_PANEL_FLAT_BUTTON_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS = `group/thread-details-action flex w-full items-center rounded-lg transition-colors ${THREAD_DETAILS_PANEL_HOVER_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS = `h-9 min-w-0 flex-1 justify-start gap-2.5 rounded-e-none border-transparent bg-transparent px-2.5 pr-2 text-[13px] font-medium text-foreground/80 sm:h-9 sm:text-[13px] ${THREAD_DETAILS_PANEL_SPLIT_BUTTON_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS = `h-9 w-8 rounded-s-none border-transparent bg-transparent px-0 sm:h-9 sm:w-8 ${THREAD_DETAILS_PANEL_SPLIT_BUTTON_SURFACE_CLASS}`;
export const THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS = "h-4 w-px shrink-0 bg-border/65";