@pellux/goodvibes-tui 1.0.0 → 1.7.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.
Files changed (209) hide show
  1. package/CHANGELOG.md +130 -127
  2. package/README.md +32 -14
  3. package/docs/foundation-artifacts/operator-contract.json +1 -1
  4. package/package.json +2 -2
  5. package/src/cli/ensure-goodvibes-gitignore.ts +32 -0
  6. package/src/cli/entrypoint.ts +2 -0
  7. package/src/core/alert-gating.ts +67 -0
  8. package/src/core/approval-alert.ts +72 -0
  9. package/src/core/budget-breach-notifier.ts +106 -0
  10. package/src/core/conversation-rendering.ts +19 -0
  11. package/src/core/conversation.ts +58 -0
  12. package/src/core/focus-tracker.ts +41 -0
  13. package/src/core/long-task-notifier.ts +33 -6
  14. package/src/core/stream-event-wiring.ts +104 -2
  15. package/src/core/stream-stall-watchdog.ts +41 -17
  16. package/src/core/system-message-router.ts +37 -51
  17. package/src/core/turn-cancellation.ts +20 -0
  18. package/src/core/turn-event-wiring.ts +64 -3
  19. package/src/export/cost-utils.ts +126 -8
  20. package/src/input/command-registry.ts +54 -1
  21. package/src/input/commands/checkpoint-runtime.ts +280 -0
  22. package/src/input/commands/codebase-runtime.ts +192 -0
  23. package/src/input/commands/diff-runtime.ts +61 -30
  24. package/src/input/commands/eval.ts +1 -1
  25. package/src/input/commands/health-runtime.ts +1 -1
  26. package/src/input/commands/image-runtime.ts +112 -0
  27. package/src/input/commands/intelligence-runtime.ts +11 -1
  28. package/src/input/commands/local-auth-runtime.ts +4 -1
  29. package/src/input/commands/local-runtime.ts +9 -3
  30. package/src/input/commands/marketplace-runtime.ts +2 -2
  31. package/src/input/commands/memory.ts +6 -1
  32. package/src/input/commands/operator-panel-runtime.ts +40 -24
  33. package/src/input/commands/planning-runtime.ts +26 -3
  34. package/src/input/commands/platform-sandbox-runtime.ts +1 -6
  35. package/src/input/commands/plugin-runtime.ts +2 -2
  36. package/src/input/commands/policy-dispatch.ts +21 -0
  37. package/src/input/commands/provider-accounts-runtime.ts +1 -1
  38. package/src/input/commands/qrcode-runtime.ts +3 -3
  39. package/src/input/commands/recall-review.ts +35 -0
  40. package/src/input/commands/remote-runtime.ts +3 -3
  41. package/src/input/commands/runtime-services.ts +54 -13
  42. package/src/input/commands/services-runtime.ts +1 -1
  43. package/src/input/commands/session-content.ts +12 -0
  44. package/src/input/commands/session-workflow.ts +19 -1
  45. package/src/input/commands/settings-sync-runtime.ts +1 -1
  46. package/src/input/commands/share-runtime.ts +9 -2
  47. package/src/input/commands/shell-core.ts +15 -7
  48. package/src/input/commands/skills-runtime.ts +2 -8
  49. package/src/input/commands/subscription-runtime.ts +2 -2
  50. package/src/input/commands/test-runtime.ts +277 -0
  51. package/src/input/commands/websearch-runtime.ts +101 -0
  52. package/src/input/commands/work-plan-runtime.ts +36 -10
  53. package/src/input/commands/workstream-runtime.ts +338 -0
  54. package/src/input/commands.ts +12 -0
  55. package/src/input/config-modal-types.ts +161 -0
  56. package/src/input/config-modal.ts +377 -0
  57. package/src/input/feed-context-factory.ts +7 -8
  58. package/src/input/handler-command-route.ts +27 -17
  59. package/src/input/handler-content-actions.ts +22 -8
  60. package/src/input/handler-feed-routes.ts +107 -7
  61. package/src/input/handler-feed.ts +49 -13
  62. package/src/input/handler-interactions.ts +3 -3
  63. package/src/input/handler-modal-routes.ts +65 -0
  64. package/src/input/handler-modal-stack.ts +3 -5
  65. package/src/input/handler-modal-token-routes.ts +16 -49
  66. package/src/input/handler-picker-routes.ts +11 -94
  67. package/src/input/handler-shortcuts.ts +24 -14
  68. package/src/input/handler-types.ts +3 -6
  69. package/src/input/handler-ui-state.ts +10 -22
  70. package/src/input/handler.ts +10 -28
  71. package/src/input/keybindings.ts +22 -8
  72. package/src/input/model-picker-types.ts +24 -6
  73. package/src/input/model-picker.ts +58 -0
  74. package/src/input/panel-integration-actions.ts +9 -170
  75. package/src/input/settings-modal-data.ts +95 -0
  76. package/src/input/settings-modal-mutations.ts +6 -4
  77. package/src/main.ts +41 -44
  78. package/src/panels/agent-inspector-shared.ts +35 -11
  79. package/src/panels/base-panel.ts +22 -1
  80. package/src/panels/builtin/agent.ts +21 -107
  81. package/src/panels/builtin/development.ts +16 -62
  82. package/src/panels/builtin/knowledge.ts +8 -32
  83. package/src/panels/builtin/operations.ts +84 -428
  84. package/src/panels/builtin/session.ts +21 -112
  85. package/src/panels/builtin/shared.ts +9 -43
  86. package/src/panels/builtin-modals.ts +218 -0
  87. package/src/panels/builtin-panels.ts +5 -0
  88. package/src/panels/cost-tracker-panel.ts +63 -14
  89. package/src/panels/diff-panel.ts +123 -60
  90. package/src/panels/eval-registry.ts +60 -0
  91. package/src/panels/fleet-panel.ts +800 -0
  92. package/src/panels/fleet-read-model.ts +477 -0
  93. package/src/panels/fleet-steer.ts +92 -0
  94. package/src/panels/fleet-stop.ts +125 -0
  95. package/src/panels/fleet-tabs.ts +230 -0
  96. package/src/panels/fleet-transcript.ts +356 -0
  97. package/src/panels/git-panel.ts +9 -9
  98. package/src/panels/index.ts +7 -31
  99. package/src/panels/local-auth-panel.ts +10 -0
  100. package/src/panels/modals/hooks-modal.ts +187 -0
  101. package/src/panels/modals/keybindings-modal.ts +151 -0
  102. package/src/panels/modals/knowledge-modal.ts +158 -0
  103. package/src/panels/modals/local-auth-modal.ts +132 -0
  104. package/src/panels/modals/marketplace-modal.ts +218 -0
  105. package/src/panels/modals/memory-modal.ts +180 -0
  106. package/src/panels/modals/modal-surface-helpers.ts +54 -0
  107. package/src/panels/modals/modal-theme.ts +36 -0
  108. package/src/panels/modals/pairing-modal.ts +144 -0
  109. package/src/panels/modals/planning-modal.ts +282 -0
  110. package/src/panels/modals/plugins-modal.ts +174 -0
  111. package/src/panels/modals/policy-modal.ts +256 -0
  112. package/src/panels/modals/provider-health-modal.ts +136 -0
  113. package/src/panels/modals/remote-modal.ts +115 -0
  114. package/src/panels/modals/sandbox-modal.ts +150 -0
  115. package/src/panels/modals/security-modal.ts +217 -0
  116. package/src/panels/modals/services-modal.ts +179 -0
  117. package/src/panels/modals/settings-sync-modal.ts +142 -0
  118. package/src/panels/modals/skills-modal.ts +189 -0
  119. package/src/panels/modals/subscription-modal.ts +172 -0
  120. package/src/panels/modals/work-plan-modal.ts +149 -0
  121. package/src/panels/panel-confirm-overlay.ts +72 -0
  122. package/src/panels/panel-manager.ts +108 -5
  123. package/src/panels/project-planning-answer-actions.ts +4 -2
  124. package/src/panels/scrollable-list-panel.ts +9 -0
  125. package/src/panels/skills-panel.ts +7 -51
  126. package/src/panels/token-budget-panel.ts +5 -3
  127. package/src/panels/types.ts +26 -0
  128. package/src/permissions/hunk-selection.ts +179 -0
  129. package/src/permissions/prompt.ts +60 -4
  130. package/src/renderer/compaction-history-modal.ts +19 -3
  131. package/src/renderer/compaction-preview.ts +13 -2
  132. package/src/renderer/compaction-quality.ts +100 -0
  133. package/src/renderer/config-modal.ts +81 -0
  134. package/src/renderer/conversation-overlays.ts +10 -17
  135. package/src/renderer/fleet-tab-strip.ts +56 -0
  136. package/src/renderer/footer-tips.ts +10 -2
  137. package/src/renderer/git-status.ts +40 -0
  138. package/src/renderer/help-overlay.ts +2 -2
  139. package/src/renderer/model-workspace.ts +44 -1
  140. package/src/renderer/panel-workspace-bar.ts +8 -2
  141. package/src/renderer/shell-surface.ts +8 -1
  142. package/src/renderer/turn-injection.ts +114 -0
  143. package/src/renderer/ui-factory.ts +91 -7
  144. package/src/runtime/bootstrap-command-context.ts +24 -1
  145. package/src/runtime/bootstrap-command-parts.ts +36 -7
  146. package/src/runtime/bootstrap-core.ts +19 -4
  147. package/src/runtime/bootstrap-hook-bridge.ts +5 -0
  148. package/src/runtime/bootstrap-shell.ts +41 -17
  149. package/src/runtime/bootstrap.ts +11 -17
  150. package/src/runtime/code-index-services.ts +112 -0
  151. package/src/runtime/orchestrator-core-services.ts +49 -0
  152. package/src/runtime/process-lifecycle.ts +3 -1
  153. package/src/runtime/services.ts +91 -43
  154. package/src/runtime/ui-services.ts +8 -0
  155. package/src/runtime/workstream-services.ts +195 -0
  156. package/src/shell/blocking-input.ts +22 -1
  157. package/src/shell/ui-openers.ts +129 -17
  158. package/src/utils/format-duration.ts +8 -18
  159. package/src/utils/splash-lines.ts +1 -1
  160. package/src/version.ts +1 -1
  161. package/src/panels/agent-inspector-panel.ts +0 -786
  162. package/src/panels/approval-panel.ts +0 -252
  163. package/src/panels/automation-control-panel.ts +0 -479
  164. package/src/panels/cockpit-panel.ts +0 -481
  165. package/src/panels/cockpit-read-model.ts +0 -233
  166. package/src/panels/communication-panel.ts +0 -256
  167. package/src/panels/control-plane-panel.ts +0 -470
  168. package/src/panels/debug-panel.ts +0 -609
  169. package/src/panels/docs-panel.ts +0 -375
  170. package/src/panels/eval-panel.ts +0 -627
  171. package/src/panels/file-explorer-panel.ts +0 -664
  172. package/src/panels/file-preview-panel.ts +0 -517
  173. package/src/panels/hooks-panel.ts +0 -401
  174. package/src/panels/incident-review-panel.ts +0 -406
  175. package/src/panels/intelligence-panel.ts +0 -383
  176. package/src/panels/knowledge-graph-panel.ts +0 -506
  177. package/src/panels/marketplace-panel.ts +0 -399
  178. package/src/panels/memory-panel.ts +0 -558
  179. package/src/panels/ops-control-panel.ts +0 -329
  180. package/src/panels/ops-strategy-panel.ts +0 -321
  181. package/src/panels/orchestration-panel.ts +0 -465
  182. package/src/panels/panel-list-panel.ts +0 -557
  183. package/src/panels/plan-dashboard-panel.ts +0 -707
  184. package/src/panels/policy-panel.ts +0 -517
  185. package/src/panels/project-planning-panel.ts +0 -721
  186. package/src/panels/provider-health-panel.ts +0 -678
  187. package/src/panels/provider-health-tracker.ts +0 -306
  188. package/src/panels/provider-health-views.ts +0 -560
  189. package/src/panels/qr-panel.ts +0 -280
  190. package/src/panels/remote-panel.ts +0 -534
  191. package/src/panels/routes-panel.ts +0 -241
  192. package/src/panels/sandbox-panel.ts +0 -456
  193. package/src/panels/security-panel.ts +0 -447
  194. package/src/panels/services-panel.ts +0 -329
  195. package/src/panels/session-browser-panel.ts +0 -487
  196. package/src/panels/settings-sync-panel.ts +0 -398
  197. package/src/panels/subscription-panel.ts +0 -342
  198. package/src/panels/symbol-outline-panel.ts +0 -619
  199. package/src/panels/system-messages-panel.ts +0 -364
  200. package/src/panels/tasks-panel.ts +0 -608
  201. package/src/panels/thinking-panel.ts +0 -333
  202. package/src/panels/tool-inspector-panel.ts +0 -537
  203. package/src/panels/work-plan-panel.ts +0 -530
  204. package/src/panels/worktree-panel.ts +0 -360
  205. package/src/panels/wrfc-panel.ts +0 -790
  206. package/src/renderer/agent-detail-modal.ts +0 -465
  207. package/src/renderer/live-tail-modal.ts +0 -156
  208. package/src/renderer/process-modal.ts +0 -656
  209. package/src/renderer/qr-renderer.ts +0 -120
@@ -1,506 +0,0 @@
1
- /**
2
- * KnowledgeGraphPanel — SDK knowledge graph front-door.
3
- *
4
- * WO-123: Replaces the former static GRAPH_COMMANDS/MEMORY_COMMANDS command
5
- * catalogue with a live console over the injected KnowledgeApi surface:
6
- * - 'browse' mode: header counts + a combined node/source/issue list,
7
- * with '/' search dispatched through graph.items.search, plus a
8
- * schedules summary from jobs.schedules.list.
9
- * - 'review' mode (Tab): the open-issue review queue, with
10
- * accept/reject/resolve/reopen mutations via graph.issues.review,
11
- * ConfirmState-gated — mirrors MemoryPanel's proven review pattern.
12
- *
13
- * 'M' opens the Memory panel directly via panelManager.open (no more dead
14
- * hint text) — the two panels stay distinct: this one is the SDK graph,
15
- * memory-panel.ts is the durable project-memory substrate.
16
- */
17
-
18
- import type { Line } from '../types/grid.ts';
19
- import type { KnowledgeApi } from '@pellux/goodvibes-sdk/platform/knowledge';
20
- import type {
21
- KnowledgeIssueRecord,
22
- KnowledgeNodeRecord,
23
- KnowledgeScheduleRecord,
24
- KnowledgeSearchResult,
25
- KnowledgeSourceRecord,
26
- } from '@pellux/goodvibes-sdk/platform/knowledge';
27
- import { ScrollableListPanel } from './scrollable-list-panel.ts';
28
- import { truncateDisplay } from '../utils/terminal-width.ts';
29
- import { type ConfirmState, handleConfirmInput, renderConfirmLines } from './confirm-state.ts';
30
- import {
31
- buildBodyText,
32
- buildKeyValueLine,
33
- buildPanelLine,
34
- buildPanelWorkspace,
35
- buildSearchInputLine,
36
- DEFAULT_PANEL_PALETTE,
37
- } from './polish.ts';
38
- import {
39
- getPanelSearchFocusTransition,
40
- isPanelSearchBackspace,
41
- isPanelSearchCancel,
42
- isPanelSearchCommit,
43
- isPanelSearchPrintable,
44
- } from './search-focus.ts';
45
- import { summarizeError } from '@pellux/goodvibes-sdk/platform/utils';
46
-
47
- const C = DEFAULT_PANEL_PALETTE;
48
-
49
- // The 'edit' and 'forget' review actions accept structured data the panel has
50
- // no field to collect, so only the four browsable actions are key-bound here
51
- // (mirrors the reduced key surface the plan calls out: a/x/r/o).
52
- const KNOWLEDGE_REVIEW_ACTIONS = ['accept', 'reject', 'resolve', 'reopen'] as const;
53
- type KnowledgeReviewAction = typeof KNOWLEDGE_REVIEW_ACTIONS[number];
54
-
55
- type BrowseKind = 'node' | 'source' | 'issue' | 'result';
56
-
57
- interface BrowseRow {
58
- readonly kind: BrowseKind;
59
- readonly id: string;
60
- readonly title: string;
61
- readonly tag: string;
62
- readonly detail: string;
63
- }
64
-
65
- type Mode = 'browse' | 'review';
66
-
67
- const LIST_LIMIT = 60;
68
- const SEARCH_LIMIT = 30;
69
-
70
- function cleanInline(value: string | undefined): string {
71
- return (value ?? '').replace(/\s+/g, ' ').trim();
72
- }
73
-
74
- function nodeRow(node: KnowledgeNodeRecord): BrowseRow {
75
- return {
76
- kind: 'node',
77
- id: node.id,
78
- title: cleanInline(node.title) || 'untitled',
79
- tag: `node/${node.kind}`,
80
- detail: cleanInline(node.summary),
81
- };
82
- }
83
-
84
- function sourceRow(source: KnowledgeSourceRecord): BrowseRow {
85
- return {
86
- kind: 'source',
87
- id: source.id,
88
- title: cleanInline(source.title) || cleanInline(source.canonicalUri) || cleanInline(source.sourceUri) || source.id,
89
- tag: `source/${source.status}`,
90
- detail: cleanInline(source.summary),
91
- };
92
- }
93
-
94
- function issueRow(issue: KnowledgeIssueRecord): BrowseRow {
95
- return {
96
- kind: 'issue',
97
- id: issue.id,
98
- title: issue.code,
99
- tag: `issue/${issue.severity}`,
100
- detail: cleanInline(issue.message),
101
- };
102
- }
103
-
104
- function searchResultRow(result: KnowledgeSearchResult): BrowseRow {
105
- const title = result.source?.title
106
- ?? result.source?.canonicalUri
107
- ?? result.node?.title
108
- ?? result.id;
109
- return {
110
- kind: 'result',
111
- id: result.id,
112
- title: cleanInline(title) || result.id,
113
- tag: `${result.kind} score=${result.score}`,
114
- detail: cleanInline(result.reason),
115
- };
116
- }
117
-
118
- function kindColor(kind: BrowseKind): string {
119
- switch (kind) {
120
- case 'node': return C.info;
121
- case 'source': return C.good;
122
- case 'issue': return C.warn;
123
- case 'result': return C.value;
124
- }
125
- }
126
-
127
- function severityColor(severity: KnowledgeIssueRecord['severity']): string {
128
- switch (severity) {
129
- case 'error': return C.bad;
130
- case 'warning': return C.warn;
131
- case 'info':
132
- default: return C.info;
133
- }
134
- }
135
-
136
- export class KnowledgeGraphPanel extends ScrollableListPanel<BrowseRow> {
137
- private readonly knowledge: KnowledgeApi;
138
- private readonly openMemoryPanel?: () => void;
139
-
140
- private mode: Mode = 'browse';
141
-
142
- // Browse-mode data + search state
143
- private browseRows: BrowseRow[] = [];
144
- private searchRows: BrowseRow[] = [];
145
- private searchFocused = false;
146
- private searchQuery = '';
147
- private sourceCount = 0;
148
- private nodeCount = 0;
149
- private issueCount = 0;
150
- private schedules: readonly KnowledgeScheduleRecord[] = [];
151
-
152
- // Review-mode data
153
- private reviewRows: BrowseRow[] = [];
154
- private reviewIssues = new Map<string, KnowledgeIssueRecord>();
155
-
156
- private confirm: ConfirmState<{ issueId: string; action: KnowledgeReviewAction }> | null = null;
157
-
158
- constructor(knowledge: KnowledgeApi, openMemoryPanel?: () => void) {
159
- super('knowledge', 'Knowledge', 'K', 'agent');
160
- this.knowledge = knowledge;
161
- this.openMemoryPanel = openMemoryPanel;
162
- }
163
-
164
- // ---------------------------------------------------------------------------
165
- // Lifecycle
166
- // ---------------------------------------------------------------------------
167
-
168
- override onActivate(): void {
169
- super.onActivate();
170
- this.confirm = null;
171
- this.refreshBrowseRows();
172
- this.refreshReviewRows();
173
- }
174
-
175
- // ---------------------------------------------------------------------------
176
- // Data refresh
177
- // ---------------------------------------------------------------------------
178
-
179
- private refreshBrowseRows(): void {
180
- try {
181
- const nodes = this.knowledge.graph.nodes.list(LIST_LIMIT);
182
- const sources = this.knowledge.sources.list(LIST_LIMIT);
183
- const issues = this.knowledge.graph.issues.list(LIST_LIMIT);
184
- this.sourceCount = sources.length;
185
- this.nodeCount = nodes.length;
186
- this.issueCount = issues.length;
187
- this.browseRows = [
188
- ...sources.map(sourceRow),
189
- ...nodes.map(nodeRow),
190
- ...issues.map(issueRow),
191
- ];
192
- this.schedules = this.knowledge.jobs.schedules.list(20);
193
- } catch (e) {
194
- this.setError(`Knowledge graph load failed: ${summarizeError(e)}`);
195
- }
196
- this.clampSelection();
197
- this.markDirty();
198
- }
199
-
200
- private refreshReviewRows(): void {
201
- try {
202
- const issues = this.knowledge.graph.issues.list(LIST_LIMIT).filter((issue) => issue.status === 'open');
203
- this.reviewIssues = new Map(issues.map((issue) => [issue.id, issue]));
204
- this.reviewRows = issues.map(issueRow);
205
- } catch (e) {
206
- this.setError(`Knowledge review queue load failed: ${summarizeError(e)}`);
207
- }
208
- this.clampSelection();
209
- this.markDirty();
210
- }
211
-
212
- private runSearch(): void {
213
- const query = this.searchQuery.trim();
214
- if (!query) {
215
- this.searchRows = [];
216
- this.markDirty();
217
- return;
218
- }
219
- try {
220
- this.searchRows = this.knowledge.graph.items.search(query, SEARCH_LIMIT).map(searchResultRow);
221
- } catch (e) {
222
- this.setError(`Knowledge search failed: ${summarizeError(e)}`);
223
- this.searchRows = [];
224
- }
225
- this.selectedIndex = 0;
226
- this.markDirty();
227
- }
228
-
229
- // ---------------------------------------------------------------------------
230
- // ScrollableListPanel implementation
231
- // ---------------------------------------------------------------------------
232
-
233
- protected getItems(): readonly BrowseRow[] {
234
- if (this.mode === 'review') return this.reviewRows;
235
- if (this.searchQuery.trim()) return this.searchRows;
236
- return this.browseRows;
237
- }
238
-
239
- protected renderItem(row: BrowseRow, _index: number, selected: boolean, width: number): Line {
240
- const bg = selected ? C.selectBg : undefined;
241
- return buildPanelLine(width, [
242
- [' ', C.label, bg],
243
- [row.tag.padEnd(16), kindColor(row.kind), bg],
244
- [truncateDisplay(row.title, Math.max(0, Math.floor((width - 22) * 0.45))), C.value, bg],
245
- [' ', C.label, bg],
246
- [truncateDisplay(row.detail, Math.max(0, width - 22 - Math.floor((width - 22) * 0.45) - 2)), C.dim, bg],
247
- ]);
248
- }
249
-
250
- protected override getPalette() { return C; }
251
-
252
- protected override getEmptyStateMessage(): string {
253
- if (this.mode === 'review') return 'No issues waiting for review.';
254
- if (this.searchQuery.trim()) return ` No results matching "${this.searchQuery.trim()}"`;
255
- return 'No ingested knowledge yet.';
256
- }
257
-
258
- protected override getEmptyStateActions() {
259
- if (this.mode === 'review' || this.searchQuery.trim()) return [];
260
- return [
261
- { command: '/knowledge ingest-url <url>', summary: 'ingest a URL as the first graph source' },
262
- ];
263
- }
264
-
265
- // ---------------------------------------------------------------------------
266
- // Input
267
- // ---------------------------------------------------------------------------
268
-
269
- handleInput(key: string): boolean {
270
- if (this.lastError !== null) this.clearError();
271
-
272
- if (this.confirm) {
273
- const result = handleConfirmInput(this.confirm, key);
274
- if (result === 'confirmed') {
275
- const { issueId, action } = this.confirm.subject;
276
- this.confirm = null;
277
- void this.applyReview(issueId, action);
278
- return true;
279
- }
280
- if (result === 'cancelled') {
281
- this.confirm = null;
282
- this.markDirty();
283
- return true;
284
- }
285
- if (result === 'absorbed') return true;
286
- }
287
-
288
- if (key === 'tab') {
289
- this.mode = this.mode === 'browse' ? 'review' : 'browse';
290
- this.selectedIndex = 0;
291
- if (this.mode === 'review') this.refreshReviewRows();
292
- else this.refreshBrowseRows();
293
- this.markDirty();
294
- return true;
295
- }
296
-
297
- if (key === 'm' || key === 'M') {
298
- this.openMemoryPanel?.();
299
- return true;
300
- }
301
-
302
- if (this.mode === 'review') {
303
- // getItems() returns reviewRows in review mode, so the shared
304
- // getSelectedItem() accessor resolves the highlighted issue row.
305
- const selected = this.getSelectedItem();
306
- if (key === 'a' && selected) {
307
- this.confirm = { subject: { issueId: selected.id, action: 'accept' }, label: truncateDisplay(selected.detail || selected.title, 40), verb: 'Accept' };
308
- this.markDirty();
309
- return true;
310
- }
311
- if (key === 'x' && selected) {
312
- this.confirm = { subject: { issueId: selected.id, action: 'reject' }, label: truncateDisplay(selected.detail || selected.title, 40), verb: 'Reject' };
313
- this.markDirty();
314
- return true;
315
- }
316
- if (key === 'r' && selected) {
317
- this.confirm = { subject: { issueId: selected.id, action: 'resolve' }, label: truncateDisplay(selected.detail || selected.title, 40), verb: 'Resolve' };
318
- this.markDirty();
319
- return true;
320
- }
321
- if (key === 'o' && selected) {
322
- this.confirm = { subject: { issueId: selected.id, action: 'reopen' }, label: truncateDisplay(selected.detail || selected.title, 40), verb: 'Reopen' };
323
- this.markDirty();
324
- return true;
325
- }
326
- return ScrollableListPanel.prototype.handleInput.call(this, key);
327
- }
328
-
329
- // Browse mode: '/' search focus
330
- if (this.searchFocused) {
331
- const items = this.getItems();
332
- const transition = getPanelSearchFocusTransition(key, { selectedIndex: this.selectedIndex, itemCount: items.length });
333
- if (transition === 'focus-list') {
334
- this.searchFocused = false;
335
- this.markDirty();
336
- return true;
337
- }
338
- if (isPanelSearchCancel(key)) {
339
- this.searchFocused = false;
340
- this.searchQuery = '';
341
- this.searchRows = [];
342
- this.selectedIndex = 0;
343
- this.markDirty();
344
- return true;
345
- }
346
- if (isPanelSearchBackspace(key)) {
347
- this.searchQuery = this.searchQuery.slice(0, -1);
348
- this.runSearch();
349
- return true;
350
- }
351
- if (isPanelSearchCommit(key)) {
352
- this.searchFocused = false;
353
- this.markDirty();
354
- return true;
355
- }
356
- if (isPanelSearchPrintable(key)) {
357
- this.searchQuery += key;
358
- this.runSearch();
359
- return true;
360
- }
361
- return true;
362
- }
363
-
364
- const items = this.getItems();
365
- const transition = getPanelSearchFocusTransition(key, { selectedIndex: this.selectedIndex, itemCount: items.length });
366
- if (transition === 'focus-search') {
367
- this.searchFocused = true;
368
- this.markDirty();
369
- return true;
370
- }
371
-
372
- return ScrollableListPanel.prototype.handleInput.call(this, key);
373
- }
374
-
375
- private async applyReview(issueId: string, action: KnowledgeReviewAction): Promise<void> {
376
- try {
377
- await this.knowledge.graph.issues.review({ issueId, action, reviewer: 'tui' });
378
- } catch (e) {
379
- this.setError(`Review ${action} failed: ${summarizeError(e)}`);
380
- }
381
- this.refreshReviewRows();
382
- this.refreshBrowseRows();
383
- }
384
-
385
- // ---------------------------------------------------------------------------
386
- // Render
387
- // ---------------------------------------------------------------------------
388
-
389
- render(width: number, height: number): Line[] {
390
- if (this.confirm) {
391
- return buildPanelWorkspace(width, height, {
392
- title: 'Knowledge',
393
- intro: '',
394
- sections: [{ title: 'Confirmation', lines: renderConfirmLines(width, this.confirm) }],
395
- footerLines: [buildPanelLine(width, [[' y confirm n / Esc cancel', C.dim]])],
396
- palette: C,
397
- });
398
- }
399
-
400
- // KnowledgeApi has no subscribe/eventing hook (unlike MemoryRegistry), so
401
- // pull fresh data on every render — same fetch-per-call pattern as the
402
- // /knowledge command handlers. These are synchronous in-memory reads.
403
- if (this.mode === 'review') {
404
- this.refreshReviewRows();
405
- this.clampSelection();
406
- return this.renderReviewMode(width, height);
407
- }
408
- this.refreshBrowseRows();
409
- this.clampSelection();
410
- return this.renderBrowseMode(width, height);
411
- }
412
-
413
- private modeToggleLine(width: number): Line {
414
- const label = this.mode === 'review' ? 'Review Queue' : 'Browse';
415
- return buildPanelLine(width, [
416
- [' Mode: ', C.label],
417
- [label, C.info],
418
- [' (Tab to toggle)', C.dim],
419
- ]);
420
- }
421
-
422
- private renderBrowseMode(width: number, height: number): Line[] {
423
- const readySources = this.sourceCount > 0 && this.nodeCount > 0;
424
- const summaryLines: Line[] = [
425
- buildKeyValueLine(width, [
426
- { label: 'sources', value: String(this.sourceCount), valueColor: C.good },
427
- { label: 'nodes', value: String(this.nodeCount), valueColor: C.info },
428
- { label: 'issues', value: String(this.issueCount), valueColor: this.issueCount > 0 ? C.warn : C.good },
429
- { label: 'schedules', value: String(this.schedules.length), valueColor: C.value },
430
- ], C),
431
- this.modeToggleLine(width),
432
- buildSearchInputLine(
433
- width,
434
- this.searchFocused ? '[Search] ' : 'Search: ',
435
- this.searchFocused ? `${this.searchQuery}_` : (this.searchQuery || '(/ to search)'),
436
- C,
437
- this.searchFocused ? { active: false, bg: C.inputBg, valueColor: C.info } : { active: false },
438
- ),
439
- ];
440
-
441
- const selected = this.getSelectedItem();
442
- const selectedLines: Line[] = [];
443
- if (selected) {
444
- selectedLines.push(buildKeyValueLine(width, [
445
- { label: 'kind', value: selected.tag, valueColor: kindColor(selected.kind) },
446
- { label: 'id', value: selected.id.slice(-10), valueColor: C.dim },
447
- ], C));
448
- if (selected.detail) selectedLines.push(...buildBodyText(width, selected.detail, C, C.value));
449
- selectedLines.push(buildPanelLine(width, [
450
- [' Retrieval readiness: ', C.label],
451
- [readySources ? 'ready (sources + nodes indexed)' : 'not ready (needs sources and nodes)', readySources ? C.good : C.warn],
452
- ]));
453
- }
454
-
455
- if (this.schedules.length > 0) {
456
- selectedLines.push(buildPanelLine(width, [[' Schedules', C.label]]));
457
- for (const schedule of this.schedules.slice(0, 4)) {
458
- selectedLines.push(buildPanelLine(width, [
459
- [' ', C.label],
460
- [schedule.enabled ? 'on ' : 'off', schedule.enabled ? C.good : C.dim],
461
- [' ', C.label],
462
- [truncateDisplay(schedule.label, Math.max(0, width - 14)), C.value],
463
- ]));
464
- }
465
- }
466
-
467
- return this.renderList(width, height, {
468
- title: 'Knowledge',
469
- header: summaryLines,
470
- footer: [
471
- ...selectedLines,
472
- buildPanelLine(width, [[' / search j/k or Up/Down move Tab: Review Queue M memory panel Esc clear search', C.dim]]),
473
- ],
474
- });
475
- }
476
-
477
- private renderReviewMode(width: number, height: number): Line[] {
478
- const summaryLines: Line[] = [
479
- buildKeyValueLine(width, [
480
- { label: 'open issues', value: String(this.reviewRows.length), valueColor: this.reviewRows.length > 0 ? C.warn : C.good },
481
- ], C),
482
- this.modeToggleLine(width),
483
- ];
484
-
485
- const selectedRow = this.getSelectedItem();
486
- const selectedIssue = selectedRow ? this.reviewIssues.get(selectedRow.id) : undefined;
487
- const selectedLines: Line[] = [];
488
- if (selectedRow && selectedIssue) {
489
- selectedLines.push(buildKeyValueLine(width, [
490
- { label: 'severity', value: selectedIssue.severity, valueColor: severityColor(selectedIssue.severity) },
491
- { label: 'code', value: selectedIssue.code, valueColor: C.value },
492
- { label: 'status', value: selectedIssue.status, valueColor: C.info },
493
- ], C));
494
- selectedLines.push(...buildBodyText(width, selectedIssue.message, C, C.value));
495
- }
496
-
497
- return this.renderList(width, height, {
498
- title: 'Knowledge',
499
- header: summaryLines,
500
- footer: [
501
- ...selectedLines,
502
- buildPanelLine(width, [[' Up/Down move a accept x reject r resolve o reopen Tab: Browse M memory panel', C.dim]]),
503
- ],
504
- });
505
- }
506
- }