@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
@@ -0,0 +1,55 @@
1
+ // assistant-identity.js - who the assistant's messages are shown as.
2
+ //
3
+ // A session cast as a named agent shows that agent's name and its avatar from
4
+ // the shared resolver (agent-avatar.js: the operator's roster choice, else the
5
+ // seeded robot). A session with no agent shows the vendor that runs it. The
6
+ // agent key is the name exactly as the roster records it.
7
+ //
8
+ // A header never names a vendor the session did not run on: with no vendor
9
+ // known at all it shows a neutral "Assistant" with no vendor avatar.
10
+
11
+ import { VENDOR_AVATARS, VENDOR_NAMES } from "./vendor-registry.js";
12
+ import { listedVendor } from "./session-vendor-state.js";
13
+
14
+ export var NEUTRAL_ASSISTANT_NAME = "Assistant";
15
+
16
+ /** The vendor the active session shows: the page's, else the session list's. */
17
+ export function activeVendorId(get) {
18
+ return get("currentVendor") || listedVendor(get("sessionVendors"), get("activeSessionId"));
19
+ }
20
+
21
+ export var LOOP_QUEUE_PLACEHOLDER = "Message queues for the next loop iteration…";
22
+
23
+ /**
24
+ * The composer's placeholder: the loop queue wording while queue mode is on,
25
+ * else the vendor the page holds, else the one the session list records for the
26
+ * active session, else a neutral wording. It never names a vendor nothing says
27
+ * the session runs on.
28
+ * get a store getter (key => value)
29
+ */
30
+ export function composerPlaceholder(get) {
31
+ if (get("loopQueueMode")) return LOOP_QUEUE_PLACEHOLDER;
32
+ var id = activeVendorId(get);
33
+ return id && VENDOR_NAMES[id] ? "Message " + VENDOR_NAMES[id] + "..." : "Message the assistant...";
34
+ }
35
+
36
+ /**
37
+ * { name, agentKey, avatarUrl } for the assistant of a session.
38
+ * vendor the page's current vendor id (claude, codex, ...), or null
39
+ * agentName the named agent the session is cast as, or null
40
+ * listedVendor the vendor the session list records for the session, used
41
+ * when the page holds none
42
+ * agentKey is null for a vendor identity, which has no roster entry.
43
+ * avatarUrl is null for the neutral identity: the caller draws a plain avatar.
44
+ */
45
+ export function assistantIdentity(vendor, agentName, listedVendor) {
46
+ var name = typeof agentName === "string" ? agentName.trim() : "";
47
+ if (name) return { name: name, agentKey: agentName, avatarUrl: null };
48
+ var id = vendor || listedVendor;
49
+ if (!id || !VENDOR_NAMES[id]) return { name: NEUTRAL_ASSISTANT_NAME, agentKey: null, avatarUrl: null };
50
+ return {
51
+ name: VENDOR_NAMES[id],
52
+ agentKey: null,
53
+ avatarUrl: VENDOR_AVATARS[id] || null,
54
+ };
55
+ }
@@ -31,6 +31,7 @@
31
31
 
32
32
  import { escapeHtml } from './utils.js';
33
33
  import { getWs } from './ws-ref.js';
34
+ import { openInputList, closeInputList } from './input-list-menu.js';
34
35
 
35
36
  // --- Module state ---
36
37
  var _ctx = null;
@@ -118,6 +119,7 @@ export function hideAgentMenu() {
118
119
  if (_menuEl) {
119
120
  _menuEl.classList.remove("visible");
120
121
  _menuEl.innerHTML = "";
122
+ closeInputList(_menuEl);
121
123
  }
122
124
  }
123
125
 
@@ -209,6 +211,7 @@ function _render(query) {
209
211
  }
210
212
  _menuEl.innerHTML = html;
211
213
  _menuEl.classList.add("visible");
214
+ openInputList(_menuEl, _ctx && _ctx.inputEl, hideAgentMenu);
212
215
 
213
216
  // Bind mouseenter for hover highlighting.
214
217
  var itemEls = _menuEl.querySelectorAll(".at-agents-item");
@@ -9,6 +9,10 @@
9
9
  // unsent input the guard shows a banner the user acts on instead, and reloads
10
10
  // at once when there is nothing to lose.
11
11
 
12
+ import { showOverlay } from './overlay.js';
13
+
14
+ var RELOAD_BANNER_ID = "sw-update-banner";
15
+
12
16
  export function createBuildGuard(deps) {
13
17
  var booted = null;
14
18
  var acted = false;
@@ -40,22 +44,32 @@ export function createBuildGuard(deps) {
40
44
  return { observe: observe, observeInfo: observeInfo };
41
45
  }
42
46
 
43
- // Not dismissable: the page is running code the server no longer matches.
44
- export function showReloadBanner(doc, reload) {
45
- if (doc.getElementById("sw-update-banner")) return;
46
- var banner = doc.createElement("div");
47
- banner.id = "sw-update-banner";
48
- banner.className = "sw-update-banner";
47
+ /**
48
+ * The reload banner, drawn once however many paths ask (the build guard here,
49
+ * the service worker's update message in notifications.js: both share its id).
50
+ * By default it is not dismissable: the page is running code the server no
51
+ * longer matches.
52
+ * @param {Document} doc
53
+ * @param {function(): void} reload
54
+ * @param {{text?: string, dismissible?: boolean}} [opts]
55
+ */
56
+ export function showReloadBanner(doc, reload, opts) {
57
+ var o = opts || {};
58
+ if (doc.getElementById(RELOAD_BANNER_ID)) return;
49
59
  var text = doc.createElement("span");
50
60
  text.className = "sw-update-banner-text";
51
- text.textContent = "Clagentic: Console was updated. Reload to continue.";
61
+ text.textContent = o.text || "Clagentic: Console was updated. Reload to continue.";
52
62
  var button = doc.createElement("button");
53
63
  button.className = "sw-update-banner-btn";
54
64
  button.id = "sw-update-reload";
55
65
  button.textContent = "Reload";
56
66
  button.addEventListener("click", reload);
57
- banner.appendChild(text);
58
- banner.appendChild(button);
59
- doc.body.appendChild(banner);
60
- banner.classList.add("visible");
67
+ showOverlay({
68
+ doc: doc,
69
+ kind: "banner",
70
+ id: RELOAD_BANNER_ID,
71
+ className: "sw-update-banner",
72
+ content: [text, button],
73
+ dismissible: o.dismissible === true,
74
+ });
61
75
  }
@@ -0,0 +1,75 @@
1
+ // The Appearance chat width choice, one component for every surface that offers
2
+ // it (the desktop Settings page, and the same panel the phone Settings list opens).
3
+ //
4
+ // mountChatWidthChoice(container, { showDescriptions, onChange })
5
+ //
6
+ // It offers Compact, Comfortable, Wide and Full, marks the current step and keeps
7
+ // itself current when the step changes anywhere (another surface, another
8
+ // device's saved choice arriving with the profile). Choosing goes through
9
+ // chat-width.js, which applies the step at once and saves it on the server.
10
+ //
11
+ // Per-use options, so a surface adapts the shape and never forks it:
12
+ // showDescriptions show each step's one-line description (default true)
13
+ // onChange called with the chosen option after it is applied
14
+
15
+ import { WIDTH_OPTIONS } from './chat-width-prefs.js';
16
+ import { getChatWidth, setChatWidth, onChatWidthChange } from './chat-width.js';
17
+
18
+ function textEl(className, text) {
19
+ var span = document.createElement("span");
20
+ span.className = className;
21
+ span.textContent = text;
22
+ return span;
23
+ }
24
+
25
+ function buildCard(option, selected, showDescriptions) {
26
+ var btn = document.createElement("button");
27
+ btn.type = "button";
28
+ btn.className = "layout-option" + (selected ? " selected" : "");
29
+ btn.appendChild(textEl("layout-option-label", option.label));
30
+ if (showDescriptions) btn.appendChild(textEl("layout-option-desc", option.description));
31
+ return btn;
32
+ }
33
+
34
+ /**
35
+ * Renders the choice into `container` and keeps it current. Returns a function
36
+ * that stops updating it; the component also stops by itself once `container`
37
+ * has left the document.
38
+ */
39
+ export function mountChatWidthChoice(container, options) {
40
+ var opts = options || {};
41
+ var showDescriptions = opts.showDescriptions !== undefined ? !!opts.showDescriptions : true;
42
+ var unsubscribe = null;
43
+
44
+ container.setAttribute("role", "radiogroup");
45
+ container.setAttribute("aria-label", "Chat width");
46
+
47
+ function render() {
48
+ if (unsubscribe && !container.isConnected) {
49
+ unsubscribe();
50
+ unsubscribe = null;
51
+ return;
52
+ }
53
+ var selected = getChatWidth();
54
+ container.textContent = "";
55
+ WIDTH_OPTIONS.forEach(function (option) {
56
+ var isSelected = option.key === selected;
57
+ var el = buildCard(option, isSelected, showDescriptions);
58
+ el.setAttribute("role", "radio");
59
+ el.setAttribute("aria-checked", isSelected ? "true" : "false");
60
+ el.dataset.widthOption = option.key;
61
+ el.addEventListener("click", function () {
62
+ setChatWidth(option.key);
63
+ if (opts.onChange) opts.onChange(option);
64
+ });
65
+ container.appendChild(el);
66
+ });
67
+ }
68
+
69
+ render();
70
+ unsubscribe = onChatWidthChange(render);
71
+ return function () {
72
+ if (unsubscribe) unsubscribe();
73
+ unsubscribe = null;
74
+ };
75
+ }
@@ -0,0 +1,52 @@
1
+ // Pure rules for the conversation width. No DOM and no imports, so the same code
2
+ // runs in the browser (chat-width.js) and under node:test.
3
+ //
4
+ // The server keeps the same list in lib/chat-width.js; a test holds them
5
+ // together. The pixel size of each step lives in css/base.css
6
+ // (--chat-width-*), not here.
7
+
8
+ export var DEFAULT_WIDTH = "comfortable";
9
+
10
+ // Label and description are what Appearance shows for each step.
11
+ export var WIDTH_OPTIONS = [
12
+ { key: "compact", label: "Compact", description: "A narrow column, 640 px" },
13
+ { key: "comfortable", label: "Comfortable", description: "The default, 820 px" },
14
+ { key: "wide", label: "Wide", description: "A wider column, 1040 px" },
15
+ { key: "full", label: "Full", description: "The whole pane. A phone is always full width" }
16
+ ];
17
+
18
+ export function isChatWidth(value) {
19
+ for (var i = 0; i < WIDTH_OPTIONS.length; i++) {
20
+ if (WIDTH_OPTIONS[i].key === value) return true;
21
+ }
22
+ return false;
23
+ }
24
+
25
+ /** The step to apply: the value itself when valid, else the default. */
26
+ export function normalizeWidth(value) {
27
+ return isChatWidth(value) ? value : DEFAULT_WIDTH;
28
+ }
29
+
30
+ // The retired bubble/channel choice, mapped once onto the closest step.
31
+ var LEGACY_LAYOUT_WIDTH = { bubble: "comfortable", channel: "full" };
32
+
33
+ /** The step a retired layout value maps to, or null when it is not one. */
34
+ export function widthFromLegacyLayout(layout) {
35
+ if (typeof layout !== "string") return null;
36
+ return Object.prototype.hasOwnProperty.call(LEGACY_LAYOUT_WIDTH, layout) ? LEGACY_LAYOUT_WIDTH[layout] : null;
37
+ }
38
+
39
+ /**
40
+ * The step the page starts on, from what this browser stored.
41
+ * stored { width, legacy }: the saved step and the retired layout value,
42
+ * each a string or null
43
+ * Returns { width, migrated }. A valid saved step wins; else the retired layout
44
+ * maps once (migrated true, so the caller drops the old key); else the default.
45
+ */
46
+ export function resolveStoredWidth(stored) {
47
+ var s = stored || {};
48
+ if (isChatWidth(s.width)) return { width: s.width, migrated: false };
49
+ var mapped = widthFromLegacyLayout(s.legacy);
50
+ if (mapped) return { width: mapped, migrated: true };
51
+ return { width: DEFAULT_WIDTH, migrated: s.legacy != null };
52
+ }
@@ -0,0 +1,102 @@
1
+ // chat-width.js - the conversation width, stored and applied the way the theme
2
+ // is: cached in localStorage for first paint, saved on the server so it follows
3
+ // the person to another device, applied without a reload.
4
+ //
5
+ // The step is the data-chat-width attribute on <html>; css/base.css turns it into
6
+ // --content-width, which every message type and the composer read. index.html's
7
+ // first-paint script sets the same attribute from the same key before any
8
+ // module loads; change both together.
9
+
10
+ import {
11
+ normalizeWidth, isChatWidth, resolveStoredWidth
12
+ } from './chat-width-prefs.js';
13
+ import { createSerializedSaver } from './serialized-save.js';
14
+ import { loadProfilePreference } from './preference-sync.js';
15
+
16
+ var WIDTH_KEY = "clagentic-chat-width";
17
+ // The key the retired bubble/channel switch used.
18
+ var LEGACY_KEY = "clagentic-wide-view";
19
+
20
+ var currentWidth = normalizeWidth(null);
21
+ var changeCallbacks = [];
22
+ // A choice made on this page outranks a profile reply that was already in flight.
23
+ var chosenThisPage = false;
24
+
25
+ // Storage can be unavailable (private mode, quota); the choice then lasts for
26
+ // the page only, which is the right degradation.
27
+ function lsGet(key) {
28
+ try { return localStorage.getItem(key); } catch (e) { return null; }
29
+ }
30
+
31
+ function lsSet(key, value) {
32
+ try { localStorage.setItem(key, value); } catch (e) {}
33
+ }
34
+
35
+ function lsRemove(key) {
36
+ try { localStorage.removeItem(key); } catch (e) {}
37
+ }
38
+
39
+ export function getChatWidth() {
40
+ return currentWidth;
41
+ }
42
+
43
+ // Returns a function that removes the listener again.
44
+ export function onChatWidthChange(fn) {
45
+ changeCallbacks.push(fn);
46
+ return function () {
47
+ var at = changeCallbacks.indexOf(fn);
48
+ if (at !== -1) changeCallbacks.splice(at, 1);
49
+ };
50
+ }
51
+
52
+ // Applies a step to the page and tells the listeners. Nothing is stored or sent.
53
+ export function applyChatWidth(width) {
54
+ var next = normalizeWidth(width);
55
+ currentWidth = next;
56
+ document.documentElement.setAttribute("data-chat-width", next);
57
+ // A snapshot: a listener that unsubscribes itself while this runs must not make
58
+ // the next one in the live array get skipped.
59
+ var listeners = changeCallbacks.slice();
60
+ for (var i = 0; i < listeners.length; i++) {
61
+ try { listeners[i](next); } catch (e) {
62
+ console.error("chat width listener failed:", e);
63
+ }
64
+ }
65
+ }
66
+
67
+ // Saves are serialized (see serialized-save.js).
68
+ var saveChatWidth = createSerializedSaver("/api/user/chat-width", "chatWidth");
69
+
70
+ // Choose a step: applied at once, cached, and saved on the server (best effort;
71
+ // the next profile load reconciles).
72
+ export function setChatWidth(width) {
73
+ if (!isChatWidth(width)) return false;
74
+ chosenThisPage = true;
75
+ lsSet(WIDTH_KEY, width);
76
+ applyChatWidth(width);
77
+ saveChatWidth(width);
78
+ return true;
79
+ }
80
+
81
+ // The server is authoritative once the profile loads, so a choice made on
82
+ // another device wins. `server` is { chatWidth } from /api/profile.
83
+ export function applyServerChatWidth(server) {
84
+ var width = server && server.chatWidth;
85
+ if (!isChatWidth(width) || chosenThisPage) return;
86
+ lsSet(WIDTH_KEY, width);
87
+ if (width !== currentWidth) applyChatWidth(width);
88
+ }
89
+
90
+ // Applies the saved step from this browser, migrating the retired layout key
91
+ // once, then asks the server for the person's own choice so another device's
92
+ // setting applies at load without opening Settings.
93
+ export function initChatWidth() {
94
+ var resolved = resolveStoredWidth({ width: lsGet(WIDTH_KEY), legacy: lsGet(LEGACY_KEY) });
95
+ if (lsGet(LEGACY_KEY) !== null) {
96
+ lsSet(WIDTH_KEY, resolved.width);
97
+ lsRemove(LEGACY_KEY);
98
+ }
99
+ applyChatWidth(resolved.width);
100
+
101
+ return loadProfilePreference("chat width", applyServerChatWidth);
102
+ }
@@ -7,6 +7,8 @@
7
7
  // and is only hidden while collapsed. State lives in the closure, so it is per
8
8
  // message and gone on reload.
9
9
 
10
+ import { iconHtml, refreshIcons } from './icons.js';
11
+
10
12
  // Lines the collapsed view shows; a text of more lines collapses.
11
13
  export var COLLAPSE_LINES = 3;
12
14
 
@@ -34,10 +36,11 @@ export function needsCollapse(text) {
34
36
  }
35
37
 
36
38
  // The first COLLAPSE_LINES non-empty lines, for the collapsed preview.
37
- export function previewLines(text) {
39
+ export function previewLines(text, count) {
40
+ var max = count > 0 ? count : COLLAPSE_LINES;
38
41
  var out = [];
39
42
  var lines = String(text == null ? "" : text).split(/\r?\n/);
40
- for (var i = 0; i < lines.length && out.length < COLLAPSE_LINES; i++) {
43
+ for (var i = 0; i < lines.length && out.length < max; i++) {
41
44
  if (lines[i].trim() !== "") out.push(lines[i]);
42
45
  }
43
46
  return out.join("\n");
@@ -48,11 +51,25 @@ export function previewLines(text) {
48
51
  // opts.collapsed: initial state (default true).
49
52
  // opts.onChange(collapsed): lets the caller mirror the state on its own
50
53
  // container; called once at build and on every toggle.
54
+ // opts.lines: lines the collapsed view shows (default COLLAPSE_LINES).
55
+ // opts.size: "normal" (default) or "compact" (smaller text, tighter line).
56
+ // opts.controls: where the caller places the toggle. "row" (default) and
57
+ // "header" leave the toggle a word button the caller's CSS places; "inline" makes
58
+ // it an icon button with an accessible name, for a host that puts it on the
59
+ // collapsed line beside its other controls. Every option left out reproduces the
60
+ // markup of a call with no options, so existing callers are unchanged.
61
+ // The icon of an inline toggle is a placeholder the page's icon pass resolves:
62
+ // the caller runs refreshIcons over the built row.
51
63
  export function buildCollapsibleText(text, opts) {
52
64
  var collapsed = !(opts && opts.collapsed === false);
65
+ var lines = opts && opts.lines > 0 ? Math.floor(opts.lines) : COLLAPSE_LINES;
66
+ var compact = !!opts && opts.size === "compact";
67
+ var inline = !!opts && opts.controls === "inline";
53
68
 
54
69
  var el = document.createElement("span");
55
70
  el.className = "collapsible-text";
71
+ if (compact) el.classList.add("collapsible-compact");
72
+ if (inline) el.classList.add("collapsible-inline");
56
73
 
57
74
  // One line of text needs no second copy: the one node is the preview while
58
75
  // collapsed (CSS clamps it) and the whole text once expanded. Several lines get
@@ -60,7 +77,12 @@ export function buildCollapsibleText(text, opts) {
60
77
  var single = String(text == null ? "" : text).indexOf("\n") === -1;
61
78
  var preview = document.createElement("span");
62
79
  preview.className = "collapsible-preview";
63
- preview.textContent = single ? text : previewLines(text);
80
+ preview.textContent = single ? text : previewLines(text, lines);
81
+ // The stylesheet clamps to COLLAPSE_LINES; another count is set on the node.
82
+ if (lines !== COLLAPSE_LINES) {
83
+ preview.style.webkitLineClamp = String(lines);
84
+ preview.style.lineClamp = String(lines);
85
+ }
64
86
  el.appendChild(preview);
65
87
  if (single) {
66
88
  el.classList.add("collapsible-single");
@@ -75,10 +97,19 @@ export function buildCollapsibleText(text, opts) {
75
97
  button.type = "button";
76
98
  button.className = "collapsible-toggle";
77
99
 
100
+ var built = false;
78
101
  function apply() {
79
102
  el.classList.toggle("is-collapsed", collapsed);
80
103
  button.setAttribute("aria-expanded", collapsed ? "false" : "true");
81
- button.textContent = collapsed ? "Expand" : "Collapse";
104
+ if (inline) {
105
+ button.setAttribute("aria-label", collapsed ? "Expand" : "Collapse");
106
+ button.title = collapsed ? "Expand" : "Collapse";
107
+ button.innerHTML = iconHtml(collapsed ? "chevron-down" : "chevron-up");
108
+ // Before the caller has placed the button the caller's own pass resolves it.
109
+ if (built) refreshIcons(button);
110
+ } else {
111
+ button.textContent = collapsed ? "Expand" : "Collapse";
112
+ }
82
113
  if (opts && typeof opts.onChange === "function") opts.onChange(collapsed);
83
114
  }
84
115
  button.addEventListener("click", function (e) {
@@ -87,6 +118,7 @@ export function buildCollapsibleText(text, opts) {
87
118
  apply();
88
119
  });
89
120
  apply();
121
+ built = true;
90
122
 
91
123
  return { el: el, button: button };
92
124
  }
@@ -2,11 +2,13 @@ import { userAvatarUrl } from './avatar.js';
2
2
  import { escapeHtml, relativeTime } from './utils.js';
3
3
  import { refreshIcons } from './icons.js';
4
4
  import { openSearch as openSessionSearch } from './session-search.js';
5
- import { pushOverlayState, popOverlayState } from './overlay-history.js';
5
+ import { showOverlay } from './overlay.js';
6
6
  import { projectIconHtml } from './project-icon.js';
7
7
 
8
8
  var ctx;
9
9
  var paletteEl = null;
10
+ // The open palette (overlay.js); null until it is first opened.
11
+ var paletteHandle = null;
10
12
  var inputEl = null;
11
13
  var resultsEl = null;
12
14
  var footerEl = null;
@@ -53,13 +55,14 @@ export function initCommandPalette(_ctx) {
53
55
  }
54
56
 
55
57
  export function isCommandPaletteOpen() {
56
- return paletteEl && !paletteEl.classList.contains("hidden");
58
+ return !!paletteHandle && paletteHandle.isOpen();
57
59
  }
58
60
 
59
61
  export function openCommandPalette() {
60
62
  if (!paletteEl) return;
61
- pushOverlayState();
62
- paletteEl.classList.remove("hidden");
63
+ paletteHandle = showOverlay({ kind: "modal", panel: true, el: paletteEl, closeLabel: "Close search", onRemove: resetPalette });
64
+ // Refused while a dialog is open (overlay-registry.js isPanelBlocked).
65
+ if (!paletteHandle.isOpen()) return;
63
66
  var searchbar = document.getElementById("cmd-palette-btn");
64
67
  if (searchbar) searchbar.style.visibility = "hidden";
65
68
  inputEl.value = "";
@@ -72,10 +75,19 @@ export function openCommandPalette() {
72
75
  fetchHomeData();
73
76
  }
74
77
 
75
- export function closeCommandPalette() {
76
- if (!paletteEl) return;
77
- popOverlayState();
78
- paletteEl.classList.add("hidden");
78
+ // navigates: the page switches project right after, which pushes its own history
79
+ // entry, so the palette's entry is released without a history.back() that would
80
+ // land on the old sentinel after that push.
81
+ export function closeCommandPalette(navigates) {
82
+ if (paletteHandle) paletteHandle.close(navigates ? { keepHistory: true } : undefined);
83
+ }
84
+
85
+ function leavesProject(slug) {
86
+ return !!ctx.currentSlug && ctx.currentSlug() !== slug;
87
+ }
88
+
89
+ // The palette closed, however: its search state goes with it.
90
+ function resetPalette() {
79
91
  var searchbar = document.getElementById("cmd-palette-btn");
80
92
  if (searchbar) searchbar.style.visibility = "";
81
93
  inputEl.value = "";
@@ -112,14 +124,13 @@ export function handlePaletteSessionSwitch() {
112
124
 
113
125
  function buildDOM() {
114
126
  paletteEl = document.createElement("div");
115
- paletteEl.className = "cmd-palette hidden";
127
+ paletteEl.className = "command-palette hidden";
116
128
  paletteEl.innerHTML =
117
- '<div class="cmd-palette-backdrop"></div>' +
118
- '<div class="cmd-palette-dialog">' +
129
+ '<div class="overlay-modal-backdrop"></div>' +
130
+ '<div class="overlay-modal-dialog cmd-palette-dialog">' +
119
131
  '<div class="cmd-palette-input-row">' +
120
132
  '<i data-lucide="search"></i>' +
121
133
  '<input class="cmd-palette-input" type="text" placeholder="Type a command or search..." autocomplete="off" spellcheck="false" />' +
122
- '<span class="cmd-palette-kbd" id="cmd-palette-close"><i data-lucide="x"></i></span>' +
123
134
  '</div>' +
124
135
  '<div class="cmd-palette-results"></div>' +
125
136
  '<div class="cmd-palette-footer"></div>' +
@@ -132,14 +143,6 @@ function buildDOM() {
132
143
  resultsEl = paletteEl.querySelector(".cmd-palette-results");
133
144
  footerEl = paletteEl.querySelector(".cmd-palette-footer");
134
145
 
135
- paletteEl.querySelector(".cmd-palette-backdrop").addEventListener("click", function () {
136
- closeCommandPalette();
137
- });
138
-
139
- paletteEl.querySelector("#cmd-palette-close").addEventListener("click", function () {
140
- closeCommandPalette();
141
- });
142
-
143
146
  inputEl.addEventListener("input", function () {
144
147
  var q = inputEl.value;
145
148
  if (debounceTimer) clearTimeout(debounceTimer);
@@ -152,11 +155,6 @@ function buildDOM() {
152
155
  });
153
156
 
154
157
  inputEl.addEventListener("keydown", function (e) {
155
- if (e.key === "Escape") {
156
- e.preventDefault();
157
- closeCommandPalette();
158
- return;
159
- }
160
158
  if (e.key === "ArrowDown") {
161
159
  e.preventDefault();
162
160
  setActive(activeIndex + 1);
@@ -175,17 +173,13 @@ function buildDOM() {
175
173
  return;
176
174
  }
177
175
  });
178
-
179
- paletteEl.querySelector(".cmd-palette-dialog").addEventListener("click", function (e) {
180
- e.stopPropagation();
181
- });
182
176
  }
183
177
 
184
178
  function updateFooter() {
185
179
  var shortcuts =
186
180
  '<span><kbd>&uarr;</kbd> <kbd>&darr;</kbd> navigate</span>' +
187
181
  '<span><kbd>Enter</kbd> select</span>';
188
- var versionText = cachedVersion ? "v" + cachedVersion : "";
182
+ var versionText = cachedVersion ? escapeHtml("v" + cachedVersion) : "";
189
183
  footerEl.innerHTML =
190
184
  '<a href="https://github.com/clagentic/clagentic-console" target="_blank" rel="noopener" class="cmd-palette-brand"><img src="favicon-banded.png" width="13" height="13" alt="">Clagentic: Console ' + versionText + '</a>' +
191
185
  '<span class="cmd-palette-footer-shortcuts">' + shortcuts + '</span>';
@@ -291,7 +285,7 @@ function renderHome(filter) {
291
285
  var userName = escapeHtml(user.displayName || user.username);
292
286
  var userSub = user.username ? "@" + escapeHtml(user.username) : "";
293
287
  var uAvatarUrl = userAvatarUrl(user, 28);
294
- var uAvatarHtml = '<img src="' + uAvatarUrl + '" width="28" height="28" style="border-radius:50%;" alt="">';
288
+ var uAvatarHtml = '<img src="' + escapeHtml(uAvatarUrl) + '" width="28" height="28" style="border-radius:50%;" alt="">';
295
289
  html += renderItem(flatIndex, uAvatarHtml, userName, userSub, null);
296
290
  flatIndex++;
297
291
  }
@@ -311,7 +305,7 @@ function renderHome(filter) {
311
305
  var proj = filteredProjects[j];
312
306
  items.push({ type: "project", data: proj });
313
307
  var pName = escapeHtml(proj.title || proj.project || proj.slug);
314
- var sessLabel = proj.sessions ? proj.sessions + " sessions" : "";
308
+ var sessLabel = proj.sessions ? escapeHtml(proj.sessions + " sessions") : "";
315
309
  // projectIconHtml() routes custom (:slug:) icons to a safe <img> tag;
316
310
  // the prior raw proj.icon interpolation (via refreshIcons(), which only
317
311
  // converts <i data-lucide> placeholders) showed ':slug:' as literal
@@ -460,7 +454,7 @@ function activateItem(entry) {
460
454
  } else if (entry.type === "session" || entry.type === "search-result") {
461
455
  navigateToSession(entry.data, entry.query || null);
462
456
  } else if (entry.type === "project") {
463
- closeCommandPalette();
457
+ closeCommandPalette(leavesProject(entry.data.slug));
464
458
  ctx.switchProject(entry.data.slug);
465
459
  } else if (entry.type === "user") {
466
460
  closeCommandPalette();
@@ -478,7 +472,7 @@ function executeCommand(cmd) {
478
472
  }
479
473
 
480
474
  function navigateToSession(item, query) {
481
- closeCommandPalette();
475
+ closeCommandPalette(leavesProject(item.projectSlug));
482
476
  var slug = item.projectSlug;
483
477
  var sessionId = item.sessionId;
484
478
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { refreshIcons } from './icons.js';
4
4
  import { escapeHtml } from './utils.js';
5
+ import { isModalOpen, closeModal } from './overlay-registry.js';
5
6
 
6
7
  var ctx = null;
7
8
  var activeSourceIds = new Set();
@@ -42,10 +43,7 @@ function closePicker() {
42
43
  document.removeEventListener("click", closePicker, true);
43
44
  // Also close mobile bottom sheet if open
44
45
  var moreSheet = document.getElementById("input-more-sheet");
45
- if (moreSheet && moreSheet.classList.contains("open")) {
46
- moreSheet.classList.remove("open");
47
- setTimeout(function () { moreSheet.classList.add("hidden"); }, 250);
48
- }
46
+ if (moreSheet && isModalOpen(moreSheet)) closeModal(moreSheet);
49
47
  }
50
48
 
51
49
  // Re-render all open picker surfaces (desktop popover and mobile bottom sheet)
@@ -53,7 +51,7 @@ function renderAllOpen() {
53
51
  var picker = document.getElementById("context-sources-picker");
54
52
  if (picker && !picker.classList.contains("hidden")) renderPicker();
55
53
  var moreSheet = document.getElementById("input-more-sheet");
56
- if (moreSheet && moreSheet.classList.contains("open")) renderPicker("-mobile");
54
+ if (moreSheet && isModalOpen(moreSheet)) renderPicker("-mobile");
57
55
  }
58
56
 
59
57
  // Restore state from server