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: '\n后台子代理「检索」已结束。\n' }],
}
const html = renderToStaticMarkup(createElement(NoticeMessage, { msg }))
expect(html).toContain('通知 · 后台子代理「检索」已结束。')
expect(html).toContain('msg notice')
expect(html).not.toContain('