@trevonistrevon/pi-loop 0.1.5 → 0.1.7
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/dist/index.js +1 -0
- package/dist/monitor-manager.js +3 -0
- package/dist/store.d.ts +1 -0
- package/dist/store.js +14 -0
- package/dist/ui/widget.js +2 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/monitor-manager.ts +3 -0
- package/src/store.ts +14 -0
- package/src/ui/widget.ts +2 -1
package/dist/index.js
CHANGED
package/dist/monitor-manager.js
CHANGED
|
@@ -68,6 +68,9 @@ export class MonitorManager {
|
|
|
68
68
|
for (const resolve of bp.waiters)
|
|
69
69
|
resolve();
|
|
70
70
|
bp.waiters = [];
|
|
71
|
+
// Remove completed/errored monitors after a brief delay so tool
|
|
72
|
+
// consumers have time to read the final state via MonitorList.
|
|
73
|
+
setTimeout(() => { this.processes.delete(id); }, 30000);
|
|
71
74
|
};
|
|
72
75
|
child.on("close", (code) => {
|
|
73
76
|
if (entry.status === "running") {
|
package/dist/store.d.ts
CHANGED
package/dist/store.js
CHANGED
|
@@ -176,6 +176,20 @@ export class LoopStore {
|
|
|
176
176
|
return count;
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
+
expireEventLoops() {
|
|
180
|
+
return this.withLock(() => {
|
|
181
|
+
let count = 0;
|
|
182
|
+
for (const [_id, entry] of this.loops) {
|
|
183
|
+
if (entry.status !== "active")
|
|
184
|
+
continue;
|
|
185
|
+
if (entry.trigger.type === "event" || entry.trigger.type === "hybrid") {
|
|
186
|
+
entry.status = "expired";
|
|
187
|
+
count++;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return count;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
179
193
|
clearAll() {
|
|
180
194
|
return this.withLock(() => {
|
|
181
195
|
const count = this.loops.size;
|
package/dist/ui/widget.js
CHANGED
|
@@ -85,7 +85,8 @@ export class LoopWidget {
|
|
|
85
85
|
for (const m of monitors.slice(0, Math.max(0, MAX_VISIBLE - loops.length))) {
|
|
86
86
|
const icon = "◉";
|
|
87
87
|
const age = Date.now() - m.startedAt;
|
|
88
|
-
|
|
88
|
+
const label = m.description || m.command.replace(/\n/g, " ").replace(/\s+/g, " ").trim().slice(0, 50);
|
|
89
|
+
lines.push(trunc(` ${icon} #${m.id} ${label} ${m.outputLines} lines (${formatDuration(age)})`));
|
|
89
90
|
}
|
|
90
91
|
return lines;
|
|
91
92
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/monitor-manager.ts
CHANGED
|
@@ -73,6 +73,9 @@ export class MonitorManager {
|
|
|
73
73
|
});
|
|
74
74
|
for (const resolve of bp.waiters) resolve();
|
|
75
75
|
bp.waiters = [];
|
|
76
|
+
// Remove completed/errored monitors after a brief delay so tool
|
|
77
|
+
// consumers have time to read the final state via MonitorList.
|
|
78
|
+
setTimeout(() => { this.processes.delete(id); }, 30000);
|
|
76
79
|
};
|
|
77
80
|
|
|
78
81
|
child.on("close", (code) => {
|
package/src/store.ts
CHANGED
|
@@ -173,6 +173,20 @@ export class LoopStore {
|
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
expireEventLoops(): number {
|
|
177
|
+
return this.withLock(() => {
|
|
178
|
+
let count = 0;
|
|
179
|
+
for (const [_id, entry] of this.loops) {
|
|
180
|
+
if (entry.status !== "active") continue;
|
|
181
|
+
if (entry.trigger.type === "event" || entry.trigger.type === "hybrid") {
|
|
182
|
+
entry.status = "expired";
|
|
183
|
+
count++;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return count;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
176
190
|
clearAll(): number {
|
|
177
191
|
return this.withLock(() => {
|
|
178
192
|
const count = this.loops.size;
|
package/src/ui/widget.ts
CHANGED
|
@@ -106,7 +106,8 @@ export class LoopWidget {
|
|
|
106
106
|
for (const m of monitors.slice(0, Math.max(0, MAX_VISIBLE - loops.length))) {
|
|
107
107
|
const icon = "◉";
|
|
108
108
|
const age = Date.now() - m.startedAt;
|
|
109
|
-
|
|
109
|
+
const label = m.description || m.command.replace(/\n/g, " ").replace(/\s+/g, " ").trim().slice(0, 50);
|
|
110
|
+
lines.push(trunc(` ${icon} #${m.id} ${label} ${m.outputLines} lines (${formatDuration(age)})`));
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
return lines;
|