create-pmos 0.537.0 → 0.538.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 (100) hide show
  1. package/package.json +68 -14
  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/board-columns-test.js +11 -10
  8. package/workspace/board-programs-test.js +21 -23
  9. package/workspace/board-publish-ui-test.js +19 -15
  10. package/workspace/board-shared-ui-test.js +15 -12
  11. package/workspace/briefing-premium-board-test.js +46 -31
  12. package/workspace/briefing-premium-insights-test.js +24 -31
  13. package/workspace/briefing-premium-metrics-test.js +2 -2
  14. package/workspace/calm-timeline-test.js +1 -1
  15. package/workspace/changelog.json +67 -0
  16. package/workspace/ev-everywhere-test.js +4 -5
  17. package/workspace/fixtures/board-premium-facts.js +1 -1
  18. package/workspace/fixtures/initiative-premium-facts.js +1 -1
  19. package/workspace/fixtures/insights-premium-facts.js +6 -6
  20. package/workspace/fixtures/program-ascent.js +1 -1
  21. package/workspace/guide/adler.md +2 -2
  22. package/workspace/guide/agent-capabilities.md +38 -6
  23. package/workspace/guide/board.md +13 -6
  24. package/workspace/guide/claude-proposes.md +1 -1
  25. package/workspace/guide/home.md +2 -2
  26. package/workspace/guide/index.md +3 -3
  27. package/workspace/guide/intelligence-okr-goals.md +18 -7
  28. package/workspace/guide/lifecycle.md +2 -2
  29. package/workspace/guide/programs.md +2 -2
  30. package/workspace/guide/reports-needs-you.md +5 -5
  31. package/workspace/guide/settings.md +14 -11
  32. package/workspace/guide/workflows.md +3 -3
  33. package/workspace/guide/your-impact.md +1 -1
  34. package/workspace/lib/agent-team.js +262 -0
  35. package/workspace/lib/ai-cli.js +36 -4
  36. package/workspace/lib/bg-queue.js +9 -4
  37. package/workspace/lib/board-premium.js +6 -3
  38. package/workspace/lib/goal-source.js +77 -0
  39. package/workspace/lib/grill-runs.js +6 -3
  40. package/workspace/lib/headless.js +36 -4
  41. package/workspace/lib/idle-lab-engine.js +7 -6
  42. package/workspace/lib/initiative-premium.js +6 -3
  43. package/workspace/lib/insights-premium.js +1 -1
  44. package/workspace/lib/job-graph.js +191 -0
  45. package/workspace/lib/okr-goals.js +3 -0
  46. package/workspace/lib/orchestrator-keeprate.js +108 -7
  47. package/workspace/lib/pmos-verbs.js +3 -0
  48. package/workspace/lib/proposal-runs.js +8 -5
  49. package/workspace/lib/proposals.js +32 -2
  50. package/workspace/lib/report-slots.js +14 -10
  51. package/workspace/lib/routes-boards.js +2 -2
  52. package/workspace/lib/routes-insights-premium.js +11 -4
  53. package/workspace/lib/routes-premium-dashboards.js +20 -6
  54. package/workspace/lib/routes-proposals.js +10 -5
  55. package/workspace/lib/routes-your-move.js +6 -7
  56. package/workspace/lib/status-proof.js +45 -0
  57. package/workspace/lib/status-signal.js +4 -2
  58. package/workspace/lib/task-links.js +3 -1
  59. package/workspace/lib/team-cli.js +164 -0
  60. package/workspace/lib/team-runs.js +244 -0
  61. package/workspace/lib/verify-runs.js +112 -0
  62. package/workspace/okr-goals-ui-test.js +10 -13
  63. package/workspace/package-lock.json +2 -2
  64. package/workspace/package.json +1 -1
  65. package/workspace/premium-vw-backlog-test.js +2 -2
  66. package/workspace/premium-vw-jira-test.js +1 -1
  67. package/workspace/public/pm/bd-acts.js +14 -34
  68. package/workspace/public/pm/bd-ini-panel.js +38 -27
  69. package/workspace/public/pm/bd-publish.js +1 -1
  70. package/workspace/public/pm/bd-span.js +2 -1
  71. package/workspace/public/pm/bd-views.js +7 -5
  72. package/workspace/public/pm/c3-ini-ui.js +9 -7
  73. package/workspace/public/pm/cozy-board.css +17 -6
  74. package/workspace/public/pm/cozy-insights.css +18 -0
  75. package/workspace/public/pm/cozy-nav.js +2 -2
  76. package/workspace/public/pm/cozy-search.js +29 -7
  77. package/workspace/public/pm/cozy-settings.js +39 -20
  78. package/workspace/public/pm/home-data.js +3 -1
  79. package/workspace/public/pm/home-ini-model.js +15 -1
  80. package/workspace/public/pm/home-ini.js +9 -3
  81. package/workspace/public/pm/ini-tail.js +61 -0
  82. package/workspace/public/pm/ini-view-model.js +10 -7
  83. package/workspace/public/pm/premium-board.js +66 -99
  84. package/workspace/public/pm/premium-insights.js +95 -112
  85. package/workspace/public/pm/premium-report-intel.js +3 -2
  86. package/workspace/public/pm/readonly.js +4 -3
  87. package/workspace/public/pm/stage-chip.js +2 -1
  88. package/workspace/public/pm/status-proof.js +43 -0
  89. package/workspace/public/premium-board.html +10 -28
  90. package/workspace/public/premium-intelligence.html +7 -9
  91. package/workspace/server.js +35 -1
  92. package/workspace/sort-order-test.js +10 -8
  93. package/workspace/test-files.json +4 -2
  94. package/workspace/test-lists/agent-team.json +9 -0
  95. package/workspace/test-lists/job-graph.json +11 -0
  96. package/workspace/test-lists/status-proof.json +5 -0
  97. package/workspace/workflows-setup-test.js +3 -2
  98. package/workspace/public/premium-chat.html +0 -14
  99. package/workspace/public/premium-initiative.html +0 -15
  100. package/workspace/public/premium-work.html +0 -14
@@ -21,12 +21,13 @@
21
21
  * back (pm/dash-view.js, PbH1Header): the PM's last choice per initiative wins; a Board row is a press to act, so Work opens first until then.
22
22
  * The rest sits on the thing it changes: the stage chip's picker moves the stage with the row menu's own presses (moreAct(r, k, btn), bd-acts.js);
23
23
  * Change workflow, Won't do and Archive are Home's (ini-wf.js). Discuss in chat takes the question to Home. */
24
- import * as IM from './impact.js'; // Your impact (batch 16 item 7): who made a delivered milestone happen
24
+ import * as TL from './ini-tail.js'; // the parts under Linked, Home's page draws them too (UI grill U1): drafted tickets, the PRD drift, Your impact
25
25
  import * as VW from './cozy-viewer.js';
26
26
  import * as SV from './small-vw.js'; // the one stakeholder form, Home's too (batch 18 item 2-C)
27
27
  import { esc } from './premium-shell.js';
28
- import { lr, copyText } from './cozy-xv.js';
28
+ import { copyText } from './cozy-xv.js';
29
29
  import { iniView } from './ini-view-model.js';
30
+ import { gateOf } from './premium-initiative-head.js'; // the gate chips (PRD, draft, reviewed), as Home's page reads them (UI grill U1)
30
31
  import { rowFor } from './ini-versions.js'; // planned versus actual (batch 11 item 8): Live or the draft the PM shows, with the plan line
31
32
  import { viewHtml, wireView } from './ini-view.js';
32
33
  import * as TV from './tk-view.js';
@@ -44,30 +45,37 @@ let adding = null; // the key of the initiative whose inline Add a task is open
44
45
  let addTo = ''; // the stage a task added there finishes (the Board's Next cell: "Add what finishes <stage>")
45
46
  let addDates = null; // the start and due a task added there takes (a gap's + on the timeline, batch 11 item 13)
46
47
  const TI = (r) => (r && r.trail) || null;
47
- const jiraAt = () => { const J = (O.M() && O.M().jira) || {}; return J.readAt ? 'Jira · ' + O.ago(J.readAt) : ''; };
48
+ const jiraAt = () => TL.jiraAgo(((O.M() && O.M().jira) || {}).readAt);
48
49
 
49
50
  /* ── the initiative: the one view ── */
50
51
  /** The view's model for a row: the same function Home's page calls, with what only the Board's model holds (its eight steps, its day). */
51
52
  export function viewOf(r) {
52
53
  const M = O.M() || {}, p = O.programOf ? O.programOf(r) : null, u = O.usual ? O.usual(r.track || {}) : null;
53
- return iniView(rowFor(r), { steps: M.steps || [], today: M.today, usual: u, grill: r.id ? O.grill(r.id) : null, program: p ? { id: p.id, title: p.title } : null, jiraAt: jiraAt(), jiraReadAt: ((M.jira || {}).readAt) || '' });
54
+ const pg = (r.id && PAGE.get(r.id)) || {};
55
+ return iniView(rowFor(r), { steps: M.steps || [], today: M.today, usual: u, grill: r.id ? O.grill(r.id) : null, program: p ? { id: p.id, title: p.title } : null, jiraAt: jiraAt(), jiraReadAt: ((M.jira || {}).readAt) || '',
56
+ gate: pg.gate || null, people: pg.people || [] });
54
57
  }
55
- function draftedHtml(d, g) {
56
- return d.slice(0, 8).map((x) => lr({ mk: x.waiting ? 'you' : '', title: (x.id ? `<em>${esc(x.id)}</em> ` : '') + esc(x.summary || ''), sub: 'not in Jira' })).join('')
57
- + (d.length > 8 ? lr({ title: esc(d.length - 8 + ' more drafted') }) : '')
58
- + `<p class="xv-q">They go to Jira only through your Commit${g.open === false && g.why ? '. The Commit is closed: ' + esc(g.why) : ''}.</p>`;
58
+ /* ── what Home's page reads beside the board row (UI grill U1: one initiative view): the gate chips and the core documents from the
59
+ * initiative's own read (GET /api/initiative-premium, Home's loadIni), the stakeholders from GET /api/home-desk. Read when the view opens. ── */
60
+ const PAGE = new Map(); // initiative id → { gate, docs, people } | null while reading
61
+ async function readPage(r, force) {
62
+ if (!r || !r.id || (!force && PAGE.has(r.id))) return;
63
+ if (!PAGE.has(r.id)) PAGE.set(r.id, null);
64
+ const w = where(r), q = (k, v) => (v ? '&' + k + '=' + encodeURIComponent(v) : '');
65
+ const [x, d] = await Promise.all([pmGet('/api/initiative-premium?id=' + encodeURIComponent(r.id) + q('ws', w.ws) + q('board', w.board)).catch(() => null),
66
+ pmGet('/api/home-desk' + (w.ws ? '?ws=' + encodeURIComponent(w.ws) : '')).catch(() => null)]);
67
+ const m = x && x.ok && x.model;
68
+ const was = JSON.stringify(PAGE.get(r.id) || { gate: null, docs: [], people: [] });
69
+ const now = { gate: m && !ownWf(r) ? gateOf(m.gateSteps || m.checks) : null, docs: m ? MD.docRows(m) : [], people: (d && d.ok && d.stakeholders && d.stakeholders[r.id]) || [] };
70
+ PAGE.set(r.id, now);
71
+ if (JSON.stringify(now) !== was) refresh(); // only when the read changed what shows, and never under the PM's hand (refresh skips a focused body)
59
72
  }
60
- const driftQ = (keys) => 'What changed in the PRD after ' + keys.join(', ') + ' ' + (keys.length === 1 ? 'was' : 'were') + ' pushed?';
61
- const driftHtml = (keys) => `<p>${esc(keys.join(', '))} ${keys.length === 1 ? 'was' : 'were'} pushed from an older PRD. Review ${keys.length === 1 ? 'it' : 'them'} before the next push.</p>`
62
- + `<div><button type="button" class="xv-mini" data-xb="drift" data-q="${esc(driftQ(keys))}">Discuss the change in chat</button></div>`;
63
- /** What only the Board reads under the view: tickets drafted in PMOS and pushed tickets that differ from the PRD. */
64
- function boardSections(r) {
65
- const it = TI(r), S = [];
66
- const d = ((it && it.drafted) || []).filter((x) => !x.key);
67
- if (d.length) S.push({ id: 'drafted', title: 'Drafted in PMOS', count: d.length, render: () => draftedHtml(d, (it && it.gate) || {}) });
68
- const dr = (it && it.drift) || [];
69
- if (dr.length) S.push({ id: 'drift', title: 'Jira differs from the PRD', count: dr.length, render: () => driftHtml(dr) });
70
- return S;
73
+ /** Documents, as a drill-in of the view (Home's page opens its Documents view): each core document with its state; a press opens it. */
74
+ function openDocs(r) {
75
+ const L = ((PAGE.get(r.id) || {}).docs) || [];
76
+ const rows = L.map((d) => `<button type="button" class="czs-it"${d.path ? ` data-doc="${esc(d.path)}"` : ' disabled'} aria-label="${d.path ? 'Open ' : ''}${esc(d.title)}"><span class="w">${esc(d.title)}<span>${esc([d.when, d.by, MD.docPill(d)[0]].filter(Boolean).join(' · '))}</span></span>${d.look ? '<span class="czs-amb" role="img" aria-label="Needs a look"></span>' : ''}</button>`).join('');
77
+ VW.drill();
78
+ VW.open({ kind: 'Documents', title: r.title, icon: 'doc', back: true, id: 'docs:' + vidOf(r), html: `<div class="hi-v">${rows || '<p class="hi-small">No document is on record yet.</p>'}</div>` });
71
79
  }
72
80
  /* ── ⋯: the ONE initiative menu (pm/ini-more.js, feedback batch 14 item 5), the same words and order as Home's initiative page ── */
73
81
  const LAY = new Map(); // the initiative's layout record (GET /api/initiative-layout): its own Moves on by itself, read when the panel opens
@@ -178,8 +186,11 @@ function iniBody(r) {
178
186
  const md = (v) => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][+v.slice(5, 7) - 1] + ' ' + +v.slice(8, 10) + (+v.slice(0, 4) !== new Date().getFullYear() ? ' ’' + v.slice(2, 4) : '');
179
187
  const self = !!((O.M() || {}).board || {}).self, M = O.M() || {};
180
188
  // what left the ⋯ for the thing it changes (batch 16 item 5c): the workflow chip, the dashed +, the stage chip, the dates chip, Jira's ↻
181
- return viewHtml(viewOf(r), { add: !!(r.id && O.addTask), adding: adding === r.key, addHint: adding === r.key && addDates ? md(addDates.start) + ' to ' + md(addDates.due) : '', openTask: !!O.openTask, quick: !!(O.setTask && O.setDates), hold: !!O.hold, tail: VW.czSections(boardSections(r), { key: 'board' }),
182
- wf: !!r.id && !self && !r.ended, person: !!r.id, stagePick: !!r.id, planDates: !!r.id, jira: !!M.jira }) + madeHtml(r);
189
+ // the same parts and presses as Home's page (UI grill U1): the next stage is a press, Core documents a fold, the tail under Linked
190
+ const v = viewOf(r), docs = ((r.id && PAGE.get(r.id)) || {}).docs || [];
191
+ return viewHtml(v, { add: !!(r.id && O.addTask), adding: adding === r.key, addHint: adding === r.key && addDates ? md(addDates.start) + ' to ' + md(addDates.due) : '', openTask: !!O.openTask, quick: !!(O.setTask && O.setDates), hold: !!O.hold,
192
+ next: !!(r.id && v.stage.next && O.moreAct && !self), docs: docs.length ? { n: docs.length } : null, tail: TL.tailHtml(r, { VW, today: M.today }),
193
+ wf: !!r.id && !self && !r.ended, person: !!r.id, stagePick: !!r.id, planDates: !!r.id, jira: !!M.jira });
183
194
  }
184
195
  /** Presses inside the shown item: the view's own (pm/ini-view.js), a ticket's drill-in, the PRD-change question. A [data-doc] goes to the page's handler. */
185
196
  function wire(body, key) {
@@ -219,6 +230,9 @@ function wire(body, key) {
219
230
  stagePick: (b) => { const r = O.rowOf(key); if (r) stageChip(b, r); },
220
231
  planDates: () => { const r = O.rowOf(key); if (r) location.assign(O.askHref(r, 'Propose new start and end dates for ' + r.title)); },
221
232
  jira: () => O.refreshJira(),
233
+ // the next stage on the stage card (Home's page has it too): the Board's own move forward, Undo in the toast (bd-acts.js moreAct)
234
+ next: (b) => { const r = O.rowOf(key), n = r && viewOf(r).stage.next; if (r && n && O.moreAct) O.moreAct(r, 'fwd:' + n.name, b); },
235
+ docs: () => { const r = O.rowOf(key); if (r) openDocs(r); },
222
236
  // Claude's split or merge card (batch 11 item 14): ✕ Not now, ✎ Change it first, ✓ as suggested; the merged summary's link opens the one that stays
223
237
  sm: (act, b) => { const r = O.rowOf(key); if (r && O.smPress) O.smPress(r, act, b); },
224
238
  openIni: (id) => { if (O.openIniId) O.openIniId(id); },
@@ -241,6 +255,7 @@ export function openIni(r, from, o = {}) {
241
255
  adding = o.addTo != null ? r.key : null; addTo = o.addTo || ''; addDates = o.addDates || null;
242
256
  // a row with no record id has no chat of its own: its question goes to the board's chat
243
257
  readLay(r); // Moves on by itself shows once the layout record is read
258
+ readPage(r, true); // the gate chips, Core documents and the stakeholders, as Home's page shows them
244
259
  { const h = dashFor(r); if (h) h.read(o.via || 'act'); } // a Board row is a press to act (PbH1Header); a link to read passes via 'read'
245
260
  // the same tile as Home's initiative page; no "Open in full": the header's expand already opens it wide (batch 14 item 5)
246
261
  VW.open({ kind: 'Initiative', title: r.title, icon: 'goal', wrap: true, id: vidOf(r),
@@ -268,7 +283,7 @@ export function openTicket(r, k, from) {
268
283
  readAt: (M.jira && M.jira.readAt) || '', back, blockerTitle, askHref: (q) => O.askHref(r, q),
269
284
  refresh: M.jira ? () => O.refreshJira() : null,
270
285
  openIni: () => openIni(O.rowOf(r.key) || r),
271
- extra: () => (((it && it.drift) || []).includes(k.key) ? [{ id: 'tdrift', title: 'The PRD changed after the push', count: 1, open: true, render: () => driftHtml([k.key]) }] : []),
286
+ extra: () => (((it && it.drift) || []).includes(k.key) ? [{ id: 'tdrift', title: 'The PRD changed after the push', count: 1, open: true, render: () => TL.driftHtml([k.key]) }] : []),
272
287
  onHide: () => { if (cur && cur.tk === k.key) { cur = null; O.onHide(); } } });
273
288
  }
274
289
 
@@ -284,11 +299,7 @@ export function refresh(force) {
284
299
  }
285
300
  export function close() { if (cur) { cur = null; VW.close(); } }
286
301
  export const shown = () => (cur ? cur.key : null);
287
- /** Your impact, Phase 3 (batch 16 item 7, GmA2Board): under a milestone delivered in the last 30 days, the people who made it happen, from
288
- * the row's own tickets, unranked, each with its ticket to open. Private: no thank-you press, no send, and the ◆ on the timeline stays plain. */
289
- const madeHtml = (r) => IM.madeHtml(IM.madeOf(r, (O.M() && O.M().today) || new Date().toISOString().slice(0, 10)));
290
302
  export function mount(o) {
291
303
  O = o; ensurePopCss();
292
- IM.readWeek().then(() => refresh()).catch(() => {});
293
- window.addEventListener('pmos:impact', () => { setTimeout(() => IM.readWeek().then(() => refresh()).catch(() => {}), 0); }); // the switch: the section follows at once
304
+ TL.readImpact(() => refresh()); // Your impact under a delivered milestone (pm/ini-tail.js); the switch makes it follow at once
294
305
  }
@@ -158,7 +158,7 @@ export function open(btn, ctx) {
158
158
  if (b.dataset.bpDays) { S.days = Number(b.dataset.bpDays); return draw(`[data-bp-days="${S.days}"]`); }
159
159
  if (b.dataset.bpAdd) { S.sel.add(keyOf('initiative', b.dataset.bpAdd)); S.iniOpen = false; return draw('[data-bp="ini"]'); }
160
160
  const act = b.dataset.bp;
161
- if (act === 'shared') { close(false); const t = document.getElementById('tabShared'); if (t && t.getAttribute('aria-pressed') !== 'true') t.click(); return; }
161
+ if (act === 'shared') { close(false); const t = document.querySelector('#bdViewMenu [data-vshared]'); if (t && t.getAttribute('aria-pressed') !== 'true') t.click(); return; } // Shared with me, in the View chip (UI grill U2)
162
162
  if (act === 'changehost') { S.host = null; S.hostIn = ''; S.err = ''; return draw('#bpHost'); }
163
163
  if (act === 'savehost') {
164
164
  const v = ((m.querySelector('#bpHost') || {}).value || '').trim(); S.hostIn = v; S.err = '';
@@ -48,6 +48,7 @@ import { mergeClose } from './program-model.js';
48
48
  import { stagesOfRow } from './bd-wf.js';
49
49
  import { shownMs, endStage } from './bd-pins.js';
50
50
  import { stageName } from './stage-chip.js'; // W1: the one stage
51
+ import { provenStatus } from './status-proof.js'; // T3: a status renders only with its source and read time
51
52
 
52
53
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
53
54
  const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
@@ -119,7 +120,7 @@ export function fcRange(r) {
119
120
  const hi = day(F.high || F.low), lo = day(F.low);
120
121
  return tone && hi && hi > e ? { tone, low: lo || hi, high: hi } : null;
121
122
  }
122
- const toneOf = (r, now) => (r.late || anyMsLate(r, now) ? 'late' : r.status === 'at risk' ? 'risk' : r.track && r.track.you ? 'you' : r.status === 'on track' ? 'ok' : 'q');
123
+ const toneOf = (r, now) => { const ps = provenStatus(r); return r.late || anyMsLate(r, now) ? 'late' : ps === 'at risk' ? 'risk' : r.track && r.track.you ? 'you' : ps === 'on track' ? 'ok' : 'q'; }; // T3: a proven status only
123
124
  /** A row's dot (batch 13 item 4): only off track. 'late' | 'risk' | 'q' (on hold) | null. */
124
125
  export const offTone = (r, now) => { const t = toneOf(r, now); return t === 'late' || t === 'risk' ? t : r.status === 'on hold' ? 'q' : null; };
125
126
  const dotHtml = (r, now) => { const t = offTone(r, now); return t ? `<i class="cz-dot ${t}${t === 'q' ? '' : ' m-warn'}" aria-hidden="true"></i>` : ''; };
@@ -13,6 +13,7 @@ import { esc } from './premium-shell.js';
13
13
  import * as WF from './bd-wf.js';
14
14
  import { nextHtml } from './bd-next.js';
15
15
  import { stageName, stageChip } from './stage-chip.js'; // W1: the one stage
16
+ import { provenStatus, NO_SIGNAL } from './status-proof.js'; // T3: a status renders only with its source and read time
16
17
 
17
18
  let A = null; // the page: { M(), statusOf(r), usual(t), trail(r), docMeta(path, ws), sel(), groups(L), folded(key), laneHead(g), subTile(name), memberIcon(id), programOf(r), programs(),
18
19
  // wf() → { list, cur, ended } the workflows on the board, the picked one (null for All) and the rows that ended (pm/bd-wf.js) }
@@ -176,7 +177,7 @@ function phoneStages(L, C) {
176
177
  const n = at(L).length;
177
178
  if (!n) { empty.push(c.label); return ''; }
178
179
  const body = lanes.map((ln) => { const rs = at(ln.rows); return rs.length ? (G ? ln.label : '') + rs.map((r) => card(r, false)).join('') : ''; }).join('');
179
- return `<section class="bd-scol" aria-label="${esc(c.label)}"${dropAt(c, cur)}><h3>${msI(c.ms)}${esc(c.label)}<span>${c.count}</span></h3>${body}</section>`;
180
+ return `<section class="bd-scol" aria-label="${esc(c.label)}"${dropAt(c, cur)}><h3>${msI(c.ms)}${esc(c.label)}${c.count ? `<span>${c.count}</span>` : ''}</h3>${body}</section>`;
180
181
  }).join('');
181
182
  const tail = empty.length ? `<p class="bd-sempty">Nothing on screen in ${esc(empty.length > 1 ? empty.slice(0, -1).join(', ') + ' or ' + empty[empty.length - 1] : empty[0])}.</p>` : '';
182
183
  return `<div class="bd-scols ph">${secs}${tail}</div>${phoneEnded(C)}`;
@@ -191,7 +192,7 @@ export function morePcat(k) { pmore.add(k); }
191
192
  const CHEV_R = 'M10 7l5 5-5 5', CHEV_D = 'M7 10l5 5 5-5';
192
193
  function phoneSec(k, label, count, rs, o = {}) {
193
194
  const open = pcatOpen(k), all = pmore.has(k) || rs.length <= 6, shown = all ? rs : rs.slice(0, 5);
194
- const head = `<button type="button" class="bd-ghd bd-pcat${o.end ? ' end' : ''}" data-pcat="${esc(k)}" aria-expanded="${open}">${SV(open ? CHEV_D : CHEV_R)}${esc(label)}<span class="n">${count}</span></button>`;
195
+ const head = `<button type="button" class="bd-ghd bd-pcat${o.end ? ' end' : ''}" data-pcat="${esc(k)}" aria-expanded="${open}">${SV(open ? CHEV_D : CHEV_R)}${esc(label)}${count ? `<span class="n">${count}</span>` : ''}</button>`;
195
196
  if (!open) return head;
196
197
  return head + shown.map((r) => phoneRow(r)).join('') + (all ? '' : `<button type="button" class="dlink bd-pmore" data-pmore="${esc(k)}">${rs.length - 5} more</button>`);
197
198
  }
@@ -247,8 +248,8 @@ export function stagesHtml(L, o = {}) {
247
248
  }
248
249
  const span = Math.max(2, bodyEnd);
249
250
  const heads = C.map((c, j) => (shut[j]
250
- ? `<button type="button" class="bd-kstrip${c.end ? ' end' : ''}" data-colfold="${esc(c.key)}" style="grid-column:${j + 1};grid-row:1 / span ${span - 1}" aria-expanded="false" aria-label="Show ${esc(c.label)}, ${c.count}"><b>${c.count}</b><span>${msI(c.ms)}${esc(c.label)}</span></button>`
251
- : `<button type="button" class="bd-kh" data-colfold="${esc(c.key)}" style="grid-column:${j + 1}" aria-expanded="true" aria-label="${esc(c.label)}, ${c.count}. Fold the column"><span class="l">${msI(c.ms)}${esc(c.label)}</span><span class="n">${c.count}</span>${SV('M7 10l5 5 5-5')}</button>`)).join('');
251
+ ? `<button type="button" class="bd-kstrip${c.end ? ' end' : ''}" data-colfold="${esc(c.key)}" style="grid-column:${j + 1};grid-row:1 / span ${span - 1}" aria-expanded="false" aria-label="Show ${esc(c.label)}${c.count ? ', ' + c.count : ''}">${c.count ? `<b>${c.count}</b>` : ''}<span>${msI(c.ms)}${esc(c.label)}</span></button>`
252
+ : `<button type="button" class="bd-kh" data-colfold="${esc(c.key)}" style="grid-column:${j + 1}" aria-expanded="true" aria-label="${esc(c.label)}${c.count ? ', ' + c.count : ''}. Fold the column"><span class="l">${msI(c.ms)}${esc(c.label)}</span>${c.count ? `<span class="n">${c.count}</span>` : ''}${SV('M7 10l5 5 5-5')}</button>`)).join('');
252
253
  const cols = C.map((c, j) => (shut[j] ? '40px' : c.wide ? 'minmax(0,3.2fr)' : 'minmax(0,1fr)')).join(' ');
253
254
  const foot = `<div class="bd-foot bd-sfoot"><span>Any column folds to a strip and stays folded. Empty ones start folded.</span>${drag ? '<span>Drag a card to move its stage</span>' : ''}</div>`;
254
255
  return `<div class="bd-kb${G ? ' lanes' : ''}${mixed ? ' cats' : ''}" style="grid-template-columns:${cols}">${heads}${body}</div>${foot}`;
@@ -264,7 +265,8 @@ function phoneRow(r) {
264
265
  export function phoneListHtml(L) {
265
266
  const you = L.filter((r) => r.track && r.track.you), bad = L.filter((r) => !you.includes(r) && needOf(r) <= 3), left = L.filter((r) => !you.includes(r) && !bad.includes(r));
266
267
  // workspace grill W2: a row with nothing read is not on track; it is listed under No signal
267
- const none = left.filter((r) => r.status === 'no signal'), rest = left.filter((r) => !none.includes(r));
268
+ const none = left.filter((r) => provenStatus(r) === NO_SIGNAL), // T3: nothing proven is No signal, never On track
269
+ rest = left.filter((r) => !none.includes(r));
268
270
  const grp = (name, rs) => (rs.length ? `<div class="bd-ghd">${esc(name)}<span class="n">${rs.length}</span></div>${rs.map(phoneRow).join('')}` : '');
269
271
  if (!L.length) return '<p class="bt-empty">No initiative matches the chips or the filter.</p>';
270
272
  return `<div class="bd-plist">${grp('Your turn', you)}${grp('At risk or late', bad)}${grp('On track', rest)}${grp('No signal', none)}</div>`;
@@ -1,5 +1,5 @@
1
1
  /* pm/c3-ini-ui.js — the console3 builders the Initiatives page draws with (mockup v5, src/pages/34-initiatives.js: nr, crumbs, lh,
2
- * segTabs, cols, UI.sect, UI.kv, UI.empty, statusChip, healthSt, ownerChip, stageChip, stepsMini, progChip, hbr). Every tab module of
2
+ * segTabs, cols, UI.sect, UI.kv, UI.empty, statusChip, ownerChip, stageChip, stepsMini, progChip, hbr). Every tab module of
3
3
  * the page (c3-initiatives.js and the c3-ib-*.js / c3-ii-tabs.js files) imports them from here, so the markup is the mockup's
4
4
  * everywhere: `.calwrap > .calbar`, `.lh`, `.seg`, `.brief.sbb > .bcols > .bcol`, `.card.sect > .sh2`, `ul.list > li.nrow`, `.chips2`,
5
5
  * `.chip2`, `.st`, `.tag`, `.pill`, `.chgl`, `.hbs > .hbr`, `.fold`.
@@ -17,13 +17,14 @@
17
17
  * after + xp, acts); an `xp` (a node or an array) makes the row expand in place (c3-expand.js)
18
18
  * list(rows) · empty(text) · emptyLi(text) · crumbs(parts, right) · lh(ic, title, sub, right) · segTabs(items, cur, onPick, label)
19
19
  * cols(left, right) · hbs(rows) · hbr(label, value, frac, tone) · kv(pairs) · chgl(items) · chgli(ic, text, tag, tone)
20
- * chip(...kids) · tag(...kids) · st(tone, ic, text) · note(...kids) · lbl(text) · sw(cat) · stageChip(name, cat) · statusChip(s)
21
- * healthSt(h) · ownerChip(o) · stepsMini(workflow, stage, label) · progChip(p, tone) · miniBar(p, tone) · dateChip(a, b, late)
20
+ * chip(...kids) · tag(...kids) · st(tone, ic, text) · note(...kids) · lbl(text) · sw(cat) · stageChip(name, cat) · statusChip(row)
21
+ * ownerChip(o) · stepsMini(workflow, stage, label) · progChip(p, tone) · miniBar(p, tone) · dateChip(a, b, late)
22
22
  * openMenu(anchor, { label, items: [{ label, kids, onPick, disabled, current, attrs } | { group }] }) a popover menu, closed by
23
23
  * Escape, a press outside or a pick; arrow keys move between its items
24
24
  * day(iso) '12 Oct' · dayLong(iso) 'Mon 12 Oct 2026' · ago(iso, today) · daysBetween(a, b) · plural(n, one, many) · trunc(s, n)
25
25
  */
26
26
  import { el, frag } from './dom.js';
27
+ import { provenStatus, fromLine } from './status-proof.js'; // T3: a status renders only with its source and read time
27
28
  import { button, ensureComponentsCss } from './primitives.js';
28
29
  import { c3ic } from './c3-base.js';
29
30
  import { makeXp, attachExpand } from './c3-expand.js';
@@ -133,10 +134,11 @@ export function ago(iso, today) {
133
134
  export { MON };
134
135
 
135
136
  /* ── chips ── */
136
- export const statusChip = (s) => (s === 'at risk' ? st('warn', 'alert', 'At risk') : s === 'late' ? st('bad', 'clock', 'Late') : s === 'done' ? st('ok', 'check', 'Done')
137
- : s === 'on hold' ? st('', 'moon', 'On hold') : s === 'cancelled' ? el('span', { class: 'tag' }, icon('x', 'sm'), 'Cancelled') : chip('On track'));
138
- export const HEALTH = { ok: 'On track', warn: 'Needs attention', bad: 'Off track' };
139
- export const healthSt = (h) => (h === 'ok' ? st('ok', 'check', 'On track') : h === 'warn' ? st('warn', 'alert', 'Needs attention') : h === 'bad' ? st('bad', 'alert', 'Off track') : chip('No health yet'));
137
+ /** T3 (status-proof.js): a status chip renders only with the source and read time behind it; anything it cannot prove is No signal, grey.
138
+ * (Before, an unknown status fell through to On track, and a health "ok", which only means no rule complained, read On track too.) */
139
+ export const statusChip = (r) => { const s = provenStatus(r || {}); const c = s === 'at risk' ? st('warn', 'alert', 'At risk') : s === 'late' ? st('bad', 'clock', 'Late') : s === 'done' ? st('ok', 'check', 'Done')
140
+ : s === 'on hold' ? st('', 'moon', 'On hold') : s === 'cancelled' ? el('span', { class: 'tag' }, icon('x', 'sm'), 'Cancelled') : s === 'on track' ? st('ok', 'check', 'On track') : chip('No signal');
141
+ const from = fromLine(r && r.signal); if (from && c && c.setAttribute) c.setAttribute('title', from); return c; };
140
142
  export const ownerText = (o) => (o ? o : el('span', { class: 'dim' }, 'No owner'));
141
143
  export const ownerChip = (o) => chip(icon('user', 'sm'), ownerText(o));
142
144
  export const stageChip = (name, cat) => chip(sw(cat), name || 'No stage');
@@ -58,15 +58,22 @@ body.bd-page main.bd-main { position: relative; max-width: none; margin: 16px; p
58
58
  .bd-chip.bd-shb:hover { background: var(--cz-well); }
59
59
  .bd-chip.bd-shb[aria-pressed="true"] { background: var(--cz-bluebg); color: var(--cz-blueink); }
60
60
  .bd-chip.bd-shb .n:empty { display: none; }
61
- .bd-jiraw { display: inline-flex; }
62
- .bd-jiraw:empty { display: none; }
63
- .bd-tools .bd-ict { display: none; }
61
+ .bd-tools .bd-icf { display: none; }
64
62
  .bd-tools .bd-tune-pip[hidden] { display: none; }
65
63
  .bd-tools .bd-tune-pip { right: 7px; top: 7px; }
66
- /* a phone's view button and its menu: the four views, the span on the timeline, Shared with me */
64
+ /* the View chip and its menu (UI grill U2): the four views, the span and the Columns on the timeline, Shared with me */
67
65
  .bd-vbtn { gap: 2px; padding: 0 8px 0 10px; border-color: transparent; background: transparent; }
68
66
  .bd-vbtn svg { width: 18px; height: 18px; }
69
67
  .bd-vbtn svg.bd-chv { width: 14px; height: 14px; }
68
+ .bd-viewm .bd-vcols { display: flex; flex-direction: column; gap: 4px; padding: 6px 12px; }
69
+ .bd-viewm .bd-vcols .bd-cmh { font: var(--fw-strong) var(--fs-label)/var(--lh-label) var(--cz-sans); color: var(--cz-ink3); }
70
+ .bd-lgdm .bd-lgdrow { display: flex; align-items: center; gap: 8px; padding: 6px 0; font: var(--fw-regular) var(--fs-meta)/var(--lh-meta) var(--cz-sans); color: var(--cz-ink2); white-space: nowrap; }
71
+ .bd-lgdm .bd-lgdrow > span { flex: 1; }
72
+ .bd-lgdm button.bd-lgdrow { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 0; font: var(--fw-strong) var(--fs-meta)/var(--lh-meta) var(--cz-sans); color: var(--cz-ink); }
73
+ .bd-lgdm button.bd-lgdrow:hover { color: var(--cz-blueink); }
74
+ .bd-lgdm button.bd-lgdrow:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 6px; }
75
+ .bd-lgdm .bd-lgdrow svg { width: 16px; height: 16px; flex: none; }
76
+ .bd-lgdm .bd-lgdrow .bd-ib { width: 28px; height: 28px; }
70
77
  .bd-grpw2 .bd-grpm.bd-viewm { left: 0; right: auto; min-width: 260px; max-width: calc(100vw - 24px); padding: 8px; gap: 2px; border-radius: 20px; }
71
78
  .bd-viewm .bd-vmi { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 14px; font: var(--fw-regular) var(--fs-row)/var(--lh-row) var(--cz-sans); color: var(--cz-ink); }
72
79
  .bd-viewm .bd-vmi:hover, .bd-viewm .bd-vmi:focus-visible { background: var(--cz-well); }
@@ -621,8 +628,6 @@ span.tg-end { left: var(--tl-x); cursor: default; } /* a shared board's milest
621
628
  .bd-hide-s, .bd-views, .bd-spw, .bd-lgdw, #chSprint, .bd-page #pvBell, .bd-page #moreBtn, .bd-page .tools-top { display: none !important; }
622
629
  .bd-show-s, .bd-grpw2.bd-show-s { display: inline-flex; }
623
630
  .bd-ib { width: 44px; height: 44px; }
624
- .bd-tools .bd-icf { display: none; }
625
- .bd-tools .bd-ict { display: block; }
626
631
  .bd-pickw .crumb, .bd-pickw .crumb #crBoard { height: 34px; }
627
632
  .bd-pickw .crumb #crBoard { max-width: 120px; }
628
633
  .bd-sp { display: none !important; }
@@ -1539,3 +1544,9 @@ span.tg-ng { cursor: default; }
1539
1544
  .bd-fc-go { display: flex; justify-content: flex-end; padding-bottom: 6px; }
1540
1545
  .bd-fc-sp { all: unset; box-sizing: border-box; width: 44px; height: 44px; border-radius: 22px; background: var(--cz-blue); color: var(--cz-onsolid); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
1541
1546
  .bd-fc-sp:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
1547
+
1548
+ /* Publish a read-only copy as a row of the Board ⋯ (UI grill U2): its count of open links sits after the words */
1549
+ #moreMenu #bdPublish .bpn { position: static; margin-left: 8px; display: inline-block; min-width: 16px; padding: 0 5px; border-radius: 99px; background: var(--cz-well); color: var(--cz-ink2); font: var(--fw-strong) var(--fs-badge)/16px var(--cz-sans); text-align: center; }
1550
+ #moreMenu #bdPublish .bpn[hidden] { display: none; }
1551
+ /* a row the Board takes out of the shared ⋯ (UI grill U2) stays out: the shell draws its rows as flex */
1552
+ #moreMenu [hidden] { display: none !important; }
@@ -989,3 +989,21 @@ body.ins-trv #pGoals .ins-trstrip { display: flex; } /* the narrow form hides
989
989
  .ins-nrow:first-child { border-top: 1px solid var(--cz-hair); }
990
990
  .ins-nrow .ac .note { display: none; }
991
991
  }
992
+
993
+ /* Waiting on a source (U3, UI grill item 4): the key results with no reading, one row per source, its key results, its one connect ✓ */
994
+ .ins-wait .ins-wh { display: flex; align-items: baseline; gap: 8px; padding: 0 4px; }
995
+ .ins-wait .ins-wh h2 { margin: 0; font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
996
+ .ins-wait .ins-wh .q { color: var(--cz-ink3); font-size: var(--fs-meta); }
997
+ .ins-wl { display: flex; flex-direction: column; border: 1px solid var(--cz-hair); border-radius: 18px; overflow: hidden; background: var(--cz-card); }
998
+ .ins-wrow { display: grid; grid-template-columns: minmax(160px, 240px) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; }
999
+ .ins-wrow + .ins-wrow { border-top: 1px solid var(--cz-hair); }
1000
+ .ins-wsrc { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
1001
+ .ins-wsrc small { color: var(--cz-ink3); font-size: var(--fs-meta); line-height: var(--lh-meta); }
1002
+ .ins-wkrs { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
1003
+ .ins-wkr { border: 1px solid var(--cz-hair); background: transparent; border-radius: 999px; padding: 3px 10px; font: inherit; font-size: var(--fs-meta); color: var(--cz-ink2); cursor: pointer; text-align: left; }
1004
+ .ins-wkr:hover, .ins-wkr:focus-visible { background: var(--cz-bluebg); }
1005
+ .ins-wkr .ins-krt { margin-right: 6px; }
1006
+ @media (max-width: 760px) {
1007
+ .ins-wrow { grid-template-columns: minmax(0, 1fr) auto; }
1008
+ .ins-wkrs { grid-column: 1 / -1; grid-row: 2; }
1009
+ }
@@ -123,7 +123,7 @@ export function mountNav(here, doc = document, opts = {}) {
123
123
  if (a && opts.here && !e.metaKey && !e.ctrlKey && !e.shiftKey) { e.preventDefault(); set(false); opts.here(); return; }
124
124
  const b = e.target.closest('button'); if (!b) return;
125
125
  set(false);
126
- if ('czSearch' in b.dataset) import('./cozy-search.js').then((M) => M.openSearch(opts.search ? { go: opts.search() } : {}));
126
+ if ('czSearch' in b.dataset) import('./cozy-search.js').then((M) => M.openSearch({ ...(opts.search ? { go: opts.search() } : {}), ...(opts.scope ? { scope: opts.scope() } : {}) }));
127
127
  // a stale source opens Settings at Connectors, the stale one first (FmA3Settings: open where it matters)
128
128
  else if ('czGuide' in b.dataset) import('./premium-vw-open.js').then((M) => M.openGuide('index'));
129
129
  else if ('czSettings' in b.dataset) import('./cozy-settings.js').then((M) => M.openSettings(N.stale ? 'connectors' : undefined));
@@ -135,7 +135,7 @@ export function mountNav(here, doc = document, opts = {}) {
135
135
  if (!k && !(e.key === '/' && !e.ctrlKey && !e.metaKey && !e.altKey && !typing)) return;
136
136
  if (t && t.closest && t.closest('.xterm')) return; // a terminal keeps its keys
137
137
  e.preventDefault(); e.stopImmediatePropagation();
138
- import('./cozy-search.js').then((M) => M.openSearch(opts.search ? { go: opts.search() } : {}));
138
+ import('./cozy-search.js').then((M) => M.openSearch({ ...(opts.search ? { go: opts.search() } : {}), ...(opts.scope ? { scope: opts.scope() } : {}) }));
139
139
  }, true);
140
140
  const read = async () => {
141
141
  if (doc.hidden) return;
@@ -3,7 +3,10 @@
3
3
  * One palette over the page: the query, the kind chips with their counts (All, Initiatives, Documents, Slides, Reports, Artifacts, Meetings)
4
4
  * (no worktree chip since workspace grill W4); the results grouped (Initiatives · Documents, slides and reports · Artifacts and designs ·
5
5
  * Meetings), and last "Ask Claude about …", which starts a chat in Home. ↑ ↓ move, ↵ opens, Esc closes. On a phone it is the whole screen.
6
- * openSearch({ go?, q? }) go: the page's own opener ({ ini } | { ses } | { doc }), used before a page change
6
+ * openSearch({ go?, q?, scope? }) go: the page's own opener ({ ini } | { ses } | { doc }), used before a page change
7
+ * scope: the page Search opens from (UI grill U2: one search; the Board's and Intelligence's own find boxes are gone). { name, hits(q) }
8
+ * where hits returns [{ label, rows: [{ id?, title, sub?, tag?, icon?, open() }] }]: the page's own groups, drawn first ("On this Board ·
9
+ * Initiatives", "… · Work-items in Jira"), then everything else Search reads. An initiative the page lists is not listed twice.
7
10
  * closeSearch()
8
11
  * It reads GET /api/find (the repository and every worktree: lib/search-index.js), GET /api/boards/backlog (the initiatives' stage) and
9
12
  * GET /api/sessions. A result opens in the Viewer when it can: a document of main as its page (premium-vw-doc.js), a meeting as its card,
@@ -17,7 +20,7 @@ import { adler } from './cozy-adler.js'; // session names A: the PM's name win
17
20
 
18
21
  const PHONE = 760;
19
22
  const isPhone = () => innerWidth <= PHONE;
20
- const S = { el: null, q: '', kind: 'all', at: 0, rows: [], res: null, busy: false, err: '', wt: null, back: null, go: null, seq: 0, boards: null, sessions: null, t: 0 };
23
+ const S = { el: null, q: '', kind: 'all', scope: null, at: 0, rows: [], res: null, busy: false, err: '', wt: null, back: null, go: null, seq: 0, boards: null, sessions: null, t: 0 };
21
24
  const KIND_ICON = { initiative: ICON.flag, document: ICON.doc, slides: ICON.slides, report: ICON.report, artifact: ICON.design, file: ICON.file, meeting: ICON.meet, session: ICON.session };
22
25
  async function getj(p) { try { const r = await fetch(p, { credentials: 'same-origin' }); const j = await r.json().catch(() => null); return j || { ok: false, error: 'the server did not answer' }; } catch { return { ok: false, error: 'the server did not answer' }; } }
23
26
 
@@ -53,12 +56,14 @@ function mount() {
53
56
  export function openSearch(o = {}) {
54
57
  const el = mount();
55
58
  S.go = typeof o.go === 'function' ? o.go : null;
59
+ S.scope = o.scope && typeof o.scope.hits === 'function' ? o.scope : null;
56
60
  if (!el.hidden) { el.querySelector('#evQ').focus(); return el; }
57
61
  const ae = document.activeElement; S.back = ae && ae !== document.body ? ae : null;
58
62
  S.wt = null; S.kind = 'all'; S.at = 0; // every worktree: with no chip there is no pick to keep (workspace grill W4)
59
63
  if (o.q != null) S.q = String(o.q);
60
64
  el.hidden = false; document.getElementById('evSpScrim').hidden = false; el.setAttribute('data-esc-layer', '');
61
65
  const q = el.querySelector('#evQ'); q.value = S.q; q.focus(); q.select();
66
+ q.placeholder = S.scope ? 'Search ' + S.scope.name + ', then everywhere' : 'Search initiatives, documents, slides, reports, artifacts and meetings';
62
67
  if (!S.boards) getj('/api/boards/backlog?limit=200' + wsQ('&')).then((b) => { S.boards = b && b.ok && Array.isArray(b.rows) ? b : { rows: [] }; draw(); });
63
68
  if (!S.sessions) getj('/api/sessions').then((s) => { S.sessions = s && Array.isArray(s.sessions) ? s.sessions.filter((x) => !x.automatic && x.shown !== 'exited') : []; draw(); });
64
69
  run();
@@ -101,10 +106,15 @@ const countsOf = (rows) => { const c = { all: rows.length }; for (const r of row
101
106
  function drawChips() {
102
107
  const box = S.el && S.el.querySelector('#evChips'); if (!box) return;
103
108
  const rows = allRows(), c = countsOf(rows), K = isPhone() ? PHONE_KINDS : SEARCH_KINDS;
109
+ // the page's own hits (UI grill U2) count on All and on Initiatives, where they show; an initiative listed twice counts once
110
+ { const kind = S.kind; S.kind = 'all'; const own = scopeGroups(S.q.trim()); S.kind = kind;
111
+ const ids = new Set(own.flatMap((g) => g.rows.map((r) => r.id).filter(Boolean))), n = own.reduce((a, g) => a + g.rows.length, 0), dup = rows.filter((r) => r.kind === 'initiative' && ids.has(r.id)).length;
112
+ if (n) { c.all = (c.all || 0) + n - dup; c.initiative = (c.initiative || 0) + n - dup; } }
104
113
  // no worktree chip and no "main" chip (workspace grill W4): Search reads every worktree, and the footer says "Searches your work"
105
114
  box.innerHTML = K.map(([k, l]) => `<button type="button" class="ev-chip${S.kind === k ? ' on' : ''}" data-ev-kind="${k}" aria-pressed="${S.kind === k}">${esc(l)}${!isPhone() && S.q.trim().length >= 2 ? ' ' + (c[k] || 0) : ''}</button>`).join('');
106
115
  }
107
116
  function rowHtml(r, i) {
117
+ if (r.kind === 'scoped') return `<button type="button" class="ev-mi${i === S.at ? ' hl' : ''}" role="option" id="evo${i}" data-ev-i="${i}" aria-selected="${i === S.at}">${svg(KIND_ICON[r.icon] || ICON[r.icon] || ICON.flag, 18)}<span class="ev-t"><b>${esc(r.title)}</b>${r.sub ? (isPhone() ? `<br><span class="ev-small ev-mut">${esc(r.sub)}</span>` : ` <span class="ev-mut">· ${esc(r.sub)}</span>`) : ''}</span>${r.tag ? `<span class="ev-k">${esc(r.tag)}</span>` : ''}</button>`;
108
118
  const tag = resultTag(r), sub = resultSub(r);
109
119
  const right = r.kind === 'document' && r.draft ? '<span class="ev-pill y">Draft</span>' : esc(tag);
110
120
  const title = r.kind === 'initiative' ? `<b>${esc(r.title)}</b>` : esc(r.title);
@@ -112,23 +122,34 @@ function rowHtml(r, i) {
112
122
  const two = isPhone() ? `<span class="ev-t">${title}${sub ? `<br><span class="ev-small ev-mut">${subHtml}</span>` : ''}</span>` : `<span class="ev-t">${title}${sub ? ` <span class="ev-mut">· ${subHtml}</span>` : ''}</span>`;
113
123
  return `<button type="button" class="ev-mi${i === S.at ? ' hl' : ''}" role="option" id="evo${i}" data-ev-i="${i}" aria-selected="${i === S.at}">${svg(KIND_ICON[r.kind] || ICON.doc, 18)}${two}${right ? `<span class="ev-k">${right}</span>` : ''}</button>`;
114
124
  }
125
+ /** The page's own groups first (o.scope, UI grill U2), on All and on Initiatives; a page that throws or finds nothing adds nothing. */
126
+ function scopeGroups(q) {
127
+ if (!S.scope || q.length < 2 || !['all', 'initiative'].includes(S.kind)) return [];
128
+ let G = []; try { G = S.scope.hits(q) || []; } catch { G = []; }
129
+ return G.filter((g) => g && (g.rows || []).length).map((g) => ({ key: 'scoped', label: g.label, rows: g.rows.map((x) => ({ ...x, kind: 'scoped' })) }));
130
+ }
115
131
  function drawList() {
116
132
  const box = S.el && S.el.querySelector('#evRes'); if (!box) return;
117
133
  const q = S.q.trim();
118
134
  let rows = allRows();
119
135
  if (S.kind !== 'all') rows = rows.filter((r) => (S.kind === 'artifact' ? ['artifact', 'file'].includes(r.kind) : S.kind === 'meeting' ? ['meeting', 'session'].includes(r.kind) : r.kind === S.kind));
120
- const groups = searchGroups(rows, { phone: isPhone() });
136
+ const own = scopeGroups(q), ownIds = new Set(own.flatMap((g) => g.rows.map((r) => r.id).filter(Boolean)));
137
+ if (ownIds.size) rows = rows.filter((r) => !(r.kind === 'initiative' && ownIds.has(r.id)));
138
+ const groups = own.concat(searchGroups(rows, { phone: isPhone() }));
121
139
  S.rows = groups.flatMap((g) => g.rows);
122
140
  const ask = q.length >= 2 ? { kind: 'ask', title: q } : null;
123
141
  if (ask) S.rows.push(ask);
124
142
  S.at = Math.min(S.at, Math.max(0, S.rows.length - 1));
125
143
  let h = '', i = 0;
126
- if (q.length < 2) h = '<p class="ev-sp-empty">Type two letters or more. Search reads the initiatives, the documents, slides and reports, the artifacts and designs, and the meetings.</p>';
127
- else if (S.err) h = cantRead({ what: 'Search', why: S.err, sources: false });
128
- else if (S.busy && !groups.length) h = skelRows(3);
144
+ // the page's own groups first (UI grill U2): what Search itself could not read is said after them
145
+ own.forEach((g) => { h += `<p class="ev-mlbl">${esc(g.label)}</p>` + g.rows.map((r) => rowHtml(r, i++)).join(''); });
146
+ const rest = groups.slice(own.length);
147
+ if (q.length < 2) h = `<p class="ev-sp-empty">Type two letters or more. Search reads ${S.scope ? esc(S.scope.name) + ' first, then ' : ''}the initiatives, the documents, slides and reports, the artifacts and designs, and the meetings.</p>`;
148
+ else if (S.err) h += cantRead({ what: 'Search', why: S.err, sources: false });
149
+ else if (S.busy && !rest.length) h += skelRows(3);
129
150
  // nothing found: Adler with his magnifier (canvas AdU4); the words stay the same
130
151
  else if (!groups.length) h = `<div class="ev-sp-empty ev-sp-ad" role="status">${adler('needs-you', 'l', { label: false, prop: 'magnifier' })}<p>Nothing matches “${esc(q)}”${S.kind !== 'all' ? ' in this kind' : ''}.</p></div>`;
131
- groups.forEach((g, gi) => {
152
+ rest.forEach((g, gi) => {
132
153
  h += `<p class="ev-mlbl">${esc(g.label)}</p>` + g.rows.map((r) => rowHtml(r, i++)).join('');
133
154
  if (gi === 0 && isPhone() && g.key === 'initiative') h += '<div class="ev-sp-chips ev-phchips" aria-hidden="true"></div>';
134
155
  });
@@ -152,6 +173,7 @@ function homeUrl(params) { const q = new URLSearchParams(params); if (wsParam())
152
173
  function go(r) {
153
174
  closeSearch();
154
175
  if (r.kind === 'ask') { askClaude(r.title); return; }
176
+ if (r.kind === 'scoped') { if (typeof r.open === 'function') r.open(); return; }
155
177
  if (r.kind === 'initiative') { if (S.go) { S.go({ ini: r.id }); return; } location.assign(homeUrl(r.board ? { ini: r.id, board: r.board } : { ini: r.id })); return; }
156
178
  if (r.kind === 'session') { if (S.go) { S.go({ ses: r.id }); return; } location.assign(homeUrl({ session: r.id })); return; }
157
179
  if (r.kind === 'meeting') { import('./premium-vw-open.js').then(() => window.czViews.openMeeting({ note: r.id }, { ws: wsParam() })).catch(() => openFileCard(r)); return; }