diff --git a/desktop/src/components/chat/ThinkingBlock.test.tsx b/desktop/src/components/chat/ThinkingBlock.test.tsx new file mode 100644 index 00000000..a980af67 --- /dev/null +++ b/desktop/src/components/chat/ThinkingBlock.test.tsx @@ -0,0 +1,42 @@ +import { afterEach, beforeEach, describe, expect, it } from 'vitest' +import { cleanup, render, screen } from '@testing-library/react' +import '@testing-library/jest-dom' + +import { ThinkingBlock } from './ThinkingBlock' +import { useSettingsStore } from '../../stores/settingsStore' + +describe('ThinkingBlock', () => { + beforeEach(() => { + useSettingsStore.setState({ locale: 'zh' }) + }) + + afterEach(() => { + cleanup() + useSettingsStore.setState({ locale: 'zh' }) + }) + + it('shows the in-progress label while thinking is active', () => { + render() + expect(screen.getByRole('button')).toHaveTextContent('思考中') + expect(screen.getByRole('button')).not.toHaveTextContent('已思考') + }) + + it('shows the done label once thinking has completed', () => { + render() + expect(screen.getByRole('button')).toHaveTextContent('已思考') + expect(screen.getByRole('button')).not.toHaveTextContent('思考中') + }) + + it('defaults to the done label when isActive is omitted', () => { + render() + expect(screen.getByRole('button')).toHaveTextContent('已思考') + }) + + it('localizes both labels in English', () => { + useSettingsStore.setState({ locale: 'en' }) + const { rerender } = render() + expect(screen.getByRole('button')).toHaveTextContent('Thinking') + rerender() + expect(screen.getByRole('button')).toHaveTextContent('Thought') + }) +}) diff --git a/desktop/src/components/chat/ThinkingBlock.tsx b/desktop/src/components/chat/ThinkingBlock.tsx index 284f9a3f..542843be 100644 --- a/desktop/src/components/chat/ThinkingBlock.tsx +++ b/desktop/src/components/chat/ThinkingBlock.tsx @@ -28,7 +28,7 @@ export function ThinkingBlock({ content, isActive = false }: { content: string; {expanded ? '\u25BE' : '\u25B8'} - {t('thinking.label')} + {isActive ? t('thinking.label') : t('thinking.labelDone')} {isActive && } diff --git a/desktop/src/i18n/locales/en.ts b/desktop/src/i18n/locales/en.ts index c5509b54..b7439d6b 100644 --- a/desktop/src/i18n/locales/en.ts +++ b/desktop/src/i18n/locales/en.ts @@ -1304,6 +1304,7 @@ export const en = { // ─── Thinking Block ────────────────────────────────────── 'thinking.label': 'Thinking', + 'thinking.labelDone': 'Thought', // ─── Tool Calls ────────────────────────────────────── 'tool.errorOutput': 'Error Output', diff --git a/desktop/src/i18n/locales/zh.ts b/desktop/src/i18n/locales/zh.ts index 299e831f..cdcfa270 100644 --- a/desktop/src/i18n/locales/zh.ts +++ b/desktop/src/i18n/locales/zh.ts @@ -1306,6 +1306,7 @@ export const zh: Record = { // ─── Thinking Block ────────────────────────────────────── 'thinking.label': '思考中', + 'thinking.labelDone': '已思考', // ─── Tool Calls ────────────────────────────────────── 'tool.errorOutput': '错误输出',