dsh-agy-link 0.4.97 → 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,19 @@
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
+
3
17
  ## 0.4.97 (2026-10-30)
4
18
 
5
19
  ### 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.4.97",
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",