@trevonistrevon/pi-loop 0.4.7 → 0.4.8

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 CHANGED
@@ -271,11 +271,13 @@ export default function (pi) {
271
271
  });
272
272
  return true;
273
273
  }
274
- async function flushPendingNotifications() {
274
+ async function flushPendingNotifications(options) {
275
275
  if (flushPromise)
276
276
  return flushPromise;
277
277
  flushPromise = (async () => {
278
- if (agentRunning || _latestCtx?.hasPendingMessages())
278
+ if (agentRunning)
279
+ return;
280
+ if (!options?.ignorePendingMessages && _latestCtx?.hasPendingMessages())
279
281
  return;
280
282
  const entries = [...pendingNotifications.entries()]
281
283
  .sort(([, left], [, right]) => left.timestamp - right.timestamp);
@@ -375,7 +377,7 @@ export default function (pi) {
375
377
  agentRunning = false;
376
378
  _latestCtx = ctx;
377
379
  widget.setUICtx(ctx.ui);
378
- await flushPendingNotifications();
380
+ await flushPendingNotifications({ ignorePendingMessages: true });
379
381
  await pumpLoops();
380
382
  });
381
383
  pi.on("session_shutdown", async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trevonistrevon/pi-loop",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "A pi extension for cron/event-based agent re-wake loops and background process monitoring.",
5
5
  "author": "trevonistrevon",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -292,11 +292,12 @@ export default function (pi: ExtensionAPI) {
292
292
  return true;
293
293
  }
294
294
 
295
- async function flushPendingNotifications(): Promise<void> {
295
+ async function flushPendingNotifications(options?: { ignorePendingMessages?: boolean }): Promise<void> {
296
296
  if (flushPromise) return flushPromise;
297
297
 
298
298
  flushPromise = (async () => {
299
- if (agentRunning || _latestCtx?.hasPendingMessages()) return;
299
+ if (agentRunning) return;
300
+ if (!options?.ignorePendingMessages && _latestCtx?.hasPendingMessages()) return;
300
301
 
301
302
  const entries = [...pendingNotifications.entries()]
302
303
  .sort(([, left], [, right]) => left.timestamp - right.timestamp);
@@ -408,7 +409,7 @@ export default function (pi: ExtensionAPI) {
408
409
  agentRunning = false;
409
410
  _latestCtx = ctx;
410
411
  widget.setUICtx(ctx.ui);
411
- await flushPendingNotifications();
412
+ await flushPendingNotifications({ ignorePendingMessages: true });
412
413
  await pumpLoops();
413
414
  });
414
415