dsh-agy-link 0.4.96 → 0.4.98

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.98 (2026-10-30)
4
+
5
+ ### English
6
+
7
+ - **Fix(client/mermaid): re-render a diagram after streaming settles instead of leaving the finished reply as a code block.**
8
+ - A streaming reply rewrites its code block in place (React keeps the element and only replaces the text), so the scanner's `data-agy-mermaid` state survived every chunk. The first pass usually saw an incomplete mermaid prefix, failed to parse, and silently marked the block `fallback`; when the full text arrived the element was never rebuilt, so the block was skipped forever and stayed a plain `代码块` until the user switched sessions (which remounts the block and wipes the state — exactly the "切走再切回就显示了" symptom). The scanner now fingerprints the current source (`sourceSignature`) and remembers what it last attempted (`data-agy-mermaid-sig`); when the text changes it waits one quiet pass (`data-agy-mermaid-pending`, so intermediate stream prefixes are not rendered) and then renders the settled source. `renderInto()` also reschedules a scan on completion so a source change during an in-flight render is caught. Adds `mermaidScanAction`/`sourceSignature` regression tests (verified live: partial → full in place now ends `done` with an SVG).
9
+
10
+ ### 中文
11
+
12
+ - **修复(client/mermaid):流式回复结束后会自动重渲染图表,不再把已经完整的回复留成代码块。**
13
+ - 流式输出会**原地改写**代码块(React 复用同一个元素、只替换文本),所以扫描器打的 `data-agy-mermaid` 状态会一直保留。第一遍扫描往往看到的是**不完整的 mermaid 前缀**,解析失败后被静默标成 `fallback`;等完整文本到达时元素并没有重建,于是永远跳过、一直显示成普通「代码块」——直到你切到别的会话再切回来(元素被重新挂载、状态被清空)才渲染,这正是“切走再切回就显示了”的现象。现在扫描器会给当前源码打指纹(`sourceSignature`)并记住上次尝试过的源码(`data-agy-mermaid-sig`):源码变化时先等一个“安静”的扫描周期(`data-agy-mermaid-pending`,避免把流式中间态每个前缀都渲染一遍),确认稳定后再渲染完整内容。`renderInto()` 完成时也会补一次扫描,覆盖“渲染过程中源码又变了”的情况。新增 `mermaidScanAction`/`sourceSignature` 回归测试(已实测:partial → full 原地更新后最终 `done` 并出图)。
14
+
15
+ **Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.4.97...v0.4.98
16
+
17
+ ## 0.4.97 (2026-10-30)
18
+
19
+ ### English
20
+
21
+ - **Fix(pool): switching the active account ("设为当前使用" / set primary) now refreshes that account's model catalog and always re-announces the model picker, so the composer's cached list updates immediately (e.g. Gemini 4 Argon appears after switching to a Pro/Ultra account).**
22
+ - `/pool/set-active` refreshed via `catalog.forceRefresh(id)` and relied on `ModelCatalog` emitting an update *only when the catalog contents changed*. But the composer model picker caches its snapshot and re-reads only on the `llm/adapters-updated` event, and the visible set also depends on the active account's plan (`listModels()` filters the Argon family). So switching to an account whose catalog happened to match the previous one left the picker showing the old models (Argon missing). Added `ModelCatalog.forceRefreshAndNotify()` — refresh the target account, then emit unconditionally — and wired it into `/pool/set-active`, `/pool/primary` and `/pool/reorder`; `enable`/`remove` now announce too. Adds a regression test (identical catalog still re-announces).
23
+
24
+ ### 中文
25
+
26
+ - **修复(pool):切换「设为当前使用」/主用账号后会刷新该账号的模型目录并强制重新广播,会话窗口的模型列表立即更新(切到 Pro/Ultra 账号后 Gemini 4 Argon 正常出现)。**
27
+ - `/pool/set-active` 之前只调 `catalog.forceRefresh(id)`,且 `ModelCatalog` 仅在**目录内容发生变化**时才发更新事件;但会话模型选择器缓存快照、只在 `llm/adapters-updated` 事件后重读,而可见集还取决于当前账号的套餐(`listModels()` 会按账号过滤 Argon)。因此切到「目录恰好与之前相同」的账号时,选择器仍显示旧模型(Argon 不出现)。新增 `ModelCatalog.forceRefreshAndNotify()`(刷新目标账号后**无条件**广播),并接入 `/pool/set-active`、`/pool/primary`、`/pool/reorder`;`enable`/`remove` 也会广播。补充回归测试(目录未变也重新广播)。
28
+
29
+ **Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.4.96...v0.4.97
30
+
3
31
  ## 0.4.96 (2026-10-30)
4
32
 
5
33
  ### English
package/dist/client.js CHANGED
@@ -3419,6 +3419,7 @@ body > [id^="iagy-mmd"] .error-icon {
3419
3419
  cleanupTempElements(id);
3420
3420
  }
3421
3421
  });
3422
+ scheduleScan$1();
3422
3423
  }
3423
3424
  let scanTimer$1 = null;
3424
3425
  function scheduleScan$1() {
@@ -3430,6 +3431,36 @@ body > [id^="iagy-mmd"] .error-icon {
3430
3431
  scan();
3431
3432
  }, 150);
3432
3433
  }
3434
+ /**
3435
+ * Cheap content signature for a block's current source.
3436
+ *
3437
+ * Streaming rewrites the block in place (React keeps the same element and only
3438
+ * replaces the text), so the `data-agy-mermaid` state survives every chunk.
3439
+ * Without a signature, a block first scanned mid-stream parsed as incomplete
3440
+ * source, fell back to "not a diagram", and was never retried — the finished
3441
+ * diagram stayed a plain code block forever. The signature lets the scanner
3442
+ * notice that the source changed and try again.
3443
+ */
3444
+ function sourceSignature(source) {
3445
+ let h = 5381;
3446
+ for (let i = 0; i < source.length; i++) h = (h << 5) + h + source.charCodeAt(i) | 0;
3447
+ return source.length + ":" + (h >>> 0).toString(36);
3448
+ }
3449
+ /**
3450
+ * Decide what the scanner should do with one block.
3451
+ *
3452
+ * - `skip`: already rendered this exact source, or a render is in flight.
3453
+ * - `wait`: the source changed since the last attempt; require one quiet pass
3454
+ * so a streaming block is not rendered for every intermediate prefix.
3455
+ * - `render`: first attempt (no signature yet), or the source settled after a
3456
+ * previous attempt.
3457
+ */
3458
+ function mermaidScanAction(state, renderedSig, pendingSig, sig) {
3459
+ if (state === "busy") return "skip";
3460
+ if (renderedSig === sig) return "skip";
3461
+ if (renderedSig === null) return "render";
3462
+ return pendingSig === sig ? "render" : "wait";
3463
+ }
3433
3464
  function scan() {
3434
3465
  if (typeof document === "undefined") return;
3435
3466
  if (isInteractionLocked()) return;
@@ -3438,12 +3469,21 @@ body > [id^="iagy-mmd"] .error-icon {
3438
3469
  for (let i = 0; i < blocks.length; i++) {
3439
3470
  const block = blocks[i];
3440
3471
  if (!block) continue;
3441
- const state = block.getAttribute("data-agy-mermaid");
3442
- if (state === "done" || state === "busy" || state === "error" || state === "fallback") continue;
3443
3472
  const lang = fenceLang(block);
3444
3473
  const source = readSource(block);
3445
3474
  if (source === "") continue;
3446
3475
  if (!isMermaidBlock(lang, source)) continue;
3476
+ const state = block.getAttribute("data-agy-mermaid");
3477
+ const sig = sourceSignature(source);
3478
+ const action = mermaidScanAction(state, block.getAttribute("data-agy-mermaid-sig"), block.getAttribute("data-agy-mermaid-pending"), sig);
3479
+ if (action === "skip") continue;
3480
+ if (action === "wait") {
3481
+ block.setAttribute("data-agy-mermaid-pending", sig);
3482
+ scheduleScan$1();
3483
+ continue;
3484
+ }
3485
+ block.removeAttribute("data-agy-mermaid-pending");
3486
+ block.setAttribute("data-agy-mermaid-sig", sig);
3447
3487
  block.setAttribute("data-agy-mermaid", "busy");
3448
3488
  renderInto(block, source, lang);
3449
3489
  }
package/dist/index.js CHANGED
@@ -2364,7 +2364,25 @@ var ModelCatalog = class ModelCatalog {
2364
2364
  await this.refresh(accountId);
2365
2365
  return this.get(accountId);
2366
2366
  }
2367
- async refresh(accountId) {
2367
+ /**
2368
+ * Refresh one account's catalog, then ALWAYS announce a picker update.
2369
+ *
2370
+ * `refresh()` only fires onUpdate when the catalog *contents* changed. But
2371
+ * switching the active account changes the picker's visible set even when
2372
+ * the catalog itself is identical — `listModels()` filters the Argon family
2373
+ * by the active account's plan, and it resolves `catalog.get(accountId)`,
2374
+ * which must be populated for the newly active account before the picker
2375
+ * re-reads. So an account switch must (a) discover that account's catalog and
2376
+ * (b) emit the update unconditionally, or the composer's cached model
2377
+ * snapshot keeps showing the previous account's models (e.g. no Argon after
2378
+ * switching to a Pro/Ultra account).
2379
+ */
2380
+ async forceRefreshAndNotify(accountId) {
2381
+ await this.refresh(accountId, false);
2382
+ this.onUpdate?.();
2383
+ return this.get(accountId);
2384
+ }
2385
+ async refresh(accountId, announce = true) {
2368
2386
  try {
2369
2387
  const ac = new AbortController();
2370
2388
  const timer = setTimeout(() => ac.abort(), 3e4);
@@ -2382,7 +2400,7 @@ var ModelCatalog = class ModelCatalog {
2382
2400
  const changed = prev.source !== "discovered" || prev.models.length !== newModels.length || prev.models.some((m, i) => m.id !== newModels[i]?.id);
2383
2401
  if (accountId) this.accountCatalogs.set(accountId, newCatalog);
2384
2402
  else this.current = newCatalog;
2385
- if (changed) this.onUpdate?.();
2403
+ if (changed && announce) this.onUpdate?.();
2386
2404
  return;
2387
2405
  }
2388
2406
  if (accountId) {
@@ -35890,6 +35908,7 @@ function apply(ctx, entryConfig = {}) {
35890
35908
  const body = await readBody(req);
35891
35909
  const id = typeof body.id === "string" ? body.id : "";
35892
35910
  pool.deleteAccount(id);
35911
+ notifyPicker();
35893
35912
  sendJson(res, 200, {
35894
35913
  ok: true,
35895
35914
  pool: pool.getPoolData()
@@ -35910,6 +35929,7 @@ function apply(ctx, entryConfig = {}) {
35910
35929
  const id = typeof body.id === "string" ? body.id : "";
35911
35930
  const enabled = typeof body.enabled === "boolean" ? body.enabled : true;
35912
35931
  const ok = pool.setAccountEnabled(id, enabled);
35932
+ if (ok) notifyPicker();
35913
35933
  sendJson(res, ok ? 200 : 400, {
35914
35934
  ok,
35915
35935
  pool: pool.getPoolData()
@@ -35948,7 +35968,10 @@ function apply(ctx, entryConfig = {}) {
35948
35968
  }
35949
35969
  const body = await readBody(req);
35950
35970
  const id = typeof body.id === "string" ? body.id : "";
35951
- pool.setPrimaryAccount(id);
35971
+ if (pool.setPrimaryAccount(id)) {
35972
+ notifyPicker();
35973
+ catalog.forceRefreshAndNotify(id).catch(() => void 0);
35974
+ }
35952
35975
  sendJson(res, 200, {
35953
35976
  ok: true,
35954
35977
  pool: pool.getPoolData()
@@ -36083,7 +36106,10 @@ function apply(ctx, entryConfig = {}) {
36083
36106
  const body = await readBody(req);
36084
36107
  const id = typeof body.id === "string" ? body.id : "";
36085
36108
  const ok = id !== "" && pool.setActiveAccount(id);
36086
- if (ok) catalog.forceRefresh(id).catch(() => void 0);
36109
+ if (ok) {
36110
+ notifyPicker();
36111
+ catalog.forceRefreshAndNotify(id).catch(() => void 0);
36112
+ }
36087
36113
  sendJson(res, ok ? 200 : 400, {
36088
36114
  ok,
36089
36115
  pool: pool.getPoolData()
@@ -36102,7 +36128,11 @@ function apply(ctx, entryConfig = {}) {
36102
36128
  }
36103
36129
  const body = await readBody(req);
36104
36130
  const ids = Array.isArray(body.ids) ? body.ids.filter((x) => typeof x === "string") : [];
36105
- pool.reorderAccounts(ids);
36131
+ if (pool.reorderAccounts(ids)) {
36132
+ const activeId = pool.getActiveAccountId("google");
36133
+ notifyPicker();
36134
+ if (activeId) catalog.forceRefreshAndNotify(activeId).catch(() => void 0);
36135
+ }
36106
36136
  sendJson(res, 200, {
36107
36137
  ok: true,
36108
36138
  pool: pool.getPoolData()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.4.96",
3
+ "version": "0.4.98",
4
4
  "description": "Google Antigravity (agy CLI) models for DeepSeek Harness — stream Gemini/Claude/GPT-OSS subscriptions into DSH with thinking, tool activity, token usage and in-GUI Google OAuth login.",
5
5
  "type": "module",
6
6
  "license": "MIT",