dsh-cliproxyapi-pro 1.10.0 → 1.11.0

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,6 +4,20 @@
4
4
 
5
5
  本插件的所有重要变更。版本号遵循[语义化版本](https://semver.org/lang/zh-CN/)。
6
6
 
7
+ ## 1.11.0 — 2026-11-12
8
+
9
+ ### 新增
10
+ - **侧边栏额度。** 左侧边栏底部(「设置」上方)新增「CPA 额度」一行:信号格汇总所有已启用、已填写管理密钥账号的凭证,右侧显示「充足 / 可用」凭证数,侧边栏收起时只显示信号格;点击后按账号列出凭证分布、每个凭证的额度窗口与重置时间,并可按账号刷新。使用 DSH 原生的 `sidebar.footer.action` 插槽,样式与原生底部按钮一致。「设置 → CLIProxyAPI」页面最上方新增所有账号共用的「在侧边栏显示额度」总开关(默认开启,保存在 `state.json` 的新全局字段 `sidebarQuota`),侧边栏额度弹层底部也可直接「从侧边栏隐藏」;关闭后侧边栏不显示,也不再为它读取额度状态。来自 [@Six6stRINgs](https://github.com/Six6stRINgs) 的建议(#2)。
11
+
12
+ ### 修复
13
+ - **额度详情和生成模型菜单滚动后不再丢失背景。** 凭据较多、弹层超过最大高度出现滚动条时,背景和毛玻璃原先画在随内容滚走的 `::before` 上,向下滚动后弹层变成透明;现在直接画在弹层本身上,和 DSH 原生可滚动弹层一致。感谢 [@Six6stRINgs](https://github.com/Six6stRINgs)(#3)。
14
+ - **同时出现的额度组件不再漏掉第一次数据。** 两个额度组件同时挂载时,先订阅的一个读到数据后,后一个可能在订阅前错过通知而一直不显示;现在订阅后会再核对一次快照。
15
+
16
+ ## 1.10.1 — 2026-11-12
17
+
18
+ ### 修复
19
+ - **输入框额度详情和生成模型菜单不再乱飘。** 新版 DSH 的输入框底座是 sticky 并带 `will-change: transform`,`position: fixed` 的弹层因此以输入框底座而不是视口为参照,原先按视口坐标计算的位置会偏到别处(常被右侧裁掉),并跟着输入框移动。现在弹层仍渲染在组件内部(不挂到 `document.body`),先在底座原点处隐藏测量,再把按钮的视口位置换算到这一层,保持在视口和聊天滚动区内,高度不超过按钮上方的空间,并在打开期间跟随按钮。问题由 [@CDeZT](https://github.com/CDeZT) 在 #4 / #5 报告。
20
+
7
21
  ## 1.10.0 — 2026-11-11
8
22
 
9
23
  ### 新增
package/README.en.md CHANGED
@@ -14,7 +14,7 @@ Enter a server URL and an API key, and the plugin reads the CPA model catalog an
14
14
  - **Works out of the box**: on the first connection, the newest model of each family in that server's own catalog is checked (at most 12), so the picker isn't flooded with hundreds of models. [Details](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/en/accounts-and-models.md)
15
15
  - **Native protocols**: Claude over Anthropic Messages, GPT / Codex / Grok over OpenAI Responses, everything else over OpenAI Chat — fewer protocol translations inside CPA. [Details](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/en/accounts-and-models.md)
16
16
  - **Visual management**: check models and edit per-model parameters in the settings panel. By default the plugin registers no agent tool, so it takes no model context (the optional generation tool `generate_media` is switched on in the Generation tab). [Details](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/en/accounts-and-models.md)
17
- - **Channel quota**: see each channel's remaining quota per credential, with a badge for the current model in the composer; failed queries pause automatic refresh. [Details](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/en/quota.md)
17
+ - **Channel quota**: see each channel's remaining quota per credential, with a badge for the current model in the composer and a quick view of every account in the sidebar footer; failed queries pause automatic refresh. [Details](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/en/quota.md)
18
18
  - **Images and videos**: generate and edit images, and generate, edit and extend videos through CPA; the optional agent generation tool is off by default. [Details](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/en/media.md)
19
19
  - **Plugin updates**: automatically check Stable / Beta / Dev channels and choose global / Mainland China sources. With the [DSH plugin market (dshmarket)](https://github.com/dsh-market/dsh-market) installed, new versions install in one click or automatically; otherwise download a verified offline package and upgrade with DSH closed. [Details](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/en/updates.md)
20
20
  - **Secure**: API keys live only in the DSH credentials service, never in configuration files. [Details](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/en/storage-and-config.md)
@@ -36,7 +36,7 @@ The plugin is published on npm as [`dsh-cliproxyapi-pro`](https://www.npmjs.com/
36
36
  dsh-cliproxyapi-pro
37
37
  ```
38
38
 
39
- To pin a version, write `dsh-cliproxyapi-pro@1.10.0`.
39
+ To pin a version, write `dsh-cliproxyapi-pro@1.11.0`.
40
40
  4. Click **Install**. When it finishes, the dialog offers to enable the plugin right away — accept it.
41
41
 
42
42
  > If downloads are slow in mainland China, open **Registry** next to the input and choose **the mainland China mirror**.
@@ -65,7 +65,7 @@ In **Add plugin**, or as the `plugin_manager` `target`, you can also enter:
65
65
 
66
66
  | Source | What to enter |
67
67
  |---|---|
68
- | A released version | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#v1.10.0` |
68
+ | A released version | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#v1.11.0` |
69
69
  | Latest development version | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#main` |
70
70
  | Offline package | Download [`dsh-cliproxyapi-pro.tgz`](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/releases/latest/download/dsh-cliproxyapi-pro.tgz) (always the latest release) and enter its absolute local path |
71
71
  | Local source (development) | Absolute path of a cloned repository; installed as a link, so code changes go live when the plugin reloads |
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  - **开箱即用**:首次连接时按该服务自己的模型目录,为每个模型家族勾选最新的一个(最多 12 个),模型选择器不会被上百个模型淹没。 [详解](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/zh/accounts-and-models.md)
15
15
  - **原生协议**:Claude 走 Anthropic Messages,GPT / Codex / Grok 走 OpenAI Responses,其余走 OpenAI Chat,减少 CPA 的协议转换。 [详解](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/zh/accounts-and-models.md)
16
16
  - **可视化管理**:设置面板里勾选模型、编辑单个模型的参数。默认不注册 Agent 工具,不占用模型上下文(可选的生成工具 `generate_media` 需在「生成」标签手动打开)。 [详解](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/zh/accounts-and-models.md)
17
- - **渠道额度**:按凭证查看各渠道的剩余额度,对话框里的徽标显示当前模型的额度;查询失败会暂停自动刷新。 [详解](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/zh/quota.md)
17
+ - **渠道额度**:按凭证查看各渠道的剩余额度,对话框里的徽标显示当前模型的额度,侧边栏底部可快速查看所有账号;查询失败会暂停自动刷新。 [详解](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/zh/quota.md)
18
18
  - **生图 / 生视频**:通过 CPA 生成和编辑图片,生成、编辑和延长视频;可选的 agent 生成工具默认关闭。 [详解](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/zh/media.md)
19
19
  - **插件更新**:自动检查稳定 / Beta / 开发通道,可选择全球 / 中国大陆下载源;装有 [DSH 插件市场(dshmarket)](https://github.com/dsh-market/dsh-market) 时可一键或自动安装新版本,否则下载校验离线包,在关闭 DSH 后手动升级。 [详解](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/zh/updates.md)
20
20
  - **安全**:API Key 只保存在 DSH 凭证服务里,不写入任何配置文件。 [详解](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/zh/storage-and-config.md)
@@ -36,7 +36,7 @@
36
36
  dsh-cliproxyapi-pro
37
37
  ```
38
38
 
39
- 需要固定版本时可以写成 `dsh-cliproxyapi-pro@1.10.0`。
39
+ 需要固定版本时可以写成 `dsh-cliproxyapi-pro@1.11.0`。
40
40
  4. 点击 **安装**,完成后点击 **立即启用**。
41
41
 
42
42
  > 在中国大陆下载慢,可以点输入框旁的 **安装源**,切换到 **中国大陆镜像源**。
@@ -65,7 +65,7 @@ dsh plugin --profile <profile 名称> add dsh-cliproxyapi-pro
65
65
 
66
66
  | 来源 | 填写内容 |
67
67
  |---|---|
68
- | 某个发布版本 | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#v1.10.0` |
68
+ | 某个发布版本 | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#v1.11.0` |
69
69
  | 最新开发版 | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#main` |
70
70
  | 离线安装包 | 下载 [`dsh-cliproxyapi-pro.tgz`](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/releases/latest/download/dsh-cliproxyapi-pro.tgz)(始终是最新版),填写它的本地绝对路径 |
71
71
  | 本地源码(开发用) | 克隆后的仓库目录绝对路径;以链接方式安装,改代码后重载插件即生效 |
package/lib/client.js CHANGED
@@ -253,7 +253,7 @@ window.__ModuleLoader__.load({
253
253
  tabSettings: "设置",
254
254
  tabQuota: "额度",
255
255
  qTitle: "CPA 渠道额度",
256
- qSubtitle: "填写管理密钥后,查看 CPA 上每个渠道凭证的剩余额度;对话框模型选择器旁也会显示当前模型的额度。",
256
+ qSubtitle: "填写管理密钥后,查看 CPA 上每个渠道凭证的剩余额度;对话框模型选择器旁也会显示当前模型的额度,左侧边栏底部可快速查看所有账号的额度。",
257
257
  qAccountsLabel: "选择账号",
258
258
  qNoAccounts: "还没有 CLIProxyAPI 账号,请先在「设置」页添加并连接。",
259
259
  qAccountDisabled: "账号未启用",
@@ -337,6 +337,15 @@ window.__ModuleLoader__.load({
337
337
  qPeekLoading: "正在读取额度…",
338
338
  qPeekFooter: "完整列表见 设置 → CLIProxyAPI → 额度",
339
339
  qPeekBest: "最充足",
340
+ qSideLabel: "CPA 额度",
341
+ qSideCount: "{ok}/{n} 充足",
342
+ qSideAria: "CPA 额度:{n} 个可用凭证中 {ok} 个充足",
343
+ qSideSwitch: "在侧边栏显示额度",
344
+ qSideSwitchHint: "所有账号共用。开启后左侧边栏底部显示「CPA 额度」,汇总所有已启用、已填写管理密钥账号的凭证;关闭后侧边栏不再显示,也不再为它读取额度状态。也可以在侧边栏额度弹层底部点「从侧边栏隐藏」。",
345
+ qSideHide: "从侧边栏隐藏",
346
+ qSideHideFailed: "隐藏失败:{error}",
347
+ qSideOnToast: "已在侧边栏显示额度",
348
+ qSideOffToast: "已从侧边栏隐藏额度",
340
349
  infoLabel: "说明",
341
350
  tabConnection: "连接",
342
351
  tabModels: "模型",
@@ -787,7 +796,7 @@ window.__ModuleLoader__.load({
787
796
  tabSettings: "Settings",
788
797
  tabQuota: "Quota",
789
798
  qTitle: "CPA Channel Quota",
790
- qSubtitle: "With a management key, see the remaining quota of every channel credential on CPA; the composer also shows the current model's quota next to the model picker.",
799
+ qSubtitle: "With a management key, see the remaining quota of every channel credential on CPA; the composer also shows the current model's quota next to the model picker, and the sidebar footer gives a quick view of every account.",
791
800
  qAccountsLabel: "Choose account",
792
801
  qNoAccounts: "No CLIProxyAPI account yet. Add and connect one on the Settings tab first.",
793
802
  qAccountDisabled: "Account disabled",
@@ -871,6 +880,15 @@ window.__ModuleLoader__.load({
871
880
  qPeekLoading: "Loading quota…",
872
881
  qPeekFooter: "Full list in Settings → CLIProxyAPI → Quota",
873
882
  qPeekBest: "Best",
883
+ qSideLabel: "CPA Quota",
884
+ qSideCount: "{ok}/{n} healthy",
885
+ qSideAria: "CPA quota: {ok} of {n} usable credentials healthy",
886
+ qSideSwitch: "Show quota in the sidebar",
887
+ qSideSwitchHint: "Shared by all accounts. When on, the bottom of the left sidebar shows CPA Quota, summing up the credentials of every enabled account with a management key; when off, the sidebar shows nothing and stops reading quota status for it. You can also click Hide from sidebar at the bottom of the sidebar quota peek.",
888
+ qSideHide: "Hide from sidebar",
889
+ qSideHideFailed: "Could not hide: {error}",
890
+ qSideOnToast: "Quota shown in the sidebar",
891
+ qSideOffToast: "Quota hidden from the sidebar",
874
892
  infoLabel: "More info",
875
893
  tabConnection: "Connection",
876
894
  tabModels: "Models",
@@ -2432,21 +2450,13 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
2432
2450
  border-radius: var(--dsw-radius-lg, 12px);
2433
2451
  --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);
2434
2452
  box-shadow: var(--dsw-elevation-prominent, 0 8px 24px var(--dsw-alias-border-l2));
2453
+ background: var(--dsw-menu-surface-fill, var(--dsw-alias-bg-layer-1));
2454
+ backdrop-filter: var(--dsw-menu-backdrop-filter, none);
2435
2455
  color: var(--dsw-alias-label-primary);
2436
2456
  font-size: 13px;
2437
2457
  line-height: 20px;
2438
2458
  text-align: left;
2439
2459
  }
2440
- .dcpa-q-pop::before {
2441
- content: "";
2442
- position: absolute;
2443
- inset: 0;
2444
- z-index: -1;
2445
- border-radius: inherit;
2446
- background: var(--dsw-menu-surface-fill, var(--dsw-alias-bg-layer-1));
2447
- backdrop-filter: var(--dsw-menu-backdrop-filter, none);
2448
- pointer-events: none;
2449
- }
2450
2460
  .dcpa-q-pop-head { padding: 8px 8px 6px; }
2451
2461
  .dcpa-q-pop-model { font-weight: 500; overflow-wrap: anywhere; }
2452
2462
  .dcpa-q-pop-sub { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); }
@@ -2476,7 +2486,48 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
2476
2486
  font-size: 12px;
2477
2487
  color: var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary));
2478
2488
  }
2479
- `;
2489
+
2490
+ /* ---- Sidebar footer entry: same metrics as DSH's native footer buttons ---- */
2491
+ .dcpa-q-side { display: flex; align-items: center; width: 100%; min-width: 0; }
2492
+ .dcpa-q-side[data-wide="false"] { width: 36px; height: 36px; }
2493
+ .dcpa-q-side-btn {
2494
+ box-sizing: border-box;
2495
+ display: inline-flex;
2496
+ align-items: center;
2497
+ gap: 8px;
2498
+ width: calc(100% + 4px);
2499
+ height: 42px;
2500
+ margin: 0 -2px;
2501
+ padding: 0 10px 0 8px;
2502
+ border: none;
2503
+ border-radius: var(--dsw-radius-lg, 12px);
2504
+ background: transparent;
2505
+ color: var(--dsw-alias-label-primary);
2506
+ font: inherit;
2507
+ font-size: 14px;
2508
+ cursor: pointer;
2509
+ overflow: hidden;
2510
+ }
2511
+ .dcpa-q-side-btn:hover, .dcpa-q-side-btn[aria-expanded="true"] {
2512
+ background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-2));
2513
+ }
2514
+ .dcpa-q-side[data-wide="false"] .dcpa-q-side-btn { width: 36px; height: 36px; margin: 0; padding: 0; gap: 0; justify-content: center; border-radius: 50%; }
2515
+ .dcpa-q-side-btn .dcpa-q-bars { flex: none; justify-content: center; width: 16px; }
2516
+ .dcpa-q-side-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2517
+ .dcpa-q-side-count {
2518
+ flex: none;
2519
+ margin-left: auto;
2520
+ font-size: 12px;
2521
+ line-height: 16px;
2522
+ color: var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary));
2523
+ font-variant-numeric: tabular-nums;
2524
+ }
2525
+ .dcpa-q-side-count[data-level="low"] { color: var(--dsw-alias-state-warn-primary); }
2526
+ .dcpa-q-side-count[data-level="empty"] { color: var(--dsw-alias-state-error-primary); }
2527
+ .dcpa-q-side-acct + .dcpa-q-side-acct { margin-top: 8px; }
2528
+ .dcpa-q-side-pop .dcpa-q-summary { padding: 0 8px 4px; }
2529
+ .dcpa-q-side-pop .dcpa-q-side-hint { padding-top: 6px; }
2530
+ .dcpa-q-side-foot { margin-top: 8px; }`;
2480
2531
 
2481
2532
  const REASONING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
2482
2533
  const PROTOCOL_NAME_KEYS = {
@@ -3454,7 +3505,8 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
3454
3505
  }
3455
3506
 
3456
3507
  /**
3457
- * The CLIProxyAPI settings section: one account bar for every tab, then the
3508
+ * The CLIProxyAPI settings section: the all-account sidebar-quota switch,
3509
+ * one account bar for every tab, then the
3458
3510
  * selected account's header, its 连接 / 模型 / 额度 tabs and one save bar.
3459
3511
  * Owns the account server data; the add-account form creates an account only
3460
3512
  * when the user connects it.
@@ -3548,6 +3600,7 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
3548
3600
  run("patch", async () => {
3549
3601
  setData(await postJson(API.save, { ...patch, accountId }));
3550
3602
  if (okText) setNotice({ tone: "ok", text: okText });
3603
+ return true;
3551
3604
  }),
3552
3605
  test: (accountId, draft) =>
3553
3606
  run("test", async () => (await postJson(API.testAccount, { ...(accountId ? { accountId } : {}), ...draft })).test),
@@ -3585,11 +3638,31 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
3585
3638
  }),
3586
3639
  };
3587
3640
 
3641
+ // The sidebar peek's "hide" button (or this switch) changed the global:
3642
+ // follow it here without reloading the drafts.
3643
+ useEffect(() => {
3644
+ const listener = (on) =>
3645
+ setData((d) => (d && d.global?.sidebarQuota !== on ? { ...d, global: { ...d.global, sidebarQuota: on } } : d));
3646
+ sidebarQuotaListeners.add(listener);
3647
+ return () => {
3648
+ sidebarQuotaListeners.delete(listener);
3649
+ };
3650
+ }, []);
3651
+ const toggleSidebarQuota = (next) =>
3652
+ void run("patch", async () => {
3653
+ setData(await saveSidebarQuota(next));
3654
+ setNotice({ tone: "ok", text: next ? t("qSideOnToast") : t("qSideOffToast") });
3655
+ });
3656
+
3588
3657
  const showAdd = adding || (!loading && data !== null && accounts.length === 0);
3589
3658
 
3590
3659
  return h(
3591
3660
  "div",
3592
3661
  { className: "dcpa-wrap dcpa-q", "data-dsh-plugin": MODULE_ID },
3662
+ // All-account settings that are not part of any account draft.
3663
+ data !== null
3664
+ ? h(SidebarQuotaSwitch, { t, on: data.global?.sidebarQuota !== false, busy: busy !== null, onToggle: toggleSidebarQuota })
3665
+ : null,
3593
3666
  h(
3594
3667
  "div",
3595
3668
  { className: "dcpa-acct-bar" },
@@ -5760,18 +5833,24 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5760
5833
  /** Subscribe a component to the shared quota store (null when inactive). */
5761
5834
  function useQuota(store) {
5762
5835
  const [, setTick] = useState(0);
5836
+ const snapshot = store ? store.getSnapshot() : { data: null, loading: false, error: null, busy: null };
5837
+ // The snapshot this render used: another subscriber's load can finish
5838
+ // between this render and the effect below, without notifying us.
5839
+ const rendered = useRef(snapshot);
5840
+ rendered.current = snapshot;
5763
5841
  useEffect(() => {
5764
5842
  if (store === null || store === undefined) return undefined;
5765
5843
  let alive = true;
5766
5844
  const off = store.subscribe(() => {
5767
5845
  if (alive) setTick((n) => n + 1);
5768
5846
  });
5847
+ if (store.getSnapshot() !== rendered.current) setTick((n) => n + 1);
5769
5848
  return () => {
5770
5849
  alive = false;
5771
5850
  off();
5772
5851
  };
5773
5852
  }, [store]);
5774
- return store ? store.getSnapshot() : { data: null, loading: false, error: null, busy: null };
5853
+ return snapshot;
5775
5854
  }
5776
5855
 
5777
5856
  /**
@@ -5822,6 +5901,16 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5822
5901
  } catch {}
5823
5902
  }
5824
5903
  };
5904
+ // The Quota tab's sidebar switch tells the sidebar entry on this page
5905
+ // (which stops reading quota status while switched off).
5906
+ const sidebarQuotaListeners = new Set();
5907
+ const announceSidebarQuota = (on) => {
5908
+ for (const fn of [...sidebarQuotaListeners]) {
5909
+ try {
5910
+ fn(on === true);
5911
+ } catch {}
5912
+ }
5913
+ };
5825
5914
 
5826
5915
  /**
5827
5916
  * Composer placement announces itself for its session; hero placement
@@ -5897,6 +5986,175 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5897
5986
  return now;
5898
5987
  }
5899
5988
 
5989
+ /*
5990
+ * The composer peeks (`.dcpa-q-pop`, `position: fixed`) stay inside their
5991
+ * component: no portal, nothing appended to document.body. DSH's active
5992
+ * composer seat is sticky and carries `will-change: transform`, which makes
5993
+ * it the containing block of fixed descendants, so `left` / `bottom` count
5994
+ * from the seat, not the viewport. Plain viewport coordinates put the peek
5995
+ * somewhere else and let it drift with the composer.
5996
+ *
5997
+ * Each placement measures where the rendered peek actually landed, derives
5998
+ * the containing block's left and bottom edges from the offsets it applied,
5999
+ * and converts the wanted viewport position into that box. Ancestors from
6000
+ * the containing block upward that clip overflow (the chat scroller) bound
6001
+ * the peek together with the viewport. Without such a box the result equals
6002
+ * plain viewport placement.
6003
+ */
6004
+ const PEEK_WIDTH = 340;
6005
+ const PEEK_MIN_WIDTH = 160;
6006
+ const PEEK_GAP = 6;
6007
+ const PEEK_MARGIN = 16;
6008
+ const PEEK_MAX_HEIGHT = 440;
6009
+ const PEEK_MIN_HEIGHT = 120;
6010
+ // Measured once on open at the containing block origin, then shown.
6011
+ const PEEK_HIDDEN = Object.freeze({ visibility: "hidden", left: "0px", bottom: "0px" });
6012
+
6013
+ /**
6014
+ * Pure placement. `anchor` and `box` are viewport rects of the anchor and of
6015
+ * the peek as rendered with `applied` `{ left, bottom }` offsets; `bounds`
6016
+ * is the visible area `{ left, top, right, bottom }` in viewport coordinates.
6017
+ * Returns offsets in the peek's own containing block.
6018
+ */
6019
+ function placePeek({ anchor, box, applied, bounds }) {
6020
+ const originLeft = box.left - applied.left;
6021
+ const originBottom = box.bottom + applied.bottom;
6022
+ const room = bounds.right - bounds.left - 2 * PEEK_MARGIN;
6023
+ const width = Math.min(PEEK_WIDTH, Math.max(PEEK_MIN_WIDTH, room));
6024
+ const left = Math.max(bounds.left + PEEK_MARGIN, Math.min(anchor.left, bounds.right - width - PEEK_MARGIN));
6025
+ const edge = anchor.top - PEEK_GAP;
6026
+ const maxHeight = Math.max(PEEK_MIN_HEIGHT, Math.min(PEEK_MAX_HEIGHT, edge - bounds.top - PEEK_MARGIN));
6027
+ return {
6028
+ left: Math.round(left - originLeft),
6029
+ bottom: Math.round(originBottom - edge),
6030
+ width: Math.round(width),
6031
+ maxHeight: Math.round(maxHeight),
6032
+ };
6033
+ }
6034
+
6035
+ const samePeek = (a, b) =>
6036
+ !!a && !!b && a.left === b.left && a.bottom === b.bottom && a.width === b.width && a.maxHeight === b.maxHeight;
6037
+
6038
+ /** Nearest ancestor that becomes the containing block of fixed descendants. */
6039
+ function fixedContainer(el) {
6040
+ const root = el?.ownerDocument?.documentElement ?? null;
6041
+ for (let node = el?.parentElement ?? null; node && node !== root; node = node.parentElement) {
6042
+ const s = getComputedStyle(node);
6043
+ if (
6044
+ (s.transform && s.transform !== "none") ||
6045
+ (s.perspective && s.perspective !== "none") ||
6046
+ (s.filter && s.filter !== "none") ||
6047
+ (s.backdropFilter && s.backdropFilter !== "none") ||
6048
+ /transform|perspective|filter/.test(s.willChange ?? "") ||
6049
+ /paint|layout|strict|content/.test(s.contain ?? "") ||
6050
+ (s.containerType && s.containerType !== "normal")
6051
+ ) {
6052
+ return node;
6053
+ }
6054
+ }
6055
+ return null;
6056
+ }
6057
+
6058
+ /** The containing block and its ancestors that clip a fixed peek. */
6059
+ function peekClips(pop) {
6060
+ const container = fixedContainer(pop);
6061
+ if (!container) return [];
6062
+ const root = pop.ownerDocument?.documentElement ?? null;
6063
+ const clips = [];
6064
+ for (let node = container; node && node !== root; node = node.parentElement) {
6065
+ const s = getComputedStyle(node);
6066
+ if (s.overflowX !== "visible" || s.overflowY !== "visible" || /paint|strict|content/.test(s.contain ?? "")) clips.push(node);
6067
+ }
6068
+ return clips;
6069
+ }
6070
+
6071
+ function peekBounds(clips) {
6072
+ const bounds = { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight };
6073
+ for (const node of clips) {
6074
+ const r = node.getBoundingClientRect();
6075
+ if (r.width === 0 && r.height === 0) continue;
6076
+ bounds.left = Math.max(bounds.left, r.left);
6077
+ bounds.top = Math.max(bounds.top, r.top);
6078
+ bounds.right = Math.min(bounds.right, r.right);
6079
+ bounds.bottom = Math.min(bounds.bottom, r.bottom);
6080
+ }
6081
+ return bounds;
6082
+ }
6083
+
6084
+ /**
6085
+ * Close an open peek on a press outside `wrapRef` (the peek renders inside
6086
+ * it) or on Escape, which returns focus to `buttonRef`.
6087
+ */
6088
+ function useDismissPeek(open, wrapRef, buttonRef, close) {
6089
+ const closeRef = useRef(close);
6090
+ closeRef.current = close;
6091
+ useEffect(() => {
6092
+ if (!open || typeof document === "undefined") return undefined;
6093
+ const onDown = (e) => {
6094
+ if (wrapRef.current && !wrapRef.current.contains(e.target)) closeRef.current();
6095
+ };
6096
+ const onKey = (e) => {
6097
+ if (e.key === "Escape") {
6098
+ closeRef.current();
6099
+ buttonRef.current?.focus?.();
6100
+ }
6101
+ };
6102
+ document.addEventListener("mousedown", onDown, true);
6103
+ document.addEventListener("keydown", onKey, true);
6104
+ return () => {
6105
+ document.removeEventListener("mousedown", onDown, true);
6106
+ document.removeEventListener("keydown", onKey, true);
6107
+ };
6108
+ }, [open]);
6109
+ }
6110
+
6111
+ /**
6112
+ * Style for a fixed peek anchored above `anchorRef`, rendered with
6113
+ * `ref: popRef` inside the same component. Tracks the anchor every frame
6114
+ * while open (state changes only when the placement moves) and stays
6115
+ * hidden until the first measurement.
6116
+ */
6117
+ function useAnchoredPeek(open, anchorRef, popRef) {
6118
+ const [pos, setPos] = useState(null);
6119
+ useEffect(() => {
6120
+ if (!open) {
6121
+ setPos(null);
6122
+ return undefined;
6123
+ }
6124
+ if (typeof window === "undefined" || typeof getComputedStyle !== "function") return undefined;
6125
+ let clips = null;
6126
+ let frame = 0;
6127
+ const place = () => {
6128
+ const anchor = anchorRef.current?.getBoundingClientRect?.();
6129
+ const pop = popRef.current;
6130
+ const box = pop?.getBoundingClientRect?.();
6131
+ if (!anchor || !box || (anchor.width === 0 && anchor.height === 0)) return;
6132
+ clips ??= peekClips(pop);
6133
+ const applied = { left: parseFloat(pop.style.left) || 0, bottom: parseFloat(pop.style.bottom) || 0 };
6134
+ const next = placePeek({ anchor, box, applied, bounds: peekBounds(clips) });
6135
+ setPos((prev) => (samePeek(prev, next) ? prev : next));
6136
+ };
6137
+ const onResize = () => {
6138
+ clips = null;
6139
+ place();
6140
+ };
6141
+ const raf = typeof window.requestAnimationFrame === "function" ? window.requestAnimationFrame.bind(window) : null;
6142
+ const loop = () => {
6143
+ place();
6144
+ frame = raf(loop);
6145
+ };
6146
+ place();
6147
+ if (raf) frame = raf(loop);
6148
+ window.addEventListener("resize", onResize);
6149
+ return () => {
6150
+ if (raf && frame) window.cancelAnimationFrame?.(frame);
6151
+ window.removeEventListener("resize", onResize);
6152
+ };
6153
+ }, [open]);
6154
+ if (!open || !pos) return PEEK_HIDDEN;
6155
+ return { left: `${pos.left}px`, bottom: `${pos.bottom}px`, width: `${pos.width}px`, maxHeight: `${pos.maxHeight}px` };
6156
+ }
6157
+
5900
6158
  function QuotaMeter({ t, w, now }) {
5901
6159
  const pct = typeof w.remainingPercent === "number" ? Math.max(0, Math.min(100, w.remainingPercent)) : null;
5902
6160
  const level = quotaLevel(pct);
@@ -6352,41 +6610,15 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6352
6610
  const snap = useQuota(selection ? store : null);
6353
6611
  const now = useNow(60 * 1000);
6354
6612
  const [open, setOpen] = useState(false);
6355
- const [pos, setPos] = useState(null);
6356
6613
  const wrapRef = useRef(null);
6357
6614
  const buttonRef = useRef(null);
6615
+ const popRef = useRef(null);
6616
+ const popStyle = useAnchoredPeek(open, buttonRef, popRef);
6358
6617
 
6359
6618
  const summary = selection ? summarizeModelQuota(snap.data, selection.provider, selection.model) : null;
6360
6619
  const visible = !shadowed && summary !== null && summary.account.keyConfigured === true;
6361
6620
 
6362
- useEffect(() => {
6363
- if (!open) return undefined;
6364
- const place = () => {
6365
- const rect = buttonRef.current?.getBoundingClientRect?.();
6366
- if (!rect || typeof window === "undefined") return;
6367
- const width = Math.min(340, window.innerWidth - 32);
6368
- const left = Math.max(16, Math.min(rect.left, window.innerWidth - width - 16));
6369
- setPos({ left, bottom: Math.max(16, window.innerHeight - rect.top + 6), width });
6370
- };
6371
- place();
6372
- const onDown = (e) => {
6373
- if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
6374
- };
6375
- const onKey = (e) => {
6376
- if (e.key === "Escape") {
6377
- setOpen(false);
6378
- buttonRef.current?.focus?.();
6379
- }
6380
- };
6381
- document.addEventListener("mousedown", onDown, true);
6382
- document.addEventListener("keydown", onKey, true);
6383
- window.addEventListener("resize", place);
6384
- return () => {
6385
- document.removeEventListener("mousedown", onDown, true);
6386
- document.removeEventListener("keydown", onKey, true);
6387
- window.removeEventListener("resize", place);
6388
- };
6389
- }, [open]);
6621
+ useDismissPeek(open, wrapRef, buttonRef, () => setOpen(false));
6390
6622
 
6391
6623
  useEffect(() => {
6392
6624
  if (!visible && open) setOpen(false);
@@ -6404,10 +6636,11 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6404
6636
  ? h(
6405
6637
  "div",
6406
6638
  {
6639
+ ref: popRef,
6407
6640
  className: "dcpa-q-pop",
6408
6641
  role: "dialog",
6409
6642
  "aria-label": label,
6410
- style: pos ? { left: `${pos.left}px`, bottom: `${pos.bottom}px`, width: `${pos.width}px` } : { visibility: "hidden" },
6643
+ style: popStyle,
6411
6644
  },
6412
6645
  h(
6413
6646
  "div",
@@ -6480,6 +6713,244 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6480
6713
 
6481
6714
  // #endregion
6482
6715
 
6716
+ /** Accounts the sidebar summarizes: enabled, with a management key. */
6717
+ function sidebarQuotaAccounts(data) {
6718
+ const accounts = Array.isArray(data?.accounts) ? data.accounts : [];
6719
+ return accounts.filter((a) => a.keyConfigured === true && a.enabled !== false);
6720
+ }
6721
+
6722
+ /**
6723
+ * Totals over the credentials of those accounts. `usable` leaves out
6724
+ * disabled / failing credentials; the level is the signal-bar fill.
6725
+ */
6726
+ function sidebarQuotaSummary(accounts) {
6727
+ const credentials = accounts.flatMap((a) => (Array.isArray(a.credentials) ? a.credentials : []));
6728
+ const stats = quotaStats(credentials);
6729
+ const usable = stats.total - stats.issue;
6730
+ let level = "unknown";
6731
+ if (stats.healthy > 0) level = stats.healthy * 2 >= usable ? "ok" : "mid";
6732
+ else if (stats.low > 0) level = "low";
6733
+ else if (stats.empty > 0) level = "empty";
6734
+ const loading = accounts.every((a) => a.fetchedAt === undefined && a.errorCode === undefined);
6735
+ return { stats, usable, level, loading };
6736
+ }
6737
+
6738
+ /**
6739
+ * Save the global `sidebarQuota` switch (a globals-only save leaves every
6740
+ * account alone) and tell this page's sidebar entry and settings section.
6741
+ */
6742
+ async function saveSidebarQuota(on) {
6743
+ const body = await postJson(API.save, { sidebarQuota: on === true });
6744
+ announceSidebarQuota(body?.global?.sidebarQuota !== false);
6745
+ return body;
6746
+ }
6747
+
6748
+ /**
6749
+ * The all-account switch at the top of the CLIProxyAPI settings section
6750
+ * (the sidebar peek also has a "hide" button for the same setting).
6751
+ */
6752
+ function SidebarQuotaSwitch({ t, on, busy, onToggle }) {
6753
+ return h(
6754
+ "div",
6755
+ { className: "dcpa-q-row dcpa-q-side-switch" },
6756
+ h(
6757
+ "div",
6758
+ { className: "dcpa-q-row-main" },
6759
+ h("div", { className: "dcpa-q-title" }, t("qSideSwitch"), h(InfoTip, { t, text: t("qSideSwitchHint") }))
6760
+ ),
6761
+ h(
6762
+ "div",
6763
+ { className: "dcpa-q-actions" },
6764
+ h(
6765
+ "button",
6766
+ {
6767
+ type: "button",
6768
+ role: "switch",
6769
+ className: "dcpa-switch",
6770
+ "aria-checked": on,
6771
+ "aria-label": t("qSideSwitch"),
6772
+ disabled: busy,
6773
+ onClick: () => onToggle(!on),
6774
+ },
6775
+ h("span", { className: "dcpa-switch-thumb" })
6776
+ )
6777
+ )
6778
+ );
6779
+ }
6780
+
6781
+ /** Problems last, then least remaining first, like the Quota tab. */
6782
+ function sidebarCredentialOrder(a, b) {
6783
+ const rank = (c) => (c.status !== "active" ? 1 : 0);
6784
+ return rank(a) - rank(b) || (credentialHeadroom(a) ?? 101) - (credentialHeadroom(b) ?? 101);
6785
+ }
6786
+
6787
+ function SidebarQuotaAccount({ t, account, snap, store, now }) {
6788
+ const credentials = Array.isArray(account.credentials) ? [...account.credentials].sort(sidebarCredentialOrder) : [];
6789
+ const errorText = quotaErrorText(t, account);
6790
+ const refreshing = account.refreshing === true || (snap.busy === "refresh" && snap.busyAccount === account.accountId);
6791
+ const loadingFirst = account.fetchedAt === undefined && errorText === null;
6792
+ return h(
6793
+ "section",
6794
+ { className: "dcpa-q-side-acct", "aria-label": account.displayName || account.accountId },
6795
+ h(
6796
+ "div",
6797
+ { className: "dcpa-q-pop-head" },
6798
+ h("div", { className: "dcpa-q-pop-model" }, account.displayName || account.accountId),
6799
+ h("div", { className: "dcpa-q-pop-sub" }, fmt(t, "qTotalCreds", { n: credentials.length }))
6800
+ ),
6801
+ errorText ? h("p", { className: "dcpa-q-pop-text", "data-tone": "error" }, errorText) : null,
6802
+ loadingFirst ? h("p", { className: "dcpa-q-pop-text" }, t("qPeekLoading")) : null,
6803
+ !loadingFirst && credentials.length === 0 && account.state === "ok" ? h("p", { className: "dcpa-q-pop-text" }, t("qNoCredentials")) : null,
6804
+ credentials.length > 0 ? h(QuotaSummary, { t, credentials }) : null,
6805
+ credentials.map((cred) =>
6806
+ h(
6807
+ "div",
6808
+ { key: cred.id, className: "dcpa-q-pop-cred" },
6809
+ h(
6810
+ "div",
6811
+ { className: "dcpa-q-pop-who" },
6812
+ h("span", { className: "dcpa-q-tag" }, providerName(t, cred.provider)),
6813
+ h("span", { className: "dcpa-q-name", title: cred.label || cred.id }, cred.label || cred.id),
6814
+ CredentialTags({ t, cred })
6815
+ ),
6816
+ h(CredentialWindows, { t, cred, windows: credentialWindows(cred), now })
6817
+ )
6818
+ ),
6819
+ h(
6820
+ "div",
6821
+ { className: "dcpa-q-pop-foot" },
6822
+ h("span", null,
6823
+ account.fetchedAt ? fmt(t, "qUpdated", { time: agoText(t, account.fetchedAt, now) }) : t("qNeverUpdated"),
6824
+ account.autoRefreshPaused === true ? ` · ${t("qAccountPaused")}` : ""),
6825
+ h(
6826
+ "button",
6827
+ {
6828
+ type: "button",
6829
+ className: "dcpa-q-btn",
6830
+ disabled: snap.busy !== null || refreshing,
6831
+ onClick: () => void store?.refresh(account.accountId),
6832
+ },
6833
+ refreshing ? t("qRefreshing") : t("qRefresh")
6834
+ )
6835
+ )
6836
+ );
6837
+ }
6838
+
6839
+ /**
6840
+ * `sidebar.footer.action`: signal bars for the credentials of every enabled
6841
+ * account with a management key (label and healthy count while the
6842
+ * sidebar is wide); click opens a peek listing them per account. Renders
6843
+ * nothing until such an account exists. Same shared store as the badge.
6844
+ *
6845
+ * The global `sidebarQuota` switch arrives as `sidebar` in the quota
6846
+ * snapshot. Once it reads off, the entry unsubscribes, so it adds no
6847
+ * status polling; the Quota tab's switch on this page announces changes
6848
+ * (an in-page answer then wins over the last snapshot).
6849
+ */
6850
+ function SidebarQuota({ t, wide = true, store = sharedQuota }) {
6851
+ // null = follow the snapshot; true / false = switched on this page.
6852
+ const [override, setOverride] = useState(null);
6853
+ const [seenOff, setSeenOff] = useState(false);
6854
+ const off = override === null ? seenOff : !override;
6855
+ const snap = useQuota(off ? null : store);
6856
+ const now = useNow(60 * 1000);
6857
+ const [open, setOpen] = useState(false);
6858
+ const [hiding, setHiding] = useState(false);
6859
+ const [hideError, setHideError] = useState(null);
6860
+ const wrapRef = useRef(null);
6861
+ const buttonRef = useRef(null);
6862
+ const popRef = useRef(null);
6863
+ const mounted = useRef(true);
6864
+ const popStyle = useAnchoredPeek(open, buttonRef, popRef);
6865
+ const flagOff = override === null && snap.data?.sidebar === false;
6866
+ const accounts = sidebarQuotaAccounts(snap.data);
6867
+ const visible = !off && !flagOff && store !== null && store !== undefined && accounts.length > 0;
6868
+
6869
+ useEffect(() => {
6870
+ const listener = (on) => {
6871
+ setOverride(on);
6872
+ if (on) void store?.load?.();
6873
+ };
6874
+ sidebarQuotaListeners.add(listener);
6875
+ return () => {
6876
+ sidebarQuotaListeners.delete(listener);
6877
+ };
6878
+ }, [store]);
6879
+
6880
+ useEffect(() => {
6881
+ if (flagOff) setSeenOff(true);
6882
+ }, [flagOff]);
6883
+
6884
+ useEffect(() => {
6885
+ mounted.current = true;
6886
+ return () => {
6887
+ mounted.current = false;
6888
+ };
6889
+ }, []);
6890
+
6891
+ // Turn the global switch off from the peek itself; the Settings switch
6892
+ // brings the entry back.
6893
+ const hide = async () => {
6894
+ setHiding(true);
6895
+ setHideError(null);
6896
+ try {
6897
+ await saveSidebarQuota(false);
6898
+ } catch (error) {
6899
+ if (mounted.current) setHideError(error instanceof Error ? error.message : String(error));
6900
+ } finally {
6901
+ if (mounted.current) setHiding(false);
6902
+ }
6903
+ };
6904
+ useDismissPeek(open, wrapRef, buttonRef, () => setOpen(false));
6905
+
6906
+ useEffect(() => {
6907
+ if (!visible && open) setOpen(false);
6908
+ }, [visible, open]);
6909
+
6910
+ if (!visible) return null;
6911
+ const { stats, usable, level, loading } = sidebarQuotaSummary(accounts);
6912
+ const count = loading ? "…" : fmt(t, "qSideCount", { ok: stats.healthy, n: usable });
6913
+ const label = loading ? t("qSideLabel") : fmt(t, "qSideAria", { ok: stats.healthy, n: usable });
6914
+
6915
+ const peek = open
6916
+ ? h(
6917
+ "div",
6918
+ { ref: popRef, className: "dcpa-q-pop dcpa-q-side-pop", role: "dialog", "aria-label": t("qSideLabel"), style: popStyle },
6919
+ accounts.map((account) => h(SidebarQuotaAccount, { key: account.accountId, t, account, snap, store, now })),
6920
+ snap.error ? h("p", { className: "dcpa-q-pop-text", "data-tone": "error" }, fmt(t, "qErrLoad", { error: snap.error })) : null,
6921
+ hideError ? h("p", { className: "dcpa-q-pop-text", "data-tone": "error", role: "alert" }, fmt(t, "qSideHideFailed", { error: hideError })) : null,
6922
+ h(
6923
+ "div",
6924
+ { className: "dcpa-q-pop-foot dcpa-q-side-foot" },
6925
+ h("span", null, t("qPeekFooter")),
6926
+ h("button", { type: "button", className: "dcpa-q-btn", disabled: hiding, onClick: () => void hide() }, t("qSideHide"))
6927
+ )
6928
+ )
6929
+ : null;
6930
+
6931
+ return h(
6932
+ "div",
6933
+ { ref: wrapRef, className: "dcpa-q-side", "data-wide": wide ? "true" : "false", "data-dsh-plugin": MODULE_ID },
6934
+ h(
6935
+ "button",
6936
+ {
6937
+ ref: buttonRef,
6938
+ type: "button",
6939
+ className: "dcpa-q-side-btn",
6940
+ "aria-label": label,
6941
+ "aria-haspopup": "dialog",
6942
+ "aria-expanded": open,
6943
+ title: wide ? undefined : label,
6944
+ onClick: () => setOpen((v) => !v),
6945
+ },
6946
+ h("span", { className: "dcpa-q-bars", "data-level": loading ? "unknown" : level, "aria-hidden": "true" }, h("i"), h("i"), h("i")),
6947
+ wide ? h("span", { className: "dcpa-q-side-label" }, t("qSideLabel")) : null,
6948
+ wide ? h("span", { className: "dcpa-q-side-count", "data-level": loading ? "unknown" : level }, count) : null
6949
+ ),
6950
+ peek
6951
+ );
6952
+ }
6953
+
6483
6954
  // #region Generation-model button (composer / hero)
6484
6955
 
6485
6956
  function mediaFileURL(sessionId, id) {
@@ -6535,7 +7006,6 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6535
7006
  const [loading, setLoading] = useState(true);
6536
7007
  // Which kind's model menu is open (image / video), or null.
6537
7008
  const [openKind, setOpenKind] = useState(null);
6538
- const [pos, setPos] = useState(null);
6539
7009
  const [busy, setBusy] = useState(false);
6540
7010
  const [error, setError] = useState(null);
6541
7011
  // Bumped to reload while no image model is known yet.
@@ -6545,6 +7015,10 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6545
7015
  const wrapRef = useRef(null);
6546
7016
  const buttonRef = useRef(null);
6547
7017
  const mounted = useRef(true);
7018
+ const popRef = useRef(null);
7019
+ // Anchor the menu to the whole two-button group; it sits left of the
7020
+ // model selector either way.
7021
+ const popStyle = useAnchoredPeek(openKind !== null, wrapRef, popRef);
6548
7022
  const shadowed = useBadgePlacement(placement, sessionId, presence);
6549
7023
  // Icon-only buttons while the composer row is narrow (names move to aria-label).
6550
7024
  const [compact, setCompact] = useState(false);
@@ -6625,16 +7099,6 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6625
7099
 
6626
7100
  useEffect(() => {
6627
7101
  if (openKind === null) return undefined;
6628
- const place = () => {
6629
- // Anchor the menu to the whole two-button group; it sits left of the
6630
- // model selector either way.
6631
- const rect = wrapRef.current?.getBoundingClientRect?.();
6632
- if (!rect || typeof window === "undefined") return;
6633
- const width = Math.min(340, window.innerWidth - 32);
6634
- const left = Math.max(16, Math.min(rect.left, window.innerWidth - width - 16));
6635
- setPos({ left, bottom: Math.max(16, window.innerHeight - rect.top + 6), width });
6636
- };
6637
- place();
6638
7102
  const onDown = (e) => {
6639
7103
  if (wrapRef.current && !wrapRef.current.contains(e.target)) closeMenu();
6640
7104
  };
@@ -6646,11 +7110,9 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6646
7110
  };
6647
7111
  document.addEventListener("mousedown", onDown, true);
6648
7112
  document.addEventListener("keydown", onKey, true);
6649
- window.addEventListener("resize", place);
6650
7113
  return () => {
6651
7114
  document.removeEventListener("mousedown", onDown, true);
6652
7115
  document.removeEventListener("keydown", onKey, true);
6653
- window.removeEventListener("resize", place);
6654
7116
  };
6655
7117
  }, [openKind]);
6656
7118
 
@@ -6838,7 +7300,8 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6838
7300
  className: "dcpa-q-pop dcpa-m-pop",
6839
7301
  role: "dialog",
6840
7302
  "aria-label": showingAgent ? t("mediaAgentSection") : t(activeKind.kind === "image" ? "mediaImageGroup" : "mediaVideoGroup"),
6841
- style: pos ? { left: `${pos.left}px`, bottom: `${pos.bottom}px`, width: `${pos.width}px` } : { visibility: "hidden" },
7303
+ ref: popRef,
7304
+ style: popStyle,
6842
7305
  },
6843
7306
  head,
6844
7307
  ...(showingAgent ? [agentSettings] : [optionGroups(activeKind), agentAvailable ? h("div", { className: "dcpa-m-foot" }, agentButton) : null]),
@@ -7883,6 +8346,22 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
7883
8346
  });
7884
8347
  }
7885
8348
 
8349
+ // Sidebar footer: every keyed account's quota at a glance (renders
8350
+ // nothing until an enabled account has a management key).
8351
+ ctx.slots.inject("sidebar.footer.action", () =>
8352
+ registerListEntry(
8353
+ ctx.slots,
8354
+ {
8355
+ name: "sidebar.footer.action",
8356
+ id: `${NS}:quota-sidebar`,
8357
+ order: 100,
8358
+ label: () => t("qSideLabel"),
8359
+ locale: NS,
8360
+ },
8361
+ (props = {}) => h(SidebarQuota, { t, wide: props.wide !== false, store: sharedQuota })
8362
+ )
8363
+ );
8364
+
7886
8365
  // Generation-model button, left of the quota badge. It only needs the
7887
8366
  // session id; like the badge, the hero copy steps aside while the
7888
8367
  // composer copy of the same session is mounted.
@@ -34,8 +34,8 @@ export function plainObject(value) {
34
34
 
35
35
  /**
36
36
  * Normalize the state file into `{ version, refreshIntervalSeconds,
37
- * probeTimeoutMs, onlineModelInfo, accounts[] }` (a file without
38
- * `onlineModelInfo` reads as on). A legacy single-account file (flat fields,
37
+ * probeTimeoutMs, onlineModelInfo, sidebarQuota, accounts[] }` (a file
38
+ * without `onlineModelInfo` / `sidebarQuota` reads as on). A legacy single-account file (flat fields,
39
39
  * no `accounts` array) becomes one account with id `default`, so its
40
40
  * provider route, key reference and model selection carry over unchanged.
41
41
  * Invalid or duplicate account ids are replaced with generated ones.
@@ -64,6 +64,7 @@ export function normalizeState(raw = {}) {
64
64
  refreshIntervalSeconds: globals.refreshIntervalSeconds,
65
65
  probeTimeoutMs: globals.probeTimeoutMs,
66
66
  onlineModelInfo: globals.onlineModelInfo,
67
+ sidebarQuota: globals.sidebarQuota,
67
68
  accounts,
68
69
  };
69
70
  }
@@ -5,7 +5,7 @@ import { dirname, join } from "node:path";
5
5
  import { createQuotaController } from "../../quota/index.js";
6
6
 
7
7
  export function createQuotaService(shared) {
8
- const { ctx, resolveApiKey, describeApiKey, controller, updateDirectory } = shared;
8
+ const { ctx, resolveApiKey, describeApiKey, controller, updateDirectory, readState } = shared;
9
9
  // Quota ("额度" tab + composer badge): management keys live in the
10
10
  // credentials service under their own refs, never in account state.
11
11
  // Consecutive management-key rejections per account (never the key itself),
@@ -22,6 +22,7 @@ export function createQuotaService(shared) {
22
22
  },
23
23
  },
24
24
  listAccounts: () => controller.quotaAccounts(),
25
+ sidebar: () => readState().sidebarQuota !== false,
25
26
  resolveKey: (ref) => resolveApiKey(ref),
26
27
  describeKey: (ref) => describeApiKey(ref),
27
28
  setKey: async (ref, value) => {
@@ -29,8 +29,9 @@ export const ACCOUNT_FIELDS = [
29
29
  /**
30
30
  * All-account settings. `onlineModelInfo` (default on) lets recommendations
31
31
  * use public model catalogs (lib/host/model-info.js); download only.
32
+ * `sidebarQuota` (default on) shows the quota entry in the DSH sidebar footer.
32
33
  */
33
- export const GLOBAL_FIELDS = ["refreshIntervalSeconds", "probeTimeoutMs", "onlineModelInfo"];
34
+ export const GLOBAL_FIELDS = ["refreshIntervalSeconds", "probeTimeoutMs", "onlineModelInfo", "sidebarQuota"];
34
35
  export const DEFAULT_REFRESH_INTERVAL_SECONDS = 300;
35
36
  export const DEFAULT_PROBE_TIMEOUT_MS = 5000;
36
37
 
@@ -197,6 +198,7 @@ export function resolveConfig(rawConfig = {}) {
197
198
  refreshIntervalSeconds,
198
199
  probeTimeoutMs,
199
200
  onlineModelInfo: readVolatile(rawConfig?.onlineModelInfo, true) !== false,
201
+ sidebarQuota: readVolatile(rawConfig?.sidebarQuota, true) !== false,
200
202
  includePrefix,
201
203
  excludePrefix,
202
204
  ...(selectedModels === undefined ? {} : { selectedModels }),
@@ -204,6 +204,7 @@ export function createCpaController(deps) {
204
204
  refreshIntervalSeconds: state.refreshIntervalSeconds,
205
205
  probeTimeoutMs: state.probeTimeoutMs,
206
206
  onlineModelInfo: state.onlineModelInfo !== false,
207
+ sidebarQuota: state.sidebarQuota !== false,
207
208
  ...(deps.modelInfo === undefined ? {} : { modelInfo: deps.modelInfo.status() }),
208
209
  },
209
210
  accounts,
@@ -339,6 +339,8 @@ export function createQuotaController(deps) {
339
339
  return {
340
340
  generatedAt: new Date(now()).toISOString(),
341
341
  refreshing: out.some((a) => a.refreshing),
342
+ // The global sidebar switch, so the page learns it from the same read.
343
+ sidebar: deps.sidebar?.() !== false,
342
344
  accounts: out,
343
345
  };
344
346
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cliproxyapi-pro",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "CLIProxyAPI (CPA) provider for DeepSeek Harness — multiple accounts, model sync over native protocols, per-credential quota, and optional image / video generation.",
5
5
  "keywords": [
6
6
  "dsh",