@oss-autopilot/core 3.42.5 → 3.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-pre-action.js +8 -3
- package/dist/cli-registry.js +428 -27
- package/dist/cli.bundle.cjs +212 -156
- package/dist/commands/check-integration.js +5 -1
- package/dist/commands/cleanup.d.ts +80 -0
- package/dist/commands/cleanup.js +334 -0
- package/dist/commands/comments.d.ts +14 -1
- package/dist/commands/comments.js +17 -5
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.js +63 -6
- package/dist/commands/daily-dismiss-filter.d.ts +7 -0
- package/dist/commands/daily-dismiss-filter.js +17 -1
- package/dist/commands/daily-ledger.d.ts +150 -0
- package/dist/commands/daily-ledger.js +248 -0
- package/dist/commands/daily-recent-prs.d.ts +26 -0
- package/dist/commands/daily-recent-prs.js +55 -0
- package/dist/commands/daily-render.d.ts +2 -1
- package/dist/commands/daily-render.js +4 -1
- package/dist/commands/daily.d.ts +5 -1
- package/dist/commands/daily.js +83 -93
- package/dist/commands/dashboard-cache.d.ts +2 -0
- package/dist/commands/dashboard-cache.js +33 -8
- package/dist/commands/dashboard-data.js +113 -69
- package/dist/commands/dashboard-gist-sync.js +3 -1
- package/dist/commands/dashboard-lifecycle.d.ts +36 -8
- package/dist/commands/dashboard-lifecycle.js +132 -39
- package/dist/commands/dashboard-process.d.ts +49 -1
- package/dist/commands/dashboard-process.js +111 -12
- package/dist/commands/dashboard-server.js +89 -23
- package/dist/commands/detect-formatters.js +1 -0
- package/dist/commands/dismiss.js +11 -7
- package/dist/commands/doctor.d.ts +15 -1
- package/dist/commands/doctor.js +66 -5
- package/dist/commands/draft.d.ts +77 -0
- package/dist/commands/draft.js +218 -0
- package/dist/commands/eval.js +1 -0
- package/dist/commands/fork-prune.d.ts +58 -0
- package/dist/commands/fork-prune.js +247 -0
- package/dist/commands/guidelines.d.ts +69 -2
- package/dist/commands/guidelines.js +158 -14
- package/dist/commands/index.d.ts +29 -4
- package/dist/commands/index.js +20 -3
- package/dist/commands/issue-thread.d.ts +46 -0
- package/dist/commands/issue-thread.js +123 -0
- package/dist/commands/ledger-backfill.d.ts +9 -0
- package/dist/commands/ledger-backfill.js +44 -1
- package/dist/commands/list-mark-done.d.ts +2 -1
- package/dist/commands/list-mark-done.js +3 -1
- package/dist/commands/list-move-tier.d.ts +2 -1
- package/dist/commands/list-move-tier.js +3 -1
- package/dist/commands/local-repos.js +10 -5
- package/dist/commands/locate-issue-list.d.ts +40 -17
- package/dist/commands/locate-issue-list.js +148 -88
- package/dist/commands/move.js +7 -1
- package/dist/commands/overnight-handoff.d.ts +17 -7
- package/dist/commands/overnight-handoff.js +36 -14
- package/dist/commands/overnight-push-prep.d.ts +14 -8
- package/dist/commands/overnight-push-prep.js +107 -35
- package/dist/commands/overnight-tool-rules.d.ts +54 -0
- package/dist/commands/overnight-tool-rules.js +217 -0
- package/dist/commands/overnight.d.ts +5 -6
- package/dist/commands/overnight.js +61 -140
- package/dist/commands/parse-list.js +7 -1
- package/dist/commands/policy.d.ts +90 -0
- package/dist/commands/policy.js +276 -0
- package/dist/commands/pr-create.d.ts +48 -0
- package/dist/commands/pr-create.js +200 -0
- package/dist/commands/pr-preflight.d.ts +69 -0
- package/dist/commands/pr-preflight.js +348 -0
- package/dist/commands/repo-vet.d.ts +9 -0
- package/dist/commands/repo-vet.js +36 -11
- package/dist/commands/scout-bridge.js +18 -8
- package/dist/commands/search.js +7 -0
- package/dist/commands/setup.d.ts +3 -3
- package/dist/commands/setup.js +160 -48
- package/dist/commands/skip-add.js +10 -1
- package/dist/commands/startup.d.ts +12 -3
- package/dist/commands/startup.js +82 -49
- package/dist/commands/state-cmd.d.ts +2 -0
- package/dist/commands/state-cmd.js +5 -1
- package/dist/commands/stats.js +1 -0
- package/dist/commands/status.js +6 -0
- package/dist/commands/strategy.js +1 -0
- package/dist/commands/validation.d.ts +5 -0
- package/dist/commands/validation.js +5 -0
- package/dist/commands/vet-list.d.ts +6 -0
- package/dist/commands/vet-list.js +26 -1
- package/dist/commands/vet.d.ts +20 -0
- package/dist/commands/vet.js +133 -2
- package/dist/commands/work.d.ts +4 -0
- package/dist/commands/work.js +34 -11
- package/dist/core/__fixtures__/prompt-injection-payloads.js +31 -0
- package/dist/core/anti-llm-policy.d.ts +3 -0
- package/dist/core/anti-llm-policy.js +3 -0
- package/dist/core/auth.js +2 -0
- package/dist/core/ci-analysis.d.ts +7 -2
- package/dist/core/ci-analysis.js +76 -21
- package/dist/core/commit-date.d.ts +45 -0
- package/dist/core/commit-date.js +45 -0
- package/dist/core/compliance-score.d.ts +3 -0
- package/dist/core/compliance-score.js +13 -9
- package/dist/core/config-registry.d.ts +27 -2
- package/dist/core/config-registry.js +94 -7
- package/dist/core/contributing.d.ts +2 -3
- package/dist/core/contributing.js +2 -3
- package/dist/core/daily-logic.d.ts +30 -5
- package/dist/core/daily-logic.js +68 -19
- package/dist/core/errors.d.ts +37 -3
- package/dist/core/errors.js +54 -5
- package/dist/core/fork-prune.d.ts +149 -0
- package/dist/core/fork-prune.js +333 -0
- package/dist/core/gist-health.d.ts +15 -3
- package/dist/core/gist-health.js +8 -0
- package/dist/core/gist-state-store.d.ts +24 -4
- package/dist/core/gist-state-store.js +98 -51
- package/dist/core/github-stats.d.ts +110 -16
- package/dist/core/github-stats.js +295 -110
- package/dist/core/http-cache.d.ts +0 -10
- package/dist/core/http-cache.js +0 -19
- package/dist/core/index.d.ts +13 -6
- package/dist/core/index.js +16 -6
- package/dist/core/issue-conversation.d.ts +8 -2
- package/dist/core/issue-conversation.js +31 -12
- package/dist/core/local-config.d.ts +95 -0
- package/dist/core/local-config.js +270 -0
- package/dist/core/merged-pr-notes.d.ts +2 -2
- package/dist/core/pacing.d.ts +41 -0
- package/dist/core/pacing.js +115 -0
- package/dist/core/pagination.d.ts +55 -0
- package/dist/core/pagination.js +59 -0
- package/dist/core/paths.d.ts +7 -0
- package/dist/core/paths.js +9 -0
- package/dist/core/pr-assembly.d.ts +2 -0
- package/dist/core/pr-assembly.js +6 -2
- package/dist/core/pr-graphql.d.ts +53 -4
- package/dist/core/pr-graphql.js +87 -14
- package/dist/core/pr-monitor.d.ts +35 -12
- package/dist/core/pr-monitor.js +110 -26
- package/dist/core/pr-preflight.d.ts +154 -0
- package/dist/core/pr-preflight.js +753 -0
- package/dist/core/pr-quality-rubric.d.ts +0 -6
- package/dist/core/pr-quality-rubric.js +0 -8
- package/dist/core/pr-template.d.ts +2 -0
- package/dist/core/pr-template.js +5 -1
- package/dist/core/prose-script.d.ts +72 -0
- package/dist/core/prose-script.js +223 -0
- package/dist/core/repo-policy.d.ts +111 -0
- package/dist/core/repo-policy.js +428 -0
- package/dist/core/repo-score-manager.d.ts +66 -0
- package/dist/core/repo-score-manager.js +140 -1
- package/dist/core/review-analysis.d.ts +49 -21
- package/dist/core/review-analysis.js +89 -15
- package/dist/core/reviewed-prs-fetch.js +11 -29
- package/dist/core/reviewed-prs.js +8 -15
- package/dist/core/stale-data.d.ts +78 -0
- package/dist/core/stale-data.js +153 -0
- package/dist/core/state-persistence.d.ts +62 -27
- package/dist/core/state-persistence.js +338 -119
- package/dist/core/state-schema.d.ts +152 -210
- package/dist/core/state-schema.js +232 -80
- package/dist/core/state.d.ts +81 -8
- package/dist/core/state.js +239 -46
- package/dist/core/status-determination.js +32 -12
- package/dist/core/strategy.js +3 -1
- package/dist/core/types.d.ts +22 -1
- package/dist/core/types.js +1 -0
- package/dist/core/untrusted-content.d.ts +30 -11
- package/dist/core/untrusted-content.js +95 -42
- package/dist/core/urls.d.ts +33 -0
- package/dist/core/urls.js +94 -0
- package/dist/dashboard/assets/chart-panel-B-nLVgzQ.js +3 -0
- package/dist/dashboard/assets/index-5IvMGokL.js +55 -0
- package/dist/dashboard/index.html +1 -1
- package/dist/formatters/json.d.ts +432 -10
- package/dist/formatters/json.js +156 -1
- package/package.json +6 -6
- package/dist/core/ci-enforced-tools.d.ts +0 -35
- package/dist/core/ci-enforced-tools.js +0 -109
- package/dist/core/comment-decision.d.ts +0 -79
- package/dist/core/comment-decision.js +0 -82
- package/dist/core/extraction-categories.d.ts +0 -55
- package/dist/core/extraction-categories.js +0 -108
- package/dist/core/follow-up-history.d.ts +0 -40
- package/dist/core/follow-up-history.js +0 -71
- package/dist/core/issue-effort.d.ts +0 -29
- package/dist/core/issue-effort.js +0 -47
- package/dist/core/maintainer-hints.d.ts +0 -23
- package/dist/core/maintainer-hints.js +0 -36
- package/dist/core/workflow-state.d.ts +0 -56
- package/dist/core/workflow-state.js +0 -101
- package/dist/dashboard/assets/chart-panel-DPKNBUts.js +0 -3
- package/dist/dashboard/assets/index-B25bZOYX.js +0 -55
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* Handles GitHub API calls, PR grouping, stats computation, and monthly chart data.
|
|
4
4
|
* Consumed by the dashboard HTTP server (dashboard-server.ts) for the SPA API.
|
|
5
5
|
*/
|
|
6
|
-
import { getStateManager, PRMonitor, IssueConversationMonitor, getOctokit, CRITICAL_STATUSES, applyStatusOverrides, collectEngagedIssues, toShelvedPRRef, buildStarFilter,
|
|
6
|
+
import { getStateManager, PRMonitor, IssueConversationMonitor, getOctokit, CRITICAL_STATUSES, shouldAutoUnshelve, applyStatusOverrides, collectEngagedIssues, toShelvedPRRef, buildStarFilter, } from '../core/index.js';
|
|
7
7
|
import { errorMessage, isRateLimitOrAuthError } from '../core/errors.js';
|
|
8
8
|
import { warn } from '../core/logger.js';
|
|
9
|
-
import { emptyPRCountsResult,
|
|
10
|
-
import { parseGitHubUrl } from '../core/urls.js';
|
|
9
|
+
import { emptyPRCountsResult, CLOSED_LEDGER_TRUNCATED_MESSAGE, MERGED_LEDGER_TRUNCATED_MESSAGE, } from '../core/github-stats.js';
|
|
10
|
+
import { parseGitHubUrl, issueRefKey } from '../core/urls.js';
|
|
11
11
|
import { isBelowMinStars, } from '../core/types.js';
|
|
12
|
+
import { evictNeverTrackedRepos, fetchClosedLedgerGap, fetchMergedLedgerGap, storeClosedLedger, storeMergedLedger, syncLedgersWithGitHub, } from './daily-ledger.js';
|
|
12
13
|
const MODULE = 'dashboard-data';
|
|
13
14
|
export function buildDashboardStats(digest, state, storedMergedCount, storedClosedCount) {
|
|
14
15
|
const summary = digest.summary || {
|
|
@@ -39,15 +40,18 @@ export function buildDashboardStats(digest, state, storedMergedCount, storedClos
|
|
|
39
40
|
* dormant-auto-shelve rule applies (dormant + not needing attention). Mirrors
|
|
40
41
|
* the partition built in fetchDashboardData (see the `freshShelved` filter).
|
|
41
42
|
*
|
|
42
|
-
* #1352: an explicitly shelved PR
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* headline count until the
|
|
43
|
+
* #1352: an explicitly shelved PR the daily check would auto-unshelve
|
|
44
|
+
* (`shouldAutoUnshelve`: it needs addressing and a maintainer acted after the
|
|
45
|
+
* shelve or the action reason is new, #1922) is NOT shelved for display, so the dashboard agrees
|
|
46
|
+
* immediately rather than diverging from the CLI's headline count until the
|
|
47
|
+
* next daily run.
|
|
46
48
|
*/
|
|
47
|
-
function isShelvedForDisplay(pr,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
function isShelvedForDisplay(pr, config) {
|
|
50
|
+
const key = issueRefKey(pr.url);
|
|
51
|
+
const isExplicit = (config.shelvedPRUrls || []).some((url) => (key ? issueRefKey(url) === key : url === pr.url));
|
|
52
|
+
if (isExplicit)
|
|
53
|
+
return !shouldAutoUnshelve(pr, config.shelvedPRInfo);
|
|
54
|
+
return pr.stalenessTier === 'dormant' && !CRITICAL_STATUSES.has(pr.status);
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
53
57
|
* Re-derive `digest.shelvedPRs` and `summary.totalActivePRs` from the CURRENT
|
|
@@ -68,17 +72,16 @@ function isShelvedForDisplay(pr, explicitlyShelved) {
|
|
|
68
72
|
export function reconcileShelvePartition(digest, state) {
|
|
69
73
|
const openPRs = (digest.openPRs || []);
|
|
70
74
|
const openByUrl = new Map(openPRs.map((pr) => [pr.url, pr]));
|
|
71
|
-
const explicitlyShelved = new Set(state.config.shelvedPRUrls || []);
|
|
72
75
|
// Keep baked entries that are either off the open-PR list (daily dormant
|
|
73
76
|
// partition we can't recompute here) or still shelved under current state.
|
|
74
77
|
const reconciled = (digest.shelvedPRs || []).filter((ref) => {
|
|
75
78
|
const pr = openByUrl.get(ref.url);
|
|
76
|
-
return !pr || isShelvedForDisplay(pr,
|
|
79
|
+
return !pr || isShelvedForDisplay(pr, state.config);
|
|
77
80
|
});
|
|
78
81
|
// Add open PRs that became shelved but aren't represented in the baked list yet.
|
|
79
82
|
const present = new Set(reconciled.map((ref) => ref.url));
|
|
80
83
|
for (const pr of openPRs) {
|
|
81
|
-
if (!present.has(pr.url) && isShelvedForDisplay(pr,
|
|
84
|
+
if (!present.has(pr.url) && isShelvedForDisplay(pr, state.config)) {
|
|
82
85
|
reconciled.push(toShelvedPRRef(pr));
|
|
83
86
|
}
|
|
84
87
|
}
|
|
@@ -171,16 +174,35 @@ export function updateMonthlyAnalytics(prs, monthlyCounts, monthlyClosedCounts,
|
|
|
171
174
|
* time that does not parse, issues past the comment-fetch cap) collapse to
|
|
172
175
|
* one label: the monitor already logged each one, and the banner lists
|
|
173
176
|
* operations. Engaged issues whose batched lookup failed were not checked
|
|
174
|
-
* at all this run, so they get their own label
|
|
177
|
+
* at all this run, so they get their own label, and so does a comment
|
|
178
|
+
* search that returned a partial list (#1928).
|
|
175
179
|
*/
|
|
176
180
|
function engagedScanLabels(result) {
|
|
177
181
|
const labels = [];
|
|
178
182
|
if (result.lookupFailures > 0)
|
|
179
183
|
labels.push('look up engaged issues');
|
|
180
|
-
|
|
184
|
+
// A partial comment search is named on its own (#1928); its sentence is one of `warnings`.
|
|
185
|
+
const { searchTruncation } = result;
|
|
186
|
+
if (searchTruncation !== undefined)
|
|
187
|
+
labels.push(searchTruncation);
|
|
188
|
+
if (result.warnings.length > (searchTruncation === undefined ? 0 : 1))
|
|
181
189
|
labels.push('scan engaged issues');
|
|
182
190
|
return labels;
|
|
183
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Name a ledger gap fetch that stored nothing on the partial-data banner
|
|
194
|
+
* (#1924): `failedLabel` when it failed, `truncatedMessage` when it matched
|
|
195
|
+
* more than one refresh fetches.
|
|
196
|
+
*/
|
|
197
|
+
function reportLedgerGap(gap, failedLabel, truncatedMessage, partialFailures) {
|
|
198
|
+
if (!gap) {
|
|
199
|
+
partialFailures.push(failedLabel);
|
|
200
|
+
}
|
|
201
|
+
else if (gap.truncated) {
|
|
202
|
+
partialFailures.push(truncatedMessage);
|
|
203
|
+
warn(MODULE, truncatedMessage);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
184
206
|
/**
|
|
185
207
|
* Fetch fresh dashboard data from GitHub.
|
|
186
208
|
* Returns the digest and commented issues, updating state as a side effect.
|
|
@@ -191,34 +213,8 @@ export async function fetchDashboardData(token) {
|
|
|
191
213
|
const prMonitor = new PRMonitor(token);
|
|
192
214
|
const issueMonitor = new IssueConversationMonitor(token);
|
|
193
215
|
const octokit = getOctokit(token);
|
|
194
|
-
const config = stateManager.getState().config;
|
|
195
216
|
// Build star filter from cached repoScores (#576)
|
|
196
217
|
const starFilter = buildStarFilter(stateManager.getState());
|
|
197
|
-
// Get watermarks for incremental PR fetch
|
|
198
|
-
const watermark = stateManager.getMergedPRWatermark();
|
|
199
|
-
const closedWatermark = stateManager.getClosedPRWatermark();
|
|
200
|
-
// Self-heal a ledger stranded behind a recent watermark (#1504). The
|
|
201
|
-
// incremental fetch only asks for merges newer than the newest stored one,
|
|
202
|
-
// so once the recent-merge feed (daily's recentlyMergedPRs) seeds the ledger
|
|
203
|
-
// before any full historical fetch ran, the older history can never be
|
|
204
|
-
// recovered. When the stored detail count is materially below the known
|
|
205
|
-
// all-time merged count, drop the watermark for a one-shot full backfill
|
|
206
|
-
// (bounded by the existing pagination cap); once the ledger catches up the
|
|
207
|
-
// watermark resumes incremental fetching. Closed PRs are not seeded ahead of
|
|
208
|
-
// their backfill in practice, so only merged needs the guard.
|
|
209
|
-
const storedMergedCount = stateManager.getMergedPRs().length;
|
|
210
|
-
const knownMergedAllTime = stateManager.getState().lastDigest?.summary?.totalMergedAllTime ?? 0;
|
|
211
|
-
// A full backfill can only ever return up to fetchMergedPRsSince's pagination
|
|
212
|
-
// cap (MAX_PAGINATION_PAGES * 100 = 300). Stop forcing one once the ledger has
|
|
213
|
-
// reached that ceiling, so a contributor whose star-filtered all-time count
|
|
214
|
-
// legitimately exceeds 300 doesn't trigger a full refetch on every poll.
|
|
215
|
-
const MERGED_BACKFILL_CEILING = 300;
|
|
216
|
-
const mergedNeedsBackfill = storedMergedCount < knownMergedAllTime && storedMergedCount < MERGED_BACKFILL_CEILING;
|
|
217
|
-
const mergedFetchSince = mergedNeedsBackfill ? undefined : watermark;
|
|
218
|
-
if (mergedNeedsBackfill) {
|
|
219
|
-
warn(MODULE, `Merged-PR ledger has ${storedMergedCount} of ~${knownMergedAllTime} known merges; ` +
|
|
220
|
-
'running a full backfill (watermark dropped) to recover history (#1504).');
|
|
221
|
-
}
|
|
222
218
|
// Track which non-critical sub-fetches degraded to fallbacks so the SPA
|
|
223
219
|
// can surface a "partial data" banner instead of silently showing zeros.
|
|
224
220
|
// Rate-limit / auth errors still rethrow via isRateLimitOrAuthError —
|
|
@@ -233,19 +229,38 @@ export async function fetchDashboardData(token) {
|
|
|
233
229
|
return fallback;
|
|
234
230
|
};
|
|
235
231
|
};
|
|
236
|
-
|
|
232
|
+
// The ledger phases daily runs (daily-ledger.ts), so gaps, backfill and
|
|
233
|
+
// eviction follow one rule (#2038). Their warnings stay out of the banner:
|
|
234
|
+
// the gaps are reported from their results below, and the "ledger is
|
|
235
|
+
// short, run ledger-backfill" check is the daily run's to report.
|
|
236
|
+
const ledgerWarnings = [];
|
|
237
|
+
const gapOptions = { rethrowIf: isRateLimitOrAuthError };
|
|
238
|
+
const recentListTruncations = [];
|
|
239
|
+
const mergedCounts = prMonitor
|
|
240
|
+
.fetchUserMergedPRCounts(starFilter)
|
|
241
|
+
.catch(trackingCatch('fetch merged PR counts', emptyPRCountsResult()));
|
|
242
|
+
const closedCounts = prMonitor
|
|
243
|
+
.fetchUserClosedPRCounts(starFilter)
|
|
244
|
+
.catch(trackingCatch('fetch closed PR counts', emptyPRCountsResult()));
|
|
245
|
+
const [{ prs, failures, warnings: fetchWarnings }, recentlyClosedPRs, recentlyMergedPRs, mergedResult, closedResult, mergedGap, closedGap,] = await Promise.all([
|
|
237
246
|
prMonitor.fetchUserOpenPRs(),
|
|
238
|
-
prMonitor.fetchRecentlyClosedPRs().catch(trackingCatch('fetch recently closed PRs', [])),
|
|
239
|
-
prMonitor.fetchRecentlyMergedPRs().catch(trackingCatch('fetch recently merged PRs', [])),
|
|
240
247
|
prMonitor
|
|
241
|
-
.
|
|
242
|
-
.catch(trackingCatch('fetch
|
|
248
|
+
.fetchRecentlyClosedPRs(7, recentListTruncations)
|
|
249
|
+
.catch(trackingCatch('fetch recently closed PRs', [])),
|
|
243
250
|
prMonitor
|
|
244
|
-
.
|
|
245
|
-
.catch(trackingCatch('fetch
|
|
246
|
-
|
|
247
|
-
|
|
251
|
+
.fetchRecentlyMergedPRs(7, recentListTruncations)
|
|
252
|
+
.catch(trackingCatch('fetch recently merged PRs', [])),
|
|
253
|
+
mergedCounts,
|
|
254
|
+
closedCounts,
|
|
255
|
+
// The gap fetches wait for the counts: a ledger short of its all-time
|
|
256
|
+
// count under the ceiling is fetched from the start (gapFetchWatermark,
|
|
257
|
+
// #1504, #1925). Nothing else adds ledger rows before they are stored, so
|
|
258
|
+
// a failed or truncated fetch leaves the watermark alone.
|
|
259
|
+
mergedCounts.then((counts) => fetchMergedLedgerGap(octokit, stateManager, ledgerWarnings, counts.totalCount, gapOptions)),
|
|
260
|
+
closedCounts.then((counts) => fetchClosedLedgerGap(octokit, stateManager, ledgerWarnings, counts.totalCount, gapOptions)),
|
|
248
261
|
]);
|
|
262
|
+
reportLedgerGap(mergedGap, 'fetch merged PRs for storage', MERGED_LEDGER_TRUNCATED_MESSAGE, partialFailures);
|
|
263
|
+
reportLedgerGap(closedGap, 'fetch closed PRs for storage', CLOSED_LEDGER_TRUNCATED_MESSAGE, partialFailures);
|
|
249
264
|
// Issue conversations run after the PR lists: the engaged set (#1862)
|
|
250
265
|
// needs the open, recently closed and recently merged PRs. The fetch has
|
|
251
266
|
// custom messaging based on the error content, so it keeps its bespoke catch.
|
|
@@ -292,6 +307,8 @@ export async function fetchDashboardData(token) {
|
|
|
292
307
|
warn(MODULE, message);
|
|
293
308
|
}
|
|
294
309
|
}
|
|
310
|
+
// Same for a recent-list truncation (#1928): the short label here, the full sentence already logged.
|
|
311
|
+
partialFailures.push(...recentListTruncations.map((truncation) => truncation.label));
|
|
295
312
|
// Wrap all state mutations in a batch for a single disk write.
|
|
296
313
|
// try-catch: save errors should not crash the dashboard data fetch.
|
|
297
314
|
try {
|
|
@@ -305,19 +322,41 @@ export async function fetchDashboardData(token) {
|
|
|
305
322
|
// Per-PR override failures (#1448) land in partialFailures so the SPA
|
|
306
323
|
// banner flags PRs silently showing their un-overridden status.
|
|
307
324
|
const overriddenPRs = applyStatusOverrides(prs, stateManager.getState(), partialFailures);
|
|
325
|
+
// Re-key transferred repos, drop closed-ledger rows that were reopened
|
|
326
|
+
// or merged (#1923) and rows in untracked organisations (#1924), as the
|
|
327
|
+
// daily run does before it stores. Private repositories are evicted by
|
|
328
|
+
// the daily run only: it is the one that reads repository visibility.
|
|
329
|
+
// Separate guards, so one failing does not skip the other.
|
|
330
|
+
try {
|
|
331
|
+
syncLedgersWithGitHub(stateManager, [...mergedResult.searchedPRs, ...closedResult.searchedPRs], prs);
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
partialFailures.push('clean up PR ledgers');
|
|
335
|
+
warn(MODULE, `Failed to clean up PR ledgers: ${errorMessage(error)}`);
|
|
336
|
+
}
|
|
337
|
+
try {
|
|
338
|
+
evictNeverTrackedRepos(stateManager, []);
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
partialFailures.push('remove untracked PRs');
|
|
342
|
+
warn(MODULE, `Failed to remove untracked PRs: ${errorMessage(error)}`);
|
|
343
|
+
}
|
|
308
344
|
// Previous run's digest — read BEFORE setLastDigest below replaces it.
|
|
309
345
|
// Supplies best-effort firstMaintainerResponseAt for PRs that were
|
|
310
346
|
// enriched while open, mirroring daily's Phase 3 (#1461). openedAt is
|
|
311
347
|
// already on the entries (created_at from the search result).
|
|
312
348
|
const previousDigest = stateManager.getState().lastDigest;
|
|
313
|
-
// Store
|
|
314
|
-
//
|
|
349
|
+
// Store the gap plus the recent list, only when the gap was fetched
|
|
350
|
+
// whole, as the daily run does (dedupes by URL; re-seen entries upgrade
|
|
351
|
+
// missing ledger fields in place).
|
|
315
352
|
try {
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
353
|
+
const dropped = storeMergedLedger(stateManager, {
|
|
354
|
+
gap: mergedGap,
|
|
355
|
+
allTimeCount: mergedResult.totalCount,
|
|
356
|
+
recentlyMergedPRs,
|
|
357
|
+
previousDigest,
|
|
358
|
+
warnings: ledgerWarnings,
|
|
359
|
+
});
|
|
321
360
|
if (dropped > 0) {
|
|
322
361
|
partialFailures.push(`Dropped ${dropped} merged PR(s) with invalid URLs before persistence`);
|
|
323
362
|
}
|
|
@@ -326,14 +365,14 @@ export async function fetchDashboardData(token) {
|
|
|
326
365
|
partialFailures.push('store merged PRs');
|
|
327
366
|
warn(MODULE, `Failed to store merged PRs: ${errorMessage(error)}`);
|
|
328
367
|
}
|
|
329
|
-
// Store new closed PRs incrementally (dedupes by URL; re-seen entries
|
|
330
|
-
// upgrade missing ledger fields in place)
|
|
331
368
|
try {
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
369
|
+
const dropped = storeClosedLedger(stateManager, {
|
|
370
|
+
gap: closedGap,
|
|
371
|
+
allTimeCount: closedResult.totalCount,
|
|
372
|
+
recentlyClosedPRs,
|
|
373
|
+
previousDigest,
|
|
374
|
+
warnings: ledgerWarnings,
|
|
375
|
+
});
|
|
337
376
|
if (dropped > 0) {
|
|
338
377
|
partialFailures.push(`Dropped ${dropped} closed PR(s) with invalid URLs before persistence`);
|
|
339
378
|
}
|
|
@@ -357,15 +396,15 @@ export async function fetchDashboardData(token) {
|
|
|
357
396
|
const digest = prMonitor.generateDigest(prs, recentlyClosedPRs, recentlyMergedPRs);
|
|
358
397
|
// Apply shelve partitioning for display (auto-unshelve only runs in daily check).
|
|
359
398
|
// Dormant PRs are treated as shelved unless they need addressing, and a
|
|
360
|
-
//
|
|
361
|
-
//
|
|
399
|
+
// PR the daily check would auto-unshelve is never display-shelved
|
|
400
|
+
// (#1352, #1922) so headline counts agree.
|
|
362
401
|
// Partitioned over overriddenPRs (#1416): the shelve decision must use
|
|
363
402
|
// the same post-override status the CLI partitions on.
|
|
364
|
-
const
|
|
403
|
+
const shelveConfig = stateManager.getState().config;
|
|
365
404
|
// Single copy of the shelve predicate (#1421): isShelvedForDisplay is
|
|
366
405
|
// the same rule reconcileShelvePartition applies on rebuilds, so its
|
|
367
406
|
// regression tests now guard this line too.
|
|
368
|
-
const freshShelved = overriddenPRs.filter((pr) => isShelvedForDisplay(pr,
|
|
407
|
+
const freshShelved = overriddenPRs.filter((pr) => isShelvedForDisplay(pr, shelveConfig));
|
|
369
408
|
digest.shelvedPRs = freshShelved.map(toShelvedPRRef);
|
|
370
409
|
digest.autoUnshelvedPRs = [];
|
|
371
410
|
digest.summary.totalActivePRs = overriddenPRs.length - freshShelved.length;
|
|
@@ -376,6 +415,11 @@ export async function fetchDashboardData(token) {
|
|
|
376
415
|
partialFailures.push('persist dashboard state');
|
|
377
416
|
warn(MODULE, `Failed to persist dashboard state: ${errorMessage(error)}`);
|
|
378
417
|
}
|
|
418
|
+
// Gap failures were logged where they happened; the short-ledger check was not.
|
|
419
|
+
for (const warning of ledgerWarnings) {
|
|
420
|
+
if (warning.phase === 'analytics')
|
|
421
|
+
warn(MODULE, warning.message);
|
|
422
|
+
}
|
|
379
423
|
warn(MODULE, `Refreshed: ${prs.length} PRs fetched`);
|
|
380
424
|
// Convert stored PRs to full types (derive repo/number from URL) — read-only, outside batch
|
|
381
425
|
const allMergedPRs = storedToMergedPRs(stateManager.getMergedPRs());
|
|
@@ -196,7 +196,9 @@ export class GistSyncCoordinator {
|
|
|
196
196
|
async maybeRecoverGist() {
|
|
197
197
|
// One probe covers both degraded shapes — health.degraded is non-null
|
|
198
198
|
// for configured-but-local AND bootstrap-degraded (#1444).
|
|
199
|
-
|
|
199
|
+
const degraded = this.probeGistHealth()?.degraded;
|
|
200
|
+
// An unknown mode (#2005) is not recoverable by re-running init.
|
|
201
|
+
if (degraded == null || !degraded.recoverable)
|
|
200
202
|
return;
|
|
201
203
|
if (this.recoveryHaltedReason !== null)
|
|
202
204
|
return;
|
|
@@ -23,17 +23,26 @@ export interface LaunchResult {
|
|
|
23
23
|
*/
|
|
24
24
|
export declare function resolveCliEntry(argv1: string, assetsDir: string): string;
|
|
25
25
|
/**
|
|
26
|
-
* Stop the running dashboard server if
|
|
26
|
+
* Stop the running dashboard server if an older CLI version launched it (#548).
|
|
27
27
|
*
|
|
28
28
|
* The server's refresh path re-classifies PRs with its own bundled code and
|
|
29
29
|
* writes the result to state, so an old-version server overwrites whatever a
|
|
30
30
|
* newer `daily` just wrote (#1709). The server cannot detect this itself:
|
|
31
31
|
* plugin updates install into a new versioned directory, so the old server's
|
|
32
32
|
* own package.json never changes. Callers running the current CLI (startup,
|
|
33
|
-
* `daily`) therefore make the check.
|
|
33
|
+
* `daily`, `dashboard launch`) therefore make the check.
|
|
34
34
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* A newer server is left running: a long-lived session on an old plugin root
|
|
36
|
+
* must not replace it with its own older code (#1882).
|
|
37
|
+
*
|
|
38
|
+
* A server that does not answer `/api/health` as ours (one from before 3.43.0
|
|
39
|
+
* has no such route, and a busy one can miss the timeout) is stopped too
|
|
40
|
+
* unless it is newer, but only after its command line identifies it as
|
|
41
|
+
* `dashboard serve`. Otherwise the PID may have been recycled to an unrelated
|
|
42
|
+
* process and is never signalled (#1927).
|
|
43
|
+
*
|
|
44
|
+
* Returns the running server when it is left up (same, newer or unknown
|
|
45
|
+
* version, or the kill failed), or null when none is running or it was stopped.
|
|
37
46
|
*/
|
|
38
47
|
export declare function stopStaleDashboardServer(): Promise<LaunchResult | null>;
|
|
39
48
|
/**
|
|
@@ -42,11 +51,30 @@ export declare function stopStaleDashboardServer(): Promise<LaunchResult | null>
|
|
|
42
51
|
* Returns the server URL if launched successfully, or null if the SPA assets
|
|
43
52
|
* are not available (dashboard is skipped).
|
|
44
53
|
*
|
|
45
|
-
* If a server from the current version is already running
|
|
46
|
-
* file + health probe), returns its URL without launching a
|
|
47
|
-
* from
|
|
48
|
-
* no replacement can be launched (#1709).
|
|
54
|
+
* If a server from the current or a newer version is already running
|
|
55
|
+
* (detected via PID file + health probe), returns its URL without launching a
|
|
56
|
+
* new one. A server from an older version is stopped first, even when the
|
|
57
|
+
* assets are missing and no replacement can be launched (#1709). See
|
|
58
|
+
* stopStaleDashboardServer for the rules.
|
|
49
59
|
*/
|
|
50
60
|
export declare function launchDashboardServer(options?: {
|
|
51
61
|
port?: number;
|
|
62
|
+
/** Append the server's stdout and stderr here instead of discarding them. */
|
|
63
|
+
logFile?: string;
|
|
52
64
|
}): Promise<LaunchResult | null>;
|
|
65
|
+
export interface DashboardLaunchOutput {
|
|
66
|
+
status: 'launched' | 'already_running';
|
|
67
|
+
url: string;
|
|
68
|
+
port: number;
|
|
69
|
+
/** Where the server's output goes when this command started it. */
|
|
70
|
+
logFile: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* `dashboard launch`: reuse the running server or start one in the
|
|
74
|
+
* background, through the same version check and health probe as startup.
|
|
75
|
+
* The `/oss-dashboard` command calls this instead of probing the server
|
|
76
|
+
* itself (#2039).
|
|
77
|
+
*/
|
|
78
|
+
export declare function runDashboardLaunch(options: {
|
|
79
|
+
port: number;
|
|
80
|
+
}): Promise<DashboardLaunchOutput>;
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import { spawn } from 'node:child_process';
|
|
7
7
|
import * as fs from 'node:fs';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
|
-
import {
|
|
9
|
+
import { isDashboardServeProcess, isDashboardServerRunning, probeDashboardServer, readDashboardServerInfo, removeDashboardServerInfo, } from './dashboard-process.js';
|
|
10
10
|
import { resolveAssetsDir } from './dashboard.js';
|
|
11
|
-
import { getCLIVersion } from '../core/index.js';
|
|
11
|
+
import { getCLIVersion, getDataDir } from '../core/index.js';
|
|
12
12
|
const DEFAULT_PORT = 3000;
|
|
13
13
|
const POLL_INTERVAL_MS = 200;
|
|
14
14
|
const MAX_POLL_ATTEMPTS = 25; // 5 seconds total
|
|
@@ -24,55 +24,128 @@ export function resolveCliEntry(argv1, assetsDir) {
|
|
|
24
24
|
const coreBundle = path.resolve(assetsDir, '../../core/dist/cli.bundle.cjs');
|
|
25
25
|
return fs.existsSync(coreBundle) ? coreBundle : argv1;
|
|
26
26
|
}
|
|
27
|
+
/** Open `logFile` for appending and mark where this server's output starts. */
|
|
28
|
+
function openLogFile(logFile) {
|
|
29
|
+
const startedAt = new Date();
|
|
30
|
+
const fd = fs.openSync(logFile, 'a', 0o600);
|
|
31
|
+
fs.writeSync(fd, `--- dashboard server started ${startedAt.toISOString()} ---\n`);
|
|
32
|
+
return fd;
|
|
33
|
+
}
|
|
34
|
+
/** Spawn `dashboard serve` detached, with its output discarded or appended to `logFile`. */
|
|
35
|
+
function spawnDashboardServer(cliPath, port, logFile) {
|
|
36
|
+
const logFd = logFile ? openLogFile(logFile) : undefined;
|
|
37
|
+
const stdio = logFd === undefined ? 'ignore' : ['ignore', logFd, logFd];
|
|
38
|
+
try {
|
|
39
|
+
return spawn('node', [cliPath, 'dashboard', 'serve', '--port', String(port), '--no-open'], {
|
|
40
|
+
detached: true,
|
|
41
|
+
stdio,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
// The child holds its own copy of the descriptor.
|
|
46
|
+
if (logFd !== undefined)
|
|
47
|
+
fs.closeSync(logFd);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
27
50
|
function sleep(ms) {
|
|
28
51
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
29
52
|
}
|
|
53
|
+
/** `x.y.z` of a version string, or null when it does not start with one. */
|
|
54
|
+
function parseVersion(version) {
|
|
55
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
|
|
56
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
|
|
57
|
+
}
|
|
30
58
|
/**
|
|
31
|
-
*
|
|
59
|
+
* How the version a server recorded compares with the current CLI's. A PID
|
|
60
|
+
* file with no version predates the stamp (#548), so it is older. `unknown`
|
|
61
|
+
* when either side cannot be read (`getCLIVersion` falls back to 0.0.0).
|
|
62
|
+
*/
|
|
63
|
+
function compareServerVersion(serverVersion, currentVersion) {
|
|
64
|
+
const current = parseVersion(currentVersion);
|
|
65
|
+
if (currentVersion === '0.0.0' || !current)
|
|
66
|
+
return 'unknown';
|
|
67
|
+
if (serverVersion === undefined)
|
|
68
|
+
return 'older';
|
|
69
|
+
const server = parseVersion(serverVersion);
|
|
70
|
+
if (!server)
|
|
71
|
+
return 'unknown';
|
|
72
|
+
const diff = server.map((part, i) => part - current[i]).find((d) => d !== 0) ?? 0;
|
|
73
|
+
if (diff === 0)
|
|
74
|
+
return 'same';
|
|
75
|
+
return diff < 0 ? 'older' : 'newer';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* SIGTERM the server the PID file records and remove the file. Returns null
|
|
79
|
+
* once it is stopped, or `running` when the signal could not be delivered
|
|
80
|
+
* (e.g. EPERM): the server is still up, so the caller must not spawn another.
|
|
81
|
+
*/
|
|
82
|
+
function stopDashboardServer(info, running) {
|
|
83
|
+
try {
|
|
84
|
+
process.kill(info.pid, 'SIGTERM');
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
// ESRCH = already exited
|
|
88
|
+
if (err.code !== 'ESRCH') {
|
|
89
|
+
console.error(`[DASHBOARD] Could not kill outdated dashboard (PID ${info.pid}): ${err.message}`);
|
|
90
|
+
return running;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
removeDashboardServerInfo();
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Stop the running dashboard server if an older CLI version launched it (#548).
|
|
32
98
|
*
|
|
33
99
|
* The server's refresh path re-classifies PRs with its own bundled code and
|
|
34
100
|
* writes the result to state, so an old-version server overwrites whatever a
|
|
35
101
|
* newer `daily` just wrote (#1709). The server cannot detect this itself:
|
|
36
102
|
* plugin updates install into a new versioned directory, so the old server's
|
|
37
103
|
* own package.json never changes. Callers running the current CLI (startup,
|
|
38
|
-
* `daily`) therefore make the check.
|
|
104
|
+
* `daily`, `dashboard launch`) therefore make the check.
|
|
105
|
+
*
|
|
106
|
+
* A newer server is left running: a long-lived session on an old plugin root
|
|
107
|
+
* must not replace it with its own older code (#1882).
|
|
39
108
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
109
|
+
* A server that does not answer `/api/health` as ours (one from before 3.43.0
|
|
110
|
+
* has no such route, and a busy one can miss the timeout) is stopped too
|
|
111
|
+
* unless it is newer, but only after its command line identifies it as
|
|
112
|
+
* `dashboard serve`. Otherwise the PID may have been recycled to an unrelated
|
|
113
|
+
* process and is never signalled (#1927).
|
|
114
|
+
*
|
|
115
|
+
* Returns the running server when it is left up (same, newer or unknown
|
|
116
|
+
* version, or the kill failed), or null when none is running or it was stopped.
|
|
42
117
|
*/
|
|
43
118
|
export async function stopStaleDashboardServer() {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
return null;
|
|
47
|
-
const info = readDashboardServerInfo();
|
|
48
|
-
// PID file disappeared between health check and now (race condition).
|
|
49
|
-
if (!info)
|
|
119
|
+
const probe = await probeDashboardServer();
|
|
120
|
+
if (probe.status === 'none')
|
|
50
121
|
return null;
|
|
122
|
+
const { info } = probe;
|
|
51
123
|
const running = {
|
|
52
|
-
url:
|
|
53
|
-
port:
|
|
124
|
+
url: `http://oss.localhost:${info.port}`,
|
|
125
|
+
port: info.port,
|
|
54
126
|
alreadyRunning: true,
|
|
55
127
|
lastBrowserOpenedAt: info.lastBrowserOpenedAt,
|
|
56
128
|
};
|
|
57
129
|
const currentVersion = getCLIVersion();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
process.kill(info.pid, 'SIGTERM');
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
// ESRCH = already exited
|
|
67
|
-
if (err.code !== 'ESRCH') {
|
|
68
|
-
console.error(`[DASHBOARD] Could not kill outdated dashboard (PID ${info.pid}): ${err.message}`);
|
|
69
|
-
// Could not kill old server (e.g. EPERM); report it as running rather
|
|
70
|
-
// than letting the caller attempt a doomed spawn on the same port.
|
|
130
|
+
const age = compareServerVersion(info.version, currentVersion);
|
|
131
|
+
if (probe.status === 'running') {
|
|
132
|
+
// A server that answers /api/health is 3.43.0 or later and always records
|
|
133
|
+
// its version; keep the old reading of a missing one as "leave it".
|
|
134
|
+
if (!info.version || age !== 'older')
|
|
71
135
|
return running;
|
|
72
|
-
}
|
|
136
|
+
console.error(`[DASHBOARD] Dashboard server version mismatch (running: ${info.version}, current: ${currentVersion}). Stopping it...`);
|
|
137
|
+
return stopDashboardServer(info, running);
|
|
73
138
|
}
|
|
74
|
-
|
|
75
|
-
|
|
139
|
+
if (age === 'unknown' || !isDashboardServeProcess(info.pid)) {
|
|
140
|
+
// Not identified as our server, or no version to compare: the stale-PID-file
|
|
141
|
+
// case. Never signal it (#1927).
|
|
142
|
+
removeDashboardServerInfo();
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
if (age === 'newer')
|
|
146
|
+
return running;
|
|
147
|
+
console.error(`[DASHBOARD] Dashboard server (PID ${info.pid}, version ${info.version ?? 'unknown'}) did not answer the health check. Stopping it...`);
|
|
148
|
+
return stopDashboardServer(info, running);
|
|
76
149
|
}
|
|
77
150
|
/**
|
|
78
151
|
* Launch the interactive dashboard SPA server as a detached background process.
|
|
@@ -80,10 +153,11 @@ export async function stopStaleDashboardServer() {
|
|
|
80
153
|
* Returns the server URL if launched successfully, or null if the SPA assets
|
|
81
154
|
* are not available (dashboard is skipped).
|
|
82
155
|
*
|
|
83
|
-
* If a server from the current version is already running
|
|
84
|
-
* file + health probe), returns its URL without launching a
|
|
85
|
-
* from
|
|
86
|
-
* no replacement can be launched (#1709).
|
|
156
|
+
* If a server from the current or a newer version is already running
|
|
157
|
+
* (detected via PID file + health probe), returns its URL without launching a
|
|
158
|
+
* new one. A server from an older version is stopped first, even when the
|
|
159
|
+
* assets are missing and no replacement can be launched (#1709). See
|
|
160
|
+
* stopStaleDashboardServer for the rules.
|
|
87
161
|
*/
|
|
88
162
|
export async function launchDashboardServer(options) {
|
|
89
163
|
// 1. Check if SPA assets exist
|
|
@@ -99,10 +173,7 @@ export async function launchDashboardServer(options) {
|
|
|
99
173
|
// 3. Launch as detached child process
|
|
100
174
|
const port = options?.port ?? DEFAULT_PORT;
|
|
101
175
|
const cliPath = resolveCliEntry(process.argv[1], assetsDir);
|
|
102
|
-
const child =
|
|
103
|
-
detached: true,
|
|
104
|
-
stdio: 'ignore',
|
|
105
|
-
});
|
|
176
|
+
const child = spawnDashboardServer(cliPath, port, options?.logFile);
|
|
106
177
|
// Track spawn failures and early exits so the polling loop can bail early
|
|
107
178
|
let spawnFailed = false;
|
|
108
179
|
let childExited = false;
|
|
@@ -126,7 +197,7 @@ export async function launchDashboardServer(options) {
|
|
|
126
197
|
}
|
|
127
198
|
const info = readDashboardServerInfo();
|
|
128
199
|
// PID file appeared — verify the server is responding
|
|
129
|
-
if (info && (await isDashboardServerRunning(info.port))) {
|
|
200
|
+
if (info && (await isDashboardServerRunning(info.port, info.pid))) {
|
|
130
201
|
return { url: `http://oss.localhost:${info.port}`, port: info.port, alreadyRunning: false };
|
|
131
202
|
}
|
|
132
203
|
}
|
|
@@ -146,3 +217,25 @@ export async function launchDashboardServer(options) {
|
|
|
146
217
|
}
|
|
147
218
|
return null;
|
|
148
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* `dashboard launch`: reuse the running server or start one in the
|
|
222
|
+
* background, through the same version check and health probe as startup.
|
|
223
|
+
* The `/oss-dashboard` command calls this instead of probing the server
|
|
224
|
+
* itself (#2039).
|
|
225
|
+
*/
|
|
226
|
+
export async function runDashboardLaunch(options) {
|
|
227
|
+
const logFile = path.join(getDataDir(), 'dashboard.log');
|
|
228
|
+
const result = await launchDashboardServer({ port: options.port, logFile });
|
|
229
|
+
if (!result) {
|
|
230
|
+
if (!resolveAssetsDir()) {
|
|
231
|
+
throw new Error('Dashboard SPA assets not found. Build with: cd packages/dashboard && pnpm run build');
|
|
232
|
+
}
|
|
233
|
+
throw new Error(`Dashboard server did not start. Logs: ${logFile}`);
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
status: result.alreadyRunning ? 'already_running' : 'launched',
|
|
237
|
+
url: result.url,
|
|
238
|
+
port: result.port,
|
|
239
|
+
logFile,
|
|
240
|
+
};
|
|
241
|
+
}
|