import { useState } from "react"; import { Terminal } from "./components/Terminal"; export function App() { const [cwd, setCwd] = useState(() => { const params = new URLSearchParams(window.location.search); return params.get("cwd") ?? "/"; }); return (
codehost |
); } function CwdInput({ cwd, onChange }: { cwd: string; onChange: (cwd: string) => void }) { const [editing, setEditing] = useState(false); const [draft, setDraft] = useState(cwd); if (editing) { return (
{ e.preventDefault(); onChange(draft); setEditing(false); }} style={{ flex: 1 }} > setDraft(e.target.value)} onBlur={() => setEditing(false)} onKeyDown={(e) => e.key === "Escape" && setEditing(false)} style={{ width: "100%", background: "#1f1f1f", border: "1px solid #555", color: "#ccc", fontFamily: "monospace", fontSize: 12, padding: "2px 6px", borderRadius: 3, outline: "none", }} />
); } return ( ); }