feat(web): open project settings from thread menus (#8925)

This commit is contained in:
Dara Adedeji authored and GitHub committed 2026-09-01 16:43:24 -04:00
1 parent 9d1879b142
commit cb00746916
6 files changed
+105 -7

No files matched your search

+14
View File
@@ -2165,11 +2165,21 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
{ id: "mark-unread", label: "Mark unread" },
{ id: "copy-path", label: "Copy Path" },
{ id: "copy-thread-id", label: "Copy Thread ID" },
{ id: "project-settings", label: "Project settings" },
{ id: "delete", label: "Delete", destructive: true, icon: "trash" },
],
position,
);
if (clicked === "project-settings") {
if (isMobile) setOpenMobile(false);
void router.navigate({
to: "/projects/$projectKey",
params: { projectKey: project.projectKey },
});
return;
}
if (clicked === "new-thread-on-branch") {
// Explicit branch carry-over: reuse the thread's worktree when it
// has one, otherwise its branch on the local checkout.
@@ -2252,9 +2262,13 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
copyThreadIdToClipboard,
deleteThread,
handleNewThread,
isMobile,
markThreadUnread,
memberProjectByScopedKey,
project.projectKey,
project.workspaceRoot,
router,
setOpenMobile,
startThreadRename,
],
);
+25 -5
View File
@@ -1888,6 +1888,8 @@ export default function Sidebar() {
() => sortLogicalProjectsForSidebar(unsortedProjectGroups, threads, sidebarProjectSortOrder),
[sidebarProjectSortOrder, threads, unsortedProjectGroups],
);
const projectGroupsRef = useRef(projectGroups);
projectGroupsRef.current = projectGroups;
const serverConfigs = useAtomValue(environmentServerConfigsAtom);
// Threads on non-primary environments (T3 Connect, hosted) resolve their
// provider entry from their own environment's config: default instance ids
@@ -2043,11 +2045,8 @@ export default function Sidebar() {
clearSelection();
}, [clearSelection, projectScopeKey]);
const handleProjectSettings = useCallback(
(event: ReactMouseEvent<HTMLButtonElement>, projectGroup: SidebarProjectSnapshot) => {
event.preventDefault();
event.stopPropagation();
dispatchProjectScopeMenu({ type: "project-settings-opened" });
const openProjectSettings = useCallback(
(projectGroup: SidebarProjectSnapshot) => {
if (isMobile) {
setOpenMobile(false);
}
@@ -2058,6 +2057,15 @@ export default function Sidebar() {
},
[isMobile, router, setOpenMobile],
);
const handleProjectSettings = useCallback(
(event: ReactMouseEvent<HTMLButtonElement>, projectGroup: SidebarProjectSnapshot) => {
event.preventDefault();
event.stopPropagation();
dispatchProjectScopeMenu({ type: "project-settings-opened" });
openProjectSettings(projectGroup);
},
[openProjectSettings],
);
// Settled threads stay in the live shell stream (settled ≠ archived), so
// the partition works directly off live shells: no archived-snapshot
@@ -3122,6 +3130,17 @@ export default function Sidebar() {
return;
}
switch (clicked.value) {
case "project-settings": {
const projectGroup = projectGroupsRef.current.find((group) =>
group.memberProjectRefs.some(
(projectRef) =>
projectRef.environmentId === thread.environmentId &&
projectRef.projectId === thread.projectId,
),
);
if (projectGroup) openProjectSettings(projectGroup);
return;
}
case "new-thread-on-branch": {
// Explicit branch carry-over: reuse the thread's worktree when it
// has one, otherwise its branch on the local checkout.
@@ -3281,6 +3300,7 @@ export default function Sidebar() {
deleteThread,
handleMultiSelectContextMenu,
markThreadUnread,
openProjectSettings,
projectCwdByKey,
serverConfigs,
startThreadRename,
@@ -33,7 +33,18 @@ describe("buildThreadActionMenuItems", () => {
...baseState,
supports: { settlement: false, snooze: false, pinning: false, titleRegeneration: false },
}),
).toEqual(["rename", "mark-unread", "copy", "archive", "delete"]);
).toEqual(["rename", "mark-unread", "copy", "project-settings", "archive", "delete"]);
});
it("groups project settings with utility actions before archive", () => {
const items = buildThreadActionMenuItems(baseState);
const copyIndex = items.findIndex((item) => item.id === "copy");
expect(items[copyIndex + 1]).toMatchObject({
id: "project-settings",
label: "Project settings",
icon: "settings",
});
expect(items[copyIndex + 2]?.id).toBe("archive");
});
it("includes branch items only for threads with a branch", () => {
@@ -8,6 +8,7 @@ import type { SnoozePreset } from "@t3tools/client-runtime/state/thread-settled"
*/
export type ThreadActionMenuId =
| "new-thread-on-branch"
| "project-settings"
| "pin"
| "unpin"
| "settle"
@@ -119,6 +120,7 @@ export function buildThreadActionMenuItems(
{ id: "copy-thread-id", label: "Thread ID", icon: "hash" },
],
},
{ id: "project-settings", label: "Project settings", icon: "settings" },
// Archive removes the thread from the sidebar while keeping its
// conversation under Settings > Archived threads — distinct from Settle
// (stays visible in the Settled shelf) and Delete (clears history for
+9
View File
@@ -96,6 +96,15 @@ const ICON_PATHS: Record<string, ReadonlyArray<{ tag: string; attrs: Record<stri
{ tag: "path", attrs: { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" } },
{ tag: "path", attrs: { d: "M8 16H3v5" } },
],
settings: [
{
tag: "path",
attrs: {
d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.38a2 2 0 0 0-.73-2.73l-.15-.09a2 2 0 0 1-1-1.74v-.51a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",
},
},
{ tag: "circle", attrs: { cx: "12", cy: "12", r: "3" } },
],
"folder-tree": [
{
tag: "path",
+43 -1
View File
@@ -7,7 +7,8 @@ import {
} from "@t3tools/client-runtime/state/runtime";
import { canSnooze, effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled";
import type { ScopedThreadRef, ThreadId } from "@t3tools/contracts";
import { useCallback } from "react";
import { useRouter } from "@tanstack/react-router";
import { useCallback, useMemo } from "react";
import { resolveSnoozePresets, snoozeWakeDescription } from "../components/Sidebar.snooze";
import {
@@ -23,8 +24,16 @@ import {
readEnvironmentSupportsSnooze,
readEnvironmentSupportsTitleRegeneration,
readThreadShell,
useProjects,
} from "../state/entities";
import { usePrimaryEnvironmentId } from "../state/environments";
import { readLocalApi } from "../localApi";
import {
deriveLogicalProjectKeyFromSettings,
derivePhysicalProjectKey,
selectProjectGroupingSettings,
} from "../logicalProject";
import { buildPhysicalToLogicalProjectKeyMap } from "../sidebarProjectGrouping";
import { useUiStateStore } from "../uiStateStore";
import { useCopyToClipboard } from "./useCopyToClipboard";
import { useNewThreadHandler } from "./useHandleNewThread";
@@ -58,6 +67,19 @@ export function useThreadActionMenu(input: {
readonly onStartRename: () => void;
}) {
const { threadRef, projectCwd, onStartRename } = input;
const router = useRouter();
const projects = useProjects();
const primaryEnvironmentId = usePrimaryEnvironmentId();
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
const logicalProjectKeyByPhysicalKey = useMemo(
() =>
buildPhysicalToLogicalProjectKeyMap({
projects,
settings: projectGroupingSettings,
primaryEnvironmentId,
}),
[primaryEnvironmentId, projectGroupingSettings, projects],
);
const {
settleThread,
unsettleThread,
@@ -168,6 +190,22 @@ export function useThreadActionMenu(input: {
}
};
switch (action) {
case "project-settings": {
const project = projects.find(
(candidate) =>
candidate.environmentId === thread.environmentId &&
candidate.id === thread.projectId,
);
if (!project) return;
const projectKey =
logicalProjectKeyByPhysicalKey.get(derivePhysicalProjectKey(project)) ??
deriveLogicalProjectKeyFromSettings(project, projectGroupingSettings);
void router.navigate({
to: "/projects/$projectKey",
params: { projectKey },
});
return;
}
case "new-thread-on-branch": {
// Explicit branch carry-over: reuse the thread's worktree when it
// has one, otherwise its branch on the local checkout.
@@ -300,10 +338,14 @@ export function useThreadActionMenu(input: {
copyThreadIdToClipboard,
deleteThread,
handleNewThread,
logicalProjectKeyByPhysicalKey,
markThreadUnread,
onStartRename,
pinThread,
projectCwd,
projectGroupingSettings,
projects,
router,
settleThread,
snoozeThread,
threadRef,