okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
7c5e84612
main
1import { tr } from './i18n' ; 2import type { TimeSkipJob } from './time-skip' ; 3 4/** What the working view says it is doing: the host's own words (activity.code / text / args.step, notes-split-agent3.md), else from the phase. */ 5export function activityWords ( job :Pick < TimeSkipJob , 'phase' | 'activity' > | undefined ) :string { 6const a = job ?. activity ; 7if ( a ?. code === 'line' && a . text ) return a . text ; 8if ( a ?. code === 'trying-version' ) { 9const step = typeof a . args ?. step === 'string' && a . args . step ?String ( a . args . step ) :'' ; 10return step || tr ( 'Trying an improved version…' ); 11} 12switch ( a ?. code ) { 13case 'reading-files' :return tr ( 'Reading your files…' ); 14case 'checking-result' :return tr ( 'Checking the result…' ); 15case 'comparing' :return tr ( 'Comparing the two versions…' ); 16default :break ; 17} 18switch ( job ?. phase ) { 19case 'generating' :return tr ( 'Trying an improved version…' ); 20case 'checking' :case 'decision' :return tr ( 'Checking the result…' ); 21default :return tr ( 'Reading your files…' ); 22} 23} 24 25/** A rough fraction for the progress line from the phase (the host reports phases, not percentages). */ 26export function phaseFraction ( phase :string | undefined ) :number { 27switch ( phase ) { 28case 'queued' :return 0.06 ; 29case 'checkpointing' :return 0.18 ; 30case 'generating' :return 0.6 ; 31case 'checking' :return 0.85 ; 32case 'decision' :return 0.95 ; 33default :return 0.06 ; 34} 35}