create-pmos 0.393.0 → 0.395.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 +25 -25
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/REMOTE.md +7 -2
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +1 -0
- package/workspace/item-chat-history-test.js +3 -1
- package/workspace/lib/briefing-premium-agent.js +10 -1
- package/workspace/lib/routes-briefing-premium.js +4 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-term-test.js +91 -0
- package/workspace/public/pm/c3-boot.js +2 -1
- package/workspace/public/pm/c3-shell.js +2 -0
- package/workspace/public/pm/chat-term.js +12 -0
- package/workspace/public/pm/premium-shell.js +18 -2
- package/workspace/public/pm/premium.css +2 -0
- package/workspace/server.js +8 -0
- package/workspace/test-lists/premium-chat-term.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.395.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.395.0",
|
|
37
|
+
"at": "2026-10-22T10:27:24.369Z",
|
|
38
|
+
"f": 2,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 1009,
|
|
42
|
+
"t": "Keep share.pm-os.app out of the workspace Access application",
|
|
43
|
+
"s": "Keep share.pm-os.app out of the workspace Access application"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"v": "0.394.0",
|
|
49
|
+
"at": "2026-10-22T04:51:35.949Z",
|
|
50
|
+
"f": 2,
|
|
51
|
+
"prs": [
|
|
52
|
+
{
|
|
53
|
+
"n": 1008,
|
|
54
|
+
"t": "Open in terminal icon in the chat header",
|
|
55
|
+
"s": "Open in terminal icon in the chat header"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
35
59
|
{
|
|
36
60
|
"v": "0.393.0",
|
|
37
61
|
"at": "2026-10-22T04:08:26.227Z",
|
|
@@ -272,30 +296,6 @@
|
|
|
272
296
|
"s": "Chat page viewer stays closed until something opens in it"
|
|
273
297
|
}
|
|
274
298
|
]
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
"v": "0.375.0",
|
|
278
|
-
"at": "2026-10-21T04:39:03.068Z",
|
|
279
|
-
"f": 2,
|
|
280
|
-
"prs": [
|
|
281
|
-
{
|
|
282
|
-
"n": 983,
|
|
283
|
-
"t": "A Focus button replaces the automatic hiding on a phone",
|
|
284
|
-
"s": "A Focus button replaces the automatic hiding on a phone"
|
|
285
|
-
}
|
|
286
|
-
]
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
"v": "0.374.0",
|
|
290
|
-
"at": "2026-10-21T04:16:12.143Z",
|
|
291
|
-
"f": 2,
|
|
292
|
-
"prs": [
|
|
293
|
-
{
|
|
294
|
-
"n": 980,
|
|
295
|
-
"t": "Ending an item's chat session keeps its conversation",
|
|
296
|
-
"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."
|
|
297
|
-
}
|
|
298
|
-
]
|
|
299
299
|
}
|
|
300
300
|
]
|
|
301
301
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-22T10:27:21Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-22T10:27:21Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-22T10:27:21Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/REMOTE.md
CHANGED
|
@@ -237,11 +237,15 @@ Do these steps one time, on the computer that runs the workspace:
|
|
|
237
237
|
- service: http_status:404
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
-
3. **
|
|
240
|
+
3. **Keep `share.pm-os.app` out of your workspace's Access application.** In Cloudflare Zero Trust, open **Access › Applications** and edit the application for the workspace. Open its domains list:
|
|
241
|
+
- If the list has `share.pm-os.app`, remove that line and save. Do not add it to any application.
|
|
242
|
+
- If the list has a wildcard (`*.pm-os.app`), keep it. Then add a second **Self-hosted** application with the domain `share.pm-os.app`. Give it one policy, with the action **Bypass** and the selector **Everyone**. The more exact hostname wins over the wildcard.
|
|
243
|
+
|
|
244
|
+
The share server has its own password check, so it does not need a Cloudflare sign-in.
|
|
241
245
|
|
|
242
246
|
4. Turn Online off and on again in **Settings › Online**, so the tunnel reads the new rule.
|
|
243
247
|
|
|
244
|
-
Check it: open `https://share.pm-os.app/robots.txt` in a private window. It shows `Disallow: /` with no sign-in. Any other path shows "Not found". A link opens only while this computer is on and Online runs.
|
|
248
|
+
Check it: make one link, then open `https://share.pm-os.app/robots.txt` in a private window. It shows `Disallow: /` with no sign-in. If it shows a Cloudflare Access sign-in page, an Access application still covers the hostname: do step 3 again. Any other path shows "Not found". A link opens only while this computer is on and Online runs.
|
|
245
249
|
|
|
246
250
|
What a link does:
|
|
247
251
|
|
|
@@ -257,6 +261,7 @@ What a link does:
|
|
|
257
261
|
- **`403` "forbidden origin/host" on the public hostname** — `PMOS_PUBLIC_HOST` is not set, or it names another hostname, or the tunnel rewrites the `Host` header. Remove `httpHostHeader` from the tunnel's ingress rule.
|
|
258
262
|
- **A local reverse proxy now gets `401`** — it adds a forwarding header, so its requests need the token. This is intended.
|
|
259
263
|
- **`403` "your Cloudflare sign-in could not be verified for this workspace"** (Online switch) — check the AUD tag, the team domain and the email in **Settings › Online**. The email must be the one you sign in with. Settings › Online on the desktop names the check that refused the last sign-in. To see which email Cloudflare signed you in with, open `https://<your address>/cdn-cgi/access/get-identity` and read `email`.
|
|
264
|
+
- **A share link asks for a Cloudflare Access sign-in** — an Access application covers `share.pm-os.app`, as a listed domain or as a wildcard. Do [Share links](#share-links-a-second-hostname-without-access) step 3. To check it from a terminal, run `curl -sI https://share.pm-os.app/robots.txt`. A `302` to `<team>.cloudflareaccess.com` means that Access is still in front of the hostname.
|
|
260
265
|
- **Cloudflare error 1033** — the tunnel is not running. In **Settings › Online**, check the status line, and read `online-tunnel.log` in the workspace state folder. Another `cloudflared` for the same tunnel (for example a service you installed) also serves the hostname.
|
|
261
266
|
|
|
262
267
|
- **"refusing to bind … only loopback or a Tailscale tailnet address (100.64.0.0/10) is permitted"** — you passed `PMOS_BIND_ADDR` (or `PMOS_TAILNET_IP`) that isn't loopback or tailnet. Use your real `tailscale ip -4` value.
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.395.0",
|
|
4
|
+
"at": "2026-10-22T10:27:24.369Z",
|
|
5
|
+
"f": 2,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1009,
|
|
9
|
+
"t": "Keep share.pm-os.app out of the workspace Access application",
|
|
10
|
+
"s": "Keep share.pm-os.app out of the workspace Access application"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"v": "0.394.0",
|
|
16
|
+
"at": "2026-10-22T04:51:35.949Z",
|
|
17
|
+
"f": 2,
|
|
18
|
+
"prs": [
|
|
19
|
+
{
|
|
20
|
+
"n": 1008,
|
|
21
|
+
"t": "Open in terminal icon in the chat header",
|
|
22
|
+
"s": "Open in terminal icon in the chat header"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
2
26
|
{
|
|
3
27
|
"v": "0.393.0",
|
|
4
28
|
"at": "2026-10-22T04:08:26.227Z",
|
|
@@ -433,6 +433,7 @@ Every popup has this chat, including the ones that have no row of their own: a t
|
|
|
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
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.
|
|
436
437
|
- **Stop** shows while Claude works. It presses Esc in the session. If Claude was stopped, the conversation shows a grey "Stopped" line.
|
|
437
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.
|
|
438
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.
|
|
@@ -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 };
|
|
@@ -233,7 +233,10 @@ module.exports = {
|
|
|
233
233
|
const history = !live && ctx.runtimeDir ? Ag.chatHistory({ runtimeDir: ctx.runtimeDir, key, sessions: ctx.chatSessions }) : null;
|
|
234
234
|
// popup context slice 3: a popup's stored lead comes with its thread, so the popup shows it first and starts nothing
|
|
235
235
|
const lead = key.startsWith('pop:') && ctx.runtimeDir ? Leads.get(ctx.runtimeDir, key) : undefined;
|
|
236
|
-
|
|
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 } : {}) });
|
|
237
240
|
return true;
|
|
238
241
|
}
|
|
239
242
|
if (url.pathname !== '/api/briefing-premium') return false;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.395.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.395.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -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
|
-
|
|
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,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
|
+
}
|
|
@@ -11,6 +11,7 @@ import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, goalChipHtml, go
|
|
|
11
11
|
import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
|
|
12
12
|
import { splitReport, reportChipHtml, blockSig } from './report-chat.js';
|
|
13
13
|
import { askCardHtml, answerText } from './chat-ask.js';
|
|
14
|
+
import { termTarget, TERM_ICON } from './chat-term.js';
|
|
14
15
|
import { openReportTab } from './premium-report-tab.js';
|
|
15
16
|
import { openChartTab } from './premium-chart-tab.js';
|
|
16
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). */
|
|
@@ -305,7 +306,7 @@ function markSeen(key, c) {
|
|
|
305
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(() => {});
|
|
306
307
|
}
|
|
307
308
|
export function openDlg(o) {
|
|
308
|
-
S.key = o.noteKey || null;
|
|
309
|
+
S.key = o.noteKey || null; syncTerm(null);
|
|
309
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;
|
|
310
311
|
if (S.ctx) markSeen(S.key, S.ctx);
|
|
311
312
|
park(); // a page's own control lent to the dialog (the Briefing's product picker) goes home before the pane is replaced
|
|
@@ -349,7 +350,7 @@ export function setFocus(f) {
|
|
|
349
350
|
$('#dFocus').onclick = () => setFocus(!$('#dlg').classList.contains('focus'));
|
|
350
351
|
export function closeDlg() {
|
|
351
352
|
if (chatPage()) return;
|
|
352
|
-
clearTimeout(threadTimer); S.key = null; flushNotes(); railOnClose();
|
|
353
|
+
clearTimeout(threadTimer); S.key = null; syncTerm(null); flushNotes(); railOnClose();
|
|
353
354
|
park();
|
|
354
355
|
$('#veil').classList.remove('on'); $$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; });
|
|
355
356
|
$('#dlg').inert = true; document.documentElement.style.overflow = ''; $('#dlg').classList.remove('on');
|
|
@@ -370,6 +371,19 @@ export function setMode(m) {
|
|
|
370
371
|
if (innerWidth < 1000) setTab(m === 'detail' ? 'out' : 'chat');
|
|
371
372
|
}
|
|
372
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
|
+
};
|
|
373
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'); }
|
|
374
388
|
$('#tabGo').onclick = () => setTab('chat');
|
|
375
389
|
$('#dClose').onclick = closeDlg; $('#veil').onclick = closeDlg;
|
|
@@ -492,6 +506,7 @@ export function drawThread(th, key, conv) {
|
|
|
492
506
|
putHtml(t, threadHtml(th) + sessionHtml(conv, th.goal, { answer: true }));
|
|
493
507
|
ctxAuto(key, conv);
|
|
494
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') }));
|
|
495
510
|
goalView(key, conv);
|
|
496
511
|
reportAuto(key, conv);
|
|
497
512
|
const go = $('#askGo'); if (go) go.disabled = !!th.working; // an earlier read-only run still answering
|
|
@@ -1384,6 +1399,7 @@ async function loadSid(id) {
|
|
|
1384
1399
|
clearTimeout(R.sidTimer);
|
|
1385
1400
|
const c = await pmGet('/api/sessions/conversation?id=' + encodeURIComponent(id)).catch(() => null);
|
|
1386
1401
|
if (S.sid !== id) return;
|
|
1402
|
+
syncTerm(termTarget({ live: c && c.ok && c.state !== 'ended' ? id : null }));
|
|
1387
1403
|
const box = $('#dBody .stream'); if (!box) return;
|
|
1388
1404
|
const b = $('#dBody'), atEnd = b.scrollHeight - b.scrollTop - b.clientHeight < 80;
|
|
1389
1405
|
putHtml(box, c && c.ok ? sessionHtml(c) : turnA(ptx('The conversation of this session could not be read.')));
|
|
@@ -2681,3 +2681,5 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
2681
2681
|
.askh{margin:0 0 2px;font:600 var(--t-micro) var(--mono);color:var(--ink-3);text-transform:uppercase;letter-spacing:.04em}
|
|
2682
2682
|
.chip.on{background:var(--solid);color:var(--on-solid);border-color:transparent}
|
|
2683
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}
|
package/workspace/server.js
CHANGED
|
@@ -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
|
};
|
|
@@ -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
|
+
}
|