Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 0f59a5f0023b5bc4a1a4fcc6ee816b57dcfb23b3
parent 4b4f811c2e634bd09c4216b66bd44761cc96d52d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu,  5 Nov 2026 02:49:40 -0500

umtool: New take's Save as a draft -- the take recorded with nothing rendered (umtool take … --draft, through the take tools route with the form's label, group, style, patch and window), then a link to walk it

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/app/api/report/takes/tools/route.ts | 24+++++++++++++++++++++++-
Mumtool/components/projects/NewTakePanel.tsx | 37+++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/umtool/app/api/report/takes/tools/route.ts b/umtool/app/api/report/takes/tools/route.ts @@ -19,6 +19,9 @@ export const dynamic = "force-dynamic"; // POST { project, take, op: "import", refs: "<project>:<item>[,…]", after?, before?, dryRun? } // umtool take <p> --id <take> --import-item … [--dry-run] --json // -> { exit, report } +// POST { project, op: "draft-new", label, group?, style?, patch?, window? } +// umtool take <p> --id <slug of label> --label L --draft +// -> { exit, id, report } [--group G] [--style S] [--patch-json P] [--full | --at A --dur D] export async function POST(request: Request) { const refused = refuseCaller(request, "/api/report/takes/tools"); if (refused) return refused; @@ -46,6 +49,25 @@ export async function POST(request: Request) { const exit = await lintCommand([project.id, ...(take ? ["--take", take] : []), "--json"], io); return answer(exit); } + if (body.op === "draft-new") { + // A draft from the New take form: recorded, nothing rendered (`umtool take … --draft`), walked before it renders. + const label = typeof body.label === "string" ? body.label.replace(/\s+/g, " ").trim() : ""; + if (!label) return Response.json({ error: "a draft needs a label" }, { status: 400 }); + const have = new Set(((await listTakes(project.dir)).takes as { id: string }[]).map((t) => t.id)); + const base = label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "draft"; + let id = base; + for (let n = 2; have.has(id) && n < 1000; n++) id = `${base}-${n}`; + if (!isTakeId(id)) return Response.json({ error: `"${id}" is not a take id` }, { status: 400 }); + const w = body.window as { at?: number; dur?: number } | "full" | undefined; + const args = [project.id, "--id", id, "--label", label, "--draft", "--json"]; + if (typeof body.group === "string" && body.group) args.push("--group", body.group); + if (typeof body.style === "string" && body.style) args.push("--style", body.style); + if (body.patch && typeof body.patch === "object") args.push("--patch-json", JSON.stringify(body.patch)); + if (w === "full") args.push("--full"); + else if (w && typeof w === "object" && Number.isFinite(w.at) && Number.isFinite(w.dur)) args.push("--at", String(w.at), "--dur", String(w.dur)); + const exit = await takeCommand(args, io); + return answer(exit, { id }); + } if (!take) return Response.json({ error: `${String(body.op)} needs a take` }, { status: 400 }); if (body.op === "draft-from") { let id = typeof body.id === "string" && body.id ? body.id : null; @@ -65,7 +87,7 @@ export async function POST(request: Request) { const exit = await takeCommand([project.id, "--id", take, ...refs.split(/\s+/).flatMap((r) => ["--import-item", r]), ...place, ...(body.dryRun ? ["--dry-run"] : []), "--json"], io); return answer(exit); } - return Response.json({ error: "op must be lint, draft-from or import" }, { status: 400 }); + return Response.json({ error: "op must be lint, draft-from, draft-new or import" }, { status: 400 }); } catch (e) { return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 500 }); } diff --git a/umtool/components/projects/NewTakePanel.tsx b/umtool/components/projects/NewTakePanel.tsx @@ -3,6 +3,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { useRouter } from "next/navigation"; import { buttonVariants } from "@/components/ui/button"; +import { takeWalkHref } from "@/lib/hrefs"; import { Field, Input, Select, Textarea } from "@/components/ui/field"; import { JobProgress, type JobStepState } from "@/components/ui/job-progress"; import RenderModeBanner, { renderPriorityPref } from "./RenderModeBanner"; @@ -153,6 +154,24 @@ export default function NewTakePanel({ if (r.error) setError(r.error); }; + // Save as a draft (lane/ui-simplify): the take recorded with nothing rendered (POST /api/report/takes/tools, draft-new). + const [drafted, setDrafted] = useState<string | null>(null); + const saveDraft = async () => { + setBusy(true); + setError(null); + const r = await fetch("/api/report/takes/tools", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ project, op: "draft-new", label, group, style: style || null, patch, window: windowOf() }), + }); + const j = (await r.json().catch(() => ({}))) as { exit?: number; id?: string; said?: string; error?: string }; + setBusy(false); + if (r.ok && j.exit === 0 && j.id) { + setDrafted(j.id); + router.refresh(); + } else setError(j.error ?? j.said ?? `HTTP ${r.status}`); + }; + const takeEvents = (job?.events ?? []).filter((e) => e.ev === "take"); const takeIds = [...new Set(takeEvents.map((e) => String(e.id)))]; const stateOf = (id: string) => { @@ -292,6 +311,16 @@ export default function NewTakePanel({ </button> <button type="button" + data-action="save-draft" + disabled={!ready || busy || running || !label.trim() || !!patchError || windowBad} + className={buttonVariants({ variant: "quiet", size: "sm" })} + title={`umtool take ${project} --id <label> --label … --draft: recorded, nothing rendered — walk it, then render it`} + onClick={() => void saveDraft()} + > + Save as a draft + </button> + <button + type="button" data-action="make-all-styles" disabled={!ready || busy || running || !styles.length || windowBad} className={buttonVariants({ size: "sm" })} @@ -310,6 +339,14 @@ export default function NewTakePanel({ </div> </form> </details> + {drafted && ( + <p data-take-drafted-new={drafted} className="text-[12px] text-text-2"> + draft <b className="font-mono">{drafted}</b> recorded, nothing rendered:{" "} + <a href={takeWalkHref(project, drafted)} className="ink-link"> + walk it + </a> + </p> + )} {error && ( <p data-take-error="" role="alert" className="text-[12px] text-reject-text"> {error}