# Chat Reasoning

> 紧凑呈现推理摘要，展开查看详情。

网页来源：/components/chat-reasoning

版本：@quirekit/ui 0.3.1；源码修订：d79a6b48d00e+worktree。此文档对应当前源码构建，接入方式以开始使用为准。

接入前置：[开始使用](/raw/components/getting-started.md)（Vue、样式、主题与图标 Provider）。

`part` 提供稳定身份、文本、摘要和状态。默认收起；流式追加和结束不会覆盖你的展开选择。`default` slot 可接入 Prose renderer，`v-model:open` 可由宿主管理。

展开入口采用透明背景：悬停时强调文字，键盘聚焦时增加下划线，不显示整行背景色。

### 示例：chat-reasoning/basic

文件：`basic.vue`

```vue
<script setup lang="ts">
import { ref } from 'vue';
import { QuireButton, QuireChatReasoning } from '@quirekit/ui/vue';
import type { QuireKitChatReasoningPart } from '@quirekit/ui';
const part = ref<QuireKitChatReasoningPart>({ id: 'analysis', kind: 'reasoning', title: '思考过程', meta: '4 秒', state: 'complete', text: '先核对交付范围，再识别负责人和前置依赖。\n最后将验收条件整理为可执行步骤。' });
/** Append while keeping the current part identity and disclosure choice. */
function append(): void { part.value = { ...part.value, state: 'streaming', text: part.value.text + '\n继续检查团队评审需要的资料。' }; }
</script>
<template>
  <div class="grid gap-qk-surface p-qk-surface" data-reasoning-standalone>
    <QuireChatReasoning :part="part" />
    <div class="flex gap-qk-inline">
      <QuireButton variant="outline" @click="append">追加推理</QuireButton>
      <QuireButton variant="outline" @click="part = { ...part, state: 'complete' }">结束推理</QuireButton>
    </div>
  </div>
</template>
```

## API

### QuireChatReasoning

#### Props

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| part | 是 | — | 推理展示投影。 |
| messageId | 否 | — | 所属消息的身份，独立使用时可省略。 |
| open | 否 | undefined | 受控展开状态；省略时组件按 Part 身份持有。 |
| defaultOpen | 否 | — | 未受控时的初始状态；流式结束不会强行收起。 |

**part**

```ts
QuireKitChatReasoningPart
```

```ts
{
  /** 推理判别项。 */
  kind: "reasoning";
  /** 标题；省略时使用语言包中的默认标题。 */
  title?: undefined | string;
  /** 可选单行摘要，不由 UI 猜测或定时生成。 */
  summary?: string | undefined;
  /** 宿主提供的耗时等次要文案。 */
  meta?: string | undefined;
  /** 完整推理文本。 */
  text: string;
  /** 推理状态，默认 complete；不会改变用户的展开选择。 */
  state?: undefined | "error" | "complete" | "streaming" | "stopped";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: undefined | readonly ({
    /** 在所属操作组内稳定且唯一的标识。 */
    id: string;
    /** 可见名称或图标操作的辅助名称。 */
    label: string;
    /** IconProvider 中的图标名；省略时显示文字按钮。 */
    icon?: string | undefined;
    /** 明确不可执行时禁用。 */
    disabled?: boolean | undefined;
    /** 宿主正在处理此操作；阻止重复触发。 */
    busy?: boolean | undefined;
    /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
    pressed?: boolean | undefined;
    /** 需要危险语义的操作。 */
    danger?: boolean | undefined;
    /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
    placement?: undefined | "inline" | "more";
    /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
    when?: undefined | "settled" | "active" | "always";
  })[];
}
```

**messageId**

```ts
string | undefined
```

```ts
undefined | string
```

**open**

```ts
boolean | undefined
```

**defaultOpen**

```ts
boolean | undefined
```

#### Events

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| action | 否 | — |  |
| update\:open | 否 | — |  |

**action**

```ts
[details: QuireKitChatActionDetails]
```

**update:open**

```ts
[value: boolean]
```

#### Slots

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| default | 否 | — |  |

**default**

```ts
{ part: QuireKitChatReasoningPart; }
```

```ts
{
  part: {
    /** 推理判别项。 */
    kind: "reasoning";
    /** 标题；省略时使用语言包中的默认标题。 */
    title?: undefined | string;
    /** 可选单行摘要，不由 UI 猜测或定时生成。 */
    summary?: string | undefined;
    /** 宿主提供的耗时等次要文案。 */
    meta?: string | undefined;
    /** 完整推理文本。 */
    text: string;
    /** 推理状态，默认 complete；不会改变用户的展开选择。 */
    state?: undefined | "error" | "complete" | "streaming" | "stopped";
    /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
    id: string;
    /** 可选的局部操作。 */
    actions?: undefined | readonly ({
      /** 在所属操作组内稳定且唯一的标识。 */
      id: string;
      /** 可见名称或图标操作的辅助名称。 */
      label: string;
      /** IconProvider 中的图标名；省略时显示文字按钮。 */
      icon?: string | undefined;
      /** 明确不可执行时禁用。 */
      disabled?: boolean | undefined;
      /** 宿主正在处理此操作；阻止重复触发。 */
      busy?: boolean | undefined;
      /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
      pressed?: boolean | undefined;
      /** 需要危险语义的操作。 */
      danger?: boolean | undefined;
      /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
      placement?: "inline" | "more" | undefined;
      /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
      when?: "settled" | "active" | "always" | undefined;
    })[];
  };
}
```

#### 公开实例成员

无。

#### 相关类型

```ts
type QuireKitChatReasoningPart = {
  /** 推理判别项。 */
  kind: "reasoning";
  /** 标题；省略时使用语言包中的默认标题。 */
  title?: undefined | string;
  /** 可选单行摘要，不由 UI 猜测或定时生成。 */
  summary?: string | undefined;
  /** 宿主提供的耗时等次要文案。 */
  meta?: string | undefined;
  /** 完整推理文本。 */
  text: string;
  /** 推理状态，默认 complete；不会改变用户的展开选择。 */
  state?: undefined | "error" | "complete" | "streaming" | "stopped";
  /** 消息内唯一、非空的稳定 ID，跨 chunk 和终态保持。 */
  id: string;
  /** 可选的局部操作。 */
  actions?: undefined | readonly ({
    /** 在所属操作组内稳定且唯一的标识。 */
    id: string;
    /** 可见名称或图标操作的辅助名称。 */
    label: string;
    /** IconProvider 中的图标名；省略时显示文字按钮。 */
    icon?: string | undefined;
    /** 明确不可执行时禁用。 */
    disabled?: boolean | undefined;
    /** 宿主正在处理此操作；阻止重复触发。 */
    busy?: boolean | undefined;
    /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
    pressed?: boolean | undefined;
    /** 需要危险语义的操作。 */
    danger?: boolean | undefined;
    /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
    placement?: "inline" | "more" | undefined;
    /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
    when?: "settled" | "active" | "always" | undefined;
  })[];
};
```

```ts
type QuireKitChatAction = {
  /** 在所属操作组内稳定且唯一的标识。 */
  id: string;
  /** 可见名称或图标操作的辅助名称。 */
  label: string;
  /** IconProvider 中的图标名；省略时显示文字按钮。 */
  icon?: string | undefined;
  /** 明确不可执行时禁用。 */
  disabled?: boolean | undefined;
  /** 宿主正在处理此操作；阻止重复触发。 */
  busy?: boolean | undefined;
  /** 内联反馈/开关类操作的受控按下状态；有此状态的操作保持内联。 */
  pressed?: boolean | undefined;
  /** 需要危险语义的操作。 */
  danger?: boolean | undefined;
  /** inline 留在操作栏，more 放进紧凑的公共 Menu。 */
  placement?: undefined | "inline" | "more";
  /** 消息级默认 settled，Part 级默认 always；active 用于停止，always 用于必要恢复/确认。 */
  when?: undefined | "settled" | "active" | "always";
};
```
