import { useState } from "react"; import type { Item } from "../types"; import { chooseFolder } from "../tauri"; import { Icon } from "./Icon"; type DirReqItem = Extract; // The agent asked (via request_directory) for access to a folder. The user picks/confirms a path // and access level, or declines — mirroring the approval card, shown in the composer head. export function DirectoryRequestCard({ item, onRespond, }: { item: DirReqItem; onRespond: (granted: boolean, path?: string, writable?: boolean) => void; }) { const [path, setPath] = useState(item.path || ""); const [writable, setWritable] = useState(!!item.writable); const browse = async () => { const picked = await chooseFolder(); if (picked) setPath(picked); }; return (
{item.primary ? "The agent asks to make a folder this session's workspace" : "The agent is requesting access to a folder"}
{item.reason &&
“{item.reason}”
} {item.primary && (
Granting makes this folder the session's primary working directory (read-write); the scratch directory stays available for temporary files and artifacts.
)}
setPath(e.target.value)} />
{!item.primary && ( )}
); }