@xiangyixie/dsh-superagent 0.16.2 → 0.16.4
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 +36 -0
- package/README.en.md +3 -3
- package/README.md +3 -3
- package/README.zh.md +3 -3
- package/lib/client.js +130 -25
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,42 @@ 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.4 — 2026-11-17
|
|
12
|
+
|
|
13
|
+
### 变化
|
|
14
|
+
|
|
15
|
+
- **默认布局回到单列。** 打开时只有正文,没有常驻右栏;会话/任务线列表默认
|
|
16
|
+
收起,和普通会话一致。
|
|
17
|
+
- **右栏改成可展开的抽屉。** 头栏放宿主 `IconPanelLeft` 图标按钮展开/收起,
|
|
18
|
+
快捷键 `Ctrl/Cmd+Shift+B`,`Esc` 关闭;状态存 `localStorage`
|
|
19
|
+
(`dsh-superagent.rail-open`),下次打开保持上次选择。
|
|
20
|
+
- **展开不挤压正文。** 抽屉用绝对定位浮在正文右侧(`z-index` 30、
|
|
21
|
+
`shadow lv2`、最大宽度 `min(84vw, 320px)`),正文列宽仍按宿主
|
|
22
|
+
`--dsh-chat-user-width` 公式计算,窄窗口下也是浮层而不是横向挤压。
|
|
23
|
+
- **收起时保留最小信息。** 按钮上显示运行中任务线的数字徽标(超过 9 显示
|
|
24
|
+
`9+`),不再为了状态保留一整列。
|
|
25
|
+
- **头栏标题固定为「超级智能体」。** 去掉自动生成的会话名和面包屑分隔斜杠;
|
|
26
|
+
会话名仍保留在数据层与抽屉列表里,不再当页面标题展示。
|
|
27
|
+
|
|
28
|
+
## 0.16.3 — 2026-11-17
|
|
29
|
+
|
|
30
|
+
### 修复
|
|
31
|
+
|
|
32
|
+
- **assistant 正文恢复了 Markdown 渲染。** 根因不是渲染分支,而是组件探测:
|
|
33
|
+
`MarkdownText` 是 `React.memo` 包装的对象,`Button` 是 `React.forwardRef`
|
|
34
|
+
对象,0.16.1 起用 `typeof x === 'function'` 判断,两者都被误判为「宿主没导出」,
|
|
35
|
+
于是正文一直走 `.dsa-md-plain` 纯文本兜底(表格、加粗、行内代码原样露出)。
|
|
36
|
+
现在同时接受 function、`react.memo` 和 `react.forward_ref`,流式与完成态的
|
|
37
|
+
正文都走宿主 `MarkdownText`。
|
|
38
|
+
- **降级不再静默。** 缺少宿主组件时在控制台打印一次缺失清单;单条消息降级为
|
|
39
|
+
纯文本时打印带消息 id 的 `console.error`;`MarkdownText` 运行期抛错由错误
|
|
40
|
+
边界接住并记录,正文继续以纯文本显示。
|
|
41
|
+
|
|
42
|
+
### 已知待办(本轮未改)
|
|
43
|
+
|
|
44
|
+
- 委派提示词里把 Run ID、token 统计、并行上限这类内部信息写进了面向用户的
|
|
45
|
+
输出,措辞需要单独调整。
|
|
46
|
+
|
|
11
47
|
## 0.16.2 — 2026-11-17
|
|
12
48
|
|
|
13
49
|
### 变化
|
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.
|
|
39
|
+
Desktop: **Plugins** → **Add plugin** → enter `@xiangyixie/dsh-superagent@0.16.4` → install.
|
|
40
40
|
|
|
41
41
|
CLI:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.
|
|
44
|
+
dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.4
|
|
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.
|
|
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.4` 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.
|
|
39
|
+
桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.16.4` → 安装。
|
|
40
40
|
|
|
41
41
|
命令行:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.
|
|
44
|
+
dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.4
|
|
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.
|
|
1093
|
+
| `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.4` 重装,并在宿主日志里找 `[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.
|
|
39
|
+
桌面端:侧边栏 **插件** → **Add plugin** → 输入 `@xiangyixie/dsh-superagent@0.16.4` → 安装。
|
|
40
40
|
|
|
41
41
|
命令行:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.
|
|
44
|
+
dsh plugin --profile web add @xiangyixie/dsh-superagent@0.16.4
|
|
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.
|
|
1093
|
+
| `superagent_*` 工具不存在 | bundle 行没挂上,或者宿主拒绝加载插件。 | 跑 `--dump-config` 查 `@xiangyixie/dsh-superagent` 块;用 `dsh plugin --profile <p> add @xiangyixie/dsh-superagent@0.16.4` 重装,并在宿主日志里找 `[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
|
@@ -52,13 +52,27 @@ window.__ModuleLoader__.load({
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const h = react ? react.createElement : null
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
55
|
+
// React.memo / React.forwardRef components are objects, not functions.
|
|
56
|
+
// Checking typeof alone silently rejected MarkdownText and Button and made
|
|
57
|
+
// assistant prose fall back to raw text.
|
|
58
|
+
const isComponent = value => typeof value === 'function'
|
|
59
|
+
|| (value !== null && typeof value === 'object'
|
|
60
|
+
&& (value.$$typeof === Symbol.for('react.memo') || value.$$typeof === Symbol.for('react.forward_ref')))
|
|
61
|
+
const pick = name => (isComponent(ui?.[name]) ? ui[name] : null)
|
|
62
|
+
const Button = pick('Button')
|
|
63
|
+
const FishLogo = pick('FishLogo')
|
|
64
|
+
const MarkdownText = pick('MarkdownText')
|
|
65
|
+
const UserMessageBubble = pick('UserMessageBubble')
|
|
66
|
+
const StateDot = pick('StateDot')
|
|
67
|
+
const Menu = pick('Menu')
|
|
68
|
+
const Tooltip = pick('Tooltip')
|
|
69
|
+
const MISSING_PRIMITIVES = ['Button', 'FishLogo', 'MarkdownText', 'UserMessageBubble', 'StateDot', 'Menu', 'Tooltip']
|
|
70
|
+
.filter(name => !pick(name))
|
|
71
|
+
if (!ui) {
|
|
72
|
+
console.warn('[dsh-superagent] host primitives module is absent; assistant text renders as plain text')
|
|
73
|
+
} else if (MISSING_PRIMITIVES.length > 0) {
|
|
74
|
+
console.warn(`[dsh-superagent] host primitives unavailable: ${MISSING_PRIMITIVES.join(', ')}; those spots fall back to plain rendering`)
|
|
75
|
+
}
|
|
62
76
|
const ICONS = {
|
|
63
77
|
spark: ui?.IconSparkleRegular ?? ui?.IconSparkleMedium,
|
|
64
78
|
send: ui?.IconSendOutlineRegular ?? ui?.IconSendOutlineMedium,
|
|
@@ -71,6 +85,7 @@ window.__ModuleLoader__.load({
|
|
|
71
85
|
close: ui?.IconCloseOutlineRegular ?? ui?.IconCloseOutlineMedium,
|
|
72
86
|
folder: ui?.IconFolderCloseRegular ?? ui?.IconFolderCloseMedium,
|
|
73
87
|
chevron: ui?.IconChevronDownOutlineRegular ?? ui?.IconChevronDownOutlineMedium,
|
|
88
|
+
panel: ui?.IconPanelLeftOutlineRegular ?? ui?.IconPanelLeftOutlineMedium,
|
|
74
89
|
}
|
|
75
90
|
// MarkdownText reads `labels.code` on every fenced block, so the host
|
|
76
91
|
// component is only safe with this shape filled in.
|
|
@@ -91,6 +106,22 @@ window.__ModuleLoader__.load({
|
|
|
91
106
|
{ id: 'queue', label: '排队' },
|
|
92
107
|
{ id: 'steer', label: '插话' },
|
|
93
108
|
]
|
|
109
|
+
const RAIL_KEY = 'dsh-superagent.rail-open'
|
|
110
|
+
function readRailOpen() {
|
|
111
|
+
try {
|
|
112
|
+
return window.localStorage.getItem(RAIL_KEY) === '1'
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return false
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function saveRailOpen(open) {
|
|
118
|
+
try {
|
|
119
|
+
window.localStorage.setItem(RAIL_KEY, open ? '1' : '0')
|
|
120
|
+
} catch (error) {
|
|
121
|
+
// Private mode or a sandboxed webview: the layout still works, it just
|
|
122
|
+
// does not remember the choice.
|
|
123
|
+
}
|
|
124
|
+
}
|
|
94
125
|
|
|
95
126
|
/**
|
|
96
127
|
* Host tooltip when it exists; the native `title` only survives as the
|
|
@@ -101,6 +132,35 @@ window.__ModuleLoader__.load({
|
|
|
101
132
|
return react.cloneElement(node, { key, title: label })
|
|
102
133
|
}
|
|
103
134
|
|
|
135
|
+
const MARKDOWN_FALLBACKS = new Set()
|
|
136
|
+
function noteMarkdownFallback(id, reason) {
|
|
137
|
+
if (MARKDOWN_FALLBACKS.has(id)) return
|
|
138
|
+
MARKDOWN_FALLBACKS.add(id)
|
|
139
|
+
console.error(`[dsh-superagent] assistant message ${id} fell back to plain text: ${reason}`)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// A throw inside MarkdownText must be visible, not silently swallowed by
|
|
143
|
+
// React. This logs once and keeps the prose on screen as plain text.
|
|
144
|
+
const MarkdownBoundary = react && typeof react.Component === 'function'
|
|
145
|
+
? class MarkdownBoundary extends react.Component {
|
|
146
|
+
constructor(props) {
|
|
147
|
+
super(props)
|
|
148
|
+
this.state = { failed: false }
|
|
149
|
+
}
|
|
150
|
+
static getDerivedStateFromError() {
|
|
151
|
+
return { failed: true }
|
|
152
|
+
}
|
|
153
|
+
componentDidCatch(error) {
|
|
154
|
+
noteMarkdownFallback(this.props.messageId, error?.message ?? String(error))
|
|
155
|
+
}
|
|
156
|
+
render() {
|
|
157
|
+
return this.state.failed
|
|
158
|
+
? h('div', { className: 'dsa-md-plain' }, this.props.text)
|
|
159
|
+
: this.props.children
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
: null
|
|
163
|
+
|
|
104
164
|
/**
|
|
105
165
|
* One class sheet for the panel. Every value is copied from the host's own
|
|
106
166
|
* modules: header 76px / 10-28-0-20, sidebar rows 32px / radius 12 / 5px 9px,
|
|
@@ -120,11 +180,13 @@ window.__ModuleLoader__.load({
|
|
|
120
180
|
.dsa-iconbtn svg{width:15px;height:15px}
|
|
121
181
|
.dsa-iconbtn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
|
|
122
182
|
.dsa-iconbtn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-alias-state-business-primary,#7aaaff);outline-offset:-2px}
|
|
183
|
+
.dsa-railtoggle{position:relative}
|
|
184
|
+
.dsa-badge{position:absolute;top:-2px;right:-2px;min-width:14px;height:14px;padding:0 3px;border-radius:7px;background:var(--dsw-alias-state-business-primary,#4d6bfe);color:#fff;font-size:9px;line-height:14px;font-weight:600;text-align:center;box-sizing:border-box}
|
|
123
185
|
.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))}
|
|
124
186
|
.dsa-dot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-caption,rgb(129,133,140))}
|
|
125
187
|
.dsa-dot[data-state=live]{background:var(--dsw-alias-state-success-primary,#22c55e)}
|
|
126
188
|
.dsa-dot[data-state=warn]{background:var(--dsw-alias-state-warn-primary,#f59e0b)}
|
|
127
|
-
.dsa-body{display:flex;flex:1;min-height:0}
|
|
189
|
+
.dsa-body{position:relative;display:flex;flex:1;min-height:0}
|
|
128
190
|
.dsa-main{position:relative;display:flex;flex-direction:column;flex:1;min-width:0}
|
|
129
191
|
.dsa-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;margin-right:2px;padding:0 32px;scrollbar-gutter:stable}
|
|
130
192
|
.dsa-scroll::-webkit-scrollbar{width:10px}
|
|
@@ -172,7 +234,7 @@ window.__ModuleLoader__.load({
|
|
|
172
234
|
.dsa-approval-title{font-size:14px;line-height:22px;font-weight:500;color:var(--dsw-alias-label-primary,#f9fafb)}
|
|
173
235
|
.dsa-approval-body{font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary,rgb(207,211,214));overflow-wrap:anywhere}
|
|
174
236
|
.dsa-approval-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end}
|
|
175
|
-
.dsa-rail{display:flex;flex
|
|
237
|
+
.dsa-rail{position:absolute;top:0;right:0;bottom:0;z-index:30;display:flex;flex-direction:column;width:280px;max-width:min(84vw,320px);min-width:0;box-sizing:border-box;padding:8px;border-left:.5px solid var(--dsw-alias-border-l3,rgba(255,255,255,.12));background:var(--dsw-alias-bg-base,rgb(21,21,23));box-shadow:var(--dsw-shadow-lv2,0 8px 28px rgba(0,0,0,.32));overflow:hidden}
|
|
176
238
|
.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))}
|
|
177
239
|
.dsa-rail-list{display:flex;flex-direction:column;gap:2px;min-height:0;overflow-y:auto;margin-bottom:8px}
|
|
178
240
|
.dsa-rowitem{display:flex;align-items:center;gap:6px;box-sizing:border-box;width:100%;height:32px;padding:0 8px 0 9px;border:0;border-radius:var(--dsw-radius-md,12px);background:transparent;color:var(--dsw-alias-label-primary,#f9fafb);font:inherit;font-size:14px;line-height:20px;text-align:left;cursor:pointer}
|
|
@@ -496,16 +558,24 @@ window.__ModuleLoader__.load({
|
|
|
496
558
|
}
|
|
497
559
|
|
|
498
560
|
function Header(props) {
|
|
499
|
-
const { model,
|
|
561
|
+
const { model, railOpen, runningCount, onToggleRail, onNew, onRefresh } = props
|
|
562
|
+
const toggleLabel = railOpen ? '收起任务栏(Ctrl+Shift+B)' : '展开任务栏(Ctrl+Shift+B)'
|
|
500
563
|
return h('header', { className: 'dsa-header' },
|
|
501
564
|
h('div', { className: 'dsa-crumbs' },
|
|
502
|
-
h('span', { className: 'dsa-crumb' }, PANEL_LABEL),
|
|
503
|
-
h('span', { className: 'dsa-sep' }, '/'),
|
|
504
|
-
h('span', { className: 'dsa-crumb dsa-crumb-current' }, title)),
|
|
565
|
+
h('span', { className: 'dsa-crumb dsa-crumb-current' }, PANEL_LABEL)),
|
|
505
566
|
h('div', { className: 'dsa-head-actions' },
|
|
506
567
|
h('span', { className: 'dsa-status' },
|
|
507
568
|
h('span', { className: 'dsa-dot', 'data-state': model.conn }),
|
|
508
569
|
model.conn === 'live' ? '已连接' : model.conn === 'warn' ? '流中断' : '连接中'),
|
|
570
|
+
tipped(toggleLabel, h('button', {
|
|
571
|
+
type: 'button',
|
|
572
|
+
className: 'dsa-iconbtn dsa-railtoggle',
|
|
573
|
+
'aria-label': runningCount > 0 ? `${toggleLabel},${runningCount} 条任务线运行中` : toggleLabel,
|
|
574
|
+
'aria-expanded': railOpen ? 'true' : 'false',
|
|
575
|
+
onClick: onToggleRail,
|
|
576
|
+
},
|
|
577
|
+
h(Icon, { of: 'panel' }),
|
|
578
|
+
runningCount > 0 ? h('span', { className: 'dsa-badge' }, runningCount > 9 ? '9+' : String(runningCount)) : null)),
|
|
509
579
|
tipped('刷新', h('button', { type: 'button', className: 'dsa-iconbtn', onClick: onRefresh },
|
|
510
580
|
h(Icon, { of: 'refresh' }))),
|
|
511
581
|
tipped('新建会话', h('button', { type: 'button', className: 'dsa-iconbtn', onClick: onNew },
|
|
@@ -542,14 +612,19 @@ window.__ModuleLoader__.load({
|
|
|
542
612
|
})))
|
|
543
613
|
}
|
|
544
614
|
if (message.text) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
key: 'text',
|
|
615
|
+
if (MarkdownText) {
|
|
616
|
+
const node = h(MarkdownText, {
|
|
548
617
|
text: message.text,
|
|
549
618
|
streaming: message.streaming === true,
|
|
550
619
|
labels: MARKDOWN_LABELS,
|
|
551
620
|
})
|
|
552
|
-
|
|
621
|
+
children.push(MarkdownBoundary
|
|
622
|
+
? h(MarkdownBoundary, { key: 'text', messageId: message.id, text: message.text }, node)
|
|
623
|
+
: react.cloneElement(node, { key: 'text' }))
|
|
624
|
+
} else {
|
|
625
|
+
noteMarkdownFallback(message.id, 'host MarkdownText export is unavailable')
|
|
626
|
+
children.push(h('div', { key: 'text', className: 'dsa-md-plain' }, message.text))
|
|
627
|
+
}
|
|
553
628
|
}
|
|
554
629
|
return h('div', { className: 'dsa-assistant' }, children)
|
|
555
630
|
}
|
|
@@ -812,6 +887,35 @@ window.__ModuleLoader__.load({
|
|
|
812
887
|
|
|
813
888
|
function Seat(props) {
|
|
814
889
|
const { model, dispatch } = props
|
|
890
|
+
// Hooks must run before the loading/error early returns.
|
|
891
|
+
const [railOpen, setRailOpen] = react.useState(readRailOpen)
|
|
892
|
+
const toggleRail = () => {
|
|
893
|
+
setRailOpen(current => {
|
|
894
|
+
const next = !current
|
|
895
|
+
saveRailOpen(next)
|
|
896
|
+
return next
|
|
897
|
+
})
|
|
898
|
+
}
|
|
899
|
+
react.useEffect(() => {
|
|
900
|
+
if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined
|
|
901
|
+
const onKey = event => {
|
|
902
|
+
if ((event.ctrlKey || event.metaKey) && event.shiftKey && String(event.key).toLowerCase() === 'b') {
|
|
903
|
+
event.preventDefault()
|
|
904
|
+
setRailOpen(current => {
|
|
905
|
+
const next = !current
|
|
906
|
+
saveRailOpen(next)
|
|
907
|
+
return next
|
|
908
|
+
})
|
|
909
|
+
return
|
|
910
|
+
}
|
|
911
|
+
if (event.key === 'Escape' && railOpen) {
|
|
912
|
+
setRailOpen(false)
|
|
913
|
+
saveRailOpen(false)
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
window.addEventListener('keydown', onKey)
|
|
917
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
918
|
+
}, [railOpen])
|
|
815
919
|
if (model.phase === 'loading') {
|
|
816
920
|
return h('div', { className: 'dsa-root' },
|
|
817
921
|
h('div', { className: 'dsa-empty' },
|
|
@@ -828,16 +932,17 @@ window.__ModuleLoader__.load({
|
|
|
828
932
|
onClick: () => dispatch({ type: 'retry' }),
|
|
829
933
|
}, '重试')))
|
|
830
934
|
}
|
|
831
|
-
const title = (() => {
|
|
832
|
-
const current = model.sessions.find(session => session.sessionId === model.sessionId)
|
|
833
|
-
return current ? sessionTitle(current) : model.sessionId ? `会话 ${shortId(model.sessionId)}` : '新会话'
|
|
834
|
-
})()
|
|
835
935
|
const empty = model.messages.length === 0
|
|
936
|
+
const runningCount = Array.isArray(model.runs)
|
|
937
|
+
? model.runs.filter(run => run.status === 'running').length
|
|
938
|
+
: 0
|
|
836
939
|
const notify = text => dispatch({ type: 'toast', text })
|
|
837
|
-
return h('div', { className: 'dsa-root' },
|
|
940
|
+
return h('div', { className: 'dsa-root', 'data-rail': railOpen ? 'open' : 'closed' },
|
|
838
941
|
h(Header, {
|
|
839
942
|
model,
|
|
840
|
-
|
|
943
|
+
railOpen,
|
|
944
|
+
runningCount,
|
|
945
|
+
onToggleRail: toggleRail,
|
|
841
946
|
onNew: () => dispatch({ type: 'new-session' }),
|
|
842
947
|
onRefresh: () => dispatch({ type: 'refresh' }),
|
|
843
948
|
}),
|
|
@@ -873,10 +978,10 @@ window.__ModuleLoader__.load({
|
|
|
873
978
|
onMode: mode => dispatch({ type: 'mode', mode }),
|
|
874
979
|
onError: notify,
|
|
875
980
|
})),
|
|
876
|
-
h(Rail, {
|
|
981
|
+
railOpen ? h(Rail, {
|
|
877
982
|
model,
|
|
878
983
|
onSwitch: sessionId => dispatch({ type: 'switch', sessionId }),
|
|
879
|
-
})))
|
|
984
|
+
}) : null))
|
|
880
985
|
}
|
|
881
986
|
|
|
882
987
|
/** One-line status above the composer; errors stay until replaced. */
|