create-pmos 0.377.0 → 0.379.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/briefing-premium-test.js +1 -1
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +14 -8
- package/workspace/lib/chat-files.js +50 -3
- package/workspace/lib/jira-status.js +20 -1
- package/workspace/lib/routes-briefing-premium.js +18 -0
- 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-attach-test.js +2 -3
- package/workspace/premium-chat-context-test.js +121 -0
- package/workspace/premium-chat-notes-test.js +146 -0
- package/workspace/public/pm/chat-context.js +102 -0
- package/workspace/public/pm/premium-attach.js +17 -6
- package/workspace/public/pm/premium-notes.js +227 -0
- package/workspace/public/pm/premium-shell.js +43 -7
- package/workspace/public/pm/premium-vw-ctx.js +70 -0
- package/workspace/public/pm/premium-vw-notepad.css +41 -0
- package/workspace/public/pm/premium.css +16 -21
- package/workspace/server.js +5 -0
- package/workspace/test-lists/premium-chat-context.json +9 -0
- package/workspace/test-lists/premium-chat-notes.json +13 -0
- package/workspace/premium-pad-test.js +0 -125
- package/workspace/public/pm/premium-pad.js +0 -89
- package/workspace/test-lists/premium-pad.json +0 -13
|
@@ -3,11 +3,13 @@ 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';
|
|
9
11
|
import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
|
|
10
|
-
import {
|
|
12
|
+
import { mountNotes, openNotes, flushNotes, syncNotes } from './premium-notes.js';
|
|
11
13
|
import { attachMarkup, attachRowMarkup, mountAttach, attachNames, clearAttach, syncAttach, dropFiles, splitFiles, filesHtml, openAttachment } from './premium-attach.js';
|
|
12
14
|
import { railModel, railHtml, teaser, menuCount, loudestRow, factsOf, titleOf, endAsks, DOT, WORD } from './session-rail.js';
|
|
13
15
|
export const $ = (s, r = document) => r.querySelector(s);
|
|
@@ -291,9 +293,9 @@ export function openDlg(o) {
|
|
|
291
293
|
$('#oMain').innerHTML = o.pane || `<article class="paper doc">${o.html}</article>`; $('#oLab').textContent = o.label || 'Detail';
|
|
292
294
|
if (o.paneEmpty) $('#oMain').dataset.empty = '1'; else delete $('#oMain').dataset.empty; // a placeholder note is not a tab (premium-chat-viewer V2)
|
|
293
295
|
vwReset(); // extra viewer tabs belong to the dialog that opened them
|
|
294
|
-
$('#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>${
|
|
295
|
-
|
|
296
|
-
mountAttach({ getKey: () => S.key, input: $('#askIn'), note: $('#askNote'), onSlash: () => { const i = $('#askIn'); if (!i.value.startsWith('/')) i.value = '/' + i.value; i.focus(); drawSlash(); growAsk(); }, onPad: () =>
|
|
296
|
+
$('#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>${attachRowMarkup()}${attachMarkup()}<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></div>`;
|
|
297
|
+
mountNotes({ getKey: () => S.key, ws: new URLSearchParams(location.search).get('ws'), input: $('#askIn'), note: $('#askNote'), show: () => { if (!desk()) setTab('out'); }, toChat: () => { if (!desk()) setTab('chat'); } });
|
|
298
|
+
mountAttach({ getKey: () => S.key, input: $('#askIn'), note: $('#askNote'), onSlash: () => { const i = $('#askIn'); if (!i.value.startsWith('/')) i.value = '/' + i.value; i.focus(); drawSlash(); growAsk(); }, onPad: () => openNotes() });
|
|
297
299
|
quietNote();
|
|
298
300
|
$('#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
|
|
299
301
|
$('#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
|
|
@@ -323,7 +325,7 @@ export function setFocus(f) {
|
|
|
323
325
|
$('#dFocus').onclick = () => setFocus(!$('#dlg').classList.contains('focus'));
|
|
324
326
|
export function closeDlg() {
|
|
325
327
|
if (chatPage()) return;
|
|
326
|
-
clearTimeout(threadTimer); S.key = null;
|
|
328
|
+
clearTimeout(threadTimer); S.key = null; flushNotes(); railOnClose();
|
|
327
329
|
park();
|
|
328
330
|
$('#veil').classList.remove('on'); $$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; });
|
|
329
331
|
$('#dlg').inert = true; document.documentElement.style.overflow = ''; $('#dlg').classList.remove('on');
|
|
@@ -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) || [];
|
|
@@ -1205,7 +1241,7 @@ function pickSession(id) {
|
|
|
1205
1241
|
const st = $('#dBody .stream'); if (st) clearHtml(st);
|
|
1206
1242
|
$('#askF').hidden = !!r.headless; $('#askIn').value = ''; $('#askIn').placeholder = r.key ? 'Message Claude, or type /' : 'Message this session';
|
|
1207
1243
|
if (r.key) { S.sid = null; S.key = r.key; loadThread(r.key); } else { S.key = null; S.sid = id; loadSid(id); }
|
|
1208
|
-
syncAttach();
|
|
1244
|
+
syncAttach(); syncNotes();
|
|
1209
1245
|
sessionCard(r); railDraw();
|
|
1210
1246
|
if (!r.key && desk()) vwOpenPane(true); // a session with no conversation of its own: its facts and Stop are in the viewer; the list the PM just used stays open
|
|
1211
1247
|
if (!desk()) setTab('chat');
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
:root{--fs-1:11px;--fs-2:12px;--fs-3:14px;--fs-4:16px;--fs-5:20px;--fs-6:28px}
|
|
2
|
+
/* premium-vw-notepad.css — Notes in the premium viewer (premium-notes.js; initiative premium-chat-attach N1-N7). Loaded once by vwStyle('notepad').
|
|
3
|
+
* Sizes are the console's six steps only (var(--fs-1..6)), weights 400/500/600, the page's own tokens otherwise. Checked by premium-console-type.test.js. */
|
|
4
|
+
.p-out>.obody.vw:not([hidden]):has(>.ntpad){flex:1;min-height:0;display:flex!important;flex-direction:column} /* the notepad fills the pane: the note scrolls, its foot stays */
|
|
5
|
+
.ntpad{flex:1;min-height:0;width:100%;display:flex;flex-direction:column;max-width:780px;margin:0 auto;position:relative}
|
|
6
|
+
.nth{display:flex;align-items:center;gap:8px;padding:2px 0 10px;border-bottom:1px solid var(--hair)}
|
|
7
|
+
.nth .gap{flex:1}
|
|
8
|
+
.ntsw{display:inline-flex;align-items:center;gap:4px;min-width:0;max-width:60%;min-height:34px;padding:0 6px;margin-left:-6px;border:0;border-radius:6px;background:none;color:var(--ink);font:600 var(--fs-3) var(--sans);cursor:pointer}
|
|
9
|
+
.ntsw b{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
10
|
+
.ntsw .i{width:15px;height:15px;flex:none}
|
|
11
|
+
.ntn,.ntst{font-size:var(--fs-2);color:var(--ink-3);white-space:nowrap}
|
|
12
|
+
.ntic{flex:none;width:36px;height:36px;display:inline-grid;place-items:center;border-radius:6px;border:1px solid var(--hair);background:var(--card-solid);color:var(--ink);cursor:pointer}
|
|
13
|
+
.ntic .i{width:17px;height:17px}
|
|
14
|
+
.ntic.pri{background:var(--solid);border-color:var(--solid);color:var(--on-solid)}
|
|
15
|
+
.ntmenu{position:absolute;top:42px;left:0;z-index:5;min-width:220px;max-width:min(340px,100%);max-height:320px;overflow:auto;padding:6px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid);box-shadow:var(--card-shadow);display:grid;gap:2px}
|
|
16
|
+
.ntmenu[hidden]{display:none}
|
|
17
|
+
.ntmenu button{display:flex;align-items:center;gap:8px;min-height:36px;padding:0 10px;border:0;border-radius:6px;background:none;color:var(--ink);font:400 var(--fs-3) var(--sans);text-align:left;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
18
|
+
.ntmenu button[aria-current]{font-weight:600}
|
|
19
|
+
.ntmenu .ntdel{color:var(--ink-2);border-top:1px solid var(--hair);border-radius:0;margin-top:4px}
|
|
20
|
+
.ntmenu .ntdel .i{width:15px;height:15px}
|
|
21
|
+
.ntd{flex:1;min-height:160px;overflow-y:auto;padding:16px 0;outline:0;font:400 var(--fs-4)/1.6 var(--sans);color:var(--ink);overflow-wrap:anywhere}
|
|
22
|
+
.ntd.ph::before{content:attr(data-ph);color:var(--ink-3);pointer-events:none;position:absolute}
|
|
23
|
+
.ntd>*:first-child{margin-top:0}
|
|
24
|
+
.ntd p{margin:0 0 8px}
|
|
25
|
+
.ntd h1{font-size:var(--fs-5);font-weight:600;margin:4px 0 10px}
|
|
26
|
+
.ntd h2{font-size:var(--fs-4);font-weight:600;margin:14px 0 6px}
|
|
27
|
+
.ntd h3{font-size:var(--fs-3);font-weight:600;margin:12px 0 4px;color:var(--ink-2)}
|
|
28
|
+
.ntd ul,.ntd ol{margin:0 0 8px;padding-left:22px}
|
|
29
|
+
.ntd ul.tasks{list-style:none;padding-left:0}
|
|
30
|
+
.ntd li{margin:2px 0}
|
|
31
|
+
.ntd li.task{display:flex;align-items:baseline;gap:8px}
|
|
32
|
+
.ntd li.task input{flex:none;width:16px;height:16px;margin:0;transform:translateY(2px);accent-color:var(--solid);cursor:pointer}
|
|
33
|
+
.ntd li.task.done>span{text-decoration:line-through;color:var(--ink-3)}
|
|
34
|
+
.ntd b,.ntd strong{font-weight:600}
|
|
35
|
+
.ntd code{font:400 var(--fs-2) var(--mono);background:var(--well);padding:1px 4px;border-radius:6px}
|
|
36
|
+
.ntd blockquote{margin:0 0 8px;padding-left:12px;border-left:3px solid var(--hair);color:var(--ink-2)}
|
|
37
|
+
.ntd a{color:var(--vw-lnk,inherit)}
|
|
38
|
+
.ntf{flex:none;display:flex;align-items:center;gap:8px;padding:10px 0 4px;border-top:1px solid var(--hair)}
|
|
39
|
+
.ntw{flex:1;min-width:0;font-size:var(--fs-2);color:var(--ink-3)}
|
|
40
|
+
@media (hover:hover){.ntsw:hover,.ntmenu button:hover,.ntic:not(.pri):hover{background:var(--well)}}
|
|
41
|
+
@media (max-width:999px),(pointer:coarse){.ntic{width:44px;height:44px}.ntsw{min-height:44px}.ntmenu button{min-height:44px}.ntw{display:none}.ntf{justify-content:flex-end}}
|
|
@@ -2529,29 +2529,9 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
2529
2529
|
.stease{height:44px}
|
|
2530
2530
|
}
|
|
2531
2531
|
|
|
2532
|
-
/* the
|
|
2532
|
+
/* the note under the message box */
|
|
2533
2533
|
.askfoot{display:flex;align-items:flex-start;gap:10px}
|
|
2534
2534
|
.askfoot .fine2{flex:1;min-width:0}
|
|
2535
|
-
.padt{flex:none;display:inline-flex;align-items:center;gap:6px;margin-top:2px;padding:5px 12px;border-radius:var(--r-chip);background:var(--well);color:var(--ink-2);font-size:var(--fs-2);font-weight:600;white-space:nowrap;min-height:30px}
|
|
2536
|
-
.padt[hidden]{display:none}
|
|
2537
|
-
.padt.on{background:var(--solid);color:var(--on-solid)}
|
|
2538
|
-
.padt svg{width:14px;height:14px}
|
|
2539
|
-
.padt em{font-style:normal;font-weight:500;opacity:.75}
|
|
2540
|
-
.spad{flex:1 0 100%;box-sizing:border-box;border-radius:var(--r-in);background:var(--well);overflow:hidden;margin-bottom:2px}
|
|
2541
|
-
.spad[hidden]{display:none}
|
|
2542
|
-
.spad-grip{height:14px;display:grid;place-items:center;cursor:ns-resize;touch-action:none}
|
|
2543
|
-
.spad-grip i{width:36px;height:4px;border-radius:9px;background:var(--ink-3);opacity:.35}
|
|
2544
|
-
.spad-grip:focus-visible{outline:0;box-shadow:inset 0 0 0 2px var(--b3)}
|
|
2545
|
-
.spad-h{display:flex;align-items:baseline;justify-content:space-between;gap:8px;padding:0 16px}
|
|
2546
|
-
.spad-h b{font-size:var(--fs-3);font-weight:600}
|
|
2547
|
-
.spad-h span{font-size:var(--fs-2);color:var(--ink-3);text-align:right}
|
|
2548
|
-
.askbar .spad textarea{flex:none;height:auto;min-height:0;max-height:none;border-radius:0;overflow-y:auto;display:block;width:100%;box-sizing:border-box;border:0;background:transparent;padding:6px 16px 8px;font:inherit;font-size:var(--fs-3);line-height:1.5;color:var(--ink);resize:none;outline:0}
|
|
2549
|
-
.askbar .spad textarea:focus{box-shadow:none}
|
|
2550
|
-
.spad:focus-within{box-shadow:0 0 0 2px var(--b3)}
|
|
2551
|
-
.spad-f{display:flex;justify-content:flex-end;padding:0 10px 10px}
|
|
2552
|
-
.askbar .spad-f .cta{width:auto;height:34px;min-height:34px;padding:0 14px;border-radius:var(--r-chip);display:inline-flex;font-size:var(--fs-2);background:var(--card);color:var(--ink)}
|
|
2553
|
-
.askbar .spad-f .cta:disabled{opacity:.5;cursor:not-allowed}
|
|
2554
|
-
@media (max-width:700px){.spad-h span{display:none}.askbar .spad textarea{font-size:var(--fs-4)}.padt{min-height:44px}}
|
|
2555
2535
|
/* Item fields at dialog level (PM, 2026-10-20): Edit ▾ and Done sit in the Detail / Conversation row; Edit opens the fields as a sheet over the body,
|
|
2556
2536
|
closed by default, so the conversation keeps the whole body. On a wide dialog the switch is not drawn, so the row holds the bar alone. */
|
|
2557
2537
|
.dlg.itm:not(.srl-open) #dTabs{display:flex!important;align-items:center;gap:8px;position:relative}
|
|
@@ -2703,3 +2683,18 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
2703
2683
|
.vtab[hidden]{display:none}
|
|
2704
2684
|
@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
2685
|
.chatpg.vwlayer .dlg.on{border-radius:0}
|
|
2686
|
+
/* ── 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 ── */
|
|
2687
|
+
.ctxc{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
|
|
2688
|
+
.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}
|
|
2689
|
+
.ctxchip:hover{background:var(--card)}
|
|
2690
|
+
.ctxchip:focus-visible{outline:2px solid var(--ink);outline-offset:1px}
|
|
2691
|
+
.ctxchip.lead{background:var(--card-solid);box-shadow:var(--card-shadow)}
|
|
2692
|
+
.ctxchip .i{width:16px;height:16px;flex:none;color:var(--ink-2)}
|
|
2693
|
+
.ctxchip span{display:flex;flex-direction:column;min-width:0}
|
|
2694
|
+
.ctxchip b{font-weight:600;font-size:var(--fs-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:240px}
|
|
2695
|
+
.ctxchip em{font-style:normal;font-size:var(--fs-1);color:var(--ink-3)}
|
|
2696
|
+
.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}
|
|
2697
|
+
.ctxpeek[hidden]{display:none}
|
|
2698
|
+
.ctxpeek b{color:var(--ink);font-weight:600}
|
|
2699
|
+
.ctxpeek em{font-style:normal;font-weight:600;color:var(--ink)}
|
|
2700
|
+
.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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-chat-attach (N1-N7): Notes for a premium chat conversation, replacing the Scratchpad (the note store and the pure parts, and Notes in the viewer on the real page and server).",
|
|
3
|
+
"modules": [
|
|
4
|
+
"premium-chat-notes.test.js"
|
|
5
|
+
],
|
|
6
|
+
"panels": [
|
|
7
|
+
"premium-chat-notes-test.js"
|
|
8
|
+
],
|
|
9
|
+
"seconds": {
|
|
10
|
+
"premium-chat-notes.test.js": 1,
|
|
11
|
+
"premium-chat-notes-test.js": 30
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
/* premium-pad-test.js — the Scratchpad in the premium chat panel (initiative premium-chat-scratchpad).
|
|
4
|
-
* Serves the real My work page from the real server with a fixture model; the pad saves through the real /api/scratchpad in a scratch state folder.
|
|
5
|
-
* P1 the chip, pad closed · P2 open, type, saved for the row · P3 back after close and reload · P4 another row has its own pad
|
|
6
|
-
* P5 Add selection / Add to message fill the message box and send nothing · P6 no key, no pad · P7 the file name is a hash · P8 phone
|
|
7
|
-
*/
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const { spawn } = require('child_process');
|
|
11
|
-
const { findBrowser } = require('./lib/find-browser');
|
|
12
|
-
const T = require('./test-run').configure({ name: 'premium-pad' });
|
|
13
|
-
const WP = require('./lib/my-work-premium.js');
|
|
14
|
-
const F = require('./fixtures/my-work-premium-facts.js');
|
|
15
|
-
|
|
16
|
-
const BASE = T.BASE;
|
|
17
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
18
|
-
const until = async (fn, ms = 6000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); 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 !== '' ? ' — ' + extra : ''}`); };
|
|
21
|
-
let srv = null; let browser = null;
|
|
22
|
-
const finish = async (code) => {
|
|
23
|
-
if (browser) await browser.close().catch(() => {});
|
|
24
|
-
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
25
|
-
T.killTmux();
|
|
26
|
-
const bad = results.filter((x) => !x.cond).length;
|
|
27
|
-
console.log(`\n${results.length - bad}/${results.length} premium-pad assertions passed`);
|
|
28
|
-
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
29
|
-
};
|
|
30
|
-
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
31
|
-
const get = async (u) => (await fetch(BASE + u)).json();
|
|
32
|
-
const SHOTS = process.env.PAD_SHOTS || ''; // a folder: the suite also saves screenshots there for review
|
|
33
|
-
const shot = async (page, n) => { if (SHOTS) await page.screenshot({ path: path.join(SHOTS, n + '.png') }); };
|
|
34
|
-
const KEY = 'pad-test:row/../1', KEY2 = 'pad-test:row-2';
|
|
35
|
-
|
|
36
|
-
(async () => {
|
|
37
|
-
const exe = findBrowser();
|
|
38
|
-
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
39
|
-
let chromium;
|
|
40
|
-
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
41
|
-
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
42
|
-
await T.waitForServer(BASE);
|
|
43
|
-
browser = await chromium.launch({ executablePath: exe });
|
|
44
|
-
const model = WP.build({ v: F.view(), now: F.NOW });
|
|
45
|
-
|
|
46
|
-
const open = async ({ w = 1280, h = 900, ctx = null } = {}) => {
|
|
47
|
-
ctx = ctx || await browser.newContext({ viewport: { width: w, height: h } });
|
|
48
|
-
const page = await ctx.newPage();
|
|
49
|
-
const errors = [], asks = [];
|
|
50
|
-
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
|
|
51
|
-
await page.route('**/api/my-work-premium', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model, as_of: Date.now() }) }));
|
|
52
|
-
await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() !== 'GET') asks.push(new URL(rq.url()).pathname); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }); });
|
|
53
|
-
await page.goto(BASE + '/premium-work.html', { waitUntil: 'domcontentloaded' });
|
|
54
|
-
await page.waitForFunction(() => document.querySelector('#dBody') !== null);
|
|
55
|
-
return { page, ctx, errors, asks };
|
|
56
|
-
};
|
|
57
|
-
const dlg = (page, key) => page.evaluate(async (key) => { const m = await import('/pm/premium-shell.js'); m.openDlg({ eye: 'Test', title: 'Pad test', say: 'Hello.', noteKey: key, html: '<p>detail</p>' }); }, key);
|
|
58
|
-
const close = (page) => page.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.closeDlg(); });
|
|
59
|
-
|
|
60
|
-
/* P1 */
|
|
61
|
-
let { page, ctx, errors, asks } = await open();
|
|
62
|
-
await dlg(page, KEY);
|
|
63
|
-
ok('P1 the Scratchpad chip is under the message box', await page.isVisible('#sPadT'));
|
|
64
|
-
ok('P1 the pad starts closed', await page.isHidden('#sPad'));
|
|
65
|
-
/* P2 */
|
|
66
|
-
await page.click('#sPadT');
|
|
67
|
-
ok('P2 the chip opens the pad and the pad has focus', await page.isVisible('#sPad') && await page.evaluate(() => document.activeElement && document.activeElement.id === 'sPadTa'));
|
|
68
|
-
ok('P2 the pad sits above the message box', await page.evaluate(() => document.querySelector('#sPad').getBoundingClientRect().bottom <= document.querySelector('#askIn').getBoundingClientRect().top + 1));
|
|
69
|
-
ok('P2 Add to message is off while the pad is empty', await page.isDisabled('#sPadAdd'));
|
|
70
|
-
await page.fill('#sPadTa', 'first line\nsecond keep this\nthird line');
|
|
71
|
-
ok('P2 typing saves the pad for this row', !!(await until(async () => (await get('/api/scratchpad?key=' + encodeURIComponent(KEY))).text === 'first line\nsecond keep this\nthird line')));
|
|
72
|
-
/* P5 */
|
|
73
|
-
await page.evaluate(() => { const t = document.querySelector('#sPadTa'); const a = t.value.indexOf('keep this'); t.focus(); t.setSelectionRange(a, a + 'keep this'.length); t.dispatchEvent(new Event('select')); });
|
|
74
|
-
ok('P5 with a selection the button reads Add selection to message', (await page.textContent('#sPadAdd')).trim() === 'Add selection to message');
|
|
75
|
-
await shot(page, 'build-select-1280-light');
|
|
76
|
-
await page.click('#sPadAdd');
|
|
77
|
-
ok('P5 only the selection goes into the message box', (await page.inputValue('#askIn')) === 'keep this');
|
|
78
|
-
ok('P5 the message box has focus and nothing was sent', await page.evaluate(() => document.activeElement.id === 'askIn') && asks.length === 0, JSON.stringify(asks));
|
|
79
|
-
ok('P5 the pad keeps its text', (await page.inputValue('#sPadTa')).includes('keep this'));
|
|
80
|
-
await page.evaluate(() => { const t = document.querySelector('#sPadTa'); t.setSelectionRange(0, 0); t.dispatchEvent(new Event('select')); });
|
|
81
|
-
await page.click('#sPadAdd');
|
|
82
|
-
const multi = await page.evaluate(() => document.querySelector('#askIn').tagName === 'TEXTAREA');
|
|
83
|
-
const want = 'keep this\nfirst line\nsecond keep this\nthird line';
|
|
84
|
-
ok('P5 Add to message adds the whole pad after what is typed', (await page.inputValue('#askIn')) === (multi ? want : want.replace(/\n/g, ' ')), JSON.stringify(await page.inputValue('#askIn')));
|
|
85
|
-
ok('P5 still nothing sent', asks.length === 0);
|
|
86
|
-
/* P3 */
|
|
87
|
-
await page.fill('#sPadTa', 'saved on close');
|
|
88
|
-
await close(page);
|
|
89
|
-
ok('P3 closing the dialog saves an edit at once', !!(await until(async () => (await get('/api/scratchpad?key=' + encodeURIComponent(KEY))).text === 'saved on close', 2000)));
|
|
90
|
-
await page.click('body').catch(() => {});
|
|
91
|
-
/* P4 */
|
|
92
|
-
await dlg(page, KEY2);
|
|
93
|
-
ok('P4 another row has its own, empty pad', (await page.inputValue('#sPadTa')) === '' && await page.isVisible('#sPad'));
|
|
94
|
-
await close(page);
|
|
95
|
-
await page.reload({ waitUntil: 'domcontentloaded' }); await page.waitForFunction(() => document.querySelector('#dBody') !== null);
|
|
96
|
-
await dlg(page, KEY);
|
|
97
|
-
ok('P3 after a reload the row\'s pad text is back and the pad is open as left', !!(await until(async () => (await page.inputValue('#sPadTa')) === 'saved on close')) && await page.isVisible('#sPad'));
|
|
98
|
-
await page.click('#sPadT');
|
|
99
|
-
ok('P3 closed, the chip says how many lines the pad holds', /1 line/.test(await page.textContent('#sPadT')) && await page.isHidden('#sPad'));
|
|
100
|
-
await close(page);
|
|
101
|
-
/* P6 */
|
|
102
|
-
await dlg(page, null);
|
|
103
|
-
ok('P6 a dialog with no conversation has no pad', await page.isHidden('#sPadT') && await page.isHidden('#sPad'));
|
|
104
|
-
await close(page);
|
|
105
|
-
/* P7 */
|
|
106
|
-
const files = []; const walk = (d) => { for (const n of fs.readdirSync(d, { withFileTypes: true })) { const f = path.join(d, n.name); if (n.isDirectory()) walk(f); else files.push(path.relative(T.STATE_DIR, f)); } };
|
|
107
|
-
try { walk(path.join(T.STATE_DIR, 'scratchpad')); } catch { /* none */ }
|
|
108
|
-
ok('P7 a row pad is filed under a hashed name, never the key', files.length > 0 && files.every((f) => /^scratchpad\/[^/]+\/row-[0-9a-f]{32}\.txt$/.test(f)), files.join(', '));
|
|
109
|
-
const bad = await fetch(BASE + '/api/scratchpad?key=', { method: 'GET' }); ok('P7 an empty key is refused', bad.status === 400);
|
|
110
|
-
ok('P1-P7 no page errors', errors.length === 0, errors.join(' | '));
|
|
111
|
-
await ctx.close();
|
|
112
|
-
|
|
113
|
-
/* P8 phone */
|
|
114
|
-
({ page, ctx, errors } = await open({ w: 390, h: 844 }));
|
|
115
|
-
await dlg(page, KEY);
|
|
116
|
-
await until(async () => (await page.inputValue('#sPadTa')) === 'saved on close');
|
|
117
|
-
await page.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.setTab('chat'); });
|
|
118
|
-
if (await page.isHidden('#sPad')) await page.click('#sPadT');
|
|
119
|
-
await shot(page, 'build-open-390-light');
|
|
120
|
-
ok('P8 on a phone the pad and chip fit the width', await page.evaluate(() => { const w = innerWidth; return ['#sPad', '#sPadT', '#askIn'].every((s) => { const r = document.querySelector(s).getBoundingClientRect(); return r.width > 0 && r.left >= 0 && r.right <= w + 1; }); }));
|
|
121
|
-
ok('P8 the chip is a 44px target on a phone', await page.evaluate(() => document.querySelector('#sPadT').getBoundingClientRect().height >= 44));
|
|
122
|
-
ok('P8 no page errors', errors.length === 0, errors.join(' | '));
|
|
123
|
-
await ctx.close();
|
|
124
|
-
finish();
|
|
125
|
-
})();
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/* pm/premium-pad.js — the Scratchpad in the premium chat panel (initiative premium-chat-scratchpad).
|
|
2
|
-
* The console's per-session pad (c3-session-term.js makePad), kept per conversation: one pad for each row's key, because a row's session
|
|
3
|
-
* starts with its first message and can end and start again. Saved on this machine through /api/scratchpad?key=… as you type.
|
|
4
|
-
* "Add to message" puts the pad text, or the selected part of it, into the message box. Nothing is sent; the pad keeps its text. */
|
|
5
|
-
import { pmGet, pmPost } from './http.js';
|
|
6
|
-
|
|
7
|
-
const OPEN_KEY = 'pmos.premium.pad.open', H_KEY = 'pmos.premium.pad.h';
|
|
8
|
-
export const PAD_H = 132, PAD_MIN = 64, PAD_STEP = 18;
|
|
9
|
-
const PEN = '<svg class="i" viewBox="0 0 24 24"><path d="M4 20h4L19 9l-4-4L4 16v4z"/><path d="M14 6l4 4"/></svg>';
|
|
10
|
-
|
|
11
|
-
/** The lines the pad holds, for the closed chip ("Scratchpad · 3 lines"). Blank lines at the ends do not count. Pure. */
|
|
12
|
-
export function padLines(text) { const t = String(text || '').replace(/^\s+|\s+$/g, ''); return t ? t.split('\n').length : 0; }
|
|
13
|
-
/** The message box after Add to message: the added text goes after what is already typed, on a new line. Pure. */
|
|
14
|
-
export function addToMessage(cur, add) {
|
|
15
|
-
const a = String(add || '').replace(/^\n+|\s+$/g, ''); if (!a) return String(cur || '');
|
|
16
|
-
const c = String(cur || '').replace(/\s+$/, '');
|
|
17
|
-
return c ? c + '\n' + a : a;
|
|
18
|
-
}
|
|
19
|
-
/** The pad height in px, kept between the minimum and 60% of the room. Pure. */
|
|
20
|
-
export function clampPadH(h, room) { const n = Math.round(Number(h)); const max = Math.max(PAD_MIN, Math.round((Number(room) || 600) * 0.6)); return Number.isFinite(n) ? Math.min(max, Math.max(PAD_MIN, n)) : PAD_H; }
|
|
21
|
-
|
|
22
|
-
const store = { get: (k) => { try { return localStorage.getItem(k); } catch { return null; } }, set: (k, v) => { try { localStorage.setItem(k, v); } catch { /* not remembered */ } } };
|
|
23
|
-
export const padMarkup = () => `<div class="spad" id="sPad" hidden><div class="spad-grip" id="sPadGrip" role="separator" aria-orientation="horizontal" tabindex="0" aria-label="Resize the scratchpad" title="Drag to resize the scratchpad. Double-click for the default size."><i></i></div><div class="spad-h"><b>Scratchpad</b><span>This conversation · saved on this machine</span></div><textarea id="sPadTa" aria-label="Scratchpad" placeholder="Notes for this conversation. Claude does not see them until you add them to a message." maxlength="200000"></textarea><div class="spad-f"><button type="button" class="cta alt sm" id="sPadAdd" disabled title="Put the text in the message box. Nothing is sent.">Add to message</button></div></div>`;
|
|
24
|
-
export const padChipMarkup = () => `<button type="button" class="padt" id="sPadT" aria-expanded="false" aria-controls="sPad" hidden>${PEN}<span>Scratchpad</span><em id="sPadN"></em></button>`;
|
|
25
|
-
|
|
26
|
-
let cur = null; // the pad on show: { key, ws, ta, flush }
|
|
27
|
-
/** Flush the open pad's unsaved text at once (the dialog closes, the page hides). */
|
|
28
|
-
export function flushPad() { if (cur) cur.flush(); }
|
|
29
|
-
|
|
30
|
-
/** Wire the pad that padMarkup() and padChipMarkup() drew into the dialog for the row `key`. No key: no conversation, so no pad. */
|
|
31
|
-
export function mountPad({ key, ws, input }) {
|
|
32
|
-
flushPad(); cur = null;
|
|
33
|
-
const box = document.getElementById('sPad'), chip = document.getElementById('sPadT');
|
|
34
|
-
if (!box || !chip) return;
|
|
35
|
-
if (!key) { chip.hidden = true; box.hidden = true; return; }
|
|
36
|
-
const ta = document.getElementById('sPadTa'), add = document.getElementById('sPadAdd'), grip = document.getElementById('sPadGrip'), n = document.getElementById('sPadN');
|
|
37
|
-
const q = 'key=' + encodeURIComponent(key) + (ws ? '&ws=' + encodeURIComponent(ws) : '');
|
|
38
|
-
let typed = false, timer = null, pending = null;
|
|
39
|
-
const me = { key, ws, ta };
|
|
40
|
-
me.flush = () => {
|
|
41
|
-
if (timer) { clearTimeout(timer); timer = null; }
|
|
42
|
-
if (pending === null) return;
|
|
43
|
-
const text = pending; pending = null;
|
|
44
|
-
pmPost('/api/scratchpad', { key, ws: ws || undefined, text }).catch(() => { /* the text stays in the box */ });
|
|
45
|
-
};
|
|
46
|
-
cur = me;
|
|
47
|
-
const sel = () => (ta.selectionEnd > ta.selectionStart ? ta.value.slice(ta.selectionStart, ta.selectionEnd) : '');
|
|
48
|
-
const sync = () => {
|
|
49
|
-
const s = sel().trim();
|
|
50
|
-
add.disabled = !ta.value.trim();
|
|
51
|
-
add.textContent = s ? 'Add selection to message' : 'Add to message';
|
|
52
|
-
const k = padLines(ta.value);
|
|
53
|
-
n.textContent = box.hidden && k ? ` · ${k} ${k === 1 ? 'line' : 'lines'}` : '';
|
|
54
|
-
};
|
|
55
|
-
const setOpen = (on) => {
|
|
56
|
-
box.hidden = !on; chip.classList.toggle('on', on); chip.setAttribute('aria-expanded', String(on));
|
|
57
|
-
chip.title = on ? 'Hide the scratchpad. The text is kept.' : 'Show the scratchpad';
|
|
58
|
-
sync();
|
|
59
|
-
};
|
|
60
|
-
let h = Number(store.get(H_KEY)) || 0;
|
|
61
|
-
const room = () => (document.getElementById('dBody') || document.body).clientHeight;
|
|
62
|
-
const applyH = () => { // the height is the box's own rows, as the console pad does, so no inline style
|
|
63
|
-
ta.rows = Math.max(2, Math.round((h || PAD_H) / (parseFloat(getComputedStyle(ta).lineHeight) || 21))); grip.setAttribute('aria-valuenow', String(h || PAD_H)); };
|
|
64
|
-
const setH = (v) => { h = clampPadH(v, room()); applyH(); };
|
|
65
|
-
const saveH = () => store.set(H_KEY, h ? String(h) : '');
|
|
66
|
-
chip.hidden = false;
|
|
67
|
-
chip.onclick = () => { const on = box.hidden; store.set(OPEN_KEY, on ? 'open' : 'closed'); setOpen(on); if (on) ta.focus(); };
|
|
68
|
-
ta.oninput = () => { typed = true; pending = ta.value; if (timer) clearTimeout(timer); timer = setTimeout(me.flush, 500); sync(); };
|
|
69
|
-
ta.onselect = sync; ta.onkeyup = sync; ta.onmouseup = sync;
|
|
70
|
-
ta.onkeydown = (e) => { if (e.key === 'Enter') e.stopPropagation(); }; // Enter is a new line in the pad, never a send
|
|
71
|
-
add.onclick = () => {
|
|
72
|
-
const text = sel() || ta.value; if (!text.trim() || !input) return;
|
|
73
|
-
const v = addToMessage(input.value, text);
|
|
74
|
-
input.value = input.tagName === 'TEXTAREA' ? v : v.replace(/[ \t]*\n[ \t]*/g, ' '); // a one-line box would drop the line breaks and join the words
|
|
75
|
-
input.dispatchEvent(new Event('input', { bubbles: true })); // the message box grows and the / menu reads it, as if typed
|
|
76
|
-
input.focus();
|
|
77
|
-
try { input.setSelectionRange(input.value.length, input.value.length); } catch { /* a box without a caret */ }
|
|
78
|
-
const note = document.getElementById('askNote'); if (note) note.textContent = 'Added to your message. Press send when it reads right. The pad keeps its text.';
|
|
79
|
-
};
|
|
80
|
-
let y0 = null, h0 = 0;
|
|
81
|
-
grip.onpointerdown = (e) => { y0 = e.clientY; h0 = h || PAD_H; try { grip.setPointerCapture(e.pointerId); } catch { /* none */ } };
|
|
82
|
-
grip.onpointermove = (e) => { if (y0 != null) setH(h0 + (y0 - e.clientY)); };
|
|
83
|
-
grip.onpointerup = grip.onpointercancel = () => { if (y0 == null) return; y0 = null; saveH(); };
|
|
84
|
-
grip.ondblclick = () => { h = 0; applyH(); saveH(); };
|
|
85
|
-
grip.onkeydown = (e) => { if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return; e.preventDefault(); setH((h || PAD_H) + (e.key === 'ArrowUp' ? PAD_STEP : -PAD_STEP)); saveH(); };
|
|
86
|
-
ta.value = ''; applyH(); setOpen(store.get(OPEN_KEY) === 'open');
|
|
87
|
-
pmGet('/api/scratchpad?' + q).then((r) => { if (cur === me && !typed && r && typeof r.text === 'string') { ta.value = r.text; sync(); } }).catch(() => { /* an empty pad */ });
|
|
88
|
-
}
|
|
89
|
-
if (typeof addEventListener === 'function') addEventListener('pagehide', flushPad);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_comment": "Initiative premium-chat-scratchpad: the Scratchpad in the premium chat panel (pure parts, and the pad on the real page and server).",
|
|
3
|
-
"modules": [
|
|
4
|
-
"premium-pad.test.js"
|
|
5
|
-
],
|
|
6
|
-
"panels": [
|
|
7
|
-
"premium-pad-test.js"
|
|
8
|
-
],
|
|
9
|
-
"seconds": {
|
|
10
|
-
"premium-pad.test.js": 1,
|
|
11
|
-
"premium-pad-test.js": 40
|
|
12
|
-
}
|
|
13
|
-
}
|