create-pmos 0.380.0 → 0.382.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/package.json +30 -35
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-calendar-test.js +1 -1
  7. package/workspace/briefing-premium-initiative-test.js +2 -2
  8. package/workspace/briefing-premium-test.js +1 -1
  9. package/workspace/changelog.json +29 -0
  10. package/workspace/guide/briefing-premium.md +6 -1
  11. package/workspace/lib/briefing-premium-agent.js +19 -9
  12. package/workspace/lib/routes-briefing-premium.js +1 -1
  13. package/workspace/package-lock.json +2 -2
  14. package/workspace/package.json +1 -1
  15. package/workspace/premium-viewer-download-test.js +179 -0
  16. package/workspace/premium-work-depth-test.js +1 -1
  17. package/workspace/public/pm/chat-md.js +2 -10
  18. package/workspace/public/pm/md-table.js +53 -0
  19. package/workspace/public/pm/premium-acts.js +3 -4
  20. package/workspace/public/pm/premium-doc-edit.js +5 -7
  21. package/workspace/public/pm/premium-initiative.js +6 -8
  22. package/workspace/public/pm/premium-insights.js +5 -7
  23. package/workspace/public/pm/premium-meeting.js +1 -2
  24. package/workspace/public/pm/premium-report-read.js +4 -3
  25. package/workspace/public/pm/premium-shell.js +16 -7
  26. package/workspace/public/pm/premium-vw-doc-model.js +3 -9
  27. package/workspace/public/pm/premium-vw-doc.css +19 -0
  28. package/workspace/public/pm/premium-vw-doc.js +1 -1
  29. package/workspace/public/pm/premium-vw-file.js +83 -6
  30. package/workspace/public/pm/premium-work.js +4 -4
  31. package/workspace/public/pm/premium.css +10 -2
  32. package/workspace/public/pm/premium.js +7 -7
  33. package/workspace/server.js +17 -0
  34. package/workspace/test-files.json +2 -0
  35. package/workspace/test-lists/premium-viewer-share.json +9 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.380.0",
3
+ "version": "0.382.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": {
@@ -32,6 +32,35 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.382.0",
37
+ "at": "2026-10-21T12:58:18.296Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 991,
42
+ "t": "A chat in every premium popup",
43
+ "s": "A chat in every premium popup"
44
+ },
45
+ {
46
+ "n": 992,
47
+ "t": "Download a file from the viewer (premium-viewer-share slice 1)",
48
+ "s": "Download a file from the viewer (premium-viewer-share slice 1)"
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "v": "0.381.0",
54
+ "at": "2026-10-21T12:15:37.889Z",
55
+ "f": 2,
56
+ "prs": [
57
+ {
58
+ "n": 990,
59
+ "t": "Markdown tables draw as tables in the viewer, the Read tab and chat",
60
+ "s": "Markdown tables draw as tables in the viewer, the Read tab and chat"
61
+ }
62
+ ]
63
+ },
35
64
  {
36
65
  "v": "0.380.0",
37
66
  "at": "2026-10-21T09:18:41.886Z",
@@ -287,40 +316,6 @@
287
316
  "s": "The meeting detail is one scroll with a short head on a phone"
288
317
  }
289
318
  ]
290
- },
291
- {
292
- "v": "0.362.0",
293
- "at": "2026-10-21T00:23:03.151Z",
294
- "f": 2,
295
- "prs": [
296
- {
297
- "n": 961,
298
- "t": "Settings lists every connector of your Claude session",
299
- "s": "Settings › Connectors lists every connector your Claude session has, and says that your sessions can use all of them while a switch only chooses what PMOS reads on its own."
300
- },
301
- {
302
- "n": 963,
303
- "t": "The premium Board release card lists the board's past releases",
304
- "s": "The premium Board release card lists the board's past releases"
305
- },
306
- {
307
- "n": 964,
308
- "t": "Premium Sprint tab folds past sprints, shows the goal from the tickets, opens every ticket",
309
- "s": "Premium Sprint tab folds past sprints, shows the goal from the tickets, opens every ticket"
310
- }
311
- ]
312
- },
313
- {
314
- "v": "0.361.0",
315
- "at": "2026-10-21T00:14:19.012Z",
316
- "f": 2,
317
- "prs": [
318
- {
319
- "n": 960,
320
- "t": "The morning brief runs on fresh sources; Sources says whether background work runs",
321
- "s": "PMOS reads the pane after it presses Enter."
322
- }
323
- ]
324
319
  }
325
320
  ]
326
321
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@61c8ea33
1
+ kernel-source: pmos@55f5fd88
2
2
  assembled: 2026-10-21
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-21T09:18:37Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T12:58:15Z"}
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-21T09:18:37Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T12:58:15Z"}
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-21T09:18:37Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-21T12:58:15Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -143,7 +143,7 @@ const MOCKUP = fs.readFileSync(path.join(__dirname, '..', 'prototype', 'premium-
143
143
  ok('C6 with no note the dialog says so', dlg && /No notes for this meeting\./.test(dlg.text));
144
144
  ok('C7 the material is listed with the scope it was linked at', dlg && /Capacity sheet/.test(dlg.text) && /every meeting of this series/.test(dlg.text) && /Roadmap/.test(dlg.text) && /for this meeting/.test(dlg.text));
145
145
  ok('C8 with no recording the dialog draws no Replay', dlg && !/Replay/.test(dlg.text) && !/recording/i.test(dlg.text));
146
- ok('C4 the conversation is not offered on a week row', dlg && dlg.ask === true);
146
+ ok('C4 a week row has its own conversation too (premium-popup-context P1)', dlg && dlg.ask === false);
147
147
  ok('C5 the dialog says what it is about, and that the calendar is never written', dlg && /It is about Board: IDPF/.test(dlg.text) && /calendar itself is never written/.test(dlg.text));
148
148
  await p.keyboard.press('Escape');
149
149
  const closed = await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
@@ -126,7 +126,7 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
126
126
  await p.click('#tkTabs [data-v="list"]');
127
127
  await p.locator('#cIniTk .tkq').first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
128
128
  const td = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, grid: [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'), ask: document.querySelector('#askF').hidden, seg: !!document.querySelector('#oMain .tkst') }));
129
- ok('I6 a Jira task opens its record as a grid, read-only: no status control and no question box', td.title === 'Sandbox key step' && /Reference\|ONB-12\|Source\|Jira \(read-only\)/.test(td.grid) && td.ask === true && td.seg === false, JSON.stringify(td));
129
+ ok('I6 a Jira task opens its record as a grid, read-only: no status control, and its own conversation (premium-popup-context P1)', td.title === 'Sandbox key step' && /Reference\|ONB-12\|Source\|Jira \(read-only\)/.test(td.grid) && td.ask === false && td.seg === false, JSON.stringify(td));
130
130
  await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
131
131
  /* a PMOS task: its status can be changed */
132
132
  A.set({ status: 200, body: { ok: true, item: {} } });
@@ -223,7 +223,7 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
223
223
  ok('I8 every document row opens, including one with no file', await p.evaluate(() => [...document.querySelectorAll('#dmList .dmr')].every((r) => !!r.querySelector('.dmo[data-doc]'))));
224
224
  await p.click('#dmList .dmo[data-doc="problem"]'); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(400);
225
225
  { const ab = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, body: document.querySelector('#oMain').textContent, draft: !!document.querySelector('#abDraft'), ask: document.querySelector('#askF').hidden }));
226
- ok('I8 a document with no file says what it is for, who writes it and offers Draft it', ab.title === 'Problem statement' && /Who writes it/.test(ab.body) && ab.draft && ab.ask === true, JSON.stringify(ab)); }
226
+ ok('I8 a document with no file says what it is for, who writes it and offers Draft it', ab.title === 'Problem statement' && /Who writes it/.test(ab.body) && ab.draft && ab.ask === false, JSON.stringify(ab)); }
227
227
  const nD = A.posts.length; A.set({ status: 200, body: { ok: true, run: 'r1' } }); await p.click('#abDraft');
228
228
  ok('I8 Draft it in that popup posts the draft route and closes the popup', await until(() => A.posts.length > nD && A.posts[A.posts.length - 1].path === '/api/core-docs/draft' && A.posts[A.posts.length - 1].body.key === 'problem') && await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))));
229
229
  ok('0 no page error', A.errors.length === 0, A.errors.join(' | '));
@@ -597,7 +597,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
597
597
  await cp.locator('#rank .rr .rhd').nth(dec).click();
598
598
  await until(() => cp.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
599
599
  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 || '' }));
600
- 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));
600
+ ok('C5 a decision opens the dialog with what its record says, its source link and its own conversation (premium-popup-context P1)', dd.title === 'Pick the launch market' && /Read from the console Briefing/.test(dd.body) && !dd.ask && /J-7/.test(dd.link), JSON.stringify(dd));
601
601
  await cp.keyboard.press('Escape');
602
602
  await cp.route('**/premium-work.html*', (r) => r.fulfill({ contentType: 'text/html', body: '<p>work</p>' }));
603
603
  const own = await cp.evaluate(() => [...document.querySelectorAll('#rank .rr')].findIndex((r) => /Send Priya the date/.test(r.textContent)));
@@ -1,4 +1,33 @@
1
1
  [
2
+ {
3
+ "v": "0.382.0",
4
+ "at": "2026-10-21T12:58:18.296Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 991,
9
+ "t": "A chat in every premium popup",
10
+ "s": "A chat in every premium popup"
11
+ },
12
+ {
13
+ "n": 992,
14
+ "t": "Download a file from the viewer (premium-viewer-share slice 1)",
15
+ "s": "Download a file from the viewer (premium-viewer-share slice 1)"
16
+ }
17
+ ]
18
+ },
19
+ {
20
+ "v": "0.381.0",
21
+ "at": "2026-10-21T12:15:37.889Z",
22
+ "f": 2,
23
+ "prs": [
24
+ {
25
+ "n": 990,
26
+ "t": "Markdown tables draw as tables in the viewer, the Read tab and chat",
27
+ "s": "Markdown tables draw as tables in the viewer, the Read tab and chat"
28
+ }
29
+ ]
30
+ },
2
31
  {
3
32
  "v": "0.380.0",
4
33
  "at": "2026-10-21T09:18:41.886Z",
@@ -183,7 +183,7 @@ Not built in premium: translation, Present and the slides stage, Ask PMOS quietl
183
183
  Under Today, the **Around you** card holds what the agents and the outside world have left for you. It has six rows. A row opens a dialog and states what it found in one line. The caption says how many rows wait on you, or "quiet". If a source cannot be read, its row says so and gives the reason. It never reads as empty.
184
184
 
185
185
  - **Agent proposals.** Every open draft of the Initiative Driver, for initiatives and for Work items, when the agent mode for that kind is Approve. Each draft is one card: what it is, its target, and the draft in two lines, with **Read more** for the why and the sources. Press a card to choose it. The bar at the bottom acts on the chosen card. **Keep** is the main press, and **Send back** and **Drop** sit next to it. The notes about undo and the agent mode are behind the ⓘ line. **Keep** records that you accept it and applies it (a problem statement, a stage move, a next step). **Send back** needs a note and starts a new run. **Drop** counts as a correction. None of the three can be undone. A decided proposal stays in the list and says what was recorded.
186
- - **Mentions.** The people who named you in Slack, Jira, Confluence or mail, from today's morning brief. The row names who waits on a reply. **Make it a task** adds one Work item. **Mark read** hides the mention, and **Mark unread** brings it back. **Open in Slack** (or Jira, Confluence, mail) opens the original in a new tab. Nothing here replies, reacts or posts. The Mentions dialog has no question box, because a mention has no agent thread.
186
+ - **Mentions.** The people who named you in Slack, Jira, Confluence or mail, from today's morning brief. The row names who waits on a reply. **Make it a task** adds one Work item. **Mark read** hides the mention, and **Mark unread** brings it back. **Open in Slack** (or Jira, Confluence, mail) opens the original in a new tab. Nothing here replies, reacts or posts. The Mentions dialog has its own chat, like every popup.
187
187
  - **Portfolio pulse.** How many initiatives are late or at risk, by the Calendar's own status: the promised date against the forecast, or the Jira read. It is read only and it is not a forecast of its own. **Open the initiative** goes to its page.
188
188
  - **Horizon scan.** When the scan last ran, when it runs next, its reports and their proposals. Each proposal says what **Approve** does before you press it. **Dismiss** asks for a reason and counts as a correction, and **Undo** takes a dismissal back. **Scan now** starts an agent that reads the public web and the repository, and says how many manual scans are left. The row on the card says it too, before you open the dialog. A scan that is switched off says so and the button stays off.
189
189
  - **Report found.** What the report finder found in your calendar, Slack and the subjects of mail you sent: each finding with its name, why, its evidence lines and how sure it is (Likely or Not sure). **Set up** creates the recurring report and drafts its first cycle on this machine. **Not a report** tells the finder not to raise it again. PMOS drafts only and nothing is sent. **Change first** and the finder settings stay in Insights and the console. A finder that is off says so.
@@ -224,6 +224,8 @@ Every markdown document opens as one page in a tab: a report, a PRD, a new docum
224
224
 
225
225
  A Confluence page or Google Doc opens as a tab too. From a document's **Copies**, press **Preview** on a copy. If the last check found the same text in both, the PMOS file is shown as the page, with **Same as PMOS** and the check time. If the copy changed, the tab says so and shows the PMOS version dimmed. **Use the … version** writes the copy's text into the PMOS file after five seconds; press **Undo** to stop it. From a meeting's **Material**, press the page icon on a Google Doc or Confluence link. PMOS holds only the address of such a page, so the tab says so. **Read it now** starts one session that reads the page with your connector and keeps the text in PMOS; it changes nothing in Google Docs or Confluence. The tab then shows the text with when it was read. Press **Read again** for later edits.
226
226
 
227
+ A table in any Markdown page (a document, a copy's text, a chat answer) shows as a table. This includes a table exported from Google Docs whose first row is empty and whose header is on the next row: that row becomes the header. Each column keeps its alignment, and cells keep their bold, code and links. A wide table keeps short cells on one line and scrolls sideways, and its first column stays in view.
228
+
227
229
  A decision opens with no option chosen, because no recommendation is on record. Its card shows the evidence as label and value rows, the options, and one **Why** field. One bar at the bottom holds a quiet **Later ▾** and the only main button, named after your choice (for example **Record: Extend the date**). Choose one and the draft entry on the right changes. Nothing is written. The main button, "Not yet" and "Return this run to the agent" are off in this version, and each says why.
228
230
 
229
231
  ## The conversation
@@ -411,6 +413,8 @@ A document opens in one sheet on both the Board and the initiative page. Its sta
411
413
 
412
414
  The conversation beside every premium dialog is a real Claude Code session. Anything you can do in a Claude Code chat, you can do here.
413
415
 
416
+ Every popup has this chat, including the ones that have no row of their own: a task, a document with no file, a set-up report, a measure, a meeting on another day, Sources, Settings, the Around-you rows and the forms (Add a task, Add a document, the board actions). Its conversation belongs to that one thing, so it is there again the next time you open it. Opening a popup starts nothing; the session starts when you send the first message, and Claude starts from what the popup shows: its title, its sub line and its facts. A draft report keeps its own **Say how it should look** box, and Insight Studio keeps its brief.
417
+
414
418
  - **Your first message** in a dialog starts one session for that row, the page or the initiative, in its repository. Claude gets the row as the page shows it: the title, what the page says, the facts and the files to start from. Then it gets your words.
415
419
  - **The message box** takes several lines. **Enter** sends; **Shift+Enter** starts a new line. The box grows as you type, up to about eight lines, and then scrolls. The send button stays at its foot, also with a phone keyboard open.
416
420
  - **Later messages** in the same dialog go to the same session. Write `/compact`, `/clear` or any other slash command, and Claude Code runs it.
@@ -419,6 +423,7 @@ The conversation beside every premium dialog is a real Claude Code session. Anyt
419
423
  - **The conversation** is Claude Code's own record, word for word. Claude's answers are formatted as Claude Code formats them: headings, bold, lists, code, tables, quotes and links (links open in a new tab). Your messages keep their line breaks, and a paste shows without the tags Claude Code wraps around it. A run of tool calls shows as one small grey line, for example "Used Read ×2, slack_read_thread". A connector tool shows its short name.
420
424
  - **While a session runs**, the panel reads it again every 2 seconds and changes only when there is something new. The messages already on screen stay still, so nothing blinks beside the viewer.
421
425
  - **A file Claude names** (a path such as `briefs/drafts/plan.md`, or a link to one) is underlined. Press it to read the file beside the conversation, as a tab in the viewer; on a phone, the Detail side shows it (on the Chat page, the viewer opens over the conversation). Markdown shows as a page, an HTML file shows as the page it draws (press **Source** for its code), and other text files show as code. An HTML page runs its own scripts, so its toggles and charts work, but it cannot reach PMOS or the internet: a web font falls back to the system font. It is read-only. While the tab is open it shows the newest version, so a file Claude is still writing stays current. A file outside the workspaces PMOS serves says "Not in a workspace" and is not read.
426
+ - **Download a file** with the download icon at the right of its name in the viewer. An HTML file saves as **HTML** (as it is) or **PDF**. A markdown file saves as **Markdown**, **Word .docx** or **PDF**. Other text files save at once as they are, with no menu. PDF opens your browser's print window: choose **Save as PDF** there. An HTML page prints with no access to PMOS or the internet, as in the viewer. Word holds the note's headings, paragraphs, lists and tables.
422
427
  - **What an answer worked with** shows as buttons under it: the files Claude wrote, changed or read, the Jira tickets and Slack channels it used, and the links it named. The first one is the main one: a file Claude wrote comes first, then what it named in its words, then what it only read. When an answer finishes while the chat is open, its main one opens in the viewer by itself, once; answers that were there when you opened the chat open nothing. On a phone a bar over the message box offers it instead (**View**), so the conversation stays in view. A Jira ticket shows what PMOS last read from Jira for a board or initiative it syncs, with **Open in Jira**; a ticket PMOS has not read says so. A Slack channel or message opens with **Open in Slack**, as PMOS keeps no copy of Slack messages.
423
428
  - **A link to a Google Doc or a Confluence page** opens beside the conversation too, as the viewer shows a copy: the text PMOS has read, or **Read it now**. **A Claude artifact link** opens a tab with **Open in Claude**: claude.ai does not let another site show an artifact inside it. Other links open in a new browser tab.
424
429
  - **The session** is also listed in **Sessions** and in the console, where you can open its terminal.
@@ -4,7 +4,7 @@
4
4
  * ask({ root, runtimeDir, key, text, model, spawnSession, wsId, now }) → { status, body } starts ONE headless, read-only run
5
5
  * threadOf(runtimeDir, key, now) → { turns: [{ id, q, state, a?, error?, at }], working }
6
6
  * promptFor(row, turns, question) → the prompt text. Written here: the page chooses none of it.
7
- * rowFor(model, key) → { title, subject, say, facts, files } | null the row as the server's own model has it
7
+ * rowFor(model, key, context) → { title, subject, say, facts, files } | null the row as the server's own model has it (a pop: key: the popup's own context)
8
8
  * settle(runtimeDir, a, done, now) → the answer or the reason it failed, appended to the thread file
9
9
  *
10
10
  * The run is the `ask` kind of lib/headless.js (origin `briefing-ask:<key>`): Read, Glob and Grep, nothing else, the PM's own login. It
@@ -17,7 +17,7 @@ const headless = require('./headless.js');
17
17
  const Goal = require('./goal-chat.js');
18
18
 
19
19
  const THREADS = 'briefing-premium-threads.jsonl';
20
- const KEY_RE = /^(decision|blocked|waited|src|ev|work|board|init|doc|ins|chat):[A-Za-z0-9][A-Za-z0-9._:-]{0,100}$/; // chat: the PM's own chat on the Chat page (premium-chat-page)
20
+ const KEY_RE = /^(decision|blocked|waited|src|ev|work|board|init|doc|ins|chat|pop):[A-Za-z0-9][A-Za-z0-9._:-]{0,100}$/; // chat: the PM's own chat on the Chat page (premium-chat-page); pop: a popup with no row of its own (premium-popup-context P1)
21
21
  const MAX_Q = 2000, MAX_A = 6000, MAX_QUESTIONS = 40, PROMPT_TURNS = 8;
22
22
  const fail = (status, error) => ({ status, body: { ok: false, error } });
23
23
  const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
@@ -48,8 +48,9 @@ function threadOf(runtimeDir, key, now = Date.now()) {
48
48
  }
49
49
 
50
50
  /** The row as the server's own model has it, plus the files an answer should start from. null when the key names no row on the page. */
51
- function rowFor(model, key) {
51
+ function rowFor(model, key, context) {
52
52
  if (/^chat:/.test(String(key || '')) && KEY_RE.test(key)) return { title: '', subject: '', say: '', facts: [], files: [] }; // the PM's own chat: no page row, no context
53
+ if (/^pop:/.test(String(key || '')) && KEY_RE.test(key)) return popRow(context); // premium-popup-context P1: the popup says what it shows, the same facts the PM sees
53
54
  if (!model || !KEY_RE.test(String(key || ''))) return null;
54
55
  if (/^(src|work):this-page$/.test(key)) { // the top bar's Chat: the whole page is the context, its summary and its first rows
55
56
  const rows = model.rows || (model.list && model.list.rows) || [];
@@ -83,6 +84,15 @@ function rowFor(model, key) {
83
84
  };
84
85
  }
85
86
 
87
+ /** A popup that has no row in a server model (a task, a document with no file, a report, a measure, a form): the context it shows, cut to size. null without a title. */
88
+ function popRow(c) {
89
+ if (!c || typeof c !== 'object' || typeof c.title !== 'string' || !c.title.trim()) return null;
90
+ const str = (v, n) => (typeof v === 'string' ? clip(v, n) : '');
91
+ const facts = (Array.isArray(c.facts) ? c.facts : []).filter((f) => Array.isArray(f) && f[1] != null && String(f[1]).trim()).slice(0, 12).map(([a, b]) => clip(String(a), 40) + ': ' + clip(String(b), 240));
92
+ const files = (Array.isArray(c.files) ? c.files : []).filter((f) => typeof f === 'string' && SAFE_PATH.test(f) && !f.includes('..')).slice(0, 4);
93
+ return { title: str(c.title, 160), subject: str(c.subject, 240), say: str(c.say, 600), facts, files };
94
+ }
95
+
86
96
  function promptFor(row, turns, question) {
87
97
  const prior = turns.filter((t) => t.state === 'answered').slice(-PROMPT_TURNS);
88
98
  return [
@@ -115,14 +125,14 @@ function settle(runtimeDir, a, { result, timedOut, stopped, note } = {}, now = n
115
125
  return end({ event: 'answered', text: text.slice(0, MAX_A) });
116
126
  }
117
127
 
118
- function ask({ runtimeDir, key, text, model, spawnSession, wsId, now = new Date() }) {
128
+ function ask({ runtimeDir, key, text, model, context, spawnSession, wsId, now = new Date() }) {
119
129
  if (!runtimeDir) return fail(409, 'this workspace has no state folder to keep the conversation in');
120
130
  if (!KEY_RE.test(String(key || ''))) return fail(400, 'key must name a row');
121
131
  const q = String(text == null ? '' : text).trim();
122
132
  if (!q) return fail(400, 'Write a question for the agent.');
123
133
  if (q.length > MAX_Q) return fail(400, 'The question is too long (' + MAX_Q + ' characters at most).');
124
- const row = rowFor(model, key);
125
- if (!row) return fail(404, model ? 'that row is not on the page' : 'the page has not read the repository yet');
134
+ const row = rowFor(model, key, context);
135
+ if (!row) return fail(404, /^pop:/.test(key) ? 'the popup did not say what it shows' : model ? 'that row is not on the page' : 'the page has not read the repository yet');
126
136
  if (typeof spawnSession !== 'function') return fail(409, 'this workspace cannot start sessions');
127
137
  const origin = 'briefing-ask:' + key;
128
138
  if (headless.kindFor({ agent: 'claude', origin }) !== 'ask') return fail(409, 'Background runs are switched off here (PMOS_HEADLESS=off), so this page cannot start the agent.');
@@ -165,7 +175,7 @@ function openingFor(row, text) {
165
175
  ].filter((l) => l !== '').join('\n');
166
176
  }
167
177
  /** sessions: { alive(id) → bool, spawn(spec) → session row, type(id, text) → bool (Enter after, `/` left as typed) }. */
168
- function chat({ runtimeDir, key, text, model, sessions, wsId, now = new Date() }) {
178
+ function chat({ runtimeDir, key, text, model, context, sessions, wsId, now = new Date() }) {
169
179
  if (!runtimeDir) return fail(409, 'this workspace has no state folder to keep the conversation in');
170
180
  if (!KEY_RE.test(String(key || ''))) return fail(400, 'key must name a row');
171
181
  const q = String(text == null ? '' : text).trim();
@@ -177,8 +187,8 @@ function chat({ runtimeDir, key, text, model, sessions, wsId, now = new Date() }
177
187
  // slice 4 (PRD L2): an ended chat resumes its own Claude Code conversation when the file for it is still there
178
188
  const prev = alive ? null : chatRecordOf(runtimeDir, key);
179
189
  const resume = !!(prev && prev.claude && typeof sessions.hasConversation === 'function' && sessions.hasConversation(prev.claude));
180
- const row = alive ? null : rowFor(model, key);
181
- if (!alive && !row && !resume) return fail(404, model ? 'that row is not on the page' : 'the page has not read the repository yet');
190
+ const row = alive ? null : rowFor(model, key, context);
191
+ if (!alive && !row && !resume) return fail(404, /^pop:/.test(key) ? 'the popup did not say what it shows' : model ? 'that row is not on the page' : 'the page has not read the repository yet');
182
192
  // slice 2 (PRD G2): `/goal <text>` becomes the PMOS grilling prompt, on record before it reaches the session
183
193
  let msg = q, goal = null;
184
194
  const cmd = Goal.parseCommand(q);
@@ -94,7 +94,7 @@ async function post(req, res, url, ctx) {
94
94
  // premium-chat-attach A5: the files a message names must be saved files of its conversation; one closing line names each for Claude
95
95
  const att = Files.pathsOf({ runtimeDir, key: b.key, names: b.files });
96
96
  if (!att.ok) { ctx.json(res, { ok: false, error: att.error }, att.status); return true; }
97
- const a = (ctx.chatSessions ? Ag.chat : Ag.ask)({ runtimeDir, key: b.key, text: Files.withFiles(b.text, att.paths), sessions: ctx.chatSessions, model: /^work:/.test(String(b.key || '')) ? WP.peekModel() : /^board:/.test(String(b.key || '')) ? BoardP.peekModel() : /^ins:/.test(String(b.key || '')) ? InsP.peekModel() : /^(init|doc):/.test(String(b.key || '')) ? InitP.peekModel() : sk || (/^src:/.test(String(b.key || '')) && !(b.key === 'src:this-page' && url.searchParams.get('ws'))) ? Prod.peekModel() : BP.peekModel(root), spawnSession: ctx.spawnSession, wsId });
97
+ const a = (ctx.chatSessions ? Ag.chat : Ag.ask)({ runtimeDir, key: b.key, text: Files.withFiles(b.text, att.paths), context: b.context, sessions: ctx.chatSessions, model: /^work:/.test(String(b.key || '')) ? WP.peekModel() : /^board:/.test(String(b.key || '')) ? BoardP.peekModel() : /^ins:/.test(String(b.key || '')) ? InsP.peekModel() : /^(init|doc):/.test(String(b.key || '')) ? InitP.peekModel() : sk || (/^src:/.test(String(b.key || '')) && !(b.key === 'src:this-page' && url.searchParams.get('ws'))) ? Prod.peekModel() : BP.peekModel(root), spawnSession: ctx.spawnSession, wsId });
98
98
  ctx.json(res, a.body, a.status);
99
99
  return true;
100
100
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.380.0",
3
+ "version": "0.382.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.380.0",
9
+ "version": "0.382.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.380.0",
3
+ "version": "0.382.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",
@@ -0,0 +1,179 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-viewer-download-test.js — a file in the viewer has a download icon (premium-viewer-share slice 1, PM 2026-10-21: "I should be able to download
4
+ * or share"). public/pm/premium-vw-file.js draws the icon at the right of the file's title; GET /api/doc/export builds Word from a markdown file.
5
+ * W1 downloadsOf(): .html = HTML, PDF · markdown = Markdown, Word .docx, PDF · other text = the original alone · nothing for a file not read
6
+ * W2 printSrc(): the CSP comes first, the page prints itself once loaded, markdown prints as a page of its words
7
+ * W3 GET /api/doc/export: a markdown file becomes a .docx holding its words; outside the workspace 404, not markdown 400, fmt other than docx 400,
8
+ * POST 405, never cached
9
+ * W4 the real premium page: an .html file's icon opens a menu (HTML, PDF); HTML saves the file's own text under its name; PDF prints in a frame
10
+ * sandboxed to scripts and modals, never same-origin; Escape closes the menu and gives the icon focus back
11
+ * W5 a markdown file's menu is Markdown, Word .docx, PDF; Word asks the export route for that file and saves <name>.docx
12
+ * W6 a .js file saves at once, with no menu
13
+ * W7 at 390 the icon is a 44 px target and the page does not scroll sideways
14
+ * PMOS_SHOTS=<dir> also saves the viewer with the menu open at 1280 and 390, light and dark. */
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+ const { spawn } = require('child_process');
18
+ const { findBrowser } = require('./lib/find-browser');
19
+ const T = require('./test-run').configure({ name: 'premium-viewer-download' });
20
+
21
+ const BASE = T.BASE;
22
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
23
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
24
+ const results = [];
25
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
26
+ let srv = null; let browser = null;
27
+ const finish = async (code) => {
28
+ if (browser) await browser.close().catch(() => {});
29
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
30
+ T.killTmux();
31
+ const bad = results.filter((x) => !x.cond).length;
32
+ console.log(`\n${results.length - bad}/${results.length} premium-viewer-download assertions passed`);
33
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
34
+ };
35
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
36
+
37
+ const HTMLF = 'pmos/state/reports/leadership/2026-10-19-leadership.html';
38
+ const MDF = 'pmos/state/notes/2026-10-19.md';
39
+ const JSF = 'workspace/lib/a.js';
40
+ const FILES = {
41
+ [HTMLF]: { kind: 'html', text: '<!doctype html><html><head><title>Leadership</title></head><body><h1>Leadership update</h1><p>Three on track.</p></body></html>' },
42
+ [MDF]: { kind: 'markdown', text: '# Weekly notes\n\nThe **sign-up** rate is 38%.\n\n## Next\n\n- Ship the download icon\n' },
43
+ [JSF]: { kind: 'text', text: 'const a = 1;\n' },
44
+ };
45
+ const SHOTS = process.env.PMOS_SHOTS || '';
46
+
47
+ (async () => {
48
+ {
49
+ const M = await import('./public/pm/premium-vw-file.js');
50
+ const fmts = (f) => M.downloadsOf(f).map((o) => o.fmt + ':' + o.label).join();
51
+ ok('W1 an .html file offers HTML, then PDF', fmts({ name: 'r.html', kind: 'html', text: 'x' }) === 'orig:HTML,pdf:PDF', fmts({ name: 'r.html', kind: 'html', text: 'x' }));
52
+ ok('W1 a markdown file offers Markdown, Word .docx, PDF', fmts({ name: 'n.md', kind: 'markdown', text: 'x' }) === 'orig:Markdown,docx:Word .docx,pdf:PDF');
53
+ ok('W1 any other text file offers only the original', fmts({ name: 'a.json', kind: 'text', text: '{}' }) === 'orig:.json file');
54
+ ok('W1 a file still reading, missing or unreadable offers nothing', !M.downloadsOf({ loading: true }).length && !M.downloadsOf({ reason: 'missing' }).length && !M.downloadsOf({ err: 'x' }).length);
55
+ const h = M.printSrc({ name: 'r.html', kind: 'html', text: '<!doctype html><p>x</p>' }), m = M.printSrc({ name: 'n.md', kind: 'markdown', text: '# Notes\n\nThe **rate** is 38%.' });
56
+ ok('W2 the print page keeps the CSP first and prints itself on load', h.startsWith('<!doctype html><meta http-equiv="Content-Security-Policy"') && /addEventListener\("load"[\s\S]*print\(\)/.test(h), h.slice(0, 200));
57
+ ok('W2 markdown prints as a page of its words', /<h1>Notes<\/h1>/.test(m) && /<strong>rate<\/strong>/.test(m) && m.includes(M.FRAME_CSP), m.slice(0, 300));
58
+ ok('W1 the title row of a read file carries the download icon', /data-fdl/.test(M.fileHtml({ name: 'n.md', kind: 'markdown', text: '# N', rel: 'n.md' })) && !/data-fdl/.test(M.fileHtml({ loading: true })));
59
+ }
60
+ const exe = findBrowser();
61
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the premium-viewer-download suite cannot run'); return finish(1); }
62
+ let chromium;
63
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed — the premium-viewer-download suite cannot run'); return finish(1); }
64
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
65
+ await T.waitForServer(BASE);
66
+
67
+ // W3 the export route, against the real server and a markdown file of this repository (the home workspace)
68
+ {
69
+ const PRD = 'planning/prd/premium-viewer-share-prd.md';
70
+ const r = await fetch(BASE + '/api/doc/export?path=' + encodeURIComponent(PRD) + '&fmt=docx');
71
+ const buf = Buffer.from(await r.arrayBuffer());
72
+ let words = '';
73
+ try { const RX = require('./lib/report-export.js'); const doc = RX.unzip(buf).find((e) => e.name === 'word/document.xml'); words = doc ? doc.data.toString('utf8') : ''; } catch (e) { words = String(e); }
74
+ ok('W3 a markdown file comes back as a .docx holding its words', r.status === 200 && /wordprocessingml/.test(r.headers.get('content-type') || '') && /filename="premium-viewer-share-prd\.docx"/.test(r.headers.get('content-disposition') || '') && /Download and share a file from the viewer/.test(words), r.status + ' ' + r.headers.get('content-disposition') + ' ' + words.slice(0, 120));
75
+ ok('W3 the file is never cached', r.headers.get('cache-control') === 'no-store');
76
+ const st = async (q, o) => (await fetch(BASE + '/api/doc/export?' + q, o)).status;
77
+ ok('W3 a path outside the workspace answers 404', await st('path=' + encodeURIComponent('../../../etc/hosts') + '&fmt=docx') === 404);
78
+ ok('W3 a file that is not markdown answers 400', await st('path=workspace%2Fpackage.json&fmt=docx') === 400);
79
+ ok('W3 any fmt but docx answers 400', await st('path=' + encodeURIComponent(PRD) + '&fmt=pdf') === 400 && await st('path=' + encodeURIComponent(PRD)) === 400);
80
+ ok('W3 the route is GET only', await st('path=' + encodeURIComponent(PRD) + '&fmt=docx', { method: 'POST' }) === 405);
81
+ }
82
+
83
+ browser = await chromium.launch({ executablePath: exe });
84
+ const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
85
+ const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: theme, acceptDownloads: true });
86
+ const page = await ctx.newPage();
87
+ const errors = []; const asked = [];
88
+ page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
89
+ const json = (body) => (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(body) });
90
+ await page.route('**/api/brief-page*', json({ ok: false, error: 'off in this suite' }));
91
+ await page.route('**/api/doc/locate*', (r) => {
92
+ const p = new URL(r.request().url()).searchParams.get('path'), f = FILES[p];
93
+ return json(f ? { ok: true, ws: 'w0', rel: p, abs: '/Users/pm/pmos/' + p, name: p.split('/').pop(), mtime: 1, size: f.text.length } : { ok: false, reason: 'missing', why: 'No such file.' })(r);
94
+ });
95
+ await page.route('**/api/doc?*', (r) => {
96
+ const f = FILES[new URL(r.request().url()).searchParams.get('path')];
97
+ return r.fulfill({ status: 200, contentType: f.kind === 'markdown' ? 'text/markdown' : 'text/plain', headers: { 'X-Doc-Kind': f.kind }, body: f.text });
98
+ });
99
+ await page.route('**/api/doc/export*', (r) => r.fulfill({ status: 200, contentType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', headers: { 'Content-Disposition': 'attachment; filename="2026-10-19.docx"' }, body: 'PK' }));
100
+ await page.goto(BASE + '/premium.html?theme=' + theme);
101
+ await until(() => page.evaluate(() => !!document.querySelector('#dlg')), 15000);
102
+ await page.evaluate(async () => {
103
+ const S = await import('/pm/premium-shell.js');
104
+ S.openDlg({ eye: 'Your item', title: 'Leadership update', say: 'The report is an HTML file in the repo.', noteKey: null, pane: '<article class="paper doc"><p>Item record</p></article>', label: 'Item record' });
105
+ });
106
+ return { ctx, page, errors, asked };
107
+ };
108
+ const press = (page, file) => page.evaluate((f) => {
109
+ const b = document.createElement('button'); b.type = 'button'; b.className = 'fpath'; b.dataset.file = f; b.textContent = f;
110
+ document.querySelector('#dBody .stream').append(b); b.click();
111
+ }, file);
112
+ const ICON = '#dOut .obody.vw:not([hidden]) [data-fdl]';
113
+ const menu = (page) => page.evaluate(() => [...document.querySelectorAll('#dOut .obody.vw:not([hidden]) .vwdlm [data-fmt]')].map((b) => b.dataset.fmt + ':' + b.querySelector('span').textContent).join());
114
+
115
+ {
116
+ const { page, errors, asked, ctx } = await open();
117
+ await press(page, HTMLF);
118
+ await until(() => page.$(ICON), 8000);
119
+ const where = await page.evaluate((s) => { const b = document.querySelector(s), t = b && b.closest('.vwfh').querySelector('.cft'); return b && t ? { right: b.getBoundingClientRect().left > t.getBoundingClientRect().left, label: b.getAttribute('aria-label'), exp: b.getAttribute('aria-expanded') } : null; }, ICON);
120
+ ok('W4 the .html file shows a download icon at the right of its title', where && where.right && /^Download/.test(where.label) && where.exp === 'false', JSON.stringify(where));
121
+ await page.click(ICON);
122
+ const m1 = await until(() => menu(page), 3000);
123
+ ok('W4 the icon opens a menu: HTML, then PDF', m1 === 'orig:HTML,pdf:PDF', m1);
124
+ ok('W4 the menu takes focus on its first choice', await page.evaluate(() => document.activeElement && document.activeElement.dataset.fmt === 'orig'));
125
+ const [dl] = await Promise.all([page.waitForEvent('download', { timeout: 5000 }).catch(() => null), page.click('#dOut .vwdlm [data-fmt="orig"]')]);
126
+ const body = dl ? fs.readFileSync(await dl.path(), 'utf8') : '';
127
+ ok('W4 HTML saves the file\'s own text under its own name', dl && dl.suggestedFilename() === '2026-10-19-leadership.html' && body === FILES[HTMLF].text, dl ? dl.suggestedFilename() + ' ' + body.slice(0, 60) : 'no download');
128
+ ok('W4 the menu closes after a choice', !(await page.$('#dOut .vwdlm')));
129
+ await page.click(ICON);
130
+ await until(() => menu(page), 3000);
131
+ await page.click('#dOut .vwdlm [data-fmt="pdf"]');
132
+ const pf = await until(() => page.evaluate(() => { const f = document.querySelector('iframe.vwprint'); return f ? { sb: f.getAttribute('sandbox'), src: f.srcdoc } : null; }), 3000);
133
+ ok('W4 PDF prints in a frame sandboxed to scripts and modals, never same-origin', pf && pf.sb === 'allow-scripts allow-modals' && /print\(\)/.test(pf.src) && /Leadership update/.test(pf.src) && /default-src 'none'/.test(pf.src), JSON.stringify(pf && { sb: pf.sb }));
134
+ await page.click(ICON);
135
+ await until(() => menu(page), 3000);
136
+ await page.keyboard.press('Escape');
137
+ const esc = await page.evaluate((s) => ({ gone: !document.querySelector('#dOut .vwdlm'), focus: document.activeElement === document.querySelector(s), dlg: !!document.querySelector('#dlg[open], #dlg.on, #dlg:not([hidden])') }), ICON);
138
+ ok('W4 Escape closes the menu and gives the icon focus back, the dialog stays', esc.gone && esc.focus && esc.dlg, JSON.stringify(esc));
139
+ await page.click(ICON);
140
+ await until(() => menu(page), 3000);
141
+ await page.click('#dOut .obody.vw:not([hidden]) .cft');
142
+ ok('W4 a press elsewhere closes the menu', !!(await until(() => page.evaluate(() => !document.querySelector('#dOut .vwdlm')), 2000)));
143
+
144
+ await press(page, MDF);
145
+ await until(() => page.evaluate(() => { const p = document.querySelector('#dOut .obody.vw:not([hidden]) .cfb'); return p && p.querySelector('strong'); }), 6000);
146
+ await page.click(ICON);
147
+ const m2 = await until(() => menu(page), 3000);
148
+ ok('W5 a markdown file\'s menu is Markdown, Word .docx, PDF', m2 === 'orig:Markdown,docx:Word .docx,pdf:PDF', m2);
149
+ const [dw] = await Promise.all([page.waitForEvent('download', { timeout: 5000 }).catch(() => null), page.click('#dOut .vwdlm [data-fmt="docx"]')]);
150
+ if (dw) asked.push(dw.url());
151
+ const q = asked[0] ? new URL(asked[0], BASE).searchParams : null;
152
+ ok('W5 Word asks the export route for that file and saves <name>.docx', dw && dw.suggestedFilename() === '2026-10-19.docx' && q && q.get('ws') === 'w0' && q.get('path') === MDF && q.get('fmt') === 'docx', (dw ? dw.suggestedFilename() : 'no download') + ' ' + asked.join());
153
+ await page.click(ICON);
154
+ await until(() => menu(page), 3000);
155
+ const [dm] = await Promise.all([page.waitForEvent('download', { timeout: 5000 }).catch(() => null), page.click('#dOut .vwdlm [data-fmt="orig"]')]);
156
+ ok('W5 Markdown saves the note\'s own text', dm && dm.suggestedFilename() === '2026-10-19.md' && fs.readFileSync(await dm.path(), 'utf8') === FILES[MDF].text, dm ? dm.suggestedFilename() : 'no download');
157
+
158
+ await press(page, JSF);
159
+ await until(() => page.evaluate(() => { const p = document.querySelector('#dOut .obody.vw:not([hidden]) .cb'); return p && p.dataset.lang === 'js'; }), 6000);
160
+ const [dj] = await Promise.all([page.waitForEvent('download', { timeout: 5000 }).catch(() => null), page.click(ICON)]);
161
+ ok('W6 a .js file saves at once, with no menu', dj && dj.suggestedFilename() === 'a.js' && !(await page.$('#dOut .vwdlm')) && !(await page.$eval(ICON, (b) => b.hasAttribute('aria-haspopup'))), dj ? dj.suggestedFilename() : 'no download');
162
+ ok('W4 no page errors', errors.length === 0, errors.join(' | '));
163
+ await ctx.close();
164
+ }
165
+
166
+ for (const [w, h] of [[1280, 900], [390, 844]]) for (const theme of ['light', 'dark']) {
167
+ const { page, ctx } = await open({ w, h, theme });
168
+ await press(page, HTMLF);
169
+ await until(() => page.$(ICON), 8000);
170
+ await sleep(300);
171
+ await page.click(ICON);
172
+ await until(() => menu(page), 3000);
173
+ const geo = await page.evaluate((s) => { const b = document.querySelector(s).getBoundingClientRect(), m = document.querySelector('#dOut .vwdlm').getBoundingClientRect(); return { bw: Math.round(b.width), bh: Math.round(b.height), mr: Math.round(m.right), ml: Math.round(m.left), mw: Math.round(m.width), vw: innerWidth, sx: document.documentElement.scrollWidth - innerWidth }; }, ICON);
174
+ ok(`W7 at ${w} ${theme} the icon is a ${w < 700 ? 44 : 36} px target and the menu fits on screen`, geo.bw >= (w < 700 ? 44 : 36) && geo.bh >= (w < 700 ? 44 : 36) && geo.ml >= 0 && geo.mr <= geo.vw && geo.mw >= 160 && geo.sx <= 0, JSON.stringify(geo));
175
+ if (SHOTS) { fs.mkdirSync(SHOTS, { recursive: true }); await sleep(200); await page.screenshot({ path: path.join(SHOTS, `menu-${w}-${theme}.png`) }); }
176
+ await ctx.close();
177
+ }
178
+ return finish();
179
+ })();
@@ -95,7 +95,7 @@ const mk = (edit) => { const v = F.view(); if (edit) edit(v); return WP.build({
95
95
  await undoOf(p);
96
96
  ok('W9 Undo of Accept posts focus/clear for that key', A.last().path === '/api/pm-items/focus/clear' && A.last().body.key === 'job:job-1' && Object.keys(A.last().body).join() === 'key', JSON.stringify(A.last()));
97
97
  const fd = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, text: document.querySelector('#oMain').textContent, ask: document.querySelector('#askF').hidden, add: document.querySelector('[data-fx="jadd"]').disabled }));
98
- ok('W6 See all lists the suggestion with the item it covers, and the PM\'s jobs with open counts', fd.title === 'Focus and jobs' && /to walk in with a decision ready/.test(fd.text) && /Prepare for the Design review/.test(fd.text) && /When a design review is on the calendar, I want to walk in with a decision ready, so the review ends with a disposition\./.test(fd.text) && /1 open item/.test(fd.text) && fd.ask, JSON.stringify(fd));
98
+ ok('W6 See all lists the suggestion with the item it covers, and the PM\'s jobs with open counts', fd.title === 'Focus and jobs' && /to walk in with a decision ready/.test(fd.text) && /Prepare for the Design review/.test(fd.text) && /When a design review is on the calendar, I want to walk in with a decision ready, so the review ends with a disposition\./.test(fd.text) && /1 open item/.test(fd.text) && !fd.ask, JSON.stringify(fd));
99
99
  ok('W6 Add the job stays off until the line has when, I want and so', fd.add && await p.evaluate(async () => { const i = document.querySelector('#xjIn'); i.value = 'when a launch slips'; i.dispatchEvent(new Event('input', { bubbles: true })); return document.querySelector('[data-fx="jadd"]').disabled; }));
100
100
  await p.fill('#xjIn', 'when a launch slips, I want the owner named, so the date holds');
101
101
  ok('W6 …and turns on when it has all three', await p.evaluate(() => !document.querySelector('[data-fx="jadd"]').disabled));
@@ -2,6 +2,7 @@
2
2
  * Claude's turns are markdown: headings, **bold**, lists, `code`, fences, links, tables and quotes are drawn, not printed as their marks.
3
3
  * Everything is escaped first and the marks are read from the escaped text, so no HTML in a message reaches the page. Links open only
4
4
  * http(s). The PM's own turns lose the <pasted_content> wrapper Claude Code puts around a paste, and keep their line breaks. */
5
+ import { tableStarts, readTable, tableHtml } from './md-table.js';
5
6
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
6
7
 
7
8
  /* A file path Claude wrote (PM, 2026-10-20: "Why can't I click the file and see it on the right panel?"): a `code` span, a [name](path) link or a bare
@@ -45,8 +46,6 @@ function inline(t) {
45
46
  .replace(/~~(?=\S)([\s\S]*?\S)~~/g, '<del>$1</del>');
46
47
  return s.replace(/\u0000(\d+)\u0000/g, (_, i) => keep[+i]);
47
48
  }
48
- const cells = (l) => l.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map((c) => c.trim());
49
- const isRule = (l) => l.includes('|') && /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(l);
50
49
  const LI = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/;
51
50
 
52
51
  /** A list's items ({ ind, ord, html }) as nested <ul>/<ol>: a deeper item opens a list inside the item above it. */
@@ -85,14 +84,7 @@ function blocks(lines) {
85
84
  const h = /^\s*(#{1,6})\s+(.*?)\s*#*\s*$/.exec(l);
86
85
  if (h) { flush(); out.push(`<h${h[1].length > 3 ? 6 : h[1].length + 3}>${inline(h[2])}</h${h[1].length > 3 ? 6 : h[1].length + 3}>`); continue; }
87
86
  if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(l)) { flush(); out.push('<hr>'); continue; }
88
- if (l.includes('|') && i + 1 < lines.length && isRule(lines[i + 1])) {
89
- flush();
90
- const head = cells(l), rows = [];
91
- for (i += 2; i < lines.length && lines[i].includes('|') && lines[i].trim(); i++) rows.push(cells(lines[i]));
92
- i--;
93
- out.push(`<div class="mdtab"><table><thead><tr>${head.map((c) => `<th>${inline(c)}</th>`).join('')}</tr></thead><tbody>${rows.map((r) => `<tr>${head.map((_, c) => `<td>${inline(r[c] || '')}</td>`).join('')}</tr>`).join('')}</tbody></table></div>`);
94
- continue;
95
- }
87
+ if (tableStarts(lines, i)) { flush(); const t = readTable(lines, i); i = t.end; out.push(tableHtml(t, inline, 'mdtab')); continue; }
96
88
  if (/^\s*&gt;/.test(l)) {
97
89
  flush();
98
90
  const q = [];