create-pmos 0.440.0 → 0.442.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 +25 -25
- 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/adler-seasons-art-test.js +106 -0
- package/workspace/adler-seasons-test.js +111 -0
- package/workspace/briefing-premium-adddoc-test.js +16 -13
- package/workspace/briefing-premium-board-test.js +19 -17
- package/workspace/briefing-premium-initiative-test.js +7 -4
- package/workspace/briefing-premium-products-test.js +4 -4
- package/workspace/briefing-premium-sources-test.js +2 -2
- package/workspace/briefing-premium-test.js +29 -23
- package/workspace/changelog.json +24 -0
- package/workspace/guide/adler.md +10 -0
- package/workspace/guide/core-documents.md +2 -2
- package/workspace/guide/data-freshness.md +7 -5
- package/workspace/guide/home.md +3 -1
- package/workspace/guide/horizon-scan.md +1 -1
- package/workspace/ini-workflow-test.js +6 -2
- package/workspace/lib/agent-inbox.js +20 -2
- package/workspace/lib/briefing-premium-sources.js +3 -0
- package/workspace/lib/briefing-premium.js +37 -7
- package/workspace/lib/driver-cli.js +1 -1
- package/workspace/lib/driver-run.js +15 -1
- package/workspace/lib/driver.js +31 -2
- package/workspace/lib/news-for-you.js +24 -9
- package/workspace/lib/pm-idle.js +12 -0
- package/workspace/lib/refresh.js +17 -8
- package/workspace/lib/routes-core-docs.js +1 -1
- package/workspace/lib/routes-news.js +15 -1
- package/workspace/lib/routes-phone-day.js +6 -4
- package/workspace/lib/settings-store.js +38 -0
- package/workspace/metric-drafts-ui-test.js +2 -2
- package/workspace/need-shot.js +57 -0
- package/workspace/news-viewers-test.js +183 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +2 -1
- package/workspace/premium-chat-attach-test.js +2 -0
- package/workspace/premium-core-doc-issue-test.js +9 -8
- package/workspace/program-panel-test.js +1 -1
- package/workspace/public/pm/bd-ini-panel.js +6 -13
- package/workspace/public/pm/c3-ini-ui.js +1 -1
- package/workspace/public/pm/cozy-adler.css +21 -0
- package/workspace/public/pm/cozy-adler.js +415 -8
- package/workspace/public/pm/cozy-ev.css +44 -0
- package/workspace/public/pm/cozy-home.css +8 -0
- package/workspace/public/pm/cozy-news.js +186 -22
- package/workspace/public/pm/cozy-seasons.js +318 -0
- package/workspace/public/pm/cozy-settings.js +88 -5
- package/workspace/public/pm/cozy-today.css +5 -0
- package/workspace/public/pm/cozy-viewer.js +12 -7
- package/workspace/public/pm/cozy-vw-shell.css +49 -0
- package/workspace/public/pm/cozy.css +65 -0
- package/workspace/public/pm/dash-view.js +4 -2
- package/workspace/public/pm/home-adddoc.js +46 -26
- package/workspace/public/pm/home-app.js +142 -114
- package/workspace/public/pm/home-chat.js +1 -1
- package/workspace/public/pm/home-day.js +17 -9
- package/workspace/public/pm/home-draft.js +35 -23
- package/workspace/public/pm/home-ini.js +4 -4
- package/workspace/public/pm/home-mentions.js +1 -1
- package/workspace/public/pm/home-need.js +336 -0
- package/workspace/public/pm/home-today.js +2 -2
- package/workspace/public/pm/home-work.js +51 -4
- package/workspace/public/pm/impact.js +1 -1
- package/workspace/public/pm/ini-groups.js +15 -10
- package/workspace/public/pm/ini-links.js +1 -1
- package/workspace/public/pm/ini-tasks.js +208 -44
- package/workspace/public/pm/ini-view-model.js +8 -2
- package/workspace/public/pm/ini-view.css +305 -1
- package/workspace/public/pm/ini-view.js +190 -80
- package/workspace/public/pm/mission.js +234 -0
- package/workspace/public/pm/premium-board.js +1 -1
- package/workspace/public/pm/premium-welcome.js +2 -2
- package/workspace/public/pm/small-vw.js +128 -0
- package/workspace/public/pm/split-merge.js +1 -1
- package/workspace/public/pm/stage-line.js +2 -2
- package/workspace/server.js +10 -6
- package/workspace/skills/initiative-drive.skill +4 -1
- package/workspace/split-merge-ui-test.js +1 -1
- package/workspace/stage-card-test.js +48 -11
- package/workspace/task-links-test.js +2 -0
- package/workspace/task-milestones-test.js +5 -1
- package/workspace/task-plans-test.js +3 -3
- package/workspace/task-views-test.js +90 -37
- package/workspace/test-lists/adler-seasons-art.json +13 -0
- package/workspace/test-lists/batch18-adler-seasons.json +13 -0
- package/workspace/test-lists/batch18-asks.json +5 -0
- package/workspace/test-lists/mission.json +5 -0
- package/workspace/test-lists/news-viewers.json +13 -0
- package/workspace/test-lists/small-viewers.json +5 -0
- package/workspace/test-lists/viewer-tasks.json +5 -0
- package/workspace/tk-tasks-test.js +25 -30
|
@@ -18,6 +18,7 @@ import { mountNav } from './cozy-nav.js';
|
|
|
18
18
|
import { mountLivePill } from './cozy-live-pill.js';
|
|
19
19
|
import { ownTab, bring, tabUrl } from './rec-tab-core.js';
|
|
20
20
|
import * as VW from './cozy-viewer.js';
|
|
21
|
+
import * as SV from './small-vw.js'; // the small Viewers: a stakeholder, its form, a routine (batch 18 item 2-C)
|
|
21
22
|
import { pmGet, pmPost, pmHeaders } from './http.js';
|
|
22
23
|
import * as H from './home-data.js';
|
|
23
24
|
import { mountChat, avHtml } from './home-chat.js';
|
|
@@ -31,6 +32,7 @@ import { iniView } from './ini-view-model.js'; // the one initiative view (bat
|
|
|
31
32
|
import { rowFor } from './ini-versions.js'; // planned versus actual (batch 11 item 8): Live or the draft the PM shows, with the plan line
|
|
32
33
|
import { programOf } from './program-model.js';
|
|
33
34
|
import { startAgent } from './page-agent.js';
|
|
35
|
+
import * as NEED from './home-need.js'; // the asks in the Viewer: start, decision, waited, source (batch 18 item 2-A)
|
|
34
36
|
import { mdHtml } from './chat-md.js';
|
|
35
37
|
import { mountPhoneCard } from './home-phone-card.js';
|
|
36
38
|
import { mountFirst } from './premium-first.js';
|
|
@@ -201,6 +203,7 @@ async function load() {
|
|
|
201
203
|
S.ready = true;
|
|
202
204
|
await loadIni();
|
|
203
205
|
draw();
|
|
206
|
+
NEED.refresh(); // an open ask: its agent finished, or it left Home while it was open
|
|
204
207
|
loadImpact();
|
|
205
208
|
readImpact();
|
|
206
209
|
// the boards of the other products Home reads, each its own closed group: read after the list is drawn, so a slow one never holds it up
|
|
@@ -245,7 +248,7 @@ function poll() {
|
|
|
245
248
|
if (ses && Array.isArray(ses.sessions)) S.D.sessions = H.homeSessions(ses.sessions);
|
|
246
249
|
if (desk && desk.ok) S.D.desk = desk;
|
|
247
250
|
S.D.now = Date.now();
|
|
248
|
-
drawList(); drawTop();
|
|
251
|
+
drawList(); drawTop(); NEED.refresh();
|
|
249
252
|
}
|
|
250
253
|
poll();
|
|
251
254
|
}, 8000);
|
|
@@ -314,7 +317,7 @@ function homeListHtml() {
|
|
|
314
317
|
* marks all seen. An item leaves once it is opened or marked seen. */
|
|
315
318
|
function dayHtml() { return ''; }
|
|
316
319
|
function dayParts() {
|
|
317
|
-
const Y = YD.dayModel(S.M, S.D, L.reviewModel(S.D, NOW()), NOW(), { delightOk: !!S.joyOk, news: S.news, sources: S.src && S.src.sources, ask: MEN.dayAskOf(S.D) });
|
|
320
|
+
const Y = YD.dayModel(S.M, S.D, L.reviewModel(S.D, NOW()), NOW(), { delightOk: !!S.joyOk, news: S.news, sources: S.src && S.src.sources, ask: MEN.dayAskOf(S.D), dress: AD.dress() });
|
|
318
321
|
return { Y, P: YD.dayParts(Y, { moment: !!(isPhone() && PHC), now: NOW(), first: !!S.first }) };
|
|
319
322
|
}
|
|
320
323
|
function drawDayBody(body, P) {
|
|
@@ -354,8 +357,11 @@ function day(on) {
|
|
|
354
357
|
presses: [{ act: 'cal', label: 'Open the calendar', icon: 'cal' }], onPress: (act) => { if (act === 'cal') openCalendar(); },
|
|
355
358
|
onClose: () => { S.day = false; },
|
|
356
359
|
render: (body) => {
|
|
357
|
-
|
|
360
|
+
// ← back from a row's Viewer draws the day as it is now (a draft the PM is done with has left Drafted for you, batch 18 item 2)
|
|
361
|
+
if (body.dataset.ydDrawn) { const f = dayParts(); S.Y = f.Y; drawDayBody(body, f.P); } else { body.dataset.ydDrawn = '1'; drawDayBody(body, P); }
|
|
358
362
|
if (isPhone()) mountPull(body, { read: rereadDay, label: 'Reading your day again' });
|
|
363
|
+
// dressed for the season (batch 18 item 8-B, AsSet2Tap): a press on the dressed scene says why; no toast says he dressed up
|
|
364
|
+
AD.mountDressTip(body, { post: pmPost, say: toast, openSettings: (sec) => import('./cozy-settings.js').then((M) => M.openSettings(sec)) });
|
|
359
365
|
body.onclick = (e) => { // the rows are the list's own rows: the same presses open them
|
|
360
366
|
const b = e.target.closest('button'); if (!b) return;
|
|
361
367
|
if (b.dataset.hmSel) { if (b.dataset.hmSel === 'n:update' && !rowById('n:update')) openUpdateViewer(); else select(b.dataset.hmSel); return; }
|
|
@@ -412,6 +418,7 @@ function newsIn(r) {
|
|
|
412
418
|
if (r.count !== was) { drawList(); redrawDay(); }
|
|
413
419
|
}
|
|
414
420
|
document.addEventListener('cz:news-for-you', (e) => { if (e.detail && e.detail.ok) newsIn(e.detail); });
|
|
421
|
+
document.addEventListener('adler:dressed', () => { if (S.day) redrawDay(); }); // he dresses (or undresses: "Not this one") while Your day is open
|
|
415
422
|
/** ✓✓ in the New for you fold: every item is marked seen (POST /api/news-for-you/seen), so the fold goes. */
|
|
416
423
|
async function daySeen(b) {
|
|
417
424
|
const ids = YD.newsOf(S.news).map((x) => x.id); if (!ids.length || b.disabled) return;
|
|
@@ -460,7 +467,10 @@ function iniViewOf(id) {
|
|
|
460
467
|
const need = H.needsOf(S.D).find((r) => r.ini === id);
|
|
461
468
|
const p = programOf(S.D.programs || [], row.ws || (B.board || {}).ws || '', id);
|
|
462
469
|
return iniView(rowFor({ ...row, trail: t || row.trail || null }), { steps: B.steps || STEPS, today: B.today, usual: WFM.usualOf(S.D.trail, row),
|
|
463
|
-
ask: need ? { title: need.name } : null, program: p ? { id: p.id, title: p.title } : null
|
|
470
|
+
ask: need ? { title: need.name, n: H.needsOf(S.D).filter((r) => r.ini === id).length } : null, program: p ? { id: p.id, title: p.title } : null,
|
|
471
|
+
// the card (batch 18 item 1): Claude's line while a session works on it, the stakeholders
|
|
472
|
+
claude: (() => { const w = S.D.sessions.find((s) => H.iniOfSession(s) === id && s.shown === 'working'); return w ? 'I’m working on “' + H.nameOf(w) + '”. I’ll say here when it is ready.' : ''; })(),
|
|
473
|
+
people: (((S.D.desk && S.D.desk.stakeholders) || {})[id] || []) });
|
|
464
474
|
}
|
|
465
475
|
/** An initiative no board Home reads holds (its own read only, GET /api/initiative-premium): the row the one view needs, from that read. */
|
|
466
476
|
function imRowOf(id) {
|
|
@@ -757,53 +767,15 @@ function alsoOf(ini) {
|
|
|
757
767
|
const n = ini ? other.find((r) => r.ini === ini) : other[0];
|
|
758
768
|
return n ? { text: n.name, go: () => select(n.id) } : null;
|
|
759
769
|
}
|
|
760
|
-
/*
|
|
761
|
-
*
|
|
762
|
-
function decisionCard(r) {
|
|
763
|
-
const d = r.row.dialog || {};
|
|
764
|
-
const st = S.rec[r.key] || (S.rec[r.key] = { choice: d.sel || null, why: '', ret: null, note: '' });
|
|
765
|
-
if (st.whyShown == null) st.whyShown = st.why;
|
|
766
|
-
const ok = () => !!st.choice && st.why.trim().length >= 3;
|
|
767
|
-
return {
|
|
768
|
-
html: () => `<div class="ut-card ut-dec" role="group" aria-label="Your decision"><p class="ut-lbl">Your decision</p><div role="radiogroup" aria-label="Choices">${(d.opts || []).map((o) => `<button type="button" class="ut-radio" role="radio" aria-checked="${st.choice === o.k}" data-dc-opt="${esc(o.k)}"><span class="o" aria-hidden="true"></span><span><b>${esc(o.t)}</b>${o.d ? `<br><span class="ut-small ut-mut">${esc(o.d)}</span>` : ''}</span></button>`).join('')}</div>`
|
|
769
|
-
+ `<div class="ut-field"><label for="dcWhy">Why <span class="ut-mut">· kept in the journal</span></label><textarea id="dcWhy" rows="2" placeholder="The reason goes in pm-decisions.md with your choice">${esc(st.whyShown)}</textarea></div>`
|
|
770
|
-
+ `<div class="ut-acts"><button type="button" class="ut-btn pri" data-dc-rec${ok() ? '' : ' disabled'}>Record</button><button type="button" class="ut-btn" data-dc-later aria-haspopup="menu">Later${TD.svg(TD.P.chevD, 14)}</button>`
|
|
771
|
-
+ `<button type="button" class="ut-ib${S.pin.has(r.key) ? ' on' : ''}" data-dc-pin aria-pressed="${S.pin.has(r.key)}" aria-label="${S.pin.has(r.key) ? 'Unpin' : 'Pin to the top'}" title="${S.pin.has(r.key) ? 'Unpin' : 'Pin to the top'}">${TD.svg(TD.P.pin, 16)}</button><span class="sp">Nothing changes until you press Record</span></div>`
|
|
772
|
-
+ '<p class="ut-small ut-mut" role="status" id="dcMsg"></p></div>',
|
|
773
|
-
input: (t, card) => { if (t.id !== 'dcWhy') return; st.why = t.value; const b = card.querySelector('[data-dc-rec]'); if (b) b.disabled = !ok(); },
|
|
774
|
-
press: async (b) => {
|
|
775
|
-
st.whyShown = st.why; // a redraw after a press keeps what was typed; typing itself never changes the card's html
|
|
776
|
-
const say = (m) => { const el = document.getElementById('dcMsg'); if (el) el.textContent = m; };
|
|
777
|
-
if (b.dataset.dcOpt) { st.choice = b.dataset.dcOpt; return true; }
|
|
778
|
-
if ('dcPin' in b.dataset) { if (S.pin.has(r.key)) S.pin.delete(r.key); else S.pin.add(r.key); store.set('pmos.home.pin', JSON.stringify([...S.pin])); drawList(); return true; }
|
|
779
|
-
if ('dcLater' in b.dataset) {
|
|
780
|
-
const at = new Date(NOW() + 3 * 3600000);
|
|
781
|
-
const put = async (until) => { const res = await bpPost('put-off', { key: r.key, until }); if (res.ok) { toast('Put off. It comes back by itself, and it is not counted as done.'); delete S.rec[r.key]; VW.close(); await load(); select(null); } else say(res.error); };
|
|
782
|
-
menu(b, [{ label: 'Later today', k: H.hm(at.toISOString()), go: () => put('later') }, { label: 'Tomorrow', k: '09:00', go: () => put('tomorrow') }, { label: 'Next week', k: 'Mon', go: () => put('nextweek') }], '');
|
|
783
|
-
return false;
|
|
784
|
-
}
|
|
785
|
-
if ('dcRec' in b.dataset) {
|
|
786
|
-
b.disabled = true;
|
|
787
|
-
const res = await bpPost('decide', { key: r.key, choice: st.choice, why: st.why });
|
|
788
|
-
if (!res.ok) { b.disabled = false; say(res.error); return false; }
|
|
789
|
-
delete S.rec[r.key];
|
|
790
|
-
toast('Recorded in pm-decisions.md.');
|
|
791
|
-
VW.close(); await load(); select(null);
|
|
792
|
-
}
|
|
793
|
-
return false;
|
|
794
|
-
},
|
|
795
|
-
};
|
|
796
|
-
}
|
|
770
|
+
/* An ask's conversation (batch 18 item 2-A, OvA10Desk): the Viewer holds the summary and the one verb, so the chat asks a question instead
|
|
771
|
+
* of saying it again. A decision's choices are pills that open the Viewer with that choice picked; it is recorded there. */
|
|
797
772
|
function needTarget(r) {
|
|
798
773
|
const row = r.row, d = row.dialog || {};
|
|
799
774
|
const pills = [];
|
|
800
|
-
|
|
801
|
-
if (!dec) for (const o of d.opts || []) pills.push({ label: o.t, primary: o.k === (d.prim || d.sel), go: () => { S.rec[r.key] = { ...(S.rec[r.key] || {}), choice: o.k }; openNeedViewer(r, true); } });
|
|
802
|
-
if (d.write && d.write.kind === 'start') pills.unshift({ label: 'Start the agent', primary: true, go: () => start(r) });
|
|
775
|
+
if (d.write && d.write.kind === 'decision') for (const o of d.opts || []) pills.push({ label: o.t, go: () => openNeedViewer(r, o.k) });
|
|
803
776
|
if (d.write && d.write.kind === 'return') pills.push({ label: 'Return it', go: () => openNeedViewer(r, true) });
|
|
804
|
-
if (!dec) pills.push({ label: 'Discuss', go: () => chat.focus() });
|
|
805
777
|
return { key: r.key, ini: r.ini, ws: WS || undefined, title: r.name, sub: r.hint || '', scope: scopeOf(r.ini), rich: rich(), role: CLAUDE,
|
|
806
|
-
intro: { role: CLAUDE, text: d.say || row.subject || row.title
|
|
778
|
+
intro: { role: CLAUDE, text: d.write && d.write.kind === 'return' ? (d.say || row.subject || row.title) : NEED.introOf(r), pills }, placeholder: 'Ask about ' + r.name, also: null };
|
|
807
779
|
}
|
|
808
780
|
function updateTarget() {
|
|
809
781
|
const U = H.weeklyUpdate(S.D, S.D.now);
|
|
@@ -1093,10 +1065,50 @@ function openBoardTask(t) {
|
|
|
1093
1065
|
rename: taskRenameOf,
|
|
1094
1066
|
}));
|
|
1095
1067
|
}
|
|
1068
|
+
/* Finished (batch 18 item 2, canvas OvA7Drafted): a draft of today's prep run, open to read. Summary first: when it finished and that nothing
|
|
1069
|
+
* was sent (a sent one says so), Claude's one line, ONE primary "Done with it" (it leaves Drafted for you: New for you's seen line,
|
|
1070
|
+
* fin:<date>:<id>), ↗ the draft's own page when it has one; the chat icon in the header asks Claude to change it in Home's chat. */
|
|
1071
|
+
const WHEN_OF = (iso) => { const t = Date.parse(iso || ''); if (!Number.isFinite(t)) return ''; const h = new Date(t).getHours(); return h < 12 ? 'this morning' : h < 17 ? 'this afternoon' : 'this evening'; };
|
|
1072
|
+
function finSummary(f) {
|
|
1073
|
+
const when = WHEN_OF(f.at);
|
|
1074
|
+
const line = f.status === 'sent' ? 'Sent' + (when ? ' · ' + when : '') : f.status === 'review' ? 'Ready for you at your desk' : 'Finished' + (when ? ' · ' + when : '');
|
|
1075
|
+
const meta = f.status === 'sent' ? '' : 'Nothing is sent. It stays on this machine.';
|
|
1076
|
+
return VW.czSummary({ line, tone: 'ok', text: f.summary && f.body ? '' : f.summary || '', meta, primary: f.key ? { label: 'Done with it', act: 'fin-done' } : null,
|
|
1077
|
+
also: HTTPS.test(f.link || '') ? [{ act: 'fin-open', label: 'Open it', icon: 'M14 4h6v6M20 4l-9 9M18 14v5H5V6h5' }] : [] });
|
|
1078
|
+
}
|
|
1096
1079
|
function openFinished(f) {
|
|
1097
1080
|
if (!f) return;
|
|
1098
|
-
|
|
1099
|
-
|
|
1081
|
+
const id = 'fin:' + (f.id || f.title);
|
|
1082
|
+
VW.open({ id, kind: 'Finished', title: f.title, icon: 'doc',
|
|
1083
|
+
presses: [{ act: 'chat', label: 'Change it in chat', icon: I.chat }],
|
|
1084
|
+
more: [{ label: 'Copy the text', on: () => { try { navigator.clipboard.writeText(f.body || f.summary || ''); toast('Copied.'); } catch { toast('It was not copied.'); } } }],
|
|
1085
|
+
onPress: (act) => { if (act === 'chat') finChat(f); },
|
|
1086
|
+
render: (body) => {
|
|
1087
|
+
body.innerHTML = `<div class="ut-vc">${finSummary(f)}${f.body ? `<article class="hv-doc">${mdHtml(f.body)}</article>` : ''}</div>`;
|
|
1088
|
+
body.onclick = async (e) => {
|
|
1089
|
+
const b = e.target.closest('[data-czs-act]'); if (!b || b.disabled) return;
|
|
1090
|
+
if (b.dataset.czsAct === 'fin-open') { window.open(f.link, '_blank', 'noopener'); return; }
|
|
1091
|
+
if (b.dataset.czsAct !== 'fin-done') return;
|
|
1092
|
+
b.disabled = true;
|
|
1093
|
+
const r = await pmPost('/api/news-for-you/seen', { ids: [f.key] }).catch(() => null);
|
|
1094
|
+
if (!r || !r.ok) { b.disabled = false; toast('It was not marked done. The server did not answer.'); return; }
|
|
1095
|
+
toast('Done with ' + f.title + '.');
|
|
1096
|
+
const pd = await pmGet('/api/phone-day').catch(() => null);
|
|
1097
|
+
if (pd && pd.ok) S.D.phoneDay = pd;
|
|
1098
|
+
const c = VW.current(); if (c && c.id === id) VW.back();
|
|
1099
|
+
redrawDay();
|
|
1100
|
+
};
|
|
1101
|
+
} });
|
|
1102
|
+
}
|
|
1103
|
+
/** "Change it in chat": Home's chat about this one draft, with its text as the context. The draft changes only when the PM says so. */
|
|
1104
|
+
function finChat(f) {
|
|
1105
|
+
S.phoneChat = isPhone();
|
|
1106
|
+
openTarget({ ...homeTarget(), key: 'chat:fin-' + (f.id || f.title), title: f.title, sub: 'Drafted for you', scope: { text: f.title, icon: I.doc },
|
|
1107
|
+
intro: { role: CLAUDE, text: 'What should I change in ' + f.title + '?' }, placeholder: 'Tell Claude what to change',
|
|
1108
|
+
context: 'The PM wants to change a draft from today\'s prep run: "' + f.title + '".' + (f.summary ? ' Summary: ' + f.summary : '') + (f.body ? '\nThe draft:\n' + String(f.body).slice(0, 6000) : '') + '\nNothing is sent: write the changed draft here for the PM to read.' });
|
|
1109
|
+
drawList();
|
|
1110
|
+
if (isPhone()) VW.close();
|
|
1111
|
+
chat.focus();
|
|
1100
1112
|
}
|
|
1101
1113
|
function openReviewVw() {
|
|
1102
1114
|
S.sel = 'review'; drawList();
|
|
@@ -1177,67 +1189,85 @@ function reopenViewer() {
|
|
|
1177
1189
|
openUpdateViewer(); // nothing picked on Home: the product's weekly update (My work is no longer a page of its own)
|
|
1178
1190
|
}
|
|
1179
1191
|
function factsHtml(rows) { return rows && rows.length ? `<dl class="hv-facts">${rows.map(([k, v]) => `<div><dt>${esc(k)}</dt><dd>${esc(v)}</dd></div>`).join('')}</dl>` : ''; }
|
|
1180
|
-
|
|
1192
|
+
/** An ask in the Viewer. The asks (start / blocked, decision, waited, source) are home-need.js's (batch 18 item 2-A); a run's return stays
|
|
1193
|
+
* here (XvAReturn). pick: a decision's choice from the chat's pills, or true to focus a return's note. */
|
|
1194
|
+
function openNeedViewer(r, pick) {
|
|
1181
1195
|
const row = r.row, d = row.dialog || {}, w = d.write || {};
|
|
1196
|
+
if (w.kind !== 'return') return NEED.openNeed(r, needHost(), { choice: typeof pick === 'string' ? pick : null });
|
|
1197
|
+
let focusWhy = !!pick;
|
|
1182
1198
|
const st = S.rec[r.key] || (S.rec[r.key] = { choice: d.sel || null, why: '', ret: null });
|
|
1183
1199
|
const draw = (b) => {
|
|
1184
1200
|
const pane = d.pane || {};
|
|
1185
1201
|
const facts = factsHtml(pane.rows || d.facts || []);
|
|
1186
|
-
//
|
|
1187
|
-
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
const score = (pane.rows || d.facts || []).find((x) => /score|rubric/i.test(String(x[0] || '')));
|
|
1199
|
-
b.innerHTML = VW.czSummary({ line: score ? String(score[1]) : r.hint || pane.h || 'Waits for your review', tone: 'warn', text: pane.intro || (pane.paras || [])[0] || r.hint || '',
|
|
1200
|
-
meta: (w.agent || 'The agent') + ' gets this note and tries again. It counts as one correction.', primary: { label: 'Return it', act: 'return', disabled: !st.ret }, second: { label: 'Keep it as is', act: 'keep' } })
|
|
1201
|
-
+ VW.czSections([
|
|
1202
|
-
{ id: 'why', title: 'Why it goes back', open: true, html: `<div class="ut-chips" role="group" aria-label="Why it goes back">${RET_REASONS.map((x) => `<button type="button" class="cz-chip${st.ret === x ? ' on' : ''}" aria-pressed="${st.ret === x}" data-hv-ret="${esc(x)}">${esc(RET_LABEL[x] || x)}</button>`).join('')}</div>` },
|
|
1203
|
-
{ id: 'note', title: 'What to change', open: true, html: `<div class="ut-field"><label for="hvNote" class="hi-vh">What to change</label><textarea id="hvNote" rows="3" placeholder="Say what the agent should change">${esc(st.note || '')}</textarea></div>` },
|
|
1204
|
-
facts ? { id: 'facts', title: pane.h || 'The review', count: (pane.rows || d.facts || []).length, html: facts } : null,
|
|
1205
|
-
], { key: 'return' })
|
|
1206
|
-
+ '<p class="ut-small ut-mut" role="status" id="hvMsg"></p>';
|
|
1207
|
-
if (focusWhy) { const t = b.querySelector('#hvNote'); if (t) setTimeout(() => t.focus(), 0); focusWhy = false; }
|
|
1208
|
-
return;
|
|
1209
|
-
} else if (w.kind === 'start') {
|
|
1210
|
-
rec = `<section class="hv-sec"><h4>Start</h4><p class="hx-n">The agent drafts ${esc(w.what || 'it')} in a real session. Its draft waits for you to read.</p><div class="hv-acts"><button type="button" class="hx-b pri" data-hv-start>Start the agent</button>${laterHtml()}${pinHtml(r)}</div></section>`;
|
|
1211
|
-
} else rec = `<div class="hv-acts">${link}${src ? '' : laterHtml()}${pinHtml(r)}</div>`; // a source row cannot be put off (the server refuses it)
|
|
1212
|
-
b.innerHTML = `<div class="hv">${pane.note ? `<p class="hv-note">${esc(pane.note)}</p>` : ''}${pane.h ? `<h4 class="hv-h">${esc(pane.h)}</h4>` : ''}${intro}${facts}${paras}${rec}<p class="hx-n" role="status" id="hvMsg"></p></div>`;
|
|
1213
|
-
if (focusWhy) { const t = b.querySelector('#hvWhy'); if (t) setTimeout(() => t.focus(), 0); focusWhy = false; }
|
|
1202
|
+
// shell A (canvas XvAReturn): the summary says what the review found and holds Return it with Keep it as is beside it;
|
|
1203
|
+
// why it goes back and what to change are open rows below, the facts the review rests on fold under them
|
|
1204
|
+
const score = (pane.rows || d.facts || []).find((x) => /score|rubric/i.test(String(x[0] || '')));
|
|
1205
|
+
b.innerHTML = VW.czSummary({ line: score ? String(score[1]) : r.hint || pane.h || 'Waits for your review', tone: 'warn', text: pane.intro || (pane.paras || [])[0] || r.hint || '',
|
|
1206
|
+
meta: (w.agent || 'The agent') + ' gets this note and tries again. It counts as one correction.', primary: { label: 'Return it', act: 'return', disabled: !st.ret }, second: { label: 'Keep it as is', act: 'keep' } })
|
|
1207
|
+
+ VW.czSections([
|
|
1208
|
+
{ id: 'why', title: 'Why it goes back', open: true, html: `<div class="ut-chips" role="group" aria-label="Why it goes back">${RET_REASONS.map((x) => `<button type="button" class="cz-chip${st.ret === x ? ' on' : ''}" aria-pressed="${st.ret === x}" data-hv-ret="${esc(x)}">${esc(RET_LABEL[x] || x)}</button>`).join('')}</div>` },
|
|
1209
|
+
{ id: 'note', title: 'What to change', open: true, html: `<div class="ut-field"><label for="hvNote" class="hi-vh">What to change</label><textarea id="hvNote" rows="3" placeholder="Say what the agent should change">${esc(st.note || '')}</textarea></div>` },
|
|
1210
|
+
facts ? { id: 'facts', title: pane.h || 'The review', count: (pane.rows || d.facts || []).length, html: facts } : null,
|
|
1211
|
+
], { key: 'return' })
|
|
1212
|
+
+ '<p class="ut-small ut-mut" role="status" id="hvMsg"></p>';
|
|
1213
|
+
if (focusWhy) { const t = b.querySelector('#hvNote'); if (t) setTimeout(() => t.focus(), 0); focusWhy = false; }
|
|
1214
1214
|
};
|
|
1215
|
-
const body = VW.open({ id: 'need:' + r.key, kind:
|
|
1216
|
-
body.oninput = (e) => { if (e.target.id === 'hvNote')
|
|
1215
|
+
const body = VW.open({ id: 'need:' + r.key, kind: 'Waiting', title: r.name, icon: 'info', render: draw });
|
|
1216
|
+
body.oninput = (e) => { if (e.target.id === 'hvNote') st.note = e.target.value; };
|
|
1217
1217
|
body.onclick = async (e) => {
|
|
1218
1218
|
const t = e.target.closest('button'); if (!t || t.disabled) return;
|
|
1219
1219
|
const say = (m) => { const el = body.querySelector('#hvMsg'); if (el) el.textContent = m; };
|
|
1220
|
-
if (t.dataset.hvOpt) { st.choice = t.dataset.hvOpt; draw(body); return; }
|
|
1221
1220
|
if (t.dataset.hvRet) { st.ret = t.dataset.hvRet; draw(body); return; }
|
|
1222
|
-
if (
|
|
1223
|
-
if (t.dataset.
|
|
1224
|
-
if ('hvPin' in t.dataset) { if (S.pin.has(r.key)) S.pin.delete(r.key); else S.pin.add(r.key); store.set('pmos.home.pin', JSON.stringify([...S.pin])); draw(body); drawList(); return; }
|
|
1225
|
-
if ('hvStart' in t.dataset) { start(r); return; }
|
|
1226
|
-
if ('hvKeep' in t.dataset || t.dataset.czsAct === 'keep') { delete S.rec[r.key]; VW.close(); return; }
|
|
1227
|
-
if ('hvRec' in t.dataset || t.dataset.czsAct === 'return') {
|
|
1221
|
+
if (t.dataset.czsAct === 'keep') { delete S.rec[r.key]; VW.close(); return; }
|
|
1222
|
+
if (t.dataset.czsAct === 'return') {
|
|
1228
1223
|
t.disabled = true;
|
|
1229
|
-
const res =
|
|
1224
|
+
const res = await bpPost('return', { run: w.run, reason: st.ret, ...(w.ws ? { ws: w.ws } : {}) });
|
|
1230
1225
|
if (!res.ok) { t.disabled = false; say(res.error); return; }
|
|
1231
1226
|
delete S.rec[r.key];
|
|
1232
|
-
toast(
|
|
1233
|
-
const note =
|
|
1227
|
+
toast('Returned to the agent. It counts as a correction.');
|
|
1228
|
+
const note = String(st.note || '').trim();
|
|
1234
1229
|
if (note && chat.current() && chat.current().key === r.key) chat.send('What to change: ' + note);
|
|
1235
1230
|
VW.close(); await load(); select(null);
|
|
1236
1231
|
}
|
|
1237
1232
|
};
|
|
1238
1233
|
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1234
|
+
/** What home-need.js reads and calls on Home. */
|
|
1235
|
+
function needHost() {
|
|
1236
|
+
return {
|
|
1237
|
+
VW, P: TD.P, esc, svg: TD.svg, toast, menu,
|
|
1238
|
+
me: () => (String((S.D.today && S.D.today.me) || 'You').trim()[0] || 'Y').toUpperCase(),
|
|
1239
|
+
pinned: (k) => S.pin.has(k),
|
|
1240
|
+
togglePin: (k) => { if (S.pin.has(k)) S.pin.delete(k); else S.pin.add(k); store.set('pmos.home.pin', JSON.stringify([...S.pin])); drawList(); },
|
|
1241
|
+
putOff: async (k, until) => { const res = await bpPost('put-off', { key: k, until }); if (res.ok) { toast('Put off. It comes back by itself, and it is not counted as done.'); delete S.rec[k]; VW.close(); await load(); select(null); } else toast(res.error); },
|
|
1242
|
+
start: (r) => start(r),
|
|
1243
|
+
sessions: () => S.D.sessions || [],
|
|
1244
|
+
stopSession: async (sid) => { const res = await pmPost('/api/session/remove', { id: sid }).catch(() => null); if (res && res.ok) { load(); return true; } return false; },
|
|
1245
|
+
openSession: (sid) => { const s = (S.D.sessions || []).find((x) => x.id === sid); if (!s) { toast('That session has ended. Its conversation is in Sessions.'); return; } if (isPhone()) { S.phoneChat = true; VW.close(); } openTarget(sessionTarget(s)); drawList(); chat.focus(); },
|
|
1246
|
+
ask: (r, text) => {
|
|
1247
|
+
const c = chat.current && chat.current();
|
|
1248
|
+
if (!c || c.key !== r.key) openTarget(needTarget(r));
|
|
1249
|
+
if (isPhone()) { S.phoneChat = true; VW.close(); drawList(); }
|
|
1250
|
+
if (text) chat.send(text); else chat.focus();
|
|
1251
|
+
},
|
|
1252
|
+
decide: async (r, choice, why) => {
|
|
1253
|
+
const res = await bpPost('decide', { key: r.key, choice, why });
|
|
1254
|
+
if (!res.ok) return res;
|
|
1255
|
+
delete S.rec[r.key]; toast('Recorded in pm-decisions.md.'); VW.close(); await load(); select(null);
|
|
1256
|
+
return res;
|
|
1257
|
+
},
|
|
1258
|
+
openReturn: (it) => {
|
|
1259
|
+
if (!it.run) { if (it.id) goIni(it.id); return; }
|
|
1260
|
+
VW.drill();
|
|
1261
|
+
openNeedViewer({ key: 'ret:' + it.run, name: it.t, hint: '', row: { kind: 'run', dialog: { write: { kind: 'return', run: it.run, ...(it.ws ? { ws: it.ws } : {}) },
|
|
1262
|
+
pane: { h: 'The review', intro: it.lead || '', rows: [['Score', it.s], ['Waiting', it.days != null ? it.days + ' days' : '']].filter((x) => x[1]) } } } });
|
|
1263
|
+
},
|
|
1264
|
+
recordHref: (r) => { const f = (r.row.detail || {}).record || ((r.row.dialog || {}).pane || {}).file; return f && /\.md$/.test(f) ? '/premium-board.html?doc=' + encodeURIComponent(f) : ''; },
|
|
1265
|
+
boardHref: (r) => { const t = r.row.detail || {}, ws = t.ws || r.row.ws || boardWs() || ''; return t.id && t.lane ? '/premium-board.html?' + (ws ? 'ws=' + encodeURIComponent(ws) + '&' : '') + 'focus=' + encodeURIComponent(t.id) : ''; },
|
|
1266
|
+
linkOf: (r) => location.origin + selfUrl({ open: r.key }),
|
|
1267
|
+
signIn: () => import('./cozy-settings.js').then((M) => M.openSettings('connectors')),
|
|
1268
|
+
rowGone: (k) => !!S.D.brief && !H.needsOf(S.D).some((x) => x.key === k),
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1241
1271
|
async function bpPost(act, body) {
|
|
1242
1272
|
const r = await pmPost('/api/briefing-premium/' + act + wsQ(), body);
|
|
1243
1273
|
return r && r.ok === true ? r : { ok: false, error: (r && r.error) || 'The record was not written.' };
|
|
@@ -1247,6 +1277,7 @@ async function start(r) {
|
|
|
1247
1277
|
const res = await startAgent({ ws: w.ws || WS || undefined, task: 'draft', initiative: w.initiative, what: w.what });
|
|
1248
1278
|
toast(res.ok ? 'The agent started. Its draft waits for you to read.' : 'Not started: ' + res.error);
|
|
1249
1279
|
if (res.ok) load();
|
|
1280
|
+
return res;
|
|
1250
1281
|
}
|
|
1251
1282
|
|
|
1252
1283
|
/* the weekly update: the recipients are editable; Send opens a mail draft in the PM's own mail and records that it was sent */
|
|
@@ -1346,7 +1377,7 @@ function openOverview() {
|
|
|
1346
1377
|
if (t.dataset.ovDread) { // a draft: read it, edit it, Issue it (home-draft.js, in the Viewer's card shape)
|
|
1347
1378
|
const d = (M.docs.rows || []).find((x) => x.key === t.dataset.ovDread); if (!d) return;
|
|
1348
1379
|
const A = await import('./home-draft.js');
|
|
1349
|
-
A.openDraftVw({ VW, pmGet, pmPost, toast, ws: M.board.ws, scope: M.docs.scope, doc: d, onIssued: () => load() });
|
|
1380
|
+
A.openDraftVw({ VW, pmGet, pmPost, toast, ws: M.board.ws, scope: M.docs.scope, doc: d, iniTitle: iniTitle(id), onIssued: () => load() });
|
|
1350
1381
|
return;
|
|
1351
1382
|
}
|
|
1352
1383
|
if ('ovAdddoc' in t.dataset) { // the form in the Viewer (home-adddoc.js): it posts to /api/custom-docs/add only
|
|
@@ -1363,28 +1394,17 @@ async function openFile(f) {
|
|
|
1363
1394
|
const fws = () => (S.ini && S.IM && S.IM.board && S.IM.board.ws) || deskWs(); // an initiative's document lives in its board's workspace
|
|
1364
1395
|
const ini = S.ini || ''; // its chat edits the document in the initiative's own worktree: the page reads it there (premium-vw-doc.js)
|
|
1365
1396
|
if (/\.md$/i.test(f.path)) { try { const M = await import('./premium-vw-doc.js'); if (M.openDocPage({ path: f.path, title: f.name || f.path.split('/').pop() }, { ws: () => fws(), ini })) return; } catch { /* the plain view below */ } }
|
|
1366
|
-
|
|
1397
|
+
// shell A (batch 18 item 2-C): the kind is a Document and the path is under ⋯ (Copy path), never in the body
|
|
1398
|
+
const body = VW.open({ id: 'file:' + f.path, kind: 'Document', title: f.name || f.path.split('/').pop(), icon: 'doc', html: '<p class="hx-n hv">Reading the file.</p>',
|
|
1399
|
+
more: [{ label: 'Copy path', icon: 'M8 8h11v12H8zM5 16V4h11', on: async () => { try { await navigator.clipboard.writeText(f.path); toast('Path copied.'); } catch { toast('The path was not copied: ' + f.path); } } }] });
|
|
1367
1400
|
let txt = null;
|
|
1368
1401
|
try { const r = await fetch('/api/doc?path=' + encodeURIComponent(f.path) + (deskWs() ? '&ws=' + encodeURIComponent(deskWs()) : ''), { credentials: 'same-origin' }); txt = r.ok ? await r.text() : null; } catch { txt = null; }
|
|
1369
1402
|
if (VW.current() && VW.current().id === 'file:' + f.path) body.innerHTML = txt == null ? '<p class="hx-n hv">The file could not be read.</p>' : `<article class="hv hv-doc">${mdHtml(txt.replace(/^---\n[\s\S]*?\n---\n/, ''))}</article>`;
|
|
1370
1403
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
}
|
|
1376
|
-
function addPerson() {
|
|
1377
|
-
const id = S.ini;
|
|
1378
|
-
const body = VW.open({ id: 'person:new', kind: 'Stakeholder', title: 'Add a stakeholder to ' + iniTitle(id), icon: 'info',
|
|
1379
|
-
html: '<div class="hv"><label class="hv-why"><span>Name</span><input id="hpN" autocomplete="off"></label><label class="hv-why"><span>Role</span><input id="hpR" placeholder="e.g. Head of Sales"></label><label class="hv-why"><span>Note</span><input id="hpT" placeholder="What they care about"></label><div class="hv-acts"><button type="button" class="hx-b pri" data-hv-addp>Add</button></div></div>' });
|
|
1380
|
-
setTimeout(() => { const i = body.querySelector('#hpN'); if (i) i.focus(); }, 0);
|
|
1381
|
-
body.onclick = async (e) => {
|
|
1382
|
-
if (!e.target.closest('[data-hv-addp]')) return;
|
|
1383
|
-
const name = body.querySelector('#hpN').value.trim(); if (!name) return;
|
|
1384
|
-
const r = await pmPost('/api/home-desk/stakeholder', { ws: deskWs(), initiative: id, name, role: body.querySelector('#hpR').value.trim(), note: body.querySelector('#hpT').value.trim() });
|
|
1385
|
-
if (r && r.ok) { toast('Added ' + name + '.'); VW.close(); await load(); } else toast((r && r.error) || 'Not added.');
|
|
1386
|
-
};
|
|
1387
|
-
}
|
|
1404
|
+
/* a stakeholder and the one stakeholder form (pm/small-vw.js; batch 18 item 2-C, canvas OvA8People), the same as the Board's */
|
|
1405
|
+
const personCtx = () => { const id = S.ini; return { VW, pmPost, toast: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)), ws: deskWs(), ini: id, iniTitle: iniTitle(id), saved: () => load(), back: () => VW.back() }; };
|
|
1406
|
+
function openPerson(p) { SV.openPersonVw(p, { ...personCtx(), back: null }); }
|
|
1407
|
+
function addPerson() { SV.openPersonForm(personCtx()); }
|
|
1388
1408
|
/* ── the metrics review (AgMetrics): the Strategist's conversation, and the review in the Viewer: three tiles, the correction rate by week
|
|
1389
1409
|
* (the current week in blue) and what moved it. Every number is a record of the product's repository (GET /api/board-metrics-premium:
|
|
1390
1410
|
* corrections from its run log, merges from its trunk, blocked from its workflow state); a measure that is not read says so. ── */
|
|
@@ -1458,10 +1478,7 @@ async function openMetrics(o = {}) {
|
|
|
1458
1478
|
if (S.sel !== id) return;
|
|
1459
1479
|
openTarget(metricsTarget());
|
|
1460
1480
|
}
|
|
1461
|
-
function openRoutine(s) {
|
|
1462
|
-
VW.open({ id: 'routine:' + (s.id || s.name), kind: 'Routine', title: String(s.name || s.task || s.skill || 'Routine'), icon: 'cal',
|
|
1463
|
-
html: `<div class="hv">${MORE.WAIT}${factsHtml([['Task', s.task || s.skill], ['Next run', s.next ? new Date(s.next).toString().slice(0, 21) : 'Not scheduled'], ['Repeats', s.cron || s.every || s.when || ''], ['On', s.enabled === false ? 'Off' : 'On']].filter((x) => x[1]))}</div>` });
|
|
1464
|
-
}
|
|
1481
|
+
function openRoutine(s) { SV.openRoutineVw(s, { VW, now: S.D && S.D.now }); }
|
|
1465
1482
|
|
|
1466
1483
|
/* the agent's terminal, read only, in the Viewer (term-view.js) */
|
|
1467
1484
|
function openTerminal(sid) {
|
|
@@ -1629,12 +1646,23 @@ menuEl.onclick = (e) => { // delegated: every item is a <button role=menuitem>
|
|
|
1629
1646
|
document.addEventListener('click', (e) => { if (!menuEl.hidden && !menuEl.contains(e.target) && !(menu.anchor && menu.anchor.contains(e.target))) closeMenu(); }, true);
|
|
1630
1647
|
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menuEl.hidden) { e.stopPropagation(); closeMenu(); } else if (e.key === 'Escape' && S.sheet) sheet(false); }, true);
|
|
1631
1648
|
function searchGo(d) {
|
|
1649
|
+
if (d.merge) { mergeFrom(d.merge.from, d.merge.into); return; }
|
|
1632
1650
|
if (d.ini) goIni(d.ini);
|
|
1633
1651
|
else if (d.doc) openFile({ path: d.doc, name: d.doc.split('/').pop() });
|
|
1634
1652
|
else if (d.ses) { const s = S.D.sessions.find((x) => x.id === d.ses); if (s) { S.sel = 's:' + s.id; openTarget(sessionTarget(s)); followViewer(s); drawList(); } }
|
|
1635
1653
|
else if (d.link) location.href = d.link;
|
|
1636
1654
|
}
|
|
1637
1655
|
|
|
1656
|
+
/** Merge from New for you's overlap note (batch 18 item 2b, OvA5): the initiative that goes opens, then the merge check with both set, as its
|
|
1657
|
+
* ⋯ › Merge into does. A merge stays on one board: when the two are not both on this board, the initiative opens and a toast says why. */
|
|
1658
|
+
async function mergeFrom(from, into) {
|
|
1659
|
+
const rows = H.boardRows(S.D), both = rows.some((r) => r.id === from) && rows.some((r) => r.id === into);
|
|
1660
|
+
await goIni(from);
|
|
1661
|
+
if (!both || (S.D.board && S.D.board.board && S.D.board.board.self)) { toast('These two are on different boards, so they cannot be merged here.'); return; }
|
|
1662
|
+
VW.drill();
|
|
1663
|
+
SM.openMerge(smCtx(from), into);
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1638
1666
|
/* ── the phone sheet ── */
|
|
1639
1667
|
function sheet(on) {
|
|
1640
1668
|
S.sheet = !!on;
|
|
@@ -54,7 +54,7 @@ export function avHtml(role, size = 28, cls = '') {
|
|
|
54
54
|
/** Adler is Claude's avatar once, on the latest reply, in that reply's mood (batch 16 item 2, canvas AdU1): needs you while it asks,
|
|
55
55
|
* honest when the run stopped, thinking while it runs, handled otherwise. Another role keeps its letter. */
|
|
56
56
|
const isClaude = (r) => !r || !r.key || r.key === 'claude';
|
|
57
|
-
export const adlerAvHtml = (mood) => `<span class="hm-av hm-adler" aria-hidden="true">${adler(mood, 36, { label: false, id: 'chat' })}</span>`;
|
|
57
|
+
export const adlerAvHtml = (mood) => `<span class="hm-av hm-adler" aria-hidden="true">${adler(mood, 36, { label: false, id: 'chat', dress: true })}</span>`;
|
|
58
58
|
|
|
59
59
|
export function mountChat(el, host) {
|
|
60
60
|
const esc = host.esc;
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* finished while away. The 3 newest, then "N more" (the whole list in the Viewer, cozy-news.js); ✓✓ in the fold's header
|
|
9
9
|
* marks all seen; today's digests of the morning brief are one row. No item and no digest, no fold. It replaces the New
|
|
10
10
|
* for you page of the place menu.
|
|
11
|
-
* Drafted for you the drafts of today's morning prep run (GET /api/phone-day finished) and the weekly update
|
|
11
|
+
* Drafted for you the drafts of today's morning prep run (GET /api/phone-day finished) and the weekly update; a draft the PM is done
|
|
12
|
+
* with ("Done with it" in the Finished Viewer, batch 18 item 2) leaves it
|
|
12
13
|
* Can wait every other row that was "Your move" (tasks, brief items, Jira)
|
|
13
14
|
* Now the phone's moment card (home-phone-card.js), open by default
|
|
14
15
|
* Tomorrow after 17:00 only (canvas FmA5Evening, was More › End of the day): tomorrow's meetings (GET /api/phone-day tomorrow);
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
* never happier than the data. When Claude's own miss or a stuck call already leads the card, the failed source is one card under it. */
|
|
30
31
|
|
|
31
32
|
import { todayOf, hm } from './home-data.js';
|
|
32
|
-
import { adler, adlerScene, asleep, firstOpenToday } from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2): AdB1-3, AdP1, AdP4
|
|
33
|
+
import { adler, adlerScene, asleep, firstOpenToday, dress, dressDay } from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2): AdB1-3, AdP1, AdP4; dressed for the season (batch 18 item 8-B)
|
|
33
34
|
import { initials, ago } from './cozy-evmodel.js';
|
|
34
35
|
|
|
35
36
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
@@ -114,7 +115,7 @@ export function dayModel(M, D, R, now = Date.now(), o = {}) {
|
|
|
114
115
|
const drafted = fin.filter((x) => x.status !== 'sent').length, sent = fin.filter((x) => x.status === 'sent').length;
|
|
115
116
|
const chips = [prepped && plural(prepped, 'meeting prepped', 'meetings prepped'), drafted && plural(drafted, 'draft ready', 'drafts ready'), sent && sent + ' sent'].filter(Boolean);
|
|
116
117
|
|
|
117
|
-
const calls = move.filter((r) => r.call), drafts = [...fin.map((x) => ({ fin: x })), ...move.filter((r) => r.kind === 'update').map((r) => ({ row: r }))];
|
|
118
|
+
const calls = move.filter((r) => r.call), drafts = [...fin.filter((x) => !x.seen).map((x) => ({ fin: x })), ...move.filter((r) => r.kind === 'update').map((r) => ({ row: r }))];
|
|
118
119
|
const wait = move.filter((r) => !r.call && r.kind !== 'update');
|
|
119
120
|
const misses = run ? (run.failed || []).map((f) => ({ id: f.id, title: f.title, why: f.error || '' })) : [];
|
|
120
121
|
const blocked = calls.filter((r) => r.state === 'blocked');
|
|
@@ -123,7 +124,9 @@ export function dayModel(M, D, R, now = Date.now(), o = {}) {
|
|
|
123
124
|
const thanks = thanksOf(D, now);
|
|
124
125
|
|
|
125
126
|
const h = new Date(now).getHours(), name = D.today && D.today.me ? String(D.today.me) : '';
|
|
126
|
-
|
|
127
|
+
// on a festival's own day the greeting wishes it once (AsPlaces); a day with bad news says the news instead (the concerned line replaces it)
|
|
128
|
+
const wish = o.dress && dressDay(o.dress, now) ? 'Happy ' + o.dress.name : '';
|
|
129
|
+
const hi = (wish || (h < 12 ? 'Morning' : h < 17 ? 'Afternoon' : 'Evening')) + (name ? ', ' + name : '') + '.';
|
|
127
130
|
const gaps = gapsOf(t, now);
|
|
128
131
|
let mood = 'calm', line = hi, sub = meetText, offer = null;
|
|
129
132
|
if (misses.length || blocked.length) {
|
|
@@ -174,7 +177,8 @@ export function openHtml(Y, o = {}) {
|
|
|
174
177
|
// AdP5: a failed source that leads the card draws the small rain cloud in place of the morning scene (Face only: the honest face)
|
|
175
178
|
const rain = Y.fail && Y.failLead ? adlerScene('rain', 'honest', { label: 'Adler, honest, under a small rain cloud', h: 170 }) : '';
|
|
176
179
|
if (rain) o = { ...o, scene: true };
|
|
177
|
-
|
|
180
|
+
// a dressed day's scene is wider (460 x 170), so the card's 150 px shows its garland or lights, not only the ground (AsPlaces)
|
|
181
|
+
const head = rain ? `<div class="yd-scene">${rain}</div>` : o.scene ? `<div class="yd-scene"${dress() ? ' data-ad-dress role="button" tabindex="0" aria-label="Why Adler is dressed"' : ''}>${adlerScene('morning', 'handled', { label: false, dress: true, ...(dress() ? { w: 460, h: 170 } : {}) })}</div>` : o.big ? '' : faceHtml(Y.face || Y.mood);
|
|
178
182
|
const chips = Y.chips.length ? `<div class="yd-chips">${Y.chips.map((c) => `<span class="yd-chip">${svg(CHECK, 14, 2.6)}${esc(c)}</span>`).join('')}</div>` : '';
|
|
179
183
|
const miss = Y.misses.map((m) => `<div class="yd-miss" data-id="${esc(m.id)}"><div class="yd-mt"><b>My miss: ${esc(m.title)}</b>${m.why ? `<em>${esc(m.why)}</em>` : ''}</div>${ok('retry', 'Run it again', m.id)}</div>`).join('');
|
|
180
184
|
// the failed source under Claude's own miss: one card, no second Adler; its icon reads the source again (Settings › Connectors' ↻)
|
|
@@ -212,19 +216,23 @@ const bigHtml = (kind) => (kind === 'win'
|
|
|
212
216
|
/** After 22:00 (Settings > Adler > Quiet after), unless something is wrong: Adler asleep, and the day one press away (AdP4). */
|
|
213
217
|
export function nightHtml(Y) {
|
|
214
218
|
const sub = Y.calls.length ? (Y.calls.length === 1 ? 'One call waits for you in the morning.' : Y.calls.length + ' calls wait for you in the morning.') : 'Nothing needs you tonight.';
|
|
215
|
-
return `<div class="yd-night">${adlerScene('night', 'resting')}<b>It’ll keep till morning.</b><em>${esc(sub)}</em><button type="button" class="yd-awake" data-yd="awake">Open anyway</button></div>`;
|
|
219
|
+
return `<div class="yd-night">${adlerScene('night', 'resting', { dress: true })}<b>It’ll keep till morning.</b><em>${esc(sub)}</em><button type="button" class="yd-awake" data-yd="awake">Open anyway</button></div>`;
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
/* one New for you item (FmA2Day): the blue dot, who, the words and where it came from; a press opens it in the Viewer (cozy-news.js) */
|
|
219
223
|
const MARK2 = 'M2 12.5l4.5 4.5L15 8M9 15l2 2L22 7';
|
|
224
|
+
const SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z';
|
|
220
225
|
export const NEWS_SHOWN = 3;
|
|
221
226
|
function newsRow(it, now) {
|
|
222
227
|
const who = it.kind === 'task' ? (it.from || 'Someone') : (it.product || 'Claude');
|
|
223
228
|
const when = it.at ? ago(new Date(it.at).toISOString(), now) : '';
|
|
224
|
-
const head = it.title;
|
|
225
|
-
|
|
229
|
+
const head = it.kind === 'task' ? String(it.title || '').replace(/^New task: /, '') : it.title;
|
|
230
|
+
// an overlap note is Claude's proposal (batch 18 item 2b): the ✦ tile and both initiatives by name, never an id
|
|
231
|
+
const sub = it.kind === 'overlap' ? [it.a && it.a.title, it.b && it.b.title].filter(Boolean).join(' and ') || 'Two open initiatives'
|
|
232
|
+
: it.kind === 'task' ? ['Given to you' + (it.from ? ' from ' + it.from : ''), it.due ? 'due ' + it.due : '', it.iniTitle ? 'filed under ' + it.iniTitle : ''].filter(Boolean).join(' · ')
|
|
226
233
|
: ['Finished while you were away', it.target, when].filter(Boolean).join(' · ');
|
|
227
|
-
|
|
234
|
+
const av = it.kind === 'overlap' ? `<span class="yd-av sp" aria-hidden="true">${svg(SPARK, 13, 2)}</span>` : `<span class="yd-av${it.kind === 'finished' ? ' b' : ''}" aria-hidden="true">${esc(initials(who))}</span>`;
|
|
235
|
+
return `<button type="button" class="yd-nw" data-yd="news" data-id="${esc(it.id)}"><i class="yd-nd" aria-hidden="true"></i>${av}<span class="yd-mt"><b>${esc(head)}</b><em>${esc(sub)}</em></span></button>`;
|
|
228
236
|
}
|
|
229
237
|
/** The New for you fold's parts: the 3 newest rows, "N more", the morning brief's digests as one row, and the ✓✓ that marks all seen.
|
|
230
238
|
* → a czSections row, or null when nothing is new and there is no digest (zero is silence). */
|