import * as React from "react"; import { api } from "./api/client"; import { Chat } from "./components/Chat"; import "./App.css"; function App() { const [projectPath, setProjectPath] = React.useState(null); const [errorMsg, setErrorMsg] = React.useState(null); const [pathInput, setPathInput] = React.useState(""); const [isOpening, setIsOpening] = React.useState(false); const [knownProjects, setKnownProjects] = React.useState([]); React.useEffect(() => { api .getKnownProjects() .then((projects) => setKnownProjects(projects)) .catch((error) => console.error(error)); }, []); async function openProject(path: string) { if (!path.trim()) { setErrorMsg("Please enter a project path."); return; } try { setErrorMsg(null); setIsOpening(true); const confirmedPath = await api.openProject(path.trim()); setProjectPath(confirmedPath); } catch (e) { console.error(e); const message = e instanceof Error ? e.message : typeof e === "string" ? e : "An error occurred opening the project."; setErrorMsg(message); } finally { setIsOpening(false); } } function handleOpen() { void openProject(pathInput); } async function closeProject() { try { await api.closeProject(); setProjectPath(null); } catch (e) { console.error(e); } } return (
{!projectPath ? (

AI Code Assistant

Paste a project path to start the Story-Driven Spec Workflow.

{knownProjects.length > 0 && (
Recent projects
    {knownProjects.map((project) => (
  • ))}
)} setPathInput(event.target.value)} onKeyDown={(event) => { if (event.key === "Enter") { handleOpen(); } }} style={{ width: "100%", padding: "10px", marginTop: "12px" }} />
) : (
)} {errorMsg && (

Error: {errorMsg}

)}
); } export default App;