@clagentic/console 1.7.1-beta.1 → 1.8.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 (39) hide show
  1. package/bin/cli.js +198 -2542
  2. package/lib/build-sha.json +2 -2
  3. package/lib/cli/daemon-launch.js +797 -0
  4. package/lib/cli/ipc-subcommands.js +186 -0
  5. package/lib/cli/menus.js +849 -0
  6. package/lib/cli/net-detect.js +209 -0
  7. package/lib/cli/tui.js +589 -0
  8. package/lib/pages.js +13 -17
  9. package/lib/public/css/diagnostics.css +15 -0
  10. package/lib/public/css/overlays.css +19 -0
  11. package/lib/public/index.html +12 -11
  12. package/lib/public/manifest.json +1 -1
  13. package/lib/public/modules/app-connection.js +150 -4
  14. package/lib/public/modules/app-history-replay.js +155 -0
  15. package/lib/public/modules/app-home-hub.js +2 -16
  16. package/lib/public/modules/app-messages.js +1245 -1489
  17. package/lib/public/modules/app-notifications.js +4 -4
  18. package/lib/public/modules/command-palette.js +11 -22
  19. package/lib/public/modules/context-sources.js +1 -6
  20. package/lib/public/modules/filebrowser.js +25 -13
  21. package/lib/public/modules/mcp-ui.js +2 -2
  22. package/lib/public/modules/notifications.js +22 -1
  23. package/lib/public/modules/playbook.js +6 -6
  24. package/lib/public/modules/project-settings.js +5 -13
  25. package/lib/public/modules/qrcode.js +2 -2
  26. package/lib/public/modules/relative-time.js +27 -0
  27. package/lib/public/modules/scheduler-history.js +1 -5
  28. package/lib/public/modules/server-settings.js +28 -15
  29. package/lib/public/modules/sidebar-projects.js +1 -1
  30. package/lib/public/modules/sidebar-sessions.js +1 -15
  31. package/lib/public/modules/sidebar.js +3 -3
  32. package/lib/public/modules/utils.js +1 -0
  33. package/lib/public/sw.js +24 -4
  34. package/lib/server-auth.js +48 -2
  35. package/lib/server-settings.js +70 -4
  36. package/lib/server.js +200 -4
  37. package/lib/smtp.js +6 -6
  38. package/lib/yoke/adapters/codex.js +1 -1
  39. package/package.json +1 -1
@@ -100,14 +100,14 @@ function showBanner(notif, autoDismissMs) {
100
100
  var iconHtmlStr = userMentionAvatarSrc
101
101
  ? '<img class="notif-banner-avatar" src="' + escapeHtml(userMentionAvatarSrc) + '" alt="' + escapeHtml((notif.meta && notif.meta.fromName) || "User") + '">'
102
102
  : isAuthRequired
103
- ? '<img src="/icon-banded-76.png" width="32" height="32" alt="Clagentic:Console" style="border-radius:8px">'
103
+ ? '<img src="/icon-banded-76.png" width="32" height="32" alt="Clagentic: Console" style="border-radius:8px">'
104
104
  : projectIcon
105
105
  // projectIconHtml() routes custom (:slug:) icons to a safe <img> tag and
106
106
  // emoji to escaped text — the raw `projectIcon` interpolation previously
107
107
  // showed ':slug:' as literal text (lr-a6da).
108
108
  ? '<span class="notif-banner-emoji">' + projectIconHtml(projectIcon) + '</span>'
109
109
  : isEmpty
110
- ? '<img src="/icon-banded-76.png" width="32" height="32" alt="Clagentic:Console" style="border-radius:8px">'
110
+ ? '<img src="/icon-banded-76.png" width="32" height="32" alt="Clagentic: Console" style="border-radius:8px">'
111
111
  : iconHtml("folder");
112
112
 
113
113
  // Format permission title as "Can I ..." style
@@ -262,7 +262,7 @@ function showLoginReminderBanner() {
262
262
  '<div class="notif-banner-body">' +
263
263
  '<div class="notif-banner-project">CONSOLE</div>' +
264
264
  '<div class="notif-banner-title">Login started</div>' +
265
- '<div class="notif-banner-text">After the login completes, open a new session so Clagentic:Console picks up the fresh auth state.</div>' +
265
+ '<div class="notif-banner-text">After the login completes, open a new session so Clagentic: Console picks up the fresh auth state.</div>' +
266
266
  '<div class="notif-banner-actions">' +
267
267
  '<button class="notif-banner-new-session notif-banner-update-now">Open new session</button>' +
268
268
  '</div>' +
@@ -554,7 +554,7 @@ export function showUpdateBanner(msg) {
554
554
  }
555
555
 
556
556
  banner.innerHTML =
557
- '<div class="notif-banner-icon"><img src="/icon-banded-76.png" width="32" height="32" alt="Clagentic:Console" style="border-radius:8px"></div>' +
557
+ '<div class="notif-banner-icon"><img src="/icon-banded-76.png" width="32" height="32" alt="Clagentic: Console" style="border-radius:8px"></div>' +
558
558
  '<div class="notif-banner-body">' +
559
559
  '<div class="notif-banner-project">CLAGENTIC</div>' +
560
560
  '<div class="notif-banner-title">v' + escapeHtml(msg.version) + ' is available</div>' +
@@ -1,29 +1,10 @@
1
1
  import { userAvatarUrl } from './avatar.js';
2
- import { escapeHtml } from './utils.js';
2
+ import { escapeHtml, relativeTime } from './utils.js';
3
3
  import { refreshIcons } from './icons.js';
4
4
  import { openSearch as openSessionSearch } from './session-search.js';
5
5
  import { pushOverlayState, popOverlayState } from './overlay-history.js';
6
6
  import { projectIconHtml } from './project-icon.js';
7
7
 
8
- function formatRelativeDate(ts) {
9
- if (!ts) return "";
10
- var now = Date.now();
11
- var diff = now - ts;
12
- if (diff < 0) diff = 0;
13
- var sec = Math.floor(diff / 1000);
14
- if (sec < 60) return "just now";
15
- var min = Math.floor(sec / 60);
16
- if (min < 60) return min + "m ago";
17
- var hr = Math.floor(min / 60);
18
- if (hr < 24) return hr + "h ago";
19
- var days = Math.floor(hr / 24);
20
- if (days < 7) return days + "d ago";
21
- if (days < 30) return Math.floor(days / 7) + "w ago";
22
- var d = new Date(ts);
23
- var months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
24
- return months[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
25
- }
26
-
27
8
  var ctx;
28
9
  var paletteEl = null;
29
10
  var inputEl = null;
@@ -109,6 +90,14 @@ export function setPaletteVersion(version) {
109
90
  cachedVersion = version;
110
91
  }
111
92
 
93
+ // Read-only accessor for the version this client's WS connection last
94
+ // reported as running (set from the "info" handshake message). Used by the
95
+ // stale-bundle watchdog in app-connection.js to detect a version mismatch
96
+ // against the server's currently served build (lr-e0ec47).
97
+ export function getPaletteVersion() {
98
+ return cachedVersion;
99
+ }
100
+
112
101
  export function handlePaletteSessionSwitch() {
113
102
  if (!pendingNav) return;
114
103
  var nav = pendingNav;
@@ -198,7 +187,7 @@ function updateFooter() {
198
187
  '<span><kbd>Enter</kbd> select</span>';
199
188
  var versionText = cachedVersion ? "v" + cachedVersion : "";
200
189
  footerEl.innerHTML =
201
- '<a href="https://github.com/clagentic/clagentic-console" target="_blank" rel="noopener" class="cmd-palette-brand"><img src="favicon-banded.png" width="13" height="13" alt="">Clagentic:Console ' + versionText + '</a>' +
190
+ '<a href="https://github.com/clagentic/clagentic-console" target="_blank" rel="noopener" class="cmd-palette-brand"><img src="favicon-banded.png" width="13" height="13" alt="">Clagentic: Console ' + versionText + '</a>' +
202
191
  '<span class="cmd-palette-footer-shortcuts">' + shortcuts + '</span>';
203
192
  }
204
193
 
@@ -415,7 +404,7 @@ function appendHomeSearchResults(results, query) {
415
404
  // ==========================================
416
405
 
417
406
  function renderItem(index, iconContent, title, desc, snippet, timestamp) {
418
- var dateStr = formatRelativeDate(timestamp);
407
+ var dateStr = relativeTime(timestamp);
419
408
  return '<div class="cmd-palette-item" data-index="' + index + '">' +
420
409
  '<div class="cmd-palette-item-icon">' + iconContent + '</div>' +
421
410
  '<div class="cmd-palette-item-body">' +
@@ -1,6 +1,7 @@
1
1
  // Context Sources — attach terminal output and browser tabs as context for Claude
2
2
 
3
3
  import { refreshIcons } from './icons.js';
4
+ import { escapeHtml } from './utils.js';
4
5
 
5
6
  var ctx = null;
6
7
  var activeSourceIds = new Set();
@@ -357,9 +358,3 @@ export function getActiveSources() {
357
358
  export function hasActiveSources() {
358
359
  return activeSourceIds.size > 0;
359
360
  }
360
-
361
- function escapeHtml(str) {
362
- var div = document.createElement("div");
363
- div.textContent = str;
364
- return div.innerHTML;
365
- }
@@ -1,5 +1,5 @@
1
1
  import { iconHtml, refreshIcons } from './icons.js';
2
- import { escapeHtml, copyToClipboard } from './utils.js';
2
+ import { escapeHtml, copyToClipboard, relativeTime } from './utils.js';
3
3
  import { renderMarkdown, highlightCodeBlocks, renderMermaidBlocks, exportMarkdownAsPdf } from './markdown.js';
4
4
  import { closeSidebar } from './sidebar.js';
5
5
  import { closeTerminal } from './terminal.js';
@@ -11,6 +11,7 @@ import {
11
11
  peekPendingNavigate,
12
12
  getPendingNavigate,
13
13
  } from './pending-navigate.js';
14
+ import { registerHandlers } from './app-messages.js';
14
15
 
15
16
  var ctx;
16
17
  var showDropHint = function () {};
@@ -1457,7 +1458,7 @@ function renderHistoryPanel() {
1457
1458
  if (item.source === "git") {
1458
1459
  var sub = document.createElement("div");
1459
1460
  sub.className = "file-history-meta";
1460
- sub.textContent = item.hash.substring(0, 7) + " by " + (item.author || "unknown") + formatTimeAgo(item.timestamp);
1461
+ sub.textContent = item.hash.substring(0, 7) + " by " + (item.author || "unknown") + (item.timestamp ? ", " + relativeTime(item.timestamp) : "");
1461
1462
  entry.appendChild(sub);
1462
1463
  } else {
1463
1464
  var sessionMeta = document.createElement("div");
@@ -1770,17 +1771,6 @@ function shortEntryLabel(entry) {
1770
1771
  return (entry.assistantSnippet || entry.toolName || "Edit").substring(0, 30);
1771
1772
  }
1772
1773
 
1773
- function formatTimeAgo(ts) {
1774
- if (!ts) return "";
1775
- var diff = Date.now() - ts;
1776
- if (diff < 60000) return ", just now";
1777
- if (diff < 3600000) return ", " + Math.floor(diff / 60000) + "m ago";
1778
- if (diff < 86400000) return ", " + Math.floor(diff / 3600000) + "h ago";
1779
- var d = new Date(ts);
1780
- return ", " + d.toLocaleDateString();
1781
- }
1782
-
1783
-
1784
1774
  function viewEntryFile(entry) {
1785
1775
  var viewerEl = ctx.fileViewerEl;
1786
1776
  var bodyEl = document.getElementById("file-viewer-body");
@@ -1991,3 +1981,25 @@ function scrollToToolElement(toolId, assistantUuid) {
1991
1981
 
1992
1982
  // peekPendingNavigate and getPendingNavigate are imported from
1993
1983
  // ./pending-navigate.js and re-exported from the import statement at the top.
1984
+
1985
+ // --- WS message registry (lr-4e49 Part 2) ---
1986
+ // Registers this module's own result/event handlers directly with the
1987
+ // app-messages.js registry instead of app-messages.js importing and
1988
+ // switch-casing them itself. Runs once at module load — app.js imports
1989
+ // every domain module (including this one) before connect() opens the
1990
+ // WebSocket, so registration always completes before any message can
1991
+ // arrive (see lib/public/app.js).
1992
+ // fs_read_result is NOT registered here even though handleFsRead lives in
1993
+ // this module: the wire message is shared with the CLAUDE.md instructions
1994
+ // editor in project-settings.js (msg.path === "CLAUDE.md" &&
1995
+ // isProjectSettingsOpen() routes there instead). That routing decision
1996
+ // needs both modules and stays a core case in app-messages.js.
1997
+ registerHandlers({
1998
+ fs_list_result: handleFsList,
1999
+ fs_search_result: handleFsSearch,
2000
+ fs_file_changed: handleFileChanged,
2001
+ fs_dir_changed: handleDirChanged,
2002
+ fs_file_history_result: handleFileHistory,
2003
+ fs_git_diff_result: handleGitDiff,
2004
+ fs_file_at_result: handleFileAt,
2005
+ });
@@ -155,7 +155,7 @@ function renderMcpServerList() {
155
155
  title: "Install Chrome Extension",
156
156
  desc: step1Done
157
157
  ? "Connected"
158
- : "Required to bridge your browser with Clagentic:Console.",
158
+ : "Required to bridge your browser with Clagentic: Console.",
159
159
  action: step1Done ? null : {
160
160
  label: "Setup Extension",
161
161
  icon: "puzzle",
@@ -191,7 +191,7 @@ function renderMcpServerList() {
191
191
  if (step3Done) {
192
192
  step3Desc = available.length + " server" + (available.length === 1 ? "" : "s") + " enabled";
193
193
  } else if (step2Done) {
194
- step3Desc = "Add servers from the Clagentic:Console Chrome Extension popup using the + button, or import an existing config file.";
194
+ step3Desc = "Add servers from the Clagentic: Console Chrome Extension popup using the + button, or import an existing config file.";
195
195
  } else {
196
196
  step3Desc = "Configure after installing the bridge.";
197
197
  }
@@ -503,7 +503,7 @@ export function initNotifications(_ctx) {
503
503
  localStorage.setItem("onboarding-dismissed", "1");
504
504
  // Show a welcome notification so the user knows it works
505
505
  navigator.serviceWorker.ready.then(function (reg) {
506
- reg.showNotification("\ud83c\udf89 Welcome to Clagentic:Console!", {
506
+ reg.showNotification("\ud83c\udf89 Welcome to Clagentic: Console!", {
507
507
  body: "\ud83d\udd14 You\u2019ll be notified when Claude responds.",
508
508
  tag: "claude-welcome",
509
509
  });
@@ -553,6 +553,27 @@ export function initNotifications(_ctx) {
553
553
  }
554
554
 
555
555
  navigator.serviceWorker.register("/sw.js")
556
+ .then(function (reg) {
557
+ // sw.js is served no-cache (server.js serveStatic), so reg.update()
558
+ // always re-fetches it from the network and picks up a post-deploy
559
+ // change. Without an explicit update() call the browser only
560
+ // re-checks sw.js on its own heuristic schedule (typically once per
561
+ // navigation, ~24h max) — a foregrounded mobile PWA that never
562
+ // navigates can hold a pre-deploy SW+cache indefinitely (lr-e0ec47).
563
+ reg.update().catch(function () {});
564
+
565
+ // Re-check for a newer sw.js whenever the PWA is foregrounded, so a
566
+ // backgrounded-then-resumed mobile client re-validates promptly
567
+ // instead of waiting for the browser's own update heuristic.
568
+ document.addEventListener("visibilitychange", function () {
569
+ if (document.visibilityState === "visible") reg.update().catch(function () {});
570
+ });
571
+ window.addEventListener("pageshow", function () {
572
+ reg.update().catch(function () {});
573
+ });
574
+
575
+ return reg;
576
+ })
556
577
  .then(function () { return navigator.serviceWorker.ready; })
557
578
  .then(function (reg) {
558
579
  // Fetch current VAPID key to detect key changes
@@ -287,7 +287,7 @@ function registerBuiltinPlaybooks() {
287
287
  {
288
288
  id: "intro",
289
289
  title: "Never miss a response",
290
- body: "When Claude is working on a long task, you can walk away and get a push notification the moment it's done. Works even when Clagentic:Console is in the background.",
290
+ body: "When Claude is working on a long task, you can walk away and get a push notification the moment it's done. Works even when Clagentic: Console is in the background.",
291
291
  actions: [
292
292
  { label: "Enable notifications", action: "notif_request", next: "check_perm" },
293
293
  { label: "Not now", next: "" },
@@ -382,9 +382,9 @@ function registerBuiltinPlaybooks() {
382
382
  if (isInsecure) {
383
383
  return "⚠️ <strong>Insecure context detected.</strong><br><br>" +
384
384
  "Notifications require a <strong>secure context</strong> (HTTPS or localhost). " +
385
- "You're accessing Clagentic:Console over <strong>" + location.protocol + "//" + location.hostname + "</strong>, so the browser automatically blocks notifications.<br><br>" +
385
+ "You're accessing Clagentic: Console over <strong>" + location.protocol + "//" + location.hostname + "</strong>, so the browser automatically blocks notifications.<br><br>" +
386
386
  "<strong>How to fix:</strong><br>" +
387
- "<strong>1.</strong> Access Clagentic:Console via <strong>https://</strong> (set up a TLS certificate)<br>" +
387
+ "<strong>1.</strong> Access Clagentic: Console via <strong>https://</strong> (set up a TLS certificate)<br>" +
388
388
  "<strong>2.</strong> Or access via <strong>localhost:" + location.port + "</strong> instead of an IP address<br>";
389
389
  }
390
390
 
@@ -418,7 +418,7 @@ function registerBuiltinPlaybooks() {
418
418
  {
419
419
  id: "done",
420
420
  title: "All set! 🎉",
421
- body: "You'll now get a notification whenever Claude finishes processing. This works even when Clagentic:Console is minimized or in another tab.",
421
+ body: "You'll now get a notification whenever Claude finishes processing. This works even when Clagentic: Console is minimized or in another tab.",
422
422
  note: "You can toggle notifications anytime from the header bar.",
423
423
  actions: [
424
424
  { label: "Done", next: "" },
@@ -515,7 +515,7 @@ function registerBuiltinPlaybooks() {
515
515
  {
516
516
  id: "intro",
517
517
  title: "Getting certificate warnings?",
518
- body: "Clagentic:Console generates a local CA certificate for secure HTTPS connections. " +
518
+ body: "Clagentic: Console generates a local CA certificate for secure HTTPS connections. " +
519
519
  "Your browser may show warnings until you install and trust this certificate on your device.",
520
520
  actions: [
521
521
  { label: "Download certificate", action: "cert_download", next: "install" },
@@ -556,7 +556,7 @@ function registerBuiltinPlaybooks() {
556
556
 
557
557
  function fireTestNotification(cb) {
558
558
  try {
559
- var n = new Notification("Clagentic:Console", {
559
+ var n = new Notification("Clagentic: Console", {
560
560
  body: "Notifications are working! 🎉",
561
561
  tag: "clagentic-test-" + Date.now(),
562
562
  });
@@ -1,7 +1,7 @@
1
1
  // project-settings.js — Project settings panel (profile, defaults, instructions, env)
2
2
  import { refreshIcons } from './icons.js';
3
3
  import { buildEmojiPicker } from './emoji-picker.js';
4
- import { showToast } from './utils.js';
4
+ import { showToast, escapeHtml } from './utils.js';
5
5
  import { parseEmojis } from './markdown.js';
6
6
  import { renderProjectIcon } from './project-icon.js';
7
7
  import { pushOverlayState, popOverlayState } from './overlay-history.js';
@@ -344,16 +344,16 @@ function renderPsPaletteResults(query) {
344
344
  for (var j = 0; j < visible.length; j++) {
345
345
  var sec = visible[j];
346
346
  if (sec.group !== lastGroup) {
347
- html += '<div class="settings-palette-group-header">' + escapeHtmlPs(sec.group) + '</div>';
347
+ html += '<div class="settings-palette-group-header">' + escapeHtml(sec.group) + '</div>';
348
348
  lastGroup = sec.group;
349
349
  }
350
350
  var isCurrent = sec.section === currentPsSection;
351
351
  html += '<button class="settings-palette-item' +
352
352
  (isCurrent ? ' current' : '') +
353
353
  (j === psPaletteHighlight ? ' highlighted' : '') +
354
- '" data-section="' + escapeHtmlPs(sec.section) + '">' +
355
- '<span class="settings-palette-item-icon"><i data-lucide="' + escapeHtmlPs(sec.icon) + '"></i></span>' +
356
- '<span class="settings-palette-item-label">' + escapeHtmlPs(sec.label) + '</span>' +
354
+ '" data-section="' + escapeHtml(sec.section) + '">' +
355
+ '<span class="settings-palette-item-icon"><i data-lucide="' + escapeHtml(sec.icon) + '"></i></span>' +
356
+ '<span class="settings-palette-item-label">' + escapeHtml(sec.label) + '</span>' +
357
357
  (isCurrent ? '<span class="settings-palette-item-check"><i data-lucide="check"></i></span>' : '') +
358
358
  '</button>';
359
359
  }
@@ -405,14 +405,6 @@ function updatePsPaletteHighlight(items) {
405
405
  }
406
406
  }
407
407
 
408
- function escapeHtmlPs(str) {
409
- return String(str)
410
- .replace(/&/g, "&amp;")
411
- .replace(/</g, "&lt;")
412
- .replace(/>/g, "&gt;")
413
- .replace(/"/g, "&quot;");
414
- }
415
-
416
408
  // ===== Profile =====
417
409
  function populateProfile() {
418
410
  var nameEl = document.getElementById("ps-project-name");
@@ -15,7 +15,7 @@ export function triggerShare() {
15
15
  // Use Web Share API on mobile only
16
16
  var isMobile = window.innerWidth <= 768 || /Mobi|Android/i.test(navigator.userAgent);
17
17
  if (isMobile && navigator.share) {
18
- navigator.share({ title: document.title || "Clagentic:Console", url: url }).catch(function () {});
18
+ navigator.share({ title: document.title || "Clagentic: Console", url: url }).catch(function () {});
19
19
  return;
20
20
  }
21
21
 
@@ -74,7 +74,7 @@ export function initQrCode() {
74
74
  if (qrShareBtn) {
75
75
  qrShareBtn.addEventListener("click", function () {
76
76
  var url = getShareUrl();
77
- navigator.share({ title: document.title || "Clagentic:Console", url: url }).catch(function () {});
77
+ navigator.share({ title: document.title || "Clagentic: Console", url: url }).catch(function () {});
78
78
  });
79
79
  }
80
80
 
@@ -0,0 +1,27 @@
1
+ // Shared relative-time formatter — importable in both browser (ESM) and
2
+ // Node (for tests), same pattern as escape-html.js.
3
+ //
4
+ // Consolidates the four near-duplicate "Xm ago" / "Xh ago" formatters that
5
+ // existed across filebrowser.js, app-home-hub.js, command-palette.js, and
6
+ // sidebar-sessions.js (lr-2f75) into one implementation.
7
+ //
8
+ // Accepts either a Date-parseable value (ISO string) or an epoch-ms number,
9
+ // matching every prior caller's input shape.
10
+ export function relativeTime(ts) {
11
+ if (!ts) return "";
12
+ var t = typeof ts === "number" ? ts : new Date(ts).getTime();
13
+ var diff = Date.now() - t;
14
+ if (diff < 0) diff = 0;
15
+ var sec = Math.floor(diff / 1000);
16
+ if (sec < 60) return "just now";
17
+ var min = Math.floor(sec / 60);
18
+ if (min < 60) return min + "m ago";
19
+ var hr = Math.floor(min / 60);
20
+ if (hr < 24) return hr + "h ago";
21
+ var days = Math.floor(hr / 24);
22
+ if (days < 7) return days + "d ago";
23
+ if (days < 30) return Math.floor(days / 7) + "w ago";
24
+ var d = new Date(t);
25
+ var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
26
+ return months[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
27
+ }
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { renderMarkdown } from './markdown.js';
8
+ import { escapeHtml } from './utils.js';
8
9
 
9
10
  var histCtx = null;
10
11
 
@@ -112,11 +113,6 @@ function renderFileEdit(bodyEl, tab, content, recId) {
112
113
  }
113
114
  }
114
115
 
115
- function escapeHtml(str) {
116
- if (!str) return "";
117
- return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
118
- }
119
-
120
116
  export function handleScheduleRunStarted(msg) {
121
117
  if (histCtx.isPanelOpen()) histCtx.render();
122
118
  }
@@ -1,12 +1,14 @@
1
1
  // server-settings.js — Full-screen server settings overlay
2
2
  import { refreshIcons } from './icons.js';
3
- import { showToast, copyToClipboard } from './utils.js';
3
+ import { showToast, copyToClipboard, escapeHtml } from './utils.js';
4
4
  import { pushOverlayState, popOverlayState } from './overlay-history.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';
8
8
  import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar, renderBetaCard, isSonnetModel } from './settings-defaults.js';
9
9
  import { initCustomIconsSettings, initCustomIconsUpload, loadCustomIcons } from './custom-icons-settings.js';
10
+ import { formatBytes } from './app-panels.js';
11
+ import { registerHandlers } from './app-messages.js';
10
12
 
11
13
  var ctx = null;
12
14
  var settingsEl = null;
@@ -416,7 +418,7 @@ function renderPaletteResults(query) {
416
418
  }
417
419
  }
418
420
  if (filtered.length === 0) {
419
- resultsEl.innerHTML = '<div class="settings-palette-empty">No matches for "' + escapeHtmlPalette(query) + '"</div>';
421
+ resultsEl.innerHTML = '<div class="settings-palette-empty">No matches for "' + escapeHtml(query) + '"</div>';
420
422
  paletteHighlight = -1;
421
423
  return;
422
424
  }
@@ -432,7 +434,7 @@ function renderPaletteResults(query) {
432
434
  var itemIndex = 0;
433
435
  for (var gi = 0; gi < groupOrder.length; gi++) {
434
436
  var gName = groupOrder[gi];
435
- html += '<div class="settings-palette-group-header">' + escapeHtmlPalette(gName) + '</div>';
437
+ html += '<div class="settings-palette-group-header">' + escapeHtml(gName) + '</div>';
436
438
  var items = groups[gName];
437
439
  for (var ii = 0; ii < items.length; ii++) {
438
440
  var item = items[ii];
@@ -443,7 +445,7 @@ function renderPaletteResults(query) {
443
445
  if (itemIndex === paletteHighlight) cls += " highlighted";
444
446
  html += '<button class="' + cls + '" data-section="' + item.section + '" data-index="' + itemIndex + '">' +
445
447
  '<i data-lucide="' + item.icon + '" class="settings-palette-item-icon"></i>' +
446
- '<span class="settings-palette-item-label">' + escapeHtmlPalette(item.label) + '</span>' +
448
+ '<span class="settings-palette-item-label">' + escapeHtml(item.label) + '</span>' +
447
449
  (isCurrent ? '<i data-lucide="check" class="settings-palette-item-check"></i>' : '') +
448
450
  '</button>';
449
451
  itemIndex++;
@@ -493,10 +495,6 @@ function updatePaletteHighlight(buttons) {
493
495
  }
494
496
  }
495
497
 
496
- function escapeHtmlPalette(str) {
497
- return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
498
- }
499
-
500
498
  function updateNavPill(sectionName) {
501
499
  var pill = document.getElementById("settings-nav-pill");
502
500
  if (!pill) return;
@@ -1132,13 +1130,6 @@ function autoSaveSharedEnv() {
1132
1130
  }, 800);
1133
1131
  }
1134
1132
 
1135
- function formatBytes(n) {
1136
- if (n >= 1073741824) return (n / 1073741824).toFixed(1) + " GB";
1137
- if (n >= 1048576) return (n / 1048576).toFixed(1) + " MB";
1138
- if (n >= 1024) return (n / 1024).toFixed(1) + " KB";
1139
- return n + " B";
1140
- }
1141
-
1142
1133
  function formatUptime(seconds) {
1143
1134
  var d = Math.floor(seconds / 86400);
1144
1135
  var h = Math.floor((seconds % 86400) / 3600);
@@ -1174,3 +1165,25 @@ export function initSsLiteToggle() {
1174
1165
  });
1175
1166
  }
1176
1167
  }
1168
+
1169
+ // --- WS message registry (lr-4e49 Part 2) ---
1170
+ // Registers this module's own single-owner result handlers directly with
1171
+ // the app-messages.js registry. Runs once at module load — app.js imports
1172
+ // every domain module (including this one) before connect() opens the
1173
+ // WebSocket, so registration always completes before any message can
1174
+ // arrive (see lib/public/app.js). Message types with more than one
1175
+ // consumer module (shared_env_result, set_shared_env_result, process_stats,
1176
+ // daemon_config) stay registered directly in app-messages.js, which is the
1177
+ // only place both consumers are already imported together.
1178
+ registerHandlers({
1179
+ global_claude_md_result: handleGlobalClaudeMdRead,
1180
+ write_global_claude_md_result: handleGlobalClaudeMdWrite,
1181
+ set_pin_result: handleSetPinResult,
1182
+ set_keep_awake_result: handleKeepAwakeChanged,
1183
+ keep_awake_changed: handleKeepAwakeChanged,
1184
+ set_auto_continue_result: handleAutoContinueChanged,
1185
+ auto_continue_changed: handleAutoContinueChanged,
1186
+ refresh_agents_result: handleRefreshAgentsResult,
1187
+ restart_server_result: handleRestartResult,
1188
+ shutdown_server_result: handleShutdownResult,
1189
+ });
@@ -93,7 +93,7 @@ export function initSidebarProjects() {
93
93
  // Tooltip + click for home icon
94
94
  var homeIcon = document.querySelector(".icon-strip-home");
95
95
  if (homeIcon) {
96
- homeIcon.addEventListener("mouseenter", function () { showIconTooltip(homeIcon, "Clagentic:Console"); });
96
+ homeIcon.addEventListener("mouseenter", function () { showIconTooltip(homeIcon, "Clagentic: Console"); });
97
97
  homeIcon.addEventListener("mouseleave", hideIconTooltip);
98
98
  homeIcon.addEventListener("click", function (e) {
99
99
  e.preventDefault();
@@ -2,7 +2,7 @@
2
2
  // Extracted from sidebar.js (PR-35)
3
3
 
4
4
  import { avatarUrl, userAvatarUrl } from './avatar.js';
5
- import { escapeHtml } from './utils.js';
5
+ import { escapeHtml, relativeTime } from './utils.js';
6
6
  import { iconHtml, refreshIcons } from './icons.js';
7
7
  import { openSearch as openSessionSearch } from './session-search.js';
8
8
  import { store } from './store.js';
@@ -1570,20 +1570,6 @@ function updateCountdowns() {
1570
1570
 
1571
1571
  // --- CLI session picker ---
1572
1572
 
1573
- function relativeTime(isoString) {
1574
- if (!isoString) return "";
1575
- var ms = Date.now() - new Date(isoString).getTime();
1576
- var sec = Math.floor(ms / 1000);
1577
- if (sec < 60) return "just now";
1578
- var min = Math.floor(sec / 60);
1579
- if (min < 60) return min + "m ago";
1580
- var hr = Math.floor(min / 60);
1581
- if (hr < 24) return hr + "h ago";
1582
- var days = Math.floor(hr / 24);
1583
- if (days < 30) return days + "d ago";
1584
- return new Date(isoString).toLocaleDateString();
1585
- }
1586
-
1587
1573
  export function populateCliSessionList(sessions) {
1588
1574
  var pickerLoading = document.getElementById("resume-picker-loading");
1589
1575
  var pickerEmpty = document.getElementById("resume-picker-empty");
@@ -29,7 +29,7 @@ export function updatePageTitle() {
29
29
  var activeItem = ctx.sessionListEl.querySelector(".session-item.active .session-item-text");
30
30
  if (activeItem) sessionTitle = activeItem.textContent;
31
31
  if (ctx.headerTitleEl) {
32
- ctx.headerTitleEl.textContent = sessionTitle || ctx.projectName || "Clagentic:Console";
32
+ ctx.headerTitleEl.textContent = sessionTitle || ctx.projectName || "Clagentic: Console";
33
33
  }
34
34
  var tbProjectName = ctx.$("title-bar-project-name");
35
35
  if (tbProjectName && ctx.projectName) {
@@ -42,9 +42,9 @@ export function updatePageTitle() {
42
42
  if (ctx.projectName && sessionTitle) {
43
43
  document.title = sessionTitle + " - " + ctx.projectName;
44
44
  } else if (ctx.projectName) {
45
- document.title = ctx.projectName + " - Clagentic:Console";
45
+ document.title = ctx.projectName + " - Clagentic: Console";
46
46
  } else {
47
- document.title = "Clagentic:Console";
47
+ document.title = "Clagentic: Console";
48
48
  }
49
49
  }
50
50
 
@@ -52,3 +52,4 @@ export function copyToClipboard(text) {
52
52
  }
53
53
 
54
54
  export { escapeHtml } from './escape-html.js';
55
+ export { relativeTime } from './relative-time.js';
package/lib/public/sw.js CHANGED
@@ -1,11 +1,31 @@
1
1
  var CACHE_NAME = "clagentic-offline-v__VERSION__";
2
2
 
3
+ // Minimal app-shell paths pre-cached on install so the new cache generation
4
+ // is never empty at activate time. Without this, an offline mobile client
5
+ // that goes offline in the window between activate (old cache deleted) and
6
+ // the first successful network fetch (cache repopulated) falls through to
7
+ // the bare "Waiting for server..." placeholder instead of the real shell
8
+ // (lr-e0ec47).
9
+ var SHELL_URLS = ["/", "/index.html"];
10
+
3
11
  self.addEventListener("install", function (event) {
4
- event.waitUntil(self.skipWaiting());
12
+ event.waitUntil(
13
+ caches.open(CACHE_NAME).then(function (cache) {
14
+ return cache.addAll(SHELL_URLS).catch(function () {
15
+ // Best-effort: a shell fetch failing (e.g. offline install) must not
16
+ // block skipWaiting — the fetch handler's cache-fallback still works
17
+ // for whatever the previous cache generation already holds.
18
+ });
19
+ }).then(function () {
20
+ return self.skipWaiting();
21
+ })
22
+ );
5
23
  });
6
24
 
7
25
  self.addEventListener("activate", function (event) {
8
- // Clean up old cache versions
26
+ // Clean up old cache versions only after the new cache has the app shell
27
+ // (guaranteed by install above), so there is no window where a client can
28
+ // hit an empty cache and fall through to the minimal offline placeholder.
9
29
  event.waitUntil(
10
30
  caches.keys().then(function (names) {
11
31
  return Promise.all(
@@ -75,7 +95,7 @@ self.addEventListener("fetch", function (event) {
75
95
  // If even the index page is not cached, show a minimal offline page
76
96
  if (indexCached) return indexCached;
77
97
  return new Response(
78
- "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Clagentic:Console</title>" +
98
+ "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Clagentic: Console</title>" +
79
99
  "<style>body{margin:0;background:#000;color:#888;display:flex;" +
80
100
  "align-items:center;justify-content:center;height:100vh;" +
81
101
  "font-family:monospace;font-size:1.2em}</style></head>" +
@@ -130,7 +150,7 @@ self.addEventListener("push", function (event) {
130
150
  if (clientList[i].focused || clientList[i].visibilityState === "visible") return;
131
151
  }
132
152
  }
133
- return self.registration.showNotification(data.title || "Clagentic:Console", options);
153
+ return self.registration.showNotification(data.title || "Clagentic: Console", options);
134
154
  }).catch(function () {})
135
155
  );
136
156
  });