pi-invisible-continue 0.2.2 → 0.2.3

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.
Files changed (2) hide show
  1. package/continue.ts +9 -1
  2. package/package.json +1 -1
package/continue.ts CHANGED
@@ -41,6 +41,11 @@ Agent.prototype.subscribe = function (this: Agent, ...args: any[]) {
41
41
  // producing "Agent is already processing".
42
42
  let _continueInProgress = false;
43
43
 
44
+ // Timestamp of the last completed invisible continue.
45
+ // Used to avoid double continuation when continue() unblocks after
46
+ // triggerInvisibleContinue just ran.
47
+ let _lastInvisibleContinueTime = 0;
48
+
44
49
  // Monkey-patch continue() so the session's built-in loop cooperates with
45
50
  // our mutex AND can convert the "Cannot continue from assistant" error
46
51
  // into a prompt([]) call when the agent was mid-task.
@@ -75,7 +80,8 @@ Agent.prototype.continue = function (this: Agent) {
75
80
  lastMsg.stopReason !== 'aborted' &&
76
81
  lastMsg.stopReason !== 'error') {
77
82
  // Agent was mid-task — fall back to prompt([])
78
- if (!_continueInProgress) {
83
+ // Guard: if an invisible continue just completed, don't double-run
84
+ if (!_continueInProgress && Date.now() - _lastInvisibleContinueTime > 500) {
79
85
  _continueInProgress = true;
80
86
  try {
81
87
  await self.prompt([]);
@@ -107,6 +113,7 @@ export default function (pi: ExtensionAPI) {
107
113
 
108
114
  pi.on("session_start", () => {
109
115
  _continueInProgress = false;
116
+ _lastInvisibleContinueTime = 0;
110
117
  });
111
118
  }
112
119
 
@@ -173,5 +180,6 @@ async function runContinueCommand(
173
180
  }
174
181
  } finally {
175
182
  _continueInProgress = false;
183
+ _lastInvisibleContinueTime = Date.now();
176
184
  }
177
185
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-invisible-continue",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Invisible session continuation for pi — resume the agentic loop without sending ANY prompt the LLM can see",
5
5
  "type": "module",
6
6
  "author": "Tom X Nguyen",