pi-better-background-tasks 0.12.0 → 0.12.2
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/package.json +1 -1
- package/src/shared-navigator.ts +118 -66
package/package.json
CHANGED
package/src/shared-navigator.ts
CHANGED
|
@@ -175,18 +175,15 @@ export function isNavigatorUiAvailable(ctx: ExtensionContext | undefined): boole
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
export function navigatorFooterHint(_count: number): string | null {
|
|
178
|
-
// Retain the compatibility helper
|
|
178
|
+
// Retain the compatibility helper without publishing a badge.
|
|
179
179
|
return null;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
export function applyNavigatorFooter(ui: { setStatus(key: string, value: string | undefined): void }, count: number): string | null {
|
|
183
|
-
|
|
184
|
-
ui.setStatus(NAVIGATOR_STATUS_KEY, hint ?? undefined);
|
|
185
|
-
return hint;
|
|
183
|
+
return navigatorFooterHint(count);
|
|
186
184
|
}
|
|
187
185
|
|
|
188
186
|
export function applyCloseConfirmFooter(ui: { setStatus(key: string, value: string | undefined): void }, hint: string | null | undefined): string | null {
|
|
189
|
-
ui.setStatus(CLOSE_CONFIRM_STATUS_KEY, hint ?? undefined);
|
|
190
187
|
return hint ?? null;
|
|
191
188
|
}
|
|
192
189
|
|
|
@@ -219,8 +216,6 @@ export function disposeBackgroundWorkNavigator(ctx?: ExtensionContext): void {
|
|
|
219
216
|
s.uiCtx = undefined;
|
|
220
217
|
if (activeCtx && isNavigatorUiAvailable(activeCtx)) {
|
|
221
218
|
const ui = activeCtx.ui;
|
|
222
|
-
try { applyNavigatorFooter(ui as any, 0); } catch { /* ignore */ }
|
|
223
|
-
try { applyCloseConfirmFooter(ui as any, null); } catch { /* ignore */ }
|
|
224
219
|
try { (ui as any).setWidget?.(MAIN_LIST_WIDGET_KEY, undefined); } catch { /* ignore */ }
|
|
225
220
|
}
|
|
226
221
|
s.lastHint = undefined;
|
|
@@ -241,12 +236,6 @@ export function refreshBackgroundWorkNavigator(ctx?: ExtensionContext): void {
|
|
|
241
236
|
const activeCtx = isNavigatorUiAvailable(ctx) ? ctx : s.uiCtx;
|
|
242
237
|
if (!isNavigatorUiAvailable(activeCtx)) return;
|
|
243
238
|
try {
|
|
244
|
-
const count = visibleCount();
|
|
245
|
-
const hint = navigatorFooterHint(count);
|
|
246
|
-
if (hint !== s.lastHint) {
|
|
247
|
-
applyNavigatorFooter(activeCtx!.ui as any, count);
|
|
248
|
-
s.lastHint = hint;
|
|
249
|
-
}
|
|
250
239
|
refreshMainListWidget();
|
|
251
240
|
} catch { /* ignore */ }
|
|
252
241
|
}
|
|
@@ -271,7 +260,6 @@ function clearMainListCloseArm(): void {
|
|
|
271
260
|
s.mainListCloseArmTimer = undefined;
|
|
272
261
|
if (!s.mainListCloseArm) return;
|
|
273
262
|
s.mainListCloseArm = undefined;
|
|
274
|
-
try { applyCloseConfirmFooter((s.uiCtx as any).ui, null); } catch { /* ignore */ }
|
|
275
263
|
}
|
|
276
264
|
|
|
277
265
|
function refreshMainListWidget(): void {
|
|
@@ -293,6 +281,7 @@ function refreshMainListWidget(): void {
|
|
|
293
281
|
const nextSignature = rows.length ? mainListSignature(rows, {
|
|
294
282
|
selectedId: s.mainListFocused ? s.mainListSelectedId : undefined,
|
|
295
283
|
focused: s.mainListFocused === true,
|
|
284
|
+
closeHint: closeHintFor(rows.find((row) => row.navigatorId === s.mainListCloseArm?.id)),
|
|
296
285
|
}) : undefined;
|
|
297
286
|
const changed = nextSignature !== s.lastMainListSignature;
|
|
298
287
|
s.lastMainListSignature = nextSignature;
|
|
@@ -348,20 +337,60 @@ type MainListWidget = Component & {
|
|
|
348
337
|
handleMouse(event: WidgetMouseEvent): WidgetMouseResult | undefined;
|
|
349
338
|
};
|
|
350
339
|
|
|
340
|
+
const BACK_TO_MAIN = "← main (Esc)";
|
|
341
|
+
const BACK_TARGET = "back-to-main";
|
|
342
|
+
|
|
343
|
+
function highlightPointerTarget(theme: unknown, line: string, width: number): string {
|
|
344
|
+
const colors = theme as { bg?(color: string, value: string): string } | undefined;
|
|
345
|
+
return colors?.bg?.("selectedBg", line + " ".repeat(Math.max(0, width - visibleWidth(line))))
|
|
346
|
+
?? themeFgFromTheme(theme)("accent", line);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function createPointerNavigation(targetAt: (event: WidgetMouseEvent) => string | undefined, activate: (target: string) => boolean) {
|
|
350
|
+
let hovered: string | undefined;
|
|
351
|
+
let pressed: { target: string; y: number } | undefined;
|
|
352
|
+
return {
|
|
353
|
+
get hovered() { return hovered; },
|
|
354
|
+
reset() { hovered = undefined; pressed = undefined; },
|
|
355
|
+
handleMouse(event: WidgetMouseEvent): WidgetMouseResult | undefined {
|
|
356
|
+
if (event.type === "move" || event.type === "leave") {
|
|
357
|
+
const target = event.type === "leave" ? undefined : targetAt(event);
|
|
358
|
+
const changed = hovered !== target;
|
|
359
|
+
hovered = target;
|
|
360
|
+
return changed || target ? { handled: true, render: changed } : undefined;
|
|
361
|
+
}
|
|
362
|
+
if (event.button !== "left" || event.shift || event.alt || event.ctrl) {
|
|
363
|
+
pressed = undefined;
|
|
364
|
+
return undefined;
|
|
365
|
+
}
|
|
366
|
+
if (event.type === "press") {
|
|
367
|
+
const target = targetAt(event);
|
|
368
|
+
pressed = target ? { target, y: event.y } : undefined;
|
|
369
|
+
return target ? { handled: true, render: false } : undefined;
|
|
370
|
+
}
|
|
371
|
+
if (event.type !== "click") return undefined;
|
|
372
|
+
const claim = pressed;
|
|
373
|
+
pressed = undefined;
|
|
374
|
+
if (!claim || claim.y !== event.y || targetAt(event) !== claim.target || !activate(claim.target)) return undefined;
|
|
375
|
+
return { handled: true, render: true };
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
|
|
351
380
|
function createMainListWidget(tui: { requestRender?(): void }, theme: unknown, deps: HostDeps): MainListWidget {
|
|
352
381
|
const requestRender = () => tui.requestRender?.();
|
|
353
382
|
state().mainListRequestRender = requestRender;
|
|
354
383
|
// navigatorId per rendered line, so a pointer row resolves by structure, never by row text.
|
|
355
384
|
let lineOwners: Array<string | undefined> = [];
|
|
356
385
|
let lineWidth = MAIN_LIST_FALLBACK_WIDTH;
|
|
357
|
-
// Pi synthesizes a click only for the component that handled the initial press.
|
|
358
|
-
let pressedRow: { navigatorId: string; y: number } | undefined;
|
|
359
386
|
const rowAt = (event: WidgetMouseEvent): string | undefined => {
|
|
360
387
|
const width = Number.isFinite(event.width) && event.width > 0 ? Math.floor(event.width) : lineWidth;
|
|
361
388
|
if (!Number.isFinite(event.x) || event.x < 0 || event.x >= width) return undefined;
|
|
362
389
|
if (!Number.isInteger(event.y) || event.y < 0 || event.y >= lineOwners.length) return undefined;
|
|
363
|
-
|
|
390
|
+
const id = lineOwners[event.y];
|
|
391
|
+
return id && listRows().some((row) => row.navigatorId === id) ? id : undefined;
|
|
364
392
|
};
|
|
393
|
+
const pointer = createPointerNavigation(rowAt, openNavigatorRow);
|
|
365
394
|
return {
|
|
366
395
|
render(width: number): string[] {
|
|
367
396
|
const rows = listRows();
|
|
@@ -369,51 +398,37 @@ function createMainListWidget(tui: { requestRender?(): void }, theme: unknown, d
|
|
|
369
398
|
if (!rows.length) {
|
|
370
399
|
state().lastMainListLines = undefined;
|
|
371
400
|
lineOwners = [];
|
|
372
|
-
|
|
401
|
+
pointer.reset();
|
|
373
402
|
return [];
|
|
374
403
|
}
|
|
375
404
|
const layout = buildMainListLayout(rows, renderWidth(width), deps.truncate, themeFgFromTheme(theme), {
|
|
376
405
|
selectedId: state().mainListFocused ? state().mainListSelectedId : undefined,
|
|
377
406
|
focused: state().mainListFocused === true,
|
|
378
407
|
});
|
|
408
|
+
const armedRow = rows.find((row) => row.navigatorId === state().mainListCloseArm?.id);
|
|
409
|
+
const hint = closeHintFor(armedRow);
|
|
410
|
+
if (hint) { layout.lines.push(deps.truncate(` ${hint}`, renderWidth(width))); layout.owners.push(undefined); }
|
|
379
411
|
lineWidth = renderWidth(width);
|
|
380
412
|
// The leading gap line belongs to the widget too, so its slot stays ownerless.
|
|
381
413
|
lineOwners = [undefined, ...layout.owners];
|
|
382
|
-
const lines = ["", ...layout.lines]
|
|
414
|
+
const lines = ["", ...layout.lines].map((line, index) =>
|
|
415
|
+
pointer.hovered && lineOwners[index] === pointer.hovered ? highlightPointerTarget(theme, line, lineWidth) : line);
|
|
383
416
|
state().lastMainListLines = lines;
|
|
384
417
|
return lines;
|
|
385
418
|
},
|
|
386
419
|
handleMouse(event: WidgetMouseEvent): WidgetMouseResult | undefined {
|
|
387
|
-
|
|
388
|
-
if (event.button !== "left" || event.shift === true || event.alt === true || event.ctrl === true) {
|
|
389
|
-
pressedRow = undefined;
|
|
390
|
-
return undefined;
|
|
391
|
-
}
|
|
392
|
-
if (event.type === "press") {
|
|
393
|
-
pressedRow = undefined;
|
|
394
|
-
const navigatorId = rowAt(event);
|
|
395
|
-
if (!navigatorId || !listRows().some((row) => row.navigatorId === navigatorId)) return undefined;
|
|
396
|
-
pressedRow = { navigatorId, y: event.y };
|
|
397
|
-
return { handled: true, render: false };
|
|
398
|
-
}
|
|
399
|
-
if (event.type !== "click") return undefined;
|
|
400
|
-
const pressed = pressedRow;
|
|
401
|
-
pressedRow = undefined;
|
|
402
|
-
// A click after another component's press, or after the layout moved, is not the row we claimed.
|
|
403
|
-
if (!pressed || pressed.y !== event.y || rowAt(event) !== pressed.navigatorId) return undefined;
|
|
404
|
-
if (!openNavigatorRow(pressed.navigatorId)) return undefined;
|
|
405
|
-
return { handled: true, render: true };
|
|
420
|
+
return pointer.handleMouse(event);
|
|
406
421
|
},
|
|
407
422
|
invalidate() {
|
|
408
423
|
state().lastMainListLines = undefined;
|
|
409
424
|
lineOwners = [];
|
|
410
|
-
|
|
425
|
+
pointer.reset();
|
|
411
426
|
},
|
|
412
427
|
dispose() {
|
|
413
428
|
const s = state();
|
|
414
429
|
if (s.mainListRequestRender === requestRender) s.mainListRequestRender = undefined;
|
|
415
430
|
lineOwners = [];
|
|
416
|
-
|
|
431
|
+
pointer.reset();
|
|
417
432
|
},
|
|
418
433
|
};
|
|
419
434
|
}
|
|
@@ -607,9 +622,10 @@ function statusIndicator(row: InternalRow, now = Date.now()): { glyph: string; c
|
|
|
607
622
|
return { glyph: RUNNING_DOT_GLYPH, color: "accent" };
|
|
608
623
|
}
|
|
609
624
|
|
|
610
|
-
function mainListSignature(rows: InternalRow[], options: { selectedId?: string; focused?: boolean } = {}): string {
|
|
625
|
+
function mainListSignature(rows: InternalRow[], options: { selectedId?: string; focused?: boolean; closeHint?: string | null } = {}): string {
|
|
611
626
|
return JSON.stringify({
|
|
612
627
|
focused: options.focused === true,
|
|
628
|
+
closeHint: options.closeHint ?? null,
|
|
613
629
|
selectedId: options.focused === true ? options.selectedId ?? null : null,
|
|
614
630
|
rows: rows.map((row) => ({
|
|
615
631
|
navigatorId: row.navigatorId,
|
|
@@ -840,7 +856,6 @@ function handleMainListCloseKey(): void {
|
|
|
840
856
|
}
|
|
841
857
|
clearMainListCloseArm();
|
|
842
858
|
s.mainListCloseArm = { id: row.navigatorId, armedAt: now };
|
|
843
|
-
try { applyCloseConfirmFooter((s.uiCtx as any).ui, closeHintFor(row)); } catch { /* ignore */ }
|
|
844
859
|
s.mainListCloseArmTimer = setTimeout(() => {
|
|
845
860
|
clearMainListCloseArm();
|
|
846
861
|
refreshMainListWidget();
|
|
@@ -958,6 +973,22 @@ function createOverlayComponent(
|
|
|
958
973
|
let closed = false;
|
|
959
974
|
let transcriptDetail: BackgroundWorkDetail | null = null;
|
|
960
975
|
let transcriptComponent: Component | null = null;
|
|
976
|
+
let pointerTargets: Array<string | undefined> = [];
|
|
977
|
+
let pointerWidth = 0;
|
|
978
|
+
const pointer = createPointerNavigation((event) => {
|
|
979
|
+
if (closed || !Number.isInteger(event.y) || !Number.isFinite(event.x) || event.x < 0 || event.x >= pointerWidth) return undefined;
|
|
980
|
+
const target = pointerTargets[event.y];
|
|
981
|
+
if (target === BACK_TARGET) return event.x >= 3 && event.x < 3 + visibleWidth(BACK_TO_MAIN) ? target : undefined;
|
|
982
|
+
return target && listRows().some((row) => row.navigatorId === target) ? target : undefined;
|
|
983
|
+
}, (target) => {
|
|
984
|
+
if (target === BACK_TARGET) { backToMain(); return true; }
|
|
985
|
+
refreshRows();
|
|
986
|
+
const index = overlayState.rows.findIndex((row) => row.navigatorId === target);
|
|
987
|
+
if (index < 0) return false;
|
|
988
|
+
selectOverlayRow(index);
|
|
989
|
+
openDetail();
|
|
990
|
+
return true;
|
|
991
|
+
});
|
|
961
992
|
|
|
962
993
|
const fg = (color: string, value: string) => theme?.fg ? theme.fg(color, value) : value;
|
|
963
994
|
|
|
@@ -995,7 +1026,6 @@ function createOverlayComponent(
|
|
|
995
1026
|
closeArmTimer = undefined;
|
|
996
1027
|
if (closeArm) {
|
|
997
1028
|
closeArm = undefined;
|
|
998
|
-
try { applyCloseConfirmFooter((state().uiCtx as any).ui, null); } catch { /* ignore */ }
|
|
999
1029
|
}
|
|
1000
1030
|
}
|
|
1001
1031
|
|
|
@@ -1036,6 +1066,11 @@ function createOverlayComponent(
|
|
|
1036
1066
|
try { done(null); } catch { /* ignore */ }
|
|
1037
1067
|
}
|
|
1038
1068
|
|
|
1069
|
+
function backToMain(): void {
|
|
1070
|
+
unfocusMainList();
|
|
1071
|
+
close();
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1039
1074
|
function handleCloseKey(): void {
|
|
1040
1075
|
const row = selectedRow();
|
|
1041
1076
|
if (!row || row.parentRow) return;
|
|
@@ -1064,11 +1099,9 @@ function createOverlayComponent(
|
|
|
1064
1099
|
}
|
|
1065
1100
|
clearCloseArm();
|
|
1066
1101
|
closeArm = { id: row.navigatorId, armedAt: now };
|
|
1067
|
-
try { applyCloseConfirmFooter((state().uiCtx as any).ui, closeHintFor(row)); } catch { /* ignore */ }
|
|
1068
1102
|
closeArmTimer = setTimeout(() => {
|
|
1069
1103
|
closeArmTimer = undefined;
|
|
1070
1104
|
closeArm = undefined;
|
|
1071
|
-
try { applyCloseConfirmFooter((state().uiCtx as any).ui, null); } catch { /* ignore */ }
|
|
1072
1105
|
requestRender();
|
|
1073
1106
|
}, CLOSE_ARM_MS);
|
|
1074
1107
|
closeArmTimer.unref?.();
|
|
@@ -1101,14 +1134,20 @@ function createOverlayComponent(
|
|
|
1101
1134
|
render(width: number) {
|
|
1102
1135
|
closeIfEditorReplaced();
|
|
1103
1136
|
refreshRows();
|
|
1104
|
-
const
|
|
1137
|
+
const rail = buildMainListLayout(overlayState.rows, width, deps.truncate, fg, {
|
|
1105
1138
|
selectedId: selectedRow()?.navigatorId,
|
|
1106
1139
|
focused: true,
|
|
1107
1140
|
});
|
|
1141
|
+
const armedRow = overlayState.rows.find((row) => row.navigatorId === closeArm?.id);
|
|
1142
|
+
const hint = closeHintFor(armedRow);
|
|
1143
|
+
if (hint) { rail.lines.push(deps.truncate(` ${hint}`, renderWidth(width))); rail.owners.push(undefined); }
|
|
1144
|
+
const railLines = rail.lines;
|
|
1108
1145
|
const editorLines = renderEditorLines(width);
|
|
1109
1146
|
const bottomLines = [...railLines, ...editorLines];
|
|
1110
1147
|
const overlayRows = state().detailOverlayRows;
|
|
1111
1148
|
const detailRows = overlayRows === undefined ? undefined : Math.max(1, overlayRows - bottomLines.length);
|
|
1149
|
+
const backControl = pointer.hovered === BACK_TARGET
|
|
1150
|
+
? highlightPointerTarget(theme, BACK_TO_MAIN, visibleWidth(BACK_TO_MAIN)) : undefined;
|
|
1112
1151
|
let contentLines: string[];
|
|
1113
1152
|
if (detail?.transcript && deps.createTranscriptComponent) {
|
|
1114
1153
|
if (transcriptDetail !== detail || !transcriptComponent) {
|
|
@@ -1121,18 +1160,30 @@ function createOverlayComponent(
|
|
|
1121
1160
|
width,
|
|
1122
1161
|
deps.truncate,
|
|
1123
1162
|
fg,
|
|
1124
|
-
{ minRows: detailRows, maxRows: detailRows, bottomFooter: false, logTailRows },
|
|
1163
|
+
{ minRows: detailRows, maxRows: detailRows, bottomFooter: false, logTailRows, backControl },
|
|
1125
1164
|
);
|
|
1126
1165
|
} else {
|
|
1127
1166
|
transcriptDetail = null;
|
|
1128
1167
|
transcriptComponent = null;
|
|
1129
|
-
contentLines = buildDetailLines(detail, width, deps.truncate, fg, { expandedSections, logTailRows, minRows: detailRows, maxRows: detailRows, bottomFooter: false });
|
|
1168
|
+
contentLines = buildDetailLines(detail, width, deps.truncate, fg, { expandedSections, logTailRows, minRows: detailRows, maxRows: detailRows, bottomFooter: false, backControl });
|
|
1130
1169
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1170
|
+
const fittedContent = detailRows === undefined ? contentLines : contentLines.slice(0, detailRows);
|
|
1171
|
+
if (detailRows !== undefined) while (fittedContent.length < detailRows) fittedContent.push("");
|
|
1172
|
+
const contentTargets = fittedContent.map((_, index) => index === 1 ? BACK_TARGET : undefined);
|
|
1173
|
+
const allLines = [...fittedContent, ...bottomLines];
|
|
1174
|
+
const allTargets = [...contentTargets, ...rail.owners, ...editorLines.map(() => undefined)];
|
|
1175
|
+
// Match hit targets to the same viewport clipping as the visible lines.
|
|
1176
|
+
const start = overlayRows === undefined ? 0 : Math.max(0, allLines.length - Math.max(1, overlayRows));
|
|
1177
|
+
pointerTargets = allTargets.slice(start);
|
|
1178
|
+
pointerWidth = renderWidth(width);
|
|
1179
|
+
return allLines.slice(start).map((line, index) => {
|
|
1180
|
+
if (!pointer.hovered || pointerTargets[index] !== pointer.hovered) return line;
|
|
1181
|
+
if (pointer.hovered === BACK_TARGET) return line;
|
|
1182
|
+
return highlightPointerTarget(theme, line, width);
|
|
1183
|
+
});
|
|
1184
|
+
},
|
|
1185
|
+
handleMouse(event: WidgetMouseEvent): WidgetMouseResult | undefined {
|
|
1186
|
+
return pointer.handleMouse(event);
|
|
1136
1187
|
},
|
|
1137
1188
|
handleInput(data: string) {
|
|
1138
1189
|
if (closed) return;
|
|
@@ -1151,7 +1202,7 @@ function createOverlayComponent(
|
|
|
1151
1202
|
else if (deps.matchKey(data, "left")) {
|
|
1152
1203
|
const mainIdx = overlayState.rows.findIndex((row) => row.parentRow && row.id === "main");
|
|
1153
1204
|
if (mainIdx >= 0) selectOverlayRow(mainIdx);
|
|
1154
|
-
|
|
1205
|
+
backToMain();
|
|
1155
1206
|
}
|
|
1156
1207
|
else if (deps.matchKey(data, "enter")) {
|
|
1157
1208
|
const row = selectedRow();
|
|
@@ -1179,8 +1230,7 @@ function createOverlayComponent(
|
|
|
1179
1230
|
requestRender();
|
|
1180
1231
|
}
|
|
1181
1232
|
else if (deps.matchKey(data, "escape")) {
|
|
1182
|
-
|
|
1183
|
-
close();
|
|
1233
|
+
backToMain();
|
|
1184
1234
|
}
|
|
1185
1235
|
},
|
|
1186
1236
|
/** Show another row's detail in this overlay (the main list moved while it was unfocused). */
|
|
@@ -1195,8 +1245,10 @@ function createOverlayComponent(
|
|
|
1195
1245
|
},
|
|
1196
1246
|
/** Close the overlay (done), e.g. when the navigator is disposed. */
|
|
1197
1247
|
dismiss() { close(); },
|
|
1198
|
-
invalidate() { transcriptComponent?.invalidate(); },
|
|
1248
|
+
invalidate() { pointer.reset(); pointerTargets = []; transcriptComponent?.invalidate(); },
|
|
1199
1249
|
dispose() {
|
|
1250
|
+
pointer.reset();
|
|
1251
|
+
pointerTargets = [];
|
|
1200
1252
|
clearCloseArm();
|
|
1201
1253
|
detailScheduler.dispose();
|
|
1202
1254
|
},
|
|
@@ -1233,14 +1285,14 @@ function buildTranscriptDetailLines(
|
|
|
1233
1285
|
width: number,
|
|
1234
1286
|
truncate: (s: string, width: number) => string,
|
|
1235
1287
|
fg: (color: string, value: string) => string,
|
|
1236
|
-
options: { minRows?: number; maxRows?: number; bottomFooter?: boolean; logTailRows?: number } = {},
|
|
1288
|
+
options: { minRows?: number; maxRows?: number; bottomFooter?: boolean; logTailRows?: number; backControl?: string } = {},
|
|
1237
1289
|
): string[] {
|
|
1238
|
-
const actions = [...(detail.footerActions ?? ["x close"])
|
|
1290
|
+
const actions = [...(detail.footerActions ?? ["x close"])].join(" · ");
|
|
1239
1291
|
const tailRows = options.logTailRows ?? DEFAULT_LOG_TAIL_ROWS;
|
|
1240
1292
|
let shownTranscriptLines = transcriptLines.length ? transcriptLines.slice(-tailRows) : [" (no transcript yet)"];
|
|
1241
1293
|
const lines: string[] = [
|
|
1242
1294
|
fg("accent", rule(detail.title, width)),
|
|
1243
|
-
dim(`
|
|
1295
|
+
` ${options.backControl ?? fg("accent", BACK_TO_MAIN)}${dim(` · ${actions}`, fg)}`,
|
|
1244
1296
|
"",
|
|
1245
1297
|
` status ${fg(toneColor(detail.statusTone, detail.status), detail.status)}`,
|
|
1246
1298
|
];
|
|
@@ -1264,7 +1316,7 @@ function buildTranscriptDetailLines(
|
|
|
1264
1316
|
lines.push(...shownTranscriptLines);
|
|
1265
1317
|
lines.push("");
|
|
1266
1318
|
if (options.bottomFooter === false) return lines.map((line) => safeTruncate(line, width, truncate));
|
|
1267
|
-
const footerLines = [dim(`
|
|
1319
|
+
const footerLines = [dim(` ${BACK_TO_MAIN} · ${actions}`, fg), dim(rule("", width), fg)];
|
|
1268
1320
|
padBeforeFooter(lines, footerLines.length, options.minRows);
|
|
1269
1321
|
lines.push(...footerLines);
|
|
1270
1322
|
return lines.map((line) => safeTruncate(line, width, truncate));
|
|
@@ -1320,10 +1372,10 @@ function buildDetailLines(
|
|
|
1320
1372
|
width: number,
|
|
1321
1373
|
truncate: (s: string, width: number) => string,
|
|
1322
1374
|
fg: (color: string, value: string) => string,
|
|
1323
|
-
options: { expandedSections?: Set<string>; logTailRows?: number; minRows?: number; maxRows?: number; bottomFooter?: boolean } = {},
|
|
1375
|
+
options: { expandedSections?: Set<string>; logTailRows?: number; minRows?: number; maxRows?: number; bottomFooter?: boolean; backControl?: string } = {},
|
|
1324
1376
|
): string[] {
|
|
1325
1377
|
if (!detail) {
|
|
1326
|
-
const lines = [rule("Work unavailable", width),
|
|
1378
|
+
const lines = [rule("Work unavailable", width), ` ${options.backControl ?? fg("accent", BACK_TO_MAIN)}`, ""];
|
|
1327
1379
|
if (options.bottomFooter === false) return lines.map((line) => safeTruncate(line, width, truncate));
|
|
1328
1380
|
const footerLines = [dim(rule("", width), fg)];
|
|
1329
1381
|
padBeforeFooter(lines, footerLines.length, options.minRows);
|
|
@@ -1336,8 +1388,8 @@ function buildDetailLines(
|
|
|
1336
1388
|
const foldedAction = toggleableSectionId
|
|
1337
1389
|
? (options.expandedSections?.has(toggleableSectionId) ? "Enter collapse" : "Enter expand")
|
|
1338
1390
|
: null;
|
|
1339
|
-
const actions = [foldedAction, ...(detail.footerActions?.length ? detail.footerActions : ["x close"]), "l 10/25"
|
|
1340
|
-
lines.push(dim(`
|
|
1391
|
+
const actions = [foldedAction, ...(detail.footerActions?.length ? detail.footerActions : ["x close"]), "l 10/25"].filter(Boolean).join(" · ");
|
|
1392
|
+
lines.push(` ${options.backControl ?? fg("accent", BACK_TO_MAIN)}${dim(` · ${actions}`, fg)}`);
|
|
1341
1393
|
lines.push("");
|
|
1342
1394
|
lines.push(` status ${fg(toneColor(detail.statusTone, detail.status), detail.status)}`);
|
|
1343
1395
|
if (detail.subtitle) lines.push(` summary ${detail.subtitle}`);
|
|
@@ -1393,7 +1445,7 @@ function buildDetailLines(
|
|
|
1393
1445
|
}
|
|
1394
1446
|
lines.push("");
|
|
1395
1447
|
if (options.bottomFooter === false) return lines.map((line) => safeTruncate(line, width, truncate));
|
|
1396
|
-
const footerLines = [dim(`
|
|
1448
|
+
const footerLines = [dim(` ${BACK_TO_MAIN} · ${actions}`, fg), dim(rule("", width), fg)];
|
|
1397
1449
|
padBeforeFooter(lines, footerLines.length, options.minRows);
|
|
1398
1450
|
lines.push(...footerLines);
|
|
1399
1451
|
return lines.map((line) => safeTruncate(line, width, truncate));
|