diff --git a/apps/web/src/components/RightPanelTabs.tsx b/apps/web/src/components/RightPanelTabs.tsx index 1e8a1bc0aeeb6..cb9ce1ad96b20 100644 --- a/apps/web/src/components/RightPanelTabs.tsx +++ b/apps/web/src/components/RightPanelTabs.tsx @@ -72,7 +72,7 @@ import type { DesktopPreviewOverlay } from "~/previewStateStore"; import { linkedThreadTitle } from "~/linkedThreadSurface"; import type { RightPanelSurface } from "~/rightPanelStore"; import { cn } from "~/lib/utils"; -import { type FilePathCopyKind, filePathCopyLabel } from "~/fileContextMenu"; +import type { FilePathCopyKind } from "~/fileContextMenu"; import { issueStatePresentation } from "~/components/issue/issuePresentation"; import { issueEnvironment } from "~/state/issues"; import { resolveShortcutCommand, type ShortcutMatchContext } from "~/keybindings"; @@ -1353,9 +1353,9 @@ export function RightPanelTabs(props: RightPanelTabsProps) { if (surface.kind === "file" && surface.attachment === undefined) { // A host file's only path is the full one. if (!isAbsolutePath(surface.relativePath)) { - items.push({ id: "copy-relative-path", label: filePathCopyLabel("relative") }); + items.push({ id: "copy-relative-path", label: gt("Copy relative path") }); } - items.push({ id: "copy-full-path", label: filePathCopyLabel("full") }); + items.push({ id: "copy-full-path", label: gt("Copy full path") }); } const menuPreviewTabId = previewTabIdOf(surface, props.previewSessions); const menuOverlay = menuPreviewTabId ? (props.desktopByTabId[menuPreviewTabId] ?? null) : null; diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts index 0788159fe34ea..8e7761cfeb92a 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts @@ -39,7 +39,10 @@ import { deriveFinalResponseRunIdsKey, workEntryReadOutput, } from "./MessagesTimeline.logic"; -import { deriveTimelineMinimapItems } from "./MessagesTimeline.minimap"; +import { + computeTimelineMinimapState, + EMPTY_TIMELINE_MINIMAP_STATE, +} from "./MessagesTimeline.minimap"; import { workEntryIconName } from "./TimelineWorkEntryRow.logic"; describe("resolveAssistantMessageCopyState", () => { @@ -2950,16 +2953,21 @@ describe("deriveMessagesTimelineRows", () => { expect(finalIds(rows)).toEqual(["final-1", "final-3"]); expect( - deriveTimelineMinimapItems(rows, "final-assistant").map((item) => ({ - id: item.id, - primaryText: item.primaryText, - })), + computeTimelineMinimapState(rows, EMPTY_TIMELINE_MINIMAP_STATE).assistantItems.map( + (item) => ({ + id: item.id, + primaryText: item.primaryText, + }), + ), ).toEqual([ { id: "final-1-entry", primaryText: "Done." }, { id: "final-3-entry", primaryText: "Third answer." }, ]); expect( - deriveTimelineMinimapItems(rows, "user-turn").map((item) => [item.id, item.secondaryText]), + computeTimelineMinimapState(rows, EMPTY_TIMELINE_MINIMAP_STATE).userItems.map((item) => [ + item.id, + item.secondaryText, + ]), ).toEqual([ ["user-1-entry", "Done."], ["user-2-entry", "Still working."], diff --git a/apps/web/src/components/chat/MessagesTimeline.minimap.test.ts b/apps/web/src/components/chat/MessagesTimeline.minimap.test.ts index 835f885abe80d..91bf2e8a6019d 100644 --- a/apps/web/src/components/chat/MessagesTimeline.minimap.test.ts +++ b/apps/web/src/components/chat/MessagesTimeline.minimap.test.ts @@ -9,7 +9,6 @@ import { import type { MessagesTimelineRow } from "./MessagesTimeline.logic"; import { computeTimelineMinimapState, - deriveTimelineMinimapItems, EMPTY_TIMELINE_MINIMAP_STATE, resolveTimelineMinimapAnchorIndex, resolveTimelineMinimapAriaLabel, @@ -76,7 +75,7 @@ describe("resolveTimelineMinimapTooltipTranslate", () => { }); }); -describe("deriveTimelineMinimapItems", () => { +describe("computeTimelineMinimapState items", () => { it("lists replies in order without gaps and flags messages from other agents", () => { const rows = [ messageRow({ id: "user-1", role: "user", text: "user-1" }), @@ -92,20 +91,17 @@ describe("deriveTimelineMinimapItems", () => { ]; expect( - deriveTimelineMinimapItems(rows, "final-assistant").map(({ id, timestamp }) => [ - id, - timestamp, - ]), + computeTimelineMinimapState(rows, EMPTY_TIMELINE_MINIMAP_STATE).assistantItems.map( + ({ id, timestamp }) => [id, timestamp], + ), ).toEqual([ ["assistant-1", "updated:assistant-1"], ["assistant-3", "updated:assistant-3"], ]); expect( - deriveTimelineMinimapItems(rows, "user-turn").map(({ id, fromAgent, timestamp }) => [ - id, - fromAgent, - timestamp, - ]), + computeTimelineMinimapState(rows, EMPTY_TIMELINE_MINIMAP_STATE).userItems.map( + ({ id, fromAgent, timestamp }) => [id, fromAgent, timestamp], + ), ).toEqual([ ["user-1", false, "created:user-1"], ["user-2", false, "created:user-2"], @@ -122,7 +118,9 @@ describe("deriveTimelineMinimapItems", () => { }), ]; - expect(deriveTimelineMinimapItems(rows, "user-turn")[0]?.primaryText).toBeNull(); + expect( + computeTimelineMinimapState(rows, EMPTY_TIMELINE_MINIMAP_STATE).userItems[0]?.primaryText, + ).toBeNull(); }); it("previews a quote and a context chip in the user's message as their text", () => { @@ -146,9 +144,9 @@ describe("deriveTimelineMinimapItems", () => { messageRow({ id: "user-1", role: "user", text: `${quote}\nWhere does ${file} cover this?` }), ]; - expect(deriveTimelineMinimapItems(rows, "user-turn")[0]?.primaryText).toBe( - "The cache misses on a cold start. Where does README.md cover this?", - ); + expect( + computeTimelineMinimapState(rows, EMPTY_TIMELINE_MINIMAP_STATE).userItems[0]?.primaryText, + ).toBe("The cache misses on a cold start. Where does README.md cover this?"); }); }); diff --git a/apps/web/src/components/chat/MessagesTimeline.minimap.ts b/apps/web/src/components/chat/MessagesTimeline.minimap.ts index e135e831a23b0..eaabb23d7922e 100644 --- a/apps/web/src/components/chat/MessagesTimeline.minimap.ts +++ b/apps/web/src/components/chat/MessagesTimeline.minimap.ts @@ -15,8 +15,6 @@ import { const TIMELINE_MINIMAP_ARIA_EXCERPT_MAX_LENGTH = 120; export const TIMELINE_MINIMAP_PREVIEW_MAX_LENGTH = 240; -export type TimelineMinimapKind = "user-turn" | "final-assistant"; - export interface TimelineMinimapItem { readonly id: string; readonly rowIndex: number; @@ -240,14 +238,6 @@ export function computeTimelineMinimapState( }; } -export function deriveTimelineMinimapItems( - rows: ReadonlyArray, - kind: TimelineMinimapKind, -): ReadonlyArray { - const state = computeTimelineMinimapState(rows, EMPTY_TIMELINE_MINIMAP_STATE); - return kind === "user-turn" ? state.userItems : state.assistantItems; -} - export function resolveTimelineMinimapTooltipTranslate(index: number, itemCount: number): string { if (index === 0) { return "0%"; diff --git a/apps/web/src/components/chat/useRightPanelActions.ts b/apps/web/src/components/chat/useRightPanelActions.ts index 66d9d8dbc0e9f..7e936a03c3eef 100644 --- a/apps/web/src/components/chat/useRightPanelActions.ts +++ b/apps/web/src/components/chat/useRightPanelActions.ts @@ -316,7 +316,7 @@ export function useRightPanelActions(input: RightPanelActionsInput) { if (activeWorkspaceRoot === undefined) { toastManager.add({ type: "error", - title: "Failed to copy full path", + title: m(msg("Failed to copy full path")), description: "The project root is not loaded yet.", }); return; diff --git a/apps/web/src/components/linear/LinearIssueDetailPanel.tsx b/apps/web/src/components/linear/LinearIssueDetailPanel.tsx index 9948aca57ced5..9277a20aac5da 100644 --- a/apps/web/src/components/linear/LinearIssueDetailPanel.tsx +++ b/apps/web/src/components/linear/LinearIssueDetailPanel.tsx @@ -10,8 +10,6 @@ import type { ScopedThreadRef, } from "@t3tools/contracts"; import { - CheckIcon, - CopyIcon, CornerLeftUpIcon, ExternalLinkIcon, GitBranchIcon, @@ -19,7 +17,8 @@ import { SendIcon, } from "lucide-react"; import { useAtomValue } from "@effect/atom-react"; -import { useRef, useState, type ReactNode } from "react"; +import { msg, useGT } from "gt-react"; +import { useState, type ReactNode } from "react"; import { RefreshIcon } from "~/components/ui/refresh-icon"; import { cn } from "~/lib/utils"; @@ -33,11 +32,8 @@ import { formatRelativeTimeLabel } from "~/timestampFormat"; import { useRightPanelStore } from "../../rightPanelStore"; import ChatMarkdown from "../ChatMarkdown"; import { LinearIcon } from "../Icons"; -import { useCopyToClipboard } from "../../hooks/useCopyToClipboard"; -import { - ANCHORED_COPY_TOAST_TIMEOUT_MS, - showAnchoredCopyErrorToast, -} from "../ui/anchoredCopyToast"; +import { PullRequestCopyableCode } from "../pullRequest/PullRequestCopyableCode"; +import { PullRequestLabelChip } from "../pullRequest/pullRequestPresentation"; import { Badge } from "../ui/badge"; import { Button } from "../ui/button"; import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty"; @@ -48,7 +44,6 @@ import { linearCommentDraftKey, useLinearCommentDraftStore } from "./linearComme import { linearIssueUrl } from "./linearMarkdown.logic"; import { formatLinearDueDate, - LinearLabelPill, LinearPriorityIcon, LinearStateIcon, LinearUserAvatar, @@ -255,41 +250,12 @@ function DetailRow({ label, children }: { label: string; children: ReactNode }) ); } -function CopyButton({ value, label }: { value: string; label: string }) { - const ref = useRef(null); - const { copyToClipboard, isCopied } = useCopyToClipboard({ - onError: (error) => showAnchoredCopyErrorToast(ref, error), - timeout: ANCHORED_COPY_TOAST_TIMEOUT_MS, - }); - return ( - - copyToClipboard(value, undefined)} - > - {isCopied ? ( - - ) : ( - - )} - - } - /> - {label} - - ); -} - /** * Timestamps, the due date, and the branch name. Two label/value pairs per row once the panel * is wide enough for them, one below the other before that. */ function IssueDetails({ issue }: { issue: LinearIssue }) { + const gt = useGT(); const due = issue.dueDate ? formatLinearDueDate(issue.dueDate) : null; const settled = isEnded(issue.state); return ( @@ -328,10 +294,25 @@ function IssueDetails({ issue }: { issue: LinearIssue }) { {issue.branchName ? (
- - {issue.branchName} - - + + toastManager.add({ + type: "error", + title: gt("Failed to copy"), + description: error.message, + }) + } + className="font-mono text-2xs text-foreground/90" + />
) : null} @@ -701,7 +682,12 @@ export function LinearIssueDetailPanel({ {issue.labels.length > 0 ? (
{issue.labels.map((label) => ( - + ))}
) : null} diff --git a/apps/web/src/components/linear/linearPresentation.tsx b/apps/web/src/components/linear/linearPresentation.tsx index 1229502c6e944..934b7e9162490 100644 --- a/apps/web/src/components/linear/linearPresentation.tsx +++ b/apps/web/src/components/linear/linearPresentation.tsx @@ -146,19 +146,6 @@ export function LinearStateBadge({ ); } -export function LinearLabelPill({ label }: { label: LinearIssue["labels"][number] }) { - return ( - - - {label.name} - - ); -} - export function LinearUserAvatar({ user, className, diff --git a/apps/web/src/fileContextMenu.ts b/apps/web/src/fileContextMenu.ts index 40b5141ff486f..9e4efaa022ff7 100644 --- a/apps/web/src/fileContextMenu.ts +++ b/apps/web/src/fileContextMenu.ts @@ -29,7 +29,7 @@ import { toastManager } from "./components/ui/toast"; import { useAtomValue } from "@effect/atom-react"; import { msg, useMessages } from "gt-react"; -import type { MessageResolver } from "./i18n/messages"; +import { m, type MessageResolver } from "./i18n/messages"; export type FileContextMenuAction = | "reveal-in-folder" @@ -145,24 +145,20 @@ export function buildFileContextMenuItems(input: { if (input.hasRelativePath) { items.push({ id: "copy-relative-path", - label: filePathCopyLabel("relative"), + label: input.resolve(msg("Copy relative path")), icon: "copy", separatorBefore, }); } items.push({ id: "copy-full-path", - label: filePathCopyLabel("full"), + label: input.resolve(msg("Copy full path")), icon: "copy", separatorBefore: separatorBefore && !input.hasRelativePath, }); return items; } -export function filePathCopyLabel(kind: FilePathCopyKind): string { - return kind === "relative" ? "Copy relative path" : "Copy full path"; -} - /** Copies a file path and reports the outcome with the same toasts everywhere. */ export async function copyFilePathToClipboard( value: string, @@ -175,12 +171,14 @@ export async function copyFilePathToClipboard( if (!(await writeTextToClipboard(value, namedClipboardTarget(noun.toLowerCase())))) failure = "The path is empty."; } catch (error) { - failure = error instanceof Error ? error.message : "An error occurred."; + failure = error instanceof Error ? error.message : m(msg("An error occurred.")); } if (failure !== null) { toastManager.add({ type: "error", - title: `Failed to copy ${noun.toLowerCase()}`, + title: m( + kind === "relative" ? msg("Failed to copy relative path") : msg("Failed to copy full path"), + ), description: failure, }); return;