Factory recreate mode; chunked uploads with progress everywhere
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
771c6f5245
commit
b309778be8
17 files changed
+477
-47
No files matched your search
@@ -3,6 +3,7 @@ import { get, post } from "../api";
|
||||
import { useT } from "../i18n";
|
||||
import { navigate } from "../router";
|
||||
import { toast } from "../dialogs";
|
||||
import { uploadBatch } from "../uploads";
|
||||
import { Icon } from "./Icon";
|
||||
import { Spinner } from "./Activity";
|
||||
|
||||
@@ -11,6 +12,7 @@ interface Draft {
|
||||
setup?: string | null;
|
||||
proposal: { name?: string; slug?: string; description?: string } | null;
|
||||
connections: { id: string; name: string; kind: string; owner: string }[];
|
||||
recreate?: boolean;
|
||||
}
|
||||
|
||||
export const isDraftChat = (cwd: string) => /\/_drafts\/[^/]+$/.test(cwd);
|
||||
@@ -88,9 +90,9 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
|
||||
const create = async () => {
|
||||
setBusy(true);
|
||||
try {
|
||||
const r = await post<{ repo: string; issue: number }>(`/factory/drafts/${sessionId}/create`, { connection, name, slug, description, owner });
|
||||
const r = await post<{ repo: string; issue: number | null }>(`/factory/drafts/${sessionId}/create`, { connection, name, slug, description, owner });
|
||||
await post("/factory/poll", {}).catch(() => undefined);
|
||||
toast(t("draft.created", { repo: r.repo, n: r.issue }), "success");
|
||||
toast(r.issue == null ? t("draft.createdRecreate", { repo: r.repo }) : t("draft.created", { repo: r.repo, n: r.issue }), "success");
|
||||
onClose();
|
||||
navigate("/factory");
|
||||
} catch (e: any) {
|
||||
@@ -312,3 +314,58 @@ function CreateIssuesDialog({ sessionId, onClose }: { sessionId: string; onClose
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Start a recreate draft: the original (upload and/or URL) is analysed in depth, then a clean-room spec is written. */
|
||||
export function RecreateDialog({ onClose }: { onClose: () => void }) {
|
||||
const t = useT();
|
||||
const [source, setSource] = useState("");
|
||||
const [notes, setNotes] = useState("");
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const start = async () => {
|
||||
setBusy(true);
|
||||
try {
|
||||
const s = await post<{ id: string; cwd: string }>("/factory/drafts", { mode: "recreate", source, notes });
|
||||
const sent = await uploadBatch(files.map((f) => ({ file: f, path: `${s.cwd}/original/${f.name}` })));
|
||||
if (sent.length < files.length) throw new Error(t("recreate.uploadFailed"));
|
||||
await post(`/sessions/${s.id}/prompt`, { text: t("recreate.firstMessage") });
|
||||
onClose();
|
||||
navigate(`/s/${s.id}`);
|
||||
} catch (e: any) {
|
||||
toast(e.message);
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="modal-backdrop" onClick={busy ? undefined : onClose}>
|
||||
<div className="modal draft-modal" role="dialog" aria-label={t("recreate.title")} onClick={(e) => e.stopPropagation()}>
|
||||
<h3>{t("recreate.title")}</h3>
|
||||
<div className="hint" style={{ marginBottom: 8 }}>{t("recreate.hint")}</div>
|
||||
<div className="factory-form">
|
||||
<label style={{ gridColumn: "1 / -1" }}>
|
||||
<span>{t("recreate.source")}</span>
|
||||
<input autoFocus value={source} placeholder="https://…" onChange={(e) => setSource(e.target.value)} />
|
||||
</label>
|
||||
<label style={{ gridColumn: "1 / -1" }}>
|
||||
<span>{t("recreate.files")}</span>
|
||||
<input type="file" multiple onChange={(e) => setFiles([...(e.target.files ?? [])])} />
|
||||
</label>
|
||||
<label style={{ gridColumn: "1 / -1" }}>
|
||||
<span>{t("recreate.notes")}</span>
|
||||
<textarea rows={4} value={notes} placeholder={t("recreate.notesPlaceholder")} onChange={(e) => setNotes(e.target.value)} />
|
||||
</label>
|
||||
</div>
|
||||
<div className="row" style={{ justifyContent: "flex-end", gap: 8, marginTop: 12 }}>
|
||||
<button onClick={onClose} disabled={busy}>
|
||||
{t("common.cancel")}
|
||||
</button>
|
||||
<button className="primary" onClick={start} disabled={busy || (!source.trim() && files.length === 0)}>
|
||||
{busy ? <Spinner small /> : <Icon name="search" />} {t("recreate.go")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user