@lynn123411/dsh-notify-user 0.5.3 → 0.5.5
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/README.md +18 -18
- package/lib/client.js +86 -53
- package/lib/client.js.map +2 -2
- package/lib/index.js +25 -20
- package/lib/index.js.map +2 -2
- package/package.json +34 -31
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
## 概述
|
|
6
6
|
|
|
7
|
-
`notify_user`
|
|
7
|
+
`notify_user` 是一个不结束本轮的工具。模型在干活途中调它,成功后对话流里出现一张进度卡;本轮继续,不阻塞,也不等用户回答。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
连续多次根工具调用没有汇报时,插件在下一步之前注入一条提醒,让模型把当前结论和下一步发出来。汇报成功、写了散文正文、开了新回合或用户插话,计数都清零。
|
|
10
10
|
|
|
11
11
|
进度卡站在步骤组外:两次汇报之间的工具调用各自折成一个原生子折叠,卡片本身不会被折进组里。回合进行中始终可见,回合结束后随「工作过程」一起折叠。
|
|
12
12
|
|
|
@@ -28,7 +28,7 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
28
28
|
|
|
29
29
|
关掉之后两处一起变:催办状态机不催,计数一并清零,重新打开从零开始;`notify_user` 用 `ctx.tools.register(def, { when })` 按会话收放,关掉的会话在这一步的声明与派发里都没有它。
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
子代理会话没有汇报工具和催办,也不显示这个开关。判定同时看当前会话快照的 `subagent` 与会话列表里的 `origin`。
|
|
32
32
|
|
|
33
33
|
点开关先按新值重画,写入交给设置表单排队;宿主拒收就退回宿主上的值,并通过菜单宿主的 `reportFailure` 报一次。写入在途时开关禁用。
|
|
34
34
|
|
|
@@ -40,7 +40,7 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
40
40
|
| --- | --- | --- | --- |
|
|
41
41
|
| `defaultEnabled` | true | 布尔 | 会话没有自己的选择时,主动汇报开不开。 |
|
|
42
42
|
| `sessionOverrides` | `{}` | 会话 id → 布尔 | 按会话的选择;只留与默认值不同的会话。 |
|
|
43
|
-
| `nudgeAfter` | 10 | 0–100 | 连续多少次根工具调用没有汇报时催一次;0
|
|
43
|
+
| `nudgeAfter` | 10 | 0–100 | 连续多少次根工具调用没有汇报时催一次;0 关闭催办,仍可主动汇报。 |
|
|
44
44
|
| `resetOnProse` | true | 布尔 | 助手消息里写了正文就清零计数。 |
|
|
45
45
|
| `collapsible` | true | 布尔 | 卡片带不带折叠键;关掉后正文始终展开。 |
|
|
46
46
|
| `summaryOnly` | false | 布尔 | 模型只写一行标题,卡片只显示标题行。 |
|
|
@@ -51,7 +51,7 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
51
51
|
|
|
52
52
|
配置卡把 `summaryOnly` 画成「结构化正文 / 只报摘要」两选一,把 `collapsible` 与 `bodyExpandedByDefault` 合成「始终展开 / 默认收起 / 默认展开」三选一,把 `showTime` 画成一个开关;只报摘要时「正文显示」整行不出现,改出现「摘要呈现」,摘要按散文渲染时根本不画卡片,「显示时间」整行随之不出现。
|
|
53
53
|
|
|
54
|
-
字段都标了 `.volatile()`:改它们不重挂这条 loader entry。催办状态机每次 `pre-step` 现读 `nudgeAfter`、`summaryOnly` 与 `defaultEnabled`/`sessionOverrides
|
|
54
|
+
字段都标了 `.volatile()`:改它们不重挂这条 loader entry。催办状态机每次 `pre-step` 现读 `nudgeAfter`、`summaryOnly` 与 `defaultEnabled`/`sessionOverrides`;浏览器用宿主下发的同步配置引用决定进度卡的位置、汇报形态、展开方式和时间显示。配置页与会话开关通过配置表单读写。
|
|
55
55
|
|
|
56
56
|
宿主没服务这份配置时卡片整块不出现。插件同时用 `ctx.settings.configure({ auto: false })` 关掉内核按 schema 自动生成的那份设置页。
|
|
57
57
|
|
|
@@ -62,7 +62,7 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
62
62
|
这一行同时承载两个半边:
|
|
63
63
|
|
|
64
64
|
- 宿主半边注册 `notify_user` 工具,并把催办状态机接到 `tools/result`(纯观察)、`session/event`(助手消息落定)与 `agent/pre-step` 三条事件上;
|
|
65
|
-
- 浏览器半边注册对话节点定义、进度卡渲染器(`conversation.chat.node`,key 是 `notify-user
|
|
65
|
+
- 浏览器半边注册对话节点定义、进度卡渲染器(`conversation.chat.node`,key 是 `notify-user`)、跟随工具行时的渲染(`tool.call.toolview`,key 是 `notify_user`)、菜单开关(`conversation.input.model.options`,id 是 `notify-user-enabled`)与插件页配置卡(`plugins.bundle.config`,key 是包名)。
|
|
66
66
|
|
|
67
67
|
行 id 同时是配置命名空间:宿主 `Config` 与浏览器 `ctx.configForms.get('dsh-notify-user')` 读写的是同一份值。
|
|
68
68
|
|
|
@@ -79,13 +79,13 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
79
79
|
| `tool/call` | 工具名是 `notify_user` |
|
|
80
80
|
| `tool/result` | 追加写法,且 callId 在调用事件里见过 |
|
|
81
81
|
| `assistant/live-chunk` | 带工具名的增量与块结束事件 |
|
|
82
|
-
| `tool/ptc-dispatch-start` / `tool/ptc-dispatch` | 工具名是 `notify_user
|
|
82
|
+
| `tool/ptc-dispatch-start` / `tool/ptc-dispatch` | 工具名是 `notify_user`。失败的结果也交给宿主通用工具定义。 |
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
结果事件不带工具名,按调用事件记下的 callId 认领。失败的直接调用显示失败提示和原始错误。PTC 子调用的失败结果带工具名和父调用,宿主在 `run_code` 下显示原生错误行,插件隐藏对应的进度卡。窗口里找不到调用时,宿主通用定义会补建一条没有工具名的工具行。
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
独占认领的事件不再交给其他 chat 定义,回合过程的工具调用计数与助手行的流式块列表因此少这一次。
|
|
87
87
|
|
|
88
|
-
位置设成 `inline` 时不注册这份定义:通用工具定义建出工具行,`tool.call.toolview`
|
|
88
|
+
位置设成 `inline` 时不注册这份定义:通用工具定义建出工具行,`tool.call.toolview` 把卡片画在行里,卡片随组折叠。失败时工具行显示失败提示和原始错误。切换位置会重挂定义,对话流当场重排。
|
|
89
89
|
|
|
90
90
|
### 只报摘要
|
|
91
91
|
|
|
@@ -97,9 +97,9 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
97
97
|
|
|
98
98
|
### 计数口径
|
|
99
99
|
|
|
100
|
-
- `notify_user
|
|
100
|
+
- 开启主动汇报的主会话立即提供 `notify_user`,催办阈值只控制提醒。
|
|
101
101
|
- 只数根调用:原生模式下是模型每次直接发起的调用(同一轮里的并行调用各算一次);PTC 模式下是每次 `run_code`,程序内部的子调用不算。
|
|
102
|
-
- `notify_user`
|
|
102
|
+
- `notify_user` 成功才清零,根调用和 PTC 子调用都适用。直接调用失败仍按一次根调用计数,失败的 PTC 子调用保留已有计数。
|
|
103
103
|
- 助手消息里带非空白正文时清零,`resetOnProse` 关掉则不算;`reasoning` 块不算正文,失败、重试、取消的尝试也不清零。
|
|
104
104
|
- 新回合(`step === 1`)或用户插话清零。回合边界取宿主给的 `step`,不按消息来源枚举。
|
|
105
105
|
- 子代理会话不计数、不注入。
|
|
@@ -115,7 +115,7 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
115
115
|
|
|
116
116
|
## 模型体验
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
开启主动汇报的主会话从第一步起就能调用 `notify_user`。
|
|
119
119
|
|
|
120
120
|
结构化正文模式的工具描述:
|
|
121
121
|
|
|
@@ -146,14 +146,14 @@ cd plugins/dsh-notify-user && pnpm check
|
|
|
146
146
|
`check` 链上每一步:
|
|
147
147
|
|
|
148
148
|
- `typecheck`:`src` 的类型闸门。
|
|
149
|
-
- `smoke-host.mjs`:真 cordis + 真 `ToolRuntime`,断言配置形状、工具注册与执行、装配行,以及催办接线在真 `ctx.waterfall` 下的行为(满阈值注入、汇报/散文/新回合/用户插话/阈值 0 清零、只有思考块不清零、失败尝试不清零、散文开关关掉不清零、上下文注入不清零、PTC
|
|
150
|
-
- `smoke-client.mjs`:按 Web shell 方式装载浏览器 bundle
|
|
151
|
-
- `test-nudge.mjs
|
|
149
|
+
- `smoke-host.mjs`:真 cordis + 真 `ToolRuntime`,断言配置形状、工具注册与执行、装配行,以及催办接线在真 `ctx.waterfall` 下的行为(满阈值注入、汇报/散文/新回合/用户插话/阈值 0 清零、只有思考块不清零、失败尝试不清零、散文开关关掉不清零、上下文注入不清零、PTC 子调用不计数、嵌套汇报清零、子代理不注入、下游拒绝时不追加),以及按会话开关、零阈值仍可汇报,以及直接和 PTC 调用失败后保留计数、重试成功后清零。
|
|
150
|
+
- `smoke-client.mjs`:按 Web shell 方式装载浏览器 bundle,断言对话节点定义、位置切换会重挂定义、四处座位注册(进度卡、跟随工具行、菜单开关、配置卡)、同步展示配置、字典键集与「未声明服务读取会抛」的守卫。
|
|
151
|
+
- `test-nudge.mjs`:催办状态机的纯逻辑(阈值、四条清零路径、阈值与散文开关现读、按会话隔离、散文判定、开关关掉时不催且计数清零)。
|
|
152
152
|
- `test-config.mjs`:按会话开关的纯逻辑(默认值、会话自己的选择优先、脏数据与原型键不算记录、写入时只留与默认值不同的会话)。
|
|
153
153
|
- `test-render.mjs`:用真 react 把菜单开关画进 jsdom(默认值、写入规则、宿主拒收回退并报失败、写入在途禁用、子代理会话不画、配置不可用不画、锁住不可点)。
|
|
154
|
-
- `test-card.mjs`:用真 react 把进度卡与配置卡画进 jsdom
|
|
154
|
+
- `test-card.mjs`:用真 react 把进度卡与配置卡画进 jsdom(只报摘要时只有标题行、折叠键长在圆点里、正文三种显示形态、配置卡汇报形态两选一与正文显示三选一及各自写入、同步配置晚到时默认展开在就绪后生效、失败行显示宿主错误)。
|
|
155
155
|
- `test-row-model.mjs`:进度卡数据视图的三条来路(`meta` / PTC 参数 / start 参数)与标题回退。
|
|
156
|
-
- `test-notify-node.mjs`:对话节点定义的认领范围、节点位置与卡片数据(原生调用、结果落定、流式增量与块结束、PTC
|
|
156
|
+
- `test-notify-node.mjs`:对话节点定义的认领范围、节点位置与卡片数据(原生调用、结果落定、流式增量与块结束、PTC 子调用、直接调用失败、PTC 失败交给原生行、结果先到、没有正文时的兜底)。
|
|
157
157
|
- `assert-lib-untracked.mjs`:`lib/` 是构建镜像,不入 git。
|
|
158
158
|
|
|
159
159
|
浏览器里验收:打开跑过 `notify_user` 的会话,展开回合后进度卡应站在步骤组外、前后各有一条折叠组。DOM 判据是 `[data-chat-flow-kind="notify-user"]` 的节点不在 `[data-step-process-body]` 里,`[data-step-process]` 的组头成对出现在卡片之间。
|
package/lib/client.js
CHANGED
|
@@ -448,6 +448,7 @@ function RootEnabledToggle({ sessionId, form, locked, reportFailure, t }) {
|
|
|
448
448
|
var NS = "notifyUser";
|
|
449
449
|
var en = {
|
|
450
450
|
"row.preparing": "Sending update\u2026",
|
|
451
|
+
"row.failed": "Could not send update",
|
|
451
452
|
"row.fallbackTitle": "Update",
|
|
452
453
|
"markdown.copy": "Copy",
|
|
453
454
|
"markdown.copied": "Copied",
|
|
@@ -459,10 +460,10 @@ var en = {
|
|
|
459
460
|
"config.defaultEnabled.label": "On by default",
|
|
460
461
|
"config.defaultEnabled.hint": "New sessions start with proactive updates on; change a single session in the model and reasoning menu.",
|
|
461
462
|
"config.threshold.label": "Nudge after",
|
|
462
|
-
"config.threshold.hint": "Tool calls without an update before the model is nudged; 0 turns nudging off.",
|
|
463
|
+
"config.threshold.hint": "Tool calls without an update before the model is nudged; 0 turns nudging off and leaves the update tool available.",
|
|
463
464
|
"config.threshold.unit": "calls",
|
|
464
465
|
"config.resetOnProse.label": "Reset on prose",
|
|
465
|
-
"config.resetOnProse.hint": "Any assistant reply with text counts as an update and resets the count; turn it off to reset only on
|
|
466
|
+
"config.resetOnProse.hint": "Any assistant reply with text counts as an update and resets the count; turn it off to reset only on a successful update, a new turn, or a user message.",
|
|
466
467
|
"config.reportMode.label": "Update format",
|
|
467
468
|
"config.reportMode.hint": "Summary only: the model writes one line and the card shows just the title; structured body: the model writes a title and a body.",
|
|
468
469
|
"config.reportMode.structured": "Structured body",
|
|
@@ -487,6 +488,7 @@ var en = {
|
|
|
487
488
|
};
|
|
488
489
|
var zh = {
|
|
489
490
|
"row.preparing": "\u6B63\u5728\u6C47\u62A5\u2026",
|
|
491
|
+
"row.failed": "\u6C47\u62A5\u5931\u8D25",
|
|
490
492
|
"row.fallbackTitle": "\u66F4\u65B0",
|
|
491
493
|
"markdown.copy": "\u590D\u5236",
|
|
492
494
|
"markdown.copied": "\u5DF2\u590D\u5236",
|
|
@@ -498,10 +500,10 @@ var zh = {
|
|
|
498
500
|
"config.defaultEnabled.label": "\u9ED8\u8BA4\u5F00\u542F",
|
|
499
501
|
"config.defaultEnabled.hint": "\u65B0\u4F1A\u8BDD\u9ED8\u8BA4\u6253\u5F00\u4E3B\u52A8\u6C47\u62A5\uFF1B\u5355\u4E2A\u4F1A\u8BDD\u7684\u5F00\u5173\u5728\u6A21\u578B\u4E0E\u63A8\u7406\u7B49\u7EA7\u83DC\u5355\u91CC\u3002",
|
|
500
502
|
"config.threshold.label": "\u50AC\u529E\u9608\u503C",
|
|
501
|
-
"config.threshold.hint": "\u8FDE\u7EED\u591A\u5C11\u6B21\u5DE5\u5177\u8C03\u7528\u6CA1\u6709\u6C47\u62A5\u65F6\u50AC\u4E00\u6B21\uFF1B0 \u5173\u95ED\u50AC\u529E\u3002",
|
|
503
|
+
"config.threshold.hint": "\u8FDE\u7EED\u591A\u5C11\u6B21\u5DE5\u5177\u8C03\u7528\u6CA1\u6709\u6C47\u62A5\u65F6\u50AC\u4E00\u6B21\uFF1B0 \u5173\u95ED\u50AC\u529E\uFF0C\u4ECD\u53EF\u4E3B\u52A8\u6C47\u62A5\u3002",
|
|
502
504
|
"config.threshold.unit": "\u6B21",
|
|
503
505
|
"config.resetOnProse.label": "\u6563\u6587\u56DE\u590D\u6E05\u96F6",
|
|
504
|
-
"config.resetOnProse.hint": "\u6A21\u578B\u5728\u52A9\u624B\u6D88\u606F\u91CC\u5199\u4E86\u6B63\u6587\u5C31\u7B97\u6C47\u62A5\u8FC7\uFF0C\u8BA1\u6570\u6E05\u96F6\uFF1B\u5173\u6389\u540E\u53EA\u5728
|
|
506
|
+
"config.resetOnProse.hint": "\u6A21\u578B\u5728\u52A9\u624B\u6D88\u606F\u91CC\u5199\u4E86\u6B63\u6587\u5C31\u7B97\u6C47\u62A5\u8FC7\uFF0C\u8BA1\u6570\u6E05\u96F6\uFF1B\u5173\u6389\u540E\u53EA\u5728\u6C47\u62A5\u6210\u529F\u3001\u65B0\u56DE\u5408\u6216\u7528\u6237\u63D2\u8BDD\u65F6\u6E05\u96F6\u3002",
|
|
505
507
|
"config.reportMode.label": "\u6C47\u62A5\u5F62\u6001",
|
|
506
508
|
"config.reportMode.hint": "\u53EA\u62A5\u6458\u8981\u65F6\u6A21\u578B\u53EA\u5199\u4E00\u884C\u6807\u9898\uFF0C\u5361\u7247\u53EA\u663E\u793A\u6807\u9898\u884C\uFF1B\u7ED3\u6784\u5316\u6B63\u6587\u65F6\u6A21\u578B\u5199\u6807\u9898\u4E0E\u6B63\u6587\u3002",
|
|
507
509
|
"config.reportMode.structured": "\u7ED3\u6784\u5316\u6B63\u6587",
|
|
@@ -526,6 +528,11 @@ var zh = {
|
|
|
526
528
|
};
|
|
527
529
|
|
|
528
530
|
// src/client/row-model.ts
|
|
531
|
+
function failureOf(content, error) {
|
|
532
|
+
const text = content.flatMap((block) => block.type === "text" && block.text?.trim() ? [block.text] : []).join("\n");
|
|
533
|
+
const detail = text || (error === void 0 ? "" : error.reason || `${error.name}: ${error.code}`);
|
|
534
|
+
return { detail };
|
|
535
|
+
}
|
|
529
536
|
function parseUpdate(value) {
|
|
530
537
|
if (typeof value !== "object" || value === null) return null;
|
|
531
538
|
const record = value;
|
|
@@ -586,13 +593,22 @@ function settledState(current, update) {
|
|
|
586
593
|
...current.anchorSeq === void 0 ? {} : { anchorSeq: current.anchorSeq }
|
|
587
594
|
};
|
|
588
595
|
}
|
|
596
|
+
function rootResultState(event, current) {
|
|
597
|
+
if (event.data.message.isError) {
|
|
598
|
+
return {
|
|
599
|
+
...stateOf(null, current?.time ?? event.time, true, current?.anchorSeq ?? event.seq),
|
|
600
|
+
failure: failureOf(event.data.message.content, event.data.error)
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
const update = parseUpdate(event.data.meta);
|
|
604
|
+
return current === void 0 ? stateOf(update, event.time, true, event.seq) : settledState(current, update);
|
|
605
|
+
}
|
|
589
606
|
function fallbackState(context) {
|
|
590
607
|
for (let index = context.matches.length - 1; index >= 0; index -= 1) {
|
|
591
608
|
const event = context.matches[index].event;
|
|
592
|
-
if (event.type === "tool/result")
|
|
593
|
-
return { ...parseUpdate(event.data.meta) ?? { message: "" }, time: event.time, settled: true, anchorSeq: event.seq };
|
|
594
|
-
}
|
|
609
|
+
if (event.type === "tool/result") return rootResultState(event);
|
|
595
610
|
if (event.type === "tool/ptc-dispatch") {
|
|
611
|
+
if (event.data.isError) return void 0;
|
|
596
612
|
return {
|
|
597
613
|
...parseUpdate(event.data.meta) ?? parseUpdate(event.data.arguments) ?? { message: "" },
|
|
598
614
|
time: event.time,
|
|
@@ -638,6 +654,9 @@ function createNotifyDefinition() {
|
|
|
638
654
|
case "tool/ptc-dispatch-start":
|
|
639
655
|
case "tool/ptc-dispatch": {
|
|
640
656
|
if (event.data.name !== NOTIFY_TOOL_NAME) return null;
|
|
657
|
+
if (event.type === "tool/ptc-dispatch" && event.data.isError) {
|
|
658
|
+
return { id: String(event.data.subCallId), role: "update" };
|
|
659
|
+
}
|
|
641
660
|
return {
|
|
642
661
|
id: String(event.data.subCallId),
|
|
643
662
|
role: event.type === "tool/ptc-dispatch-start" ? "start" : "update",
|
|
@@ -662,8 +681,9 @@ function createNotifyDefinition() {
|
|
|
662
681
|
if (event.type === "tool/call") {
|
|
663
682
|
return stateOf(parseArgs(event.data.arguments) ?? { message: current.message }, event.time, current.settled, event.seq);
|
|
664
683
|
}
|
|
665
|
-
if (event.type === "tool/result") return
|
|
684
|
+
if (event.type === "tool/result") return rootResultState(event, current);
|
|
666
685
|
if (event.type === "tool/ptc-dispatch") {
|
|
686
|
+
if (event.data.isError) return { ...current, useNativeError: true };
|
|
667
687
|
return settledState(current, parseUpdate(event.data.meta) ?? parseUpdate(event.data.arguments));
|
|
668
688
|
}
|
|
669
689
|
return current;
|
|
@@ -678,13 +698,14 @@ function createNotifyDefinition() {
|
|
|
678
698
|
target: "chat",
|
|
679
699
|
anchorSeq: state.anchorSeq,
|
|
680
700
|
location: context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" },
|
|
681
|
-
groupTree: "process",
|
|
682
|
-
visibility: "visible",
|
|
701
|
+
groupTree: state.failure === void 0 ? "process" : void 0,
|
|
702
|
+
visibility: state.useNativeError ? "hidden" : "visible",
|
|
683
703
|
data: {
|
|
684
704
|
...state.title === void 0 ? {} : { title: state.title },
|
|
685
705
|
message: state.message,
|
|
686
706
|
time: state.time,
|
|
687
|
-
settled: state.settled
|
|
707
|
+
settled: state.settled,
|
|
708
|
+
...state.failure === void 0 ? {} : { failure: state.failure }
|
|
688
709
|
}
|
|
689
710
|
};
|
|
690
711
|
return node;
|
|
@@ -696,34 +717,39 @@ function createNotifyDefinition() {
|
|
|
696
717
|
var import_react3 = require("react");
|
|
697
718
|
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
698
719
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
699
|
-
function useClientConfig(form) {
|
|
700
|
-
const [config, setConfig] = (0, import_react3.useState)(() => readConfig(form) ?? DEFAULT_CLIENT_CONFIG);
|
|
701
|
-
(0, import_react3.useEffect)(() => {
|
|
702
|
-
const sync = () => {
|
|
703
|
-
setConfig(readConfig(form) ?? DEFAULT_CLIENT_CONFIG);
|
|
704
|
-
};
|
|
705
|
-
sync();
|
|
706
|
-
return form.subscribe(sync);
|
|
707
|
-
}, [form]);
|
|
708
|
-
return config;
|
|
709
|
-
}
|
|
710
720
|
function markdownLabels(t) {
|
|
711
721
|
return {
|
|
712
722
|
code: { copyLabel: t("markdown.copy"), copiedLabel: t("markdown.copied") },
|
|
713
723
|
footnotes: t("markdown.footnotes")
|
|
714
724
|
};
|
|
715
725
|
}
|
|
716
|
-
function NotifyCard({
|
|
717
|
-
|
|
726
|
+
function NotifyCard({
|
|
727
|
+
data,
|
|
728
|
+
openFile,
|
|
729
|
+
t,
|
|
730
|
+
seat,
|
|
731
|
+
config: { useCollapsible, useSummaryOnly, useSummaryRender, useBodyExpandedByDefault, useShowTime }
|
|
732
|
+
}) {
|
|
733
|
+
const collapsibleByConfig = useCollapsible((value) => value ?? DEFAULT_CLIENT_CONFIG.collapsible);
|
|
734
|
+
const summaryOnly = useSummaryOnly((value) => value ?? DEFAULT_CLIENT_CONFIG.summaryOnly);
|
|
735
|
+
const summaryRender = useSummaryRender((value) => value ?? DEFAULT_CLIENT_CONFIG.summaryRender);
|
|
736
|
+
const bodyExpandedByDefault = useBodyExpandedByDefault((value) => value ?? DEFAULT_CLIENT_CONFIG.bodyExpandedByDefault);
|
|
737
|
+
const showTime = useShowTime((value) => value ?? DEFAULT_CLIENT_CONFIG.showTime);
|
|
718
738
|
const [open, setOpen] = (0, import_react3.useState)(null);
|
|
739
|
+
if (data.failure !== void 0) {
|
|
740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-notify-failure", "data-tool": NOTIFY_TOOL_NAME, "data-state": "error", children: [
|
|
741
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: t("row.failed") }),
|
|
742
|
+
data.failure.detail.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: data.failure.detail })
|
|
743
|
+
] });
|
|
744
|
+
}
|
|
719
745
|
const title = titleOf({ title: data.title, message: data.message }, t("row.fallbackTitle"));
|
|
720
|
-
if (
|
|
746
|
+
if (summaryOnly && summaryRender === "prose") {
|
|
721
747
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-notify-prose", "data-tool": NOTIFY_TOOL_NAME, "data-state": data.settled ? "settled" : "running", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.MarkdownDelegateProvider, { openFile, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.MarkdownText, { text: title, labels: markdownLabels(t) }) }) });
|
|
722
748
|
}
|
|
723
|
-
const hasBody = !
|
|
724
|
-
const collapsible =
|
|
725
|
-
const expanded = collapsible ? open ??
|
|
726
|
-
const time =
|
|
749
|
+
const hasBody = !summaryOnly && data.message.trim().length > 0;
|
|
750
|
+
const collapsible = collapsibleByConfig && hasBody;
|
|
751
|
+
const expanded = collapsible ? open ?? bodyExpandedByDefault : true;
|
|
752
|
+
const time = showTime ? formatClock(data.time) : null;
|
|
727
753
|
const titleNode = data.settled ? title : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.TextShimmer, { active: true, children: title });
|
|
728
754
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
729
755
|
"div",
|
|
@@ -766,30 +792,33 @@ function NotifyCard({ data, form, openFile, t, seat }) {
|
|
|
766
792
|
|
|
767
793
|
// src/client/NotifyNodeView.tsx
|
|
768
794
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
769
|
-
function NotifyNodeView(
|
|
770
|
-
|
|
795
|
+
function NotifyNodeView(props) {
|
|
796
|
+
const { node, openFile, t } = props;
|
|
797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NotifyCard, { data: node.data, config: props, openFile, t, seat: "node" });
|
|
771
798
|
}
|
|
772
799
|
|
|
773
800
|
// src/client/NotifyRow.tsx
|
|
774
801
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
775
802
|
function NotifyRow(props) {
|
|
776
|
-
const { t
|
|
803
|
+
const { t } = props;
|
|
804
|
+
const failure = props.phase === "result" && props.block.isError ? failureOf(props.block.content, props.block.error) : void 0;
|
|
777
805
|
const preparing = props.phase === "preparing";
|
|
778
|
-
const update = preparing ? { message: "" } : readUpdate(props.block);
|
|
806
|
+
const update = preparing || failure !== void 0 ? { message: "" } : readUpdate(props.block);
|
|
779
807
|
const data = {
|
|
780
808
|
...preparing ? { title: t("row.preparing") } : update.title === void 0 ? {} : { title: update.title },
|
|
781
809
|
message: update.message,
|
|
782
810
|
time: props.block.time,
|
|
783
|
-
settled: props.phase === "result"
|
|
811
|
+
settled: props.phase === "result",
|
|
812
|
+
...failure === void 0 ? {} : { failure }
|
|
784
813
|
};
|
|
785
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(NotifyCard, { data,
|
|
814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(NotifyCard, { data, config: props, openFile: props.openFile, t, seat: "row" });
|
|
786
815
|
}
|
|
787
816
|
|
|
788
817
|
// src/client/ConfigCard.css
|
|
789
818
|
var ConfigCard_default = "/* \u63D2\u4EF6\u9875\u4E0A\u7684\u50AC\u529E\u914D\u7F6E\u5361\u3002 */\n\n.dsh-notify-config {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.dsh-notify-config-row {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 16px;\n}\n\n.dsh-notify-config-info {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n\n.dsh-notify-config-label {\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n}\n\n.dsh-notify-config-hint {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.dsh-notify-config-field {\n display: flex;\n flex: none;\n align-items: center;\n gap: 6px;\n}\n\n.dsh-notify-config-input {\n width: 88px;\n}\n\n.dsh-notify-config-unit {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n}\n\n.dsh-notify-config-error {\n color: var(--dsw-alias-state-error-primary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.dsh-notify-config-note {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n";
|
|
790
819
|
|
|
791
820
|
// src/client/NotifyCard.css
|
|
792
|
-
var NotifyCard_default = '/* `notify_user` \u7684\u8FDB\u5EA6\u5361\uFF1A\u5706\u70B9 + \u6807\u9898 + \u65F6\u95F4\uFF0C\u6B63\u6587\u9ED8\u8BA4\u6536\u8D77\uFF1B\u60AC\u505C\u65F6\u5706\u70B9\u53D8\u6210\u6298\u53E0\u952E\u3002\n *\n * \u884C\u9996\u53D6\u5BBF\u4E3B `DisclosureRow` \u7684\u540C\u4E00\u5957\u51E0\u4F55\uFF1A16px \u56FE\u6807\u6846 + 6px \u95F4\u8DDD\uFF0C\u6807\u9898\u6587\u5B57\u56E0\u6B64\u843D\u5728\n * \u884C\u5DE6\u8FB9\u7F18 +22px\uFF0C\u4E0E\u8FC7\u7A0B\u884C\u3001\u5DE5\u5177\u884C\u7684\u6587\u5B57\u5217\u5BF9\u9F50\uFF1B\u6846\u5BBD\u8DDF\u968F\u5BBF\u4E3B\u7684\u5B57\u53F7\u8F74\uFF0C\u6539\u5B57\u53F7\u540E\u4ECD\u5BF9\u9F50\u3002 */\n\n.dsh-notify-card {\n padding: 2px 0 8px;\n}\n\n/* \u5BF9\u8BDD\u8282\u70B9\u5EA7\u4F4D\uFF1A\u4E0A\u4E0B\u95F4\u8DDD\u4EA4\u7ED9\u5BBF\u4E3B\u7684\u6D41\u95F4\u8DDD\uFF08\u89C1\u6587\u4EF6\u672B\u5C3E\u7684 --dsh-chat-flow-gap\uFF09\uFF0C\u5361\u7247\u672C\u8EAB\u4E0D\u52A0\u5185\u8FB9\u8DDD\u3002 */\n.dsh-notify-card[data-seat="node"] {\n padding: 0;\n}\n\n.dsh-notify-head {\n display: flex;\n align-items: center;\n gap: 6px;\n min-height: 24px;\n}\n\n.dsh-notify-dot {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n width: calc(16px + var(--dsh-content-font-delta, 0px));\n height: calc(16px + var(--dsh-content-font-delta, 0px));\n}\n\n/* \u5706\u70B9\u662F\u5E73\u65F6\u7684\u6837\u5B50\uFF1B\u60AC\u505C\u6807\u9898\u884C\u65F6\u8BA9\u4F4D\u7ED9\u6298\u53E0\u952E\uFF0C\u4E0E\u5BBF\u4E3B DisclosureRow \u7684 leading \u540C\u6784\u3002 */\n.dsh-notify-dot-idle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 1;\n transition: opacity 100ms ease;\n}\n\n.dsh-notify-dot-idle::before {\n content: \'\';\n width: 7px;\n height: 7px;\n border-radius: 50%;\n corner-shape: round;\n background: var(--dsw-alias-state-business-primary);\n}\n\n.dsh-notify-toggle {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n padding: 0;\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-notify-title {\n color: var(--dsw-alias-state-business-primary);\n font-size: 14px;\n font-weight: 600;\n line-height: 22px;\n}\n\n.dsh-notify-chevron {\n position: absolute;\n inset: 0;\n margin: auto;\n color: var(--dsw-alias-state-business-primary);\n opacity: 0;\n transition: transform 0.15s ease, opacity 100ms ease;\n}\n\n/* \u60AC\u505C\u65F6\u6309\u5C55\u5F00\u72B6\u6001\u7ED9\u65B9\u5411\uFF1A\u6536\u8D77\u671D\u4E0B\uFF0C\u5C55\u5F00\u671D\u4E0A\u3002 */\n.dsh-notify-dot[data-open] .dsh-notify-chevron {\n transform: rotate(180deg);\n}\n\n/* \u5C55\u5F00\u4E0E\u6536\u8D77\u90FD\u663E\u793A\u5706\u70B9\uFF1B\u6298\u53E0\u952E\u53EA\u5728\u60AC\u505C\u6807\u9898\u884C\u65F6\u51FA\u73B0\uFF0C\u4E0D\u968F\u5C55\u5F00\u72B6\u6001\u5E38\u9A7B\u3002 */\n@media (hover: hover) {\n /* \u53EA\u6709\u5E26\u6298\u53E0\u952E\u7684\u5361\u7247\u624D\u5728\u60AC\u505C\u65F6\u8BA9\u5706\u70B9\u8BA9\u4F4D\uFF1B\u6458\u8981\u6A21\u5F0F\u6CA1\u6709\u6298\u53E0\u952E\uFF0C\u5706\u70B9\u4FDD\u6301\u4E0D\u52A8\u3002 */\n .dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-dot-idle {\n opacity: 0;\n }\n\n .dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-chevron {\n opacity: 1;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsh-notify-dot-idle,\n .dsh-notify-chevron {\n transition: none;\n }\n}\n\n.dsh-notify-time {\n flex: none;\n margin-left: auto;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n\n/* \u6458\u8981\u6309\u6563\u6587\u6E32\u67D3\uFF1A\u4E0D\u52A0\u5361\u7247\u5185\u8FB9\u8DDD\uFF0C\u6392\u7248\u4EA4\u7ED9\u5BBF\u4E3B\u7684\u6B63\u6587\u6837\u5F0F\u3002 */\n.dsh-notify-prose {\n padding: 0;\n}\n\n/* \u7AD6\u7EBF\u843D\u5728\u5706\u70B9\u7684\u5706\u5FC3\u4E0A\uFF08\u884C\u5DE6\u8FB9\u7F18 +8px\uFF09\uFF0C\u6B63\u6587\u6587\u5B57\u4E0E\u6807\u9898\u540C\u5217\uFF08+22px\uFF09\u3002 */\n.dsh-notify-body {\n margin: 2px 0 0 calc(8px + var(--dsh-content-font-delta, 0px) * 0.5);\n padding-left: calc(13px + var(--dsh-content-font-delta, 0px) * 0.5);\n border-left: 1px solid var(--dsw-alias-border-l1);\n color: var(--dsw-alias-label-primary);\n}\n\n/* \u5BBF\u4E3B\u7684 compact markdown \u81EA\u5E26\u7070\u5B57\uFF0C\u8FD9\u91CC\u6309\u6563\u6587\u9ED1\u8986\u76D6\u5230\u5B83\u7684\u6839\u8282\u70B9\u3002 */\n.dsh-notify-body > div {\n color: var(--dsw-alias-label-primary);\n}\n\n/* \u6298\u53E0\u6001\u7684\u6C47\u62A5\u884C\u4E0E\u6563\u6587\u5757\u540C\u8DDD\uFF1A\u5BBF\u4E3B\u6309 --dsh-chat-flow-gap \u7ED9\u6D41\u8282\u70B9\u7559\u767D\uFF0C\u9ED8\u8BA4 4px\uFF1B\n \u8FD9\u91CC\u628A\u6C47\u62A5\u884C\u81EA\u5DF1\u4E0E\u5B83\u540E\u9762\u90A3\u4E00\u884C\u90FD\u63D0\u5230\u6563\u6587\u7684 12px\u3002 */\n[data-chat-flow-kind="notify-user"] {\n --dsh-chat-flow-gap: 12px;\n}\n\n[data-chat-flow-kind="notify-user"] + * {\n --dsh-chat-flow-gap: 12px;\n}\n';
|
|
821
|
+
var NotifyCard_default = '/* `notify_user` \u7684\u8FDB\u5EA6\u5361\uFF1A\u5706\u70B9 + \u6807\u9898 + \u65F6\u95F4\uFF0C\u6B63\u6587\u9ED8\u8BA4\u6536\u8D77\uFF1B\u60AC\u505C\u65F6\u5706\u70B9\u53D8\u6210\u6298\u53E0\u952E\u3002\n *\n * \u884C\u9996\u53D6\u5BBF\u4E3B `DisclosureRow` \u7684\u540C\u4E00\u5957\u51E0\u4F55\uFF1A16px \u56FE\u6807\u6846 + 6px \u95F4\u8DDD\uFF0C\u6807\u9898\u6587\u5B57\u56E0\u6B64\u843D\u5728\n * \u884C\u5DE6\u8FB9\u7F18 +22px\uFF0C\u4E0E\u8FC7\u7A0B\u884C\u3001\u5DE5\u5177\u884C\u7684\u6587\u5B57\u5217\u5BF9\u9F50\uFF1B\u6846\u5BBD\u8DDF\u968F\u5BBF\u4E3B\u7684\u5B57\u53F7\u8F74\uFF0C\u6539\u5B57\u53F7\u540E\u4ECD\u5BF9\u9F50\u3002 */\n\n.dsh-notify-card {\n padding: 2px 0 8px;\n}\n\n/* \u5BF9\u8BDD\u8282\u70B9\u5EA7\u4F4D\uFF1A\u4E0A\u4E0B\u95F4\u8DDD\u4EA4\u7ED9\u5BBF\u4E3B\u7684\u6D41\u95F4\u8DDD\uFF08\u89C1\u6587\u4EF6\u672B\u5C3E\u7684 --dsh-chat-flow-gap\uFF09\uFF0C\u5361\u7247\u672C\u8EAB\u4E0D\u52A0\u5185\u8FB9\u8DDD\u3002 */\n.dsh-notify-card[data-seat="node"] {\n padding: 0;\n}\n\n.dsh-notify-head {\n display: flex;\n align-items: center;\n gap: 6px;\n min-height: 24px;\n}\n\n.dsh-notify-dot {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n width: calc(16px + var(--dsh-content-font-delta, 0px));\n height: calc(16px + var(--dsh-content-font-delta, 0px));\n}\n\n/* \u5706\u70B9\u662F\u5E73\u65F6\u7684\u6837\u5B50\uFF1B\u60AC\u505C\u6807\u9898\u884C\u65F6\u8BA9\u4F4D\u7ED9\u6298\u53E0\u952E\uFF0C\u4E0E\u5BBF\u4E3B DisclosureRow \u7684 leading \u540C\u6784\u3002 */\n.dsh-notify-dot-idle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 1;\n transition: opacity 100ms ease;\n}\n\n.dsh-notify-dot-idle::before {\n content: \'\';\n width: 7px;\n height: 7px;\n border-radius: 50%;\n corner-shape: round;\n background: var(--dsw-alias-state-business-primary);\n}\n\n.dsh-notify-toggle {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n padding: 0;\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-notify-title {\n color: var(--dsw-alias-state-business-primary);\n font-size: 14px;\n font-weight: 600;\n line-height: 22px;\n}\n\n.dsh-notify-chevron {\n position: absolute;\n inset: 0;\n margin: auto;\n color: var(--dsw-alias-state-business-primary);\n opacity: 0;\n transition: transform 0.15s ease, opacity 100ms ease;\n}\n\n/* \u60AC\u505C\u65F6\u6309\u5C55\u5F00\u72B6\u6001\u7ED9\u65B9\u5411\uFF1A\u6536\u8D77\u671D\u4E0B\uFF0C\u5C55\u5F00\u671D\u4E0A\u3002 */\n.dsh-notify-dot[data-open] .dsh-notify-chevron {\n transform: rotate(180deg);\n}\n\n/* \u5C55\u5F00\u4E0E\u6536\u8D77\u90FD\u663E\u793A\u5706\u70B9\uFF1B\u6298\u53E0\u952E\u53EA\u5728\u60AC\u505C\u6807\u9898\u884C\u65F6\u51FA\u73B0\uFF0C\u4E0D\u968F\u5C55\u5F00\u72B6\u6001\u5E38\u9A7B\u3002 */\n@media (hover: hover) {\n /* \u53EA\u6709\u5E26\u6298\u53E0\u952E\u7684\u5361\u7247\u624D\u5728\u60AC\u505C\u65F6\u8BA9\u5706\u70B9\u8BA9\u4F4D\uFF1B\u6458\u8981\u6A21\u5F0F\u6CA1\u6709\u6298\u53E0\u952E\uFF0C\u5706\u70B9\u4FDD\u6301\u4E0D\u52A8\u3002 */\n .dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-dot-idle {\n opacity: 0;\n }\n\n .dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-chevron {\n opacity: 1;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsh-notify-dot-idle,\n .dsh-notify-chevron {\n transition: none;\n }\n}\n\n.dsh-notify-time {\n flex: none;\n margin-left: auto;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n\n/* \u6458\u8981\u6309\u6563\u6587\u6E32\u67D3\uFF1A\u4E0D\u52A0\u5361\u7247\u5185\u8FB9\u8DDD\uFF0C\u6392\u7248\u4EA4\u7ED9\u5BBF\u4E3B\u7684\u6B63\u6587\u6837\u5F0F\u3002 */\n.dsh-notify-prose {\n padding: 0;\n}\n\n/* \u7AD6\u7EBF\u843D\u5728\u5706\u70B9\u7684\u5706\u5FC3\u4E0A\uFF08\u884C\u5DE6\u8FB9\u7F18 +8px\uFF09\uFF0C\u6B63\u6587\u6587\u5B57\u4E0E\u6807\u9898\u540C\u5217\uFF08+22px\uFF09\u3002 */\n.dsh-notify-body {\n margin: 2px 0 0 calc(8px + var(--dsh-content-font-delta, 0px) * 0.5);\n padding-left: calc(13px + var(--dsh-content-font-delta, 0px) * 0.5);\n border-left: 1px solid var(--dsw-alias-border-l1);\n color: var(--dsw-alias-label-primary);\n}\n\n/* \u5BBF\u4E3B\u7684 compact markdown \u81EA\u5E26\u7070\u5B57\uFF0C\u8FD9\u91CC\u6309\u6563\u6587\u9ED1\u8986\u76D6\u5230\u5B83\u7684\u6839\u8282\u70B9\u3002 */\n.dsh-notify-body > div {\n color: var(--dsw-alias-label-primary);\n}\n\n/* \u6298\u53E0\u6001\u7684\u6C47\u62A5\u884C\u4E0E\u6563\u6587\u5757\u540C\u8DDD\uFF1A\u5BBF\u4E3B\u6309 --dsh-chat-flow-gap \u7ED9\u6D41\u8282\u70B9\u7559\u767D\uFF0C\u9ED8\u8BA4 4px\uFF1B\n \u8FD9\u91CC\u628A\u6C47\u62A5\u884C\u81EA\u5DF1\u4E0E\u5B83\u540E\u9762\u90A3\u4E00\u884C\u90FD\u63D0\u5230\u6563\u6587\u7684 12px\u3002 */\n[data-chat-flow-kind="notify-user"] {\n --dsh-chat-flow-gap: 12px;\n}\n\n[data-chat-flow-kind="notify-user"] + * {\n --dsh-chat-flow-gap: 12px;\n}\n\n.dsh-notify-failure {\n color: var(--dsw-alias-state-error-primary);\n overflow-wrap: anywhere;\n white-space: pre-wrap;\n}\n';
|
|
793
822
|
|
|
794
823
|
// src/client/EnabledToggle.css
|
|
795
824
|
var EnabledToggle_default = "/* \u6A21\u578B\u4E0E\u63A8\u7406\u7B49\u7EA7\u83DC\u5355\u91CC\u7684\u300C\u4E3B\u52A8\u6C47\u62A5\u300D\u5F00\u5173\u3002 */\n\n.dsh-notify-toggle-row {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n min-height: 34px;\n padding: 0 8px;\n border-radius: var(--dsw-radius-md);\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n}\n\n.dsh-notify-toggle-label {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n}\n\n.dsh-notify-toggle-info {\n position: relative;\n z-index: 1;\n flex: none;\n width: 20px;\n height: 20px;\n padding: 0;\n color: var(--dsw-alias-label-caption);\n}\n\n/* \u5F00\u5173\u7684\u70B9\u51FB\u533A\u94FA\u6EE1\u6574\u884C\uFF0C\u4F46\u4E0D\u5305\u4F4F\u4FE1\u606F\u6309\u94AE\u3002 */\n.dsh-notify-toggle-row .dsh-notify-toggle-switch {\n position: static;\n}\n\n.dsh-notify-toggle-switch::after {\n content: '';\n position: absolute;\n inset: 0;\n border-radius: var(--dsw-radius-md);\n}\n\n.dsh-notify-toggle-row:has(.dsh-notify-toggle-switch:focus-visible) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n@media (hover: hover) {\n .dsh-notify-toggle-row:has(.dsh-notify-toggle-switch:not(:disabled)):hover {\n background: var(--dsw-alias-interactive-bg-hover);\n }\n}\n";
|
|
@@ -818,7 +847,14 @@ function removeStyles() {
|
|
|
818
847
|
if (typeof document === "undefined") return;
|
|
819
848
|
for (const tag of document.head.querySelectorAll(`style[data-plugin="${BUNDLE_NAME}"]`)) tag.remove();
|
|
820
849
|
}
|
|
821
|
-
function apply(ctx) {
|
|
850
|
+
function apply(ctx, config) {
|
|
851
|
+
const cardHooks = {
|
|
852
|
+
collapsible: config.collapsible,
|
|
853
|
+
summaryOnly: config.summaryOnly,
|
|
854
|
+
summaryRender: config.summaryRender,
|
|
855
|
+
bodyExpandedByDefault: config.bodyExpandedByDefault,
|
|
856
|
+
showTime: config.showTime
|
|
857
|
+
};
|
|
822
858
|
ctx.effect(() => {
|
|
823
859
|
injectStyles();
|
|
824
860
|
return () => {
|
|
@@ -827,36 +863,33 @@ function apply(ctx) {
|
|
|
827
863
|
}, "dsh-notify-user: stylesheets");
|
|
828
864
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dsh-notify-user: dictionaries");
|
|
829
865
|
ctx.effect(() => {
|
|
830
|
-
|
|
866
|
+
let placement;
|
|
831
867
|
let dispose;
|
|
832
868
|
const sync = () => {
|
|
833
|
-
const
|
|
834
|
-
if (
|
|
835
|
-
dispose ??= ctx.uiConversation.events.register(createNotifyDefinition());
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
869
|
+
const next = config.cardPlacement.get() === "inline" ? "inline" : DEFAULT_CARD_PLACEMENT;
|
|
870
|
+
if (next === placement) return;
|
|
838
871
|
dispose?.();
|
|
839
|
-
|
|
872
|
+
placement = next;
|
|
873
|
+
dispose = next === "boundary" ? ctx.uiConversation.events.register(createNotifyDefinition()) : ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
|
|
874
|
+
name: "tool.call.toolview",
|
|
875
|
+
key: NOTIFY_TOOL_NAME,
|
|
876
|
+
locale: NS,
|
|
877
|
+
inject: () => ({ hooks: cardHooks })
|
|
878
|
+
}, NotifyRow));
|
|
840
879
|
};
|
|
841
880
|
sync();
|
|
842
|
-
const unsubscribe =
|
|
881
|
+
const unsubscribe = config.cardPlacement.subscribe(sync);
|
|
843
882
|
return () => {
|
|
844
883
|
unsubscribe();
|
|
845
884
|
dispose?.();
|
|
846
885
|
};
|
|
847
|
-
}, "dsh-notify-user:
|
|
886
|
+
}, "dsh-notify-user: card placement");
|
|
848
887
|
ctx.slots.inject("conversation.chat.node", () => ctx.slots.register({
|
|
849
888
|
name: "conversation.chat.node",
|
|
850
889
|
key: NOTIFY_NODE_KIND,
|
|
851
890
|
locale: NS,
|
|
852
|
-
inject: () => ({
|
|
891
|
+
inject: () => ({ hooks: cardHooks })
|
|
853
892
|
}, NotifyNodeView));
|
|
854
|
-
ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
|
|
855
|
-
name: "tool.call.toolview",
|
|
856
|
-
key: NOTIFY_TOOL_NAME,
|
|
857
|
-
locale: NS,
|
|
858
|
-
inject: () => ({ form: ctx.configForms.get(SETTINGS_NAMESPACE) })
|
|
859
|
-
}, NotifyRow));
|
|
860
893
|
ctx.slots.inject(MODEL_OPTIONS_SLOT, () => ctx.slots.register({
|
|
861
894
|
name: MODEL_OPTIONS_SLOT,
|
|
862
895
|
id: "notify-user-enabled",
|