@clagentic/console 1.11.0-beta.2 → 1.12.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.
- package/bin/cli.js +12 -1
- package/lib/build-sha.json +2 -2
- package/lib/cli/arg-validation.js +1 -1
- package/lib/cli/ipc-subcommands.js +26 -0
- package/lib/daemon.js +20 -0
- package/lib/notification-prefs.js +255 -0
- package/lib/project-loop.js +3 -6
- package/lib/project-notifications.js +176 -34
- package/lib/project-sessions.js +28 -0
- package/lib/prompt-registry.js +18 -0
- package/lib/prompt-reminders.js +277 -0
- package/lib/public/css/input.css +93 -0
- package/lib/public/css/menus.css +22 -0
- package/lib/public/css/server-settings.css +24 -0
- package/lib/public/css/sidebar.css +17 -0
- package/lib/public/index.html +3 -0
- 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 +29 -3
- package/lib/public/modules/app-rate-limit.js +12 -6
- package/lib/public/modules/app-rendering.js +16 -3
- package/lib/public/modules/collapsible-text.js +77 -0
- package/lib/public/modules/keep-alive.js +66 -0
- package/lib/public/modules/notification-prefs.js +151 -0
- package/lib/public/modules/prompt-reminders-setting.js +13 -0
- package/lib/public/modules/sidebar-mobile.js +8 -0
- package/lib/public/modules/sidebar-sessions.js +27 -0
- package/lib/public/sw.js +7 -1
- package/lib/push-audience.js +84 -0
- package/lib/push.js +24 -1
- package/lib/sdk-bridge.js +27 -12
- package/lib/sdk-message-processor.js +72 -14
- package/lib/sender-ref.js +3 -0
- package/lib/server.js +46 -2
- package/lib/session-input.js +7 -1
- package/lib/sessions.js +27 -0
- package/lib/usage-store.js +381 -0
- package/lib/ws-schema.js +6 -0
- package/lib/yoke/adapters/claude.js +10 -0
- package/lib/yoke/adapters/codex.js +5 -1
- package/package.json +1 -1
package/lib/public/css/input.css
CHANGED
|
@@ -1388,3 +1388,96 @@ body.wide-view .scheduled-msg-wrap .scheduled-msg-countdown {
|
|
|
1388
1388
|
font-size: inherit;
|
|
1389
1389
|
color: inherit;
|
|
1390
1390
|
}
|
|
1391
|
+
|
|
1392
|
+
/* Collapsible text: a pending scheduled input and a long fired one. Collapsed
|
|
1393
|
+
shows the first line only, cut by CSS so the text itself stays whole. */
|
|
1394
|
+
.collapsible-text.is-collapsed .collapsible-full { display: none; }
|
|
1395
|
+
.collapsible-text:not(.is-collapsed):not(.collapsible-single) .collapsible-preview { display: none; }
|
|
1396
|
+
.collapsible-text.is-collapsed .collapsible-preview {
|
|
1397
|
+
display: block;
|
|
1398
|
+
white-space: nowrap;
|
|
1399
|
+
overflow: hidden;
|
|
1400
|
+
text-overflow: ellipsis;
|
|
1401
|
+
}
|
|
1402
|
+
.collapsible-toggle {
|
|
1403
|
+
padding: 0;
|
|
1404
|
+
border: none;
|
|
1405
|
+
background: none;
|
|
1406
|
+
color: var(--accent);
|
|
1407
|
+
font-size: 12px;
|
|
1408
|
+
font-weight: 500;
|
|
1409
|
+
font-family: inherit;
|
|
1410
|
+
cursor: pointer;
|
|
1411
|
+
white-space: nowrap;
|
|
1412
|
+
}
|
|
1413
|
+
.collapsible-toggle:hover { text-decoration: underline; }
|
|
1414
|
+
.collapsible-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
1415
|
+
.collapsible-toggle-fired { align-self: flex-start; margin-top: 2px; }
|
|
1416
|
+
|
|
1417
|
+
/* A collapsed pending card is one row: send time and actions, then the first
|
|
1418
|
+
line taking the rest of the width. Bubble view and channel view. */
|
|
1419
|
+
.scheduled-msg-wrap.is-collapsed:not(.dm-bubble-content) {
|
|
1420
|
+
flex-direction: row;
|
|
1421
|
+
align-items: center;
|
|
1422
|
+
gap: 8px;
|
|
1423
|
+
}
|
|
1424
|
+
.scheduled-msg-wrap.is-collapsed .scheduled-msg-meta { order: -1; flex: 0 1 auto; min-width: 0; padding-right: 0; }
|
|
1425
|
+
.scheduled-msg-wrap.is-collapsed .scheduled-msg-countdown {
|
|
1426
|
+
flex: 0 1 auto;
|
|
1427
|
+
min-width: 0;
|
|
1428
|
+
overflow: hidden;
|
|
1429
|
+
text-overflow: ellipsis;
|
|
1430
|
+
white-space: nowrap;
|
|
1431
|
+
}
|
|
1432
|
+
.scheduled-msg-wrap.is-collapsed .bubble {
|
|
1433
|
+
flex: 1 1 0;
|
|
1434
|
+
min-width: 0;
|
|
1435
|
+
max-width: none;
|
|
1436
|
+
padding: 4px 12px;
|
|
1437
|
+
}
|
|
1438
|
+
.scheduled-msg-wrap.is-collapsed .dm-bubble-content {
|
|
1439
|
+
flex-direction: row;
|
|
1440
|
+
align-items: center;
|
|
1441
|
+
gap: 8px;
|
|
1442
|
+
min-width: 0;
|
|
1443
|
+
flex: 1 1 0;
|
|
1444
|
+
}
|
|
1445
|
+
.scheduled-msg-wrap.is-collapsed .dm-bubble-header { flex: 0 1 auto; min-width: 0; }
|
|
1446
|
+
|
|
1447
|
+
.scheduled-msg-wrap.is-collapsed .scheduled-msg-send-now,
|
|
1448
|
+
.scheduled-msg-wrap.is-collapsed .scheduled-msg-cancel,
|
|
1449
|
+
.scheduled-msg-wrap.is-collapsed .scheduled-msg-sep { white-space: nowrap; flex: none; }
|
|
1450
|
+
.scheduled-msg-wrap.is-collapsed .scheduled-msg-actions { flex: none; margin-left: 0; }
|
|
1451
|
+
.scheduled-msg-wrap.is-collapsed .scheduled-msg-badge { min-width: 0; flex: 0 1 auto; padding: 3px 8px; }
|
|
1452
|
+
.scheduled-msg-wrap.is-collapsed .collapsible-toggle { flex: none; }
|
|
1453
|
+
|
|
1454
|
+
/* Phone widths: index.html pins the narrow-screen column layout of user rows
|
|
1455
|
+
with !important, so the collapsed card overrides it the same way, scoped to
|
|
1456
|
+
itself. A 390px row cannot hold the send time, three actions and a readable
|
|
1457
|
+
prompt, so the card is two compact rows: send time and actions, then the
|
|
1458
|
+
prompt's first line across the full width. */
|
|
1459
|
+
@media (max-width: 768px) {
|
|
1460
|
+
body.wide-view .msg-user.scheduled-msg-wrap.is-collapsed {
|
|
1461
|
+
gap: 0 !important;
|
|
1462
|
+
align-items: stretch !important;
|
|
1463
|
+
}
|
|
1464
|
+
body.wide-view .msg-user.scheduled-msg-wrap.is-collapsed > .dm-bubble-avatar { display: none !important; }
|
|
1465
|
+
body.wide-view .msg-user.scheduled-msg-wrap.is-collapsed .dm-bubble-content {
|
|
1466
|
+
flex-direction: column !important;
|
|
1467
|
+
align-items: stretch !important;
|
|
1468
|
+
gap: 2px !important;
|
|
1469
|
+
min-width: 0 !important;
|
|
1470
|
+
width: 100% !important;
|
|
1471
|
+
}
|
|
1472
|
+
body.wide-view .msg-user.scheduled-msg-wrap.is-collapsed .dm-bubble-name { display: none; }
|
|
1473
|
+
body.wide-view .msg-user.scheduled-msg-wrap.is-collapsed .dm-bubble-header { flex-wrap: nowrap; }
|
|
1474
|
+
body.wide-view .msg-user.scheduled-msg-wrap.is-collapsed .bubble {
|
|
1475
|
+
flex: none !important;
|
|
1476
|
+
max-width: 100% !important;
|
|
1477
|
+
width: auto !important;
|
|
1478
|
+
padding: 0 !important;
|
|
1479
|
+
background: none !important;
|
|
1480
|
+
border: none !important;
|
|
1481
|
+
border-radius: 0 !important;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
package/lib/public/css/menus.css
CHANGED
|
@@ -43,6 +43,28 @@
|
|
|
43
43
|
#header-rename-btn:hover { color: var(--text-secondary); background: rgba(var(--overlay-rgb),0.04); border-color: var(--border); }
|
|
44
44
|
#header-rename-btn .lucide { width: 13px; height: 13px; }
|
|
45
45
|
|
|
46
|
+
#header-keepalive-btn {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
width: 24px;
|
|
51
|
+
height: 24px;
|
|
52
|
+
border: 1px solid transparent;
|
|
53
|
+
background: none;
|
|
54
|
+
color: var(--text-dimmer);
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
border-radius: 8px;
|
|
57
|
+
flex-shrink: 0;
|
|
58
|
+
padding: 0;
|
|
59
|
+
margin-left: 4px;
|
|
60
|
+
transition: color 0.15s, background 0.15s, border-color 0.15s;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#header-keepalive-btn.hidden { display: none; }
|
|
64
|
+
#header-keepalive-btn:hover { color: var(--text-secondary); background: rgba(var(--overlay-rgb),0.04); border-color: var(--border); }
|
|
65
|
+
#header-keepalive-btn.active { color: var(--accent, #63b3ed); }
|
|
66
|
+
#header-keepalive-btn .lucide { width: 13px; height: 13px; }
|
|
67
|
+
|
|
46
68
|
#header-info-btn {
|
|
47
69
|
display: flex;
|
|
48
70
|
align-items: center;
|
|
@@ -1253,3 +1253,27 @@
|
|
|
1253
1253
|
margin-top: 4px;
|
|
1254
1254
|
}
|
|
1255
1255
|
|
|
1256
|
+
|
|
1257
|
+
/* Per-type notification preferences (modules/notification-prefs.js) */
|
|
1258
|
+
.settings-subheading {
|
|
1259
|
+
margin: 16px 0 8px;
|
|
1260
|
+
font-size: 14px;
|
|
1261
|
+
font-weight: 600;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
.notif-prefs-grid {
|
|
1265
|
+
width: 100%;
|
|
1266
|
+
border-collapse: collapse;
|
|
1267
|
+
margin-top: 8px;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
.notif-prefs-grid th,
|
|
1271
|
+
.notif-prefs-grid td {
|
|
1272
|
+
padding: 6px 8px;
|
|
1273
|
+
text-align: center;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
.notif-prefs-grid th:first-child,
|
|
1277
|
+
.notif-prefs-grid td:first-child {
|
|
1278
|
+
text-align: left;
|
|
1279
|
+
}
|
|
@@ -2025,3 +2025,20 @@
|
|
|
2025
2025
|
50% { opacity: 0.18; }
|
|
2026
2026
|
100% { opacity: 0.1; }
|
|
2027
2027
|
}
|
|
2028
|
+
|
|
2029
|
+
/* Pin shown on a session the operator has kept alive past the idle reaper. */
|
|
2030
|
+
.session-item .session-keepalive-badge,
|
|
2031
|
+
.mobile-session-item .session-keepalive-badge {
|
|
2032
|
+
display: inline-flex;
|
|
2033
|
+
align-items: center;
|
|
2034
|
+
justify-content: center;
|
|
2035
|
+
color: var(--accent, #63b3ed);
|
|
2036
|
+
margin-right: 4px;
|
|
2037
|
+
vertical-align: middle;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
.session-item .session-keepalive-badge i,
|
|
2041
|
+
.mobile-session-item .session-keepalive-badge i {
|
|
2042
|
+
width: 12px;
|
|
2043
|
+
height: 12px;
|
|
2044
|
+
}
|
package/lib/public/index.html
CHANGED
|
@@ -268,6 +268,7 @@
|
|
|
268
268
|
<span class="header-title" id="header-title">Connecting...</span>
|
|
269
269
|
<button id="header-info-btn" type="button" title="Session info"><i data-lucide="info"></i></button>
|
|
270
270
|
<button id="header-rename-btn" type="button" title="Rename session"><i data-lucide="pencil"></i></button>
|
|
271
|
+
<button id="header-keepalive-btn" type="button" class="hidden" aria-pressed="false" title="Keep this session alive"><i data-lucide="pin"></i></button>
|
|
271
272
|
</div>
|
|
272
273
|
<div id="todo-sticky" class="hidden"></div>
|
|
273
274
|
<div id="ralph-sticky" class="hidden"></div>
|
|
@@ -1300,6 +1301,8 @@
|
|
|
1300
1301
|
<span class="toggle-track"><span class="toggle-thumb"></span></span>
|
|
1301
1302
|
</label>
|
|
1302
1303
|
</div>
|
|
1304
|
+
<h3 class="settings-subheading">What to notify you about</h3>
|
|
1305
|
+
<div class="settings-card" id="notif-prefs-card"></div>
|
|
1303
1306
|
</div>
|
|
1304
1307
|
<div class="server-settings-section" data-section="claudemd">
|
|
1305
1308
|
<h2>CLAUDE.md</h2>
|
|
@@ -12,6 +12,7 @@ import { saveToolState, resetToolState, restoreToolState } from './tools.js';
|
|
|
12
12
|
import { getSessionUsage, setSessionUsage, getContextData, setContextData, updateContextPanel, updateUsagePanel } from './app-panels.js';
|
|
13
13
|
import { onHistoryPrepended as onSessionSearchHistoryPrepended } from './session-search.js';
|
|
14
14
|
import { positionPopover } from './popover-position.js';
|
|
15
|
+
import { initKeepAliveButton } from './keep-alive.js';
|
|
15
16
|
|
|
16
17
|
// --- Module-owned state ---
|
|
17
18
|
var sessionInfoPopover = null;
|
|
@@ -21,6 +22,7 @@ export function initHeader() {
|
|
|
21
22
|
var headerRenameBtn = document.getElementById("header-rename-btn");
|
|
22
23
|
var headerTitleEl = document.getElementById("header-title");
|
|
23
24
|
var headerInfoBtn = document.getElementById("header-info-btn");
|
|
25
|
+
initKeepAliveButton();
|
|
24
26
|
|
|
25
27
|
// --- Header session rename ---
|
|
26
28
|
if (headerRenameBtn) {
|
|
@@ -27,6 +27,7 @@ import { getWs } from './ws-ref.js';
|
|
|
27
27
|
import { showToast } from './utils.js';
|
|
28
28
|
import { refreshIcons, iconHtml } from './icons.js';
|
|
29
29
|
import { updatePageTitle } from './sidebar.js';
|
|
30
|
+
import { syncKeepAliveButton } from './keep-alive.js';
|
|
30
31
|
import { renderSessionList, updateSessionPresence, populateCliSessionList, handleSearchResults, updateSessionBadge } from './sidebar-sessions.js';
|
|
31
32
|
import { updateDmBadge, renderSidebarPresence, setMentionActive } from './sidebar-users.js';
|
|
32
33
|
import { refreshMobileChatSheet } from './sidebar-mobile.js';
|
|
@@ -37,6 +38,7 @@ import { handleFindInSessionResults } from './session-search.js';
|
|
|
37
38
|
import { handleInputSync, autoResize, resetAutoResize, builtinCommands } from './input.js';
|
|
38
39
|
import { startThinking, appendThinking, stopThinking, resetThinkingGroup, createToolItem, updateToolExecuting, updateToolResult, markAllToolsDone, closeToolGroup, removeToolFromGroup, resetToolState, getTools, getPlanContent, setPlanContent, renderPlanBanner, renderPlanCard, getTodoTools, handleTodoWrite, handleTaskCreate, handleTaskUpdate, applyDeadSessionTodoCompaction, isPlanFilePath, enableMainInput, addTurnMeta, updateSubagentActivity, addSubagentToolEntry, markSubagentDone, initSubagentStop, updateSubagentProgress, updateSubagentTaskStatus, applyPromptMessage, hasPendingPrompts } from './tools.js';
|
|
39
40
|
import { showDoneNotification, playDoneSound, isNotifAlertEnabled, isNotifSoundEnabled } from './notifications.js';
|
|
41
|
+
import { handleNotificationPrefs, isSurfaceWanted } from './notification-prefs.js';
|
|
40
42
|
import { handleFsRead, refreshIfOpen } from './filebrowser.js';
|
|
41
43
|
import { isProjectSettingsOpen, refreshProjectSettingsModels, handleInstructionsRead, handleInstructionsWrite, handleProjectEnv, handleProjectEnvSaved, handleProjectSharedEnv, handleProjectSharedEnvSaved, handleProjectOwnerChanged, updateLiteVisibility, handleLiteProjectStatus, handleLiteEnrollResult, handleLiteUnenrollResult } from './project-settings.js';
|
|
42
44
|
import { updateSettingsModels, updateSettingsStats, updateDaemonConfig, handleSharedEnv, handleSharedEnvSaved, updateSsLiteVisibility } from './server-settings.js';
|
|
@@ -393,6 +395,7 @@ registerHandlers({
|
|
|
393
395
|
|
|
394
396
|
session_list: function (msg) {
|
|
395
397
|
renderSessionList(msg.sessions || []);
|
|
398
|
+
syncKeepAliveButton(msg.sessions || []);
|
|
396
399
|
handlePaletteSessionSwitch();
|
|
397
400
|
// lr-5edd64: 'processing' (the transcript footer's field) is now a pure
|
|
398
401
|
// PROJECTION of server-authoritative per-session state — nothing writes
|
|
@@ -959,8 +962,8 @@ registerHandlers({
|
|
|
959
962
|
resetToolState();
|
|
960
963
|
syncUrgentBlink();
|
|
961
964
|
if (document.hidden) {
|
|
962
|
-
if (isNotifAlertEnabled() && !window._pushSubscription) showDoneNotification();
|
|
963
|
-
if (isNotifSoundEnabled()) playDoneSound();
|
|
965
|
+
if (isNotifAlertEnabled() && !window._pushSubscription && isSurfaceWanted("banner", "turn_done")) showDoneNotification();
|
|
966
|
+
if (isNotifSoundEnabled() && isSurfaceWanted("sound", "turn_done")) playDoneSound();
|
|
964
967
|
}
|
|
965
968
|
},
|
|
966
969
|
|
|
@@ -1476,6 +1479,7 @@ registerHandlers({
|
|
|
1476
1479
|
// --- Notifications ---
|
|
1477
1480
|
notifications_state: handleNotificationsState,
|
|
1478
1481
|
notification_created: handleNotificationCreated,
|
|
1482
|
+
notification_prefs: handleNotificationPrefs,
|
|
1479
1483
|
notification_dismissed: handleNotificationDismissed,
|
|
1480
1484
|
|
|
1481
1485
|
notification_dismissed_all: function (msg) {
|
|
@@ -15,6 +15,8 @@ import { openTerminal } from './terminal.js';
|
|
|
15
15
|
import { askWording } from './prompt-kinds/index.js';
|
|
16
16
|
import { wirePromptBanner, restoreUnconfirmedBanners, bannerActions } from './prompt-banner.js';
|
|
17
17
|
import { promptLabelHtml } from './prompt-label.js';
|
|
18
|
+
import { isSurfaceWanted, shouldChimeForNotification } from './notification-prefs.js';
|
|
19
|
+
import { playDoneSound, isNotifSoundEnabled } from './notifications.js';
|
|
18
20
|
|
|
19
21
|
// The server dismisses a prompt's banner once the prompt settles, however it
|
|
20
22
|
// was answered.
|
|
@@ -95,13 +97,15 @@ function showBanner(notif, autoDismissMs) {
|
|
|
95
97
|
var isPermission = notif.type === "permission_request" && notif.meta && notif.meta.requestId;
|
|
96
98
|
var isAuthRequired = notif.type === "auth_required";
|
|
97
99
|
var isUserMention = notif.type === "user_mention";
|
|
100
|
+
var isReminder = notif.type === "permission_reminder";
|
|
98
101
|
var projectIcon = isEmpty ? null : getProjectIcon(notif.slug);
|
|
99
102
|
var projectName = isEmpty ? "" : (isAuthRequired ? "CLAGENTIC" : getProjectName(notif.slug));
|
|
100
103
|
var userMentionAvatarSrc = isUserMention ? buildUserMentionAvatarSrc(notif) : null;
|
|
101
104
|
|
|
102
105
|
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" : "");
|
|
106
|
+
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
107
|
if (!isEmpty) banner.setAttribute("data-notif-id", notif.id);
|
|
108
|
+
if (!isEmpty && notif.type) banner.setAttribute("data-notif-type", notif.type);
|
|
105
109
|
if (isAuthRequired) banner.setAttribute("data-auth-banner", "true");
|
|
106
110
|
|
|
107
111
|
var iconHtmlStr = userMentionAvatarSrc
|
|
@@ -404,6 +408,7 @@ export function handleNotificationsState(msg) {
|
|
|
404
408
|
notifications = msg.notifications || [];
|
|
405
409
|
unreadCount = msg.unreadCount || 0;
|
|
406
410
|
updateBadge();
|
|
411
|
+
dropBannersOfEndedPrompts();
|
|
407
412
|
|
|
408
413
|
// Check for pending session navigation after project switch
|
|
409
414
|
try {
|
|
@@ -418,6 +423,20 @@ export function handleNotificationsState(msg) {
|
|
|
418
423
|
} catch (e) {}
|
|
419
424
|
}
|
|
420
425
|
|
|
426
|
+
// A prompt banner and a reminder are tied to a live prompt. The server's list
|
|
427
|
+
// (sent on every connect) is the truth: after a daemon restart no prompt
|
|
428
|
+
// survives, and the dismissals were sent to a connection that was gone, so
|
|
429
|
+
// banners it no longer lists are removed.
|
|
430
|
+
function dropBannersOfEndedPrompts() {
|
|
431
|
+
if (!bannerContainer) return;
|
|
432
|
+
var live = Object.create(null);
|
|
433
|
+
notifications.forEach(function (n) { live[n.id] = true; });
|
|
434
|
+
var banners = bannerContainer.querySelectorAll('.notif-banner[data-notif-type="permission_request"], .notif-banner[data-notif-type="permission_reminder"]');
|
|
435
|
+
for (var i = 0; i < banners.length; i++) {
|
|
436
|
+
if (!live[banners[i].getAttribute("data-notif-id")]) removeBanner(banners[i]);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
421
440
|
export function handleNotificationCreated(msg) {
|
|
422
441
|
var notif = msg.notification;
|
|
423
442
|
|
|
@@ -441,8 +460,15 @@ export function handleNotificationCreated(msg) {
|
|
|
441
460
|
// activeSessionId match, OR
|
|
442
461
|
// 3. The user clicks the X close button.
|
|
443
462
|
// Permission and auth banners are also persistent for the same UX reason.
|
|
444
|
-
|
|
445
|
-
|
|
463
|
+
// A reminder stays until its prompt is answered, or the next one replaces it.
|
|
464
|
+
var _autoDismiss = (notif.type === "permission_request" || notif.type === "permission_reminder" || notif.type === "auth_required" || notif.type === "user_mention") ? false : true;
|
|
465
|
+
|
|
466
|
+
// The user's per-type choices (lib/notification-prefs.js). A muted type has
|
|
467
|
+
// still been added to the list and counted above: only the alert and the
|
|
468
|
+
// sound are skipped. A sound plays only while the page is hidden, like the
|
|
469
|
+
// finished turn's own chime.
|
|
470
|
+
if (isSurfaceWanted("banner", notif.category)) showBanner(notif, _autoDismiss);
|
|
471
|
+
if (shouldChimeForNotification(notif, isNotifSoundEnabled())) playDoneSound();
|
|
446
472
|
}
|
|
447
473
|
|
|
448
474
|
export function handleNotificationDismissed(msg) {
|
|
@@ -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';
|
|
@@ -538,10 +539,18 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName, i
|
|
|
538
539
|
bubble.appendChild(pasteRow);
|
|
539
540
|
}
|
|
540
541
|
|
|
542
|
+
// A long scheduled input that has fired collapses like its pending card did.
|
|
543
|
+
// Labelling of injected input is untouched; only the text node is swapped.
|
|
544
|
+
var firedCollapse = null;
|
|
541
545
|
if (text) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
546
|
+
if (injected && isScheduledInitiator(injected.initiator) && needsCollapse(text)) {
|
|
547
|
+
firedCollapse = buildCollapsibleText(text);
|
|
548
|
+
bubble.appendChild(firedCollapse.el);
|
|
549
|
+
} else {
|
|
550
|
+
var textEl = document.createElement("span");
|
|
551
|
+
textEl.textContent = text;
|
|
552
|
+
bubble.appendChild(textEl);
|
|
553
|
+
}
|
|
545
554
|
}
|
|
546
555
|
|
|
547
556
|
|
|
@@ -607,6 +616,10 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName, i
|
|
|
607
616
|
}
|
|
608
617
|
}
|
|
609
618
|
contentWrap.appendChild(bubble);
|
|
619
|
+
if (firedCollapse) {
|
|
620
|
+
firedCollapse.button.classList.add("collapsible-toggle-fired");
|
|
621
|
+
contentWrap.appendChild(firedCollapse.button);
|
|
622
|
+
}
|
|
610
623
|
div.appendChild(contentWrap);
|
|
611
624
|
|
|
612
625
|
var actions = document.createElement("div");
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|