chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.5.0 Latest 5 packages
0
0
// Every state of the workspace worth a look, each drawn by look.mjs into
// target/look (emptied first), desktop light and phone dark: what to hand
// a fresh reviewer with the house rules. Each state is its name and the
// steps that bring it about from the world in world.mjs, so the picture
// shows what its name says.
//
// node harness/look/states.mjs [name...] `just looks [name...]`
//
// With names, only those, and target/look is left as it is. `states` is
// theirs to import too (hero.mjs draws the hero state in every theme).
import { spawnSync } from 'node:child_process';
import { mkdirSync, readdirSync, readFileSync, rmSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { world } from './world.mjs';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
const out = join(root, 'target/look');
/** A canvas opened from the + menu, by the start of its name. */
const opened = (name) => ['--press', 'n', '--click', `.canvases .menu-item:has-text("${name}")`];
const w = world(JSON.parse(readFileSync(join(root, 'harness/look/tools.json'), 'utf8')));
/** Only these canvases open as tabs, the first on screen. */
const tabs = (...keys) => [
'--set',
`getWorkspace.open=${JSON.stringify(keys.map((key) => w.canvases.find((c) => c.view.key === key)).map((c) => ({ canvas: { ...c.view, tileCount: c.tiles.length } })))}`,
'--set',
`getWorkspace.current=${keys[0]}`
];
export const states = {
// Three tabs, the first on screen.
tabs: [],
// A tab out of sight badged ✦ 2 by an agent's tiles, another dotted by a member's change: on a phone, the dotted one scrolled to.
badges: ['--events', 'badges', '--eval', `document.querySelector('[data-tab="c00000000003"]').scrollIntoView({ inline: 'nearest' })`],
// An agent's tile on the canvas on screen: it glows, and the toast offers Show.
arrival: ['--events', 'arrival'],
// The + menu, every section full.
'canvas-menu': ['--press', 'n'],
// A launcher, searched.
launcher: ['--press', 't', '--type', '.launcher input=post'],
// A launcher unsearched, your atmosphere: your apps (most collections first), the first app's (Bluesky's) entry points, your canvases.
'launcher-apps': ['--press', 't'],
// Bluesky chosen in the launcher: its app page, a tile in the launcher's place.
'app-page': ['--press', 't', '--click', '.launcher [data-launcher-row="mine:bsky.app"] button'],
// A tile's app icon clicked: its app's page, opened right of it.
'tile-app': ['--click', 'article[data-tile="aaaaaaaaaa11"] .app-mark'],
palette: ['--press', 'k'],
// The palette searched for an app's queries.
'palette-apps': ['--press', 'k', '--type', '.palette input=knotless'],
// A stack, its lower tile focused.
stack: ['--press', '2', '--press', 'l'],
// A column zoomed (on a phone a column is the screen's width already).
zoom: ['--desktop', '--light', '--press', 'z'],
overview: ['--press', 'o'],
// A document tile's details: its call, at-uri, DID and NSID, and who added it.
details: ['--click', 'article[data-tile="aaaaaaaaaa14"] summary[aria-label="Details"]'],
// A canvas shared with this person as a viewer.
viewer: ['--press', '3'],
share: ['--press', '2', '--click', '.map .share'],
'long-name': opened('A canvas with'),
'long-handle': [...opened('A canvas with'), '--click', '.map .share'],
'one-tile': opened('Knotless'),
// A canvas with no tiles, its launcher closed.
empty: [...opened('An empty'), '--press', 'Escape'],
// A liked track playing, the mini player showing it: in the tab bar on a desktop, across the foot on a phone.
'now-playing': [...opened('Listening'), '--click', 'article[data-tile] .player .hit:not([disabled]) >> nth=0', '--eval', `new Promise((done) => setTimeout(done, 1500))`],
// Signed out: what HUD is, its sign-in in the header and the hero.
landing: ['--signed-out'],
// The landing's picture (crates/hud-server/hero/): chadtmiller.com's own canvas, nothing of anyone else's, desktop light and dark.
hero: [
...tabs('c00000000010', 'c00000000004'),
'--desktop',
'--light',
'--dark',
// Its photos are full size: drawn once each on screen has come.
'--eval',
`Promise.race([new Promise((done) => setTimeout(done, 20000)), Promise.all([...document.images].filter((i) => { const r = i.getBoundingClientRect(); return r.bottom > 0 && r.top < innerHeight && r.right > 0 && r.left < innerWidth; }).map((i) => i.decode().catch(() => {})))]).then(() => 'drawn')`
],
// The landing's Sign in pressed: the sign-in dialog over it, its logos running past.
'sign-in': ['--signed-out', '--click', 'header button:has-text("Sign in")'],
// The sign-in field typed into, offering who matches.
'sign-in-typed': ['--signed-out', '--click', 'header button:has-text("Sign in")', '--type', '#sign-in-handle=da'],
// The tab bar's account menu, with two other accounts this browser is signed in to.
accounts: [
'--set',
'getWorkspace.accounts=[{"did":"did:plc:fpruhuo22xkm5o7ttr2ktxdo","handle":"danabra.mov"},{"did":"did:plc:ragtjsm2j2vknwkz3zp4oxrd","handle":"pfrazee.com"}]',
'--click',
'details.account summary'
],
// Add account from that menu: the sign-in dialog over the workspace.
'add-account': ['--click', 'details.account summary', '--click', 'details.account .menu-item:has-text("Add account")'],
// Delete your HUD data from that menu: what HUD holds read, the canvases owned listed, the shared ones marked, the handle to type.
'delete-data': [
'--click',
'details.account summary',
'--click',
'details.account .menu-item:has-text("Delete your HUD data")',
'--eval',
`new Promise((done) => { const look = () => (document.querySelector('.delete-data form') ? done('read') : setTimeout(look, 50)); look(); })`
]
};
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
const asked = process.argv.slice(2);
const unknown = asked.filter((name) => !(name in states));
if (unknown.length) {
console.log(`==> no such state: ${unknown.join(', ')}; one of ${Object.keys(states).join(', ')}`);
process.exit(2);
}
if (!asked.length) {
rmSync(out, { recursive: true, force: true });
mkdirSync(out, { recursive: true });
}
let failed = 0;
for (const name of asked.length ? asked : Object.keys(states)) {
const run = spawnSync('node', [join(root, 'harness/look.mjs'), name, ...states[name]], { cwd: root, encoding: 'utf8' });
const said = `${run.stdout}${run.stderr}`.split('\n').filter((line) => line.startsWith('==>') && !line.includes('pictures in'));
for (const line of said) console.log(line.replace('==> ', `==> ${name}: `));
if (run.status !== 0) {
failed++;
console.log(`==> ${name}: failed\n${run.stderr.trim().split('\n').slice(0, 6).join('\n')}`);
}
}
console.log(`==> ${readdirSync(out).length} pictures in ${out}`);
process.exit(failed ? 1 : 0);
}