@clagentic/console 1.5.0-beta.2 → 1.5.0-beta.4

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 (54) hide show
  1. package/README.md +18 -14
  2. package/bin/cli.js +1 -0
  3. package/lib/cli-sessions.js +71 -18
  4. package/lib/config.js +80 -6
  5. package/lib/daemon-projects.js +1 -1
  6. package/lib/daemon.js +142 -26
  7. package/lib/pages.js +1 -42
  8. package/lib/project-connection.js +4 -8
  9. package/lib/project-external-trigger.js +62 -7
  10. package/lib/project-http.js +17 -1
  11. package/lib/project-loop.js +3 -2
  12. package/lib/project-notifications.js +3 -18
  13. package/lib/project-sessions.js +68 -27
  14. package/lib/project-team.js +417 -0
  15. package/lib/project-user-message.js +5 -10
  16. package/lib/project.js +53 -53
  17. package/lib/public/app.js +7 -15
  18. package/lib/public/css/home-hub.css +36 -0
  19. package/lib/public/css/icon-strip.css +28 -126
  20. package/lib/public/css/menus.css +2 -2
  21. package/lib/public/css/team-panel.css +149 -0
  22. package/lib/public/index.html +72 -15
  23. package/lib/public/modules/admin.js +1 -52
  24. package/lib/public/modules/agent-picker.js +11 -3
  25. package/lib/public/modules/app-cursors.js +43 -47
  26. package/lib/public/modules/app-home-hub.js +12 -0
  27. package/lib/public/modules/app-messages.js +18 -12
  28. package/lib/public/modules/app-rendering.js +1 -2
  29. package/lib/public/modules/server-settings.js +74 -5
  30. package/lib/public/modules/sidebar-mobile.js +9 -88
  31. package/lib/public/modules/sidebar-projects.js +1 -1
  32. package/lib/public/modules/sidebar-sessions.js +6 -2
  33. package/lib/public/modules/sidebar-users.js +37 -307
  34. package/lib/public/modules/team-panel.js +331 -0
  35. package/lib/public/modules/tools.js +3 -0
  36. package/lib/public/modules/user-settings.js +0 -3
  37. package/lib/public/style.css +1 -0
  38. package/lib/sdk-bridge.js +121 -8
  39. package/lib/sdk-message-processor.js +39 -4
  40. package/lib/sdk-worker.js +2 -2
  41. package/lib/server-admin.js +1 -86
  42. package/lib/server-auth.js +13 -124
  43. package/lib/server-dm.js +2 -7
  44. package/lib/server-palette.js +9 -20
  45. package/lib/server-settings.js +41 -243
  46. package/lib/server-skills.js +11 -13
  47. package/lib/server.js +37 -60
  48. package/lib/sessions.js +16 -50
  49. package/lib/terminal-manager.js +13 -15
  50. package/lib/users-auth.js +0 -38
  51. package/lib/users.js +14 -11
  52. package/lib/ws-schema.js +12 -0
  53. package/lib/yoke/adapters/claude.js +5 -0
  54. package/package.json +1 -1
@@ -85,7 +85,7 @@ export function initAdmin(appCtx) {
85
85
  export function checkAdminAccess() {
86
86
  return apiGet("/api/me").then(function (data) {
87
87
  meInfo = data;
88
- return data.multiUser && data.user && data.user.role === "admin";
88
+ return data.user && data.user.role === "admin";
89
89
  }).catch(function () { return false; });
90
90
  }
91
91
 
@@ -103,39 +103,6 @@ export function loadAdminSection(section, body) {
103
103
  }
104
104
 
105
105
  }
106
- // --- Migration from single-user to multi-user ---
107
- function enableMultiUserMode() {
108
- var modal = document.createElement("div");
109
- modal.className = "admin-modal-overlay";
110
- modal.innerHTML = '<div class="admin-modal">' +
111
- '<div class="admin-modal-body" style="padding:20px 16px 16px">' +
112
- '<p class="admin-modal-desc" style="margin:0;font-size:14px;color:var(--text)">Enable multi-user mode? You will be directed to set up the admin account. Your current PIN will become the admin PIN.</p>' +
113
- '</div>' +
114
- '<div class="admin-modal-footer">' +
115
- '<button class="admin-modal-save" id="confirm-enable-multiuser">Enable</button>' +
116
- '<button class="admin-modal-cancel">Cancel</button>' +
117
- '</div></div>';
118
- document.body.appendChild(modal);
119
- refreshIcons(modal);
120
- modal.querySelector(".admin-modal-cancel").addEventListener("click", function () { modal.remove(); });
121
- modal.addEventListener("click", function (e) { if (e.target === modal) modal.remove(); });
122
- modal.querySelector("#confirm-enable-multiuser").addEventListener("click", function () {
123
- modal.remove();
124
- apiPost("/api/settings/enable-multiuser").then(function (data) {
125
- if (data.ok && data.setupCode) {
126
- showToast("Multi-user mode enabled. Redirecting to setup...");
127
- setTimeout(function () {
128
- window.location.href = "/auth?setupCode=" + encodeURIComponent(data.setupCode);
129
- }, 500);
130
- } else {
131
- showToast(data.error || "Failed to enable multi-user mode");
132
- }
133
- }).catch(function () {
134
- showToast("Failed to enable multi-user mode");
135
- });
136
- });
137
- }
138
-
139
106
  // --- Users ---
140
107
  function loadUsersTab(body) {
141
108
  apiGet("/api/admin/users").then(function (data) {
@@ -148,16 +115,6 @@ function loadUsersTab(body) {
148
115
 
149
116
  function renderUsersTab(body) {
150
117
  var html = '';
151
-
152
- // Show migration callout if single-user mode with PIN is active
153
- if (meInfo && meInfo.singleUserMigrationAvailable && !meInfo.multiUser) {
154
- html += '<div class="migration-callout">' +
155
- '<strong>Migrate to multi-user mode</strong>' +
156
- '<p>You\'re currently using single-user PIN mode. Multi-user mode lets you create named accounts with better security. Your existing PIN will continue to work during transition.</p>' +
157
- '<button id="migrate-to-multiuser-btn" class="admin-action-btn">Set up multi-user mode</button>' +
158
- '</div>';
159
- }
160
-
161
118
  html += '<div class="admin-section-header">' +
162
119
  '<div class="admin-header-btns">' +
163
120
  '<button class="admin-action-btn" id="admin-add-user">' + iconHtml("user-plus") + ' Add User</button>' +
@@ -194,14 +151,6 @@ function renderUsersTab(body) {
194
151
  body.innerHTML = html;
195
152
  refreshIcons(body);
196
153
 
197
- // Bind migration button
198
- var migrateBtn = body.querySelector("#migrate-to-multiuser-btn");
199
- if (migrateBtn) {
200
- migrateBtn.addEventListener("click", function () {
201
- enableMultiUserMode();
202
- });
203
- }
204
-
205
154
  // Bind add user button
206
155
  var addUserBtn = body.querySelector("#admin-add-user");
207
156
  if (addUserBtn) {
@@ -30,6 +30,7 @@ var allAgents = [];
30
30
  var favorites = [];
31
31
  var recents = [];
32
32
  var activeTab = "favorites"; // "favorites" | "all"
33
+ var _catalogReceived = false; // true once at least one agents_list response has arrived
33
34
 
34
35
  // Identity match: name is the sole key (lr-8e39, flat SDK catalog).
35
36
  function sameAgent(a, b) {
@@ -58,6 +59,7 @@ export function openAgentPicker() {
58
59
  // the surface from flickering open).
59
60
  if (store.get('dmMode')) return;
60
61
  _preferredTargetSlug = null;
62
+ _catalogReceived = false;
61
63
  paletteEl.classList.remove("hidden");
62
64
  inputEl.value = "";
63
65
  activeIndex = -1;
@@ -79,6 +81,7 @@ export function openAgentPicker() {
79
81
  export function openAgentPickerForPreferred(slug) {
80
82
  if (!paletteEl || !slug) return;
81
83
  _preferredTargetSlug = slug;
84
+ _catalogReceived = false;
82
85
  paletteEl.classList.remove("hidden");
83
86
  inputEl.value = "";
84
87
  activeIndex = -1;
@@ -124,6 +127,7 @@ export function handleAgentsList(msg) {
124
127
  allAgents = Array.isArray(msg.agents) ? msg.agents : [];
125
128
  favorites = Array.isArray(msg.favorites) ? msg.favorites : [];
126
129
  recents = Array.isArray(msg.recents) ? msg.recents : [];
130
+ _catalogReceived = true;
127
131
  if (isAgentPickerOpen()) {
128
132
  render();
129
133
  }
@@ -295,9 +299,13 @@ function render() {
295
299
  }
296
300
 
297
301
  if (items.length === 0 && !html) {
298
- html = '<div class="agent-picker-empty">' +
299
- (f ? 'No agents match "' + escapeHtml(f) + '".' : 'No agents discovered.') +
300
- '</div>';
302
+ if (!_catalogReceived) {
303
+ html = '<div class="cmd-palette-loading">Loading agents…</div>';
304
+ } else {
305
+ html = '<div class="agent-picker-empty">' +
306
+ (f ? 'No agents match "' + escapeHtml(f) + '".' : 'No agents discovered.') +
307
+ '</div>';
308
+ }
301
309
  }
302
310
 
303
311
  resultsEl.innerHTML = html;
@@ -200,7 +200,6 @@ function findClosestTurn(clientY) {
200
200
  }
201
201
 
202
202
  function hasOtherSessionViewers() {
203
- if (!store.get('isMultiUserMode')) return false;
204
203
  var sessionId = store.get('activeSessionId');
205
204
  if (!sessionId) return false;
206
205
  var viewers = getSessionPresenceUsers(sessionId);
@@ -216,9 +215,8 @@ function shouldBroadcastCollab() {
216
215
  return cursorSharingEnabled && hasOtherSessionViewers();
217
216
  }
218
217
 
219
- // Cursor sharing toggle button in user island (multi-user only)
218
+ // Cursor sharing toggle button in user island
220
219
  export function initCursorToggle() {
221
- if (!store.get('isMultiUserMode')) return;
222
220
  var actionsEl = document.querySelector(".user-island-actions");
223
221
  if (!actionsEl) return;
224
222
  if (document.getElementById("cursor-share-toggle")) return;
@@ -443,52 +441,50 @@ export function initCursors() {
443
441
  });
444
442
 
445
443
  // Track local text selection and send to server
446
- if (store.get('isMultiUserMode')) {
447
- document.addEventListener("selectionchange", function () {
448
- if (!shouldBroadcastCollab()) return;
449
- var ws = getWs();
450
- if (!ws || ws.readyState !== 1) return;
451
- if (selectionThrottleTimer) return;
452
- selectionThrottleTimer = setTimeout(function () { selectionThrottleTimer = null; }, 100);
453
-
454
- var activeEl = document.activeElement;
455
- if (activeEl && activeEl.id === "input" && lastSelectionKey === "") return;
456
-
457
- var sel = window.getSelection();
458
- if (!sel || sel.rangeCount === 0 || sel.isCollapsed) {
459
- // Selection cleared
460
- if (lastSelectionKey !== "") {
461
- lastSelectionKey = "";
462
- sendWsQuiet({ type: "text_select", ranges: [] });
463
- }
464
- return;
444
+ document.addEventListener("selectionchange", function () {
445
+ if (!shouldBroadcastCollab()) return;
446
+ var ws = getWs();
447
+ if (!ws || ws.readyState !== 1) return;
448
+ if (selectionThrottleTimer) return;
449
+ selectionThrottleTimer = setTimeout(function () { selectionThrottleTimer = null; }, 100);
450
+
451
+ var activeEl = document.activeElement;
452
+ if (activeEl && activeEl.id === "input" && lastSelectionKey === "") return;
453
+
454
+ var sel = window.getSelection();
455
+ if (!sel || sel.rangeCount === 0 || sel.isCollapsed) {
456
+ // Selection cleared
457
+ if (lastSelectionKey !== "") {
458
+ lastSelectionKey = "";
459
+ sendWsQuiet({ type: "text_select", ranges: [] });
465
460
  }
461
+ return;
462
+ }
466
463
 
467
- var ranges = [];
468
- for (var i = 0; i < sel.rangeCount; i++) {
469
- var range = sel.getRangeAt(i);
470
- var startTurn = findParentTurn(range.startContainer);
471
- var endTurn = findParentTurn(range.endContainer);
472
- if (!startTurn || !endTurn) continue;
473
- // Both must be inside messagesEl
474
- if (!messagesEl.contains(startTurn)) continue;
475
-
476
- var startCh = getCharOffset(startTurn, range.startContainer, range.startOffset);
477
- var endCh = getCharOffset(endTurn, range.endContainer, range.endOffset);
478
-
479
- ranges.push({
480
- startTurn: parseInt(startTurn.dataset.turn, 10),
481
- startCh: startCh,
482
- endTurn: parseInt(endTurn.dataset.turn, 10),
483
- endCh: endCh
484
- });
485
- }
464
+ var ranges = [];
465
+ for (var i = 0; i < sel.rangeCount; i++) {
466
+ var range = sel.getRangeAt(i);
467
+ var startTurn = findParentTurn(range.startContainer);
468
+ var endTurn = findParentTurn(range.endContainer);
469
+ if (!startTurn || !endTurn) continue;
470
+ // Both must be inside messagesEl
471
+ if (!messagesEl.contains(startTurn)) continue;
472
+
473
+ var startCh = getCharOffset(startTurn, range.startContainer, range.startOffset);
474
+ var endCh = getCharOffset(endTurn, range.endContainer, range.endOffset);
475
+
476
+ ranges.push({
477
+ startTurn: parseInt(startTurn.dataset.turn, 10),
478
+ startCh: startCh,
479
+ endTurn: parseInt(endTurn.dataset.turn, 10),
480
+ endCh: endCh
481
+ });
482
+ }
486
483
 
487
- var key = JSON.stringify(ranges);
488
- if (key === lastSelectionKey) return;
489
- lastSelectionKey = key;
484
+ var key = JSON.stringify(ranges);
485
+ if (key === lastSelectionKey) return;
486
+ lastSelectionKey = key;
490
487
 
491
- sendWsQuiet({ type: "text_select", ranges: ranges });
492
- });
493
- }
488
+ sendWsQuiet({ type: "text_select", ranges: ranges });
489
+ });
494
490
  }
@@ -8,6 +8,7 @@ import { switchProject, getCachedProjects, renderProjectList } from './app-proje
8
8
  import { openSchedulerToTab } from './scheduler.js';
9
9
  // playbook imports removed (Quick Start section removed from hub)
10
10
  import { exitDmMode } from './app-dm.js';
11
+ import { openCommandPalette } from './command-palette.js';
11
12
 
12
13
  function $hub(id) { return document.getElementById(id); }
13
14
 
@@ -50,6 +51,17 @@ export function initHomeHub() {
50
51
  homeHub = document.getElementById("home-hub");
51
52
  hubCloseBtn = document.getElementById("home-hub-close");
52
53
 
54
+ // Hub search bar: focus or keydown delegates immediately to the command palette.
55
+ var hubSearchInput = document.getElementById("hub-search-input");
56
+ if (hubSearchInput) {
57
+ function delegateToPalette() {
58
+ hubSearchInput.blur();
59
+ openCommandPalette();
60
+ }
61
+ hubSearchInput.addEventListener("focus", delegateToPalette);
62
+ hubSearchInput.addEventListener("keydown", delegateToPalette);
63
+ }
64
+
53
65
  if (hubCloseBtn) {
54
66
  hubCloseBtn.addEventListener("click", function () {
55
67
  hideHomeHub();
@@ -11,7 +11,7 @@ import { refreshIcons, iconHtml } from './icons.js';
11
11
  import { renderMarkdown, highlightCodeBlocks, highlightCodeBlocksBatched, renderMermaidBlocks } from './markdown.js';
12
12
  import { updatePageTitle } from './sidebar.js';
13
13
  import { renderSessionList, updateSessionPresence, populateCliSessionList, handleSearchResults, updateSessionBadge } from './sidebar-sessions.js';
14
- import { updateDmBadge, renderSidebarPresence, setMentionActive, renderUserStrip } from './sidebar-users.js';
14
+ import { updateDmBadge, renderSidebarPresence, setMentionActive } from './sidebar-users.js';
15
15
  import { refreshMobileChatSheet } from './sidebar-mobile.js';
16
16
  import { handlePaletteSessionSwitch, setPaletteVersion } from './command-palette.js';
17
17
  import { handleAgentsList, handleAgentFavoriteToggled } from './agent-picker.js';
@@ -23,7 +23,7 @@ import { showDoneNotification, playDoneSound, isNotifAlertEnabled, isNotifSoundE
23
23
  import { handleFsList, handleFsRead, handleFileChanged, handleDirChanged, handleFileHistory, handleGitDiff, handleFileAt, refreshIfOpen, handleFsSearch } from './filebrowser.js';
24
24
  import { getPendingNavigate, peekPendingNavigate } from './pending-navigate.js';
25
25
  import { isProjectSettingsOpen, refreshProjectSettingsModels, handleInstructionsRead, handleInstructionsWrite, handleProjectEnv, handleProjectEnvSaved, handleProjectSharedEnv, handleProjectSharedEnvSaved, handleProjectOwnerChanged, updateLiteVisibility, handleLiteProjectStatus, handleLiteEnrollResult, handleLiteUnenrollResult } from './project-settings.js';
26
- import { updateSettingsModels, updateSettingsStats, updateDaemonConfig, handleSetPinResult, handleKeepAwakeChanged, handleAutoContinueChanged, handleRestartResult, handleShutdownResult, handleSharedEnv, handleSharedEnvSaved, handleGlobalClaudeMdRead, handleGlobalClaudeMdWrite, updateSsLiteVisibility } from './server-settings.js';
26
+ import { updateSettingsModels, updateSettingsStats, updateDaemonConfig, handleSetPinResult, handleKeepAwakeChanged, handleAutoContinueChanged, handleRefreshAgentsResult, handleRestartResult, handleShutdownResult, handleSharedEnv, handleSharedEnvSaved, handleGlobalClaudeMdRead, handleGlobalClaudeMdWrite, updateSsLiteVisibility } from './server-settings.js';
27
27
  import { handleTermList, handleTermCreated, sendTerminalCommand, handleTermOutput, handleTermResized, handleTermExited, handleTermClosed } from './terminal.js';
28
28
  import { updateTerminalList, handleContextSourcesState } from './context-sources.js';
29
29
  import { handleNotesList, handleNoteCreated, handleNoteUpdated, handleNoteDeleted } from './sticky-notes.js';
@@ -49,6 +49,7 @@ import { showLoopBanner, updateLoopBanner, updateLoopInputVisibility, showRalphA
49
49
  import { handleSkillInstallWs } from './app-skills-install.js';
50
50
  import { handleNotificationsState, handleNotificationCreated, handleNotificationDismissed, handleNotificationDismissedAll, showUpdateBanner } from './app-notifications.js';
51
51
  import { handleMentionStart, handleMentionActivity, handleMentionStream, handleMentionDone, handleMentionError, renderMentionUser, renderMentionResponse, renderUserMention } from './mention.js';
52
+ import { handleTeamState, handleTeamMemberUpdate, handleTeamTaskUpdate, handleTeamMessage as handleTeamMsg, handleTeamGone } from './team-panel.js';
52
53
 
53
54
  // --- DOM refs (cached once, stable for page lifetime) ---
54
55
  var messagesEl = document.getElementById("messages");
@@ -226,7 +227,7 @@ export function processMessage(msg) {
226
227
  // The server config has dangerouslySkipPermissions=true but it is disabled
227
228
  // because multi-user mode is active. Warn admins so they know the config
228
229
  // flag has no effect and remove it to avoid confusion.
229
- if (store.get('isMultiUserMode') && store.get('permissions') && store.get('permissions').projectSettings !== false) {
230
+ if (store.get('permissions') && store.get('permissions').projectSettings !== false) {
230
231
  showToast("dangerouslySkipPermissions is set in config but is disabled in multi-user mode. All users have normal tool-approval rules.", "warn");
231
232
  }
232
233
  }
@@ -239,16 +240,11 @@ export function processMessage(msg) {
239
240
 
240
241
  case "update_available":
241
242
  // In multi-user mode, only show update UI to admins
242
- if (store.get('isMultiUserMode')) {
243
- checkAdminAccess().then(function (isAdmin) {
244
- if (!isAdmin) return;
245
- showUpdateAvailable(msg);
246
- showUpdateBanner(msg);
247
- });
248
- } else {
243
+ checkAdminAccess().then(function (isAdmin) {
244
+ if (!isAdmin) return;
249
245
  showUpdateAvailable(msg);
250
246
  showUpdateBanner(msg);
251
- }
247
+ });
252
248
  break;
253
249
 
254
250
  case "up_to_date":
@@ -1220,7 +1216,6 @@ export function processMessage(msg) {
1220
1216
 
1221
1217
  case "projects_updated":
1222
1218
  updateProjectList(msg);
1223
- renderUserStrip();
1224
1219
  break;
1225
1220
 
1226
1221
  case "project_owner_changed":
@@ -1326,6 +1321,13 @@ export function processMessage(msg) {
1326
1321
  if (msg.error) showToast("@Mention: " + msg.error, "error");
1327
1322
  break;
1328
1323
 
1324
+ // --- Team activity ---
1325
+ case "team_state": handleTeamState(msg); break;
1326
+ case "team_member_update": handleTeamMemberUpdate(msg); break;
1327
+ case "team_task_update": handleTeamTaskUpdate(msg); break;
1328
+ case "team_message": handleTeamMsg(msg); break;
1329
+ case "team_gone": handleTeamGone(msg); break;
1330
+
1329
1331
  case "daemon_config":
1330
1332
  if (msg.config && msg.config.headless) store.set({ isHeadlessMode: true });
1331
1333
  updateDaemonConfig(msg.config);
@@ -1348,6 +1350,10 @@ export function processMessage(msg) {
1348
1350
  handleAutoContinueChanged(msg);
1349
1351
  break;
1350
1352
 
1353
+ case "refresh_agents_result":
1354
+ handleRefreshAgentsResult(msg);
1355
+ break;
1356
+
1351
1357
  case "restart_server_result":
1352
1358
  handleRestartResult(msg);
1353
1359
  break;
@@ -484,8 +484,7 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
484
484
  // already known AND the message is from a different user. If myUserId is
485
485
  // null (init race — /api/me hasn't returned yet), assume the message is
486
486
  // from the local user to prevent avatar/name bleed-through in bubble view.
487
- var isMultiUser = store.get('isMultiUserMode');
488
- var isOtherUser = isMultiUser && myUserId && fromUserId && fromUserId !== myUserId;
487
+ var isOtherUser = myUserId && fromUserId && fromUserId !== myUserId;
489
488
  var div = document.createElement("div");
490
489
  div.className = "msg-user" + (isOtherUser ? " msg-user-other" : "");
491
490
  div.dataset.turn = ++turnCounter;
@@ -29,7 +29,7 @@ var SETTINGS_SECTIONS = [
29
29
  { section: 'admin-invites', label: 'Invites', group: 'Admin', icon: 'mail', danger: false, adminOnly: true },
30
30
  { section: 'admin-projects', label: 'Projects', group: 'Admin', icon: 'folder', danger: false, adminOnly: true },
31
31
  { section: 'admin-smtp', label: 'Email', group: 'Server', icon: 'send', danger: false, adminOnly: true },
32
- { section: 'keep-awake', label: 'Keep Awake', group: 'Server', icon: 'zap', danger: false, conditionalId: 'settings-keep-awake-nav' },
32
+ { section: 'advanced', label: 'Advanced', group: 'Server', icon: 'settings-2', danger: false },
33
33
  { section: 'restart', label: 'Restart', group: 'Server', icon: 'refresh-cw', danger: false },
34
34
  { section: 'shutdown', label: 'Shutdown', group: 'Server', icon: 'power', danger: true },
35
35
  ];
@@ -233,6 +233,45 @@ export function initServerSettings(appCtx) {
233
233
  });
234
234
  }
235
235
 
236
+ // Advanced Memory: min available memory input
237
+ var memAvailInput = document.getElementById("settings-mem-available-min");
238
+ if (memAvailInput) {
239
+ memAvailInput.addEventListener("change", function () {
240
+ var val = parseInt(this.value, 10);
241
+ if (isNaN(val) || val < 0) return;
242
+ var ws = ctx.ws;
243
+ if (ws && ws.readyState === 1) {
244
+ ws.send(JSON.stringify({ type: "set_mem_available_threshold", value: val }));
245
+ }
246
+ });
247
+ }
248
+
249
+ // Advanced Memory: tokens per MB headroom input
250
+ var tpmInput = document.getElementById("settings-tokens-per-mb-headroom");
251
+ if (tpmInput) {
252
+ tpmInput.addEventListener("change", function () {
253
+ var val = parseInt(this.value, 10);
254
+ if (isNaN(val) || val < 10 || val > 500) return;
255
+ var ws = ctx.ws;
256
+ if (ws && ws.readyState === 1) {
257
+ ws.send(JSON.stringify({ type: "set_tokens_per_mb_headroom", value: val }));
258
+ }
259
+ });
260
+ }
261
+
262
+ // Advanced Memory: collapse toggle
263
+ var advMemToggle = document.getElementById("settings-advanced-memory-toggle");
264
+ var advMemBody = document.getElementById("settings-advanced-memory-body");
265
+ if (advMemToggle && advMemBody) {
266
+ advMemToggle.addEventListener("click", function () {
267
+ var isOpen = !advMemBody.classList.contains("hidden");
268
+ advMemBody.classList.toggle("hidden", isOpen);
269
+ advMemToggle.setAttribute("aria-expanded", String(!isOpen));
270
+ var chevron = advMemToggle.querySelector(".settings-adv-chevron");
271
+ if (chevron) chevron.style.transform = isOpen ? "" : "rotate(90deg)";
272
+ });
273
+ }
274
+
236
275
  // Global CLAUDE.md: save button
237
276
  var ssClaudeMdSave = document.getElementById("ss-claudemd-save");
238
277
  if (ssClaudeMdSave) {
@@ -248,6 +287,19 @@ export function initServerSettings(appCtx) {
248
287
  });
249
288
  }
250
289
 
290
+ // Refresh agent catalog
291
+ var refreshAgentsBtn = document.getElementById("settings-refresh-agents-btn");
292
+ if (refreshAgentsBtn) {
293
+ refreshAgentsBtn.addEventListener("click", function () {
294
+ var ws = ctx.ws;
295
+ if (ws && ws.readyState === 1) {
296
+ refreshAgentsBtn.disabled = true;
297
+ refreshAgentsBtn.innerHTML = '<i data-lucide="refresh-cw" style="width:14px;height:14px;vertical-align:-2px;margin-right:4px;"></i>Refreshing...';
298
+ ws.send(JSON.stringify({ type: "refresh_agents" }));
299
+ }
300
+ });
301
+ }
302
+
251
303
  // Restart server
252
304
  var restartBtn = document.getElementById("settings-restart-btn");
253
305
  if (restartBtn) {
@@ -738,17 +790,24 @@ export function updateDaemonConfig(config) {
738
790
  liteAutoEnrollToggle.checked = !!config.liteAutoEnroll;
739
791
  }
740
792
 
741
- // Show keep awake section/nav only on macOS
793
+ // Advanced Memory inputs
794
+ var memAvailEl = document.getElementById("settings-mem-available-min");
795
+ if (memAvailEl && config.memAvailableMinMB !== undefined) {
796
+ memAvailEl.value = String(config.memAvailableMinMB);
797
+ }
798
+ var tpmEl = document.getElementById("settings-tokens-per-mb-headroom");
799
+ if (tpmEl && config.tokensPerMbHeadroom !== undefined) {
800
+ tpmEl.value = String(config.tokensPerMbHeadroom);
801
+ }
802
+
803
+ // Show keep awake subsection only on macOS (lives inside the Advanced section)
742
804
  var keepAwakeSection = document.getElementById("settings-keep-awake-section");
743
- var keepAwakeNav = document.getElementById("settings-keep-awake-nav");
744
805
  var keepAwakeOpt = document.getElementById("settings-keep-awake-opt");
745
806
  if (config.platform === "darwin") {
746
807
  if (keepAwakeSection) keepAwakeSection.classList.remove("hidden");
747
- if (keepAwakeNav) keepAwakeNav.classList.remove("hidden");
748
808
  if (keepAwakeOpt) keepAwakeOpt.classList.remove("hidden");
749
809
  } else {
750
810
  if (keepAwakeSection) keepAwakeSection.classList.add("hidden");
751
- if (keepAwakeNav) keepAwakeNav.classList.add("hidden");
752
811
  if (keepAwakeOpt) keepAwakeOpt.classList.add("hidden");
753
812
  }
754
813
  }
@@ -770,6 +829,16 @@ export function handleAutoContinueChanged(msg) {
770
829
  // Auto-continue is now per-user; server broadcast no longer updates UI
771
830
  }
772
831
 
832
+ export function handleRefreshAgentsResult(msg) {
833
+ var btn = document.getElementById("settings-refresh-agents-btn");
834
+ if (!btn) return;
835
+ // Reset button regardless of ok — the toast (broadcast from server) carries
836
+ // the outcome. If not ok, we just unblock the button silently.
837
+ btn.disabled = false;
838
+ btn.innerHTML = '<i data-lucide="refresh-cw" style="width:14px;height:14px;vertical-align:-2px;margin-right:4px;"></i>Refresh agents';
839
+ refreshIcons();
840
+ }
841
+
773
842
  export function handleRestartResult(msg) {
774
843
  var restartBtn = document.getElementById("settings-restart-btn");
775
844
  var errorEl = document.getElementById("settings-restart-error");
@@ -42,6 +42,7 @@ import { openDm } from './app-dm.js';
42
42
  import { showHomeHub } from './app-home-hub.js';
43
43
  import { openTerminal } from './terminal.js';
44
44
  import { loadRootDirectory } from './filebrowser.js';
45
+ import { renderSheetTeam as renderTeamView } from './team-panel.js';
45
46
 
46
47
  // --- Mobile state ---
47
48
  var mobileChatSheetOpen = false;
@@ -85,9 +86,9 @@ export function openMobileSheet(type) {
85
86
  fileTree.classList.remove("hidden");
86
87
  }
87
88
  loadRootDirectory();
88
- } else if (type === "search") {
89
- titleEl.textContent = "Search";
90
- renderSheetSearch(listEl);
89
+ } else if (type === "team") {
90
+ titleEl.textContent = "Team";
91
+ renderSheetTeam(listEl);
91
92
  } else if (type === "more") {
92
93
  titleEl.textContent = "More";
93
94
  renderSheetMore(listEl);
@@ -1057,88 +1058,8 @@ function renderSheetMateProfile(listEl) {
1057
1058
  }
1058
1059
  }
1059
1060
 
1060
- function renderSheetSearch(listEl) {
1061
- // Search input at top
1062
- var wrap = document.createElement("div");
1063
- wrap.className = "mobile-search-input-wrap";
1064
- var input = document.createElement("input");
1065
- input.className = "mobile-search-input";
1066
- input.type = "text";
1067
- input.placeholder = "Search sessions, messages...";
1068
- input.autocomplete = "off";
1069
- input.spellcheck = false;
1070
- wrap.appendChild(input);
1071
- listEl.appendChild(wrap);
1072
-
1073
- // Results container
1074
- var resultsEl = document.createElement("div");
1075
- resultsEl.style.padding = "0 8px";
1076
- listEl.appendChild(resultsEl);
1077
-
1078
- // Auto-focus
1079
- setTimeout(function () { input.focus(); }, 300);
1080
-
1081
- // Show all sessions initially
1082
- renderSearchResults(resultsEl, "");
1083
-
1084
- input.addEventListener("input", function () {
1085
- var q = input.value.trim().toLowerCase();
1086
- renderSearchResults(resultsEl, q);
1087
- });
1088
- input.addEventListener("keydown", function (e) { e.stopPropagation(); });
1089
- input.addEventListener("keyup", function (e) { e.stopPropagation(); });
1090
- input.addEventListener("keypress", function (e) { e.stopPropagation(); });
1091
- }
1092
-
1093
- function renderSearchResults(container, query) {
1094
- container.innerHTML = "";
1095
- var sorted = getCachedSessions().slice().sort(function (a, b) {
1096
- if (!!a.bookmarked !== !!b.bookmarked) return a.bookmarked ? -1 : 1;
1097
- return (b.lastActivity || 0) - (a.lastActivity || 0);
1098
- });
1099
-
1100
- var found = 0;
1101
- for (var i = 0; i < sorted.length; i++) {
1102
- var s = sorted[i];
1103
- var title = s.title || "New Session";
1104
- if (query && title.toLowerCase().indexOf(query) === -1) continue;
1105
- found++;
1106
-
1107
- var el = document.createElement("button");
1108
- el.className = "mobile-session-item";
1109
- if (s.active) el.classList.add("active");
1110
-
1111
- var titleSpan = document.createElement("span");
1112
- titleSpan.className = "mobile-session-title";
1113
- titleSpan.appendChild(document.createTextNode(title));
1114
- el.appendChild(titleSpan);
1115
-
1116
- if (s.isProcessing) {
1117
- var dot = document.createElement("span");
1118
- dot.className = "mobile-session-processing";
1119
- el.appendChild(dot);
1120
- }
1121
-
1122
- (function (id) {
1123
- el.addEventListener("click", function () {
1124
- if (dismissOverlayPanels) dismissOverlayPanels();
1125
- closeMobileSheetThen(function () {
1126
- if (getWs() && store.get('connected')) {
1127
- getWs().send(JSON.stringify({ type: "switch_session", id: id }));
1128
- }
1129
- });
1130
- });
1131
- })(s.id);
1132
-
1133
- container.appendChild(el);
1134
- }
1135
-
1136
- if (found === 0 && query) {
1137
- var empty = document.createElement("div");
1138
- empty.className = "mobile-alert-empty";
1139
- empty.textContent = 'No results for "' + query + '"';
1140
- container.appendChild(empty);
1141
- }
1061
+ function renderSheetTeam(listEl) {
1062
+ renderTeamView(listEl);
1142
1063
  }
1143
1064
 
1144
1065
  function renderSheetMore(listEl) {
@@ -1409,9 +1330,9 @@ export function initSidebarMobile() {
1409
1330
  } else if (name === "chat") {
1410
1331
  openMobileSheet("sessions");
1411
1332
  setMobileTabActive("chat");
1412
- } else if (name === "search") {
1413
- openCommandPalette();
1414
- setMobileTabActive("search");
1333
+ } else if (name === "team") {
1334
+ openMobileSheet("team");
1335
+ setMobileTabActive("team");
1415
1336
  } else if (name === "more") {
1416
1337
  openMobileSheet("more");
1417
1338
  setMobileTabActive("more");
@@ -474,7 +474,7 @@ function showProjectCtxMenu(anchorEl, slug, name, icon, position) {
474
474
  menu.appendChild(shareItem);
475
475
 
476
476
  // --- Manage Access ---
477
- if (store.get('isMultiUserMode') && slug.indexOf("--") === -1) {
477
+ if (slug.indexOf("--") === -1) {
478
478
  var isProjectOwner = store.get('myUserId') && store.get('currentProjectOwnerId') && store.get('myUserId') === store.get('currentProjectOwnerId');
479
479
  var isAdmin = store.get('permissions') && store.get('permissions').projectSettings !== false;
480
480
  if (isProjectOwner || isAdmin) {
@@ -649,7 +649,7 @@ function showSessionCtxMenu(anchorBtn, sessionId, title, cliSid, sessionData) {
649
649
  menu.appendChild(renameItem);
650
650
 
651
651
  // Session visibility toggle (only the session owner can change)
652
- if (store.get('isMultiUserMode') && sessionData && sessionData.ownerId && sessionData.ownerId === store.get('myUserId')) {
652
+ if (sessionData && sessionData.ownerId && sessionData.ownerId === store.get('myUserId')) {
653
653
  var currentVis = (sessionData && sessionData.sessionVisibility) || "shared";
654
654
  var isPrivate = currentVis === "private";
655
655
  var visItem = document.createElement("button");
@@ -1141,7 +1141,7 @@ function renderSessionItem(s) {
1141
1141
  if (s.isProcessing) {
1142
1142
  textHtml += '<span class="session-processing"></span>';
1143
1143
  }
1144
- if (store.get('isMultiUserMode') && s.sessionVisibility === "private") {
1144
+ if (s.sessionVisibility === "private") {
1145
1145
  textHtml += '<span class="session-private-icon" title="Private session">' + iconHtml("lock") + '</span>';
1146
1146
  }
1147
1147
  // lr-7db0 — agent badge for sessions cast as a named agent via the SDK `agent` option.
@@ -1360,6 +1360,10 @@ export function renderSessionList(sessions) {
1360
1360
  refreshIcons();
1361
1361
  if (updatePageTitle) updatePageTitle();
1362
1362
  syncHeaderSearchUi();
1363
+ // Re-arm the countdown timer after each render. startCountdownTimer() is a
1364
+ // no-op when schedules are outside the 3-minute window or the timer is
1365
+ // already running, so calling it here is safe and low-cost.
1366
+ startCountdownTimer();
1363
1367
  }
1364
1368
 
1365
1369
  // --- Search results ---