mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-18 13:23:33 +08:00
fix(desktop): de-duplicate localhost url in output card (hide subtitle when == title)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
95d1ba997a
commit
78baace37e
@ -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(<AssistantOutputTargetCard target={localhostTarget} sessionId="s1" />)
|
||||
// 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()
|
||||
})
|
||||
|
||||
|
||||
@ -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<HTMLButtonElement>) => {
|
||||
event.stopPropagation()
|
||||
@ -99,9 +100,11 @@ export function AssistantOutputTargetCard({ target, sessionId, workDir }: Props)
|
||||
{badge}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-1 truncate text-xs text-[var(--color-text-tertiary)]" title={subtitle}>
|
||||
{subtitle}
|
||||
</div>
|
||||
{showSubtitle && (
|
||||
<div className="mt-1 truncate text-xs text-[var(--color-text-tertiary)]" title={subtitle}>
|
||||
{subtitle}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user