create-pmos 0.439.0 → 0.441.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/bin/create-pmos.js +5 -2
- 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/briefing-premium-adddoc-test.js +16 -13
- package/workspace/briefing-premium-insights-test.js +1 -1
- 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/core-documents.md +2 -2
- package/workspace/guide/data-freshness.md +7 -5
- package/workspace/guide/home.md +4 -1
- package/workspace/guide/horizon-scan.md +1 -1
- package/workspace/guide/settings.md +2 -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/goal-status.js +2 -1
- package/workspace/lib/headless.js +18 -1
- package/workspace/lib/kit-update.js +2 -2
- package/workspace/lib/metric-draft-runs.js +10 -4
- 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-metric-drafts.js +2 -2
- package/workspace/lib/routes-news.js +15 -1
- package/workspace/lib/routes-phone-day.js +6 -4
- 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-core-doc-issue-test.js +9 -8
- package/workspace/premium-phone-card-test.js +9 -6
- package/workspace/public/pm/bd-ini-panel.js +4 -11
- package/workspace/public/pm/cozy-ev.css +29 -0
- package/workspace/public/pm/cozy-live-pill.css +6 -0
- package/workspace/public/pm/cozy-news.js +186 -22
- package/workspace/public/pm/cozy-today.css +5 -0
- package/workspace/public/pm/cozy-viewer.js +4 -3
- package/workspace/public/pm/cozy-vw-shell.css +49 -0
- package/workspace/public/pm/home-adddoc.js +46 -26
- package/workspace/public/pm/home-app.js +137 -115
- package/workspace/public/pm/home-day.js +15 -11
- package/workspace/public/pm/home-draft.js +35 -23
- package/workspace/public/pm/home-ini.js +2 -2
- package/workspace/public/pm/home-need.js +336 -0
- package/workspace/public/pm/home-phone-card.js +4 -2
- package/workspace/public/pm/home-today.js +2 -2
- package/workspace/public/pm/home-work.js +51 -4
- package/workspace/public/pm/okr-list.js +8 -4
- package/workspace/public/pm/premium-insights.js +6 -5
- package/workspace/public/pm/small-vw.js +128 -0
- package/workspace/public/premium-intelligence.html +1 -1
- package/workspace/server.js +20 -11
- package/workspace/skills/initiative-drive.skill +4 -1
- package/workspace/test-lists/batch18-asks.json +5 -0
- package/workspace/test-lists/news-viewers.json +13 -0
- package/workspace/test-lists/small-viewers.json +5 -0
- package/workspace/test-run.js +3 -1
|
@@ -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);
|
|
@@ -354,11 +357,13 @@ 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' });
|
|
359
363
|
body.onclick = (e) => { // the rows are the list's own rows: the same presses open them
|
|
360
364
|
const b = e.target.closest('button'); if (!b) return;
|
|
361
|
-
if (b.dataset.hmSel) { select(b.dataset.hmSel); return; }
|
|
365
|
+
if (b.dataset.hmSel) { if (b.dataset.hmSel === 'n:update' && !rowById('n:update')) openUpdateViewer(); else select(b.dataset.hmSel); return; }
|
|
366
|
+
if (b.dataset.yd === 'fin') { const d = (dayParts().Y.drafts || [])[+b.dataset.i]; if (d && d.fin) { VW.drill(); openFinished(d.fin); } return; }
|
|
362
367
|
if (b.dataset.yd === 'sel') { const c = b.closest('.yd-call'); if (c) select(c.dataset.id); return; }
|
|
363
368
|
if (b.dataset.yd === 'retry' || b.dataset.yd === 'prep') { dayAct(b); return; }
|
|
364
369
|
if (b.dataset.yd === 'sync') { syncAgain(b); return; }
|
|
@@ -366,7 +371,6 @@ function day(on) {
|
|
|
366
371
|
if (b.dataset.yd === 'news' || b.dataset.yd === 'news-all') { VW.drill(); MORE.openInbox(searchGo, b.dataset.yd === 'news' ? b.dataset.id : ''); return; }
|
|
367
372
|
if (b.dataset.yd === 'seen') { daySeen(b); return; }
|
|
368
373
|
if ('hmReview' in b.dataset) { openReviewVw(); return; }
|
|
369
|
-
if ('hdMeet' in b.dataset && S.Y && S.Y.next) openMeeting(S.Y.next.meeting);
|
|
370
374
|
};
|
|
371
375
|
} });
|
|
372
376
|
readNews();
|
|
@@ -757,53 +761,15 @@ function alsoOf(ini) {
|
|
|
757
761
|
const n = ini ? other.find((r) => r.ini === ini) : other[0];
|
|
758
762
|
return n ? { text: n.name, go: () => select(n.id) } : null;
|
|
759
763
|
}
|
|
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
|
-
}
|
|
764
|
+
/* 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
|
|
765
|
+
* of saying it again. A decision's choices are pills that open the Viewer with that choice picked; it is recorded there. */
|
|
797
766
|
function needTarget(r) {
|
|
798
767
|
const row = r.row, d = row.dialog || {};
|
|
799
768
|
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) });
|
|
769
|
+
if (d.write && d.write.kind === 'decision') for (const o of d.opts || []) pills.push({ label: o.t, go: () => openNeedViewer(r, o.k) });
|
|
803
770
|
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
771
|
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
|
|
772
|
+
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
773
|
}
|
|
808
774
|
function updateTarget() {
|
|
809
775
|
const U = H.weeklyUpdate(S.D, S.D.now);
|
|
@@ -1093,10 +1059,50 @@ function openBoardTask(t) {
|
|
|
1093
1059
|
rename: taskRenameOf,
|
|
1094
1060
|
}));
|
|
1095
1061
|
}
|
|
1062
|
+
/* 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
|
|
1063
|
+
* 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,
|
|
1064
|
+
* 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. */
|
|
1065
|
+
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'; };
|
|
1066
|
+
function finSummary(f) {
|
|
1067
|
+
const when = WHEN_OF(f.at);
|
|
1068
|
+
const line = f.status === 'sent' ? 'Sent' + (when ? ' · ' + when : '') : f.status === 'review' ? 'Ready for you at your desk' : 'Finished' + (when ? ' · ' + when : '');
|
|
1069
|
+
const meta = f.status === 'sent' ? '' : 'Nothing is sent. It stays on this machine.';
|
|
1070
|
+
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,
|
|
1071
|
+
also: HTTPS.test(f.link || '') ? [{ act: 'fin-open', label: 'Open it', icon: 'M14 4h6v6M20 4l-9 9M18 14v5H5V6h5' }] : [] });
|
|
1072
|
+
}
|
|
1096
1073
|
function openFinished(f) {
|
|
1097
1074
|
if (!f) return;
|
|
1098
|
-
|
|
1099
|
-
|
|
1075
|
+
const id = 'fin:' + (f.id || f.title);
|
|
1076
|
+
VW.open({ id, kind: 'Finished', title: f.title, icon: 'doc',
|
|
1077
|
+
presses: [{ act: 'chat', label: 'Change it in chat', icon: I.chat }],
|
|
1078
|
+
more: [{ label: 'Copy the text', on: () => { try { navigator.clipboard.writeText(f.body || f.summary || ''); toast('Copied.'); } catch { toast('It was not copied.'); } } }],
|
|
1079
|
+
onPress: (act) => { if (act === 'chat') finChat(f); },
|
|
1080
|
+
render: (body) => {
|
|
1081
|
+
body.innerHTML = `<div class="ut-vc">${finSummary(f)}${f.body ? `<article class="hv-doc">${mdHtml(f.body)}</article>` : ''}</div>`;
|
|
1082
|
+
body.onclick = async (e) => {
|
|
1083
|
+
const b = e.target.closest('[data-czs-act]'); if (!b || b.disabled) return;
|
|
1084
|
+
if (b.dataset.czsAct === 'fin-open') { window.open(f.link, '_blank', 'noopener'); return; }
|
|
1085
|
+
if (b.dataset.czsAct !== 'fin-done') return;
|
|
1086
|
+
b.disabled = true;
|
|
1087
|
+
const r = await pmPost('/api/news-for-you/seen', { ids: [f.key] }).catch(() => null);
|
|
1088
|
+
if (!r || !r.ok) { b.disabled = false; toast('It was not marked done. The server did not answer.'); return; }
|
|
1089
|
+
toast('Done with ' + f.title + '.');
|
|
1090
|
+
const pd = await pmGet('/api/phone-day').catch(() => null);
|
|
1091
|
+
if (pd && pd.ok) S.D.phoneDay = pd;
|
|
1092
|
+
const c = VW.current(); if (c && c.id === id) VW.back();
|
|
1093
|
+
redrawDay();
|
|
1094
|
+
};
|
|
1095
|
+
} });
|
|
1096
|
+
}
|
|
1097
|
+
/** "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. */
|
|
1098
|
+
function finChat(f) {
|
|
1099
|
+
S.phoneChat = isPhone();
|
|
1100
|
+
openTarget({ ...homeTarget(), key: 'chat:fin-' + (f.id || f.title), title: f.title, sub: 'Drafted for you', scope: { text: f.title, icon: I.doc },
|
|
1101
|
+
intro: { role: CLAUDE, text: 'What should I change in ' + f.title + '?' }, placeholder: 'Tell Claude what to change',
|
|
1102
|
+
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.' });
|
|
1103
|
+
drawList();
|
|
1104
|
+
if (isPhone()) VW.close();
|
|
1105
|
+
chat.focus();
|
|
1100
1106
|
}
|
|
1101
1107
|
function openReviewVw() {
|
|
1102
1108
|
S.sel = 'review'; drawList();
|
|
@@ -1177,67 +1183,85 @@ function reopenViewer() {
|
|
|
1177
1183
|
openUpdateViewer(); // nothing picked on Home: the product's weekly update (My work is no longer a page of its own)
|
|
1178
1184
|
}
|
|
1179
1185
|
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
|
-
|
|
1186
|
+
/** 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
|
|
1187
|
+
* here (XvAReturn). pick: a decision's choice from the chat's pills, or true to focus a return's note. */
|
|
1188
|
+
function openNeedViewer(r, pick) {
|
|
1181
1189
|
const row = r.row, d = row.dialog || {}, w = d.write || {};
|
|
1190
|
+
if (w.kind !== 'return') return NEED.openNeed(r, needHost(), { choice: typeof pick === 'string' ? pick : null });
|
|
1191
|
+
let focusWhy = !!pick;
|
|
1182
1192
|
const st = S.rec[r.key] || (S.rec[r.key] = { choice: d.sel || null, why: '', ret: null });
|
|
1183
1193
|
const draw = (b) => {
|
|
1184
1194
|
const pane = d.pane || {};
|
|
1185
1195
|
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; }
|
|
1196
|
+
// shell A (canvas XvAReturn): the summary says what the review found and holds Return it with Keep it as is beside it;
|
|
1197
|
+
// why it goes back and what to change are open rows below, the facts the review rests on fold under them
|
|
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; }
|
|
1214
1208
|
};
|
|
1215
|
-
const body = VW.open({ id: 'need:' + r.key, kind:
|
|
1216
|
-
body.oninput = (e) => { if (e.target.id === 'hvNote')
|
|
1209
|
+
const body = VW.open({ id: 'need:' + r.key, kind: 'Waiting', title: r.name, icon: 'info', render: draw });
|
|
1210
|
+
body.oninput = (e) => { if (e.target.id === 'hvNote') st.note = e.target.value; };
|
|
1217
1211
|
body.onclick = async (e) => {
|
|
1218
1212
|
const t = e.target.closest('button'); if (!t || t.disabled) return;
|
|
1219
1213
|
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
1214
|
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') {
|
|
1215
|
+
if (t.dataset.czsAct === 'keep') { delete S.rec[r.key]; VW.close(); return; }
|
|
1216
|
+
if (t.dataset.czsAct === 'return') {
|
|
1228
1217
|
t.disabled = true;
|
|
1229
|
-
const res =
|
|
1218
|
+
const res = await bpPost('return', { run: w.run, reason: st.ret, ...(w.ws ? { ws: w.ws } : {}) });
|
|
1230
1219
|
if (!res.ok) { t.disabled = false; say(res.error); return; }
|
|
1231
1220
|
delete S.rec[r.key];
|
|
1232
|
-
toast(
|
|
1233
|
-
const note =
|
|
1221
|
+
toast('Returned to the agent. It counts as a correction.');
|
|
1222
|
+
const note = String(st.note || '').trim();
|
|
1234
1223
|
if (note && chat.current() && chat.current().key === r.key) chat.send('What to change: ' + note);
|
|
1235
1224
|
VW.close(); await load(); select(null);
|
|
1236
1225
|
}
|
|
1237
1226
|
};
|
|
1238
1227
|
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1228
|
+
/** What home-need.js reads and calls on Home. */
|
|
1229
|
+
function needHost() {
|
|
1230
|
+
return {
|
|
1231
|
+
VW, P: TD.P, esc, svg: TD.svg, toast, menu,
|
|
1232
|
+
me: () => (String((S.D.today && S.D.today.me) || 'You').trim()[0] || 'Y').toUpperCase(),
|
|
1233
|
+
pinned: (k) => S.pin.has(k),
|
|
1234
|
+
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(); },
|
|
1235
|
+
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); },
|
|
1236
|
+
start: (r) => start(r),
|
|
1237
|
+
sessions: () => S.D.sessions || [],
|
|
1238
|
+
stopSession: async (sid) => { const res = await pmPost('/api/session/remove', { id: sid }).catch(() => null); if (res && res.ok) { load(); return true; } return false; },
|
|
1239
|
+
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(); },
|
|
1240
|
+
ask: (r, text) => {
|
|
1241
|
+
const c = chat.current && chat.current();
|
|
1242
|
+
if (!c || c.key !== r.key) openTarget(needTarget(r));
|
|
1243
|
+
if (isPhone()) { S.phoneChat = true; VW.close(); drawList(); }
|
|
1244
|
+
if (text) chat.send(text); else chat.focus();
|
|
1245
|
+
},
|
|
1246
|
+
decide: async (r, choice, why) => {
|
|
1247
|
+
const res = await bpPost('decide', { key: r.key, choice, why });
|
|
1248
|
+
if (!res.ok) return res;
|
|
1249
|
+
delete S.rec[r.key]; toast('Recorded in pm-decisions.md.'); VW.close(); await load(); select(null);
|
|
1250
|
+
return res;
|
|
1251
|
+
},
|
|
1252
|
+
openReturn: (it) => {
|
|
1253
|
+
if (!it.run) { if (it.id) goIni(it.id); return; }
|
|
1254
|
+
VW.drill();
|
|
1255
|
+
openNeedViewer({ key: 'ret:' + it.run, name: it.t, hint: '', row: { kind: 'run', dialog: { write: { kind: 'return', run: it.run, ...(it.ws ? { ws: it.ws } : {}) },
|
|
1256
|
+
pane: { h: 'The review', intro: it.lead || '', rows: [['Score', it.s], ['Waiting', it.days != null ? it.days + ' days' : '']].filter((x) => x[1]) } } } });
|
|
1257
|
+
},
|
|
1258
|
+
recordHref: (r) => { const f = (r.row.detail || {}).record || ((r.row.dialog || {}).pane || {}).file; return f && /\.md$/.test(f) ? '/premium-board.html?doc=' + encodeURIComponent(f) : ''; },
|
|
1259
|
+
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) : ''; },
|
|
1260
|
+
linkOf: (r) => location.origin + selfUrl({ open: r.key }),
|
|
1261
|
+
signIn: () => import('./cozy-settings.js').then((M) => M.openSettings('connectors')),
|
|
1262
|
+
rowGone: (k) => !!S.D.brief && !H.needsOf(S.D).some((x) => x.key === k),
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1241
1265
|
async function bpPost(act, body) {
|
|
1242
1266
|
const r = await pmPost('/api/briefing-premium/' + act + wsQ(), body);
|
|
1243
1267
|
return r && r.ok === true ? r : { ok: false, error: (r && r.error) || 'The record was not written.' };
|
|
@@ -1247,6 +1271,7 @@ async function start(r) {
|
|
|
1247
1271
|
const res = await startAgent({ ws: w.ws || WS || undefined, task: 'draft', initiative: w.initiative, what: w.what });
|
|
1248
1272
|
toast(res.ok ? 'The agent started. Its draft waits for you to read.' : 'Not started: ' + res.error);
|
|
1249
1273
|
if (res.ok) load();
|
|
1274
|
+
return res;
|
|
1250
1275
|
}
|
|
1251
1276
|
|
|
1252
1277
|
/* 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 +1371,7 @@ function openOverview() {
|
|
|
1346
1371
|
if (t.dataset.ovDread) { // a draft: read it, edit it, Issue it (home-draft.js, in the Viewer's card shape)
|
|
1347
1372
|
const d = (M.docs.rows || []).find((x) => x.key === t.dataset.ovDread); if (!d) return;
|
|
1348
1373
|
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() });
|
|
1374
|
+
A.openDraftVw({ VW, pmGet, pmPost, toast, ws: M.board.ws, scope: M.docs.scope, doc: d, iniTitle: iniTitle(id), onIssued: () => load() });
|
|
1350
1375
|
return;
|
|
1351
1376
|
}
|
|
1352
1377
|
if ('ovAdddoc' in t.dataset) { // the form in the Viewer (home-adddoc.js): it posts to /api/custom-docs/add only
|
|
@@ -1363,28 +1388,17 @@ async function openFile(f) {
|
|
|
1363
1388
|
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
1389
|
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
1390
|
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
|
-
|
|
1391
|
+
// shell A (batch 18 item 2-C): the kind is a Document and the path is under ⋯ (Copy path), never in the body
|
|
1392
|
+
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>',
|
|
1393
|
+
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
1394
|
let txt = null;
|
|
1368
1395
|
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
1396
|
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
1397
|
}
|
|
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
|
-
}
|
|
1398
|
+
/* a stakeholder and the one stakeholder form (pm/small-vw.js; batch 18 item 2-C, canvas OvA8People), the same as the Board's */
|
|
1399
|
+
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() }; };
|
|
1400
|
+
function openPerson(p) { SV.openPersonVw(p, { ...personCtx(), back: null }); }
|
|
1401
|
+
function addPerson() { SV.openPersonForm(personCtx()); }
|
|
1388
1402
|
/* ── the metrics review (AgMetrics): the Strategist's conversation, and the review in the Viewer: three tiles, the correction rate by week
|
|
1389
1403
|
* (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
1404
|
* corrections from its run log, merges from its trunk, blocked from its workflow state); a measure that is not read says so. ── */
|
|
@@ -1458,10 +1472,7 @@ async function openMetrics(o = {}) {
|
|
|
1458
1472
|
if (S.sel !== id) return;
|
|
1459
1473
|
openTarget(metricsTarget());
|
|
1460
1474
|
}
|
|
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
|
-
}
|
|
1475
|
+
function openRoutine(s) { SV.openRoutineVw(s, { VW, now: S.D && S.D.now }); }
|
|
1465
1476
|
|
|
1466
1477
|
/* the agent's terminal, read only, in the Viewer (term-view.js) */
|
|
1467
1478
|
function openTerminal(sid) {
|
|
@@ -1629,12 +1640,23 @@ menuEl.onclick = (e) => { // delegated: every item is a <button role=menuitem>
|
|
|
1629
1640
|
document.addEventListener('click', (e) => { if (!menuEl.hidden && !menuEl.contains(e.target) && !(menu.anchor && menu.anchor.contains(e.target))) closeMenu(); }, true);
|
|
1630
1641
|
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menuEl.hidden) { e.stopPropagation(); closeMenu(); } else if (e.key === 'Escape' && S.sheet) sheet(false); }, true);
|
|
1631
1642
|
function searchGo(d) {
|
|
1643
|
+
if (d.merge) { mergeFrom(d.merge.from, d.merge.into); return; }
|
|
1632
1644
|
if (d.ini) goIni(d.ini);
|
|
1633
1645
|
else if (d.doc) openFile({ path: d.doc, name: d.doc.split('/').pop() });
|
|
1634
1646
|
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
1647
|
else if (d.link) location.href = d.link;
|
|
1636
1648
|
}
|
|
1637
1649
|
|
|
1650
|
+
/** 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
|
|
1651
|
+
* ⋯ › 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. */
|
|
1652
|
+
async function mergeFrom(from, into) {
|
|
1653
|
+
const rows = H.boardRows(S.D), both = rows.some((r) => r.id === from) && rows.some((r) => r.id === into);
|
|
1654
|
+
await goIni(from);
|
|
1655
|
+
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; }
|
|
1656
|
+
VW.drill();
|
|
1657
|
+
SM.openMerge(smCtx(from), into);
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1638
1660
|
/* ── the phone sheet ── */
|
|
1639
1661
|
function sheet(on) {
|
|
1640
1662
|
S.sheet = !!on;
|
|
@@ -1807,7 +1829,7 @@ mountLivePill(document, {
|
|
|
1807
1829
|
return true;
|
|
1808
1830
|
},
|
|
1809
1831
|
});
|
|
1810
|
-
PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m) }); drawList();
|
|
1832
|
+
PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m), skip: ['meeting'] }); drawList();
|
|
1811
1833
|
drawList(); drawTop();
|
|
1812
1834
|
{ // a conversation the address names opens at once, before the lists are read, so nothing typed or attached lands in the Home chat
|
|
1813
1835
|
const a = P.get('about') || '', early = /^(decision|blocked|waited|src|ev|work|board|doc|ins|chat|pop):[A-Za-z0-9][A-Za-z0-9._:-]{0,100}$/.test(a) && !P.get('open') && !P.get('session') ? a : null;
|
|
@@ -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);
|
|
@@ -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');
|
|
@@ -198,10 +199,11 @@ function waitRow(r) {
|
|
|
198
199
|
return `<div class="hm-r hv-r two" data-id="${esc(r.id)}"><button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"><span class="hv-mk">${mark}</span><span class="hm-rt"><b>${esc(r.name)}</b>${sub}</span></button></div>`;
|
|
199
200
|
}
|
|
200
201
|
const DSTATE = { review: 'Ready for you at your desk', done: 'Finished', sent: 'Sent' };
|
|
201
|
-
|
|
202
|
+
/* a draft row opens what it is (batch 18 item 3: both rows were dead on a phone): a finished draft opens what Claude wrote, the weekly update opens the update */
|
|
203
|
+
function draftRow(d, i) {
|
|
202
204
|
if (d.row) return waitRow({ ...d.row, sub: d.row.sub || 'Drafted for you' });
|
|
203
205
|
const f = d.fin;
|
|
204
|
-
return `<div class="hm-r hv-r two yd-fin"><
|
|
206
|
+
return `<div class="hm-r hv-r two yd-fin"><button type="button" class="hm-rm" data-yd="fin" data-i="${i}" aria-label="${esc(f.title)}. Open"><span class="hv-mk"><span class="yd-tick">${svg(CHECK, 13, 2.6)}</span></span><span class="hm-rt"><b>${esc(f.title)}</b><em>${esc(DSTATE[f.status] || 'Finished')}${f.summary ? ' · ' + esc(f.summary) : ''}</em></span></button></div>`;
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
/* the L figure in Your move when nothing needs the PM: his tea on a quiet day (AdB2), celebrating on an earned one (AdB3) */
|
|
@@ -216,14 +218,18 @@ export function nightHtml(Y) {
|
|
|
216
218
|
|
|
217
219
|
/* 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) */
|
|
218
220
|
const MARK2 = 'M2 12.5l4.5 4.5L15 8M9 15l2 2L22 7';
|
|
221
|
+
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';
|
|
219
222
|
export const NEWS_SHOWN = 3;
|
|
220
223
|
function newsRow(it, now) {
|
|
221
224
|
const who = it.kind === 'task' ? (it.from || 'Someone') : (it.product || 'Claude');
|
|
222
225
|
const when = it.at ? ago(new Date(it.at).toISOString(), now) : '';
|
|
223
|
-
const head = it.title;
|
|
224
|
-
|
|
226
|
+
const head = it.kind === 'task' ? String(it.title || '').replace(/^New task: /, '') : it.title;
|
|
227
|
+
// an overlap note is Claude's proposal (batch 18 item 2b): the ✦ tile and both initiatives by name, never an id
|
|
228
|
+
const sub = it.kind === 'overlap' ? [it.a && it.a.title, it.b && it.b.title].filter(Boolean).join(' and ') || 'Two open initiatives'
|
|
229
|
+
: 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(' · ')
|
|
225
230
|
: ['Finished while you were away', it.target, when].filter(Boolean).join(' · ');
|
|
226
|
-
|
|
231
|
+
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>`;
|
|
232
|
+
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>`;
|
|
227
233
|
}
|
|
228
234
|
/** 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.
|
|
229
235
|
* → a czSections row, or null when nothing is new and there is no digest (zero is silence). */
|
|
@@ -256,12 +262,10 @@ export function dayParts(Y, o = {}) {
|
|
|
256
262
|
if (Y.calls.length) sections.push({ id: 'move', title: 'Your move', count: Y.calls.length, open: true, html: Y.calls.map(callHtml).join('') });
|
|
257
263
|
else if (big) sections.push({ id: 'move', title: 'Your move', open: true, html: bigHtml(big) });
|
|
258
264
|
{ const nw = newsSection(Y.news || [], o.now, Y.digests || 0); if (nw) sections.push(nw); }
|
|
259
|
-
if (Y.drafts.length) sections.push({ id: 'drafts', title: 'Drafted for you', count: Y.drafts.length, html: `<div class="hv-card">${Y.drafts.map(draftRow).join('')}</div>` });
|
|
265
|
+
if (Y.drafts.length) sections.push({ id: 'drafts', title: 'Drafted for you', count: Y.drafts.length, html: `<div class="hv-card">${Y.drafts.map((d, i) => draftRow(d, i)).join('')}</div>` });
|
|
260
266
|
if (Y.wait.length) sections.push({ id: 'wait', title: 'Can wait', count: Y.wait.length, html: `<div class="hv-card hd-move">${Y.wait.map(waitRow).join('')}</div>` });
|
|
267
|
+
// the meeting on now or next is Home's own meeting line (say it once, batch 18 item 3); a phone's moment card shows only what Home does not
|
|
261
268
|
if (o.moment) sections.push({ id: 'now', title: 'Now', open: true, html: '<div class="hd-now"></div>' }); // drawDay puts the moment card in
|
|
262
|
-
else if (Y.next) {
|
|
263
|
-
sections.push({ id: 'next', title: Y.next.now ? 'On now' : 'Next meeting', count: Y.next.now ? '' : Y.next.time, html: `<div class="hv-card"><div class="hm-r hv-r two"><button type="button" class="hm-rm" data-hd-meet><span class="hv-mk">${svg(CLOCK, 15)}</span><span class="hm-rt"><b>${esc(Y.next.title)}</b><em>${esc(Y.next.now ? 'On now' : Y.next.time)}</em></span><span class="hv-cv">${svg(CHEV, 16)}</span></button></div></div>` });
|
|
264
|
-
}
|
|
265
269
|
if (Y.tomorrow && !o.moment) sections.push(tomorrowSection(Y.tomorrow)); // a phone's moment card already shows tomorrow at the end of the day (say it once)
|
|
266
270
|
sections.push({ id: 'week', title: 'This week', count: Y.week.sub, html: `<div class="hv-card"><div class="hm-r hv-r two" data-id="review"><button type="button" class="hm-rm" data-hm-review aria-label="Weekly review: ${esc(Y.week.sub)}. Open"><span class="hv-mk">${svg(CAL, 16)}</span><span class="hm-rt"><b>Weekly review</b><em>${esc(Y.week.sub)}</em></span><span class="hv-cv">${svg(CHEV, 16)}</span></button></div></div>` });
|
|
267
271
|
const scene = !big && o.first && Y.mood !== 'concerned' && new Date(now).getHours() < 12;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/* home-draft.js — a core document's draft, read in Home's Viewer, with Issue it (premium-agreed-design; initiative premium-core-doc-issue
|
|
2
|
-
*
|
|
3
|
-
* Read
|
|
1
|
+
/* home-draft.js — a core document's draft, read in Home's Viewer, with Issue it (premium-agreed-design; initiative premium-core-doc-issue;
|
|
2
|
+
* batch 18 item 2-C, canvas OvA9Docs). Shell A: the title, "A draft · <initiative>" under it, ✎ Edit in the header (pressed while editing,
|
|
3
|
+
* in place of the old Read | Edit tabs), ⋯ Copy path (the path is not in the body). The summary waits for you to read, with Issue it the one
|
|
4
|
+
* primary, above the text. Edit is the document page's own editor (premium-vw-doc.js, ctx.host), so a save goes through POST /api/doc-sheet/edit as everywhere else.
|
|
4
5
|
* Issue it posts POST /api/core-docs/issue { ws, scope, key, slot } and nothing else: it marks the draft issued and sends nothing to anyone.
|
|
5
6
|
* Issue it is refused here while the editor holds typed text that is not saved.
|
|
6
7
|
*
|
|
7
|
-
* openDraftVw({ VW, pmGet, pmPost, toast, ws, scope, doc, onIssued })
|
|
8
|
+
* openDraftVw({ VW, pmGet, pmPost, toast, ws, scope, doc, iniTitle?, onIssued })
|
|
8
9
|
* doc the docs row: { key, title, path, slot, st, state }
|
|
9
10
|
* onIssued awaited after the route answers ok (the page reads again)
|
|
10
11
|
*/
|
|
@@ -12,20 +13,22 @@ import { mdHtml } from './premium-doc-edit.js';
|
|
|
12
13
|
|
|
13
14
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
14
15
|
|
|
16
|
+
const PEN = 'M4 20h4L19 9l-4-4L4 16zM14 6l4 4', COPY = 'M8 8h11v12H8zM5 16V4h11';
|
|
17
|
+
|
|
15
18
|
export function openDraftVw(o) {
|
|
16
|
-
const d = o.doc;
|
|
19
|
+
const d = o.doc, VW = o.VW;
|
|
17
20
|
const X = { tab: 'read', text: null, err: '', issued: d.st !== 'draft', dirty: false, busy: false, msg: '' };
|
|
18
21
|
const wsq = () => (o.ws ? '&ws=' + encodeURIComponent(o.ws) : '');
|
|
22
|
+
const id = 'draft:' + o.scope + ':' + d.key;
|
|
19
23
|
let body = null;
|
|
20
|
-
const
|
|
21
|
-
?
|
|
22
|
-
: `<div
|
|
24
|
+
const sum = () => (X.issued
|
|
25
|
+
? `<div data-issue-bar="done" role="status">${VW.czSummary({ line: 'Issued', tone: 'ok', text: 'Nothing was sent to anyone.' })}</div>`
|
|
26
|
+
: `<div data-issue-bar="draft">${VW.czSummary({ line: 'Waits for you to read', tone: 'you', text: 'When it reads right, issue it. Issuing marks it issued and sends nothing to anyone.', primary: { label: 'Issue it', act: 'issue', disabled: X.busy } })}</div>`);
|
|
27
|
+
const presses = () => [{ act: 'edit', label: X.tab === 'edit' ? 'Back to reading' : 'Edit the draft', icon: PEN, pressed: X.tab === 'edit' }];
|
|
23
28
|
const draw = () => {
|
|
24
29
|
if (!body) return;
|
|
25
|
-
const tabs = `<div class="hx-tabs ut-chips" role="tablist" aria-label="Draft">${[['read', 'Read'], ['edit', 'Edit']].map(([k, l]) => `<button type="button" class="cz-chip${X.tab === k ? ' on' : ' gh'}" role="tab" aria-selected="${X.tab === k}" aria-pressed="${X.tab === k}" data-ds="${k}">${l}</button>`).join('')}</div>`;
|
|
26
30
|
const text = X.text == null ? `<p class="hx-n">${esc(X.err || 'Reading the draft.')}</p>` : `<div class="dsbody hm-md">${mdHtml(X.text).html}</div>`;
|
|
27
|
-
body.innerHTML =
|
|
28
|
-
+ (X.tab === 'read' ? text : '<div class="hm-dsed" data-ds-host></div>') + '</div>';
|
|
31
|
+
body.innerHTML = sum() + `<p class="czf-err" id="dsErr" role="alert">${esc(X.msg)}</p>` + (X.tab === 'read' ? text : '<div class="hm-dsed" data-ds-host></div>');
|
|
29
32
|
if (X.tab === 'edit') mountEditor();
|
|
30
33
|
};
|
|
31
34
|
async function read() {
|
|
@@ -42,19 +45,18 @@ export function openDraftVw(o) {
|
|
|
42
45
|
host.addEventListener('input', () => { X.dirty = true; });
|
|
43
46
|
host.addEventListener('keydown', (e) => { if (e.key.length === 1 || e.key === 'Backspace' || e.key === 'Delete' || e.key === 'Enter') X.dirty = true; });
|
|
44
47
|
const M = await import('./premium-vw-doc.js');
|
|
45
|
-
M.openDocPage({ path: d.path, title: d.title }, { host, ws: () => o.ws || '', onWrite: async () => { X.dirty = false; await read(); }, onClose: () => { X.dirty = false;
|
|
48
|
+
M.openDocPage({ path: d.path, title: d.title }, { host, ws: () => o.ws || '', onWrite: async () => { X.dirty = false; await read(); }, onClose: () => { X.dirty = false; tab('read'); } });
|
|
49
|
+
}
|
|
50
|
+
const say = (m) => { X.msg = m; const e = body.querySelector('#dsErr'); if (e) e.textContent = m; };
|
|
51
|
+
/** ✎ in the header: Edit, and pressed again, back to reading (refused while the editor holds typed text that is not saved) */
|
|
52
|
+
function tab(k) {
|
|
53
|
+
if (k === X.tab) return;
|
|
54
|
+
if (k === 'read' && X.dirty) { say('You have unsaved changes in Edit. Save or cancel them there.'); return; } // leaving Edit would drop the typed text
|
|
55
|
+
X.msg = ''; X.tab = k; if (VW.setPresses) VW.setPresses(id, presses()); draw(); if (k === 'read') read();
|
|
46
56
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const k = b.dataset.ds;
|
|
51
|
-
if (k === 'read' || k === 'edit') {
|
|
52
|
-
if (k === X.tab) return;
|
|
53
|
-
if (k === 'read' && X.dirty) { X.msg = 'You have unsaved changes in Edit. Save or cancel them there.'; body.querySelector('#dsErr').textContent = X.msg; return; } // leaving Edit would drop the typed text
|
|
54
|
-
X.msg = ''; X.tab = k; draw(); if (k === 'read') read(); return;
|
|
55
|
-
}
|
|
56
|
-
if (k !== 'issue') return;
|
|
57
|
-
if (X.dirty) { X.msg = 'This draft has unsaved changes. Save or cancel them first, then issue it.'; body.querySelector('#dsErr').textContent = X.msg; return; }
|
|
57
|
+
async function issue() {
|
|
58
|
+
if (X.issued || X.busy) return;
|
|
59
|
+
if (X.dirty) { say('This draft has unsaved changes. Save or cancel them first, then issue it.'); return; }
|
|
58
60
|
X.busy = true; X.msg = ''; draw();
|
|
59
61
|
const r = await o.pmPost('/api/core-docs/issue', { ws: o.ws, scope: o.scope, key: d.key, slot: d.slot });
|
|
60
62
|
X.busy = false;
|
|
@@ -62,6 +64,16 @@ export function openDraftVw(o) {
|
|
|
62
64
|
X.issued = true; draw();
|
|
63
65
|
o.toast('Issued. Nothing was sent to anyone.');
|
|
64
66
|
if (o.onIssued) await o.onIssued();
|
|
67
|
+
}
|
|
68
|
+
body = VW.open({ id, kind: 'Draft · ' + (d.state || 'Draft'), title: d.title, sub: 'A draft' + (o.iniTitle ? ' · ' + o.iniTitle : ''), icon: 'doc',
|
|
69
|
+
presses: presses(), onPress: (a) => { if (a === 'edit') tab(X.tab === 'edit' ? 'read' : 'edit'); },
|
|
70
|
+
more: [{ label: 'Copy path', icon: COPY, on: () => copy() }],
|
|
71
|
+
render: (b) => { body = b; draw(); } });
|
|
72
|
+
async function copy() {
|
|
73
|
+
try { await navigator.clipboard.writeText(d.path); o.toast('Path copied.'); } catch { o.toast('The path was not copied: ' + d.path); }
|
|
74
|
+
}
|
|
75
|
+
body.onclick = (e) => {
|
|
76
|
+
const b = e.target.closest('[data-czs-act="issue"]'); if (b && body.contains(b)) issue();
|
|
65
77
|
};
|
|
66
78
|
read();
|
|
67
79
|
return body;
|