oxedyne/daimond/dev/shot_guide_workspace.mjs
2.7 KiB, 1 run
created by r2519314175:157, 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 | // shot_guide_workspace.mjs — regenerate the guide's Workspace screenshot. |
| 2 | // |
| 3 | // The guide now describes three chips and a file that lives in cloud storage |
| 4 | // rather than on this device, so the picture beside that prose has to show them. |
| 5 | // The old shot predates all of it: it showed "OPFS (sandbox)" and a single |
| 6 | // "Open a folder…" button, and sat directly above text describing something |
| 7 | // else. A screenshot that contradicts its own caption is worse than none. |
| 8 | // |
| 9 | // Needs dev/serve.mjs and a gateway on :9002 — the cloud-only row is real |
| 10 | // rather than staged: a file is genuinely offloaded, then freed. |
| 11 | import { open, signInAs } from './harness.mjs'; |
| 12 | import path from 'node:path'; |
| 13 | |
| 14 | const OUT = path.join(process.cwd(), 'www', 'guide', 'shots'); |
| 15 | |
| 16 | const s = await open({ name: 'Alex', connect: false, signIn: true }); |
| 17 | const p = s.page; |
| 18 | await p.waitForFunction( |
| 19 | () => !!window.DaimondCloud && !!window.DaimondCore && !!window.DaimondSync, |
| 20 | null, { timeout: 15000 }, |
| 21 | ).catch(() => {}); |
| 22 | |
| 23 | // A small workspace showing every residency at once: ordinary files, one pinned |
| 24 | // to the device, and one that lives in cloud storage alone. |
| 25 | await p.evaluate(async () => { |
| 26 | const mod = await import('../pkg/oxedyne_daimond.js'); |
| 27 | const app = new mod.DaimondApp('http://127.0.0.1/v1/chat/completions', '', 'none', 256, '', true); |
| 28 | const bulk = (n) => { let b = ''; while (b.length < n) b += 'the draft continues, at length, for some pages. '; return b; }; |
| 29 | await app.run_tool('file_write', JSON.stringify({ path: 'notes.md', content: '# Notes\n\nA short file.\n' })); |
| 30 | await app.run_tool('file_write', JSON.stringify({ path: 'proposal.typ', content: bulk(3 * 1024) })); |
| 31 | await app.run_tool('file_write', JSON.stringify({ path: 'interviews.txt', content: bulk(300 * 1024) })); |
| 32 | await app.run_tool('file_write', JSON.stringify({ path: 'report-draft.txt', content: bulk(200 * 1024) })); |
| 33 | await window.DaimondSync.push(); |
| 34 | window.DaimondCloud.pin('report-draft.txt', true); |
| 35 | await window.DaimondCloud.evict('interviews.txt'); |
| 36 | }); |
| 37 | |
| 38 | await p.evaluate(() => { try { DaimondPanels.open('work'); } catch (e) { /* already open */ } }); |
| 39 | await p.waitForTimeout(700); |
| 40 | await p.click('#panel-work [data-act="refresh"]').catch(() => {}); |
| 41 | await p.waitForTimeout(1400); |
| 42 | |
| 43 | const clip = await p.evaluate(() => { |
| 44 | const el = document.querySelector('#panel-work'); |
| 45 | if (!el) return null; |
| 46 | const r = el.getBoundingClientRect(); |
| 47 | // The head and the tree; not the empty tail of a tall panel. |
| 48 | return { x: Math.round(r.x), y: Math.round(r.y), width: Math.round(r.width), height: 340 }; |
| 49 | }); |
| 50 | if (!clip) { |
| 51 | console.log(' SKIP — the Workspace panel is not on screen'); |
| 52 | } else { |
| 53 | await p.screenshot({ path: path.join(OUT, 'workspace.png'), clip }); |
| 54 | console.log(` wrote workspace.png (${clip.width}x${clip.height})`); |
| 55 | } |
| 56 | await s.browser.close(); |