@clagentic/console 1.10.0-beta.4 → 1.11.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/README.md +14 -0
- package/bin/cli.js +15 -3
- package/lib/agents.js +1 -55
- package/lib/bash-auto-approve.js +133 -0
- package/lib/build-identity.js +23 -5
- package/lib/build-sha.json +2 -2
- package/lib/build-update-check.js +0 -62
- package/lib/build-update-offer.js +23 -13
- package/lib/build-update-restart.js +59 -43
- package/lib/cli/schedule-input-subcommands.js +327 -0
- package/lib/cli/session-subcommands.js +100 -17
- package/lib/client-build-id.js +56 -0
- package/lib/daemon.js +20 -5
- package/lib/injected-sender.js +225 -0
- package/lib/message-sender-record.js +133 -0
- package/lib/pending-prompts.js +55 -0
- package/lib/permission-mode-policy.js +63 -0
- package/lib/permission-summary.js +67 -0
- package/lib/project-connection.js +2 -1
- package/lib/project-external-trigger.js +9 -1
- package/lib/project-loop.js +26 -20
- package/lib/project-prompt-responses.js +20 -14
- package/lib/project-sessions.js +73 -21
- package/lib/project-user-message.js +18 -47
- package/lib/project.js +36 -62
- package/lib/public/app.js +3 -5
- package/lib/public/css/channel-layout.css +20 -0
- package/lib/public/css/diagnostics.css +7 -0
- package/lib/public/css/input.css +78 -0
- package/lib/public/css/menus.css +17 -0
- package/lib/public/modules/app-connection.js +18 -1
- package/lib/public/modules/app-messages.js +19 -17
- package/lib/public/modules/app-panels.js +9 -2
- package/lib/public/modules/app-rate-limit.js +63 -87
- package/lib/public/modules/app-rendering.js +37 -6
- package/lib/public/modules/at-agents.js +8 -0
- package/lib/public/modules/build-guard.js +61 -0
- package/lib/public/modules/build-update-detail.js +1 -4
- package/lib/public/modules/diagnostics.js +98 -9
- package/lib/public/modules/injected-identity.js +78 -0
- package/lib/public/modules/injected-label.js +62 -0
- package/lib/public/modules/input.js +64 -114
- package/lib/public/modules/mode-options.js +19 -16
- package/lib/public/modules/rate-limit-state.js +47 -22
- package/lib/public/modules/schedule-panel.js +234 -0
- package/lib/public/modules/schedule-time.js +193 -0
- package/lib/public/modules/scheduled-input-actions.js +19 -0
- package/lib/runtime-env.js +4 -0
- package/lib/scheduled-input/ipc.js +92 -0
- package/lib/scheduled-input/rate-limit-resume.js +53 -0
- package/lib/scheduled-input/records.js +350 -0
- package/lib/scheduled-input/service.js +743 -0
- package/lib/scheduled-input/store.js +132 -0
- package/lib/scheduled-input/ws.js +194 -0
- package/lib/sdk-bridge.js +137 -152
- package/lib/sdk-message-processor.js +13 -5
- package/lib/sdk-skill-discovery.js +17 -0
- package/lib/sender-ref.js +109 -0
- package/lib/server.js +28 -8
- package/lib/session-directory.js +224 -0
- package/lib/session-file-scan.js +55 -0
- package/lib/session-input-ipc.js +20 -0
- package/lib/session-input.js +355 -19
- package/lib/session-name-holder.js +82 -0
- package/lib/session-resume.js +1 -0
- package/lib/sessions.js +44 -0
- package/lib/turn-initiator.js +6 -2
- package/lib/ws-schema.js +15 -7
- package/lib/yoke/adapters/claude-worker.js +3 -1
- package/lib/yoke/adapters/claude.js +13 -7
- package/lib/yoke/adapters/codex.js +18 -5
- package/lib/yoke/adapters/permission-relay.js +9 -0
- package/lib/yoke/interface.js +7 -1
- package/package.json +1 -1
- package/scripts/check-test-count.js +1 -1
- package/scripts/install-local-test.js +45 -1
- package/scripts/postinstall.js +1 -0
|
@@ -3,22 +3,23 @@
|
|
|
3
3
|
|
|
4
4
|
import { iconHtml, refreshIcons } from './icons.js';
|
|
5
5
|
import { store } from './store.js';
|
|
6
|
-
import { getWs } from './ws-ref.js';
|
|
7
6
|
import { addToMessages, scrollToBottom } from './app-rendering.js';
|
|
8
7
|
import { userAvatarUrl } from './avatar.js';
|
|
9
|
-
import { clearScheduleDelay, setScheduleDelayForSession, clearScheduleDelayForSession, restoreScheduleDelayUi } from './input.js';
|
|
8
|
+
import { clearScheduleDelay, setScheduleDelayForSession, clearScheduleDelayForSession, restoreScheduleDelayUi, refreshScheduleControls } from './input.js';
|
|
10
9
|
import { isSonnetModel, isOpusModel } from './model-families.js';
|
|
11
10
|
import {
|
|
12
11
|
getRateLimitResetsAt, setRateLimitResetsAt,
|
|
13
12
|
getRateLimitResetTimer, setRateLimitResetTimer,
|
|
14
13
|
getRateLimitResetState,
|
|
15
|
-
|
|
14
|
+
setScheduledInputs, getScheduledInputs,
|
|
16
15
|
clearSession as clearSessionRateLimitState,
|
|
17
16
|
} from './rate-limit-state.js';
|
|
17
|
+
import { countdownText } from './schedule-time.js';
|
|
18
|
+
import { sendScheduledNow, cancelScheduledInput, requestScheduledInputList } from './scheduled-input-actions.js';
|
|
18
19
|
|
|
19
20
|
// --- Module-owned state ---
|
|
20
21
|
// lr-0827ba: rateLimitResetsAt / rateLimitResetTimer / rateLimitResetState /
|
|
21
|
-
// the scheduled
|
|
22
|
+
// the session's scheduled inputs are now owned per-session by
|
|
22
23
|
// rate-limit-state.js (see imports above) — arming one project's rate-limit
|
|
23
24
|
// auto-schedule no longer clobbers another project's armed state. The
|
|
24
25
|
// variables below remain module-scoped because they are references to the
|
|
@@ -29,8 +30,11 @@ var rateLimitIndicatorEl = null;
|
|
|
29
30
|
var rateLimitUsageEl = null;
|
|
30
31
|
var rateLimitTickTimer = null;
|
|
31
32
|
var _rateLimitUsageLastHtml = null; // guard against redundant innerHTML + refreshIcons()
|
|
33
|
+
// The scheduled-message bubbles of the session on screen share one container;
|
|
34
|
+
// each has a countdown the one interval below keeps current.
|
|
32
35
|
var scheduledMsgEl = null;
|
|
33
36
|
var scheduledCountdownTimer = null;
|
|
37
|
+
var scheduledCountdowns = [];
|
|
34
38
|
var fastModeIndicatorEl = null;
|
|
35
39
|
|
|
36
40
|
function currentSessionId() {
|
|
@@ -233,7 +237,7 @@ export function handleRateLimitEvent(msg) {
|
|
|
233
237
|
// that gets its schedule armed, NOT necessarily the currently-focused
|
|
234
238
|
// session — a rate limit hit in a background session must still arm that
|
|
235
239
|
// session's auto-schedule and keep its reset timer running, exactly like
|
|
236
|
-
// server-
|
|
240
|
+
// the server's per-session scheduled inputs do. Fall back to the
|
|
237
241
|
// active session for events from servers/replays that predate the localId
|
|
238
242
|
// stamp (older recorded history entries).
|
|
239
243
|
var eventSessionId = msg.localId != null ? msg.localId : currentSessionId();
|
|
@@ -365,22 +369,49 @@ export function updateRateLimitUsage(msg) {
|
|
|
365
369
|
}
|
|
366
370
|
}
|
|
367
371
|
|
|
368
|
-
//
|
|
369
|
-
//
|
|
370
|
-
//
|
|
371
|
-
//
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
372
|
+
// The server's list of a session's armed scheduled inputs is the only source of
|
|
373
|
+
// the bubbles, the panel list and the clock button's state. msg.localId names
|
|
374
|
+
// the session the list belongs to (lr-0827ba): it may not be the one on screen,
|
|
375
|
+
// so it is stored either way and switching back in finds it, and only the
|
|
376
|
+
// session on screen is drawn, never into another session's message list.
|
|
377
|
+
export function applyScheduledInputList(msg) {
|
|
378
|
+
var targetSessionId = msg.localId != null ? msg.localId : currentSessionId();
|
|
379
|
+
setScheduledInputs(targetSessionId, msg.inputs, msg.limit);
|
|
380
|
+
refreshScheduleControls();
|
|
381
|
+
if (targetSessionId === currentSessionId()) renderScheduledBubbles(targetSessionId);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Draws one bubble per armed input of the session on screen, in one container
|
|
385
|
+
// so the message list keeps them together at its end.
|
|
386
|
+
function renderScheduledBubbles(sessionId) {
|
|
379
387
|
removeScheduledMessageBubble();
|
|
388
|
+
var inputs = getScheduledInputs(sessionId);
|
|
389
|
+
if (inputs.length === 0) return;
|
|
390
|
+
var container = document.createElement("div");
|
|
391
|
+
container.className = "scheduled-msgs";
|
|
392
|
+
inputs.forEach(function (input) {
|
|
393
|
+
var built = buildScheduledBubble(input);
|
|
394
|
+
container.appendChild(built.wrap);
|
|
395
|
+
scheduledCountdowns.push({ el: built.countdownEl, input: input });
|
|
396
|
+
});
|
|
397
|
+
addToMessages(container);
|
|
398
|
+
scheduledMsgEl = container;
|
|
399
|
+
scrollToBottom();
|
|
400
|
+
updateScheduledCountdowns();
|
|
401
|
+
scheduledCountdownTimer = setInterval(updateScheduledCountdowns, 1000);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function updateScheduledCountdowns() {
|
|
405
|
+
var now = Date.now();
|
|
406
|
+
scheduledCountdowns.forEach(function (c) { c.el.textContent = countdownText(c.input, now); });
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function buildScheduledBubble(input) {
|
|
410
|
+
var text = input.text;
|
|
380
411
|
var isChannel = document.body.classList.contains("wide-view");
|
|
381
412
|
var wrap = document.createElement("div");
|
|
382
413
|
wrap.className = "msg-user scheduled-msg-wrap";
|
|
383
|
-
wrap.
|
|
414
|
+
wrap.setAttribute("data-id", input.id);
|
|
384
415
|
|
|
385
416
|
var countdownEl;
|
|
386
417
|
var cancelBtn;
|
|
@@ -421,12 +452,7 @@ export function addScheduledMessageBubble(text, resetsAt, sessionId) {
|
|
|
421
452
|
var sendNowBtn = document.createElement("button");
|
|
422
453
|
sendNowBtn.className = "scheduled-msg-send-now";
|
|
423
454
|
sendNowBtn.textContent = "Send now";
|
|
424
|
-
sendNowBtn.addEventListener("click", function () {
|
|
425
|
-
var ws = getWs();
|
|
426
|
-
if (ws && ws.readyState === 1) {
|
|
427
|
-
ws.send(JSON.stringify({ type: "send_scheduled_now" }));
|
|
428
|
-
}
|
|
429
|
-
});
|
|
455
|
+
sendNowBtn.addEventListener("click", function () { sendScheduledNow(input.id); });
|
|
430
456
|
actions.appendChild(sendNowBtn);
|
|
431
457
|
|
|
432
458
|
var sep = document.createElement("span");
|
|
@@ -437,12 +463,7 @@ export function addScheduledMessageBubble(text, resetsAt, sessionId) {
|
|
|
437
463
|
cancelBtn = document.createElement("button");
|
|
438
464
|
cancelBtn.className = "scheduled-msg-cancel";
|
|
439
465
|
cancelBtn.textContent = "Cancel";
|
|
440
|
-
cancelBtn.addEventListener("click", function () {
|
|
441
|
-
var ws = getWs();
|
|
442
|
-
if (ws && ws.readyState === 1) {
|
|
443
|
-
ws.send(JSON.stringify({ type: "cancel_scheduled_message" }));
|
|
444
|
-
}
|
|
445
|
-
});
|
|
466
|
+
cancelBtn.addEventListener("click", function () { cancelScheduledInput(input.id); });
|
|
446
467
|
actions.appendChild(cancelBtn);
|
|
447
468
|
|
|
448
469
|
header.appendChild(actions);
|
|
@@ -481,12 +502,7 @@ export function addScheduledMessageBubble(text, resetsAt, sessionId) {
|
|
|
481
502
|
var sendNowBtn2 = document.createElement("button");
|
|
482
503
|
sendNowBtn2.className = "scheduled-msg-send-now";
|
|
483
504
|
sendNowBtn2.textContent = "Send now";
|
|
484
|
-
sendNowBtn2.addEventListener("click", function () {
|
|
485
|
-
var ws = getWs();
|
|
486
|
-
if (ws && ws.readyState === 1) {
|
|
487
|
-
ws.send(JSON.stringify({ type: "send_scheduled_now" }));
|
|
488
|
-
}
|
|
489
|
-
});
|
|
505
|
+
sendNowBtn2.addEventListener("click", function () { sendScheduledNow(input.id); });
|
|
490
506
|
metaEl.appendChild(sendNowBtn2);
|
|
491
507
|
|
|
492
508
|
var sep2 = document.createElement("span");
|
|
@@ -497,71 +513,31 @@ export function addScheduledMessageBubble(text, resetsAt, sessionId) {
|
|
|
497
513
|
cancelBtn = document.createElement("button");
|
|
498
514
|
cancelBtn.className = "scheduled-msg-cancel";
|
|
499
515
|
cancelBtn.textContent = "Cancel";
|
|
500
|
-
cancelBtn.addEventListener("click", function () {
|
|
501
|
-
var ws = getWs();
|
|
502
|
-
if (ws && ws.readyState === 1) {
|
|
503
|
-
ws.send(JSON.stringify({ type: "cancel_scheduled_message" }));
|
|
504
|
-
}
|
|
505
|
-
});
|
|
516
|
+
cancelBtn.addEventListener("click", function () { cancelScheduledInput(input.id); });
|
|
506
517
|
metaEl.appendChild(cancelBtn);
|
|
507
518
|
|
|
508
519
|
wrap.appendChild(bubble);
|
|
509
520
|
wrap.appendChild(metaEl);
|
|
510
521
|
}
|
|
511
522
|
|
|
512
|
-
|
|
513
|
-
scheduledMsgEl = wrap;
|
|
514
|
-
scrollToBottom();
|
|
515
|
-
|
|
516
|
-
// Start countdown
|
|
517
|
-
function updateCountdown() {
|
|
518
|
-
var remaining = resetsAt - Date.now();
|
|
519
|
-
if (remaining <= 0) {
|
|
520
|
-
countdownEl.textContent = "Sending...";
|
|
521
|
-
if (scheduledCountdownTimer) { clearInterval(scheduledCountdownTimer); scheduledCountdownTimer = null; }
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
var hrs = Math.floor(remaining / 3600000);
|
|
525
|
-
var mins = Math.floor((remaining % 3600000) / 60000);
|
|
526
|
-
var secs = Math.floor((remaining % 60000) / 1000);
|
|
527
|
-
var timeStr = "";
|
|
528
|
-
if (hrs > 0) timeStr += hrs + "h ";
|
|
529
|
-
if (mins > 0 || hrs > 0) timeStr += mins + "m ";
|
|
530
|
-
timeStr += secs + "s";
|
|
531
|
-
|
|
532
|
-
var sendDate = new Date(resetsAt);
|
|
533
|
-
var absTime = sendDate.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
534
|
-
countdownEl.textContent = "Sends at " + absTime + " (" + timeStr + ")";
|
|
535
|
-
}
|
|
536
|
-
updateCountdown();
|
|
537
|
-
scheduledCountdownTimer = setInterval(updateCountdown, 1000);
|
|
523
|
+
return { wrap: wrap, countdownEl: countdownEl };
|
|
538
524
|
}
|
|
539
525
|
|
|
540
|
-
// Clears the visible DOM
|
|
541
|
-
//
|
|
542
|
-
//
|
|
543
|
-
// clearScheduledMessage() below.
|
|
526
|
+
// Clears the visible DOM bubbles and their countdown only; the per-session
|
|
527
|
+
// list is untouched. Used when re-drawing for the same session and when the
|
|
528
|
+
// view moves to another project.
|
|
544
529
|
export function removeScheduledMessageBubble() {
|
|
545
530
|
if (scheduledMsgEl) {
|
|
546
531
|
scheduledMsgEl.remove();
|
|
547
532
|
scheduledMsgEl = null;
|
|
548
533
|
}
|
|
534
|
+
scheduledCountdowns = [];
|
|
549
535
|
if (scheduledCountdownTimer) {
|
|
550
536
|
clearInterval(scheduledCountdownTimer);
|
|
551
537
|
scheduledCountdownTimer = null;
|
|
552
538
|
}
|
|
553
539
|
}
|
|
554
540
|
|
|
555
|
-
// lr-0827ba: clears both the persisted per-session scheduled-message state
|
|
556
|
-
// and (if that session is currently focused) the visible bubble. sessionId
|
|
557
|
-
// defaults to the currently active session for existing call sites that
|
|
558
|
-
// don't yet carry a server-stamped localId (older history entries).
|
|
559
|
-
export function clearScheduledMessage(sessionId) {
|
|
560
|
-
var targetSessionId = sessionId != null ? sessionId : currentSessionId();
|
|
561
|
-
clearScheduledMsg(targetSessionId);
|
|
562
|
-
if (targetSessionId === currentSessionId()) removeScheduledMessageBubble();
|
|
563
|
-
}
|
|
564
|
-
|
|
565
541
|
export function handleFastModeState(state) {
|
|
566
542
|
var statusArea = document.querySelector(".title-bar-content .status");
|
|
567
543
|
if (!statusArea) return;
|
|
@@ -596,8 +572,8 @@ export function getScheduledMsgEl() { return scheduledMsgEl; }
|
|
|
596
572
|
// which meant switching projects silently canceled the OUTGOING session's
|
|
597
573
|
// rate-limit reset timer and armed schedule, exactly the bug this task
|
|
598
574
|
// fixes. Reset timers and armed state are per-session now (rate-limit-state.js)
|
|
599
|
-
// and must keep running in the background regardless of focus, mirroring
|
|
600
|
-
// server
|
|
575
|
+
// and must keep running in the background regardless of focus, mirroring the
|
|
576
|
+
// server's scheduled inputs. This function now only tears down
|
|
601
577
|
// the visible DOM/UI-timer for whichever session was previously focused —
|
|
602
578
|
// it does not touch any session's persisted arming state. Callers switching
|
|
603
579
|
// into a different session must call restoreRateLimitStateForSession() for
|
|
@@ -630,13 +606,13 @@ export function forgetSessionRateLimitState(sessionId) {
|
|
|
630
606
|
// the new session is focused (store.activeSessionId already updated).
|
|
631
607
|
export function restoreRateLimitStateForSession(sessionId) {
|
|
632
608
|
restoreScheduleDelayUi();
|
|
609
|
+
refreshScheduleControls();
|
|
633
610
|
var resetsAt = getRateLimitResetsAt(sessionId);
|
|
634
611
|
if (resetsAt && resetsAt > Date.now()) {
|
|
635
612
|
updateRateLimitIndicator({ status: "rejected", resetsAt: resetsAt });
|
|
636
613
|
startRateLimitCountdown(null, resetsAt, null);
|
|
637
614
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}
|
|
615
|
+
renderScheduledBubbles(sessionId);
|
|
616
|
+
// The list held here may be older than the server's; ask for the current one.
|
|
617
|
+
requestScheduledInputList();
|
|
642
618
|
}
|
|
@@ -8,6 +8,9 @@ import { escapeHtml, copyToClipboard } from './utils.js';
|
|
|
8
8
|
import { renderMarkdown, renderMarkdownAsync, highlightCodeBlocks, renderMermaidBlocks } from './markdown.js';
|
|
9
9
|
import { iconHtml, refreshIcons } from './icons.js';
|
|
10
10
|
import { userAvatarUrl } from './avatar.js';
|
|
11
|
+
import { injectedSenderName, injectedLabel, injectedSessionNote } from './injected-label.js';
|
|
12
|
+
import { resolveInjectedIdentity } from './injected-identity.js';
|
|
13
|
+
import { getProjectAgents } from './at-agents.js';
|
|
11
14
|
import { closeToolGroup } from './tools.js';
|
|
12
15
|
import { showImageModal, showPasteModal } from './app-misc.js';
|
|
13
16
|
import { sendMessage, hasSendableContent } from './input.js';
|
|
@@ -471,16 +474,20 @@ export function finalizeAssistantBlock() {
|
|
|
471
474
|
}
|
|
472
475
|
}
|
|
473
476
|
|
|
474
|
-
|
|
477
|
+
// injected (optional): { senderKind, fromName, initiator, contextNote } of a
|
|
478
|
+
// message another process sent into the session. It always renders through the
|
|
479
|
+
// other-sender path, never as the local user. All of its text is untrusted and
|
|
480
|
+
// is set with textContent.
|
|
481
|
+
export function addUserMessage(text, images, pastes, fromUserId, fromUserName, injected) {
|
|
475
482
|
if (!text && (!images || images.length === 0) && (!pastes || pastes.length === 0)) return;
|
|
476
483
|
var myUserId = store.get('myUserId');
|
|
477
484
|
// Only treat as "other user" if we're in multi-user mode AND myUserId is
|
|
478
485
|
// already known AND the message is from a different user. If myUserId is
|
|
479
486
|
// null (init race — /api/me hasn't returned yet), assume the message is
|
|
480
487
|
// from the local user to prevent avatar/name bleed-through in bubble view.
|
|
481
|
-
var isOtherUser = myUserId && fromUserId && fromUserId !== myUserId;
|
|
488
|
+
var isOtherUser = injected ? true : (myUserId && fromUserId && fromUserId !== myUserId);
|
|
482
489
|
var div = document.createElement("div");
|
|
483
|
-
div.className = "msg-user" + (isOtherUser ? " msg-user-other" : "");
|
|
490
|
+
div.className = "msg-user" + (isOtherUser ? " msg-user-other" : "") + (injected ? " msg-user-injected" : "");
|
|
484
491
|
div.dataset.turn = ++turnCounter;
|
|
485
492
|
if (shouldGroupMessage("msg-user")) div.classList.add("grouped");
|
|
486
493
|
var bubble = document.createElement("div");
|
|
@@ -541,7 +548,11 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
|
|
|
541
548
|
var cachedAllUsers = store.get('cachedAllUsers');
|
|
542
549
|
var _targetUser;
|
|
543
550
|
var _displayName;
|
|
544
|
-
|
|
551
|
+
var _injectedIdentity = null;
|
|
552
|
+
if (injected) {
|
|
553
|
+
_injectedIdentity = resolveInjectedIdentity(injected, fromUserId, getProjectAgents(), 36);
|
|
554
|
+
_displayName = _injectedIdentity.name;
|
|
555
|
+
} else if (isOtherUser) {
|
|
545
556
|
_targetUser = cachedAllUsers.find(function (u) { return u.id === fromUserId; });
|
|
546
557
|
_displayName = fromUserName || (_targetUser && (_targetUser.displayName || _targetUser.username)) || "User";
|
|
547
558
|
} else {
|
|
@@ -557,7 +568,7 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
|
|
|
557
568
|
|
|
558
569
|
var avi = document.createElement("img");
|
|
559
570
|
avi.className = "dm-bubble-avatar" + (isOtherUser ? " dm-bubble-avatar-other" : " dm-bubble-avatar-me");
|
|
560
|
-
avi.src = isOtherUser
|
|
571
|
+
avi.src = _injectedIdentity ? _injectedIdentity.avatarUrl : isOtherUser
|
|
561
572
|
? userAvatarUrl(_targetUser || { id: fromUserId }, 36)
|
|
562
573
|
: (document.body.dataset.myAvatarUrl || userAvatarUrl(_targetUser || { id: myUserId }, 36));
|
|
563
574
|
div.appendChild(avi);
|
|
@@ -576,6 +587,25 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
|
|
|
576
587
|
timeSpan.textContent = getMsgTime();
|
|
577
588
|
header.appendChild(timeSpan);
|
|
578
589
|
contentWrap.appendChild(header);
|
|
590
|
+
if (injected) {
|
|
591
|
+
var labelEl = document.createElement("div");
|
|
592
|
+
labelEl.className = "injected-label";
|
|
593
|
+
labelEl.textContent = injectedLabel(injected);
|
|
594
|
+
contentWrap.appendChild(labelEl);
|
|
595
|
+
// The full sender session id: on hover (title) and on tap, which a phone has
|
|
596
|
+
// no hover for. Not part of the label itself.
|
|
597
|
+
var sessionNote = injectedSessionNote(injected);
|
|
598
|
+
if (sessionNote) {
|
|
599
|
+
nameSpan.title = sessionNote;
|
|
600
|
+
nameSpan.dataset.senderSession = injected.senderSessionId;
|
|
601
|
+
nameSpan.classList.add("dm-bubble-name-tappable");
|
|
602
|
+
nameSpan.addEventListener("click", function () {
|
|
603
|
+
var shown = labelEl.dataset.showSession === "1";
|
|
604
|
+
labelEl.dataset.showSession = shown ? "0" : "1";
|
|
605
|
+
labelEl.textContent = injectedLabel(injected) + (shown ? "" : " · " + sessionNote);
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
}
|
|
579
609
|
contentWrap.appendChild(bubble);
|
|
580
610
|
div.appendChild(contentWrap);
|
|
581
611
|
|
|
@@ -591,7 +621,8 @@ export function addUserMessage(text, images, pastes, fromUserId, fromUserName) {
|
|
|
591
621
|
|
|
592
622
|
actions.querySelector(".msg-action-copy").addEventListener("click", function () {
|
|
593
623
|
var self = this;
|
|
594
|
-
|
|
624
|
+
// A copied injected message keeps its sender, so it cannot be pasted as the operator's words.
|
|
625
|
+
copyToClipboard(injected ? "[" + injectedSenderName(injected) + " · " + injectedLabel(injected) + "] " + (text || "") : (text || ""));
|
|
595
626
|
self.innerHTML = iconHtml("check");
|
|
596
627
|
refreshIcons(actions);
|
|
597
628
|
setTimeout(function () { self.innerHTML = iconHtml("copy"); refreshIcons(actions); }, 1200);
|
|
@@ -92,6 +92,14 @@ export function handleProjectAgentsList(msg) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// The project agents last sent by the server, for callers that need to match a
|
|
96
|
+
// name to a known agent identity (injected-message sender display).
|
|
97
|
+
export function getProjectAgents() {
|
|
98
|
+
return _agents.map(function (a) {
|
|
99
|
+
return { id: a.slug || a.name, name: a.name, agentName: a.name, slug: a.slug };
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
95
103
|
// Show the dropdown at the position of the input element. Filter by query.
|
|
96
104
|
// Called from input.js when @ is active.
|
|
97
105
|
export function showAgentMenu(query) {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Detects that the daemon now serves a different build than the one this page
|
|
2
|
+
// booted with, and gets the page onto the new client.
|
|
3
|
+
//
|
|
4
|
+
// The id arrives with every connect (the WebSocket info message and /info), so a
|
|
5
|
+
// tab that stayed open across a daemon restart notices on its reconnect, even
|
|
6
|
+
// when both builds carry the same package version.
|
|
7
|
+
//
|
|
8
|
+
// Reload versus banner: a reload drops what has not been sent yet, so with
|
|
9
|
+
// unsent input the guard shows a banner the user acts on instead, and reloads
|
|
10
|
+
// at once when there is nothing to lose.
|
|
11
|
+
|
|
12
|
+
export function createBuildGuard(deps) {
|
|
13
|
+
var booted = null;
|
|
14
|
+
var acted = false;
|
|
15
|
+
|
|
16
|
+
// Returns what happened, so callers and tests can tell the paths apart.
|
|
17
|
+
function observe(buildId) {
|
|
18
|
+
if (!buildId) return "ignored";
|
|
19
|
+
if (booted === null) {
|
|
20
|
+
booted = buildId;
|
|
21
|
+
return "booted";
|
|
22
|
+
}
|
|
23
|
+
if (buildId === booted) return "same";
|
|
24
|
+
if (acted) return "pending";
|
|
25
|
+
acted = true;
|
|
26
|
+
if (deps.hasUnsent()) {
|
|
27
|
+
deps.showBanner();
|
|
28
|
+
return "banner";
|
|
29
|
+
}
|
|
30
|
+
deps.reload();
|
|
31
|
+
return "reload";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Both ways the id arrives carry it as `buildId`: the WebSocket "info" message
|
|
35
|
+
// and the /info response. One entry point for both keeps them from drifting.
|
|
36
|
+
function observeInfo(info) {
|
|
37
|
+
return observe(info && info.buildId);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { observe: observe, observeInfo: observeInfo };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Not dismissable: the page is running code the server no longer matches.
|
|
44
|
+
export function showReloadBanner(doc, reload) {
|
|
45
|
+
if (doc.getElementById("sw-update-banner")) return;
|
|
46
|
+
var banner = doc.createElement("div");
|
|
47
|
+
banner.id = "sw-update-banner";
|
|
48
|
+
banner.className = "sw-update-banner";
|
|
49
|
+
var text = doc.createElement("span");
|
|
50
|
+
text.className = "sw-update-banner-text";
|
|
51
|
+
text.textContent = "Clagentic: Console was updated. Reload to continue.";
|
|
52
|
+
var button = doc.createElement("button");
|
|
53
|
+
button.className = "sw-update-banner-btn";
|
|
54
|
+
button.id = "sw-update-reload";
|
|
55
|
+
button.textContent = "Reload";
|
|
56
|
+
button.addEventListener("click", reload);
|
|
57
|
+
banner.appendChild(text);
|
|
58
|
+
banner.appendChild(button);
|
|
59
|
+
doc.body.appendChild(banner);
|
|
60
|
+
banner.classList.add("visible");
|
|
61
|
+
}
|
|
@@ -30,10 +30,7 @@ export function buildUpdateDetailEl(offer) {
|
|
|
30
30
|
'Running: ' + shortSha(offer.loadedBuildSha) + ' Installed: ' + shortSha(offer.installedBuildSha)));
|
|
31
31
|
|
|
32
32
|
var changes = offer.changes || {};
|
|
33
|
-
if (
|
|
34
|
-
root.appendChild(line('build-update-note',
|
|
35
|
-
'Both report the same build, but the installed files differ from the ones this process loaded.'));
|
|
36
|
-
} else if (changes.available && Array.isArray(changes.commits) && changes.commits.length > 0) {
|
|
33
|
+
if (changes.available && Array.isArray(changes.commits) && changes.commits.length > 0) {
|
|
37
34
|
root.appendChild(line('build-update-heading', 'Changes since the running build:'));
|
|
38
35
|
var list = document.createElement('ul');
|
|
39
36
|
list.className = 'build-update-commits';
|
|
@@ -44,13 +44,78 @@ var _noticeGate = createNoticeGate();
|
|
|
44
44
|
// another diagnostic carrying a one-use token, and only its "Restart now"
|
|
45
45
|
// sends that token back.
|
|
46
46
|
var CONFIRM_BUILD_UPDATE = 'confirm_build_update_restart';
|
|
47
|
+
// A handler returns true only when its frame was handed to an open socket; a
|
|
48
|
+
// click that sent nothing must leave the button usable.
|
|
49
|
+
// Each request carries a requestId the daemon echoes in its result, so a result
|
|
50
|
+
// releases only the button whose click produced it.
|
|
47
51
|
var ACTIONABLE_HANDLERS = {
|
|
48
|
-
restart_for_build_update: function () {
|
|
49
|
-
|
|
52
|
+
restart_for_build_update: function (entry, requestId) {
|
|
53
|
+
return sendWs({ type: 'restart_for_build_update', requestId: requestId });
|
|
54
|
+
},
|
|
55
|
+
confirm_build_update_restart: function (entry, requestId) {
|
|
50
56
|
var token = entry.buildUpdate && entry.buildUpdate.token;
|
|
51
|
-
if (typeof token
|
|
57
|
+
if (typeof token !== 'string' || !token) return false;
|
|
58
|
+
return sendWs({ type: 'restart_for_build_update', confirmToken: token, requestId: requestId });
|
|
52
59
|
},
|
|
53
60
|
};
|
|
61
|
+
var _nextRequestId = 1;
|
|
62
|
+
|
|
63
|
+
// A click disables its button until the daemon answers. The answer is a
|
|
64
|
+
// restart_for_build_update_result frame, but a refused request (admin gate) or
|
|
65
|
+
// a reply lost with the socket is never followed by one, so the wait is bounded:
|
|
66
|
+
// a button that stayed dimmed for ever looked like a restart under way.
|
|
67
|
+
var REPLY_TIMEOUT_MS = 15000;
|
|
68
|
+
var SEND_FAILED_TEXT = "Not connected to Clagentic: Console right now. Wait for it to reconnect, then try again.";
|
|
69
|
+
var _awaitingReply = []; // [{btn, timer, requestId}]
|
|
70
|
+
|
|
71
|
+
function _setSendFailedNote(btn, text) {
|
|
72
|
+
var host = btn.parentNode;
|
|
73
|
+
if (!host) return;
|
|
74
|
+
var note = host.querySelectorAll(".build-update-send-failed")[0];
|
|
75
|
+
if (!text) {
|
|
76
|
+
if (note && note.parentNode) note.parentNode.removeChild(note);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!note) {
|
|
80
|
+
note = document.createElement("div");
|
|
81
|
+
note.className = "build-update-send-failed";
|
|
82
|
+
host.appendChild(note);
|
|
83
|
+
}
|
|
84
|
+
note.textContent = text;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var NO_ANSWER_TEXT = "Clagentic: Console did not answer, so the restart may not have been requested. Try again.";
|
|
88
|
+
|
|
89
|
+
function _awaitReply(btn, requestId) {
|
|
90
|
+
var slot = { btn: btn, timer: null, requestId: requestId };
|
|
91
|
+
slot.timer = setTimeout(function () { _releaseSlot(slot, true, NO_ANSWER_TEXT); }, REPLY_TIMEOUT_MS);
|
|
92
|
+
_awaitingReply.push(slot);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _releaseSlot(slot, reenable, note) {
|
|
96
|
+
clearTimeout(slot.timer);
|
|
97
|
+
_awaitingReply = _awaitingReply.filter(function (s) { return s !== slot; });
|
|
98
|
+
if (reenable) slot.btn.disabled = false;
|
|
99
|
+
if (note) _setSendFailedNote(slot.btn, note);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The daemon's answer to a restart request. `ok: true` means the restart is
|
|
104
|
+
* scheduled: the buttons stay disabled. Anything else (a fresh offer to
|
|
105
|
+
* confirm, a refusal, nothing to apply) gives the buttons back so the
|
|
106
|
+
* operator can act on what is now on screen.
|
|
107
|
+
*
|
|
108
|
+
* Only the slot whose requestId the result echoes is released; a result that
|
|
109
|
+
* names no pending request releases nothing (the slot's own timeout covers it).
|
|
110
|
+
*/
|
|
111
|
+
export function settleBuildUpdateRequest(result) {
|
|
112
|
+
var requestId = result && typeof result.requestId === "string" ? result.requestId : null;
|
|
113
|
+
if (!requestId) return;
|
|
114
|
+
var restarting = result.ok === true;
|
|
115
|
+
var refusal = !restarting && typeof result.error === "string" ? result.error : null;
|
|
116
|
+
_awaitingReply.filter(function (s) { return s.requestId === requestId; })
|
|
117
|
+
.forEach(function (slot) { _releaseSlot(slot, !restarting, refusal); });
|
|
118
|
+
}
|
|
54
119
|
|
|
55
120
|
// Shared by both render sites below (panel entry + toast). Returns
|
|
56
121
|
// a clickable button when entry.actionable.action is a known action, or null
|
|
@@ -65,8 +130,14 @@ function _buildActionableEl(entry, btnClass) {
|
|
|
65
130
|
btn.className = btnClass;
|
|
66
131
|
btn.textContent = entry.actionable.label;
|
|
67
132
|
btn.addEventListener("click", function () {
|
|
133
|
+
var requestId = "bu-" + (_nextRequestId++);
|
|
134
|
+
if (handler(entry, requestId) !== true) {
|
|
135
|
+
_setSendFailedNote(btn, SEND_FAILED_TEXT);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
_setSendFailedNote(btn, null);
|
|
68
139
|
btn.disabled = true;
|
|
69
|
-
|
|
140
|
+
_awaitReply(btn, requestId);
|
|
70
141
|
});
|
|
71
142
|
return btn;
|
|
72
143
|
}
|
|
@@ -192,7 +263,7 @@ export function initDiagnostics() {
|
|
|
192
263
|
// ============================================================
|
|
193
264
|
|
|
194
265
|
export function addDiagnostic(msg, opts) {
|
|
195
|
-
var now =
|
|
266
|
+
var now = _arrivalTime(msg);
|
|
196
267
|
|
|
197
268
|
// lr-e901: same condition can arrive via two independent emitters (CLI-stderr
|
|
198
269
|
// capture + deterministic preflight) - collapse to a single visible entry.
|
|
@@ -205,6 +276,7 @@ export function addDiagnostic(msg, opts) {
|
|
|
205
276
|
message: msg.message || "",
|
|
206
277
|
actionable: msg.actionable || null,
|
|
207
278
|
buildUpdate: msg.buildUpdate || null,
|
|
279
|
+
persistent: msg.persistent === true,
|
|
208
280
|
ts: now,
|
|
209
281
|
id: _nextDiagnosticId++,
|
|
210
282
|
};
|
|
@@ -226,6 +298,20 @@ export function addDiagnostic(msg, opts) {
|
|
|
226
298
|
}
|
|
227
299
|
}
|
|
228
300
|
|
|
301
|
+
// Only the newest restart confirmation is live: the daemon spends an offer's
|
|
302
|
+
// token on first use, so an older card would carry a dead one. A re-issued
|
|
303
|
+
// offer (expired token, or something changed) replaces it, even when its text
|
|
304
|
+
// matches the card it replaces.
|
|
305
|
+
// Returns the arrival time; the retraction happens before the duplicate check
|
|
306
|
+
// so the replaced card's text is no longer on record as seen.
|
|
307
|
+
function _arrivalTime(msg) {
|
|
308
|
+
if (_actionOf(msg) === CONFIRM_BUILD_UPDATE) retractDiagnostics(msg.source || "", CONFIRM_BUILD_UPDATE);
|
|
309
|
+
// A persistent state (a restart pending) is stated once however many times
|
|
310
|
+
// and from however many paths it arrives, so a repeat replaces its card.
|
|
311
|
+
if (msg.persistent === true) retractDiagnostics(msg.source || "");
|
|
312
|
+
return Date.now();
|
|
313
|
+
}
|
|
314
|
+
|
|
229
315
|
// The standing build-update notice is replayed to every connection and refreshed
|
|
230
316
|
// while the build is stale; build-notice-gate.js decides whether this arrival
|
|
231
317
|
// adds, replaces, re-toasts or is dropped. Anything else passes through.
|
|
@@ -408,8 +494,9 @@ function _showDiagnosticToast(entry) {
|
|
|
408
494
|
|
|
409
495
|
// Auto-dismiss after 6s — EXCEPT when an action button is present: an
|
|
410
496
|
// operator deciding whether to restart must not have the offer vanish out
|
|
411
|
-
// from under them before they've read it.
|
|
412
|
-
|
|
497
|
+
// from under them before they've read it. Likewise a persistent state (a
|
|
498
|
+
// restart pending) stays until the operator closes it or the page reloads.
|
|
499
|
+
var timer = (hasAction || entry.persistent) ? null : setTimeout(function () { _removeDiagnosticToast(el); }, 6000);
|
|
413
500
|
|
|
414
501
|
// Manual dismiss.
|
|
415
502
|
dismissBtn.addEventListener("click", function () {
|
|
@@ -418,9 +505,11 @@ function _showDiagnosticToast(entry) {
|
|
|
418
505
|
_removeDiagnosticToast(el);
|
|
419
506
|
});
|
|
420
507
|
|
|
421
|
-
// Keyboard dismiss.
|
|
508
|
+
// Keyboard dismiss. Enter and Space bubble up from the toast's own buttons
|
|
509
|
+
// when they are activated; that must activate the button, not close the card.
|
|
422
510
|
el.addEventListener("keydown", function (e) {
|
|
423
|
-
|
|
511
|
+
var fromButton = e.target && e.target.tagName === "BUTTON";
|
|
512
|
+
if (e.key === "Escape" || ((e.key === "Enter" || e.key === " ") && !fromButton)) {
|
|
424
513
|
clearTimeout(timer);
|
|
425
514
|
_noticeGate.toastClosed(entry.noticeKey, Date.now());
|
|
426
515
|
_removeDiagnosticToast(el);
|