Factory: show and merge pull requests, issue chats (plan features, cut milestones)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Sonnet 5.5 committed 2026-11-16 11:31:36 +01:00
1 parent a0a4082383
commit 56c20d92f8
10 files changed
+673 -3

No files matched your search

+129
View File
@@ -183,3 +183,132 @@ function CreateProjectDialog({ sessionId, onClose }: { sessionId: string; onClos
</div>
);
}
export const isIssueChat = (cwd: string) => /\/_issues\/[^/]+$/.test(cwd);
interface ProposedIssue {
title: string;
description: string;
scope: string;
depends: string;
}
interface IssueProposal {
repo: string;
proposal: { spec?: string; issues: ProposedIssue[] } | null;
}
/** Bar above the composer of an issue chat: file the proposed issues on the forge. */
export function IssueBar({ sessionId }: { sessionId: string }) {
const t = useT();
const [open, setOpen] = useState(false);
return (
<>
<div className="draft-bar">
<Icon name="scroll" />
<span>{t("issues.hint")}</span>
<span className="spacer" />
<button className="small primary" onClick={() => setOpen(true)}>
<Icon name="check" /> {t("issues.create")}
</button>
</div>
{open && <CreateIssuesDialog sessionId={sessionId} onClose={() => setOpen(false)} />}
</>
);
}
function CreateIssuesDialog({ sessionId, onClose }: { sessionId: string; onClose: () => void }) {
const t = useT();
const [data, setData] = useState<IssueProposal>();
const [items, setItems] = useState<(ProposedIssue & { on: boolean })[]>([]);
const [spec, setSpec] = useState("");
const [start, setStart] = useState(false);
const [busy, setBusy] = useState(false);
useEffect(() => {
get<IssueProposal>(`/factory/issue-chats/${sessionId}`)
.then((d) => {
setData(d);
setSpec(d.proposal?.spec ?? "");
setItems((d.proposal?.issues ?? []).map((i) => ({ title: i.title ?? "", description: i.description ?? "", scope: i.scope ?? "", depends: i.depends ?? "", on: true })));
})
.catch((e) => {
toast(e.message);
onClose();
});
}, [sessionId]);
if (!data)
return (
<div className="modal-backdrop">
<div className="modal">
<Spinner />
</div>
</div>
);
const chosen = items.filter((i) => i.on && i.title.trim());
const set = (k: number, patch: Partial<ProposedIssue & { on: boolean }>) => setItems(items.map((x, j) => (j === k ? { ...x, ...patch } : x)));
const create = async () => {
setBusy(true);
try {
const r = await post<{ created: { number: number }[] }>(`/factory/issue-chats/${sessionId}/create`, {
spec,
start,
issues: chosen.map(({ on, ...i }) => i),
});
toast(t("issues.created", { n: r.created.length }), "success");
onClose();
navigate("/factory");
} 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("issues.create")} onClick={(e) => e.stopPropagation()}>
<h3>{t("issues.create")}</h3>
{!data.proposal ? (
<div className="notice err">{t("issues.noProposal")}</div>
) : (
<>
<label className="factory-form" style={{ display: "block" }}>
<span>{t("issues.spec")}</span>
<input className="mono" value={spec} onChange={(e) => setSpec(e.target.value)} />
</label>
<div className="issue-list">
{items.map((i, k) => (
<div key={k} className="issue-item">
<label className="row" style={{ gap: 8 }}>
<input type="checkbox" checked={i.on} onChange={(e) => set(k, { on: e.target.checked })} />
<input style={{ flex: 1 }} value={i.title} onChange={(e) => set(k, { title: e.target.value })} />
</label>
<div className="hint">{i.scope}</div>
{i.depends && i.depends.toLowerCase() !== "none" && <div className="hint">{t("issues.depends", { d: i.depends })}</div>}
<details>
<summary>{t("issues.description")}</summary>
<textarea rows={4} value={i.description} onChange={(e) => set(k, { description: e.target.value })} />
</details>
</div>
))}
</div>
<label className="row" style={{ gap: 8, marginTop: 8 }}>
<input type="checkbox" checked={start} onChange={(e) => setStart(e.target.checked)} />
<span>{t("issues.start")}</span>
</label>
<div className="hint">{t("issues.startHint")}</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={create} disabled={!data.proposal || chosen.length === 0 || !spec.trim() || busy}>
{busy ? <Spinner small /> : <Icon name="check" />} {t("issues.createGo", { n: chosen.length })}
</button>
</div>
</div>
</div>
);
}