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

+2 -1
View File
@@ -1,4 +1,4 @@
import { DraftBar, isDraftChat } from "./FactoryDraft";
import { DraftBar, IssueBar, isDraftChat, isIssueChat } from "./FactoryDraft";
import { takePrefill } from "../share";
import { Icon } from "./Icon";
import { FileChip, FileFigure, fileType, imageSize, imageSrc } from "./FileFigure";
@@ -1091,6 +1091,7 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
{sharing && <ShareDialog sessionId={sessionId} onClose={() => setSharing(false)} />}
{rewinding && <RewindDialog sessionId={sessionId} messageId={rewinding.id} onDone={rewindDone} onClose={() => setRewinding(undefined)} />}
{!readOnly && isDraftChat(session.cwd) && <DraftBar sessionId={sessionId} />}
{!readOnly && isIssueChat(session.cwd) && <IssueBar sessionId={sessionId} />}
{!readOnly && <OutboxBar sessionId={sessionId} />}
{!readOnly && <QueueList sessionId={sessionId} busy={busy} />}
{readOnly ? (
+109 -1
View File
@@ -2,11 +2,23 @@ import { useEffect, useMemo, useState } from "react";
import { get, post, put } from "../api";
import { fmtCompact, fmtCost, fmtRelative, useT } from "../i18n";
import { navigate } from "../router";
import { confirmDialog, toast } from "../dialogs";
import { choiceDialog, confirmDialog, promptDialog, toast } from "../dialogs";
import { Icon } from "./Icon";
import { Spinner } from "./Activity";
import { ModelSelect } from "./ModelSelect";
interface PrInfo {
number: number;
html_url: string;
title: string;
state: "open" | "merged" | "closed";
mergeable: boolean | null;
changed_files: number | null;
additions: number | null;
deletions: number | null;
head: string;
}
type Phase = "review" | "build" | "qa";
const PHASES: Phase[] = ["review", "build", "qa"];
@@ -180,6 +192,35 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
}
};
/** Start a chat that works out a feature or cuts a milestone into issues. */
const issueChat = async (mode: "feature" | "slice") => {
if (!data) return;
let target = repo;
if (!target) {
const repos = data.repos.filter((r) => r.enabled);
if (repos.length === 1) target = repos[0].url;
else {
const pick = await choiceDialog({ message: t("issues.pickRepo"), choices: repos.map((r) => ({ value: r.url, label: repoName(r.url) })) });
if (!pick) return;
target = pick;
}
}
let topic = "";
if (mode === "slice") {
const name = await promptDialog({ message: t("issues.sliceWhich"), placeholder: "M2", confirmLabel: t("issues.sliceGo") });
if (!name?.trim()) return;
topic = name.trim();
}
setBusy(true);
try {
const s = await post<{ id: string }>("/factory/issue-chats", { repo: target, mode, topic });
navigate(`/s/${s.id}`);
} catch (e: any) {
toast(e.message);
setBusy(false);
}
};
const issues = useMemo(() => (data?.issues ?? []).filter((i) => !repo || i.repo === repo), [data, repo]);
const runs = useMemo(() => (data?.runs ?? []).filter((r) => !repo || r.repo === repo), [data, repo]);
if (!data) return <div className="empty"><Spinner /></div>;
@@ -231,6 +272,37 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
setBusy(false);
}
};
const [pr, setPr] = useState<PrInfo | null>(null);
const [prMethod, setPrMethod] = useState("merge");
const selKey = selected ? `${selected.repo}#${selected.number}` : "";
const loadPr = async () => {
if (!selected || (!selected.branch && !selected.pr_url)) return setPr(null);
try {
const r = await get<{ pr: PrInfo | null }>(`/factory/issues/pr?repo=${encodeURIComponent(selected.repo)}&number=${selected.number}`);
setPr(r.pr);
} catch {
setPr(null);
}
};
useEffect(() => {
setPr(null);
void loadPr();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selKey, selected?.state]);
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;
setBusy(true);
try {
await post("/factory/issues/pr/merge", { repo: selected.repo, number: selected.number, pr: pr.number, method: prMethod });
toast(t("factory.merged"));
await loadPr();
} catch (e: any) {
toast(e.message);
} finally {
setBusy(false);
}
};
const phaseRunning = !!selected && ["review", "building", "testing"].includes(selected.state);
return (
@@ -289,6 +361,12 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
<button className="small primary" onClick={newProject} disabled={busy}>
<Icon name="plus" /> {t("factory.newProject")}
</button>
<button className="small" onClick={() => issueChat("feature")} disabled={busy} title={t("issues.featureHint")}>
<Icon name="sparkle" /> {t("issues.feature")}
</button>
<button className="small" onClick={() => issueChat("slice")} disabled={busy} title={t("issues.sliceHint")}>
<Icon name="sparkle" /> {t("issues.slice")}
</button>
<button className="small" onClick={poll} disabled={busy} title={t("factory.pollNow")}>
<Icon name="refresh" /> {t("factory.pollNow")}
</button>
@@ -360,6 +438,36 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
)}
</div>
{selected?.note && <div className="hint" style={{ margin: "6px 0" }}>{selected.note}</div>}
{pr && (
<div className="factory-pr">
<a href={pr.html_url} target="_blank" rel="noreferrer">
<Icon name="external" /> #{pr.number} {pr.title}
</a>
<span className={`chip ${pr.state === "merged" ? "ok" : pr.state === "open" ? "" : "warn"}`}>{t(`factory.pr.${pr.state}` as any)}</span>
{pr.state === "open" && pr.mergeable === false && <span className="chip warn">{t("factory.pr.conflict")}</span>}
{pr.changed_files != null && (
<span className="hint">
{t("factory.pr.files", { n: pr.changed_files })}
{pr.additions != null && ` · +${pr.additions} −${pr.deletions ?? 0}`}
</span>
)}
<span className="spacer" />
{pr.state === "open" && (
<>
<select value={prMethod} onChange={(e) => setPrMethod(e.target.value)} disabled={busy}>
{["merge", "squash", "rebase"].map((m) => (
<option key={m} value={m}>
{t(`factory.merge.${m}` as any)}
</option>
))}
</select>
<button className="small primary" onClick={mergePr} disabled={busy || pr.mergeable === false}>
{t("factory.mergeBtn")}
</button>
</>
)}
</div>
)}
{shown.length === 0 && <div className="hint">{t("factory.noRuns")}</div>}
{shown.length > 0 && (
<div className="table-wrap">
+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>
);
}
+28
View File
@@ -1213,6 +1213,34 @@ export const de: Messages = {
"factory.cost": "Kosten",
"factory.restartAt": "Neu starten bei:",
"factory.restarted": "Issue ist wieder im Ablauf",
"factory.mergeBtn": "Freigeben und mergen",
"factory.mergeConfirm": "Pull Request #{n} mergen ({method})? Die Factory merged nie selbst – das ist deine Freigabe.",
"factory.merged": "Pull Request gemergt",
"factory.merge.merge": "Merge-Commit",
"factory.merge.squash": "Squash",
"factory.merge.rebase": "Rebase",
"factory.pr.open": "offen",
"factory.pr.merged": "gemergt",
"factory.pr.closed": "geschlossen",
"factory.pr.conflict": "Konflikt mit dem Zielbranch",
"factory.pr.files": "{n} Dateien",
"issues.hint": "Wenn der Plan steht, die Issues im Repository anlegen.",
"issues.create": "Issues anlegen",
"issues.createGo": "{n} Issues anlegen",
"issues.created": "{n} Issues angelegt",
"issues.noProposal": "Das Modell hat noch keine Issue-Liste vorgeschlagen. Sag ihm, dass der Plan fertig ist; es schließt dann mit der Liste ab.",
"issues.spec": "Spec-Datei im Repository",
"issues.depends": "Voraussetzung: {d}",
"issues.description": "Beschreibung",
"issues.start": "Sofort starten (Label factory setzen)",
"issues.startHint": "Standardmäßig aus: die Issues werden nur angelegt, das Label setzt du selbst nacheinander – spätere bauen auf den gemergten früheren auf.",
"issues.pickRepo": "Für welches Repository?",
"issues.sliceWhich": "Welcher Meilenstein soll in Deliverables zerlegt werden?",
"issues.sliceGo": "Starten",
"issues.feature": "Feature planen",
"issues.featureHint": "Ein neues Feature mit einem Modell ausarbeiten und daraus Issues anlegen",
"issues.slice": "Meilenstein zerlegen",
"issues.sliceHint": "Ein Modell zerlegt einen Meilenstein in nummerierte Deliverables und legt die Issues an",
"factory.pr": "Pull Request",
"factory.round": "Runde {n}",
"factory.openChat": "Chat öffnen",
+28
View File
@@ -1212,6 +1212,34 @@ export const en = {
"factory.cost": "Cost",
"factory.restartAt": "Restart at:",
"factory.restarted": "Issue is back in the flow",
"factory.mergeBtn": "Approve and merge",
"factory.mergeConfirm": "Merge pull request #{n} ({method})? The factory itself never merges – this is your approval.",
"factory.merged": "Pull request merged",
"factory.merge.merge": "Merge commit",
"factory.merge.squash": "Squash",
"factory.merge.rebase": "Rebase",
"factory.pr.open": "open",
"factory.pr.merged": "merged",
"factory.pr.closed": "closed",
"factory.pr.conflict": "conflicts with the target branch",
"factory.pr.files": "{n} files",
"issues.hint": "When the plan is done, file the issues on the forge.",
"issues.create": "Create issues",
"issues.createGo": "Create {n} issues",
"issues.created": "{n} issues created",
"issues.noProposal": "The model has not proposed an issue list yet. Tell it that the plan is done; it ends with the list.",
"issues.spec": "Spec file in the repository",
"issues.depends": "Needs first: {d}",
"issues.description": "Description",
"issues.start": "Start right away (set the factory label)",
"issues.startHint": "Off by default: the issues are only created and you set the label yourself, one after the other – later ones build on the merged earlier ones.",
"issues.pickRepo": "For which repository?",
"issues.sliceWhich": "Which milestone should be cut into deliverables?",
"issues.sliceGo": "Start",
"issues.feature": "Plan a feature",
"issues.featureHint": "Work out a new feature with a model and create issues from it",
"issues.slice": "Cut a milestone",
"issues.sliceHint": "Let a model cut a milestone into numbered deliverables and create the issues",
"factory.pr": "Pull request",
"factory.round": "round {n}",
"factory.openChat": "Open chat",
+25
View File
@@ -5170,3 +5170,28 @@ td.fold-indent {
padding: 8px;
font-size: 12px;
}
.factory-pr {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
padding: 8px 0 12px;
}
.issue-list {
display: flex;
flex-direction: column;
gap: 8px;
max-height: 46vh;
overflow: auto;
margin-top: 8px;
}
.issue-item {
border: 1px solid var(--border);
border-radius: 8px;
padding: 8px;
}
.issue-item textarea {
width: 100%;
}
+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: see an issue's pull request and approve/merge it right in the factory page", "Factory: plan a feature with a model or cut a milestone into numbered deliverables – the issues are created for you"],
de: ["Factory: Pull Request eines Issues ansehen und direkt in der Factory freigeben/mergen", "Factory: Feature mit einem Modell planen oder einen Meilenstein in nummerierte Deliverables zerlegen – die Issues werden für dich angelegt"],
},
"202611-00044": {
en: ["Factory: the pull request is now opened by the acceptance, after it passed", "Factory has its own icon and all its chats sit in one sidebar folder", "Factory acceptance only judges the scenarios in the issue's scope"],
de: ["Factory: den Pull Request erstellt jetzt die Abnahme, nachdem sie bestanden ist", "Die Factory hat ein eigenes Icon, alle ihre Chats liegen in einem Ordner in der Seitenleiste", "Die Factory-Abnahme beurteilt nur die Szenarien im Umfang des Issues"],