From 7ca702a253b90312d9aa9cf73c089d2545ce67b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Mon, 1 Jun 2026 01:43:15 +0800 Subject: [PATCH] fix(desktop): simplify changed-file open-with menus Changed-file rows are easier to scan when previewable files are grouped before source-only files, and the file open-with menu should only expose useful preview, editor, and reveal actions. Output target cards also no longer need a separate copy control now that open/open-with are the primary actions. Constraint: Keep the existing open-with API and menu components shared across changed files, workspace context menus, and output target cards. Rejected: Keep system-default open for files | it duplicated less predictable platform behavior and added a low-value final menu item. Confidence: high Scope-risk: narrow Directive: File open-with menus should stay ordered by immediate preview/open usefulness before editor and reveal actions. Tested: cd desktop && bun run test src/lib/openWithItems.test.ts src/components/workspace/WorkspaceFileOpenWith.test.tsx src/components/chat/AssistantOutputTargetCard.test.tsx src/components/chat/CurrentTurnChangeCard.test.tsx Tested: cd desktop && bun run lint Tested: cd desktop && bun run build Tested: git diff --check --- .../chat/AssistantOutputTargetCard.test.tsx | 7 ++-- .../chat/AssistantOutputTargetCard.tsx | 17 +--------- .../chat/CurrentTurnChangeCard.test.tsx | 19 +++++++++++ .../components/chat/CurrentTurnChangeCard.tsx | 10 +++--- .../workspace/WorkspaceFileOpenWith.test.tsx | 32 ++++--------------- .../workspace/WorkspaceFileOpenWith.tsx | 2 ++ desktop/src/i18n/locales/en.ts | 2 -- desktop/src/i18n/locales/zh.ts | 2 -- desktop/src/lib/openWithItems.test.ts | 15 ++++----- desktop/src/lib/openWithItems.ts | 1 - 10 files changed, 43 insertions(+), 64 deletions(-) diff --git a/desktop/src/components/chat/AssistantOutputTargetCard.test.tsx b/desktop/src/components/chat/AssistantOutputTargetCard.test.tsx index 40e69906..d43ebffc 100644 --- a/desktop/src/components/chat/AssistantOutputTargetCard.test.tsx +++ b/desktop/src/components/chat/AssistantOutputTargetCard.test.tsx @@ -93,12 +93,9 @@ describe('AssistantOutputTargetCard', () => { expect(openBrowser).toHaveBeenCalledWith('s1', 'http://localhost:5173/') }) - it('copies the normalized path when Copy is clicked', () => { - const writeText = vi.fn().mockResolvedValue(undefined) - Object.assign(navigator, { clipboard: { writeText } }) + it('does not render a copy button for output target cards', () => { render() - fireEvent.click(screen.getByLabelText('assistantOutputs.copy')) - expect(writeText).toHaveBeenCalledWith('docs/readme.md') + expect(screen.queryByLabelText('assistantOutputs.copy')).not.toBeInTheDocument() }) it('opens the open-with menu with URL items for a localhost target', async () => { diff --git a/desktop/src/components/chat/AssistantOutputTargetCard.tsx b/desktop/src/components/chat/AssistantOutputTargetCard.tsx index 8ddca096..83413cf1 100644 --- a/desktop/src/components/chat/AssistantOutputTargetCard.tsx +++ b/desktop/src/components/chat/AssistantOutputTargetCard.tsx @@ -1,6 +1,6 @@ import { useCallback, useState } from 'react' import type { MouseEvent as ReactMouseEvent } from 'react' -import { ChevronDown, Copy, ExternalLink, Globe } from 'lucide-react' +import { ChevronDown, ExternalLink, Globe } from 'lucide-react' import type { AssistantOutputTarget } from '../../lib/assistantOutputTargets' import { useTranslation, type TranslationKey } from '../../i18n' import { OpenWithMenu } from '../common/OpenWithMenu' @@ -11,7 +11,6 @@ import { getServerBaseUrl } from '../../lib/desktopRuntime' import { useOpenTargetStore } from '../../stores/openTargetStore' import { useBrowserPanelStore } from '../../stores/browserPanelStore' import { useWorkspacePanelStore } from '../../stores/workspacePanelStore' -import { copyTextToClipboard } from './clipboard' type Props = { target: AssistantOutputTarget @@ -53,11 +52,6 @@ export function AssistantOutputTargetCard({ target, sessionId, workDir }: Props) }) }, [sessionId, target.href]) - const handleCopy = useCallback((event: ReactMouseEvent) => { - event.stopPropagation() - void copyTextToClipboard(target.normalizedPath ?? target.href) - }, [target.href, target.normalizedPath]) - const handleOpenWith = useCallback((event: ReactMouseEvent) => { event.stopPropagation() // Toggle: a second click on the same trigger closes the menu. OpenWithMenu's @@ -125,15 +119,6 @@ export function AssistantOutputTargetCard({ target, sessionId, workDir }: Props) >