dsh-model-switch 0.4.61 → 0.4.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## v0.4.62
2
+
3
+ 修复设置页「模型目录偶发加载失败后整个页面卡死」的问题:两个会话在不同供应商上并行、后台任务(如记忆蒸馏)恰在加载瞬间占用 Host 时,`session/modelCatalog` 的一次瞬时失败会把设置页永久留在空目录状态——供应商配置组下拉里所有供应商都带 ⚠、模型下拉没有选项、依赖目录的开关全部禁用,只能重开设置页恢复。
4
+
5
+ - **根因**:`useSettingsCatalog` 只在挂载与供应商排序变化时各加载一次,`.catch()` 只设置错误文案、`groups` 保持 `[]`,没有任何重试或刷新入口。空目录时 `groupProviderChoices` 把每个已配置供应商追加为 `unavailable ⚠`,且宿主目录响应里的 `failures`(哪些供应商只是暂时加载失败)被客户端整个丢弃,"暂时不可用"被渲染成"已删除"。
6
+ - **修复(`src/client/main-row-controller.ts`)**:目录加载改为状态机 `loading / ready / failed`——失败后按 400ms / 1200ms 退避重试(共 3 次尝试),重试成功即自愈;**失败时保留最近一次成功的 groups**(不再把可用目录清空);只有最新一次加载可以落地(取消的加载被丢弃)。新增 `withCatalogFailures()` 把宿主 `failures` 合并为无模型的供应商条目:这些供应商保持可选(不再显示 ⚠),但不发明模型行(种子逻辑因 `models[0]` 为空自动跳过)。`src/client/index.tsx` 的 `loadCatalog` 现在把 `failures` 与 `groups` 一起返回。
7
+ - **UI(`src/client/ModelSwitchSettings.tsx`)**:目录失败时显示明确提示与「重试」按钮;从未加载成功时显示原始失败文案,还留着上一次成功目录时显示"目录暂时不可用(已保存的组仍可编辑)";初始加载期显示"正在加载模型目录…"。供应商配置组的「删除该组」与已选组编辑在目录失败期间保持可用;依赖模型种子的能力开关语义不变(目录为空仍禁用,防误点)。
8
+ - **测试**:`tests/client-controller.spec.ts` 新增 8 条(failures 合并去重、空名回退 id、失败供应商在组编辑器可选、重试助手的首试即成/退避重试/预算用尽抛最后错误/取消即停);`tests/settings-ui.client.spec.tsx` 新增 4 条(加载提示、失败重试按钮触发 reload、残留组可编辑可删除、宿主报失败的供应商不带 ⚠ 且可删除)。`pnpm run check` 全绿(tsc + tsdown + 656 测试 + pack 闸门)。
9
+
1
10
  ## v0.4.61
2
11
 
3
12
  修复 DSH 0.2.1 上**子代理与团队通道全部不可用**的 P0:`spawn_teammate` / `subagent` 一律失败,报 `cannot get property "workingDirectory" without inject`。
@@ -7,8 +16,14 @@
7
16
  - **验证(virtual / 零真实额度)**:DSH `0.2.1-rc.5` lab 的 headless profile(真实宿主 + 虚拟探针 4731,模型回放一次 `subagent` 工具调用)。发布版 **0.4.60** 复现:工具结果为 `Error: cannot get property "workingDirectory" without inject`(会话 `session-f783b457`);装本修复构建后同一回放得到 `started subagent 4b1d65b1-1b91-4b41-a144-41cc7617e039`(`isError:false`,会话 `session-8ea93988`,探针记录 `D:\dsh-artifacts\probe-subagent.jsonl`)。自动审查/命名/记忆等其它接管行未改动。
8
17
  - **残余**:0.4.61 装到桌面 profile 后需实际点一次子代理/团队委派确认(桌面宿主无法在 lab 内复刻)。0.1.7 / 0.2.0 的 `start()` 线依赖列表照旧合并,语义不变。
9
18
 
10
- ## Unreleased
19
+ ## v0.4.63
20
+
21
+ - **子代理停止按钮(`subagents/interruptByParent` definition-unavailable)**:不再用子类替换官方 `@deepseek-ai/dsh-subagent` 运行时。`cordis.patch.yml` 保留官方 `subagent` 行启用(Typert 清单由其包拥有),`src/subagent-runtime.ts` 只在官方实例的 `start` / `startContinuable` / `startActivation` 三个入口上装可恢复包装:用 `symbols.original` 定位官方原对象、按 lease 幂等共享、乱序卸载只恢复自己仍拥有的属性,`prompt` / `interrupt` / `interruptByParent` / Typert 绑定一概不碰;旧的启动辅助与子类保留在 `src/subagent-runtime-legacy.ts` 供已有导入使用(标注 deprecated,不再挂载)。**运行时证据(virtual / 零真实额度)**:DSH `0.2.2-rc.1` lab(`D:/dsh-artifacts/rc1-diff/home-next`,端口 3084)+ 本构建 + `tools/route-probe.mjs`(4719)启动后,按 UI 停止按钮的调用原样发起 `POST /api/subagents/interruptByParent`,返回 `{"ok":true,"value":{"accepted":true}}`(此前为 `gateway/definition-unavailable … strict definition was withdrawn`);同一宿主里 `include:subagent` 仍 active。同一 lab 用探针回放一次 `subagent` 工具调用(子路由分组设为 `apigoto/mimo-v2.6-pro`,会话模型 `gpt-6.1-sol`),探针依次记录 `gpt-6.1-sol`(父)→ `mimo-v2.6-pro`(子代理实际请求)→ `gpt-6.1-sol`(父续跑),即子代理请求携带的正是 Model Switch 计算的 provider/model。把 lab 的 bundles 换成 `@deepseek-ai/dsh-experimental-agent-team-profile` 后,回放 `spawn_teammate`(`context: fresh` 与 `fork` 各一次)同样出现 `mimo-v2.6-pro` 的子请求,证明 Teams 创建成员走官方运行时且继承同一路由;`spawn_teammate` 工具本身返回成功(否则不会产生子请求)。证据:`D:/dsh-artifacts/subagent-route-stop/lab/report-*.json`、`delegation3.log`、`teams.log`、`teams-fork.log`。
22
+ - **计划审查卡模型菜单裁切/错位**:菜单改为独立 Portal(`document.body`,`data-dsh-plan-review-menu`),`popup-placement.ts` 纯函数产出 `--dsh-menu-top/right/max-height` 三个变量,样式表再组合 `env(safe-area-inset-*)` 与 56dvh 上限;`useComposerPickerSurface` 用 `useLayoutEffect` + `ResizeObserver(trigger+menu)` + `resize`/捕获 `scroll` 幂等重定位(相等守卫防自回写),Escape 分层(搜索→根→关闭并回焦)、外点消失、SSR 无 `document` 时不渲染弹层。`tests/picker` 21 文件 / **166 测试**全绿(含真实 DOM portal 几何与 320px 右移基线)。浏览器视觉复核已完成(无头 Edge + CDP,1300×626):composer 模型 chip 的菜单与 PlanReviewCard 共用同一 `ComposerPicker` 组件与 `useComposerPickerSurface` hook,实测 Portal 为 `document.body` 直接子节点、`position:fixed`、右缘与触发器对齐(差 0px)、上方放置、完全在视口内、CSS 变量 `--dsh-menu-top/right/max-height` 均正确写入。截图:`D:/dsh-artifacts/subagent-route-stop/lab/picker-menu.png`。
23
+ - **随对话更新的标题(all-prompts)路由**:`src/title-settings-reader.ts` 改为每次调用先读 `ctx.get('modelSwitch')`(active-only 严格读),再回落到 scoped `ctx.inject` 子作用域;读不到/抛错一律返回 undefined,回到官方回退且不阻塞行。**rc.1 实机定位到的两处真实缺陷**:①监听器把 `this`(发射上下文)当成事件负载,`loader/partial-dispose` 拿不到 entry,导致启动过程中无关条目的 teardown 释放槽位后不再重领——命名 provider 静默消失、标题退回截断文案;现改为优先取第一个参数并用 entry 形状判定。②无关条目的 `partial-dispose` 不再释放命名槽位,只有官方命名行消失才释放并重领。**运行时证据(virtual / 零真实额度)**:rc.1 lab 中一次会话发两条消息,探针记录 `gpt-6.1-sol`(会话模型)与 `mimo-v2.6-flash`(配置的标题模型)交替出现,即每轮对话都触发标题更新且走 Model Switch 标题路由。热切换用同一 `settings/update` 验证:只改扁平 `titleProvider/titleModel` 时第二条标题仍走旧模型——这是**有意优先级**(会话 provider `apigoto` 存有分组,分组 pin 优先于扁平对),不是缓存;把该分组的 `titleModel` 一并改到 `mimo-v2.6-pro` 后,下一次标题请求即使用 `mimo-v2.6-pro`,无需重启。**热切换已验收。**
24
+ - 说明:本轮所有改动均未提交、未打标签、未推送、未发 npm、未安装到桌面 profile(按用户指示,等“发布并推送”)。`pnpm run check` 全绿:69 文件 / 678 测试 + pack 闸门。
11
25
 
26
+ - **0.4.62 无头 lab 补验(2026-11-05,virtual / 零真实额度)**:DSH `0.2.1-rc.5` lab(`D:\dsh-lab`,3082)+ `dsh-model-switch@0.4.62` 本地构建产物 + `tools/route-probe.mjs`(4731),用 dsh-browser-cdp 全程无头运行。基线目录加载正常(供应商下拉 8 项、无 ⚠);页面级仅拦截 `POST /session/modelCatalog` 做确定性故障注入:前 2 次失败后第 3 次成功,自动恢复无点击(calls=3, faulted=2);连续 3 次失败时显示错误与「重试」,「保存」「删除该组」保持可用;清除故障后点「重试」一次即恢复完整目录(calls=5, faulted=4,0 ⚠)。另在新建会话经 UI 发起一次真实工具调用:1 轮 2 步、页面显示「已读取文件」与 `ok`,探针记录 `deepseek-flash tool=read` → `mimo-v2.6-flash`(会话命名)→ `deepseek-flash` 后续请求,无 inactive context / body-not-executed 报错。宿主报告的 `ModelCatalogFailure` 合并在 lab 不可复现(pi-ai 提供商目录为静态配置,停探针不会让 `listModels` 抛错),该路径由 `tests/client-controller.spec.ts` 覆盖。证据:`D:\dsh-artifacts\lab-0462-evidence.json`、`D:\dsh-artifacts\probe-lab-0462-tool.jsonl`;宿主与探针已停止,3082/4731 已释放,lab 恢复为 npm `0.4.62`,桌面 profile 未改动。**仅文档,不发版。**
12
27
  - **兼容巡检(2026-11-02,仅文档)**:DSH `latest` 仍是 `0.2.1-rc.5`(未移动,10-30/31 的验收结论继续有效);`dsh-prime-memory` 从 **0.26.16 移到 0.26.24**,其 `engines.dsh` 含 rc.5,已在 rc.5 lab + 本插件 0.4.60 下跑完七项接入检查(行激活、适配推送落地、无 `llm:` 静态钉、`settings-set` 读回、`effectiveCfg` 单测 9/9、免重启改路由 `replays:1→2`、蒸馏走新路由)。`docs/compat-watch-state.json` 记录 0.26.24 为已验证版本。**无代码改动,不发版。**
13
28
 
14
29
  ## v0.4.60
package/cordis.patch.yml CHANGED
@@ -1,14 +1,11 @@
1
- # Replace independently packaged host modules only through public profile patches.
2
- # Existing rows are disabled with their original name; replacements use unique ids.
1
+ # Adapt public DSH rows only through profile patches and released runtime APIs.
3
2
  # Do not replace agent-presets: a nested AgentPresets instance loads a second
4
3
  # @deepseek-ai/dsh-scope identity, and session.create then fails as unscoped.
4
+ # Keep the official Subagent row enabled: its package-owned Typert manifest
5
+ # defines prompt/interruptByParent. The inserted adapter wraps only start methods.
5
6
  # Web selection is a deployment opt-in: preserve the existing complete Web config.
6
7
  # An id-targeted config patch replaces (not merges) it, including fetchProvider.
7
8
 
8
- - id: subagent
9
- name: '@deepseek-ai/dsh-subagent'
10
- disabled: true
11
-
12
9
  # The official Auto reviewer hardwires the session route; Model Switch replaces
13
10
  # it with its own row so the reviewer model stays configurable (one registerAuto
14
11
  # per context). A profile that never enabled the optional bundle has no such
package/lib/client.js CHANGED
@@ -1141,8 +1141,10 @@ window.__ModuleLoader__.load({
1141
1141
  * catalog-only list makes that group unreachable: the row stays stored, no
1142
1142
  * selection can open it, and nothing can delete it. Union in every configured
1143
1143
  * group's provider and mark the missing ones unavailable so the editor can still
1144
- * open and remove them.
1145
- * @param groups - the live model catalog.
1144
+ * open and remove them. Feed this the merged list from `withCatalogFailures` so
1145
+ * a provider that merely failed to load stays selectable instead of looking
1146
+ * deleted.
1147
+ * @param groups - the live model catalog merged with the host's load failures.
1146
1148
  * @param configured - provider ids that still have a stored group.
1147
1149
  * @param current - the group being edited, kept listed even when it is unknown.
1148
1150
  * @returns catalog choices first (original order), then the missing providers.
@@ -1161,38 +1163,110 @@ window.__ModuleLoader__.load({
1161
1163
  }
1162
1164
  return choices;
1163
1165
  }
1164
- /** Load the model catalog backing every route editor, reloading on provider-order changes. */
1166
+ /** Backoff between catalog retries: a busy Host clears within seconds, not minutes. */
1167
+ const CATALOG_RETRY_DELAYS_MS = [400, 1200];
1168
+ /**
1169
+ * Load the model catalog with bounded backoff.
1170
+ *
1171
+ * The catalog RPC is one read against a live Host; a transient failure (a busy
1172
+ * Host, a reconnecting remote, a background task saturating the provider
1173
+ * lookups) must recover on its own instead of leaving the settings page stuck
1174
+ * on an empty catalog. Each attempt re-runs `load`; a cancelled load rethrows
1175
+ * the last error without further attempts.
1176
+ */
1177
+ async function loadCatalogWithRetry(load, options = {}) {
1178
+ const attempts = options.attempts ?? 3;
1179
+ const delaysMs = options.delaysMs ?? CATALOG_RETRY_DELAYS_MS;
1180
+ const sleep = options.sleep ?? ((ms) => new Promise((resolve) => {
1181
+ setTimeout(resolve, ms);
1182
+ }));
1183
+ let lastError;
1184
+ for (let attempt = 0; attempt < attempts; attempt += 1) {
1185
+ if (attempt > 0) await sleep(delaysMs[Math.min(attempt - 1, delaysMs.length - 1)] ?? 0);
1186
+ if (options.cancelled?.() === true) break;
1187
+ try {
1188
+ return await load();
1189
+ } catch (error) {
1190
+ lastError = error;
1191
+ }
1192
+ }
1193
+ throw lastError instanceof Error ? lastError : /* @__PURE__ */ new Error("catalog load failed");
1194
+ }
1195
+ /**
1196
+ * Merge the host's load failures into the catalog as model-less groups.
1197
+ *
1198
+ * A failed provider is KNOWN (the Host listed it) but temporarily unavailable.
1199
+ * Rendering it as absent would mark every stored route for it "unavailable ⚠"
1200
+ * and lock the provider-group editor while a background task hiccups. A
1201
+ * model-less group keeps the provider selectable without inventing model rows;
1202
+ * seeding logic skips it because `models[0]` is undefined.
1203
+ */
1204
+ function withCatalogFailures(groups, failures) {
1205
+ const known = new Set(groups.map((group) => group.id));
1206
+ const extra = failures.filter((failure) => failure.id.trim() !== "" && !known.has(failure.id)).map((failure) => ({
1207
+ id: failure.id,
1208
+ name: failure.name.trim() === "" ? failure.id : failure.name,
1209
+ models: []
1210
+ }));
1211
+ return [...groups, ...extra];
1212
+ }
1213
+ /**
1214
+ * Load the model catalog backing every route editor, with bounded retries.
1215
+ *
1216
+ * A failed load keeps the last successful groups (the editor stays usable and
1217
+ * honest via the error hint) instead of collapsing to an empty catalog; a
1218
+ * provider-order change or `reload()` starts a fresh attempt, and only the
1219
+ * newest attempt may land.
1220
+ */
1165
1221
  function useSettingsCatalog(input) {
1166
- const [groups, setGroups] = (0, react.useState)([]);
1167
- const [catalogError, setCatalogError] = (0, react.useState)();
1168
- (0, react.useEffect)(() => {
1169
- let live = true;
1170
- const load = () => {
1171
- input.loadCatalog().then((value) => {
1172
- if (live) {
1173
- setGroups(value);
1174
- setCatalogError(void 0);
1175
- }
1176
- }).catch(() => {
1177
- if (live) setCatalogError(input.t("catalogFailed"));
1222
+ const [state, setState] = (0, react.useState)({
1223
+ status: "loading",
1224
+ groups: [],
1225
+ failures: [],
1226
+ error: void 0
1227
+ });
1228
+ const latest = (0, react.useRef)(input);
1229
+ latest.current = input;
1230
+ const runRef = (0, react.useRef)(0);
1231
+ const run = (0, react.useCallback)(() => {
1232
+ const runId = runRef.current + 1;
1233
+ runRef.current = runId;
1234
+ setState((previous) => ({
1235
+ ...previous,
1236
+ status: "loading"
1237
+ }));
1238
+ loadCatalogWithRetry(() => latest.current.loadCatalog(), { cancelled: () => runId !== runRef.current }).then((payload) => {
1239
+ if (runId !== runRef.current) return;
1240
+ setState({
1241
+ status: "ready",
1242
+ groups: withCatalogFailures(payload.groups, payload.failures),
1243
+ failures: payload.failures,
1244
+ error: void 0
1178
1245
  });
1179
- };
1180
- load();
1181
- const stop = input.subscribeProviderOrder?.(() => {
1182
- if (live) load();
1246
+ }).catch(() => {
1247
+ if (runId !== runRef.current) return;
1248
+ setState((previous) => ({
1249
+ ...previous,
1250
+ status: "failed",
1251
+ error: latest.current.t("catalogFailed")
1252
+ }));
1253
+ });
1254
+ }, []);
1255
+ const subscribeRef = (0, react.useRef)(input.subscribeProviderOrder);
1256
+ subscribeRef.current = input.subscribeProviderOrder;
1257
+ (0, react.useEffect)(() => {
1258
+ run();
1259
+ const stop = subscribeRef.current?.(() => {
1260
+ run();
1183
1261
  });
1184
1262
  return () => {
1185
- live = false;
1263
+ runRef.current += 1;
1186
1264
  stop?.();
1187
1265
  };
1188
- }, [
1189
- input.loadCatalog,
1190
- input.subscribeProviderOrder,
1191
- input.t
1192
- ]);
1266
+ }, [run]);
1193
1267
  return {
1194
- groups,
1195
- catalogError
1268
+ ...state,
1269
+ reload: run
1196
1270
  };
1197
1271
  }
1198
1272
  //#endregion
@@ -1650,7 +1724,7 @@ window.__ModuleLoader__.load({
1650
1724
  return choices;
1651
1725
  }
1652
1726
  function ModelSwitchSettings(props) {
1653
- const { groups, catalogError } = useSettingsCatalog(props);
1727
+ const { groups, status: catalogStatus, error: catalogError, reload: reloadCatalog } = useSettingsCatalog(props);
1654
1728
  const subagent = props.useSubagentSettings((value) => value);
1655
1729
  const search = props.useSearchSettings((value) => value);
1656
1730
  const image = props.useImageSettings((value) => value);
@@ -2289,9 +2363,21 @@ window.__ModuleLoader__.load({
2289
2363
  className: ModelSwitchSettings_module_css_default.saved,
2290
2364
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", { className: ModelSwitchSettings_module_css_default.savedDot }), synced ? props.t("settingsSynced") : props.t("loading")]
2291
2365
  }),
2292
- catalogError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2366
+ catalogError === void 0 ? catalogStatus === "loading" && groups.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2367
+ className: ModelSwitchSettings_module_css_default.hint,
2368
+ children: props.t("catalogLoading")
2369
+ }) : null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2293
2370
  className: cx(ModelSwitchSettings_module_css_default.hint, ModelSwitchSettings_module_css_default.message),
2294
- children: catalogError
2371
+ children: [
2372
+ groups.length === 0 ? catalogError : props.t("catalogUnavailableHint"),
2373
+ " ",
2374
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2375
+ type: "button",
2376
+ className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
2377
+ onClick: reloadCatalog,
2378
+ children: props.t("catalogRetry")
2379
+ })
2380
+ ]
2295
2381
  }),
2296
2382
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2297
2383
  className: ModelSwitchSettings_module_css_default.group,
@@ -3397,6 +3483,9 @@ window.__ModuleLoader__.load({
3397
3483
  loading: "正在加载设置…",
3398
3484
  requestFailed: "保存失败",
3399
3485
  catalogFailed: "无法加载模型目录。",
3486
+ catalogLoading: "正在加载模型目录…",
3487
+ catalogRetry: "重试",
3488
+ catalogUnavailableHint: "模型目录暂时不可用(后台任务繁忙或 Host 忙碌时会偶发);已显示的供应商与已保存的组仍可编辑,也可点击重试。",
3400
3489
  autoReview: "自动审查模型",
3401
3490
  autoReviewFollow: "跟随会话模型",
3402
3491
  autoReviewHelp: "为官方 auto-review(Auto 权限预设的逐调用审查)指定审查模型;需启用官方 auto-review 能力包。关闭时审查跟随当前会话模型。本插件启用时,官方「自动审查」组件由本插件接管。",
@@ -3494,6 +3583,9 @@ window.__ModuleLoader__.load({
3494
3583
  loading: "Loading settings…",
3495
3584
  requestFailed: "Save failed",
3496
3585
  catalogFailed: "Could not load the model catalog.",
3586
+ catalogLoading: "Loading the model catalog…",
3587
+ catalogRetry: "Retry",
3588
+ catalogUnavailableHint: "The model catalog is temporarily unavailable (it can hiccup while a background task or the Host is busy); the providers shown and saved groups stay editable, or retry now.",
3497
3589
  autoReview: "Auto review model",
3498
3590
  autoReviewFollow: "Follows the session model",
3499
3591
  autoReviewHelp: "Pin the reviewer model for the official auto-review gate (per-call review under the Auto permission preset). Requires the official auto-review bundle. When off, reviews follow the session model. With this plugin enabled the official auto-review component is taken over.",
@@ -3878,16 +3970,65 @@ window.__ModuleLoader__.load({
3878
3970
  };
3879
3971
  }
3880
3972
  //#endregion
3973
+ //#region src/client/picker/popup-placement.ts
3974
+ function samePlacement(left, right) {
3975
+ return left !== void 0 && left["--dsh-menu-top"] === right["--dsh-menu-top"] && left["--dsh-menu-right"] === right["--dsh-menu-right"] && left["--dsh-menu-max-height"] === right["--dsh-menu-max-height"] && left.visibility === right.visibility;
3976
+ }
3977
+ /**
3978
+ * Narrow-screen reservation: the right clamp keeps this much viewport width
3979
+ * clear to the menu's left even when right-aligning to the trigger would
3980
+ * push the left edge off-screen (the pre-portal behavior base).
3981
+ */
3982
+ const PREFERRED_WIDTH = 320;
3983
+ const FALLBACK_WIDTH = 280;
3984
+ const FALLBACK_HEIGHT = 220;
3985
+ /**
3986
+ * Position the portaled picker menu in viewport coordinates, right-aligned to
3987
+ * its trigger and preferring the space above it, clamped to the viewport.
3988
+ */
3989
+ /**
3990
+ * Position the portaled picker menu in viewport coordinates, right-aligned to
3991
+ * its trigger and preferring the space above it, clamped to the viewport.
3992
+ *
3993
+ * The height clamp is the viewport budget only (never a content measurement):
3994
+ * the stylesheet caps the box at that budget, so taller menu panes grow into
3995
+ * it naturally and a later ResizeObserver pass only re-reads the rendered box
3996
+ * to re-anchor the trigger edge. Capping from the measured box would instead
3997
+ * lock the menu at whatever height it first rendered with.
3998
+ */
3999
+ function placeComposerPopup({ trigger, menu, viewport, gutter = 8 }) {
4000
+ const maxWidth = Math.max(0, viewport.width - gutter * 2);
4001
+ const width = Math.min(menu.width || FALLBACK_WIDTH, maxWidth);
4002
+ const reserve = Math.max(Math.min(PREFERRED_WIDTH, maxWidth), width);
4003
+ const right = Math.min(Math.max(gutter, viewport.width - trigger.right), Math.max(gutter, viewport.width - gutter - reserve));
4004
+ const spaceAbove = Math.max(0, trigger.top - gutter * 2);
4005
+ const spaceBelow = Math.max(0, viewport.height - trigger.bottom - gutter * 2);
4006
+ const placeAbove = spaceAbove >= Math.min(menu.height, 180) || spaceAbove >= spaceBelow;
4007
+ const availableHeight = Math.max(0, (placeAbove ? spaceAbove : spaceBelow) - gutter);
4008
+ return {
4009
+ "--dsh-menu-top": `${placeAbove ? Math.max(gutter, trigger.top - gutter - Math.min(menu.height || FALLBACK_HEIGHT, availableHeight)) : Math.min(Math.max(gutter, trigger.bottom + gutter), Math.max(gutter, viewport.height - gutter - Math.min(menu.height || FALLBACK_HEIGHT, availableHeight)))}px`,
4010
+ "--dsh-menu-right": `${right}px`,
4011
+ "--dsh-menu-max-height": `${availableHeight}px`,
4012
+ visibility: "visible"
4013
+ };
4014
+ }
4015
+ //#endregion
3881
4016
  //#region src/client/picker/useComposerPickerSurface.ts
3882
- /** Own popup activation, positioning, and dismissal behind one internal seam. */
4017
+ /** camelCase React style keys to hyphenated CSS custom-value writes. */
4018
+ function applyPopupStyle(target, style) {
4019
+ if (target === void 0) return;
4020
+ for (const [property, value] of Object.entries(style)) {
4021
+ if (value === void 0) continue;
4022
+ const rendered = typeof value === "number" && property !== "zIndex" ? `${value}px` : String(value);
4023
+ target.setProperty(property.replace(/[A-Z]/gu, (char) => `-${char.toLowerCase()}`), rendered);
4024
+ }
4025
+ }
4026
+ /** Own popup activation, viewport placement, and dismissal behind one internal seam. */
3883
4027
  function useComposerPickerSurface(options) {
3884
4028
  const [open, setOpen] = (0, react.useState)(false);
3885
- const [menuStyle, setMenuStyle] = (0, react.useState)({
3886
- position: "fixed",
3887
- zIndex: 4e3
3888
- });
3889
4029
  const triggerRef = (0, react.useRef)(null);
3890
4030
  const menuRef = (0, react.useRef)(null);
4031
+ const placementRef = (0, react.useRef)();
3891
4032
  const pointerOpenIntent = (0, react.useRef)(null);
3892
4033
  const callbacks = (0, react.useRef)({
3893
4034
  onOpen: options.onOpen,
@@ -3902,6 +4043,7 @@ window.__ModuleLoader__.load({
3902
4043
  const id = (0, react.useId)();
3903
4044
  const close = (0, react.useCallback)((restoreFocus = false) => {
3904
4045
  setOpen(false);
4046
+ placementRef.current = void 0;
3905
4047
  callbacks.current.onClose();
3906
4048
  if (restoreFocus) queueMicrotask(() => {
3907
4049
  triggerRef.current?.focus();
@@ -3916,29 +4058,54 @@ window.__ModuleLoader__.load({
3916
4058
  (0, react.useEffect)(() => {
3917
4059
  if (options.locked) close();
3918
4060
  }, [close, options.locked]);
4061
+ /**
4062
+ * Keep the portaled menu glued to its trigger in viewport coordinates:
4063
+ * measure once per commit, then follow resizes, scrolls, and menu size
4064
+ * changes through listeners instead of re-rendering.
4065
+ */
3919
4066
  (0, react.useLayoutEffect)(() => {
3920
- if (!open) return;
4067
+ if (!open || typeof window === "undefined") return;
4068
+ const place = () => {
4069
+ const trigger = triggerRef.current;
4070
+ const menu = menuRef.current;
4071
+ if (trigger === null || menu === null) return;
4072
+ const rect = trigger.getBoundingClientRect();
4073
+ const measured = menu.getBoundingClientRect();
4074
+ const bounds = {
4075
+ width: measured.width || Math.min(280, window.innerWidth - 16),
4076
+ height: measured.height || menu.scrollHeight || 220
4077
+ };
4078
+ const next = placeComposerPopup({
4079
+ trigger: rect,
4080
+ menu: {
4081
+ width: bounds.width,
4082
+ height: bounds.height
4083
+ },
4084
+ viewport: {
4085
+ width: window.innerWidth,
4086
+ height: window.innerHeight
4087
+ }
4088
+ });
4089
+ if (samePlacement(placementRef.current, next)) return;
4090
+ placementRef.current = next;
4091
+ applyPopupStyle(menu.style, next);
4092
+ };
4093
+ place();
3921
4094
  const trigger = triggerRef.current;
3922
- if (trigger === null) return;
3923
- const rect = trigger.getBoundingClientRect();
3924
- const gutter = 8;
3925
- const maxWidth = Math.min(420, window.innerWidth - 16);
3926
- const preferredWidth = Math.min(320, maxWidth);
3927
- const safeRight = "max(" + Math.min(Math.max(gutter, window.innerWidth - rect.right), Math.max(gutter, window.innerWidth - gutter - preferredWidth)) + "px, calc(env(safe-area-inset-right) + 8px))";
3928
- setMenuStyle({
3929
- position: "fixed",
3930
- right: safeRight,
3931
- bottom: "max(" + Math.max(gutter, window.innerHeight - rect.top + gutter) + "px, calc(env(safe-area-inset-bottom) + 8px))",
3932
- maxWidth: "max(0px, calc(100vw - " + safeRight + " - env(safe-area-inset-left) - 8px))",
3933
- zIndex: 4e3
3934
- });
3935
- }, [
3936
- open,
3937
- options.embedded,
3938
- options.pane
3939
- ]);
4095
+ const menu = menuRef.current;
4096
+ const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(place);
4097
+ if (trigger !== null) observer?.observe(trigger);
4098
+ if (menu !== null) observer?.observe(menu);
4099
+ window.addEventListener("resize", place);
4100
+ window.addEventListener("scroll", place, true);
4101
+ return () => {
4102
+ observer?.disconnect();
4103
+ window.removeEventListener("resize", place);
4104
+ window.removeEventListener("scroll", place, true);
4105
+ };
4106
+ }, [open, options.pane]);
3940
4107
  (0, react.useEffect)(() => {
3941
- if (!open || options.tone === "capsule") return;
4108
+ if (!open || typeof document === "undefined") return;
3942
4109
  const interaction = options.resolveInteractionOperations?.();
3943
4110
  return installPickerDismissal({
3944
4111
  documentTarget: document,
@@ -3952,13 +4119,11 @@ window.__ModuleLoader__.load({
3952
4119
  close,
3953
4120
  id,
3954
4121
  open,
3955
- options.resolveInteractionOperations,
3956
- options.tone
4122
+ options.resolveInteractionOperations
3957
4123
  ]);
3958
4124
  return {
3959
4125
  id,
3960
4126
  open,
3961
- menuStyle,
3962
4127
  triggerRef,
3963
4128
  menuRef,
3964
4129
  show,
@@ -4231,7 +4396,7 @@ window.__ModuleLoader__.load({
4231
4396
  }
4232
4397
  //#endregion
4233
4398
  //#region \0dsh-css:src/client/picker/ComposerPicker.module.css.mjs
4234
- const css$1 = ".GdQohq_root{min-width:0;position:relative}.GdQohq_trigger{width:fit-content;min-width:0;max-width:256px;min-height:28px;color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xs-strong-13);cursor:pointer;background:0 0;border:none;border-radius:24px;outline:none;align-items:center;gap:4px;padding:4px 4px 4px 8px;display:flex}.GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-border-l3)}.GdQohq_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.GdQohq_triggerLabel{overflow-wrap:normal;text-overflow:ellipsis;white-space:nowrap;align-items:center;gap:4px;min-width:0;display:inline-flex;overflow:hidden}.GdQohq_triggerEffort{color:var(--dsw-alias-label-caption);flex:none}.GdQohq_chevron{color:var(--dsw-alias-label-caption);transition:transform .12s var(--ds-ease-in-out);flex:none}.GdQohq_chevronOpen{transform:rotate(180deg)}.GdQohq_embedded{width:100%}.GdQohq_embedded .GdQohq_trigger{background:var(--dsw-alias-interactive-bg-hover);width:100%;max-width:none;min-height:36px;color:var(--dsw-alias-label-primary);border-radius:10px;justify-content:space-between;padding:4px 10px}.GdQohq_embedded .GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_capsule{width:100%}.GdQohq_capsule .GdQohq_trigger{border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-input-major);width:100%;max-width:none;min-height:32px;color:var(--dsw-alias-label-primary);border-radius:24px;justify-content:space-between;padding:4px 8px 4px 10px}.GdQohq_capsule .GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_menu{box-sizing:border-box;width:min(280px, max(0px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))));max-height:min(360px, calc(56dvh - env(safe-area-inset-bottom)));border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border-radius:12px;flex-direction:column;padding:4px;display:flex;overflow:hidden}.GdQohq_paneHeader{flex:none;grid-template-columns:32px minmax(0,1fr) 32px;align-items:center;gap:8px;min-height:40px;padding:2px 4px;display:grid}.GdQohq_paneHeader .GdQohq_headerButton{width:32px;min-width:32px;height:32px;color:var(--dsw-alias-label-secondary);padding:0}.GdQohq_paneHeader .GdQohq_headerButton:last-child{justify-self:end}.GdQohq_paneTitle{min-width:0;color:var(--dsw-alias-label-primary);font:var(--dsw-font-s-strong-14);overflow-wrap:anywhere;text-align:center;padding:4px 8px}.GdQohq_searchSlot{min-width:0;overflow:hidden}.GdQohq_headerSearch{box-sizing:border-box;width:100%;min-width:0;max-width:100%;display:flex}.GdQohq_headerSearch input::-webkit-search-cancel-button{display:none}.GdQohq_list{min-height:0;overflow:hidden auto}.GdQohq_status,.GdQohq_empty{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);overflow-wrap:anywhere;padding:10px}.GdQohq_error,.GdQohq_warning{background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);font:var(--dsw-font-xxs-12);overflow-wrap:anywhere;border-radius:8px;justify-content:space-between;align-items:flex-start;gap:8px;margin-bottom:4px;padding:7px 8px;display:flex}.GdQohq_warning{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-state-warn-label)}.GdQohq_retry{color:inherit;font:var(--dsw-font-xxs-strong-12);cursor:pointer;background:0 0;border:none;flex:none;padding:0}.GdQohq_groups{min-height:0}.GdQohq_group+.GdQohq_group{margin-top:4px}.GdQohq_groupTitle{z-index:1;background:var(--dsw-specific-menu);color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-strong-12);overflow-wrap:anywhere;align-items:center;gap:6px;padding:5px 8px 3px;display:flex;position:sticky;top:0}.GdQohq_runtimeMark{min-width:14px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-strong-12);justify-content:center;align-items:center;display:inline-flex}.GdQohq_runtimeMark svg{width:14px;height:14px;display:block}.GdQohq_option{box-sizing:border-box;width:auto;min-width:100%;min-height:38px;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;border-radius:10px;outline:none;align-items:center;gap:8px;padding:6px 8px;display:flex}.GdQohq_option:hover:not(:disabled),.GdQohq_option:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_selected{background:0 0}.GdQohq_option:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.GdQohq_optionCopy{flex-direction:column;flex:1;min-width:0;display:flex}.GdQohq_modelName{color:inherit;font:var(--dsw-font-s-strong-14);overflow-wrap:anywhere}.GdQohq_description{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-12);overflow-wrap:anywhere}.GdQohq_check{color:var(--dsw-alias-label-primary);flex:0 0 18px;place-items:center;display:grid}.GdQohq_cell{box-sizing:border-box;width:auto;min-width:100%;height:40px;min-height:40px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-s-14);cursor:pointer;text-align:left;background:0 0;border:none;border-radius:10px;align-items:center;gap:8px;padding:0 10px;display:flex}.GdQohq_cell:hover{background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_cellLabel{white-space:nowrap;flex:none}.GdQohq_cellValue{min-width:0;color:var(--dsw-alias-label-tertiary);text-align:right;text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.GdQohq_cellChevron{color:var(--dsw-alias-label-tertiary);flex:none}";
4399
+ const css$1 = ".GdQohq_root{min-width:0;position:relative}.GdQohq_trigger{width:fit-content;min-width:0;max-width:256px;min-height:28px;color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xs-strong-13);cursor:pointer;background:0 0;border:none;border-radius:24px;outline:none;align-items:center;gap:4px;padding:4px 4px 4px 8px;display:flex}.GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-border-l3)}.GdQohq_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.GdQohq_triggerLabel{overflow-wrap:normal;text-overflow:ellipsis;white-space:nowrap;align-items:center;gap:4px;min-width:0;display:inline-flex;overflow:hidden}.GdQohq_triggerEffort{color:var(--dsw-alias-label-caption);flex:none}.GdQohq_chevron{color:var(--dsw-alias-label-caption);transition:transform .12s var(--ds-ease-in-out);flex:none}.GdQohq_chevronOpen{transform:rotate(180deg)}.GdQohq_embedded{width:100%}.GdQohq_embedded .GdQohq_trigger{background:var(--dsw-alias-interactive-bg-hover);width:100%;max-width:none;min-height:36px;color:var(--dsw-alias-label-primary);border-radius:10px;justify-content:space-between;padding:4px 10px}.GdQohq_embedded .GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_capsule{width:100%}.GdQohq_capsule .GdQohq_trigger{border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-input-major);width:100%;max-width:none;min-height:32px;color:var(--dsw-alias-label-primary);border-radius:24px;justify-content:space-between;padding:4px 8px 4px 10px}.GdQohq_capsule .GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_menu{box-sizing:border-box;width:min(280px, max(0px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))));top:max(var(--dsh-menu-top,8px), calc(env(safe-area-inset-top) + 8px));right:max(var(--dsh-menu-right,8px), calc(env(safe-area-inset-right) + 8px));max-height:min(var(--dsh-menu-max-height,360px), calc(56dvh - env(safe-area-inset-bottom) - env(safe-area-inset-top)));visibility:hidden;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border-radius:12px;flex-direction:column;padding:4px;display:flex;overflow:hidden}.GdQohq_paneHeader{flex:none;grid-template-columns:32px minmax(0,1fr) 32px;align-items:center;gap:8px;min-height:40px;padding:2px 4px;display:grid}.GdQohq_paneHeader .GdQohq_headerButton{width:32px;min-width:32px;height:32px;color:var(--dsw-alias-label-secondary);padding:0}.GdQohq_paneHeader .GdQohq_headerButton:last-child{justify-self:end}.GdQohq_paneTitle{min-width:0;color:var(--dsw-alias-label-primary);font:var(--dsw-font-s-strong-14);overflow-wrap:anywhere;text-align:center;padding:4px 8px}.GdQohq_searchSlot{min-width:0;overflow:hidden}.GdQohq_headerSearch{box-sizing:border-box;width:100%;min-width:0;max-width:100%;display:flex}.GdQohq_headerSearch input::-webkit-search-cancel-button{display:none}.GdQohq_list{min-height:0;overflow:hidden auto}.GdQohq_status,.GdQohq_empty{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);overflow-wrap:anywhere;padding:10px}.GdQohq_error,.GdQohq_warning{background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);font:var(--dsw-font-xxs-12);overflow-wrap:anywhere;border-radius:8px;justify-content:space-between;align-items:flex-start;gap:8px;margin-bottom:4px;padding:7px 8px;display:flex}.GdQohq_warning{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-state-warn-label)}.GdQohq_retry{color:inherit;font:var(--dsw-font-xxs-strong-12);cursor:pointer;background:0 0;border:none;flex:none;padding:0}.GdQohq_groups{min-height:0}.GdQohq_group+.GdQohq_group{margin-top:4px}.GdQohq_groupTitle{z-index:1;background:var(--dsw-specific-menu);color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-strong-12);overflow-wrap:anywhere;align-items:center;gap:6px;padding:5px 8px 3px;display:flex;position:sticky;top:0}.GdQohq_runtimeMark{min-width:14px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-strong-12);justify-content:center;align-items:center;display:inline-flex}.GdQohq_runtimeMark svg{width:14px;height:14px;display:block}.GdQohq_option{box-sizing:border-box;width:auto;min-width:100%;min-height:38px;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;border-radius:10px;outline:none;align-items:center;gap:8px;padding:6px 8px;display:flex}.GdQohq_option:hover:not(:disabled),.GdQohq_option:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_selected{background:0 0}.GdQohq_option:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.GdQohq_optionCopy{flex-direction:column;flex:1;min-width:0;display:flex}.GdQohq_modelName{color:inherit;font:var(--dsw-font-s-strong-14);overflow-wrap:anywhere}.GdQohq_description{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-12);overflow-wrap:anywhere}.GdQohq_check{color:var(--dsw-alias-label-primary);flex:0 0 18px;place-items:center;display:grid}.GdQohq_cell{box-sizing:border-box;width:auto;min-width:100%;height:40px;min-height:40px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-s-14);cursor:pointer;text-align:left;background:0 0;border:none;border-radius:10px;align-items:center;gap:8px;padding:0 10px;display:flex}.GdQohq_cell:hover{background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_cellLabel{white-space:nowrap;flex:none}.GdQohq_cellValue{min-width:0;color:var(--dsw-alias-label-tertiary);text-align:right;text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.GdQohq_cellChevron{color:var(--dsw-alias-label-tertiary);flex:none}";
4235
4400
  const tagId$1 = "dsh-model-switch/ComposerPicker.module.css";
4236
4401
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
4237
4402
  const tag = document.createElement("style");
@@ -4365,7 +4530,7 @@ window.__ModuleLoader__.load({
4365
4530
  lastActionRef.current = "load";
4366
4531
  load();
4367
4532
  };
4368
- const { id, open, menuStyle, triggerRef, menuRef, close, onTriggerPointerDown, onTriggerClick } = useComposerPickerSurface({
4533
+ const { id, open, triggerRef, menuRef, close, onTriggerPointerDown, onTriggerClick } = useComposerPickerSurface({
4369
4534
  locked,
4370
4535
  embedded: embedded ?? false,
4371
4536
  pane,
@@ -4471,16 +4636,15 @@ window.__ModuleLoader__.load({
4471
4636
  const contextDisplay = (label) => label === "standard" ? t("context.standard") : label;
4472
4637
  const triggerLabel = triggerBits.join(" · ");
4473
4638
  const triggerAria = currentSelection === null ? t("trigger.selectAria") : t("trigger.aria", { model: triggerLabel });
4474
- const onRootKeyDown = (event) => {
4475
- if (lockedRef.current) return;
4476
- if (event.key === "Escape" && open) {
4477
- event.preventDefault();
4478
- if (pane === "model" && searching) {
4479
- setSearching(false);
4480
- setQuery("");
4481
- } else if (pane !== "root") returnToRoot();
4482
- else close(true);
4483
- }
4639
+ const onPickerKeyDown = (event) => {
4640
+ if (lockedRef.current || event.key !== "Escape" || !open) return;
4641
+ event.preventDefault();
4642
+ event.stopPropagation();
4643
+ if (pane === "model" && searching) {
4644
+ setSearching(false);
4645
+ setQuery("");
4646
+ } else if (pane !== "root") returnToRoot();
4647
+ else close(true);
4484
4648
  };
4485
4649
  const paneHeader = pane === "root" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPaneHeader, {
4486
4650
  title: t({
@@ -4510,7 +4674,11 @@ window.__ModuleLoader__.load({
4510
4674
  ref: menuRef,
4511
4675
  id: `${id}-menu`,
4512
4676
  className: ComposerPicker_module_css_default.menu,
4513
- style: menuStyle,
4677
+ style: {
4678
+ position: "fixed",
4679
+ zIndex: 4e3
4680
+ },
4681
+ "data-dsh-plan-review-menu": "true",
4514
4682
  role: "menu",
4515
4683
  tabIndex: -1,
4516
4684
  "aria-label": t("menu.aria"),
@@ -4518,6 +4686,7 @@ window.__ModuleLoader__.load({
4518
4686
  onPointerDown: (event) => {
4519
4687
  event.stopPropagation();
4520
4688
  },
4689
+ onKeyDown: onPickerKeyDown,
4521
4690
  children: [paneHeader, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4522
4691
  className: ComposerPicker_module_css_default.list,
4523
4692
  children: [
@@ -4822,7 +4991,7 @@ window.__ModuleLoader__.load({
4822
4991
  }) : null;
4823
4992
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4824
4993
  className: classNames(ComposerPicker_module_css_default.root, tone === "capsule" ? ComposerPicker_module_css_default.capsule : embedded && ComposerPicker_module_css_default.embedded),
4825
- onKeyDown: onRootKeyDown,
4994
+ onKeyDown: onPickerKeyDown,
4826
4995
  children: [
4827
4996
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
4828
4997
  ref: triggerRef,
@@ -4847,7 +5016,7 @@ window.__ModuleLoader__.load({
4847
5016
  className: classNames(ComposerPicker_module_css_default.chevron, open && ComposerPicker_module_css_default.chevronOpen)
4848
5017
  })]
4849
5018
  }),
4850
- menu !== null && (tone === "capsule" ? menu : (0, react_dom.createPortal)(menu, document.body)),
5019
+ menu !== null && typeof document !== "undefined" ? (0, react_dom.createPortal)(menu, document.body) : null,
4851
5020
  toast !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
4852
5021
  text: toast.text,
4853
5022
  icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, { size: 16 }),
@@ -6259,7 +6428,10 @@ window.__ModuleLoader__.load({
6259
6428
  if (!response.ok || response.value === void 0) throw new Error(t("catalogFailed"));
6260
6429
  const enabled = await fetchAntigravityCatalogGroups(connectionRpc);
6261
6430
  const order = orderStore.getSnapshot();
6262
- return sortCatalogGroupsWithRoutes(withAntigravityCatalog(response.value.groups, enabled), order, readCatalogRoutes(directory));
6431
+ return {
6432
+ groups: sortCatalogGroupsWithRoutes(withAntigravityCatalog(response.value.groups, enabled), order, readCatalogRoutes(directory)),
6433
+ failures: response.value.failures
6434
+ };
6263
6435
  },
6264
6436
  ...connectionRpc === void 0 ? {} : { loadCapabilities: async (revision, signal) => {
6265
6437
  const rpc = connectionRpc;