Infer terminal PR state without SCM

This commit is contained in:
Ashish Huddar 2026-04-05 17:42:59 +05:30
parent 80d6e76bda
commit f12500545e
2 changed files with 6 additions and 4 deletions

View File

@ -59,9 +59,9 @@ describe("getDashboardPageData fast path", () => {
hoisted.listDashboardOrchestratorsMock.mockReturnValue([{ id: "orch-1", projectId: "docs", projectName: "Docs" }]);
});
it("runs fast enrichment, uses cache-only PR hydration, and infers merged state for terminal cache misses", async () => {
it("runs fast enrichment, uses cache-only PR hydration, and infers merged state for terminal cache misses even without SCM", async () => {
const noPrCore = { id: "session-no-pr", status: "working", pr: null };
const noScmCore = { id: "session-no-scm", status: "working", pr: { number: 2 } };
const noScmCore = { id: "session-no-scm", status: "merged", pr: { number: 2 } };
const mergedCore = { id: "session-merged", status: "merged", pr: { number: 3 } };
const allSessions = [noPrCore, noScmCore, mergedCore];
@ -100,6 +100,7 @@ describe("getDashboardPageData fast path", () => {
mergedCore.pr,
{ cacheOnly: true },
);
expect(dashboardNoScm.pr.state).toBe("merged");
expect(dashboardMerged.pr.state).toBe("merged");
expect(pageData.sessions).toEqual([dashboardNoPr, dashboardNoScm, dashboardMerged]);
});

View File

@ -75,8 +75,9 @@ export const getDashboardPageData = cache(async function getDashboardPageData(pr
if (!core.pr) continue;
const projectConfig = resolveProject(core, config.projects);
const scm = getSCM(registry, projectConfig);
if (!scm) continue;
await enrichSessionPR(pageData.sessions[i], scm, core.pr, { cacheOnly: true });
if (scm) {
await enrichSessionPR(pageData.sessions[i], scm, core.pr, { cacheOnly: true });
}
// For terminal sessions with cache-miss PRs, infer state from session status
// to avoid showing merged/closed PRs as "open" until client refresh