pi-better-background-tasks 0.15.3 → 0.15.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-background-tasks",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
4
4
  "description": "Pi extension for durable background shell tasks, watchers, logs, and status inspection.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -90,6 +90,7 @@ type NavigatorState = {
90
90
  lastHint?: string | null;
91
91
  lastMainListLines?: string[];
92
92
  lastMainListSignature?: string;
93
+ mainListRows?: InternalRow[];
93
94
  mainListWidgetInstalled?: boolean;
94
95
  mainListRequestRender?: () => void;
95
96
  mainListSelectedId?: string;
@@ -121,6 +122,7 @@ export const NAVIGATOR_STATUS_KEY = "background-work-nav";
121
122
  export const CLOSE_CONFIRM_STATUS_KEY = "background-work-close";
122
123
  export const MAIN_LIST_WIDGET_KEY = "background-work-list";
123
124
  export const DETAIL_TICK_MS = 10_000;
125
+ export const MAIN_LIST_REFRESH_MS = 1_000;
124
126
  export const CLOSE_ARM_MS = 3000;
125
127
  export const DEFAULT_LOG_TAIL_ROWS = 25;
126
128
  export const LOG_TAIL_ROW_CHOICES = [10, 25] as const;
@@ -208,6 +210,7 @@ export function ensureBackgroundWorkNavigator(ctx: ExtensionContext, deps: HostD
208
210
  try { setNavigatorPanel(ctx, MAIN_LIST_WIDGET_KEY, undefined); } catch { /* ignore */ }
209
211
  s.mainListWidgetInstalled = false;
210
212
  s.mainListRequestRender = undefined;
213
+ s.mainListRows = undefined;
211
214
  s.mainListDeadlineScheduler?.dispose();
212
215
  s.mainListDeadlineScheduler = createRenderScheduler(() => refreshMainListWidget());
213
216
  installNavigatorEditor(ctx.ui as any, deps);
@@ -242,6 +245,7 @@ export function disposeBackgroundWorkNavigator(ctx?: ExtensionContext, owner?: s
242
245
  s.lastHint = undefined;
243
246
  s.lastMainListLines = undefined;
244
247
  s.lastMainListSignature = undefined;
248
+ s.mainListRows = undefined;
245
249
  s.mainListDeadlineScheduler?.dispose();
246
250
  s.mainListDeadlineScheduler = undefined;
247
251
  s.mainListWidgetInstalled = false;
@@ -290,13 +294,15 @@ function refreshMainListWidget(): void {
290
294
  if (!ctx || !deps || !isNavigatorUiAvailable(ctx)) return;
291
295
  const now = Date.now();
292
296
  const rows = listRows(now);
297
+ s.mainListRows = rows;
293
298
  s.mainListDeadlineScheduler?.cancel();
294
299
  const nextExpiry = rows.reduce<number | undefined>((next, row) => {
295
300
  if (row.expiresAt === undefined || row.expiresAt <= now) return next;
296
301
  return next === undefined ? row.expiresAt : Math.min(next, row.expiresAt);
297
302
  }, undefined);
298
- if (nextExpiry !== undefined) {
299
- s.mainListDeadlineScheduler?.schedule(nextExpiry - now);
303
+ if (rows.length) {
304
+ // External writers cannot notify this host. Refresh independently of paint frequency.
305
+ s.mainListDeadlineScheduler?.schedule(Math.min(MAIN_LIST_REFRESH_MS, nextExpiry === undefined ? Infinity : nextExpiry - now));
300
306
  }
301
307
  syncMainListSelection(rows);
302
308
  const nextSignature = rows.length ? mainListSignature(rows, {
@@ -409,12 +415,12 @@ function createMainListWidget(tui: { requestRender?(): void }, theme: unknown, d
409
415
  if (!Number.isFinite(event.x) || event.x < 0 || event.x >= width) return undefined;
410
416
  if (!Number.isInteger(event.y) || event.y < 0 || event.y >= lineOwners.length) return undefined;
411
417
  const id = lineOwners[event.y];
412
- return id && listRows().some((row) => row.navigatorId === id) ? id : undefined;
418
+ return id && state().mainListRows?.some((row) => row.navigatorId === id) ? id : undefined;
413
419
  };
414
420
  const pointer = createPointerNavigation(rowAt, openNavigatorRow);
415
421
  return {
416
422
  render(width: number): string[] {
417
- const rows = listRows();
423
+ const rows = state().mainListRows ?? [];
418
424
  syncMainListSelection(rows);
419
425
  if (!rows.length) {
420
426
  state().lastMainListLines = undefined;