Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(chat): preserve explicit file link destinations
321sssrt-bitdf3517c85526
diff --git a/apps/desktop/src/renderer/__tests__/markdownTarget.test.ts b/apps/desktop/src/renderer/__tests__/markdownTarget.test.tsindex c6acc41394..ee3cc8b41d 100644--- a/apps/desktop/src/renderer/__tests__/markdownTarget.test.ts+++ b/apps/desktop/src/renderer/__tests__/markdownTarget.test.ts@@ -201,6 +201,18 @@ describe('classifyMarkdownLinkTarget', () => {});});+ // F2: a same-name attachment must not replace an explicit destination.+ it.each([+ 'C:\\project\\report.pdf', 'C:/project/report.pdf', '/project/report.pdf',+ 'file:///C:/project/report.pdf', 'file:///project/report.pdf',+ '\\\\server\\share\\report.pdf', '~/project/report.pdf',+ '%2Fproject%2Freport.pdf',+ ])('keeps explicit destination %s instead of a same-name attachment', (href) => {+ expect(classifyMarkdownLinkTarget(href, [+ { name: 'report.pdf', path: 'C:\\uploads\\report.pdf' },+ ])).toMatchObject({ kind: 'local-candidate', href });+ });+it('does not render unsupported schemes or directories as clickable links', () => {expect(classifyMarkdownLinkTarget('mailto:[email protected]')).toEqual({kind: 'plain-text',diff --git a/apps/desktop/src/renderer/lib/localPathResolver.ts b/apps/desktop/src/renderer/lib/localPathResolver.tsindex aa9f463e3a..1714e6e69e 100644--- a/apps/desktop/src/renderer/lib/localPathResolver.ts+++ b/apps/desktop/src/renderer/lib/localPathResolver.ts@@ -204,7 +204,7 @@ function normalizeKnownFileHref(href: string): string {* `[name.docx](name.docx)` because the prompt exposes the original filename,* while the real file lives outside the session working directory. In that* case, resolve by unique attachment basename before falling back to cwd-based- * path resolution.+ * path resolution. Explicit absolute/home paths keep their own identity.** Matching is case-insensitive. Windows / macOS-default filesystems are* case-insensitive, and LLMs frequently lowercase the basename when authoring@@ -221,6 +221,8 @@ export function resolveKnownLocalFileHref(files: readonly KnownLocalFileRef[] | undefined,): string | null {if (!href || !files || files.length === 0) return null;+ const decoded = safeDecodeURIComponent(stripQueryAndHash(href.trim()));+ if (/^(?:file:\/\/|[\\/]|[a-z]:[\\/]|~[\\/])/i.test(decoded)) return null;const wanted = normalizeKnownFileHref(href).toLowerCase();if (!wanted) return null;