mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix(web): show full voice platform rules in settings preview (#1345)
Settings truncated read-only fixtures to 800 chars so scrolling never revealed the rest. Default preview is now the full document; explicit caps remain for tests. Closes #1341 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
|||||||
truncateUtf8ByteLength,
|
truncateUtf8ByteLength,
|
||||||
utf8ByteLength
|
utf8ByteLength
|
||||||
} from './voicePersonality'
|
} from './voicePersonality'
|
||||||
import { VOICE_PLATFORM_FIXTURES } from './voicePromptLayers'
|
import { VOICE_PLATFORM_FIXTURES, getVoicePlatformFixturesPreview } from './voicePromptLayers'
|
||||||
|
|
||||||
describe('voicePersonality', () => {
|
describe('voicePersonality', () => {
|
||||||
test('parseVoicePersonalityPreferences returns defaults for invalid input', () => {
|
test('parseVoicePersonalityPreferences returns defaults for invalid input', () => {
|
||||||
@@ -78,4 +78,10 @@ describe('voicePersonality', () => {
|
|||||||
const huge = truncateUtf8ByteLength('a'.repeat(50_000), 100)
|
const huge = truncateUtf8ByteLength('a'.repeat(50_000), 100)
|
||||||
expect(utf8ByteLength(huge)).toBeLessThanOrEqual(100)
|
expect(utf8ByteLength(huge)).toBeLessThanOrEqual(100)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('settings fixtures preview returns full platform rules by default', () => {
|
||||||
|
expect(getVoicePlatformFixturesPreview()).toBe(VOICE_PLATFORM_FIXTURES)
|
||||||
|
expect(getVoicePlatformFixturesPreview(40)).toContain('[…]')
|
||||||
|
expect(getVoicePlatformFixturesPreview(40).length).toBeLessThan(VOICE_PLATFORM_FIXTURES.length)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -205,9 +205,15 @@ export function composeVoiceAgentPrompt(
|
|||||||
return prompt
|
return prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Short preview for Settings (fixtures are read-only). */
|
/**
|
||||||
export function getVoicePlatformFixturesPreview(maxChars = 600): string {
|
* Read-only fixtures text for Settings.
|
||||||
|
* Pass a finite maxChars only when deliberately truncating (e.g. tests);
|
||||||
|
* Settings shows the full document in a scrollable panel.
|
||||||
|
*/
|
||||||
|
export function getVoicePlatformFixturesPreview(maxChars?: number): string {
|
||||||
const text = VOICE_PLATFORM_FIXTURES
|
const text = VOICE_PLATFORM_FIXTURES
|
||||||
if (text.length <= maxChars) return text
|
if (maxChars == null || !Number.isFinite(maxChars) || maxChars <= 0 || text.length <= maxChars) {
|
||||||
|
return text
|
||||||
|
}
|
||||||
return `${text.slice(0, maxChars)}\n\n[…]`
|
return `${text.slice(0, maxChars)}\n\n[…]`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ export function VoiceDiagnosticsControls(props: {
|
|||||||
|
|
||||||
const backend = props.voiceBackend ?? 'elevenlabs'
|
const backend = props.voiceBackend ?? 'elevenlabs'
|
||||||
const wireHint = getVoiceWireBudgetHint(backend)
|
const wireHint = getVoiceWireBudgetHint(backend)
|
||||||
const fixturesPreview = useMemo(() => getVoicePlatformFixturesPreview(800), [])
|
const fixturesPreview = useMemo(() => getVoicePlatformFixturesPreview(), [])
|
||||||
const composed = useMemo(
|
const composed = useMemo(
|
||||||
() => resolveComposedVoiceSystemPrompt(prefs, { backend }),
|
() => resolveComposedVoiceSystemPrompt(prefs, { backend }),
|
||||||
[prefs, backend]
|
[prefs, backend]
|
||||||
|
|||||||
Reference in New Issue
Block a user