@clagentic/console 1.12.0 → 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
@@ -28,11 +28,18 @@ import { formatDiagnosticSource as _formatSource } from './diagnostic-format.js'
28
28
  import { sendWs } from './ws-ref.js';
29
29
  import { buildUpdateDetailEl } from './build-update-detail.js';
30
30
  import { sessionLinesOf, messageWithoutSessions, buildSessionsEl } from './build-update-sessions.js';
31
+ import { showOverlay } from './overlay.js';
32
+ import { removeFromStack, cardsBySource } from './overlay-stack.js';
33
+ import { openInfoPanel } from './info-panel.js';
34
+ import { closeMenu, isMenuOpen } from './overlay-registry.js';
31
35
 
32
36
  // The build-update offer's diagnostics entry: where its restart action lives.
33
37
  // The offer itself is a core notification (build_update_offer); the page builds
34
38
  // this entry from it, and its collapse and close come from the core.
35
39
  var BUILD_NOTICE_SOURCE = 'build-update';
40
+ // Marks the cards this module draws, so a clear-all never reaches another
41
+ // surface's card that happens to carry a source key.
42
+ var DIAGNOSTIC_GROUP = 'diagnostic';
36
43
  var BUILD_NOTICE_ACTION = 'restart_for_build_update';
37
44
  // The notification the held offer entry was built from.
38
45
  var _offerNotifId = null;
@@ -211,55 +218,26 @@ export function initDiagnostics() {
211
218
 
212
219
  if (!panelEl || !panelListEl || !panelToggleBtn) return;
213
220
 
214
- // Shared helper: close panel and return focus to the topbar button (WCAG 2.1 §2.4.3).
215
- // Both the close button click and the Escape-key path use this so focus restoration
216
- // is consistent for all keyboard-accessible dismiss gestures.
217
- function closePanelAndRefocus() {
218
- closePanel();
219
- if (panelToggleBtn) panelToggleBtn.focus();
220
- }
221
-
222
- // Close button inside the panel header.
223
- var closeBtn = panelEl.querySelector(".diagnostics-panel-close");
224
- if (closeBtn) {
225
- closeBtn.addEventListener("click", function () {
226
- closePanelAndRefocus();
227
- });
228
- }
229
-
230
221
  // Clear-all button (parity with app-notifications.js clearAllBanners()).
231
222
  if (clearAllBtn) {
232
223
  clearAllBtn.addEventListener("click", function () {
233
224
  clearAllDiagnostics();
225
+ var closeBtn = panelEl.querySelector(".overlay-close");
234
226
  if (closeBtn) closeBtn.focus();
235
227
  });
236
228
  }
237
229
 
238
- // Toggle button in the topbar.
230
+ // Toggle button in the topbar. The panel is a non-modal surface (no backdrop
231
+ // element): the close control, outside click and Escape are the shared
232
+ // component's and the open-menu registry's; the toggle button is its opener,
233
+ // so a click on it is this handler's alone (lr-b580).
239
234
  panelToggleBtn.addEventListener("click", function () {
240
- if (panelEl.classList.contains("hidden")) {
241
- openPanel();
242
- } else {
235
+ if (isMenuOpen(panelEl)) {
243
236
  closePanel();
237
+ } else {
238
+ openPanel();
244
239
  }
245
240
  });
246
-
247
- // Keyboard: dismiss on Escape when panel is focused.
248
- panelEl.addEventListener("keydown", function (e) {
249
- if (e.key === "Escape") {
250
- closePanelAndRefocus();
251
- }
252
- });
253
-
254
- // Click-outside dismiss: the panel is a non-modal surface (no backdrop
255
- // element), so listen on the document and close when a click lands
256
- // outside the panel and outside its topbar toggle button (lr-b580).
257
- document.addEventListener("click", function (e) {
258
- if (panelEl.classList.contains("hidden")) return;
259
- if (panelEl.contains(e.target)) return;
260
- if (panelToggleBtn && panelToggleBtn.contains(e.target)) return;
261
- closePanelAndRefocus();
262
- });
263
241
  }
264
242
 
265
243
  // ============================================================
@@ -313,33 +291,55 @@ function _arrivalTime(msg) {
313
291
  return Date.now();
314
292
  }
315
293
 
294
+ // The offer is a pop-up once per build pair: a refresh of the same offer (its
295
+ // change list arriving; the core sends it as a dismissal and a new notification)
296
+ // replaces a pop-up still on screen but never brings back one the operator
297
+ // closed. An offer that was gone longer than this is a new one (the cooldown
298
+ // ended, or a later build).
299
+ var OFFER_REFRESH_GRACE_MS = 5000;
300
+ var _poppedOfferKey = null;
301
+ var _offerGoneAt = 0;
302
+
303
+ function _offerKeyOf(buildUpdate) {
304
+ return String(buildUpdate.loadedBuildSha || '') + ':' + String(buildUpdate.installedBuildSha || '');
305
+ }
306
+
316
307
  /**
317
308
  * Shows the build-update offer a notification carries, as the diagnostics entry
318
- * with the restart action. The core already collapsed repeats into the one
319
- * notification, so this only replaces the entry it built from an earlier one;
320
- * the same notification again (a reconnect's state) changes nothing. No toast:
321
- * the notification's banner is the alert.
309
+ * with the restart action and, while a tab is open, as a pop-up carrying it (the
310
+ * entry alone sits behind a panel button). It is the offer's only in-console
311
+ * alert: no stack banner is drawn for it. The core already collapsed repeats into the one notification, so this
312
+ * only replaces the entry it built from an earlier one; the same notification
313
+ * again (a reconnect's state) changes nothing, so the pop-up shows once.
322
314
  * @param {object} notif a build_update_offer notification.
315
+ * @param {{popup?: boolean}} [opts] popup: false when the user has muted the
316
+ * banner surface for the offer's category; the entry is still held.
323
317
  */
324
- export function applyBuildOffer(notif) {
318
+ export function applyBuildOffer(notif, opts) {
325
319
  var meta = notif && notif.meta;
326
320
  if (!meta || !meta.buildUpdate) return;
327
321
  var held = diagnostics.some(function (e) { return e.source === BUILD_NOTICE_SOURCE && _actionOf(e) === BUILD_NOTICE_ACTION; });
328
322
  if (held && _offerNotifId === notif.id) return;
323
+ var key = _offerKeyOf(meta.buildUpdate);
324
+ var onScreen = _toastsFor(BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION).length > 0;
325
+ var isNew = key !== _poppedOfferKey || Date.now() - _offerGoneAt > OFFER_REFRESH_GRACE_MS;
326
+ var popup = !(opts && opts.popup === false) && (isNew || onScreen);
329
327
  retractDiagnostics(BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION);
330
328
  _offerNotifId = notif.id;
329
+ if (popup) _poppedOfferKey = key;
331
330
  addDiagnostic({
332
331
  severity: 'warning',
333
332
  source: BUILD_NOTICE_SOURCE,
334
333
  message: meta.message || '',
335
334
  buildUpdate: meta.buildUpdate,
336
335
  actionable: meta.actionable || null,
337
- }, { toast: false });
336
+ }, { toast: popup });
338
337
  }
339
338
 
340
339
  /** The offer was closed (installed, declined anywhere, or no longer stale). */
341
340
  export function withdrawBuildOffer() {
342
341
  _offerNotifId = null;
342
+ _offerGoneAt = Date.now();
343
343
  retractDiagnostics(BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION);
344
344
  }
345
345
 
@@ -354,6 +354,8 @@ function _declineBuildOffer() {
354
354
  if (!_offerNotifId) return;
355
355
  var id = _offerNotifId;
356
356
  _offerNotifId = null;
357
+ // The operator closed this offer: the next one (after the cooldown) pops up.
358
+ _poppedOfferKey = null;
357
359
  sendWs({ type: 'notification_dismiss', ids: [id] });
358
360
  }
359
361
 
@@ -362,8 +364,7 @@ function _actionOf(entry) {
362
364
  }
363
365
 
364
366
  function _toastsFor(source, action) {
365
- return Array.prototype.filter.call(
366
- _getToastContainer().querySelectorAll('[data-diag-source="' + source + '"]'),
367
+ return cardsBySource(source).filter(
367
368
  function (el) { return action === undefined || el.getAttribute("data-diag-action") === action; }
368
369
  );
369
370
  }
@@ -409,52 +410,33 @@ export { formatDiagnosticSource } from './diagnostic-format.js';
409
410
  // Toast
410
411
  // ============================================================
411
412
 
412
- // lr-e901: fixed top-right corner stack (see diagnostics.css
413
- // #diagnostic-toast-container) so concurrent diagnostic toasts stack via
414
- // normal flex flow instead of piling on top of each other at a single fixed
415
- // position over the input box.
416
- var toastContainerEl = null;
417
-
418
- function _getToastContainer() {
419
- if (toastContainerEl && toastContainerEl.isConnected) return toastContainerEl;
420
- toastContainerEl = document.getElementById("diagnostic-toast-container");
421
- if (!toastContainerEl) {
422
- toastContainerEl = document.createElement("div");
423
- toastContainerEl.id = "diagnostic-toast-container";
424
- document.body.appendChild(toastContainerEl);
425
- }
426
- return toastContainerEl;
427
- }
413
+ // A diagnostic toast is a card in the shared overlay stack (modules/overlay.js,
414
+ // overlay-stack.js): the stack places it, so concurrent toasts, notification
415
+ // banners and plain toasts never share a spot.
428
416
 
429
417
  // The toast's lower part: the offer detail when the diagnostic carries one,
430
418
  // then a known actionable.action as a real button (with "Not now" for an
431
- // offer), else the plain hint. Returns whether an action button was added.
432
- function _appendToastActions(el, entry, onDecline) {
419
+ // offer), else the plain hint. Returns the nodes and whether an action button
420
+ // was among them.
421
+ function _toastActionNodes(entry, onDecline) {
422
+ var nodes = [];
433
423
  var detailEl = buildUpdateDetailEl(entry.buildUpdate);
434
- if (detailEl) el.appendChild(detailEl);
424
+ if (detailEl) nodes.push(detailEl);
435
425
  var actionBtn = _buildActionableEl(entry, "toast-diagnostic-action-btn");
436
426
  if (actionBtn) {
437
- el.appendChild(actionBtn);
427
+ nodes.push(actionBtn);
438
428
  var declineBtn = _buildDeclineEl(entry, "toast-diagnostic-action-btn", onDecline);
439
- if (declineBtn) el.appendChild(declineBtn);
440
- return true;
429
+ if (declineBtn) nodes.push(declineBtn);
430
+ return { nodes: nodes, hasAction: true };
441
431
  }
442
432
  var hintEl = document.createElement("div");
443
433
  hintEl.className = "toast-diagnostic-hint";
444
434
  hintEl.textContent = "See Diagnostics panel for details";
445
- el.appendChild(hintEl);
446
- return false;
435
+ nodes.push(hintEl);
436
+ return { nodes: nodes, hasAction: false };
447
437
  }
448
438
 
449
439
  function _showDiagnosticToast(entry) {
450
- var el = document.createElement("div");
451
- // Use a dedicated class so diagnostics are visually distinct from error messages.
452
- el.className = "toast toast-diagnostic toast-diagnostic-" + entry.severity;
453
- el.setAttribute("role", "alert");
454
- el.setAttribute("aria-live", "assertive");
455
- el.setAttribute("data-diag-source", entry.source);
456
- el.setAttribute("data-diag-action", _actionOf(entry));
457
-
458
440
  var headerEl = document.createElement("div");
459
441
  headerEl.className = "toast-diagnostic-header";
460
442
 
@@ -466,64 +448,43 @@ function _showDiagnosticToast(entry) {
466
448
  sourceEl.className = "toast-diagnostic-source";
467
449
  sourceEl.textContent = _formatSource(entry.source, entry.scope);
468
450
 
469
- var dismissBtn = document.createElement("button");
470
- dismissBtn.className = "toast-diagnostic-dismiss";
471
- dismissBtn.setAttribute("aria-label", "Dismiss diagnostic notification");
472
- dismissBtn.innerHTML = iconHtml("x");
473
-
474
451
  headerEl.appendChild(severityEl);
475
452
  headerEl.appendChild(sourceEl);
476
- headerEl.appendChild(dismissBtn);
477
453
 
478
454
  var msgEl = document.createElement("div");
479
455
  msgEl.className = "toast-diagnostic-msg diagnostic-multiline";
480
456
  var sessionLines = sessionLinesOf(entry.buildUpdate);
481
457
  msgEl.textContent = messageWithoutSessions(entry.message, sessionLines);
482
458
 
483
- el.appendChild(headerEl);
484
- el.appendChild(msgEl);
459
+ var content = [headerEl, msgEl];
485
460
  var sessionsEl = buildSessionsEl(sessionLines);
486
- if (sessionsEl) el.appendChild(sessionsEl);
487
- var hasAction = _appendToastActions(el, entry, function () {
461
+ if (sessionsEl) content.push(sessionsEl);
462
+ var card = null;
463
+ var actions = _toastActionNodes(entry, function () {
488
464
  if (entry.source === BUILD_NOTICE_SOURCE) _declineBuildOffer();
489
- clearTimeout(timer);
490
- _removeDiagnosticToast(el);
491
- });
492
-
493
- _getToastContainer().appendChild(el);
494
- refreshIcons();
495
-
496
- // Animate in.
497
- requestAnimationFrame(function () { el.classList.add("visible"); });
498
-
499
- // Auto-dismiss after 6s — EXCEPT when an action button is present: an
500
- // operator deciding whether to restart must not have the offer vanish out
501
- // from under them before they've read it. Likewise a persistent state (a
502
- // restart pending) stays until the operator closes it or the page reloads.
503
- var timer = (hasAction || entry.persistent) ? null : setTimeout(function () { _removeDiagnosticToast(el); }, 6000);
504
-
505
- // Manual dismiss.
506
- dismissBtn.addEventListener("click", function () {
507
- clearTimeout(timer);
508
- _removeDiagnosticToast(el);
465
+ _removeDiagnosticToast(card.el);
509
466
  });
510
-
511
- // Keyboard dismiss. Enter and Space bubble up from the toast's own buttons
512
- // when they are activated; that must activate the button, not close the card.
513
- el.addEventListener("keydown", function (e) {
514
- var fromButton = e.target && e.target.tagName === "BUTTON";
515
- if (e.key === "Escape" || ((e.key === "Enter" || e.key === " ") && !fromButton)) {
516
- clearTimeout(timer);
517
- _removeDiagnosticToast(el);
518
- }
467
+ content = content.concat(actions.nodes);
468
+
469
+ card = showOverlay({
470
+ kind: "toast",
471
+ severity: entry.severity,
472
+ source: entry.source,
473
+ group: DIAGNOSTIC_GROUP,
474
+ className: "toast-diagnostic",
475
+ attrs: { role: "alert", "aria-live": "assertive", "data-diag-action": _actionOf(entry) },
476
+ content: content,
477
+ closeLabel: "Dismiss diagnostic notification",
478
+ // Auto-dismiss after 6s — EXCEPT when an action button is present: an
479
+ // operator deciding whether to restart must not have the offer vanish out
480
+ // from under them before they've read it. Likewise a persistent state (a
481
+ // restart pending) stays until the operator closes it or the page reloads.
482
+ timeout: (actions.hasAction || entry.persistent) ? null : 6000,
519
483
  });
520
484
  }
521
485
 
522
486
  function _removeDiagnosticToast(el) {
523
- el.classList.remove("visible");
524
- setTimeout(function () {
525
- if (el.parentNode) el.parentNode.removeChild(el);
526
- }, 300);
487
+ removeFromStack(el);
527
488
  }
528
489
 
529
490
  // ============================================================
@@ -532,7 +493,11 @@ function _removeDiagnosticToast(el) {
532
493
 
533
494
  function openPanel() {
534
495
  if (!panelEl) return;
535
- panelEl.classList.remove("hidden");
496
+ _escapeDismiss = false;
497
+ openInfoPanel(panelEl, {
498
+ label: "Close diagnostics panel", opener: panelToggleBtn,
499
+ onRemove: _onPanelClosed, onEscape: _onPanelEscape, onDismiss: _focusToggle,
500
+ });
536
501
  panelEl.setAttribute("aria-expanded", "true");
537
502
  if (panelToggleBtn) {
538
503
  panelToggleBtn.setAttribute("aria-expanded", "true");
@@ -543,12 +508,32 @@ function openPanel() {
543
508
  }
544
509
 
545
510
  function closePanel() {
546
- if (!panelEl) return;
547
- panelEl.classList.add("hidden");
511
+ if (panelEl) closeMenu(panelEl);
512
+ }
513
+
514
+ // However the panel closed, its state follows. Focus returns to the topbar
515
+ // button (WCAG 2.1 §2.4.3) only when the user dismissed this panel (Escape or
516
+ // its close control): when another menu opened or a click landed on another
517
+ // control, focus belongs to that one.
518
+ var _escapeDismiss = false;
519
+
520
+ function _onPanelEscape() {
521
+ _escapeDismiss = true;
522
+ return false;
523
+ }
524
+
525
+ function _focusToggle() {
526
+ if (panelToggleBtn) panelToggleBtn.focus();
527
+ }
528
+
529
+ function _onPanelClosed() {
530
+ var restore = _escapeDismiss;
531
+ _escapeDismiss = false;
548
532
  panelEl.setAttribute("aria-expanded", "false");
549
533
  if (panelToggleBtn) {
550
534
  panelToggleBtn.setAttribute("aria-expanded", "false");
551
535
  panelToggleBtn.classList.remove("active");
536
+ if (restore) panelToggleBtn.focus();
552
537
  }
553
538
  }
554
539
 
@@ -687,15 +672,31 @@ function dismissDiagnostic(id) {
687
672
  * no server-side dismiss contract (see module header note).
688
673
  */
689
674
  function clearAllDiagnostics() {
690
- if (diagnostics.some(function (entry) { return entry.source === BUILD_NOTICE_SOURCE; })) _declineBuildOffer();
691
- // Toasts for the cleared entries go too, so clear-all leaves nothing on screen.
692
- Array.prototype.slice.call(_getToastContainer().querySelectorAll("[data-diag-source]")).forEach(_removeDiagnosticToast);
693
- diagnostics = [];
694
- if (panelListEl) panelListEl.innerHTML = "";
695
- _restoreEmptyPlaceholder();
675
+ // The build-update offer asks the operator for a decision: a clear-all neither
676
+ // declines it nor orphans it. Only its own close, its own entry's dismiss or
677
+ // "Not now" does (the notifications clear-all leaves it standing the same way).
678
+ var standing = diagnostics.filter(_isOfferEntry);
679
+ var offerIds = standing.map(function (entry) { return entry.id; });
680
+ cardsBySource().filter(function (el) { return el.getAttribute("data-overlay-group") === DIAGNOSTIC_GROUP; }).forEach(function (el) {
681
+ if (el.getAttribute("data-overlay-source") === BUILD_NOTICE_SOURCE && el.getAttribute("data-diag-action") === BUILD_NOTICE_ACTION && standing.length) return;
682
+ _removeDiagnosticToast(el);
683
+ });
684
+ var cleared = diagnostics.filter(function (entry) { return offerIds.indexOf(entry.id) === -1; });
685
+ diagnostics = standing;
686
+ if (panelListEl) {
687
+ cleared.forEach(function (entry) {
688
+ var itemEl = panelListEl.querySelector('[data-diag-id="' + entry.id + '"]');
689
+ if (itemEl && itemEl.parentNode) itemEl.parentNode.removeChild(itemEl);
690
+ });
691
+ }
692
+ if (diagnostics.length === 0) _restoreEmptyPlaceholder();
696
693
  _updateBadge();
697
694
  }
698
695
 
696
+ function _isOfferEntry(entry) {
697
+ return entry.source === BUILD_NOTICE_SOURCE && _actionOf(entry) === BUILD_NOTICE_ACTION;
698
+ }
699
+
699
700
  // ============================================================
700
701
  // Badge
701
702
  // ============================================================
@@ -0,0 +1,31 @@
1
+ // info-panel.js - opens one of the panels that index.html keeps in #info-panels
2
+ // (usage, status, diagnostics) through the shared overlay component.
3
+ //
4
+ // The panels stack in one column that the container lays out, so each is adopted
5
+ // as its own node (the container also holds the context panel, which is not a
6
+ // menu and stays open beside whichever panel is). The component hides a panel
7
+ // on close (retain), draws the shared close control and tracks it in the
8
+ // open-menu registry: opening one closes any other menu, and outside click and
9
+ // Escape close it.
10
+
11
+ import { showOverlay } from './overlay.js';
12
+
13
+ /**
14
+ * @param {Element} el the panel node.
15
+ * @param {object} opts
16
+ * @param {string} opts.label the close control's accessible name.
17
+ * @param {Element} [opts.opener] the control that toggles the panel.
18
+ * @param {function(Element)} [opts.onRemove] it closed, however.
19
+ * @param {function(Event): boolean} [opts.onEscape] Escape is about to close it;
20
+ * return false (or nothing) to let it close.
21
+ * @param {function(Element)} [opts.onDismiss] the close control closed it.
22
+ * @returns {{el: Element, close: function(): void, isOpen: function(): boolean}}
23
+ */
24
+ export function openInfoPanel(el, opts) {
25
+ return showOverlay({
26
+ kind: "popover", el: el, retain: true, inline: true,
27
+ closeButton: true, closeLabel: opts.label,
28
+ opener: opts.opener, onRemove: opts.onRemove,
29
+ onEscape: opts.onEscape, onDismiss: opts.onDismiss,
30
+ });
31
+ }
@@ -9,12 +9,11 @@
9
9
 
10
10
  import { mateAvatarUrl } from "./avatar.js";
11
11
  import { injectedSenderName } from "./injected-label.js";
12
- import { resolveAgentAvatar, robotAvatarUrl, senderAgentKey } from "./agent-avatar.js";
12
+ import { resolveAgentAvatar, robotAvatarUrl, senderAgentKey, systemKindOf } from "./agent-avatar.js";
13
13
 
14
14
  // Fixed seeds keep the avatar of anonymous senders stable across renders.
15
15
  var UNDECLARED_SEED = "undeclared-sender";
16
16
  var UNRECORDED_SEED = "unrecorded-sender";
17
- var AUTOMATION_SEED_PREFIX = "console-automation:";
18
17
 
19
18
  function norm(value) {
20
19
  return typeof value === "string" ? value.trim().toLowerCase() : "";
@@ -39,12 +38,13 @@ function findKnownIdentity(known, fromId, fromName) {
39
38
  function identityOf(injected, name, defaultAvatarUrl, matched, size) {
40
39
  var agentKey = senderAgentKey(injected);
41
40
  var avatarUrl = agentKey ? resolveAgentAvatar(agentKey, size, defaultAvatarUrl).url : defaultAvatarUrl;
42
- return { name: name, avatarUrl: avatarUrl, defaultAvatarUrl: defaultAvatarUrl, agentKey: agentKey, matched: matched };
41
+ return { name: name, avatarUrl: avatarUrl, defaultAvatarUrl: defaultAvatarUrl, agentKey: agentKey, matched: matched, systemKind: systemKindOf(injected) };
43
42
  }
44
43
 
45
44
  // injected: { senderKind, fromName, ... }; fromId: the recorded `from`;
46
45
  // known: mates and agents as { id, name, agentName?, slug?, avatar fields }.
47
- // Returns { name, avatarUrl, defaultAvatarUrl, agentKey, matched }.
46
+ // Returns { name, avatarUrl, defaultAvatarUrl, agentKey, matched, systemKind };
47
+ // a systemKind (non-null) means draw the fixed system icon, not avatarUrl.
48
48
  export function resolveInjectedIdentity(injected, fromId, known, size) {
49
49
  var extracted = injected.senderKind === "extracted";
50
50
  var declared = injected.senderKind === "declared" || extracted;
@@ -64,11 +64,11 @@ export function resolveInjectedIdentity(injected, fromId, known, size) {
64
64
  if (extracted && injected.senderAgentSlug) {
65
65
  return identityOf(injected, injectedSenderName(injected), mateAvatarUrl({ id: injected.senderAgentSlug }, size), false, size);
66
66
  }
67
- // The console's own automations keep one avatar each, whichever session or
68
- // project they run in, and never match a mate or agent by name.
67
+ // The console's own automations draw a fixed system icon (systemKind, always
68
+ // set for them), never a seed, and never match a mate or agent by name. There
69
+ // is no image URL to give.
69
70
  if (injected.senderKind === "automation") {
70
- return identityOf(injected, injectedSenderName(injected),
71
- mateAvatarUrl({ avatarStyle: "bottts", avatarSeed: AUTOMATION_SEED_PREFIX + (injected.fromName || "console") }, size), false, size);
71
+ return identityOf(injected, injectedSenderName(injected), null, false, size);
72
72
  }
73
73
  // A sender that names an agent shows that agent's seeded robot, the same one
74
74
  // the roster and every other place that draws the agent start from.
@@ -0,0 +1,39 @@
1
+ // input-list-menu.js - joins an input autocomplete list (mention, slash command,
2
+ // @agent) to the open-menu registry for one-open only.
3
+ //
4
+ // A list is tied to the text box, not to a click, so it keeps its own keyboard
5
+ // navigation, selection and Escape. The registry only enforces that a list and a
6
+ // menu are never open together: opening a list closes any open menu, and opening
7
+ // a menu closes the list (through onClose, which clears the list's own state).
8
+ //
9
+ // The existing registry options carry the rest, no new concept:
10
+ // - opener: the text box, so a click in it is not an outside click;
11
+ // - onEscape returning true: the registry's document Escape leaves the list to
12
+ // the text box's own Escape handler;
13
+ // - retain: the node lives in the page, so it is hidden, not removed;
14
+ // - inputList: the one small flag, so openModal can close a list that would
15
+ // otherwise hold Escape above the modal.
16
+ // The passive option is not used: a passive entry sits outside the one-open
17
+ // stack and would stay open beside a menu.
18
+
19
+ import { openMenu, closeMenu } from "./overlay-registry.js";
20
+
21
+ function keepOpen() { return true; }
22
+
23
+ /**
24
+ * @param {Element} listEl the list's node.
25
+ * @param {?Element} inputEl the text box the list belongs to.
26
+ * @param {function()} onClose clears the list's own state; runs when the registry
27
+ * closes the list (another menu opened, an outside click, back).
28
+ */
29
+ export function openInputList(listEl, inputEl, onClose) {
30
+ if (!listEl) return;
31
+ // The registry hides a retained node with "hidden"; a list shows by "visible".
32
+ listEl.classList.remove("hidden");
33
+ openMenu(listEl, { opener: inputEl || null, retain: true, onClose: onClose, onEscape: keepOpen, inputList: true });
34
+ }
35
+
36
+ /** The list closed itself: let the registry forget it. */
37
+ export function closeInputList(listEl) {
38
+ if (listEl) closeMenu(listEl);
39
+ }
@@ -3,14 +3,16 @@ import { setRewindMode, isRewindMode } from './rewind.js';
3
3
  import { renderPicker as renderContextPicker } from './context-sources.js';
4
4
  import { checkForMention, showMentionMenu, hideMentionMenu, isMentionMenuVisible, mentionMenuKeydown, setMentionAtIdx, parseMentionFromInput, clearMentionState, stickyReapplyMention, sendUserMention, renderUserMention, removeMentionChip } from './mention.js';
5
5
  import { initAtAgents, showAgentMenu, hideAgentMenu, isAgentMenuActive, agentMenuKeydown, requestProjectAgents } from './at-agents.js';
6
+ import { openInputList, closeInputList } from './input-list-menu.js';
6
7
  import { store } from './store.js';
8
+ import { showOverlay } from './overlay.js';
7
9
  import { sendWsQuiet } from './ws-ref.js';
8
10
  import { getScheduleDelayMs, getArmedSchedule, setArmedSchedule, canArmScheduledInput, getScheduledInputs } from './rate-limit-state.js';
9
11
  import { createSchedulePanel } from './schedule-panel.js';
10
12
  import { scheduleMessageFor, specLabel, specTitle } from './schedule-time.js';
11
13
  import { sendScheduledNow, cancelScheduledInput } from './scheduled-input-actions.js';
12
14
  import { currentSendNowState, isSendNowKey, isMacPlatform, initSendLongPress } from './send-now.js';
13
- import { parseShellLine } from './shell-line.js';
15
+ import { shellCommandFrom } from './shell-line.js';
14
16
  import { isShellModeOn, isShellPending, hasQueuedChat, sendShellCommand, queueShellCommand, isTurnRunning, queueChatMessage, flushQueuedChat, restoreSetAsideDraft, registerComposer, registerChatSender, runQueuedShellNext, takeBackLastQueued, registerFrameSender, registerSocketProbe, registerDeliveredRenderer, chatQueuesWithAgent, trackSentChat, newMessageId } from './user-shell.js';
15
17
 
16
18
  var ctx;
@@ -32,6 +34,8 @@ var isRemoteInput = false;
32
34
  var _showArmedScheduleFn = null; // set by initInput: paints the clock button
33
35
  var _schedulePanel = null; // set by initInput
34
36
  var slashMenuBound = false;
37
+ // Matches the slide-down of #input-more-sheet.closing in css/input.css.
38
+ var INPUT_MORE_EXIT_MS = 250;
35
39
 
36
40
  function currentSessionId() {
37
41
  return store.get('activeSessionId');
@@ -142,8 +146,9 @@ export var builtinCommands = [
142
146
  // --- Send ---
143
147
  // Whether the composer holds a ! command line that would be sent as a command.
144
148
  function draftIsShellLine() {
145
- var attached = pendingFiles.length > 0 || pendingPastes.length > 0 || pendingImages.length > 0;
146
- return !attached && isShellModeOn() && parseShellLine(ctx.inputEl.value) !== null;
149
+ var attached = pendingFiles.length > 0 || pendingImages.length > 0;
150
+ var pastes = pendingPastes.map(function (p) { return p.text; });
151
+ return !attached && isShellModeOn() && shellCommandFrom(ctx.inputEl.value, pastes) !== null;
147
152
  }
148
153
 
149
154
  // Send-now (Ctrl/Cmd+Enter, or a long press of the send button on touch): the
@@ -311,11 +316,12 @@ export function sendMessage(opts) {
311
316
 
312
317
  // A line that starts with ! is a shell command, not a chat message: it goes as
313
318
  // its own request, which the server checks and answers with a result card. The
314
- // command is read from the composer as typed (parseShellLine drops only the !
315
- // and the whitespace after it). Anything attached keeps it a chat message, and
319
+ // command is read from the composer as typed (only the ! and the whitespace
320
+ // after it are dropped), followed by any collapsed pastes, which the server's
321
+ // chat path would otherwise expand. Files or images keep it a chat message, and
316
322
  // so does the mode being off: the line is then sent as ordinary text.
317
- var hasAttachments = files.length > 0 || pendingPastes.length > 0 || images.length > 0;
318
- var shellCommand = hasAttachments ? null : parseShellLine(ctx.inputEl.value);
323
+ var hasAttachments = files.length > 0 || images.length > 0;
324
+ var shellCommand = hasAttachments ? null : shellCommandFrom(ctx.inputEl.value, pastes);
319
325
  if (shellCommand !== null && isShellModeOn()) {
320
326
  // Held like native Claude Code does: a command typed during a turn, during
321
327
  // another command, or behind earlier unsent entries waits in the queue and
@@ -428,13 +434,8 @@ function showSentMessage(text, images, pastes) {
428
434
  // to the server, which records the mark with the message.
429
435
  ctx.addUserMessage(text, images.length > 0 ? images : null, pastes.length > 0 ? pastes : null);
430
436
 
431
- // Show pre-thinking dots before server responds.
432
- // Channel layout: rich pre-thinking bubble via showClaudePreThinking().
433
- // Bubble layout: simple activity-inline dots via setActivity("thinking").
434
- if (ctx.showClaudePreThinking) {
435
- ctx.showClaudePreThinking();
436
- }
437
- if (!document.body.classList.contains("wide-view") && ctx.setActivity) {
437
+ // Show the working dots before the server responds: the one indicator.
438
+ if (ctx.setActivity) {
438
439
  ctx.setActivity("thinking");
439
440
  }
440
441
  }
@@ -850,6 +851,7 @@ function showSlashMenu(filter) {
850
851
  '</div>';
851
852
  }).join("");
852
853
  ctx.slashMenu.classList.add("visible");
854
+ openInputList(ctx.slashMenu, ctx.inputEl, hideSlashMenu);
853
855
  }
854
856
 
855
857
  export function hideSlashMenu() {
@@ -859,6 +861,7 @@ export function hideSlashMenu() {
859
861
  ctx.slashMenu.innerHTML = "";
860
862
  slashActiveIdx = -1;
861
863
  slashFiltered = [];
864
+ closeInputList(ctx.slashMenu);
862
865
  }
863
866
 
864
867
  function selectSlashItem(idx) {
@@ -996,25 +999,23 @@ export function initInput(_ctx) {
996
999
  // Mobile "+" button -> unified bottom sheet with attach/image + context sources
997
1000
  var moreBtn = document.getElementById("input-more-btn");
998
1001
  var moreSheet = document.getElementById("input-more-sheet");
1002
+ var moreHandle = null;
999
1003
  function openMoreSheet() {
1000
1004
  if (!moreSheet) return;
1001
1005
  // Render context sources into mobile sheet containers
1002
1006
  try { renderContextPicker("-mobile"); } catch (e) {}
1003
- moreSheet.classList.remove("hidden");
1004
- requestAnimationFrame(function () { moreSheet.classList.add("open"); });
1007
+ // A shared sheet: Escape, the scrim and the close control close it. The exit
1008
+ // class plays the slide-down (css/input.css) before the node is hidden.
1009
+ moreHandle = showOverlay({ kind: "sheet", el: moreSheet, exit: { className: "closing", ms: INPUT_MORE_EXIT_MS } });
1005
1010
  }
1006
1011
  function closeMoreSheet() {
1007
- if (!moreSheet) return;
1008
- moreSheet.classList.remove("open");
1009
- setTimeout(function () { moreSheet.classList.add("hidden"); }, 250);
1012
+ if (moreHandle) moreHandle.close();
1010
1013
  }
1011
1014
  if (moreBtn && moreSheet) {
1012
1015
  moreBtn.addEventListener("click", function (e) {
1013
1016
  e.stopPropagation();
1014
1017
  openMoreSheet();
1015
1018
  });
1016
- var backdrop = moreSheet.querySelector(".input-more-backdrop");
1017
- if (backdrop) backdrop.addEventListener("click", closeMoreSheet);
1018
1019
 
1019
1020
  var moreAttach = document.getElementById("input-more-attach");
1020
1021
  if (moreAttach) moreAttach.addEventListener("click", function () {