Why: A background child should not look like the conversation is busy, and its completion note needs a compact row instead of a full assistant bubble. Evidence: vitest run passed, including design-guard. tsc -b passed. Impact: The stop button cancels the conversation run. System notices fold with the shared Collapsible. Refs: feature/agent-harness-p3b Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { renderToStaticMarkup } from 'react-dom/server'
|
|
import { createElement } from 'react'
|
|
import { activeRun } from '../src/store'
|
|
import { NoticeMessage } from '../src/components/Conversation'
|
|
import type { Message, Run } from '../src/contracts'
|
|
|
|
function run(kind: Run['kind'], status: Run['status']): Run {
|
|
return {
|
|
id: `${kind}-${status}`, conversationId: 'c', projectId: 'p',
|
|
kind, status, createdAt: '2026-10-01T00:00:00Z',
|
|
}
|
|
}
|
|
|
|
describe('activeRun', () => {
|
|
it('ignores background subagents so they do not block sending', () => {
|
|
const runs = [run('subagent', 'running'), run('conversation', 'completed')]
|
|
expect(activeRun(runs)).toBeUndefined()
|
|
expect(activeRun([run('conversation', 'running'), run('subagent', 'running')])?.kind).toBe('conversation')
|
|
})
|
|
})
|
|
|
|
describe('NoticeMessage', () => {
|
|
it('renders a compact notice row', () => {
|
|
const msg: Message = {
|
|
id: 'msg_notice', conversationId: 'c', role: 'system', createdAt: '2026-10-01T00:00:00Z',
|
|
parts: [{ type: 'text', text: '<system-reminder>\n后台子代理「检索」已结束。\n</system-reminder>' }],
|
|
}
|
|
const html = renderToStaticMarkup(createElement(NoticeMessage, { msg }))
|
|
expect(html).toContain('通知 · 后台子代理「检索」已结束。')
|
|
expect(html).toContain('msg notice')
|
|
expect(html).not.toContain('<details')
|
|
})
|
|
})
|