mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
3.4 KiB
3.4 KiB
+++ id = "01" title = "Dynamic Mount-Add and Mount-Remove Commands" status = "Merged" dependencies = "" last_updated = "2025-06-25T01:40:09.501150" +++
Task 01: Dynamic Mount-Add and Mount-Remove Commands
This task is specific to codex-rs.
Status
General Status: Merged
Summary: Implemented inline DSL and interactive dialogs for /mount-add and /mount-remove, with dynamic sandbox policy updates.
Goal
Implement the /mount-add and /mount-remove slash commands in the TUI, supporting two modes:
- Inline DSL: e.g.
/mount-add host=/path/to/host container=/path/in/agent mode=rw - Interactive dialog: if the user just types
/mount-addor/mount-removewithout args, pop up a prompt to fill inhost,container, and optionalmodefields.
These commands should:
- Create or remove symlinks (or real directories) under the current working directory.
- Update the in-memory
SandboxPolicyto grant or revoke read/write permission for the host path. - Emit confirmation or error messages into the TUI log pane.
Acceptance Criteria
- Users can type
/mount-add host=... container=... mode=...and the mount is created immediately. - Users can type
/mount-addalone to open a small TUI form prompting for the three fields. - Symmetrically for
/mount-removeby container path. - The
sandbox_policyis updated so subsequent shell commands can read/write the newly mounted folder.
Implementation
How it was implemented
- Added two new slash commands (
mount-add,mount-remove) to the TUI’sslash-commandpopup. - Inline DSL parsing: commands typed as
/mount-add host=... container=... mode=...or/mount-remove container=...are detected and handled immediately by parsing key/value args, performing the mount/unmount, and updating theConfig.sandbox_policyin memory. - Interactive dialogs: selecting
/mount-addor/mount-removewithout args opens a bottom‑pane form (MountAddVieworMountRemoveView) that prompts sequentially for the required fields and then triggers the same mount logic. - Mount logic implemented in
do_mount_add/do_mount_remove:- Creates/removes a symlink under
cwdpointing to the host path (std::os::unix::fs::symlinkon Unix, platform equivalents on Windows). - Uses new
SandboxPolicymethods (allow_disk_write_folder/revoke_disk_write_folder) to grant or revokeDiskWriteFolderpermissions for the host path. - Emits success or error messages via
tracing::info!/tracing::error!, which appear in the TUI log pane.
- Creates/removes a symlink under
How it works
- Inline DSL
- User types:
/mount-add host=/path/to/host container=path/in/cwd mode=ro - The first-stage popup intercepts the mount-add command with args, dispatches
InlineMountAdd, and the app parses the args and runs the mount logic immediately.
- User types:
- Interactive dialog
- User types
/mount-add(or selects it via the popup) without args. - A small form appears that prompts for
host,container, thenmode. - Upon completion, the same mount logic runs.
- User types
- Unmount
/mount-remove container=...(inline) or/mount-remove(interactive) remove the symlink and revoke write permissions.
- Policy update
allow_disk_write_folderappends aDiskWriteFolderpermission for new mounts.revoke_disk_write_folderremoves the corresponding permission on unmount.
Notes
- This builds on the static
[[sandbox.mounts]]support introduced earlier.