@mrclrchtr/supi-code-intelligence 11.1.0 → 11.3.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/CHANGELOG.md +19 -0
- package/README.md +41 -6
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +81 -7
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/LICENSE +15 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +5 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +11 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +77 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +149 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-typescript-project.ts +40 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +174 -49
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +306 -75
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +19 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +40 -25
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/call-context.ts +44 -0
- package/package.json +6 -5
- package/src/analysis/capability/capability-warnings.ts +18 -12
- package/src/analysis/health/check.ts +115 -0
- package/src/analysis/health/diagnostics.ts +3 -0
- package/src/analysis/health/file-scope.ts +2 -3
- package/src/analysis/health/semantic-state.ts +38 -0
- package/src/analysis/health/server-status.ts +14 -2
- package/src/analysis/health/signals.ts +2 -0
- package/src/analysis/health/status.ts +82 -0
- package/src/analysis/refactor/apply.ts +17 -8
- package/src/analysis/search/exclusions.ts +47 -0
- package/src/analysis/search/paths.ts +32 -9
- package/src/analysis/target/anchored-structural.ts +3 -8
- package/src/analysis/target/anchored.ts +4 -20
- package/src/analysis/target/identity.ts +1 -1
- package/src/analysis/target/latex-label-container.ts +6 -6
- package/src/analysis/target/latex-section-anchor.ts +6 -6
- package/src/analysis/target/resolution.ts +18 -0
- package/src/analysis/target/symbol.ts +39 -11
- package/src/analysis/target/types.ts +6 -1
- package/src/extension.ts +17 -11
- package/src/session/graph/collect.ts +1 -10
- package/src/session/graph-types.ts +2 -0
- package/src/session/graph-workflow.ts +1 -0
- package/src/session/health-types.ts +7 -0
- package/src/session/health-workflow.ts +8 -43
- package/src/session/inspect/collect.ts +8 -2
- package/src/session/inspect/file-point.ts +2 -3
- package/src/session/inspect-workflow.ts +1 -1
- package/src/session/orientation/collect.ts +184 -20
- package/src/session/orientation/context-facts.ts +27 -2
- package/src/session/orientation/context-sections.ts +49 -3
- package/src/session/orientation/facts.ts +132 -0
- package/src/session/orientation/gather.ts +98 -11
- package/src/session/orientation/workspace-context.ts +16 -6
- package/src/session/orientation-types.ts +8 -0
- package/src/session/orientation-workflow.ts +20 -6
- package/src/session/refactor-identity.ts +76 -0
- package/src/session/refactor-plans.ts +5 -2
- package/src/session/refactor-workflow.ts +15 -17
- package/src/session/target-store.ts +3 -18
- package/src/session/target-workflow.ts +33 -16
- package/src/substrate/lsp/recovery.ts +5 -5
- package/src/tool/code_find/guidance.ts +1 -1
- package/src/tool/code_find/render.ts +8 -4
- package/src/tool/code_find/result.ts +78 -6
- package/src/tool/code_find/spec.ts +4 -3
- package/src/tool/code_find/structured.ts +25 -9
- package/src/tool/code_graph/details.ts +1 -0
- package/src/tool/code_graph/display.ts +1 -1
- package/src/tool/code_graph/guidance.ts +1 -1
- package/src/tool/code_graph/markdown.ts +11 -6
- package/src/tool/code_graph/read-next.ts +38 -9
- package/src/tool/code_graph/reference-selection.ts +30 -0
- package/src/tool/code_graph/result.ts +25 -118
- package/src/tool/code_graph/section.ts +133 -0
- package/src/tool/code_graph/spec.ts +3 -3
- package/src/tool/code_graph/structured.ts +17 -6
- package/src/tool/code_health/display-paths.ts +92 -0
- package/src/tool/code_health/file-scope-markdown.ts +3 -2
- package/src/tool/code_health/markdown.ts +12 -2
- package/src/tool/code_health/result.ts +18 -3
- package/src/tool/code_health/spec.ts +5 -3
- package/src/tool/code_health/structured-schema.ts +250 -0
- package/src/tool/code_health/structured.ts +256 -0
- package/src/tool/code_inspect/result.ts +11 -5
- package/src/tool/code_inspect/spec.ts +7 -1
- package/src/tool/code_inspect/structured.ts +231 -0
- package/src/tool/code_orientation/execute.ts +1 -1
- package/src/tool/code_orientation/result.ts +31 -8
- package/src/tool/code_orientation/spec.ts +2 -0
- package/src/tool/code_orientation/structured-schema.ts +617 -0
- package/src/tool/code_orientation/structured-workspace.ts +194 -0
- package/src/tool/code_orientation/structured.ts +189 -0
- package/src/tool/code_orientation/workspace-format.ts +2 -5
- package/src/tool/code_orientation/workspace-observations.ts +81 -0
- package/src/tool/code_orientation/workspace-output.ts +5 -0
- package/src/tool/code_orientation/workspace-projects.ts +16 -31
- package/src/tool/code_orientation/workspace-sections.ts +46 -32
- package/src/tool/code_refactor_apply/execute.ts +1 -1
- package/src/tool/code_refactor_apply/result.ts +14 -6
- package/src/tool/code_refactor_apply/spec.ts +2 -0
- package/src/tool/code_refactor_apply/structured.ts +49 -0
- package/src/tool/code_refactor_plan/result.ts +18 -9
- package/src/tool/code_refactor_plan/spec.ts +2 -0
- package/src/tool/code_refactor_plan/structured.ts +127 -0
- package/src/tool/code_resolve/markdown.ts +6 -30
- package/src/tool/code_resolve/result.ts +24 -11
- package/src/tool/code_resolve/structured.ts +7 -9
- package/src/tool/result/refactor.ts +8 -5
- package/src/tool/result/structured.ts +8 -5
- package/src/tool/result/types.ts +18 -14
- package/src/tool/schemas.ts +12 -6
- package/src/ui/status-command.ts +147 -322
- package/src/ui/status-overlay.ts +584 -421
- package/src/ui/status-presentation.ts +108 -0
package/src/ui/status-overlay.ts
CHANGED
|
@@ -1,563 +1,726 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { DynamicBorder } from "@earendil-works/pi-coding-agent";
|
|
1
|
+
import { relative, resolve } from "node:path";
|
|
2
|
+
import { DynamicBorder, type Theme } from "@earendil-works/pi-coding-agent";
|
|
5
3
|
import {
|
|
6
4
|
Container,
|
|
5
|
+
getKeybindings,
|
|
7
6
|
Key,
|
|
7
|
+
type KeybindingsManager,
|
|
8
8
|
matchesKey,
|
|
9
|
+
ScrollView,
|
|
9
10
|
Spacer,
|
|
10
11
|
Text,
|
|
11
12
|
truncateToWidth,
|
|
12
|
-
visibleWidth,
|
|
13
13
|
} from "@earendil-works/pi-tui";
|
|
14
14
|
import { BRAILLE_SPINNER_FRAMES } from "@mrclrchtr/supi-core/spinner-frames";
|
|
15
15
|
import type {
|
|
16
16
|
Diagnostic,
|
|
17
|
-
|
|
17
|
+
DiagnosticEvidenceSummary,
|
|
18
18
|
ProjectServerInfo,
|
|
19
19
|
} from "@mrclrchtr/supi-lsp/api";
|
|
20
|
-
import type {
|
|
20
|
+
import type {
|
|
21
|
+
DiagnosticCheckFile,
|
|
22
|
+
WorkspaceDiagnosticCheckReport,
|
|
23
|
+
} from "../analysis/health/check.ts";
|
|
21
24
|
import {
|
|
22
25
|
countProjectServerRouteStatuses,
|
|
23
|
-
|
|
26
|
+
formatProjectServerCompiler,
|
|
24
27
|
formatProjectServerRoot,
|
|
25
28
|
formatProjectServerStatusReason,
|
|
26
29
|
} from "../analysis/health/server-status.ts";
|
|
30
|
+
import type { WorkspaceStatusSnapshot } from "../analysis/health/status.ts";
|
|
31
|
+
import type { HealthDiagnosticEntry } from "../session/health-types.ts";
|
|
27
32
|
import { diagnosticMessageString } from "../substrate/lsp/utils.ts";
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
import {
|
|
34
|
+
CiHealthRefreshError,
|
|
35
|
+
presentDiagnosticDetails,
|
|
36
|
+
presentDiagnosticEvidence,
|
|
37
|
+
} from "./status-presentation.ts";
|
|
38
|
+
|
|
39
|
+
/** Passive health facts plus the session's active tool surface. */
|
|
40
|
+
export interface CiStatusData extends WorkspaceStatusSnapshot {
|
|
41
|
+
readonly activeTools: readonly string[];
|
|
42
|
+
readonly diagnosticCheck?: WorkspaceDiagnosticCheckReport;
|
|
43
|
+
/** Compact outcome of the latest health action, never a source of current evidence. */
|
|
44
|
+
readonly healthRefresh?: readonly string[];
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
semanticAvailable: boolean;
|
|
48
|
-
/** Whether tracked-file diagnostic counts prove the current document and workspace state. */
|
|
49
|
-
diagnosticSnapshotCurrent: boolean;
|
|
50
|
-
/** Sorted: errors desc, then warnings desc, then info desc, then hints desc. */
|
|
51
|
-
diagnostics: OutstandingDiagnosticSummaryEntry[];
|
|
52
|
-
capabilities: {
|
|
53
|
-
semantic: { kind: string; reason?: string; providerAvailable: boolean };
|
|
54
|
-
structural: { kind: string; reason?: string; providerAvailable: boolean };
|
|
55
|
-
refactorAvailable: boolean;
|
|
56
|
-
};
|
|
57
|
-
activeTools: string[];
|
|
58
|
-
/** Supplemental Capability Warnings. Undefined when fully healthy. */
|
|
59
|
-
capabilityWarnings?: CapabilityWarningReport;
|
|
47
|
+
/** Full messages and file-specific evidence from one passive diagnostic snapshot. */
|
|
48
|
+
export interface CiDiagnosticDetails {
|
|
49
|
+
readonly evidence: DiagnosticEvidenceSummary;
|
|
50
|
+
readonly entries: readonly {
|
|
51
|
+
readonly file: string;
|
|
52
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
53
|
+
}[];
|
|
60
54
|
}
|
|
61
55
|
|
|
62
|
-
/**
|
|
63
|
-
export type DiagFetcher = (
|
|
64
|
-
maxSeverity: number,
|
|
65
|
-
) =>
|
|
66
|
-
| Array<{ file: string; diagnostics: Diagnostic[] }>
|
|
67
|
-
| Promise<Array<{ file: string; diagnostics: Diagnostic[] }>>;
|
|
68
|
-
|
|
56
|
+
/** Dependencies owned by one terminal interaction. Reload is passive, not LSP recovery. */
|
|
69
57
|
export interface CiStatusDialogDeps {
|
|
70
|
-
theme:
|
|
58
|
+
theme: Pick<Theme, "fg" | "bold">;
|
|
71
59
|
done: () => void;
|
|
72
|
-
tui: { requestRender: () => void };
|
|
73
|
-
|
|
74
|
-
fetchDetailedDiagnostics?:
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
tui: { terminal: { rows: number }; requestRender: () => void };
|
|
61
|
+
keybindings?: KeybindingsManager;
|
|
62
|
+
fetchDetailedDiagnostics?: () => CiDiagnosticDetails | Promise<CiDiagnosticDetails>;
|
|
63
|
+
onRefresh?: (signal: AbortSignal) => Promise<CiStatusData>;
|
|
64
|
+
onCheck?: (signal: AbortSignal) => Promise<CiStatusData>;
|
|
65
|
+
onHealth?: (signal: AbortSignal) => Promise<CiStatusData>;
|
|
77
66
|
}
|
|
78
67
|
|
|
79
|
-
|
|
68
|
+
type DiagnosticFile = DiagnosticCheckFile & HealthDiagnosticEntry;
|
|
69
|
+
|
|
70
|
+
type DetailState =
|
|
71
|
+
| { kind: "loading" }
|
|
72
|
+
| { kind: "ready"; diagnostics: readonly Diagnostic[]; evidenceLabel: string }
|
|
73
|
+
| { kind: "error"; message: string };
|
|
80
74
|
const MAX_INLINE_MESSAGES = 5;
|
|
81
75
|
const MAX_OPEN_FILES_SHOWN = 3;
|
|
82
|
-
const
|
|
83
|
-
|
|
76
|
+
const FRAME_ROWS = 6;
|
|
77
|
+
const ACTION_LABELS = {
|
|
78
|
+
reload: { name: "Reload", progress: "reloading" },
|
|
79
|
+
check: { name: "Check", progress: "checking" },
|
|
80
|
+
health: { name: "Refresh health", progress: "refreshing health" },
|
|
81
|
+
};
|
|
82
|
+
const STATUS_ACTIONS = [
|
|
83
|
+
"tui.select.cancel",
|
|
84
|
+
"tui.select.up",
|
|
85
|
+
"tui.select.down",
|
|
86
|
+
"tui.select.confirm",
|
|
87
|
+
"tui.select.pageUp",
|
|
88
|
+
"tui.select.pageDown",
|
|
89
|
+
"tui.input.tab",
|
|
90
|
+
] as const;
|
|
91
|
+
|
|
92
|
+
/** A bounded inspector with file-keyed selection and interaction-local asynchronous work. */
|
|
84
93
|
export class CiStatusDialog {
|
|
85
|
-
private
|
|
86
|
-
private
|
|
87
|
-
private
|
|
94
|
+
private files: readonly DiagnosticFile[];
|
|
95
|
+
private selectedFile: string | undefined;
|
|
96
|
+
private expandedFile: string | undefined;
|
|
97
|
+
private details: DetailState | undefined;
|
|
98
|
+
private detailGeneration = 0;
|
|
99
|
+
private refreshGeneration = 0;
|
|
100
|
+
private refreshing = false;
|
|
101
|
+
private refreshError: string | undefined;
|
|
102
|
+
private healthRefresh: readonly string[] | undefined;
|
|
103
|
+
private refreshAction: "reload" | "check" | "health" = "reload";
|
|
104
|
+
private refreshController: AbortController | undefined;
|
|
105
|
+
private disposed = false;
|
|
106
|
+
private spinner: ReturnType<typeof setInterval> | undefined;
|
|
107
|
+
private spinnerFrame = 0;
|
|
88
108
|
private cachedWidth: number | undefined;
|
|
109
|
+
private cachedHeight: number | undefined;
|
|
89
110
|
private cachedLines: string[] | undefined;
|
|
90
|
-
private
|
|
91
|
-
private
|
|
92
|
-
private
|
|
111
|
+
private bodyLines: string[] = [];
|
|
112
|
+
private selectedRow = 0;
|
|
113
|
+
private expandedRows = 1;
|
|
114
|
+
private revealSelection = false;
|
|
115
|
+
private followingSelection = false;
|
|
116
|
+
// A late check may update data, but must not replace newer navigation intent.
|
|
117
|
+
private navigationGeneration = 0;
|
|
118
|
+
private readonly scroll = new ScrollView({ render: () => this.bodyLines, invalidate() {} });
|
|
119
|
+
private readonly keybindings: KeybindingsManager;
|
|
93
120
|
|
|
94
121
|
constructor(
|
|
95
122
|
private data: CiStatusData,
|
|
96
|
-
deps: CiStatusDialogDeps,
|
|
123
|
+
private readonly deps: CiStatusDialogDeps,
|
|
97
124
|
) {
|
|
98
|
-
this.
|
|
99
|
-
this.
|
|
100
|
-
this.
|
|
101
|
-
this.
|
|
102
|
-
this.onRefresh = deps.onRefresh;
|
|
125
|
+
this.files = diagnosticFiles(data);
|
|
126
|
+
this.healthRefresh = data.healthRefresh;
|
|
127
|
+
this.selectedFile = this.files[0]?.file;
|
|
128
|
+
this.keybindings = deps.keybindings ?? getKeybindings();
|
|
103
129
|
}
|
|
104
130
|
|
|
105
|
-
/**
|
|
131
|
+
/** Invalidate in-flight work before releasing the spinner and terminal interaction. */
|
|
106
132
|
dispose(): void {
|
|
133
|
+
this.disposed = true;
|
|
134
|
+
this.detailGeneration++;
|
|
135
|
+
this.refreshGeneration++;
|
|
136
|
+
this.refreshController?.abort();
|
|
107
137
|
this.stopSpinner();
|
|
108
138
|
}
|
|
109
139
|
|
|
110
140
|
render(width: number): string[] {
|
|
111
|
-
|
|
141
|
+
const height = Math.max(1, Math.floor(this.deps.tui.terminal.rows * 0.85));
|
|
142
|
+
if (this.cachedLines && this.cachedWidth === width && this.cachedHeight === height)
|
|
112
143
|
return this.cachedLines;
|
|
144
|
+
if (height <= FRAME_ROWS)
|
|
145
|
+
return [truncateToWidth(`CI · ${this.keyLabel("tui.select.cancel")} close`, width)];
|
|
146
|
+
const bodyHeight = height - FRAME_ROWS;
|
|
147
|
+
const resized =
|
|
148
|
+
this.cachedHeight !== undefined &&
|
|
149
|
+
(this.cachedHeight !== height || this.cachedWidth !== width);
|
|
150
|
+
this.bodyLines = this.renderBody(width);
|
|
151
|
+
this.scroll.updateLayout(this.bodyLines.length, bodyHeight, () =>
|
|
152
|
+
this.deps.tui.requestRender(),
|
|
153
|
+
);
|
|
154
|
+
if (this.revealSelection || (resized && this.followingSelection)) {
|
|
155
|
+
const end = this.selectedRow + Math.min(this.expandedRows, bodyHeight) - 1;
|
|
156
|
+
if (this.selectedRow < this.scroll.scrollTop) this.scroll.scrollTo(this.selectedRow);
|
|
157
|
+
else if (end >= this.scroll.scrollTop + bodyHeight)
|
|
158
|
+
this.scroll.scrollTo(end - bodyHeight + 1);
|
|
113
159
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
this.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
160
|
+
this.revealSelection = false;
|
|
161
|
+
const t = this.deps.theme;
|
|
162
|
+
const border = new DynamicBorder((s) => t.fg("accent", s)).render(width)[0] ?? "";
|
|
163
|
+
const position =
|
|
164
|
+
this.bodyLines.length > bodyHeight
|
|
165
|
+
? ` · ${this.scroll.scrollTop + 1}–${Math.min(this.scroll.scrollTop + bodyHeight, this.bodyLines.length)}/${this.bodyLines.length}`
|
|
166
|
+
: "";
|
|
167
|
+
// Pi's overlay adapter only calls render(width), not the fullscreen layout engine.
|
|
168
|
+
// ScrollView owns offsets/clamping; apply its viewport explicitly for this adapter.
|
|
169
|
+
const lines = [
|
|
170
|
+
border,
|
|
171
|
+
t.fg("accent", t.bold("◆ Code Intelligence")) + t.fg("dim", " · /supi-ci-status"),
|
|
172
|
+
this.summaryLine(),
|
|
173
|
+
...this.scroll.render(width).slice(this.scroll.scrollTop, this.scroll.scrollTop + bodyHeight),
|
|
174
|
+
t.fg("dim", this.controlHints()),
|
|
175
|
+
t.fg(
|
|
176
|
+
"dim",
|
|
177
|
+
`${this.keyLabel("tui.select.up")}/${this.keyLabel("tui.select.down")} scroll · ${this.fileNavigationHint()} · ${this.keyLabel("tui.select.pageUp")}/${this.keyLabel("tui.select.pageDown")} page · home/end${position}`,
|
|
178
|
+
),
|
|
179
|
+
border,
|
|
180
|
+
].map((line) => truncateToWidth(line, width));
|
|
131
181
|
this.cachedWidth = width;
|
|
182
|
+
this.cachedHeight = height;
|
|
132
183
|
this.cachedLines = lines;
|
|
133
184
|
return lines;
|
|
134
185
|
}
|
|
135
186
|
|
|
136
187
|
invalidate(): void {
|
|
137
|
-
this.cachedWidth = undefined;
|
|
138
188
|
this.cachedLines = undefined;
|
|
139
189
|
}
|
|
140
190
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.
|
|
146
|
-
this.done();
|
|
191
|
+
handleInput(input: string): boolean {
|
|
192
|
+
if (this.disposed) return false;
|
|
193
|
+
if (this.keybindings.matches(input, "tui.select.cancel")) {
|
|
194
|
+
this.dispose();
|
|
195
|
+
this.deps.done();
|
|
147
196
|
return true;
|
|
148
197
|
}
|
|
198
|
+
return (
|
|
199
|
+
this.handleScrollInput(input) ||
|
|
200
|
+
this.handleFileInput(input) ||
|
|
201
|
+
this.handleDiagnosticActionInput(input) ||
|
|
202
|
+
this.handleShortcutInput(input)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
149
205
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
206
|
+
private handleDiagnosticActionInput(input: string): boolean {
|
|
207
|
+
if (this.hasConfiguredAction(input)) return false;
|
|
208
|
+
let action: "check" | "health";
|
|
209
|
+
if (input === "c" || matchesKey(input, "f5")) action = "check";
|
|
210
|
+
else if (input === "h" || matchesKey(input, "f6")) action = "health";
|
|
211
|
+
else return false;
|
|
212
|
+
if (!(action === "check" ? this.deps.onCheck : this.deps.onHealth)) return false;
|
|
213
|
+
void this.reload(action);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
158
216
|
|
|
159
|
-
|
|
160
|
-
|
|
217
|
+
private handleShortcutInput(input: string): boolean {
|
|
218
|
+
if (input === "r" && this.deps.onRefresh) {
|
|
219
|
+
void this.reload();
|
|
161
220
|
return true;
|
|
162
221
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if ((matchesKey(data, Key.up) || data === "k") && this.selectedFileIdx > 0) {
|
|
168
|
-
this.selectedFileIdx--;
|
|
169
|
-
this.invalidate();
|
|
170
|
-
this.tui.requestRender();
|
|
222
|
+
if (input === "a") {
|
|
223
|
+
this.collapse();
|
|
224
|
+
this.changed();
|
|
171
225
|
return true;
|
|
172
226
|
}
|
|
227
|
+
if (input === "j" || input === "k") {
|
|
228
|
+
this.scroll.scrollBy(input === "k" ? -1 : 1);
|
|
229
|
+
} else if (matchesKey(input, Key.home)) this.scroll.scrollToStart();
|
|
230
|
+
else if (matchesKey(input, Key.end)) this.scroll.scrollToEnd();
|
|
231
|
+
else return false;
|
|
232
|
+
this.scrolled();
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
173
235
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
236
|
+
private handleScrollInput(input: string): boolean {
|
|
237
|
+
const page = Math.max(1, this.scroll.viewportHeight - 1);
|
|
238
|
+
let lines: number;
|
|
239
|
+
if (this.keybindings.matches(input, "tui.select.up")) lines = -1;
|
|
240
|
+
else if (this.keybindings.matches(input, "tui.select.down")) lines = 1;
|
|
241
|
+
else if (this.keybindings.matches(input, "tui.select.pageUp")) lines = -page;
|
|
242
|
+
else if (this.keybindings.matches(input, "tui.select.pageDown")) lines = page;
|
|
243
|
+
else return false;
|
|
244
|
+
this.scroll.scrollBy(lines);
|
|
245
|
+
this.scrolled();
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
180
248
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
this.stopSpinner();
|
|
189
|
-
} else {
|
|
190
|
-
this.expandedFileIdx = this.selectedFileIdx;
|
|
191
|
-
this.expandedDiagnostics = null;
|
|
192
|
-
void this.loadDetailedDiagnostics();
|
|
193
|
-
}
|
|
194
|
-
this.invalidate();
|
|
195
|
-
this.tui.requestRender();
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
249
|
+
/** Manual scrolling owns the viewport until diagnostic-file navigation resumes. */
|
|
250
|
+
private scrolled(): void {
|
|
251
|
+
this.navigationGeneration++;
|
|
252
|
+
this.followingSelection = false;
|
|
253
|
+
this.revealSelection = false;
|
|
254
|
+
this.changed();
|
|
255
|
+
}
|
|
198
256
|
|
|
257
|
+
private handleFileInput(input: string): boolean {
|
|
258
|
+
if (this.keybindings.matches(input, "tui.select.confirm")) return this.expandSelection();
|
|
259
|
+
if (this.keybindings.matches(input, "tui.input.tab")) return this.moveSelection(1);
|
|
260
|
+
if (matchesKey(input, Key.shift("tab"))) return this.moveSelection(-1);
|
|
261
|
+
if (matchesKey(input, Key.space)) return this.expandSelection();
|
|
199
262
|
return false;
|
|
200
263
|
}
|
|
201
264
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (this.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
this.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
265
|
+
private expandSelection(): boolean {
|
|
266
|
+
if (!this.selectedFile) return true;
|
|
267
|
+
this.navigationGeneration++;
|
|
268
|
+
if (this.expandedFile === this.selectedFile) this.collapse();
|
|
269
|
+
else {
|
|
270
|
+
this.collapse();
|
|
271
|
+
this.expandedFile = this.selectedFile;
|
|
272
|
+
void this.loadDetails(this.selectedFile);
|
|
273
|
+
}
|
|
274
|
+
this.followingSelection = true;
|
|
275
|
+
this.revealSelection = true;
|
|
276
|
+
this.changed();
|
|
277
|
+
return true;
|
|
213
278
|
}
|
|
214
279
|
|
|
215
|
-
private
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
this.
|
|
280
|
+
private moveSelection(direction: number): boolean {
|
|
281
|
+
this.navigationGeneration++;
|
|
282
|
+
const files = this.files;
|
|
283
|
+
const index = files.findIndex((entry) => entry.file === this.selectedFile);
|
|
284
|
+
const next = files[Math.max(0, Math.min(files.length - 1, index + direction))];
|
|
285
|
+
if (next) this.selectedFile = next.file;
|
|
286
|
+
this.followingSelection = true;
|
|
287
|
+
this.revealSelection = true;
|
|
288
|
+
this.changed();
|
|
289
|
+
return true;
|
|
221
290
|
}
|
|
222
291
|
|
|
223
|
-
|
|
292
|
+
private collapse(): void {
|
|
293
|
+
this.detailGeneration++;
|
|
294
|
+
this.expandedFile = undefined;
|
|
295
|
+
this.details = undefined;
|
|
296
|
+
this.updateSpinner();
|
|
297
|
+
}
|
|
224
298
|
|
|
225
|
-
private async
|
|
226
|
-
|
|
227
|
-
|
|
299
|
+
private async loadDetails(file: string): Promise<void> {
|
|
300
|
+
const fetch = this.deps.fetchDetailedDiagnostics;
|
|
301
|
+
if (!fetch) {
|
|
302
|
+
this.details = { kind: "error", message: "Diagnostic details are unavailable" };
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const generation = ++this.detailGeneration;
|
|
306
|
+
this.details = { kind: "loading" };
|
|
307
|
+
this.changed();
|
|
228
308
|
try {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
309
|
+
const result = await fetch();
|
|
310
|
+
if (this.disposed || generation !== this.detailGeneration) return;
|
|
311
|
+
const entry = result.entries.find(
|
|
312
|
+
(entry) =>
|
|
313
|
+
resolve(this.data.workspaceRoot, entry.file) === resolve(this.data.workspaceRoot, file),
|
|
314
|
+
);
|
|
315
|
+
this.details = {
|
|
316
|
+
kind: "ready",
|
|
317
|
+
diagnostics: entry?.diagnostics ?? [],
|
|
318
|
+
evidenceLabel: presentDiagnosticDetails(result.evidence, this.data.workspaceRoot, file),
|
|
319
|
+
};
|
|
320
|
+
} catch (error) {
|
|
321
|
+
if (this.disposed || generation !== this.detailGeneration) return;
|
|
322
|
+
this.details = { kind: "error", message: errorText(error) };
|
|
232
323
|
}
|
|
233
|
-
this.
|
|
234
|
-
this.selectedFileIdx,
|
|
235
|
-
Math.max(0, this.data.diagnostics.length - 1),
|
|
236
|
-
);
|
|
237
|
-
this.expandedFileIdx = null;
|
|
238
|
-
this.expandedDiagnostics = null;
|
|
239
|
-
this.invalidate();
|
|
240
|
-
this.tui.requestRender();
|
|
324
|
+
if (!this.disposed && generation === this.detailGeneration) this.changed();
|
|
241
325
|
}
|
|
242
326
|
|
|
243
|
-
private async
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
327
|
+
private async reload(action: "reload" | "check" | "health" = "reload"): Promise<void> {
|
|
328
|
+
const collect = {
|
|
329
|
+
check: this.deps.onCheck,
|
|
330
|
+
health: this.deps.onHealth,
|
|
331
|
+
reload: this.deps.onRefresh,
|
|
332
|
+
}[action];
|
|
333
|
+
if (this.refreshing || !collect) return;
|
|
334
|
+
const generation = ++this.refreshGeneration;
|
|
335
|
+
const navigation = this.navigationGeneration;
|
|
336
|
+
this.refreshController = new AbortController();
|
|
337
|
+
this.refreshAction = action;
|
|
338
|
+
this.refreshing = true;
|
|
339
|
+
this.refreshError = undefined;
|
|
340
|
+
this.healthRefresh = undefined;
|
|
341
|
+
this.collapse();
|
|
342
|
+
this.changed();
|
|
248
343
|
try {
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
this.
|
|
252
|
-
} catch {
|
|
253
|
-
this.
|
|
254
|
-
|
|
255
|
-
this.
|
|
344
|
+
const data = await collect(this.refreshController.signal);
|
|
345
|
+
if (this.disposed || generation !== this.refreshGeneration) return;
|
|
346
|
+
this.acceptSnapshot(data, action === "check" && navigation === this.navigationGeneration);
|
|
347
|
+
} catch (error) {
|
|
348
|
+
if (this.disposed || generation !== this.refreshGeneration) return;
|
|
349
|
+
this.refreshError = errorText(error);
|
|
350
|
+
if (error instanceof CiHealthRefreshError) this.healthRefresh = error.healthRefresh;
|
|
351
|
+
}
|
|
352
|
+
if (!this.disposed && generation === this.refreshGeneration) {
|
|
353
|
+
this.refreshing = false;
|
|
354
|
+
this.refreshController = undefined;
|
|
355
|
+
this.changed();
|
|
256
356
|
}
|
|
257
|
-
this.invalidate();
|
|
258
|
-
this.tui.requestRender();
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// ── Section builders ──────────────────────────────────────────────
|
|
262
|
-
|
|
263
|
-
private renderHeader(): string {
|
|
264
|
-
const accent = this.theme.fg("accent", this.theme.bold("◆ Code Intelligence"));
|
|
265
|
-
const hint = this.theme.fg("dim", " /supi-ci-status toggles · ↑↓ nav · enter expand");
|
|
266
|
-
return truncateToWidth(accent + hint, 1000);
|
|
267
357
|
}
|
|
268
358
|
|
|
269
|
-
private
|
|
270
|
-
|
|
359
|
+
private acceptSnapshot(data: CiStatusData, check: boolean): void {
|
|
360
|
+
this.data = data;
|
|
361
|
+
this.healthRefresh = data.healthRefresh;
|
|
362
|
+
this.files = diagnosticFiles(data);
|
|
363
|
+
if (!this.files.some((entry) => entry.file === this.selectedFile))
|
|
364
|
+
this.selectedFile = this.files[0]?.file;
|
|
365
|
+
// Collection closed the previous expansion at start; any current one is newer user intent.
|
|
366
|
+
const expanded = this.expandedFile;
|
|
367
|
+
this.collapse();
|
|
368
|
+
if (expanded && this.files.some((entry) => entry.file === expanded)) {
|
|
369
|
+
this.expandedFile = expanded;
|
|
370
|
+
void this.loadDetails(expanded);
|
|
371
|
+
}
|
|
372
|
+
if (check) {
|
|
373
|
+
const firstChecked = data.diagnosticCheck?.files[0];
|
|
374
|
+
if (firstChecked) this.selectedFile = resolve(data.workspaceRoot, firstChecked.file);
|
|
375
|
+
this.followingSelection = true;
|
|
376
|
+
}
|
|
377
|
+
this.revealSelection = this.followingSelection;
|
|
271
378
|
}
|
|
272
379
|
|
|
273
|
-
private
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
this.structuralSummaryPart(),
|
|
279
|
-
];
|
|
280
|
-
const joined =
|
|
281
|
-
parts.length > 0
|
|
282
|
-
? parts.join(this.theme.fg("dim", " · "))
|
|
283
|
-
: this.theme.fg("dim", "(no data)");
|
|
284
|
-
return truncateToWidth(joined, width);
|
|
380
|
+
private changed(): void {
|
|
381
|
+
if (this.disposed) return;
|
|
382
|
+
this.updateSpinner();
|
|
383
|
+
this.invalidate();
|
|
384
|
+
this.deps.tui.requestRender();
|
|
285
385
|
}
|
|
286
386
|
|
|
287
|
-
private
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
387
|
+
private updateSpinner(): void {
|
|
388
|
+
if (this.disposed || (!this.refreshing && this.details?.kind !== "loading")) {
|
|
389
|
+
this.stopSpinner();
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (this.spinner) return;
|
|
393
|
+
this.spinner = setInterval(() => {
|
|
394
|
+
this.spinnerFrame++;
|
|
395
|
+
this.invalidate();
|
|
396
|
+
this.deps.tui.requestRender();
|
|
397
|
+
}, 80);
|
|
292
398
|
}
|
|
293
399
|
|
|
294
|
-
private
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return [
|
|
298
|
-
errors > 0 ? this.theme.fg("error", `${errors} error${errors === 1 ? "" : "s"}`) : null,
|
|
299
|
-
warnings > 0
|
|
300
|
-
? this.theme.fg("warning", `${warnings} warning${warnings === 1 ? "" : "s"}`)
|
|
301
|
-
: null,
|
|
302
|
-
].filter((part): part is string => part !== null);
|
|
400
|
+
private stopSpinner(): void {
|
|
401
|
+
if (this.spinner) clearInterval(this.spinner);
|
|
402
|
+
this.spinner = undefined;
|
|
303
403
|
}
|
|
304
404
|
|
|
305
|
-
private
|
|
405
|
+
private summaryLine(): string {
|
|
406
|
+
const t = this.deps.theme;
|
|
407
|
+
if (this.refreshError) return t.fg("error", this.refreshFailure());
|
|
408
|
+
const ready = this.data.servers.filter(
|
|
409
|
+
(server) => server.status === "running" && server.ready,
|
|
410
|
+
).length;
|
|
411
|
+
const starting = this.data.servers.filter(
|
|
412
|
+
(server) => server.status === "running" && !server.ready,
|
|
413
|
+
).length;
|
|
306
414
|
const counts = countProjectServerRouteStatuses(this.data.servers);
|
|
415
|
+
const entries = this.data.diagnostics.entries;
|
|
416
|
+
const errors = entries.reduce((sum, entry) => sum + entry.errors, 0);
|
|
417
|
+
const warnings = entries.reduce((sum, entry) => sum + entry.warnings, 0);
|
|
307
418
|
return [
|
|
308
|
-
|
|
309
|
-
|
|
419
|
+
`${ready} ready${starting ? ` · ${starting} starting` : ""}`,
|
|
420
|
+
errors ? t.fg("error", countLabel(errors, "error")) : "",
|
|
421
|
+
warnings ? t.fg("warning", countLabel(warnings, "warning")) : "",
|
|
422
|
+
counts.recovering
|
|
423
|
+
? t.fg(
|
|
310
424
|
"warning",
|
|
311
425
|
`${counts.recovering} route${counts.recovering === 1 ? "" : "s"} recovering`,
|
|
312
426
|
)
|
|
313
|
-
:
|
|
314
|
-
counts.error
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
? this.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
].filter((part): part is string => part !== null);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
private structuralSummaryPart(): string {
|
|
327
|
-
const kind = this.data.capabilities.structural.kind;
|
|
328
|
-
if (kind === "ready") return this.theme.fg("success", "✓ ts ready");
|
|
329
|
-
if (kind === "pending") return this.theme.fg("dim", "ts pending…");
|
|
330
|
-
return this.theme.fg("error", "ts unavailable");
|
|
427
|
+
: "",
|
|
428
|
+
counts.error ? t.fg("error", countLabel(counts.error, "route error")) : "",
|
|
429
|
+
counts.unavailable ? t.fg("warning", `${counts.unavailable} routes unavailable`) : "",
|
|
430
|
+
this.data.diagnostics.kind === "partial" ? t.fg("warning", "partial snapshot") : "",
|
|
431
|
+
this.refreshing
|
|
432
|
+
? t.fg("accent", `${this.frame()} ${ACTION_LABELS[this.refreshAction].progress}…`)
|
|
433
|
+
: "",
|
|
434
|
+
]
|
|
435
|
+
.filter(Boolean)
|
|
436
|
+
.join(t.fg("dim", " · "));
|
|
331
437
|
}
|
|
332
438
|
|
|
333
|
-
private
|
|
334
|
-
const t = this.theme;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
439
|
+
private renderBody(width: number): string[] {
|
|
440
|
+
const t = this.deps.theme;
|
|
441
|
+
const body = new Container();
|
|
442
|
+
const text = (value: string) => body.addChild(new Text(value, 0, 0));
|
|
443
|
+
const heading = (value: string) => text(t.fg("accent", t.bold(value)));
|
|
444
|
+
heading("Capabilities");
|
|
445
|
+
this.addCapabilities(text);
|
|
446
|
+
body.addChild(new Spacer(1));
|
|
447
|
+
if (this.healthRefresh) {
|
|
448
|
+
heading("Health action outcome");
|
|
449
|
+
for (const line of this.healthRefresh) text(` ${line}`);
|
|
450
|
+
body.addChild(new Spacer(1));
|
|
339
451
|
}
|
|
340
|
-
|
|
341
|
-
|
|
452
|
+
heading("Diagnostic files · tracked-file snapshot (not a workspace-wide check)");
|
|
453
|
+
this.addProblems(body, width, text);
|
|
454
|
+
body.addChild(new Spacer(1));
|
|
455
|
+
heading("Servers");
|
|
456
|
+
this.addServers(text);
|
|
457
|
+
if (this.data.capabilityWarnings?.hasWarnings) {
|
|
458
|
+
body.addChild(new Spacer(1));
|
|
459
|
+
heading("Capability Warnings");
|
|
460
|
+
this.addWarnings(text);
|
|
342
461
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (!this.data.serverInventoryAvailable) {
|
|
348
|
-
container.addChild(new Text(t.fg("dim", " server inventory unavailable"), 1, 0));
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
if (this.data.capabilities.semantic.kind === "disabled") {
|
|
352
|
-
container.addChild(new Text(t.fg("dim", " all language servers disabled"), 1, 0));
|
|
353
|
-
return;
|
|
462
|
+
if (this.data.activeTools.length) {
|
|
463
|
+
body.addChild(new Spacer(1));
|
|
464
|
+
heading("Tools");
|
|
465
|
+
text(this.data.activeTools.join(", "));
|
|
354
466
|
}
|
|
355
|
-
|
|
356
|
-
new Text(t.fg("dim", " no active project servers; routes may start lazily"), 1, 0),
|
|
357
|
-
);
|
|
467
|
+
return body.render(width);
|
|
358
468
|
}
|
|
359
469
|
|
|
360
|
-
private
|
|
361
|
-
const t = this.theme;
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
" " +
|
|
373
|
-
t.fg("dim", `root: ${formatProjectServerRoot(this.data.workspaceRoot, server.root)}`),
|
|
374
|
-
0,
|
|
375
|
-
0,
|
|
376
|
-
),
|
|
377
|
-
);
|
|
378
|
-
|
|
379
|
-
const fileTypes = server.fileTypes.map((f) => `.${f}`).join(" ");
|
|
380
|
-
container.addChild(new Text(t.fg("dim", ` files: ${fileTypes || "(none)"}`), 0, 0));
|
|
381
|
-
|
|
382
|
-
const statusReason = formatProjectServerStatusReason(server.statusReason);
|
|
383
|
-
if (statusReason) {
|
|
384
|
-
container.addChild(new Text(t.fg("warning", ` ${statusReason}`), 0, 0));
|
|
385
|
-
}
|
|
386
|
-
const operationSupport = formatProjectServerOperationSupport(server.operationSupport);
|
|
387
|
-
if (operationSupport) {
|
|
388
|
-
container.addChild(new Text(t.fg("dim", ` ${operationSupport}`), 0, 0));
|
|
470
|
+
private addCapabilities(text: (value: string) => void): void {
|
|
471
|
+
const t = this.deps.theme;
|
|
472
|
+
for (const [label, state] of Object.entries(this.data.capabilities)) {
|
|
473
|
+
const color =
|
|
474
|
+
state.kind === "ready" ? "success" : state.kind === "unavailable" ? "error" : "dim";
|
|
475
|
+
const reason = "reason" in state ? ` — ${state.reason}` : "";
|
|
476
|
+
text(
|
|
477
|
+
t.fg(
|
|
478
|
+
color,
|
|
479
|
+
` ${label === "semantic" ? "Semantic" : "Structural"}: ${state.kind}${reason}`,
|
|
480
|
+
),
|
|
481
|
+
);
|
|
389
482
|
}
|
|
483
|
+
text(t.fg("dim", " Refactor: negotiated per route; see Servers"));
|
|
484
|
+
}
|
|
390
485
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
486
|
+
private addProblems(body: Container, width: number, text: (value: string) => void): void {
|
|
487
|
+
this.selectedRow = body.render(width).length;
|
|
488
|
+
this.addDiagnosticEvidence(text);
|
|
489
|
+
const check = this.data.diagnosticCheck;
|
|
490
|
+
if (check) {
|
|
491
|
+
const range = check.files.length
|
|
492
|
+
? `${check.startOffset + 1}–${check.startOffset + check.files.length}`
|
|
493
|
+
: "none";
|
|
494
|
+
text(
|
|
495
|
+
` Check: files ${range} of ${check.total ?? "unknown"} eligible · ${check.remaining ?? "unknown"} remaining in pass`,
|
|
496
|
+
);
|
|
497
|
+
if (check.reason) text(this.deps.theme.fg("warning", ` ${check.reason}`));
|
|
398
498
|
}
|
|
499
|
+
if (this.refreshError) text(this.deps.theme.fg("error", this.refreshFailure()));
|
|
500
|
+
this.expandedRows = Math.max(1, body.render(width).length - this.selectedRow);
|
|
501
|
+
for (const entry of this.files) this.addProblemRow(entry, body, width);
|
|
399
502
|
}
|
|
400
503
|
|
|
401
|
-
private
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
this.
|
|
406
|
-
|
|
504
|
+
private addProblemRow(entry: DiagnosticFile, body: Container, width: number): void {
|
|
505
|
+
const text = (value: string) => body.addChild(new Text(value, 0, 0));
|
|
506
|
+
if (entry.file === this.selectedFile) this.selectedRow = body.render(width).length;
|
|
507
|
+
const indicator =
|
|
508
|
+
entry.file === this.expandedFile ? "▼" : entry.file === this.selectedFile ? "▶" : " ";
|
|
509
|
+
const label = relative(
|
|
510
|
+
this.data.workspaceRoot,
|
|
511
|
+
resolve(this.data.workspaceRoot, entry.file),
|
|
512
|
+
).replaceAll("\\", "/");
|
|
513
|
+
const counts = problemCounts(entry);
|
|
514
|
+
const status =
|
|
515
|
+
entry.status === "confirmed" && !counts ? "no errors or warnings (confirmed)" : entry.status;
|
|
516
|
+
text(`${indicator} ${label} ${[counts, status, entry.reason].filter(Boolean).join(" · ")}`);
|
|
517
|
+
if (entry.file === this.selectedFile)
|
|
518
|
+
this.expandedRows = body.render(width).length - this.selectedRow;
|
|
519
|
+
if (entry.file === this.expandedFile) {
|
|
520
|
+
const start = body.render(width).length;
|
|
521
|
+
this.addDetails(text);
|
|
522
|
+
if (entry.file === this.selectedFile) this.expandedRows += body.render(width).length - start;
|
|
407
523
|
}
|
|
408
|
-
|
|
409
|
-
new Text(t.fg("dim", " ↑↓ navigate · enter to expand · single-expand"), 1, 0),
|
|
410
|
-
);
|
|
411
|
-
|
|
412
|
-
const visible = this.data.diagnostics.slice(0, MAX_FILES_IN_LIST);
|
|
413
|
-
visible.forEach((entry, idx) => {
|
|
414
|
-
this.addProblemRow(container, entry, idx, width);
|
|
415
|
-
});
|
|
524
|
+
}
|
|
416
525
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
526
|
+
private addServers(text: (value: string) => void): void {
|
|
527
|
+
const t = this.deps.theme;
|
|
528
|
+
if (!this.data.serverInventoryAvailable) {
|
|
529
|
+
text(t.fg("dim", " server inventory unavailable"));
|
|
530
|
+
} else if (!this.data.servers.length) {
|
|
531
|
+
text(
|
|
532
|
+
t.fg(
|
|
533
|
+
"dim",
|
|
534
|
+
this.data.capabilities.semantic.kind === "disabled"
|
|
535
|
+
? " all language servers disabled"
|
|
536
|
+
: " no active project servers; routes may start lazily",
|
|
537
|
+
),
|
|
421
538
|
);
|
|
422
539
|
}
|
|
540
|
+
for (const server of this.data.servers) this.addServer(server, text);
|
|
423
541
|
}
|
|
424
542
|
|
|
425
|
-
private
|
|
426
|
-
const
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
container.addChild(new Text(t.fg("warning", " diagnostic snapshot is stale"), 1, 0));
|
|
431
|
-
} else {
|
|
432
|
-
container.addChild(new Text(t.fg("success", " ✓ no issues"), 1, 0));
|
|
543
|
+
private addWarnings(text: (value: string) => void): void {
|
|
544
|
+
for (const warning of this.data.capabilityWarnings?.warnings ?? []) {
|
|
545
|
+
const language = warning.language ? `${warning.language}: ` : "";
|
|
546
|
+
const detail = warning.detail ? ` — ${warning.detail}` : "";
|
|
547
|
+
text(this.deps.theme.fg("warning", `⚠ ${language}${warning.message}${detail}`));
|
|
433
548
|
}
|
|
434
549
|
}
|
|
435
550
|
|
|
436
|
-
private
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
): void {
|
|
442
|
-
const t = this.theme;
|
|
443
|
-
const isSelected = idx === this.selectedFileIdx;
|
|
444
|
-
const isExpanded = idx === this.expandedFileIdx;
|
|
445
|
-
|
|
446
|
-
const counts: string[] = [];
|
|
447
|
-
if (entry.errors > 0) {
|
|
448
|
-
counts.push(t.fg("error", `${entry.errors} error${entry.errors === 1 ? "" : "s"}`));
|
|
449
|
-
}
|
|
450
|
-
if (entry.warnings > 0) {
|
|
451
|
-
counts.push(t.fg("warning", `${entry.warnings} warning${entry.warnings === 1 ? "" : "s"}`));
|
|
452
|
-
}
|
|
453
|
-
const countsText = counts.length > 0 ? ` ${counts.join(" ")}` : "";
|
|
454
|
-
const indicator = isExpanded ? t.fg("accent", "▼") : isSelected ? t.fg("accent", "▶") : " ";
|
|
455
|
-
const fileColor = isSelected ? "accent" : "muted";
|
|
456
|
-
const line = `${indicator} ${t.fg(fileColor, entry.file)}${countsText}`;
|
|
457
|
-
container.addChild(new Text(truncateToWidth(line, width), 0, 0));
|
|
458
|
-
|
|
459
|
-
if (isExpanded) {
|
|
460
|
-
this.addInlineDiagnostics(container, width);
|
|
461
|
-
}
|
|
551
|
+
private addDiagnosticEvidence(text: (value: string) => void): void {
|
|
552
|
+
const presentation = presentDiagnosticEvidence(this.data.diagnostics);
|
|
553
|
+
const t = this.deps.theme;
|
|
554
|
+
if (presentation.counts) text(t.fg("dim", ` ${presentation.counts}`));
|
|
555
|
+
text(t.fg(presentation.tone, ` ${presentation.summary}`));
|
|
462
556
|
}
|
|
463
557
|
|
|
464
|
-
private
|
|
465
|
-
const t = this.theme;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
558
|
+
private addDetails(text: (value: string) => void): void {
|
|
559
|
+
const t = this.deps.theme;
|
|
560
|
+
const details = this.details;
|
|
561
|
+
if (!details) return;
|
|
562
|
+
if (details.kind === "loading") {
|
|
563
|
+
text(t.fg("accent", ` ${this.frame()} loading…`));
|
|
469
564
|
return;
|
|
470
565
|
}
|
|
471
|
-
if (
|
|
472
|
-
|
|
566
|
+
if (details.kind === "error") {
|
|
567
|
+
text(t.fg("error", ` Details unavailable: ${details.message}`));
|
|
473
568
|
return;
|
|
474
569
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
if (remaining > 0) {
|
|
486
|
-
container.addChild(new Text(t.fg("dim", ` └ +${remaining} more`), 0, 0));
|
|
570
|
+
text(t.fg("dim", ` Details: ${details.evidenceLabel}`));
|
|
571
|
+
if (!details.diagnostics.length)
|
|
572
|
+
text(t.fg("dim", " No error or warning messages in this snapshot"));
|
|
573
|
+
for (const diagnostic of details.diagnostics.slice(0, MAX_INLINE_MESSAGES)) {
|
|
574
|
+
text(
|
|
575
|
+
t.fg(
|
|
576
|
+
diagnostic.severity === 1 ? "error" : "warning",
|
|
577
|
+
` ${diagnostic.range.start.line + 1}:${diagnostic.range.start.character + 1} ${diagnosticMessageString(diagnostic)}`,
|
|
578
|
+
),
|
|
579
|
+
);
|
|
487
580
|
}
|
|
581
|
+
if (details.diagnostics.length > MAX_INLINE_MESSAGES)
|
|
582
|
+
text(t.fg("dim", ` +${details.diagnostics.length - MAX_INLINE_MESSAGES} more messages`));
|
|
488
583
|
}
|
|
489
584
|
|
|
490
|
-
private
|
|
491
|
-
const t = this.theme;
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
585
|
+
private addServer(server: ProjectServerInfo, text: (value: string) => void): void {
|
|
586
|
+
const t = this.deps.theme;
|
|
587
|
+
const state =
|
|
588
|
+
server.status === "running" ? (server.ready ? "ready" : "starting") : server.status;
|
|
589
|
+
text(
|
|
590
|
+
t.fg(
|
|
591
|
+
state === "ready" ? "success" : state === "error" ? "error" : "warning",
|
|
592
|
+
` ${server.name}: ${state} · root: ${formatProjectServerRoot(this.data.workspaceRoot, server.root)}`,
|
|
593
|
+
),
|
|
594
|
+
);
|
|
595
|
+
text(
|
|
596
|
+
t.fg("dim", ` files: ${server.fileTypes.map((type) => `.${type}`).join(" ") || "(none)"}`),
|
|
499
597
|
);
|
|
598
|
+
const compiler = formatProjectServerCompiler(server.typescript);
|
|
599
|
+
if (compiler) text(t.fg("dim", ` ${compiler}`));
|
|
600
|
+
if (server.failureMessage) text(t.fg("warning", ` ${server.failureMessage}`));
|
|
601
|
+
const reason = formatProjectServerStatusReason(server.statusReason);
|
|
602
|
+
if (reason) text(t.fg("warning", ` ${reason}`));
|
|
603
|
+
const shown = server.openFiles.slice(0, MAX_OPEN_FILES_SHOWN);
|
|
604
|
+
text(
|
|
605
|
+
t.fg(
|
|
606
|
+
"dim",
|
|
607
|
+
` open: ${shown.join(", ") || "(none)"}${server.openFiles.length > shown.length ? ` +${server.openFiles.length - shown.length} more` : ""}`,
|
|
608
|
+
),
|
|
609
|
+
);
|
|
610
|
+
this.addOperationSupport(server, text);
|
|
500
611
|
}
|
|
501
612
|
|
|
502
|
-
private
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
);
|
|
613
|
+
private addOperationSupport(server: ProjectServerInfo, text: (value: string) => void): void {
|
|
614
|
+
const t = this.deps.theme;
|
|
615
|
+
if (!server.operationSupport || !Object.keys(server.operationSupport).length)
|
|
616
|
+
text(t.fg("dim", " Refactor support: not negotiated"));
|
|
617
|
+
for (const [operation, support] of Object.entries(server.operationSupport ?? {})) {
|
|
618
|
+
text(
|
|
619
|
+
t.fg(
|
|
620
|
+
"dim",
|
|
621
|
+
` ${operation}: server ${support.server}; SuPi ${support.supi}${support.reason ? ` — ${support.reason}` : ""}`,
|
|
622
|
+
),
|
|
623
|
+
);
|
|
624
|
+
}
|
|
515
625
|
}
|
|
516
626
|
|
|
517
|
-
private
|
|
518
|
-
|
|
519
|
-
|
|
627
|
+
private hasConfiguredAction(input: string): boolean {
|
|
628
|
+
return STATUS_ACTIONS.some((action) => this.keybindings.matches(input, action));
|
|
629
|
+
}
|
|
520
630
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
631
|
+
private fileNavigationHint(): string {
|
|
632
|
+
const previous = this.hasConfiguredAction("\x1b[Z") ? "" : "/⇧tab";
|
|
633
|
+
return `${this.keyLabel("tui.input.tab")}${previous} files`;
|
|
634
|
+
}
|
|
524
635
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
|
|
636
|
+
private checkShortcut() {
|
|
637
|
+
return (
|
|
638
|
+
[
|
|
639
|
+
{ input: "c", label: "c" },
|
|
640
|
+
{ input: "\x1b[15~", label: "F5" },
|
|
641
|
+
] as const
|
|
642
|
+
).find(({ input }) => !this.hasConfiguredAction(input));
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
private healthShortcut() {
|
|
646
|
+
return (
|
|
647
|
+
[
|
|
648
|
+
{ input: "h", label: "h" },
|
|
649
|
+
{ input: "\x1b[17~", label: "F6" },
|
|
650
|
+
] as const
|
|
651
|
+
).find(({ input }) => !this.hasConfiguredAction(input));
|
|
533
652
|
}
|
|
534
653
|
|
|
535
|
-
private
|
|
536
|
-
|
|
537
|
-
if (this.data.activeTools.length === 0) return;
|
|
538
|
-
container.addChild(new Spacer(1));
|
|
539
|
-
container.addChild(new Text(t.fg("accent", t.bold(" Tools")), 1, 0));
|
|
540
|
-
const label = ` ${this.data.activeTools.map((tool) => t.fg("text", tool)).join(t.fg("dim", ", "))}`;
|
|
541
|
-
const truncated = truncateTextForInline(label, width - 4);
|
|
542
|
-
container.addChild(new Text(truncated, 0, 0));
|
|
543
|
-
container.addChild(new Spacer(1));
|
|
654
|
+
private refreshFailure(): string {
|
|
655
|
+
return `${ACTION_LABELS[this.refreshAction].name} failed: ${this.refreshError}`;
|
|
544
656
|
}
|
|
545
657
|
|
|
546
|
-
private
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
658
|
+
private controlHints(): string {
|
|
659
|
+
const checkKey = this.checkShortcut();
|
|
660
|
+
return [
|
|
661
|
+
`${this.keyLabel("tui.select.cancel")} close`,
|
|
662
|
+
this.deps.onCheck ? `${checkKey?.label ?? "unbound"} check` : "",
|
|
663
|
+
this.deps.onHealth ? `${this.healthShortcut()?.label ?? "unbound"} Refresh health` : "",
|
|
664
|
+
`${this.keyLabel("tui.select.confirm")} expand`,
|
|
665
|
+
this.deps.onRefresh && !this.hasConfiguredAction("r") ? "r reload" : "",
|
|
666
|
+
!this.hasConfiguredAction("a") ? "a collapse" : "",
|
|
667
|
+
]
|
|
668
|
+
.filter(Boolean)
|
|
669
|
+
.join(" · ");
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
private keyLabel(action: Parameters<KeybindingsManager["getKeys"]>[0]): string {
|
|
673
|
+
const key = this.keybindings.getKeys(action)[0];
|
|
674
|
+
const labels: Record<string, string> = {
|
|
675
|
+
escape: "esc",
|
|
676
|
+
up: "↑",
|
|
677
|
+
down: "↓",
|
|
678
|
+
pageUp: "PgUp",
|
|
679
|
+
pageDown: "PgDn",
|
|
680
|
+
};
|
|
681
|
+
return key ? (labels[key] ?? key) : "unbound";
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
private frame(): string {
|
|
685
|
+
return BRAILLE_SPINNER_FRAMES[this.spinnerFrame % BRAILLE_SPINNER_FRAMES.length] ?? "…";
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/** Join per-file evidence with problem counts; an absent problem row does not prove clean. */
|
|
690
|
+
function diagnosticFiles(data: CiStatusData): DiagnosticFile[] {
|
|
691
|
+
const rows = new Map<string, DiagnosticFile>();
|
|
692
|
+
const add = (entry: DiagnosticCheckFile, counts?: HealthDiagnosticEntry) => {
|
|
693
|
+
const file = resolve(data.workspaceRoot, entry.file);
|
|
694
|
+
const existing = rows.get(file);
|
|
695
|
+
rows.set(file, { errors: 0, warnings: 0, ...existing, ...counts, ...entry, file });
|
|
696
|
+
};
|
|
697
|
+
for (const entry of data.diagnostics.entries)
|
|
698
|
+
add({ file: entry.file, status: "unconfirmed" }, entry);
|
|
699
|
+
if (data.diagnostics.kind !== "not-requested") {
|
|
700
|
+
for (const document of data.diagnostics.evidence.documents) add(document);
|
|
701
|
+
}
|
|
702
|
+
for (const entry of data.diagnosticCheck?.files ?? []) add(entry);
|
|
703
|
+
return [...rows.values()];
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
function problemCounts(entry: HealthDiagnosticEntry): string {
|
|
707
|
+
return [
|
|
708
|
+
entry.errors ? countLabel(entry.errors, "error") : "",
|
|
709
|
+
entry.warnings ? countLabel(entry.warnings, "warning") : "",
|
|
710
|
+
]
|
|
711
|
+
.filter(Boolean)
|
|
712
|
+
.join(" · ");
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function countLabel(count: number, label: string): string {
|
|
716
|
+
return `${count} ${label}${count === 1 ? "" : "s"}`;
|
|
551
717
|
}
|
|
552
718
|
|
|
553
|
-
function
|
|
554
|
-
|
|
555
|
-
return truncateToWidth(text, Math.max(8, maxWidth), "…");
|
|
719
|
+
function errorText(error: unknown): string {
|
|
720
|
+
return error instanceof Error ? error.message : String(error);
|
|
556
721
|
}
|
|
557
722
|
|
|
558
|
-
/**
|
|
559
|
-
* Factory for use with `ctx.ui.custom()`.
|
|
560
|
-
*/
|
|
723
|
+
/** Construct a fresh, disposable inspector for ctx.ui.custom(). */
|
|
561
724
|
export function createCiStatusDialog(data: CiStatusData, deps: CiStatusDialogDeps): CiStatusDialog {
|
|
562
725
|
return new CiStatusDialog(data, deps);
|
|
563
726
|
}
|