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
@@ -0,0 +1,155 @@
1
+ /* pm/cozy-routine.css — Routine (initiative routine-place, board 11) and a routine in the popup (board 10). One container: the page panel; the
2
+ * table is one card with a thin border; the setup is one grey box. Tokens are cozy.css's. */
3
+ .rt-page { gap: 14px; }
4
+ /* on a wide screen the page keeps one reading width and does not stretch (round 2) */
5
+ .rt-page > * { width: 100%; max-width: 1200px; }
6
+ .rt-pick:empty { display: none; }
7
+ .rt-seg .rt-n { margin-left: 6px; font-weight: var(--fw-strong); color: var(--cz-ink3); font-variant-numeric: tabular-nums; }
8
+ .rt-hid { margin: 0 0 10px; font-size: var(--fs-meta); color: var(--cz-ink3); }
9
+ .rt-hid button { all: unset; cursor: pointer; color: var(--cz-blue); font-weight: var(--fw-strong); }
10
+ .rt-hid button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 4px; }
11
+ .rt-bar { display: flex; align-items: center; gap: 12px; }
12
+ .rt-seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--cz-well); flex-wrap: wrap; }
13
+ .rt-seg button { all: unset; cursor: pointer; height: 30px; padding: 0 14px; border-radius: 999px; font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink2); display: inline-flex; align-items: center; }
14
+ .rt-seg button[aria-pressed="true"] { background: var(--cz-card); color: var(--cz-ink); box-shadow: 0 1px 2px rgba(30, 40, 60, .12); }
15
+ .rt-seg button:focus-visible, .rt-add:focus-visible, .rt-did:focus-visible, .rt-r:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
16
+ .rt-add { all: unset; cursor: pointer; margin-left: auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink2); }
17
+ .rt-add svg, .rt-did svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
18
+ .rt-add:hover { background: var(--cz-well); }
19
+ .rt-did { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 14px; background: var(--cz-well); font-size: var(--fs-body); color: var(--cz-ink); }
20
+ .rt-did > b { color: var(--cz-c-6b4fa3); }
21
+ .rt-did span { flex: 1; min-width: 0; }
22
+ .rt-did em { font-style: normal; color: var(--cz-ink3); }
23
+ .rt-tbl { border-radius: 16px; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); overflow: hidden; font-size: var(--fs-body); color: var(--cz-ink); }
24
+ .rt-r { display: grid; grid-template-columns: 26px minmax(180px, 1.3fr) 76px minmax(160px, 1fr) 196px 112px 44px 14px; align-items: center; column-gap: 12px; min-height: 46px; padding: 0 18px; box-shadow: inset 0 -1px 0 var(--cz-hair); }
25
+ .rt-tbl.multi .rt-r { grid-template-columns: 26px minmax(180px, 1.3fr) 76px 128px minmax(160px, 1fr) 196px 112px 44px 14px; }
26
+ /* the row is the way in: a small chevron shows on hover (round 3 item 5) */
27
+ .rt-r .go { color: var(--cz-ink3); display: grid; place-items: center; opacity: 0; }
28
+ .rt-r .go svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
29
+ .rt-r.rt-row:hover .go, .rt-r.rt-row:focus-visible .go { opacity: 1; }
30
+ /* one-time reports and loose drafts: one fold line at the end of Reports (round 3 item 1) */
31
+ .rt-r.rt-fold { display: block; min-height: 40px; padding: 0 18px; }
32
+ .rt-fold button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-size: var(--fs-meta); color: var(--cz-ink3); }
33
+ .rt-fold button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
34
+ .rt-fold button[aria-expanded="true"] svg { transform: rotate(90deg); }
35
+ .rt-fold button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 4px; }
36
+ .rt-r:last-child { box-shadow: none; }
37
+ .rt-r.rt-h { min-height: 38px; background: var(--cz-well); font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink2); }
38
+ .rt-r.rt-g { min-height: 34px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink3); background: var(--cz-well); }
39
+ .rt-r.rt-g > div { grid-column: 1 / -1; }
40
+ .rt-r.rt-row { cursor: pointer; }
41
+ .rt-r.rt-row:hover { background: var(--cz-well); }
42
+ .rt-r .e { display: flex; justify-content: flex-end; align-items: center; }
43
+ .rt-r .ic { color: var(--cz-ink3); display: grid; place-items: center; }
44
+ .rt-r .ic svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
45
+ .rt-r .n { font-weight: var(--fw-strong); }
46
+ /* nothing is cut off (round 2): a long name or sentence takes a second line, and only a third is cut */
47
+ .rt-r .n, .rt-r .c { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 6px 0; line-height: 1.35; }
48
+ .rt-r .c { color: var(--cz-ink2); }
49
+ .rt-r .w { color: var(--cz-risk); font-weight: var(--fw-strong); display: inline-flex; align-items: center; gap: 7px; }
50
+ .rt-r .w::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--cz-dot-risk); flex: none; }
51
+ .rt-r.off .n, .rt-r.off .c { color: var(--cz-ink3); }
52
+ .rt-sw { all: unset; box-sizing: border-box; cursor: pointer; width: 34px; height: 20px; border-radius: 999px; background: var(--cz-well2); position: relative; justify-self: end; flex: none; }
53
+ .rt-sw::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--cz-card); box-shadow: 0 1px 2px rgba(30, 40, 60, .25); transition: left .15s; }
54
+ .rt-sw[aria-checked="true"] { background: var(--cz-blue); }
55
+ .rt-sw[aria-checked="true"]::after { left: 17px; }
56
+ .rt-sw:focus-visible, .rt-yes:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
57
+ .rt-yes { all: unset; cursor: pointer; justify-self: end; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-ink); color: var(--cz-card); }
58
+ .rt-yes svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
59
+ .rt-yes[disabled], .rt-sw[disabled] { opacity: .5; cursor: default; }
60
+ .rt-note, .rt-quiet { margin: 0 6px; font-size: var(--fs-meta); color: var(--cz-ink3); }
61
+ .rt-msg { margin: 0 6px; font-size: var(--fs-meta); color: var(--cz-ink2); min-height: 1em; }
62
+ .rt-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90; padding: 10px 16px; border-radius: 12px; background: var(--cz-ink); color: var(--cz-card); font-size: var(--fs-body); opacity: 0; pointer-events: none; transition: opacity .2s; }
63
+ .rt-toast.on { opacity: 1; }
64
+ @media (max-width: 760px) {
65
+ .rt-r { grid-template-columns: 22px minmax(0, 1fr) minmax(0, .8fr) 44px; padding: 0 12px; min-height: 52px; }
66
+ .rt-r .go { display: none; }
67
+ .rt-tbl.multi .rt-r { grid-template-columns: 22px minmax(0, 1fr) minmax(0, .8fr) 44px; }
68
+ .rt-r .c.does, .rt-r .c.when, .rt-r.rt-h .does, .rt-r.rt-h .when, .rt-r .type, .rt-r .prod { display: none; }
69
+ .rt-seg { border-radius: 16px; }
70
+ }
71
+ .vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
72
+
73
+ /* PMOS did, the full log (in the popup) */
74
+ .rt-log { display: flex; flex-direction: column; gap: 2px; padding: 4px 2px 20px; font-size: var(--fs-body); color: var(--cz-ink); }
75
+ .rt-log .l { display: flex; align-items: flex-start; gap: 10px; padding: 10px 4px; box-shadow: inset 0 -1px 0 var(--cz-hair); }
76
+ .rt-log .l span { flex: 1; min-width: 0; }
77
+ .rt-log .l b { font-weight: var(--fw-strong); display: block; }
78
+ .rt-log .l em { font-style: normal; color: var(--cz-ink3); font-size: var(--fs-meta); }
79
+ .rt-log .l button { all: unset; cursor: pointer; flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink2); }
80
+ .rt-log .l button:hover { background: var(--cz-well); }
81
+ .rt-log .l button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
82
+ .rt-log .l button[disabled] { opacity: .4; cursor: default; }
83
+
84
+ /* a report in the popup (board 10): the issue on the left, the setup in one grey box */
85
+ .rp-w { display: grid; grid-template-columns: minmax(0, 1fr) 300px; column-gap: 22px; align-items: start; padding: 4px 4px 24px; }
86
+ @media (max-width: 1100px) { .rp-w { grid-template-columns: minmax(0, 1fr); row-gap: 16px; } }
87
+ .rp-main { font-size: var(--fs-body); line-height: 1.55; color: var(--cz-ink); min-width: 0; }
88
+ .rp-sg { margin: 0 0 16px; border-radius: 12px; background: var(--cz-card); box-shadow: inset 0 0 0 1px rgba(107, 91, 210, .28); padding: 8px 12px; }
89
+ .rp-sg h5 { margin: 0 0 2px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-c-6b4fa3); display: flex; align-items: center; gap: 5px; }
90
+ .rp-sg div { display: flex; align-items: center; gap: 8px; font-size: var(--fs-body); line-height: 1.4; }
91
+ .rp-sg div span { flex: 1; min-width: 0; }
92
+ .rp-sg button { all: unset; cursor: pointer; flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); color: var(--cz-ink); }
93
+ .rp-sg button.rp-y { background: var(--cz-ink); color: var(--cz-card); box-shadow: none; }
94
+ .rp-sg button[disabled] { opacity: .5; cursor: default; }
95
+ .rp-m { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: var(--fs-meta); color: var(--cz-ink3); }
96
+ .rp-ch { height: 28px; padding: 0 10px; border-radius: 999px; background: var(--cz-well); font: inherit; font-weight: var(--fw-strong); color: var(--cz-ink2); border: 0; display: inline-flex; align-items: center; }
97
+ .rp-ed { all: unset; cursor: pointer; margin-left: auto; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink2); }
98
+ .rp-ed:hover { background: var(--cz-well); }
99
+ .rp-txt h1, .rp-txt h2, .rp-txt h3, .rp-txt h4 { font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink2); margin: 20px 0 4px; }
100
+ .rp-txt p { margin: 0 0 8px; }
101
+ .rp-txt ul, .rp-txt ol { margin: 0 0 8px; padding-left: 20px; }
102
+ .rp-txt table { border-collapse: collapse; font-size: var(--fs-body); margin: 6px 0 10px; }
103
+ .rp-txt th, .rp-txt td { padding: 4px 8px; box-shadow: inset 0 -1px 0 var(--cz-hair); text-align: left; }
104
+ .rp-q { color: var(--cz-ink3); font-size: var(--fs-body); }
105
+ .rp-msg { margin: 10px 0 0; font-size: var(--fs-meta); color: var(--cz-ink2); min-height: 1em; }
106
+ .rp-box { border-radius: 16px; background: var(--cz-well); padding: 12px 14px 14px; font-size: var(--fs-meta); color: var(--cz-ink); }
107
+ .rp-box h6 { margin: 4px 2px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink3); }
108
+ .rp-box h6 + .rp-r { box-shadow: none; }
109
+ .rp-box h6:not(:first-child) { margin-top: 14px; }
110
+ .rp-box .rp-r { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 2px; box-shadow: inset 0 1px 0 var(--cz-hair); }
111
+ .rp-box .rp-r > span { flex: 1; min-width: 0; color: var(--cz-ink2); }
112
+ .rp-box .rp-r em { font-style: normal; text-align: right; }
113
+ .rp-box .rp-r em.w { color: var(--cz-risk); font-weight: var(--fw-strong); }
114
+ .rp-box .rp-i { cursor: pointer; }
115
+ .rp-box .rp-i.cur > span { font-weight: var(--fw-strong); color: var(--cz-ink); }
116
+ .rp-box .rp-sel { all: unset; cursor: pointer; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--cz-card); font-weight: var(--fw-strong); font-size: var(--fs-meta); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
117
+ .rp-box select.rp-sel { appearance: auto; }
118
+ .rp-box .rp-in { height: 28px; border-radius: 10px; border: 0; padding: 0 8px; font: inherit; font-size: var(--fs-meta); background: var(--cz-card); max-width: 170px; }
119
+ .rp-box p { margin: 12px 2px 0; font-size: var(--fs-meta); line-height: 1.45; color: var(--cz-ink3); }
120
+ .rp-box .rt-sw { justify-self: auto; }
121
+ /* a read, a job, a service or your task in the popup (cozy-routine-job.js): Instruction and Last runs beside the Setup box */
122
+ .rj-sec { margin: 0 0 18px; }
123
+ .rj-sec h6 { margin: 0 0 6px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink3); }
124
+ .rj-ins { box-sizing: border-box; width: 100%; min-height: 96px; resize: vertical; border: 0; border-radius: 12px; padding: 10px 12px; font: inherit; font-size: var(--fs-body); line-height: 1.5; color: var(--cz-ink); background: var(--cz-well); }
125
+ .rj-ins:focus { outline: 2px solid var(--cz-ink3); outline-offset: 1px; }
126
+ .rj-act { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
127
+ .rj-act .rp-y { all: unset; cursor: pointer; flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-ink); color: var(--cz-card); }
128
+ .rj-act .rp-y[disabled] { opacity: .5; cursor: default; }
129
+ .rj-hint { margin: 0; font-size: var(--fs-meta); line-height: 1.45; color: var(--cz-ink3); }
130
+ .rj-hint b { font-weight: var(--fw-strong); color: var(--cz-ink2); }
131
+ .rj-txt { margin: 0 0 6px; }
132
+ .rj-run { display: flex; gap: 12px; align-items: baseline; min-height: 32px; padding: 6px 0; box-shadow: inset 0 -1px 0 var(--cz-hair); font-size: var(--fs-meta); }
133
+ .rj-run span { flex: none; width: 110px; color: var(--cz-ink3); }
134
+ .rj-run em { font-style: normal; min-width: 0; overflow-wrap: anywhere; }
135
+ .rj-run.bad em { color: var(--cz-risk); }
136
+ .rj-undo, .rt-tundo { all: unset; cursor: pointer; font-weight: var(--fw-strong); text-decoration: underline; text-underline-offset: 2px; }
137
+ .rt-toast.on:has(.rt-tundo) { pointer-events: auto; }
138
+ .rj-act .rp-n { all: unset; cursor: pointer; flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); color: var(--cz-ink); }
139
+ .rp-ins h6 { display: flex; align-items: center; gap: 4px; min-height: 32px; }
140
+ .rp-ins h6 .rp-ed { margin-left: 0; width: 28px; height: 28px; }
141
+ .rp-insx { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--cz-ink2); }
142
+ /* ✕ on a proposed report: shown on hover, where the chevron is */
143
+ .rt-r .go .rt-drop { all: unset; cursor: pointer; width: 26px; height: 26px; margin: -6px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink3); }
144
+ .rt-r .go .rt-drop:hover { background: var(--cz-well); color: var(--cz-ink); }
145
+ .rt-r .go:has(.rt-drop) { opacity: 0; }
146
+ .rt-r.rt-row:hover .go:has(.rt-drop), .rt-r .go:has(.rt-drop:focus-visible) { opacity: 1; }
147
+ .rp-hold ol { margin: 0; padding-left: 20px; font-size: var(--fs-body); line-height: 1.5; }
148
+ .rp-hold li { margin: 0 0 4px; color: var(--cz-ink2); }
149
+ .rp-hold li b { font-weight: var(--fw-strong); color: var(--cz-ink); }
150
+ /* PMOS reads and PMOS jobs fold to their heading while a program or project is picked */
151
+ .rt-gf { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
152
+ .rt-gf svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
153
+ .rt-gf[aria-expanded="true"] svg { transform: rotate(90deg); }
154
+ .rt-gf em { font-style: normal; color: var(--cz-ink3); font-weight: var(--fw-regular); }
155
+ .rt-gf:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 4px; }
@@ -0,0 +1,335 @@
1
+ /* pm/cozy-routine.js — Routine, the place (initiative routine-place, slice 8 of the six-place navigation; board 11 on Exploring 2; build plan
2
+ * /mnt/project-files/nav-structure/build-plan.md; done test planning/done-tests/routine-place.md).
3
+ *
4
+ * One table of everything that repeats: Routine, Type, Product (two products or more), What it does, When, Next, and the same switch on every row. Groups: Waits for you,
5
+ * Reports, PMOS reads, PMOS jobs, Your tasks (pm/cozy-routine-model.js). The kinds above it filter the table; PMOS remembers the choice on this
6
+ * computer. "PMOS did" is one line on top; a press opens the full log in the popup, each line with its Undo. + opens Ask PMOS about a new
7
+ * routine. A row opens the one popup (pm/cozy-routine-pop.js). It replaces the Scheduled work list of Settings › Connectors, which now goes here.
8
+ *
9
+ * READS GET /api/workspaces, then per product GET /api/report-setups/routine?ws and GET /api/autonomy?ws; once GET /api/refresh and
10
+ * GET /api/schedules?all=1. Every product is read: Routine has no product choice (slice 1).
11
+ * WRITES, each the PM's press: a report's switch → POST /api/report-setups/pause | resume; a read or a job → POST /api/refresh/source { id, on };
12
+ * your task → POST /api/schedules/update { id, enabled }; the switch of a proposed report (Waits for you) → /api/report-setups/confirm; Undo in the log →
13
+ * POST /api/autonomy/undo. Nothing here runs a routine or sends anything. */
14
+ import { pmGet, pmPost } from './http.js';
15
+ import { mountNav } from './cozy-nav.js';
16
+ import { mountLivePill } from './cozy-live-pill.js';
17
+ import * as VW from './cozy-viewer.js';
18
+ import * as POP from './cozy-popup.js';
19
+ import { KINDS, routineRows, routineGroups, didLine, kindCounts, productsOf, productName } from './cozy-routine-model.js';
20
+ import * as PK from './cozy-pick.js'; // the saved product pick of Work, Today and Goals
21
+ import { scopeChipHtml, openScope, scopeWords, whenNames } from './scope-chip.js'; // one chip for products, programs and projects (shared with Events)
22
+ import { atOf } from './cozy-evmodel.js';
23
+ import { openReport } from './cozy-routine-pop.js';
24
+ import { openJob, openNew } from './cozy-routine-job.js'; // reads, jobs, services and your tasks: manage them in the popup (round 3 item 3)
25
+
26
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
27
+ const svg = (d, n = 18) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true"><path d="${d}"/></svg>`;
28
+ const I = {
29
+ reports: 'M4 20V10M10 20V4M16 20v-8M22 20H2', reads: 'M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6zM12 9.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 1 0 0-5',
30
+ jobs: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', tasks: 'M5 5h14v14H5zM8.5 12.5l2.5 2.5 4.5-5',
31
+ check: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18', chev: 'M9 6l6 6-6 6', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3',
32
+ };
33
+ const KIND_KEY = 'pmos.routine.kind';
34
+ const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* a private window */ } } };
35
+ const S = { ws: [], reports: [], refresh: [], tasks: [], done: [], kind: KINDS.some(([k]) => k === store.get(KIND_KEY)) ? store.get(KIND_KEY) : 'all', rows: [], busy: new Set(), gone: new Set(), read: false, err: '', pick: null, all: false, openG: new Set() };
36
+ const $ = (id) => document.getElementById(id);
37
+ /** A short line at the bottom. With `undo`, it carries an Undo button and stays 10 s, the time the undo has. */
38
+ const toast = (t, undo) => {
39
+ const el = $('toast'); if (!el) return;
40
+ el.textContent = t;
41
+ if (undo) { const b = document.createElement('button'); b.type = 'button'; b.className = 'rt-tundo'; b.textContent = 'Undo'; b.onclick = () => { undo(); el.classList.remove('on'); }; el.append(' ', b); }
42
+ el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), undo ? 10000 : 4200);
43
+ };
44
+ const say = (t) => { const el = $('rtMsg'); if (el) el.textContent = t || ''; };
45
+ const enc = encodeURIComponent;
46
+
47
+ mountNav('routine', document, {});
48
+ mountLivePill(document);
49
+
50
+ async function load() {
51
+ const w = await pmGet('/api/workspaces').catch(() => null);
52
+ // a product's display name, as Work shows it ("IDPF", not "pmos-idpf"); a work copy takes the name of its product
53
+ const raw = w && Array.isArray(w.workspaces) ? w.workspaces : [];
54
+ // the product a workspace is a copy of: a "⑂" work copy, or a linked git worktree of the same repository (a folder name such as "mainwt"
55
+ // never shows: the copy takes its product's name, and a product with no display name takes its repository's name)
56
+ const mainOf = (x) => {
57
+ const n = productName(x.name || x.id);
58
+ const up = (n !== (x.name || x.id) && raw.find((y) => y.name === n)) || (x.linked && x.repo_key && raw.find((y) => y !== x && !y.linked && y.repo_key === x.repo_key));
59
+ return up && up !== x ? up : null;
60
+ };
61
+ const own = (x) => x.label || (x.linked && x.repo_name) || x.name || x.id;
62
+ S.ws = raw.map((x) => { const m = mainOf(x); return { id: x.id, name: m ? own(m) : own(x), slug: x.name || x.id, main: m ? m.id : null }; });
63
+ const home = (raw.find((x) => x.home) || raw[0] || {}).id; // Horizon scan and Report finder are settings of the home product
64
+ const per = await Promise.all(S.ws.map((x) => Promise.all([pmGet('/api/report-setups/routine?ws=' + enc(x.id)).catch(() => null), pmGet('/api/autonomy?ws=' + enc(x.id)).catch(() => null)])));
65
+ const [rf, sc, pk, scan, rs, pg] = await Promise.all([pmGet('/api/refresh').catch(() => null), pmGet('/api/schedules?all=1').catch(() => null), PK.readPick().catch(() => null),
66
+ home ? pmGet('/api/scan/portfolio?ws=' + enc(home)).catch(() => null) : null, home ? pmGet('/api/report-setups?ws=' + enc(home)).catch(() => null) : null, pmGet('/api/programs').catch(() => null)]);
67
+ // the two PMOS jobs whose schedule lives with their own setting: Horizon scan and Report finder (round 2 note 3)
68
+ S.jobs = {
69
+ scan: scan && scan.setting ? { cadence: scan.setting.cadence, was: scan.setting.cadence !== 'off' ? scan.setting.cadence : 'daily', when: scan.setting.cadence === 'off' ? 'Off' : String(scan.schedule || ''), on: scan.setting.cadence !== 'off' } : null,
70
+ finder: rs && rs.finder ? { when: rs.finder.cadence === 'off' ? 'Off' : rs.finder.cadence === 'weekly' ? 'Every week' : String(rs.finder.cadence), next: rs.finder.cadence === 'off' ? null : rs.finder.next_run || null, on: rs.finder.cadence !== 'off' } : null,
71
+ };
72
+ S.pick = pk; S.home = home;
73
+ S.programs = pg && pg.ok && Array.isArray(pg.programs) ? pg.programs : [];
74
+ S.reports = []; S.done = [];
75
+ per.forEach(([r, a], i) => {
76
+ const x = S.ws[i];
77
+ if (r && r.ok) for (const row of r.reports || []) S.reports.push({ ...row, ws: x.id, wsName: x.name });
78
+ if (a && a.ok) for (const d of a.done || []) S.done.push({ ...d, ws: x.id });
79
+ });
80
+ S.done.sort((a, b) => String(b.at || '').localeCompare(String(a.at || '')));
81
+ S.refresh = rf && rf.ok && Array.isArray(rf.rows) ? rf.rows : [];
82
+ const nameOf = new Map(S.ws.map((x) => [x.id, x.name]));
83
+ S.tasks = sc && Array.isArray(sc.schedules) ? sc.schedules.map((t) => (t && t.ws ? { ...t, wsName: nameOf.get(t.ws) || t.ws } : t)) : [];
84
+ S.err = !w ? 'PMOS is not answering. The table shows again when it is back.' : '';
85
+ S.read = true;
86
+ draw();
87
+ }
88
+
89
+ function kindsHtml(n) {
90
+ // each kind says how many it holds (round 2); All needs no number, and a kind with none says none (zero is silence)
91
+ return KINDS.map(([k, l]) => `<button type="button" data-kind="${k}" aria-pressed="${S.kind === k}"${k !== 'all' && n ? ` aria-label="${esc(l + ', ' + (n[k] || 0))}"` : ''}>${esc(l)}${k !== 'all' && n && n[k] ? `<span class="rt-n">${n[k]}</span>` : ''}</button>`).join('');
92
+ }
93
+ /* ── the chip (round 2, PR 3): the shared scope chip of Events (pm/scope-chip.js). Products is the saved pick of Work; Programs and Projects
94
+ * are this page's own (kept on this computer). A report is under a program or a project when its setup says so (lib/routine-reports.js
95
+ * about). Reads and PMOS jobs serve every product, so they always show. "Show all" shows everything on this page once, and leaves the
96
+ * saved pick and the page's own choice as they are. ── */
97
+ const SCOPE_KEY = 'pmos.routine.scope.v1';
98
+ S.sel = (() => { try { const v = JSON.parse(store.get(SCOPE_KEY) || '{}'); return { programs: Array.isArray(v.programs) ? v.programs : [], projects: Array.isArray(v.projects) ? v.projects : [] }; } catch { return { programs: [], projects: [] }; } })();
99
+ const onSet = () => { const P = S.pick; if (!P || S.all) return null; const on = P.products.filter((p) => p.on).map((p) => p.ws); return on.length && on.length < P.products.length ? new Set(on) : null; };
100
+ /** The product a workspace belongs to in the pick: a work copy ("pmos-idpf ⑂ initiative/x") counts as its product. */
101
+ function prodWs(id) {
102
+ const P = S.pick; if (!P || !id) return id;
103
+ if (P.products.some((p) => p.ws === id)) return id;
104
+ const w = S.ws.find((x) => x.id === id);
105
+ return w && w.main && P.products.some((p) => p.ws === w.main) ? w.main : id;
106
+ }
107
+ const inPick = (on) => (x) => !on || !x.ws || on.has(prodWs(x.ws));
108
+ /** A row's tokens for the chip: its product, its project and the programs that hold that project, or its program. */
109
+ function scopeOfRow(r) {
110
+ if (!r.ws) return null; // a read or a PMOS job: every product
111
+ const pw = prodWs(r.ws), out = ['p:' + pw];
112
+ const a = r.kind === 'reports' ? (reportOf(r) || {}).about : null;
113
+ if (a && a.level === 'program') out.push('g:' + a.id);
114
+ if (a && a.level === 'initiative') {
115
+ out.push('j:' + pw + '|' + a.id);
116
+ for (const g of S.programs) if ((g.members || []).some((m) => m && m.initiative === a.id && (!m.ws || m.ws === pw || prodWs(m.ws) === pw))) out.push('g:' + g.id);
117
+ }
118
+ return out;
119
+ }
120
+ /** The chip's Programs and Projects: only the ones a routine is under; a project says its product and its count of routines. */
121
+ function groupsOf(rows) {
122
+ const n = new Map(), name = new Map();
123
+ for (const r of rows) for (const t of r.scope || []) if (t[0] !== 'p') {
124
+ n.set(t, (n.get(t) || 0) + 1);
125
+ if (t.startsWith('j:') && !name.has(t)) name.set(t, String(r.name).split(' · ')[0]); // a ready-made report is "<project> · <kind>"
126
+ }
127
+ const wsName = (id) => (S.ws.find((x) => x.id === id) || {}).name || '';
128
+ const programs = [...n.keys()].filter((t) => t.startsWith('g:')).map((t) => { const g = S.programs.find((x) => 'g:' + x.id === t); return { id: t, name: (g && g.title) || t.slice(2), n: n.get(t) }; });
129
+ const projects = [...n.keys()].filter((t) => t.startsWith('j:')).map((t) => ({ id: t, name: name.get(t) || t.split('|')[1], product: wsName(t.slice(2).split('|')[0]), n: n.get(t) }));
130
+ return { programs, projects };
131
+ }
132
+ const extraOn = () => !S.all && (S.sel.programs.length > 0 || S.sel.projects.length > 0);
133
+ const inScope = (r) => !extraOn() || !r.scope || [...S.sel.programs, ...S.sel.projects].some((t) => r.scope.includes(t));
134
+ function drawPick(groups) {
135
+ const host = $('rtPick'); if (!host) return;
136
+ const P = S.pick && S.pick.products && S.pick.products.length ? S.pick : null;
137
+ const has = (P && P.products.length > 1) || groups.programs.length || groups.projects.length;
138
+ const shown = S.all && P ? { ...P, products: P.products.map((p) => ({ ...p, on: true })) } : P;
139
+ host.innerHTML = has ? scopeChipHtml(shown, S.all ? { programs: [], projects: [] } : S.sel, { id: 'rtPickBtn', groups }) : '';
140
+ const chip = $('rtPickBtn'); if (!chip) return;
141
+ chip.onclick = (e) => {
142
+ e.stopPropagation();
143
+ openScope(chip, { P: S.pick, groups, sel: S.sel, unit: 'routines', onApply: (next) => {
144
+ S.sel = { programs: next.programs || [], projects: next.projects || [] }; S.all = false;
145
+ store.set(SCOPE_KEY, S.sel.programs.length || S.sel.projects.length ? JSON.stringify(S.sel) : null);
146
+ draw();
147
+ } });
148
+ };
149
+ }
150
+ whenNames().then(() => draw()); // product display names (IDPF, not a folder name) arrive after the first draw
151
+ addEventListener('pp:changed', (e) => { if (e.detail && e.detail.ok) { S.pick = e.detail; S.all = false; draw(); } });
152
+ /** The fold line at the end of Reports: one-time reports and loose drafts, opened as plain rows. */
153
+ const foldHtml = (f) => `<div class="rt-r rt-fold" role="row"><button type="button" role="cell" data-once aria-expanded="${!!S.once}">${svg(I.chev, 14)}<span>${esc(f.words)}</span></button></div>`;
154
+ /** The Product cell: the product, or the first and +N when one report is in several. Empty for what serves every product. */
155
+ const prodWords = (r) => (r.wss && r.wss.length ? r.wss[0] + (r.wss.length > 1 ? ' +' + (r.wss.length - 1) : '') : '');
156
+ function rowHtml(r, multi) {
157
+ const busy = S.busy.has(r.key);
158
+ // round 3 item 1: the same switch on every row. A proposed routine's switch is off, and turning it on is the yes.
159
+ const label = r.proposed ? r.name + ': proposed by PMOS. Press to start it' : r.name + (r.on ? ': on. Press to pause it' : ': paused. Press to start it again');
160
+ const end = r.on === null ? '<span></span>'
161
+ : `<button type="button" class="rt-sw" role="switch" aria-checked="${r.on}" data-sw="${esc(r.key)}" aria-label="${esc(label)}" title="${r.proposed ? 'Proposed. Turn on to start it' : r.on ? 'On' : 'Paused'}"${busy ? ' disabled' : ''}></button>`;
162
+ const next = r.late || (r.group === 'once' && r.draft) ? `<span class="w">${esc(r.next)}</span>` : esc(r.next);
163
+ return `<div class="rt-r rt-row${r.off ? ' off' : ''}" role="row" tabindex="0" data-key="${esc(r.key)}" aria-label="${esc('Open ' + r.name)}">`
164
+ + `<span class="ic" role="cell">${svg(I[r.kind], 17)}</span><span class="n" role="cell" title="${esc(r.name)}">${esc(r.name)}</span>`
165
+ + `<span class="c type" role="cell">${esc(r.type || '')}</span>${multi ? `<span class="c prod" role="cell" title="${esc((r.wss || []).join(', '))}">${esc(prodWords(r))}</span>` : ''}`
166
+ + `<span class="c does" role="cell" title="${esc(r.does)}">${esc(r.does)}</span><span class="c when" role="cell" title="${esc(r.when)}">${esc(r.when)}</span>`
167
+ + `<span class="c" role="cell">${next}</span><span role="cell" class="e">${end}</span>${r.proposed && r.kind === 'reports' ? `<span class="go" role="cell"><button type="button" class="rt-drop" data-drop="${esc(r.key)}" aria-label="${esc('Drop ' + r.name + '. PMOS stops proposing it')}" title="Drop this proposal">${svg(I.x, 14)}</button></span>` : `<span class="go" aria-hidden="true">${svg(I.chev, 14)}</span>`}</div>`;
168
+ }
169
+ function draw() {
170
+ const on = onSet();
171
+ const tag = (rows) => rows.map((r) => ({ ...r, scope: scopeOfRow(r) }));
172
+ const every = S.read ? tag(routineRows({ reports: S.reports, refresh: S.refresh, jobs: S.jobs, tasks: S.tasks, spaces: S.ws.flatMap((x) => [x.id, x.name]) })) : [];
173
+ const groups = groupsOf(every);
174
+ // drop a program or project that no routine is under any more, so the page never filters on one it cannot show
175
+ const known = new Set([...groups.programs, ...groups.projects].map((g) => g.id));
176
+ if (S.read) S.sel = { programs: S.sel.programs.filter((t) => known.has(t)), projects: S.sel.projects.filter((t) => known.has(t)) };
177
+ const mine = S.read ? tag(routineRows({ reports: S.reports.filter(inPick(on)), refresh: S.refresh, jobs: S.jobs, tasks: S.tasks.filter(inPick(on)), spaces: S.ws.flatMap((x) => [x.id, x.name]) })).filter(inScope) : [];
178
+ $('rtKinds').innerHTML = kindsHtml(S.read ? kindCounts(mine.filter((r) => r.group !== 'once' && (!r.unclear || S.unclear))) : null); // the routines, not the one-time reports
179
+ drawPick(groups);
180
+ const D = didLine(S.done);
181
+ $('rtDid').innerHTML = D ? `<button type="button" class="rt-did" data-did aria-label="${esc(D.text + ' Open the full log')}"><b aria-hidden="true">✦</b><span>${esc(D.text)} <em>${esc(D.sub)}</em></span>${svg(I.chev, 14)}</button>` : '';
182
+ if (!S.read) return;
183
+ S.rows = mine.filter((r) => !S.gone.has(r.key)); // a deleted task leaves at once; its delete is sent when the Undo has passed
184
+ // rows a PM cannot read are held back, counted in one grey line (round 3 item 2); one-time reports fold under Reports (item 1)
185
+ const unclear = mine.filter((r) => r.unclear && !S.unclear);
186
+ const G = routineGroups(S.rows.filter((r) => !unclear.includes(r)), S.kind);
187
+ const once = (S.kind === 'all' || S.kind === 'reports') ? mine.filter((r) => r.group === 'once' && !unclear.includes(r)) : [];
188
+ if (once.length) {
189
+ const nd = once.filter((r) => r.draft).length, no = once.length;
190
+ const words = (no === 1 ? 'One one-time report' : no + ' one-time reports') + (nd ? ' · ' + (nd === 1 ? 'one draft waits' : nd + ' drafts wait') : '');
191
+ const fold = { key: 'once', fold: true, words };
192
+ let g = G.find((x) => x.id === 'reports');
193
+ if (!g) { g = { id: 'reports', title: 'Reports', rows: [] }; const at = G.findIndex((x) => x.id !== 'wait'); G.splice(at < 0 ? G.length : at, 0, g); }
194
+ g.rows = g.rows.concat([fold], S.once ? once : []);
195
+ }
196
+ // a Product column only when the rows in view come from two products or more
197
+ const multi = productsOf(G.flatMap((g) => g.rows)).length > 1;
198
+ const hid = Math.max(0, routineGroups(every, S.kind).reduce((n, g) => n + g.rows.length, 0) - G.reduce((n, g) => n + g.rows.filter((r) => !r.fold && r.group !== 'once').length, 0));
199
+ // with a program or project picked, PMOS reads and PMOS jobs fold to their heading: they serve every product, so the picked
200
+ // work's own reports come first (design note on #1384). Pressing the heading opens the rows.
201
+ const shut = (g) => extraOn() && (g.id === 'reads' || g.id === 'jobs') && !S.openG.has(g.id) && g.rows.length > 0;
202
+ const head = (g) => shut(g) || (extraOn() && S.openG.has(g.id))
203
+ ? `<div class="rt-r rt-g" role="row"><div role="rowheader"><button type="button" class="rt-gf" data-gfold="${esc(g.id)}" aria-expanded="${!shut(g)}" aria-label="${esc((shut(g) ? "Show " : "Fold ") + g.title)}">${svg(I.chev, 14)}<span>${esc(g.title)}</span>${shut(g) ? `<em>${g.rows.length}</em>` : ''}</button></div></div>`
204
+ : `<div class="rt-r rt-g" role="row"><div role="rowheader">${esc(g.title)}</div></div>`;
205
+ const unLine = unclear.length ? `<p class="rt-hid">${unclear.length === 1 ? 'One row is' : unclear.length + ' rows are'} hidden because their source is unclear. <button type="button" data-unclear>Show</button></p>` : '';
206
+ const only = extraOn() ? scopeWords(on ? S.pick : null, S.sel, groups) : '';
207
+ const hidLine = unLine + (hid ? `<p class="rt-hid">${only ? esc('Showing ' + only + ' only. ') + (hid === 1 ? 'One routine is' : hid + ' routines are') : hid === 1 ? 'One routine of another product is' : hid + ' routines of other products are'} not shown. <button type="button" data-showall>Show all</button></p>` : '');
208
+ const f = document.activeElement && document.activeElement.closest && document.activeElement.closest('[data-key],[data-sw],[data-yes]');
209
+ const fk = f ? (f.dataset.key || f.dataset.sw || f.dataset.yes) + (f.dataset.sw ? ':sw' : f.dataset.yes ? ':yes' : '') : '';
210
+ $('rtTable').innerHTML = hidLine + (S.err ? `<p class="rt-quiet">${esc(S.err)}</p>`
211
+ : !G.length ? `<p class="rt-quiet">${S.kind === 'all' ? 'Nothing repeats yet. Tell PMOS what to do on a schedule with +.' : 'Nothing of this kind repeats.'}</p>`
212
+ : `<div class="rt-tbl${multi ? ' multi' : ''}" role="table" aria-label="Routine"><div class="rt-r rt-h" role="row"><span role="columnheader"><span class="vh">Kind</span></span><span role="columnheader">Routine</span><span role="columnheader" class="type">Type</span>${multi ? '<span role="columnheader" class="prod">Product</span>' : ''}<span role="columnheader" class="does">What it does</span><span role="columnheader" class="when">When</span><span role="columnheader">Next</span><span role="columnheader"><span class="vh">On</span></span></div>`
213
+ + G.map((g) => head(g) + (shut(g) ? '' : g.rows.map((r) => (r.fold ? foldHtml(r) : rowHtml(r, multi))).join(''))).join('') + '</div>'
214
+ + '<p class="rt-note">Everything that repeats, in one table. Press a row to open it. The switch pauses it.</p>');
215
+ if (fk) { const [k, x] = [fk.replace(/:(sw|yes)$/, ''), (/:(sw|yes)$/.exec(fk) || [])[1]]; const el = $('rtTable').querySelector(x === 'sw' ? `[data-sw="${CSS.escape(k)}"]` : x === 'yes' ? `[data-yes="${CSS.escape(k)}"]` : `[data-key="${CSS.escape(k)}"]`); if (el) el.focus(); }
216
+ }
217
+
218
+ const rowOf = (k) => S.rows.find((r) => r.key === k);
219
+ const reportOf = (r) => S.reports.find((x) => x.ws === r.ws && x.id === r.id);
220
+ const said = (x, ok) => (x && x.ok !== false && !(x && x.error) ? ok : 'Nothing changed: ' + ((x && x.error) || 'the server did not answer') + '.');
221
+ async function press(key, fn) {
222
+ if (S.busy.has(key)) return;
223
+ S.busy.add(key); draw();
224
+ try { say(await fn()); } finally { S.busy.delete(key); }
225
+ await load();
226
+ }
227
+ function flip(r) {
228
+ if (r.proposed) return yes(r);
229
+ return press(r.key, async () => {
230
+ const on = !r.on;
231
+ if (r.kind === 'reports') return said(await pmPost('/api/report-setups/' + (on ? 'resume' : 'pause'), { ws: r.ws || undefined, id: r.id }), r.name + (on ? ' is on.' : ' is paused. PMOS does not draft it until you turn it on.'));
232
+ if (r.kind === 'tasks') return said(await pmPost('/api/schedules/update', { id: r.id, enabled: on }), r.name + (on ? ' runs on its schedule again.' : ' is paused.'));
233
+ if (r.svc) return flipSvc(r, on);
234
+ return said(await pmPost('/api/refresh/source', { id: r.id, on }), r.name + (on ? ' is on.' : ' is paused. PMOS does not run it on its own.'));
235
+ });
236
+ }
237
+ /** One service of Your tools on or off, through the routes that exist: off is its own rhythm "only when you press read"; on follows Your
238
+ * tools again. When Your tools itself is off, turning one service on turns Your tools on and keeps the other services off. */
239
+ async function flipSvc(r, on) {
240
+ const tools = S.refresh.find((x) => x.id === r.parent) || { svcs: [] };
241
+ if (!on) return said(await pmPost('/api/refresh/source', { id: r.parent, svc: r.svc, schedule: { kind: 'manual' } }), r.name + ' is paused. PMOS reads it only when you press read.');
242
+ if (!tools.on) {
243
+ for (const v of tools.svcs || []) if (v.id !== r.svc && !(v.own && v.schedule && v.schedule.kind === 'manual')) await pmPost('/api/refresh/source', { id: r.parent, svc: v.id, schedule: { kind: 'manual' } });
244
+ const x = await pmPost('/api/refresh/source', { id: r.parent, on: true }); if (!(x && x.ok)) return said(x, '');
245
+ }
246
+ return said(await pmPost('/api/refresh/source', { id: r.parent, svc: r.svc, schedule: null }), r.name + ' is on.');
247
+ }
248
+ function yes(r) {
249
+ const rep = reportOf(r); if (!rep || !rep.act) return;
250
+ return press(r.key, async () => (rep.act.act === 'move'
251
+ ? said(await pmPost('/api/report-setups/move', { ws: r.ws || undefined, id: r.id, to: rep.act.to }), 'Moved ' + r.name + ' to ' + rep.act.toName + '. It drafts there from now on.')
252
+ : said(await pmPost('/api/report-setups/confirm', { ws: r.ws || undefined, id: r.id }), 'Started ' + r.name + '. Its drafts follow the definition as it is.')));
253
+ }
254
+ /** A delete or a drop with Undo: the row leaves at once, and the POST is sent when its 10 s of Undo have passed (or when the page closes),
255
+ * so Undo needs no route of its own. */
256
+ const LATER = new Map();
257
+ function later(r, url, body, words) {
258
+ const send = async (keep) => {
259
+ const x = await pmPost(url, body, keep ? { keepalive: true } : undefined).catch(() => null);
260
+ LATER.delete(r.key);
261
+ if (keep) return;
262
+ if (!x || !x.ok) toast(said(x, ''));
263
+ await load(); S.gone.delete(r.key); draw();
264
+ };
265
+ LATER.set(r.key, { send, t: setTimeout(() => send(false), 10000) });
266
+ S.gone.add(r.key); draw();
267
+ toast(words, () => { const L = LATER.get(r.key); if (L) clearTimeout(L.t); LATER.delete(r.key); S.gone.delete(r.key); draw(); });
268
+ }
269
+ addEventListener('pagehide', () => { for (const L of [...LATER.values()]) { clearTimeout(L.t); L.send(true); } });
270
+ function drop(r) { later(r, '/api/report-setups/drop', { ws: r.ws || undefined, id: r.id }, r.name + ' is dropped. PMOS stops proposing it.'); }
271
+
272
+ /** What the popup reads for a row: its record, and for a service the rhythm it shares with Your tools. `fresh` finds the row again after a load. */
273
+ function rawOf(row, fresh) {
274
+ const r = fresh ? rowOf(row.key) || row : row;
275
+ if (r.kind === 'tasks') return { row: r, raw: S.tasks.find((t) => t && t.id === r.id) || {} };
276
+ if (r.svc) {
277
+ const tools = S.refresh.find((x) => x.id === r.parent) || {}, v = (tools.svcs || []).find((x) => x.id === r.svc) || {};
278
+ // repeatOpts reads a service as { svc, own, parent_text, kinds, every, schedule }
279
+ const own = { ...v, svc: v.id, parent: tools.id, own: !!v.own, parent_text: tools.schedule_text, kinds: tools.kinds, every: tools.every, schedule: v.own ? v.schedule : tools.schedule };
280
+ return { row: r, raw: tools, tools, own };
281
+ }
282
+ return { row: r, raw: S.refresh.find((x) => x.id === r.id) || {}, extra: (S.jobs && S.jobs[r.id]) || null };
283
+ }
284
+ const H = { VW, http: { pmGet, pmPost }, reload: () => load(), toast, raw: rawOf, flipSvc: (r, on) => flipSvc(r, on),
285
+ get ws() { return S.home || undefined; },
286
+ later: (r, url, body, words) => later(r, url, body, words) };
287
+ function open(r) {
288
+ if (r.kind === 'reports') { const rep = reportOf(r); if (rep) openReport({ ...rep, name: r.name, key: r.key, proposed: !!r.proposed, when: rep.when || r.when }, H); return; }
289
+ openJob(r, H);
290
+ }
291
+
292
+ /* PMOS did, the full log: newest first, each with what it did, why, when, and Undo (POST /api/autonomy/undo) */
293
+ const logHtml = () => `<div class="rt-log" role="list">${S.done.map((d) => `<div class="l" role="listitem"><span><b>${esc(d.title || 'Done')}</b><em>${esc([d.reason, atOf(d.at)].filter(Boolean).join(' · '))}</em></span>`
294
+ + `<button type="button" data-undo="${esc(d.ref)}" data-ws="${esc(d.ws)}" aria-label="${esc('Undo: ' + (d.title || 'this'))}" title="Undo">${svg(I.undo, 16)}</button></div>`).join('') || '<p class="rt-quiet">Nothing in the last 14 days.</p>'}</div>`;
295
+ function openLog() {
296
+ VW.open({ id: 'routine:did', kind: 'PMOS did', title: 'PMOS did', icon: 'spark', pop: { id: 'routine-did', kind: 'routine', title: 'What PMOS did' },
297
+ render: (b) => {
298
+ b.innerHTML = logHtml();
299
+ b.addEventListener('click', async (e) => {
300
+ const u = e.target.closest('[data-undo]'); if (!u || u.disabled) return;
301
+ u.disabled = true;
302
+ const x = await pmPost('/api/autonomy/undo', { ws: u.dataset.ws || undefined, ref: u.dataset.undo }).catch(() => null);
303
+ if (!x || !x.ok) { u.disabled = false; toast((x && x.error) || 'It could not be undone. Nothing changed.'); return; }
304
+ toast('Undone.'); await load(); if (b.isConnected) b.innerHTML = logHtml();
305
+ });
306
+ } });
307
+ }
308
+
309
+ document.addEventListener('click', (e) => {
310
+ const k = e.target.closest('[data-kind]');
311
+ if (k) { S.kind = k.dataset.kind; store.set(KIND_KEY, S.kind); draw(); return; }
312
+ if (e.target.closest('[data-did]')) { openLog(); return; }
313
+ if (e.target.closest('[data-showall]')) { S.all = true; draw(); return; }
314
+ if (e.target.closest('[data-unclear]')) { S.unclear = true; draw(); return; }
315
+ if (e.target.closest('[data-once]')) { S.once = !S.once; draw(); return; }
316
+ const gf = e.target.closest('[data-gfold]');
317
+ if (gf) { const id = gf.dataset.gfold; if (S.openG.has(id)) S.openG.delete(id); else S.openG.add(id); draw(); return; }
318
+ // + a new routine (round 3 item 4): the popup with an empty setup, and Ask PMOS asks "What should repeat?". A phone keeps the chat's sheet.
319
+ if (e.target.closest('#rtAdd')) { import('./page-chat.js').then((M) => (window.innerWidth > 760 ? openNew(H, M.targetOf({ id: 'routine-new', kind: 'routine', title: 'New routine' }, S.home)) : M.openCos({ here: 'Routine' }))); return; }
320
+ const d = e.target.closest('[data-drop]'); if (d) { const r = rowOf(d.dataset.drop); if (r) drop(r); return; }
321
+ const s = e.target.closest('[data-sw]'); if (s) { const r = rowOf(s.dataset.sw); if (r && !s.disabled) flip(r); return; }
322
+ const y = e.target.closest('[data-yes]'); if (y) { const r = rowOf(y.dataset.yes); if (r && !y.disabled) yes(r); return; }
323
+ const row = e.target.closest('[data-key]'); if (row && $('rtTable').contains(row)) { const r = rowOf(row.dataset.key); if (r) open(r); }
324
+ });
325
+ document.addEventListener('keydown', (e) => {
326
+ if (e.key !== 'Enter' && e.key !== ' ') return;
327
+ const row = e.target.closest && e.target.closest('[data-key]');
328
+ if (!row || e.target !== row) return;
329
+ e.preventDefault(); const r = rowOf(row.dataset.key); if (r) open(r);
330
+ });
331
+ document.addEventListener('visibilitychange', () => { if (!document.hidden) load(); });
332
+ document.addEventListener('cz:chat-turn', () => load()); // PMOS changed something from the chat: the table shows it
333
+ setInterval(() => { if (!document.hidden && !POP.isOpen()) load(); }, 60000);
334
+ draw();
335
+ load();
@@ -3,7 +3,8 @@
3
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
4
  * module draws the two panels the rows open, inside the Connectors section (cozy-settings.js T.sub):
5
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).
6
+ * often and when it runs next. Since slice 8 of the six-place navigation it is the place Routine (pm/cozy-routine.js); the
7
+ * entry under the sources goes there (swEntry), and an old ?settings=scheduled link still opens this list.
7
8
  * job:<id> one source or job (lib/refresh.js id), like the scheduled task page of the Claude app: Active, Next run, Repeats,
8
9
  * Working hours only, PMOS's ✦ rhythm proposal (✓ saves it, ✕ hides it for today), History and ▶ Read now.
9
10
  * job:tools.<svc> one service of Your tools (batch 31 item 6, agreed design StA): its own rhythm or that of Your tools, Next run,
@@ -95,11 +96,11 @@ export function svcOf(rows, id) {
95
96
  what: 'PMOS reads ' + v.label + ' for the Briefing. ' + (v.own ? 'It has a rhythm of its own.' : 'It follows the rhythm of Your tools.') + ' Services due at the same minute share one session.' };
96
97
  }
97
98
  const rowOf = (id) => (S.rows || []).find((r) => r.id === id) || svcOf(S.rows, id);
98
- /** The quiet entry under the sources: "Scheduled work · 9 jobs". */
99
+ /** The one line under the sources that goes to Routine (slice 8 of the six-place navigation): Scheduled work left Settings and is a place now.
100
+ * The rows above it still open their own setup here (job:<id>). */
99
101
  export function swEntry() {
100
- const n = S.rows ? shown().filter((r) => r.on).length + (S.tasks || []).filter((x) => x.enabled !== false).length : null;
101
- 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>`
102
- + ib('data-ev-sw="list"', 'Open Scheduled work', CHEV) + '</div>';
102
+ return `<a class="ev-trow ev-fr ev-sw-entry" href="/premium-routine.html"><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 is in Routine</span><p class="ev-small ev-mut">Everything PMOS does on a schedule, with your reports and your own tasks</p></div>`
103
+ + `<span class="ev-ib" aria-hidden="true">${svg(CHEV, 18)}</span></a>`;
103
104
  }
104
105
  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>`;
105
106
 
@@ -1,5 +1,5 @@
1
1
  /* pm/cozy-settings.js — Settings (initiative premium-uncovered-features, E3; canvas EvSettings). A dialog over the page, its sections on the left:
2
- * General Theme (this device; the place menu's Theme row moved here, feedback batch 16 item 5), Viewer opens as a column or a popup
2
+ * General Theme (this device; the place menu's Theme row moved here, feedback batch 16 item 5). No "Viewer opens as": the popup is the one way (popup audit item 9)
3
3
  * (this device), Product (which products Home reads: the Products card), Your day (when the end-of-day card shows:
4
4
  * time.workEnd, POST /api/settings), Your impact (impact.on, POST /api/settings; canvas GmP1Switch, batch 16 item 7: the one switch
5
5
  * for Adler's leaf, the impact log and the weekly check; the page hears `pmos:impact`), Agents write to Jira (fixed: only after Commit).
@@ -69,7 +69,6 @@ async function pmSend(method, path, body) {
69
69
  const SECTIONS = [['general', 'General'], ['claude', 'PMOS'], ['connectors', 'Connectors'], ['workspaces', 'Workspaces'], ['updates', 'Updates']];
70
70
  const SUBS = { adler: 'Adler', jl: 'Jev and Laya', workflows: 'Workflows' }; // General › Extras and Workspaces › Workflows: each opens as a sub-panel of its section (U4, U1)
71
71
  const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
72
- const VIEWER_KEY = 'pmos.cz.viewer';
73
72
  const T = { el: null, sec: 'general', sub: '', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null, fresh: null, reading: '', note: {}, info: false, fold: false, dir: null, q: '', cat: 'all', wait: null, dress: false, more: false, bday: false, dset: {}, wkOpen: new Set(), wkMore: new Set(), arc: false };
74
73
  const cmpVer = (a, b) => { const x = String(a || '0').split('-')[0].split('.').map(Number), y = String(b || '0').split('-')[0].split('.').map(Number); for (let i = 0; i < 3; i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) < (y[i] || 0) ? -1 : 1; return 0; };
75
74
  const home = () => (T.ws && T.ws[0] ? T.st[T.ws[0].id] : null);
@@ -97,7 +96,6 @@ function general() {
97
96
  if (T.sub === 'adler') return T.dress ? dressSec() : subHead('adler') + adlerSec();
98
97
  if (T.sub === 'jl') return subHead('jl') + JL.html();
99
98
  const theme = (() => { const t = store.get('pmos.c3.theme'); return t === 'light' || t === 'dark' ? t : 'auto'; })();
100
- const vw = store.get(VIEWER_KEY) === 'popup' ? 'popup' : 'column';
101
99
  const P = T.prods, on = P ? P.filter((x) => x.on) : null;
102
100
  // the product the pages read (workspace grill W4): the page's own ?ws= first, then the pick; "No product" only when none is registered
103
101
  const pageWs = (() => { try { return new URLSearchParams(location.search).get('ws') || ''; } catch { return ''; } })();
@@ -107,7 +105,6 @@ function general() {
107
105
  const hours = []; for (let h = 13; h <= 23; h++) hours.push(h);
108
106
  const upd = ready() ? `<div class="ev-card ev-upd">${adFace('needs-you')}<span class="ev-pill y">Update</span><p><b>PMOS ${esc(latest())} is ready.</b> <span class="ev-mut">${esc(firstLine())}</span></p><button type="button" class="ev-btn sm" data-ev-go="updates">What's new</button><button type="button" class="ev-btn sm dark" data-ev-upd="update">${appBehind() ? 'Restart to update' : 'Update'}</button></div>` : '';
109
107
  return trow('Theme', 'Auto follows your computer', seg('Theme', 'theme', theme, [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']]))
110
- + trow('Viewer opens as', 'A column beside the chat, or a popup over it', seg('Viewer opens as', 'viewer', vw, [['column', 'Column'], ['popup', 'Popup']]))
111
108
  + trow('Product', 'Which products Today, Work and Goals read', `<button type="button" class="ev-pick" data-ev-products aria-haspopup="menu">${esc(pname)} ${svg(ICON.down, 14)}</button>`)
112
109
  + trow('Your day', 'When the end-of-day card shows', `<label class="ev-vh" for="evDay">Your day ends at</label><select id="evDay" class="ev-inp" data-ev-day>${hours.map((h) => `<option value="${h}"${h === end ? ' selected' : ''}>${pad(h)}:00</option>`).join('')}</select>`)
113
110
  + trow('Your impact', 'Adler’s sprout and your impact log. Only you see it. Nothing leaves PMOS.', sw(impactOn(), 'data-ev-impact', 'Your impact'))
@@ -630,7 +627,6 @@ async function press(e) {
630
627
  T.msg = r && r.ok ? (on ? 'Your impact is on.' : 'Your impact is off. The leaf, the log and the weekly check are hidden.') : (r && r.error) || 'Not saved.';
631
628
  draw(); return;
632
629
  }
633
- if (t.dataset.evSeg === 'viewer') { store.set(VIEWER_KEY, t.dataset.v); document.body.classList.toggle('ev-vw-popup', t.dataset.v === 'popup'); draw(); return; }
634
630
  // the one product pick (batch 12 item 5): the same list as the chip on Home, Board and Insights, under this row
635
631
  if ('evProducts' in t.dataset) {
636
632
  const PP = await import('./cozy-pick.js'), P = await PP.readPick();