dsh-any-deepseek 0.0.35 → 0.0.36
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/lib/client.js +68 -9
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1573,6 +1573,26 @@ window.__ModuleLoader__.load({
|
|
|
1573
1573
|
*/
|
|
1574
1574
|
const USAGE_BADGE_REFRESH_MS = 3e5;
|
|
1575
1575
|
/**
|
|
1576
|
+
* Refresh cadence for the PROVIDER line: **fifteen seconds**.
|
|
1577
|
+
*
|
|
1578
|
+
* 🔴 Owner report (2026-11-18): 「我设定不用供应组不生效了好像」 — the switch HAD taken effect (the ledger
|
|
1579
|
+
* proved it: within a minute the requests were all on the newly chosen channel), but this line still
|
|
1580
|
+
* named the old supplier, because it shares the 5-minute refresh above.
|
|
1581
|
+
*
|
|
1582
|
+
* ⚠️ **Why the two facts cannot share one cadence, stated as the reason the numbers differ**: the
|
|
1583
|
+
* usage figure is expensive — `/stats` reads the whole month's ledger files — and it is a DAILY
|
|
1584
|
+
* cumulative, so a five-minute lag changes it by a rounding error. The provider name is cheap — one
|
|
1585
|
+
* `/channels` read, no ledger — and it is instantaneous: the moment it is wrong, the reader believes
|
|
1586
|
+
* their selection did not apply, which is exactly what happened.
|
|
1587
|
+
*
|
|
1588
|
+
* ⇒ Two facts, two costs, two cadences. Coupling them was the bug; unifying them would only move it.
|
|
1589
|
+
*
|
|
1590
|
+
* 📌 **Residual staleness: up to 15 seconds, and it is real.** Not "instant": say what is true. A
|
|
1591
|
+
* focus / tab-switch also triggers an immediate read, which covers the common "I just changed it,
|
|
1592
|
+
* let me look at the corner" path.
|
|
1593
|
+
*/
|
|
1594
|
+
const PROVIDER_REFRESH_MS = 15e3;
|
|
1595
|
+
/**
|
|
1576
1596
|
* The visible label, in words, so the number is not ambiguous.
|
|
1577
1597
|
*
|
|
1578
1598
|
* 🔴 Owner asked for this on 2026-11-01 ("显示的内容多几个字,注明是今日 token 消耗"): a bare
|
|
@@ -1636,12 +1656,9 @@ window.__ModuleLoader__.load({
|
|
|
1636
1656
|
const [day, setDay] = (0, react.useState)(() => localDayKey());
|
|
1637
1657
|
const [channels, setChannels] = (0, react.useState)(void 0);
|
|
1638
1658
|
const alive = (0, react.useRef)(true);
|
|
1639
|
-
/** One read of
|
|
1659
|
+
/** One read of the usage figure. Failures land in `failed`, never in `value`. */
|
|
1640
1660
|
const read = (0, react.useCallback)(async () => {
|
|
1641
1661
|
const today = localDayKey();
|
|
1642
|
-
loadChannels().then((response) => {
|
|
1643
|
-
if (alive.current) setChannels(response);
|
|
1644
|
-
}).catch(() => void 0);
|
|
1645
1662
|
try {
|
|
1646
1663
|
const stats = await loadToday();
|
|
1647
1664
|
if (!alive.current) return;
|
|
@@ -1658,18 +1675,60 @@ window.__ModuleLoader__.load({
|
|
|
1658
1675
|
if (!alive.current) return;
|
|
1659
1676
|
setFailed(true);
|
|
1660
1677
|
}
|
|
1661
|
-
}, [loadToday
|
|
1678
|
+
}, [loadToday]);
|
|
1679
|
+
/**
|
|
1680
|
+
* One read of the PROVIDER line, on its own faster cadence.
|
|
1681
|
+
*
|
|
1682
|
+
* 🔴 Split from {@link read} on 2026-11-18 (owner report). The two facts used to share one timer
|
|
1683
|
+
* and that is exactly how the sidebar came to name a supplier that had already been switched away
|
|
1684
|
+
* from: the selection is instantaneous, the usage figure is a daily cumulative.
|
|
1685
|
+
*
|
|
1686
|
+
* ⚠️ Its failure is swallowed on purpose: a missing channel list must not blank the usage figure
|
|
1687
|
+
* that did arrive (and vice versa — the two never overwrite each other's state).
|
|
1688
|
+
*/
|
|
1689
|
+
const readProvider = (0, react.useCallback)(async () => {
|
|
1690
|
+
try {
|
|
1691
|
+
const response = await loadChannels();
|
|
1692
|
+
if (alive.current) setChannels(response);
|
|
1693
|
+
} catch {}
|
|
1694
|
+
}, [loadChannels]);
|
|
1662
1695
|
(0, react.useEffect)(() => {
|
|
1663
1696
|
alive.current = true;
|
|
1664
1697
|
read();
|
|
1665
|
-
|
|
1698
|
+
readProvider();
|
|
1699
|
+
const usageTimer = setInterval(() => {
|
|
1666
1700
|
read();
|
|
1667
1701
|
}, USAGE_BADGE_REFRESH_MS);
|
|
1702
|
+
const providerTimer = setInterval(() => {
|
|
1703
|
+
readProvider();
|
|
1704
|
+
}, PROVIDER_REFRESH_MS);
|
|
1668
1705
|
return () => {
|
|
1669
1706
|
alive.current = false;
|
|
1670
|
-
clearInterval(
|
|
1707
|
+
clearInterval(usageTimer);
|
|
1708
|
+
clearInterval(providerTimer);
|
|
1709
|
+
};
|
|
1710
|
+
}, [read, readProvider]);
|
|
1711
|
+
/**
|
|
1712
|
+
* Re-read the provider the moment the tab regains attention.
|
|
1713
|
+
*
|
|
1714
|
+
* 📌 This is the path that actually covers the owner's workflow: switch the channel in Settings,
|
|
1715
|
+
* come back to the conversation, glance at the corner. Waiting up to 15 seconds for a timer would
|
|
1716
|
+
* still look like "the switch did not take" — the same misreading, just shorter.
|
|
1717
|
+
*
|
|
1718
|
+
* ⚠️ It refreshes the PROVIDER only. Re-reading the ledger on every focus would turn a cosmetic
|
|
1719
|
+
* seat into a file-reading poll driven by the user's tab switching.
|
|
1720
|
+
*/
|
|
1721
|
+
(0, react.useEffect)(() => {
|
|
1722
|
+
const onVisible = () => {
|
|
1723
|
+
if (document.visibilityState === "visible") readProvider();
|
|
1724
|
+
};
|
|
1725
|
+
document.addEventListener("visibilitychange", onVisible);
|
|
1726
|
+
window.addEventListener("focus", onVisible);
|
|
1727
|
+
return () => {
|
|
1728
|
+
document.removeEventListener("visibilitychange", onVisible);
|
|
1729
|
+
window.removeEventListener("focus", onVisible);
|
|
1671
1730
|
};
|
|
1672
|
-
}, [
|
|
1731
|
+
}, [readProvider]);
|
|
1673
1732
|
const state = badgeState(value, failed);
|
|
1674
1733
|
/**
|
|
1675
1734
|
* The provider line, or nothing.
|
|
@@ -1707,7 +1766,7 @@ window.__ModuleLoader__.load({
|
|
|
1707
1766
|
]
|
|
1708
1767
|
}), provider === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1709
1768
|
className: "ad-usageRow ad-providerRow",
|
|
1710
|
-
title: "
|
|
1769
|
+
title: "当前供应商(请求正在走的那个渠道)。最多 15 秒延迟;切换渠道后回到本窗口会立刻重读。",
|
|
1711
1770
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1712
1771
|
className: "ad-usageDot ad-providerDot",
|
|
1713
1772
|
"aria-hidden": "true"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-any-deepseek",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "One DeepSeek V4.1 Flash provider for DeepSeek Harness: paste a key per channel, switch channels manually, token usage booked per real upstream.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|