@clagentic/console 1.6.0-beta.2 → 1.6.0-beta.4
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 +21 -0
- package/lib/history-visibility.js +113 -0
- package/lib/project-sessions.js +25 -2
- package/lib/public/css/diagnostics.css +99 -19
- package/lib/public/index.html +4 -1
- package/lib/public/modules/app-header.js +68 -10
- package/lib/public/modules/diagnostic-format.js +18 -2
- package/lib/public/modules/diagnostics.js +149 -8
- package/lib/public/modules/emoji-picker.js +26 -5
- package/lib/public/modules/history-visibility.js +98 -0
- package/lib/release-list.js +87 -0
- package/lib/sdk-bridge.js +59 -19
- package/lib/sdk-message-processor.js +58 -3
- package/lib/sdk-permission-ownership.js +85 -0
- package/lib/sessions.js +61 -1
- package/lib/settings-preflight.js +52 -16
- package/lib/utils.js +23 -0
- package/lib/yoke/adapters/diagnostic-patterns.js +25 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -48,6 +48,26 @@ function openUrl(url) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
var args = process.argv.slice(2);
|
|
51
|
+
|
|
52
|
+
// --- `release` subcommand group (release-engineering helpers, lr-01c6) ---
|
|
53
|
+
// Positional subcommand, handled before flag parsing: `clagentic-console release list-betas`.
|
|
54
|
+
if (args[0] === "release") {
|
|
55
|
+
var releaseSub = args[1];
|
|
56
|
+
if (releaseSub === "list-betas") {
|
|
57
|
+
var releaseList = require("../lib/release-list");
|
|
58
|
+
var betasResult = releaseList.readBetasFile(process.cwd());
|
|
59
|
+
var betasLines = releaseList.formatBetasOutput(betasResult);
|
|
60
|
+
for (var bl = 0; bl < betasLines.length; bl++) {
|
|
61
|
+
console.log(betasLines[bl]);
|
|
62
|
+
}
|
|
63
|
+
process.exit(betasResult.ok ? 0 : 1);
|
|
64
|
+
} else {
|
|
65
|
+
console.error("Unknown release subcommand: " + (releaseSub || "(none)"));
|
|
66
|
+
console.error("Usage: clagentic-console release list-betas");
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
51
71
|
var port = _isDev ? 2635 : 2633;
|
|
52
72
|
var useHttps = true;
|
|
53
73
|
var forceMkcert = false;
|
|
@@ -124,6 +144,7 @@ for (var i = 0; i < args.length; i++) {
|
|
|
124
144
|
console.log(" clagentic-console --add <path> Add a project to the running daemon");
|
|
125
145
|
console.log(" clagentic-console --remove <path> Remove a project from the running daemon");
|
|
126
146
|
console.log(" clagentic-console --list List registered projects");
|
|
147
|
+
console.log(" clagentic-console release list-betas List promotable beta versions (maintainer/release-engineering)");
|
|
127
148
|
console.log("");
|
|
128
149
|
console.log("Options:");
|
|
129
150
|
console.log(" -p, --port <port> Port to listen on (default: 2633)");
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* history-visibility.js — shared source of truth for classifying a recorded
|
|
3
|
+
* history event as "renders a visible message" vs. an invisible-yield event.
|
|
4
|
+
* (lr-c24b)
|
|
5
|
+
*
|
|
6
|
+
* This is the CJS backend copy, used by the load_more_history page-window
|
|
7
|
+
* extension in lib/sessions.js / lib/project-sessions.js. The ES module
|
|
8
|
+
* (browser) copy lives at lib/public/modules/history-visibility.js and must
|
|
9
|
+
* be kept in sync with the render dispatch in lib/public/modules/app-messages.js
|
|
10
|
+
* (the switch(msg.type) cases starting around line 67). A test
|
|
11
|
+
* (test/history-visibility-parity.test.js) asserts both copies produce
|
|
12
|
+
* identical classifications so they cannot silently drift.
|
|
13
|
+
*
|
|
14
|
+
* Background: pagination pages by RAW history-event count
|
|
15
|
+
* (sessions.js HISTORY_PAGE_SIZE), but the user perceives rendered message
|
|
16
|
+
* bubbles. Long agentic turns are dominated by invisible-yield events (todo/
|
|
17
|
+
* task-list bookkeeping, hidden plan tools, state-only events, thinking
|
|
18
|
+
* deltas) — a page made entirely of these renders zero visible bubbles.
|
|
19
|
+
* isVisibleHistoryEvent() lets callers extend a page window until it
|
|
20
|
+
* contains at least one event that will actually render something.
|
|
21
|
+
*
|
|
22
|
+
* Keep this module dependency-light: no project imports, no Node built-ins.
|
|
23
|
+
* That constraint is what lets it stay close to the browser copy.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// Tool names that render as hidden bookkeeping widgets (todo/task list state,
|
|
27
|
+
// plan-mode banners, the ask-user-questions card is rendered by its own
|
|
28
|
+
// dedicated tool_executing branch, not the generic tool item) — mirrors
|
|
29
|
+
// TODO_TOOLS / PLAN_MODE_TOOLS in lib/public/modules/tools.js and the
|
|
30
|
+
// tool_start branch in lib/public/modules/app-messages.js.
|
|
31
|
+
var HIDDEN_TOOL_NAMES = {
|
|
32
|
+
TodoWrite: 1,
|
|
33
|
+
TaskCreate: 1,
|
|
34
|
+
TaskUpdate: 1,
|
|
35
|
+
TaskList: 1,
|
|
36
|
+
TaskGet: 1,
|
|
37
|
+
EnterPlanMode: 1,
|
|
38
|
+
ExitPlanMode: 1,
|
|
39
|
+
ask_user_questions: 1,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Event types that never render a new visible message/bubble on their own —
|
|
43
|
+
// they update existing UI state (status text, badges, panels) or are pure
|
|
44
|
+
// internal bookkeeping. Matches the case branches in app-messages.js that
|
|
45
|
+
// call a state setter / no-op rather than a DOM-inserting render helper.
|
|
46
|
+
var INVISIBLE_TYPES = {
|
|
47
|
+
message_uuid: 1,
|
|
48
|
+
session_id: 1,
|
|
49
|
+
status: 1,
|
|
50
|
+
compacting: 1,
|
|
51
|
+
thinking_start: 1,
|
|
52
|
+
thinking_delta: 1,
|
|
53
|
+
thinking_stop: 1,
|
|
54
|
+
ask_user_answered: 1,
|
|
55
|
+
permission_request: 1,
|
|
56
|
+
permission_request_pending: 1,
|
|
57
|
+
permission_cancel: 1,
|
|
58
|
+
permission_resolved: 1,
|
|
59
|
+
elicitation_request: 1,
|
|
60
|
+
elicitation_resolved: 1,
|
|
61
|
+
context_usage: 1,
|
|
62
|
+
fast_mode_state: 1,
|
|
63
|
+
rate_limit: 1,
|
|
64
|
+
rate_limit_usage: 1,
|
|
65
|
+
subagent_activity: 1,
|
|
66
|
+
subagent_tool: 1,
|
|
67
|
+
subagent_done: 1,
|
|
68
|
+
task_started: 1,
|
|
69
|
+
task_progress: 1,
|
|
70
|
+
task_updated: 1,
|
|
71
|
+
done: 1,
|
|
72
|
+
digest_checkpoint: 1,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Event types whose visibility depends on the tool name carried in the event.
|
|
76
|
+
var TOOL_NAME_TYPES = {
|
|
77
|
+
tool_start: 1,
|
|
78
|
+
tool_executing: 1,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns true when `entry` (a single session.history[] item / WS message)
|
|
83
|
+
* causes app-messages.js's processMessage() to insert a new visible element
|
|
84
|
+
* into the message list. Returns false for state-only or hidden-bookkeeping
|
|
85
|
+
* events — the invisible-yield set that can dominate a raw-event-count page.
|
|
86
|
+
*
|
|
87
|
+
* entry is intentionally treated defensively: unknown/missing type defaults
|
|
88
|
+
* to visible (safe default — never under-counts and can't create a new
|
|
89
|
+
* zero-visible page shape that this module wasn't already guarding against).
|
|
90
|
+
*/
|
|
91
|
+
function isVisibleHistoryEvent(entry) {
|
|
92
|
+
if (!entry || typeof entry.type !== "string") return true;
|
|
93
|
+
var type = entry.type;
|
|
94
|
+
|
|
95
|
+
if (INVISIBLE_TYPES[type]) return false;
|
|
96
|
+
|
|
97
|
+
if (TOOL_NAME_TYPES[type]) {
|
|
98
|
+
return !HIDDEN_TOOL_NAMES[entry.name];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// tool_result carries only an id (no name) — it updates an existing tool
|
|
102
|
+
// card rather than inserting a new one, so it is never itself the reason
|
|
103
|
+
// a page becomes visible.
|
|
104
|
+
if (type === "tool_result") return false;
|
|
105
|
+
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = {
|
|
110
|
+
HIDDEN_TOOL_NAMES: HIDDEN_TOOL_NAMES,
|
|
111
|
+
INVISIBLE_TYPES: INVISIBLE_TYPES,
|
|
112
|
+
isVisibleHistoryEvent: isVisibleHistoryEvent,
|
|
113
|
+
};
|
package/lib/project-sessions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var fs = require("fs");
|
|
2
2
|
var path = require("path");
|
|
3
|
+
var utils = require("./utils");
|
|
3
4
|
var { execFileSync, execFile } = require("child_process");
|
|
4
5
|
var { CODEX_DEFAULTS, getCodexConfig } = require("./codex-defaults");
|
|
5
6
|
var liteDetect = require("./lite-detect");
|
|
@@ -120,6 +121,13 @@ function attachSessions(ctx) {
|
|
|
120
121
|
var before = msg.before;
|
|
121
122
|
var targetFrom = typeof msg.target === "number" ? msg.target : before - sm.HISTORY_PAGE_SIZE;
|
|
122
123
|
var from = sm.findTurnBoundary(session.history, Math.max(0, targetFrom));
|
|
124
|
+
// Extend backward turn-boundary by turn-boundary (bounded — see
|
|
125
|
+
// extendWindowForVisibility) until the page contains at least one
|
|
126
|
+
// visibly-rendering event. Otherwise a page landing entirely on
|
|
127
|
+
// invisible-yield events (todo/task bookkeeping, hidden plan tools,
|
|
128
|
+
// state events, thinking deltas) advances historyFrom but renders
|
|
129
|
+
// nothing — "Load earlier" appears to do nothing (lr-c24b).
|
|
130
|
+
from = sm.extendWindowForVisibility(session.history, from, before);
|
|
123
131
|
var to = before;
|
|
124
132
|
var items = session.history.slice(from, to).map(hydrateImageRefs);
|
|
125
133
|
sendTo(ws, {
|
|
@@ -368,7 +376,11 @@ function attachSessions(ctx) {
|
|
|
368
376
|
// If Clay already has a persisted meta file for this cliSessionId, read
|
|
369
377
|
// its vendor so resumeSession doesn't silently default to the project's
|
|
370
378
|
// primary vendor (which would break codex sessions after server restart).
|
|
379
|
+
// Also read allowedTools (lr-8b2e) so a previously-granted "allow for
|
|
380
|
+
// session" decision survives this rehydration path instead of
|
|
381
|
+
// re-prompting — resumeSession() itself defaults to {} when absent.
|
|
371
382
|
var persistedVendor = null;
|
|
383
|
+
var persistedAllowedTools = null;
|
|
372
384
|
try {
|
|
373
385
|
var _fsResume = require("fs");
|
|
374
386
|
var _pathResume = require("path");
|
|
@@ -378,6 +390,12 @@ function attachSessions(ctx) {
|
|
|
378
390
|
try {
|
|
379
391
|
var metaObj = JSON.parse(firstLine);
|
|
380
392
|
if (metaObj && metaObj.type === "meta" && metaObj.vendor) persistedVendor = metaObj.vendor;
|
|
393
|
+
// Sanitize before it ever reaches resumeSession() (lr-8b2e
|
|
394
|
+
// hardening) — a crafted meta record must not be able to
|
|
395
|
+
// auto-approve a tool with no operator click.
|
|
396
|
+
if (metaObj && metaObj.type === "meta" && metaObj.allowedTools) {
|
|
397
|
+
persistedAllowedTools = utils.sanitizeAllowedTools(metaObj.allowedTools);
|
|
398
|
+
}
|
|
381
399
|
} catch (e) {}
|
|
382
400
|
}
|
|
383
401
|
} catch (e) {}
|
|
@@ -402,10 +420,10 @@ function attachSessions(ctx) {
|
|
|
402
420
|
}
|
|
403
421
|
}
|
|
404
422
|
}
|
|
405
|
-
var resumed = sm.resumeSession(msg.cliSessionId, { history: history, title: title, vendor: persistedVendor || undefined }, ws);
|
|
423
|
+
var resumed = sm.resumeSession(msg.cliSessionId, { history: history, title: title, vendor: persistedVendor || undefined, allowedTools: persistedAllowedTools || undefined }, ws);
|
|
406
424
|
if (resumed) ws._clayActiveSession = resumed.localId;
|
|
407
425
|
}).catch(function() {
|
|
408
|
-
var resumed = sm.resumeSession(msg.cliSessionId, persistedVendor ? { vendor: persistedVendor } : undefined, ws);
|
|
426
|
+
var resumed = sm.resumeSession(msg.cliSessionId, (persistedVendor || persistedAllowedTools) ? { vendor: persistedVendor, allowedTools: persistedAllowedTools } : undefined, ws);
|
|
409
427
|
if (resumed) ws._clayActiveSession = resumed.localId;
|
|
410
428
|
});
|
|
411
429
|
return true;
|
|
@@ -1241,6 +1259,11 @@ function attachSessions(ctx) {
|
|
|
1241
1259
|
if (decision === "allow_always") {
|
|
1242
1260
|
if (!session.allowedTools) session.allowedTools = {};
|
|
1243
1261
|
session.allowedTools[pending.toolName] = true;
|
|
1262
|
+
// Flush immediately (lr-8b2e) so the grant survives daemon restart /
|
|
1263
|
+
// resume-by-cliSessionId rehydration even without a later save
|
|
1264
|
+
// trigger — previously this lived only in the in-memory session
|
|
1265
|
+
// object and was lost on rebuild, causing a spurious re-prompt.
|
|
1266
|
+
sm.saveSessionFile(session);
|
|
1244
1267
|
}
|
|
1245
1268
|
pending.resolve({ behavior: "allow", updatedInput: pending.toolInput });
|
|
1246
1269
|
} else {
|
|
@@ -56,6 +56,38 @@
|
|
|
56
56
|
min-height: 0;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/* Header actions group: Clear all + Close, side by side (parity with the
|
|
60
|
+
Notifications panel's .notif-banner-clear-all placement). */
|
|
61
|
+
.diagnostics-panel-header-actions {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
gap: 6px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.diagnostics-panel-clear-all {
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
padding: 3px 8px;
|
|
71
|
+
background: none;
|
|
72
|
+
border: 1px solid var(--border);
|
|
73
|
+
border-radius: 999px;
|
|
74
|
+
font-family: var(--font-mono, monospace);
|
|
75
|
+
font-size: 9.5px;
|
|
76
|
+
font-weight: 400;
|
|
77
|
+
letter-spacing: 0.06em;
|
|
78
|
+
color: var(--text-muted);
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
transition: color 0.15s, border-color 0.15s;
|
|
81
|
+
}
|
|
82
|
+
.diagnostics-panel-clear-all:hover {
|
|
83
|
+
color: var(--text);
|
|
84
|
+
border-color: var(--border-bright, var(--border));
|
|
85
|
+
}
|
|
86
|
+
.diagnostics-panel-clear-all:focus-visible {
|
|
87
|
+
outline: 2px solid var(--accent);
|
|
88
|
+
outline-offset: 1px;
|
|
89
|
+
}
|
|
90
|
+
|
|
59
91
|
/* --------------------------------------------------------
|
|
60
92
|
Diagnostic items
|
|
61
93
|
-------------------------------------------------------- */
|
|
@@ -114,6 +146,31 @@
|
|
|
114
146
|
letter-spacing: 0.08em;
|
|
115
147
|
}
|
|
116
148
|
|
|
149
|
+
/* Per-entry dismiss (x) control, pushed to the end of the meta row. */
|
|
150
|
+
.diagnostics-item-dismiss {
|
|
151
|
+
margin-left: auto;
|
|
152
|
+
background: none;
|
|
153
|
+
border: none;
|
|
154
|
+
color: var(--text-muted);
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
padding: 2px;
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
justify-content: center;
|
|
160
|
+
border-radius: 4px;
|
|
161
|
+
flex-shrink: 0;
|
|
162
|
+
transition: color 0.15s, background 0.15s;
|
|
163
|
+
}
|
|
164
|
+
.diagnostics-item-dismiss:hover {
|
|
165
|
+
color: var(--text);
|
|
166
|
+
background: rgba(var(--overlay-rgb), 0.06);
|
|
167
|
+
}
|
|
168
|
+
.diagnostics-item-dismiss:focus-visible {
|
|
169
|
+
outline: 2px solid var(--accent);
|
|
170
|
+
outline-offset: 1px;
|
|
171
|
+
}
|
|
172
|
+
.diagnostics-item-dismiss .lucide { width: 12px; height: 12px; }
|
|
173
|
+
|
|
117
174
|
/* Message text */
|
|
118
175
|
.diagnostics-message {
|
|
119
176
|
font-size: 12px;
|
|
@@ -154,17 +211,38 @@
|
|
|
154
211
|
}
|
|
155
212
|
|
|
156
213
|
/* --------------------------------------------------------
|
|
157
|
-
Diagnostic Toast
|
|
158
|
-
|
|
159
|
-
|
|
214
|
+
Diagnostic Toast container (lr-e901)
|
|
215
|
+
Fixed top-right corner stack, off the composer/input box.
|
|
216
|
+
The base .toast family (base.css) is center-bottom over the
|
|
217
|
+
input — fine for a single transient message, but diagnostic
|
|
218
|
+
toasts can arrive concurrently (lr-e901 doubling defect) and
|
|
219
|
+
that spot has no stacking room. Follows the existing corner-
|
|
220
|
+
anchored, flex-column-stacked container precedent already
|
|
221
|
+
used by .notif-banner-container (notifications-center.css)
|
|
222
|
+
rather than introducing a third pattern: normal flow + gap
|
|
223
|
+
handles stacking with no per-toast JS offset math needed.
|
|
160
224
|
-------------------------------------------------------- */
|
|
161
|
-
|
|
225
|
+
#diagnostic-toast-container {
|
|
162
226
|
position: fixed;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
transform: translateX(-50%) translateY(8px);
|
|
227
|
+
top: 48px;
|
|
228
|
+
right: 8px;
|
|
166
229
|
z-index: 450;
|
|
230
|
+
display: flex;
|
|
231
|
+
flex-direction: column;
|
|
232
|
+
gap: 8px;
|
|
233
|
+
pointer-events: none;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* --------------------------------------------------------
|
|
237
|
+
Diagnostic Toast
|
|
238
|
+
Extends the base .toast with richer layout; positioning now
|
|
239
|
+
comes from the parent #diagnostic-toast-container (lr-e901),
|
|
240
|
+
not from the element itself.
|
|
241
|
+
-------------------------------------------------------- */
|
|
242
|
+
.toast-diagnostic {
|
|
243
|
+
position: relative;
|
|
167
244
|
opacity: 0;
|
|
245
|
+
transform: translateY(-8px);
|
|
168
246
|
pointer-events: auto;
|
|
169
247
|
transition: opacity 0.2s, transform 0.2s;
|
|
170
248
|
|
|
@@ -181,7 +259,7 @@
|
|
|
181
259
|
}
|
|
182
260
|
.toast-diagnostic.visible {
|
|
183
261
|
opacity: 1;
|
|
184
|
-
transform:
|
|
262
|
+
transform: translateY(0);
|
|
185
263
|
}
|
|
186
264
|
|
|
187
265
|
/* Severity border accent */
|
|
@@ -259,19 +337,21 @@
|
|
|
259
337
|
Mobile
|
|
260
338
|
-------------------------------------------------------- */
|
|
261
339
|
@media (max-width: 768px) {
|
|
262
|
-
|
|
263
|
-
|
|
340
|
+
/* lr-2fdd: bottom:80px occluded the bottom-nav / input box / content on
|
|
341
|
+
mobile (iOS screenshot showed the PREFLIGHT WARNING toast covering the
|
|
342
|
+
UPCOMING card just above the Projects/Chat/Team/More nav). Top-anchor
|
|
343
|
+
instead, matching the base .toast / .sw-update-banner mobile fix so the
|
|
344
|
+
whole toast family lands the same way. lr-e901 keeps this top-anchor
|
|
345
|
+
intact — only widens the container to full-width since the desktop
|
|
346
|
+
top-right corner box is too narrow/cramped on small viewports. */
|
|
347
|
+
#diagnostic-toast-container {
|
|
348
|
+
top: calc(var(--safe-top) + 12px);
|
|
264
349
|
right: 16px;
|
|
265
|
-
|
|
350
|
+
left: 16px;
|
|
351
|
+
}
|
|
352
|
+
.toast-diagnostic {
|
|
266
353
|
max-width: none;
|
|
267
|
-
|
|
268
|
-
bottom-nav / input box / content on mobile (iOS screenshot showed
|
|
269
|
-
the PREFLIGHT WARNING toast covering the UPCOMING card just above
|
|
270
|
-
the Projects/Chat/Team/More nav). Top-anchor instead, matching the
|
|
271
|
-
base .toast / .sw-update-banner mobile fix so the whole toast
|
|
272
|
-
family lands the same way. */
|
|
273
|
-
top: calc(var(--safe-top) + 12px);
|
|
274
|
-
bottom: auto;
|
|
354
|
+
transform: translateY(-8px);
|
|
275
355
|
}
|
|
276
356
|
.toast-diagnostic.visible {
|
|
277
357
|
transform: translateY(0);
|
package/lib/public/index.html
CHANGED
|
@@ -342,7 +342,10 @@
|
|
|
342
342
|
<div id="diagnostics-panel" class="hidden" role="region" aria-label="Diagnostics" aria-expanded="false" tabindex="-1">
|
|
343
343
|
<div class="usage-panel-header">
|
|
344
344
|
<span>Diagnostics</span>
|
|
345
|
-
<
|
|
345
|
+
<div class="diagnostics-panel-header-actions">
|
|
346
|
+
<button class="diagnostics-panel-clear-all" aria-label="Clear all diagnostics">Clear all</button>
|
|
347
|
+
<button class="diagnostics-panel-close" aria-label="Close diagnostics panel"><i data-lucide="x"></i></button>
|
|
348
|
+
</div>
|
|
346
349
|
</div>
|
|
347
350
|
<div class="usage-panel-body diagnostics-panel-body">
|
|
348
351
|
<div id="diagnostics-panel-list">
|
|
@@ -129,6 +129,22 @@ export function updateHistorySentinel() {
|
|
|
129
129
|
var messagesEl = getMessagesEl();
|
|
130
130
|
var existing = messagesEl.querySelector(".history-sentinel");
|
|
131
131
|
if (store.get('historyFrom') > 0) {
|
|
132
|
+
// Never render a solitary sentinel (lr-c24b): if there is no visible
|
|
133
|
+
// message currently rendered below where the sentinel would sit, a lone
|
|
134
|
+
// "Load earlier messages" button with nothing above it is not a useful
|
|
135
|
+
// affordance — trigger a load instead of displaying it. This can happen
|
|
136
|
+
// after a prepend page advanced historyFrom without rendering any
|
|
137
|
+
// visible content. Skipped mid-initial-replay (replayingHistory): that
|
|
138
|
+
// path's own history_meta -> item stream -> history_done sequence is
|
|
139
|
+
// already populating #messages and has not finished yet, so an empty
|
|
140
|
+
// container at this instant is expected, not a stuck page.
|
|
141
|
+
var hasRenderedContent = !!(existing ? existing.nextElementSibling : messagesEl.firstElementChild);
|
|
142
|
+
if (!hasRenderedContent && !store.get('replayingHistory')) {
|
|
143
|
+
if (existing) existing.remove();
|
|
144
|
+
if (historySentinelObserver) { historySentinelObserver.disconnect(); historySentinelObserver = null; }
|
|
145
|
+
if (!store.get('loadingMore')) requestMoreHistory();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
132
148
|
if (!existing) {
|
|
133
149
|
var sentinel = document.createElement("div");
|
|
134
150
|
sentinel.className = "history-sentinel";
|
|
@@ -153,15 +169,26 @@ export function updateHistorySentinel() {
|
|
|
153
169
|
}
|
|
154
170
|
}
|
|
155
171
|
|
|
172
|
+
// Sends the load_more_history request. Assumes the caller has already
|
|
173
|
+
// validated preconditions (ws connected, historyFrom > 0) and set
|
|
174
|
+
// loadingMore — shared by requestMoreHistory (guarded, user/observer-
|
|
175
|
+
// triggered) and prependOlderHistory's auto-advance (lr-c24b), which is
|
|
176
|
+
// already mid-load and must not be blocked by the loadingMore guard.
|
|
177
|
+
function sendLoadMoreHistory(before) {
|
|
178
|
+
var ws = getWs();
|
|
179
|
+
if (!ws) return;
|
|
180
|
+
var messagesEl = getMessagesEl();
|
|
181
|
+
var btn = messagesEl.querySelector(".load-more-btn");
|
|
182
|
+
if (btn) btn.classList.add("loading");
|
|
183
|
+
ws.send(JSON.stringify({ type: "load_more_history", before: before }));
|
|
184
|
+
}
|
|
185
|
+
|
|
156
186
|
export function requestMoreHistory() {
|
|
157
187
|
var ws = getWs();
|
|
158
188
|
var s = store.snap();
|
|
159
189
|
if (s.loadingMore || s.historyFrom <= 0 || !ws || !s.connected) return;
|
|
160
190
|
store.set({ loadingMore: true });
|
|
161
|
-
|
|
162
|
-
var btn = messagesEl.querySelector(".load-more-btn");
|
|
163
|
-
if (btn) btn.classList.add("loading");
|
|
164
|
-
ws.send(JSON.stringify({ type: "load_more_history", before: s.historyFrom }));
|
|
191
|
+
sendLoadMoreHistory(s.historyFrom);
|
|
165
192
|
}
|
|
166
193
|
|
|
167
194
|
export function prependOlderHistory(items, meta) {
|
|
@@ -193,6 +220,16 @@ export function prependOlderHistory(items, meta) {
|
|
|
193
220
|
var anchorEl = getPrependAnchor();
|
|
194
221
|
var anchorOffset = anchorEl ? anchorEl.getBoundingClientRect().top : 0;
|
|
195
222
|
|
|
223
|
+
// Snapshot the sibling immediately before the anchor (or the last child,
|
|
224
|
+
// when the container was empty) so the batch's visible yield can be
|
|
225
|
+
// measured after rendering (lr-c24b). addToMessages() (app-rendering.js)
|
|
226
|
+
// is the single choke point for top-level #messages insertion during
|
|
227
|
+
// processMessage(), and it always inserts immediately before the current
|
|
228
|
+
// prepend anchor — so any new node from this batch appears between this
|
|
229
|
+
// snapshot and anchorEl. anchorEl itself is never removed/replaced by the
|
|
230
|
+
// rendering pipeline, so it remains a stable reference across the batch.
|
|
231
|
+
var siblingBeforeAnchor = anchorEl ? anchorEl.previousSibling : messagesEl.lastChild;
|
|
232
|
+
|
|
196
233
|
// Process each item through the rendering pipeline
|
|
197
234
|
for (var i = 0; i < items.length; i++) {
|
|
198
235
|
processMessage(items[i]);
|
|
@@ -204,6 +241,13 @@ export function prependOlderHistory(items, meta) {
|
|
|
204
241
|
// Clear prepend mode
|
|
205
242
|
setPrependAnchor(null);
|
|
206
243
|
|
|
244
|
+
// Did this page render any visible DOM? If the sibling immediately before
|
|
245
|
+
// the anchor (or the container's last child, for an initially-empty
|
|
246
|
+
// container) is unchanged, the batch inserted nothing new.
|
|
247
|
+
var renderedNoVisibleContent = anchorEl
|
|
248
|
+
? anchorEl.previousSibling === siblingBeforeAnchor
|
|
249
|
+
: messagesEl.lastChild === siblingBeforeAnchor;
|
|
250
|
+
|
|
207
251
|
// Restore saved state
|
|
208
252
|
store.set({ currentMsgEl: savedMsgEl, currentFullText: savedFullText });
|
|
209
253
|
resetCurrentFullText(savedFullText);
|
|
@@ -223,7 +267,7 @@ export function prependOlderHistory(items, meta) {
|
|
|
223
267
|
}
|
|
224
268
|
|
|
225
269
|
// Update state
|
|
226
|
-
store.set({ historyFrom: meta.from
|
|
270
|
+
store.set({ historyFrom: meta.from });
|
|
227
271
|
|
|
228
272
|
// Renumber data-turn attributes in DOM order
|
|
229
273
|
var turnEls = messagesEl.querySelectorAll("[data-turn]");
|
|
@@ -232,12 +276,26 @@ export function prependOlderHistory(items, meta) {
|
|
|
232
276
|
}
|
|
233
277
|
setTurnCounter(turnEls.length);
|
|
234
278
|
|
|
235
|
-
//
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
279
|
+
// Auto-advance when this page rendered nothing visible (lr-c24b): the
|
|
280
|
+
// server already extends the window by turn boundary to surface a visible
|
|
281
|
+
// event when possible, but a bounded extension can still exhaust its step
|
|
282
|
+
// cap on a pathologically long invisible-yield run. One user click (or one
|
|
283
|
+
// sentinel auto-load) must always surface >=1 message when older history
|
|
284
|
+
// exists — settle loadingMore:false only once something rendered, or there
|
|
285
|
+
// is nothing left to load.
|
|
286
|
+
if (renderedNoVisibleContent && meta.hasMore) {
|
|
287
|
+
// loadingMore stays true; the next history_prepend response re-enters
|
|
288
|
+
// this function and re-evaluates.
|
|
289
|
+
sendLoadMoreHistory(meta.from);
|
|
239
290
|
} else {
|
|
240
|
-
|
|
291
|
+
store.set({ loadingMore: false });
|
|
292
|
+
// Update sentinel
|
|
293
|
+
if (meta.hasMore) {
|
|
294
|
+
var btn = messagesEl.querySelector(".load-more-btn");
|
|
295
|
+
if (btn) btn.classList.remove("loading");
|
|
296
|
+
} else {
|
|
297
|
+
updateHistorySentinel();
|
|
298
|
+
}
|
|
241
299
|
}
|
|
242
300
|
|
|
243
301
|
// Notify in-session search that history was prepended (for pending scroll targets)
|
|
@@ -13,14 +13,30 @@ var SOURCE_LABELS = {
|
|
|
13
13
|
preflight: "Preflight",
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
// Terse scope suffixes shown alongside the source label (lr-7e22). Settings
|
|
17
|
+
// preflight runs against both ~/.claude/settings.json and the project's
|
|
18
|
+
// .claude/settings.json independently, emitting one diagnostic per unknown
|
|
19
|
+
// key per file — without a scope suffix, two distinct warnings render an
|
|
20
|
+
// identical "Preflight" header and visually stack as apparent duplicates.
|
|
21
|
+
var SCOPE_LABELS = {
|
|
22
|
+
user: "user",
|
|
23
|
+
project: "project",
|
|
24
|
+
};
|
|
25
|
+
|
|
16
26
|
/**
|
|
17
27
|
* Format a raw diagnostic source identifier for display.
|
|
18
28
|
* @param {string} source - The source field from the diagnostic message.
|
|
29
|
+
* @param {string} [scope] - Optional file/config scope ('user' | 'project').
|
|
30
|
+
* When present and recognized, appended to the
|
|
31
|
+
* source label so diagnostics from different
|
|
32
|
+
* scopes are distinguishable at a glance.
|
|
19
33
|
* @returns {string} Human-readable source label.
|
|
20
34
|
*/
|
|
21
|
-
export function formatDiagnosticSource(source) {
|
|
35
|
+
export function formatDiagnosticSource(source, scope) {
|
|
22
36
|
if (!source) return "Diagnostic";
|
|
23
|
-
|
|
37
|
+
var label = SOURCE_LABELS[source] || source;
|
|
38
|
+
var scopeLabel = scope && SCOPE_LABELS[scope];
|
|
39
|
+
return scopeLabel ? label + " · " + scopeLabel : label;
|
|
24
40
|
}
|
|
25
41
|
|
|
26
42
|
/**
|