/** Floating action button to start a tool from any page. */ import { useState } from "react"; import { Icon } from "./icon"; import { ToolStarter } from "./tool-starter"; import type { Workspace } from "../types/workspace"; import { listAllWorkspaces } from "../api/workspaces"; export function StartToolFAB() { const [open, setOpen] = useState(false); const [workspaces, setWorkspaces] = useState([]); const [workspacesLoading, setWorkspacesLoading] = useState(false); const [selectedWorkspace, setSelectedWorkspace] = useState( null, ); const handleOpen = async () => { setOpen(true); setWorkspacesLoading(true); try { const data = await listAllWorkspaces(); setWorkspaces(data); } catch { // ignore } finally { setWorkspacesLoading(false); } }; const handleClose = () => { setOpen(false); setSelectedWorkspace(null); }; return ( <> {open && (
e.stopPropagation()} >

Start Tool

{workspacesLoading ? (

Loading workspaces...

) : workspaces.length === 0 ? (

No workspaces yet.{" "} Create a workspace first.

) : !selectedWorkspace ? (
) : ( <>

{selectedWorkspace.project_name} /{" "} {selectedWorkspace.repo_name} / {selectedWorkspace.name}

setSelectedWorkspace(null)} /> )}
)} ); }