Skip to content

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.

fix(code): coding agent can read its own working dir (pin containment to workDir)

purple3db0aebaa6e4
diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.ts
index 6080d835..dc215c30 100644
--- a/src/hooks/useCodex.ts
+++ b/src/hooks/useCodex.ts
@@ -266,6 +266,22 @@ export function useCodex() {
codexStore.workingDirectory ||
'.'
+ // Pin the tool-containment workspace to the SAME folder the model is told
+ // to use (workDir). resolveWorkspace() above only sees the agent-mode
+ // per-chat store + settings.defaultWorkspace — it MISSES the folder the
+ // Code tab's FileTree picker sets (codexStore.workingDirectory), which is
+ // the primary way to pick a repo in the Code tab. Without this, containment
+ // stayed pinned to the per-chat sandbox while the model was told to work in
+ // a real folder, so every file_list/file_read of the working dir failed
+ // with "path escapes the allowed workspace" (live cloud find, 2026-07-11).
+ if (workDir && workDir !== '.') {
+ setActiveWorkspace({
+ kind: 'folder',
+ path: workDir,
+ extraPaths: codexWorkspace && codexWorkspace.kind === 'folder' ? codexWorkspace.extraPaths : undefined,
+ })
+ }
+
// Add instruction event
codexStore.addEvent(convId, {
id: uuid(), type: 'instruction', content: instruction, timestamp: Date.now(),