create-pmos 0.389.0 → 0.390.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,7 +1,9 @@
1
1
  /* pm/premium-vw-doc.js — a markdown document as a page in the premium viewer (initiative premium-viewer, S2; planning/prd/premium-viewer-prd.md R2).
2
2
  * One document, one page: read it, edit it in place (or as Markdown), and see an agent's proposed change applied and highlighted, with one Keep and one
3
3
  * Undo all. Built on the viewer frame (premium-viewer.js) and the existing /api/doc-sheet routes: log and at to read, edit to save, proposals, accept and
4
- * reject for an agent's edit, ask to request one. Nothing here is stored anywhere else. The pure half is premium-vw-doc-model.js. */
4
+ * reject for an agent's edit, ask to request one. Nothing here is stored anywhere else. The pure half is premium-vw-doc-model.js.
5
+ * ctx.host (an element) draws the page editor inside it instead of a viewer tab (the report dialog's Edit, PM 2026-10-22: one place to edit a
6
+ * report). It opens in Edit, offers only Edit and Markdown, and Cancel or a save calls ctx.onClose. No Health, Links, Copies, extras or Ask. */
5
7
  import { pmPost } from './http.js';
6
8
  import { vwOpen, vwStyle, vwConfirm } from './premium-viewer.js';
7
9
  import { $, $$, esc, toast, AI, CHECK } from './premium-shell.js';
@@ -79,6 +81,7 @@ const tb = (c, label, icon) => `<button type="button" class="vwtb" data-c="${c}"
79
81
  export function openDocPage(d, ctx = {}) {
80
82
  if (!d || !d.path) return null;
81
83
  vwStyle('doc');
84
+ if (ctx.host) return makePage(d, ctx);
82
85
  const id = 'doc:' + d.path, prior = OPEN.get(id);
83
86
  if (prior) return prior.show(ctx); // the same document opened again: show its tab and read it again; what is typed and not saved stays
84
87
  return makePage(d, ctx);
@@ -104,6 +107,7 @@ function makePage(d, ctx) {
104
107
  const at = revs.length ? await getJson('/api/doc-sheet/at?path=' + p + '&rev=' + revs[revs.length - 1].rev + wsq()) : null;
105
108
  if (at && at.ok) P.text = at.text; else { P.text = null; P.err = (at && at.error) || (lg && lg.error) || 'The file could not be read.'; }
106
109
  P.kept = null; draw();
110
+ if (ctx.host) return;
107
111
  loadHealth(); loadCopies(); if (P.more === 'links') loadLib();
108
112
  }
109
113
  /* ── Health, Links and Copies: the sheet's own reads (POST /api/doc-health/check, GET /api/docs/library, GET /api/docs), drawn under the bar ── */
@@ -196,6 +200,7 @@ function makePage(d, ctx) {
196
200
  function toolsHtml(p) {
197
201
  const lock = p ? ' disabled title="Keep or undo the agent\'s edit first"' : '';
198
202
  const seg = (m, label, icon) => `<button type="button" class="vwseg" data-vd="mode:${m}" aria-pressed="${P.mode === m}"${m !== 'read' ? lock : ''}>${IC[icon]}${label}</button>`;
203
+ if (ctx.host) return `<div class="vwdt" role="toolbar" aria-label="Document"><span class="vwsg">${seg('edit', 'Edit', 'pen')}${seg('md', 'Markdown', 'md')}</span></div>`;
199
204
  return `<div class="vwdt" role="toolbar" aria-label="Document"><span class="vwsg">${seg('read', 'Page', 'doc')}${seg('edit', 'Edit', 'pen')}${seg('md', 'Markdown', 'md')}</span><span class="gap"></span>`
200
205
  + (P.mode === 'read' ? extrasHtml() : '')
201
206
  + (P.mode === 'read' && !p ? `<button type="button" class="vwbtn" data-vd="askt" aria-expanded="${P.askOpen}">${AI}Ask the agent</button>` : '') + '</div>'
@@ -354,6 +359,7 @@ function makePage(d, ctx) {
354
359
  if (k === 'back') cur.delete(arg); else cur.add(arg);
355
360
  P.kept = o.live.filter((n) => cur.has(n)); draw(); return;
356
361
  }
362
+ if (k === 'cancel' && ctx.host) { if (ctx.onClose) ctx.onClose(); return; }
357
363
  if (k === 'cancel') { P.mode = 'read'; P.work = null; P.base = null; P.why = ''; P.msg = ''; draw(); return; }
358
364
  if (k === 'save') {
359
365
  const why = ($('#vwWhy', el) || {}).value || '';
@@ -365,6 +371,7 @@ function makePage(d, ctx) {
365
371
  if (!res || res.ok !== true) return fail((res && res.error) || 'The document could not be saved.');
366
372
  toast(`Saved as v${v() + 1}. The reason is in the Edit log.`);
367
373
  P.busy = false; P.mode = 'read'; P.base = null; P.work = null; P.why = '';
374
+ if (ctx.host) { if (ctx.onWrite) await ctx.onWrite(); if (ctx.onClose) ctx.onClose(); return; }
368
375
  await load(); if (ctx.onWrite) ctx.onWrite(); return;
369
376
  }
370
377
  if (k === 'ask') {
@@ -468,6 +475,7 @@ function makePage(d, ctx) {
468
475
  pane.addEventListener('mouseup', () => { if (P.mode === 'edit') setTimeout(syncBar, 0); });
469
476
  }
470
477
 
478
+ if (ctx.host) { P.mode = 'edit'; el = ctx.host; el.innerHTML = '<p class="vwempty">Reading the file.</p>'; if (!WIRED.has(el)) { WIRED.add(el); wire(el); } load(); return el; }
471
479
  const spec = { id, title: d.title || String(d.path).split('/').pop(), icon: 'doc', render(e) { el = e; draw(); }, wire(e) { if (WIRED.has(e)) return; WIRED.add(e); wire(e); } };
472
480
  const api = { show(c2) { if (!el || !el.isConnected) { OPEN.delete(id); return makePage(d, c2 || ctx); } if (c2) ctx = c2; el = vwOpen(spec) || el; if (P.mode === 'read') load(); return el; } };
473
481
  OPEN.set(id, api);
@@ -43,7 +43,7 @@
43
43
  .rt-secs span{font-size:var(--fs-2);color:var(--ink-3)}
44
44
  .rt-frame{width:100%;aspect-ratio:16/10;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid,var(--card))}
45
45
  .rt-cyc{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:6px}
46
- .rt-cyc li{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-height:44px;padding:4px 4px 4px 10px;border:1px solid var(--hair);border-radius:8px}
46
+ .rt-cyc li{position:relative;display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-height:44px;padding:4px 4px 4px 10px;border:1px solid var(--hair);border-radius:8px}
47
47
  .rt-slot{flex:1;min-width:0;font-size:var(--fs-3);color:var(--ink)}
48
48
  .rt-tag{padding:2px 8px;border-radius:6px;font:500 var(--fs-1) var(--mono);text-transform:uppercase}
49
49
  .rt-tag.draft{background:var(--well);color:var(--ink-2)}
@@ -3,7 +3,9 @@
3
3
  * (pm/premium-deck.js has the format): the editor reads it through GET /api/doc and saves it through POST /api/doc-sheet/edit, which keeps a
4
4
  * revision with the PM's why. Nothing else is stored.
5
5
  *
6
- * openSlides({ ws, path, title, readOnly, onSaved }) opens the file as a Slides tab beside the dialog's own detail
6
+ * openSlides({ ws, path, title, readOnly, onSaved, host, onClose }) opens the file as a Slides tab beside the dialog's own detail. With host
7
+ * (an element), the editor is drawn inside it instead (the report dialog's Edit, PM 2026-10-22: one place to edit a report), with a Cancel
8
+ * that calls onClose, and a save that calls onSaved then onClose. Present stays: it is the presenter view, with the notes.
7
9
  *
8
10
  * On the slide: click to select, drag to move (centre guides), the corner handles to resize, double-click to type. The rail reorders by drag
9
11
  * (or Move up and Move down), adds a slide from a layout, duplicates and deletes. Undo and redo cover every change. Present opens the presenter
@@ -145,12 +147,13 @@ export function present(deck, ws, start, opt = {}) {
145
147
  /* ── the editor ── */
146
148
  const OPEN = new Map(); // path -> editor state, so the test hook can read it
147
149
 
148
- export async function openSlides({ ws, path, title, readOnly, onSaved } = {}) {
150
+ export async function openSlides({ ws, path, title, readOnly, onSaved, host, onClose } = {}) {
149
151
  if (!path) return null;
150
152
  vwStyle('slides');
151
- const S = { ws: ws || '', path, title: title || String(path).split('/').pop(), ro: !!readOnly, onSaved, text: null, deck: null, i: 0, sel: null, editing: null, drag: null, hist: [], fut: [], dirty: false, msg: '', busy: false, pop: null, root: null };
153
+ const S = { ws: ws || '', path, title: title || String(path).split('/').pop(), ro: !!readOnly, onSaved, onClose: host ? onClose : null, text: null, deck: null, i: 0, sel: null, editing: null, drag: null, hist: [], fut: [], dirty: false, msg: '', busy: false, pop: null, root: null };
152
154
  OPEN.set(path, S);
153
- const el = vwOpen({ id: 'slides:' + path, title: S.title + ' slides', icon: 'doc', html: '<p class="note">Reading the slides.</p>' });
155
+ const el = host || vwOpen({ id: 'slides:' + path, title: S.title + ' slides', icon: 'doc', html: '<p class="note">Reading the slides.</p>' });
156
+ if (host) host.innerHTML = '<p class="note">Reading the slides.</p>';
154
157
  S.root = el;
155
158
  try {
156
159
  const r = await fetch('/api/doc?' + new URLSearchParams({ ...(S.ws ? { ws: S.ws } : {}), path }).toString(), { credentials: 'same-origin' });
@@ -175,7 +178,7 @@ function build(S) {
175
178
  el.innerHTML = `<div class="sl${ro ? ' ro' : ''}" data-sl>`
176
179
  + `<div class="sl-tb" role="toolbar" aria-label="Slides">`
177
180
  + (ro ? '' : `${tb('undo', 'Undo', 'undo', ' disabled')}${tb('redo', 'Redo', 'redo', ' disabled')}<span class="sl-sep"></span>${tbl('text', 'Text', 'txt')}${tbl('img', 'Image', 'img')}${tbl('chart', 'Chart', 'chart')}${tbl('table', 'Table', 'tbl')}${tbl('shape', 'Shape', 'shape')}<span class="sl-sep"></span>${tbl('layout', 'Layout', 'lay', ' aria-haspopup="menu"')}${tbl('theme', 'Theme', 'pal', ' aria-haspopup="menu"')}`)
178
- + `<span class="sl-gap"></span>${tbl('present', 'Present', 'play')}${ro ? '' : `<button type="button" class="sl-b sl-pri" data-c="save">${I('save')}<span>Save</span></button>`}</div>`
181
+ + `<span class="sl-gap"></span>${tbl('present', 'Present', 'play')}${S.onClose ? `<button type="button" class="sl-b sl-bl" data-c="close"><span>Cancel</span></button>` : ''}${ro ? '' : `<button type="button" class="sl-b sl-pri" data-c="save">${I('save')}<span>Save</span></button>`}</div>`
179
182
  + (ro ? '' : '<div class="sl-ctx" role="toolbar" aria-label="Change the selected item"></div>')
180
183
  + `<p class="sl-msg" role="status"></p>`
181
184
  + `<div class="sl-body"><nav class="sl-rail" aria-label="Slides"></nav><div class="sl-main"><div class="sl-stage" tabindex="0" aria-label="Slide"></div>`
@@ -338,6 +341,11 @@ function onTop(S, c, b) {
338
341
  S.pres = present(S.deck, S.ws, S.i, { ro: S.ro, onNotes: (i, v, first) => { if (first) snap(S); S.deck.slides[i].notes = v; S.dirty = true; drawBar(S); }, onEnd: (i) => { S.pres = null; go(S, i); } });
339
342
  return;
340
343
  }
344
+ if (c === 'close') {
345
+ commitEdit(S);
346
+ if (S.dirty && !S.closing) { S.closing = true; b.innerHTML = '<span>Sure? Leave without saving</span>'; return; }
347
+ OPEN.delete(S.path); if (S.onClose) S.onClose(); return;
348
+ }
341
349
  if (S.ro) return;
342
350
  if (c === 'undo') return undo(S);
343
351
  if (c === 'redo') return redo(S);
@@ -451,6 +459,7 @@ function askSave(S, b) {
451
459
  const r = await save(S, why);
452
460
  if (!r.ok) { err.hidden = false; err.textContent = r.error; return; }
453
461
  closePop(S);
462
+ if (S.onClose) { OPEN.delete(S.path); S.onClose(); }
454
463
  };
455
464
  }
456
465
  async function save(S, why) {
@@ -1912,8 +1912,76 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
1912
1912
  @media (max-width:700px){#dsOlItems{display:flex;flex-wrap:wrap;gap:6px}.dso button{display:inline-flex;width:auto}.dso .l2,.dso .l3{padding-left:10px}.dso{max-height:none}}
1913
1913
  .dsbody .dsat{display:flex;align-items:center;gap:6px;margin:-2px 0 8px;font-size:var(--fs-2);color:var(--ink-3)}
1914
1914
  .dsbody .dsat i{width:18px;height:18px;border-radius:50%;background:var(--well);display:grid;place-items:center;font:600 var(--fs-1) var(--mono);font-style:normal;color:var(--ink-2)}
1915
- .rdbar .rdsp{margin-left:auto;display:flex;gap:8px;flex-wrap:wrap}
1916
- .rdbar .dsvw:last-child .dsmn,.rdbar .rdsp .dsmn{left:auto;right:0}
1915
+ /* one bar for a report, one row, icons only (PM 2026-10-22): Slides | Page, Brief, state, schedule, then Edit, Present, Share, Issue and ⋯ */
1916
+ .rdbar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:0 0 12px}
1917
+ .rdbar .rdsp{flex:1 1 0;min-width:0;margin:0}
1918
+ .rdib{display:grid;place-items:center;flex:none;width:44px;height:44px;border-radius:10px;background:var(--well);color:var(--ink)}
1919
+ .rdib svg{width:18px;height:18px}
1920
+ .rdib:disabled{opacity:.5;cursor:not-allowed}
1921
+ .rdib.pri{background:var(--ink);color:var(--card-solid)}
1922
+ .rdib[data-rr="mo"] svg{fill:currentColor;stroke:none}
1923
+ @media (hover:hover){.rdib:hover{background:color-mix(in oklab,var(--ink) 9%,transparent)}.rdib.pri:hover{background:var(--ink);opacity:.9}}
1924
+ .rdvw{display:inline-flex;gap:2px;padding:2px;border-radius:12px;background:var(--well)}
1925
+ .rdvw .rdib{background:none;color:var(--ink-3)}
1926
+ .rdvw .rdib[aria-pressed="true"]{background:var(--card-solid);color:var(--ink);box-shadow:0 0 0 1px var(--hair)}
1927
+ .rdst{padding:4px 10px;font-size:var(--fs-2);gap:6px;font-weight:600}
1928
+ .rdbar .chp.rdsch{min-height:44px;padding:0 12px;border:0;cursor:pointer;font:600 var(--fs-2) var(--mono);gap:6px;background:var(--well);color:var(--ink-2)}
1929
+ .rdsch svg{width:15px;height:15px}
1930
+ .rdsch b{font-weight:600;color:var(--ink)}
1931
+ .rdbar .dsmn{top:50px}
1932
+ .rdbar .dsvw:last-child .dsmn{left:auto;right:0}
1933
+ .dsmn.rdmo,.dsmn.rdsm,.dsmn.rdcm{min-width:min(300px,86vw);max-height:min(70vh,560px);overflow:auto}
1934
+ .dsmn.rdmo button,.dsmn.rdmo a,.dsmn.rdsm button,.dsmn.rdsm a,.dsmn.rdcm button{height:auto;min-height:44px;align-items:flex-start;padding:9px 12px}
1935
+ .dsmn.rdmo hr,.dsmn.rdsm hr{border:0;border-top:1px solid var(--hair);margin:4px 6px;width:auto}
1936
+ .dsmn .rdbad,.dsmn .rdbad svg{color:var(--bad)}
1937
+ .rdfile{margin:6px 12px 2px;font:500 var(--fs-2) var(--mono);color:var(--ink-3);overflow-wrap:anywhere}
1938
+ .rdsd{display:flex;gap:4px;flex-wrap:wrap;padding:6px 8px}
1939
+ .dsmn .rdsd button{min-height:44px;height:auto;padding:6px 12px;border-radius:999px;background:var(--well)}
1940
+ .dsmn .rdsd button[aria-pressed="true"]{background:var(--ink);color:var(--card-solid)}
1941
+ .dsmn.rdsm a span{flex:1}
1942
+ .rdedn{margin:0;align-self:center}
1943
+ .rded{min-height:420px}
1944
+ .rdlook{margin:0 0 12px}
1945
+ /* the report's cycles, under its name */
1946
+ #dSub .rdcw{display:inline-flex;z-index:60}
1947
+ #dSub .chp.rdcyc{min-height:32px;padding:2px 10px;border:0;border-radius:999px;background:var(--well);font:600 var(--fs-2) var(--mono);color:var(--ink-2);gap:4px;cursor:pointer}
1948
+ #dSub .rdcyc svg{width:15px;height:15px}
1949
+ .dsmn.rdcm{top:38px}
1950
+ .dsmn.rdcm .label{margin:8px 12px 2px}
1951
+ .dsmn.rdcm button{flex-wrap:wrap}
1952
+ .dsmn.rdcm small{display:block;width:100%;font:400 var(--fs-2) var(--mono);color:var(--ink-3)}
1953
+ .dsmn.rdcm button svg{margin-left:auto}
1954
+ /* the samples above the chat box, and its clip */
1955
+ .rdsmp{display:flex;flex-wrap:wrap;align-items:center;gap:2px 0;margin-top:10px}
1956
+ .rdsmp .label{margin:0 8px 0 0}
1957
+ #rdF .rdclip{background:var(--well);color:var(--ink-2)}
1958
+ @media (pointer:coarse){#dSub .chp.rdcyc{min-height:44px}}
1959
+ /* the Brief, in its own viewer tab: how the report is made, not part of it */
1960
+ .rbrief{padding:4px 4px 24px;display:grid;gap:14px}
1961
+ .rbhd{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
1962
+ .rbhd>span:first-child{flex:1;min-width:0;display:grid;gap:2px}
1963
+ .rbhd small{font-size:var(--fs-2);color:var(--ink-3)}
1964
+ .rbto{padding:4px 10px;border-radius:999px;background:var(--warn-bg,var(--well));color:var(--warn,var(--ink));font:600 var(--fs-2) var(--mono)}
1965
+ .rbhd .dmcta{min-height:44px}
1966
+ .rbtoc{display:flex;gap:6px;overflow-x:auto;padding-bottom:2px}
1967
+ .rbtoc button{flex:none;min-height:44px;padding:0 12px;border-radius:999px;background:var(--well);font:600 var(--fs-2) var(--mono);color:var(--ink-2)}
1968
+ .rbs{padding:14px 16px;border-radius:14px;background:var(--well);scroll-margin-top:12px}
1969
+ .rbs h4{display:flex;align-items:center;gap:8px;margin:0 0 8px;font-size:var(--fs-4)}
1970
+ .rbs p,.rbs li{font-size:var(--fs-3);line-height:1.5;color:var(--ink-2)}
1971
+ .rbs ul,.rbs ol{margin:0;padding-left:20px;display:grid;gap:4px}
1972
+ .rbs p{margin:0 0 6px}
1973
+ .rbfix{margin-left:auto;min-height:44px;padding:0 12px;border-radius:10px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair);font:600 var(--fs-2) var(--mono);color:var(--ink-2)}
1974
+ .rbs li .rbfix{margin-left:6px;vertical-align:middle}
1975
+ .rbkv{display:grid;grid-template-columns:max-content 1fr;gap:6px 14px;margin:0;font-size:var(--fs-3)}
1976
+ .rbkv dt{color:var(--ink-3)}
1977
+ .rbkv dd{margin:0;color:var(--ink)}
1978
+ .rbcalc{padding:10px 12px;border-radius:10px;background:var(--card-solid);margin:0 0 8px}
1979
+ .rbcalc p{margin:2px 0 0}
1980
+ .rbsub{color:var(--ink-3)}
1981
+ .rbrief .tag{display:inline-block;padding:1px 8px;border-radius:999px;font:600 var(--fs-1) var(--mono);background:var(--card-solid);color:var(--ink-3);box-shadow:inset 0 0 0 1px var(--hair)}
1982
+ .rbrief .tag.ok{color:var(--ok)}
1983
+ .rbrief .tag.no,.rbrief .tag.as{color:var(--warn,var(--bad))}
1984
+ @media (max-width:520px){.rbkv{grid-template-columns:1fr}.rbkv dd{margin-bottom:6px}.rdbar{gap:4px}}
1917
1985
  .dsrel{display:grid;gap:6px}
1918
1986
  .dsrr{display:flex;align-items:center;gap:10px;justify-content:space-between;padding:6px 10px;border-radius:10px;background:var(--well)}
1919
1987
  .dsrr button,.dsrr>span:first-child{display:grid;gap:2px;text-align:left;min-height:44px;align-content:center;color:var(--ink)}