Oregami
Repositories/oxedyne/daimond

oxedyne/daimond/dev/probe_hold.mjs

3.1 KiB, 1 run

created by r2519314175:49, 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// probe_hold.mjs — a picture of where the ◈ is, following the path a person takes.
2import { open, shot } from './harness.mjs';
3
4const s = await open({ name: 'probehold' });
5const { page } = s;
6
7await page.click('#new-diamond-btn', { force: true });
8await page.waitForSelector('.dlg-input', { timeout: 10000 });
9await page.fill('.dlg-input', 'Where is the diamond button');
10await page.click('.dlg-ok', { force: true });
11await page.waitForTimeout(800);
12
13await page.evaluate(async () => {
14 const m = await import('/pkg/oxedyne_daimond.js');
15 const app = new m.DaimondApp('http://127.0.0.1/v1/chat/completions', '', 'none', 4096, '', true);
16 await app.run_tool('file_write', JSON.stringify({ path: 'notes/mine.md', content: '# Mine\nBrought in by me.\n' }));
17});
18
19// What the panel is called where a person would look for it.
20const labels = await page.evaluate(() => ({
21 nav: [...document.querySelectorAll('[data-panel], .panel-tab, .rail-btn')]
22 .map(e => ((e.getAttribute('data-panel') || '') + '=' + (e.textContent || e.getAttribute('title') || '').trim()).slice(0, 40))
23 .filter(x => x.length > 2).slice(0, 14),
24}));
25console.log('panel entry points:', JSON.stringify(labels.nav, null, 1));
26
27// Before a Diamond is opened.
28await page.evaluate(() => DaimondPanels.show('work'));
29await page.waitForTimeout(600);
30await page.fill('.files-filter-input', 'mine');
31await page.waitForTimeout(800);
32for (const row of await page.$$('.files-row')) {
33 const nm = await row.$eval('.files-name', e => e.textContent).catch(() => '');
34 if (nm.includes('mine.md')) { await row.click({ force: true }); break; }
35}
36await page.waitForTimeout(1500);
37const before = await page.evaluate(() => {
38 const b = document.querySelector('[data-act="attach"]');
39 if (!b) return 'no hold button in the DOM at all';
40 const r = b.getBoundingClientRect();
41 return { display: b.style.display, w: Math.round(r.width), h: Math.round(r.height) };
42});
43console.log('with NO Diamond open:', JSON.stringify(before));
44await shot(s, 'hold-file-open-no-diamond');
45
46// Now open the Diamond and look at the same file.
47await page.$$eval('.diamond-box', els => els[0] && els[0].click());
48await page.waitForTimeout(1200);
49await page.evaluate(() => DaimondPanels.show('work'));
50await page.waitForTimeout(600);
51await page.fill('.files-filter-input', 'mine');
52await page.waitForTimeout(800);
53for (const row of await page.$$('.files-row')) {
54 const nm = await row.$eval('.files-name', e => e.textContent).catch(() => '');
55 if (nm.includes('mine.md')) { await row.click({ force: true }); break; }
56}
57await page.waitForTimeout(1500);
58const after = await page.evaluate(() => {
59 const b = document.querySelector('[data-act="attach"]');
60 if (!b) return 'no hold button';
61 const r = b.getBoundingClientRect();
62 // Its neighbours, so the answer can say WHERE on screen it is.
63 const bar = b.parentElement;
64 return {
65 label: b.getAttribute('aria-label'),
66 visible: r.width > 0 && r.height > 0,
67 at: { x: Math.round(r.x), y: Math.round(r.y) },
68 siblings: [...bar.children].map(c => (c.textContent || '').trim().slice(0, 12)),
69 };
70});
71console.log('with the Diamond open:', JSON.stringify(after, null, 1));
72await shot(s, 'hold-file-open-diamond');
73await s.browser.close();