@pi-unipi/info-screen 0.1.3 → 0.1.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/core-groups.ts CHANGED
@@ -180,6 +180,7 @@ const loadTimes: Array<{ name: string; type: string; ms: number }> = [];
180
180
  let totalLoadTimeMs = 0;
181
181
  let loadTrackingStarted = false;
182
182
  let loadTrackingStartMs = 0;
183
+ const moduleStartTimes = new Map<string, number>();
183
184
 
184
185
  /** Start load time tracking */
185
186
  export function startLoadTracking(): void {
@@ -189,10 +190,28 @@ export function startLoadTracking(): void {
189
190
  }
190
191
  }
191
192
 
193
+ /** Record when a module starts loading */
194
+ export function recordModuleStart(name: string): void {
195
+ moduleStartTimes.set(name, Date.now());
196
+ }
197
+
192
198
  /** Record a load time */
193
- export function recordLoadTime(name: string, type: string, ms: number): void {
194
- loadTimes.push({ name, type, ms });
195
- totalLoadTimeMs += ms;
199
+ export function recordLoadTime(name: string, type: string, ms?: number): void {
200
+ // If no ms provided, calculate from start time
201
+ if (ms === undefined || ms === 0) {
202
+ const startTime = moduleStartTimes.get(name);
203
+ if (startTime) {
204
+ ms = Date.now() - startTime;
205
+ } else {
206
+ ms = 0;
207
+ }
208
+ }
209
+ // Avoid duplicates
210
+ const existing = loadTimes.find(t => t.name === name && t.type === type);
211
+ if (!existing) {
212
+ loadTimes.push({ name, type, ms });
213
+ totalLoadTimeMs += ms;
214
+ }
196
215
  }
197
216
 
198
217
  /** Finish load tracking */
@@ -209,7 +228,7 @@ export function getLoadTimes(): Array<{ name: string; type: string; ms: number }
209
228
 
210
229
  /** Get total load time */
211
230
  export function getTotalLoadTime(): number {
212
- return totalLoadTimeMs;
231
+ return totalLoadTimeMs > 0 ? totalLoadTimeMs : (loadTrackingStarted ? Date.now() - loadTrackingStartMs : 0);
213
232
  }
214
233
 
215
234
  /**
@@ -510,16 +529,28 @@ export function registerCoreGroups(): void {
510
529
  return source === "sdk";
511
530
  });
512
531
 
513
- // Build tool list as comma-separated values
532
+ // Build tool list as comma-separated values with wrapping
514
533
  const toolNames = tools.map((t) => `${t.name}`);
515
- const toolListStr = toolNames.join(", ");
534
+ // Split into chunks of ~60 chars for wrapping
535
+ const chunks: string[] = [];
536
+ let current = "";
537
+ for (const name of toolNames) {
538
+ if (current && (current.length + name.length + 2) > 60) {
539
+ chunks.push(current);
540
+ current = name;
541
+ } else {
542
+ current = current ? `${current}, ${name}` : name;
543
+ }
544
+ }
545
+ if (current) chunks.push(current);
516
546
 
517
547
  return {
518
548
  total: { value: String(tools.length) },
519
549
  builtin: { value: String(builtin.length) },
520
550
  registered: { value: String(extension.length + sdk.length) },
521
551
  list: {
522
- value: toolListStr.length > 0 ? toolListStr : "none",
552
+ value: chunks.length > 0 ? chunks[0] : "none",
553
+ detail: chunks.length > 1 ? chunks.slice(1).join("\n") : undefined,
523
554
  },
524
555
  };
525
556
  },
@@ -585,16 +616,28 @@ export function registerCoreGroups(): void {
585
616
  const global = skills.filter((s) => s.source === "global");
586
617
  const project = skills.filter((s) => s.source === "project");
587
618
 
588
- // Build skill list as comma-separated values
619
+ // Build skill list as comma-separated values with wrapping
589
620
  const skillNames = skills.map((s) => `${s.name} (${s.source})`);
590
- const skillListStr = skillNames.join(", ");
621
+ // Split into chunks of ~60 chars for wrapping
622
+ const chunks: string[] = [];
623
+ let current = "";
624
+ for (const name of skillNames) {
625
+ if (current && (current.length + name.length + 2) > 60) {
626
+ chunks.push(current);
627
+ current = name;
628
+ } else {
629
+ current = current ? `${current}, ${name}` : name;
630
+ }
631
+ }
632
+ if (current) chunks.push(current);
591
633
 
592
634
  return {
593
635
  count: { value: String(skills.length) },
594
636
  global: { value: String(global.length) },
595
637
  project: { value: String(project.length) },
596
638
  list: {
597
- value: skillListStr.length > 0 ? skillListStr : "none",
639
+ value: chunks.length > 0 ? chunks[0] : "none",
640
+ detail: chunks.length > 1 ? chunks.slice(1).join("\n") : undefined,
598
641
  },
599
642
  };
600
643
  },
package/index.ts CHANGED
@@ -12,10 +12,10 @@
12
12
  import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
13
13
  import { UNIPI_EVENTS, MODULES, UNIPI_PREFIX, emitEvent, getPackageVersion } from "@pi-unipi/core";
14
14
  import { infoRegistry } from "./registry.js";
15
- import { registerCoreGroups, trackModule, trackTool, setPiApi, registerSkillDir, startLoadTracking, recordLoadTime, finishLoadTracking } from "./core-groups.js";
15
+ import { registerCoreGroups, trackModule, trackTool, setPiApi, registerSkillDir, startLoadTracking, recordLoadTime, finishLoadTracking, recordModuleStart } from "./core-groups.js";
16
16
 
17
17
  /** Re-export infoRegistry, registerSkillDir, and load tracking for external use */
18
- export { infoRegistry, registerSkillDir, startLoadTracking, recordLoadTime, finishLoadTracking };
18
+ export { infoRegistry, registerSkillDir, startLoadTracking, recordLoadTime, finishLoadTracking, recordModuleStart };
19
19
  import { getInfoSettings } from "./config.js";
20
20
  import { InfoOverlay } from "./tui/info-overlay.js";
21
21
  import { SettingsOverlay } from "./settings/settings-tui.js";
@@ -62,7 +62,7 @@ export default function (pi: ExtensionAPI) {
62
62
  if (event.name && event.name !== MODULES.INFO_SCREEN) {
63
63
  // Track the module
64
64
  trackModule(event.name, event.version || "unknown");
65
- recordLoadTime(event.name, "module", event.loadTimeMs || 0);
65
+ recordLoadTime(event.name, "module", event.loadTimeMs);
66
66
 
67
67
  // Track tools from this module
68
68
  if (event.tools && Array.isArray(event.tools)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/info-screen",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Dashboard and module registry for Unipi — configurable info overlay with tabbed groups",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -153,12 +153,12 @@ export class InfoOverlay implements Component {
153
153
  return this.renderError(width);
154
154
  }
155
155
 
156
- // Check for new groups (but don't re-trigger loading)
156
+ // Check for new groups and re-fetch data
157
157
  const allGroups = infoRegistry.getAllGroups();
158
158
  const groupIds = allGroups.map(g => g.id).join(",");
159
159
  const currentIds = this.groups.map(g => g.id).join(",");
160
160
 
161
- if (groupIds !== currentIds) {
161
+ if (groupIds !== currentIds || this.groups.length !== allGroups.length) {
162
162
  this.groups = allGroups;
163
163
  // Apply saved order
164
164
  const settings = getInfoSettings();
@@ -170,10 +170,11 @@ export class InfoOverlay implements Component {
170
170
  return (ai === -1 ? 999 : ai) - (bi === -1 ? 999 : bi);
171
171
  });
172
172
  }
173
- // Load data for any new groups (non-blocking)
174
- this.loadDataForNewGroups(allGroups);
175
173
  }
176
174
 
175
+ // Always re-fetch data for all groups to catch late updates
176
+ this.refreshAllData();
177
+
177
178
  if (this.groups.length === 0) {
178
179
  return this.renderEmpty(width);
179
180
  }
@@ -197,6 +198,22 @@ export class InfoOverlay implements Component {
197
198
  }
198
199
  }
199
200
 
201
+ /**
202
+ * Refresh data for all groups (non-blocking).
203
+ */
204
+ private refreshAllData(): void {
205
+ for (const group of this.groups) {
206
+ // Invalidate cache to get fresh data
207
+ infoRegistry.invalidateCache(group.id);
208
+ // Fetch fresh data (non-blocking)
209
+ infoRegistry.getGroupData(group.id).then(data => {
210
+ this.groupData.set(group.id, data);
211
+ }).catch(() => {
212
+ // Ignore errors
213
+ });
214
+ }
215
+ }
216
+
200
217
  /**
201
218
  * Render loading state.
202
219
  */