create-pmos 0.404.0 → 0.406.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.404.0",
3
+ "version": "0.406.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": {
@@ -32,6 +32,30 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.406.0",
37
+ "at": "2026-10-24T10:26:17.544Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 1036,
42
+ "t": "Tap the title to rename a program, an initiative or a task",
43
+ "s": "Tap the title to rename a program, an initiative or a task"
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "v": "0.405.0",
49
+ "at": "2026-10-24T09:32:24.061Z",
50
+ "f": 2,
51
+ "prs": [
52
+ {
53
+ "n": 1035,
54
+ "t": "Home session list, program chat, and new initiative sessions",
55
+ "s": "Home session list, program chat, and new initiative sessions"
56
+ }
57
+ ]
58
+ },
35
59
  {
36
60
  "v": "0.404.0",
37
61
  "at": "2026-10-24T05:07:12.902Z",
@@ -262,30 +286,6 @@
262
286
  "s": "Popup leads after each refresh, and a derived document's PRD section"
263
287
  }
264
288
  ]
265
- },
266
- {
267
- "v": "0.386.0",
268
- "at": "2026-10-21T14:59:05.016Z",
269
- "f": 2,
270
- "prs": [
271
- {
272
- "n": 997,
273
- "t": "Board measure popup reads its numbers and the trunk fetch time",
274
- "s": "Board measure popup reads its numbers and the trunk fetch time"
275
- }
276
- ]
277
- },
278
- {
279
- "v": "0.385.0",
280
- "at": "2026-10-21T14:04:22.922Z",
281
- "f": 2,
282
- "prs": [
283
- {
284
- "n": 996,
285
- "t": "A task's Jira ticket from the stored reads, with Read it now",
286
- "s": "A task's Jira ticket from the stored reads, with Read it now"
287
- }
288
- ]
289
289
  }
290
290
  ]
291
291
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@d588f370
1
+ kernel-source: pmos@6eaac31d
2
2
  assembled: 2026-10-24
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-10-24T05:07:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-24T10:26:14Z"}
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-10-24T05:07:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-24T10:26:14Z"}
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-10-24T05:07:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-24T10:26:14Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,28 @@
1
1
  [
2
+ {
3
+ "v": "0.406.0",
4
+ "at": "2026-10-24T10:26:17.544Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 1036,
9
+ "t": "Tap the title to rename a program, an initiative or a task",
10
+ "s": "Tap the title to rename a program, an initiative or a task"
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "v": "0.405.0",
16
+ "at": "2026-10-24T09:32:24.061Z",
17
+ "f": 2,
18
+ "prs": [
19
+ {
20
+ "n": 1035,
21
+ "t": "Home session list, program chat, and new initiative sessions",
22
+ "s": "Home session list, program chat, and new initiative sessions"
23
+ }
24
+ ]
25
+ },
2
26
  {
3
27
  "v": "0.404.0",
4
28
  "at": "2026-10-24T05:07:12.902Z",
@@ -21,7 +21,7 @@ Home is the page at `/premium.html`. It follows the Agreed design and the "Uncov
21
21
  - Every group stays open or closed after you reload the page.
22
22
  - On a desktop, the chat has a header line with the open item's name and where it sits (its initiative, product or program).
23
23
  - The microphone in the chat box turns what you say into text. Nothing is sent until you press send.
24
- - A link can open Home at one item: `?item=pt:<program>:<key>` selects a program task, and `?ask=program:<id>` opens the chat about that program.
24
+ - A link can open Home at one item: `?item=pt:<program>:<key>` selects a program task, and `?ask=program:<id>` opens the chat about that program. **Discuss in chat** on a program in the Board opens the same program chat. **New session** on an initiative starts a new chat about that initiative.
25
25
 
26
26
  ## An initiative
27
27
 
@@ -32,6 +32,17 @@ Open an initiative with `?ini=<id>`. Its card at the top of the list shows the s
32
32
  - **Tasks** in the Viewer can be grouped by stage, by groups that you name, by owner or by status. Drag a task to another group.
33
33
  - **Core documents** in the list shows only the documents that need a look. **All documents** opens every document in the Viewer.
34
34
 
35
+ ## Rename a program, an initiative or a task
36
+
37
+ Press the name in the Viewer's header. The name becomes a field.
38
+
39
+ - Type the new name. Press Enter or the check to save it. Press Esc to stop without a change. An empty name is not saved.
40
+ - The new name shows at once in the list, the chat header, the Viewer, the Board and the Timeline. The message **Renamed** has **Undo**.
41
+ - Only the name changes. The id, the record file, the links and the history stay the same.
42
+ - An initiative with a Jira epic shows **Rename the Jira epic too**. It is off by default. When you select it, Home opens the initiative's chat with the request typed. Send it to let your agent rename the epic in Jira. PMOS does not change Jira itself.
43
+ - A program has no Jira box. Its goal stays as it is.
44
+ - A Jira ticket keeps its Jira name. Rename it in Jira.
45
+
35
46
  Some features are still not designed. Home keeps each one usable as a plain card in the Viewer with the label **Waiting for design**. The label means that the card works, but its look is not final.
36
47
 
37
48
  ## New for you, Search, Sources and Settings
@@ -62,7 +73,7 @@ There is no My work page. The list on Home is your list:
62
73
  - **Tasks.** An initiative shows its 3 most urgent tasks: yours first, then due today, late, and due this week. **Show N more tasks** shows the rest.
63
74
  - **Your items.** A PM item opens alone, as its own card. There is no Focus chip. Items that nobody touched are in the Weekly review.
64
75
  - **Add a task.** Press **New**, then **A task**, then choose the initiative, or **Not in an initiative**. Home has no add box that is always open.
65
- - **Sessions.** A session row names its agent. The coloured dot beside it is its state: blue waits on you, amber may be blocked, green is running. A session PMOS started itself (a skill or a background job) shows on Home only while it works or asks you something. Once it finishes its prompt, it leaves the list.
76
+ - **Sessions.** A session row names its agent. The coloured dot beside it is its state: blue waits on you, amber may be blocked, green is running. A session PMOS started itself (a skill or a background job) shows on Home only while it works or asks you something. Once it finishes its prompt, it leaves the list. On an initiative's page, a session that waits on you shows once, under **Needs you**, not again under **Sessions**. **Finished sessions** does not list an old run of a chat that is open again.
66
77
  - **One chat box.** Every conversation has the same box: **+** (attach a file, notes, the terminal, and **Link to an initiative** for a loose chat), **/** for commands, **@** inside an initiative, the To or In chip, the mic, and Send. A chat opens at its newest message.
67
78
  - **Documents not written yet.** A document that does not exist yet shows **Draft it**, in its stage or ahead of it. The agent writes a draft. Nothing is issued until you read it.
68
79
  - **Meeting notes.** A decision, to-do or question that the notes caught is not a fact until you confirm it in the meeting's Replay. Home, End of the day and the evening recap do not count unconfirmed points.
@@ -28,6 +28,7 @@ Programs do not change how Insights, the weekly update or sprints count initiati
28
28
  Press a program's name on the Board to open its panel. Home links to it with `?program=<id>`.
29
29
 
30
30
  - The top shows the program's name, its owner and its span (for example "Sep 2026 to Jun 2028").
31
+ - Press the program's name to rename it (see Home, "Rename a program, an initiative or a task"). The panel saves the whole charter again with the same id, so the rename never makes a new program.
31
32
  - The goal row shows the KRs of its initiatives for one half year, each with its name and a dot (met, on course or behind). Use the half-year picker to see another half. Earlier halves fold into one chip.
32
33
  - The milestone track shows the next 3 milestones. The done cluster and the **N more** cluster open the **Milestones** tab, which lists Done, Next and Later.
33
34
  - The rows that wait on you open in Home.
@@ -60,7 +60,9 @@ function rowFor(model, key, context) {
60
60
  return { title: key === 'work:this-page' ? 'The My work page' : 'The Briefing page', subject: clip(model.header && model.header.text, 240), say: clip(say, 600), facts: rows.slice(0, 12).map((r) => clip(r.kind || r.list || 'item', 40) + ': ' + clip(r.title, 240)), files: [] };
61
61
  }
62
62
  if (/^(work|board|init|doc|ins):/.test(key)) { // a My work item, a Board initiative, an Insights measure, an initiative page or one of its documents: the item's own record is the context
63
- const w = (model.rows || []).find((r) => r.key === key); if (!w) return null;
63
+ // a second session on an initiative (Home's New session: init:<id>:<n>) reads the initiative's own row
64
+ const base = /^init:[^:]+:/.test(key) ? key.replace(/^(init:[^:]+):.*$/, '$1') : key;
65
+ const w = (model.rows || []).find((r) => r.key === key) || (base !== key ? (model.rows || []).find((r) => r.key === base) : null); if (!w) return null;
64
66
  const d = w.dialog || {};
65
67
  return { title: clip(w.title, 160), subject: clip(w.sub, 240), say: clip(d.say, 600), facts: (d.facts || []).slice(0, 12).map(([a, b]) => clip(a, 40) + ': ' + clip(b, 240)), files: (d.files || []).filter((f) => SAFE_PATH.test(f) && !f.includes('..')).slice(0, 4) };
66
68
  }
@@ -95,6 +97,15 @@ function popRow(c) {
95
97
  return { title: str(c.title, 160), subject: str(c.subject, 240), say: str(c.say, 600), facts, files };
96
98
  }
97
99
 
100
+ /** The opening's row of an initiative's chat when the page model holds no row for it (bug 2026-10-24: Home's New session on an
101
+ * initiative other than the one the initiative model last read). The chat is the PM's own Claude Code session, so it starts with
102
+ * the initiative's id and what the page sent instead of refusing. A row of another kind that is not on the page is still refused. */
103
+ function contextRow(key, context) {
104
+ const say = typeof context === 'string' ? clip(context, 600) : '';
105
+ const id = String(key).replace(/^[a-z]+:/, '').replace(/:\d+$/, '');
106
+ return { title: clip(id, 160), subject: '', say, facts: [], files: [] };
107
+ }
108
+
98
109
  function promptFor(row, turns, question) {
99
110
  const prior = turns.filter((t) => t.state === 'answered').slice(-PROMPT_TURNS);
100
111
  return [
@@ -189,7 +200,7 @@ function chat({ runtimeDir, key, text, model, context, sessions, wsId, now = new
189
200
  // slice 4 (PRD L2): an ended chat resumes its own Claude Code conversation when the file for it is still there
190
201
  const prev = alive ? null : chatRecordOf(runtimeDir, key);
191
202
  const resume = !!(prev && prev.claude && typeof sessions.hasConversation === 'function' && sessions.hasConversation(prev.claude));
192
- const row = alive ? null : rowFor(model, key, context);
203
+ const row = alive ? null : rowFor(model, key, context) || (/^init:/.test(key) ? contextRow(key, context) : null);
193
204
  if (!alive && !row && !resume) return fail(404, /^pop:/.test(key) ? 'the popup did not say what it shows' : model ? 'that row is not on the page' : 'the page has not read the repository yet');
194
205
  // slice 2 (PRD G2): `/goal <text>` becomes the PMOS grilling prompt, on record before it reaches the session
195
206
  let msg = q, goal = null;
@@ -36,7 +36,7 @@
36
36
  * new initiatives may pick, the template they start with)
37
37
  * ini-workflow { id, template, stages: [{ name, cat, hint }], moved: { from, to } | null } one initiative's own workflow
38
38
  * task { task, type: Task|Epic, initiative, title, epic, owner, state, start, due } a PMOS task (or PMOS epic) on the board
39
- * task-update { task, state?, start?, due?, why } a status move or a reschedule
39
+ * task-update { task, state?, start?, due?, title?, why } a status move, a reschedule or a rename
40
40
  * Nothing is deleted. A line that is not an object with a known kind is skipped.
41
41
  *
42
42
  * STAGE OF AN INITIATIVE on a team board: the last move recorded for it on that board (a workflow edit's `moved` and an
@@ -253,6 +253,7 @@ function fold(events) {
253
253
  if (typeof e.initiative === 'string' && e.initiative) t.initiative = e.initiative; // a merge moves the task (and its undo moves it back)
254
254
  if (typeof e.start === 'string') t.start = e.start;
255
255
  if (typeof e.due === 'string') t.due = e.due;
256
+ if (typeof e.title === 'string' && e.title.trim()) t.title = e.title.trim(); // a rename (canvas RnATask)
256
257
  t.history.push({ at: e.at || null, by: e.by || null, state: e.state || null, start: e.start || null, due: e.due || null, why: e.why || '' });
257
258
  } else if (e.kind === 'ini-epics' && typeof e.id === 'string' && Array.isArray(e.epics)) {
258
259
  epics.set(e.id, e.epics.filter((k) => typeof k === 'string' && JIRA_KEY_RE.test(k)).map((k) => k.toUpperCase()));
@@ -30,6 +30,12 @@
30
30
  * The file is opened O_CREAT|O_EXCL|O_NOFOLLOW inside the resolved initiatives folder, so an existing file or a
31
31
  * symlink is never written through. When the placement line cannot be written, the new record is removed again and
32
32
  * the refusal is returned: a record never lands without its place in Later.
33
+ *
34
+ * renameInitiative(root, id, title, { actor }) → { ok: true, id, path, from, title } | { ok: false, status, error, field }
35
+ *
36
+ * RENAME (testing feedback 2026-10-24, canvas RnAIni). Only the record's `title:` line changes, and its `# <title>` heading
37
+ * when that heading is the old title. The id, the file name and every other line stay as they are, so links, the
38
+ * placements and the gates keep reading the same record. Same refusals for the title as a new record; no record → 404.
33
39
  */
34
40
  const fs = require('fs');
35
41
  const path = require('path');
@@ -138,4 +144,42 @@ function createInitiative(root, input, { actor, now } = {}) {
138
144
  return { ok: true, id, path: path.relative(realRoot, file).split(path.sep).join('/'), written: 1 + placed.written };
139
145
  }
140
146
 
141
- module.exports = { createInitiative, slugOf, ID_RE, INPUT_KEYS };
147
+ /** The quoted or plain YAML scalar of a `title:` line, read back as text. */
148
+ function unquote(v) {
149
+ const t = String(v || '').trim();
150
+ if (/^".*"$/.test(t)) return t.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
151
+ if (/^'.*'$/.test(t)) return t.slice(1, -1).replace(/''/g, "'");
152
+ return t;
153
+ }
154
+
155
+ function renameInitiative(root, id, title, { actor } = {}) {
156
+ if (!actorLib.valid(actor)) return refuse(500, 'initiative-writer: the caller must pass the actor from pm-guard.js or actor.js');
157
+ if (typeof id !== 'string' || !ID_RE.test(id) || id.includes('..') || id.length > MAX_ID) return refuse(400, 'name the initiative by its id', 'id');
158
+ if (!ONE_LINE(title, 120)) return refuse(400, 'give a name of 1 to 120 characters on one line', 'title');
159
+ const name = title.trim();
160
+ const loaded = consoleState.loadEngine();
161
+ if (!loaded.ok) return refuse(500, loaded.error);
162
+ let realDir, realRoot;
163
+ try { realDir = fs.realpathSync(loaded.engine.layout(root).initiatives); realRoot = fs.realpathSync(path.resolve(root)); }
164
+ catch { return refuse(404, `no initiative ${id}`, 'id'); }
165
+ if (realDir !== realRoot && !realDir.startsWith(realRoot + path.sep)) return refuse(500, 'the initiatives folder resolves outside the repository — nothing was saved');
166
+ const file = path.join(realDir, `${id}.md`);
167
+ let st;
168
+ try { st = fs.lstatSync(file); } catch { return refuse(404, `no initiative ${id}`, 'id'); }
169
+ if (!st.isFile()) return refuse(409, `the record of ${id} is not a plain file — nothing was saved`, 'id');
170
+ const text = fs.readFileSync(file, 'utf8');
171
+ const m = /^---\r?\n([\s\S]*?)\r?\n---(\r?\n|$)/.exec(text);
172
+ if (!m) return refuse(409, `the record of ${id} has no front matter — nothing was saved`, 'id');
173
+ const lines = m[1].split(/\r?\n/);
174
+ const at = lines.findIndex((l) => /^title:/.test(l));
175
+ const from = at >= 0 ? unquote(lines[at].slice(6)) : '';
176
+ const line = `title: ${q(name)}`;
177
+ if (at >= 0) lines[at] = line; else lines.splice(Math.min(1, lines.length), 0, line);
178
+ let rest = text.slice(m[0].length);
179
+ if (from) rest = rest.replace(new RegExp('^(\\s*)# ' + from.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '[ \\t]*$', 'm'), (_, sp) => sp + '# ' + name);
180
+ const out = '---\n' + lines.join('\n') + '\n---' + m[2] + rest;
181
+ try { fs.writeFileSync(file, out, { flag: 'w' }); } catch { return refuse(500, 'the record could not be written — nothing was saved'); }
182
+ return { ok: true, id, path: path.relative(realRoot, file).split(path.sep).join('/'), from, title: name };
183
+ }
184
+
185
+ module.exports = { createInitiative, renameInitiative, slugOf, ID_RE, INPUT_KEYS };
@@ -27,6 +27,7 @@
27
27
  * POST /api/boards/tasks/add { ws, board, initiative, title, type?, epic?, start?, due?, owner? } → { ok, item }
28
28
  * POST /api/boards/tasks/state { ws, board, task, state } → { ok, item }
29
29
  * POST /api/boards/tasks/reschedule { ws, board, task, days } → { ok, item }
30
+ * POST /api/boards/tasks/rename { ws, board, task, title } → { ok, from, item } only the title changes
30
31
  * POST /api/boards/archive { ws, board, id, archived, reason? } → { ok, row } archive (hidden everywhere, kept whole) or restore;
31
32
  * restoring a merged initiative moves its epics and tasks back
32
33
  * POST /api/boards/merge { ws, board, id, into, epics?, tasks? } → { ok, row, into } moves the picked Jira epic links and PMOS
@@ -825,6 +826,18 @@ const WRITES = {
825
826
  const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
826
827
  ctx.json(res, { ok: true, item: B.rollupItems([B.taskItem(t2)])[0] });
827
828
  },
829
+ '/api/boards/tasks/rename': (ctx, res, body, g) => {
830
+ // tap the title to rename it (canvas RnATask): only the title changes; Undo is the same press with the old name
831
+ const p = postFrame(ctx, res, body);
832
+ if (!p) return;
833
+ const t = B.taskOf(p.fr.folded, body.task);
834
+ if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
835
+ if (!ONE_LINE(body.title, 200)) return fail(ctx, res, 400, 'title is one line of 1 to 200 characters');
836
+ if (!p.file) return fail(ctx, res, 409, NO_STATE);
837
+ append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, title: body.title.trim(), why: 'renamed' });
838
+ const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
839
+ ctx.json(res, { ok: true, from: t.title, item: B.rollupItems([B.taskItem(t2)])[0] });
840
+ },
828
841
  '/api/boards/tasks/reschedule': (ctx, res, body, g) => {
829
842
  const p = postFrame(ctx, res, body);
830
843
  if (!p) return;
@@ -7,6 +7,7 @@
7
7
  * GET /api/initiatives/<id>/export?ws= → { ok, id, markdown } (lib/breakdown-export.js; nothing is written)
8
8
  * POST /api/initiatives { ws, title, lane, anchor, intent?, id?, from?, specimen_test?, surface_check? }
9
9
  * → { ok, id, path, written, sig } New initiative (requirePagePress)
10
+ * POST /api/initiatives/rename { ws, id, title } → { ok, id, from, title, path, sig } rename: the record's title only (requirePagePress)
10
11
  * POST /api/initiatives/rescan { ws } → { ok, started, running } read the repository again now (requirePagePress);
11
12
  * nothing is written: the cached rows go stale and one derivation starts
12
13
  * POST /api/initiatives/duplicates { ws } → { ok, profile, archive, groups } documents that share an initiative and a
@@ -650,6 +651,17 @@ async function handle(req, res, url, ctx) {
650
651
  ctx.json(res, { ws: w.id, ...r });
651
652
  return true;
652
653
  }
654
+ if (p === '/api/initiatives/rename') {
655
+ // tap the title to rename it (canvas RnAIni): only the record's title changes; the id, the file and the links stay
656
+ const g = guard.requirePagePress(req, body);
657
+ if (!g.ok) return answer(ctx, res, g), true;
658
+ const r = writer.renameInitiative(w.root, body.id, body.title, { actor: g.actor });
659
+ if (!r.ok) { ctx.json(res, { ok: false, status: r.status, error: r.error, field: r.field }, r.status); return true; }
660
+ rowsLib.invalidate(w.root);
661
+ if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id);
662
+ ctx.json(res, { ok: true, id: r.id, from: r.from, title: r.title, path: r.path, sig: sigOf(w.root) });
663
+ return true;
664
+ }
653
665
  if (p === '/api/initiatives') {
654
666
  const g = guard.requirePagePress(req, body);
655
667
  if (!g.ok) return answer(ctx, res, g), true;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.404.0",
3
+ "version": "0.406.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.404.0",
9
+ "version": "0.406.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.404.0",
3
+ "version": "0.406.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",
@@ -78,6 +78,14 @@ const json = (r, body, status = 200) => r.fulfill({ status, contentType: 'applic
78
78
  ok('D1 a kind Home has no key for is a chat key: about=chat:<id>', u.searchParams.get('about') === 'chat:ana', u.search);
79
79
  await sleep(2500); s = await state();
80
80
  ok('D4 a kind Home has no view for is the chat alone, named by its label', s.top === 'Ana Lim' && !s.vw, JSON.stringify(s));
81
+ // bug 2026-10-24: the Board's program panel Discuss named board:program:<id>, which Home sent as a Board row it does not have
82
+ // ("that row is not on the page"); it lands on the program's own conversation, the one its tasks open
83
+ await ctx.route(/\/api\/programs(\?.*)?$/, (r) => json(r, { ok: true, programs: [{ id: 'project-ascent', title: 'Project Ascent', members: [], tasks: [], milestones: [] }] }));
84
+ u = await discussFrom({ kind: 'Program', id: 'program:project-ascent', title: 'Project Ascent' });
85
+ ok('D6 a program\'s Discuss names it: about=board:program:<id>', u.searchParams.get('about') === 'board:program:project-ascent', u.search);
86
+ s = await until(async () => { const v = await page.evaluate(() => { const c = document.querySelector('[data-hm-scope]'); return { top: document.querySelector('#hmTopTitle').textContent, scope: c ? c.textContent.trim() : '' }; }); return /Project Ascent/.test(v.scope) ? v : null; }, 15000)
87
+ || await page.evaluate(() => ({ top: document.querySelector('#hmTopTitle').textContent, scope: ((document.querySelector('[data-hm-scope]') || {}).textContent || '').trim() }));
88
+ ok('D6 a program lands on its own conversation: the chat goes in the program, not All work', s.top === 'Project Ascent' && s.scope === 'In: Project Ascent', JSON.stringify(s));
81
89
  ok('D5 no page error', errors.length === 0, errors.join(' | '));
82
90
  finish();
83
91
  })();
@@ -161,12 +161,12 @@ function wire(body, key) {
161
161
  };
162
162
  }
163
163
  /** The shell's id of an initiative: its record id, so Discuss in chat names it (?about=init:<id>&vid=<id>) and Home reopens it beside the chat. */
164
- const vidOf = (r) => (r.id ? String(r.id) : 'bd:' + r.key);
164
+ export const vidOf = (r) => (r.id ? String(r.id) : 'bd:' + r.key);
165
165
  export function openIni(r, from) {
166
166
  if (!O || !r || !r.track) return;
167
167
  // a row with no record id has no chat of its own: its question goes to the board's chat
168
168
  VW.open({ kind: 'Initiative', title: r.title, icon: 'flag', id: vidOf(r), url: r.id ? O.pageHref(r) : '', full: true,
169
- discuss: r.id ? true : () => location.assign(O.askHref(r, '')), more: iniMore(r),
169
+ discuss: r.id ? true : () => location.assign(O.askHref(r, '')), more: iniMore(r), rename: O.rename ? O.rename(r) : null,
170
170
  render: (body) => { const x = O.rowOf(r.key) || r; cur = { key: x.key, tk: null }; O.onShow(x.key, from); body.innerHTML = iniBody(x); wire(body, x.key); },
171
171
  onClose: () => { if (cur && cur.key === r.key && !cur.tk) { cur = null; O.onHide(); } } });
172
172
  }
@@ -27,6 +27,7 @@ import { STEPS } from './premium-initiative-head.js';
27
27
  import * as VW from './cozy-viewer.js';
28
28
  import * as Pop from './bd-pop.js';
29
29
  import { copyText } from './cozy-xv.js';
30
+ import { programRename } from './rename-press.js';
30
31
 
31
32
  const SV = (d, w) => `<svg viewBox="0 0 24 24" width="${w || 18}" height="${w || 18}" aria-hidden="true"><path d="${d}"/></svg>`;
32
33
  const I = {
@@ -344,12 +345,20 @@ function textOf(p) {
344
345
  for (const i of st.inis) lines.push('- ' + i.title + ' · ' + ((i.row.track && i.row.track.label) || i.stage || ''));
345
346
  return lines.join('\n');
346
347
  }
348
+ const titleOf = (p) => p.title + (p.goal ? ' · ' + p.goal : '');
347
349
  function openPanel(id, from) {
348
350
  if (!O || !O.M() || !progOf(id)) return false;
349
351
  const p = progOf(id);
350
352
  adding = false; period = null; O._perOpen = false;
351
- VW.open({ kind: 'Program', title: p.title + (p.goal ? ' · ' + p.goal : ''), icon: I.prog, id: 'program:' + id,
352
- discuss: true, more: moreOf(p),
353
+ // tap the title to rename (canvas RnAProg): the field holds the name only; the goal stays as it is
354
+ const rename = programRename({ pmPost, program: p, onSaved: async (o) => {
355
+ await O.reload(); VW.retitle('program:' + id, titleOf(progOf(id) || { ...p, title: o.title }));
356
+ O.say('Renamed', async () => { const u = await o.undo(); if (!u.ok) { O.say(u.error); return; } await O.reload(); VW.retitle('program:' + id, titleOf(progOf(id) || p)); });
357
+ } });
358
+ rename.save = ((save) => async (title, x) => { const r = await save(title, x); if (!r.ok) return r; p.title = r.title; rename.value = r.title; return { ...r, title: titleOf(p) }; })(rename.save);
359
+ rename.value = p.title;
360
+ VW.open({ kind: 'Program', title: titleOf(p), icon: I.prog, id: 'program:' + id,
361
+ discuss: true, more: moreOf(p), rename,
353
362
  render: (body) => {
354
363
  cur = { id, from: from && !(VW.body() && VW.body().contains(from)) ? from : (cur && cur.id === id && cur.from) || null };
355
364
  body.classList.add('pp-vw');
@@ -20,6 +20,11 @@
20
20
  * url the item's own address: "Open in a new tab" goes under ⋯ (full: true names it "Open in full")
21
21
  * more [{ label, on(moreButton), note?, danger?, icon?, disabled? } | { sep: true }], or a function that returns it: the ⋯ menu; on() gets the ⋯ button as an anchor, in the xvMore order (change it, look back, stop or remove last)
22
22
  * discuss true, { href }, or fn(): the quiet "Discuss in chat" icon before ⋯. Never drawn on Home, where the chat is already beside it.
23
+ * rename { save(title, { jira }) → Promise<{ ok, title?, error? }>, max?, value?, jira?: { label, key } }: the title is the rename press
24
+ * (value: the name the field starts from when the title shows more, as a program's "title · goal")
25
+ * (canvas RnATask, RnAIni, RnAProg, RnAPhone). A tap turns it into one field with a check: Enter or the check saves, Esc
26
+ * cancels, an empty or unchanged name saves nothing. jira draws "Rename the Jira … too" under the field, off by default.
27
+ * The caller writes the record and says "Renamed" with Undo; the header shows the saved name at once.
23
28
  * true goes to Home with ?about=<kind>:<id>&label=<title>; { href } goes there; fn() runs instead.
24
29
  * back true: keep the item shown now, so ← comes back to it. Without back, opening an item forgets what was behind it.
25
30
  * render called with the body element to draw into; html is the same as a string. Neither: the body is left empty for the caller.
@@ -84,6 +89,14 @@ const V = { el: null, cur: null, back: null, subs: [], stack: [], wide: false, r
84
89
  /** "PRD" over "PRD", or "File · plans/x.md" over "x.md": the kind is left out when it only repeats the title */
85
90
  const sameAs = (kind, title) => { const k = String(kind || '').trim().toLowerCase().replace(/^file · /, ''), t = String(title || '').trim().toLowerCase(); return !!t && (k === t || k.split('/').pop() === t || k.split('/').pop().replace(/\.[a-z]+$/, '') === t); };
86
91
  const ib = (act, label, d, extra = '') => `<button type="button" class="cz-vw-ib" data-cz-vw="${act}" aria-label="${esc(label)}" title="${esc(label)}"${extra}>${svg(d, 18, act === 'more' ? 3 : 1.8)}</button>`;
92
+ /** The rename field in the title's place (RnATask): the name, a blue check; the Jira box under it when the item has a Jira twin. */
93
+ function renHtml(o) {
94
+ const r = o.rename || {}, max = r.max || 120;
95
+ const j = r.jira && r.jira.label ? `<label class="cz-vw-jt"><input type="checkbox" data-cz-vw-jira${o.renJira ? ' checked' : ''}>${esc(r.jira.label)}${r.jira.key ? `<span class="k">${esc(r.jira.key)}</span>` : ''}</label>` : '';
96
+ const err = o.renError ? `<p class="cz-vw-rnerr" role="alert">${esc(o.renError)}</p>` : '';
97
+ return `<form class="cz-vw-ren" data-cz-vw-ren data-esc-layer><input id="czVwTitle" type="text" value="${esc(o.renValue != null ? o.renValue : o.title || '')}" maxlength="${max}" aria-label="Name" autocomplete="off"${o.renBusy ? ' disabled' : ''}>`
98
+ + `<button type="submit" class="cz-vw-sv" aria-label="Save the name" title="Save (Enter). Esc cancels."${o.renBusy ? ' disabled' : ''}>${svg('M5 12.5l4.5 4.5L19 7.5', 16, 2.2)}</button></form>` + j + err;
99
+ }
87
100
  /** The header's markup for one item; pure, so a unit test can read it. o.canBack: ← is drawn; o.isWide: ⤢ reads "Back to the side". */
88
101
  export function headHtml(it) {
89
102
  const o = it || {};
@@ -93,7 +106,7 @@ export function headHtml(it) {
93
106
  const more = typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
94
107
  return (o.canBack || phone ? ib('back', o.canBack ? 'Back' : 'Close the viewer', P.back) : '')
95
108
  + `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`
96
- + `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title" id="czVwTitle">${esc(o.title || '')}</h3></div>`
109
+ + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : esc(o.title || '')}</h3></div>`)
97
110
  + disc + more
98
111
  + (phone ? '' : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
99
112
  + (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
@@ -310,6 +323,7 @@ function mount() {
310
323
  el.prepend(grip(el));
311
324
  el.addEventListener('click', (e) => { // the header's presses, and the folds of czSections in the body
312
325
  const f = e.target.closest('[data-czs-fold]'); if (f && el.contains(f)) { toggleFold(f); return; }
326
+ if (e.target.closest('[data-cz-vw-rn]')) { startRename(); return; } // the title is the rename press (RnATask)
313
327
  const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled || !el.querySelector('.cz-vw-hd').contains(b)) return;
314
328
  const a = b.dataset.czVw;
315
329
  if (a === 'close') close();
@@ -318,6 +332,10 @@ function mount() {
318
332
  else if (a === 'wide') wide();
319
333
  else if (a === 'discuss') discuss();
320
334
  });
335
+ el.addEventListener('submit', (e) => { if (e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); saveRename(); } });
336
+ el.addEventListener('keydown', (e) => { if (e.key === 'Escape' && e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); e.stopPropagation(); endRename(); } });
337
+ el.addEventListener('input', (e) => { if (e.target.id === 'czVwTitle' && V.cur && V.cur.renaming) V.cur.renValue = e.target.value; });
338
+ el.addEventListener('change', (e) => { if (e.target.matches('[data-cz-vw-jira]') && V.cur) V.cur.renJira = e.target.checked; });
321
339
  place(el);
322
340
  V.el = el;
323
341
  if (typeof ResizeObserver !== 'undefined') new ResizeObserver(() => {
@@ -345,8 +363,39 @@ function leave() {
345
363
  function redraw() {
346
364
  if (!V.el || !V.cur) return;
347
365
  V.ph = isPhone();
348
- V.el.querySelector('.cz-vw-hd').innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, isWide: V.wide || V.rail, phone: V.ph, home: onHome() });
366
+ const hd = V.el.querySelector('.cz-vw-hd');
367
+ hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, isWide: V.wide || V.rail, phone: V.ph, home: onHome() });
368
+ hd.classList.toggle('cz-vw-renon', !!V.cur.renaming);
369
+ }
370
+
371
+ /* ── rename: the title is the press (RnATask) ── */
372
+ function startRename() {
373
+ if (!V.cur || !V.cur.rename || V.cur.renaming) return;
374
+ Object.assign(V.cur, { renaming: true, renValue: V.cur.rename.value != null ? V.cur.rename.value : V.cur.title, renJira: false, renError: '', renBusy: false });
375
+ redraw();
376
+ const i = V.el.querySelector('#czVwTitle'); if (i) { i.focus(); i.select(); }
377
+ }
378
+ function endRename(focusTitle = true) {
379
+ if (!V.cur) return;
380
+ Object.assign(V.cur, { renaming: false, renValue: null, renError: '', renBusy: false });
381
+ redraw();
382
+ if (focusTitle) { const b = V.el.querySelector('[data-cz-vw-rn]'); if (b) b.focus(); }
383
+ }
384
+ async function saveRename() {
385
+ const cur = V.cur; if (!cur || !cur.renaming || cur.renBusy) return;
386
+ const i = V.el.querySelector('#czVwTitle'); const v = String((i && i.value) || '').replace(/\s+/g, ' ').trim();
387
+ if (!v) { if (i) i.focus(); return; } // an empty name is not saved: the field stays
388
+ if (v === (cur.rename.value != null ? cur.rename.value : cur.title)) { endRename(); return; }
389
+ Object.assign(cur, { renValue: v, renBusy: true, renError: '' }); redraw();
390
+ let r = null;
391
+ try { r = await cur.rename.save(v, { jira: !!cur.renJira }); } catch { r = null; }
392
+ if (V.cur !== cur) return; // another item opened while it saved
393
+ if (!r || r.ok !== true) { Object.assign(cur, { renBusy: false, renError: (r && r.error) || 'The name was not saved.' }); redraw(); const j = V.el.querySelector('#czVwTitle'); if (j) j.focus(); return; }
394
+ cur.title = r.title || v; if (cur.rename.value != null && r.title == null) cur.rename.value = v; if (cur.args) cur.args = { ...cur.args, title: cur.title };
395
+ endRename(); emit();
349
396
  }
397
+ /** The caller's own rename landed elsewhere (Undo, or a reload): the header shows the name. */
398
+ export function retitle(id, title) { if (V.cur && V.cur.id === String(id) && title) { V.cur.title = title; if (V.cur.args) V.cur.args = { ...V.cur.args, title }; if (!V.cur.renaming) redraw(); emit(); } }
350
399
 
351
400
  /** Show one item in the Viewer, in place of the one shown. Returns the body element the content is in. */
352
401
  export function open(it) {
@@ -356,7 +405,7 @@ export function open(it) {
356
405
  if (o.back && V.cur && V.cur.args) V.stack.push(V.cur.args); else if (!o._back) V.stack = [];
357
406
  const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
358
407
  leave();
359
- V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, args: o };
408
+ V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
360
409
  el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
361
410
  redraw();
362
411
  const m = el.querySelector('.cz-vw-menu'); if (m) m.remove();
@@ -408,4 +457,4 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
408
457
  e.preventDefault(); e.stopImmediatePropagation(); close();
409
458
  }, true);
410
459
  }
411
- if (typeof window !== 'undefined') window.czViewer = { open, close, back, isOpen, current, body, onChange, placeholder, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
460
+ if (typeof window !== 'undefined') window.czViewer = { open, close, back, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
@@ -13,6 +13,20 @@
13
13
  .cz-vw-kind { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* say it once: the kind is for a screen reader */
14
14
  .cz-vw-title { font-size: 16px; font-weight: 800; }
15
15
  .cz-vw-ib { border-radius: 999px; }
16
+
17
+ /* rename (canvas RnATask, RnAIni, RnAProg, RnAPhone): the title is the press; a tap makes it one field with a blue check */
18
+ .cz-vw-rn { font: inherit; color: inherit; background: transparent; border: 0; margin: 0 0 0 -6px; padding: 2px 6px; border-radius: 10px; cursor: text; text-align: left; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
19
+ .cz-vw-rn:hover { background: var(--cz-well); }
20
+ .cz-vw-rn:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
21
+ .cz-vw-hd.cz-vw-renon { flex-wrap: wrap; }
22
+ .cz-vw-ren { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; height: 40px; margin-right: 6px; border-radius: 12px; background: var(--cz-card); box-shadow: 0 0 0 1.5px var(--cz-blue), 0 0 0 5px color-mix(in srgb, var(--cz-blue) 14%, transparent); padding: 0 4px 0 10px; }
23
+ .cz-vw-ren input { flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 800; color: var(--cz-ink); border: 0; background: transparent; outline: 0; padding: 0; }
24
+ .cz-vw-sv { width: 32px; height: 32px; border-radius: 999px; border: 0; background: var(--cz-solid); color: var(--cz-onsolid); display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
25
+ .cz-vw-sv:disabled { opacity: .6; cursor: default; }
26
+ .cz-vw-jt { flex-basis: 100%; display: flex; align-items: center; gap: 10px; margin: 8px 16px 0 46px; font-size: 13px; color: var(--cz-ink2); font-weight: 600; cursor: pointer; }
27
+ .cz-vw-jt input { width: 18px; height: 18px; margin: 0; accent-color: var(--cz-solid); flex: none; }
28
+ .cz-vw-jt .k { color: var(--cz-ink3); font-weight: 700; }
29
+ .cz-vw-rnerr { flex-basis: 100%; margin: 6px 16px 0 46px; font-size: 12.5px; color: var(--cz-red); }
16
30
  .cz-vw-ib svg { width: 18px; height: 18px; }
17
31
  .cz-vw-ib[aria-pressed="true"] { background: var(--cz-bluebg); color: var(--cz-blueink); }
18
32
  .cz-vw-hd [data-cz-vw="back"] { margin-left: -6px; }
@@ -80,7 +94,7 @@ body.cz-vw-drag, body.cz-vw-drag * { cursor: col-resize !important; user-select:
80
94
  .czs-it .w span { display: block; font-size: 12.5px; color: var(--cz-ink3); }
81
95
  /* a row's leading tile (XvATask): a document glyph on the well, or the Jira J on blue */
82
96
  .ut-tki { width: 28px; height: 28px; border-radius: 9px; background: var(--cz-well); color: var(--cz-ink2); display: inline-grid; place-items: center; flex: none; }
83
- .ut-tki.j { background: var(--cz-blueink); color: var(--cz-onsolid); font-size: 11px; font-weight: 800; }
97
+ .ut-tki.j { background: var(--cz-solid); color: var(--cz-onsolid); font-size: 11px; font-weight: 800; }
84
98
  .czs-it:has(.ut-tki) { align-items: center; }
85
99
  .ut-tki.dash { background: none; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--cz-ink3) 45%, var(--cz-card)); }
86
100
  .czs-amb { width: 8px; height: 8px; border-radius: 50%; background: var(--cz-dot-risk); flex: none; align-self: center; margin-left: 8px; }
@@ -112,6 +126,10 @@ body.cz-vw-rail [data-cz-vw-list] > :not(.cz-vw-railbar), body.cz-vw-rail #hmLis
112
126
  .cz-vw-grip { display: none; }
113
127
  .cz-vw-hd { padding: 8px 4px 0 6px; }
114
128
  .cz-vw-hd [data-cz-vw="back"] { margin-left: 0; }
129
+ .cz-vw-rn { min-height: 44px; }
130
+ .cz-vw-ren { height: 44px; }
131
+ .cz-vw-ren input { font-size: 17px; }
132
+ .cz-vw-sv { width: 36px; height: 36px; }
115
133
  .cz-vw-body { padding: 4px 16px 16px; }
116
134
  .cz-vw-menu { right: 8px; }
117
135
  .cz-vw-menu button, .czs-ib { min-height: 44px; }
@@ -120,6 +138,7 @@ body.cz-vw-rail [data-cz-vw-list] > :not(.cz-vw-railbar), body.cz-vw-rail #hmLis
120
138
  }
121
139
  /* a touch screen wider than a phone (a tablet, a phone held sideways) keeps the 44 px presses too */
122
140
  @media (pointer: coarse) {
141
+ .cz-vw-rn { min-height: 44px; }
123
142
  .cz-vw-menu button, .czs-ib { min-height: 44px; }
124
143
  .czs-pri, .czs-sec2 { height: 44px; min-height: 44px; }
125
144
  .czs-ib { width: 44px; }
@@ -29,7 +29,8 @@ import * as YD from './home-day.js'; // Your day in the Viewer (XvAPhDay)
29
29
  import { canDictate, dictate } from './home-dictate.js';
30
30
  import { mountIni, iniList, iniOverview } from './home-ini.js'; // the initiative's stage move, Tasks and Core documents (premium-uncovered-features)
31
31
  import * as MEN from './home-mentions.js'; // @Mentions, the permanent row at the top of Home and its Viewer (Viewer kit, XvANew)
32
- import { mountRecRow } from './home-rec-row.js'; // the pinned recording row above it (XvARecHome)
32
+ import { mountRecRow } from './home-rec-row.js';
33
+ import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
33
34
 
34
35
  const $ = (s, r = document) => r.querySelector(s);
35
36
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -86,7 +87,35 @@ const S = {
86
87
  // pmos.home.pg, an initiative's rows and its "N more" in pmos.home.kids
87
88
  (() => { try { const k = JSON.parse(store.get('pmos.home.kids') || '{}') || {}; for (const [n, v] of [['on', S.kids], ['off', S.kidsOff], ['rest', S.rest], ['tasks', S.tasks]]) for (const x of k[n] || []) v.add(x); } catch { /* none kept */ } })();
88
89
  const keepKids = () => store.set('pmos.home.kids', JSON.stringify({ on: [...S.kids], off: [...S.kidsOff], rest: [...S.rest], tasks: [...S.tasks] }));
89
- const toast = (t) => { const el = $('#toast'); el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
90
+ const toast = (t) => { const el = $('#toast'); el.classList.remove('act'); el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
91
+ /** The toast with Undo (RnASaved: "Renamed · Undo"), the shape home-work.js draws: undo() runs the write's opposite once. */
92
+ function toastUndo(msg, undo) {
93
+ const el = $('#toast');
94
+ el.innerHTML = esc(msg) + ' <button class="undo" type="button">Undo</button>'; el.classList.add('on', 'act');
95
+ el.querySelector('.undo').onclick = async () => { el.classList.remove('on', 'act'); const r = await undo(); if (r && r.ok === false) toast(r.error || 'It could not be undone.'); };
96
+ clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on', 'act'), 8000);
97
+ }
98
+ /** A rename landed (or its Undo did): every place that names it reads the new name now, and the server's read follows. */
99
+ function renamedHere(kind, id, title) {
100
+ if (kind === 'task') for (const t of ((S.D.items && S.D.items.items) || [])) { if (t && t.uid === id) t.title = title; }
101
+ if (kind === 'ini') for (const r of H.boardRows(S.D)) { if (r && r.id === id) r.title = title; }
102
+ if (kind === 'ini' && S.IMid === id && S.IM) S.IM.title = title;
103
+ if (S.cur && kind === 'ini' && S.ini === id && S.cur.title !== title) { S.cur.title = title; }
104
+ drawList(); if (chat.refresh) chat.refresh();
105
+ }
106
+ const taskRenameOf = (t) => taskRename({ pmPost, ws: t.ws || boardWs(), board: t.board || boardId(), uid: t.uid, ref: null,
107
+ onSaved: (o) => {
108
+ renamedHere('task', t.uid, o.title); t.title = o.title;
109
+ toastUndo('Renamed', async () => { const u = await o.undo(); if (u.ok) { renamedHere('task', t.uid, u.title); t.title = u.title; { const c = VW.current(); if (c && String(c.id).endsWith(t.uid)) VW.retitle(c.id, u.title); } load(); } return u; });
110
+ load();
111
+ } });
112
+ const iniRenameOf = (id, prefix) => initiativeRename({ pmPost, ws: WS || undefined, id, epics: ((H.boardRows(S.D).find((r) => r.id === id) || {}).epics) || [],
113
+ onSaved: (o) => {
114
+ renamedHere('ini', id, o.title);
115
+ if (o.jira) { S.phoneChat = isPhone(); openTarget(iniTarget(id)); setTimeout(() => { const ta = $('#hmIn'); if (ta) { ta.value = o.jira; ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); } }, 0); }
116
+ toastUndo('Renamed', async () => { const u = await o.undo(); if (u.ok) { renamedHere('ini', id, u.title); VW.retitle('ov:' + id, (prefix || '') + u.title); load(); } return u; });
117
+ load();
118
+ } });
90
119
 
91
120
  /* ── reading ── */
92
121
  async function getRetry(path, tries = 20) {
@@ -641,6 +670,7 @@ function openBoardTask(t) {
641
670
  },
642
671
  openRecord: (task) => import('./premium-vw-item.js').then((V) => V.openWorkItem({ kind: 'task', ini: task.ini, key: 'task:' + task.uid, title: task.title, ws: boardWs(), board: boardId() })).catch(() => toast('The record could not open.')),
643
672
  onChange: () => load(),
673
+ rename: taskRenameOf,
644
674
  }));
645
675
  }
646
676
  function openFinished(f) {
@@ -1272,7 +1302,7 @@ function cta() {
1272
1302
  }
1273
1303
 
1274
1304
  /* ── start ── */
1275
- mountIni({ S, VW, pmGet, pmPost, toast, load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT });
1305
+ mountIni({ S, VW, pmGet, pmPost, toast, renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT });
1276
1306
  mountNav('home', document, { more: () => moreMenu, settings: () => MORE.openSettings() });
1277
1307
  PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m) }); drawList();
1278
1308
  drawList(); drawTop();
@@ -1313,6 +1343,8 @@ load().then(() => {
1313
1343
  else if (sid) { const s = S.D.sessions.find((x) => x.id === sid); if (s) { S.sel = 's:' + s.id; openTarget(sessionTarget(s)); drawList(); } else { openTarget(homeTarget()); toast('That session is not on this machine.'); } }
1314
1344
  else if (/^program:[A-Za-z0-9][A-Za-z0-9._-]{0,100}$/.test(ask)) openTarget(programTarget(ask.slice(8))); // Ask in Home from the program panel
1315
1345
  else if (about && /^init:/.test(about) && iniRowOf(P.get('vid') || about.slice(5))) { const id = iniRowOf(P.get('vid')) ? P.get('vid') : about.slice(5); goIni(id).then(() => { if (P.get('vk') && S.ini === id && !isPhone()) iniOverview(); }); }
1346
+ // the Board's program panel Discuss in chat names board:program:<id>: the program's own conversation, the one its tasks open (bug 2026-10-24)
1347
+ else if (about && /^board:program:[A-Za-z0-9][A-Za-z0-9._-]{0,100}$/.test(about)) openTarget(programTarget(about.slice(14)));
1316
1348
  else if (about) { openTarget({ ...homeTarget(), key: about, title: (P.get('label') || '').slice(0, 80) || about }); discussed(about, P.get('vid'), P.get('label')); }
1317
1349
  else if (S.ini && P.get('view') === 'metrics') goIni(S.ini).then(() => openMetrics()); // ?view=metrics: the metrics review, as its Open in a new tab names it
1318
1350
  else if (S.ini) goIni(S.ini);
@@ -58,7 +58,8 @@ const stateOf = (s) => (s.shown === 'needs' ? 'needs' : s.shown === 'blocked' ?
58
58
  export function sessionRow(s, roles) {
59
59
  const role = roleOf(s, roles);
60
60
  const st = stateOf(s);
61
- const name = s.hx && s.hx.title ? s.hx.title : s.name || 'Session';
61
+ // a chat's tmux name carries a 'chat: ' prefix (lib/briefing-premium-agent.js); the row shows its title only (testing fixes)
62
+ const name = s.hx && s.hx.title ? s.hx.title : String(s.name || '').replace(/^chat:\s*/, '') || 'Session';
62
63
  return { id: 's:' + s.id, kind: 'session', sid: s.id, key: keyOfSession(s), ini: iniOfSession(s), name, state: st, initial: role.initial, role,
63
64
  hint: role.name, icon: 'chat', created: s.created || '' }; // the state is the dot beside the row, not a word (testing fixes)
64
65
  }
@@ -236,7 +237,9 @@ function productRow(D) {
236
237
  export function iniLayout(D, id) {
237
238
  const needs = needsOf(D);
238
239
  const mine = needs.filter((r) => r.ini === id);
239
- const ses = (D.sessions || []).filter((s) => iniOfSession(s) === id).map((s) => sessionRow(s, D.desk && D.desk.roles));
240
+ // a session that waits on the PM shows once, under Needs you, never again under Sessions (say it once; the Home list does the same)
241
+ const ses = (D.sessions || []).filter((s) => iniOfSession(s) === id && s.shown !== 'needs' && s.shown !== 'blocked').map((s) => sessionRow(s, D.desk && D.desk.roles));
242
+ const liveKeys = new Set((D.sessions || []).filter((s) => iniOfSession(s) === id && live(s)).map(keyOfSession).filter(Boolean));
240
243
  const people = (((D.desk && D.desk.stakeholders) || {})[id] || []).map((p) => ({ id: 'k:' + p.name, kind: 'person', name: p.name + (p.role ? ' · ' + p.role : ''), hint: p.note || 'Stakeholder', initial: initials(p.name), state: 'quiet', person: p }));
241
244
  const meet = todayOf(D).filter((m) => meetIni(m) === id).map((m) => ({ id: 'm:' + (m.id || m.title), kind: 'meeting', name: m.title, hint: (m.state === 'now' ? 'Now' : hm(m.start)) + ' meeting' + (m.state === 'past' ? ' · done' : ''), state: m.state === 'now' ? 'working' : 'quiet', icon: 'clock', meeting: m }));
242
245
  const routines = ((D.schedules && D.schedules.schedules) || []).filter((s) => s.initiative === id || new RegExp('\\b' + id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\b').test(String(s.name || s.label || ''))).map((s) => ({ id: 'r:' + (s.id || s.name), kind: 'routine', name: cap1(String(s.name || s.task || s.skill || 'Routine').replace(/[-_]/g, ' ')), hint: s.next ? 'Next ' + DOW[new Date(s.next).getDay()] + ' ' + hm(s.next) : 'Not scheduled', state: 'quiet', icon: 'routine', schedule: s }));
@@ -248,7 +251,8 @@ export function iniLayout(D, id) {
248
251
  ['meetings', 'Meetings', meet],
249
252
  ['routines', 'Routines', routines],
250
253
  ['files', 'Files', files],
251
- ['done', 'Finished sessions', ses.filter((s) => s.state === 'exited')],
254
+ // a finished run of a conversation that is open again (the same chat key, live or waiting on the PM) is not listed a second time
255
+ ['done', 'Finished sessions', ses.filter((s) => s.state === 'exited' && !(s.key && liveKeys.has(s.key)))],
252
256
  ].map(([key, title, rows]) => ({ key, title, rows })).filter((g) => g.rows.length);
253
257
  const other = needs.filter((r) => r.ini !== id);
254
258
  const byIni = new Map(); for (const r of other) { const k = r.ini || ''; byIni.set(k, (byIni.get(k) || 0) + 1); }
@@ -420,7 +420,11 @@ export function iniOverview(view) {
420
420
  const VW = X.ctx.VW;
421
421
  const docs = X.view === 'docs';
422
422
  // render wires the body too, so ← from a drill-in (a drafted ticket) draws the view again with its presses
423
- BODY = VW.open({ id: 'ov:' + id, kind: KIND[X.view], title: KIND[X.view] + ' · ' + X.ctx.iniTitle(id), icon: ICON[X.view], more: docs ? () => docsMore(id) : moreOf(id, X.view),
423
+ // tap the title to rename the initiative (canvas RnAIni): the field holds its name; the view's word before it stays
424
+ const pre = KIND[X.view] + ' · ';
425
+ let rename = X.ctx.renameIni ? X.ctx.renameIni(id, pre) : null;
426
+ if (rename) { const save = rename.save; rename = { ...rename, value: X.ctx.iniTitle(id), save: async (t, o) => { const r = await save(t, o); if (r.ok) rename.value = r.title; return r.ok ? { ...r, title: pre + r.title } : r; } }; }
427
+ BODY = VW.open({ id: 'ov:' + id, kind: KIND[X.view], title: pre + X.ctx.iniTitle(id), icon: ICON[X.view], more: docs ? () => docsMore(id) : moreOf(id, X.view), rename,
424
428
  render: (b) => { BODY = b; draw(b); wire(b, id); } });
425
429
  if (!curM()) { X.failed = null; X.ctx.loadIni().then(() => { if (S.ini !== id) return; if (!curM()) X.failed = id; X.ctx.drawList(); redrawView(); }); } // a slow first read: read it again rather than say it failed
426
430
  return true;
@@ -567,7 +571,8 @@ async function openTask(id, M, key) {
567
571
  const row = (M.tasks.rows || []).find((x) => x.key === key); if (!row) return;
568
572
  const o = bw(M);
569
573
  if (!row.pmos && row.ref && /^Jira/.test(row.src || '')) { (await import('./premium-vw-jira.js')).openTicket({ ...o, initiative: id, ref: row.ref }); return; }
570
- (await import('./premium-vw-item.js')).openWorkItem({ kind: 'task', ini: id, key: row.key, title: row.title, ...o });
574
+ const rename = row.pmos && row.uid && X.ctx.renameTask ? X.ctx.renameTask({ uid: row.uid, title: row.title, ws: o.ws, board: o.board }) : null;
575
+ (await import('./premium-vw-item.js')).openWorkItem({ kind: 'task', ini: id, key: row.key, title: row.title, ...o, rename });
571
576
  }
572
577
 
573
578
  /* ── presses on the list column ── */
@@ -23,7 +23,8 @@ export function dueText(iso, now = Date.now()) {
23
23
  /** h: { VW, pmPost, toast, now, ws, board, iniTitle(id), docs(id) → [{ title, path }], openIni(id), openDoc(doc), askInChat(task), openRecord(task), onChange() }
24
24
  * Shell A (canvas XvATask): the summary card says when it is due, quotes the task's words, says where it sits, and holds the one primary
25
25
  * (Talk it through in chat) with Done as a quiet check beside it. "Needs" folds below: the initiative, its documents and the Jira item.
26
- * The status moves and the task's record are under ⋯ (the xvMore note: change it, then look back). */
26
+ * The status moves and the task's record are under ⋯ (the xvMore note: change it, then look back). h.rename(task), when given, is the
27
+ * Viewer's rename option for the task (rename-press.js taskRename). */
27
28
  export function openTask(task, h) {
28
29
  const st = { msg: '', busy: false };
29
30
  const t = task;
@@ -45,7 +46,9 @@ export function openTask(task, h) {
45
46
  };
46
47
  const more = () => STATES.filter((x) => x !== 'Done' && x !== t.status).map((x) => ({ label: 'Mark ' + x.toLowerCase(), on: () => setState(x) }))
47
48
  .concat(h.openRecord ? [{ sep: true }, { label: "Open the task's record", on: () => h.openRecord(t) }] : []);
48
- const body = h.VW.open({ id: 'task:' + t.uid, kind: 'Task', title: t.title, icon: 'task', more: more(), render: draw });
49
+ // tap the title to rename (canvas RnATask): a PMOS task only; a Jira ticket's name is Jira's
50
+ const rename = t.src === 'pmos' && h.rename ? h.rename(t) : null;
51
+ const body = h.VW.open({ id: 'task:' + t.uid, kind: 'Task', title: t.title, icon: 'task', more: more(), render: draw, rename });
49
52
  const setState = async (state) => {
50
53
  if (st.busy) return; st.busy = true;
51
54
  const r = await h.pmPost('/api/boards/tasks/state', { ws: h.ws, board: t.board || h.board, task: t.uid, state }).catch(() => null);
@@ -29,6 +29,7 @@ import { open as viewerOpen } from './cozy-viewer.js';
29
29
  import * as VW from './cozy-viewer.js';
30
30
  import * as PP from './bd-prog-panel.js';
31
31
  import * as BI from './bd-ini-panel.js';
32
+ import { initiativeRename } from './rename-press.js';
32
33
  import { setSay } from './cozy-xv.js';
33
34
 
34
35
  const VIEW_KEY = 'pmos.board.view', PVIEW_KEY = 'pmos.board.pview', SPAN_KEY = 'pmos.board.span', GROUP_KEY = 'pmos.board.group', GROUPING_KEY = 'pmos.board.grouping';
@@ -707,7 +708,7 @@ async function load() {
707
708
  setTimeout(load, 15000);
708
709
  return;
709
710
  }
710
- M = r.model; draw();
711
+ M = r.model; holdNames(); draw();
711
712
  focusOnce(); programOnce(); loadOthers();
712
713
  if (r.stale) setTimeout(load, 2000); // a press is still being derived: ask again
713
714
  else { loadTrail(); loadGrill(); }
@@ -725,7 +726,25 @@ Acts.init({ M: () => M, load, say, panel: actsPanel, close: closePanel, redraw:
725
726
  BI.mount({ M: () => M, statusOf, dayTitle, fmt, md, ago, segHtml, barHtml: V.barHtml, grill: (id) => GR[id], rowOf, pageHref, askHref, refreshJira: () => refreshJira(), viewDoc,
726
727
  send: (r) => import('./tk-send.js').then((S) => S.openSend({ ws: r.ws || M.board.ws || null, board: r.boardId || M.board.id, initiative: r.id, toast: say })),
727
728
  acts: (r, b) => Acts.open.row(r, b), grillOpen: (r, b) => Asks.openGrill(r.id, r.title, (r.track && r.track.label) || 'Triage', false, b), onShow: iniShown, onHide: iniHidden,
728
- programOf: (r) => programOf(PGS, r.ws || M.board.ws || '', r.id), turnProgram });
729
+ programOf: (r) => programOf(PGS, r.ws || M.board.ws || '', r.id), rename: renameIni, turnProgram });
730
+ /** Tap the title to rename (canvas RnAIni): the list, the Timeline and the panel show the new name at once; Undo is the same press.
731
+ * The Jira box opens Home's chat about it with the request typed, for the PM to send (PMOS holds no Jira credential, D53). */
732
+ // a name the PM just saved holds over a read that predates it (the board derives off the request path) until a read says it too
733
+ const RENAMED = new Map();
734
+ function renamedOn(ids, title) { for (const id of ids) RENAMED.set(id, title); if (!M) return; holdNames(); draw(); }
735
+ function holdNames() {
736
+ if (!M || !RENAMED.size) return;
737
+ const I = M.initiatives || {};
738
+ const all = [].concat(M.rows || [], (I.list && I.list.rows) || [], ...((I.stages || []).map((c) => c.rows || [])), (I.timeline && I.timeline.bars) || []);
739
+ for (const r of M.rows || []) if (RENAMED.has(r.id) && r.title === RENAMED.get(r.id)) RENAMED.delete(r.id); // the read says it: nothing to hold
740
+ for (const r of all) if (r && RENAMED.has(r.id)) r.title = RENAMED.get(r.id);
741
+ }
742
+ function renameIni(r) { return r && r.id ? initiativeRename({ pmPost, ws: r.ws || M.board.ws, id: r.id, epics: r.epics,
743
+ onSaved: (o) => {
744
+ renamedOn([r.id], o.title); load();
745
+ if (o.jira) { location.assign('/premium.html?about=' + encodeURIComponent('init:' + r.id) + '&label=' + encodeURIComponent(o.title) + '&say=' + encodeURIComponent(o.jira)); return; }
746
+ say('Renamed', async () => { const u = await o.undo(); if (!u.ok) { say(u.error); return; } renamedOn([r.id], u.title); VW.retitle(BI.vidOf(r), u.title); load(); });
747
+ } }) : null; }
729
748
  setSay(say);
730
749
  PP.mount({ M: () => M, programs: () => PGS, openIni: (id, from) => openIni((M.rows || []).find((x) => x.id === id && x.track), from), close: closePanel, reload: loadPrograms, say }); // the program panel (PgProgram)
731
750
  setTab('ini');
@@ -87,7 +87,7 @@ let czLast = null;
87
87
  export function vwReopen() { if (!czLast) return false; czVw(czLast); return true; }
88
88
  function czVw(it) {
89
89
  let el = null; czLast = it;
90
- czOpen({ id: 'vw:' + it.id, kind: it.kind || it.title || 'Item', title: it.name || it.title || 'Item', icon: CZ_ICON[it.icon] || 'doc', url: it.url || '',
90
+ czOpen({ id: 'vw:' + it.id, kind: it.kind || it.title || 'Item', title: it.name || it.title || 'Item', icon: CZ_ICON[it.icon] || 'doc', url: it.url || '', rename: it.rename || null,
91
91
  render: (body) => {
92
92
  el = document.createElement('div'); el.className = 'obody vw'; el.dataset.vw = it.id; el.setAttribute('role', 'region'); body.append(el);
93
93
  if (it.render) it.render(el); else el.innerHTML = it.html || '';
@@ -39,6 +39,7 @@ export function openWorkItem(o) {
39
39
  id: isTask ? taskId(ctx.id, o.key) : iniId(ctx.id),
40
40
  title: o.title || (isTask ? 'Task' : 'Initiative'),
41
41
  icon: isTask ? 'tk' : 'list',
42
+ rename: o.rename || null, // the Viewer's rename option, from the page that knows how to write it (rename-press.js)
42
43
  render(el) {
43
44
  el.innerHTML = readingHtml(isTask ? 'the task' : 'the initiative');
44
45
  read(ctx).then((s) => {
@@ -0,0 +1,81 @@
1
+ /* pm/rename-press.js — rename a program, an initiative or a PMOS task (testing feedback 2026-10-24; canvas RnATask, RnAIni,
2
+ * RnAProg, RnASaved). The Viewer's title is the press (cozy-viewer.js `rename`); these are the writes behind it, one per level,
3
+ * each the level's own route and the PM's press. Only the name changes: the id, the file, the links and the history stay.
4
+ *
5
+ * initiativeRename({ pmPost, ws, id, epics }) → the Viewer's `rename` option for an initiative (Jira box when it has an epic)
6
+ * taskRename({ pmPost, ws, board, uid, ref }) → the same for a PMOS task (Jira box when it has a Jira key)
7
+ * programRename({ pmPost, program }) → the same for a program: its whole charter again, with its id (no Jira box)
8
+ * jiraAsk(kind, keys, title) → the words the chat starts with when the PM ticks the Jira box. PMOS holds no
9
+ * Jira credential (D53): the PM's own agent renames it, after the PM sends them.
10
+ * Each `save` resolves { ok, title, from, undo() } or { ok: false, error }; the caller says "Renamed" with Undo. */
11
+
12
+ const said = (r, fallback) => (r && r.error) || fallback;
13
+
14
+ export function jiraAsk(kind, keys, title) {
15
+ const k = (keys || []).filter(Boolean);
16
+ if (!k.length) return '';
17
+ return 'Rename the Jira ' + kind + (k.length > 1 ? 's ' : ' ') + k.join(', ') + ' to "' + title + '".';
18
+ }
19
+
20
+ export function initiativeRename({ pmPost, ws, id, epics, onSaved }) {
21
+ const keys = (epics || []).filter(Boolean);
22
+ const write = async (title) => {
23
+ const r = await pmPost('/api/initiatives/rename', { ws: ws || undefined, id, title }).catch(() => null);
24
+ return r && r.ok ? { ok: true, title: r.title, from: r.from } : { ok: false, error: said(r, 'The name was not saved.') };
25
+ };
26
+ return {
27
+ max: 120,
28
+ jira: keys.length ? { label: 'Rename the Jira ' + (keys.length > 1 ? 'epics' : 'epic') + ' too', key: keys.join(', ') } : null,
29
+ save: async (title, o = {}) => {
30
+ const r = await write(title);
31
+ if (!r.ok) return r;
32
+ const out = { ...r, jira: o.jira ? jiraAsk('epic', keys, r.title) : '', undo: () => write(r.from) };
33
+ if (onSaved) await onSaved(out);
34
+ return out;
35
+ },
36
+ };
37
+ }
38
+
39
+ export function taskRename({ pmPost, ws, board, uid, ref, onSaved }) {
40
+ const write = async (title) => {
41
+ const r = await pmPost('/api/boards/tasks/rename', { ws: ws || undefined, board: board || undefined, task: uid, title }).catch(() => null);
42
+ return r && r.ok ? { ok: true, title: (r.item && r.item.title) || title, from: r.from } : { ok: false, error: said(r, 'The name was not saved.') };
43
+ };
44
+ return {
45
+ max: 200,
46
+ jira: ref ? { label: 'Rename the Jira ticket too', key: ref } : null,
47
+ save: async (title, o = {}) => {
48
+ const r = await write(title);
49
+ if (!r.ok) return r;
50
+ const out = { ...r, jira: o.jira && ref ? jiraAsk('ticket', [ref], r.title) : '', undo: () => write(r.from) };
51
+ if (onSaved) await onSaved(out);
52
+ return out;
53
+ },
54
+ };
55
+ }
56
+
57
+ /** The charter as POST /api/programs/save takes it: every field it keeps, with the id, so a new title never makes a new program. */
58
+ export function charterOf(p, title) {
59
+ const ms = (p.milestones || []).map((m) => ({ id: m.id, name: m.name, date: m.date || '', waits: m.waits || [], ...(m.waits && m.waits.length ? {} : { done: !!m.done }) }));
60
+ return { id: p.id, title, owner: p.owner || '', goal: p.goal || '', why: p.why || '', start: p.start || '', target: p.target || '', jira: p.jira || '', milestones: ms };
61
+ }
62
+
63
+ export function programRename({ pmPost, program, onSaved }) {
64
+ const p = program;
65
+ const write = async (title) => {
66
+ const r = await pmPost('/api/programs/save', { ws: p.home || undefined, program: charterOf(p, title) }).catch(() => null);
67
+ return r && r.ok !== false ? { ok: true, title, from: p.title } : { ok: false, error: said(r, 'The name was not saved.') };
68
+ };
69
+ return {
70
+ max: 120,
71
+ jira: null,
72
+ save: async (title) => {
73
+ const from = p.title;
74
+ const r = await write(title);
75
+ if (!r.ok) return r;
76
+ const out = { ...r, from, undo: () => write(from) };
77
+ if (onSaved) await onSaved(out);
78
+ return out;
79
+ },
80
+ };
81
+ }
@@ -0,0 +1,166 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* rename-test.js — tap the title to rename a program, an initiative or a task (testing feedback 2026-10-24; canvas RnATask, RnAIni,
4
+ * RnAProg, RnASaved, RnAPhone). Serves the real Board page from the real server; GET /api/board-premium answers the Project Ascent
5
+ * product (fixtures/board-premium-facts.js programFacts, one row given a Jira epic), GET /api/programs its programs, and every write
6
+ * is captured, not written.
7
+ * F the field: a tap makes the title one field with a check; Esc cancels; an empty name saves nothing; the same name saves nothing
8
+ * I an initiative: Enter writes POST /api/initiatives/rename with its id; the panel and the list show the new name at once; the toast
9
+ * says Renamed with Undo, and Undo sends the old name; the Jira box is there only for a row with an epic, off by default, and when
10
+ * ticked Home's chat opens on the initiative with the request typed, not sent
11
+ * P a program: the field holds the name only (not "· goal"); the save resends the whole charter with its id, so no new program is made
12
+ * E a refusal keeps the field open with the reason
13
+ * S on a phone the field fills the header */
14
+ const path = require('path');
15
+ const { spawn } = require('child_process');
16
+ const { findBrowser } = require('./lib/find-browser');
17
+ const T = require('./test-run').configure({ name: 'rename' });
18
+ const BP = require('./lib/board-premium.js');
19
+ const F = require('./fixtures/board-premium-facts.js');
20
+
21
+ const BASE = T.BASE;
22
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
23
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
24
+ const results = [];
25
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
26
+ let srv = null; let browser = null;
27
+ const finish = async (code) => {
28
+ if (browser) await browser.close().catch(() => {});
29
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
30
+ T.killTmux();
31
+ const bad = results.filter((x) => !x.cond).length;
32
+ console.log(`\n${results.length - bad}/${results.length} rename assertions passed`);
33
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
34
+ };
35
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
36
+
37
+ (async () => {
38
+ const exe = process.env.PMOS_CHROME || findBrowser();
39
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
40
+ let chromium;
41
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
42
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
43
+ await T.waitForServer(BASE);
44
+ browser = await chromium.launch({ executablePath: exe });
45
+
46
+ const model = () => { const m = BP.build(F.programFacts('idpf')); const r = m.rows.find((x) => x.id === 'descope-parity'); if (r) r.epics = ['IDPF-12']; return m; };
47
+ const open = async ({ w = 1440, h = 900, qs = '?ws=idpf&focus=descope-parity', refuse = false } = {}) => {
48
+ const c = await browser.newContext({ viewport: { width: w, height: h } });
49
+ const page = await c.newPage();
50
+ const errors = [], posts = [];
51
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
52
+ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
53
+ await page.route('**/api/board-premium*', (r) => json(r, { ok: true, state: 'ready', model: model(), as_of: Date.now() }));
54
+ await page.route('**/api/programs', (r) => json(r, { ok: true, programs: F.programs() }));
55
+ await page.route('**/api/boards/anchors*', (r) => json(r, { ok: true, anchors: [] }));
56
+ await page.route('**/api/insights-premium*', (r) => json(r, { ok: true, model: { goals: [] } }));
57
+ await page.route('**/api/boards/items*', (r) => json(r, { ok: true, items: [] }));
58
+ await page.route('**/api/board-trail*', (r) => json(r, { ok: false, error: 'not in this check' }, 500));
59
+ const capture = (r) => {
60
+ const rq = r.request(), body = JSON.parse(rq.postData() || '{}'), p = new URL(rq.url()).pathname;
61
+ posts.push({ path: p, body });
62
+ if (refuse) return json(r, { ok: false, error: 'the record could not be written — nothing was saved' }, 500);
63
+ if (p === '/api/initiatives/rename') return json(r, { ok: true, id: body.id, title: body.title, from: posts.filter((x) => x.path === p).length > 1 ? 'Descope feature parity · v2' : 'Descope feature parity' });
64
+ return json(r, { ok: true });
65
+ };
66
+ await page.route('**/api/initiatives/rename', capture);
67
+ await page.route('**/api/programs/*', capture);
68
+ await page.goto(BASE + '/premium-board.html' + qs);
69
+ return { page, ctx: c, errors, posts };
70
+ };
71
+ const head = (p) => p.evaluate(() => { const v = document.querySelector('#czViewer'); if (!v || v.hidden) return null; const i = v.querySelector('.cz-vw-ren input');
72
+ return { title: (v.querySelector('.cz-vw-title') || {}).textContent || '', field: i ? i.value : null, check: !!v.querySelector('.cz-vw-ren .cz-vw-sv'), jira: (v.querySelector('.cz-vw-jt') || {}).textContent || '',
73
+ jiraOn: !!(v.querySelector('.cz-vw-jt input') || {}).checked, err: (v.querySelector('.cz-vw-rnerr') || {}).textContent || '', press: !!v.querySelector('[data-cz-vw-rn]'), pencil: !!v.querySelector('[aria-label*="pencil" i], [data-cz-vw="edit"]') }; });
74
+
75
+ /* ── an initiative on the Board (RnAIni) ── */
76
+ const D = await open();
77
+ const p = D.page;
78
+ let h = await until(() => head(p).then((x) => (x && /Descope/.test(x.title) ? x : null)));
79
+ ok('F the initiative\'s title is the rename press: no pencil button, a text cursor on hover', h && h.press && !h.pencil
80
+ && await p.evaluate(() => getComputedStyle(document.querySelector('#czViewer [data-cz-vw-rn]')).cursor) === 'text', JSON.stringify(h));
81
+ await p.click('#czViewer [data-cz-vw-rn]');
82
+ h = await head(p);
83
+ ok('F a tap makes it one field with the name and a check; the focus is in it', h.field === 'Descope feature parity' && h.check && await p.evaluate(() => document.activeElement && document.activeElement.closest('.cz-vw-ren') !== null), JSON.stringify(h));
84
+ ok('I the initiative has a Jira epic, so the box is there, off by default, naming it', /Rename the Jira epic too/.test(h.jira) && /IDPF-12/.test(h.jira) && !h.jiraOn, JSON.stringify(h));
85
+ await p.keyboard.press('Escape');
86
+ h = await head(p);
87
+ ok('F Esc cancels: the title is back, the Viewer stays open, nothing is written', h && h.field === null && /Descope feature parity/.test(h.title) && D.posts.length === 0, JSON.stringify([h, D.posts]));
88
+ await p.click('#czViewer [data-cz-vw-rn]');
89
+ await p.fill('#czViewer .cz-vw-ren input', ' ');
90
+ await p.keyboard.press('Enter');
91
+ h = await head(p);
92
+ ok('F an empty name saves nothing: the field stays', h.field !== null && D.posts.length === 0, JSON.stringify([h, D.posts]));
93
+ await p.fill('#czViewer .cz-vw-ren input', 'Descope feature parity');
94
+ await p.keyboard.press('Enter');
95
+ h = await head(p);
96
+ ok('F the same name saves nothing and closes the field', h.field === null && D.posts.length === 0, JSON.stringify([h, D.posts]));
97
+ await p.click('#czViewer [data-cz-vw-rn]');
98
+ await p.fill('#czViewer .cz-vw-ren input', 'Descope feature parity · v2');
99
+ await p.keyboard.press('Enter');
100
+ h = await until(() => head(p).then((x) => (x && x.field === null ? x : null)));
101
+ const post = D.posts.find((x) => x.path === '/api/initiatives/rename');
102
+ ok('I Enter writes the rename with the initiative\'s id and the new name', post && post.body.id === 'descope-parity' && post.body.title === 'Descope feature parity · v2' && post.body.ws === 'idpf', JSON.stringify(D.posts));
103
+ ok('I the panel shows the new name at once', h && h.title === 'Descope feature parity · v2', JSON.stringify(h));
104
+ const row = await until(() => p.evaluate(() => [...document.querySelectorAll('#ibBody [data-key]')].map((x) => x.textContent).some((t) => /Descope feature parity · v2/.test(t))));
105
+ ok('I the Board list shows the new name too', row);
106
+ const tst = await until(() => p.evaluate(() => { const t = document.querySelector('#bdToast'); return t && !t.hidden ? t.textContent : ''; }));
107
+ ok('I the toast says Renamed, with Undo', /^Renamed/.test(tst) && /Undo/.test(tst), tst + ' | ' + D.errors.join(' | '));
108
+ await p.click('#bdToast .bd-undo');
109
+ await until(() => D.posts.filter((x) => x.path === '/api/initiatives/rename').length === 2);
110
+ const undo = D.posts.filter((x) => x.path === '/api/initiatives/rename')[1];
111
+ h = await until(() => head(p).then((x) => (x && x.title === 'Descope feature parity' ? x : null)));
112
+ ok('I Undo sends the old name through the same route, and the panel shows it again', undo && undo.body.title === 'Descope feature parity' && h, JSON.stringify([undo, h]));
113
+
114
+ // the Jira box, ticked: Home's chat about the initiative, with the request typed for the PM to send
115
+ await p.click('#czViewer [data-cz-vw-rn]');
116
+ await p.fill('#czViewer .cz-vw-ren input', 'Descope parity');
117
+ await p.check('#czViewer .cz-vw-jt input');
118
+ await Promise.all([p.waitForURL(/\/premium\.html\?/, { timeout: 15000 }).catch(() => null), p.click('#czViewer .cz-vw-sv')]);
119
+ const u = new URL(p.url());
120
+ ok('I with the Jira box ticked, Home opens the initiative\'s chat with the request typed, not sent', u.pathname === '/premium.html' && u.searchParams.get('about') === 'init:descope-parity'
121
+ && u.searchParams.get('say') === 'Rename the Jira epic IDPF-12 to "Descope parity".', u.href);
122
+ ok('I a row with no Jira epic has no Jira box', await (async () => {
123
+ const X = await open({ qs: '?ws=idpf&focus=usage-billing' });
124
+ await until(() => head(X.page).then((x) => (x && /Usage-based billing/.test(x.title) ? x : null)));
125
+ await X.page.click('#czViewer [data-cz-vw-rn]');
126
+ const y = await head(X.page); await X.ctx.close(); return y && y.field === 'Usage-based billing' && y.jira === '';
127
+ })());
128
+ ok('I no page error', D.errors.length === 0, D.errors.join(' | '));
129
+ await D.ctx.close();
130
+
131
+ /* ── a refusal (E) ── */
132
+ const E = await open({ refuse: true });
133
+ await until(() => head(E.page).then((x) => (x && /Descope/.test(x.title) ? x : null)));
134
+ await E.page.click('#czViewer [data-cz-vw-rn]');
135
+ await E.page.fill('#czViewer .cz-vw-ren input', 'New name');
136
+ await E.page.keyboard.press('Enter');
137
+ h = await until(() => head(E.page).then((x) => (x && x.err ? x : null)));
138
+ ok('E a refusal keeps the field open, with the name typed and the reason', h && h.field === 'New name' && /nothing was saved/.test(h.err), JSON.stringify(h));
139
+ await E.ctx.close();
140
+
141
+ /* ── a program (RnAProg) ── */
142
+ const G = await open({ qs: '?ws=idpf&program=project-ascent' });
143
+ h = await until(() => head(G.page).then((x) => (x && /Project Ascent/.test(x.title) ? x : null)));
144
+ await G.page.click('#czViewer [data-cz-vw-rn]');
145
+ h = await head(G.page);
146
+ ok('P the field holds the program\'s name only, not "· goal"; a program has no Jira box', h.field === 'Project Ascent' && h.jira === '', JSON.stringify(h));
147
+ await G.page.fill('#czViewer .cz-vw-ren input', 'Ascent');
148
+ await G.page.keyboard.press('Enter');
149
+ const sv = await until(() => G.posts.find((x) => x.path === '/api/programs/save'));
150
+ const pr = F.programs().find((x) => x.id === 'project-ascent');
151
+ ok('P the save resends the whole charter with its id: a new title never makes a new program', sv && sv.body.program.id === 'project-ascent' && sv.body.program.title === 'Ascent' && sv.body.ws === 'idpf'
152
+ && sv.body.program.goal === pr.goal && sv.body.program.owner === pr.owner && sv.body.program.target === pr.target && sv.body.program.milestones.length === pr.milestones.length, JSON.stringify(sv));
153
+ ok('P no page error', G.errors.length === 0, G.errors.join(' | '));
154
+ await G.ctx.close();
155
+
156
+ /* ── a phone (RnAPhone) ── */
157
+ const S = await open({ w: 390, h: 844 });
158
+ await until(() => head(S.page).then((x) => (x && /Descope/.test(x.title) ? x : null)));
159
+ const rnH = await S.page.evaluate(() => document.querySelector('#czViewer [data-cz-vw-rn]').getBoundingClientRect().height);
160
+ ok('S on a phone the title press is a 44 px target', rnH >= 44, String(rnH));
161
+ await S.page.click('#czViewer [data-cz-vw-rn]');
162
+ const box = await S.page.evaluate(() => { const f = document.querySelector('#czViewer .cz-vw-ren'); const r = f.getBoundingClientRect(); return { w: r.width, h: r.height, vw: innerWidth }; });
163
+ ok('S on a phone the field fills the header, 44 px high', box.w > box.vw * 0.6 && box.h >= 44, JSON.stringify(box));
164
+ await S.ctx.close();
165
+ finish();
166
+ })();
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "testing feedback 2026-10-24: tap the title to rename a program, an initiative or a task (canvas RnATask, RnAIni, RnAProg, RnASaved, RnAPhone).",
3
+ "panels": [
4
+ "rename-test.js"
5
+ ],
6
+ "seconds": {
7
+ "rename-test.js": 25
8
+ }
9
+ }