fix: add top-level GET /workspaces endpoint and derive project/repo from workspace data

- Add all_workspaces_router with GET /workspaces/ (no project/repo required)
- Include project_id in workspace responses
- Frontend: useWorkspaces() calls listAllWorkspaces when no args
- Frontend: WorkspacesPage uses top-level list, derives project/repo from workspace for mutations
- Fixes 422 from invalid UUID path params
This commit is contained in:
2026-06-01 00:20:19 +02:00
parent b05de96569
commit 59b125d8e2
6 changed files with 93 additions and 35 deletions
+7 -4
View File
@@ -1,7 +1,7 @@
/** Hook for fetching workspaces. */
import { useCallback, useEffect, useState } from "react";
import { listWorkspaces } from "../api/workspaces";
import { listAllWorkspaces, listWorkspaces } from "../api/workspaces";
import type { Workspace } from "../types/workspace";
export interface UseWorkspacesResult {
@@ -12,8 +12,8 @@ export interface UseWorkspacesResult {
}
export function useWorkspaces(
projectId: string,
repoId: string,
projectId?: string,
repoId?: string,
): UseWorkspacesResult {
const [workspaces, setWorkspaces] = useState<Workspace[]>([]);
const [loading, setLoading] = useState(true);
@@ -23,7 +23,10 @@ export function useWorkspaces(
setLoading(true);
setError(null);
try {
const data = await listWorkspaces(projectId, repoId);
const data =
projectId && repoId
? await listWorkspaces(projectId, repoId)
: await listAllWorkspaces();
setWorkspaces(data);
} catch (err) {
setError(