@clagentic/console 1.12.0-beta.3 → 1.13.0-beta.1

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 (243) hide show
  1. package/README.md +7 -1
  2. package/bin/cli.js +18 -15
  3. package/lib/agent-roster-ws.js +38 -13
  4. package/lib/agent-roster.js +111 -12
  5. package/lib/agents.js +68 -33
  6. package/lib/atomic-install.js +334 -0
  7. package/lib/build-changes.js +33 -4
  8. package/lib/build-sha.json +2 -2
  9. package/lib/build-update-offer.js +12 -0
  10. package/lib/chat-width.js +31 -0
  11. package/lib/cli/agent-usage.js +126 -0
  12. package/lib/cli/arg-validation.js +1 -1
  13. package/lib/cli/compact-output.js +69 -0
  14. package/lib/cli/ipc-subcommands.js +92 -67
  15. package/lib/cli/output.js +28 -0
  16. package/lib/cli/restart-verb.js +132 -0
  17. package/lib/cli/schedule-input-subcommands.js +45 -8
  18. package/lib/cli/session-subcommands.js +37 -11
  19. package/lib/cli/settings-subcommands.js +74 -0
  20. package/lib/cli-transcript-title.js +56 -3
  21. package/lib/client-files.js +79 -0
  22. package/lib/daemon.js +100 -28
  23. package/lib/default-avatar-color.js +4 -0
  24. package/lib/drain.js +58 -10
  25. package/lib/mcp-tool-input.js +2 -2
  26. package/lib/model-families.js +49 -1
  27. package/lib/notify/type-registry.js +4 -0
  28. package/lib/notify/types.js +7 -4
  29. package/lib/pages.js +13 -63
  30. package/lib/permission-summary.js +12 -16
  31. package/lib/plan-usage-reader.js +70 -0
  32. package/lib/project-connection.js +4 -2
  33. package/lib/project-filesystem.js +6 -7
  34. package/lib/project-notifications.js +55 -8
  35. package/lib/project-prompt-expiry-settings.js +42 -0
  36. package/lib/project-sessions.js +52 -0
  37. package/lib/project-settings-gate.js +98 -0
  38. package/lib/project-user-mention.js +3 -2
  39. package/lib/project.js +1 -1
  40. package/lib/prompt-expiry-settings.js +49 -0
  41. package/lib/prompt-expiry.js +24 -3
  42. package/lib/prompt-kinds/codecs.js +6 -2
  43. package/lib/public/app.js +36 -36
  44. package/lib/public/css/admin.css +156 -170
  45. package/lib/public/css/agent-messages.css +24 -24
  46. package/lib/public/css/agent-picker.css +90 -38
  47. package/lib/public/css/agent-roster.css +61 -27
  48. package/lib/public/css/at-agents.css +10 -10
  49. package/lib/public/css/base.css +207 -184
  50. package/lib/public/css/chat-layout.css +228 -0
  51. package/lib/public/css/command-palette.css +86 -88
  52. package/lib/public/css/diagnostics.css +78 -204
  53. package/lib/public/css/diff.css +10 -10
  54. package/lib/public/css/filebrowser.css +32 -60
  55. package/lib/public/css/home-hub.css +100 -100
  56. package/lib/public/css/icon-strip.css +195 -238
  57. package/lib/public/css/input.css +191 -212
  58. package/lib/public/css/login-panel.css +16 -16
  59. package/lib/public/css/loop.css +96 -187
  60. package/lib/public/css/mention.css +49 -110
  61. package/lib/public/css/menus.css +162 -169
  62. package/lib/public/css/messages.css +49 -123
  63. package/lib/public/css/mobile-nav.css +207 -264
  64. package/lib/public/css/notifications-center.css +45 -124
  65. package/lib/public/css/overlay.css +269 -0
  66. package/lib/public/css/overlays.css +134 -156
  67. package/lib/public/css/playbook.css +41 -41
  68. package/lib/public/css/profile.css +43 -112
  69. package/lib/public/css/rewind.css +112 -112
  70. package/lib/public/css/scheduler-modal.css +27 -135
  71. package/lib/public/css/scheduler.css +204 -210
  72. package/lib/public/css/server-settings.css +173 -239
  73. package/lib/public/css/session-search.css +20 -20
  74. package/lib/public/css/settings-nav.css +197 -0
  75. package/lib/public/css/sidebar.css +213 -304
  76. package/lib/public/css/skills.css +121 -135
  77. package/lib/public/css/sticky-notes.css +114 -200
  78. package/lib/public/css/stt.css +17 -26
  79. package/lib/public/css/team-panel.css +36 -36
  80. package/lib/public/css/team-view.css +9 -9
  81. package/lib/public/css/title-bar.css +83 -100
  82. package/lib/public/css/tooltip.css +10 -10
  83. package/lib/public/css/user-settings.css +78 -131
  84. package/lib/public/css/user-shell.css +125 -29
  85. package/lib/public/index.html +178 -177
  86. package/lib/public/manifest.json +0 -2
  87. package/lib/public/modules/admin.js +54 -92
  88. package/lib/public/modules/agent-avatar.js +134 -3
  89. package/lib/public/modules/agent-messages.js +2 -1
  90. package/lib/public/modules/agent-picker.js +23 -21
  91. package/lib/public/modules/agent-roster-groups.js +128 -0
  92. package/lib/public/modules/agent-roster.js +40 -11
  93. package/lib/public/modules/app-connection.js +13 -1
  94. package/lib/public/modules/app-cursors.js +9 -9
  95. package/lib/public/modules/app-favicon.js +8 -16
  96. package/lib/public/modules/app-header.js +28 -19
  97. package/lib/public/modules/app-history-replay.js +67 -4
  98. package/lib/public/modules/app-home-hub.js +15 -0
  99. package/lib/public/modules/app-loop-ui.js +41 -47
  100. package/lib/public/modules/app-loop-wizard.js +9 -10
  101. package/lib/public/modules/app-messages.js +32 -36
  102. package/lib/public/modules/app-misc.js +22 -92
  103. package/lib/public/modules/app-modals.js +98 -0
  104. package/lib/public/modules/app-notifications.js +124 -135
  105. package/lib/public/modules/app-panels.js +28 -32
  106. package/lib/public/modules/app-projects.js +30 -40
  107. package/lib/public/modules/app-rate-limit.js +26 -9
  108. package/lib/public/modules/app-rendering.js +128 -110
  109. package/lib/public/modules/app-skills-install.js +6 -4
  110. package/lib/public/modules/assistant-identity.js +55 -0
  111. package/lib/public/modules/at-agents.js +3 -0
  112. package/lib/public/modules/build-guard.js +25 -11
  113. package/lib/public/modules/chat-width-choice.js +75 -0
  114. package/lib/public/modules/chat-width-prefs.js +52 -0
  115. package/lib/public/modules/chat-width.js +102 -0
  116. package/lib/public/modules/collapsible-text.js +36 -4
  117. package/lib/public/modules/command-palette.js +28 -34
  118. package/lib/public/modules/context-sources.js +3 -5
  119. package/lib/public/modules/diagnostics.js +130 -129
  120. package/lib/public/modules/info-panel.js +31 -0
  121. package/lib/public/modules/injected-identity.js +8 -8
  122. package/lib/public/modules/input-list-menu.js +39 -0
  123. package/lib/public/modules/input.js +22 -21
  124. package/lib/public/modules/markdown.js +10 -11
  125. package/lib/public/modules/mcp-ui.js +4 -14
  126. package/lib/public/modules/mention.js +100 -229
  127. package/lib/public/modules/message-header.js +80 -0
  128. package/lib/public/modules/message-participants.js +39 -0
  129. package/lib/public/modules/mobile-action-sheet.js +46 -0
  130. package/lib/public/modules/mobile-nav-sheet.js +104 -0
  131. package/lib/public/modules/model-families.js +41 -4
  132. package/lib/public/modules/note-order.js +39 -0
  133. package/lib/public/modules/notifications.js +35 -52
  134. package/lib/public/modules/overlay-history.js +73 -19
  135. package/lib/public/modules/overlay-menu.js +123 -0
  136. package/lib/public/modules/overlay-modal.js +186 -0
  137. package/lib/public/modules/overlay-registry.js +392 -0
  138. package/lib/public/modules/overlay-stack.js +110 -0
  139. package/lib/public/modules/overlay.js +117 -0
  140. package/lib/public/modules/popover-position.js +18 -2
  141. package/lib/public/modules/preference-sync.js +28 -0
  142. package/lib/public/modules/profile.js +24 -49
  143. package/lib/public/modules/project-settings.js +27 -172
  144. package/lib/public/modules/prompt-expiry-controls.js +46 -0
  145. package/lib/public/modules/prompt-kinds/command-summary.js +149 -0
  146. package/lib/public/modules/prompt-kinds/permission.js +70 -92
  147. package/lib/public/modules/prompts.js +1 -2
  148. package/lib/public/modules/qrcode.js +6 -21
  149. package/lib/public/modules/queued-button.js +15 -2
  150. package/lib/public/modules/rewind.js +9 -3
  151. package/lib/public/modules/schedule-time.js +32 -7
  152. package/lib/public/modules/scheduled-outbox.js +51 -18
  153. package/lib/public/modules/scheduler-config.js +87 -127
  154. package/lib/public/modules/scheduler.js +29 -26
  155. package/lib/public/modules/serialized-save.js +79 -0
  156. package/lib/public/modules/server-settings.js +75 -65
  157. package/lib/public/modules/session-grants.js +16 -19
  158. package/lib/public/modules/session-list-avatars.js +98 -0
  159. package/lib/public/modules/session-vendor-state.js +86 -0
  160. package/lib/public/modules/settings-access.js +35 -0
  161. package/lib/public/modules/settings-hub.js +125 -0
  162. package/lib/public/modules/settings-nav.js +182 -0
  163. package/lib/public/modules/shell-line.js +24 -0
  164. package/lib/public/modules/sidebar-mobile.js +151 -195
  165. package/lib/public/modules/sidebar-projects.js +88 -129
  166. package/lib/public/modules/sidebar-sessions.js +66 -34
  167. package/lib/public/modules/sidebar.js +2 -2
  168. package/lib/public/modules/skills.js +11 -26
  169. package/lib/public/modules/sticky-notes.js +19 -16
  170. package/lib/public/modules/stt.js +9 -23
  171. package/lib/public/modules/terminal.js +86 -90
  172. package/lib/public/modules/theme-choice.js +126 -0
  173. package/lib/public/modules/theme-colors.js +19 -0
  174. package/lib/public/modules/theme-prefs.js +121 -0
  175. package/lib/public/modules/theme.js +227 -605
  176. package/lib/public/modules/tool-palette.js +7 -17
  177. package/lib/public/modules/tools.js +8 -10
  178. package/lib/public/modules/user-settings.js +59 -115
  179. package/lib/public/modules/user-shell.js +9 -2
  180. package/lib/public/modules/utils.js +10 -12
  181. package/lib/public/modules/vendor-picker.js +4 -2
  182. package/lib/public/modules/vendor-registry.js +1 -2
  183. package/lib/public/style.css +3 -1
  184. package/lib/public/sw.js +9 -2
  185. package/lib/public/theme-core.js +411 -0
  186. package/lib/request-body.js +70 -0
  187. package/lib/sdk-bridge.js +227 -88
  188. package/lib/sdk-message-processor.js +44 -16
  189. package/lib/server-admin.js +198 -200
  190. package/lib/server-auth.js +16 -13
  191. package/lib/server-dm.js +4 -3
  192. package/lib/server-settings.js +177 -130
  193. package/lib/server.js +87 -36
  194. package/lib/session-background-tasks.js +79 -0
  195. package/lib/session-directory.js +138 -13
  196. package/lib/session-input-ipc.js +2 -0
  197. package/lib/session-input.js +39 -5
  198. package/lib/session-list-avatars.js +16 -0
  199. package/lib/session-reclaim.js +37 -25
  200. package/lib/session-vendor.js +37 -0
  201. package/lib/sessions.js +99 -34
  202. package/lib/settings-ipc.js +60 -0
  203. package/lib/settings-registry.js +86 -0
  204. package/lib/terminal-manager.js +17 -5
  205. package/lib/theme-files.js +132 -0
  206. package/lib/theme-seed.js +136 -0
  207. package/lib/themes/clagentic-dark.json +13 -6
  208. package/lib/themes/clagentic-light.json +12 -5
  209. package/lib/updater.js +6 -4
  210. package/lib/usage-store.js +97 -10
  211. package/lib/users-preferences.js +118 -19
  212. package/lib/users.js +19 -10
  213. package/lib/vendor-catalog.js +130 -0
  214. package/lib/ws-schema.js +4 -2
  215. package/lib/yoke/adapters/claude.js +81 -1
  216. package/lib/yoke/adapters/codex-user-shell.js +87 -23
  217. package/lib/yoke/adapters/codex.js +89 -5
  218. package/lib/yoke/codex-binary.js +59 -0
  219. package/package.json +1 -1
  220. package/scripts/check-test-count.js +5 -0
  221. package/scripts/install-local-test.js +50 -9
  222. package/scripts/write-build-sha.js +18 -2
  223. package/lib/public/css/channel-layout.css +0 -329
  224. package/lib/themes/ayu-light.json +0 -9
  225. package/lib/themes/catppuccin-latte.json +0 -9
  226. package/lib/themes/catppuccin-mocha.json +0 -9
  227. package/lib/themes/dracula.json +0 -9
  228. package/lib/themes/everforest-light.json +0 -9
  229. package/lib/themes/everforest.json +0 -9
  230. package/lib/themes/github-light.json +0 -9
  231. package/lib/themes/gruvbox-dark.json +0 -9
  232. package/lib/themes/gruvbox-light.json +0 -9
  233. package/lib/themes/monokai.json +0 -9
  234. package/lib/themes/nord-light.json +0 -9
  235. package/lib/themes/nord.json +0 -9
  236. package/lib/themes/one-dark.json +0 -9
  237. package/lib/themes/one-light.json +0 -9
  238. package/lib/themes/rose-pine-dawn.json +0 -9
  239. package/lib/themes/rose-pine.json +0 -9
  240. package/lib/themes/solarized-dark.json +0 -9
  241. package/lib/themes/solarized-light.json +0 -9
  242. package/lib/themes/tokyo-night-light.json +0 -9
  243. package/lib/themes/tokyo-night.json +0 -9
@@ -11,10 +11,11 @@
11
11
 
12
12
  import { addToMessages, scrollToBottom } from './app-rendering.js';
13
13
  import { sendScheduledNow, cancelScheduledInput } from './scheduled-input-actions.js';
14
- import { countdownText } from './schedule-time.js';
14
+ import { countdownText, fireTimeParts } from './schedule-time.js';
15
15
  import { currentSendNowState, sendNowLabel } from './send-now.js';
16
16
  import { queuedButton } from './queued-button.js';
17
- import { buildCollapsibleText, needsCollapse, isNonTypedInput } from './collapsible-text.js';
17
+ import { buildCollapsibleText, isNonTypedInput } from './collapsible-text.js';
18
+ import { refreshIcons } from './icons.js';
18
19
 
19
20
  var containerEl = null;
20
21
  var countdowns = [];
@@ -28,9 +29,22 @@ var inFlight = {};
28
29
  var failures = {};
29
30
  var requestSeq = 0;
30
31
 
31
- function tickCountdowns() {
32
- var now = Date.now();
33
- countdowns.forEach(function (c) { c.el.textContent = countdownText(c.input, now); });
32
+ // The one ticking source for every row: the expanded meta line and the collapsed
33
+ // line's fire time are both painted from here, so there is one timer however many
34
+ // cards are drawn. `now` is injectable for tests.
35
+ function paintFireTime(el, input, now) {
36
+ var parts = fireTimeParts(input, now);
37
+ el.textContent = parts.text;
38
+ el.title = parts.title;
39
+ el.setAttribute("aria-label", parts.label);
40
+ }
41
+
42
+ export function tickScheduledOutbox(now) {
43
+ var at = now == null ? Date.now() : now;
44
+ countdowns.forEach(function (c) {
45
+ c.el.textContent = countdownText(c.input, at);
46
+ if (c.fireEl) paintFireTime(c.fireEl, c.input, at);
47
+ });
34
48
  }
35
49
 
36
50
  // Fire now follows the capability table like Send now of the other kinds; a
@@ -77,7 +91,10 @@ function request(id, send) {
77
91
  }
78
92
  }
79
93
 
80
- function buildRow(input) {
94
+ // opts.fireTime (default true): the collapsed line carries the fire time, time
95
+ // remaining with the absolute time in its title and accessible name.
96
+ function buildRow(input, opts) {
97
+ var showFireTime = !opts || opts.fireTime !== false;
81
98
  var el = document.createElement("div");
82
99
  el.className = "shell-queued scheduled-queued";
83
100
  el.setAttribute("data-id", input.id);
@@ -86,6 +103,12 @@ function buildRow(input) {
86
103
  tag.className = "shell-queued-tag";
87
104
  tag.textContent = "Scheduled";
88
105
 
106
+ var fireAt = null;
107
+ if (showFireTime) {
108
+ fireAt = document.createElement("span");
109
+ fireAt.className = "scheduled-queued-fire-at";
110
+ }
111
+
89
112
  var when = document.createElement("span");
90
113
  when.className = "scheduled-queued-time";
91
114
 
@@ -93,8 +116,15 @@ function buildRow(input) {
93
116
  body.className = "shell-queued-text";
94
117
  var toggle = null;
95
118
  // A schedule is input the console pushes in later: the same rule as its delivery.
96
- if (isNonTypedInput({ initiator: "scheduled", senderKind: "automation" }) && needsCollapse(input.text)) {
97
- var collapsible = buildCollapsibleText(input.text);
119
+ // The card is one line, so Expand is always there: the next time, cadence and
120
+ // remaining count (when) are shown only in the expanded view.
121
+ if (isNonTypedInput({ initiator: "scheduled", senderKind: "automation" })) {
122
+ var collapsible = buildCollapsibleText(input.text, {
123
+ lines: 1,
124
+ size: "compact",
125
+ controls: "inline",
126
+ onChange: function (collapsed) { el.classList.toggle("is-expanded", !collapsed); },
127
+ });
98
128
  body.appendChild(collapsible.el);
99
129
  toggle = collapsible.button;
100
130
  } else {
@@ -103,18 +133,18 @@ function buildRow(input) {
103
133
 
104
134
  var actions = document.createElement("span");
105
135
  actions.className = "shell-queued-actions";
106
- var fireBtn = queuedButton(sendNowLabel("scheduled"), "shell-queued-send-now scheduled-queued-fire");
136
+ var fireBtn = queuedButton(sendNowLabel("scheduled"), "shell-queued-send-now scheduled-queued-fire", { icon: "play" });
107
137
  fireBtn.addEventListener("click", function () {
108
138
  var st = currentSendNowState("scheduled");
109
139
  if (st.mode === "disabled") return;
110
140
  request(input.id, sendScheduledNow);
111
141
  });
112
- var cancelBtn = queuedButton("Cancel", "shell-queued-cancel scheduled-queued-cancel");
142
+ var cancelBtn = queuedButton("Cancel", "shell-queued-cancel scheduled-queued-cancel", { icon: "x" });
113
143
  cancelBtn.addEventListener("click", function () { request(input.id, cancelScheduledInput); });
114
144
  actions.appendChild(fireBtn);
115
145
  actions.appendChild(cancelBtn);
116
146
  if (toggle) {
117
- toggle.classList.add("shell-queued-btn");
147
+ toggle.classList.add("shell-queued-btn", "shell-queued-icon-btn");
118
148
  actions.appendChild(toggle);
119
149
  }
120
150
  paintFireNow(fireBtn);
@@ -124,11 +154,12 @@ function buildRow(input) {
124
154
  errorEl.setAttribute("role", "alert");
125
155
 
126
156
  el.appendChild(tag);
127
- el.appendChild(when);
128
157
  el.appendChild(body);
158
+ if (fireAt) el.appendChild(fireAt);
129
159
  el.appendChild(actions);
160
+ el.appendChild(when);
130
161
  el.appendChild(errorEl);
131
- var row = { id: input.id, el: el, when: when, fireBtn: fireBtn, cancelBtn: cancelBtn, errorEl: errorEl };
162
+ var row = { id: input.id, el: el, when: when, fireAt: fireAt, fireBtn: fireBtn, cancelBtn: cancelBtn, errorEl: errorEl };
132
163
  paintBusy(row, input.id);
133
164
  return row;
134
165
  }
@@ -182,8 +213,9 @@ export function clearScheduledOutboxOnReconnect() {
182
213
  * Redraws the outbox rows of the session on screen from the server's list:
183
214
  * one row per armed input, in the list's order. Replaces what was drawn.
184
215
  * @param {Array<object>} inputs the service's armed inputs for the session
216
+ * @param {{fireTime?: boolean}} [opts] fireTime: false leaves the fire time off the collapsed line
185
217
  */
186
- export function renderScheduledOutbox(inputs) {
218
+ export function renderScheduledOutbox(inputs, opts) {
187
219
  removeScheduledOutbox();
188
220
  // A schedule the server no longer lists has left: nothing of it stays waiting.
189
221
  var listed = {};
@@ -194,16 +226,17 @@ export function renderScheduledOutbox(inputs) {
194
226
  var container = document.createElement("div");
195
227
  container.className = "scheduled-msgs";
196
228
  inputs.forEach(function (input) {
197
- var row = buildRow(input);
229
+ var row = buildRow(input, opts);
198
230
  container.appendChild(row.el);
199
231
  rows.push(row);
200
- countdowns.push({ el: row.when, input: input });
232
+ countdowns.push({ el: row.when, fireEl: row.fireAt, input: input });
201
233
  });
202
234
  addToMessages(container);
203
235
  containerEl = container;
236
+ refreshIcons(container);
204
237
  scrollToBottom();
205
- tickCountdowns();
206
- countdownTimer = setInterval(tickCountdowns, 1000);
238
+ tickScheduledOutbox();
239
+ countdownTimer = setInterval(tickScheduledOutbox, 1000);
207
240
  }
208
241
 
209
242
  /** Forgets the requests in flight and their failures (the view left the session). */
@@ -5,7 +5,8 @@
5
5
  */
6
6
 
7
7
  import { showToast } from './utils.js';
8
- import { positionPopover } from './popover-position.js';
8
+ import { showOverlay } from './overlay.js';
9
+ import { closeMenu, isMenuOpen } from './overlay-registry.js';
9
10
 
10
11
  // Constants (duplicated from scheduler.js — small arrays)
11
12
  var DAY_NAMES = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
@@ -14,9 +15,16 @@ var MONTH_NAMES = [
14
15
  "July", "August", "September", "October", "November", "December"
15
16
  ];
16
17
 
18
+ // With no anchor cell the create popover opens at the content area's centre:
19
+ // half its 360 px width left of centre, 60 px below the area's top.
20
+ var CREATE_POPOVER_HALF_WIDTH = 180;
21
+ var CREATE_POPOVER_DROP = 60;
22
+
17
23
  // Module-private state
18
24
  var configCtx = null;
19
25
  var previewEl = null;
26
+ // The open delete dialog (overlay.js); null until it is first opened.
27
+ var deleteHandle = null;
20
28
  var createEditingRecId = null;
21
29
  var createSelectedDate = null;
22
30
  var createRecurrence = "none";
@@ -44,16 +52,13 @@ export function setupCreateModal() {
44
52
  var createPopover = configCtx.getCreatePopover();
45
53
  if (!createPopover) return;
46
54
 
47
- // Close
48
- document.getElementById("sched-create-cancel").addEventListener("click", function () { closeCreateModal(); });
49
-
50
55
  // Color picker
51
56
  var colorBtn = document.getElementById("sched-create-color-btn");
52
57
  var colorPalette = document.getElementById("sched-create-color-palette");
53
58
  if (colorBtn && colorPalette) {
54
59
  colorBtn.addEventListener("click", function (e) {
55
60
  e.stopPropagation();
56
- colorPalette.classList.toggle("hidden");
61
+ toggleCreateDropdown(colorPalette, colorBtn);
57
62
  });
58
63
  var swatches = colorPalette.querySelectorAll(".sched-color-swatch");
59
64
  for (var i = 0; i < swatches.length; i++) {
@@ -68,7 +73,7 @@ export function setupCreateModal() {
68
73
  for (var j = 0; j < all.length; j++) {
69
74
  all[j].classList.toggle("active", all[j].dataset.color === c);
70
75
  }
71
- colorPalette.classList.add("hidden");
76
+ closeMenu(colorPalette);
72
77
  });
73
78
  }
74
79
  }
@@ -101,20 +106,10 @@ export function setupCreateModal() {
101
106
  if (taskBtn && taskList) {
102
107
  taskBtn.addEventListener("click", function (e) {
103
108
  e.stopPropagation();
104
- taskList.classList.toggle("hidden");
109
+ toggleCreateDropdown(taskList, taskBtn, true);
105
110
  });
106
111
  }
107
112
 
108
- // Close task dropdown on outside click
109
- document.addEventListener("click", function (e) {
110
- var tl = document.getElementById("sched-create-task-list");
111
- if (tl && !tl.classList.contains("hidden")) {
112
- if (!tl.contains(e.target) && !e.target.closest("#sched-create-task-btn")) {
113
- tl.classList.add("hidden");
114
- }
115
- }
116
- });
117
-
118
113
  // Review checkbox toggle
119
114
  var reviewCheck = document.getElementById("sched-review-check");
120
115
  if (reviewCheck) {
@@ -311,16 +306,23 @@ export function setupCreateModal() {
311
306
  var endBtn = document.getElementById("sched-custom-end-btn");
312
307
  var endList = document.getElementById("sched-custom-end-list");
313
308
 
309
+ // #sched-custom-end-list lives in index.html: the shared component adopts it,
310
+ // hides it on close (retain) and tracks it in the open-menu registry.
311
+ var endListMenu = null;
312
+ function closeEndList() {
313
+ if (endListMenu) endListMenu.close();
314
+ }
315
+
314
316
  endBtn.addEventListener("click", function (e) {
315
317
  e.stopPropagation();
316
- if (endList.classList.contains("hidden")) {
317
- endList.classList.remove("hidden");
318
+ if (endListMenu && endListMenu.isOpen()) {
319
+ closeEndList();
320
+ } else {
318
321
  // Four-edge clamp (lr-a10a): the prior bottom-flip-only logic could
319
322
  // leave the flipped dropdown with top < 0 when the button sits near
320
323
  // the top of a short viewport.
321
- positionPopover(endList, endBtn, { placement: "below", gap: 4 });
322
- } else {
323
- endList.classList.add("hidden");
324
+ // Owned by the create popover it sits in: opening it leaves the popover open.
325
+ endListMenu = showOverlay({ kind: "menu", el: endList, retain: true, parent: configCtx.getCreatePopover(), anchor: endBtn, opener: endBtn, placement: "below", gap: 4 });
324
326
  }
325
327
  });
326
328
 
@@ -338,7 +340,7 @@ export function setupCreateModal() {
338
340
  for (var j = 0; j < endItems.length; j++) {
339
341
  endItems[j].classList.toggle("active", endItems[j] === item);
340
342
  }
341
- endList.classList.add("hidden");
343
+ closeEndList();
342
344
 
343
345
  // Toggle conditional inputs
344
346
  var dateBtn2 = document.getElementById("sched-custom-end-date-btn");
@@ -364,15 +366,6 @@ export function setupCreateModal() {
364
366
  })(endItems[ei]);
365
367
  }
366
368
 
367
- // Close end dropdown on outside click
368
- document.addEventListener("click", function (e) {
369
- if (endList && !endList.classList.contains("hidden")) {
370
- if (!endList.contains(e.target) && !endBtn.contains(e.target)) {
371
- endList.classList.add("hidden");
372
- }
373
- }
374
- });
375
-
376
369
  // Custom repeat: End date button -> toggle inline calendar
377
370
  document.getElementById("sched-custom-end-date-btn").addEventListener("click", function (e) {
378
371
  e.stopPropagation();
@@ -467,46 +460,34 @@ export function setupCreateModal() {
467
460
  });
468
461
  })(deleteOptions[i]);
469
462
  }
470
- // Close on backdrop click
471
- deleteDialog.addEventListener("click", function (e) {
472
- if (e.target === deleteDialog) closeDeleteDialog();
473
- });
474
463
  }
475
464
 
476
- // Close color palette on any click outside it
477
- document.addEventListener("click", function (e) {
478
- var pal = document.getElementById("sched-create-color-palette");
479
- if (pal && !pal.classList.contains("hidden")) {
480
- if (!pal.contains(e.target) && !e.target.closest("#sched-create-color-btn")) {
481
- pal.classList.add("hidden");
482
- }
483
- }
484
- });
465
+ }
485
466
 
486
- // Close popover on outside click
487
- document.addEventListener("click", function (e) {
488
- var cp = configCtx.getCreatePopover();
489
- if (!cp || cp.classList.contains("hidden")) return;
490
- if (cp.contains(e.target)) return;
491
- // Also ignore clicks on calendar cells (they open the popover)
492
- if (e.target.closest(".scheduler-cell") || e.target.closest(".scheduler-week-slot")) return;
493
- closeCreateModal();
494
- });
467
+ // Outside click and Escape for the create popover and its dropdowns are the
468
+ // registry's. Escape is offered here first: an open accordion takes it.
469
+ function collapseOpenAccordion() {
470
+ var openAcc = configCtx.getCreatePopover().querySelector(".sched-accordion.open");
471
+ if (!openAcc) return false;
472
+ openAcc.classList.remove("open");
473
+ var openBody = openAcc.querySelector(".sched-accordion-body");
474
+ if (openBody) openBody.classList.add("hidden");
475
+ return true;
476
+ }
495
477
 
496
- // Escape key
497
- document.addEventListener("keydown", function (e) {
498
- var cp = configCtx.getCreatePopover();
499
- if (e.key === "Escape" && cp && !cp.classList.contains("hidden")) {
500
- // Close open accordions first
501
- var openAcc = cp.querySelector(".sched-accordion.open");
502
- if (openAcc) {
503
- openAcc.classList.remove("open");
504
- var openBody = openAcc.querySelector(".sched-accordion-body");
505
- if (openBody) openBody.classList.add("hidden");
506
- return;
507
- }
508
- closeCreateModal();
509
- }
478
+ // A dropdown inside the create popover (the task list, the colour palette): a
479
+ // menu the popover owns, so opening it leaves the popover open.
480
+ function toggleCreateDropdown(listEl, btn, matchWidth) {
481
+ if (isMenuOpen(listEl)) {
482
+ closeMenu(listEl);
483
+ return;
484
+ }
485
+ // A list that reads as the button's own menu is as wide as the button; where
486
+ // it sits is the shared component's.
487
+ if (matchWidth) listEl.style.width = btn.getBoundingClientRect().width + "px";
488
+ showOverlay({
489
+ kind: "menu", el: listEl, retain: true, parent: configCtx.getCreatePopover(),
490
+ anchor: btn, opener: btn, placement: "below", gap: 6,
510
491
  });
511
492
  }
512
493
 
@@ -959,7 +940,7 @@ export function openCreateModal(date, hour, anchorEl) {
959
940
  var colorDot = document.getElementById("sched-create-color-dot");
960
941
  if (colorDot) colorDot.style.background = createColor;
961
942
  var palette = document.getElementById("sched-create-color-palette");
962
- if (palette) palette.classList.add("hidden");
943
+ if (palette) closeMenu(palette);
963
944
  var swatches = createPopover.querySelectorAll(".sched-color-swatch");
964
945
  for (var si = 0; si < swatches.length; si++) {
965
946
  swatches[si].classList.toggle("active", swatches[si].dataset.color === createColor);
@@ -975,7 +956,7 @@ export function openCreateModal(date, hour, anchorEl) {
975
956
  if (taskLabel) taskLabel.textContent = "Select a task";
976
957
  if (taskBtn) { taskBtn.classList.remove("has-value"); taskBtn.classList.remove("invalid"); }
977
958
  if (taskListEl) {
978
- taskListEl.classList.add("hidden");
959
+ closeMenu(taskListEl);
979
960
  var tasks = records.filter(function (r) { return r.source !== "ralph" && r.source !== "schedule"; });
980
961
  var html = "";
981
962
  if (tasks.length === 0) {
@@ -1003,7 +984,7 @@ export function openCreateModal(date, hour, anchorEl) {
1003
984
  for (var k = 0; k < all.length; k++) {
1004
985
  all[k].classList.toggle("selected", all[k] === item);
1005
986
  }
1006
- taskListEl.classList.add("hidden");
987
+ closeMenu(taskListEl);
1007
988
  updateTaskSubtitle();
1008
989
  });
1009
990
  })(items[j]);
@@ -1085,7 +1066,9 @@ export function openCreateModal(date, hour, anchorEl) {
1085
1066
  for (var ei = 0; ei < endItems.length; ei++) {
1086
1067
  endItems[ei].classList.toggle("active", endItems[ei].dataset.value === "never");
1087
1068
  }
1088
- document.getElementById("sched-custom-end-list").classList.add("hidden");
1069
+ var endListEl = document.getElementById("sched-custom-end-list");
1070
+ closeMenu(endListEl);
1071
+ endListEl.classList.add("hidden");
1089
1072
  createEndType = "never";
1090
1073
  createEndDate = null;
1091
1074
  createEndAfter = 10;
@@ -1097,54 +1080,26 @@ export function openCreateModal(date, hour, anchorEl) {
1097
1080
  var dragState = configCtx.getDragState();
1098
1081
  showPreviewForCreate(anchorEl, dragState.draggedTaskName || null);
1099
1082
 
1100
- // Position near anchor cell
1101
- createPopover.classList.remove("hidden");
1102
- positionCreatePopover(anchorEl);
1083
+ // Beside the anchor cell; without one, centred in the scheduler content area.
1084
+ // The close control, outside click and Escape are the shared component's and
1085
+ // the registry's. The cell is the opener: a click on it is its own handler's.
1086
+ var contentCalEl = configCtx.getContentCalEl();
1087
+ var anchor = anchorEl || null;
1088
+ if (!anchor && contentCalEl) {
1089
+ var cRect = contentCalEl.getBoundingClientRect();
1090
+ anchor = { x: cRect.left + cRect.width / 2 - CREATE_POPOVER_HALF_WIDTH, y: cRect.top + CREATE_POPOVER_DROP };
1091
+ }
1092
+ showOverlay({
1093
+ kind: "popover", el: createPopover, retain: true, anchor: anchor, opener: anchorEl || undefined,
1094
+ placement: "right", gap: 8, margin: 10,
1095
+ closeButton: true, closeLabel: "Close",
1096
+ onRemove: resetCreateState, onEscape: collapseOpenAccordion,
1097
+ });
1103
1098
 
1104
1099
  try { lucide.createIcons({ node: createPopover }); } catch (e) {}
1105
1100
  setTimeout(function () { document.getElementById("sched-create-title").focus(); }, 50);
1106
1101
  }
1107
1102
 
1108
- function positionCreatePopover(anchorEl) {
1109
- var createPopover = configCtx.getCreatePopover();
1110
- var contentCalEl = configCtx.getContentCalEl();
1111
- if (!createPopover || !anchorEl) {
1112
- // Fallback: center in scheduler content area
1113
- if (createPopover && contentCalEl) {
1114
- var cRect = contentCalEl.getBoundingClientRect();
1115
- createPopover.style.left = (cRect.left + cRect.width / 2 - 180) + "px";
1116
- createPopover.style.top = (cRect.top + 60) + "px";
1117
- }
1118
- return;
1119
- }
1120
-
1121
- var rect = anchorEl.getBoundingClientRect();
1122
- var popW = 360;
1123
- var popH = createPopover.offsetHeight || 300;
1124
-
1125
- // Try to place to the right of the cell
1126
- var left = rect.right + 8;
1127
- var top = rect.top;
1128
-
1129
- // If it overflows right, place to the left
1130
- if (left + popW > window.innerWidth - 10) {
1131
- left = rect.left - popW - 8;
1132
- }
1133
- // If it still overflows left, center horizontally on the cell
1134
- if (left < 10) {
1135
- left = Math.max(10, rect.left + rect.width / 2 - popW / 2);
1136
- }
1137
-
1138
- // Vertical: don't overflow bottom
1139
- if (top + popH > window.innerHeight - 10) {
1140
- top = window.innerHeight - popH - 10;
1141
- }
1142
- if (top < 10) top = 10;
1143
-
1144
- createPopover.style.left = left + "px";
1145
- createPopover.style.top = top + "px";
1146
- }
1147
-
1148
1103
  function updateRecurrenceLabels(date) {
1149
1104
  var dow = date.getDay();
1150
1105
  var dayName = DAY_NAMES[dow];
@@ -1181,7 +1136,14 @@ function updateRecurrenceLabels(date) {
1181
1136
 
1182
1137
  export function closeCreateModal() {
1183
1138
  var createPopover = configCtx.getCreatePopover();
1184
- if (createPopover) createPopover.classList.add("hidden");
1139
+ // Closing the popover closes its dropdowns, and runs resetCreateState.
1140
+ if (createPopover) closeMenu(createPopover);
1141
+ resetCreateState();
1142
+ }
1143
+
1144
+ // What the popover leaves behind when it closes, however it closes. Safe to run
1145
+ // twice, and when the popover was never open.
1146
+ function resetCreateState() {
1185
1147
  // Collapse accordions
1186
1148
  var accRepeat = document.getElementById("sched-accordion-repeat");
1187
1149
  if (accRepeat) { accRepeat.classList.remove("open"); }
@@ -1191,10 +1153,6 @@ export function closeCreateModal() {
1191
1153
  if (accInterval) { accInterval.classList.remove("open"); }
1192
1154
  var accIntervalBody = document.getElementById("sched-accordion-interval-body");
1193
1155
  if (accIntervalBody) accIntervalBody.classList.add("hidden");
1194
- var pal = document.getElementById("sched-create-color-palette");
1195
- if (pal) pal.classList.add("hidden");
1196
- var tl = document.getElementById("sched-create-task-list");
1197
- if (tl) tl.classList.add("hidden");
1198
1156
  removePreview();
1199
1157
  createSelectedDate = null;
1200
1158
  createEditingRecId = null;
@@ -1242,16 +1200,18 @@ function openDeleteDialog(recId, eventDate, isOneOff) {
1242
1200
  var existingDel = footer ? footer.querySelector(".sched-delete-confirm-btn") : null;
1243
1201
  if (existingDel) existingDel.classList.add("hidden");
1244
1202
  }
1245
- dialog.classList.remove("hidden");
1203
+ // The scrim, Escape and the close control close it as Cancel does.
1204
+ deleteHandle = showOverlay({ kind: "modal", el: dialog, onRemove: forgetDeleteTarget });
1246
1205
  }
1247
1206
 
1248
1207
  function closeDeleteDialog() {
1249
- var dialog = document.getElementById("sched-delete-dialog");
1250
- if (dialog) {
1251
- dialog.classList.add("hidden");
1252
- dialog.dataset.recId = "";
1253
- dialog.dataset.eventDate = "";
1254
- }
1208
+ if (deleteHandle) deleteHandle.close();
1209
+ }
1210
+
1211
+ // The dialog closed, however: it no longer names an event.
1212
+ function forgetDeleteTarget(dialog) {
1213
+ dialog.dataset.recId = "";
1214
+ dialog.dataset.eventDate = "";
1255
1215
  }
1256
1216
 
1257
1217
  // Build an explicit list of values offset from a start value with a given step, wrapping at max
@@ -14,7 +14,7 @@ import { approveToolsCardHtml, bindApproveToolsToggle } from './approve-tools-to
14
14
  import { loopHooksWarningHtml } from './loop-hooks-warning.js';
15
15
  import { initSchedulerConfig, setupCreateModal, openCreateModal, openCreateModalWithRecord, closeCreateModal, removePreview, getPreviewEl, showPreviewOnCell, showPreviewOnSlot, showPreviewForCreate, applyDraggedTask, parseCronSimple } from './scheduler-config.js';
16
16
  import { initSchedulerHistory, renderHistory, _lastFiles as lastLoopFiles } from './scheduler-history.js';
17
- import { positionPopover } from './popover-position.js';
17
+ import { showOverlay } from './overlay.js';
18
18
  export { handleLoopRegistryUpdated, handleLoopRegistryFiles, handleScheduleRunStarted, handleScheduleRunFinished, handleLoopScheduled } from './scheduler-history.js';
19
19
 
20
20
  var ctx = null;
@@ -117,13 +117,6 @@ export function initScheduler(_ctx) {
117
117
  send: send,
118
118
  formatDateTime: formatDateTime,
119
119
  });
120
-
121
- // Close popover on outside click
122
- document.addEventListener("click", function (e) {
123
- if (popoverEl && !popoverEl.classList.contains("hidden") && !popoverEl.contains(e.target)) {
124
- popoverEl.classList.add("hidden");
125
- }
126
- });
127
120
  }
128
121
 
129
122
  function ensurePanel() {
@@ -412,7 +405,7 @@ export function closeScheduler() {
412
405
  }
413
406
 
414
407
  if (panel) panel.classList.add("hidden");
415
- if (popoverEl) popoverEl.classList.add("hidden");
408
+ closeSchedulePopover();
416
409
  closeCreateModal();
417
410
 
418
411
  var messagesEl = document.getElementById("messages");
@@ -1322,6 +1315,21 @@ function getEventsForDate(date) {
1322
1315
 
1323
1316
  // --- Popover ---
1324
1317
 
1318
+ // #schedule-popover lives in index.html: the shared component adopts it, hides
1319
+ // it on close (retain) and tracks it in the open-menu registry.
1320
+ var schedulePopover = null;
1321
+
1322
+ function closeSchedulePopover() {
1323
+ if (schedulePopover) {
1324
+ schedulePopover.close();
1325
+ schedulePopover = null;
1326
+ }
1327
+ }
1328
+
1329
+ function openSchedulePopover(anchorEl) {
1330
+ schedulePopover = showOverlay({ kind: "popover", el: popoverEl, retain: true, anchor: anchorEl, placement: "below" });
1331
+ }
1332
+
1325
1333
  function showPopover(recId, anchorEl) {
1326
1334
  var rec = null;
1327
1335
  for (var i = 0; i < records.length; i++) {
@@ -1348,14 +1356,9 @@ function showPopover(recId, anchorEl) {
1348
1356
  html += '</div>';
1349
1357
 
1350
1358
  popoverEl.innerHTML = html;
1351
- popoverEl.classList.remove("hidden");
1352
-
1353
- var rect = anchorEl.getBoundingClientRect();
1354
- var left = Math.max(8, Math.min(rect.left, window.innerWidth - 268));
1355
- var top = rect.bottom + 6;
1356
- if (top + 200 > window.innerHeight) top = rect.top - 200;
1357
- popoverEl.style.left = left + "px";
1358
- popoverEl.style.top = top + "px";
1359
+ // Placed by popover-position.js: below the anchor, flipped above and clamped
1360
+ // on all four edges (replaces a hand-measured left clamp and a 200px height guess).
1361
+ openSchedulePopover(anchorEl);
1359
1362
 
1360
1363
  var btns = popoverEl.querySelectorAll(".schedule-popover-btn");
1361
1364
  for (var i = 0; i < btns.length; i++) {
@@ -1364,17 +1367,20 @@ function showPopover(recId, anchorEl) {
1364
1367
  e.stopPropagation();
1365
1368
  var action = btn.dataset.action;
1366
1369
  var id = btn.dataset.id;
1367
- popoverEl.classList.add("hidden");
1370
+ // The follow-up surfaces hang from anchorEl, the control still in the
1371
+ // page. btn is inside the popover: closing hides it (empty rect) and the
1372
+ // move list replaces its innerHTML, so btn is detached by the time it is measured.
1373
+ closeSchedulePopover();
1368
1374
  if (action === "edit") {
1369
1375
  var rec = null;
1370
1376
  for (var ri = 0; ri < records.length; ri++) {
1371
1377
  if (records[ri].id === id) { rec = records[ri]; break; }
1372
1378
  }
1373
- if (rec) openCreateModalWithRecord(rec, btn);
1379
+ if (rec) openCreateModalWithRecord(rec, anchorEl);
1374
1380
  }
1375
1381
  else if (action === "toggle") send({ type: "loop_registry_toggle", id: id });
1376
1382
  else if (action === "rerun") send({ type: "loop_registry_rerun", id: id });
1377
- else if (action === "move") showMovePopover(id, btn);
1383
+ else if (action === "move") showMovePopover(id, anchorEl);
1378
1384
  else if (action === "delete" && confirm("Delete this schedule?")) send({ type: "loop_registry_remove", id: id });
1379
1385
  });
1380
1386
  })(btns[i]);
@@ -1420,8 +1426,7 @@ function showMovePopover(recId, anchorEl) {
1420
1426
  var projects = getAvailableProjects(rec.projectSlug);
1421
1427
  if (projects.length === 0) {
1422
1428
  popoverEl.innerHTML = '<div class="schedule-popover-name">No other projects available</div>';
1423
- popoverEl.classList.remove("hidden");
1424
- positionPopover(popoverEl, anchorEl, { placement: "below" });
1429
+ openSchedulePopover(anchorEl);
1425
1430
  return;
1426
1431
  }
1427
1432
 
@@ -1433,18 +1438,16 @@ function showMovePopover(recId, anchorEl) {
1433
1438
  html += '</div>';
1434
1439
 
1435
1440
  popoverEl.innerHTML = html;
1436
- popoverEl.classList.remove("hidden");
1437
-
1438
1441
  // Four-edge clamp (lr-a10a): the prior left-only clamp could still leave
1439
1442
  // the popover with its bottom edge off-screen on short mobile viewports.
1440
- positionPopover(popoverEl, anchorEl, { placement: "below" });
1443
+ openSchedulePopover(anchorEl);
1441
1444
 
1442
1445
  var btns = popoverEl.querySelectorAll('[data-action="move-to"]');
1443
1446
  for (var b = 0; b < btns.length; b++) {
1444
1447
  (function (btn) {
1445
1448
  btn.addEventListener("click", function (e) {
1446
1449
  e.stopPropagation();
1447
- popoverEl.classList.add("hidden");
1450
+ closeSchedulePopover();
1448
1451
  send({
1449
1452
  type: "schedule_move",
1450
1453
  recordId: recId,