okami.mom/strata

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

Niko1221Merge main (87dfca0e7) into f-own-int: the 0.2.14 app branch, fixtures and CI fixes, the Qwen4-readiness tools, the shape-engine build scriptsffb3d9b31

main
5.3 KiB63 linesraw
1/**
2 * Settings > About, the update lines:
3 * - QAGUI-STRIX 11-09 finding 2: the first-run card's failed engine update ("A model is running ... then press Continue") stayed under About after
4 *   Continue installed the engine and after restarts (jobs persist in native-jobs.json). A failure a later finished update of the same component
5 *   made right is no longer shown there.
6 * - Lane 3 finding 6 (11-09): after an in-app update the row kept "Update available" until the next manual check. An update that finished after
7 *   the check shown makes About check again, once per update.
8 */
9import test from 'node:test';
10import assert from 'node:assert/strict';
11import { build } from 'esbuild';
12import { readFileSync } from 'node:fs';
13import { fileURLToPath } from 'node:url';
14
15const out = await build({ entryPoints: [fileURLToPath(new URL('../src/lib/native-job-diagnostics.ts', import.meta.url))], bundle: true, format: 'esm', platform: 'node', write: false, logLevel: 'silent' });
16const { currentUpdateFailure, updateFinishedAfter } = await import(`data:text/javascript;base64,${Buffer.from(out.outputFiles[0].text).toString('base64')}`);
17
18const job = (id, kind, state, startedAt, extra = {}) => ({ id, kind, state, startedAt, summary: state, error: state === 'error' ? 'A model is running, so nothing was changed. Unload the model in Models, then press Continue.' : null, result: null, ...extra });
19
20test('the Strix case: a first-run engine failure, then Continue installed the engine: About shows no failure, also after a restart (same records)', () => {
21  const jobs = [job('a', 'update-engine', 'error', '2026-11-09T14:10:00Z'), job('b', 'update-engine', 'done', '2026-11-09T14:10:30Z')];
22  assert.equal(currentUpdateFailure(jobs), undefined);
23  assert.equal(currentUpdateFailure(JSON.parse(JSON.stringify(jobs))), undefined);
24});
25
26test('a failure with no later finished update of the same component is still shown, the last one', () => {
27  const a = job('a', 'update-engine', 'error', '2026-11-09T14:10:00Z');
28  assert.equal(currentUpdateFailure([a])?.id, 'a');
29  assert.equal(currentUpdateFailure([a, job('b', 'update-strata', 'done', '2026-11-09T14:20:00Z')])?.id, 'a', 'another component does not settle it');
30  assert.equal(currentUpdateFailure([a, job('b', 'update-engine', 'running', '2026-11-09T14:20:00Z')])?.id, 'a', 'a running retry does not');
31  assert.equal(currentUpdateFailure([a, job('b', 'update-engine', 'cancelled', '2026-11-09T14:20:00Z')])?.id, 'a', 'a cancelled retry does not');
32  assert.equal(currentUpdateFailure([job('b', 'update-engine', 'done', '2026-11-09T14:00:00Z'), a])?.id, 'a', 'a success before it does not');
33  assert.equal(currentUpdateFailure([a, job('c', 'update-strata', 'error', '2026-11-09T14:30:00Z')])?.id, 'c', 'the last failure');
34  assert.equal(currentUpdateFailure([a, job('d', 'load', 'error', '2026-11-09T14:30:00Z')])?.id, 'a', 'not an update: not here');
35});
36
37test('an interrupted update with no later finished one is still shown in About, with its own words; once a later one finished it is not', async () => {
38  const { INTERRUPTED, jobErrorText } = await import(`data:text/javascript;base64,${Buffer.from(out.outputFiles[0].text).toString('base64')}`);
39  const cut = { ...job('i', 'update-strata', 'error', '2026-11-09T14:10:00Z'), error: INTERRUPTED };
40  const shown = currentUpdateFailure([cut]);
41  assert.equal(shown?.id, 'i');
42  assert.equal(jobErrorText(shown, [cut]), INTERRUPTED);
43  assert.equal(currentUpdateFailure([cut, job('r', 'update-strata', 'running', '2026-11-09T14:20:00Z')])?.id, 'i', 'a retry still running: shown');
44  assert.equal(currentUpdateFailure([cut, job('d', 'update-strata', 'done', '2026-11-09T14:20:00Z')]), undefined, 'settled by a later finished update: not in About (Diagnostics keeps it)');
45});
46
47test('an update that finished after the check shown asks for one new check; none before it, none without a check', () => {
48  const check = '2026-11-09T14:00:00Z';
49  assert.equal(updateFinishedAfter([job('u', 'update-strata', 'done', '2026-11-09T14:05:00Z')], check), 'u');
50  assert.equal(updateFinishedAfter([job('u', 'update-engine', 'done', '2026-11-09T13:55:00Z', { finishedAt: '2026-11-09T14:02:00Z' })], check), 'u', 'finished after the check');
51  assert.equal(updateFinishedAfter([job('u', 'update-engine', 'done', '2026-11-09T13:50:00Z')], check), undefined, 'the check is newer');
52  assert.equal(updateFinishedAfter([job('u', 'update-engine', 'error', '2026-11-09T14:05:00Z')], check), undefined, 'a failed update');
53  assert.equal(updateFinishedAfter([job('u', 'load', 'done', '2026-11-09T14:05:00Z')], check), undefined, 'not an update');
54  assert.equal(updateFinishedAfter([job('u', 'update-engine', 'done', '2026-11-09T14:05:00Z')], undefined), undefined, 'no check shown: nothing (no network on opening Settings)');
55});
56
57test('Settings > About uses both: the failure line and the check again, once per finished update', () => {
58  const src = readFileSync(fileURLToPath(new URL('../src/components/SettingsUpdates.tsx', import.meta.url)), 'utf8');
59  assert.match(src, /currentUpdateFailure\(native\?\.jobs \?\? \[\]\)/);
60  assert.doesNotMatch(src, /j\.state === 'error' && \['update-strata', 'update-engine'\]\.includes\(j\.kind\)\)\.slice\(-1\)/);
61  assert.match(src, /updateFinishedAfter\(native\?\.jobs \?\? \[\], result\?\.checkedAt\)/);
62  assert.match(src, /rechecked\.current !== finished\) \{ rechecked\.current = finished; void check\(\); \}/);
63});