@clagentic/console 1.1.0-beta.1 → 1.1.0-beta.2

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
- var updated = await checkAndUpdate(currentVersion, skipUpdate);
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
- sendTo(ws, { type: "session_switched", id: active.localId, cliSessionId: active.cliSessionId || null, loop: active.loop || null, vendor: active.vendor || null, hasHistory: (active.history && active.history.length > 0), capabilities: _vendorCaps, agentName: active.agentName || null });
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
- var total = active.history.length;
193
- var fromIndex = 0;
194
- if (total > sm.HISTORY_PAGE_SIZE) {
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
- // Clear the session list immediately so the sidebar doesn't show the previous
430
- // project's sessions while waiting for the new project's session_list from
431
- // the server. Resets the fingerprint too so the incoming list is never skipped.
432
- if (typeof _onResetClientState === "function") _onResetClientState();
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
  }
@@ -583,12 +583,15 @@ export function getCachedSessions() {
583
583
  }
584
584
 
585
585
  // Called by resetClientState() on project switch. Clears the cached session
586
- // list and resets the fingerprint so the next session_list from the new
587
- // project is always rendered (never skipped by the fingerprint guard).
586
+ // list and immediately wipes the DOM so the sidebar is blank while waiting
587
+ // for the new project's session_list. Bypasses the fingerprint guard on
588
+ // purpose — when both old and new fingerprints are "" (empty list) the guard
589
+ // would return early before clearing innerHTML, leaving stale sessions visible.
588
590
  export function resetSessionList() {
589
591
  cachedSessions = [];
590
- _sessionListFingerprint = "";
591
- renderSessionList(null);
592
+ _sessionListFingerprint = "__reset__";
593
+ var listEl = getSessionListEl();
594
+ if (listEl) listEl.innerHTML = "";
592
595
  }
593
596
 
594
597
  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
- var latest = await fetchLatestVersion();
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@latest" + a.reset);
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
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.1.0-beta.1",
6
+ "version": "1.1.0-beta.2",
7
7
  "description": "Self-hosted console for Claude Code and Codex. Multi-user, browser-based, persistent AI sessions.",
8
8
  "bin": {
9
9
  "clagentic": "./bin/cli.js",