From 3f937c8446f94ab356535fe649441aed6244f432 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 3 Jul 2026 20:53:26 +0000 Subject: [PATCH] fix: compact branch follower list status --- scripts/src/cicd-branch-follower.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/src/cicd-branch-follower.ts b/scripts/src/cicd-branch-follower.ts index a7be0727..81856a95 100644 --- a/scripts/src/cicd-branch-follower.ts +++ b/scripts/src/cicd-branch-follower.ts @@ -572,10 +572,11 @@ async function buildStatus(registry: BranchFollowerRegistry, options: ParsedOpti const shouldLive = wantsLive && options.inCluster; const selected = selectFollowers(registry, options, { includeDisabled: true }); const followers = []; + const detailedFollowers = options.followerId !== null || options.full; for (const follower of selected) { const stored = k8s.stateByFollower[follower.id] ?? {}; const live = shouldLive && follower.enabled ? await readAdapterStatus(registry, follower, options) : null; - followers.push(mergeFollowerStatus(registry, follower, stored, live, shouldLive)); + followers.push(mergeFollowerStatus(registry, follower, stored, live, shouldLive, detailedFollowers)); } return { ok: k8s.ok && followers.every((item) => item.ok !== false), @@ -1808,6 +1809,7 @@ function mergeFollowerStatus( stored: Record, live: AdapterSummary | null, liveRequested: boolean, + detailed: boolean, ): Record { const storedSource = asOptionalRecord(stored.source); const storedTarget = asOptionalRecord(stored.target); @@ -1816,7 +1818,7 @@ function mergeFollowerStatus( const targetSha = live?.targetSha ?? stringOrNull(storedTarget?.targetSha); const lastTriggeredSha = live?.lastTriggeredSha ?? stringOrNull(stored.lastTriggeredSha); const lastSucceededSha = live?.lastSucceededSha ?? stringOrNull(stored.lastSucceededSha); - return { + const summary: Record = { ok: live === null ? true : live.ok, id: follower.id, enabled: follower.enabled, @@ -1826,7 +1828,6 @@ function mergeFollowerStatus( repository: follower.source.repository, branch: follower.source.branch, observedSha, - snapshotPrefix: follower.source.snapshotPrefix, }, target: { node: follower.target.node, @@ -1839,12 +1840,21 @@ function mergeFollowerStatus( lastSucceededSha, pipelineRun: live?.pipelineRun ?? stringOrNull(stored.pipelineRun), inFlightJob: live?.inFlightJob ?? stringOrNull(stored.inFlightJob), - budgetSource: follower.budgets, updatedAt: stringOrNull(stored.updatedAt), - stateConfigMap: registry.controller.stateConfigMapName, live: liveRequested, message: live?.message ?? stringOrNull(stored.decision) ?? "no controller state yet", timings: live === null ? storedFollowerTimingsForStatus(follower, asOptionalRecord(stored.timings), phase, observedSha) : buildFollowerTimings(follower, live, undefined, asOptionalRecord(stored.timings), phase), + drilldown: `bun scripts/cli.ts cicd branch-follower status --follower ${follower.id} --live`, + }; + if (!detailed) return summary; + return { + ...summary, + source: { + ...asOptionalRecord(summary.source), + snapshotPrefix: follower.source.snapshotPrefix, + }, + budgetSource: follower.budgets, + stateConfigMap: registry.controller.stateConfigMapName, warnings: Array.isArray(stored.warnings) ? stored.warnings.slice(0, 6) : [], next: followerNextCommands(follower), };