@clagentic/console 1.5.0 → 1.6.0-beta.2

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 (66) hide show
  1. package/README.md +23 -4
  2. package/bin/cli.js +15 -82
  3. package/lib/agents-favorites.js +21 -6
  4. package/lib/config.js +1 -1
  5. package/lib/daemon.js +153 -22
  6. package/lib/drain.js +213 -0
  7. package/lib/lite-detect.js +6 -5
  8. package/lib/loop-handoff.js +282 -0
  9. package/lib/mcp-local.js +18 -2
  10. package/lib/memory-limits.js +436 -0
  11. package/lib/model-context-windows.js +65 -0
  12. package/lib/project-loop.js +31 -3
  13. package/lib/project-sessions.js +26 -0
  14. package/lib/project-team.js +4 -1
  15. package/lib/project.js +8 -0
  16. package/lib/public/app.js +4 -0
  17. package/lib/public/css/base.css +18 -0
  18. package/lib/public/css/diagnostics.css +279 -0
  19. package/lib/public/css/icon-strip.css +201 -0
  20. package/lib/public/css/menus.css +2 -2
  21. package/lib/public/css/mobile-nav.css +24 -0
  22. package/lib/public/css/server-settings.css +100 -0
  23. package/lib/public/index.html +26 -0
  24. package/lib/public/modules/app-header.js +4 -7
  25. package/lib/public/modules/app-home-hub.js +31 -7
  26. package/lib/public/modules/app-messages.js +13 -0
  27. package/lib/public/modules/app-notifications.js +5 -1
  28. package/lib/public/modules/app-panels.js +11 -21
  29. package/lib/public/modules/app-projects.js +10 -5
  30. package/lib/public/modules/command-palette.js +16 -5
  31. package/lib/public/modules/custom-icons-settings.js +399 -0
  32. package/lib/public/modules/custom-icons.js +114 -0
  33. package/lib/public/modules/diagnostic-format.js +34 -0
  34. package/lib/public/modules/diagnostics.js +297 -0
  35. package/lib/public/modules/emoji-picker.js +253 -6
  36. package/lib/public/modules/model-context-windows.js +62 -0
  37. package/lib/public/modules/popover-position.js +192 -0
  38. package/lib/public/modules/project-icon.js +113 -0
  39. package/lib/public/modules/project-settings.js +2 -2
  40. package/lib/public/modules/project-switcher.js +2 -1
  41. package/lib/public/modules/scheduler-config.js +5 -8
  42. package/lib/public/modules/scheduler.js +5 -6
  43. package/lib/public/modules/server-settings.js +6 -0
  44. package/lib/public/modules/sidebar-mobile.js +4 -6
  45. package/lib/public/modules/sidebar-projects.js +35 -90
  46. package/lib/public/modules/sidebar-sessions.js +6 -20
  47. package/lib/public/modules/sticky-notes.js +4 -4
  48. package/lib/public/modules/terminal.js +5 -12
  49. package/lib/public/style.css +1 -0
  50. package/lib/sdk-bridge.js +75 -10
  51. package/lib/sdk-message-processor.js +12 -0
  52. package/lib/sdk-worker.js +4 -1
  53. package/lib/server-settings.js +221 -1
  54. package/lib/server.js +30 -1
  55. package/lib/sessions.js +27 -11
  56. package/lib/settings-preflight.js +212 -0
  57. package/lib/ws-schema.js +2 -0
  58. package/lib/yoke/adapters/claude-worker.js +14 -2
  59. package/lib/yoke/adapters/claude.js +16 -0
  60. package/lib/yoke/adapters/diagnostic-patterns.js +120 -0
  61. package/lib/yoke/index.js +4 -0
  62. package/lib/yoke/interface.js +99 -0
  63. package/package.json +2 -1
  64. package/scripts/postinstall.js +41 -0
  65. package/lib/certs/fullchain.pem +0 -47
  66. package/lib/certs/privkey.pem +0 -5
@@ -0,0 +1,192 @@
1
+ // popover-position.js — Shared viewport-clamp positioning util for popovers,
2
+ // context menus, and dropdowns (lr-a10a).
3
+ //
4
+ // BACKGROUND: many popup call sites positioned themselves via
5
+ // getBoundingClientRect() + inline style.top/left, clamping only the
6
+ // right/bottom edges (or, in some cases, no edge at all). On mobile the
7
+ // anchor is often near the bottom or right edge of a narrow viewport (e.g.
8
+ // the fixed icon-strip, a low context-menu trigger, a synthetic
9
+ // contextmenu from a mobile action-sheet), so the popup could still land
10
+ // with its top or left edge off-screen. lr-149e fixed this one-off for the
11
+ // emoji picker (positionEmojiPicker in sidebar-projects.js); this module
12
+ // generalizes that fix into a single reusable helper so every affected
13
+ // popup routes through the same math instead of reinventing it.
14
+ //
15
+ // The clamp math (clampRect) is DOM-free and unit-testable directly from
16
+ // Node; positionPopover / positionAtPoint are thin DOM wrappers used by
17
+ // browser call sites.
18
+
19
+ // Mobile breakpoint mirrors the @media (max-width: 768px) blocks used
20
+ // throughout the CSS (see icon-strip.css, etc).
21
+ export var MOBILE_BREAKPOINT = 768;
22
+
23
+ /**
24
+ * True when the current viewport width is at or below the mobile breakpoint.
25
+ * @returns {boolean}
26
+ */
27
+ export function isMobileViewport() {
28
+ return window.innerWidth <= MOBILE_BREAKPOINT;
29
+ }
30
+
31
+ /**
32
+ * Clamp a popover rect to the viewport on all four edges.
33
+ *
34
+ * Pure function — no DOM access — so it can be unit-tested directly.
35
+ *
36
+ * @param {{top:number, left:number, width:number, height:number}} rect
37
+ * The popover's natural (unclamped) position and measured size.
38
+ * @param {{innerWidth:number, innerHeight:number}} viewport
39
+ * @param {object} [opts]
40
+ * @param {number} [opts.margin=8] Minimum gap to keep from every edge.
41
+ * @returns {{top:number, left:number}}
42
+ */
43
+ export function clampRect(rect, viewport, opts) {
44
+ var margin = (opts && typeof opts.margin === "number") ? opts.margin : 8;
45
+ var maxLeft = viewport.innerWidth - rect.width - margin;
46
+ var maxTop = viewport.innerHeight - rect.height - margin;
47
+
48
+ // Clamp left/right first.
49
+ var left = rect.left;
50
+ if (left > maxLeft) left = maxLeft;
51
+ if (left < margin) left = margin;
52
+
53
+ // Clamp top/bottom.
54
+ var top = rect.top;
55
+ if (top > maxTop) top = maxTop;
56
+ if (top < margin) top = margin;
57
+
58
+ return { top: top, left: left };
59
+ }
60
+
61
+ /**
62
+ * Compute a clamped position for a popover anchored to an element.
63
+ *
64
+ * Desktop behavior (preserves existing anchor-relative behavior): the
65
+ * popover opens at (preferredTop, preferredLeft) relative to the anchor
66
+ * rect, per `placement`, then gets flipped to the opposite side if it
67
+ * would overflow, then clamped on all four edges as a final safety net
68
+ * (this is the "prefer flip-then-clamp" requirement — flipping alone
69
+ * cannot leave the popover off-screen because the clamp always runs
70
+ * afterward).
71
+ *
72
+ * Mobile behavior: centers the popover in the viewport (matches the
73
+ * lr-149e emoji-picker fix) rather than anchoring, since low/edge anchors
74
+ * on narrow viewports frequently have no safe anchor-relative position.
75
+ *
76
+ * @param {{width:number, height:number}} popoverSize Measured popover size (getBoundingClientRect of the appended-but-unpositioned element).
77
+ * @param {{top:number, left:number, right:number, bottom:number}} anchorRect Anchor element's getBoundingClientRect().
78
+ * @param {{innerWidth:number, innerHeight:number}} viewport
79
+ * @param {object} [opts]
80
+ * @param {"right"|"below"|"below-right-aligned"} [opts.placement="right"]
81
+ * Preferred side: "right" of the anchor (default, matches existing
82
+ * ctx-menu behavior), "below" the anchor left-aligned, or
83
+ * "below-right-aligned" (below the anchor with the popover's right edge
84
+ * aligned to the anchor's right edge — matches session/loop ctx-menu
85
+ * `right: window.innerWidth - btnRect.right` anchoring).
86
+ * @param {number} [opts.gap=6] Gap between anchor and popover on the preferred side.
87
+ * @param {number} [opts.margin=8] Minimum gap from viewport edges.
88
+ * @param {boolean} [opts.mobile] Force mobile/desktop branch (defaults to viewport.innerWidth <= MOBILE_BREAKPOINT).
89
+ * @returns {{top:number, left:number}}
90
+ */
91
+ export function computePopoverPosition(popoverSize, anchorRect, viewport, opts) {
92
+ opts = opts || {};
93
+ var margin = typeof opts.margin === "number" ? opts.margin : 8;
94
+ var gap = typeof opts.gap === "number" ? opts.gap : 6;
95
+ var placement = opts.placement || "right";
96
+ var mobile = typeof opts.mobile === "boolean" ? opts.mobile : (viewport.innerWidth <= MOBILE_BREAKPOINT);
97
+
98
+ if (mobile) {
99
+ var left = Math.max(margin, (viewport.innerWidth - popoverSize.width) / 2);
100
+ var top = Math.max(margin, (viewport.innerHeight - popoverSize.height) / 2);
101
+ return clampRect({ top: top, left: left, width: popoverSize.width, height: popoverSize.height }, viewport, { margin: margin });
102
+ }
103
+
104
+ var top2, left2;
105
+ if (placement === "below-right-aligned") {
106
+ left2 = anchorRect.right - popoverSize.width;
107
+ top2 = anchorRect.bottom + gap;
108
+ // Flip above the anchor if it would overflow the bottom edge.
109
+ if (top2 + popoverSize.height > viewport.innerHeight - margin) {
110
+ top2 = anchorRect.top - popoverSize.height - gap;
111
+ }
112
+ } else if (placement === "below") {
113
+ left2 = anchorRect.left;
114
+ top2 = anchorRect.bottom + gap;
115
+ // Flip above the anchor if it would overflow the bottom edge.
116
+ if (top2 + popoverSize.height > viewport.innerHeight - margin) {
117
+ top2 = anchorRect.top - popoverSize.height - gap;
118
+ }
119
+ } else {
120
+ // placement === "right" (default)
121
+ left2 = anchorRect.right + gap;
122
+ top2 = anchorRect.top;
123
+ // Flip to the left of the anchor if it would overflow the right edge.
124
+ if (left2 + popoverSize.width > viewport.innerWidth - margin) {
125
+ left2 = anchorRect.left - popoverSize.width - gap;
126
+ }
127
+ }
128
+
129
+ // Final safety net: clamp on all four edges regardless of flip outcome,
130
+ // so a low/edge anchor (e.g. mobile bottom-sheet trigger) never leaves
131
+ // the popover with top < 0 or top + height > innerHeight (and same for
132
+ // left/right).
133
+ return clampRect({ top: top2, left: left2, width: popoverSize.width, height: popoverSize.height }, viewport, { margin: margin });
134
+ }
135
+
136
+ /**
137
+ * Compute a clamped position for a popover opened at an arbitrary point
138
+ * (e.g. a contextmenu event's clientX/clientY) rather than anchored to an
139
+ * element. Used by sites like terminal.js's right-click menu.
140
+ *
141
+ * @param {{width:number, height:number}} popoverSize
142
+ * @param {{x:number, y:number}} point
143
+ * @param {{innerWidth:number, innerHeight:number}} viewport
144
+ * @param {object} [opts]
145
+ * @param {number} [opts.margin=4]
146
+ * @returns {{top:number, left:number}}
147
+ */
148
+ export function computePointPosition(popoverSize, point, viewport, opts) {
149
+ var margin = (opts && typeof opts.margin === "number") ? opts.margin : 4;
150
+ return clampRect({ top: point.y, left: point.x, width: popoverSize.width, height: popoverSize.height }, viewport, { margin: margin });
151
+ }
152
+
153
+ /**
154
+ * DOM wrapper: position an already-appended (so it can be measured) popover
155
+ * element relative to an anchor element, applying the clamp math above, and
156
+ * write the result to inline styles.
157
+ *
158
+ * @param {HTMLElement} el The popover element (must already be appended to the DOM so getBoundingClientRect() reports real dimensions).
159
+ * @param {HTMLElement} anchorEl
160
+ * @param {object} [opts] See computePopoverPosition opts.
161
+ */
162
+ export function positionPopover(el, anchorEl, opts) {
163
+ var popRect = el.getBoundingClientRect();
164
+ var anchorRect = anchorEl.getBoundingClientRect();
165
+ var viewport = { innerWidth: window.innerWidth, innerHeight: window.innerHeight };
166
+ var pos = computePopoverPosition(
167
+ { width: popRect.width, height: popRect.height },
168
+ anchorRect,
169
+ viewport,
170
+ opts
171
+ );
172
+ el.style.position = "fixed";
173
+ el.style.left = pos.left + "px";
174
+ el.style.top = pos.top + "px";
175
+ }
176
+
177
+ /**
178
+ * DOM wrapper: position an already-appended popover element at a point
179
+ * (e.g. contextmenu clientX/clientY), applying the clamp math above.
180
+ *
181
+ * @param {HTMLElement} el
182
+ * @param {{x:number, y:number}} point
183
+ * @param {object} [opts] See computePointPosition opts.
184
+ */
185
+ export function positionAtPoint(el, point, opts) {
186
+ var popRect = el.getBoundingClientRect();
187
+ var viewport = { innerWidth: window.innerWidth, innerHeight: window.innerHeight };
188
+ var pos = computePointPosition({ width: popRect.width, height: popRect.height }, point, viewport, opts);
189
+ el.style.position = "fixed";
190
+ el.style.left = pos.left + "px";
191
+ el.style.top = pos.top + "px";
192
+ }
@@ -0,0 +1,113 @@
1
+ // project-icon.js — Shared helper for rendering project icons.
2
+ //
3
+ // A project icon is either:
4
+ // - A custom image, stored as `:slug:` in config.projects[].icon.
5
+ // Detect with isCustomIcon(); render as <img src="/api/custom-emoji/{slug}">.
6
+ // - A Unicode emoji (any other non-empty string).
7
+ // Render via the existing parseEmojis() path.
8
+ // - null / undefined / empty — caller shows an abbreviation fallback.
9
+ //
10
+ // The helpers here are DOM-free for the classification functions so they can
11
+ // be imported in Node test environments as well as the browser.
12
+
13
+ // Custom-icon sentinel pattern: :slug: where slug is [a-z0-9_-]{1,64}
14
+ var CUSTOM_ICON_RE = /^:[a-z0-9_-]{1,64}:$/;
15
+
16
+ /**
17
+ * Returns true when iconStr is a custom-image sentinel (:slug:).
18
+ * @param {string|null|undefined} iconStr
19
+ * @returns {boolean}
20
+ */
21
+ export function isCustomIcon(iconStr) {
22
+ if (!iconStr || typeof iconStr !== "string") return false;
23
+ return CUSTOM_ICON_RE.test(iconStr);
24
+ }
25
+
26
+ /**
27
+ * Extract the slug from a custom-icon sentinel.
28
+ * Returns null when iconStr is not a custom-icon sentinel.
29
+ * @param {string|null|undefined} iconStr
30
+ * @returns {string|null}
31
+ */
32
+ export function customIconSlug(iconStr) {
33
+ if (!isCustomIcon(iconStr)) return null;
34
+ return iconStr.slice(1, -1); // strip leading and trailing ":"
35
+ }
36
+
37
+ // Minimal HTML-escape for the string-composition path (projectIconHtml).
38
+ // Mirrors escapeHtml() from utils.js without importing it, so this module
39
+ // stays DOM-free / Node-importable (see file header).
40
+ function escapeForHtml(str) {
41
+ return String(str)
42
+ .replace(/&/g, "&amp;")
43
+ .replace(/</g, "&lt;")
44
+ .replace(/>/g, "&gt;")
45
+ .replace(/"/g, "&quot;")
46
+ .replace(/'/g, "&#39;");
47
+ }
48
+
49
+ /**
50
+ * Build a safe HTML string for a project/folder icon, for call sites that
51
+ * compose markup via string concatenation + innerHTML (e.g. command-palette.js)
52
+ * rather than direct DOM-API building.
53
+ *
54
+ * Behaviour mirrors renderProjectIcon():
55
+ * - Custom icon -> "<img src=... class="project-emoji-img">" markup.
56
+ * Safe to interpolate: customIconSlug() already validated the slug against
57
+ * CUSTOM_ICON_RE ([a-z0-9_-]{1,64}), so no raw user/icon string is ever
58
+ * concatenated into the returned markup.
59
+ * - Emoji string -> HTML-escaped text (defends against a non-sentinel icon
60
+ * value that isn't actually a safe emoji).
61
+ * - null/empty -> fallbackHtml (caller-supplied placeholder markup, e.g.
62
+ * a lucide `<i data-lucide="...">` icon).
63
+ *
64
+ * @param {string|null|undefined} iconStr
65
+ * @param {string} [fallbackHtml]
66
+ * @returns {string}
67
+ */
68
+ export function projectIconHtml(iconStr, fallbackHtml) {
69
+ if (!iconStr) return fallbackHtml || "";
70
+ var slug = customIconSlug(iconStr);
71
+ if (slug) {
72
+ // Inline onerror mirrors renderProjectIcon()'s delete-in-use fallback
73
+ // (hide the broken image) since this string-built markup has no JS
74
+ // event-listener wiring of its own. The handler is a fixed literal —
75
+ // nothing from iconStr is interpolated into it.
76
+ return '<img src="/api/custom-emoji/' + encodeURIComponent(slug) + '" alt=":' + slug + ':" class="project-emoji-img" onerror="this.style.display=&#39;none&#39;">';
77
+ }
78
+ return escapeForHtml(iconStr);
79
+ }
80
+
81
+ /**
82
+ * Render a project icon into the given DOM element.
83
+ *
84
+ * Behaviour:
85
+ * - Custom icon → replaces el content with <img src="/api/custom-emoji/{slug}"
86
+ * class="project-emoji-img"> (no innerHTML: safe against XSS).
87
+ * - Emoji string → sets el.textContent = iconStr, then calls parseEmojis(el).
88
+ * - null/empty → clears the element (caller may show an abbreviation).
89
+ *
90
+ * @param {string|null|undefined} iconStr The icon value from project config.
91
+ * @param {Element} el The container element to render into.
92
+ * @param {Function} [parseEmojisFn] parseEmojis from markdown.js (browser only).
93
+ */
94
+ export function renderProjectIcon(iconStr, el, parseEmojisFn) {
95
+ // Clear previous content
96
+ el.textContent = "";
97
+
98
+ if (!iconStr) return;
99
+
100
+ var slug = customIconSlug(iconStr);
101
+ if (slug) {
102
+ var img = document.createElement("img");
103
+ img.src = "/api/custom-emoji/" + encodeURIComponent(slug);
104
+ img.alt = ":" + slug + ":";
105
+ img.className = "project-emoji-img";
106
+ // Graceful fallback: if the image 404s (deleted-in-use), show nothing
107
+ img.addEventListener("error", function () { img.style.display = "none"; });
108
+ el.appendChild(img);
109
+ } else {
110
+ el.textContent = iconStr;
111
+ if (typeof parseEmojisFn === "function") parseEmojisFn(el);
112
+ }
113
+ }
@@ -3,6 +3,7 @@ import { refreshIcons } from './icons.js';
3
3
  import { buildEmojiPicker } from './emoji-picker.js';
4
4
  import { showToast } from './utils.js';
5
5
  import { parseEmojis } from './markdown.js';
6
+ import { renderProjectIcon } from './project-icon.js';
6
7
  import { pushOverlayState, popOverlayState } from './overlay-history.js';
7
8
  import { closeFileViewer } from './filebrowser.js';
8
9
  import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar, renderBetaCard } from './settings-defaults.js';
@@ -546,8 +547,7 @@ function updateIconPreview(icon) {
546
547
  var preview = document.getElementById("ps-icon-preview");
547
548
  var removeBtn = document.getElementById("ps-icon-remove-btn");
548
549
  if (preview) {
549
- preview.textContent = icon || "";
550
- if (icon) parseEmojis(preview);
550
+ renderProjectIcon(icon || null, preview, parseEmojis);
551
551
  }
552
552
  if (removeBtn) {
553
553
  removeBtn.classList.toggle("hidden", !icon);
@@ -13,6 +13,7 @@ import { store } from './store.js';
13
13
  import { refreshIcons } from './icons.js';
14
14
  import { getCachedProjects, switchProject } from './app-projects.js';
15
15
  import { parseEmojis } from './markdown.js';
16
+ import { renderProjectIcon } from './project-icon.js';
16
17
 
17
18
  var _projectMru = []; // project slugs, most recent first
18
19
  var _overlay = null;
@@ -250,7 +251,7 @@ function buildEntryNode(entry, index) {
250
251
  var iconWrap = document.createElement('div');
251
252
  iconWrap.className = 'cmd-palette-item-icon';
252
253
  if (entry.icon) {
253
- iconWrap.textContent = entry.icon;
254
+ renderProjectIcon(entry.icon, iconWrap, parseEmojis);
254
255
  } else if (entry.avatarUrl) {
255
256
  var img = document.createElement('img');
256
257
  img.src = entry.avatarUrl;
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { showToast } from './utils.js';
8
+ import { positionPopover } from './popover-position.js';
8
9
 
9
10
  // Constants (duplicated from scheduler.js — small arrays)
10
11
  var DAY_NAMES = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
@@ -313,15 +314,11 @@ export function setupCreateModal() {
313
314
  endBtn.addEventListener("click", function (e) {
314
315
  e.stopPropagation();
315
316
  if (endList.classList.contains("hidden")) {
316
- var r = endBtn.getBoundingClientRect();
317
- endList.style.left = r.left + "px";
318
- endList.style.top = (r.bottom + 4) + "px";
319
- // If it would overflow bottom, show above
320
317
  endList.classList.remove("hidden");
321
- var lr = endList.getBoundingClientRect();
322
- if (lr.bottom > window.innerHeight - 8) {
323
- endList.style.top = (r.top - lr.height - 4) + "px";
324
- }
318
+ // Four-edge clamp (lr-a10a): the prior bottom-flip-only logic could
319
+ // leave the flipped dropdown with top < 0 when the button sits near
320
+ // the top of a short viewport.
321
+ positionPopover(endList, endBtn, { placement: "below", gap: 4 });
325
322
  } else {
326
323
  endList.classList.add("hidden");
327
324
  }
@@ -12,6 +12,7 @@ import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar } f
12
12
  import { store } from './store.js';
13
13
  import { initSchedulerConfig, setupCreateModal, openCreateModal, openCreateModalWithRecord, closeCreateModal, removePreview, getPreviewEl, showPreviewOnCell, showPreviewOnSlot, showPreviewForCreate, applyDraggedTask, parseCronSimple } from './scheduler-config.js';
14
14
  import { initSchedulerHistory, renderHistory, _lastFiles as lastLoopFiles } from './scheduler-history.js';
15
+ import { positionPopover } from './popover-position.js';
15
16
  export { handleLoopRegistryUpdated, handleLoopRegistryFiles, handleScheduleRunStarted, handleScheduleRunFinished, handleLoopScheduled } from './scheduler-history.js';
16
17
 
17
18
  var ctx = null;
@@ -1399,9 +1400,7 @@ function showMovePopover(recId, anchorEl) {
1399
1400
  if (projects.length === 0) {
1400
1401
  popoverEl.innerHTML = '<div class="schedule-popover-name">No other projects available</div>';
1401
1402
  popoverEl.classList.remove("hidden");
1402
- var r2 = anchorEl.getBoundingClientRect();
1403
- popoverEl.style.left = Math.max(8, r2.left) + "px";
1404
- popoverEl.style.top = (r2.bottom + 6) + "px";
1403
+ positionPopover(popoverEl, anchorEl, { placement: "below" });
1405
1404
  return;
1406
1405
  }
1407
1406
 
@@ -1415,9 +1414,9 @@ function showMovePopover(recId, anchorEl) {
1415
1414
  popoverEl.innerHTML = html;
1416
1415
  popoverEl.classList.remove("hidden");
1417
1416
 
1418
- var rect = anchorEl.getBoundingClientRect();
1419
- popoverEl.style.left = Math.max(8, Math.min(rect.left, window.innerWidth - 268)) + "px";
1420
- popoverEl.style.top = (rect.bottom + 6) + "px";
1417
+ // Four-edge clamp (lr-a10a): the prior left-only clamp could still leave
1418
+ // the popover with its bottom edge off-screen on short mobile viewports.
1419
+ positionPopover(popoverEl, anchorEl, { placement: "below" });
1421
1420
 
1422
1421
  var btns = popoverEl.querySelectorAll('[data-action="move-to"]');
1423
1422
  for (var b = 0; b < btns.length; b++) {
@@ -6,6 +6,7 @@ import { parseEnvString, looksLikeEnv } from './project-settings.js';
6
6
  import { checkAdminAccess, loadAdminSection } from './admin.js';
7
7
  import { closeFileViewer } from './filebrowser.js';
8
8
  import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar, renderBetaCard, isSonnetModel } from './settings-defaults.js';
9
+ import { initCustomIconsSettings, initCustomIconsUpload, loadCustomIcons } from './custom-icons-settings.js';
9
10
 
10
11
  var ctx = null;
11
12
  var settingsEl = null;
@@ -24,6 +25,7 @@ var SETTINGS_SECTIONS = [
24
25
  { section: 'claudemd', label: 'Instructions', group: 'Config', icon: 'file-text', danger: false },
25
26
  { section: 'environment', label: 'Environment', group: 'Config', icon: 'terminal', danger: false },
26
27
  { section: 'storage', label: 'Storage', group: 'Config', icon: 'database', danger: false },
28
+ { section: 'custom-icons', label: 'Custom Icons', group: 'Config', icon: 'image', danger: false },
27
29
  { section: 'lite', label: 'Lite', group: 'Clagentic', icon: 'zap', danger: false },
28
30
  { section: 'admin-users', label: 'Users', group: 'Admin', icon: 'users', danger: false, adminOnly: true },
29
31
  { section: 'admin-invites', label: 'Invites', group: 'Admin', icon: 'mail', danger: false, adminOnly: true },
@@ -47,6 +49,9 @@ export function initServerSettings(appCtx) {
47
49
 
48
50
  if (!settingsEl || !settingsBtn) return;
49
51
 
52
+ initCustomIconsSettings(appCtx);
53
+ initCustomIconsUpload();
54
+
50
55
  navItems = settingsEl.querySelectorAll(".settings-nav-item");
51
56
  sections = settingsEl.querySelectorAll(".server-settings-section");
52
57
 
@@ -521,6 +526,7 @@ function switchSection(sectionName) {
521
526
  // Lazy-load section data
522
527
  if (sectionName === "claudemd") loadGlobalClaudeMd();
523
528
  if (sectionName === "environment") loadSharedEnv();
529
+ if (sectionName === "custom-icons") loadCustomIcons();
524
530
  if (sectionName === "admin-users" || sectionName === "admin-invites" || sectionName === "admin-projects" || sectionName === "admin-smtp") {
525
531
  var adminBody = document.getElementById(sectionName + "-body");
526
532
  if (adminBody) loadAdminSection(sectionName, adminBody);
@@ -6,6 +6,7 @@ import { escapeHtml } from './utils.js';
6
6
  import { iconHtml, refreshIcons } from './icons.js';
7
7
  import { getSessionTools } from './tool-palette.js';
8
8
  import { parseEmojis } from './markdown.js';
9
+ import { renderProjectIcon } from './project-icon.js';
9
10
  import { getCurrentTheme, getChatLayout, setChatLayout, toggleDarkMode, getBrand, setBrand } from './theme.js';
10
11
  import { openCommandPalette } from './command-palette.js';
11
12
  import { openAgentPicker, openAgentPickerForPreferred } from './agent-picker.js';
@@ -175,8 +176,7 @@ function renderSheetProjects(listEl) {
175
176
  var abbrev = document.createElement("span");
176
177
  abbrev.className = "mobile-project-abbrev";
177
178
  if (p.icon) {
178
- abbrev.textContent = p.icon;
179
- parseEmojis(abbrev);
179
+ renderProjectIcon(p.icon, abbrev, parseEmojis);
180
180
  } else {
181
181
  abbrev.textContent = getProjectAbbrev(p.name);
182
182
  }
@@ -254,8 +254,7 @@ function renderSheetProjects(listEl) {
254
254
  if (meta.icon) {
255
255
  var overlay = document.createElement("span");
256
256
  overlay.className = "mobile-folder-emoji-overlay";
257
- overlay.textContent = meta.icon;
258
- parseEmojis(overlay);
257
+ renderProjectIcon(meta.icon, overlay, parseEmojis);
259
258
  iconWrap.appendChild(overlay);
260
259
  }
261
260
  headerEl.appendChild(iconWrap);
@@ -361,8 +360,7 @@ function renderSheetSessions(listEl) {
361
360
  var projIcon = document.createElement("span");
362
361
  projIcon.className = "mobile-chat-project-icon";
363
362
  if (currentProject.icon) {
364
- projIcon.textContent = currentProject.icon;
365
- parseEmojis(projIcon);
363
+ renderProjectIcon(currentProject.icon, projIcon, parseEmojis);
366
364
  } else {
367
365
  projIcon.textContent = getProjectAbbrev(currentProject.name);
368
366
  }