vg-coder-cli 2.0.57 → 2.0.58

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/bugs/bug1.md +97 -51
  2. package/package.json +1 -1
package/bugs/bug1.md CHANGED
@@ -8,32 +8,49 @@
8
8
 
9
9
  ---
10
10
 
11
- ## Status: 🟢 RESOLVED (2026-05-10, v2.0.53+)
11
+ ## Status: 🟢 RESOLVED (2026-05-10, v2.0.57)
12
12
 
13
- **Root cause confirmed**: AI Studio silently fallback model khi account thiếu
14
- access. AI Studio versions mới (verified 2026-05-10) KHÔNG redirect URL — URL
15
- param giữ nguyên request, chỉ DOM `<ms-model-selector>` phản ánh model thực.
13
+ **Real root cause** (xác định cuối cùng sau 5 round debug):
14
+
15
+ `vetgo-auto/scripts/aistudio.google.com/main.js` hardcode
16
+ `VG_DEFAULT_MODEL='gemini-3-flash-preview'`. `task-worker.js:handleTaskExecute`
17
+ gọi `startNewChat()` ở đầu mỗi task → navigate
18
+ `/prompts/new_chat?model=gemini-3-flash-preview` (drop `?model=` của caller pin).
19
+ Task chạy trên Flash bất kể caller request gì.
20
+
21
+ **Bằng chứng** (verified server2 ULTRA, 2026-05-10):
22
+ - Trước v2.0.57: pin `gemini-3.1-pro-preview` → quan sát qua noVNC: tab navigate
23
+ Pro → reload thành Flash → `actualModel: gemini-3-flash-preview`
24
+ - Sau v2.0.57: pin `gemini-3.1-pro-preview` → tab giữ Pro → `actualModel:
25
+ gemini-3.1-pro-preview` ✅
16
26
 
17
27
  **Fix shipped**:
18
28
  - v2.0.52: `open-tab` response thêm `requested_model` / `actual_model` /
19
- `fallback_occurred` (URL-based kept for backward-compat nhưng KHÔNG
20
- reliable với AI Studio versions mới).
21
- - v2.0.53: **`task.result.actualModel`** worker scrape DOM
22
- `<ms-model-selector> [data-test-id="model-name"]` sau khi task done. Đây
23
- **source of truth** cho client. Verified work với:
24
- - Request `gemini-99-fake` `actualModel: "gemini-3.1-pro-preview"` (AI Studio fallback rõ ràng).
25
-
26
- **Client pattern recommend**: bỏ qua `actual_model` open-tab response, check
27
- `task.result.actualModel === requestedModel` sau task done; nếu khác → fallback
28
- xảy ra, retry hoặc fail-fast tùy context.
29
+ `fallback_occurred` (URL-based, partial detection)
30
+ - v2.0.53: `task.result.actualModel` worker scrape DOM `<ms-model-selector>`
31
+ sau task done (detection accurate)
32
+ - v2.0.55: `_pinnedModelByEmail` Map `_recycleWorkerTab` reopen với pinned
33
+ model (giữ pin qua nhiều task)
34
+ - **v2.0.57: REAL FIX** — `getTargetModel()` đọc model từ URL hiện tại +
35
+ sessionStorage cache, thay tất cả hardcode `VG_DEFAULT_MODEL`. `startNewChat`
36
+ + `pinPromptModel` không còn override pin của caller.
37
+
38
+ **Client pattern recommend**:
39
+ 1. Pin model qua `POST /api/launcher/open-tab` body `{model: "..."}`
40
+ 2. Submit task → check `task.result.actualModel === expectedModel`
41
+ 3. Nếu khác → AI Studio fallback (account không có access). Decide retry /
42
+ fail-fast / accept tùy use-case.
29
43
 
30
44
  **Code refs**:
31
- - `vetgo-auto/chrome/src/launcher.ts` — open-tab handler (URL-based detection,
32
- legacy)
33
- - `src/server/views/js/features/task-worker.js:201-235` — `readActualModel()`
34
- scrape DOM, retry without/with toggle panel
35
- - `src/server/task-queue.js:417-422` — persist `actualModel` vào `task.result`
36
- - `INTEGRATION.md` client docs với recommend pattern
45
+ - `vetgo-auto/scripts/aistudio.google.com/main.js:20-37` — `getTargetModel()`
46
+ (real fix — primary)
47
+ - `src/server/views/js/features/task-worker.js:210-236` — `readActualModel()`
48
+ scrape DOM (verification layer)
49
+ - `src/server/task-queue.js:42-44, 491-494` — `_pinnedModelByEmail` persist
50
+ qua recycle (secondary fix)
51
+ - `vetgo-auto/chrome/src/launcher.ts` — open-tab handler URL-based detection
52
+ (legacy — không reliable với AI Studio versions mới)
53
+ - `INTEGRATION.md "Verify model thực"` — client docs với recommend pattern
37
54
 
38
55
  ---
39
56
 
@@ -371,34 +388,63 @@ For the AI agent fixing this bug:
371
388
 
372
389
  ---
373
390
 
374
- ## Update 2026-05-10 — Deep root cause discovered
375
-
376
- Sau khi ship v2.0.55 (`_pinnedModelByEmail`), test với account ULTRA Pro
377
- access vẫn cho `actualModel: gemini-3-flash-preview`. Debug DOM trong khi task
378
- đang chạy phát hiện:
379
-
380
- ```
381
- URL during task: https://aistudio.google.com/prompts/new_chat ← KHÔNG ?model=
382
- DOM ms-model-selector: "gemini-3-flash-preview"
383
- ```
384
-
385
- **AI Studio strip `?model=` query khỏi URL sau khi user/script trigger run.**
386
- URL pin model chỉ work cho **initial load** sau khi prompt submit, AI Studio
387
- clean URL → model selector revert về default Flash → task chạy thực sự trên
388
- Flash bất kể request gì.
389
-
390
- ### Real fix cần thiết (ngoài scope hôm nay)
391
-
392
- 1. Worker phải **click model dropdown UI + select model** trước khi submit prompt
393
- (không thể chỉ rely vào URL param)
394
- 2. Hoặc: dùng AI Studio **Run settings panel** model picker thay vì URL trick
395
-
396
- Cả 2 cách yêu cầu DOM scripting thêm trong `task-worker.js` `handleTaskExecute`,
397
- prerun step "ensureModel(targetModel)". Phức tạp hơn fix hiện tại.
398
-
399
- ### Tạm thời (workaround)
400
-
401
- - `actualModel` field vẫn correct — phản ánh model THỰC SỰ chạy (không phải
402
- request). Client dùng để fail-fast: `if (actualModel !== expected) abort`.
403
- - Default model `gemini-3-flash-preview` chấp nhận được cho most use cases.
404
- - Nếu cần Pro: manual select via noVNC trước khi run task pipeline.
391
+ ## Debug timeline (2026-05-10)
392
+
393
+ Bug fix mất 5 round đoán sai root cause vài lần. Lưu lại để tránh lặp:
394
+
395
+ ### Round 1 (v2.0.52) — URL-based detection ❌
396
+ Hypothesis: AI Studio redirect URL khi fallback. Add `requested_model` /
397
+ `actual_model` từ URL ở open-tab response.
398
+ **Sai vì**: AI Studio versions hiện tại **không** redirect URL (từng làm trong
399
+ quá khứ?). URL giữ nguyên dù fallback.
400
+
401
+ ### Round 2 (v2.0.53) — DOM scrape sau task ✅ partial
402
+ Worker `readActualModel()` scrape `<ms-model-selector>` sau task done. Verified
403
+ work với account free tier (request fake model DOM trả model thực).
404
+
405
+ ### Round 3 Test với account ULTRA, vẫn Flash
406
+ Hypothesis: pin model bị mất sau `_recycleWorkerTab` (close+reopen với default).
407
+ v2.0.55 add `_pinnedModelByEmail` Map.
408
+ **Đúng 1 phần**: pin persist qua recycle. Nhưng test vẫn Flash.
409
+
410
+ ### Round 4 Hypothesis "AI Studio strip ?model="
411
+ Quan sát: URL during task = `/prompts/new_chat` (no query). Đoán AI Studio
412
+ auto-clean URL sau prompt submit.
413
+ **Sai vì**: chính code vg-coder navigate URL (không phải AI Studio).
414
+
415
+ ### Round 5 (v2.0.57) — REAL ROOT CAUSE ✅
416
+ User quan sát qua noVNC: tab navigate đúng Pro → reload thành Flash trước khi
417
+ chat. Grep code → tìm thấy `vetgo-auto/scripts/aistudio.google.com/main.js`
418
+ hardcode `VG_DEFAULT_MODEL='gemini-3-flash-preview'`. `startNewChat()` đầu
419
+ mỗi task navigate `/prompts/new_chat?model=Flash` override pin caller.
420
+ Fix: `getTargetModel()` dynamic từ URL + sessionStorage. **Verified work.**
421
+
422
+ ### Round 6 — CI miss step (real-real fix)
423
+
424
+ Sau v2.0.57 deployed, test server3 vẫn fail. Verify bundle trên server:
425
+ - `grep getTargetModel /usr/local/lib/node_modules/vg-coder-cli/dist/vg-coder-bundle.js` → 0 match
426
+ - v2.0.57 publish thành công nhưng code mới **không có** trong bundle
427
+
428
+ **Cause**: `vetgo-auto/scripts/aistudio.google.com/main.js` deploy qua Firebase
429
+ RTDB (`ENV/VGCODER`), KHÔNG bundle vào npm package. Extension fetch script tại
430
+ runtime từ Firebase. CI `publish.yml` chỉ chạy `build:extension` + `build:copy`
431
+ + `build:inject` — bỏ qua `deploy-scripts`. Phải chạy thủ công
432
+ `cd vetgo-auto && node deploy-scripts.js` từ máy local để push code mới.
433
+
434
+ **Fix CI**: add `npm run deploy-scripts` step vào `publish.yml` (commit
435
+ 83186ba). Lần sau bump version → CI tự push Firebase.
436
+
437
+ ### Lesson learned
438
+
439
+ - **Quan sát visual (noVNC) > eval DOM async**: User report "tab reload trước
440
+ khi chat" là clue quyết định. Eval DOM tại các thời điểm khác nhau cho data
441
+ rời rạc khó ráp.
442
+ - **Grep hardcode constant trước khi đoán external behavior**: 4 round đầu đoán
443
+ AI Studio làm gì đó (redirect, strip query). Round 5 tìm thấy hardcode trong
444
+ chính code mình.
445
+ - **Verify deploy artifact trên target server**: Round 6 chỉ ra version bump
446
+ KHÔNG đảm bảo code mới chạy nếu deploy pipeline có gap. Sau mỗi fix, grep
447
+ symbol mới trong file production thực — không tin "CI passed = code chạy".
448
+ - **Multiple layer detection có giá trị**: `actualModel` (DOM scrape) là
449
+ source-of-truth đúng đắn ngay từ v2.0.53 — confirm bug có thật, định nghĩa
450
+ expected behavior cho fix, không phụ thuộc fix nào fail.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vg-coder-cli",
3
- "version": "2.0.57",
3
+ "version": "2.0.58",
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": {