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:
HeavyGee
2026-08-03 18:01:17 +08:00
committed by GitHub
co-authored by Cursor
parent cd570adf66
commit 82639c66f8
3 changed files with 17 additions and 5 deletions
+7 -1
View File
@@ -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)
})
}) })
+9 -3
View File
@@ -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]