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:
1 parent
a39d2fda26
commit
686be78b69
15 files changed
+809
-431
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";
|
||||
@@ -629,12 +630,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) {
|
||||
@@ -786,7 +784,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>
|
||||
@@ -805,18 +808,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>
|
||||
|
||||
@@ -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 ? (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
variant={isPanel ? "ghost" : "outline"}
|
||||
className={isPanel ? THREAD_DETAILS_PANEL_ROW_CLASS : undefined}
|
||||
disabled={initAction.isPending}
|
||||
onClick={() => {
|
||||
@@ -1741,7 +1742,7 @@ export default function GitActionsControl({
|
||||
isPanel && THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS,
|
||||
)}
|
||||
size="xs"
|
||||
variant="outline"
|
||||
variant={isPanel ? "ghost" : "outline"}
|
||||
/>
|
||||
}
|
||||
>
|
||||
@@ -1765,7 +1766,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}
|
||||
@@ -1803,13 +1804,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) => {
|
||||
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
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,
|
||||
@@ -183,7 +184,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}`}
|
||||
// The tooltip wrapper replaces data-slot="button", so themed
|
||||
@@ -218,13 +219,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) => {
|
||||
@@ -284,7 +287,7 @@ export default function ProjectScriptsControl({
|
||||
render={
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
variant={isPanel ? "ghost" : "outline"}
|
||||
className={
|
||||
isPanel
|
||||
? THREAD_DETAILS_PANEL_ROW_CLASS
|
||||
|
||||
@@ -10,9 +10,10 @@ import {
|
||||
getFallbackThreadIdAfterDelete,
|
||||
getVisibleThreadsForProject,
|
||||
getProjectSortTimestamp,
|
||||
getSidebarForkParentThreadId,
|
||||
hasUnseenCompletion,
|
||||
isContextMenuPointerDown,
|
||||
isSidebarNestedLinkClick,
|
||||
isSidebarSubagentThread,
|
||||
isTrailingDoubleClick,
|
||||
orderItemsByPreferredIds,
|
||||
resolveProjectStatusIndicator,
|
||||
@@ -238,6 +239,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;
|
||||
@@ -406,27 +447,6 @@ describe("isTrailingDoubleClick", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isSidebarNestedLinkClick", () => {
|
||||
const linkTarget = {
|
||||
closest: (selector: string) => (selector === "a[href]" ? ({} as Element) : null),
|
||||
} as unknown as EventTarget;
|
||||
|
||||
it("ignores row clicks that originated on a nested link", () => {
|
||||
expect(isSidebarNestedLinkClick(linkTarget)).toBe(true);
|
||||
});
|
||||
|
||||
it("walks up from a text node to the enclosing link", () => {
|
||||
expect(isSidebarNestedLinkClick({ parentElement: linkTarget } as unknown as EventTarget)).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("leaves ordinary row clicks alone", () => {
|
||||
expect(isSidebarNestedLinkClick({ closest: () => null } as unknown as EventTarget)).toBe(false);
|
||||
expect(isSidebarNestedLinkClick(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldCreateNewThreadInCurrentProject", () => {
|
||||
it("creates directly on shift+click in a multi-project setup", () => {
|
||||
expect(shouldCreateNewThreadInCurrentProject(true, 2)).toBe(true);
|
||||
|
||||
@@ -50,71 +50,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 {
|
||||
|
||||
+560
-100
@@ -1,3 +1,29 @@
|
||||
import {
|
||||
ArchiveIcon,
|
||||
ArrowUpDownIcon,
|
||||
ChevronRightIcon,
|
||||
CloudIcon,
|
||||
ContainerIcon,
|
||||
FolderPlusIcon,
|
||||
GitForkIcon,
|
||||
Globe2Icon,
|
||||
LoaderIcon,
|
||||
SearchIcon,
|
||||
SquarePenIcon,
|
||||
TerminalIcon,
|
||||
TriangleAlertIcon,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
ChangeRequestStatusIcon,
|
||||
prStatusIndicator,
|
||||
PrStatusTooltipContent,
|
||||
resolveThreadPr,
|
||||
terminalStatusFromRunningIds,
|
||||
ThreadStatusLabel,
|
||||
ThreadWorktreeIndicator,
|
||||
} from "./ThreadStatusIndicators";
|
||||
import { ProjectFavicon } from "./ProjectFavicon";
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { autoAnimate } from "@formkit/auto-animate";
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import * as Schema from "effect/Schema";
|
||||
@@ -116,7 +142,84 @@ import {
|
||||
resolveActiveThreadRouteRef,
|
||||
resolveThreadRouteTarget,
|
||||
} from "../threadRoutes";
|
||||
import { formatRelativeTimeLabel, parseTimestampDate } from "../timestampFormat";
|
||||
import { stackedThreadToast, toastManager } from "./ui/toast";
|
||||
import { formatRelativeTimeLabel } from "../timestampFormat";
|
||||
import { SettingsSidebarNav } from "./settings/SettingsSidebarNav";
|
||||
import { Kbd } from "./ui/kbd";
|
||||
import {
|
||||
getArm64IntelBuildWarningDescription,
|
||||
getDesktopUpdateActionError,
|
||||
getDesktopUpdateInstallConfirmationMessage,
|
||||
isDesktopUpdateButtonDisabled,
|
||||
resolveDesktopUpdateButtonAction,
|
||||
shouldShowArm64IntelBuildWarning,
|
||||
shouldToastDesktopUpdateActionResult,
|
||||
} from "./desktopUpdate.logic";
|
||||
import { showDesktopUpdateDownloadedToast } from "./desktopUpdate.toast";
|
||||
import { Alert, AlertAction, AlertDescription, AlertTitle } from "./ui/alert";
|
||||
import { Button } from "./ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogPanel,
|
||||
DialogPopup,
|
||||
DialogTitle,
|
||||
} from "./ui/dialog";
|
||||
import { Input } from "./ui/input";
|
||||
import { Menu, MenuGroup, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "./ui/menu";
|
||||
import {
|
||||
NumberField,
|
||||
NumberFieldDecrement,
|
||||
NumberFieldGroup,
|
||||
NumberFieldIncrement,
|
||||
NumberFieldInput,
|
||||
} from "./ui/number-field";
|
||||
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
|
||||
import {
|
||||
SidebarContent,
|
||||
SidebarGroup,
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
SidebarMenuSub,
|
||||
SidebarMenuSubButton,
|
||||
SidebarMenuSubItem,
|
||||
useSidebar,
|
||||
} from "./ui/sidebar";
|
||||
import { useThreadSelectionStore } from "../threadSelectionStore";
|
||||
import { openCommandPalette } from "../commandPaletteBus";
|
||||
import {
|
||||
getSidebarForkParentThreadId,
|
||||
getSidebarThreadIdsToPrewarm,
|
||||
isSidebarSubagentThread,
|
||||
resolveAdjacentThreadId,
|
||||
isContextMenuPointerDown,
|
||||
isTrailingDoubleClick,
|
||||
resolveProjectStatusIndicator,
|
||||
resolveThreadRowClassName,
|
||||
resolveThreadStatusPill,
|
||||
orderItemsByPreferredIds,
|
||||
shouldClearThreadSelectionOnMouseDown,
|
||||
sortProjectsForSidebar,
|
||||
useThreadJumpHintVisibility,
|
||||
ThreadStatusPill,
|
||||
} from "./Sidebar.logic";
|
||||
import { sortThreads } from "../lib/threadSort";
|
||||
import { SidebarChromeFooter, SidebarChromeHeader } from "./sidebar/SidebarChrome";
|
||||
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
|
||||
import { useIsMobile } from "~/hooks/useMediaQuery";
|
||||
import { CommandDialogTrigger } from "./ui/command";
|
||||
import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
|
||||
import { primaryServerKeybindingsAtom } from "../state/server";
|
||||
import {
|
||||
derivePhysicalProjectKey,
|
||||
deriveProjectGroupingOverrideKey,
|
||||
getProjectOrderKey,
|
||||
selectProjectGroupingSettings,
|
||||
} from "../logicalProject";
|
||||
import type { SidebarThreadSummary } from "../types";
|
||||
import { cn } from "~/lib/utils";
|
||||
import { buildThreadActionMenuItems } from "./threadActionMenu.logic";
|
||||
@@ -733,7 +836,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
[thread.environmentId, thread.id],
|
||||
);
|
||||
const threadKey = scopedThreadKey(threadRef);
|
||||
const isRegeneratingTitle = thread.titleRegeneration != null;
|
||||
const forkParentThreadId = getSidebarForkParentThreadId(thread);
|
||||
const lastVisitedAt = useUiStateStore((state) => state.threadLastVisitedAtById[threadKey]);
|
||||
const isSelected = useThreadSelectionStore((state) => state.selectedThreadKeys.has(threadKey));
|
||||
const openPrLink = useOpenPrLink();
|
||||
@@ -753,8 +856,6 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
})
|
||||
: null,
|
||||
);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
const isHighlighted = isActive || isSelected;
|
||||
const handleOpenDiscoveredPort = useCallback(
|
||||
(event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
@@ -789,7 +890,6 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
lastVisitedAt,
|
||||
},
|
||||
});
|
||||
>>>>>>> 8f521e516e (Complete orchestration V2 frontend cutover)
|
||||
const pr = resolveThreadPr({
|
||||
threadBranch: thread.branch,
|
||||
gitStatus: gitStatus.data,
|
||||
@@ -965,12 +1065,40 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
},
|
||||
[isRenaming, onStartRename, thread.title, threadRef],
|
||||
);
|
||||
const renameCommittedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
if (isRenaming) renameCommittedRef.current = false;
|
||||
}, [isRenaming]);
|
||||
const handleRenameKeyDown = useCallback(
|
||||
(event: ReactKeyboardEvent<HTMLInputElement>) => {
|
||||
const handlePrClick = useCallback(
|
||||
(event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
if (!prStatus) return;
|
||||
openPrLink(event, prStatus.url);
|
||||
},
|
||||
[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) {
|
||||
renamingInputRef.current = element;
|
||||
element.focus();
|
||||
element.select();
|
||||
}
|
||||
},
|
||||
[renamingInputRef],
|
||||
);
|
||||
const handleRenameInputChange = useCallback(
|
||||
(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setRenamingTitle(event.target.value);
|
||||
},
|
||||
[setRenamingTitle],
|
||||
);
|
||||
const handleRenameInputKeyDown = useCallback(
|
||||
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
event.stopPropagation();
|
||||
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === "Enter") {
|
||||
@@ -1716,41 +1844,7 @@ export default function Sidebar() {
|
||||
() => openCommandPalette({ open: "add-project" }),
|
||||
[],
|
||||
);
|
||||
const { environments } = useEnvironments();
|
||||
const primaryEnvironmentId = usePrimaryEnvironmentId();
|
||||
const clearSelection = useThreadSelectionStore((s) => s.clearSelection);
|
||||
const setSelectionAnchor = useThreadSelectionStore((s) => s.setAnchor);
|
||||
const toggleThreadSelection = useThreadSelectionStore((s) => s.toggleThread);
|
||||
const rangeSelectTo = useThreadSelectionStore((s) => s.rangeSelectTo);
|
||||
const markThreadUnread = useUiStateStore((s) => s.markThreadUnread);
|
||||
const markThreadVisited = useUiStateStore((s) => s.markThreadVisited);
|
||||
const acknowledgeWoke = useCallback(
|
||||
(threadRef: ScopedThreadRef, visitedAt: string) => {
|
||||
markThreadVisited(scopedThreadKey(threadRef), visitedAt);
|
||||
},
|
||||
[markThreadVisited],
|
||||
);
|
||||
const routeTarget = useParams({
|
||||
strict: false,
|
||||
select: (params) => resolveThreadRouteTarget(params),
|
||||
});
|
||||
const routeDraftThread = useComposerDraftStore((store) =>
|
||||
routeTarget?.kind === "draft" ? store.getDraftSession(routeTarget.draftId) : null,
|
||||
);
|
||||
const routeThreadRef = useMemo(
|
||||
() => resolveActiveThreadRouteRef(routeTarget, routeDraftThread),
|
||||
[routeDraftThread, routeTarget],
|
||||
);
|
||||
const routeThreadKey = routeThreadRef ? scopedThreadKey(routeThreadRef) : null;
|
||||
const routeTargetRef = useRef(routeTarget);
|
||||
routeTargetRef.current = routeTarget;
|
||||
// Post-settle navigation validates against the CURRENT route, not the one
|
||||
// captured when the settle started: if the user navigated elsewhere while
|
||||
// the command was in flight, completing it must not yank them away.
|
||||
const routeThreadKeyRef = useRef(routeThreadKey);
|
||||
routeThreadKeyRef.current = routeThreadKey;
|
||||
|
||||
const environmentLabelById = useMemo(
|
||||
const sidebarThreadByKey = useMemo(
|
||||
() =>
|
||||
new Map(
|
||||
environments.map((environment) => [environment.environmentId, environment.label] as const),
|
||||
@@ -2191,16 +2285,42 @@ export default function Sidebar() {
|
||||
),
|
||||
[orderedThreads],
|
||||
);
|
||||
// Handlers read these through refs: depending on per-update Map/Set
|
||||
// identities would give every row a fresh callback prop on each shell
|
||||
// event and defeat row memoization during streaming.
|
||||
const threadByKeyRef = useRef(threadByKey);
|
||||
threadByKeyRef.current = threadByKey;
|
||||
// handleNewThread is inherently unstable (depends on the projects list);
|
||||
// a ref keeps it out of attemptSettle's dependency array.
|
||||
const handleNewThreadRef = useRef(newThreadContext.handleNewThread);
|
||||
handleNewThreadRef.current = newThreadContext.handleNewThread;
|
||||
const settledThreadKeys = useMemo(
|
||||
// Keep a ref so callbacks can read the latest map without appearing in
|
||||
// dependency arrays (avoids invalidating every thread-row memo on each
|
||||
// thread-list change).
|
||||
const sidebarThreadByKeyRef = useRef(sidebarThreadByKey);
|
||||
sidebarThreadByKeyRef.current = sidebarThreadByKey;
|
||||
const projectThreads = visibleSidebarThreads;
|
||||
const projectPreferenceKeys = useMemo(() => projectExpansionPreferenceKeys(project), [project]);
|
||||
const projectExpanded = useUiStateStore((state) =>
|
||||
resolveProjectExpanded(state.projectExpandedById, projectPreferenceKeys),
|
||||
);
|
||||
const threadLastVisitedAts = useUiStateStore(
|
||||
useShallow((state) =>
|
||||
projectThreads.map(
|
||||
(thread) =>
|
||||
state.threadLastVisitedAtById[
|
||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))
|
||||
] ?? null,
|
||||
),
|
||||
),
|
||||
);
|
||||
const [renamingThreadKey, setRenamingThreadKey] = useState<string | null>(null);
|
||||
const [renamingTitle, setRenamingTitle] = useState("");
|
||||
const [confirmingArchiveThreadKey, setConfirmingArchiveThreadKey] = useState<string | null>(null);
|
||||
const [projectRenameTarget, setProjectRenameTarget] = useState<SidebarProjectGroupMember | null>(
|
||||
null,
|
||||
);
|
||||
const [projectRenameTitle, setProjectRenameTitle] = useState("");
|
||||
const [projectGroupingTarget, setProjectGroupingTarget] =
|
||||
useState<SidebarProjectGroupMember | null>(null);
|
||||
const [projectGroupingSelection, setProjectGroupingSelection] = useState<
|
||||
SidebarProjectGroupingMode | "inherit"
|
||||
>("inherit");
|
||||
const renamingCommittedRef = useRef(false);
|
||||
const renamingInputRef = useRef<HTMLInputElement | null>(null);
|
||||
const confirmArchiveButtonRefs = useRef(new Map<string, HTMLButtonElement>());
|
||||
const memberProjectByScopedKey = useMemo(
|
||||
() =>
|
||||
new Set(
|
||||
settledThreads.map((thread) =>
|
||||
@@ -2413,38 +2533,6 @@ export default function Sidebar() {
|
||||
[navigateToThread, router],
|
||||
);
|
||||
|
||||
<<<<<<< HEAD
|
||||
const attemptSettle = useCallback(
|
||||
(threadRef: ScopedThreadRef, opts: { coSettlingKeys?: ReadonlySet<string> } = {}) => {
|
||||
void (async () => {
|
||||
const threadKey = scopedThreadKey(threadRef);
|
||||
if (settlingThreadKeysRef.current.has(threadKey)) return;
|
||||
settlingThreadKeysRef.current.add(threadKey);
|
||||
try {
|
||||
const navigateAfterSettle = planForwardNavigation(threadKey, opts.coSettlingKeys);
|
||||
const result = await settleThread(threadRef);
|
||||
if (result._tag === "Failure") {
|
||||
// Never navigate away from a thread that did not settle.
|
||||
if (!isAtomCommandInterrupted(result)) {
|
||||
const error = squashAtomCommandFailure(result);
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Failed to settle thread",
|
||||
description: error instanceof Error ? error.message : "An error occurred.",
|
||||
}),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Only move forward if the user is still on the settled thread —
|
||||
// a navigation made during the await wins over ours.
|
||||
if (routeThreadKeyRef.current === threadKey) {
|
||||
navigateAfterSettle?.();
|
||||
}
|
||||
} finally {
|
||||
settlingThreadKeysRef.current.delete(threadKey);
|
||||
=======
|
||||
const clicked = await api.contextMenu.show(
|
||||
buildMultiSelectThreadContextMenuItems({ count, hasRunningThread }),
|
||||
position,
|
||||
@@ -2454,7 +2542,6 @@ export default function Sidebar() {
|
||||
for (const threadKey of threadKeys) {
|
||||
const thread = sidebarThreadByKeyRef.current.get(threadKey);
|
||||
markThreadUnread(threadKey, thread?.latestRun?.completedAt);
|
||||
>>>>>>> 8f521e516e (Complete orchestration V2 frontend cutover)
|
||||
}
|
||||
})();
|
||||
},
|
||||
@@ -2974,16 +3061,6 @@ export default function Sidebar() {
|
||||
);
|
||||
|
||||
const handleThreadContextMenu = useCallback(
|
||||
<<<<<<< HEAD
|
||||
(threadRef: ScopedThreadRef, position: { x: number; y: number }) => {
|
||||
void (async () => {
|
||||
const api = readLocalApi();
|
||||
if (!api) return;
|
||||
const threadKey = scopedThreadKey(threadRef);
|
||||
const selectionState = useThreadSelectionStore.getState();
|
||||
if (selectionState.hasSelection() && selectionState.selectedThreadKeys.has(threadKey)) {
|
||||
await handleMultiSelectContextMenu(position);
|
||||
=======
|
||||
async (threadRef: ScopedThreadRef, position: { x: number; y: number }) => {
|
||||
const api = readLocalApi();
|
||||
if (!api) return;
|
||||
@@ -3051,7 +3128,6 @@ export default function Sidebar() {
|
||||
description: "This thread does not have a workspace path to copy.",
|
||||
}),
|
||||
);
|
||||
>>>>>>> 8f521e516e (Complete orchestration V2 frontend cutover)
|
||||
return;
|
||||
}
|
||||
const thread = threadByKeyRef.current.get(threadKey);
|
||||
@@ -3253,6 +3329,390 @@ export default function Sidebar() {
|
||||
? selectThreadTerminalUiState(state.terminalUiStateByThreadKey, routeThreadRef).terminalOpen
|
||||
: false,
|
||||
);
|
||||
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
|
||||
const openAddProjectCommandPalette = useCallback(
|
||||
() => openCommandPalette({ open: "add-project" }),
|
||||
[],
|
||||
);
|
||||
const [expandedThreadListsByProject, setExpandedThreadListsByProject] = useState<
|
||||
ReadonlySet<string>
|
||||
>(() => new Set());
|
||||
const { showThreadJumpHints, updateThreadJumpHintsVisibility } = useThreadJumpHintVisibility();
|
||||
const dragInProgressRef = useRef(false);
|
||||
const suppressProjectClickAfterDragRef = useRef(false);
|
||||
const suppressProjectClickForContextMenuRef = useRef(false);
|
||||
const desktopUpdateState = useDesktopUpdateState();
|
||||
const clearSelection = useThreadSelectionStore((s) => s.clearSelection);
|
||||
const setSelectionAnchor = useThreadSelectionStore((s) => s.setAnchor);
|
||||
const platform = navigator.platform;
|
||||
const shortcutModifiers = useShortcutModifierState();
|
||||
const { environments } = useEnvironments();
|
||||
const primaryEnvironmentId = usePrimaryEnvironmentId();
|
||||
const environmentLabelById = useMemo(
|
||||
() =>
|
||||
new Map(
|
||||
environments.map((environment) => [environment.environmentId, environment.label] as const),
|
||||
),
|
||||
[environments],
|
||||
);
|
||||
const desktopLocalEnvironmentIds = useMemo(
|
||||
() =>
|
||||
new Set(
|
||||
environments
|
||||
.filter((environment) => isDesktopLocalConnectionTarget(environment.entry.target))
|
||||
.map((environment) => environment.environmentId),
|
||||
),
|
||||
[environments],
|
||||
);
|
||||
const orderedProjects = useMemo(() => {
|
||||
return orderItemsByPreferredIds({
|
||||
items: projects,
|
||||
preferredIds: projectOrder,
|
||||
getId: getProjectOrderKey,
|
||||
getPreferenceIds: (project) => [
|
||||
getProjectOrderKey(project),
|
||||
legacyProjectCwdPreferenceKey(project.workspaceRoot),
|
||||
],
|
||||
});
|
||||
}, [projectOrder, projects]);
|
||||
|
||||
// Build a mapping from physical project key → logical project key for
|
||||
// cross-environment grouping. Projects that share a repositoryIdentity
|
||||
// canonicalKey are treated as one logical project in the sidebar.
|
||||
const physicalToLogicalKey = useMemo(() => {
|
||||
return buildPhysicalToLogicalProjectKeyMap({
|
||||
projects: orderedProjects,
|
||||
settings: projectGroupingSettings,
|
||||
primaryEnvironmentId,
|
||||
});
|
||||
}, [orderedProjects, projectGroupingSettings, primaryEnvironmentId]);
|
||||
const projectPhysicalKeyByScopedRef = useMemo(
|
||||
() =>
|
||||
new Map(
|
||||
orderedProjects.map((project) => [
|
||||
scopedProjectKey(scopeProjectRef(project.environmentId, project.id)),
|
||||
derivePhysicalProjectKey(project),
|
||||
]),
|
||||
),
|
||||
[orderedProjects],
|
||||
);
|
||||
|
||||
const sidebarProjects = useMemo<SidebarProjectSnapshot[]>(() => {
|
||||
return buildSidebarProjectSnapshots({
|
||||
projects: orderedProjects,
|
||||
settings: projectGroupingSettings,
|
||||
primaryEnvironmentId,
|
||||
resolveEnvironmentLabel: (environmentId) => environmentLabelById.get(environmentId) ?? null,
|
||||
isDesktopLocalEnvironment: (environmentId) => desktopLocalEnvironmentIds.has(environmentId),
|
||||
});
|
||||
}, [
|
||||
environmentLabelById,
|
||||
desktopLocalEnvironmentIds,
|
||||
orderedProjects,
|
||||
projectGroupingSettings,
|
||||
primaryEnvironmentId,
|
||||
]);
|
||||
|
||||
const sidebarProjectByKey = useMemo(
|
||||
() => new Map(sidebarProjects.map((project) => [project.projectKey, project] as const)),
|
||||
[sidebarProjects],
|
||||
);
|
||||
const sidebarThreadByKey = useMemo(
|
||||
() =>
|
||||
new Map(
|
||||
sidebarThreads.map(
|
||||
(thread) =>
|
||||
[scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)), thread] as const,
|
||||
),
|
||||
),
|
||||
[sidebarThreads],
|
||||
);
|
||||
// Resolve the active route's project key to a logical key so it matches the
|
||||
// sidebar's grouped project entries.
|
||||
const activeRouteProjectKey = useMemo(() => {
|
||||
if (!routeThreadKey) {
|
||||
return null;
|
||||
}
|
||||
const activeThread = sidebarThreadByKey.get(routeThreadKey);
|
||||
if (!activeThread) return null;
|
||||
const physicalKey =
|
||||
projectPhysicalKeyByScopedRef.get(
|
||||
scopedProjectKey(scopeProjectRef(activeThread.environmentId, activeThread.projectId)),
|
||||
) ?? scopedProjectKey(scopeProjectRef(activeThread.environmentId, activeThread.projectId));
|
||||
return physicalToLogicalKey.get(physicalKey) ?? physicalKey;
|
||||
}, [routeThreadKey, sidebarThreadByKey, physicalToLogicalKey, projectPhysicalKeyByScopedRef]);
|
||||
|
||||
// Group threads by logical project key so all threads from grouped projects
|
||||
// are displayed together.
|
||||
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)),
|
||||
) ?? scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId));
|
||||
const logicalKey = physicalToLogicalKey.get(physicalKey) ?? physicalKey;
|
||||
const existing = next.get(logicalKey);
|
||||
if (existing) {
|
||||
existing.push(thread);
|
||||
} else {
|
||||
next.set(logicalKey, [thread]);
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}, [sidebarThreads, physicalToLogicalKey, projectPhysicalKeyByScopedRef]);
|
||||
const getCurrentSidebarShortcutContext = useCallback(
|
||||
() => ({
|
||||
terminalFocus: isTerminalFocused(),
|
||||
terminalOpen: routeTerminalOpen,
|
||||
modelPickerOpen: isModelPickerOpen(),
|
||||
}),
|
||||
[routeTerminalOpen],
|
||||
);
|
||||
const newThreadShortcutLabelOptions = useMemo(
|
||||
() => ({
|
||||
platform,
|
||||
context: {
|
||||
terminalFocus: false,
|
||||
terminalOpen: false,
|
||||
},
|
||||
}),
|
||||
[platform],
|
||||
);
|
||||
const newThreadShortcutLabel =
|
||||
shortcutLabelForCommand(keybindings, "chat.newLocal", newThreadShortcutLabelOptions) ??
|
||||
shortcutLabelForCommand(keybindings, "chat.new", newThreadShortcutLabelOptions);
|
||||
|
||||
const navigateToThread = useCallback(
|
||||
(threadRef: ScopedThreadRef) => {
|
||||
if (useThreadSelectionStore.getState().selectedThreadKeys.size > 0) {
|
||||
clearSelection();
|
||||
}
|
||||
setSelectionAnchor(scopedThreadKey(threadRef));
|
||||
if (isMobile) {
|
||||
setOpenMobile(false);
|
||||
}
|
||||
void navigate({
|
||||
to: "/$environmentId/$threadId",
|
||||
params: buildThreadRouteParams(threadRef),
|
||||
});
|
||||
},
|
||||
[clearSelection, isMobile, navigate, setOpenMobile, setSelectionAnchor],
|
||||
);
|
||||
|
||||
const projectDnDSensors = useSensors(
|
||||
useSensor(PointerSensor, {
|
||||
activationConstraint: { distance: 6 },
|
||||
}),
|
||||
);
|
||||
const projectCollisionDetection = useCallback<CollisionDetection>((args) => {
|
||||
const pointerCollisions = pointerWithin(args);
|
||||
if (pointerCollisions.length > 0) {
|
||||
return pointerCollisions;
|
||||
}
|
||||
|
||||
return closestCorners(args);
|
||||
}, []);
|
||||
|
||||
const handleProjectDragEnd = useCallback(
|
||||
(event: DragEndEvent) => {
|
||||
if (sidebarProjectSortOrder !== "manual") {
|
||||
dragInProgressRef.current = false;
|
||||
return;
|
||||
}
|
||||
dragInProgressRef.current = false;
|
||||
const { active, over } = event;
|
||||
if (!over || active.id === over.id) return;
|
||||
const activeProject = sidebarProjects.find((project) => project.projectKey === active.id);
|
||||
const overProject = sidebarProjects.find((project) => project.projectKey === over.id);
|
||||
if (!activeProject || !overProject) return;
|
||||
const activeMemberKeys = activeProject.memberProjects.map(
|
||||
(member) => member.physicalProjectKey,
|
||||
);
|
||||
const overMemberKeys = overProject.memberProjects.map((member) => member.physicalProjectKey);
|
||||
reorderProjects(orderedProjects.map(getProjectOrderKey), activeMemberKeys, overMemberKeys);
|
||||
},
|
||||
[orderedProjects, sidebarProjectSortOrder, reorderProjects, sidebarProjects],
|
||||
);
|
||||
|
||||
const handleProjectDragStart = useCallback(
|
||||
(_event: DragStartEvent) => {
|
||||
if (sidebarProjectSortOrder !== "manual") {
|
||||
return;
|
||||
}
|
||||
dragInProgressRef.current = true;
|
||||
suppressProjectClickAfterDragRef.current = true;
|
||||
},
|
||||
[sidebarProjectSortOrder],
|
||||
);
|
||||
|
||||
const handleProjectDragCancel = useCallback((_event: DragCancelEvent) => {
|
||||
dragInProgressRef.current = false;
|
||||
}, []);
|
||||
|
||||
const animatedProjectListsRef = useRef(new WeakSet<HTMLElement>());
|
||||
const attachProjectListAutoAnimateRef = useCallback((node: HTMLElement | null) => {
|
||||
if (!node || animatedProjectListsRef.current.has(node)) {
|
||||
return;
|
||||
}
|
||||
autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
|
||||
animatedProjectListsRef.current.add(node);
|
||||
}, []);
|
||||
|
||||
const animatedThreadListsRef = useRef(new WeakSet<HTMLElement>());
|
||||
const attachThreadListAutoAnimateRef = useCallback((node: HTMLElement | null) => {
|
||||
if (!node || animatedThreadListsRef.current.has(node)) {
|
||||
return;
|
||||
}
|
||||
autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
|
||||
animatedThreadListsRef.current.add(node);
|
||||
}, []);
|
||||
|
||||
const visibleThreads = useMemo(
|
||||
() =>
|
||||
sidebarThreads.filter(
|
||||
(thread) => thread.archivedAt === null && !isSidebarSubagentThread(thread),
|
||||
),
|
||||
[sidebarThreads],
|
||||
);
|
||||
const sortedProjects = useMemo(() => {
|
||||
const sortableProjects = sidebarProjects.map((project) => ({
|
||||
...project,
|
||||
id: project.projectKey,
|
||||
}));
|
||||
const sortableThreads = visibleThreads.map((thread) => {
|
||||
const physicalKey =
|
||||
projectPhysicalKeyByScopedRef.get(
|
||||
scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId)),
|
||||
) ?? scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId));
|
||||
return {
|
||||
...thread,
|
||||
projectId: (physicalToLogicalKey.get(physicalKey) ?? physicalKey) as ProjectId,
|
||||
};
|
||||
});
|
||||
return sortProjectsForSidebar(
|
||||
sortableProjects,
|
||||
sortableThreads,
|
||||
sidebarProjectSortOrder,
|
||||
).flatMap((project) => {
|
||||
const resolvedProject = sidebarProjectByKey.get(project.id);
|
||||
return resolvedProject ? [resolvedProject] : [];
|
||||
});
|
||||
}, [
|
||||
sidebarProjectSortOrder,
|
||||
physicalToLogicalKey,
|
||||
projectPhysicalKeyByScopedRef,
|
||||
sidebarProjectByKey,
|
||||
sidebarProjects,
|
||||
visibleThreads,
|
||||
]);
|
||||
const isManualProjectSorting = sidebarProjectSortOrder === "manual";
|
||||
const visibleSidebarThreadKeys = useMemo(
|
||||
() =>
|
||||
sortedProjects.flatMap((project) => {
|
||||
const projectThreads = sortThreads(
|
||||
(threadsByProjectKey.get(project.projectKey) ?? []).filter(
|
||||
(thread) => thread.archivedAt === null,
|
||||
),
|
||||
sidebarThreadSortOrder,
|
||||
);
|
||||
const projectExpanded = resolveProjectExpanded(
|
||||
projectExpandedById,
|
||||
projectExpansionPreferenceKeys(project),
|
||||
);
|
||||
const activeThreadKey = routeThreadKey ?? undefined;
|
||||
const pinnedCollapsedThread =
|
||||
!projectExpanded && activeThreadKey
|
||||
? (projectThreads.find(
|
||||
(thread) =>
|
||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) ===
|
||||
activeThreadKey,
|
||||
) ?? null)
|
||||
: null;
|
||||
const shouldShowThreadPanel = projectExpanded || pinnedCollapsedThread !== null;
|
||||
if (!shouldShowThreadPanel) {
|
||||
return [];
|
||||
}
|
||||
const isThreadListExpanded = expandedThreadListsByProject.has(project.projectKey);
|
||||
const hasOverflowingThreads = projectThreads.length > sidebarThreadPreviewCount;
|
||||
const previewThreads =
|
||||
isThreadListExpanded || !hasOverflowingThreads
|
||||
? projectThreads
|
||||
: projectThreads.slice(0, sidebarThreadPreviewCount);
|
||||
const renderedThreads = pinnedCollapsedThread ? [pinnedCollapsedThread] : previewThreads;
|
||||
return renderedThreads.map((thread) =>
|
||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
|
||||
);
|
||||
}),
|
||||
[
|
||||
sidebarThreadSortOrder,
|
||||
sidebarThreadPreviewCount,
|
||||
expandedThreadListsByProject,
|
||||
projectExpandedById,
|
||||
routeThreadKey,
|
||||
sortedProjects,
|
||||
threadsByProjectKey,
|
||||
],
|
||||
);
|
||||
const threadJumpCommandByKey = useMemo(() => {
|
||||
const mapping = new Map<string, NonNullable<ReturnType<typeof threadJumpCommandForIndex>>>();
|
||||
for (const [visibleThreadIndex, threadKey] of visibleSidebarThreadKeys.entries()) {
|
||||
const jumpCommand = threadJumpCommandForIndex(visibleThreadIndex);
|
||||
if (!jumpCommand) {
|
||||
return mapping;
|
||||
}
|
||||
mapping.set(threadKey, jumpCommand);
|
||||
}
|
||||
|
||||
return mapping;
|
||||
}, [visibleSidebarThreadKeys]);
|
||||
const threadJumpThreadKeys = useMemo(
|
||||
() => [...threadJumpCommandByKey.keys()],
|
||||
[threadJumpCommandByKey],
|
||||
);
|
||||
const sidebarShortcutContext = {
|
||||
terminalFocus: false,
|
||||
terminalOpen: routeTerminalOpen,
|
||||
modelPickerOpen: isModelPickerOpen(),
|
||||
};
|
||||
const threadJumpLabelByKey = useMemo(
|
||||
() =>
|
||||
buildThreadJumpLabelMap({
|
||||
keybindings,
|
||||
platform,
|
||||
terminalOpen: sidebarShortcutContext.terminalOpen,
|
||||
threadJumpCommandByKey,
|
||||
}),
|
||||
[keybindings, platform, sidebarShortcutContext.terminalOpen, threadJumpCommandByKey],
|
||||
);
|
||||
const shouldShowThreadJumpHintsNow = shouldShowThreadJumpHintsForModifiers(
|
||||
shortcutModifiers,
|
||||
keybindings,
|
||||
{
|
||||
platform,
|
||||
context: sidebarShortcutContext,
|
||||
},
|
||||
);
|
||||
const visibleThreadJumpLabelByKey = showThreadJumpHints
|
||||
? threadJumpLabelByKey
|
||||
: EMPTY_THREAD_JUMP_LABELS;
|
||||
const orderedSidebarThreadKeys = visibleSidebarThreadKeys;
|
||||
const prewarmedSidebarThreadKeys = useMemo(
|
||||
() => getSidebarThreadIdsToPrewarm(visibleSidebarThreadKeys),
|
||||
[visibleSidebarThreadKeys],
|
||||
);
|
||||
const prewarmedSidebarThreadRefs = useMemo(
|
||||
() =>
|
||||
prewarmedSidebarThreadKeys.flatMap((threadKey) => {
|
||||
const ref = parseScopedThreadKey(threadKey);
|
||||
return ref ? [ref] : [];
|
||||
}),
|
||||
[prewarmedSidebarThreadKeys],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const onWindowKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.defaultPrevented || event.repeat) return;
|
||||
|
||||
@@ -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={
|
||||
|
||||
@@ -57,7 +57,7 @@ import {
|
||||
EyeIcon,
|
||||
GitForkIcon,
|
||||
GlobeIcon,
|
||||
HammerIcon,
|
||||
type LucideIcon,
|
||||
MessageCircleIcon,
|
||||
MousePointerClickIcon,
|
||||
PaintbrushIcon,
|
||||
@@ -1337,11 +1337,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":
|
||||
@@ -1379,7 +1383,7 @@ function v2EventPresentation(item: OrchestrationV2TurnItem): {
|
||||
label: "Conversation fork",
|
||||
detail: `Continues in ${item.targetThreadId}`,
|
||||
tone: "muted",
|
||||
icon: HammerIcon,
|
||||
icon: GitForkIcon,
|
||||
};
|
||||
case "compaction": {
|
||||
const tokenSummary =
|
||||
@@ -1395,11 +1399,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 {
|
||||
@@ -2205,7 +2209,6 @@ type WorkEntryIconName =
|
||||
| "circle-alert"
|
||||
| "eye"
|
||||
| "globe"
|
||||
| "hammer"
|
||||
| "message-circle"
|
||||
| "square-pen"
|
||||
| "terminal"
|
||||
@@ -2225,8 +2228,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":
|
||||
@@ -2358,16 +2359,9 @@ function workEntryIconName(workEntry: TimelineWorkEntry): WorkEntryIconName {
|
||||
case "dynamic_tool":
|
||||
return "wrench";
|
||||
case "subagent":
|
||||
return "hammer";
|
||||
case "collab_agent_tool_call":
|
||||
return "bot";
|
||||
}
|
||||
|
||||
// Subagent lifecycle rows (grouped by taskId) get agent identity chrome.
|
||||
if (workEntry.taskId) {
|
||||
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";
|
||||
Reference in new issue
Block a user