create-pmos 0.610.0 → 0.612.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 (164) hide show
  1. package/package.json +135 -27
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/board-columns-test.js +2 -1
  8. package/workspace/board-deliveries-test.js +2 -1
  9. package/workspace/board-programs-test.js +7 -3
  10. package/workspace/board-publish-ui-test.js +2 -1
  11. package/workspace/board-shared-ui-test.js +2 -1
  12. package/workspace/board-workflows-test.js +2 -1
  13. package/workspace/briefing-premium-board-test.js +3 -2
  14. package/workspace/briefing-premium-calendar-2-test.js +3 -2
  15. package/workspace/briefing-premium-calendar-3-test.js +1 -1
  16. package/workspace/briefing-premium-calendar-test.js +1 -1
  17. package/workspace/briefing-premium-doc-edit-test.js +2 -1
  18. package/workspace/briefing-premium-insights-test.js +4 -3
  19. package/workspace/briefing-premium-test.js +3 -2
  20. package/workspace/calm-timeline-test.js +2 -1
  21. package/workspace/changelog.json +134 -0
  22. package/workspace/core-docs-workflow-test.js +2 -1
  23. package/workspace/ev-everywhere-test.js +3 -2
  24. package/workspace/guide/home.md +2 -2
  25. package/workspace/guide/index.md +4 -0
  26. package/workspace/guide/layout.md +97 -3
  27. package/workspace/guide/programs.md +16 -2
  28. package/workspace/guide/routine.md +65 -0
  29. package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
  30. package/workspace/guide/settings-and-switches.md +2 -2
  31. package/workspace/impact-screens-test.js +3 -1
  32. package/workspace/ini-workflow-test.js +2 -1
  33. package/workspace/lib/board-premium.js +12 -4
  34. package/workspace/lib/classic-board.js +15 -0
  35. package/workspace/lib/cos-chat.js +1 -0
  36. package/workspace/lib/doc-library.js +43 -12
  37. package/workspace/lib/doc-path.js +30 -0
  38. package/workspace/lib/engine/boards.js +4 -2
  39. package/workspace/lib/events-place.js +368 -0
  40. package/workspace/lib/events-stated.js +129 -0
  41. package/workspace/lib/initiative-chat.js +1 -0
  42. package/workspace/lib/insights-premium.js +13 -1
  43. package/workspace/lib/library-find.js +162 -0
  44. package/workspace/lib/library-items.js +250 -0
  45. package/workspace/lib/notes.js +9 -1
  46. package/workspace/lib/plan-items.js +17 -3
  47. package/workspace/lib/route-modules.js +4 -0
  48. package/workspace/lib/routes-artefacts.js +5 -2
  49. package/workspace/lib/routes-boards.js +6 -2
  50. package/workspace/lib/routes-doc-sheet.js +1 -0
  51. package/workspace/lib/routes-events-place.js +203 -0
  52. package/workspace/lib/routes-library.js +155 -0
  53. package/workspace/lib/routes-pop-work.js +39 -0
  54. package/workspace/lib/routes-report-setups.js +32 -1
  55. package/workspace/lib/routes-today-log.js +48 -0
  56. package/workspace/lib/routine-reports.js +84 -0
  57. package/workspace/lib/status-when.js +36 -0
  58. package/workspace/lib/task-items.js +5 -3
  59. package/workspace/lib/today-log.js +131 -0
  60. package/workspace/live-pill-round-test.js +10 -7
  61. package/workspace/metric-drafts-ui-test.js +3 -1
  62. package/workspace/milestone-pins-test.js +2 -1
  63. package/workspace/milestone-suggest-test.js +3 -1
  64. package/workspace/package-lock.json +2 -2
  65. package/workspace/package.json +1 -1
  66. package/workspace/panels-test.js +2 -1
  67. package/workspace/premium-board-actions-test.js +3 -1
  68. package/workspace/premium-rec-tab-test.js +2 -1
  69. package/workspace/premium-vw-backlog-test.js +3 -1
  70. package/workspace/premium-vw-item-test.js +3 -1
  71. package/workspace/premium-vw-jira-test.js +3 -1
  72. package/workspace/premium-vw-meet-test.js +2 -1
  73. package/workspace/premium-vw-notes-test.js +3 -2
  74. package/workspace/product-lane-test.js +2 -1
  75. package/workspace/program-charter-test.js +3 -1
  76. package/workspace/program-leave-test.js +2 -1
  77. package/workspace/program-order-test.js +2 -1
  78. package/workspace/program-panel-test.js +3 -1
  79. package/workspace/public/pm/artefact-kind.js +87 -0
  80. package/workspace/public/pm/bd-ini-panel.js +77 -12
  81. package/workspace/public/pm/bd-prog-panel.js +55 -8
  82. package/workspace/public/pm/bd-span.js +5 -0
  83. package/workspace/public/pm/bd-work.css +192 -0
  84. package/workspace/public/pm/bd-work.js +483 -0
  85. package/workspace/public/pm/cozy-bar.css +11 -0
  86. package/workspace/public/pm/cozy-bar.js +99 -0
  87. package/workspace/public/pm/cozy-day-pick.css +27 -0
  88. package/workspace/public/pm/cozy-day-pick.js +97 -0
  89. package/workspace/public/pm/cozy-ev.css +2 -5
  90. package/workspace/public/pm/cozy-events-view.js +274 -0
  91. package/workspace/public/pm/cozy-events.css +179 -0
  92. package/workspace/public/pm/cozy-events.js +278 -0
  93. package/workspace/public/pm/cozy-evmodel.js +1 -1
  94. package/workspace/public/pm/cozy-goals.css +172 -0
  95. package/workspace/public/pm/cozy-library.css +125 -0
  96. package/workspace/public/pm/cozy-live-pill.js +1 -0
  97. package/workspace/public/pm/cozy-nav.js +6 -7
  98. package/workspace/public/pm/cozy-pick.css +3 -0
  99. package/workspace/public/pm/cozy-pop-work.css +224 -0
  100. package/workspace/public/pm/cozy-pop-work.js +668 -0
  101. package/workspace/public/pm/cozy-popup.css +11 -2
  102. package/workspace/public/pm/cozy-popup.js +67 -9
  103. package/workspace/public/pm/cozy-routine-job.js +203 -0
  104. package/workspace/public/pm/cozy-routine-model.js +219 -0
  105. package/workspace/public/pm/cozy-routine-pop.js +318 -0
  106. package/workspace/public/pm/cozy-routine.css +155 -0
  107. package/workspace/public/pm/cozy-routine.js +335 -0
  108. package/workspace/public/pm/cozy-schedwork.js +6 -5
  109. package/workspace/public/pm/cozy-settings.js +1 -5
  110. package/workspace/public/pm/cozy-status-when.js +48 -0
  111. package/workspace/public/pm/cozy-today-app.js +236 -0
  112. package/workspace/public/pm/cozy-today-model.js +176 -0
  113. package/workspace/public/pm/cozy-today-page.css +100 -0
  114. package/workspace/public/pm/cozy-today-view.js +76 -0
  115. package/workspace/public/pm/cozy-viewer.js +19 -8
  116. package/workspace/public/pm/cozy-vw-mtg.css +39 -0
  117. package/workspace/public/pm/goals-model.js +205 -0
  118. package/workspace/public/pm/goals-open.js +124 -0
  119. package/workspace/public/pm/home-app.js +18 -3
  120. package/workspace/public/pm/home-chat.js +4 -2
  121. package/workspace/public/pm/home-ini.js +43 -10
  122. package/workspace/public/pm/ini-edit.js +3 -1
  123. package/workspace/public/pm/ini-view-model.js +1 -1
  124. package/workspace/public/pm/library-model.js +197 -0
  125. package/workspace/public/pm/library-open.js +37 -0
  126. package/workspace/public/pm/page-chat.js +12 -2
  127. package/workspace/public/pm/pop-work-model.js +493 -0
  128. package/workspace/public/pm/premium-board.js +204 -17
  129. package/workspace/public/pm/premium-goals.js +213 -0
  130. package/workspace/public/pm/premium-library.js +436 -0
  131. package/workspace/public/pm/premium-shell.js +1 -1
  132. package/workspace/public/pm/premium-vw-mtg.js +79 -1
  133. package/workspace/public/pm/scope-chip.js +204 -0
  134. package/workspace/public/premium-board.html +1 -0
  135. package/workspace/public/premium-events.html +44 -0
  136. package/workspace/public/premium-goals.html +37 -0
  137. package/workspace/public/premium-library.html +39 -0
  138. package/workspace/public/premium-routine.html +33 -0
  139. package/workspace/public/today.html +50 -0
  140. package/workspace/ready-dash-ui-test.js +3 -1
  141. package/workspace/rename-test.js +2 -1
  142. package/workspace/run-tests.js +4 -1
  143. package/workspace/server.js +4 -2
  144. package/workspace/sort-order-test.js +2 -1
  145. package/workspace/split-merge-ui-test.js +3 -1
  146. package/workspace/stage-card-tasks-test.js +3 -1
  147. package/workspace/stage-card-test.js +2 -1
  148. package/workspace/task-delete-test.js +2 -1
  149. package/workspace/task-links-test.js +2 -1
  150. package/workspace/task-milestones-test.js +4 -2
  151. package/workspace/task-plans-test.js +3 -1
  152. package/workspace/task-press-test.js +3 -1
  153. package/workspace/task-views-test.js +3 -1
  154. package/workspace/test-lists/doc-path.json +9 -0
  155. package/workspace/test-lists/events-place.json +11 -0
  156. package/workspace/test-lists/goals-place.json +9 -0
  157. package/workspace/test-lists/library-place.json +9 -0
  158. package/workspace/test-lists/pop-work.json +9 -0
  159. package/workspace/test-lists/routine-place.json +9 -0
  160. package/workspace/test-lists/status-when.json +9 -0
  161. package/workspace/test-lists/today-log.json +9 -0
  162. package/workspace/test-lists/work-view.json +9 -0
  163. package/workspace/timeline-holds-test.js +3 -1
  164. package/workspace/tk-tasks-test.js +2 -1
@@ -11,16 +11,19 @@
11
11
  margin: 0 !important; transform: none !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; }
12
12
  .cz-pop .cz-vw.cz-vw-pop > .cz-vw-grip { display: none; }
13
13
  .cz-pop .cz-vw.cz-vw-pop .cz-vw-hd { border-bottom: 0; padding: 18px 20px 10px 22px; }
14
- .cz-pop-card.chat-off .cz-vw.cz-vw-pop .cz-vw-hd { padding-right: 200px; }
14
+ .cz-pop-card.chat-off .cz-vw.cz-vw-pop .cz-vw-hd { padding-right: 112px; }
15
15
  .cz-vw-path { display: inline-flex; align-items: baseline; gap: 6px; flex: 0 1 auto; min-width: 0; max-width: 55%; overflow: hidden; white-space: nowrap; }
16
16
  .cz-vw-path button { all: unset; cursor: pointer; font-size: var(--fs-meta); color: var(--cz-ink3); overflow: hidden; text-overflow: ellipsis; border-radius: 6px; }
17
17
  .cz-vw-path button:hover { color: var(--cz-ink); text-decoration: underline; }
18
18
  .cz-vw-path button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
19
19
  .cz-vw-path span { color: var(--cz-ink3); font-size: var(--fs-meta); }
20
+ /* the small kind chip after the title (board 34: Library › Vendor call: Descope [Meeting notes]) */
21
+ .cz-vw-kchip { flex: none; align-self: center; padding: 2px 8px; border-radius: 6px; background: var(--cz-well); color: var(--cz-ink2); font-size: var(--fs-badge); font-weight: var(--fw-regular); white-space: nowrap; }
20
22
  /* the grip: the line between the two sides, with its handle */
21
23
  .cz-pop-grip { position: relative; flex: none; width: 1px; background: var(--cz-hair); cursor: col-resize; touch-action: none; }
22
24
  .cz-pop-grip::before { content: ''; position: absolute; inset: 0 -6px; }
23
25
  .cz-pop-grip i { position: absolute; left: -3px; top: 50%; width: 7px; height: 44px; margin-top: -22px; border-radius: 4px; background: var(--cz-card); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cz-ink3) 45%, transparent); }
26
+ .cz-pop-grip:hover, .cz-pop-grip:focus-visible { background: var(--cz-blue); }
24
27
  .cz-pop-grip:hover i, .cz-pop-grip:focus-visible i { background: var(--cz-well); }
25
28
  .cz-pop-grip:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
26
29
  body.cz-pop-drag, body.cz-pop-drag * { cursor: col-resize !important; user-select: none !important; }
@@ -100,8 +103,12 @@ body.cz-pop-drag, body.cz-pop-drag * { cursor: col-resize !important; user-selec
100
103
  /* chat hidden: its way back and the close, at the top right of the work */
101
104
  .cz-pop-tools { position: absolute; z-index: 6; top: 18px; right: 18px; display: flex; align-items: center; gap: 6px; }
102
105
  .cz-pop-tools[hidden] { display: none; }
103
- .cz-pop-ask { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; font-size: var(--fs-body); font-weight: var(--fw-strong);
106
+ /* the round Ask PMOS button (round 3 point 11); its dot: a session about this item waits for you */
107
+ .cz-pop-ask { all: unset; position: relative; cursor: pointer; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 999px;
104
108
  color: var(--cz-ink); background: var(--cz-well); }
109
+ .cz-pop-ask:hover { background: var(--cz-well2); }
110
+ .cz-pop-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 99px; background: var(--cz-blue); box-shadow: 0 0 0 2px var(--cz-card); }
111
+ .cz-pop-dot[hidden] { display: none; }
105
112
  .cz-pop-ask svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
106
113
  .cz-pop-ask:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
107
114
  /* "Session ended · Undo" for a few seconds */
@@ -111,3 +118,5 @@ body.cz-pop-drag, body.cz-pop-drag * { cursor: col-resize !important; user-selec
111
118
  .cz-pop-toast button { all: unset; cursor: pointer; margin-left: auto; font-weight: var(--fw-strong); text-decoration: underline; }
112
119
  .cz-pop-toast button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
113
120
  body.cz-pop-on { overflow: hidden; }
121
+ /* the chat side starts with two plain grey lines, no mascot (board 23) */
122
+ .cz-pop .hm-empty-ad > :not(p) { display: none; }
@@ -4,9 +4,13 @@
4
4
  * One way to open work: a popup that covers almost the whole page, with a thin dimmed edge of the page around it. The thing is on the left, in
5
5
  * the page's own Viewer (cozy-viewer.js lifts #czViewer into the popup, so every page's selectors still find it). Ask PMOS is on the right,
6
6
  * already about that thing. Esc, × or a press on the edge closes it. The phone keeps today's layout (cozy-viewer.js never pops on a phone).
7
- * The grip between the two sides resizes them: each side keeps a smallest width (the work 480 px, the chat 360 px), and PMOS remembers the
7
+ * The grip between the two sides resizes them: each side keeps a smallest width (the work 480 px, the chat 320 px), and PMOS remembers the
8
8
  * chat's width (localStorage 'cz-pop-chat'). Double-click or Home resets it; ← and → move it 24 px. The chat's top bar hides the chat, and the
9
9
  * work takes the full width; "Ask PMOS" at the top right brings it back.
10
+ * Ask PMOS is hidden by default (popup round 3 point 11): the thing takes the whole popup. The chat shows by itself only when it was open on
11
+ * this item in the last 24 hours and not hidden since (localStorage 'cz-pop-chaton': item → when), or a session about the item works or
12
+ * waits for you; then the round Ask PMOS button carries a dot while a session waits. Opened from the rail's chat icon, a session row or
13
+ * search's "Ask PMOS: …", the chat shows. Ctrl or Cmd J shows or hides it. A ✦ "Ask PMOS about this" press shows it with the text ready.
10
14
  * The chat's title is the session chooser: the newest sessions with the work each is about and its state (PMOS is working, Waits for you, or
11
15
  * when it was last used), New session (about the work on the left), and All sessions (the full list on the chat side with a search box; the
12
16
  * popup stays; ← goes back to the session you were in). Press one and the chat changes to it; the work on the left stays.
@@ -36,7 +40,7 @@ const I = {
36
40
  side: 'M3.5 5h17v14h-17zM12 5v14',
37
41
  };
38
42
  const CLAUDE = { key: 'claude', name: 'PMOS', initial: 'P' };
39
- const MIN_WORK = 480, MIN_CHAT = 360, DEF_CHAT = 460, POLL = 6000, UNDO = 6000, CHOOSER = 5;
43
+ const MIN_WORK = 480, MIN_CHAT = 320, DEF_CHAT = 460, DAY_MS = 864e5, POLL = 6000, UNDO = 6000, CHOOSER = 5;
40
44
  const store = {
41
45
  get(k) { try { return localStorage.getItem(k); } catch { return null; } },
42
46
  set(k, v) { try { if (v == null) localStorage.removeItem(k); else localStorage.setItem(k, String(v)); } catch { /* a private window */ } },
@@ -76,7 +80,7 @@ function frame() {
76
80
  + '<section class="cz-pop-r" aria-label="Ask PMOS">'
77
81
  + `<header class="cz-pop-hd"><span class="cz-pop-tile" aria-hidden="true">${svg(I.chat)}</span><div class="cz-pop-tw"></div>${ib('where', 'Open work beside the page', I.side)}${ib('hide', 'Hide the chat', I.hide)}${ib('close', 'Close', I.close)}</header>`
78
82
  + '<div class="cz-pop-chat"></div><div class="cz-pop-all" hidden></div><div class="cz-pop-toast" role="status" hidden></div></section>'
79
- + `<div class="cz-pop-tools" hidden><button type="button" class="cz-pop-ask" data-pop="ask" aria-label="Show Ask PMOS">${svg(I.chat, 16)}Ask PMOS</button>${ib('close', 'Close', I.close)}</div>`
83
+ + `<div class="cz-pop-tools" hidden><button type="button" class="cz-pop-ask" data-pop="ask" aria-label="Show Ask PMOS" title="Ask PMOS (Ctrl J)">${svg(I.chat, 18)}<i class="cz-pop-dot" hidden></i></button>${ib('close', 'Close', I.close)}</div>`
80
84
  + '</div>';
81
85
  document.body.appendChild(el);
82
86
  Object.assign(S, { el, card: el.querySelector('.cz-pop-card'), left: el.querySelector('.cz-pop-l'), right: el.querySelector('.cz-pop-r'), box: el.querySelector('.cz-pop-chat'),
@@ -110,20 +114,50 @@ function grip(g) {
110
114
  });
111
115
  }
112
116
 
117
+ /* ── is the chat shown? per item, remembered (round 3 point 11) ── */
118
+ const CHATON = 'cz-pop-chaton';
119
+ const itemKey = (a) => (a && a.id ? (a.kind || 'initiative') + ':' + a.id : '');
120
+ function chatMem() { try { const m = JSON.parse(store.get(CHATON) || '{}'); return m && typeof m === 'object' ? m : {}; } catch { return {}; } }
121
+ function remember(on) {
122
+ const k = itemKey(S.about); if (!k) return;
123
+ const m = chatMem(), now = Date.now();
124
+ for (const [x, t] of Object.entries(m)) if (!(now - t < DAY_MS)) delete m[x];
125
+ if (on) m[k] = now; else delete m[k];
126
+ store.set(CHATON, JSON.stringify(m));
127
+ }
128
+ const recentOn = (a) => { const t = chatMem()[itemKey(a)]; return !!t && Date.now() - t < DAY_MS; };
129
+ /** The sessions about the item on the left: 'wait' when one waits for you, 'work' when one works, '' for none. */
130
+ function aboutState() {
131
+ const a = S.about; if (!a || !a.id) return '';
132
+ const R = S.rows.now.filter((r) => r.ini === a.id);
133
+ return R.some((r) => r.state === 'wait') ? 'wait' : R.some((r) => r.state === 'work') ? 'work' : '';
134
+ }
135
+ function chatOn(on, why) {
136
+ if (!S.card) return;
137
+ S.card.classList.toggle('chat-off', !on); S.tools.hidden = on;
138
+ if (on) width(S.w || DEF_CHAT);
139
+ if (why === 'press') { S.userSet = true; remember(on); }
140
+ drawDot();
141
+ }
142
+ function drawDot() { const d = S.tools && S.tools.querySelector('.cz-pop-dot'); if (d) d.hidden = aboutState() !== 'wait'; }
143
+
113
144
  /* ── open and close ── */
114
145
  VW.popHook({ host: () => { frame(); return S.left; }, show });
115
146
  VW.onChange((d) => { if (d && d.pop && d.shut && S.open) hide(); });
116
147
  /** cozy-viewer.js calls this as an item goes into the popup. A popup already open keeps its chat: the work on the left changes, the chat stays. */
117
148
  function show(pop) {
118
- if (S.open) return;
149
+ if (S.open) { retarget(pop); return; }
119
150
  frame();
120
151
  S.open = true; S.view = 'chat'; S.q = ''; S.prev = null;
121
152
  S.back = document.activeElement && document.activeElement !== document.body ? document.activeElement : null;
122
153
  S.el.hidden = false; document.body.classList.add('cz-pop-on');
123
- S.card.classList.remove('chat-off'); S.tools.hidden = true; S.all.hidden = true; closeMenu();
154
+ S.all.hidden = true; closeMenu();
124
155
  const p = pop && typeof pop === 'object' ? pop : {};
125
156
  S.about = p.session ? (p.session.ini ? { id: p.session.ini, kind: 'initiative', title: p.session.work, ws: p.session.ws } : null) : p.id ? { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws } : null;
126
157
  width(parseInt(store.get('cz-pop-chat') || '', 10) || DEF_CHAT);
158
+ // the chat shows when it was asked for (the rail's chat icon, a session row, search's Ask PMOS), else when it was recently open on this item
159
+ S.userSet = false;
160
+ chatOn(!!(p.session || p.target || p.chat || !S.about || recentOn(S.about)));
127
161
  const want = p.keep ? null : p.target ? p.target : p.session ? null : S.about ? aboutTarget(S.about) : null;
128
162
  drawWhere();
129
163
  attach(want, p.session || null);
@@ -131,6 +165,18 @@ function show(pop) {
131
165
  tick();
132
166
  setTimeout(() => { if (S.open && S.card && !S.card.contains(document.activeElement)) S.card.focus({ preventScroll: true }); }, 0);
133
167
  }
168
+ /* A new item going into the open popup (a Today mention, a row in another list): the per-item rule again, and the chat moves to that
169
+ * item's scope ("In: <title>"), so it never keeps the previous item's conversation beside it. The same item, or none, changes nothing. */
170
+ function retarget(pop) {
171
+ const p = pop && typeof pop === 'object' ? pop : null;
172
+ if (!p || !p.id || p.keep || (S.about && S.about.id === p.id)) return;
173
+ S.about = { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws };
174
+ S.userSet = false;
175
+ chatOn(!!(p.target || p.chat || recentOn(S.about)));
176
+ drawWhere();
177
+ attach(p.target || aboutTarget(S.about), null);
178
+ read();
179
+ }
134
180
  function hide() {
135
181
  S.open = false; clearTimeout(S.timer); closeMenu(); hideToast();
136
182
  S.view = 'chat'; S.all.hidden = true; S.all.innerHTML = ''; S.right.classList.remove('all-on');
@@ -171,7 +217,7 @@ function aboutTarget(a) {
171
217
  async function resolve(t) {
172
218
  if (!t || !t.__about) return t;
173
219
  const M = await pageChat(), a = t.__about;
174
- return M.keyOf(a) ? M.targetOf(a, a.ws) : M.cosTarget(a.title || '', a.ws);
220
+ return M.keyOf(a) ? M.popTarget(a, a.ws) : M.cosTarget(a.title || '', a.ws);
175
221
  }
176
222
  async function attach(want, row) {
177
223
  const my = ++S.seq;
@@ -212,6 +258,7 @@ export async function chatTo(t) {
212
258
  const P = S.chat || await provider();
213
259
  const x = await resolve(t);
214
260
  if (x) P.open(x);
261
+ if (S.card && S.card.classList.contains('chat-off')) chatOn(true, 'press');
215
262
  S.view = 'chat'; S.all.hidden = true; S.right.classList.remove('all-on'); closeMenu(); drawTitle(); stateLine();
216
263
  setTimeout(() => P.focus && P.focus(), 30);
217
264
  return true;
@@ -222,6 +269,9 @@ async function read() {
222
269
  const r = await pmGet('/api/sessions').catch(() => null);
223
270
  if (!S.open) return;
224
271
  if (r && Array.isArray(r.sessions)) { S.raw = r.sessions; S.rows = sessionRows(S.raw, { titleOf }); }
272
+ // a session about this item works or waits for you: the chat shows by itself, unless you hid it in this popup
273
+ if (S.card && S.card.classList.contains('chat-off') && !S.userSet && aboutState()) chatOn(true);
274
+ drawDot();
225
275
  drawTitle(); stateLine(); drawLists();
226
276
  }
227
277
  function tick() { clearTimeout(S.timer); S.timer = setTimeout(async () => { if (!S.open) return; if (!document.hidden) await read(); tick(); }, POLL); }
@@ -344,7 +394,7 @@ async function newSession() {
344
394
  const a = S.about, M = await pageChat();
345
395
  let t;
346
396
  if (a && M.keyOf(a)) {
347
- const base = M.targetOf(a, a.ws);
397
+ const base = M.popTarget(a, a.ws);
348
398
  t = { ...base, key: nextKey(base.key, S.raw), title: 'New session · ' + (a.title || 'this'), empty: 'A new session about ' + (a.title || 'this') + '. Say what it is for.' };
349
399
  } else {
350
400
  const d = new Date(), p = (x) => String(x).padStart(2, '0');
@@ -361,14 +411,22 @@ function onClick(e) {
361
411
  const a = b.dataset.pop;
362
412
  if (a === 'close') close();
363
413
  else if (a === 'where') where();
364
- else if (a === 'hide') { S.card.classList.add('chat-off'); S.tools.hidden = false; closeMenu(); const k = S.tools.querySelector('[data-pop="ask"]'); if (k) k.focus(); }
365
- else if (a === 'ask') { S.card.classList.remove('chat-off'); S.tools.hidden = true; width(S.w); if (S.chat && S.chat.focus) S.chat.focus(); }
414
+ else if (a === 'hide') { chatOn(false, 'press'); closeMenu(); const k = S.tools.querySelector('[data-pop="ask"]'); if (k) k.focus(); }
415
+ else if (a === 'ask') { chatOn(true, 'press'); if (S.chat && S.chat.focus) S.chat.focus(); }
366
416
  else if (a === 'pick') { if (S.menu) closeMenu(); else { openMenu(); read(); } }
367
417
  else if (a === 'new') newSession();
368
418
  else if (a === 'all') showAll(true);
369
419
  else if (a === 'unall') showAll(false);
370
420
  else if (a === 'undo') { const u = S.toast._undo; hideToast(); if (u) u(); }
371
421
  }
422
+ // Ctrl or Cmd J: show or hide Ask PMOS (round 3 point 11)
423
+ addEventListener('keydown', (e) => {
424
+ if (!S.open || !(e.ctrlKey || e.metaKey) || e.altKey || e.shiftKey || String(e.key).toLowerCase() !== 'j') return;
425
+ e.preventDefault(); e.stopPropagation();
426
+ const off = S.card.classList.contains('chat-off');
427
+ chatOn(off, 'press');
428
+ if (off && S.chat && S.chat.focus) S.chat.focus(); else { const k = S.tools.querySelector('[data-pop="ask"]'); if (k) k.focus(); }
429
+ }, true);
372
430
  // Esc: the chooser closes first, then All sessions goes back to the session; with neither, the Viewer's own Esc closes the popup
373
431
  addEventListener('keydown', (e) => {
374
432
  if (e.key !== 'Escape' || !S.open) return;
@@ -0,0 +1,203 @@
1
+ /* pm/cozy-routine-job.js — a read, a PMOS job, a service of Your tools or one of your tasks, managed in the one popup (Routine round 3, design
2
+ * /mnt/project-files/nav-structure/audit/routine-round3.md item 3; the report case is pm/cozy-routine-pop.js).
3
+ *
4
+ * The same parts for every type: on the left the Instruction (what PMOS does in each run, in plain words) and Last runs; on the right the grey
5
+ * Setup box (On, Repeats, Next, Tells, After the run, Built from). ▶ Run now is in the header; Delete is in ⋯ for your own tasks, with Undo.
6
+ * A built-in read or job shows its instruction read-only and says "Built in": its rhythm and its switch still change here. Every value can also
7
+ * be changed by telling PMOS in the chat.
8
+ *
9
+ * WRITES, each the PM's press, on routes that exist:
10
+ * a read or a job On → POST /api/refresh/source { id, on }; Repeats → /api/refresh/source { id, schedule }; ▶ → /api/refresh/run { id }
11
+ * a service On / Repeats → /api/refresh/source { id: 'tools', svc, schedule } (off = its own rhythm "only when you press read")
12
+ * Horizon scan On / Repeats → POST /api/scan/setting { ws, cadence }; ▶ → POST /api/scan/now { ws }
13
+ * Report finder On → POST /api/report-setups/finder { ws, cadence: weekly | off }
14
+ * your task On → /api/schedules/update { id, enabled }; Repeats → { cadence }; Instruction → { args }; ▶ → /api/schedules/run;
15
+ * Delete → /api/schedules/delete, sent only when the Undo has passed (10 s), so Undo needs no route of its own
16
+ * jobHtml(J, now) — pure, for the tests. J = { row, raw, svc?, tools?, extra?, msg, busy, text, undo } */
17
+ import { repeatOpts } from './cozy-schedwork.js';
18
+ import { dayTime } from './cozy-routine-model.js';
19
+
20
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
21
+ const svg = (d, n = 16) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
22
+ export const ICON = { play: 'M8 5l11 7-11 7z', check: 'M5 12.5l4.5 4.5L19 7.5', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', trash: 'M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3' };
23
+ const MONS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
24
+ const sw = (on, label, dis) => `<button type="button" class="rt-sw" role="switch" aria-checked="${!!on}" data-rj="on" aria-label="${esc(label)}" title="${esc(label)}"${dis ? ' disabled' : ''}></button>`;
25
+ const kv = (k, v) => `<div class="rp-r"><span>${esc(k)}</span>${v}</div>`;
26
+ const em = (t, title) => `<em${title ? ` title="${esc(title)}"` : ''}>${esc(t)}</em>`;
27
+ export const TASK_CAD = [['hourly', 'Every hour'], ['daily', 'Every day'], ['weekly', 'Every week'], ['bi-weekly', 'Every 2 weeks'], ['monthly', 'Every month']];
28
+ const DAYS = [['Mon', 'Monday'], ['Tue', 'Tuesday'], ['Wed', 'Wednesday'], ['Thu', 'Thursday'], ['Fri', 'Friday'], ['Sat', 'Saturday'], ['Sun', 'Sunday']];
29
+ const SCAN_CAD = [['daily', 'Every working day'], ['weekly', 'Every week']];
30
+ /** "18 Nov, 09:00" for a run. */
31
+ const when = (t) => dayTime(t) || '';
32
+ /** Where a read puts what it reads, for After the run: the first page its own words name, else "Nothing to send". */
33
+ function afterOf(row) {
34
+ if (row.kind === 'tasks') return 'Nothing to send';
35
+ const m = /\binto (Today|Work|Events|Library|Goals|Routine)\b/.exec(row.does || '') || /\bfor (the Briefing|Calendar|the Work page)\b/.exec(row.does || '');
36
+ return m ? 'Puts it into ' + m[1].replace(/^the /, '').replace('Briefing', 'Today').replace('Calendar', 'Events').replace('Work page', 'Work') : 'Nothing to send';
37
+ }
38
+
39
+ /** The last runs (at most 5): the day and time, what came out, and "Failed: why" when one failed. */
40
+ export function runsOf(J) {
41
+ const r = J.raw || {};
42
+ if (J.row.kind === 'tasks') return r.lastRun ? [{ at: r.lastRun, ok: r.lastStatus !== 'failed' && r.lastStatus !== 'error', said: r.lastStatus === 'failed' || r.lastStatus === 'error' ? 'Failed' + (r.lastError ? ': ' + r.lastError : '') : 'Done' }] : [];
43
+ const runs = (J.tools ? J.tools.runs : r.runs) || [];
44
+ return runs.filter((x) => x && x.start_at && (!J.svc || !Array.isArray(x.svcs) || x.svcs.includes(J.svc))).slice(0, 5).map((x) => ({
45
+ at: x.start_at, ok: x.result !== 'failed',
46
+ said: x.result === 'failed' ? 'Failed' + (x.error ? ': ' + String(x.error).replace(/\.$/, '') : '') : x.result === 'skipped' ? 'Skipped' + (x.note ? ': ' + x.note : '') : !x.end_at ? 'Running' : x.got ? String(x.got) : 'Done',
47
+ }));
48
+ }
49
+
50
+ /** The popup's left and right sides, as html. Pure. */
51
+ export function jobHtml(J, now = Date.now()) {
52
+ const row = J.row || {}, r = J.raw || {}, x = J.extra || null, task = row.kind === 'tasks';
53
+ // Instruction: a task's own words can change; a built-in read or job is read-only and says why
54
+ const ins = task
55
+ ? `<label class="vh" for="rjIns">Instruction</label><textarea id="rjIns" class="rj-ins" data-rj="ins" rows="4" maxlength="2000" placeholder="What PMOS does in each run, in plain words">${esc(J.text != null ? J.text : r.args || '')}</textarea>`
56
+ + `<div class="rj-act">${J.text != null && J.text !== (r.args || '') ? `<button type="button" class="rp-y" data-rj="save" aria-label="Save the instruction" title="Save the instruction"${J.busy ? ' disabled' : ''}>${svg(ICON.check, 14)}</button>` : ''}<span class="rj-hint">${esc('Runs ' + (r.skill || r.task || 'its skill') + ' with these words. Or tell PMOS on the right what to change.')}</span></div>`
57
+ : `<p class="rj-txt">${esc(J.svc ? 'Reads what is new in ' + row.name + ' and saves it as it is, for Today. ' + 'It reads only; it sends nothing.' : String(r.what || row.does || ''))}</p><p class="rj-hint"><b>Built in.</b> PMOS wrote this one. You can change how often it runs, or turn it off.</p>`;
58
+ const runs = runsOf(J);
59
+ const last = runs.length ? runs.map((u) => `<div class="rj-run${u.ok ? '' : ' bad'}"><span>${esc(when(u.at))}</span><em>${esc(u.said)}</em></div>`).join('') : '<p class="rj-hint">It has not run yet.</p>';
60
+ const main = `<section class="rj-sec" aria-label="Instruction"><h6>Instruction</h6>${ins}</section><section class="rj-sec" aria-label="Last runs"><h6>Last runs</h6>${last}</section>`;
61
+ // the Setup box: only what the records say
62
+ const rows = [];
63
+ rows.push(kv('On', sw(row.on, row.on ? 'On. Press to pause it' : 'Paused. Press to start it again', J.busy)));
64
+ const sch = J.svc ? (J.own || {}) : r;
65
+ const opts = task ? TASK_CAD.map(([v, l]) => [v, l, v === r.cadence]) : row.id === 'scan' && x ? SCAN_CAD.map(([v, l]) => [v, l, x.cadence === v]) : sch && sch.schedule ? repeatOpts(sch) : [];
66
+ if (opts.length) rows.push(kv('Repeats', `<label class="vh" for="rjRep">Repeats</label><select id="rjRep" class="rp-sel" data-rj="rep"${J.busy ? ' disabled' : ''}>${opts.map(([v, l, on]) => `<option value="${esc(v)}"${on ? ' selected' : ''}>${esc(l)}</option>`).join('')}</select>`));
67
+ else if (row.when) rows.push(kv('Repeats', em(row.when, row.when)));
68
+ // a task's day and time change here too (round 3 design check item 4): the day for a weekly one, the day of the month for a monthly one
69
+ if (task && (r.cadence === 'weekly' || r.cadence === 'bi-weekly')) rows.push(kv('Day', `<label class="vh" for="rjDay">Day</label><select id="rjDay" class="rp-sel" data-rj="day"${J.busy ? ' disabled' : ''}>${DAYS.map(([v, l]) => `<option value="${v}"${(r.day || 'Mon') === v ? ' selected' : ''}>${l}</option>`).join('')}</select>`));
70
+ if (task && r.cadence === 'monthly') rows.push(kv('Day', `<label class="vh" for="rjDom">Day of the month</label><select id="rjDom" class="rp-sel" data-rj="dom"${J.busy ? ' disabled' : ''}>${Array.from({ length: 28 }, (_, i) => i + 1).map((n) => `<option value="${n}"${+(r.dayOfMonth || 1) === n ? ' selected' : ''}>Day ${n}</option>`).join('')}</select>`));
71
+ if (task && r.cadence && r.cadence !== 'hourly') rows.push(kv('At', `<label class="vh" for="rjTime">Time</label><input id="rjTime" type="time" class="rp-in" data-rj="time" value="${esc(r.time || '09:00')}"${J.busy ? ' disabled' : ''}>`));
72
+ const nx = task ? r.nextRun : J.svc ? (J.own && J.own.next_at) : r.next_at || (x && x.next);
73
+ if (row.on && nx) rows.push(kv('Next', em(when(nx))));
74
+ rows.push(kv('Tells', em('You')));
75
+ rows.push(kv('After the run', em(afterOf(row))));
76
+ const from = task ? (r.skill || r.task || '') : (r.inputs || []).map((i) => i.label).filter(Boolean).join(' · ');
77
+ if (from) rows.push(kv('Built from', em(from, from)));
78
+ const box = `<aside class="rp-box" aria-label="Setup"><h6>Setup</h6>${rows.join('')}<p>To change the setup, press a value. Or tell PMOS on the right, for example “run it every two hours”.</p></aside>`;
79
+ const msg = `<p class="rp-msg" role="status">${esc(J.msg || '')}${J.undo ? ` <button type="button" class="rj-undo" data-rj="undo">${esc(J.undo.label || 'Undo')}</button>` : ''}</p>`;
80
+ return `<div class="rp-w"><div class="rp-main">${main}${msg}</div>${box}</div>`;
81
+ }
82
+
83
+ /** + a new routine (round 3 item 4): an empty setup on the left; PMOS asks "What should repeat?" on the right and fills it from the answer. Pure. */
84
+ export function newHtml() {
85
+ const rows = [kv('On', sw(false, 'Off until PMOS has filled it in', true)), kv('Repeats', em('From your answer')), kv('Tells', em('From your answer')), kv('After the run', em('From your answer'))];
86
+ const main = `<section class="rj-sec" aria-label="Instruction"><h6>Instruction</h6><p class="rj-txt">Tell PMOS on the right what should repeat, how often, and who it tells. PMOS fills in the setup and the instruction, and asks you once before it starts.</p>`
87
+ + `<p class="rj-hint">For example: “Every Friday at 16:00, sum up the week for me.”</p></section>`;
88
+ return `<div class="rp-w"><div class="rp-main">${main}</div><aside class="rp-box" aria-label="Setup"><h6>Setup</h6>${rows.join('')}</aside></div>`;
89
+ }
90
+ /** Open + in the popup, with Ask PMOS open on "What should repeat?" (the one popup that opens with the chat shown). */
91
+ export function openNew(h, target) {
92
+ // the same chip ("In: New routine") and empty line as every popup (design check item 2); the box asks the question
93
+ const t = { ...target, placeholder: 'What should repeat?', context: 'Routine · a new routine: ask what should repeat, how often and who it tells' };
94
+ h.VW.open({ id: 'routine:new', kind: 'New routine', from: 'Routine', kindChip: 'New routine', title: 'New routine', icon: 'gear',
95
+ pop: { id: 'routine-new', kind: 'routine', title: 'New routine', target: t, chat: 'open' },
96
+ render: (b) => { b.innerHTML = newHtml(); } });
97
+ }
98
+
99
+ /* ── the popup ── */
100
+ const said = (r, ok) => (r && r.ok !== false && !(r && r.error) ? ok : 'Nothing changed: ' + ((r && r.error) || 'the server did not answer') + '.');
101
+ let CUR = null;
102
+
103
+ /** Open a read, a job, a service or one of your tasks. h: { VW, http: { pmGet, pmPost }, reload(), raw(row, fresh?) → { row?, raw, tools?, own?, extra? },
104
+ * ws, toast, later(row, url, body, words) — a delete with Undo, flipSvc(row, on) } */
105
+ export function openJob(row, h) {
106
+ const got = h.raw(row) || {};
107
+ const J = { row, raw: got.raw || {}, tools: got.tools || null, own: got.own || null, svc: row.svc || null, extra: got.extra || null, msg: '', busy: false, text: null, undo: null };
108
+ const me = CUR = { J, body: null, h };
109
+ const task = row.kind === 'tasks';
110
+ const kd = task ? 'Your task' : row.kind === 'reads' ? 'PMOS reads' : 'PMOS job';
111
+ h.VW.open({ id: 'routine:' + row.key, kind: kd, from: 'Routine', kindChip: kd, title: row.name, icon: task ? 'task' : row.kind === 'reads' ? 'source' : 'gear',
112
+ pop: { id: 'routine-' + row.id, kind: 'routine', title: row.name },
113
+ presses: [{ act: 'run', label: task ? 'Run it now' : row.kind === 'reads' ? 'Read now' : 'Run it now', icon: ICON.play, solid: true }],
114
+ more: task ? [{ label: 'Delete this task', icon: ICON.trash, on: () => del(me) }] : null,
115
+ onPress: (act) => { if (act === 'run') run(me); },
116
+ render: (b) => { me.body = b; draw(me); wire(me); },
117
+ onClose: () => { if (CUR === me) CUR = null; } });
118
+ return me;
119
+ }
120
+ function draw(me) { if (me.body && me.body.isConnected) me.body.innerHTML = jobHtml(me.J); }
121
+ async function again(me) {
122
+ if (me.h.reload) await me.h.reload();
123
+ const got = me.h.raw(me.J.row, true) || {};
124
+ if (got.row) me.J.row = got.row;
125
+ Object.assign(me.J, { raw: got.raw || me.J.raw, tools: got.tools || me.J.tools, own: got.own || me.J.own, extra: got.extra || me.J.extra });
126
+ if (CUR === me) draw(me);
127
+ }
128
+ async function act(me, fn) {
129
+ const J = me.J; if (J.busy) return;
130
+ J.busy = true; draw(me);
131
+ try { J.msg = await fn(); } finally { J.busy = false; }
132
+ await again(me);
133
+ }
134
+ function post(me, url, body) { return me.h.http.pmPost(url, body).catch(() => null); }
135
+ async function run(me) {
136
+ const { row } = me.J, ws = me.h.ws || undefined;
137
+ return act(me, async () => {
138
+ if (row.kind === 'tasks') return said(await post(me, '/api/schedules/run', { id: row.id }), 'Started. It runs now.');
139
+ if (row.id === 'scan') return said(await post(me, '/api/scan/now', { ws }), 'Started. PMOS scans now.');
140
+ if (row.svc) return said(await post(me, '/api/refresh/run', { id: row.parent, svcs: [row.svc], ws }), 'Started. PMOS reads ' + row.name + ' now.');
141
+ return said(await post(me, '/api/refresh/run', { id: row.id, ws }), 'Started. ' + row.name + ' runs now.');
142
+ });
143
+ }
144
+ /** Delete a task: the row goes at once, and the delete is sent when its 10 s of Undo have passed (the page's later()). */
145
+ function del(me) {
146
+ const { row } = me.J;
147
+ me.h.later(row, '/api/schedules/delete', { id: row.id }, row.name + ' is deleted.');
148
+ me.h.VW.closePop();
149
+ }
150
+ function wire(me) {
151
+ const b = me.body; if (!b || b.__rj) return; b.__rj = true;
152
+ const J = me.J;
153
+ b.addEventListener('input', (e) => { if (e.target.dataset && e.target.dataset.rj === 'ins') { const had = J.text != null && J.text !== (J.raw.args || ''); J.text = e.target.value; const has = J.text !== (J.raw.args || ''); if (had !== has) { const pos = e.target.selectionStart; draw(me); const t = b.querySelector('#rjIns'); if (t) { t.focus(); t.setSelectionRange(pos, pos); } } } });
154
+ b.addEventListener('click', (e) => {
155
+ const t = e.target.closest('[data-rj]'); if (!t || t.tagName === 'SELECT' || t.tagName === 'TEXTAREA' || t.disabled) return;
156
+ const k = t.dataset.rj, row = J.row, ws = me.h.ws || undefined;
157
+ if (k === 'on') {
158
+ const on = !row.on;
159
+ return act(me, async () => {
160
+ if (row.kind === 'tasks') return said(await post(me, '/api/schedules/update', { id: row.id, enabled: on }), on ? 'On. It runs on its schedule again.' : 'Paused.');
161
+ if (row.svc && me.h.flipSvc) return me.h.flipSvc(row, on);
162
+ if (row.id === 'scan') return said(await post(me, '/api/scan/setting', { ws, cadence: on ? (J.extra && J.extra.was) || 'daily' : 'off' }), on ? 'On.' : 'Paused. PMOS does not scan until you turn it on.');
163
+ if (row.id === 'finder') return said(await post(me, '/api/report-setups/finder', { ws, cadence: on ? 'weekly' : 'off' }), on ? 'On. It looks once a week.' : 'Paused.');
164
+ return said(await post(me, '/api/refresh/source', { id: row.id, on }), on ? 'On.' : 'Paused. PMOS does not run it on its own.');
165
+ });
166
+ }
167
+ if (k === 'save') {
168
+ const old = J.raw.args || '', v = String(J.text || '').trim();
169
+ return act(me, async () => {
170
+ const r = await post(me, '/api/schedules/update', { id: row.id, args: v || null });
171
+ if (r && r.ok) { J.text = null; J.undo = { label: 'Undo', args: old }; return 'Saved. It runs with these words from the next run.'; }
172
+ return said(r, '');
173
+ });
174
+ }
175
+ if (k === 'undo' && J.undo) {
176
+ const u = J.undo; J.undo = null;
177
+ return act(me, async () => said(await post(me, '/api/schedules/update', { id: row.id, args: u.args || null }), 'Undone. The instruction is as it was.'));
178
+ }
179
+ });
180
+ b.addEventListener('change', (e) => {
181
+ const t = e.target; if (!t.dataset) return;
182
+ if (['day', 'dom', 'time'].includes(t.dataset.rj)) {
183
+ const k = t.dataset.rj, v = t.value; if (!v) return;
184
+ const body = { id: J.row.id, ...(k === 'day' ? { day: v } : k === 'dom' ? { dayOfMonth: +v } : { time: v }) };
185
+ return act(me, async () => said(await post(me, '/api/schedules/update', body), 'Saved.'));
186
+ }
187
+ if (t.dataset.rj !== 'rep') return;
188
+ const row = J.row, v = t.value, ws = me.h.ws || undefined;
189
+ act(me, async () => {
190
+ if (row.kind === 'tasks') return said(await post(me, '/api/schedules/update', { id: row.id, cadence: v }), 'Saved. ' + ((TASK_CAD.find((c) => c[0] === v) || [0, v])[1]) + '.');
191
+ if (row.id === 'scan') return said(await post(me, '/api/scan/setting', { ws, cadence: v }), 'Saved.');
192
+ const base = row.svc ? J.own || {} : J.raw, cur = (base && base.schedule) || {}, times = cur.times && cur.times.length ? cur.times : ['09:00'];
193
+ let sch;
194
+ if (row.svc && v === 'same') sch = null;
195
+ else if (v === 'manual') sch = { kind: 'manual' };
196
+ else if (v.startsWith('every:')) sch = { kind: 'every', every: v.slice(6), work: cur.kind === 'every' ? !!cur.work : true };
197
+ else sch = { kind: v, times: v === 'weekly' ? times.slice(0, 1) : times, ...(v === 'weekly' ? { day: cur.day || 'Mon' } : {}) };
198
+ return said(await post(me, '/api/refresh/source', row.svc ? { id: row.parent, svc: row.svc, schedule: sch } : { id: row.id, schedule: sch }), 'Saved.');
199
+ });
200
+ });
201
+ }
202
+
203
+ export { MONS };