@pellux/goodvibes-tui 0.28.0 → 1.0.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 (144) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/README.md +1 -1
  3. package/package.json +1 -1
  4. package/src/core/conversation-line-cache.ts +432 -0
  5. package/src/core/conversation-rendering.ts +11 -3
  6. package/src/core/conversation.ts +50 -4
  7. package/src/input/commands/cost-runtime.ts +49 -0
  8. package/src/input/commands/operator-runtime.ts +5 -1
  9. package/src/input/commands.ts +2 -0
  10. package/src/input/handler-content-actions.ts +8 -3
  11. package/src/input/handler-feed-routes.ts +12 -35
  12. package/src/input/handler-feed.ts +4 -8
  13. package/src/input/handler-shortcuts.ts +51 -0
  14. package/src/input/handler.ts +43 -6
  15. package/src/input/input-history.ts +17 -4
  16. package/src/input/keybindings.ts +48 -8
  17. package/src/input/panel-integration-actions.ts +107 -1
  18. package/src/main.ts +19 -11
  19. package/src/panels/agent-inspector-panel.ts +125 -36
  20. package/src/panels/agent-inspector-shared.ts +144 -0
  21. package/src/panels/approval-panel.ts +67 -16
  22. package/src/panels/automation-control-panel.ts +368 -124
  23. package/src/panels/base-panel.ts +1 -1
  24. package/src/panels/builtin/agent.ts +28 -37
  25. package/src/panels/builtin/development.ts +40 -32
  26. package/src/panels/builtin/knowledge.ts +15 -6
  27. package/src/panels/builtin/operations.ts +178 -117
  28. package/src/panels/builtin/session.ts +35 -9
  29. package/src/panels/builtin/shared.ts +98 -6
  30. package/src/panels/cockpit-panel.ts +232 -73
  31. package/src/panels/communication-panel.ts +58 -20
  32. package/src/panels/confirm-state.ts +8 -1
  33. package/src/panels/control-plane-panel.ts +351 -118
  34. package/src/panels/cost-tracker-panel.ts +165 -7
  35. package/src/panels/debug-panel.ts +312 -159
  36. package/src/panels/diff-panel.ts +209 -57
  37. package/src/panels/docs-panel.ts +152 -66
  38. package/src/panels/eval-panel.ts +220 -42
  39. package/src/panels/file-explorer-panel.ts +202 -122
  40. package/src/panels/file-preview-panel.ts +132 -57
  41. package/src/panels/git-panel.ts +310 -129
  42. package/src/panels/hooks-panel.ts +150 -22
  43. package/src/panels/incident-review-panel.ts +223 -35
  44. package/src/panels/index.ts +0 -4
  45. package/src/panels/intelligence-panel.ts +212 -86
  46. package/src/panels/knowledge-graph-panel.ts +461 -101
  47. package/src/panels/local-auth-panel.ts +240 -28
  48. package/src/panels/marketplace-panel.ts +193 -26
  49. package/src/panels/memory-panel.ts +78 -77
  50. package/src/panels/ops-control-panel.ts +146 -29
  51. package/src/panels/ops-strategy-panel.ts +72 -4
  52. package/src/panels/orchestration-panel.ts +231 -69
  53. package/src/panels/panel-list-panel.ts +154 -131
  54. package/src/panels/panel-manager.ts +97 -9
  55. package/src/panels/plan-dashboard-panel.ts +333 -17
  56. package/src/panels/plugins-panel.ts +184 -29
  57. package/src/panels/policy-panel.ts +210 -38
  58. package/src/panels/polish-core.ts +7 -2
  59. package/src/panels/polish.ts +23 -4
  60. package/src/panels/project-planning-answer-actions.ts +134 -0
  61. package/src/panels/project-planning-panel.ts +62 -113
  62. package/src/panels/provider-health-panel.ts +434 -518
  63. package/src/panels/provider-health-routes.ts +203 -0
  64. package/src/panels/provider-health-tracker.ts +194 -6
  65. package/src/panels/provider-health-views.ts +560 -0
  66. package/src/panels/qr-panel.ts +116 -30
  67. package/src/panels/remote-panel.ts +114 -36
  68. package/src/panels/routes-panel.ts +63 -22
  69. package/src/panels/sandbox-panel.ts +174 -42
  70. package/src/panels/scrollable-list-panel.ts +19 -135
  71. package/src/panels/security-panel.ts +133 -33
  72. package/src/panels/services-panel.ts +116 -64
  73. package/src/panels/session-browser-panel.ts +73 -2
  74. package/src/panels/session-maintenance.ts +4 -122
  75. package/src/panels/settings-sync-panel.ts +335 -72
  76. package/src/panels/skills-panel.ts +157 -89
  77. package/src/panels/subscription-panel.ts +86 -33
  78. package/src/panels/symbol-outline-panel.ts +248 -108
  79. package/src/panels/system-messages-panel.ts +114 -13
  80. package/src/panels/tasks-panel.ts +326 -139
  81. package/src/panels/thinking-panel.ts +43 -10
  82. package/src/panels/token-budget-panel.ts +194 -18
  83. package/src/panels/tool-inspector-panel.ts +144 -34
  84. package/src/panels/types.ts +40 -4
  85. package/src/panels/work-plan-panel.ts +280 -17
  86. package/src/panels/worktree-panel.ts +175 -42
  87. package/src/panels/wrfc-panel.ts +116 -24
  88. package/src/renderer/agent-detail-modal.ts +37 -8
  89. package/src/renderer/code-block.ts +58 -28
  90. package/src/renderer/context-inspector.ts +3 -6
  91. package/src/renderer/conversation-overlays.ts +25 -11
  92. package/src/renderer/conversation-surface.ts +1 -21
  93. package/src/renderer/diff-view.ts +6 -4
  94. package/src/renderer/footer-tips.ts +41 -0
  95. package/src/renderer/fullscreen-primitives.ts +23 -17
  96. package/src/renderer/fullscreen-workspace.ts +2 -7
  97. package/src/renderer/help-overlay.ts +91 -14
  98. package/src/renderer/hint-grammar.ts +52 -0
  99. package/src/renderer/history-search-overlay.ts +10 -16
  100. package/src/renderer/layout.ts +7 -7
  101. package/src/renderer/markdown.ts +9 -1
  102. package/src/renderer/modal-factory.ts +23 -15
  103. package/src/renderer/model-picker-overlay.ts +8 -485
  104. package/src/renderer/model-workspace.ts +9 -24
  105. package/src/renderer/overlay-box.ts +23 -19
  106. package/src/renderer/process-indicator.ts +15 -25
  107. package/src/renderer/profile-picker-modal.ts +13 -14
  108. package/src/renderer/prompt-content-width.ts +16 -0
  109. package/src/renderer/search-overlay.ts +27 -6
  110. package/src/renderer/selection-modal-overlay.ts +3 -1
  111. package/src/renderer/semantic-diff.ts +1 -1
  112. package/src/renderer/session-picker-modal.ts +6 -4
  113. package/src/renderer/settings-modal-helpers.ts +10 -34
  114. package/src/renderer/settings-modal.ts +70 -10
  115. package/src/renderer/shell-surface.ts +54 -15
  116. package/src/renderer/status-glyphs.ts +11 -9
  117. package/src/renderer/surface-layout.ts +0 -12
  118. package/src/renderer/term-caps.ts +1 -1
  119. package/src/renderer/theme.ts +60 -3
  120. package/src/renderer/tool-call.ts +6 -20
  121. package/src/renderer/ui-factory.ts +48 -37
  122. package/src/renderer/ui-primitives.ts +41 -3
  123. package/src/runtime/bootstrap-shell.ts +35 -18
  124. package/src/runtime/diagnostics/panels/index.ts +0 -3
  125. package/src/runtime/render-scheduler.ts +80 -0
  126. package/src/shell/ui-openers.ts +14 -22
  127. package/src/utils/format-duration.ts +2 -2
  128. package/src/utils/splash-lines.ts +54 -5
  129. package/src/version.ts +1 -1
  130. package/src/work-plans/work-plan-store.ts +13 -0
  131. package/src/panels/agent-logs-panel.ts +0 -635
  132. package/src/panels/agent-logs-shared.ts +0 -129
  133. package/src/panels/context-visualizer-panel.ts +0 -238
  134. package/src/panels/forensics-panel.ts +0 -378
  135. package/src/panels/provider-account-snapshot.ts +0 -259
  136. package/src/panels/provider-accounts-panel.ts +0 -255
  137. package/src/panels/provider-stats-panel.ts +0 -391
  138. package/src/panels/schedule-panel.ts +0 -365
  139. package/src/panels/watchers-panel.ts +0 -213
  140. package/src/renderer/file-tree.ts +0 -153
  141. package/src/renderer/progress.ts +0 -99
  142. package/src/renderer/status-token.ts +0 -67
  143. package/src/runtime/diagnostics/panels/panel-resources.ts +0 -118
  144. package/src/runtime/diagnostics/panels/policy.ts +0 -177
@@ -1,34 +1,59 @@
1
+ import { logger } from '@pellux/goodvibes-sdk/platform/utils';
1
2
  import type { Line } from '../types/grid.ts';
3
+ import { createEmptyLine } from '../types/grid.ts';
2
4
  import { fitDisplay, truncateDisplay } from '../utils/terminal-width.ts';
3
5
  import { ScrollableListPanel } from './scrollable-list-panel.ts';
4
6
  import {
5
7
  buildDetailBlock,
6
- buildGuidanceLine,
7
8
  buildKeyboardHints,
8
9
  buildPanelListRow,
9
10
  buildPanelLine,
11
+ buildPanelWorkspace,
10
12
  buildStatusPill,
11
13
  buildSummaryBlock,
12
14
  DEFAULT_PANEL_PALETTE,
15
+ resolveScrollablePanelSection,
13
16
  type PanelPalette,
17
+ type PanelWorkspaceSection,
14
18
  } from './polish.ts';
15
19
  import { getSettingsControlPlaneSnapshot } from '@/runtime/index.ts';
16
20
  import type { ConfigManager } from '../config/index.ts';
21
+ import type { PanelIntegrationContext } from './types.ts';
17
22
 
18
- const C = {
19
- ...DEFAULT_PANEL_PALETTE,
20
- dim: '#475569',
21
- info: '#38bdf8',
22
- ok: '#22c55e',
23
- warn: '#eab308',
24
- error: '#ef4444',
25
- } as const;
23
+ // Base chrome only — state colors and text tokens come straight from
24
+ // DEFAULT_PANEL_PALETTE (WO-002).
25
+ const C = DEFAULT_PANEL_PALETTE;
26
26
 
27
- type ResolvedEntry = ReturnType<typeof getSettingsControlPlaneSnapshot>['resolvedEntries'][number];
27
+ type SettingsSnapshot = ReturnType<typeof getSettingsControlPlaneSnapshot>;
28
+ type ResolvedEntry = SettingsSnapshot['resolvedEntries'][number];
29
+
30
+ // Tab-toggled browse modes (RemotePanel pattern): 'keys' is the primary
31
+ // selectable list (kept at its own scroll viewport); the rest were
32
+ // previously dumped unconditionally into the header, squeezing the key
33
+ // list out of view.
34
+ const BROWSE_MODES = ['keys', 'events', 'locks', 'failures', 'conflicts', 'rollback'] as const;
35
+ type BrowseMode = typeof BROWSE_MODES[number];
36
+
37
+ interface BrowseModeContent {
38
+ readonly title: string;
39
+ readonly rows: Line[];
40
+ readonly emptyMessage: string;
41
+ }
28
42
 
29
43
  export class SettingsSyncPanel extends ScrollableListPanel<ResolvedEntry> {
44
+ private browseMode: BrowseMode = 'keys';
45
+ private browseIndex = 0;
46
+ private browseScrollOffset = 0;
47
+
48
+ // Inline local/synced picker for a conflicted entry (Enter on the keys
49
+ // list). Resolved via handlePanelIntegrationAction, the only place
50
+ // executeCommand is available.
51
+ private _resolvePrompt: { readonly key: string } | null = null;
52
+ private _pendingResolve: { readonly key: string; readonly choice: 'local' | 'synced' } | null = null;
53
+ private _pendingManagedReview = false;
54
+
30
55
  public constructor(private readonly configManager: ConfigManager) {
31
- super('settings-sync', 'Settings Sync', 'S', 'monitoring');
56
+ super('settings-sync', 'Settings Sync', '', 'security-policy');
32
57
  this.showSelectionGutter = true; // I5: non-color selection affordance
33
58
  this.filterEnabled = true;
34
59
  this.filterLabel = 'Filter settings';
@@ -51,8 +76,8 @@ export class SettingsSyncPanel extends ScrollableListPanel<ResolvedEntry> {
51
76
  protected renderItem(entry: ResolvedEntry, _index: number, selected: boolean, width: number): Line {
52
77
  return buildPanelListRow(width, [
53
78
  { text: fitDisplay(entry.key, 32).padEnd(32), fg: C.value },
54
- { text: ` ${entry.effectiveSource}`.padEnd(11), fg: entry.effectiveSource === 'managed' ? C.warn : entry.effectiveSource === 'synced' ? C.ok : entry.effectiveSource === 'local' ? C.info : C.dim },
55
- { text: truncateDisplay(`${String(entry.effectiveValue)}`, Math.max(0, width - 47)), fg: entry.locked ? C.warn : C.dim },
79
+ { text: ` ${entry.effectiveSource}`.padEnd(11), fg: entry.effectiveSource === 'managed' ? C.warn : entry.effectiveSource === 'synced' ? C.good : entry.effectiveSource === 'local' ? C.info : C.dim },
80
+ { text: truncateDisplay(`${String(entry.effectiveValue)}`, Math.max(0, width - 47)), fg: entry.conflict ? C.bad : entry.locked ? C.warn : C.dim },
56
81
  ], C, { selected });
57
82
  }
58
83
 
@@ -60,76 +85,314 @@ export class SettingsSyncPanel extends ScrollableListPanel<ResolvedEntry> {
60
85
  return ' No resolved settings entries.';
61
86
  }
62
87
 
63
- public render(width: number, height: number): Line[] {
88
+ /** Enter on a conflicted entry opens the inline local/synced picker. */
89
+ protected override onSelect(entry: ResolvedEntry): void {
90
+ if (!entry.conflict) return;
91
+ this._resolvePrompt = { key: entry.key };
92
+ this.needsRender = true;
93
+ }
94
+
95
+ public override handleInput(key: string): boolean {
96
+ if (this.lastError !== null) this.clearError();
97
+
98
+ if (this._resolvePrompt) {
99
+ if (key === 'l') {
100
+ this._pendingResolve = { key: this._resolvePrompt.key, choice: 'local' };
101
+ this._resolvePrompt = null;
102
+ this.needsRender = true;
103
+ return true;
104
+ }
105
+ if (key === 's') {
106
+ this._pendingResolve = { key: this._resolvePrompt.key, choice: 'synced' };
107
+ this._resolvePrompt = null;
108
+ this.needsRender = true;
109
+ return true;
110
+ }
111
+ if (key === 'escape' || key === 'n') {
112
+ this._resolvePrompt = null;
113
+ this.needsRender = true;
114
+ return true;
115
+ }
116
+ return true; // absorbed — keep the picker pending
117
+ }
118
+
119
+ // The inline `/`-filter capture must win over browse-mode/managed-review
120
+ // keys while it is actively collecting a query (e.g. typing "m").
121
+ if (this.filterActive) {
122
+ return super.handleInput(key);
123
+ }
124
+
125
+ if (key === 'tab') {
126
+ const idx = BROWSE_MODES.indexOf(this.browseMode);
127
+ this.browseMode = BROWSE_MODES[(idx + 1) % BROWSE_MODES.length]!;
128
+ this.browseIndex = 0;
129
+ this.browseScrollOffset = 0;
130
+ this.needsRender = true;
131
+ return true;
132
+ }
133
+
134
+ if (key === 'm') {
135
+ const snapshot = getSettingsControlPlaneSnapshot(this.configManager);
136
+ if (snapshot.stagedManagedBundle) {
137
+ this._pendingManagedReview = true;
138
+ return true;
139
+ }
140
+ return false;
141
+ }
142
+
143
+ if (this.browseMode !== 'keys') {
144
+ return this._handleBrowseInput(key);
145
+ }
146
+
147
+ return super.handleInput(key);
148
+ }
149
+
150
+ public handlePanelIntegrationAction(_key: string, ctx: PanelIntegrationContext): boolean {
151
+ if (this._pendingResolve) {
152
+ const { key, choice } = this._pendingResolve;
153
+ this._pendingResolve = null;
154
+ void ctx.executeCommand?.('settings-sync', ['resolve', key, choice]).catch((err) => {
155
+ logger.debug('settings-sync resolve dispatch failed', { err });
156
+ });
157
+ return true;
158
+ }
159
+ if (this._pendingManagedReview) {
160
+ this._pendingManagedReview = false;
161
+ void ctx.executeCommand?.('managed', ['review']).catch((err) => {
162
+ logger.debug('managed review dispatch failed', { err });
163
+ });
164
+ return true;
165
+ }
166
+ return false;
167
+ }
168
+
169
+ private _browseItemCount(): number {
64
170
  const snapshot = getSettingsControlPlaneSnapshot(this.configManager);
171
+ switch (this.browseMode) {
172
+ case 'events': return snapshot.recentEvents.length;
173
+ case 'locks': return snapshot.managedLocks.length;
174
+ case 'failures': return snapshot.recentFailures.length;
175
+ case 'conflicts': return snapshot.conflicts.length;
176
+ case 'rollback': return snapshot.rollbackHistory.length;
177
+ default: return 0;
178
+ }
179
+ }
65
180
 
66
- const postureLines: Line[] = [
67
- buildPanelLine(width, [[' resolved keys ', C.label], [String(snapshot.resolvedEntries.length), C.value], [' conflicts ', C.label], ...buildStatusPill(snapshot.conflicts.length > 0 ? 'bad' : 'good', String(snapshot.conflicts.length)), [' failures ', C.label], ...buildStatusPill(snapshot.recentFailures.length > 0 ? 'warn' : 'good', String(snapshot.recentFailures.length))]),
68
- buildPanelLine(width, [[' managed locks ', C.label], [String(snapshot.managedLockCount), snapshot.managedLockCount > 0 ? C.warn : C.dim], [' staged bundle ', C.label], [snapshot.stagedManagedBundle ? snapshot.stagedManagedBundle.profileName : 'none', snapshot.stagedManagedBundle ? C.info : C.dim]]),
69
- buildGuidanceLine(width, '/settings-sync conflicts', 'review conflicting synced values before they silently shape effective configuration', C),
70
- buildGuidanceLine(width, '/managed review', 'inspect staged managed changes, risk posture, and rollback records', C),
181
+ private _handleBrowseInput(key: string): boolean {
182
+ const count = this._browseItemCount();
183
+ if (count === 0) return false;
184
+ switch (key) {
185
+ case 'up':
186
+ case 'k':
187
+ this.browseIndex = Math.max(0, this.browseIndex - 1);
188
+ this.needsRender = true;
189
+ return true;
190
+ case 'down':
191
+ case 'j':
192
+ this.browseIndex = Math.min(count - 1, this.browseIndex + 1);
193
+ this.needsRender = true;
194
+ return true;
195
+ case 'pageup':
196
+ this.browseIndex = Math.max(0, this.browseIndex - this.getPageSize());
197
+ this.needsRender = true;
198
+ return true;
199
+ case 'pagedown':
200
+ this.browseIndex = Math.min(count - 1, this.browseIndex + this.getPageSize());
201
+ this.needsRender = true;
202
+ return true;
203
+ case 'home':
204
+ case 'g':
205
+ this.browseIndex = 0;
206
+ this.needsRender = true;
207
+ return true;
208
+ case 'end':
209
+ case 'G':
210
+ this.browseIndex = count - 1;
211
+ this.needsRender = true;
212
+ return true;
213
+ default:
214
+ return false;
215
+ }
216
+ }
217
+
218
+ /** ≤5 fixed rows total (1 summary title + 4 rows), shared by every mode. */
219
+ private _buildPostureHeader(width: number, snapshot: SettingsSnapshot): Line[] {
220
+ const rows: Line[] = [
221
+ buildPanelLine(width, [
222
+ [' resolved keys ', C.label], [String(snapshot.resolvedEntries.length), C.value],
223
+ [' conflicts ', C.label], ...buildStatusPill(snapshot.conflicts.length > 0 ? 'bad' : 'good', String(snapshot.conflicts.length)),
224
+ [' failures ', C.label], ...buildStatusPill(snapshot.recentFailures.length > 0 ? 'warn' : 'good', String(snapshot.recentFailures.length)),
225
+ ]),
226
+ buildPanelLine(width, [
227
+ [' managed locks ', C.label], [String(snapshot.managedLockCount), snapshot.managedLockCount > 0 ? C.warn : C.dim],
228
+ [' staged bundle ', C.label], [snapshot.stagedManagedBundle ? snapshot.stagedManagedBundle.profileName : 'none', snapshot.stagedManagedBundle ? C.info : C.dim],
229
+ ]),
230
+ buildPanelLine(width, [
231
+ [' effective local ', C.label], [String(snapshot.resolvedCounts.local), C.info],
232
+ [' synced ', C.label], [String(snapshot.resolvedCounts.synced), snapshot.resolvedCounts.synced > 0 ? C.good : C.dim],
233
+ [' managed ', C.label], [String(snapshot.resolvedCounts.managed), snapshot.resolvedCounts.managed > 0 ? C.warn : C.dim],
234
+ ]),
235
+ buildPanelLine(width, [
236
+ [' last sync ', C.label], [snapshot.lastSync ? `${snapshot.lastSync.surface}/${snapshot.lastSync.direction}` : 'none', snapshot.lastSync ? C.good : C.dim],
237
+ [' mode ', C.label], [this.browseMode, C.info],
238
+ ]),
71
239
  ];
240
+ return buildSummaryBlock(width, 'Settings posture', rows, C);
241
+ }
72
242
 
73
- const headerLines: Line[] = [
74
- ...buildSummaryBlock(width, 'Settings posture', postureLines, C),
75
- buildPanelLine(width, [[' local typed config ', C.label], [String(snapshot.liveKeyCount), C.value], [' saved profiles ', C.label], [String(snapshot.profileCount), C.info], [' managed locks ', C.label], [String(snapshot.managedLockCount), snapshot.managedLockCount > 0 ? C.warn : C.dim]]),
76
- buildPanelLine(width, [[' effective local ', C.label], [String(snapshot.resolvedCounts.local), C.info], [' synced ', C.label], [String(snapshot.resolvedCounts.synced), snapshot.resolvedCounts.synced > 0 ? C.ok : C.dim], [' managed ', C.label], [String(snapshot.resolvedCounts.managed), snapshot.resolvedCounts.managed > 0 ? C.warn : C.dim]]),
77
- buildPanelLine(width, [[' last sync ', C.label], [snapshot.lastSync ? `${snapshot.lastSync.surface}/${snapshot.lastSync.direction}` : 'none', snapshot.lastSync ? C.ok : C.dim], [' when ', C.label], [snapshot.lastSync ? new Date(snapshot.lastSync.timestamp).toLocaleString() : 'n/a', C.dim]]),
78
- // Staged Bundle
79
- ...(snapshot.stagedManagedBundle
80
- ? [
81
- buildPanelLine(width, [[' profile ', C.label], [snapshot.stagedManagedBundle.profileName, C.value], [' risk ', C.label], [snapshot.stagedManagedBundle.risk, snapshot.stagedManagedBundle.risk === 'high' ? C.error : snapshot.stagedManagedBundle.risk === 'medium' ? C.warn : C.ok], [' changes ', C.label], [String(snapshot.stagedManagedBundle.changeCount), C.info]]),
82
- buildPanelLine(width, [[' path ', C.label], [truncateDisplay(snapshot.stagedManagedBundle.path, Math.max(0, width - 9)), C.dim]]),
83
- ]
84
- : [buildPanelLine(width, [[' No staged managed settings bundle.', C.dim]])]),
85
- // Recent Events
86
- ...(snapshot.recentEvents.length > 0
87
- ? snapshot.recentEvents.map((event) => buildPanelLine(width, [[fitDisplay(` ${event.surface}/${event.direction}`, 18).padEnd(18), C.info], [truncateDisplay(` ${event.detail}`, Math.max(0, width - 20)), C.dim]]))
88
- : [buildPanelLine(width, [[' No sync or managed-setting events recorded yet.', C.dim]])]),
89
- // Managed Locks
90
- ...(snapshot.managedLocks.length > 0
91
- ? snapshot.managedLocks.slice(0, 10).map((lock) => buildPanelLine(width, [[fitDisplay(` ${lock.key}`, 30).padEnd(30), C.value], [fitDisplay(` source=${lock.source}`, 24).padEnd(24), C.info], [truncateDisplay(` ${lock.reason}`, Math.max(0, width - 56)), C.dim]]))
92
- : [buildPanelLine(width, [[' No managed locks are currently active.', C.dim]])]),
93
- // Failures
94
- ...(snapshot.recentFailures.length > 0
95
- ? snapshot.recentFailures.map((failure) => buildPanelLine(width, [[` ${failure.surface}`.padEnd(10), C.error], [truncateDisplay(` ${failure.message}`, Math.max(0, width - 12)), C.dim]]))
96
- : [buildPanelLine(width, [[' No recent sync or managed-setting failures.', C.dim]])]),
97
- // Conflicts
98
- ...(snapshot.conflicts.length > 0
99
- ? snapshot.conflicts.map((conflict) => buildPanelLine(width, [[fitDisplay(` ${conflict.key}`, 30).padEnd(30), C.value], [fitDisplay(` ${conflict.source}`, 10).padEnd(10), C.warn], [truncateDisplay(` resolve: /settings-sync resolve ${conflict.key} local|synced`, Math.max(0, width - 42)), C.dim]]))
100
- : [buildPanelLine(width, [[' No settings conflicts detected.', C.dim]])]),
101
- // Rollback History
102
- ...(snapshot.rollbackHistory.length > 0
103
- ? snapshot.rollbackHistory.map((entry) => buildPanelLine(width, [[fitDisplay(` ${entry.token}`, 18).padEnd(18), C.info], [fitDisplay(` ${entry.profileName}`, 18).padEnd(18), C.value], [` restored=${String(entry.restoredKeys.length).padEnd(4)}`, C.warn], [truncateDisplay(` ${new Date(entry.appliedAt).toLocaleString()}`, Math.max(0, width - 46)), C.dim]]))
104
- : [buildPanelLine(width, [[' No managed rollback records yet.', C.dim]])]),
243
+ private _buildResolvePromptLines(width: number, key: string): Line[] {
244
+ return [
245
+ buildPanelLine(width, [[` Resolve conflict for "${key}"?`, C.warn]]),
246
+ buildPanelLine(width, [
247
+ [' l', C.info], [' keep local', C.dim],
248
+ [' s', C.info], [' use synced', C.dim],
249
+ [' Esc', C.info], [' cancel', C.dim],
250
+ ]),
105
251
  ];
252
+ }
253
+
254
+ private _buildBrowseModeContent(width: number, snapshot: SettingsSnapshot): BrowseModeContent {
255
+ switch (this.browseMode) {
256
+ case 'events':
257
+ return {
258
+ title: 'Recent Sync & Managed-Setting Events',
259
+ rows: snapshot.recentEvents.map((event, index) => buildPanelListRow(width, [
260
+ { text: fitDisplay(` ${event.surface}/${event.direction}`, 18).padEnd(18), fg: C.info },
261
+ { text: truncateDisplay(` ${event.detail}`, Math.max(0, width - 20)), fg: C.dim },
262
+ ], C, { selected: index === this.browseIndex })),
263
+ emptyMessage: ' No sync or managed-setting events recorded yet.',
264
+ };
265
+ case 'locks':
266
+ return {
267
+ title: 'Managed Locks',
268
+ rows: snapshot.managedLocks.map((lock, index) => buildPanelListRow(width, [
269
+ { text: fitDisplay(` ${lock.key}`, 30).padEnd(30), fg: C.value },
270
+ { text: fitDisplay(` source=${lock.source}`, 24).padEnd(24), fg: C.info },
271
+ { text: truncateDisplay(` ${lock.reason}`, Math.max(0, width - 56)), fg: C.dim },
272
+ ], C, { selected: index === this.browseIndex })),
273
+ emptyMessage: ' No managed locks are currently active.',
274
+ };
275
+ case 'failures':
276
+ return {
277
+ title: 'Sync & Managed-Setting Failures',
278
+ rows: snapshot.recentFailures.map((failure, index) => buildPanelListRow(width, [
279
+ { text: ` ${failure.surface}`.padEnd(10), fg: C.bad },
280
+ { text: truncateDisplay(` ${failure.message}`, Math.max(0, width - 12)), fg: C.dim },
281
+ ], C, { selected: index === this.browseIndex })),
282
+ emptyMessage: ' No recent sync or managed-setting failures.',
283
+ };
284
+ case 'conflicts':
285
+ return {
286
+ title: 'Settings Conflicts',
287
+ rows: snapshot.conflicts.map((conflict, index) => buildPanelListRow(width, [
288
+ { text: fitDisplay(` ${conflict.key}`, 30).padEnd(30), fg: C.value },
289
+ { text: fitDisplay(` ${conflict.source}`, 10).padEnd(10), fg: C.warn },
290
+ { text: truncateDisplay(` local=${String(conflict.localValue)} incoming=${String(conflict.incomingValue)}`, Math.max(0, width - 42)), fg: C.dim },
291
+ ], C, { selected: index === this.browseIndex })),
292
+ emptyMessage: ' No settings conflicts detected. Resolve conflicts from the keys list (Enter on a conflicted entry).',
293
+ };
294
+ case 'rollback':
295
+ return {
296
+ title: 'Managed Rollback History',
297
+ rows: snapshot.rollbackHistory.map((entry, index) => buildPanelListRow(width, [
298
+ { text: fitDisplay(` ${entry.token}`, 18).padEnd(18), fg: C.info },
299
+ { text: fitDisplay(` ${entry.profileName}`, 18).padEnd(18), fg: C.value },
300
+ { text: ` restored=${String(entry.restoredKeys.length).padEnd(4)}`, fg: C.warn },
301
+ { text: truncateDisplay(` ${new Date(entry.appliedAt).toLocaleString()}`, Math.max(0, width - 46)), fg: C.dim },
302
+ ], C, { selected: index === this.browseIndex })),
303
+ emptyMessage: ' No managed rollback records yet.',
304
+ };
305
+ default:
306
+ return { title: '', rows: [], emptyMessage: '' };
307
+ }
308
+ }
309
+
310
+ private _renderKeysMode(width: number, height: number, snapshot: SettingsSnapshot): Line[] {
311
+ const headerLines = this._buildPostureHeader(width, snapshot);
106
312
 
107
313
  this.clampSelection();
108
- const selectedEntry = snapshot.resolvedEntries[this.selectedIndex];
109
- const footerLines: Line[] = [
110
- ...(selectedEntry
111
- ? buildDetailBlock(width, 'Selected setting', [
112
- buildPanelLine(width, [[' key ', C.label], [selectedEntry.key, C.value], [' category ', C.label], [selectedEntry.category, C.info]]),
113
- buildPanelLine(width, [[' effective ', C.label], [selectedEntry.effectiveSource, selectedEntry.effectiveSource === 'managed' ? C.warn : selectedEntry.effectiveSource === 'synced' ? C.ok : selectedEntry.effectiveSource === 'local' ? C.info : C.dim], [' locked ', C.label], [selectedEntry.locked ? 'yes' : 'no', selectedEntry.locked ? C.warn : C.dim], [' conflict ', C.label], [selectedEntry.conflict ? 'yes' : 'no', selectedEntry.conflict ? C.error : C.good]]),
114
- buildPanelLine(width, [[' source ', C.label], [truncateDisplay(selectedEntry.sourceLabel ?? 'local/default', Math.max(0, width - 10)), C.dim]]),
115
- buildPanelLine(width, [[' overrides ', C.label], [truncateDisplay(selectedEntry.overriddenSources.length > 0 ? selectedEntry.overriddenSources.join(', ') : 'none', Math.max(0, width - 13)), C.dim]]),
116
- buildPanelLine(width, [[' local ', C.label], [truncateDisplay(String(selectedEntry.localValue), Math.max(0, width - 9)), C.dim]]),
117
- buildPanelLine(width, [[' synced ', C.label], [truncateDisplay(String(selectedEntry.syncedValue ?? '(unset)'), Math.max(0, width - 10)), C.ok]]),
118
- buildPanelLine(width, [[' managed ', C.label], [truncateDisplay(String(selectedEntry.managedValue ?? '(unset)'), Math.max(0, width - 11)), C.warn]]),
119
- ], C)
120
- : [buildPanelLine(width, [[' Select a setting above to inspect its effective value, source, and overrides.', C.dim]])]),
121
- buildKeyboardHints(width, [
122
- { keys: '↑/↓', label: 'browse' },
123
- { keys: '/', label: 'filter' },
124
- { keys: '/settings-sync show <key>', label: 'inspect' },
125
- { keys: '/settings-sync resolve <key> <local|synced>', label: 'resolve conflict' },
126
- ], C),
127
- ];
314
+ // Detail must describe the row the (possibly filtered) list highlights —
315
+ // raw resolvedEntries desyncs selectedIndex under an applied '/' filter.
316
+ const selectedEntry = this.getSelectedItem();
317
+ const detailLines: Line[] = this._resolvePrompt
318
+ ? this._buildResolvePromptLines(width, this._resolvePrompt.key)
319
+ : (selectedEntry
320
+ ? buildDetailBlock(width, 'Selected setting', [
321
+ buildPanelLine(width, [[' key ', C.label], [selectedEntry.key, C.value], [' category ', C.label], [selectedEntry.category, C.info]]),
322
+ buildPanelLine(width, [[' effective ', C.label], [selectedEntry.effectiveSource, selectedEntry.effectiveSource === 'managed' ? C.warn : selectedEntry.effectiveSource === 'synced' ? C.good : selectedEntry.effectiveSource === 'local' ? C.info : C.dim], [' locked ', C.label], [selectedEntry.locked ? 'yes' : 'no', selectedEntry.locked ? C.warn : C.dim], [' conflict ', C.label], [selectedEntry.conflict ? 'yes' : 'no', selectedEntry.conflict ? C.bad : C.good]]),
323
+ buildPanelLine(width, [[' source ', C.label], [truncateDisplay(selectedEntry.sourceLabel ?? 'local/default', Math.max(0, width - 10)), C.dim]]),
324
+ buildPanelLine(width, [[' overrides ', C.label], [truncateDisplay(selectedEntry.overriddenSources.length > 0 ? selectedEntry.overriddenSources.join(', ') : 'none', Math.max(0, width - 13)), C.dim]]),
325
+ buildPanelLine(width, [[' local ', C.label], [truncateDisplay(String(selectedEntry.localValue), Math.max(0, width - 9)), C.dim]]),
326
+ buildPanelLine(width, [[' synced ', C.label], [truncateDisplay(String(selectedEntry.syncedValue ?? '(unset)'), Math.max(0, width - 10)), C.good]]),
327
+ buildPanelLine(width, [[' managed ', C.label], [truncateDisplay(String(selectedEntry.managedValue ?? '(unset)'), Math.max(0, width - 11)), C.warn]]),
328
+ ], C)
329
+ : [buildPanelLine(width, [[' Select a setting above to inspect its effective value, source, and overrides.', C.dim]])]);
128
330
 
129
331
  return this.renderList(width, height, {
130
332
  title: 'Settings Sync',
131
333
  header: headerLines,
132
- footer: footerLines,
334
+ // Keyboard hints are placed BEFORE the detail block (rather than after,
335
+ // which is the usual convention) so that if the fixed-row budget is
336
+ // tight, the tail of the detail block is what gets clipped by the
337
+ // panel-workspace row budget — not the hints row itself.
338
+ footer: [
339
+ buildKeyboardHints(width, [
340
+ { keys: '↑/↓', label: 'browse' },
341
+ { keys: '/', label: 'filter' },
342
+ { keys: 'enter', label: 'resolve conflict' },
343
+ { keys: 'tab', label: 'events/locks/failures/conflicts/rollback' },
344
+ { keys: 'm', label: 'managed review' },
345
+ ], C),
346
+ ...detailLines,
347
+ ],
133
348
  });
134
349
  }
350
+
351
+ private _renderBrowseMode(width: number, height: number, snapshot: SettingsSnapshot): Line[] {
352
+ this.needsRender = false;
353
+ const postureSection: PanelWorkspaceSection = { lines: this._buildPostureHeader(width, snapshot) };
354
+ const content = this._buildBrowseModeContent(width, snapshot);
355
+ const itemCount = content.rows.length;
356
+ this.browseIndex = itemCount > 0 ? Math.min(this.browseIndex, itemCount - 1) : 0;
357
+ const scrollableLines = itemCount > 0 ? content.rows : [buildPanelLine(width, [[content.emptyMessage, C.dim]])];
358
+
359
+ const hintsLine = buildKeyboardHints(width, [
360
+ { keys: '↑/↓', label: 'browse' },
361
+ { keys: 'tab', label: 'next mode' },
362
+ { keys: 'm', label: 'managed review' },
363
+ ], C);
364
+
365
+ const resolved = resolveScrollablePanelSection(width, height, {
366
+ palette: C,
367
+ beforeSections: [postureSection],
368
+ footerLines: [hintsLine],
369
+ section: {
370
+ title: content.title,
371
+ scrollableLines,
372
+ selectedIndex: itemCount > 0 ? this.browseIndex : undefined,
373
+ scrollOffset: this.browseScrollOffset,
374
+ guardRows: 1,
375
+ minRows: 4,
376
+ appendWindowSummary: { dimColor: C.dim },
377
+ },
378
+ });
379
+ this.browseScrollOffset = resolved.scrollOffset;
380
+
381
+ const lines = buildPanelWorkspace(width, height, {
382
+ title: 'Settings Sync',
383
+ sections: [postureSection, resolved.section],
384
+ footerLines: [hintsLine],
385
+ palette: C,
386
+ });
387
+ while (lines.length < height) lines.push(createEmptyLine(width));
388
+ return lines.slice(0, height);
389
+ }
390
+
391
+ public render(width: number, height: number): Line[] {
392
+ const snapshot = getSettingsControlPlaneSnapshot(this.configManager);
393
+ if (this.browseMode !== 'keys') {
394
+ return this._renderBrowseMode(width, height, snapshot);
395
+ }
396
+ return this._renderKeysMode(width, height, snapshot);
397
+ }
135
398
  }