create-pmos 0.410.0 → 0.412.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.
Files changed (131) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +2 -2
  7. package/workspace/briefing-premium-initiative-test.js +9 -15
  8. package/workspace/briefing-premium-insights-test.js +2 -2
  9. package/workspace/briefing-premium-test.js +3 -3
  10. package/workspace/changelog.json +24 -0
  11. package/workspace/chat-asks-test.js +146 -0
  12. package/workspace/guide/board.md +1 -1
  13. package/workspace/guide/breakdown.md +6 -13
  14. package/workspace/guide/briefing-premium.md +1 -1
  15. package/workspace/guide/home.md +24 -0
  16. package/workspace/guide/index.md +1 -1
  17. package/workspace/guide/initiative-driver.md +1 -1
  18. package/workspace/guide/initiatives-screen.md +1 -1
  19. package/workspace/guide/pm-only-acts.md +23 -24
  20. package/workspace/guide/today.md +1 -1
  21. package/workspace/home-rows-test.js +149 -56
  22. package/workspace/ini-workflow-test.js +4 -4
  23. package/workspace/lib/briefing-premium-agent.js +8 -1
  24. package/workspace/lib/briefing-premium-writes.js +5 -4
  25. package/workspace/lib/coredoc-cli.js +1 -1
  26. package/workspace/lib/driver-cli.js +2 -1
  27. package/workspace/lib/driver-decide.js +3 -2
  28. package/workspace/lib/driver.js +2 -1
  29. package/workspace/lib/engine/boards.js +3 -1
  30. package/workspace/lib/goal-chat.js +94 -30
  31. package/workspace/lib/grant-mint.js +3 -2
  32. package/workspace/lib/initiative-cli.js +9 -9
  33. package/workspace/lib/issues.js +5 -4
  34. package/workspace/lib/mention-cli.js +70 -0
  35. package/workspace/lib/mention-store.js +307 -0
  36. package/workspace/lib/people-store.js +1 -1
  37. package/workspace/lib/people.js +3 -1
  38. package/workspace/lib/placements.js +13 -15
  39. package/workspace/lib/plan-items.js +17 -48
  40. package/workspace/lib/pm-guard.js +18 -5
  41. package/workspace/lib/pm-lines-needs.js +9 -5
  42. package/workspace/lib/pmos-verbs.js +3 -0
  43. package/workspace/lib/report-cli.js +2 -2
  44. package/workspace/lib/routes-board-metric-targets.js +0 -1
  45. package/workspace/lib/routes-boards.js +12 -0
  46. package/workspace/lib/routes-briefing-premium.js +5 -7
  47. package/workspace/lib/routes-core-docs.js +0 -1
  48. package/workspace/lib/routes-custom-docs.js +0 -1
  49. package/workspace/lib/routes-driver.js +0 -1
  50. package/workspace/lib/routes-home-desk.js +1 -1
  51. package/workspace/lib/routes-home-review.js +1 -1
  52. package/workspace/lib/routes-initiative-layout.js +1 -1
  53. package/workspace/lib/routes-insights-records.js +0 -1
  54. package/workspace/lib/routes-meeting-material.js +0 -1
  55. package/workspace/lib/routes-mentions.js +62 -9
  56. package/workspace/lib/routes-onboarding.js +3 -1
  57. package/workspace/lib/routes-orchestrator.js +0 -1
  58. package/workspace/lib/routes-premium-charts.js +0 -1
  59. package/workspace/lib/routes-premium-dashboards.js +0 -1
  60. package/workspace/lib/routes-programs.js +1 -1
  61. package/workspace/lib/routes-records.js +1 -1
  62. package/workspace/lib/routes-report-design.js +7 -3
  63. package/workspace/lib/routes-report-setups.js +0 -1
  64. package/workspace/lib/routes-report-structure.js +0 -1
  65. package/workspace/lib/routes-runs.js +2 -5
  66. package/workspace/lib/routes-scan.js +0 -1
  67. package/workspace/lib/routes-sources.js +1 -1
  68. package/workspace/lib/run-answers.js +14 -5
  69. package/workspace/lib/scan-cli.js +2 -1
  70. package/workspace/lib/scan.js +2 -1
  71. package/workspace/lib/session-files.js +132 -0
  72. package/workspace/lib/session-name.js +103 -0
  73. package/workspace/lib/source-reads.js +4 -1
  74. package/workspace/lib/vendor/scripts/onboarding/proposals.js +7 -3
  75. package/workspace/package-lock.json +2 -2
  76. package/workspace/package.json +1 -1
  77. package/workspace/premium-board-actions-test.js +10 -8
  78. package/workspace/premium-chat-goal-setup-test.js +203 -0
  79. package/workspace/premium-chat-goal-view-test.js +28 -23
  80. package/workspace/premium-chat-line-test.js +189 -0
  81. package/workspace/premium-core-doc-issue-test.js +1 -1
  82. package/workspace/premium-viewer-share-test.js +5 -2
  83. package/workspace/premium-vw-backlog-test.js +1 -1
  84. package/workspace/premium-vw-item-test.js +1 -1
  85. package/workspace/premium-vw-jira-test.js +1 -1
  86. package/workspace/public/pm/chat-ask.js +17 -9
  87. package/workspace/public/pm/cozy-home-rows.css +39 -1
  88. package/workspace/public/pm/cozy-home.css +112 -12
  89. package/workspace/public/pm/cozy-search.js +2 -1
  90. package/workspace/public/pm/cozy-steps.css +69 -0
  91. package/workspace/public/pm/cozy-steps.js +90 -0
  92. package/workspace/public/pm/goal-chat.js +141 -23
  93. package/workspace/public/pm/home-app.js +68 -35
  94. package/workspace/public/pm/home-ask.js +121 -0
  95. package/workspace/public/pm/home-chat.js +120 -68
  96. package/workspace/public/pm/home-data.js +10 -2
  97. package/workspace/public/pm/home-goal.js +159 -0
  98. package/workspace/public/pm/home-ini.css +35 -0
  99. package/workspace/public/pm/home-ini.js +50 -19
  100. package/workspace/public/pm/home-line.css +59 -0
  101. package/workspace/public/pm/home-line.js +200 -0
  102. package/workspace/public/pm/home-list.js +2 -2
  103. package/workspace/public/pm/home-mentions.js +303 -111
  104. package/workspace/public/pm/home-ses-name.js +65 -0
  105. package/workspace/public/pm/home-stage-card.js +94 -0
  106. package/workspace/public/pm/home-sweep.js +112 -0
  107. package/workspace/public/pm/home-today.js +7 -2
  108. package/workspace/public/pm/premium-initiative-head.js +8 -4
  109. package/workspace/public/pm/rename-press.js +24 -0
  110. package/workspace/public/pm/wf-page.css +3 -0
  111. package/workspace/public/pm/wf-page.js +2 -1
  112. package/workspace/public/premium-workflows.html +1 -0
  113. package/workspace/replaced-tests.json +101 -0
  114. package/workspace/server.js +133 -20
  115. package/workspace/session-names-test.js +144 -0
  116. package/workspace/skills/jira-push.skill +1 -0
  117. package/workspace/skills/morning-brief.skill +2 -1
  118. package/workspace/skills/report-daily.skill +1 -0
  119. package/workspace/skills/report-monthly.skill +1 -0
  120. package/workspace/skills/report-weekly.skill +1 -0
  121. package/workspace/skills/sources-read.skill +3 -2
  122. package/workspace/stage-card-test.js +203 -0
  123. package/workspace/test-lists/chat-asks.json +13 -0
  124. package/workspace/test-lists/chat-progress.json +13 -0
  125. package/workspace/test-lists/mentions-a-plus.json +9 -0
  126. package/workspace/test-lists/premium-chat-goal-setup.json +9 -0
  127. package/workspace/test-lists/session-files.json +5 -0
  128. package/workspace/test-lists/session-names.json +13 -0
  129. package/workspace/test-lists/stage-card.json +6 -0
  130. package/workspace/tk-tasks-test.js +1 -1
  131. package/workspace/workflows-setup-test.js +17 -0
@@ -0,0 +1,121 @@
1
+ /* home-ask — every kind of ask as one card shape with icon answers (initiative premium-agreed-design; canvas XcbOptions "Every kind of ask").
2
+ * Pure: no DOM, so Node tests it. home-chat.js draws the card; the progress line (home-line.js) turns blue while openAsk() is true and a tap
3
+ * on it scrolls to the newest .hm-askw.
4
+ *
5
+ * 1 file a change to the PM's files (or a command): ✓ Allow · × No
6
+ * 2 send something leaves PMOS (Jira, Confluence, Slack, mail, calendar): ✓ Send · × No
7
+ * 3 choice a choice only the PM can make (Claude Code's AskUserQuestion): tap answers, the recommended one first (chat-ask.js)
8
+ * 4 judge a done point Claude cannot check itself: ✓ Yes, it's done · × Not yet
9
+ * 5 reach something Claude cannot reach: a key icon signs in, a paperclip attaches a file
10
+ *
11
+ * Kinds 1 and 2 come from the terminal's permission prompt (conv.ask) and the open call read as a change (conv.change,
12
+ * lib/transcript-steps.js). Kinds 4 and 5 come from a fenced `pmos-ask` JSON block at the end of Claude's message:
13
+ * {"kind":"judge","point":"Ready for Dita's review","question":"Is the draft ready for Dita?"}
14
+ * {"kind":"reach","what":"Jira","why":"sign-in expired","need":"signin"|"file"|"both"}
15
+ * Every answer is a labeled icon (aria-label and title), and the icon alone says the action. */
16
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
17
+
18
+ export const ICON = {
19
+ yes: 'M5 12.5l4.5 4.5L19 7',
20
+ no: 'M6 6l12 12M18 6 6 18',
21
+ key: 'M14.5 3.5a5 5 0 1 0 0 10 5 5 0 0 0 0-10M10.6 11.4 3.5 18.5v2h3v-2h2v-2h2l1.6-1.6',
22
+ clip: 'M20 11.5l-8.2 8.2a5 5 0 0 1-7-7L13 4.5a3.3 3.3 0 0 1 4.7 4.7L9.5 17.4a1.7 1.7 0 0 1-2.4-2.4L14.5 7.6',
23
+ again: 'M4 12a8 8 0 1 0 2.3-5.6M4 4v4.5h4.5',
24
+ to: 'M5 12h14M13 6l6 6-6 6',
25
+ dots: 'M5 12h.01M12 12h.01M19 12h.01',
26
+ };
27
+ const svg = (d, w = 2) => `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${w}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"></path></svg>`;
28
+ /** One answer as an icon button. a = { icon, label, attr, pri }. */
29
+ export const iconBtn = (a) => `<button type="button" class="hm-icb${a.pri ? ' pri' : ''}" ${a.attr} aria-label="${esc(a.label)}" title="${esc(a.label)}"${a.off ? ' disabled' : ''}>${svg(ICON[a.icon] || a.icon, a.icon === 'yes' ? 2.4 : 2)}</button>`;
30
+
31
+ // systems where a write leaves PMOS; a read from them still asks as a plain Allow
32
+ const OUTSIDE = /jira|confluence|atlassian|slack|gmail|mail|calendar|google|drive|notion|linear|asana|teams|figma|wispr/i;
33
+ const WRITE = /create|update|edit|add|send|post|transition|delete|comment|reply|forward|schedule|share|upload|move|invite|respond|label|draft/i;
34
+
35
+ /** The terminal's permission prompt as kind 1 or 2, or null when nothing asks. conv = /api/sessions/conversation. */
36
+ export function permissionAsk(conv) {
37
+ const c = conv || {};
38
+ if (c.state === 'ended' || !c.ask) return null;
39
+ const opts = Array.isArray(c.ask.options) ? c.ask.options : [];
40
+ if (!opts.length) return null;
41
+ const deny = opts.find((o) => /^no\b/i.test(o.label)) || opts[opts.length - 1];
42
+ const allow = opts[0];
43
+ const more = opts.filter((o) => o !== allow && o !== deny);
44
+ const ch = c.change || null;
45
+ const send = !!ch && OUTSIDE.test(ch.system || '') && WRITE.test(ch.tool || '');
46
+ const verb = ch && ch.tool && !/^mcp__/.test(ch.tool) ? ch.tool + ' ' : '';
47
+ return {
48
+ kind: send ? 'send' : 'file',
49
+ label: send ? 'Asks before it sends to ' + ch.system : 'Asks before it goes on',
50
+ title: ch ? (send ? ch.what : verb + ch.what) : c.ask.question,
51
+ from: ch ? ch.from || '' : '', to: ch ? ch.to || '' : '',
52
+ answers: [
53
+ { icon: 'yes', label: send ? 'Send' : 'Allow', attr: `data-hm-press="${esc(allow.n)}"`, pri: true },
54
+ { icon: 'no', label: 'No', attr: `data-hm-press="${esc(deny.n)}"` },
55
+ ],
56
+ more: more.map((o) => ({ label: o.label, attr: `data-hm-press="${esc(o.n)}"` })),
57
+ };
58
+ }
59
+
60
+ /** { text, block }: the words with the last `pmos-ask` block taken out, and that block parsed (null when there is none or it does not parse). */
61
+ export function splitAsk(text) {
62
+ const s = String(text == null ? '' : text);
63
+ const re = /```pmos-ask[^\n]*\n([\s\S]*?)```/g;
64
+ let m, last = null;
65
+ while ((m = re.exec(s))) last = m;
66
+ if (!last) return { text: s, block: null };
67
+ let block = null;
68
+ try { const o = JSON.parse(last[1]); if (o && typeof o === 'object' && (o.kind === 'judge' || o.kind === 'reach')) block = o; } catch { block = null; }
69
+ return { text: (s.slice(0, last.index) + s.slice(last.index + last[0].length)).trim(), block };
70
+ }
71
+
72
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
73
+ /** A `pmos-ask` block as kind 4 or 5, or null. The answers send a message, open Settings › Connectors, or open the file picker. */
74
+ export function blockAsk(b) {
75
+ if (!b || typeof b !== 'object') return null;
76
+ if (b.kind === 'judge') {
77
+ const point = clip(b.point, 200), q = clip(b.question, 200) || (point ? 'Is this done: ' + point + '?' : '');
78
+ if (!q) return null;
79
+ const of = point || q;
80
+ return { kind: 'judge', label: 'Only you can check this', title: q, from: '', to: '',
81
+ answers: [{ icon: 'yes', label: 'Yes, it’s done', attr: `data-chat-say="${esc('Yes, it’s done: ' + of)}"`, pri: true },
82
+ { icon: 'no', label: 'Not yet', attr: `data-chat-say="${esc('Not yet: ' + of)}"` }], more: [] };
83
+ }
84
+ if (b.kind === 'reach') {
85
+ const what = clip(b.what, 60), why = clip(b.why, 120);
86
+ if (!what && !why) return null;
87
+ const need = ['signin', 'file', 'both'].includes(b.need) ? b.need : 'both';
88
+ const answers = [];
89
+ if (need !== 'file') answers.push({ icon: 'key', label: 'Sign in to ' + (what || 'it'), attr: `data-hm-signin="${esc(what)}"`, pri: true });
90
+ if (need !== 'signin') answers.push({ icon: 'clip', label: 'Attach a file', attr: 'data-hm-file', pri: !answers.length });
91
+ return { kind: 'reach', label: 'Can’t reach it', title: [what, why].filter(Boolean).join(' · '), from: '', to: '', answers, more: [] };
92
+ }
93
+ return null;
94
+ }
95
+
96
+ /** The card: the kind's label, what it asks, the before → after where the change holds both, then the answers. live: false draws the
97
+ * answers off (an ask that was answered stays readable). more: the prompt's other choices behind a quiet ⋯ (kept from the earlier card). */
98
+ export function askCardHtml(a, { live = true, role = 'Claude' } = {}) {
99
+ if (!a) return '';
100
+ const ft = a.from || a.to ? `<p class="ft">${a.from ? `<s>${esc(a.from)}</s> → ` : ''}<b>${esc(a.to)}</b></p>` : '';
101
+ const more = live && a.more && a.more.length
102
+ ? `<span class="hm-mw"><button type="button" class="hm-icb hm-dots" data-hm-pmore aria-haspopup="menu" aria-label="More choices: ${esc(a.more.map((o) => o.label).join(', '))}" title="${esc(a.more.map((o) => o.label).join(' · '))}">${svg(ICON.dots, 2.6)}</button><span class="hm-pmenu" role="menu" hidden>${a.more.map((o) => `<button type="button" role="menuitem" ${o.attr}>${esc(o.label)}</button>`).join('')}</span></span>` : '';
103
+ return `<div class="hm-askw" role="group" aria-label="${esc(role)} asks before it goes on"><div class="hm-askk" data-ask-kind="${a.kind}"><p class="k">${esc(a.label)}</p><b class="q">${esc(a.title)}</b>${ft}`
104
+ + `<div class="acts">${a.answers.map((x) => iconBtn({ ...x, off: !live })).join('')}${more}</div></div></div>`;
105
+ }
106
+
107
+ /** True while something in the chat waits on the PM's answer: the permission prompt, a live question card or a live pmos-ask block.
108
+ * msgs: the conversation's messages; the newest assistant message's block counts only when the PM has not written after it. */
109
+ export function openAsk(conv) {
110
+ const c = conv || {};
111
+ if (c.state === 'ended') return false;
112
+ if (c.ask) return true;
113
+ const ms = Array.isArray(c.messages) ? c.messages : [];
114
+ for (let i = ms.length - 1; i >= 0; i--) {
115
+ const m = ms[i];
116
+ if (m.role === 'user') return false;
117
+ if (m.role === 'tool' && m.ask) return true;
118
+ if (m.role === 'assistant') return !!splitAsk(m.text).block;
119
+ }
120
+ return false;
121
+ }
@@ -2,10 +2,11 @@
2
2
  *
3
3
  * On a desktop a header line names what is open: its mark, its title and the chip of where it sits (HvACDesk; host.head(t) draws it).
4
4
  * Home's own chat has none. The stream: the role's avatar and name over each agent message with Copy, Retry and Make a work-item; the
5
- * PM's bubbles with "You · HH:MM"; "Worked …" folds (under the message that asks, while it asks); a Today divider; "New since you left"; "N earlier messages · show"; the agent's step
6
- * checklist while it works (from its own TodoWrite list); a permission card with the change before → after, Allow and Deny. Over the box: the
7
- * run strip with Stop, and "Also waiting on you". One box for every conversation (+, /, @ in an initiative, the In:/To: chip, the key hint,
8
- * ↑ send). The + menu holds Attach a file, the Notes and the terminal of the conversation, and Link to an initiative for a loose session.
5
+ * PM's bubbles with "You · HH:MM"; "Worked …" folds (under the message that asks, while it asks); a Today divider; "New since you left"; "N earlier messages · show";
6
+ * a permission card with the change before → after, Allow and Deny. At the top of the chat, the progress line (XcbOptions B, home-line.js): one
7
+ * line for the goal or the session while it works, with Stop; a tap opens its steps in place on a phone and in the Viewer on a desktop; blue while
8
+ * Claude asks. Where a goal finished, a quiet divider ("Goal done", or in amber why it stopped). Over the box: "Also waiting on you". One box for
9
+ * every conversation (+, the In:/To: chip, the key hint, ↑ send; typing / opens the commands). The + menu holds Attach a file, the Notes and the terminal of the conversation, and Link to an initiative for a loose session.
9
10
  * The mic is part of the input (canvas HmMic): press it and speak, the words appear as text in the box with a small blue dot while it
10
11
  * listens, press it again to stop, edit, send. On a phone it opens the "Speak to Claude" sheet (HmPhone): Discard, or stop and send.
11
12
  * Nothing is saved as audio (home-dictate.js). A card the target brings (intro.card, the decision card of HmDecide) draws under the intro.
@@ -19,11 +20,15 @@
19
20
  * host: { esc, toast, pmGet, pmPost, roles(), seen(key), markSeen(key), onScope(btn), onLink(btn), onTo(btn), workItem(text, target),
20
21
  * viewerClosed(), reopenViewer(), head(target) } */
21
22
  import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
22
- import { streamOf, runOf, roleOf, tintOf, hm } from './home-data.js';
23
- import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, goalChipHtml, goalViewHtml, goalNow, slashMatches, loadSlash } from './goal-chat.js';
23
+ import { streamOf, roleOf, tintOf, hm } from './home-data.js';
24
+ import { splitGoal, shownUser, goalBlockHtml, goalViewHtml, goalNow, slashMatches, loadSlash } from './goal-chat.js';
25
+ import { goalModel, sessionModel, lineHtml, viewHtml, dividerHtml, goalDivider } from './home-line.js';
26
+ import { goalUi } from './home-goal.js';
24
27
  import { splitReport, reportChipHtml, blockSig } from './report-chat.js';
25
28
  import { turnsOf } from './chat-context.js';
26
29
  import { askCardHtml, answerText } from './chat-ask.js';
30
+ import { permissionAsk, splitAsk, blockAsk, iconBtn, openAsk, askCardHtml as kindCardHtml } from './home-ask.js';
31
+ import { splitChase, runStop, sweepLine, stopText } from './home-sweep.js';
27
32
  import { splitFiles, filesHtml, sizeText, MAX_BYTES, MAX_FILES, setAttachSink } from './premium-attach.js';
28
33
  import * as VWC from './cozy-viewer.js';
29
34
  import { canDictate, dictate } from './home-dictate.js';
@@ -37,7 +42,6 @@ const SVG = (d, w = 16, sw = 2) => `<svg aria-hidden="true" width="${w}" height=
37
42
  const CHEV = 'M9 6l6 6-6 6', ARROW = 'M5 12h14M13 6l6 6-6 6', UP = 'M12 19V5M6 11l6-6 6 6', PLUS = 'M12 5v14M5 12h14', DOWN = 'M6 9l6 6 6-6';
38
43
  const MIC = 'M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3', SQ = 'M6 6h12v12H6z', XX = 'M6 6l12 12M18 6L6 18', OK = 'M5 12l5 5 9-10';
39
44
  const PANE = '<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><rect x="3" y="4" width="18" height="16" rx="3"></rect><path d="M14 4v16"></path></svg>';
40
- const DOTS = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><circle cx="5" cy="12" r="1.8"/><circle cx="12" cy="12" r="1.8"/><circle cx="19" cy="12" r="1.8"/></svg>';
41
45
  const INTERRUPT = /^\[Request interrupted by user/;
42
46
  const POLL = 2000, IDLE_POLL = 9000;
43
47
 
@@ -48,10 +52,12 @@ export function avHtml(role, size = 28, cls = '') {
48
52
 
49
53
  export function mountChat(el, host) {
50
54
  const esc = host.esc;
51
- const C = { t: null, th: null, conv: null, timer: null, show: 12, open: new Set(), seq: 0, sending: false, files: [], seenAt: null, lastKey: null, picked: {}, auto: { key: null, ctx: new Set(), rep: null, goal: null }, slashAt: 0 };
55
+ const C = { t: null, th: null, conv: null, timer: null, show: 12, plOpen: false, plAll: false, open: new Set(), seq: 0, sending: false, files: [], seenAt: null, lastKey: null, picked: {}, auto: { key: null, ctx: new Set(), rep: null, goal: null }, slashAt: 0 };
52
56
  el.innerHTML = `<button type="button" class="hm-reopen" id="hmReopen" aria-label="Open the Viewer" title="Open the Viewer" hidden>${PANE}</button>`
53
- + '<div class="hm-chd" id="hmCh" hidden></div><div class="hm-sug" id="hmSug" hidden></div><div class="hm-log" id="hmLog" role="log" aria-live="polite"></div><div class="hm-foot" id="hmFoot"></div>';
54
- const log = el.querySelector('#hmLog'), foot = el.querySelector('#hmFoot'), reopen = el.querySelector('#hmReopen'), head = el.querySelector('#hmCh'), sug = el.querySelector('#hmSug');
57
+ + '<div class="hm-chd" id="hmCh" hidden></div><div class="hm-sug" id="hmSug" hidden></div><div class="hm-plw" id="hmPl" hidden></div><div class="hm-log" id="hmLog" role="log" aria-live="polite"></div><div class="hm-foot" id="hmFoot"></div>';
58
+ const log = el.querySelector('#hmLog'), foot = el.querySelector('#hmFoot'), reopen = el.querySelector('#hmReopen'), head = el.querySelector('#hmCh'), sug = el.querySelector('#hmSug'), pl = el.querySelector('#hmPl');
59
+ const GU = goalUi({ C, host, el, draw: () => draw(), send: (t) => send(t), read: () => read(), openGoal: () => openGoal(), live: () => goalLive(), viewBody: () => document.querySelector('.obody.vw[data-vw="goal"]') });
60
+ GU.wire(el);
55
61
  loadSlash(host.pmGet).then(() => { if (el.querySelector('#hmSlash:not([hidden])')) drawSlash(); });
56
62
  // when a hidden log is shown (the phone's chat over the list), a jump still owed is made then
57
63
  // On a phone the chat is the page: the log grows and the page scrolls, so "the end" is the page's end (testing fixes: a chat opened at its oldest message)
@@ -105,10 +111,24 @@ export function mountChat(el, host) {
105
111
  }
106
112
  const last = i === R.lastAgent;
107
113
  const asking = last && R.asking; // the message that asks before a change: no tools while the ask is open, and the name on its own line (AgChatAsk)
108
- const g = splitGoal(it.text), rp = splitReport(g.text);
114
+ const g = splitGoal(it.text), rp0 = splitReport(g.text), ak = splitAsk(splitChase(rp0.text).text), rp = { ...rp0, text: ak.text };
109
115
  const goal = C.th && C.th.goal, gl = it.mi === R.lastMsg && R.waiting && !!goal && goal.state === 'grilling';
110
- return `<div class="hm-a${asking ? ' ask' : ''}">${avHtml(R.role)}<div class="hm-ab"><p class="hm-who">${esc(R.role.name)} <span>${esc(hm(it.at))}</span></p>${rp.text ? mdHtml(rp.text) : ''}${goalBlockHtml(g.block, { live: gl, state: goal && goal.state })}${reportChipHtml(rp.block, it.mi)}${R.chips(it.mi)}`
111
- + (asking ? '' : `<div class="hm-tools" role="group" aria-label="Message actions"><button type="button" data-hm-copy="${i}">Copy</button>${last && !running() ? `<button type="button" data-hm-retry>Retry</button>` : ''}<button type="button" data-hm-wi="${i}">Make a work-item</button></div>`) + '</div></div>';
116
+ const go = GU.blockOpts(it.mi, g.block, gl); // home-goal.js: the newest plan, the method menu, the editor in place
117
+ // a run that stopped: the divider sits where it finished, over Claude's last message, and the fix sits under it (canvas XcbOptions, Routine)
118
+ const stopAt = R.stop && i === R.lastAgent;
119
+ return (stopAt ? dividerHtml({ tone: R.stop.tone, text: R.stop.text }) : '') + `<div class="hm-a${asking ? ' ask' : ''}">${avHtml(R.role)}<div class="hm-ab"><p class="hm-who">${esc(R.role.name)} <span>${esc(hm(it.at))}</span></p>${rp.text ? mdHtml(rp.text) : ''}${goalBlockHtml(go.block, go)}${reportChipHtml(rp.block, it.mi)}${R.chips(it.mi)}`
120
+ + (asking ? '' : `<div class="hm-tools" role="group" aria-label="Message actions"><button type="button" data-hm-copy="${i}">Copy</button>${last && !running() && !(stopAt && R.stop.actions.length) ? `<button type="button" data-hm-retry>Retry</button>` : ''}<button type="button" data-hm-wi="${i}">Make a work-item</button></div>`) + '</div></div>'
121
+ + (stopAt && R.stop.actions.length ? `<div class="hm-fix" role="group" aria-label="What to do next">${R.stop.actions.map((a, k) => iconBtn({ icon: a.icon, label: a.label, attr: a.data, pri: k === 0 })).join('')}</div>` : '')
122
+ + blockAskHtml(ak.block, it, R);
123
+ }
124
+ /** A done point only the PM can judge, or something Claude cannot reach (a `pmos-ask` block): the same card as a permission ask, answerable
125
+ * until the PM writes again. A stopped run's reach is not drawn here: its divider holds the fix (say it once). */
126
+ function blockAskHtml(b, it, R) {
127
+ const a = blockAsk(b); if (!a) return '';
128
+ const msgs = (C.conv && C.conv.messages) || [];
129
+ const live = !!C.conv && C.conv.state !== 'ended' && !msgs.slice(it.mi + 1).some((x) => x.role === 'user');
130
+ if (a.kind === 'reach' && R.stop && R.stop.reach && it.mi === R.lastMsg) return '';
131
+ return kindCardHtml(a, { live, role: R.role.name });
112
132
  }
113
133
  function introHtml(o) {
114
134
  if (!o) return '';
@@ -122,44 +142,17 @@ export function mountChat(el, host) {
122
142
  const msgs = (C.conv && C.conv.messages) || [];
123
143
  const live = !!C.t.key && C.conv && C.conv.state !== 'ended' && !msgs.slice(it.mi + 1).some((x) => x.role === 'user');
124
144
  const at = askId(it.askMsg);
125
- return `<div class="hm-a hm-askc">${avHtml(R.role)}<div class="hm-ab"><div class="tc">${askCardHtml(it.ask, { live, picked: live ? (C.picked[at] || {}) : {}, at })}</div></div></div>`;
126
- }
127
- function liveHtml(R) {
128
- const run = runOf(C.conv, R.role);
129
- if (!run || !run.steps) return '';
130
- return `<div class="hm-live">${avHtml(R.role, 28, 'run')}<div class="hm-lb"><p class="hm-who">${esc(R.role.name)} <span>working${run.clock ? ' for ' + esc(run.clock) : ''} · ${esc(run.title)}</span></p>`
131
- + `<ol class="hm-steps">${run.steps.map((s) => { const call = s.call || (s.state === 'now' ? lastCall() : ''); return `<li class="${s.state}"><i aria-hidden="true"></i><span>${esc(s.text)}${s.sub ? `<small>${esc(s.sub)}</small>` : ''}${call ? `<code>${esc(call)}</code>` : ''}</span></li>`; }).join('')}</ol>`
132
- + `<button type="button" class="hm-watch" data-hm-term>Watch its terminal</button></div></div>`;
133
- }
134
- /** The newest tool call of the turn that runs now ("Read · planning/sprint.md"), for the step that is current when the session's step has none. */
135
- function lastCall() {
136
- const ms = (C.conv && C.conv.messages) || [];
137
- for (let i = ms.length - 1; i >= 0; i--) {
138
- if (ms[i].role === 'user') return '';
139
- const c = ms[i].role === 'tool' && (ms[i].calls || []).slice(-1)[0];
140
- if (c) return String(c.tool || '').split(/__|\//).pop() + (c.target ? ' ' + c.target : '');
141
- }
142
- return '';
145
+ return `<div class="hm-askc" role="group" aria-label="${esc(R.role.name)} asks"><div class="tc hm-askk" data-ask-kind="choice">${askCardHtml(it.ask, { live, picked: live ? (C.picked[at] || {}) : {}, at })}</div></div>`;
143
146
  }
147
+ /** The terminal's permission prompt: a change to the PM's files (Allow · No) or something that leaves PMOS (Send · No), icons only (home-ask.js). */
144
148
  function askHtml(R) {
145
- const c = C.conv; if (!c || c.state === 'ended' || !c.ask) return '';
146
- const opts = c.ask.options || [];
147
- const deny = opts.find((o) => /^no\b/i.test(o.label)) || opts[opts.length - 1];
148
- const allow = opts[0];
149
- const more = opts.filter((o) => o !== allow && o !== deny);
150
- const ch = c.change;
151
- const body = ch ? `<span class="hm-chg"><span class="k">Change in ${esc(ch.system)}</span><b>${esc(ch.what)}</b>${ch.from || ch.to ? `<span class="ft">${ch.from ? `<s>${esc(ch.from)}</s>${SVG('M5 12h14M13 6l6 6-6 6', 14)}` : ''}<b>${esc(ch.to)}</b></span>` : ''}</span>`
152
- : `<span class="hm-chg"><span class="k">Asks before it goes on</span><b>${esc(c.ask.question)}</b></span>`;
153
- // part of the agent's last message: no avatar of its own, in line with the message text (AgChatAsk)
154
- return `<div class="hm-askw" role="group" aria-label="${esc(R.role.name)} asks before it goes on"><div class="hm-ab"><div class="hm-perm">${body}`
155
- + `<span class="hm-pa"><button type="button" class="pri" data-hm-press="${esc(allow.n)}">Allow</button><button type="button" data-hm-press="${esc(deny.n)}">Deny</button><span class="sp"></span>`
156
- + (more.length ? `<span class="hm-mw"><button type="button" class="hm-dots" data-hm-pmore aria-haspopup="menu" aria-label="More choices: ${esc(more.map((o) => o.label).join(', '))}" title="${esc(more.map((o) => o.label).join(' · '))}">${DOTS}</button><span class="hm-pmenu" role="menu" hidden>${more.map((o) => `<button type="button" role="menuitem" data-hm-press="${esc(o.n)}">${esc(o.label)}</button>`).join('')}</span></span>` : '')
157
- + '</span></div></div></div>';
149
+ const a = permissionAsk(C.conv);
150
+ return a ? kindCardHtml(a, { role: R.role.name }) : '';
158
151
  }
159
152
  function queuedHtml() {
160
153
  const q = host.queued ? host.queued(sid()) : [];
161
154
  const said = new Set(((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user').map((m) => String(m.text || '').trim()));
162
- return q.filter((x) => !said.has(String(x.text).trim())).map((x) => `<div class="hm-q"><div class="hm-qb">${userHtml(x.text)}</div><span class="hm-qn">Queued · ${esc(role().name)} reads it after this step<button type="button" data-hm-qdel="${esc(x.at)}">Delete</button></span></div>`).join('');
155
+ return q.filter((x) => !said.has(String(x.text).trim())).map((x) => `<div class="hm-q"><div class="hm-qb">${userHtml(x.text)}</div><span class="hm-qn">${esc(role().name)} reads it after this tool call, in seconds<button type="button" class="hm-qx" data-hm-qdel="${esc(x.at)}" aria-label="Take it back" title="Take it back">${SVG(XX, 13)}</button></span></div>`).join('');
163
156
  }
164
157
  const sid = () => (C.t && C.t.sid) || (C.th && C.th.session) || null;
165
158
  // A loose chat that reads like one initiative gets one quiet chip at its top: "Looks like <initiative> · Link it ×" (XvALinkSuggest).
@@ -180,22 +173,28 @@ export function mountChat(el, host) {
180
173
  const la = R.lastAgent;
181
174
  if (R.asking && la > 0 && items[la - 1].t === 'worked' && !items[la - 1].ask) { const w = items[la - 1]; items[la - 1] = items[la]; items[la] = w; R.lastAgent = la - 1; }
182
175
  R.lastMsg = msgs.length - 1;
176
+ R.stop = C.conv ? runStop(C.conv, { routine: !!(C.t && C.t.routine) }) : null;
183
177
  R.waiting = !!C.conv && !C.conv.ask && C.conv.turn !== 'agent' && C.conv.turn !== 'tool';
184
178
  const ctx = new Map(turnsOf(msgs, R.waiting || (C.conv && C.conv.state === 'ended')).filter((x) => x.done).map((x) => [x.at, x.items]));
185
179
  R.chips = (mi) => (ctx.get(mi) ? chipsOf(ctx.get(mi)) : '');
186
180
  const se = document.scrollingElement || document.documentElement;
187
181
  const atEnd = pageScrolls() ? se.scrollHeight - se.scrollTop - innerHeight < 80 : log.scrollHeight - log.scrollTop - log.clientHeight < 80;
188
182
  const goal = C.th && C.th.goal;
189
- let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro) : '') + items.map((it, i) => msgHtml(it, i, R)).join('') + (goalProgressHtml(goal) ? goalChipHtml(goal) : '') + liveHtml(R) + askHtml(R) + queuedHtml();
183
+ const parts = items.map((it, i) => msgHtml(it, i, R));
184
+ placeDivider(parts, items, goal);
185
+ let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro) : '') + parts.join('') + askHtml(R) + (R.stop && R.lastAgent < 0 ? dividerHtml(R.stop) : '') + queuedHtml();
186
+ html += GU.choiceHtml(); // /goal while a goal works here: In a new chat, or Here instead
190
187
  if (C.th && C.th.working) html += `<p class="hm-note" role="status">The agent is answering. You can write again when it has.</p>`;
191
188
  if (C.conv && C.conv.state === 'ended') html += '<p class="hm-note">This session has ended. Your conversation is kept here, and your next message picks it up.</p>';
192
189
  if (!html) html = `<p class="hm-empty">${esc(t.empty || 'Ask anything. It works in a real Claude Code session.')}</p>`;
193
190
  put(log, html);
194
191
  C.items = items;
192
+ GU.afterDraw(log);
195
193
  // a session opens at its latest message: the jump waits until the conversation is read and the log is shown (on a phone the chat
196
194
  // can be drawn while hidden, where scrollTop does nothing and the session then opened at the top)
197
195
  if (atEnd || C.jump) { toEnd(); if (C.conv && log.clientHeight) C.jump = false; }
198
196
  drawFoot(R);
197
+ drawLine(R);
199
198
  reopen.hidden = !host.viewerClosed();
200
199
  // the header line over the conversation on a desktop (HvACDesk): what is open and where it sits; Home's own chat has none
201
200
  const hh = host.head ? host.head(t) : '';
@@ -204,8 +203,63 @@ export function mountChat(el, host) {
204
203
  const lastAt = msgs.length ? msgs[msgs.length - 1].at : null;
205
204
  if (t.key && lastAt && (!C.marked || C.marked < lastAt)) { C.marked = lastAt; host.markSeen(t.key); }
206
205
  autoOpen(R);
207
- const gp = document.querySelector('.obody.vw[data-vw="goal"]'); // an open Goal view follows every change
208
- if (gp) { const h = goalViewHtml(C.th && C.th.goal, readyDraft(C.conv), { live: goalLive() }); if (h && gp.__h !== h) { gp.__h = h; gp.innerHTML = h; } }
206
+ const gp = document.querySelector('.obody.vw[data-vw="goal"]'); // an open Goal view (or the steps) follows every change
207
+ if (gp) { const h = goalViewNow(); if (h && gp.__h !== h) { gp.__h = h; gp.innerHTML = h; GU.fill(gp); } }
208
+ }
209
+ /* A goal that finished leaves a divider where it finished: "Goal done" over Claude's result, or in amber, why it stopped, after it. */
210
+ function placeDivider(parts, items, goal) {
211
+ const d = goalDivider(goal); if (!d) return;
212
+ const at = Date.parse((goal && goal.at) || '');
213
+ let k = -1;
214
+ items.forEach((it, i) => { if (it.at && Number.isFinite(at) && Date.parse(it.at) <= at && (goal.state !== 'done' || it.t === 'agent')) k = i; });
215
+ if (k < 0) { parts.push(dividerHtml(d)); return; }
216
+ if (goal.state === 'done') parts[k] = dividerHtml(d) + parts[k]; else parts[k] += dividerHtml(d);
217
+ }
218
+ /* ── the progress line (XcbOptions B) ── */
219
+ // a card that waits on the PM: the permission prompt, a question Claude asked that is still open (answerable only in a chat with a key),
220
+ // or a point only the PM can judge or something Claude cannot reach (a pmos-ask block, home-ask.js)
221
+ function askLive() {
222
+ const c = C.conv; if (!openAsk(c)) return false;
223
+ if (c.ask) return true;
224
+ const ms = c.messages || [];
225
+ for (let i = ms.length - 1; i >= 0; i--) { if (ms[i].role === 'tool' && ms[i].ask) return !!C.t.key; if (ms[i].role === 'assistant') return true; }
226
+ return false;
227
+ }
228
+ const vwShows = () => !!(window.czViewer && window.czViewer.isOpen() && (window.czViewer.current() || {}).id === 'vw:goal');
229
+ function lineModel(o = {}) {
230
+ const t = C.t; if (!t) return null;
231
+ const live = !!sid() && !!C.conv && C.conv.state !== 'ended';
232
+ const opt = { now: Date.now(), asking: askLive(), open: C.plOpen, all: C.plAll || !!o.view, on: host.desk() && vwShows(), term: live && !!host.openTerminal, title: t.title };
233
+ if (typeof t.line === 'function') { const m = t.line(C.conv, opt); if (m) return m; }
234
+ return sweepLine(C.conv, opt) || goalModel(C.th && C.th.goal, C.conv, opt) || sessionModel(C.conv, opt); // a chase first: it waits on people (home-sweep.js)
235
+ }
236
+ function drawLine() {
237
+ const m = lineModel();
238
+ if (!m) { C.plOpen = false; C.plAll = false; } // the run ended: the line goes, and folds itself for the next run
239
+ const h = m ? lineHtml({ ...m, open: m.open && !host.desk() }) : '';
240
+ put(pl, h); pl.hidden = !h;
241
+ }
242
+ /** The Goal view in the Viewer: the steps of a goal or session at work, else the goal's plan or how it ended. */
243
+ function goalViewNow() {
244
+ const vo = GU.viewOpts(); // the plan editor, while the PM changes a working goal in the Viewer (home-goal.js)
245
+ if (vo.edit) return goalViewHtml(C.th && C.th.goal, readyDraft(C.conv), vo);
246
+ const m = lineModel({ view: true }), g = C.th && C.th.goal;
247
+ if (m && m.kind === 'goal' && g && (g.state === 'started' || g.state === 'waiting')) m.change = true;
248
+ return m ? viewHtml(m) : goalViewHtml(g, readyDraft(C.conv), vo);
249
+ }
250
+ function plPress(k) {
251
+ const goal = C.th && C.th.goal;
252
+ const say = k === 'stop' ? stopText(lineModel()) : ''; // Stop chasing tells Claude to stop, it is not Esc
253
+ if (say) { send(say); return; }
254
+ if (k === 'stop') { if (goal && ['started', 'waiting'].includes(goal.state) && C.t.key) { goalPress({ dataset: { goal: 'stop' } }); } else press('esc'); return; }
255
+ if (k === 'term') { host.openTerminal(sid()); return; }
256
+ if (k === 'all') { C.plAll = true; drawLine(); return; }
257
+ if (k === 'toggle') {
258
+ const m = lineModel();
259
+ if (m && m.tone === 'you') { const a = [...log.querySelectorAll('.hm-askw, .hm-askc, .hm-a.ask')].pop(); if (a) a.scrollIntoView({ block: 'center', behavior: 'smooth' }); return; }
260
+ if (host.desk()) { if (vwShows()) window.czViewer.close(); else openGoal(); return; }
261
+ C.plOpen = !C.plOpen; drawLine();
262
+ }
209
263
  }
210
264
  /* What an answer worked with opens by itself, once, when the answer finishes while the chat is open: on a desktop in the Viewer, on a phone
211
265
  * as a bar over the box. What was already there when the chat opened opens nothing. Reports, charts and dashboards and a /goal do the same. */
@@ -214,7 +268,8 @@ export function mountChat(el, host) {
214
268
  const first = C.auto.key !== key;
215
269
  const done = turnsOf(conv.messages, R.waiting || conv.state === 'ended').filter((x) => x.done);
216
270
  const rep = R.waiting || conv.state === 'ended' ? newestReport(conv) : undefined;
217
- const now = goalNow(C.th && C.th.goal, readyDraft(conv));
271
+ // the plan of a goal still being grilled opens by itself; once it works, the progress line stands for it
272
+ const g0 = C.th && C.th.goal, now = !g0 || g0.state === 'grilling' ? goalNow(g0, readyDraft(conv)) : null;
218
273
  if (first) { C.auto = { key, ctx: new Set(done.map((x) => x.id)), rep: rep === undefined ? null : blockSig(rep), goal: now ? now.sig : null }; peek(null); return; }
219
274
  for (const d of done) {
220
275
  if (C.auto.ctx.has(d.id)) continue;
@@ -245,19 +300,15 @@ export function mountChat(el, host) {
245
300
  for (let i = ms.length - 1; i >= 0; i--) { if (ms[i].role !== 'assistant') continue; const b = splitReport(splitGoal(ms[i].text).text).block; if (b) return b; }
246
301
  return null;
247
302
  }
248
- function readyDraft(conv) {
249
- const ms = (conv && conv.messages) || [];
250
- for (let i = ms.length - 1; i >= 0; i--) { if (ms[i].role !== 'assistant') continue; const b = splitGoal(ms[i].text).block; if (b && b.step === 'ready') return b.draft || null; }
251
- return null;
252
- }
303
+ const readyDraft = () => GU.readyDraft(); // Claude's newest plan, or the PM's newer edit of it (home-goal.js)
253
304
  const goalLive = () => !!(C.th && C.th.goal) && C.th.goal.state === 'grilling' && !!C.conv && !C.conv.ask && C.conv.turn !== 'agent' && C.conv.turn !== 'tool';
254
305
  function openGoal() {
255
- const html = goalViewHtml(C.th && C.th.goal, readyDraft(C.conv), { live: goalLive() }); if (!html) return null;
256
- return import('./premium-viewer.js').then((V) => { V.vwStyle('doc'); return V.vwOpen({ id: 'goal', title: 'Goal', icon: 'goal', render: (p) => { p.innerHTML = p.__h = goalViewHtml(C.th && C.th.goal, readyDraft(C.conv), { live: goalLive() }); p.onclick = (e) => { const g = e.target.closest('[data-goal]'); if (g) goalPress(g); }; } }); });
306
+ const html = goalViewNow(); if (!html) return null;
307
+ const m = lineModel({ view: true });
308
+ return import('./premium-viewer.js').then((V) => { V.vwStyle('doc'); return V.vwOpen({ id: 'goal', title: m && m.kind !== 'goal' ? 'Steps' : 'Goal', icon: 'goal', render: (p) => { p.innerHTML = p.__h = goalViewNow(); GU.fill(p); GU.wire(p); p.onclick = async (e) => { const b = e.target.closest('[data-pl]'); if (b) { plPress(b.dataset.pl); return; } const gb = e.target.closest('button'); if (gb && await GU.press(gb)) return; const g = e.target.closest('[data-goal]'); if (g) goalPress(g); }; } }); }).then((r) => { drawLine(); return r; });
257
309
  }
258
310
  async function goalPress(gb) {
259
311
  const act = gb.dataset.goal;
260
- if (act === 'change') { const ta = foot.querySelector('textarea'); ta.placeholder = 'Tell Claude what to change'; ta.focus(); return; }
261
312
  const goal = C.th && C.th.goal; if (!goal || !C.t.key) return;
262
313
  gb.disabled = true;
263
314
  const r = await host.pmPost('/api/briefing-premium/goal' + (C.t.ws ? '?ws=' + encodeURIComponent(C.t.ws) : ''), { key: C.t.key, id: goal.id, act, draft: readyDraft(C.conv) }).catch(() => null);
@@ -271,16 +322,16 @@ export function mountChat(el, host) {
271
322
  views.ctx().then((M) => { chipsHtmlFn = M.chipsHtml; if (C.t) draw(); }).catch(() => {});
272
323
  const chipsOf = (items) => (chipsHtmlFn ? chipsHtmlFn(items) : '');
273
324
  function drawFoot(R) {
274
- const t = C.t, run = runOf(C.conv, R.role), busy = running();
275
- const strip = run ? `<div class="hm-run" role="status">${avHtml(R.role, 28, 'run')}<span class="hm-rt"><b>${esc(run.title)}</b><span>${esc(run.sub)}</span></span><progress class="hm-bar" aria-hidden="true" max="100" value="${Math.round(run.frac * 100)}"></progress><button type="button" class="hm-stop" data-hm-press="esc" title="Stop (Esc)"><i aria-hidden="true"></i>Stop</button></div>` : '';
325
+ const t = C.t, goal = C.th && C.th.goal;
276
326
  const also = t.also && !(C.conv && C.conv.ask) ? `<button type="button" class="hm-also" data-hm-also><i aria-hidden="true"></i><span><b>Also waiting on you:</b> ${esc(t.also.text)}</span><em>Answer</em></button>` : '';
277
- const ph = busy ? 'Steer ' + R.role.name + '…' : C.conv && C.conv.ask ? 'Or tell ' + R.role.name + ' what to do instead' : t.placeholder || 'Message Claude';
327
+ // while it works the PM talks as usual (Claude reads it after its tool call); a goal that stopped says how to go on (principle 8)
328
+ const ph = C.conv && C.conv.ask ? 'Or tell ' + R.role.name + ' what to do instead' : goal && goal.state === 'stopped' && !running() ? 'Reply to go on, or /goal for a new goal' : t.placeholder || 'Message Claude';
278
329
  const sc = t.scope || { text: 'All work', icon: 'M5 21V4M5 4h12l-2 4 2 4H5' };
279
330
  const keep = foot.querySelector('textarea'); const val = keep ? keep.value : '';
280
331
  // the session's terminal: watch it read only while the session runs; copy the line that resumes an ended chat
281
332
  const live = sid() && C.conv && C.conv.state !== 'ended';
282
333
  // the + is the box's one quiet entry: Attach a file (the Agreed design's +), then the conversation's Notes and its terminal.
283
- // The toolbar stays "+ / @ chip" as the mockup has it.
334
+ // No / and no @ button (XcbOptions B): typing / opens the commands, and the To: chip is the one control for who reads it.
284
335
  const term = live ? `<button type="button" role="menuitem" id="hmTerm" data-hm-term aria-label="Watch its terminal"><b>Watch its terminal</b><em>Read only, while it works</em></button>`
285
336
  : C.th && C.th.resume ? `<button type="button" role="menuitem" id="hmTerm" data-hm-copyterm aria-label="Copy the terminal command"><b>Copy the terminal command</b><em>Picks this chat up in Terminal</em></button>` : '';
286
337
  const notesBtn = t.key ? `<button type="button" role="menuitem" id="hmNotes" data-hm-notes aria-label="Notes for this conversation"><b>Notes</b><em>Your notepad for this conversation</em></button>` : '';
@@ -298,10 +349,8 @@ export function mountChat(el, host) {
298
349
  const wait = C.conv && C.conv.ask && t.also ? `<button type="button" class="hm-chip" data-hm-also><i class="dot" aria-hidden="true"></i><span>1 more next step</span></button>` : '';
299
350
  const to = t.to && !wait ? `<button type="button" class="hm-chip to" data-hm-to aria-label="Who reads this: ${esc(t.to.name)}. Change">${avHtml(t.to, 20)}<span>To: ${esc(t.to.name)}</span></button>` : '';
300
351
  const scope = !to && !wait ? `<button type="button" class="hm-chip${sc.loose ? ' loose' : ''}" data-hm-scope aria-label="Where this goes: ${esc(sc.text)}. Change" title="Where this goes: ${esc(sc.text)}">${SVG(sc.icon, 14)}<span>In: ${esc(sc.text)}</span></button>` : '';
301
- const at = t.ini ? '<button type="button" class="hm-tool" data-hm-at aria-label="Choose which conversation reads this" title="Send to another session of this initiative"><b>@</b></button>' : '';
302
- const html = `${also}${strip}<form class="hm-box${on ? ' ut-on' : ''}" id="hmForm">${dot}<textarea id="hmIn" rows="1" aria-label="A message for ${esc(R.role.name)}" placeholder="${esc(ph)}"></textarea>`
352
+ const html = `${also}<form class="hm-box${on ? ' ut-on' : ''}" id="hmForm">${dot}<textarea id="hmIn" rows="1" aria-label="A message for ${esc(R.role.name)}" placeholder="${esc(ph)}"></textarea>`
303
353
  + `<div class="hm-tb">${add}`
304
- + `<button type="button" class="hm-tool" data-hm-slash aria-label="Commands" title="Commands"><b>/</b></button>${at}`
305
354
  + to + wait + scope + `<span class="sp"></span>${host.viewerClosed() ? '<span class="hm-key">Enter sends · Shift+Enter for a new line</span>' : ''}`
306
355
  + `${mic}<button type="submit" class="hm-send" aria-label="Send" title="Send">${SVG(UP, 18)}</button></div>`
307
356
  + filesRow()
@@ -380,12 +429,14 @@ export function mountChat(el, host) {
380
429
  if (d.utSpeak) { speakPress(d.utSpeak); return; }
381
430
  if ('hmAdd' in d) { C.addOpen = !C.addOpen; drawFoot({ role: role() }); const f = C.addOpen && foot.querySelector('.hm-addm [role=menuitem]'); if (f) f.focus(); return; }
382
431
  if (C.addOpen && b.closest('.hm-addm')) { C.addOpen = false; drawFoot({ role: role() }); } // a press in the + menu closes it, then does its part
432
+ if ('hmSignin' in d) { import('./cozy-settings.js').then((S) => S.openSettings('connectors')); return; } // a reach ask: Sign in to Jira opens Settings › Connectors
383
433
  if ('hmFile' in d) { const i = foot.querySelector('#hmFile'); if (i) i.click(); return; }
384
434
  if (d.reportOpen != null && d.reportOpen !== '') { e.preventDefault(); const m = ((C.conv && C.conv.messages) || [])[+d.reportOpen]; const bl = m ? splitReport(splitGoal(m.text).text).block : null; if (bl) views.block(bl); return; }
385
435
  if (d.ctx != null) { e.preventDefault(); views.ctx().then((M) => M.openCtx(M.itemOf(b), where())); return; }
386
436
  if (d.file) { e.preventDefault(); views.file().then((M) => M.openChatFile(d.file, where())); return; }
387
437
  if (d.att) { e.preventDefault(); if (/\/notes\/n[0-9a-z]{6,16}\.md$/.test(d.att)) openNotesHere(d.att.split('/').pop().replace(/\.md$/, '')); else views.attach().then((M) => M.openAttachment(d.att)); return; }
388
438
  if ('goalOpen' in d) { e.preventDefault(); openGoal(); return; }
439
+ if (await GU.press(b)) return; // home-goal.js: the method menu, the plan editor, skip and Undo, the /goal choice
389
440
  if (d.goal) { goalPress(b); return; }
390
441
  if (d.chatSay) { b.disabled = true; send(d.chatSay); return; }
391
442
  if (d.slash) { pickSlash(d.slash); return; }
@@ -398,6 +449,7 @@ export function mountChat(el, host) {
398
449
  return;
399
450
  }
400
451
  if (d.askSend != null && d.askSend !== '') { const ask = askOf(d.askSend), text = ask && answerText(ask, C.picked[d.askSend]); if (!text) return; b.disabled = true; if (await send(text)) delete C.picked[d.askSend]; return; }
452
+ if (d.pl && b.closest('#hmPl')) { plPress(d.pl); return; }
401
453
  if ('hmFold' in d) { C.show = Infinity; draw(); return; }
402
454
  if (d.hmWk) { if (C.open.has(d.hmWk)) C.open.delete(d.hmWk); else C.open.add(d.hmWk); draw(); return; }
403
455
  if (d.hmCopy) { const it = C.items[+d.hmCopy]; try { await navigator.clipboard.writeText(it.text); host.toast('Copied.'); } catch { host.toast('The copy did not work in this browser.'); } return; }
@@ -413,8 +465,7 @@ export function mountChat(el, host) {
413
465
  if ('hmNotes' in d) { openNotesHere(); return; }
414
466
  if ('hmScope' in d) { host.onScope(b); return; }
415
467
  if ('hmLink' in d) { host.onLink(foot.querySelector('#hmAdd') || b, C.t); return; } // the + menu has closed: the list opens from the +
416
- if ('hmTo' in d || 'hmAt' in d) { host.onTo(b, C.t); return; }
417
- if ('hmSlash' in d) { const ta = foot.querySelector('textarea'); if (!ta.value.startsWith('/')) ta.value = '/' + ta.value; ta.focus(); drawSlash(); return; }
468
+ if ('hmTo' in d) { host.onTo(b, C.t); return; }
418
469
  if (d.hmUnfile) {
419
470
  const f = C.files[+d.hmUnfile]; if (!f) return;
420
471
  C.files = C.files.filter((x) => x !== f); if (f.url) URL.revokeObjectURL(f.url);
@@ -422,11 +473,12 @@ export function mountChat(el, host) {
422
473
  drawFoot({ role: role() });
423
474
  }
424
475
  };
425
- el.addEventListener('submit', (e) => { e.preventDefault(); const ta = foot.querySelector('textarea'); const v = ta.value; send(v).then((ok) => { if (ok) { ta.value = ''; grow(ta); } }); });
476
+ el.addEventListener('submit', (e) => { e.preventDefault(); const ta = foot.querySelector('textarea'); const v = ta.value; if (GU.submit(v)) { ta.value = ''; grow(ta); return; } send(v).then((ok) => { if (ok) { ta.value = ''; grow(ta); } }); });
426
477
  const shutAdd = (focus) => { if (!C.addOpen) return; C.addOpen = false; drawFoot({ role: role() }); if (focus) { const a = foot.querySelector('#hmAdd'); if (a) a.focus(); } };
427
478
  document.addEventListener('click', (e) => { if (C.addOpen && e.target.isConnected && !e.target.closest('.hm-addw')) shutAdd(false); }, true);
428
479
  el.addEventListener('keydown', (e) => {
429
480
  if (e.key === 'Escape' && C.addOpen) { e.preventDefault(); e.stopPropagation(); shutAdd(true); return; }
481
+ if (e.key === 'Escape' && GU.escape()) { e.preventDefault(); e.stopPropagation(); return; }
430
482
  if (e.target.id !== 'hmIn') { if (e.key === 'Escape' && running() && !document.querySelector('[data-esc-layer]') && !(window.czViewer && window.czViewer.isOpen())) press('esc'); return; }
431
483
  if (e.isComposing || e.keyCode === 229) return;
432
484
  const list = slashMatches(e.target.value), sm = el.querySelector('#hmSlash'), menu = list.length && sm && !sm.hidden;
@@ -517,7 +569,7 @@ export function mountChat(el, host) {
517
569
  if (notesM) notesM.then((M) => setTimeout(() => M.syncNotes(), 0)); // the Notes open in the Viewer belonged to the conversation before
518
570
  const same = C.t && t && C.t.key === t.key && C.t.sid === t.sid;
519
571
  C.t = t;
520
- if (!same) { C.addOpen = false; C.th = null; C.conv = null; C.show = 12; C.open = new Set(); C.files = []; C.marked = null; C.picked = {}; C.seenAt = t.key ? host.seen(t.key) : null; put(log, introHtml(t.intro)); C.jump = true; peek(null); }
572
+ if (!same) { C.addOpen = false; C.th = null; C.conv = null; C.show = 12; C.open = new Set(); C.files = []; C.marked = null; C.picked = {}; C.plOpen = false; C.plAll = false; C.seenAt = t.key ? host.seen(t.key) : null; put(log, introHtml(t.intro)); put(pl, ''); pl.hidden = true; C.jump = true; peek(null); }
521
573
  draw(); read();
522
574
  },
523
575
  refresh() { if (C.t) draw(); },
@@ -55,13 +55,21 @@ export function iniOfSession(s) {
55
55
  return m ? m[1] : null;
56
56
  }
57
57
  const stateOf = (s) => (s.shown === 'needs' ? 'needs' : s.shown === 'blocked' ? 'blocked' : s.shown === 'working' ? 'working' : s.shown === 'exited' ? 'exited' : 'quiet');
58
+ /** What a session is called (session names A, canvas XmsNames): the PM's own name always wins; else the name Claude gave it after its first
59
+ * real answer; else the CLI's opening title; else its start name, without a chat's 'chat: ' prefix. lib/session-name.js shownName on the server. */
60
+ export function nameOf(s) {
61
+ if (!s) return '';
62
+ const plain = String(s.name || '').replace(/^chat:\s*/, '');
63
+ if (s.name_by === 'pm') return plain || s.auto_name || (s.hx && s.hx.title) || 'Session';
64
+ return s.auto_name || (s.hx && s.hx.title) || plain || 'Session';
65
+ }
58
66
  export function sessionRow(s, roles) {
59
67
  const role = roleOf(s, roles);
60
68
  const st = stateOf(s);
61
69
  // a chat's tmux name carries a 'chat: ' prefix (lib/briefing-premium-agent.js); the row shows its title only (testing fixes)
62
- const name = s.hx && s.hx.title ? s.hx.title : String(s.name || '').replace(/^chat:\s*/, '') || 'Session';
70
+ const name = nameOf(s);
63
71
  return { id: 's:' + s.id, kind: 'session', sid: s.id, key: keyOfSession(s), ini: iniOfSession(s), name, state: st, initial: role.initial, role,
64
- hint: role.name, icon: 'chat', created: s.created || '' }; // the state is the dot beside the row, not a word (testing fixes)
72
+ hint: role.name, icon: 'chat', created: s.created || '', prog: s.progress && s.progress.n > 0 ? s.progress : null }; // the state is the dot beside the row, not a word (testing fixes)
65
73
  }
66
74
  /** The sessions as Home reads them. A session PMOS started (a skill, a background job) reads 'needs' as soon as its prompt is done:
67
75
  * its turn ending asks nothing of the PM, so it is a finished run, quiet, and never a row that waits on the PM (testing fixes).