@clagentic/console 1.1.0-beta.1 → 1.1.0
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
CHANGED
|
@@ -2606,7 +2606,11 @@ var { checkAndUpdate } = require("../lib/updater");
|
|
|
2606
2606
|
var currentVersion = require("../package.json").version;
|
|
2607
2607
|
|
|
2608
2608
|
(async function () {
|
|
2609
|
-
|
|
2609
|
+
// Read update channel from saved config (best-effort — may not exist yet on first run)
|
|
2610
|
+
var _startupConfig = null;
|
|
2611
|
+
try { _startupConfig = loadConfig(); } catch (e) {}
|
|
2612
|
+
var _updateChannel = (_startupConfig && _startupConfig.updateChannel) || (currentVersion.includes("-") ? "beta" : "stable");
|
|
2613
|
+
var updated = await checkAndUpdate(currentVersion, skipUpdate, _updateChannel);
|
|
2610
2614
|
if (updated) return;
|
|
2611
2615
|
|
|
2612
2616
|
// Dev mode — foreground daemon with file watching
|
|
@@ -184,32 +184,18 @@ function attachConnection(ctx) {
|
|
|
184
184
|
}
|
|
185
185
|
ws._clayActiveSession = active.localId;
|
|
186
186
|
var _vendorCaps = (sm.capabilitiesByVendor && sm.capabilitiesByVendor[active.vendor || sm.defaultVendor || "claude"]) || {};
|
|
187
|
-
|
|
187
|
+
// Load history from disk before checking hasHistory — the session may have
|
|
188
|
+
// been evicted from the LRU cache (lr-f311 lazy load), in which case
|
|
189
|
+
// active.history is [] in memory even though the session file has content.
|
|
190
|
+
sm.loadSessionHistory(active);
|
|
191
|
+
sendTo(ws, { type: "session_switched", id: active.localId, cliSessionId: active.cliSessionId || null, loop: active.loop || null, vendor: active.vendor || null, hasHistory: (active.history.length > 0), capabilities: _vendorCaps, agentName: active.agentName || null });
|
|
188
192
|
// Send per-session context sources
|
|
189
193
|
var sessionSources = loadContextSources(slug, active.localId);
|
|
190
194
|
sendTo(ws, { type: "context_sources_state", active: sessionSources });
|
|
191
195
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
fromIndex = sm.findTurnBoundary(active.history, Math.max(0, total - sm.HISTORY_PAGE_SIZE));
|
|
196
|
-
}
|
|
197
|
-
sendTo(ws, { type: "history_meta", total: total, from: fromIndex });
|
|
198
|
-
for (var i = fromIndex; i < total; i++) {
|
|
199
|
-
sendTo(ws, hydrateImageRefs(active.history[i]));
|
|
200
|
-
}
|
|
201
|
-
var _lastUsage = null, _lastModelUsage = null, _lastCost = null, _lastStreamInputTokens = null;
|
|
202
|
-
for (var _ri = total - 1; _ri >= 0; _ri--) {
|
|
203
|
-
if (active.history[_ri].type === "result") {
|
|
204
|
-
var _r = active.history[_ri];
|
|
205
|
-
_lastUsage = _r.usage || null;
|
|
206
|
-
_lastModelUsage = _r.modelUsage || null;
|
|
207
|
-
_lastCost = _r.cost != null ? _r.cost : null;
|
|
208
|
-
_lastStreamInputTokens = _r.lastStreamInputTokens || null;
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
sendTo(ws, { type: "history_done", lastUsage: _lastUsage, lastModelUsage: _lastModelUsage, lastCost: _lastCost, lastStreamInputTokens: _lastStreamInputTokens, contextUsage: active.lastContextUsage || null });
|
|
196
|
+
// Use sm.replayHistory so history is guaranteed loaded from disk (handles
|
|
197
|
+
// LRU eviction) and the replay logic stays in one place.
|
|
198
|
+
sm.replayHistory(active, undefined, ws, hydrateImageRefs);
|
|
213
199
|
|
|
214
200
|
if (active.isProcessing) {
|
|
215
201
|
sendTo(ws, { type: "status", status: "processing" });
|
package/lib/public/app.js
CHANGED
|
@@ -625,6 +625,11 @@ import { initMention, handleMentionStart, handleMentionStream, handleMentionDone
|
|
|
625
625
|
basePath = "/p/" + newSlug + "/";
|
|
626
626
|
wsPath = "/p/" + newSlug + "/ws";
|
|
627
627
|
store.set({ basePath: basePath, wsPath: wsPath });
|
|
628
|
+
// Clear session list before connecting so the sidebar doesn't show
|
|
629
|
+
// the previous project's sessions. Must be called here (not inside
|
|
630
|
+
// resetClientState) because resetClientState is also called from
|
|
631
|
+
// session_switched where the list must be preserved.
|
|
632
|
+
resetSessionList();
|
|
628
633
|
resetClientState();
|
|
629
634
|
connect();
|
|
630
635
|
}
|
|
@@ -426,10 +426,11 @@ export function resetClientState() {
|
|
|
426
426
|
// Clear vendor state so the incoming model_info for the new project is never
|
|
427
427
|
// blocked by a lock that was set during the previous project's session.
|
|
428
428
|
store.set({ currentVendor: null, vendorSelectionLocked: false, codexApproval: null, codexSandbox: null, codexWebSearch: null });
|
|
429
|
-
//
|
|
430
|
-
// project
|
|
431
|
-
//
|
|
432
|
-
|
|
429
|
+
// NOTE: session list reset is NOT done here. resetClientState() is also called
|
|
430
|
+
// from session_switched (within-project session switching) where the session
|
|
431
|
+
// list must be preserved. Session list clearing is done only in switchProject()
|
|
432
|
+
// and the popstate handler via _onResetClientState, which are the only paths
|
|
433
|
+
// that actually change projects.
|
|
433
434
|
}
|
|
434
435
|
|
|
435
436
|
export function switchProject(slug) {
|
|
@@ -461,6 +462,12 @@ export function switchProject(slug) {
|
|
|
461
462
|
} else {
|
|
462
463
|
history.pushState(null, "", "/p/" + slug + "/");
|
|
463
464
|
}
|
|
465
|
+
// Clear the session list immediately so the sidebar shows blank (not the
|
|
466
|
+
// previous project's sessions) while waiting for the new project's
|
|
467
|
+
// session_list. Must happen here, NOT in resetClientState(), because
|
|
468
|
+
// resetClientState() is also called from session_switched (within-project
|
|
469
|
+
// session switch) where the session list must stay intact.
|
|
470
|
+
if (typeof _onResetClientState === "function") _onResetClientState();
|
|
464
471
|
resetClientState();
|
|
465
472
|
connect();
|
|
466
473
|
}
|
|
@@ -390,6 +390,7 @@ function refreshSessionTopActions() {
|
|
|
390
390
|
if (!oldActions) return;
|
|
391
391
|
var newActions = renderSessionTopActions();
|
|
392
392
|
stickyTop.replaceChild(newActions, oldActions);
|
|
393
|
+
refreshIcons(newActions);
|
|
393
394
|
}
|
|
394
395
|
|
|
395
396
|
function runSessionSearch(query) {
|
|
@@ -583,12 +584,15 @@ export function getCachedSessions() {
|
|
|
583
584
|
}
|
|
584
585
|
|
|
585
586
|
// Called by resetClientState() on project switch. Clears the cached session
|
|
586
|
-
// list and
|
|
587
|
-
//
|
|
587
|
+
// list and immediately wipes the DOM so the sidebar is blank while waiting
|
|
588
|
+
// for the new project's session_list. Bypasses the fingerprint guard on
|
|
589
|
+
// purpose — when both old and new fingerprints are "" (empty list) the guard
|
|
590
|
+
// would return early before clearing innerHTML, leaving stale sessions visible.
|
|
588
591
|
export function resetSessionList() {
|
|
589
592
|
cachedSessions = [];
|
|
590
|
-
_sessionListFingerprint = "";
|
|
591
|
-
|
|
593
|
+
_sessionListFingerprint = "__reset__";
|
|
594
|
+
var listEl = getSessionListEl();
|
|
595
|
+
if (listEl) listEl.innerHTML = "";
|
|
592
596
|
}
|
|
593
597
|
|
|
594
598
|
export function getSearchQuery() {
|
package/lib/updater.js
CHANGED
|
@@ -99,16 +99,30 @@ function reExec() {
|
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
async function checkAndUpdate(currentVersion, skipUpdate) {
|
|
102
|
+
async function checkAndUpdate(currentVersion, skipUpdate, channel) {
|
|
103
103
|
if (skipUpdate) return false;
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
// Determine which npm tag(s) to check. When the current version is a pre-release
|
|
106
|
+
// (e.g. 1.0.5-beta.1) or the saved channel is "beta", check the beta tag.
|
|
107
|
+
// Always also check latest so a stable release is never missed.
|
|
108
|
+
var isBeta = channel === "beta" || (currentVersion && currentVersion.includes("-"));
|
|
109
|
+
var tags = isBeta ? ["beta", "latest"] : ["latest"];
|
|
110
|
+
|
|
111
|
+
var latest = null;
|
|
112
|
+
for (var ti = 0; ti < tags.length; ti++) {
|
|
113
|
+
var candidate = await fetchVersion(tags[ti]);
|
|
114
|
+
if (candidate && (!latest || isNewer(candidate, latest))) {
|
|
115
|
+
latest = candidate;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
106
119
|
if (!latest || !isNewer(latest, currentVersion)) return false;
|
|
107
120
|
|
|
121
|
+
var tag = (isBeta && latest.includes("-")) ? "beta" : "latest";
|
|
108
122
|
log(sym.pointer + " " + a.bold + "Update available" + a.reset + " " + a.dim + currentVersion + " -> " + latest + a.reset);
|
|
109
123
|
log(sym.bar + " Installing...");
|
|
110
124
|
|
|
111
|
-
if (performUpdate()) {
|
|
125
|
+
if (performUpdate(tag === "beta" ? "beta" : "stable")) {
|
|
112
126
|
log(sym.done + " Updated to " + a.green + latest + a.reset);
|
|
113
127
|
log("");
|
|
114
128
|
reExec();
|
|
@@ -116,7 +130,7 @@ async function checkAndUpdate(currentVersion, skipUpdate) {
|
|
|
116
130
|
}
|
|
117
131
|
|
|
118
132
|
log(sym.warn + " " + a.yellow + "Update failed" + a.reset + a.dim + " (permission denied?)" + a.reset);
|
|
119
|
-
log(sym.bar + " " + a.dim + "Run manually: npm install -g @clagentic/console@
|
|
133
|
+
log(sym.bar + " " + a.dim + "Run manually: npm install -g @clagentic/console@" + tag + a.reset);
|
|
120
134
|
log("");
|
|
121
135
|
return false;
|
|
122
136
|
}
|
package/package.json
CHANGED