From 78baace37e2ad351fbadd32aea69c1f24d951aef 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: Sat, 30 May 2026 17:10:40 +0800 Subject: [PATCH] fix(desktop): de-duplicate localhost url in output card (hide subtitle when == title) Co-Authored-By: Claude Opus 4.8 (1M context) --- .../components/chat/AssistantOutputTargetCard.test.tsx | 6 +++--- .../src/components/chat/AssistantOutputTargetCard.tsx | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/desktop/src/components/chat/AssistantOutputTargetCard.test.tsx b/desktop/src/components/chat/AssistantOutputTargetCard.test.tsx index 73aeac3a..2fd7b836 100644 --- a/desktop/src/components/chat/AssistantOutputTargetCard.test.tsx +++ b/desktop/src/components/chat/AssistantOutputTargetCard.test.tsx @@ -74,10 +74,10 @@ describe('AssistantOutputTargetCard', () => { expect(screen.getByText('docs/readme.md')).toBeInTheDocument() }) - it('renders a localhost target title + Localhost badge', () => { + it('renders a localhost target title + Localhost badge (URL not duplicated)', () => { render() - // Title + subtitle both fall back to href, so it appears twice. - expect(screen.getAllByText('http://localhost:5173/').length).toBeGreaterThan(0) + // subtitle equals the title for localhost, so the URL renders exactly once. + expect(screen.getAllByText('http://localhost:5173/')).toHaveLength(1) expect(screen.getByText('assistantOutputs.kind.localhost')).toBeInTheDocument() }) diff --git a/desktop/src/components/chat/AssistantOutputTargetCard.tsx b/desktop/src/components/chat/AssistantOutputTargetCard.tsx index aefb944b..a627c232 100644 --- a/desktop/src/components/chat/AssistantOutputTargetCard.tsx +++ b/desktop/src/components/chat/AssistantOutputTargetCard.tsx @@ -34,6 +34,7 @@ export function AssistantOutputTargetCard({ target, sessionId, workDir }: Props) ? t('assistantOutputs.kind.markdown') : t('assistantOutputs.kind.image') const subtitle = target.subtitle ?? target.normalizedPath ?? target.href + const showSubtitle = subtitle !== target.title const handleOpen = useCallback((event: ReactMouseEvent) => { event.stopPropagation() @@ -99,9 +100,11 @@ export function AssistantOutputTargetCard({ target, sessionId, workDir }: Props) {badge} -
- {subtitle} -
+ {showSubtitle && ( +
+ {subtitle} +
+ )}