dsh-cliproxyapi-pro 1.9.1 → 1.10.1

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,19 @@
4
4
 
5
5
  本插件的所有重要变更。版本号遵循[语义化版本](https://semver.org/lang/zh-CN/)。
6
6
 
7
+ ## 1.10.1 — 2026-11-12
8
+
9
+ ### 修复
10
+ - **输入框额度详情和生成模型菜单不再乱飘。** 新版 DSH 的输入框底座是 sticky 并带 `will-change: transform`,`position: fixed` 的弹层因此以输入框底座而不是视口为参照,原先按视口坐标计算的位置会偏到别处(常被右侧裁掉),并跟着输入框移动。现在弹层仍渲染在组件内部(不挂到 `document.body`),先在底座原点处隐藏测量,再把按钮的视口位置换算到这一层,保持在视口和聊天滚动区内,高度不超过按钮上方的空间,并在打开期间跟随按钮。问题由 [@CDeZT](https://github.com/CDeZT) 在 #4 / #5 报告。
11
+
12
+ ## 1.10.0 — 2026-11-11
13
+
14
+ ### 新增
15
+ - **按产品线推荐模型。** 「恢复推荐精选」和新账号首次自动勾选不再「每个家族只取版本号最大的一个」,而是把 Claude Opus / Sonnet / Haiku / Fable、GPT sol / terra / luna / astra、Gemini / Gemini Flash 等分成产品线:每条线取最新型号(有发布日期按日期,修正了 `grok-4.20` 被当成比 `grok-4.7` 新的问题),优先不带 `-thinking` / `-fast` / `-1m` 后缀和 `devin/` 前缀的型号;比本家族最新型号早 180 天以上的旧产品线和被上游弃用的型号不推荐。只推荐旗舰:按在线能力评分只保留达到本服务最强产品线 80% 的产品线,最多 12 个,轻量线和没有评分的小众模型不推荐;没有评分时推荐主流厂商的非轻量产品线。此外,账号接入的每个渠道(按前缀或 `owned_by` 区分)至少推荐一个它自己的最佳模型,例如 Devin 渠道的 `devin/swe-2`、Grok 渠道最好的 Grok。不透明 id(如 `model_private_12`)改用显示名判断。列表中推荐的模型带「推荐」标记,旁边的 ⓘ 说明理由。
16
+ - **在线模型资料(默认开启)。** 每天从 models.dev 和 OpenRouter 下载公开的模型资料(产品线、发布日期、弃用 / 下线状态、上下文与输出上限、价格、能力评分),用于推荐排序;只下载,不上传任何账号、密钥、地址或模型列表。缓存在 `.dsh-cliproxyapi/model-info.json`,失败时沿用旧缓存并在一小时后重试。「模型」标签顶部可关闭(所有账号共用,保存在 `state.json` 的新全局字段 `onlineModelInfo`,缺省视为开启)。CPA 目录未提供上下文窗口或最大输出时,用在线资料中精确匹配的值(最大输出不超过 128K)代替固定的 262144 / 64000。
17
+ - **选择建议。** 「模型」标签提示已勾选产品线的新型号(如勾选了 Fable 5.1 而目录里有 5.2,可「加入」或「替换」)、已不在服务目录中的勾选(有同名带前缀型号时可直接改为它)和被上游弃用的勾选。只修改草稿,仍需「保存并应用」。
18
+ - 从 CPA 普通模型列表读取 `created` 日期,用于判断新旧。
19
+
7
20
  ## 1.9.1 — 2026-10-27
8
21
 
9
22
  ### 修复
package/README.en.md CHANGED
@@ -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.9.1`.
39
+ To pin a version, write `dsh-cliproxyapi-pro@1.10.1`.
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.9.1` |
68
+ | A released version | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#v1.10.1` |
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 |
@@ -76,7 +76,7 @@ All versions are listed under [Releases](https://github.com/TinyBOOOOM/dsh-clipr
76
76
 
77
77
  1. **Open the settings panel**: **Settings** → the **CLIProxyAPI** page in the left navigation (accounts, models and protocols live there). The plugin's own updates are on sidebar **Plugins** → **CLIProxyAPI** and on **Settings** → **Built-in plugins** → the **CLIProxyAPI** tab; those two places contain only update features.
78
78
  2. **Add an account**: click **+ Add Account**, enter an account name, the **Base URL** (e.g. `http://127.0.0.1:8317`, without `/v1`) and the **API Key** (leave it empty for a local CPA without authentication), then click **Connect**. A successful connection creates and enables the account; on failure the reason is shown so you can fix it, or choose **Add Anyway (Disabled)**.
79
- 3. **Choose models**: the account's **Models** tab lists every model on the server, with the newest model of each family already checked. Adjust the selection and click **Save & Apply** at the bottom.
79
+ 3. **Choose models**: the account's **Models** tab lists every model on the server, with the recommended models already checked by product line (the newest Claude Opus, Sonnet, Fable, …, informed by [online model info](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/en/accounts-and-models.md#recommendations-and-suggestions), on by default and download only). Adjust the selection and click **Save & Apply** at the bottom.
80
80
  4. **Use them**: open the model picker in a conversation; the models appear in a group named after the account.
81
81
 
82
82
  If CPA runs on this machine on the default port `8317` without a key, there is nothing to fill in: the plugin finds it automatically.
package/README.md CHANGED
@@ -36,7 +36,7 @@
36
36
  dsh-cliproxyapi-pro
37
37
  ```
38
38
 
39
- 需要固定版本时可以写成 `dsh-cliproxyapi-pro@1.9.1`。
39
+ 需要固定版本时可以写成 `dsh-cliproxyapi-pro@1.10.1`。
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.9.1` |
68
+ | 某个发布版本 | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#v1.10.1` |
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
  | 本地源码(开发用) | 克隆后的仓库目录绝对路径;以链接方式安装,改代码后重载插件即生效 |
@@ -76,7 +76,7 @@ dsh plugin --profile <profile 名称> add dsh-cliproxyapi-pro
76
76
 
77
77
  1. **打开设置面板**:**设置** → 左侧导航的 **CLIProxyAPI** 页(账号、模型与协议都在这里)。插件自身的更新在左侧栏 **插件** → **CLIProxyAPI**,或 **设置** → **内置插件** → **CLIProxyAPI** 标签页,这两处只有更新功能。
78
78
  2. **添加账号**:点 **+ 添加账号**,填账号名称、**服务地址**(如 `http://127.0.0.1:8317`,不用加 `/v1`)和 **API Key**(本地免密的 CPA 可留空),点 **连接**。连接成功即创建并启用账号;失败时会显示原因,可修正后重试,或选「仍然添加(不启用)」。
79
- 3. **选择模型**:在账号的 **模型** 标签里,CPA 上的全部模型已列出,并已为每个家族勾好最新的一个。按需增减后点底部的 **保存并应用**。
79
+ 3. **选择模型**:在账号的 **模型** 标签里,CPA 上的全部模型已列出,并已按产品线勾好推荐模型(Claude Opus / Sonnet / Fable 等各取最新,参考默认开启、只下载不上传的[在线模型资料](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/docs/zh/accounts-and-models.md#推荐与选择建议))。按需增减后点底部的 **保存并应用**。
80
80
  4. **开始使用**:回到对话框,打开模型选择器,就能在以账号名称命名的分组里看到这些模型。
81
81
 
82
82
  CPA 就在本机默认端口 `8317` 且没有设置密钥时,什么都不用填,插件会自动发现它。
package/lib/client.js CHANGED
@@ -69,7 +69,7 @@ window.__ModuleLoader__.load({
69
69
  addAccountBtn: "+ 添加账号",
70
70
  removeAccountBtn: "删除此账号",
71
71
  removeConfirm: "确定删除账号「{name}」吗?它同步到模型选择器中的模型路由也会一并移除(已保存的密钥不会删除)。",
72
- addedToast: "账号已添加并启用,已按每个家族勾选最新模型。",
72
+ addedToast: "账号已添加并启用,已按产品线勾选推荐模型。",
73
73
  removedToast: "账号已删除,其模型已从模型选择器中移除",
74
74
  disabledHint: "未启用:模型不在模型选择器中,配置已保留。",
75
75
  enabledLabel: "启用此账号",
@@ -113,7 +113,7 @@ window.__ModuleLoader__.load({
113
113
  selectAllVisibleBtn: "全选当前列表",
114
114
  deselectAllVisibleBtn: "取消当前列表",
115
115
  selectRecommendedBtn: "恢复推荐精选",
116
- selectRecommendedHint: "按该服务的模型目录,每个模型家族勾选最新的一个。",
116
+ selectRecommendedHint: "只推荐旗舰:每条产品线(如 Claude Opus / Sonnet / Fable)取最新型号,再按在线资料的能力评分只保留达到本服务最强模型 80% 的产品线,最多 12 个;轻量、无评分的小众模型和被新品淘汰的旧线不推荐;另外每个接入的渠道(如 Devin、Grok)至少推荐一个它自己的最佳模型。关闭在线模型资料时改为推荐主流厂商的非轻量产品线。",
117
117
  badgeVision: "视觉 Image",
118
118
  badgeReasoning: "推理",
119
119
  badgeSelected: "已启用",
@@ -555,6 +555,35 @@ window.__ModuleLoader__.load({
555
555
  mediaRunErrExpired: "CPA 已不再记得这个视频:提交已超过 3 小时。",
556
556
  mediaRunErrInvalidVideo: "CPA 返回的数据不是 MP4、MOV 或 WebM 视频。",
557
557
  mediaRunErrVideoTooLarge: "视频超过 200 MiB,未保存。",
558
+ badgeRecommended: "推荐",
559
+ recommendReason: "{line} 产品线的最新型号(依据:{source})",
560
+ recommendReasonDated: "{line} 产品线的最新型号,{date} 发布(依据:{source})",
561
+ recommendReasonChannel: "{channel} 渠道自己最好的模型({line} 产品线):每个接入的渠道至少推荐一个(依据:{source})",
562
+ recommendReasonScore: ";能力评分 {score},接近本服务最强模型",
563
+ recommendSourceOnline: "在线模型资料",
564
+ recommendSourceCatalog: "CPA 目录日期",
565
+ recommendSourceName: "模型名称中的版本号",
566
+ onlineInfoLabel: "在线模型资料",
567
+ onlineInfoHint: "开启后,每天从 models.dev 和 openrouter.ai 下载公开的模型资料(产品线、发布日期、下线状态、能力评分),用于改进推荐,并补全 CPA 未提供的上下文和输出上限。只下载,不上传任何账号、密钥、地址或模型列表。所有账号共用此开关;关闭后只按 CPA 目录推荐。",
568
+ onlineInfoOff: "已关闭,只按 CPA 目录推荐",
569
+ onlineInfoLoading: "正在获取…",
570
+ onlineInfoReady: "已更新({date})",
571
+ onlineInfoPartial: "部分来源不可用,资料更新于 {date}",
572
+ onlineInfoError: "暂时无法获取,暂按 CPA 目录推荐",
573
+ onlineInfoIdle: "尚未获取,稍后自动下载",
574
+ onlineInfoOnToast: "已开启在线模型资料",
575
+ onlineInfoOffToast: "已关闭在线模型资料",
576
+ adviceTitle: "选择建议",
577
+ adviceHint: "根据服务目录和在线资料给出的建议,不会自动修改你的选择;点击按钮后需「保存并应用」才生效。",
578
+ adviceUpgrade: "{to} 比已勾选的 {from} 更新",
579
+ adviceUpgradeDated: "{to}({date} 发布)比已勾选的 {from} 更新",
580
+ adviceMissing: "已勾选的 {id} 不在服务目录中,不会出现在模型选择器里",
581
+ adviceRetired: "已勾选的 {id} 已被上游标记为弃用或已过下线日期",
582
+ adviceAdd: "加入",
583
+ adviceReplace: "替换",
584
+ adviceRemove: "取消勾选",
585
+ adviceSwitchTo: "改为 {id}",
586
+ onlineLimitsNote: "(CPA 未提供,取自在线资料)",
558
587
  };
559
588
 
560
589
  const en = {
@@ -574,7 +603,7 @@ window.__ModuleLoader__.load({
574
603
  addAccountBtn: "+ Add Account",
575
604
  removeAccountBtn: "Delete Account",
576
605
  removeConfirm: "Delete account \"{name}\"? Its model routes are removed from the model picker too (the stored key is kept).",
577
- addedToast: "Account added and enabled; the newest model of each family is checked.",
606
+ addedToast: "Account added and enabled; the recommended model of each product line is checked.",
578
607
  removedToast: "Account deleted and its models removed from the picker",
579
608
  disabledHint: "Disabled: its models are not in the model picker; settings are kept.",
580
609
  enabledLabel: "Enable This Account",
@@ -618,7 +647,7 @@ window.__ModuleLoader__.load({
618
647
  selectAllVisibleBtn: "Check Visible",
619
648
  deselectAllVisibleBtn: "Uncheck Visible",
620
649
  selectRecommendedBtn: "Reset to Recommended",
621
- selectRecommendedHint: "Check the newest model of each family in this server's catalog.",
650
+ selectRecommendedHint: "Flagships only: the newest model of each product line (Claude Opus, Sonnet, Fable, …), keeping only lines whose online capability score reaches 80% of this server's strongest, at most 12; light, unscored niche models and lines a newer one left behind are skipped; every connected channel (Devin, Grok, …) also gets its own best model. With online model info off, the non-light lines of well-known vendors are recommended instead.",
622
651
  badgeVision: "Image",
623
652
  badgeReasoning: "Reasoning",
624
653
  badgeSelected: "Active",
@@ -1060,6 +1089,35 @@ window.__ModuleLoader__.load({
1060
1089
  mediaRunErrExpired: "CPA no longer knows this video: more than 3 hours have passed since it was submitted.",
1061
1090
  mediaRunErrInvalidVideo: "CPA returned data that is not an MP4, MOV or WebM video.",
1062
1091
  mediaRunErrVideoTooLarge: "The video is larger than 200 MiB and was not saved.",
1092
+ badgeRecommended: "Recommended",
1093
+ recommendReason: "Newest model of the {line} line (based on: {source})",
1094
+ recommendReasonDated: "Newest model of the {line} line, released {date} (based on: {source})",
1095
+ recommendReasonChannel: "The {channel} channel's own best model ({line} line): every connected channel gets at least one (based on: {source})",
1096
+ recommendReasonScore: "; capability score {score}, close to this server's strongest model",
1097
+ recommendSourceOnline: "online model info",
1098
+ recommendSourceCatalog: "CPA catalog dates",
1099
+ recommendSourceName: "version in the model name",
1100
+ onlineInfoLabel: "Online Model Info",
1101
+ onlineInfoHint: "When on, public model data (product lines, release dates, retirement, capability scores) is downloaded daily from models.dev and openrouter.ai to improve recommendations and to fill context and output limits the CPA catalog leaves out. Download only: no account, key, address or model list is sent. Shared by all accounts; when off, recommendations use the CPA catalog only.",
1102
+ onlineInfoOff: "Off: recommendations use the CPA catalog only",
1103
+ onlineInfoLoading: "Fetching…",
1104
+ onlineInfoReady: "Updated {date}",
1105
+ onlineInfoPartial: "Some sources unavailable; data from {date}",
1106
+ onlineInfoError: "Unavailable for now; using the CPA catalog",
1107
+ onlineInfoIdle: "Not fetched yet; downloads shortly",
1108
+ onlineInfoOnToast: "Online model info turned on",
1109
+ onlineInfoOffToast: "Online model info turned off",
1110
+ adviceTitle: "Suggestions",
1111
+ adviceHint: "Based on the server's catalog and online model info. Nothing changes on its own: a button edits the selection, and Save & Apply makes it take effect.",
1112
+ adviceUpgrade: "{to} is newer than checked {from}",
1113
+ adviceUpgradeDated: "{to} (released {date}) is newer than checked {from}",
1114
+ adviceMissing: "Checked {id} is not in the server's catalog and is missing from the model picker",
1115
+ adviceRetired: "Checked {id} is deprecated upstream or past its end date",
1116
+ adviceAdd: "Add",
1117
+ adviceReplace: "Replace",
1118
+ adviceRemove: "Uncheck",
1119
+ adviceSwitchTo: "Use {id}",
1120
+ onlineLimitsNote: " (not provided by CPA; from online model info)",
1063
1121
  };
1064
1122
 
1065
1123
  const CSS = `
@@ -2163,6 +2221,22 @@ select.dcpa-q-input { appearance: auto; padding-right: 8px; }
2163
2221
  .dcpa-models .dcpa-model-row:hover { background: var(--dsw-alias-interactive-bg-hover, transparent); }
2164
2222
  .dcpa-models .dcpa-badge { border: 0; background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-2)); border-radius: 999px; padding: 1px 8px; }
2165
2223
  .dcpa-models .dcpa-editor { border-top: 0; padding: 4px 0 6px 25px; }
2224
+ /* Online model info switch, recommendation badge and selection suggestions. */
2225
+ .dcpa-advice { display: flex; flex-direction: column; gap: 8px; }
2226
+ .dcpa-advice-online { justify-content: space-between; gap: 12px; padding: 4px 0; }
2227
+ .dcpa-advice-label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
2228
+ .dcpa-advice-list {
2229
+ display: flex;
2230
+ flex-direction: column;
2231
+ gap: 4px;
2232
+ padding: 8px 10px;
2233
+ border-radius: var(--dsw-radius-md, 10px);
2234
+ background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-2));
2235
+ }
2236
+ .dcpa-advice-list > .dcpa-q-sub { display: flex; align-items: center; gap: 4px; }
2237
+ .dcpa-advice-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
2238
+ .dcpa-advice-text { font-size: 13px; line-height: 18px; color: var(--dsw-alias-label-primary); overflow-wrap: anywhere; }
2239
+ .dcpa-models .dcpa-badge-rec { display: inline-flex; align-items: center; gap: 4px; color: var(--dsw-alias-brand-primary, var(--dsw-alias-label-primary)); }
2166
2240
  /* Generation tab: flat rows without checkboxes, kind select + switch on the right. */
2167
2241
  .dcpa-media .dcpa-model-row { cursor: default; }
2168
2242
  .dcpa-media .dcpa-model-left { flex-wrap: wrap; }
@@ -3671,6 +3745,123 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
3671
3745
  );
3672
3746
  }
3673
3747
 
3748
+ /** Why a model is recommended, from the Host's `recommendations` detail. */
3749
+ function recommendationReason(t, detail) {
3750
+ if (!detail) return "";
3751
+ const source = t(detail.source === "online" ? "recommendSourceOnline" : detail.source === "catalog" ? "recommendSourceCatalog" : "recommendSourceName");
3752
+ if (detail.via === "channel") {
3753
+ return fmt(t, "recommendReasonChannel", { channel: detail.channel ?? "", line: detail.line, source });
3754
+ }
3755
+ const base = detail.released
3756
+ ? fmt(t, "recommendReasonDated", { line: detail.line, date: detail.released, source })
3757
+ : fmt(t, "recommendReason", { line: detail.line, source });
3758
+ return typeof detail.score === "number" ? `${base}${fmt(t, "recommendReasonScore", { score: detail.score })}` : base;
3759
+ }
3760
+
3761
+ function modelInfoStatusText(t, info) {
3762
+ if (!info || info.enabled === false || info.state === "off") return t("onlineInfoOff");
3763
+ if (info.state === "loading") return t("onlineInfoLoading");
3764
+ const dates = Object.values(info.sources ?? {}).map((s) => s?.fetchedAt).filter(Boolean).sort();
3765
+ const latest = dates.length > 0 ? new Date(dates[dates.length - 1]) : null;
3766
+ if (latest && !Number.isNaN(latest.getTime())) {
3767
+ const when = latest.toLocaleDateString();
3768
+ return info.state === "partial" ? fmt(t, "onlineInfoPartial", { date: when }) : fmt(t, "onlineInfoReady", { date: when });
3769
+ }
3770
+ return info.state === "error" ? t("onlineInfoError") : t("onlineInfoIdle");
3771
+ }
3772
+
3773
+ /**
3774
+ * Stateless: the online-info switch (a global, saved at once) and advice
3775
+ * about the draft selection. Buttons only change the draft; the save bar
3776
+ * applies them like any other selection change.
3777
+ */
3778
+ function ModelAdvice({ t, account, global, selectedIds, busy, onSelection, onToggleOnline }) {
3779
+ const on = global?.onlineModelInfo !== false;
3780
+ const advice = account.suggestions ?? {};
3781
+ const has = (id) => selectedIds.has(id);
3782
+ const edit = (fn) => onSelection((prev) => {
3783
+ const next = new Set(prev);
3784
+ fn(next);
3785
+ return next;
3786
+ });
3787
+ const items = [];
3788
+ for (const u of Array.isArray(advice.upgrades) ? advice.upgrades : []) {
3789
+ const from = (u.from ?? []).filter(has);
3790
+ if (has(u.to) || from.length === 0) continue;
3791
+ items.push({
3792
+ key: `up:${u.to}`,
3793
+ text: fmt(t, u.released ? "adviceUpgradeDated" : "adviceUpgrade", { from: from.join(", "), to: u.to, date: u.released ?? "" }),
3794
+ actions: [
3795
+ [t("adviceAdd"), () => edit((s) => s.add(u.to))],
3796
+ [t("adviceReplace"), () => edit((s) => { s.add(u.to); for (const id of from) s.delete(id); })],
3797
+ ],
3798
+ });
3799
+ }
3800
+ const fix = (kind, entry) => {
3801
+ if (!has(entry.id)) return;
3802
+ const replacement = entry.replacement && !has(entry.replacement) ? entry.replacement : null;
3803
+ items.push({
3804
+ key: `${kind}:${entry.id}`,
3805
+ text: fmt(t, kind === "missing" ? "adviceMissing" : "adviceRetired", { id: entry.id }),
3806
+ actions: replacement
3807
+ ? [[fmt(t, "adviceSwitchTo", { id: replacement }), () => edit((s) => { s.delete(entry.id); s.add(replacement); })]]
3808
+ : [[t("adviceRemove"), () => edit((s) => s.delete(entry.id))]],
3809
+ });
3810
+ };
3811
+ for (const m of Array.isArray(advice.missing) ? advice.missing : []) fix("missing", m);
3812
+ for (const r of Array.isArray(advice.retired) ? advice.retired : []) fix("retired", r);
3813
+
3814
+ return h(
3815
+ "div",
3816
+ { className: "dcpa-advice" },
3817
+ h(
3818
+ "div",
3819
+ { className: "dcpa-switch-row dcpa-advice-online" },
3820
+ h(
3821
+ "div",
3822
+ { className: "dcpa-advice-label" },
3823
+ h("span", { className: "dcpa-label" }, t("onlineInfoLabel")),
3824
+ h(InfoTip, { t, text: t("onlineInfoHint") }),
3825
+ h("span", { className: "dcpa-q-sub", role: "status" }, modelInfoStatusText(t, global?.modelInfo))
3826
+ ),
3827
+ h(
3828
+ "button",
3829
+ {
3830
+ type: "button",
3831
+ role: "switch",
3832
+ className: "dcpa-switch",
3833
+ "aria-checked": on,
3834
+ "aria-label": t("onlineInfoLabel"),
3835
+ disabled: busy !== null,
3836
+ onClick: () => onToggleOnline(!on),
3837
+ },
3838
+ h("span", { className: "dcpa-switch-thumb" })
3839
+ )
3840
+ ),
3841
+ items.length > 0
3842
+ ? h(
3843
+ "div",
3844
+ { className: "dcpa-advice-list", role: "region", "aria-label": t("adviceTitle") },
3845
+ h("div", { className: "dcpa-q-sub" }, t("adviceTitle"), h(InfoTip, { t, text: t("adviceHint") })),
3846
+ items.map((item) =>
3847
+ h(
3848
+ "div",
3849
+ { key: item.key, className: "dcpa-advice-item" },
3850
+ h("span", { className: "dcpa-advice-text" }, item.text),
3851
+ h(
3852
+ "span",
3853
+ { className: "dcpa-actions" },
3854
+ item.actions.map(([label, run]) =>
3855
+ h("button", { key: label, type: "button", className: "dcpa-btn dcpa-btn-sm", onClick: run }, label)
3856
+ )
3857
+ )
3858
+ )
3859
+ )
3860
+ )
3861
+ : null
3862
+ );
3863
+ }
3864
+
3674
3865
  function AccountPanel({ t, account, global, rev, busy, notice, actions, onDirtyChange }) {
3675
3866
  const syncing = busy === "refresh";
3676
3867
  const saving = busy === "save";
@@ -3874,11 +4065,19 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
3874
4065
  });
3875
4066
  }, [visibleModels]);
3876
4067
 
3877
- // Computed by the Host from this account's own catalog: newest per family.
4068
+ // Computed by the Host from this account's catalog (and online model info):
4069
+ // the newest model of each product line, with a reason per model.
3878
4070
  const recommended = Array.isArray(account.recommendedModels) ? account.recommendedModels : [];
3879
4071
  const resetRecommended = useCallback(() => {
3880
4072
  setSelectedIds(new Set(recommended));
3881
4073
  }, [recommended]);
4074
+ const recommendedById = useMemo(() => {
4075
+ const details = Array.isArray(account.recommendations) ? account.recommendations : [];
4076
+ return new Map(recommended.map((id) => [id, details.find((d) => d.id === id) ?? { id }]));
4077
+ }, [recommended, account.recommendations]);
4078
+ // A global: saved at once without touching the drafts.
4079
+ const toggleOnlineInfo = (next) =>
4080
+ void actions.patch(account.id, { onlineModelInfo: next }, next ? t("onlineInfoOnToast") : t("onlineInfoOffToast"));
3882
4081
 
3883
4082
  const updateOverride = useCallback((model, patch) => {
3884
4083
  setModelOverrides((prev) => {
@@ -4108,6 +4307,7 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
4108
4307
  "div",
4109
4308
  { className: "dcpa-tabbody dcpa-models" },
4110
4309
  h("p", { className: "dcpa-q-sub" }, t("modelsEmptyRule")),
4310
+ h(ModelAdvice, { t, account, global, selectedIds, busy, onSelection: setSelectedIds, onToggleOnline: toggleOnlineInfo }),
4111
4311
  // Search + Segmented Filter + Batch Actions
4112
4312
  h(
4113
4313
  "div",
@@ -4275,6 +4475,14 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
4275
4475
  h(
4276
4476
  "div",
4277
4477
  { className: "dcpa-model-tags" },
4478
+ recommendedById.has(m.id)
4479
+ ? h(
4480
+ "span",
4481
+ { className: "dcpa-badge dcpa-badge-rec" },
4482
+ t("badgeRecommended"),
4483
+ h(InfoTip, { t, text: recommendationReason(t, recommendedById.get(m.id)) })
4484
+ )
4485
+ : null,
4278
4486
  hasOverride
4279
4487
  ? h("span", { className: "dcpa-badge dcpa-badge-warn" }, t("customParamsBadge"))
4280
4488
  : null,
@@ -4342,7 +4550,9 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
4342
4550
  h(
4343
4551
  "p",
4344
4552
  { className: "dcpa-hint" },
4345
- `${t("discoveredValue")}: ${formatTokens(m.discovered?.contextWindow)}`
4553
+ `${t("discoveredValue")}: ${formatTokens(m.discovered?.contextWindow)}${
4554
+ m.discovered?.onlineLimits?.includes?.("contextWindow") ? t("onlineLimitsNote") : ""
4555
+ }`
4346
4556
  )
4347
4557
  ),
4348
4558
  h(
@@ -4364,7 +4574,9 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
4364
4574
  h(
4365
4575
  "p",
4366
4576
  { className: "dcpa-hint" },
4367
- `${t("discoveredValue")}: ${formatTokens(m.discovered?.maxTokens)}`
4577
+ `${t("discoveredValue")}: ${formatTokens(m.discovered?.maxTokens)}${
4578
+ m.discovered?.onlineLimits?.includes?.("maxTokens") ? t("onlineLimitsNote") : ""
4579
+ }`
4368
4580
  )
4369
4581
  )
4370
4582
  ),
@@ -5685,6 +5897,148 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5685
5897
  return now;
5686
5898
  }
5687
5899
 
5900
+ /*
5901
+ * The composer peeks (`.dcpa-q-pop`, `position: fixed`) stay inside their
5902
+ * component: no portal, nothing appended to document.body. DSH's active
5903
+ * composer seat is sticky and carries `will-change: transform`, which makes
5904
+ * it the containing block of fixed descendants, so `left` / `bottom` count
5905
+ * from the seat, not the viewport. Plain viewport coordinates put the peek
5906
+ * somewhere else and let it drift with the composer.
5907
+ *
5908
+ * Each placement measures where the rendered peek actually landed, derives
5909
+ * the containing block's left and bottom edges from the offsets it applied,
5910
+ * and converts the wanted viewport position into that box. Ancestors from
5911
+ * the containing block upward that clip overflow (the chat scroller) bound
5912
+ * the peek together with the viewport. Without such a box the result equals
5913
+ * plain viewport placement.
5914
+ */
5915
+ const PEEK_WIDTH = 340;
5916
+ const PEEK_MIN_WIDTH = 160;
5917
+ const PEEK_GAP = 6;
5918
+ const PEEK_MARGIN = 16;
5919
+ const PEEK_MAX_HEIGHT = 440;
5920
+ const PEEK_MIN_HEIGHT = 120;
5921
+ // Measured once on open at the containing block origin, then shown.
5922
+ const PEEK_HIDDEN = Object.freeze({ visibility: "hidden", left: "0px", bottom: "0px" });
5923
+
5924
+ /**
5925
+ * Pure placement. `anchor` and `box` are viewport rects of the anchor and of
5926
+ * the peek as rendered with `applied` `{ left, bottom }` offsets; `bounds`
5927
+ * is the visible area `{ left, top, right, bottom }` in viewport coordinates.
5928
+ * Returns offsets in the peek's own containing block.
5929
+ */
5930
+ function placePeek({ anchor, box, applied, bounds }) {
5931
+ const originLeft = box.left - applied.left;
5932
+ const originBottom = box.bottom + applied.bottom;
5933
+ const room = bounds.right - bounds.left - 2 * PEEK_MARGIN;
5934
+ const width = Math.min(PEEK_WIDTH, Math.max(PEEK_MIN_WIDTH, room));
5935
+ const left = Math.max(bounds.left + PEEK_MARGIN, Math.min(anchor.left, bounds.right - width - PEEK_MARGIN));
5936
+ const edge = anchor.top - PEEK_GAP;
5937
+ const maxHeight = Math.max(PEEK_MIN_HEIGHT, Math.min(PEEK_MAX_HEIGHT, edge - bounds.top - PEEK_MARGIN));
5938
+ return {
5939
+ left: Math.round(left - originLeft),
5940
+ bottom: Math.round(originBottom - edge),
5941
+ width: Math.round(width),
5942
+ maxHeight: Math.round(maxHeight),
5943
+ };
5944
+ }
5945
+
5946
+ const samePeek = (a, b) =>
5947
+ !!a && !!b && a.left === b.left && a.bottom === b.bottom && a.width === b.width && a.maxHeight === b.maxHeight;
5948
+
5949
+ /** Nearest ancestor that becomes the containing block of fixed descendants. */
5950
+ function fixedContainer(el) {
5951
+ const root = el?.ownerDocument?.documentElement ?? null;
5952
+ for (let node = el?.parentElement ?? null; node && node !== root; node = node.parentElement) {
5953
+ const s = getComputedStyle(node);
5954
+ if (
5955
+ (s.transform && s.transform !== "none") ||
5956
+ (s.perspective && s.perspective !== "none") ||
5957
+ (s.filter && s.filter !== "none") ||
5958
+ (s.backdropFilter && s.backdropFilter !== "none") ||
5959
+ /transform|perspective|filter/.test(s.willChange ?? "") ||
5960
+ /paint|layout|strict|content/.test(s.contain ?? "") ||
5961
+ (s.containerType && s.containerType !== "normal")
5962
+ ) {
5963
+ return node;
5964
+ }
5965
+ }
5966
+ return null;
5967
+ }
5968
+
5969
+ /** The containing block and its ancestors that clip a fixed peek. */
5970
+ function peekClips(pop) {
5971
+ const container = fixedContainer(pop);
5972
+ if (!container) return [];
5973
+ const root = pop.ownerDocument?.documentElement ?? null;
5974
+ const clips = [];
5975
+ for (let node = container; node && node !== root; node = node.parentElement) {
5976
+ const s = getComputedStyle(node);
5977
+ if (s.overflowX !== "visible" || s.overflowY !== "visible" || /paint|strict|content/.test(s.contain ?? "")) clips.push(node);
5978
+ }
5979
+ return clips;
5980
+ }
5981
+
5982
+ function peekBounds(clips) {
5983
+ const bounds = { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight };
5984
+ for (const node of clips) {
5985
+ const r = node.getBoundingClientRect();
5986
+ if (r.width === 0 && r.height === 0) continue;
5987
+ bounds.left = Math.max(bounds.left, r.left);
5988
+ bounds.top = Math.max(bounds.top, r.top);
5989
+ bounds.right = Math.min(bounds.right, r.right);
5990
+ bounds.bottom = Math.min(bounds.bottom, r.bottom);
5991
+ }
5992
+ return bounds;
5993
+ }
5994
+
5995
+ /**
5996
+ * Style for a fixed peek anchored above `anchorRef`, rendered with
5997
+ * `ref: popRef` inside the same component. Tracks the anchor every frame
5998
+ * while open (state changes only when the placement moves) and stays
5999
+ * hidden until the first measurement.
6000
+ */
6001
+ function useAnchoredPeek(open, anchorRef, popRef) {
6002
+ const [pos, setPos] = useState(null);
6003
+ useEffect(() => {
6004
+ if (!open) {
6005
+ setPos(null);
6006
+ return undefined;
6007
+ }
6008
+ if (typeof window === "undefined" || typeof getComputedStyle !== "function") return undefined;
6009
+ let clips = null;
6010
+ let frame = 0;
6011
+ const place = () => {
6012
+ const anchor = anchorRef.current?.getBoundingClientRect?.();
6013
+ const pop = popRef.current;
6014
+ const box = pop?.getBoundingClientRect?.();
6015
+ if (!anchor || !box || (anchor.width === 0 && anchor.height === 0)) return;
6016
+ clips ??= peekClips(pop);
6017
+ const applied = { left: parseFloat(pop.style.left) || 0, bottom: parseFloat(pop.style.bottom) || 0 };
6018
+ const next = placePeek({ anchor, box, applied, bounds: peekBounds(clips) });
6019
+ setPos((prev) => (samePeek(prev, next) ? prev : next));
6020
+ };
6021
+ const onResize = () => {
6022
+ clips = null;
6023
+ place();
6024
+ };
6025
+ const raf = typeof window.requestAnimationFrame === "function" ? window.requestAnimationFrame.bind(window) : null;
6026
+ const loop = () => {
6027
+ place();
6028
+ frame = raf(loop);
6029
+ };
6030
+ place();
6031
+ if (raf) frame = raf(loop);
6032
+ window.addEventListener("resize", onResize);
6033
+ return () => {
6034
+ if (raf && frame) window.cancelAnimationFrame?.(frame);
6035
+ window.removeEventListener("resize", onResize);
6036
+ };
6037
+ }, [open]);
6038
+ if (!open || !pos) return PEEK_HIDDEN;
6039
+ return { left: `${pos.left}px`, bottom: `${pos.bottom}px`, width: `${pos.width}px`, maxHeight: `${pos.maxHeight}px` };
6040
+ }
6041
+
5688
6042
  function QuotaMeter({ t, w, now }) {
5689
6043
  const pct = typeof w.remainingPercent === "number" ? Math.max(0, Math.min(100, w.remainingPercent)) : null;
5690
6044
  const level = quotaLevel(pct);
@@ -6140,23 +6494,16 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6140
6494
  const snap = useQuota(selection ? store : null);
6141
6495
  const now = useNow(60 * 1000);
6142
6496
  const [open, setOpen] = useState(false);
6143
- const [pos, setPos] = useState(null);
6144
6497
  const wrapRef = useRef(null);
6145
6498
  const buttonRef = useRef(null);
6499
+ const popRef = useRef(null);
6500
+ const popStyle = useAnchoredPeek(open, buttonRef, popRef);
6146
6501
 
6147
6502
  const summary = selection ? summarizeModelQuota(snap.data, selection.provider, selection.model) : null;
6148
6503
  const visible = !shadowed && summary !== null && summary.account.keyConfigured === true;
6149
6504
 
6150
6505
  useEffect(() => {
6151
6506
  if (!open) return undefined;
6152
- const place = () => {
6153
- const rect = buttonRef.current?.getBoundingClientRect?.();
6154
- if (!rect || typeof window === "undefined") return;
6155
- const width = Math.min(340, window.innerWidth - 32);
6156
- const left = Math.max(16, Math.min(rect.left, window.innerWidth - width - 16));
6157
- setPos({ left, bottom: Math.max(16, window.innerHeight - rect.top + 6), width });
6158
- };
6159
- place();
6160
6507
  const onDown = (e) => {
6161
6508
  if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
6162
6509
  };
@@ -6168,11 +6515,9 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6168
6515
  };
6169
6516
  document.addEventListener("mousedown", onDown, true);
6170
6517
  document.addEventListener("keydown", onKey, true);
6171
- window.addEventListener("resize", place);
6172
6518
  return () => {
6173
6519
  document.removeEventListener("mousedown", onDown, true);
6174
6520
  document.removeEventListener("keydown", onKey, true);
6175
- window.removeEventListener("resize", place);
6176
6521
  };
6177
6522
  }, [open]);
6178
6523
 
@@ -6192,10 +6537,11 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6192
6537
  ? h(
6193
6538
  "div",
6194
6539
  {
6540
+ ref: popRef,
6195
6541
  className: "dcpa-q-pop",
6196
6542
  role: "dialog",
6197
6543
  "aria-label": label,
6198
- style: pos ? { left: `${pos.left}px`, bottom: `${pos.bottom}px`, width: `${pos.width}px` } : { visibility: "hidden" },
6544
+ style: popStyle,
6199
6545
  },
6200
6546
  h(
6201
6547
  "div",
@@ -6323,7 +6669,6 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6323
6669
  const [loading, setLoading] = useState(true);
6324
6670
  // Which kind's model menu is open (image / video), or null.
6325
6671
  const [openKind, setOpenKind] = useState(null);
6326
- const [pos, setPos] = useState(null);
6327
6672
  const [busy, setBusy] = useState(false);
6328
6673
  const [error, setError] = useState(null);
6329
6674
  // Bumped to reload while no image model is known yet.
@@ -6333,6 +6678,10 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6333
6678
  const wrapRef = useRef(null);
6334
6679
  const buttonRef = useRef(null);
6335
6680
  const mounted = useRef(true);
6681
+ const popRef = useRef(null);
6682
+ // Anchor the menu to the whole two-button group; it sits left of the
6683
+ // model selector either way.
6684
+ const popStyle = useAnchoredPeek(openKind !== null, wrapRef, popRef);
6336
6685
  const shadowed = useBadgePlacement(placement, sessionId, presence);
6337
6686
  // Icon-only buttons while the composer row is narrow (names move to aria-label).
6338
6687
  const [compact, setCompact] = useState(false);
@@ -6413,16 +6762,6 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6413
6762
 
6414
6763
  useEffect(() => {
6415
6764
  if (openKind === null) return undefined;
6416
- const place = () => {
6417
- // Anchor the menu to the whole two-button group; it sits left of the
6418
- // model selector either way.
6419
- const rect = wrapRef.current?.getBoundingClientRect?.();
6420
- if (!rect || typeof window === "undefined") return;
6421
- const width = Math.min(340, window.innerWidth - 32);
6422
- const left = Math.max(16, Math.min(rect.left, window.innerWidth - width - 16));
6423
- setPos({ left, bottom: Math.max(16, window.innerHeight - rect.top + 6), width });
6424
- };
6425
- place();
6426
6765
  const onDown = (e) => {
6427
6766
  if (wrapRef.current && !wrapRef.current.contains(e.target)) closeMenu();
6428
6767
  };
@@ -6434,11 +6773,9 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6434
6773
  };
6435
6774
  document.addEventListener("mousedown", onDown, true);
6436
6775
  document.addEventListener("keydown", onKey, true);
6437
- window.addEventListener("resize", place);
6438
6776
  return () => {
6439
6777
  document.removeEventListener("mousedown", onDown, true);
6440
6778
  document.removeEventListener("keydown", onKey, true);
6441
- window.removeEventListener("resize", place);
6442
6779
  };
6443
6780
  }, [openKind]);
6444
6781
 
@@ -6626,7 +6963,8 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6626
6963
  className: "dcpa-q-pop dcpa-m-pop",
6627
6964
  role: "dialog",
6628
6965
  "aria-label": showingAgent ? t("mediaAgentSection") : t(activeKind.kind === "image" ? "mediaImageGroup" : "mediaVideoGroup"),
6629
- style: pos ? { left: `${pos.left}px`, bottom: `${pos.bottom}px`, width: `${pos.width}px` } : { visibility: "hidden" },
6966
+ ref: popRef,
6967
+ style: popStyle,
6630
6968
  },
6631
6969
  head,
6632
6970
  ...(showingAgent ? [agentSettings] : [optionGroups(activeKind), agentAvailable ? h("div", { className: "dcpa-m-foot" }, agentButton) : null]),