create-pmos 0.608.0 → 0.610.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.
- package/package.json +33 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +2 -2
- package/workspace/briefing-premium-adddoc-test.js +2 -1
- package/workspace/briefing-premium-board-test.js +9 -9
- package/workspace/briefing-premium-initiative-test.js +7 -6
- package/workspace/briefing-premium-insights-test.js +10 -10
- package/workspace/briefing-premium-products-test.js +4 -2
- package/workspace/briefing-premium-sources-test.js +1 -1
- package/workspace/briefing-premium-test.js +4 -4
- package/workspace/briefing-premium-work-test.js +1 -1
- package/workspace/changelog.json +32 -0
- package/workspace/ev-everywhere-test.js +9 -9
- package/workspace/guide/home.md +1 -1
- package/workspace/guide/layout.md +32 -11
- package/workspace/home-other-product-test.js +2 -1
- package/workspace/home-railcard-test.js +2 -1
- package/workspace/lib/beside-page.js +15 -0
- package/workspace/lib/routes-lab.js +4 -1
- package/workspace/live-pill-round-test.js +3 -4
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +5 -4
- package/workspace/premium-chat-context-test.js +6 -6
- package/workspace/premium-chat-line-test.js +1 -1
- package/workspace/premium-chat-notes-test.js +1 -1
- package/workspace/premium-core-doc-issue-test.js +2 -1
- package/workspace/premium-vw-cal-test.js +1 -1
- package/workspace/premium-vw-doc-test.js +2 -1
- package/workspace/program-leave-test.js +2 -1
- package/workspace/program-panel-test.js +2 -2
- package/workspace/public/pm/bd-ini-panel.js +3 -1
- package/workspace/public/pm/bd-scroll.js +4 -2
- package/workspace/public/pm/cozy-board.css +3 -0
- package/workspace/public/pm/cozy-ev.css +51 -0
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-live-pill.js +2 -1
- package/workspace/public/pm/cozy-nav.js +70 -7
- package/workspace/public/pm/cozy-panels.js +1 -1
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pick.js +6 -2
- package/workspace/public/pm/cozy-popup.css +113 -0
- package/workspace/public/pm/cozy-popup.js +408 -0
- package/workspace/public/pm/cozy-proto.js +3 -0
- package/workspace/public/pm/cozy-settings.js +10 -1
- package/workspace/public/pm/cozy-viewer.js +66 -18
- package/workspace/public/pm/home-app.js +11 -3
- package/workspace/public/pm/home-ini.js +4 -3
- package/workspace/public/pm/ini-agent.js +17 -4
- package/workspace/public/pm/ini-view.js +11 -0
- package/workspace/public/pm/page-chat.js +16 -4
- package/workspace/public/pm/pop-sessions.js +65 -0
- package/workspace/public/pm/premium-board.js +7 -3
- package/workspace/public/pm/premium-insights.js +14 -2
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/stage-card-tasks-test.js +2 -2
- package/workspace/task-card-test.js +2 -1
- package/workspace/task-delete-test.js +2 -1
- package/workspace/task-links-test.js +3 -2
- package/workspace/task-views-test.js +7 -7
- package/workspace/test-lists/one-popup.json +9 -0
- package/workspace/tk-tasks-test.js +2 -1
- package/workspace/viewer-trail-test.js +1 -1
- package/workspace/workflows-setup-test.js +1 -1
|
@@ -64,6 +64,11 @@
|
|
|
64
64
|
* trail; Back at the first item closes the Viewer. Close (×, Escape, close()) takes the trail's entries off again, so Back never
|
|
65
65
|
* lands on a closed item. A page writes its own address with replaceUrl(url), which waits while the history is still moving.
|
|
66
66
|
* placeholder(featureName, { kind?, icon? }) opens the card with czPlaceholder(featureName) in it (cozy-placeholder.js)
|
|
67
|
+
* The popup (slice 2 of the six-place navigation, boards 3, 7, 23; pm/cozy-popup.js): open({ pop: { … } }) on a desk puts the item in a
|
|
68
|
+
* Viewer of its own on the left of the near-full popup, with the chat on its right. pop is what the chat is about (cozy-popup.js show()).
|
|
69
|
+
* A press inside the popup (the Viewer or the chat beside it) drills in there; the header then shows the path and ←. That Viewer has no
|
|
70
|
+
* grip, ⤢, × or Discuss (the popup has its own grip, × and chat), and the panels engine never counts it: it is the one slide-over.
|
|
71
|
+
* popHook({ host(), show(pop) }) is how cozy-popup.js registers · popOpen() → whether it shows · closePop() closes it (its guard asks first)
|
|
67
72
|
* onChange(fn) → fn({ open, id, kind, title, via }) after each open and close (via 'history' when the browser's Back closed it); document also gets the event 'cz-viewer' with the same detail.
|
|
68
73
|
* czSummary({ line, tone, right, text, meta, primary, also, extra }) → the summary card's markup: one line of state, the words, one quiet meta
|
|
69
74
|
* line and ONE primary press ({ label, act } → data-czs-act="<act>", or { label, href }). tone 'you' (blue dot), 'warn' (amber), 'live' (red).
|
|
@@ -121,17 +126,27 @@ const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file
|
|
|
121
126
|
* key or the last open() went to, so the exported API always speaks of the Viewer used last. G is what the page has once: its list's rail,
|
|
122
127
|
* the listeners, the rail's card. Only the first instance (#czViewer) writes the browser history; another keeps its own ← → trail.
|
|
123
128
|
* Without cozy-panels.js (Board, Intelligence) the limit stays 1 and there is one Viewer, as before. */
|
|
124
|
-
const G = { chat: null, subs: [], card: null, railKey: null, rail: false, lw: 0, hold: 0, tick: 0, limit: 1, beside: null, place: null, managed: null, own: null };
|
|
129
|
+
const G = { chat: null, subs: [], card: null, railKey: null, rail: false, lw: 0, hold: 0, tick: 0, limit: 1, beside: null, place: null, managed: null, own: null, popH: null, popNext: null };
|
|
125
130
|
/** The list's fold, when the page owns it (Home, batch 20 item 6): { folded() → bool, show() }. Then only the list's own icon folds or unfolds it:
|
|
126
131
|
* a Viewer's width, its reset, open wide and its close never do. null: the Viewer folds the list to a rail as it needs (a page without one). */
|
|
127
132
|
export function listFold(o) { G.own = o && typeof o.folded === 'function' ? o : null; }
|
|
128
133
|
const owned = () => (G.own ? !!G.own.folded() : null);
|
|
129
134
|
/** true: the PM has pressed the list's fold or unfold, so a full Viewer keeps the list as the PM left it (no starting fold). */
|
|
130
135
|
const chosen = () => !!(G.own && typeof G.own.chosen === 'function' && G.own.chosen());
|
|
131
|
-
const mk = (i) => ({ i, el: null, cur: null, back: null, stack: [], fwd: [], wide: false, w: 0, drill: false, over: false, used: 0, ph: false, via: '' });
|
|
136
|
+
const mk = (i) => ({ i, el: null, cur: null, back: null, stack: [], fwd: [], wide: false, w: 0, drill: false, over: false, used: 0, ph: false, via: '', pop: false });
|
|
132
137
|
let V = mk(0);
|
|
133
138
|
const ALL = [V];
|
|
134
139
|
const shown = (x) => !!(x && x.el && !x.el.hidden && x.cur);
|
|
140
|
+
/** The Viewers of the page, without the popup's (the panels engine and a drop beside never use it). */
|
|
141
|
+
const side = () => ALL.filter((x) => !x.pop);
|
|
142
|
+
/** The popup's Viewer is the first one (#czViewer), lifted into the popup while it shows, so every page's own selectors still find it.
|
|
143
|
+
* An item it showed beside the page closes first (the popup takes its place); on close it goes back to the page's host (close()). */
|
|
144
|
+
function popInst() {
|
|
145
|
+
const x = ALL[0];
|
|
146
|
+
if (!x.pop && shown(x)) on(x, () => close());
|
|
147
|
+
x.pop = true; if (x.el) x.el.classList.add('cz-vw-pop');
|
|
148
|
+
return x;
|
|
149
|
+
}
|
|
135
150
|
/** The open Viewer used last (or null). */
|
|
136
151
|
const mru = () => ALL.filter(shown).sort((a, b) => b.used - a.used)[0] || null;
|
|
137
152
|
/** A press, a key or an open on this instance: it is the one in use now. */
|
|
@@ -143,16 +158,16 @@ function on(x, fn) { const was = V; V = x; try { return fn(); } finally { V = wa
|
|
|
143
158
|
function pick(o) {
|
|
144
159
|
const b = G.beside; G.beside = null;
|
|
145
160
|
if (b && Date.now() - b.t < 6000) {
|
|
146
|
-
const free =
|
|
161
|
+
const free = side().find((x) => !shown(x));
|
|
147
162
|
if (free) return free;
|
|
148
163
|
if (ALL.length < G.limit) { const n = mk(ALL.length); ALL.push(n); return n; }
|
|
149
|
-
return
|
|
164
|
+
return side().filter(shown).sort((a, c) => a.used - c.used)[0];
|
|
150
165
|
}
|
|
151
166
|
const p = H.press && Date.now() - H.press.t < 10000 ? H.press : null;
|
|
152
167
|
if (p && p.inst && shown(p.inst) && !o.fresh) {
|
|
153
168
|
// a Viewer that holds a chat (outward: the Board's chat panel) opens what it names in the other Viewer, as Home's chat column does;
|
|
154
169
|
// with no other Viewer it drills in, and ← comes back to the chat
|
|
155
|
-
const other = p.inst.cur && p.inst.cur.args && p.inst.cur.args.outward ?
|
|
170
|
+
const other = p.inst.cur && p.inst.cur.args && p.inst.cur.args.outward ? side().filter((x) => shown(x) && x !== p.inst).sort((a, c) => c.used - a.used)[0] : null;
|
|
156
171
|
return other || p.inst;
|
|
157
172
|
}
|
|
158
173
|
return mru() || ALL[0];
|
|
@@ -175,7 +190,7 @@ export function headHtml(it) {
|
|
|
175
190
|
const o = it || {};
|
|
176
191
|
const phone = !!o.phone;
|
|
177
192
|
const kind = o.kind && !sameAs(o.kind, o.title) ? `<p class="cz-vw-kind">${esc(o.kind)}</p>` : '';
|
|
178
|
-
const disc = o.discuss && (!o.home || o.discussHome) ? ib('discuss', 'Discuss in chat', P.chat) : '';
|
|
193
|
+
const disc = o.discuss && !o.pop && (!o.home || o.discussHome) ? ib('discuss', 'Discuss in chat', P.chat) : ''; // in the popup the chat is beside it
|
|
179
194
|
// a press marked menu (the initiative's Dashboard, batch 18 item 1) goes into ⋯ on a phone, so the title keeps the room
|
|
180
195
|
const inMenu = phone && (o.presses || []).some((x) => x && x.menu && x.act && x.label);
|
|
181
196
|
const more = inMenu || typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
|
|
@@ -187,17 +202,19 @@ export function headHtml(it) {
|
|
|
187
202
|
// lead: a press that stands before Discuss (the initiative's kind of work, batch 29 item 11, KdV1-3)
|
|
188
203
|
const lead = shown.filter((x) => x.lead).map(pressHtml).join(''), own = shown.filter((x) => !x.lead).map(pressHtml).join('');
|
|
189
204
|
const sub = o.sub ? `<p class="cz-vw-sub">${esc(o.sub)}</p>` : '';
|
|
205
|
+
// the popup's path (board 22: initiative › suggestion): each step behind is a press that goes back to it
|
|
206
|
+
const pth = o.pop && (o.path || []).length ? `<nav class="cz-vw-path" aria-label="Path">${o.path.map((t, i, a) => `<button type="button" data-cz-vw-path="${i - a.length}">${esc(t || 'Back')}</button><span aria-hidden="true">›</span>`).join('')}</nav>` : '';
|
|
190
207
|
const chip = o.chip && (o.chip.n > 0 || o.chip.looking) ? `<button type="button" class="cz-vw-chip${o.chip.looking ? ' live' : ''}" data-cz-vw="chip" aria-haspopup="dialog" aria-label="${esc(o.chip.label || 'PMOS proposes ' + o.chip.n + '. Open')}" title="${esc(o.chip.label || 'PMOS proposes')}">${svg(ICONS.spark, 13, 2)}${o.chip.n > 0 && !o.chip.quiet ? `<b>${esc(o.chip.n)}</b>` : ''}</button>` : '';
|
|
191
208
|
return (o.canBack || phone ? ib('back', o.canBack ? (o.backTo ? 'Back to ' + o.backTo : 'Back') : 'Close the viewer', P.back) : '')
|
|
192
209
|
+ (o.fwdTo ? ib('fwd', 'Forward to ' + o.fwdTo, P.fwd) : '')
|
|
193
210
|
+ (o.check ? `<button type="button" class="cz-vw-tile cz-vw-chk s-${esc(o.check.state || 'todo')}" data-cz-vw="press" data-cz-vw-p="check" aria-label="${esc(o.check.label || 'Mark done')}" title="${esc(o.check.title || o.check.label || 'Mark done')}"${o.check.disabled ? ' disabled' : ''}><span class="bx"></span></button>`
|
|
194
211
|
: `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`)
|
|
195
|
-
+ (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}${o.wrap ? ' wrap' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
|
|
212
|
+
+ (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${pth || kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}${o.wrap ? ' wrap' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
|
|
196
213
|
+ lead + disc + own + add + more
|
|
197
214
|
// ⧉ (batch 18 item 15, TbT7Place): where a page arranges panels, one placement press takes the place of ⤢ (Full screen is in it)
|
|
198
|
-
+ (phone ? '' : o.place ? ib('place', 'Arrange', P.place, ' aria-haspopup="menu" aria-expanded="false"')
|
|
215
|
+
+ (phone || o.pop ? '' : o.place ? ib('place', 'Arrange', P.place, ' aria-haspopup="menu" aria-expanded="false"')
|
|
199
216
|
: ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
|
|
200
|
-
+ (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
|
|
217
|
+
+ (phone || o.pop ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
|
|
201
218
|
}
|
|
202
219
|
|
|
203
220
|
/* ── summary first: the card and the folding rows ── */
|
|
@@ -341,6 +358,8 @@ const sideMax = () => { const r = room(); return r.float ? r.side : Math.max(MIN
|
|
|
341
358
|
function apply(px) {
|
|
342
359
|
const el = V.el; if (!el) return;
|
|
343
360
|
if (isPhone()) { el.style.width = ''; el.style.flexBasis = ''; el.classList.remove('cz-vw-w2'); setRail(false); return; }
|
|
361
|
+
// the popup's Viewer: the popup sizes it (its grip is between the work and the chat); the list behind is never folded for it
|
|
362
|
+
if (V.pop) { el.style.width = ''; el.style.flexBasis = ''; el.classList.toggle('cz-vw-w2', el.offsetWidth >= W2); return; }
|
|
344
363
|
// cozy-panels.js lays the panels out itself (two Viewers, a Viewer full or sliding over): it sizes this one, the rail is its own call
|
|
345
364
|
if (G.managed && G.managed('v' + V.i)) { el.style.width = ''; el.classList.toggle('cz-vw-w2', el.offsetWidth >= W2); return; } // its flex is the engine's; V.w keeps the width beside the chat
|
|
346
365
|
let r = room();
|
|
@@ -465,15 +484,16 @@ function mount() {
|
|
|
465
484
|
if (V.el && V.el.isConnected) return V.el;
|
|
466
485
|
sheet();
|
|
467
486
|
const el = document.createElement('section'), x = V;
|
|
468
|
-
el.className = 'cz-vw'; el.id = V.i ? 'czViewer' + (V.i + 1) : 'czViewer'; el.hidden = true; el.dataset.czPanel = 'v' + V.i;
|
|
487
|
+
el.className = 'cz-vw' + (V.pop ? ' cz-vw-pop' : ''); el.id = V.i ? 'czViewer' + (V.i + 1) : 'czViewer'; el.hidden = true; el.dataset.czPanel = 'v' + V.i;
|
|
469
488
|
if (!V.i) el.setAttribute('aria-labelledby', 'czVwTitle'); // a second Viewer is named by its aria-label (the title id is the first one's)
|
|
470
489
|
el.tabIndex = -1;
|
|
471
490
|
el.innerHTML = '<header class="cz-vw-hd"></header><div class="cz-vw-body"></div>';
|
|
472
|
-
el.prepend(grip(el));
|
|
491
|
+
el.prepend(grip(el)); // hidden in the popup: its grip is the popup's own, between the work and the chat
|
|
473
492
|
el.addEventListener('click', (e) => { // the header's presses, and the folds of czSections in the body
|
|
474
493
|
use(x);
|
|
475
494
|
const f = e.target.closest('[data-czs-fold]'); if (f && el.contains(f)) { toggleFold(f); return; }
|
|
476
495
|
if (e.target.closest('[data-cz-vw-rn]')) { startRename(); return; } // the title is the rename press (RnATask)
|
|
496
|
+
const pa = e.target.closest('[data-cz-vw-path]'); if (pa) { const n = +pa.dataset.czVwPath; guarded(() => step(n), pa); return; } // the popup's path
|
|
477
497
|
const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled || !el.querySelector('.cz-vw-hd').contains(b)) return;
|
|
478
498
|
const a = b.dataset.czVw;
|
|
479
499
|
if (a === 'close') guarded(close, b);
|
|
@@ -503,6 +523,7 @@ function mount() {
|
|
|
503
523
|
}
|
|
504
524
|
/** In the page's own place for it when there is one (data-cz-viewer-host), else at the end of the body, floating. */
|
|
505
525
|
function place(el) {
|
|
526
|
+
if (V.pop && G.popH) { const h = G.popH.host(); if (h && el.parentNode !== h) h.appendChild(el); el.classList.remove('cz-vw-float'); return; }
|
|
506
527
|
const host = document.querySelector('[data-cz-viewer-host]');
|
|
507
528
|
if (host) { if (el.parentNode !== host) host.appendChild(el); el.classList.remove('cz-vw-float'); }
|
|
508
529
|
else { if (el.parentNode !== document.body) document.body.appendChild(el); el.classList.add('cz-vw-float'); }
|
|
@@ -512,8 +533,8 @@ function place(el) {
|
|
|
512
533
|
function emit(x) {
|
|
513
534
|
x = x || V;
|
|
514
535
|
const d = { open: !!V.cur, id: V.cur ? V.cur.id : null, kind: V.cur ? V.cur.kind : null, title: V.cur ? V.cur.title : null, via: V.cur ? '' : x.via || '', // via 'history': the browser's Back closed it
|
|
515
|
-
panel: 'v' + x.i, shut: !shown(x) };
|
|
516
|
-
document.body.classList.toggle('cz-vw-on',
|
|
536
|
+
panel: 'v' + x.i, shut: !shown(x), pop: !!x.pop };
|
|
537
|
+
if (!x.pop) document.body.classList.toggle('cz-vw-on', side().some(shown)); // the popup covers the page: the page does not make room for it
|
|
517
538
|
G.subs.forEach((f) => { try { f(d); } catch { /* a listener's fault stays its own */ } });
|
|
518
539
|
document.dispatchEvent(new CustomEvent('cz-viewer', { detail: d }));
|
|
519
540
|
}
|
|
@@ -532,7 +553,8 @@ function redraw() {
|
|
|
532
553
|
V.ph = isPhone();
|
|
533
554
|
const hd = V.el.querySelector('.cz-vw-hd');
|
|
534
555
|
const bk = V.stack[V.stack.length - 1], fw = V.fwd[V.fwd.length - 1];
|
|
535
|
-
hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, backTo: bk ? bk.title || '' : '', fwdTo: fw ? fw.title || 'the next item' : '', isWide: V.wide || G.rail, phone: V.ph, home: onHome(), place: !!G.place
|
|
556
|
+
hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, backTo: bk ? bk.title || '' : '', fwdTo: fw ? fw.title || 'the next item' : '', isWide: V.wide || G.rail, phone: V.ph, home: onHome(), place: !!G.place && !V.pop,
|
|
557
|
+
pop: V.pop, path: V.pop ? V.stack.map((a) => (a && a.title) || '') : null });
|
|
536
558
|
hd.classList.toggle('cz-vw-renon', !!V.cur.renaming);
|
|
537
559
|
}
|
|
538
560
|
|
|
@@ -590,9 +612,15 @@ function retitle0(id, title) { if (V.cur && V.cur.id === String(id) && title) {
|
|
|
590
612
|
/** Show one item in the Viewer, in place of the one shown. Returns the body element the content is in. */
|
|
591
613
|
export function open(it) {
|
|
592
614
|
let o = it || {};
|
|
593
|
-
|
|
615
|
+
// pop (the popup, slice 2): on a desk the item goes in the popup's own Viewer, and the popup shows the chat about pop beside it
|
|
616
|
+
const pn = !o._inst && G.popNext && Date.now() - G.popNext.t < 8000 ? G.popNext : null; if (pn) G.popNext = null; // popNext(): this open pops
|
|
617
|
+
const popArg = o.pop || (pn && pn.pop);
|
|
618
|
+
// a published read-only Board has no chat; 'beside' (the PM's choice, cozy-popup.js) keeps work beside the page, unless the popup shows
|
|
619
|
+
// already (it takes what opens next) or the open is the chat icon's own (force)
|
|
620
|
+
const toPop = !o._inst && !!popArg && !!G.popH && !isPhone() && !window.PMOS_READONLY && (!!popArg.force || popShown() || !popBeside());
|
|
621
|
+
let x = o._inst || (toPop && popInst()) || (o.into && byP(o.into)) || pick(o); // into: a panel id ('v1'), the Viewer that shows it (the Board's chat panel)
|
|
594
622
|
// one item, one Viewer (batch 31 item 10): an item already shown in another Viewer is not opened twice; that Viewer shows it again
|
|
595
|
-
const twin = !o._inst && o.id != null ? ALL.find((y) => y !== x && shown(y) && y.cur.id === String(o.id)) : null;
|
|
623
|
+
const twin = !o._inst && !x.pop && o.id != null ? ALL.find((y) => y !== x && !y.pop && shown(y) && y.cur.id === String(o.id)) : null;
|
|
596
624
|
if (twin) { x.drill = false; x = twin; o = { ...o, keep: true, fresh: false }; }
|
|
597
625
|
use(x);
|
|
598
626
|
// an item with unsaved changes asks first; the open goes on when it says so (and keeps a drill-in asked for before it)
|
|
@@ -602,6 +630,7 @@ export function open(it) {
|
|
|
602
630
|
now = false;
|
|
603
631
|
if (!ran) return null;
|
|
604
632
|
}
|
|
633
|
+
if (toPop) { try { G.popH.show(popArg); } catch (err) { console.error(err); } }
|
|
605
634
|
const el = mount(); place(el);
|
|
606
635
|
if (!V.cur) { const ae = document.activeElement; V.back = ae && ae !== document.body && !el.contains(ae) ? ae : null; }
|
|
607
636
|
const was = isOpen(), pos = V.stack.length, how = stepOf(o);
|
|
@@ -666,6 +695,8 @@ export function close(o = {}) {
|
|
|
666
695
|
const nx = mru(); // another Viewer is still open: it is the one in use now, and the list stays as it is
|
|
667
696
|
if (nx) V = nx; else setRail(false);
|
|
668
697
|
emit(x);
|
|
698
|
+
// the popup closed: its Viewer goes back to the page, as a Viewer of the page again
|
|
699
|
+
if (x.pop) { x.pop = false; if (x.el) { x.el.classList.remove('cz-vw-pop'); on(x, () => place(x.el)); } }
|
|
669
700
|
let b = x.back; x.back = null;
|
|
670
701
|
// the page drew its rows again meanwhile (a page panel back to its wide form): the same row, by its key, takes the focus
|
|
671
702
|
if (b && !b.isConnected && b.dataset && b.dataset.key) b = document.querySelector(`[data-key="${CSS.escape(b.dataset.key)}"]`);
|
|
@@ -744,7 +775,12 @@ function follow(n) {
|
|
|
744
775
|
if (!ran) hq({ go: -n });
|
|
745
776
|
}
|
|
746
777
|
/* where a press was: inside the Viewer it drills in, outside it starts a new trail */
|
|
747
|
-
function pressAt(e) {
|
|
778
|
+
function pressAt(e) {
|
|
779
|
+
const t = e.target; let inst = t && t.nodeType === 1 && !t.closest('.cz-vw-trail') ? ALL.find((x) => x.el && x.el.contains(t)) || null : null;
|
|
780
|
+
// a press in the popup's chat (a file or a link it names) opens on the popup's left, behind the work shown there (board 22)
|
|
781
|
+
if (!inst && t && t.nodeType === 1 && t.closest('.cz-pop')) inst = ALL.find((x) => x.pop && shown(x)) || null;
|
|
782
|
+
H.press = { t: Date.now(), inst };
|
|
783
|
+
}
|
|
748
784
|
/* the trail list: hover ← or → for a moment (a mouse), or hold it (a touch). It names every step, newest first, and the page it started on. */
|
|
749
785
|
let HOLD = { t: 0, fired: 0 };
|
|
750
786
|
function holdable(el, x) {
|
|
@@ -800,7 +836,7 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
|
|
|
800
836
|
/* ── for cozy-panels.js (batch 18 item 15): the instances behind one object. A panel id is 'v' + the instance's number (v0 is #czViewer). ── */
|
|
801
837
|
const byP = (id) => ALL.find((x) => 'v' + x.i === id) || null;
|
|
802
838
|
export const panels = {
|
|
803
|
-
list: () =>
|
|
839
|
+
list: () => side().map((x) => ({ id: 'v' + x.i, open: shown(x), used: x.used, el: x.el, item: x.cur ? { id: x.cur.id, kind: x.cur.kind, title: x.cur.title } : null })),
|
|
804
840
|
/** limit: how many Viewers may be open at once · place(id, button): ⧉ was pressed · managed(id) → true: the panels engine sizes it */
|
|
805
841
|
config(c = {}) { if (c.limit) G.limit = c.limit; if ('place' in c) G.place = c.place; if ('managed' in c) G.managed = c.managed; ALL.filter(shown).forEach((x) => on(x, redraw)); },
|
|
806
842
|
/** The next open() goes into a Viewer of its own (a drop beside, TbT5DragRow). */
|
|
@@ -816,4 +852,16 @@ export const panels = {
|
|
|
816
852
|
rest() { ALL.filter(shown).forEach((x) => on(x, () => { const k = widthOf(V.cur.kind); V.wide = false; apply(k || room().def); redraw(); })); },
|
|
817
853
|
rail(v) { setRail(!!v); }, railOn: () => G.rail, owned, chosen,
|
|
818
854
|
};
|
|
855
|
+
/* ── the popup (slice 2, pm/cozy-popup.js) ── */
|
|
856
|
+
/** cozy-popup.js registers { host() → the popup's left element, show(pop) → the popup is shown with the chat about pop }. */
|
|
857
|
+
export function popHook(h) { G.popH = h && typeof h.host === 'function' && typeof h.show === 'function' ? h : null; }
|
|
858
|
+
export const popOpen = () => ALL.some((x) => x.pop && shown(x));
|
|
859
|
+
/** The next open() (within a few seconds) goes into the popup about pop: for an opener that does not pass pop itself (premium-vw-item.js). */
|
|
860
|
+
/** Where work opens on a desk: 'beside' keeps it beside the page (the panels), anything else the popup. Kept in localStorage. */
|
|
861
|
+
export const POP_WHERE = 'cz-pop-open';
|
|
862
|
+
const popBeside = () => { try { return localStorage.getItem(POP_WHERE) === 'beside'; } catch { return false; } };
|
|
863
|
+
const popShown = () => ALL.some((y) => y.pop && shown(y));
|
|
864
|
+
export function popNext(pop) { G.popNext = pop ? { pop, t: Date.now() } : null; }
|
|
865
|
+
/** Close the popup's Viewer (an item with unsaved changes asks first). */
|
|
866
|
+
export function closePop() { const x = ALL.find((y) => y.pop && shown(y)); if (x) { use(x); guarded(close); } }
|
|
819
867
|
if (typeof window !== 'undefined') window.czViewer = { open, close, closeOf, bodyOf, back, forward, trail, replaceUrl, drill, setPresses, setChip, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, railCard, railSync, keepWide, ICONS };
|
|
@@ -24,6 +24,7 @@ import { mountLivePill } from './cozy-live-pill.js';
|
|
|
24
24
|
import { mountPanels } from './cozy-panels.js';
|
|
25
25
|
import { ownTab, bring, tabUrl } from './rec-tab-core.js';
|
|
26
26
|
import * as VW from './cozy-viewer.js';
|
|
27
|
+
import * as POP from './cozy-popup.js'; // the one popup: an initiative and Ask PMOS side by side (slice 2 of the six-place navigation)
|
|
27
28
|
import * as SV from './small-vw.js'; // the small Viewers: a stakeholder, its form, a routine (batch 18 item 2-C)
|
|
28
29
|
import { pmGet, pmPost, pmHeaders } from './http.js';
|
|
29
30
|
import * as ST from './story.js';
|
|
@@ -1144,7 +1145,7 @@ const rich = () => !!S.ini;
|
|
|
1144
1145
|
function iniTarget(id) {
|
|
1145
1146
|
const h = S.H || {};
|
|
1146
1147
|
return { key: 'init:' + id, ini: id, ws: (otherIni(id) || {}).ws || WS || undefined, title: iniTitle(id), about: iniTitle(id), newChat: () => newIn(id), sub: (S.IMid === id && h.stage) || '', scope: scopeOf(id), rich: true, placeholder: 'Message PMOS about ' + iniTitle(id),
|
|
1147
|
-
empty: 'Ask about ' + iniTitle(id) + '. PMOS reads its records and works in a real
|
|
1148
|
+
empty: 'Ask about ' + iniTitle(id) + '. PMOS reads its records and works on it in a real session.', also: alsoOf(id),
|
|
1148
1149
|
// a prototype the sentence started (lib/routes-briefing-premium.js liveAsk): the Viewer opens it beside the chat, and shows it as it renders
|
|
1149
1150
|
onSent: (r) => { if (r && r.live && r.live.id) import('./cozy-lab.js').then((LC) => LC.openCompare({ where: { ws: r.live.ws || WS, board: r.live.board || '' }, id: r.live.id, H: { toast } })).catch(() => {}); },
|
|
1150
1151
|
// the initiative's conversation opens on where it stands (AgInitYou), until it has messages of its own
|
|
@@ -1494,7 +1495,8 @@ async function goIni(id, o = {}) {
|
|
|
1494
1495
|
// the address follows the page, so the entry before it (the trail's start, batch 14 item 7) keeps Home's own address
|
|
1495
1496
|
if (id === 'product') { openTarget(productTarget()); if (o.page !== false) { pushPage(); openProductPage(); } syncUrl(); return; }
|
|
1496
1497
|
openTarget(iniTarget(id));
|
|
1497
|
-
|
|
1498
|
+
// on a desk the page opens in the one popup, and Home's own chat (already on the initiative) goes in beside it
|
|
1499
|
+
if (o.page !== false) { pushPage(); iniPage({ pop: { keep: true, id, kind: 'initiative', title: iniTitle(id) } }); }
|
|
1498
1500
|
syncUrl();
|
|
1499
1501
|
if (window.czPanels) window.czPanels.scope(id); // the initiative reopens with its last panels and shares (batch 18 item 15)
|
|
1500
1502
|
await loadIni();
|
|
@@ -1680,7 +1682,7 @@ function pickProduct(chip) {
|
|
|
1680
1682
|
PP.openPicker(chip, { P: S.D.pick, label: 'Products on Home', tones: pickTones(), lines: pickLine, onApply: async (on) => { const r = await PP.savePick(on); if (!r.ok) toast(r.error); } });
|
|
1681
1683
|
}
|
|
1682
1684
|
// a saved pick (from this chip or Settings): Home shows and reads the ticked products
|
|
1683
|
-
addEventListener('pp:changed', (e) => { if (WS) { location.assign('/premium.html'); return; } pickGen++; S.D.pick = e.detail; drawList(); toast('Saved.
|
|
1685
|
+
addEventListener('pp:changed', (e) => { if (WS) { location.assign('/premium.html'); return; } pickGen++; S.D.pick = e.detail; drawList(); toast('Saved. Today, Work and Goals show the products you picked.'); load(); });
|
|
1684
1686
|
|
|
1685
1687
|
/* ── the Viewer: needs rows, the weekly update, the overview, files, people, routines ── */
|
|
1686
1688
|
let lastViewer = null;
|
|
@@ -2373,6 +2375,12 @@ PH = mountPhoneHead({
|
|
|
2373
2375
|
PH.draw();
|
|
2374
2376
|
/* The panels (batch 18 item 15, canvas TbT1Split…TbT9Divider): the chat and up to 3 Viewers side by side, the divider, open beside, ⧉, slide
|
|
2375
2377
|
* over. A Live pill row opens in the chat (liveGo); a remembered Viewer of an initiative opens again here when Home has a view for it. */
|
|
2378
|
+
/* The one popup (slice 2): Home's own chat is the popup's chat, so the page never holds two; a session picked in it opens the way Home opens a
|
|
2379
|
+
* session; the chat icon opens a session's initiative on the popup's left. */
|
|
2380
|
+
POP.useChat({ el: $('#hmChat'), open: (t) => openTarget(t), current: () => (chat.current ? chat.current() : null), focus: () => chat.focus(),
|
|
2381
|
+
sessionTarget: (row) => { const s = (S.D.sessions || []).find((x) => x.id === row.id); return s ? sessionTarget(s) : null; } });
|
|
2382
|
+
POP.setTitles((id) => (iniRowOf(id) ? iniTitle(id) : ''));
|
|
2383
|
+
POP.setOpener((id) => { openIniFrom(id).then(() => iniPage()); });
|
|
2376
2384
|
mountPanels({
|
|
2377
2385
|
go: liveGo,
|
|
2378
2386
|
reopen: (it) => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* mountIni(ctx) once, from home-app.js. ctx: { S, VW, pmGet, pmPost, toast, load, openFile, iniTitle, drawList, wait }
|
|
5
5
|
* iniList(sc) after each draw of the list column: reads the layout record and moves the stage by itself when it may. The list column
|
|
6
6
|
* never changes for an initiative (canvas HbC): the initiative is a page of the Viewer.
|
|
7
|
-
* iniPage()
|
|
7
|
+
* iniPage(o?) the initiative's page in the Viewer (o.pop: in the one popup, with Home's chat beside it): the ONE view the Board's panel draws too (ini-view.js; batch 6 items 1 and 3):
|
|
8
8
|
* summary, stage card with the dates line, Tasks as the WBS, Documents and Linked. The next stage opens the move sheet;
|
|
9
9
|
* Documents drills into the documents view, with ← back to the page. true when it opened.
|
|
10
10
|
* iniOverview(v, o) the initiative in the Viewer: Documents or Stage; o.back keeps the page behind it. true when it opened. Any other view
|
|
@@ -451,7 +451,8 @@ async function autoPress(id, M, on) {
|
|
|
451
451
|
}
|
|
452
452
|
/** The initiative's kind of work: the page's own model, else its Board row; none reads as Product management. */
|
|
453
453
|
const kindNow = (id) => { const M = curM(); return (M && M.kind) || rowOf(id).kind || 'product'; };
|
|
454
|
-
|
|
454
|
+
/** o.pop: open it in the one popup with Ask PMOS beside it (slice 2 of the six-place navigation; cozy-viewer.js pop). */
|
|
455
|
+
export function iniPage(o = {}) {
|
|
455
456
|
if (!X.ctx) return false;
|
|
456
457
|
const S = X.ctx.S, id = S.ini;
|
|
457
458
|
if (!id || id === 'product') return false;
|
|
@@ -460,7 +461,7 @@ export function iniPage() {
|
|
|
460
461
|
let rename = X.ctx.renameIni ? X.ctx.renameIni(id, '') : null;
|
|
461
462
|
if (rename) rename = { ...rename, value: X.ctx.iniTitle(id) };
|
|
462
463
|
const dh = dashFor(id);
|
|
463
|
-
BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', wrap: true, more: () => pageMore(id), rename,
|
|
464
|
+
BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', wrap: true, more: () => pageMore(id), rename, pop: o.pop || undefined,
|
|
464
465
|
discuss: () => X.ctx.newIn(id), discussHome: true, // the one view (OvViewers): Discuss starts a new session about it, where + New session was
|
|
465
466
|
// the kind of work (batch 29 item 11, KdV1-3): its glyph stands before Discuss; a tap opens the three kinds
|
|
466
467
|
presses: [WK.pressOf(kindNow(id))].concat(dh ? dh.presses() : []), onPress: (a, btn) => {
|
|
@@ -79,9 +79,22 @@ const one = (a, f) => { const v = a && a.fields && a.fields[f]; return v && !Arr
|
|
|
79
79
|
const list = (a, f) => { const v = a && a.fields && a.fields[f]; return Array.isArray(v) ? v.filter((x) => x && x.text) : []; };
|
|
80
80
|
const carried = (a, f) => ((a && a.carried) || []).filter((c) => c.field === f && c.text);
|
|
81
81
|
|
|
82
|
+
/** The prototype files a line of the experiment links (/api/lab/specimen?file=…), in its text or its sources. */
|
|
83
|
+
function linkedFiles(v) {
|
|
84
|
+
const out = [], refs = [String((v && v.text) || ''), ...((v && Array.isArray(v.sources) ? v.sources : []).map((x) => String((x && x.ref) || '')))];
|
|
85
|
+
for (const r of refs) for (const m of r.matchAll(/\/api\/lab\/specimen\?(?:[^\s)]*&)?file=([^&\s)]+)/g)) { try { out.push(decodeURIComponent(m[1])); } catch { /* not a file link */ } }
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
82
88
|
/** The Specimens row. rounds: GET /api/lab/rounds (newest first, open or not). With a round, the row names every version that landed and opens
|
|
83
89
|
* the compare view (lab: the round's id), so a round kept or closed too early stays reachable (2026-11-17). Without one, the artefact's words. */
|
|
84
|
-
function specimensRow(kept, tries, rounds) {
|
|
90
|
+
function specimensRow(kept, tries, rounds, removed) {
|
|
91
|
+
// a line that links a deleted version (GET /api/lab/rounds removed) is not a specimen any more: with every version deleted, no row
|
|
92
|
+
// (batch 31, Wawan 2026-11-18: "when no prototype saved (all removed) then there should be no specimen")
|
|
93
|
+
if (Array.isArray(removed) && removed.length) {
|
|
94
|
+
const out = (v) => linkedFiles(v).some((f) => removed.includes(f));
|
|
95
|
+
if (kept && out(kept)) kept = null;
|
|
96
|
+
tries = tries.filter((t) => !out(t));
|
|
97
|
+
}
|
|
85
98
|
const R = Array.isArray(rounds) && rounds.length ? rounds[0] : null;
|
|
86
99
|
// the initiative's prototype (2026-11-18: the line said "kept" for an old test round): its version, and it opens that version
|
|
87
100
|
if (R && R.current) return { key: 'specimens', label: 'Prototype', text: 'Version ' + R.current.n + (R.current.said ? ': ' + R.current.said : '') + (R.working ? ' · the next version is on the way' : ''), by: '', at: R.at || '', edit: null, lab: R.current.version || R.id };
|
|
@@ -96,7 +109,7 @@ function specimensRow(kept, tries, rounds) {
|
|
|
96
109
|
return null;
|
|
97
110
|
}
|
|
98
111
|
|
|
99
|
-
/** The Viewer's model. art: GET /api/artefacts answer for scope experiment:<id>; auto: GET /api/autonomy answer; o: { now, ahead, rounds }. */
|
|
112
|
+
/** The Viewer's model. art: GET /api/artefacts answer for scope experiment:<id>; auto: GET /api/autonomy answer; o: { now, ahead, rounds, removed }. */
|
|
100
113
|
export function agentModel(A, U, id, o = {}) {
|
|
101
114
|
const now = o.now || Date.now();
|
|
102
115
|
const X = art(A, 'experiment'), S = art(A, 'specimens'), T = art(A, 'done-test');
|
|
@@ -109,7 +122,7 @@ export function agentModel(A, U, id, o = {}) {
|
|
|
109
122
|
row('kill', 'Stop if', kill, { artefact: 'experiment', field: 'kill' }),
|
|
110
123
|
row('budget', 'Budget', budget, { artefact: 'experiment', field: 'budget' }),
|
|
111
124
|
ex ? { key: 'executor', label: 'Who builds', text: whoText(ex.text, factory), value: ex.text, by: ex.by || '', at: ex.at || '', edit: { artefact: 'experiment', field: 'executor', pick: picks(factory, ex.text) } } : null,
|
|
112
|
-
specimensRow(kept, tries, o.rounds),
|
|
125
|
+
specimensRow(kept, tries, o.rounds, o.removed),
|
|
113
126
|
checks.length ? { key: 'done', label: 'Done when', text: checks.map((c) => c.text).join(' · '), sub: result ? 'Result: ' + result.text : '', at: checks[checks.length - 1].at || '', edit: null } : null,
|
|
114
127
|
].filter(Boolean);
|
|
115
128
|
// the newest line Claude wrote dates the section: "Claude keeps it · 3 Nov"
|
|
@@ -243,7 +256,7 @@ export function want(ws, id, done, title) {
|
|
|
243
256
|
pmGet('/api/kind-control?' + q + 'ini=' + encodeURIComponent(id)).catch(() => null),
|
|
244
257
|
pmGet('/api/lab/rounds?' + q + 'initiative=' + encodeURIComponent(id)).catch(() => null)])
|
|
245
258
|
.then(([a, u, h, k, r]) => {
|
|
246
|
-
const M = agentModel(a && a.ok ? a : null, u && u.ok ? u : null, id, { ahead: h && h.ok ? h : null, rounds: r && r.ok ? r.rounds : null });
|
|
259
|
+
const M = agentModel(a && a.ok ? a : null, u && u.ok ? u : null, id, { ahead: h && h.ok ? h : null, rounds: r && r.ok ? r.rounds : null, removed: r && r.ok ? r.removed : null });
|
|
247
260
|
const C = k && k.ok && k.kind !== 'product' ? k : null;
|
|
248
261
|
const was = JSON.stringify([cached(id), cachedControl(id)]);
|
|
249
262
|
CACHE.set(id, { M, C, at: Date.now() });
|
|
@@ -435,6 +435,17 @@ export function wireView(body, h) {
|
|
|
435
435
|
if (!body) return;
|
|
436
436
|
const idOf = () => { const n = body.querySelector('[data-iv]'); return n ? n.dataset.iv : null; };
|
|
437
437
|
body.__iv = LK.wrap(VS.wrap(ED.writes({ ...h, __id: idOf }), body, (id) => SHOWN.get(id)), idOf);
|
|
438
|
+
// a prototype version deleted or brought back in the Viewer (pm/cozy-proto.js): this initiative reads its Specimens line and its
|
|
439
|
+
// Prototype & design fold again, so a deleted version leaves both at once (batch 31, 2026-11-18)
|
|
440
|
+
if (typeof window !== 'undefined') {
|
|
441
|
+
const onLab = (e) => {
|
|
442
|
+
if (!body.isConnected) { window.removeEventListener('pmos:lab-version', onLab); return; }
|
|
443
|
+
const id = idOf(); if (!id || !e.detail || e.detail.ini !== id) return;
|
|
444
|
+
IA.forget(id); IA.want(wsOf(), id, () => paintAgent(id));
|
|
445
|
+
const H = body.__iv || {}; if (H.reload) H.reload();
|
|
446
|
+
};
|
|
447
|
+
window.addEventListener('pmos:lab-version', onLab);
|
|
448
|
+
}
|
|
438
449
|
// the one blue ✦ after the title (pm/ini-props.js), drawn again with each draw of the initiative
|
|
439
450
|
const chip = () => { const id = idOf(); if (id && VIEWED.has(id)) PP.sync(VIEWED.get(id), body.__iv || {}); drafts(id); about(id); agent(id); fitMission(body); };
|
|
440
451
|
// agent-run (AwB): the experiment and Claude's work, read every 30 s at most; they draw alone (and the gate with them) when they change
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* (the same chat with the scope filled in), and Settings › Workflows' New workflow opens here too, so there is no second chat column.
|
|
9
9
|
*
|
|
10
10
|
* openCos({ here, ws? }) → true the chief-of-staff chat; here: the page's words for the chip ("Board · Atlas"), '' for none
|
|
11
|
-
* openTarget(t, o) → true any chat target (home-chat.js mountChat open), o: { title, url }
|
|
11
|
+
* openTarget(t, o) → true any chat target (home-chat.js mountChat open), o: { title, url }; while the popup shows, its chat
|
|
12
|
+
* box() → { el, chat } the chat for the popup's right side (cozy-popup.js)
|
|
12
13
|
*
|
|
13
14
|
* "Discuss in chat" on the Board's initiative or program panel opens the chat about that item in a Viewer of its own, beside the panel
|
|
14
15
|
* (1600 px and wider) or sliding over it (a laptop), through the panels engine (cozy-panels.js openBeside). The page stays where it is.
|
|
@@ -41,7 +42,7 @@ export function keyOf(it) {
|
|
|
41
42
|
export function targetOf(it, ws) {
|
|
42
43
|
const title = String((it && it.title) || 'this').slice(0, 80);
|
|
43
44
|
return { key: keyOf(it), ws: ws || undefined, title, about: title, scope: { text: title, icon: FLAG }, role: CLAUDE, rich: false,
|
|
44
|
-
placeholder: 'Message PMOS about ' + title, empty: 'Ask about ' + title + '. PMOS reads its records and works in a real
|
|
45
|
+
placeholder: 'Message PMOS about ' + title, empty: 'Ask about ' + title + '. PMOS reads its records and works on it in a real session.' };
|
|
45
46
|
}
|
|
46
47
|
/** Home's own address for the same conversation (⋯ › Open in a new tab). */
|
|
47
48
|
const homeHref = (it, key) => '/premium.html?' + new URLSearchParams({ about: key, label: String(it.title || '').slice(0, 80) }).toString();
|
|
@@ -82,16 +83,27 @@ export function cosTarget(here, ws) {
|
|
|
82
83
|
scope: h ? { text: 'You are on ' + h, icon: PIN, drop: true } : { text: 'Everything', icon: GLOBE }, context: h || undefined,
|
|
83
84
|
placeholder: 'Ask or tell PMOS', empty: 'Ask anything about your work. I read it with PMOS and say where each answer came from.' };
|
|
84
85
|
}
|
|
85
|
-
/** The chief-of-staff chat over this page (the menu's chat icon). here: "Board · Atlas"; × on the chip drops it.
|
|
86
|
-
|
|
86
|
+
/** The chief-of-staff chat over this page (the menu's chat icon). here: "Board · Atlas"; × on the chip drops it. On a desk it opens in the
|
|
87
|
+
* one popup (cozy-popup.js, slice 2 of the six-place navigation) with the list of sessions beside it; a phone keeps the chat's sheet. */
|
|
88
|
+
export async function openCos(o = {}) {
|
|
89
|
+
if (!isPhone()) { const P = await import('./cozy-popup.js'); return P.openCos(cosTarget(o.here, o.ws)); }
|
|
87
90
|
return openTarget(cosTarget(o.here, o.ws), { title: 'Ask PMOS', url: '/premium.html' });
|
|
88
91
|
}
|
|
92
|
+
const isPhone = () => typeof innerWidth === 'number' && innerWidth <= 760;
|
|
93
|
+
/** The chat itself for the popup (cozy-popup.js): mounted once, the same element and conversation reader as the chat panel. */
|
|
94
|
+
export async function box() {
|
|
95
|
+
sheets();
|
|
96
|
+
const M = await mod();
|
|
97
|
+
if (!Q.el) { Q.el = document.createElement('section'); Q.el.className = 'hm-chat pc-chat'; Q.el.setAttribute('aria-label', 'Conversation'); Q.chat = M.mountChat(Q.el, host()); }
|
|
98
|
+
return { el: Q.el, chat: Q.chat };
|
|
99
|
+
}
|
|
89
100
|
export async function openChat(it, o = {}) {
|
|
90
101
|
const key = keyOf(it); if (!key) return false;
|
|
91
102
|
return openTarget(targetOf(it, o.ws), { title: targetOf(it, o.ws).title, url: homeHref(it, key) });
|
|
92
103
|
}
|
|
93
104
|
export async function openTarget(t, o = {}) {
|
|
94
105
|
if (!t || !t.key) return false;
|
|
106
|
+
if (VW.popOpen()) { const P = await import('./cozy-popup.js'); return P.chatTo(t); } // the popup shows: its chat changes, the work stays
|
|
95
107
|
sheets();
|
|
96
108
|
const M = await mod();
|
|
97
109
|
if (!Q.el) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* pm/pop-sessions.js — the sessions of the popup's chat (slice 2 of the six-place navigation, boards 3, 7 and 23). Pure: no DOM, no fetch,
|
|
2
|
+
* so Node tests it.
|
|
3
|
+
*
|
|
4
|
+
* sessionRows(list, { titleOf(ini) → name | '', now }) → { now: [row], earlier: [row], all: [row] }
|
|
5
|
+
* list is GET /api/sessions .sessions. Now: live sessions. Earlier: ended ones (a chat that ended stays as Earlier, newest run only, and
|
|
6
|
+
* never beside its live run). Newest first in each. A PMOS-started session that asks nothing, and a start shell, are not listed (as Home).
|
|
7
|
+
* row: { id, key, ini, ws, name, work, state: 'wait'|'work'|'', word, live, at }
|
|
8
|
+
* work the name of the work it is about, or "No work"
|
|
9
|
+
* state 'wait' (it waits for you), 'work' (PMOS is working), '' (idle or ended)
|
|
10
|
+
* word "Waits for you", "PMOS is working", or when it was last used ("14:05", "Yesterday", "Mon", "12 Nov")
|
|
11
|
+
* pickSession(rows) → the row the chat icon opens: the newest that waits for you, else the newest live, else the newest; null for none
|
|
12
|
+
* recent(rows, n) → the chooser's rows: the newest n of all, live ones first
|
|
13
|
+
* nextKey(base, list) → base + ':' + the first free number from 2 (a new session about the same work, as Home's newIn)
|
|
14
|
+
* timeWord(iso, now) → the last-used word */
|
|
15
|
+
import { keyOfSession, iniOfSession, nameOf, startShell } from './home-data.js';
|
|
16
|
+
|
|
17
|
+
const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
18
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
19
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
20
|
+
const ended = (s) => s.shown === 'exited' || s.state === 'exited';
|
|
21
|
+
const atOf = (s) => String(s.touched_at || s.last || s.updated || s.created || '');
|
|
22
|
+
const t = (iso) => { const n = Date.parse(iso || ''); return Number.isNaN(n) ? 0 : n; };
|
|
23
|
+
|
|
24
|
+
export function timeWord(iso, now = Date.now()) {
|
|
25
|
+
const d = new Date(iso); if (Number.isNaN(d.getTime())) return '';
|
|
26
|
+
const n = new Date(now), y = new Date(now); y.setDate(n.getDate() - 1);
|
|
27
|
+
if (d.toDateString() === n.toDateString()) return pad(d.getHours()) + ':' + pad(d.getMinutes());
|
|
28
|
+
if (d.toDateString() === y.toDateString()) return 'Yesterday';
|
|
29
|
+
if (now - d.getTime() < 6 * 86400000 && d.getTime() <= now) return DOW[d.getDay()];
|
|
30
|
+
return d.getDate() + ' ' + MON[d.getMonth()];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function sessionRows(list, { titleOf = () => '', now = Date.now() } = {}) {
|
|
34
|
+
const L = (Array.isArray(list) ? list : []).filter((s) => s && s.id && !startShell(s) && !s.away)
|
|
35
|
+
// a session PMOS started is listed only while it works or asks you something (Home's rule, home-data.js homeSessions)
|
|
36
|
+
.filter((s) => !(s.automatic && (ended(s) || s.shown === 'needs' || s.shown === 'quiet') && !s.ask));
|
|
37
|
+
const liveKeys = new Set(L.filter((s) => !ended(s)).map(keyOfSession).filter(Boolean));
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
const rows = [];
|
|
40
|
+
for (const s of L.slice().sort((a, b) => t(atOf(b)) - t(atOf(a)))) {
|
|
41
|
+
const key = keyOfSession(s), live = !ended(s);
|
|
42
|
+
if (!live && key && (liveKeys.has(key) || seen.has(key))) continue; // one row per conversation: its live run, else its newest ended run
|
|
43
|
+
if (!live && !key && !s.headless && s.agent === 'shell') continue; // an ended terminal shell has nothing to go back to
|
|
44
|
+
if (key) seen.add(key);
|
|
45
|
+
const ini = iniOfSession(s);
|
|
46
|
+
const state = live && (s.shown === 'needs' || s.shown === 'blocked' || s.ask) ? 'wait' : live && s.shown === 'working' ? 'work' : '';
|
|
47
|
+
const at = atOf(s);
|
|
48
|
+
rows.push({ id: s.id, key, ini, ws: s.ws || '', name: nameOf(s) || 'Session', work: (ini && titleOf(ini)) || (ini ? ini : 'No work'), state, live,
|
|
49
|
+
word: state === 'wait' ? 'Waits for you' : state === 'work' ? 'PMOS is working' : timeWord(at, now), at });
|
|
50
|
+
}
|
|
51
|
+
const nowRows = rows.filter((r) => r.live), earlier = rows.filter((r) => !r.live);
|
|
52
|
+
return { now: nowRows, earlier, all: nowRows.concat(earlier) };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function pickSession(rows) {
|
|
56
|
+
const L = Array.isArray(rows) ? rows : [];
|
|
57
|
+
return L.find((r) => r.state === 'wait') || L.find((r) => r.live) || L[0] || null;
|
|
58
|
+
}
|
|
59
|
+
export const recent = (rows, n = 5) => (Array.isArray(rows) ? rows : []).slice(0, n);
|
|
60
|
+
|
|
61
|
+
export function nextKey(base, list) {
|
|
62
|
+
const used = new Set((Array.isArray(list) ? list : []).map(keyOfSession).filter(Boolean));
|
|
63
|
+
let n = 2; while (used.has(base + ':' + n)) n++;
|
|
64
|
+
return base + ':' + n;
|
|
65
|
+
}
|
|
@@ -40,6 +40,7 @@ import * as PG from './bd-prog.js';
|
|
|
40
40
|
import { programOf, liveRows } from './program-model.js';
|
|
41
41
|
import { open as viewerOpen, current as viewerCur } from './cozy-viewer.js';
|
|
42
42
|
import * as VW from './cozy-viewer.js';
|
|
43
|
+
import * as POP from './cozy-popup.js'; // the one popup: an initiative and Ask PMOS side by side (slice 2 of the six-place navigation)
|
|
43
44
|
import { mountPanels } from './cozy-panels.js';
|
|
44
45
|
import * as PP from './bd-prog-panel.js';
|
|
45
46
|
import * as PO from './prog-order.js';
|
|
@@ -106,6 +107,9 @@ mountPanels({ page: document.getElementById('stage'), key: 'board', sources: BP2
|
|
|
106
107
|
VW.chatHere((it) => { const r = M && (M.rows || []).find((x) => x.id === it.id); import('./page-chat.js').then((C) => C.openChat(it, { ws: (r && r.ws) || (M && M.board.ws) || undefined })); return true; });
|
|
107
108
|
document.addEventListener('cz:chat-turn', () => { clearTimeout(chatT); chatT = setTimeout(() => load(), 400); });
|
|
108
109
|
let chatT = null;
|
|
110
|
+
// the popup's sessions name the work they are about, and the chat icon opens a session's initiative here, in the popup
|
|
111
|
+
POP.setTitles((id) => { const r = M && ((M.rows || []).find((x) => x.id === id) || goneRows().find((x) => x.id === id)); return r ? r.title : ''; });
|
|
112
|
+
POP.setOpener((id) => { openIniId(id); });
|
|
109
113
|
// a product head's goal dots (PgBoard .gd) count that product's open initiatives, the way Home's product header does
|
|
110
114
|
PG.goalsFrom((name) => (M ? M.initiatives.list.rows.filter((r) => !M.board.all || r.product === name) : null));
|
|
111
115
|
const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
@@ -217,11 +221,11 @@ function shownPick() {
|
|
|
217
221
|
}
|
|
218
222
|
function drawPick() {
|
|
219
223
|
const P = shownPick(), host = $('#crumbHost'); if (!host) return;
|
|
220
|
-
host.innerHTML = P ? PK.chipHtml(P, { id: 'bdPick', label: 'Products' }) : `<span class="crpg">${esc(M.board.name || 'Board')}</span>`;
|
|
224
|
+
host.innerHTML = P ? PK.chipHtml(P, { id: 'bdPick', label: 'Products', names: !matchMedia('(max-width: 760px)').matches }) : `<span class="crpg">${esc(M.board.name || 'Board')}</span>`;
|
|
221
225
|
const chip = $('#bdPick'); if (!chip) return;
|
|
222
226
|
// a product's line: its open initiatives on this page (zero is silence)
|
|
223
227
|
const lines = (ws) => { const rows = (M.initiatives.list.rows || []).filter((r) => (M.board.all ? r.ws === ws : M.board.ws === ws)); return rows.length ? rows.length + (rows.length === 1 ? ' initiative' : ' initiatives') : ''; };
|
|
224
|
-
chip.onclick = (e) => { e.stopPropagation(); PK.openPicker(chip, { P: shownPick(), label: 'Products', lines, note: 'One pick for
|
|
228
|
+
chip.onclick = (e) => { e.stopPropagation(); PK.openPicker(chip, { P: shownPick(), label: 'Products', lines, note: 'One pick for Today, Work and Goals: unticking a product here also takes it off Today.', onApply: async (on) => { const r = await PK.savePick(on); if (!r.ok) say(r.error); } }); };
|
|
225
229
|
}
|
|
226
230
|
// a saved pick (this chip, or Settings): the Board opens on the ticked products, without a one-off link's ws or board
|
|
227
231
|
addEventListener('pp:changed', () => { const q = new URLSearchParams(location.search); ['ws', 'board', 'all', 'pick'].forEach((k) => q.delete(k)); const s = q.toString(); location.assign(location.pathname + (s ? '?' + s : '')); });
|
|
@@ -960,7 +964,7 @@ document.addEventListener('bd:links', (e) => { if (!SH_FULL && e.detail) setShar
|
|
|
960
964
|
if (pb) pb.onclick = () => { if (M && !ALL && M.board.ws) import('./bd-publish.js').then((P) => P.open($('#moreBtn'), { ws: M.board.ws, board: M.board.id || M.board.ws, view })); };
|
|
961
965
|
}
|
|
962
966
|
window.addEventListener('keydown', (e) => {
|
|
963
|
-
if (e.key !== 'Escape' || document.querySelector('.pv-ov:not([hidden]), #moreMenu:not([hidden]), #crMenu:not([hidden]), #czMenu:not([hidden]), #bdPop:not([hidden])')) return;
|
|
967
|
+
if (e.key !== 'Escape' || document.querySelector('.pv-ov:not([hidden]), #moreMenu:not([hidden]), #crMenu:not([hidden]), #czMenu:not([hidden]):not(.ev-rail), #bdPop:not([hidden])')) return;
|
|
964
968
|
if ($$('.bd-pop').some((p) => !p.hidden)) closePops(true); // the shell closes itself on Escape (cozy-viewer.js)
|
|
965
969
|
}, true);
|
|
966
970
|
|
|
@@ -49,6 +49,18 @@ import * as GC from './goals-clear.js';
|
|
|
49
49
|
import * as LAB from './cozy-lab-ins.js'; // Intelligence › Lab (idle lab B+C, canvas I1 IlBC): what fits no initiative, the week's background record, next time
|
|
50
50
|
import * as FCV from './goal-forecast.js'; // a goal's forecast in its Viewer (FcViewer, FcPhone): the state line, the range band, the baseline ✓ // goals made clear (batch 18 item 11, 11-B): the drafts table, the check panel, first readings, failed and held
|
|
51
51
|
import { provenStatus } from './status-proof.js'; // T3: an initiative's status word renders only with its source and read time
|
|
52
|
+
import * as POP from './cozy-popup.js'; // the one popup (slice 2 of the six-place navigation): an initiative opens in it with Ask PMOS beside it
|
|
53
|
+
/* An initiative's link (a goal's "Moved by", the outcomes table, a step) opens the initiative in the one popup on a desk, read the way the
|
|
54
|
+
* Viewer reads it (premium-vw-item.js), with Ask PMOS about it on the right. ⌘/Ctrl-click, a middle click and a phone keep the link. */
|
|
55
|
+
document.addEventListener('click', (e) => {
|
|
56
|
+
const a = e.target.closest && e.target.closest('a[href^="/premium-initiative.html"]');
|
|
57
|
+
if (!a || e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || innerWidth <= 760) return;
|
|
58
|
+
const u = new URL(a.getAttribute('href'), location.origin), id = u.searchParams.get('id'); if (!id) return;
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
const ws = u.searchParams.get('ws') || '', t = a.querySelector('.n, b'), title = String((t || a).textContent || '').trim();
|
|
61
|
+
POP.openWork({ about: { id, kind: 'initiative', title, ws: ws || undefined },
|
|
62
|
+
open: () => import('./premium-vw-item.js').then((M) => M.openWorkItem({ kind: 'initiative', id, ws, title: title || undefined })) });
|
|
63
|
+
});
|
|
52
64
|
|
|
53
65
|
let M = null; // the model
|
|
54
66
|
let BM = null, bmErr = ''; // the Board measures (Delivery trends)
|
|
@@ -201,11 +213,11 @@ function shownPick() {
|
|
|
201
213
|
}
|
|
202
214
|
function drawPick() {
|
|
203
215
|
const P = shownPick(), host = $('#prodHost');
|
|
204
|
-
host.innerHTML = P ? PK.chipHtml(P, { id: 'prodPick', label: 'Products' }) : `<span class="ins-ttl">${esc(M.board.name || 'Intelligence')}</span>`;
|
|
216
|
+
host.innerHTML = P ? PK.chipHtml(P, { id: 'prodPick', label: 'Products', names: !matchMedia('(max-width: 760px)').matches }) : `<span class="ins-ttl">${esc(M.board.name || 'Intelligence')}</span>`;
|
|
205
217
|
const chip = $('#prodPick'); if (!chip) return;
|
|
206
218
|
// a product's line: its goals, from what this page read (zero is silence)
|
|
207
219
|
const lines = (ws) => { const n = PF ? PF.goals.filter((g) => g.ws === ws).length : ws === M.board.ws ? M.goals.length : 0; return n ? nGoals(n) : ''; };
|
|
208
|
-
chip.onclick = (e) => { e.stopPropagation(); closeMenus(); PK.openPicker(chip, { P: shownPick(), label: 'Products', lines, note: 'One pick for
|
|
220
|
+
chip.onclick = (e) => { e.stopPropagation(); closeMenus(); PK.openPicker(chip, { P: shownPick(), label: 'Products', lines, note: 'One pick for Today, Work and Goals: unticking a product here also takes it off Today.', onApply: async (on) => { const r = await PK.savePick(on); if (!r.ok) toast(r.error); } }); };
|
|
209
221
|
}
|
|
210
222
|
// a saved pick (this chip, or Settings): Insights opens on the ticked products, without a one-off link's ws or board
|
|
211
223
|
addEventListener('pp:changed', () => { const q = new URLSearchParams(location.search); ['ws', 'board'].forEach((k) => q.delete(k)); const s = q.toString(); location.assign(location.pathname + (s ? '?' + s : '')); });
|
|
@@ -937,7 +937,7 @@ export function wireCrumb(o) {
|
|
|
937
937
|
const SRCH = '<svg class="i" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg>';
|
|
938
938
|
const IC = (d) => `<svg class="i" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
|
|
939
939
|
const GL = { place: IC('M4 5h16v14H4zM4 10h16'), ini: IC('M12 3l9 9-9 9-9-9z'), doc: IC('M6 3h9l4 4v14H6zM14 3v5h5'), ses: IC('M5 4l14 8-14 8z'), need: IC('M12 4v10M12 18v2') };
|
|
940
|
-
const PLACES = [['
|
|
940
|
+
const PLACES = [['Today', '/premium.html'], ['Work', '/premium-board.html'], ['Goals', '/premium-intelligence.html']]; // the places' names since slice 1 of the six places
|
|
941
941
|
const PV_WS = new URLSearchParams(location.search).get('ws');
|
|
942
942
|
const pvQ = (sep) => (PV_WS ? sep + 'ws=' + encodeURIComponent(PV_WS) : '');
|
|
943
943
|
async function pvGet(u) { try { const r = await fetch(u, { credentials: 'same-origin' }); return { status: r.status, j: await r.json() }; } catch { return { status: 0, j: null }; } }
|