mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-05 01:01:42 +00:00
* feat(web): render AGENT_NOTIFY_SUMMARY as compact metadata * fix(web): defer summary rendering until completion * fix(shared): preserve indentation when splitting summaries * fix(web): guard unknown summary statuses * feat(web): settings for AGENT_NOTIFY_SUMMARY chat display (default hide) Add hub setting sibling to emit (#1376): show compact NotifySummaryText when on; strip footer from chat/copy when off. Store/parse/FCM unchanged. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): address #1477 Majors for display setting Allow any namespace to GET hub-settings (PUT stays owner-only) so sessionSummaryInChat applies hub-wide. Reject whitespace-delimited AGENT_NOTIFY_SUMMARY examples so default-hide does not eat prose. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(shared): allow indented AGENT_NOTIFY_SUMMARY footers Keep rejecting whitespace-delimited prose examples, but accept a standalone footer whose only prefix is leading indentation. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): poll hub display setting; hide empty notify footers Refetch sessionSummaryInChat so open clients pick up owner toggles. When display is on, recognized footers without status/summary/action still strip raw JSON instead of falling back to MarkdownText. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): poll notify display once in chat shell Move hub-settings refetchInterval off per-message hooks into HappyThread context. Strip well-formed footers while streaming when display is off. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web,hub): QueryClient for HappyThread tests; atomic hub-settings Wrap HappyThread mobile-scroll tests in QueryClientProvider after the chat-shell hub-settings poll. Read/write both hub setting flags in one settings.json snapshot under the shared lock. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Ananovo <78636812+techotaku39@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import type { ThreadAssistantMessagePart } from '@assistant-ui/react'
|
|
import { getAssistantCopyText } from '@/components/AssistantChat/messages/assistantCopyText'
|
|
|
|
describe('getAssistantCopyText', () => {
|
|
it('joins assistant text parts and ignores non-text parts', () => {
|
|
const parts = [
|
|
{ type: 'text', text: 'First paragraph.' },
|
|
{ type: 'reasoning', text: 'Hidden chain of thought' },
|
|
{ type: 'tool-call', toolCallId: 'tool-1', toolName: 'search', args: {}, argsText: '{}' },
|
|
{ type: 'text', text: 'Second paragraph.' }
|
|
] satisfies ThreadAssistantMessagePart[]
|
|
|
|
expect(getAssistantCopyText(parts)).toBe('First paragraph.\n\nSecond paragraph.')
|
|
})
|
|
|
|
it('returns empty string when no assistant text exists', () => {
|
|
const parts = [
|
|
{ type: 'reasoning', text: 'Thinking' },
|
|
{ type: 'tool-call', toolCallId: 'tool-1', toolName: 'search', args: {}, argsText: '{}' }
|
|
] satisfies ThreadAssistantMessagePart[]
|
|
|
|
expect(getAssistantCopyText(parts)).toBe('')
|
|
})
|
|
|
|
it('strips trailing AGENT_NOTIFY_SUMMARY when stripNotifySummary is on', () => {
|
|
const parts = [
|
|
{
|
|
type: 'text',
|
|
text: 'Did the work.\n\nAGENT_NOTIFY_SUMMARY {"summary":"Done","status":"done"}'
|
|
}
|
|
] satisfies ThreadAssistantMessagePart[]
|
|
|
|
expect(getAssistantCopyText(parts, { stripNotifySummary: true })).toBe('Did the work.')
|
|
expect(getAssistantCopyText(parts)).toContain('AGENT_NOTIFY_SUMMARY')
|
|
})
|
|
})
|