create-pmos 0.599.0 → 0.600.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.599.0",
3
+ "version": "0.600.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,19 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.600.0",
38
+ "at": "2026-11-18T06:46:12.110Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1343,
43
+ "t": "A roomier phone chat: one context line, ⋯ menu, full-width stream, one-row box",
44
+ "s": "A roomier phone chat: one context line, ⋯ menu, full-width stream, one-row box",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
36
49
  {
37
50
  "v": "0.599.0",
38
51
  "at": "2026-11-18T05:55:46.962Z",
@@ -297,19 +310,6 @@
297
310
  "k": "new"
298
311
  }
299
312
  ]
300
- },
301
- {
302
- "v": "0.580.0",
303
- "at": "2026-11-17T02:13:59.003Z",
304
- "f": 4,
305
- "prs": [
306
- {
307
- "n": 1309,
308
- "t": "Standing rules become checks; the harness joins the trigger list",
309
- "s": "Standing rules become checks; the harness joins the trigger list",
310
- "k": "new"
311
- }
312
- ]
313
313
  }
314
314
  ]
315
315
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@0e4e563a
1
+ kernel-source: pmos@5cdf7b91
2
2
  assembled: 2026-11-18
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-18T05:55:44Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-18T06:46:09Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-18T05:55:44Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-18T06:46:09Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-18T05:55:44Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-18T06:46:09Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.600.0",
4
+ "at": "2026-11-18T06:46:12.110Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1343,
9
+ "t": "A roomier phone chat: one context line, ⋯ menu, full-width stream, one-row box",
10
+ "s": "A roomier phone chat: one context line, ⋯ menu, full-width stream, one-row box",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.599.0",
4
17
  "at": "2026-11-18T05:55:46.962Z",
@@ -2,7 +2,7 @@
2
2
  type: Guide
3
3
  title: "Layout and first run: the places, the menu, the Viewer, the launcher and Adler"
4
4
  description: "The three places, the menu button, the Viewer, the keys and the phone; the first run; when features appear; the PMOS app; and Adler."
5
- timestamp: 2026-11-10
5
+ timestamp: 2026-11-18
6
6
  ---
7
7
 
8
8
  # Layout and first run
@@ -11,7 +11,7 @@ PMOS has three places: **Home**, **Board** and **Intelligence**. Each fills the
11
11
 
12
12
  ## The menu button
13
13
 
14
- The round button at the bottom of every page moves between the places: bottom left on a computer, bottom right on a phone. Press it to open the menu: **Home**, **Board** and **Intelligence**, then three icons: **Search**, **Guide** and **Settings**. The menu holds nothing else.
14
+ The round button at the bottom of every page moves between the places: bottom left on a computer, bottom right on a phone. Press it to open the menu: **Home**, **Board** and **Intelligence**, then three icons: **Search**, **Guide** and **Settings**. The menu holds nothing else. In a chat on a phone, **⋯** in the top bar opens the same menu (see [On a phone](#on-a-phone)).
15
15
 
16
16
  - The button has a blue dot when something is new for you and an amber dot when a source is stale.
17
17
  - Press the place you are on to go back to its start.
@@ -45,7 +45,14 @@ A key that you type in a field, or in a terminal, goes to the field or the termi
45
45
 
46
46
  ## On a phone
47
47
 
48
- At phone width, Home's list is the page. A row opens its item over the list, with a back bar. The menu button is at the bottom right. In a chat the message box stays at the bottom of the screen while you scroll, and the menu button sits just above it, with the Live count beside it. Messages fade out under them. Search fills the screen. The Viewer fills the screen, and ← at the first item closes it.
48
+ At phone width, Home's list is the page. The menu button is at the bottom right. A row opens its item over the list. Search fills the screen. The Viewer fills the screen, and ← at the first item closes it.
49
+
50
+ A chat on a phone uses the full width of the screen:
51
+
52
+ - **The top bar** has ← on the left, the chat's name with one line under it, and **⋯** on the right. The line says what the chat is about: the initiative, the number of files and the number of pull requests. Something with none is left out. With nothing to show, the line says where your messages go. Tap the line to open a sheet with the initiative, its newest files (and **All files**), its pull requests and **Sends to**, where you change where your messages go.
53
+ - **⋯** opens the menu under the top bar. **Waiting on you** and **Live now** are at the top of it when something is there. A blue dot on ⋯ means that something waits on you. A chat has no round menu button.
54
+ - **The messages** have no picture and no name or time line. Copy, Retry and Make a work-item are under the newest message. To see them under an older message, touch and hold that message.
55
+ - **The message box** is one row: **+**, the text, the microphone and send. It stays at the bottom of the screen while you scroll.
49
56
 
50
57
  ## First run
51
58
 
@@ -127,11 +127,11 @@ function build(f) {
127
127
  const phases = dd && Array.isArray(dd.phases) && dd.phases.length ? dd.phases.slice() : null;
128
128
  const all = dd ? (dd.docs || []).map((d) => ({
129
129
  key: d.key, title: d.title, what: d.for || '', st: d.st, state: d.kind === 'live' ? 'Live' : DOC_STATE[d.st] || d.st || '', by: BY[d.by] || d.by || '', byKey: d.by || '',
130
- when: d.when ? shortDate(d.when) : '', cat: phases ? (d.other ? null : d.cat || null) : d.cat === 'Do' ? 'Build' : d.cat === 'Learn' ? 'Evaluate' : d.cat || 'Board', ...(d.other ? { other: true } : {}), path: d.open && d.open.path ? d.open.path : null, slot: d.st === 'draft' && d.draft && d.draft.slot ? d.draft.slot : '', running: !!d.running, tech: TECH.has(d.key), kind: d.kind || '', reader: d.reader || '', cadence: d.cadence || '', sections: ((GUIDE[d.key] || {}).sections || []).slice(),
130
+ when: d.when ? shortDate(d.when) : '', at: d.when || '', cat: phases ? (d.other ? null : d.cat || null) : d.cat === 'Do' ? 'Build' : d.cat === 'Learn' ? 'Evaluate' : d.cat || 'Board', ...(d.other ? { other: true } : {}), path: d.open && d.open.path ? d.open.path : null, slot: d.st === 'draft' && d.draft && d.draft.slot ? d.draft.slot : '', running: !!d.running, tech: TECH.has(d.key), kind: d.kind || '', reader: d.reader || '', cadence: d.cadence || '', sections: ((GUIDE[d.key] || {}).sections || []).slice(),
131
131
  act: d.act && d.act.do === 'draft' ? { kind: 'draft', label: d.running ? 'Drafting' : d.act.label || 'Draft it' } : null,
132
132
  from: d.from && d.from.text ? { path: d.from.path, heading: d.from.heading, text: d.from.text, cut: !!d.from.cut } : null,
133
133
  })) : [];
134
- const custom = (f.custom || []).map((d) => Object.assign(Custom.rowOf(d), { added: shortDate(d.at), cat: d.phase || 'Board' }));
134
+ const custom = (f.custom || []).map((d) => Object.assign(Custom.rowOf(d), { added: shortDate(d.at), at: d.at || '', cat: d.phase || 'Board' }));
135
135
  const rows = all.concat(custom);
136
136
  const core = rows.filter((d) => !d.tech);
137
137
  const cnt = { all: core.length, none: core.filter((d) => d.st === 'missing').length, draft: core.filter((d) => d.st === 'draft').length, ok: core.filter((d) => d.st === 'ok' || d.st === 'live').length };
@@ -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); }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.599.0",
3
+ "version": "0.600.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.600.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.600.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",
@@ -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)
@@ -15,7 +15,8 @@
15
15
  * The models are in home-data.js and home-list.js (pure). This file reads the routes, draws, and wires the presses. Every write is the PM's
16
16
  * press (pmPost). Nothing here opens the old dialog or links to the console. */
17
17
  import './fetch-share.js'; // first: identical GETs in flight are asked once (page-open-speed)
18
- import { mountNav } from './cozy-nav.js';
18
+ import { mountNav, openMenu } from './cozy-nav.js';
19
+ import { mountPhoneHead } from './phone-chat-head.js'; // the phone chat's top bar: the context line, its sheet and ⋯ (batch 31 item 5)
19
20
  import { mountSetupChecklist } from './setup-checklist.js';
20
21
  import { mountOnboard } from './cozy-onboard.js';
21
22
  import { mountReveal, leftHtml as revealLeft } from './cozy-reveal.js';
@@ -979,6 +980,7 @@ function allRows() {
979
980
  const rowById = (id) => allRows().find((r) => r.id === id) || null;
980
981
 
981
982
  /* ── the top bar (phone) ── */
983
+ let PH = null; // the phone chat's top bar (mountPhoneHead, below)
982
984
  function drawTop() {
983
985
  const n = H.needsOf(S.D).length;
984
986
  const cur = S.cur || { title: 'Home', sub: '' };
@@ -992,6 +994,7 @@ function drawTop() {
992
994
  $('#hmNeedsN').textContent = !S.ready ? 'Reading' : n ? n + (n === 1 ? ' next step' : ' next steps') : 'Today';
993
995
  $('#hmNeeds').classList.toggle('loud', n > 0);
994
996
  document.title = 'PMOS · ' + (title || 'Home');
997
+ if (PH) PH.draw();
995
998
  }
996
999
  const SN = mountSesName({ esc, pmPost, toast, toastUndo: (m, u) => toastUndo(m, u), session: (sid) => S.D.sessions.find((x) => x.id === sid) || null, shown: (x) => H.nameOf(x),
997
1000
  changed: () => { drawTop(); chat.refresh(); drawList(); } });
@@ -2325,6 +2328,49 @@ const liveGo = (x) => {
2325
2328
  return true;
2326
2329
  };
2327
2330
  mountLivePill(document, { open: () => (S.cur && S.cur.ses) || null, go: liveGo });
2331
+ /* The phone chat's top bar (batch 31 item 5, boards RcB, RcBfiles, RcBmenu): the context line under the title, its sheet, and ⋯ for the
2332
+ * menu with Waiting on you and Live now on top. The initiative's files and pull requests come from its page model: the one Home holds
2333
+ * when it is that initiative, else one read of /api/initiative-premium kept for a minute (PHF). */
2334
+ const PHF = new Map();
2335
+ const iniOfTarget = (t) => { const m = /^init:([^:]+)/.exec((t && t.key) || ''); return (t && t.ini) || (m ? m[1] : null); };
2336
+ function phoneFacts(t) {
2337
+ const ini = iniOfTarget(t);
2338
+ if (!ini || ini === 'product' || !iniRowOf(ini)) return null;
2339
+ let M = S.IM && S.IMid === ini ? S.IM : null;
2340
+ if (!M) {
2341
+ const c = PHF.get(ini);
2342
+ if (c && c.M) M = c.M;
2343
+ if (!c || Date.now() - c.at > 60000) {
2344
+ PHF.set(ini, { M: c ? c.M : null, at: Date.now() });
2345
+ const oi = otherIni(ini);
2346
+ pmGet('/api/initiative-premium?id=' + encodeURIComponent(ini) + (oi && oi.ws ? '&ws=' + encodeURIComponent(oi.ws) : wsQ('&'))).then((r) => {
2347
+ if (r && r.ok && r.model) { PHF.set(ini, { M: r.model, at: Date.now() }); PH.draw(); } else if (r && r.state === 'reading') PHF.delete(ini);
2348
+ }).catch(() => {});
2349
+ }
2350
+ }
2351
+ const files = M && M.docs ? (M.docs.rows || []).filter((d) => d.path) : [];
2352
+ return { ini: { id: ini, title: iniTitle(ini), sub: (M && M.head && M.head.stage) || '' }, files, prs: (M && M.prs) || [] };
2353
+ }
2354
+ async function openIniFrom(id) {
2355
+ if (S.ini !== id) { S.ini = id; S.IM = null; S.IMid = null; S.doneOpen = false; S.stepsMore = false; }
2356
+ return id;
2357
+ }
2358
+ PH = mountPhoneHead({
2359
+ esc, phone: () => isPhone() && !document.body.classList.contains('hm-plist'),
2360
+ target: () => (chat.current ? chat.current() : null),
2361
+ facts: phoneFacts,
2362
+ openIni: async (id) => { await openIniFrom(id); iniPage(); },
2363
+ openFile: (f) => openFile(f),
2364
+ allFiles: async (id) => { await openIniFrom(id); if (S.IMid !== id) await loadIni(); iniOverview('docs'); },
2365
+ sendsTo: (anchor, t) => (t && t.to ? menu(anchor, toItems(t), 'Send your messages to') : menu(anchor, scopeItems(), 'Where this goes')),
2366
+ waiting: () => {
2367
+ const other = H.needsOf(S.D).filter((r) => !(S.sel && S.sel === r.id));
2368
+ const t = chat.current ? chat.current() : null;
2369
+ return { n: other.length, go: () => (t && t.also && t.also.go ? t.also.go() : other[0] ? select(other[0].id) : null) };
2370
+ },
2371
+ openMenu: (o) => openMenu(o),
2372
+ });
2373
+ PH.draw();
2328
2374
  /* The panels (batch 18 item 15, canvas TbT1Split…TbT9Divider): the chat and up to 3 Viewers side by side, the divider, open beside, ⧉, slide
2329
2375
  * over. A Live pill row opens in the chat (liveGo); a remembered Viewer of an initiative opens again here when Home has a view for it. */
2330
2376
  mountPanels({
@@ -14,6 +14,9 @@
14
14
  * The words are Claude Code's own transcript. A conversation is either a chat key (GET /api/briefing-premium/thread?key=, the session it
15
15
  * started, POST /ask and /press) or a session with no chat key (GET /api/sessions/conversation?id=, POST /api/session/say and /keys).
16
16
  * A loose session the host can place (host.suggestLink(target, firstText) → { id, title }) shows one chip: Link it (host.linkTo) or × (host.dismissLink).
17
+ * On a phone (batch 31 item 5) the stream is messages only: no avatar column and no name or time line (both still read out), and
18
+ * Copy, Retry and Make a work-item show on the newest message; an older one shows them on press and hold. The In:/To: chip and the
19
+ * waiting bar leave the box there: the top bar's context line and ⋯ hold them (pm/phone-chat-head.js).
17
20
  * Every write is the PM's press. mountChat(el, host) returns { open(target), refresh(), focus(), send(text) }.
18
21
  * target: { key?, sid?, title, scope: { text, icon, loose }, role: { name, initial }, intro?: { role, text, at, mood? (Adler as the avatar while the log is empty), pills: [{ label, primary, go }] },
19
22
  * ini?, rich, also?: { text, go, verb? ('Answer' when absent; 'Review' for Claude's ✦ proposal) } }
@@ -170,7 +173,7 @@ export function mountChat(el, host) {
170
173
  // a run that stopped: the divider sits where it finished, over Claude's last message, and the fix sits under it (canvas XcbOptions, Routine)
171
174
  const stopAt = R.stop && i === R.lastAgent;
172
175
  const av = last && isClaude(R.role) ? adlerAvHtml(asking || ak.block ? 'needs-you' : stopAt ? 'honest' : running() ? 'thinking' : 'handled') : avHtml(R.role);
173
- return (stopAt ? dividerHtml({ tone: R.stop.tone, text: R.stop.text }) : '') + `<div class="hm-a${asking ? ' ask' : ''}">${av}<div class="hm-ab"><p class="hm-who">${esc(R.role.name)} <span>${esc(hm(it.at))}</span></p>${rp.text ? verHtml(rp.text) : ''}${srcHtml(sr.src)}${goalBlockHtml(go.block, go)}${reportChipHtml(rp.block, it.mi)}${R.chips(it.mi)}`
176
+ return (stopAt ? dividerHtml({ tone: R.stop.tone, text: R.stop.text }) : '') + `<div class="hm-a${asking ? ' ask' : ''}${last ? ' last' : ''}">${av}<div class="hm-ab"><p class="hm-who">${esc(R.role.name)} <span>${esc(hm(it.at))}</span></p>${rp.text ? verHtml(rp.text) : ''}${srcHtml(sr.src)}${goalBlockHtml(go.block, go)}${reportChipHtml(rp.block, it.mi)}${R.chips(it.mi)}`
174
177
  + (asking ? '' : `<div class="hm-tools" role="group" aria-label="Message actions"><button type="button" data-hm-copy="${i}">Copy</button>${last && !running() && !(stopAt && R.stop.actions.length) ? `<button type="button" data-hm-retry>Retry</button>` : ''}<button type="button" data-hm-wi="${i}">Make a work-item</button></div>`) + '</div></div>'
175
178
  + (stopAt && R.stop.actions.length ? `<div class="hm-fix" role="group" aria-label="What to do next">${R.stop.actions.map((a, k) => iconBtn({ icon: a.icon, label: a.label, attr: a.data, pri: k === 0 })).join('')}</div>` : '')
176
179
  + blockAskHtml(ak.block, it, R);
@@ -189,7 +192,7 @@ export function mountChat(el, host) {
189
192
  if (!o) return '';
190
193
  const r = o.role || { name: 'PMOS', initial: 'P' };
191
194
  const card = o.card && typeof o.card.html === 'function' ? o.card.html() : '';
192
- return `<div class="hm-a">${o.mood && alone && isClaude(r) ? adlerAvHtml(o.mood) : avHtml(r)}<div class="hm-ab"><p class="hm-who"><b>${esc(r.name)}</b> <span class="hm-say">${esc(o.text)}</span></p>${card ? `<div class="hm-icard">${card}</div>` : ''}</div></div>`
195
+ return `<div class="hm-a hm-intro">${o.mood && alone && isClaude(r) ? adlerAvHtml(o.mood) : avHtml(r)}<div class="hm-ab"><p class="hm-who"><b>${esc(r.name)}</b> <span class="hm-say">${esc(o.text)}</span></p>${card ? `<div class="hm-icard">${card}</div>` : ''}</div></div>`
193
196
  + (o.pills && o.pills.length ? `<div class="hm-pills">${o.pills.map((p, i) => `<button type="button" class="${p.primary ? 'pri' : ''}" data-hm-pill="${i}"${p.disabled ? ' disabled' : ''}>${esc(p.label)}</button>`).join('')}</div>` : '');
194
197
  }
195
198
  /** Claude's question card (AskUserQuestion), answerable until the PM writes again. */
@@ -725,6 +728,18 @@ export function mountChat(el, host) {
725
728
  window.addEventListener('pmos:point', (e) => { if (!mine(e)) return; C.mark = { ...(C.mark || {}), point: e.detail.el || e.detail.label ? { el: e.detail.el || '', label: e.detail.label || '' } : null }; drawFoot({ role: role() }); const ta = foot.querySelector('textarea'); if (ta && C.mark.point) ta.focus(); });
726
729
  window.addEventListener('pmos:from', (e) => { if (!mine(e)) return; C.mark = { ...(C.mark || {}), from: Number(e.detail.n) || null }; drawFoot({ role: role() }); const ta = foot.querySelector('textarea'); if (ta) ta.focus(); });
727
730
  window.addEventListener('pmos:say', (e) => { if (!mine(e) || !e.detail.text) return; send(String(e.detail.text)); });
731
+ /* An older message's Copy, Retry and Make a work-item on a phone (batch 31 item 5): press and hold the message to show them (the CSS
732
+ * shows them on the newest message, and on focus for a keyboard). A tap elsewhere hides them again. */
733
+ let holdT = null;
734
+ const unhold = () => el.querySelectorAll('.hm-a.held').forEach((x) => x.classList.remove('held'));
735
+ el.addEventListener('pointerdown', (e) => {
736
+ clearTimeout(holdT);
737
+ const a = e.target.closest('.hm-a');
738
+ if (!a || a.classList.contains('last')) { if (!e.target.closest('.hm-tools')) unhold(); return; }
739
+ if (e.target.closest('button, a, input, textarea')) return;
740
+ holdT = setTimeout(() => { unhold(); a.classList.add('held'); }, 450);
741
+ });
742
+ for (const ev of ['pointerup', 'pointercancel', 'pointermove']) el.addEventListener(ev, (e) => { if (ev !== 'pointermove' || Math.abs(e.movementX) + Math.abs(e.movementY) > 6) clearTimeout(holdT); });
728
743
  el.addEventListener('change', (e) => { if (e.target.id === 'hmFile') { upload([...e.target.files]); e.target.value = ''; } });
729
744
  // a pasted file, or one dropped on the conversation, is attached like a picked one
730
745
  el.addEventListener('paste', (e) => { if (e.target.id !== 'hmIn' || !C.t || !C.t.key) return; const fs = e.clipboardData ? [...e.clipboardData.files] : []; if (!fs.length) return; e.preventDefault(); upload(fs); });
@@ -0,0 +1,147 @@
1
+ /* pm/phone-chat-head.js — the phone chat's top bar (batch 31 item 5, roomier-phone-chat; boards RcB, RcBfiles, RcBmenu).
2
+ *
3
+ * On a phone (max-width 760px) a conversation has three zones on one 16 px grid: the top bar, the stream and the box. The top bar is
4
+ * ← · the title over ONE context line · ⋯.
5
+ * The context line names what the chat is about: "<initiative> · N files · N PR". A kind with nothing is left out (zero is silence).
6
+ * In an initiative's own chat the title is its name, so the line starts "Initiative · <stage>".
7
+ * With no initiative, no files and no PR it says where the words go ("In: Everything", "To: Communicator"), because that chip
8
+ * left the box on a phone; a press opens the sheet.
9
+ * The sheet: the initiative (opens its page), its files (3 newest + "All N files"), its pull requests, and "Sends to" (what the
10
+ * box's In:/To: chip did).
11
+ * ⋯ opens the one nav menu (pm/cozy-nav.js openMenu) under the top bar, with "Waiting on you · N" and "Live now · N" on top; a
12
+ * row with zero is not drawn. A blue dot sits on ⋯ while something waits on you.
13
+ * Desktop never draws any of this (.hm-top is hidden there).
14
+ *
15
+ * ctxModel({ ini, files, prs, to, scope, title }) → { text, label, parts } | null PURE
16
+ * moreRows({ waiting, live }) → [{ key, label, dot }] PURE
17
+ * sheetHtml(m, esc) → string PURE
18
+ * newestFiles(rows, n) → rows PURE
19
+ * mountPhoneHead(host) → { draw() }
20
+ * host: { esc, phone(), target(), facts(t) → { ini: { id, title, sub } | null, files, prs } | null, openIni(id), openFile(f),
21
+ * allFiles(id), sendsTo(anchor, t), waiting() → { n, go }, openMenu(o) }
22
+ */
23
+ const SV = (d, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${d}</svg>`;
24
+ export const IC = {
25
+ ini: '<path d="M5 21V4M5 4h12l-2 4 2 4H5"/>',
26
+ file: '<path d="M7 3h7l5 5v13H7zM14 3v5h5"/>',
27
+ pr: '<circle cx="6" cy="6" r="2.2"/><circle cx="6" cy="18" r="2.2"/><circle cx="18" cy="18" r="2.2"/><path d="M6 8.2v7.6M18 15.8V10a3 3 0 0 0-3-3h-3"/>',
28
+ send: '<path d="M4 12l16-8-6 16-2-7z"/>',
29
+ wait: '<path d="M4 5h16v11H9l-5 4z"/>',
30
+ live: '<circle cx="12" cy="12" r="3"/><path d="M6 6a8.5 8.5 0 0 0 0 12M18 6a8.5 8.5 0 0 1 0 12"/>',
31
+ chev: '<path d="M9 6l6 6-6 6"/>',
32
+ down: '<path d="M7 10l5 5 5-5"/>',
33
+ more: '<circle cx="5" cy="12" r="1.2"/><circle cx="12" cy="12" r="1.2"/><circle cx="19" cy="12" r="1.2"/>',
34
+ };
35
+ /* the ⋯ rows' icons as path data (pm/cozy-evui.js svg draws the menu's own) */
36
+ const MENU_IC = { wait: 'M4 5h16v11H9l-5 4z', live: 'M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6M6 6a8.5 8.5 0 0 0 0 12M18 6a8.5 8.5 0 0 1 0 12' };
37
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
38
+
39
+ /** The 3 (n) newest files: the newest `at` first; a file with no time keeps its place after the dated ones. */
40
+ export function newestFiles(rows, n = 3) {
41
+ const list = (rows || []).filter((f) => f && f.path).map((f, i) => ({ f, i, t: Date.parse(f.at || '') || 0 }));
42
+ list.sort((a, b) => (b.t - a.t) || (a.i - b.i));
43
+ return list.slice(0, n).map((x) => x.f);
44
+ }
45
+
46
+ /** The context line and its sheet's facts. null: nothing to say (no initiative, no file, no PR and nowhere to send). */
47
+ export function ctxModel({ ini = null, files = [], prs = [], to = null, scope = null, title = '' } = {}) {
48
+ const fs = (files || []).filter((f) => f && f.path), ps = (prs || []).filter((p) => p && p.ref);
49
+ const parts = [];
50
+ // an initiative's own chat has its name as the title already (say it once): the line says what it is and its stage instead
51
+ if (ini && ini.title) parts.push(ini.title !== title ? ini.title : ['Initiative', ini.sub].filter(Boolean).join(' · '));
52
+ if (fs.length) parts.push(plural(fs.length, 'file', 'files'));
53
+ if (ps.length) parts.push(ps.length + ' PR');
54
+ const sends = to && to.name ? { text: 'To: ' + to.name, kind: 'to' } : scope && scope.text ? { text: 'In: ' + scope.text, kind: 'scope' } : null;
55
+ if (!parts.length && !sends) return null;
56
+ const text = parts.length ? parts.join(' · ') : sends.text;
57
+ const label = (parts.length ? 'About this chat: ' + parts.join(', ') : 'Where your messages go: ' + sends.text.replace(/^(In|To): /, '')) + '. Show';
58
+ return { text, label, parts, ini: ini && ini.title ? ini : null, files: fs, newest: newestFiles(fs, 3), prs: ps, sends };
59
+ }
60
+
61
+ /** The rows ⋯ adds on top of the nav menu; a row with zero is not drawn. */
62
+ export function moreRows({ waiting = 0, live = 0 } = {}) {
63
+ const out = [];
64
+ if (waiting > 0) out.push({ key: 'wait', label: 'Waiting on you · ' + waiting, icon: MENU_IC.wait, dot: true });
65
+ if (live > 0) out.push({ key: 'live', label: 'Live now · ' + live, icon: MENU_IC.live, dot: false });
66
+ return out;
67
+ }
68
+
69
+ const prName = (p) => { const m = /\/pull\/(\d+)/.exec(p.ref) || /^pr:#?(\d+)$/i.exec(p.ref); return (m ? 'Pull request #' + m[1] : 'Pull request') + (p.item ? ' · ' + p.item : ''); };
70
+ const isUrl = (s) => /^https?:\/\//.test(String(s || ''));
71
+
72
+ /** The sheet the context line opens. Every row is a button or a link with one job. */
73
+ export function sheetHtml(m, esc) {
74
+ if (!m) return '';
75
+ const row = (attrs, ic, title, sub, end) => `<button type="button" class="hm-csr" ${attrs}><span class="ic">${SV(ic)}</span><span class="t"><b>${esc(title)}</b>${sub ? `<small>${esc(sub)}</small>` : ''}</span>${end || ''}</button>`;
76
+ const chev = SV(IC.chev, 14);
77
+ const parts = [];
78
+ if (m.ini) parts.push(row(`data-cs-ini="${esc(m.ini.id)}"`, IC.ini, m.ini.title, ['Initiative', m.ini.sub].filter(Boolean).join(' · '), chev));
79
+ if (m.files.length) {
80
+ parts.push(`<p class="hm-csl">${esc(plural(m.files.length, 'file', 'files'))}</p>`
81
+ + m.newest.map((f) => row(`data-cs-file="${esc(f.path)}" data-cs-name="${esc(f.title || f.name || '')}"`, IC.file, f.title || f.name || f.path.split('/').pop(), f.state || '', f.when ? `<em>${esc(f.when)}</em>` : '')).join('')
82
+ + (m.files.length > m.newest.length && m.ini ? row(`data-cs-all="${esc(m.ini.id)}"`, IC.file, 'All ' + m.files.length + ' files', '', chev) : ''));
83
+ }
84
+ if (m.prs.length) {
85
+ parts.push(`<p class="hm-csl">${esc(plural(m.prs.length, 'pull request', 'pull requests'))}</p>`
86
+ + m.prs.map((p) => (isUrl(p.ref)
87
+ ? `<a class="hm-csr" href="${esc(p.ref)}" target="_blank" rel="noopener"><span class="ic">${SV(IC.pr)}</span><span class="t"><b>${esc(prName(p))}</b><small>${esc(p.state)}</small></span>${chev}</a>`
88
+ : `<div class="hm-csr"><span class="ic">${SV(IC.pr)}</span><span class="t"><b>${esc(prName(p))}</b><small>${esc(p.state)}</small></span></div>`)).join(''));
89
+ }
90
+ if (m.sends) parts.push(row('data-cs-sends', IC.send, 'Sends to', m.sends.text.replace(/^(In|To): /, ''), chev));
91
+ return '<div class="hm-csg" aria-hidden="true"></div>' + parts.join('<div class="hm-css" role="separator"></div>');
92
+ }
93
+
94
+ export function mountPhoneHead(host) {
95
+ const esc = host.esc;
96
+ const top = document.getElementById('hmTop'); if (!top) return { draw() {} };
97
+ const tt = top.querySelector('.hm-top-t');
98
+ tt.insertAdjacentHTML('beforeend', `<button type="button" class="hm-ctx" id="hmCtx" aria-haspopup="dialog" aria-expanded="false" aria-label="About this chat. Show" hidden><em></em>${SV(IC.down, 14)}</button>`);
99
+ top.insertAdjacentHTML('beforeend', `<button type="button" class="hm-ell" id="hmEll" aria-haspopup="menu" aria-expanded="false" aria-label="Menu" title="Menu">${SV(IC.more, 20)}<i aria-hidden="true" hidden></i></button>`);
100
+ document.body.insertAdjacentHTML('beforeend', '<div class="hm-csc" id="hmCsScrim" hidden></div><div class="hm-cs" id="hmCs" role="dialog" aria-label="About this chat" hidden></div>');
101
+ const ctx = top.querySelector('#hmCtx'), ell = top.querySelector('#hmEll'), dot = ell.querySelector('i'), sh = document.getElementById('hmCs'), scrim = document.getElementById('hmCsScrim');
102
+ const H = { m: null, live: 0, t: null };
103
+ document.addEventListener('cz:live-n', (e) => { H.live = (e.detail && e.detail.n) || 0; });
104
+
105
+ function draw() {
106
+ const t = host.phone() ? host.target() : null;
107
+ H.t = t;
108
+ const f = t ? host.facts(t) : null;
109
+ const m = t ? ctxModel({ ini: f && f.ini, files: f ? f.files : [], prs: f ? f.prs : [], to: t.to, scope: t.scope, title: t.title }) : null;
110
+ H.m = m;
111
+ ctx.hidden = !m;
112
+ if (m) {
113
+ const em = ctx.querySelector('em'); if (em.textContent !== m.text) em.textContent = m.text;
114
+ ctx.setAttribute('aria-label', m.label);
115
+ }
116
+ if (!sh.hidden) { if (m) sh.innerHTML = sheetHtml(m, esc); else open(false); }
117
+ const w = host.waiting();
118
+ dot.hidden = !(w && w.n > 0);
119
+ ell.setAttribute('aria-label', w && w.n > 0 ? 'Menu. ' + (w.n === 1 ? 'One thing waits' : w.n + ' things wait') + ' on you' : 'Menu');
120
+ }
121
+ function open(on) {
122
+ on = !!on && !!H.m;
123
+ sh.hidden = !on; scrim.hidden = !on; ctx.setAttribute('aria-expanded', String(on));
124
+ document.body.classList.toggle('hm-cs-on', on);
125
+ if (on) { sh.innerHTML = sheetHtml(H.m, esc); sh.setAttribute('data-esc-layer', ''); const b = sh.querySelector('button, a'); if (b) b.focus(); }
126
+ else { sh.removeAttribute('data-esc-layer'); if (sh.contains(document.activeElement)) ctx.focus(); }
127
+ }
128
+ ctx.onclick = () => open(sh.hidden);
129
+ scrim.onclick = () => open(false);
130
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !sh.hidden) { e.stopPropagation(); open(false); ctx.focus(); } }, true);
131
+ sh.onclick = (e) => {
132
+ const b = e.target.closest('[data-cs-ini], [data-cs-file], [data-cs-all], [data-cs-sends], a'); if (!b) return;
133
+ const t = H.t, d = b.dataset;
134
+ open(false);
135
+ if (b.tagName === 'A') return; // a pull request opens on GitHub in a new tab
136
+ if (d.csIni) host.openIni(d.csIni);
137
+ else if (d.csFile) host.openFile({ path: d.csFile, name: d.csName || '' });
138
+ else if (d.csAll) host.allFiles(d.csAll);
139
+ else if ('csSends' in d) host.sendsTo(ctx, t);
140
+ };
141
+ ell.onclick = () => {
142
+ const w = host.waiting() || { n: 0 };
143
+ const rows = moreRows({ waiting: w.n, live: H.live }).map((r) => ({ ...r, go: r.key === 'wait' ? () => w.go && w.go() : () => document.dispatchEvent(new CustomEvent('cz:live-open')) }));
144
+ host.openMenu({ anchor: ell, rows });
145
+ };
146
+ return { draw, close: () => open(false) };
147
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Initiative roomier-phone-chat (feedback batch 31 item 5; boards RcB, RcBfiles, RcBmenu): the phone chat's top bar. roomier-phone-chat.test.js is pure: pm/phone-chat-head.js, pm/cozy-nav.js menuHtml extra rows and lib/routes-initiative-premium.js prsOf.",
3
+ "modules": [
4
+ "roomier-phone-chat.test.js"
5
+ ],
6
+ "seconds": {
7
+ "roomier-phone-chat.test.js": 1
8
+ }
9
+ }