Skip to content

feat: support a {{session}} placeholder in OPEN_TERMINAL_FILE_BROWSER_ROOT (per-chat workspace) #147

Description

@leonardocrdso

Problem

When Open Terminal is shared by a team through Open WebUI, every chat of a given user sees the same home directory. A user who asks the model to "build me this spreadsheet" in chat A also sees the leftovers of chats B..Z in the file browser. There is no way to scope a chat to its own area.

Current behaviour (verified on ghcr.io/open-webui/open-terminal:latest)

  • OPEN_TERMINAL_FILE_BROWSER_ROOT accepts home, filesystem, or an explicit path with exactly one placeholder, {{home}} (open_terminal/main.py:157).
  • A per-session cwd does exist (_session_cwds, TTL from OPEN_TERMINAL_SESSION_CWD_TTL, default 7 days, sliding window), but it is only ever written by POST /files/cwd (main.py:487) — i.e. when a human navigates in the file browser. run_command and the file tools only read it through _get_session_cwd, so the model cannot create a directory and "move into" it.
  • It is in-process memory only, so it is also lost on container restart.

The only workaround today is manual: a human opens the panel once, navigates into a folder, and that chat stays anchored there — for at most 7 days, and not across restarts.

Proposal

Accept a {{session}} placeholder (the Open WebUI chat/session id) in OPEN_TERMINAL_FILE_BROWSER_ROOT, resolved in _file_browser_root() right next to {{home}}, creating the directory on first use:

OPEN_TERMINAL_FILE_BROWSER_ROOT="{{home}}/chats/{{session}}"

Each chat then gets its own workspace. Shared state remains possible by pointing at paths outside the session directory.

Ideally the same resolved path would also become the default cwd for run_command and the file tools — otherwise the model writes into $HOME while the browser displays the session directory.

Why not the existing options

  • Multi-user mode isolates users, not chats.
  • A static subdirectory (e.g. ~/workspace) is the same folder for every chat, and it must pre-exist for each user or the panel shows "Directory not found".

Environment

ghcr.io/open-webui/open-terminal:latest (multi-user), Open WebUI 0.11.0, Docker Swarm, sandbox network with no egress.

Happy to open a PR if the approach sounds right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions