@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,707 +0,0 @@
1
- import type { Line } from '../types/grid.ts';
2
- import type { ExecutionPlan, ExecutionPlanManager, PlanItem, PlanItemStatus } from '@pellux/goodvibes-sdk/platform/core';
3
- import { truncateDisplay } from '../utils/terminal-width.ts';
4
- import { BasePanel } from './base-panel.ts';
5
- import { AgentInspectorPanel } from './agent-inspector-panel.ts';
6
- import type { PanelIntegrationContext } from './types.ts';
7
- import type { WorkflowEvent } from '@/runtime/index.ts';
8
- import type { UiEventFeed } from '../runtime/ui-events.ts';
9
- import {
10
- buildEmptyState,
11
- buildKeyboardHints,
12
- buildKeyValueLine,
13
- buildMeterLine,
14
- buildPanelLine,
15
- buildPanelWorkspace,
16
- buildSelectablePanelLine,
17
- resolveScrollablePanelSection,
18
- DEFAULT_PANEL_PALETTE,
19
- extendPalette,
20
- type PanelWorkspaceSection,
21
- } from './polish.ts';
22
-
23
- // ---------------------------------------------------------------------------
24
- // Palette (no inline hex in render bodies)
25
- // ---------------------------------------------------------------------------
26
-
27
- const C = extendPalette(DEFAULT_PANEL_PALETTE, {
28
- complete: '#22c55e',
29
- active: '#00ffff',
30
- pending: '#94a3b8',
31
- failed: '#ef4444',
32
- skipped: '#64748b',
33
- blocked: '#f97316',
34
- selectBg: '#1e293b',
35
- phase: '#cbd5e1',
36
- });
37
-
38
- // ---------------------------------------------------------------------------
39
- // Status display maps
40
- // ---------------------------------------------------------------------------
41
-
42
- const STATUS_ICON: Record<PlanItemStatus, string> = {
43
- complete: '✓',
44
- in_progress: '▸',
45
- pending: '•',
46
- failed: '✗',
47
- skipped: '–',
48
- };
49
-
50
- const STATUS_FG: Record<PlanItemStatus, string> = {
51
- complete: C.complete,
52
- in_progress: C.active,
53
- pending: C.pending,
54
- failed: C.failed,
55
- skipped: C.skipped,
56
- };
57
-
58
- // ---------------------------------------------------------------------------
59
- // Deps
60
- // ---------------------------------------------------------------------------
61
-
62
- /**
63
- * The subset of ExecutionPlanManager the dashboard needs: the live active
64
- * plan (getActive) plus history/switching support (list/getSummary/
65
- * toMarkdown — the same trio /plan list|show consume, planning-runtime.ts:
66
- * 140-165) so the panel can browse and view any plan on disk, not just the
67
- * currently active one.
68
- */
69
- export interface PlanDashboardPanelDeps {
70
- readonly planManager: Pick<ExecutionPlanManager, 'getActive' | 'list' | 'getSummary' | 'toMarkdown'>;
71
- }
72
-
73
- // ---------------------------------------------------------------------------
74
- // PlanDashboardPanel
75
- // ---------------------------------------------------------------------------
76
-
77
- export class PlanDashboardPanel extends BasePanel {
78
- private scrollOffset = 0;
79
- private selectedIndex = 0;
80
-
81
- // Flat list of navigable row indices (set during render)
82
- private totalRows = 0;
83
- // Item flat-list parallel to navigable rows (set during render) for detail.
84
- private navItems: PlanItem[] = [];
85
- private blockedItemIds = new Set<string>();
86
-
87
- /**
88
- * The plan item under the cursor. This panel owns its own selection state
89
- * (`selectedIndex` navigates the `this.navItems` flat list directly), so
90
- * every selected-row read routes through this one accessor — indexing
91
- * `this.navItems` by the cursor directly is banned by the
92
- * no-raw-selectedindex-read architecture rule.
93
- */
94
- private selectedNavItem(): PlanItem | undefined {
95
- return this.navItems.at(this.selectedIndex);
96
- }
97
-
98
- // Plan history / switching (planManager.list()/getSummary()/toMarkdown()).
99
- // `viewingPlanId` is null while following the live active plan; once set,
100
- // the dashboard renders that specific plan from disk instead.
101
- private viewingPlanId: string | null = null;
102
- private historyMode = false;
103
- private historyPlans: ExecutionPlan[] = [];
104
- private historySelectedIndex = 0;
105
- private historyScrollOffset = 0;
106
-
107
- // Live-refresh subscriptions (WrfcPanel pattern: subscribe ui.events.workflows
108
- // so the dashboard updates during a run without requiring a keypress).
109
- private unsubscribers: Array<() => void> = [];
110
-
111
- constructor(
112
- private readonly workflowEvents: UiEventFeed<WorkflowEvent>,
113
- private readonly deps: PlanDashboardPanelDeps,
114
- ) {
115
- super('plan', 'Plan', '▤', 'agent');
116
- this.subscribeToEvents();
117
- }
118
-
119
- override onActivate(): void {
120
- super.onActivate();
121
- // Re-read plan from disk each time the panel is activated
122
- this.markDirty();
123
- }
124
-
125
- override onDestroy(): void {
126
- for (const unsub of this.unsubscribers) unsub();
127
- this.unsubscribers = [];
128
- super.onDestroy();
129
- }
130
-
131
- // --------------------------------------------------------------------------
132
- // Live refresh — mirrors WrfcPanel: any workflow event may have changed the
133
- // active plan's item statuses (WRFC updates plan items via
134
- // wrfcController.setPlanManager, main.ts:120), so re-render without
135
- // requiring a keypress.
136
- // --------------------------------------------------------------------------
137
-
138
- private subscribeToEvents(): void {
139
- const refresh = () => this.markDirty();
140
- this.unsubscribers.push(
141
- this.workflowEvents.on('WORKFLOW_CHAIN_CREATED', refresh),
142
- this.workflowEvents.on('WORKFLOW_STATE_CHANGED', refresh),
143
- this.workflowEvents.on('WORKFLOW_REVIEW_COMPLETED', refresh),
144
- this.workflowEvents.on('WORKFLOW_FIX_ATTEMPTED', refresh),
145
- this.workflowEvents.on('WORKFLOW_GATE_RESULT', refresh),
146
- this.workflowEvents.on('WORKFLOW_CHAIN_PASSED', refresh),
147
- this.workflowEvents.on('WORKFLOW_CHAIN_FAILED', refresh),
148
- this.workflowEvents.on('WORKFLOW_AUTO_COMMITTED', refresh),
149
- this.workflowEvents.on('WORKFLOW_CASCADE_ABORTED', refresh),
150
- );
151
- }
152
-
153
- // --------------------------------------------------------------------------
154
- // Input
155
- // --------------------------------------------------------------------------
156
-
157
- handleInput(key: string): boolean {
158
- if (this.historyMode) {
159
- return this.handleHistoryInput(key);
160
- }
161
- if (key === 'h') {
162
- this.enterHistoryMode();
163
- return true;
164
- }
165
- if (key === 'a' && this.viewingPlanId !== null) {
166
- this.viewingPlanId = null;
167
- this.selectedIndex = 0;
168
- this.markDirty();
169
- return true;
170
- }
171
- if (key === 'up' || key === 'k') {
172
- if (this.selectedIndex > 0) {
173
- this.selectedIndex--;
174
- this.markDirty();
175
- return true;
176
- }
177
- } else if (key === 'down' || key === 'j') {
178
- if (this.selectedIndex < this.totalRows - 1) {
179
- this.selectedIndex++;
180
- this.markDirty();
181
- return true;
182
- }
183
- } else if (key === 'home' || key === 'g') {
184
- if (this.selectedIndex !== 0) {
185
- this.selectedIndex = 0;
186
- this.markDirty();
187
- }
188
- return true;
189
- } else if (key === 'end' || key === 'G') {
190
- const last = Math.max(0, this.totalRows - 1);
191
- if (this.selectedIndex !== last) {
192
- this.selectedIndex = last;
193
- this.markDirty();
194
- }
195
- return true;
196
- } else if (key === 'enter' || key === 'return') {
197
- // Consumed here (so the integration router fires next) only when the
198
- // selected item actually has an agent to jump to; see
199
- // handlePanelIntegrationAction below.
200
- const item = this.selectedNavItem();
201
- if (item?.agentId) return true;
202
- }
203
- return false;
204
- }
205
-
206
- /**
207
- * Cross-panel jump: Enter on a plan item with an assigned agent opens the
208
- * Inspector focused on that agent (inspectAgent, WO-110). The inspector
209
- * already renders a WRFC badge for the inspected agent, so this also
210
- * cross-links the owning WRFC chain without the dashboard needing to know
211
- * about WrfcController directly.
212
- */
213
- handlePanelIntegrationAction(key: string, ctx: PanelIntegrationContext): boolean {
214
- if (this.historyMode) return false;
215
- if (key !== 'enter' && key !== 'return') return false;
216
- const item = this.selectedNavItem();
217
- if (!item?.agentId) return false;
218
- const inspector = ctx.panelManager.open('inspector');
219
- if (inspector instanceof AgentInspectorPanel) {
220
- inspector.inspectAgent(item.agentId);
221
- }
222
- return true;
223
- }
224
-
225
- // --------------------------------------------------------------------------
226
- // Plan history / switching
227
- // --------------------------------------------------------------------------
228
-
229
- private enterHistoryMode(): void {
230
- this.historyPlans = [...this.deps.planManager.list()].sort(
231
- (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime(),
232
- );
233
- this.historySelectedIndex = 0;
234
- this.historyScrollOffset = 0;
235
- this.historyMode = true;
236
- this.markDirty();
237
- }
238
-
239
- private handleHistoryInput(key: string): boolean {
240
- if (key === 'up' || key === 'k') {
241
- if (this.historySelectedIndex > 0) {
242
- this.historySelectedIndex--;
243
- this.markDirty();
244
- }
245
- return true;
246
- }
247
- if (key === 'down' || key === 'j') {
248
- if (this.historySelectedIndex < this.historyPlans.length - 1) {
249
- this.historySelectedIndex++;
250
- this.markDirty();
251
- }
252
- return true;
253
- }
254
- if (key === 'enter' || key === 'return') {
255
- const plan = this.historyPlans[this.historySelectedIndex];
256
- if (plan) {
257
- this.viewingPlanId = plan.id;
258
- this.selectedIndex = 0;
259
- }
260
- this.historyMode = false;
261
- this.markDirty();
262
- return true;
263
- }
264
- if (key === 'escape' || key === 'h') {
265
- this.historyMode = false;
266
- this.markDirty();
267
- return true;
268
- }
269
- // Modal browsing: absorb everything else (mirrors ConfirmState's "others
270
- // absorbed" contract) so stray keys cannot leak into item navigation.
271
- return true;
272
- }
273
-
274
- // --------------------------------------------------------------------------
275
- // Render
276
- // --------------------------------------------------------------------------
277
-
278
- render(width: number, height: number): Line[] {
279
- return this.trackedRender(() => {
280
- if (this.historyMode) {
281
- return this.renderHistory(width, height);
282
- }
283
- const plan = this.resolveViewedPlan();
284
- if (!plan) {
285
- return buildPanelWorkspace(width, height, {
286
- title: ' Plan Dashboard',
287
- intro: 'Track the active execution plan, item status, phase grouping, and overall completion.',
288
- sections: [
289
- {
290
- lines: buildEmptyState(
291
- width,
292
- ' No active execution plan',
293
- 'Execution plans are produced by WRFC-reviewed tasks (gather-plan-apply execution). Start one from Teamwork and its phases, progress, blocked steps, and next action will surface here.',
294
- [
295
- { command: '/teamwork create-mode local-engineer <title>', summary: 'start a WRFC-reviewed engineer task — the only producer of a real execution plan' },
296
- { command: '/teamwork modes', summary: 'see every reviewMode: wrfc mode that can seed a plan' },
297
- ],
298
- C,
299
- ),
300
- },
301
- ],
302
- footerLines: this.historyFooterHintLines(width),
303
- palette: C,
304
- });
305
- }
306
- return this.renderPlan(plan, width, height);
307
- });
308
- }
309
-
310
- /** Resolve which plan to render: the pinned history selection, or the live active plan. */
311
- private resolveViewedPlan(): ExecutionPlan | null {
312
- if (this.viewingPlanId !== null) {
313
- const found = this.deps.planManager.list().find((p) => p.id === this.viewingPlanId);
314
- if (found) return found;
315
- // The pinned plan is gone (e.g. deleted from disk) — fall back to live.
316
- this.viewingPlanId = null;
317
- }
318
- return this.deps.planManager.getActive();
319
- }
320
-
321
- /** Keyboard hint shown even on the empty state so 'h' (history) stays discoverable. */
322
- private historyFooterHintLines(width: number): Line[] {
323
- return [
324
- buildKeyboardHints(width, [
325
- { keys: 'h', label: 'plan history' },
326
- ], C),
327
- ];
328
- }
329
-
330
- // --------------------------------------------------------------------------
331
- // Plan history browser
332
- // --------------------------------------------------------------------------
333
-
334
- private renderHistory(width: number, height: number): Line[] {
335
- if (this.historyPlans.length === 0) {
336
- return buildPanelWorkspace(width, height, {
337
- title: ' Plan History',
338
- intro: 'Every execution plan ever created for this project.',
339
- sections: [
340
- {
341
- lines: buildEmptyState(
342
- width,
343
- ' No plans on disk',
344
- 'Plans appear here once a WRFC-reviewed task (gather-plan-apply execution) creates one.',
345
- [],
346
- C,
347
- ),
348
- },
349
- ],
350
- footerLines: [buildKeyboardHints(width, [{ keys: 'Esc / h', label: 'back' }], C)],
351
- palette: C,
352
- });
353
- }
354
-
355
- const activePlan = this.deps.planManager.getActive();
356
- const rows: Line[] = [];
357
- let selectedLineIndex = 0;
358
- for (let i = 0; i < this.historyPlans.length; i++) {
359
- const plan = this.historyPlans[i]!;
360
- const isSelected = i === this.historySelectedIndex;
361
- if (isSelected) selectedLineIndex = rows.length;
362
- rows.push(this.renderHistoryRow(plan, activePlan?.id === plan.id, isSelected, width));
363
- }
364
-
365
- const highlighted = this.historyPlans[this.historySelectedIndex];
366
- const detailSection: PanelWorkspaceSection | null = highlighted ? {
367
- title: 'Plan Detail',
368
- lines: this.buildHistoryDetailLines(highlighted, width),
369
- } : null;
370
-
371
- const footerLines: Line[] = [
372
- buildKeyboardHints(width, [
373
- { keys: '↑/↓', label: 'browse' },
374
- { keys: 'Enter', label: 'view plan' },
375
- { keys: 'Esc / h', label: 'back' },
376
- ], C),
377
- ];
378
-
379
- const intro = `${this.historyPlans.length} plan${this.historyPlans.length === 1 ? '' : 's'} on disk`;
380
- const historySection = resolveScrollablePanelSection(width, height, {
381
- intro,
382
- footerLines,
383
- palette: C,
384
- afterSections: detailSection ? [detailSection] : [],
385
- section: {
386
- title: 'Plan History',
387
- scrollableLines: rows,
388
- selectedIndex: selectedLineIndex,
389
- scrollOffset: this.historyScrollOffset,
390
- minRows: 6,
391
- },
392
- });
393
- this.historyScrollOffset = historySection.scrollOffset;
394
-
395
- return buildPanelWorkspace(width, height, {
396
- title: ' Plan History',
397
- intro,
398
- sections: [
399
- historySection.section,
400
- ...(detailSection ? [detailSection] : []),
401
- ],
402
- footerLines,
403
- palette: C,
404
- });
405
- }
406
-
407
- private renderHistoryRow(plan: ExecutionPlan, isActive: boolean, isSelected: boolean, width: number): Line {
408
- const marker = isActive ? '▶' : ' ';
409
- const idShort = plan.id.slice(0, 8);
410
- const statusTag = `[${plan.status.padEnd(8)}]`;
411
- const prefix = ` ${marker} ${idShort} ${statusTag} `;
412
- const label = truncateDisplay(plan.title, Math.max(6, width - prefix.length - 2));
413
- return buildSelectablePanelLine(width, [
414
- { text: ` ${marker} `, fg: isActive ? C.good : C.dim, bold: isActive },
415
- { text: `${idShort} `, fg: C.dim },
416
- { text: `${statusTag} `, fg: this.statusColor(plan.status) },
417
- { text: label, fg: C.value },
418
- ], {
419
- selected: isSelected,
420
- selectedBg: C.selectBg,
421
- leadingMarker: '▸',
422
- });
423
- }
424
-
425
- private buildHistoryDetailLines(plan: ExecutionPlan, width: number): Line[] {
426
- const lines: Line[] = [
427
- buildPanelLine(width, [
428
- [' Summary ', C.label],
429
- [truncateDisplay(this.deps.planManager.getSummary(plan), Math.max(8, width - 12)), C.value],
430
- ]),
431
- ];
432
- const markdown = this.deps.planManager.toMarkdown(plan)
433
- .split('\n')
434
- .filter((line) => line.trim().length > 0)
435
- .slice(0, 4);
436
- for (const line of markdown) {
437
- lines.push(buildPanelLine(width, [
438
- [' ', C.label],
439
- [truncateDisplay(line, Math.max(8, width - 3)), C.dim],
440
- ]));
441
- }
442
- return lines;
443
- }
444
-
445
- // --------------------------------------------------------------------------
446
- // Plan render
447
- // --------------------------------------------------------------------------
448
-
449
- private renderPlan(plan: ExecutionPlan, width: number, height: number): Line[] {
450
- const activePlan = this.deps.planManager.getActive();
451
- const isHistorical = activePlan?.id !== plan.id;
452
-
453
- const phaseOrder: string[] = [];
454
- const byPhase = new Map<string, PlanItem[]>();
455
- for (const item of plan.items) {
456
- if (!byPhase.has(item.phase)) {
457
- byPhase.set(item.phase, []);
458
- phaseOrder.push(item.phase);
459
- }
460
- byPhase.get(item.phase)!.push(item);
461
- }
462
-
463
- // Build a set of complete item IDs for dependency blocking detection
464
- const completeIds = new Set(
465
- plan.items
466
- .filter((i) => i.status === 'complete' || i.status === 'skipped')
467
- .map((i) => i.id),
468
- );
469
-
470
- const isBlocked = (item: PlanItem): boolean =>
471
- item.status === 'pending' &&
472
- item.dependencies !== undefined &&
473
- item.dependencies.length > 0 &&
474
- !item.dependencies.every((depId) => completeIds.has(depId));
475
-
476
- let rowCount = 0;
477
- let selectedLineIndex = 0;
478
- const planLines: Line[] = [];
479
- const navItems: PlanItem[] = [];
480
- const blockedItemIds = new Set<string>();
481
-
482
- for (const phase of phaseOrder) {
483
- const items = byPhase.get(phase)!;
484
- planLines.push(this.renderPhaseHeaderLine(phase, items, width));
485
- for (const item of items) {
486
- const isSelected = rowCount === this.selectedIndex;
487
- if (isSelected) selectedLineIndex = planLines.length;
488
- const blocked = isBlocked(item);
489
- if (blocked) blockedItemIds.add(item.id);
490
- navItems.push(item);
491
- planLines.push(this.renderItem(item, isSelected, blocked, width));
492
- rowCount++;
493
- }
494
- }
495
-
496
- this.totalRows = rowCount;
497
- this.navItems = navItems;
498
- this.blockedItemIds = blockedItemIds;
499
- if (this.selectedIndex >= this.totalRows) {
500
- this.selectedIndex = Math.max(0, this.totalRows - 1);
501
- }
502
-
503
- const total = plan.items.length;
504
- const done = plan.items.filter((i) => i.status === 'complete' || i.status === 'skipped').length;
505
- const inProgress = plan.items.filter((i) => i.status === 'in_progress').length;
506
- const failed = plan.items.filter((i) => i.status === 'failed').length;
507
- const blockedCount = blockedItemIds.size;
508
- const pct = total > 0 ? Math.round((done / total) * 100) : 0;
509
-
510
- // The single most useful pointer: what should happen next. Prefer the first
511
- // in-progress item, else the first actionable (unblocked) pending item.
512
- const nextItem = plan.items.find((i) => i.status === 'in_progress')
513
- ?? plan.items.find((i) => i.status === 'pending' && !isBlocked(i));
514
-
515
- const meterWidth = Math.max(10, Math.min(28, width - 30));
516
- const summary: PanelWorkspaceSection = {
517
- title: 'Summary',
518
- lines: [
519
- buildPanelLine(width, [
520
- [' Status ', C.label],
521
- [plan.status, this.statusColor(plan.status)],
522
- [' ', C.label],
523
- [`${done}/${total} items`, C.value],
524
- [' ', C.label],
525
- [`${pct}%`, pct === 100 ? C.good : C.info],
526
- ]),
527
- buildMeterLine(width, Math.round((pct / 100) * meterWidth), meterWidth, {
528
- filled: pct === 100 ? C.good : C.info,
529
- empty: C.empty,
530
- label: C.label,
531
- }, { prefix: ' Progress ', suffix: ` ${pct}% ` }),
532
- buildKeyValueLine(width, [
533
- { label: 'in progress', value: String(inProgress), valueColor: inProgress > 0 ? C.active : C.dim },
534
- { label: 'blocked', value: String(blockedCount), valueColor: blockedCount > 0 ? C.blocked : C.dim },
535
- { label: 'failed', value: String(failed), valueColor: failed > 0 ? C.bad : C.dim },
536
- ], C),
537
- nextItem
538
- ? buildPanelLine(width, [
539
- [' Next ', C.label],
540
- [STATUS_ICON[nextItem.status], STATUS_FG[nextItem.status]],
541
- [' ', C.label],
542
- [truncateDisplay(nextItem.description, Math.max(8, width - 9)), C.value],
543
- ])
544
- : buildPanelLine(width, [
545
- [' Next ', C.label],
546
- [failed > 0 ? 'review failed steps' : blockedCount > 0 ? 'unblock dependencies' : 'plan complete',
547
- failed > 0 ? C.bad : blockedCount > 0 ? C.blocked : C.good],
548
- ]),
549
- ],
550
- };
551
-
552
- const historyBanner: PanelWorkspaceSection | null = isHistorical ? {
553
- lines: [
554
- buildPanelLine(width, [
555
- [' Viewing history ', C.warn],
556
- [plan.status.toUpperCase(), this.statusColor(plan.status)],
557
- [' — press a to return to the live plan', C.dim],
558
- ]),
559
- ],
560
- } : null;
561
-
562
- const detailSection = this.buildDetailSection(width);
563
- const footerLines = this.footerLines(width);
564
-
565
- const planSection = resolveScrollablePanelSection(width, height, {
566
- intro: plan.title,
567
- footerLines,
568
- palette: C,
569
- beforeSections: historyBanner ? [historyBanner, summary] : [summary],
570
- afterSections: detailSection ? [detailSection] : [],
571
- section: {
572
- title: 'Execution Plan',
573
- scrollableLines: planLines,
574
- selectedIndex: selectedLineIndex,
575
- scrollOffset: this.scrollOffset,
576
- minRows: 6,
577
- appendWindowSummary: { dimColor: C.dim },
578
- },
579
- });
580
- this.scrollOffset = planSection.scrollOffset;
581
-
582
- return buildPanelWorkspace(width, height, {
583
- title: ` Plan Dashboard`,
584
- intro: plan.title,
585
- sections: [
586
- ...(historyBanner ? [historyBanner] : []),
587
- summary,
588
- planSection.section,
589
- ...(detailSection ? [detailSection] : []),
590
- ],
591
- footerLines,
592
- palette: C,
593
- });
594
- }
595
-
596
- private buildDetailSection(width: number): PanelWorkspaceSection | null {
597
- const item = this.selectedNavItem();
598
- if (!item) return null;
599
- const blocked = this.blockedItemIds.has(item.id);
600
- const lines: Line[] = [
601
- buildPanelLine(width, [
602
- [' ', C.label],
603
- [STATUS_ICON[item.status], STATUS_FG[item.status]],
604
- [' ', C.label],
605
- [truncateDisplay(item.description, Math.max(8, width - 4)), C.value],
606
- ]),
607
- buildKeyValueLine(width, [
608
- { label: 'phase', value: item.phase, valueColor: C.phase },
609
- { label: 'status', value: blocked ? 'blocked' : item.status.replace(/_/g, ' '), valueColor: blocked ? C.blocked : STATUS_FG[item.status] },
610
- ...(item.agentId ? [{ label: 'agent', value: item.agentId, valueColor: C.info }] : []),
611
- ], C),
612
- ];
613
- if (item.dependencies && item.dependencies.length > 0) {
614
- lines.push(buildPanelLine(width, [
615
- [' depends on ', C.label],
616
- [truncateDisplay(item.dependencies.join(', '), Math.max(8, width - 13)), blocked ? C.blocked : C.dim],
617
- ]));
618
- }
619
- return { title: 'Selected Step', lines };
620
- }
621
-
622
- private footerLines(width: number): Line[] {
623
- const hints: Array<{ keys: string; label: string }> = [
624
- { keys: this.totalRows > 0 ? `${this.selectedIndex + 1}/${this.totalRows}` : '0/0', label: 'step' },
625
- { keys: '↑/↓', label: 'navigate' },
626
- { keys: 'Home/End', label: 'jump' },
627
- { keys: 'h', label: 'history' },
628
- ];
629
- const item = this.selectedNavItem();
630
- if (item?.agentId) hints.push({ keys: 'Enter', label: 'inspect agent' });
631
- if (this.viewingPlanId !== null) hints.push({ keys: 'a', label: 'back to active' });
632
- return [buildKeyboardHints(width, hints, C)];
633
- }
634
-
635
- // --------------------------------------------------------------------------
636
- // Phase header — title + progress meter
637
- // --------------------------------------------------------------------------
638
-
639
- private renderPhaseHeaderLine(phase: string, items: PlanItem[], width: number): Line {
640
- const done = items.filter(
641
- (i) => i.status === 'complete' || i.status === 'skipped',
642
- ).length;
643
- const total = items.length;
644
- const active = items.some((i) => i.status === 'in_progress');
645
- const failed = items.some((i) => i.status === 'failed');
646
-
647
- const phaseFg = failed ? C.failed : active ? C.active : done === total ? C.complete : C.phase;
648
-
649
- const barW = 8;
650
- const filledB = total > 0 ? Math.round((done / total) * barW) : 0;
651
- const progressText = ` ${done}/${total}`;
652
- const label = truncateDisplay(phase, Math.max(4, width - barW - progressText.length - 6));
653
-
654
- return buildSelectablePanelLine(width, [
655
- { text: ` ${active ? '▸' : '▪'} `, fg: phaseFg, bold: true },
656
- { text: label, fg: phaseFg, bold: true },
657
- { text: ' ', fg: C.dim },
658
- { text: '▰'.repeat(filledB) + '▱'.repeat(barW - filledB), fg: phaseFg },
659
- { text: progressText, fg: C.dim },
660
- ], { fillBg: C.sectionBg });
661
- }
662
-
663
- // --------------------------------------------------------------------------
664
- // Individual item
665
- // --------------------------------------------------------------------------
666
-
667
- private renderItem(
668
- item: PlanItem,
669
- isSelected: boolean,
670
- isBlocked: boolean,
671
- width: number,
672
- ): Line {
673
- const icon = STATUS_ICON[item.status];
674
- const fg = isBlocked ? C.blocked : STATUS_FG[item.status];
675
- const dim = item.status === 'skipped';
676
-
677
- // Indent blocked items to visually signal they depend on others
678
- const indent = isBlocked ? ' ' : ' ';
679
- const agentTag = item.agentId && (item.status === 'in_progress' || item.status === 'complete')
680
- ? ` [${item.agentId}]`
681
- : '';
682
- const blockedTag = isBlocked ? ' ⊘ blocked' : '';
683
- const reserve = indent.length + 2 + agentTag.length + blockedTag.length;
684
- const desc = truncateDisplay(item.description, Math.max(6, width - reserve - 2));
685
-
686
- return buildSelectablePanelLine(width, [
687
- { text: `${indent}${icon} `, fg, dim, bold: item.status === 'in_progress' },
688
- { text: desc, fg, dim },
689
- { text: agentTag, fg: C.info },
690
- { text: blockedTag, fg: C.blocked },
691
- ], {
692
- selected: isSelected,
693
- selectedBg: C.selectBg,
694
- leadingMarker: '▸',
695
- });
696
- }
697
-
698
- private statusColor(status: ExecutionPlan['status']): string {
699
- return status === 'complete'
700
- ? C.good
701
- : status === 'failed'
702
- ? C.bad
703
- : status === 'active'
704
- ? C.info
705
- : C.dim;
706
- }
707
- }