okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge branch 'f-split-int' into f-split-vision7c5e84612

main
1.4 KiB35 linesraw
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 {
6  const a = job?.activity;
7  if (a?.code === 'line' && a.text) return a.text;
8  if (a?.code === 'trying-version') {
9    const step = typeof a.args?.step === 'string' && a.args.step ? String(a.args.step) : '';
10    return step || tr('Trying an improved version…');
11  }
12  switch (a?.code) {
13    case 'reading-files': return tr('Reading your files…');
14    case 'checking-result': return tr('Checking the result…');
15    case 'comparing': return tr('Comparing the two versions…');
16    default: break;
17  }
18  switch (job?.phase) {
19    case 'generating': return tr('Trying an improved version…');
20    case 'checking': case 'decision': return tr('Checking the result…');
21    default: 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 {
27  switch (phase) {
28    case 'queued': return 0.06;
29    case 'checkpointing': return 0.18;
30    case 'generating': return 0.6;
31    case 'checking': return 0.85;
32    case 'decision': return 0.95;
33    default: return 0.06;
34  }
35}