From 560360d2e314a8598bb261bb678adb5b5e55241b Mon Sep 17 00:00:00 2001 From: iris Date: Mon, 25 May 2026 01:50:06 +0200 Subject: [PATCH] dashboard: extract shared helpers into common.js (#406 step 1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First slice of the app.js split (#406). Pure utility / infrastructure code that both /index.html and /flow.html use lifts out of the IIFE into a sibling ES module: - DOM helpers: `$`, `el`, `esc`, `form`, `fmtAgeSecs` - Side-panel singleton (`Panel.open` / `openNamed` / `refresh` / `close` / `bind`). The `ensure()` lazy-init makes it tolerate being imported before the DOM element exists — `bind()` still needs to be called once the host page is ready. - Path linkification + file-preview side panel: `appendLinkified`, `appendText`, `makePathLink`, plus the internal `openFilePanel` + `fetchStateFile` + `mdNode` / `svgImage` / `buildTabbedPreview` it depends on. - Browser-notification module `NOTIF` (`bind`, `show`, `renderControls`). `app.js` now imports these from `./common.js` and the duplicated definitions are gone. Each removal is replaced by a one-line breadcrumb comment so a reader chasing a name from the bundled output can find where it landed. `truncate`, `fmtAgo`, `fmtElapsed`, `fmtDuration` stay in app.js for now — each has caller-specific phrasing ("X running", "X ago") that doesn't generalise cleanly. Lift them when a second consumer needs the same shape. ## Next steps (separate PRs) - Step 2: split app.js into `tabs.js` (entry for /index.html — tab renderers + tab routing + refreshState) and `flow.js` (entry for /flow.html — broker terminal + inbox derived store + compose), both importing from common.js. Updates `build.mjs` for multiple entry points and switches each HTML file's `