@alexpeng/dsh-custom-plugin 0.1.5 → 0.1.6

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
@@ -4,7 +4,7 @@ All notable changes to this project are documented here. The format loosely
4
4
  follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions
5
5
  follow [Semantic Versioning](https://semver.org/).
6
6
 
7
- ## Unreleased
7
+ ## 0.1.6 — 2026-09-02
8
8
 
9
9
  ### Fixed
10
10
 
@@ -19,6 +19,13 @@ follow [Semantic Versioning](https://semver.org/).
19
19
  09:00–12:00 / 14:00–18:00 as peak; weekends are off-peak.
20
20
  - The browser usage panel now uses the same Beijing-time day bucket as the
21
21
  Host, including when the desktop host runs outside UTC+8.
22
+ - Client state snapshots are serialized in invocation order so rapid settings
23
+ changes cannot be overwritten by an older save completing later.
24
+ - Timeline refreshes ignore stale session/request responses and follow live
25
+ conversation running-state changes.
26
+ - Mermaid modal changes reload correctly, while concurrent CDN loads share one
27
+ in-flight request; the balance hover panel also remains reachable across its
28
+ trigger gap.
22
29
 
23
30
  ### Changed
24
31
 
@@ -30,6 +37,14 @@ follow [Semantic Versioning](https://semver.org/).
30
37
  source link, and the built-in rule check date.
31
38
  - Saved panel keys prefer the optional OS credential store, migrate legacy
32
39
  state-file keys when possible, and no longer cross the browser state boundary.
40
+ - Light/dark root theme styles now take precedence over the host OS preference,
41
+ and the build uses the current tsdown dependency configuration without
42
+ deprecation warnings.
43
+
44
+ ### Added
45
+
46
+ - Regression coverage for ordered state saves and shared in-flight Mermaid
47
+ loading.
33
48
 
34
49
  ## 0.1.3 — 2026-08-23
35
50
 
package/lib/client.js CHANGED
@@ -177,13 +177,21 @@ window.__ModuleLoader__.load({
177
177
  body: JSON.stringify(body)
178
178
  });
179
179
  }
180
+ /**
181
+ * State POSTs carry a complete snapshot rather than an operation log. Keep
182
+ * them on one client-side queue so a quick sequence of toggles cannot be
183
+ * applied out of order when the network completes requests differently.
184
+ */
185
+ let stateSaveQueue = Promise.resolve();
180
186
  /** Read the whole state document. */
181
187
  async function apiStateGet() {
182
188
  return await request("/state", { cache: "no-store" });
183
189
  }
184
190
  /** Persist a state edit. */
185
191
  async function apiStateSave(edit) {
186
- return await postJson("/state", edit);
192
+ const run = stateSaveQueue.catch(() => {}).then(() => postJson("/state", edit));
193
+ stateSaveQueue = run.then(() => {}, () => {});
194
+ return await run;
187
195
  }
188
196
  /** Timeline nodes for one session (tail-capped by the host). */
189
197
  async function apiTimelineGet(sessionId) {
@@ -1250,7 +1258,71 @@ window.__ModuleLoader__.load({
1250
1258
  .vx-mmd-stage svg {
1251
1259
  max-width: 100%;
1252
1260
  height: auto;
1253
- }`;
1261
+ }
1262
+
1263
+ /* DSH can select a theme independently of the operating system. The root
1264
+ classes are applied from the resolved GUI theme and intentionally win
1265
+ over the media-query fallback above. */
1266
+ .vx-root.vx-dark .vx-glass {
1267
+ background: rgba(13, 17, 25, .62);
1268
+ color: #eef1f7;
1269
+ }
1270
+ .vx-root.vx-dark .vx-liquid .vx-glass {
1271
+ background: rgba(0, 0, 0, .06);
1272
+ }
1273
+ .vx-root.vx-dark .vx-liquid .vx-pattern {
1274
+ background-image: radial-gradient(rgba(110, 110, 128, .5) 3px, transparent 3px);
1275
+ }
1276
+ .vx-root.vx-dark .vx-pattern {
1277
+ background-image: radial-gradient(rgba(100, 100, 116, .5) 1px, transparent 1px);
1278
+ }
1279
+ .vx-root.vx-dark .vx-dot {
1280
+ background: rgba(205, 215, 230, .95);
1281
+ border-color: rgba(28, 34, 46, .9);
1282
+ }
1283
+ .vx-root.vx-dark .vx-thumb {
1284
+ background: rgba(165, 180, 205, .45);
1285
+ }
1286
+ .vx-root.vx-dark .vx-balance-hover,
1287
+ .vx-root.vx-dark .vx-panel,
1288
+ .vx-root.vx-dark .vx-modal,
1289
+ .vx-root.vx-dark .vx-folders {
1290
+ color: #e8ebf2;
1291
+ }
1292
+ .vx-root.vx-dark .vx-toast {
1293
+ background: rgba(18, 22, 30, .94);
1294
+ }
1295
+
1296
+ .vx-root.vx-light .vx-glass {
1297
+ background: rgba(255, 255, 255, .64);
1298
+ color: #20242e;
1299
+ }
1300
+ .vx-root.vx-light .vx-liquid .vx-glass {
1301
+ background: rgba(255, 255, 255, .06);
1302
+ }
1303
+ .vx-root.vx-light .vx-liquid .vx-pattern {
1304
+ background-image: radial-gradient(rgba(150, 150, 160, .5) 3px, transparent 3px);
1305
+ }
1306
+ .vx-root.vx-light .vx-pattern {
1307
+ background-image: radial-gradient(rgba(150, 150, 160, .42) 1px, transparent 1px);
1308
+ }
1309
+ .vx-root.vx-light .vx-dot {
1310
+ background: rgba(70, 85, 110, .92);
1311
+ border-color: rgba(255, 255, 255, .92);
1312
+ }
1313
+ .vx-root.vx-light .vx-thumb {
1314
+ background: rgba(90, 105, 135, .5);
1315
+ }
1316
+ .vx-root.vx-light .vx-balance-hover,
1317
+ .vx-root.vx-light .vx-panel,
1318
+ .vx-root.vx-light .vx-modal,
1319
+ .vx-root.vx-light .vx-folders {
1320
+ color: #20242e;
1321
+ }
1322
+ .vx-root.vx-light .vx-toast {
1323
+ background: rgba(26, 32, 44, .92);
1324
+ }
1325
+ }`;
1254
1326
  //#endregion
1255
1327
  //#region src/client/custom.tsx
1256
1328
  /**
@@ -2513,6 +2585,7 @@ window.__ModuleLoader__.load({
2513
2585
  });
2514
2586
  }
2515
2587
  let lastRefetchAt = 0;
2588
+ let turnsRequestSerial = 0;
2516
2589
  let railRefetchRows = -1;
2517
2590
  let lastDiagAt = 0;
2518
2591
  function diagThrottled(message) {
@@ -2528,9 +2601,10 @@ window.__ModuleLoader__.load({
2528
2601
  fetchTurns(S.sessionId);
2529
2602
  }
2530
2603
  async function fetchTurns(sessionId) {
2604
+ const requestSerial = ++turnsRequestSerial;
2531
2605
  try {
2532
2606
  const result = await apiTimelineGet(sessionId);
2533
- if (sessionId !== S.sessionId) return;
2607
+ if (sessionId !== S.sessionId || requestSerial !== turnsRequestSerial) return;
2534
2608
  if (result.ok === true) {
2535
2609
  S.turns = {
2536
2610
  sessionId,
@@ -2636,8 +2710,10 @@ window.__ModuleLoader__.load({
2636
2710
  let viewH = height;
2637
2711
  let railRight = 4;
2638
2712
  let railLeft = 56;
2713
+ let scrollerRect = null;
2639
2714
  if (scroller !== null) try {
2640
2715
  const r = scroller.getBoundingClientRect();
2716
+ scrollerRect = r;
2641
2717
  top = Math.max(0, r.top);
2642
2718
  height = Math.max(60, r.height);
2643
2719
  viewH = Math.max(1, scroller.clientHeight || r.height);
@@ -2649,7 +2725,7 @@ window.__ModuleLoader__.load({
2649
2725
  const trackH = height;
2650
2726
  const pos = [];
2651
2727
  const seqAnchor = /* @__PURE__ */ new Map();
2652
- if (scroller !== null) {
2728
+ if (scroller !== null && scrollerRect !== null) {
2653
2729
  const rows = queryUserRows(scroller);
2654
2730
  const offset = items.length - rows.length;
2655
2731
  if (rows.length > items.length && railRefetchRows < rows.length) {
@@ -2661,8 +2737,7 @@ window.__ModuleLoader__.load({
2661
2737
  if (item === void 0) continue;
2662
2738
  try {
2663
2739
  const r = rows[i].getBoundingClientRect();
2664
- const sr = scroller.getBoundingClientRect();
2665
- const pct = Math.max(0, Math.min(1, (r.top + r.height / 2 - sr.top + scrollTop) / Math.max(1, scroller.scrollHeight || 1)));
2740
+ const pct = Math.max(0, Math.min(1, (r.top + r.height / 2 - scrollerRect.top + scrollTop) / Math.max(1, scroller.scrollHeight || 1)));
2666
2741
  const starred = S.stars[S.sessionId]?.[item.seq] === true;
2667
2742
  seqAnchor.set(item.seq, rows[i]);
2668
2743
  pos.push({
@@ -3281,20 +3356,18 @@ window.__ModuleLoader__.load({
3281
3356
  const bal = b?.ok === true && b.balance !== null && b.balance !== void 0 ? b.balance : null;
3282
3357
  const balance = bal !== null ? (bal.currency ?? "CNY") === "CNY" ? "¥" + (bal.total ?? "") : `${bal.total ?? ""} ${bal.currency ?? ""}` : b?.ok === false ? b.keyConfigured === true ? "额度?" : "未配置密钥" : "额度…";
3283
3358
  const open = hover || pinned;
3284
- return react.createElement("span", { className: "vx-balance-wrap" }, react.createElement("span", {
3285
- className: "vx-balance-text" + (pinned ? " vx-balance-pinned" : ""),
3286
- title: pinned ? "再次点击取消固定" : "点击固定密钥面板",
3287
- onClick: () => setPinned(!pinned),
3359
+ return react.createElement("span", {
3360
+ className: "vx-balance-wrap",
3288
3361
  onMouseEnter: () => setHover(true),
3289
3362
  onMouseLeave: () => setHover(false)
3363
+ }, react.createElement("span", {
3364
+ className: "vx-balance-text" + (pinned ? " vx-balance-pinned" : ""),
3365
+ title: pinned ? "再次点击取消固定" : "点击固定密钥面板",
3366
+ onClick: () => setPinned(!pinned)
3290
3367
  }, react.createElement(Icon, {
3291
3368
  n: "wallet",
3292
3369
  size: 13
3293
- }), react.createElement("span", null, balance), calls > 0 ? react.createElement("span", { className: "vx-balance-today" }, `今日 ${calls} 次`) : null), open ? react.createElement("div", {
3294
- className: "vx-glass vx-balance-hover",
3295
- onMouseEnter: () => setHover(true),
3296
- onMouseLeave: () => setHover(false)
3297
- }, react.createElement("div", { className: "vx-pattern" }), pinned ? react.createElement("div", { className: "vx-balance-head" }, react.createElement("span", { className: "vx-muted" }, "已固定 · 再次点击「额度」或下方按钮取消"), react.createElement("button", {
3370
+ }), react.createElement("span", null, balance), calls > 0 ? react.createElement("span", { className: "vx-balance-today" }, `今日 ${calls} 次`) : null), open ? react.createElement("div", { className: "vx-glass vx-balance-hover" }, react.createElement("div", { className: "vx-pattern" }), pinned ? react.createElement("div", { className: "vx-balance-head" }, react.createElement("span", { className: "vx-muted" }, "已固定 · 再次点击「额度」或下方按钮取消"), react.createElement("button", {
3298
3371
  className: "vx-btn vx-btn-sm",
3299
3372
  onClick: () => setPinned(false)
3300
3373
  }, react.createElement(Icon, {
@@ -3608,11 +3681,16 @@ window.__ModuleLoader__.load({
3608
3681
  }, [current]);
3609
3682
  react.useEffect(() => {
3610
3683
  if (s.cfg.timeline !== true || S.sessionId === null) return;
3684
+ const running = summary?.running === true;
3611
3685
  const handle = setInterval(() => {
3612
- if (summary !== null && summary.running === true) fetchTurns(S.sessionId);
3686
+ if (running) fetchTurns(S.sessionId);
3613
3687
  }, 3e3);
3614
3688
  return () => clearInterval(handle);
3615
- }, [s.cfg.timeline, current]);
3689
+ }, [
3690
+ s.cfg.timeline,
3691
+ current,
3692
+ summary?.running
3693
+ ]);
3616
3694
  react.useEffect(() => {
3617
3695
  if (s.cfg.timeline !== true || S.sessionId === null) return;
3618
3696
  const el = trackRef.current;
@@ -4405,7 +4483,7 @@ window.__ModuleLoader__.load({
4405
4483
  return () => {
4406
4484
  alive = false;
4407
4485
  };
4408
- }, [mm?.index]);
4486
+ }, [mm]);
4409
4487
  if (mm === null) return null;
4410
4488
  return react.createElement("div", {
4411
4489
  className: "vx-modal-mask",
@@ -4898,7 +4976,7 @@ window.__ModuleLoader__.load({
4898
4976
  if (s.ask !== null) children.push(react.createElement(AskModal, { key: "ask" }));
4899
4977
  if (s.confirmAsk !== null) children.push(react.createElement(ConfirmModal, { key: "confirm" }));
4900
4978
  children.push(react.createElement(Toasts, { key: "toasts" }));
4901
- return react.createElement("div", { className: "vx-root" }, children);
4979
+ return react.createElement("div", { className: `vx-root ${s.dark ? "vx-dark" : "vx-light"}` }, children);
4902
4980
  }
4903
4981
  setDynCss("");
4904
4982
  try {