create-pmos 0.352.0 → 0.353.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.352.0",
3
+ "version": "0.353.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,18 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.353.0",
37
+ "at": "2026-10-20T08:29:44.242Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 951,
42
+ "t": "Sessions listed beside the chat, grouped like Slack",
43
+ "s": "In full screen, the chat dialog has three panels: the session list on the left, the chat in the middle and the viewer on the right."
44
+ }
45
+ ]
46
+ },
35
47
  {
36
48
  "v": "0.352.0",
37
49
  "at": "2026-10-20T08:20:25.043Z",
@@ -274,28 +286,6 @@
274
286
  "s": "On the Briefing, while a note records or is paused, the meeting sheet's During part is the live capture itself."
275
287
  }
276
288
  ]
277
- },
278
- {
279
- "v": "0.333.0",
280
- "at": "2026-10-20T01:10:53.373Z",
281
- "f": 2,
282
- "prs": [
283
- {
284
- "n": 929,
285
- "t": "What's new shows each PR's title and one clean sentence",
286
- "s": "Each pull request shows its title in bold, such as \"Draw the premium calendar the way the console draws it\", with one clean sentence from its After: paragraph under it, such as \"The grid follows the console's Calendar.\""
287
- },
288
- {
289
- "n": 928,
290
- "t": "Agent draft rows on the premium Briefing stay in premium",
291
- "s": "An agent drafts row (driver-drafts, driver-blocked) opens the Briefing's own Agent proposals dialog, showing only that task's or initiative's proposals, with Keep, Send back and Drop, and a \"Show all proposals\" button."
292
- },
293
- {
294
- "n": 930,
295
- "t": "Premium menus, console sheets and highlight tags no longer draw broken",
296
- "s": "Menu rows grow with their text and keep their old height as the minimum."
297
- }
298
- ]
299
289
  }
300
290
  ]
301
291
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@6b52b2f8
1
+ kernel-source: pmos@234b6784
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:20:20Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-20T08:29: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:20:20Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-20T08:29: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:20:20Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-20T08:29:41Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -142,69 +142,86 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
142
142
  for (let i = A.reqs.length - 1; i >= 0; i--) if (/^POST \/api\/proactive\/settings$/.test(A.reqs[i])) A.reqs.splice(i, 1); // R10 below counts presses on a page where nothing was pressed
143
143
  await p.keyboard.press('Escape'); }
144
144
 
145
- /* premium-sessions: the running list reads /api/sessions; Stop asks first and the one write is /api/session/remove */
146
- { const fake = [
147
- { id: 'sess-1', name: 'Draft the brief', agent: 'claude', note: 'Writing the brief', cwd: 'planning', created: new Date(Date.now() - 14 * 60000).toISOString(), shown: 'working', label: 'Working', automatic: false },
148
- { id: 'sess-2', name: 'Refresh metrics', agent: 'claude', note: '', cwd: '.', created: new Date(Date.now() - 6 * 60000).toISOString(), shown: 'working', label: 'Working', automatic: true, headless: 'skill' },
149
- { id: 'sess-3', name: 'Old one', agent: 'claude', note: '', cwd: '.', created: new Date().toISOString(), shown: 'exited', label: 'Exited', automatic: false }];
150
- let removes = 0, slowOnce = true;
145
+ /* premium-session-list (replaces the Agent sessions popup): the ⋯ menu's Sessions opens the chat panel full screen with the list beside it.
146
+ * The list reads /api/sessions; PMOS sessions that need nothing fold into one line; the viewer holds the session's facts, its question and Stop. */
147
+ { const now = Date.now();
148
+ const fake = [
149
+ { id: 'sess-1', name: 'Draft the brief', agent: 'claude', note: 'Writing the brief', cwd: 'planning', created: new Date(now - 14 * 60000).toISOString(), shown: 'needs', label: 'needs you', automatic: false, origin: 'next-step' },
150
+ { id: 'sess-2', name: 'Refresh metrics', agent: 'claude', note: '', cwd: '.', created: new Date(now - 6 * 60000).toISOString(), shown: 'working', label: 'working', automatic: true, origin: 'schedule:metrics', headless: 'skill' },
151
+ { id: 'sess-3', name: 'Old one', agent: 'claude', note: '', cwd: '.', created: new Date(now).toISOString(), shown: 'exited', label: 'exited', automatic: false },
152
+ { id: 'sess-4', name: 'Driver · drafts search', agent: 'claude', note: '', cwd: '.', created: new Date(now - 3 * 60000).toISOString(), shown: 'blocked', label: 'maybe blocked', automatic: true, origin: 'drive:drafts:search' }];
153
+ let removes = 0, slowOnce = true; const said = [];
151
154
  await p.route('**/api/sessions', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ sessions: fake }) }));
152
- await p.route('**/api/session/remove', (r) => { removes++; const id = JSON.parse(r.request().postData()).id; if (id === 'sess-2' && slowOnce) { slowOnce = false; return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, removed: false, note: 'asked it to end' }) }); } const i = fake.findIndex((x) => x.id === id); if (i >= 0) fake.splice(i, 1); return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, removed: true }) }); });
153
- await p.click('#moreBtn'); const bt = await p.evaluate(() => { const b = document.querySelector('#sessBtn'); if (!b) return null; const r = b.getBoundingClientRect(); return { w: Math.round(r.width), h: Math.round(r.height) }; });
154
- ok('X1 the ⋯ menu has an Agent sessions item of at least 44 px', bt && bt.w >= 44 && bt.h >= 44, JSON.stringify(bt));
155
+ await p.route('**/api/briefing-premium/goals', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, goals: {} }) }));
156
+ await p.route('**/api/sessions/conversation**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'conv', turn: 'user', messages: [{ role: 'user', text: 'Draft the brief' }, { role: 'assistant', text: 'The brief is drafted in planning/briefs.' }] }) }));
157
+ await p.route('**/api/session/say', (r) => { said.push({ ...JSON.parse(r.request().postData()), hasNonce: !!r.request().headers()['x-pmos-nonce'] }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
158
+ await p.route('**/api/session/remove', (r) => { removes++; const id = JSON.parse(r.request().postData()).id; if (id === 'sess-4' && slowOnce) { slowOnce = false; return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, removed: false, note: 'asked it to end' }) }); } const i = fake.findIndex((x) => x.id === id); if (i >= 0) fake.splice(i, 1); return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, removed: true }) }); });
159
+ await p.click('#moreBtn'); const bt = await p.evaluate(() => { const b = document.querySelector('#sessBtn'); if (!b) return null; const r = b.getBoundingClientRect(); return { w: Math.round(r.width), h: Math.round(r.height), t: b.textContent }; });
160
+ ok('X1 the ⋯ menu has a Sessions item of at least 44 px', bt && bt.w >= 44 && bt.h >= 44 && /^Sessions/.test(bt.t), JSON.stringify(bt));
155
161
  await p.click('#sessBtn');
156
- const rows = await until(() => p.evaluate(() => document.querySelectorAll('#oMain .ssr').length), 8000);
157
- ok('X2 the list shows the sessions that have not exited, and the title counts them', rows === 2 && (await p.evaluate(() => document.querySelector('#dTitle').textContent)) === '2 running', String(rows));
158
- const meta = await p.evaluate(() => [...document.querySelectorAll('#oMain .ssr')].map((r) => r.querySelector('.ssm').textContent + '|' + r.querySelector('.ssn').textContent));
159
- ok('X3 a row carries only record fields: agent, state word, folder, age; a background run and a PMOS start are named', /claude.*Working.*planning.*min ago/.test(meta[0]) && /Background run/.test(meta[1]) && /Started by PMOS/.test(meta[1]) && /No note$/.test(meta[1]), meta.join(' // '));
160
- await p.click('#oMain [data-stop="sess-1"]');
162
+ const lay = await until(() => p.evaluate(() => { const d = document.querySelector('#dlg'), r = document.querySelector('#sRail'); if (!d.classList.contains('full') || !r || !r.offsetWidth || !document.querySelector('#srlList .srl-r')) return null; const o = { rail: Math.round(r.getBoundingClientRect().width), work: Math.round(document.querySelector('#dBody').getBoundingClientRect().width), out: Math.round(document.querySelector('#dOut').getBoundingClientRect().width) }; return o.out > 300 ? o : null; }), 8000) || (await p.evaluate(() => ({ rail: document.querySelector('#sRail').getBoundingClientRect().width, work: document.querySelector('#dBody').getBoundingClientRect().width, out: document.querySelector('#dOut').getBoundingClientRect().width, cls: document.querySelector('#dlg').className, mode: document.querySelector('#dlg').dataset.mode, w: document.querySelector('#dlg').getBoundingClientRect().width })));
163
+ ok('X2 Sessions opens the chat panel full screen with three panels: list, conversation, viewer', lay && lay.out > 300 && lay.rail > 150 && lay.work > 300 && lay.out > 300, JSON.stringify(lay));
164
+ const grpOf = () => p.evaluate(() => [...document.querySelectorAll('#srlList .srl-g')].map((g) => g.querySelector('.srl-gh span').textContent + ':' + g.querySelectorAll('.srl-r').length + (g.querySelector('.srl-more') ? '+' + g.querySelector('.srl-more').textContent : '')));
165
+ const grp = (await until(async () => { const v = await grpOf(); return v.join('|') === 'Yours:1|Started by PMOS:1+1 more working on their own · Show' ? v : null; }, 8000)) || (await grpOf());
166
+ ok('X3 the list groups by who started each session, exited ones are gone, and PMOS runs that need nothing fold into one line', grp.join('|') === 'Yours:1|Started by PMOS:1+1 more working on their own · Show', grp.join('|'));
167
+ ok('X4 the badge counts the sessions that need you (Ready or Maybe blocked), not every running one', !!(await until(() => p.evaluate(() => document.querySelector('#sessBdg').textContent === '2'), 6000)), await p.evaluate(() => document.querySelector('#sessBdg').textContent));
168
+ const first = await until(() => p.evaluate(() => { const on = document.querySelector('#srlList .srl-r.on'); return on && /Draft the brief/.test(document.querySelector('#dTitle').textContent) && /brief is drafted/.test(document.querySelector('#dBody').textContent) ? on.dataset.sid : null; }), 8000);
169
+ ok('X5 it opens on the session that needs you most, with its conversation from the transcript', first === 'sess-1', String(first));
170
+ await p.fill('#askIn', 'Put it in planning/research instead'); await p.click('#askGo');
171
+ await until(() => said.length, 6000);
172
+ ok('X6 a message to a session with no chat row goes to that session, as a page press', said.length === 1 && said[0].id === 'sess-1' && /planning\/research/.test(said[0].text) && said[0].hasNonce, JSON.stringify(said));
173
+ await p.click('#srlList [data-smore]');
174
+ ok('X7 Show lists the PMOS runs that need nothing', (await p.evaluate(() => document.querySelectorAll('#srlList .srl-r').length)) === 3);
175
+ await p.click('#srlList [data-sid="sess-4"]');
176
+ await until(() => p.evaluate(() => /Driver · drafts search/.test(document.querySelector('#dTitle').textContent) && !!document.querySelector('#oMain [data-stop]')), 6000);
177
+ await p.click('#oMain [data-stop]');
161
178
  const asked = await p.evaluate(() => { const c = document.querySelector('#oMain .ssc'); return c ? c.textContent : ''; });
162
- ok('X4 Stop asks first and says what it ends, and nothing is sent yet', /Stop “Draft the brief”\?/.test(asked) && /closes its terminal/.test(asked) && removes === 0, asked);
163
- await p.click('#oMain [data-no="sess-1"]');
164
- ok('X5 Keep running closes the question and sends nothing', (await p.evaluate(() => !document.querySelector('#oMain .ssc'))) && removes === 0);
165
- await p.click('#oMain [data-stop="sess-2"]'); await p.click('#oMain [data-yes="sess-2"]');
179
+ ok('X8 Stop in the viewer asks first and says what it ends, and nothing is sent yet', /Stop “Driver · drafts search”\?/.test(asked) && /closes its terminal/.test(asked) && removes === 0, asked);
180
+ await p.click('#oMain [data-no]');
181
+ ok('X9 Keep running closes the question and sends nothing', (await p.evaluate(() => !document.querySelector('#oMain .ssc'))) && removes === 0);
182
+ await p.click('#oMain [data-stop]'); await p.click('#oMain [data-yes]');
166
183
  const slow = await until(() => p.evaluate(() => { const c = document.querySelector('#oMain .ssc'); return c ? c.textContent : ''; }), 6000);
167
- ok('X6 a session that has not exited says so and offers Stop again, never "Ended"', /has not exited yet/.test(slow) && !/Ended/.test(await p.evaluate(() => document.querySelector('#oMain').textContent)), slow);
168
- await p.click('#oMain [data-yes="sess-2"]');
169
- ok('X7 the second press ends it: the row says Ended and the toast confirms', !!(await until(() => p.evaluate(() => /Ended “Refresh metrics”/.test(document.querySelector('#oMain').textContent) && /Ended “Refresh metrics”/.test(document.querySelector('#toast').textContent)), 6000)));
170
- ok('X8 the list re-reads and drops it, and the badge follows', !!(await until(() => p.evaluate(() => document.querySelectorAll('#oMain .ssr').length === 1 && document.querySelector('#sessBdg').textContent === '1'), 8000)));
171
- /* the soft warning: silent at 6 working agents, speaks at 7, names the count and the cause, and offers no new press */
172
- const rm0 = removes;
173
- const mk = (n) => Array.from({ length: n }, (_, i) => ({ id: 'w-' + i, name: 'Agent ' + i, agent: 'claude', note: '', cwd: '.', created: new Date().toISOString(), shown: 'working', label: 'Working', automatic: false }));
184
+ ok('X10 a session that has not exited says so and offers Stop again, never "Ended"', /has not exited yet/.test(slow), slow);
185
+ await p.click('#oMain [data-yes]');
186
+ ok('X11 the second press ends it, the toast confirms, and the list drops it', !!(await until(() => p.evaluate(() => /Ended “Driver · drafts search”/.test(document.querySelector('#toast').textContent) && !document.querySelector('#srlList [data-sid="sess-4"]')), 8000)));
187
+ await p.click('#srlFold');
188
+ const folded = await until(() => p.evaluate(() => { const w = document.querySelector('#sRail').getBoundingClientRect().width; return w > 0 && w < 70 ? Math.round(w) : 0; }), 4000);
189
+ ok('X12 the list folds to a strip of dots', folded > 0, String(folded));
190
+ await p.click('#vFold');
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
+ 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
+ await p.click('#srlFold'); await p.click('#vFold');
194
+ /* the soft warning: silent at 6 working agents, speaks at 7, at the top of the list */
174
195
  const before = fake.slice();
196
+ const mk = (n) => Array.from({ length: n }, (_, i) => ({ id: 'w-' + i, name: 'Agent ' + i, agent: 'claude', note: '', cwd: '.', created: new Date().toISOString(), shown: 'working', label: 'working', automatic: false }));
175
197
  fake.splice(0, fake.length, ...mk(6));
176
- await p.keyboard.press('Escape'); await p.click('#moreBtn'); await p.click('#sessBtn');
177
- const six = await until(() => p.evaluate(() => document.querySelectorAll('#oMain .ssr').length === 6), 8000);
178
- ok('X10 six agents working: no warning', six && (await p.evaluate(() => !document.querySelector('#oMain .ssw'))));
179
- fake.push(...mk(7).slice(6).map((x) => ({ ...x, id: 'w-6' })));
180
- await p.keyboard.press('Escape'); await p.click('#moreBtn'); await p.click('#sessBtn');
181
- const warnText = await until(() => p.evaluate(() => { const w = document.querySelector('#oMain .ssw'); return w ? w.textContent : ''; }), 8000);
182
- ok('X11 seven agents working: the warning names the count and says why, in the dialog only', /^7 agents are working at once\./.test(warnText) && /slow it/.test(warnText) && /Stop the ones you are not watching/.test(warnText), warnText);
183
- ok('X12 the warning adds no button and no write', (await p.evaluate(() => document.querySelectorAll('#oMain .ssw button, #oMain .ssw a').length)) === 0 && removes === rm0);
184
- fake.splice(0, fake.length, ...mk(7).map((x, i) => (i < 3 ? { ...x, shown: 'needs', label: 'Needs you' } : x)));
185
- await p.keyboard.press('Escape'); await p.click('#moreBtn'); await p.click('#sessBtn');
186
- await until(() => p.evaluate(() => document.querySelectorAll('#oMain .ssr').length === 7), 8000);
187
- ok('X13 only working agents are counted: seven sessions with three waiting is four working, no warning', await p.evaluate(() => !document.querySelector('#oMain .ssw')));
198
+ ok('X14 six agents working: no warning', !!(await until(() => p.evaluate(() => document.querySelectorAll('#srlList .srl-r').length === 6 && !document.querySelector('#srlList .srl-warn')), 8000)));
199
+ fake.push({ ...mk(7)[6] });
200
+ const warnText = await until(() => p.evaluate(() => { const w = document.querySelector('#srlList .srl-warn'); return w ? w.textContent : ''; }), 8000);
201
+ ok('X15 seven agents working: the warning names the count and says why, with no button', /^7 agents are working at once\./.test(warnText) && /Stop the ones you are not watching/.test(warnText) && (await p.evaluate(() => document.querySelectorAll('#srlList .srl-warn button').length)) === 0, warnText);
188
202
  fake.splice(0, fake.length, ...before);
189
203
  const bare = await fetch(BASE + '/api/session/remove', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: 'sess-1' }) });
190
- ok('X9 Stop is a page press: no nonce, no end (403)', bare.status === 403, String(bare.status));
191
- /* premium-run-questions: a session whose card is asking shows the agent's own question and its offered options; a press is the one write, /api/runs/answer */
204
+ ok('X16 Stop is a page press: no nonce, no end (403)', bare.status === 403, String(bare.status));
205
+ const bareSay = await fetch(BASE + '/api/session/say', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: 'sess-1', text: 'hi' }) });
206
+ ok('X17 writing to a session is a page press: no nonce, nothing typed (403)', bareSay.status === 403, String(bareSay.status));
207
+ /* premium-run-questions: the question a run asks shows in its viewer; a press is the one write, /api/runs/answer */
192
208
  let asking = true; const answers = [];
193
209
  await p.route('**/api/runs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, cards: asking ? { 'sess-1': { state: 'asking', asked: 'q-7', ask: { id: 'q-7', q: 'Which folder should the brief go in?', options: [{ label: 'planning/briefs', rec: true }, { label: 'planning/research' }] } } } : {} }) }));
194
210
  await p.route('**/api/runs/answer', (r) => { answers.push({ ...JSON.parse(r.request().postData()), hasNonce: !!r.request().headers()['x-pmos-nonce'] }); asking = false; r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
195
- await p.keyboard.press('Escape'); await p.click('#moreBtn'); await p.click('#sessBtn');
211
+ await until(() => p.evaluate(() => !!document.querySelector('#srlList [data-sid="sess-1"]')), 8000);
212
+ await p.click('#srlList [data-sid="sess-1"]');
196
213
  const q = await until(() => p.evaluate(() => { const b = document.querySelector('#oMain .ssq'); return b ? b.textContent : ''; }), 8000);
197
214
  ok('Q1 a session that is asking shows its question and the options it offered, in its own words', /Which folder should the brief go in\?/.test(q) && /planning\/briefs/.test(q) && /planning\/research/.test(q), q);
198
- ok('Q2 no question shows on a session that is not asking', (await p.evaluate(() => document.querySelectorAll('#oMain .ssq').length)) === 1);
199
- await p.click('#oMain [data-ans="sess-1"][data-opt="planning/research"]');
215
+ await p.click('#oMain [data-ans="planning/research"]');
200
216
  await until(() => answers.length, 6000);
201
217
  ok('Q3 a press sends the chosen option to /api/runs/answer with the run, the request id and the page nonce', answers.length === 1 && answers[0].run === 'sess-1' && answers[0].request === 'q-7' && answers[0].behavior === 'answer' && answers[0].message === 'planning/research' && answers[0].hasNonce, JSON.stringify(answers));
202
- ok('Q4 the question leaves the row once answered, and the toast says so', !!(await until(() => p.evaluate(() => !document.querySelector('#oMain .ssq') && /Answered/.test(document.querySelector('#toast').textContent)), 6000)));
218
+ ok('Q4 the question leaves once answered, and the toast says so', !!(await until(() => p.evaluate(() => !document.querySelector('#oMain .ssq') && /Answered/.test(document.querySelector('#toast').textContent)), 6000)));
203
219
  const bareAns = await fetch(BASE + '/api/runs/answer', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ run: 'sess-1', request: 'q-7', behavior: 'answer', message: 'planning/research' }) });
204
220
  ok('Q5 answering is a page press: no nonce, no answer (403)', bareAns.status === 403, String(bareAns.status));
205
221
  await p.unroute('**/api/runs'); await p.unroute('**/api/runs/answer');
206
- await p.keyboard.press('Escape'); await p.unroute('**/api/sessions'); await p.unroute('**/api/session/remove');
207
- for (let i = A.reqs.length - 1; i >= 0; i--) if (/^POST \/api\/(session\/remove|runs\/answer)$/.test(A.reqs[i])) A.reqs.splice(i, 1); }
222
+ await p.keyboard.press('Escape'); await p.keyboard.press('Escape');
223
+ await p.unroute('**/api/sessions'); await p.unroute('**/api/session/remove'); await p.unroute('**/api/session/say'); await p.unroute('**/api/sessions/conversation**'); await p.unroute('**/api/briefing-premium/goals');
224
+ for (let i = A.reqs.length - 1; i >= 0; i--) if (/^POST \/api\/(session\/remove|session\/say|runs\/answer)$/.test(A.reqs[i])) A.reqs.splice(i, 1); }
208
225
 
209
226
  /* R2: with the console reads off, the hero is the model's records-only sentences */
210
227
  const hero = await p.evaluate(() => ({ text: document.querySelector('#brief').textContent, k: [...document.querySelectorAll('#brief .k')].map((x) => x.textContent) }));
@@ -276,7 +293,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
276
293
  await p.click('[data-start="no"]');
277
294
  ok('W8 Not now goes back to the Start button', await p.evaluate(() => !!document.querySelector('#startBtn') && !document.querySelector('#startGo')) && startBody === null);
278
295
  await p.click('#startBtn'); await p.click('#startGo');
279
- ok('W8 confirming starts a draft session for that initiative, closes the dialog and raises the sessions badge', await until(() => startBody && p.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && !document.querySelector('#sessBdg').hidden)) && startBody.task === 'draft' && !!startBody.initiative && !!startBody.what, JSON.stringify(startBody));
296
+ ok('W8 confirming starts a draft session for that initiative and closes the dialog', await until(() => startBody && p.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))) && startBody.task === 'draft' && !!startBody.initiative && !!startBody.what, JSON.stringify(startBody));
280
297
  await p.unroute('**/api/agent/start');
281
298
  await row0.focus(); await row0.press('Enter');
282
299
  await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
@@ -1,4 +1,16 @@
1
1
  [
2
+ {
3
+ "v": "0.353.0",
4
+ "at": "2026-10-20T08:29:44.242Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 951,
9
+ "t": "Sessions listed beside the chat, grouped like Slack",
10
+ "s": "In full screen, the chat dialog has three panels: the session list on the left, the chat in the middle and the viewer on the right."
11
+ }
12
+ ]
13
+ },
2
14
  {
3
15
  "v": "0.352.0",
4
16
  "at": "2026-10-20T08:20:25.043Z",
@@ -18,7 +18,7 @@ Every premium page has the same top bar. On the left is where you are, then a ro
18
18
  - **Chat** opens a conversation with Claude about the page you are on: the Briefing, My work, the board, or the initiative. On Insights, Chat opens the Insight Studio, because the Studio is that page's chat.
19
19
  - **Sources** has a green dot when every source was read recently, and an orange dot when a source is old, was never read, failed, or the page could not read it. Hover to see which. A press opens the Sources dialog (see "Sources" below).
20
20
  - **The bell** is your inbox of agent results: see [The bell: what the agent has for you](#the-bell-what-the-agent-has-for-you).
21
- - **The ⋯ menu** holds **Search** (Ctrl K), **Agent sessions** with a count, **Console**, **Theme** (Light, Dark or Auto) and **Settings**. On the Board it also holds **Open initiatives** as Page or Popup. An orange dot on ⋯ means a newer PMOS is ready, and **Settings** then shows the version.
21
+ - **The ⋯ menu** holds **Search** (Ctrl K), **Sessions** with a count of the sessions that need you, **Console**, **Theme** (Light, Dark or Auto) and **Settings**. On the Board it also holds **Open initiatives** as Page or Popup. An orange dot on ⋯ means a newer PMOS is ready, and **Settings** then shows the version.
22
22
  - **On a phone** the bar is one row: the page name, Chat, the bell and ⋯. Sources moves into the ⋯ menu.
23
23
  - **Menus.** An option that is too long for one line wraps onto the next line, and its row grows to hold it.
24
24
 
@@ -26,7 +26,16 @@ Every premium page has the same top bar. On the left is where you are, then a ro
26
26
 
27
27
  **Sources** is a dialog that lists each tracked source (Repository, Initiatives, Calendar, Jira status, My work and Tracker items) with its own state and the time it was last read. Each source except the repository has **Refresh**, and **Refresh all** reads them all again. Slack and email are read as part of My work, so they have no row of their own. A source PMOS does not track has no row: the dialog shows only what PMOS can say it read.
28
28
 
29
- **Agent sessions** in the ⋯ menu shows a count of the sessions running. It opens a dialog that lists each running session and background run with its note, state and start time. **Stop** asks first and says what it ends, then ends the session and closes its terminal. If the session has not exited yet, the row says so and offers Stop again. When more than six agents are working at once, a note at the top says how many and that many at once can slow this computer, and suggests stopping the ones you are not watching. It is only a note: nothing is stopped for you. When a session has asked a question, its row shows the question in the agent's own words with the options it offered; a press sends that option as your answer, and the question leaves the row. A permission request ("Wants to run"), terminals and new sessions stay in the console; the dialog links to it. Answering needs the page's launch nonce, so an agent session cannot call it.
29
+ **Sessions** lists every running session beside the chat. When a chat dialog is full screen on a desktop, it has three panels: the session list, the conversation and the viewer.
30
+
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
+ - **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
+ - **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.
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
+ - **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
+ - 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.
38
+ - Terminals and new sessions stay in the console. Writing, answering and Stop need the page's launch nonce, so an agent session cannot call them.
30
39
 
31
40
  ## Products
32
41
 
@@ -233,7 +242,7 @@ Each button writes one record, through a check that only a real press from this
233
242
 
234
243
  Later today means three hours from now. Tomorrow and Next week mean 09:00, tomorrow and next Monday.
235
244
 
236
- A decision needs your reason. A prototype or tripwire that already has a decision on record cannot be decided again from this page. A decided row leaves the list because the record changed. A merge has no run of its own, so its return button stays off and says so. The Start button on a blocked row asks you to confirm, then starts an agent session that drafts the next step. The session is listed in Agent sessions.
245
+ A decision needs your reason. A prototype or tripwire that already has a decision on record cannot be decided again from this page. A decided row leaves the list because the record changed. A merge has no run of its own, so its return button stays off and says so. The Start button on a blocked row asks you to confirm, then starts an agent session that drafts the next step. The session is listed in Sessions.
237
246
 
238
247
  ## Asking the agent
239
248
 
@@ -393,7 +402,7 @@ The conversation beside every premium dialog is a real Claude Code session. Anyt
393
402
  - **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.
394
403
  - **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.
395
404
  - **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.
396
- - **The session** is also listed in **Agent sessions** and in the console, where you can open its terminal. When it has ended, your next message starts a new one.
405
+ - **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.
397
406
  - Answers from the older read-only agent stay above the session, marked "Earlier read-only answer".
398
407
 
399
408
  Sending and the option presses need the page's launch nonce, so an agent session cannot type into your chat.
@@ -180,7 +180,7 @@ function chat({ runtimeDir, key, text, model, sessions, wsId, now = new Date() }
180
180
  if (cmd) { const b = Goal.begin({ runtimeDir, key, text: cmd.text, now }); if (b.error) return fail(400, b.error); msg = b.prompt; goal = b.id; }
181
181
  const extra = goal ? { goal } : {};
182
182
  if (alive) {
183
- if (!sessions.type(live, msg)) return fail(409, 'The message did not reach the session. Open it in Agent sessions.');
183
+ if (!sessions.type(live, msg)) return fail(409, 'The message did not reach the session. Open it in Sessions.');
184
184
  if (!goal) Goal.resume({ runtimeDir, key, now }); // slice 3: the PM's answer to a goal that needs them sets it going again; a finished one is seen
185
185
  return { status: 200, body: { ok: true, session: live, started: false, ...extra } };
186
186
  }
@@ -74,7 +74,7 @@ const fmRows = (fm) => (fm ? [['Lane', fm.lane], ['Anchor', fm.parent_kr], ['Sta
74
74
 
75
75
  /* A record the builder cannot read must cost its own row or dialog and nothing more. tryD gives a dialog or null; a record that throws is skipped and counted,
76
76
  * and the header says how many (never silently). */
77
- const START_NOTE = 'Starting opens an agent session that drafts this for you to read. It sends nothing outside PMOS and you can stop it in Agent sessions.';
77
+ const START_NOTE = 'Starting opens an agent session that drafts this for you to read. It sends nothing outside PMOS and you can stop it in Sessions.';
78
78
  const tryD = (fn) => { try { return fn(); } catch { return null; } };
79
79
  const skipped = { n: 0 };
80
80
 
@@ -80,6 +80,15 @@ function goalOf(runtimeDir, key) {
80
80
  }
81
81
  return g;
82
82
  }
83
+ /** Every key's goal state in one read: { <key>: { state, rounds, limit } } (premium-session-list L1: the session list's Goals group). */
84
+ function statesAt(runtimeDir) {
85
+ let t; try { t = fs.readFileSync(path.join(runtimeDir, RUNS), 'utf8'); } catch { return {}; }
86
+ const keys = new Set();
87
+ for (const l of t.split('\n')) { if (!l.trim()) continue; try { const e = JSON.parse(l); if (e && typeof e.key === 'string') keys.add(e.key); } catch { /* skip */ } }
88
+ const out = {};
89
+ for (const key of keys) { const g = goalOf(runtimeDir, key); if (g) out[key] = { state: g.state, rounds: g.rounds || 0, limit: (g.draft && g.draft.limit) || LIMIT }; }
90
+ return out;
91
+ }
83
92
 
84
93
  /* ── slice 3: until achieved (PRD U1–U7) ───────────────────────────────────────────────────────────────────────────────
85
94
  * Claude Code's Stop hook posts here each time Claude would end its turn in a chat session. While the key's goal is started
@@ -215,9 +224,9 @@ function decide({ runtimeDir, key, id, act, draft, session, sessions, now = new
215
224
  if (!session || !sessions || !sessions.alive(session)) return fail(409, 'No session is running for this conversation. Send /goal again to start one.');
216
225
  let d = null;
217
226
  if (act === 'start') { d = cleanDraft(draft); if (!d) return fail(400, 'The goal needs a sentence and at least one done point before it can start.'); }
218
- if (!sessions.type(session, act === 'start' ? startMessage(d) : cancelMessage())) return fail(409, 'The message did not reach the session. Open it in Agent sessions.');
227
+ if (!sessions.type(session, act === 'start' ? startMessage(d) : cancelMessage())) return fail(409, 'The message did not reach the session. Open it in Sessions.');
219
228
  append(runtimeDir, { event: act === 'start' ? 'started' : 'cancelled', id, key, ...(d ? { draft: d } : {}), at: now.toISOString() });
220
229
  return { status: 200, body: { ok: true, id, state: act === 'start' ? 'started' : 'cancelled' } };
221
230
  }
222
231
 
223
- module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
232
+ module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
@@ -126,6 +126,11 @@ module.exports = {
126
126
  if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
127
127
  return post(req, res, url, ctx);
128
128
  }
129
+ if (url.pathname === '/api/briefing-premium/goals') { // premium-session-list L1: every conversation's goal state, for the session list's Goals group
130
+ if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
131
+ ctx.json(res, { ok: true, goals: ctx.runtimeDir ? Goal.statesAt(ctx.runtimeDir) : {} });
132
+ return true;
133
+ }
129
134
  if (url.pathname === '/api/briefing-premium/thread') {
130
135
  if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
131
136
  const key = url.searchParams.get('key') || '';
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.352.0",
3
+ "version": "0.353.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.352.0",
9
+ "version": "0.353.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.352.0",
3
+ "version": "0.353.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",
@@ -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 { railModel, railHtml, teaser, menuCount, loudestRow, factsOf, titleOf, DOT, WORD } from './session-rail.js';
10
11
  export const $ = (s, r = document) => r.querySelector(s);
11
12
  export const $$ = (s, r = document) => [...r.querySelectorAll(s)];
12
13
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
@@ -14,7 +15,7 @@ export const RM = matchMedia('(prefers-reduced-motion: reduce)').matches;
14
15
  export const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* no storage */ } } };
15
16
  export const THEME_KEY = 'pmos.c3.theme';
16
17
  export const AI = '<svg class="i" viewBox="0 0 24 24"><path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/></svg>';
17
- export const S = { key: null }; // the key of the row whose dialog is open (the agent's thread belongs to it)
18
+ export const S = { key: null, sid: null }; // the key of the row whose dialog is open (the agent's thread belongs to it); sid: a session the list opened that has no row (premium-session-list)
18
19
  let lastFocus = null;
19
20
  /* ── theme ──────────────────────────────────────────────────────────────────────────────────────────────── */
20
21
  export function theme(t) {
@@ -27,7 +28,7 @@ export function flip() {
27
28
  }
28
29
  { const t = new URLSearchParams(location.search).get('theme') || store.get(THEME_KEY); theme(t); }
29
30
  /* ── the top bar (initiative premium-topbar): where you are and Chat on the left; the Sources chip, the bell and one menu on the right.
30
- * The menu holds what left the bar: Search, Agent sessions, Console, Theme, Settings, and on Board how an initiative opens. Every item keeps
31
+ * The menu holds what left the bar: Search, Sessions, Console, Theme, Settings, and on Board how an initiative opens. Every item keeps
31
32
  * the id the pages and the code below wire, so a press does what it did as a round button. ── */
32
33
  export const CHAT = '<svg class="i" viewBox="0 0 24 24"><path d="M4 5h16v11h-9l-5 4v-4H4z"/><path d="M12 7.6l.8 1.9 1.9.8-1.9.8-.8 1.9-.8-1.9-1.9-.8 1.9-.8z"/></svg>';
33
34
  const MORE = '<svg class="i" viewBox="0 0 24 24"><circle cx="6" cy="12" r="1.3"/><circle cx="12" cy="12" r="1.3"/><circle cx="18" cy="12" r="1.3"/></svg>';
@@ -40,7 +41,7 @@ function tbMount() {
40
41
  + '<div class="crmenu tbmenu" id="moreMenu" role="menu" aria-label="More" hidden>'
41
42
  + '<button role="menuitem" id="pvSearch" aria-haspopup="dialog">Search<em>Ctrl K</em></button>'
42
43
  + '<button role="menuitem" id="srcItem" class="tbm-src" aria-haspopup="dialog">Sources</button>'
43
- + '<button role="menuitem" id="sessBtn" aria-haspopup="dialog" aria-label="Agent sessions">Agent sessions<em id="sessBdg" hidden></em></button>'
44
+ + '<button role="menuitem" id="sessBtn" aria-haspopup="dialog" aria-label="Sessions">Sessions<em id="sessBdg" hidden></em></button>'
44
45
  + '<a role="menuitem" id="toConsole" href="/console.html" aria-label="Open the console">Console</a>'
45
46
  + '<div class="tbrow" id="modeRow" hidden><span>Open initiatives</span></div>'
46
47
  + `<div class="tbrow" role="group" aria-label="Theme"><span>Theme</span><span class="tbseg" id="tbTheme">${TH.map(([k, w]) => `<button role="menuitemradio" data-th="${k}" aria-checked="false">${w}</button>`).join('')}</span></div>`
@@ -157,7 +158,7 @@ export function openPageChat(key, page) {
157
158
  $('#askIn').placeholder = 'Message Claude about this page';
158
159
  loadThread(key);
159
160
  }
160
- tbMount(); // the top bar first: the menu holds the Settings, Agent sessions, Console and Search items the code below wires
161
+ tbMount(); // the top bar first: the menu holds the Settings, Sessions, Console and Search items the code below wires
161
162
  { const t2 = $('#theme2'); if (t2) t2.onclick = flip; }
162
163
  { const b = $('#settingsBtn'); if (b) b.onclick = () => openSettings(); } // hoisted: the function below is declared, not assigned
163
164
 
@@ -197,10 +198,11 @@ export function openDlg(o) {
197
198
  $('#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
198
199
  $('#veil').classList.add('on'); $('#dlg').classList.add('on');
199
200
  $$('#dGrid .pane').forEach((p) => { p.scrollTop = 0; });
201
+ railOnOpen(o);
200
202
  setTimeout(() => $('#dlg').focus(), 60);
201
203
  }
202
204
  export function closeDlg() {
203
- clearTimeout(threadTimer); S.key = null;
205
+ clearTimeout(threadTimer); S.key = null; railOnClose();
204
206
  park();
205
207
  $('#veil').classList.remove('on'); $$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; });
206
208
  $('#dlg').inert = true; document.documentElement.style.overflow = ''; $('#dlg').classList.remove('on');
@@ -216,7 +218,7 @@ export function setMode(m) {
216
218
  if (innerWidth < 1000) setTab(m === 'detail' ? 'out' : 'chat');
217
219
  }
218
220
  $('#dPane').onclick = () => setMode($('#dlg').dataset.mode === 'split' ? 'detail' : 'split');
219
- export function setFull(f) { $('#dlg').classList.toggle('full', f); const b = $('#dExpand'); b.setAttribute('aria-pressed', f); b.title = f ? 'Exit full screen' : 'Full screen'; $('#dExpP').setAttribute('d', f ? 'M20 10h-6V4M4 14h6v6M14 10l7-7M3 21l7-7' : 'M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7'); }
221
+ export function setFull(f) { $('#dlg').classList.toggle('full', f); $('#dlg').classList.remove('srl-open'); if (R.model) railDraw(); if (f) { railRead(); railTick(); } const b = $('#dExpand'); b.setAttribute('aria-pressed', f); b.title = f ? 'Exit full screen' : 'Full screen'; $('#dExpP').setAttribute('d', f ? 'M20 10h-6V4M4 14h6v6M14 10l7-7M3 21l7-7' : 'M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7'); }
220
222
  $('#tabGo').onclick = () => setTab('chat');
221
223
  $('#dClose').onclick = closeDlg; $('#veil').onclick = closeDlg;
222
224
  $('#dExpand').onclick = () => setFull(!$('#dlg').classList.contains('full'));
@@ -311,8 +313,9 @@ function readyDraft(conv) {
311
313
  }
312
314
  const chatPost = (act, body) => { const ws = new URLSearchParams(location.search).get('ws'); return pmPost('/api/briefing-premium/' + act + (ws ? '?ws=' + encodeURIComponent(ws) : ''), body).catch(() => null); };
313
315
  $('#dBody').addEventListener('click', async (e) => {
314
- const p = e.target.closest('[data-chat-press]'); if (!p || !S.key) return;
316
+ const p = e.target.closest('[data-chat-press]'); if (!p || (!S.key && !S.sid)) return;
315
317
  p.disabled = true;
318
+ if (S.sid) { const id = S.sid, r = await pmPost('/api/session/keys', { id, press: p.dataset.chatPress }); if (!r || !r.ok) $('#askNote').textContent = (r && r.error) || 'The key did not reach the session.'; setTimeout(() => loadSid(id), 500); return; }
316
319
  const r = await chatPost('press', { key: S.key, press: p.dataset.chatPress });
317
320
  if (!r || !r.ok) $('#askNote').textContent = (r && r.error) || 'The key did not reach the session.';
318
321
  setTimeout(() => loadThread(S.key), 500);
@@ -380,6 +383,12 @@ $('#dBody').addEventListener('keydown', (e) => {
380
383
  $('#dBody').addEventListener('submit', async (e) => {
381
384
  e.preventDefault();
382
385
  const inp = $('#askIn'), text = inp.value.trim(), key = S.key;
386
+ if (!key && S.sid) { // premium-session-list: a session the list opened that has no row of its own
387
+ if (!text) { $('#askNote').textContent = 'Write a message for Claude.'; return; }
388
+ const id = S.sid, r = await pmPost('/api/session/say', { id, text });
389
+ if (!r || !r.ok) { $('#askNote').textContent = (r && r.error) || 'The message was not sent.'; return; }
390
+ inp.value = ''; $('#askNote').textContent = 'Sent.'; drawSlash(); setTimeout(() => loadSid(id), 400); return;
391
+ }
383
392
  if (!key) { $('#askNote').textContent = 'This row has no conversation, so the message was not sent.'; return; }
384
393
  if (!text) { $('#askNote').textContent = 'Write a message for Claude.'; return; }
385
394
  if (await sendText(key, text)) { inp.value = ''; inp.placeholder = 'Message Claude, or type /'; drawSlash(); }
@@ -851,76 +860,152 @@ export async function openSettings() {
851
860
  await load();
852
861
  }
853
862
 
854
- /* ── Agent sessions: the running list with Stop (initiative premium-sessions) ──────────────────────────────────────────────────────────────
855
- * Reads GET /api/sessions, the list the console dock reads. The one write is POST /api/session/remove, a page press. A session's terminal, a new
856
- * session and a run's questions stay in the console. Every word on a row is a field of the session record. */
857
- const sessLive = (s) => s && s.shown !== 'exited';
858
- const SESS_MANY = 6; // more agents than this working at once earns the soft warning in the Sessions dialog
859
- const sessWorking = (l) => l.filter((x) => x.shown === 'working').length;
860
- const readSessions = async () => { const r = await pmGet('/api/sessions'); return r && Array.isArray(r.sessions) ? r.sessions.filter(sessLive) : null; };
861
- // The cards the console's run card reads (GET /api/runs): a session whose card is asking carries the agent's own question and the options it offered.
862
- const readAsks = async () => { const r = await pmGet('/api/runs'); const out = {}; if (r && r.ok && r.cards) for (const [id, c] of Object.entries(r.cards)) if (c && c.state === 'asking' && c.ask && c.ask.q && Array.isArray(c.ask.options) && c.ask.options.length) out[id] = { request: c.asked || c.ask.id, q: c.ask.q, options: c.ask.options }; return out; };
863
- const sessAgo = (t) => { const ms = Date.now() - new Date(t).getTime(); if (!(ms >= 0)) return ''; const m = Math.max(1, Math.round(ms / 60000)); return 'Started ' + (m < 60 ? m + ' min ago' : Math.floor(m / 60) + ' h ' + (m % 60) + ' min ago'); };
864
- function sessBadge(n) { const b = $('#sessBdg'); if (!b) return; b.textContent = String(n || ''); b.hidden = !n; const a = $('#sessBtn'); if (a) a.setAttribute('aria-label', 'Agent sessions, ' + (n ? n + ' running' : 'none running')); }
863
+ /* ── Sessions: the list beside the chat (initiative premium-session-list; PM decisions 2026-10-20) ─────────────────────────────────────────
864
+ * In full screen the dialog has three panels: the session list, the conversation and the viewer; the list and the viewer fold. A normal-size
865
+ * chat dialog shows a chip that opens the list. The list reads GET /api/sessions (the list the console dock reads) and the goals of the chat
866
+ * conversations; lib/session-rail.js groups them. Pressing a row switches the dialog to that session: a chat row opens its own conversation,
867
+ * any other session its transcript. The writes are a page press each: a message or a key (POST /api/session/say|keys), Stop (/api/session/remove)
868
+ * and an answer to a run's question (/api/runs/answer). The Agent sessions popup this replaces is gone; the ⋯ menu's Sessions opens this. */
869
+ const R = { rows: [], goals: {}, model: null, sel: null, shut: [], showAll: false, timer: null, asks: {}, ask: null, busy: false, slow: null, err: '', sidTimer: null,
870
+ railMin: store.get('pmos.srl.rail') === 'min', viewMin: store.get('pmos.srl.view') === 'min' };
871
+ const SRL_POLL = 3000, BADGE_POLL = 15000;
872
+ const desk = () => innerWidth >= 1000;
873
+ const railShowing = () => $('#dlg').classList.contains('on') && $('#dlg').classList.contains('srl-on') && ($('#dlg').classList.contains('full') ? desk() : $('#dlg').classList.contains('srl-open'));
874
+ function railMount() {
875
+ const g = $('#dGrid'); if (!g || $('#sRail')) return;
876
+ g.insertAdjacentHTML('afterbegin', `<aside class="srl" id="sRail" aria-label="Sessions"><div class="srl-hd"><b>Sessions</b><button type="button" class="srl-fold" id="srlFold" aria-label="Fold the list" title="Fold the list"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="M9 4v16"/></svg></button></div><div class="srl-list" id="srlList"></div><div class="srl-lg" aria-hidden="true"><span><i class="sdot2 ready"></i>Ready</span><span><i class="sdot2 run"></i>Running</span><span><i class="sdot2 blk"></i>Maybe blocked</span></div></aside>`);
877
+ $('#dlg .dtools').insertAdjacentHTML('afterbegin', '<button type="button" class="stease" id="sTease" aria-haspopup="true" hidden><i class="sdot2" aria-hidden="true"></i><span>Sessions</span><em></em></button>');
878
+ 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>');
879
+ $('#srlFold').onclick = () => { R.railMin = !R.railMin; store.set('pmos.srl.rail', R.railMin ? 'min' : 'open'); railLayout(); };
880
+ $('#vFold').onclick = () => { R.viewMin = !R.viewMin; store.set('pmos.srl.view', R.viewMin ? 'min' : 'open'); railLayout(); };
881
+ $('#sTease').onclick = () => {
882
+ if (desk()) { setFull(true); railLayout(); railRead(); return; }
883
+ $('#dlg').classList.toggle('srl-open'); railDraw(); if ($('#dlg').classList.contains('srl-open')) railRead();
884
+ };
885
+ $('#srlList').onclick = (e) => {
886
+ const gh = e.target.closest('[data-sg]'), mo = e.target.closest('[data-smore]'), r = e.target.closest('[data-sid]');
887
+ if (mo) { R.showAll = !R.showAll; railDraw(); return; }
888
+ if (gh) { if (R.railMin) { R.railMin = false; store.set('pmos.srl.rail', 'open'); railLayout(); return; } const k = gh.dataset.sg; R.shut = R.shut.includes(k) ? R.shut.filter((x) => x !== k) : [...R.shut, k]; railDraw(); return; }
889
+ if (r) pickSession(r.dataset.sid);
890
+ };
891
+ }
892
+ function railLayout() {
893
+ const d = $('#dlg');
894
+ d.classList.toggle('srl-min', R.railMin); d.classList.toggle('vw-min', R.viewMin);
895
+ const f = $('#srlFold'), v = $('#vFold');
896
+ if (f) { f.title = R.railMin ? 'Open the list' : 'Fold the list'; f.setAttribute('aria-label', f.title); f.setAttribute('aria-pressed', String(R.railMin)); }
897
+ if (v) { v.title = R.viewMin ? 'Open the viewer' : 'Fold the viewer'; v.setAttribute('aria-label', v.title); v.setAttribute('aria-pressed', String(R.viewMin)); }
898
+ }
899
+ function railDraw() {
900
+ const m = R.model = railModel(R.rows, R.goals, { showAll: R.showAll });
901
+ const l = $('#srlList'); if (l) l.innerHTML = railHtml(m, { sel: R.sel, shut: R.shut, showAll: R.showAll });
902
+ const t = $('#sTease'), tz = teaser(m);
903
+ if (t) {
904
+ t.hidden = !tz || !t.dataset.on || $('#dlg').classList.contains('full');
905
+ if (tz) { $('i', t).className = 'sdot2 ' + tz.dot; $('em', t).textContent = tz.text; t.setAttribute('aria-label', 'Sessions, ' + tz.text + '. Switch between sessions'); t.title = 'Switch between sessions'; t.setAttribute('aria-expanded', String($('#dlg').classList.contains('srl-open'))); }
906
+ }
907
+ sessBadge(menuCount(R.rows));
908
+ }
909
+ async function railRead() {
910
+ const [s, g] = await Promise.all([pmGet('/api/sessions').catch(() => null), pmGet('/api/briefing-premium/goals').catch(() => null)]);
911
+ if (s && Array.isArray(s.sessions)) R.rows = s.sessions;
912
+ if (g && g.ok && g.goals) R.goals = g.goals;
913
+ if (R.sel && !R.rows.some((x) => x.id === R.sel && x.shown !== 'exited') && S.sid === R.sel) { S.sid = null; sessionCard(null); }
914
+ railDraw();
915
+ }
916
+ function railTick() { clearTimeout(R.timer); R.timer = setTimeout(async () => { if (!document.hidden && railShowing()) await railRead(); railTick(); }, SRL_POLL); }
917
+ /** openDlg calls this: a dialog with a conversation shows the chip; the list marks the session this dialog's conversation runs in. */
918
+ function railOnOpen(o) {
919
+ railMount(); clearTimeout(R.sidTimer); S.sid = null; R.ask = null; R.slow = null; R.err = '';
920
+ $('#dlg').classList.remove('srl-open');
921
+ const t = $('#sTease'); if (t) { if (o.noteKey || o.sessions) t.dataset.on = '1'; else delete t.dataset.on; }
922
+ $('#dlg').classList.toggle('srl-on', !!(o.noteKey || o.sessions)); // only a dialog with a conversation gets the list
923
+ R.sel = o.noteKey ? ((R.rows.find((x) => x.origin === 'chat:' + o.noteKey && x.shown !== 'exited') || {}).id || null) : null;
924
+ railLayout(); railDraw(); railRead().then(() => { if (o.noteKey && !R.sel) { R.sel = (R.rows.find((x) => x.origin === 'chat:' + o.noteKey && x.shown !== 'exited') || {}).id || null; railDraw(); } });
925
+ railTick();
926
+ }
927
+ function railOnClose() { clearTimeout(R.timer); clearTimeout(R.sidTimer); S.sid = null; $('#dlg').classList.remove('srl-open'); }
928
+ /** Switch the dialog to one session. A chat row is its own conversation (key); any other session is read from its transcript (S.sid). */
929
+ function pickSession(id) {
930
+ const r = (R.model && R.model.rows.find((x) => x.id === id)) || null; if (!r) return;
931
+ clearTimeout(R.sidTimer); R.sel = id; R.ask = null; R.slow = null; R.err = '';
932
+ $('#dlg').classList.remove('srl-open');
933
+ $('#dEye').textContent = r.group === 'pmos' ? 'Started by PMOS' : r.goal ? 'Goal' : 'Session'; $('#dTitle').textContent = r.name; $('#dSub').hidden = true;
934
+ const st = $('#dBody .stream'); if (st) st.innerHTML = '';
935
+ $('#askF').hidden = !!r.headless; $('#askIn').value = ''; $('#askIn').placeholder = r.key ? 'Message Claude, or type /' : 'Message this session';
936
+ if (r.key) { S.sid = null; S.key = r.key; loadThread(r.key); } else { S.key = null; S.sid = id; loadSid(id); }
937
+ sessionCard(r); railDraw();
938
+ if (!desk()) setTab('chat');
939
+ const go = $('#askIn'); if (go && !r.headless && desk()) go.focus();
940
+ }
941
+ async function loadSid(id) {
942
+ clearTimeout(R.sidTimer);
943
+ const c = await pmGet('/api/sessions/conversation?id=' + encodeURIComponent(id)).catch(() => null);
944
+ if (S.sid !== id) return;
945
+ const box = $('#dBody .stream'); if (!box) return;
946
+ const b = $('#dBody'), atEnd = b.scrollHeight - b.scrollTop - b.clientHeight < 80;
947
+ box.innerHTML = c && c.ok ? sessionHtml(c) : turnA(ptx('The conversation of this session could not be read.'));
948
+ $('#askNote').textContent = c && c.ask ? 'Claude is waiting for your answer above.' : 'Your message goes to this session.';
949
+ if (atEnd) b.scrollTop = b.scrollHeight;
950
+ if (c && c.ok && c.state !== 'ended' && $('#dlg').classList.contains('on')) R.sidTimer = setTimeout(() => loadSid(id), 2000);
951
+ }
952
+ /* the viewer for a session the list opened: its facts, the question a run asks, and Stop (asks first; says so when it has not exited yet) */
953
+ async function sessionCard(r) {
954
+ vwReset(); $('#oLab').textContent = 'Session';
955
+ if (!r) { $('#oMain').innerHTML = '<article class="paper doc"><p class="note">This session has ended. Pick another from the list.</p></article>'; return; }
956
+ const runs = await pmGet('/api/runs').catch(() => null); R.asks = {};
957
+ if (runs && runs.ok && runs.cards) for (const [k, c] of Object.entries(runs.cards)) if (c && c.state === 'asking' && c.ask && c.ask.q && Array.isArray(c.ask.options) && c.ask.options.length) R.asks[k] = { request: c.asked || c.ask.id, q: c.ask.q, options: c.ask.options };
958
+ cardDraw(r);
959
+ }
960
+ function cardDraw(r) {
961
+ if (R.sel !== r.id) return;
962
+ const q = R.asks[r.id], what = r.headless ? 'This ends the background run.' : 'This ends the session and closes its terminal.';
963
+ $('#oMain').innerHTML = `<article class="paper doc scard"><p class="scs"><i class="sdot2 ${DOT[r.state]}" aria-hidden="true"></i>${esc(WORD[r.state])}</p><h3 class="d2">${esc(r.name)}</h3>${kv(factsOf(r))}
964
+ ${q ? `<div class="ssc ssq" role="group" aria-label="${esc(r.name)} asks"><p><b>${esc(q.q)}</b></p><div class="ssx">${q.options.map((o) => `<button type="button" class="cta${o.rec ? '' : ' alt'}" data-ans="${esc(o.label)}"${R.busy ? ' disabled' : ''}>${esc(o.label)}</button>`).join('')}</div></div>` : ''}
965
+ ${R.ask ? `<div class="ssc" role="group" aria-label="Confirm stop"><p><b>Stop “${esc(r.name)}”?</b> ${what} Files it already wrote stay where they are.</p><div class="ssx"><button type="button" class="cta bad" data-yes="1">Stop</button><button type="button" class="cta alt" data-no="1">Keep running</button></div></div>`
966
+ : R.slow ? `<div class="ssc" role="group" aria-label="Still running"><p><b>Asked “${esc(r.name)}” to end.</b> It has not exited yet. Press Stop again to remove it.</p><div class="ssx"><button type="button" class="cta bad" data-yes="1">Stop again</button><button type="button" class="cta alt" data-no="1">Keep running</button></div></div>`
967
+ : `<div class="ssx"><button type="button" class="cta alt" data-stop="1"${R.busy ? ' disabled' : ''}>${R.busy ? 'Ending…' : 'Stop'}</button></div>`}
968
+ <p class="note" role="status">${esc(R.err)}</p><p class="note">Its terminal is in the console. <a href="/console.html">Open the console</a>.</p></article>`;
969
+ }
970
+ $('#oMain').addEventListener('click', async (e) => {
971
+ const card = e.target.closest('.scard'); if (!card || R.busy) return;
972
+ const r = R.model && R.model.rows.find((x) => x.id === R.sel); if (!r) return;
973
+ const an = e.target.closest('[data-ans]'), st = e.target.closest('[data-stop]'), yes = e.target.closest('[data-yes]'), no = e.target.closest('[data-no]');
974
+ R.err = '';
975
+ if (an) {
976
+ const a = R.asks[r.id]; if (!a) return;
977
+ R.busy = true; cardDraw(r);
978
+ const res = await pmPost('/api/runs/answer', { run: r.id, request: a.request, behavior: 'answer', message: an.dataset.ans }); R.busy = false;
979
+ if (res && res.ok) { toast('Answered. The agent continues with your choice.'); delete R.asks[r.id]; } else R.err = (res && (res.error || res.reason)) || 'Not answered.';
980
+ cardDraw(r); return;
981
+ }
982
+ if (st) { R.ask = true; cardDraw(r); const k = $('#oMain [data-no]'); if (k) k.focus(); return; }
983
+ if (no) { R.ask = null; R.slow = null; cardDraw(r); return; }
984
+ if (yes) {
985
+ R.busy = true; R.ask = null; R.slow = null; cardDraw(r);
986
+ const res = await pmPost('/api/session/remove', { id: r.id }); R.busy = false;
987
+ if (res && res.ok && res.removed === false) R.slow = true; // asked to end, not exited yet: say so, never claim an end that did not happen
988
+ else if (res && res.ok) { toast('Ended “' + r.name + '”.'); R.rows = R.rows.filter((x) => x.id !== r.id); if (S.sid === r.id) S.sid = null; R.sel = null; railDraw(); sessionCard(null); railRead(); return; }
989
+ else R.err = (res && (res.error || res.reason)) || 'Not stopped.';
990
+ cardDraw(r);
991
+ }
992
+ });
993
+ function sessBadge(n) { const b = $('#sessBdg'); if (!b) return; b.textContent = String(n || ''); b.hidden = !n; const a = $('#sessBtn'); if (a) a.setAttribute('aria-label', 'Sessions, ' + (n ? n + ' need you' : 'none need you')); }
865
994
  {
866
995
  const b = $('#sessBtn');
867
996
  if (b) {
868
997
  b.onclick = () => openSessions();
869
- const poll = async () => { if (document.hidden) return; const l = await readSessions(); if (l) sessBadge(l.length); };
870
- poll(); setInterval(poll, 15000);
998
+ const poll = async () => { if (document.hidden || railShowing()) return; const s = await pmGet('/api/sessions').catch(() => null); if (s && Array.isArray(s.sessions)) { R.rows = s.sessions; sessBadge(menuCount(R.rows)); } };
999
+ poll(); setInterval(poll, BADGE_POLL);
871
1000
  }
872
1001
  }
1002
+ /** The ⋯ menu's Sessions: the chat panel, full screen with the list (the list itself on a phone), on the session that needs you most. */
873
1003
  export async function openSessions() {
874
- const M = { list: null, ask: null, busy: null, slow: null, done: null, err: '', asks: {}, ans: null };
875
- const draw = () => {
876
- const l = M.list, n = l ? l.length : 0;
877
- $('#dTitle').textContent = l === null ? 'Agent sessions' : n ? n + ' running' : 'None running';
878
- const rows = l === null ? '<p class="note">Reading the sessions.</p>' : n ? `<ul class="ssl">${l.map((x) => {
879
- if (M.done && M.done.id === x.id) return `<li class="ssr"><p class="ssdone">Ended “${esc(x.name)}”.</p></li>`;
880
- const busy = M.busy === x.id, ask = M.ask === x.id, slow = M.slow === x.id;
881
- const what = x.headless ? 'This ends the background run.' : 'This ends the session and closes its terminal.';
882
- return `<li class="ssr"${busy ? ' aria-busy="true"' : ''}><i class="ssd ${esc(x.shown || '')}" aria-hidden="true"></i>
883
- <div class="ssb"><h3>${esc(x.name)}</h3><p class="ssn">${esc(x.note || 'No note')}</p>
884
- <p class="ssm">${[x.headless ? 'Background run' : '', x.agent, x.label, x.cwd, sessAgo(x.created), x.automatic ? 'Started by PMOS' : ''].filter(Boolean).map((t) => `<span>${esc(t)}</span>`).join('')}</p></div>
885
- <button type="button" class="cta alt" data-stop="${esc(x.id)}" aria-label="Stop ${esc(x.name)}"${ask || busy || slow ? ' disabled' : ''}>${busy ? 'Ending…' : 'Stop'}</button>
886
- ${M.asks[x.id] ? `<div class="ssc ssq" role="group" aria-label="${esc(x.name)} asks"><p><b>${esc(M.asks[x.id].q)}</b></p><div class="ssx">${M.asks[x.id].options.map((o) => `<button type="button" class="cta${o.rec ? '' : ' alt'}" data-ans="${esc(x.id)}" data-opt="${esc(o.label)}"${M.ans ? ' disabled' : ''}>${esc(o.label)}</button>`).join('')}</div></div>` : ''}
887
- ${ask && !busy ? `<div class="ssc" role="group" aria-label="Confirm stop"><p><b>Stop “${esc(x.name)}”?</b> ${what} Files it already wrote stay where they are.</p><div class="ssx"><button type="button" class="cta bad" data-yes="${esc(x.id)}">Stop</button><button type="button" class="cta alt" data-no="${esc(x.id)}">Keep running</button></div></div>` : ''}
888
- ${slow ? `<div class="ssc" role="group" aria-label="Still running"><p><b>Asked “${esc(x.name)}” to end.</b> It has not exited yet. Press Stop again to remove it.</p><div class="ssx"><button type="button" class="cta bad" data-yes="${esc(x.id)}">Stop again</button><button type="button" class="cta alt" data-no="${esc(x.id)}">Keep running</button></div></div>` : ''}</li>`;
889
- }).join('')}</ul>` : '<div class="sse"><b>No agent sessions running.</b><p>New sessions start in the console.</p></div>';
890
- const w = l ? sessWorking(l) : 0;
891
- const warn = w > SESS_MANY ? `<p class="note ssw" role="status"><b>${w} agents are working at once.</b> Each one is a program running on this computer, so many at once can slow it. Stop the ones you are not watching.</p>` : '';
892
- $('#oMain').innerHTML = `<article class="paper doc"><div class="addf">${warn}${rows}
893
- <p class="note" id="ssM" role="status" style="margin:0;min-height:1.2em">${esc(M.err)}</p>
894
- <p class="note" style="margin:0">Terminals and new sessions stay in the console. <a href="/console.html">Open the console</a>.</p></div></article>`;
895
- };
896
- openDlg({ eye: 'Agent sessions · real data', title: 'Agent sessions', say: 'The sessions running now. Stop ends one.', stream: turnA(ptx('The sessions running now, read from the same list the console shows. Stop ends one and says so.')), noteKey: null, pane: '<article class="paper doc"></article>', label: 'Sessions' });
897
- $('#askF').hidden = true; setMode('detail'); draw();
898
- const load = async () => { M.list = await readSessions(); M.asks = M.list ? await readAsks() : {}; if (M.list === null) { M.list = []; M.err = 'The sessions could not be read.'; } else sessBadge(M.list.length); draw(); };
899
- const focusNext = () => { const b = $('#oMain [data-stop]:not([disabled])') || $('#dTitle'); if (b) b.focus(); };
900
- $('#oMain').onclick = async (e) => {
901
- if (M.busy) return;
902
- const an = e.target.closest('[data-ans]');
903
- if (an) {
904
- const id = an.dataset.ans, a = M.asks[id]; if (!a) return;
905
- M.ans = id; M.err = ''; draw();
906
- const r = await pmPost('/api/runs/answer', { run: id, request: a.request, behavior: 'answer', message: an.dataset.opt }); M.ans = null;
907
- if (r && r.ok) { toast('Answered. The agent continues with your choice.'); delete M.asks[id]; } else M.err = (r && (r.error || r.reason)) || 'Not answered.';
908
- draw(); return;
909
- }
910
- const st = e.target.closest('[data-stop]'), yes = e.target.closest('[data-yes]'), no = e.target.closest('[data-no]');
911
- M.err = '';
912
- if (st) { M.ask = st.dataset.stop; M.slow = null; draw(); const k = $(`#oMain [data-no="${M.ask}"]`); if (k) k.focus(); }
913
- else if (no) { const id = no.dataset.no; M.ask = null; M.slow = null; draw(); const b = $(`#oMain [data-stop="${id}"]`); if (b) b.focus(); }
914
- else if (yes) {
915
- const id = yes.dataset.yes, x = M.list.find((y) => y.id === id); if (!x) return;
916
- M.busy = id; M.ask = null; M.slow = null; draw();
917
- const r = await pmPost('/api/session/remove', { id }); M.busy = null;
918
- if (r && r.ok && r.removed === false) M.slow = id; // asked to end, not exited yet: say so, never claim an end that did not happen
919
- else if (r && r.ok) { M.done = x; toast('Ended “' + x.name + '”.'); } else M.err = (r && (r.error || r.reason)) || 'Not stopped.';
920
- draw();
921
- if (M.done) setTimeout(async () => { M.done = null; await load(); focusNext(); }, 1600);
922
- else if (M.slow) { const b = $(`#oMain [data-yes="${id}"]`); if (b) b.focus(); }
923
- }
924
- };
925
- await load();
1004
+ openDlg({ eye: 'Sessions', title: 'Sessions', say: 'Pick a session from the list.', stream: turnA(ptx('Pick a session from the list. A dot shows its state: Ready, Running or Maybe blocked.')), noteKey: null, sessions: true, pane: '<article class="paper doc"><p class="note">Pick a session from the list.</p></article>', label: 'Session' });
1005
+ $('#askF').hidden = true;
1006
+ if (desk()) setFull(true); else $('#dlg').classList.add('srl-open');
1007
+ await railRead();
1008
+ if (!R.sel) $('#dTitle').textContent = titleOf(R.model);
1009
+ const top = loudestRow(R.model);
1010
+ if (top && desk()) pickSession(top.id);
926
1011
  }
@@ -1635,25 +1635,14 @@ button.dsn:hover{box-shadow:inset 0 0 0 1.5px rgb(79,109,245)}
1635
1635
  .sbtn{position:relative}
1636
1636
  .sbdg{position:absolute;top:-3px;right:-3px;min-width:22px;height:22px;padding:0 6px;border-radius:999px;background:var(--ember);color:rgb(20,22,31);font:600 var(--fs-2) var(--mono);display:grid;place-items:center;pointer-events:none}
1637
1637
  .sbdg[hidden]{display:none}
1638
- .ssl{list-style:none;margin:0;padding:0;display:grid;gap:10px}
1639
- .ssr{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:6px 14px;align-items:start;padding:16px 18px;border-radius:var(--r-in);background:var(--well)}
1640
- .ssd{width:10px;height:10px;border-radius:50%;margin-top:7px;background:var(--ink-3)}
1641
- .ssd.working{background:var(--ok)}.ssd.needs,.ssd.blocked{background:var(--ember)}
1642
- .ssb{min-width:0}.ssb h3{font-size:var(--fs-4);font-weight:600;letter-spacing:-.01em;overflow-wrap:anywhere}
1643
- .ssn{color:var(--ink-2);font-size:var(--t-small);margin-top:2px;overflow-wrap:anywhere}
1644
- .ssm{display:flex;flex-wrap:wrap;gap:2px 14px;margin-top:8px;font:500 var(--fs-2) var(--mono);color:var(--ink-3)}
1645
- .ssr>.cta{height:44px;padding:0 20px}
1646
- .ssc,.ssdone{grid-column:1/-1}
1638
+ .ssc{grid-column:1/-1}
1647
1639
  .ssc{border-top:1px solid var(--hair);padding-top:14px;margin-top:8px;font-size:var(--t-small);color:var(--ink-2)}
1648
1640
  .ssc b{color:var(--ink);font-weight:600}
1649
1641
  .ssx{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}.ssx .cta{height:44px;padding:0 20px}
1650
1642
  .cta.bad{background:var(--bad);color:rgb(255,255,255)}
1651
1643
  @media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .cta.bad{color:rgb(40,12,10)}}
1652
1644
  :root[data-theme="dark"] .cta.bad{color:rgb(40,12,10)}
1653
- .ssdone{color:var(--ok);font-weight:600}
1654
1645
  .ssw{margin:0;padding:12px 16px;border-radius:var(--r-in);background:var(--well);border-left:3px solid var(--ember);color:var(--ink-2)}.ssw b{color:var(--ink);font-weight:600}
1655
- .sse{padding:34px 20px;text-align:center;border-radius:var(--r-in);background:var(--well)}.sse b{display:block;font-size:var(--fs-4);font-weight:600}.sse p{color:var(--ink-2);margin-top:6px;font-size:var(--t-small)}
1656
- @media (max-width:700px){.ssr{grid-template-columns:auto minmax(0,1fr)}.ssr>.cta{grid-column:2}}
1657
1646
 
1658
1647
  /* Issue it on a core document draft (initiative premium-core-doc-issue) */
1659
1648
  .dsiss{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;padding:12px 16px;border-radius:14px;background:color-mix(in oklab,var(--ember) 12%,transparent);margin:0 0 12px;font-size:var(--fs-2)}
@@ -2374,3 +2363,79 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2374
2363
  .ilead{margin:6px 0 14px;font-size:var(--fs-3);font-weight:600;color:var(--ember-ink)}
2375
2364
  .footi{margin-top:28px;display:flex;align-items:center}
2376
2365
  .ifold .foot{margin:0;max-width:90ch}
2366
+ /* ── Sessions beside the chat (initiative premium-session-list): the list, its dots, the chip, the folds ── */
2367
+ .srl{display:none;flex-direction:column;min-height:0;overflow:hidden;border-right:1px solid var(--hair);padding-right:10px}
2368
+ .srl-hd{display:flex;align-items:center;gap:6px;padding:4px 2px 8px 8px}
2369
+ .srl-hd b{flex:1;font-size:var(--fs-3);font-weight:600;white-space:nowrap}
2370
+ .srl-fold,.vfold{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;color:var(--ink-2);flex:none}
2371
+ .srl-fold:hover,.vfold:hover{background:var(--well);color:var(--ink)}
2372
+ .srl-fold svg,.vfold svg{width:16px;height:16px}
2373
+ .vfold{display:none}
2374
+ .srl-list{flex:1;overflow:auto;min-height:0;scrollbar-width:thin}
2375
+ .srl ul{list-style:none;margin:0;padding:0}
2376
+ .srl-gh{display:flex;align-items:center;gap:6px;width:100%;min-height:32px;padding:4px 8px;border-radius:10px;font-size:var(--fs-2);font-weight:600;color:var(--ink-2);margin-top:6px}
2377
+ .srl-gh:hover{background:var(--well)}
2378
+ .srl-gh .chev{width:12px;height:12px;transition:transform .15s}
2379
+ .srl-gh[aria-expanded="false"] .chev{transform:rotate(-90deg)}
2380
+ .srl-gh em{font:500 var(--fs-1) var(--mono);font-style:normal;color:var(--ink-3)}
2381
+ .srl-r{display:flex;align-items:center;gap:8px;width:100%;min-height:32px;padding:4px 8px;border-radius:10px;text-align:left;font-size:var(--fs-2);color:var(--ink);position:relative}
2382
+ .srl-r:hover{background:var(--well)}
2383
+ .srl-r.on{background:var(--solid);color:var(--on-solid)}
2384
+ .srl-ic{width:20px;height:20px;border-radius:6px;display:grid;place-items:center;background:var(--well);color:var(--ink-2);flex:none}
2385
+ .srl-r.on .srl-ic{background:color-mix(in oklab,var(--on-solid) 16%,transparent);color:inherit}
2386
+ .srl-ic svg{width:12px;height:12px}
2387
+ .srl-n{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
2388
+ .srl-r.rd .srl-n{font-weight:600}
2389
+ .srl-h{display:none;font:500 var(--fs-1) var(--mono);color:var(--ink-3);white-space:nowrap}
2390
+ .srl-r:hover .srl-h,.srl-r:focus-visible .srl-h,.srl-r.on .srl-h{display:inline}
2391
+ .srl-r.on .srl-h{color:inherit;opacity:.75}
2392
+ .srl-more{display:block;width:100%;text-align:left;min-height:32px;padding:4px 8px 4px 36px;border-radius:10px;color:var(--ink-3);font-size:var(--fs-2)}
2393
+ .srl-more:hover{background:var(--well);color:var(--ink)}
2394
+ .srl-lg{display:flex;flex-wrap:wrap;gap:4px 12px;padding:8px 8px 0;border-top:1px solid var(--hair);font-size:var(--fs-1);color:var(--ink-3)}
2395
+ .srl-lg span{display:inline-flex;align-items:center;gap:5px}
2396
+ .srl-warn{margin:4px 2px 8px;padding:8px 10px;border-radius:10px;background:var(--spot);font-size:var(--fs-2);color:var(--ink-2)}
2397
+ .srl-warn b{color:var(--ink);font-weight:600}
2398
+ .srl-none{padding:8px;color:var(--ink-3);font-size:var(--fs-2)}
2399
+ .sdot2{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}
2400
+ .sdot2.ready{background:var(--ember)}
2401
+ .sdot2.run{background:var(--ok);animation:spulse 2s infinite}
2402
+ .sdot2.blk{box-shadow:inset 0 0 0 2px var(--ember)}
2403
+ .sdot2.idle{background:transparent}
2404
+ @keyframes spulse{0%{box-shadow:0 0 0 0 color-mix(in oklab,var(--ok) 50%,transparent)}70%{box-shadow:0 0 0 5px transparent}100%{box-shadow:0 0 0 0 transparent}}
2405
+ @media (prefers-reduced-motion:reduce){.sdot2.run{animation:none}}
2406
+ .stease{display:inline-flex;align-items:center;gap:7px;height:36px;padding:0 13px;border-radius:999px;background:var(--well);font-size:var(--fs-2);font-weight:600;color:var(--ink);align-self:center}
2407
+ .stease[hidden]{display:none}
2408
+ .stease em{font-style:normal;font-weight:500;color:var(--ink-2)}
2409
+ .stease:hover{background:var(--b3)}
2410
+ .scard .scs{display:flex;align-items:center;gap:8px;font-size:var(--fs-2);color:var(--ink-2);margin:0 0 4px}
2411
+ .scard .ssx{margin-top:12px}
2412
+ @media (min-width:1000px){
2413
+ .dlg.full.srl-on .dgrid{grid-template-columns:var(--srw,232px) minmax(360px,.75fr) minmax(0,1.25fr);gap:22px}
2414
+ .dlg.full.srl-on .srl{display:flex}
2415
+ .dlg.full.srl-on.srl-min{--srw:52px}
2416
+ .dlg.full.srl-on.vw-min .dgrid{grid-template-columns:var(--srw,232px) minmax(0,1fr) 52px}
2417
+ .dlg.full.vw-min:not(.srl-on) .dgrid{grid-template-columns:minmax(0,1fr) 52px}
2418
+ .dlg.full[data-mode="detail"].srl-on .dgrid{grid-template-columns:var(--srw,232px) minmax(0,1fr)}
2419
+ .dlg.full .vfold{display:grid}
2420
+ .dlg.full.vw-min .p-out{background:transparent;overflow:hidden}
2421
+ .dlg.full.vw-min .p-out>:not(.otop),.dlg.full.vw-min .otop>:not(#vFold){display:none!important}
2422
+ .dlg.full.vw-min .otop{padding:0;background:transparent;justify-content:center}
2423
+ .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)}
2424
+ .dlg.full.srl-on .stream{gap:12px}
2425
+ .dlg.full.vw-min #dBody{padding-inline:max(0px,calc((100% - 880px) / 2))}
2426
+ .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}
2427
+ .srl-min .srl{padding-right:6px}
2428
+ .srl-min .srl-hd{justify-content:center;padding-left:0}
2429
+ .srl-min .srl-gh{min-height:1px;height:1px;padding:0;margin:8px 6px;background:var(--hair)}
2430
+ .srl-min .srl-r{justify-content:center;padding:6px 0}
2431
+ .srl-min .srl-r .sdot2{position:absolute;top:4px;right:6px;width:7px;height:7px}
2432
+ .srl-min .srl-ic{width:26px;height:26px}
2433
+ }
2434
+ @media (max-width:999px){
2435
+ .dlg.srl-open .srl{display:flex;border-right:0;padding-right:0;grid-column:1/-1}
2436
+ .dlg.srl-open .dgrid>.pane,.dlg.srl-open #dTabs{display:none!important}
2437
+ .dlg.srl-open .srl-r,.dlg.srl-open .srl-gh,.dlg.srl-open .srl-more{min-height:44px;font-size:var(--fs-3)}
2438
+ .dlg.srl-open .srl-h{display:inline}
2439
+ .dlg.srl-open .srl-hd{display:none}
2440
+ .stease{height:44px}
2441
+ }
@@ -292,8 +292,7 @@ $('#dBody').addEventListener('click', (e) => {
292
292
  $$('#card button').forEach((b) => { b.disabled = true; });
293
293
  startAgent({ ws: w.ws || new URLSearchParams(location.search).get('ws') || undefined, task: 'draft', initiative: w.initiative, what: w.what }).then((res) => {
294
294
  if (!res.ok) { $$('#card button').forEach((b) => { b.disabled = false; }); showErr('Not started: ' + res.error); return; }
295
- delete START[key]; toast('The agent started. It is listed in Agent sessions, and its draft waits for you to read.'); closeDlg();
296
- const bd = $('#sessBdg'); if (bd) { bd.textContent = String((+bd.textContent || 0) + 1); bd.hidden = false; }
295
+ delete START[key]; toast('The agent started. It is listed in Sessions, and its draft waits for you to read.'); closeDlg();
297
296
  });
298
297
  return;
299
298
  }
@@ -0,0 +1,92 @@
1
+ /* pm/session-rail.js — the session list beside the chat (initiative premium-session-list, PRD L2). Pure: no DOM, no fetch, so Node tests it.
2
+ *
3
+ * railModel(rows, goals, { showAll }) → { groups: [{ id, title, rows, hidden }], ready, blocked, working, live, warn }
4
+ * railHtml(model, { sel, shut, folded }) → the list's markup
5
+ * teaser(model) → { dot, text } | null the chip in a normal-size chat dialog
6
+ * menuCount(rows) → how many live sessions need the PM (Ready or Maybe blocked): the ⋯ menu badge
7
+ * loudestRow(model) → the row the menu's Sessions opens on
8
+ *
9
+ * rows are GET /api/sessions rows (origin, automatic, shown, label, name, created, headless); goals is GET /api/briefing-premium/goals.
10
+ * Every word on a row is a record field or the fixed word for its state. Exited sessions are not listed. */
11
+
12
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
13
+ // lib/session-state.js ATTENTION, minus exited: the order rows sort in and the state a folded group stands for
14
+ export const RANK = Object.freeze({ needs: 4, blocked: 3, working: 2, quiet: 1 });
15
+ export const DOT = Object.freeze({ needs: 'ready', blocked: 'blk', working: 'run', quiet: 'idle' });
16
+ export const WORD = Object.freeze({ needs: 'Ready', blocked: 'Maybe blocked', working: 'Running', quiet: 'Idle' });
17
+ const GOAL_LIVE = ['started', 'waiting'];
18
+ export const MANY = 6; // more agents than this working at once earns the soft warning (premium-sessions-warning)
19
+ const GROUPS = [['goals', 'Goals'], ['yours', 'Yours'], ['pmos', 'Started by PMOS']];
20
+
21
+ const keyOf = (origin) => (/^chat:/.test(String(origin || '')) ? String(origin).slice(5) : null);
22
+ const needsYou = (r) => r.state === 'needs' || r.state === 'blocked';
23
+ const kindOf = (r) => (r.headless ? 'run' : /^schedule:/.test(r.origin || '') ? 'clock' : r.goal ? 'goal' : r.key ? 'chat' : r.group === 'pmos' ? 'auto' : 'step');
24
+
25
+ function rowOf(s, goals) {
26
+ const key = keyOf(s.origin), g = key && goals ? goals[key] : null;
27
+ const goal = g && GOAL_LIVE.includes(g.state) ? g : null;
28
+ const state = RANK[s.shown] ? s.shown : 'working'; // an unknown live word is never promoted into a claim (session-state)
29
+ const group = goal ? 'goals' : s.automatic ? 'pmos' : 'yours';
30
+ let hint = WORD[state];
31
+ if (goal && goal.state === 'waiting') hint = 'Asked you';
32
+ else if (goal && state === 'working') hint = 'Round ' + (goal.rounds || 0) + ' of ' + goal.limit;
33
+ else if (state === 'working' && s.label && /\d/.test(s.label)) hint = s.label; // "Bash 2m": the server's word carries the open call
34
+ const r = { id: s.id, key, name: String(s.name || s.id).replace(/^chat:\s*/, ''), state, group, hint, goal, origin: s.origin || null, created: s.created || null, headless: s.headless || null, note: s.note || '', cwd: s.cwd || '', agent: s.agent || '' };
35
+ r.kind = kindOf(r);
36
+ return r;
37
+ }
38
+
39
+ export function railModel(rows, goals = {}, { showAll = false } = {}) {
40
+ const live = (Array.isArray(rows) ? rows : []).filter((s) => s && s.id && s.shown !== 'exited').map((s) => rowOf(s, goals));
41
+ live.sort((a, b) => (RANK[b.state] - RANK[a.state]) || (Date.parse(b.created || '') || 0) - (Date.parse(a.created || '') || 0));
42
+ const groups = GROUPS.map(([id, title]) => {
43
+ const all = live.filter((r) => r.group === id);
44
+ const shown = id === 'pmos' && !showAll ? all.filter(needsYou) : all;
45
+ return { id, title, rows: shown, all: all.length, hidden: all.length - shown.length };
46
+ }).filter((g) => g.all);
47
+ const n = (st) => live.filter((r) => r.state === st).length;
48
+ const working = n('working');
49
+ return { groups, live: live.length, ready: n('needs'), blocked: n('blocked'), working, warn: working > MANY ? working : 0, rows: live };
50
+ }
51
+
52
+ export const menuCount = (rows) => (Array.isArray(rows) ? rows : []).filter((s) => s && (s.shown === 'needs' || s.shown === 'blocked')).length;
53
+
54
+ export function loudestRow(m) { return (m && m.rows && m.rows[0]) || null; }
55
+
56
+ /** The dialog's title when the ⋯ menu's Sessions opens it: what needs the PM first. */
57
+ export function titleOf(m) { return !m || !m.live ? 'No sessions running' : m.ready ? m.ready + ' ready for you' : m.blocked ? m.blocked + ' ' + WORD.blocked.toLowerCase() : m.working ? m.working + ' running' : m.live + (m.live === 1 ? ' session' : ' sessions'); }
58
+
59
+ export function teaser(m) {
60
+ if (!m || !m.live) return null;
61
+ const top = m.rows[0];
62
+ const text = m.ready ? m.ready + ' ready' : m.blocked ? m.blocked + ' ' + WORD.blocked.toLowerCase() : m.working ? m.working + ' running' : m.live + (m.live === 1 ? ' session' : ' sessions');
63
+ return { dot: DOT[top.state], text };
64
+ }
65
+
66
+ const ICON = {
67
+ chat: '<path d="M4 5h16v11H9l-5 4z"/>', goal: '<path d="M5 21V4"/><path d="M5 4h12l-2 4 2 4H5"/>', step: '<path d="M5 12h14"/><path d="M13 6l6 6-6 6"/>',
68
+ auto: '<circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M4.2 4.2l2.1 2.1M17.7 17.7l2.1 2.1M2 12h3M19 12h3M4.2 19.8l2.1-2.1M17.7 6.3l2.1-2.1"/>',
69
+ clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>', run: '<path d="M4 17l6-6-6-6"/><path d="M12 19h8"/>',
70
+ };
71
+ export const icon = (k) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${ICON[k] || ICON.step}</svg>`;
72
+ const CHEV = '<svg class="i chev" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>';
73
+
74
+ export function railHtml(m, { sel = null, shut = [], showAll = false } = {}) {
75
+ if (!m || !m.live) return '<p class="srl-none">No sessions are running. Write in a chat to start one.</p>';
76
+ let h = m.warn ? `<p class="srl-warn" role="status"><b>${m.warn} agents are working at once.</b> Each one is a program running on this computer, so many at once can slow it. Stop the ones you are not watching.</p>` : '';
77
+ for (const g of m.groups) {
78
+ const open = !shut.includes(g.id);
79
+ h += `<section class="srl-g"><button type="button" class="srl-gh" data-sg="${g.id}" aria-expanded="${open}">${CHEV}<span>${esc(g.title)}</span><em>${g.all}</em></button>`;
80
+ if (!open) { h += '</section>'; continue; }
81
+ h += '<ul>' + g.rows.map((r) => `<li><button type="button" class="srl-r${r.id === sel ? ' on' : ''}${r.state === 'needs' ? ' rd' : ''}" data-sid="${esc(r.id)}" aria-current="${r.id === sel}" aria-label="${esc(r.name + ', ' + r.hint)}" title="${esc(r.name + ' · ' + r.hint)}"><i class="sdot2 ${DOT[r.state]}" aria-hidden="true"></i><span class="srl-ic">${icon(r.kind)}</span><span class="srl-n">${esc(r.name)}</span><span class="srl-h">${esc(r.hint)}</span></button></li>`).join('');
82
+ if (g.id === 'pmos' && (g.hidden || showAll)) h += `<li><button type="button" class="srl-more" data-smore="1">${showAll ? 'Hide the ones that need nothing' : g.hidden + ' more working on their own · Show'}</button></li>`;
83
+ h += '</ul></section>';
84
+ }
85
+ return h;
86
+ }
87
+
88
+ /** The facts the viewer shows for a session that is not a chat row: every line a record field. */
89
+ export function factsOf(r) {
90
+ const who = r.group === 'pmos' ? 'Started by PMOS' : r.goal ? 'A goal in your chat' : r.key ? 'Your chat' : 'You started it';
91
+ return [['State', WORD[r.state]], ['Started by', who], ['Started', r.created ? new Date(r.created).toLocaleString() : ''], ['Folder', r.cwd && r.cwd !== '.' ? r.cwd : ''], ['Note', r.note], ['Kind', r.headless ? 'Background run, no terminal' : '']].filter((x) => x[1]);
92
+ }
@@ -6455,6 +6455,27 @@ async function handleRequest(req, res) {
6455
6455
  }
6456
6456
  // End a session and remove it, with an answer. The WebSocket kill/remove messages return nothing,
6457
6457
  // so a refusal or a slow exit left the PM clicking a control that seemed to do nothing.
6458
+ // premium-session-list L5: the session list's panel writes to a session the PM did not start from a chat panel (a Next step, a PMOS run).
6459
+ // A page press only, into a live session that is not a plain shell; `say` types a line with Enter, `keys` a permission option or Esc.
6460
+ if ((p === '/api/session/say' || p === '/api/session/keys') && req.method === 'POST') {
6461
+ let body = {};
6462
+ try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
6463
+ const g = pmGuard.requirePagePress(req, body);
6464
+ if (!g.ok) return json(res, { ok: false, error: g.error }, g.status);
6465
+ const sess = sessions.get(String(body.id || ''));
6466
+ if (!sess || !sess.pty || sess.state === 'exited') return json(res, { ok: false, error: 'That session is not running.' }, 409);
6467
+ if (sess.agent === 'shell') return json(res, { ok: false, error: 'A terminal shell takes input in the console.' }, 409);
6468
+ if (p === '/api/session/say') {
6469
+ const t = String(body.text == null ? '' : body.text).trim();
6470
+ if (!t) return json(res, { ok: false, error: 'Write a message for Claude.' }, 400);
6471
+ if (t.length > 8000) return json(res, { ok: false, error: 'The message is too long (8000 characters at most).' }, 400);
6472
+ return chatSessions.type(sess.id, t) ? json(res, { ok: true, session: sess.id }) : json(res, { ok: false, error: 'The message did not reach the session.' }, 409);
6473
+ }
6474
+ const KEYS = { esc: '\x1b', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9' };
6475
+ const data = Object.prototype.hasOwnProperty.call(KEYS, String(body.press)) ? KEYS[String(body.press)] : null;
6476
+ if (!data) return json(res, { ok: false, error: 'press must be esc or 1 to 9' }, 400);
6477
+ return chatSessions.keys(sess.id, data) ? json(res, { ok: true, session: sess.id }) : json(res, { ok: false, error: 'The key did not reach the session.' }, 409);
6478
+ }
6458
6479
  if (p === '/api/session/remove' && req.method === 'POST') {
6459
6480
  let body = {};
6460
6481
  try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
@@ -56,6 +56,7 @@
56
56
  "briefing-premium-sources.test.js",
57
57
  "briefing-premium-drafts.test.js",
58
58
  "agent-inbox.test.js",
59
+ "session-rail.test.js",
59
60
  "briefing-premium-metrics.test.js",
60
61
  "premium-welcome.test.js",
61
62
  "calendar-events.test.js",
@@ -232,6 +233,7 @@
232
233
  "briefing-premium-sources.test.js": 1,
233
234
  "briefing-premium-drafts.test.js": 1,
234
235
  "agent-inbox.test.js": 1,
236
+ "session-rail.test.js": 1,
235
237
  "briefing-premium-metrics.test.js": 1,
236
238
  "premium-welcome.test.js": 1,
237
239
  "calendar-events.test.js": 1,