feat(code): add support for additional directories#2038
Conversation
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.
adboio
left a comment
There was a problem hiding this comment.
thank you! stamping bc this looks good and no major concerns, but personally i think i'd prefer a UI button to do this, without actually sending a message, like a little folder icon in the chat box or something
it felt a little unintuitive with the slash command -> dialog -> dialog -> send message
but not blocking at all, and we can always add a UI button on top of the work you've done here if we want
good stuff 🫡
yeah we should probably have an item in the attachment menu for this as well, we can do that in a follow up PR! |
…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
…alog When the user picks a folder via the attachment menu on a live task, open the same scope-choice dialog as /add-dir (just this chat vs always) instead of inserting a folder reference chip that doesn't actually grant the agent access. Falls back to chip insertion when there's no task yet (e.g. in the new-task input). Generated-By: PostHog Code Task-Id: c5674c04-c95c-4bfe-bfcf-248a921b4aae
f3f1c28 to
26139ab
Compare
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