Fix blank factory page: hooks above early returns
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5ebdfee1a8
commit
af89b91e01
3 files changed
+29
-18
No files matched your search
@@ -3,6 +3,13 @@
|
||||
All notable changes to CodeCraft. Versions follow [Semantic Versioning](https://semver.org/);
|
||||
until 1.0, minor versions may contain breaking changes.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- The factory page showed a blank page since v202611-00047 (the new pull request panel declared its state
|
||||
after an early return, which breaks React's hook order). The hooks now sit above the early returns.
|
||||
|
||||
## [v202611-00047] – 2026-11-16
|
||||
|
||||
### Added
|
||||
|
||||
@@ -223,6 +223,24 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
||||
|
||||
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]);
|
||||
const selected = issues.find((i) => `${i.repo}#${i.number}` === sel);
|
||||
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]);
|
||||
if (!data) return <div className="empty"><Spinner /></div>;
|
||||
if (data.repos.length === 0)
|
||||
return (
|
||||
@@ -243,7 +261,6 @@ function FactoryOverview({ onSettings }: { onSettings: () => void }) {
|
||||
const done = issues.filter((i) => i.state === "done").length;
|
||||
const failed = issues.filter((i) => ["failed", "rejected"].includes(i.state)).length;
|
||||
const runsOf = (i: Issue) => data.runs.filter((r) => r.repo === i.repo && r.issue === i.number);
|
||||
const selected = issues.find((i) => `${i.repo}#${i.number}` === sel);
|
||||
const shown = selected ? runsOf(selected) : runs.slice(0, 12);
|
||||
|
||||
const poll = async () => {
|
||||
@@ -272,23 +289,6 @@ 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;
|
||||
|
||||
@@ -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: ["Fixed: the factory page was blank"],
|
||||
de: ["Behoben: die Factory-Seite blieb leer"],
|
||||
},
|
||||
"202611-00047": {
|
||||
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"],
|
||||
|
||||
Reference in new issue
Block a user