create-pmos 0.351.0 → 0.353.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /* pm/premium-vw-file.js — a file Claude named in a chat panel, read-only in the viewer beside the conversation (PM, 2026-10-20: "Why can't I click the file
2
2
  * and see it on the right panel?"). A press on a path in Claude's words (chat-md.js draws it as button.fpath) opens the file as a tab: markdown as a page,
3
- * any other text file as code. GET /api/doc/locate says which served workspace holds the path and GET /api/doc reads it there, so a path outside every
3
+ * an .html file as the page it is (PM, 2026-10-20: "HTML file didn't render properly"), with Source one press away, and any other text file as code. GET /api/doc/locate says which served workspace holds the path and GET /api/doc reads it there, so a path outside every
4
4
  * workspace PMOS serves is never read: its tab says so quietly. While the tab is open the file is checked every few seconds and drawn again when it
5
5
  * changed, so a file Claude is still writing stays current. Nothing here writes.
6
6
  * openChatFile(path, { session, ws }) -> the tab's pane */
@@ -14,8 +14,21 @@ const OPEN = new Map(); // tab id -> state
14
14
  async function getJson(url) { try { const r = await fetch(url, { credentials: 'same-origin' }); return await r.json(); } catch { return null; } }
15
15
  async function getText(url) { try { const r = await fetch(url, { credentials: 'same-origin' }); return { ok: r.ok, text: await r.text(), kind: r.headers.get('X-Doc-Kind') || 'text' }; } catch { return { ok: false, text: 'The workspace server did not answer.' }; } }
16
16
 
17
- /** The page for one file as HTML. Pure, for Node: f is { name, rel, abs, kind, text, err, why, reason }. */
18
- export function fileHtml(f) {
17
+ /* ── an .html file is drawn as the page it is, in a frame that grants it nothing but its own inline scripts ──
18
+ * The frame's sandbox is allow-scripts WITHOUT allow-same-origin, so the page runs in an opaque origin: it cannot reach this app's document, storage,
19
+ * cookies or API, and its forms, popups and top-level navigation were never granted. The CSP put at the top of the page blocks every network fetch
20
+ * (default-src 'none'; no host in script-src), so a report's toggles and charts work and nothing leaves the machine. A remote font falls back to the
21
+ * system font. The same box the console's document tab uses (tab-doc.js htmlFrame), with scripts on, because a report page is what the PM asked to see.
22
+ * The meta goes right after the doctype, not before it: markup before the doctype puts the page in quirks mode and changes its layout. */
23
+ export const FRAME_CSP = "default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:; script-src 'unsafe-inline'";
24
+ export function framedSrc(text) {
25
+ const t = String(text || ''), meta = `<meta http-equiv="Content-Security-Policy" content="${FRAME_CSP}">`;
26
+ const m = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*<!doctype[^>]*>/i.exec(t);
27
+ return m ? m[0] + meta + t.slice(m[0].length) : meta + t;
28
+ }
29
+ const isHtml = (f) => f.kind === 'html' || /\.html?$/i.test(f.name || '');
30
+ /** The page for one file as HTML. Pure, for Node: f is { name, rel, abs, kind, text, err, why, reason }; view is 'page' (default) or 'source' for an .html file. */
31
+ export function fileHtml(f, view = 'page') {
19
32
  if (!f || f.loading) return '<div class="vwdoc"><p class="vwempty" role="status">Reading the file.</p></div>';
20
33
  if (f.reason) {
21
34
  const head = f.reason === 'outside' ? 'Not in a workspace' : f.reason === 'missing' ? 'No such file' : 'Not opened here';
@@ -31,6 +44,18 @@ export function fileHtml(f) {
31
44
  + `</header><div class="cfb">${body || '<p class="vwmut">The file has no text yet.</p>'}</div>${foot}</article></div>`;
32
45
  }
33
46
  const ext = (/\.([A-Za-z0-9]+)$/.exec(f.name || '') || [])[1] || 'text';
47
+ if (isHtml(f)) {
48
+ const page = view !== 'source';
49
+ const bar = `<div class="vwdt"><div class="vwsg" role="group" aria-label="Show the file as">`
50
+ + `<button type="button" class="vwseg" data-fv="page" aria-pressed="${page}">Page</button><button type="button" class="vwseg" data-fv="source" aria-pressed="${!page}">Source</button></div></div>`;
51
+ if (page) {
52
+ return `<div class="vwdoc vwhtml"><article class="cf vwfile"><header class="cfh"><h1 class="cft">${esc(f.name)}</h1></header>${bar}`
53
+ + `<iframe class="vwframe" sandbox="allow-scripts" referrerpolicy="no-referrer" title="${esc(f.name)}" srcdoc="${esc(framedSrc(f.text))}"></iframe>`
54
+ + `<footer class="cff"><span>Read-only · the page runs offline, with no access to PMOS</span><span class="gap"></span><code>${esc(f.abs || f.rel)}</code></footer></article></div>`;
55
+ }
56
+ return `<div class="vwdoc"><article class="cf vwfile"><header class="cfh"><h1 class="cft">${esc(f.name)}</h1></header>${bar}`
57
+ + `<div class="cfb"><div class="cb" data-lang="${esc(ext)}"><div class="cbh"><span>${esc(ext)}</span></div><pre>${esc(f.text)}</pre></div></div>${foot}</article></div>`;
58
+ }
34
59
  return `<div class="vwdoc"><article class="cf vwfile"><header class="cfh"><h1 class="cft">${esc(f.name)}</h1></header>`
35
60
  + `<div class="cfb"><div class="cb" data-lang="${esc(ext)}"><div class="cbh"><span>${esc(ext)}</span></div><pre>${esc(f.text)}</pre></div></div>${foot}</article></div>`;
36
61
  }
@@ -41,12 +66,14 @@ export function openChatFile(p, ctx = {}) {
41
66
  const where = () => '/api/doc/locate?' + q({ path: p, session: ctx.session, ws: ctx.ws });
42
67
  const id = 'file:' + p;
43
68
  let st = OPEN.get(id);
44
- if (!st) { st = { f: { loading: true, path: p }, sig: '', timer: null }; OPEN.set(id, st); }
45
- const pane = vwOpen({ id, title: base(p), icon: 'doc', render: (el) => { el.innerHTML = fileHtml(st.f); } });
69
+ if (!st) { st = { f: { loading: true, path: p }, sig: '', timer: null, view: 'page' }; OPEN.set(id, st); }
70
+ // Page and Source on an .html file: the press draws the other view; the choice stays while the tab is open
71
+ const wire = (el) => { el.onclick = (e) => { const b = e.target.closest('[data-fv]'); if (!b || b.dataset.fv === st.view) return; st.view = b.dataset.fv; draw(); }; };
72
+ const pane = vwOpen({ id, title: base(p), icon: 'doc', render: (el) => { el.innerHTML = fileHtml(st.f, st.view); wire(el); } });
46
73
  const draw = () => {
47
74
  const el = document.querySelector(`#dOut .obody.vw[data-vw="${CSS.escape(id)}"]`);
48
75
  if (!el) return false;
49
- const y = el.scrollTop; el.innerHTML = fileHtml(st.f); el.scrollTop = y;
76
+ const y = el.scrollTop; el.innerHTML = fileHtml(st.f, st.view); wire(el); el.scrollTop = y;
50
77
  return true;
51
78
  };
52
79
  async function read() {
@@ -192,6 +192,13 @@ a.round{color:inherit;text-decoration:none}
192
192
  .mprog{margin-top:8px}}
193
193
  .rr.done .rt,.rr.done .rs,.rr.done .sug{opacity:.45}
194
194
  .rr.done .rt{text-decoration:line-through}
195
+ /* premium-simple-ui #5: a "What you need to do" row is two lines, the title then "subject · next step", with a chevron. The pin sits beside the chevron. */
196
+ .rr .rs{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:4px}
197
+ .rr .rhd{padding-right:100px!important}
198
+ .rchev{position:absolute;right:14px;top:50%;width:20px;height:20px;margin-top:-10px;fill:none;stroke:var(--ink-3);stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
199
+ .rr .rhd:hover .rchev{stroke:var(--ink)}
200
+ .rr .rpin{right:42px;top:50%;transform:translateY(-50%)}
201
+ @media (max-width:640px){.rr .rs{white-space:normal;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.rr .rhd{padding-right:92px!important}}
195
202
  .rn svg{width:20px;height:20px;color:var(--ok);stroke-width:2.4}
196
203
  .dlg{display:flex;flex-direction:column;overflow:hidden;padding-bottom:22px}
197
204
  .dbody{}
@@ -1628,25 +1635,14 @@ button.dsn:hover{box-shadow:inset 0 0 0 1.5px rgb(79,109,245)}
1628
1635
  .sbtn{position:relative}
1629
1636
  .sbdg{position:absolute;top:-3px;right:-3px;min-width:22px;height:22px;padding:0 6px;border-radius:999px;background:var(--ember);color:rgb(20,22,31);font:600 var(--fs-2) var(--mono);display:grid;place-items:center;pointer-events:none}
1630
1637
  .sbdg[hidden]{display:none}
1631
- .ssl{list-style:none;margin:0;padding:0;display:grid;gap:10px}
1632
- .ssr{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:6px 14px;align-items:start;padding:16px 18px;border-radius:var(--r-in);background:var(--well)}
1633
- .ssd{width:10px;height:10px;border-radius:50%;margin-top:7px;background:var(--ink-3)}
1634
- .ssd.working{background:var(--ok)}.ssd.needs,.ssd.blocked{background:var(--ember)}
1635
- .ssb{min-width:0}.ssb h3{font-size:var(--fs-4);font-weight:600;letter-spacing:-.01em;overflow-wrap:anywhere}
1636
- .ssn{color:var(--ink-2);font-size:var(--t-small);margin-top:2px;overflow-wrap:anywhere}
1637
- .ssm{display:flex;flex-wrap:wrap;gap:2px 14px;margin-top:8px;font:500 var(--fs-2) var(--mono);color:var(--ink-3)}
1638
- .ssr>.cta{height:44px;padding:0 20px}
1639
- .ssc,.ssdone{grid-column:1/-1}
1638
+ .ssc{grid-column:1/-1}
1640
1639
  .ssc{border-top:1px solid var(--hair);padding-top:14px;margin-top:8px;font-size:var(--t-small);color:var(--ink-2)}
1641
1640
  .ssc b{color:var(--ink);font-weight:600}
1642
1641
  .ssx{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}.ssx .cta{height:44px;padding:0 20px}
1643
1642
  .cta.bad{background:var(--bad);color:rgb(255,255,255)}
1644
1643
  @media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .cta.bad{color:rgb(40,12,10)}}
1645
1644
  :root[data-theme="dark"] .cta.bad{color:rgb(40,12,10)}
1646
- .ssdone{color:var(--ok);font-weight:600}
1647
1645
  .ssw{margin:0;padding:12px 16px;border-radius:var(--r-in);background:var(--well);border-left:3px solid var(--ember);color:var(--ink-2)}.ssw b{color:var(--ink);font-weight:600}
1648
- .sse{padding:34px 20px;text-align:center;border-radius:var(--r-in);background:var(--well)}.sse b{display:block;font-size:var(--fs-4);font-weight:600}.sse p{color:var(--ink-2);margin-top:6px;font-size:var(--t-small)}
1649
- @media (max-width:700px){.ssr{grid-template-columns:auto minmax(0,1fr)}.ssr>.cta{grid-column:2}}
1650
1646
 
1651
1647
  /* Issue it on a core document draft (initiative premium-core-doc-issue) */
1652
1648
  .dsiss{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;padding:12px 16px;border-radius:14px;background:color-mix(in oklab,var(--ember) 12%,transparent);margin:0 0 12px;font-size:var(--fs-2)}
@@ -2367,3 +2363,79 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2367
2363
  .ilead{margin:6px 0 14px;font-size:var(--fs-3);font-weight:600;color:var(--ember-ink)}
2368
2364
  .footi{margin-top:28px;display:flex;align-items:center}
2369
2365
  .ifold .foot{margin:0;max-width:90ch}
2366
+ /* ── Sessions beside the chat (initiative premium-session-list): the list, its dots, the chip, the folds ── */
2367
+ .srl{display:none;flex-direction:column;min-height:0;overflow:hidden;border-right:1px solid var(--hair);padding-right:10px}
2368
+ .srl-hd{display:flex;align-items:center;gap:6px;padding:4px 2px 8px 8px}
2369
+ .srl-hd b{flex:1;font-size:var(--fs-3);font-weight:600;white-space:nowrap}
2370
+ .srl-fold,.vfold{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;color:var(--ink-2);flex:none}
2371
+ .srl-fold:hover,.vfold:hover{background:var(--well);color:var(--ink)}
2372
+ .srl-fold svg,.vfold svg{width:16px;height:16px}
2373
+ .vfold{display:none}
2374
+ .srl-list{flex:1;overflow:auto;min-height:0;scrollbar-width:thin}
2375
+ .srl ul{list-style:none;margin:0;padding:0}
2376
+ .srl-gh{display:flex;align-items:center;gap:6px;width:100%;min-height:32px;padding:4px 8px;border-radius:10px;font-size:var(--fs-2);font-weight:600;color:var(--ink-2);margin-top:6px}
2377
+ .srl-gh:hover{background:var(--well)}
2378
+ .srl-gh .chev{width:12px;height:12px;transition:transform .15s}
2379
+ .srl-gh[aria-expanded="false"] .chev{transform:rotate(-90deg)}
2380
+ .srl-gh em{font:500 var(--fs-1) var(--mono);font-style:normal;color:var(--ink-3)}
2381
+ .srl-r{display:flex;align-items:center;gap:8px;width:100%;min-height:32px;padding:4px 8px;border-radius:10px;text-align:left;font-size:var(--fs-2);color:var(--ink);position:relative}
2382
+ .srl-r:hover{background:var(--well)}
2383
+ .srl-r.on{background:var(--solid);color:var(--on-solid)}
2384
+ .srl-ic{width:20px;height:20px;border-radius:6px;display:grid;place-items:center;background:var(--well);color:var(--ink-2);flex:none}
2385
+ .srl-r.on .srl-ic{background:color-mix(in oklab,var(--on-solid) 16%,transparent);color:inherit}
2386
+ .srl-ic svg{width:12px;height:12px}
2387
+ .srl-n{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
2388
+ .srl-r.rd .srl-n{font-weight:600}
2389
+ .srl-h{display:none;font:500 var(--fs-1) var(--mono);color:var(--ink-3);white-space:nowrap}
2390
+ .srl-r:hover .srl-h,.srl-r:focus-visible .srl-h,.srl-r.on .srl-h{display:inline}
2391
+ .srl-r.on .srl-h{color:inherit;opacity:.75}
2392
+ .srl-more{display:block;width:100%;text-align:left;min-height:32px;padding:4px 8px 4px 36px;border-radius:10px;color:var(--ink-3);font-size:var(--fs-2)}
2393
+ .srl-more:hover{background:var(--well);color:var(--ink)}
2394
+ .srl-lg{display:flex;flex-wrap:wrap;gap:4px 12px;padding:8px 8px 0;border-top:1px solid var(--hair);font-size:var(--fs-1);color:var(--ink-3)}
2395
+ .srl-lg span{display:inline-flex;align-items:center;gap:5px}
2396
+ .srl-warn{margin:4px 2px 8px;padding:8px 10px;border-radius:10px;background:var(--spot);font-size:var(--fs-2);color:var(--ink-2)}
2397
+ .srl-warn b{color:var(--ink);font-weight:600}
2398
+ .srl-none{padding:8px;color:var(--ink-3);font-size:var(--fs-2)}
2399
+ .sdot2{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}
2400
+ .sdot2.ready{background:var(--ember)}
2401
+ .sdot2.run{background:var(--ok);animation:spulse 2s infinite}
2402
+ .sdot2.blk{box-shadow:inset 0 0 0 2px var(--ember)}
2403
+ .sdot2.idle{background:transparent}
2404
+ @keyframes spulse{0%{box-shadow:0 0 0 0 color-mix(in oklab,var(--ok) 50%,transparent)}70%{box-shadow:0 0 0 5px transparent}100%{box-shadow:0 0 0 0 transparent}}
2405
+ @media (prefers-reduced-motion:reduce){.sdot2.run{animation:none}}
2406
+ .stease{display:inline-flex;align-items:center;gap:7px;height:36px;padding:0 13px;border-radius:999px;background:var(--well);font-size:var(--fs-2);font-weight:600;color:var(--ink);align-self:center}
2407
+ .stease[hidden]{display:none}
2408
+ .stease em{font-style:normal;font-weight:500;color:var(--ink-2)}
2409
+ .stease:hover{background:var(--b3)}
2410
+ .scard .scs{display:flex;align-items:center;gap:8px;font-size:var(--fs-2);color:var(--ink-2);margin:0 0 4px}
2411
+ .scard .ssx{margin-top:12px}
2412
+ @media (min-width:1000px){
2413
+ .dlg.full.srl-on .dgrid{grid-template-columns:var(--srw,232px) minmax(360px,.75fr) minmax(0,1.25fr);gap:22px}
2414
+ .dlg.full.srl-on .srl{display:flex}
2415
+ .dlg.full.srl-on.srl-min{--srw:52px}
2416
+ .dlg.full.srl-on.vw-min .dgrid{grid-template-columns:var(--srw,232px) minmax(0,1fr) 52px}
2417
+ .dlg.full.vw-min:not(.srl-on) .dgrid{grid-template-columns:minmax(0,1fr) 52px}
2418
+ .dlg.full[data-mode="detail"].srl-on .dgrid{grid-template-columns:var(--srw,232px) minmax(0,1fr)}
2419
+ .dlg.full .vfold{display:grid}
2420
+ .dlg.full.vw-min .p-out{background:transparent;overflow:hidden}
2421
+ .dlg.full.vw-min .p-out>:not(.otop),.dlg.full.vw-min .otop>:not(#vFold){display:none!important}
2422
+ .dlg.full.vw-min .otop{padding:0;background:transparent;justify-content:center}
2423
+ .dlg.full.srl-on #dBody .tt,.dlg.full.srl-on #dBody .ub,.dlg.full.srl-on #dBody .md,.dlg.full.srl-on #dBody .md p,.dlg.full.srl-on #dBody .md li{font-size:var(--fs-2)}
2424
+ .dlg.full.srl-on .stream{gap:12px}
2425
+ .dlg.full.vw-min #dBody{padding-inline:max(0px,calc((100% - 880px) / 2))}
2426
+ .srl-min .srl-hd b,.srl-min .srl-lg,.srl-min .srl-n,.srl-min .srl-h,.srl-min .srl-more,.srl-min .srl-warn,.srl-min .srl-gh>*{display:none!important}
2427
+ .srl-min .srl{padding-right:6px}
2428
+ .srl-min .srl-hd{justify-content:center;padding-left:0}
2429
+ .srl-min .srl-gh{min-height:1px;height:1px;padding:0;margin:8px 6px;background:var(--hair)}
2430
+ .srl-min .srl-r{justify-content:center;padding:6px 0}
2431
+ .srl-min .srl-r .sdot2{position:absolute;top:4px;right:6px;width:7px;height:7px}
2432
+ .srl-min .srl-ic{width:26px;height:26px}
2433
+ }
2434
+ @media (max-width:999px){
2435
+ .dlg.srl-open .srl{display:flex;border-right:0;padding-right:0;grid-column:1/-1}
2436
+ .dlg.srl-open .dgrid>.pane,.dlg.srl-open #dTabs{display:none!important}
2437
+ .dlg.srl-open .srl-r,.dlg.srl-open .srl-gh,.dlg.srl-open .srl-more{min-height:44px;font-size:var(--fs-3)}
2438
+ .dlg.srl-open .srl-h{display:inline}
2439
+ .dlg.srl-open .srl-hd{display:none}
2440
+ .stease{height:44px}
2441
+ }
@@ -71,6 +71,18 @@ function drawHero() {
71
71
 
72
72
  /* ── rows ───────────────────────────────────────────────────────────────────────────────────────────────── */
73
73
  const STAMP = (n) => String(n).padStart(2, '0');
74
+ /* premium-simple-ui #5: a row is two lines, the title and then "subject · next step". A "nothing on record" sentence is left off the row; the
75
+ * "If you skip" line and the whole next step stay in the row's dialog (skipFact). */
76
+ const NEXT_OF = (r) => { const t = String(r.prepared || '').replace(/^Next step: /, ''); return /^No .* is on record\.$/.test(t) ? '' : t; };
77
+ const line2 = (r) => [r.subject, NEXT_OF(r)].filter(Boolean).join(' · ');
78
+ /** The row's own "If you skip" (or "Why now", …) line, as a dialog fact, when the dialog does not already hold it. */
79
+ function skipFact(r) {
80
+ const d = r.dialog;
81
+ if (!r.skip || !d || !Array.isArray(d.facts) || d.items) return r;
82
+ const m = /^([A-Z][a-z]+(?: [a-z]+){0,3}): (.+)$/.exec(r.skip), label = m ? m[1] : 'Note', text = m ? m[2] : r.skip;
83
+ if (d.facts.some(([a, b]) => a === label || b === text)) return r;
84
+ return { ...r, dialog: { ...d, facts: d.facts.concat([[label, text]]) } };
85
+ }
74
86
  const CL_ORDER = 'In the order of Needs you on the console: what cannot wait first, then by impact, urgency and effort.';
75
87
  /** The list the page draws: the console's Needs you once it is read, else the model's records-only rows. */
76
88
  function LIST() {
@@ -93,7 +105,7 @@ function drawRows() {
93
105
  const keys = rows.map((r) => r.key), off = (LS.putOff || []).map((x) => x.key); // a row put off is not done: it leaves both counts and is named below the list
94
106
  const base = (pend ? keys : baseline(keys)).filter((k) => !off.includes(k)), done = base.filter((k) => !keys.includes(k)).length, total = base.length;
95
107
  const order = rows.slice().sort((a, b) => (pinned.has(b.key) - pinned.has(a.key)) || (a.n - b.n));
96
- L.innerHTML = order.map((r, i) => `<div class="rr${i < 3 ? ' lead' : ''}${i === 0 ? ' first' : ''}" data-key="${esc(r.key)}"${linkOf(r) ? ` data-link="${esc(linkOf(r))}"` : ''}><button class="rhd" aria-haspopup="dialog"><span class="rn">${STAMP(i + 1)}</span><span><span class="rt">${esc(r.title)}${i === 0 ? '<em class="tgf">Do this first</em>' : ''}</span><span class="rs">${r.product ? `<b class="pn">${esc(r.product)}</b>` : ''}${esc(r.subject)}</span><span class="sug"><span>${esc(r.prepared)}</span></span>${r.skip ? `<span class="skip">${esc(r.skip)}</span>` : ''}</span></button><button class="rpin" data-pin="${esc(r.key)}" aria-pressed="${pinned.has(r.key)}" aria-label="Pin ${esc(r.title)} to the top" title="Pin to the top"><svg class="i" viewBox="0 0 24 24"><path d="M9 4h6l-1 6 3 3H7l3-3zM12 13v7"/></svg></button></div>`).join('')
108
+ L.innerHTML = order.map((r, i) => `<div class="rr${i < 3 ? ' lead' : ''}${i === 0 ? ' first' : ''}" data-key="${esc(r.key)}"${linkOf(r) ? ` data-link="${esc(linkOf(r))}"` : ''}><button class="rhd" aria-haspopup="dialog"><span class="rn">${STAMP(i + 1)}</span><span><span class="rt">${esc(r.title)}${i === 0 ? '<em class="tgf">Do this first</em>' : ''}</span><span class="rs" title="${esc(line2(r))}">${r.product ? `<b class="pn">${esc(r.product)}</b>` : ''}${esc(line2(r))}</span></span><svg class="rchev" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></button><button class="rpin" data-pin="${esc(r.key)}" aria-pressed="${pinned.has(r.key)}" aria-label="Pin ${esc(r.title)} to the top" title="Pin to the top"><svg class="i" viewBox="0 0 24 24"><path d="M9 4h6l-1 6 3 3H7l3-3zM12 13v7"/></svg></button></div>`).join('')
97
109
  + (LS.more ? `<p class="note">${LS.more} more ${LS.more === 1 ? 'row is' : 'rows are'} not shown here.</p>` : '');
98
110
  if (!$('#ibLine')) $('#calm').insertAdjacentHTML('afterend', '<div id="ibLine"></div>'); // premium-agent-inbox: the agent's results, one count line under the PM's own rows
99
111
  $('#ibLine').innerHTML = inboxLine();
@@ -244,6 +256,7 @@ function consoleDialog(r) {
244
256
  function openRow(r) {
245
257
  if (!r) return;
246
258
  if (!r.dialog) r = { ...r, dialog: r.src ? consoleDialog(r) : plainDialog(r) };
259
+ r = skipFact(r);
247
260
  openR = r; const d = r.dialog;
248
261
  openDlg({ eye: d.eye + ' · real data', title: d.title || r.title, sub: d.sub || r.subject, say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(r), noteKey: r.chatKey || r.key, pane: paneHtml(r), label: d.pane.label }); // a goal row (premium-chat-session U7) opens its own conversation
249
262
  ctaState(r);
@@ -279,8 +292,7 @@ $('#dBody').addEventListener('click', (e) => {
279
292
  $$('#card button').forEach((b) => { b.disabled = true; });
280
293
  startAgent({ ws: w.ws || new URLSearchParams(location.search).get('ws') || undefined, task: 'draft', initiative: w.initiative, what: w.what }).then((res) => {
281
294
  if (!res.ok) { $$('#card button').forEach((b) => { b.disabled = false; }); showErr('Not started: ' + res.error); return; }
282
- delete START[key]; toast('The agent started. It is listed in Agent sessions, and its draft waits for you to read.'); closeDlg();
283
- const bd = $('#sessBdg'); if (bd) { bd.textContent = String((+bd.textContent || 0) + 1); bd.hidden = false; }
295
+ delete START[key]; toast('The agent started. It is listed in Sessions, and its draft waits for you to read.'); closeDlg();
284
296
  });
285
297
  return;
286
298
  }
@@ -0,0 +1,92 @@
1
+ /* pm/session-rail.js — the session list beside the chat (initiative premium-session-list, PRD L2). Pure: no DOM, no fetch, so Node tests it.
2
+ *
3
+ * railModel(rows, goals, { showAll }) → { groups: [{ id, title, rows, hidden }], ready, blocked, working, live, warn }
4
+ * railHtml(model, { sel, shut, folded }) → the list's markup
5
+ * teaser(model) → { dot, text } | null the chip in a normal-size chat dialog
6
+ * menuCount(rows) → how many live sessions need the PM (Ready or Maybe blocked): the ⋯ menu badge
7
+ * loudestRow(model) → the row the menu's Sessions opens on
8
+ *
9
+ * rows are GET /api/sessions rows (origin, automatic, shown, label, name, created, headless); goals is GET /api/briefing-premium/goals.
10
+ * Every word on a row is a record field or the fixed word for its state. Exited sessions are not listed. */
11
+
12
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
13
+ // lib/session-state.js ATTENTION, minus exited: the order rows sort in and the state a folded group stands for
14
+ export const RANK = Object.freeze({ needs: 4, blocked: 3, working: 2, quiet: 1 });
15
+ export const DOT = Object.freeze({ needs: 'ready', blocked: 'blk', working: 'run', quiet: 'idle' });
16
+ export const WORD = Object.freeze({ needs: 'Ready', blocked: 'Maybe blocked', working: 'Running', quiet: 'Idle' });
17
+ const GOAL_LIVE = ['started', 'waiting'];
18
+ export const MANY = 6; // more agents than this working at once earns the soft warning (premium-sessions-warning)
19
+ const GROUPS = [['goals', 'Goals'], ['yours', 'Yours'], ['pmos', 'Started by PMOS']];
20
+
21
+ const keyOf = (origin) => (/^chat:/.test(String(origin || '')) ? String(origin).slice(5) : null);
22
+ const needsYou = (r) => r.state === 'needs' || r.state === 'blocked';
23
+ const kindOf = (r) => (r.headless ? 'run' : /^schedule:/.test(r.origin || '') ? 'clock' : r.goal ? 'goal' : r.key ? 'chat' : r.group === 'pmos' ? 'auto' : 'step');
24
+
25
+ function rowOf(s, goals) {
26
+ const key = keyOf(s.origin), g = key && goals ? goals[key] : null;
27
+ const goal = g && GOAL_LIVE.includes(g.state) ? g : null;
28
+ const state = RANK[s.shown] ? s.shown : 'working'; // an unknown live word is never promoted into a claim (session-state)
29
+ const group = goal ? 'goals' : s.automatic ? 'pmos' : 'yours';
30
+ let hint = WORD[state];
31
+ if (goal && goal.state === 'waiting') hint = 'Asked you';
32
+ else if (goal && state === 'working') hint = 'Round ' + (goal.rounds || 0) + ' of ' + goal.limit;
33
+ else if (state === 'working' && s.label && /\d/.test(s.label)) hint = s.label; // "Bash 2m": the server's word carries the open call
34
+ const r = { id: s.id, key, name: String(s.name || s.id).replace(/^chat:\s*/, ''), state, group, hint, goal, origin: s.origin || null, created: s.created || null, headless: s.headless || null, note: s.note || '', cwd: s.cwd || '', agent: s.agent || '' };
35
+ r.kind = kindOf(r);
36
+ return r;
37
+ }
38
+
39
+ export function railModel(rows, goals = {}, { showAll = false } = {}) {
40
+ const live = (Array.isArray(rows) ? rows : []).filter((s) => s && s.id && s.shown !== 'exited').map((s) => rowOf(s, goals));
41
+ live.sort((a, b) => (RANK[b.state] - RANK[a.state]) || (Date.parse(b.created || '') || 0) - (Date.parse(a.created || '') || 0));
42
+ const groups = GROUPS.map(([id, title]) => {
43
+ const all = live.filter((r) => r.group === id);
44
+ const shown = id === 'pmos' && !showAll ? all.filter(needsYou) : all;
45
+ return { id, title, rows: shown, all: all.length, hidden: all.length - shown.length };
46
+ }).filter((g) => g.all);
47
+ const n = (st) => live.filter((r) => r.state === st).length;
48
+ const working = n('working');
49
+ return { groups, live: live.length, ready: n('needs'), blocked: n('blocked'), working, warn: working > MANY ? working : 0, rows: live };
50
+ }
51
+
52
+ export const menuCount = (rows) => (Array.isArray(rows) ? rows : []).filter((s) => s && (s.shown === 'needs' || s.shown === 'blocked')).length;
53
+
54
+ export function loudestRow(m) { return (m && m.rows && m.rows[0]) || null; }
55
+
56
+ /** The dialog's title when the ⋯ menu's Sessions opens it: what needs the PM first. */
57
+ export function titleOf(m) { return !m || !m.live ? 'No sessions running' : m.ready ? m.ready + ' ready for you' : m.blocked ? m.blocked + ' ' + WORD.blocked.toLowerCase() : m.working ? m.working + ' running' : m.live + (m.live === 1 ? ' session' : ' sessions'); }
58
+
59
+ export function teaser(m) {
60
+ if (!m || !m.live) return null;
61
+ const top = m.rows[0];
62
+ const text = m.ready ? m.ready + ' ready' : m.blocked ? m.blocked + ' ' + WORD.blocked.toLowerCase() : m.working ? m.working + ' running' : m.live + (m.live === 1 ? ' session' : ' sessions');
63
+ return { dot: DOT[top.state], text };
64
+ }
65
+
66
+ const ICON = {
67
+ chat: '<path d="M4 5h16v11H9l-5 4z"/>', goal: '<path d="M5 21V4"/><path d="M5 4h12l-2 4 2 4H5"/>', step: '<path d="M5 12h14"/><path d="M13 6l6 6-6 6"/>',
68
+ auto: '<circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M4.2 4.2l2.1 2.1M17.7 17.7l2.1 2.1M2 12h3M19 12h3M4.2 19.8l2.1-2.1M17.7 6.3l2.1-2.1"/>',
69
+ clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>', run: '<path d="M4 17l6-6-6-6"/><path d="M12 19h8"/>',
70
+ };
71
+ export const icon = (k) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${ICON[k] || ICON.step}</svg>`;
72
+ const CHEV = '<svg class="i chev" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>';
73
+
74
+ export function railHtml(m, { sel = null, shut = [], showAll = false } = {}) {
75
+ if (!m || !m.live) return '<p class="srl-none">No sessions are running. Write in a chat to start one.</p>';
76
+ let h = m.warn ? `<p class="srl-warn" role="status"><b>${m.warn} agents are working at once.</b> Each one is a program running on this computer, so many at once can slow it. Stop the ones you are not watching.</p>` : '';
77
+ for (const g of m.groups) {
78
+ const open = !shut.includes(g.id);
79
+ h += `<section class="srl-g"><button type="button" class="srl-gh" data-sg="${g.id}" aria-expanded="${open}">${CHEV}<span>${esc(g.title)}</span><em>${g.all}</em></button>`;
80
+ if (!open) { h += '</section>'; continue; }
81
+ h += '<ul>' + g.rows.map((r) => `<li><button type="button" class="srl-r${r.id === sel ? ' on' : ''}${r.state === 'needs' ? ' rd' : ''}" data-sid="${esc(r.id)}" aria-current="${r.id === sel}" aria-label="${esc(r.name + ', ' + r.hint)}" title="${esc(r.name + ' · ' + r.hint)}"><i class="sdot2 ${DOT[r.state]}" aria-hidden="true"></i><span class="srl-ic">${icon(r.kind)}</span><span class="srl-n">${esc(r.name)}</span><span class="srl-h">${esc(r.hint)}</span></button></li>`).join('');
82
+ if (g.id === 'pmos' && (g.hidden || showAll)) h += `<li><button type="button" class="srl-more" data-smore="1">${showAll ? 'Hide the ones that need nothing' : g.hidden + ' more working on their own · Show'}</button></li>`;
83
+ h += '</ul></section>';
84
+ }
85
+ return h;
86
+ }
87
+
88
+ /** The facts the viewer shows for a session that is not a chat row: every line a record field. */
89
+ export function factsOf(r) {
90
+ const who = r.group === 'pmos' ? 'Started by PMOS' : r.goal ? 'A goal in your chat' : r.key ? 'Your chat' : 'You started it';
91
+ return [['State', WORD[r.state]], ['Started by', who], ['Started', r.created ? new Date(r.created).toLocaleString() : ''], ['Folder', r.cwd && r.cwd !== '.' ? r.cwd : ''], ['Note', r.note], ['Kind', r.headless ? 'Background run, no terminal' : '']].filter((x) => x[1]);
92
+ }
@@ -6455,6 +6455,27 @@ async function handleRequest(req, res) {
6455
6455
  }
6456
6456
  // End a session and remove it, with an answer. The WebSocket kill/remove messages return nothing,
6457
6457
  // so a refusal or a slow exit left the PM clicking a control that seemed to do nothing.
6458
+ // premium-session-list L5: the session list's panel writes to a session the PM did not start from a chat panel (a Next step, a PMOS run).
6459
+ // A page press only, into a live session that is not a plain shell; `say` types a line with Enter, `keys` a permission option or Esc.
6460
+ if ((p === '/api/session/say' || p === '/api/session/keys') && req.method === 'POST') {
6461
+ let body = {};
6462
+ try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
6463
+ const g = pmGuard.requirePagePress(req, body);
6464
+ if (!g.ok) return json(res, { ok: false, error: g.error }, g.status);
6465
+ const sess = sessions.get(String(body.id || ''));
6466
+ if (!sess || !sess.pty || sess.state === 'exited') return json(res, { ok: false, error: 'That session is not running.' }, 409);
6467
+ if (sess.agent === 'shell') return json(res, { ok: false, error: 'A terminal shell takes input in the console.' }, 409);
6468
+ if (p === '/api/session/say') {
6469
+ const t = String(body.text == null ? '' : body.text).trim();
6470
+ if (!t) return json(res, { ok: false, error: 'Write a message for Claude.' }, 400);
6471
+ if (t.length > 8000) return json(res, { ok: false, error: 'The message is too long (8000 characters at most).' }, 400);
6472
+ return chatSessions.type(sess.id, t) ? json(res, { ok: true, session: sess.id }) : json(res, { ok: false, error: 'The message did not reach the session.' }, 409);
6473
+ }
6474
+ const KEYS = { esc: '\x1b', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9' };
6475
+ const data = Object.prototype.hasOwnProperty.call(KEYS, String(body.press)) ? KEYS[String(body.press)] : null;
6476
+ if (!data) return json(res, { ok: false, error: 'press must be esc or 1 to 9' }, 400);
6477
+ return chatSessions.keys(sess.id, data) ? json(res, { ok: true, session: sess.id }) : json(res, { ok: false, error: 'The key did not reach the session.' }, 409);
6478
+ }
6458
6479
  if (p === '/api/session/remove' && req.method === 'POST') {
6459
6480
  let body = {};
6460
6481
  try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
@@ -56,6 +56,7 @@
56
56
  "briefing-premium-sources.test.js",
57
57
  "briefing-premium-drafts.test.js",
58
58
  "agent-inbox.test.js",
59
+ "session-rail.test.js",
59
60
  "briefing-premium-metrics.test.js",
60
61
  "premium-welcome.test.js",
61
62
  "calendar-events.test.js",
@@ -232,6 +233,7 @@
232
233
  "briefing-premium-sources.test.js": 1,
233
234
  "briefing-premium-drafts.test.js": 1,
234
235
  "agent-inbox.test.js": 1,
236
+ "session-rail.test.js": 1,
235
237
  "briefing-premium-metrics.test.js": 1,
236
238
  "premium-welcome.test.js": 1,
237
239
  "calendar-events.test.js": 1,
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Bug 2026-10-20 (\"HTML file didn't render properly\"): an .html file Claude names in a premium chat panel opens in the viewer as the page, sandboxed to its own inline scripts with no network, with Page and Source on its bar.",
3
+ "panels": [
4
+ "premium-html-viewer-test.js"
5
+ ],
6
+ "seconds": {
7
+ "premium-html-viewer-test.js": 25
8
+ }
9
+ }