char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
521a64cd0
char/aliceai-t5-moe
1// Guards the unfolding of `renderContentAsRawText` back onto the two 2// per-surface render keys. The single toggle carried user content and 3// thinking at once, so only the user key is restored from it and thinking 4// returns to its own default. The toggle is removed from the persisted 5// config so it does not stay orphaned in localStorage. 6 7import { CONFIG_LOCALSTORAGE_KEY } from '$lib/constants' ; 8import { MigrationService } from '$lib/services/migration.service' ; 9import { settingsStore } from '$lib/stores/settings/index.svelte' ; 10import { beforeEach , describe , expect , it } from 'vitest' ; 11 12const RENDER_KEYS_MIGRATION_ID = 'render-keys-unfold-v1' ; 13 14async function seedConfig ( stored :Record < string , unknown >) { 15localStorage . setItem ( CONFIG_LOCALSTORAGE_KEY , JSON . stringify ( stored )); 16 17const migration = MigrationService . getMigrations (). find (( m ) => m . id === RENDER_KEYS_MIGRATION_ID ); 18 19await migration ?. run (); 20settingsStore . initialize (); 21} 22 23function persisted () :Record < string , unknown > { 24return JSON . parse ( localStorage . getItem ( CONFIG_LOCALSTORAGE_KEY ) ?? '{}' ); 25} 26 27describe ( 'renderContentAsRawText unfolding' , () => { 28beforeEach (() => { 29localStorage . removeItem ( CONFIG_LOCALSTORAGE_KEY ); 30MigrationService . resetState (); 31settingsStore . initialize (); 32}); 33 34it ( 'maps raw text to user content as plain text' , async () => { 35await seedConfig ({ renderContentAsRawText :true }); 36expect ( settingsStore . config . renderUserContentAsMarkdown ). toBe ( false ); 37}); 38 39it ( 'maps markdown to user content as markdown' , async () => { 40await seedConfig ({ renderContentAsRawText :false }); 41expect ( settingsStore . config . renderUserContentAsMarkdown ). toBe ( true ); 42}); 43 44it ( 'leaves thinking on its own default' , async () => { 45await seedConfig ({ renderContentAsRawText :true }); 46expect ( settingsStore . config . renderThinkingAsMarkdown ). toBe ( true ); 47}); 48 49it ( 'keeps an explicit user preference over the toggle' , async () => { 50await seedConfig ({ renderContentAsRawText :true , renderUserContentAsMarkdown :true }); 51expect ( settingsStore . config . renderUserContentAsMarkdown ). toBe ( true ); 52}); 53 54it ( 'drops the toggle from the persisted config' , async () => { 55await seedConfig ({ renderContentAsRawText :true }); 56expect ( persisted (). renderContentAsRawText ). toBeUndefined (); 57}); 58 59it ( 'leaves both surfaces on markdown when nothing is stored' , async () => { 60await seedConfig ({}); 61expect ( settingsStore . config . renderUserContentAsMarkdown ). toBe ( true ); 62expect ( settingsStore . config . renderThinkingAsMarkdown ). toBe ( true ); 63}); 64});