From aee5f8d304e065bf749653b27b0f706b6cf5083a Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 23 Jul 2026 17:56:32 +0200 Subject: [PATCH] replace nested project actions with management dialog Co-authored-by: codex --- apps/web/src/components/Sidebar.logic.test.ts | 68 -------- apps/web/src/components/Sidebar.logic.ts | 57 ------- apps/web/src/components/SidebarV2.tsx | 159 ++++++++++++++---- 3 files changed, 123 insertions(+), 161 deletions(-) diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts index df7ab49acc..084cf0956b 100644 --- a/apps/web/src/components/Sidebar.logic.test.ts +++ b/apps/web/src/components/Sidebar.logic.test.ts @@ -2,7 +2,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test" import { archiveSelectedThreadEntries, buildMultiSelectThreadContextMenuItems, - buildSidebarV2ProjectActionItems, createThreadJumpHintVisibilityController, getSidebarThreadIdsToPrewarm, getVisibleSidebarThreadIds, @@ -37,73 +36,6 @@ import { ThreadId, } from "@t3tools/contracts"; -describe("buildSidebarV2ProjectActionItems", () => { - it("targets each physical member and makes remove-all explicit for grouped projects", () => { - expect( - buildSidebarV2ProjectActionItems([ - { - physicalProjectKey: "local:/repo", - title: "Local title", - workspaceRoot: "/repo", - environmentLabel: "Grouping Local", - }, - { - physicalProjectKey: "remote:/repo", - title: "Remote title", - workspaceRoot: "/repo", - environmentLabel: "Grouping Remote", - }, - ]), - ).toEqual([ - { - id: "rename:submenu", - label: "Rename project entry", - children: [ - { id: "rename:local:/repo", label: "Grouping Local — /repo" }, - { id: "rename:remote:/repo", label: "Grouping Remote — /repo" }, - ], - }, - { - id: "grouping:submenu", - label: "Group into…", - children: [ - { id: "grouping:local:/repo", label: "Grouping Local — /repo" }, - { id: "grouping:remote:/repo", label: "Grouping Remote — /repo" }, - ], - }, - { - id: "copy-path:submenu", - label: "Copy Path", - children: [ - { id: "copy-path:local:/repo", label: "Grouping Local — /repo" }, - { id: "copy-path:remote:/repo", label: "Grouping Remote — /repo" }, - ], - }, - { - id: "remove:submenu", - label: "Remove", - children: [ - { - id: "remove:local:/repo", - label: "Grouping Local — /repo", - destructive: true, - }, - { - id: "remove:remote:/repo", - label: "Grouping Remote — /repo", - destructive: true, - }, - ], - }, - { - id: "remove-all", - label: "Remove all grouped entries…", - destructive: true, - icon: "trash", - }, - ]); - }); -}); import { DEFAULT_INTERACTION_MODE, DEFAULT_RUNTIME_MODE, diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts index 91a10ce844..04124feb58 100644 --- a/apps/web/src/components/Sidebar.logic.ts +++ b/apps/web/src/components/Sidebar.logic.ts @@ -44,63 +44,6 @@ type LogicalSidebarProject = SidebarProject & { }[]; }; -type ProjectActionMember = { - readonly physicalProjectKey: string; - readonly title: string; - readonly workspaceRoot: string; - readonly environmentLabel: string | null; -}; - -export function buildSidebarV2ProjectActionItems( - members: readonly ProjectActionMember[], -): ContextMenuItem[] { - const memberLabel = (member: ProjectActionMember) => - members.length > 1 - ? member.environmentLabel - ? `${member.environmentLabel} — ${member.workspaceRoot}` - : member.workspaceRoot - : member.title; - const targetedItem = ( - action: "rename" | "grouping" | "copy-path" | "remove", - label: string, - destructive = false, - ): ContextMenuItem => { - if (members.length === 1) { - return { - id: `${action}:${members[0]!.physicalProjectKey}`, - label, - ...(destructive ? { destructive: true, icon: "trash" as const } : {}), - }; - } - return { - id: `${action}:submenu`, - label, - children: members.map((member) => ({ - id: `${action}:${member.physicalProjectKey}`, - label: memberLabel(member), - ...(destructive ? { destructive: true } : {}), - })), - }; - }; - - return [ - targetedItem("rename", members.length > 1 ? "Rename project entry" : "Rename"), - targetedItem("grouping", "Group into…"), - targetedItem("copy-path", "Copy Path"), - targetedItem("remove", "Remove", true), - ...(members.length > 1 - ? [ - { - id: "remove-all", - label: "Remove all grouped entries…", - destructive: true, - icon: "trash" as const, - }, - ] - : []), - ]; -} - export type ThreadTraversalDirection = "previous" | "next"; export async function archiveSelectedThreadEntries< diff --git a/apps/web/src/components/SidebarV2.tsx b/apps/web/src/components/SidebarV2.tsx index 9beb2fe5e7..cadbdb99fd 100644 --- a/apps/web/src/components/SidebarV2.tsx +++ b/apps/web/src/components/SidebarV2.tsx @@ -90,7 +90,6 @@ import type { SidebarThreadSummary } from "../types"; import { cn } from "~/lib/utils"; import { firstValidTimestampMs, - buildSidebarV2ProjectActionItems, hasUnseenCompletion, isTrailingDoubleClick, orderItemsByPreferredIds, @@ -797,6 +796,9 @@ export default function SidebarV2() { null, ); const [projectRenameTitle, setProjectRenameTitle] = useState(""); + const [projectActionsTarget, setProjectActionsTarget] = useState( + null, + ); const [projectGroupingTarget, setProjectGroupingTarget] = useState(null); const [projectGroupingSelection, setProjectGroupingSelection] = useState< @@ -1124,44 +1126,12 @@ export default function SidebarV2() { ]); const handleProjectActions = useCallback( - async (event: ReactMouseEvent, projectGroup: SidebarProjectSnapshot) => { + (event: ReactMouseEvent, projectGroup: SidebarProjectSnapshot) => { event.preventDefault(); event.stopPropagation(); - const api = readLocalApi(); - if (!api) return; - const clicked = await api.contextMenu.show( - buildSidebarV2ProjectActionItems(projectGroup.memberProjects), - { x: event.clientX, y: event.clientY }, - ); - if (!clicked) return; - if (clicked === "remove-all") { - await handleRemoveProjectMembers(projectGroup, projectGroup.memberProjects); - return; - } - const member = projectGroup.memberProjects.find((candidate) => - clicked.endsWith(`:${candidate.physicalProjectKey}`), - ); - if (!member) return; - if (clicked.startsWith("rename:")) { - setProjectRenameTarget(member); - setProjectRenameTitle(member.title); - } else if (clicked.startsWith("grouping:")) { - const overrideKey = deriveProjectGroupingOverrideKey(member); - setProjectGroupingTarget(member); - setProjectGroupingSelection( - projectGroupingSettings.sidebarProjectGroupingOverrides?.[overrideKey] ?? "inherit", - ); - } else if (clicked.startsWith("copy-path:")) { - copyProjectPath(member.workspaceRoot, { path: member.workspaceRoot }); - } else if (clicked.startsWith("remove:")) { - await handleRemoveProjectMembers(projectGroup, [member]); - } + setProjectActionsTarget(projectGroup); }, - [ - copyProjectPath, - handleRemoveProjectMembers, - projectGroupingSettings.sidebarProjectGroupingOverrides, - ], + [], ); // Settled threads stay in the live shell stream (settled ≠ archived), so @@ -2022,6 +1992,123 @@ export default function SidebarV2() { ) : null} + { + if (!open) setProjectActionsTarget(null); + }} + > + + + Manage {projectActionsTarget?.displayName ?? "project"} + + {projectActionsTarget && projectActionsTarget.memberProjects.length > 1 + ? "Manage each environment's project entry independently." + : "Rename, regroup, copy, or remove this project entry."} + + + + {projectActionsTarget?.memberProjects.map((member) => ( +
+
+ +
+
+ {member.title} +
+
+ {member.environmentLabel + ? `${member.environmentLabel} · ${member.workspaceRoot}` + : member.workspaceRoot} +
+
+
+
+ + + + +
+
+ ))} + {projectActionsTarget && projectActionsTarget.memberProjects.length > 1 ? ( +
+

+ Removes every grouped entry and its conversation history. +

+ +
+ ) : null} +
+ + + +
+
{