@clagentic/console 1.11.0 → 1.12.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.
- package/README.md +1 -0
- package/bin/cli.js +14 -2
- package/lib/build-changes.js +8 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-offer.js +31 -7
- package/lib/claude-settings-env.js +142 -0
- package/lib/cli/arg-validation.js +1 -1
- package/lib/cli/duration.js +27 -0
- package/lib/cli/ipc-subcommands.js +26 -0
- package/lib/cli/schedule-input-subcommands.js +1 -22
- package/lib/cli/session-subcommands.js +38 -7
- package/lib/daemon.js +26 -0
- package/lib/notification-prefs.js +257 -0
- package/lib/notify/core.js +175 -0
- package/lib/notify/index.js +31 -0
- package/lib/notify/live-prompts.js +36 -0
- package/lib/notify/payload.js +63 -0
- package/lib/notify/target.js +5 -0
- package/lib/notify/type-registry.js +64 -0
- package/lib/notify/types.js +20 -0
- package/lib/open-sockets.js +27 -0
- package/lib/outbound-access.js +74 -0
- package/lib/outbound-entry.js +109 -0
- package/lib/outbound-ledger.js +306 -0
- package/lib/outbound-query.js +153 -0
- package/lib/pending-prompts.js +31 -16
- package/lib/project-connection.js +40 -1
- package/lib/project-filesystem.js +20 -5
- package/lib/project-http.js +9 -1
- package/lib/project-loop.js +25 -13
- package/lib/project-notifications.js +206 -42
- package/lib/project-prompt-responses.js +1 -1
- package/lib/project-sessions.js +30 -1
- package/lib/project.js +15 -1
- package/lib/prompt-registry.js +92 -24
- package/lib/prompt-reminders.js +282 -0
- package/lib/prompt-source.js +43 -8
- package/lib/public/app.js +1 -0
- package/lib/public/css/diagnostics.css +28 -0
- package/lib/public/css/home-hub.css +12 -0
- package/lib/public/css/icon-strip.css +9 -0
- package/lib/public/css/input.css +93 -0
- package/lib/public/css/menus.css +22 -0
- package/lib/public/css/mobile-nav.css +11 -0
- package/lib/public/css/server-settings.css +24 -0
- package/lib/public/css/sidebar.css +24 -0
- package/lib/public/index.html +6 -0
- package/lib/public/modules/activity-state.js +20 -4
- package/lib/public/modules/app-connection.js +22 -5
- package/lib/public/modules/app-header.js +2 -0
- package/lib/public/modules/app-messages.js +6 -2
- package/lib/public/modules/app-notifications.js +65 -40
- package/lib/public/modules/app-projects.js +3 -1
- package/lib/public/modules/app-rate-limit.js +12 -6
- package/lib/public/modules/app-rendering.js +26 -3
- package/lib/public/modules/build-update-sessions.js +81 -0
- package/lib/public/modules/collapsible-text.js +77 -0
- package/lib/public/modules/diagnostics.js +9 -2
- package/lib/public/modules/env-shadow-notice.js +34 -0
- package/lib/public/modules/keep-alive.js +66 -0
- package/lib/public/modules/notification-prefs.js +151 -0
- package/lib/public/modules/notify-client.js +153 -0
- package/lib/public/modules/project-settings.js +5 -0
- package/lib/public/modules/prompt-reminders-setting.js +13 -0
- package/lib/public/modules/prompt-state.js +3 -3
- package/lib/public/modules/prompts.js +1 -1
- package/lib/public/modules/server-settings.js +3 -0
- package/lib/public/modules/sidebar-mobile.js +8 -0
- package/lib/public/modules/sidebar-sessions.js +27 -0
- package/lib/public/modules/terminal-links.js +175 -0
- package/lib/public/modules/terminal.js +19 -103
- package/lib/public/notify-sw-logic.js +300 -0
- package/lib/public/notify-target.js +97 -0
- package/lib/public/sw.js +15 -62
- package/lib/push-audience.js +84 -0
- package/lib/push.js +87 -20
- package/lib/runtime-env.js +1 -0
- package/lib/sdk-bridge.js +83 -36
- package/lib/sdk-message-processor.js +148 -49
- package/lib/sender-ref.js +3 -0
- package/lib/server.js +80 -4
- package/lib/session-directory.js +6 -4
- package/lib/session-input-ipc.js +11 -1
- package/lib/session-input.js +95 -14
- package/lib/session-liveness.js +53 -0
- package/lib/session-reclaim.js +37 -2
- package/lib/sessions.js +58 -4
- package/lib/usage-store.js +403 -0
- package/lib/vendor-auth.js +33 -2
- package/lib/ws-schema.js +13 -2
- package/lib/yoke/adapters/claude-vendor.js +11 -1
- package/lib/yoke/adapters/claude.js +17 -0
- package/lib/yoke/adapters/codex.js +5 -1
- package/lib/yoke/auth-checks.js +17 -2
- package/lib/yoke/index.js +21 -3
- package/lib/yoke/provider-credentials.js +24 -0
- package/lib/yoke/registry.js +8 -1
- package/package.json +2 -2
- package/scripts/check-test-count.js +14 -0
|
@@ -9,16 +9,21 @@ import { store } from './store.js';
|
|
|
9
9
|
import { loginCommandFor, defaultVendorId } from './vendor-registry.js';
|
|
10
10
|
import { getWs } from './ws-ref.js';
|
|
11
11
|
import { getCachedProjects } from './app-projects.js';
|
|
12
|
-
import { switchProject } from './app-projects.js';
|
|
13
12
|
import { userAvatarUrl } from './avatar.js';
|
|
14
13
|
import { openTerminal } from './terminal.js';
|
|
15
14
|
import { askWording } from './prompt-kinds/index.js';
|
|
16
15
|
import { wirePromptBanner, restoreUnconfirmedBanners, bannerActions } from './prompt-banner.js';
|
|
17
16
|
import { promptLabelHtml } from './prompt-label.js';
|
|
17
|
+
import { isSurfaceWanted, shouldChimeForNotification } from './notification-prefs.js';
|
|
18
|
+
import { playDoneSound, isNotifSoundEnabled } from './notifications.js';
|
|
19
|
+
import { initNotifyClient, noteNotificationsState, routeTo, takePendingSession } from './notify-client.js';
|
|
20
|
+
import '../notify-sw-logic.js';
|
|
18
21
|
|
|
19
22
|
// The server dismisses a prompt's banner once the prompt settles, however it
|
|
20
23
|
// was answered.
|
|
21
24
|
var notifications = [];
|
|
25
|
+
// The notification behind each banner on screen, by id.
|
|
26
|
+
var shownNotifs = Object.create(null);
|
|
22
27
|
var unreadCount = 0;
|
|
23
28
|
var bannerContainer = null;
|
|
24
29
|
var bellBtn = null;
|
|
@@ -45,6 +50,8 @@ export function initAppNotifications() {
|
|
|
45
50
|
bannerContainer.className = "notif-banner-container";
|
|
46
51
|
document.body.appendChild(bannerContainer);
|
|
47
52
|
|
|
53
|
+
initNotifyClient();
|
|
54
|
+
|
|
48
55
|
if (bellBtn) {
|
|
49
56
|
bellBtn.addEventListener("click", function (e) {
|
|
50
57
|
e.stopPropagation();
|
|
@@ -95,13 +102,19 @@ function showBanner(notif, autoDismissMs) {
|
|
|
95
102
|
var isPermission = notif.type === "permission_request" && notif.meta && notif.meta.requestId;
|
|
96
103
|
var isAuthRequired = notif.type === "auth_required";
|
|
97
104
|
var isUserMention = notif.type === "user_mention";
|
|
105
|
+
var isReminder = notif.type === "permission_reminder";
|
|
98
106
|
var projectIcon = isEmpty ? null : getProjectIcon(notif.slug);
|
|
99
107
|
var projectName = isEmpty ? "" : (isAuthRequired ? "CLAGENTIC" : getProjectName(notif.slug));
|
|
100
108
|
var userMentionAvatarSrc = isUserMention ? buildUserMentionAvatarSrc(notif) : null;
|
|
101
109
|
|
|
102
110
|
var banner = document.createElement("div");
|
|
103
|
-
banner.className = "notif-banner" + (isAuthRequired ? " notif-banner-update notif-banner-auth" : isPermission ? " notif-banner-permission" : isUserMention ? " notif-banner-user-mention" : "");
|
|
111
|
+
banner.className = "notif-banner" + (isAuthRequired ? " notif-banner-update notif-banner-auth" : isPermission ? " notif-banner-permission" : isUserMention ? " notif-banner-user-mention" : isReminder ? " notif-banner-reminder" : "");
|
|
104
112
|
if (!isEmpty) banner.setAttribute("data-notif-id", notif.id);
|
|
113
|
+
if (!isEmpty && notif.type) banner.setAttribute("data-notif-type", notif.type);
|
|
114
|
+
if (!isEmpty && notif.liveInState === true) {
|
|
115
|
+
banner.setAttribute("data-live-in-state", "true");
|
|
116
|
+
shownNotifs[notif.id] = notif;
|
|
117
|
+
}
|
|
105
118
|
if (isAuthRequired) banner.setAttribute("data-auth-banner", "true");
|
|
106
119
|
|
|
107
120
|
var iconHtmlStr = userMentionAvatarSrc
|
|
@@ -318,6 +331,7 @@ export function showAuthRequiredBanner(msg) {
|
|
|
318
331
|
|
|
319
332
|
function removeBanner(banner) {
|
|
320
333
|
if (!banner || !banner.parentNode) return;
|
|
334
|
+
delete shownNotifs[banner.getAttribute("data-notif-id")];
|
|
321
335
|
banner.classList.remove("show");
|
|
322
336
|
banner.classList.add("hide");
|
|
323
337
|
// Update the clear-all button right away so it disappears before the
|
|
@@ -404,18 +418,37 @@ export function handleNotificationsState(msg) {
|
|
|
404
418
|
notifications = msg.notifications || [];
|
|
405
419
|
unreadCount = msg.unreadCount || 0;
|
|
406
420
|
updateBadge();
|
|
421
|
+
dropBannersOfEndedPrompts(msg.livePrompts || null);
|
|
422
|
+
noteNotificationsState(notifications, msg.livePrompts);
|
|
407
423
|
|
|
408
|
-
//
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
424
|
+
// A route waiting on the connection (a project switch, a deep link) opens
|
|
425
|
+
// its session now that this project's socket is up.
|
|
426
|
+
var ws = getWs();
|
|
427
|
+
if (ws && ws.readyState === 1) {
|
|
428
|
+
var pendingId = takePendingSession();
|
|
429
|
+
if (pendingId !== null) ws.send(JSON.stringify({ type: "switch_session", id: pendingId }));
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// A prompt banner and a reminder are tied to a live prompt. The server's list
|
|
434
|
+
// (sent on every connect) and its live-prompt record are the truth: after a
|
|
435
|
+
// daemon restart no prompt survives, and the dismissals were sent to a
|
|
436
|
+
// connection that was gone. The check is the one the push reconcile uses
|
|
437
|
+
// (NotifySw.isBannerLive), for every banner the registry marks liveInState.
|
|
438
|
+
function dropBannersOfEndedPrompts(livePrompts) {
|
|
439
|
+
if (!bannerContainer) return;
|
|
440
|
+
var banners = bannerContainer.querySelectorAll('.notif-banner[data-live-in-state="true"]');
|
|
441
|
+
for (var i = 0; i < banners.length; i++) {
|
|
442
|
+
var notif = shownNotifs[banners[i].getAttribute("data-notif-id")];
|
|
443
|
+
if (notif && !globalThis.NotifySw.isBannerLive(notif, notifications, livePrompts)) removeBanner(banners[i]);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Session local ids are unique only within a project, and the server sends a
|
|
448
|
+
// user's notifications to every project socket that user has open. A session
|
|
449
|
+
// id therefore names the viewed session only together with the project slug.
|
|
450
|
+
function isViewedProject(slug) {
|
|
451
|
+
return !!slug && slug === (store.get('currentSlug') || "");
|
|
419
452
|
}
|
|
420
453
|
|
|
421
454
|
export function handleNotificationCreated(msg) {
|
|
@@ -423,8 +456,9 @@ export function handleNotificationCreated(msg) {
|
|
|
423
456
|
|
|
424
457
|
// Auto-dismiss if it's for the session the user is currently viewing
|
|
425
458
|
var activeSession = store.get('activeSessionId') || null;
|
|
426
|
-
|
|
427
|
-
|
|
459
|
+
var sameProject = isViewedProject(notif.slug);
|
|
460
|
+
console.log("[notif] created:", notif.type, "slug=" + notif.slug, "sessionId=" + notif.sessionId + "(" + typeof notif.sessionId + ")", "active=" + activeSession + "(" + typeof activeSession + ")", "match=" + (sameProject && notif.sessionId == activeSession));
|
|
461
|
+
if (notif.type !== "auth_required" && notif.sessionId && sameProject && String(notif.sessionId) === String(activeSession)) {
|
|
428
462
|
dismissNotif(notif.id);
|
|
429
463
|
return;
|
|
430
464
|
}
|
|
@@ -433,16 +467,19 @@ export function handleNotificationCreated(msg) {
|
|
|
433
467
|
unreadCount = msg.unreadCount;
|
|
434
468
|
updateBadge();
|
|
435
469
|
|
|
436
|
-
//
|
|
437
|
-
//
|
|
438
|
-
//
|
|
439
|
-
//
|
|
440
|
-
//
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
//
|
|
444
|
-
|
|
445
|
-
|
|
470
|
+
// A banner stays until acted on when the type registry says so (the
|
|
471
|
+
// notification's persistent flag; lib/notify/types.js), or when it carries
|
|
472
|
+
// its own persistent marker in meta. It goes away when the user clicks it
|
|
473
|
+
// (which routes to its session), views the session some other way (handled
|
|
474
|
+
// above), closes it, or when its prompt resolves and the server dismisses it.
|
|
475
|
+
var _autoDismiss = !(notif.persistent === true || (notif.meta && notif.meta.persistent === true));
|
|
476
|
+
|
|
477
|
+
// The user's per-type choices (lib/notification-prefs.js). A muted type has
|
|
478
|
+
// still been added to the list and counted above: only the alert and the
|
|
479
|
+
// sound are skipped. A sound plays only while the page is hidden, like the
|
|
480
|
+
// finished turn's own chime.
|
|
481
|
+
if (isSurfaceWanted("banner", notif.category)) showBanner(notif, _autoDismiss);
|
|
482
|
+
if (shouldChimeForNotification(notif, isNotifSoundEnabled())) playDoneSound();
|
|
446
483
|
}
|
|
447
484
|
|
|
448
485
|
export function handleNotificationDismissed(msg) {
|
|
@@ -484,22 +521,10 @@ function updateBadge() {
|
|
|
484
521
|
// Navigation
|
|
485
522
|
// ========================================================
|
|
486
523
|
|
|
524
|
+
// The one router (notify-client.js) opens the notification's project and
|
|
525
|
+
// session; the slug is part of the target, as session ids repeat across projects.
|
|
487
526
|
function navigateToNotification(notif) {
|
|
488
|
-
|
|
489
|
-
var needsProjectSwitch = notif.slug && notif.slug !== currentSlug;
|
|
490
|
-
|
|
491
|
-
if (needsProjectSwitch) {
|
|
492
|
-
// Store target session for after project switch
|
|
493
|
-
if (notif.sessionId) {
|
|
494
|
-
try { sessionStorage.setItem("pending-notif-session", notif.sessionId); } catch (e) {}
|
|
495
|
-
}
|
|
496
|
-
switchProject(notif.slug);
|
|
497
|
-
} else if (notif.sessionId) {
|
|
498
|
-
var ws = getWs();
|
|
499
|
-
if (ws && ws.readyState === 1) {
|
|
500
|
-
ws.send(JSON.stringify({ type: "switch_session", id: notif.sessionId }));
|
|
501
|
-
}
|
|
502
|
-
}
|
|
527
|
+
routeTo({ slug: notif.slug, sessionId: notif.sessionId, requestId: notif.meta && notif.meta.requestId });
|
|
503
528
|
}
|
|
504
529
|
|
|
505
530
|
// Build the sender avatar URL for a user_mention notification banner.
|
|
@@ -22,7 +22,7 @@ import { resetFileBrowser } from './filebrowser.js';
|
|
|
22
22
|
import { closeArchive } from './sticky-notes.js';
|
|
23
23
|
import { isSchedulerOpen, closeScheduler, resetScheduler } from './scheduler.js';
|
|
24
24
|
import { connect, cancelReconnect, setStatus } from './app-connection.js';
|
|
25
|
-
import { setTurnCounter, setPrependAnchor, setActivityEl, setIsUserScrolledUp, hideSuggestionChips, resetCurrentFullText } from './app-rendering.js';
|
|
25
|
+
import { setTurnCounter, setPrependAnchor, setActivityEl, setIsUserScrolledUp, hideSuggestionChips, resetCurrentFullText, resetStreamState } from './app-rendering.js';
|
|
26
26
|
import { resetToolState, enableMainInput, resetTurnMetaCost, clearPromptStates } from './tools.js';
|
|
27
27
|
import { clearPendingImages } from './input.js';
|
|
28
28
|
import { clearAllMentionActive } from './sidebar-users.js';
|
|
@@ -404,6 +404,7 @@ export function resetClientState() {
|
|
|
404
404
|
store.set({ currentMsgEl: null });
|
|
405
405
|
store.set({ currentFullText: "" });
|
|
406
406
|
resetCurrentFullText("");
|
|
407
|
+
resetStreamState();
|
|
407
408
|
resetToolState();
|
|
408
409
|
clearPromptStates();
|
|
409
410
|
clearPendingImages();
|
|
@@ -506,6 +507,7 @@ export function switchProject(slug) {
|
|
|
506
507
|
// session switch) where the session list must stay intact.
|
|
507
508
|
if (typeof _onResetClientState === "function") _onResetClientState();
|
|
508
509
|
resetClientState();
|
|
510
|
+
cancelReconnect();
|
|
509
511
|
connect();
|
|
510
512
|
}
|
|
511
513
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
clearSession as clearSessionRateLimitState,
|
|
16
16
|
} from './rate-limit-state.js';
|
|
17
17
|
import { countdownText } from './schedule-time.js';
|
|
18
|
+
import { buildCollapsibleText } from './collapsible-text.js';
|
|
18
19
|
import { sendScheduledNow, cancelScheduledInput, requestScheduledInputList } from './scheduled-input-actions.js';
|
|
19
20
|
|
|
20
21
|
// --- Module-owned state ---
|
|
@@ -416,6 +417,11 @@ function buildScheduledBubble(input) {
|
|
|
416
417
|
var countdownEl;
|
|
417
418
|
var cancelBtn;
|
|
418
419
|
|
|
420
|
+
// Collapsed by default to one line; the card's own state, not persisted.
|
|
421
|
+
var collapsible = buildCollapsibleText(text, {
|
|
422
|
+
onChange: function (collapsed) { wrap.classList.toggle("is-collapsed", collapsed); },
|
|
423
|
+
});
|
|
424
|
+
|
|
419
425
|
if (isChannel) {
|
|
420
426
|
// Channel mode: avatar + header with scheduled badge + message
|
|
421
427
|
var _me = store.get('cachedAllUsers').find(function (u) { return u.id === store.get('myUserId'); });
|
|
@@ -449,6 +455,8 @@ function buildScheduledBubble(input) {
|
|
|
449
455
|
var actions = document.createElement("span");
|
|
450
456
|
actions.className = "scheduled-msg-actions";
|
|
451
457
|
|
|
458
|
+
actions.appendChild(collapsible.button);
|
|
459
|
+
|
|
452
460
|
var sendNowBtn = document.createElement("button");
|
|
453
461
|
sendNowBtn.className = "scheduled-msg-send-now";
|
|
454
462
|
sendNowBtn.textContent = "Send now";
|
|
@@ -472,9 +480,7 @@ function buildScheduledBubble(input) {
|
|
|
472
480
|
|
|
473
481
|
var bubble = document.createElement("div");
|
|
474
482
|
bubble.className = "bubble scheduled-msg-bubble";
|
|
475
|
-
|
|
476
|
-
textEl.textContent = text;
|
|
477
|
-
bubble.appendChild(textEl);
|
|
483
|
+
bubble.appendChild(collapsible.el);
|
|
478
484
|
content.appendChild(bubble);
|
|
479
485
|
|
|
480
486
|
wrap.appendChild(content);
|
|
@@ -483,9 +489,7 @@ function buildScheduledBubble(input) {
|
|
|
483
489
|
var bubble = document.createElement("div");
|
|
484
490
|
bubble.className = "bubble scheduled-msg-bubble";
|
|
485
491
|
|
|
486
|
-
|
|
487
|
-
textEl.textContent = text;
|
|
488
|
-
bubble.appendChild(textEl);
|
|
492
|
+
bubble.appendChild(collapsible.el);
|
|
489
493
|
|
|
490
494
|
var metaEl = document.createElement("div");
|
|
491
495
|
metaEl.className = "scheduled-msg-meta";
|
|
@@ -499,6 +503,8 @@ function buildScheduledBubble(input) {
|
|
|
499
503
|
countdownEl.className = "scheduled-msg-countdown";
|
|
500
504
|
metaEl.appendChild(countdownEl);
|
|
501
505
|
|
|
506
|
+
metaEl.appendChild(collapsible.button);
|
|
507
|
+
|
|
502
508
|
var sendNowBtn2 = document.createElement("button");
|
|
503
509
|
sendNowBtn2.className = "scheduled-msg-send-now";
|
|
504
510
|
sendNowBtn2.textContent = "Send now";
|
|
@@ -9,6 +9,7 @@ import { renderMarkdown, renderMarkdownAsync, highlightCodeBlocks, renderMermaid
|
|
|
9
9
|
import { iconHtml, refreshIcons } from './icons.js';
|
|
10
10
|
import { userAvatarUrl } from './avatar.js';
|
|
11
11
|
import { injectedSenderName, injectedLabel, injectedSessionNote } from './injected-label.js';
|
|
12
|
+
import { buildCollapsibleText, needsCollapse, isScheduledInitiator } from './collapsible-text.js';
|
|
12
13
|
import { resolveInjectedIdentity } from './injected-identity.js';
|
|
13
14
|
import { getProjectAgents } from './at-agents.js';
|
|
14
15
|
import { closeToolGroup } from './tools.js';
|
|
@@ -36,6 +37,16 @@ var currentFullTextLocal = ""; // module-local accumulator — not in store duri
|
|
|
36
37
|
export function resetCurrentFullText(v) {
|
|
37
38
|
currentFullTextLocal = v || "";
|
|
38
39
|
}
|
|
40
|
+
|
|
41
|
+
// Drops undrawn stream text and in-flight render bookkeeping. Without this a
|
|
42
|
+
// reset (reconnect, session or project switch) leaves buffered text that is
|
|
43
|
+
// then drawn in front of the next replayed block.
|
|
44
|
+
export function resetStreamState() {
|
|
45
|
+
if (streamDrainTimer) { cancelAnimationFrame(streamDrainTimer); streamDrainTimer = null; }
|
|
46
|
+
streamBuffer = "";
|
|
47
|
+
streamRenderPending = false;
|
|
48
|
+
streamRenderLen = 0;
|
|
49
|
+
}
|
|
39
50
|
var isUserScrolledUp = false;
|
|
40
51
|
var scrollThreshold = 150;
|
|
41
52
|
|
|
@@ -538,10 +549,18 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName, i
|
|
|
538
549
|
bubble.appendChild(pasteRow);
|
|
539
550
|
}
|
|
540
551
|
|
|
552
|
+
// A long scheduled input that has fired collapses like its pending card did.
|
|
553
|
+
// Labelling of injected input is untouched; only the text node is swapped.
|
|
554
|
+
var firedCollapse = null;
|
|
541
555
|
if (text) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
556
|
+
if (injected && isScheduledInitiator(injected.initiator) && needsCollapse(text)) {
|
|
557
|
+
firedCollapse = buildCollapsibleText(text);
|
|
558
|
+
bubble.appendChild(firedCollapse.el);
|
|
559
|
+
} else {
|
|
560
|
+
var textEl = document.createElement("span");
|
|
561
|
+
textEl.textContent = text;
|
|
562
|
+
bubble.appendChild(textEl);
|
|
563
|
+
}
|
|
545
564
|
}
|
|
546
565
|
|
|
547
566
|
|
|
@@ -607,6 +626,10 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName, i
|
|
|
607
626
|
}
|
|
608
627
|
}
|
|
609
628
|
contentWrap.appendChild(bubble);
|
|
629
|
+
if (firedCollapse) {
|
|
630
|
+
firedCollapse.button.classList.add("collapsible-toggle-fired");
|
|
631
|
+
contentWrap.appendChild(firedCollapse.button);
|
|
632
|
+
}
|
|
610
633
|
div.appendChild(contentWrap);
|
|
611
634
|
|
|
612
635
|
var actions = document.createElement("div");
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// build-update-sessions.js — the sessions a restart would end, as a count line
|
|
2
|
+
// with an expand control instead of one line each in the card's message. A
|
|
3
|
+
// card that lists every session grows with the session count until its
|
|
4
|
+
// action buttons leave the screen; collapsed by default, and bounded and
|
|
5
|
+
// scrolling when expanded, the list can never push them out. The card places
|
|
6
|
+
// this block above its actions, never around them. Every value is set with
|
|
7
|
+
// textContent: session titles are content, never markup.
|
|
8
|
+
|
|
9
|
+
function plural(n, word) {
|
|
10
|
+
return n + ' ' + word + (n === 1 ? '' : 's');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// The session lines the offer carries, or [] when it has none to set apart.
|
|
14
|
+
export function sessionLinesOf(offer) {
|
|
15
|
+
var i = offer && offer.interruptions;
|
|
16
|
+
if (!i || !Array.isArray(i.lines)) return [];
|
|
17
|
+
return i.lines.filter(function (l) { return typeof l === 'string' && l !== ''; });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The card's message without the per-session lines. Each line is dropped once,
|
|
22
|
+
* by exact match on the "- " form the daemon writes, so nothing else in the
|
|
23
|
+
* message can be mistaken for a session.
|
|
24
|
+
*/
|
|
25
|
+
export function messageWithoutSessions(message, lines) {
|
|
26
|
+
if (lines.length === 0) return message;
|
|
27
|
+
var pending = lines.map(function (l) { return '- ' + l; });
|
|
28
|
+
return String(message).split('\n').filter(function (l) {
|
|
29
|
+
var at = pending.indexOf(l);
|
|
30
|
+
if (at === -1) return true;
|
|
31
|
+
pending.splice(at, 1);
|
|
32
|
+
return false;
|
|
33
|
+
}).join('\n');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {string[]} lines
|
|
38
|
+
* @param {{collapsed?: boolean}} [opts]
|
|
39
|
+
* @returns {?HTMLElement} null when there is no session to list
|
|
40
|
+
*/
|
|
41
|
+
export function buildSessionsEl(lines, opts) {
|
|
42
|
+
if (!lines || lines.length === 0) return null;
|
|
43
|
+
var collapsed = !(opts && opts.collapsed === false);
|
|
44
|
+
|
|
45
|
+
var root = document.createElement('div');
|
|
46
|
+
root.className = 'build-update-sessions';
|
|
47
|
+
|
|
48
|
+
var head = document.createElement('div');
|
|
49
|
+
head.className = 'build-update-sessions-head';
|
|
50
|
+
var count = document.createElement('span');
|
|
51
|
+
count.className = 'build-update-sessions-count';
|
|
52
|
+
count.textContent = 'Ends ' + plural(lines.length, 'live session');
|
|
53
|
+
var toggle = document.createElement('button');
|
|
54
|
+
toggle.type = 'button';
|
|
55
|
+
toggle.className = 'collapsible-toggle build-update-sessions-toggle';
|
|
56
|
+
head.appendChild(count);
|
|
57
|
+
head.appendChild(toggle);
|
|
58
|
+
|
|
59
|
+
var list = document.createElement('ul');
|
|
60
|
+
list.className = 'build-update-session-list';
|
|
61
|
+
lines.forEach(function (l) {
|
|
62
|
+
var item = document.createElement('li');
|
|
63
|
+
item.textContent = l;
|
|
64
|
+
list.appendChild(item);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function apply() {
|
|
68
|
+
root.classList.toggle('is-collapsed', collapsed);
|
|
69
|
+
toggle.setAttribute('aria-expanded', collapsed ? 'false' : 'true');
|
|
70
|
+
toggle.textContent = collapsed ? 'Expand' : 'Collapse';
|
|
71
|
+
}
|
|
72
|
+
toggle.addEventListener('click', function () {
|
|
73
|
+
collapsed = !collapsed;
|
|
74
|
+
apply();
|
|
75
|
+
});
|
|
76
|
+
apply();
|
|
77
|
+
|
|
78
|
+
root.appendChild(head);
|
|
79
|
+
root.appendChild(list);
|
|
80
|
+
return root;
|
|
81
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// collapsible-text.js - one-line collapsed view of a multi-line prompt, with a
|
|
2
|
+
// real expand/collapse button. Shared by the pending scheduled-input card and a
|
|
3
|
+
// fired scheduled message, so the two cannot drift apart. The stored text is
|
|
4
|
+
// never cut: the preview carries the first line and CSS truncates it with an
|
|
5
|
+
// ellipsis; the full text stays in the DOM and is only hidden while collapsed.
|
|
6
|
+
// State lives in the closure, so it is per card and gone on reload.
|
|
7
|
+
|
|
8
|
+
// A fired message collapses only when it is long: more than one line, or over
|
|
9
|
+
// this many characters.
|
|
10
|
+
export var COLLAPSE_CHAR_LIMIT = 280;
|
|
11
|
+
|
|
12
|
+
// The turn initiators a scheduled input fires under (lib/turn-initiator.js).
|
|
13
|
+
export function isScheduledInitiator(initiator) {
|
|
14
|
+
return initiator === "scheduled" || initiator === "scheduled-now";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function needsCollapse(text) {
|
|
18
|
+
var s = String(text == null ? "" : text).trim();
|
|
19
|
+
return s.indexOf("\n") !== -1 || s.length > COLLAPSE_CHAR_LIMIT;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// First non-empty line, for the collapsed preview.
|
|
23
|
+
export function firstLine(text) {
|
|
24
|
+
var lines = String(text == null ? "" : text).split(/\r?\n/);
|
|
25
|
+
for (var i = 0; i < lines.length; i++) {
|
|
26
|
+
if (lines[i].trim() !== "") return lines[i];
|
|
27
|
+
}
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Builds { el, button }. `el` holds the preview and the full text; `button`
|
|
32
|
+
// toggles it and is placed by the caller, beside the card's other actions.
|
|
33
|
+
// opts.collapsed: initial state (default true).
|
|
34
|
+
// opts.onChange(collapsed): lets the caller mirror the state on its own
|
|
35
|
+
// container; called once at build and on every toggle.
|
|
36
|
+
export function buildCollapsibleText(text, opts) {
|
|
37
|
+
var collapsed = !(opts && opts.collapsed === false);
|
|
38
|
+
|
|
39
|
+
var el = document.createElement("span");
|
|
40
|
+
el.className = "collapsible-text";
|
|
41
|
+
|
|
42
|
+
// One line of text needs no second copy: the one node is the preview while
|
|
43
|
+
// collapsed (CSS cuts it) and the whole text once expanded. Several lines get
|
|
44
|
+
// a preview node and the full node, one shown at a time.
|
|
45
|
+
var single = String(text == null ? "" : text).indexOf("\n") === -1;
|
|
46
|
+
var preview = document.createElement("span");
|
|
47
|
+
preview.className = "collapsible-preview";
|
|
48
|
+
preview.textContent = single ? text : firstLine(text);
|
|
49
|
+
el.appendChild(preview);
|
|
50
|
+
if (single) {
|
|
51
|
+
el.classList.add("collapsible-single");
|
|
52
|
+
} else {
|
|
53
|
+
var full = document.createElement("span");
|
|
54
|
+
full.className = "collapsible-full";
|
|
55
|
+
full.textContent = text;
|
|
56
|
+
el.appendChild(full);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var button = document.createElement("button");
|
|
60
|
+
button.type = "button";
|
|
61
|
+
button.className = "collapsible-toggle";
|
|
62
|
+
|
|
63
|
+
function apply() {
|
|
64
|
+
el.classList.toggle("is-collapsed", collapsed);
|
|
65
|
+
button.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
66
|
+
button.textContent = collapsed ? "Expand" : "Collapse";
|
|
67
|
+
if (opts && typeof opts.onChange === "function") opts.onChange(collapsed);
|
|
68
|
+
}
|
|
69
|
+
button.addEventListener("click", function (e) {
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
collapsed = !collapsed;
|
|
72
|
+
apply();
|
|
73
|
+
});
|
|
74
|
+
apply();
|
|
75
|
+
|
|
76
|
+
return { el: el, button: button };
|
|
77
|
+
}
|
|
@@ -27,6 +27,7 @@ import { iconHtml, refreshIcons } from './icons.js';
|
|
|
27
27
|
import { formatDiagnosticSource as _formatSource } from './diagnostic-format.js';
|
|
28
28
|
import { sendWs } from './ws-ref.js';
|
|
29
29
|
import { buildUpdateDetailEl } from './build-update-detail.js';
|
|
30
|
+
import { sessionLinesOf, messageWithoutSessions, buildSessionsEl } from './build-update-sessions.js';
|
|
30
31
|
import {
|
|
31
32
|
BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION, noticeKeyOf, cooldownOf, createNoticeGate,
|
|
32
33
|
} from './build-notice-gate.js';
|
|
@@ -477,10 +478,13 @@ function _showDiagnosticToast(entry) {
|
|
|
477
478
|
|
|
478
479
|
var msgEl = document.createElement("div");
|
|
479
480
|
msgEl.className = "toast-diagnostic-msg diagnostic-multiline";
|
|
480
|
-
|
|
481
|
+
var sessionLines = sessionLinesOf(entry.buildUpdate);
|
|
482
|
+
msgEl.textContent = messageWithoutSessions(entry.message, sessionLines);
|
|
481
483
|
|
|
482
484
|
el.appendChild(headerEl);
|
|
483
485
|
el.appendChild(msgEl);
|
|
486
|
+
var sessionsEl = buildSessionsEl(sessionLines);
|
|
487
|
+
if (sessionsEl) el.appendChild(sessionsEl);
|
|
484
488
|
var hasAction = _appendToastActions(el, entry, function () {
|
|
485
489
|
clearTimeout(timer);
|
|
486
490
|
_removeDiagnosticToast(el);
|
|
@@ -587,10 +591,13 @@ function _appendEntry(entry) {
|
|
|
587
591
|
|
|
588
592
|
var msgEl = document.createElement("div");
|
|
589
593
|
msgEl.className = "diagnostics-message diagnostic-multiline";
|
|
590
|
-
|
|
594
|
+
var panelSessionLines = sessionLinesOf(entry.buildUpdate);
|
|
595
|
+
msgEl.textContent = messageWithoutSessions(entry.message, panelSessionLines);
|
|
591
596
|
|
|
592
597
|
item.appendChild(meta);
|
|
593
598
|
item.appendChild(msgEl);
|
|
599
|
+
var panelSessions = buildSessionsEl(panelSessionLines);
|
|
600
|
+
if (panelSessions) item.appendChild(panelSessions);
|
|
594
601
|
var panelDetail = buildUpdateDetailEl(entry.buildUpdate);
|
|
595
602
|
if (panelDetail) item.appendChild(panelDetail);
|
|
596
603
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// env-shadow-notice.js - the warning shown under an environment editor when the
|
|
2
|
+
// Claude user settings file sets a variable the editor also sets. That file
|
|
3
|
+
// wins at the runtime, so the saved value has no effect for those names.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} elementId the notice element
|
|
7
|
+
* @param {?string[]} keys names set in both places (empty or absent hides it unless configDirNote is set)
|
|
8
|
+
* @param {boolean} [configDirNote] the edited text sets CLAUDE_CONFIG_DIR,
|
|
9
|
+
* which the console does not consult: say the check covers one file only
|
|
10
|
+
*/
|
|
11
|
+
export function renderShadowNotice(elementId, keys, configDirNote) {
|
|
12
|
+
var el = document.getElementById(elementId);
|
|
13
|
+
if (!el) return;
|
|
14
|
+
var names = Array.isArray(keys) ? keys : [];
|
|
15
|
+
var scopeNote = "This check covers that user's Claude settings only; a CLAUDE_CONFIG_DIR set here is not consulted.";
|
|
16
|
+
// The scope note matters most when nothing overlaps: the admin would
|
|
17
|
+
// otherwise read the empty result as covering the directory they set.
|
|
18
|
+
if (names.length === 0 && configDirNote) {
|
|
19
|
+
el.textContent = scopeNote;
|
|
20
|
+
el.classList.remove("hidden");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (names.length === 0) {
|
|
24
|
+
el.textContent = "";
|
|
25
|
+
el.classList.add("hidden");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
el.textContent = (names.length === 1 ? "The variable " : "The variables ") + names.join(", ") +
|
|
29
|
+
(names.length === 1 ? " is" : " are") +
|
|
30
|
+
" also set in the Claude settings file of the user running Clagentic: Console. That file wins, so the value saved here has no effect for " +
|
|
31
|
+
(names.length === 1 ? "it." : "them.") +
|
|
32
|
+
(configDirNote ? " " + scopeNote : "");
|
|
33
|
+
el.classList.remove("hidden");
|
|
34
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// keep-alive.js - the operator's per-session keep-alive pin. A pinned session
|
|
2
|
+
// is skipped by the idle reaper, so a coordinator that sits waiting for other
|
|
3
|
+
// sessions' messages is not ended after 30 minutes of silence. Memory pressure
|
|
4
|
+
// can still end it. Shown as a toggle in the session header, a badge on the
|
|
5
|
+
// session lists, and a context menu entry.
|
|
6
|
+
|
|
7
|
+
import { store } from './store.js';
|
|
8
|
+
import { getWs } from './ws-ref.js';
|
|
9
|
+
import { refreshIcons, iconHtml } from './icons.js';
|
|
10
|
+
|
|
11
|
+
var lastSessions = [];
|
|
12
|
+
|
|
13
|
+
export var KEEP_ALIVE_ON_TITLE = "Kept alive: Clagentic: Console will not end this session for being idle. Click to allow idle ending.";
|
|
14
|
+
export var KEEP_ALIVE_OFF_TITLE = "Keep this session alive: stop Clagentic: Console ending it after it sits idle";
|
|
15
|
+
|
|
16
|
+
/** Asks the server to pin or unpin a session. */
|
|
17
|
+
export function sendSessionKeepAlive(sessionId, keepAlive) {
|
|
18
|
+
var ws = getWs();
|
|
19
|
+
if (ws && store.get('connected')) {
|
|
20
|
+
ws.send(JSON.stringify({ type: "set_session_keep_alive", sessionId: sessionId, keepAlive: !!keepAlive }));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** HTML for the pin badge shown on a session row, empty when not pinned. */
|
|
25
|
+
export function keepAliveBadgeHtml(session) {
|
|
26
|
+
if (!session || !session.keepAlive) return "";
|
|
27
|
+
return '<span class="session-keepalive-badge" title="Kept alive: not ended when idle">' + iconHtml("pin") + '</span>';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function activeSession() {
|
|
31
|
+
var activeId = store.get('activeSessionId');
|
|
32
|
+
for (var i = 0; i < lastSessions.length; i++) {
|
|
33
|
+
if (lastSessions[i].id === activeId) return lastSessions[i];
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function paintButton() {
|
|
39
|
+
var btn = document.getElementById("header-keepalive-btn");
|
|
40
|
+
if (!btn) return;
|
|
41
|
+
var s = activeSession();
|
|
42
|
+
var on = !!(s && s.keepAlive);
|
|
43
|
+
btn.classList.toggle("active", on);
|
|
44
|
+
btn.setAttribute("aria-pressed", on ? "true" : "false");
|
|
45
|
+
btn.title = on ? KEEP_ALIVE_ON_TITLE : KEEP_ALIVE_OFF_TITLE;
|
|
46
|
+
btn.classList.toggle("hidden", !s);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Called with every session_list broadcast. */
|
|
50
|
+
export function syncKeepAliveButton(sessions) {
|
|
51
|
+
lastSessions = Array.isArray(sessions) ? sessions : [];
|
|
52
|
+
paintButton();
|
|
53
|
+
refreshIcons();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Wires the header toggle; call once from initHeader. */
|
|
57
|
+
export function initKeepAliveButton() {
|
|
58
|
+
var btn = document.getElementById("header-keepalive-btn");
|
|
59
|
+
if (!btn) return;
|
|
60
|
+
btn.addEventListener("click", function () {
|
|
61
|
+
var s = activeSession();
|
|
62
|
+
if (!s) return;
|
|
63
|
+
sendSessionKeepAlive(s.id, !s.keepAlive);
|
|
64
|
+
});
|
|
65
|
+
store.subscribe(['activeSessionId'], paintButton);
|
|
66
|
+
}
|