@clagentic/console 1.7.0 → 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 (58) hide show
  1. package/bin/cli.js +198 -2542
  2. package/lib/build-sha.json +4 -0
  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/daemon.js +15 -6
  9. package/lib/memory-shed.js +81 -2
  10. package/lib/pages.js +13 -17
  11. package/lib/project-connection.js +13 -0
  12. package/lib/project-loop.js +4 -0
  13. package/lib/project-sessions.js +9 -3
  14. package/lib/project.js +3 -2
  15. package/lib/public/css/diagnostics.css +29 -1
  16. package/lib/public/css/home-hub.css +10 -0
  17. package/lib/public/css/overlays.css +19 -0
  18. package/lib/public/index.html +12 -11
  19. package/lib/public/manifest.json +1 -1
  20. package/lib/public/modules/app-connection.js +150 -4
  21. package/lib/public/modules/app-history-replay.js +155 -0
  22. package/lib/public/modules/app-home-hub.js +24 -14
  23. package/lib/public/modules/app-messages.js +1246 -1469
  24. package/lib/public/modules/app-notifications.js +4 -4
  25. package/lib/public/modules/app-rate-limit.js +128 -27
  26. package/lib/public/modules/command-palette.js +11 -22
  27. package/lib/public/modules/context-sources.js +1 -6
  28. package/lib/public/modules/filebrowser.js +25 -13
  29. package/lib/public/modules/input.js +47 -12
  30. package/lib/public/modules/mcp-ui.js +2 -2
  31. package/lib/public/modules/notifications.js +22 -1
  32. package/lib/public/modules/playbook.js +6 -6
  33. package/lib/public/modules/project-settings.js +5 -13
  34. package/lib/public/modules/qrcode.js +2 -2
  35. package/lib/public/modules/rate-limit-state.js +133 -0
  36. package/lib/public/modules/relative-time.js +27 -0
  37. package/lib/public/modules/scheduler-history.js +1 -5
  38. package/lib/public/modules/server-settings.js +28 -15
  39. package/lib/public/modules/sidebar-mobile.js +8 -3
  40. package/lib/public/modules/sidebar-projects.js +1 -1
  41. package/lib/public/modules/sidebar-sessions.js +1 -15
  42. package/lib/public/modules/sidebar.js +3 -3
  43. package/lib/public/modules/utils.js +1 -0
  44. package/lib/public/sw.js +24 -4
  45. package/lib/sdk-bridge.js +22 -0
  46. package/lib/sdk-message-processor.js +27 -1
  47. package/lib/server-auth.js +48 -2
  48. package/lib/server-palette.js +17 -1
  49. package/lib/server-settings.js +70 -4
  50. package/lib/server.js +200 -4
  51. package/lib/session-search.js +20 -5
  52. package/lib/sessions.js +84 -3
  53. package/lib/smtp.js +6 -6
  54. package/lib/yoke/adapters/codex.js +1 -1
  55. package/package.json +4 -2
  56. package/scripts/install-local-test.js +97 -0
  57. package/scripts/verify-installed-build.js +80 -0
  58. package/scripts/write-build-sha.js +53 -0
@@ -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,133 @@
1
+ // rate-limit-state.js - Per-session rate-limit / schedule-message arming state.
2
+ //
3
+ // lr-0827ba: this state was previously a handful of bare module-scoped
4
+ // variables in input.js and app-rate-limit.js (scheduleDelayMs,
5
+ // rateLimitResetsAt, rateLimitResetTimer, rateLimitResetState, scheduled
6
+ // message bubble text/resetsAt). Because the SPA does not reload the page
7
+ // when the user switches projects, all sessions across all projects shared
8
+ // that single set of variables — arming a schedule in a second project
9
+ // silently clobbered the first project's armed state.
10
+ //
11
+ // This module replaces those bare variables with a small state map keyed by
12
+ // session localId (the same id the server uses as its session-map key, see
13
+ // lib/sessions.js and the `id` field on `session_switched`), mirroring the
14
+ // existing sessionDrafts precedent in app-messages.js/app.js. Each session's
15
+ // entry keeps running in the background (including its reset setTimeout)
16
+ // even while a different session is focused, mirroring server-side behavior
17
+ // (session.scheduledMessage in lib/project.js is already correctly
18
+ // per-session).
19
+ //
20
+ // DOM-free by design so it can be imported and unit-tested directly under
21
+ // plain Node (see test/rate-limit-state.test.js), following the same
22
+ // DOM-free-sibling-module convention as sticky-notes-fmt.js.
23
+
24
+ var _bySession = Object.create(null);
25
+
26
+ function emptyEntry() {
27
+ return {
28
+ // Auto-schedule arming (input.js sendMessage() consumes this).
29
+ scheduleDelayMs: 0,
30
+ // Rate-limit-driven auto-schedule bookkeeping (app-rate-limit.js).
31
+ rateLimitResetsAt: null,
32
+ rateLimitResetTimer: null,
33
+ rateLimitResetState: {},
34
+ // Scheduled-message bubble (queued user message awaiting send).
35
+ scheduledMsgText: null,
36
+ scheduledMsgResetsAt: null,
37
+ };
38
+ }
39
+
40
+ function getEntry(sessionId) {
41
+ if (sessionId == null) return emptyEntry();
42
+ if (!_bySession[sessionId]) _bySession[sessionId] = emptyEntry();
43
+ return _bySession[sessionId];
44
+ }
45
+
46
+ // --- Schedule delay (auto-send arming) ---
47
+
48
+ export function getScheduleDelayMs(sessionId) {
49
+ return getEntry(sessionId).scheduleDelayMs;
50
+ }
51
+
52
+ export function setScheduleDelayMs(sessionId, ms) {
53
+ if (sessionId == null) return;
54
+ getEntry(sessionId).scheduleDelayMs = ms;
55
+ }
56
+
57
+ // --- Rate-limit reset bookkeeping ---
58
+
59
+ export function getRateLimitResetsAt(sessionId) {
60
+ return getEntry(sessionId).rateLimitResetsAt;
61
+ }
62
+
63
+ export function setRateLimitResetsAt(sessionId, resetsAt) {
64
+ if (sessionId == null) return;
65
+ getEntry(sessionId).rateLimitResetsAt = resetsAt;
66
+ }
67
+
68
+ export function getRateLimitResetTimer(sessionId) {
69
+ return getEntry(sessionId).rateLimitResetTimer;
70
+ }
71
+
72
+ export function setRateLimitResetTimer(sessionId, timer) {
73
+ if (sessionId == null) return;
74
+ getEntry(sessionId).rateLimitResetTimer = timer;
75
+ }
76
+
77
+ export function getRateLimitResetState(sessionId) {
78
+ return getEntry(sessionId).rateLimitResetState;
79
+ }
80
+
81
+ // --- Scheduled-message bubble ---
82
+
83
+ export function getScheduledMsg(sessionId) {
84
+ var e = getEntry(sessionId);
85
+ if (e.scheduledMsgText == null) return null;
86
+ return { text: e.scheduledMsgText, resetsAt: e.scheduledMsgResetsAt };
87
+ }
88
+
89
+ export function setScheduledMsg(sessionId, text, resetsAt) {
90
+ if (sessionId == null) return;
91
+ var e = getEntry(sessionId);
92
+ e.scheduledMsgText = text;
93
+ e.scheduledMsgResetsAt = resetsAt;
94
+ }
95
+
96
+ export function clearScheduledMsg(sessionId) {
97
+ if (sessionId == null) return;
98
+ var e = getEntry(sessionId);
99
+ e.scheduledMsgText = null;
100
+ e.scheduledMsgResetsAt = null;
101
+ }
102
+
103
+ // --- Whole-session lifecycle ---
104
+
105
+ // True if this session has any armed/queued state worth restoring on
106
+ // switch-in (used to decide whether a redraw is needed).
107
+ export function hasArmedState(sessionId) {
108
+ if (sessionId == null) return false;
109
+ var e = _bySession[sessionId];
110
+ if (!e) return false;
111
+ return e.scheduleDelayMs > 0 || e.scheduledMsgText != null;
112
+ }
113
+
114
+ // Clears a single session's state entirely, including canceling its
115
+ // background reset timer. Call when a session is actually destroyed/closed,
116
+ // NOT on a mere project/session switch (switching away must leave the timer
117
+ // running in the background so it fires even while unfocused).
118
+ export function clearSession(sessionId) {
119
+ if (sessionId == null) return;
120
+ var e = _bySession[sessionId];
121
+ if (e && e.rateLimitResetTimer) clearTimeout(e.rateLimitResetTimer);
122
+ delete _bySession[sessionId];
123
+ }
124
+
125
+ // Test/diagnostic helper: wipes all tracked sessions. Not used in production
126
+ // code paths (there is no "reset everything" client action), only in tests
127
+ // that need isolation between cases.
128
+ export function _resetAllForTest() {
129
+ for (var k in _bySession) {
130
+ if (_bySession[k] && _bySession[k].rateLimitResetTimer) clearTimeout(_bySession[k].rateLimitResetTimer);
131
+ }
132
+ _bySession = Object.create(null);
133
+ }
@@ -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
+ });
@@ -40,7 +40,7 @@ import { getWs } from './ws-ref.js';
40
40
  import { dismissOverlayPanels, closeSidebar } from './sidebar.js';
41
41
  import { switchProject, getCachedProjects, openAddProjectModal } from './app-projects.js';
42
42
  import { openDm } from './app-dm.js';
43
- import { showHomeHub } from './app-home-hub.js';
43
+ import { showHomeHub, hideHomeHub, isHomeHubVisible } from './app-home-hub.js';
44
44
  import { openTerminal } from './terminal.js';
45
45
  import { loadRootDirectory } from './filebrowser.js';
46
46
  import { renderSheetTeam as renderTeamView } from './team-panel.js';
@@ -1278,8 +1278,13 @@ export function initSidebarMobile() {
1278
1278
  if (mobileHomeBtn) {
1279
1279
  mobileHomeBtn.addEventListener("click", function () {
1280
1280
  closeSidebar();
1281
- setMobileTabActive("home");
1282
- showHomeHub();
1281
+ if (isHomeHubVisible()) {
1282
+ hideHomeHub();
1283
+ setMobileTabActive(null);
1284
+ } else {
1285
+ setMobileTabActive("home");
1286
+ showHomeHub();
1287
+ }
1283
1288
  });
1284
1289
  }
1285
1290
 
@@ -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
  });
package/lib/sdk-bridge.js CHANGED
@@ -324,6 +324,28 @@ function createSDKBridge(opts) {
324
324
  // have been idle for IDLE_TIMEOUT_MS, allowing processQueryStream's finally
325
325
  // block to clean up the child process. Session state on disk is preserved —
326
326
  // the next startQuery() call resumes with a fresh process.
327
+ //
328
+ // lr-f36626: that resume-cleanly assumption is true for an idle human but
329
+ // was FALSE for a session correctly WAITING on a live backgrounded Task
330
+ // (Agent-tool dispatch) — isProcessing is false in that state (the parent
331
+ // turn already completed a 'result'), so this loop previously saw no
332
+ // difference between "abandoned" and "waiting on a live child" and reaped
333
+ // both after IDLE_TIMEOUT_MS, orphaning the child's stream. Fixed at the
334
+ // source rather than here: session.lastActivityAt is now also bumped on
335
+ // genuine subagent stream activity (processSubagentMessage and the
336
+ // tool_progress/task_progress/task_updated/task_started branches in
337
+ // sdk-message-processor.js), so a progressing child keeps pushing this
338
+ // loop's idle clock forward for as long as it keeps producing output.
339
+ // Deliberately NOT "never reap if session.activeTaskToolIds is non-empty"
340
+ // — a dead/silent child (crashed, stuck, or simply never checks back in)
341
+ // must still become reapable once IDLE_TIMEOUT_MS genuinely elapses with
342
+ // no activity at all, or a leaked child registration would pin the
343
+ // session (and its process) alive forever. Because that case was never
344
+ // "live" at the moment of reap (no activity for the full timeout window),
345
+ // it emits no notification here — only the pressure path in
346
+ // lib/memory-shed.js, which can reclaim a still-progressing session as a
347
+ // deliberate last resort, notifies both UI surfaces (see its
348
+ // liveChildReclaims handling).
327
349
  var IDLE_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes
328
350
  var IDLE_CHECK_INTERVAL_MS = 60 * 1000; // check every 60 seconds
329
351
  var _idleReaperTimer = null;
@@ -80,6 +80,19 @@ function attachMessageProcessor(ctx) {
80
80
  var content = parsed.content;
81
81
  if (!Array.isArray(content)) return;
82
82
 
83
+ // lr-f36626: a backgrounded Task's own stream activity is genuine session
84
+ // activity even though the parent turn's isProcessing is false while the
85
+ // dispatch-loop sits WAITING on the child (root cause: the idle reaper in
86
+ // sdk-bridge.js only ever saw the two top-level turn/query bump sites, so
87
+ // a session correctly waiting on a live child looked identical to an
88
+ // abandoned one and got reaped out from under it). Bumping here — the
89
+ // same field the reaper compares against — means a genuinely progressing
90
+ // child keeps the parent session non-idle for as long as it keeps
91
+ // producing output; a dead/silent child stops bumping and the session
92
+ // still times out and is reaped normally (no blanket "never reap if a
93
+ // child is registered" rule — see startIdleReaper in sdk-bridge.js).
94
+ session.lastActivityAt = Date.now();
95
+
83
96
  if (parsed.messageRole === "assistant") {
84
97
  // Extract tool_use blocks from sub-agent assistant messages
85
98
  for (var i = 0; i < content.length; i++) {
@@ -654,6 +667,11 @@ function attachMessageProcessor(ctx) {
654
667
  } else if (parsed.yokeType === "task_started") {
655
668
  var parentId = parsed.parentToolId;
656
669
  if (parentId) {
670
+ // lr-f36626: genuine backgrounded-Task lifecycle activity — see the
671
+ // matching comment on processSubagentMessage's bump above and on
672
+ // startIdleReaper in sdk-bridge.js for why this keeps a WAITING
673
+ // parent session non-idle for as long as its child keeps reporting in.
674
+ session.lastActivityAt = Date.now();
657
675
  if (!session.taskIdMap) session.taskIdMap = {};
658
676
  session.taskIdMap[parentId] = parsed.taskId;
659
677
  sendAndRecord(session, {
@@ -667,6 +685,7 @@ function attachMessageProcessor(ctx) {
667
685
  } else if (parsed.yokeType === "task_progress") {
668
686
  var parentId = parsed.parentToolId;
669
687
  if (parentId) {
688
+ session.lastActivityAt = Date.now(); // lr-f36626 — see task_started above
670
689
  sendAndRecord(session, {
671
690
  type: "task_progress",
672
691
  parentToolId: parentId,
@@ -689,6 +708,7 @@ function attachMessageProcessor(ctx) {
689
708
  }
690
709
  }
691
710
  if (parentId) {
711
+ session.lastActivityAt = Date.now(); // lr-f36626 — see task_started above
692
712
  sendAndRecord(session, {
693
713
  type: "task_updated",
694
714
  parentToolId: parentId,
@@ -701,6 +721,7 @@ function attachMessageProcessor(ctx) {
701
721
  // Sub-agent tool_progress: forward as activity update
702
722
  var parentId = parsed.parentToolId;
703
723
  if (parentId) {
724
+ session.lastActivityAt = Date.now(); // lr-f36626 — see task_started above
704
725
  sendAndRecord(session, {
705
726
  type: "subagent_activity",
706
727
  parentToolId: parentId,
@@ -760,13 +781,17 @@ function attachMessageProcessor(ctx) {
760
781
  var info = parsed.rateLimitInfo;
761
782
  console.log("[sdk-bridge] rate_limit_event for session " + session.localId + ": status=" + info.status + " resetsAt=" + info.resetsAt + " isUsingOverage=" + info.isUsingOverage + " isProcessing=" + session.isProcessing);
762
783
 
763
- // Broadcast reset time for top-bar usage link
784
+ // Broadcast reset time for top-bar usage link. This is a project-wide
785
+ // broadcast (not sendAndRecord), but still stamp localId so a client
786
+ // with multiple sessions open across tabs can tell which session's
787
+ // query actually triggered this usage update.
764
788
  if (info.rateLimitType && info.resetsAt) {
765
789
  send({
766
790
  type: "rate_limit_usage",
767
791
  rateLimitType: info.rateLimitType,
768
792
  resetsAt: info.resetsAt * 1000,
769
793
  status: info.status,
794
+ localId: session.localId,
770
795
  });
771
796
  }
772
797
 
@@ -780,6 +805,7 @@ function attachMessageProcessor(ctx) {
780
805
  utilization: info.utilization || null,
781
806
  isUsingOverage: info.isUsingOverage || false,
782
807
  blocksCurrentModel: bucketBlocksModel(info.rateLimitType, sm && sm.currentModel),
808
+ localId: session.localId,
783
809
  });
784
810
  // Track rejection for auto-continue / scheduled message support
785
811
  if (info.status === "rejected" && info.resetsAt) {