From 31eec74e15f8b7d7b077d13ab84fe6a67e0662a2 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Thu, 5 Mar 2026 10:54:53 +0800 Subject: [PATCH 1/6] feat(reasoning): default expand thinking bubble --- docs/src/components/bubble.md | 8 +++++--- docs/src/tools/message.md | 2 +- packages/components/src/bubble/renderers/Reasoning.vue | 9 +++++---- packages/kit/src/vue/message/plugins/thinkingPlugin.ts | 6 ++++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/src/components/bubble.md b/docs/src/components/bubble.md index 5515967f8..2c6f9bf7d 100644 --- a/docs/src/components/bubble.md +++ b/docs/src/components/bubble.md @@ -630,9 +630,11 @@ type BubbleMessageGroup = { **reasoning 推理** -| 变量名 | 说明 | -| ---------------------------------- | ------------------------------ | -| `--tr-bubble-reasoning-max-height` | 推理内容最大高度(默认 300px) | +| 变量名 | 说明 | +| ------------------------------------------- | -------------------------------------------------- | +| `--tr-bubble-reasoning-max-height` | 推理内容最大高度(默认 300px) | +| `--tr-bubble-reasoning-side-border-width` | 推理内容左侧边线宽度(默认 1.5px) | +| `--tr-bubble-reasoning-side-border-color` | 推理内容左侧边线颜色(默认使用 `--tr-border-color-disabled`) | **BubbleList 容器变量** diff --git a/docs/src/tools/message.md b/docs/src/tools/message.md index 06416c7ce..8ccf1a82e 100644 --- a/docs/src/tools/message.md +++ b/docs/src/tools/message.md @@ -245,7 +245,7 @@ useMessage({ #### thinkingPlugin -根据流式响应中的 `reasoning_content`(或 `choice.delta.reasoning_content`)更新当前消息的 `state.thinking`,用于展示“思考中”等 UI;在回合结束时清除该状态。**已默认激活**;若需禁用或自定义配置,可显式传入覆盖: +根据流式响应中的 `reasoning_content`(或 `choice.delta.reasoning_content`)更新当前消息的 `state.thinking` 与 `state.open`;思考中时自动展开思考过程,结束后自动收起。若需禁用或自定义配置,可显式传入覆盖: ```typescript import { thinkingPlugin, useMessage } from '@opentiny/tiny-robot-kit' diff --git a/packages/components/src/bubble/renderers/Reasoning.vue b/packages/components/src/bubble/renderers/Reasoning.vue index 0482df3e0..128beefa6 100644 --- a/packages/components/src/bubble/renderers/Reasoning.vue +++ b/packages/components/src/bubble/renderers/Reasoning.vue @@ -18,10 +18,11 @@ const { restMessage, restProps } = useOmitMessageFields(props, ['reasoning_conte const renderer = useBubbleContentRenderer(restMessage, props.contentIndex) -const open = ref(false) +const open = ref(true) watchEffect(() => { - open.value = props.message.state?.open ?? false + // 思考过程默认展开 + open.value = props.message.state?.open ?? true }) const handleStateChange = useBubbleStateChangeFn() @@ -164,8 +165,8 @@ watch( .border-line { flex: 1; - width: 1.5px; - background-color: var(--tr-border-color-disabled); + width: var(--tr-bubble-reasoning-side-border-width, 1.5px); + background-color: var(--tr-bubble-reasoning-side-border-color, var(--tr-border-color-disabled)); border-radius: 1px; } } diff --git a/packages/kit/src/vue/message/plugins/thinkingPlugin.ts b/packages/kit/src/vue/message/plugins/thinkingPlugin.ts index f23c7650c..f7fae3fca 100644 --- a/packages/kit/src/vue/message/plugins/thinkingPlugin.ts +++ b/packages/kit/src/vue/message/plugins/thinkingPlugin.ts @@ -10,8 +10,9 @@ export const thinkingPlugin = (options: UseMessagePlugin = {}): UseMessagePlugin const thinking = typeof reasoning_content === 'string' if (currentMessage.state) { currentMessage.state.thinking = thinking + currentMessage.state.open = thinking } else { - currentMessage.state = { thinking } + currentMessage.state = { thinking, open: thinking } } return options.onCompletionChunk?.(context) @@ -19,8 +20,9 @@ export const thinkingPlugin = (options: UseMessagePlugin = {}): UseMessagePlugin onTurnEnd(context) { // 如果不是流式数据或者请求被中断,thinking 状态可能不会被更新,在 onTurnEnd 中手动更新 const lastMessage = context.currentTurn.slice(-1)[0] - if (lastMessage?.state) { + if (lastMessage?.state?.thinking) { lastMessage.state.thinking = undefined + lastMessage.state.open = undefined } return options.onTurnEnd?.(context) }, From ed0a1dc8e96aac43dbb1d649a62cb82c469f81d9 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Fri, 6 Mar 2026 11:38:20 +0800 Subject: [PATCH 2/6] fix(thinkingPlugin): update thinking state to false on turn end --- packages/kit/src/vue/message/plugins/thinkingPlugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/kit/src/vue/message/plugins/thinkingPlugin.ts b/packages/kit/src/vue/message/plugins/thinkingPlugin.ts index f7fae3fca..7faae7a42 100644 --- a/packages/kit/src/vue/message/plugins/thinkingPlugin.ts +++ b/packages/kit/src/vue/message/plugins/thinkingPlugin.ts @@ -21,8 +21,8 @@ export const thinkingPlugin = (options: UseMessagePlugin = {}): UseMessagePlugin // 如果不是流式数据或者请求被中断,thinking 状态可能不会被更新,在 onTurnEnd 中手动更新 const lastMessage = context.currentTurn.slice(-1)[0] if (lastMessage?.state?.thinking) { - lastMessage.state.thinking = undefined - lastMessage.state.open = undefined + lastMessage.state.thinking = false + lastMessage.state.open = false } return options.onTurnEnd?.(context) }, From 9952d2a954e62d769165c8b147db1fafb5ffec01 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Tue, 10 Mar 2026 11:45:11 +0800 Subject: [PATCH 3/6] docs(quick-start): update component usage from tr-bubble-item to tr-bubble in quick start guide --- docs/src/guide/quick-start.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/guide/quick-start.md b/docs/src/guide/quick-start.md index 71b84489d..938230a2e 100644 --- a/docs/src/guide/quick-start.md +++ b/docs/src/guide/quick-start.md @@ -72,11 +72,11 @@ app.mount('#app') ```vue