From d11747b27cfa84644abd67fca374d845ed67c701 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 24 Jun 2026 23:10:56 -0700 Subject: [PATCH] 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 --- .../ProviderEventIngestor.test.ts | 2 +- .../orchestration-v2/SubagentProjection.ts | 2 +- .../BranchToolbarBranchSelector.tsx | 30 +- apps/web/src/components/GitActionsControl.tsx | 14 +- .../src/components/ProjectScriptsControl.tsx | 11 +- apps/web/src/components/Sidebar.logic.test.ts | 64 +- apps/web/src/components/Sidebar.logic.ts | 72 +- apps/web/src/components/Sidebar.tsx | 660 +++++++++++++++--- apps/web/src/components/chat/ChatHeader.tsx | 2 - .../src/components/chat/MessagesTimeline.tsx | 24 +- apps/web/src/components/chat/OpenInPicker.tsx | 10 +- .../components/chat/ThreadDetailsPanel.tsx | 66 +- .../chat/ThreadRelationshipsControl.tsx | 235 +++---- .../src/components/chat/V2LifecycleRow.tsx | 13 +- .../chat/threadDetailsPanelStyles.ts | 35 +- 15 files changed, 809 insertions(+), 431 deletions(-) diff --git a/apps/server/src/orchestration-v2/ProviderEventIngestor.test.ts b/apps/server/src/orchestration-v2/ProviderEventIngestor.test.ts index 0149d43ac3..3f360dd14e 100644 --- a/apps/server/src/orchestration-v2/ProviderEventIngestor.test.ts +++ b/apps/server/src/orchestration-v2/ProviderEventIngestor.test.ts @@ -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, diff --git a/apps/server/src/orchestration-v2/SubagentProjection.ts b/apps/server/src/orchestration-v2/SubagentProjection.ts index d2bec48536..37176ed2e0 100644 --- a/apps/server/src/orchestration-v2/SubagentProjection.ts +++ b/apps/server/src/orchestration-v2/SubagentProjection.ts @@ -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: { diff --git a/apps/web/src/components/BranchToolbarBranchSelector.tsx b/apps/web/src/components/BranchToolbarBranchSelector.tsx index 8cae3fa155..9b37bed72d 100644 --- a/apps/web/src/components/BranchToolbarBranchSelector.tsx +++ b/apps/web/src/components/BranchToolbarBranchSelector.tsx @@ -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})` : ""; const openPrLink = useOpenPrLink(threadRef); - 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) { @@ -775,7 +773,12 @@ export function BranchToolbarBranchSelector({ > {triggerLabel} - + {displayMode === "panel" && branchPr && branchPrStatus ? ( @@ -794,18 +797,7 @@ export function BranchToolbarBranchSelector({ - - View {sourceControlPresentation.terminology.shortLabel} #{branchPr.number} - - - + {panelPrLabel} {branchPrStatus.tooltip} diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx index 1f7ae7aa81..b97a267d99 100644 --- a/apps/web/src/components/GitActionsControl.tsx +++ b/apps/web/src/components/GitActionsControl.tsx @@ -91,6 +91,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, @@ -1696,8 +1697,8 @@ export default function GitActionsControl({ <> {!isRepo ? ( - ) : null} - {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
@@ -298,7 +242,11 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) { ); if (props.mode === "popover") { - return
{card}
; + return ( +
+ {card} +
+ ); } return ( diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx index 90c45715c1..537d817595 100644 --- a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx +++ b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx @@ -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
- {canFork ? ( - - ) : null} {canDetach ? ( @@ -213,69 +177,73 @@ export function ThreadRelationshipsPanel(props: {
- {visibleRows.length > 0 ? ( -
    - {visibleRows.map(({ threadId, edge }) => { + {relationshipRows.length > 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 ( -
    • - - 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" - > - - - - - - {threadTitle} - - - {node?.missing - ? "Unavailable" - : `${relationship}${edge.status ? ` · ${edge.status.replaceAll("_", " ")}` : ""}`} - - - - - } + const threadTitle = relationshipThreadTitle({ + title: node?.thread?.title ?? threadId, + isSubagent, + }); + const relationshipContent = ( + <> + + + - + + + + {threadTitle} + + + + + ); + return ( +
    • {isMergeTarget ? ( - - +
      + + openThread(threadId)} + /> + } + > + {relationshipContent} + + + {node?.missing + ? "This related thread is unavailable" + : `Open ${relationship.toLowerCase()} in this chat`} + + + + } + /> + + {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"} + + +
      + ) : ( + + openThread(threadId)} + className={THREAD_DETAILS_PANEL_LINK_ROW_CLASS} + /> } - /> + > + {relationshipContent} + - {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`} - ) : null} + )}
    • ); })}
    ) : null} - - {hiddenRelationshipCount > 0 ? ( -

    - {hiddenRelationshipCount} more direct relationship - {hiddenRelationshipCount === 1 ? "" : "s"} -

    - ) : null} ); } diff --git a/apps/web/src/components/chat/V2LifecycleRow.tsx b/apps/web/src/components/chat/V2LifecycleRow.tsx index ef366f9c17..e19ebd9ee1 100644 --- a/apps/web/src/components/chat/V2LifecycleRow.tsx +++ b/apps/web/src/components/chat/V2LifecycleRow.tsx @@ -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 ( ); } + +function subagentDisplayTitle(title: string): string { + return title.replace(/^Subagent:\s*/i, ""); +} diff --git a/apps/web/src/components/chat/threadDetailsPanelStyles.ts b/apps/web/src/components/chat/threadDetailsPanelStyles.ts index 4292f9cb31..2cc71e4ffe 100644 --- a/apps/web/src/components/chat/threadDetailsPanelStyles.ts +++ b/apps/web/src/components/chat/threadDetailsPanelStyles.ts @@ -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";