@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
@@ -2,6 +2,7 @@ import { copyToClipboard, escapeHtml } from './utils.js';
2
2
  import { refreshIcons } from './icons.js';
3
3
  import { getMermaidThemeVars } from './theme.js';
4
4
  import { store } from './store.js';
5
+ import { showOverlay } from './overlay.js';
5
6
 
6
7
  // --- Web Worker for off-main-thread markdown parsing ---
7
8
  // The worker handles marked.parse() (the heavy part). DOMPurify.sanitize()
@@ -77,17 +78,19 @@ marked.use({
77
78
  }
78
79
  });
79
80
 
80
- // Initialize mermaid
81
+ // Initialize mermaid. "base" is the theme that takes its colours from
82
+ // themeVariables, which the active mode's palette supplies (theme-core.js), so
83
+ // diagrams are drawn in the colours of Dark or Light and not a fixed dark theme.
81
84
  mermaid.initialize({
82
85
  startOnLoad: false,
83
- theme: "dark",
86
+ theme: "base",
84
87
  themeVariables: getMermaidThemeVars()
85
88
  });
86
89
 
87
90
  export function updateMermaidTheme(vars) {
88
91
  mermaid.initialize({
89
92
  startOnLoad: false,
90
- theme: "dark",
93
+ theme: "base",
91
94
  themeVariables: vars
92
95
  });
93
96
  }
@@ -258,7 +261,8 @@ export function showMermaidModal(svgHtml) {
258
261
  // defensively here too since showMermaidModal is also exported and callable
259
262
  // from other paths.
260
263
  body.innerHTML = DOMPurify.sanitize(svgHtml, { USE_PROFILES: { svg: true, svgFilters: true } });
261
- modal.classList.remove("hidden");
264
+ // Escape, the scrim and the shared close control close it.
265
+ showOverlay({ kind: "modal", el: modal });
262
266
  refreshIcons();
263
267
 
264
268
  var dlBtn = document.getElementById("mermaid-download-btn");
@@ -267,11 +271,6 @@ export function showMermaidModal(svgHtml) {
267
271
  };
268
272
  }
269
273
 
270
- export function closeMermaidModal() {
271
- var modal = document.getElementById("mermaid-modal");
272
- if (modal) modal.classList.add("hidden");
273
- }
274
-
275
274
  export function downloadMermaidPng(svgEl) {
276
275
  if (!svgEl) return;
277
276
  var svgClone = svgEl.cloneNode(true);
@@ -294,8 +293,8 @@ export function downloadMermaidPng(svgEl) {
294
293
  canvas.width = w;
295
294
  canvas.height = h;
296
295
  var ctx = canvas.getContext("2d");
297
- // Dark background
298
- ctx.fillStyle = "#1E1D1A";
296
+ // The diagram is drawn for the active theme, so it lands on that theme's code surface.
297
+ ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue("--code-bg").trim();
299
298
  ctx.fillRect(0, 0, w, h);
300
299
  ctx.drawImage(img, 0, 0, w, h);
301
300
  URL.revokeObjectURL(url);
@@ -4,8 +4,10 @@
4
4
  import { getWs } from './ws-ref.js';
5
5
  import { refreshIcons } from './icons.js';
6
6
  import { setHttpMcpServers } from './app-misc.js';
7
+ import { showOverlay } from './overlay.js';
7
8
 
8
9
  var modal = null;
10
+ var modalHandle = null;
9
11
  var contentEl = null;
10
12
  var _mcpServers = []; // { name, transport, toolCount, extensionEnabled, projectEnabled }
11
13
  var _extensionConnected = false;
@@ -18,20 +20,9 @@ export function initMcp() {
18
20
 
19
21
  var btn = document.getElementById("mcp-btn");
20
22
  var mateBtn = document.getElementById("mate-mcp-btn");
21
- var closeBtn = document.getElementById("mcp-modal-close");
22
- var backdrop = modal ? modal.querySelector(".confirm-backdrop") : null;
23
23
 
24
24
  if (btn) btn.addEventListener("click", openMcpModal);
25
25
  if (mateBtn) mateBtn.addEventListener("click", openMcpModal);
26
- if (closeBtn) closeBtn.addEventListener("click", closeMcpModal);
27
- if (backdrop) backdrop.addEventListener("click", closeMcpModal);
28
-
29
- // ESC to close
30
- document.addEventListener("keydown", function (e) {
31
- if (e.key === "Escape" && modal && !modal.classList.contains("hidden")) {
32
- closeMcpModal();
33
- }
34
- });
35
26
  }
36
27
 
37
28
  export function handleMcpServersState(msg) {
@@ -62,14 +53,13 @@ export function getMcpServers() {
62
53
 
63
54
  function openMcpModal() {
64
55
  if (!modal) return;
65
- modal.classList.remove("hidden");
56
+ modalHandle = showOverlay({ kind: "modal", el: modal });
66
57
  refreshIcons(modal);
67
58
  renderMcpServerList();
68
59
  }
69
60
 
70
61
  function closeMcpModal() {
71
- if (!modal) return;
72
- modal.classList.add("hidden");
62
+ if (modalHandle) modalHandle.close();
73
63
  }
74
64
 
75
65
  function updateBadge() {
@@ -4,6 +4,8 @@ import { escapeHtml, copyToClipboard } from './utils.js';
4
4
  import { iconHtml, refreshIcons } from './icons.js';
5
5
  import { store } from './store.js';
6
6
  import { gatedButtonAttrs } from './vendor-registry.js';
7
+ import { buildMessageHeader, AVATAR_REQUEST_SIZE } from './message-header.js';
8
+ import { openInputList, closeInputList } from './input-list-menu.js';
7
9
 
8
10
  var ctx;
9
11
 
@@ -234,6 +236,7 @@ export function showMentionMenu(query) {
234
236
  '</div>';
235
237
  }).join("");
236
238
  menuEl.classList.add("visible");
239
+ openInputList(menuEl, ctx && ctx.inputEl, hideMentionMenu);
237
240
  }
238
241
 
239
242
  export function hideMentionMenu() {
@@ -246,6 +249,7 @@ export function hideMentionMenu() {
246
249
  if (menuEl) {
247
250
  menuEl.classList.remove("visible");
248
251
  menuEl.innerHTML = "";
252
+ closeInputList(menuEl);
249
253
  }
250
254
  }
251
255
 
@@ -523,107 +527,49 @@ export function handleMentionStart(msg) {
523
527
 
524
528
  var avatarSrc = buildMentionAvatarUrl(msg);
525
529
 
526
- if (isDmLayout()) {
527
- // DM-style: render as DM-style assistant message (Mate DM or Wide view)
528
- currentMentionEl = document.createElement("div");
529
- currentMentionEl.className = "msg-assistant msg-mention-dm";
530
-
531
- var avi = document.createElement("img");
532
- avi.className = "dm-bubble-avatar dm-bubble-avatar-agent";
533
- avi.src = avatarSrc;
534
- currentMentionEl.appendChild(avi);
535
-
536
- var contentWrap = document.createElement("div");
537
- contentWrap.className = "dm-bubble-content";
538
-
539
- var header = document.createElement("div");
540
- header.className = "dm-bubble-header";
541
- var nameSpan = document.createElement("span");
542
- nameSpan.className = "dm-bubble-name";
543
- nameSpan.style.color = msg.avatarColor || "#6c5ce7";
544
- nameSpan.textContent = msg.mateName || "Mate";
545
- header.appendChild(nameSpan);
546
-
547
- var badge = document.createElement("span");
548
- badge.className = "mention-badge";
549
- badge.textContent = "@MENTION";
550
- header.appendChild(badge);
551
-
552
- var stopBtn = document.createElement("button");
553
- stopBtn.className = "mention-stop-btn";
554
- stopBtn.title = "Stop";
555
- stopBtn.textContent = "Stop";
556
- stopBtn.addEventListener("click", function () {
557
- if (ctx.ws && ctx.connected) {
558
- ctx.ws.send(JSON.stringify({ type: "mention_stop", mateId: msg.mateId }));
559
- }
560
- });
561
- header.appendChild(stopBtn);
562
- contentWrap.appendChild(header);
563
-
564
- // Activity indicator
565
- var activityDiv = document.createElement("div");
566
- activityDiv.className = "activity-inline mention-activity-bar";
567
- activityDiv.innerHTML =
568
- '<span class="activity-icon">' + iconHtml("sparkles") + '</span>' +
569
- '<span class="activity-text">Thinking...</span>';
570
- contentWrap.appendChild(activityDiv);
571
-
572
- // Content area for streamed markdown
573
- var contentDiv = document.createElement("div");
574
- contentDiv.className = "md-content mention-content";
575
- contentDiv.dir = "auto";
576
- contentWrap.appendChild(contentDiv);
577
-
578
- currentMentionEl.appendChild(contentWrap);
579
- } else {
580
- // Project chat: mention block style
581
- currentMentionEl = document.createElement("div");
582
- currentMentionEl.className = "msg-mention";
583
- currentMentionEl.style.setProperty("--mention-color", msg.avatarColor || "#6c5ce7");
584
-
585
- var header = document.createElement("div");
586
- header.className = "mention-header";
587
-
588
- var avatar = document.createElement("img");
589
- avatar.className = "mention-avatar";
590
- avatar.src = avatarSrc;
591
- avatar.width = 20;
592
- avatar.height = 20;
593
- header.appendChild(avatar);
594
-
595
- var nameSpan = document.createElement("span");
596
- nameSpan.className = "mention-name";
597
- nameSpan.textContent = msg.mateName || "Mate";
598
- header.appendChild(nameSpan);
599
-
600
- var stopBtn = document.createElement("button");
601
- stopBtn.className = "mention-stop-btn";
602
- stopBtn.title = "Stop";
603
- stopBtn.textContent = "Stop";
604
- stopBtn.addEventListener("click", function () {
605
- if (ctx.ws && ctx.connected) {
606
- ctx.ws.send(JSON.stringify({ type: "mention_stop", mateId: msg.mateId }));
607
- }
608
- });
609
- header.appendChild(stopBtn);
610
-
611
- currentMentionEl.appendChild(header);
612
-
613
- // Activity indicator
614
- var activityDiv = document.createElement("div");
615
- activityDiv.className = "activity-inline mention-activity-bar";
616
- activityDiv.innerHTML =
617
- '<span class="activity-icon">' + iconHtml("sparkles") + '</span>' +
618
- '<span class="activity-text">Thinking...</span>';
619
- currentMentionEl.appendChild(activityDiv);
620
-
621
- // Content area for streamed markdown
622
- var contentDiv = document.createElement("div");
623
- contentDiv.className = "md-content mention-content";
624
- contentDiv.dir = "auto";
625
- currentMentionEl.appendChild(contentDiv);
626
- }
530
+ currentMentionEl = document.createElement("div");
531
+ currentMentionEl.className = "msg-assistant msg-mention-dm";
532
+
533
+ var avi = document.createElement("img");
534
+ avi.className = "dm-bubble-avatar dm-bubble-avatar-agent";
535
+ avi.src = avatarSrc;
536
+ avi.alt = "";
537
+
538
+ var badge = document.createElement("span");
539
+ badge.className = "mention-badge";
540
+ badge.textContent = "@MENTION";
541
+
542
+ var stopBtn = document.createElement("button");
543
+ stopBtn.className = "mention-stop-btn";
544
+ stopBtn.title = "Stop";
545
+ stopBtn.textContent = "Stop";
546
+ stopBtn.addEventListener("click", function () {
547
+ if (ctx.ws && ctx.connected) {
548
+ ctx.ws.send(JSON.stringify({ type: "mention_stop", mateId: msg.mateId }));
549
+ }
550
+ });
551
+
552
+ currentMentionEl.appendChild(buildMessageHeader({
553
+ side: "other",
554
+ avatarEl: avi,
555
+ name: msg.mateName || "Mate",
556
+ nameColor: msg.avatarColor,
557
+ extras: [badge, stopBtn],
558
+ }).el);
559
+
560
+ // Activity indicator
561
+ var activityDiv = document.createElement("div");
562
+ activityDiv.className = "activity-inline mention-activity-bar";
563
+ activityDiv.innerHTML =
564
+ '<span class="activity-icon">' + iconHtml("sparkles") + '</span>' +
565
+ '<span class="activity-text">Thinking...</span>';
566
+ currentMentionEl.appendChild(activityDiv);
567
+
568
+ // Content area for streamed markdown
569
+ var contentDiv = document.createElement("div");
570
+ contentDiv.className = "md-content mention-content";
571
+ contentDiv.dir = "auto";
572
+ currentMentionEl.appendChild(contentDiv);
627
573
 
628
574
  mentionFullText = "";
629
575
  mentionStreamBuffer = "";
@@ -764,19 +710,11 @@ export function handleMentionError(msg) {
764
710
  }
765
711
 
766
712
  // --- Helpers ---
767
- function isWideView() {
768
- return document.body.classList.contains("wide-view");
769
- }
770
-
771
- function isDmLayout() {
772
- return isWideView();
773
- }
774
-
775
713
  function getMyAvatarSrc() {
776
714
  if (document.body.dataset.myAvatarUrl) return document.body.dataset.myAvatarUrl;
777
715
  var myUser = null;
778
716
  try { myUser = JSON.parse(localStorage.getItem("clagentic_my_user") || localStorage.getItem("clay_my_user") || "null"); } catch (e) {}
779
- return userAvatarUrl(myUser || {}, 36);
717
+ return userAvatarUrl(myUser || {}, AVATAR_REQUEST_SIZE);
780
718
  }
781
719
 
782
720
  function getMyDisplayName() {
@@ -877,32 +815,21 @@ export function renderUserMention(entry) {
877
815
  var avi = document.createElement("img");
878
816
  avi.className = "dm-bubble-avatar dm-bubble-avatar-me";
879
817
  avi.src = buildUserAvatarUrlFromEntry(entry, "from");
880
- div.appendChild(avi);
881
-
882
- var contentWrap = document.createElement("div");
883
- contentWrap.className = "dm-bubble-content";
884
-
885
- var header = document.createElement("div");
886
- header.className = "dm-bubble-header";
887
- var nameSpan = document.createElement("span");
888
- nameSpan.className = "dm-bubble-name";
889
- nameSpan.textContent = fromName;
890
- header.appendChild(nameSpan);
818
+ avi.alt = "";
891
819
 
892
820
  var sideTag = document.createElement("span");
893
821
  sideTag.className = "mention-badge mention-badge-user";
894
822
  sideTag.textContent = "@" + targetName.toUpperCase();
895
823
  sideTag.title = "Side conversation with " + targetName + ". The coding agent will see this on the next message.";
896
- header.appendChild(sideTag);
897
-
898
- var ts = document.createElement("span");
899
- ts.className = "dm-bubble-time";
900
- ts.textContent = timeStr();
901
- header.appendChild(ts);
902
824
 
903
- contentWrap.appendChild(header);
904
- contentWrap.appendChild(bubble);
905
- div.appendChild(contentWrap);
825
+ div.appendChild(buildMessageHeader({
826
+ side: "own",
827
+ avatarEl: avi,
828
+ name: fromName,
829
+ extras: [sideTag],
830
+ time: timeStr(),
831
+ }).el);
832
+ div.appendChild(bubble);
906
833
 
907
834
  if (ctx.addToMessages) ctx.addToMessages(div);
908
835
  else if (ctx.messagesEl) ctx.messagesEl.appendChild(div);
@@ -971,40 +898,29 @@ export function renderMentionUser(entry) {
971
898
  textEl.innerHTML = '<span class="mention-chip">@' + escapeHtml(entry.mateName || "Mate") + '</span> ' + escapeHtml(entry.text || "");
972
899
  bubble.appendChild(textEl);
973
900
 
974
- // Always render avatar + header structure (CSS controls visibility)
901
+ // The viewer's own mention: the same mirrored header as any own message,
902
+ // with the action bar in it.
975
903
  var avi = document.createElement("img");
976
904
  avi.className = "dm-bubble-avatar dm-bubble-avatar-me";
977
905
  avi.src = getMyAvatarSrc();
978
- div.appendChild(avi);
979
-
980
- var contentWrap = document.createElement("div");
981
- contentWrap.className = "dm-bubble-content";
982
-
983
- var header = document.createElement("div");
984
- header.className = "dm-bubble-header";
985
- var nameSpan = document.createElement("span");
986
- nameSpan.className = "dm-bubble-name";
987
- nameSpan.textContent = getMyDisplayName();
988
- header.appendChild(nameSpan);
989
- var ts = document.createElement("span");
990
- ts.className = "dm-bubble-time";
991
- ts.textContent = timeStr();
992
- header.appendChild(ts);
993
- contentWrap.appendChild(header);
994
- contentWrap.appendChild(bubble);
995
- div.appendChild(contentWrap);
996
-
997
- // Action bar below bubble (same as regular user messages)
906
+ avi.alt = "";
907
+
998
908
  var actions = document.createElement("div");
999
909
  actions.className = "msg-actions";
1000
- var ts2 = timeStr();
1001
910
  actions.innerHTML =
1002
- '<span class="msg-action-time">' + ts2 + '</span>' +
1003
911
  '<button class="msg-action-btn msg-action-copy" type="button" title="Copy">' + iconHtml("copy") + '</button>' +
1004
912
  '<button class="msg-action-btn msg-action-fork" type="button" ' + gatedButtonAttrs("fork", "Fork") + '>' + iconHtml("git-branch") + '</button>' +
1005
913
  '<button class="msg-action-btn msg-action-rewind msg-user-rewind-btn" type="button" ' + gatedButtonAttrs("rewind", "Rewind") + '>' + iconHtml("rotate-ccw") + '</button>' +
1006
914
  '<button class="msg-action-btn msg-action-hidden msg-action-edit" type="button" title="Edit">' + iconHtml("pencil") + '</button>';
1007
- div.appendChild(actions);
915
+
916
+ div.appendChild(buildMessageHeader({
917
+ side: "own",
918
+ avatarEl: avi,
919
+ name: getMyDisplayName(),
920
+ time: timeStr(),
921
+ actions: actions,
922
+ }).el);
923
+ div.appendChild(bubble);
1008
924
 
1009
925
  // Copy handler
1010
926
  var rawText = (entry.mateName ? "@" + entry.mateName + " " : "") + (entry.text || "");
@@ -1024,81 +940,36 @@ export function renderMentionUser(entry) {
1024
940
  export function renderMentionResponse(entry) {
1025
941
  var avatarSrc = buildMentionAvatarUrl(entry);
1026
942
 
1027
- // DM-style message layout (Mate DM or Wide view)
1028
- if (isDmLayout()) {
1029
- var el = document.createElement("div");
1030
- el.className = "msg-assistant msg-mention-dm";
1031
-
1032
- var avi = document.createElement("img");
1033
- avi.className = "dm-bubble-avatar dm-bubble-avatar-agent";
1034
- avi.src = avatarSrc;
1035
- el.appendChild(avi);
1036
-
1037
- var contentWrap = document.createElement("div");
1038
- contentWrap.className = "dm-bubble-content";
1039
-
1040
- var header = document.createElement("div");
1041
- header.className = "dm-bubble-header";
1042
- var nameSpan = document.createElement("span");
1043
- nameSpan.className = "dm-bubble-name";
1044
- nameSpan.style.color = entry.avatarColor || "#6c5ce7";
1045
- nameSpan.textContent = entry.mateName || "Mate";
1046
- header.appendChild(nameSpan);
1047
-
1048
- var badge = document.createElement("span");
1049
- badge.className = "mention-badge";
1050
- badge.textContent = "@MENTION";
1051
- header.appendChild(badge);
1052
-
1053
- var ts = document.createElement("span");
1054
- ts.className = "dm-bubble-time";
1055
- ts.textContent = timeStr();
1056
- header.appendChild(ts);
1057
- contentWrap.appendChild(header);
1058
-
1059
- var contentDiv = document.createElement("div");
1060
- contentDiv.className = "md-content mention-content";
1061
- contentDiv.dir = "auto";
1062
- contentDiv.innerHTML = renderMarkdown(entry.text || "");
1063
- highlightCodeBlocks(contentDiv);
1064
- contentWrap.appendChild(contentDiv);
1065
- el.appendChild(contentWrap);
1066
-
1067
- if (ctx.addToMessages) ctx.addToMessages(el);
1068
- else if (ctx.messagesEl) ctx.messagesEl.appendChild(el);
1069
- } else {
1070
- // Project chat: use mention block style
1071
- var el = document.createElement("div");
1072
- el.className = "msg-mention";
1073
- el.style.setProperty("--mention-color", entry.avatarColor || "#6c5ce7");
1074
-
1075
- var mheader = document.createElement("div");
1076
- mheader.className = "mention-header";
1077
-
1078
- var avatar = document.createElement("img");
1079
- avatar.className = "mention-avatar";
1080
- avatar.src = avatarSrc;
1081
- avatar.width = 20;
1082
- avatar.height = 20;
1083
- mheader.appendChild(avatar);
1084
-
1085
- var mname = document.createElement("span");
1086
- mname.className = "mention-name";
1087
- mname.textContent = entry.mateName || "Mate";
1088
- mheader.appendChild(mname);
1089
-
1090
- el.appendChild(mheader);
1091
-
1092
- var contentDiv = document.createElement("div");
1093
- contentDiv.className = "md-content mention-content";
1094
- contentDiv.dir = "auto";
1095
- contentDiv.innerHTML = renderMarkdown(entry.text || "");
1096
- highlightCodeBlocks(contentDiv);
1097
- el.appendChild(contentDiv);
1098
-
1099
- if (ctx.addToMessages) ctx.addToMessages(el);
1100
- else if (ctx.messagesEl) ctx.messagesEl.appendChild(el);
1101
- }
943
+ var el = document.createElement("div");
944
+ el.className = "msg-assistant msg-mention-dm";
945
+
946
+ var avi = document.createElement("img");
947
+ avi.className = "dm-bubble-avatar dm-bubble-avatar-agent";
948
+ avi.src = avatarSrc;
949
+ avi.alt = "";
950
+
951
+ var badge = document.createElement("span");
952
+ badge.className = "mention-badge";
953
+ badge.textContent = "@MENTION";
954
+
955
+ el.appendChild(buildMessageHeader({
956
+ side: "other",
957
+ avatarEl: avi,
958
+ name: entry.mateName || "Mate",
959
+ nameColor: entry.avatarColor,
960
+ extras: [badge],
961
+ time: timeStr(),
962
+ }).el);
963
+
964
+ var contentDiv = document.createElement("div");
965
+ contentDiv.className = "md-content mention-content";
966
+ contentDiv.dir = "auto";
967
+ contentDiv.innerHTML = renderMarkdown(entry.text || "");
968
+ highlightCodeBlocks(contentDiv);
969
+ el.appendChild(contentDiv);
970
+
971
+ if (ctx.addToMessages) ctx.addToMessages(el);
972
+ else if (ctx.messagesEl) ctx.messagesEl.appendChild(el);
1102
973
 
1103
974
  // Add copy handler
1104
975
  if (ctx.addCopyHandler && entry.text) {
@@ -0,0 +1,80 @@
1
+ // message-header.js - the one header line every message in the transcript uses.
2
+ //
3
+ // buildMessageHeader({ side, avatarEl, showAvatar, name, nameColor, showName,
4
+ // label, time, extras, control, actions, compact })
5
+ //
6
+ // Avatar, name, label, time and controls sit on a single line of
7
+ // --msg-header-height; nothing in a header is placed on a row by itself. The
8
+ // other-speaker side reads avatar, name, label, time, then the controls at the
9
+ // far end. The own side is the same line mirrored by CSS (row-reverse), so the
10
+ // DOM order is the same and a screen reader hears one order for both.
11
+ //
12
+ // Per-use options, so a surface adapts the shape and never forks it:
13
+ // side "other" (default) or "own": picks the mirrored styling
14
+ // avatarEl the <img> the caller built (through agent-avatar.js for an agent);
15
+ // absent draws no avatar
16
+ // showAvatar false draws no avatar even when avatarEl is given (default true)
17
+ // name the speaker's name; showName false leaves it out (default true)
18
+ // nameColor an accent for the name (a mention's own colour)
19
+ // label the one-line label after the name (an injected message's
20
+ // initiator, note and sender kind)
21
+ // time the time text; absent draws none
22
+ // extras elements placed after the label (badges, a stop button)
23
+ // control the collapse control, placed at the far end
24
+ // actions the copy/fork/rewind bar, placed after the control
25
+ // compact the compact header: avatar and name are left out and only the
26
+ // time and controls remain
27
+ //
28
+ // Returns { el, avatarEl, nameEl, labelEl, timeEl }. All text is set with
29
+ // textContent; a name or label can come from another process.
30
+
31
+ // Avatars are drawn at --msg-avatar-size; resolvers are asked for twice that so
32
+ // they stay sharp on a dense screen.
33
+ export var AVATAR_REQUEST_SIZE = 48;
34
+
35
+ function textSpan(className, text) {
36
+ var span = document.createElement("span");
37
+ span.className = className;
38
+ span.textContent = text;
39
+ return span;
40
+ }
41
+
42
+ export function buildMessageHeader(options) {
43
+ var o = options || {};
44
+ var own = o.side === "own";
45
+ var header = document.createElement("div");
46
+ header.className = "dm-bubble-header msg-header" + (own ? " msg-header-own" : "") + (o.compact ? " msg-header-compact" : "");
47
+
48
+ var avatarEl = null;
49
+ if (o.avatarEl && o.showAvatar !== false && !o.compact) {
50
+ avatarEl = o.avatarEl;
51
+ avatarEl.classList.add("msg-header-avatar");
52
+ header.appendChild(avatarEl);
53
+ }
54
+
55
+ var nameEl = null;
56
+ if (o.name != null && o.showName !== false && !o.compact) {
57
+ nameEl = textSpan("dm-bubble-name", o.name);
58
+ if (o.nameColor) nameEl.style.color = o.nameColor;
59
+ header.appendChild(nameEl);
60
+ }
61
+
62
+ var labelEl = null;
63
+ if (o.label) {
64
+ labelEl = textSpan("injected-label msg-header-label", o.label);
65
+ header.appendChild(labelEl);
66
+ }
67
+
68
+ (o.extras || []).forEach(function (extra) { header.appendChild(extra); });
69
+
70
+ var timeEl = null;
71
+ if (o.time) {
72
+ timeEl = textSpan("dm-bubble-time", o.time);
73
+ header.appendChild(timeEl);
74
+ }
75
+
76
+ if (o.control) header.appendChild(o.control);
77
+ if (o.actions) header.appendChild(o.actions);
78
+
79
+ return { el: header, avatarEl: avatarEl, nameEl: nameEl, labelEl: labelEl, timeEl: timeEl };
80
+ }
@@ -0,0 +1,39 @@
1
+ // message-participants.js - how many different people have typed in the
2
+ // transcript on screen, which decides what the viewer's own header shows: time
3
+ // only while one person has spoken, avatar, name and time once two or more have.
4
+ // Agents and injected input are never people here.
5
+ //
6
+ // Pure state and no DOM, so node:test can run it. The renderer calls noteHuman()
7
+ // for each typed message and applies the result as a class on the transcript;
8
+ // the stylesheet does the rest, so an earlier own message changes the moment a
9
+ // second person speaks.
10
+
11
+ export var MULTI_HUMAN_CLASS = "multi-human";
12
+
13
+ var speakers = Object.create(null);
14
+ var count = 0;
15
+
16
+ /** Records a person who typed a message. Returns how many people have spoken. */
17
+ export function noteHuman(userId) {
18
+ var key = userId == null || userId === "" ? "self" : String(userId);
19
+ if (!speakers[key]) {
20
+ speakers[key] = true;
21
+ count++;
22
+ }
23
+ return count;
24
+ }
25
+
26
+ export function humanCount() {
27
+ return count;
28
+ }
29
+
30
+ /** True once two or more people have spoken. */
31
+ export function isMultiHuman() {
32
+ return count >= 2;
33
+ }
34
+
35
+ /** Forget everyone: the transcript was cleared (session or project switch). */
36
+ export function resetHumans() {
37
+ speakers = Object.create(null);
38
+ count = 0;
39
+ }