Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
test(voice): make composer race guard declaration-independent
JiangJiahao04967f3729bf
diff --git a/apps/desktop/src/renderer/__tests__/voiceInputEnterToSend.test.ts b/apps/desktop/src/renderer/__tests__/voiceInputEnterToSend.test.tsindex 8b86e0c233..c541d701a3 100644--- a/apps/desktop/src/renderer/__tests__/voiceInputEnterToSend.test.ts+++ b/apps/desktop/src/renderer/__tests__/voiceInputEnterToSend.test.ts@@ -2,6 +2,10 @@ import { readFileSync } from 'node:fs';import { resolve } from 'node:path';import { describe, expect, it } from 'vitest';+// Guard tier, engineering-conventions §3.2: these cross-hook race contracts+// protect source-draft ownership and stop/refine completion across task switches.+// The wiring lives in component-local closures, not an exported helper. Keep+// runtime dispatch coverage in chatInputModelLoading.test.tsx as well.const chatInputSource = readFileSync(resolve(__dirname, '..', 'components', 'new-chat', 'ChatInput.tsx'),'utf8',@@ -262,9 +266,13 @@ describe('ChatInput voice input Enter-to-send contract', () => {'const latestStorageKeyRef = useRef<string | undefined>(storageKey);',);expect(restoreEffectBlock).toContain('if (!hasHydratedRef.current) return;');- expect(restoreEffectBlock).toContain('let cancelled = false;');+ // Initial state and transition ownership matter; let versus const does not.+ // CI on ca67ca85f9 failed here after an equivalent prefer-const lint fix.+ expect(restoreEffectBlock).toMatch(/\b(?:const|let)\s+cancelled\s*=\s*false\s*;/);expect(restoreEffectBlock).toContain('!cancelled');expect(restoreEffectBlock).toContain('!editor.isDestroyed');+ expect(restoreEffectBlock).toContain('isDataOwnerGenerationCurrent(dataOwnerAtTransition)');+ expect(restoreEffectBlock).toContain('storageKeyTransitionSeqRef.current === transitionSeq');expect(restoreEffectBlock).toContain('latestStorageKeyRef.current === storageKey');expect(restoreEffectBlock).toContain('if (!isCurrentTransition()) return;');expect(restoreEffectBlock).toContain('restoreNextDraft();');diff --git a/scripts/test-hygiene-baseline.json b/scripts/test-hygiene-baseline.jsonindex 24be857e96..e64a4de95b 100644--- a/scripts/test-hygiene-baseline.json+++ b/scripts/test-hygiene-baseline.json@@ -789,9 +789,6 @@"apps/desktop/src/renderer/__tests__/userMessageCollapse.test.ts": {"sourceReads": 1},- "apps/desktop/src/renderer/__tests__/voiceInputEnterToSend.test.ts": {- "sourceReads": 2- },"apps/desktop/src/renderer/components/chat/__tests__/embeddedSessionNavigation.test.tsx": {"sourceReads": 1},diff --git a/scripts/test-workspaces.config.mjs b/scripts/test-workspaces.config.mjsindex ae3e50d7e0..69debda44a 100644--- a/scripts/test-workspaces.config.mjs+++ b/scripts/test-workspaces.config.mjs@@ -149,6 +149,8 @@ const mobileGuardInclude = [// in the explicit guard tier. Keeping an exact allowlist makes it impossible// for a new source scan to silently become part of the ordinary unit gate.const desktopGuardInclude = [+ // Cross-hook voice stop/refine ownership and composer hydration race wiring.+ 'src/renderer/__tests__/voiceInputEnterToSend.test.ts','src/renderer/__tests__/sessionAgentSwitchRemoteRouting.contract.test.ts','src/main/__tests__/deviceLinkVoiceCredentialBootstrap.test.ts','src/main/__tests__/discordExternalization.test.ts',