The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(agent): Pfadvergleich auf rohen Zeichenketten vereinheitlicht (R2-41)
purple311811e5c150
diff --git a/src/api/__tests__/agent-context-workspace.test.ts b/src/api/__tests__/agent-context-workspace.test.tsindex 883270e3..fadc74ab 100644--- a/src/api/__tests__/agent-context-workspace.test.ts+++ b/src/api/__tests__/agent-context-workspace.test.ts@@ -84,6 +84,30 @@ describe('agent-context — active workspace pointer', () => {setActiveWorkspace({ kind: 'folder', path: '/a', extraPaths: ['', '/a'] })expect(getActiveWorkspace()).toEqual({ kind: 'folder', path: '/a' })})++ it('R2-41: dedupes extras on a case/slash-normalized key, not the raw string', () => {+ // Windows: the same folder picked twice with different case/trailing+ // slash, plus the primary itself spelled differently, must all collapse.+ setActiveWorkspace({+ kind: 'folder',+ path: 'D:\\code',+ extraPaths: ['d:/CODE/', 'D:\\code\\'],+ })+ expect(getActiveWorkspace()).toEqual({ kind: 'folder', path: 'D:\\code' })+ })++ it('and keeps two genuinely different paths apart (negative control)', () => {+ setActiveWorkspace({+ kind: 'folder',+ path: 'D:\\code',+ extraPaths: ['D:\\other'],+ })+ expect(getActiveWorkspace()).toEqual({+ kind: 'folder',+ path: 'D:\\code',+ extraPaths: ['D:\\other'],+ })+ })})describe('renderWorkspaceSection', () => {diff --git a/src/api/agent-context.ts b/src/api/agent-context.tsindex a8b41cef..5061e11f 100644--- a/src/api/agent-context.ts+++ b/src/api/agent-context.ts@@ -20,6 +20,7 @@*/import type { AgentWorkspace } from '../types/agent-workspace'+import { pathKey } from '../lib/dev-fs-jail'/*** Duplication-proof state carrier (v2.5.3 live E2E find, 2026-06-11).@@ -319,14 +320,21 @@ export function normalizeWorkspace(ws: AgentWorkspace | null | undefined): Agent// Defensive: filter out blanks + dedupe extras + drop the primary if// a caller accidentally listed it as both. Keeps the public shape// stable for downstream readers (system prompt + chatCtx).+ //+ // R2-41: the dedupe used to compare raw strings, so `D:\code` and+ // `d:/CODE/` counted as two different paths. `pathKey` (dev-fs-jail.ts)+ // is the same normalization the actual containment check uses.+ const primaryKey = pathKey(ws.path)+ const seenKeys = new Set<string>()const cleanedExtras = Array.isArray(ws.extraPaths)- ? Array.from(- new Set(- ws.extraPaths- .filter((p): p is string => typeof p === 'string' && p.length > 0)- .filter((p) => p !== ws.path),- ),- )+ ? ws.extraPaths+ .filter((p): p is string => typeof p === 'string' && p.length > 0)+ .filter((p) => {+ const key = pathKey(p)+ if (key === primaryKey || seenKeys.has(key)) return false+ seenKeys.add(key)+ return true+ }): []return {kind: 'folder',diff --git a/src/components/chat/AgentWorkspaceDialog.tsx b/src/components/chat/AgentWorkspaceDialog.tsxindex 9d1b6728..134b7b3f 100644--- a/src/components/chat/AgentWorkspaceDialog.tsx+++ b/src/components/chat/AgentWorkspaceDialog.tsx@@ -7,6 +7,7 @@ import { backendCall } from '../../api/backend'import { rememberedFolderRefusal } from '../../api/agents/workspace-validate'import type { AgentWorkspace } from '../../types/agent-workspace'import { HINWEIS_TEXT } from '../../lib/hinweis'+import { pathKey } from '../../lib/dev-fs-jail'interface Props {open: boolean@@ -134,7 +135,12 @@ export function AgentWorkspaceDialog({setDraft((d) => {if (!d || d.kind !== 'folder') return dconst extras = d.extraPaths ?? []- if (extras.includes(res) || res === d.path) return d+ // R2-41: a raw string compare missed the same folder picked with a+ // different case or trailing slash on Windows (`D:\code` vs+ // `d:/CODE/`); `pathKey` is the same normalization the workspace+ // dedup in agent-context.ts uses.+ const key = pathKey(res)+ if (extras.some((p) => pathKey(p) === key) || (d.path && key === pathKey(d.path))) return dreturn { ...d, extraPaths: [...extras, res] }})} catch (e) {diff --git a/src/lib/__tests__/dev-fs-jail.test.ts b/src/lib/__tests__/dev-fs-jail.test.tsindex 166fd157..53e295ec 100644--- a/src/lib/__tests__/dev-fs-jail.test.ts+++ b/src/lib/__tests__/dev-fs-jail.test.ts@@ -26,6 +26,7 @@ import {effectiveByteCap,DEV_READ_BYTES_CAP,JailEscapeError,+ pathKey,} from '../dev-fs-jail'// Der Ordnername kommt aus app-identity (dieser Branch hängt einen Suffix an),// damit die Zusicherungen den Namen nicht gegen sich selbst ausspielen.@@ -130,6 +131,14 @@ describe('path primitives', () => {expect(lexicalNormalize('C:\\a\\b\\..\\c')).toBe('C:/a/c')})+ it('R2-41: pathKey treats case/slash/trailing-slash variants of the same path as equal', () => {+ expect(pathKey('D:\\code')).toBe(pathKey('d:/CODE/'))+ expect(pathKey('D:\\code')).toBe(pathKey('D:\\code\\'))+ // Negative control: a genuinely different path is NOT the same key.+ expect(pathKey('D:\\code')).not.toBe(pathKey('D:\\other'))+ expect(pathKey('/a/b')).not.toBe(pathKey('/a/bc'))+ })+it('knows an absolute path on both platforms', () => {expect(isAbsolutePath('/etc')).toBe(true)expect(isAbsolutePath('C:\\Windows')).toBe(true)diff --git a/src/lib/dev-fs-jail.ts b/src/lib/dev-fs-jail.tsindex 33d09cbb..9e0f9d03 100644--- a/src/lib/dev-fs-jail.ts+++ b/src/lib/dev-fs-jail.ts@@ -102,14 +102,29 @@ export function lexicalNormalize(path: string): string {return rooted ? `/${joined}` : joined}-/** Case-insensitive comparison on Windows-shaped paths, exact elsewhere. */-function compareKey(normalized: string): string {+/**+ * Case-insensitive comparison on Windows-shaped paths, exact elsewhere.+ * Exported (R2-41) so every path deduplication in the app uses the same+ * normalization instead of a raw string compare, which treated `D:\code`,+ * `d:/CODE/` and `D:\code\` as three different paths.+ */+export function compareKey(normalized: string): string {const trimmed = normalized.replace(/\/+$/, '')return /^[a-z]:/i.test(trimmed) || trimmed.startsWith('//')? trimmed.toLowerCase(): trimmed}+/**+ * One raw, unnormalized path in, one comparable key out: `lexicalNormalize`+ * then `compareKey`. For callers that only want to know whether two paths+ * from different sources (a picked folder, a stored draft, a saved setting)+ * are the SAME path, not whether one contains the other.+ */+export function pathKey(raw: string): string {+ return compareKey(lexicalNormalize(raw))+}+/*** `is_within` aus filesystem.rs, auf normalisierten Strings: `cand` IST `root`* oder liegt darunter, verglichen an einer Bestandteil-Grenze, damit `…/foo`