-
Notifications
You must be signed in to change notification settings - Fork 1
docs: add Google-style docstrings to public api/services/utils/models… #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
b1b04be
efd50a0
a41fa84
cbbe594
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,10 +24,7 @@ | |
| warn_workspace_json_read, | ||
| ) | ||
| from utils.workspace_descriptor import read_json_file | ||
| from services.workspace_resolver import ( | ||
| infer_workspace_name_from_context, | ||
| lookup_workspace_display_name, | ||
| ) | ||
| from services.workspace_resolver import infer_workspace_name_from_context | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1): it is the cleanup your own PR body lists as out of scope, so it contradicts "docstrings only, not function changes" |
||
| from services.cli_tabs import get_cli_workspace_tabs | ||
| from services.workspace_listing import list_workspace_projects | ||
| from services.workspace_tabs import ( | ||
|
|
@@ -57,6 +54,14 @@ def _request_nocache() -> bool: | |
|
|
||
| @bp.route("/api/workspaces") | ||
| def list_workspaces() -> tuple[Response, int] | Response: | ||
| """List workspace projects for the sidebar (GET /api/workspaces). | ||
|
|
||
| Args: | ||
| nocache: When ``1`` or ``true``, bypass the summary disk cache. | ||
|
|
||
| Returns: | ||
| JSON with ``projects`` and optional ``warnings``. 500 on failure. | ||
| """ | ||
| try: | ||
| workspace_path = resolve_workspace_path() | ||
| rules = exclusion_rules() | ||
|
|
@@ -70,12 +75,23 @@ def list_workspaces() -> tuple[Response, int] | Response: | |
| except Exception: | ||
| _logger.exception("Failed to get workspaces") | ||
| return json_response({"error": "Failed to get workspaces"}, 500) | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # GET /api/workspaces/<id> | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| @bp.route("/api/workspaces/<workspace_id>") | ||
| def get_workspace(workspace_id: str) -> tuple[Response, int] | Response: | ||
| """Return metadata for one workspace, global bucket, or CLI project. | ||
|
|
||
| Args: | ||
| workspace_id: Storage folder name, ``global``, or ``cli:<project_id>``. | ||
|
|
||
| Returns: | ||
| Workspace JSON (id, name, path, folder, lastModified). 404 when not found; | ||
| 500 on unexpected failure. | ||
| """ | ||
| try: | ||
| if workspace_id == "global": | ||
| return json_response({ | ||
|
|
@@ -144,12 +160,28 @@ def get_workspace(workspace_id: str) -> tuple[Response, int] | Response: | |
| except Exception: | ||
| _logger.exception("Failed to get workspace") | ||
| return json_response({"error": "Failed to get workspace"}, 500) | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # GET /api/workspaces/<id>/tabs | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| @bp.route("/api/workspaces/<workspace_id>/tabs") | ||
| def get_workspace_tabs(workspace_id: str) -> tuple[Response, int] | Response: | ||
| """List conversation tabs for a workspace (GET /api/workspaces/<id>/tabs). | ||
|
|
||
| Args: | ||
| workspace_id: Storage folder name, ``global`` for unassigned chats, or | ||
| ``cli:<project_id>``. | ||
| summary: When ``1`` or ``true``, return lightweight tab headers only. | ||
| nocache: When ``1`` or ``true``, bypass cache on summary requests. | ||
|
|
||
| Returns: | ||
| Tabs payload from :func:`services.workspace_tabs` helpers (typically | ||
| ``{"tabs": [...]}`` with optional ``warnings``). May return 200 with an | ||
| empty ``tabs`` list when upstream SQLite reads fail silently; 404 when | ||
| global storage is missing; 500 on unexpected route-level failure. | ||
| """ | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| if workspace_id.startswith("cli:"): | ||
| try: | ||
| return get_cli_workspace_tabs(workspace_id, exclusion_rules()) | ||
|
|
@@ -170,12 +202,27 @@ def get_workspace_tabs(workspace_id: str) -> tuple[Response, int] | Response: | |
| except Exception: | ||
| _logger.exception("Failed to get workspace tabs") | ||
| return json_response({"error": "Failed to get workspace tabs"}, 500) | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # GET /api/workspaces/<id>/tabs/<composer_id> | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| @bp.route("/api/workspaces/<workspace_id>/tabs/<composer_id>") | ||
| def get_workspace_tab(workspace_id: str, composer_id: str) -> tuple[Response, int] | Response: | ||
| """Lazy-load one conversation tab (GET /api/workspaces/<id>/tabs/<composer_id>). | ||
|
|
||
| Args: | ||
| workspace_id: Storage folder name, ``global`` for unassigned chats, or | ||
| ``cli:<project_id>`` (CLI workspaces return 400). | ||
| composer_id: Composer UUID to load. | ||
|
|
||
| Returns: | ||
| Single-tab JSON from :func:`services.workspace_tabs.assemble_single_tab` | ||
| (typically ``{"tab": {...}}`` with optional ``warnings``). 400 for CLI | ||
| workspaces; 404 when global storage is missing, the composer is not found, | ||
| or it is not assigned to *workspace_id*; 500 on unexpected failure. | ||
| """ | ||
| if workspace_id.startswith("cli:"): | ||
| return json_response({"error": "Per-tab lazy load is not supported for CLI workspaces"}, 400) | ||
| try: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.