vg-coder-cli 2.0.58 → 2.0.60

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": "vg-coder-cli",
3
- "version": "2.0.58",
3
+ "version": "2.0.60",
4
4
  "description": "🚀 CLI tool to analyze projects, concatenate source files, count tokens, and export HTML with syntax highlighting and copy functionality",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -163,7 +163,13 @@ class TaskQueue {
163
163
  if (wasUnknown && email !== existing.email) {
164
164
  // shouldn't happen — kept for clarity (email already assigned above)
165
165
  }
166
- console.log(chalk.green(`[TaskQueue] Worker re-register: ${socket.id} (${email})`));
166
+ // Re-establish pin từ URL hiện tại của tab worker. Khắc phục race khi
167
+ // open-tab handler set _pinnedModelByEmail nhưng launcher email lúc đó
168
+ // null (chưa scrape) → pin bị mất → recycle reopen với default.
169
+ if (meta?.pinnedModel && !email.startsWith('unknown:')) {
170
+ this._pinnedModelByEmail.set(email, meta.pinnedModel);
171
+ }
172
+ console.log(chalk.green(`[TaskQueue] Worker re-register: ${socket.id} (${email})${meta?.pinnedModel ? ` pinned=${meta.pinnedModel}` : ''}`));
167
173
  setImmediate(() => this._drain());
168
174
  return true;
169
175
  }
@@ -184,7 +190,11 @@ class TaskQueue {
184
190
  if (meta?.chromeId && email && !email.startsWith('unknown:')) {
185
191
  this._bindChromeIdToEmail(meta.chromeId, email);
186
192
  }
187
- console.log(chalk.green(`[TaskQueue] Worker registered: ${socket.id} (${email})`));
193
+ // Re-establish pin từ URL hiện tại (xem comment re-register branch).
194
+ if (meta?.pinnedModel && !email.startsWith('unknown:')) {
195
+ this._pinnedModelByEmail.set(email, meta.pinnedModel);
196
+ }
197
+ console.log(chalk.green(`[TaskQueue] Worker registered: ${socket.id} (${email})${meta?.pinnedModel ? ` pinned=${meta.pinnedModel}` : ''}`));
188
198
  setImmediate(() => this._drain());
189
199
  return true;
190
200
  }
@@ -284,8 +284,10 @@ async function handleTaskExecute(payload) {
284
284
  // 5. Re-check after turn renders — error turns count as turns too.
285
285
  throwIfRateLimited('post_turn');
286
286
 
287
- // 6. Extra settle so streaming finalizes before we trigger Copy-as-markdown
288
- await new Promise(r => setTimeout(r, 1500));
287
+ // Settle hardcoded 1.5s đã được thay thế: AIChat.send clickRunAndWait
288
+ // (trong main.js v2.0.59+) có post-render buffer scale theo render time
289
+ // (10% elapsed, floor 2s, cap 30s) — đủ cho task PDF lớn 5-10p tránh
290
+ // copy thiếu text streaming chunks cuối.
289
291
 
290
292
  if (cancelFlags.has(taskId)) {
291
293
  cancelFlags.delete(taskId);
@@ -345,12 +347,20 @@ function connect() {
345
347
  // Register with whatever email we have right now (may be null on cold load).
346
348
  const initialEmail = extractEmail();
347
349
  const chromeId = (window.vetgo && window.vetgo.chromeId) || null;
350
+ // pinnedModel: lấy từ URL ?model=X — server dùng để re-establish pin
351
+ // sau khi worker register với email thật (không lúc open-tab vì lúc đó
352
+ // launcher có thể chưa scrape email).
353
+ const pinnedModel = (() => {
354
+ try { return new URLSearchParams(location.search).get('model') || null; }
355
+ catch (_) { return null; }
356
+ })();
348
357
  socket.emit('worker:register', {
349
358
  domain: location.hostname,
350
359
  chatId: window.AIChat?.getChatIdFromUrl?.() || null,
351
360
  userAgent: navigator.userAgent,
352
361
  email: initialEmail,
353
- chromeId
362
+ chromeId,
363
+ pinnedModel
354
364
  });
355
365
  console.log(`[TaskWorker] Initial email: ${initialEmail || '(pending)'}, chromeId: ${chromeId || '(none)'}`);
356
366
 
@@ -366,14 +376,19 @@ function connect() {
366
376
  try {
367
377
  const resolved = await resolveEmail(3000, emailAbort?.signal);
368
378
  if (!resolved || !socket.connected) return;
379
+ const pm = (() => {
380
+ try { return new URLSearchParams(location.search).get('model') || null; }
381
+ catch (_) { return null; }
382
+ })();
369
383
  socket.emit('worker:register', {
370
384
  domain: location.hostname,
371
385
  chatId: window.AIChat?.getChatIdFromUrl?.() || null,
372
386
  userAgent: navigator.userAgent,
373
387
  email: resolved,
374
- chromeId: (window.vetgo && window.vetgo.chromeId) || null
388
+ chromeId: (window.vetgo && window.vetgo.chromeId) || null,
389
+ pinnedModel: pm
375
390
  });
376
- console.log(`[TaskWorker] Re-registered with email: ${resolved}`);
391
+ console.log(`[TaskWorker] Re-registered with email: ${resolved} (pinnedModel=${pm || 'none'})`);
377
392
  } catch (err) {
378
393
  console.error('[TaskWorker] Email retry failed:', err);
379
394
  }