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. |
| 2 | import { open, shot } from './harness.mjs'; |
| 3 | |
| 4 | const s = await open({ name: 'probehold' }); |
| 5 | const { page } = s; |
| 6 | |
| 7 | await page.click('#new-diamond-btn', { force: true }); |
| 8 | await page.waitForSelector('.dlg-input', { timeout: 10000 }); |
| 9 | await page.fill('.dlg-input', 'Where is the diamond button'); |
| 10 | await page.click('.dlg-ok', { force: true }); |
| 11 | await page.waitForTimeout(800); |
| 12 | |
| 13 | await 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. |
| 20 | const 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 | })); |
| 25 | console.log('panel entry points:', JSON.stringify(labels.nav, null, 1)); |
| 26 | |
| 27 | // Before a Diamond is opened. |
| 28 | await page.evaluate(() => DaimondPanels.show('work')); |
| 29 | await page.waitForTimeout(600); |
| 30 | await page.fill('.files-filter-input', 'mine'); |
| 31 | await page.waitForTimeout(800); |
| 32 | for (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 | } |
| 36 | await page.waitForTimeout(1500); |
| 37 | const 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 | }); |
| 43 | console.log('with NO Diamond open:', JSON.stringify(before)); |
| 44 | await shot(s, 'hold-file-open-no-diamond'); |
| 45 | |
| 46 | // Now open the Diamond and look at the same file. |
| 47 | await page.$$eval('.diamond-box', els => els[0] && els[0].click()); |
| 48 | await page.waitForTimeout(1200); |
| 49 | await page.evaluate(() => DaimondPanels.show('work')); |
| 50 | await page.waitForTimeout(600); |
| 51 | await page.fill('.files-filter-input', 'mine'); |
| 52 | await page.waitForTimeout(800); |
| 53 | for (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 | } |
| 57 | await page.waitForTimeout(1500); |
| 58 | const 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 | }); |
| 71 | console.log('with the Diamond open:', JSON.stringify(after, null, 1)); |
| 72 | await shot(s, 'hold-file-open-diamond'); |
| 73 | await s.browser.close(); |