@@ -57,6 +57,14 @@ def _request_nocache() -> bool:
5757
5858@bp .route ("/api/workspaces" )
5959def list_workspaces () -> tuple [Response , int ] | Response :
60+ """List workspace projects for the sidebar (GET /api/workspaces).
61+
62+ Args:
63+ nocache: When ``1`` or ``true``, bypass the summary disk cache.
64+
65+ Returns:
66+ JSON with ``projects`` and optional ``warnings``. 500 on failure.
67+ """
6068 try :
6169 workspace_path = resolve_workspace_path ()
6270 rules = exclusion_rules ()
@@ -70,12 +78,23 @@ def list_workspaces() -> tuple[Response, int] | Response:
7078 except Exception :
7179 _logger .exception ("Failed to get workspaces" )
7280 return json_response ({"error" : "Failed to get workspaces" }, 500 )
81+
82+
7383# ---------------------------------------------------------------------------
7484# GET /api/workspaces/<id>
7585# ---------------------------------------------------------------------------
7686
7787@bp .route ("/api/workspaces/<workspace_id>" )
7888def get_workspace (workspace_id : str ) -> tuple [Response , int ] | Response :
89+ """Return metadata for one workspace, global bucket, or CLI project.
90+
91+ Args:
92+ workspace_id: Storage folder name, ``global``, or ``cli:<project_id>``.
93+
94+ Returns:
95+ Workspace JSON (id, name, path, folder, lastModified). 404 when not found;
96+ 500 on unexpected failure.
97+ """
7998 try :
8099 if workspace_id == "global" :
81100 return json_response ({
@@ -144,12 +163,28 @@ def get_workspace(workspace_id: str) -> tuple[Response, int] | Response:
144163 except Exception :
145164 _logger .exception ("Failed to get workspace" )
146165 return json_response ({"error" : "Failed to get workspace" }, 500 )
166+
167+
147168# ---------------------------------------------------------------------------
148169# GET /api/workspaces/<id>/tabs
149170# ---------------------------------------------------------------------------
150171
151172@bp .route ("/api/workspaces/<workspace_id>/tabs" )
152173def get_workspace_tabs (workspace_id : str ) -> tuple [Response , int ] | Response :
174+ """List conversation tabs for a workspace (GET /api/workspaces/<id>/tabs).
175+
176+ Args:
177+ workspace_id: Storage folder name, ``global`` for unassigned chats, or
178+ ``cli:<project_id>``.
179+ summary: When ``1`` or ``true``, return lightweight tab headers only.
180+ nocache: When ``1`` or ``true``, bypass cache on summary requests.
181+
182+ Returns:
183+ Tabs payload from :func:`services.workspace_tabs` helpers (typically
184+ ``{"tabs": [...]}`` with optional ``warnings``). May return 200 with an
185+ empty ``tabs`` list when upstream SQLite reads fail silently; 404 when
186+ global storage is missing; 500 on unexpected route-level failure.
187+ """
153188 if workspace_id .startswith ("cli:" ):
154189 try :
155190 return get_cli_workspace_tabs (workspace_id , exclusion_rules ())
@@ -170,12 +205,27 @@ def get_workspace_tabs(workspace_id: str) -> tuple[Response, int] | Response:
170205 except Exception :
171206 _logger .exception ("Failed to get workspace tabs" )
172207 return json_response ({"error" : "Failed to get workspace tabs" }, 500 )
208+
209+
173210# ---------------------------------------------------------------------------
174211# GET /api/workspaces/<id>/tabs/<composer_id>
175212# ---------------------------------------------------------------------------
176213
177214@bp .route ("/api/workspaces/<workspace_id>/tabs/<composer_id>" )
178215def get_workspace_tab (workspace_id : str , composer_id : str ) -> tuple [Response , int ] | Response :
216+ """Lazy-load one conversation tab (GET /api/workspaces/<id>/tabs/<composer_id>).
217+
218+ Args:
219+ workspace_id: Storage folder name, ``global`` for unassigned chats, or
220+ ``cli:<project_id>`` (CLI workspaces return 400).
221+ composer_id: Composer UUID to load.
222+
223+ Returns:
224+ Single-tab JSON from :func:`services.workspace_tabs.assemble_single_tab`
225+ (typically ``{"tab": {...}}`` with optional ``warnings``). 400 for CLI
226+ workspaces; 404 when global storage is missing, the composer is not found,
227+ or it is not assigned to *workspace_id*; 500 on unexpected failure.
228+ """
179229 if workspace_id .startswith ("cli:" ):
180230 return json_response ({"error" : "Per-tab lazy load is not supported for CLI workspaces" }, 400 )
181231 try :
0 commit comments