create-pmos 0.599.0 → 0.601.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 (35) hide show
  1. package/package.json +33 -27
  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/changelog.json +32 -0
  7. package/workspace/guide/layout.md +10 -3
  8. package/workspace/guide/settings-and-switches.md +24 -0
  9. package/workspace/lib/bg-queue.js +1 -0
  10. package/workspace/lib/event-relay.js +202 -0
  11. package/workspace/lib/initiative-premium.js +2 -2
  12. package/workspace/lib/job-graph.js +1 -0
  13. package/workspace/lib/refresh-run.js +171 -30
  14. package/workspace/lib/refresh.js +107 -20
  15. package/workspace/lib/route-modules.js +1 -0
  16. package/workspace/lib/routes-initiative-premium.js +11 -1
  17. package/workspace/lib/routes-refresh.js +12 -4
  18. package/workspace/lib/routes-relay.js +29 -0
  19. package/workspace/package-lock.json +2 -2
  20. package/workspace/package.json +1 -1
  21. package/workspace/public/pm/cozy-ev.css +9 -0
  22. package/workspace/public/pm/cozy-evmodel.js +14 -0
  23. package/workspace/public/pm/cozy-home.css +76 -0
  24. package/workspace/public/pm/cozy-live-pill.js +4 -0
  25. package/workspace/public/pm/cozy-nav.js +26 -6
  26. package/workspace/public/pm/cozy-relay.js +80 -0
  27. package/workspace/public/pm/cozy-schedwork.js +52 -19
  28. package/workspace/public/pm/cozy-settings.js +11 -3
  29. package/workspace/public/pm/home-app.js +47 -1
  30. package/workspace/public/pm/home-chat.js +17 -2
  31. package/workspace/public/pm/phone-chat-head.js +147 -0
  32. package/workspace/server.js +15 -6
  33. package/workspace/skills/sources-read.skill +1 -1
  34. package/workspace/test-lists/event-relay.json +9 -0
  35. package/workspace/test-lists/roomier-phone-chat.json +9 -0
@@ -2,7 +2,7 @@
2
2
  /* routes-initiative-premium.js — GET /api/initiative-premium?id=<id>[&ws=<id>&board=<id>] (initiative briefing-premium-initiative).
3
3
  *
4
4
  * 200 { ok, state: 'ready', model, as_of } | 202 { ok, state: 'reading' } | 404 { ok: false, state: 'error', error } | 500 { ok: false, state: 'error', error }
5
- * model is lib/initiative-premium.js build(), made from the answers of the routes the production Initiatives sheet reads: /api/boards/initiative,
5
+ * model is lib/initiative-premium.js build() plus model.prs (prsOf below), made from the answers of the routes the production Initiatives sheet reads: /api/boards/initiative,
6
6
  * /api/initiatives/<id>, /api/boards/items and /api/core-docs?level=initiative. Those routes derive the initiatives in the background and answer 202
7
7
  * while they do, so this route answers 202 too and the page asks again: no request waits for the read. Read-only: the one press of the page (Draft it)
8
8
  * goes to POST /api/core-docs/draft from the page. */
@@ -11,6 +11,7 @@ const boards = require('./routes-boards.js');
11
11
  const initiatives = require('./routes-initiatives.js');
12
12
  const coreDocs = require('./routes-core-docs.js');
13
13
  const Custom = require('./custom-docs.js');
14
+ const factoryJoin = require('./factory-join.js');
14
15
 
15
16
  /** GET `pathAndQuery` from a route module's own handler, as the Work page's route does, and return { status, body }. */
16
17
  async function via(mod, pathAndQuery, req, ctx) {
@@ -21,9 +22,17 @@ async function via(mod, pathAndQuery, req, ctx) {
21
22
  return handled === false ? { status: 404, body: null } : out;
22
23
  }
23
24
  const qs = (o) => '?' + Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
25
+ /** The initiative's pull requests (batch 31 item 5, the phone chat's context line): the factory's work items that name one in their evidence
26
+ * (lib/factory-join.js, the one join). [{ ref, item, state: 'Open' | 'Merged' | 'Closed' }]; no ledger or no PR gives []. */
27
+ const PR_STATE = { integrated: 'Merged', shipped: 'Merged', withdrawn: 'Closed' };
28
+ function prsOf(join, id) {
29
+ const f = factoryJoin.factoryOf(join, id);
30
+ return f && Array.isArray(f.items) ? f.items.filter((x) => x && x.pr).map((x) => ({ ref: String(x.pr), item: x.id, state: PR_STATE[x.state] || 'Open' })) : [];
31
+ }
24
32
  const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/;
25
33
 
26
34
  module.exports = {
35
+ prsOf,
27
36
  prefixes: ['/api/initiative-premium'],
28
37
  handle: async (req, res, url, ctx) => {
29
38
  if (url.pathname !== '/api/initiative-premium') return false;
@@ -64,6 +73,7 @@ module.exports = {
64
73
  row: head.body.row, sheet: sh, items: it ? it.items : [], docs: dd, custom, ladder: lad,
65
74
  boards: all.map((x) => ({ ws: x.ws, id: x.id, name: x.name })), siblings: it ? (it.initiatives || []).map((x) => ({ id: x.id, title: x.title })) : [],
66
75
  });
76
+ try { const w = ctx.getWs ? ctx.getWs(pick.ws) : null; model.prs = w ? prsOf(factoryJoin.joinFactory(w.root, { initiative: id }), id) : []; } catch { model.prs = []; }
67
77
  ctx.json(res, { ok: true, state: 'ready', model, as_of: Date.now() });
68
78
  return true;
69
79
  } catch (e) { return fail((e && e.message) || e); }
@@ -4,7 +4,9 @@
4
4
  * GET /api/refresh?ws=<id> → { ok, ws, rules, quiet, window, rows: [row] } lib/refresh.js rowsOf
5
5
  * POST /api/refresh/source { id, on?, schedule? } → { ok, source } on or off, and a skill source's schedule
6
6
  * POST /api/refresh/rules { catchup?, retry?, tell?, max?, keep? } → { ok, rules }
7
- * POST /api/refresh/run { id, ws?, with_inputs? } → { ok, source, started?|waiting?, inputs } Refresh now
7
+ * POST /api/refresh/source { id: 'tools', svc, schedule|null } → { ok, source, svc } one service's own rhythm (null follows Your tools)
8
+ * POST /api/refresh/run { id, ws?, with_inputs?, svcs? } → { ok, source, started?|waiting?, inputs } Refresh now (svcs: some services of Your tools)
9
+ * POST /api/refresh/stop { id, ws?, again? } → { ok, stopped, again } Stop and read again (batch 31 item 6)
8
10
  * POST /api/refresh/run-all { ws? } → { ok, started: [id], failed: [{ id, error }] } every source that is on
9
11
  * GET /api/refresh/log?source=&result=&limit= → { ok, runs: [run] } newest first
10
12
  * GET /api/refresh/log.csv → text/csv, every run kept
@@ -47,7 +49,7 @@ async function handle(req, res, url, ctx) {
47
49
  return true;
48
50
  }
49
51
 
50
- if (!['/api/refresh/source', '/api/refresh/rules', '/api/refresh/run', '/api/refresh/run-all'].includes(p)) return false;
52
+ if (!['/api/refresh/source', '/api/refresh/rules', '/api/refresh/run', '/api/refresh/run-all', '/api/refresh/stop'].includes(p)) return false;
51
53
  if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
52
54
  const got = await ctx.readJson(req);
53
55
  if (!got.ok) { ctx.json(res, { ok: false, error: 'the body is not JSON' }, 400); return true; }
@@ -62,7 +64,7 @@ async function handle(req, res, url, ctx) {
62
64
  }
63
65
 
64
66
  if (p === '/api/refresh/source') {
65
- const r = run.setSource(String(body.id || ''), { on: body.on, schedule: body.schedule });
67
+ const r = run.setSource(String(body.id || ''), body.svc !== undefined ? { svc: body.svc, schedule: body.schedule } : { on: body.on, schedule: body.schedule });
66
68
  ctx.json(res, r, r.ok ? 200 : 400);
67
69
  return true;
68
70
  }
@@ -74,7 +76,13 @@ async function handle(req, res, url, ctx) {
74
76
  return true;
75
77
  }
76
78
  if (p === '/api/refresh/run') {
77
- const r = run.runNow(String(body.id || ''), { ws, withInputs: body.with_inputs === true });
79
+ if (body.svcs !== undefined && !(Array.isArray(body.svcs) && body.svcs.every((x) => typeof x === 'string'))) { ctx.json(res, { ok: false, error: 'svcs must be a list of service ids' }, 400); return true; }
80
+ const r = run.runNow(String(body.id || ''), { ws, withInputs: body.with_inputs === true, svcs: body.svcs });
81
+ ctx.json(res, r, r.ok ? 200 : r.status || 400);
82
+ return true;
83
+ }
84
+ if (p === '/api/refresh/stop') {
85
+ const r = run.stopAndRead(String(body.id || ''), { ws, again: body.again !== false });
78
86
  ctx.json(res, r, r.ok ? 200 : r.status || 400);
79
87
  return true;
80
88
  }
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+ /* routes-relay.js — Settings › Connectors › Listening (initiative event-relay; D110). Page presses only; the host is never given a way in.
3
+ *
4
+ * GET /api/relay -> { ok, host, sources: { github, jira }, recent, last } (no secret, no key)
5
+ * POST /api/relay/setup { source } -> { ok, source, url, secret, steps } makes the address on the host; the PM pastes it into the service
6
+ * POST /api/relay/steps { source } -> { ok, source, url, secret, steps } shows the same steps again
7
+ * POST /api/relay/stop { source } -> { ok } the address and its queue are deleted on the host
8
+ * POST /api/relay/pull -> { ok, events, rang } pull now (the background queue pulls every minute)
9
+ * The secret goes only to this loopback page, for the PM to paste. Nothing here writes a record (D110 point 5). */
10
+ const relay = require('./event-relay.js');
11
+
12
+ module.exports = {
13
+ prefixes: ['/api/relay'],
14
+ handle: async (req, res, url, ctx) => {
15
+ const p = url.pathname; const dir = ctx.runtimeDir;
16
+ if (p === '/api/relay' && req.method === 'GET') { ctx.json(res, { ok: true, ...relay.status(dir) }); return true; }
17
+ if (!['/api/relay/setup', '/api/relay/steps', '/api/relay/stop', '/api/relay/pull'].includes(p)) return false;
18
+ if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
19
+ const b = await ctx.readJson(req); const body = b && b.ok ? b.body || {} : {};
20
+ const source = String(body.source || '');
21
+ let r;
22
+ if (p === '/api/relay/setup') r = await relay.setup(dir, source, {});
23
+ else if (p === '/api/relay/steps') r = relay.steps(dir, source);
24
+ else if (p === '/api/relay/stop') r = await relay.stop(dir, source, {});
25
+ else r = await relay.pull(dir, { ring: ctx.refreshRun ? relay.doorbell(ctx.refreshRun) : null });
26
+ ctx.json(res, r, r.ok ? 200 : r.status || 400);
27
+ return true;
28
+ },
29
+ };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.599.0",
3
+ "version": "0.601.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.599.0",
9
+ "version": "0.601.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.599.0",
3
+ "version": "0.601.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",
@@ -423,6 +423,15 @@
423
423
  .cz .ev-ls { display: flex; flex-direction: column; gap: 2px; }
424
424
  .cz .ev-ls .ev-ms { color: var(--cz-late); }
425
425
  .cz .ev-ls .ev-nx { color: var(--cz-blueink); }
426
+ /* Settings › Connectors › Listening (event-relay, D110; pm/cozy-relay.js) */
427
+ .ev-st .ev-rl-acts { display: flex; gap: 2px; }
428
+ .ev-st .ev-rl-steps { margin: 2px 0 10px 28px; padding: 10px 12px; border-radius: 12px; background: var(--cz-well); }
429
+ .ev-st .ev-rl-steps ol { margin: 0 0 8px; padding-left: 18px; }
430
+ .ev-st .ev-rl-steps li { margin: 3px 0; }
431
+ .ev-st .ev-rl-kv { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 6px; align-items: center; margin-top: 4px; }
432
+ .ev-st .ev-rl-kv code { overflow-wrap: anywhere; }
433
+ .ev-st .ev-rl-ev { margin: 4px 0 0 28px; padding: 0; list-style: none; }
434
+ .ev-st .ev-rl-ev li { padding: 2px 0; }
426
435
  /* Settings › Connectors › Scheduled work (batch 31 item 2, agreed design SwC; pm/cozy-schedwork.js): the quiet entry, the list, and a
427
436
  * job's page like the Claude app's scheduled task: Active, Next run, Repeats in one card, PMOS's ✦ rhythm, History, ▶ Read now */
428
437
  .ev-st .ev-sw-ic { color: var(--cz-ink3); display: inline-flex; flex: none; }
@@ -8,6 +8,7 @@
8
8
  * (self-heal, feedback batch 26 item 7): null while Claude repairs a source by itself, or after it did
9
9
  * sourceRows(sources, now) → [{ id, name, sub, when, risk, act: 'read' | 'connect' | '' }] the Sources table (EvSources)
10
10
  * connectorRows(sources, health, now) → [{ id, name, trouble, why, when, act }] Settings › Connectors, design A (CnA): trouble first
11
+ * svcRow(svc, schedule, job, now) → one service of Your tools as a Connectors row (batch 31 item 6, StA)
11
12
  * issueRow(issue) → { src, name, why } a harness-health issue split into a row's name and reason
12
13
  * clockOf(iso, now) → '09:15' today · 'yesterday' · '3 Nov'
13
14
  * partsOf(id) → what may be out of date when that source is old ('Board and the Jira-linked initiatives')
@@ -137,6 +138,17 @@ export function scheduleLine(s, now = Date.now()) {
137
138
  const nx = sch.next_run ? nextOf(sch.next_run, now) : '';
138
139
  return { text: everyLine(sch.cadence) + (nx ? ' · next ' + nx : ''), missed: false };
139
140
  }
141
+ /** One service of Your tools as a Connectors row (batch 31 item 6). `id` is 'tools.<svc>', which ↻ and › read. */
142
+ export function svcRow(v, sch, job, now = Date.now()) {
143
+ const id = (job || 'tools') + '.' + v.id, base = { id, name: v.label, job: id, svc: v.id };
144
+ const st = sch.stall && v.reading && (!sch.stall.svcs || sch.stall.svcs.includes(v.id)) ? sch.stall : null;
145
+ if (st) return { ...base, trouble: 1, why: 'Stuck since ' + clockOf(st.since, now) + ' · ' + st.why.replace(/^./, (c) => c.toLowerCase()), when: '', act: null };
146
+ if (v.cadence === 'off') return { ...base, trouble: 0, why: 'Off', when: '', act: null };
147
+ if (v.last_state === 'not-reached' && !v.reading) return { ...base, trouble: 2, why: 'Not reached' + (v.last_why ? ': ' + v.last_why : '') + '.', when: '', act: { kind: 'read', label: 'Read ' + v.label + ' again' } };
148
+ if (v.missed_at && !v.reading) return { ...base, trouble: 4, why: (v.last_at ? 'Read ' + atOf(v.last_at, now) : 'Never read') + ' · missed ' + atOf(v.missed_at, now), when: '', act: { kind: 'read', label: 'Read ' + v.label + ' again' } };
149
+ const nx = v.next_run ? nextOf(v.next_run, now) : '';
150
+ return { ...base, trouble: 0, why: v.reading ? 'Reading now' : everyLine(v.cadence) + (nx ? ' · next ' + nx : ''), when: v.reading ? '' : v.last_at ? short(ago(v.last_at, now)) : 'Never read', act: null };
151
+ }
140
152
  /**
141
153
  * connectorRows(sources, health, now) → [{ id, name, trouble, why, when, act }] trouble rows first (needs you, then failed, then
142
154
  * the other issues), then the quiet rows in the server's order.
@@ -169,6 +181,8 @@ export function connectorRows(sources, health, now = Date.now()) {
169
181
  }
170
182
  const mend = h && h.state === 'repairing' && (s.state === 'stale' || s.state === 'never');
171
183
  const sch = s.schedule || {}, job = sch.refresh || null, line = scheduleLine(s, now);
184
+ // batch 31 item 6 (A): Your tools is one row per service, each with its own rhythm; a stuck read names why on the services it holds
185
+ if (Array.isArray(sch.svcs) && sch.svcs.length && sch.cadence !== 'off') { for (const v of sch.svcs) out.push(svcRow(v, sch, job, now)); continue; }
172
186
  if (line && line.missed && !mend && s.state !== 'building' && s.state !== 'off') {
173
187
  out.push({ id: s.id, name, trouble: 4, why: line.text, when: '', act: read, ...(job ? { job } : {}) });
174
188
  continue;
@@ -860,3 +860,79 @@ form.hm-box textarea { min-height: 48px; border: 0; background: none; resize: no
860
860
  /* chief-of-staff C1 (board CsA): where an answer came from, one quiet line under it (pm/chat-src.js) */
861
861
  .hm-src { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0 2px; }
862
862
  .hm-src span { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-meta); color: var(--cz-ink3); }
863
+
864
+ /* ── the phone chat (batch 31 item 5, roomier-phone-chat; boards RcB, RcBfiles, RcBmenu): three zones on one 16 px grid ──
865
+ * The top bar: ← · the title over ONE context line · ⋯ (pm/phone-chat-head.js). The stream: messages only, full width, 24 px between
866
+ * turns and tight inside one. The foot: one box, + · input · mic · send, four 44 px controls. Desktop draws none of this. */
867
+ .hm-ctx, .hm-ell { display: none; }
868
+ .hm-cs[hidden], .hm-csc[hidden] { display: none; }
869
+ @media (max-width: 760px) {
870
+ /* the top bar: the 44 px boxes of ← and ⋯ put their glyphs on the 16 px margins */
871
+ body.cz-home:not(.hm-plist) .hm-top { align-items: center; gap: 0; min-height: 56px; box-sizing: border-box; padding: 6px 4px 6px 3px; }
872
+ body.cz-home:not(.hm-plist) .hm-top .hm-back { flex: none; margin: 0; }
873
+ body.cz-home:not(.hm-plist) .hm-top-t { flex-direction: column; align-items: flex-start; gap: 0; padding: 0 8px 0 5px; }
874
+ body.cz-home:not(.hm-plist) .hm-top-t b { max-width: 100%; font-size: var(--fs-row); line-height: 22px; } /* the row role on a 22 px line (R28-14: no raw size) */
875
+ body.cz-home:not(.hm-plist) .hm-top-t:has(.hm-ctx:not([hidden])) .hm-rn { min-height: 22px; }
876
+ body.cz-home:not(.hm-plist) .hm-ctx:not([hidden]) { display: flex; align-items: center; gap: 4px; max-width: 100%; min-height: 18px; margin: 0; padding: 0; border: 0; background: none; color: var(--cz-ink3); font: var(--fw-regular) var(--fs-meta)/18px var(--cz-sans); cursor: pointer; text-align: left; }
877
+ body.cz-home:not(.hm-plist) .hm-ctx em { font-style: normal; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
878
+ body.cz-home:not(.hm-plist) .hm-ctx svg { flex: none; }
879
+ body.cz-home:not(.hm-plist) .hm-ell { position: relative; flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin: 0 0 0 auto; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--cz-ink2); cursor: pointer; }
880
+ body.cz-home:not(.hm-plist) .hm-top:has(.hm-ren) :is(.hm-ell, .hm-ctx) { display: none; } /* renaming: the field fills the bar beside back */
881
+ body.cz-home:not(.hm-plist) .hm-top-t:has(.hm-ren) { align-items: stretch; }
882
+ .hm-ell i { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--cz-blue); box-shadow: 0 0 0 2px var(--cz-card); }
883
+ .hm-ell i[hidden] { display: none; }
884
+ /* ⋯ opens the one nav menu under the top bar; no round button, no live bubble, no waiting bar on a phone chat */
885
+ body.cz-home:not(.hm-plist):not(.hm-sheet) .cz-fabw.cz-top,
886
+ body.cz-home:not(.hm-plist):not(.hm-sheet) .cz-fabw:has(> .lv-tray:not([hidden])) { display: flex; }
887
+ body.cz-home:not(.hm-plist):not(.hm-sheet) .cz-fabw.cz-top { top: 52px; right: 16px; bottom: auto; left: auto; }
888
+ body.cz-home:not(.hm-plist):not(.hm-sheet) .cz-fabw > :is(.cz-fab, .cz-live, .ev-fd) { display: none; }
889
+ body.cz-home:not(.hm-plist) .hm-also, body.cz-home:not(.hm-plist) form#hmForm.hm-box .hm-chip { display: none; }
890
+ /* the sheet the context line opens: the initiative, its files, its pull requests, Sends to */
891
+ .hm-csc { position: fixed; inset: 0; z-index: 70; background: color-mix(in srgb, var(--cz-ink) 22%, transparent); }
892
+ .hm-cs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 71; max-height: 80vh; max-height: 80dvh; overflow-y: auto; box-sizing: border-box; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: var(--cz-card); box-shadow: var(--cz-sheet); display: flex; flex-direction: column; }
893
+ .hm-csg { flex: none; width: 36px; height: 4px; margin: 0 auto 12px; border-radius: 2px; background: var(--cz-hair); }
894
+ .hm-csl { margin: 0; padding: 8px 0 4px; font-size: var(--fs-meta); line-height: 18px; color: var(--cz-ink3); }
895
+ .hm-css { height: 1px; margin: 8px 0; background: var(--cz-hair); }
896
+ .hm-csr { display: flex; align-items: center; gap: 12px; min-height: 56px; width: 100%; padding: 0; border: 0; background: none; color: var(--cz-ink); font: inherit; font-size: var(--fs-body); text-align: left; text-decoration: none; cursor: pointer; }
897
+ .hm-csr .ic { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: var(--cz-well); color: var(--cz-ink2); }
898
+ .hm-csr .t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
899
+ .hm-csr .t b { font-weight: var(--fw-regular); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
900
+ .hm-csr .t small { font-size: var(--fs-meta); color: var(--cz-ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
901
+ .hm-csr em { flex: none; font-style: normal; font-size: var(--fs-meta); color: var(--cz-ink3); }
902
+ .hm-csr > svg { flex: none; color: var(--cz-ink3); }
903
+ .hm-csr:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 12px; }
904
+
905
+ /* the stream: messages only, from margin to margin. Adler stays on the empty chat's intro. */
906
+ body.cz-home:not(.hm-plist) .hm-log { gap: 0; padding: 12px 0 16px; }
907
+ body.cz-home:not(.hm-plist) .hm-log > * + * { margin-top: 24px; }
908
+ body.cz-home:not(.hm-plist) .hm-log > .hm-worked + .hm-a { margin-top: 2px; }
909
+ body.cz-home:not(.hm-plist) .hm-a:not(.hm-intro) > .hm-av { display: none; }
910
+ body.cz-home:not(.hm-plist) .hm-a { gap: 0; }
911
+ body.cz-home:not(.hm-plist) .hm-a.hm-intro { gap: 10px; }
912
+ body.cz-home:not(.hm-plist) :is(.hm-worked, .hm-pills) { padding-left: 0; }
913
+ body.cz-home:not(.hm-plist) .hm-wk { padding: 0; gap: 6px; min-height: 28px; }
914
+ body.cz-home:not(.hm-plist) .hm-ab .md p { margin: 0 0 8px; }
915
+ body.cz-home:not(.hm-plist) .hm-ab .md p:last-child { margin-bottom: 0; }
916
+ body.cz-home:not(.hm-plist) .hm-bub { padding: 10px 16px; }
917
+ /* no name and time line and no "You · 12:09": still read out to a screen reader. The ask card keeps its name line. */
918
+ body.cz-home:not(.hm-plist) .hm-a:not(.ask):not(.hm-intro) .hm-ab > .hm-who:not(:has(.hm-say)),
919
+ body.cz-home:not(.hm-plist) .hm-u > .hm-you { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
920
+ /* Copy, Retry and Make a work-item: on the newest message; an older one shows them on press and hold, or on focus */
921
+ body.cz-home:not(.hm-plist) .hm-tools { margin-top: 8px; }
922
+ body.cz-home:not(.hm-plist) .hm-a:not(.last):not(.held):not(:focus-within) .hm-tools { height: 0; margin: 0; overflow: hidden; opacity: 0; }
923
+
924
+ /* the foot: one box, + · input · mic · send, on the card with no fade over the stream */
925
+ body.cz-home:not(.hm-plist) #hmFoot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--cz-card); }
926
+ body.cz-home:not(.hm-plist) #hmFoot::before { content: none; }
927
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 0; padding: 4px; border-radius: 26px; }
928
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box .hm-tb { display: contents; }
929
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box .hm-tb > :is(.sp, .hm-key) { display: none; }
930
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box > *, body.cz-home:not(.hm-plist) form#hmForm.hm-box .hm-tb > * { order: 2; }
931
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box .hm-addw { order: 0; width: 44px; flex: none; margin: 0; }
932
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box textarea { order: 1; flex: 1; min-width: 0; box-sizing: border-box; min-height: 44px; margin: 0; padding: 11px 8px 11px 4px; line-height: 22px; }
933
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* one row: a long placeholder ends in … */
934
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box .ut-mic { order: 3; }
935
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box .hm-send { order: 4; }
936
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box :is(.hm-tool, .ut-mic, .hm-send) { flex: none; width: 44px; height: 44px; margin: 0; }
937
+ body.cz-home:not(.hm-plist) form#hmForm.hm-box > .hm-files { order: 9; flex-basis: 100%; padding: 4px 8px; box-sizing: border-box; }
938
+ }
@@ -21,6 +21,8 @@
21
21
  * 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
22
22
  * session); the recording comes from pm/rec-state.js. The recording's row has one icon-only Stop beside it (Wawan, 2026-11-03: finish
23
23
  * from anywhere): the first press asks "Press again", the second ends the meeting (rec-state.js stopPress). Nothing else is written.
24
+ * The phone chat has no round button (batch 31 item 5): its ⋯ menu shows "Live now · N" from the event 'cz:live-n' ({ n }) and opens
25
+ * this list with the event 'cz:live-open'.
24
26
  * Adler (batch 17 item 4-B, AdM1 "Live recording pill", AdH5): while a meeting records, his S face with headphones follows the clock, now in
25
27
  * the recording's row. The red dot stays: the face never replaces the row's mark. Paused, he is not shown (nobody is listening). */
26
28
  import { onRecording, stopPress } from './rec-state.js';
@@ -111,6 +113,7 @@ export function mountLivePill(doc = document, opts = {}) {
111
113
  function draw() {
112
114
  if (!pill) return;
113
115
  const now = items();
116
+ if (now.length !== L.n) { L.n = now.length; doc.dispatchEvent(new CustomEvent('cz:live-n', { detail: { n: now.length } })); } // the phone chat's ⋯ says "Live now · N" (batch 31 item 5)
114
117
  if (!now.length && !L.open) { pill.hidden = true; tray.hidden = true; scrim.hidden = true; return; }
115
118
  const list = L.open ? keepOrder(L.shown, now) : now;
116
119
  if (L.open && !list.length) { set(false); return; }
@@ -219,5 +222,6 @@ export function mountLivePill(doc = document, opts = {}) {
219
222
  setInterval(read, 10000);
220
223
  doc.addEventListener('visibilitychange', () => { if (!doc.hidden) read(); });
221
224
  doc.addEventListener('cz:live', () => read());
225
+ doc.addEventListener('cz:live-open', () => { if (pill) set(true); }); // the phone chat's ⋯ > Live now: the same list, with no round button
222
226
  doc.addEventListener('cz-panels', () => draw()); // a panel put away or brought back
223
227
  }
@@ -21,6 +21,8 @@
21
21
  * are Adler's ears over the phone button (AdP6): Your move is the one place that says what is yours.
22
22
  * THE CHAT (C5, board CsB): the tray's chat icon opens the one chat over the page you are on (pm/page-chat.js openCos), with a soft
23
23
  * "You are on …" chip. A page that has its own chat column (Home) passes opts.chat() and the icon focuses that chat instead.
24
+ * FROM THE TOP BAR (batch 31 item 5, board RcBmenu): openMenu({ anchor, rows }) opens the same menu under a page's own ⋯ (the phone
25
+ * chat has no round button). rows go on top of the places, each { label, icon, dot, go }; the menu closes and focus goes back to the anchor.
24
26
  */
25
27
  import { esc, svg, ICON, wsQ } from './cozy-evui.js';
26
28
  import { fabLabel, bannerOf } from './cozy-evmodel.js';
@@ -35,7 +37,8 @@ export const PLACES = [
35
37
  export { fabLabel };
36
38
  const THEME_KEY = 'pmos.c3.theme';
37
39
  const CSS = new URL('./cozy-ev.css', import.meta.url).href;
38
- const N = { news: 0, stale: null, here: 'home', calls: 0, fresh: new Set() };
40
+ const N = { news: 0, stale: null, here: 'home', calls: 0, fresh: new Set(), extra: [], from: null };
41
+ let OPEN = null; // mountNav's own open(o): openMenu reaches the one menu of the page
39
42
  /* A place that just opened (onboarding B3, ObA4Gradual; GET /api/moments places[p].dot): its menu row gets one soft blue dot until the PM
40
43
  * first opens it. Reports live in Intelligence, so their dot is on the Intelligence row. */
41
44
  const ROW_OF = { board: 'board', insights: 'insights', reports: 'insights' };
@@ -54,10 +57,12 @@ export function setTheme(pick, doc = document, { keep = true } = {}) {
54
57
  doc.dispatchEvent(new CustomEvent('cz:theme', { detail: { pick: p, dark } }));
55
58
  }
56
59
 
57
- /** The menu's markup; pure, so a unit test can read it. here: home | board | insights. o: { news, stale: { text } | null } */
60
+ /** The menu's markup; pure, so a unit test can read it. here: home | board | insights. o: { news, stale: { text } | null, extra: rows }
61
+ * extra: the rows a page's own ⋯ puts on top ({ label, icon, dot }), as buttons data-cz-extra="i". */
58
62
  export function menuHtml(here, o = {}) {
59
63
  const calls = o.calls > 0, dot = (c) => `<i class="ev-md ${c}" aria-hidden="true"></i>`;
60
- return PLACES.map((p) => {
64
+ const extra = (o.extra || []).map((x, i) => `<button type="button" class="ev-mi ev-x" data-cz-extra="${i}">${x.icon ? svg(x.icon, 18) : ''}<span>${esc(x.label)}</span>${x.dot ? dot('you') : ''}</button>`).join('');
65
+ return extra + PLACES.map((p) => {
61
66
  const opened = p.key !== here && !!(o.fresh && o.fresh.has(p.key));
62
67
  const you = (p.key === 'home' && calls) || opened;
63
68
  const lab = p.key === 'home' && calls ? ` aria-label="${p.label}. ${o.calls === 1 ? 'One call is yours' : o.calls + ' calls are yours'} in Your move"` : opened ? ` aria-label="${p.label}. New: it has something to show now"` : '';
@@ -80,6 +85,9 @@ async function getj(p) { try { const r = await fetch(p, { credentials: 'same-ori
80
85
  /** What the button adds to its name while a call is the PM's: 'One call is yours' · '3 calls are yours'. */
81
86
  export const callWords = (n) => (n === 1 ? 'One call is yours' : n + ' calls are yours');
82
87
 
88
+ /** Open the page's one menu from its own button (the phone chat's ⋯): { anchor, rows: [{ label, icon, dot, go }] }. A second press closes it. */
89
+ export function openMenu(o = {}) { if (OPEN) OPEN(o); }
90
+
83
91
  /** Mount the menu once. `here` is home | board | insights. Returns the wrapper. */
84
92
  export function mountNav(here, doc = document, opts = {}) {
85
93
  const old = doc.getElementById('czNav'); if (old) return old;
@@ -98,7 +106,7 @@ export function mountNav(here, doc = document, opts = {}) {
98
106
  mountToastFaces(doc); loadPrefs();
99
107
  const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
100
108
  const draw = () => {
101
- menu.innerHTML = menuHtml(here, { calls: N.calls, stale: N.stale, fresh: N.fresh });
109
+ menu.innerHTML = menuHtml(here, { calls: N.calls, stale: N.stale, fresh: N.fresh, extra: N.extra });
102
110
  const opened = [...N.fresh].some((k) => k !== here);
103
111
  // one dot: amber while a source needs the PM, else blue while a call is theirs or a place has something new
104
112
  w.querySelector('#czFdRisk').hidden = !N.stale || !menu.hidden;
@@ -106,23 +114,35 @@ export function mountNav(here, doc = document, opts = {}) {
106
114
  if (menu.hidden) fab.setAttribute('aria-label', fabLabel(here, false, N.stale) + (opened ? '. A place has something new to show' : '') + (N.calls > 0 ? '. ' + callWords(N.calls) : ''));
107
115
  };
108
116
  const set = (open) => {
117
+ if (!open && N.from) { N.from.setAttribute('aria-expanded', 'false'); N.from = null; N.extra = []; w.classList.remove('cz-top'); }
109
118
  menu.hidden = !open; scrim.hidden = !open; fab.setAttribute('aria-expanded', String(open));
110
119
  fab.setAttribute('aria-label', fabLabel(here, open, N.stale)); fab.innerHTML = svg(open ? ICON.close : ICON.menu, 22);
111
120
  draw();
112
121
  if (open) { const f = menu.querySelector('a, button'); if (f) f.focus(); }
113
122
  };
123
+ OPEN = (o) => {
124
+ const back = N.from;
125
+ if (!menu.hidden) { set(false); if (back === o.anchor) { if (back) back.focus(); return; } }
126
+ N.from = o.anchor || null; N.extra = o.rows || [];
127
+ w.classList.toggle('cz-top', !!N.from);
128
+ if (N.from) N.from.setAttribute('aria-expanded', 'true');
129
+ set(true);
130
+ };
114
131
  draw();
115
132
  fab.addEventListener('click', () => set(menu.hidden));
116
133
  scrim.addEventListener('click', () => set(false));
117
- doc.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menu.hidden) { e.stopPropagation(); set(false); fab.focus(); } }, true);
134
+ doc.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menu.hidden) { e.stopPropagation(); const back = N.from || fab; set(false); back.focus(); } }, true);
118
135
  // set() redraws the button's icon, so the pressed icon may be gone from the page by now: only a press still on the page closes the menu
119
- doc.addEventListener('click', (e) => { if (!menu.hidden && e.target.isConnected && !w.contains(e.target)) set(false); });
136
+ // (the ⋯ that opened it toggles it itself)
137
+ doc.addEventListener('click', (e) => { if (!menu.hidden && e.target.isConnected && !w.contains(e.target) && !(N.from && N.from.contains(e.target))) set(false); });
120
138
  menu.addEventListener('click', (e) => {
121
139
  // the page you are on, pressed again: a page that passes opts.here goes back to its start without a reload (Home: the list, no page open)
122
140
  const a = e.target.closest('a[aria-current="page"]');
123
141
  if (a && opts.here && !e.metaKey && !e.ctrlKey && !e.shiftKey) { e.preventDefault(); set(false); opts.here(); return; }
124
142
  const b = e.target.closest('button'); if (!b) return;
143
+ const x = 'czExtra' in b.dataset ? N.extra[+b.dataset.czExtra] : null;
125
144
  set(false);
145
+ if (x) { if (x.go) x.go(); return; }
126
146
  if ('czChat' in b.dataset) { if (opts.chat) opts.chat(); else import('./page-chat.js').then((M) => M.openCos({ here: opts.where ? opts.where() : PLACES.find((p) => p.key === here) ? PLACES.find((p) => p.key === here).label : '' })); }
127
147
  else if ('czSearch' in b.dataset) import('./cozy-search.js').then((M) => M.openSearch({ ...(opts.search ? { go: opts.search() } : {}), ...(opts.scope ? { scope: opts.scope() } : {}) }));
128
148
  // a stale source opens Settings at Connectors, the stale one first (FmA3Settings: open where it matters)
@@ -0,0 +1,80 @@
1
+ /* cozy-relay.js — Settings › Connectors › Listening (initiative event-relay; D110; design "Connectors directory and events", board CnC).
2
+ *
3
+ * GitHub and Jira can send events to the central host; PMOS pulls them each minute and starts a read of that service. An event only starts a
4
+ * read: it never changes a record. Each row: the service, what it does now (Listening · the last event, or Reads on its schedule), and icon
5
+ * buttons: listen, show the steps again, stop. The steps show the address and the secret with a copy button each, for the PM to paste into
6
+ * GitHub or Jira; PMOS sends nothing to those services.
7
+ *
8
+ * relayState() -> a fresh state object for one Settings dialog
9
+ * relayLoad(R) GET /api/relay
10
+ * relayHtml(R) -> the Listening block (a slot under the Connectors rows)
11
+ * relayClick(e, R, redraw, toast) -> true when the press was one of this block's; runs the press
12
+ * Routes: lib/routes-relay.js. UI copy says PMOS. */
13
+ import { pmGet, pmPost } from './http.js';
14
+ import { esc, svg } from './cozy-evui.js';
15
+
16
+ const LABEL = { github: 'GitHub', jira: 'Jira' };
17
+ const BELL = 'M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0';
18
+ const OFF = 'M6 16V11a6 6 0 0 1 9.5-4.9M18 11v5l2 2H8M10 20a2 2 0 0 0 4 0M3 3l18 18';
19
+ const STEPS = 'M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01';
20
+ const COPY = 'M9 9h11v11H9zM5 15V5a1 1 0 0 1 1-1h10';
21
+ function ago(iso) {
22
+ const t = Date.parse(iso); if (!Number.isFinite(t)) return '';
23
+ const m = Math.round((Date.now() - t) / 60000);
24
+ if (m < 1) return 'just now'; if (m < 60) return m + ' min ago';
25
+ const h = Math.round(m / 60); if (h < 24) return h + ' h ago';
26
+ return Math.round(h / 24) + ' d ago';
27
+ }
28
+
29
+ export function relayState() { return { st: null, open: null, steps: null, busy: false }; }
30
+
31
+ export async function relayLoad(R) {
32
+ const r = await pmGet('/api/relay');
33
+ R.st = r && r.ok ? r : { ok: false };
34
+ }
35
+
36
+ const ib = (act, src, icon, label) => `<button type="button" class="ev-ib" data-rl="${act}" data-rls="${esc(src)}" aria-label="${esc(label)}" title="${esc(label)}">${svg(icon, 18)}</button>`;
37
+
38
+ export function relayHtml(R) {
39
+ const st = R.st;
40
+ if (st === null) return '';
41
+ const head = '<h4 id="evListen">Listening</h4>';
42
+ if (!st.ok) return `<div data-relay>${head}<p class="ev-small ev-mut">The listening settings could not be read.</p></div>`;
43
+ const rows = Object.keys(LABEL).map((k) => {
44
+ const s = (st.sources && st.sources[k]) || { listening: false };
45
+ const what = s.listening ? 'Listening · ' + (s.last ? 'last event ' + ago(s.last) : 'no event yet') : 'Reads on its schedule';
46
+ const acts = s.listening ? ib('steps', k, STEPS, 'Show the ' + LABEL[k] + ' steps') + ib('stop', k, OFF, 'Stop listening to ' + LABEL[k]) : ib('setup', k, BELL, 'Listen for ' + LABEL[k] + ' events');
47
+ let panel = '';
48
+ if (R.open === k && R.steps && R.steps.source === k) {
49
+ panel = `<div class="ev-rl-steps ev-small" data-rl-panel="${esc(k)}"><ol>${R.steps.steps.map((x) => `<li>${esc(x)}</li>`).join('')}</ol>`
50
+ + `<div class="ev-rl-kv"><b>Address</b><code>${esc(R.steps.url)}</code>${ib('copy-url', k, COPY, 'Copy the address')}</div>`
51
+ + `<div class="ev-rl-kv"><b>Secret</b><code>${esc(R.steps.secret)}</code>${ib('copy-secret', k, COPY, 'Copy the secret')}</div></div>`;
52
+ }
53
+ return `<div class="ev-trow ev-fr" data-rl-row="${esc(k)}"><span class="ev-gut">${s.listening ? '<i class="ev-dot ok" aria-hidden="true"></i>' : ''}</span><div class="ev-tx ev-grow"><span>${esc(LABEL[k])}</span><p class="ev-small ev-mut">${esc(what)}</p></div><span class="ev-rl-acts">${acts}</span></div>${panel}`;
54
+ }).join('');
55
+ const recent = (st.recent || []).slice(0, 5);
56
+ const ev = recent.length ? `<ul class="ev-rl-ev ev-small ev-mut" aria-label="Recent events">${recent.map((e) => `<li>${esc(LABEL[e.source] || e.source)} · ${esc(e.kind)}${e.key ? ' · ' + esc(e.key) : ''} · ${esc(ago(e.at))}</li>`).join('')}</ul>` : '';
57
+ const host = st.host ? '' : '<p class="ev-small ev-late">Listening needs the central host. Set its address in Board › Publish first.</p>';
58
+ return `<div data-relay>${head}<p class="ev-small ev-mut">A service that sends events is read within a minute of a change, even while this computer sleeps. An event only starts a read; it never changes your records.</p>${host}${rows}${ev}</div>`;
59
+ }
60
+
61
+ export async function relayClick(e, R, redraw, toast) {
62
+ const b = e.target.closest('[data-rl]'); if (!b) return false;
63
+ if (R.busy) return true;
64
+ const act = b.dataset.rl, src = b.dataset.rls, name = LABEL[src] || src;
65
+ const say = (t) => { if (toast) toast(t); };
66
+ if (act === 'copy-url' || act === 'copy-secret') {
67
+ const v = R.steps ? (act === 'copy-url' ? R.steps.url : R.steps.secret) : '';
68
+ try { await navigator.clipboard.writeText(v); say(act === 'copy-url' ? 'Address copied.' : 'Secret copied.'); } catch { say('Select it and copy it by hand.'); }
69
+ return true;
70
+ }
71
+ if (act === 'steps' && R.open === src) { R.open = null; R.steps = null; redraw(); return true; }
72
+ R.busy = true;
73
+ const r = await pmPost('/api/relay/' + (act === 'setup' ? 'setup' : act === 'stop' ? 'stop' : 'steps'), { source: src });
74
+ R.busy = false;
75
+ if (!r || r.ok === false) { say((r && r.error) || 'Not done.'); return true; }
76
+ if (act === 'stop') { R.open = null; R.steps = null; say('PMOS stopped listening to ' + name + '. It reads it on its schedule.'); }
77
+ else { R.open = src; R.steps = r; if (act === 'setup') say('Paste the address and the secret into ' + name + '.'); }
78
+ await relayLoad(R); redraw();
79
+ return true;
80
+ }