Files
claude-code-haha/desktop/src/lib/assistantFileContext.test.ts
T
程序员阿江(Relakkes) fadaa775ac fix(desktop): resolve output files against declared project roots
Keep explicit file identities across output cards and prose links, preserve
shell outputs without checkpoint evidence, and retain a file card when
video preview fails. Add cross-project path and opening regressions.
2026-09-27 23:22:40 +08:00

23 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest'
import { resolveAssistantFileHref } from './assistantFileContext'
describe('resolveAssistantFileHref', () => {
it('resolves only explicit directory declarations including Windows and spaces', () => {
expect(resolveAssistantFileHref('public/audio/track.wav', '项目根目录是 `/external/my project/`:')).toBe('/external/my project/public/audio/track.wav')
expect(resolveAssistantFileHref('out/movie.mp4', 'Project root: `D:\\work\\demo\\`')).toBe('D:/work/demo/out/movie.mp4')
expect(resolveAssistantFileHref('report.pdf', '参考 `/external/docs/`')).toBe('report.pdf')
})
it('ignores declarations inside fences and preserves absolute paths and remote URLs', () => {
expect(resolveAssistantFileHref('report.pdf', '```txt\n项目根目录是 `/example/`\n```')).toBe('report.pdf')
expect(resolveAssistantFileHref('/other/report.pdf', '输出目录:`/output/`')).toBe('/other/report.pdf')
expect(resolveAssistantFileHref('https://example.com/report.pdf', '输出目录:`/output/`')).toBe('https://example.com/report.pdf')
})
it('declines multiple roots and applies a single declaration to the whole reply', () => {
const content = '项目根目录是 `/one/`\nreport.pdf\n项目根目录是 `/two/`\nreport.pdf'
expect(resolveAssistantFileHref('report.pdf', content)).toBe('report.pdf')
expect(resolveAssistantFileHref('report.pdf', 'report.pdf\n项目根目录是 `/one/`')).toBe('/one/report.pdf')
})
})