create-pmos 0.377.0 → 0.378.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 +13 -13
- 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 +12 -0
- package/workspace/guide/briefing-premium.md +1 -0
- package/workspace/lib/jira-status.js +20 -1
- package/workspace/lib/transcript-read.js +2 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-context-test.js +121 -0
- package/workspace/public/pm/chat-context.js +102 -0
- package/workspace/public/pm/premium-shell.js +37 -1
- package/workspace/public/pm/premium-vw-ctx.js +70 -0
- package/workspace/public/pm/premium.css +15 -0
- package/workspace/server.js +5 -0
- package/workspace/test-lists/premium-chat-context.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.378.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,18 @@
|
|
|
32
32
|
"audit"
|
|
33
33
|
],
|
|
34
34
|
"pmosChanges": [
|
|
35
|
+
{
|
|
36
|
+
"v": "0.378.0",
|
|
37
|
+
"at": "2026-10-21T07:48:19.057Z",
|
|
38
|
+
"f": 2,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 987,
|
|
42
|
+
"t": "Chips for what an answer worked with, main one opens by itself",
|
|
43
|
+
"s": "Chips for what an answer worked with, main one opens by itself"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
35
47
|
{
|
|
36
48
|
"v": "0.377.0",
|
|
37
49
|
"at": "2026-10-21T07:27:29.956Z",
|
|
@@ -309,18 +321,6 @@
|
|
|
309
321
|
"s": "When a field loses focus or the keyboard closes, the bar goes back to the bottom of the screen and the dock back to the top."
|
|
310
322
|
}
|
|
311
323
|
]
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
"v": "0.358.0",
|
|
315
|
-
"at": "2026-10-20T11:00:48.565Z",
|
|
316
|
-
"f": 2,
|
|
317
|
-
"prs": [
|
|
318
|
-
{
|
|
319
|
-
"n": 939,
|
|
320
|
-
"t": "Chat sessions end when idle, resume, and cap at 4 live",
|
|
321
|
-
"s": "A chat session that prints nothing for the workspace idle limit (60 minutes by default) is ended, unless its goal is started or a permission prompt is waiting."
|
|
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-21T07:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-21T07:48:16Z"}
|
|
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-21T07:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-21T07:48:16Z"}
|
|
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-21T07:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-21T07:48:16Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.378.0",
|
|
4
|
+
"at": "2026-10-21T07:48:19.057Z",
|
|
5
|
+
"f": 2,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 987,
|
|
9
|
+
"t": "Chips for what an answer worked with, main one opens by itself",
|
|
10
|
+
"s": "Chips for what an answer worked with, main one opens by itself"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"v": "0.377.0",
|
|
4
16
|
"at": "2026-10-21T07:27:29.956Z",
|
|
@@ -419,6 +419,7 @@ The conversation beside every premium dialog is a real Claude Code session. Anyt
|
|
|
419
419
|
- **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.
|
|
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 (on the Chat page, the viewer opens over the conversation). Markdown shows as a page, an HTML file shows as the page it draws (press **Source** for its code), and other text files show as code. An HTML page runs its own scripts, so its toggles and charts work, but it cannot reach PMOS or the internet: a web font falls back to the system font. It is read-only. While the tab is open it shows the newest version, so a file Claude is still writing stays current. A file outside the workspaces PMOS serves says "Not in a workspace" and is not read.
|
|
422
|
+
- **What an answer worked with** shows as buttons under it: the files Claude wrote, changed or read, the Jira tickets and Slack channels it used, and the links it named. The first one is the main one: a file Claude wrote comes first, then what it named in its words, then what it only read. When an answer finishes while the chat is open, its main one opens in the viewer by itself, once; answers that were there when you opened the chat open nothing. On a phone a bar over the message box offers it instead (**View**), so the conversation stays in view. A Jira ticket shows what PMOS last read from Jira for a board or initiative it syncs, with **Open in Jira**; a ticket PMOS has not read says so. A Slack channel or message opens with **Open in Slack**, as PMOS keeps no copy of Slack messages.
|
|
422
423
|
- **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
424
|
- **The session** is also listed in **Sessions** and in the console, where you can open its terminal.
|
|
424
425
|
- **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.
|
|
@@ -244,6 +244,25 @@ function readSnapshot(root, initiative) {
|
|
|
244
244
|
return { fetchedAt: isStr(data.fetched_at) ? data.fetched_at : null, query: isStr(data.query) ? data.query : null, tickets };
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
/**
|
|
248
|
+
* One ticket by its key from every stored Jira reading (the initiatives' and the boards' snapshots), newest reading first, or null.
|
|
249
|
+
* The Chat page's viewer shows a ticket Claude worked with from this; it never reads Jira itself (premium-chat-viewer slice 2).
|
|
250
|
+
*/
|
|
251
|
+
function findTicket(root, key) {
|
|
252
|
+
const k = String(key || '').toUpperCase();
|
|
253
|
+
if (!KEY_RE.test(k)) return null;
|
|
254
|
+
let names;
|
|
255
|
+
try { names = fs.readdirSync(jiraTickets.jiraDir(root)); } catch { return null; }
|
|
256
|
+
let best = null;
|
|
257
|
+
for (const n of names) {
|
|
258
|
+
if (!n.endsWith('.md') || n.endsWith('-tickets.md')) continue;
|
|
259
|
+
const snap = readSnapshot(root, n.slice(0, -3));
|
|
260
|
+
const r = snap && snap.tickets.get(k);
|
|
261
|
+
if (r && (!best || String(snap.fetchedAt || '') > String(best.fetchedAt || ''))) best = { ...r, fetchedAt: snap.fetchedAt, from: n.slice(0, -3) };
|
|
262
|
+
}
|
|
263
|
+
return best;
|
|
264
|
+
}
|
|
265
|
+
|
|
247
266
|
/**
|
|
248
267
|
* Write the snapshot from a saved search result. Only the tickets this initiative pushed are kept; any other issue in
|
|
249
268
|
* the result is counted and ignored. A pushed ticket missing from the result keeps its last reading, marked stale.
|
|
@@ -509,5 +528,5 @@ function which(root, key) {
|
|
|
509
528
|
return { ok: true, key: k, initiatives: hits };
|
|
510
529
|
}
|
|
511
530
|
|
|
512
|
-
module.exports = { queryFor, linkedInitiatives, normalize, sync, readSnapshot, which, sprintLabel, snapshotPath, snapshotRel, sprintQuery, syncSprints, readSprints, SPRINTS_FILE,
|
|
531
|
+
module.exports = { queryFor, linkedInitiatives, normalize, sync, readSnapshot, findTicket, which, sprintLabel, snapshotPath, snapshotRel, sprintQuery, syncSprints, readSprints, SPRINTS_FILE,
|
|
513
532
|
sprintsToSummarise, saveSprintNotes, readSprintNotes, sameSprint, noteOne, NOTES_FILE };
|
|
@@ -429,6 +429,8 @@ function callTarget(input, root) {
|
|
|
429
429
|
else if (str(input.command)) t = str(input.command).split('\n')[0];
|
|
430
430
|
else if (str(input.pattern)) t = str(input.pattern) + (str(input.path) ? ' in ' + rel(str(input.path)) : '');
|
|
431
431
|
else if (str(input.url)) t = str(input.url);
|
|
432
|
+
else if (str(input.issueIdOrKey) || str(input.issueKey) || str(input.issue_key)) t = str(input.issueIdOrKey) || str(input.issueKey) || str(input.issue_key); // a Jira call: the ticket (premium-chat-viewer slice 2)
|
|
433
|
+
else if (str(input.channel_id) || str(input.channel)) t = (str(input.channel_id) || str(input.channel)) + (str(input.message_ts) || str(input.thread_ts) ? ' ' + (str(input.message_ts) || str(input.thread_ts)) : ''); // a Slack call: the channel and the message
|
|
432
434
|
else if (str(input.query)) t = str(input.query);
|
|
433
435
|
else if (str(input.description)) t = str(input.description);
|
|
434
436
|
else if (str(input.path)) t = rel(str(input.path));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.378.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.378.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-chat-context-test.js — what one of Claude's answers worked with shows as chips under it, and the main one opens by itself
|
|
4
|
+
* (initiative premium-chat-viewer, slice 2). A real server on a scratch repository (c3-scan-fixture.js); the chat's thread and conversation
|
|
5
|
+
* and the file reads are routed, and the test changes the conversation the way a running session does.
|
|
6
|
+
* C1 an answer that was there when the chat opened has its chips, the main one first, and opens nothing
|
|
7
|
+
* C2 a new answer opens its main item in the viewer once, when Claude has finished, and not while it still works
|
|
8
|
+
* C3 a Jira chip opens the ticket from the stored Jira reading, with Open in Jira; a key with no reading says so
|
|
9
|
+
* C4 a Slack chip opens a tab with Open in Slack
|
|
10
|
+
* C5 at 390 a new answer shows a bar over the message box instead of covering the conversation; its press opens the viewer layer
|
|
11
|
+
* C6 every chip is at least 44 px; no sideways scroll; no page error
|
|
12
|
+
* Set CHAT_CONTEXT_SHOTS=<dir> to save the page at 1280 and 390, light and dark. */
|
|
13
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
14
|
+
require('./test-run').configure({ name: 'premium-chat-context' });
|
|
15
|
+
const Fx = require('./c3-scan-fixture.js');
|
|
16
|
+
|
|
17
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
18
|
+
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); } };
|
|
19
|
+
const results = [];
|
|
20
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
|
|
21
|
+
let F = null, browser = null;
|
|
22
|
+
const finish = async (code) => {
|
|
23
|
+
if (browser) await browser.close().catch(() => {});
|
|
24
|
+
if (F) F.stop();
|
|
25
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
26
|
+
console.log(`\n${results.length - bad}/${results.length} premium-chat-context assertions passed`);
|
|
27
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
28
|
+
};
|
|
29
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
30
|
+
|
|
31
|
+
const MD = '# Sign-up drop\n\nThe **sign-up** rate fell from 41% to 38%.\n';
|
|
32
|
+
const first = () => [
|
|
33
|
+
{ role: 'user', text: 'Why did sign-ups drop?', at: '2026-10-21T08:00:00Z' },
|
|
34
|
+
{ role: 'tool', tools: { Read: 1, Write: 1 }, calls: [{ tool: 'Read', target: 'planning/prd/signup-fix.md' }, { tool: 'Write', target: 'planning/research/signup-drop.md' }], at: '2026-10-21T08:00:10Z' },
|
|
35
|
+
{ role: 'assistant', text: 'I wrote it up in planning/research/signup-drop.md. The rate fell from 41% to 38% (UTF-8 export).', at: '2026-10-21T08:00:20Z' },
|
|
36
|
+
];
|
|
37
|
+
const second = (k) => [
|
|
38
|
+
{ role: 'user', text: 'Check the ticket and tell the channel', at: '2026-10-21T08:01:00Z' },
|
|
39
|
+
{ role: 'tool', tools: { getJiraIssue: 2, slack_send_message: 1, Edit: 1 }, calls: [{ tool: 'mcp__Atlassian__getJiraIssue', target: 'SGN-42' }, { tool: 'mcp__Atlassian__getJiraIssue', target: 'SGN-7' }, { tool: 'mcp__Slack__slack_send_message', target: 'C0123ABCD' }, { tool: 'Edit', target: 'planning/research/signup-plan' + k + '.md' }], at: '2026-10-21T08:01:10Z' },
|
|
40
|
+
{ role: 'assistant', text: 'SGN-42 is in review. I told the team in Slack and updated the plan.', at: '2026-10-21T08:01:2' + k + 'Z' },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
(async () => {
|
|
44
|
+
const exe = findBrowser();
|
|
45
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
46
|
+
let chromium;
|
|
47
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
48
|
+
F = await Fx.start({ name: 'premium-chat-context' });
|
|
49
|
+
browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
|
|
50
|
+
const shots = process.env.CHAT_CONTEXT_SHOTS;
|
|
51
|
+
const chat = `${F.BASE}/premium-chat.html?ws=${encodeURIComponent(F.ws)}`;
|
|
52
|
+
const open = async (width, scheme = 'light') => {
|
|
53
|
+
const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 800 }, colorScheme: scheme, hasTouch: width < 1000 });
|
|
54
|
+
const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
|
|
55
|
+
const conv = { ok: true, state: 'conv', turn: 'user', messages: first() };
|
|
56
|
+
await p.route('**/api/briefing-premium/thread**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-ctx' } }));
|
|
57
|
+
await p.route('**/api/sessions/conversation**', (r) => r.fulfill({ json: conv }));
|
|
58
|
+
await p.route('**/api/jira/ticket**', (r) => r.fulfill({ json: { ok: true, ticket: /SGN-42/.test(r.request().url()) ? { key: 'SGN-42', summary: 'Fix the sign-up form', status: 'In Review', category: 'indeterminate', sprint: { name: 'Sprint 14', state: 'active' }, url: 'https://acme.atlassian.net/browse/SGN-42', fetchedAt: '2026-10-21T07:00:00Z' } : null } }));
|
|
59
|
+
await p.route('**/api/doc/locate**', (r) => { const u = decodeURIComponent(r.request().url()); const rel = (u.match(/path=([^&]+)/) || [])[1] || 'x.md'; r.fulfill({ json: { ok: true, ws: F.ws, rel, name: rel.split('/').pop(), abs: '/x/' + rel, mtime: 1, size: MD.length } }); });
|
|
60
|
+
await p.route('**/api/doc?**', (r) => r.fulfill({ contentType: 'text/plain', headers: { 'X-Doc-Kind': 'markdown' }, body: MD }));
|
|
61
|
+
await p.goto(chat);
|
|
62
|
+
await until(() => p.evaluate(() => document.querySelectorAll('#dBody .ctxchip').length > 0), 10000);
|
|
63
|
+
return { p, ctx, errs, conv };
|
|
64
|
+
};
|
|
65
|
+
const look = () => {
|
|
66
|
+
const g = document.querySelector('#dlg'), peek = document.querySelector('#ctxPeek');
|
|
67
|
+
return { shut: g.classList.contains('vw-shut'), layer: g.classList.contains('vw-layer'), out: Math.round(document.querySelector('#dOut').getBoundingClientRect().width),
|
|
68
|
+
tabs: [...document.querySelectorAll('#vTabs .vtab')].filter((t) => !t.hidden).map((t) => t.textContent.trim()),
|
|
69
|
+
chips: [...document.querySelectorAll('#dBody .ctxc')].map((c) => [...c.querySelectorAll('.ctxchip')].map((b) => b.dataset.ctx + ':' + b.querySelector('b').textContent + (b.classList.contains('lead') ? '*' : ''))),
|
|
70
|
+
peek: peek && !peek.hidden ? peek.textContent.trim() : null, minH: Math.min(...[...document.querySelectorAll('#dBody .ctxchip')].map((b) => b.getBoundingClientRect().height)), wide: document.documentElement.scrollWidth > innerWidth + 1 };
|
|
71
|
+
};
|
|
72
|
+
const answer = async (p, conv, k, working) => { conv.messages = [...first(), ...second(k)]; conv.turn = working ? 'agent' : 'user'; };
|
|
73
|
+
|
|
74
|
+
{ const { p, ctx, errs, conv } = await open(1280);
|
|
75
|
+
await sleep(2500); // a read after the first: an answer already there opens nothing
|
|
76
|
+
const s0 = await p.evaluate(look);
|
|
77
|
+
ok('C1 the answer that was there has its chips, the file Claude wrote first and the file it read after', JSON.stringify(s0.chips) === JSON.stringify([['file:signup-drop.md*', 'file:signup-fix.md']]), JSON.stringify(s0.chips));
|
|
78
|
+
ok('C1 it opens nothing by itself: the viewer stays closed', s0.shut && s0.out === 0 && s0.tabs.length === 0, JSON.stringify(s0));
|
|
79
|
+
await answer(p, conv, 1, true);
|
|
80
|
+
await sleep(2600);
|
|
81
|
+
const s1 = await p.evaluate(look);
|
|
82
|
+
ok('C2 while Claude still works, the new answer has no chips and nothing opens', s1.shut && s1.chips.length === 1, JSON.stringify(s1));
|
|
83
|
+
conv.turn = 'user';
|
|
84
|
+
const s2 = await until(async () => { const v = await p.evaluate(look); return !v.shut && v.tabs.length ? v : null; }, 6000) || await p.evaluate(look);
|
|
85
|
+
ok('C2 when it has finished, its main item (the file it changed) opens in the viewer', !s2.shut && s2.out > 300 && JSON.stringify(s2.tabs) === JSON.stringify(['signup-plan1.md']), JSON.stringify(s2));
|
|
86
|
+
ok('C2 its chips: the file it changed, then the ticket and the Slack channel it worked with; a ticket only read and not named comes after', JSON.stringify(s2.chips[1]) === JSON.stringify(['file:signup-plan1.md*', 'slack:Slack channel', 'jira:SGN-42', 'jira:SGN-7']), JSON.stringify(s2.chips));
|
|
87
|
+
await sleep(2500);
|
|
88
|
+
ok('C2 it opens once: later reads open nothing more', JSON.stringify((await p.evaluate(look)).tabs) === JSON.stringify(['signup-plan1.md']));
|
|
89
|
+
await p.click('#dBody .ctxchip[data-ctx="jira"][data-ctx-ref="SGN-42"]');
|
|
90
|
+
const tk = await until(() => p.evaluate(() => { const e = document.querySelector('#dOut .obody.vw[data-vw="jira:SGN-42"]'); return e && /Fix the sign-up form/.test(e.textContent) ? { text: e.textContent, href: (e.querySelector('a') || {}).href } : null; }));
|
|
91
|
+
ok('C3 a Jira chip opens the ticket from the stored reading: key, summary, status, sprint, and Open in Jira', !!tk && /In Review/.test(tk.text) && /Active sprint: Sprint 14/.test(tk.text) && tk.href === 'https://acme.atlassian.net/browse/SGN-42', JSON.stringify(tk));
|
|
92
|
+
await p.click('#dBody .ctxchip[data-ctx="jira"][data-ctx-ref="SGN-7"]');
|
|
93
|
+
const none = await until(() => p.evaluate(() => { const e = document.querySelector('#dOut .obody.vw[data-vw="jira:SGN-7"]'); return e && /no reading/.test(e.textContent) ? e.textContent : null; }));
|
|
94
|
+
ok('C3 a key with no stored reading says so and claims nothing', !!none, String(none));
|
|
95
|
+
await p.click('#dBody .ctxchip[data-ctx="slack"]');
|
|
96
|
+
const sl = await until(() => p.evaluate(() => { const e = document.querySelector('#dOut .obody.vw[data-vw^="slack:"]'); const a = e && e.querySelector('a'); return a ? a.href : null; }));
|
|
97
|
+
ok('C4 a Slack chip opens a tab with Open in Slack', sl === 'slack://channel?id=C0123ABCD', String(sl));
|
|
98
|
+
const s3 = await p.evaluate(look);
|
|
99
|
+
ok('C6 at 1280 every chip is at least 44 px and nothing scrolls sideways', s3.minH >= 44 && !s3.wide, JSON.stringify(s3));
|
|
100
|
+
if (shots) await p.screenshot({ path: `${shots}/chat-context-1280-light.png` });
|
|
101
|
+
ok('C6 no page error at 1280', errs.length === 0, errs.join(' | '));
|
|
102
|
+
await ctx.close(); }
|
|
103
|
+
|
|
104
|
+
for (const scheme of ['light', 'dark']) {
|
|
105
|
+
const { p, ctx, errs, conv } = await open(390, scheme);
|
|
106
|
+
await sleep(2500);
|
|
107
|
+
await answer(p, conv, 2, false);
|
|
108
|
+
const s0 = await until(async () => { const v = await p.evaluate(look); return v.peek ? v : null; }, 6000) || await p.evaluate(look);
|
|
109
|
+
ok(`C5 at 390 (${scheme}) a new answer shows a bar over the message box and leaves the conversation uncovered`, /Claude wrote this · signup-plan2\.md\s*View/.test(s0.peek || '') && !s0.layer, JSON.stringify(s0));
|
|
110
|
+
if (shots) await p.screenshot({ path: `${shots}/chat-context-390-${scheme}.png` });
|
|
111
|
+
await p.click('#ctxPeek');
|
|
112
|
+
const s1 = await until(async () => { const v = await p.evaluate(look); return v.layer ? v : null; }) || await p.evaluate(look);
|
|
113
|
+
ok(`C5 at 390 (${scheme}) the bar's press opens the file in the viewer layer and the bar goes`, s1.layer && JSON.stringify(s1.tabs) === JSON.stringify(['signup-plan2.md']) && !s1.peek, JSON.stringify(s1));
|
|
114
|
+
await p.click('#vBack');
|
|
115
|
+
const s2 = await p.evaluate(look);
|
|
116
|
+
ok(`C6 at 390 (${scheme}) every chip is at least 44 px and nothing scrolls sideways`, s2.minH >= 44 && !s2.wide, JSON.stringify(s2));
|
|
117
|
+
ok(`C6 no page error at 390 (${scheme})`, errs.length === 0, errs.join(' | '));
|
|
118
|
+
await ctx.close();
|
|
119
|
+
}
|
|
120
|
+
return finish();
|
|
121
|
+
})();
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/* chat-context — what one of Claude's answers worked with (initiative premium-chat-viewer, slice 2). Pure: no DOM, so Node tests it.
|
|
2
|
+
* A turn is the PM's message and everything after it up to the next: Claude's words and the tool calls between them (lib/transcript-read.js
|
|
3
|
+
* gives each call its tool name and a short target: the file, the address, the Jira key, the Slack channel). contextOf() turns a turn into a
|
|
4
|
+
* short list of things the viewer can open, the main one first:
|
|
5
|
+
* 1. a file Claude wrote or changed, 2. a thing named in its words (a file path, a Jira key, a link), 3. a thing it only read.
|
|
6
|
+
* Kinds: 'file' (any file, opened read-only), 'jira' (a ticket key), 'slack' (a channel or a message link), 'web' (a Claude artifact, a Google
|
|
7
|
+
* Doc or a Confluence page, see chat-md.js webKind). Nothing here reads a file or calls a route; the viewer does that when a chip is pressed. */
|
|
8
|
+
import { looksFile, webKind, toolName } from './chat-md.js';
|
|
9
|
+
|
|
10
|
+
const MAX = 6;
|
|
11
|
+
const WRITE = /^(write|edit|multiedit|notebookedit|str_replace_based_edit_tool|create_file)$/i;
|
|
12
|
+
const READ = /^(read|notebookread|view)$/i;
|
|
13
|
+
const JIRA_KEY = /\b([A-Z][A-Z0-9]{1,9})-(\d{1,6})\b/g;
|
|
14
|
+
const NOT_JIRA = new Set(['UTF', 'ISO', 'SHA', 'RFC', 'CVE', 'MD', 'HTTP', 'TLS', 'SSL', 'IPV', 'COVID', 'GPT', 'Q1', 'Q2', 'Q3', 'Q4', 'H1', 'H2', 'FY', 'P0', 'P1', 'P2', 'P3', 'P4', 'L2', 'L3', 'L4', 'KR', 'D']);
|
|
15
|
+
const SLACK_LINK = /https:\/\/[\w-]+\.slack\.com\/archives\/[A-Z0-9]+(\/p\d+)?[^\s)\]>"']*/g;
|
|
16
|
+
const URL_RE = /https?:\/\/[^\s)\]>"'`]+/g;
|
|
17
|
+
const PATH_RE = /`([^`\n]+)`|\[[^\]\n]*\]\(([^)\s]+)\)|(?:^|[\s(])((?:~\/|\.{1,2}\/|\/)?[\w.@+-]+(?:\/[\w.@+-]+)+\.[A-Za-z0-9]{1,10})(?=[\s).,;:!?]|$)/gm;
|
|
18
|
+
|
|
19
|
+
const base = (p) => String(p).split('/').filter(Boolean).pop() || String(p);
|
|
20
|
+
const clip = (s, n) => (s.length > n ? s.slice(0, n - 1) + '…' : s);
|
|
21
|
+
const keyOf = (it) => it.kind + ':' + (it.kind === 'file' ? it.path : it.kind === 'jira' ? it.key : it.url || it.channel);
|
|
22
|
+
|
|
23
|
+
/** A Jira key in a tool call's target or input words, or null. */
|
|
24
|
+
export function jiraKeyIn(s) {
|
|
25
|
+
const m = String(s || '').match(/\b[A-Z][A-Z0-9]{1,9}-\d{1,6}\b/);
|
|
26
|
+
return m && !NOT_JIRA.has(m[0].split('-')[0]) ? m[0] : null;
|
|
27
|
+
}
|
|
28
|
+
/** A Slack place from a tool call: { channel, ts } from the target lib/transcript-read.js wrote ("C0123 1700000000.000100" or a link). */
|
|
29
|
+
export function slackOf(target) {
|
|
30
|
+
const t = String(target || '');
|
|
31
|
+
const link = t.match(/https:\/\/[\w-]+\.slack\.com\/archives\/[A-Z0-9]+[^\s]*/); if (link) return { url: link[0] };
|
|
32
|
+
const m = t.match(/\b([CDG][A-Z0-9]{6,})\b(?:\s+(\d{9,}\.\d+))?/);
|
|
33
|
+
return m ? { channel: m[1], ts: m[2] || null } : null;
|
|
34
|
+
}
|
|
35
|
+
/** The address that opens a Slack channel or message: its own link, or the Slack app's address for a channel (the page names no web origin of its own). */
|
|
36
|
+
export const slackUrl = (it) => it.url || ('slack://channel?id=' + encodeURIComponent(it.channel));
|
|
37
|
+
|
|
38
|
+
/** One item for a tool call, or null. */
|
|
39
|
+
function fromCall(c) {
|
|
40
|
+
const n = toolName(c && c.tool), t = String((c && c.target) || '').trim();
|
|
41
|
+
if (!t) return null;
|
|
42
|
+
if (WRITE.test(n) && looksFile(t)) return { kind: 'file', path: t, how: 'wrote' };
|
|
43
|
+
if (READ.test(n) && looksFile(t)) return { kind: 'file', path: t, how: 'read' };
|
|
44
|
+
if (/jira/i.test(n)) { const k = jiraKeyIn(t); if (k) return { kind: 'jira', key: k, how: /edit|create|transition|comment|add/i.test(n) ? 'wrote' : 'read' }; }
|
|
45
|
+
if (/slack/i.test(n)) { const s = slackOf(t); if (s) return { kind: 'slack', ...s, how: /send|post|schedule|update/i.test(n) ? 'wrote' : 'read' }; }
|
|
46
|
+
if (/^https?:\/\//.test(t)) { const w = webKind(t); if (w) return { kind: 'web', url: t, web: w, how: 'read' }; }
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/** The items Claude's words name: file paths, Jira keys it also touched or whose project it touched, Slack links and web links. */
|
|
50
|
+
function fromText(text, projects) {
|
|
51
|
+
const s = String(text || ''), out = [];
|
|
52
|
+
for (const m of s.matchAll(PATH_RE)) { const p = (m[1] || m[2] || m[3] || '').replace(/:\d+(:\d+)?$/, ''); if (looksFile(p)) out.push({ kind: 'file', path: p, how: 'named' }); }
|
|
53
|
+
for (const m of s.matchAll(SLACK_LINK)) out.push({ kind: 'slack', url: m[0], how: 'named' });
|
|
54
|
+
for (const m of s.matchAll(URL_RE)) { const w = webKind(m[0]); if (w) out.push({ kind: 'web', url: m[0], web: w, how: 'named' }); }
|
|
55
|
+
for (const m of s.matchAll(JIRA_KEY)) if (projects.has(m[1]) && !NOT_JIRA.has(m[1])) out.push({ kind: 'jira', key: m[0], how: 'named' });
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
const RANK = { wrote: 0, named: 1, read: 2 };
|
|
59
|
+
/** The title and the small line a chip shows. */
|
|
60
|
+
export function labelOf(it) {
|
|
61
|
+
if (it.kind === 'file') return { title: clip(base(it.path), 48), sub: it.how === 'wrote' ? 'Claude wrote this' : it.how === 'named' ? 'File' : 'Claude read this' };
|
|
62
|
+
if (it.kind === 'jira') return { title: it.key, sub: 'Jira ticket' };
|
|
63
|
+
if (it.kind === 'slack') return { title: it.channel ? 'Slack channel' : 'Slack message', sub: it.how === 'wrote' ? 'Claude posted here' : 'Slack' };
|
|
64
|
+
return { title: it.web === 'artifact' ? 'Claude artifact' : it.web === 'google' ? 'Google file' : 'Confluence page', sub: it.how === 'named' ? 'Link' : 'Claude read this' };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* What one turn worked with, the main item first. calls: [{ tool, target }] in order; text: Claude's words in the turn; projects: Jira project
|
|
68
|
+
* prefixes seen anywhere in the conversation's tool calls (a key in the words counts only for a project Claude touched, so "UTF-8" is not a ticket).
|
|
69
|
+
* Returns at most MAX items, each { kind, id, title, sub, how, ... }.
|
|
70
|
+
*/
|
|
71
|
+
export function contextOf(calls, text, projects = new Set()) {
|
|
72
|
+
const seen = new Map();
|
|
73
|
+
const add = (it, order) => { if (!it) return; const k = keyOf(it), was = seen.get(k); if (!was) seen.set(k, { ...it, id: k, order }); else if (RANK[it.how] < RANK[was.how]) seen.set(k, { ...was, how: it.how }); };
|
|
74
|
+
(calls || []).forEach((c, i) => add(fromCall(c), i));
|
|
75
|
+
fromText(text, projects).forEach((it, i) => add(it, 1000 + i));
|
|
76
|
+
// files Claude only searched through (Grep/Glob results) never reach here: only Read, Write and Edit name one file
|
|
77
|
+
return [...seen.values()].sort((a, b) => RANK[a.how] - RANK[b.how] || (a.how === 'wrote' ? b.order - a.order : a.order - b.order)).slice(0, MAX).map((it) => ({ ...it, ...labelOf(it) }));
|
|
78
|
+
}
|
|
79
|
+
/** The Jira project prefixes in a conversation's tool calls. */
|
|
80
|
+
export function jiraProjects(messages) {
|
|
81
|
+
const out = new Set();
|
|
82
|
+
for (const m of messages || []) for (const c of (m && m.calls) || []) { if (!/jira/i.test(toolName(c.tool))) continue; const k = jiraKeyIn(c.target); if (k) out.add(k.split('-')[0]); }
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The conversation split into turns, each with its context: [{ at, id, done, items }]. at: the index of the assistant message that ends the turn;
|
|
87
|
+
* id: that message's time (stable when older messages scroll out of the read); done: the PM wrote after it, or Claude is waiting (waiting=true)
|
|
88
|
+
* and it is the last turn. A turn with no words from Claude has none. messages: the session conversation (lib/transcript-read.js).
|
|
89
|
+
*/
|
|
90
|
+
export function turnsOf(messages, waiting = false) {
|
|
91
|
+
const ms = messages || [], projects = jiraProjects(ms), out = [];
|
|
92
|
+
let calls = [], words = [], last = -1;
|
|
93
|
+
const close = (done) => { if (last >= 0) out.push({ at: last, id: (ms[last] && ms[last].at) || 'i' + last, done, items: contextOf(calls, words.join('\n'), projects) }); calls = []; words = []; last = -1; };
|
|
94
|
+
ms.forEach((m, i) => {
|
|
95
|
+
if (!m) return;
|
|
96
|
+
if (m.role === 'user') { close(true); return; }
|
|
97
|
+
if (m.role === 'tool') { calls.push(...(m.calls || [])); return; }
|
|
98
|
+
if (m.role === 'assistant') { words.push(m.text || ''); last = i; }
|
|
99
|
+
});
|
|
100
|
+
close(!!waiting);
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
@@ -3,6 +3,8 @@ import { pmGet, pmPost } from './http.js';
|
|
|
3
3
|
import { recChipView, STOP_LINE } from './premium-meeting.js';
|
|
4
4
|
import { vwReset, vwOn, vwCount } from './premium-viewer.js';
|
|
5
5
|
import { openChatFile, openWebLink } from './premium-vw-file.js';
|
|
6
|
+
import { turnsOf } from './chat-context.js';
|
|
7
|
+
import { chipsHtml, itemOf, openCtx } from './premium-vw-ctx.js';
|
|
6
8
|
import { chipActs, openLive, openFocus, mountRecord, HL_LINE } from './premium-vw-rec.js';
|
|
7
9
|
import { lineItems, behindOf, whenRead } from './freshness-words.js';
|
|
8
10
|
import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, slashMatches } from './goal-chat.js';
|
|
@@ -404,12 +406,13 @@ export function sessionHtml(c, goal = null) {
|
|
|
404
406
|
if (c.state !== 'conv' && c.state !== 'ended') return turnAgent(`<p class="tt" role="status">${esc(c.missing || 'Claude is starting.')}</p>`);
|
|
405
407
|
const msgs = c.messages || [], last = msgs.length - 1;
|
|
406
408
|
const waiting = !c.ask && c.turn !== 'agent' && c.turn !== 'tool';
|
|
409
|
+
const ctx = new Map(turnsOf(msgs, waiting || c.state === 'ended').filter((t) => t.done).map((t) => [t.at, t.items])); // premium-chat-viewer slice 2
|
|
407
410
|
const out = msgs.map((m, i) => {
|
|
408
411
|
if (m.role === 'user') return turnUser(shownUser(m.text));
|
|
409
412
|
if (m.role !== 'assistant') return `<p class="toolline" title="${esc((m.calls || []).map((x) => x.tool + (x.target ? ' ' + x.target : '')).join('\n'))}">${esc(toolLine(m.tools))}</p>`;
|
|
410
413
|
const g = splitGoal(m.text);
|
|
411
414
|
const live = i === last && waiting && !!goal && goal.state === 'grilling';
|
|
412
|
-
return turnAgent(`<p class="agtag">Claude</p>${g.text ? mdHtml(g.text) : ''}${goalBlockHtml(g.block, { live, state: goal && goal.state })}`);
|
|
415
|
+
return turnAgent(`<p class="agtag">Claude</p>${g.text ? mdHtml(g.text) : ''}${goalBlockHtml(g.block, { live, state: goal && goal.state })}${chipsHtml(ctx.get(i))}`);
|
|
413
416
|
});
|
|
414
417
|
const gp = goalProgressHtml(goal); if (gp) out.push(gp);
|
|
415
418
|
// item-chat-history: an ended session keeps its conversation on the item; the next message picks it up
|
|
@@ -435,6 +438,7 @@ export function drawThread(th, key, conv) {
|
|
|
435
438
|
let t = $('#thr', box); if (!t) { box.insertAdjacentHTML('beforeend', '<div id="thr"></div>'); t = $('#thr', box); }
|
|
436
439
|
const b = $('#dBody'), atEnd = b.scrollHeight - b.scrollTop - b.clientHeight < 80;
|
|
437
440
|
putHtml(t, threadHtml(th) + sessionHtml(conv, th.goal));
|
|
441
|
+
ctxAuto(key, conv);
|
|
438
442
|
S.goal = th.goal || null; S.draft = readyDraft(conv); S.session = th.session || null;
|
|
439
443
|
const go = $('#askGo'); if (go) go.disabled = !!th.working; // an earlier read-only run still answering
|
|
440
444
|
const n = $('#askNote'); if (n) n.textContent = th.working ? 'The agent is answering. You can write again when it has.' : conv && conv.ask ? 'Claude is waiting for your answer above.' : CHAT_NOTE;
|
|
@@ -452,6 +456,38 @@ export async function loadThread(key) {
|
|
|
452
456
|
drawThread(th, key, conv && conv.ok ? conv : null);
|
|
453
457
|
if ((th.working || th.session) && S.key === key && $('#dlg').classList.contains('on')) threadTimer = setTimeout(() => loadThread(key), 2000);
|
|
454
458
|
}
|
|
459
|
+
/* premium-chat-viewer slice 2: when one of Claude's answers finishes while the chat is open, the main thing it worked with opens by itself, once.
|
|
460
|
+
* On a desktop it opens in the viewer; on a phone a bar over the message box offers it, so the conversation is not covered. Answers that were
|
|
461
|
+
* already there when the chat opened open nothing. */
|
|
462
|
+
const CTX = { key: null, seen: new Set(), peekTimer: null };
|
|
463
|
+
function ctxAuto(key, conv) {
|
|
464
|
+
if (!conv || !Array.isArray(conv.messages)) return;
|
|
465
|
+
const waiting = !conv.ask && conv.turn !== 'agent' && conv.turn !== 'tool';
|
|
466
|
+
const done = turnsOf(conv.messages, waiting || conv.state === 'ended').filter((t) => t.done);
|
|
467
|
+
if (CTX.key !== key) { CTX.key = key; CTX.seen = new Set(done.map((t) => t.id)); ctxPeek(null); return; }
|
|
468
|
+
for (const t of done) {
|
|
469
|
+
if (CTX.seen.has(t.id)) continue;
|
|
470
|
+
CTX.seen.add(t.id);
|
|
471
|
+
if (!t.items.length || t !== done[done.length - 1]) continue; // only the newest answer opens anything
|
|
472
|
+
if (desk()) openCtx(t.items[0], ctxWhere()); else ctxPeek(t.items[0]);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const ctxWhere = () => ({ session: S.session || null, ws: new URLSearchParams(location.search).get('ws') });
|
|
476
|
+
function ctxPeek(it) {
|
|
477
|
+
clearTimeout(CTX.peekTimer);
|
|
478
|
+
let b = $('#ctxPeek');
|
|
479
|
+
if (!it) { if (b) b.hidden = true; return; }
|
|
480
|
+
const f = $('#askF'); if (!f) return;
|
|
481
|
+
if (!b) { f.insertAdjacentHTML('beforebegin', '<button type="button" class="ctxpeek" id="ctxPeek" hidden></button>'); b = $('#ctxPeek'); }
|
|
482
|
+
b.innerHTML = `<span>${esc(it.sub)} · <b>${esc(it.title)}</b></span><em>View</em>`; b.hidden = false;
|
|
483
|
+
b.onclick = () => { ctxPeek(null); openCtx(it, ctxWhere()); };
|
|
484
|
+
CTX.peekTimer = setTimeout(() => ctxPeek(null), 15000);
|
|
485
|
+
}
|
|
486
|
+
$('#dBody').addEventListener('click', (e) => {
|
|
487
|
+
const b = e.target.closest('[data-ctx]'); if (!b) return;
|
|
488
|
+
e.preventDefault(); openCtx(itemOf(b), ctxWhere());
|
|
489
|
+
if (innerWidth < 1000 && !chatPage()) setTab('out');
|
|
490
|
+
});
|
|
455
491
|
/** The draft of the newest ready goal block in the conversation, which Start sends as the confirmed goal. */
|
|
456
492
|
function readyDraft(conv) {
|
|
457
493
|
const ms = (conv && conv.messages) || [];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* pm/premium-vw-ctx.js — what one of Claude's answers worked with, as chips under the answer and as viewer tabs (initiative premium-chat-viewer, slice 2).
|
|
2
|
+
* chat-context.js finds the items (pure); this file draws the chips and opens an item in the viewer:
|
|
3
|
+
* file → premium-vw-file.js openChatFile (read-only, current while the tab is open)
|
|
4
|
+
* web → premium-vw-file.js openWebLink (a Google Doc or Confluence copy, or a Claude artifact's Open in Claude)
|
|
5
|
+
* jira → a ticket tab from the stored Jira readings (GET /api/jira/ticket); PMOS never reads Jira from here
|
|
6
|
+
* slack → a Slack tab with Open in Slack; PMOS stores no Slack message to show
|
|
7
|
+
* Nothing here writes. */
|
|
8
|
+
import { vwOpen, vwStyle } from './premium-viewer.js';
|
|
9
|
+
import { openChatFile, openWebLink } from './premium-vw-file.js';
|
|
10
|
+
import { slackUrl } from './chat-context.js';
|
|
11
|
+
|
|
12
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
13
|
+
const ICO = {
|
|
14
|
+
file: '<path d="M6 3h9l4 4v14H6zM14 3v5h5"/>',
|
|
15
|
+
jira: '<path d="M12 3 4 11l8 8 8-8zM12 8v6"/>',
|
|
16
|
+
slack: '<path d="M8 4v12M16 8v12M4 16h12M8 8h12"/>',
|
|
17
|
+
web: '<path d="M14 4h6v6M20 4l-9 9M18 14v6H4V6h6"/>',
|
|
18
|
+
};
|
|
19
|
+
const icon = (k) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${ICO[k] || ICO.file}</svg>`;
|
|
20
|
+
const ref = (it) => (it.kind === 'file' ? it.path : it.kind === 'jira' ? it.key : it.url || it.channel || '');
|
|
21
|
+
|
|
22
|
+
/** The chip row under an answer. Pure. The first item is the main one: it is what opened by itself. */
|
|
23
|
+
export function chipsHtml(items) {
|
|
24
|
+
if (!items || !items.length) return '';
|
|
25
|
+
return `<div class="ctxc" role="list" aria-label="What Claude worked with">${items.map((it, i) => `<button type="button" class="ctxchip${i === 0 ? ' lead' : ''}" role="listitem" data-ctx="${esc(it.kind)}" data-ctx-ref="${esc(ref(it))}"${it.ts ? ` data-ctx-ts="${esc(it.ts)}"` : ''}${it.web ? ` data-ctx-web="${esc(it.web)}"` : ''} title="${esc(ref(it))}">${icon(it.kind)}<span><b>${esc(it.title)}</b><em>${esc(it.sub)}</em></span></button>`).join('')}</div>`;
|
|
26
|
+
}
|
|
27
|
+
/** An item from a chip's data attributes. */
|
|
28
|
+
export function itemOf(b) {
|
|
29
|
+
const k = b.dataset.ctx, r = b.dataset.ctxRef || '';
|
|
30
|
+
if (k === 'file') return { kind: k, path: r, title: b.querySelector('b') ? b.querySelector('b').textContent : r };
|
|
31
|
+
if (k === 'jira') return { kind: k, key: r };
|
|
32
|
+
if (k === 'slack') return /^https:/.test(r) ? { kind: k, url: r } : { kind: k, channel: r, ts: b.dataset.ctxTs || null };
|
|
33
|
+
return { kind: 'web', url: r, web: b.dataset.ctxWeb || null, title: b.querySelector('b') ? b.querySelector('b').textContent : r };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The ticket tab as HTML from GET /api/jira/ticket. Pure. */
|
|
37
|
+
export function ticketHtml(key, t) {
|
|
38
|
+
if (!t) return `<div class="vwdoc"><div class="vwfnone" role="status"><b>${esc(key)}</b><p class="vwmut">PMOS has no reading of this ticket. Only tickets on a board or initiative that PMOS syncs with Jira are read.</p></div></div>`;
|
|
39
|
+
const when = t.fetchedAt ? new Date(t.fetchedAt) : null;
|
|
40
|
+
const read = when && !isNaN(when) ? 'Read from Jira ' + when.toLocaleString([], { dateStyle: 'medium', timeStyle: 'short' }) : 'Read from Jira';
|
|
41
|
+
const sprint = t.category === 'done' ? 'Done' : t.sprint ? (t.sprint.state === 'active' ? 'Active sprint: ' : t.sprint.state === 'future' ? 'Next sprint: ' : 'Sprint: ') + t.sprint.name : 'Backlog';
|
|
42
|
+
return `<div class="vwdoc"><div class="vwfnone vwtk" role="status"><b>${esc(key)} · ${esc(t.summary || '')}</b>`
|
|
43
|
+
+ `<p class="vwmut">${esc(t.status || 'No status read')} · ${esc(sprint)}${t.flagged ? ' · ' + esc(t.reason || 'Flagged') : ''}</p>`
|
|
44
|
+
+ `<p class="vwmut">${esc(read)}. Assignee, comments and the other fields stay in Jira.</p>`
|
|
45
|
+
+ (t.url ? `<div class="vwrow"><a class="vwbtn pri" href="${esc(t.url)}" target="_blank" rel="noopener noreferrer">Open in Jira</a></div>` : '') + '</div></div>';
|
|
46
|
+
}
|
|
47
|
+
/** The Slack tab as HTML. Pure. */
|
|
48
|
+
export function slackHtml(it) {
|
|
49
|
+
const what = it.url ? 'A Slack message' : it.ts ? 'A message in a Slack channel' : 'A Slack channel';
|
|
50
|
+
return `<div class="vwdoc"><div class="vwfnone" role="status"><b>${esc(what)}</b><p class="vwmut">Claude worked with this in Slack. PMOS keeps no copy of Slack messages, so it opens in Slack.</p>`
|
|
51
|
+
+ `<div class="vwrow"><a class="vwbtn pri" href="${esc(slackUrl(it))}" target="_blank" rel="noopener noreferrer">Open in Slack</a></div><code>${esc(it.url || it.channel + (it.ts ? ' · ' + it.ts : ''))}</code></div></div>`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Open one item in the viewer. ctx: { session, ws }. */
|
|
55
|
+
export function openCtx(it, ctx = {}) {
|
|
56
|
+
if (!it) return null;
|
|
57
|
+
if (it.kind === 'file') return openChatFile(it.path, ctx);
|
|
58
|
+
if (it.kind === 'web') return openWebLink(it.url, it.web, it.title, ctx);
|
|
59
|
+
vwStyle('doc');
|
|
60
|
+
if (it.kind === 'slack') return vwOpen({ id: 'slack:' + (it.url || it.channel + ':' + (it.ts || '')), title: it.url || it.ts ? 'Slack message' : 'Slack channel', icon: 'doc', render: (el) => { el.innerHTML = slackHtml(it); } });
|
|
61
|
+
return vwOpen({
|
|
62
|
+
id: 'jira:' + it.key, title: it.key, icon: 'tk',
|
|
63
|
+
render: async (el) => {
|
|
64
|
+
el.innerHTML = '<div class="vwdoc"><p class="vwmut">Reading the stored Jira reading</p></div>';
|
|
65
|
+
let t = null;
|
|
66
|
+
try { const r = await fetch('/api/jira/ticket?key=' + encodeURIComponent(it.key) + (ctx.ws ? '&ws=' + encodeURIComponent(ctx.ws) : ''), { credentials: 'same-origin' }); const j = await r.json(); t = j && j.ok ? j.ticket : null; } catch { t = null; }
|
|
67
|
+
el.innerHTML = ticketHtml(it.key, t);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -2703,3 +2703,18 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
2703
2703
|
.vtab[hidden]{display:none}
|
|
2704
2704
|
@media (min-width:1000px){.chatpg .dlg.full .otop{flex-wrap:nowrap;align-items:center}.chatpg .dlg.full .otop #vTabs{flex:1 1 0;min-width:0}}
|
|
2705
2705
|
.chatpg.vwlayer .dlg.on{border-radius:0}
|
|
2706
|
+
/* ── premium-chat-viewer slice 2: what an answer worked with, as chips under it (the main one first); on a phone a bar over the box offers it ── */
|
|
2707
|
+
.ctxc{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
|
|
2708
|
+
.ctxchip{display:inline-flex;align-items:center;gap:8px;min-height:44px;max-width:100%;padding:6px 12px 6px 10px;border-radius:var(--r-chip);background:var(--well);color:var(--ink);text-align:left;cursor:pointer}
|
|
2709
|
+
.ctxchip:hover{background:var(--card)}
|
|
2710
|
+
.ctxchip:focus-visible{outline:2px solid var(--ink);outline-offset:1px}
|
|
2711
|
+
.ctxchip.lead{background:var(--card-solid);box-shadow:var(--card-shadow)}
|
|
2712
|
+
.ctxchip .i{width:16px;height:16px;flex:none;color:var(--ink-2)}
|
|
2713
|
+
.ctxchip span{display:flex;flex-direction:column;min-width:0}
|
|
2714
|
+
.ctxchip b{font-weight:600;font-size:var(--fs-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:240px}
|
|
2715
|
+
.ctxchip em{font-style:normal;font-size:var(--fs-1);color:var(--ink-3)}
|
|
2716
|
+
.ctxpeek{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;min-height:44px;margin:0 0 8px;padding:6px 14px;border-radius:14px;background:var(--card-solid);box-shadow:var(--card-shadow);color:var(--ink-2);font-size:var(--fs-2);text-align:left}
|
|
2717
|
+
.ctxpeek[hidden]{display:none}
|
|
2718
|
+
.ctxpeek b{color:var(--ink);font-weight:600}
|
|
2719
|
+
.ctxpeek em{font-style:normal;font-weight:600;color:var(--ink)}
|
|
2720
|
+
.vwtk b{display:block}
|
package/workspace/server.js
CHANGED
|
@@ -8050,6 +8050,11 @@ async function handleRequest(req, res) {
|
|
|
8050
8050
|
// `jira-push` for the tickets the PM selected (a PM-only press, pm-guard act `push`, which first records the
|
|
8051
8051
|
// selection), and Check now starts `jira-sync` for this initiative. No route here reads or writes Jira: the session,
|
|
8052
8052
|
// holding the PM's own Atlassian connection, does (D53, D88).
|
|
8053
|
+
if (p === '/api/jira/ticket' && req.method === 'GET') { // premium-chat-viewer slice 2: one ticket by key from the stored Jira readings
|
|
8054
|
+
const w = getWs(url.searchParams.get('ws'));
|
|
8055
|
+
const t = jiraStatus.findTicket(w ? w.root : SELF_ROOT, url.searchParams.get('key'));
|
|
8056
|
+
return json(res, { ok: true, ticket: t });
|
|
8057
|
+
}
|
|
8053
8058
|
if (p === '/api/jira/tickets' && req.method === 'GET') {
|
|
8054
8059
|
const w = getWs(url.searchParams.get('ws'));
|
|
8055
8060
|
const root = w ? w.root : SELF_ROOT;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "What an answer worked with shows as chips under it (files, Jira tickets, Slack, links) and its main item opens once when Claude finishes; on a phone a bar offers it. Real server, 390 and 1280 wide.",
|
|
3
|
+
"seconds": {
|
|
4
|
+
"premium-chat-context-test.js": 40
|
|
5
|
+
},
|
|
6
|
+
"panels": [
|
|
7
|
+
"premium-chat-context-test.js"
|
|
8
|
+
]
|
|
9
|
+
}
|