/** Workspaces list page. */ import { useState } from "react"; import { Icon } from "../components/icon"; import { useWorkspaces } from "../hooks/use-workspaces"; import { useWorkspaceActions } from "../hooks/use-workspace-actions"; import { WorkspaceCard } from "../components/workspace-card"; import { WorkspaceCreateForm } from "../components/workspace-create-form"; import { StartToolModal } from "../components/start-tool-modal"; import type { Workspace } from "../types/workspace"; export function WorkspacesPage() { const [showCreate, setShowCreate] = useState(false); const [startWorkspace, setStartWorkspace] = useState(null); // TODO: Get projectId and repoId from URL params or context const projectId = "default-project"; const repoId = "default-repo"; const { workspaces, loading, error, refresh } = useWorkspaces(projectId, repoId); const actions = useWorkspaceActions(); const handleCreate = async (data: { name: string; branch: string }) => { await actions.create(projectId, repoId, data); setShowCreate(false); await refresh(); }; const handleDelete = async (workspace: Workspace) => { await actions.delete(projectId, repoId, workspace, refresh); }; const handleSync = async (workspace: Workspace) => { await actions.sync(projectId, repoId, workspace, refresh); }; const handleStartTool = async (toolTypeId: string, configProfileId?: string) => { if (!startWorkspace) return; // TODO: Call instance creation API with workspace_id console.log("Start tool", { toolTypeId, configProfileId, workspace: startWorkspace.id }); setStartWorkspace(null); }; return (

Workspaces

{error &&
{error}
} {showCreate && ( setShowCreate(false)} /> )} {loading && workspaces.length === 0 ? (
Loading workspaces...
) : workspaces.length === 0 ? (

No workspaces yet.

) : (
{workspaces.map((ws) => ( ))}
)} {startWorkspace && ( setStartWorkspace(null)} onStart={handleStartTool} /> )}
); }