create-pmos 0.311.0 → 0.313.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.311.0",
3
+ "version": "0.313.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@ae8712a
1
+ kernel-source: pmos@36b0e23
2
2
  assembled: 2026-10-19
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-19T12:56:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T13:24:33Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-19T12:56:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T13:24:33Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-19T12:56:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T13:24:33Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -104,8 +104,7 @@ const SUGGEST = { ok: true, suggested: [{ kind: 'pmos-doc', ref: 'planning/prd/p
104
104
  await page.route('**/api/calendar-links', (r) => json(r, { ok: true }));
105
105
  await page.goto(BASE + '/premium.html?theme=' + theme);
106
106
  S.up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 && document.querySelectorAll('#tl .ev').length > 0), 20000);
107
- await page.click('#rng [data-r=week]');
108
- await until(() => page.evaluate(() => !document.querySelector('#tl').hasAttribute('aria-busy') && !!document.querySelector('#tl .wkd')));
107
+ await until(() => page.evaluate(() => document.querySelectorAll('#wkStrip [data-day]').length === 5)); // the card's day strip: today is picked, so the row is a Today row
109
108
  await page.evaluate(() => { const r = [...document.querySelectorAll('#tl .ev')].find((e) => e.querySelector('b').textContent === 'Sprint planning'); r.id = 'rowSprint'; r.click(); });
110
109
  S.dlg = await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#mmAdd') && /Roadmap|No material/.test(document.querySelector('#oMain').textContent)));
111
110
  return Object.assign(S, { ctx, page });
@@ -37,7 +37,8 @@ const NOW = new Date();
37
37
  const midnight = new Date(NOW.getFullYear(), NOW.getMonth(), NOW.getDate());
38
38
  const monday = () => { const d = new Date(midnight); d.setDate(d.getDate() - ((d.getDay() + 6) % 7)); return d; };
39
39
  /* "Live review" is under way now (it starts at most 10 minutes ago, never before midnight); "Retro" ended long ago when the day allows, so it cannot be recorded. */
40
- const START = new Date(Math.max(midnight.getTime(), NOW.getTime() - 10 * 60000)), END = new Date(START.getTime() + 60 * 60000);
40
+ /* START is in whole minutes, as the calendar answer holds them, so the Today row finds its event. */
41
+ const START = new Date(Math.max(midnight.getTime(), Math.floor((NOW.getTime() - 10 * 60000) / 60000) * 60000)), END = new Date(START.getTime() + 60 * 60000);
41
42
  const weekAnswer = () => {
42
43
  const m = monday(), cells = [];
43
44
  for (let i = 0; i < 7; i++) { const d = new Date(m.getFullYear(), m.getMonth(), m.getDate() + i); cells.push({ key: dayKey(d), start: dayKey(d), end: dayKey(d), events: [] }); }
@@ -134,8 +135,7 @@ const RECORDER = () => {
134
135
  await page.goto(BASE + url + (url.includes('?') ? '&' : '?') + 'theme=' + theme);
135
136
  if (url === '/premium.html' && openDialog) {
136
137
  S.up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0), 20000);
137
- await page.click('#rng [data-r=week]');
138
- await until(() => page.evaluate(() => !document.querySelector('#tl').hasAttribute('aria-busy') && !!document.querySelector('#tl .wkd')));
138
+ await until(() => page.evaluate(() => document.querySelectorAll('#wkStrip [data-day]').length === 5)); // the card's day strip: today is picked, so the row is a Today row
139
139
  await page.evaluate(() => { const r = [...document.querySelectorAll('#tl .ev')].find((e) => e.querySelector('b').textContent === 'Live review'); r.click(); });
140
140
  S.dlg = await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#m3Rec')));
141
141
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
- /* briefing-premium-calendar-test.js — the Today / This week switch and the meeting dialog on the premium Briefing (initiative briefing-premium-calendar, slice 1;
3
+ /* briefing-premium-calendar-test.js — the Calendar card's day strip (initiative premium-calendar-card; it replaced the Today / This week switch) and the meeting dialog on the premium Briefing (initiative briefing-premium-calendar, slice 1;
4
4
  * planning/prd/briefing-premium-calendar-prd.md C1 to C10). Serves the real page from the real server. The Briefing model, the calendar answer, the replay and the material
5
5
  * are answered by stand-ins, so each press can be read off the request the page sent; the routes' own behaviour is in their own suites.
6
6
  * C1 the switch · C2 the week · C3 honest states · C4 the dialog · C5 link it · C6 notes · C7 material · C8 replay summary · C9 only the link write · C10 floors and fidelity
@@ -35,16 +35,20 @@ const iso = (d) => { const off = -d.getTimezoneOffset(), a = Math.abs(off); retu
35
35
  const NOW = new Date();
36
36
  const at = (h, m, plus = 0) => { const d = new Date(NOW.getFullYear(), NOW.getMonth(), NOW.getDate() + plus, h, m, 0, 0); return d; };
37
37
  const monday = () => { const d = new Date(NOW.getFullYear(), NOW.getMonth(), NOW.getDate()); d.setDate(d.getDate() - ((d.getDay() + 6) % 7)); return d; };
38
+ /* a weekday of this week that is not today: Tuesday when today is Monday, else Monday */
39
+ const OTHER = () => { const m = monday(); if (NOW.getDay() === 1) m.setDate(m.getDate() + 1); return m; };
38
40
  const weekAnswer = () => {
39
41
  const m = monday(), cells = [];
40
42
  for (let i = 0; i < 7; i++) { const d = new Date(m.getFullYear(), m.getMonth(), m.getDate() + i); cells.push({ key: dayKey(d), start: dayKey(d), end: dayKey(d), events: [] }); }
41
43
  const put = (d, e) => cells.find((c) => c.key === dayKey(d)).events.push(e);
42
- put(at(9, 30), { id: 'ev-checkout', at: iso(at(9, 30)), end: iso(at(10, 15)), title: 'Checkout sync', attendees: ['Priya', 'Dara'] });
43
- put(at(14, 0), { id: 'ev-sprint', at: iso(at(14, 0)), end: iso(at(15, 0)), title: 'Sprint planning', attendees: ['Dara', 'Priya', 'Sam'], series: 'sprint-planning' });
44
- const other = at(9, 30, NOW.getDay() === 0 ? -1 : 1); // a day other than today, still in the week unless it runs off the end
45
- if (cells.some((c) => c.key === dayKey(other))) put(other, { id: 'ev-standup', at: iso(other), end: iso(new Date(other.getTime() + 30 * 60000)), title: 'Standup', attendees: [] });
44
+ /* today holds Sprint planning (the Today row); another day of the strip holds Checkout sync and Sprint planning (the rows a picked day lists) */
45
+ const o = (h, mm) => { const x = OTHER(); x.setHours(h, mm, 0, 0); return x; };
46
+ put(at(14, 0), { id: 'ev-sprint-today', at: iso(at(14, 0)), end: iso(at(15, 0)), title: 'Sprint planning', attendees: ['Dara', 'Priya', 'Sam'], series: 'sprint-planning' });
47
+ put(o(9, 30), { id: 'ev-checkout', at: iso(o(9, 30)), end: iso(o(10, 15)), title: 'Checkout sync', attendees: ['Priya', 'Dara'] });
48
+ put(o(14, 0), { id: 'ev-sprint', at: iso(o(14, 0)), end: iso(o(15, 0)), title: 'Sprint planning', attendees: ['Dara', 'Priya', 'Sam'], series: 'sprint-planning' });
49
+ const lvl = { phase: 'upcoming', level: { kind: 'board', ws: 'w1', id: 'idpf', name: 'IDPF', why: 'you linked it to the board', by: 'pm' } };
46
50
  return { ok: true, view: 'week', range: { start: cells[0].key, end: cells[6].key }, cells, events_source: 'calendar-memory', today: dayKey(NOW),
47
- context: { 'ev-sprint': { phase: 'upcoming', level: { kind: 'board', ws: 'w1', id: 'idpf', name: 'IDPF', why: 'you linked it to the board', by: 'pm' } } },
51
+ context: { 'ev-sprint': lvl, 'ev-sprint-today': lvl },
48
52
  link_boards: [{ ws: 'w1', id: 'idpf', name: 'IDPF' }, { ws: 'w1', id: 'pay', name: 'Payments' }], gantt: [{ id: 'premium-ux', title: 'Premium UX' }] };
49
53
  };
50
54
  const REPLAY = { ok: true, note: { id: 'n1', title: 'Sprint planning notes' }, meeting: { title: 'Sprint planning', attendees: ['Dara', 'Priya', 'Sam'] }, audio: { url: '/x', ms: 1500000 }, length_ms: 1500000, lines: [{}],
@@ -82,36 +86,50 @@ const MOCKUP = fs.readFileSync(path.join(__dirname, '..', 'prototype', 'premium-
82
86
  S.up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 && document.querySelectorAll('#tl .ev').length > 0), 20000);
83
87
  return Object.assign(S, { ctx, page });
84
88
  };
85
- const week = (p) => p.click('#rng [data-r=week]').then(() => until(() => p.evaluate(() => !document.querySelector('#tl').hasAttribute('aria-busy') && (!!document.querySelector('#tl .wkd') || /Calendar not read/.test(document.querySelector('#tl').textContent)))));
89
+ const strip = (p) => until(() => p.evaluate(() => document.querySelectorAll('#wkStrip [data-day]').length === 5));
90
+ const week = (p) => strip(p).then(() => p.click(`#wkStrip [data-day="${dayKey(OTHER())}"]`)).then(() => until(() => p.evaluate(() => !!document.querySelector('#tl .wkd') || /Calendar not read/.test(document.querySelector('#tl').textContent))));
86
91
 
87
92
  const A = await open();
88
93
  ok('0 the page draws the list and Today', A.up);
89
94
  if (!A.up) return finish(1);
90
95
  const p = A.page;
91
96
 
92
- /* C1 */
93
- const sw = await p.evaluate(() => ({ labels: [...document.querySelectorAll('#rng button')].map((b) => b.textContent + ':' + b.getAttribute('aria-pressed')), box: [...document.querySelectorAll('#rng button')].map((b) => { const r = b.getBoundingClientRect(); return Math.round(Math.min(r.width, r.height)); }), ahead: !!document.querySelector('#tl .grp'), group: document.querySelector('#rng').getAttribute('role') }));
94
- ok('C1 the switch is beside the title, Today is pressed by default and Today is unchanged', sw.labels.join() === 'Today:true,This week:false' && sw.ahead && sw.group === 'group', JSON.stringify(sw));
95
- ok('C1 both switch buttons are at least 44 px', sw.box.every((n) => n >= 44), JSON.stringify(sw.box));
96
- ok('C1 the week is not read until the PM presses it', A.weekGets.length === 0);
97
+ /* C1 the card: titled Calendar, a strip of five days, today picked and the Today timeline below */
98
+ await strip(p);
99
+ const sw = await p.evaluate(() => ({ title: document.querySelector('#hToday').textContent, days: [...document.querySelectorAll('#wkStrip [data-day]')].map((b) => b.dataset.day + ':' + b.getAttribute('aria-pressed')), box: [...document.querySelectorAll('#wkStrip [data-day]')].map((b) => { const r = b.getBoundingClientRect(); return Math.round(Math.min(r.width, r.height)); }), ahead: !!document.querySelector('#tl .grp'), sw: !!document.querySelector('#rng'), fold: document.querySelector('#todayCard .foldb').getAttribute('aria-expanded') }));
100
+ const isWeekday = NOW.getDay() >= 1 && NOW.getDay() <= 5;
101
+ ok('C1 the card is titled Calendar, has no Today / This week switch, and is open at 1280 px', sw.title === 'Calendar' && !sw.sw && sw.fold === 'true', JSON.stringify(sw));
102
+ ok('C1 the strip has Monday to Friday, today is pressed, and Today is unchanged', sw.days.length === 5 && sw.days.filter((x) => /:true$/.test(x)).length === (isWeekday ? 1 : 0) && (!isWeekday || sw.days.includes(dayKey(NOW) + ':true')) && sw.ahead, JSON.stringify(sw.days));
103
+ ok('C1 each day button is at least 44 px', sw.box.every((n) => n >= 44), JSON.stringify(sw.box));
104
+ ok('C1 the week is read once when the page opens, for today\'s date', A.weekGets.length === 1 && /view=week/.test(A.weekGets[0]) && A.weekGets[0].includes('date=' + dayKey(NOW)), JSON.stringify(A.weekGets));
97
105
 
98
- /* C2 */
106
+ /* C2 another day */
99
107
  await week(p);
100
108
  const wk = await p.evaluate(() => ({
101
109
  days: [...document.querySelectorAll('#tl .wkd')].map((d) => d.textContent), rows: [...document.querySelectorAll('#tl .ev')].map((e) => e.querySelector('b').textContent + '|' + e.querySelector('time').textContent + '|' + e.querySelector('.d').textContent),
102
- now: document.querySelector('#tl .wkd.now') && document.querySelector('#tl .wkd.now').textContent, empty: document.querySelectorAll('#tl .empty').length, cap: document.querySelector('#rcap').textContent, capShown: !document.querySelector('#rcap').hidden,
103
- filter: getComputedStyle(document.querySelector('#todayCard .fbtn')).display, pressed: document.querySelector('#rng [data-r=week]').getAttribute('aria-pressed'), past: document.querySelectorAll('#tl .ev.wkpast').length,
104
- label: document.querySelector('#tl').getAttribute('aria-label') }));
105
- ok('C2 pressing This week reads the week once, for today\'s date', A.weekGets.length === 1 && /view=week/.test(A.weekGets[0]) && A.weekGets[0].includes('date=' + dayKey(NOW)), JSON.stringify(A.weekGets));
106
- ok('C2 the card lists seven days with their counts and marks today', wk.days.length === 7 && /today/.test(wk.now || '') && wk.days.some((d) => /2 meetings/.test(d)), JSON.stringify(wk.days));
110
+ cap: document.querySelector('#todayCap').textContent, filter: getComputedStyle(document.querySelector('#todayCard .fbtn')).display,
111
+ pressed: [...document.querySelectorAll('#wkStrip [aria-pressed="true"]')].map((b) => b.dataset.day), label: document.querySelector('#tl').getAttribute('aria-label') }));
112
+ ok('C2 pressing a day lists that day only, with its count', wk.days.length === 1 && /2 meetings/.test(wk.days[0]) && wk.pressed.join() === dayKey(OTHER()), JSON.stringify(wk));
107
113
  ok('C2 a row shows time, title, length, people and what it is about', wk.rows.some((r) => r === 'Sprint planning|14:00|1 h · with Dara, Priya, Sam · Board: IDPF') && wk.rows.some((r) => r === 'Checkout sync|09:30|45 min · with Priya, Dara'), JSON.stringify(wk.rows));
108
- ok('C2 days with no meetings say so', wk.empty >= 3, String(wk.empty));
109
- ok('C2 the caption counts the meetings, the switch shows the week, the filter is hidden', /meetings? · /.test(wk.cap) && wk.capShown && wk.pressed === 'true' && wk.filter === 'none' && /This week/.test(wk.label), JSON.stringify(wk));
110
- await p.click('#rng [data-r=today]');
111
- const back = await p.evaluate(() => ({ ahead: !!document.querySelector('#tl .grp'), wk: !!document.querySelector('#tl .wkd'), filter: getComputedStyle(document.querySelector('#todayCard .fbtn')).display, cap: document.querySelector('#todayCap').textContent }));
112
- ok('C2 Today comes back unchanged', back.ahead && !back.wk && back.filter !== 'none' && /earlier · \d+ ahead/.test(back.cap), JSON.stringify(back));
113
- await week(p);
114
- ok('C2 pressing This week again reads again', await until(() => A.weekGets.length === 2));
114
+ ok('C2 the caption counts the day\'s meetings and the source filter is hidden', /^2 meetings/.test(wk.cap) && wk.filter === 'none', JSON.stringify(wk));
115
+ if (isWeekday) {
116
+ await p.click(`#wkStrip [data-day="${dayKey(NOW)}"]`);
117
+ const back = await p.evaluate(() => ({ ahead: !!document.querySelector('#tl .grp'), wk: !!document.querySelector('#tl .wkd'), filter: getComputedStyle(document.querySelector('#todayCard .fbtn')).display, cap: document.querySelector('#todayCap').textContent }));
118
+ ok('C2 pressing today brings Today back unchanged', back.ahead && !back.wk && back.filter !== 'none' && /earlier · \d+ ahead/.test(back.cap), JSON.stringify(back));
119
+ await week(p);
120
+ }
121
+
122
+ /* C11 hide and show */
123
+ await p.click('#todayCard .foldb');
124
+ const hid = await p.evaluate(() => ({ fold: document.querySelector('#todayCard').classList.contains('calhid'), tl: getComputedStyle(document.querySelector('#tl')).display, strip: getComputedStyle(document.querySelector('#wkStrip')).display, line: document.querySelector('#todayCard .folds').textContent, shown: !document.querySelector('#todayCard .folds').hidden, exp: document.querySelector('#todayCard .foldb').getAttribute('aria-expanded') }));
125
+ ok('C11 the chevron hides the card to its header and one line', hid.fold && hid.tl === 'none' && hid.strip === 'none' && hid.shown && hid.exp === 'false' && /meetings? this week/.test(hid.line), JSON.stringify(hid));
126
+ const H2p = await A.ctx.newPage(); await H2p.goto(BASE + '/premium.html?theme=light');
127
+ ok('C11 a reload keeps it hidden', await until(() => H2p.evaluate(() => document.querySelector('#todayCard').classList.contains('calhid'))));
128
+ await H2p.click('#todayCard .folds');
129
+ ok('C11 pressing the line shows it again, and that is kept', await until(() => H2p.evaluate(() => !document.querySelector('#todayCard').classList.contains('calhid') && localStorage.getItem('pmos.premium.calfold.brief') === '0')));
130
+ await H2p.close();
131
+ await p.click('#todayCard .foldb');
132
+ await until(() => p.evaluate(() => !document.querySelector('#todayCard').classList.contains('calhid')));
115
133
 
116
134
  /* C4 C5 C6 C7 C8: the dialog from a week row */
117
135
  await p.focus('#tl .ev[data-w]');
@@ -140,17 +158,17 @@ const MOCKUP = fs.readFileSync(path.join(__dirname, '..', 'prototype', 'premium-
140
158
  await p.click('#mtgLink');
141
159
  await until(() => A.posts.length === 1);
142
160
  ok('C5 the press posts one link to /api/calendar-links for the meeting and its series', A.posts.length === 1 && A.posts[0].kind === 'board' && A.posts[0].board === 'pay' && A.posts[0].ws === 'w1' && A.posts[0].event.title === 'Sprint planning' && A.posts[0].event.series === 'sprint-planning', JSON.stringify(A.posts));
143
- ok('C5 after the write the week is read again', await until(() => A.weekGets.length >= 3));
161
+ ok('C5 after the write the week is read again', await until(() => A.weekGets.length >= 2));
144
162
  await p.keyboard.press('Escape');
145
163
 
146
164
  /* C3 honest states */
147
165
  const E = await open({ week: { ok: false, error: 'the calendar could not read the repository: boom' } });
148
166
  await week(E.page);
149
- const er = await E.page.evaluate(() => ({ text: document.querySelector('#tl').textContent, rows: document.querySelectorAll('#tl .ev').length, cap: document.querySelector('#rcap').textContent }));
167
+ const er = await E.page.evaluate(() => ({ text: document.querySelector('#tl').textContent, rows: document.querySelectorAll('#tl .ev').length, cap: document.querySelector('#todayCap').textContent }));
150
168
  ok('C3 a failed read says "Calendar not read" with the reason and draws no meeting', /Calendar not read\./.test(er.text) && /boom/.test(er.text) && er.rows === 0 && er.cap === 'Calendar not read', JSON.stringify(er));
151
169
  const Z = await open({ week: Object.assign(weekAnswer(), { cells: weekAnswer().cells.map((c) => Object.assign({}, c, { events: [] })), context: {} }) });
152
170
  await week(Z.page);
153
- ok('C3 an empty week says so', await Z.page.evaluate(() => /No meetings this week/.test(document.querySelector('#rcap').textContent) && document.querySelectorAll('#tl .ev').length === 0));
171
+ ok('C3 an empty day says so', await Z.page.evaluate(() => /^No meetings/.test(document.querySelector('#todayCap').textContent) && /No meetings\./.test(document.querySelector('#tl').textContent) && document.querySelectorAll('#tl .ev').length === 0));
154
172
 
155
173
  /* C6 C8 with a note and a recording */
156
174
  const R = await open({ replay: REPLAY });
@@ -179,9 +197,12 @@ const MOCKUP = fs.readFileSync(path.join(__dirname, '..', 'prototype', 'premium-
179
197
  /* C10 floors and fidelity */
180
198
  for (const th of ['light', 'dark']) {
181
199
  const P = await open({ w: 390, h: 844, theme: th });
200
+ await strip(P.page);
201
+ ok(`C10 at 390 px (${th}) the card starts hidden`, await P.page.evaluate(() => document.querySelector('#todayCard').classList.contains('calhid') && !document.querySelector('#todayCard .folds').hidden));
202
+ await P.page.click('#todayCard .folds');
182
203
  await week(P.page);
183
- const f = await P.page.evaluate(() => ({ scroll: document.documentElement.scrollWidth <= innerWidth + 1, rows: [...document.querySelectorAll('#tl .ev')].map((e) => e.getBoundingClientRect().height), sw: [...document.querySelectorAll('#rng button')].map((b) => Math.min(b.getBoundingClientRect().width, b.getBoundingClientRect().height)) }));
184
- ok(`C10 at 390 px (${th}) there is no sideways scroll and rows and switch buttons are at least 44 px`, f.scroll && f.rows.every((h) => h >= 44) && f.sw.every((n) => n >= 44), JSON.stringify(f));
204
+ const f = await P.page.evaluate(() => ({ scroll: document.documentElement.scrollWidth <= innerWidth + 1, rows: [...document.querySelectorAll('#tl .ev')].map((e) => e.getBoundingClientRect().height), sw: [...document.querySelectorAll('#wkStrip [data-day], #todayCard .foldb')].map((b) => Math.min(b.getBoundingClientRect().width, b.getBoundingClientRect().height)) }));
205
+ ok(`C10 at 390 px (${th}) there is no sideways scroll and rows, day buttons and the chevron are at least 44 px`, f.scroll && f.rows.every((h) => h >= 44) && f.sw.every((n) => n >= 44), JSON.stringify(f));
185
206
  await P.ctx.close();
186
207
  }
187
208
  const css = (page, sel) => page.evaluate((s) => { const e = document.querySelector(s); if (!e) return null; const c = getComputedStyle(e); return ['fontSize', 'fontWeight', 'letterSpacing', 'textTransform', 'borderRadius', 'paddingTop', 'color'].map((k) => c[k]).join('|'); }, sel);
@@ -70,6 +70,10 @@ const product = (name, cond) => {
70
70
  ok('P1 the two rows share an id and differ in workspace', m0 && new Set(m0.model.list.rows.map((r) => r.key)).size === 2 && m0.model.list.rows.every((r) => /^decision:KC9:/.test(r.key)));
71
71
 
72
72
  browser = await chromium.launch({ executablePath: exe });
73
+ { /* this suite checks the records-only rows: the console's Needs you read (premium-brief.js), which replaces them when it answers, is off */
74
+ const nc = browser.newContext.bind(browser);
75
+ browser.newContext = async (...args) => { const c = await nc(...args); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
76
+ }
73
77
  const open = async ({ w = 1280, h = 900, theme = 'light', q = '' } = {}) => {
74
78
  const ctx = await browser.newContext({ viewport: { width: w, height: h } });
75
79
  await ctx.addInitScript((t) => { try { localStorage.setItem('pmos.premium.theme', t); } catch { /* none */ } }, theme);
@@ -77,6 +77,10 @@ const sh = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
77
77
  ok('S8 the header no longer says there is no brief', !/no morning brief/.test(m1.header.text), m1.header.text);
78
78
 
79
79
  browser = await chromium.launch({ executablePath: exe });
80
+ { /* this suite checks the records-only rows: the console's Needs you read (premium-brief.js), which replaces them when it answers, is off */
81
+ const nc = browser.newContext.bind(browser);
82
+ browser.newContext = async (...args) => { const c = await nc(...args); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
83
+ }
80
84
  const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
81
85
  const ctx = await browser.newContext({ viewport: { width: w, height: h } });
82
86
  const page = await ctx.newPage(); const errors = [];
@@ -133,6 +137,7 @@ const sh = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
133
137
  await until(() => m.evaluate(() => document.querySelectorAll('#rank .rr').length > 1 && document.querySelectorAll('#tl .ev').length > 0));
134
138
  await m.evaluate((t) => { document.documentElement.dataset.theme = t; }, th);
135
139
  const R = await open({ w, h, theme: th });
140
+ if (w === 390) { await R.page.click('#todayCard .folds').catch(() => {}); await R.page.evaluate(() => scrollTo(0, 0)); } // the Calendar card starts hidden on a phone (premium-calendar-card); measure it open
136
141
  await R.page.evaluate(() => { window.__ev = (s) => { const d = document.querySelector('#tl .ev.src-digest'); return !d ? null : / time$/.test(s) ? d.querySelector('time') : / b$/.test(s) ? d.querySelector('b') : d; }; });
137
142
  await sleep(500);
138
143
  const a = await grab(m, PAIRS), c = await grab(R.page, PAIRS), diffs = [];
@@ -51,14 +51,22 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
51
51
  srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
52
52
  await T.waitForServer(BASE);
53
53
  browser = await chromium.launch({ executablePath: exe });
54
+ { /* every context starts with the console's Needs you read off (see open below); a page route set by `console` wins over it */
55
+ const nc = browser.newContext.bind(browser);
56
+ browser.newContext = async (...args) => { const c = await nc(...args); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
57
+ }
54
58
 
55
- const open = async ({ w = 1280, h = 900, theme = 'light', model = MODEL, ctxOpts = {}, pre = null } = {}) => {
59
+ /* The console's Needs you reads (premium-brief.js): off by default, so the page keeps the model's records-only hero and rows, which most of
60
+ * this suite checks. `console` stubs them: { briefing, page, agent }; the C block checks that path. */
61
+ const open = async ({ w = 1280, h = 900, theme = 'light', model = MODEL, ctxOpts = {}, pre = null, console: cn = null } = {}) => {
56
62
  const ctx = await browser.newContext({ viewport: { width: w, height: h }, ...ctxOpts });
57
63
  const page = await ctx.newPage();
58
64
  const errors = [], reqs = [];
59
65
  page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
60
66
  page.on('request', (r) => { if (r.url().startsWith(BASE)) reqs.push(r.method() + ' ' + new URL(r.url()).pathname); });
61
67
  await page.route('**/api/briefing-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model, as_of: Date.now() }) }));
68
+ const json = (body) => (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(body) });
69
+ if (cn) { await page.route('**/api/brief-page*', json(cn.page)); await page.route('**/api/briefing', json(cn.briefing)); await page.route('**/api/needs?*', json({ needs: cn.agent || [] })); }
62
70
  if (pre) await page.addInitScript(pre);
63
71
  await page.goto(BASE + '/premium.html?theme=' + theme);
64
72
  const up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 || !document.querySelector('#calm').hidden), 20000);
@@ -168,12 +176,11 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
168
176
  await p.keyboard.press('Escape'); await p.unroute('**/api/sessions'); await p.unroute('**/api/session/remove');
169
177
  for (let i = A.reqs.length - 1; i >= 0; i--) if (/^POST \/api\/(session\/remove|runs\/answer)$/.test(A.reqs[i])) A.reqs.splice(i, 1); }
170
178
 
171
- /* R2: the hero is the console's The brief (premium-brief.js) once its reads come back; the same composer gives the same words */
172
- await until(() => p.evaluate(() => /^The same paragraph as The brief/.test(document.querySelector('#brief').title || '')));
179
+ /* R2: with the console reads off, the hero is the model's records-only sentences */
173
180
  const hero = await p.evaluate(() => ({ text: document.querySelector('#brief').textContent, k: [...document.querySelectorAll('#brief .k')].map((x) => x.textContent) }));
174
- const want = await p.evaluate(() => import('/pm/premium-brief.js').then((m) => m.consoleBrief()).then((r) => (r ? r.parts.map((x) => x.t).join('') : null)));
175
- ok('R2 the hero reads the console brief, word for word', !!want && hero.text === want, hero.text + ' | ' + want);
176
- ok('R2 the hero is not the records-only sentences', hero.text !== MODEL.hero.map((s) => s.parts.map((x) => x.t).join('')).join(' '), hero.text);
181
+ const want = MODEL.hero.map((s) => s.parts.map((x) => x.t).join('')).join(' ');
182
+ ok('R2 the hero reads the model, word for word, while the console reads fail', hero.text === want, hero.text);
183
+ ok('R2 the numbers and the stuck items are marked', hero.k.some((t) => /three changes today/.test(t)) && hero.k.some((t) => /20 to 10 per 100 runs/.test(t)) && hero.k.length >= 5, JSON.stringify(hero.k));
177
184
  ok('R2 the date line is the model\'s', await p.evaluate((d) => document.querySelector('#date').textContent === d, MODEL.date));
178
185
 
179
186
  /* R3, R4 */
@@ -472,6 +479,37 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
472
479
  await E.ctx.close();
473
480
  }
474
481
 
482
+ /* C: the console's Needs you, read the way the console reads it, is the hero and the list (premium-brief.js) */
483
+ {
484
+ const CN = {
485
+ briefing: { cards: [], needs: [{ key: 'mw:J-7', itemId: 'J-7', origin: 'jira', kind: 'Decide', headline: 'Pick the launch market', time: null, dueText: null, src: 'J-7', why: 'Assigned to you as a decision.', facts: [{ text: 'J-7 · In progress', source: 'Jira' }], url: 'https://example.atlassian.net/browse/J-7', url_label: 'Open J-7 in Jira' }] },
486
+ page: { ok: true, today: [], mentions: null, needs: [{ key: 'item:w1', id: 'w1', kind: 'overdue', headline: 'Send Priya the date', days_late: 3, person: 'Priya' }] },
487
+ agent: [{ run_id: 'run-9', kind: 'driver-drafts', question: 'Agent has 2 drafts on Checkout', initiative_id: 'checkout', ws: 'w0' }],
488
+ };
489
+ const C = await open({ console: CN });
490
+ const cp = C.page;
491
+ await until(() => cp.evaluate(() => document.querySelectorAll('#rank .rr').length === 3 && /^The same paragraph as The brief/.test(document.querySelector('#brief').title || '')));
492
+ const want = await cp.evaluate(() => import('/pm/premium-brief.js').then((m) => m.consoleReads().then((r) => ({ brief: m.briefOf(r).parts.map((x) => x.t).join(''), titles: m.needsListOf(r).map((x) => x.title) }))));
493
+ const got = await cp.evaluate(() => ({ brief: document.querySelector('#brief').textContent, titles: [...document.querySelectorAll('#rank .rr .rt')].map((t) => t.childNodes[0].textContent), skip: document.querySelectorAll('#rank .rr .skip').length, cap: document.querySelector('#movesCap').textContent, dn: document.querySelector('#dN').textContent, bell: document.querySelector('#pvBdg').textContent, links: document.querySelectorAll('#rank .rr[data-link]').length }));
494
+ ok('C1 the hero is the console brief, word for word', got.brief === want.brief && /3 things need you/.test(got.brief), got.brief);
495
+ ok('C2 the list is the console\'s Needs you, in its order', got.titles.join('|') === want.titles.join('|') && got.titles.length === 3, JSON.stringify(got.titles));
496
+ ok('C3 a console row has no "If you skip" line and no meeting link: no record holds them', got.skip === 0 && got.links === 0, JSON.stringify(got));
497
+ ok('C4 the header, the dock and the bell count the same three rows', /3 rows left/.test(got.cap) && got.dn === '3' && got.bell === '3', JSON.stringify(got));
498
+ const dec = await cp.evaluate(() => [...document.querySelectorAll('#rank .rr')].findIndex((r) => /Pick the launch market/.test(r.textContent)));
499
+ await cp.locator('#rank .rr .rhd').nth(dec).click();
500
+ await until(() => cp.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
501
+ const dd = await cp.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, body: document.querySelector('#dBody').textContent, ask: document.querySelector('#askF').hidden, link: (document.querySelector('#srcLink') || {}).href || '' }));
502
+ ok('C5 a decision opens the dialog with what its record says and its source link, and no agent box', dd.title === 'Pick the launch market' && /Read from the console Briefing/.test(dd.body) && dd.ask && /J-7/.test(dd.link), JSON.stringify(dd));
503
+ await cp.keyboard.press('Escape');
504
+ await cp.route('**/premium-work.html*', (r) => r.fulfill({ contentType: 'text/html', body: '<p>work</p>' }));
505
+ const own = await cp.evaluate(() => [...document.querySelectorAll('#rank .rr')].findIndex((r) => /Send Priya the date/.test(r.textContent)));
506
+ await cp.locator('#rank .rr .rhd').nth(own).click();
507
+ await until(() => cp.evaluate(() => /premium-work\.html/.test(location.pathname)));
508
+ ok('C6 your own item opens on My work, on that item', await cp.evaluate(() => location.pathname === '/premium-work.html' && new URLSearchParams(location.search).get('item') === 'w1'), await cp.evaluate(() => location.href));
509
+ ok('C7 no page error on the console path', C.errors.length === 0, C.errors.join(' | '));
510
+ await C.ctx.close();
511
+ }
512
+
475
513
  /* R8, R11 the dock folds in on scroll, and is not reachable before it shows */
476
514
  await p.evaluate(() => window.scrollTo(0, 0));
477
515
  await until(() => p.evaluate(() => !document.body.classList.contains('docked')));
@@ -526,6 +564,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
526
564
  await until(() => m.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 && document.querySelectorAll('#tl .ev').length > 0));
527
565
  await m.evaluate((t) => { document.documentElement.dataset.theme = t; }, th);
528
566
  const R = await open({ w, h, theme: th });
567
+ if (w === 390) { await R.page.click('#todayCard .folds').catch(() => {}); await R.page.evaluate(() => scrollTo(0, 0)); } // the Calendar card starts hidden on a phone (premium-calendar-card); measure it open
529
568
  await sleep(500);
530
569
  const a = await grab(m, PAIRS), c = await grab(R.page, PAIRS), diffs = [];
531
570
  for (const [n] of PAIRS) {
@@ -68,6 +68,15 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
68
68
  ok('M1 the rail names four places, My work is current and the indicator sits on it', rail.names.join() === 'Briefing,My work,Board,Insights' && rail.cur === 'My work' && rail.go.join() === 'brief,work,init,rep' && rail.pi === '1', JSON.stringify(rail));
69
69
  { const tc = await p.evaluate(() => { const a = document.querySelector('#toConsole'); if (!a) return null; const r = a.getBoundingClientRect(); return { href: a.getAttribute('href'), label: a.getAttribute('aria-label'), w: Math.round(r.width), h: Math.round(r.height), tab: a.tabIndex }; }); ok('M1 the header links to the console (premium-console-link)', tc && tc.href === '/console.html' && tc.label === 'Open the console' && tc.w >= 44 && tc.h >= 44 && tc.tab === 0, JSON.stringify(tc)); }
70
70
  const res = await fetch(BASE + '/premium-work').then((r) => r.status);
71
+ { /* the Calendar card shared with the Briefing (initiative premium-calendar-card) */
72
+ const cal = await until(() => p.evaluate(() => { const b = [...document.querySelectorAll('#weekBody [data-day]')]; return b.length === 5 && !/Reading/.test(document.querySelector('#wkList').textContent) ? { title: document.querySelector('#hWeek').textContent, pressed: b.filter((x) => x.getAttribute('aria-pressed') === 'true').length, list: !!document.querySelector('#wkList .wkd'), fold: document.querySelector('#weekCard .foldb').getAttribute('aria-expanded') } : null; }));
73
+ ok('M13 My work shows the same Calendar card: five day buttons, a day list and a chevron, open at 1280 px', cal && cal.title === 'Calendar' && cal.pressed <= 1 && cal.list && cal.fold === 'true', JSON.stringify(cal));
74
+ const other = await p.evaluate(() => { const b = document.querySelector('#weekBody [data-day][aria-pressed="false"]'); b.click(); return b.dataset.day; });
75
+ ok('M13 pressing a day lists that day', await until(() => p.evaluate((d) => document.querySelector('#weekBody [data-day="' + d + '"]').getAttribute('aria-pressed') === 'true' && !!document.querySelector('#wkList .wkd'), other)));
76
+ await p.click('#weekCard .foldb');
77
+ ok('M13 the chevron hides the card to one line', await p.evaluate(() => document.querySelector('#weekCard').classList.contains('calhid') && getComputedStyle(document.querySelector('#wkList')).display === 'none' && !document.querySelector('#weekCard .folds').hidden));
78
+ await p.click('#weekCard .folds');
79
+ }
71
80
  ok('M1 the page is served at /premium-work and /premium-work.html', res === 200 && (await fetch(BASE + '/premium-work.html')).status === 200);
72
81
  {
73
82
  const r2 = await open(); await r2.page.locator('.rail [data-go="brief"]').click();
@@ -88,6 +88,8 @@ A part with no record is left out. With nothing to say, the hero says so.
88
88
 
89
89
  ## What you need to do
90
90
 
91
+ The list is the console's **Needs you**: the same rows, in the same order, from the same reads. A decision opens here, with what its record says and a link to its source. Choose its option on the console Briefing. Your own item opens on My work, on that item. An agent row opens its initiative. These rows have no "If you skip" line and no link to a meeting, because no record holds them. The header, the dock and the bell count the same rows. If the console reads fail, the page shows the records-only rows below instead.
92
+
91
93
  Each row is a thing that waits for you. The order is fixed: blocked work first, then decisions only you can make, then what has waited longest. The first row is tagged "Do this first".
92
94
 
93
95
  A row has a verb-first title, the subject, what the repository says is next, and "If you skip", which says what stays blocked. Press a row to open it. Detail opens first, and the conversation sits beside it. On a phone, the Detail tab is first.
@@ -96,17 +98,21 @@ The header counts "N of M done". A row counts as done when the record behind it
96
98
 
97
99
  The pin on a row keeps it at the top for this session.
98
100
 
99
- ## Today
101
+ ## Calendar
102
+
103
+ The Calendar card holds the week and the day. Its top row is a strip of Monday to Friday: each day shows its meeting time from the calendar PMOS holds, and blocks for items done and due that day from your list. Today is picked when the page opens. Press another day to list its meetings; press today to come back. The same card is on My work.
104
+
105
+ The chevron in the card header hides the card down to one line: the next meeting today (or "Nothing more today"), the week's meeting count and the items due. Press the line or the chevron to show the card again. The page remembers this in this browser. With nothing remembered, the card starts open on a computer and hidden on a phone.
100
106
 
101
- Today lists the day in time order: what is ahead, a marker for the time the data was read, and what came earlier. It has three sources: the calendar PMOS holds, merges to `main`, and agent runs. The filter button turns a source on or off. Press an item to read it.
107
+ With today picked, the card lists the day in time order: what is ahead, a marker for the time the data was read, and what came earlier. It has three sources: the calendar PMOS holds, merges to `main`, and agent runs. The filter button turns a source on or off. Press an item to read it.
102
108
 
103
- Above the list, on the **Today** view, a ring shows how many of the meetings still ahead are prepped. A meeting is prepped when no open item is linked to it as "Before you go". The line names the meeting that is on now or next. The ring reads the same day as the console's. With no meeting left, or on **This week**, it is not shown.
109
+ Above the list, with today picked, a ring shows how many of the meetings still ahead are prepped. A meeting is prepped when no open item is linked to it as "Before you go". The line names the meeting that is on now or next. The ring reads the same day as the console's. With no meeting left, or with another day picked, it is not shown.
104
110
 
105
- ### This week
111
+ ### Another day
106
112
 
107
- The Today card has a **Today / This week** switch. **This week** lists the meetings of the current week from the calendar PMOS holds, grouped by day. It reads the week once when you press it; while it reads, the list says so. If the calendar cannot be read, the card says "Calendar not read" and gives the reason, and does not guess. A meeting in the past is shown dimmer. The switch changes only what the card shows and records nothing.
113
+ With another day picked, the card lists that day's meetings from the calendar PMOS holds, and the items due that day. It reads the week once when the page opens. If the calendar cannot be read, the card says "Calendar not read" and gives the reason, and does not guess. A meeting in the past is shown dimmer. Picking a day changes only what the card shows and records nothing.
108
114
 
109
- Press a meeting, from Today or from the week, to open the meeting dialog. It shows the time, the people, and what the meeting is about. It also shows the notes (decisions, next steps and open questions), the material, and, when a recording was kept, its length and the key points. Each part appears only when a record holds it.
115
+ Press a meeting, from today or from another day, to open the meeting dialog. It shows the time, the people, and what the meeting is about. It also shows the notes (decisions, next steps and open questions), the material, and, when a recording was kept, its length and the key points. Each part appears only when a record holds it.
110
116
 
111
117
  When the meeting is not linked, the dialog has a **Link it** press. You choose the portfolio, a board, an initiative or none. The press writes one calendar link, through a check that only a real press from this page can pass, so an agent session is refused. After the write, the page reads the week again. The **Material** part has **Add material** and a **Remove** on each row. Add material opens a sheet in the dialog with three ways to pick: **Suggested** (the documents of the meeting's initiative and the newest report cycles), **Find in PMOS** (type two letters or more) and **Paste a link** (an https address). A **For** choice says whether the material belongs to this meeting or to every meeting in the series. Before you press Add, the sheet says what it records: one line in PMOS's own record of the meeting. The calendar invite is never changed. After a write, the list is read again from the record. Remove names its scope and says the document itself is not changed. A few seconds of **Undo** put a removed item back.
112
118
 
@@ -194,7 +200,7 @@ The Start button on a blocked row stays off. Starting an agent that writes needs
194
200
 
195
201
  My work is the second place on the rail, at `/premium-work.html`. It reads the list the Work page reads, so the two pages show one list, and every press uses the Work page's own route. It adds no writer of its own.
196
202
 
197
- **This week.** A card at the top of the right column shows Monday to Friday. Each day has a grey bar for its meeting time, from your calendar, with black blocks for items done that day and orange hatched blocks for items due, from your list (at most three of each; they count items, not hours). A legend names the three. If PMOS cannot read the calendar, the card says so and draws no meeting bar. The mockup's hours done, hours free, warning line and Move to Friday need an estimate per item and working hours, which PMOS does not hold, so they are not drawn. It makes no "will not fit" note, because no item has a size and PMOS holds no working hours.
203
+ **Calendar.** The same Calendar card as on the Briefing sits at the top of the right column. Its strip shows Monday to Friday. Each day has a grey bar for its meeting time, from your calendar, with black blocks for items done that day and orange hatched blocks for items due, from your list (at most three of each; they count items, not hours). A legend names the three. If PMOS cannot read the calendar, the card says so and draws no meeting bar. The mockup's hours done, hours free, warning line and Move to Friday need an estimate per item and working hours, which PMOS does not hold, so they are not drawn. It makes no "will not fit" note, because no item has a size and PMOS holds no working hours. Press a day to list its meetings below the strip; here the rows are for reading only. The chevron hides the card, as on the Briefing.
198
204
 
199
205
  **Row suggestions and buttons.** A row shows a suggestion line only when a record backs it: an agent's offer on the item, a draft that is ready, or a date. A row has no button of its own. Press the row to open the item, where you review a draft, start the agent, or give the item a day. To act without opening it, swipe the row or press the right or left arrow key. A row in Today goes to Done (or opens its draft when one is ready) on the right and to Tomorrow on the left. Any other row goes to Today on the right and to Someday on the left. A row from Jira shows its Jira key.
200
206
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.311.0",
3
+ "version": "0.313.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.311.0",
9
+ "version": "0.313.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.311.0",
3
+ "version": "0.313.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -322,9 +322,10 @@ const GANTT = [
322
322
  await until(() => p.evaluate(() => { const c = document.querySelector('#prep'); return c && !c.hidden && /prepped/.test(c.textContent); }), 30000);
323
323
  const prep = await p.evaluate(() => { const c = document.querySelector('#prep'); return { t: c.textContent, ring: !!c.querySelector('circle.rg'), l: c.querySelector('svg').getAttribute('aria-label') }; });
324
324
  ok('PR1 the ring counts the meetings left and those with nothing to do before them', /Meeting b at \d\d:\d\d is next/.test(prep.t) && /3 meetings left today\. 2 of 3 prepped\./.test(prep.t) && prep.ring && prep.l === '2 of 3 prepped', JSON.stringify(prep));
325
- await p.click('#rng [data-r="week"]');
325
+ await until(() => p.evaluate(() => document.querySelectorAll('#wkStrip [data-day]').length === 5));
326
+ await p.click('#wkStrip [data-day][aria-pressed="false"]');
326
327
  await until(() => p.evaluate(() => document.querySelector('#prep').hidden));
327
- ok('PR2 the ring is not shown on This week', await p.evaluate(() => document.querySelector('#prep').hidden));
328
+ ok('PR2 the ring is not shown on another day', await p.evaluate(() => document.querySelector('#prep').hidden));
328
329
  await p.unroute('**/api/brief-page*');
329
330
 
330
331
  /* L: floors */
@@ -3,6 +3,7 @@
3
3
  * consoleBrief(now?) → Promise of { parts: [{ t, go? }], sources } | null reads what the console Briefing reads, composes with composeBrief
4
4
  * briefNeeds(b, page, agent) → { decisions, own, agentN } PURE. The rows the console's Needs you holds, in its ranked order (c3-brief-needs.js)
5
5
  * briefInputOf(...) → the composeBrief input PURE
6
+ * needsListOf(reads, ws) → the rows of "What you need to do", one per console Needs you row, in its order PURE
6
7
  * The same five reads, the same row rules and the same composer as the console: GET /api/briefing, GET /api/brief-page, GET /api/needs (agent drafts),
7
8
  * the calendar quarter, and the day part of the clock. A read that fails leaves its sentence out. null when the needs reads failed, so the page keeps
8
9
  * its own records-only hero rather than guess. No write, no model call. */
@@ -37,7 +38,39 @@ export function briefNeeds(b, page, agent) {
37
38
  const ordered = [...R.first, ...R.rest].filter((r) => !(R.byKey.get(r.key) || {}).members).map((r) => byKey.get(r.key)).filter(Boolean);
38
39
  const decisions = ordered.filter((x) => x.src === 'decision').map((x) => { const m = meta.get(String(x.raw.key)) || {}; return { key: String(x.raw.key), headline: x.raw.headline || '', time: m.time || null, decide: !!m.decide, overdue: !!m.overdue, days_late: m.days_late || 0 }; });
39
40
  const own = ordered.filter((x) => x.src === 'own').map((x) => ({ key: String(x.raw.key), headline: x.raw.headline || '', kind: x.raw.kind, days_late: x.raw.days_late || 0 }));
40
- return { decisions, own, agentN: ordered.filter((x) => x.src === 'agent').length };
41
+ return { decisions, own, agentN: ordered.filter((x) => x.src === 'agent').length, ordered };
42
+ }
43
+
44
+ const lateWord = (d) => (d === 1 ? '1 day late' : d + ' days late');
45
+ const factText = (f) => (f && typeof f === 'object' ? f.text : f);
46
+ /** One row of "What you need to do" from one row of the console's Needs you. A row says only what the console row's own data says:
47
+ * no "If you skip" line (no record holds one). go: where a press goes, the item's own page; null opens the Briefing's dialog. */
48
+ export function needsRowOf(x, ws) {
49
+ const r = x.raw, q = (k, v) => k + '=' + encodeURIComponent(v);
50
+ if (x.src === 'own') {
51
+ const when = r.kind === 'overdue' ? lateWord(Math.max(1, Number(r.days_late) || 1)) : r.kind === 'due-today' ? 'Due today' : r.offline ? 'Outside PMOS' : '';
52
+ return { key: 'own:' + r.key, src: 'own', title: r.headline || '', subject: ['Yours', when, r.person ? 'with ' + r.person : ''].filter(Boolean).join(' · '),
53
+ prepared: r.evidence && r.evidence.text ? 'Looks done: ' + r.evidence.text + '. Confirm it in My work.' : 'Open it in My work to mark it done, put it off or drop it.',
54
+ go: r.id ? '/premium-work.html?' + [q('item', r.id), ws ? q('ws', ws) : ''].filter(Boolean).join('&') : null };
55
+ }
56
+ if (x.src === 'agent') {
57
+ const blocked = r.kind === 'driver-blocked', ini = r.initiative_id || '';
58
+ return { key: 'agent:' + r.run_id, src: 'agent', title: r.question || '', subject: ['From the agent', blocked ? 'waiting on you' : 'drafts to review', ini].filter(Boolean).join(' · '),
59
+ prepared: blocked ? 'The agent will not go on until you decide.' : r.kind === 'core-doc-drafts' ? 'Review each draft, then issue it.' : 'Keep, send back or drop each draft.',
60
+ go: ini ? '/premium-initiative.html?' + [q('id', ini), r.ws ? q('ws', r.ws) : ''].filter(Boolean).join('&') : '/console.html' };
61
+ }
62
+ const v = r.view || null;
63
+ const facts = v ? v.facts : (r.facts || []).map(factText).filter(Boolean);
64
+ const say = (v ? v.why : r.why) || '';
65
+ return { key: 'dec:' + r.key, src: 'decision', title: r.headline || '', subject: [v ? v.tag : r.kind, r.dueText || (v && v.deadline && v.deadline.text) || r.time || '', r.src && r.src !== (v && v.tag) ? r.src : ''].filter(Boolean).join(' · '),
66
+ prepared: say || facts[0] || '', facts, options: v ? v.options.map((o) => o.label) : [], url: (v ? v.url : r.url) || null, urlLabel: (v ? v.urlLabel : r.url_label) || null, go: null };
67
+ }
68
+
69
+ /** "What you need to do" in the console's Needs you order. null when the needs reads failed. */
70
+ export function needsListOf({ b, page, agent }, ws) {
71
+ if (!page || page.ok === false) return null;
72
+ const { ordered } = briefNeeds(b, page, agent);
73
+ return ordered.map((x) => needsRowOf(x, ws));
41
74
  }
42
75
 
43
76
  export function briefInputOf({ b, page, agent, quarter, now }) {
@@ -48,9 +81,17 @@ export function briefInputOf({ b, page, agent, quarter, now }) {
48
81
  pulse: quarter && quarter.ok !== false ? pulseRows(quarter.gantt) : null };
49
82
  }
50
83
 
51
- export async function consoleBrief(now) {
84
+ /** The console Briefing's reads, once. */
85
+ export async function consoleReads() {
52
86
  const [b, page, agent, quarter] = await Promise.all([loadBriefing(true), loadBriefPage(), loadDriverNeeds().catch(() => []), readQuarter().catch(() => null)]);
87
+ return { b, page, agent, quarter };
88
+ }
89
+
90
+ export function briefOf(reads, now) {
91
+ const { page } = reads;
53
92
  if (!page || page.ok === false) return null; // the needs reads failed: keep the records-only hero rather than half a brief
54
- const r = composeBrief(briefInputOf({ b, page, agent, quarter, now }));
93
+ const r = composeBrief(briefInputOf({ ...reads, now }));
55
94
  return r.parts.length ? r : null;
56
95
  }
96
+
97
+ export async function consoleBrief(now) { return briefOf(await consoleReads(), now); }
@@ -42,6 +42,67 @@ export function weekView(r, today) {
42
42
  initiatives: (Array.isArray(r.gantt) ? r.gantt : []).filter((g) => g && g.id).slice(0, 60).map((g) => ({ id: g.id, name: clip(g.title || g.id, 70) })) };
43
43
  }
44
44
 
45
+ /* ── the Calendar card shared by the Briefing and My work (initiative premium-calendar-card): the day strip, its summary line and the chevron ── */
46
+ const weekKeys = (today) => {
47
+ const [y, m, d] = today.split('-').map(Number), wd = (new Date(Date.UTC(y, m - 1, d)).getUTCDay() + 6) % 7;
48
+ return [0, 1, 2, 3, 4].map((i) => new Date(Date.UTC(y, m - 1, d - wd + i)).toISOString().slice(0, 10));
49
+ };
50
+ /** Monday to Friday, in the shape lib/my-work-premium.js weekOf draws: meeting minutes from the week answer `W` (weekView), done and due counts from the PM's
51
+ * list `items` (GET /api/pm-items). With no calendar the days still carry the list's counts and `calendar` is false. */
52
+ export function stripOf(W, items, today) {
53
+ const ok = !!(W && W.state === 'ok'), its = Array.isArray(items) ? items : [];
54
+ const days = weekKeys(today).map((k) => {
55
+ const rows = ok ? ((W.days.find((x) => x.key === k) || {}).rows || []) : [], wd = (new Date(k + 'T00:00:00Z').getUTCDay() + 6) % 7;
56
+ return { iso: k, dow: DOW[wd].toUpperCase(), n: Number(k.slice(8)), meetings: rows.length,
57
+ meet_min: rows.reduce((a, r) => { const v = minutesBetween(r.at, r.end); return a + (v > 0 && v < 1440 ? v : 0); }, 0),
58
+ done: its.filter((it) => it && it.done && String(it.done_at || '').slice(0, 10) === k).length,
59
+ due: its.filter((it) => it && !it.done && it.due === k).length, today: k === today, past: k < today };
60
+ });
61
+ return { days, calendar: ok };
62
+ }
63
+ /** The strip: one button per day, the picked one pressed. Its look is the My work This week card's (meeting bar, done and due blocks). */
64
+ export function stripHtml(S, picked, esc) {
65
+ const top = Math.max(60, ...S.days.map((d) => d.meet_min));
66
+ const blk = (n, c) => Array.from({ length: Math.min(n, 3) }, () => `<i class="${c}"></i>`).join('');
67
+ return `<div class="wks" role="group" aria-label="This week. Pick a day to see its meetings.">${S.days.map((d) => {
68
+ const h = d.meet_min ? Math.max(8, Math.round(d.meet_min / top * 40)) : 0, hrs = d.meet_min ? (Math.round(d.meet_min / 6) / 10) + ' h' : '';
69
+ const say = d.dow + ' ' + d.n + (d.today ? ', today' : '') + ': ' + (S.calendar ? (d.meet_min ? hrs + ' of meetings, ' : 'no meetings, ') : '') + d.done + ' done, ' + d.due + ' due';
70
+ return `<button type="button" class="wkc${d.today ? ' now' : ''}${d.past ? ' past' : ''}" data-day="${d.iso}" aria-pressed="${d.iso === picked}" aria-label="${esc(say)}"><span class="wkl">${d.dow}</span><b>${d.n}</b><span class="wkb">${h ? `<i class="wkm" style="height:${h}%"></i>` : ''}${blk(d.done, 'wkx')}${blk(d.due, 'wkp')}</span><span class="wkt">${S.calendar ? (hrs || '·') : '·'}</span><span class="wkn">${d.today ? 'today' : d.due ? d.due + ' due' : ''}</span></button>`;
71
+ }).join('')}</div><p class="wkg" aria-hidden="true"><span><i class="wkm"></i>Meetings</span><span><i class="wkx"></i>Done</span><span><i class="wkp"></i>Due</span></p>`;
72
+ }
73
+ /** The one line the card shows while hidden: the next meeting today, then the week's meetings and due items. Only what the answers hold. */
74
+ export function foldLine(S, W, now = Date.now()) {
75
+ const t = S.days.find((d) => d.today), rows = W && W.state === 'ok' && t ? ((W.days.find((x) => x.key === t.iso) || {}).rows || []) : [];
76
+ const next = rows.find((r) => hasTime(r.at) && Date.parse(r.at) > now);
77
+ const meet = S.days.reduce((a, d) => a + d.meetings, 0), due = S.days.reduce((a, d) => a + d.due, 0);
78
+ return [!S.calendar ? 'Calendar not read' : next ? 'Next ' + next.time + ' ' + next.title : t ? 'Nothing more today' : '',
79
+ S.calendar ? meet + ' ' + (meet === 1 ? 'meeting' : 'meetings') + ' this week' : '', due ? due + ' due' : ''].filter(Boolean).join(' · ');
80
+ }
81
+ /** The chevron that hides `card` down to its header and one summary line. Kept in this browser per page (`key`); with nothing kept, hidden at 640 px and narrower. */
82
+ export function mountFold(card, key) {
83
+ const k = 'pmos.premium.calfold.' + key;
84
+ let kept = null; try { kept = localStorage.getItem(k); } catch { /* no storage */ }
85
+ const btn = document.createElement('button'), sum = document.createElement('button');
86
+ btn.type = sum.type = 'button'; btn.className = 'foldb'; sum.className = 'folds';
87
+ card.querySelector('.ch').append(btn); card.querySelector('.ch').after(sum);
88
+ const set = (hid, save) => {
89
+ card.classList.toggle('calhid', hid); sum.hidden = !hid;
90
+ btn.setAttribute('aria-expanded', String(!hid)); btn.setAttribute('aria-label', hid ? 'Show calendar' : 'Hide calendar');
91
+ btn.innerHTML = `<svg class="i" viewBox="0 0 24 24"><path d="${hid ? 'm6 9 6 6 6-6' : 'm6 15 6-6 6 6'}"/></svg>`;
92
+ if (save) { try { localStorage.setItem(k, hid ? '1' : '0'); } catch { /* no storage */ } }
93
+ };
94
+ set(kept === null ? matchMedia('(max-width:640px)').matches : kept === '1', false);
95
+ btn.addEventListener('click', () => set(!card.classList.contains('calhid'), true));
96
+ sum.addEventListener('click', () => { set(false, true); btn.focus(); });
97
+ return {
98
+ line(S, text, esc) {
99
+ const top = Math.max(60, ...S.days.map((d) => d.meet_min));
100
+ sum.setAttribute('aria-label', 'Show calendar. ' + text);
101
+ sum.innerHTML = `<span>${esc(text)}</span><span class="wkmini" aria-hidden="true">${S.days.map((d) => `<i${d.today ? ' class="now"' : ''} style="height:${S.calendar && d.meet_min ? Math.max(15, Math.round(d.meet_min / top * 100)) : 10}%"></i>`).join('')}</span>`;
102
+ },
103
+ };
104
+ }
105
+
45
106
  /** The meeting dialog's sections. `row` is a weekView row; `replay` is { state:'none'|'ok'|'error', body }; `material` is { state, items }. Nothing here is invented. */
46
107
  export function meetingView(row, replay, material, extra) {
47
108
  const rep = replay && replay.state === 'ok' ? replay.body : null;
@@ -260,13 +321,15 @@ export function replayAt(m, pos) {
260
321
 
261
322
  /* ── the page half ─────────────────────────────────────────────────────────────────────────────────────── */
262
323
 
263
- /** deps: { $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, wsq(), ws() }. Returns { mode, draw, openToday }. */
324
+ /** deps: { $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, wsq(), ws() }. Returns { mode, draw, openToday }. The card's day strip and chevron are drawn here (initiative premium-calendar-card). */
264
325
  export function mountMeeting(d) {
265
326
  const { $, $$, esc } = d;
266
- let mode = 'today', W = null, seq = 0, busy = false;
327
+ let picked = null, W = null, listItems = null, seq = 0, busy = false;
267
328
  const today = () => { const t = new Date(); return `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`; };
329
+ const other = () => !!picked && picked !== today();
268
330
  const wsq = (first) => { const w = d.ws(); return w ? (first ? '?' : '&') + 'ws=' + encodeURIComponent(w) : ''; };
269
331
  const ICON = '<rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/>';
332
+ const fold = mountFold($('#todayCard'), 'brief');
270
333
 
271
334
  async function readWeek() {
272
335
  const n = ++seq; busy = true;
@@ -274,29 +337,36 @@ export function mountMeeting(d) {
274
337
  if (n !== seq) return;
275
338
  busy = false; W = weekView(res, today());
276
339
  }
340
+ async function readItems() { const r = await d.pmGet('/api/pm-items' + wsq(true)); listItems = r && r.ok === true && Array.isArray(r.items) ? r.items : []; }
277
341
  const rowHtml = (r, k) => `<button class="ev src-meeting${r.past ? ' wkpast' : ''}" data-w="${esc(k)}" aria-haspopup="dialog"><time>${esc(r.time)}</time><span class="gl-t"><svg class="i" viewBox="0 0 24 24">${ICON}</svg></span><span><b>${esc(r.title)}</b><span class="d">${esc([r.sub, r.about].filter(Boolean).join(' · ') || 'No other people listed')}</span></span></button>`;
342
+ /** The day strip and the hidden line. Drawn once the week and the list are read. */
343
+ function drawStrip() {
344
+ if (!W || !listItems) return;
345
+ const S = stripOf(W, listItems, today());
346
+ $('#wkStrip').innerHTML = stripHtml(S, picked || today(), esc);
347
+ fold.line(S, foldLine(S, W), esc);
348
+ }
349
+ /** Today picked: false, and the page draws its Today timeline. Another day picked: that day's meetings and due items, and true. */
278
350
  function draw() {
279
351
  const card = $('#todayCard');
280
- $$('#rng button').forEach((b) => b.setAttribute('aria-pressed', b.dataset.r === mode));
281
- card.classList.toggle('wkm', mode === 'week'); $('#rcap').hidden = mode !== 'week';
282
- if (mode !== 'week') return false;
283
- $('#tl').setAttribute('aria-label', 'This week. Use the up and down arrow keys to move between rows.');
284
- if (!W) { $('#todayCap').textContent = $('#rcap').textContent = 'Reading the calendar'; $('#tl').innerHTML = '<div class="empty">Reading the calendar PMOS holds.</div>'; return true; }
285
- $('#todayCap').textContent = $('#rcap').textContent = W.caption;
286
- if (W.state === 'error') { $('#tl').innerHTML = `<div class="empty" role="status">Calendar not read. ${esc(W.reason)}</div>`; return true; }
287
- $('#tl').innerHTML = W.days.map((x) => `<div class="wkd${x.today ? ' now' : ''}">${esc(x.label)}${x.today ? ' · today' : ''}<em>${x.rows.length ? x.rows.length + (x.rows.length === 1 ? ' meeting' : ' meetings') : ''}</em></div>${x.rows.length ? x.rows.map((r, i) => rowHtml(r, x.key + '|' + i)).join('') : '<div class="empty">No meetings.</div>'}`).join('');
352
+ drawStrip();
353
+ card.classList.toggle('wkm', other());
354
+ if (!other()) { $('#tl').setAttribute('aria-label', 'Today. Use the up and down arrow keys to move between rows.'); return false; }
355
+ const x = W && W.state === 'ok' ? W.days.find((y) => y.key === picked) : null;
356
+ $('#tl').setAttribute('aria-label', (x ? x.label : 'That day') + '. Use the up and down arrow keys to move between rows.');
357
+ if (!W) { $('#todayCap').textContent = 'Reading the calendar'; $('#tl').innerHTML = '<div class="empty">Reading the calendar PMOS holds.</div>'; return true; }
358
+ if (W.state === 'error') { $('#todayCap').textContent = W.caption; $('#tl').innerHTML = `<div class="empty" role="status">Calendar not read. ${esc(W.reason)}</div>`; return true; }
359
+ const due = (listItems || []).filter((it) => it && !it.done && it.due === picked);
360
+ $('#todayCap').textContent = x ? (x.rows.length ? x.rows.length + (x.rows.length === 1 ? ' meeting' : ' meetings') : 'No meetings') + (due.length ? ' · ' + due.length + ' due' : '') : '';
361
+ $('#tl').innerHTML = x ? `<div class="wkd">${esc(x.label)}<em>${x.rows.length ? x.rows.length + (x.rows.length === 1 ? ' meeting' : ' meetings') : ''}</em></div>`
362
+ + due.map((it) => `<div class="wkdue"><span>Due</span><b>${esc(clip(it.title, 140))}</b></div>`).join('')
363
+ + (x.rows.length ? x.rows.map((r, i) => rowHtml(r, x.key + '|' + i)).join('') : '<div class="empty">No meetings.</div>') : '<div class="empty">That day is not in this week.</div>';
288
364
  $$('#tl .ev').forEach((e, i) => { e.tabIndex = i ? -1 : 0; });
289
365
  mark();
290
366
  return true;
291
367
  }
292
368
  const rowOf = (k) => { const [day, i] = k.split('|'); const x = W && W.days.find((y) => y.key === day); return x ? x.rows[+i] : null; };
293
369
 
294
- async function setMode(m, redraw) {
295
- mode = m;
296
- if (m === 'week') { $('#tl').setAttribute('aria-busy', 'true'); draw(); await readWeek(); $('#tl').removeAttribute('aria-busy'); }
297
- redraw();
298
- }
299
-
300
370
  /* ── recording: the notes the server holds, the recorder this page holds, and the presses on both ───────────────────────── */
301
371
  let NR = [], HOLD = null, R = null, evOf = null, cur = null;
302
372
  const bump = () => { try { window.dispatchEvent(new CustomEvent('premium-rec')); } catch { /* no window */ } };
@@ -696,7 +766,7 @@ export function mountMeeting(d) {
696
766
  if (!res || res.ok !== true) { t.disabled = false; $('#mtgMsg').textContent = (res && res.error) || 'The link could not be saved.'; return; }
697
767
  saved = body.kind === 'none' ? '' : $('#mtgSel').selectedOptions[0].textContent;
698
768
  d.toast(body.kind === 'none' ? 'The link is removed for every occurrence of this meeting.' : 'Linked. It applies to every occurrence of this meeting.');
699
- await readWeek(); paint(); if (mode === 'week') draw();
769
+ await readWeek(); paint(); if (other()) draw();
700
770
  };
701
771
  }
702
772
 
@@ -709,9 +779,10 @@ export function mountMeeting(d) {
709
779
  return true;
710
780
  }
711
781
 
712
- $('#rng').addEventListener('click', (e) => { const b = e.target.closest('button'); if (b && b.dataset.r !== mode && d.redraw) setMode(b.dataset.r, d.redraw); });
782
+ $('#wkStrip').addEventListener('click', (e) => { const b = e.target.closest('[data-day]'); if (!b || b.dataset.day === (picked || today())) return; picked = b.dataset.day; if (d.redraw) d.redraw(); });
783
+ Promise.all([readWeek(), readItems()]).then(() => { if (d.redraw) d.redraw(); else drawStrip(); });
713
784
  $('#tl').addEventListener('click', (e) => { const b = e.target.closest('.ev[data-w]'); if (!b) return; e.stopImmediatePropagation(); const r = rowOf(b.dataset.w); if (r) openRow(r, 'week'); }, true);
714
785
  readNotes().then(() => mark());
715
786
  { const want = new URLSearchParams(location.search).get('meeting'); if (want) { history.replaceState(null, '', location.pathname + location.search.replace(/[?&]meeting=[^&]*/, '').replace(/^&/, '?')); setTimeout(() => openNote(want), 600); } }
716
- return { mode: () => mode, draw, openToday, busy: () => busy, mark, openNote };
787
+ return { mode: () => (other() ? 'day' : 'today'), draw, openToday, busy: () => busy, mark, openNote };
717
788
  }
@@ -3,7 +3,8 @@
3
3
  * Every press goes to the Work page's own route under /api/pm-items, /api/pm-jobs or /api/my-work; this file adds no writer. A control with nothing honest to write stays off and says why.
4
4
  * My work depth (initiative premium-work-depth): the dialog's tool row (Edit, Who does each step, Not before, Someday), the Focus bar and its jobs, the agent on an item
5
5
  * (draft, stop, edit, post after a confirm, send back, try again), and keys and swipe on the rows. */
6
- import { pmPost } from './http.js';
6
+ import { pmPost, pmGet } from './http.js';
7
+ import { weekView, stripHtml, foldLine, mountFold } from './premium-meeting.js';
7
8
  import { mdRender } from './markdown.js';
8
9
  import { $, $$, esc, openDlg, closeDlg, setMode, toast, loadThread, onScroll, wireRail, logHtml, turnA, turnU, ptx, CHECK, RM, S } from './premium-shell.js';
9
10
 
@@ -118,17 +119,30 @@ $('#frBody').addEventListener('click', (e) => {
118
119
  const st = M.friday.steps.find((x) => x.key === b.dataset.fr); const r = st && st.first ? rowOf(st.first) : null;
119
120
  if (r) openRow(r); else toast('Nothing to open here.');
120
121
  });
122
+ /* the Calendar card (initiative premium-calendar-card): the strip from this page's model, the picked day's meetings from GET /api/calendar-views (read-only here), a chevron */
123
+ let wkPick = null, WK = null, wkFold = null;
124
+ const wkToday = () => (M && M.today) || new Date().toISOString().slice(0, 10);
125
+ async function readWk() {
126
+ const w = new URLSearchParams(location.search).get('ws');
127
+ WK = weekView(await pmGet('/api/calendar-views?view=week&date=' + wkToday() + (w ? '&ws=' + encodeURIComponent(w) : '')), wkToday());
128
+ drawWeek();
129
+ }
121
130
  function drawWeek() {
122
131
  const W = M.week; if (!W) return;
132
+ if (!wkFold) wkFold = mountFold($('#weekCard'), 'work');
133
+ const pick = wkPick || wkToday(), S = { days: W.days.map((d) => ({ ...d, meetings: d.meetings || 0 })), calendar: W.calendar };
123
134
  $('#weekCap').textContent = W.cap;
124
- const top = Math.max(60, ...W.days.map((d) => d.meet_min));
125
- const blk = (n, c) => Array.from({ length: Math.min(n, 3) }, () => `<i class="${c}"></i>`).join('');
126
- $('#weekBody').innerHTML = `<div class="wkd" role="list">${W.days.map((d) => {
127
- const h = d.meet_min ? Math.max(8, Math.round(d.meet_min / top * 40)) : 0;
128
- const hrs = d.meet_min ? (Math.round(d.meet_min / 6) / 10) + ' h' : '';
129
- return `<div class="wkc${d.today ? ' now' : ''}${d.past ? ' past' : ''}" role="listitem" aria-label="${esc(d.dow + ' ' + d.n + ': ' + (W.calendar ? (d.meet_min ? hrs + ' of meetings, ' : 'no meetings, ') : '') + d.done + ' done, ' + d.due + ' due')}"><span class="wkl">${d.dow}</span><b>${d.n}</b><span class="wkb">${h ? `<i class="wkm" style="height:${h}%"></i>` : ''}${blk(d.done, 'wkx')}${blk(d.due, 'wkp')}</span><span class="wkt">${W.calendar ? (hrs || '·') : '·'}</span><span class="wkn">${d.done} done${d.due ? ' · ' + d.due + ' due' : ''}</span></div>`;
130
- }).join('')}</div><p class="wkg" aria-hidden="true"><span><i class="wkm"></i>Meetings</span><span><i class="wkx"></i>Done</span><span><i class="wkp"></i>Due</span></p><p class="note" style="margin-top:8px">${esc(W.note)}</p>`;
131
- }
135
+ $('#weekBody').innerHTML = stripHtml(S, pick, esc);
136
+ $('#weekNote').textContent = W.note;
137
+ wkFold.line(S, foldLine(S, WK), esc);
138
+ const x = WK && WK.state === 'ok' ? WK.days.find((y) => y.key === pick) : null;
139
+ const due = (M.rows || []).filter((r) => r.edit && r.edit.due === pick && r.list !== 'done');
140
+ $('#wkList').innerHTML = !WK ? '<div class="empty">Reading the calendar PMOS holds.</div>' : WK.state === 'error' ? `<div class="empty" role="status">Calendar not read. ${esc(WK.reason)}</div>`
141
+ : `<div class="wkd${x && x.today ? ' now' : ''}">${esc(x ? x.label : pick)}${x && x.today ? ' · today' : ''}<em>${x && x.rows.length ? x.rows.length + (x.rows.length === 1 ? ' meeting' : ' meetings') : ''}</em></div>`
142
+ + due.map((r) => `<div class="wkdue" role="listitem"><span>Due</span><b>${esc(r.title)}</b></div>`).join('')
143
+ + (x && x.rows.length ? x.rows.map((r) => `<div class="ev src-meeting${r.past || (x.today && Date.parse(r.end || r.at) < Date.now()) ? ' wkpast' : ''}" role="listitem"><time>${esc(r.time)}</time><span class="gl-t"><svg class="i" viewBox="0 0 24 24"><rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/></svg></span><span><b>${esc(r.title)}</b><span class="d">${esc([r.sub, r.about].filter(Boolean).join(' · ') || 'No other people listed')}</span></span></div>`).join('') : '<div class="empty">No meetings.</div>');
144
+ }
145
+ $('#weekBody').addEventListener('click', (e) => { const b = e.target.closest('[data-day]'); if (!b || !M) return; wkPick = b.dataset.day; drawWeek(); });
132
146
  function draw() { drawHero(); drawWeek(); drawFriday(); drawFocus(); drawPlate(); drawTray(); drawAgents(); drawWaiting(); drawReview(); drawDock(); onScroll(); backFocus(); }
133
147
  const rowOf = (key) => (M && M.rows || []).find((r) => r.key === key) || null;
134
148
 
@@ -623,6 +637,13 @@ $('#cap').addEventListener('submit', async (e) => {
623
637
  });
624
638
 
625
639
  /* ── load ────────────────────────────────────────────────────────────────────────────────────────────────── */
640
+ /* ?item=<id> (a row of the Briefing's "What you need to do"): open that item's dialog once, after the first read. */
641
+ let ASKED = new URLSearchParams(location.search).get('item');
642
+ function openAsked() {
643
+ if (!ASKED) return;
644
+ const r = rowOf('work:' + ASKED); ASKED = null;
645
+ if (r) openRow(r); else toast('That item is not on your list any more.');
646
+ }
626
647
  async function load() {
627
648
  let r = null, status = 0;
628
649
  try { const res = await fetch('/api/my-work-premium', { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
@@ -632,6 +653,8 @@ async function load() {
632
653
  return;
633
654
  }
634
655
  M = r.model; draw();
656
+ openAsked();
657
+ if (!WK) readWk();
635
658
  const mine = dlgOpen() && ((dlgKind === 'item' && openR && S.key === openR.key) || (dlgKind === 'fjobs' && S.key === 'focus:today'));
636
659
  if (mine && dlgKind === 'item') refreshOpen(); else if (mine) drawFocusDlg();
637
660
  }
@@ -1811,13 +1811,13 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
1811
1811
  .dabt{margin:0;padding-left:18px;display:grid;gap:6px;color:var(--ink-2)}
1812
1812
 
1813
1813
  /* My work: the This week card. A row has no button of its own: the whole row opens the item, where every choice is made. */
1814
- .wkd{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}
1814
+ .wks{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}
1815
1815
  .wkc{display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 4px 8px;border-radius:18px;border:1.5px solid transparent;font-size:12px;color:var(--ink-3)}
1816
1816
  .wkc.now{border-color:var(--ink)}.wkc.past{opacity:.75}
1817
1817
  .wkl{font:500 11px var(--mono);letter-spacing:.06em}.wkc b{font-size:20px;color:var(--ink);font-weight:650}
1818
1818
  .wkb{display:flex;align-items:flex-end;width:26px;height:84px;border-radius:10px;background:var(--well);overflow:hidden}.wkb i{display:block;width:100%;background:var(--ink-3);border-radius:10px 10px 0 0}
1819
1819
  .wkt{font-weight:650;color:var(--ink-2)}.wkn{font-size:11.5px;text-align:center}
1820
- @media (max-width:520px){.wkd{gap:4px}.wkn{font-size:11px}}
1820
+ @media (max-width:520px){.wks{gap:4px}.wkn{font-size:11px}}
1821
1821
 
1822
1822
  .agdraft .mdr{font-size:14px;line-height:1.55;overflow-x:auto}.agdraft .mdr table{border-collapse:collapse;margin:8px 0}.agdraft .mdr th,.agdraft .mdr td{border:1px solid var(--hair);padding:5px 9px;text-align:left}
1823
1823
  .agturns{list-style:none;margin:8px 0 0;padding:0;display:grid;gap:8px;font-size:13px;color:var(--ink-3)}.agturns li b{color:var(--ink)}.agturns span{display:block;color:var(--ink-2)}
@@ -1978,7 +1978,7 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
1978
1978
  .mhint .lk:hover{color:var(--ember-ink)}
1979
1979
 
1980
1980
  .rdbtns{display:inline-flex;gap:6px;align-items:center}
1981
- .wkd .wkc{font:400 12px var(--sans);letter-spacing:0;text-transform:none;padding:12px 4px 10px}
1981
+ .wks .wkc{font:400 12px var(--sans);letter-spacing:0;text-transform:none;padding:12px 4px 10px}
1982
1982
  .wkc .wkl{font:500 11px var(--mono);letter-spacing:.08em}
1983
1983
  .wkc .wkb{flex-direction:column-reverse;gap:3px;width:36px;height:100px;border-radius:12px;padding:0}.wkb i{flex:none;border-radius:4px}
1984
1984
  .wkb .wkm,.wkg .wkm{background:color-mix(in oklab,var(--ink) 22%,var(--well))}
@@ -1986,3 +1986,20 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
1986
1986
  .wkb .wkp,.wkg .wkp{background:repeating-linear-gradient(135deg,var(--ember) 0 3px,color-mix(in oklab,var(--ember) 35%,var(--well)) 3px 6px)}
1987
1987
  .wkc .wkt{font-weight:600;color:var(--ink-2)}
1988
1988
  .wkg{display:flex;gap:14px;margin:12px 0 0;font-size:12px;color:var(--ink-3)}.wkg span{display:inline-flex;align-items:center;gap:6px}.wkg i{width:10px;height:10px;border-radius:50%;display:inline-block}
1989
+ /* the Calendar card shared by the Briefing and My work (initiative premium-calendar-card): a day strip to pick from, the picked day below, a chevron that hides it */
1990
+ .wks{margin-top:14px}
1991
+ .wks .wkc{width:100%;min-height:44px;cursor:pointer;transition:border-color .25s,background .25s}
1992
+ .wks .wkc.now{border-color:transparent}.wks .wkc.now .wkl,.wks .wkc.now .wkn{color:var(--ember-ink);font-weight:600}
1993
+ .wks .wkc[aria-pressed="true"]{border-color:var(--ink);background:var(--card)}
1994
+ .wks .wkc:hover{background:var(--well)}.wks .wkc[aria-pressed="true"]:hover{background:var(--card)}
1995
+ .wks .wkc .wkn{min-height:14px}
1996
+ .foldb{flex:none;width:44px;height:44px;border-radius:50%;display:grid;place-items:center;background:var(--well);color:var(--ink)}
1997
+ .folds{display:flex;align-items:center;gap:12px;width:100%;min-height:44px;margin-top:8px;padding:0 2px;font-size:var(--t-small);color:var(--ink-3);text-align:left}
1998
+ .folds[hidden]{display:none}.folds>span:first-child{flex:1;min-width:0}
1999
+ .wkmini{display:flex;align-items:flex-end;gap:3px;height:22px;flex:none}.wkmini i{width:5px;border-radius:3px;background:color-mix(in oklab,var(--ink) 30%,var(--well))}.wkmini i.now{background:var(--ink)}
2000
+ .card.calhid>:not(.ch):not(.folds){display:none}
2001
+ .card.calhid .ch{position:static}
2002
+ .wkdue{display:grid;grid-template-columns:48px minmax(0,1fr);gap:12px;align-items:center;padding:10px 12px;margin:2px 0 6px;border-radius:14px;background:color-mix(in oklab,var(--ember) 12%,var(--card))}
2003
+ .wkdue span{font:600 12px var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--ember-ink)}.wkdue b{font-weight:550}
2004
+ .tl.wkday{min-height:0}.tl.wkday .ev{cursor:default}
2005
+ #todayCard.wkm .foldb{margin-left:auto}
@@ -7,7 +7,7 @@ import { startAgent } from './page-agent.js';
7
7
  import { mountMeeting } from './premium-meeting.js';
8
8
  import { mountFirst } from './premium-first.js';
9
9
  import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
10
- import { consoleBrief } from './premium-brief.js';
10
+ import { consoleReads, briefOf, needsListOf } from './premium-brief.js';
11
11
  import { momentOf, inText } from './c3-phone-model.js';
12
12
  import { $, $$, esc, store, THEME_KEY, RM, AI, S, theme, toast, kv, H, openDlg, closeDlg, setTab, setMode, CHECK, CHEV, ptx, turnA, turnU, H1, H2, P1, UL, logHtml, loadThread, onScroll, wireRail, pvFeed } from './premium-shell.js';
13
13
  const ICON = {
@@ -22,7 +22,7 @@ const on = new Set(Object.keys(SRC));
22
22
  const pinned = new Set();
23
23
 
24
24
  wireRail('brief');
25
- const week = mountMeeting({ $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, ws: () => new URLSearchParams(location.search).get('ws'), redraw: () => drawTl() });
25
+ const week = mountMeeting({ $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, ws: () => new URLSearchParams(location.search).get('ws'), redraw: () => { if (M) drawTl(); } });
26
26
 
27
27
  /* ── a day's baseline, kept on this device, so "N of M done" counts rows that cleared since the page first read today ────── */
28
28
  const dayKey = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
@@ -39,10 +39,17 @@ function baseline(keys) {
39
39
  /* The headline is the console's "The brief", from the same reads and the same composer (premium-brief.js). Until it comes back, or when its reads fail, the
40
40
  * records-only sentences above stay. Each draw asks again; a late answer to an older ask is dropped. */
41
41
  let briefAsk = 0, shownBrief = null; // once the console brief is shown, a re-read keeps it on screen until the next answer: the hero does not flip back
42
+ /* "What you need to do" is the console's Needs you, from the same reads (premium-brief.js needsListOf). null until they come back, and while the
43
+ * needs reads fail: the records-only rows of the model stay. */
44
+ let CL = null;
42
45
  function drawConsoleBrief() {
43
46
  const ask = ++briefAsk;
44
- consoleBrief().then((r) => {
45
- if (ask !== briefAsk || !r) return;
47
+ consoleReads().then((reads) => {
48
+ if (ask !== briefAsk) return;
49
+ const list = needsListOf(reads, new URLSearchParams(location.search).get('ws'));
50
+ if (list) { CL = list; drawRows(); drawDock(); pvFeed({ ok: true, model: { list: LIST() } }); }
51
+ const r = briefOf(reads);
52
+ if (!r) return;
46
53
  shownBrief = r.parts.map((p) => (p.go ? `<span class="k">${esc(p.t)}</span>` : esc(p.t))).join('');
47
54
  if ($('#brief').innerHTML !== shownBrief) { $('#brief').innerHTML = shownBrief; onScroll(); }
48
55
  $('#brief').title = 'The same paragraph as The brief on the console Briefing. Read from: ' + r.sources.join(', ') + '.';
@@ -58,21 +65,28 @@ function drawHero() {
58
65
 
59
66
  /* ── rows ───────────────────────────────────────────────────────────────────────────────────────────────── */
60
67
  const STAMP = (n) => String(n).padStart(2, '0');
68
+ const CL_ORDER = 'In the order of Needs you on the console: what cannot wait first, then by impact, urgency and effort.';
69
+ /** The list the page draws: the console's Needs you once it is read, else the model's records-only rows. */
70
+ function LIST() {
71
+ if (!CL) return M.list;
72
+ return { rows: CL.map((r, i) => ({ ...r, n: i + 1 })), count: CL.length, more: 0, putOff: [], order: CL_ORDER, pendingNote: '' };
73
+ }
61
74
  function drawRows() {
62
- const rows = M.list.rows, L = $('#rank');
63
- const keys = rows.map((r) => r.key), off = (M.list.putOff || []).map((x) => x.key); // a row put off is not done: it leaves both counts and is named below the list
64
- const base = (M.pending ? keys : baseline(keys)).filter((k) => !off.includes(k)), done = base.filter((k) => !keys.includes(k)).length, total = base.length;
75
+ const LS = LIST(), pend = M.pending && !CL;
76
+ const rows = LS.rows, L = $('#rank');
77
+ const keys = rows.map((r) => r.key), off = (LS.putOff || []).map((x) => x.key); // a row put off is not done: it leaves both counts and is named below the list
78
+ const base = (pend ? keys : baseline(keys)).filter((k) => !off.includes(k)), done = base.filter((k) => !keys.includes(k)).length, total = base.length;
65
79
  const order = rows.slice().sort((a, b) => (pinned.has(b.key) - pinned.has(a.key)) || (a.n - b.n));
66
- L.innerHTML = order.map((r, i) => `<div class="rr${i < 3 ? ' lead' : ''}${i === 0 ? ' first' : ''}" data-key="${esc(r.key)}"${linkOf(r) ? ` data-link="${esc(linkOf(r))}"` : ''}><button class="rhd" aria-haspopup="dialog"><span class="rn">${STAMP(i + 1)}</span><span><span class="rt">${esc(r.title)}${i === 0 ? '<em class="tgf">Do this first</em>' : ''}</span><span class="rs">${r.product ? `<b class="pn">${esc(r.product)}</b>` : ''}${esc(r.subject)}</span><span class="sug"><span>${esc(r.prepared)}</span></span><span class="skip">${esc(r.skip)}</span></span></button><button class="rpin" data-pin="${esc(r.key)}" aria-pressed="${pinned.has(r.key)}" aria-label="Pin ${esc(r.title)} to the top" title="Pin to the top"><svg class="i" viewBox="0 0 24 24"><path d="M9 4h6l-1 6 3 3H7l3-3zM12 13v7"/></svg></button></div>`).join('')
67
- + (M.list.more ? `<p class="note">${M.list.more} more ${M.list.more === 1 ? 'row is' : 'rows are'} not shown here.</p>` : '');
68
- const n = M.list.count;
69
- $('#movesCap').innerHTML = M.pending ? `${n} ${n === 1 ? 'row' : 'rows'} so far · still reading` : n ? `<b>${done} of ${total}</b> done · ${n} ${n === 1 ? 'row' : 'rows'} left` : 'All clear';
80
+ L.innerHTML = order.map((r, i) => `<div class="rr${i < 3 ? ' lead' : ''}${i === 0 ? ' first' : ''}" data-key="${esc(r.key)}"${linkOf(r) ? ` data-link="${esc(linkOf(r))}"` : ''}><button class="rhd" aria-haspopup="dialog"><span class="rn">${STAMP(i + 1)}</span><span><span class="rt">${esc(r.title)}${i === 0 ? '<em class="tgf">Do this first</em>' : ''}</span><span class="rs">${r.product ? `<b class="pn">${esc(r.product)}</b>` : ''}${esc(r.subject)}</span><span class="sug"><span>${esc(r.prepared)}</span></span>${r.skip ? `<span class="skip">${esc(r.skip)}</span>` : ''}</span></button><button class="rpin" data-pin="${esc(r.key)}" aria-pressed="${pinned.has(r.key)}" aria-label="Pin ${esc(r.title)} to the top" title="Pin to the top"><svg class="i" viewBox="0 0 24 24"><path d="M9 4h6l-1 6 3 3H7l3-3zM12 13v7"/></svg></button></div>`).join('')
81
+ + (LS.more ? `<p class="note">${LS.more} more ${LS.more === 1 ? 'row is' : 'rows are'} not shown here.</p>` : '');
82
+ const n = LS.count;
83
+ $('#movesCap').innerHTML = pend ? `${n} ${n === 1 ? 'row' : 'rows'} so far · still reading` : n ? `<b>${done} of ${total}</b> done · ${n} ${n === 1 ? 'row' : 'rows'} left` : 'All clear';
70
84
  $('#movesCap').title = 'Counts rows that cleared since this page first read today. A row clears when its record changes.';
71
- const p = $('#mprog'); p.hidden = !total || !!M.pending; p.setAttribute('aria-valuemax', total); p.setAttribute('aria-valuenow', done); $('b', p).style.width = (total ? done / total * 100 : 0) + '%';
72
- $('#calm').hidden = n > 0 || !!M.pending; $('#calmNext').textContent = '';
73
- $('#order').textContent = M.pending ? M.list.pendingNote : n ? M.list.order : '';
74
- $('#order').hidden = !n && !M.pending;
75
- const po = M.list.putOff || [];
85
+ const p = $('#mprog'); p.hidden = !total || pend; p.setAttribute('aria-valuemax', total); p.setAttribute('aria-valuenow', done); $('b', p).style.width = (total ? done / total * 100 : 0) + '%';
86
+ $('#calm').hidden = n > 0 || pend; $('#calmNext').textContent = '';
87
+ $('#order').textContent = pend ? LS.pendingNote : n ? LS.order : '';
88
+ $('#order').hidden = !n && !pend;
89
+ const po = LS.putOff || [];
76
90
  $('#putoff').textContent = po.length ? 'Put off by you: ' + po.map((x) => x.text).join('; ') + '. Not counted as done.' : '';
77
91
  $('#putoff').hidden = !po.length;
78
92
  }
@@ -80,13 +94,16 @@ $('#rank').addEventListener('click', (e) => {
80
94
  const pin = e.target.closest('.rpin');
81
95
  if (pin) { const k = pin.dataset.pin; pinned.has(k) ? pinned.delete(k) : pinned.add(k); drawRows(); toast(pinned.has(k) ? 'Pinned to the top for this session.' : 'Unpinned.'); return; }
82
96
  const h = e.target.closest('.rhd');
83
- if (h) openRow(M.list.rows.find((r) => r.key === h.closest('.rr').dataset.key));
97
+ if (!h) return;
98
+ const r = LIST().rows.find((x) => x.key === h.closest('.rr').dataset.key);
99
+ if (r && r.go) { location.assign(r.go); return; } // a console row opens its item on its own page: My work, the initiative, or the console
100
+ openRow(r);
84
101
  });
85
102
 
86
103
  /* ── today ──────────────────────────────────────────────────────────────────────────────────────────────── */
87
104
  const linkOf = (r) => ((r.from || []).find((x) => /^meeting:/.test(x)) || '').replace(/^meeting:/, '');
88
105
  function evHtml(e, i) {
89
- const lnk = e.kind === 'meeting' && (M.list.rows || []).some((r) => linkOf(r) === e.title) ? e.title : '';
106
+ const lnk = e.kind === 'meeting' && (LIST().rows || []).some((r) => linkOf(r) === e.title) ? e.title : '';
90
107
  return `<button class="ev src-${e.kind}"${lnk ? ` data-link="${esc(lnk)}"` : ''} data-i="${i}" style="animation:rise .6s var(--ease) both"><time>${esc(e.t)}</time><span class="gl-t"><svg class="i" viewBox="0 0 24 24">${ICON[e.kind]}</svg></span><span><b>${esc(e.title)}</b><span class="d">${esc(e.sub)}${e.product ? ' · ' + esc(e.product) : ''}</span></span></button>`;
91
108
  }
92
109
  const ALL = () => M.today.ahead.concat(M.today.earlier);
@@ -135,7 +152,10 @@ document.addEventListener('click', (e) => {
135
152
  });
136
153
 
137
154
  /* ── dock ───────────────────────────────────────────────────────────────────────────────────────────────── */
138
- function drawDock() { $('#dN').textContent = M.dock.needs == null ? '·' : M.dock.needs; $('#dLab').textContent = M.dock.needs == null ? 'still reading' : M.dock.needs === 0 ? 'need you' : M.dock.label; }
155
+ function drawDock() {
156
+ const n = CL ? CL.length : M.dock.needs;
157
+ $('#dN').textContent = n == null ? '·' : n; $('#dLab').textContent = n == null ? 'still reading' : n === 0 ? 'need you' : CL ? (n === 1 ? 'needs you' : 'need you') : M.dock.label;
158
+ }
139
159
 
140
160
  const SEL = {}; // the option chosen on each row, for this session
141
161
  const START = {}; // 'ask' while the PM is confirming a start, by row key
@@ -189,13 +209,20 @@ let openR = null;
189
209
  function plainDialog(r) {
190
210
  return { eye: 'Detail', logTitle: 'Read from the repository', log: ['Read the record'], say: [r.prepared, r.skip].filter(Boolean).join(' '), head: 'What is known', facts: [['Subject', r.subject], ['Next', r.prepared], ['If you skip', r.skip && r.skip.replace(/^If you skip: /, '')]].filter((x) => x[1]), opts: [], sel: null, nodef: '', pane: { label: 'Detail', file: '', h: r.title, intro: r.subject || '', rows: [], paras: [] } };
191
211
  }
212
+ /* A decision from the console's Needs you: what its record says, and its source. Choosing an option on an engine card is not recorded from here. */
213
+ function consoleDialog(r) {
214
+ const facts = [['Kind', r.subject]].concat((r.facts || []).map((f) => ['Fact', f]), r.options && r.options.length ? [['Options', r.options.join(' · ')]] : []);
215
+ return { eye: 'Needs you', logTitle: 'Read from the console Briefing', log: ['Read GET /api/briefing', 'Kept the row Needs you shows'], say: r.prepared || 'This is on the console\'s Needs you.', head: 'What is known', facts, opts: [], sel: null,
216
+ nodef: r.options && r.options.length ? 'Choosing an option is recorded on the console Briefing, not here.' : '', link: r.url || null, linkLabel: r.urlLabel || null, noAsk: true,
217
+ pane: { label: 'Detail', file: 'Needs you', h: r.title, intro: r.subject || '', rows: [], paras: (r.facts || []).slice(0, 6) } };
218
+ }
192
219
  function openRow(r) {
193
220
  if (!r) return;
194
- if (!r.dialog) r = { ...r, dialog: plainDialog(r) };
221
+ if (!r.dialog) r = { ...r, dialog: r.src ? consoleDialog(r) : plainDialog(r) };
195
222
  openR = r; const d = r.dialog;
196
223
  openDlg({ eye: d.eye + ' · real data', title: d.title || r.title, sub: d.sub || r.subject, say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(r), noteKey: r.key, pane: paneHtml(r), label: d.pane.label });
197
224
  ctaState(r);
198
- loadThread(r.key);
225
+ if (r.dialog.noAsk) { $('#askF').hidden = true; $('#askNote').hidden = true; } else loadThread(r.key); // the read-only agent answers about the model's rows only
199
226
  setTimeout(() => { const b = $('#dBody'); b.scrollTop = b.scrollHeight; }, 120);
200
227
  }
201
228
  function showErr(msg) { const e = $('#cardErr'); if (!e) { toast(msg); return; } e.textContent = msg; e.hidden = false; }
@@ -899,7 +926,7 @@ async function load() {
899
926
  const ws = new URLSearchParams(location.search).get('ws');
900
927
  try { const res = await fetch('/api/briefing-premium' + (ws ? '?ws=' + encodeURIComponent(ws) : ''), { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
901
928
  clearInterval(readTimer);
902
- pvFeed(r);
929
+ pvFeed(CL && r && r.ok ? { ok: true, model: { list: LIST() } } : r); // the bell counts what the list shows: the console's Needs you once it is read
903
930
  if (r && r.state === 'reading') {
904
931
  // the first read has no end I can promise: say how long it has run, and ask again
905
932
  const t0 = Date.now() - (r.elapsed_ms || 0), tick = () => { $('#brief').textContent = 'Reading the products for the first time. ' + Math.round((Date.now() - t0) / 1000) + ' s so far. This page shows nothing until it has read, rather than guess.'; };
@@ -59,8 +59,10 @@
59
59
  </div>
60
60
  <div>
61
61
  <section class="card rise" style="--d:6" id="weekCard" aria-labelledby="hWeek">
62
- <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/></svg></span><h2 id="hWeek">This week</h2><small id="weekCap"></small></div>
62
+ <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/></svg></span><h2 id="hWeek">Calendar</h2><small id="weekCap"></small></div>
63
63
  <div id="weekBody"></div>
64
+ <div class="tl wkday" id="wkList" role="list" aria-label="Meetings of the picked day"></div>
65
+ <p class="note" id="weekNote" style="margin-top:8px"></p>
64
66
  </section>
65
67
  <section class="card rise" style="--d:7" id="agCard" aria-labelledby="hAg">
66
68
  <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/></svg></span><h2 id="hAg">With agents</h2><small id="agCap"></small></div>
@@ -67,8 +67,8 @@
67
67
  </div>
68
68
  <div>
69
69
  <section class="card rise" id="todayCard" style="--d:7" aria-labelledby="hToday">
70
- <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></span><h2 id="hToday">Today</h2><div class="seg" id="rng" role="group" aria-label="Range"><button type="button" data-r="today" aria-pressed="true">Today</button><button type="button" data-r="week" aria-pressed="false">This week</button></div><small id="todayCap"></small><button class="fbtn" data-opts="todayOpts" aria-expanded="false" aria-controls="todayOpts" aria-label="Filter sources"><svg class="i" viewBox="0 0 24 24"><path d="M4 7h9M17 7h3M4 17h3M11 17h9"/><circle cx="15" cy="7" r="2"/><circle cx="9" cy="17" r="2"/></svg></button></div>
71
- <p class="rcap" id="rcap" hidden></p>
70
+ <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></span><h2 id="hToday">Calendar</h2><small id="todayCap"></small><button class="fbtn" data-opts="todayOpts" aria-expanded="false" aria-controls="todayOpts" aria-label="Filter sources"><svg class="i" viewBox="0 0 24 24"><path d="M4 7h9M17 7h3M4 17h3M11 17h9"/><circle cx="15" cy="7" r="2"/><circle cx="9" cy="17" r="2"/></svg></button></div>
71
+ <div id="wkStrip"></div>
72
72
  <div class="prep" id="prep" hidden></div>
73
73
  <div class="opts" id="todayOpts" inert><div><div class="chips" id="srcChips" role="group" aria-label="Sources"></div></div></div>
74
74
  <div class="tl" id="tl" role="group" aria-label="Today. Use the up and down arrow keys to move between rows."></div>