create-pmos 0.392.0 → 0.394.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.392.0",
3
+ "version": "0.394.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,30 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.394.0",
37
+ "at": "2026-10-22T04:51:35.949Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 1008,
42
+ "t": "Open in terminal icon in the chat header",
43
+ "s": "Open in terminal icon in the chat header"
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "v": "0.393.0",
49
+ "at": "2026-10-22T04:08:26.227Z",
50
+ "f": 2,
51
+ "prs": [
52
+ {
53
+ "n": 1007,
54
+ "t": "Show Claude's questions in the chat as a card, not a picker the panel cannot show",
55
+ "s": "Show Claude's questions in the chat as a card, not a picker the panel cannot show"
56
+ }
57
+ ]
58
+ },
35
59
  {
36
60
  "v": "0.392.0",
37
61
  "at": "2026-10-22T04:00:27.581Z",
@@ -272,30 +296,6 @@
272
296
  "s": "A Focus button replaces the automatic hiding on a phone"
273
297
  }
274
298
  ]
275
- },
276
- {
277
- "v": "0.374.0",
278
- "at": "2026-10-21T04:16:12.143Z",
279
- "f": 2,
280
- "prs": [
281
- {
282
- "n": 980,
283
- "t": "Ending an item's chat session keeps its conversation",
284
- "s": "The item keeps its whole conversation after the session ends, in the item dialog and in the session's own view, with a line saying the session ended."
285
- }
286
- ]
287
- },
288
- {
289
- "v": "0.373.0",
290
- "at": "2026-10-21T03:11:16.462Z",
291
- "f": 2,
292
- "prs": [
293
- {
294
- "n": 982,
295
- "t": "Calmer Briefing first screen: mic, calendar ⋯, pin on hover (calmer first screen 5/5)",
296
- "s": "Calmer Briefing first screen: mic, calendar ⋯, pin on hover (calmer first screen 5/5)"
297
- }
298
- ]
299
299
  }
300
300
  ]
301
301
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@a30f40d4
1
+ kernel-source: pmos@5dd55068
2
2
  assembled: 2026-10-22
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-22T04:00:24Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-22T04:51:32Z"}
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-22T04:00:24Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-22T04:51:32Z"}
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-22T04:00:24Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-22T04:51:32Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,28 @@
1
1
  [
2
+ {
3
+ "v": "0.394.0",
4
+ "at": "2026-10-22T04:51:35.949Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 1008,
9
+ "t": "Open in terminal icon in the chat header",
10
+ "s": "Open in terminal icon in the chat header"
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "v": "0.393.0",
16
+ "at": "2026-10-22T04:08:26.227Z",
17
+ "f": 2,
18
+ "prs": [
19
+ {
20
+ "n": 1007,
21
+ "t": "Show Claude's questions in the chat as a card, not a picker the panel cannot show",
22
+ "s": "Show Claude's questions in the chat as a card, not a picker the panel cannot show"
23
+ }
24
+ ]
25
+ },
2
26
  {
3
27
  "v": "0.392.0",
4
28
  "at": "2026-10-22T04:00:27.581Z",
@@ -432,7 +432,9 @@ Every popup has this chat, including the ones that have no row of their own: a t
432
432
  - **The message box** takes several lines. **Enter** sends; **Shift+Enter** starts a new line. The box grows as you type, up to about eight lines, and then scrolls. The send button stays at its foot, also with a phone keyboard open.
433
433
  - **Later messages** in the same dialog go to the same session. Write `/compact`, `/clear` or any other slash command, and Claude Code runs it.
434
434
  - **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.
435
- - **Stop** shows while Claude works. It presses Esc in the session.
435
+ - **Claude's questions** show as a card in the conversation. Claude Code's question picker cannot show in the panel, so the session does not open it: the card shows each question with its options as buttons. Press an option to answer a single question. When Claude asks several questions, or a question takes more than one answer, press the options and then **Send answers**. You can also write your own answer in the box. A session that started before this change still opens the picker: end it in the session list, and your next message resumes the same conversation without it.
436
+ - **Open in terminal** is the terminal icon at the top right of the conversation. It shows when the conversation has a session. While the session runs, it opens that same session in the console's terminal in a new tab: the same process, not a second copy, so what you type there and in the panel reaches the same Claude. On a phone it opens the same terminal. When the session has ended, the icon copies the line that resumes it, for example `cd '/Users/you/pmos' && claude --resume <id>`, for Terminal on the computer PMOS runs on. Writing in the chat also resumes it.
437
+ - **Stop** shows while Claude works. It presses Esc in the session. If Claude was stopped, the conversation shows a grey "Stopped" line.
436
438
  - **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.
437
439
  - **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.
438
440
  - **A file Claude names** (a path such as `briefs/drafts/plan.md`, or a link to one) is underlined. Press it to read the file beside the conversation, as a tab in the viewer; on a phone, the Detail side shows it (on the Chat page, the viewer opens over the conversation). Markdown shows as a page, an HTML file shows as the page it draws (press **Source** for its code), and other text files show as code. An HTML page runs its own scripts, so its toggles and charts work, but it cannot reach PMOS or the internet: a web font falls back to the system font. It is read-only. While the tab is open it shows the newest version, so a file Claude is still writing stays current. A file in a workspace PMOS serves, in a git worktree of one, or in the folder a session runs in opens here. Any other file says "Not in a workspace" and is not read.
@@ -43,7 +43,7 @@ const freePort = () => new Promise((res) => { const s = net.createServer(); s.li
43
43
  const conv = path.join(home, 'projects', '-alpha', uuid + '.jsonl');
44
44
  fs.mkdirSync(path.dirname(conv), { recursive: true });
45
45
  const line = (o) => JSON.stringify(o) + '\n';
46
- const convText = line({ type: 'user', timestamp: '2026-10-20T06:53:47Z', message: { role: 'user', content: 'The PM is talking to you from the chat panel of one item on their PMOS page.\n\nThe PM says: Update the TSC deck for Thursday' } })
46
+ const convText = line({ type: 'user', timestamp: '2026-10-20T06:53:47Z', cwd: root, message: { role: 'user', content: 'The PM is talking to you from the chat panel of one item on their PMOS page.\n\nThe PM says: Update the TSC deck for Thursday' } })
47
47
  + line({ type: 'assistant', timestamp: '2026-10-20T06:54:10Z', message: { id: 'm1', model: 'claude-test', content: [{ type: 'text', text: 'I updated the CAS and Scarlet table in tsc-deck.html.' }] } })
48
48
  + line({ type: 'user', timestamp: '2026-10-20T07:10:00Z', message: { role: 'user', content: 'Split status and remarks' } })
49
49
  + line({ type: 'assistant', timestamp: '2026-10-20T07:10:30Z', message: { id: 'm2', model: 'claude-test', content: [{ type: 'text', text: 'Status now carries last month; Remarks carries the next step.' }] } });
@@ -66,6 +66,8 @@ const freePort = () => new Promise((res) => { const s = net.createServer(); s.li
66
66
  ok('H1 the chat session is restored as ended (its process is gone)', !!ended);
67
67
  const t1 = await thread();
68
68
  ok('H2 the item still shows its conversation after the session ended', t1.status === 200 && t1.body.session === null && /CAS and Scarlet table/.test(texts(t1)) && /Remarks carries the next step/.test(texts(t1)), JSON.stringify(t1.body));
69
+ // chat-open-in-terminal: an ended chat's header icon copies the line that resumes it, in its folder and its own Claude home
70
+ ok('H2b the ended chat carries its terminal line: cd to its folder, the profile\'s Claude home, claude --resume its id', t1.body.resume === "cd '" + root + "' && CLAUDE_CONFIG_DIR='" + home + "' claude --resume " + uuid, JSON.stringify(t1.body.resume));
69
71
  const c1 = await R('GET', '/api/sessions/conversation?id=' + sid);
70
72
  ok('H3 the session view of an ended chat shows the conversation too', c1.body && c1.body.state === 'ended' && c1.body.messages.some((m) => /Split status and remarks/.test(m.text || '')), JSON.stringify(c1.body));
71
73
 
@@ -251,6 +251,15 @@ function chatHistory({ runtimeDir, key, sessions }) {
251
251
  }
252
252
  return { messages, conversations };
253
253
  }
254
+ /* chat-open-in-terminal: the shell line that opens an ended chat's Claude Code conversation in a terminal on this computer.
255
+ * cwd: the folder the conversation ran in (Claude Code keys its files by it); home: the Claude home that holds the file, named only when
256
+ * it is not ~/.claude (a profile such as ~/.claude-personal). Paths are single-quoted. null when the id or the folder is missing. */
257
+ const shq = (s) => "'" + String(s).replace(/'/g, "'\\''") + "'";
258
+ function resumeCommand({ uuid, cwd, home, defaultHome }) {
259
+ if (!UUID_RE.test(String(uuid || '')) || !cwd || !path.isAbsolute(String(cwd))) return null;
260
+ const env = home && defaultHome && path.resolve(home) !== path.resolve(defaultHome) ? 'CLAUDE_CONFIG_DIR=' + shq(home) + ' ' : '';
261
+ return 'cd ' + shq(cwd) + ' && ' + env + 'claude --resume ' + uuid;
262
+ }
254
263
  const MAX_LIVE = 4;
255
264
  /** Which live chat session to end so a new one fits (PRD L3), or null. rows: [{ id, origin, lastOutputAt, busy }];
256
265
  * busy = working or waiting on a permission prompt. A session whose goal is started is never picked. */
@@ -278,4 +287,4 @@ function press({ runtimeDir, key, what, sessions }) {
278
287
  return { status: 200, body: { ok: true, session: live } };
279
288
  }
280
289
 
281
- module.exports = { ask, chat, press, chatSessionOf, chatRecordOf, chatRecordsOf, chatClaudeOfSession, chatHistory, pickToEnd, MAX_LIVE, openingFor, threadOf, promptFor, rowFor, settle, KEY_RE, THREADS, CHATS };
290
+ module.exports = { ask, chat, press, resumeCommand, chatSessionOf, chatRecordOf, chatRecordsOf, chatClaudeOfSession, chatHistory, pickToEnd, MAX_LIVE, openingFor, threadOf, promptFor, rowFor, settle, KEY_RE, THREADS, CHATS };
@@ -192,9 +192,21 @@ function withGoalRows(model, rows) {
192
192
  const count = (model.list.count || 0) + add.length;
193
193
  return { ...model, list: { ...model.list, rows: list, count }, dock: model.dock && model.dock.needs != null ? { ...model.dock, needs: count, label: count === 1 ? 'needs you' : 'need you', next: list[0].title } : model.dock };
194
194
  }
195
- /** The Claude Code --settings for a chat session: one Stop hook that posts to this workspace with the session's token. */
195
+ /** The Claude Code --settings for a chat session: a Stop hook and an AskUserQuestion hook, each posting to this workspace with the session's token. */
196
196
  function hookSettings(port, host = '127.0.0.1') {
197
- return { hooks: { Stop: [{ hooks: [{ type: 'http', url: 'http://' + host + ':' + port + '/api/briefing-premium/goal-stop', headers: { 'x-pmos-session': '$PMOS_SESSION' }, allowedEnvVars: ['PMOS_SESSION'], timeout: 10 }] }] } };
197
+ const hook = (route) => ({ type: 'http', url: 'http://' + host + ':' + port + '/api/briefing-premium/' + route, headers: { 'x-pmos-session': '$PMOS_SESSION' }, allowedEnvVars: ['PMOS_SESSION'], timeout: 10 });
198
+ return { hooks: { Stop: [{ hooks: [hook('goal-stop')] }], PreToolUse: [{ matcher: ASK_TOOL, hooks: [hook('ask-tool')] }] } };
199
+ }
200
+ /* chat-ask-card (bug 2026-10-22): Claude Code's question tool draws a picker in the terminal, and the chat panel cannot show it. The panel
201
+ * showed "Claude is working", the PM pressed Stop (Esc) and the question ended as "[Request interrupted by user for tool use]", again and
202
+ * again. Now the PreToolUse hook refuses the picker with this reason: the panel draws the questions from the transcript as a card with
203
+ * answer buttons, and the PM's answer comes back as their next message. */
204
+ const ASK_TOOL = 'AskUserQuestion';
205
+ const ASK_REASON = 'The PM is in the PMOS chat panel, not a terminal. The panel already shows these questions and their options as buttons, '
206
+ + 'and the PM\'s answer comes as their next message. Do not ask again and do not guess the answer: end your turn now with one short line. '
207
+ + 'If you are working on a /goal, end with a pmos-goal progress block whose state is needs-you.';
208
+ function askToolReply() {
209
+ return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: ASK_REASON } };
198
210
  }
199
211
 
200
212
  /** chat() hands a `/goal` message here: { error } or { id, prompt } with the grilling line already on record. */
@@ -229,4 +241,4 @@ function decide({ runtimeDir, key, id, act, draft, session, sessions, now = new
229
241
  return { status: 200, body: { ok: true, id, state: act === 'start' ? 'started' : 'cancelled' } };
230
242
  }
231
243
 
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 };
244
+ module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, askToolReply, ASK_TOOL, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
@@ -191,6 +191,16 @@ module.exports = {
191
191
  ctx.json(res, key ? Goal.onStop({ runtimeDir: ctx.runtimeDir, key, message: body.last_assistant_message }) : {});
192
192
  return true;
193
193
  }
194
+ if (url.pathname === '/api/briefing-premium/ask-tool') {
195
+ // chat-ask-card: Claude Code's PreToolUse hook for AskUserQuestion in a chat session. The panel draws the question; the picker is refused.
196
+ if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
197
+ await ctx.readJson(req);
198
+ const tok = req.headers && req.headers['x-pmos-session'];
199
+ const who = actor.sessionForToken(Array.isArray(tok) ? tok[0] : tok, { sessDir: ctx.sessDir || path.join(ctx.runtimeDir || '', 'sessions') });
200
+ if (!who) { ctx.json(res, { ok: false, error: 'no valid session token' }, 401); return true; }
201
+ ctx.json(res, Goal.askToolReply());
202
+ return true;
203
+ }
194
204
  if (url.pathname === '/api/briefing-premium/seen') {
195
205
  // popup context slice 3b: a popup the PM opened, with what it showed, so the leads session after a refresh writes its lead. Starts nothing.
196
206
  if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
@@ -223,7 +233,10 @@ module.exports = {
223
233
  const history = !live && ctx.runtimeDir ? Ag.chatHistory({ runtimeDir: ctx.runtimeDir, key, sessions: ctx.chatSessions }) : null;
224
234
  // popup context slice 3: a popup's stored lead comes with its thread, so the popup shows it first and starts nothing
225
235
  const lead = key.startsWith('pop:') && ctx.runtimeDir ? Leads.get(ctx.runtimeDir, key) : undefined;
226
- ctx.json(res, { ok: true, ...Ag.threadOf(ctx.runtimeDir, key), session: live ? sid : null, history, goal: ctx.runtimeDir ? Goal.goalOf(ctx.runtimeDir, key) : null, ...(lead !== undefined ? { lead } : {}) });
236
+ // chat-open-in-terminal: an ended chat's terminal line (cd to its folder, claude --resume its id), for the header's terminal icon
237
+ const rec = !live && ctx.runtimeDir ? Ag.chatRecordOf(ctx.runtimeDir, key) : null;
238
+ const resume = rec && rec.claude && ctx.chatSessions && typeof ctx.chatSessions.resumeCommand === 'function' ? ctx.chatSessions.resumeCommand(rec.claude) : null;
239
+ ctx.json(res, { ok: true, ...Ag.threadOf(ctx.runtimeDir, key), session: live ? sid : null, history, resume, goal: ctx.runtimeDir ? Goal.goalOf(ctx.runtimeDir, key) : null, ...(lead !== undefined ? { lead } : {}) });
227
240
  return true;
228
241
  }
229
242
  if (url.pathname !== '/api/briefing-premium') return false;
@@ -438,6 +438,16 @@ function callTarget(input, root) {
438
438
  return t.length > TARGET_MAX ? t.slice(0, TARGET_MAX - 1) + '…' : t;
439
439
  }
440
440
 
441
+ /* The questions of one AskUserQuestion call, as the chat panel draws them: [{ question, header, multi, options:[{ label, detail }] }].
442
+ * At most 4 questions of at most 6 options; a question with fewer than 2 options is dropped. Every string goes through `clean`. */
443
+ function askQuestions(input, clean = (x) => x) {
444
+ const s = (v, n) => clean(String(v == null ? '' : v).replace(/\s+/g, ' ').trim()).slice(0, n);
445
+ return (input && Array.isArray(input.questions) ? input.questions : []).slice(0, 4).map((q) => ({
446
+ question: s(q && q.question, 300), header: s(q && q.header, 40), multi: !!(q && q.multiSelect),
447
+ options: (q && Array.isArray(q.options) ? q.options : []).slice(0, 6).map((o) => ({ label: s(o && o.label, 120), detail: s(o && o.description, 240) })).filter((o) => o.label),
448
+ })).filter((q) => q.question && q.options.length >= 2);
449
+ }
450
+
441
451
  function readConversation(file, clean = (x) => x, limit = CONV_LIMIT, root = null) {
442
452
  let raw;
443
453
  try {
@@ -466,6 +476,8 @@ function readConversation(file, clean = (x) => x, limit = CONV_LIMIT, root = nul
466
476
  if (last.calls.length < CALLS_MAX) last.calls.push(call);
467
477
  last.at = at || last.at;
468
478
  } else out.push({ role: 'tool', tools: { [n]: 1 }, calls: [call], at: at || null });
479
+ // chat-ask-card: Claude Code's question tool keeps its questions, so the chat panel can draw them as a card with answer buttons
480
+ if (name === 'AskUserQuestion') { const q = askQuestions(input, clean); if (q.length) out[out.length - 1].ask = q; }
469
481
  };
470
482
  for (const line of raw.split('\n')) {
471
483
  if (!line) continue;
@@ -492,7 +504,7 @@ function readConversation(file, clean = (x) => x, limit = CONV_LIMIT, root = nul
492
504
  }
493
505
  }
494
506
  const messages = out.slice(-limit).map((x) => (x.role === 'tool'
495
- ? { role: 'tool', tools: x.tools, calls: x.calls, at: x.at }
507
+ ? { role: 'tool', tools: x.tools, calls: x.calls, at: x.at, ...(x.ask ? { ask: x.ask } : {}) }
496
508
  : { role: x.role, text: x.text, at: x.at }));
497
509
  return { messages };
498
510
  }
@@ -518,5 +530,5 @@ function permissionAsk(screen, clean = (x) => x) {
518
530
  return options.length >= 2 ? { question: clean(lines[at]).slice(0, 200), options } : null;
519
531
  }
520
532
 
521
- module.exports = { permissionAsk, claudeHomes, callTarget, findTranscript, readHarness, readConversation, CONV_LIMIT, prettyTool, slugFor, resolvePid, descendants,
533
+ module.exports = { permissionAsk, askQuestions, claudeHomes, callTarget, findTranscript, readHarness, readConversation, CONV_LIMIT, prettyTool, slugFor, resolvePid, descendants,
522
534
  MAX_BYTES, MAX_WALK_DEPTH, PS_SNAPSHOT_MS, defaultChildren };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.392.0",
3
+ "version": "0.394.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.392.0",
9
+ "version": "0.394.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.392.0",
3
+ "version": "0.394.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,91 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-chat-term-test.js — the chat header's Open in terminal icon (chat-open-in-terminal, Wawan 2026-10-22).
4
+ * A real server on a scratch repository (c3-scan-fixture.js); the thread and the session list are routed.
5
+ * O1 a running session: the icon shows and opens the console terminal of that same session in a new tab
6
+ * O2 an ended chat: the icon copies the line that resumes it
7
+ * O3 no session: no icon
8
+ * O4 /console.html?term=<id> opens that session's sheet on the terminal, also at phone width
9
+ * Set CHAT_TERM_SHOTS=<dir> to save the header at 1280 light and 390 dark. */
10
+ const { findBrowser } = require('./lib/find-browser');
11
+ require('./test-run').configure({ name: 'premium-chat-term' });
12
+ const Fx = require('./c3-scan-fixture.js');
13
+
14
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
15
+ const until = async (fn, ms = 8000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
16
+ const results = [];
17
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
18
+ let F = null, browser = null;
19
+ const finish = async (code) => {
20
+ if (browser) await browser.close().catch(() => {});
21
+ if (F) F.stop();
22
+ const bad = results.filter((x) => !x.cond).length;
23
+ console.log(`\n${results.length - bad}/${results.length} premium-chat-term assertions passed`);
24
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
25
+ };
26
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
27
+
28
+ const CMD = "cd '/Users/pm/pmos' && claude --resume 685a486b-d916-4002-9629-5e0fa33eaa9b";
29
+ const icon = () => { const b = document.querySelector('#dTerm'); return b ? { shown: !b.hidden && getComputedStyle(b).display !== 'none', label: b.getAttribute('aria-label'), before: b.nextElementSibling && b.nextElementSibling.id } : null; };
30
+
31
+ (async () => {
32
+ const exe = findBrowser();
33
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
34
+ let chromium;
35
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
36
+ F = await Fx.start({ name: 'premium-chat-term' });
37
+ browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
38
+ const shots = process.env.CHAT_TERM_SHOTS;
39
+ const chat = `${F.BASE}/premium-chat.html?ws=${encodeURIComponent(F.ws)}`;
40
+ const open = async (thread, width = 1280, scheme = 'light') => {
41
+ const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 800 }, colorScheme: scheme, hasTouch: width < 1000 });
42
+ await ctx.grantPermissions(['clipboard-read', 'clipboard-write'], { origin: F.BASE });
43
+ const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
44
+ await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], working: false, history: null, goal: null, ...thread } }));
45
+ await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', messages: [{ role: 'assistant', text: 'Working on the sheet.', at: null }], turn: null } }));
46
+ await p.goto(chat); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dBody .stream')));
47
+ // the Chat page draws a conversation once it has a key: give it one, as a press on a list row does
48
+ await p.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.S.key = 'work:term-test'; await m.loadThread('work:term-test'); });
49
+ return { p, ctx, errs };
50
+ };
51
+
52
+ { const { p, ctx, errs } = await open({ session: 'sess-7' });
53
+ const i = await until(async () => { const v = await p.evaluate(icon); return v && v.shown ? v : null; }) || await p.evaluate(icon);
54
+ ok('O1 a running session shows the terminal icon, before the conversation toggle', i && i.shown && i.label === 'Open in terminal' && i.before === 'dPane', JSON.stringify(i));
55
+ const [pop] = await Promise.all([ctx.waitForEvent('page', { timeout: 8000 }).catch(() => null), p.click('#dTerm')]);
56
+ // the new tab opens on about:blank and then loads the address, so wait for it (on a busy CI runner the event comes first)
57
+ if (pop) await pop.waitForURL(/\/console\.html\?term=/, { timeout: 8000 }).catch(() => {});
58
+ const href = pop ? pop.url() : '';
59
+ ok('O1 pressing it opens the console terminal of that same session in a new tab', /\/console\.html\?term=sess-7&ws=/.test(href), href);
60
+ if (pop) await pop.close();
61
+ if (shots) await p.screenshot({ path: `${shots}/term-1280-light.png` });
62
+ ok('O1 no error on the page', !errs.length, errs.join(' | '));
63
+ await ctx.close();
64
+ }
65
+ { const { p, ctx } = await open({ session: null, resume: CMD }, 390, 'dark');
66
+ const i = await until(async () => { const v = await p.evaluate(icon); return v && v.shown ? v : null; }) || await p.evaluate(icon);
67
+ ok('O2 an ended chat shows the icon to copy its terminal line', i && i.shown && i.label === 'Copy the terminal command', JSON.stringify(i));
68
+ await p.click('#dTerm');
69
+ const clip = await until(() => p.evaluate(() => navigator.clipboard.readText()));
70
+ const t = await p.evaluate(() => document.querySelector('#toast').textContent);
71
+ ok('O2 pressing it copies cd to the folder and claude --resume, and says so', clip === CMD && /Copied/.test(t), clip + ' | ' + t);
72
+ if (shots) await p.screenshot({ path: `${shots}/term-390-dark.png` });
73
+ await ctx.close();
74
+ }
75
+ { const { p, ctx } = await open({ session: null, resume: null });
76
+ await sleep(600);
77
+ const i = await p.evaluate(icon);
78
+ ok('O3 no session and nothing to resume: no icon', i && !i.shown, JSON.stringify(i));
79
+ await ctx.close();
80
+ }
81
+ for (const width of [1280, 390]) {
82
+ const ctx = await browser.newContext({ viewport: { width, height: 800 } });
83
+ const p = await ctx.newPage();
84
+ await p.route('**/api/sessions', (r) => r.fulfill({ json: { sessions: [{ id: 'sess-7', name: 'chat: PSLE sheet', agent: 'claude', state: 'working', shown: 'working' }] } }));
85
+ await p.goto(`${F.BASE}/console.html?term=sess-7&ws=${encodeURIComponent(F.ws)}`);
86
+ const v = await until(() => p.evaluate(() => { const s = document.querySelector('[data-c3-session="sess-7"]'); const b = document.querySelector('[data-c3-view="term"]'); return s && b ? b.getAttribute('aria-pressed') : null; }), 15000);
87
+ ok(`O4 at ${width} /console.html?term= opens that session's sheet on its terminal`, v === 'true', String(v));
88
+ await ctx.close();
89
+ }
90
+ finish();
91
+ })();
@@ -8,5 +8,6 @@ let desk = false;
8
8
  try { desk = localStorage.getItem('pmos.c3.testDesk') === 'desk'; } catch { /* no storage */ }
9
9
  if (new URLSearchParams(location.search).get('audience') === '1') import('./c3-audience.js').then((m) => m.runAudiencePage()); // the audience window of a PMOS deck: slides only, in a window of its own
10
10
  else if (new URLSearchParams(location.search).get('capture') === '1') import('./c3-capture.js'); // the PMOS Chrome extension's popup page: a small page on its own, at any width
11
- else if (narrow && !desk) import('./c3-phone-boot.js');
11
+ // ?term=<session> (the premium chat's Open in terminal) needs the desktop console's terminal sheet, which the phone companion has not got
12
+ else if (narrow && !desk && !new URLSearchParams(location.search).get('term')) import('./c3-phone-boot.js');
12
13
  else import('./c3-shell.js');
@@ -616,6 +616,8 @@ async function boot() {
616
616
  // ?replay=<note id> opens the meeting replay of that note (initiative meeting-material-replay-gaps). An id that is not a note id opens the replay page's own error, and makes no request.
617
617
  if (q.get('replay')) import('./c3-replay.js').then((m) => m.openReplay(m.NOTE_ID_RE.test(q.get('replay')) ? { note: q.get('replay') } : { note: '' })).catch(() => {});
618
618
  if (q.get('structure') && /^[a-z][a-z0-9-]{0,39}$/.test(q.get('structure'))) { if (!start) start = 'rep'; import('./c3-report-structure.js').then((m) => m.openStructure({ ws: S.ws, id: q.get('structure'), name: '' })).catch(() => { /* the structure step is not available */ }); }
619
+ // ?term=<session id> opens that session's live terminal (the premium chat's Open in terminal): the same process, attached, not a second one
620
+ if (/^sess-\d+$/.test(q.get('term') || '')) import('./c3-session-term.js').then((m) => m.openSessionTerm({ id: q.get('term'), view: 'term' })).catch(() => { /* the terminal is not available */ });
619
621
  if (!S.userNav) showTab(start || 'brief', false); // a press during the read above (the gear, a tab) wins over the start page
620
622
  new ResizeObserver(moveInd).observe(S.tabNav);
621
623
  briefCount(); S.dock.start(); S.dockStarted = true;
@@ -0,0 +1,35 @@
1
+ /* chat-ask — Claude Code's question tool (AskUserQuestion) as a card in the chat panel (bug 2026-10-22, chat-ask-card).
2
+ * The terminal picker cannot be shown in the panel, so a chat session's hook refuses it (lib/goal-chat.js askToolReply) and the panel draws
3
+ * the questions from the transcript here. One question with one answer: each option is a button that sends it. Several questions, or a
4
+ * question that takes several answers: the options toggle, and Send answers sends them all as one message. Pure: no DOM, so Node tests it. */
5
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
6
+
7
+ /** True when one press answers the whole card: one question that takes one answer. */
8
+ export const oneTap = (ask) => Array.isArray(ask) && ask.length === 1 && !ask[0].multi;
9
+
10
+ /** The PM's answer as one message. picked: { '<q>': [option index, …] }. Empty when a question has no answer yet. */
11
+ export function answerText(ask, picked) {
12
+ const qs = Array.isArray(ask) ? ask : [];
13
+ const parts = qs.map((q, i) => (picked && picked[i] || []).map((k) => q.options[k] && q.options[k].label).filter(Boolean));
14
+ if (!qs.length || parts.some((p) => !p.length)) return '';
15
+ if (qs.length === 1) return parts[0].join(', ');
16
+ return qs.map((q, i) => (q.header || q.question) + ': ' + parts[i].join(', ')).join('; ');
17
+ }
18
+
19
+ /** The card. live: the PM can still answer (nothing was written after the question); picked: the toggled options of a multi card. */
20
+ export function askCardHtml(ask, { live = false, picked = {}, at = '' } = {}) {
21
+ const qs = Array.isArray(ask) ? ask : [];
22
+ if (!qs.length) return '';
23
+ const one = oneTap(qs);
24
+ const body = qs.map((q, i) => {
25
+ const opts = q.options.map((o, k) => {
26
+ const on = (picked[i] || []).includes(k);
27
+ const act = one ? `data-chat-say="${esc(o.label)}"` : `data-ask-pick="${i}:${k}" aria-pressed="${on}"`;
28
+ return `<button type="button" class="chip${on ? ' on' : ''}" ${act}${o.detail ? ` title="${esc(o.detail)}"` : ''}${live ? '' : ' disabled'}>${esc(o.label)}</button>`;
29
+ }).join('');
30
+ return `<div class="askq">${q.header ? `<p class="askh">${esc(q.header)}${q.multi ? ' · pick any' : ''}</p>` : ''}<p class="tt"><b>${esc(q.question)}</b></p><div class="chips">${opts}</div></div>`;
31
+ }).join('');
32
+ const send = !one && live ? `<div class="chatopts"><button type="button" class="cta" data-ask-send="${esc(at)}"${answerText(qs, picked) ? '' : ' disabled'}>Send answers</button></div>` : '';
33
+ const foot = live ? '<p class="askfoot">Or write your own answer below.</p>' : '';
34
+ return `<p class="agtag">Claude asks</p>${body}${send}${foot}`;
35
+ }
@@ -0,0 +1,12 @@
1
+ /* chat-term — the chat header's Open in terminal icon (chat-open-in-terminal, Wawan 2026-10-22). Pure: no DOM, so Node tests it.
2
+ * A running session opens in the console's terminal, attached to the same process (/console.html?term=<id>), in a new tab.
3
+ * An ended chat copies the line that resumes its Claude Code conversation in a terminal (lib/briefing-premium-agent.js resumeCommand).
4
+ * Nothing to open or copy: the icon is hidden. */
5
+ export const TERM_ICON = '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 10 3 2-3 2M12 15h5"/></svg>';
6
+
7
+ /** { live, command, ws } → { href, label } for a running session, { copy, label } for an ended one, or null. */
8
+ export function termTarget({ live = null, command = null, ws = null } = {}) {
9
+ if (live && /^sess-\d+$/.test(String(live))) return { href: '/console.html?term=' + encodeURIComponent(live) + (ws ? '&ws=' + encodeURIComponent(ws) : ''), label: 'Open in terminal' };
10
+ if (command && typeof command === 'string') return { copy: command, label: 'Copy the terminal command' };
11
+ return null;
12
+ }
@@ -10,6 +10,8 @@ import { lineItems, behindOf, whenRead } from './freshness-words.js';
10
10
  import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, goalChipHtml, goalViewHtml, goalNow, slashMatches } from './goal-chat.js';
11
11
  import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
12
12
  import { splitReport, reportChipHtml, blockSig } from './report-chat.js';
13
+ import { askCardHtml, answerText } from './chat-ask.js';
14
+ import { termTarget, TERM_ICON } from './chat-term.js';
13
15
  import { openReportTab } from './premium-report-tab.js';
14
16
  import { openChartTab } from './premium-chart-tab.js';
15
17
  /** A pmos-report block opens the Report tab, or the Chart tab for a chart or a dashboard (premium-reports-from-chat, slice C). */
@@ -304,7 +306,7 @@ function markSeen(key, c) {
304
306
  pmPost('/api/briefing-premium/seen', { key, title: c.title, subject: c.subject, say: c.say, facts: c.facts.slice(0, 12).map((f) => [String(f[0]), String(f[1])]) }).catch(() => {});
305
307
  }
306
308
  export function openDlg(o) {
307
- S.key = o.noteKey || null;
309
+ S.key = o.noteKey || null; syncTerm(null);
308
310
  S.ctx = S.key && S.key.startsWith('pop:') ? { title: o.title, subject: o.sub || '', say: o.say || '', facts: (o.facts || []).filter((f) => f && f[1]) } : null;
309
311
  if (S.ctx) markSeen(S.key, S.ctx);
310
312
  park(); // a page's own control lent to the dialog (the Briefing's product picker) goes home before the pane is replaced
@@ -348,7 +350,7 @@ export function setFocus(f) {
348
350
  $('#dFocus').onclick = () => setFocus(!$('#dlg').classList.contains('focus'));
349
351
  export function closeDlg() {
350
352
  if (chatPage()) return;
351
- clearTimeout(threadTimer); S.key = null; flushNotes(); railOnClose();
353
+ clearTimeout(threadTimer); S.key = null; syncTerm(null); flushNotes(); railOnClose();
352
354
  park();
353
355
  $('#veil').classList.remove('on'); $$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; });
354
356
  $('#dlg').inert = true; document.documentElement.style.overflow = ''; $('#dlg').classList.remove('on');
@@ -369,6 +371,19 @@ export function setMode(m) {
369
371
  if (innerWidth < 1000) setTab(m === 'detail' ? 'out' : 'chat');
370
372
  }
371
373
  $('#dPane').onclick = () => setMode($('#dlg').dataset.mode === 'split' ? 'detail' : 'split');
374
+ /* chat-open-in-terminal: one icon before the conversation toggle. A running session opens in the console terminal (new tab, the same process);
375
+ * an ended chat copies its claude --resume line. Hidden while the dialog has no session. */
376
+ $('#dPane').insertAdjacentHTML('beforebegin', `<button type="button" class="round dx2" id="dTerm" hidden>${TERM_ICON}</button>`);
377
+ function syncTerm(t = null) {
378
+ S.term = t; const b = $('#dTerm'); b.hidden = !t;
379
+ if (t) { b.title = t.label; b.setAttribute('aria-label', t.label); }
380
+ }
381
+ $('#dTerm').onclick = async () => {
382
+ const t = S.term; if (!t) return;
383
+ if (t.href) { window.open(t.href, '_blank', 'noopener'); return; }
384
+ try { await navigator.clipboard.writeText(t.copy); toast('Copied. Paste it in Terminal on the computer PMOS runs on.'); }
385
+ catch { toast('Copy did not work here. The command: ' + t.copy); }
386
+ };
372
387
  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'); }
373
388
  $('#tabGo').onclick = () => setTab('chat');
374
389
  $('#dClose').onclick = closeDlg; $('#veil').onclick = closeDlg;
@@ -423,7 +438,9 @@ export function threadHtml(th) {
423
438
  export { toolLine }; // "Used Read ×2, slack_read_thread": chat-md.js shortens a connector tool's long name
424
439
  /** The session's part of the panel: its turns, the permission question with its options, and Stop while Claude works. Pure, for Node. */
425
440
  /** goal: the key's /goal record (GET /thread), so the newest grilling message can be pressed (slice 2, PRD G4, G5). */
426
- export function sessionHtml(c, goal = null) {
441
+ /** answer: the panel can answer Claude's questions (a chat key's session; a session opened from the list answers in its terminal). */
442
+ const INTERRUPT = /^\[Request interrupted by user/;
443
+ export function sessionHtml(c, goal = null, { answer = false } = {}) {
427
444
  if (!c) return '';
428
445
  if (c.state === 'ended' && !(c.messages || []).length) return turnAgent('<p class="tt" role="status">This session has ended. Your next message starts a new one.</p>');
429
446
  if (c.state !== 'conv' && c.state !== 'ended') return turnAgent(`<p class="tt" role="status">${esc(c.missing || 'Claude is starting.')}</p>`);
@@ -431,8 +448,14 @@ export function sessionHtml(c, goal = null) {
431
448
  const waiting = !c.ask && c.turn !== 'agent' && c.turn !== 'tool';
432
449
  const ctx = new Map(turnsOf(msgs, waiting || c.state === 'ended').filter((t) => t.done).map((t) => [t.at, t.items])); // premium-chat-viewer slice 2
433
450
  const out = msgs.map((m, i) => {
434
- if (m.role === 'user') return turnUser(shownUser(m.text));
435
- if (m.role !== 'assistant') return `<p class="toolline" title="${esc((m.calls || []).map((x) => x.tool + (x.target ? ' ' + x.target : '')).join('\n'))}">${esc(toolLine(m.tools))}</p>`;
451
+ if (m.role === 'user') return INTERRUPT.test(m.text || '') ? '<p class="toolline">Stopped</p>' : turnUser(shownUser(m.text));
452
+ if (m.role !== 'assistant') {
453
+ const line = `<p class="toolline" title="${esc((m.calls || []).map((x) => x.tool + (x.target ? ' ' + x.target : '')).join('\n'))}">${esc(toolLine(m.tools))}</p>`;
454
+ if (!m.ask) return line;
455
+ // chat-ask-card: Claude's question is a card; it can be answered until the PM writes again
456
+ const live = answer && c.state !== 'ended' && !msgs.slice(i + 1).some((x) => x.role === 'user');
457
+ return line + turnAgent(askCardHtml(m.ask, { live, picked: live ? (ASKS.picked[askId(m)] || {}) : {}, at: askId(m) }));
458
+ }
436
459
  const g = splitGoal(m.text), rp = splitReport(g.text); // premium-reports-from-chat: a pmos-report block becomes a chip that opens the Report tab
437
460
  const live = i === last && waiting && !!goal && goal.state === 'grilling';
438
461
  return turnAgent(`<p class="agtag">Claude</p>${rp.text ? mdHtml(rp.text) : ''}${goalBlockHtml(g.block, { live, state: goal && goal.state })}${reportChipHtml(rp.block, i)}${chipsHtml(ctx.get(i))}`);
@@ -479,9 +502,11 @@ export function drawThread(th, key, conv) {
479
502
  drawLead(box, th);
480
503
  let t = $('#thr', box); if (!t) { box.insertAdjacentHTML('beforeend', '<div id="thr"></div>'); t = $('#thr', box); }
481
504
  const b = $('#dBody'), atEnd = b.scrollHeight - b.scrollTop - b.clientHeight < 80;
482
- putHtml(t, threadHtml(th) + sessionHtml(conv, th.goal));
505
+ S.conv = conv;
506
+ putHtml(t, threadHtml(th) + sessionHtml(conv, th.goal, { answer: true }));
483
507
  ctxAuto(key, conv);
484
508
  S.goal = th.goal || null; S.draft = readyDraft(conv); S.session = th.session || null;
509
+ syncTerm(termTarget({ live: th.session, command: th.resume, ws: new URLSearchParams(location.search).get('ws') }));
485
510
  goalView(key, conv);
486
511
  reportAuto(key, conv);
487
512
  const go = $('#askGo'); if (go) go.disabled = !!th.working; // an earlier read-only run still answering
@@ -640,6 +665,27 @@ async function sendText(key, text, files) {
640
665
  loadThread(key);
641
666
  return true;
642
667
  }
668
+ /* chat-ask-card: the options of a card with several questions toggle, and Send answers sends them as one message */
669
+ const ASKS = { picked: {} };
670
+ const askId = (m) => String(m.at || '') + ':' + (m.ask || []).map((q) => q.question).join('|').slice(0, 80);
671
+ function askOf(id) { const m = ((S.conv && S.conv.messages) || []).find((x) => x.role === 'tool' && x.ask && askId(x) === id); return m ? m.ask : null; }
672
+ $('#dBody').addEventListener('click', async (e) => {
673
+ const pick = e.target.closest('[data-ask-pick]'), send = e.target.closest('[data-ask-send]');
674
+ if (!S.key || (!pick && !send)) return;
675
+ if (pick) {
676
+ const card = pick.closest('.tc'), btn = card && card.querySelector('[data-ask-send]');
677
+ const at = btn ? btn.dataset.askSend : null, ask = at != null && askOf(at); if (!ask) return;
678
+ const [q, k] = pick.dataset.askPick.split(':').map(Number);
679
+ const cur = (ASKS.picked[at] = ASKS.picked[at] || {}), had = cur[q] || [];
680
+ cur[q] = had.includes(k) ? had.filter((x) => x !== k) : ask[q].multi ? had.concat(k) : [k];
681
+ card.innerHTML = askCardHtml(ask, { live: true, picked: cur, at }); // the next poll draws the same picks
682
+ return;
683
+ }
684
+ const ask = askOf(send.dataset.askSend), text = ask && answerText(ask, ASKS.picked[send.dataset.askSend]);
685
+ if (!text) return;
686
+ send.disabled = true;
687
+ if (await sendText(S.key, text)) delete ASKS.picked[send.dataset.askSend];
688
+ });
643
689
  async function onGoalPress(e) {
644
690
  const say = e.target.closest('[data-chat-say]'), gb = e.target.closest('[data-goal]'), mi = e.target.closest('[data-slash]');
645
691
  if (mi) { pickSlash(mi.dataset.slash); return; }
@@ -1353,6 +1399,7 @@ async function loadSid(id) {
1353
1399
  clearTimeout(R.sidTimer);
1354
1400
  const c = await pmGet('/api/sessions/conversation?id=' + encodeURIComponent(id)).catch(() => null);
1355
1401
  if (S.sid !== id) return;
1402
+ syncTerm(termTarget({ live: c && c.ok && c.state !== 'ended' ? id : null }));
1356
1403
  const box = $('#dBody .stream'); if (!box) return;
1357
1404
  const b = $('#dBody'), atEnd = b.scrollHeight - b.scrollTop - b.clientHeight < 80;
1358
1405
  putHtml(box, c && c.ok ? sessionHtml(c) : turnA(ptx('The conversation of this session could not be read.')));
@@ -2675,3 +2675,11 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2675
2675
  .plead p{margin:0 0 6px;font-size:var(--fs-3);line-height:1.5;overflow-wrap:anywhere}
2676
2676
  .plead .fine2{color:var(--ink-3)}
2677
2677
  .plead.none{display:flex;align-items:center;gap:10px;justify-content:space-between}.plead.none p{margin:0}
2678
+
2679
+ /* ── chat-ask-card (bug 2026-10-22): Claude's question in the chat panel, with its options as buttons. public/pm/chat-ask.js ── */
2680
+ .askq+.askq{margin-top:14px}
2681
+ .askh{margin:0 0 2px;font:600 var(--t-micro) var(--mono);color:var(--ink-3);text-transform:uppercase;letter-spacing:.04em}
2682
+ .chip.on{background:var(--solid);color:var(--on-solid);border-color:transparent}
2683
+ .askfoot{margin:8px 0 0;font-size:var(--t-small);color:var(--ink-3)}
2684
+ /* chat-open-in-terminal: the header's terminal icon shows only while the dialog has a session to open or resume */
2685
+ #dTerm[hidden]{display:none}
@@ -3915,6 +3915,14 @@ const chatSessions = {
3915
3915
  end: (id) => { const s = sessions.get(String(id || '')); if (!s || !s.pty || s.state === 'exited') return false; s.autoEnded = true; s.note = 'ended: room for a newer chat (it resumes on its next message)'; if (s.tmux) tmuxKillSession(s.tmux); try { s.pty.kill(); } catch {} return true; },
3916
3916
  // slice 4 (PRD L2): whether Claude Code still has the conversation file for this id (any project folder of any Claude home)
3917
3917
  hasConversation: (uuid) => !!chatConversationFile(uuid, { live: true }),
3918
+ // chat-open-in-terminal: the line that resumes this Claude id in a terminal, from the folder its own file records, or null
3919
+ resumeCommand: (uuid) => {
3920
+ const f = chatConversationFile(uuid, { live: true });
3921
+ if (!f) return null;
3922
+ let cwd = null;
3923
+ try { for (const l of fs.readFileSync(f, 'utf8').split('\n', 200)) { if (!l) continue; let r; try { r = JSON.parse(l); } catch { continue; } if (r && typeof r.cwd === 'string' && r.cwd) { cwd = r.cwd; break; } } } catch { return null; }
3924
+ return require('./lib/briefing-premium-agent.js').resumeCommand({ uuid, cwd, home: path.dirname(path.dirname(path.dirname(f))), defaultHome: path.join(os.homedir(), '.claude') });
3925
+ },
3918
3926
  // item-chat-history: the conversation of one Claude id, as the panel draws it, or null when no file is left
3919
3927
  conversation: (uuid) => { const f = chatConversationFile(uuid); return f ? transcript.readConversation(f, scrub, transcript.CONV_LIMIT).messages : null; },
3920
3928
  };
@@ -39,6 +39,7 @@
39
39
  "briefing-premium-writes.test.js",
40
40
  "briefing-premium-agent.test.js",
41
41
  "goal-chat.test.js",
42
+ "chat-ask.test.js",
42
43
  "chat-md.test.js",
43
44
  "md-table.test.js",
44
45
  "chat-file-locate.test.js",
@@ -217,6 +218,7 @@
217
218
  "briefing-premium-writes.test.js": 1,
218
219
  "briefing-premium-agent.test.js": 1,
219
220
  "goal-chat.test.js": 1,
221
+ "chat-ask.test.js": 1,
220
222
  "chat-md.test.js": 1,
221
223
  "md-table.test.js": 1,
222
224
  "chat-file-locate.test.js": 1,
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "The chat header's Open in terminal icon: a running session opens the console terminal of the same session in a new tab, an ended chat copies its claude --resume line, no session shows no icon; /console.html?term= opens the session sheet on its terminal at 1280 and 390. Real server.",
3
+ "seconds": {
4
+ "premium-chat-term-test.js": 40
5
+ },
6
+ "panels": [
7
+ "premium-chat-term-test.js"
8
+ ]
9
+ }