create-pmos 0.429.0 → 0.431.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.
Files changed (70) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-board-test.js +2 -2
  8. package/workspace/briefing-premium-insights-test.js +1 -1
  9. package/workspace/changelog.json +24 -0
  10. package/workspace/guide/adler.md +45 -0
  11. package/workspace/guide/briefing-premium.md +2 -0
  12. package/workspace/guide/home.md +4 -4
  13. package/workspace/guide/index.md +1 -0
  14. package/workspace/guide/metric-drafts.md +2 -1
  15. package/workspace/guide/programs.md +4 -2
  16. package/workspace/intelligence-gaps-ui-test.js +168 -0
  17. package/workspace/lib/initiative-writer.js +16 -2
  18. package/workspace/lib/insight-moves.js +135 -0
  19. package/workspace/lib/insights-premium.js +4 -3
  20. package/workspace/lib/intel-report.js +16 -3
  21. package/workspace/lib/metric-drafts.js +32 -2
  22. package/workspace/lib/page-opens.js +74 -0
  23. package/workspace/lib/report-setups.js +1 -1
  24. package/workspace/lib/route-modules.js +2 -0
  25. package/workspace/lib/routes-insight-moves.js +119 -0
  26. package/workspace/lib/routes-insights-premium.js +10 -1
  27. package/workspace/lib/routes-metric-drafts.js +10 -1
  28. package/workspace/lib/routes-page-opens.js +26 -0
  29. package/workspace/lib/routes-report-setups.js +6 -1
  30. package/workspace/lib/settings-store.js +6 -0
  31. package/workspace/metric-drafts-ui-test.js +4 -4
  32. package/workspace/milestone-suggest-test.js +4 -4
  33. package/workspace/package-lock.json +2 -2
  34. package/workspace/package.json +1 -1
  35. package/workspace/premium-viewer-flicker-test.js +1 -1
  36. package/workspace/public/pm/bd-prog-panel.js +3 -3
  37. package/workspace/public/pm/bd-prog.js +2 -2
  38. package/workspace/public/pm/bd-span.js +17 -14
  39. package/workspace/public/pm/cozy-adler.css +82 -0
  40. package/workspace/public/pm/cozy-adler.js +270 -0
  41. package/workspace/public/pm/cozy-ev.css +3 -0
  42. package/workspace/public/pm/cozy-home.css +4 -0
  43. package/workspace/public/pm/cozy-insights.css +15 -1
  44. package/workspace/public/pm/cozy-nav.js +2 -0
  45. package/workspace/public/pm/cozy-search.js +4 -2
  46. package/workspace/public/pm/cozy-settings.js +15 -2
  47. package/workspace/public/pm/cozy-today.css +15 -0
  48. package/workspace/public/pm/cozy.css +16 -0
  49. package/workspace/public/pm/home-app.js +7 -9
  50. package/workspace/public/pm/home-chat.js +10 -2
  51. package/workspace/public/pm/home-day.js +39 -16
  52. package/workspace/public/pm/home-today.js +5 -3
  53. package/workspace/public/pm/ini-view-model.js +1 -1
  54. package/workspace/public/pm/ini-view.css +6 -0
  55. package/workspace/public/pm/ini-view.js +13 -0
  56. package/workspace/public/pm/metric-drafts.css +7 -0
  57. package/workspace/public/pm/metric-drafts.js +46 -7
  58. package/workspace/public/pm/ms-suggest.js +2 -1
  59. package/workspace/public/pm/premium-board.js +2 -2
  60. package/workspace/public/pm/premium-insights.js +76 -10
  61. package/workspace/public/pm/premium-vw-cal.js +1 -1
  62. package/workspace/public/pm/premium-welcome.js +3 -2
  63. package/workspace/public/pm/premium.css +3 -0
  64. package/workspace/public/pm/program-model.js +7 -0
  65. package/workspace/public/pm/split-merge.js +2 -1
  66. package/workspace/public/pm/stage-line.js +7 -5
  67. package/workspace/public/premium-intelligence.html +1 -1
  68. package/workspace/test-lists/intelligence-gaps-ui.json +5 -0
  69. package/workspace/test-lists/intelligence-gaps.json +5 -0
  70. package/workspace/test-lists/milestone-label.json +5 -0
@@ -12,9 +12,14 @@
12
12
  * a thank-you only from a real mention, a miss only from a failed task. No data, no line (zero is silence). The mood is never happier than
13
13
  * the data: concerned when something failed or is blocked, delighted at most once a week, calm on a packed or ordinary day.
14
14
  * Voice: Claude's Adlerian rules (canvas note ydAdler): thanks for contribution, no praise, no orders, say whose task it is, no blame,
15
- * no "N days late". dayModel is pure; dayParts turns it into the shell's sections. Text from records goes through esc(). */
15
+ * no "N days late". dayModel is pure; dayParts turns it into the shell's sections. Text from records goes through esc().
16
+ * Adler (batch 16 item 2) is the face: the M face on the opening card in the day's mood (ADLER: glad and calm are handled, delighted is
17
+ * celebrating, concerned is honest, a run still drafting is thinking); the morning scene on the day's first open before noon (AdP1);
18
+ * the L figure with his tea when nothing needs the PM (AdB2) or celebrating on an earned day (AdB3), and then the small face hides (one
19
+ * Adler per screen); after 22:00 the night scene guards the evening (AdP4) unless something is wrong, which is never hidden. */
16
20
 
17
21
  import { todayOf, hm } from './home-data.js';
22
+ import { adler, adlerScene, asleep, firstOpenToday } from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2): AdB1-3, AdP1, AdP4
18
23
 
19
24
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
20
25
  const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
@@ -104,28 +109,24 @@ export function dayModel(M, D, R, now = Date.now(), o = {}) {
104
109
  // no prep run today: say so, and offer it (Prepare my day); never claim work that did not happen
105
110
  if (!run && h < 17) offer = { kind: 'prep', text: 'I haven’t prepared today yet.', sub: 'Shall I prep your meetings and draft what I can?' };
106
111
  return {
107
- mood, line, sub, chips, misses, offer, calls, drafts, wait, done, thanks,
112
+ mood, face: run && run.working && mood === 'calm' ? 'working' : mood, line, sub, chips, misses, offer, calls, drafts, wait, done, thanks,
108
113
  next: next ? { meeting: next, now: next.state === 'now', time: hm(next.start), title: next.title || 'A meeting' } : null,
109
114
  week: { sub: un || 'Weekly review' },
110
115
  };
111
116
  }
112
117
 
113
- /* Claude's small mood face (glad, delighted, calm, concerned): the frames' faces, drawn in currentColor on a tinted disc */
114
- const MOUTH = {
115
- glad: '<path d="M7.5 13.5c1.3 2.2 2.8 3.2 4.5 3.2s3.2-1 4.5-3.2" fill="none" stroke-width="1.6" stroke-linecap="round"/>',
116
- delighted: '<path d="M7 13h10c-.6 3-2.6 4.6-5 4.6S7.6 16 7 13z" fill="currentColor" stroke-width="1.6" stroke-linejoin="round"/>',
117
- calm: '<path d="M8.5 15c1 .9 2.2 1.3 3.5 1.3s2.5-.4 3.5-1.3" fill="none" stroke-width="1.6" stroke-linecap="round"/>',
118
- concerned: '<path d="M7.6 7.6l2.4.9M16.4 7.6l-2.4.9" stroke-width="1.4" stroke-linecap="round"/><path d="M8.5 16.5c1-1.3 2.2-1.9 3.5-1.9s2.5.6 3.5 1.9" fill="none" stroke-width="1.6" stroke-linecap="round"/>',
119
- };
120
- export const faceHtml = (mood) => `<span class="yd-face ${esc(mood)}" role="img" aria-label="Claude is ${esc(mood)}"><svg width="32" height="32" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><circle cx="9" cy="10.5" r="1.3" fill="currentColor" stroke="none"/><circle cx="15" cy="10.5" r="1.3" fill="currentColor" stroke="none"/>${MOUTH[mood] || MOUTH.calm}</svg></span>`;
118
+ /* Claude's face is Adler's M face (it replaced the yellow mood circle): the day's mood read as his */
119
+ export const ADLER = { glad: 'handled', calm: 'handled', delighted: 'celebrating', concerned: 'honest', working: 'thinking' };
120
+ export const faceHtml = (mood) => `<span class="yd-face ad ${esc(mood)}">${adler(ADLER[mood] || 'handled', 48, { label: 'Claude is ' + mood })}</span>`;
121
121
  const ok = (act, label, id) => `<button type="button" class="yd-ok" data-yd="${esc(act)}"${id ? ` data-id="${esc(id)}"` : ''} aria-label="${esc(label)}" title="${esc(label)}">${svg(CHECK, 22, 2.6)}</button>`;
122
122
  const alt = (act, label, id, icon) => `<button type="button" class="yd-alt" data-yd="${esc(act)}"${id ? ` data-id="${esc(id)}"` : ''} aria-label="${esc(label)}" title="${esc(label)}">${svg(icon || OPEN, 18, 2)}</button>`;
123
123
 
124
124
  /** The opening card: face, line, sub, the chips of real work, and Claude's own misses with a ✓ to run them again. */
125
- export function openHtml(Y) {
125
+ export function openHtml(Y, o = {}) {
126
+ const head = o.scene ? `<div class="yd-scene">${adlerScene('morning', 'handled', { label: false })}</div>` : o.big ? '' : faceHtml(Y.face || Y.mood);
126
127
  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>` : '';
127
128
  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('');
128
- return `<div class="yd-open ${esc(Y.mood)}"><div class="yd-hd">${faceHtml(Y.mood)}<div class="yd-ht"><b>${esc(Y.line)}</b>${Y.sub ? `<em>${esc(Y.sub)}</em>` : ''}</div></div>${chips}${miss}</div>`
129
+ return `<div class="yd-open ${esc(Y.mood)}${o.scene ? ' has-scene' : ''}">${o.scene ? head : ''}<div class="yd-hd">${o.scene ? '' : head}<div class="yd-ht"><b>${esc(Y.line)}</b>${Y.sub ? `<em>${esc(Y.sub)}</em>` : ''}</div></div>${chips}${miss}</div>`
129
130
  + (Y.offer ? `<div class="yd-card yd-offer"><div class="yd-mt"><b>${esc(Y.offer.text)}</b><em>${esc(Y.offer.sub)}</em></div>${ok('prep', 'Prepare my day')}</div>` : '');
130
131
  }
131
132
 
@@ -147,11 +148,25 @@ function draftRow(d) {
147
148
  return `<div class="hm-r hv-r two yd-fin"><div class="hm-rm"><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></div></div>`;
148
149
  }
149
150
 
150
- /** The shell's parts for Your day (czSections takes them). o: { moment: true on a phone with the moment card } → { open, sections } */
151
+ /* the L figure in Your move when nothing needs the PM: his tea on a quiet day (AdB2), celebrating on an earned one (AdB3) */
152
+ const bigHtml = (kind) => (kind === 'win'
153
+ ? `<div class="yd-big">${adler('celebrating', 'l')}<b>That was everything that needed you today.</b></div>`
154
+ : `<div class="yd-big">${adler('handled', 'l', { label: 'Adler, handled, with his tea' })}<b>Nothing else needs you today.</b><em>I’ll tell you if that changes.</em></div>`);
155
+ /** After 22:00 (Settings > Adler > Quiet after), unless something is wrong: Adler asleep, and the day one press away (AdP4). */
156
+ export function nightHtml(Y) {
157
+ 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.';
158
+ 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>`;
159
+ }
160
+
161
+ /** The shell's parts for Your day (czSections takes them). o: { moment: true on a phone with the moment card, now, first: the day's first
162
+ * open (the morning scene) } → { open, sections, night } */
151
163
  export function dayParts(Y, o = {}) {
152
- const sections = [];
164
+ const sections = [], now = o.now || Date.now();
165
+ // the tea figure only after a real day (something done, drafted or waiting): nothing at all stays silent (zero is silence)
166
+ const real = Y.done > 0 || Y.chips.length || Y.drafts.length || Y.wait.length;
167
+ const big = Y.calls.length || Y.mood === 'concerned' ? null : Y.mood === 'delighted' ? 'win' : real ? 'tea' : null;
153
168
  if (Y.calls.length) sections.push({ id: 'move', title: 'Your move', count: Y.calls.length, open: true, html: Y.calls.map(callHtml).join('') });
154
- else if (Y.mood === 'delighted') sections.push({ id: 'move', title: 'Your move', open: true, html: '<div class="yd-card"><div class="yd-mt"><em>That was everything that needed you today.</em></div></div>' });
169
+ else if (big) sections.push({ id: 'move', title: 'Your move', open: true, html: bigHtml(big) });
155
170
  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>` });
156
171
  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>` });
157
172
  if (o.moment) sections.push({ id: 'now', title: 'Now', open: true, html: '<div class="hd-now"></div>' }); // drawDay puts the moment card in
@@ -159,11 +174,19 @@ export function dayParts(Y, o = {}) {
159
174
  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>` });
160
175
  }
161
176
  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>` });
162
- return { open: openHtml(Y), sections };
177
+ const scene = !big && o.first && Y.mood !== 'concerned' && new Date(now).getHours() < 12;
178
+ const night = Y.mood !== 'concerned' && asleep(now) ? nightHtml(Y) : '';
179
+ return { open: openHtml(Y, { big: !!big, scene }), sections, night };
163
180
  }
164
181
 
165
182
  /** Draws Your day into the Viewer's body: the opening card, then the folds; moment(el) puts the phone's moment card in Now. */
183
+ export { firstOpenToday };
166
184
  export function drawDay(body, P, VW, moment) {
185
+ if (P.night) { // AdP4: the evening is guarded; Open anyway shows the day, this once
186
+ body.innerHTML = `<div class="yd">${P.night}</div>`;
187
+ const b = body.querySelector('[data-yd="awake"]'); if (b) b.addEventListener('click', (e) => { e.stopPropagation(); drawDay(body, { ...P, night: '' }, VW, moment); });
188
+ return;
189
+ }
167
190
  body.innerHTML = `<div class="yd">${P.open}${VW.czSections(P.sections, { key: 'day' })}</div>`;
168
191
  const now = body.querySelector('.hd-now'); if (now && moment) moment(now);
169
192
  }
@@ -18,6 +18,7 @@ import { gripHtml, sugHtml } from './prog-order.js'; // a program's order: the
18
18
  import * as SO from './sort-order.js'; // the sort button and ONE order with the Board (batch 14 item 8, canvas SoAHomePhone)
19
19
  import { prodKey } from './order-model.js';
20
20
  import * as CW from './ctx-wedge.js'; // how full a session's context is: the pie, and Claude's ✦ Compact (batch 13 item 8, XctxA1Desk)
21
+ import * as AD from './cozy-adler.js'; // Adler greets on Home (batch 16 item 2, canvas AdH1): the M face, honest when the read failed
21
22
 
22
23
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
23
24
  export const P = {
@@ -269,7 +270,7 @@ const MOMENT = new Set(['rec', 'soon', 'live', 'eod', 'review']);
269
270
  /** M is homeList(); T todayCard(); o: { sel, ses (the initiative row whose pill is open), pOpen, restOpen, pin, avHtml, ready, err, pick (GET /api/briefing-premium/products), tones, review, phone, day (Your day is open) } */
270
271
  export function listHtml(M, T, o) {
271
272
  const flt = M.filter !== 'today' ? M.filters.find((f) => f.key === M.filter) : null;
272
- const head = `<div class="hm-hd hv-bar"><button type="button" class="hv-hi" data-hm-day aria-expanded="${!!o.day}" aria-label="${esc(M.word || 'Today')}. Open your day"><b>${esc(M.word || 'Today')}</b>${svg(P.chevD, 18)}</button>`
273
+ const head = `<div class="hm-hd hv-bar"><button type="button" class="hv-hi" data-hm-day aria-expanded="${!!o.day}" aria-label="${esc(M.word || 'Today')}. Open your day">${AD.adler(o.err ? 'honest' : 'handled', 36, { label: false, cls: 'hv-ad' })}<b>${esc(M.word || 'Today')}</b>${svg(P.chevD, 18)}</button>`
273
274
  // the product chip, always (it is also the way to add one): the ticked products' tiles, or All (canvas XhpA2States)
274
275
  + (o.pick ? chipHtml(o.pick, { id: 'hmPick', attrs: 'data-hm-pick', label: 'Products on Home', tones: o.tones }) : '')
275
276
  + (o.phone ? '' : `<button type="button" class="ut-ib hv-ib${flt ? ' on' : ''}" data-hm-flt aria-haspopup="menu" aria-label="Show: Today, Kept or Done${flt ? '. Now ' + esc(flt.label) : ''}" title="Show: Today, Kept or Done">${svg(P.filter, 18)}</button>`)
@@ -278,8 +279,9 @@ export function listHtml(M, T, o) {
278
279
  + (M.yours ? `<p class="hv-sub">${M.yours} ${M.yours === 1 ? 'is' : 'are'} yours</p>` : '');
279
280
  // the Today card only while the day has a moment; the plain day (its meetings and load) is in Your day
280
281
  const card = MOMENT.has(T.mode) ? todayHtml(T, { greet: M.greet, sub: '', phone: o.phone }) : '';
281
- if (!o.ready) return head + card + '<p class="hm-none" role="status">Reading your work.</p>';
282
- const errLine = `<p class="hm-none" role="status">Home could not read the repository: ${esc(o.err)}.</p>`;
282
+ // start-up and errors (canvas AdU9, AdU6): Adler wears his glasses while Home reads, and says a failure plainly; the greeting's face hides
283
+ if (!o.ready) return head + card + `<div class="hm-none hm-ad" role="status">${AD.adler('thinking', 'l', { label: false })}<p>Reading your work.</p></div>`;
284
+ const errLine = `<div class="hm-none hm-ad" role="status">${AD.adler('honest', 48, { label: false })}<p>Home could not read the repository: ${esc(o.err)}.</p></div>`;
283
285
  if (o.err && !M.groups.some((g) => (g.kind === 'product' && g.count) || (g.rows && g.rows.length))) return head + card + errLine;
284
286
  // the repository's read failed but sessions or notes still answered: say so above what did come back, never an empty product as if calm
285
287
  let body = o.err && !M.groups.some((g) => g.kind === 'product' && (g.count || g.flat.length)) ? errLine : '';
@@ -250,7 +250,7 @@ export function iniView(r, ctx = {}) {
250
250
  const lateSay = late.length ? plural(late.length, 'task is', 'tasks are') + ' late' + (late.length > 1 ? ', the oldest since ' + dateY(late.map((x) => x.end).sort()[0], today) : ', since ' + dateY(late[0].end, today)) + '.' : '';
251
251
  const why = whyText(r, list, cur, today, finished);
252
252
  const it = tr || {};
253
- const progress = jira ? (ctx.jiraAt || '') : r.progress != null && Number.isFinite(Number(r.progress)) ? Math.round(Number(r.progress)) + '% done · typed in by hand' : '';
253
+ const progress = jira ? (ctx.jiraAt || '') : r.progress != null && Number.isFinite(Number(r.progress)) ? Math.round(Number(r.progress)) + '% · by hand' : '';
254
254
  // what waits on the PM: the track's, else the trail's (the Board merges the trail into the track; Home reads the row as sent)
255
255
  const you = t.you || (it.you && it.you.text) || null, youKind = t.youKind || (it.you && it.you.kind) || null, youWhy = t.youWhy || (it.you && it.you.why) || '';
256
256
  let wait = null;
@@ -22,6 +22,12 @@
22
22
  .iv-s1 .iv-r + .iv-go { margin-left: 6px; }
23
23
  .iv-s1 b + .iv-go { margin-left: auto; }
24
24
  .iv-why { margin: 0; font-size: var(--fs-3); line-height: 1.5; color: var(--cz-ink); }
25
+ /* one row when the summary is only its status (batch 16 item 7): status, owner avatar, workflow icon, program, progress at the end */
26
+ .iv-sum.iv-one { padding: 8px 14px; }
27
+ .iv-one .iv-s1 { flex-wrap: wrap; row-gap: 4px; }
28
+ .iv-one .iv-meta { flex-wrap: nowrap; min-width: 0; gap: 8px; }
29
+ .iv-one .iv-prog { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
30
+ .iv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
25
31
  .iv-meta { margin: 0; font-size: var(--fs-2); color: var(--cz-ink3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
26
32
  .iv-meta > span, .iv-meta > button { display: inline-flex; align-items: center; gap: 5px; }
27
33
  .iv-meta .wfi { color: var(--cz-ink3); display: inline-flex; }
@@ -66,6 +66,19 @@ function summaryHtml(s, o = {}) {
66
66
  : `<span class="iv-wf">${wfIcon(s.wf, 15)}${esc(s.wf.name || 'Product feature')}</span>`);
67
67
  if (s.program) meta.push(`<button type="button" class="iv-prog" data-iv-program="${esc(s.program.id)}" title="Open the program ${esc(s.program.title)}">${SVG(P.prog, 15)}${esc(s.program.title)}</button>`);
68
68
  if (!s.line && !s.text && !go) return '';
69
+ // nothing to say beyond the status (batch 16 item 7, "feels like wasting space"): one row. The owner is the avatar, the workflow its icon,
70
+ // each named on hover and to a reader; the program keeps its name, because it is a press
71
+ if (!s.text && !go) {
72
+ const m = [];
73
+ if (s.status) m.push(`<span class="iv-st ${esc(s.status.tone)}"><i aria-hidden="true"></i>${esc(s.status.text)}</span>`);
74
+ m.push(s.owner ? `<span class="iv-who" title="${esc('Owner: ' + s.owner.name)}"><span class="iv-av" aria-hidden="true">${esc(s.owner.av)}</span><span class="iv-sr">${esc(s.owner.name)}</span></span>` : '<span class="iv-who q">No owner</span>');
75
+ const wn = s.wf ? s.wf.name || 'Product feature' : '';
76
+ if (s.wf) m.push(o.wf ? `<button type="button" class="iv-wf" data-iv-wf aria-haspopup="listbox" aria-label="${esc('Workflow: ' + wn + '. Change')}" title="${esc('Workflow: ' + wn + '. Change')}">${wfIcon(s.wf, 15)}<span class="iv-sr">${esc(wn)}</span></button>`
77
+ : `<span class="iv-wf" title="${esc('Workflow: ' + wn)}">${wfIcon(s.wf, 15)}<span class="iv-sr">${esc(wn)}</span></span>`);
78
+ if (s.program) m.push(`<button type="button" class="iv-prog" data-iv-program="${esc(s.program.id)}" title="Open the program ${esc(s.program.title)}">${SVG(P.prog, 15)}${esc(s.program.title)}</button>`);
79
+ return `<section class="iv-sum iv-one" aria-label="Summary"><div class="iv-s1 ${dot}">${dot && dot !== 'ok' ? '<span class="iv-dot" aria-hidden="true"></span>' : ''}<b>${esc(s.line)}</b>`
80
+ + `<p class="iv-meta">${m.join('')}</p>${s.right ? `<span class="iv-r">${esc(s.right)}</span>` : ''}</div></section>`;
81
+ }
69
82
  return `<section class="iv-sum" aria-label="Summary"><div class="iv-s1 ${dot}">${dot && dot !== 'ok' ? '<span class="iv-dot" aria-hidden="true"></span>' : ''}<b>${esc(s.line)}</b>`
70
83
  + `${s.right ? `<span class="iv-r">${esc(s.right)}</span>` : ''}${go}</div>${s.text ? `<p class="iv-why">${esc(s.text)}</p>` : ''}`
71
84
  + `<p class="iv-meta">${meta.join('<span class="iv-sep" aria-hidden="true">·</span>')}</p></section>`;
@@ -80,3 +80,10 @@
80
80
  .md-in { animation: md-in .3s ease-out both; }
81
81
  @keyframes md-in { from { opacity: 0; } to { opacity: 1; } }
82
82
  }
83
+
84
+ /* the inline edit (batch 16 item 1): each draft as one row of fields, its role over it */
85
+ .md-ed { display: flex; flex-direction: column; gap: 10px; }
86
+ .md-er { display: flex; flex-direction: column; gap: 4px; }
87
+ .md-ef { display: grid; grid-template-columns: minmax(0, 110px) minmax(0, 1fr); gap: 6px; align-items: center; }
88
+ .md-fld { box-sizing: border-box; width: 100%; min-width: 0; height: 32px; border: 1px solid var(--cz-hair); border-radius: 10px; padding: 0 9px; font: inherit; font-size: var(--fs-3); font-weight: 700; background: var(--cz-card); color: var(--cz-ink); }
89
+ .md-fld:focus { outline: 2px solid color-mix(in srgb, var(--cz-blueink) 45%, transparent); outline-offset: 0; border-color: var(--cz-blueink); }
@@ -11,11 +11,13 @@
11
11
  * open rows: "✦ Proposed success measure": Proves it worked, Early signal and Guardrail as Now → Target rows,
12
12
  * one line of why, then Edit and ✓ keep all
13
13
  * kept rows: the folded "Success measure · Set before the build · N" with its rows, and Undo
14
- * press(b, h) a press on [data-md]: keep all, Undo, the fold. h: { redraw(), toast(text) }. → true when it was one
14
+ * press(b, h) a press on [data-md]: keep all, Undo, the fold, Edit, Save, Cancel. h: { redraw(), toast(text) }. → true when it was one
15
15
  *
16
- * Zero is silence: no row drafted (or a read that failed) draws nothing. Discuss and Edit go to Home's chat with the question in the box; the
17
- * server has no edit of a draft, so a change is asked of Claude there. Nothing is kept until the PM's ✓. */
16
+ * Zero is silence: no row drafted (or a read that failed) draws nothing. Edit (✎) turns the card's rows into fields in place (batch 16 item 1):
17
+ * each row's name, target and where it is measured; ✓ saves them (POST /api/metric-drafts/edit, one per changed row), × puts them back, and the
18
+ * chat icon asks Claude in Home for anything else. Discuss goes to Home's chat. Nothing is kept until the PM's ✓ keep. */
18
19
  import { pmPost } from './http.js';
20
+ import { adler } from './cozy-adler.js'; // Claude drafted it unasked, so Adler holds the card (batch 16 item 2, canvas AdM3)
19
21
 
20
22
  (function sheet() { // once, at import: the parts show on the Board and in Home's Viewer, and the look must come with them on both
21
23
  if (typeof document === 'undefined' || !document.head || typeof document.getElementById !== 'function' || document.getElementById('mdCss')) return;
@@ -29,7 +31,7 @@ const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" heigh
29
31
  const I = {
30
32
  spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', ask: 'M4 5h16v11H9l-5 4z',
31
33
  pen: 'M4 20h4l10.5-10.5a2.1 2.1 0 0 0-3-3L5 17v3z', check: 'M5 12l5 5L20 7', undo: 'M9 14L4 9l5-5M4 9h11a5 5 0 0 1 0 10h-3',
32
- right: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5',
34
+ right: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', x: 'M6 6l12 12M18 6L6 18',
33
35
  };
34
36
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
35
37
  const DAY = /^(\d{4})-(\d{2})-(\d{2})/;
@@ -40,6 +42,7 @@ const month = (iso) => { const m = DAY.exec(String(iso || '')); return m ? MON[+
40
42
  const READ = new Map(); // scope|id → { ws, d: the GET answer | null, reading, busy }
41
43
  const SEEN = new Set(); // scope|id whose part has been drawn once: the soft fade runs on the first draw only, never on a redraw
42
44
  const FOLD = new Set(); // initiative ids whose kept success measure is open (it starts folded: summary first)
45
+ const EDIT = new Set(); // scope|id whose proposal is open for an inline edit
43
46
  const keyOf = (scope, id) => scope + '|' + id;
44
47
  function fetchOne(ws, scope, id) {
45
48
  const q = new URLSearchParams({ scope, id }); if (ws) q.set('ws', ws);
@@ -82,10 +85,23 @@ const homeHref = (o) => { const q = new URLSearchParams(); for (const [k, v] of
82
85
  const ib = (o) => (o.href
83
86
  ? `<a class="md-ib" href="${esc(o.href)}" aria-label="${esc(o.label)}" title="${esc(o.title || o.label)}">${SVG(o.icon)}</a>`
84
87
  : `<button type="button" class="md-ib${o.solid ? ' solid' : ''}" data-md="${esc(o.act)}" data-md-scope="${esc(o.scope)}" data-md-id="${esc(o.id)}" aria-label="${esc(o.label)}" title="${esc(o.title || o.label)}"${o.busy ? ' disabled' : ''}>${SVG(o.icon, 16, o.solid ? 2.2 : 1.8)}</button>`);
85
- const head = (label, src) => `<div class="md-hd"><span class="md-sp">${SVG(I.spark)}</span><b>${esc(label)}</b>${src ? `<span class="md-src">${esc(src)}</span>` : ''}</div>`;
88
+ const head = (label, src) => `<div class="md-hd"><span class="md-sp ad">${adler('needs-you', 32, { label: false })}</span><b>${esc(label)}</b>${src ? `<span class="md-src">${esc(src)}</span>` : ''}</div>`;
86
89
  /** The one line of why: the server's line for the whole draft, else the lead row's own. */
87
90
  const whyOf = (d, lead) => String((d && d.sub) || (lead && lead.why) || '');
88
91
 
92
+ /* ── the inline edit (batch 16 item 1): one field row per open draft; the card's footer turns into ask, ×, ✓ ── */
93
+ const field = (r, f, val, label, o = {}) => `<input class="md-fld${o.cls ? ' ' + o.cls : ''}" data-md-f="${f}" data-md-row="${esc(r.id)}" value="${esc(val)}" aria-label="${esc(label)}"${o.ph ? ` placeholder="${esc(o.ph)}"` : ''}${o.num ? ' inputmode="decimal"' : ''} maxlength="${o.max || 80}">`;
94
+ function editRows(rows, label) {
95
+ return `<div class="md-ed" role="list">${rows.map((r) => `<div class="md-er" role="listitem"><span class="md-role">${esc(label(r))}</span>`
96
+ + field(r, 'name', r.name, 'Name of ' + r.name)
97
+ + `<span class="md-ef">${r.type === 'Done or not' ? `<b class="md-to">${esc(r.targetTxt || 'Done')}</b>` : field(r, 'target', r.target == null ? '' : String(r.target), 'Target of ' + r.name, { num: true, cls: 'n', max: 20, ph: 'Target' })}`
98
+ + field(r, 'source', r.source || '', 'Where ' + r.name + ' is measured', { ph: 'Measured by', max: 40 }) + '</span></div>').join('')}</div>`;
99
+ }
100
+ const editFoot = (scope, id, ask, busy) => `<div class="md-ft"><p class="md-why">Name, target and where it is measured. Anything else, ask me in Home.</p>`
101
+ + ib({ href: ask, icon: I.ask, label: 'Ask Claude in Home to change something else', title: 'Ask in Home' })
102
+ + ib({ act: 'cancel', scope, id, icon: I.x, label: 'Cancel the edit', title: 'Cancel', busy })
103
+ + ib({ act: 'save', scope, id, icon: I.check, label: 'Save the edit', title: 'Save', solid: true, busy }) + '</div>';
104
+
89
105
  /* ── the program: the proposed goal, then the kept Goal row ── */
90
106
  export function progHtml(p, ws) {
91
107
  if (!p || !p.id) return '';
@@ -107,11 +123,13 @@ export function progHtml(p, ws) {
107
123
  + rolls.map((r) => { const [a, ...b] = String(r.name).split(' · ');
108
124
  return `<div class="md-ru" role="row"><span role="cell">${b.length ? `<b>${esc(a)}</b> · ${esc(b.join(' · '))}` : esc(a)}</span><span role="cell">${esc(nowOf(r))}</span><span role="cell">${r.ticket && r.now == null ? ticketPill(r.ticket) : esc([r.targetTxt, r.by ? 'by ' + day(r.by) : ''].filter(Boolean).join(' '))}</span></div>`; }).join('') + '</div>' : '';
109
125
  const q = (w) => homeHref({ ws: ws || p.home, ask: 'program:' + p.id, q: w + p.title + ': ' });
126
+ if (EDIT.has(keyOf('program', p.id))) return `<section class="md-card md-top" aria-label="Edit the proposed goal">${head('Proposed goal', P.d.src)}`
127
+ + editRows([goal].concat(rolls, guard), (r) => (r === goal ? 'Goal' : String(r.group || ''))) + editFoot('program', p.id, q('Change the proposed goal for '), P.busy) + '</section>';
110
128
  return `<section class="md-card md-top${fade('program', p.id)}" aria-label="Proposed goal">${head('Proposed goal', P.d.src)}<p class="md-gl">${esc(line)}</p>`
111
129
  + (chips ? `<div class="md-cps">${chips}</div>` : '') + built
112
130
  + `<div class="md-ft"><p class="md-why">${esc(whyOf(P.d, goal))}</p>`
113
131
  + ib({ href: q('About the proposed goal for '), icon: I.ask, label: 'Discuss the proposed goal in Home', title: 'Discuss in Home' })
114
- + ib({ href: q('Change the proposed goal for '), icon: I.pen, label: 'Edit the proposed goal in Home', title: 'Edit' })
132
+ + ib({ act: 'edit', scope: 'program', id: p.id, icon: I.pen, label: 'Edit the proposed goal', title: 'Edit', busy: P.busy })
115
133
  + ib({ act: 'keep', scope: 'program', id: p.id, icon: I.check, label: 'Keep this goal', solid: true, busy: P.busy }) + '</div></section>';
116
134
  }
117
135
 
@@ -134,8 +152,9 @@ export function iniHtml(id, ws, title) {
134
152
  }
135
153
  const row = (r) => `<div class="md-mr"><span class="md-nm"><span class="md-role">${esc(roleOf(r))}</span><b>${esc(r.name)}</b>${r.ticket && r.now == null ? `<small>${ticketPill(r.ticket)}</small>` : r.why && r.why !== why ? `<small>${esc(r.why)}</small>` : ''}</span><span class="md-now">${esc(nowOf(r))}</span><b class="md-to">${esc(targetOf(r))}</b></div>`;
136
154
  const q = homeHref({ ws, ask: id, q: 'Change the proposed success measure for ' + (title || id) + ': ' });
155
+ if (EDIT.has(keyOf('initiative', id))) return `<section class="md-card" aria-label="Edit the proposed success measure">${head('Proposed success measure', P.d.src)}` + editRows(R, roleOf) + editFoot('initiative', id, q, P.busy) + '</section>';
137
156
  return `<section class="md-card${fade('initiative', id)}" aria-label="Proposed success measure">${head('Proposed success measure', P.d.src)}<div class="md-ms" role="list">${R.map(row).join('')}</div>`
138
- + `<div class="md-ft"><p class="md-why">${esc(why)}</p>${ib({ href: q, icon: I.pen, label: 'Edit the proposed success measure in Home', title: 'Edit' })}`
157
+ + `<div class="md-ft"><p class="md-why">${esc(why)}</p>${ib({ act: 'edit', scope: 'initiative', id, icon: I.pen, label: 'Edit the proposed success measure', title: 'Edit', busy: P.busy })}`
139
158
  + ib({ act: 'keep', scope: 'initiative', id, icon: I.check, label: 'Keep this success measure', solid: true, busy: P.busy }) + '</div></section>';
140
159
  }
141
160
 
@@ -145,7 +164,27 @@ export function press(b, h = {}) {
145
164
  const scope = b.dataset.mdScope, id = b.dataset.mdId, one = READ.get(keyOf(scope, id));
146
165
  const redraw = () => { if (h.redraw) h.redraw(); }, say = (m) => { if (h.toast) h.toast(m); };
147
166
  if (a === 'fold') { if (FOLD.has(id)) FOLD.delete(id); else FOLD.add(id); redraw(); return true; }
167
+ if (a === 'edit') { EDIT.add(keyOf(scope, id)); redraw(); return true; }
168
+ if (a === 'cancel') { EDIT.delete(keyOf(scope, id)); redraw(); return true; }
148
169
  if (!one || !one.d || one.busy) return true;
170
+ if (a === 'save') {
171
+ // what each field row says now, against the draft as read: only a changed row is sent
172
+ const card = b.closest('section') || (typeof document !== 'undefined' ? document : null), want = new Map();
173
+ for (const x of card ? card.querySelectorAll('[data-md-f]') : []) { const r = x.dataset.mdRow; if (!want.has(r)) want.set(r, {}); want.get(r)[x.dataset.mdF] = x.value; }
174
+ const rows = rowsOf(one.d).filter((r) => r.state === 'open' && want.has(r.id)).map((r) => ({ r, w: want.get(r.id) }))
175
+ .filter(({ r, w }) => (w.name !== undefined && w.name.trim() !== r.name) || (w.source !== undefined && w.source.trim() !== (r.source || '')) || (w.target !== undefined && w.target.trim() !== (r.target == null ? '' : String(r.target))));
176
+ if (!rows.length) { EDIT.delete(keyOf(scope, id)); redraw(); say('Nothing changed.'); return true; }
177
+ one.busy = true; redraw();
178
+ (async () => {
179
+ let bad = null;
180
+ for (const { r, w } of rows) { const res = await pmPost('/api/metric-drafts/edit', { ws: one.ws || null, scope, id, row: r.id, ...w }).catch(() => null); if (!res || !res.ok) { bad = (res && res.error) || 'Not saved. The server did not say why.'; break; } }
181
+ one.busy = false;
182
+ if (bad) { say(bad); redraw(); return; }
183
+ EDIT.delete(keyOf(scope, id)); say('Saved. Keep it to track it as you wrote it.');
184
+ await again(scope, id, redraw);
185
+ })();
186
+ return true;
187
+ }
149
188
  const body = { ws: one.ws || null, scope, id };
150
189
  one.busy = true; redraw();
151
190
  (async () => {
@@ -11,6 +11,7 @@
11
11
  * Every press is icon-only: ✓ keeps, the pencil opens the charter with the change filled in, ✕ drops it (Claude does not ask again unless the
12
12
  * source changes). A row says why and where it came from. Nothing shows when there is nothing to suggest (zero is silence). The presses carry
13
13
  * data-ms-act and data-key; the panel handles them. */
14
+ import { adler } from './cozy-adler.js'; // Adler holds Claude's suggested milestones (batch 16 item 2, canvas AdM2); the rows keep their ✦
14
15
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
15
16
  const SV = (d, w, sw) => `<svg viewBox="0 0 24 24" width="${w || 16}" height="${w || 16}" fill="none" stroke="currentColor" stroke-width="${sw || 1.8}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
16
17
  const I = {
@@ -78,7 +79,7 @@ export function firstHtml(p, L) {
78
79
  const n = L.length, from = fromWords(L);
79
80
  const all = L.length > 1 ? `<span class="msg-ends"><button type="button" class="msg-ok" data-ms-act="keepall" aria-label="Keep all ${n} suggestions" title="Keep all">${SV(I.check, 15, 2.4)}</button>`
80
81
  + `<button type="button" class="msg-ib" data-ms-act="dropall" aria-label="Drop all ${n} suggestions" title="Drop all">${SV(I.x, 15)}</button></span>` : '';
81
- return `<div class="msg-box" role="group" aria-label="Claude's suggested milestones"><div class="msg-hd"><span class="msg-mk" aria-hidden="true">${SV(I.spark, 14)}</span>`
82
+ return `<div class="msg-box" role="group" aria-label="Claude's suggested milestones"><div class="msg-hd"><span class="msg-mk ad" aria-hidden="true">${adler('needs-you', 28, { label: false })}</span>`
82
83
  + `<span class="msg-ht"><b>Claude suggests ${n} ${plural(n, 'milestone', 'milestones')}</b>${from ? ' from ' + esc(from) : ''}</span>${all}</div>`
83
84
  + `<div role="list">${L.map((i) => rowHtml(p, i, 'first')).join('')}</div></div>`;
84
85
  }
@@ -32,7 +32,7 @@ import * as V from './bd-views.js';
32
32
  import * as WF from './bd-wf.js';
33
33
  import * as Asks from './bd-asks.js';
34
34
  import * as PG from './bd-prog.js';
35
- import { programOf } from './program-model.js';
35
+ import { programOf, liveRows } from './program-model.js';
36
36
  import { open as viewerOpen, current as viewerCur } from './cozy-viewer.js';
37
37
  import * as VW from './cozy-viewer.js';
38
38
  import * as PP from './bd-prog-panel.js';
@@ -671,7 +671,7 @@ async function loadOthers() {
671
671
  let a = null; try { a = await (await fetch('/api/board-premium?ws=' + encodeURIComponent(w) + '&board=' + encodeURIComponent(b.id), { credentials: 'same-origin' })).json(); } catch { a = null; }
672
672
  const m = a && a.ok && a.model; if (!m) continue; // still reading, or not read: the member stays "missing", never guessed
673
673
  const st = m.steps || [];
674
- XR[w] = { name: (m.board && (m.board.product || m.board.name)) || b.name, rows: (m.rows || []).filter((x) => x.id).map((x) => ({ id: x.id, title: x.title, stage: x.track && x.track.k >= 0 && st[x.track.k] ? st[x.track.k].key : x.stage, start: x.start || null, end: x.end || null })) };
674
+ XR[w] = { name: (m.board && (m.board.product || m.board.name)) || b.name, rows: liveRows(m).filter((x) => x.id).map((x) => ({ id: x.id, title: x.title, stage: x.track && x.track.k >= 0 && st[x.track.k] ? st[x.track.k].key : x.stage, start: x.start || null, end: x.end || null })) };
675
675
  }
676
676
  if (Object.keys(XR).length) drawInit();
677
677
  }
@@ -34,6 +34,7 @@ import * as PK from './cozy-pick.js'; // the one product picker Home, Board an
34
34
  import { openReport } from './premium-report-read.js';
35
35
  import { mountNav } from './cozy-nav.js';
36
36
  import { mountLivePill } from './cozy-live-pill.js';
37
+ import * as AD from './cozy-adler.js'; // Adler in Claude's ✦ line only, never in a chart (batch 16 item 2, canvas AdH3, AdM3)
37
38
  import * as RI from './premium-report-intel.js'; // a report made from Intelligence (batch 15 item 4): the header icon, the ✦ proposals, the draft panel
38
39
 
39
40
  let M = null; // the model
@@ -218,7 +219,16 @@ document.addEventListener('cz-viewer', (e) => {
218
219
  const d = e.detail || {}, id = d.open && /^goal:/.test(d.id || '') ? d.id.slice(5) : null;
219
220
  if ((new URLSearchParams(location.search).get('goal') || null) !== id) addr({ goal: id });
220
221
  });
221
- function setView(id) { dash = id; closeLib(); redraw(); }
222
+ function setView(id) { dash = id; closeLib(); redraw(); noteOpen(); }
223
+ /* the view on screen, noted once a day per view (feedback batch 16 item 1; POST /api/page-opens, local only): it is what lets the ✦ strip say
224
+ * "You open this every week" from a record, never from a guess. Portfolio is no one product's view, so it is not noted. */
225
+ const NOTED = new Set();
226
+ async function noteOpen() {
227
+ if (!M || PF || !M.board.ws) return;
228
+ const D = curDash(), view = D && D.saved ? 'dashboard:' + D.id : 'view', k = M.board.ws + '|' + view;
229
+ if (NOTED.has(k)) return; NOTED.add(k);
230
+ await Promise.resolve(pmPost('/api/page-opens', { ws: M.board.ws, page: 'intelligence', view })).catch(() => null);
231
+ }
222
232
 
223
233
  /* Portfolio: the goals of the ticked products (several ticked, batch 12 item 5), each product's model read once through GET /api/insights-premium,
224
234
  * grouped by product. A goal of another product keeps its own workspace, so a reading added to it goes there. Budgets, Outcomes and Library stay
@@ -341,38 +351,62 @@ const ABOUT = '<div class="ins-about"><p>Every goal is a KR metric record of thi
341
351
  + '<p>A press records only what it says: a goal in the KR metric records, or a dashboard in the workspace’s state folder. Nothing is sent from this page.</p></div>';
342
352
 
343
353
  /* ── the ✦ strip (Iq8Overview): one finding at a time, said plainly with its reason; the dots page through up to three and × moves on to the
344
- * next one. Ask why takes the finding to Home. A finding carries a drafted move only when the engine has one: then ✓ makes it and Undo takes it
345
- * back. None has a move yet, so no ✓ is drawn rather than a press that does nothing. ── */
354
+ * next one. Ask why takes the finding to Home. A finding carries a drafted move only when the engine has one (feedback batch 16 item 1,
355
+ * lib/insight-moves.js: chase the owner, anchor an initiative, move the date): the move is said under the reason, ✓ makes it (POST
356
+ * /api/insight-moves/apply, the server finds the move again by its sig) and Undo takes it back (/undo). A finding with no move draws no ✓. ── */
346
357
  let insIdx = 0;
347
358
  const insSkip = new Set(); // the findings put off with Not now, this visit only
348
359
  function stripList() {
349
360
  const I0 = M.insight || { none: true, text: '' };
350
361
  if (I0.none) return [{ text: I0.text, why: I0.why || '', none: true }].concat(PF ? [] : RI.stripItems());
351
- return [{ text: I0.text, why: I0.why || '', chart: I0.chart }].concat((I0.more || []).map((x) => ({ text: x.text, why: '', chart: x.chart })), PF ? [] : RI.stripItems());
362
+ return [{ text: I0.text, why: I0.why || '', chart: I0.chart, move: I0.move || null }].concat((I0.more || []).map((x) => ({ text: x.text, why: x.why || '', chart: x.chart, move: x.move || null })), PF ? [] : RI.stripItems());
352
363
  }
353
364
  function drawStrip() {
354
365
  const G = goalsShown(), behind = G.filter((g) => g.tone === 'late' || g.tone === 'red').length;
355
- $('#insEye').textContent = ''; $('#insAct').innerHTML = ''; $('#insPg').innerHTML = '';
366
+ $('#insEye').textContent = ''; $('#insAct').innerHTML = ''; $('#insPg').innerHTML = ''; $('#insMv').hidden = true; $('#insMv').innerHTML = ''; $('#insHero').classList.remove('mv');
356
367
  if (PF) { $('#brief').textContent = 'Portfolio: ' + nGoals(G.length) + ' across ' + PF.products.length + (PF.products.length === 1 ? ' product' : ' products') + (behind ? ', ' + behind + ' behind.' : '.'); $('#insWhy').textContent = 'The finding under it is read one product at a time.'; $('#askWhy').href = homeAsk('insights', 'Which product needs me most this quarter?'); $('#askWhy').hidden = false; return; }
357
368
  const L = stripList(), open = L.map((f, i) => i).filter((i) => !insSkip.has(i));
358
369
  if (!open.includes(insIdx)) insIdx = open.length ? open[0] : 0;
359
370
  const f = L[insIdx];
360
371
  $('#brief').textContent = f.text;
361
372
  $('#insWhy').textContent = f.why || '';
373
+ // Claude's line carries Adler's face in the line's mood: honest when a goal is behind or the finding says so plainly, needs you on a
374
+ // proposal, handled otherwise. The charts and KR rows below stay pure data.
375
+ const sp = $('#insHero .sp');
376
+ if (sp) { sp.classList.add('ad'); sp.innerHTML = AD.adler(f.report ? 'needs-you' : behind || /^Straight answer/.test(f.text) || AD.moodOfText(f.text) === 'honest' ? 'honest' : 'handled', 40, { label: false }); }
362
377
  $('#askWhy').href = homeAsk('insights', f.none ? 'Why is there no finding on my goals yet?' : 'Why? ' + f.text);
363
378
  $('#askWhy').hidden = !!f.report; $('#askWhy').style.display = f.report ? 'none' : ''; // a report Claude proposes carries its own presses: See the draft, Not now, ✓ Set it up
364
379
  if (f.report) $('#insAct').innerHTML = RI.stripActs(f.report);
380
+ const mv = !f.report && f.move ? f.move : null;
381
+ $('#insHero').classList.toggle('mv', !!mv);
382
+ if (mv) { $('#insMv').innerHTML = `${SV(I.spark)}<span>${esc(mv.text)}</span>`; $('#insMv').hidden = false; $('#insMv').classList.toggle('dn', !!mv.done); }
383
+ const mvAct = !mv ? '' : mv.done ? `<span class="cz-pill ok">Done</span><button type="button" class="cz-ib sm" data-mv="undo" aria-label="Undo: ${esc(mv.label)}" title="Undo">${SV(I.undo)}</button>`
384
+ : `<button type="button" class="cz-ib sm solid" data-mv="apply" aria-label="${esc(mv.label)}" title="${esc(mv.label)}">${SV(I.chk)}</button>`;
385
+ if (!f.report) $('#insAct').innerHTML = mvAct;
365
386
  if (open.length > 1) {
366
- if (!f.report) $('#insAct').innerHTML = `<button type="button" class="cz-ib sm" id="insNo" aria-label="Not now" title="Not now">${SV(I.x)}</button>`;
387
+ if (!f.report) $('#insAct').innerHTML = `<button type="button" class="cz-ib sm" id="insNo" aria-label="Not now" title="Not now">${SV(I.x)}</button>` + mvAct;
367
388
  $('#insPg').innerHTML = L.map((x, i) => `<button type="button" class="${i === insIdx ? 'on' : ''}" data-ins="${i}" aria-label="Finding ${i + 1} of ${L.length}" aria-pressed="${i === insIdx}"${insSkip.has(i) ? ' hidden' : ''}></button>`).join('');
368
389
  }
369
390
  }
370
391
  $('#insHero').addEventListener('click', async (e) => {
371
392
  if (e.target.closest('[data-rp]')) { await RI.stripPress(e); return; }
393
+ const b = e.target.closest('[data-mv]'); if (b) { await pressMove(b); return; }
372
394
  const d = e.target.closest('[data-ins]'); if (d) { insIdx = +d.dataset.ins; drawStrip(); return; }
373
395
  if (e.target.closest('#insNo')) { insSkip.add(insIdx); const L = stripList(), n = L.findIndex((x, i) => i > insIdx && !insSkip.has(i)); insIdx = n >= 0 ? n : L.findIndex((x, i) => !insSkip.has(i)); drawStrip(); }
374
396
  });
375
397
 
398
+ /** ✓ on a drafted move, or Undo on a made one. The server finds the move again by its sig; the toast carries Undo. */
399
+ async function pressMove(b) {
400
+ const f = stripList()[insIdx], mv = f && f.move; if (!mv || b.disabled) return;
401
+ b.disabled = true;
402
+ const undo = async () => { const r = await pmPost('/api/insight-moves/undo', { ws: M.board.ws, sig: mv.sig }); toast(r && r.ok ? 'Undone. It is as it was.' : (r && r.error) || 'It could not be undone.'); await load(); };
403
+ if (b.dataset.mv === 'undo') { await undo(); return; }
404
+ const r = await pmPost('/api/insight-moves/apply', { ws: M.board.ws, board: M.board.id, sig: mv.sig });
405
+ if (!r || r.ok !== true) { b.disabled = false; toast((r && r.error) || 'It could not be done. Nothing changed.'); return; }
406
+ toast(r.said || mv.said || 'Done.', { label: 'Undo', fn: undo });
407
+ await load();
408
+ }
409
+
376
410
  /* ── the North Star and its inputs (Iq8Overview): the KR metric record with role north-star, drawn as its number with the change against the
377
411
  * span before it and its readings as a line; the records with role input (and guardrail) as a list beside it, each with its change over the same
378
412
  * span. Every number is a reading. With no North Star the row is not drawn (zero is silence); Claude's drafts say what is missing. ── */
@@ -440,8 +474,8 @@ $('#nsRow').addEventListener('click', (e) => {
440
474
  });
441
475
 
442
476
  /* ── what Claude drafted (Iq8Suggest, Iq9Draft): GET /api/metric-drafts for this product. While a run drafts, the five steps and what it read;
443
- * once ready, each proposed metric with its Now, its Target, why that target and where it is measured, ✓ to track it and × to remove it, ✓ all for
444
- * the rest. A ✓ writes a KR metric record (lib/routes-metric-drafts.js); Undo takes it back. Nothing drafted: the box is not drawn. ── */
477
+ * once ready, each proposed metric with its Now, its Target, why that target and where it is measured, ✎ to edit its name, target and source in
478
+ * place (batch 16 item 1), ✓ to track it and × to remove it, ✓ all for the rest. A ✓ writes a KR metric record (lib/routes-metric-drafts.js); Undo takes it back. Nothing drafted: the box is not drawn. ── */
445
479
  let DR = null, drTimer = 0;
446
480
  const DR_STEPS = ['Read', 'Shape', 'Measure', 'Target', 'Ready'];
447
481
  async function draftsLoad() {
@@ -466,8 +500,9 @@ function drawDrafts() {
466
500
  let grp = '';
467
501
  const body = rows.map((r) => {
468
502
  const g = r.group !== grp ? `<div class="ins-grp" role="row"><span role="cell">${esc(r.group)}</span></div>` : ''; grp = r.group;
503
+ if (r.state === 'open' && drEdit === r.id) return g + drEditRow(r);
469
504
  const src = r.ticket ? `<span class="cz-pill risk">${esc(r.ticket.text || (r.ticket.key + ' drafted'))}</span>` : r.source ? `<span class="note">${esc(r.source)}</span>` : '';
470
- const act = r.state === 'open' ? `<button type="button" class="cz-ib sm" data-dr="drop" data-row="${esc(r.id)}" aria-label="Remove ${esc(r.name)}" title="Remove">${SV(I.x)}</button><button type="button" class="cz-ib sm solid" data-dr="keep" data-row="${esc(r.id)}" aria-label="Track ${esc(r.name)}" title="Track this metric">${SV(I.chk)}</button>`
505
+ const act = r.state === 'open' ? `<button type="button" class="cz-ib sm" data-dr="edit" data-row="${esc(r.id)}" aria-label="Edit ${esc(r.name)}" title="Edit">${SV(I.pen)}</button><button type="button" class="cz-ib sm" data-dr="drop" data-row="${esc(r.id)}" aria-label="Remove ${esc(r.name)}" title="Remove">${SV(I.x)}</button><button type="button" class="cz-ib sm solid" data-dr="keep" data-row="${esc(r.id)}" aria-label="Track ${esc(r.name)}" title="Track this metric">${SV(I.chk)}</button>`
471
506
  : `<span class="cz-pill ${r.state === 'kept' ? 'ok' : 'q'}">${r.state === 'kept' ? 'Tracking' : 'Removed'}</span><button type="button" class="cz-ib sm" data-dr="undo" data-row="${esc(r.id)}" aria-label="Undo" title="Undo">${SV(I.undo)}</button>`;
472
507
  return g + `<div class="ins-tr ins-row ins-dcols${r.state === 'dropped' ? ' gone' : ''}" role="row"><div class="nm" role="cell"><b>${esc(r.name)}</b>${r.type ? `<small><span class="cz-pill q ins-type">${esc(r.type)}</span></small>` : ''}</div>`
473
508
  + `<div role="cell"><b>${esc(r.nowTxt || '—')}</b></div><div role="cell"><b>${esc(r.targetTxt || '—')}</b></div><div role="cell" class="note">${esc(r.why || '')}</div><div role="cell">${src}</div><div role="cell" class="ins-act">${act}</div></div>`;
@@ -477,9 +512,40 @@ function drawDrafts() {
477
512
  box.innerHTML = `<div class="ins-drh"><span class="sp" aria-hidden="true">${SV(I.spark)}</span><div><b>${esc(head)}</b>${!busy && DR.sub ? `<span class="note">${esc(DR.sub)}</span>` : ''}</div>${tools}</div>${busy ? steps : ''}${reads}${table}${!busy && DR.src ? `<p class="note">Read: ${esc(DR.src)}</p>` : ''}`;
478
513
  box.hidden = false;
479
514
  }
515
+ /* the inline edit of an open draft (batch 16 item 1): its name, its target and where it is measured, in place on the row; ✓ saves (POST
516
+ * /api/metric-drafts/edit), × puts it back, and the chat icon asks Claude in Home for anything else (the why, the group, a new metric). */
517
+ let drEdit = null;
518
+ function drEditRow(r) {
519
+ const askQ = 'Change the drafted metric ' + r.name + ': ';
520
+ const tgt = r.type === 'Done or not' ? `<b>${esc(r.targetTxt || 'Done')}</b>` : `<input class="ins-dri" data-drf="target" inputmode="decimal" value="${esc(r.target == null ? '' : String(r.target))}" aria-label="Target of ${esc(r.name)}"${r.unit || r.type === 'Percentage' ? ` placeholder="${esc(r.type === 'Percentage' ? '%' : r.unit)}"` : ''}>`;
521
+ return `<div class="ins-tr ins-row ins-dcols ins-dred" role="row" data-dred="${esc(r.id)}"><div class="nm" role="cell"><input class="ins-dri" data-drf="name" value="${esc(r.name)}" maxlength="80" aria-label="Name"></div>`
522
+ + `<div role="cell"><b>${esc(r.nowTxt || '—')}</b></div><div role="cell">${tgt}</div><div role="cell" class="note">${esc(r.why || '')}</div>`
523
+ + `<div role="cell"><input class="ins-dri" data-drf="source" value="${esc(r.source || '')}" maxlength="40" aria-label="Measured by" placeholder="Measured by"></div>`
524
+ + `<div role="cell" class="ins-act"><a class="cz-ib sm" href="${esc(homeAsk('insights', askQ))}" aria-label="Ask Claude in Home to change something else" title="Ask Claude in Home">${SV('M4 5h16v11H9l-5 4z')}</a>`
525
+ + `<button type="button" class="cz-ib sm" data-dr="cancel" data-row="${esc(r.id)}" aria-label="Cancel the edit" title="Cancel">${SV(I.x)}</button><button type="button" class="cz-ib sm solid" data-dr="save" data-row="${esc(r.id)}" aria-label="Save ${esc(r.name)}" title="Save">${SV(I.chk)}</button></div></div>`;
526
+ }
527
+ $('#draftBox').addEventListener('keydown', (e) => {
528
+ const f = e.target.closest('[data-drf]'); if (!f) return;
529
+ const ed = f.closest('[data-dred]');
530
+ if (e.key === 'Enter') { e.preventDefault(); const s = ed && ed.querySelector('[data-dr="save"]'); if (s) s.click(); }
531
+ if (e.key === 'Escape') { e.preventDefault(); drEdit = null; drawDrafts(); }
532
+ });
480
533
  $('#draftBox').addEventListener('click', async (e) => {
481
534
  const b = e.target.closest('[data-dr]'); if (!b || b.disabled || !DR) return;
482
535
  const k = b.dataset.dr, row = b.dataset.row || null, r0 = row ? (DR.rows || []).find((x) => x.id === row) : null;
536
+ if (k === 'edit') { drEdit = row; drawDrafts(); const n = $('#draftBox').querySelector(`[data-dred="${CSS.escape(row)}"] [data-drf="name"]`); if (n) { n.focus(); n.select(); } return; }
537
+ if (k === 'cancel') { drEdit = null; drawDrafts(); return; }
538
+ if (k === 'save') {
539
+ const ed = b.closest('[data-dred]'), val = (f) => { const x = ed && ed.querySelector(`[data-drf="${f}"]`); return x ? x.value : undefined; };
540
+ const body = { ws: M.board.ws, scope: 'product', id: M.board.ws, row, name: val('name'), source: val('source') };
541
+ if (val('target') !== undefined) body.target = val('target');
542
+ b.disabled = true;
543
+ const res = await pmPost('/api/metric-drafts/edit', body);
544
+ if (!res || res.ok !== true) { b.disabled = false; toast((res && res.error) || 'It could not be saved. Nothing changed.'); return; }
545
+ drEdit = null; toast(res.changed ? 'Saved. Track it to keep it as you wrote it.' : 'Nothing changed.');
546
+ await draftsLoad();
547
+ return;
548
+ }
483
549
  b.disabled = true;
484
550
  const res = await pmPost('/api/metric-drafts/' + k, Object.assign({ ws: M.board.ws, scope: 'product', id: M.board.ws }, row ? { row } : {}));
485
551
  if (!res || res.ok !== true) { b.disabled = false; toast((res && res.error) || 'It could not be done. Nothing changed.'); return; }
@@ -1570,7 +1636,7 @@ async function load() {
1570
1636
  // an old tab link (Insights had Goals, Outcomes and Library): it lands on the section or the panel, once
1571
1637
  if (first) { const t = new URLSearchParams(location.search).get('tab'); if (t === 'outcomes' || t === 'library') setTab(t); }
1572
1638
  if (first) draftsLoad();
1573
- if (!PF) RI.loadProposals(M.board.ws, M.board.id).then(() => { if (M) drawStrip(); });
1639
+ if (!PF) { await noteOpen(); RI.loadProposals(M.board.ws, M.board.id).then(() => { if (M) drawStrip(); }); }
1574
1640
  }
1575
1641
  /* a report from Intelligence (batch 15 item 4): the view on screen is its first scope; a saved dashboard is its own */
1576
1642
  RI.mount({ model: () => (PF ? null : M), scope: () => { const D = curDash(); return D && D.saved ? 'dashboard:' + D.id : 'view'; }, viewer, close: () => closeMenus(), reload: () => load(),
@@ -214,7 +214,7 @@ export function dayModel(W, notes, picked, today, now = Date.now()) {
214
214
  const status = n && n.state === 'ended' ? 'notes ready' : '';
215
215
  const who = (r.who || []).slice(0, 3).join(', ') + ((r.who || []).length > 3 ? ' and ' + ((r.who || []).length - 3) + ' more' : '');
216
216
  const ended = !n && Number.isFinite(end) && end < now;
217
- return { kind: 'event', t: Number.isFinite(at) ? at : 0, time: hasTime(r.at) ? hmOf(r.at) : 'All day', title: r.title, sub: [about || 'Not linked', status, soon].filter(Boolean).join(' · '), who, chip, k, next, ended, linked: !!about || linked, row: r, note: n ? n.id : '', mins: hasTime(r.at) && Number.isFinite(end) && end > at ? Math.round((end - at) / 60000) : 0 };
217
+ return { kind: 'event', t: Number.isFinite(at) ? at : 0, time: hasTime(r.at) ? hmOf(r.at) : 'All day', title: r.title, sub: [about || 'Not linked', status, soon].filter(Boolean).join(' · '), who, chip, k, next, ended, linked: !!about || linked, row: r, note: n ? n.id : '', mins: hasTime(r.at) && Number.isFinite(end) && end > at && end - at < 864e5 ? Math.round((end - at) / 60000) : 0 };
218
218
  });
219
219
  for (const n of N) {
220
220
  const m = n.meeting;
@@ -6,6 +6,7 @@
6
6
  * Text taken from the scanned folder is untrusted: every value goes through esc() and no quoted file text is shown. The pure half is premium-welcome-model.js. */
7
7
  import { pmGet, pmPost } from './http.js';
8
8
  import * as W from './premium-welcome-model.js';
9
+ import { adlerScene, prefs as adPrefs } from './cozy-adler.js'; // Adler says hello once (batch 16 item 2, canvas AdH6), and reads with his glasses on
9
10
 
10
11
  const $ = (s, r = document) => r.querySelector(s);
11
12
  const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -99,7 +100,7 @@ const err = () => (S.error ? `<p class="wl-err" role="alert">${esc(S.error)}</p>
99
100
  function viewAbout() {
100
101
  const a = S.about;
101
102
  const f = (k, text, hint, max) => `<label>${text}<input data-f="${k}" maxlength="${max}" value="${esc(a[k])}" placeholder="${esc(hint)}" autocomplete="off"></label>`;
102
- return `<h1 id="wlH" tabindex="-1">Welcome to PMOS</h1><p class="wl-lede">Tell PMOS who you are, so your Briefing knows what matters to you. Every field is optional, and you can change them later in the console's Settings.</p>
103
+ return `<div class="wl-ad">${adlerScene('morning', 'needs-you', { label: 'Adler says hello' })}</div>${adPrefs()['adler.amount'] === 'off' ? '' : '<p class="wl-hi">Hi, I’m Adler. I do the boring bits, so you get the calls only you can make.</p>'}<h1 id="wlH" tabindex="-1">Welcome to PMOS</h1><p class="wl-lede">Tell PMOS who you are, so your Briefing knows what matters to you. Every field is optional, and you can change them later in the console's Settings.</p>
103
104
  <div class="wl-f">${f('name', 'Your name', 'For example: Dana', 40)}${f('role', 'Your role', 'For example: Senior PM, Payments', 80)}${f('work', 'What you do', 'In one line, for example: I run checkout and the payment methods', 200)}
104
105
  <label>Your job description<textarea data-f="duties" maxlength="1000" placeholder="What you own, decide and deliver. Paste it from your job description if you have one.">${esc(a.duties)}</textarea></label></div>${err()}`
105
106
  + foot('', btn('about', 'Continue', { busy: 'about', busyText: 'Saving' }));
@@ -115,7 +116,7 @@ function viewSources() {
115
116
  const rows = [`<li class="wl-row"><span class="wl-ic">${I.folder}</span><span><b>${esc(f.name || 'This folder')}</b><span class="path">${esc(f.root)}</span></span><span class="chip">this folder</span></li>`]
116
117
  .concat(S.added.map((a) => `<li class="wl-row"><span class="wl-ic">${I.folder}</span><span><b>${esc(a.name)}</b><span class="path">${esc(a.root)}</span></span><span></span></li>`)).join('');
117
118
  if (S.busy === 'scan') {
118
- return `<h1 id="wlH" tabindex="-1">Reading ${esc(f.name || 'your folder')}</h1><p class="wl-lede">A large folder can take a minute or two. The rest of PMOS keeps working.</p>
119
+ return `<div class="wl-ad">${adlerScene('think', 'thinking', { label: false })}</div><h1 id="wlH" tabindex="-1">Reading ${esc(f.name || 'your folder')}</h1><p class="wl-lede">A large folder can take a minute or two. The rest of PMOS keeps working.</p>
119
120
  <div class="wl-scan" role="status"><div>${spin('Starting the tools you ticked, then reading the folder')}</div></div>`;
120
121
  }
121
122
  return `<h1 id="wlH" tabindex="-1">Where does your work live?</h1><p class="wl-lede">PMOS reads your folders and the tools you tick, then shows you your initiatives, your documents and what needs you first.</p>