Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): recognize pasted directories with trailing separators
Stella-xixi4279e2fbf580
diff --git a/apps/desktop/src/renderer/__tests__/pastePipeline.test.ts b/apps/desktop/src/renderer/__tests__/pastePipeline.test.tsindex 91df8e67cc..9c5aa0e7e2 100644--- a/apps/desktop/src/renderer/__tests__/pastePipeline.test.ts+++ b/apps/desktop/src/renderer/__tests__/pastePipeline.test.ts@@ -185,6 +185,29 @@ describe('segmentPastedContent — path candidates', () => {]);});+ it.each([+ [WORKDIR, `${WORKDIR}/apps/desktop`, '/'],+ [WORKDIR, `${WORKDIR}/apps/desktop`, '///'],+ [WIN_WORKDIR, 'C:\\Code\\XDMaker\\apps', '\\'],+ [WIN_WORKDIR, 'C:\\Code\\XDMaker\\apps', '\\\\'],+ [WIN_WORKDIR, 'c:/code/xdmaker/apps', '/'],+ ])('recognizes standalone directory paths for %s: %s%s', (workingDir, dir, suffix) => {+ expect(segmentPastedContent(`${dir}${suffix}`, { workingDir })).toEqual([+ { kind: 'path', path: dir },+ ]);+ expect(segmentPastedContent(` \t${dir}${suffix}\r\n`, { workingDir })).toEqual([+ { kind: 'text', text: ' \t' },+ { kind: 'path', path: dir },+ { kind: 'text', text: '\r\n' },+ ]);+ expect(segmentPastedContent(`${workingDir}${suffix}`, { workingDir })).toBeNull();+ expect(segmentPastedContent(`cd ${dir}${suffix}`, { workingDir })).toBeNull();+ });++ it.each(['/:12', ':12/', '/)', ')/', '/,', ',/'])('keeps directory diagnostic suffix %s literal', (suffix) => {+ expect(segmentPastedContent(`${WORKDIR}/apps${suffix}`, { workingDir: WORKDIR })).toBeNull();+ });+it('does not treat the workingDir itself as a path segment', () => {expect(segmentPastedContent(`目录是 ${WORKDIR} 本体`, { workingDir: WORKDIR })).toBeNull();});diff --git a/apps/desktop/src/renderer/components/new-chat/pastePipeline.ts b/apps/desktop/src/renderer/components/new-chat/pastePipeline.tsindex 8fc4c47649..4a0166818c 100644--- a/apps/desktop/src/renderer/components/new-chat/pastePipeline.ts+++ b/apps/desktop/src/renderer/components/new-chat/pastePipeline.ts@@ -274,6 +274,9 @@ function segmentPathCandidates(segments.push({ kind: 'path', path: trimmed });matchedAny = true;cursor = m.index + trimmed.length;+ // 尾分隔符属于目录路径,不应作为非空白文本阻止独立路径识别。+ // 只消费紧随路径的分隔符,诊断后缀和标点仍保留为文本。+ cursor += /^[\\/]+/.exec(text.slice(cursor))?.[0].length ?? 0;PATH_CANDIDATE_RE.lastIndex = cursor;}if (!matchedAny) return null;