@clagentic/console 1.0.0-beta.2 → 1.0.0-beta.3
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/lib/public/modules/app-cursors.js +44 -42
- package/lib/public/modules/app-messages.js +15 -1
- package/lib/public/modules/app-notifications.js +1 -1
- package/lib/public/modules/app-rendering.js +6 -2
- package/lib/public/modules/input.js +13 -0
- package/lib/public/modules/markdown.js +33 -0
- package/lib/public/modules/mention.js +13 -0
- package/lib/public/modules/notifications.js +1 -1
- package/package.json +1 -1
|
@@ -443,50 +443,52 @@ export function initCursors() {
|
|
|
443
443
|
});
|
|
444
444
|
|
|
445
445
|
// Track local text selection and send to server
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
lastSelectionKey
|
|
461
|
-
|
|
446
|
+
if (store.get('isMultiUserMode')) {
|
|
447
|
+
document.addEventListener("selectionchange", function () {
|
|
448
|
+
if (!shouldBroadcastCollab()) return;
|
|
449
|
+
var ws = getWs();
|
|
450
|
+
if (!ws || ws.readyState !== 1) return;
|
|
451
|
+
if (selectionThrottleTimer) return;
|
|
452
|
+
selectionThrottleTimer = setTimeout(function () { selectionThrottleTimer = null; }, 100);
|
|
453
|
+
|
|
454
|
+
var activeEl = document.activeElement;
|
|
455
|
+
if (activeEl && activeEl.id === "input" && lastSelectionKey === "") return;
|
|
456
|
+
|
|
457
|
+
var sel = window.getSelection();
|
|
458
|
+
if (!sel || sel.rangeCount === 0 || sel.isCollapsed) {
|
|
459
|
+
// Selection cleared
|
|
460
|
+
if (lastSelectionKey !== "") {
|
|
461
|
+
lastSelectionKey = "";
|
|
462
|
+
sendWsQuiet({ type: "text_select", ranges: [] });
|
|
463
|
+
}
|
|
464
|
+
return;
|
|
462
465
|
}
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
466
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
467
|
+
var ranges = [];
|
|
468
|
+
for (var i = 0; i < sel.rangeCount; i++) {
|
|
469
|
+
var range = sel.getRangeAt(i);
|
|
470
|
+
var startTurn = findParentTurn(range.startContainer);
|
|
471
|
+
var endTurn = findParentTurn(range.endContainer);
|
|
472
|
+
if (!startTurn || !endTurn) continue;
|
|
473
|
+
// Both must be inside messagesEl
|
|
474
|
+
if (!messagesEl.contains(startTurn)) continue;
|
|
475
|
+
|
|
476
|
+
var startCh = getCharOffset(startTurn, range.startContainer, range.startOffset);
|
|
477
|
+
var endCh = getCharOffset(endTurn, range.endContainer, range.endOffset);
|
|
478
|
+
|
|
479
|
+
ranges.push({
|
|
480
|
+
startTurn: parseInt(startTurn.dataset.turn, 10),
|
|
481
|
+
startCh: startCh,
|
|
482
|
+
endTurn: parseInt(endTurn.dataset.turn, 10),
|
|
483
|
+
endCh: endCh
|
|
484
|
+
});
|
|
485
|
+
}
|
|
485
486
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
487
|
+
var key = JSON.stringify(ranges);
|
|
488
|
+
if (key === lastSelectionKey) return;
|
|
489
|
+
lastSelectionKey = key;
|
|
489
490
|
|
|
490
|
-
|
|
491
|
-
|
|
491
|
+
sendWsQuiet({ type: "text_select", ranges: ranges });
|
|
492
|
+
});
|
|
493
|
+
}
|
|
492
494
|
}
|
|
@@ -80,7 +80,12 @@ export function processMessage(msg) {
|
|
|
80
80
|
var nav = getPendingNavigate();
|
|
81
81
|
var hasNavTarget = nav && (nav.toolId || nav.assistantUuid);
|
|
82
82
|
if (!hasNavTarget) {
|
|
83
|
-
|
|
83
|
+
// Use a longer quiet window when replaying long history — deferred
|
|
84
|
+
// content (lazy images, async markdown, todo compaction) can keep
|
|
85
|
+
// arriving for several seconds on mobile with a large transcript.
|
|
86
|
+
var historyLen = store.get('historyTotal') || 0;
|
|
87
|
+
var quietMs = historyLen > 20 ? 2000 : 750;
|
|
88
|
+
armStickyBottom(quietMs);
|
|
84
89
|
}
|
|
85
90
|
// Batched syntax highlight + mermaid pass for the entire replayed
|
|
86
91
|
// transcript. Per-message highlights are skipped during replay
|
|
@@ -89,6 +94,15 @@ export function processMessage(msg) {
|
|
|
89
94
|
if (messagesEl) {
|
|
90
95
|
highlightCodeBlocks(messagesEl);
|
|
91
96
|
renderMermaidBlocks(messagesEl);
|
|
97
|
+
// Re-arm after highlight batch completes — Highlight.js defers work
|
|
98
|
+
// via requestAnimationFrame, so the actual DOM updates may happen
|
|
99
|
+
// after the synchronous call returns. This re-arm catches the deferred
|
|
100
|
+
// work on slow browsers.
|
|
101
|
+
setTimeout(function () {
|
|
102
|
+
if (!store.get('processing')) {
|
|
103
|
+
armStickyBottom(500);
|
|
104
|
+
}
|
|
105
|
+
}, 300);
|
|
92
106
|
}
|
|
93
107
|
// Compact dead-session todo widgets (unfinished items will never
|
|
94
108
|
// resolve — the agent isn't coming back) so they don't anchor
|
|
@@ -555,7 +555,7 @@ export function showUpdateBanner(msg) {
|
|
|
555
555
|
'<div class="notif-banner-project">CLAY</div>' +
|
|
556
556
|
'<div class="notif-banner-title">v' + escapeHtml(msg.version) + ' is available</div>' +
|
|
557
557
|
(isHeadless
|
|
558
|
-
? '<div class="notif-banner-text">Run: npx
|
|
558
|
+
? '<div class="notif-banner-text">Run: npx @clagentic/console@' + escapeHtml(updTag) + '</div>'
|
|
559
559
|
: '') +
|
|
560
560
|
actionsHtml +
|
|
561
561
|
'</div>' +
|
|
@@ -139,6 +139,7 @@ export function armStickyBottom(durationMs) {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
export function disarmStickyBottom() {
|
|
142
|
+
if (!stickyBottom) return; // already disarmed — skip timer ops
|
|
142
143
|
stickyBottom = false;
|
|
143
144
|
if (stickyBottomQuietTimer) { clearTimeout(stickyBottomQuietTimer); stickyBottomQuietTimer = null; }
|
|
144
145
|
if (stickyBottomCeilingTimer) { clearTimeout(stickyBottomCeilingTimer); stickyBottomCeilingTimer = null; }
|
|
@@ -192,13 +193,13 @@ export function scrollToBottom() {
|
|
|
192
193
|
});
|
|
193
194
|
}
|
|
194
195
|
|
|
195
|
-
export function forceScrollToBottom() {
|
|
196
|
+
export function forceScrollToBottom(quietMs) {
|
|
196
197
|
if (prependAnchor) return;
|
|
197
198
|
// Arm sticky-bottom mode so deferred layout (tool widgets, code highlighting,
|
|
198
199
|
// image loads) can't strand the user partway down — single-rAF pin captures
|
|
199
200
|
// a stale scrollHeight, then growth below pushes the bottom further away.
|
|
200
201
|
// The quiet detector extends the window automatically while layout shifts.
|
|
201
|
-
armStickyBottom(750);
|
|
202
|
+
armStickyBottom(quietMs || 750);
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
export function getMsgTime() {
|
|
@@ -433,6 +434,9 @@ export function finalizeAssistantBlock() {
|
|
|
433
434
|
contentEl.innerHTML = html;
|
|
434
435
|
highlightCodeBlocks(contentEl);
|
|
435
436
|
renderMermaidBlocks(contentEl);
|
|
437
|
+
// Re-pin after the last-message expansion — this fires after the
|
|
438
|
+
// initial history_done arm may have already expired on mobile.
|
|
439
|
+
armStickyBottom(500);
|
|
436
440
|
}
|
|
437
441
|
}, 0);
|
|
438
442
|
});
|
|
@@ -604,6 +604,8 @@ function getAllCommands() {
|
|
|
604
604
|
return builtinCommands.concat(ctx.slashCommands());
|
|
605
605
|
}
|
|
606
606
|
|
|
607
|
+
var _lastSlashRenderKey = "";
|
|
608
|
+
|
|
607
609
|
function showSlashMenu(filter) {
|
|
608
610
|
var query = filter.toLowerCase();
|
|
609
611
|
slashFiltered = getAllCommands().filter(function (c) {
|
|
@@ -611,6 +613,16 @@ function showSlashMenu(filter) {
|
|
|
611
613
|
});
|
|
612
614
|
if (slashFiltered.length === 0) { hideSlashMenu(); return; }
|
|
613
615
|
|
|
616
|
+
// Compute a cheap key to detect if the filtered set has changed
|
|
617
|
+
var renderKey = slashFiltered.map(function (c) { return c.name; }).join(",");
|
|
618
|
+
if (ctx.slashMenu.classList.contains("visible") && renderKey === _lastSlashRenderKey) {
|
|
619
|
+
// Same candidates — just update highlight
|
|
620
|
+
slashActiveIdx = 0;
|
|
621
|
+
updateSlashHighlight();
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
_lastSlashRenderKey = renderKey;
|
|
625
|
+
|
|
614
626
|
slashActiveIdx = 0;
|
|
615
627
|
ctx.slashMenu.innerHTML = slashFiltered.map(function (c, i) {
|
|
616
628
|
return '<div class="slash-item' + (i === 0 ? ' active' : '') + '" data-idx="' + i + '">' +
|
|
@@ -623,6 +635,7 @@ function showSlashMenu(filter) {
|
|
|
623
635
|
|
|
624
636
|
export function hideSlashMenu() {
|
|
625
637
|
if (slashFiltered.length === 0 && slashActiveIdx === -1) return; // already hidden
|
|
638
|
+
_lastSlashRenderKey = "";
|
|
626
639
|
ctx.slashMenu.classList.remove("visible");
|
|
627
640
|
ctx.slashMenu.innerHTML = "";
|
|
628
641
|
slashActiveIdx = -1;
|
|
@@ -200,6 +200,39 @@ export function renderMermaidBlocks(el) {
|
|
|
200
200
|
}
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
|
+
export function highlightCodeBlocksBatched(container, onDone) {
|
|
204
|
+
var blocks = Array.prototype.slice.call(container.querySelectorAll("pre > code:not(.hljs)"));
|
|
205
|
+
if (blocks.length === 0) { if (onDone) onDone(); return; }
|
|
206
|
+
|
|
207
|
+
var BATCH = 5; // blocks per idle callback
|
|
208
|
+
var idx = 0;
|
|
209
|
+
|
|
210
|
+
function processBatch(deadline) {
|
|
211
|
+
while (idx < blocks.length) {
|
|
212
|
+
// In rAF fallback mode, deadline is null — process one per frame
|
|
213
|
+
if (deadline && deadline.timeRemaining() < 2) break;
|
|
214
|
+
try { hljs.highlightElement(blocks[idx]); } catch (e) {}
|
|
215
|
+
idx++;
|
|
216
|
+
if (!deadline) break; // rAF mode: one per frame
|
|
217
|
+
}
|
|
218
|
+
if (idx < blocks.length) {
|
|
219
|
+
if (typeof requestIdleCallback !== "undefined") {
|
|
220
|
+
requestIdleCallback(processBatch, { timeout: 2000 });
|
|
221
|
+
} else {
|
|
222
|
+
requestAnimationFrame(function () { processBatch(null); });
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
if (onDone) onDone();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (typeof requestIdleCallback !== "undefined") {
|
|
230
|
+
requestIdleCallback(processBatch, { timeout: 2000 });
|
|
231
|
+
} else {
|
|
232
|
+
requestAnimationFrame(function () { processBatch(null); });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
203
236
|
|
|
204
237
|
export function showMermaidModal(svgHtml) {
|
|
205
238
|
var modal = document.getElementById("mermaid-modal");
|
|
@@ -177,6 +177,8 @@ function buildMentionCandidates() {
|
|
|
177
177
|
return candidates;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
var _lastMentionRenderKey = "";
|
|
181
|
+
|
|
180
182
|
export function showMentionMenu(query) {
|
|
181
183
|
var candidates = buildMentionCandidates();
|
|
182
184
|
if (candidates.length === 0) {
|
|
@@ -197,6 +199,16 @@ export function showMentionMenu(query) {
|
|
|
197
199
|
return;
|
|
198
200
|
}
|
|
199
201
|
|
|
202
|
+
// Compute a cheap key to detect if the filtered set has changed
|
|
203
|
+
var renderKey = mentionFiltered.map(function (c) { return c.id || c.name; }).join(",");
|
|
204
|
+
if (mentionActive && renderKey === _lastMentionRenderKey) {
|
|
205
|
+
// Same candidates — just update highlight
|
|
206
|
+
mentionActiveIdx = 0;
|
|
207
|
+
updateMentionHighlight();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
_lastMentionRenderKey = renderKey;
|
|
211
|
+
|
|
200
212
|
mentionActive = true;
|
|
201
213
|
mentionActiveIdx = 0;
|
|
202
214
|
|
|
@@ -225,6 +237,7 @@ export function showMentionMenu(query) {
|
|
|
225
237
|
|
|
226
238
|
export function hideMentionMenu() {
|
|
227
239
|
if (!mentionActive && mentionFiltered.length === 0) return; // already hidden
|
|
240
|
+
_lastMentionRenderKey = "";
|
|
228
241
|
mentionActive = false;
|
|
229
242
|
mentionActiveIdx = -1;
|
|
230
243
|
mentionFiltered = [];
|
|
@@ -113,7 +113,7 @@ export function initNotifications(_ctx) {
|
|
|
113
113
|
copyBtn.addEventListener("click", function (e) {
|
|
114
114
|
e.stopPropagation();
|
|
115
115
|
var cmdEl = document.getElementById("update-manual-cmd");
|
|
116
|
-
var cmdText = cmdEl ? cmdEl.textContent : "npx
|
|
116
|
+
var cmdText = cmdEl ? cmdEl.textContent : "npx @clagentic/console@latest";
|
|
117
117
|
copyToClipboard(cmdText).then(function () {
|
|
118
118
|
copyBtn.classList.add("copied");
|
|
119
119
|
copyBtn.innerHTML = iconHtml("check");
|
package/package.json
CHANGED