okami.mom/strata

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

Niko1221rc1 merge gui-fb2 (35d4781f1): two files conflicted (apps/host/server/native-control.mjs, apps/host/src/components/NativeModels.tsx), resolved at token level; images/visionPrepared take both the DeepSeek tower check and picturesMissinga2f602398

main
4.7 KiB60 linesraw
1/** Owner round 7: live numbers in chat, a steady status line, the subagents counts on the title row, plain Privacy, a round arrow instead of "Latest". */
2import test from 'node:test';
3import assert from 'node:assert/strict';
4import { readFile } from 'node:fs/promises';
5import { build } from 'esbuild';
6import { fileURLToPath } from 'node:url';
7
8const src = f => fileURLToPath(new URL(`../src/${f}`, import.meta.url));
9const read = f => readFile(src(f), 'utf8');
10async function load(file) {
11  const result = await build({ entryPoints: [src(`lib/${file}`)], bundle: true, format: 'esm', platform: 'node', write: false, alias: { react: fileURLToPath(new URL('./helpers/react-stub.mjs', import.meta.url)) }, logLevel: 'silent', loader: { '.json': 'json' } });
12  return import(`data:text/javascript;base64,${Buffer.from(result.outputFiles[0].text).toString('base64')}`);
13}
14globalThis.window ??= globalThis; globalThis.localStorage ??= { getItem: () => null, setItem: () => {} };
15globalThis.navigator ??= { language: 'en' };
16const { tweenValue, easeOutCubic } = await load('tween.ts');
17const { chatMetrics } = await load('chat-metrics.ts');
18
19test('item 5: a number travels between two readings in a short ease-out, never past them', () => {
20  assert.equal(tweenValue(40, 50, 0, 600), 40);
21  assert.equal(tweenValue(40, 50, 600, 600), 50);
22  assert.ok(tweenValue(40, 50, 150, 600) > 40 && tweenValue(40, 50, 150, 600) < 50);
23  assert.ok(tweenValue(50, 40, 150, 600) < 50 && tweenValue(50, 40, 150, 600) > 40, 'down as well as up');
24  assert.equal(tweenValue(NaN, 7, 100, 600), 7); assert.equal(tweenValue(1, 2, 0, 0), 2);
25  assert.ok(easeOutCubic(0.5) > 0.5, 'fast at first, settling at the end');
26});
27
28const reply = (extra = {}) => ({ role: 'assistant', at: new Date(1_000_000).toISOString(), content: 'x', ...extra });
29test('item 5: during a goal the chat follows the Monitor even though the engine names another session', () => {
30  const session = { id: 'chat-a', statsAvailable: true, tokensIn: 5000, tokensOut: 400, messages: [{ role: 'user', content: 'goal' }, reply({ inputTokens: 5000, tokens: 400, tps: 41, contextMax: 65536, durationMs: 9000, reasoningMs: 3000 }), reply({ streaming: true, tokens: 120, inputTokens: 5200, reasoningStartedAt: 1_070_000 })] };
31  const monitor = { phase: 'generating', outputTps: 47.4, context: { sessionId: 'harness-xyz', usedTokens: 9100, maxTokens: 65536 } };
32  const m = chatMetrics(session, monitor, 65536, 1_100_000);
33  assert.equal(m.speed, 47.4, 'the live speed comes from the Monitor');
34  assert.equal(m.used, 9100, 'and so does the context in use');
35  assert.equal(m.llmMs, 9000 + 100_000, 'a reply being written counts its running time');
36  assert.equal(m.thinkMs, 3000 + 30_000);
37  assert.equal(m.writeMs, 9000 + 100_000 - 33_000);
38  assert.equal(m.total, 5000 + 400 + 120 + 5200);
39  // an idle engine does not move a finished chat's numbers
40  const idle = chatMetrics({ ...session, messages: session.messages.slice(0, 2) }, { phase: 'idle', outputTps: 0, context: { sessionId: 'harness-xyz', usedTokens: 1, maxTokens: 2 } }, 65536, 1_100_000);
41  assert.equal(idle.speed, 41); assert.notEqual(idle.used, 1);
42});
43
44test('item 10 / GUI-FB2 item 7: the status line is a wrapping flex row with no fixed widths, so a long time or count never runs into its neighbour', async () => {
45  const css = await read('styles/app.css'), line = await read('components/StatusLine.tsx');
46  assert.match(css, /\.live-status \{ display: flex; flex-wrap: wrap;/);
47  assert.doesNotMatch(css, /\.live-status \{[^}]*grid-template-columns/);
48  assert.doesNotMatch(css, /\.live-status[^{]*\{[^}]*\b6ch\b/, 'no fixed column for the time');
49  assert.match(css, /\.live-status__verb \{ flex: 0 1 24ch; min-width: 0;/, 'the word gives way first');
50  assert.match(css, /\.live-status__time, \.live-status__tokens \{ flex: none; font-variant-numeric: tabular-nums/);
51  assert.match(line, /live-status__verb/); assert.match(line, /live-status__time/); assert.match(line, /live-status__tokens/);
52});
53
54test('items 15, 16, 17: counts on the Subagents title row, Privacy as plain text, a round arrow', async () => {
55  const bar = await read('components/ChatToolbar.tsx'), pop = await read('components/Popover.tsx'), privacy = await read('components/PrivacyNotes.tsx'), chat = await read('screens/Chat.tsx');
56  assert.match(bar, /title=\{tr\(session\?\.agents\?\.length \? "Subagents" : "No subagents recorded"\)\} detail=\{/); assert.ok(!/subagents-overview-summary/.test(bar), 'no second line of counts');
57  assert.match(pop, /telepop__detail/);
58  assert.ok(!/Icon/.test(privacy), 'no icons in Privacy');
59  assert.ok(!/>\{tr\("Latest"\)\}</.test(chat) && (chat.match(/aria-label=\{tr\("Scroll to the latest message"\)\}/g) ?? []).length === 2, 'the Latest button is a round arrow');
60});