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
4.1 KiB64 linesraw
1/**
2 * QAGUI-STRIX 11-09 finding 4: "Read pictures" unticked and loaded did not hold across an app restart on a model set up without the picture files:
3 * the box came back ticked and Load fetched the 866 MB picture reader. The off was saved (ui_vision_enabled false), but the page honoured a saved off
4 * only when the picture files were prepared (a guard for the off 0.2.9 saved while the engine had no reader). A choice made with a reader present now
5 * carries a marker (ui_vision_chosen) and holds; an old off without the marker behaves exactly as before.
6 */
7import test from 'node:test';
8import assert from 'node:assert/strict';
9import { readFileSync, writeFileSync } from 'node:fs';
10import { join } from 'node:path';
11import { openingVision } from '../src/lib/pictures-choice.ts';
12import { nativeFixture, finishJob } from './helpers/native-fixture.mjs';
13
14test('the page: an off with the marker holds without the picture files; without the marker nothing changed', () => {
15  assert.equal(openingVision({ visionEnabled: false, visionPrepared: false, visionChosen: true, images: 'off' }), 'no', 'the Strix case');
16  assert.equal(openingVision({ visionEnabled: false, visionPrepared: false, images: 'off' }), 'yes', 'an old off (no marker, no files): on, as before');
17  assert.equal(openingVision({ visionEnabled: false, visionPrepared: false, visionChosen: false, images: 'off' }), 'yes');
18  assert.equal(openingVision({ visionEnabled: false, visionPrepared: true }), 'no', 'off with the files: off, as before');
19  assert.equal(openingVision({ visionEnabled: true, visionPrepared: false, visionChosen: true, images: 'off' }), 'yes', 'on stays on');
20  assert.equal(openingVision({ visionEnabled: true, visionPrepared: true, visionChosen: true, visionDevice: 'cpu' }), 'cpu');
21  assert.equal(openingVision(undefined), 'yes');
22});
23
24test('the host: a load with Read pictures off on a model without picture files saves the off with the marker, and reports it after a restart', async () => {
25  const f = nativeFixture();
26  try {
27    await f.control.refresh();
28    const path = join(f.repo, 'strata-iq2_xs.json');
29    const { vision, ...noFiles } = JSON.parse(readFileSync(path, 'utf8'));
30    assert.ok(vision, 'the fixture had picture files');
31    writeFileSync(path, JSON.stringify(noFiles));                       // set up without the picture files (the Strix model)
32    await f.control.refresh(true);
33    const row = () => f.control.state().installed.models.find(m => m.model === 'iq2_xs');
34    assert.equal(row().visionPrepared, false);
35    assert.equal(row().visionChosen, false, 'no marker before a choice');
36    const off = await finishJob(f.control, f.control.operation('load', { model: 'iq2_xs', vision: 'no' }).id);
37    assert.equal(off.state, 'done', off.error);
38    const saved = JSON.parse(readFileSync(path, 'utf8'));
39    assert.equal(saved.ui_vision_enabled, false);
40    assert.equal(saved.ui_vision_chosen, true, 'the marker is saved with the choice');
41    await f.control.refresh(true);
42    assert.equal(row().visionChosen, true);
43    assert.equal(openingVision(row()), 'no', 'after a restart the box opens unticked');
44  } finally { await f.cleanup(); }
45});
46
47test('the host: a load while the engine has no reader still saves nothing, the marker neither; an old file without the marker reads as before', async () => {
48  const f = nativeFixture();
49  try {
50    await f.control.refresh();
51    const path = join(f.repo, 'strata-iq2_xs.json');
52    const none = await finishJob(f.control, f.control.operation('load', { model: 'iq2_xs', vision: 'no', visionUnavailable: true }).id);
53    assert.equal(none.state, 'done', none.error);
54    const saved = JSON.parse(readFileSync(path, 'utf8'));
55    assert.equal(saved.ui_vision_enabled, undefined);
56    assert.equal(saved.ui_vision_chosen, undefined);
57    const { vision, ...noFiles } = saved;
58    writeFileSync(path, JSON.stringify({ ...noFiles, ui_vision_enabled: false, ui_vision_device: 'yes' }));   // a 0.2.9 file: off, no files, no marker
59    await f.control.refresh(true);
60    const row = f.control.state().installed.models.find(m => m.model === 'iq2_xs');
61    assert.equal(row.visionChosen, false);
62    assert.equal(openingVision(row), 'yes');
63  } finally { await f.cleanup(); }
64});