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,
|
||||
utf8ByteLength
|
||||
} from './voicePersonality'
|
||||
import { VOICE_PLATFORM_FIXTURES } from './voicePromptLayers'
|
||||
import { VOICE_PLATFORM_FIXTURES, getVoicePlatformFixturesPreview } from './voicePromptLayers'
|
||||
|
||||
describe('voicePersonality', () => {
|
||||
test('parseVoicePersonalityPreferences returns defaults for invalid input', () => {
|
||||
@@ -78,4 +78,10 @@ describe('voicePersonality', () => {
|
||||
const huge = truncateUtf8ByteLength('a'.repeat(50_000), 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
|
||||
}
|
||||
|
||||
/** 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
|
||||
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[…]`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user