@blueking/chat-x 0.0.49-beta.2 → 0.0.49-beta.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/dist/components/chat-message/assistant-message/message-artifacts/artifact-preview/use-artifact-preview-loader.d.ts +2 -4
- package/dist/composables/use-artifact-preview.d.ts +4 -11
- package/dist/composables/use-container-scroll.d.ts +9 -2
- package/dist/index.css +1 -1
- package/dist/index.js +875 -864
- package/dist/index.js.map +1 -1
- package/dist/mcp/generated/docs/assistant-message.md +19 -15
- package/dist/mcp/generated/docs/chat-container.md +3 -3
- package/dist/mcp/generated/docs/file-artifact-panel.md +4 -4
- package/dist/mcp/generated/docs/message-container.md +3 -2
- package/dist/mcp/generated/docs/toolcall-render.md +18 -10
- package/dist/mcp/generated/docs/use-artifact-preview.md +5 -5
- package/dist/mcp/generated/docs/use-container-scroll.md +6 -2
- package/dist/mcp/generated/docs/use-message-group.md +8 -5
- package/dist/mcp/generated/index.json +4 -4
- package/package.json +2 -2
|
@@ -102,15 +102,15 @@ const doubled = computed(() => count.value * 2);
|
|
|
102
102
|
|
|
103
103
|
## 消息状态
|
|
104
104
|
|
|
105
|
-
`status`
|
|
105
|
+
`status` 直接影响 **内容区**(`ContentRender`)。`ToolCallRender` 的状态**按工具维度推导**(见下方「工具调用状态推导」),不直接等于本组件的 `status`。
|
|
106
106
|
|
|
107
|
-
| `status` | 内容区效果 |
|
|
108
|
-
| ----------- | ----------------------------------- |
|
|
109
|
-
| `pending` | 正常渲染(通常 content 为空) |
|
|
110
|
-
| `streaming` | Markdown 自动补全未闭合语法 |
|
|
111
|
-
| `complete` | 正常渲染完整 Markdown |
|
|
112
|
-
| `error` | 红色错误图标 + content 作为错误提示 |
|
|
113
|
-
| `stop` | 正常渲染(内容停留在中止时的状态) |
|
|
107
|
+
| `status` | 内容区效果 |
|
|
108
|
+
| ----------- | ----------------------------------- |
|
|
109
|
+
| `pending` | 正常渲染(通常 content 为空) |
|
|
110
|
+
| `streaming` | Markdown 自动补全未闭合语法 |
|
|
111
|
+
| `complete` | 正常渲染完整 Markdown |
|
|
112
|
+
| `error` | 红色错误图标 + content 作为错误提示 |
|
|
113
|
+
| `stop` | 正常渲染(内容停留在中止时的状态) |
|
|
114
114
|
|
|
115
115
|
### Pending
|
|
116
116
|
|
|
@@ -130,7 +130,7 @@ const doubled = computed(() => count.value * 2);
|
|
|
130
130
|
|
|
131
131
|
## 工具调用
|
|
132
132
|
|
|
133
|
-
当 AI 回复中包含工具调用时,传入 `toolCalls` 数组,每项自动渲染为 `ToolCallRender
|
|
133
|
+
当 AI 回复中包含工具调用时,传入 `toolCalls` 数组,每项自动渲染为 `ToolCallRender`,位于内容区下方。传给每个 `ToolCallRender` 的 `status` 按下方优先级从 `toolCall.toolMessage` 推导,而非直接同步本组件的 `status`。
|
|
134
134
|
|
|
135
135
|
### 单个工具调用
|
|
136
136
|
|
|
@@ -278,13 +278,17 @@ AI 可在一次回复中发起多个工具调用,组件依次渲染:
|
|
|
278
278
|
|
|
279
279
|
**渲染效果**
|
|
280
280
|
|
|
281
|
-
###
|
|
281
|
+
### 工具调用状态推导
|
|
282
282
|
|
|
283
|
-
`ToolCallRender`
|
|
283
|
+
传给每个 `ToolCallRender` 的 `status` 按以下优先级计算:
|
|
284
284
|
|
|
285
|
-
|
|
285
|
+
1. 无 `toolMessage` → `MessageStatus.Pending`(调用中)
|
|
286
|
+
2. `toolMessage.error` 为真 → `MessageStatus.Error`(调用失败)
|
|
287
|
+
3. 否则 → `toolMessage.status ??` 本组件 `status`
|
|
286
288
|
|
|
287
|
-
|
|
289
|
+
**调用中**(有 `toolCalls`、尚无 `toolMessage`;即便助手 `status` 已是 `complete` 也显示调用中):
|
|
290
|
+
|
|
291
|
+
**调用成功**(`toolMessage.status = "complete"`):
|
|
288
292
|
|
|
289
293
|
## 自定义内容渲染
|
|
290
294
|
|
|
@@ -381,7 +385,7 @@ AI 可在一次回复中发起多个工具调用,组件依次渲染:
|
|
|
381
385
|
| `html` / `markdown` / `md` / `txt` / `json` | `download_url` | 正文直渲染(srcdoc / MarkdownContent / `<pre>`) |
|
|
382
386
|
| `pdf` / `jpg` 等 | `preview_url` | iframe(一般为后台转好的 PDF) |
|
|
383
387
|
|
|
384
|
-
`md` 与 `markdown` 等价(见 `AIFileType.Md` / `AIFileType.Markdown
|
|
388
|
+
`md` 与 `markdown` 等价(见 `AIFileType.Md` / `AIFileType.Markdown`)。预览重载、重试与取链约定见 [FileArtifactPanel 预览机制](/components/message/file-artifact-panel#预览机制)。
|
|
385
389
|
|
|
386
390
|
```vue
|
|
387
391
|
<template>
|
|
@@ -424,7 +428,7 @@ AI 可在一次回复中发起多个工具调用,组件依次渲染:
|
|
|
424
428
|
| 属性名 | 类型 | 说明 |
|
|
425
429
|
| --------- | ----------------------- | ----------------------------------------------------------------------------------------- |
|
|
426
430
|
| content | `string` | AI 回复文本,支持 Markdown;空值时不渲染内容区 |
|
|
427
|
-
| status | `MessageStatus` | 影响 ContentRender
|
|
431
|
+
| status | `MessageStatus` | 影响 ContentRender;ToolCallRender 在无 toolMessage.status 时回退使用此值 |
|
|
428
432
|
| toolCalls | `ToolCall[]` | 工具调用列表,每项渲染一个 `ToolCallRender` |
|
|
429
433
|
| id | `number \| string` | 消息 ID;无 `uid` 时回退为 `messageUid` |
|
|
430
434
|
| messageId | `number \| string` | 消息唯一标识 |
|
|
@@ -247,8 +247,8 @@ ai-chat-container(:data-ai-size="size")
|
|
|
247
247
|
- **主动打开**:点击 AI 回复中的文件卡片([ArtifactFileCard](/components/message/assistant-message))时,容器通过 `useArtifactPreviewProvider` 以 `outputId` 命中该文件,再 `addCustomTab` 展开侧栏并选中「文件产物」
|
|
248
248
|
- **排序 / 关闭**:`order: -1` 排在「执行情况」之前,`closable: false` 不可关闭
|
|
249
249
|
- **显隐解耦**:该 Tab 存在时,侧栏展示不再受「`executionGroups` 为空」约束(即使当前会话没有执行类消息,也能独立展示文件产物侧栏);会话切换或无文件产物时自动移除并重置命中态
|
|
250
|
-
- **内容**:由 [FileArtifactPanel](/components/message/file-artifact-panel) 渲染列表与下载头,预览委托内部 `ArtifactPreviewHost`;`download_url` / `preview_url` 通过 `onArtifactClick`
|
|
251
|
-
-
|
|
250
|
+
- **内容**:由 [FileArtifactPanel](/components/message/file-artifact-panel) 渲染列表与下载头,预览委托内部 `ArtifactPreviewHost`;`download_url` / `preview_url` 通过 `onArtifactClick` 异步获取(每次重新取链,无 URL 缓存)。文本类(`html` / `markdown` / `md` / `txt` / `json`)拉 `download_url` 正文直渲染(`md` 与 `markdown` 等价);其余类型用 `preview_url` iframe(一般为后台转好的 PDF)。预览重载键为 `outputId:type`;失败重试再次 `load()` 重新取链
|
|
251
|
+
- **状态管理**:命中与切换由 [useArtifactPreview](/composables/use-artifact-preview) 提供(Provider 在容器内、Consumer 在文件卡片 / 面板内);正文加载与分类型渲染由 Host 内部完成;取链只传 `file`,同文件并发去重
|
|
252
252
|
- **未传 `onArtifactClick`**:下载按钮隐藏,预览区展示无数据
|
|
253
253
|
|
|
254
254
|
详见 [FileArtifactPanel 文件产物预览](/components/message/file-artifact-panel) 与 [useArtifactPreview 文件产物预览](/composables/use-artifact-preview)。
|
|
@@ -710,7 +710,7 @@ ChatContainer 的 Props 继承自 `ChatInputProps` 和 `MessageContainerProps`
|
|
|
710
710
|
| size | `'normal' \| 'small'` | `'small'` | 字号主题:`small` 12px / `normal` 14px;根节点设置 `data-ai-size` 并注入 `useGlobalConfig` |
|
|
711
711
|
| welcomeTitle | `string` | — | 欢迎页标题;未传时默认展示「你好,我是小鲸」 |
|
|
712
712
|
| onCustomTabChange | `(tab: CustomTab) => Promise<any>` | — | 自定义 Tab 切换回调,返回值作为 Tab 组件 props |
|
|
713
|
-
| onArtifactClick | `(file: AIFileInfo) => Promise<{ download_url?: string; preview_url?: string }>` | — | 异步获取下载 /
|
|
713
|
+
| onArtifactClick | `(file: AIFileInfo) => Promise<{ download_url?: string; preview_url?: string }>` | — | 异步获取下载 / 预览链接(每次调用重新获取,无缓存;同文件并发去重)。文本类预览依赖 `download_url`,iframe 类依赖 `preview_url`;未传则隐藏下载、预览无数据 |
|
|
714
714
|
|
|
715
715
|
> 其余 Props(如 `messages`、`messageStatus`、`onSendMessage`、`shortcuts` 等)继承自 [ChatInput](/components/input/chat-input) 与 [MessageContainer](/components/setup/message-container)。
|
|
716
716
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- AI SUMMARY -->
|
|
2
2
|
## 快速了解
|
|
3
3
|
|
|
4
|
-
汇总当前会话所有 AssistantMessage 的 artifacts(按 outputId 去重),支持关键词搜索、列表选中与下载; 预览区委托 ArtifactPreviewHost:按类型走 text_from_download(html / markdown / md / txt / json) 或 preview_url_iframe(其余类型);download_url / preview_url 经 onArtifactClick
|
|
4
|
+
汇总当前会话所有 AssistantMessage 的 artifacts(按 outputId 去重),支持关键词搜索、列表选中与下载; 预览区委托 ArtifactPreviewHost:按类型走 text_from_download(html / markdown / md / txt / json) 或 preview_url_iframe(其余类型);download_url / preview_url 经 onArtifactClick 每次异步获取(无 URL 缓存,并发去重); 预览重载键为 outputId:type;重试再次调用 load() 重新取链。 源码位置:src/components/chat-message/assistant-message/message-artifacts/file-artifact-panel.vue。
|
|
5
5
|
|
|
6
6
|
### 关联组件
|
|
7
7
|
- **assistant-message** — 文件产物来源于 AssistantMessage.property.artifacts
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
- **会话级聚合**:拍平当前会话所有 `AssistantMessage.property.artifacts`,以 `outputId` 去重后统一在一个列表内展示
|
|
32
32
|
- **唯一命中**:以 `outputId` 作为会话内唯一键(同 `outputId` 视为同一文件);文件名可能重复,不可作唯一键
|
|
33
33
|
- **关键词搜索**:按文件名实时过滤列表
|
|
34
|
-
- **异步取链**:`AIFileInfo` 本身不含 `url` / `previewUrl`,通过 `ChatContainer` 的 `onArtifactClick` 按 `outputId` 获取 `download_url` / `preview_url
|
|
34
|
+
- **异步取链**:`AIFileInfo` 本身不含 `url` / `previewUrl`,通过 `ChatContainer` 的 `onArtifactClick` 按 `outputId` 获取 `download_url` / `preview_url`(每次重新取链,无 URL 缓存;同文件并发去重)
|
|
35
35
|
- **职责拆分**:
|
|
36
36
|
- **面板本身**:列表、搜索、预览头(文件名 / 图标 / 下载)
|
|
37
37
|
- **`ArtifactPreviewHost`**:按策略加载正文或预览 URL,分派到对应 renderer;展示 loading / empty / error(含重试)
|
|
@@ -206,8 +206,8 @@ sessionArtifacts 有产物时
|
|
|
206
206
|
### 重载与取链约定
|
|
207
207
|
|
|
208
208
|
- **重载键**:`ArtifactPreviewHost` 以 `` `${outputId}:${type}` `` 监听文件变化;`outputId` 或 `type` 任一变化会重新 `load()`,仅改文件名等其它字段不会
|
|
209
|
-
-
|
|
210
|
-
-
|
|
209
|
+
- **取链**:`resolveArtifactUrls(file)` 每次重新调用 `onArtifactClick`;同文件进行中的请求会复用(并发去重)
|
|
210
|
+
- **重试**:错误态点击重试再次走 `load()`,重新取链并加载
|
|
211
211
|
- **竞态**:切换文件时 `useArtifactPreviewLoader` 用 `loadSeq` + `AbortController` 中断上一次 `fetch`,避免过期结果覆盖最新内容
|
|
212
212
|
|
|
213
213
|
下载图标仍由面板用 bkui `Loading` spin 单独表达。
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
- **消息分组**:将连续的非用户消息合并为一组,每组共享一个工具栏
|
|
27
27
|
- **Tool 消息关联**:自动将 `role: 'tool'` 消息注入到对应 Assistant 消息的 toolCall 中
|
|
28
28
|
- **Loading 自动注入**:末尾为用户消息时,自动追加 Loading 动画组
|
|
29
|
-
- **滚动管理**:`messageStatus` 为流式、等待响应或请求中(`streaming` / `pending` / `fetching`)时显示「停止生成」,离开底部时显示「返回底部」;`renderMode` 为 `Share`
|
|
29
|
+
- **滚动管理**:`messageStatus` 为流式、等待响应或请求中(`streaming` / `pending` / `fetching`)时显示「停止生成」,离开底部时显示「返回底部」;`renderMode` 为 `Share` 时不显示「停止生成」。挂载时通过 `jumpToBottom()` 瞬时贴底,避免切换会话时从顶部平滑滚到底部的动画
|
|
30
30
|
- **多选模式**:支持按消息组勾选,用户消息与 AI 回复联动选中
|
|
31
31
|
|
|
32
32
|
## 基础用法
|
|
@@ -533,10 +533,11 @@ AI 回复状态为 `error` 时,消息以错误样式展示:
|
|
|
533
533
|
| 按钮 | 显示条件 | 点击行为 |
|
|
534
534
|
| ------------ | ---------------------------------------------------------------------------------------------- | ---------------------- |
|
|
535
535
|
| 「停止生成」 | `messageStatus` 为 `streaming`、`pending`、`fetching` 或 `stop-loading`(停止中 loading 态),且 `renderMode` 不为 `Share` | 触发 `@stop-streaming` |
|
|
536
|
-
| 「返回底部」 | `debouncedShowScrollBottomBtn`(距底部 > 100px,且防抖 300ms 后才显示/隐藏) |
|
|
536
|
+
| 「返回底部」 | `debouncedShowScrollBottomBtn`(距底部 > 100px,且防抖 300ms 后才显示/隐藏) | 平滑滚动到消息列表底部(显式 `toScrollBottom('smooth')`) |
|
|
537
537
|
|
|
538
538
|
> **防抖说明**:「返回底部」按钮的显隐使用 300ms 防抖,避免快速滚动时按钮频繁闪烁。隐藏时立即生效(无防抖),显示时延迟 300ms。
|
|
539
539
|
|
|
540
|
+
> **首屏 / 切换会话贴底**:`MessageContainer` 挂载时若已有消息组,会立即调用 `jumpToBottom()`,并在下一帧再补一次,避免历史消息渲染过程中出现「从顶部滚到底部」的动画。流式输出场景下的小幅跟随仍由 markdown 挂载触发的 `toScrollBottom()`(距底较近时走 smooth)完成。
|
|
540
541
|
## API
|
|
541
542
|
|
|
542
543
|
### Props
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
│ ├── "调用工具:" / "调用 MCP:"(有 mcpName 时)
|
|
32
32
|
│ ├── .toolcall-header-title(工具名,overflow-tips 溢出截断)
|
|
33
33
|
│ └── .toolcall-status-title
|
|
34
|
-
│ ├── Loading
|
|
34
|
+
│ ├── Loading(pending / streaming)
|
|
35
|
+
│ ├── BkFlowSuccessIcon(success / complete / completed)
|
|
36
|
+
│ ├── BkFlowFailedIcon(error)
|
|
35
37
|
│ ├── 状态文案(调用中 / 调用成功 / 调用失败)
|
|
36
38
|
│ └── .toolcall-duration(耗时,如 "(1.2s)")
|
|
37
39
|
│
|
|
@@ -76,16 +78,16 @@
|
|
|
76
78
|
|
|
77
79
|
## 调用状态
|
|
78
80
|
|
|
79
|
-
`status` prop 同时控制头部的 CSS class(`toolcall-status-{status}
|
|
81
|
+
`status` prop 同时控制头部的 CSS class(`toolcall-status-{status}`)、背景/边框颜色、状态文案和状态图标:
|
|
80
82
|
|
|
81
|
-
| `status` | 状态文案 | 背景色 | 边框色 |
|
|
82
|
-
| ------------------------------------- | -------- | ----------------- | --------- |
|
|
83
|
-
| `pending` / `streaming` | 调用中 | `#fafbfd` | `#dcdee5` |
|
|
84
|
-
| `complete` / `completed` / `success` | 调用成功 | `#ebfaf0` | `#a1e3ba` |
|
|
85
|
-
| `error` | 调用失败 | `#fff0f0` | `#f8b4b4` |
|
|
86
|
-
| 其他 / `undefined` | 调用中 | —(无匹配 class) | — |
|
|
83
|
+
| `status` | 状态文案 | 背景色 | 边框色 | 状态图标 |
|
|
84
|
+
| ------------------------------------- | -------- | ----------------- | --------- | ------------------- |
|
|
85
|
+
| `pending` / `streaming` | 调用中 | `#fafbfd` | `#dcdee5` | `Loading` |
|
|
86
|
+
| `complete` / `completed` / `success` | 调用成功 | `#ebfaf0` | `#a1e3ba` | `BkFlowSuccessIcon` |
|
|
87
|
+
| `error` | 调用失败 | `#fff0f0` | `#f8b4b4` | `BkFlowFailedIcon` |
|
|
88
|
+
| 其他 / `undefined` | 调用中 | —(无匹配 class) | — | — |
|
|
87
89
|
|
|
88
|
-
> **说明**:`statusTitle` 将 `Completed`(`completed`)与 `Complete` / `Success` 一并视为成功;主题 `$toolcallStatusMap` 同步提供 `completed` 色值。`default` 与 `case Pending` 共享「调用中」文案,`streaming` 与未知 status 命中 `default
|
|
90
|
+
> **说明**:`statusTitle` 将 `Completed`(`completed`)与 `Complete` / `Success` 一并视为成功;主题 `$toolcallStatusMap` 同步提供 `completed` 色值。`default` 与 `case Pending` 共享「调用中」文案,`streaming` 与未知 status 命中 `default`。状态图标互斥:`pending` / `streaming` 显示 `Loading`;`success` / `complete` / `completed` 显示 `BkFlowSuccessIcon`;`error` 显示 `BkFlowFailedIcon`。
|
|
89
91
|
|
|
90
92
|
**三种状态对比**
|
|
91
93
|
|
|
@@ -244,7 +246,13 @@ const assistantMessage = {
|
|
|
244
246
|
v-for="toolCall in assistantMessage.toolCalls"
|
|
245
247
|
:key="toolCall.id"
|
|
246
248
|
:tool-call="toolCall"
|
|
247
|
-
:status="
|
|
249
|
+
:status="
|
|
250
|
+
!toolCall.toolMessage
|
|
251
|
+
? MessageStatus.Pending
|
|
252
|
+
: toolCall.toolMessage.error
|
|
253
|
+
? MessageStatus.Error
|
|
254
|
+
: (toolCall.toolMessage.status ?? assistantMessage.status)
|
|
255
|
+
"
|
|
248
256
|
/>
|
|
249
257
|
</template>
|
|
250
258
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- AI SUMMARY -->
|
|
2
2
|
## 快速了解
|
|
3
3
|
|
|
4
|
-
useArtifactPreviewProvider 维护 activeArtifactId(值为 outputId),openPreview 命中文件并触发 onOpen 打开侧栏 Tab; 并通过 getOnArtifactClick 封装 resolveArtifactUrls
|
|
4
|
+
useArtifactPreviewProvider 维护 activeArtifactId(值为 outputId),openPreview 命中文件并触发 onOpen 打开侧栏 Tab; 并通过 getOnArtifactClick 封装 resolveArtifactUrls(每次重新取链,并发去重); useArtifactPreviewConsumer 在后代注入同一套 API。SessionArtifact 即 AIFileInfo,会话内以 outputId 为唯一键。 正文加载与分类型渲染不在本 composable,由 FileArtifactPanel 内 ArtifactPreviewHost 完成(重载键 outputId:type)。 FILE_ARTIFACT_TAB_NAME 标识固定「文件产物」Tab。
|
|
5
5
|
|
|
6
6
|
### 关联组件
|
|
7
7
|
- **chat-container** — Provider 主场景,聚合 sessionArtifacts 并挂载 FileArtifactPanel
|
|
@@ -19,7 +19,7 @@ Provider/Consumer 模式的文件产物预览状态管理。Provider 在 `ChatCo
|
|
|
19
19
|
|
|
20
20
|
**职责边界**:
|
|
21
21
|
|
|
22
|
-
- **本 composable**:维护「命中文件」与「URL
|
|
22
|
+
- **本 composable**:维护「命中文件」与「URL 解析」(每次重新取链 + 并发去重);打开侧栏 Tab(`addCustomTab`)由容器通过 `onOpen` 注入
|
|
23
23
|
- **不在本 composable**:聚合会话文件列表、渲染预览面板、按类型 fetch 正文 / iframe 展示 —— 分别由 `useMessageGroup.sessionArtifacts`、`FileArtifactPanel`、内部 `ArtifactPreviewHost` + `useArtifactPreviewLoader` 承担(预览重载键为 `outputId:type`)
|
|
24
24
|
|
|
25
25
|
## 函数签名
|
|
@@ -36,7 +36,7 @@ function useArtifactPreviewProvider(options: {
|
|
|
36
36
|
activeArtifactId: ShallowRef<string>;
|
|
37
37
|
canResolveArtifactUrl: ComputedRef<boolean>;
|
|
38
38
|
openPreview: (payload: OpenArtifactPreviewPayload) => void;
|
|
39
|
-
resolveArtifactUrls: (file: AIFileInfo
|
|
39
|
+
resolveArtifactUrls: (file: AIFileInfo) => Promise<ArtifactUrlResult>;
|
|
40
40
|
setActiveArtifactId: (id: string) => void;
|
|
41
41
|
};
|
|
42
42
|
```
|
|
@@ -50,7 +50,7 @@ function useArtifactPreviewConsumer():
|
|
|
50
50
|
activeArtifactId: Ref<string>;
|
|
51
51
|
canResolveArtifactUrl: ComputedRef<boolean>;
|
|
52
52
|
openPreview: (payload: OpenArtifactPreviewPayload) => void;
|
|
53
|
-
resolveArtifactUrls: (file: AIFileInfo
|
|
53
|
+
resolveArtifactUrls: (file: AIFileInfo) => Promise<ArtifactUrlResult>;
|
|
54
54
|
setActiveArtifactId: (id: string) => void;
|
|
55
55
|
};
|
|
56
56
|
```
|
|
@@ -166,7 +166,7 @@ const onArtifactClick = async (file: AIFileInfo) => {
|
|
|
166
166
|
| activeArtifactId | `ShallowRef<string>` | 当前命中的文件 `outputId` |
|
|
167
167
|
| canResolveArtifactUrl | `ComputedRef<boolean>` | 是否具备异步取链能力(有 `onArtifactClick` 时为 true,下载按钮据此显隐) |
|
|
168
168
|
| openPreview | `(payload: OpenArtifactPreviewPayload) => void` | 由文件卡片触发:以 `file.outputId` 更新命中态、调用 `onOpen` |
|
|
169
|
-
| resolveArtifactUrls | `(file: AIFileInfo
|
|
169
|
+
| resolveArtifactUrls | `(file: AIFileInfo) => Promise<ArtifactUrlResult>` | 调用 `onArtifactClick` 取链;每次重新获取,不缓存;同文件并发去重 |
|
|
170
170
|
| setActiveArtifactId | `(id: string) => void` | 直接设置命中文件 `outputId`;侧栏列表内切换选中时使用 |
|
|
171
171
|
|
|
172
172
|
## 类型定义
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- AI SUMMARY -->
|
|
2
2
|
## 快速了解
|
|
3
3
|
|
|
4
|
-
useContainerScrollProvider 在滚动容器与底部锚点上绑定 IntersectionObserver、scroll、wheel,提供 isScrollBottom、scrollBottomHeight、autoScrollEnabled、toScrollBottom/toScrollTop 及防抖「返回底部」按钮状态。 useContainerScrollConsumer 通过 inject 在子组件中获取同一套控制,无需 props 透传。 典型用于流式输出时仅在用户位于底部时自动滚底。MessageContainer 与 ScrollBtn 配合使用。
|
|
4
|
+
useContainerScrollProvider 在滚动容器与底部锚点上绑定 IntersectionObserver、scroll、wheel,提供 isScrollBottom、scrollBottomHeight、autoScrollEnabled、jumpToBottom、toScrollBottom/toScrollTop 及防抖「返回底部」按钮状态。 toScrollBottom 缺省按距底部距离自动选择行为:超过 INSTANT_SCROLL_DISTANCE(600px)时瞬时贴底,否则平滑滚动,避免切换会话时出现长距离平滑滚动动画。 useContainerScrollConsumer 通过 inject 在子组件中获取同一套控制,无需 props 透传。 典型用于流式输出时仅在用户位于底部时自动滚底。MessageContainer 与 ScrollBtn 配合使用。
|
|
5
5
|
|
|
6
6
|
### 关联组件
|
|
7
7
|
- **message-container** — Provider 挂载于消息列表滚动区域
|
|
@@ -35,7 +35,10 @@ useContainerScrollProvider(containerRef, bottomRef)
|
|
|
35
35
|
├── wheel 事件(passive)→ deltaY < 0 时 autoScrollEnabled=false
|
|
36
36
|
│ (用户向上滚动时暂停自动滚动)
|
|
37
37
|
│
|
|
38
|
-
├──
|
|
38
|
+
├── jumpToBottom() → autoScrollEnabled=true + container.scrollTop = scrollHeight(瞬时)
|
|
39
|
+
├── toScrollBottom(behavior?) → autoScrollEnabled=true;
|
|
40
|
+
│ behavior 缺省时:距底部 > INSTANT_SCROLL_DISTANCE(600) → jumpToBottom()
|
|
41
|
+
│ 否则 / 显式 'smooth' → bottomRef.scrollIntoView({ behavior:'smooth', block:'end' })
|
|
39
42
|
├── toScrollTop() → containerRef.scrollTo({ top:0, behavior:'smooth' })
|
|
40
43
|
│
|
|
41
44
|
└── provide(CONTAINER_SCROLL_TOKEN, computed(() => ({
|
|
@@ -43,6 +46,7 @@ useContainerScrollProvider(containerRef, bottomRef)
|
|
|
43
46
|
isScrollBottom, // ShallowRef<boolean>(保持响应式)
|
|
44
47
|
scrollBottomHeight, // ShallowRef<number>(保持响应式)
|
|
45
48
|
debouncedShowScrollBottomBtn, // customRef,防抖显示返回底部按钮
|
|
49
|
+
jumpToBottom,
|
|
46
50
|
toScrollBottom,
|
|
47
51
|
toScrollTop,
|
|
48
52
|
})))
|
|
@@ -71,15 +71,18 @@ role=user role=tool 其他 role
|
|
|
71
71
|
`role: 'tool'` 消息不会独立渲染,而是通过 `toolCallId` 注入到对应 AssistantMessage 的 `toolCall.toolMessage` 字段:
|
|
72
72
|
|
|
73
73
|
```typescript
|
|
74
|
-
const
|
|
74
|
+
const assistantToolMessage = messages.find(
|
|
75
75
|
m => m.role === 'assistant' && m.toolCalls?.some(t => t.id === message.toolCallId),
|
|
76
|
-
);
|
|
77
|
-
if (
|
|
78
|
-
const toolCall =
|
|
76
|
+
) as AssistantMessage | undefined;
|
|
77
|
+
if (assistantToolMessage) {
|
|
78
|
+
const toolCall = assistantToolMessage.toolCalls?.find(t => t.id === message.toolCallId);
|
|
79
79
|
if (toolCall) {
|
|
80
80
|
toolCall.toolMessage = message;
|
|
81
81
|
}
|
|
82
|
-
//
|
|
82
|
+
// error 时强制 assistant 为 Error;否则保留原 status,空值兜底 Complete
|
|
83
|
+
assistantToolMessage.status = message.error
|
|
84
|
+
? MessageStatus.Error
|
|
85
|
+
: assistantToolMessage.status || MessageStatus.Complete;
|
|
83
86
|
}
|
|
84
87
|
```
|
|
85
88
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "2.0.0",
|
|
3
|
-
"generatedAt": "2026-08-
|
|
3
|
+
"generatedAt": "2026-08-07T07:34:43.673Z",
|
|
4
4
|
"domains": {
|
|
5
5
|
"setup": {
|
|
6
6
|
"label": "对话搭建",
|
|
@@ -1115,7 +1115,7 @@
|
|
|
1115
1115
|
"slug": "file-artifact-panel",
|
|
1116
1116
|
"kind": "component",
|
|
1117
1117
|
"description": "汇总当前会话全部文件产物,支持搜索、选中与分类型预览,挂载在 ChatContainer 侧栏「文件产物」Tab。",
|
|
1118
|
-
"aiSummary": "汇总当前会话所有 AssistantMessage 的 artifacts(按 outputId 去重),支持关键词搜索、列表选中与下载; 预览区委托 ArtifactPreviewHost:按类型走 text_from_download(html / markdown / md / txt / json) 或 preview_url_iframe(其余类型);download_url / preview_url 经 onArtifactClick
|
|
1118
|
+
"aiSummary": "汇总当前会话所有 AssistantMessage 的 artifacts(按 outputId 去重),支持关键词搜索、列表选中与下载; 预览区委托 ArtifactPreviewHost:按类型走 text_from_download(html / markdown / md / txt / json) 或 preview_url_iframe(其余类型);download_url / preview_url 经 onArtifactClick 每次异步获取(无 URL 缓存,并发去重); 预览重载键为 outputId:type;重试再次调用 load() 重新取链。 源码位置:src/components/chat-message/assistant-message/message-artifacts/file-artifact-panel.vue。",
|
|
1119
1119
|
"relatedComponents": [
|
|
1120
1120
|
{
|
|
1121
1121
|
"slug": "assistant-message",
|
|
@@ -1586,7 +1586,7 @@
|
|
|
1586
1586
|
"slug": "use-artifact-preview",
|
|
1587
1587
|
"kind": "composable",
|
|
1588
1588
|
"description": "Provider/Consumer 模式的文件产物预览状态管理,用于 ChatContainer 侧栏「文件产物」Tab 的命中与切换。 Provider 在 ChatContainer 中创建,Consumer 在深层文件卡片中注入使用。",
|
|
1589
|
-
"aiSummary": "useArtifactPreviewProvider 维护 activeArtifactId(值为 outputId),openPreview 命中文件并触发 onOpen 打开侧栏 Tab; 并通过 getOnArtifactClick 封装 resolveArtifactUrls
|
|
1589
|
+
"aiSummary": "useArtifactPreviewProvider 维护 activeArtifactId(值为 outputId),openPreview 命中文件并触发 onOpen 打开侧栏 Tab; 并通过 getOnArtifactClick 封装 resolveArtifactUrls(每次重新取链,并发去重); useArtifactPreviewConsumer 在后代注入同一套 API。SessionArtifact 即 AIFileInfo,会话内以 outputId 为唯一键。 正文加载与分类型渲染不在本 composable,由 FileArtifactPanel 内 ArtifactPreviewHost 完成(重载键 outputId:type)。 FILE_ARTIFACT_TAB_NAME 标识固定「文件产物」Tab。",
|
|
1590
1590
|
"relatedComponents": [
|
|
1591
1591
|
{
|
|
1592
1592
|
"slug": "chat-container",
|
|
@@ -1644,7 +1644,7 @@
|
|
|
1644
1644
|
"slug": "use-container-scroll",
|
|
1645
1645
|
"kind": "composable",
|
|
1646
1646
|
"description": "为消息容器提供滚动控制的组合式函数对,通过 **Provider/Consumer** 模式在父子组件间共享滚动状态。",
|
|
1647
|
-
"aiSummary": "useContainerScrollProvider 在滚动容器与底部锚点上绑定 IntersectionObserver、scroll、wheel,提供 isScrollBottom、scrollBottomHeight、autoScrollEnabled、toScrollBottom/toScrollTop 及防抖「返回底部」按钮状态。 useContainerScrollConsumer 通过 inject 在子组件中获取同一套控制,无需 props 透传。 典型用于流式输出时仅在用户位于底部时自动滚底。MessageContainer 与 ScrollBtn 配合使用。",
|
|
1647
|
+
"aiSummary": "useContainerScrollProvider 在滚动容器与底部锚点上绑定 IntersectionObserver、scroll、wheel,提供 isScrollBottom、scrollBottomHeight、autoScrollEnabled、jumpToBottom、toScrollBottom/toScrollTop 及防抖「返回底部」按钮状态。 toScrollBottom 缺省按距底部距离自动选择行为:超过 INSTANT_SCROLL_DISTANCE(600px)时瞬时贴底,否则平滑滚动,避免切换会话时出现长距离平滑滚动动画。 useContainerScrollConsumer 通过 inject 在子组件中获取同一套控制,无需 props 透传。 典型用于流式输出时仅在用户位于底部时自动滚底。MessageContainer 与 ScrollBtn 配合使用。",
|
|
1648
1648
|
"relatedComponents": [
|
|
1649
1649
|
{
|
|
1650
1650
|
"slug": "message-container",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueking/chat-x",
|
|
3
|
-
"version": "0.0.49-beta.
|
|
3
|
+
"version": "0.0.49-beta.4",
|
|
4
4
|
"description": "蓝鲸智云 AI Chat 组件库 —— 遵循 AG-UI,为 AI Agent 和人类开发者共同设计的对话 UI 组件库。",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"vitepress": "2.0.0-alpha.16",
|
|
80
80
|
"vitest": "^4.0.18",
|
|
81
81
|
"vue-tsc": "^3.1.4",
|
|
82
|
-
"@blueking/chat-helper": "0.0.12-beta.
|
|
82
|
+
"@blueking/chat-helper": "0.0.12-beta.15"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
85
85
|
"dev": "vite --config vite.config.ts",
|