Comprehensive multi-workspace management with templates, cloning, snapshots, sharing, archiving, and statistics.
Overview
The MultiWorkspaceManager provides comprehensive multi-workspace management capabilities including:
- Multiple workspace configuration
- Workspace templates (empty, python, javascript, web, data_science, full_stack)
- Workspace switching with status management
- Workspace cloning
- Workspace snapshots and restoration
- Workspace sharing with permissions
- Workspace archiving
- JSON persistence for workspace configurations
- Active workspace tracking
- Workspace metadata support
- Comprehensive statistics
Components
from novacoder.workspace.multi_workspace import (
MultiWorkspaceManager, WorkspaceConfig, WorkspaceStatus,
WorkspaceTemplate, WorkspaceSnapshot, WorkspaceShare
)
manager = MultiWorkspaceManager("/path/to/base")
config = WorkspaceConfig("project1", "/path/to/project1")
manager.add_workspace(config)
Usage
Create Workspace from Template
Creates a new workspace from a template:
success = manager.create_workspace(
name="project1",
path="/path/to/project1",
template=WorkspaceTemplate.PYTHON
)
Available templates:
WorkspaceTemplate.EMPTY- Empty workspaceWorkspaceTemplate.PYTHON- Python project with main.py, requirements.txt, .gitignoreWorkspaceTemplate.JAVASCRIPT- JavaScript project with index.js, package.jsonWorkspaceTemplate.WEB- Web project with HTML, CSS, JS filesWorkspaceTemplate.DATA_SCIENCE- Data science project with notebook.ipynbWorkspaceTemplate.FULL_STACK- Full-stack project template
Add Workspace
Adds a new workspace configuration:
config = WorkspaceConfig(
name="project1",
path="/path/to/project1",
active=False,
status=WorkspaceStatus.INACTIVE,
template=WorkspaceTemplate.PYTHON,
metadata={"description": "Main project"}
)
success = manager.add_workspace(config)
Switch Workspace
Switches to a different workspace, marking it as active:
success = manager.switch_workspace("project1")
if success:
print("Switched to project1")
Clone Workspace
Clones an existing workspace:
success = manager.clone_workspace(
source_name="project1",
target_name="project1-clone",
target_path="/path/to/project1-clone"
)
Create Snapshot
Creates a snapshot of a workspace:
snapshot = manager.create_snapshot("project1", description="Before major refactoring")
print(f"Snapshot ID: {snapshot.snapshot_id}")
Restore Snapshot
Restores a workspace from a snapshot:
success = manager.restore_snapshot(
snapshot_id="snapshot-id",
target_name="project1-restored",
target_path="/path/to/project1-restored"
)
Share Workspace
Shares a workspace with another user:
share = manager.share_workspace(
workspace_name="project1",
shared_with="user@example.com",
permissions=["read", "write"]
)
print(f"Share ID: {share.share_id}")
Revoke Share
Revokes a workspace share:
success = manager.revoke_share(share_id="share-id")
Archive Workspace
Archives a workspace:
success = manager.archive_workspace("project1")
List Workspaces
Lists all configured workspaces:
workspaces = manager.list_workspaces()
for ws in workspaces:
print(f"{ws.name}: {ws.path} (active: {ws.active}, status: {ws.status.value})")
Get Active Workspace
Retrieves the currently active workspace:
active = manager.get_active_workspace()
if active:
print(f"Active: {active.name}")
Get Specific Workspace
Retrieves a specific workspace by name:
workspace = manager.get_workspace("project1")
if workspace:
print(f"Path: {workspace.path}")
print(f"Status: {workspace.status.value}")
print(f"Template: {workspace.template.value}")
List Snapshots
Lists snapshots for a workspace:
snapshots = manager.list_snapshots("project1")
for snap in snapshots:
print(f"{snap.snapshot_id}: {snap.description}")
List Shares
Lists shares for a workspace:
shares = manager.list_shares("project1")
for share in shares:
print(f"{share.shared_with}: {share.permissions}")
Get Statistics
Gets workspace statistics:
stats = manager.get_statistics()
print(f"Total workspaces: {stats['total_workspaces']}")
print(f"Active workspaces: {stats['active_workspaces']}")
print(f"Archived workspaces: {stats['archived_workspaces']}")
print(f"Shared workspaces: {stats['shared_workspaces']}")
print(f"Total snapshots: {stats['total_snapshots']}")
print(f"Total shares: {stats['total_shares']}")
Remove Workspace
Removes a workspace configuration:
success = manager.remove_workspace("project1", delete_files=True)
Data Structures
WorkspaceConfig
Represents a workspace configuration:
name: Unique workspace namepath: Path to the workspace directoryactive: Whether this is the active workspacestatus: Workspace status (ACTIVE, INACTIVE, ARCHIVED, CLONED, SHARED)template: Workspace template usedcreated_at: Creation timestamplast_accessed: Last access timestampmetadata: Additional metadata dictionarydependencies: List of workspace dependenciesshared_with: List of users workspace is shared with
WorkspaceStatus
Enum for workspace status:
ACTIVE- Currently active workspaceINACTIVE- Not activeARCHIVED- Archived workspaceCLONED- Cloned workspaceSHARED- Shared workspace
WorkspaceTemplate
Enum for workspace templates:
EMPTY- Empty workspacePYTHON- Python projectJAVASCRIPT- JavaScript projectWEB- Web projectDATA_SCIENCE- Data science projectFULL_STACK- Full-stack project
WorkspaceSnapshot
Represents a workspace snapshot:
snapshot_id: Unique snapshot identifierworkspace_name: Name of the workspacecreated_at: Creation timestampdescription: Snapshot descriptionmetadata: Additional metadata
WorkspaceShare
Represents a workspace share:
share_id: Unique share identifierworkspace_name: Name of the workspaceshared_with: User to share withpermissions: List of permissions (read, write, admin)shared_at: Share timestampexpires_at: Expiration timestamp
Integration
WorkspaceService
from novacoder.workspace.service import WorkspaceService
service = WorkspaceService()
service.initialize()
manager = service.multi_workspace_manager
Web API
GET /api/workspace/workspaces
POST /api/workspace/create-workspace
POST /api/workspace/clone-workspace
POST /api/workspace/create-snapshot
POST /api/workspace/restore-snapshot
POST /api/workspace/share-workspace
DELETE /api/workspace/revoke-share
POST /api/workspace/archive-workspace
GET /api/workspace/statistics
CLI
novacoder workspace list-workspaces
novacoder workspace add-workspace project1 /path/to/project1
novacoder workspace switch-workspace project1
novacoder workspace create-workspace project1 /path/to/project1 --template python
novacoder workspace clone-workspace project1 project1-clone /path/to/clone
novacoder workspace create-snapshot project1 "Before refactoring"
novacoder workspace restore-snapshot snapshot-id project1-restored /path/to/restored
novacoder workspace share-workspace project1 user@example.com read,write
novacoder workspace archive-workspace project1
TUI
View workspaces table in the Workspace page with status, template, and actions.
Features
- Workspace Templates: Pre-configured templates for different project types
- Workspace Cloning: Clone existing workspaces with metadata tracking
- Workspace Snapshots: Create and restore workspace snapshots
- Workspace Sharing: Share workspaces with granular permissions
- Workspace Archiving: Archive workspaces without deleting files
- JSON Persistence: Automatically saves workspace configurations to
.novacoder/workspaces.json - Snapshot Persistence: Automatically saves snapshots to
.novacoder/snapshots.json - Share Persistence: Automatically saves shares to
.novacoder/shares.json - Active Tracking: Tracks which workspace is currently active
- Status Management: Track workspace status (active, inactive, archived, cloned, shared)
- Metadata Support: Stores additional metadata with each workspace
- Path Validation: Validates workspace paths before adding
- Error Handling: Gracefully handles non-existent workspaces
- Comprehensive Statistics: Detailed statistics on workspaces, snapshots, and shares
Configuration Files
Workspace Configurations
Stored in:
~/.config/novacoder/workspaces.json
Format:
{
"project1": {
"name": "project1",
"path": "/path/to/project1",
"active": true,
"status": "active",
"template": "python",
"created_at": "2026-07-31T00:00:00",
"last_accessed": "2026-07-31T12:00:00",
"metadata": {},
"dependencies": [],
"shared_with": []
}
}
Snapshots
Stored in:
~/.config/novacoder/snapshots.json
Format:
[
{
"snapshot_id": "uuid",
"workspace_name": "project1",
"created_at": "2026-07-31T00:00:00",
"description": "Before refactoring",
"metadata": {}
}
]
Shares
Stored in:
~/.config/novacoder/shares.json
Format:
[
{
"share_id": "uuid",
"workspace_name": "project1",
"shared_with": "user@example.com",
"permissions": ["read", "write"],
"shared_at": "2026-07-31T00:00:00",
"expires_at": ""
}
]
REST API
The manager is exposed via novacoder/api/routes_workspace_multi.py:
| Endpoint | Description |
|---|---|
GET /api/workspace/workspaces |
List configured workspaces |
POST /api/workspace/workspaces |
Add ({"name","path"}) or create ("create":true + "template") a workspace |
GET /api/workspace/workspaces/active |
Currently active workspace |
POST /api/workspace/workspaces/{name}/switch |
Mark a workspace active |
DELETE /api/workspace/workspaces/{name} |
Remove (optional ?delete_files=true) |
POST /api/workspace/workspaces/{name}/clone |
Clone to {"target_name","target_path"} |
POST /api/workspace/workspaces/{name}/archive |
Archive a workspace |
GET/POST /api/workspace/workspaces/{name}/snapshots |
List / create snapshots |
POST /api/workspace/snapshots/{id}/restore |
Restore to {"target_name","target_path"} |
GET/POST /api/workspace/workspaces/{name}/share |
List / create shares ({"shared_with","permissions"}) |
DELETE /api/workspace/shares/{share_id} |
Revoke a share |
POST /api/workspace/merge |
Merge two paths, strategies copy, git-merge, manual (dry-run plan) |
File-watcher control (the workspace.watch flag still controls boot-time auto-start):
| Endpoint | Description |
|---|---|
GET /api/workspace/watcher |
{running, path} |
POST /api/workspace/watcher/start |
Start the watcher thread |
POST /api/workspace/watcher/stop |
Stop the watcher thread |
The React Workspace page surfaces all of this under "Multi-Workspace & Watcher" (add form, per-workspace switch/snapshot/archive/remove, merge form, watcher toggle).
Related
- Workspace
- Advanced Workspace
- Workspace Analytics
IDE Integration (multi-root)
The React IDE is multi-root aware. GET /api/ide/info now returns a
roots array, the primary workspace plus every configured
MultiWorkspaceManager workspace, and the toolbar root selector
switches the active root via POST /api/workspace/switch with
{"name": "<workspace>"} (the sentinel "__primary__" selects the
primary workspace).
Switching calls WorkspaceService.set_active_root(path) which retargets
service.workspace, _project_path, and the path-scoped engines
(indexer/symbol graph) so IDE file reads, tree browsing, search, and
debug sessions resolve against the newly active root. Removing the
active workspace falls back to the primary root via
MultiWorkspaceManager.clear_active(). The pre-existing bare-array
GET /api/workspace/workspaces contract in
routes_workspace_enhancement_systems.py is preserved.
On a root switch the IDE closes all open tabs (paths are root-relative), clears breakpoints/diagnostics/decorations, and invalidates the editor/tree React Query caches.
Tests: tests/test_ide_roots.py (6 tests).