The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): cover wire reference normalization edges
Paulo Nascimentofed10fa245e4
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts b/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.tsindex 335bad8113f..1a67321d8e2 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts+++ b/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts@@ -1,6 +1,6 @@import { afterEach, beforeEach, describe, expect, it } from 'vitest'-import { WIRE_REFERENCE_KINDS } from '@/components/assistant-ui/reference-kinds'+import { textWithoutReferenceLines, WIRE_REFERENCE_KINDS } from '@/components/assistant-ui/reference-kinds'import type { ChatMessage } from '@/lib/chat-messages'import { $approvalModes, approvalModeForProfile } from '@/store/approval-mode'import { $desktopOnboarding } from '@/store/onboarding'@@ -616,6 +616,49 @@ describe('preserveLocalPendingTurnMessages', () => {})+ it('does not duplicate a directive-only file turn', () => {+ const previous = [+ msg('1-user', 'user', 'first'),+ msg('2-assistant', 'assistant', 'first answer'),+ msg('user-optimistic', 'user', '', {+ attachmentRefs: ['@file:X']+ })+ ]++ const next = [+ msg('1-user-stored', 'user', 'first'),+ msg('2-assistant-stored', 'assistant', 'first answer'),+ msg('3-user-stored', 'user', '@file:X')+ ]++ expect(preserveLocalPendingTurnMessages(next, previous)).toBe(next)+ })++ it('does not duplicate a turn with multiple CRLF directives and Unicode payloads', () => {+ const refs = ['@file:`資料/über notes.md`', '@url:`https://example.com/café?q=✓`']+ const previous = [+ msg('1-user', 'user', 'first'),+ msg('2-assistant', 'assistant', 'first answer'),+ msg('user-optimistic', 'user', 'text', {+ attachmentRefs: refs+ })+ ]++ const next = [+ msg('1-user-stored', 'user', 'first'),+ msg('2-assistant-stored', 'assistant', 'first answer'),+ msg('3-user-stored', 'user', `${refs.join('\r\n')}\r\n\r\ntext`)+ ]++ expect(preserveLocalPendingTurnMessages(next, previous)).toBe(next)+ })++ it('strips only complete reference lines from visible text', () => {+ expect(textWithoutReferenceLines('see @file:X here')).toBe('see @file:X here')+ expect(textWithoutReferenceLines('@file:X trailing prose')).toBe('@file:X trailing prose')+ expect(textWithoutReferenceLines(' @file:X')).toBe('@file:X')+ })+it('still keeps a genuinely uncommitted optimistic image turn when the persisted text differs', () => {const previous = [msg('1-user', 'user', 'first'),