Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ export default function Sidebar() {
if (!api) return;
const thread = threads.find((t) => t.id === threadId);
if (!thread) return;

const threadProject = projects.find((project) => project.id === thread.projectId);
// When bulk-deleting, exclude the other threads being deleted so
// getOrphanedWorktreePathForThread correctly detects that no surviving
Expand Down Expand Up @@ -665,7 +664,7 @@ export default function Sidebar() {
],
);

const { copyToClipboard } = useCopyToClipboard<{ threadId: ThreadId }>({
const { copyToClipboard: copyThreadIdToClipboard } = useCopyToClipboard<{ threadId: ThreadId }>({
onCopy: (ctx) => {
toastManager.add({
type: "success",
Expand All @@ -681,21 +680,40 @@ export default function Sidebar() {
});
},
});
const { copyToClipboard: copyPathToClipboard } = useCopyToClipboard<{ path: string }>({
onCopy: (ctx) => {
toastManager.add({
type: "success",
title: "Path copied",
description: ctx.path,
});
},
onError: (error) => {
toastManager.add({
type: "error",
title: "Failed to copy path",
description: error instanceof Error ? error.message : "An error occurred.",
});
},
});
const handleThreadContextMenu = useCallback(
async (threadId: ThreadId, position: { x: number; y: number }) => {
const api = readNativeApi();
if (!api) return;
const thread = threads.find((t) => t.id === threadId);
if (!thread) return;
const threadWorkspacePath =
thread.worktreePath ?? projectCwdById.get(thread.projectId) ?? null;
const clicked = await api.contextMenu.show(
[
{ id: "rename", label: "Rename thread" },
{ id: "mark-unread", label: "Mark unread" },
{ id: "copy-path", label: "Copy Path" },
{ id: "copy-thread-id", label: "Copy Thread ID" },
{ id: "delete", label: "Delete", destructive: true },
],
position,
);
const thread = threads.find((t) => t.id === threadId);
if (!thread) return;

if (clicked === "rename") {
setRenamingThreadId(threadId);
Expand All @@ -708,8 +726,20 @@ export default function Sidebar() {
markThreadUnread(threadId);
return;
}
if (clicked === "copy-path") {
if (!threadWorkspacePath) {
toastManager.add({
type: "error",
title: "Path unavailable",
description: "This thread does not have a workspace path to copy.",
});
return;
}
copyPathToClipboard(threadWorkspacePath, { path: threadWorkspacePath });
return;
}
if (clicked === "copy-thread-id") {
copyToClipboard(threadId, { threadId });
copyThreadIdToClipboard(threadId, { threadId });
return;
}
if (clicked !== "delete") return;
Expand All @@ -726,7 +756,15 @@ export default function Sidebar() {
}
await deleteThread(threadId);
},
[appSettings.confirmThreadDelete, copyToClipboard, deleteThread, markThreadUnread, threads],
[
appSettings.confirmThreadDelete,
copyPathToClipboard,
copyThreadIdToClipboard,
deleteThread,
markThreadUnread,
projectCwdById,
threads,
],
);

const handleMultiSelectContextMenu = useCallback(
Expand Down