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.
- package/package.json +39 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +38 -0
- package/workspace/fixtures/transcript-task-tools.jsonl +5 -0
- package/workspace/guide/agent-capabilities.md +2 -2
- package/workspace/guide/cli.md +1 -1
- package/workspace/guide/notes.md +2 -2
- package/workspace/guide/scheduled-tasks-and-cli.md +3 -1
- package/workspace/guide/settings-and-switches.md +20 -1
- package/workspace/lib/calendar-events.js +5 -1
- package/workspace/lib/goal-chat.js +1 -1
- package/workspace/lib/lab-cli.js +2 -2
- package/workspace/lib/live-round.js +20 -9
- package/workspace/lib/proposals.js +22 -4
- package/workspace/lib/refresh-run.js +23 -9
- package/workspace/lib/refresh.js +64 -19
- package/workspace/lib/routes-briefing-premium.js +1 -1
- package/workspace/lib/routes-lab.js +7 -3
- package/workspace/lib/schedule-cli.js +2 -2
- package/workspace/lib/schedule-logic.js +8 -2
- package/workspace/lib/transcript-steps.js +66 -17
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-ev.css +27 -0
- package/workspace/public/pm/cozy-evmodel.js +45 -6
- package/workspace/public/pm/cozy-schedwork.js +201 -0
- package/workspace/public/pm/cozy-settings.js +12 -4
- package/workspace/public/pm/cozy-vw-mtg.css +3 -0
- package/workspace/public/pm/ini-agent.js +2 -0
- package/workspace/public/pm/ini-props.js +1 -1
- package/workspace/public/pm/ini-view.js +10 -1
- package/workspace/public/pm/premium-vw-doc.css +0 -3
- package/workspace/public/pm/small-vw.js +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/* pm/cozy-schedwork.js — Scheduled work in Settings › Connectors (batch 31 item 2, agreed design SwC, Wawan 2026-11-18 "Build C").
|
|
2
|
+
*
|
|
3
|
+
* The row line under each source (how often · next, amber with ↻ only when a read was missed) is pm/cozy-evmodel.js scheduleLine. This
|
|
4
|
+
* module draws the two panels the rows open, inside the Connectors section (cozy-settings.js T.sub):
|
|
5
|
+
* list "Scheduled work": every source PMOS reads on a schedule, PMOS's own jobs and your own scheduled tasks, each with how
|
|
6
|
+
* often and when it runs next. One quiet entry under the sources opens it (swEntry).
|
|
7
|
+
* job:<id> one source or job (lib/refresh.js id), like the scheduled task page of the Claude app: Active, Next run, Repeats,
|
|
8
|
+
* Working hours only, PMOS's ✦ rhythm proposal (✓ saves it, ✕ hides it for today), History and ▶ Read now.
|
|
9
|
+
* task:<id> one of your scheduled tasks (schedules.json): Active, Next run, Repeats (Every hour is new), last run and ▶ Run now.
|
|
10
|
+
* Reads GET /api/refresh?ws= (lib/routes-refresh.js: rows with next_at, missed_at, propose, runs) and GET /api/schedules?all=1. Writes are
|
|
11
|
+
* the PM's presses: POST /api/refresh/source { id, on | schedule }, /api/refresh/run { id, ws }, /api/schedules/update, /api/schedules/run.
|
|
12
|
+
* PMOS proposes the rhythm; the PM approves it or picks another. Nothing here changes a schedule by itself.
|
|
13
|
+
* swLine(row, now) · repeatOpts(row) · taskLine(s, now) — pure, for the tests. */
|
|
14
|
+
import { pmGet, pmPost } from './http.js';
|
|
15
|
+
import { esc, svg, ICON, toast, wsParam } from './cozy-evui.js';
|
|
16
|
+
import { nextOf, atOf, everyLine } from './cozy-evmodel.js';
|
|
17
|
+
|
|
18
|
+
const CHEV = 'M10 7l5 5-5 5', BACK = 'M15 18l-6-6 6-6', PLAY = 'M8 5l11 7-11 7z', SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', CLOCK = 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 7v5l3 2';
|
|
19
|
+
const S = { rows: null, win: null, tasks: null, err: '', busy: false, from: '', undo: null };
|
|
20
|
+
const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* no storage */ } } };
|
|
21
|
+
const NOPE = (id) => 'pmos.sw.not-now.' + id;
|
|
22
|
+
const today = () => { const d = new Date(); return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate(); };
|
|
23
|
+
const ib = (attrs, label, d, cls = 'ev-ib') => `<button type="button" class="${cls}" ${attrs} aria-label="${esc(label)}" title="${esc(label)}">${svg(d, 18)}</button>`;
|
|
24
|
+
const swc = (on, attrs, label) => `<button type="button" class="ev-sw" role="switch" aria-checked="${!!on}" aria-label="${esc(label)}" ${attrs}>${on ? 'On' : 'Off'}</button>`;
|
|
25
|
+
const at = atOf;
|
|
26
|
+
const kv = (icon, k, v) => `<div class="ev-trow ev-sw-kv"><span class="ev-sw-ic" aria-hidden="true">${svg(icon, 18)}</span><span class="ev-grow">${esc(k)}</span>${v}</div>`;
|
|
27
|
+
|
|
28
|
+
/** The line under a row of the list: "Every 30 min in working hours · next 10:00", "Missed 09:00 · read yesterday", "Off". */
|
|
29
|
+
export function swLine(r, now = Date.now()) {
|
|
30
|
+
if (!r) return { text: '', missed: false };
|
|
31
|
+
if (!r.on) return { text: 'Off', missed: false };
|
|
32
|
+
if (r.missed_at) return { text: 'Missed ' + atOf(r.missed_at, now) + (r.last && r.last.at ? ' · read ' + atOf(r.last.at, now) : ' · never read'), missed: true };
|
|
33
|
+
if (r.state === 'running') return { text: 'Running now', missed: false };
|
|
34
|
+
const nx = r.next_at ? nextOf(r.next_at, now) : '';
|
|
35
|
+
if (!r.schedule_text && r.set_in) return { text: 'Set in ' + r.set_in.replace(/, /, ' › '), missed: false };
|
|
36
|
+
return { text: everyLine(r.schedule_text) + (nx ? ' · next ' + nx : ''), missed: false };
|
|
37
|
+
}
|
|
38
|
+
const EVERY_WORD = { 15: 'Every 15 min', 30: 'Every 30 min', 60: 'Every hour', 120: 'Every 2 hours', 240: 'Every 4 hours' };
|
|
39
|
+
/** The choices of Repeats for a row: [[value, label, selected]]: by the press, every 15 min to 4 hours, every day, working days, once a week.
|
|
40
|
+
* A day-based choice keeps its times (At) and day (On). */
|
|
41
|
+
export function repeatOpts(r) {
|
|
42
|
+
const s = r && r.schedule; if (!s) return [];
|
|
43
|
+
const cur = s.kind === 'every' ? 'every:' + s.every : s.kind;
|
|
44
|
+
const out = [];
|
|
45
|
+
if ((r.kinds || []).includes('manual')) out.push(['manual', 'Only when you press read', cur === 'manual']);
|
|
46
|
+
for (const v of r.every || []) out.push(['every:' + v, EVERY_WORD[v] || 'Every ' + v + ' min', cur === 'every:' + v]);
|
|
47
|
+
if ((r.kinds || []).includes('daily')) for (const [k, l] of [['daily', 'Every day'], ['weekdays', 'Working days'], ['weekly', 'Once a week']]) out.push([k, l, cur === k]);
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
const TASK_CAD = [['hourly', 'Every hour'], ['daily', 'Every day'], ['weekly', 'Every week'], ['bi-weekly', 'Every 2 weeks'], ['monthly', 'Every month']];
|
|
51
|
+
const DAYN = { Mon: 'Monday', Tue: 'Tuesday', Wed: 'Wednesday', Thu: 'Thursday', Fri: 'Friday', Sat: 'Saturday', Sun: 'Sunday' };
|
|
52
|
+
/** Your scheduled task in words: "Every hour at :15 · next 10:15", "Every Friday at 16:00 · next Fri 16:00", "Off". */
|
|
53
|
+
export function taskLine(s, now = Date.now()) {
|
|
54
|
+
if (!s) return '';
|
|
55
|
+
if (s.enabled === false) return 'Off';
|
|
56
|
+
const t = String(s.time || '09:00'), d = DAYN[s.day] || 'Monday';
|
|
57
|
+
const rep = s.cadence === 'hourly' ? 'Every hour at :' + t.slice(-2) : s.cadence === 'daily' ? 'Every day at ' + t : s.cadence === 'weekly' ? 'Every ' + d + ' at ' + t
|
|
58
|
+
: s.cadence === 'bi-weekly' ? 'Every other ' + d + ' at ' + t : s.cadence === 'monthly' ? 'On day ' + (s.dayOfMonth || 1) + ' of each month at ' + t : s.cadence === 'once' ? 'Once, ' + (s.date || '') + ' at ' + t : String(s.cadence || '');
|
|
59
|
+
const nx = s.next ? nextOf(s.next, now) : '';
|
|
60
|
+
return rep + (nx ? ' · next ' + nx : '');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Read the rows and your tasks. `draw` redraws Settings. */
|
|
64
|
+
export async function swLoad(draw) {
|
|
65
|
+
const ws = wsParam() || '';
|
|
66
|
+
const [r, t] = await Promise.all([pmGet('/api/refresh' + (ws ? '?ws=' + encodeURIComponent(ws) : '')), pmGet('/api/schedules?all=1')]);
|
|
67
|
+
S.rows = r && r.ok && Array.isArray(r.rows) ? r.rows : []; S.win = r && r.window ? r.window : null;
|
|
68
|
+
S.tasks = t && Array.isArray(t.schedules) ? t.schedules.filter((x) => !x.endedReason) : [];
|
|
69
|
+
S.err = !r || !r.ok ? 'The schedules could not be read' + (r && r.error ? ': ' + r.error : '') + '.' : '';
|
|
70
|
+
if (draw) draw();
|
|
71
|
+
}
|
|
72
|
+
export const swReset = () => { S.rows = null; S.tasks = null; S.err = ''; S.from = ''; };
|
|
73
|
+
const shown = () => (S.rows || []).filter((r) => r.run !== 'change');
|
|
74
|
+
/** The quiet entry under the sources: "Scheduled work · 9 jobs". */
|
|
75
|
+
export function swEntry() {
|
|
76
|
+
const n = S.rows ? shown().filter((r) => r.on).length + (S.tasks || []).filter((x) => x.enabled !== false).length : null;
|
|
77
|
+
return `<div class="ev-trow ev-fr ev-sw-entry"><span class="ev-gut"></span><span class="ev-sw-ic" aria-hidden="true">${svg(CLOCK, 18)}</span><div class="ev-tx ev-grow"><span>Scheduled work</span>${n != null ? `<p class="ev-small ev-mut">${n} ${n === 1 ? 'job runs' : 'jobs run'} on a schedule</p>` : ''}</div>`
|
|
78
|
+
+ ib('data-ev-sw="list"', 'Open Scheduled work', CHEV) + '</div>';
|
|
79
|
+
}
|
|
80
|
+
const head = (title, back, backLabel) => `<div class="ev-dr-hd">${ib(`data-ev-sw="${esc(back)}"`, backLabel, BACK)}<h4 class="ev-grow">${esc(title)}</h4></div>`;
|
|
81
|
+
|
|
82
|
+
function listHtml(now) {
|
|
83
|
+
const rows = shown();
|
|
84
|
+
const row = (r) => { const l = swLine(r, now); return `<div class="ev-trow ev-fr"><span class="ev-gut">${l.missed ? '<i class="ev-dot risk" aria-hidden="true"></i>' : ''}</span><div class="ev-tx ev-grow"><span>${esc(r.label)}</span><p class="ev-small ${l.missed ? 'ev-late' : 'ev-mut'}">${esc(l.text)}</p></div>${ib(`data-ev-sw="job:${esc(r.id)}" data-ev-sw-from="list"`, 'Open ' + r.label, CHEV)}</div>`; };
|
|
85
|
+
const grp = (label, list) => (list.length ? `<p class="ev-mlbl ev-sw-grp">${esc(label)}</p>` + list.join('') : '');
|
|
86
|
+
const tasks = (S.tasks || []).map((s) => `<div class="ev-trow ev-fr"><span class="ev-gut"></span><div class="ev-tx ev-grow"><span>${esc(s.name || s.skill)}</span><p class="ev-small ev-mut">${esc(taskLine(s, now))}</p></div>${ib(`data-ev-sw="task:${esc(s.id)}"`, 'Open ' + (s.name || s.skill), CHEV)}</div>`);
|
|
87
|
+
return head('Scheduled work', '', 'Back to Connectors')
|
|
88
|
+
+ (S.err ? `<p class="ev-small ev-mut">${esc(S.err)}</p>` : '')
|
|
89
|
+
+ grp('PMOS reads', rows.filter((r) => r.run === 'skill').map(row))
|
|
90
|
+
+ grp('PMOS’s own jobs', rows.filter((r) => r.run === 'job').map(row))
|
|
91
|
+
+ grp('Your scheduled tasks', tasks)
|
|
92
|
+
+ (S.tasks && !S.tasks.length ? '<p class="ev-small ev-mut">You have no scheduled tasks of your own.</p>' : '');
|
|
93
|
+
}
|
|
94
|
+
const RESULT = { done: 'done', failed: 'failed', skipped: 'skipped', interrupted: 'stopped', running: 'running' };
|
|
95
|
+
function jobHtml(r, now) {
|
|
96
|
+
const back = S.from === 'list' ? 'list' : '', backLabel = S.from === 'list' ? 'Back to Scheduled work' : 'Back to Connectors';
|
|
97
|
+
if (!r) return head('Scheduled work', back, backLabel) + '<p class="ev-small ev-mut">This job could not be read.</p>';
|
|
98
|
+
const s = r.schedule, skip = r.missed_at ? (r.runs || []).find((x) => x.result === 'skipped' && Date.parse(x.start_at) >= Date.parse(r.missed_at)) : null;
|
|
99
|
+
const warn = r.missed_at ? `<div class="ev-warn ev-line ev-sw-warn"><i class="ev-dot risk" aria-hidden="true"></i><p class="ev-grow">${esc((r.last && r.last.at ? 'Last read ' + at(r.last.at, now) + '. ' : 'Never read. ') + 'PMOS missed ' + atOf(r.missed_at, now) + (skip && skip.note ? ': ' + skip.note + '.' : ', because PMOS was not running then or your computer slept.'))}</p></div>` : '';
|
|
100
|
+
const opts = repeatOpts(r);
|
|
101
|
+
const rep = opts.length ? `<label class="ev-vh" for="evSwRep">Repeats</label><select id="evSwRep" class="ev-inp" data-ev-sw-rep="${esc(r.id)}"${S.busy ? ' disabled' : ''}>${opts.map(([v, l, on]) => `<option value="${esc(v)}"${on ? ' selected' : ''}>${esc(l)}</option>`).join('')}</select>`
|
|
102
|
+
: `<span class="ev-small ev-mut">${esc(everyLine(r.schedule_text) || 'Not set here')}</span>`;
|
|
103
|
+
const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
104
|
+
const times = s && ['daily', 'weekdays', 'weekly'].includes(s.kind) ? kv(CLOCK, 'At', `<label class="ev-vh" for="evSwAt">At</label><input id="evSwAt" class="ev-inp ev-sw-at" type="time" value="${esc((s.times || ['09:00'])[0])}" data-ev-sw-at="${esc(r.id)}">`)
|
|
105
|
+
+ (s.kind === 'weekly' ? kv(ICON.cal, 'On', `<label class="ev-vh" for="evSwDay">On</label><select id="evSwDay" class="ev-inp" data-ev-sw-day="${esc(r.id)}">${DAYS.map((d) => `<option value="${d}"${s.day === d ? ' selected' : ''}>${esc(DAYN[d])}</option>`).join('')}</select>`) : '')
|
|
106
|
+
+ ((s.times || []).length > 1 ? `<p class="ev-small ev-mut ev-sw-more">Also at ${esc(s.times.slice(1).join(' and '))}.</p>` : '') : '';
|
|
107
|
+
const work = s && s.kind === 'every' && r.run === 'skill' ? kv(CLOCK, 'Working hours only' + (S.win ? ' (' + S.win.start + ' to ' + S.win.end + ')' : ''), swc(s.work, `data-ev-sw-work="${esc(r.id)}"`, 'Working hours only')) : '';
|
|
108
|
+
const nx = !r.on ? 'Off' : r.missed_at ? 'Now, when you press ▶' : r.state === 'running' ? 'Running now' : r.next_at ? nextOf(r.next_at, now) : r.run === 'skill' ? 'Only when you press' : everyLine(r.schedule_text) || '—';
|
|
109
|
+
const p = r.propose && store.get(NOPE(r.id)) !== today() ? r.propose : null;
|
|
110
|
+
const span = p && p.s.work && S.win ? ' from ' + S.win.start + ' to ' + S.win.end : '';
|
|
111
|
+
const prop = p ? `<div class="ev-card ev-sw-prop"><span class="ev-av sp" aria-hidden="true">${svg(SPARK, 15)}</span><div class="ev-grow"><b>Read it more often on meeting days</b><p class="ev-small">Every ${esc(p.every)} min${esc(span)} on days with ${p.meetings} or more meetings. Today has ${p.today}. Other days stay at ${esc(EVERY_WORD[p.s.every] ? EVERY_WORD[p.s.every].replace(/^Every /, '') : p.s.every + ' min')}.</p></div>`
|
|
112
|
+
+ ib(`data-ev-sw-nope="${esc(r.id)}"`, 'Not now', ICON.close) + ib(`data-ev-sw-yes="${esc(r.id)}"`, 'Use this', ICON.check, 'ev-ib ev-jl-pri') + '</div>' : '';
|
|
113
|
+
const runs = (r.runs || []).slice(0, 5).map((x) => `<div class="ev-sw-h"><span>${esc(at(x.start_at, now))}</span><span class="ev-mut">${esc([RESULT[x.result] || x.result || '', x.took_ms != null ? Math.max(1, Math.round(x.took_ms / 60000)) + ' min' : '', x.note || x.error || x.got || ''].filter(Boolean).join(' · '))}</span></div>`).join('');
|
|
114
|
+
const canRun = r.run === 'skill' || r.run === 'job';
|
|
115
|
+
return head(r.label, back, backLabel) + `<p class="ev-small ev-mut ev-sw-what">${esc(r.what || '')}</p>` + warn
|
|
116
|
+
+ `<div class="ev-sw-card">${kv(CLOCK, 'Active', swc(r.on, `data-ev-sw-on="${esc(r.id)}"`, r.label + ': active'))}${kv(ICON.cal, 'Next run', `<span class="ev-small ev-mut">${esc(nx)}</span>`)}${kv(ICON.refresh, 'Repeats', rep)}${times}${work}</div>`
|
|
117
|
+
+ (S.undo && S.undo.id === r.id ? `<div class="ev-trow ev-sw-undo"><p class="ev-small ev-grow">Saved. PMOS reads it more often on meeting days.</p><button type="button" class="ev-btn sm" data-ev-sw-undo="${esc(r.id)}">Undo</button></div>` : '')
|
|
118
|
+
+ prop
|
|
119
|
+
+ `<p class="ev-mlbl ev-sw-grp">History</p>` + (runs ? `<div class="ev-sw-hist">${runs}</div>` : '<p class="ev-small ev-mut">No runs yet.</p>')
|
|
120
|
+
+ (canRun ? `<div class="ev-sw-run">${ib(`data-ev-sw-run="${esc(r.id)}"`, r.run === 'skill' ? 'Read now' : 'Run now', PLAY, 'ev-ib ev-sw-play')}</div>` : '');
|
|
121
|
+
}
|
|
122
|
+
function taskHtml(s, now) {
|
|
123
|
+
if (!s) return head('Scheduled work', 'list', 'Back to Scheduled work') + '<p class="ev-small ev-mut">This task could not be read.</p>';
|
|
124
|
+
const cad = TASK_CAD.some(([v]) => v === s.cadence) ? TASK_CAD : TASK_CAD.concat([[s.cadence, s.cadence === 'once' ? 'Once' : s.cadence]]);
|
|
125
|
+
const rep = `<label class="ev-vh" for="evSwTask">Repeats</label><select id="evSwTask" class="ev-inp" data-ev-sw-cad="${esc(s.id)}"${S.busy ? ' disabled' : ''}>${cad.map(([v, l]) => `<option value="${esc(v)}"${v === s.cadence ? ' selected' : ''}>${esc(l)}</option>`).join('')}</select>`;
|
|
126
|
+
const nx = s.enabled === false ? 'Off' : s.next ? nextOf(s.next, now) : 'Not scheduled';
|
|
127
|
+
const last = s.lastRun ? at(s.lastRun, now) + ({ ok: ' · finished', fail: ' · did not finish', started: ' · started' }[s.lastStatus] || '') : '';
|
|
128
|
+
return head(s.name || s.skill, 'list', 'Back to Scheduled work') + `<p class="ev-small ev-mut ev-sw-what">${esc(taskLine({ ...s, next: null }, now))}. It runs ${esc(s.skill || s.task || '')}.</p>`
|
|
129
|
+
+ `<div class="ev-sw-card">${kv(CLOCK, 'Active', swc(s.enabled !== false, `data-ev-sw-ton="${esc(s.id)}"`, (s.name || s.skill) + ': active'))}${kv(ICON.cal, 'Next run', `<span class="ev-small ev-mut">${esc(nx)}</span>`)}${kv(ICON.refresh, 'Repeats', rep)}</div>`
|
|
130
|
+
+ `<p class="ev-mlbl ev-sw-grp">History</p>` + (last ? `<div class="ev-sw-hist"><div class="ev-sw-h"><span>${esc(last)}</span></div></div>` : '<p class="ev-small ev-mut">No runs yet.</p>')
|
|
131
|
+
+ `<div class="ev-sw-run">${ib(`data-ev-sw-trun="${esc(s.id)}"`, 'Run now', PLAY, 'ev-ib ev-sw-play')}</div>`;
|
|
132
|
+
}
|
|
133
|
+
/** The panel for `sub` ('sw:list', 'sw:job:<id>', 'sw:task:<id>'). */
|
|
134
|
+
export function swBody(sub) {
|
|
135
|
+
const k = String(sub || '').slice(3), now = Date.now();
|
|
136
|
+
if (S.rows === null) return head('Scheduled work', k === 'list' ? '' : 'list', 'Back') + '<p class="ev-small ev-mut">Reading the schedules.</p>';
|
|
137
|
+
if (k === 'list') return listHtml(now);
|
|
138
|
+
if (k.startsWith('job:')) return jobHtml(S.rows.find((r) => r.id === k.slice(4)), now);
|
|
139
|
+
if (k.startsWith('task:')) return taskHtml((S.tasks || []).find((x) => x.id === k.slice(5)), now);
|
|
140
|
+
return '';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const said = (r, ok) => (r && r.ok ? ok : 'Not saved: ' + ((r && r.error) || 'the server did not answer') + '.');
|
|
144
|
+
/** A press inside Scheduled work. → true when it was one. `go(sub)` opens a panel ('' goes back to Connectors); `say(text)` the status line. */
|
|
145
|
+
export async function swPress(t, { go, say, draw }) {
|
|
146
|
+
const d = t.dataset;
|
|
147
|
+
if (d.evSw !== undefined) {
|
|
148
|
+
const k = d.evSw;
|
|
149
|
+
if (k === 'list' || k === '') S.from = '';
|
|
150
|
+
else S.from = d.evSwFrom || '';
|
|
151
|
+
go(k ? 'sw:' + k : '');
|
|
152
|
+
if (k && S.rows === null) swLoad(draw);
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
const id = d.evSwOn || d.evSwWork || d.evSwYes || d.evSwNope || d.evSwRun || d.evSwTon || d.evSwTrun || d.evSwUndo;
|
|
156
|
+
if (!id) return false;
|
|
157
|
+
if (d.evSwNope) { store.set(NOPE(id), today()); say('Hidden for today. PMOS keeps the rhythm you have.'); draw(); return true; }
|
|
158
|
+
if (S.busy) return true;
|
|
159
|
+
S.busy = true;
|
|
160
|
+
try {
|
|
161
|
+
const r = (S.rows || []).find((x) => x.id === id);
|
|
162
|
+
if (d.evSwOn && r) { const on = !r.on, x = await pmPost('/api/refresh/source', { id, on }); say(said(x, on ? r.label + ' is on.' : r.label + ' is off. PMOS does not run it on its own.')); }
|
|
163
|
+
else if (d.evSwWork && r) { const x = await pmPost('/api/refresh/source', { id, schedule: { ...r.schedule, work: !r.schedule.work } }); say(said(x, r.schedule.work ? 'Saved. It runs all day.' : 'Saved. It runs in working hours only.')); }
|
|
164
|
+
else if (d.evSwYes && r && r.propose) { const old = r.schedule, x = await pmPost('/api/refresh/source', { id, schedule: r.propose.s }); if (x && x.ok) S.undo = { id, s: old }; say(said(x, 'Saved. PMOS reads ' + r.label + ' every ' + r.propose.every + ' min on meeting days.')); }
|
|
165
|
+
else if (d.evSwUndo && S.undo && S.undo.id === id) { const x = await pmPost('/api/refresh/source', { id, schedule: S.undo.s }); if (x && x.ok) S.undo = null; say(said(x, 'Undone. The rhythm is as it was.')); }
|
|
166
|
+
else if (d.evSwRun && r) { const x = await pmPost('/api/refresh/run', { id, ws: wsParam() || undefined }); say(x && x.ok ? (x.waiting ? 'It starts once ' + x.waiting.join(', ') + ' finish.' : 'Started. ' + r.label + ' runs now.') : 'It did not start: ' + ((x && x.error) || 'the server did not answer') + '.'); if (x && x.ok) toast('Started.'); }
|
|
167
|
+
else if (d.evSwTon) { const s = (S.tasks || []).find((y) => y.id === id); if (s) { const on = s.enabled === false, x = await pmPost('/api/schedules/update', { id, enabled: on }); say(said(x, on ? 'It runs on its schedule again.' : 'It is off.')); } }
|
|
168
|
+
else if (d.evSwTrun) { const x = await pmPost('/api/schedules/run', { id }); say(x && x.ok !== false ? 'Started.' : 'It did not start: ' + ((x && x.error) || 'the server did not answer') + '.'); }
|
|
169
|
+
} finally { S.busy = false; }
|
|
170
|
+
await swLoad(draw);
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
/** A change of Repeats. → true when it was one. */
|
|
174
|
+
export async function swChange(x, { say, draw }) {
|
|
175
|
+
const id = x.dataset.evSwRep || x.dataset.evSwCad || x.dataset.evSwAt || x.dataset.evSwDay;
|
|
176
|
+
if (!id) return false;
|
|
177
|
+
if (S.busy) return true;
|
|
178
|
+
S.busy = true;
|
|
179
|
+
try {
|
|
180
|
+
if (x.dataset.evSwRep) {
|
|
181
|
+
const r = (S.rows || []).find((y) => y.id === id); if (!r) return true;
|
|
182
|
+
const v = x.value, cur = r.schedule || {}, times = cur.times && cur.times.length ? cur.times : ['09:00'];
|
|
183
|
+
let sch;
|
|
184
|
+
if (x.dataset.evSwAt) { if (!/^\d\d:\d\d$/.test(v)) return true; sch = { ...cur, times: [v, ...times.slice(1).filter((y) => y !== v)] }; }
|
|
185
|
+
else if (x.dataset.evSwDay) sch = { ...cur, day: v };
|
|
186
|
+
else if (v === 'manual') sch = { kind: 'manual' };
|
|
187
|
+
else if (v.startsWith('every:')) sch = { kind: 'every', every: v.slice(6), work: cur.kind === 'every' ? !!cur.work : true, ...(cur.busy ? { busy: cur.busy } : {}) };
|
|
188
|
+
else sch = { kind: v, times: v === 'weekly' ? times.slice(0, 1) : times, ...(v === 'weekly' ? { day: cur.day || 'Mon' } : {}) };
|
|
189
|
+
const res = await pmPost('/api/refresh/source', { id, schedule: sch });
|
|
190
|
+
await swLoad();
|
|
191
|
+
const nr = (S.rows || []).find((y) => y.id === id);
|
|
192
|
+
say(said(res, 'Saved. ' + r.label + ': ' + (nr ? everyLine(nr.schedule_text).toLowerCase() : 'saved') + '.'));
|
|
193
|
+
} else {
|
|
194
|
+
const s = (S.tasks || []).find((y) => y.id === id); if (!s) return true;
|
|
195
|
+
const res = await pmPost('/api/schedules/update', { id, cadence: x.value });
|
|
196
|
+
say(said(res, 'Saved. ' + (TASK_CAD.find(([v]) => v === x.value) || [0, x.value])[1] + '.'));
|
|
197
|
+
}
|
|
198
|
+
} finally { S.busy = false; }
|
|
199
|
+
await swLoad(draw);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
* where a measured read applies (SrSee R3). Claude's failed background work and the Git sync failure are rows too. ↻ in the
|
|
24
24
|
* header reads every source (POST /api/sources/refresh-all); (i) says what PMOS reads and that it never posts. The switches
|
|
25
25
|
* (what PMOS reads on its own, the connectors your sessions have; GET and POST /api/proactive/settings) fold into one row.
|
|
26
|
+
* Scheduled work (batch 31 item 2, agreed design SwC): a scheduled source's line says how often and when it reads next, amber
|
|
27
|
+
* with ↻ only when PMOS missed a read; › on the row opens its page (Active, Next run, Repeats, ✦ rhythm, History, ▶ Read now),
|
|
28
|
+
* and one quiet entry opens the Scheduled work list, your own scheduled tasks too (pm/cozy-schedwork.js; T.sub 'sw:…').
|
|
26
29
|
* Workspaces the repositories PMOS works in (GET and POST /api/workspaces, POST /api/workspaces/forget; the folder is never touched),
|
|
27
30
|
* then the row "Workflows ›" (U4; it was a section of its own that linked out): the stages each kind of initiative goes
|
|
28
31
|
* through (pm/wf-page.js, D99). It opens as a sub-panel here, the Settings dialog widened to the window (UI grill U1: the
|
|
@@ -46,6 +49,7 @@ import * as JL from './cozy-jl.js';
|
|
|
46
49
|
import { pmGet, pmPost, pressFetch } from './http.js';
|
|
47
50
|
import { esc, svg, ICON, toast, wsParam, wsQ } from './cozy-evui.js';
|
|
48
51
|
import { connectorRows, bannerOf } from './cozy-evmodel.js';
|
|
52
|
+
import * as SW from './cozy-schedwork.js';
|
|
49
53
|
import * as AD from './cozy-adler.js';
|
|
50
54
|
import * as SE from './cozy-seasons.js';
|
|
51
55
|
import { weeksOf, lineOf, storiesOf } from './upd-weeks.js';
|
|
@@ -203,8 +207,8 @@ function readsHtml() {
|
|
|
203
207
|
// one list, trouble first (CnA): the amber dot, the one reason and the one action on a trouble row; the name and the time on a quiet one
|
|
204
208
|
const rows = connectorRows(s.sources, s.health).map((x) => `<div class="ev-trow ev-fr${x.trouble ? ' ev-fr-t' : ''}" data-src="${esc(x.id)}"><span class="ev-gut">${x.trouble ? '<i class="ev-dot risk" aria-hidden="true"></i>' : ''}</span>`
|
|
205
209
|
+ `<div class="ev-tx ev-grow">${x.trouble ? `<b>${esc(x.name)}</b>` : `<span>${esc(x.name)}</span>`}${x.why ? `<p class="ev-small ev-why ${x.trouble ? 'ev-late' : 'ev-mut'}">${x.trouble ? '<span class="ev-vh">Needs a look: </span>' : ''}${esc(x.why)}</p>` : ''}${T.note[x.id] ? `<p class="ev-small" role="status">${esc(T.note[x.id])}</p>` : ''}</div>`
|
|
206
|
-
+ `${x.when ? `<span class="ev-small ev-mut">${esc(x.when)}</span>` : ''}${act(x)}</div>`).join('');
|
|
207
|
-
return `<div class="ev-reads">${rows}</div
|
|
210
|
+
+ `${x.when ? `<span class="ev-small ev-mut">${esc(x.when)}</span>` : ''}${act(x)}${x.job ? `<button type="button" class="ev-ib" data-ev-sw="job:${esc(x.job)}" aria-label="${esc('Open ' + x.name + ': how often and when it runs next')}" title="How often and when it runs next">${svg(CHEV, 18)}</button>` : ''}</div>`).join('');
|
|
211
|
+
return `<div class="ev-reads">${rows}</div>` + SW.swEntry();
|
|
208
212
|
}
|
|
209
213
|
/** The amber box at the top of Settings, only when the PM must act on a source (self-heal, feedback batch 26 item 7). While Claude
|
|
210
214
|
* reads a source again by itself, or after it did, there is no box. The box names the one action and links to the exact place:
|
|
@@ -219,6 +223,7 @@ function staleHtml() {
|
|
|
219
223
|
}
|
|
220
224
|
const INFO = 'PMOS reads these sources and never posts to them. A switch chooses only what PMOS reads on its own; your Claude sessions can use every connector.';
|
|
221
225
|
function connectors() {
|
|
226
|
+
if (T.sub && T.sub.startsWith('sw:')) return SW.swBody(T.sub);
|
|
222
227
|
const info = T.info ? `<p class="ev-small ev-mut ev-info" id="evConInfo">${esc(INFO)}</p>` : '';
|
|
223
228
|
if (T.src === null) return info + readsHtml() + '<p class="ev-small ev-mut">Reading the connectors.</p>';
|
|
224
229
|
const brief = Object.keys(SRC).filter((k) => k in T.src).map((k) => [SRC[k], trow(SRC[k], T.src[k] ? 'PMOS reads it on its own' : 'PMOS does not read it on its own', sw(T.src[k], `data-ev-src="${k}"`, SRC[k]))]);
|
|
@@ -388,7 +393,7 @@ function checksSec() {
|
|
|
388
393
|
}
|
|
389
394
|
const BODY = { general, claude: claudeSec, connectors, workspaces, updates };
|
|
390
395
|
// the old section names (deep links, other pages' calls): where their controls are now (U4)
|
|
391
|
-
const MOVED = { checks: ['claude', ''], adler: ['general', 'adler'], jl: ['general', 'jl'], dress: ['general', 'adler'], workflows: ['workspaces', 'workflows'] };
|
|
396
|
+
const MOVED = { scheduled: ['connectors', 'sw:list'], checks: ['claude', ''], adler: ['general', 'adler'], jl: ['general', 'jl'], dress: ['general', 'adler'], workflows: ['workspaces', 'workflows'] };
|
|
392
397
|
let disposeClaudeSetup = null;
|
|
393
398
|
function draw() {
|
|
394
399
|
const el = T.el; if (!el || el.hidden) return;
|
|
@@ -447,6 +452,7 @@ function mount() {
|
|
|
447
452
|
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && T.el && !T.el.hidden && !T.el.contains(e.target) && !(e.target.closest && e.target.closest('.wf-menu'))) { e.preventDefault(); e.stopPropagation(); if (!vwFirst()) closeSettings(); } }, true);
|
|
448
453
|
T.el.addEventListener('change', async (e) => {
|
|
449
454
|
const x = e.target;
|
|
455
|
+
if (await SW.swChange(x, { say: (m) => { T.msg = m; }, draw })) return;
|
|
450
456
|
if (x.matches('[data-ev-prof]')) {
|
|
451
457
|
const r = await pmPost('/api/profiles/prefer', { agent: 'claude', profile: x.value || null });
|
|
452
458
|
if (r && r.ok) { T.cl = { ...T.cl, prefs: { ...((T.cl && T.cl.prefs) || {}) } }; if (x.value) T.cl.prefs.claude = x.value; else delete T.cl.prefs.claude; }
|
|
@@ -524,6 +530,7 @@ async function press(e) {
|
|
|
524
530
|
draw(); return;
|
|
525
531
|
}
|
|
526
532
|
if (await JL.press(t, draw, (m) => { T.msg = m; })) return;
|
|
533
|
+
if (await SW.swPress(t, { go: (k) => { T.sub = k; T.msg = ''; draw(); const f = T.el.querySelector('.ev-dr-hd .ev-ib') || T.el.querySelector('[data-ev-sw="list"]'); if (f) f.focus(); }, say: (m) => { T.msg = m; }, draw })) return;
|
|
527
534
|
if (t.dataset.evRead || 'evReadall' in t.dataset) { readAgain(t.dataset.evRead || ''); return; }
|
|
528
535
|
if (T.busy) return;
|
|
529
536
|
T.busy = true; T.msg = '';
|
|
@@ -603,6 +610,7 @@ async function readAgain(id) {
|
|
|
603
610
|
}
|
|
604
611
|
async function load() {
|
|
605
612
|
readFresh();
|
|
613
|
+
SW.swLoad(draw);
|
|
606
614
|
pmGet('/api/autonomy/kinds').then((k) => { T.ck = k && k.ok ? k : { ok: false, error: (k && k.error) || '' }; draw(); }).catch(() => { T.ck = { ok: false }; draw(); });
|
|
607
615
|
pmGet('/api/artefacts/lessons').then((l) => { T.ls = l && l.ok ? l : null; draw(); }).catch(() => { T.ls = null; });
|
|
608
616
|
pmGet('/api/grill').then((g) => { T.gr = g && g.ok ? g : { ok: false, error: (g && g.error) || '' }; draw(); }).catch(() => { T.gr = { ok: false }; draw(); });
|
|
@@ -631,7 +639,7 @@ export function openSettings(section, o = {}) {
|
|
|
631
639
|
const m = MOVED[section];
|
|
632
640
|
if (m) { T.sec = m[0]; T.sub = m[1]; T.dress = section === 'dress'; } else if (section && BODY[section]) { T.sec = section; T.sub = ''; T.dress = false; }
|
|
633
641
|
else if (el.hidden) { T.sec = 'general'; T.sub = ''; T.dress = false; } // a fresh open with no section opens on General (R2), not on the section of the last visit
|
|
634
|
-
if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.auto = false; T.wkOpen = new Set(); T.wkMore = new Set(); T.arc = false; T.fresh = null; T.note = {}; T.info = false; T.fold = false; T.dset = {}; T.cl = null; T.gr = null; T.np = null; T.ck = null; T.ls = null; JL.reset(); }
|
|
642
|
+
if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.auto = false; T.wkOpen = new Set(); T.wkMore = new Set(); T.arc = false; T.fresh = null; T.note = {}; T.info = false; T.fold = false; T.dset = {}; T.cl = null; T.gr = null; T.np = null; T.ck = null; T.ls = null; JL.reset(); SW.swReset(); }
|
|
635
643
|
el.hidden = false; document.getElementById('evStScrim').hidden = false; el.setAttribute('data-esc-layer', '');
|
|
636
644
|
draw();
|
|
637
645
|
const f = el.querySelector('[aria-current="page"]'); if (f) f.focus();
|
|
@@ -530,3 +530,6 @@
|
|
|
530
530
|
.vzc-seg > button, .vzc-chips .vzm-chip { position: relative; overflow: visible; }
|
|
531
531
|
.vzc-seg > button::before, .vzc-chips .vzm-chip::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }
|
|
532
532
|
}
|
|
533
|
+
/* the meeting share popover (shareable-meeting-notes): on a cozy page that does not load premium.css or cozy-viewer.css (premium-viewer.html), it names the cozy tokens itself. It lives here, not in premium-vw-doc.css, because the console type check (premium-console-type S1) would turn --sans and --mono back to the console fonts */
|
|
534
|
+
.cz-vw-hd > .vwshp{--hair:var(--cz-hair);--ink:var(--cz-ink);--ink-2:var(--cz-ink2);--ink-3:var(--cz-ink3);--ember:var(--cz-blue);--card:var(--cz-card);--card-solid:var(--cz-card);
|
|
535
|
+
--well:var(--cz-well);--ok:var(--cz-ok);--bad:var(--cz-red);--sans:var(--cz-sans);--mono:var(--cz-mono);--card-shadow:var(--cz-lift);border-radius:18px;padding:10px;max-height:calc(100dvh - 140px);overflow:auto}
|
|
@@ -83,6 +83,8 @@ const carried = (a, f) => ((a && a.carried) || []).filter((c) => c.field === f &
|
|
|
83
83
|
* the compare view (lab: the round's id), so a round kept or closed too early stays reachable (2026-11-17). Without one, the artefact's words. */
|
|
84
84
|
function specimensRow(kept, tries, rounds) {
|
|
85
85
|
const R = Array.isArray(rounds) && rounds.length ? rounds[0] : null;
|
|
86
|
+
// the initiative's prototype (2026-11-18: the line said "kept" for an old test round): its version, and it opens that version
|
|
87
|
+
if (R && R.current) return { key: 'specimens', label: 'Prototype', text: 'Version ' + R.current.n + (R.current.said ? ': ' + R.current.said : '') + (R.working ? ' · the next version is on the way' : ''), by: '', at: R.at || '', edit: null, lab: R.current.version || R.id };
|
|
86
88
|
if (R && (R.keys.length || R.working)) {
|
|
87
89
|
const made = R.keys.length ? R.keys.join(', ') + (R.keys.length === 1 ? ' is made' : ' are made') : 'none made yet';
|
|
88
90
|
const n = rounds.length > 1 ? rounds.length + ' rounds' : R.rounds > 1 ? R.rounds + ' rounds' : 'Round 1';
|
|
@@ -94,7 +94,7 @@ export function lookHtml(v) {
|
|
|
94
94
|
}
|
|
95
95
|
export function foundDocs(v) {
|
|
96
96
|
const f = v && v.found;
|
|
97
|
-
return f && f.docs ? f.docs.map((d) => ({ title: d.title, meta: [d.source, md(d.at)].filter(Boolean).join(' · '), ref: d.ref || '' })) : [];
|
|
97
|
+
return f && f.docs ? f.docs.map((d) => ({ title: d.title, meta: [d.source, md(d.at)].filter(Boolean).join(' · '), ref: d.ref || '', kind: d.kind || '', round: d.round || '' })) : [];
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/* ── the Viewer ── */
|
|
@@ -389,7 +389,16 @@ function openIn(sec) {
|
|
|
389
389
|
function foldsHtml(v, o) {
|
|
390
390
|
const rows = [];
|
|
391
391
|
// the documents a ✓ kept from elsewhere (batch 12 item 4) list inline under Documents, each with its source and date
|
|
392
|
-
const
|
|
392
|
+
const all = PP.foundDocs(v);
|
|
393
|
+
// the initiative's prototype has its own fold, first (Wawan 2026-11-18: "the prototype under the Prototype and Design section so the
|
|
394
|
+
// workspace always refers to the correct one"): ONE entry, the current version (lib/proposals.js currentOf); it opens the Viewer.
|
|
395
|
+
// Older versions live in the Viewer's ‹ ›, never as documents.
|
|
396
|
+
const proto = all.filter((d) => d.kind === 'prototype' && d.round), fd = all.filter((d) => !(d.kind === 'prototype' && d.round));
|
|
397
|
+
if (proto.length) {
|
|
398
|
+
const op = isOpen(v, 'proto', true);
|
|
399
|
+
rows.push(`<button type="button" class="iv-fr" data-iv-fold="proto" aria-expanded="${op}"><b>Prototype & design</b><span class="n">${proto.length}</span>${chev(op)}</button>`
|
|
400
|
+
+ (op ? `<div class="iv-fb"><div class="iv-fds">${proto.map((d) => `<button type="button" class="iv-fd" data-ia-lab="${esc(d.round)}" title="Open it in the Viewer"><b>${esc(d.title)}</b>${d.meta ? `<small>${esc(d.meta)}</small>` : ''}</button>`).join('')}</div></div>` : ''));
|
|
401
|
+
}
|
|
393
402
|
const fdHtml = fd.map((d) => (/^https?:\/\//.test(d.ref) ? `<a class="iv-fd" href="${esc(d.ref)}" target="_blank" rel="noopener">` : '<span class="iv-fd">') + `<b>${esc(d.title)}</b>${d.meta ? `<small>${esc(d.meta)}</small>` : ''}` + (/^https?:\/\//.test(d.ref) ? '</a>' : '</span>')).join('');
|
|
394
403
|
if ((o.docs && o.docs.n) || fd.length) {
|
|
395
404
|
const n = ((o.docs && o.docs.n) || 0) + fd.length, inl = !!(o.docs && o.docs.html) || fd.length > 0;
|
|
@@ -231,9 +231,6 @@ iframe.vwprint{position:fixed;right:0;bottom:0;width:1px;height:1px;border:0;opa
|
|
|
231
231
|
@media (prefers-reduced-motion:reduce){.vwsw::after{transition:none}}
|
|
232
232
|
/* a meeting's share popover (shareable-meeting-notes, design A plus the follow-up draft, Exploring 2): under the share icon beside ⋯ */
|
|
233
233
|
.cz-vw-hd:has(> .vwshp){position:relative}.cz-vw-hd > .vwshp{top:calc(100% + 2px);right:8px}
|
|
234
|
-
/* on a cozy page that does not load premium.css or cozy-viewer.css (premium-viewer.html), the popover names the cozy tokens itself */
|
|
235
|
-
.cz-vw-hd > .vwshp{--hair:var(--cz-hair);--ink:var(--cz-ink);--ink-2:var(--cz-ink2);--ink-3:var(--cz-ink3);--ember:var(--cz-blue);--card:var(--cz-card);--card-solid:var(--cz-card);
|
|
236
|
-
--well:var(--cz-well);--ok:var(--cz-ok);--bad:var(--cz-red);--sans:var(--cz-sans);--mono:var(--cz-mono);--card-shadow:var(--cz-lift);border-radius:18px;padding:10px;max-height:calc(100dvh - 140px);overflow:auto}
|
|
237
234
|
.vwshp:has(.vwmc){width:380px;max-width:min(380px,calc(100vw - 32px))}
|
|
238
235
|
.vwmc{display:flex;flex-wrap:wrap;gap:6px;padding:4px 8px}
|
|
239
236
|
.vwmchip,.vwmout{display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 12px;border-radius:999px;border:1px solid var(--hair);background:var(--card-solid);color:var(--ink);font:var(--fw-regular) var(--fs-body)/1.2 var(--sans);cursor:pointer}
|
|
@@ -90,6 +90,7 @@ export function repeatsOf(s) {
|
|
|
90
90
|
const t = /^\d{1,2}:\d{2}$/.test(String(s.time || '')) ? String(s.time).padStart(5, '0') : '';
|
|
91
91
|
const at = t ? ' at ' + t : '';
|
|
92
92
|
const day = DAYS[s.day] || 'Monday';
|
|
93
|
+
if (s.cadence === 'hourly') return 'Every hour' + (t ? ' at :' + t.slice(-2) : '');
|
|
93
94
|
if (s.cadence === 'daily') return 'Every day' + at;
|
|
94
95
|
if (s.cadence === 'weekly') return 'Every ' + day + at;
|
|
95
96
|
if (s.cadence === 'bi-weekly') return 'Every other ' + day + at;
|