@pellux/goodvibes-tui 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +101 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/input/commands/cost-runtime.ts +49 -0
- package/src/input/commands/operator-runtime.ts +5 -1
- package/src/input/commands.ts +2 -0
- package/src/input/handler-feed-routes.ts +12 -35
- package/src/input/handler-feed.ts +4 -8
- package/src/input/handler-shortcuts.ts +51 -0
- package/src/input/handler.ts +43 -6
- package/src/input/keybindings.ts +48 -8
- package/src/input/panel-integration-actions.ts +107 -1
- package/src/main.ts +5 -1
- package/src/panels/agent-inspector-panel.ts +125 -36
- package/src/panels/agent-inspector-shared.ts +144 -0
- package/src/panels/approval-panel.ts +67 -16
- package/src/panels/automation-control-panel.ts +368 -124
- package/src/panels/builtin/agent.ts +28 -37
- package/src/panels/builtin/development.ts +40 -32
- package/src/panels/builtin/knowledge.ts +15 -6
- package/src/panels/builtin/operations.ts +178 -117
- package/src/panels/builtin/session.ts +35 -9
- package/src/panels/builtin/shared.ts +98 -6
- package/src/panels/cockpit-panel.ts +232 -73
- package/src/panels/communication-panel.ts +58 -20
- package/src/panels/confirm-state.ts +8 -1
- package/src/panels/control-plane-panel.ts +351 -118
- package/src/panels/cost-tracker-panel.ts +165 -7
- package/src/panels/debug-panel.ts +312 -159
- package/src/panels/diff-panel.ts +203 -57
- package/src/panels/docs-panel.ts +152 -66
- package/src/panels/eval-panel.ts +220 -42
- package/src/panels/file-explorer-panel.ts +202 -122
- package/src/panels/file-preview-panel.ts +132 -57
- package/src/panels/git-panel.ts +309 -128
- package/src/panels/hooks-panel.ts +150 -22
- package/src/panels/incident-review-panel.ts +223 -35
- package/src/panels/index.ts +0 -4
- package/src/panels/intelligence-panel.ts +212 -86
- package/src/panels/knowledge-graph-panel.ts +461 -101
- package/src/panels/local-auth-panel.ts +240 -28
- package/src/panels/marketplace-panel.ts +193 -26
- package/src/panels/memory-panel.ts +78 -77
- package/src/panels/ops-control-panel.ts +146 -29
- package/src/panels/ops-strategy-panel.ts +72 -4
- package/src/panels/orchestration-panel.ts +231 -69
- package/src/panels/panel-list-panel.ts +154 -131
- package/src/panels/panel-manager.ts +97 -9
- package/src/panels/plan-dashboard-panel.ts +333 -17
- package/src/panels/plugins-panel.ts +184 -29
- package/src/panels/policy-panel.ts +210 -38
- package/src/panels/polish-core.ts +7 -2
- package/src/panels/polish.ts +23 -4
- package/src/panels/project-planning-answer-actions.ts +134 -0
- package/src/panels/project-planning-panel.ts +62 -113
- package/src/panels/provider-health-panel.ts +434 -518
- package/src/panels/provider-health-routes.ts +203 -0
- package/src/panels/provider-health-tracker.ts +194 -6
- package/src/panels/provider-health-views.ts +560 -0
- package/src/panels/qr-panel.ts +116 -30
- package/src/panels/remote-panel.ts +114 -36
- package/src/panels/routes-panel.ts +63 -22
- package/src/panels/sandbox-panel.ts +174 -42
- package/src/panels/scrollable-list-panel.ts +19 -135
- package/src/panels/security-panel.ts +133 -33
- package/src/panels/services-panel.ts +116 -64
- package/src/panels/session-browser-panel.ts +73 -2
- package/src/panels/session-maintenance.ts +4 -122
- package/src/panels/settings-sync-panel.ts +335 -72
- package/src/panels/skills-panel.ts +157 -89
- package/src/panels/subscription-panel.ts +86 -33
- package/src/panels/symbol-outline-panel.ts +248 -108
- package/src/panels/system-messages-panel.ts +114 -13
- package/src/panels/tasks-panel.ts +326 -139
- package/src/panels/thinking-panel.ts +43 -10
- package/src/panels/token-budget-panel.ts +194 -18
- package/src/panels/tool-inspector-panel.ts +144 -34
- package/src/panels/types.ts +40 -4
- package/src/panels/work-plan-panel.ts +280 -17
- package/src/panels/worktree-panel.ts +175 -42
- package/src/panels/wrfc-panel.ts +116 -24
- package/src/renderer/conversation-overlays.ts +25 -11
- package/src/renderer/footer-tips.ts +41 -0
- package/src/renderer/fullscreen-primitives.ts +22 -16
- package/src/renderer/help-overlay.ts +91 -14
- package/src/renderer/hint-grammar.ts +52 -0
- package/src/renderer/layout.ts +7 -7
- package/src/renderer/modal-factory.ts +23 -15
- package/src/renderer/model-picker-overlay.ts +21 -7
- package/src/renderer/overlay-box.ts +16 -10
- package/src/renderer/process-indicator.ts +3 -1
- package/src/renderer/progress.ts +5 -4
- package/src/renderer/search-overlay.ts +27 -6
- package/src/renderer/session-picker-modal.ts +6 -4
- package/src/renderer/settings-modal.ts +70 -10
- package/src/renderer/shell-surface.ts +41 -15
- package/src/renderer/status-glyphs.ts +11 -9
- package/src/renderer/theme.ts +60 -3
- package/src/renderer/ui-factory.ts +41 -30
- package/src/renderer/ui-primitives.ts +23 -2
- package/src/runtime/bootstrap-shell.ts +35 -18
- package/src/runtime/diagnostics/panels/index.ts +0 -3
- package/src/shell/ui-openers.ts +14 -22
- package/src/utils/format-duration.ts +2 -2
- package/src/utils/splash-lines.ts +44 -3
- package/src/version.ts +1 -1
- package/src/work-plans/work-plan-store.ts +13 -0
- package/src/panels/agent-logs-panel.ts +0 -635
- package/src/panels/agent-logs-shared.ts +0 -129
- package/src/panels/context-visualizer-panel.ts +0 -238
- package/src/panels/forensics-panel.ts +0 -378
- package/src/panels/provider-account-snapshot.ts +0 -259
- package/src/panels/provider-accounts-panel.ts +0 -255
- package/src/panels/provider-stats-panel.ts +0 -391
- package/src/panels/schedule-panel.ts +0 -365
- package/src/panels/watchers-panel.ts +0 -213
- package/src/runtime/diagnostics/panels/panel-resources.ts +0 -118
- 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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
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', '
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
buildPanelLine(width, [[
|
|
76
|
-
buildPanelLine(width, [
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
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
|
}
|