create-pmos 0.354.0 → 0.356.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.354.0",
3
+ "version": "0.356.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.356.0",
37
+ "at": "2026-10-20T09:37:44.880Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 955,
42
+ "t": "Full-screen chat is never blank when the viewer is folded",
43
+ "s": "The panel always shows something."
44
+ },
45
+ {
46
+ "n": 957,
47
+ "t": "A live premium chat stops blinking beside the viewer",
48
+ "s": "The conversation stays still."
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "v": "0.355.0",
54
+ "at": "2026-10-20T09:07:17.325Z",
55
+ "f": 2,
56
+ "prs": [
57
+ {
58
+ "n": 954,
59
+ "t": "A Scratchpad in the chat panel",
60
+ "s": "A Scratchpad chip under the message box opens a pad above it."
61
+ }
62
+ ]
63
+ },
35
64
  {
36
65
  "v": "0.354.0",
37
66
  "at": "2026-10-20T08:48:31.686Z",
@@ -262,30 +291,6 @@
262
291
  "s": "When more than six sessions are in the working state, the dialog shows one note above the list: \"N agents are working at once."
263
292
  }
264
293
  ]
265
- },
266
- {
267
- "v": "0.336.0",
268
- "at": "2026-10-20T01:42:17.900Z",
269
- "f": 2,
270
- "prs": [
271
- {
272
- "n": 931,
273
- "t": "Every premium chat panel is a real Claude Code session",
274
- "s": "The first message in a dialog starts one interactive Claude Code session for that row, with the PM's own login, model and permission settings."
275
- }
276
- ]
277
- },
278
- {
279
- "v": "0.335.0",
280
- "at": "2026-10-20T01:35:14.740Z",
281
- "f": 2,
282
- "prs": [
283
- {
284
- "n": 932,
285
- "t": "Portfolio drafts, report Issue and board document Open stay in premium",
286
- "s": "A portfolio drafts row opens the draft in the same document sheet the Board page uses, on the Briefing, with Issue it and Draft it again."
287
- }
288
- ]
289
294
  }
290
295
  ]
291
296
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@38d4682f
1
+ kernel-source: pmos@6ce4772b
2
2
  assembled: 2026-10-20
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-20T08:48:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-20T09:37:41Z"}
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-20T08:48:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-20T09:37:41Z"}
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-20T08:48:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-20T09:37:41Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -190,6 +190,15 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
190
190
  await p.click('#vFold');
191
191
  const vf = await until(() => p.evaluate(() => { const w = document.querySelector('#dOut').getBoundingClientRect().width; return w > 0 && w < 70 ? Math.round(w) : 0; }), 4000);
192
192
  ok('X13 the viewer folds and the conversation takes the width', vf > 0 && (await p.evaluate(() => document.querySelector('#dBody').getBoundingClientRect().width)) > 800, String(vf));
193
+ /* premium-fullscreen-blank: the folded viewer is a strip that opens again from anywhere on it, and folding never empties the panel */
194
+ const strip = await p.evaluate(() => { const r = document.querySelector('#dOut').getBoundingClientRect(); return { x: r.left + r.width / 2, y: r.top + r.height * 0.6 }; });
195
+ await p.mouse.click(strip.x, strip.y);
196
+ ok('X13b a press anywhere on the folded viewer strip opens the viewer again', !!(await until(() => p.evaluate(() => document.querySelector('#dOut').getBoundingClientRect().width > 300 && !document.querySelector('#dlg').classList.contains('vw-min')), 4000)));
197
+ await p.click('#vFold');
198
+ await p.click('#dExpand'); await p.click('#dPane'); await p.click('#dExpand');
199
+ const det = await until(() => p.evaluate(() => { const d = document.querySelector('#dlg'), o = document.querySelector('#oMain').getBoundingClientRect(); return d.classList.contains('full') && d.dataset.mode === 'detail' && o.width > 300 && o.height > 0 ? { out: Math.round(o.width), fold: getComputedStyle(document.querySelector('#vFold')).display } : null; }), 4000);
200
+ ok('X13c with the conversation hidden, a folded viewer still shows: full screen is never blank', det && det.fold === 'none', JSON.stringify(det));
201
+ await p.click('#dPane');
193
202
  await p.click('#srlFold'); await p.click('#vFold');
194
203
  /* the soft warning: silent at 6 working agents, speaks at 7, at the top of the list */
195
204
  const before = fake.slice();
@@ -1,4 +1,33 @@
1
1
  [
2
+ {
3
+ "v": "0.356.0",
4
+ "at": "2026-10-20T09:37:44.880Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 955,
9
+ "t": "Full-screen chat is never blank when the viewer is folded",
10
+ "s": "The panel always shows something."
11
+ },
12
+ {
13
+ "n": 957,
14
+ "t": "A live premium chat stops blinking beside the viewer",
15
+ "s": "The conversation stays still."
16
+ }
17
+ ]
18
+ },
19
+ {
20
+ "v": "0.355.0",
21
+ "at": "2026-10-20T09:07:17.325Z",
22
+ "f": 2,
23
+ "prs": [
24
+ {
25
+ "n": 954,
26
+ "t": "A Scratchpad in the chat panel",
27
+ "s": "A Scratchpad chip under the message box opens a pad above it."
28
+ }
29
+ ]
30
+ },
2
31
  {
3
32
  "v": "0.354.0",
4
33
  "at": "2026-10-20T08:48:31.686Z",
@@ -31,7 +31,7 @@ Every premium page has the same top bar. On the left is where you are, then a ro
31
31
  - **Groups.** **Goals** holds a chat whose goal is started or waiting on you. **Yours** holds the other sessions you started. **Started by PMOS** holds schedules, the day run, the Driver, the Checker, notes, document syncs and other background runs. A PMOS session shows only when it needs you. The rest fold into one line, "N more working on their own · Show".
32
32
  - **Dots.** An orange dot means **Ready**: the session finished its turn and waits for you. A green dot means **Running**. An orange ring means **Maybe blocked**: a call is open and nothing moves, often a permission question. No dot means idle. Ready sessions come first and are bold. Hold the pointer over a row to see its state in words.
33
33
  - **Switch.** Press a row to switch the dialog to that session. A chat opens its own conversation. Any other session shows its conversation from Claude Code's record. You can write to it and answer its permission questions, as in a chat. The viewer shows the session's facts, the question a background run asks with the options it offered, and **Stop**. Stop asks first, and if the session has not exited yet it says so and offers Stop again.
34
- - **Fold.** The button at the top of the list folds it to a strip of icons with dots. The button at the top of the viewer folds the viewer, so the conversation gets the width. PMOS remembers both in this browser.
34
+ - **Fold.** The button at the top of the list folds it to a strip of icons with dots. The button at the top of the viewer folds the viewer to a strip, so the conversation gets the width; press anywhere on the strip to open the viewer again. PMOS remembers both in this browser. When the conversation is hidden, the viewer always shows, so the panel is never empty.
35
35
  - **When the chat is not full screen,** a chip in the dialog's header shows the loudest dot and, for example, "2 ready". Press it to go full screen with the list. On a phone, it opens the list over the dialog, and a tap on a row switches to that session.
36
36
  - **Sessions in the ⋯ menu** counts the sessions that are Ready or Maybe blocked. It opens the dialog full screen on the session that needs you most. On a phone, it opens the list.
37
37
  - When more than six agents are working at once, a note at the top of the list says how many, and suggests stopping the ones you are not watching. Nothing is stopped for you.
@@ -401,6 +401,7 @@ The conversation beside every premium dialog is a real Claude Code session. Anyt
401
401
  - **What it may do** is set by your own Claude Code settings. Claude can change files and run commands. When your settings say to ask first, the question shows in the panel with its options; press one to answer.
402
402
  - **Stop** shows while Claude works. It presses Esc in the session.
403
403
  - **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.
404
+ - **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.
404
405
  - **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. 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.
405
406
  - **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.
406
407
  - **The session** is also listed in **Sessions** and in the console, where you can open its terminal. When it has ended, your next message starts a new one.
@@ -408,6 +409,16 @@ The conversation beside every premium dialog is a real Claude Code session. Anyt
408
409
 
409
410
  Sending and the option presses need the page's launch nonce, so an agent session cannot type into your chat.
410
411
 
412
+ ### The Scratchpad
413
+
414
+ Under the message box, **Scratchpad** opens a pad above the box. It keeps notes for this conversation only. Claude does not see them until you add them to a message.
415
+
416
+ - The text is saved on this machine as you type. It is there when you open the same row again, also after a reload.
417
+ - **Add to message** puts the pad text into the message box. Nothing is sent: read it, change it and press send yourself. If you select part of the pad first, the button reads **Add selection to message** and adds only that part. The pad keeps its text.
418
+ - To hide the pad, press **Scratchpad** again. The text is kept, and the chip shows how many lines it holds. The page remembers if the pad was open.
419
+ - To make the pad taller or shorter, drag the grip on its top edge, or select the grip and press the up arrow or the down arrow. Double-click the grip for the default height.
420
+ - A dialog with no conversation has no pad.
421
+
411
422
  ### Give Claude a goal with `/goal`
412
423
 
413
424
  Type `/` in the box to see the commands: `/goal`, `/compact` and `/clear`. Use the arrow keys and Enter, or press one.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.354.0",
3
+ "version": "0.356.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.354.0",
9
+ "version": "0.356.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.354.0",
3
+ "version": "0.356.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,125 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-pad-test.js — the Scratchpad in the premium chat panel (initiative premium-chat-scratchpad).
4
+ * Serves the real My work page from the real server with a fixture model; the pad saves through the real /api/scratchpad in a scratch state folder.
5
+ * P1 the chip, pad closed · P2 open, type, saved for the row · P3 back after close and reload · P4 another row has its own pad
6
+ * P5 Add selection / Add to message fill the message box and send nothing · P6 no key, no pad · P7 the file name is a hash · P8 phone
7
+ */
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const { spawn } = require('child_process');
11
+ const { findBrowser } = require('./lib/find-browser');
12
+ const T = require('./test-run').configure({ name: 'premium-pad' });
13
+ const WP = require('./lib/my-work-premium.js');
14
+ const F = require('./fixtures/my-work-premium-facts.js');
15
+
16
+ const BASE = T.BASE;
17
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
18
+ const until = async (fn, ms = 6000, 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); } };
19
+ const results = [];
20
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
21
+ let srv = null; let browser = null;
22
+ const finish = async (code) => {
23
+ if (browser) await browser.close().catch(() => {});
24
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
25
+ T.killTmux();
26
+ const bad = results.filter((x) => !x.cond).length;
27
+ console.log(`\n${results.length - bad}/${results.length} premium-pad assertions passed`);
28
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
29
+ };
30
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
31
+ const get = async (u) => (await fetch(BASE + u)).json();
32
+ const SHOTS = process.env.PAD_SHOTS || ''; // a folder: the suite also saves screenshots there for review
33
+ const shot = async (page, n) => { if (SHOTS) await page.screenshot({ path: path.join(SHOTS, n + '.png') }); };
34
+ const KEY = 'pad-test:row/../1', KEY2 = 'pad-test:row-2';
35
+
36
+ (async () => {
37
+ const exe = findBrowser();
38
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
39
+ let chromium;
40
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
41
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
42
+ await T.waitForServer(BASE);
43
+ browser = await chromium.launch({ executablePath: exe });
44
+ const model = WP.build({ v: F.view(), now: F.NOW });
45
+
46
+ const open = async ({ w = 1280, h = 900, ctx = null } = {}) => {
47
+ ctx = ctx || await browser.newContext({ viewport: { width: w, height: h } });
48
+ const page = await ctx.newPage();
49
+ const errors = [], asks = [];
50
+ page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
51
+ await page.route('**/api/my-work-premium', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model, as_of: Date.now() }) }));
52
+ await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() !== 'GET') asks.push(new URL(rq.url()).pathname); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }); });
53
+ await page.goto(BASE + '/premium-work.html', { waitUntil: 'domcontentloaded' });
54
+ await page.waitForFunction(() => document.querySelector('#dBody') !== null);
55
+ return { page, ctx, errors, asks };
56
+ };
57
+ const dlg = (page, key) => page.evaluate(async (key) => { const m = await import('/pm/premium-shell.js'); m.openDlg({ eye: 'Test', title: 'Pad test', say: 'Hello.', noteKey: key, html: '<p>detail</p>' }); }, key);
58
+ const close = (page) => page.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.closeDlg(); });
59
+
60
+ /* P1 */
61
+ let { page, ctx, errors, asks } = await open();
62
+ await dlg(page, KEY);
63
+ ok('P1 the Scratchpad chip is under the message box', await page.isVisible('#sPadT'));
64
+ ok('P1 the pad starts closed', await page.isHidden('#sPad'));
65
+ /* P2 */
66
+ await page.click('#sPadT');
67
+ ok('P2 the chip opens the pad and the pad has focus', await page.isVisible('#sPad') && await page.evaluate(() => document.activeElement && document.activeElement.id === 'sPadTa'));
68
+ ok('P2 the pad sits above the message box', await page.evaluate(() => document.querySelector('#sPad').getBoundingClientRect().bottom <= document.querySelector('#askIn').getBoundingClientRect().top + 1));
69
+ ok('P2 Add to message is off while the pad is empty', await page.isDisabled('#sPadAdd'));
70
+ await page.fill('#sPadTa', 'first line\nsecond keep this\nthird line');
71
+ ok('P2 typing saves the pad for this row', !!(await until(async () => (await get('/api/scratchpad?key=' + encodeURIComponent(KEY))).text === 'first line\nsecond keep this\nthird line')));
72
+ /* P5 */
73
+ await page.evaluate(() => { const t = document.querySelector('#sPadTa'); const a = t.value.indexOf('keep this'); t.focus(); t.setSelectionRange(a, a + 'keep this'.length); t.dispatchEvent(new Event('select')); });
74
+ ok('P5 with a selection the button reads Add selection to message', (await page.textContent('#sPadAdd')).trim() === 'Add selection to message');
75
+ await shot(page, 'build-select-1280-light');
76
+ await page.click('#sPadAdd');
77
+ ok('P5 only the selection goes into the message box', (await page.inputValue('#askIn')) === 'keep this');
78
+ ok('P5 the message box has focus and nothing was sent', await page.evaluate(() => document.activeElement.id === 'askIn') && asks.length === 0, JSON.stringify(asks));
79
+ ok('P5 the pad keeps its text', (await page.inputValue('#sPadTa')).includes('keep this'));
80
+ await page.evaluate(() => { const t = document.querySelector('#sPadTa'); t.setSelectionRange(0, 0); t.dispatchEvent(new Event('select')); });
81
+ await page.click('#sPadAdd');
82
+ const multi = await page.evaluate(() => document.querySelector('#askIn').tagName === 'TEXTAREA');
83
+ const want = 'keep this\nfirst line\nsecond keep this\nthird line';
84
+ ok('P5 Add to message adds the whole pad after what is typed', (await page.inputValue('#askIn')) === (multi ? want : want.replace(/\n/g, ' ')), JSON.stringify(await page.inputValue('#askIn')));
85
+ ok('P5 still nothing sent', asks.length === 0);
86
+ /* P3 */
87
+ await page.fill('#sPadTa', 'saved on close');
88
+ await close(page);
89
+ ok('P3 closing the dialog saves an edit at once', !!(await until(async () => (await get('/api/scratchpad?key=' + encodeURIComponent(KEY))).text === 'saved on close', 2000)));
90
+ await page.click('body').catch(() => {});
91
+ /* P4 */
92
+ await dlg(page, KEY2);
93
+ ok('P4 another row has its own, empty pad', (await page.inputValue('#sPadTa')) === '' && await page.isVisible('#sPad'));
94
+ await close(page);
95
+ await page.reload({ waitUntil: 'domcontentloaded' }); await page.waitForFunction(() => document.querySelector('#dBody') !== null);
96
+ await dlg(page, KEY);
97
+ ok('P3 after a reload the row\'s pad text is back and the pad is open as left', !!(await until(async () => (await page.inputValue('#sPadTa')) === 'saved on close')) && await page.isVisible('#sPad'));
98
+ await page.click('#sPadT');
99
+ ok('P3 closed, the chip says how many lines the pad holds', /1 line/.test(await page.textContent('#sPadT')) && await page.isHidden('#sPad'));
100
+ await close(page);
101
+ /* P6 */
102
+ await dlg(page, null);
103
+ ok('P6 a dialog with no conversation has no pad', await page.isHidden('#sPadT') && await page.isHidden('#sPad'));
104
+ await close(page);
105
+ /* P7 */
106
+ const files = []; const walk = (d) => { for (const n of fs.readdirSync(d, { withFileTypes: true })) { const f = path.join(d, n.name); if (n.isDirectory()) walk(f); else files.push(path.relative(T.STATE_DIR, f)); } };
107
+ try { walk(path.join(T.STATE_DIR, 'scratchpad')); } catch { /* none */ }
108
+ ok('P7 a row pad is filed under a hashed name, never the key', files.length > 0 && files.every((f) => /^scratchpad\/[^/]+\/row-[0-9a-f]{32}\.txt$/.test(f)), files.join(', '));
109
+ const bad = await fetch(BASE + '/api/scratchpad?key=', { method: 'GET' }); ok('P7 an empty key is refused', bad.status === 400);
110
+ ok('P1-P7 no page errors', errors.length === 0, errors.join(' | '));
111
+ await ctx.close();
112
+
113
+ /* P8 phone */
114
+ ({ page, ctx, errors } = await open({ w: 390, h: 844 }));
115
+ await dlg(page, KEY);
116
+ await until(async () => (await page.inputValue('#sPadTa')) === 'saved on close');
117
+ await page.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.setTab('chat'); });
118
+ if (await page.isHidden('#sPad')) await page.click('#sPadT');
119
+ await shot(page, 'build-open-390-light');
120
+ ok('P8 on a phone the pad and chip fit the width', await page.evaluate(() => { const w = innerWidth; return ['#sPad', '#sPadT', '#askIn'].every((s) => { const r = document.querySelector(s).getBoundingClientRect(); return r.width > 0 && r.left >= 0 && r.right <= w + 1; }); }));
121
+ ok('P8 the chip is a 44px target on a phone', await page.evaluate(() => document.querySelector('#sPadT').getBoundingClientRect().height >= 44));
122
+ ok('P8 no page errors', errors.length === 0, errors.join(' | '));
123
+ await ctx.close();
124
+ finish();
125
+ })();
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-viewer-flicker-test.js — the premium dialog stays still while a live chat is open beside an .html file in the viewer (bug 2026-10-20:
4
+ * "When I have Viewer opened, let's say showing HTML file, the PMOS is flickering"). A live chat re-reads its conversation every 2 seconds and
5
+ * the session list every 3. Each read wrote the whole conversation back with innerHTML even when nothing had changed, so every turn was a new
6
+ * node and replayed its `rise` entrance (opacity 0 and a blur): the conversation blinked every 2 seconds beside the report.
7
+ * public/pm/premium-shell.js now writes the conversation and the list only when their HTML changed, and a redraw of a conversation already
8
+ * on screen does not replay the entrance. The real premium page and server; the thread, conversation and file reads are routed.
9
+ * F1 while nothing changes, the turns stay the same nodes and no entrance replays, over several polls
10
+ * F2 the viewer's frame is the same frame and is never reloaded
11
+ * F3 a new message still shows, and the turns already on screen do not replay their entrance
12
+ * PMOS_SHOTS=<dir> also saves the dialog at 1280 and 390, light and dark. */
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const { spawn } = require('child_process');
16
+ const { findBrowser } = require('./lib/find-browser');
17
+ const T = require('./test-run').configure({ name: 'premium-viewer-flicker' });
18
+
19
+ const BASE = T.BASE;
20
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
21
+ 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); } };
22
+ const results = [];
23
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
24
+ let srv = null; let browser = null;
25
+ const finish = async (code) => {
26
+ if (browser) await browser.close().catch(() => {});
27
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
28
+ T.killTmux();
29
+ const bad = results.filter((x) => !x.cond).length;
30
+ console.log(`\n${results.length - bad}/${results.length} premium-viewer-flicker assertions passed`);
31
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
32
+ };
33
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
34
+
35
+ const REPORT = fs.readFileSync(path.join(__dirname, 'fixtures', 'html-viewer-report.html'), 'utf8');
36
+ const HTMLF = 'pmos/state/reports/lightbox-password-conversion/2026-10-19.html';
37
+ const SHOTS = process.env.PMOS_SHOTS || '';
38
+
39
+ (async () => {
40
+ const exe = findBrowser();
41
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the premium-viewer-flicker suite cannot run'); return finish(1); }
42
+ let chromium;
43
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed — the premium-viewer-flicker suite cannot run'); return finish(1); }
44
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
45
+ await T.waitForServer(BASE);
46
+ browser = await chromium.launch({ executablePath: exe });
47
+
48
+ const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
49
+ const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: theme });
50
+ const page = await ctx.newPage();
51
+ const errors = [];
52
+ page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
53
+ const conv = { ok: true, state: 'conv', turn: 'user', messages: [
54
+ { role: 'user', text: 'Write the funnel report as an HTML file.' },
55
+ { role: 'assistant', text: 'The report is at `' + HTMLF + '`.' },
56
+ ] };
57
+ const json = (body) => (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(typeof body === 'function' ? body() : body) });
58
+ await page.route('**/api/brief-page*', json({ ok: false, error: 'off in this suite' }));
59
+ await page.route('**/api/briefing-premium/thread*', json({ ok: true, session: 's-flicker', turns: [] }));
60
+ await page.route('**/api/sessions/conversation*', json(() => conv));
61
+ await page.route('**/api/sessions', json({ sessions: [{ id: 's-flicker', origin: 'chat:k-flicker', name: 'Funnel report', shown: 'running', state: 'running' }] }));
62
+ await page.route('**/api/doc/locate*', json({ ok: true, ws: 'w0', rel: HTMLF, abs: '/Users/pm/pmos/' + HTMLF, name: '2026-10-19.html', mtime: 1, size: REPORT.length }));
63
+ await page.route('**/api/doc?*', (r) => r.fulfill({ status: 200, contentType: 'text/plain', headers: { 'X-Doc-Kind': 'html' }, body: REPORT }));
64
+ await page.goto(BASE + '/premium.html?theme=' + theme);
65
+ await until(() => page.evaluate(() => !!document.querySelector('#dlg')), 15000);
66
+ await page.evaluate(async () => {
67
+ const S = await import('/pm/premium-shell.js');
68
+ S.openDlg({ eye: 'Your item', title: 'Funnel report', say: 'Ask about the report.', noteKey: 'k-flicker', pane: '<article class="paper doc"><p>Item record</p></article>', label: 'Item record' });
69
+ S.loadThread('k-flicker');
70
+ });
71
+ const fp = await until(() => page.$('#dBody .stream button.fpath[data-file]'), 8000);
72
+ if (fp) await fp.evaluate((b) => b.click()); // on a phone the dialog opens on the Detail side, so the press goes through the button's own handler
73
+ return { ctx, page, errors, conv };
74
+ };
75
+
76
+ {
77
+ const { page, errors, conv, ctx } = await open();
78
+ const fr = await until(() => page.$('#dOut .obody.vw iframe.vwframe'), 8000);
79
+ ok('the chat names the report and the press opens it in the viewer as a frame', !!fr);
80
+ await sleep(1500); // the first draw's entrance has played
81
+ await page.evaluate(() => {
82
+ window.__rise = 0; window.__loads = 0; window.__frame = document.querySelector('#dOut .obody.vw iframe.vwframe');
83
+ window.__turns = [...document.querySelectorAll('#dBody .stream .turn')];
84
+ document.querySelector('#dBody').addEventListener('animationstart', (e) => { if (e.animationName === 'rise') window.__rise++; });
85
+ if (window.__frame) window.__frame.addEventListener('load', () => { window.__loads++; });
86
+ });
87
+ await sleep(7000); // three conversation reads and two list reads
88
+ const st = await page.evaluate(() => ({ rise: window.__rise, turns: window.__turns.length, same: window.__turns.every((t) => t.isConnected), frame: window.__frame === document.querySelector('#dOut .obody.vw iframe.vwframe'), loads: window.__loads }));
89
+ ok('F1 while nothing changes, the turns stay the same nodes over several reads', st.turns >= 2 && st.same, JSON.stringify(st));
90
+ ok('F1 no turn replays its entrance while nothing changes', st.rise === 0, JSON.stringify(st));
91
+ ok('F2 the viewer keeps the same frame and never reloads it', st.frame && st.loads === 0, JSON.stringify(st));
92
+ conv.messages.push({ role: 'user', text: 'Add the weekly view.' }, { role: 'assistant', text: 'Added the weekly view.' });
93
+ const got = await until(() => page.evaluate(() => /Added the weekly view/.test(document.querySelector('#dBody .stream').textContent)), 6000);
94
+ await sleep(800);
95
+ const st2 = await page.evaluate(() => ({ rise: window.__rise, frame: window.__frame === document.querySelector('#dOut .obody.vw iframe.vwframe'), loads: window.__loads }));
96
+ ok('F3 a new message still shows in the conversation', !!got);
97
+ ok('F3 the redraw for it does not replay the entrance of the turns on screen', st2.rise === 0, JSON.stringify(st2));
98
+ ok('F3 the viewer frame is untouched by the new message', st2.frame && st2.loads === 0, JSON.stringify(st2));
99
+ ok('no page errors', errors.length === 0, errors.join(' | '));
100
+ await ctx.close();
101
+ }
102
+
103
+ if (SHOTS) {
104
+ for (const [w, h] of [[1280, 900], [390, 844]]) for (const theme of ['light', 'dark']) {
105
+ const { page, ctx } = await open({ w, h, theme });
106
+ await until(() => page.$('#dOut .obody.vw iframe.vwframe'), 8000);
107
+ await sleep(1500);
108
+ fs.mkdirSync(SHOTS, { recursive: true });
109
+ await page.screenshot({ path: path.join(SHOTS, `after-${w}-${theme}.png`) });
110
+ await ctx.close();
111
+ }
112
+ }
113
+ return finish();
114
+ })();
@@ -0,0 +1,89 @@
1
+ /* pm/premium-pad.js — the Scratchpad in the premium chat panel (initiative premium-chat-scratchpad).
2
+ * The console's per-session pad (c3-session-term.js makePad), kept per conversation: one pad for each row's key, because a row's session
3
+ * starts with its first message and can end and start again. Saved on this machine through /api/scratchpad?key=… as you type.
4
+ * "Add to message" puts the pad text, or the selected part of it, into the message box. Nothing is sent; the pad keeps its text. */
5
+ import { pmGet, pmPost } from './http.js';
6
+
7
+ const OPEN_KEY = 'pmos.premium.pad.open', H_KEY = 'pmos.premium.pad.h';
8
+ export const PAD_H = 132, PAD_MIN = 64, PAD_STEP = 18;
9
+ const PEN = '<svg class="i" viewBox="0 0 24 24"><path d="M4 20h4L19 9l-4-4L4 16v4z"/><path d="M14 6l4 4"/></svg>';
10
+
11
+ /** The lines the pad holds, for the closed chip ("Scratchpad · 3 lines"). Blank lines at the ends do not count. Pure. */
12
+ export function padLines(text) { const t = String(text || '').replace(/^\s+|\s+$/g, ''); return t ? t.split('\n').length : 0; }
13
+ /** The message box after Add to message: the added text goes after what is already typed, on a new line. Pure. */
14
+ export function addToMessage(cur, add) {
15
+ const a = String(add || '').replace(/^\n+|\s+$/g, ''); if (!a) return String(cur || '');
16
+ const c = String(cur || '').replace(/\s+$/, '');
17
+ return c ? c + '\n' + a : a;
18
+ }
19
+ /** The pad height in px, kept between the minimum and 60% of the room. Pure. */
20
+ export function clampPadH(h, room) { const n = Math.round(Number(h)); const max = Math.max(PAD_MIN, Math.round((Number(room) || 600) * 0.6)); return Number.isFinite(n) ? Math.min(max, Math.max(PAD_MIN, n)) : PAD_H; }
21
+
22
+ const store = { get: (k) => { try { return localStorage.getItem(k); } catch { return null; } }, set: (k, v) => { try { localStorage.setItem(k, v); } catch { /* not remembered */ } } };
23
+ export const padMarkup = () => `<div class="spad" id="sPad" hidden><div class="spad-grip" id="sPadGrip" role="separator" aria-orientation="horizontal" tabindex="0" aria-label="Resize the scratchpad" title="Drag to resize the scratchpad. Double-click for the default size."><i></i></div><div class="spad-h"><b>Scratchpad</b><span>This conversation · saved on this machine</span></div><textarea id="sPadTa" aria-label="Scratchpad" placeholder="Notes for this conversation. Claude does not see them until you add them to a message." maxlength="200000"></textarea><div class="spad-f"><button type="button" class="cta alt sm" id="sPadAdd" disabled title="Put the text in the message box. Nothing is sent.">Add to message</button></div></div>`;
24
+ export const padChipMarkup = () => `<button type="button" class="padt" id="sPadT" aria-expanded="false" aria-controls="sPad" hidden>${PEN}<span>Scratchpad</span><em id="sPadN"></em></button>`;
25
+
26
+ let cur = null; // the pad on show: { key, ws, ta, flush }
27
+ /** Flush the open pad's unsaved text at once (the dialog closes, the page hides). */
28
+ export function flushPad() { if (cur) cur.flush(); }
29
+
30
+ /** Wire the pad that padMarkup() and padChipMarkup() drew into the dialog for the row `key`. No key: no conversation, so no pad. */
31
+ export function mountPad({ key, ws, input }) {
32
+ flushPad(); cur = null;
33
+ const box = document.getElementById('sPad'), chip = document.getElementById('sPadT');
34
+ if (!box || !chip) return;
35
+ if (!key) { chip.hidden = true; box.hidden = true; return; }
36
+ const ta = document.getElementById('sPadTa'), add = document.getElementById('sPadAdd'), grip = document.getElementById('sPadGrip'), n = document.getElementById('sPadN');
37
+ const q = 'key=' + encodeURIComponent(key) + (ws ? '&ws=' + encodeURIComponent(ws) : '');
38
+ let typed = false, timer = null, pending = null;
39
+ const me = { key, ws, ta };
40
+ me.flush = () => {
41
+ if (timer) { clearTimeout(timer); timer = null; }
42
+ if (pending === null) return;
43
+ const text = pending; pending = null;
44
+ pmPost('/api/scratchpad', { key, ws: ws || undefined, text }).catch(() => { /* the text stays in the box */ });
45
+ };
46
+ cur = me;
47
+ const sel = () => (ta.selectionEnd > ta.selectionStart ? ta.value.slice(ta.selectionStart, ta.selectionEnd) : '');
48
+ const sync = () => {
49
+ const s = sel().trim();
50
+ add.disabled = !ta.value.trim();
51
+ add.textContent = s ? 'Add selection to message' : 'Add to message';
52
+ const k = padLines(ta.value);
53
+ n.textContent = box.hidden && k ? ` · ${k} ${k === 1 ? 'line' : 'lines'}` : '';
54
+ };
55
+ const setOpen = (on) => {
56
+ box.hidden = !on; chip.classList.toggle('on', on); chip.setAttribute('aria-expanded', String(on));
57
+ chip.title = on ? 'Hide the scratchpad. The text is kept.' : 'Show the scratchpad';
58
+ sync();
59
+ };
60
+ let h = Number(store.get(H_KEY)) || 0;
61
+ const room = () => (document.getElementById('dBody') || document.body).clientHeight;
62
+ const applyH = () => { // the height is the box's own rows, as the console pad does, so no inline style
63
+ ta.rows = Math.max(2, Math.round((h || PAD_H) / (parseFloat(getComputedStyle(ta).lineHeight) || 21))); grip.setAttribute('aria-valuenow', String(h || PAD_H)); };
64
+ const setH = (v) => { h = clampPadH(v, room()); applyH(); };
65
+ const saveH = () => store.set(H_KEY, h ? String(h) : '');
66
+ chip.hidden = false;
67
+ chip.onclick = () => { const on = box.hidden; store.set(OPEN_KEY, on ? 'open' : 'closed'); setOpen(on); if (on) ta.focus(); };
68
+ ta.oninput = () => { typed = true; pending = ta.value; if (timer) clearTimeout(timer); timer = setTimeout(me.flush, 500); sync(); };
69
+ ta.onselect = sync; ta.onkeyup = sync; ta.onmouseup = sync;
70
+ ta.onkeydown = (e) => { if (e.key === 'Enter') e.stopPropagation(); }; // Enter is a new line in the pad, never a send
71
+ add.onclick = () => {
72
+ const text = sel() || ta.value; if (!text.trim() || !input) return;
73
+ const v = addToMessage(input.value, text);
74
+ input.value = input.tagName === 'TEXTAREA' ? v : v.replace(/[ \t]*\n[ \t]*/g, ' '); // a one-line box would drop the line breaks and join the words
75
+ input.dispatchEvent(new Event('input', { bubbles: true })); // the message box grows and the / menu reads it, as if typed
76
+ input.focus();
77
+ try { input.setSelectionRange(input.value.length, input.value.length); } catch { /* a box without a caret */ }
78
+ const note = document.getElementById('askNote'); if (note) note.textContent = 'Added to your message. Press send when it reads right. The pad keeps its text.';
79
+ };
80
+ let y0 = null, h0 = 0;
81
+ grip.onpointerdown = (e) => { y0 = e.clientY; h0 = h || PAD_H; try { grip.setPointerCapture(e.pointerId); } catch { /* none */ } };
82
+ grip.onpointermove = (e) => { if (y0 != null) setH(h0 + (y0 - e.clientY)); };
83
+ grip.onpointerup = grip.onpointercancel = () => { if (y0 == null) return; y0 = null; saveH(); };
84
+ grip.ondblclick = () => { h = 0; applyH(); saveH(); };
85
+ grip.onkeydown = (e) => { if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return; e.preventDefault(); setH((h || PAD_H) + (e.key === 'ArrowUp' ? PAD_STEP : -PAD_STEP)); saveH(); };
86
+ ta.value = ''; applyH(); setOpen(store.get(OPEN_KEY) === 'open');
87
+ pmGet('/api/scratchpad?' + q).then((r) => { if (cur === me && !typed && r && typeof r.text === 'string') { ta.value = r.text; sync(); } }).catch(() => { /* an empty pad */ });
88
+ }
89
+ if (typeof addEventListener === 'function') addEventListener('pagehide', flushPad);
@@ -7,6 +7,7 @@ import { chipActs, openLive, openFocus, mountRecord, HL_LINE } from './premium-v
7
7
  import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
8
8
  import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, slashMatches } from './goal-chat.js';
9
9
  import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
10
+ import { padMarkup, padChipMarkup, mountPad, flushPad } from './premium-pad.js';
10
11
  import { railModel, railHtml, teaser, menuCount, loudestRow, factsOf, titleOf, DOT, WORD } from './session-rail.js';
11
12
  export const $ = (s, r = document) => r.querySelector(s);
12
13
  export const $$ = (s, r = document) => [...r.querySelectorAll(s)];
@@ -194,7 +195,8 @@ export function openDlg(o) {
194
195
  $('#dlg').inert = false; document.documentElement.style.overflow = 'hidden';
195
196
  $('#dEye').textContent = o.eye; $('#dTitle').textContent = o.title; $('#dSub').textContent = o.sub || ''; $('#dSub').hidden = !o.sub;
196
197
  $('#oMain').innerHTML = o.pane || `<article class="paper doc">${o.html}</article>`; $('#oLab').textContent = o.label || 'Detail'; vwReset(); // extra viewer tabs belong to the dialog that opened them
197
- $('#dBody').innerHTML = `<div class="stream" role="log">${o.stream || turnA(ptx(o.say))}</div><form class="askbar" id="askF"><div class="slashm" id="slashM" role="listbox" aria-label="Commands" hidden></div><textarea id="askIn" rows="1" placeholder="Message Claude, or type /" maxlength="8000" autocomplete="off" enterkeyhint="send" aria-label="A message for Claude" aria-controls="slashM"></textarea><button type="submit" data-act="ask" id="askGo" aria-label="Send to Claude" title="Send to Claude"><svg class="i" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6"/></svg></button></form><p class="fine2" id="askNote">${CHAT_NOTE}</p>`;
198
+ $('#dBody').innerHTML = `<div class="stream" role="log">${o.stream || turnA(ptx(o.say))}</div><form class="askbar" id="askF"><div class="slashm" id="slashM" role="listbox" aria-label="Commands" hidden></div>${padMarkup()}<textarea id="askIn" rows="1" placeholder="Message Claude, or type /" maxlength="8000" autocomplete="off" enterkeyhint="send" aria-label="A message for Claude" aria-controls="slashM"></textarea><button type="submit" data-act="ask" id="askGo" aria-label="Send to Claude" title="Send to Claude"><svg class="i" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6"/></svg></button></form><div class="askfoot"><p class="fine2" id="askNote">${CHAT_NOTE}</p>${padChipMarkup()}</div>`;
199
+ mountPad({ key: S.key, ws: new URLSearchParams(location.search).get('ws'), input: $('#askIn') });
198
200
  $('#dlg').classList.remove('full'); setMode('split'); setTab('out'); // on a phone the dialog opens on the Detail tab and the Detail / Conversation switch brings the conversation, as the mockup draws it
199
201
  $('#veil').classList.add('on'); $('#dlg').classList.add('on');
200
202
  $$('#dGrid .pane').forEach((p) => { p.scrollTop = 0; });
@@ -202,7 +204,7 @@ export function openDlg(o) {
202
204
  setTimeout(() => $('#dlg').focus(), 60);
203
205
  }
204
206
  export function closeDlg() {
205
- clearTimeout(threadTimer); S.key = null; railOnClose();
207
+ clearTimeout(threadTimer); S.key = null; flushPad(); railOnClose();
206
208
  park();
207
209
  $('#veil').classList.remove('on'); $$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; });
208
210
  $('#dlg').inert = true; document.documentElement.style.overflow = ''; $('#dlg').classList.remove('on');
@@ -283,12 +285,22 @@ export function sessionHtml(c, goal = null) {
283
285
  return out.join('');
284
286
  }
285
287
  let threadTimer = null;
288
+ /* A live chat re-reads its conversation every 2 s and the session list every 3 s. Writing the same HTML back made every turn a new node that replayed
289
+ * its `rise` entrance, so the panel blinked beside the viewer (bug 2026-10-20). putHtml writes only what changed, and a redraw of a box already
290
+ * drawn carries .still, so the turns on screen do not replay their entrance. */
291
+ function putHtml(el, html) {
292
+ if (el.__h === html) return false;
293
+ if (el.__h !== undefined) el.classList.add('still');
294
+ el.__h = html; el.innerHTML = html;
295
+ return true;
296
+ }
297
+ function clearHtml(el) { el.__h = undefined; el.classList.remove('still'); el.innerHTML = ''; }
286
298
  export function drawThread(th, key, conv) {
287
299
  if (S.key !== key) return;
288
300
  const box = $('#dBody .stream'); if (!box) return;
289
301
  let t = $('#thr', box); if (!t) { box.insertAdjacentHTML('beforeend', '<div id="thr"></div>'); t = $('#thr', box); }
290
302
  const b = $('#dBody'), atEnd = b.scrollHeight - b.scrollTop - b.clientHeight < 80;
291
- t.innerHTML = threadHtml(th) + sessionHtml(conv, th.goal);
303
+ putHtml(t, threadHtml(th) + sessionHtml(conv, th.goal));
292
304
  S.goal = th.goal || null; S.draft = readyDraft(conv); S.session = th.session || null;
293
305
  const go = $('#askGo'); if (go) go.disabled = !!th.working; // an earlier read-only run still answering
294
306
  const n = $('#askNote'); if (n) n.textContent = th.working ? 'The agent is answering. You can write again when it has.' : conv && conv.ask ? 'Claude is waiting for your answer above.' : CHAT_NOTE;
@@ -884,6 +896,7 @@ function railMount() {
884
896
  const ot = $('#dOut .otop'); if (ot) ot.insertAdjacentHTML('afterbegin', '<button type="button" class="vfold" id="vFold" aria-label="Fold the viewer" title="Fold the viewer"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="M15 4v16"/></svg></button>');
885
897
  $('#srlFold').onclick = () => { R.railMin = !R.railMin; store.set('pmos.srl.rail', R.railMin ? 'min' : 'open'); railLayout(); };
886
898
  $('#vFold').onclick = () => { R.viewMin = !R.viewMin; store.set('pmos.srl.view', R.viewMin ? 'min' : 'open'); railLayout(); };
899
+ $('#dOut').addEventListener('click', (e) => { if (R.viewMin && $('#dlg').classList.contains('full') && desk() && !e.target.closest('#vFold')) $('#vFold').click(); }); // the whole folded strip opens the viewer again
887
900
  $('#sTease').onclick = () => {
888
901
  if (desk()) { setFull(true); railLayout(); railRead(); return; }
889
902
  $('#dlg').classList.toggle('srl-open'); railDraw(); if ($('#dlg').classList.contains('srl-open')) railRead();
@@ -904,7 +917,7 @@ function railLayout() {
904
917
  }
905
918
  function railDraw() {
906
919
  const m = R.model = railModel(R.rows, R.goals, { showAll: R.showAll });
907
- const l = $('#srlList'); if (l) l.innerHTML = railHtml(m, { sel: R.sel, shut: R.shut, showAll: R.showAll });
920
+ const l = $('#srlList'); if (l) putHtml(l, railHtml(m, { sel: R.sel, shut: R.shut, showAll: R.showAll }));
908
921
  const t = $('#sTease'), tz = teaser(m);
909
922
  if (t) {
910
923
  t.hidden = !tz || !t.dataset.on || $('#dlg').classList.contains('full');
@@ -937,7 +950,7 @@ function pickSession(id) {
937
950
  clearTimeout(R.sidTimer); R.sel = id; R.ask = null; R.slow = null; R.err = '';
938
951
  $('#dlg').classList.remove('srl-open');
939
952
  $('#dEye').textContent = r.group === 'pmos' ? 'Started by PMOS' : r.goal ? 'Goal' : 'Session'; $('#dTitle').textContent = r.name; $('#dSub').hidden = true;
940
- const st = $('#dBody .stream'); if (st) st.innerHTML = '';
953
+ const st = $('#dBody .stream'); if (st) clearHtml(st);
941
954
  $('#askF').hidden = !!r.headless; $('#askIn').value = ''; $('#askIn').placeholder = r.key ? 'Message Claude, or type /' : 'Message this session';
942
955
  if (r.key) { S.sid = null; S.key = r.key; loadThread(r.key); } else { S.key = null; S.sid = id; loadSid(id); }
943
956
  sessionCard(r); railDraw();
@@ -950,7 +963,7 @@ async function loadSid(id) {
950
963
  if (S.sid !== id) return;
951
964
  const box = $('#dBody .stream'); if (!box) return;
952
965
  const b = $('#dBody'), atEnd = b.scrollHeight - b.scrollTop - b.clientHeight < 80;
953
- box.innerHTML = c && c.ok ? sessionHtml(c) : turnA(ptx('The conversation of this session could not be read.'));
966
+ putHtml(box, c && c.ok ? sessionHtml(c) : turnA(ptx('The conversation of this session could not be read.')));
954
967
  $('#askNote').textContent = c && c.ask ? 'Claude is waiting for your answer above.' : 'Your message goes to this session.';
955
968
  if (atEnd) b.scrollTop = b.scrollHeight;
956
969
  if (c && c.ok && c.state !== 'ended' && $('#dlg').classList.contains('on')) R.sidTimer = setTimeout(() => loadSid(id), 2000);
@@ -274,6 +274,7 @@ a.round{color:inherit;text-decoration:none}
274
274
  .turn.u{justify-items:end}
275
275
  .ub{background:var(--solid);color:var(--on-solid);padding:11px 16px;border-radius:18px 18px 8px 18px;font-size:var(--fs-3);line-height:1.45;max-width:86%}
276
276
  .acard{margin-left:40px;background:var(--well);border-radius:var(--r-in);padding:20px 22px;display:grid;gap:14px;animation:rise .6s var(--ease) both}
277
+ .still .turn,.still .acard{animation:none} /* a redraw of a live chat keeps its turns still (premium-shell.js putHtml) */
277
278
  .acard .ct{margin:0;font:600 var(--t-micro) var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3)}
278
279
  .acard .kv{margin:0;grid-template-columns:110px minmax(0,1fr)!important}
279
280
  .cact{display:flex;justify-content:flex-start;padding-top:4px}
@@ -365,7 +366,7 @@ a.round{color:inherit;text-decoration:none}
365
366
  .otop .ol{display:none}
366
367
  /* a phone: the dialog's panes scroll under its title with no edge of their own, so text slid up to the subtitle and read as overlapping it (PM, 2026-10-20).
367
368
  The top of each scrolling pane now fades, and the viewer's tab strip, which stays at the top, carries the dialog's own surface. */
368
- .dlg .dgrid .pane{padding-top:12px;-webkit-mask-image:linear-gradient(to bottom,transparent 0,var(--ink) 14px);mask-image:linear-gradient(to bottom,transparent 0,var(--ink) 14px)}
369
+ .dlg .dgrid .pane{scrollbar-color:color-mix(in oklab,var(--ink) 24%,transparent) transparent;padding-top:12px;-webkit-mask-image:linear-gradient(to bottom,transparent 0,var(--ink) 14px);mask-image:linear-gradient(to bottom,transparent 0,var(--ink) 14px)}
369
370
  .dlg .dgrid .pane:has(.vtabs:not([hidden])){padding-top:0;-webkit-mask-image:none;mask-image:none}
370
371
  .otop:has(.vtabs:not([hidden])){top:0;padding-top:4px;background:var(--card-solid)}
371
372
  .obody{padding:0}
@@ -2417,16 +2418,17 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2417
2418
  .dlg.full.srl-on .dgrid{grid-template-columns:var(--srw,232px) minmax(360px,.75fr) minmax(0,1.25fr);gap:22px}
2418
2419
  .dlg.full.srl-on .srl{display:flex}
2419
2420
  .dlg.full.srl-on.srl-min{--srw:52px}
2420
- .dlg.full.srl-on.vw-min .dgrid{grid-template-columns:var(--srw,232px) minmax(0,1fr) 52px}
2421
- .dlg.full.vw-min:not(.srl-on) .dgrid{grid-template-columns:minmax(0,1fr) 52px}
2421
+ .dlg.full.srl-on.vw-min:not([data-mode="detail"]) .dgrid{grid-template-columns:var(--srw,232px) minmax(0,1fr) 52px}
2422
+ .dlg.full.vw-min:not(.srl-on):not([data-mode="detail"]) .dgrid{grid-template-columns:minmax(0,1fr) 52px}
2422
2423
  .dlg.full[data-mode="detail"].srl-on .dgrid{grid-template-columns:var(--srw,232px) minmax(0,1fr)}
2423
2424
  .dlg.full .vfold{display:grid}
2424
- .dlg.full.vw-min .p-out{background:transparent;overflow:hidden}
2425
- .dlg.full.vw-min .p-out>:not(.otop),.dlg.full.vw-min .otop>:not(#vFold){display:none!important}
2426
- .dlg.full.vw-min .otop{padding:0;background:transparent;justify-content:center}
2425
+ .dlg.full[data-mode="detail"] .vfold{display:none}
2426
+ .dlg.full.vw-min:not([data-mode="detail"]) .p-out{background:transparent;overflow:hidden;border-radius:0;border-left:1px solid var(--hair);padding-left:6px;cursor:pointer}
2427
+ .dlg.full.vw-min:not([data-mode="detail"]) .p-out>:not(.otop),.dlg.full.vw-min:not([data-mode="detail"]) .otop>:not(#vFold){display:none!important}
2428
+ .dlg.full.vw-min:not([data-mode="detail"]) .otop{padding:4px 0 0;background:transparent;justify-content:center}
2427
2429
  .dlg.full.srl-on #dBody .tt,.dlg.full.srl-on #dBody .ub,.dlg.full.srl-on #dBody .md,.dlg.full.srl-on #dBody .md p,.dlg.full.srl-on #dBody .md li{font-size:var(--fs-2)}
2428
2430
  .dlg.full.srl-on .stream{gap:12px}
2429
- .dlg.full.vw-min #dBody{padding-inline:max(0px,calc((100% - 880px) / 2))}
2431
+ .dlg.full.vw-min:not([data-mode="detail"]) #dBody{padding-inline:max(0px,calc((100% - 880px) / 2))}
2430
2432
  .srl-min .srl-hd b,.srl-min .srl-lg,.srl-min .srl-n,.srl-min .srl-h,.srl-min .srl-more,.srl-min .srl-warn,.srl-min .srl-gh>*{display:none!important}
2431
2433
  .srl-min .srl{padding-right:6px}
2432
2434
  .srl-min .srl-hd{justify-content:center;padding-left:0}
@@ -2443,3 +2445,27 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2443
2445
  .dlg.srl-open .srl-hd{display:none}
2444
2446
  .stease{height:44px}
2445
2447
  }
2448
+
2449
+ /* the Scratchpad in the chat panel (premium-pad.js): above the message box, one pad for each conversation */
2450
+ .askfoot{display:flex;align-items:flex-start;gap:10px}
2451
+ .askfoot .fine2{flex:1;min-width:0}
2452
+ .padt{flex:none;display:inline-flex;align-items:center;gap:6px;margin-top:2px;padding:5px 12px;border-radius:var(--r-chip);background:var(--well);color:var(--ink-2);font-size:var(--fs-2);font-weight:600;white-space:nowrap;min-height:30px}
2453
+ .padt[hidden]{display:none}
2454
+ .padt.on{background:var(--solid);color:var(--on-solid)}
2455
+ .padt svg{width:14px;height:14px}
2456
+ .padt em{font-style:normal;font-weight:500;opacity:.75}
2457
+ .spad{flex:1 0 100%;box-sizing:border-box;border-radius:var(--r-in);background:var(--well);overflow:hidden;margin-bottom:2px}
2458
+ .spad[hidden]{display:none}
2459
+ .spad-grip{height:14px;display:grid;place-items:center;cursor:ns-resize;touch-action:none}
2460
+ .spad-grip i{width:36px;height:4px;border-radius:9px;background:var(--ink-3);opacity:.35}
2461
+ .spad-grip:focus-visible{outline:0;box-shadow:inset 0 0 0 2px var(--b3)}
2462
+ .spad-h{display:flex;align-items:baseline;justify-content:space-between;gap:8px;padding:0 16px}
2463
+ .spad-h b{font-size:var(--fs-3);font-weight:600}
2464
+ .spad-h span{font-size:var(--fs-2);color:var(--ink-3);text-align:right}
2465
+ .askbar .spad textarea{flex:none;height:auto;min-height:0;max-height:none;border-radius:0;overflow-y:auto;display:block;width:100%;box-sizing:border-box;border:0;background:transparent;padding:6px 16px 8px;font:inherit;font-size:var(--fs-3);line-height:1.5;color:var(--ink);resize:none;outline:0}
2466
+ .askbar .spad textarea:focus{box-shadow:none}
2467
+ .spad:focus-within{box-shadow:0 0 0 2px var(--b3)}
2468
+ .spad-f{display:flex;justify-content:flex-end;padding:0 10px 10px}
2469
+ .askbar .spad-f .cta{width:auto;height:34px;min-height:34px;padding:0 14px;border-radius:var(--r-chip);display:inline-flex;font-size:var(--fs-2);background:var(--card);color:var(--ink)}
2470
+ .askbar .spad-f .cta:disabled{opacity:.5;cursor:not-allowed}
2471
+ @media (max-width:700px){.spad-h span{display:none}.askbar .spad textarea{font-size:var(--fs-4)}.padt{min-height:44px}}
@@ -5032,6 +5032,14 @@ function scratchpadPath(w, sessionId) {
5032
5032
  if (!/^[A-Za-z0-9._-]{1,64}$/.test(sid) || sid === '.' || sid === '..') return null;
5033
5033
  return path.join(SCRATCH_DIR, w.id, sid + '.txt');
5034
5034
  }
5035
+ // A premium conversation's pad belongs to its ROW, not to a session: the row's session starts with
5036
+ // its first message and can end and start again. The key is the page's own conversation key, so it
5037
+ // is hashed into the file name and never reaches the disk as given.
5038
+ function rowScratchpadId(key) {
5039
+ const k = String(key == null ? '' : key);
5040
+ if (!k || k.length > 400) return null;
5041
+ return 'row-' + crypto.createHash('sha256').update(k).digest('hex').slice(0, 32);
5042
+ }
5035
5043
  function readScratchpad(w, sessionId) {
5036
5044
  const f = scratchpadPath(w, sessionId);
5037
5045
  if (!f) return '';
@@ -7301,6 +7309,14 @@ async function handleRequest(req, res) {
7301
7309
  let body = {};
7302
7310
  try { body = JSON.parse((await readBody(req)) || '{}'); }
7303
7311
  catch { return json(res, { ok: false, error: 'invalid JSON' }, 400); }
7312
+ if (body.key != null) {
7313
+ const rid = rowScratchpadId(body.key), w = getWs(body.ws);
7314
+ if (!rid) return json(res, { ok: false, error: 'no such conversation' }, 400);
7315
+ if (!w) return json(res, { ok: false, error: 'no workspace' }, 404);
7316
+ try { writeScratchpad(w, rid, body.text); }
7317
+ catch (e) { warnWriteFail('scratchpad', e); return json(res, { ok: false, error: 'could not save scratchpad' }, 500); }
7318
+ return json(res, { ok: true, key: true });
7319
+ }
7304
7320
  const s = body.session ? sessions.get(String(body.session)) : null;
7305
7321
  if (body.session && !s) return json(res, { ok: false, error: 'no such session' }, 404);
7306
7322
  const w = s ? workspaces.get(s.ws) : getWs(body.ws);
@@ -7309,6 +7325,15 @@ async function handleRequest(req, res) {
7309
7325
  catch (e) { warnWriteFail('scratchpad', e); return json(res, { ok: false, error: 'could not save scratchpad' }, 500); }
7310
7326
  return json(res, { ok: true, session: s ? s.id : null });
7311
7327
  }
7328
+ if (p === '/api/scratchpad' && url.searchParams.has('key')) {
7329
+ const rid = rowScratchpadId(url.searchParams.get('key')), w = getWs(url.searchParams.get('ws'));
7330
+ if (!rid) return json(res, { ok: false, error: 'no such conversation' }, 400);
7331
+ if (!w) return json(res, { ok: false, error: 'no workspace' }, 404);
7332
+ // readScratchpad with an id never claims the legacy workspace pad for a row: that pad belongs to a terminal tab
7333
+ const f = scratchpadPath(w, rid); let text = '';
7334
+ try { text = fs.readFileSync(f, 'utf8'); } catch { /* an empty pad */ }
7335
+ return json(res, { ok: true, key: true, text });
7336
+ }
7312
7337
  if (p === '/api/scratchpad') {
7313
7338
  const sid = url.searchParams.get('session');
7314
7339
  const s = sid ? sessions.get(sid) : null;
@@ -0,0 +1,13 @@
1
+ {
2
+ "_comment": "Initiative premium-chat-scratchpad: the Scratchpad in the premium chat panel (pure parts, and the pad on the real page and server).",
3
+ "modules": [
4
+ "premium-pad.test.js"
5
+ ],
6
+ "panels": [
7
+ "premium-pad-test.js"
8
+ ],
9
+ "seconds": {
10
+ "premium-pad.test.js": 1,
11
+ "premium-pad-test.js": 40
12
+ }
13
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Bug 2026-10-20 (\"When I have Viewer opened, let's say showing HTML file, the PMOS is flickering\"): a live premium chat wrote its whole conversation back every 2 s, so every turn replayed its entrance beside the viewer. It now writes only what changed and keeps the turns on screen still.",
3
+ "panels": [
4
+ "premium-viewer-flicker-test.js"
5
+ ],
6
+ "seconds": {
7
+ "premium-viewer-flicker-test.js": 20
8
+ }
9
+ }