feat(code): add support for additional directories#2038
feat(code): add support for additional directories#2038jonathanlab wants to merge 4 commits intomainfrom
Conversation
…ialog Generated-By: PostHog Code Task-Id: 293ac0b4-32d3-47ac-8935-d5860b8e79de
Generated-By: PostHog Code Task-Id: 293ac0b4-32d3-47ac-8935-d5860b8e79de
Generated-By: PostHog Code Task-Id: 293ac0b4-32d3-47ac-8935-d5860b8e79de
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
apps/code/src/renderer/features/message-editor/commands.ts:75
**Wrong ID passed to `addForTask`**
`ctx.sessionId` is the ACP session ID, which `AgentService.toSessionResponse` sets to `session.taskRunId` — a different value from the actual `taskId`. `WorkspaceRepository.addAdditionalDirectory` looks up the workspace row with `findByTaskId(taskId)`, so when the run ID is passed it matches nothing and the `UPDATE` affects 0 rows silently. The directory is never persisted: "Just this chat" appears to succeed but the workspace's `additionalDirectories` column is never updated, so `resolveAdditionalDirectories` won't find it for any subsequent prompt in this session.
`CommandMentionOptions` only exposes `sessionId`; `taskId` needs to be threaded through alongside it (mirroring how `PromptInput` already receives both as separate props).
### Issue 2 of 2
apps/code/src/renderer/features/folder-picker/components/AddDirectoryDialog.tsx:86-87
**Sandbox not updated for in-flight Codex sessions**
For the Codex adapter, `writable_roots` is passed to `codex-acp` as a `-c` flag at spawn time and cannot be changed while the process is running. When a user clicks "Just this chat" or "Always add to new chats" in an ongoing Codex session, the dialog tells them "The agent will be able to read and write files in this folder," but the Codex sandbox does not include the newly added path for the current session — only future sessions will benefit from it. Consider adjusting the dialog copy to set accurate expectations (e.g., "Takes effect on the next session start") for the case when a session is already active.
Reviews (1): Last reviewed commit: "chore: pnpm format" | Re-trigger Greptile |
| name: "add-dir", | ||
| description: "Add a folder the agent can access in this task", | ||
| async onInsert(ctx) { | ||
| const taskId = ctx.sessionId; |
There was a problem hiding this comment.
ctx.sessionId is the ACP session ID, which AgentService.toSessionResponse sets to session.taskRunId — a different value from the actual taskId. WorkspaceRepository.addAdditionalDirectory looks up the workspace row with findByTaskId(taskId), so when the run ID is passed it matches nothing and the UPDATE affects 0 rows silently. The directory is never persisted: "Just this chat" appears to succeed but the workspace's additionalDirectories column is never updated, so resolveAdditionalDirectories won't find it for any subsequent prompt in this session.
CommandMentionOptions only exposes sessionId; taskId needs to be threaded through alongside it (mirroring how PromptInput already receives both as separate props).
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/message-editor/commands.ts
Line: 75
Comment:
**Wrong ID passed to `addForTask`**
`ctx.sessionId` is the ACP session ID, which `AgentService.toSessionResponse` sets to `session.taskRunId` — a different value from the actual `taskId`. `WorkspaceRepository.addAdditionalDirectory` looks up the workspace row with `findByTaskId(taskId)`, so when the run ID is passed it matches nothing and the `UPDATE` affects 0 rows silently. The directory is never persisted: "Just this chat" appears to succeed but the workspace's `additionalDirectories` column is never updated, so `resolveAdditionalDirectories` won't find it for any subsequent prompt in this session.
`CommandMentionOptions` only exposes `sessionId`; `taskId` needs to be threaded through alongside it (mirroring how `PromptInput` already receives both as separate props).
How can I resolve this? If you propose a fix, please make it concise.| <DialogDescription className="text-(--gray-11) text-sm"> | ||
| The agent will be able to read and write files in this folder. |
There was a problem hiding this comment.
Sandbox not updated for in-flight Codex sessions
For the Codex adapter, writable_roots is passed to codex-acp as a -c flag at spawn time and cannot be changed while the process is running. When a user clicks "Just this chat" or "Always add to new chats" in an ongoing Codex session, the dialog tells them "The agent will be able to read and write files in this folder," but the Codex sandbox does not include the newly added path for the current session — only future sessions will benefit from it. Consider adjusting the dialog copy to set accurate expectations (e.g., "Takes effect on the next session start") for the case when a session is already active.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/folder-picker/components/AddDirectoryDialog.tsx
Line: 86-87
Comment:
**Sandbox not updated for in-flight Codex sessions**
For the Codex adapter, `writable_roots` is passed to `codex-acp` as a `-c` flag at spawn time and cannot be changed while the process is running. When a user clicks "Just this chat" or "Always add to new chats" in an ongoing Codex session, the dialog tells them "The agent will be able to read and write files in this folder," but the Codex sandbox does not include the newly added path for the current session — only future sessions will benefit from it. Consider adjusting the dialog copy to set accurate expectations (e.g., "Takes effect on the next session start") for the case when a session is already active.
How can I resolve this? If you propose a fix, please make it concise.
We did not really support additional directories, now we do
/add-dirlets you specify additional directories for each taskDefault directories can be managed via the settings screen.
Created with PostHog Code