diff --git a/apps/web/src/api/sessions.ts b/apps/web/src/api/sessions.ts index 7bede1c..0bc13e8 100644 --- a/apps/web/src/api/sessions.ts +++ b/apps/web/src/api/sessions.ts @@ -54,13 +54,15 @@ export async function createInstance( branch?: string, newBranch?: string, configProfileId?: string, - sshKeyIds?: string[] + sshKeyIds?: string[], + workspaceId?: string ): Promise { const response = await apiClient.post( `/projects/${projectId}/repositories/${repoId}/instances`, { tool_type_id: toolTypeId, display_name: displayName, + workspace_id: workspaceId || undefined, clone_mode: cloneMode || "mount", branch: branch || undefined, new_branch: newBranch || undefined, diff --git a/apps/web/src/pages/workspaces.tsx b/apps/web/src/pages/workspaces.tsx index d055323..92f36a0 100644 --- a/apps/web/src/pages/workspaces.tsx +++ b/apps/web/src/pages/workspaces.tsx @@ -7,6 +7,7 @@ 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 { createInstance, startInstance } from "../api/sessions"; import type { Workspace } from "../types/workspace"; export function WorkspacesPage() { @@ -36,9 +37,25 @@ export function WorkspacesPage() { 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); + try { + const instance = await createInstance( + projectId, + repoId, + toolTypeId, + `${startWorkspace.name} - ${toolTypeId}`, + undefined, + undefined, + undefined, + configProfileId, + [], + startWorkspace.id + ); + await startInstance(projectId, repoId, instance.id, configProfileId); + setStartWorkspace(null); + await refresh(); + } catch (err) { + alert(err instanceof Error ? err.message : "Failed to start tool"); + } }; return (