Factory: merge and close buttons on the issue card, enforced order

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Sonnet 5.5 committed 2026-11-20 13:23:52 +01:00
1 parent 0e54714436
commit 391db43949
10 files changed
+121 -16

No files matched your search

+46 -11
View File
@@ -78,6 +78,8 @@ interface Issue {
branch: string;
rounds: number;
/** Newest phase chat that still exists. */
/** The pull request is merged (merging comes after a positive acceptance, closing after the merge). */
merged?: boolean;
chat_session?: string;
chat_phase?: Phase;
created_at: number;
@@ -188,6 +190,20 @@ export function Factory({ onMenu, overlayId }: { onMenu: () => void; overlayId?:
);
}
/** A button inside an issue card (the card itself is a button, so this is a span with the button role). */
function CardAction({ children, onClick, title, primary, disabled }: { children: React.ReactNode; onClick: () => void; title?: string; primary?: boolean; disabled?: boolean }) {
const run = (e: React.SyntheticEvent) => {
e.stopPropagation();
e.preventDefault();
if (!disabled) onClick();
};
return (
<span role="button" tabIndex={disabled ? -1 : 0} aria-disabled={disabled} className={`factory-card-action ${primary ? "primary" : ""} ${disabled ? "disabled" : ""}`} title={title} onClick={run} onKeyDown={(e) => (e.key === "Enter" || e.key === " ") && run(e)}>
{children}
</span>
);
}
/** The factory's main switch, coloured by state: green = running, yellow = stopping, red = stopped. */
function PowerSwitch({ power, onToggle }: { power: Power; onToggle: (on: boolean) => void }) {
const t = useT();
@@ -402,20 +418,24 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
setBusy(false);
}
};
const mergePr = async () => {
if (!selected || !pr) return;
if (!(await confirmDialog({ message: t("factory.mergeConfirm", { n: pr.number, method: t(`factory.merge.${prMethod}` as any) }) }))) return;
const prNo = (i: Issue) => Number(i.pr_url.replace(/\/$/, "").split("/").pop()) || 0;
/** Merge the pull request of an issue; only offered once the acceptance has passed. */
const mergeIssue = async (i: Issue, n = prNo(i)) => {
if (!n || i.state !== "done") return;
if (!(await confirmDialog({ message: t("factory.mergeConfirm", { n, method: t(`factory.merge.${prMethod}` as any) }) }))) return;
setBusy(true);
try {
await post("/factory/issues/pr/merge", { repo: selected.repo, number: selected.number, pr: pr.number, method: prMethod });
await post("/factory/issues/pr/merge", { repo: i.repo, number: i.number, pr: n, method: prMethod });
toast(t("factory.merged"));
await loadPr();
await reload();
} catch (e: any) {
toast(e.message);
} finally {
setBusy(false);
}
};
const mergePr = () => (selected && pr ? mergeIssue(selected, pr.number) : Promise.resolve());
const removeIssue = async () => {
if (!selected) return;
if (!(await confirmDialog({ message: t("factory.removeConfirm", { n: selected.number }), confirmLabel: t("factory.remove"), danger: true }))) return;
@@ -430,15 +450,16 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
setBusy(false);
}
};
const closeIssue = async () => {
if (!selected) return;
const comment = await promptDialog({ title: t("factory.closeTitle"), message: t("factory.closeMsg", { n: selected.number }), defaultValue: t("factory.closeDefault"), confirmLabel: t("factory.close") });
/** Close an issue; only offered once its pull request is merged. */
const closeIssueOf = async (i: Issue) => {
if (i.state !== "done" || !i.merged) return;
const comment = await promptDialog({ title: t("factory.closeTitle"), message: t("factory.closeMsg", { n: i.number }), defaultValue: t("factory.closeDefault"), confirmLabel: t("factory.close") });
if (comment === null) return;
setBusy(true);
try {
await post("/factory/issues/close", { repo: selected.repo, number: selected.number, comment });
await post("/factory/issues/close", { repo: i.repo, number: i.number, comment });
toast(t("factory.closed"), "success");
setSel("");
if (selected && selected.number === i.number && selected.repo === i.repo) setSel("");
await reload();
} catch (e: any) {
toast(e.message);
@@ -446,6 +467,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
setBusy(false);
}
};
const closeIssue = () => (selected ? closeIssueOf(selected) : Promise.resolve());
const phaseRunning = !!selected && ["review", "building", "testing"].includes(selected.state);
/** Master switch: a soft stop – no new agent starts, running ones finish their phase. */
const setPower = async (on: boolean) => {
@@ -623,6 +645,19 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
</span>
)}
{tokens > 0 && <span className="hint">{fmtCompact(tokens)} {t("factory.tokens")}</span>}
{i.state === "done" && (i.merged || prNo(i) > 0) && (
<span className="factory-card-actions">
{!i.merged ? (
<CardAction primary disabled={busy} title={t("factory.mergeHint")} onClick={() => void mergeIssue(i)}>
<Icon name="fork" /> {t("factory.mergeBtn")}
</CardAction>
) : (
<CardAction disabled={busy} title={t("factory.closeHint")} onClick={() => void closeIssueOf(i)}>
<Icon name="check" /> {t("factory.close")}
</CardAction>
)}
</span>
)}
</button>
);
})}
@@ -658,7 +693,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
<Icon name="trash" /> {t("factory.remove")}
</button>
)}
{selected && selected.state === "done" && (
{selected && selected.state === "done" && selected.merged && (
<button className="small" onClick={closeIssue} disabled={busy}>
<Icon name="check" /> {t("factory.close")}
</button>
@@ -691,7 +726,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
</span>
)}
<span className="spacer" />
{pr.state === "open" && (
{pr.state === "open" && selected?.state === "done" && (
<>
<select value={prMethod} onChange={(e) => setPrMethod(e.target.value)} disabled={busy}>
{["merge", "squash", "rebase"].map((m) => (
+2
View File
@@ -1246,6 +1246,8 @@ export const de: Messages = {
"factory.preparing.env": "Testumgebung wird vorbereitet",
"factory.preparing.start": "Lauf wird vorbereitet",
"factory.preparing.hint": "Der Agent-Chat startet, sobald der Checkout fertig ist und – bei der Abnahme – die App in ihrem Wegwerf-Container installiert ist und läuft",
"factory.mergeHint": "Pull Request mergen – die Abnahme war erfolgreich",
"factory.closeHint": "Issue schließen – der Pull Request ist gemerged",
"factory.col.review": "Prüfung",
"factory.col.question": "Rückfragen",
"factory.col.approved": "Freigegeben",
+2
View File
@@ -1245,6 +1245,8 @@ export const en = {
"factory.preparing.env": "Preparing the test environment",
"factory.preparing.start": "Preparing the run",
"factory.preparing.hint": "The agent chat starts when the checkout is done and – for acceptance – the app is installed and running in its throw-away container",
"factory.mergeHint": "Merge the pull request – the acceptance has passed",
"factory.closeHint": "Close the issue – the pull request is merged",
"factory.col.review": "Review",
"factory.col.question": "Questions",
"factory.col.approved": "Approved",
+32
View File
@@ -5278,6 +5278,38 @@ td.fold-indent {
border: 0;
}
}
.factory-card-actions {
display: flex;
gap: 6px;
margin-top: 4px;
}
.factory-card-action {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 3px 9px;
font-size: 12.5px;
border-radius: 6px;
border: 1px solid var(--bg3);
background: var(--bg1);
color: var(--fg0);
cursor: pointer;
}
.factory-card-action:hover {
background: var(--bg2);
}
.factory-card-action.primary {
background: var(--accent);
border-color: var(--accent);
color: var(--on-accent, var(--bg0));
}
.factory-card-action.primary:hover {
filter: brightness(1.08);
}
.factory-card-action.disabled {
opacity: 0.5;
cursor: default;
}
.factory-card-head {
display: flex;
align-items: center;
+4
View File
@@ -3,6 +3,10 @@
* under "unreleased"; scripts/release.sh renames the key to the release version.
*/
export const WHATS_NEW: Record<string, { en: string[]; de: string[] }> = {
unreleased: {
en: ["Factory: Merge and Close buttons on the issue card – merge after a positive acceptance, close after the merge"],
de: ["Factory: Merge- und Schließen-Knopf auf der Issue-Karte – Merge nach erfolgreicher Abnahme, Schließen nach dem Merge"],
},
"202611-00073": {
en: ["Factory test runner: caches between acceptance runs (npm, Cargo, pip, Go and optional seeds of the install step) – the test environment starts much faster"],
de: ["Factory-Test-Runner: Caches zwischen Abnahmeläufen (npm, Cargo, pip, Go und optionale Seeds des Install-Schritts) – die Testumgebung startet deutlich schneller"],