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