import { useEffect, useState } from "react"; import { getRecentWorkspaces, openWorkspace, type RecentWorkspace } from "../api"; import { chooseFolder } from "../tauri"; import { baseName } from "../paths"; import { Icon } from "./Icon"; // UX-029: folder enforcement AT SEND, not at session start. A code-family coworker with no // folder picked gets this dialog when the user hits send; the message goes out the moment a // choice lands (recents / native picker / temporary folder). Escape restores the draft. interface Props { coworkerName: string; onPick: (path: string, branch?: string | null) => void; onTemp: () => void; onCancel: () => void; } export function SendFolderDialog({ coworkerName, onPick, onTemp, onCancel }: Props) { const [recents, setRecents] = useState([]); const [error, setError] = useState(""); const [busy, setBusy] = useState(false); useEffect(() => { getRecentWorkspaces().then(setRecents).catch(() => {}); }, []); useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onCancel(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [onCancel]); const pick = async (path: string) => { setError(""); const res = await openWorkspace(path); if (res.ok) onPick(res.path, res.git_branch); else setError(res.error || "could not open that folder"); }; const browse = async () => { const picked = await chooseFolder(); if (picked) await pick(picked); }; return (
e.stopPropagation()} >

Where should {coworkerName} work?

Code work happens inside a folder — pick your project, or start somewhere temporary.

{recents .filter((w) => w.exists) .slice(0, 4) .map((w) => ( ))}
{error &&
{error}
}

A temporary folder is created only when you send, with git ready — you can save it as a project later. Your message sends as soon as you choose.

); }