@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
@@ -0,0 +1,79 @@
1
+ // serialized-save.js - the one way a per-user preference is written to the server.
2
+ //
3
+ // The server keeps the last write it receives, and requests can arrive out of
4
+ // order, so only one save is in flight; a choice made meanwhile replaces the
5
+ // waiting one and is sent when the in-flight save finishes. A save that fails
6
+ // (a network error or a non-OK status) is reported through preference-sync.js,
7
+ // naming the setting, and is not retried: the saver keeps sending later
8
+ // choices, and the next profile load reconciles what the server kept.
9
+ //
10
+ // var save = createSerializedSaver("/api/user/chat-width", "chatWidth");
11
+ // save("wide"); // PUT {"chatWidth":"wide"}
12
+ //
13
+ // A choice that needs more than one request, in order (the theme: a mode, then
14
+ // a custom theme id), goes through createSerializedRequestSaver, which takes the
15
+ // list of requests as the value. The waiting list replaces the older waiting
16
+ // list as a whole, so the server never sees half of one choice and half of
17
+ // another.
18
+ //
19
+ // var save = createSerializedRequestSaver();
20
+ // save([{ url: "/api/user/theme-mode", bodyKey: "themeMode", value: "dark" }]);
21
+
22
+ import { reportPreferenceFailure } from "./preference-sync.js";
23
+
24
+ function sendOne(request) {
25
+ var body = {};
26
+ body[request.bodyKey] = request.value;
27
+ var sent;
28
+ try {
29
+ // Sent now, not on a later tick: an idle saver puts a choice on the wire at once.
30
+ sent = fetch(request.url, {
31
+ method: "PUT",
32
+ headers: { "Content-Type": "application/json" },
33
+ body: JSON.stringify(body),
34
+ });
35
+ } catch (err) {
36
+ sent = Promise.reject(err);
37
+ }
38
+ return sent.then(function (res) {
39
+ if (res && res.ok === false) {
40
+ reportPreferenceFailure("Saving " + request.bodyKey + " failed: HTTP " + res.status);
41
+ }
42
+ }, function (err) {
43
+ reportPreferenceFailure("Saving " + request.bodyKey + " failed:", err);
44
+ });
45
+ }
46
+
47
+ export function createSerializedRequestSaver() {
48
+ var saving = false;
49
+ var waiting = null;
50
+
51
+ function sendWaiting() {
52
+ var requests = waiting;
53
+ waiting = null;
54
+ sendFrom(requests, 0);
55
+ }
56
+
57
+ function sendFrom(requests, at) {
58
+ if (at >= requests.length) {
59
+ if (waiting) sendWaiting();
60
+ else saving = false;
61
+ return;
62
+ }
63
+ sendOne(requests[at]).then(function () { sendFrom(requests, at + 1); });
64
+ }
65
+
66
+ return function save(requests) {
67
+ waiting = requests;
68
+ if (saving) return;
69
+ saving = true;
70
+ sendWaiting();
71
+ };
72
+ }
73
+
74
+ export function createSerializedSaver(url, bodyKey) {
75
+ var saveRequests = createSerializedRequestSaver();
76
+ return function save(value) {
77
+ saveRequests([{ url: url, bodyKey: bodyKey, value: value }]);
78
+ };
79
+ }
@@ -1,7 +1,7 @@
1
1
  // server-settings.js — Full-screen server settings overlay
2
2
  import { refreshIcons } from './icons.js';
3
3
  import { showToast, copyToClipboard, escapeHtml } from './utils.js';
4
- import { pushOverlayState, popOverlayState } from './overlay-history.js';
4
+ import { showOverlay } from './overlay.js';
5
5
  import { parseEnvString, looksLikeEnv } from './project-settings.js';
6
6
  import { checkAdminAccess, loadAdminSection } from './admin.js';
7
7
  import { closeFileViewer } from './filebrowser.js';
@@ -9,21 +9,25 @@ import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar, re
9
9
  import { capabilitiesFor, defaultVendorId } from './vendor-registry.js';
10
10
  import { renderPermissionSettings } from './permission-settings.js';
11
11
  import { renderUserShellSettings } from './shell-settings-controls.js';
12
+ import { renderPromptExpirySettings } from './prompt-expiry-controls.js';
12
13
  import { initCustomIconsSettings, initCustomIconsUpload, loadCustomIcons } from './custom-icons-settings.js';
13
14
  import { formatBytes } from './app-panels.js';
14
15
  import { renderShadowNotice } from './env-shadow-notice.js';
15
16
  import { registerHandlers } from './app-messages.js';
16
17
  import { registerPlace } from './notify-client.js';
18
+ import { mountSettingsBack } from './settings-nav.js';
17
19
 
18
20
  var ctx = null;
19
21
  var settingsEl = null;
20
22
  var settingsBtn = null;
21
- var closeBtn = null;
23
+ // The open panel (overlay.js); null until it is first opened.
24
+ var panelHandle = null;
22
25
  var navItems = null;
23
26
  var sections = null;
24
27
  var statsTimer = null;
25
28
 
26
- // Section data for command palette
29
+ // Section data for the desktop command palette (Cmd+K). Names, groups and
30
+ // order are the section list's in index.html; settings-nav.test.js holds them together.
27
31
  var SETTINGS_SECTIONS = [
28
32
  { section: 'overview', label: 'Status', group: 'General', icon: 'shield', danger: false },
29
33
  { section: 'notifications', label: 'Notifications', group: 'General', icon: 'bell', danger: false },
@@ -33,17 +37,18 @@ var SETTINGS_SECTIONS = [
33
37
  { section: 'environment', label: 'Environment', group: 'Config', icon: 'terminal', danger: false },
34
38
  { section: 'storage', label: 'Storage', group: 'Config', icon: 'database', danger: false },
35
39
  { section: 'custom-icons', label: 'Custom Icons', group: 'Config', icon: 'image', danger: false },
36
- { section: 'lite', label: 'Lite', group: 'Clagentic', icon: 'zap', danger: false },
37
40
  { section: 'admin-users', label: 'Users', group: 'Admin', icon: 'users', danger: false, adminOnly: true },
38
41
  { section: 'admin-invites', label: 'Invites', group: 'Admin', icon: 'mail', danger: false, adminOnly: true },
39
42
  { section: 'admin-projects', label: 'Projects', group: 'Admin', icon: 'folder', danger: false, adminOnly: true },
40
- { section: 'admin-smtp', label: 'Email', group: 'Server', icon: 'send', danger: false, adminOnly: true },
43
+ { section: 'admin-smtp', label: 'Email', group: 'Admin', icon: 'send', danger: false, adminOnly: true },
44
+ { section: 'lite', label: 'Lite', group: 'Clagentic', icon: 'zap', danger: false },
41
45
  { section: 'advanced', label: 'Advanced', group: 'Server', icon: 'settings-2', danger: false },
42
46
  { section: 'restart', label: 'Restart', group: 'Server', icon: 'refresh-cw', danger: false },
43
47
  { section: 'shutdown', label: 'Shutdown', group: 'Server', icon: 'power', danger: true },
44
48
  ];
45
49
 
46
50
  var currentSection = 'overview';
51
+ var backBar = null;
47
52
  var paletteOpen = false;
48
53
  var paletteHighlight = -1;
49
54
  var isAdminUser = false;
@@ -52,7 +57,6 @@ export function initServerSettings(appCtx) {
52
57
  ctx = appCtx;
53
58
  settingsEl = document.getElementById("server-settings");
54
59
  settingsBtn = document.getElementById("server-settings-btn");
55
- closeBtn = document.getElementById("server-settings-close");
56
60
 
57
61
  if (!settingsEl || !settingsBtn) return;
58
62
 
@@ -62,32 +66,24 @@ export function initServerSettings(appCtx) {
62
66
  navItems = settingsEl.querySelectorAll(".settings-nav-item");
63
67
  sections = settingsEl.querySelectorAll(".server-settings-section");
64
68
 
69
+ // Phone: the Back bar stands in for the section list, which the shared
70
+ // Settings list replaces there.
71
+ backBar = mountSettingsBack(settingsEl.querySelector(".server-settings-nav-inner"), {
72
+ label: "Back to Settings",
73
+ onBack: closeSettings,
74
+ });
75
+
65
76
  // Open settings
66
77
  settingsBtn.addEventListener("click", function () {
67
- openSettings();
78
+ openServerSettings();
68
79
  });
69
80
  // The update button lives here: a tap on an update notice opens it.
70
- registerPlace("update_available", openSettings);
71
-
72
- // Close settings
73
- closeBtn.addEventListener("click", function () {
74
- closeSettings();
75
- });
76
-
77
- // ESC to close
78
- document.addEventListener("keydown", function (e) {
79
- if (e.key === "Escape" && !settingsEl.classList.contains("hidden")) {
80
- if (paletteOpen) {
81
- closeSettingsPalette();
82
- } else {
83
- closeSettings();
84
- }
85
- }
86
- });
81
+ registerPlace("update_available", function () { openServerSettings(); });
87
82
 
88
- // Global keyboard: Cmd+K / Ctrl+K inside settings, Esc to close palette
83
+ // Global keyboard: Cmd+K / Ctrl+K inside settings (Esc, in the panel's own
84
+ // onEscape, closes the palette before the panel)
89
85
  document.addEventListener("keydown", function (e) {
90
- if (settingsEl && !settingsEl.classList.contains("hidden")) {
86
+ if (isSettingsOpen()) {
91
87
  if ((e.metaKey || e.ctrlKey) && e.key === "k") {
92
88
  e.preventDefault();
93
89
  if (paletteOpen) {
@@ -107,14 +103,6 @@ export function initServerSettings(appCtx) {
107
103
  });
108
104
  }
109
105
 
110
- // Mobile command palette pill
111
- var navPill = document.getElementById("settings-nav-pill");
112
- if (navPill) {
113
- navPill.addEventListener("click", function () {
114
- openSettingsPalette();
115
- });
116
- }
117
-
118
106
  // Palette backdrop click to close
119
107
  var paletteEl = document.getElementById("settings-palette");
120
108
  if (paletteEl) {
@@ -215,6 +203,9 @@ export function initServerSettings(appCtx) {
215
203
  if (pinSaveBtn) pinSaveBtn.addEventListener("click", function () { submitPin(); });
216
204
  if (pinCancelBtn) pinCancelBtn.addEventListener("click", function () { hidePinForm(); });
217
205
  if (pinInput) pinInput.addEventListener("keydown", function (e) {
206
+ // The panel's Escape handling is the registry's document listener: the key
207
+ // is spent here, so one Escape hides the form and leaves the panel open.
208
+ e.stopPropagation();
218
209
  if (e.key === "Enter") { e.preventDefault(); submitPin(); }
219
210
  if (e.key === "Escape") { e.preventDefault(); hidePinForm(); }
220
211
  });
@@ -364,12 +355,10 @@ export function initServerSettings(appCtx) {
364
355
  function openSettingsPalette() {
365
356
  var paletteEl = document.getElementById("settings-palette");
366
357
  var paletteInput = document.getElementById("settings-palette-input");
367
- var pill = document.getElementById("settings-nav-pill");
368
358
  if (!paletteEl) return;
369
359
  paletteEl.classList.remove("hidden");
370
360
  paletteOpen = true;
371
361
  paletteHighlight = -1;
372
- if (pill) pill.setAttribute("aria-expanded", "true");
373
362
  renderPaletteResults("");
374
363
  if (paletteInput) {
375
364
  paletteInput.value = "";
@@ -386,16 +375,9 @@ function openSettingsPalette() {
386
375
 
387
376
  function closeSettingsPalette() {
388
377
  var paletteEl = document.getElementById("settings-palette");
389
- var pill = document.getElementById("settings-nav-pill");
390
378
  if (!paletteEl) return;
391
379
  paletteEl.classList.add("hidden");
392
380
  paletteOpen = false;
393
- if (pill) {
394
- pill.setAttribute("aria-expanded", "false");
395
- if (window.matchMedia("(pointer: fine)").matches) {
396
- pill.focus();
397
- }
398
- }
399
381
  document.body.style.overflow = "";
400
382
  }
401
383
 
@@ -505,27 +487,21 @@ function updatePaletteHighlight(buttons) {
505
487
  }
506
488
  }
507
489
 
508
- function updateNavPill(sectionName) {
509
- var pill = document.getElementById("settings-nav-pill");
510
- if (!pill) return;
511
- var groupEl = document.getElementById("settings-nav-pill-group");
512
- var labelEl = document.getElementById("settings-nav-pill-label");
513
- for (var i = 0; i < SETTINGS_SECTIONS.length; i++) {
514
- if (SETTINGS_SECTIONS[i].section === sectionName) {
515
- if (groupEl) groupEl.textContent = SETTINGS_SECTIONS[i].group;
516
- if (labelEl) labelEl.textContent = SETTINGS_SECTIONS[i].label;
517
- break;
518
- }
490
+ // The phone Back bar names the open section; desktop does not show it.
491
+ function syncBackTitle() {
492
+ if (!backBar) return;
493
+ for (var i = 0; i < navItems.length; i++) {
494
+ if (navItems[i].dataset.section === currentSection) backBar.setTitle(navItems[i].textContent.trim());
519
495
  }
520
496
  }
521
497
 
522
498
  function switchSection(sectionName) {
523
499
  currentSection = sectionName;
524
- updateNavPill(sectionName);
525
500
  for (var i = 0; i < navItems.length; i++) {
526
501
  var isActive = navItems[i].dataset.section === sectionName;
527
502
  navItems[i].classList.toggle("active", isActive);
528
503
  }
504
+ syncBackTitle();
529
505
  for (var j = 0; j < sections.length; j++) {
530
506
  var isActive2 = sections[j].dataset.section === sectionName;
531
507
  sections[j].classList.toggle("active", isActive2);
@@ -541,11 +517,47 @@ function switchSection(sectionName) {
541
517
  }
542
518
  }
543
519
 
520
+ // The one way into Server Settings. It asks the check that shows the gear
521
+ // button on desktop (administrators), so a route that skips the button, a
522
+ // scripted click or a phone menu, gets the same answer. `section` opens on
523
+ // that section instead of the one shown last. Resolves true when it opened, false
524
+ // when the check said no or a dialog is open (the panel is refused then).
525
+ export function openServerSettings(section) {
526
+ return checkAdminAccess().then(function (isAdmin) {
527
+ if (!isAdmin) return false;
528
+ if (!openSettings()) return false;
529
+ if (section) switchSection(section);
530
+ return true;
531
+ });
532
+ }
533
+
534
+ // Escape closes the Jump to setting palette first, and the panel on the next.
535
+ function onSettingsEscape() {
536
+ if (!paletteOpen) return false;
537
+ closeSettingsPalette();
538
+ return true;
539
+ }
540
+
541
+ function stopStatsTimer() {
542
+ if (statsTimer) {
543
+ clearInterval(statsTimer);
544
+ statsTimer = null;
545
+ }
546
+ }
547
+
548
+ function onSettingsClosed() {
549
+ settingsBtn.classList.remove("active");
550
+ stopStatsTimer();
551
+ }
552
+
553
+ // Resolves false when a dialog is open and the panel was refused (overlay-registry.js
554
+ // isPanelBlocked), true when it is open.
544
555
  function openSettings() {
556
+ panelHandle = showOverlay({ kind: "modal", panel: true, el: settingsEl, onEscape: onSettingsEscape, onRemove: onSettingsClosed });
557
+ if (!panelHandle.isOpen()) return false;
545
558
  closeFileViewer();
546
- pushOverlayState();
547
- settingsEl.classList.remove("hidden");
548
559
  settingsBtn.classList.add("active");
560
+ syncBackTitle();
549
561
  refreshIcons(settingsEl);
550
562
  populateSettings();
551
563
  requestDaemonConfig();
@@ -562,8 +574,11 @@ function openSettings() {
562
574
  });
563
575
 
564
576
  // Start periodic stats refresh
577
+ // A second open while open must not leave the first interval running.
578
+ stopStatsTimer();
565
579
  requestStats();
566
580
  statsTimer = setInterval(requestStats, 5000);
581
+ return true;
567
582
  }
568
583
 
569
584
  function resetRestartButton() {
@@ -583,17 +598,11 @@ function resetShutdownForm() {
583
598
  }
584
599
 
585
600
  export function closeSettings() {
586
- popOverlayState();
587
- settingsEl.classList.add("hidden");
588
- settingsBtn.classList.remove("active");
589
- if (statsTimer) {
590
- clearInterval(statsTimer);
591
- statsTimer = null;
592
- }
601
+ if (panelHandle) panelHandle.close();
593
602
  }
594
603
 
595
604
  export function isSettingsOpen() {
596
- return settingsEl && !settingsEl.classList.contains("hidden");
605
+ return !!panelHandle && panelHandle.isOpen();
597
606
  }
598
607
 
599
608
  function requestStats() {
@@ -629,6 +638,7 @@ function populateSettings() {
629
638
  updateSsBetaCard();
630
639
  renderPermissionSettings(ssSendMsg);
631
640
  renderUserShellSettings(ssSendMsg);
641
+ renderPromptExpirySettings(ssSendMsg);
632
642
  }
633
643
 
634
644
  function syncNotifToggles() {
@@ -4,12 +4,15 @@
4
4
  // draws what it is told and sends a revoke. A revoke takes effect on the
5
5
  // session's next tool call, and the server answers with the list as it now is.
6
6
  //
7
- // Free of the rest of the frontend module graph apart from the connection, so
8
- // a test can drive it with a hand-built DOM.
7
+ // Free of the rest of the frontend module graph apart from the connection and
8
+ // the shared overlay component, so a test can drive it with a hand-built DOM.
9
9
 
10
10
  import { getWs } from './ws-ref.js';
11
+ import { showOverlay } from './overlay.js';
11
12
 
12
13
  var MODAL_ID = "session-grants-modal";
14
+ // The open list, so a second request replaces it.
15
+ var openHandle = null;
13
16
 
14
17
  function send(msg) {
15
18
  var ws = getWs();
@@ -23,8 +26,7 @@ function modal() {
23
26
  }
24
27
 
25
28
  function close() {
26
- var m = modal();
27
- if (m && m.parentNode) m.parentNode.removeChild(m);
29
+ if (openHandle) openHandle.close();
28
30
  }
29
31
 
30
32
  /**
@@ -77,14 +79,6 @@ export function renderGrantList(list, grants, sessionId, sendMsg) {
77
79
  /** Open the grants list for a session. */
78
80
  export function openSessionGrants(sessionId) {
79
81
  close();
80
- var m = document.createElement("div");
81
- m.id = MODAL_ID;
82
- m.dataset.sessionId = String(sessionId);
83
- var backdrop = document.createElement("div");
84
- backdrop.className = "confirm-backdrop";
85
- backdrop.addEventListener("click", close);
86
- var dialog = document.createElement("div");
87
- dialog.className = "confirm-dialog session-grants-dialog";
88
82
  var title = document.createElement("div");
89
83
  title.className = "session-grants-title";
90
84
  title.textContent = "Allow for session grants";
@@ -95,12 +89,15 @@ export function openSessionGrants(sessionId) {
95
89
  done.className = "confirm-btn confirm-cancel";
96
90
  done.textContent = "Close";
97
91
  done.addEventListener("click", close);
98
- dialog.appendChild(title);
99
- dialog.appendChild(list);
100
- dialog.appendChild(done);
101
- m.appendChild(backdrop);
102
- m.appendChild(dialog);
103
- document.body.appendChild(m);
92
+ var handle = showOverlay({
93
+ kind: "modal",
94
+ id: MODAL_ID,
95
+ dialogClass: "session-grants-dialog",
96
+ attrs: { "data-session-id": String(sessionId) },
97
+ content: [title, list, done],
98
+ onRemove: function () { if (openHandle === handle) openHandle = null; },
99
+ });
100
+ openHandle = handle;
104
101
  send({ type: "list_session_grants", sessionId: sessionId });
105
102
  }
106
103
 
@@ -120,7 +117,7 @@ export function showGrantError(list, message) {
120
117
  /** The server's session_grants message: redraw the list if it is the one open. */
121
118
  export function handleSessionGrants(msg) {
122
119
  var m = modal();
123
- if (!m || m.dataset.sessionId !== String(msg.sessionId)) return;
120
+ if (!m || m.getAttribute("data-session-id") !== String(msg.sessionId)) return;
124
121
  var list = m.querySelector(".session-grants-list");
125
122
  if (!list) return;
126
123
  if (typeof msg.error === "string" && msg.error) {
@@ -0,0 +1,98 @@
1
+ // session-list-avatars.js - the "Avatars in session list" preference, and the one
2
+ // element every session list draws for it.
3
+ //
4
+ // Stored and applied the way the chat width is: cached in localStorage for first
5
+ // paint, saved on the server so it follows the person to another device, applied
6
+ // without a reload. On (the default) a session run by a named agent leads its row
7
+ // with that agent's avatar; off keeps the generic agent badge.
8
+ //
9
+ // The avatar itself is the shared agent avatar (agent-avatar.js), so a change in
10
+ // the Team view repaints these rows with every other agent avatar on the page.
11
+
12
+ import { createAgentAvatar } from "./agent-avatar.js";
13
+ import { createSerializedSaver } from "./serialized-save.js";
14
+ import { loadProfilePreference } from "./preference-sync.js";
15
+
16
+ var STORAGE_KEY = "clagentic-session-list-avatars";
17
+ // The size the design gives a session-list avatar, in CSS pixels.
18
+ export var SESSION_AVATAR_SIZE = 20;
19
+
20
+ var enabled = true;
21
+ var changeCallbacks = [];
22
+ // A choice made on this page outranks a profile reply that was already in flight.
23
+ var chosenThisPage = false;
24
+ var saveEnabled = createSerializedSaver("/api/user/session-list-avatars", "sessionListAvatars");
25
+
26
+ function lsGet() {
27
+ try { return localStorage.getItem(STORAGE_KEY); } catch (e) { return null; }
28
+ }
29
+
30
+ function lsSet(value) {
31
+ try { localStorage.setItem(STORAGE_KEY, value ? "1" : "0"); } catch (e) {}
32
+ }
33
+
34
+ export function sessionListAvatarsEnabled() {
35
+ return enabled;
36
+ }
37
+
38
+ // Returns a function that removes the listener again.
39
+ export function onSessionListAvatarsChange(fn) {
40
+ changeCallbacks.push(fn);
41
+ return function () {
42
+ var at = changeCallbacks.indexOf(fn);
43
+ if (at !== -1) changeCallbacks.splice(at, 1);
44
+ };
45
+ }
46
+
47
+ // Applies the setting to the page and tells the listeners. Nothing is stored or sent.
48
+ export function applySessionListAvatars(value) {
49
+ enabled = value !== false;
50
+ var listeners = changeCallbacks.slice();
51
+ for (var i = 0; i < listeners.length; i++) {
52
+ try { listeners[i](enabled); } catch (e) {
53
+ console.error("session list avatars listener failed:", e);
54
+ }
55
+ }
56
+ }
57
+
58
+ // Choose on or off: applied at once, cached, and saved on the server.
59
+ export function setSessionListAvatars(value) {
60
+ if (typeof value !== "boolean") return false;
61
+ chosenThisPage = true;
62
+ lsSet(value);
63
+ applySessionListAvatars(value);
64
+ saveEnabled(value);
65
+ return true;
66
+ }
67
+
68
+ // The server is authoritative once the profile loads, so a choice made on
69
+ // another device wins. `server` is { sessionListAvatars } from /api/profile.
70
+ export function applyServerSessionListAvatars(server) {
71
+ var value = server && server.sessionListAvatars;
72
+ if (typeof value !== "boolean" || chosenThisPage) return;
73
+ lsSet(value);
74
+ if (value !== enabled) applySessionListAvatars(value);
75
+ }
76
+
77
+ // Applies this browser's cached choice, then asks the server for the person's
78
+ // own so another device's setting applies at load without opening Settings.
79
+ export function initSessionListAvatars() {
80
+ var cached = lsGet();
81
+ if (cached === "0" || cached === "1") enabled = cached === "1";
82
+
83
+ return loadProfilePreference("session list avatars", applyServerSessionListAvatars);
84
+ }
85
+
86
+ /**
87
+ * The avatar a session row shows for a named agent: the shared agent avatar at
88
+ * the list size, round (css), named by the agent for assistive tech and on hover.
89
+ * With no picked image, or an agent outside the caller's roster, it shows the
90
+ * agent's initial on one of four tints (the "initial" option of the shared
91
+ * avatar), so it reveals nothing beyond the name.
92
+ */
93
+ export function createSessionAgentAvatar(agentName) {
94
+ var el = createAgentAvatar(agentName, SESSION_AVATAR_SIZE, "session-list-avatar", null, { initial: true });
95
+ el.setAttribute("aria-label", agentName);
96
+ el.title = agentName;
97
+ return el;
98
+ }
@@ -0,0 +1,86 @@
1
+ // session-vendor-state.js - which vendor a session belongs to, decided from the
2
+ // messages the server sends, as pure functions so the rules can be tested
3
+ // without a page. The store is read and written by the callers.
4
+
5
+ /**
6
+ * The vendor state a session_switched settles on, or null when the session has
7
+ * neither a recorded vendor nor history (a new session keeps the visitor's own
8
+ * choice, so nothing is imposed).
9
+ * current { currentVendor, vendorSelectionLocked } as the store holds them
10
+ * before the switch
11
+ * defaultId the registry's preferred vendor, for a session with history and
12
+ * no recorded vendor
13
+ * A session with history has its vendor structurally bound: it is locked so a
14
+ * late model_info from the default adapter cannot flip the page back.
15
+ * msg.vendorSource says how the server resolved the vendor; only an absent one
16
+ * (or a message from a path that sends none) takes the default. "error" means
17
+ * the session's recorded vendor could not be read: whether or not it has
18
+ * history, no vendor is shown and the page is locked so a model_info cannot
19
+ * name one.
20
+ * current.sameSession is false when the switch is to another session than the
21
+ * one the page was on, so a pick made on that one is not carried over.
22
+ * @returns {{currentVendor: string|null, vendorSelectionLocked: boolean}|null}
23
+ */
24
+ export function vendorStateForSwitch(msg, current, defaultId) {
25
+ var locked = !!(current && current.vendorSelectionLocked);
26
+ if (!msg.vendor && msg.vendorSource === "error") {
27
+ return { currentVendor: null, vendorSelectionLocked: true };
28
+ }
29
+ if (msg.vendor) {
30
+ // A locked page without history keeps the vendor it holds, but only on the
31
+ // same session: another session takes the vendor the server resolved for it.
32
+ var keepHeld = locked && !msg.hasHistory && current.sameSession !== false;
33
+ return {
34
+ currentVendor: keepHeld ? (current.currentVendor || null) : msg.vendor,
35
+ vendorSelectionLocked: locked || !!msg.hasHistory,
36
+ };
37
+ }
38
+ if (msg.hasHistory) return { currentVendor: defaultId, vendorSelectionLocked: false };
39
+ // A brand-new session keeps the vendor picked before its first message; the
40
+ // caller re-applies this after the reset that clears the page's vendor.
41
+ if (locked && current.currentVendor && current.sameSession !== false) {
42
+ return { currentVendor: current.currentVendor, vendorSelectionLocked: true };
43
+ }
44
+ return null;
45
+ }
46
+
47
+ /** The vendor each session of a session list records, by session id. */
48
+ export function sessionVendorMap(sessions) {
49
+ var map = {};
50
+ if (!Array.isArray(sessions)) return map;
51
+ for (var i = 0; i < sessions.length; i++) {
52
+ if (sessions[i] && sessions[i].vendor) map[sessions[i].id] = sessions[i].vendor;
53
+ }
54
+ return map;
55
+ }
56
+
57
+ /** The vendor the session list recorded for a session id, or null. */
58
+ export function listedVendor(map, sessionId) {
59
+ if (sessionId == null || !map) return null;
60
+ return Object.prototype.hasOwnProperty.call(map, sessionId) ? map[sessionId] : null;
61
+ }
62
+
63
+ /**
64
+ * Whether the composer placeholder must be recomputed after a store change:
65
+ * only when the vendor the active session shows changed, never for a new
66
+ * session_list map that leaves it as it was, and never while loop-queue mode
67
+ * holds the queue wording.
68
+ * state, prev { currentVendor, activeSessionId, sessionVendors, loopQueueMode }
69
+ */
70
+ export function placeholderNeedsRecompute(state, prev) {
71
+ if (state.loopQueueMode) return false;
72
+ var shown = function (s) {
73
+ return s.currentVendor || listedVendor(s.sessionVendors, s.activeSessionId);
74
+ };
75
+ return shown(state) !== shown(prev);
76
+ }
77
+
78
+ /**
79
+ * Whether a model_info belongs to something other than what the page is on, and
80
+ * so must change nothing: a vendor other than the bound one, or another session's.
81
+ * state { currentVendor, activeSessionId }
82
+ */
83
+ export function isForeignModelInfo(msg, state) {
84
+ if (msg.vendor && state.currentVendor && msg.vendor !== state.currentVendor) return true;
85
+ return msg.sessionId != null && state.activeSessionId != null && msg.sessionId !== state.activeSessionId;
86
+ }
@@ -0,0 +1,35 @@
1
+ // settings-access.js — who may open which settings area, in one place.
2
+ //
3
+ // Desktop and phone answer these questions the same way. Nothing here touches
4
+ // the DOM at import time, so the rules run under plain Node.
5
+
6
+ // Project Settings is open to everyone except a user whose permissions turn it
7
+ // off. No permissions object (single-user mode, not yet loaded) means open.
8
+ export function canOpenProjectSettings(permissions) {
9
+ return !permissions || permissions.projectSettings !== false;
10
+ }
11
+
12
+ /**
13
+ * The settings areas a user is offered, in display order.
14
+ *
15
+ * permissions the user's permission object (or null)
16
+ * isAdmin true when the Server Settings gear is shown to this user
17
+ * currentSlug the open project's slug, or null when no project is open
18
+ *
19
+ * Every user has their own settings. Project Settings needs an open project
20
+ * and the project-settings permission; Server Settings needs the same
21
+ * administrator check that shows the gear button on desktop.
22
+ */
23
+ export function settingsAreaIds(state) {
24
+ var ids = ["user"];
25
+ if (state.currentSlug && canOpenProjectSettings(state.permissions)) ids.push("project");
26
+ if (state.isAdmin) ids.push("server");
27
+ return ids;
28
+ }
29
+
30
+ // The phone layout: the breakpoint at which the tab bar replaces the sidebar
31
+ // and the settings panels fill the screen.
32
+ export function isPhoneSettingsLayout() {
33
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" &&
34
+ window.matchMedia("(max-width: 768px)").matches;
35
+ }