OpenProgram Docs

Additional working directories

Same meaning as Claude Code's additionalWorkingDirectories.

Main directoryAdditional directory
Model cwd (system prompt, --cd, tool ContextVar)Project pathUnchanged
Conversation storageprojects/<id>/chats/Unchanged
acceptEdits fence allowlistYesAdded
Told to the modelWorking directory“Also writable: /a, /b”
Stored inProject bindingSessionRunConfig, session metadata
Change mid-sessionFrozen on the first turn; move or repair onlyAny time, from the next turn

The main directory links through project_workdir_for; the fence side is in Sandbox architecture §3.5. A session with no stored list starts from its project's source folders.

Out of scope and extension points
  • CLAUDE.md and project settings are not loaded from additional directories. Permission rules follow the main project.
  • No per-directory read-only grading: once listed, a directory is a writable safe zone.
  • No global additional directories. Cross-session needs are served by projects.
  • Attributed entries: change only _as_str_list and check_path_safety; schemaless storage needs no migration.
  • MCP roots or multi-root IDE workspaces would use the same field as single source of truth.

Data path

StageCodeBehaviour
PickWorkingDirChips, POST /api/pick-folderRecent projects, or “Choose folder…” in the native picker
Sendset_working_dirs {session_id, dirs}Whole list. A draft has no id yet, so the list rides on its first chat frame
Validate and savehandle_set_working_dirs in ws_actions/session/run_config.pyEach expanduser() must be a directory; one bad entry rejects the frame with a reason. Stores the expanded path, not the realpath. Broadcasts working_dirs
Persistsave_session_run_configNone leaves the list unchanged, so a chat frame never clears it
Reloadsession_loaded.data.settingsRestores the list after a refresh or client switch
Each turnload_session_run_config → TurnRequest.additional_working_dirs
Fence_path_is_safe in runtime/permissions/identity.py → check_path_safety[current_worktree_path() or getcwd(), *dirs]
Promptruntime/context/prompt_assembly/components.pyLine present only when the list is non-empty

The dispatcher binds the real cwd into current_worktree_path each turn; getcwd is only a fallback.

Composer

[my-project]  [foo ✕]  [bar ✕]  [+]
  • Project chip, then one chip per additional directory and an icon-only add button (apps/web/components/chat/top-bar/chips/working-dir-chips.tsx).
  • Add and ✕ update local state optimistically; the working_dirs broadcast wins.
  • State is additionalWorkingDirsBySession in the session store, fed by session_loaded, the broadcast and optimistic updates. Not in ComposerSettings or localStorage: it is server data.
  • When list_projects reports path_missing for the session's project, the project chip turns to the orange warning palette with a Solar danger-triangle and offers “Locate folder…”.

Invariants

RuleBecause
Only the fence and the promptWiring into cwd or storage breaks the table above
Fence and prompt cwd share current_worktree_path()Otherwise the model thinks it can write, the fence blocks, and approvals loop
Whole-list replacementIdempotent; no “already added” cases and no partial write
Schemaless session metadataOld sessions read an empty list, no migration
Editable for the session's whole lifeThe only mid-session way to widen the fence
A missing main project resolves to NoneAnother directory would be a plausible cwd the user never chose
Tests
FileCovers
tests/unit/store/session/test_session_config.pyRound trip, “None leaves it unchanged”, _as_str_list sanitizing
tests/unit/security/test_permission_rules.py_path_is_safe: inside, outside, and inside the ContextVar cwd
tests/unit/webui/chat/test_ws_working_dirs.pyValid write and broadcast, whole-frame rejection, session_loaded round trip
tests/unit/store/session/test_session_main_workdir.pyFreeze, missing-directory resolution, relocate node, and editing additional directories after the freeze
Last updated · 2026-11-25