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
This commit is contained in:
2026-05-31 23:30:09 +02:00
parent 986091ac56
commit 5bba2bbd92
2 changed files with 23 additions and 4 deletions
+3 -1
View File
@@ -54,13 +54,15 @@ export async function createInstance(
branch?: string, branch?: string,
newBranch?: string, newBranch?: string,
configProfileId?: string, configProfileId?: string,
sshKeyIds?: string[] sshKeyIds?: string[],
workspaceId?: string
): Promise<ToolInstance> { ): Promise<ToolInstance> {
const response = await apiClient.post( const response = await apiClient.post(
`/projects/${projectId}/repositories/${repoId}/instances`, `/projects/${projectId}/repositories/${repoId}/instances`,
{ {
tool_type_id: toolTypeId, tool_type_id: toolTypeId,
display_name: displayName, display_name: displayName,
workspace_id: workspaceId || undefined,
clone_mode: cloneMode || "mount", clone_mode: cloneMode || "mount",
branch: branch || undefined, branch: branch || undefined,
new_branch: newBranch || undefined, new_branch: newBranch || undefined,
+20 -3
View File
@@ -7,6 +7,7 @@ import { useWorkspaceActions } from "../hooks/use-workspace-actions";
import { WorkspaceCard } from "../components/workspace-card"; import { WorkspaceCard } from "../components/workspace-card";
import { WorkspaceCreateForm } from "../components/workspace-create-form"; import { WorkspaceCreateForm } from "../components/workspace-create-form";
import { StartToolModal } from "../components/start-tool-modal"; import { StartToolModal } from "../components/start-tool-modal";
import { createInstance, startInstance } from "../api/sessions";
import type { Workspace } from "../types/workspace"; import type { Workspace } from "../types/workspace";
export function WorkspacesPage() { export function WorkspacesPage() {
@@ -36,9 +37,25 @@ export function WorkspacesPage() {
const handleStartTool = async (toolTypeId: string, configProfileId?: string) => { const handleStartTool = async (toolTypeId: string, configProfileId?: string) => {
if (!startWorkspace) return; if (!startWorkspace) return;
// TODO: Call instance creation API with workspace_id try {
console.log("Start tool", { toolTypeId, configProfileId, workspace: startWorkspace.id }); const instance = await createInstance(
setStartWorkspace(null); 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 ( return (