jsdoc typing round, phases 3-4: the clerk (tool/memory.mjs) and the SPA (web/) typed under strict -- row shapes local to their owners (the clerk's five tables in its header; the SPA's response envelopes in the new web/shapes.mjs, the server's shared shapes imported at their use sites: User, LogEvent, JobState, HttpError); the db boundary cast at every .get()/.all(), fail as @returns {never} so guard-narrowing works; web via a second tsconfig (tsconfig.web.json: DOM libs in their own program, node types riding along because shapes.mjs's Provider typedef pulls provider.mjs in), npm run typecheck runs both; every non-annotation delta audited onto a small intended list (COUNT(*) Number() wraps, impossible-path guards, ?? ''/?? undefined null-absorbers, the RewordOp reason fix -- the validator demands it, the reminder-find naming its tag); smoke 110/110 + restart + reminder + repo checks + a zero-console-error browser pass green; the typing round is complete

This commit is contained in:
2026-11-15 19:57:07 +00:00
parent f81b188ce1
commit 8d4a6b91df
22 changed files with 567 additions and 227 deletions
+11 -2
View File
@@ -8,8 +8,11 @@ import { banner } from './chrome.mjs';
import { navigate, render } from './router.mjs';
import { armedButton } from './widgets.mjs';
/** @typedef {import('./shapes.mjs').RunCard} RunCard */
/** @param {?string} arg @param {number} seq @returns {Promise<void>} */
export async function enter(arg, seq) {
const runs = await api('/runs');
/** @type {RunCard[]} */ const runs = await api('/runs');
if (seq !== state.seq) return;
const list = $('run-list');
list.textContent = '';
@@ -17,7 +20,7 @@ export async function enter(arg, seq) {
list.appendChild(el('div', 'hint', 'no runs yet -- start one from a package'));
}
for (const r of runs) {
const mine = state.me && r.owner === state.me.id;
const mine = !!(state.me && r.owner === state.me.id);
const card = el('button', 'card run-card');
// the name carries the content facts plus the ownership garnish;
// started-or-forked rides the meta -- chrome, never model-facing
@@ -31,15 +34,18 @@ export async function enter(arg, seq) {
await renderAdmin(seq);
}
/** @param {RunCard} r @param {boolean} mine @returns {string} */
const ownershipTag = (r, mine) =>
(mine ? ' \u00b7 yours' : r.owner == null ? ' \u00b7 ownerless' : ` \u00b7 ${r.ownerName ?? 'someone'}'s`);
// all times UTC (house rule): unixtime -> "YYYY-MM-DD HH:MM:SS UTC"
/** @param {number} t @returns {string} */
function fmtUnix(t) {
const iso = new Date(Number(t) * 1000).toISOString();
return `${iso.slice(0, 10)} ${iso.slice(11, 19)} UTC`;
}
/** @param {RunCard} r @returns {string} */
function runStateText(r) {
if (r.phase === 'live') return `session open${r.pendingAsk ? ' -- waiting for your answer' : ''}`;
if (r.phase === 'dormant') {
@@ -48,6 +54,7 @@ function runStateText(r) {
}
return 'no sessions';
}
/** @param {RunCard} r @returns {string} */
function runStateClass(r) {
if (r.pendingAsk) return 'attention';
if (r.phase === 'live') return 'ok';
@@ -56,10 +63,12 @@ function runStateClass(r) {
return '';
}
/** @param {number} seq @returns {Promise<void>} */
async function renderAdmin(seq) {
const box = $('admin');
if (!state.me?.superuser) { box.hidden = true; return; }
box.hidden = false;
/** @type {[{ invites: { id: number, kind: string, created_at: string, state: string }[] }, { users: import('../server/shapes.mjs').User[] }]} */
const [inv, us] = await Promise.all([api('/invites'), api('/users')]);
if (seq !== state.seq) return;
const invList = $('invite-list');