create-pmos 0.373.0 → 0.375.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/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +3 -2
- package/workspace/item-chat-history-test.js +101 -0
- package/workspace/lib/briefing-premium-agent.js +31 -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-phone-room-test.js +28 -41
- package/workspace/public/pm/c3-session-conv.js +3 -2
- package/workspace/public/pm/premium-shell.js +19 -25
- package/workspace/public/pm/premium.css +10 -6
- package/workspace/server.js +45 -8
- package/workspace/test-lists/item-chat-history.json +9 -0
- package/workspace/test-lists/premium-phone-room.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.375.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.375.0",
|
|
37
|
+
"at": "2026-10-21T04:39:03.068Z",
|
|
38
|
+
"f": 2,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 983,
|
|
42
|
+
"t": "A Focus button replaces the automatic hiding on a phone",
|
|
43
|
+
"s": "A Focus button replaces the automatic hiding on a phone"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"v": "0.374.0",
|
|
49
|
+
"at": "2026-10-21T04:16:12.143Z",
|
|
50
|
+
"f": 2,
|
|
51
|
+
"prs": [
|
|
52
|
+
{
|
|
53
|
+
"n": 980,
|
|
54
|
+
"t": "Ending an item's chat session keeps its conversation",
|
|
55
|
+
"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."
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
35
59
|
{
|
|
36
60
|
"v": "0.373.0",
|
|
37
61
|
"at": "2026-10-21T03:11:16.462Z",
|
|
@@ -297,30 +321,6 @@
|
|
|
297
321
|
"s": "The conversation stays still."
|
|
298
322
|
}
|
|
299
323
|
]
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
"v": "0.355.0",
|
|
303
|
-
"at": "2026-10-20T09:07:17.325Z",
|
|
304
|
-
"f": 2,
|
|
305
|
-
"prs": [
|
|
306
|
-
{
|
|
307
|
-
"n": 954,
|
|
308
|
-
"t": "A Scratchpad in the chat panel",
|
|
309
|
-
"s": "A Scratchpad chip under the message box opens a pad above it."
|
|
310
|
-
}
|
|
311
|
-
]
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
"v": "0.354.0",
|
|
315
|
-
"at": "2026-10-20T08:48:31.686Z",
|
|
316
|
-
"f": 2,
|
|
317
|
-
"prs": [
|
|
318
|
-
{
|
|
319
|
-
"n": 953,
|
|
320
|
-
"t": "Multi-line chat reply box in premium dialogs",
|
|
321
|
-
"s": "The box takes several lines."
|
|
322
|
-
}
|
|
323
|
-
]
|
|
324
324
|
}
|
|
325
325
|
]
|
|
326
326
|
}
|
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-21T04:39:00Z"}
|
|
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-21T04:39:00Z"}
|
|
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-21T04:39:00Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.375.0",
|
|
4
|
+
"at": "2026-10-21T04:39:03.068Z",
|
|
5
|
+
"f": 2,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 983,
|
|
9
|
+
"t": "A Focus button replaces the automatic hiding on a phone",
|
|
10
|
+
"s": "A Focus button replaces the automatic hiding on a phone"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"v": "0.374.0",
|
|
16
|
+
"at": "2026-10-21T04:16:12.143Z",
|
|
17
|
+
"f": 2,
|
|
18
|
+
"prs": [
|
|
19
|
+
{
|
|
20
|
+
"n": 980,
|
|
21
|
+
"t": "Ending an item's chat session keeps its conversation",
|
|
22
|
+
"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."
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
2
26
|
{
|
|
3
27
|
"v": "0.373.0",
|
|
4
28
|
"at": "2026-10-21T03:11:16.462Z",
|
|
@@ -383,7 +383,7 @@ The premium Briefing is the default page: `/` and `/index.html` open it. The con
|
|
|
383
383
|
|
|
384
384
|
**The short head.** On a phone or tablet every dialog has a short head: no category line, a title of two lines at most and a sub line of one line. The **Sessions** chip shows only its dot and count. Press the title to see the whole title, the category line and the whole sub line; press it again to make the head short. When you scroll the detail, the head keeps only the title and the tools, so the detail gets most of the screen. Scroll back to the top to see the sub line and the Detail and Conversation switch again.
|
|
385
385
|
|
|
386
|
-
**
|
|
386
|
+
**Focus.** On a phone or tablet the dialog's head has a **Focus** button. Press it and the dialog takes the whole screen: the head keeps only the title and the button, and on the Chat page the bar at the bottom moves away. Press it again to see everything again. Nothing hides by itself when you scroll or type.
|
|
387
387
|
|
|
388
388
|
On a phone or tablet (under 1000 px) every dialog opens on **Detail**. On a touch screen every text field, the reply box included, uses 16 px type, so typing in one does not zoom the page. A card's label and value rows (for example **Blocked at** and **Initiative** in "The way through") stay as two columns, one row per label. A **Detail / Conversation** switch sits under the title, and **Open it** at the foot of Detail brings the conversation when an action waits there. The header holds only **Close**. A document sheet picks its view (**Read**, **Edit**, **Proposals**, **Edit log**, **Health**, **Relations**) from one button with a menu.
|
|
389
389
|
|
|
@@ -420,7 +420,8 @@ The conversation beside every premium dialog is a real Claude Code session. Anyt
|
|
|
420
420
|
- **While a session runs**, the panel reads it again every 2 seconds and changes only when there is something new. The messages already on screen stay still, so nothing blinks beside the viewer.
|
|
421
421
|
- **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.
|
|
422
422
|
- **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.
|
|
423
|
-
- **The session** is also listed in **Sessions** and in the console, where you can open its terminal.
|
|
423
|
+
- **The session** is also listed in **Sessions** and in the console, where you can open its terminal.
|
|
424
|
+
- **Ending a session ends only its process.** Whether you press End in the session list, or PMOS ends an idle chat, the conversation stays with the row: the panel and the session's own view still show every turn, read from Claude Code's record (in whichever Claude login ran it, such as `~/.claude-personal`). PMOS also keeps a copy in its own state folder (`chat-history/`), so the conversation stays after Claude Code removes old records. Files the session wrote are never touched. Your next message picks up the same conversation.
|
|
424
425
|
- Answers from the older read-only agent stay above the session, marked "Earlier read-only answer".
|
|
425
426
|
|
|
426
427
|
Sending and the option presses need the page's launch nonce, so an agent session cannot type into your chat.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* item-chat-history-test — ending an item's chat session ends only the process (bug 2026-10-21: "Update TSC deck" lost its conversation).
|
|
4
|
+
*
|
|
5
|
+
* A real server with its own state and a stub `claude`. The state is seeded as an item chat leaves it: the key → session record with its
|
|
6
|
+
* Claude Code conversation id, the session's record (its process gone), the conversation file in a Claude home that is a profile's
|
|
7
|
+
* (not ~/.claude), and a file the session wrote. Then: the item's thread shows the conversation; End removes the session; the thread still
|
|
8
|
+
* shows every turn, the file it wrote and the conversation file are untouched, a copy is kept in the runtime state; the conversation still
|
|
9
|
+
* shows when Claude Code's own file is pruned; and the next message resumes the same conversation (claude --resume <id>). */
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const os = require('os');
|
|
12
|
+
const net = require('net');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { spawn, spawnSync } = require('child_process');
|
|
15
|
+
|
|
16
|
+
const results = [];
|
|
17
|
+
const ok = (name, cond, detail = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${cond || !detail ? '' : '\n ' + String(detail).slice(0, 400)}`); };
|
|
18
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
19
|
+
const waitFor = async (fn, ms = 20000) => { const end = Date.now() + ms; while (Date.now() < end) { try { const v = await fn(); if (v) return v; } catch {} await sleep(200); } return null; };
|
|
20
|
+
const freePort = () => new Promise((res) => { const s = net.createServer(); s.listen(0, '127.0.0.1', () => { const p = s.address().port; s.close(() => res(p)); }); });
|
|
21
|
+
|
|
22
|
+
(async () => {
|
|
23
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'pmos-ich-'));
|
|
24
|
+
const sock = 'ich-' + process.pid;
|
|
25
|
+
let srv = null;
|
|
26
|
+
try {
|
|
27
|
+
const root = path.join(tmp, 'alpha');
|
|
28
|
+
fs.mkdirSync(root, { recursive: true });
|
|
29
|
+
spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: root });
|
|
30
|
+
const port = await freePort();
|
|
31
|
+
const state = path.join(tmp, 'state');
|
|
32
|
+
const home = path.join(tmp, 'claude-personal'); // the profile's CLAUDE_CONFIG_DIR, not ~/.claude
|
|
33
|
+
const fakeBin = path.join(tmp, 'bin'); fs.mkdirSync(fakeBin, { recursive: true });
|
|
34
|
+
const rec = path.join(tmp, 'rec'); fs.mkdirSync(rec);
|
|
35
|
+
fs.writeFileSync(path.join(fakeBin, 'claude'), `#!/bin/sh\nprintf '%s\\n' "$@" > "${rec}/args.$(date +%s%N)"\ncat > /dev/null\n`, { mode: 0o755 });
|
|
36
|
+
|
|
37
|
+
// the state an item chat leaves behind
|
|
38
|
+
const key = 'work:item-tsc', uuid = '685a486b-d916-4002-9629-5e0fa33eaa9b', sid = 'sess-901';
|
|
39
|
+
fs.mkdirSync(path.join(state, 'sessions'), { recursive: true });
|
|
40
|
+
fs.writeFileSync(path.join(state, 'premium-chat-sessions.jsonl'), JSON.stringify({ key, session: sid, claude: uuid, name: 'chat: Update TSC deck', at: '2026-10-20T06:53:43.000Z' }) + '\n');
|
|
41
|
+
fs.writeFileSync(path.join(state, 'sessions', sid + '.json'), JSON.stringify({ id: sid, name: 'chat: Update TSC deck', agent: 'claude', cwd: root, root, state: 'working', created: '2026-10-20T06:53:43.000Z', tmux: 'pmos-gone-901', origin: 'chat:' + key }));
|
|
42
|
+
fs.writeFileSync(path.join(state, 'sessions', sid + '.scrollback'), 'the last screen');
|
|
43
|
+
const conv = path.join(home, 'projects', '-alpha', uuid + '.jsonl');
|
|
44
|
+
fs.mkdirSync(path.dirname(conv), { recursive: true });
|
|
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' } })
|
|
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
|
+
+ line({ type: 'user', timestamp: '2026-10-20T07:10:00Z', message: { role: 'user', content: 'Split status and remarks' } })
|
|
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.' }] } });
|
|
50
|
+
fs.writeFileSync(conv, convText);
|
|
51
|
+
const result = path.join(root, 'tsc-deck.html');
|
|
52
|
+
fs.writeFileSync(result, '<h1>TSC deck</h1>');
|
|
53
|
+
|
|
54
|
+
const env = { ...process.env, PMOS_STATE_DIR: state, PMOS_WS_PORT: String(port), PMOS_TMUX_SOCK: sock, PMOS_CLAUDE_HOME: home, PATH: fakeBin + path.delimiter + process.env.PATH };
|
|
55
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, env, stdio: 'ignore' });
|
|
56
|
+
const base = `http://127.0.0.1:${port}`;
|
|
57
|
+
const R = async (m, p, b, headers) => { const res = await fetch(base + p, { method: m, headers: { 'content-type': 'application/json', ...(headers || {}) }, body: b ? JSON.stringify(b) : undefined }); let j = null; try { j = await res.json(); } catch {} return { status: res.status, body: j }; };
|
|
58
|
+
ok('H0 a scratch server is up', !!await waitFor(async () => (await fetch(base + '/api/sessions')).ok));
|
|
59
|
+
const html = await (await fetch(base + '/')).text();
|
|
60
|
+
const nonce = (/<meta name="pmos-nonce" content="([^"]*)"/.exec(html) || [])[1] || '';
|
|
61
|
+
const press = { Origin: base, ...(nonce ? { 'x-pmos-nonce': nonce } : {}) };
|
|
62
|
+
const thread = () => R('GET', '/api/briefing-premium/thread?key=' + encodeURIComponent(key));
|
|
63
|
+
const texts = (t) => ((t.body && t.body.history && t.body.history.messages) || []).map((m) => m.text || '').join(' | ');
|
|
64
|
+
|
|
65
|
+
const ended = await waitFor(async () => { const s = (await R('GET', '/api/sessions')).body.sessions.find((x) => x.id === sid); return s && s.state === 'exited' ? s : null; });
|
|
66
|
+
ok('H1 the chat session is restored as ended (its process is gone)', !!ended);
|
|
67
|
+
const t1 = await thread();
|
|
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
|
+
const c1 = await R('GET', '/api/sessions/conversation?id=' + sid);
|
|
70
|
+
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
|
+
|
|
72
|
+
const rm = await R('POST', '/api/session/remove', { id: sid }, press);
|
|
73
|
+
ok('H4 End removes the session from the list', rm.status === 200 && rm.body.removed === true && !(await R('GET', '/api/sessions')).body.sessions.some((x) => x.id === sid), JSON.stringify(rm.body));
|
|
74
|
+
const t2 = await thread();
|
|
75
|
+
ok('H5 after End the item still shows every turn of its conversation', t2.body.history && t2.body.history.messages.filter((m) => m.role === 'assistant').length === 2 && /Update the TSC deck/.test(texts(t2)), JSON.stringify(t2.body));
|
|
76
|
+
ok('H6 the files the session wrote are untouched', fs.existsSync(result) && fs.readFileSync(result, 'utf8') === '<h1>TSC deck</h1>');
|
|
77
|
+
ok('H7 Claude Code\'s conversation file is untouched', fs.existsSync(conv) && fs.readFileSync(conv, 'utf8') === convText);
|
|
78
|
+
const kept = path.join(state, 'chat-history', uuid + '.jsonl');
|
|
79
|
+
ok('H8 a copy of the conversation is kept in the runtime state', fs.existsSync(kept) && fs.readFileSync(kept, 'utf8') === convText);
|
|
80
|
+
ok('H9 the item\'s link to its conversation is kept', fs.readFileSync(path.join(state, 'premium-chat-sessions.jsonl'), 'utf8').includes(uuid));
|
|
81
|
+
|
|
82
|
+
const moved = conv + '.pruned'; fs.renameSync(conv, moved);
|
|
83
|
+
const t3 = await thread();
|
|
84
|
+
ok('H10 when Claude Code prunes its file, the kept copy still shows the conversation', /Remarks carries the next step/.test(texts(t3)), JSON.stringify(t3.body));
|
|
85
|
+
fs.renameSync(moved, conv);
|
|
86
|
+
|
|
87
|
+
const next = await R('POST', '/api/briefing-premium/ask', { key, text: 'Add the roadmap slide' }, press);
|
|
88
|
+
ok('H11 the next message resumes the same conversation', next.status === 200 && next.body.resumed === true && next.body.session, JSON.stringify(next.body));
|
|
89
|
+
const args = await waitFor(async () => { const f = fs.readdirSync(rec).find((x) => x.startsWith('args.')); return f ? fs.readFileSync(path.join(rec, f), 'utf8').split('\n') : null; });
|
|
90
|
+
ok('H12 claude is started with --resume and the conversation id from the profile\'s Claude home', args && args.includes('--resume') && args.includes(uuid), args && args.join(' '));
|
|
91
|
+
} catch (e) {
|
|
92
|
+
ok('the suite ran without throwing', false, e && e.stack);
|
|
93
|
+
} finally {
|
|
94
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch {} }
|
|
95
|
+
spawnSync('tmux', ['-L', sock, 'kill-server'], { stdio: 'ignore' });
|
|
96
|
+
try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {}
|
|
97
|
+
}
|
|
98
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
99
|
+
console.log(`\n${results.length - bad}/${results.length} item-chat-history assertions passed`);
|
|
100
|
+
process.exit(bad ? 1 : 0);
|
|
101
|
+
})();
|
|
@@ -208,6 +208,36 @@ function chatRecordOf(runtimeDir, key) {
|
|
|
208
208
|
return rec;
|
|
209
209
|
}
|
|
210
210
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
211
|
+
/** Every record for a key in premium-chat-sessions.jsonl, oldest first. */
|
|
212
|
+
function chatRecordsOf(runtimeDir, key) {
|
|
213
|
+
let t; try { t = fs.readFileSync(path.join(runtimeDir, CHATS), 'utf8'); } catch { return []; }
|
|
214
|
+
const out = [];
|
|
215
|
+
for (const l of t.split('\n')) { if (!l.trim()) continue; let e; try { e = JSON.parse(l); } catch { continue; } if (e && e.key === key && typeof e.session === 'string') out.push(e); }
|
|
216
|
+
return out;
|
|
217
|
+
}
|
|
218
|
+
/** The Claude Code conversation id a PMOS session was started with, from its record, or null. */
|
|
219
|
+
function chatClaudeOfSession(runtimeDir, key, sessionId) {
|
|
220
|
+
let id = null;
|
|
221
|
+
for (const e of chatRecordsOf(runtimeDir, key)) if (e.session === sessionId && UUID_RE.test(String(e.claude || ''))) id = e.claude;
|
|
222
|
+
return id;
|
|
223
|
+
}
|
|
224
|
+
/* item-chat-history (bug 2026-10-21): the conversation belongs to the item, not to the session. Ending a session (End in the list, the idle
|
|
225
|
+
* sweep, room for a newer chat) ends only the process; the Claude Code conversation file stays, and this reads it back so the item's panel
|
|
226
|
+
* still shows every earlier turn. Each Claude conversation the key ever had is read once, oldest first (a resumed one is the same file).
|
|
227
|
+
* sessions.conversation(uuid) → [messages] or null when the file is gone. */
|
|
228
|
+
function chatHistory({ runtimeDir, key, sessions }) {
|
|
229
|
+
if (!runtimeDir || !sessions || typeof sessions.conversation !== 'function') return { messages: [], conversations: 0 };
|
|
230
|
+
const seen = new Set(), messages = [];
|
|
231
|
+
let conversations = 0;
|
|
232
|
+
for (const e of chatRecordsOf(runtimeDir, key)) {
|
|
233
|
+
const u = String(e.claude || '');
|
|
234
|
+
if (!UUID_RE.test(u) || seen.has(u)) continue;
|
|
235
|
+
seen.add(u);
|
|
236
|
+
let m = null; try { m = sessions.conversation(u); } catch { m = null; }
|
|
237
|
+
if (Array.isArray(m) && m.length) { messages.push(...m); conversations++; }
|
|
238
|
+
}
|
|
239
|
+
return { messages, conversations };
|
|
240
|
+
}
|
|
211
241
|
const MAX_LIVE = 4;
|
|
212
242
|
/** Which live chat session to end so a new one fits (PRD L3), or null. rows: [{ id, origin, lastOutputAt, busy }];
|
|
213
243
|
* busy = working or waiting on a permission prompt. A session whose goal is started is never picked. */
|
|
@@ -235,4 +265,4 @@ function press({ runtimeDir, key, what, sessions }) {
|
|
|
235
265
|
return { status: 200, body: { ok: true, session: live } };
|
|
236
266
|
}
|
|
237
267
|
|
|
238
|
-
module.exports = { ask, chat, press, chatSessionOf, chatRecordOf, pickToEnd, MAX_LIVE, openingFor, threadOf, promptFor, rowFor, settle, KEY_RE, THREADS, CHATS };
|
|
268
|
+
module.exports = { ask, chat, press, chatSessionOf, chatRecordOf, chatRecordsOf, chatClaudeOfSession, chatHistory, pickToEnd, MAX_LIVE, openingFor, threadOf, promptFor, rowFor, settle, KEY_RE, THREADS, CHATS };
|
|
@@ -136,7 +136,10 @@ module.exports = {
|
|
|
136
136
|
const key = url.searchParams.get('key') || '';
|
|
137
137
|
if (!Ag.KEY_RE.test(key)) { ctx.json(res, { ok: false, error: 'key must name a row' }, 400); return true; }
|
|
138
138
|
const sid = ctx.runtimeDir ? Ag.chatSessionOf(ctx.runtimeDir, key) : null;
|
|
139
|
-
|
|
139
|
+
const live = !!(sid && ctx.chatSessions && ctx.chatSessions.alive(sid));
|
|
140
|
+
// item-chat-history: with no live session, the conversation the key had is read from its saved Claude Code file, so ending a session never empties the panel
|
|
141
|
+
const history = !live && ctx.runtimeDir ? Ag.chatHistory({ runtimeDir: ctx.runtimeDir, key, sessions: ctx.chatSessions }) : null;
|
|
142
|
+
ctx.json(res, { ok: true, ...Ag.threadOf(ctx.runtimeDir, key), session: live ? sid : null, history, goal: ctx.runtimeDir ? Goal.goalOf(ctx.runtimeDir, key) : null });
|
|
140
143
|
return true;
|
|
141
144
|
}
|
|
142
145
|
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.375.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.375.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
|
-
/* premium-phone-room-test.js —
|
|
4
|
-
* the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* class stays off ·
|
|
8
|
-
* Set PHONE_ROOM_SHOTS=<dir> to save the Chat page at 390 wide, light and dark,
|
|
3
|
+
/* premium-phone-room-test.js — Focus on a phone (Wawan, 2026-10-21: the scroll area is too small; then "UI broken. Better to have manual CTA to
|
|
4
|
+
* Focus" after the automatic hiding misdrew the page with the keyboard up). A real server on a scratch repository (c3-scan-fixture.js); the
|
|
5
|
+
* conversation is filled in the page.
|
|
6
|
+
* P1 the Chat page at rest · P2 scrolling and typing hide nothing · P3 Focus gives the dialog the screen and moves the rail away · P4 a second
|
|
7
|
+
* press brings it all back · P5 a chat dialog on another page takes the screen, the rail class stays off · P6 a desktop has no Focus button
|
|
8
|
+
* Set PHONE_ROOM_SHOTS=<dir> to save the Chat page at 390 wide, light and dark, at rest and in focus. */
|
|
9
9
|
const { findBrowser } = require('./lib/find-browser');
|
|
10
10
|
require('./test-run').configure({ name: 'premium-phone-room' });
|
|
11
11
|
const Fx = require('./c3-scan-fixture.js');
|
|
@@ -26,13 +26,11 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
|
26
26
|
|
|
27
27
|
/* the page's own state: the head, the rail and how much of the screen the conversation gets */
|
|
28
28
|
const look = () => {
|
|
29
|
-
const g = document.querySelector('#dlg'), rail = document.querySelector('.rail').getBoundingClientRect(), body = document.querySelector('#dBody').getBoundingClientRect(), ask = document.querySelector('#askF').getBoundingClientRect();
|
|
30
|
-
return {
|
|
29
|
+
const g = document.querySelector('#dlg'), rail = document.querySelector('.rail').getBoundingClientRect(), body = document.querySelector('#dBody').getBoundingClientRect(), ask = document.querySelector('#askF').getBoundingClientRect(), f = document.querySelector('#dFocus');
|
|
30
|
+
return { focus: g.classList.contains('focus'), dfocus: document.body.classList.contains('dfocus'), btn: !!f && getComputedStyle(f).display !== 'none', pressed: f && f.getAttribute('aria-pressed'), tabs: getComputedStyle(document.querySelector('#dTabs')).display !== 'none', railTop: Math.round(rail.top), dlgTop: Math.round(g.getBoundingClientRect().top), dlgH: Math.round(g.getBoundingClientRect().height), room: Math.round(ask.top - body.top), vh: innerHeight };
|
|
31
31
|
};
|
|
32
32
|
const fill = () => { const s = document.querySelector('#dBody .stream'); let h = ''; for (let i = 0; i < 14; i++) h += `<div class="turn"><p>${'A line of the conversation about the sign-up drop reasons and the counts. '.repeat(3)}</p></div>`; s.insertAdjacentHTML('beforeend', h); };
|
|
33
|
-
/* a hand scroll: a wheel, then the move; dy > 0 is down */
|
|
34
33
|
const hand = (dy) => { const b = document.querySelector('#dBody'); b.dispatchEvent(new WheelEvent('wheel', { deltaY: dy })); b.scrollTop += dy; };
|
|
35
|
-
const bare = (y) => { document.querySelector('#dBody').scrollTop = y; };
|
|
36
34
|
|
|
37
35
|
(async () => {
|
|
38
36
|
const exe = findBrowser();
|
|
@@ -53,49 +51,38 @@ const bare = (y) => { document.querySelector('#dBody').scrollTop = y; };
|
|
|
53
51
|
|
|
54
52
|
{ const { p, ctx, errs } = await open(390);
|
|
55
53
|
const s0 = await p.evaluate(look);
|
|
56
|
-
ok('P1 the Chat page at rest shows the switch
|
|
57
|
-
await p.evaluate(
|
|
54
|
+
ok('P1 the Chat page at rest shows the switch, the rail and a Focus button', s0.tabs && !s0.focus && s0.btn && s0.pressed === 'false' && s0.railTop < s0.vh, JSON.stringify(s0));
|
|
55
|
+
await p.evaluate(hand, 300); await sleep(400); await p.evaluate(hand, -100); await p.focus('#askIn'); await sleep(500);
|
|
58
56
|
const s1 = await p.evaluate(look);
|
|
59
|
-
ok('P2
|
|
60
|
-
await sleep(900); await p.evaluate(hand, 200);
|
|
61
|
-
const s2 = await until(async () => { const v = await p.evaluate(look); return v.shrunk && v.railoff && v.railTop >= v.vh && v.dlgH >= v.vh - 2 ? v : null; }) || await p.evaluate(look);
|
|
62
|
-
ok('P3 scrolling the conversation down hides the switch, moves the rail off the screen and gives the page its place', s2.shrunk && !s2.tabs && s2.railoff && s2.railTop >= s2.vh && s2.dlgH >= s2.vh - 2, JSON.stringify(s2));
|
|
63
|
-
ok('P3b the conversation gets at least 680 px of the 844 px screen (516 px before)', s2.room >= 680, JSON.stringify(s2));
|
|
64
|
-
if (shots) await p.screenshot({ path: `${shots}/chat-scrolled-390-light.png` });
|
|
65
|
-
await sleep(600); await p.evaluate(hand, -80);
|
|
66
|
-
const s3 = await until(async () => { const v = await p.evaluate(look); return !v.shrunk && !v.railoff && v.tabs && v.railTop < v.vh ? v : null; }) || await p.evaluate(look);
|
|
67
|
-
ok('P4 scrolling up a little brings the switch and the rail back', !s3.shrunk && !s3.railoff && s3.tabs && s3.railTop < s3.vh, JSON.stringify(s3));
|
|
68
|
-
await sleep(600); await p.evaluate(hand, 200); await until(() => p.evaluate(() => document.body.classList.contains('railoff')));
|
|
69
|
-
await sleep(500); await p.click('#dTitle');
|
|
70
|
-
const s4 = await until(async () => { const v = await p.evaluate(look); return !v.shrunk && !v.railoff ? v : null; }) || await p.evaluate(look);
|
|
71
|
-
ok('P5 a press on the title brings them back', !s4.shrunk && !s4.railoff && s4.tabs, JSON.stringify(s4));
|
|
72
|
-
await p.focus('#askIn');
|
|
73
|
-
const s5 = await until(async () => { const v = await p.evaluate(look); return v.typing && v.railTop >= v.vh ? v : null; }) || await p.evaluate(look);
|
|
74
|
-
ok('P6 typing in the message box moves the rail away', s5.typing && s5.railTop >= s5.vh, JSON.stringify(s5));
|
|
57
|
+
ok('P2 scrolling and typing hide nothing by themselves', s1.tabs && !s1.focus && s1.railTop < s1.vh && s1.dlgH === s0.dlgH, JSON.stringify(s1));
|
|
75
58
|
await p.evaluate(() => document.querySelector('#askIn').blur());
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
if (shots) await p.screenshot({ path: `${shots}/chat-rest-390-light.png` });
|
|
60
|
+
await p.click('#dFocus');
|
|
61
|
+
const s2 = await until(async () => { const v = await p.evaluate(look); return v.focus && v.dfocus && v.railTop >= v.vh && v.dlgH >= v.vh - 2 ? v : null; }) || await p.evaluate(look);
|
|
62
|
+
ok('P3 Focus hides the switch, moves the rail off the screen and gives the dialog the whole screen', s2.focus && !s2.tabs && s2.dfocus && s2.pressed === 'true' && s2.railTop >= s2.vh && s2.dlgTop === 0 && s2.dlgH >= s2.vh - 2, JSON.stringify(s2));
|
|
63
|
+
ok('P3b in focus the conversation gets at least 680 px of the 844 px screen (516 px before)', s2.room >= 680, JSON.stringify(s2));
|
|
64
|
+
if (shots) await p.screenshot({ path: `${shots}/chat-focus-390-light.png` });
|
|
65
|
+
await p.click('#dFocus');
|
|
66
|
+
const s3 = await until(async () => { const v = await p.evaluate(look); return !v.focus && !v.dfocus && v.tabs && v.railTop < v.vh ? v : null; }) || await p.evaluate(look);
|
|
67
|
+
ok('P4 a second press brings the switch and the rail back', !s3.focus && !s3.dfocus && s3.tabs && s3.railTop < s3.vh && s3.pressed === 'false', JSON.stringify(s3));
|
|
68
|
+
ok('P4b no page error', errs.length === 0, errs.join(' | '));
|
|
79
69
|
await ctx.close(); }
|
|
80
70
|
|
|
81
|
-
if (shots)
|
|
82
|
-
const { p, ctx } = await open(390, scheme, 844 - 336);
|
|
83
|
-
await p.focus('#askIn'); await sleep(700); await p.screenshot({ path: `${shots}/chat-typing-390-${scheme}.png` });
|
|
84
|
-
await ctx.close();
|
|
85
|
-
}
|
|
71
|
+
if (shots) { const { p, ctx } = await open(390, 'dark'); await p.screenshot({ path: `${shots}/chat-rest-390-dark.png` }); await p.click('#dFocus'); await sleep(700); await p.screenshot({ path: `${shots}/chat-focus-390-dark.png` }); await ctx.close(); }
|
|
86
72
|
|
|
87
73
|
{ const ctx = await browser.newContext({ viewport: { width: 390, height: 844 }, hasTouch: true }); const p = await ctx.newPage();
|
|
88
74
|
await p.goto(`${F.BASE}/premium.html?ws=${encodeURIComponent(F.ws)}`); await until(() => p.evaluate(() => !!document.querySelector('.rail')));
|
|
89
75
|
await p.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.openDlg({ eye: 'Goal', title: 'Check the sign-up funnel', sub: 'Working · round 1 of 12', html: '<p>detail</p>', say: 'Hello', noteKey: 'work:x' }); m.setTab('chat'); });
|
|
90
|
-
await p.evaluate(fill); await sleep(700); await p.
|
|
91
|
-
const d = await until(async () => { const v = await p.evaluate(look); return v.
|
|
92
|
-
ok('
|
|
76
|
+
await p.evaluate(fill); await sleep(700); await p.click('#dFocus');
|
|
77
|
+
const d = await until(async () => { const v = await p.evaluate(look); return v.focus && v.dlgTop === 0 && v.dlgH >= v.vh - 2 ? v : null; }) || await p.evaluate(look);
|
|
78
|
+
ok('P5 Focus in a chat dialog on another page gives it the whole screen and leaves the page\'s rail alone', d.focus && !d.tabs && !d.dfocus && d.dlgTop === 0 && d.dlgH >= d.vh - 2, JSON.stringify(d));
|
|
79
|
+
await p.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.closeDlg(); m.openDlg({ eye: 'Goal', title: 'Another', html: '<p>x</p>', say: 'Hi', noteKey: 'work:y' }); });
|
|
80
|
+
ok('P5b the next dialog opens out of focus', !(await p.evaluate(look)).focus);
|
|
93
81
|
await ctx.close(); }
|
|
94
82
|
|
|
95
83
|
{ const { p, ctx } = await open(1280);
|
|
96
|
-
await sleep(700); await p.evaluate(hand, 200); await sleep(600);
|
|
97
84
|
const w = await p.evaluate(look);
|
|
98
|
-
ok('
|
|
85
|
+
ok('P6 a desktop shows no Focus button', !w.btn && !w.focus, JSON.stringify(w));
|
|
99
86
|
await ctx.close(); }
|
|
100
87
|
|
|
101
88
|
return finish();
|
|
@@ -116,7 +116,7 @@ export function convView({ id, onTerminal } = {}) {
|
|
|
116
116
|
kids.push(none('alert', "Claude's conversation can't be read here", d.missing + '. PMOS will not guess which transcript is this session\'s, because that could show another session\'s words.', termBtn()));
|
|
117
117
|
} else if (d.state === 'other') {
|
|
118
118
|
kids.push(none('term', 'This agent keeps no Claude transcript', 'Its output is in the terminal.', termBtn()));
|
|
119
|
-
} else if (d.state === 'ended') {
|
|
119
|
+
} else if (d.state === 'ended' && !(d.messages || []).length) {
|
|
120
120
|
kids.push(none('clock', 'This session has ended', 'Its terminal output is kept in the Sessions panel under Past.'));
|
|
121
121
|
} else {
|
|
122
122
|
for (const m of d.messages || []) {
|
|
@@ -124,7 +124,8 @@ export function convView({ id, onTerminal } = {}) {
|
|
|
124
124
|
else if (m.role === 'assistant') kids.push(el('div', { class: 'who' }, c3ic('spark', 'sm'), 'Claude'), el('div', { class: 'm bot', 'data-chat': 'bot' }, renderMd(m.text)));
|
|
125
125
|
else kids.push(toolsRow(m));
|
|
126
126
|
}
|
|
127
|
-
if (
|
|
127
|
+
if (d.state === 'ended') kids.push(el('div', { class: 'm st', 'data-chat': 'ended' }, 'This session has ended. Its conversation is kept here.')); // item-chat-history
|
|
128
|
+
else if (!(d.messages || []).length && !st.pending.length) kids.push(el('div', { class: 'm st', 'data-chat': 'empty' }, 'No messages yet. Type below to talk to Claude.'));
|
|
128
129
|
}
|
|
129
130
|
for (const p of st.pending) kids.push(el('div', { class: 'who me' }, 'You'), el('div', { class: 'm me', 'data-chat': 'me', 'data-pending': '' }, p.text));
|
|
130
131
|
if (conv && d.ask) kids.push(askCard(d.ask));
|
|
@@ -290,7 +290,7 @@ export function openDlg(o) {
|
|
|
290
290
|
$('#dBody').innerHTML = `<div class="stream" role="log">${o.stream || turnA(ptx(o.say))}</div><form class="askbar" id="askF"><div class="slashm" id="slashM" role="listbox" aria-label="Commands" hidden></div>${padMarkup()}<textarea id="askIn" rows="1" placeholder="Message Claude, or type /" maxlength="8000" autocomplete="off" enterkeyhint="send" aria-label="A message for Claude" aria-controls="slashM"></textarea><button type="submit" data-act="ask" id="askGo" aria-label="Send to Claude" title="Send to Claude"><svg class="i" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6"/></svg></button></form><div class="askfoot"><p class="fine2" id="askNote">${CHAT_NOTE}</p>${padChipMarkup()}</div>`;
|
|
291
291
|
mountPad({ key: S.key, ws: new URLSearchParams(location.search).get('ws'), input: $('#askIn') });
|
|
292
292
|
quietNote();
|
|
293
|
-
$('#dlg').classList.toggle('cmp', o.compact !== false); $('#dlg').classList.remove('shrunk', 'tfull');
|
|
293
|
+
$('#dlg').classList.toggle('cmp', o.compact !== false); $('#dlg').classList.remove('shrunk', 'tfull'); setFocus(false); // compact (every dialog unless it says compact: false): a short head on a phone that shrinks as the detail scrolls
|
|
294
294
|
$('#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
|
|
295
295
|
$('#veil').classList.add('on'); $('#dlg').classList.add('on');
|
|
296
296
|
$$('#dGrid .pane').forEach((p) => { p.scrollTop = 0; });
|
|
@@ -298,7 +298,7 @@ export function openDlg(o) {
|
|
|
298
298
|
setTimeout(() => $('#dlg').focus(), 60);
|
|
299
299
|
}
|
|
300
300
|
/* The compact head clamps a long title; a press on it shows the whole title and sub line, a second press clamps them again. */
|
|
301
|
-
$('#dTitle').addEventListener('click', () => { const g = $('#dlg'); if (
|
|
301
|
+
$('#dTitle').addEventListener('click', () => { const g = $('#dlg'); if (g.classList.contains('cmp') && innerWidth < 1000) g.classList.toggle('tfull'); });
|
|
302
302
|
/* A compact dialog on a phone: once the detail scrolls, the head keeps only the title and the tools, so the detail gets the screen.
|
|
303
303
|
* It shrinks only when the detail is much taller than its pane, so the smaller head cannot end the scroll and grow back. */
|
|
304
304
|
$('#dOut').addEventListener('scroll', () => {
|
|
@@ -306,25 +306,16 @@ $('#dOut').addEventListener('scroll', () => {
|
|
|
306
306
|
if (p.scrollTop > 48 && p.scrollHeight - p.clientHeight > 200) g.classList.add('shrunk');
|
|
307
307
|
else if (p.scrollTop < 8) g.classList.remove('shrunk');
|
|
308
308
|
}, { passive: true });
|
|
309
|
-
/*
|
|
310
|
-
* Detail / Conversation switch, and on the Chat page the rail
|
|
311
|
-
*
|
|
312
|
-
|
|
313
|
-
function
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
$('#
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (Date.now() < ROOM.until || Date.now() - ROOM.hand > 800) { ROOM.y = y; return; } // the head just changed size, or no hand moved it
|
|
320
|
-
if (dy > 24 && b.scrollHeight - b.clientHeight > 200) { roomOn(); ROOM.y = y; }
|
|
321
|
-
else if (dy < -24 || y < 8) { roomOff(); ROOM.y = y; }
|
|
322
|
-
}, { passive: true });
|
|
323
|
-
/* Typing on the Chat page on a phone: the rail steps aside so the keyboard, the message box and the conversation share the screen. */
|
|
324
|
-
$('#dBody').addEventListener('focusin', (e) => { if (chatPage() && innerWidth < 1000 && e.target.id === 'askIn') document.body.classList.add('typing'); });
|
|
325
|
-
$('#dBody').addEventListener('focusout', (e) => { if (e.target.id === 'askIn') document.body.classList.remove('typing'); });
|
|
326
|
-
/* The on-screen keyboard: the Chat page is as tall as what is left of the screen above it (visualViewport), not the whole screen. */
|
|
327
|
-
if (window.visualViewport) { const vv = window.visualViewport, fit = () => { if (chatPage()) document.documentElement.style.setProperty('--vvh', Math.round(vv.height) + 'px'); }; vv.addEventListener('resize', fit); fit(); }
|
|
309
|
+
/* Focus on a phone (premium-phone-room): one press gives the dialog the whole screen. The head keeps only the title and the Focus button,
|
|
310
|
+
* the Detail / Conversation switch and the sub line hide, and on the Chat page the rail moves away. A second press brings them back.
|
|
311
|
+
* Nothing hides by itself: scrolling and typing leave the screen as it is (PM 2026-10-21). */
|
|
312
|
+
$('#dlg .dtools').insertAdjacentHTML('beforeend', '<button type="button" class="round dx2" id="dFocus" aria-label="Focus" aria-pressed="false" title="Focus"><svg class="i" viewBox="0 0 24 24"><path id="dFocP" d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg></button>');
|
|
313
|
+
export function setFocus(f) {
|
|
314
|
+
$('#dlg').classList.toggle('focus', f); document.body.classList.toggle('dfocus', f && chatPage());
|
|
315
|
+
const b = $('#dFocus'); b.setAttribute('aria-pressed', String(f)); b.setAttribute('aria-label', f ? 'Leave focus' : 'Focus'); b.title = f ? 'Leave focus' : 'Focus';
|
|
316
|
+
$('#dFocP').setAttribute('d', f ? 'M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5' : 'M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5');
|
|
317
|
+
}
|
|
318
|
+
$('#dFocus').onclick = () => setFocus(!$('#dlg').classList.contains('focus'));
|
|
328
319
|
export function closeDlg() {
|
|
329
320
|
if (chatPage()) return;
|
|
330
321
|
clearTimeout(threadTimer); S.key = null; flushPad(); railOnClose();
|
|
@@ -335,7 +326,7 @@ export function closeDlg() {
|
|
|
335
326
|
if (lastFocus) { try { lastFocus.focus(); } catch { /* gone */ } }
|
|
336
327
|
}
|
|
337
328
|
export function pillOf(s) { const o = $('button[aria-pressed="true"]', s), p = $('.pill', s); requestAnimationFrame(() => { if (!o || !p) return; p.style.left = o.offsetLeft + 'px'; p.style.width = o.offsetWidth + 'px'; }); }
|
|
338
|
-
export function setTab(t) {
|
|
329
|
+
export function setTab(t) { $('#dGrid').dataset.tab = t; $$('#dTabs button').forEach((b) => b.setAttribute('aria-pressed', b.dataset.t === t)); pillOf($('#dTabs .seg')); }
|
|
339
330
|
export function setMode(m) {
|
|
340
331
|
$('#dlg').dataset.mode = m;
|
|
341
332
|
const b = $('#dPane'), on = m === 'split';
|
|
@@ -397,8 +388,8 @@ export { toolLine }; // "Used Read ×2, slack_read_thread": chat-md.js shorten
|
|
|
397
388
|
/** goal: the key's /goal record (GET /thread), so the newest grilling message can be pressed (slice 2, PRD G4, G5). */
|
|
398
389
|
export function sessionHtml(c, goal = null) {
|
|
399
390
|
if (!c) return '';
|
|
400
|
-
if (c.state === 'ended') return turnAgent('<p class="tt" role="status">This session has ended. Your next message starts a new one.</p>');
|
|
401
|
-
if (c.state !== 'conv') return turnAgent(`<p class="tt" role="status">${esc(c.missing || 'Claude is starting.')}</p>`);
|
|
391
|
+
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>');
|
|
392
|
+
if (c.state !== 'conv' && c.state !== 'ended') return turnAgent(`<p class="tt" role="status">${esc(c.missing || 'Claude is starting.')}</p>`);
|
|
402
393
|
const msgs = c.messages || [], last = msgs.length - 1;
|
|
403
394
|
const waiting = !c.ask && c.turn !== 'agent' && c.turn !== 'tool';
|
|
404
395
|
const out = msgs.map((m, i) => {
|
|
@@ -409,7 +400,9 @@ export function sessionHtml(c, goal = null) {
|
|
|
409
400
|
return turnAgent(`<p class="agtag">Claude</p>${g.text ? mdHtml(g.text) : ''}${goalBlockHtml(g.block, { live, state: goal && goal.state })}`);
|
|
410
401
|
});
|
|
411
402
|
const gp = goalProgressHtml(goal); if (gp) out.push(gp);
|
|
412
|
-
|
|
403
|
+
// item-chat-history: an ended session keeps its conversation on the item; the next message picks it up
|
|
404
|
+
if (c.state === 'ended') out.push(turnAgent('<p class="tt" role="status">This session has ended. Your conversation is kept here, and your next message picks it up.</p>'));
|
|
405
|
+
else if (c.ask) out.push(turnAgent(`<p class="agtag">Claude asks before it goes on</p><p class="tt">${esc(c.ask.question)}</p><div class="chatopts">${(c.ask.options || []).map((o) => `<button type="button" class="cta alt" data-chat-press="${esc(o.n)}">${esc(o.label)}</button>`).join('')}</div>`));
|
|
413
406
|
else if (c.turn === 'agent' || c.turn === 'tool') out.push(turnAgent(`<p class="tt" role="status">${c.turn === 'tool' && c.openCall ? 'Running ' + esc(c.openCall) + '.' : 'Claude is working.'} <button type="button" class="cta alt" data-chat-press="esc">Stop</button></p>`));
|
|
414
407
|
return out.join('');
|
|
415
408
|
}
|
|
@@ -443,6 +436,7 @@ export async function loadThread(key) {
|
|
|
443
436
|
if (!th || !th.ok) return;
|
|
444
437
|
let conv = null;
|
|
445
438
|
if (th.session) conv = await pmGet('/api/sessions/conversation?id=' + encodeURIComponent(th.session)).catch(() => null);
|
|
439
|
+
else if (th.history && (th.history.messages || []).length) conv = { ok: true, state: 'ended', messages: th.history.messages }; // item-chat-history
|
|
446
440
|
drawThread(th, key, conv && conv.ok ? conv : null);
|
|
447
441
|
if ((th.working || th.session) && S.key === key && $('#dlg').classList.contains('on')) threadTimer = setTimeout(() => loadThread(key), 2000);
|
|
448
442
|
}
|
|
@@ -2611,13 +2611,17 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
2611
2611
|
.chatpg .rail{z-index:42}
|
|
2612
2612
|
.chatpg .rail .ind{display:none}
|
|
2613
2613
|
|
|
2614
|
-
/* ── premium-phone-room:
|
|
2615
|
-
|
|
2614
|
+
/* ── premium-phone-room: Focus, a press in the dialog head on a phone. The dialog takes the whole screen; the head keeps the title and the Focus
|
|
2615
|
+
button; on the Chat page the rail moves away. A second press brings it all back. Nothing hides by itself. On a desktop the button is not shown. ── */
|
|
2616
|
+
#dFocus{display:none}
|
|
2616
2617
|
@media (max-width:999px){
|
|
2618
|
+
#dFocus{display:grid}
|
|
2619
|
+
.dlg.focus #dEye,.dlg.focus .dsub,.dlg.focus .dtabs,.dlg.focus .stease,.dlg.focus #dPane,.dlg.focus #dExpand{display:none!important}
|
|
2620
|
+
.dlg.focus .dgrid{margin-top:4px}
|
|
2621
|
+
.dlg.focus #dTitle{-webkit-line-clamp:1;line-clamp:1}
|
|
2622
|
+
.dlg.on.focus{left:0;top:0;bottom:0;transform:none;width:100%;height:100%;max-height:none!important;border-radius:0}
|
|
2617
2623
|
.chatpg .rail{transition:transform .45s var(--spring),opacity .3s}
|
|
2618
|
-
.chatpg.
|
|
2619
|
-
.chatpg .dlg.on{height:calc(
|
|
2620
|
-
.chatpg.railoff .dlg.on{height:var(--vvh,100%);padding-bottom:calc(14px + env(safe-area-inset-bottom,0px))}
|
|
2621
|
-
.chatpg.typing .dlg.on{height:var(--vvh,100%)}
|
|
2624
|
+
.chatpg.dfocus .rail{transform:translate(-50%,calc(100% + 40px));opacity:0;pointer-events:none}
|
|
2625
|
+
.chatpg.dfocus .dlg.on{height:100%;border-radius:0;padding-bottom:calc(14px + env(safe-area-inset-bottom,0px))}
|
|
2622
2626
|
}
|
|
2623
2627
|
@media (max-width:999px) and (prefers-reduced-motion:reduce){.chatpg .rail{transition:none}}
|
package/workspace/server.js
CHANGED
|
@@ -2890,7 +2890,7 @@ function recordConversation(s) {
|
|
|
2890
2890
|
return r;
|
|
2891
2891
|
}
|
|
2892
2892
|
function persist(s) {
|
|
2893
|
-
if (s.state === 'exited' && !s._txSaved) { s._txSaved = true; try { recordConversation(s); } catch {} }
|
|
2893
|
+
if (s.state === 'exited' && !s._txSaved) { s._txSaved = true; try { recordConversation(s); } catch {} keepChatHistory(s); }
|
|
2894
2894
|
// When it ended: the clock the sweep's keepExitedDays reads. A live session has none (a respawn clears it).
|
|
2895
2895
|
if (s.state === 'exited') { if (!s.exitedAt) s.exitedAt = nowISO(); } else if (s.exitedAt) delete s.exitedAt;
|
|
2896
2896
|
else if (s.state !== 'exited') s._txSaved = false;
|
|
@@ -3865,12 +3865,40 @@ const chatSessions = {
|
|
|
3865
3865
|
list: (now = Date.now()) => [...sessions.values()].filter((s) => /^chat:/.test(String(s.origin || '')) && s.pty && s.state !== 'exited')
|
|
3866
3866
|
.map((s) => ({ id: s.id, origin: s.origin, lastOutputAt: s.lastOutputAt, busy: harness.deriveState(s.state, s.lastOutputAt, now).state === 'working' || sessionShown(s, now) === 'blocked' })),
|
|
3867
3867
|
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; },
|
|
3868
|
-
// slice 4 (PRD L2): whether Claude Code still has the conversation file for this id (any project folder)
|
|
3869
|
-
hasConversation: (uuid) => {
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
},
|
|
3868
|
+
// slice 4 (PRD L2): whether Claude Code still has the conversation file for this id (any project folder of any Claude home)
|
|
3869
|
+
hasConversation: (uuid) => !!chatConversationFile(uuid, { live: true }),
|
|
3870
|
+
// item-chat-history: the conversation of one Claude id, as the panel draws it, or null when no file is left
|
|
3871
|
+
conversation: (uuid) => { const f = chatConversationFile(uuid); return f ? transcript.readConversation(f, scrub, transcript.CONV_LIMIT).messages : null; },
|
|
3873
3872
|
};
|
|
3873
|
+
/* item-chat-history (bug 2026-10-21). A chat's conversation is Claude Code's own file, <home>/projects/<slug>/<uuid>.jsonl. The home is the
|
|
3874
|
+
* session's profile (CLAUDE_CONFIG_DIR, such as ~/.claude-personal), not always ~/.claude, so every Claude home is searched (the same list
|
|
3875
|
+
* the harness reads, lib/transcript-read.js claudeHomes): reading only ~/.claude made every profile chat look gone, so its next message
|
|
3876
|
+
* started a fresh conversation. When a chat session ends, a copy is kept in the runtime state (chat-history/), so the item keeps its
|
|
3877
|
+
* conversation even after Claude Code prunes old files. { live: true } asks for Claude Code's own file only, the one --resume can open. */
|
|
3878
|
+
const CHAT_KEEP_DIR = path.join(STATE, 'chat-history');
|
|
3879
|
+
function chatConversationFile(uuid, { live = false } = {}) {
|
|
3880
|
+
const u = String(uuid || '');
|
|
3881
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(u)) return null;
|
|
3882
|
+
for (const home of transcript.claudeHomes()) {
|
|
3883
|
+
const dir = path.join(home, 'projects');
|
|
3884
|
+
let subs = []; try { subs = fs.readdirSync(dir); } catch { continue; }
|
|
3885
|
+
for (const p of subs) { const f = path.join(dir, p, u + '.jsonl'); if (fs.existsSync(f)) return f; }
|
|
3886
|
+
}
|
|
3887
|
+
if (live) return null;
|
|
3888
|
+
const kept = path.join(CHAT_KEEP_DIR, u + '.jsonl');
|
|
3889
|
+
return fs.existsSync(kept) ? kept : null;
|
|
3890
|
+
}
|
|
3891
|
+
/** Keep a copy of an ending chat session's conversation in the runtime state. Best-effort; the original file is never touched. */
|
|
3892
|
+
function keepChatHistory(s) {
|
|
3893
|
+
if (!s || !/^chat:/.test(String(s.origin || ''))) return;
|
|
3894
|
+
try {
|
|
3895
|
+
const uuid = require('./lib/briefing-premium-agent.js').chatClaudeOfSession(STATE, String(s.origin).slice(5), s.id);
|
|
3896
|
+
const f = uuid && chatConversationFile(uuid, { live: true });
|
|
3897
|
+
if (!f) return;
|
|
3898
|
+
fs.mkdirSync(CHAT_KEEP_DIR, { recursive: true });
|
|
3899
|
+
fs.copyFileSync(f, path.join(CHAT_KEEP_DIR, uuid + '.jsonl'));
|
|
3900
|
+
} catch (e) { warnWriteFail('chat history copy', e); }
|
|
3901
|
+
}
|
|
3874
3902
|
|
|
3875
3903
|
/* A headless run (workspace-headless-jobs). The row is an ordinary session record, so every caller that checks a
|
|
3876
3904
|
* session's state keeps working; it has no pty and no tmux, and `child` is the process. The log is read-only. */
|
|
@@ -5204,6 +5232,7 @@ function removeSession(id) {
|
|
|
5204
5232
|
if (!s || s.pty || s.child) return false;
|
|
5205
5233
|
if (s.tmux) tmuxKillSession(s.tmux); // best-effort: never orphan a detached tmux session
|
|
5206
5234
|
try { recordConversation(s); } catch {} // the conversation outlives the session (surface-batch R5)
|
|
5235
|
+
keepChatHistory(s); // item-chat-history: a chat's conversation stays with its item after End
|
|
5207
5236
|
forgetScratchpad(s); // the tab's staging text goes with the tab
|
|
5208
5237
|
// Drop a claim this session held. Correctness does not depend on this — treeShare.writerOf only
|
|
5209
5238
|
// believes a claim whose holder is still live, so a stale entry already reads as vacant — but a
|
|
@@ -6589,7 +6618,10 @@ async function handleRequest(req, res) {
|
|
|
6589
6618
|
if (!sess) {
|
|
6590
6619
|
// an ended session the server no longer holds (only its record on disk is left) is still listed in Past; removing it deletes that record
|
|
6591
6620
|
const id = String(body.id || '');
|
|
6592
|
-
if (/^sess-\d+$/.test(id) && fs.existsSync(path.join(SESS_DIR, id + '.json'))) {
|
|
6621
|
+
if (/^sess-\d+$/.test(id) && fs.existsSync(path.join(SESS_DIR, id + '.json'))) {
|
|
6622
|
+
try { keepChatHistory(JSON.parse(fs.readFileSync(path.join(SESS_DIR, id + '.json'), 'utf8'))); } catch { /* an unreadable record names no chat */ }
|
|
6623
|
+
unpersist(id); pushSessions(); return json(res, { ok: true, removed: true });
|
|
6624
|
+
}
|
|
6593
6625
|
return json(res, { ok: false, error: 'no such session' }, 404);
|
|
6594
6626
|
}
|
|
6595
6627
|
if (sess.child) {
|
|
@@ -7152,7 +7184,12 @@ async function handleRequest(req, res) {
|
|
|
7152
7184
|
if (p === '/api/sessions/conversation' && req.method === 'GET') {
|
|
7153
7185
|
const sess = sessions.get(String(url.searchParams.get('id') || ''));
|
|
7154
7186
|
if (!sess) return json(res, { ok: false, error: 'no such session' }, 404);
|
|
7155
|
-
if (sess.state === 'exited')
|
|
7187
|
+
if (sess.state === 'exited') {
|
|
7188
|
+
// item-chat-history: an ended chat still shows its conversation, from the saved Claude Code file
|
|
7189
|
+
let messages = [];
|
|
7190
|
+
if (/^chat:/.test(String(sess.origin || ''))) { try { const u = require('./lib/briefing-premium-agent.js').chatClaudeOfSession(STATE, String(sess.origin).slice(5), sess.id); messages = (u && chatSessions.conversation(u)) || []; } catch { messages = []; } }
|
|
7191
|
+
return json(res, { ok: true, id: sess.id, agent: sess.agent, messages, state: 'ended', missing: 'The session has ended.', turn: null, stamp: null });
|
|
7192
|
+
}
|
|
7156
7193
|
const c = sessionConversation(sess);
|
|
7157
7194
|
return json(res, { ok: true, id: sess.id, agent: sess.agent, messages: c.messages, state: c.state || null, missing: c.missing || null, turn: c.turn || null,
|
|
7158
7195
|
openCall: c.openCall || null, model: c.model || null, ask: c.ask || null, stamp: c.stamp || null });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "An item's chat keeps its conversation after its session ends (End, the idle sweep, room for a newer chat): the thread and the session view read the saved Claude Code file from any Claude home, a copy is kept in the runtime state, the files the session wrote are untouched, and the next message resumes it. Real server, stub claude.",
|
|
3
|
+
"panels": [
|
|
4
|
+
"item-chat-history-test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"item-chat-history-test.js": 40
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_comment": "
|
|
2
|
+
"_comment": "Focus on a phone: a press in the dialog head gives the dialog the whole screen, hides the switch and on the Chat page the rail; a second press brings them back; nothing hides by itself. Real server, 390 and 1280 wide.",
|
|
3
3
|
"seconds": {
|
|
4
4
|
"premium-phone-room-test.js": 40
|
|
5
5
|
},
|