Oregami
Repositories/oxedyne/daimond

oxedyne/daimond/dev/verify_folddelta.mjs

2.8 KiB, 1 run

created by r2519314175:419, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1// A fold retains its raw delta; the History must let you read it back.
2//
3// This used to type a delta straight into the crystal's own `#fold-delta` box
4// and press Propose. Both are gone: a Diamond has ONE composer, in the chat
5// face, and the crystal carries no input of its own. The property is unchanged
6// -- a fold keeps the words that caused it, and History shows them -- so the
7// fold is now made the way one is actually made, by selecting turns of a chat
8// and folding them into the Diamond.
9//
10// node dev/verify_folddelta.mjs
11//
12// Needs dev/serve.mjs and dev/mockllm.mjs (dev/world.sh N --up gives both).
13import { open, errors, chat } from './harness.mjs';
14
15const MARKER = 'DELTA-MARKER-42: ship the thing';
16const DIAMOND = 'Delta Test';
17const sleep = ms => new Promise(r => setTimeout(r, ms));
18
19const s = await open({ name: 'folddelta' });
20const p = s.page;
21
22// A Diamond for the fold to land in.
23await p.click('#new-diamond-btn', { force: true });
24await p.waitForSelector('.dlg-input', { timeout: 8000 });
25await p.fill('.dlg-input', DIAMOND);
26await p.click('.dlg-ok', { force: true });
27await sleep(1200);
28
29// A chat carrying the marker, so the delta the fold records contains it.
30// Through the harness helper, which knows that a new chat needs its Start
31// pressed and that a visible composer may belong to a Diamond rather than a chat.
32await chat(s, MARKER);
33
34// Select every turn and fold them into the Diamond -- the surviving path, and
35// the one a person uses.
36await p.evaluate(() => {
37 const c = document.getElementById('collapse-btn');
38 if (c && !c.classList.contains('on')) c.click();
39});
40await sleep(400);
41await p.click('#sel-all', { force: true });
42await sleep(200);
43await p.click('#sel-fold', { force: true });
44await p.waitForSelector('.fold-menu', { timeout: 8000 });
45await p.evaluate((name) => {
46 const item = [...document.querySelectorAll('.fold-menu-item')]
47 .find(b => b.textContent.trim() === name);
48 if (item) item.click();
49}, DIAMOND);
50await sleep(4000);
51
52const accept = await p.$('.diff-accept');
53if (accept && !(await accept.isDisabled())) { await accept.click(); await sleep(2000); }
54
55// History, then the fold record's Delta button.
56const hist = await p.$('button.crystal-act:has-text("History")');
57if (hist) { await hist.click(); await sleep(700); }
58const deltaBtn = await p.$('button.crystal-act:has-text("Delta")');
59let shown = '';
60if (deltaBtn) {
61 await deltaBtn.click();
62 await sleep(700);
63 shown = await p.evaluate(() => (document.querySelector('.dlg-pre') || {}).textContent || '');
64}
65
66const ok = !!deltaBtn && shown.indexOf('DELTA-MARKER-42') >= 0;
67console.log('delta button present:', !!deltaBtn);
68console.log('shows the raw delta:', shown.indexOf('DELTA-MARKER-42') >= 0);
69console.log('');
70console.log('FOLD DELTA VIEWABLE:', ok);
71console.log('errors:', errors(s));
72await s.close();
73process.exit(ok ? 0 : 1);