dsh-model-switch 0.4.62 → 0.4.64
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 +22 -1
- package/cordis.patch.yml +3 -6
- package/lib/client.js +120 -43
- package/lib/session-title.js +77 -27
- package/lib/subagent-runtime.js +204 -201
- package/lib/types/client/picker/popup-placement.d.ts +53 -0
- package/lib/types/client/picker/useComposerPickerSurface.d.ts +2 -3
- package/lib/types/subagent-runtime-legacy.d.ts +34 -0
- package/lib/types/subagent-runtime.d.ts +40 -100
- package/lib/types/title-settings-reader.d.ts +34 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## v0.4.64
|
|
2
|
+
|
|
3
|
+
DSH `0.2.2-rc.2` 兼容 + 子代理委派路由修复。
|
|
4
|
+
|
|
5
|
+
- **根因**:`0.2.2-rc.2` 把 `subagents.startActivation` 的规格从嵌套改为扁平——`@deepseek-ai/dsh-tool-subagent` 以 `...request` 把 `SubagentStartRequest` 字段(`parent`/`prompt`/`agentOptions` 等)直接展开到 spec 顶层,不再有嵌套的 `request` 字段。0.4.63 的包装器检查 `spec.request` 看到 `undefined` 后原样放行,子代理回退到父会话模型,固定/分组路由都不再注入。
|
|
6
|
+
- **修复(`src/subagent-runtime.ts`)**:新增 `routedSpecOf`,同一包装器接受两种规格形状——嵌套(0.2.1–0.2.2-rc.1)与扁平(0.2.2-rc.2+);无法识别的形状继续原样放行(未来形状保持官方回退可达)。`SubagentActivationSpecLike` 的 `request` 变为可选并继承 `RoutableSubagentRequest`;`src/subagent-runtime-legacy.ts` 的废弃入口同步类型。旧版 `start()` 线不受影响。
|
|
7
|
+
- **验证(virtual / 零真实额度)**:
|
|
8
|
+
- **rc.2 lab**(`D:/dsh-artifacts/rc2-diff/home`,端口 3084,探针 4719,DSH `0.2.2-rc.2` + 本构建 + `dsh-prime-memory@0.26.37` + `dsh-reference-session-collector@0.2.8`):回放一次 `subagent` 工具调用,探针记录 `gpt-6.1-sol`(父)→ `mimo-v2.6-pro`(子代理实际请求,配置的分组固定对)→ `gpt-6.1-sol`(父续跑);诊断行确认注入的 `agentOptions` 为 `apigoto/mimo-v2.6-pro/high`。同轮 `subagents/interruptByUser` 返回 `{accepted:true}`(rc.2 的 UI 停止端点;旧名 `interruptByParent` 已被上游撤回,返回 not found),全部插件行 active、无 incompatible/did-not-activate;`session/create` 正常(rc.2 对 standard preset 引用行新增 never-started 校验,lab 装齐依赖后通过)。
|
|
9
|
+
- **rc.1 回归**(`D:/dsh-artifacts/rc1-diff/home-next`):同一构建在嵌套形状上 delegation 仍命中 `mimo-v2.6-pro`。
|
|
10
|
+
- **标题路由**:rc.2 上每轮命名请求走配置路由(`mimo-v2.6-flash`),改分组 pin 后下一请求即 `mimo-v2.6-pro`(免重启热切换)。all-prompts 节奏的触发依赖宿主在会话 log 中记录 `request/header` 事件——官方 all-prompts 行与本插件行走同一链路(`dsh-session-title-all-prompts-llm` 与 `dsh-session-title` 两包在 rc.1/rc.2 间 byte-identical)。
|
|
11
|
+
- **prime-memory 0.26.37**:适配器 push `apigoto/deepseek-flash`(capabilities 报告 `installed:true`),`/dsh-memory/rpc/settings-get` 读回一致,memory.log「蒸馏模型路由」行匹配,蒸馏请求命中探针 `deepseek-flash`。0.26.37 的 `engines.dsh` 从精确枚举改为范围 `>=0.1.1-rc.2 <0.3.0`,是其支持 rc.1/rc.2 宿主的方式;上游已知降级:rc.2 上其 settings 分区注册 API 不可用(「记忆模式开关降级为恒开」),与本插件的 settings-forms 写入无关(适配器写入与读回均已验证)。
|
|
12
|
+
- **`dshReleases`**:新增 `0.2.2-rc.2: compatible`。npm `latest` 仍为 `0.2.2-rc.1`(`0.2.2-rc.2` 在 `next` 上,且桌面 runtime 已实际更新至该版本),按 0.2.1-rc.3 先例以 `latest` 同等证据标准验证。
|
|
13
|
+
- `pnpm run check` 全绿(tsc + tsdown + 679 测试 + pack 闸门)。
|
|
14
|
+
|
|
1
15
|
## v0.4.62
|
|
2
16
|
|
|
3
17
|
修复设置页「模型目录偶发加载失败后整个页面卡死」的问题:两个会话在不同供应商上并行、后台任务(如记忆蒸馏)恰在加载瞬间占用 Host 时,`session/modelCatalog` 的一次瞬时失败会把设置页永久留在空目录状态——供应商配置组下拉里所有供应商都带 ⚠、模型下拉没有选项、依赖目录的开关全部禁用,只能重开设置页恢复。
|
|
@@ -16,8 +30,15 @@
|
|
|
16
30
|
- **验证(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`)。自动审查/命名/记忆等其它接管行未改动。
|
|
17
31
|
- **残余**:0.4.61 装到桌面 profile 后需实际点一次子代理/团队委派确认(桌面宿主无法在 lab 内复刻)。0.1.7 / 0.2.0 的 `start()` 线依赖列表照旧合并,语义不变。
|
|
18
32
|
|
|
19
|
-
##
|
|
33
|
+
## v0.4.63
|
|
34
|
+
|
|
35
|
+
- **子代理停止按钮(`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`。
|
|
36
|
+
- **计划审查卡模型菜单裁切/错位**:菜单改为独立 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`。
|
|
37
|
+
- **随对话更新的标题(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`,无需重启。**热切换已验收。**
|
|
38
|
+
- 说明:本轮所有改动均未提交、未打标签、未推送、未发 npm、未安装到桌面 profile(按用户指示,等“发布并推送”)。`pnpm run check` 全绿:69 文件 / 678 测试 + pack 闸门。
|
|
20
39
|
|
|
40
|
+
- **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 未改动。**仅文档,不发版。**
|
|
41
|
+
- **兼容巡检(2026-11-09,仅文档)**:DSH `latest` 仍是 `0.2.2-rc.1`(桌面应用运行 `@deepseek-ai/dsh-desktop-runtime@0.2.2-rc.1`),与 0.4.63 记录的基线一致,未移动、无需新适配。被监控的 `dsh-prime-memory` 从基线 **0.26.24 前进到 0.26.37**(`beta` 0.26.36、`dsh-0.2.1-rc.5` 标签仍是 0.26.35),`engines.dsh` 为 `>=0.1.1-rc.2 <0.3.0`,`0.2.1-rc.5` 与 `0.2.2-rc.1` 都被允许。**桌面实机结果(用户实测 2026-11-09)**:DSH `0.2.2-rc.1` + 本插件 `0.4.63` + `dsh-prime-memory@0.26.37` 下,当前插件已兼容最新 prime-memory,记忆行激活且蒸馏路由由本插件服务——这是真实部署面的结论(非 lab 复刻),因此按用户实测记为已验证;**0.26.37 的七步 lab 接入矩阵尚未重跑,明确列为未完成**。`docs/compat-watch-state.json` 的 `memory.latestVerified` 更新为 `0.26.37`(`verifiedWith` = `0.2.2-rc.1`),`checkedAt` 更新为 2026-11-09。**无代码改动,不发版。**
|
|
21
42
|
- **兼容巡检(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 为已验证版本。**无代码改动,不发版。**
|
|
22
43
|
|
|
23
44
|
## v0.4.60
|
package/cordis.patch.yml
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
#
|
|
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
|
@@ -3970,16 +3970,65 @@ window.__ModuleLoader__.load({
|
|
|
3970
3970
|
};
|
|
3971
3971
|
}
|
|
3972
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
|
|
3973
4016
|
//#region src/client/picker/useComposerPickerSurface.ts
|
|
3974
|
-
/**
|
|
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. */
|
|
3975
4027
|
function useComposerPickerSurface(options) {
|
|
3976
4028
|
const [open, setOpen] = (0, react.useState)(false);
|
|
3977
|
-
const [menuStyle, setMenuStyle] = (0, react.useState)({
|
|
3978
|
-
position: "fixed",
|
|
3979
|
-
zIndex: 4e3
|
|
3980
|
-
});
|
|
3981
4029
|
const triggerRef = (0, react.useRef)(null);
|
|
3982
4030
|
const menuRef = (0, react.useRef)(null);
|
|
4031
|
+
const placementRef = (0, react.useRef)();
|
|
3983
4032
|
const pointerOpenIntent = (0, react.useRef)(null);
|
|
3984
4033
|
const callbacks = (0, react.useRef)({
|
|
3985
4034
|
onOpen: options.onOpen,
|
|
@@ -3994,6 +4043,7 @@ window.__ModuleLoader__.load({
|
|
|
3994
4043
|
const id = (0, react.useId)();
|
|
3995
4044
|
const close = (0, react.useCallback)((restoreFocus = false) => {
|
|
3996
4045
|
setOpen(false);
|
|
4046
|
+
placementRef.current = void 0;
|
|
3997
4047
|
callbacks.current.onClose();
|
|
3998
4048
|
if (restoreFocus) queueMicrotask(() => {
|
|
3999
4049
|
triggerRef.current?.focus();
|
|
@@ -4008,29 +4058,54 @@ window.__ModuleLoader__.load({
|
|
|
4008
4058
|
(0, react.useEffect)(() => {
|
|
4009
4059
|
if (options.locked) close();
|
|
4010
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
|
+
*/
|
|
4011
4066
|
(0, react.useLayoutEffect)(() => {
|
|
4012
|
-
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();
|
|
4013
4094
|
const trigger = triggerRef.current;
|
|
4014
|
-
|
|
4015
|
-
const
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
});
|
|
4027
|
-
}, [
|
|
4028
|
-
open,
|
|
4029
|
-
options.embedded,
|
|
4030
|
-
options.pane
|
|
4031
|
-
]);
|
|
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]);
|
|
4032
4107
|
(0, react.useEffect)(() => {
|
|
4033
|
-
if (!open ||
|
|
4108
|
+
if (!open || typeof document === "undefined") return;
|
|
4034
4109
|
const interaction = options.resolveInteractionOperations?.();
|
|
4035
4110
|
return installPickerDismissal({
|
|
4036
4111
|
documentTarget: document,
|
|
@@ -4044,13 +4119,11 @@ window.__ModuleLoader__.load({
|
|
|
4044
4119
|
close,
|
|
4045
4120
|
id,
|
|
4046
4121
|
open,
|
|
4047
|
-
options.resolveInteractionOperations
|
|
4048
|
-
options.tone
|
|
4122
|
+
options.resolveInteractionOperations
|
|
4049
4123
|
]);
|
|
4050
4124
|
return {
|
|
4051
4125
|
id,
|
|
4052
4126
|
open,
|
|
4053
|
-
menuStyle,
|
|
4054
4127
|
triggerRef,
|
|
4055
4128
|
menuRef,
|
|
4056
4129
|
show,
|
|
@@ -4323,7 +4396,7 @@ window.__ModuleLoader__.load({
|
|
|
4323
4396
|
}
|
|
4324
4397
|
//#endregion
|
|
4325
4398
|
//#region \0dsh-css:src/client/picker/ComposerPicker.module.css.mjs
|
|
4326
|
-
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}";
|
|
4327
4400
|
const tagId$1 = "dsh-model-switch/ComposerPicker.module.css";
|
|
4328
4401
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
4329
4402
|
const tag = document.createElement("style");
|
|
@@ -4457,7 +4530,7 @@ window.__ModuleLoader__.load({
|
|
|
4457
4530
|
lastActionRef.current = "load";
|
|
4458
4531
|
load();
|
|
4459
4532
|
};
|
|
4460
|
-
const { id, open,
|
|
4533
|
+
const { id, open, triggerRef, menuRef, close, onTriggerPointerDown, onTriggerClick } = useComposerPickerSurface({
|
|
4461
4534
|
locked,
|
|
4462
4535
|
embedded: embedded ?? false,
|
|
4463
4536
|
pane,
|
|
@@ -4563,16 +4636,15 @@ window.__ModuleLoader__.load({
|
|
|
4563
4636
|
const contextDisplay = (label) => label === "standard" ? t("context.standard") : label;
|
|
4564
4637
|
const triggerLabel = triggerBits.join(" · ");
|
|
4565
4638
|
const triggerAria = currentSelection === null ? t("trigger.selectAria") : t("trigger.aria", { model: triggerLabel });
|
|
4566
|
-
const
|
|
4567
|
-
if (lockedRef.current) return;
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
}
|
|
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);
|
|
4576
4648
|
};
|
|
4577
4649
|
const paneHeader = pane === "root" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPaneHeader, {
|
|
4578
4650
|
title: t({
|
|
@@ -4602,7 +4674,11 @@ window.__ModuleLoader__.load({
|
|
|
4602
4674
|
ref: menuRef,
|
|
4603
4675
|
id: `${id}-menu`,
|
|
4604
4676
|
className: ComposerPicker_module_css_default.menu,
|
|
4605
|
-
style:
|
|
4677
|
+
style: {
|
|
4678
|
+
position: "fixed",
|
|
4679
|
+
zIndex: 4e3
|
|
4680
|
+
},
|
|
4681
|
+
"data-dsh-plan-review-menu": "true",
|
|
4606
4682
|
role: "menu",
|
|
4607
4683
|
tabIndex: -1,
|
|
4608
4684
|
"aria-label": t("menu.aria"),
|
|
@@ -4610,6 +4686,7 @@ window.__ModuleLoader__.load({
|
|
|
4610
4686
|
onPointerDown: (event) => {
|
|
4611
4687
|
event.stopPropagation();
|
|
4612
4688
|
},
|
|
4689
|
+
onKeyDown: onPickerKeyDown,
|
|
4613
4690
|
children: [paneHeader, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4614
4691
|
className: ComposerPicker_module_css_default.list,
|
|
4615
4692
|
children: [
|
|
@@ -4914,7 +4991,7 @@ window.__ModuleLoader__.load({
|
|
|
4914
4991
|
}) : null;
|
|
4915
4992
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4916
4993
|
className: classNames(ComposerPicker_module_css_default.root, tone === "capsule" ? ComposerPicker_module_css_default.capsule : embedded && ComposerPicker_module_css_default.embedded),
|
|
4917
|
-
onKeyDown:
|
|
4994
|
+
onKeyDown: onPickerKeyDown,
|
|
4918
4995
|
children: [
|
|
4919
4996
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4920
4997
|
ref: triggerRef,
|
|
@@ -4939,7 +5016,7 @@ window.__ModuleLoader__.load({
|
|
|
4939
5016
|
className: classNames(ComposerPicker_module_css_default.chevron, open && ComposerPicker_module_css_default.chevronOpen)
|
|
4940
5017
|
})]
|
|
4941
5018
|
}),
|
|
4942
|
-
menu !== null &&
|
|
5019
|
+
menu !== null && typeof document !== "undefined" ? (0, react_dom.createPortal)(menu, document.body) : null,
|
|
4943
5020
|
toast !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
|
|
4944
5021
|
text: toast.text,
|
|
4945
5022
|
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, { size: 16 }),
|
package/lib/session-title.js
CHANGED
|
@@ -1,4 +1,69 @@
|
|
|
1
1
|
import { a as sessionProviderOf, n as groupRoute, t as deploymentRoute } from "./session-route-D8izd8Zd.js";
|
|
2
|
+
//#region lib/types/title-settings-reader.js
|
|
3
|
+
/**
|
|
4
|
+
* Safe reads of the optional Model Switch settings service for the naming row.
|
|
5
|
+
*
|
|
6
|
+
* The session-naming row must keep the official naming behavior when the
|
|
7
|
+
* `model-switch` row is absent, so `modelSwitch` can never join the row's own
|
|
8
|
+
* `inject` list: Cordis waits for every declared dependency before a fiber
|
|
9
|
+
* loads (there is no "optional" inject), and a never-provided service would
|
|
10
|
+
* leave the row pending forever.
|
|
11
|
+
*
|
|
12
|
+
* Two reads are tried per call, in this order:
|
|
13
|
+
*
|
|
14
|
+
* 1. `ctx.get('modelSwitch')` with Cordis' default strict mode — the active
|
|
15
|
+
* implementation only, or undefined. This is the read the shipped row used
|
|
16
|
+
* and it keeps working across a settings-row rebuild because the store
|
|
17
|
+
* entry is replaced, not cached here.
|
|
18
|
+
* 2. A scoped `ctx.inject(['modelSwitch'])` child fiber, which binds a
|
|
19
|
+
* dependent scope and resets it on dispose. This covers compositions where
|
|
20
|
+
* the strict store read is invisible from the row's own entry context.
|
|
21
|
+
*
|
|
22
|
+
* The returned function identity is stable for the row's lifetime and every
|
|
23
|
+
* call re-reads, so a settings save or a service rebuild needs no remount.
|
|
24
|
+
* Reads never throw: a missing face, a disposed scope, or a throwing read all
|
|
25
|
+
* answer undefined, which means "official behavior" to the caller.
|
|
26
|
+
*
|
|
27
|
+
* @module dsh-model-switch/title-settings-reader
|
|
28
|
+
*/
|
|
29
|
+
/** Accept only a settings object; anything else is the official "no settings" answer. */
|
|
30
|
+
function settingsOf(value) {
|
|
31
|
+
if (value === null || typeof value !== "object") return void 0;
|
|
32
|
+
const service = value;
|
|
33
|
+
if (typeof service.currentSettings !== "function") return void 0;
|
|
34
|
+
const settings = service.currentSettings();
|
|
35
|
+
return settings !== null && typeof settings === "object" ? settings : void 0;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create the settings reader for one naming row context.
|
|
39
|
+
* @param ctx - this row's context (the row fiber's own scope).
|
|
40
|
+
* @returns The reader: per-request live settings, or undefined when unavailable.
|
|
41
|
+
*/
|
|
42
|
+
function titleSettingsReaderOf(ctx) {
|
|
43
|
+
let scoped;
|
|
44
|
+
ctx.inject(["modelSwitch"], (scope) => {
|
|
45
|
+
scope.effect(() => {
|
|
46
|
+
scoped = scope;
|
|
47
|
+
return () => {
|
|
48
|
+
if (scoped === scope) scoped = void 0;
|
|
49
|
+
};
|
|
50
|
+
}, "model-switch: session-title settings reader");
|
|
51
|
+
});
|
|
52
|
+
return () => {
|
|
53
|
+
try {
|
|
54
|
+
const direct = settingsOf(ctx.get("modelSwitch"));
|
|
55
|
+
if (direct !== void 0) return direct;
|
|
56
|
+
} catch {}
|
|
57
|
+
const scope = scoped;
|
|
58
|
+
if (scope === void 0) return void 0;
|
|
59
|
+
try {
|
|
60
|
+
return settingsOf(scope.modelSwitch);
|
|
61
|
+
} catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
2
67
|
//#region lib/types/session-title.js
|
|
3
68
|
/**
|
|
4
69
|
* Model Switch-owned session-naming row.
|
|
@@ -479,8 +544,8 @@ async function runTitleCall(ctx, module, plan, request, attempt) {
|
|
|
479
544
|
* @returns The official provider result.
|
|
480
545
|
* @throws The last candidate failure when every candidate fails.
|
|
481
546
|
*/
|
|
482
|
-
async function generateTitle(ctx, module, plan, request) {
|
|
483
|
-
const candidates = titleRouteCandidates(
|
|
547
|
+
async function generateTitle(ctx, module, plan, request, settingsReader) {
|
|
548
|
+
const candidates = titleRouteCandidates(settingsReader(), sessionProviderOf(ctx, request.session), plan.config, request.route);
|
|
484
549
|
const attempts = candidates.length === 0 ? [{
|
|
485
550
|
route: void 0,
|
|
486
551
|
config: plan.config
|
|
@@ -513,23 +578,6 @@ async function generateTitle(ctx, module, plan, request) {
|
|
|
513
578
|
if (!request.signal.aborted) ctx.logger.warn(`model-switch: session title generation failed on every candidate (${tried}): ${String(lastError)}`);
|
|
514
579
|
throw lastError;
|
|
515
580
|
}
|
|
516
|
-
/**
|
|
517
|
-
* Read live Model Switch settings without requiring the host row.
|
|
518
|
-
*
|
|
519
|
-
* The host is read structurally instead of injected so this row keeps mirroring
|
|
520
|
-
* the official naming behavior when the `model-switch` row is disabled: an
|
|
521
|
-
* unreachable host resolves to the row's own policy rather than to a pinned
|
|
522
|
-
* route.
|
|
523
|
-
* @param ctx - this row's context.
|
|
524
|
-
* @returns The settings, or undefined when the host is unavailable.
|
|
525
|
-
*/
|
|
526
|
-
function currentSettings(ctx) {
|
|
527
|
-
try {
|
|
528
|
-
return ctx.get("modelSwitch", false)?.currentSettings();
|
|
529
|
-
} catch {
|
|
530
|
-
return;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
581
|
/** Resolve the naming plan for one official row, or the shipped defaults when no row exists. */
|
|
534
582
|
function planFor(ctx, module, entry) {
|
|
535
583
|
const cadence = titleCadence(entry === void 0 ? void 0 : officialTitlePackage(entry)) ?? TITLE_CADENCES[0];
|
|
@@ -550,11 +598,11 @@ function planFor(ctx, module, entry) {
|
|
|
550
598
|
};
|
|
551
599
|
}
|
|
552
600
|
/** One naming plan bound to a live route resolver. */
|
|
553
|
-
function providerOf(ctx, module, plan) {
|
|
601
|
+
function providerOf(ctx, module, plan, settingsReader) {
|
|
554
602
|
return {
|
|
555
603
|
id: plan.cadence.id,
|
|
556
604
|
automatic: plan.cadence.automatic,
|
|
557
|
-
generate: (request) => generateTitle(ctx, module, plan, request)
|
|
605
|
+
generate: (request) => generateTitle(ctx, module, plan, request, settingsReader)
|
|
558
606
|
};
|
|
559
607
|
}
|
|
560
608
|
/** Timing knobs for the takeover choreography (exported for tests). */
|
|
@@ -578,11 +626,13 @@ const TAKEOVER_MAX_ATTEMPTS = 20;
|
|
|
578
626
|
var NamingSeam = class {
|
|
579
627
|
ctx;
|
|
580
628
|
module;
|
|
629
|
+
settingsReader;
|
|
581
630
|
disposer;
|
|
582
631
|
plan;
|
|
583
|
-
constructor(ctx, module, plan) {
|
|
632
|
+
constructor(ctx, module, settingsReader, plan) {
|
|
584
633
|
this.ctx = ctx;
|
|
585
634
|
this.module = module;
|
|
635
|
+
this.settingsReader = settingsReader;
|
|
586
636
|
this.plan = plan;
|
|
587
637
|
}
|
|
588
638
|
/** The cadence currently registered. */
|
|
@@ -602,7 +652,7 @@ var NamingSeam = class {
|
|
|
602
652
|
this.plan = plan;
|
|
603
653
|
if (this.disposer !== void 0) return true;
|
|
604
654
|
try {
|
|
605
|
-
this.disposer = this.ctx.sessionTitle.register(providerOf(this.ctx, this.module, plan));
|
|
655
|
+
this.disposer = this.ctx.sessionTitle.register(providerOf(this.ctx, this.module, plan, this.settingsReader));
|
|
606
656
|
return true;
|
|
607
657
|
} catch {
|
|
608
658
|
return false;
|
|
@@ -725,8 +775,7 @@ function installTakeover(ctx, module, seam) {
|
|
|
725
775
|
* the real Host always provides one of them.
|
|
726
776
|
*/
|
|
727
777
|
const entryOfEvent = (self, first) => {
|
|
728
|
-
const candidate
|
|
729
|
-
return candidate !== null && typeof candidate === "object" && "options" in candidate ? candidate : void 0;
|
|
778
|
+
for (const candidate of [first, self]) if (candidate !== null && typeof candidate === "object" && "options" in candidate) return candidate;
|
|
730
779
|
};
|
|
731
780
|
const listeners = [];
|
|
732
781
|
const listen = (event, listener) => {
|
|
@@ -755,9 +804,9 @@ function installTakeover(ctx, module, seam) {
|
|
|
755
804
|
reclaim(entry, plan);
|
|
756
805
|
});
|
|
757
806
|
listen("loader/partial-dispose", function(first) {
|
|
758
|
-
seam.yieldSlot();
|
|
759
807
|
const entry = entryOfEvent(this, first);
|
|
760
808
|
if (entry === void 0 || !isOfficialTitleRow(entry)) return;
|
|
809
|
+
seam.yieldSlot();
|
|
761
810
|
handled.delete(entry);
|
|
762
811
|
if (seam.claimed) return;
|
|
763
812
|
const plan = planFor(ctx, module, officialTitleEntry(ctx.get("loader", false)));
|
|
@@ -797,6 +846,7 @@ function installTakeover(ctx, module, seam) {
|
|
|
797
846
|
* @param ctx - this row's context.
|
|
798
847
|
*/
|
|
799
848
|
async function apply(ctx) {
|
|
849
|
+
const settingsReader = titleSettingsReaderOf(ctx);
|
|
800
850
|
const entry = officialTitleEntry(ctx.get("loader", false));
|
|
801
851
|
if (entry === void 0) ctx.logger.info("model-switch: no instantiated official session-title row to mirror; naming uses the first-prompt cadence");
|
|
802
852
|
let module;
|
|
@@ -809,7 +859,7 @@ async function apply(ctx) {
|
|
|
809
859
|
}
|
|
810
860
|
const plan = planFor(ctx, module, entry);
|
|
811
861
|
if (plan === void 0) return;
|
|
812
|
-
const seam = new NamingSeam(ctx, module, plan);
|
|
862
|
+
const seam = new NamingSeam(ctx, module, settingsReader, plan);
|
|
813
863
|
if (!(enabledOfficialRows(ctx).length > 0) && !seam.claim()) ctx.logger.info("model-switch: another session-title provider already owns the seam; naming follows it while it is active");
|
|
814
864
|
installTakeover(ctx, module, seam);
|
|
815
865
|
}
|