@git-stunts/git-cas 6.5.4 → 6.5.6

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.
@@ -2,26 +2,16 @@
2
2
  * TEA app shell for the V6 git-cas cockpit.
3
3
  */
4
4
 
5
- import { startApp as bijouStartApp } from '@flyingrobots/bijou-node';
6
5
  import {
7
- cpFilter,
8
- cpFocusNext,
9
- cpFocusPrev,
10
- cpPageDown,
11
- cpPageUp,
12
- cpSelectedItem,
13
- createCommandPaletteState,
6
+ createFramedApp,
7
+ createKeyMap,
14
8
  createNavigableTableState,
15
- createNotificationState,
16
9
  navTableFocusNext,
17
10
  navTableFocusPrev,
18
11
  navTablePageDown,
19
12
  navTablePageUp,
20
- notificationsNeedTick,
21
- pushNotification,
22
- quit,
13
+ notify,
23
14
  tick as bijouTick,
24
- tickNotifications,
25
15
  } from '@flyingrobots/bijou-tui';
26
16
  import { renderDashboard, tableSchema } from './dashboard-view.js';
27
17
  import { createCliTuiContext } from './context.js';
@@ -44,9 +34,7 @@ import { shortenSha } from './components/short-sha.js';
44
34
  /** @typedef {import('../src/domain/value-objects/Manifest.js').default} Manifest */
45
35
  /** @typedef {import('../src/domain/services/VaultService.js').VaultEntry} VaultEntry */
46
36
  /** @typedef {import('@flyingrobots/bijou').BijouContext} BijouContext */
47
- /** @typedef {import('@flyingrobots/bijou-tui').CommandPaletteState} CommandPaletteState */
48
37
  /** @typedef {import('@flyingrobots/bijou-tui').NavigableTableState} NavigableTableState */
49
- /** @typedef {import('@flyingrobots/bijou-tui').NotificationState} NotificationState */
50
38
  /** @typedef {import('./store-wizard.js').StoreWizardState} StoreWizardState */
51
39
  /** @typedef {import('./blocks/operation-feed.js').OperationFeedState} OperationFeedState */
52
40
 
@@ -62,9 +50,6 @@ import { shortenSha } from './components/short-sha.js';
62
50
  * @typedef {Object} DashModel
63
51
  * @property {AppPhase} phase
64
52
  * @property {number} titleTimeMs
65
- * @property {number} lastTickTime
66
- * @property {number} fps
67
- * @property {boolean} showPerfHud
68
53
  * @property {number} vaultEntryCount
69
54
  * @property {string} passphrase
70
55
  * @property {string | null} authError
@@ -80,16 +65,12 @@ import { shortenSha } from './components/short-sha.js';
80
65
  * @property {VaultEntry[]} entries
81
66
  * @property {VaultEntry[]} filtered
82
67
  * @property {string} filterText
83
- * @property {boolean} filtering
84
68
  * @property {any} metadata
85
69
  * @property {Map<string, Manifest>} manifestCache
86
70
  * @property {string | null} loadingSlug
87
71
  * @property {string | null} error
88
72
  * @property {NavigableTableState} table
89
- * @property {CommandPaletteState | null} palette
90
- * @property {boolean} showHelp
91
73
  * @property {boolean} promptEnter
92
- * @property {boolean} quitConfirm
93
74
  * @property {any} refsStatus
94
75
  * @property {any | null} refsInventory
95
76
  * @property {string | null} refsError
@@ -106,12 +87,10 @@ import { shortenSha } from './components/short-sha.js';
106
87
  * @property {any} treemapStatus
107
88
  * @property {any | null} treemapReport
108
89
  * @property {string | null} treemapError
109
- * @property {NotificationState} notifications
110
90
  * @property {OperationFeedState} operationFeed
111
91
  * @property {StoreWizardState | null} storeWizard
112
92
  * @property {string | null} gitBranch
113
93
  * @property {Buffer | null} vaultEncryptionKey
114
- * @property {boolean} settingsOpen
115
94
  */
116
95
 
117
96
  /**
@@ -124,8 +103,6 @@ import { shortenSha } from './components/short-sha.js';
124
103
  */
125
104
 
126
105
  const TITLE_TICK_MS = 33;
127
- const NOTIFICATION_TICK_MS = 40;
128
-
129
106
  const FULL_COLUMNS = [
130
107
  { header: 'Slug' },
131
108
  { header: 'Tree OID' },
@@ -275,9 +252,6 @@ function createShellState(columns, rows, source) {
275
252
  return {
276
253
  phase: 'title',
277
254
  titleTimeMs: 0,
278
- lastTickTime: 0,
279
- fps: 0,
280
- showPerfHud: false,
281
255
  vaultEntryCount: 0,
282
256
  passphrase: '',
283
257
  authError: null,
@@ -291,10 +265,8 @@ function createShellState(columns, rows, source) {
291
265
  focusPane: 'ledger',
292
266
  chunkFocus: 0,
293
267
  promptEnter: false,
294
- quitConfirm: false,
295
268
  gitBranch: null,
296
269
  vaultEncryptionKey: null,
297
- settingsOpen: false,
298
270
  };
299
271
  }
300
272
 
@@ -303,7 +275,6 @@ function createExplorerState(rows) {
303
275
  entries: [],
304
276
  filtered: [],
305
277
  filterText: '',
306
- filtering: false,
307
278
  metadata: null,
308
279
  manifestCache: new Map(),
309
280
  loadingSlug: null,
@@ -313,8 +284,6 @@ function createExplorerState(rows) {
313
284
  rows: [],
314
285
  height: tableHeight(rows),
315
286
  }),
316
- palette: null,
317
- showHelp: false,
318
287
  };
319
288
  }
320
289
 
@@ -336,7 +305,6 @@ function createServiceState() {
336
305
  treemapStatus: 'idle',
337
306
  treemapReport: null,
338
307
  treemapError: null,
339
- notifications: createNotificationState(),
340
308
  operationFeed: createFeedState(),
341
309
  storeWizard: null,
342
310
  };
@@ -516,45 +484,21 @@ function enterDashboard(model, deps) {
516
484
  ];
517
485
  }
518
486
 
519
- function pushToast(model, spec) {
520
- return {
521
- ...model,
522
- notifications: pushNotification(
523
- model.notifications,
524
- {
525
- variant: 'TOAST',
526
- placement: 'LOWER_RIGHT',
527
- width: 42,
528
- ...spec,
529
- },
530
- Date.now()
531
- ),
532
- };
533
- }
534
-
535
- function notificationTick(model, deps) {
536
- return notificationsNeedTick(model.notifications)
537
- ? [deps.tick(NOTIFICATION_TICK_MS, { type: 'notification-tick' })]
538
- : [];
487
+ function toastCommand(spec) {
488
+ return notify({
489
+ ...spec,
490
+ durationMs: 4_000,
491
+ });
539
492
  }
540
493
 
541
494
  function handleTickMsg(msg, model, deps) {
542
- if (msg.type === 'notification-tick') {
543
- const next = { ...model, notifications: tickNotifications(model.notifications, Date.now()) };
544
- return [next, notificationTick(next, deps)];
545
- }
546
495
  if (msg.type !== 'title-tick' || (model.phase !== 'title' && model.phase !== 'password')) {
547
496
  return [model, []];
548
497
  }
549
- const now = Date.now();
550
- const elapsed = now - (model.lastTickTime || now);
551
- const fps = elapsed > 0 ? Math.round(1000 / elapsed) : 0;
552
498
  return [
553
499
  {
554
500
  ...model,
555
501
  titleTimeMs: (model.titleTimeMs || 0) + TITLE_TICK_MS,
556
- lastTickTime: now,
557
- fps: model.lastTickTime ? fps : 0,
558
502
  },
559
503
  [deps.tick(TITLE_TICK_MS, { type: 'title-tick' })],
560
504
  ];
@@ -627,7 +571,7 @@ function handleLoadError(msg, model) {
627
571
  } else if (msg.source === 'treemap') {
628
572
  next = { ...next, treemapStatus: 'error', treemapError: error };
629
573
  }
630
- return [pushToast(next, { title: 'Dashboard load failed', message: error, tone: 'ERROR' }), []];
574
+ return [next, [toastCommand({ title: 'Dashboard load failed', message: error, tone: 'ERROR' })]];
631
575
  }
632
576
 
633
577
  function handleAuthOkMsg(_msg, model, deps) {
@@ -676,39 +620,101 @@ function handleLoadedBranchMsg(msg, model) {
676
620
  function handleStoreCompleteMsg(msg, model, deps) {
677
621
  const manifestCache = new Map(model.manifestCache);
678
622
  manifestCache.set(msg.slug, msg.manifest);
679
- const next = pushToast(
623
+ const next = {
624
+ ...syncExplorer(model, { manifestCache, storeWizard: null }),
625
+ operationFeed: completeLatestOperation(model.operationFeed, msg.slug, null),
626
+ };
627
+ return [
628
+ next,
629
+ [
630
+ loadEntriesCmd(casForModel(deps.cas, model), model.source),
631
+ toastCommand({
632
+ title: 'Stored asset',
633
+ message: `${msg.slug} -> ${shortenSha(msg.treeOid)}`,
634
+ tone: 'SUCCESS',
635
+ }),
636
+ ],
637
+ ];
638
+ }
639
+
640
+ function handleStoreErrorMsg(msg, model) {
641
+ const next = {
642
+ ...model,
643
+ storeWizard: model.storeWizard
644
+ ? { ...model.storeWizard, step: 'error', error: msg.error }
645
+ : null,
646
+ operationFeed: completeLatestOperation(
647
+ model.operationFeed,
648
+ model.storeWizard?.slug ?? 'store',
649
+ msg.error
650
+ ),
651
+ };
652
+ return [next, [toastCommand({ title: 'Store failed', message: msg.error, tone: 'ERROR' })]];
653
+ }
654
+
655
+ function handleSelectAssetMsg(msg, model, deps) {
656
+ const selected = model.entries.find((entry) => entry.slug === msg.slug);
657
+ const next = syncExplorer(model, {
658
+ workspace: 'explorer',
659
+ explorerMode: 'manifest',
660
+ filterText: selected ? selected.slug : model.filterText,
661
+ });
662
+ const manifestCmd = maybeLoadSelectedManifest(next, deps);
663
+ return [next, manifestCmd ? [manifestCmd] : []];
664
+ }
665
+
666
+ function handleOpenStoreWizardMsg(_msg, model) {
667
+ return [
680
668
  {
681
- ...syncExplorer(model, { manifestCache, storeWizard: null }),
682
- operationFeed: completeLatestOperation(model.operationFeed, msg.slug, null),
669
+ ...model,
670
+ workspace: 'operations',
671
+ storeWizard: createWizardState(),
683
672
  },
684
- { title: 'Stored asset', message: `${msg.slug} -> ${shortenSha(msg.treeOid)}`, tone: 'SUCCESS' }
685
- );
673
+ [],
674
+ ];
675
+ }
676
+
677
+ function handleRefreshStatisticsMsg(_msg, model, deps) {
686
678
  return [
687
- next,
688
- [loadEntriesCmd(casForModel(deps.cas, model), model.source), ...notificationTick(next, deps)],
679
+ {
680
+ ...model,
681
+ workspace: 'operations',
682
+ statsStatus: 'loading',
683
+ statsError: null,
684
+ },
685
+ [loadStatsCmd(deps.cas, model.entries, model.source)],
689
686
  ];
690
687
  }
691
688
 
692
- function handleStoreErrorMsg(msg, model, deps) {
693
- const next = pushToast(
689
+ function handleRunDoctorMsg(_msg, model, deps) {
690
+ return [
694
691
  {
695
692
  ...model,
696
- storeWizard: model.storeWizard
697
- ? { ...model.storeWizard, step: 'error', error: msg.error }
698
- : null,
699
- operationFeed: completeLatestOperation(
700
- model.operationFeed,
701
- model.storeWizard?.slug ?? 'store',
702
- msg.error
703
- ),
693
+ workspace: 'operations',
694
+ doctorStatus: 'loading',
695
+ doctorError: null,
704
696
  },
705
- { title: 'Store failed', message: msg.error, tone: 'ERROR' }
706
- );
707
- return [next, notificationTick(next, deps)];
697
+ [
698
+ loadDoctorCmd(deps.cas, {
699
+ source: model.source,
700
+ entries: model.entries,
701
+ encryptionKey: model.vaultEncryptionKey,
702
+ }),
703
+ ],
704
+ ];
705
+ }
706
+
707
+ function handleClearAssetSearchMsg(_msg, model) {
708
+ return [
709
+ syncExplorer(model, {
710
+ workspace: 'explorer',
711
+ filterText: '',
712
+ }),
713
+ [],
714
+ ];
708
715
  }
709
716
 
710
717
  const APP_MSG_HANDLERS = {
711
- 'notification-tick': handleTickMsg,
712
718
  'title-tick': handleTickMsg,
713
719
  'vault-auth-check': handleVaultAuthCheck,
714
720
  'vault-auth-ok': handleAuthOkMsg,
@@ -723,6 +729,11 @@ const APP_MSG_HANDLERS = {
723
729
  'store-complete': handleStoreCompleteMsg,
724
730
  'store-error': handleStoreErrorMsg,
725
731
  'load-error': handleLoadError,
732
+ 'select-asset': handleSelectAssetMsg,
733
+ 'open-store-wizard': handleOpenStoreWizardMsg,
734
+ 'refresh-statistics': handleRefreshStatisticsMsg,
735
+ 'run-doctor': handleRunDoctorMsg,
736
+ 'clear-asset-search': handleClearAssetSearchMsg,
726
737
  };
727
738
 
728
739
  function handleAppMsg(msg, model, deps) {
@@ -731,12 +742,6 @@ function handleAppMsg(msg, model, deps) {
731
742
  }
732
743
 
733
744
  function handleTitleKey(msg, model, deps) {
734
- if (msg.key === '`') {
735
- return [{ ...model, showPerfHud: !model.showPerfHud }, []];
736
- }
737
- if (msg.key === 'q' || msg.key === 'escape') {
738
- return [model, [quit()]];
739
- }
740
745
  if (msg.key === 'enter' && model.promptEnter) {
741
746
  return enterDashboard(model, deps);
742
747
  }
@@ -744,12 +749,6 @@ function handleTitleKey(msg, model, deps) {
744
749
  }
745
750
 
746
751
  function handlePasswordKey(msg, model, deps) {
747
- if (msg.key === '`') {
748
- return [{ ...model, showPerfHud: !model.showPerfHud }, []];
749
- }
750
- if (msg.key === 'escape') {
751
- return [model, [quit()]];
752
- }
753
752
  if (msg.key === 'enter') {
754
753
  return [{ ...model, authError: null }, [verifyPassphraseCmd(deps.cas, model.passphrase)]];
755
754
  }
@@ -780,103 +779,6 @@ function buildPaletteItems(model) {
780
779
  });
781
780
  }
782
781
 
783
- function openPalette(model) {
784
- return {
785
- ...model,
786
- palette: createCommandPaletteState(buildPaletteItems(model), 9),
787
- showHelp: false,
788
- };
789
- }
790
-
791
- function selectPaletteItem(model, deps) {
792
- const item = cpSelectedItem(model.palette);
793
- if (!item) {
794
- return [{ ...model, palette: null }, []];
795
- }
796
- const selected = model.entries.find((entry) => entry.slug === item.id);
797
- const next = syncExplorer(model, {
798
- workspace: 'explorer',
799
- explorerMode: 'manifest',
800
- palette: null,
801
- filterText: selected ? selected.slug : model.filterText,
802
- filtering: false,
803
- });
804
- const manifestCmd = maybeLoadSelectedManifest(next, deps);
805
- return [next, manifestCmd ? [manifestCmd] : []];
806
- }
807
-
808
- const PALETTE_ACTIONS = {
809
- close: (_msg, model) => [{ ...model, palette: null }, []],
810
- select: (_msg, model, deps) => selectPaletteItem(model, deps),
811
- next: (_msg, model) => [{ ...model, palette: cpFocusNext(model.palette) }, []],
812
- previous: (_msg, model) => [{ ...model, palette: cpFocusPrev(model.palette) }, []],
813
- pageDown: (_msg, model) => [{ ...model, palette: cpPageDown(model.palette) }, []],
814
- pageUp: (_msg, model) => [{ ...model, palette: cpPageUp(model.palette) }, []],
815
- };
816
-
817
- const PALETTE_KEY_ACTIONS = {
818
- escape: 'close',
819
- enter: 'select',
820
- down: 'next',
821
- up: 'previous',
822
- pagedown: 'pageDown',
823
- pageup: 'pageUp',
824
- };
825
-
826
- function paletteAction(msg) {
827
- if (msg.ctrl && msg.key === 'n') {
828
- return 'next';
829
- }
830
- if (msg.ctrl && msg.key === 'p') {
831
- return 'previous';
832
- }
833
- if (msg.ctrl && msg.key === 'd') {
834
- return 'pageDown';
835
- }
836
- if (msg.ctrl && msg.key === 'u') {
837
- return 'pageUp';
838
- }
839
- return PALETTE_KEY_ACTIONS[msg.key] ?? null;
840
- }
841
-
842
- function paletteQueryForKey(msg, palette) {
843
- if (msg.key === 'backspace') {
844
- return palette.query.slice(0, -1);
845
- }
846
- if (msg.key.length === 1 && !msg.ctrl && !msg.alt) {
847
- return `${palette.query}${msg.key}`;
848
- }
849
- return null;
850
- }
851
-
852
- function handlePaletteKey(msg, model, deps) {
853
- if (!model.palette) {
854
- return [model, []];
855
- }
856
- const action = paletteAction(msg);
857
- if (action) {
858
- return PALETTE_ACTIONS[action](msg, model, deps);
859
- }
860
- const query = paletteQueryForKey(msg, model.palette);
861
- return query === null ? [model, []] : [{ ...model, palette: cpFilter(model.palette, query) }, []];
862
- }
863
-
864
- function handleFilterKey(msg, model) {
865
- if (msg.key === 'escape') {
866
- return [syncExplorer(model, { filtering: false }), []];
867
- }
868
- if (msg.key === 'enter') {
869
- return [syncExplorer(model, { filtering: false }), []];
870
- }
871
- if (msg.key === 'backspace') {
872
- return [syncExplorer(model, { filterText: model.filterText.slice(0, -1) }), []];
873
- }
874
- if (msg.key.length === 1 && !msg.ctrl && !msg.alt) {
875
- return [syncExplorer(model, { filterText: `${model.filterText}${msg.key}` }), []];
876
- }
877
- return [model, []];
878
- }
879
-
880
782
  const LEDGER_NAVIGATORS = {
881
783
  j: navTableFocusNext,
882
784
  down: navTableFocusNext,
@@ -952,7 +854,7 @@ function handleDetailNavigation(msg, model) {
952
854
  }
953
855
 
954
856
  function switchWorkspace(model, workspace, deps) {
955
- const next = { ...model, workspace, showHelp: false };
857
+ const next = { ...model, workspace };
956
858
  if (workspace === 'atlas' && next.treemapStatus === 'idle') {
957
859
  const cas = casForModel(deps.cas, next);
958
860
  return [
@@ -1178,90 +1080,18 @@ function handleWizardKey(msg, model, deps) {
1178
1080
 
1179
1081
  function handleOperationsKey(msg, model, deps) {
1180
1082
  if (msg.key === 'n') {
1181
- return [{ ...model, storeWizard: createWizardState() }, []];
1083
+ return handleOpenStoreWizardMsg(msg, model);
1182
1084
  }
1183
1085
  if (msg.key === 's') {
1184
- return [
1185
- { ...model, statsStatus: 'loading', statsError: null },
1186
- [loadStatsCmd(deps.cas, model.entries, model.source)],
1187
- ];
1086
+ return handleRefreshStatisticsMsg(msg, model, deps);
1188
1087
  }
1189
1088
  if (msg.key === 'x') {
1190
- return [
1191
- {
1192
- ...model,
1193
- doctorStatus: 'loading',
1194
- doctorError: null,
1195
- },
1196
- [
1197
- loadDoctorCmd(deps.cas, {
1198
- source: model.source,
1199
- entries: model.entries,
1200
- encryptionKey: model.vaultEncryptionKey,
1201
- }),
1202
- ],
1203
- ];
1204
- }
1205
- return null;
1206
- }
1207
-
1208
- function handleQuitConfirmKey(msg, model) {
1209
- if (msg.key === 'y' || msg.key === 'enter') {
1210
- return [model, [quit()]];
1211
- }
1212
- if (msg.key === 'n' || msg.key === 'escape' || msg.key === 'q') {
1213
- return [{ ...model, quitConfirm: false }, []];
1214
- }
1215
- return [model, []];
1216
- }
1217
-
1218
- function clearDashboardOverlays(model) {
1219
- return {
1220
- ...model,
1221
- showHelp: false,
1222
- storeWizard: null,
1223
- palette: null,
1224
- filtering: false,
1225
- quitConfirm: false,
1226
- settingsOpen: false,
1227
- };
1228
- }
1229
-
1230
- function handleOverlayShortcut(msg, model) {
1231
- if (msg.key === 'escape') {
1232
- return [clearDashboardOverlays(model), []];
1233
- }
1234
- if (msg.key === 'f2') {
1235
- return [{ ...model, settingsOpen: !model.settingsOpen, showHelp: false, palette: null }, []];
1236
- }
1237
- if (msg.key === '?' || (msg.shift && msg.key === '/')) {
1238
- return [{ ...model, showHelp: !model.showHelp, palette: null }, []];
1239
- }
1240
- if (msg.key === 'q') {
1241
- return [{ ...model, quitConfirm: true }, []];
1242
- }
1243
- return null;
1244
- }
1245
-
1246
- function handleSearchShortcut(msg, model) {
1247
- if (msg.key === '/' && !msg.ctrl) {
1248
- return [syncExplorer(model, { workspace: 'explorer', filtering: true, palette: null }), []];
1249
- }
1250
- if ((msg.ctrl && msg.key === 'p') || msg.key === ':') {
1251
- return [openPalette(model), []];
1089
+ return handleRunDoctorMsg(msg, model, deps);
1252
1090
  }
1253
1091
  return null;
1254
1092
  }
1255
1093
 
1256
1094
  function handleGlobalDashboardKey(msg, model, deps) {
1257
- const overlay = handleOverlayShortcut(msg, model);
1258
- if (overlay) {
1259
- return overlay;
1260
- }
1261
- const search = handleSearchShortcut(msg, model);
1262
- if (search) {
1263
- return search;
1264
- }
1265
1095
  return handleWorkspaceKey(msg, model, deps);
1266
1096
  }
1267
1097
 
@@ -1277,19 +1107,10 @@ function handleWorkspaceSpecificKey(msg, model, deps) {
1277
1107
  }
1278
1108
 
1279
1109
  function handleDashboardKey(msg, model, deps) {
1280
- if (model.quitConfirm) {
1281
- return handleQuitConfirmKey(msg, model);
1282
- }
1283
- if (model.palette) {
1284
- return handlePaletteKey(msg, model, deps);
1285
- }
1286
1110
  const wizard = handleWizardKey(msg, model, deps);
1287
1111
  if (wizard) {
1288
1112
  return wizard;
1289
1113
  }
1290
- if (model.filtering) {
1291
- return handleFilterKey(msg, model);
1292
- }
1293
1114
  const global = handleGlobalDashboardKey(msg, model, deps);
1294
1115
  return global ?? handleWorkspaceSpecificKey(msg, model, deps) ?? [model, []];
1295
1116
  }
@@ -1310,14 +1131,262 @@ function handleUpdate(msg, model, deps) {
1310
1131
  return handleAppMsg(msg, model, deps);
1311
1132
  }
1312
1133
 
1134
+ function keyMessage(key, options = {}) {
1135
+ return {
1136
+ type: 'key',
1137
+ key,
1138
+ ctrl: options.ctrl ?? false,
1139
+ alt: options.alt ?? false,
1140
+ shift: options.shift ?? false,
1141
+ };
1142
+ }
1143
+
1144
+ function createDashboardKeyMap() {
1145
+ return createKeyMap()
1146
+ .group('Workspaces', (group) =>
1147
+ group
1148
+ .bind('1', 'Open Explorer workspace', keyMessage('1'))
1149
+ .bind('2', 'Open Atlas workspace', keyMessage('2'))
1150
+ .bind('3', 'Open Operations workspace', keyMessage('3'))
1151
+ .bind('e', 'Open Explorer workspace', keyMessage('e'))
1152
+ .bind('a', 'Open Atlas workspace', keyMessage('a'))
1153
+ .bind('o', 'Open Operations workspace', keyMessage('o'))
1154
+ )
1155
+ .group('Navigate cockpit', (group) =>
1156
+ group
1157
+ .bind('tab', 'Change cockpit focus', keyMessage('tab'))
1158
+ .bind('j', 'Move down', keyMessage('j'))
1159
+ .bind('k', 'Move up', keyMessage('k'))
1160
+ .bind('down', 'Move down', keyMessage('down'))
1161
+ .bind('up', 'Move up', keyMessage('up'))
1162
+ .bind('d', 'Page down', keyMessage('d'))
1163
+ .bind('u', 'Page up', keyMessage('u'))
1164
+ .bind('pagedown', 'Page down', keyMessage('pagedown'))
1165
+ .bind('pageup', 'Page up', keyMessage('pageup'))
1166
+ .bind('g', 'Move to first item', keyMessage('g'))
1167
+ .bind('enter', 'Open or activate selection', keyMessage('enter'))
1168
+ )
1169
+ .group('Explorer', (group) =>
1170
+ group
1171
+ .bind('m', 'Cycle Merkle view', keyMessage('m'))
1172
+ .bind('i', 'Toggle inspector view', keyMessage('i'))
1173
+ )
1174
+ .group('Atlas', (group) =>
1175
+ group
1176
+ .bind('t', 'Toggle atlas scope', keyMessage('t'))
1177
+ .bind('r', 'Reload atlas', keyMessage('r'))
1178
+ .bind('+', 'Drill into atlas tile', keyMessage('+'))
1179
+ .bind('-', 'Drill out of atlas tile', keyMessage('-'))
1180
+ )
1181
+ .group('Operations', (group) =>
1182
+ group
1183
+ .bind('n', 'Open store wizard', keyMessage('n'))
1184
+ .bind('s', 'Refresh vault statistics', keyMessage('s'))
1185
+ .bind('x', 'Run repository doctor', keyMessage('x'))
1186
+ );
1187
+ }
1188
+
1189
+ function createDashboardModalKeyMap(model) {
1190
+ if (model.phase !== 'password' && !model.storeWizard) {
1191
+ return undefined;
1192
+ }
1193
+ // Bijou modal key maps intentionally swallow unmatched keys. Keep a compact
1194
+ // help surface, but make input handling total so text and shell-reserved
1195
+ // characters still reach the active password or wizard reducer.
1196
+ const helpMap = createKeyMap().group('Active input', (group) =>
1197
+ group
1198
+ .bind('enter', 'Confirm active input', keyMessage('enter'))
1199
+ .bind('backspace', 'Delete previous character', keyMessage('backspace'))
1200
+ .bind('escape', 'Cancel active input', keyMessage('escape'))
1201
+ );
1202
+ return Object.assign(Object.create(helpMap), {
1203
+ handle(msg) {
1204
+ return helpMap.handle(msg) ?? msg;
1205
+ },
1206
+ });
1207
+ }
1208
+
1209
+ function cockpitWorkspaceCommands() {
1210
+ return [
1211
+ {
1212
+ id: 'workspace-explorer',
1213
+ label: 'Open Explorer',
1214
+ category: 'workspace',
1215
+ shortcut: '1',
1216
+ action: keyMessage('1'),
1217
+ },
1218
+ {
1219
+ id: 'workspace-atlas',
1220
+ label: 'Open Repository Atlas',
1221
+ category: 'workspace',
1222
+ shortcut: '2',
1223
+ action: keyMessage('2'),
1224
+ },
1225
+ {
1226
+ id: 'workspace-operations',
1227
+ label: 'Open Operations',
1228
+ category: 'workspace',
1229
+ shortcut: '3',
1230
+ action: keyMessage('3'),
1231
+ },
1232
+ ];
1233
+ }
1234
+
1235
+ function cockpitOperationCommands() {
1236
+ return [
1237
+ {
1238
+ id: 'store-asset',
1239
+ label: 'Store a new asset',
1240
+ category: 'operation',
1241
+ shortcut: 'n',
1242
+ action: { type: 'open-store-wizard' },
1243
+ },
1244
+ {
1245
+ id: 'refresh-statistics',
1246
+ label: 'Refresh vault statistics',
1247
+ category: 'operation',
1248
+ shortcut: 's',
1249
+ action: { type: 'refresh-statistics' },
1250
+ },
1251
+ {
1252
+ id: 'run-doctor',
1253
+ label: 'Run repository doctor',
1254
+ category: 'operation',
1255
+ shortcut: 'x',
1256
+ action: { type: 'run-doctor' },
1257
+ },
1258
+ ];
1259
+ }
1260
+
1261
+ function buildCockpitCommands(model) {
1262
+ return [
1263
+ ...cockpitWorkspaceCommands(),
1264
+ ...cockpitOperationCommands(),
1265
+ ...(model.filterText
1266
+ ? [
1267
+ {
1268
+ id: 'clear-asset-search',
1269
+ label: 'Show all assets',
1270
+ category: 'search',
1271
+ action: { type: 'clear-asset-search' },
1272
+ },
1273
+ ]
1274
+ : []),
1275
+ ...(model.workspace === 'atlas'
1276
+ ? [
1277
+ {
1278
+ id: 'reload-atlas',
1279
+ label: 'Reload Repository Atlas',
1280
+ category: 'atlas',
1281
+ shortcut: 'r',
1282
+ action: keyMessage('r'),
1283
+ },
1284
+ ]
1285
+ : []),
1286
+ ];
1287
+ }
1288
+
1289
+ function buildCockpitSearchItems(model) {
1290
+ return buildPaletteItems(model).map((item) => ({
1291
+ ...item,
1292
+ action: { type: 'select-asset', slug: item.id },
1293
+ }));
1294
+ }
1295
+
1296
+ function cockpitVaultStatus(model) {
1297
+ if (model.metadata?.encryption && model.vaultEncryptionKey) {
1298
+ return 'encrypted / unlocked';
1299
+ }
1300
+ if (model.metadata?.encryption) {
1301
+ return 'encrypted / locked';
1302
+ }
1303
+ return 'plaintext vault';
1304
+ }
1305
+
1306
+ function cockpitSourceLabel(source) {
1307
+ if (source.type === 'vault') {
1308
+ return 'vault';
1309
+ }
1310
+ if (source.type === 'ref') {
1311
+ return `ref ${source.ref}`;
1312
+ }
1313
+ return `oid ${source.treeOid}`;
1314
+ }
1315
+
1316
+ function buildCockpitSettings(model, ctx) {
1317
+ return {
1318
+ title: 'Cockpit Settings',
1319
+ borderToken: ctx.theme.theme.border.primary,
1320
+ bgToken: ctx.theme.theme.surface.overlay,
1321
+ sections: [
1322
+ {
1323
+ id: 'session',
1324
+ title: 'Session',
1325
+ rows: [
1326
+ { id: 'workspace', label: 'Workspace', valueLabel: model.workspace, kind: 'info' },
1327
+ { id: 'focus', label: 'Focus', valueLabel: model.focusPane ?? '-', kind: 'info' },
1328
+ {
1329
+ id: 'source',
1330
+ label: 'Source',
1331
+ valueLabel: cockpitSourceLabel(model.source),
1332
+ kind: 'info',
1333
+ },
1334
+ { id: 'vault', label: 'Vault', valueLabel: cockpitVaultStatus(model), kind: 'info' },
1335
+ ],
1336
+ },
1337
+ {
1338
+ id: 'display',
1339
+ title: 'Display',
1340
+ rows: [
1341
+ {
1342
+ id: 'short-sha',
1343
+ label: 'Selected digest',
1344
+ description: 'The selected chunk expands in the cockpit detail status.',
1345
+ kind: 'info',
1346
+ },
1347
+ ],
1348
+ },
1349
+ ],
1350
+ };
1351
+ }
1352
+
1313
1353
  export function createDashboardApp(deps) {
1354
+ return createFramedApp({
1355
+ title: 'git-cas',
1356
+ pages: [createDashboardPage(deps)],
1357
+ defaultPageId: 'cockpit',
1358
+ initialColumns: deps.ctx.runtime.columns ?? 80,
1359
+ initialRows: deps.ctx.runtime.rows ?? 24,
1360
+ enableCommandPalette: true,
1361
+ keyPriority: 'page-first',
1362
+ ctx: deps.ctx,
1363
+ observeKey(msg, route) {
1364
+ return route === 'unhandled' ? msg : undefined;
1365
+ },
1366
+ settings: ({ pageModel }) => buildCockpitSettings(pageModel, deps.ctx),
1367
+ runtimeNotifications: true,
1368
+ });
1369
+ }
1370
+
1371
+ export function createDashboardPage(deps) {
1314
1372
  return {
1373
+ id: 'cockpit',
1374
+ title: 'Cockpit',
1315
1375
  init: () => [
1316
1376
  createInitModel(deps.ctx, deps.source),
1317
1377
  [checkVaultAuthCmd(deps.cas), deps.tick(TITLE_TICK_MS, { type: 'title-tick' })],
1318
1378
  ],
1319
1379
  update: (msg, model) => handleUpdate(msg, model, deps),
1320
- view: (model) => renderDashboard(model, deps),
1380
+ keyMap: createDashboardKeyMap(),
1381
+ modalKeyMap: (model) => createDashboardModalKeyMap(model),
1382
+ commandItems: (model) => buildCockpitCommands(model),
1383
+ searchItems: (model) => buildCockpitSearchItems(model),
1384
+ searchTitle: 'Search assets',
1385
+ layout: (model) => ({
1386
+ kind: 'pane',
1387
+ paneId: 'cockpit',
1388
+ render: (width, height) => renderDashboard(model, deps, { width, height }),
1389
+ }),
1321
1390
  };
1322
1391
  }
1323
1392
 
@@ -1341,8 +1410,8 @@ export async function launchDashboard(cas, options = {}) {
1341
1410
  }
1342
1411
  const dashTick = options.tick || bijouTick;
1343
1412
  const deps = { cas, ctx, cwdLabel: options.cwd ?? process.cwd(), source, tick: dashTick };
1344
- const runApp = options.runApp || bijouStartApp;
1345
- return runApp(createDashboardApp(deps), { ctx });
1413
+ const app = createDashboardApp(deps);
1414
+ return options.runApp ? options.runApp(app, { ctx }) : app.run({ ctx });
1346
1415
  }
1347
1416
 
1348
1417
  export { buildTableRows, selectedEntry, selectedManifest, tableSchema };