@clagentic/console 1.6.0-beta.1 → 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 (37) hide show
  1. package/README.md +18 -0
  2. package/lib/daemon.js +94 -0
  3. package/lib/project-sessions.js +26 -0
  4. package/lib/public/css/base.css +18 -0
  5. package/lib/public/css/diagnostics.css +8 -0
  6. package/lib/public/css/icon-strip.css +201 -0
  7. package/lib/public/css/menus.css +2 -2
  8. package/lib/public/css/mobile-nav.css +24 -0
  9. package/lib/public/css/server-settings.css +100 -0
  10. package/lib/public/index.html +13 -0
  11. package/lib/public/modules/app-header.js +4 -7
  12. package/lib/public/modules/app-home-hub.js +31 -7
  13. package/lib/public/modules/app-messages.js +5 -0
  14. package/lib/public/modules/app-notifications.js +5 -1
  15. package/lib/public/modules/app-projects.js +10 -5
  16. package/lib/public/modules/command-palette.js +16 -5
  17. package/lib/public/modules/custom-icons-settings.js +399 -0
  18. package/lib/public/modules/custom-icons.js +114 -0
  19. package/lib/public/modules/diagnostics.js +10 -0
  20. package/lib/public/modules/emoji-picker.js +253 -6
  21. package/lib/public/modules/popover-position.js +192 -0
  22. package/lib/public/modules/project-icon.js +113 -0
  23. package/lib/public/modules/project-settings.js +2 -2
  24. package/lib/public/modules/project-switcher.js +2 -1
  25. package/lib/public/modules/scheduler-config.js +5 -8
  26. package/lib/public/modules/scheduler.js +5 -6
  27. package/lib/public/modules/server-settings.js +6 -0
  28. package/lib/public/modules/sidebar-mobile.js +4 -6
  29. package/lib/public/modules/sidebar-projects.js +35 -90
  30. package/lib/public/modules/sidebar-sessions.js +6 -20
  31. package/lib/public/modules/sticky-notes.js +4 -4
  32. package/lib/public/modules/terminal.js +5 -12
  33. package/lib/server-settings.js +221 -1
  34. package/lib/server.js +2 -0
  35. package/lib/sessions.js +16 -9
  36. package/lib/ws-schema.js +2 -0
  37. package/package.json +2 -1
@@ -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
  }
@@ -7,6 +7,8 @@ import { openProjectSettings } from './project-settings.js';
7
7
  import { triggerShare } from './qrcode.js';
8
8
  import { parseEmojis } from './markdown.js';
9
9
  import { buildEmojiPicker } from './emoji-picker.js';
10
+ import { renderProjectIcon, projectIconHtml } from './project-icon.js';
11
+ import { positionPopover } from './popover-position.js';
10
12
  import { store } from './store.js';
11
13
  import { getWs } from './ws-ref.js';
12
14
  import { closeSidebar } from './sidebar.js';
@@ -190,18 +192,8 @@ function showProjectAccessPopover(anchorEl, slug) {
190
192
  projectAccessPopover = popover;
191
193
 
192
194
  requestAnimationFrame(function () {
193
- var rect = anchorEl.getBoundingClientRect();
194
- popover.style.position = "fixed";
195
- popover.style.left = (rect.right + 8) + "px";
196
- popover.style.top = rect.top + "px";
195
+ positionPopover(popover, anchorEl, { placement: "right", gap: 8 });
197
196
  popover.style.zIndex = "9999";
198
- var popRect = popover.getBoundingClientRect();
199
- if (popRect.right > window.innerWidth - 8) {
200
- popover.style.left = (rect.left - popRect.width - 8) + "px";
201
- }
202
- if (popRect.bottom > window.innerHeight - 8) {
203
- popover.style.top = (window.innerHeight - popRect.height - 8) + "px";
204
- }
205
197
  });
206
198
 
207
199
  setTimeout(function () {
@@ -380,17 +372,7 @@ function showIconCtxMenu(anchorEl, slug, name) {
380
372
  refreshIcons();
381
373
 
382
374
  requestAnimationFrame(function () {
383
- var rect = anchorEl.getBoundingClientRect();
384
- menu.style.position = "fixed";
385
- menu.style.left = (rect.right + 6) + "px";
386
- menu.style.top = rect.top + "px";
387
- var menuRect = menu.getBoundingClientRect();
388
- if (menuRect.right > window.innerWidth - 8) {
389
- menu.style.left = (rect.left - menuRect.width - 6) + "px";
390
- }
391
- if (menuRect.bottom > window.innerHeight - 8) {
392
- menu.style.top = (window.innerHeight - menuRect.height - 8) + "px";
393
- }
375
+ positionPopover(menu, anchorEl, { placement: "right" });
394
376
  });
395
377
  }
396
378
 
@@ -599,27 +581,24 @@ function showProjectCtxMenu(anchorEl, slug, name, icon, position) {
599
581
  refreshIcons();
600
582
 
601
583
  requestAnimationFrame(function () {
602
- var rect = anchorEl.getBoundingClientRect();
603
- menu.style.position = "fixed";
604
- if (position === "below") {
605
- menu.style.left = rect.left + "px";
606
- menu.style.top = (rect.bottom + 4) + "px";
607
- } else {
608
- menu.style.left = (rect.right + 6) + "px";
609
- menu.style.top = rect.top + "px";
610
- }
611
- var menuRect = menu.getBoundingClientRect();
612
- if (menuRect.right > window.innerWidth - 8) {
613
- menu.style.left = (rect.left - menuRect.width - 6) + "px";
614
- }
615
- if (menuRect.bottom > window.innerHeight - 8) {
616
- menu.style.top = (window.innerHeight - menuRect.height - 8) + "px";
617
- }
584
+ // "below" kept its original 4px gap; "right" keeps the shared default (6px).
585
+ positionPopover(menu, anchorEl, position === "below" ? { placement: "below", gap: 4 } : { placement: "right" });
618
586
  });
619
587
  }
620
588
 
621
589
  // --- Emoji picker ---
622
590
 
591
+ // Position an emoji-picker popover relative to an anchor element, keeping it
592
+ // fully on-screen. Delegates to the shared viewport-clamp util (lr-a10a,
593
+ // generalized from the original lr-149e fix here): desktop is
594
+ // anchor-relative (right of the anchor, flipped left + four-edge clamped);
595
+ // mobile centers the picker in the viewport and clamps both axes — this is
596
+ // what icon-strip.css's mobile block expects (it no longer sets left/right
597
+ // itself, so there is nothing for these inline styles to fight).
598
+ function positionEmojiPicker(picker, anchorEl) {
599
+ positionPopover(picker, anchorEl, { placement: "right" });
600
+ }
601
+
623
602
  function closeEmojiPicker() {
624
603
  if (emojiPickerEl) {
625
604
  emojiPickerEl.remove();
@@ -649,16 +628,7 @@ function showEmojiPicker(slug, anchorEl) {
649
628
  emojiPickerEl = picker;
650
629
 
651
630
  requestAnimationFrame(function () {
652
- var rect = anchorEl.getBoundingClientRect();
653
- picker.style.left = (rect.right + 6) + "px";
654
- picker.style.top = rect.top + "px";
655
- var pRect = picker.getBoundingClientRect();
656
- if (pRect.right > window.innerWidth - 8) {
657
- picker.style.left = (rect.left - pRect.width - 6) + "px";
658
- }
659
- if (pRect.bottom > window.innerHeight - 8) {
660
- picker.style.top = (window.innerHeight - pRect.height - 8) + "px";
661
- }
631
+ positionEmojiPicker(picker, anchorEl);
662
632
  });
663
633
  }
664
634
 
@@ -685,16 +655,7 @@ function showFolderEmojiPicker(folderName, anchorEl) {
685
655
  emojiPickerEl = picker;
686
656
 
687
657
  requestAnimationFrame(function () {
688
- var rect = anchorEl.getBoundingClientRect();
689
- picker.style.left = (rect.right + 6) + "px";
690
- picker.style.top = rect.top + "px";
691
- var pRect = picker.getBoundingClientRect();
692
- if (pRect.right > window.innerWidth - 8) {
693
- picker.style.left = (rect.left - pRect.width - 6) + "px";
694
- }
695
- if (pRect.bottom > window.innerHeight - 8) {
696
- picker.style.top = (window.innerHeight - pRect.height - 8) + "px";
697
- }
658
+ positionEmojiPicker(picker, anchorEl);
698
659
  });
699
660
  }
700
661
 
@@ -753,17 +714,7 @@ function showFolderCtxMenu(anchorEl, folderName) {
753
714
  refreshIcons();
754
715
 
755
716
  requestAnimationFrame(function () {
756
- var rect = anchorEl.getBoundingClientRect();
757
- menu.style.position = "fixed";
758
- menu.style.left = (rect.right + 6) + "px";
759
- menu.style.top = rect.top + "px";
760
- var menuRect = menu.getBoundingClientRect();
761
- if (menuRect.right > window.innerWidth - 8) {
762
- menu.style.left = (rect.left - menuRect.width - 6) + "px";
763
- }
764
- if (menuRect.bottom > window.innerHeight - 8) {
765
- menu.style.top = (window.innerHeight - menuRect.height - 8) + "px";
766
- }
717
+ positionPopover(menu, anchorEl, { placement: "right" });
767
718
  });
768
719
  }
769
720
 
@@ -778,7 +729,11 @@ function showMoveFolderMenu(anchorEl, slug, folders, position) {
778
729
  var item = document.createElement("button");
779
730
  item.className = "project-ctx-item";
780
731
  var fmeta2 = cachedFolderMeta[fn] || {};
781
- var ficon = fmeta2.icon ? ('<span style="margin-right:4px">' + fmeta2.icon + '</span>') : (iconHtml("folder") + " ");
732
+ // LOCKED SCOPE (Andy, lr-a6da): folder icons support custom :slug: images
733
+ // at parity with project icons. projectIconHtml() routes custom icons to
734
+ // a safe <img> tag and emoji to escaped text; the prior raw fmeta2.icon
735
+ // interpolation showed ':slug:' as literal text.
736
+ var ficon = fmeta2.icon ? ('<span style="margin-right:4px">' + projectIconHtml(fmeta2.icon) + '</span>') : (iconHtml("folder") + " ");
782
737
  item.innerHTML = ficon + "<span>" + escapeHtml(fn) + "</span>";
783
738
  item.addEventListener("click", function (e) {
784
739
  e.stopPropagation();
@@ -797,18 +752,8 @@ function showMoveFolderMenu(anchorEl, slug, folders, position) {
797
752
  refreshIcons();
798
753
 
799
754
  requestAnimationFrame(function () {
800
- var rect = anchorEl.getBoundingClientRect();
801
- menu.style.position = "fixed";
802
- if (position === "below") {
803
- menu.style.left = rect.left + "px";
804
- menu.style.top = (rect.bottom + 4) + "px";
805
- } else {
806
- menu.style.left = (rect.right + 6) + "px";
807
- menu.style.top = rect.top + "px";
808
- }
809
- var menuRect = menu.getBoundingClientRect();
810
- if (menuRect.right > window.innerWidth - 8) menu.style.left = (rect.left - menuRect.width - 6) + "px";
811
- if (menuRect.bottom > window.innerHeight - 8) menu.style.top = (window.innerHeight - menuRect.height - 8) + "px";
755
+ // "below" kept its original 4px gap; "right" keeps the shared default (6px).
756
+ positionPopover(menu, anchorEl, position === "below" ? { placement: "below", gap: 4 } : { placement: "right" });
812
757
  });
813
758
  }
814
759
 
@@ -1353,8 +1298,7 @@ function createIconItem(p, currentSlug) {
1353
1298
  if (p.icon) {
1354
1299
  var emojiSpan = document.createElement("span");
1355
1300
  emojiSpan.className = "project-emoji";
1356
- emojiSpan.textContent = p.icon;
1357
- parseEmojis(emojiSpan);
1301
+ renderProjectIcon(p.icon, emojiSpan, parseEmojis);
1358
1302
  el.appendChild(emojiSpan);
1359
1303
  } else {
1360
1304
  el.appendChild(document.createTextNode(getProjectAbbrev(p.name)));
@@ -1635,10 +1579,13 @@ function renderUserFolder(unit, wtByParent, currentSlug, currentDmUserId) {
1635
1579
  var iconBox = document.createElement("span");
1636
1580
  iconBox.className = "icon-strip-folder-icon-box";
1637
1581
  if (fmeta.icon) {
1638
- // Emoji fills the box — render as plain text, no parseEmojis needed
1582
+ // LOCKED SCOPE (Andy, lr-a6da): folder icons support custom :slug: images
1583
+ // at parity with project icons. renderProjectIcon() routes custom icons to
1584
+ // <img> and emoji to text; the prior plain textContent assignment showed
1585
+ // ':slug:' as literal text.
1639
1586
  var emojiSpan = document.createElement("span");
1640
1587
  emojiSpan.className = "icon-strip-folder-emoji-main";
1641
- emojiSpan.textContent = fmeta.icon;
1588
+ renderProjectIcon(fmeta.icon, emojiSpan, parseEmojis);
1642
1589
  iconBox.appendChild(emojiSpan);
1643
1590
  } else {
1644
1591
  // Fallback: folder SVG icon
@@ -1861,8 +1808,7 @@ function renderWorktreeGroup(p, worktrees, currentSlug, currentDmUserId) {
1861
1808
  if (wt.icon) {
1862
1809
  var wtEmoji = document.createElement("span");
1863
1810
  wtEmoji.className = "wt-branch-abbrev project-emoji";
1864
- wtEmoji.textContent = wt.icon;
1865
- parseEmojis(wtEmoji);
1811
+ renderProjectIcon(wt.icon, wtEmoji, parseEmojis);
1866
1812
  wtEl.appendChild(wtEmoji);
1867
1813
  } else {
1868
1814
  var abbrev = document.createElement("span");
@@ -1998,8 +1944,7 @@ function createMobileProjectItem(p, currentSlug, isWorktree) {
1998
1944
  var abbrev = document.createElement("span");
1999
1945
  abbrev.className = "mobile-project-abbrev";
2000
1946
  if (p.icon) {
2001
- abbrev.textContent = p.icon;
2002
- parseEmojis(abbrev);
1947
+ renderProjectIcon(p.icon, abbrev, parseEmojis);
2003
1948
  } else {
2004
1949
  abbrev.textContent = getProjectAbbrev(p.name);
2005
1950
  }
@@ -14,6 +14,7 @@ import { getUpcomingSchedules } from './scheduler.js';
14
14
  import { refreshMobileChatSheet } from './sidebar-mobile.js';
15
15
  import { openAgentPicker, openAgentPickerForPreferred } from './agent-picker.js';
16
16
  import { getCachedProjects } from './app-projects.js';
17
+ import { positionPopover } from './popover-position.js';
17
18
 
18
19
 
19
20
  // --- Session state ---
@@ -682,18 +683,11 @@ function showSessionCtxMenu(anchorBtn, sessionId, title, cliSid, sessionData) {
682
683
  sessionCtxMenu = menu;
683
684
  refreshIcons();
684
685
 
685
- // Position: fixed relative to the anchor button
686
+ // Position: fixed relative to the anchor button, right-edge aligned,
687
+ // flip-then-clamp on all four edges (lr-a10a: the prior bottom-flip-only
688
+ // logic could leave the flipped menu with top < 0 on a short viewport).
686
689
  requestAnimationFrame(function () {
687
- var btnRect = anchorBtn.getBoundingClientRect();
688
- menu.style.position = "fixed";
689
- menu.style.top = (btnRect.bottom + 2) + "px";
690
- menu.style.right = (window.innerWidth - btnRect.right) + "px";
691
- menu.style.left = "auto";
692
- // If menu overflows below viewport, flip up
693
- var menuRect = menu.getBoundingClientRect();
694
- if (menuRect.bottom > window.innerHeight - 8) {
695
- menu.style.top = (btnRect.top - menuRect.height - 2) + "px";
696
- }
690
+ positionPopover(menu, anchorBtn, { placement: "below-right-aligned", gap: 2 });
697
691
  });
698
692
  }
699
693
 
@@ -737,15 +731,7 @@ function showLoopCtxMenu(anchorBtn, loopId, loopName, childCount) {
737
731
  refreshIcons();
738
732
 
739
733
  requestAnimationFrame(function () {
740
- var btnRect = anchorBtn.getBoundingClientRect();
741
- menu.style.position = "fixed";
742
- menu.style.top = (btnRect.bottom + 2) + "px";
743
- menu.style.right = (window.innerWidth - btnRect.right) + "px";
744
- menu.style.left = "auto";
745
- var menuRect = menu.getBoundingClientRect();
746
- if (menuRect.bottom > window.innerHeight - 8) {
747
- menu.style.top = (btnRect.top - menuRect.height - 2) + "px";
748
- }
734
+ positionPopover(menu, anchorBtn, { placement: "below-right-aligned", gap: 2 });
749
735
  });
750
736
  }
751
737
 
@@ -1,5 +1,6 @@
1
1
  import { refreshIcons, iconHtml } from './icons.js';
2
2
  import { pushOverlayState, popOverlayState } from './overlay-history.js';
3
+ import { positionPopover } from './popover-position.js';
3
4
 
4
5
  var ctx;
5
6
  var notes = new Map(); // id -> { data, el }
@@ -835,10 +836,9 @@ function showColorPicker(anchor, noteEl, noteId) {
835
836
  document.body.appendChild(picker);
836
837
  colorPickerEl = picker;
837
838
 
838
- // Position relative to anchor
839
- var rect = anchor.getBoundingClientRect();
840
- picker.style.left = rect.left + "px";
841
- picker.style.top = (rect.bottom + 4) + "px";
839
+ // Position relative to anchor, clamped to the viewport on all four edges
840
+ // (lr-a10a: this popover previously had no clamp at all).
841
+ positionPopover(picker, anchor, { placement: "below", gap: 4 });
842
842
 
843
843
  // Close on outside click
844
844
  setTimeout(function () {
@@ -3,6 +3,7 @@ import { closeSidebar } from './sidebar.js';
3
3
  import { closeFileViewer } from './filebrowser.js';
4
4
  import { copyToClipboard } from './utils.js';
5
5
  import { getTerminalTheme } from './theme.js';
6
+ import { positionAtPoint } from './popover-position.js';
6
7
 
7
8
  var ctx;
8
9
  var tabs = new Map(); // termId -> { id, title, exited, xterm, fitAddon, bodyEl }
@@ -877,19 +878,11 @@ function showTermCtxMenu(e, tab) {
877
878
  });
878
879
  menu.appendChild(clearItem);
879
880
 
880
- // Position at mouse cursor
881
- menu.style.left = e.clientX + "px";
882
- menu.style.top = e.clientY + "px";
881
+ // Position at mouse cursor, clamped to viewport on all four edges
882
+ // (lr-a10a: mobile's synthetic contextmenu can fire from a low/edge
883
+ // touch point, so a right/bottom-only clamp isn't enough).
883
884
  document.body.appendChild(menu);
884
-
885
- // Clamp to viewport
886
- var rect = menu.getBoundingClientRect();
887
- if (rect.right > window.innerWidth) {
888
- menu.style.left = (window.innerWidth - rect.width - 4) + "px";
889
- }
890
- if (rect.bottom > window.innerHeight) {
891
- menu.style.top = (window.innerHeight - rect.height - 4) + "px";
892
- }
885
+ positionAtPoint(menu, { x: e.clientX, y: e.clientY });
893
886
 
894
887
  termCtxMenu = menu;
895
888
  refreshIcons();