Skip to content

The agent that grows with you

test(desktop): pin tool error summary paths and zero title fetches

Austin Pickett6d8b6cf2a666
diff --git a/apps/desktop/src/components/assistant-ui/tool/fallback-error-summary.test.tsx b/apps/desktop/src/components/assistant-ui/tool/fallback-error-summary.test.tsx
index 0fbfef3716b..1cc9b286281 100644
--- a/apps/desktop/src/components/assistant-ui/tool/fallback-error-summary.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/tool/fallback-error-summary.test.tsx
@@ -1,6 +1,6 @@
import { cleanup, render, screen } from '@testing-library/react'
import type { ComponentProps } from 'react'
-import { afterEach, describe, expect, it, vi } from 'vitest'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { $toolDisclosureStates, setToolDisclosureOpen } from '@/store/tool-view'
@@ -15,6 +15,12 @@ vi.mock('@assistant-ui/react', async importOriginal => ({
const { ToolFallback } = await import('./fallback')
const ERROR_TEXT = 'MCP call failed: MCPError: create file error: repository file already exists [path: README.md]'
+const WINDOWS_PATH_ERROR = 'Failed to write file: C:\\Users\\test-user\\Documents\\CODEX_PROGRESS.md is locked'
+const WWW_PATH_ERROR = 'Failed to read /tmp/www.config and C:\\Users\\test-user\\Documents\\www.config'
+
+const desktopWindow = window as unknown as { hermesDesktop?: Window['hermesDesktop'] }
+const initialHermesDesktop = desktopWindow.hermesDesktop
+let fetchLinkTitle: ReturnType<typeof vi.fn>
function renderErrorToolRow(result: unknown) {
const props = {
@@ -31,20 +37,34 @@ function renderErrorToolRow(result: unknown) {
render(<ToolFallback {...props} />)
}
+beforeEach(() => {
+ fetchLinkTitle = vi.fn().mockResolvedValue('AI Tools Directory - dealsbe.com')
+ desktopWindow.hermesDesktop = {
+ fetchLinkTitle,
+ openExternal: vi.fn().mockResolvedValue(undefined)
+ } as unknown as Window['hermesDesktop']
+})
+
afterEach(() => {
cleanup()
$toolDisclosureStates.set({})
+ desktopWindow.hermesDesktop = initialHermesDesktop
})
describe('tool error summary linkification', () => {
// The bare-domain branch of the linkifier matched `README.md` as a host and
// the pretty link then replaced the painted text with the fetched title of
// https://readme.md, so the headline stopped matching the raw error string.
- it('renders filename-shaped error tokens as plain text, not fabricated links', () => {
- renderErrorToolRow({ error: ERROR_TEXT })
+ it.each([
+ ['filename token', ERROR_TEXT],
+ ['Windows path', WINDOWS_PATH_ERROR],
+ ['www.-prefixed local paths', WWW_PATH_ERROR]
+ ])('renders a %s verbatim with no link and no title fetch', (_, error) => {
+ renderErrorToolRow({ error })
expect(screen.queryByRole('link')).toBeNull()
- expect(screen.getByText((_, element) => element?.textContent === ERROR_TEXT)).toBeTruthy()
+ expect(screen.getByText((_, element) => element?.textContent === error)).toBeTruthy()
+ expect(fetchLinkTitle).not.toHaveBeenCalled()
})
it('keeps an explicit URL in the error clickable without rewriting the headline', () => {
@@ -55,5 +75,6 @@ describe('tool error summary linkification', () => {
expect(link.textContent).toBe('https://example.com/docs/error-codes')
// eslint-disable-next-line no-restricted-globals -- the headline text is split across link and text nodes
expect(document.body.textContent).toContain('[path: README.md]')
+ expect(fetchLinkTitle).not.toHaveBeenCalled()
})
})