Skip to content

Commit 06b6d63

Browse files
committed
feat(sig): add copy task ID to context menu
Generated-By: PostHog Code Task-Id: f9d7c635-6d95-4255-8a4d-d2281b1e0389
1 parent 80d59e0 commit 06b6d63

4 files changed

Lines changed: 14 additions & 21 deletions

File tree

apps/code/src/main/services/context-menu/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const externalAppAction = z.discriminatedUnion("type", [
3333
const taskAction = z.discriminatedUnion("type", [
3434
z.object({ type: z.literal("rename") }),
3535
z.object({ type: z.literal("pin") }),
36+
z.object({ type: z.literal("copy-task-id") }),
3637
z.object({ type: z.literal("suspend") }),
3738
z.object({ type: z.literal("archive") }),
3839
z.object({ type: z.literal("delete") }),

apps/code/src/main/services/context-menu/service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class ContextMenuService {
110110
return this.showMenu<TaskAction>([
111111
this.item("Rename", { type: "rename" }),
112112
this.item(isPinned ? "Unpin" : "Pin", { type: "pin" }),
113+
this.item("Copy Task ID", { type: "copy-task-id" }),
113114
this.separator(),
114115
...(worktreePath
115116
? [this.item("Suspend", { type: "suspend" as const })]

apps/code/src/renderer/features/task-detail/components/TaskDetail.tsx

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ import { useWorkspace } from "@features/workspace/hooks/useWorkspace";
1616
import { useBlurOnEscape } from "@hooks/useBlurOnEscape";
1717
import { useFileWatcher } from "@hooks/useFileWatcher";
1818
import { useSetHeaderContent } from "@hooks/useSetHeaderContent";
19-
import { Box, Flex, Text, Tooltip } from "@radix-ui/themes";
19+
import { Box, Flex, Text } from "@radix-ui/themes";
2020
import type { Task } from "@shared/types";
2121
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2222
import { useHotkeys, useHotkeysContext } from "react-hotkeys-hook";
23-
import { toast } from "sonner";
2423
import { ExternalAppsOpener } from "./ExternalAppsOpener";
2524

2625
const MIN_REVIEW_WIDTH = 300;
@@ -86,33 +85,20 @@ export function TaskDetail({ task: initialTask }: TaskDetailProps) {
8685
useBlurOnEscape();
8786
useWorkspaceEvents(taskId);
8887

89-
const copyTaskId = useCallback(() => {
90-
navigator.clipboard.writeText(taskId);
91-
toast.success("Task ID copied");
92-
}, [taskId]);
93-
9488
const headerContent = useMemo(
9589
() => (
9690
<Flex align="center" justify="between" gap="2" width="100%">
9791
<Text size="1" weight="medium" truncate style={{ minWidth: 0 }}>
9892
{task.title}
9993
</Text>
100-
<Flex align="center" gap="2" className="shrink-0">
101-
<Tooltip content="Copy task ID">
102-
<button
103-
type="button"
104-
onClick={copyTaskId}
105-
className="no-drag cursor-pointer border-0 bg-transparent p-0 font-mono text-[10px] text-gray-9 hover:text-gray-11"
106-
style={{ lineHeight: "20px" }}
107-
>
108-
{taskId}
109-
</button>
110-
</Tooltip>
111-
{openTargetPath && <ExternalAppsOpener targetPath={openTargetPath} />}
112-
</Flex>
94+
{openTargetPath && (
95+
<Flex align="center" gap="2" className="shrink-0">
96+
<ExternalAppsOpener targetPath={openTargetPath} />
97+
</Flex>
98+
)}
11399
</Flex>
114100
),
115-
[task.title, taskId, openTargetPath, copyTaskId],
101+
[task.title, openTargetPath],
116102
);
117103

118104
useSetHeaderContent(headerContent);

apps/code/src/renderer/hooks/useTaskContextMenu.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { Task } from "@shared/types";
77
import { handleExternalAppAction } from "@utils/handleExternalAppAction";
88
import { logger } from "@utils/logger";
99
import { useCallback, useState } from "react";
10+
import { toast } from "sonner";
1011

1112
const log = logger.scope("context-menu");
1213

@@ -47,6 +48,10 @@ export function useTaskContextMenu() {
4748
case "pin":
4849
onTogglePin?.();
4950
break;
51+
case "copy-task-id":
52+
navigator.clipboard.writeText(task.id);
53+
toast.success("Task ID copied");
54+
break;
5055
case "suspend":
5156
await suspendTask({ taskId: task.id, reason: "manual" });
5257
break;

0 commit comments

Comments
 (0)