create-pmos 0.593.0 → 0.595.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/package.json +39 -27
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +38 -0
  7. package/workspace/fixtures/transcript-task-tools.jsonl +5 -0
  8. package/workspace/guide/agent-capabilities.md +2 -2
  9. package/workspace/guide/cli.md +1 -1
  10. package/workspace/guide/notes.md +2 -2
  11. package/workspace/guide/scheduled-tasks-and-cli.md +3 -1
  12. package/workspace/guide/settings-and-switches.md +20 -1
  13. package/workspace/lib/calendar-events.js +5 -1
  14. package/workspace/lib/goal-chat.js +1 -1
  15. package/workspace/lib/lab-cli.js +2 -2
  16. package/workspace/lib/live-round.js +20 -9
  17. package/workspace/lib/proposals.js +22 -4
  18. package/workspace/lib/refresh-run.js +23 -9
  19. package/workspace/lib/refresh.js +64 -19
  20. package/workspace/lib/routes-briefing-premium.js +1 -1
  21. package/workspace/lib/routes-lab.js +7 -3
  22. package/workspace/lib/schedule-cli.js +2 -2
  23. package/workspace/lib/schedule-logic.js +8 -2
  24. package/workspace/lib/transcript-steps.js +66 -17
  25. package/workspace/package-lock.json +2 -2
  26. package/workspace/package.json +1 -1
  27. package/workspace/public/pm/cozy-ev.css +27 -0
  28. package/workspace/public/pm/cozy-evmodel.js +45 -6
  29. package/workspace/public/pm/cozy-schedwork.js +201 -0
  30. package/workspace/public/pm/cozy-settings.js +12 -4
  31. package/workspace/public/pm/cozy-vw-mtg.css +3 -0
  32. package/workspace/public/pm/ini-agent.js +2 -0
  33. package/workspace/public/pm/ini-props.js +1 -1
  34. package/workspace/public/pm/ini-view.js +10 -1
  35. package/workspace/public/pm/premium-vw-doc.css +0 -3
  36. package/workspace/public/pm/small-vw.js +1 -0
@@ -7,7 +7,9 @@
7
7
  *
8
8
  * THE SETTINGS. <state>/refresh.json: { sources: { id: { on, s, ws } }, rules, migrated }. `s` is the schedule of a skill source:
9
9
  * { kind: 'manual' } only when the PM presses Refresh
10
- * { kind: 'every', every: '15'..'240', work } every N minutes from midnight; `work` keeps it inside the background working hours
10
+ * { kind: 'every', every: '15'..'240', work, busy? } every N minutes from midnight; `work` keeps it inside the background working hours;
11
+ * `busy` { every, meetings } reads more often on a day with that many meetings or more (batch 31 item 2:
12
+ * the ✦ "Read it more often on meeting days" the PM approves; the meeting count is host.busyDay)
11
13
  * { kind: 'daily' | 'weekdays', times: ['HH:MM', …] } one to four times a day (weekdays: Monday to Friday)
12
14
  * { kind: 'weekly', day: 'Mon'..'Sun', times: ['HH:MM'] }
13
15
  * A job source keeps only `on` here; the day check's minutes live in the proactive settings (dayCheck.every), their one home.
@@ -33,6 +35,7 @@ const WAIT_MS = 30 * 60 * 1000; // a refresh waits at most this long fo
33
35
  const LATE_MS = 15 * 60 * 1000; // a slot older than this when first seen was missed (PMOS was closed)
34
36
  const FIRST_MS = 2 * 3600 * 1000; // harness-health: a scheduled run first refreshes its skill inputs whose last good read is older than this
35
37
  const MAX_TIMES = 4;
38
+ const BUSY_MEETINGS = 3; // a meeting day: this many meetings or more (the ✦ rhythm proposal, batch 31 item 2)
36
39
 
37
40
  /* The sources. `fresh` names the lib/freshness.js row whose age and detail this source shares; `copy` names the files a done run keeps. */
38
41
  const SOURCES = Object.freeze([
@@ -121,7 +124,14 @@ function normalize(src, s) {
121
124
  if (s.kind === 'manual') return { ok: true, s: { kind: 'manual' } };
122
125
  if (s.kind === 'every') {
123
126
  if (!EVERY.includes(String(s.every))) return { ok: false, error: 'every must be one of ' + EVERY.join(', ') + ' (minutes)' };
124
- return { ok: true, s: { kind: 'every', every: String(s.every), work: !!s.work } };
127
+ const out = { kind: 'every', every: String(s.every), work: !!s.work };
128
+ if (s.busy != null) {
129
+ const b = s.busy, n = Number(b && b.meetings);
130
+ if (!b || typeof b !== 'object' || !EVERY.includes(String(b.every))) return { ok: false, error: 'busy.every must be one of ' + EVERY.join(', ') + ' (minutes)' };
131
+ if (!(Number.isInteger(n) && n >= 1 && n <= 12)) return { ok: false, error: 'busy.meetings must be a whole number from 1 to 12' };
132
+ if (Number(b.every) < Number(out.every)) out.busy = { every: String(b.every), meetings: n }; // a busy rhythm slower than the usual one adds nothing
133
+ }
134
+ return { ok: true, s: out };
125
135
  }
126
136
  const times = cleanTimes(s.times);
127
137
  if (!times.length) return { ok: false, error: 'times must hold one to four HH:MM times (24-hour)' };
@@ -138,11 +148,13 @@ const dayStart = (ms) => { const d = new Date(ms); d.setHours(0, 0, 0, 0); retur
138
148
  const addDays = (ms, n) => { const d = new Date(ms); d.setDate(d.getDate() + n); return d.getTime(); };
139
149
  const dayOk = (s, ms) => { const d = new Date(ms).getDay(); return s.kind === 'weekdays' ? d >= 1 && d <= 5 : s.kind === 'weekly' ? DAYS[d] === s.day : true; };
140
150
 
141
- /** The slots of one day, in ms, ascending. `win` is { start, end } HH:MM, the background working hours. */
142
- function slotsOfDay(s, dayMs, win) {
151
+ /** The slots of one day, in ms, ascending. `win` is { start, end } HH:MM, the background working hours. `busyDay(dayMs)` → how many
152
+ * meetings that day has (a schedule with `busy` steps by busy.every on a day with busy.meetings or more). */
153
+ function slotsOfDay(s, dayMs, win, busyDay) {
143
154
  if (!s || s.kind === 'manual') return [];
144
155
  if (s.kind === 'every') {
145
- const step = Number(s.every) || 60; const out = [];
156
+ const busy = s.busy && busyDay && (Number(busyDay(dayStart(dayMs))) || 0) >= s.busy.meetings;
157
+ const step = Number(busy ? s.busy.every : s.every) || 60; const out = [];
146
158
  const lo = s.work && win ? minutesOf(win.start) : 0; const hi = s.work && win ? minutesOf(win.end) : 24 * 60;
147
159
  for (let m = 0; m < 24 * 60; m += step) if (m >= lo && m < hi) out.push(dayStart(dayMs) + m * 60000);
148
160
  // A clock change can shift a day; dayStart + minutes is near enough for minute slots.
@@ -152,23 +164,50 @@ function slotsOfDay(s, dayMs, win) {
152
164
  return cleanTimes(s.times).map((t) => at(dayMs, t));
153
165
  }
154
166
  /** The most recent slot at or before `now`, in ms, or null (none in the last 8 days). */
155
- function lastSlot(s, now, win) {
167
+ function lastSlot(s, now, win, busyDay) {
156
168
  for (let k = 0; k < 8; k++) {
157
169
  const day = addDays(dayStart(now), -k);
158
- const hits = slotsOfDay(s, day, win).filter((x) => x <= now);
170
+ const hits = slotsOfDay(s, day, win, busyDay).filter((x) => x <= now);
159
171
  if (hits.length) return hits[hits.length - 1];
160
172
  }
161
173
  return null;
162
174
  }
163
175
  /** The next slot strictly after `now`, in ms, or null. */
164
- function nextSlot(s, now, win) {
176
+ function nextSlot(s, now, win, busyDay) {
165
177
  for (let k = 0; k < 9; k++) {
166
178
  const day = addDays(dayStart(now), k);
167
- const hit = slotsOfDay(s, day, win).find((x) => x > now);
179
+ const hit = slotsOfDay(s, day, win, busyDay).find((x) => x > now);
168
180
  if (hit != null) return hit;
169
181
  }
170
182
  return null;
171
183
  }
184
+ /**
185
+ * The slot PMOS missed, in ms, or null (batch 31 item 2: the amber line and ↻ show only then). The newest slot more than LATE_MS old is
186
+ * missed when nothing is running, no run started at or after it, and the PM's own change did not pass it (turning the source on or a new
187
+ * schedule moves last_slot without a run; a slot the tick skipped stays missed): PMOS was closed or the computer slept, or the slot was skipped.
188
+ */
189
+ function missedSlot(s, now, win, { lastStart, running, busyDay, handled, skipped } = {}) {
190
+ if (!s || s.kind === 'manual' || running) return null;
191
+ const slot = lastSlot(s, now - LATE_MS, win, busyDay); // the newest slot the tick has had its 15 minutes to start
192
+ if (slot == null) return null;
193
+ if (Number.isFinite(lastStart) && lastStart >= slot - 60000) return null;
194
+ // `handled` is the state's last_slot: a slot the PM's own change passed (turned on, a new schedule) is not missed; one the tick skipped is
195
+ if (Number.isFinite(handled) && handled >= slot && !(skipped && skipped(slot))) return null;
196
+ return slot;
197
+ }
198
+ /**
199
+ * PMOS's ✦ rhythm proposal for a source, or null (batch 31 item 2, agreed design SwC). Calendar on an every-N schedule slower than
200
+ * 15 min, with no meeting-day rhythm yet, on a day with BUSY_MEETINGS meetings or more: read it every 15 min on such days.
201
+ * → { every, meetings, today, s } where `s` is the whole schedule the PM's ✓ saves.
202
+ */
203
+ function proposalOf(src, set, now, busyDay) {
204
+ if (!src || src.id !== 'calendar' || !set || !set.on || !busyDay) return null;
205
+ const s = set.s;
206
+ if (!s || s.kind !== 'every' || s.busy || Number(s.every) <= 15) return null;
207
+ const today = Number(busyDay(dayStart(now))) || 0;
208
+ if (today < BUSY_MEETINGS) return null;
209
+ return { every: '15', meetings: BUSY_MEETINGS, today, s: { ...s, busy: { every: '15', meetings: BUSY_MEETINGS } } };
210
+ }
172
211
  const inWindow = (now, win) => { if (!win) return true; const d = new Date(now); const m = d.getHours() * 60 + d.getMinutes(); return m >= minutesOf(win.start) && m < minutesOf(win.end); };
173
212
  function inQuiet(now, quiet) {
174
213
  if (!quiet || !quiet.start || !quiet.end) return false;
@@ -287,7 +326,7 @@ function decide(src, st, ctx) {
287
326
  if (st.pending) return gateInputs(src, st, ctx, { trigger: st.pending.trigger || 'pressed', pressed: true });
288
327
  // A retry of a failed run.
289
328
  if (st.retry_at && now >= st.retry_at) return gateInputs(src, st, ctx, { trigger: 'retry', slot: st.last_slot || null });
290
- const slot = lastSlot(set.s, now, ctx.win);
329
+ const slot = lastSlot(set.s, now, ctx.win, ctx.busyDay);
291
330
  if (slot == null) return { act: 'none', why: 'no slot' };
292
331
  if (st.last_slot != null && st.last_slot >= slot) return { act: 'none', why: 'done' };
293
332
  // A slot from before the last start (a run pressed after it) is done too.
@@ -345,10 +384,11 @@ function sourceOfOrigin(origin, { skillOfSchedule } = {}) {
345
384
  /* ── rows for the page ── */
346
385
  /**
347
386
  * One row per source for GET /api/refresh. → [row]
348
- * opts { now, settings, state, log (folded: lastRun(id), runs(id, n)), fresh (Map id → freshness row), win, quiet, jobSchedule(id) → text|null, ws }
387
+ * opts { now, settings, state, log (folded: lastRun(id), runs(id, n)), fresh (Map id → freshness row), win, quiet, jobSchedule(id) → text|null, ws,
388
+ * busyDay(dayMs) → meetings that day }
349
389
  */
350
390
  function rowsOf(opts) {
351
- const { now, settings, state, log, fresh, win } = opts;
391
+ const { now, settings, state, log, fresh, win, busyDay } = opts;
352
392
  const rows = SOURCES.map((src) => {
353
393
  const set = settings.sources[src.id]; const st = state[src.id] || {};
354
394
  const last = log.lastRun(src.id);
@@ -363,8 +403,11 @@ function rowsOf(opts) {
363
403
  else if (fr && fr.state === 'failed') stateName = 'failed';
364
404
  else if (fr && fr.state === 'stale') stateName = 'old';
365
405
  else if (!lastAt) stateName = 'never';
366
- else stateName = staleOf(src, set, lastAt, now, win) ? 'old' : 'recent';
367
- const next = set.on && src.run === 'skill' ? nextSlot(set.s, now, win) : null;
406
+ else stateName = staleOf(src, set, lastAt, now, win, busyDay) ? 'old' : 'recent';
407
+ const next = set.on && src.run === 'skill' ? nextSlot(set.s, now, win, busyDay) : null;
408
+ const lastStart = last && last.start_at ? Date.parse(last.start_at) : NaN;
409
+ const skipped = (slot) => (log.runs(src.id, 5) || []).some((x) => x.result === 'skipped' && Date.parse(x.start_at) >= slot);
410
+ const missed = set.on && src.run === 'skill' ? missedSlot(set.s, now, win, { lastStart, running: stateName === 'running' || stateName === 'waiting', busyDay, handled: st.last_slot, skipped }) : null;
368
411
  return {
369
412
  id: src.id, label: src.label, group: src.group, ic: src.ic, run: src.run, how: src.how, what: src.what, uses: src.uses.slice(), used_by: usedBy(src.id), impact: src.impact,
370
413
  on: set.on, schedule: src.run === 'skill' || src.id === 'daycheck' ? set.s : null, default: src.def || null, ws: set.ws,
@@ -375,6 +418,8 @@ function rowsOf(opts) {
375
418
  last: last ? { at: lastAt, start_at: last.start_at, result: last.result || (last.end_at ? 'done' : null), took_ms: last.took_ms != null ? last.took_ms : null,
376
419
  got: last.got || (fr && fr.detail) || null, error: last.error || null, trigger: last.trigger || null, note: last.note || null } : (lastAt ? { at: lastAt, got: fr && fr.detail || null } : null),
377
420
  next_at: next ? new Date(next).toISOString() : null,
421
+ missed_at: missed ? new Date(missed).toISOString() : null,
422
+ propose: proposalOf(src, set, now, busyDay),
378
423
  waiting_for: st.waiting_for || [],
379
424
  runs: log.runs(src.id, 5),
380
425
  };
@@ -388,12 +433,12 @@ function rowsOf(opts) {
388
433
  return rows;
389
434
  }
390
435
  /** Old: no refresh since the slot before the last one (a skill source), or older than a day (a job). */
391
- function staleOf(src, set, lastAt, now, win) {
436
+ function staleOf(src, set, lastAt, now, win, busyDay) {
392
437
  const t = Date.parse(lastAt); if (!Number.isFinite(t)) return false;
393
438
  if (src.run === 'skill') {
394
439
  const s = set.s; if (!s || s.kind === 'manual') return now - t > 26 * 3600000;
395
- const l1 = lastSlot(s, now, win); if (l1 == null) return false;
396
- const l0 = lastSlot(s, l1 - 1, win);
440
+ const l1 = lastSlot(s, now, win, busyDay); if (l1 == null) return false;
441
+ const l0 = lastSlot(s, l1 - 1, win, busyDay);
397
442
  return l0 != null && t < l0;
398
443
  }
399
444
  if (src.run === 'change') return false;
@@ -405,7 +450,7 @@ const everyText = (v) => ({ 15: '15 min', 30: '30 min', 60: 'hour', 120: '2 hour
405
450
  function textOf(s) {
406
451
  if (!s) return '';
407
452
  if (s.kind === 'manual') return 'Only when you press Refresh';
408
- if (s.kind === 'every') return 'Every ' + everyText(s.every) + (s.work ? ', working hours only' : '');
453
+ if (s.kind === 'every') return 'Every ' + everyText(s.every) + (s.work ? ', working hours only' : '') + (s.busy ? '; every ' + everyText(s.busy.every) + ' on days with ' + s.busy.meetings + ' or more meetings' : '');
409
454
  const t = (s.times || []).join(' and ');
410
455
  if (s.kind === 'daily') return 'Daily at ' + t;
411
456
  if (s.kind === 'weekdays') return 'Working days at ' + t;
@@ -526,6 +571,6 @@ function toCsv(runs) {
526
571
 
527
572
  module.exports = {
528
573
  SOURCES, BY_ID, SKILL_OF, SKILL_KINDS, EVERY, WAIT_MS, LATE_MS, FIRST_MS, RULE_DEFAULTS, RULE_OPTS,
529
- usedBy, normalize, normalizeRules, withDefaults, migrate, retireLegacy, refreshFirst, lastSlot, nextSlot, slotsOfDay, inWindow, inQuiet, decide, jobGate, sourceOfOrigin, rowsOf, textOf,
574
+ BUSY_MEETINGS, usedBy, normalize, normalizeRules, withDefaults, migrate, retireLegacy, refreshFirst, lastSlot, nextSlot, missedSlot, proposalOf, slotsOfDay, inWindow, inQuiet, decide, jobGate, sourceOfOrigin, rowsOf, textOf,
530
575
  files, readSettings, writeSettings, readState, writeState, newRun, append, readLog, foldLog, keepCopy, prune, toCsv,
531
576
  };
@@ -85,7 +85,7 @@ function liveAsk(ctx, key, text, wsId, refs = []) {
85
85
  const cur = P ? PR.currentOf(P, ini) : null, open = P ? LR.waiting(P, ini) : null;
86
86
  const it = LR.intentOf(q, { waiting: open || (cur ? { keys: [cur.key] } : null) });
87
87
  // every other message on an initiative with a prototype carries where it is and how to change it, so the chat never hunts for files
88
- const ctxLine = cur && w ? LR.contextOf(cur, { ini, ws: w.id, rt: ctx.runtimeDir || null }) : '';
88
+ const ctxLine = P && w ? LR.contextOf(cur, { ini, ws: w.id, rt: ctx.runtimeDir || null, versions: cur ? [] : PR.versionsOf(P, ini) }) : '';
89
89
  if (!it || !w) return ctxLine ? { text: ctxLine + '\n\nThe PM says: ' + q, filed: false } : null;
90
90
  // Wawan 2026-11-17 20:25, "iterative, like Claude Code design work": the round starts at once, no ✦ ask and no ✓. One version unless the
91
91
  // PM asked for several; a change sentence while one is open is its next round. The Viewer shows it; the chat says what changed.
@@ -5,7 +5,8 @@
5
5
  *
6
6
  * GET /api/lab?ws&board → { ok, lab } lab: lib/idle-lab.js labOf (null: nothing ran this week and nothing waits)
7
7
  * GET /api/lab/compare?ws&board&id[&key] → { ok, compare } lib/idle-lab.js compareOf (404 when the prototype is gone)
8
- * GET /api/lab/rounds?ws&initiative → { ok, rounds } lib/idle-lab.js roundsOf: every round of the initiative, newest first, open or not
8
+ * GET /api/lab/rounds?ws&initiative → { ok, rounds } lib/idle-lab.js roundsOf: every round of the initiative, newest first, open or not;
9
+ * the round of the initiative's prototype first, with current: { n, key, said, version }
9
10
  * GET /api/lab/present?ws&board&id → { ok, present } lib/lab-present.js presentOf: the round's frames for present mode (GET /pm/present)
10
11
  * GET /api/lab/specimen?file → text/html, a specimen from <runtime>/idle-lab/specimens/, served sandboxed (no scripts that can
11
12
  * reach PMOS: CSP sandbox without allow-same-origin, no network but the fonts)
@@ -135,7 +136,10 @@ const READS = {
135
136
  const w = wsOf(ctx, url.searchParams.get('ws')); if (!w) return fail(ctx, res, 404, 'no such workspace');
136
137
  const dir = dirOf(ctx, w), ini = url.searchParams.get('initiative') || '';
137
138
  if (!dir || !ID_RE.test(ini)) return fail(ctx, res, 400, 'initiative names an initiative');
138
- ctx.json(res, { ok: true, rounds: LAB.roundsOf(PR.read(dir), ini) });
139
+ // the round the initiative's prototype is in leads, marked with its version (lib/proposals.js currentOf): the Specimens line opens it
140
+ const P = PR.read(dir), cur = PR.currentOf(P, ini), rounds = LAB.roundsOf(P, ini);
141
+ if (cur) { const i = rounds.findIndex((r) => r.id === cur.of); if (i >= 0) rounds.unshift({ ...rounds.splice(i, 1)[0], current: { n: cur.n, key: cur.key, said: cur.said || cur.title, version: cur.id } }); }
142
+ ctx.json(res, { ok: true, rounds });
139
143
  return true;
140
144
  },
141
145
  '/api/lab/present': (ctx, res, url) => {
@@ -260,7 +264,7 @@ function liveRound(ctx, res, b) {
260
264
  const w = wsOf(ctx, typeof b.ws === 'string' && b.ws ? b.ws : null); if (!w) return fail(ctx, res, 404, 'no such workspace');
261
265
  const by = /^(pm|agent):[\w.:-]{1,80}$/.test(String(b.by || '')) ? b.by : 'agent:cli';
262
266
  const input = { ws: w.id, board: typeof b.board === 'string' ? b.board : '', ini: String(b.ini || ''), brief: String(b.brief || ''), base: /^[A-C]$/i.test(String(b.base || '')) ? String(b.base).toUpperCase() : '',
263
- dirs: typeof b.dirs === 'string' ? b.dirs : '', from: b.from === 'meeting' ? 'meeting' : b.from === 'chat' || b.propose ? 'chat' : 'cli', by, ...(b.one === true ? { count: 1 } : {}) };
267
+ dirs: typeof b.dirs === 'string' ? b.dirs : '', from: b.from === 'meeting' ? 'meeting' : b.from === 'chat' || b.propose ? 'chat' : 'cli', by, ...(b.one === true ? { count: 1 } : {}), ...(/^pr-[0-9a-f]{6,40}$/.test(String(b.of || '')) ? { of: b.of } : {}), ...(Number.isInteger(b.fromV) && b.fromV > 0 ? { fromV: b.fromV } : {}) };
264
268
  const r = b.propose === true ? LR.proposeNow(input) : LR.startNow(input);
265
269
  if (!r.ok) return fail(ctx, res, 409, r.error);
266
270
  ctx.json(res, r);
@@ -64,7 +64,7 @@ function gitRoot(dir) {
64
64
  }
65
65
 
66
66
  function describe(s) {
67
- const when = s.cadence === 'once' ? `once, ${s.date || '?'} at ${s.time || '09:00'}`
67
+ const when = s.cadence === 'hourly' ? `every hour at :${String(s.time || '00:00').slice(-2)}` : s.cadence === 'once' ? `once, ${s.date || '?'} at ${s.time || '09:00'}`
68
68
  : s.cadence === 'weekly' ? `every ${s.day || 'Mon'} at ${s.time}`
69
69
  : s.cadence === 'bi-weekly' ? `every other ${s.day || 'Mon'} at ${s.time}`
70
70
  : s.cadence === 'monthly' ? `monthly on day ${s.dayOfMonth || 1} at ${s.time}`
@@ -155,7 +155,7 @@ async function run(argv, { call, say, cwd = process.cwd() }) {
155
155
  say(`✓ skill "${created}" written (user skill). Review it: pmos skill show ${created}`);
156
156
  }
157
157
  if (!f.skill) return fail('say which skill: --skill <name> (pmos skill list), or --from-session / --from-file');
158
- if (!f.cadence) return fail('say when: --cadence daily|weekly|bi-weekly|monthly|once (with --time HH:MM, --day, --day-of-month or --date)');
158
+ if (!f.cadence) return fail('say when: --cadence hourly|daily|weekly|bi-weekly|monthly|once (with --time HH:MM, --day, --day-of-month or --date)');
159
159
  f.name = f.name || (created ? `${created}` : f.skill);
160
160
  f.task = f.skill;
161
161
  const r = await call('POST', '/api/schedules', { ...f, ws: w.id });
@@ -6,12 +6,13 @@
6
6
  * what will fire. Window-based due-ness, NO catch-up (a missed slot is skipped, per the PRD): a
7
7
  * schedule is due iff a scheduled slot falls in the interval (lastRun, now].
8
8
  *
9
- * A schedule: { cadence:'daily'|'weekly'|'bi-weekly'|'monthly', day:'Mon'..'Sun' (weekly/bi-weekly),
9
+ * A schedule: { cadence:'hourly'|'daily'|'weekly'|'bi-weekly'|'monthly', day:'Mon'..'Sun' (weekly/bi-weekly),
10
10
  * dayOfMonth:1..28 (monthly), time:'HH:MM', enabled, lastRun:ISO|null }. Times are host-local (v1).
11
+ * `hourly` (batch 31 item 2, Scheduled work): every hour at the minute of `time` ('09:15' runs at :15 of every hour).
11
12
  */
12
13
 
13
14
  const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; // JS getDay() index
14
- const CADENCES = ['daily', 'weekly', 'bi-weekly', 'monthly', 'once']; // R11: `once` — one date and time, then it stays off
15
+ const CADENCES = ['hourly', 'daily', 'weekly', 'bi-weekly', 'monthly', 'once']; // R11: `once` — one date and time, then it stays off
15
16
  const ONCE_GRACE_MS = 15 * 60 * 1000; // a one-off whose moment passed while nothing was running is MISSED, not caught up
16
17
 
17
18
  function parseTime(t) {
@@ -25,6 +26,8 @@ function atTime(d, time) {
25
26
  x.setHours(h, m, 0, 0);
26
27
  return x;
27
28
  }
29
+ /** This hour of `d`, at the minute of `time`. */
30
+ function atMinute(d, time) { const x = new Date(d); x.setMinutes(parseTime(time).m, 0, 0); return x; }
28
31
  function dayIndex(day) { const i = DAYS.indexOf(String(day)); return i < 0 ? 1 : i; } // default Mon
29
32
 
30
33
  // The most recent scheduled slot at or before `now` (Date), or null if none exists yet.
@@ -37,6 +40,7 @@ function onceSlot(schedule) {
37
40
  function lastSlot(schedule, now) {
38
41
  const cad = schedule.cadence;
39
42
  if (cad === 'once') { const o = onceSlot(schedule); return o && o <= now ? o : null; }
43
+ if (cad === 'hourly') { const x = atMinute(now, schedule.time); return x <= now ? x : new Date(x.getTime() - 3600000); }
40
44
  if (cad === 'daily') {
41
45
  const today = atTime(now, schedule.time);
42
46
  return today <= now ? today : addDays(today, -1);
@@ -63,6 +67,7 @@ function lastSlot(schedule, now) {
63
67
  function nextSlot(schedule, now) {
64
68
  const cad = schedule.cadence;
65
69
  if (cad === 'once') { const o = onceSlot(schedule); return o && o > now ? o : null; }
70
+ if (cad === 'hourly') { const x = atMinute(now, schedule.time); return x > now ? x : new Date(x.getTime() + 3600000); }
66
71
  if (cad === 'daily') {
67
72
  const today = atTime(now, schedule.time);
68
73
  return today > now ? today : addDays(today, 1);
@@ -134,6 +139,7 @@ function nextRun(schedule, now = new Date()) {
134
139
  function humanCadence(schedule) {
135
140
  const t = schedule.time || '09:00';
136
141
  switch (schedule.cadence) {
142
+ case 'hourly': return `every hour at :${t.slice(-2)}`;
137
143
  case 'daily': return `every day at ${t}`;
138
144
  case 'weekly': return `every ${schedule.day || 'Mon'} at ${t}`;
139
145
  case 'bi-weekly': return `every other ${schedule.day || 'Mon'} at ${t}`;
@@ -4,8 +4,10 @@
4
4
  *
5
5
  * readSteps(file, clean, root) → { steps: [{ text, state: done|now|next }] | null, stepsAt, change: { system, what, from, to, tool } | null }
6
6
  *
7
- * steps the newest TodoWrite list of the session (Claude Code's own plan of its turn): completed → done, in_progress → now,
8
- * pending → next. null when the session never wrote one: the chat then draws no checklist, never an invented one.
7
+ * steps the session's own plan of its turn, as Claude Code keeps it: the newest TodoWrite list, or the task list built by
8
+ * TaskCreate and TaskUpdate (newer Claude Code), whichever the session wrote last. completed → done, in_progress → now,
9
+ * pending → next; a deleted task leaves the list. A task's id comes from its TaskCreate result ("Task #3 created"),
10
+ * else from creation order. null when the session kept no list: the chat then draws no checklist, never an invented one.
9
11
  * A step also carries what the transcript holds about it, and nothing more: a done step that was seen in progress has
10
12
  * `sub` ("3 tool calls · 9s", its calls and the time from in progress to completed), and the step in progress has `call`, its
11
13
  * newest tool call ("jira.search project = PAY"). Neither is set when the transcript does not show it.
@@ -74,45 +76,92 @@ function callLine(name, input, clean = (x) => x, root = null) {
74
76
  }
75
77
  const secs = (a, b) => { const t = (Date.parse(b) - Date.parse(a)) / 1000; return Number.isFinite(t) && t >= 0 ? (t < 60 ? Math.round(t) + 's' : t < 3600 ? Math.round(t / 60) + ' min' : Math.floor(t / 3600) + ' h ' + Math.round((t % 3600) / 60) + ' min') : ''; };
76
78
 
79
+ /** The steps and the open change from a transcript's text. Pure over the text. */
80
+ const TASK_TOOLS = new Set(['TodoWrite', 'TaskCreate', 'TaskUpdate', 'TaskList', 'TaskGet', 'TaskStop', 'AskUserQuestion']);
81
+ const taskIdOf = (c) => {
82
+ const t = c && c.task && c.task.id != null ? String(c.task.id) : '';
83
+ if (t) return t;
84
+ const txt = typeof c === 'string' ? c : Array.isArray(c) ? c.map((x) => (x && x.text) || '').join(' ') : '';
85
+ const m = /Task #(\w+) created/.exec(txt);
86
+ return m ? m[1] : '';
87
+ };
88
+
77
89
  /** The steps and the open change from a transcript's text. Pure over the text. */
78
90
  function stepsOf(raw, clean = (x) => x, root = null) {
79
91
  let todos = null, todosAt = null;
80
92
  const open = new Map();
81
- const seen = new Map(); // a step's content → { start, end, calls, last }: what the transcript shows of it
82
- let doing = null; // the content of the step in progress now
93
+ const seen = new Map(); // a step's key → { start, end, calls, last }: what the transcript shows of it
94
+ let doing = null; // the key of the step in progress now
95
+ const tasks = new Map(); // TaskCreate/TaskUpdate: task id → { key, content, activeForm, status }, in creation order
96
+ const pending = new Map();// a TaskCreate's tool_use id → the id it was given by creation order, until its result names the real one
97
+ let made = 0;
98
+ // one list, either kind: mark when a step starts and ends, and which step is in progress now
99
+ const take = (list, ts, keyOf) => {
100
+ todos = list; todosAt = ts || null; doing = null;
101
+ for (const t of list) {
102
+ if (!t || !t.content) continue;
103
+ const k = keyOf(t), st = seen.get(k) || {};
104
+ if (t.status === 'in_progress') { if (!st.start) st.start = ts || null; doing = k; }
105
+ if (t.status === 'completed' && st.start && !st.end) st.end = ts || null;
106
+ seen.set(k, st);
107
+ }
108
+ };
109
+ const fromTasks = (ts) => take([...tasks.values()].filter((t) => t.status !== 'deleted'), ts, (t) => t.key);
83
110
  for (const line of String(raw || '').split('\n')) {
84
111
  if (!line) continue;
85
112
  let r; try { r = JSON.parse(line); } catch { continue; }
86
113
  if (r.isSidechain) continue;
87
114
  const content = r.message && Array.isArray(r.message.content) ? r.message.content : [];
88
- if (r.type === 'user') { for (const c of content) if (c && c.type === 'tool_result' && c.tool_use_id) open.delete(c.tool_use_id); continue; }
115
+ if (r.type === 'user') {
116
+ for (const c of content) {
117
+ if (!c || c.type !== 'tool_result' || !c.tool_use_id) continue;
118
+ open.delete(c.tool_use_id);
119
+ if (pending.has(c.tool_use_id)) {
120
+ // the result names the task's real id: re-key the task when creation order guessed another one
121
+ const guess = pending.get(c.tool_use_id); pending.delete(c.tool_use_id);
122
+ const real = taskIdOf(r.toolUseResult) || taskIdOf(c.content);
123
+ if (real && real !== guess && tasks.has(guess) && !tasks.has(real)) {
124
+ const next = new Map(); for (const [id, t] of tasks) next.set(id === guess ? real : id, t); tasks.clear(); for (const [id, t] of next) tasks.set(id, t);
125
+ }
126
+ }
127
+ }
128
+ continue;
129
+ }
89
130
  if (r.type !== 'assistant') continue;
90
131
  for (const c of content) {
91
132
  if (!c || c.type !== 'tool_use') continue;
92
- if (c.name === 'TodoWrite' && c.input && Array.isArray(c.input.todos)) {
93
- todos = c.input.todos; todosAt = r.timestamp || null; doing = null;
94
- for (const t of todos) {
95
- if (!t || !t.content) continue;
96
- const k = String(t.content), st = seen.get(k) || {};
97
- if (t.status === 'in_progress') { if (!st.start) st.start = r.timestamp || null; doing = k; }
98
- if (t.status === 'completed' && st.start && !st.end) st.end = r.timestamp || null;
99
- seen.set(k, st);
100
- }
101
- } else if (doing && c.name !== 'AskUserQuestion') { const st = seen.get(doing); st.calls = (st.calls || 0) + 1; st.last = { name: c.name, input: c.input }; }
133
+ const i = c.input && typeof c.input === 'object' ? c.input : {};
134
+ if (c.name === 'TodoWrite' && Array.isArray(i.todos)) {
135
+ take(i.todos, r.timestamp, (t) => String(t.content));
136
+ } else if (c.name === 'TaskCreate' && (i.subject || i.description)) {
137
+ // a task made after every task of the list is done or deleted starts a new list (the result's id re-keys it if needed)
138
+ if (tasks.size && [...tasks.values()].every((t) => t.status === 'completed' || t.status === 'deleted')) tasks.clear();
139
+ made++;
140
+ let id = String(made); while (tasks.has(id)) id = String(++made);
141
+ tasks.set(id, { key: 'task:' + made + ':' + String(i.subject || i.description), content: String(i.subject || i.description), activeForm: i.activeForm || '', status: 'pending' });
142
+ if (c.id) pending.set(c.id, id);
143
+ fromTasks(r.timestamp);
144
+ } else if (c.name === 'TaskUpdate' && i.taskId != null && tasks.has(String(i.taskId))) {
145
+ const t = tasks.get(String(i.taskId));
146
+ if (i.subject) t.content = String(i.subject);
147
+ if (i.activeForm) t.activeForm = String(i.activeForm);
148
+ if (['pending', 'in_progress', 'completed', 'deleted'].includes(i.status)) t.status = i.status;
149
+ fromTasks(r.timestamp);
150
+ } else if (doing && !TASK_TOOLS.has(c.name)) { const st = seen.get(doing); st.calls = (st.calls || 0) + 1; st.last = { name: c.name, input: c.input }; }
102
151
  if (c.id) open.set(c.id, { name: c.name, input: c.input });
103
152
  }
104
153
  }
105
154
  const steps = todos ? todos.slice(0, 12).map((t) => {
106
155
  const s = { text: clean(cut(t && (t.status === 'in_progress' && t.activeForm ? t.activeForm : t.content), 140)),
107
156
  state: t && t.status === 'completed' ? 'done' : t && t.status === 'in_progress' ? 'now' : 'next' };
108
- const st = t && t.content ? seen.get(String(t.content)) : null;
157
+ const st = t && t.content ? seen.get(t.key || String(t.content)) : null;
109
158
  if (st && s.state === 'done' && st.start && st.end) s.sub = [st.calls ? st.calls + (st.calls === 1 ? ' tool call' : ' tool calls') : '', secs(st.start, st.end)].filter(Boolean).join(' · ');
110
159
  if (st && s.state === 'now' && st.last) s.call = callLine(st.last.name, st.last.input, clean, root);
111
160
  if (!s.sub) delete s.sub;
112
161
  return s;
113
162
  }).filter((s) => s.text) : null;
114
163
  let last = null; for (const [, v] of open) last = v;
115
- const change = last && last.name !== 'TodoWrite' && last.name !== 'AskUserQuestion' ? changeOf(last.name, last.input, clean, root) : null;
164
+ const change = last && !TASK_TOOLS.has(last.name) ? changeOf(last.name, last.input, clean, root) : null;
116
165
  return { steps: steps && steps.length ? steps : null, stepsAt: todosAt, change };
117
166
  }
118
167
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.593.0",
3
+ "version": "0.595.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.593.0",
9
+ "version": "0.595.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.593.0",
3
+ "version": "0.595.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",
@@ -398,3 +398,30 @@
398
398
  .cz .ev-ls { display: flex; flex-direction: column; gap: 2px; }
399
399
  .cz .ev-ls .ev-ms { color: var(--cz-late); }
400
400
  .cz .ev-ls .ev-nx { color: var(--cz-blueink); }
401
+ /* Settings › Connectors › Scheduled work (batch 31 item 2, agreed design SwC; pm/cozy-schedwork.js): the quiet entry, the list, and a
402
+ * job's page like the Claude app's scheduled task: Active, Next run, Repeats in one card, PMOS's ✦ rhythm, History, ▶ Read now */
403
+ .ev-st .ev-sw-ic { color: var(--cz-ink3); display: inline-flex; flex: none; }
404
+ .ev-st .ev-sw-entry .ev-sw-ic { margin-left: -16px; }
405
+ .ev-st .ev-sw-grp { padding: 14px 0 4px; }
406
+ .ev-st .ev-sw-what { margin: 0 0 10px; }
407
+ .ev-st .ev-sw-warn { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 10px; }
408
+ .ev-st .ev-sw-warn .ev-dot { margin-top: 8px; }
409
+ .ev-st .ev-sw-warn p { margin: 0; }
410
+ .ev-st .ev-sw-card { background: var(--cz-card); border: 1px solid var(--cz-hair); border-radius: 16px; padding: 2px 14px; }
411
+ .ev-st .ev-sw-card .ev-trow.ev-sw-kv { padding: 10px 0; min-height: 52px; box-sizing: border-box; flex-wrap: nowrap; }
412
+ .ev-st .ev-sw-card select.ev-inp { max-width: 220px; }
413
+ .ev-st .ev-sw-prop { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; }
414
+ .ev-st .ev-sw-prop b { font-weight: var(--fw-strong); }
415
+ .ev-st .ev-sw-prop p { margin: 2px 0 0; color: var(--cz-ink2); }
416
+ .ev-st .ev-sw-hist { display: flex; flex-direction: column; }
417
+ .ev-st .ev-sw-h { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--cz-hair); font-size: var(--fs-body); line-height: var(--lh-body); }
418
+ .ev-st .ev-sw-h:last-child { border-bottom: 0; }
419
+ .ev-st .ev-sw-h .ev-mut { text-align: right; min-width: 0; overflow-wrap: anywhere; }
420
+ .ev-st .ev-sw-run { display: flex; justify-content: flex-end; padding: 12px 0 4px; }
421
+ .ev-st .ev-ib.ev-sw-play { width: 48px; height: 48px; background: var(--cz-ink); color: var(--cz-card); }
422
+ .ev-st .ev-ib.ev-sw-play svg { fill: currentColor; width: 20px; height: 20px; }
423
+ .ev-st .ev-ib.ev-sw-play:hover { background: var(--cz-ink2); }
424
+ @media (max-width: 760px) { .ev-st .ev-sw-card select.ev-inp { max-width: 170px; } }
425
+ .ev-st input.ev-inp.ev-sw-at { flex: 0 0 auto; width: 120px; }
426
+ .ev-st .ev-sw-more { margin: 0 0 8px 30px; }
427
+ .ev-st .ev-sw-undo { border-bottom: 0; padding: 8px 0 0; }
@@ -106,12 +106,45 @@ export function clockOf(iso, now = Date.now()) {
106
106
  return d.getDate() + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()];
107
107
  }
108
108
  const short = (a) => a.replace(/ hours? ago$/, ' h ago');
109
+ const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
110
+ /** When a next run is: "10:00" today, "tomorrow 08:00", "Mon 08:00" this week, else "3 Nov 08:00" (batch 31 item 2). */
111
+ export function nextOf(iso, now = Date.now()) {
112
+ const d = new Date(iso || ''); if (Number.isNaN(d.getTime())) return '';
113
+ const n = new Date(now), day = (x) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
114
+ const diff = Math.round((day(d) - day(n)) / 86400000), t = two_(d.getHours()) + ':' + two_(d.getMinutes());
115
+ if (d.getTime() <= now) return 'now';
116
+ if (diff <= 0) return t;
117
+ if (diff === 1) return 'tomorrow ' + t;
118
+ if (diff < 7) return WD[d.getDay()] + ' ' + t;
119
+ return d.getDate() + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()] + ' ' + t;
120
+ }
121
+ /** A past moment with its time: "09:15" today, "yesterday 17:31", "3 Nov 09:00". */
122
+ export function atOf(iso, now = Date.now()) {
123
+ const c = clockOf(iso, now), d = new Date(iso || '');
124
+ return !c || /^\d\d:\d\d$/.test(c) ? c : c + ' ' + two_(d.getHours()) + ':' + two_(d.getMinutes());
125
+ }
126
+ /** A schedule in the row's words: "Every 30 min, working hours only" → "Every 30 min in working hours". */
127
+ export const everyLine = (text) => String(text || '').replace(/, working hours only/, ' in working hours').replace(/^Only when you press Refresh$/, 'Only when you press read');
128
+ /**
129
+ * The line under a scheduled source (batch 31 item 2, agreed design SwC): how often · next, quiet grey; or, when PMOS missed a read,
130
+ * "Read yesterday 17:31 · missed 09:00", amber with ↻. → { text, missed } | null when the row has no schedule.
131
+ */
132
+ export function scheduleLine(s, now = Date.now()) {
133
+ const sch = s && s.schedule;
134
+ if (!sch || !sch.cadence) return null;
135
+ if (sch.cadence === 'off') return { text: 'Off', missed: false };
136
+ if (sch.missed_at) return { text: (s.as_of ? 'Read ' + atOf(s.as_of, now) : 'Never read') + ' · missed ' + atOf(sch.missed_at, now), missed: true };
137
+ const nx = sch.next_run ? nextOf(sch.next_run, now) : '';
138
+ return { text: everyLine(sch.cadence) + (nx ? ' · next ' + nx : ''), missed: false };
139
+ }
109
140
  /**
110
141
  * connectorRows(sources, health, now) → [{ id, name, trouble, why, when, act }] trouble rows first (needs you, then failed, then
111
142
  * the other issues), then the quiet rows in the server's order.
112
143
  * why the one reason (trouble), or "Checked 10:42 · same since 09:15" on a quiet row a measured read applies to, else ''
113
144
  * when the time on a quiet row ('3 h ago', 'Watching', 'Not connected', 'Reading now'); '' when `why` carries the time
114
145
  * act { kind: 'read' | 'open' | 'sec', label, href?, sec? } | null the one icon action
146
+ * job the Settings › Connectors item page of a scheduled source (lib/refresh.js id: calendar, jira, mywork, tracker, tools) or null
147
+ * Batch 31 item 2 (SwC): a scheduled source's quiet line says how often and when it reads next; a missed read turns the row amber with ↻.
115
148
  */
116
149
  export function connectorRows(sources, health, now = Date.now()) {
117
150
  const issues = (health && (health.level === 'warn' || health.level === 'bad') && health.issues) || [];
@@ -120,29 +153,35 @@ export function connectorRows(sources, health, now = Date.now()) {
120
153
  const out = [];
121
154
  for (const s of (sources || []).filter(Boolean)) {
122
155
  const name = sourceName(s), h = s.heal, iss = bySrc.get(s.id);
156
+ const jobOf = s.schedule && s.schedule.refresh ? { job: s.schedule.refresh } : {}; // the Scheduled work page of this source (batch 31 item 2)
123
157
  const read = { kind: 'read', label: 'Read ' + name + ' again' };
124
158
  if (h && h.state === 'needs-you' && h.action) {
125
159
  const a = h.action, dur = s.as_of ? ago(s.as_of, now).replace(/ ago$/, '') : '';
126
160
  const why = [s.as_of ? 'Not read for ' + dur + '.' : 'Never read.', h.tried || (h.why ? 'The read ' + h.why + '.' : ''), a.read ? '' : a.how].filter(Boolean).join(' ');
127
- out.push({ id: s.id, name, trouble: 1, why, when: '', act: a.read ? { ...read, label: a.label } : a.href ? { kind: 'open', label: a.label, href: a.href } : { kind: 'sec', label: a.label, sec: a.sec || 'claude' } });
161
+ out.push({ id: s.id, name, trouble: 1, why, when: '', act: a.read ? { ...read, label: a.label } : a.href ? { kind: 'open', label: a.label, href: a.href } : { kind: 'sec', label: a.label, sec: a.sec || 'claude' }, ...jobOf });
128
162
  continue;
129
163
  }
130
164
  if (s.state === 'failed' || iss) {
131
165
  const why = iss ? iss.why : 'Could not be read.';
132
166
  const act = s.id === 'repository' ? (iss ? { kind: 'sec', label: 'Check the repository address', sec: 'workspaces' } : null) : read;
133
- out.push({ id: s.id, name, trouble: 2, why, when: '', act });
167
+ out.push({ id: s.id, name, trouble: 2, why, when: '', act, ...jobOf });
134
168
  continue;
135
169
  }
136
170
  const mend = h && h.state === 'repairing' && (s.state === 'stale' || s.state === 'never');
137
- const sch = s.schedule || {};
171
+ const sch = s.schedule || {}, job = sch.refresh || null, line = scheduleLine(s, now);
172
+ if (line && line.missed && !mend && s.state !== 'building' && s.state !== 'off') {
173
+ out.push({ id: s.id, name, trouble: 4, why: line.text, when: '', act: read, ...(job ? { job } : {}) });
174
+ continue;
175
+ }
138
176
  if (s.state === 'fresh' && sch.same_since && sch.checked_at) {
139
- out.push({ id: s.id, name, trouble: 0, why: 'Checked ' + clockOf(sch.checked_at, now) + ' · same since ' + clockOf(sch.same_since, now), when: '', act: null });
177
+ out.push({ id: s.id, name, trouble: 0, why: 'Checked ' + clockOf(sch.checked_at, now) + ' · same since ' + clockOf(sch.same_since, now) + (sch.next_run ? ' · next ' + nextOf(sch.next_run, now) : ''), when: '', act: null, ...(job ? { job } : {}) });
140
178
  continue;
141
179
  }
142
180
  const when = s.state === 'off' ? 'Not connected' : s.state === 'building' ? 'Reading now' : mend ? 'Reading again' : s.state === 'never' ? 'Never read'
143
181
  : s.id === 'repository' && s.state === 'fresh' ? 'Watching' : short(ago(s.as_of, now)) || 'Never read';
144
- const behind = (s.state === 'stale' || s.state === 'never') && s.id !== 'repository' && !mend;
145
- out.push({ id: s.id, name, trouble: 0, why: '', when, act: behind ? read : null });
182
+ // a source PMOS reads on a schedule shows ↻ only when it missed a read (above); one with no next read keeps ↻ while it is behind
183
+ const behind = (s.state === 'stale' || s.state === 'never') && s.id !== 'repository' && !mend && !sch.next_run;
184
+ out.push({ id: s.id, name, trouble: 0, why: line && !mend && s.state !== 'building' ? line.text : '', when, act: behind ? read : null, ...(job ? { job } : {}) });
146
185
  }
147
186
  for (const i of alone) out.push({ id: 'issue:' + i.key, name: i.name || 'Background work', trouble: 3, why: i.why, when: '', act: i.key === 'signedout' ? { kind: 'sec', label: 'Open Settings › PMOS', sec: 'claude' } : null });
148
187
  return out.map((r, k) => ({ r, k })).sort((a, b) => (a.r.trouble || 9) - (b.r.trouble || 9) || a.k - b.k).map((x) => x.r);