@xiangyixie/dsh-superagent 0.16.0 → 0.16.2

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
@@ -8,6 +8,46 @@ along with the next code release. A doc-only version leaves `lib/` and `bin/`
8
8
  byte-identical to the version before it, and the pinned install line in the
9
9
  README is updated to the version being released.
10
10
 
11
+ ## 0.16.2 — 2026-11-17
12
+
13
+ ### 变化
14
+
15
+ - **「排队 / 插话」不再用浏览器原生 `<select>`。** 换成宿主导出的 `Menu`:
16
+ 深浅两套语义 token、32px 行高、圆角与阴影都来自宿主菜单,选中态有对勾,
17
+ 支持方向键 / Home / End / Enter、Esc 关闭、点击外部关闭、关闭后焦点回到
18
+ 触发器,并用 `portal` + CSS anchor 定位,不会被输入卡裁掉。
19
+ - **原生提示条换成宿主 `Tooltip`。** 刷新、新建会话、附件、发送、停止、会话行、
20
+ 任务线行、工具参数气泡都改用宿主 `Tooltip`(无 primitives 的宿主才退回
21
+ `title`),不再出现系统黄框提示。
22
+ - 附件仍用隐藏的 `<input type="file">` 触发系统文件选择器——宿主没有文件选择
23
+ 组件,这个输入框本身不可见,外观由旁边的宿主风格按钮承担。
24
+
25
+ ## 0.16.1 — 2026-11-17
26
+
27
+ ### 变化
28
+
29
+ - **运行中能停下来了。** 发送键在回合运行时变成宿主同款的 34px 圆形停止键
30
+ (中间 10px 圆角方块),点击后进入取消中并画转圈;后端补了真正的回合级取消:
31
+ 新增 `POST /api/console/cancel`,走宿主的 `sessionController.cancel({ sessionId })`,
32
+ 成功广播 `canceling` 帧,回合结束后自动复位。宿主没有取消能力时明确返回 501,
33
+ 不会只画一个按钮。
34
+ - **用户气泡换成宿主的 `UserMessageBubble`。** 圆角 `radius-xl` 20、内边距
35
+ `10px 16px`、行高 `calc(22px + delta)`、字号跟 `--dsh-content-font-size`,浅色下
36
+ 是宿主的 `deepseek-50` 浅蓝,不再是自造的灰色。
37
+ - **正文列宽按宿主公式。** 正文列改为
38
+ `clamp(680px, var(--dsh-chat-user-width) * .64, 920px)`,滚动区左右各留 32px;
39
+ 审批卡和 toast 跟随同一列宽,不再贴边。
40
+ - **Markdown 改用宿主的 `MarkdownText`。** 自造的渲染子集整段删除,表格、引用、
41
+ 分割线、嵌套列表、斜体、围栏语言标记和代码高亮全部由宿主组件负责,标题字号
42
+ 走 `--dsw-font-markdown-*`。
43
+ - **审批卡对齐宿主。** 外框 `radius-xl` 20、`border warn-secondary`、
44
+ `bg input-major`、`shadow lv2`;顶部加 `warn-tertiary` 警示条(`StateDot`
45
+ warning + 「等待你的批准」)。按钮顺序改为 拒绝 → 允许一次 → 本会话都放行
46
+ (primary);请求期间 `disabled` + `aria-busy`,失败会弹出可见提示,不再
47
+ 吞异常。
48
+ - 修掉拼错的 token:`--dsw-alias-state-warning-primary` → 宿主真实存在的
49
+ `--dsw-alias-state-warn-primary`。
50
+
11
51
  ## 0.16.0 — 2026-11-17
12
52
 
13
53
  ### 变化
package/README.en.md CHANGED
@@ -36,12 +36,12 @@ Three steps. The desktop app and the CLI install the same plugin; each step says
36
36
 
37
37
  ### 1. Install
38
38
 
39
- Desktop: **Plugins** → **Add plugin** → enter `@xiangyixie/dsh-superagent@0.16.0` → install.
39
+ Desktop: **Plugins** → **Add plugin** → enter `@xiangyixie/dsh-superagent@0.16.2` → install.
40
40
 
41
41
  CLI:
42
42
 
43
43
  ```bash
44
- dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.0
44
+ dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.2
45
45
  ```
46
46
 
47
47
  **Restart DSH** afterwards — plugins are loaded once at host startup. You can also add the [plugin index](https://raw.githubusercontent.com/LittleChenLiya/dsh-superagent/main/plugin-index.json) on the **Discover** page for one-click installs; upgrades are always remove-then-add.
@@ -1666,7 +1666,7 @@ appears to "hang" until the ignored-abort child returns.
1666
1666
 
1667
1667
  | What you see | What it means | What to do |
1668
1668
  | --- | --- | --- |
1669
- | `superagent_*` tools do not exist | The bundle row is not mounted, or the host refused to load the plugin. | Run `--dump-config` and check for the `@xiangyixie/dsh-superagent` block; reinstall with `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.0` and read the host log for `[dsh-superagent]` lines. |
1669
+ | `superagent_*` tools do not exist | The bundle row is not mounted, or the host refused to load the plugin. | Run `--dump-config` and check for the `@xiangyixie/dsh-superagent` block; reinstall with `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.2` and read the host log for `[dsh-superagent]` lines. |
1670
1670
  | `Cannot find module .../lib/control.js` (or `watch.js` / `report.js` / `wizard.js`), or `[dsh-superagent] dsh-superagent failed to load because a file it imports is missing: ...` in the host log | The copy in that profile is incomplete — an `add` that was interrupted leaves a partial extraction. From 0.14.3 the entry point names the missing file itself. The published package is not the cause: every version ships all thirty-four `lib/` files. | Delete the plugin's directory under the profile's `node_modules` (scoped `@xiangyixie/dsh-superagent`, or unscoped `dsh-superagent` from an older tarball install) and run the same `add` command again, with the version number. Do not copy files in by hand. |
1671
1671
  | `[error] the model provider rejected the API key` | The key env var is missing in the process that started the host. | Export `DEEPSEEK_API_KEY` (the default route) or the variable your route names, then restart `dsh`. |
1672
1672
  | `MISSING_CREDENTIAL ... no API key for provider route "..."` | The profile's route has no credential in the environment. | Set the env var named for that route and restart. The error line names the route, so use that, not this page. |
package/README.md CHANGED
@@ -36,12 +36,12 @@ dsh-superagent 把这件事接过去:你说一句目标,它负责拆、负
36
36
 
37
37
  ### 1. 装
38
38
 
39
- 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.16.0` → 安装。
39
+ 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.16.2` → 安装。
40
40
 
41
41
  命令行:
42
42
 
43
43
  ```bash
44
- dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.0
44
+ dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.2
45
45
  ```
46
46
 
47
47
  装完**重启 DSH**(插件只在宿主启动时加载一次)。也可以从「发现」页添加[插件索引](https://raw.githubusercontent.com/LittleChenLiya/dsh-superagent/main/plugin-index.json)一键安装;升级一律先 `remove` 再 `add`。
@@ -1090,7 +1090,7 @@ SHA-256)。`--format html` 把同样的内容写成一个自包含
1090
1090
 
1091
1091
  | 你看到的 | 含义 | 怎么办 |
1092
1092
  | --- | --- | --- |
1093
- | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.0` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1093
+ | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.2` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1094
1094
  | `Cannot find module .../lib/control.js`(或 `watch.js` / `report.js` / `wizard.js`),或宿主日志里的 `[dsh-superagent] dsh-superagent failed to load because a file it imports is missing: ...` | 那个 profile 里的副本不完整——被中断的 `add` 会留下残缺的解包结果。0.14.3 起的入口会直接点名缺哪个文件。已发布的包不是原因:每个版本都带全部三十四个 `lib/` 文件。 | 删掉 profile 的 `node_modules` 下该插件的目录(带 scope 的 `@xiangyixie/dsh-superagent`,或旧 tarball 安装留下的无 scope 的 `dsh-superagent`),再用同一条 `add` 命令重装,并带上版本号。不要手工拷贝文件进去。 |
1095
1095
  | `[error] the model provider rejected the API key` | 启动宿主的那个进程里缺 key 环境变量。 | 导出 `DEEPSEEK_API_KEY`(默认路由)或你那条路由声明的变量,然后重启 `dsh`。 |
1096
1096
  | `MISSING_CREDENTIAL ... no API key for provider route "..."` | profile 的路由在环境里没有凭据。 | 设置该路由对应的环境变量并重启。错误行里写了路由名,以它为准,不要照本文。 |
package/README.zh.md CHANGED
@@ -36,12 +36,12 @@ dsh-superagent 把这件事接过去:你说一句目标,它负责拆、负
36
36
 
37
37
  ### 1. 装
38
38
 
39
- 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.16.0` → 安装。
39
+ 桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.16.2` → 安装。
40
40
 
41
41
  命令行:
42
42
 
43
43
  ```bash
44
- dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.0
44
+ dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.2
45
45
  ```
46
46
 
47
47
  装完**重启 DSH**(插件只在宿主启动时加载一次)。也可以从「发现」页添加[插件索引](https://raw.githubusercontent.com/LittleChenLiya/dsh-superagent/main/plugin-index.json)一键安装;升级一律先 `remove` 再 `add`。
@@ -1090,7 +1090,7 @@ SHA-256)。`--format html` 把同样的内容写成一个自包含
1090
1090
 
1091
1091
  | 你看到的 | 含义 | 怎么办 |
1092
1092
  | --- | --- | --- |
1093
- | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.0` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1093
+ | `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.2` 重装,并在宿主日志里找 `[dsh-superagent]` 行。 |
1094
1094
  | `Cannot find module .../lib/control.js`(或 `watch.js` / `report.js` / `wizard.js`),或宿主日志里的 `[dsh-superagent] dsh-superagent failed to load because a file it imports is missing: ...` | 那个 profile 里的副本不完整——被中断的 `add` 会留下残缺的解包结果。0.14.3 起的入口会直接点名缺哪个文件。已发布的包不是原因:每个版本都带全部三十四个 `lib/` 文件。 | 删掉 profile 的 `node_modules` 下该插件的目录(带 scope 的 `@xiangyixie/dsh-superagent`,或旧 tarball 安装留下的无 scope 的 `dsh-superagent`),再用同一条 `add` 命令重装,并带上版本号。不要手工拷贝文件进去。 |
1095
1095
  | `[error] the model provider rejected the API key` | 启动宿主的那个进程里缺 key 环境变量。 | 导出 `DEEPSEEK_API_KEY`(默认路由)或你那条路由声明的变量,然后重启 `dsh`。 |
1096
1096
  | `MISSING_CREDENTIAL ... no API key for provider route "..."` | profile 的路由在环境里没有凭据。 | 设置该路由对应的环境变量并重启。错误行里写了路由名,以它为准,不要照本文。 |
package/lib/client.js CHANGED
@@ -54,6 +54,11 @@ window.__ModuleLoader__.load({
54
54
  const h = react ? react.createElement : null
55
55
  const Button = ui && typeof ui.Button === 'function' ? ui.Button : null
56
56
  const FishLogo = ui && typeof ui.FishLogo === 'function' ? ui.FishLogo : null
57
+ const MarkdownText = ui && typeof ui.MarkdownText === 'function' ? ui.MarkdownText : null
58
+ const UserMessageBubble = ui && typeof ui.UserMessageBubble === 'function' ? ui.UserMessageBubble : null
59
+ const StateDot = ui && typeof ui.StateDot === 'function' ? ui.StateDot : null
60
+ const Menu = ui && typeof ui.Menu === 'function' ? ui.Menu : null
61
+ const Tooltip = ui && typeof ui.Tooltip === 'function' ? ui.Tooltip : null
57
62
  const ICONS = {
58
63
  spark: ui?.IconSparkleRegular ?? ui?.IconSparkleMedium,
59
64
  send: ui?.IconSendOutlineRegular ?? ui?.IconSendOutlineMedium,
@@ -65,6 +70,35 @@ window.__ModuleLoader__.load({
65
70
  check: ui?.IconCheckOutlineRegular ?? ui?.IconCheckOutlineMedium,
66
71
  close: ui?.IconCloseOutlineRegular ?? ui?.IconCloseOutlineMedium,
67
72
  folder: ui?.IconFolderCloseRegular ?? ui?.IconFolderCloseMedium,
73
+ chevron: ui?.IconChevronDownOutlineRegular ?? ui?.IconChevronDownOutlineMedium,
74
+ }
75
+ // MarkdownText reads `labels.code` on every fenced block, so the host
76
+ // component is only safe with this shape filled in.
77
+ const MARKDOWN_LABELS = {
78
+ code: {
79
+ copyLabel: '复制',
80
+ copiedLabel: '已复制',
81
+ toolbarLabels: {
82
+ codeLabel: '代码',
83
+ wrapLabel: '换行',
84
+ unwrapLabel: '取消换行',
85
+ },
86
+ },
87
+ footnotes: '脚注',
88
+ }
89
+ /** Composer delivery modes, rendered by the host Menu. */
90
+ const MODES = [
91
+ { id: 'queue', label: '排队' },
92
+ { id: 'steer', label: '插话' },
93
+ ]
94
+
95
+ /**
96
+ * Host tooltip when it exists; the native `title` only survives as the
97
+ * fallback for a host that ships no primitives at all.
98
+ */
99
+ function tipped(label, node, side = 'bottom', key) {
100
+ if (Tooltip) return h(Tooltip, { key, label, side }, node)
101
+ return react.cloneElement(node, { key, title: label })
68
102
  }
69
103
 
70
104
  /**
@@ -75,7 +109,7 @@ window.__ModuleLoader__.load({
75
109
  * 12px gaps, send 34px circle on button-info-fill, stats row 22px.
76
110
  */
77
111
  const CSS = `
78
- .dsa-root{display:flex;flex-direction:column;height:100%;min-width:0;background:var(--dsw-alias-bg-base,rgb(21,21,23));color:var(--dsw-alias-label-primary,#f9fafb);font-family:var(--dsw-font-family,inherit);font-size:14px;line-height:22px}
112
+ .dsa-root{--dsa-col:clamp(680px,calc(var(--dsh-chat-user-width,100%) * .64),920px);display:flex;flex-direction:column;height:100%;min-width:0;background:var(--dsw-alias-bg-base,rgb(21,21,23));color:var(--dsw-alias-label-primary,#f9fafb);font-family:var(--dsw-font-family,inherit);font-size:14px;line-height:22px}
79
113
  .dsa-header{display:flex;align-items:center;gap:10px;flex:none;box-sizing:border-box;min-height:76px;padding:10px 28px 0 20px;border-bottom:.5px solid var(--dsw-alias-border-l3,rgba(255,255,255,.12))}
80
114
  .dsa-crumbs{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden;white-space:nowrap}
81
115
  .dsa-crumb{display:inline-block;max-width:220px;overflow:hidden;padding:4px 8px;border:0;border-radius:var(--dsw-radius-md,12px);background:transparent;color:var(--dsw-alias-label-tertiary,rgb(129,133,140));font-size:14px;line-height:20px;text-overflow:ellipsis;white-space:nowrap}
@@ -89,19 +123,19 @@ window.__ModuleLoader__.load({
89
123
  .dsa-status{display:inline-flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
90
124
  .dsa-dot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-caption,rgb(129,133,140))}
91
125
  .dsa-dot[data-state=live]{background:var(--dsw-alias-state-success-primary,#22c55e)}
92
- .dsa-dot[data-state=warn]{background:var(--dsw-alias-state-warning-primary,#f59e0b)}
126
+ .dsa-dot[data-state=warn]{background:var(--dsw-alias-state-warn-primary,#f59e0b)}
93
127
  .dsa-body{display:flex;flex:1;min-height:0}
94
128
  .dsa-main{position:relative;display:flex;flex-direction:column;flex:1;min-width:0}
95
- .dsa-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;margin-right:2px;scrollbar-gutter:stable}
129
+ .dsa-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;margin-right:2px;padding:0 32px;scrollbar-gutter:stable}
96
130
  .dsa-scroll::-webkit-scrollbar{width:10px}
97
131
  .dsa-scroll::-webkit-scrollbar-thumb{border-radius:5px;background:var(--dsw-alias-scrollbar-bg-l1,rgba(255,255,255,.16))}
98
- .dsa-flow{width:min(100%,clamp(680px,64%,920px));margin:0 auto;padding:16px 0 8px;box-sizing:border-box}
132
+ .dsa-flow{width:min(100%,var(--dsa-col));margin:0 auto;padding:16px 0 8px;box-sizing:border-box}
99
133
  .dsa-hero{flex:1;display:flex;align-items:center;justify-content:center;min-height:0;padding:0 24px}
100
- .dsa-hero-stack{display:flex;flex-direction:column;gap:12px;width:100%;max-width:calc(clamp(680px,64%,920px) + 32px);padding-bottom:32px}
134
+ .dsa-hero-stack{display:flex;flex-direction:column;gap:12px;width:100%;max-width:calc(var(--dsa-col) + 32px);padding-bottom:32px}
101
135
  .dsa-hero-title{display:flex;align-items:center;justify-content:center;gap:10px;font-size:26px;line-height:32px;font-weight:500;color:var(--dsw-alias-label-primary,#f9fafb)}
102
136
  .dsa-hero-note{text-align:center;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
103
137
  .dsa-composer{flex:none;padding:0 16px 4px;background:var(--dsw-alias-bg-base,rgb(21,21,23))}
104
- .dsa-card{display:flex;flex-direction:column;gap:12px;box-sizing:border-box;width:100%;max-width:calc(clamp(680px,64%,920px) + 32px);margin:0 auto;padding-top:8px;border-radius:var(--dsw-radius-panel,28px);background:var(--dsw-specific-input-major,rgb(35,35,36));box-shadow:var(--dsw-elevation-soft,0 2px 12px rgba(0,0,0,.18))}
138
+ .dsa-card{display:flex;flex-direction:column;gap:12px;box-sizing:border-box;width:100%;max-width:calc(var(--dsa-col) + 32px);margin:0 auto;padding-top:8px;border-radius:var(--dsw-radius-panel,28px);background:var(--dsw-specific-input-major,rgb(35,35,36));box-shadow:var(--dsw-elevation-soft,0 2px 12px rgba(0,0,0,.18))}
105
139
  .dsa-input{box-sizing:border-box;width:100%;min-height:36px;max-height:336px;padding:4px 8px 0 14px;border:0;outline:none;background:transparent;color:var(--dsw-alias-label-primary,#f9fafb);font:inherit;font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));resize:none;overflow-y:auto}
106
140
  .dsa-input::placeholder{color:var(--dsw-alias-label-caption,rgb(129,133,140))}
107
141
  .dsa-card[data-hero=true] .dsa-input{min-height:52px}
@@ -110,37 +144,34 @@ window.__ModuleLoader__.load({
110
144
  .dsa-trailing{margin-left:auto;flex:none}
111
145
  .dsa-add{display:grid;place-items:center;flex:none;width:28px;height:28px;border:0;border-radius:999px;background:var(--dsw-specific-selector,rgba(255,255,255,.08));color:var(--dsw-alias-label-primary,#f9fafb);cursor:pointer}
112
146
  .dsa-add:hover{background:var(--dsw-alias-interactive-bg-hover-solid,rgba(255,255,255,.14))}
113
- .dsa-chip{height:28px;padding:0 20px 0 8px;border:0;border-radius:var(--dsw-radius-sm,8px);background-color:transparent;background-repeat:no-repeat;background-position:right 4px center;background-size:12px 12px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");color:var(--dsw-alias-label-secondary,rgb(207,211,214));font-size:13px;line-height:20px;font-weight:500;white-space:nowrap;cursor:pointer;appearance:none}
114
- .dsa-chip:hover{background-color:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
147
+ .dsa-chip{display:inline-flex;align-items:center;gap:4px;height:28px;padding:0 8px;border:0;border-radius:var(--dsw-radius-sm,8px);background-color:transparent;color:var(--dsw-alias-label-secondary,rgb(207,211,214));font-size:13px;line-height:20px;font-weight:500;white-space:nowrap;cursor:pointer;appearance:none}
148
+ .dsa-chip:hover,.dsa-chip[aria-expanded=true]{background-color:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
115
149
  .dsa-send{display:grid;place-items:center;flex:none;width:34px;height:34px;border:0;border-radius:999px;background:var(--dsw-alias-button-info-fill,#3964fe);color:var(--dsw-alias-label-on-color,#fff);cursor:pointer;transform:translateY(-2px);transition:background-color 100ms ease}
116
150
  .dsa-send:hover:not(:disabled){background:var(--dsw-alias-button-info-hover,#2f57e6)}
117
151
  .dsa-send:disabled{opacity:.4;cursor:default}
118
152
  .dsa-send svg{width:15px;height:15px}
153
+ .dsa-send[data-mode=stop] svg{width:10px;height:10px;border-radius:2px}
154
+ .dsa-spin{width:14px;height:14px;border-radius:50%;border:2px solid rgba(255,255,255,.35);border-top-color:var(--dsw-alias-label-on-color,#fff);animation:dsa-spin .8s linear infinite}
155
+ @keyframes dsa-spin{to{transform:rotate(360deg)}}
119
156
  .dsa-stats{min-height:calc(22px + var(--dsh-content-font-delta-secondary,0px));display:flex;align-items:center;justify-content:center;gap:10px;font-size:12px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
120
157
  .dsa-msg{padding:0 0 4px}
121
158
  .dsa-user{display:flex;flex-direction:column;align-items:flex-end;gap:6px;margin-bottom:16px}
122
- .dsa-bubble{max-width:min(calc(clamp(680px,64%,920px) * .702),82%);padding:10px 14px;border-radius:var(--dsw-radius-lg,16px);background:var(--dsw-alias-interactive-bg-hover-solid,rgba(255,255,255,.08));white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px;line-height:24px}
159
+ .dsa-bubble{max-width:min(calc(var(--dsa-col) * .702),82%);padding:10px 16px;border-radius:var(--dsw-radius-xl,20px);background:var(--dsw-specific-bubble,var(--dsw-static-deepseek-50,#eef4ff));color:var(--dsw-alias-label-primary,#f9fafb);font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));white-space:pre-wrap;overflow-wrap:anywhere}
123
160
  .dsa-bubble[data-pending=true]{opacity:.6}
124
- .dsa-assistant{display:flex;flex-direction:column;gap:6px;margin-bottom:16px;font-size:14px;line-height:24px;overflow-wrap:anywhere}
125
- .dsa-md>*:first-child{margin-top:0}
126
- .dsa-md>*:last-child{margin-bottom:0}
127
- .dsa-md p{margin:0 0 8px}
128
- .dsa-md ul,.dsa-md ol{margin:0 0 8px;padding-left:22px}
129
- .dsa-md h1,.dsa-md h2,.dsa-md h3{margin:12px 0 8px;font-size:15px;line-height:24px;font-weight:600}
130
- .dsa-md a{color:var(--dsw-alias-state-business-primary,#7aaaff);text-decoration:none}
131
- .dsa-md code{padding:1px 5px;border-radius:4px;background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08));font-family:var(--ds-font-family-code,ui-monospace,monospace);font-size:13px}
132
- .dsa-md pre{margin:0 0 8px;padding:12px;border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-layer-2,rgb(35,35,36));overflow-x:auto}
133
- .dsa-md pre code{padding:0;background:transparent}
161
+ .dsa-assistant{display:flex;flex-direction:column;gap:6px;margin-bottom:16px;font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));overflow-wrap:anywhere}
162
+ .dsa-md-plain{white-space:pre-wrap;overflow-wrap:anywhere}
134
163
  .dsa-tools-row{display:flex;flex-wrap:wrap;gap:6px}
135
164
  .dsa-tool{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 8px;border-radius:var(--dsw-radius-xs,4px);background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06));font-size:12px;line-height:16px;color:var(--dsw-alias-label-secondary,rgb(207,211,214))}
136
165
  .dsa-tool[data-status=err]{color:var(--dsw-alias-state-error-primary,#f25a5a)}
137
166
  .dsa-reasoning{font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140));white-space:pre-wrap}
138
167
  .dsa-typing{display:inline-flex;align-items:center;gap:8px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
139
- .dsa-approvals{display:flex;flex-direction:column;gap:8px;width:min(100%,clamp(680px,64%,920px));margin:0 auto;padding:0 0 8px}
140
- .dsa-approval{display:flex;flex-direction:column;gap:10px;padding:12px;border:1px solid var(--dsw-alias-border-l3,rgba(255,255,255,.12));border-radius:var(--dsw-radius-lg,16px);background:var(--dsw-alias-bg-layer-1,rgb(35,35,36))}
168
+ .dsa-approvals{display:flex;flex-direction:column;gap:8px;width:min(calc(100% - 64px),var(--dsa-col));margin:0 auto;padding:0 0 8px}
169
+ .dsa-approval{display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--dsw-alias-state-warn-secondary,var(--dsw-static-amber-400,#fbbf24));border-radius:var(--dsw-radius-xl,20px);background:var(--dsw-specific-input-major,rgb(35,35,36));box-shadow:var(--dsw-shadow-lv2,0 4px 16px rgba(0,0,0,.18))}
170
+ .dsa-approval-bar{display:flex;align-items:center;gap:8px;padding:8px 14px;background:var(--dsw-alias-state-warn-tertiary,var(--dsw-static-amber-100,#fef3c7));color:var(--dsw-alias-state-warn-label,var(--dsw-static-amber-600,#d97706));font-size:13px;line-height:20px;font-weight:500}
171
+ .dsa-approval-main{display:flex;flex-direction:column;gap:10px;padding:12px 14px}
141
172
  .dsa-approval-title{font-size:14px;line-height:22px;font-weight:500;color:var(--dsw-alias-label-primary,#f9fafb)}
142
173
  .dsa-approval-body{font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary,rgb(207,211,214));overflow-wrap:anywhere}
143
- .dsa-approval-actions{display:flex;gap:8px;justify-content:flex-end}
174
+ .dsa-approval-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end}
144
175
  .dsa-rail{display:flex;flex:none;flex-direction:column;width:260px;min-width:0;box-sizing:border-box;padding:6px 8px;border-left:.5px solid var(--dsw-alias-border-l3,rgba(255,255,255,.12))}
145
176
  .dsa-rail-head{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:6px 8px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
146
177
  .dsa-rail-list{display:flex;flex-direction:column;gap:2px;min-height:0;overflow-y:auto;margin-bottom:8px}
@@ -153,7 +184,7 @@ window.__ModuleLoader__.load({
153
184
  .dsa-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;height:100%;padding:24px;text-align:center}
154
185
  .dsa-note{font-size:13px;line-height:1.6;color:var(--dsw-alias-label-secondary,rgb(207,211,214))}
155
186
  .dsa-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-caption,rgb(129,133,140))}
156
- .dsa-toast{display:flex;align-items:center;gap:8px;margin:8px auto 0;width:min(100%,clamp(680px,64%,920px));padding:6px 10px;border-radius:var(--dsw-radius-md,12px);background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08));color:var(--dsw-alias-label-secondary,rgb(207,211,214));font-size:12px;line-height:18px}
187
+ .dsa-toast{display:flex;align-items:center;gap:8px;margin:8px auto 0;width:min(calc(100% - 64px),var(--dsa-col));padding:6px 10px;border-radius:var(--dsw-radius-md,12px);background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08));color:var(--dsw-alias-label-secondary,rgb(207,211,214));font-size:12px;line-height:18px}
157
188
  .dsa-toast[data-kind=err]{color:var(--dsw-alias-state-error-primary,#f25a5a)}
158
189
  `
159
190
 
@@ -174,95 +205,6 @@ window.__ModuleLoader__.load({
174
205
  return h(component, { size: props.size ?? 16, className: props.className })
175
206
  }
176
207
 
177
- /** Escape one text run before it becomes HTML. */
178
- function escapeHtml(value) {
179
- return String(value)
180
- .replace(/&/g, '&amp;')
181
- .replace(/</g, '&lt;')
182
- .replace(/>/g, '&gt;')
183
- .replace(/"/g, '&quot;')
184
- }
185
-
186
- /** Inline markdown: code spans, bold, links. Everything else is escaped. */
187
- function inlineHtml(text) {
188
- let out = escapeHtml(text)
189
- out = out.replace(/`([^`]+)`/g, (_, code) => `<code>${code}</code>`)
190
- out = out.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
191
- out = out.replace(/\[([^\]]+)\]\((https?:[^)\s]+)\)/g, (_, label, href) => {
192
- const safe = href.replace(/"/g, '&quot;')
193
- return `<a href="${safe}" target="_blank" rel="noreferrer noopener">${label}</a>`
194
- })
195
- return out
196
- }
197
-
198
- /**
199
- * A small markdown subset: fenced code, headings, lists, paragraphs. The
200
- * panel shows the same prose the console page shows; raw HTML is never
201
- * passed through.
202
- */
203
- function markdownHtml(text) {
204
- const source = String(text ?? '')
205
- const blocks = []
206
- const fence = /```([a-zA-Z0-9-]*)\n([\s\S]*?)```/g
207
- let rest = source.replace(fence, (_, language, body) => {
208
- blocks.push(`<pre><code>${escapeHtml(body.replace(/\n$/, ''))}</code></pre>`)
209
- return `\u0000${blocks.length - 1}\u0000`
210
- })
211
- const lines = rest.split('\n')
212
- const html = []
213
- let paragraph = []
214
- let list = null
215
- const flushParagraph = () => {
216
- if (paragraph.length === 0) return
217
- html.push(`<p>${inlineHtml(paragraph.join(' '))}</p>`)
218
- paragraph = []
219
- }
220
- const flushList = () => {
221
- if (!list) return
222
- html.push(`<${list.tag}>${list.items.map(item => `<li>${inlineHtml(item)}</li>`).join('')}</${list.tag}>`)
223
- list = null
224
- }
225
- for (const line of lines) {
226
- const placeholder = line.match(/^\u0000(\d+)\u0000$/)
227
- if (placeholder) {
228
- flushParagraph()
229
- flushList()
230
- html.push(blocks[Number(placeholder[1])] ?? '')
231
- continue
232
- }
233
- if (!line.trim()) {
234
- flushParagraph()
235
- flushList()
236
- continue
237
- }
238
- const heading = line.match(/^(#{1,3})\s+(.*)$/)
239
- if (heading) {
240
- flushParagraph()
241
- flushList()
242
- const level = Math.min(3, heading[1].length)
243
- html.push(`<h${level}>${inlineHtml(heading[2])}</h${level}>`)
244
- continue
245
- }
246
- const bullet = line.match(/^\s*[-*]\s+(.*)$/)
247
- const ordered = line.match(/^\s*\d+[.)]\s+(.*)$/)
248
- if (bullet || ordered) {
249
- flushParagraph()
250
- const tag = bullet ? 'ul' : 'ol'
251
- if (!list || list.tag !== tag) {
252
- flushList()
253
- list = { tag, items: [] }
254
- }
255
- list.items.push((bullet ?? ordered)[1])
256
- continue
257
- }
258
- flushList()
259
- paragraph.push(line.trim())
260
- }
261
- flushParagraph()
262
- flushList()
263
- return html.join('')
264
- }
265
-
266
208
  /** Local echo while a sent message waits for the host to accept it. */
267
209
  let localSeq = 0
268
210
 
@@ -341,6 +283,8 @@ window.__ModuleLoader__.load({
341
283
  conn: 'connecting',
342
284
  mode: 'queue',
343
285
  toast: null,
286
+ canceling: false,
287
+ approvalBusy: {},
344
288
  typing: false,
345
289
  sending: false,
346
290
  currentId: null,
@@ -353,6 +297,13 @@ window.__ModuleLoader__.load({
353
297
  return messages.map(message => (message.id === id ? { ...message, ...patch } : message))
354
298
  }
355
299
 
300
+ /** Drop one key from a busy-map without touching the rest. */
301
+ function omitKey(map, key) {
302
+ const next = { ...(map ?? {}) }
303
+ delete next[key]
304
+ return next
305
+ }
306
+
356
307
  /** Add or update a tool chip on the streaming assistant message. */
357
308
  function upsertTool(messages, id, tool) {
358
309
  return messages.map(message => {
@@ -388,7 +339,7 @@ window.__ModuleLoader__.load({
388
339
  case 'step/start':
389
340
  return { ...model, typing: true }
390
341
  case 'turn/end': {
391
- let next = { ...model, typing: false }
342
+ let next = { ...model, typing: false, canceling: false }
392
343
  if (next.currentId) {
393
344
  next = { ...next, messages: patchMessage(next.messages, next.currentId, { streaming: false }), currentId: null }
394
345
  }
@@ -502,7 +453,7 @@ window.__ModuleLoader__.load({
502
453
  return { ...model, sessionId: frame.sessionId ?? model.sessionId, capabilities: frame.capabilities ?? model.capabilities, conn: 'live' }
503
454
  case 'session':
504
455
  if (!frame.sessionId || frame.sessionId === model.sessionId) return model
505
- return { ...model, sessionId: frame.sessionId, messages: [], approvals: [], currentId: null, typing: false }
456
+ return { ...model, sessionId: frame.sessionId, messages: [], approvals: [], approvalBusy: {}, currentId: null, typing: false, canceling: false }
506
457
  case 'stream.snapshot': {
507
458
  let next = { ...model, messages: [], currentId: null }
508
459
  if (frame.header?.id) next.sessionId = frame.header.id
@@ -534,7 +485,7 @@ window.__ModuleLoader__.load({
534
485
  case 'runs':
535
486
  return { ...model, runs: Array.isArray(frame.runs) ? frame.runs : [] }
536
487
  case 'canceling':
537
- return model
488
+ return { ...model, canceling: true }
538
489
  case 'error':
539
490
  return { ...model, conn: frame.code === 'follow-failed' || frame.code === 'state-failed' ? 'warn' : model.conn }
540
491
  case 'closed':
@@ -555,18 +506,18 @@ window.__ModuleLoader__.load({
555
506
  h('span', { className: 'dsa-status' },
556
507
  h('span', { className: 'dsa-dot', 'data-state': model.conn }),
557
508
  model.conn === 'live' ? '已连接' : model.conn === 'warn' ? '流中断' : '连接中'),
558
- h('button', { type: 'button', className: 'dsa-iconbtn', title: '刷新', onClick: onRefresh },
559
- h(Icon, { of: 'refresh' })),
560
- h('button', { type: 'button', className: 'dsa-iconbtn', title: '新建会话', onClick: onNew },
561
- h(Icon, { of: 'newChat' }))))
509
+ tipped('刷新', h('button', { type: 'button', className: 'dsa-iconbtn', onClick: onRefresh },
510
+ h(Icon, { of: 'refresh' }))),
511
+ tipped('新建会话', h('button', { type: 'button', className: 'dsa-iconbtn', onClick: onNew },
512
+ h(Icon, { of: 'newChat' })))))
562
513
  }
563
514
 
564
515
  function UserMessage(props) {
565
- return h('div', { className: 'dsa-user' },
566
- h('div', {
567
- className: 'dsa-bubble',
568
- 'data-pending': props.message.pending === true ? 'true' : 'false',
569
- }, props.message.text))
516
+ const pending = props.message.pending === true
517
+ return h('div', { className: 'dsa-user', style: pending ? { opacity: 0.6 } : undefined },
518
+ UserMessageBubble
519
+ ? h(UserMessageBubble, { className: pending ? 'dsa-bubble-pending' : undefined }, props.message.text)
520
+ : h('div', { className: 'dsa-bubble', 'data-pending': pending ? 'true' : 'false' }, props.message.text))
570
521
  }
571
522
 
572
523
  function AssistantMessage(props) {
@@ -577,20 +528,28 @@ window.__ModuleLoader__.load({
577
528
  children.push(h('div', { key: 'reasoning', className: 'dsa-reasoning' }, message.reasoning))
578
529
  }
579
530
  if (tools.length > 0) {
580
- children.push(h('div', { key: 'tools', className: 'dsa-tools-row' }, tools.map(tool => h('span', {
581
- key: tool.callId ?? tool.name,
582
- className: 'dsa-tool',
583
- 'data-status': tool.status,
584
- title: typeof tool.arguments === 'string' ? tool.arguments : undefined,
585
- }, tool.name))))
531
+ children.push(h('div', { key: 'tools', className: 'dsa-tools-row' }, tools.map(tool => {
532
+ const chip = h('span', {
533
+ key: tool.callId ?? tool.name,
534
+ className: 'dsa-tool',
535
+ 'data-status': tool.status,
536
+ }, tool.name)
537
+ return typeof tool.arguments === 'string' && tool.arguments
538
+ ? (Tooltip
539
+ ? h(Tooltip, { key: tool.callId ?? tool.name, label: tool.arguments, side: 'top', maxWidth: 420 }, chip)
540
+ : react.cloneElement(chip, { title: tool.arguments }))
541
+ : chip
542
+ })))
586
543
  }
587
544
  if (message.text) {
588
- children.push(h('div', {
589
- key: 'text',
590
- className: 'dsa-md',
591
- // The renderer escapes every text run before it becomes markup.
592
- dangerouslySetInnerHTML: { __html: markdownHtml(message.text) },
593
- }))
545
+ children.push(MarkdownText
546
+ ? h(MarkdownText, {
547
+ key: 'text',
548
+ text: message.text,
549
+ streaming: message.streaming === true,
550
+ labels: MARKDOWN_LABELS,
551
+ })
552
+ : h('div', { key: 'text', className: 'dsa-md-plain' }, message.text))
594
553
  }
595
554
  return h('div', { className: 'dsa-assistant' }, children)
596
555
  }
@@ -614,37 +573,88 @@ window.__ModuleLoader__.load({
614
573
 
615
574
  function Approvals(props) {
616
575
  if (!props.approvals.length) return null
617
- return h('div', { className: 'dsa-approvals' }, props.approvals.map(entry => h('div', {
618
- key: entry.id,
619
- className: 'dsa-approval',
620
- },
621
- h('div', { className: 'dsa-approval-title' }, `等你决定:${entry.toolName ?? '工具调用'}`),
622
- entry.callArguments || entry.reason
623
- ? h('div', { className: 'dsa-approval-body' }, entry.callArguments ?? entry.reason)
624
- : null,
625
- h('div', { className: 'dsa-approval-actions' },
626
- h(Button ?? 'button', {
627
- variant: Button ? 'outline' : undefined,
628
- className: Button ? undefined : 'dsa-add',
629
- type: Button ? undefined : 'button',
630
- onClick: () => props.onDecide(entry.id, 'reject'),
631
- }, '拒绝'),
632
- h(Button ?? 'button', {
633
- variant: Button ? 'outline' : undefined,
634
- type: Button ? undefined : 'button',
635
- onClick: () => props.onDecide(entry.id, 'allow-tool'),
636
- }, '本会话都放行'),
637
- h(Button ?? 'button', {
638
- variant: Button ? 'primary' : undefined,
639
- type: Button ? undefined : 'button',
640
- onClick: () => props.onDecide(entry.id, 'allow'),
641
- }, '允许一次')))))
576
+ return h('div', { className: 'dsa-approvals' }, props.approvals.map(entry => {
577
+ const busy = props.busy?.[entry.id] === true
578
+ return h('div', {
579
+ key: entry.id,
580
+ className: 'dsa-approval',
581
+ 'aria-busy': busy ? 'true' : undefined,
582
+ },
583
+ h('div', { className: 'dsa-approval-bar' },
584
+ StateDot ? h(StateDot, { state: 'warning', size: 10 }) : null,
585
+ h('span', null, '等待你的批准')),
586
+ h('div', { className: 'dsa-approval-main' },
587
+ h('div', { className: 'dsa-approval-title' }, entry.toolName ?? '工具调用'),
588
+ entry.callArguments || entry.reason
589
+ ? h('div', { className: 'dsa-approval-body' }, entry.callArguments ?? entry.reason)
590
+ : null,
591
+ h('div', { className: 'dsa-approval-actions' },
592
+ h(Button ?? 'button', {
593
+ variant: Button ? 'outline' : undefined,
594
+ className: Button ? undefined : 'dsa-add',
595
+ type: Button ? undefined : 'button',
596
+ disabled: busy,
597
+ onClick: () => props.onDecide(entry.id, 'reject'),
598
+ }, '拒绝'),
599
+ h(Button ?? 'button', {
600
+ variant: Button ? 'primary' : undefined,
601
+ type: Button ? undefined : 'button',
602
+ disabled: busy,
603
+ onClick: () => props.onDecide(entry.id, 'allow'),
604
+ }, '允许一次'),
605
+ h(Button ?? 'button', {
606
+ variant: Button ? 'outline' : undefined,
607
+ type: Button ? undefined : 'button',
608
+ disabled: busy,
609
+ onClick: () => props.onDecide(entry.id, 'allow-tool'),
610
+ }, '本会话都放行'))))
611
+ }))
612
+ }
613
+
614
+ /**
615
+ * Delivery-mode picker. The host Menu carries the theme, radius, row height,
616
+ * hover fill, check mark, shadow, keyboard handling, outside dismiss and
617
+ * focus return; without it the chip still never falls back to a native
618
+ * `<select>` (it just cycles on click).
619
+ */
620
+ function Chooser(props) {
621
+ const label = MODES.find(entry => entry.id === props.mode)?.label ?? '排队'
622
+ if (!Menu) {
623
+ return h('button', {
624
+ type: 'button',
625
+ className: 'dsa-chip',
626
+ 'aria-label': `发送方式:${label},点击切换`,
627
+ onClick: () => props.onMode(props.mode === 'queue' ? 'steer' : 'queue'),
628
+ }, h('span', null, label), h(Icon, { of: 'chevron', size: 12 }))
629
+ }
630
+ return h(Menu, {
631
+ open: props.open,
632
+ anchor: h('button', {
633
+ type: 'button',
634
+ className: 'dsa-chip',
635
+ 'aria-haspopup': 'menu',
636
+ 'aria-expanded': props.open ? 'true' : 'false',
637
+ 'aria-label': `发送方式:${label}`,
638
+ onClick: () => props.onOpenChange(!props.open),
639
+ }, h('span', null, label), h(Icon, { of: 'chevron', size: 12 })),
640
+ items: MODES,
641
+ selectedId: props.mode,
642
+ side: 'top',
643
+ align: 'start',
644
+ portal: true,
645
+ onClose: () => props.onOpenChange(false),
646
+ onSelect: id => {
647
+ props.onOpenChange(false)
648
+ if (id !== props.mode) props.onMode(id)
649
+ },
650
+ })
642
651
  }
643
652
 
644
653
  function Composer(props) {
645
654
  const { hero, disabled, onSend } = props
646
655
  const [text, setText] = react.useState('')
647
656
  const [busy, setBusy] = react.useState(false)
657
+ const [chooser, setChooser] = react.useState(false)
648
658
  const areaRef = react.useRef(null)
649
659
  const fileRef = react.useRef(null)
650
660
 
@@ -720,29 +730,36 @@ window.__ModuleLoader__.load({
720
730
  event.target.value = ''
721
731
  },
722
732
  }),
723
- h('button', {
733
+ tipped('放进工作区', h('button', {
724
734
  type: 'button',
725
735
  className: 'dsa-add',
726
- title: '放进工作区',
727
736
  disabled: busy,
737
+ 'aria-label': '放进工作区',
728
738
  onClick: () => fileRef.current?.click(),
729
- }, h(Icon, { of: 'plus', size: 16 })),
730
- h('select', {
731
- className: 'dsa-chip',
732
- value: props.mode ?? 'queue',
733
- onChange: event => props.onMode(event.target.value),
734
- title: '发送方式',
735
- },
736
- h('option', { value: 'queue' }, '排队'),
737
- h('option', { value: 'steer' }, '插话'))),
739
+ }, h(Icon, { of: 'plus', size: 16 })), 'top'),
740
+ h(Chooser, {
741
+ mode: props.mode ?? 'queue',
742
+ open: chooser,
743
+ onOpenChange: setChooser,
744
+ onMode: props.onMode,
745
+ })),
738
746
  h('div', { className: 'dsa-trailing' },
739
- h('button', {
740
- type: 'button',
741
- className: 'dsa-send',
742
- disabled: disabled || !text.trim(),
743
- title: '发送',
744
- onClick: submit,
745
- }, h(Icon, { of: 'send', size: 15 }))))),
747
+ props.running
748
+ ? tipped('停止本轮', h('button', {
749
+ type: 'button',
750
+ className: 'dsa-send',
751
+ 'data-mode': 'stop',
752
+ 'aria-label': '停止本轮',
753
+ disabled: props.canceling === true,
754
+ onClick: () => props.onStop?.(),
755
+ }, props.canceling ? h('span', { className: 'dsa-spin' }) : h(Icon, { of: 'stop', size: 10 })), 'top')
756
+ : tipped('发送', h('button', {
757
+ type: 'button',
758
+ className: 'dsa-send',
759
+ 'aria-label': '发送',
760
+ disabled: disabled || !text.trim(),
761
+ onClick: submit,
762
+ }, h(Icon, { of: 'send', size: 15 })), 'top')))),
746
763
  h('div', { className: 'dsa-stats' },
747
764
  h('span', null, props.model.sessionId ? `会话 ${shortId(props.model.sessionId)}` : '还没有会话'),
748
765
  h('span', null, `${props.model.runs.length} 条任务线`)))
@@ -757,29 +774,27 @@ window.__ModuleLoader__.load({
757
774
  h('div', { className: 'dsa-rail-list' },
758
775
  model.sessions.length === 0
759
776
  ? h('div', { className: 'dsa-hint', style: { padding: '8px' } }, model.sessionsReason || '还没有历史会话')
760
- : model.sessions.map(session => h('button', {
777
+ : model.sessions.map(session => tipped(sessionTitle(session), h('button', {
761
778
  key: session.sessionId,
762
779
  type: 'button',
763
780
  className: 'dsa-rowitem',
764
781
  'data-selected': session.sessionId === model.sessionId ? 'true' : 'false',
765
- title: sessionTitle(session),
766
782
  onClick: () => onSwitch(session.sessionId),
767
783
  },
768
784
  h('span', { className: 'dsa-rowtitle' }, sessionTitle(session)),
769
- h('span', { className: 'dsa-rowtime' }, clockOf(session.updatedAt))))),
785
+ h('span', { className: 'dsa-rowtime' }, clockOf(session.updatedAt))), 'left', session.sessionId))),
770
786
  h('div', { className: 'dsa-rail-head' },
771
787
  h('span', null, '任务线'),
772
788
  h('span', null, `${model.runs.length}`)),
773
789
  h('div', { className: 'dsa-rail-list' },
774
790
  model.runs.length === 0
775
791
  ? h('div', { className: 'dsa-hint', style: { padding: '8px' } }, '这一轮还没有任务线')
776
- : model.runs.map(run => h('div', {
792
+ : model.runs.map(run => tipped(run.goal ?? '', h('div', {
777
793
  key: run.id,
778
794
  className: 'dsa-rowitem',
779
- title: run.goal ?? '',
780
795
  },
781
796
  h('span', { className: 'dsa-rowtitle' }, run.goal ?? '任务线'),
782
- h('span', { className: 'dsa-rowtime' }, run.status === 'running' ? '运行中' : run.status === 'completed' ? '完成' : '已停')))))
797
+ h('span', { className: 'dsa-rowtime' }, run.status === 'running' ? '运行中' : run.status === 'completed' ? '完成' : '已停')), 'left', run.id))))
783
798
  }
784
799
 
785
800
  function Hero(props) {
@@ -834,6 +849,9 @@ window.__ModuleLoader__.load({
834
849
  model,
835
850
  mode: model.mode,
836
851
  disabled: model.sending,
852
+ running: model.typing,
853
+ canceling: model.canceling,
854
+ onStop: () => dispatch({ type: 'cancel' }),
837
855
  onSend: text => dispatch({ type: 'send', text }),
838
856
  onMode: mode => dispatch({ type: 'mode', mode }),
839
857
  onError: notify,
@@ -841,12 +859,16 @@ window.__ModuleLoader__.load({
841
859
  : h(Transcript, { model, scrollRef: model.scrollRef }),
842
860
  h(Approvals, {
843
861
  approvals: model.approvals,
862
+ busy: model.approvalBusy,
844
863
  onDecide: (id, decision) => dispatch({ type: 'decide', id, decision }),
845
864
  }),
846
865
  empty ? null : h(Composer, {
847
866
  model,
848
867
  mode: model.mode,
849
868
  disabled: model.sending || model.capabilities?.chat === false,
869
+ running: model.typing,
870
+ canceling: model.canceling,
871
+ onStop: () => dispatch({ type: 'cancel' }),
850
872
  onSend: text => dispatch({ type: 'send', text }),
851
873
  onMode: mode => dispatch({ type: 'mode', mode }),
852
874
  onError: notify,
@@ -982,11 +1004,27 @@ window.__ModuleLoader__.load({
982
1004
  },
983
1005
  decide: async action => {
984
1006
  const { id, decision } = action
1007
+ patch(current => ({ ...current, approvalBusy: { ...current.approvalBusy, [id]: true } }))
985
1008
  try {
986
1009
  await call('/approval', { method: 'POST', body: JSON.stringify({ id, decision }) })
987
- patch(current => ({ ...current, approvals: current.approvals.filter(entry => entry.id !== id) }))
988
- } catch {
989
- // The card stays: the answer was not applied.
1010
+ patch(current => ({
1011
+ ...current,
1012
+ approvals: current.approvals.filter(entry => entry.id !== id),
1013
+ approvalBusy: omitKey(current.approvalBusy, id),
1014
+ }))
1015
+ } catch (error) {
1016
+ // The card stays and the failure surfaces instead of vanishing.
1017
+ patch(current => ({ ...current, approvalBusy: omitKey(current.approvalBusy, id) }))
1018
+ throw error
1019
+ }
1020
+ },
1021
+ cancel: async () => {
1022
+ patch(current => ({ ...current, canceling: true }))
1023
+ try {
1024
+ await call('/cancel', { method: 'POST', body: JSON.stringify({ sessionId: modelRef.current.sessionId }) })
1025
+ } catch (error) {
1026
+ patch(current => ({ ...current, canceling: false }))
1027
+ throw error
990
1028
  }
991
1029
  },
992
1030
  switch: async action => {
package/lib/console.js CHANGED
@@ -1239,6 +1239,31 @@ export function createConsole({
1239
1239
  return
1240
1240
  }
1241
1241
 
1242
+ if (leaf === 'cancel' && parts.length === 3) {
1243
+ if (method !== 'POST') throw new WorkbenchError(405, 'only POST is allowed here', { id: 'method-not-allowed' })
1244
+ const body = await readJson(req)
1245
+ const ensured = await ensureSession()
1246
+ if (typeof body.sessionId === 'string' && body.sessionId && body.sessionId !== ensured.sessionId) {
1247
+ throw new WorkbenchError(409, 'the cancel targets a conversation this console is not showing', {
1248
+ id: 'session-mismatch',
1249
+ hint: 'reload the page; the console keeps one active conversation at a time.',
1250
+ })
1251
+ }
1252
+ if (typeof host.cancelTurn !== 'function') {
1253
+ throw new WorkbenchError(501, 'this host cannot stop a turn', { id: 'cancel-unsupported' })
1254
+ }
1255
+ try {
1256
+ await host.cancelTurn(ensured.sessionId)
1257
+ } catch (error) {
1258
+ throw new WorkbenchError(502, `the host refused to stop the turn: ${messageOf(error)}`, {
1259
+ id: 'cancel-failed',
1260
+ })
1261
+ }
1262
+ broadcast({ type: 'canceling', sessionId: ensured.sessionId })
1263
+ send(res, 200, { ok: true, data: { canceling: true } })
1264
+ return
1265
+ }
1266
+
1242
1267
  if (leaf === 'message' && parts.length === 3) {
1243
1268
  if (method !== 'POST') throw new WorkbenchError(405, 'only POST is allowed here', { id: 'method-not-allowed' })
1244
1269
  const body = await readJson(req)
package/lib/index.js CHANGED
@@ -3807,6 +3807,20 @@ export function apply(ctx, config) {
3807
3807
  return { accepted: true }
3808
3808
  },
3809
3809
 
3810
+ /**
3811
+ * Stop the turn this conversation is currently running. The session
3812
+ * controller owns admission, so an idle conversation simply acknowledges
3813
+ * that there was nothing left to cancel.
3814
+ */
3815
+ async cancelTurn(sessionId) {
3816
+ await ready
3817
+ const session = getSessionController()
3818
+ if (!session) throw new Error('sessionController is not mounted')
3819
+ if (typeof session.cancel !== 'function') throw new Error('this session controller cannot stop a turn')
3820
+ const value = await session.cancel({ sessionId })
3821
+ return { accepted: value?.accepted !== false }
3822
+ },
3823
+
3810
3824
  async listRuns(sessionId) {
3811
3825
  await ready
3812
3826
  if (stateError) throw stateError
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiangyixie/dsh-superagent",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "长周期自主执行插件:一个目标拆成可并行的子任务,交付一份合并报告,重启后仍可继续。",
5
5
  "author": "Admire (LittleChenLiya)",
6
6
  "type": "module",