-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Problem
ALLOWED_WORKSPACES is a global env var (comma-separated paths) that applies to all users. WORKSPACE_BASE is also global. In multi-user, each user has repos in different locations and needs their own workspace base and allowed paths.
Currently, if a user has repos outside WORKSPACE_BASE, they must ask the machine owner to add paths to ALLOWED_WORKSPACES in the env file. This breaks the principle that workspace management is fully Telegram-driven.
Parent issue: #196 (sub-issue #4)
Proposal
Two changes:
1. Move WORKSPACE_BASE to per-user workspace_base in users.yaml
Each user gets their own base directory for /workspace new and short-name resolution:
users:
- telegram_id: 2114582497
name: Daniel
workspace_base: /Users/kai/ProjectsThe admin sets this during onboarding (the config wizard in #193 prompts for it). /workspace new <name> creates directories under this user's workspace_base.
2. User-managed allowed workspaces via Telegram
Users add and remove paths outside their workspace_base via Telegram commands. The filesystem (os_user permissions) is the security boundary, not an allowlist.
Commands
/workspace allow <path> - add an allowed workspace path
/workspace deny <path> - remove an allowed workspace path
/workspace allowed - list all allowed workspaces (workspace_base + explicit allows)
Validation
/workspace allowchecks that the path exists and is a directory- Path must be readable by the user's
os_user(if os_user isolation is active) - Absolute paths required (the current workspace command rejects them for name-based switching, but
/workspace allowspecifically needs them) - Duplicate detection (don't add a path that's already under
workspace_baseor already allowed)
Storage
Allowed workspaces stored in the database per-user. Options:
- Settings table with a list key:
allowed_workspaces:{chat_id}= JSON array of paths - New
allowed_workspacestable: (chat_id, path) pairs
Option 2 is cleaner for add/remove operations and avoids JSON parsing.
Impact on /workspace name resolution
Currently /workspace <name> searches WORKSPACE_BASE then ALLOWED_WORKSPACES. The new flow:
- Search the user's
workspace_base(from users.yaml) - Search the user's allowed workspaces (from database)
- Match by directory name in both cases
Backward compatibility
WORKSPACE_BASEenv var becomes the global fallback for users who don't haveworkspace_basein users.yamlALLOWED_WORKSPACESenv var becomes the global fallback for users who haven't added any via Telegram- Existing single-user installs work unchanged
Deprecation
After migration period:
WORKSPACE_BASEremoved from env, replaced by per-userworkspace_basein users.yamlALLOWED_WORKSPACESremoved from env, replaced by database storage
Context
- Current workspace switching: bot.py lines 1020-1117 (
handle_workspace) - Workspace name resolution: searches
WORKSPACE_BASEthenALLOWED_WORKSPACES - Config:
WORKSPACE_BASEandALLOWED_WORKSPACESloaded in config.py - UserConfig dataclass: config.py lines 86-111 (needs
workspace_basefield added)