@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
@@ -4,11 +4,12 @@
4
4
  import { escapeHtml, showToast } from './utils.js';
5
5
  import { iconHtml, refreshIcons } from './icons.js';
6
6
  import { openProjectSettings } from './project-settings.js';
7
+ import { canOpenProjectSettings } from './settings-access.js';
7
8
  import { triggerShare } from './qrcode.js';
8
9
  import { parseEmojis } from './markdown.js';
9
10
  import { buildEmojiPicker } from './emoji-picker.js';
10
11
  import { renderProjectIcon, projectIconHtml } from './project-icon.js';
11
- import { positionPopover } from './popover-position.js';
12
+ import { showOverlay } from './overlay.js';
12
13
  import { store } from './store.js';
13
14
  import { getWs } from './ws-ref.js';
14
15
  import { closeSidebar } from './sidebar.js';
@@ -60,12 +61,6 @@ var cachedFolderMeta = {};
60
61
 
61
62
  export function initSidebarProjects() {
62
63
 
63
- // Close project ctx menu and emoji picker on document click
64
- document.addEventListener("click", function () {
65
- closeProjectCtxMenu();
66
- closeEmojiPicker();
67
- });
68
-
69
64
  // Initialize icon strip buttons
70
65
  var addBtn = document.getElementById("icon-strip-add");
71
66
  if (addBtn) {
@@ -117,15 +112,15 @@ export function initSidebarProjects() {
117
112
  }
118
113
  if (!current) return;
119
114
 
120
- if (projectCtxMenu) {
115
+ if (projectCtxMenu && projectCtxMenu.isOpen()) {
121
116
  closeProjectCtxMenu();
122
117
  dropdownBtn.classList.remove("open");
123
118
  return;
124
119
  }
125
120
  dropdownBtn.classList.add("open");
126
- showProjectCtxMenu(dropdownBtn, current.slug, current.name, current.icon, "below");
121
+ showProjectCtxMenu(dropdownBtn, current.slug, current.name, current.icon, "below", dropdownBtn);
127
122
  var observer = new MutationObserver(function () {
128
- if (!projectCtxMenu) {
123
+ if (!projectCtxMenu || !projectCtxMenu.isOpen()) {
129
124
  dropdownBtn.classList.remove("open");
130
125
  observer.disconnect();
131
126
  }
@@ -166,42 +161,42 @@ export { getProjectAbbrev };
166
161
 
167
162
  // --- Project Access Popover ---
168
163
 
169
- function closeAccessOnOutside(e) {
170
- if (projectAccessPopover && !projectAccessPopover.contains(e.target)) closeProjectAccessPopover();
171
- }
172
- function closeAccessOnEscape(e) {
173
- if (e.key === "Escape") closeProjectAccessPopover();
174
- }
175
-
176
164
  function closeProjectAccessPopover() {
177
165
  if (projectAccessPopover) {
178
- projectAccessPopover.remove();
166
+ projectAccessPopover.close();
179
167
  projectAccessPopover = null;
180
- document.removeEventListener("click", closeAccessOnOutside);
181
- document.removeEventListener("keydown", closeAccessOnEscape);
182
168
  }
183
169
  }
184
170
 
185
- function showProjectAccessPopover(anchorEl, slug) {
171
+ // Who is offered Manage Access for a project: the project's owner or an admin,
172
+ // never a worktree. The desktop project menu and the phone project sheet share it.
173
+ export function canManageProjectAccess(slug) {
174
+ if (slug.indexOf("--") !== -1) return false;
175
+ var isProjectOwner = store.get('myUserId') && store.get('currentProjectOwnerId') && store.get('myUserId') === store.get('currentProjectOwnerId');
176
+ var isAdmin = store.get('permissions') && store.get('permissions').projectSettings !== false;
177
+ return !!(isProjectOwner || isAdmin);
178
+ }
179
+
180
+ export function showProjectAccessPopover(anchorEl, slug) {
186
181
  closeProjectAccessPopover();
187
182
 
183
+ // The shared close control is a child of the card, so the loaded content goes
184
+ // in its own element: redrawing it never removes the control.
188
185
  var popover = document.createElement("div");
189
- popover.className = "project-access-popover";
186
+ popover.className = "project-access-body";
190
187
  popover.innerHTML = '<div class="project-access-loading">Loading...</div>';
191
- popover.addEventListener("click", function (e) { e.stopPropagation(); });
192
- document.body.appendChild(popover);
193
- projectAccessPopover = popover;
194
-
195
- requestAnimationFrame(function () {
196
- positionPopover(popover, anchorEl, { placement: "right", gap: 8 });
197
- popover.style.zIndex = "9999";
188
+ // 8px: the gap this popover has always kept from the project icon.
189
+ projectAccessPopover = showOverlay({
190
+ kind: "popover",
191
+ className: "project-access-popover",
192
+ content: popover,
193
+ anchor: anchorEl,
194
+ placement: "right",
195
+ gap: 8,
196
+ closeButton: true,
197
+ closeLabel: "Close project access",
198
198
  });
199
199
 
200
- setTimeout(function () {
201
- document.addEventListener("click", closeAccessOnOutside);
202
- document.addEventListener("keydown", closeAccessOnEscape);
203
- }, 0);
204
-
205
200
  Promise.all([
206
201
  fetch("/api/admin/projects/" + encodeURIComponent(slug) + "/access").then(function (r) { return r.json(); }),
207
202
  fetch("/api/admin/users").then(function (r) { return r.json(); }),
@@ -228,7 +223,6 @@ function renderAccessPopover(popover, slug, access, allUsers) {
228
223
  var html = '';
229
224
  html += '<div class="project-access-header">';
230
225
  html += '<span class="project-access-title">Project Access</span>';
231
- html += '<button class="project-access-close">&times;</button>';
232
226
  html += '</div>';
233
227
 
234
228
  html += '<div class="project-access-section">';
@@ -263,10 +257,6 @@ function renderAccessPopover(popover, slug, access, allUsers) {
263
257
  popover.innerHTML = html;
264
258
  refreshIcons();
265
259
 
266
- popover.querySelector(".project-access-close").addEventListener("click", function () {
267
- closeProjectAccessPopover();
268
- });
269
-
270
260
  popover.querySelectorAll(".project-access-vis-btn").forEach(function (btn) {
271
261
  btn.addEventListener("click", function () {
272
262
  var newVis = btn.dataset.vis;
@@ -324,7 +314,7 @@ function renderAccessPopover(popover, slug, access, allUsers) {
324
314
 
325
315
  export function closeProjectCtxMenu() {
326
316
  if (projectCtxMenu) {
327
- projectCtxMenu.remove();
317
+ projectCtxMenu.close();
328
318
  projectCtxMenu = null;
329
319
  }
330
320
  }
@@ -391,16 +381,10 @@ function showIconCtxMenu(anchorEl, slug, name) {
391
381
  }
392
382
  }
393
383
 
394
- document.body.appendChild(menu);
395
- projectCtxMenu = menu;
396
- refreshIcons();
397
-
398
- requestAnimationFrame(function () {
399
- positionPopover(menu, anchorEl, { placement: "right" });
400
- });
384
+ projectCtxMenu = showOverlay({ kind: "menu", el: menu, anchor: anchorEl, placement: "right" });
401
385
  }
402
386
 
403
- function showProjectCtxMenu(anchorEl, slug, name, icon, position) {
387
+ function showProjectCtxMenu(anchorEl, slug, name, icon, position, opener) {
404
388
  closeProjectCtxMenu();
405
389
  if (closeUserCtxMenu) closeUserCtxMenu();
406
390
  closeEmojiPicker();
@@ -420,7 +404,7 @@ function showProjectCtxMenu(anchorEl, slug, name, icon, position) {
420
404
  menu.appendChild(iconItem);
421
405
 
422
406
  // --- Project Settings ---
423
- if (!store.get('permissions') || store.get('permissions').projectSettings !== false) {
407
+ if (canOpenProjectSettings(store.get('permissions'))) {
424
408
  var settingsItem = document.createElement("button");
425
409
  settingsItem.className = "project-ctx-item";
426
410
  settingsItem.innerHTML = iconHtml("settings") + " <span>Project Settings</span>";
@@ -480,20 +464,16 @@ function showProjectCtxMenu(anchorEl, slug, name, icon, position) {
480
464
  menu.appendChild(shareItem);
481
465
 
482
466
  // --- Manage Access ---
483
- if (slug.indexOf("--") === -1) {
484
- var isProjectOwner = store.get('myUserId') && store.get('currentProjectOwnerId') && store.get('myUserId') === store.get('currentProjectOwnerId');
485
- var isAdmin = store.get('permissions') && store.get('permissions').projectSettings !== false;
486
- if (isProjectOwner || isAdmin) {
487
- var accessItem = document.createElement("button");
488
- accessItem.className = "project-ctx-item";
489
- accessItem.innerHTML = iconHtml("users") + " <span>Manage Access</span>";
490
- accessItem.addEventListener("click", function (e) {
491
- e.stopPropagation();
492
- closeProjectCtxMenu();
493
- showProjectAccessPopover(anchorEl, slug);
494
- });
495
- menu.appendChild(accessItem);
496
- }
467
+ if (canManageProjectAccess(slug)) {
468
+ var accessItem = document.createElement("button");
469
+ accessItem.className = "project-ctx-item";
470
+ accessItem.innerHTML = iconHtml("users") + " <span>Manage Access</span>";
471
+ accessItem.addEventListener("click", function (e) {
472
+ e.stopPropagation();
473
+ closeProjectCtxMenu();
474
+ showProjectAccessPopover(anchorEl, slug);
475
+ });
476
+ menu.appendChild(accessItem);
497
477
  }
498
478
 
499
479
  var sep2 = document.createElement("div");
@@ -538,7 +518,7 @@ function showProjectCtxMenu(anchorEl, slug, name, icon, position) {
538
518
  moveFolderItem.addEventListener("click", function (e) {
539
519
  e.stopPropagation();
540
520
  closeProjectCtxMenu();
541
- showMoveFolderMenu(anchorEl, s, folders, position);
521
+ showMoveFolderMenu(anchorEl, s, folders, position, opener);
542
522
  });
543
523
  })(slug, existingFolders.slice());
544
524
  menu.appendChild(moveFolderItem);
@@ -600,37 +580,34 @@ function showProjectCtxMenu(anchorEl, slug, name, icon, position) {
600
580
  menu.appendChild(deleteItem);
601
581
  }
602
582
 
603
- document.body.appendChild(menu);
604
- projectCtxMenu = menu;
605
- refreshIcons();
583
+ projectCtxMenu = showOverlay(Object.assign({ kind: "menu", el: menu, anchor: anchorEl, opener: opener }, anchorPlacement(position)));
584
+ }
606
585
 
607
- requestAnimationFrame(function () {
608
- // "below" kept its original 4px gap; "right" keeps the shared default (6px).
609
- positionPopover(menu, anchorEl, position === "below" ? { placement: "below", gap: 4 } : { placement: "right" });
610
- });
586
+ // "below" kept its original 4px gap; "right" keeps the shared default (6px).
587
+ function anchorPlacement(position) {
588
+ return position === "below" ? { placement: "below", gap: 4 } : { placement: "right" };
611
589
  }
612
590
 
613
591
  // --- Emoji picker ---
614
592
 
615
- // Position an emoji-picker popover relative to an anchor element, keeping it
616
- // fully on-screen. Delegates to the shared viewport-clamp util (lr-a10a,
617
- // generalized from the original lr-149e fix here): desktop is
618
- // anchor-relative (right of the anchor, flipped left + four-edge clamped);
619
- // mobile centers the picker in the viewport and clamps both axes — this is
620
- // what icon-strip.css's mobile block expects (it no longer sets left/right
621
- // itself, so there is nothing for these inline styles to fight).
622
- function positionEmojiPicker(picker, anchorEl) {
623
- positionPopover(picker, anchorEl, { placement: "right" });
593
+ // Open the picker as a popover anchored to an element. Placement is the shared
594
+ // viewport-clamp util (lr-a10a, generalized from the original lr-149e fix
595
+ // here): desktop is anchor-relative (right of the anchor, flipped left +
596
+ // four-edge clamped); mobile centers the picker in the viewport and clamps both
597
+ // axes — this is what icon-strip.css's mobile block expects (it no longer sets
598
+ // left/right itself, so there is nothing for these inline styles to fight).
599
+ function openEmojiPicker(picker, anchorEl) {
600
+ emojiPickerEl = showOverlay({ kind: "popover", el: picker, anchor: anchorEl, placement: "right" });
624
601
  }
625
602
 
626
603
  function closeEmojiPicker() {
627
604
  if (emojiPickerEl) {
628
- emojiPickerEl.remove();
605
+ emojiPickerEl.close();
629
606
  emojiPickerEl = null;
630
607
  }
631
608
  }
632
609
 
633
- function showEmojiPicker(slug, anchorEl) {
610
+ export function showEmojiPicker(slug, anchorEl) {
634
611
  closeEmojiPicker();
635
612
 
636
613
  var picker = buildEmojiPicker({
@@ -648,12 +625,7 @@ function showEmojiPicker(slug, anchorEl) {
648
625
  },
649
626
  });
650
627
 
651
- document.body.appendChild(picker);
652
- emojiPickerEl = picker;
653
-
654
- requestAnimationFrame(function () {
655
- positionEmojiPicker(picker, anchorEl);
656
- });
628
+ openEmojiPicker(picker, anchorEl);
657
629
  }
658
630
 
659
631
  // --- Folder emoji picker ---
@@ -675,12 +647,7 @@ function showFolderEmojiPicker(folderName, anchorEl) {
675
647
  },
676
648
  });
677
649
 
678
- document.body.appendChild(picker);
679
- emojiPickerEl = picker;
680
-
681
- requestAnimationFrame(function () {
682
- positionEmojiPicker(picker, anchorEl);
683
- });
650
+ openEmojiPicker(picker, anchorEl);
684
651
  }
685
652
 
686
653
  // --- Folder context menu ---
@@ -733,17 +700,11 @@ function showFolderCtxMenu(anchorEl, folderName) {
733
700
  });
734
701
  menu.appendChild(dissolveItem);
735
702
 
736
- document.body.appendChild(menu);
737
- projectCtxMenu = menu;
738
- refreshIcons();
739
-
740
- requestAnimationFrame(function () {
741
- positionPopover(menu, anchorEl, { placement: "right" });
742
- });
703
+ projectCtxMenu = showOverlay({ kind: "menu", el: menu, anchor: anchorEl, placement: "right" });
743
704
  }
744
705
 
745
706
  // --- Move to folder submenu ---
746
- function showMoveFolderMenu(anchorEl, slug, folders, position) {
707
+ function showMoveFolderMenu(anchorEl, slug, folders, position, opener) {
747
708
  closeProjectCtxMenu();
748
709
  var menu = document.createElement("div");
749
710
  menu.className = "project-ctx-menu";
@@ -771,14 +732,7 @@ function showMoveFolderMenu(anchorEl, slug, folders, position) {
771
732
  })(folders[i]);
772
733
  }
773
734
 
774
- document.body.appendChild(menu);
775
- projectCtxMenu = menu;
776
- refreshIcons();
777
-
778
- requestAnimationFrame(function () {
779
- // "below" kept its original 4px gap; "right" keeps the shared default (6px).
780
- positionPopover(menu, anchorEl, position === "below" ? { placement: "below", gap: 4 } : { placement: "right" });
781
- });
735
+ projectCtxMenu = showOverlay(Object.assign({ kind: "menu", el: menu, anchor: anchorEl, opener: opener }, anchorPlacement(position)));
782
736
  }
783
737
 
784
738
  // --- Folder inline rename ---
@@ -924,7 +878,7 @@ function setupDragHandlers(el, slug) {
924
878
  var ghost = document.createElement("div");
925
879
  ghost.textContent = el.textContent.trim().split("\n")[0];
926
880
  ghost.style.cssText = "position:fixed;left:-200px;top:-200px;width:38px;height:38px;border-radius:12px;" +
927
- "background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;" +
881
+ "background:var(--accent);color:var(--on-accent);display:flex;align-items:center;justify-content:center;" +
928
882
  "font-size:15px;font-weight:600;pointer-events:none;z-index:-1;";
929
883
  document.body.appendChild(ghost);
930
884
  e.dataTransfer.setDragImage(ghost, 19, 19);
@@ -1151,7 +1105,7 @@ function setupFolderDragHandlers(headerEl, folderEl, folderName, folderProjects)
1151
1105
  var ghost = document.createElement("div");
1152
1106
  ghost.textContent = folderName;
1153
1107
  ghost.style.cssText = "position:fixed;left:-200px;top:-200px;width:38px;height:38px;border-radius:12px;" +
1154
- "background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;" +
1108
+ "background:var(--accent);color:var(--on-accent);display:flex;align-items:center;justify-content:center;" +
1155
1109
  "font-size:13px;font-weight:600;pointer-events:none;z-index:-1;";
1156
1110
  document.body.appendChild(ghost);
1157
1111
  e.dataTransfer.setDragImage(ghost, 19, 19);
@@ -1384,19 +1338,15 @@ function createIconItem(p, currentSlug, activityOverride) {
1384
1338
 
1385
1339
  // --- Worktree creation modal ---
1386
1340
 
1387
- function showWorktreeModal(parentSlug, parentName) {
1388
- var existing = document.getElementById("wt-modal-container");
1389
- if (existing) existing.remove();
1390
-
1391
- var container = document.createElement("div");
1392
- container.id = "wt-modal-container";
1341
+ // The open worktree modal, so a second request replaces it.
1342
+ var worktreeModalHandle = null;
1393
1343
 
1394
- var overlay = document.createElement("div");
1395
- overlay.className = "wt-modal-overlay";
1396
- container.appendChild(overlay);
1344
+ function showWorktreeModal(parentSlug, parentName) {
1345
+ if (worktreeModalHandle) worktreeModalHandle.close();
1397
1346
 
1347
+ // What goes inside the dialog; the scrim, card, layer and close control are the
1348
+ // shared overlay component's.
1398
1349
  var modal = document.createElement("div");
1399
- modal.className = "wt-modal";
1400
1350
 
1401
1351
  var title = document.createElement("div");
1402
1352
  title.className = "wt-modal-title";
@@ -1463,9 +1413,6 @@ function showWorktreeModal(parentSlug, parentName) {
1463
1413
  actions.appendChild(createBtn);
1464
1414
 
1465
1415
  modal.appendChild(actions);
1466
- container.appendChild(modal);
1467
- document.body.appendChild(container);
1468
- branchInput.focus();
1469
1416
 
1470
1417
  // Tracks the message listener + timeout for the in-flight create_worktree
1471
1418
  // request, so a modal close (or a second create attempt) can tear down the
@@ -1483,9 +1430,24 @@ function showWorktreeModal(parentSlug, parentName) {
1483
1430
  pendingCreate = null;
1484
1431
  }
1485
1432
 
1433
+ // Closing, however it happens (Escape, the scrim, the close control, Cancel or a
1434
+ // finished create), tears down the in-flight request.
1435
+ var handle = showOverlay({
1436
+ kind: "modal",
1437
+ id: "wt-modal-container",
1438
+ dialogClass: "wt-modal",
1439
+ content: modal,
1440
+ onRemove: function () {
1441
+ clearPendingCreate();
1442
+ if (worktreeModalHandle === handle) worktreeModalHandle = null;
1443
+ },
1444
+ });
1445
+ worktreeModalHandle = handle;
1446
+ branchInput.focus();
1447
+
1486
1448
  function closeModal() {
1487
1449
  clearPendingCreate();
1488
- container.remove();
1450
+ handle.close();
1489
1451
  }
1490
1452
 
1491
1453
  function doCreate() {
@@ -1546,16 +1508,13 @@ function showWorktreeModal(parentSlug, parentName) {
1546
1508
  ws.addEventListener("message", handler);
1547
1509
  }
1548
1510
 
1549
- overlay.addEventListener("click", closeModal);
1550
1511
  cancelBtn.addEventListener("click", closeModal);
1551
1512
  createBtn.addEventListener("click", doCreate);
1552
1513
  branchInput.addEventListener("keydown", function (e) {
1553
1514
  if (e.key === "Enter") doCreate();
1554
- if (e.key === "Escape") closeModal();
1555
1515
  });
1556
1516
  baseSelect.addEventListener("keydown", function (e) {
1557
1517
  if (e.key === "Enter") doCreate();
1558
- if (e.key === "Escape") closeModal();
1559
1518
  });
1560
1519
  }
1561
1520
 
@@ -18,8 +18,11 @@ import { getUpcomingSchedules } from './scheduler.js';
18
18
  import { refreshMobileChatSheet } from './sidebar-mobile.js';
19
19
  import { openAgentPicker, openAgentPickerForPreferred } from './agent-picker.js';
20
20
  import { getCachedProjects } from './app-projects.js';
21
- import { positionPopover } from './popover-position.js';
21
+ import { showOverlay } from './overlay.js';
22
22
  import { sessionActivity, rollupActivity, indicatorClass } from './activity-state.js';
23
+ import {
24
+ sessionListAvatarsEnabled, onSessionListAvatarsChange, createSessionAgentAvatar
25
+ } from './session-list-avatars.js';
23
26
 
24
27
 
25
28
  // --- Session state ---
@@ -38,6 +41,10 @@ var expandedLoopRuns = new Set();
38
41
  // updateSessionPresence() and don't need a full rebuild.
39
42
  var _sessionListFingerprint = "";
40
43
 
44
+ // Switching "Avatars in session list" repaints the list (the fingerprint carries
45
+ // the setting) and, through renderSessionList, the phone chat list.
46
+ onSessionListAvatarsChange(function () { renderSessionList(); });
47
+
41
48
  // --- Session presence (multi-user: who is viewing which session) ---
42
49
  var sessionPresence = {}; // { sessionId: [{ id, displayName, avatarStyle, avatarSeed }] }
43
50
 
@@ -51,6 +58,7 @@ var sessionCtxSessionId = null;
51
58
  var draggedSessionId = null;
52
59
  var draggedSessionBookmarked = false;
53
60
  var openResumePickerModal = function () {};
61
+ var closeResumePickerModal = function () {};
54
62
  var headerSearchOpen = false;
55
63
  var armedDeleteSessionId = null;
56
64
  var armedDeleteTimer = null;
@@ -504,7 +512,6 @@ function clearSessionSearch(shouldBlur, input, shouldClose) {
504
512
  export function initSidebarSessions() {
505
513
 
506
514
  document.addEventListener("click", function () {
507
- closeSessionCtxMenu();
508
515
  clearArmedSessionDelete();
509
516
  });
510
517
 
@@ -566,8 +573,10 @@ export function initSidebarSessions() {
566
573
  var pickerEmpty = document.getElementById("resume-picker-empty");
567
574
  var pickerList = document.getElementById("resume-picker-list");
568
575
 
576
+ var resumeHandle = null;
577
+
569
578
  function openResumeModal() {
570
- resumeModal.classList.remove("hidden");
579
+ resumeHandle = showOverlay({ kind: "modal", el: resumeModal });
571
580
  pickerLoading.classList.remove("hidden");
572
581
  pickerEmpty.classList.add("hidden");
573
582
  pickerList.classList.add("hidden");
@@ -579,11 +588,11 @@ export function initSidebarSessions() {
579
588
  openResumePickerModal = openResumeModal;
580
589
 
581
590
  function closeResumeModal() {
582
- resumeModal.classList.add("hidden");
591
+ if (resumeHandle) resumeHandle.close();
583
592
  }
593
+ closeResumePickerModal = closeResumeModal;
584
594
 
585
595
  resumeCancel.addEventListener("click", closeResumeModal);
586
- resumeModal.querySelector(".confirm-backdrop").addEventListener("click", closeResumeModal);
587
596
 
588
597
  // --- Import CLI palette tile ---
589
598
  // The button is created by tool-palette.js with this ID; we wire the handler here.
@@ -647,13 +656,28 @@ export function getExpandedLoopRuns() {
647
656
 
648
657
  function closeSessionCtxMenu() {
649
658
  if (sessionCtxMenu) {
650
- sessionCtxMenu.remove();
659
+ sessionCtxMenu.close();
651
660
  sessionCtxMenu = null;
652
661
  sessionCtxSessionId = null;
653
662
  }
654
663
  }
655
664
 
656
- function showSessionCtxMenu(anchorBtn, sessionId, title, cliSid, sessionData) {
665
+ /**
666
+ * Open the action menu for one session row. The desktop row and the phone row's
667
+ * actions control both open it, so the two offer the same actions.
668
+ *
669
+ * @param {Element} anchorBtn the element the menu hangs from.
670
+ * @param {number|string} sessionId
671
+ * @param {string} title
672
+ * @param {string} cliSid unused; kept for the existing call shape.
673
+ * @param {object} sessionData the session's list entry.
674
+ * @param {object} [opts]
675
+ * @param {function(number|string, string): void} [opts.onRename] replaces the
676
+ * inline rename, which edits the desktop list; the phone list has none.
677
+ * @param {Element} [opts.opener] the control that opens the menu, so a second tap
678
+ * on it closes the menu instead of reopening it.
679
+ */
680
+ export function showSessionCtxMenu(anchorBtn, sessionId, title, cliSid, sessionData, opts) {
657
681
  closeSessionCtxMenu();
658
682
  sessionCtxSessionId = sessionId;
659
683
 
@@ -698,7 +722,8 @@ function showSessionCtxMenu(anchorBtn, sessionId, title, cliSid, sessionData) {
698
722
  renameItem.addEventListener("click", function (e) {
699
723
  e.stopPropagation();
700
724
  closeSessionCtxMenu();
701
- startInlineRename(sessionId, title);
725
+ if (opts && opts.onRename) opts.onRename(sessionId, title);
726
+ else startInlineRename(sessionId, title);
702
727
  });
703
728
  menu.appendChild(renameItem);
704
729
 
@@ -742,16 +767,15 @@ function showSessionCtxMenu(anchorBtn, sessionId, title, cliSid, sessionData) {
742
767
  menu.appendChild(deleteItem);
743
768
  }
744
769
 
745
- document.body.appendChild(menu);
746
- sessionCtxMenu = menu;
747
- refreshIcons();
748
-
749
- // Position: fixed relative to the anchor button, right-edge aligned,
770
+ // Position: relative to the anchor button, right-edge aligned,
750
771
  // flip-then-clamp on all four edges (lr-a10a: the prior bottom-flip-only
751
772
  // logic could leave the flipped menu with top < 0 on a short viewport).
752
- requestAnimationFrame(function () {
753
- positionPopover(menu, anchorBtn, { placement: "below-right-aligned", gap: 2 });
754
- });
773
+ openSessionCtxMenu(menu, anchorBtn, opts && opts.opener);
774
+ }
775
+
776
+ // 2px: the gap these menus have always kept under their button.
777
+ function openSessionCtxMenu(menu, anchorBtn, opener) {
778
+ sessionCtxMenu = showOverlay({ kind: "menu", el: menu, anchor: anchorBtn, placement: "below-right-aligned", gap: 2, opener: opener });
755
779
  }
756
780
 
757
781
  function showLoopCtxMenu(anchorBtn, loopId, loopName, childCount) {
@@ -789,13 +813,7 @@ function showLoopCtxMenu(anchorBtn, loopId, loopName, childCount) {
789
813
  menu.appendChild(deleteItem);
790
814
  }
791
815
 
792
- document.body.appendChild(menu);
793
- sessionCtxMenu = menu;
794
- refreshIcons();
795
-
796
- requestAnimationFrame(function () {
797
- positionPopover(menu, anchorBtn, { placement: "below-right-aligned", gap: 2 });
798
- });
816
+ openSessionCtxMenu(menu, anchorBtn);
799
817
  }
800
818
 
801
819
  // --- Inline rename ---
@@ -1297,20 +1315,26 @@ function renderSessionItem(s) {
1297
1315
  textHtml += '<span class="session-processing ' + itemActivityCls + '" title="' + escapeHtml(itemActivityState.label) + '"></span>';
1298
1316
  }
1299
1317
  textHtml += compactingBadgeHtml(s);
1300
- if (s.sessionVisibility === "private") {
1301
- textHtml += '<span class="session-private-icon" title="Private session">' + iconHtml("lock") + '</span>';
1302
- }
1318
+ textHtml += privateIndicatorHtml(s);
1303
1319
  // lr-7db0 — agent badge for sessions cast as a named agent via the SDK `agent` option.
1304
1320
  // Icon-only with the agent name in `title` matches the lock-icon convention for
1305
1321
  // private sessions (above) and prevents the agent name from bleeding into the
1306
1322
  // window title via .session-item-text.textContent in sidebar.js:updatePageTitle.
1307
- if (s.agentName) {
1323
+ // With avatars on, the agent's avatar leads the row, before everything else, and
1324
+ // the badge is not drawn; an element, not markup, so the shared avatar keeps its
1325
+ // repaint binding.
1326
+ var avatarOn = !!s.agentName && sessionListAvatarsEnabled();
1327
+ if (s.agentName && !avatarOn) {
1308
1328
  textHtml += '<span class="session-agent-badge" title="Agent: ' + escapeHtml(s.agentName) + '">'
1309
1329
  + iconHtml("bot") + '</span>';
1310
1330
  }
1311
- textHtml += keepAliveBadgeHtml(s);
1312
- textHtml += highlightMatch(s.title || "New Session", searchQuery);
1313
- textSpan.innerHTML = textHtml;
1331
+ var tailHtml = keepAliveBadgeHtml(s) + highlightMatch(s.title || "New Session", searchQuery);
1332
+ if (avatarOn) {
1333
+ textSpan.appendChild(createSessionAgentAvatar(s.agentName));
1334
+ textSpan.insertAdjacentHTML("beforeend", textHtml + tailHtml);
1335
+ } else {
1336
+ textSpan.innerHTML = textHtml + tailHtml;
1337
+ }
1314
1338
  el.appendChild(textSpan);
1315
1339
 
1316
1340
  // Right-click / long-press: context menu
@@ -1357,10 +1381,17 @@ function renderSessionItem(s) {
1357
1381
  // --- Main session list ---
1358
1382
 
1359
1383
  // Text, not colour alone: the list entry carries the vendor-reported flag.
1360
- function compactingBadgeHtml(s) {
1384
+ // Exported so the phone row draws the same markup as the desktop row.
1385
+ export function compactingBadgeHtml(s) {
1361
1386
  return s.compacting ? '<span class="session-compacting" title="Compacting context">Compacting</span>' : "";
1362
1387
  }
1363
1388
 
1389
+ export function privateIndicatorHtml(s) {
1390
+ return s.sessionVisibility === "private"
1391
+ ? '<span class="session-private-icon" title="Private session">' + iconHtml("lock") + '</span>'
1392
+ : "";
1393
+ }
1394
+
1364
1395
  // lr-66c118: the activity field below is the derived class (indicatorClass/
1365
1396
  // sessionActivity), not a raw processing-flag read — also captures an
1366
1397
  // ownerId-driven tone change a boolean would have missed.
@@ -1410,7 +1441,9 @@ export function renderSessionList(sessions) {
1410
1441
  // finding that the original version suspended before knowing whether a
1411
1442
  // rebuild would run.
1412
1443
  var fp = _fingerprintSessions(cachedSessions, expandedLoopGroups, expandedLoopRuns) +
1413
- "|sq:" + searchQuery + "|sm:" + (searchMatchIds ? searchMatchIds.size : "null");
1444
+ "|sq:" + searchQuery + "|sm:" + (searchMatchIds ? searchMatchIds.size : "null") +
1445
+ // The setting swaps the agent badge for the avatar, so a change must repaint.
1446
+ "|av:" + (sessionListAvatarsEnabled() ? "1" : "0");
1414
1447
  if (fp === _sessionListFingerprint) {
1415
1448
  // No-op render: nothing is going to be torn down, so the active rename's
1416
1449
  // input stays live in the DOM untouched — leave activeRename alone.
@@ -1797,8 +1830,7 @@ export function populateCliSessionList(sessions) {
1797
1830
  if (getWs() && store.get('connected')) {
1798
1831
  getWs().send(JSON.stringify({ type: "resume_session", cliSessionId: sessionId }));
1799
1832
  }
1800
- var modal = document.getElementById("resume-modal");
1801
- if (modal) modal.classList.add("hidden");
1833
+ closeResumePickerModal();
1802
1834
  closeSidebar();
1803
1835
  });
1804
1836
  })(s.sessionId);
@@ -310,7 +310,7 @@ export function initSidebar(_ctx) {
310
310
  }
311
311
 
312
312
  export function spawnDustParticles(cx, cy) {
313
- var colors = ["#8B7355", "#A0522D", "#D2B48C", "#C4A882", "#9E9E9E", "#B8860B", "#BC8F8F"];
313
+ var colors = ["var(--text-dimmer)", "var(--text-muted)", "var(--border-strong)", "var(--text-secondary)", "var(--border)"];
314
314
  var count = 24;
315
315
  var container = document.createElement("div");
316
316
  container.style.position = "fixed";
@@ -319,7 +319,7 @@ export function spawnDustParticles(cx, cy) {
319
319
  container.style.width = "0";
320
320
  container.style.height = "0";
321
321
  container.style.pointerEvents = "none";
322
- container.style.zIndex = "10000";
322
+ container.style.zIndex = "var(--z-tooltip)";
323
323
  document.body.appendChild(container);
324
324
 
325
325
  for (var i = 0; i < count; i++) {