vg-coder-cli 2.0.59 → 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.59",
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
  }
@@ -347,12 +347,20 @@ function connect() {
347
347
  // Register with whatever email we have right now (may be null on cold load).
348
348
  const initialEmail = extractEmail();
349
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
+ })();
350
357
  socket.emit('worker:register', {
351
358
  domain: location.hostname,
352
359
  chatId: window.AIChat?.getChatIdFromUrl?.() || null,
353
360
  userAgent: navigator.userAgent,
354
361
  email: initialEmail,
355
- chromeId
362
+ chromeId,
363
+ pinnedModel
356
364
  });
357
365
  console.log(`[TaskWorker] Initial email: ${initialEmail || '(pending)'}, chromeId: ${chromeId || '(none)'}`);
358
366
 
@@ -368,14 +376,19 @@ function connect() {
368
376
  try {
369
377
  const resolved = await resolveEmail(3000, emailAbort?.signal);
370
378
  if (!resolved || !socket.connected) return;
379
+ const pm = (() => {
380
+ try { return new URLSearchParams(location.search).get('model') || null; }
381
+ catch (_) { return null; }
382
+ })();
371
383
  socket.emit('worker:register', {
372
384
  domain: location.hostname,
373
385
  chatId: window.AIChat?.getChatIdFromUrl?.() || null,
374
386
  userAgent: navigator.userAgent,
375
387
  email: resolved,
376
- chromeId: (window.vetgo && window.vetgo.chromeId) || null
388
+ chromeId: (window.vetgo && window.vetgo.chromeId) || null,
389
+ pinnedModel: pm
377
390
  });
378
- console.log(`[TaskWorker] Re-registered with email: ${resolved}`);
391
+ console.log(`[TaskWorker] Re-registered with email: ${resolved} (pinnedModel=${pm || 'none'})`);
379
392
  } catch (err) {
380
393
  console.error('[TaskWorker] Email retry failed:', err);
381
394
  }