tuna-agent 0.1.154 → 0.1.155

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.
@@ -118,21 +118,26 @@ export async function handleClaudePrompt(ws, code, taskId, prompt, systemPrompt,
118
118
  }
119
119
  }
120
120
  // ─── Handler: claude_prompt_stream (prompt → streamed text + JSON result) ────
121
- // Track active stream tasks by code so we can abort previous ones
121
+ // Track active stream tasks by taskId (UNIQUE per request). Was keyed by
122
+ // `code` (the shared pair code) which made concurrent claude_prompt_stream
123
+ // calls abort each other — fatal for the batched clone pool (5 parallel
124
+ // chunks → siblings killed → batches hang at 0). taskId is unique so streams
125
+ // run independently; a superseded request gets a fresh taskId anyway.
122
126
  const _activeStreamTasks = new Map();
123
127
  export async function handleClaudePromptStream(ws, code, taskId, prompt, systemPrompt) {
124
128
  console.log(`[claude_prompt_stream] Received: ${prompt.substring(0, 100)}...`);
125
- // Kill previous stream task for same code (e.g. user clicked Regenerate again)
126
- const prev = _activeStreamTasks.get(code);
129
+ // Per-taskId (unique): never aborts a concurrent sibling. (Re-clicked
130
+ // Regenerate arrives with a new taskId; the old one finishes on its own.)
131
+ const prev = _activeStreamTasks.get(taskId);
127
132
  if (prev) {
128
- console.log(`[claude_prompt_stream] Aborting previous task for code=${code}`);
133
+ console.log(`[claude_prompt_stream] Aborting previous task for taskId=${taskId}`);
129
134
  prev.abort();
130
135
  }
131
136
  const abortController = new AbortController();
132
- _activeStreamTasks.set(code, abortController);
137
+ _activeStreamTasks.set(taskId, abortController);
133
138
  if (!hasContentCreator()) {
134
139
  const error = 'content-creator agent not found on this machine';
135
- _activeStreamTasks.delete(code);
140
+ _activeStreamTasks.delete(taskId);
136
141
  ws.sendExtensionDone(code, taskId, { error });
137
142
  return;
138
143
  }
@@ -190,11 +195,11 @@ export async function handleClaudePromptStream(ws, code, taskId, prompt, systemP
190
195
  }
191
196
  catch { }
192
197
  }
193
- _activeStreamTasks.delete(code);
198
+ _activeStreamTasks.delete(taskId);
194
199
  ws.sendExtensionDone(code, taskId, { result: parsed, raw: text });
195
200
  }
196
201
  catch (err) {
197
- _activeStreamTasks.delete(code);
202
+ _activeStreamTasks.delete(taskId);
198
203
  if (abortController.signal.aborted) {
199
204
  console.log(`[claude_prompt_stream] Aborted (replaced by new task)`);
200
205
  return; // Don't send error — new task is already running
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.154",
3
+ "version": "0.1.155",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"