pi-crew 0.2.13 → 0.2.14

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-crew",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "Pi extension for coordinated AI teams, workflows, worktrees, and async task orchestration",
5
5
  "author": "baphuongna",
6
6
  "license": "MIT",
@@ -152,10 +152,16 @@ function agentStats(agent: CrewAgentRecord, liveHandle?: LiveAgentHandle): strin
152
152
  const ctxPct = stats?.contextUsage?.percent;
153
153
  if (ctxPct != null) parts.push(`${Math.round(ctxPct)}% ctx`);
154
154
  } catch { /* ignore */ }
155
- const completedMs = act.completedAtMs || 0;
156
- const startedMs = act.startedAtMs || 0;
157
- // Validate: startedAtMs should be within reasonable bounds (not seconds, not far future)
155
+ const rawStarted = act.startedAtMs || 0;
156
+ const rawCompleted = act.completedAtMs || 0;
158
157
  const nowMs = Date.now();
158
+ const nowSec = Math.floor(nowMs / 1000);
159
+ // Detect if value is in seconds (Unix timestamp) vs milliseconds
160
+ // If value looks like Unix seconds (within range of ±2 years from now), convert to ms
161
+ const isSeconds = (v: number) => v > 1000000000 && v < 2000000000 + 31536000 * 2;
162
+ const startedMs = isSeconds(rawStarted) ? rawStarted * 1000 : rawStarted;
163
+ const completedMs = isSeconds(rawCompleted) ? rawCompleted * 1000 : rawCompleted;
164
+ // Validate: startedAtMs should be within reasonable bounds
159
165
  const isValidStarted = startedMs > 0 && startedMs < nowMs + 60000 && startedMs > nowMs - 3155692600000;
160
166
  const isValidCompleted = completedMs === 0 || (completedMs > 0 && completedMs < nowMs + 60000);
161
167
  const ms = (isValidCompleted ? completedMs : nowMs) - (isValidStarted ? startedMs : nowMs);
@@ -64,9 +64,13 @@ export class LiveConversationOverlay {
64
64
  private static readonly SUMMARY_PREFIX = "\u200B"; // zero-width space as summary sentinel
65
65
 
66
66
  private safeElapsedMs(act: typeof this.handle.activity): number {
67
- const completedMs = act.completedAtMs || 0;
68
- const startedMs = act.startedAtMs || 0;
67
+ const rawStarted = act.startedAtMs || 0;
68
+ const rawCompleted = act.completedAtMs || 0;
69
69
  const nowMs = Date.now();
70
+ // Detect if value is in seconds vs milliseconds
71
+ const isSeconds = (v: number) => v > 1000000000 && v < 2000000000 + 31536000 * 2;
72
+ const startedMs = isSeconds(rawStarted) ? rawStarted * 1000 : rawStarted;
73
+ const completedMs = isSeconds(rawCompleted) ? rawCompleted * 1000 : rawCompleted;
70
74
  const isValidStarted = startedMs > 0 && startedMs < nowMs + 60000 && startedMs > nowMs - 3155692600000;
71
75
  const isValidCompleted = completedMs === 0 || (completedMs > 0 && completedMs < nowMs + 60000);
72
76
  return (isValidCompleted ? completedMs : nowMs) - (isValidStarted ? startedMs : nowMs);