Skip to content

Commit cbbe594

Browse files
docs: complete validate_path and get_workspace_tab docstrings
1 parent a41fa84 commit cbbe594

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

api/config_api.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,22 @@ def detect_environment() -> Response:
6565

6666
@bp.route("/api/validate-path", methods=["POST"])
6767
def validate_path() -> tuple[Response, int] | Response:
68-
"""Same path rules as POST /api/set-workspace: realpath, markers (issue #15)."""
68+
"""Validate a workspace storage path without persisting it (POST /api/validate-path).
69+
70+
Uses the same rules as :func:`set_workspace` (realpath, Cursor markers; issue #15).
71+
72+
Args:
73+
path: Workspace storage root from JSON body ``{"path": "..."}``.
74+
75+
Returns:
76+
JSON with ``valid``, ``workspaceCount``, and canonical ``path`` on success.
77+
``valid`` is ``false`` when the path fails validation or contains no
78+
workspace folders with ``state.vscdb``. Invalid JSON body returns
79+
``{"valid": false, "error": "invalid JSON body", "workspaceCount": 0}``.
80+
Path validation errors return ``{"valid": false, "error": "...", "workspaceCount": 0}``.
81+
500 with ``{"valid": false, "error": "Failed to validate path"}`` on
82+
unexpected failure.
83+
"""
6984
try:
7085
body = request.get_json(silent=True) or {}
7186
if not isinstance(body, dict):
@@ -102,6 +117,8 @@ def validate_path() -> tuple[Response, int] | Response:
102117
exc_info=True,
103118
)
104119
return json_response({"valid": False, "error": "Failed to validate path"}, 500)
120+
121+
105122
@bp.route("/api/set-workspace", methods=["POST"])
106123
def set_workspace() -> tuple[Response, int] | Response:
107124
"""Persist a validated workspace storage path (POST /api/set-workspace).

api/workspaces.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def list_workspaces() -> tuple[Response, int] | Response:
7575
except Exception:
7676
_logger.exception("Failed to get workspaces")
7777
return json_response({"error": "Failed to get workspaces"}, 500)
78+
79+
7880
# ---------------------------------------------------------------------------
7981
# GET /api/workspaces/<id>
8082
# ---------------------------------------------------------------------------
@@ -158,6 +160,8 @@ def get_workspace(workspace_id: str) -> tuple[Response, int] | Response:
158160
except Exception:
159161
_logger.exception("Failed to get workspace")
160162
return json_response({"error": "Failed to get workspace"}, 500)
163+
164+
161165
# ---------------------------------------------------------------------------
162166
# GET /api/workspaces/<id>/tabs
163167
# ---------------------------------------------------------------------------
@@ -198,6 +202,8 @@ def get_workspace_tabs(workspace_id: str) -> tuple[Response, int] | Response:
198202
except Exception:
199203
_logger.exception("Failed to get workspace tabs")
200204
return json_response({"error": "Failed to get workspace tabs"}, 500)
205+
206+
201207
# ---------------------------------------------------------------------------
202208
# GET /api/workspaces/<id>/tabs/<composer_id>
203209
# ---------------------------------------------------------------------------
@@ -207,12 +213,15 @@ def get_workspace_tab(workspace_id: str, composer_id: str) -> tuple[Response, in
207213
"""Lazy-load one conversation tab (GET /api/workspaces/<id>/tabs/<composer_id>).
208214
209215
Args:
210-
workspace_id: IDE workspace folder name (CLI workspaces return 400).
216+
workspace_id: Storage folder name, ``global`` for unassigned chats, or
217+
``cli:<project_id>`` (CLI workspaces return 400).
211218
composer_id: Composer UUID to load.
212219
213220
Returns:
214-
Single-tab JSON from :func:`services.workspace_tabs.assemble_single_tab`.
215-
400 for CLI workspaces; 500 on unexpected failure.
221+
Single-tab JSON from :func:`services.workspace_tabs.assemble_single_tab`
222+
(typically ``{"tab": {...}}`` with optional ``warnings``). 400 for CLI
223+
workspaces; 404 when global storage is missing, the composer is not found,
224+
or it is not assigned to *workspace_id*; 500 on unexpected failure.
216225
"""
217226
if workspace_id.startswith("cli:"):
218227
return json_response({"error": "Per-tab lazy load is not supported for CLI workspaces"}, 400)

0 commit comments

Comments
 (0)