From 5bba2bbd92129e142122e5da4e0b8492deaba536 Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Sun, 31 May 2026 23:30:09 +0200 Subject: [PATCH] feat: workspace frontend integration (PR-4) - Add workspace_id parameter to createInstance API client - Wire WorkspacesPage 'Start Tool' modal to createInstance + startInstance - Pass workspace_id when creating instance from workspace page - TypeScript + eslint clean --- apps/web/src/api/sessions.ts | 4 +++- apps/web/src/pages/workspaces.tsx | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) 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 (