create-pmos 0.765.0 → 0.766.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.765.0",
3
+ "version": "0.766.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": {
@@ -33,6 +33,19 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.766.0",
38
+ "at": "2026-11-24T07:23:50.157Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1723,
43
+ "t": "The chat beside a task is about the task",
44
+ "s": "The chat beside a task is about the task",
45
+ "k": "fix"
46
+ }
47
+ ]
48
+ },
36
49
  {
37
50
  "v": "0.765.0",
38
51
  "at": "2026-11-24T07:12:50.601Z",
@@ -357,25 +370,6 @@
357
370
  "k": "new"
358
371
  }
359
372
  ]
360
- },
361
- {
362
- "v": "0.746.0",
363
- "at": "2026-11-23T11:03:05.465Z",
364
- "f": 4,
365
- "prs": [
366
- {
367
- "n": 1670,
368
- "t": "Give PressRelease a doc-category row (red main)",
369
- "s": "Give PressRelease a doc-category row (red main)",
370
- "k": "fix"
371
- },
372
- {
373
- "n": 1668,
374
- "t": "A short link for every item, which opens it in its panel on a desktop and full screen on a phone (A428)",
375
- "s": "A short link for every item, which opens it in its panel on a desktop and full screen on a phone (A428)",
376
- "k": "new"
377
- }
378
- ]
379
373
  }
380
374
  ]
381
375
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@5bf77c3b
1
+ kernel-source: pmos@e6956da5
2
2
  assembled: 2026-11-24
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-11-24T07:12:47Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T07:23:46Z"}
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-11-24T07:12:47Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T07:23:46Z"}
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-11-24T07:12:47Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T07:23:46Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.766.0",
4
+ "at": "2026-11-24T07:23:50.157Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1723,
9
+ "t": "The chat beside a task is about the task",
10
+ "s": "The chat beside a task is about the task",
11
+ "k": "fix"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.765.0",
4
17
  "at": "2026-11-24T07:12:50.601Z",
@@ -181,7 +181,7 @@ Under it, two blocks use the full width of the popup:
181
181
  - **Stages.** Each stage of the workflow, with its dates under its name or "no dates yet", on a month scale with a red line for today. A stage's bar runs from the earliest start to the latest end of its tasks; a task with no start counts from its due date. Only a stage with no dated task uses the days the workflow moved through it. To change a stage's dates, change its tasks' dates. A stage has a bar only when it has real dates. A milestone is a diamond on its stage's row.
182
182
  - **Work breakdown.** **List** or **Gantt**; PMOS keeps your choice on this computer. **List** has one box on top: type a task and press Enter. Say its stage ("… in Plan"), or it goes to the stage in progress; start with ◇ to add a milestone. Each stage with tasks is one group that says how much is done, for example "1 of 3 done". Press the group to fold it, and press it again to open it. A stage whose tasks are all done is folded until you open it. In a stage, the tasks are in date order, a late task first. A done task stays in its place, in grey with a check. Stages with no tasks fold into one line at the end. Press the box before a task to mark it done, with **Undo**. Press its name to rename it: Enter saves and Escape cancels. When you point at the row, four icons show: **Who** (You, the people on this initiative, or **PMOS does it**, which gives the task to PMOS), **Due date**, **Stage** (moves the task to another stage) and ⋯ (**Status**, **Make it a milestone** and **Open the task**). Each change has **Undo**. A Jira ticket keeps its owner and stage from Jira. **Gantt** is the table described below, with its bars.
183
183
 
184
- Press the rest of a row, or a milestone, to open it as a full popup in place of the work side. Its top line has ←, the path (**Work › product › initiative**), the chat button, ⋯ and ×. ← or the initiative's name goes back to the initiative, where you left it. The chat button shows **Ask PMOS** beside it. × closes the popup. A task shows its status, dates, owner, notes and what changed. A milestone also shows its date and how many days are left, the done test, **Kill if**, and the suggestion from PMOS about it when there is one.
184
+ Press the rest of a row, or a milestone, to open it as a full popup in place of the work side. Its top line has ←, the path (**Work › product › initiative**), the chat button, ⋯ and ×. ← or the initiative's name goes back to the initiative, where you left it. The chat beside it is about the task or milestone itself: its own conversation, which starts with the item's status, dates, owner and notes, and the line under the chat's title reads **Task in** and the initiative. The chat button shows that chat. ← back to the initiative shows the initiative's chat again, and its sessions stay in the chat's session list. A file or a task that the chat opens itself does not change the chat. × closes the popup. A task shows its status, dates, owner, notes and what changed. A milestone also shows its date and how many days are left, the done test, **Kill if**, and the suggestion from PMOS about it when there is one.
185
185
 
186
186
  **Artefacts** are at the top of the initiative's ⋯ menu: the brief, the prototype and the documents, each with its kind and date. Press one to open it full screen, with ← back to the initiative. A document the gate needs that nobody wrote is grey and says which gate. **Add an artefact** adds a file, a link or a new document; it is in the menu the next time you open ⋯. When PMOS suggests a merge, the suggestion is the first row of the section. After a merge, the merged file stands and says how many earlier files it holds, for example "7 earlier". An old file folds under it when its frontmatter has `superseded_by:` with the merged file's path, or when it opens with the merge's "superseded by" note. The merge suggestion then goes away by itself.
187
187
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.765.0",
3
+ "version": "0.766.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.765.0",
9
+ "version": "0.766.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.765.0",
3
+ "version": "0.766.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",
@@ -51,7 +51,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
51
51
  await page.route('**/api/initiative-premium*', (r) => { const u = r.request().url(); S.gets.push(u); if (!r.request().headers()['x-pmos-nonce']) S.vgets.push(u); const a = answer ? answer(u, S.gets.filter((x) => x === u).length) : { status: 200, body: { ok: true, state: 'ready', model: MODEL, as_of: Date.now() } }; r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); });
52
52
  await page.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }));
53
53
  await page.goto(BASE + '/today.html?ini=self-serve-v2&ws=w1&board=w1&theme=' + theme);
54
- S.up = await until(() => page.evaluate(() => !!document.querySelector('#czViewer .iv-mc') && !!window.__premiumWorkItem), 20000);
54
+ S.up = await until(() => page.evaluate(() => !!document.querySelector('#czViewer .iv-mc') && !!window.__premiumWorkItem), 45000); // the server's first reads take ~17s on main here and more on a busy CI runner
55
55
  // When Home does not come up, say what the page holds instead, so a CI-only failure can be read from the log.
56
56
  if (!S.up) console.log(' (R9 not up: ' + JSON.stringify(await page.evaluate(() => { const v = document.querySelector('#czViewer'); return { url: location.pathname + location.search, viewer: v ? { hidden: v.hidden, w: v.getBoundingClientRect().width, cls: v.className, html: v.innerHTML.replace(/\s+/g, ' ').slice(0, 300) } : null, item: !!window.__premiumWorkItem, body: document.body.className, fs: getComputedStyle(document.documentElement).getPropertyValue('--fs-body') }; }).catch((e) => String(e))) + ' errors ' + JSON.stringify(S.errors.slice(0, 3)) + ' gets ' + S.gets.length + ')');
57
57
  return { page, ctx, S };
@@ -53,6 +53,7 @@ const S = {
53
53
  el: null, card: null, left: null, right: null, box: null, all: null, menu: null, toast: null, tools: null, title: null, st: null,
54
54
  open: false, about: null, home: null, chat: null, back: null, raw: [], rows: { now: [], earlier: [], all: [] }, view: 'chat', q: '', prev: null,
55
55
  ending: new Map(), timer: 0, toastT: 0, titles: null, opener: null, w: 0, seq: 0,
56
+ base: null, views: new Map(), bind: undefined, // base: what the popup was opened about; views: Viewer item id → what its chat is about
56
57
  };
57
58
 
58
59
  /* ── the page's hooks ── */
@@ -156,7 +157,17 @@ function drawDot() { const d = S.tools && S.tools.querySelector('.cz-pop-dot');
156
157
 
157
158
  /* ── open and close ── */
158
159
  VW.popHook({ host: () => { frame(); return S.left; }, show });
159
- VW.onChange((d) => { if (d && d.pop && d.shut && S.open) hide(); });
160
+ VW.onChange((d) => {
161
+ if (!d || !d.pop) return;
162
+ if (d.shut) { if (S.open) hide(); return; }
163
+ if (!S.open || RO || !d.open || d.id == null) return;
164
+ // the item an open with pop put on the left: its chat is the popup's base (show, retarget)
165
+ if (S.bind !== undefined) { S.views.set(d.id, S.bind); S.bind = undefined; return; }
166
+ // ← or → back to an item shown before: the chat goes back to that item's chat (the initiative's, after a task)
167
+ if (S.views.has(d.id)) { aboutItem(S.views.get(d.id)); return; }
168
+ // a drill-in that says what it is (chatAbout: a task, a milestone): the chat moves to it, unless the chat opened it itself
169
+ if (d.chatAbout && !d.viaChat) { const a = itemAbout(d.chatAbout); if (a) { S.views.set(d.id, a); aboutItem(a); } }
170
+ });
160
171
  /** cozy-viewer.js calls this as an item goes into the popup. A popup already open keeps its chat: the work on the left changes, the chat stays. */
161
172
  function show(pop) {
162
173
  if (S.open) { retarget(pop); return; }
@@ -173,6 +184,7 @@ function show(pop) {
173
184
  S.all.hidden = true; closeMenu();
174
185
  const p = pop && typeof pop === 'object' ? pop : {};
175
186
  S.about = p.session ? (p.session.ini ? { id: p.session.ini, kind: 'initiative', title: p.session.work, ws: p.session.ws } : null) : p.id ? { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws, ...(p.path ? { path: p.path } : {}) } : null;
187
+ S.base = S.about; S.views = new Map(); S.bind = S.base;
176
188
  width(parseInt(store.get('cz-pop-chat') || '', 10) || DEF_CHAT);
177
189
  // the chat shows when it was asked for (the rail's chat icon, a session row, search's Ask PMOS), else when it was recently open on this item
178
190
  S.userSet = false;
@@ -187,8 +199,12 @@ function show(pop) {
187
199
  * item's scope ("In: <title>"), so it never keeps the previous item's conversation beside it. The same item, or none, changes nothing. */
188
200
  function retarget(pop) {
189
201
  const p = pop && typeof pop === 'object' ? pop : null;
190
- if (!p || !p.id || p.keep || (S.about && S.about.id === p.id)) return;
202
+ if (!p || !p.id || p.keep || (S.base && S.base.id === p.id)) {
203
+ if (p && p.id && S.base && S.base.id === p.id) { S.bind = S.base; aboutItem(null); } // the popup's own item again: its own chat
204
+ return;
205
+ }
191
206
  S.about = { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws, ...(p.path ? { path: p.path } : {}) };
207
+ S.base = S.about; S.bind = S.base;
192
208
  S.userSet = false;
193
209
  chatOn(!!(p.target || p.chat || recentOn(S.about)));
194
210
  attach(p.target || aboutTarget(S.about), null);
@@ -225,8 +241,31 @@ function aboutTarget(a) {
225
241
  async function resolve(t) {
226
242
  if (!t || !t.__about) return t;
227
243
  const M = await pageChat(), a = t.__about;
244
+ if (a.item) { const x = M.itemTarget(a, a.ws); if (x) return x; } // a task, a milestone: its own conversation, with the item read in
228
245
  return M.keyOf(a) ? M.popTarget(a, a.ws) : M.cosTarget(a.title || '', a.ws);
229
246
  }
247
+ /** An item inside the popup's work (a task or a milestone over the initiative, bug 2026-11-24): { id, kind, title, ws?, parent?, subject?,
248
+ * say?, facts? }. null without an id and a title. */
249
+ function itemAbout(a) {
250
+ if (!a || !a.id || !a.title) return null;
251
+ return { id: String(a.id), kind: String(a.kind || 'item').toLowerCase(), title: String(a.title), ws: a.ws || (S.base && S.base.ws) || undefined, item: true,
252
+ parent: a.parent || '', subject: a.subject || '', say: a.say || '', facts: Array.isArray(a.facts) ? a.facts : [] };
253
+ }
254
+ const sameAbout = (a, b) => (!a && !b) || (!!a && !!b && a.id === b.id && (a.kind || '') === (b.kind || '') && !!a.item === !!b.item);
255
+ /** The chat moves to an item inside the popup's work (a task, a milestone; Wawan 2026-11-24: "When open chat from a task page, chat session
256
+ * should be about the task"), or back to the popup's own item with null (or the base itself). The work on the left stays; whether the chat
257
+ * shows does not change. The item's sessions and the initiative's stay in the session chooser. Returns false when the popup is not open. */
258
+ export function aboutItem(a) {
259
+ if (!S.open || RO) return false;
260
+ const next = !a || a === S.base ? S.base : a.item ? a : itemAbout(a);
261
+ if (!next && a) return false;
262
+ if (sameAbout(next, S.about)) return true;
263
+ S.about = next;
264
+ if (next) attach(aboutTarget(next), null);
265
+ else pageChat().then((M) => { if (S.open && !S.about) attach(M.cosTarget(''), null); }); // opened on the list of sessions: the chat over everything
266
+ drawDot(); read();
267
+ return true;
268
+ }
230
269
  async function attach(want, row) {
231
270
  const my = ++S.seq;
232
271
  const P = await provider();
@@ -299,6 +338,7 @@ function rowHtml(r, sel) {
299
338
  + `<em class="${r.state}">${esc(r.word)}</em>`
300
339
  + (r.live ? `<button type="button" class="cz-pop-x" data-end="${esc(r.id)}" aria-label="${esc('End ' + r.name)}" title="End this session"><i></i></button>` : '<span></span>') + '</div>';
301
340
  }
341
+ const kindWord = (k) => { const s = String(k || '').replace(/[-_]+/g, ' ').trim(); return s ? s[0].toUpperCase() + s.slice(1) : 'About'; };
302
342
  function drawTitle() {
303
343
  if (!S.title || !S.open) return;
304
344
  if (S.view === 'all') {
@@ -316,7 +356,8 @@ function drawTitle() {
316
356
  }
317
357
  delete S.title.dataset.ren;
318
358
  // one quiet context line under the session (round 3 point 19a, the phone chat's line): what the chat is about, said once
319
- const a = S.about, cx = a && a.title ? (a.kind === 'initiative' ? 'Initiative' : a.kind === 'program' ? 'Program' : 'About') + ' · ' + a.title : '';
359
+ const a = S.about, cx = a && a.item ? kindWord(a.kind) + (a.parent ? ' in ' + a.parent : ' · ' + a.title)
360
+ : a && a.title ? (a.kind === 'initiative' ? 'Initiative' : a.kind === 'program' ? 'Program' : 'About') + ' · ' + a.title : '';
320
361
  S.title.innerHTML = `<button type="button" class="cz-pop-t" data-pop="pick" aria-haspopup="menu" aria-expanded="${on}" title="Change session" aria-label="${esc(name + '. Change session')}"><span>${esc(name)}</span>${svg(I.down, 16)}</button>`
321
362
  + (cx ? `<small class="cz-pop-cx" title="${esc(cx)}">${esc(cx)}</small>` : '');
322
363
  }
@@ -501,4 +542,4 @@ export async function openCos(t) {
501
542
  VW.open(sessionsItem({ target: t }));
502
543
  return true;
503
544
  }
504
- if (typeof window !== 'undefined') { window.czOpenChat = openChat; window.czPopup = { openChat, openCos, openWork, chatTo, close, isOpen, useChat, setTitles, setOpener }; }
545
+ if (typeof window !== 'undefined') { window.czOpenChat = openChat; window.czPopup = { openChat, openCos, openWork, chatTo, close, isOpen, useChat, setTitles, setOpener, aboutItem }; }
@@ -7,7 +7,8 @@
7
7
  * pressed, becomes a field; Enter or leaving it saves), onClose?(uid) (the host
8
8
  * lights the row), openIni?(id),
9
9
  * full?: true → the full popup over the work side of the popup (work-ds-quick-edit, WorkStatesDS 4 and 6): ← and the
10
- * path (path?: [crumb]) go back to the initiative, chat?() shows the popup's chat, × closes the task and the popup
10
+ * path (path?: [crumb]) go back to the initiative, chat?(about) shows the chat about the task (with the one popup
11
+ * open, its chat already moved to the task as the task opened: window.czPopup.aboutItem), × closes the task and the popup
11
12
  * (closeAll?()); head?(t) → html under the title (a milestone's date, done test and suggestion), its presses go to
12
13
  * headPress?(button, { refresh, close }) }
13
14
  * closeTask() closes it, as ✕, Esc or a press outside do. Esc closes only the small popup.
@@ -16,7 +17,7 @@
16
17
  * where it sits, what PMOS changed) whose status pick asks when it really happened (pm/cozy-status-when.js, point 18); ⋯ with Make it a
17
18
  * milestone, Archive and Delete (Undo). No chat inside: one level only, a second task replaces the content. On a phone it is a sheet from the bottom.
18
19
  * Every write is the PM's press, on the board's own routes. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
- import { taskOf, mountCard, boardSaver, cardStyle, historyFor } from './task-card.js';
20
+ import { taskOf, mountCard, boardSaver, cardStyle, historyFor, chatAbout } from './task-card.js';
20
21
  import * as SWN from './cozy-status-when.js';
21
22
  import { linkPath, copyLink } from './short-link.js'; // Copy link in ⋯ (bet A428)
22
23
  import * as VD from './vw-ds.js'; // viewer-ds-task (board ViewerDS): the full popup's Where it stands, Linked and Activity blocks
@@ -45,10 +46,11 @@ async function rowOf(uid, ctx) {
45
46
  return it ? { ...(own || {}), ...it } : own || null;
46
47
  }
47
48
 
48
- export function closeTask() {
49
+ export function closeTask(o = {}) {
49
50
  if (!S) return;
50
51
  const S0 = S, { el, scrim, uid, ctx, prevFocus } = S;
51
52
  S = null;
53
+ if (S0.chatOn && !o.all) popChat(null); // the popup stays: its chat goes back to the initiative's
52
54
  document.removeEventListener('keydown', onKey, true);
53
55
  if (S0.ro) S0.ro.disconnect(); if (S0.offPop) document.removeEventListener('click', S0.offPop, true); window.removeEventListener('resize', place);
54
56
  el.remove(); scrim.remove();
@@ -66,6 +68,13 @@ function place() {
66
68
  Object.assign(S.el.style, { left: r.left + 'px', top: r.top + 'px', width: r.width + 'px', height: r.height + 'px' });
67
69
  }
68
70
 
71
+ /** The one popup's chat moves to the task (or back, with null). false when no popup is open (the task is on its own: its chat press opens one). */
72
+ function popChat(a) {
73
+ const P = typeof window !== 'undefined' ? window.czPopup : null;
74
+ if (!P || typeof P.aboutItem !== 'function' || !P.isOpen || !P.isOpen()) return false;
75
+ return P.aboutItem(a);
76
+ }
77
+
69
78
  function onKey(e) {
70
79
  if (!S) return;
71
80
  if (e.key === 'Escape') {
@@ -97,7 +106,7 @@ export async function openTask(uid, ctx = {}) {
97
106
  if (L && typeof ResizeObserver !== 'undefined') { S.ro = new ResizeObserver(place); S.ro.observe(L); }
98
107
  window.addEventListener('resize', place); place();
99
108
  // the popup behind closing (its scrim or its own ×) takes the full popup with it
100
- S.offPop = (e) => { if (e.target.closest && e.target.closest('.cz-pop [data-pop="close"]')) closeTask(); };
109
+ S.offPop = (e) => { if (e.target.closest && e.target.closest('.cz-pop [data-pop="close"]')) closeTask({ all: true }); };
101
110
  document.addEventListener('click', S.offPop, true);
102
111
  }
103
112
  document.addEventListener('keydown', onKey, true);
@@ -121,6 +130,8 @@ async function show(uid) {
121
130
  if (!raw) { S.el.innerHTML = `<div class="ctp-h">${ib('data-ctp-close', 'Close', P.x)}</div><p class="ctp-none">This task could not be read. It may have been removed.</p>`; return; }
122
131
  const t = taskOf(raw, { iniTitle: ctx.iniTitle ? ctx.iniTitle(raw.ini || ctx.ini) : '', board: ctx.board, ini: ctx.ini });
123
132
  S.raw = raw; S.t = t; S.nextDay = null;
133
+ // the full popup over the one popup: the chat beside it is about this task now, not its initiative (bug 2026-11-24); ← gives it back
134
+ if (ctx.full) S.chatOn = popChat(chatAbout(t, raw)) || S.chatOn;
124
135
  const L = ctx.list ? ctx.list() : [], i = L.indexOf(uid);
125
136
  const kind = `<button type="button" class="ctp-kind" data-ctp-kind aria-label="${esc(t.milestone ? 'Milestone. Make it a task' : 'Task. Make it a milestone')}"${t.jira ? ' disabled' : ''}>${SVG(t.milestone ? P.dia : P.box)}<span>${t.milestone ? 'Milestone' : 'Task'}</span></button>`;
126
137
  const title = !t.jira && ctx.rename ? `<button type="button" class="ctp-t" data-ctp-rename aria-label="${esc('Rename ' + t.title)}">${esc(t.title)}</button>` : `<span class="ctp-t">${esc(t.title)}</span>`;
@@ -265,8 +276,8 @@ async function press(e) {
265
276
  if ('ctpDundo' in d) { saveDesc('', { word: 'PMOS\'s description taken back' }); return; }
266
277
  if (b.closest('.ctp-hx')) { if (ctx.headPress) { const s0 = S; await ctx.headPress(b, { refresh: () => { if (S === s0) show(s0.uid); }, close: closeTask }); } return; }
267
278
  if ('ctpClose' in d) { closeTask(); return; }
268
- if ('ctpChat' in d) { if (ctx.chat) ctx.chat(); return; }
269
- if ('ctpX' in d) { const all = ctx.closeAll; closeTask(); if (all) all(); return; }
279
+ if ('ctpChat' in d) { if (t) S.chatOn = popChat(chatAbout(t, S.raw)) || S.chatOn; if (ctx.chat) ctx.chat(t ? chatAbout(t, S.raw) : null); return; }
280
+ if ('ctpX' in d) { const all = ctx.closeAll; closeTask({ all: !!all }); if (all) all(); return; }
270
281
  if (d.ctpStep) { const L = ctx.list ? ctx.list() : [], j = L.indexOf(S.uid) + Number(d.ctpStep); if (j >= 0 && j < L.length) show(L[j]); return; }
271
282
  if ('ctpRename' in d && t && ctx.rename) { renameField(b); return; }
272
283
  if ('ctpKind' in d && t) { kindOf(!t.milestone); return; }
@@ -553,7 +553,9 @@ function place(el) {
553
553
  function emit(x) {
554
554
  x = x || V;
555
555
  const d = { open: !!V.cur, id: V.cur ? V.cur.id : null, kind: V.cur ? V.cur.kind : null, title: V.cur ? V.cur.title : null, via: V.cur ? '' : x.via || '', // via 'history': the browser's Back closed it
556
- panel: 'v' + x.i, shut: !shown(x), pop: !!x.pop };
556
+ panel: 'v' + x.i, shut: !shown(x), pop: !!x.pop,
557
+ // what the popup's chat should be about for this item (open({ chatAbout }): a task, a milestone), and whether the chat itself opened it
558
+ chatAbout: V.cur && V.cur.args && V.cur.args.chatAbout ? V.cur.args.chatAbout : null, viaChat: !!(V.cur && V.cur.viaChat) };
557
559
  if (!x.pop) document.body.classList.toggle('cz-vw-on', side().some(shown)); // the popup covers the page: the page does not make room for it
558
560
  G.subs.forEach((f) => { try { f(d); } catch { /* a listener's fault stays its own */ } });
559
561
  document.dispatchEvent(new CustomEvent('cz-viewer', { detail: d }));
@@ -647,6 +649,7 @@ export function open(it) {
647
649
  use(x);
648
650
  // the chat opened it by itself (behind()): the item shown stays behind it, so ← comes back to it with its place (chat-open-keeps-back)
649
651
  const bn = !o._inst ? G.behindNext : null; if (bn) G.behindNext = null;
652
+ const pr = H.press && Date.now() - H.press.t < 10000 ? H.press : null, viaChat = !!bn || !!(pr && pr.chat); // the chat opened it (an answer, a link in it)
650
653
  if (keepsBehind(bn, V.cur, o)) o = { ...o, back: true };
651
654
  else if (bn && V.cur && o.id != null && V.cur.id !== String(o.id)) { try { console.warn(LOG_BEHIND, 'item not kept behind', { id: o.id }); } catch { /* no console */ } }
652
655
  // an item with unsaved changes asks first; the open goes on when it says so (and keeps a drill-in asked for before it)
@@ -674,7 +677,7 @@ export function open(it) {
674
677
  V.drill = false; H.adopt = false;
675
678
  const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
676
679
  leave();
677
- V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, wrap: !!o.wrap, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, from: o.from || '', kindChip: o.kindChip || '', args: o };
680
+ V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, wrap: !!o.wrap, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, from: o.from || '', kindChip: o.kindChip || '', viaChat: o._nav ? false : viaChat, args: o };
678
681
  el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
679
682
  redraw();
680
683
  el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
@@ -822,7 +825,7 @@ function pressAt(e) {
822
825
  const t = e.target; let inst = t && t.nodeType === 1 && !t.closest('.cz-vw-trail') ? ALL.find((x) => x.el && x.el.contains(t)) || null : null;
823
826
  // a press in the popup's chat (a file or a link it names) opens on the popup's left, behind the work shown there (board 22)
824
827
  if (!inst && t && t.nodeType === 1 && t.closest('.cz-pop')) inst = ALL.find((x) => x.pop && shown(x)) || null;
825
- H.press = { t: Date.now(), inst };
828
+ H.press = { t: Date.now(), inst, chat: !!(t && t.nodeType === 1 && t.closest('.cz-pop-r')) };
826
829
  }
827
830
  /* the trail list: hover ← or → for a moment (a mouse), or hold it (a touch). It names every step, newest first, and the page it started on. */
828
831
  let HOLD = { t: 0, fired: 0 };
@@ -6,7 +6,7 @@
6
6
  * status, the dates, the owner and the notes, and its move icon the section, the group or the initiative. Every write is the board's own route and is the PM's press; each says so
7
7
  * in a toast with Undo, and a refusal shows the route's reason and changes nothing. Talk it through in chat is under ⋯ (the chat is beside
8
8
  * the Viewer on Home). The PM's own items (a note, a mention made into a task) open in My work's item view (home-work.js). */
9
- import { taskOf, checkOf, mountCard, boardSaver, cardStyle, placeOf, historyFor, deleteEntry } from './task-card.js';
9
+ import { taskOf, checkOf, mountCard, boardSaver, cardStyle, placeOf, historyFor, deleteEntry, chatAbout } from './task-card.js';
10
10
 
11
11
  /** h: { VW, pmPost, toast, toastUndo?, now, ws, board, iniTitle(id), openIni(id), askInChat(task), onChange(), rename?(task),
12
12
  * owners?() → [names], inis?() → [{ id, title }] } */
@@ -28,6 +28,7 @@ export function openTask(task, h) {
28
28
  const del = deleteEntry({ ws, board, t, post: (p, b) => h.pmPost(p, b), toast, done: () => { if (h.VW.close) h.VW.close(); if (h.onChange) h.onChange(); } });
29
29
  const body = h.VW.open({
30
30
  id, kind: 'Task', title: t.title, icon: 'task', check: checkOf(t),
31
+ chatAbout: chatAbout(t, raw), // in the one popup, the chat beside it is about this task (cozy-popup.js, bug 2026-11-24)
31
32
  // a short link (bet A428): ⋯ Copy link gives /i/t/<uid> (or /i/m/ for a milestone), which opens this task on any device
32
33
  link: { kind: t.milestone ? 'milestone' : 'task', id: raw.uid, ws: ws || '' },
33
34
  rename: t.jira ? null : h.rename ? h.rename(raw) : null,
@@ -114,6 +114,20 @@ export function popTarget(it, ws) {
114
114
  return { ...T, popAbout: true, scope: { text: 'In: ' + T.title, icon: PIN, drop: true }, placeholder: 'Ask or tell PMOS', empty: COS_EMPTY };
115
115
  }
116
116
  const COS_EMPTY = 'Ask anything about your work. I read it with PMOS and say where each answer came from.';
117
+ /** The chat about one item that has no row of its own in a server model: a task, a milestone (bug 2026-11-24, Wawan: "When open chat from a
118
+ * task page, chat session should be about the task"). Its own conversation, pop:<kind>:<id>, so it never resumes the initiative's session;
119
+ * its first message carries what the item shows (lib/briefing-premium-agent.js popRow: title, subject, say, facts), so PMOS reads the task in.
120
+ * it: { id, kind, title, subject?, say?, facts?: [[label, value]] }. null without an id or a title. */
121
+ export function itemTarget(it, ws) {
122
+ const title = String((it && it.title) || '').replace(/\s+/g, ' ').trim().slice(0, 80);
123
+ const kind = String((it && it.kind) || 'item').trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'item';
124
+ const id = String((it && it.id) || '').replace(/[^A-Za-z0-9._:-]+/g, '-').replace(/^[^A-Za-z0-9]+/, '');
125
+ if (!id || !title) return null;
126
+ const key = ('pop:' + kind + ':' + id).slice(0, 104);
127
+ const facts = (Array.isArray(it.facts) ? it.facts : []).filter((f) => Array.isArray(f) && f[1] != null && String(f[1]).trim()).slice(0, 12).map(([a, b]) => [String(a), String(b)]);
128
+ return { key, ws: ws || undefined, title, about: title, role: CLAUDE, rich: false, popAbout: true, scope: { text: 'In: ' + title, icon: PIN, drop: true },
129
+ context: { title, subject: String(it.subject || ''), say: String(it.say || ''), facts }, placeholder: 'Ask or tell PMOS', empty: COS_EMPTY };
130
+ }
117
131
  export function cosTarget(here, ws) {
118
132
  const h = String(here || '').replace(/\s+/g, ' ').trim().slice(0, 80);
119
133
  return { key: 'chat:main', ws: ws || undefined, title: 'Ask PMOS', about: 'Ask PMOS', role: CLAUDE, rich: false, cos: true, here: h,
@@ -89,6 +89,7 @@ function czVw(it) {
89
89
  let el = null; czLast = it;
90
90
  czOpen({ id: 'vw:' + it.id, kind: it.kind || it.title || 'Item', title: it.name || it.title || 'Item', icon: CZ_ICON[it.icon] || 'doc', url: it.url || '', rename: it.rename || null,
91
91
  check: it.check || null, onPress: it.onPress, more: it.more, // a task's check box and its ⋯ (canvas XetX1Rest)
92
+ chatAbout: it.chatAbout || undefined, // the popup's chat moves to the task (cozy-popup.js, bug 2026-11-24)
92
93
  render: (body) => {
93
94
  el = document.createElement('div'); el.className = 'obody vw'; el.dataset.vw = it.id; el.setAttribute('role', 'region'); body.append(el);
94
95
  if (it.render) it.render(el); else el.innerHTML = it.html || '';
@@ -9,7 +9,7 @@ import { vwOpen, vwStyle, vwClose } from './premium-viewer.js';
9
9
  import { esc, iniId, taskId, stateOf, readingHtml, errorHtml, iniHtml, taskHtml, findTask, cardTask } from './premium-vw-item-model.js';
10
10
  import { mountCard, boardSaver, checkOf, cardStyle, toastUndo, placeOf, deleteEntry, historyFor } from './task-card.js';
11
11
  import { pmPost } from './http.js';
12
- import { setCheck, retitle } from './cozy-viewer.js';
12
+ import { setCheck, retitle, popOpen as VW_POP } from './cozy-viewer.js';
13
13
 
14
14
  const TRIES = 20, WAIT = 1500, KEEP = 30000;
15
15
  const cache = new Map(); // query → { at, p }: two tabs of one initiative read once
@@ -55,7 +55,12 @@ async function openFull(o) {
55
55
  rename: o.rename && typeof o.rename.save === 'function' ? (raw, title) => o.rename.save(title, {}) : null,
56
56
  onChange: () => cache.clear(),
57
57
  openIni: (id) => openWorkItem({ kind: 'initiative', id, title: id === o.ini && m ? m.title : '', ws: o.ws, board: o.board }),
58
- chat: () => import('./page-chat.js').then((PC) => PC.openChat({ kind: 'task', id: uid, title: (row && row.title) || o.title || 'this task' }, { ws })),
58
+ // the chat about the task itself (bug 2026-11-24), read in from what the popup shows; with the one popup open, cozy-task-pop.js moved it already
59
+ chat: (about) => import('./page-chat.js').then((PC) => {
60
+ if (VW_POP()) { const k = document.querySelector('.cz-pop [data-pop="ask"]'); if (k) k.click(); return true; }
61
+ const t = PC.itemTarget(about || { kind: 'task', id: uid, title: (row && row.title) || o.title || 'this task' }, ws);
62
+ return t ? PC.openTarget(t, { title: t.title }) : false;
63
+ }),
59
64
  });
60
65
  return true;
61
66
  }
@@ -77,6 +82,8 @@ export function openWorkItem(o) {
77
82
  id: vid,
78
83
  title: o.title || (isTask ? 'Task' : 'Initiative'),
79
84
  icon: isTask ? 'tk' : 'list',
85
+ // a task in the one popup: the chat beside it is about the task, read in (cozy-popup.js, bug 2026-11-24)
86
+ chatAbout: isTask && o.title ? { id: String(o.key || '').replace(/^[a-z]+:/, ''), kind: 'task', title: o.title, ws: ctx.ws || undefined, facts: [['Initiative', ctx.id], ['Task key', o.key || '']] } : undefined,
80
87
  rename: o.rename || null, // the Viewer's rename option, from the page that knows how to write it (rename-press.js)
81
88
  check: editable ? { state: 'todo', label: 'Mark done' } : null, // the quick Done (canvas XetX1Rest); it follows the task once read
82
89
  onPress: (act) => { if (act === 'check' && card && cardT && !cardT.jira) card.setStatus(cardT.status === 'Done' ? 'To do' : 'Done'); },
@@ -69,6 +69,14 @@ export function taskOf(row, extra = {}) {
69
69
  };
70
70
  }
71
71
 
72
+ /** What the chat about this task reads in (page-chat.js itemTarget, the server's popRow): the same facts the popup shows. */
73
+ export function chatAbout(t, raw = {}) {
74
+ const r = raw || {};
75
+ return { id: t.uid || String(t.key || '').replace(/^task:/, ''), kind: t.milestone ? 'milestone' : 'task', title: t.title, parent: t.iniTitle || '',
76
+ subject: (t.milestone ? 'Milestone' : 'Task') + (t.iniTitle ? ' in the initiative ' + t.iniTitle : '') + (t.ini ? ' (' + t.ini + ')' : '') + '. Read it with pmos before you answer.',
77
+ facts: [['Status', t.status], ['Start', t.start], ['Due', t.due], ['Owner', t.owner || r.owner || ''], ['Initiative', t.ini], ['Board', t.board], ['Task id', t.uid],
78
+ ['Notes', String(t.notes || '').slice(0, 240)]] };
79
+ }
72
80
  /** Where a task sits: { section, wbs }. The initiative view's model (ini-view-model.js, batch 6 item 1) owns the rules: sectionOf(task, stages)
73
81
  * resolves the PM's placement, then the stage that made the task, then its plan-tree stage; wbsOf(title) reads the breakdown code from the
74
82
  * title ("10.5 TC to review" sits under 10). Before that model is on the page, the same rules in their simplest form: the row's section by
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "The chat beside a task is about the task (task-chat-scope, done test C1-C5): page-chat.js itemTarget, task-card.js chatAbout and the server's popRow, plus a read of the popup's wiring. No browser.",
3
+ "modules": [
4
+ "task-chat-scope.test.js"
5
+ ],
6
+ "seconds": {
7
+ "task-chat-scope.test.js": 1
8
+ }
9
+ }