create-pmos 0.437.0 → 0.439.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 (60) 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 +1 -0
  12. package/workspace/guide/notes.md +5 -2
  13. package/workspace/home-rows-test.js +16 -0
  14. package/workspace/lib/notes-whisper.js +33 -11
  15. package/workspace/lib/notes.js +6 -4
  16. package/workspace/lib/routes-notes.js +94 -13
  17. package/workspace/package-lock.json +2 -2
  18. package/workspace/package.json +1 -1
  19. package/workspace/premium-chat-context-test.js +20 -0
  20. package/workspace/public/pm/bd-asks.js +5 -2
  21. package/workspace/public/pm/bd-deliveries.js +11 -2
  22. package/workspace/public/pm/cozy-adler.css +7 -1
  23. package/workspace/public/pm/cozy-adler.js +17 -0
  24. package/workspace/public/pm/cozy-board.css +5 -0
  25. package/workspace/public/pm/cozy-ev.css +8 -0
  26. package/workspace/public/pm/cozy-home.css +7 -0
  27. package/workspace/public/pm/cozy-live-pill.css +2 -0
  28. package/workspace/public/pm/cozy-live-pill.js +6 -3
  29. package/workspace/public/pm/cozy-nav.js +18 -5
  30. package/workspace/public/pm/cozy-pull.js +62 -0
  31. package/workspace/public/pm/cozy-rec-now.js +3 -1
  32. package/workspace/public/pm/cozy-rec-tab.css +2 -0
  33. package/workspace/public/pm/cozy-rec-tab.js +18 -1
  34. package/workspace/public/pm/cozy-settings.js +14 -5
  35. package/workspace/public/pm/cozy-steps.css +3 -0
  36. package/workspace/public/pm/cozy-steps.js +5 -4
  37. package/workspace/public/pm/cozy-today.css +5 -0
  38. package/workspace/public/pm/home-app.js +33 -2
  39. package/workspace/public/pm/home-day.js +39 -5
  40. package/workspace/public/pm/home-mentions.js +13 -2
  41. package/workspace/public/pm/home-review.js +9 -1
  42. package/workspace/public/pm/home-stage-card.js +9 -3
  43. package/workspace/public/pm/impact.css +1 -0
  44. package/workspace/public/pm/impact.js +5 -2
  45. package/workspace/public/pm/ini-tasks.js +19 -3
  46. package/workspace/public/pm/premium-board.js +12 -4
  47. package/workspace/public/pm/premium-shell.js +12 -4
  48. package/workspace/public/pm/premium-vw-ctx.js +16 -2
  49. package/workspace/public/pm/premium-vw-doc-model.js +11 -0
  50. package/workspace/public/pm/premium-vw-doc.css +2 -0
  51. package/workspace/public/pm/premium-vw-doc.js +8 -2
  52. package/workspace/public/pm/premium-vw-mtg.js +3 -1
  53. package/workspace/public/pm/premium.css +14 -0
  54. package/workspace/public/pm/program-charter.js +2 -1
  55. package/workspace/public/pm/session-rail.js +12 -5
  56. package/workspace/public/premium-rec.html +1 -1
  57. package/workspace/task-views-test.js +10 -1
  58. package/workspace/test-lists/adler-followups.json +9 -0
  59. package/workspace/test-lists/batch17-adler-moments.json +13 -0
  60. package/workspace/test-lists/notes-transcript-recovery.json +9 -0
@@ -396,16 +396,55 @@ function vocabFor(ctx, id) {
396
396
  /* ── local transcription: one transcriber for the process ─────────────────────────────────────── */
397
397
  /* THE LIVE ENGINE (Run 10). Qwen3-ASR when it is set up (lib/notes-qwen.js: more accurate, Chinese and Indonesian too, kept
398
398
  * loaded so each cut is quick), else whisper.cpp. ctx.notesQwenDetect and ctx.notesQwenRun replace them in the suites. */
399
+ /* RECOVERY (notes-transcript-recovery). When Qwen3-ASR fails QWEN_FAILS cuts in a row (it stopped, timed out, or the machine
400
+ * is short of memory), the live transcript goes on with whisper.cpp for QWEN_REST_MS when whisper.cpp is set up, and then tries
401
+ * Qwen3-ASR again. Without whisper.cpp, Qwen3-ASR is started again on the next cut, as before. */
402
+ const QWEN_FAILS = 3;
403
+ const QWEN_REST_MS = 5 * 60 * 1000;
404
+ let qwenFails = 0; let qwenRestUntil = 0;
399
405
  function qwenDetect(ctx) { return ctx.notesQwenDetect ? ctx.notesQwenDetect() : notesQwen.detect(ctx.runtimeDir); }
406
+ function whisperDetect(ctx) { return ctx.notesWhisperDetect ? ctx.notesWhisperDetect() : whisper.detect(ctx.runtimeDir); }
400
407
  function liveDetect(ctx) {
401
408
  const q = qwenDetect(ctx);
409
+ if (q.ready && Date.now() < qwenRestUntil) { const w = whisperDetect(ctx); if (w.ready) return { ...w, engine: 'whisper' }; }
402
410
  if (q.ready) return { ready: true, engine: 'qwen', model: q.live, bin: null };
403
- return { ...whisper.detect(ctx.runtimeDir), engine: 'whisper' };
411
+ return { ...whisperDetect(ctx), engine: 'whisper' };
404
412
  }
405
- function liveRun(ctx, args) {
406
- if (args.engine !== 'qwen') return whisper.runWhisper(args);
407
- if (ctx.notesQwenRun) return ctx.notesQwenRun(args);
408
- return notesQwen.runQwen(notesQwen.workerFor(ctx.runtimeDir), args);
413
+ async function liveRun(ctx, args) {
414
+ if (args.engine !== 'qwen') return ctx.notesWhisperRun ? ctx.notesWhisperRun(args) : whisper.runWhisper(args);
415
+ const r = await (ctx.notesQwenRun ? ctx.notesQwenRun(args) : notesQwen.runQwen(notesQwen.workerFor(ctx.runtimeDir), args));
416
+ if (r && r.ok) qwenFails = 0;
417
+ else if (++qwenFails >= QWEN_FAILS) { qwenFails = 0; qwenRestUntil = Date.now() + QWEN_REST_MS; }
418
+ return r;
419
+ }
420
+ /* GAPS (notes-transcript-recovery). A cut the transcriber skipped or could not transcribe is kept here as a stretch of the
421
+ * meeting clock; when the transcriber has caught up, the next audio chunk of the note hands the oldest stretch back from the
422
+ * kept audio (transcriber.fill), FILL_PIECE_MS at a time, at most FILL_TRIES times. The lines land in the transcript at their
423
+ * own time, marked filled. What still fails is covered by the final pass after Stop, which reads the whole kept audio. */
424
+ const FILL_PIECE_MS = 25000;
425
+ const FILL_TRIES = 3;
426
+ const MAX_GAPS = 200;
427
+ const gaps = new Map(); // note id → [{ source, t, ms, tries }], oldest first
428
+ function addGap(c) {
429
+ if (!c || !c.id || !(c.ms > 0) || (c.tries || 0) >= FILL_TRIES) return;
430
+ const xs = gaps.get(c.id) || [];
431
+ const last = xs.length ? xs[xs.length - 1] : null;
432
+ // a stretch straight after the last one of its source, at the same try, is the same gap
433
+ if (last && last.source === c.source && last.tries === (c.tries || 0) && Math.abs(last.t + last.ms - c.t) <= 1500) last.ms = c.t + c.ms - last.t;
434
+ else xs.push({ source: c.source, t: c.t, ms: c.ms, tries: c.tries || 0 });
435
+ if (xs.length > MAX_GAPS) xs.shift();
436
+ gaps.set(c.id, xs);
437
+ }
438
+ function fillGaps(ctx, id, tr) {
439
+ const xs = gaps.get(id);
440
+ if (!xs || !xs.length || !tr.fill) return;
441
+ const g = xs[0];
442
+ const ms = Math.min(g.ms, FILL_PIECE_MS);
443
+ const from = Math.round(g.t * whisper.RATE / 1000); const to = Math.round((g.t + ms) * whisper.RATE / 1000);
444
+ const back = notesAudio.readSource(ctx.runtimeDir, id, g.source, from, to);
445
+ if (back && back.pcm.length && !tr.fill({ id, source: g.source, pcm: back.pcm, t: (back.from / whisper.RATE) * 1000, tries: g.tries })) return;
446
+ if (g.ms - ms > 500) { g.t += ms; g.ms -= ms; } else xs.shift();
447
+ if (!xs.length) gaps.delete(id);
409
448
  }
410
449
  let transcriber = null; let transcriberDir = null;
411
450
  const audioErrors = new Map(); // note id → the last thing that went wrong, for the page
@@ -433,10 +472,11 @@ function transcriberFor(ctx) {
433
472
  return null;
434
473
  },
435
474
  onText: async (c) => {
436
- const r = notes.appendTranscript(ctx.runtimeDir, { id: c.id, text: c.text, source: c.source, t: c.t, ms: c.ms, heard_as: c.heard_as });
475
+ const r = notes.appendTranscript(ctx.runtimeDir, { id: c.id, text: c.text, source: c.source, t: c.t, ms: c.ms, heard_as: c.heard_as, fill: c.fill === true });
437
476
  if (r.ok) { audioErrors.delete(c.id); arm(ctx, c.id); }
438
477
  },
439
478
  onError: (c) => { audioErrors.set(c.id, { at: new Date().toISOString(), error: c.error }); },
479
+ onSkip: (c) => addGap(c),
440
480
  // how far the live transcription has cut each source, kept with the capture so a restart picks up what it had buffered
441
481
  onCut: (c) => { try { notesCapture.setCut(ctx.runtimeDir, c.id, { source: c.source, sample: Math.round(c.until * whisper.RATE / 1000) }); } catch { /* best effort */ } },
442
482
  });
@@ -501,11 +541,14 @@ function finalInfo(ctx) {
501
541
  const d = ctx.notesFinalDetect ? ctx.notesFinalDetect() : notesFinal.detect(ctx.runtimeDir);
502
542
  return { ready: !!d.ready && !finalOff(ctx), transcriber: d.transcriber || null, vad: !!d.vad, speakers: !!d.diarize, missing: d.missing || [], setup: d.setup || '' };
503
543
  }
504
- /** Queue the final pass of a note when it can run. → { queued, reason } */
505
- function queueFinal(ctx, id) {
544
+ /** Queue the final pass of a note when it can run. A pass already queued or running in this process is kept, unless `force`
545
+ * (the PM asks for it again). → { queued, reason } */
546
+ function queueFinal(ctx, id, { force = false } = {}) {
506
547
  const dir = ctx.runtimeDir;
507
548
  const cur = notes.read(dir, id);
508
549
  if (!cur.ok || cur.note.private) return { queued: false, reason: 'this note is marked private' };
550
+ const now = !force && finalRunner && finalRunner.state(id);
551
+ if (now && (now.state === 'queued' || now.state === 'running')) return { queued: true, reason: '' };
509
552
  if (finalOff(ctx)) return { queued: false, reason: 'the final pass is switched off on this machine' };
510
553
  const info = finalInfo(ctx);
511
554
  if (!info.ready) return { queued: false, reason: 'local transcription is not set up' };
@@ -516,6 +559,30 @@ function queueFinal(ctx, id) {
516
559
  return { queued: true, reason: '' };
517
560
  }
518
561
  function cancelFinal(ctx, id) { if (finalRunner) finalRunner.cancel(id); }
562
+ /* STOP WRITES THE NOTES (notes-transcript-recovery). The page used to ask for the final pass after Stop (summarize with
563
+ * prefer 'agent'), and a Stop that did not come from the page that listened (the recording tab after Pause, the Viewer, a phone)
564
+ * never asked, so the notes were written from the live transcript alone, and a live transcript with gaps gave notes with gaps.
565
+ * Stop now queues the final pass itself: the whole kept audio is transcribed again, and the agent writes the notes from that.
566
+ * Without an engine or audio, the agent writes them from the live transcript at once. A later summarize from the page finds
567
+ * the pass queued (queueFinal keeps it) or the agent already asked (agentAsked), and starts nothing twice. */
568
+ function agentAsked(note) {
569
+ const a = note && note.agent;
570
+ if (!a || !a.started || a.imported_at) return false;
571
+ const asked = Date.parse(a.requested_at) || 0; const ended = Date.parse(note.ended_at) || 0;
572
+ return asked >= ended - 1000;
573
+ }
574
+ function finishAfterStop(ctx, id, ws) {
575
+ const dir = ctx.runtimeDir;
576
+ const cur = notes.read(dir, id);
577
+ if (!cur.ok || cur.note.private) return;
578
+ const q = queueFinal(ctx, id);
579
+ if (q.queued) return;
580
+ const n = cur.note;
581
+ if (!(n.transcript || []).length && !String(n.body || '').trim()) return;
582
+ if (agentAsked(n)) return;
583
+ const w = ws && ws.ok && ws.w ? ws.w : (n.ws ? ctx.getWs(n.ws) : null);
584
+ startAgent(ctx, dir, id, w && (!n.ws || w.id === n.ws) ? w : null);
585
+ }
519
586
 
520
587
  const WISPR_DELAY_MS = 5 * 60 * 1000;
521
588
  const WISPR_RETRY_MS = 2 * 60 * 1000;
@@ -627,7 +694,11 @@ function mergeWispr(ctx, id) {
627
694
  * reason, and the agent writes the notes from the live transcript, as Stop does without an engine;
628
695
  * - a summary run that was started, wrote nothing and is no longer a session is started again;
629
696
  * - a Wispr Flow check that was waiting or asking carries on from its own clock, or ends as failed once its deadline
630
- * after Stop is past (the PM can press Fetch to try again). */
697
+ * after Stop is past (the PM can press Fetch to try again);
698
+ * - a meeting that ended in the last BACKFILL_MS with no final pass at all (its Stop never asked for one) gets it now, from
699
+ * its kept audio, at most BACKFILL_MAX of them; the agent then writes its notes again from the whole meeting. */
700
+ const BACKFILL_MS = 14 * 24 * 60 * 60 * 1000;
701
+ const BACKFILL_MAX = 10;
631
702
  let resumedFor = null;
632
703
  function resumeStuck(ctx) {
633
704
  const dir = ctx.runtimeDir;
@@ -643,6 +714,7 @@ function resumeStuck(ctx) {
643
714
  return live;
644
715
  };
645
716
  const wsFor = (n) => { const w = n.ws ? ctx.getWs(n.ws) : null; return w && w.id === n.ws ? w : null; };
717
+ let backfill = BACKFILL_MAX;
646
718
  for (const row of l.notes) {
647
719
  const cur = notes.read(dir, row.id);
648
720
  if (!cur.ok || cur.note.private || listening(cur.note)) continue;
@@ -657,6 +729,11 @@ function resumeStuck(ctx) {
657
729
  if (!a || (!a.imported_at && !a.started)) { startAgent(ctx, dir, n.id, wsFor(n)); done.push({ id: n.id, final: 'failed', agent: 'started' }); }
658
730
  else done.push({ id: n.id, final: 'failed' });
659
731
  }
732
+ } else if (!fst && backfill > 0 && n.ended_at && Date.now() - (Date.parse(n.ended_at) || 0) <= BACKFILL_MS && n.recorded_from
733
+ && !(n.final && (n.final.segments || []).length) && !(finalRunner && finalRunner.state(n.id))) {
734
+ // ended without a final pass (a Stop that did not ask for it, before notes-transcript-recovery): it runs now, from the kept audio
735
+ const q = queueFinal(ctx, n.id);
736
+ if (q.queued) { backfill--; done.push({ id: n.id, final: 'queued', backfill: true }); }
660
737
  } else if (n.agent && n.agent.started && !n.agent.imported_at && !(n.agent.out && fs.existsSync(n.agent.out)) && n.agent.session && !liveIds().has(n.agent.session)) {
661
738
  startAgent(ctx, dir, n.id, wsFor(n));
662
739
  done.push({ id: n.id, agent: 'started' });
@@ -845,7 +922,7 @@ async function handle(req, res, url, ctx) {
845
922
  if (p === '/api/notes/stop') {
846
923
  const r = notes.stop(dir, { id, resumeMs: resumeMsOf(ctx) });
847
924
  notesCapture.close(dir, id);
848
- if (r.ok) { clearExpiry(id); swept.add(id); disarm(id); runMinute(ctx, id, { final: true }); scheduleWispr(ctx, id); }
925
+ if (r.ok) { clearExpiry(id); swept.add(id); disarm(id); runMinute(ctx, id, { final: true }); scheduleWispr(ctx, id); gaps.delete(id); finishAfterStop(ctx, id, wsOf()); }
849
926
  return done(r);
850
927
  }
851
928
  if (p === '/api/notes/transcript') {
@@ -905,6 +982,8 @@ async function handle(req, res, url, ctx) {
905
982
  }
906
983
  const pushed = tr.push({ id, source, pcm, t, final: body.final === true, exact: !!cap });
907
984
  if (cap) notesCapture.mark(dir, id, { source, seq: body.seq, end: sample + pcm.length / 2 });
985
+ // the transcriber has caught up: a stretch it skipped earlier is read back from the kept audio and transcribed now
986
+ if (gaps.has(id) && tr.pending() < whisper.FILL_ROOM) fillGaps(ctx, id, tr);
908
987
  return done(pushed);
909
988
  }
910
989
  if (p === '/api/notes/label') return done(notes.setLabel(dir, { id, index: Number(body.index), cat: body.cat, drop: body.drop === true }));
@@ -915,7 +994,7 @@ async function handle(req, res, url, ctx) {
915
994
  if (p === '/api/notes/final') {
916
995
  // the PM asks for the final pass again, for example after setting up a better engine
917
996
  if (!notes.read(dir, id).ok) return done(notes.read(dir, id));
918
- const q = queueFinal(ctx, id);
997
+ const q = queueFinal(ctx, id, { force: true });
919
998
  return done(q.queued ? { ok: true, queued: true } : { ok: false, status: 409, error: q.reason });
920
999
  }
921
1000
  if (p === '/api/notes/bullet') return done(notes.editBullet(dir, { id, bid: body.bullet, cat: body.cat, drop: body.drop, text: body.text, owner: body.owner, due: body.due }));
@@ -1023,7 +1102,7 @@ async function handle(req, res, url, ctx) {
1023
1102
  if (p === '/api/notes/private') {
1024
1103
  vocabCache.delete(id);
1025
1104
  const r = notes.setPrivate(dir, { id, private: body.private });
1026
- if (r.ok && r.private) { clearExpiry(id); disarm(id); unwatchLate(id); cancelFinal(ctx, id); unwatchWispr(id); if (transcriber) transcriber.drop(id); notesAudio.remove(dir, id); notesCapture.remove(dir, id); notesScreen.remove(dir, id); }
1105
+ if (r.ok && r.private) { gaps.delete(id); clearExpiry(id); disarm(id); unwatchLate(id); cancelFinal(ctx, id); unwatchWispr(id); if (transcriber) transcriber.drop(id); notesAudio.remove(dir, id); notesCapture.remove(dir, id); notesScreen.remove(dir, id); }
1027
1106
  return done(r);
1028
1107
  }
1029
1108
  if (p === '/api/notes/summarize') {
@@ -1045,6 +1124,8 @@ async function handle(req, res, url, ctx) {
1045
1124
  // with kept audio and an engine, the final pass runs first and the agent writes the notes from it (Run 9)
1046
1125
  const q = cur.ok && !cur.note.private ? queueFinal(ctx, id) : { queued: false };
1047
1126
  if (q.queued) { r.final = { state: 'queued' }; r.agent = { started: false, waiting: 'final', reason: '' }; r.source = 'agent'; return done(r); }
1127
+ // Stop already asked the agent (finishAfterStop): the same run is answered, not a second one started
1128
+ if (cur.ok && agentAsked(cur.note)) { const a = cur.note.agent; r.agent = { started: true, session: a.session || null, withheld: a.withheld, out: a.out, reason: '' }; r.source = 'agent'; return done(r); }
1048
1129
  const ag = cur.ok && cur.note.private ? { ok: false, error: 'this note is marked private, so it is not handed to any agent or service' }
1049
1130
  : startAgent(ctx, dir, id, ws.ok ? ws.w : null);
1050
1131
  r.agent = ag.ok ? (({ ok, ...x }) => x)(ag) : { started: false, reason: ag.error || 'the agent could not be asked' };
@@ -1052,7 +1133,7 @@ async function handle(req, res, url, ctx) {
1052
1133
  }
1053
1134
  return done(r);
1054
1135
  }
1055
- if (p === '/api/notes/delete') { clearExpiry(id); swept.delete(id); disarm(id); unwatchLate(id); cancelFinal(ctx, id); unwatchWispr(id); if (transcriber) transcriber.drop(id); const r = notes.remove(dir, id); if (r.ok) { notesAudio.remove(dir, id); notesCapture.remove(dir, id); notesScreen.remove(dir, id); } return done(r); }
1136
+ if (p === '/api/notes/delete') { gaps.delete(id); clearExpiry(id); swept.delete(id); disarm(id); unwatchLate(id); cancelFinal(ctx, id); unwatchWispr(id); if (transcriber) transcriber.drop(id); const r = notes.remove(dir, id); if (r.ok) { notesAudio.remove(dir, id); notesCapture.remove(dir, id); notesScreen.remove(dir, id); } return done(r); }
1056
1137
  if (p === '/api/notes/highlight') {
1057
1138
  // the PM's highlight: the transcript of the window, then Jev's label and the repository check of its text
1058
1139
  const r = notes.addHighlight(dir, { id, from: body.from, to: body.to });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.437.0",
3
+ "version": "0.439.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.437.0",
9
+ "version": "0.439.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.437.0",
3
+ "version": "0.439.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -104,6 +104,26 @@ const second = (k) => [
104
104
  ok('C6 no page error at 1280', errs.length === 0, errs.join(' | '));
105
105
  await ctx.close(); }
106
106
 
107
+ { const { p, ctx, errs, conv } = await open(1280); // C7: what Claude only read folds into "+N read" (batch 17 item 5)
108
+ await sleep(1500);
109
+ const reads = ['notes/a.md', 'notes/b.md', 'notes/c.md'];
110
+ conv.messages = [...first(), { role: 'user', text: 'Sum up the notes', at: '2026-10-21T08:02:00Z' },
111
+ { role: 'tool', tools: { Read: 3, Write: 1 }, calls: [...reads.map((t) => ({ tool: 'Read', target: t })), { tool: 'Write', target: 'notes/summary.md' }], at: '2026-10-21T08:02:10Z' },
112
+ { role: 'assistant', text: 'I summed them up.', at: '2026-10-21T08:02:20Z' }];
113
+ const fold = () => p.evaluate(() => { const c = [...document.querySelectorAll('#hmLog .ctxc[role=list]')].pop(); if (!c) return null; const d = c.querySelector('details.ctxmore'); const vis = [...c.querySelectorAll('.ctxchip')].filter((b) => b.getBoundingClientRect().height > 0).map((b) => b.querySelector('b').textContent); return { vis, more: d ? d.querySelector('summary').textContent : null, open: !!(d && d.open), n: document.querySelectorAll('#hmLog .ctxc[role=list]').length }; });
114
+ const f0 = await until(async () => { const v = await fold(); return v && v.n >= 2 && v.more ? v : null; }, 6000) || await fold();
115
+ ok('C7 three files Claude only read fold into "+3 read"; the file it wrote stays in sight', !!f0 && JSON.stringify(f0.vis) === JSON.stringify(['summary.md']) && f0.more === '+3 read', JSON.stringify(f0));
116
+ ok('C7 the first answer\'s one read file is not folded', JSON.stringify((await p.evaluate(look)).chips[0]) === JSON.stringify(['file:signup-drop.md*', 'file:signup-fix.md']));
117
+ await p.click('#hmLog details.ctxmore > summary');
118
+ const f1 = await fold();
119
+ ok('C7 a press on "+3 read" shows the three files in the row', !!f1 && f1.open && JSON.stringify(f1.vis) === JSON.stringify(['summary.md', 'a.md', 'b.md', 'c.md']), JSON.stringify(f1));
120
+ conv.messages = [...conv.messages, { role: 'user', text: 'Thanks', at: '2026-10-21T08:03:00Z' }];
121
+ await sleep(2600);
122
+ const f2 = await fold();
123
+ ok('C7 it stays open when the conversation redraws', !!f2 && f2.open, JSON.stringify(f2));
124
+ ok('C7 no page error', errs.length === 0, errs.join(' | '));
125
+ await ctx.close(); }
126
+
107
127
  for (const scheme of ['light', 'dark']) {
108
128
  const { p, ctx, errs, conv } = await open(390, scheme);
109
129
  await sleep(2500);
@@ -15,6 +15,7 @@ import { pmPost } from './http.js';
15
15
  import { $, $$, esc } from './premium-shell.js';
16
16
  import * as Pop from './bd-pop.js';
17
17
  import { avatar } from './bd-views.js';
18
+ import { adler } from './cozy-adler.js'; // Adler heads the New asks (batch 17 item 4-A, canvas AdM2 New asks)
18
19
 
19
20
  let A = null; // the page: { M(), load(), say(msg, undo?), panel(html, from, cls), close(), rowOf(key), openIni(r), openDoc(path), anchors(ws, board), programs(), reloadPrograms() }
20
21
  export function init(api) { A = api; }
@@ -57,10 +58,12 @@ function unsureHtml(L) {
57
58
  function asksHtml() {
58
59
  const L = asksOf(), phone = matchMedia('(max-width: 720px)').matches;
59
60
  if (M().board.self) return '<p class="bd-h3">New asks</p><p class="bd-amut">PMOS-self has no ask source. New work starts at the pmos-router skill.</p>';
60
- if (M().asks == null || M().asks.missing) return '<p class="bd-h3">New asks</p><p class="bd-amut">The new asks could not be read, so none is shown.</p>';
61
+ // AdM2: Adler heads the list in its mood: needs you while asks wait, calm when none does, honest when they could not be read
62
+ const face = (mood) => `<span class="bd-aface" aria-hidden="true">${adler(mood, 36, { label: false })}</span>`;
63
+ if (M().asks == null || M().asks.missing) return `<div class="bd-phead">${face('honest')}<p class="bd-h3">New asks</p></div><p class="bd-amut">The new asks could not be read, so none is shown.</p>`;
61
64
  const sure = L.filter((a) => !(a.products || []).length || picked[a.id]), unsure = L.filter((a) => (a.products || []).length && !picked[a.id]);
62
65
  const src = [...new Set(L.map((a) => a.source).filter(Boolean))];
63
- const head = `<div class="bd-phead"><p class="bd-h3" id="hAsks">${L.length} new ${L.length === 1 ? 'ask' : 'asks'}</p>${src.length ? `<span class="bd-amut">${M().board.all ? 'Across products' : 'For ' + esc(M().board.name || 'this board')} · from ${esc(src.slice(0, 3).join(', ').toLowerCase())}</span>` : ''}</div>`;
66
+ const head = `<div class="bd-phead">${face(L.length ? 'needs-you' : 'handled')}<p class="bd-h3" id="hAsks">${L.length} new ${L.length === 1 ? 'ask' : 'asks'}</p>${src.length ? `<span class="bd-amut">${M().board.all ? 'Across products' : 'For ' + esc(M().board.name || 'this board')} · from ${esc(src.slice(0, 3).join(', ').toLowerCase())}</span>` : ''}</div>`;
64
67
  if (!L.length) return head + '<p class="bd-amut">No new ask waits for triage.</p>';
65
68
  return head + `<div class="bd-acards">${sure.map((a, i) => askCard(a, i, phone)).join('')}</div>` + unsureHtml(unsure);
66
69
  }
@@ -13,6 +13,7 @@
13
13
  * · Nothing to show (Filter = None, nothing pinned): no lane at all.
14
14
  * Pure apart from the remembered fold and wire(), which hooks the hover and the fold onto the Board's body. */
15
15
  import { shownMs, msMode } from './bd-pins.js';
16
+ import { faceOr } from './cozy-adler.js'; // Adler once in the lane's header when a delivery is missed (batch 17 item 4-A, canvas AdM2)
16
17
  const TICK = '<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12l5 5 9-10"/></svg>'; // the delivered mark, drawn (conformance R28-13: no glyph controls)
17
18
 
18
19
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -161,6 +162,14 @@ function foldHtml(E, now) {
161
162
  return `<div class="dl-fold">${next}${rest}${none}</div>`;
162
163
  }
163
164
 
165
+ /** AdM2 "Deliveries lane · missed": once in the lane's header, never on an entry or a ◇. The honest S face stands where the flag stood and
166
+ * says the missed ones in its hover; with nothing missed the flag stays. */
167
+ export function missedWords(E) {
168
+ const L = E.filter((x) => x.late);
169
+ return L.length ? 'Missed: ' + L.slice(0, 3).map((x) => x.name + ' was due ' + md(x.date)).join('; ') + (L.length > 3 ? '; and ' + (L.length - 3) + ' more' : '') + '.' : '';
170
+ }
171
+ const laneMark = (E) => { const w = missedWords(E); return w ? `<span class="dl-ic dl-ad" title="${esc(w)}">${faceOr('honest', 's', SV(FLAG), { label: false })}</span>` : `<span class="dl-ic">${SV(FLAG)}</span>`; };
172
+
164
173
  /** The phone's card (XcalmA6Phone): "Next deliveries · N missed", the next 3 (missed first), and All (the list by date). */
165
174
  function phoneHtml(E, now) {
166
175
  const today = midnight(now), missed = E.filter((x) => x.late), ahead = E.filter((x) => !x.done && !x.late && x.date >= today);
@@ -168,7 +177,7 @@ function phoneHtml(E, now) {
168
177
  if (!L.length) return '';
169
178
  const all = E.filter((x) => !x.done);
170
179
  const line = (x) => `<button type="button" class="dl-pl"${attrs(x)} aria-label="${esc(hoverOf(x, now).replace(/\n/g, '. '))}"><small class="${toneOf(x)}">${esc(dateWords(x, now))}</small><b>${x.prog ? `<i class="dl-pg">${SV(PROG)}</i>` : ''}<span>${esc(x.name)}</span></b></button>`;
171
- return `<section class="dl-ph" aria-label="Next deliveries"><div class="dl-phh"><b>Next deliveries</b>${missed.length ? `<span class="late">· ${missed.length} missed</span>` : ''}<button type="button" class="dl-all" data-ms-lane="${listData(all)}" data-lane-name="Deliveries" aria-haspopup="dialog" aria-label="All deliveries">All</button></div>${L.map(line).join('')}</section>`;
180
+ return `<section class="dl-ph" aria-label="Next deliveries"><div class="dl-phh">${missed.length ? laneMark(E) : ''}<b>Next deliveries</b>${missed.length ? `<span class="late">· ${missed.length} missed</span>` : ''}<button type="button" class="dl-all" data-ms-lane="${listData(all)}" data-lane-name="Deliveries" aria-haspopup="dialog" aria-label="All deliveries">All</button></div>${L.map(line).join('')}</section>`;
172
181
  }
173
182
 
174
183
  /** The lane: the hook pm/bd-span.js calls ({ W, X, rows, groups, now, phone }), with o: { span, progState, mode }. '' when nothing lands. */
@@ -179,7 +188,7 @@ export function laneHtml(c, o = {}) {
179
188
  if (!E.length) return '';
180
189
  if (c.phone) return phoneHtml(E, now);
181
190
  const shut = folded();
182
- const name = `<div class="tg-n dl-n"><span class="dl-ic">${SV(FLAG)}</span><span class="dl-t"><b>Deliveries</b>${shut ? '' : '<small>What lands when</small>'}</span><button type="button" class="dl-fb" data-dl-fold aria-expanded="${!shut}" aria-label="${shut ? 'Open the Deliveries lane' : 'Fold the Deliveries lane to one line'}">${SV(shut ? CHR : CHD)}</button></div>`;
191
+ const name = `<div class="tg-n dl-n">${laneMark(E)}<span class="dl-t"><b>Deliveries</b>${shut ? '' : '<small>What lands when</small>'}</span><button type="button" class="dl-fb" data-dl-fold aria-expanded="${!shut}" aria-label="${shut ? 'Open the Deliveries lane' : 'Fold the Deliveries lane to one line'}">${SV(shut ? CHR : CHD)}</button></div>`;
183
192
  const body = shut ? foldHtml(E, now) : columnsOf(c.W, o.span).map((col) => columnHtml(col, E, now, c.X, o.span)).join('');
184
193
  return `<div class="tg-r tg-dl${shut ? ' shut' : ''}" role="region" aria-label="Deliveries, what lands when">${name}<div class="tg-p dl-p">${body}</div></div>`;
185
194
  }
@@ -79,9 +79,15 @@ html.ad-still .env-leaf { opacity: 0; }
79
79
  .env-steam, .env-z, .env-drop { opacity: .6; }
80
80
  .env-leaf { opacity: 0; }
81
81
  }
82
- svg.ad-svg.am { stroke: none; }
82
+ svg.ad-svg.am, svg.ad-scene, svg.ad-scene svg.am { stroke: none; } /* a page's own `svg { stroke: currentColor }` (the Board's) never outlines him */
83
83
  /* Your impact (batch 16 item 7, GmA1Home): the newest leaf on the sprout grows once, on a real event; still under reduced motion and Still */
84
84
  .ad-svg .ad-gw { animation: adGw 1.4s ease-out 1 both; transform-box: fill-box; transform-origin: right bottom; }
85
85
  @keyframes adGw { 0% { transform: scale(0); opacity: 0; } 70% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
86
86
  @media (prefers-reduced-motion: reduce) { .ad-svg .ad-gw { animation: none; } }
87
87
  html.ad-still .ad-svg .ad-gw { animation: none; }
88
+
89
+ /* pull to refresh (batch 17 item 4-B, AdP2; pm/cozy-pull.js): his head rises over the bottom edge as the finger pulls, glasses on while it reads */
90
+ .cz-pull { position: relative; height: var(--cz-pull, 0px); overflow: hidden; display: flex; align-items: flex-end; justify-content: center; gap: 10px; border-bottom: 2px solid var(--cz-hair); margin-bottom: 8px; }
91
+ .cz-pull-ad { display: inline-flex; transform: translateY(max(0px, calc(44px - var(--cz-pull, 0px)))); }
92
+ .cz-pull-t { font-size: var(--fs-2); font-weight: 700; color: var(--cz-ink3); padding-bottom: 8px; }
93
+ .cz-pull-t:empty { display: none; }
@@ -10,6 +10,8 @@
10
10
  * mountToastFaces(doc) every #toast gets the S face in the mood of its words
11
11
  * prefs(), loadPrefs(), savePref(key, value) Settings > Adler (AdM5): adler.amount, adler.motion, adler.celebrate, adler.quiet
12
12
  * asleep(now), mayCelebrate(now), celebrated(now) the after-22:00 rule and "celebrate at most once a week"
13
+ * celebrateOnce(key, now) a real win celebrates on its first view only (the delivered milestone in the Board panel, AdH2)
14
+ * faceOr(mood, size, icon, o) his face where a plain icon stood; the icon stays with Settings > Adler > Off (batch 17 item 4-A)
13
15
  *
14
16
  * The binding rules (design-principles.md, "The Adler rule"): the mood comes from real state only, and no trigger means resting or handled;
15
17
  * one Adler per screen; never inside data (rows, bars, charts, KR rows, reports, connector lists); he never replaces a row's dot or box;
@@ -162,6 +164,18 @@ const weekOf = (now) => { const d = new Date(now); d.setHours(0, 0, 0, 0); d.set
162
164
  /** Celebrating: only for a real event, at most once a week, and never with Celebrations: Never. */
163
165
  export const mayCelebrate = (now = Date.now()) => P['adler.celebrate'] === 'real' && store.get('pmos.adler.joy') !== weekOf(now);
164
166
  export const celebrated = (now = Date.now()) => store.set('pmos.adler.joy', weekOf(now));
167
+ /** A real win shows once (AdH2, AdM2 "Milestone delivered"): true on the first view of `key`, and only when a celebration is allowed this
168
+ * week. The page keeps the answer while it lives, so a redraw does not turn him calm mid-view; every later view is calm. */
169
+ const joyNow = new Set();
170
+ export function celebrateOnce(key, now = Date.now()) {
171
+ const k = 'pmos.adler.once.' + key;
172
+ if (joyNow.has(k)) return true;
173
+ if (store.get(k)) return false;
174
+ store.set(k, '1');
175
+ if (!mayCelebrate(now)) return false;
176
+ celebrated(now); joyNow.add(k);
177
+ return true;
178
+ }
165
179
  /** The day's first open of the morning scene (AdP1 vs AdB1: the scene on the first open of the day, the M face after). */
166
180
  export function firstOpenToday(key = 'day', now = Date.now()) { const k = 'pmos.adler.first.' + key, d = new Date(now).toDateString(); if (store.get(k) === d) return false; store.set(k, d); return true; }
167
181
 
@@ -198,6 +212,9 @@ export function adler(mood, size = 'm', o = {}) {
198
212
  const w = Math.round(px * 200 / 252);
199
213
  return `<svg class="${cls} ad-fig" width="${w}" height="${px}" viewBox="0 0 200 252" overflow="visible" ${labelAttr(o, mood, extra)}>${defs(p)}<ellipse cx="100" cy="246" rx="62" ry="7" class="${F('shadow')}" opacity=".16" filter="url(#${p}b)"/><g class="ad-br">${full(m, p, o.prop)}</g></svg>`;
200
214
  }
215
+ /** His face where a plain icon stood (the Jira chip, the charter's check line, the Deliveries lane): with Settings > Adler > Off the icon
216
+ * stays, so the press still says what it does. */
217
+ export const faceOr = (mood, size, icon, o = {}) => (P['adler.amount'] === 'off' ? icon : adler(mood, size, o));
201
218
  /** AdP6: only his ears and the top of his head, peeking over the floating button. */
202
219
  export function adlerPeek(o = {}) {
203
220
  addCss();
@@ -102,6 +102,8 @@ body.bd-page main.bd-main { position: relative; max-width: none; margin: 16px; p
102
102
  .bd-chipset { display: contents; }
103
103
  .bd-chip { height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--cz-hair); background: var(--cz-card); display: inline-flex; align-items: center; gap: 6px; font: 600 var(--fs-2) var(--cz-sans); color: var(--cz-ink2); white-space: nowrap; cursor: pointer; text-decoration: none; flex: none; }
104
104
  .bd-chip:hover { background: var(--cz-well); }
105
+ .bd-adc { padding-left: 4px; } /* the Jira chip's Adler face (batch 17 item 4-A) sits where the refresh icon stood */
106
+ .bd-chip.bd-adc svg.ad-svg { width: 24px; height: 24px; }
105
107
  .bd-chip svg { width: 14px; height: 14px; flex: none; }
106
108
  .bd-chip b { font-weight: 800; color: var(--cz-ink); }
107
109
  .bd-chip.gh { border-color: transparent; background: transparent; padding: 0 8px; font-weight: 800; }
@@ -500,6 +502,8 @@ button.tg-n:hover b { color: var(--cz-blueink); }
500
502
  .tg-dl.shut .dl-n { align-items: center; padding-top: 8px; }
501
503
  .dl-ic { flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--cz-well); display: grid; place-items: center; color: var(--cz-ink2); }
502
504
  .dl-ic svg, .dl-fb svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
505
+ .dl-ad { background: none; } /* a missed delivery: Adler's honest face stands where the flag stood (batch 17 item 4-A) */
506
+ .dl-ic.dl-ad svg.ad-svg { width: 24px; height: 24px; fill: initial; stroke: none; }
503
507
  .dl-t { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
504
508
  .dl-t b { font-size: var(--fs-3); font-weight: 800; }
505
509
  .dl-t small { font-size: var(--fs-2); color: var(--cz-ink3); }
@@ -832,6 +836,7 @@ a.bd-btn { display: inline-flex; align-items: center; gap: 6px; text-decoration:
832
836
  /* the row menu, the asks, the trend */
833
837
  .bd-menu .bd-mlbl:first-child { color: var(--cz-ink); font-size: var(--fs-2); }
834
838
  .bd-phead { display: flex; align-items: baseline; gap: 10px; padding: 8px 12px 6px; flex-wrap: wrap; }
839
+ .bd-aface { display: inline-flex; align-self: center; flex: none; } /* Adler heads New asks (batch 17 item 4-A) */
835
840
  .bd-acards { display: flex; flex-direction: column; gap: 8px; padding: 0 4px 4px; }
836
841
  .bd-acard { all: unset; box-sizing: border-box; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--cz-hair); background: var(--cz-card); font-size: var(--fs-3); }
837
842
  .bd-acard.row { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; padding: 10px 12px; }
@@ -78,6 +78,11 @@
78
78
  .ev-fd { z-index: 2; }
79
79
  .ev-fd { position: absolute; top: 6px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--cz-card); box-sizing: content-box; pointer-events: none; }
80
80
  .ev-fd[hidden] { display: none; }
81
+ /* Adler's ears over the closed button when a call is the PM's (batch 17 item 4-B, AdP6): a phone only; they never take a press */
82
+ .cz-ears { position: absolute; bottom: 50px; left: 6px; width: 44px; height: 22px; z-index: 0; pointer-events: none; }
83
+ .cz-ears[hidden] { display: none; }
84
+ @media (min-width: 761px) { .cz-ears { display: none; } }
85
+ @media (max-width: 760px) { .cz-ears { left: auto; right: 6px; } }
81
86
  .ev-fd.you { left: 4px; background: var(--cz-blue); }
82
87
  .ev-fd.risk { right: 2px; background: var(--cz-dot-risk); }
83
88
  @media (max-width: 760px) {
@@ -207,6 +212,9 @@
207
212
  .ev-st .ev-pick { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px 0 12px; border-radius: 999px; background: var(--cz-well); font: inherit; font-size: var(--fs-2); font-weight: 700; color: var(--cz-ink2); border: 0; cursor: pointer; }
208
213
  .ev-st .ev-pick svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
209
214
  .ev-st .ev-upd { display: flex; align-items: center; gap: 12px; margin-top: auto; }
215
+ /* Adler's moments in Settings (batch 17 item 4-B, AdM4): one face per section; a failure line takes the honest face */
216
+ .ev-st .ev-ad { display: inline-flex; align-items: center; flex: none; }
217
+ .ev-st .ev-say.honest { display: flex; align-items: center; gap: 8px; }
210
218
  .ev-st .ev-upd p { flex: 1; margin: 0; }
211
219
  .ev-st .ev-sw { height: 28px; min-width: 52px; border-radius: 999px; border: 0; background: var(--cz-well2); color: var(--cz-ink3); font: inherit; font-size: var(--fs-2); font-weight: 700; cursor: pointer; }
212
220
  .ev-st .ev-sw[aria-checked="true"] { background: var(--cz-bluebg); color: var(--cz-blueink); }
@@ -767,3 +767,10 @@ form.hm-box textarea { min-height: 48px; border: 0; background: none; resize: no
767
767
  .hm-av.hm-adler { width: 36px; height: 36px; background: none; border-radius: 0; overflow: visible; }
768
768
  .hm-empty-ad { display: flex; flex-direction: column; align-items: center; gap: 8px; }
769
769
  .hm-empty-ad p { margin: 0; }
770
+ .hm-chat .ctxmore { display: contents; }
771
+ .hm-chat .ctxmore > summary { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 12px; color: var(--cz-ink3); font-size: var(--fs-1); cursor: pointer; list-style: none; }
772
+ .hm-chat .ctxmore > summary::-webkit-details-marker { display: none; }
773
+ .hm-chat .ctxmore > summary:hover { color: var(--cz-ink); }
774
+ .hm-chat .ctxmore[open] > summary { display: none; }
775
+ .hm-chat .ctxmore > .ctxc { display: contents; }
776
+ .hm-chat .ctxmore:not([open]) > .ctxc { display: none; }
@@ -8,6 +8,8 @@
8
8
  .cz-live:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
9
9
  .lv-row:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: -2px; }
10
10
  .cz-live .lv-g { display: inline-flex; align-items: center; gap: 6px; }
11
+ .cz-live .lv-ad { display: inline-flex; align-items: center; } /* Adler with headphones while the meeting records (AdM1) */
12
+ .cz-live .lv-ad .ad-sp { animation: none; }
11
13
  .cz-live .lv-sp { width: 1px; height: 16px; background: var(--cz-hair); }
12
14
  .cz-live .lv-ms { display: inline-flex; align-items: center; gap: 6px; }
13
15
 
@@ -13,11 +13,14 @@
13
13
  * opts.go(item) → true the page opens the item itself (Home: the session's chat, the meeting); else the row's link is followed
14
14
  * opts.open() → id the session open on this page now: its row is tinted
15
15
  * Reads GET /api/live every 10 s while the page is shown, and on the cz:live event (Home sends it after the PM opens or answers a
16
- * session); the recording comes from pm/rec-state.js. Nothing is written. */
16
+ * session); the recording comes from pm/rec-state.js. Nothing is written.
17
+ * Adler (batch 17 item 4-B, AdM1 "Live recording pill", AdH5): while a meeting records, his S face with headphones follows the clock in the
18
+ * pill. The red dot stays: the face never replaces the row's mark. Paused, he is not shown (nobody is listening). */
17
19
  import { onRecording } from './rec-state.js';
18
20
  import { ownTab, bring } from './rec-tab-core.js';
19
21
  import { liveItems, keepOrder, pillLabel, rowLabel, clock, elapsed } from './live-model.js';
20
- import { wedgeHtml } from './ctx-wedge.js'; // the same context pie as Home's rows, before the time (batch 13 item 8)
22
+ import { wedgeHtml } from './ctx-wedge.js';
23
+ import { adler } from './cozy-adler.js'; // the same context pie as Home's rows, before the time (batch 13 item 8)
21
24
 
22
25
  const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
23
26
  const SHEET = new URL('./cozy-live-pill.css', import.meta.url).href;
@@ -67,7 +70,7 @@ export function mountLivePill(doc = document, opts = {}) {
67
70
  }
68
71
  function pillHtml(list) {
69
72
  const r = list.find((x) => x.kind === 'rec'), rest = list.filter((x) => x.kind !== 'rec');
70
- return (r ? `<span class="lv-g"><i class="lv-m rec${r.paused ? ' paused' : ''}"></i><span class="lv-tm${r.paused ? '' : ' rec'}">${esc(r.time)}</span></span>${rest.length ? '<span class="lv-sp"></span>' : ''}` : '')
73
+ return (r ? `<span class="lv-g"><i class="lv-m rec${r.paused ? ' paused' : ''}"></i><span class="lv-tm${r.paused ? '' : ' rec'}">${esc(r.time)}</span>${r.paused ? '' : `<span class="lv-ad">${adler('thinking', 18, { label: false, prop: 'headphones', id: 'lvrec' })}</span>`}</span>${rest.length ? '<span class="lv-sp"></span>' : ''}` : '')
71
74
  + (rest.length ? `<span class="lv-ms">${rest.map((x) => markHtml(x.mark, false)).join('')}</span>` : '');
72
75
  }
73
76
  function draw() {
@@ -14,10 +14,13 @@
14
14
  * The counts come from GET /api/news-for-you and GET /api/sources, read when the page opens and every two minutes while it is shown; each
15
15
  * read of New for you is passed on as the event 'cz:news-for-you' (detail: the answer), so Home's Your day and Good morning follow it.
16
16
  * Nothing here leads to the console, and nothing here writes.
17
+ * Adler's ears (batch 17 item 4-B, AdP6): on a phone, when a page says one or more calls are the PM's (the event 'cz:calls', detail
18
+ * { count }: Home sends it from Your move), his ears and the top of his head peek over the closed button. The button's name says it. No
19
+ * call, the menu open, a desk, Settings > Adler not Full, or after Quiet after: no ears (zero is silence).
17
20
  */
18
21
  import { esc, svg, ICON, wsQ } from './cozy-evui.js';
19
22
  import { fabLabel, staleOf } from './cozy-evmodel.js';
20
- import { mountToastFaces, loadPrefs } from './cozy-adler.js'; // Adler (batch 16 item 2): every toast carries his S face; Settings > Adler is read once
23
+ import { mountToastFaces, loadPrefs, adlerPeek, asleep } from './cozy-adler.js'; // Adler (batch 16 item 2): every toast carries his S face; Settings > Adler is read once
21
24
 
22
25
  export const PLACES = [
23
26
  { key: 'home', label: 'Home', href: '/premium.html', d: ICON.home },
@@ -27,7 +30,7 @@ export const PLACES = [
27
30
  export { fabLabel };
28
31
  const THEME_KEY = 'pmos.c3.theme';
29
32
  const CSS = new URL('./cozy-ev.css', import.meta.url).href;
30
- const N = { news: 0, stale: null, here: 'home' };
33
+ const N = { news: 0, stale: null, here: 'home', calls: 0 };
31
34
 
32
35
  const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { if (v) localStorage.setItem(k, v); else localStorage.removeItem(k); } catch { /* a private window */ } } };
33
36
  /** The theme the PM picked on this device: light, dark or auto. */
@@ -62,6 +65,9 @@ function addCss(doc) {
62
65
  }
63
66
  async function getj(p) { try { const r = await fetch(p, { credentials: 'same-origin' }); return r.ok ? await r.json() : null; } catch { return null; } }
64
67
 
68
+ /** What the button adds to its name while the ears show: 'One call is yours' · '3 calls are yours'. */
69
+ export const callWords = (n) => (n === 1 ? 'One call is yours' : n + ' calls are yours');
70
+
65
71
  /** Mount the menu once. `here` is home | board | insights. Returns the wrapper. */
66
72
  export function mountNav(here, doc = document, opts = {}) {
67
73
  const old = doc.getElementById('czNav'); if (old) return old;
@@ -75,7 +81,7 @@ export function mountNav(here, doc = document, opts = {}) {
75
81
  w.innerHTML = '<div class="ev-scrim" id="czScrim" hidden></div>'
76
82
  + `<nav class="cz-fabm ev-menu" id="czMenu" aria-label="Menu" hidden></nav>`
77
83
  + `<button type="button" class="cz-fab" id="czFab" aria-controls="czMenu" aria-expanded="false" aria-label="${fabLabel(here, false)}">${svg(ICON.menu, 22)}</button>`
78
- + '<i class="ev-fd you" id="czFdYou" hidden></i><i class="ev-fd risk" id="czFdRisk" hidden></i>';
84
+ + '<i class="ev-fd you" id="czFdYou" hidden></i><i class="ev-fd risk" id="czFdRisk" hidden></i><span class="cz-ears" id="czEars" aria-hidden="true" hidden></span>';
79
85
  doc.body.appendChild(w);
80
86
  mountToastFaces(doc); loadPrefs();
81
87
  const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
@@ -83,8 +89,13 @@ export function mountNav(here, doc = document, opts = {}) {
83
89
  menu.innerHTML = menuHtml(here, { news: N.news, stale: N.stale });
84
90
  w.querySelector('#czFdYou').hidden = !(N.news > 0) || !menu.hidden;
85
91
  w.querySelector('#czFdRisk').hidden = !N.stale || !menu.hidden;
86
- if (menu.hidden) fab.setAttribute('aria-label', fabLabel(here, false, N.stale, N.news));
92
+ if (menu.hidden) fab.setAttribute('aria-label', fabLabel(here, false, N.stale, N.news) + (earsOn() ? '. ' + callWords(N.calls) : ''));
93
+ drawEars();
87
94
  };
95
+ // AdP6: the ears are drawn once and kept while the count stays above zero, so a redraw never replays them
96
+ const ears = w.querySelector('#czEars');
97
+ const earsOn = () => N.calls > 0 && menu.hidden && !asleep();
98
+ const drawEars = () => { const on = earsOn(); if (on && !ears.firstChild) ears.innerHTML = adlerPeek(); ears.hidden = !on || !ears.firstChild; };
88
99
  const set = (open) => {
89
100
  menu.hidden = !open; scrim.hidden = !open; fab.setAttribute('aria-expanded', String(open));
90
101
  fab.setAttribute('aria-label', fabLabel(here, open, N.stale, N.news)); fab.innerHTML = svg(open ? ICON.close : ICON.menu, 22);
@@ -120,13 +131,15 @@ export function mountNav(here, doc = document, opts = {}) {
120
131
  if (doc.hidden) return;
121
132
  const [n, s] = await Promise.all([getj('/api/news-for-you' + wsQ()), getj('/api/sources' + wsQ())]);
122
133
  if (n && n.ok) { N.news = n.count || 0; doc.dispatchEvent(new CustomEvent('cz:news-for-you', { detail: n })); }
123
- if (s && s.ok) N.stale = staleOf(s.sources);
134
+ if (s && s.ok) { N.stale = staleOf(s.sources); doc.dispatchEvent(new CustomEvent('cz:sources', { detail: s })); } // Your day's failed source (AdP5)
124
135
  if (menu.hidden || !menu.contains(doc.activeElement)) draw();
125
136
  };
126
137
  read();
127
138
  setInterval(read, 120000);
128
139
  doc.addEventListener('visibilitychange', () => { if (!doc.hidden) read(); });
129
140
  doc.addEventListener('cz:news', (e) => { if (e.detail && Number.isFinite(e.detail.count)) { N.news = e.detail.count; draw(); } else read(); });
141
+ doc.addEventListener('cz:calls', (e) => { const n = e.detail && Number(e.detail.count); N.calls = Number.isFinite(n) && n > 0 ? n : 0; draw(); });
142
+ doc.addEventListener('adler:prefs', () => { ears.innerHTML = ''; draw(); });
130
143
  window.addEventListener('pm:sources', (e) => { const d = e.detail; if (d && d.ok) { N.stale = staleOf(d.sources); draw(); } });
131
144
  return w;
132
145
  }