Factory: backlog column with queue buttons, status-tinted issue cards
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
51a60ee75e
commit
25e4167f56
9 files changed
+318
-4
No files matched your search
@@ -79,6 +79,15 @@ interface Issue {
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
interface BacklogIssue {
|
||||
repo: string;
|
||||
number: number;
|
||||
title: string;
|
||||
author: string;
|
||||
url: string;
|
||||
allowed: boolean;
|
||||
labels: string[];
|
||||
}
|
||||
interface Run {
|
||||
id: string;
|
||||
repo: string;
|
||||
@@ -188,10 +197,21 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [recreate, setRecreate] = useState(false);
|
||||
|
||||
const reload = () =>
|
||||
get<Overview>("/factory/overview")
|
||||
const [backlog, setBacklog] = useState<BacklogIssue[]>([]);
|
||||
const [backlogErrors, setBacklogErrors] = useState<string[]>([]);
|
||||
const loadBacklog = (refresh = false) =>
|
||||
get<{ issues: BacklogIssue[]; errors: string[] }>(`/factory/backlog${refresh ? "?refresh=1" : ""}`)
|
||||
.then((r) => {
|
||||
setBacklog(r.issues);
|
||||
setBacklogErrors(r.errors);
|
||||
})
|
||||
.catch(() => {});
|
||||
const reload = () => {
|
||||
void loadBacklog();
|
||||
return get<Overview>("/factory/overview")
|
||||
.then(setData)
|
||||
.catch((e) => toast(e.message));
|
||||
};
|
||||
useEffect(() => {
|
||||
void reload();
|
||||
const h = setInterval(() => {
|
||||
@@ -263,6 +283,24 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
||||
};
|
||||
|
||||
const issues = useMemo(() => (data?.issues ?? []).filter((i) => !repo || i.repo === repo), [data, repo]);
|
||||
const backlogShown = useMemo(() => backlog.filter((i) => !repo || i.repo === repo), [backlog, repo]);
|
||||
/** Put backlog issues into the process (they get the factory label on the forge). */
|
||||
const enqueue = async (items: BacklogIssue[]) => {
|
||||
if (items.length === 0) return;
|
||||
if (items.length > 1 && !(await confirmDialog({ message: t("factory.backlog.allConfirm", { n: items.length }), confirmLabel: t("factory.backlog.queueAll") }))) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
for (const r of [...new Set(items.map((i) => i.repo))]) {
|
||||
const res = await post<{ queued: number[]; errors: { number: number; error: string }[] }>("/factory/backlog/enqueue", { repo: r, numbers: items.filter((i) => i.repo === r).map((i) => i.number) });
|
||||
for (const e of res.errors) toast(`#${e.number}: ${e.error}`);
|
||||
}
|
||||
} catch (e: any) {
|
||||
toast(e.message);
|
||||
}
|
||||
setBusy(false);
|
||||
await loadBacklog(true);
|
||||
await reload();
|
||||
};
|
||||
const runs = useMemo(() => (data?.runs ?? []).filter((r) => !repo || r.repo === repo), [data, repo]);
|
||||
const selected = issues.find((i) => `${i.repo}#${i.number}` === sel);
|
||||
const [pr, setPr] = useState<PrInfo | null>(null);
|
||||
@@ -462,6 +500,31 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
||||
</div>
|
||||
|
||||
<div className="factory-board">
|
||||
<div className="factory-col backlog">
|
||||
<h4>
|
||||
{t("factory.col.backlog")} <span className="chip">{backlogShown.length}</span>
|
||||
</h4>
|
||||
{backlogShown.length > 1 && (
|
||||
<button className="small" onClick={() => void enqueue(backlogShown.filter((i) => i.allowed))} disabled={busy || !backlogShown.some((i) => i.allowed)} title={t("factory.backlog.queueAllHint")}>
|
||||
<Icon name="plus" /> {t("factory.backlog.queueAll")}
|
||||
</button>
|
||||
)}
|
||||
{backlogShown.map((i) => (
|
||||
<div key={`${i.repo}#${i.number}`} className="factory-card backlog">
|
||||
<span className="hint">
|
||||
{repoName(i.repo)} #{i.number} · {i.author}
|
||||
</span>
|
||||
<a href={i.url || issueUrl(i.repo, i.number)} target="_blank" rel="noreferrer">
|
||||
<b>{i.title || `#${i.number}`}</b>
|
||||
</a>
|
||||
<button className="small" onClick={() => void enqueue([i])} disabled={busy || !i.allowed} title={i.allowed ? t("factory.backlog.queueHint") : t("factory.backlog.notAllowed", { user: i.author })}>
|
||||
<Icon name="plus" /> {t("factory.backlog.queue")}
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
{backlogShown.length === 0 && <span className="hint">{t("factory.backlog.empty")}</span>}
|
||||
{backlogErrors.length > 0 && <span className="hint" title={backlogErrors.join("\n")}>{t("factory.backlog.error")}</span>}
|
||||
</div>
|
||||
{COLUMNS.map((c) => {
|
||||
const cards = issues.filter((i) => c.states.includes(i.state));
|
||||
return (
|
||||
@@ -475,7 +538,7 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
||||
const latest = active ?? rs[0];
|
||||
const tokens = rs.reduce((a, r) => a + r.input_tokens + r.output_tokens, 0);
|
||||
return (
|
||||
<button key={`${i.repo}#${i.number}`} className={`factory-card ${sel === `${i.repo}#${i.number}` ? "active" : ""} ${active ? "running" : ""}`} onClick={() => setSel(sel === `${i.repo}#${i.number}` ? "" : `${i.repo}#${i.number}`)}>
|
||||
<button key={`${i.repo}#${i.number}`} data-state={i.state} className={`factory-card ${sel === `${i.repo}#${i.number}` ? "active" : ""} ${active ? "running" : ""}`} onClick={() => setSel(sel === `${i.repo}#${i.number}` ? "" : `${i.repo}#${i.number}`)}>
|
||||
<span className="hint">
|
||||
{repoName(i.repo)} #{i.number}
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user