Voice interactions still called OpenRouter directly from the main
process with a leftover pre-redesign system prompt ("coach de
formation vocal"), bypassing Max API's intent router and the new
PERSONALITY_PROMPT entirely - causing Max to misrepresent himself in
spoken conversation. voice-turn now calls routeMessage() (the same
POST /sessions/messages entry point the chat window uses), so voice
and text share one personality and one pipeline.
The leaked-boilerplate/degenerate-text safety checks that used to live
alongside the old direct OpenRouter call move to a focused
speechSafety.ts module, still applied to the reply before it's spoken.
getAssistantReply() and its model-fallback plumbing are deleted - that
logic now lives server-side in Max API's OpenRouterService.
A learn-intent voice command (e.g. saying "apprends-moi React out
loud") now opens the pipeline stepper and syncs session status exactly
like typing it in chat, via a handleRouteMessageResult() helper shared
between voice-turn and sessions:route-message.
Known limitations (unchanged from the text-chat intent router, now
just consistent across both channels): casual chat-intent turns have
no cross-turn memory (no pre-session history storage server-side yet),
and a voice-started session's messages don't appear in the chat
window's own transcript if opened afterwards (per-window state only).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import {
|
|
containsLeakedBoilerplate,
|
|
isDegenerateText,
|
|
sanitizeForSpeech,
|
|
SPEECH_FALLBACK_REPLY
|
|
} from '../../src/main/ai/speechSafety'
|
|
|
|
describe('containsLeakedBoilerplate()', () => {
|
|
it('should detect leaked English model boilerplate with no French words', () => {
|
|
expect(
|
|
containsLeakedBoilerplate(
|
|
'Use the results below to formulate an answer to the user question with additional information needed'
|
|
)
|
|
).toBe(true)
|
|
})
|
|
|
|
it('should not flag a normal French reply', () => {
|
|
expect(containsLeakedBoilerplate('Bonjour, comment puis-je aider ?')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('isDegenerateText()', () => {
|
|
it('should detect a non-Latin corrupted reply', () => {
|
|
expect(isDegenerateText('的问题是什么呢我不知道该怎么办才好呢')).toBe(true)
|
|
})
|
|
|
|
it('should not flag a normal French reply', () => {
|
|
expect(isDegenerateText('Bonjour, comment puis-je aider ?')).toBe(false)
|
|
})
|
|
|
|
it('should not flag an empty string', () => {
|
|
expect(isDegenerateText('')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('sanitizeForSpeech()', () => {
|
|
it('should replace a leaked English boilerplate reply with the safe fallback message', () => {
|
|
expect(
|
|
sanitizeForSpeech(
|
|
'Use the results below to formulate an answer to the user question with additional information needed'
|
|
)
|
|
).toBe(SPEECH_FALLBACK_REPLY)
|
|
})
|
|
|
|
it('should replace a degenerate (non-Latin) reply with the safe fallback message', () => {
|
|
expect(sanitizeForSpeech('的问题是什么呢我不知道该怎么办才好呢')).toBe(SPEECH_FALLBACK_REPLY)
|
|
})
|
|
|
|
it('should return the original text when it is a normal French reply', () => {
|
|
expect(sanitizeForSpeech('Bonjour, comment puis-je aider ?')).toBe(
|
|
'Bonjour, comment puis-je aider ?'
|
|
)
|
|
})
|
|
})
|