create-pmos 0.436.0 → 0.438.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 (64) hide show
  1. package/package.json +25 -25
  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/adler-moments-test.js +121 -0
  7. package/workspace/briefing-premium-board-test.js +2 -1
  8. package/workspace/changelog.json +24 -0
  9. package/workspace/guide/adler.md +12 -1
  10. package/workspace/guide/briefing-premium.md +1 -1
  11. package/workspace/guide/home.md +22 -10
  12. package/workspace/home-rows-test.js +204 -115
  13. package/workspace/lib/mention-cli.js +45 -21
  14. package/workspace/lib/mention-store.js +196 -27
  15. package/workspace/lib/news-for-you.js +8 -16
  16. package/workspace/lib/routes-mentions.js +7 -2
  17. package/workspace/lib/routes-news.js +5 -11
  18. package/workspace/lib/source-reads.js +1 -1
  19. package/workspace/package-lock.json +2 -2
  20. package/workspace/package.json +1 -1
  21. package/workspace/premium-briefing-depth-test.js +2 -2
  22. package/workspace/premium-chat-context-test.js +20 -0
  23. package/workspace/public/pm/bd-asks.js +5 -2
  24. package/workspace/public/pm/bd-deliveries.js +11 -2
  25. package/workspace/public/pm/cozy-adler.css +7 -1
  26. package/workspace/public/pm/cozy-adler.js +17 -0
  27. package/workspace/public/pm/cozy-board.css +5 -0
  28. package/workspace/public/pm/cozy-ev.css +8 -0
  29. package/workspace/public/pm/cozy-home-rows.css +88 -62
  30. package/workspace/public/pm/cozy-home.css +7 -0
  31. package/workspace/public/pm/cozy-live-pill.css +2 -0
  32. package/workspace/public/pm/cozy-live-pill.js +6 -3
  33. package/workspace/public/pm/cozy-nav.js +18 -5
  34. package/workspace/public/pm/cozy-news.js +8 -27
  35. package/workspace/public/pm/cozy-pull.js +62 -0
  36. package/workspace/public/pm/cozy-rec-tab.css +2 -0
  37. package/workspace/public/pm/cozy-rec-tab.js +18 -1
  38. package/workspace/public/pm/cozy-settings.js +14 -5
  39. package/workspace/public/pm/cozy-steps.css +3 -0
  40. package/workspace/public/pm/cozy-steps.js +5 -4
  41. package/workspace/public/pm/cozy-today.css +5 -0
  42. package/workspace/public/pm/home-app.js +33 -2
  43. package/workspace/public/pm/home-day.js +43 -11
  44. package/workspace/public/pm/home-mentions.js +339 -194
  45. package/workspace/public/pm/home-review.js +9 -1
  46. package/workspace/public/pm/home-stage-card.js +9 -3
  47. package/workspace/public/pm/impact.css +1 -0
  48. package/workspace/public/pm/impact.js +5 -2
  49. package/workspace/public/pm/ini-tasks.js +19 -3
  50. package/workspace/public/pm/premium-board.js +12 -4
  51. package/workspace/public/pm/premium-shell.js +12 -4
  52. package/workspace/public/pm/premium-vw-ctx.js +16 -2
  53. package/workspace/public/pm/premium-vw-doc-model.js +11 -0
  54. package/workspace/public/pm/premium-vw-doc.css +2 -0
  55. package/workspace/public/pm/premium-vw-doc.js +8 -2
  56. package/workspace/public/pm/premium.css +14 -0
  57. package/workspace/public/pm/program-charter.js +2 -1
  58. package/workspace/public/pm/session-rail.js +12 -5
  59. package/workspace/public/premium-rec.html +1 -1
  60. package/workspace/skills/morning-brief.skill +2 -1
  61. package/workspace/skills/sources-read.skill +1 -0
  62. package/workspace/task-views-test.js +10 -1
  63. package/workspace/test-lists/adler-followups.json +9 -0
  64. package/workspace/test-lists/batch17-adler-moments.json +13 -0
@@ -1,48 +1,64 @@
1
- /* pm/home-mentions.js — @Mentions on Home: a permanent row at the top of the list and the Mentions Viewer (agreed A+; canvas
2
- * XmsMentionsGrill on the phone, XmsDeskList, XmsDeskOne and XmsDeskRefine on the desktop).
1
+ /* pm/home-mentions.js — @Mentions on Home: a permanent row at the top of the list and the Mentions Viewer ("Mentions, calm", batch 16
2
+ * item 12; canvas MnA1Calm, MnA2Waits, MnA3Thread, MnA4Desk, MnA5Busy, MnA6Edges and the 25 moments of MnGrill).
3
3
  *
4
- * rowHtml(D, { sel }) → the row's markup: "@ Mentions" and a badge with how many asks wait on the PM (reading does not clear it,
5
- * answering does). A new ask since the PM last opened Mentions adds one line under the name ("Maya asks about
6
- * SSO scope"). With nothing waiting the row stays, with no badge (zero is silence). The press is data-hr-mentions.
7
- * openMentions(ctx) → the Mentions Viewer: the summary card (how many wait, the oldest, who asks what; one round Reply press that opens
8
- * the oldest), "Waiting on you" (every unanswered ask, any age, oldest first, the age the only signal, 5 then
9
- * Show all) and "Last 7 days" (what does not wait, by real day: Today, Yesterday with its date, then dated days).
10
- * What PMOS could not read is said once at the end, with its next action. A failed read keeps the last list.
11
- * openOne(m, ctx, o) → one mention: what is asked and by when, its place, four one-tap icons with Undo (Mark answered, Remind me
12
- * tomorrow, Make it a task, Not an ask), What I found, the Proposed reply (pencil: change it with Claude in the
13
- * chat; send: copy it and open the source), and the source messages folded at the bottom.
4
+ * rowHtml(D, { sel }) → the row's markup: "@ Mentions" and a badge with how many conversations wait on the PM (Your move). Reading does
5
+ * not clear it, answering does; no badge at zero. A new ask since the PM last opened Mentions adds one line under
6
+ * the name ("Maya asks for the launch budget cap"). The press is data-hr-mentions.
7
+ * openMentions(ctx) → the Mentions Viewer. Adler's M face opens on what is handled first, and the mood is never happier than the data;
8
+ * on a heavy day one button starts on the oldest ask. Three folds, each hidden at zero: Your move (an open ask,
9
+ * oldest first, 3 then "N more"; the age turns amber after 2 days), To read (FYIs; a blue dot is not opened; ✓✓
10
+ * marks all read; closed while Your move has items) and Answered this week (closed, a small stack of faces).
11
+ * One row per conversation: a face with the source's badge, first names ("Maya and Dion", "Maya and 2 others"),
12
+ * the place, the message count and Claude's one-line gist (the real latest message in quotes until a gist
13
+ * exists). Rows carry no day. A drafted reply shows with ✎ and send only; when Claude cannot draft, it says why
14
+ * and ✎ "Write it with Claude" is the only button. After send: "Sent from Slack? I’ll see it at the next read."
15
+ * What PMOS could not read is one line each at the end; a failed read keeps the last list and says from when.
16
+ * openOne(m, ctx, o) → one conversation (MnA3): who, where, how many messages since when, ↗ to the source; the open ask first, with
17
+ * the reply and four one-tap acts, each with Undo (✓ answered, clock: remind me at 09:00, task: make it a task,
18
+ * × not an ask), then ✎ and send; "Where it stands" (hidden when nothing is settled); Claude's offer to watch for
19
+ * a dated promise (✓ ×); the messages last, in a fold.
20
+ * On a wide Viewer (desktop, MnA4) the list and the conversation sit side by side; ✎ moves the reply into the chat.
14
21
  * load(ctx) → GET /api/mentions into ctx.D().mentions, keeping the last good list when the read fails
15
- * ctx: { D() → Home's data, pmGet, pmPost, toast, toastUndo(msg, undo), reload(), iniTitle(id), stageOf(id), onBoard(id), board() → { ws, board },
16
- * goIni(id), draft(m) }
22
+ * ctx: { D() → Home's data, pmGet, pmPost, toast, toastUndo(msg, undo), reload(), redrawList(), iniTitle(id), stageOf(id), onBoard(id),
23
+ * board() → { ws, board }, goIni(id), draft(m) }
17
24
  *
18
- * The data is GET /api/mentions (lib/mention-store.js): its own store, so the brief's 30-item cap cannot crowd a mention out. Every press is
19
- * POST /api/mentions/act (one mark, undone by act: undo). Nothing here replies or posts: send copies the reply and opens the source, and
20
- * the PM sends it there. A mention shows only here: it is no longer a row under its initiative (say it once). */
25
+ * The data is GET /api/mentions (lib/mention-store.js): conversations from its own store, so the brief's 30-item cap cannot crowd one out.
26
+ * Every press is POST /api/mentions/act (one mark under the conversation's id, undone by act: undo). Nothing here replies or posts: send
27
+ * copies the reply and opens the source, and the PM sends it there. Mentions owns every mention: New for you shows none. */
21
28
  import * as VW from './cozy-viewer.js';
29
+ import { adler } from './cozy-adler.js';
22
30
 
23
31
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
24
- const SRC = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail', gmail: 'Gmail', figma: 'Figma', doc: 'the document' };
25
- const ICON = { jira: 'jira', confluence: 'doc', doc: 'doc', mail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7', gmail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7' };
32
+ const SRC = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'email', gmail: 'Gmail', figma: 'Figma', doc: 'the document' };
26
33
  const P = {
27
34
  tick: 'M5 12.5l4.5 4.5L19 7.5', clock: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 7.5V12l3 2', task: 'M4 4h11v11H4zM7 9.5l2 2 3-3.5M18 13v8M14 17h8',
28
- x: 'M6 6l12 12M18 6L6 18', reply: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 6 6v3', pen: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4', send: 'M21 3L10 14M21 3l-7 18-4-7-7-4z',
29
- plug: 'M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0zM12 17v4', again: 'M20 11a8 8 0 1 0-2.3 5.7M20 5v6h-6', chev: 'M10 7l5 5-5 5',
35
+ x: 'M6 6l12 12M18 6L6 18', pen: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4', send: 'M21 3L10 14M21 3l-7 18-4-7-7-4z', go: 'M5 12h14M13 6l6 6-6 6',
36
+ plug: 'M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0zM12 17v4', again: 'M20 11a8 8 0 1 0-2.3 5.7M20 5v6h-6', out: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6',
37
+ all: 'M2 12.5l4.5 4.5L15 8M9 15l2 2L22 7', spark: VW.ICONS.spark,
30
38
  };
39
+ const BADGE = { slack: 'M9 4l-2 16M17 4l-2 16M4 9h16M3 15h16', mail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7', gmail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7',
40
+ jira: 'M12 3l9 9-9 9-9-9z', confluence: 'M7 3h7l4 4v14H7zM14 3v4h4', doc: 'M7 3h7l4 4v14H7zM14 3v4h4' };
31
41
  const svg = (d, w = 16, sw = 2) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
32
42
  const srcName = (s) => SRC[s] || (s ? String(s).charAt(0).toUpperCase() + String(s).slice(1) : 'its source');
43
+ const sendIn = (s) => (s === 'mail' ? 'your email' : srcName(s));
33
44
  const first = (who) => String(who || 'someone').trim().split(/\s+/)[0];
34
45
  const clip = (s, n) => { s = String(s || '').replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
35
46
  const https = (u) => (/^https:\/\/\S+$/i.test(String(u || '')) ? u : '');
36
47
  const isMail = (s) => s === 'mail' || s === 'gmail';
37
48
  const isDoc = (s) => s === 'confluence' || s === 'doc';
38
- const T = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? t : 0; };
49
+ const T = (iso) => { const t = typeof iso === 'number' ? iso : Date.parse(iso || ''); return Number.isFinite(t) ? t : 0; };
39
50
  const DAY = 86400000;
51
+ const SHOWN = 3;
52
+ const WORDS = ['no', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
53
+ const word = (n) => WORDS[n] || String(n);
54
+ const cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
40
55
  const store = {
41
56
  get(k) { try { return localStorage.getItem(k); } catch { return null; } },
42
57
  set(k, v) { try { localStorage.setItem(k, String(v)); } catch { /* a private window */ } },
43
58
  };
44
59
  const SEEN = 'cz-men-seen'; // when the PM last opened Mentions: a newer ask adds its line under the row's name
45
- const CACHE = 'cz-men-last'; // the last list that loaded, with its time, for a read that fails (E4)
60
+ const CACHE = 'cz-men-last'; // the last list that loaded, with its time, for a read that fails (MnA6)
61
+ const HEARD = 'cz-men-heard'; // the landed promises the opening line already said (it says each once)
46
62
 
47
63
  /* ── the data ── */
48
64
  /** Load GET /api/mentions into D.mentions. A failed read keeps the last good list and says when it is from. */
@@ -57,24 +73,28 @@ export async function load(ctx) {
57
73
  }
58
74
  let last = D.mentions && !D.mentions.failed ? D.mentions : null;
59
75
  if (!last) { try { last = JSON.parse(store.get(CACHE) || 'null'); } catch { last = null; } }
60
- D.mentions = { ...(last || { waiting: [], recent: [], gaps: [], count: 0 }), failed: true, from: last ? last.at : 0 };
76
+ D.mentions = { ...(last || { waiting: [], toread: [], answered: [], gaps: [], count: 0 }), failed: true, from: last ? last.at : 0 };
61
77
  return D.mentions;
62
78
  }
63
- /** { waiting, recent, gaps, failed, from } of Home's data; empty lists before the first read. */
79
+ /** The lists of Home's data; empty before the first read. An answer from before conversations (no toread) reads its recent as To read. */
64
80
  export function mentionsOf(D) {
65
81
  const m = (D && D.mentions) || null;
66
- return { waiting: (m && m.waiting) || [], recent: (m && m.recent) || [], gaps: (m && m.gaps) || [], failed: !!(m && m.failed), from: (m && m.from) || 0, loaded: !!m };
82
+ const A = (k) => (m && Array.isArray(m[k]) ? m[k] : []);
83
+ const toread = m && Array.isArray(m.toread) ? m.toread : A('recent').filter((x) => x.fyi), answered = m && Array.isArray(m.answered) ? m.answered : A('recent').filter((x) => !x.fyi);
84
+ return { waiting: A('waiting'), toread, answered, gaps: A('gaps'), watching: A('watching'), landed: A('landed'), sources: A('sources'),
85
+ as_of: (m && m.as_of) || null, failed: !!(m && m.failed), from: (m && m.from) || 0, loaded: !!m };
67
86
  }
68
- /** A task made from a mention closes itself when the PM replies in the source (XmsMentionsGrill scenario 15). */
87
+ const allOf = (L) => [...L.waiting, ...L.toread, ...L.answered];
88
+ /** A task made from a mention closes itself when the PM replies in the source (MnGrill). */
69
89
  async function closeTasks(ctx, r) {
70
- for (const m of r.recent || []) {
90
+ for (const m of [...(r.answered || r.recent || [])]) {
71
91
  if (m.status !== 'replied' || !m.task || m.task_closed) continue;
72
92
  const t = m.task;
73
93
  const res = t.kind === 'board' ? await ctx.pmPost('/api/boards/tasks/state', { ws: t.ws, board: t.board, task: t.id, state: 'Done' }) : await ctx.pmPost('/api/pm-items/done', { id: t.id, how: 'confirmed' });
74
94
  if (res && res.ok) await ctx.pmPost('/api/mentions/act', { id: m.id, act: 'closed' });
75
95
  }
76
96
  }
77
- /** "40 min", "2 h", "1 day", "3 days"; '' with no time. */
97
+ /** "40 min", "5 h", "1 day", "3 days"; '' with no time. */
78
98
  export function age(at, now = Date.now()) {
79
99
  const t = T(at); if (!t) return '';
80
100
  const m = Math.max(0, Math.round((now - t) / 60000));
@@ -84,185 +104,293 @@ export function age(at, now = Date.now()) {
84
104
  }
85
105
  const late = (at, now = Date.now()) => now - T(at) >= 2 * DAY;
86
106
  const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
107
+ const WDL = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
87
108
  const MO = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
88
109
  const day0 = (t) => { const d = new Date(t); d.setHours(0, 0, 0, 0); return d.getTime(); };
89
- /** The PM's local day of a time: "Today", "Yesterday, Sat 24 Oct", "Thu 23 Oct". */
110
+ const daysAgo = (t, now) => Math.round((day0(now) - day0(t)) / DAY);
111
+ /** The PM's local day of a time: "Today", "Yesterday", "Tue 27 Oct". */
90
112
  export function dayLabel(at, now = Date.now()) {
91
- const t = T(at), d = new Date(t), n = Math.round((day0(now) - day0(t)) / DAY);
92
- const dated = WD[d.getDay()] + ' ' + d.getDate() + ' ' + MO[d.getMonth()];
93
- return n <= 0 ? 'Today' : n === 1 ? 'Yesterday, ' + dated : dated;
113
+ const t = T(at), d = new Date(t), n = daysAgo(t, now);
114
+ return n <= 0 ? 'Today' : n === 1 ? 'Yesterday' : WD[d.getDay()] + ' ' + d.getDate() + ' ' + MO[d.getMonth()];
94
115
  }
95
- /** Where the mention is, the way the frames say it: "Slack #product", "SLV-144 comment", "comment on PRD v3", "email". */
116
+ const hmOf = (t) => { const d = new Date(t); return String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0'); };
117
+ /** Where the conversation is, as the frames say it: "#tech-team-cem", "DM", "PAY-312 comment", "comment on PRD v3", "email". */
96
118
  export function placeOf(m) {
97
119
  const w = String(m.where || '').trim();
98
- if (m.source === 'slack') return 'Slack' + (w ? ' ' + w : m.via === 'dm' ? ' DM' : '');
120
+ if (m.source === 'slack') return w || (m.via === 'dm' ? 'DM' : 'Slack');
99
121
  if (m.source === 'jira') return (w || 'Jira') + ' comment';
100
122
  if (isDoc(m.source)) return 'comment on ' + (w || srcName(m.source));
101
123
  if (isMail(m.source)) return 'email';
102
124
  return [srcName(m.source), w].filter(Boolean).join(' ');
103
125
  }
104
- const whoOf = (m) => m.who || srcName(m.source);
105
- const askOf = (m) => (m.ask ? first(whoOf(m)) + ' asks ' + m.ask.replace(/^[A-Z](?=[a-z])/, (c) => c.toLowerCase()).replace(/[.?!]+$/, '') : first(whoOf(m)) + ' asks “' + clip(m.text, 70).replace(/[.?!]+$/, '') + '”');
126
+ const peopleOf = (m) => (Array.isArray(m.people) && m.people.length ? m.people : [m.who || srcName(m.source)]);
127
+ /** The row's name: a first name; "Maya and Dion"; "Maya and 2 others" for 3 or more (MnGrill). */
128
+ export function nameOf(m) {
129
+ const p = peopleOf(m).map(first);
130
+ return p.length === 1 ? p[0] : p.length === 2 ? p[0] + ' and ' + p[1] : p[0] + ' and ' + (p.length - 1) + ' others';
131
+ }
132
+ /** The conversation's title: the full names ("Samuel Chandra"; "Maya Tan and Dion Lee"; "Maya Tan, Dion Lee and Rina Sari"). */
133
+ export function fullNames(m) {
134
+ const p = peopleOf(m);
135
+ return p.length <= 2 ? p.join(' and ') : p.slice(0, -1).join(', ') + ' and ' + p[p.length - 1];
136
+ }
137
+ const initials = (who) => { const w = String(who || '?').replace(/[^\p{L}\s]/gu, '').trim().split(/\s+/); return esc(((w[0] || '?')[0] + (w[1] ? w[1][0] : (w[0] || '')[1] || '')).toUpperCase()); };
138
+ /** The row's line: Claude's gist, else the real latest message in quotes (never a made-up gist). */
139
+ export function gistOf(m) { return m.gist ? m.gist : '“' + clip(m.text || m.ask || '', 140) + '”'; }
106
140
 
107
- /* ── the row on Home (XmsMentionsGrill 4) ── */
141
+ /* ── the row on Home ── */
108
142
  export function rowHtml(D, o = {}) {
109
143
  const { waiting } = mentionsOf(D);
110
144
  const n = waiting.length;
111
145
  const sel = o.sel === 'mentions';
112
146
  const seen = +(store.get(SEEN) || 0);
113
147
  const nu = seen ? waiting.filter((m) => T(m.since) > seen || (m.count > 1 && T(m.last) > seen)).sort((a, b) => T(b.last) - T(a.last))[0] : null;
114
- const sub = nu ? clip(first(whoOf(nu)) + ' asks ' + (nu.ask ? nu.ask.replace(/[.?!]+$/, '') : 'you something'), 60) : '';
148
+ const sub = nu ? clip(nameOf(nu) + (nu.ask ? ' asks ' + nu.ask.replace(/^[A-Z](?=[a-z])/, (c) => c.toLowerCase()).replace(/[.?!]+$/, '') : ' asks you something'), 60) : '';
115
149
  return `<div class="hv-card hr-card hr-men-card"><div class="hm-r hv-r hr-men${sel ? ' sel' : ''}${n ? ' new' : ''}" data-id="mentions">`
116
150
  + `<button type="button" class="hm-rm" data-hr-mentions${sel ? ' aria-current="true"' : ''} aria-label="Mentions${n ? ', ' + n + (n === 1 ? ' waits' : ' wait') + ' on your reply' : ''}">`
117
151
  + `<span class="hv-mk hr-at" aria-hidden="true">@</span><span class="hm-rt"><b>Mentions</b>${sub ? `<small class="hr-sub">${esc(sub)}</small>` : ''}</span>`
118
152
  + (n ? `<span class="hr-bd" aria-hidden="true">${n}</span>` : '') + '<span class="hv-xc" aria-hidden="true"></span></button></div></div>';
119
153
  }
120
154
 
121
- /* ── the Mentions Viewer (XmsMentionsGrill 1, 2, E1 to E4; XmsDeskList) ── */
122
- function waitRow(m, now) {
123
- const a = age(m.since, now);
124
- let sub;
125
- if (m.drafted) sub = `<span><em class="hr-dr">Your draft is ready.</em> Send it from ${esc(srcName(m.source))} to clear this.</span>`;
126
- else sub = `<span>${esc('“' + clip(m.text, 110) + '”' + (m.count > 1 ? (T(m.last) >= day0(now) ? ' and a follow-up today' : ' and ' + (m.count - 1) + ' more') : ''))}</span>`;
127
- const check = m.check ? `<div class="hr-ck" role="group" aria-label="${esc('Did you answer ' + first(whoOf(m)) + ' already?')}"><span>Did you answer this already?</span>`
128
- + `<button type="button" class="hr-ckb" data-hr-ck="yes" data-id="${esc(m.id)}" aria-label="Yes, I answered it" title="Yes, I answered it">${svg(P.tick, 15, 2.2)}</button>`
129
- + `<button type="button" class="hr-ckb" data-hr-ck="no" data-id="${esc(m.id)}" aria-label="No, keep it waiting" title="No, keep it waiting">${svg(P.x, 15, 2.2)}</button></div>` : '';
130
- return `<button type="button" class="hr-mi hr-w8" data-hr-mi="${esc(m.id)}" aria-label="${esc(whoOf(m) + ', ' + placeOf(m) + ', waiting ' + a + '. Open')}">`
131
- + `<span class="hr-mw"><b>${esc(whoOf(m) + ' · ' + placeOf(m))}${m.count > 1 ? `<i class="hr-cn" aria-label="${m.count} asks">${m.count}</i>` : ''}</b>${sub}</span>`
132
- + `<span class="hr-age${late(m.since, now) ? ' late' : ''}">${esc(a)}</span></button>` + check;
155
+ /* ── the opening line (MnA1, MnA2, MnA5, MnA6) ── */
156
+ const heard = () => { try { return new Set(JSON.parse(store.get(HEARD) || '[]')); } catch { return new Set(); } };
157
+ const landedKey = (x) => x.id + '@' + x.at;
158
+ const joinOr = (l) => (l.length <= 1 ? l.join('') : l.slice(0, -1).join(', ') + ' or ' + l[l.length - 1]);
159
+ const joinAnd = (l) => (l.length <= 1 ? l.join('') : l.slice(0, -1).join(', ') + ' and ' + l[l.length - 1]);
160
+ /** The one ask Your day's opening card names (batch 17 item 6): the oldest conversation in Your move, or null. Pure.
161
+ * → { id, who, where, gist, more } */
162
+ export function dayAskOf(D) {
163
+ const L = mentionsOf(D);
164
+ if (!L.loaded || L.failed || !L.waiting.length) return null;
165
+ const m = L.waiting[0];
166
+ return { id: m.id, who: nameOf(m), where: placeOf(m), gist: gistOf(m), more: L.waiting.length - 1 };
133
167
  }
134
- function statusLine(m) {
135
- if (m.status === 'replied') return 'You replied in the thread';
136
- if (m.status === 'answered') return 'Marked answered by you';
137
- if (m.status === 'task') return 'A task now: ' + ((m.task && m.task.title) || 'Reply to ' + first(whoOf(m)));
138
- if (m.status === 'notask') return 'You said it is not an ask';
139
- return '';
168
+
169
+ /** Adler's opening line: what is handled first, said as plainly as the data. Pure. L: mentionsOf(); o: { heard: Set of landed keys said }.
170
+ * → { mood, html, go (start on the oldest ask), retry, said: [landed keys this line says] } */
171
+ export function openingOf(L, now = Date.now(), o = {}) {
172
+ const w = L.waiting, n = w.length;
173
+ const said = (L.landed || []).filter((x) => !(o.heard || new Set()).has(landedKey(x)));
174
+ const landed = said.map((x) => ' ' + esc(String(x.text).replace(/[.!]?$/, '.'))).join('');
175
+ const watch = (L.watching || []).length ? ' I’m watching for ' + esc(joinAnd(L.watching.map((x) => x.what))) + ' and will tell you when ' + (L.watching.length === 1 ? 'it lands' : 'they land') + '.' : '';
176
+ if (L.failed) return { mood: 'honest', html: 'I couldn’t refresh Mentions. ' + (L.from ? 'This is the list from <b>' + esc(hmOf(L.from)) + '</b>.' : 'There is no list to show yet.'), retry: true, said: [] };
177
+ const missing = (L.gaps || []).some((g) => g.kind === 'source');
178
+ const inSrc = missing && (L.sources || []).length ? ' in ' + esc(joinOr(L.sources.map((s) => (s === 'mail' ? 'email' : srcName(s))))) : '';
179
+ if (!n) {
180
+ const answered = L.answered.filter((m) => m.status === 'replied' || m.status === 'answered').length;
181
+ if (!L.toread.length && !watch && !landed) {
182
+ const lastT = Math.max(0, ...L.answered.map((m) => T(m.last)));
183
+ const d = lastT ? daysAgo(lastT, now) : 0;
184
+ const since = !lastT ? '' : d <= 0 ? 'this morning' : d === 1 ? 'yesterday' : WDL[new Date(lastT).getDay()];
185
+ return { mood: 'resting', html: lastT ? 'A quiet week. Nobody has mentioned you since ' + since + ', so nothing waits.' : 'A quiet week. Nobody has mentioned you in the last 7 days.', said: [] };
186
+ }
187
+ const done = answered ? ' You answered ' + (answered === 1 ? 'the one ask' : 'all <b>' + answered + ' asks</b>') + ' this week.' : '';
188
+ return { mood: landed ? 'celebrating' : 'handled', html: 'Nothing waits on you' + inSrc + '.' + done + landed + watch, said: said.map(landedKey) };
189
+ }
190
+ const people = [...new Set(w.flatMap((m) => peopleOf(m).map(first)))];
191
+ const lead = people.length === 1 ? esc(people[0]) + ' waits on you' : cap(word(people.length)) + ' people wait on you';
192
+ const drafted = w.filter((m) => m.draft && !m.drafted).length, cant = w.filter((m) => m.nodraft);
193
+ const heavy = n > SHOWN;
194
+ let html;
195
+ if (heavy) {
196
+ const o0 = w[0];
197
+ html = lead + ', and ' + esc(nameOf(o0)) + '’s has waited ' + esc(age(o0.since, now)) + '.' + (drafted ? ' I drafted ' + word(drafted) + (drafted >= 2 ? ', so the first few are quick.' : '.') : '')
198
+ + ' Want me to start you on ' + esc(nameOf(o0)) + '’s?';
199
+ } else {
200
+ const dr = !drafted ? '' : drafted === n ? (n === 1 ? ' I drafted your reply.' : ' I drafted all ' + word(n) + ' replies.')
201
+ : ' I drafted ' + word(drafted) + (drafted === 1 ? ' reply' : ' replies') + (cant.length ? '; ' + esc(nameOf(cant[0])) + '’s needs you.' : '.');
202
+ html = lead + '.' + dr;
203
+ }
204
+ return { mood: 'needs-you', html: html + landed + watch, go: heavy, said: said.map(landedKey) };
140
205
  }
141
- function recentRow(m, now) {
142
- const st = statusLine(m);
143
- const today = T(m.last) >= day0(now);
144
- const right = today ? age(m.last, now) : WD[new Date(T(m.last)).getDay()];
145
- const done = m.status === 'replied' || m.status === 'answered'; // a done ask carries the tick icon, not a ✓ glyph (R28-13)
146
- const sub = st ? `<span class="hr-st">${done ? svg(P.tick, 13, 2.2) + ' ' : ''}${esc(st)}</span>` : `<span>${esc('“' + clip(m.text, 110) + '”')}${m.broadcast ? ' <em class="hr-nc">Not counted as an ask</em>' : ''}</span>`;
147
- const dot = m.fyi && !m.read;
148
- return `<button type="button" class="hr-mi${dot ? ' hr-un' : ' hr-rd'}" data-hr-mi="${esc(m.id)}" aria-label="${esc(whoOf(m) + ', ' + placeOf(m) + (dot ? ', not opened' : '') + '. Open')}">`
149
- + `<span class="hr-mdot${dot ? '' : ' read'}" aria-hidden="true"></span><span class="hr-mw"><b>${esc(whoOf(m) + ' · ' + placeOf(m))}</b>${sub}</span>`
150
- + `<span class="hr-age">${esc(right)}</span></button>`;
206
+
207
+ /* ── the rows ── */
208
+ const ib = (attrs, label, d, solid = false) => `<button type="button" class="${solid ? 'hr-rp mn-sb' : 'czs-ib mn-ib'}" ${attrs} aria-label="${esc(label)}" title="${esc(label)}">${svg(d, solid ? 17 : 16, 2.2)}</button>`;
209
+ const face = (m) => `<span class="mn-av" aria-hidden="true">${initials(peopleOf(m)[0])}${BADGE[m.source] ? `<i class="mn-bg">${svg(BADGE[m.source], 9, 2.4)}</i>` : ''}</span>`;
210
+ function draftHtml(m, o = {}) {
211
+ if (m.drafted) return `<p class="mn-sent">${svg(P.send, 12, 2.2)}<span>Sent from ${esc(srcName(m.source))}? I’ll see it at the next read.</span></p>`;
212
+ if (m.nodraft) return `<div class="mn-dr no"><p class="mn-drh">${svg(P.spark, 12, 2)}<span>I can’t draft this one</span></p><p>${esc(m.nodraft)}</p></div>`
213
+ + (o.acts === false ? '' : `<div class="mn-acts">${ib(`data-mn="pen" data-id="${esc(m.id)}"`, 'Write it with Claude', P.pen, true)}</div>`);
214
+ if (m.draft) return `<div class="mn-dr"><p class="mn-drh">${svg(P.spark, 12, 2)}<span>I drafted your reply</span></p><p data-mn-draft>${esc(m.draft)}</p></div>`
215
+ + (o.acts === false ? '' : `<div class="mn-acts">${ib(`data-mn="pen" data-id="${esc(m.id)}"`, 'Change it with Claude', P.pen)}${ib(`data-mn="send" data-id="${esc(m.id)}"`, 'Copy it and open ' + srcName(m.source) + '. PMOS never posts.', P.send, true)}</div>`);
216
+ return '';
151
217
  }
152
- function byDay(list, now) {
153
- let out = '', cur = '';
154
- for (const m of list) { const d = dayLabel(m.last, now); if (d !== cur) { out += `<p class="hr-day">${esc(d)}</p>`; cur = d; } out += recentRow(m, now); }
155
- return out;
218
+ const checkHtml = (m) => (m.check ? `<div class="hr-ck" role="group" aria-label="${esc('Did you answer ' + nameOf(m) + ' already?')}"><span>Did you answer this already?</span>`
219
+ + `<button type="button" class="hr-ckb" data-mn="ck-yes" data-id="${esc(m.id)}" aria-label="Yes, I answered it" title="Yes, I answered it">${svg(P.tick, 15, 2.2)}</button>`
220
+ + `<button type="button" class="hr-ckb" data-mn="ck-no" data-id="${esc(m.id)}" aria-label="No, keep it waiting" title="No, keep it waiting">${svg(P.x, 15, 2.2)}</button></div>` : '');
221
+ /** One conversation's row. kind: 'move' | 'read' | 'done'. o: { full: the drafted reply in full (a calm day), sel, now } */
222
+ export function rowOf(m, kind, o = {}) {
223
+ const now = o.now || Date.now();
224
+ const dot = kind === 'read' && !m.read && !m.broadcast;
225
+ const n = m.messages || 1;
226
+ const right = (n > 1 ? `<i class="mn-n" aria-label="${n} messages">${n}</i>` : '')
227
+ + (kind === 'move' && m.since ? `<span class="mn-age${late(m.since, now) ? ' late' : ''}">${esc(age(m.since, now))}</span>` : '')
228
+ + (dot ? '<span class="mn-dot" aria-hidden="true"></span>' : '');
229
+ const tag = kind === 'move' && !o.full ? (m.drafted ? `<span class="mn-tag">${svg(P.send, 11, 2.2)} Sent from ${esc(srcName(m.source))}? I’ll see it at the next read.</span>`
230
+ : m.draft ? `<span class="mn-tag">${svg(P.pen, 11, 2.2)} Reply drafted</span>` : '') : '';
231
+ const label = nameOf(m) + ', ' + placeOf(m) + (kind === 'move' && m.since ? ', waiting ' + age(m.since, now) : '') + (dot ? ', not opened' : '') + '. Open';
232
+ return `<div class="mn-row k-${kind}${o.sel ? ' sel' : ''}${dot ? ' un' : ''}" data-mn-row="${esc(m.id)}">`
233
+ + `<button type="button" class="mn-open" data-mn="open" data-id="${esc(m.id)}" aria-label="${esc(label)}"${o.sel ? ' aria-current="true"' : ''}>${face(m)}`
234
+ + `<span class="mn-main"><span class="mn-top"><b class="mn-nm">${esc(nameOf(m))}</b><span class="mn-pl">· ${esc(placeOf(m))}</span><span class="mn-r">${right}</span></span>`
235
+ + `<span class="mn-gist">${m.since_reply ? '<em>New since your reply.</em> ' : ''}${esc(gistOf(m))}</span>${tag}</span></button>`
236
+ + (kind === 'move' && o.full ? draftHtml(m) : '') + (kind === 'move' ? checkHtml(m) : '') + '</div>';
156
237
  }
157
- const hmOf = (t) => { const d = new Date(t); return String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0'); };
158
- function gapsHtml(gaps) {
159
- return (gaps || []).map((g) => {
238
+
239
+ /* ── the list ── */
240
+ function gapsHtml(L) {
241
+ const out = (L.gaps || []).map((g) => {
160
242
  if (g.kind === 'stale') {
161
- const t = T(g.upto), y = day0(Date.now()) - day0(t) === DAY;
162
- return `<div class="hr-gap"><p><b>Today’s check hasn’t run yet.</b> Mentions are up to ${esc(hmOf(t) + (y ? ' yesterday' : ' on ' + dayLabel(g.upto).replace(/^Yesterday, /, '')))}.</p>`
163
- + `<button type="button" class="czs-ib" data-hr-gap="check" aria-label="Check now" title="Check now">${svg(P.again, 16, 2)}</button></div>`;
243
+ const t = T(g.upto), d = daysAgo(t, Date.now());
244
+ return `<div class="mn-gap"><p>Last read ${esc(hmOf(t) + (d === 1 ? ' yesterday' : d > 1 ? ' on ' + dayLabel(g.upto) : ''))}. Today’s read hasn’t run.</p>`
245
+ + ib('data-mn="check"', 'Read now', P.again) + '</div>';
164
246
  }
165
- const s = srcName(g.source);
166
- const said = g.state === 'not-reached' ? `<b>PMOS couldn’t reach ${esc(s)}</b> at the last check, so ${esc(s)} mentions may be missing.` : `<b>${esc(s)} isn’t connected</b>, so ${esc(s)} mentions are missing.`;
167
- return `<div class="hr-gap"><p>${said}</p><button type="button" class="czs-ib" data-hr-gap="connect" aria-label="${esc('Connect ' + s)}" title="${esc('Connect ' + s)}">${svg(P.plug, 16, 2)}</button></div>`;
247
+ const s = srcName(g.source), S = cap(s);
248
+ const said = g.state === 'not-reached' ? `<b>PMOS couldn’t reach ${esc(s)}</b> at the last read, so ${esc(s)} mentions may be missing.` : `<b>${esc(S)} isn’t connected</b>, so ${esc(s)} mentions are missing.`;
249
+ return `<div class="mn-gap"><p>${said}</p>${ib('data-mn="connect"', 'Connect ' + S, P.plug)}</div>`;
168
250
  }).join('');
251
+ if (out || L.failed || !L.as_of || !(L.sources || []).length) return out;
252
+ // nothing is missing: one quiet line says what was read and when (honest state)
253
+ const names = L.sources.map((s) => (s === 'mail' ? 'email' : srcName(s)));
254
+ return `<p class="mn-foot">${esc(cap(joinAnd(names)))} read at ${esc(hmOf(T(L.as_of)))}.</p>`;
169
255
  }
170
- /** The summary card's words. Pure, so a unit test can read it. */
171
- export function summaryOf(L, now = Date.now()) {
172
- const { waiting, recent } = L;
173
- const n = waiting.length;
174
- if (L.failed) return { line: 'Couldn’t refresh Mentions', text: L.from ? 'Showing the list from ' + hmOf(L.from) + '. The workspace didn’t answer.' : 'The workspace didn’t answer, so nothing can be shown yet.', retry: true };
175
- if (!n && !recent.length) return { text: 'Nobody mentioned you in the last 7 days.', bare: true };
176
- if (!n) {
177
- const asks = recent.filter((m) => !m.fyi).length, fyiToday = recent.filter((m) => m.fyi && T(m.last) >= day0(now)).length;
178
- const parts = [asks ? 'You answered ' + (asks === 1 ? 'the one ask' : 'all ' + asks + ' asks') + ' this week.' : '', fyiToday ? fyiToday + (fyiToday === 1 ? ' FYI from today is' : ' FYIs from today are') + ' under Last 7 days.' : ''].filter(Boolean);
179
- return { line: 'Nothing waits on you', text: parts.join(' ') || 'What came in this week is under Last 7 days.' };
180
- }
181
- let text;
182
- if (n >= 6) {
183
- const by = {}; for (const m of waiting) { const k = m.where || srcName(m.source); by[k] = (by[k] || 0) + 1; }
184
- const top = Object.entries(by).sort((a, b) => b[1] - a[1])[0];
185
- text = (top && top[1] * 2 >= n ? 'Most are from ' + top[0] + '. ' : '') + first(whoOf(waiting[0])) + '’s ask has waited ' + age(waiting[0].since, now) + '.';
186
- } else {
187
- const said = waiting.slice(0, 2).map((m) => askOf(m) + (m.count > 1 && T(m.last) >= day0(now) ? ', and asked again today' : '') + '.');
188
- text = said.join(' ') + (n > 2 ? ' And ' + (n - 2) + ' more.' : '');
189
- }
190
- return { line: n + (n === 1 ? ' waits' : ' wait') + ' on your reply', right: 'oldest ' + age(waiting[0].since, now), text, reply: true };
256
+ const stack = (list) => `<span class="mn-stk" aria-hidden="true">${list.slice(0, 4).map((m) => `<i>${initials(peopleOf(m)[0])}</i>`).join('')}</span>`;
257
+ function foldsHtml(L, X, now, sel) {
258
+ // a calm day shows each drafted reply in full on its row; side by side, the conversation beside the list shows it (say it once)
259
+ const w = L.waiting, full = w.length <= SHOWN && !X.split;
260
+ const showW = X.all ? w : w.slice(0, SHOWN);
261
+ const restW = w.slice(showW.length);
262
+ const newest = restW.length ? Math.max(...restW.map((m) => T(m.since))) : 0;
263
+ const moreW = restW.length ? `<button type="button" class="mn-more" data-mn="more-move">${esc(restW.length + ' more' + (newest && daysAgo(newest, now) <= 0 ? ', newest today' : ''))}</button>` : '';
264
+ const showR = X.allRead ? L.toread : L.toread.slice(0, SHOWN), moreR = L.toread.length - showR.length;
265
+ const unread = L.toread.filter((m) => !m.read && !m.broadcast);
266
+ const row = (k) => (m) => rowOf(m, k, { full, now, sel: sel === m.id });
267
+ return VW.czSections([
268
+ w.length ? { id: 'move', title: 'Your move', count: w.length, open: true, html: `<div class="mn-list">${showW.map(row('move')).join('')}${moreW}</div>` } : null,
269
+ L.toread.length ? { id: 'toread', title: 'To read', count: L.toread.length, open: !w.length,
270
+ tail: unread.length ? `<button type="button" class="mn-all" data-mn="all-read" aria-label="${esc('Mark all ' + unread.length + ' read')}" title="Mark all read">${svg(P.all, 18, 1.9)}</button>` : '',
271
+ html: `<div class="mn-list">${showR.map(row('read')).join('')}${moreR > 0 ? `<button type="button" class="mn-more" data-mn="more-read">${moreR} more</button>` : ''}</div>` } : null,
272
+ L.answered.length ? { id: 'answered', title: 'Answered this week', count: L.answered.length, open: false, tail: stack(L.answered), html: `<div class="mn-list">${L.answered.map(row('done')).join('')}</div>` } : null,
273
+ ], { key: 'mentions-' + (w.length ? 'busy' : 'calm') });
191
274
  }
192
275
  function listHtml(ctx, X) {
193
276
  const now = Date.now();
194
277
  const L = mentionsOf(ctx.D());
195
- const s = summaryOf(L, now);
196
- const round = s.reply ? `<button type="button" class="hr-rp" data-hr-act="reply" aria-label="${esc('Reply to ' + first(whoOf(L.waiting[0])))}" title="${esc('Reply to ' + first(whoOf(L.waiting[0])))}">${svg(P.reply, 18, 2.2)}</button>`
197
- : s.retry ? `<button type="button" class="czs-ib" data-hr-act="retry" aria-label="Try again" title="Try again">${svg(P.again, 16, 2)}</button>` : '';
198
- const sum = `<div class="hr-sum${s.reply ? ' you' : ''}">${s.line ? `<div class="czs-line${s.reply ? ' you' : ''}">${s.reply ? '<span class="czs-dot" aria-hidden="true"></span>' : ''}<span>${esc(s.line)}</span>${s.right ? `<span class="czs-r hr-old">${esc(s.right)}</span>` : ''}</div>` : ''}`
199
- + `<div class="hr-sumb"><p class="czs-p">${esc(s.text)}</p>${round}</div></div>`;
200
- if (s.bare) return '<div class="hr-vb">' + sum + gapsHtml(L.gaps) + '</div>';
201
- const w = L.waiting, show = X.all || w.length <= 5 ? w : w.slice(0, 5);
202
- const wHtml = '<div class="hr-ml">' + show.map((m) => waitRow(m, now)).join('') + (show.length < w.length ? `<button type="button" class="hr-all" data-hr-act="all">Show all ${w.length}</button>` : '') + '</div>';
203
- const secs = VW.czSections([
204
- w.length ? { id: 'waiting', title: 'Waiting on you', count: w.length, open: true, html: wHtml } : null,
205
- L.recent.length ? { id: 'recent', title: 'Last 7 days', count: L.recent.length, open: false, html: '<div class="hr-ml">' + byDay(L.recent, now) + '</div>' } : null,
206
- ], { key: 'mentions' });
207
- return '<div class="hr-vb">' + sum + secs + gapsHtml(L.gaps) + '</div>';
278
+ const s = openingOf(L, now, { heard: heard() });
279
+ if (s.said.length) { const h = heard(); s.said.forEach((k) => h.add(k)); store.set(HEARD, JSON.stringify([...h].slice(-40))); }
280
+ const btn = s.go && L.waiting[0] ? ib('data-mn="go"', 'Start on ' + nameOf(L.waiting[0]) + '’s', P.go, true) : s.retry ? ib('data-mn="retry"', 'Try again', P.again, true) : '';
281
+ const open = `<div class="mn-open-card m-${s.mood}">${adler(s.mood, 'm', { label: false })}<div class="mn-oc"><p>${s.html}</p>${btn ? `<div class="mn-acts">${btn}</div>` : ''}</div></div>`;
282
+ return `<div class="mn-vb">${open}${foldsHtml(L, X, now, X.split ? X.sel : null)}${gapsHtml(L)}</div>`;
208
283
  }
209
- let LIST = null; // the list Viewer that is open: { body, X }, so a press elsewhere redraws it
210
- export function openMentions(ctx) {
284
+
285
+ let LIST = null; // the list Viewer that is open: { body, X, draw }, so a press elsewhere redraws it
286
+ const SPLIT = 720; // a Viewer this wide shows the list and the conversation side by side (MnA4)
287
+ const canSplit = (b) => !!b && !(typeof innerWidth === 'number' && innerWidth <= VW.PHONE) && (b.clientWidth || 0) >= SPLIT;
288
+ export function openMentions(ctx, o = {}) {
211
289
  sheet();
212
290
  store.set(SEEN, Date.now());
213
- const X = { all: false };
291
+ const X = { all: false, allRead: false, sel: o.sel || null, split: false }; // o.sel: Your day's ask opens on its conversation
292
+ const find = (id) => allOf(mentionsOf(ctx.D())).find((x) => x.id === id) || null;
214
293
  const draw = (b) => {
215
- LIST = { body: b, X };
216
- b.innerHTML = listHtml(ctx, X);
217
- b.onclick = async (e) => {
218
- const t = e.target.closest('[data-hr-mi],[data-hr-act],[data-hr-ck],[data-hr-gap]'); if (!t || !b.contains(t)) return;
294
+ LIST = { body: b, X, draw };
295
+ X.split = canSplit(b);
296
+ if (X.split) {
219
297
  const L = mentionsOf(ctx.D());
220
- const all = [...L.waiting, ...L.recent];
221
- if (t.dataset.hrCk) { // a 30+ day ask, asked once: ✓ it was answered, × keep it waiting and ask again in 30 days
222
- const m = all.find((x) => x.id === t.dataset.id); if (!m) return;
223
- await act(ctx, m, t.dataset.hrCk === 'yes' ? 'answered' : 'keep');
224
- return;
225
- }
226
- if (t.dataset.hrMi) { const m = all.find((x) => x.id === t.dataset.hrMi); if (m) openOne(m, ctx, { back: true }); return; }
227
- if (t.dataset.hrAct === 'reply' && L.waiting[0]) { openOne(L.waiting[0], ctx, { back: true }); return; }
228
- if (t.dataset.hrAct === 'all') { X.all = true; draw(b); return; }
229
- if (t.dataset.hrAct === 'retry') { await load(ctx); draw(b); ctx.redrawList(); return; }
230
- if (t.dataset.hrGap === 'connect') { import('./cozy-settings.js').then((S) => S.openSettings('connectors')).catch(() => {}); return; }
231
- if (t.dataset.hrGap === 'check') {
232
- const r = await ctx.pmPost('/api/sources/refresh-all', { ws: (ctx.board() || {}).ws || '' });
233
- ctx.toast(r && r.ok ? 'Checking every source now. Mentions update when it is done.' : 'The check did not start: ' + ((r && r.error) || 'the workspace did not answer') + '.');
234
- }
235
- };
298
+ if (!X.sel || !find(X.sel)) X.sel = (L.waiting[0] || L.toread[0] || L.answered[0] || {}).id || null;
299
+ const m = X.sel ? find(X.sel) : null;
300
+ b.innerHTML = `<div class="mn-split"><div class="mn-col">${listHtml(ctx, X)}</div><div class="mn-col mn-conv" data-mn-conv>${m ? convHtml(m, ctx, { split: true }) : ''}</div></div>`;
301
+ if (m) markRead(ctx, m);
302
+ } else b.innerHTML = listHtml(ctx, X);
303
+ b.onclick = (e) => press(e, b);
304
+ };
305
+ const press = async (e, b) => {
306
+ const t = e.target.closest('[data-mn],[data-czs-act]'); if (!t || !b.contains(t)) return;
307
+ const k = t.dataset.mn || t.dataset.czsAct, L = mentionsOf(ctx.D());
308
+ const m = t.dataset.id ? find(t.dataset.id) : X.split && t.closest('[data-mn-conv]') ? find(X.sel) : null;
309
+ if (k === 'open' && m) { if (X.split) { X.sel = m.id; draw(b); } else openOne(m, ctx, { back: true }); return; }
310
+ if (k === 'go' && L.waiting[0]) { if (X.split) { X.sel = L.waiting[0].id; draw(b); } else openOne(L.waiting[0], ctx, { back: true }); return; }
311
+ if (k === 'more-move') { X.all = true; draw(b); return; }
312
+ if (k === 'more-read') { X.allRead = true; draw(b); return; }
313
+ if (k === 'retry') { await load(ctx); draw(b); ctx.redrawList(); return; }
314
+ if (k === 'all-read') { await allRead(ctx, L); return; }
315
+ if (k === 'connect') { import('./cozy-settings.js').then((S) => S.openSettings('connectors')).catch(() => {}); return; }
316
+ if (k === 'check') {
317
+ const r = await ctx.pmPost('/api/sources/refresh-all', { ws: (ctx.board() || {}).ws || '' });
318
+ ctx.toast(r && r.ok ? 'Reading every source now. Mentions update when it is done.' : 'The read did not start: ' + ((r && r.error) || 'the workspace did not answer') + '.');
319
+ return;
320
+ }
321
+ const x = m || (X.split ? find(X.sel) : null);
322
+ if (x) await onAct(ctx, x, k);
323
+ };
324
+ const body = VW.open({ id: 'mentions', kind: 'Mentions', title: 'Mentions', icon: 'at', render: draw });
325
+ // side by side, Claude changes the reply from the chat (pmos mention draft): read again while the list is open, and show the new reply
326
+ const tick = async () => {
327
+ const c = VW.current(); if (!c || c.id !== 'mentions' || !LIST || LIST.body !== body || !body.isConnected) return;
328
+ if (X.split && X.sel && (typeof document === 'undefined' || !document.hidden)) {
329
+ const was = (find(X.sel) || {}).draft;
330
+ await load(ctx);
331
+ const now = find(X.sel) || {};
332
+ if (now.draft !== was && body.isConnected) { const p = body.querySelector('[data-mn-conv] [data-mn-draft]'); if (p && now.draft) p.textContent = now.draft; else draw(body); }
333
+ }
334
+ setTimeout(tick, 5000);
236
335
  };
237
- const body = VW.open({ id: 'mentions', kind: 'Mentions', title: 'Mentions', icon: 'spark', render: draw });
336
+ setTimeout(tick, 5000);
337
+ // the desktop opens wide, so the list and the conversation sit side by side (MnA4); "Back to the side" keeps the one-column list
338
+ if (!(typeof innerWidth === 'number' && innerWidth < 1280)) { VW.wide(true); if (LIST && LIST.body === body && canSplit(body) !== X.split) draw(body); }
339
+ // one column: the asked conversation opens over the list, as a press on its row does
340
+ if (o.sel && !X.split) { const m = find(o.sel); if (m) openOne(m, ctx, { back: true }); }
238
341
  // read again on open, so the list is never older than the press that opened it
239
342
  load(ctx).then(() => { const c = VW.current(); if (c && c.id === 'mentions' && LIST && LIST.body === body) draw(body); ctx.redrawList(); });
240
343
  return body;
241
344
  }
242
345
  function redrawOpen(ctx) {
243
346
  const c = VW.current(); if (!c) return;
244
- if (c.id === 'mentions' && LIST && LIST.body.isConnected) { LIST.body.innerHTML = listHtml(ctx, LIST.X); return; }
347
+ if (c.id === 'mentions' && LIST && LIST.body.isConnected) { LIST.draw(LIST.body); return; }
348
+ if (ONE && ONE.body && ONE.body.isConnected && c.id === 'mention:' + ONE.id) ONE.draw(ONE.body);
245
349
  }
246
350
 
247
351
  /* ── the one-tap acts, each with Undo ── */
248
352
  const SAID = {
249
- answered: (m) => 'Marked answered: ' + first(whoOf(m)) + '’s ' + (isMail(m.source) ? 'email' : 'ask'),
250
- snooze: () => 'Hidden until 09:00 tomorrow',
251
- notask: (m) => 'Not an ask: ' + first(whoOf(m)) + '’s stops counting',
353
+ answered: (m) => 'Marked answered: ' + nameOf(m) + '’s ' + (isMail(m.source) ? 'email' : 'ask'),
354
+ snooze: (m) => 'I’ll bring ' + nameOf(m) + '’s back at 09:00',
355
+ notask: (m) => 'Not an ask: ' + nameOf(m) + '’s stops counting',
252
356
  keep: () => 'Kept waiting. I’ll ask again in 30 days.',
357
+ watch: (m) => 'I’ll watch for ' + ((m.offer && m.offer.what) || 'it') + ' and tell you when it lands',
358
+ nowatch: () => 'I won’t watch for it',
253
359
  };
254
360
  async function act(ctx, m, kind, extra = {}) {
255
361
  const r = await ctx.pmPost('/api/mentions/act', { id: m.id, act: kind, ...extra });
256
362
  if (!r || !r.ok) { ctx.toast('That did not go through' + (r && r.error ? ': ' + r.error : '.')); return false; }
257
363
  await load(ctx);
258
364
  const c = VW.current();
259
- if (c && c.id === 'mention:' + m.id && kind !== 'drafted') VW.back(); else redrawOpen(ctx);
365
+ const gone = ['answered', 'snooze', 'notask'].includes(kind);
366
+ if (c && c.id === 'mention:' + m.id && gone) VW.back(); else redrawOpen(ctx);
260
367
  ctx.redrawList();
261
368
  if (SAID[kind]) ctx.toastUndo(SAID[kind](m), async () => { const u = await ctx.pmPost('/api/mentions/act', { id: m.id, act: 'undo' }); await load(ctx); redrawOpen(ctx); ctx.redrawList(); return u; });
262
369
  return true;
263
370
  }
264
- const taskTitle = (m) => 'Reply to ' + first(whoOf(m));
265
- /** Make it a task: on the mention's initiative when Home's board holds it, else the PM's own tasks. The toast says where, with Undo. */
371
+ async function onAct(ctx, m, k) {
372
+ if (k === 'pen') { ctx.draft(m); return; }
373
+ if (k === 'send') { await sendReply(ctx, m); return; }
374
+ if (k === 'task') { await makeTask(ctx, m); return; }
375
+ if (k === 'src') { const l = https(m.link); if (l) window.open(l, '_blank', 'noopener'); return; }
376
+ if (k === 'ck-yes' || k === 'ck-no') { await act(ctx, m, k === 'ck-yes' ? 'answered' : 'keep'); return; } // a 30+ day ask, asked once
377
+ if (['answered', 'snooze', 'notask', 'watch', 'nowatch'].includes(k)) await act(ctx, m, k);
378
+ }
379
+ /** Opening a conversation that has something unread marks it read (one mark under the conversation's id). */
380
+ function markRead(ctx, m) {
381
+ if (m.read || m.broadcast || !(m.fyi || m.since_reply)) return;
382
+ m.read = true;
383
+ ctx.pmPost('/api/mentions/act', { id: m.id, act: 'read' }).then((r) => { if (r && r.ok) { const D = ctx.D(); for (const x of allOf(mentionsOf(D))) if (x.id === m.id) x.read = true; ctx.redrawList(); } });
384
+ }
385
+ /** ✓✓: every To read conversation not opened yet, read at once. */
386
+ async function allRead(ctx, L) {
387
+ const ids = L.toread.filter((m) => !m.read && !m.broadcast).map((m) => m.id); if (!ids.length) return;
388
+ const r = await ctx.pmPost('/api/mentions/act', { ids, act: 'read' });
389
+ if (!r || !r.ok) { ctx.toast('That did not go through' + (r && r.error ? ': ' + r.error : '.')); return; }
390
+ await load(ctx); redrawOpen(ctx); ctx.redrawList();
391
+ }
392
+ const taskTitle = (m) => 'Reply to ' + nameOf(m);
393
+ /** Make it a task: on the conversation's initiative when Home's board holds it, else the PM's own tasks. The toast says where, with Undo. */
266
394
  async function makeTask(ctx, m) {
267
395
  const title = taskTitle(m);
268
396
  const b = ctx.board() || {};
@@ -278,7 +406,7 @@ async function makeTask(ctx, m) {
278
406
  task = { id: r.item.id, kind: 'item', title };
279
407
  }
280
408
  const r2 = await ctx.pmPost('/api/mentions/act', { id: m.id, act: 'task', task });
281
- if (!r2 || !r2.ok) { ctx.toast('The task was added, but the mention still waits: ' + ((r2 && r2.error) || 'the workspace did not answer') + '.'); return; }
409
+ if (!r2 || !r2.ok) { ctx.toast('The task was added, but the conversation still waits: ' + ((r2 && r2.error) || 'the workspace did not answer') + '.'); return; }
282
410
  await load(ctx);
283
411
  const c = VW.current(); if (c && c.id === 'mention:' + m.id) VW.back(); else redrawOpen(ctx);
284
412
  ctx.reload();
@@ -289,79 +417,96 @@ async function makeTask(ctx, m) {
289
417
  return u;
290
418
  });
291
419
  }
292
- /** Send: PMOS never posts. It copies the reply, opens the source, and the row says the draft waits to be sent there. */
420
+ /** Send: PMOS never posts. It copies the reply, opens the source, and the row says "Sent from Slack? I’ll see it at the next read." */
293
421
  async function sendReply(ctx, m) {
294
422
  const text = m.draft || '';
295
423
  let copied = false;
296
424
  try { if (text && navigator.clipboard) { await navigator.clipboard.writeText(text); copied = true; } } catch { copied = false; }
297
425
  const l = https(m.link); if (l) window.open(l, '_blank', 'noopener');
298
426
  await act(ctx, m, 'drafted', { to: srcName(m.source) });
299
- ctx.toast((copied ? 'Copied. ' : 'Copy the reply, then ') + 'Paste it in ' + srcName(m.source) + ' to send it.' + (l ? '' : ' This mention has no link, so open ' + srcName(m.source) + ' yourself.'));
427
+ ctx.toast((copied ? 'Copied. ' : 'Copy the reply, then ') + 'Paste it in ' + sendIn(m.source) + ' to send it.' + (l ? '' : ' This conversation has no link, so open ' + sendIn(m.source) + ' yourself.'));
300
428
  }
301
429
 
302
- /* ── one mention (XmsMentionsGrill 3, XmsDeskOne, XmsDeskRefine) ── */
303
- const hm = (at) => (T(at) ? hmOf(T(at)) : '');
304
- const ini2 = (who) => esc(String(who || '?').replace(/[^A-Za-z]/g, '').slice(0, 2) || '?');
305
- const msgHtml = (x, me) => `<div class="hr-msg${me ? ' me' : ''}"><span class="hr-av" aria-hidden="true">${ini2(x.who)}</span><span class="hr-w"><small><b>${esc(x.who || 'Someone')}</b>${hm(x.at) ? ' · ' + hm(x.at) : ''}</small><span>${esc(x.text)}</span></span></div>`;
306
- /** The source messages, with the asker's outlined. Only what the record holds: the thread when the read kept it, else the mention's words. */
307
- export function excerptHtml(m) {
308
- const own = { who: whoOf(m), at: m.since || m.last, text: m.text || '' };
309
- const thread = Array.isArray(m.thread) && m.thread.length ? m.thread : null;
310
- const mine = (x) => !m.who || x.who === m.who;
311
- const msgs = thread ? thread.map((x) => msgHtml(x, mine(x))).join('') : msgHtml(own, true);
312
- if (isMail(m.source)) return `<div class="hr-mail">${m.where ? `<b>${esc(m.where)}</b>` : ''}</div><div class="hr-thr">${msgs}</div>`;
313
- return `<div class="hr-thr">${msgs}</div>`;
430
+ /* ── one conversation (MnA3, MnA4) ── */
431
+ /** The messages, by day; the PM's on the right (the store marks them me: true). Only what the record holds: the thread when the read kept
432
+ * it, else the conversation's latest words. */
433
+ export function messagesHtml(m) {
434
+ const th = Array.isArray(m.thread) && m.thread.length ? m.thread : [{ who: m.who, at: m.since || m.last, text: m.text || '' }];
435
+ const many = peopleOf(m).length > 1;
436
+ let out = '', cur = '';
437
+ for (const x of th) {
438
+ const d = T(x.at) ? dayLabel(x.at) : '';
439
+ if (d && d !== cur) { out += `<p class="mn-day">${esc(d)}</p>`; cur = d; }
440
+ out += `<div class="mn-msg${x.me ? ' me' : ''}">${many && !x.me ? `<small>${esc(first(x.who))}</small>` : ''}<span>${esc(x.text)}</span></div>`;
441
+ }
442
+ return `<div class="mn-thr">${out}</div>`;
314
443
  }
315
- function oneHtml(m, ctx) {
444
+ function statusLine(m) {
445
+ if (m.since_reply) return 'New since your reply';
446
+ if (m.status === 'replied') return 'You replied in the thread';
447
+ if (m.status === 'answered') return 'You marked it answered';
448
+ if (m.status === 'task') return 'A task now: ' + ((m.task && m.task.title) || taskTitle(m));
449
+ if (m.status === 'notask') return 'You said it is not an ask';
450
+ return m.broadcast ? 'To everyone in ' + placeOf(m) : 'For your information';
451
+ }
452
+ export function convHtml(m, ctx, o = {}) {
316
453
  const now = Date.now();
317
- const line = m.waiting ? 'Waiting on you · ' + age(m.since, now) : m.status ? statusLine(m) : 'Mentioned you · ' + age(m.last, now) + ' ago';
318
- const text = m.about || (m.ask ? askOf(m) + '.' : whoOf(m) + (m.fyi ? ' named you in ' : ' asks you something in ') + placeOf(m) + '.');
319
- const meta = [m.where || srcName(m.source), m.initiative ? ctx.iniTitle(m.initiative) : '', m.initiative ? ctx.stageOf(m.initiative) : ''].filter(Boolean).join(' · ');
320
- const icons = m.waiting ? [['answered', 'Mark answered', P.tick], ['snooze', 'Remind me tomorrow', P.clock], ['task', 'Make it a task', P.task], ['notask', 'Not an ask', P.x]]
321
- .map(([k, l, d]) => `<button type="button" class="czs-ib hr-ia" data-hr-one="${k}" aria-label="${esc(l)}" title="${esc(l)}">${svg(d, 17, 2)}</button>`).join('') : '';
322
- const sum = `<div class="czs-sum hr-one"><div class="czs-line${m.waiting ? ' warn' : ''}">${m.waiting ? '<span class="czs-dot" aria-hidden="true"></span>' : ''}<span>${esc(line)}</span></div>`
323
- + `<p class="czs-p">${esc(text)}</p>${meta ? `<p class="czs-meta">${esc(meta)}</p>` : ''}${icons ? `<div class="czs-acts hr-acts">${icons}</div>` : ''}</div>`;
324
- const found = Array.isArray(m.found) && m.found.length
325
- ? `<div class="hr-card2 hr-found"><b class="hr-h">What I found</b><ul>${m.found.map((f) => `<li>${f.label ? `<b>${esc(f.label)}</b>${f.text ? ' ' + esc(f.text) : ''}` : esc(f.text)}</li>`).join('')}</ul></div>` : '';
326
- const reply = m.waiting || m.draft
327
- ? `<div class="hr-card2 hr-reply"><b class="hr-h">Proposed reply</b>${m.draft ? `<p class="hr-rtxt" data-hr-draft>${esc(m.draft)}</p>` : '<p class="hr-none">No reply proposed yet. Write it with Claude.</p>'}`
328
- + `<div class="hr-racts"><button type="button" class="czs-ib" data-hr-one="pen" aria-label="${m.draft ? 'Change it with Claude' : 'Write it with Claude'}" title="${m.draft ? 'Change it with Claude' : 'Write it with Claude'}">${svg(P.pen, 16, 2)}</button>`
329
- + (m.draft ? `<button type="button" class="hr-rp" data-hr-one="send" aria-label="${esc('Copy it and open ' + srcName(m.source))}" title="${esc('Copy it and open ' + srcName(m.source) + '. PMOS never posts.')}">${svg(P.send, 17, 2.2)}</button>` : '') + '</div></div>'
330
- : '';
331
- const n = Array.isArray(m.thread) ? m.thread.filter((x) => !m.who || x.who === m.who).length : 1;
332
- const secs = VW.czSections([{ id: 'msgs', title: first(whoOf(m)) + '’s ' + (n === 1 ? 'message' : n + ' messages'), open: false, html: excerptHtml(m) },
333
- !m.waiting && https(m.link) ? { id: 'src', title: 'Open in ' + srcName(m.source), on: 'src' } : null], { key: 'mention' });
334
- return '<div class="hr-vb">' + sum + found + reply + secs + '</div>';
454
+ const four = [['answered', 'Mark answered', P.tick], ['snooze', 'Remind me at 09:00', P.clock], ['task', 'Make it a task', P.task], ['notask', 'Not an ask', P.x]]
455
+ .map(([k, l, d]) => ib(`data-mn="${k}" data-id="${esc(m.id)}"`, l, d)).join('');
456
+ const head = o.split ? `<div class="mn-ch">${face(m)}<div class="mn-cht"><b>${esc(fullNames(m))}</b><small>${esc(subOf(m))}</small></div>${https(m.link) ? ib(`data-mn="src" data-id="${esc(m.id)}"`, 'Open in ' + srcName(m.source), P.out) : ''}</div>` : '';
457
+ let top;
458
+ if (m.waiting) {
459
+ const reply = m.drafted ? draftHtml(m) : m.draft ? `<div class="mn-dr in"><p class="mn-drh">${svg(P.spark, 12, 2)}<span>I drafted your reply</span></p><p data-mn-draft>${esc(m.draft)}</p></div>`
460
+ : m.nodraft ? `<div class="mn-dr no in"><p class="mn-drh">${svg(P.spark, 12, 2)}<span>I can’t draft this one</span></p><p>${esc(m.nodraft)}</p></div>` : '';
461
+ const right = m.draft && !m.drafted ? ib(`data-mn="pen" data-id="${esc(m.id)}"`, 'Change it with Claude', P.pen) + ib(`data-mn="send" data-id="${esc(m.id)}"`, 'Copy it and open ' + srcName(m.source) + '. PMOS never posts.', P.send, true)
462
+ : m.drafted ? '' : ib(`data-mn="pen" data-id="${esc(m.id)}"`, 'Write it with Claude', P.pen, true);
463
+ top = `<div class="mn-ask"><p class="mn-ak${late(m.since, now) ? ' late' : ''}">Asks you · ${esc(age(m.since, now))}</p><p class="mn-aq">${esc(m.ask || gistOf(m))}</p>${reply}`
464
+ + `<div class="mn-acts sp"><span class="mn-four">${four}</span><span>${right}</span></div>${checkHtml(m)}</div>`;
465
+ } else top = `<div class="mn-ask calm"><p class="mn-ak">${esc(statusLine(m))}</p><p class="mn-aq">${esc(gistOf(m))}</p></div>`;
466
+ const st = m.stands && m.stands.settled && m.stands.settled.length
467
+ ? `<div class="mn-card"><p class="mn-h">${svg(P.spark, 13, 2)}<b>Where it stands</b></p><ul class="mn-st">${m.stands.settled.map((t) => `<li>${svg(P.tick, 14, 2.2)}<span>${esc(t)}</span></li>`).join('')}`
468
+ + (m.stands.open || []).map((t) => `<li class="open">${svg(P.clock, 14, 2)}<span>${esc(t)}</span></li>`).join('') + '</ul></div>' : '';
469
+ const watch = m.offer ? `<div class="mn-card mn-watch">${svg(P.spark, 13, 2)}<p>${esc(m.offer.text)}</p>${ib(`data-mn="nowatch" data-id="${esc(m.id)}"`, 'No, don’t watch', P.x)}${ib(`data-mn="watch" data-id="${esc(m.id)}"`, 'Yes, watch for it', P.tick, true)}</div>`
470
+ : m.watch ? `<p class="mn-wl">${svg(P.spark, 12, 2)}<span>I’m watching for ${esc(m.watch.what)}.</span></p>`
471
+ : m.landed ? `<p class="mn-wl">${svg(P.spark, 12, 2)}<span>${esc(m.landed.text)}</span></p>` : '';
472
+ const found = Array.isArray(m.found) && m.found.length && m.waiting
473
+ ? `<div class="mn-card"><p class="mn-h">${svg(P.spark, 13, 2)}<b>What I found</b></p><ul class="mn-fd">${m.found.map((f) => `<li>${f.label ? `<b>${esc(f.label)}</b>${f.text ? ' ' + esc(f.text) : ''}` : esc(f.text)}</li>`).join('')}</ul></div>` : '';
474
+ const secs = VW.czSections([{ id: 'msgs', title: 'The messages', count: m.messages || 1, open: !!o.split, html: messagesHtml(m) }], { key: o.split ? 'mention-desk' : 'mention' });
475
+ return `<div class="mn-vb">${head}${top}${st}${watch}${found}${secs}</div>`;
476
+ }
477
+ /** "#tech-team-cem · 9 messages since Mon" */
478
+ function subOf(m) {
479
+ const n = m.messages || 1, f = T(m.first);
480
+ const since = f ? (daysAgo(f, Date.now()) <= 0 ? ' today' : ' since ' + (daysAgo(f, Date.now()) === 1 ? 'yesterday' : WD[new Date(f).getDay()])) : '';
481
+ return placeOf(m) + ' · ' + n + (n === 1 ? ' message' : ' messages') + since;
335
482
  }
483
+ let ONE = null; // the conversation Viewer that is open: { id, body, draw }
336
484
  export function openOne(m, ctx, o = {}) {
337
485
  sheet();
338
486
  const id = m.id;
339
- const cur = () => { const L = mentionsOf(ctx.D()); return [...L.waiting, ...L.recent].find((x) => x.id === id) || m; };
340
- if (m.fyi && !m.read) ctx.pmPost('/api/mentions/read', { id, read: true }).then((r) => { if (r && r.ok) { m.read = true; const c = cur(); c.read = true; redrawOpen(ctx); } });
487
+ const cur = () => allOf(mentionsOf(ctx.D())).find((x) => x.id === id) || m;
488
+ markRead(ctx, m);
341
489
  let body = null;
342
490
  const draw = (b) => {
343
- body = b;
344
- b.innerHTML = oneHtml(cur(), ctx);
491
+ body = b; ONE = { id, body: b, draw };
492
+ b.innerHTML = convHtml(cur(), ctx);
345
493
  b.onclick = async (e) => {
346
- const t = e.target.closest('[data-hr-one],[data-czs-act]'); if (!t || !b.contains(t)) return;
347
- const k = t.dataset.hrOne || t.dataset.czsAct, x = cur();
348
- if (k === 'src') { const l = https(x.link); if (l) window.open(l, '_blank', 'noopener'); return; }
349
- if (k === 'pen') { ctx.draft(x); return; }
350
- if (k === 'send') { await sendReply(ctx, x); if (body && body.isConnected) draw(body); return; }
351
- if (k === 'task') { await makeTask(ctx, x); return; }
352
- if (k === 'answered' || k === 'snooze' || k === 'notask') await act(ctx, x, k);
494
+ const t = e.target.closest('[data-mn]'); if (!t || !b.contains(t)) return;
495
+ await onAct(ctx, cur(), t.dataset.mn);
353
496
  };
354
497
  };
355
- const args = { id: 'mention:' + id, kind: 'Mention', title: whoOf(m) + ' · ' + (m.where || srcName(m.source)), icon: ICON[m.source] || 'at', render: draw };
356
- const out = VW.open({ ...args, back: !!o.back });
357
- // Claude changes the reply from the chat (pmos mention draft): read again while this mention is open, and show the new reply
498
+ const x = cur();
499
+ const out = VW.open({ id: 'mention:' + id, kind: 'Mention', title: fullNames(x), sub: subOf(x), icon: 'at', render: draw, back: !!o.back,
500
+ presses: https(x.link) ? [{ act: 'src', label: 'Open in ' + srcName(x.source), icon: P.out }] : null,
501
+ onPress: (k) => { if (k === 'src') onAct(ctx, cur(), 'src'); } });
502
+ // Claude changes the reply from the chat (pmos mention draft): read again while this conversation is open, and show the new reply
358
503
  const tick = async () => {
359
504
  const c = VW.current(); if (!c || c.id !== 'mention:' + id || !body || !body.isConnected) return;
360
505
  if (typeof document === 'undefined' || !document.hidden) {
361
506
  const was = cur().draft;
362
507
  await load(ctx);
363
508
  const now = cur();
364
- if (now.draft !== was && body.isConnected) { const p = body.querySelector('[data-hr-draft]'); if (p) p.textContent = now.draft; else draw(body); }
509
+ if (now.draft !== was && body.isConnected) { const p = body.querySelector('[data-mn-draft]'); if (p) p.textContent = now.draft; else draw(body); }
365
510
  }
366
511
  setTimeout(tick, 5000);
367
512
  };