okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
334dde73a
main
1/** The newest line of the model's reasoning, trimmed for one compact row (while it is still reasoning, the row shows what it is thinking about). */ 2export function lastReasoningLine ( text :string | undefined , max = 110 ) :string { 3const lines = String ( text ?? '' ). split ( / \r?\n / ). map ( l => l . replace ( / ^[\s>*#\-•\d.]+ / , '' ). replace ( / [*_`] / g , '' ). trim ()). filter ( Boolean ); 4const line = lines . at ( - 1 ) ?? '' ; 5return line . length > max ?` ${ line . slice ( 0 , max - 1 )} …` :line ; 6} 7 8/** "38s", "1m 04s": how long the model reasoned. null when it is too short to be worth saying. */ 9export function thoughtDuration ( ms :number | undefined ) :string | null { 10if ( typeof ms !== 'number' || ! Number . isFinite ( ms ) || ms < 1000 ) return null ; 11const total = Math . round ( ms / 1000 ); 12return total < 60 ?` ${ total } s` :` ${ Math . floor ( total / 60 )} m ${ String ( total % 60 ). padStart ( 2 , '0' )} s` ; 13} 14 15/** Is a scrolling box at its bottom (within a few pixels)? Reasoning sticks to the bottom only while the person has not scrolled up. */ 16export function atBottom ( el :{ scrollHeight :number ; scrollTop :number ; clientHeight :number }, slack = 24 ) :boolean { 17return el . scrollHeight - el . scrollTop - el . clientHeight <= slack ; 18}