@clagentic/console 1.2.1-beta.1 → 1.3.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/lib/project-loop.js +47 -1
- package/lib/project.js +2 -0
- package/lib/public/css/home-hub.css +72 -0
- package/lib/public/css/overlays.css +54 -0
- package/lib/public/index.html +11 -0
- package/lib/public/modules/app-connection.js +19 -0
- package/lib/public/modules/app-home-hub.js +62 -1
- package/lib/public/modules/app-messages.js +24 -1
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-rendering.js +9 -0
- package/lib/public/modules/markdown.js +37 -21
- package/lib/public/modules/settings-defaults.js +14 -2
- package/lib/public/modules/sidebar-mobile.js +33 -13
- package/lib/server.js +8 -2
- package/lib/ws-schema.js +4 -2
- package/lib/yoke/adapters/claude.js +106 -154
- package/lib/yoke/adapters/codex.js +55 -9
- package/package.json +1 -2
package/lib/project-loop.js
CHANGED
|
@@ -11,7 +11,8 @@ var usersModule = require("./users");
|
|
|
11
11
|
*
|
|
12
12
|
* ctx fields:
|
|
13
13
|
* cwd, slug, sm, sdk, send, sendTo, sendToSession, pushModule,
|
|
14
|
-
* getHubSchedules,
|
|
14
|
+
* getHubSchedules, getAllProjectSessions, getStatus,
|
|
15
|
+
* getLinuxUserForSession, onProcessingChanged,
|
|
15
16
|
* hydrateImageRefs
|
|
16
17
|
*/
|
|
17
18
|
function attachLoop(ctx) {
|
|
@@ -25,6 +26,8 @@ function attachLoop(ctx) {
|
|
|
25
26
|
var pushModule = ctx.pushModule;
|
|
26
27
|
var notificationsModule = ctx.notificationsModule;
|
|
27
28
|
var getHubSchedules = ctx.getHubSchedules;
|
|
29
|
+
var getAllProjectSessions = ctx.getAllProjectSessions;
|
|
30
|
+
var getStatus = ctx.getStatus;
|
|
28
31
|
var getLinuxUserForSession = ctx.getLinuxUserForSession;
|
|
29
32
|
var onProcessingChanged = ctx.onProcessingChanged;
|
|
30
33
|
var hydrateImageRefs = ctx.hydrateImageRefs;
|
|
@@ -1139,6 +1142,49 @@ function attachLoop(ctx) {
|
|
|
1139
1142
|
return true;
|
|
1140
1143
|
}
|
|
1141
1144
|
|
|
1145
|
+
// --- Hub: cross-project recent sessions ---
|
|
1146
|
+
if (msg.type === "hub_recent_sessions_list") {
|
|
1147
|
+
// Other-project sessions (already have _projectTitle set by getAllProjectSessions)
|
|
1148
|
+
// getAllProjectSessions returns annotated shallow copies (not live objects).
|
|
1149
|
+
// Each copy carries _projectTitle, _projectSlug, _projectIcon from server.js.
|
|
1150
|
+
// We then append the current project's own sessions below with self metadata.
|
|
1151
|
+
var otherSessions = getAllProjectSessions ? getAllProjectSessions() : [];
|
|
1152
|
+
var selfStatus = getStatus ? getStatus() : {};
|
|
1153
|
+
var selfSlug = selfStatus.slug || slug;
|
|
1154
|
+
var selfTitle = selfStatus.title || selfStatus.project || selfSlug;
|
|
1155
|
+
var selfIcon = selfStatus.icon || null;
|
|
1156
|
+
var allSessions = otherSessions.slice();
|
|
1157
|
+
sm.sessions.forEach(function (s) {
|
|
1158
|
+
if (!s.hidden) {
|
|
1159
|
+
allSessions.push(Object.assign({}, s, {
|
|
1160
|
+
_projectSlug: selfSlug,
|
|
1161
|
+
_projectTitle: selfTitle,
|
|
1162
|
+
_projectIcon: selfIcon,
|
|
1163
|
+
}));
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
// Sort newest-first by lastActivity
|
|
1167
|
+
allSessions.sort(function (a, b) {
|
|
1168
|
+
return (b.lastActivity || b.createdAt || 0) - (a.lastActivity || a.createdAt || 0);
|
|
1169
|
+
});
|
|
1170
|
+
var top10 = allSessions.slice(0, 10);
|
|
1171
|
+
var mapped = top10.map(function (s) {
|
|
1172
|
+
return {
|
|
1173
|
+
id: s.localId,
|
|
1174
|
+
title: s.title || "New Session",
|
|
1175
|
+
lastActivity: s.lastActivity || s.createdAt || 0,
|
|
1176
|
+
projectSlug: s._projectSlug || selfSlug,
|
|
1177
|
+
projectTitle: s._projectTitle || selfTitle,
|
|
1178
|
+
projectIcon: s._projectIcon || null,
|
|
1179
|
+
vendor: s.vendor || null,
|
|
1180
|
+
agentName: s.agentName || null,
|
|
1181
|
+
isProcessing: !!s.isProcessing,
|
|
1182
|
+
};
|
|
1183
|
+
});
|
|
1184
|
+
sendTo(ws, { type: "hub_recent_sessions", sessions: mapped });
|
|
1185
|
+
return true;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1142
1188
|
// --- Loop Registry messages ---
|
|
1143
1189
|
if (msg.type === "loop_registry_list") {
|
|
1144
1190
|
sendTo(ws, { type: "loop_registry_updated", records: getHubSchedules() });
|
package/lib/project.js
CHANGED
|
@@ -600,6 +600,8 @@ function createProjectContext(opts) {
|
|
|
600
600
|
pushModule: pushModule,
|
|
601
601
|
notificationsModule: _notifications,
|
|
602
602
|
getHubSchedules: getHubSchedules,
|
|
603
|
+
getAllProjectSessions: getAllProjectSessions,
|
|
604
|
+
getStatus: getStatus,
|
|
603
605
|
getLinuxUserForSession: getLinuxUserForSession,
|
|
604
606
|
onProcessingChanged: onProcessingChanged,
|
|
605
607
|
hydrateImageRefs: hydrateImageRefs,
|
|
@@ -420,6 +420,78 @@
|
|
|
420
420
|
height: 14px;
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
+
/* --- Recent Sessions --- */
|
|
424
|
+
.hub-recent-sessions {
|
|
425
|
+
animation: hubCardIn 0.4s ease 0.2s both;
|
|
426
|
+
}
|
|
427
|
+
.hub-recent-sessions-list {
|
|
428
|
+
display: flex;
|
|
429
|
+
flex-direction: column;
|
|
430
|
+
gap: 2px;
|
|
431
|
+
}
|
|
432
|
+
.hub-recent-item {
|
|
433
|
+
display: flex;
|
|
434
|
+
align-items: center;
|
|
435
|
+
gap: 10px;
|
|
436
|
+
padding: 8px 10px;
|
|
437
|
+
border-radius: 8px;
|
|
438
|
+
cursor: pointer;
|
|
439
|
+
transition: background 0.15s ease;
|
|
440
|
+
}
|
|
441
|
+
.hub-recent-item:hover {
|
|
442
|
+
background: rgba(var(--overlay-rgb), 0.06);
|
|
443
|
+
}
|
|
444
|
+
.hub-recent-project-icon {
|
|
445
|
+
font-size: 14px;
|
|
446
|
+
width: 20px;
|
|
447
|
+
text-align: center;
|
|
448
|
+
flex-shrink: 0;
|
|
449
|
+
}
|
|
450
|
+
.hub-recent-project-icon--blank {
|
|
451
|
+
width: 20px;
|
|
452
|
+
height: 20px;
|
|
453
|
+
border-radius: 4px;
|
|
454
|
+
background: rgba(var(--overlay-rgb), 0.08);
|
|
455
|
+
display: inline-block;
|
|
456
|
+
vertical-align: middle;
|
|
457
|
+
}
|
|
458
|
+
.hub-recent-title {
|
|
459
|
+
font-size: 13px;
|
|
460
|
+
color: var(--text);
|
|
461
|
+
flex: 1;
|
|
462
|
+
min-width: 0;
|
|
463
|
+
overflow: hidden;
|
|
464
|
+
text-overflow: ellipsis;
|
|
465
|
+
white-space: nowrap;
|
|
466
|
+
}
|
|
467
|
+
.hub-recent-agent {
|
|
468
|
+
font-size: 10px;
|
|
469
|
+
font-weight: 600;
|
|
470
|
+
color: var(--accent);
|
|
471
|
+
background: var(--accent-12);
|
|
472
|
+
padding: 1px 6px;
|
|
473
|
+
border-radius: 6px;
|
|
474
|
+
flex-shrink: 0;
|
|
475
|
+
max-width: 70px;
|
|
476
|
+
overflow: hidden;
|
|
477
|
+
text-overflow: ellipsis;
|
|
478
|
+
white-space: nowrap;
|
|
479
|
+
}
|
|
480
|
+
.hub-recent-time {
|
|
481
|
+
font-size: 11px;
|
|
482
|
+
color: var(--text-dimmer);
|
|
483
|
+
flex-shrink: 0;
|
|
484
|
+
font-variant-numeric: tabular-nums;
|
|
485
|
+
min-width: 52px;
|
|
486
|
+
text-align: right;
|
|
487
|
+
}
|
|
488
|
+
.hub-recent-empty {
|
|
489
|
+
font-size: 13px;
|
|
490
|
+
color: var(--text-dimmer);
|
|
491
|
+
text-align: center;
|
|
492
|
+
padding: 16px 8px;
|
|
493
|
+
}
|
|
494
|
+
|
|
423
495
|
/* Hide user island when hub is visible */
|
|
424
496
|
#main-area:has(#home-hub:not(.hidden)) ~ #user-island,
|
|
425
497
|
#layout-body:has(#home-hub:not(.hidden)) #user-island {
|
|
@@ -1235,6 +1235,60 @@ button.top-bar-pill.pill-accent:hover { background: color-mix(in srgb, var(--acc
|
|
|
1235
1235
|
animation: spin 0.6s linear infinite;
|
|
1236
1236
|
}
|
|
1237
1237
|
|
|
1238
|
+
/* --- Session replay loading indicator --- */
|
|
1239
|
+
#replay-loading {
|
|
1240
|
+
position: absolute;
|
|
1241
|
+
top: 0;
|
|
1242
|
+
left: 0;
|
|
1243
|
+
right: 0;
|
|
1244
|
+
display: flex;
|
|
1245
|
+
flex-direction: column;
|
|
1246
|
+
align-items: center;
|
|
1247
|
+
gap: 10px;
|
|
1248
|
+
padding: 20px 16px 16px;
|
|
1249
|
+
pointer-events: none;
|
|
1250
|
+
z-index: 10;
|
|
1251
|
+
animation: replayFadeIn 0.15s ease;
|
|
1252
|
+
}
|
|
1253
|
+
#replay-loading.hidden {
|
|
1254
|
+
display: none;
|
|
1255
|
+
}
|
|
1256
|
+
@keyframes replayFadeIn {
|
|
1257
|
+
from { opacity: 0; }
|
|
1258
|
+
to { opacity: 1; }
|
|
1259
|
+
}
|
|
1260
|
+
.replay-loading-bar {
|
|
1261
|
+
width: 100%;
|
|
1262
|
+
max-width: 320px;
|
|
1263
|
+
height: 3px;
|
|
1264
|
+
border-radius: 2px;
|
|
1265
|
+
background: var(--border-subtle);
|
|
1266
|
+
overflow: hidden;
|
|
1267
|
+
position: relative;
|
|
1268
|
+
}
|
|
1269
|
+
.replay-loading-bar::after {
|
|
1270
|
+
content: "";
|
|
1271
|
+
position: absolute;
|
|
1272
|
+
top: 0;
|
|
1273
|
+
left: -40%;
|
|
1274
|
+
width: 40%;
|
|
1275
|
+
height: 100%;
|
|
1276
|
+
background: var(--accent);
|
|
1277
|
+
border-radius: 2px;
|
|
1278
|
+
animation: replayBarSlide 1.2s ease-in-out infinite;
|
|
1279
|
+
}
|
|
1280
|
+
@keyframes replayBarSlide {
|
|
1281
|
+
0% { left: -40%; }
|
|
1282
|
+
100% { left: 100%; }
|
|
1283
|
+
}
|
|
1284
|
+
.replay-loading-label {
|
|
1285
|
+
font-size: 11px;
|
|
1286
|
+
font-weight: 500;
|
|
1287
|
+
color: var(--text-dimmer);
|
|
1288
|
+
letter-spacing: 0.3px;
|
|
1289
|
+
font-family: var(--font-mono);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1238
1292
|
/* --- Connect overlay --- */
|
|
1239
1293
|
#connect-overlay {
|
|
1240
1294
|
position: fixed;
|
package/lib/public/index.html
CHANGED
|
@@ -174,6 +174,13 @@
|
|
|
174
174
|
<div class="hub-week-strip" id="hub-week-strip"></div>
|
|
175
175
|
</div>
|
|
176
176
|
|
|
177
|
+
<div class="hub-card hub-recent-sessions">
|
|
178
|
+
<div class="hub-card-header">
|
|
179
|
+
<span class="hub-card-title">Recent Sessions</span>
|
|
180
|
+
</div>
|
|
181
|
+
<div class="hub-recent-sessions-list" id="hub-recent-sessions-list"></div>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
177
184
|
</div>
|
|
178
185
|
</div>
|
|
179
186
|
<div id="sidebar-column">
|
|
@@ -274,6 +281,10 @@
|
|
|
274
281
|
<p id="connect-overlay-msg">Reconnecting to server…</p>
|
|
275
282
|
</div>
|
|
276
283
|
<div id="sticky-notes-container" class="hidden"></div>
|
|
284
|
+
<div id="replay-loading" class="hidden">
|
|
285
|
+
<div class="replay-loading-bar"></div>
|
|
286
|
+
<span class="replay-loading-label">Loading session…</span>
|
|
287
|
+
</div>
|
|
277
288
|
<div id="messages"></div>
|
|
278
289
|
|
|
279
290
|
<div id="info-panels">
|
|
@@ -9,6 +9,7 @@ import { startLogoAnimation, stopLogoAnimation } from './console-logo.js';
|
|
|
9
9
|
import { hasSendableContent } from './input.js';
|
|
10
10
|
import { processMessage } from './app-messages.js';
|
|
11
11
|
import { flushPendingExtMessages } from './app-misc.js';
|
|
12
|
+
import { isHomeHubVisible } from './app-home-hub.js';
|
|
12
13
|
import { resetTerminals } from './terminal.js';
|
|
13
14
|
import { closeDmUserPicker } from './sidebar-users.js';
|
|
14
15
|
import { openDm } from './app-dm.js';
|
|
@@ -72,6 +73,9 @@ export function initConnection() {
|
|
|
72
73
|
stopLogoAnimation();
|
|
73
74
|
} else {
|
|
74
75
|
if (sendBtn) sendBtn.disabled = true;
|
|
76
|
+
// Clear any in-progress replay indicator — history_done won't fire on disconnect.
|
|
77
|
+
var replayEl = document.getElementById("replay-loading");
|
|
78
|
+
if (replayEl) replayEl.classList.add("hidden");
|
|
75
79
|
// Delay showing the overlay by 600ms — absorbs brief AP switches and
|
|
76
80
|
// sub-second network hiccups without flashing the full-screen animation.
|
|
77
81
|
if (overlayGraceTimer) clearTimeout(overlayGraceTimer);
|
|
@@ -135,6 +139,21 @@ function onConnected() {
|
|
|
135
139
|
|
|
136
140
|
// Session restore is now server-driven (user-presence.json).
|
|
137
141
|
try { localStorage.removeItem("clagentic-active-dm"); localStorage.removeItem("clay-active-dm"); } catch (e) {}
|
|
142
|
+
|
|
143
|
+
// If the home hub was visible when the connection came up (common on mobile
|
|
144
|
+
// PWA cold-start where showHomeHub() fires before the WS is open), re-request
|
|
145
|
+
// hub data now that the socket is ready. Without this, the recent sessions and
|
|
146
|
+
// schedules cards show empty because the initial hub_recent_sessions_list send
|
|
147
|
+
// in showHomeHub() was dropped when readyState !== 1.
|
|
148
|
+
if (isHomeHubVisible()) {
|
|
149
|
+
try {
|
|
150
|
+
var hubWs = getWs();
|
|
151
|
+
if (hubWs && hubWs.readyState === 1) {
|
|
152
|
+
hubWs.send(JSON.stringify({ type: "hub_schedules_list" }));
|
|
153
|
+
hubWs.send(JSON.stringify({ type: "hub_recent_sessions_list" }));
|
|
154
|
+
}
|
|
155
|
+
} catch (e) {}
|
|
156
|
+
}
|
|
138
157
|
}
|
|
139
158
|
|
|
140
159
|
export function connect() {
|
|
@@ -219,6 +219,20 @@ function formatScheduleTime(ts) {
|
|
|
219
219
|
return DAY_NAMES[d.getDay()] + " " + timeStr;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
function formatRelativeTime(ts) {
|
|
223
|
+
if (!ts) return "";
|
|
224
|
+
var diff = Date.now() - ts;
|
|
225
|
+
var m = Math.floor(diff / 60000);
|
|
226
|
+
if (m < 1) return "just now";
|
|
227
|
+
if (m < 60) return m + "m ago";
|
|
228
|
+
var h = Math.floor(m / 60);
|
|
229
|
+
if (h < 24) return h + "h ago";
|
|
230
|
+
var d = Math.floor(h / 24);
|
|
231
|
+
if (d === 1) return "yesterday";
|
|
232
|
+
if (d < 7) return d + "d ago";
|
|
233
|
+
return Math.floor(d / 7) + "w ago";
|
|
234
|
+
}
|
|
235
|
+
|
|
222
236
|
export function renderHomeHub(projects) {
|
|
223
237
|
// Greeting + weather tooltip
|
|
224
238
|
updateGreetingWeather();
|
|
@@ -387,6 +401,52 @@ export function handleHubSchedules(msg) {
|
|
|
387
401
|
}
|
|
388
402
|
}
|
|
389
403
|
|
|
404
|
+
export function handleHubRecentSessions(msg) {
|
|
405
|
+
var sessions = msg.sessions || [];
|
|
406
|
+
var list = document.getElementById("hub-recent-sessions-list");
|
|
407
|
+
if (!list) return;
|
|
408
|
+
list.innerHTML = "";
|
|
409
|
+
if (sessions.length === 0) {
|
|
410
|
+
var emptyDiv = document.createElement("div");
|
|
411
|
+
emptyDiv.className = "hub-recent-empty";
|
|
412
|
+
emptyDiv.textContent = "No recent sessions";
|
|
413
|
+
list.appendChild(emptyDiv);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
sessions.forEach(function (sess) {
|
|
417
|
+
var item = document.createElement("div");
|
|
418
|
+
item.className = "hub-recent-item";
|
|
419
|
+
var iconHtml = sess.projectIcon
|
|
420
|
+
? '<span class="hub-recent-project-icon">' + escapeHtml(sess.projectIcon) + '</span>'
|
|
421
|
+
: '<span class="hub-recent-project-icon hub-recent-project-icon--blank"></span>';
|
|
422
|
+
var timeStr = formatRelativeTime(sess.lastActivity);
|
|
423
|
+
var agentBadge = sess.agentName
|
|
424
|
+
? '<span class="hub-recent-agent">' + escapeHtml(sess.agentName) + '</span>'
|
|
425
|
+
: '';
|
|
426
|
+
item.innerHTML =
|
|
427
|
+
iconHtml +
|
|
428
|
+
'<span class="hub-recent-title">' + escapeHtml(sess.title) + '</span>' +
|
|
429
|
+
agentBadge +
|
|
430
|
+
'<span class="hub-recent-time">' + timeStr + '</span>';
|
|
431
|
+
item.addEventListener("click", function () {
|
|
432
|
+
var currentSlug = store.get('currentSlug');
|
|
433
|
+
if (sess.projectSlug && sess.projectSlug !== currentSlug) {
|
|
434
|
+
// Store the target session ID so the session_list handler can drain it
|
|
435
|
+
// once the new project's WS is confirmed open — same pattern as
|
|
436
|
+
// pending-notif-session in app-notifications.js.
|
|
437
|
+
try { sessionStorage.setItem("pending-hub-session", String(sess.id)); } catch (e) {}
|
|
438
|
+
switchProject(sess.projectSlug);
|
|
439
|
+
} else {
|
|
440
|
+
if (getWs() && getWs().readyState === 1) {
|
|
441
|
+
getWs().send(JSON.stringify({ type: "switch_session", id: sess.id }));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
hideHomeHub();
|
|
445
|
+
});
|
|
446
|
+
list.appendChild(item);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
390
450
|
function startTipRotation() {} // removed: tip section no longer shown
|
|
391
451
|
function stopTipRotation() {}
|
|
392
452
|
|
|
@@ -401,9 +461,10 @@ export function showHomeHub() {
|
|
|
401
461
|
}
|
|
402
462
|
// Fetch weather silently (once)
|
|
403
463
|
fetchWeather();
|
|
404
|
-
// Request cross-project schedules
|
|
464
|
+
// Request cross-project schedules and recent sessions
|
|
405
465
|
if (getWs() && getWs().readyState === 1) {
|
|
406
466
|
getWs().send(JSON.stringify({ type: "hub_schedules_list" }));
|
|
467
|
+
getWs().send(JSON.stringify({ type: "hub_recent_sessions_list" }));
|
|
407
468
|
}
|
|
408
469
|
renderHomeHub(getCachedProjects());
|
|
409
470
|
startTipRotation();
|
|
@@ -39,7 +39,7 @@ import { setStatus } from './app-connection.js';
|
|
|
39
39
|
import { getModelEffortLevels, accumulateUsage, getSessionUsage, setSessionUsage, updateUsagePanel, accumulateContext, updateContextPanel, renderCtxPopover, updateStatusPanel } from './app-panels.js';
|
|
40
40
|
import { updateProjectList, resetClientState, showUpdateAvailable, handleRemoveProjectCheckResult, handleRemoveProjectResult, handleBrowseDirResult, handleAddProjectResult, handleCloneProgress } from './app-projects.js';
|
|
41
41
|
import { updateHistorySentinel, prependOlderHistory } from './app-header.js';
|
|
42
|
-
import { hideHomeHub, handleHubSchedules } from './app-home-hub.js';
|
|
42
|
+
import { hideHomeHub, handleHubSchedules, handleHubRecentSessions } from './app-home-hub.js';
|
|
43
43
|
import { openDm, enterDmMode, exitDmMode, appendDmMessage, showDmTypingIndicator } from './app-dm.js';
|
|
44
44
|
import { handleRateLimitEvent, updateRateLimitUsage, addScheduledMessageBubble, removeScheduledMessageBubble, handleFastModeState } from './app-rate-limit.js';
|
|
45
45
|
import { handleRemoteCursorMove, handleRemoteCursorLeave, handleRemoteSelection, clearRemoteCursors } from './app-cursors.js';
|
|
@@ -53,6 +53,7 @@ var messagesEl = document.getElementById("messages");
|
|
|
53
53
|
var headerTitleEl = document.getElementById("header-title");
|
|
54
54
|
var inputEl = document.getElementById("input");
|
|
55
55
|
var connectOverlay = document.getElementById("connect-overlay");
|
|
56
|
+
var replayLoadingEl = document.getElementById("replay-loading");
|
|
56
57
|
|
|
57
58
|
export function processMessage(msg) {
|
|
58
59
|
// Preserve original timestamp from history replay
|
|
@@ -61,6 +62,7 @@ export function processMessage(msg) {
|
|
|
61
62
|
switch (msg.type) {
|
|
62
63
|
case "history_meta":
|
|
63
64
|
store.set({ historyFrom: msg.from, historyTotal: msg.total, replayingHistory: true });
|
|
65
|
+
if (replayLoadingEl) replayLoadingEl.classList.remove("hidden");
|
|
64
66
|
updateHistorySentinel();
|
|
65
67
|
// Arm sticky-bottom at the START of replay so the scroll listener's
|
|
66
68
|
// "user scrolled up" detection is suppressed for the entire history
|
|
@@ -78,6 +80,7 @@ export function processMessage(msg) {
|
|
|
78
80
|
|
|
79
81
|
case "history_done":
|
|
80
82
|
store.set({ replayingHistory: false });
|
|
83
|
+
if (replayLoadingEl) replayLoadingEl.classList.add("hidden");
|
|
81
84
|
// Arm sticky-bottom FIRST so the ResizeObserver is watching before the
|
|
82
85
|
// bulk DOM mutations below (syntax highlighting, mermaid, todo
|
|
83
86
|
// compaction) displace the scroll position. Arming after those writes
|
|
@@ -411,6 +414,10 @@ export function processMessage(msg) {
|
|
|
411
414
|
handleHubSchedules(msg);
|
|
412
415
|
break;
|
|
413
416
|
|
|
417
|
+
case "hub_recent_sessions":
|
|
418
|
+
handleHubRecentSessions(msg);
|
|
419
|
+
break;
|
|
420
|
+
|
|
414
421
|
case "input_sync":
|
|
415
422
|
if (!store.get('dmMode')) handleInputSync(msg.text);
|
|
416
423
|
break;
|
|
@@ -418,6 +425,20 @@ export function processMessage(msg) {
|
|
|
418
425
|
case "session_list":
|
|
419
426
|
renderSessionList(msg.sessions || []);
|
|
420
427
|
handlePaletteSessionSwitch();
|
|
428
|
+
// Drain pending hub cross-project session switch (set by handleHubRecentSessions
|
|
429
|
+
// when switching to a session in a different project). Fires here because
|
|
430
|
+
// session_list is the first reliable post-connect message that guarantees
|
|
431
|
+
// the WS is open and the session roster is populated.
|
|
432
|
+
try {
|
|
433
|
+
var _pendingHubSess = sessionStorage.getItem("pending-hub-session");
|
|
434
|
+
if (_pendingHubSess) {
|
|
435
|
+
sessionStorage.removeItem("pending-hub-session");
|
|
436
|
+
var _phWs = getWs();
|
|
437
|
+
if (_phWs && _phWs.readyState === 1) {
|
|
438
|
+
_phWs.send(JSON.stringify({ type: "switch_session", id: parseInt(_pendingHubSess, 10) }));
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
} catch (e) {}
|
|
421
442
|
break;
|
|
422
443
|
|
|
423
444
|
case "agents_list":
|
|
@@ -468,6 +489,8 @@ export function processMessage(msg) {
|
|
|
468
489
|
|
|
469
490
|
case "session_switched":
|
|
470
491
|
hideHomeHub();
|
|
492
|
+
// Clear any stale replay indicator from a prior interrupted switch
|
|
493
|
+
if (replayLoadingEl) replayLoadingEl.classList.add("hidden");
|
|
471
494
|
// Save draft from outgoing session
|
|
472
495
|
var _prevSid = store.get('activeSessionId');
|
|
473
496
|
if (_prevSid && inputEl.value) {
|
|
@@ -420,7 +420,7 @@ export function initPanels() {
|
|
|
420
420
|
if (vendorBtnCodex) vendorBtnCodex.addEventListener("click", function() { onVendorClick("codex"); });
|
|
421
421
|
|
|
422
422
|
// --- Reactive UI sync ---
|
|
423
|
-
store.subscribe(['availableVendors', 'installedVendors', 'currentVendor', 'richContextUsage', 'ctxPopoverVisible', 'currentModel', 'currentMode', 'currentEffort', 'currentBetas', 'currentThinking'], function (state, prev) {
|
|
423
|
+
store.subscribe(['availableVendors', 'installedVendors', 'currentVendor', 'richContextUsage', 'ctxPopoverVisible', 'currentModel', 'currentModels', 'currentMode', 'currentEffort', 'currentBetas', 'currentThinking'], function (state, prev) {
|
|
424
424
|
// Vendor toggle state
|
|
425
425
|
if (state.availableVendors !== prev.availableVendors ||
|
|
426
426
|
state.installedVendors !== prev.installedVendors ||
|
|
@@ -447,6 +447,7 @@ export function initPanels() {
|
|
|
447
447
|
|
|
448
448
|
// config chip
|
|
449
449
|
if (state.currentModel !== prev.currentModel ||
|
|
450
|
+
state.currentModels !== prev.currentModels ||
|
|
450
451
|
state.currentMode !== prev.currentMode ||
|
|
451
452
|
state.currentEffort !== prev.currentEffort ||
|
|
452
453
|
state.currentBetas !== prev.currentBetas ||
|
|
@@ -613,10 +614,11 @@ export function updateConfigChip() {
|
|
|
613
614
|
|
|
614
615
|
// Vendor-specific sections
|
|
615
616
|
var isClaude = vendor === "claude";
|
|
616
|
-
// MODE
|
|
617
|
+
// MODE and BETA are Claude-only
|
|
617
618
|
if (configModeList && configModeList.parentElement) configModeList.parentElement.style.display = isClaude ? "" : "none";
|
|
619
|
+
// THINKING: driven by per-model supportsThinking flag (falls back to vendor check)
|
|
618
620
|
rebuildThinkingSection();
|
|
619
|
-
if (configThinkingSection) configThinkingSection.style.display =
|
|
621
|
+
if (configThinkingSection) configThinkingSection.style.display = getModelSupportsThinking() ? "" : "none";
|
|
620
622
|
// BETA section deprecated (1M context is now standard)
|
|
621
623
|
if (configBetaSection) configBetaSection.style.display = "none";
|
|
622
624
|
// APPROVAL, SANDBOX, WEB SEARCH are Codex-only
|
|
@@ -635,6 +637,27 @@ export function getModelSupportsEffort() {
|
|
|
635
637
|
return true;
|
|
636
638
|
}
|
|
637
639
|
|
|
640
|
+
/**
|
|
641
|
+
* Returns true if the currently selected model supports extended thinking.
|
|
642
|
+
* Defaults to the vendor-level check (Claude = yes, Codex = no) when no
|
|
643
|
+
* model-level capability flag is available.
|
|
644
|
+
*/
|
|
645
|
+
export function getModelSupportsThinking() {
|
|
646
|
+
var s = store.snap();
|
|
647
|
+
var vendor = s.currentVendor || "claude";
|
|
648
|
+
var defaultSupportsThinking = vendor === "claude"; // vendor-level fallback
|
|
649
|
+
if (!s.currentModels || s.currentModels.length === 0) return defaultSupportsThinking;
|
|
650
|
+
for (var i = 0; i < s.currentModels.length; i++) {
|
|
651
|
+
if (s.currentModels[i].value === s.currentModel) {
|
|
652
|
+
if (Object.prototype.hasOwnProperty.call(s.currentModels[i], "supportsThinking")) {
|
|
653
|
+
return !!s.currentModels[i].supportsThinking;
|
|
654
|
+
}
|
|
655
|
+
return defaultSupportsThinking;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return defaultSupportsThinking;
|
|
659
|
+
}
|
|
660
|
+
|
|
638
661
|
export function getModelEffortLevels() {
|
|
639
662
|
var s = store.snap();
|
|
640
663
|
var vendor = s.currentVendor || "claude";
|
|
@@ -68,6 +68,11 @@ var stickyBottomInputBound = false;
|
|
|
68
68
|
export function getStickyBottom() { return stickyBottom; }
|
|
69
69
|
|
|
70
70
|
function pinToBottomNow() {
|
|
71
|
+
// Suppress scroll-during-replay: history messages render fast enough that
|
|
72
|
+
// every per-message pin is visible as a janky scroll on mobile. We do one
|
|
73
|
+
// instant jump at history_done instead (replayingHistory is cleared before
|
|
74
|
+
// armStickyBottom fires there, so that final pin goes through unguarded).
|
|
75
|
+
if (store.get('replayingHistory')) return;
|
|
71
76
|
var messagesEl = getMessagesEl();
|
|
72
77
|
if (!messagesEl) return;
|
|
73
78
|
messagesEl.scrollTop = messagesEl.scrollHeight;
|
|
@@ -186,6 +191,10 @@ export function addToMessages(el) {
|
|
|
186
191
|
|
|
187
192
|
export function scrollToBottom() {
|
|
188
193
|
if (prependAnchor) return;
|
|
194
|
+
// During history replay, every appended message calls scrollToBottom(), which
|
|
195
|
+
// queues a rAF. On mobile these all fire visibly, making it look like the page
|
|
196
|
+
// is scrolling through history. Suppress — history_done does one final jump.
|
|
197
|
+
if (store.get('replayingHistory')) return;
|
|
189
198
|
var newMsgBtn = document.getElementById("new-msg-btn");
|
|
190
199
|
if (isUserScrolledUp) {
|
|
191
200
|
newMsgBtn.textContent = NEW_MSG_BTN_ACTIVITY;
|
|
@@ -119,27 +119,11 @@ export function parseEmojis(el) {
|
|
|
119
119
|
|
|
120
120
|
var langAliases = { jsonl: "json", dotenv: "bash" };
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// 4-8s. After history_done, app-messages.js calls this once on the full
|
|
127
|
-
// messages container, so unhighlighted blocks (selector :not(.hljs))
|
|
128
|
-
// are picked up in a single pass.
|
|
129
|
-
if (store.get('replayingHistory')) return;
|
|
130
|
-
el.querySelectorAll("pre code:not(.hljs):not(.language-mermaid)").forEach(function (block) {
|
|
131
|
-
var cls = Array.from(block.classList).find(function (c) { return c.startsWith("language-"); });
|
|
132
|
-
if (cls) {
|
|
133
|
-
var lang = cls.replace("language-", "");
|
|
134
|
-
if (langAliases[lang]) {
|
|
135
|
-
block.classList.remove(cls);
|
|
136
|
-
block.classList.add("language-" + langAliases[lang]);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
hljs.highlightElement(block);
|
|
140
|
-
});
|
|
122
|
+
// Inject copy buttons into all <pre> blocks in el that don't have one yet.
|
|
123
|
+
// Shared by the sync highlight path (per-message streaming) and the batched
|
|
124
|
+
// path (post-history_done full-container pass).
|
|
125
|
+
export function injectCopyButtons(el) {
|
|
141
126
|
el.querySelectorAll("pre:not(.has-copy-btn):not([data-mermaid-processed])").forEach(function (pre) {
|
|
142
|
-
// Skip non-content code blocks (tool details, diffs, etc.)
|
|
143
127
|
if (!pre.querySelector("code")) return;
|
|
144
128
|
pre.classList.add("has-copy-btn");
|
|
145
129
|
pre.style.position = "relative";
|
|
@@ -162,6 +146,28 @@ export function highlightCodeBlocks(el) {
|
|
|
162
146
|
});
|
|
163
147
|
}
|
|
164
148
|
|
|
149
|
+
export function highlightCodeBlocks(el) {
|
|
150
|
+
// Defer all syntax highlighting + copy-button injection while replaying
|
|
151
|
+
// history. Doing this per-message during replay triggers a long tail of
|
|
152
|
+
// sequential reflows that the sticky-bottom scroll observer chases for
|
|
153
|
+
// 4-8s. After history_done, app-messages.js calls this once on the full
|
|
154
|
+
// messages container, so unhighlighted blocks (selector :not(.hljs))
|
|
155
|
+
// are picked up in a single pass.
|
|
156
|
+
if (store.get('replayingHistory')) return;
|
|
157
|
+
el.querySelectorAll("pre code:not(.hljs):not(.language-mermaid)").forEach(function (block) {
|
|
158
|
+
var cls = Array.from(block.classList).find(function (c) { return c.startsWith("language-"); });
|
|
159
|
+
if (cls) {
|
|
160
|
+
var lang = cls.replace("language-", "");
|
|
161
|
+
if (langAliases[lang]) {
|
|
162
|
+
block.classList.remove(cls);
|
|
163
|
+
block.classList.add("language-" + langAliases[lang]);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
hljs.highlightElement(block);
|
|
167
|
+
});
|
|
168
|
+
injectCopyButtons(el);
|
|
169
|
+
}
|
|
170
|
+
|
|
165
171
|
export function renderMermaidBlocks(el) {
|
|
166
172
|
// Same rationale as highlightCodeBlocks: defer mermaid renders until
|
|
167
173
|
// history_done so they don't cause cascading layout shifts during replay.
|
|
@@ -202,7 +208,13 @@ export function renderMermaidBlocks(el) {
|
|
|
202
208
|
}
|
|
203
209
|
export function highlightCodeBlocksBatched(container, onDone) {
|
|
204
210
|
var blocks = Array.prototype.slice.call(container.querySelectorAll("pre > code:not(.hljs)"));
|
|
205
|
-
if (blocks.length === 0) {
|
|
211
|
+
if (blocks.length === 0) {
|
|
212
|
+
// No unhighlighted code blocks, but there may be pre blocks without copy
|
|
213
|
+
// buttons (e.g. plain code fences that were already highlighted). Inject now.
|
|
214
|
+
injectCopyButtons(container);
|
|
215
|
+
if (onDone) onDone();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
206
218
|
|
|
207
219
|
var BATCH = 5; // blocks per idle callback
|
|
208
220
|
var idx = 0;
|
|
@@ -222,6 +234,10 @@ export function highlightCodeBlocksBatched(container, onDone) {
|
|
|
222
234
|
requestAnimationFrame(function () { processBatch(null); });
|
|
223
235
|
}
|
|
224
236
|
} else {
|
|
237
|
+
// All blocks highlighted — inject copy buttons in one pass over the
|
|
238
|
+
// whole container. This is the post-history_done batch path; the sync
|
|
239
|
+
// highlightCodeBlocks() path handles per-message streaming injection.
|
|
240
|
+
injectCopyButtons(container);
|
|
225
241
|
if (onDone) onDone();
|
|
226
242
|
}
|
|
227
243
|
}
|
|
@@ -21,17 +21,29 @@ export var THINKING_OPTIONS = [
|
|
|
21
21
|
];
|
|
22
22
|
|
|
23
23
|
export var MODEL_DESCRIPTIONS = {
|
|
24
|
+
// Claude families
|
|
24
25
|
"default": "Automatically selects the best model for the task.",
|
|
25
26
|
"sonnet": "Fast and capable. Great balance of speed and intelligence.",
|
|
26
27
|
"haiku": "Fastest model. Best for quick tasks and simple questions.",
|
|
27
28
|
"opus": "Most powerful model. Best for complex reasoning and analysis.",
|
|
29
|
+
// Codex/OpenAI families
|
|
30
|
+
"gpt-5.4": "Latest GPT-5.4. Highest capability and reasoning.",
|
|
31
|
+
"gpt-5.4-mini": "Faster, lighter GPT-5.4 variant. Great for most coding tasks.",
|
|
32
|
+
"gpt-5.3-codex": "GPT-5.3 Codex. Strong at agentic coding and tool use.",
|
|
33
|
+
"gpt-5.3-codex-spark": "Lean GPT-5.3 Codex. Optimized for speed.",
|
|
34
|
+
"gpt-5.2": "GPT-5.2. Solid all-around performance.",
|
|
28
35
|
};
|
|
29
36
|
|
|
30
37
|
export function getModelDesc(model) {
|
|
31
38
|
if (!model) return "";
|
|
32
39
|
var lower = (model.value || model).toLowerCase();
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
// Exact match first to avoid "gpt-5.4" matching "gpt-5.4-mini"
|
|
41
|
+
if (MODEL_DESCRIPTIONS[lower]) return MODEL_DESCRIPTIONS[lower];
|
|
42
|
+
// Substring match for family names (e.g. "sonnet", "opus", "haiku")
|
|
43
|
+
// Sort keys longest-first so more-specific keys win (gpt-5.3-codex-spark > gpt-5.3-codex)
|
|
44
|
+
var keys = Object.keys(MODEL_DESCRIPTIONS).sort(function(a, b) { return b.length - a.length; });
|
|
45
|
+
for (var i = 0; i < keys.length; i++) {
|
|
46
|
+
if (lower.indexOf(keys[i]) !== -1) return MODEL_DESCRIPTIONS[keys[i]];
|
|
35
47
|
}
|
|
36
48
|
return "";
|
|
37
49
|
}
|
|
@@ -99,6 +99,9 @@ export function openMobileSheet(type) {
|
|
|
99
99
|
refreshIcons();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
// Duration must match the .closing animation in mobile-nav.css
|
|
103
|
+
var SHEET_CLOSE_MS = 230;
|
|
104
|
+
|
|
102
105
|
function closeMobileSheet() {
|
|
103
106
|
var sheet = document.getElementById("mobile-sheet");
|
|
104
107
|
if (!sheet || sheet.classList.contains("hidden")) return;
|
|
@@ -117,7 +120,21 @@ function closeMobileSheet() {
|
|
|
117
120
|
setTimeout(function () {
|
|
118
121
|
sheet.classList.add("hidden");
|
|
119
122
|
sheet.classList.remove("closing", "sheet-files");
|
|
120
|
-
},
|
|
123
|
+
}, SHEET_CLOSE_MS);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Close the sheet and run fn after the close animation completes.
|
|
127
|
+
// Use this for session/project switches so the history replay flood
|
|
128
|
+
// doesn't begin while the sheet slide-down is still animating.
|
|
129
|
+
function closeMobileSheetThen(fn) {
|
|
130
|
+
var sheet = document.getElementById("mobile-sheet");
|
|
131
|
+
if (!sheet || sheet.classList.contains("hidden")) {
|
|
132
|
+
// Already closed — run immediately
|
|
133
|
+
if (fn) fn();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
closeMobileSheet();
|
|
137
|
+
setTimeout(fn, SHEET_CLOSE_MS);
|
|
121
138
|
}
|
|
122
139
|
|
|
123
140
|
function renderSheetProjects(listEl) {
|
|
@@ -497,11 +514,12 @@ function createMobileSessionItem(s) {
|
|
|
497
514
|
|
|
498
515
|
(function (id) {
|
|
499
516
|
el.addEventListener("click", function () {
|
|
500
|
-
if (getWs() && store.get('connected')) {
|
|
501
|
-
getWs().send(JSON.stringify({ type: "switch_session", id: id }));
|
|
502
|
-
}
|
|
503
517
|
if (dismissOverlayPanels) dismissOverlayPanels();
|
|
504
|
-
|
|
518
|
+
closeMobileSheetThen(function () {
|
|
519
|
+
if (getWs() && store.get('connected')) {
|
|
520
|
+
getWs().send(JSON.stringify({ type: "switch_session", id: id }));
|
|
521
|
+
}
|
|
522
|
+
});
|
|
505
523
|
});
|
|
506
524
|
})(s.id);
|
|
507
525
|
|
|
@@ -535,11 +553,12 @@ function createMobileLoopChild(s) {
|
|
|
535
553
|
|
|
536
554
|
(function (id) {
|
|
537
555
|
el.addEventListener("click", function () {
|
|
538
|
-
if (getWs() && store.get('connected')) {
|
|
539
|
-
getWs().send(JSON.stringify({ type: "switch_session", id: id }));
|
|
540
|
-
}
|
|
541
556
|
if (dismissOverlayPanels) dismissOverlayPanels();
|
|
542
|
-
|
|
557
|
+
closeMobileSheetThen(function () {
|
|
558
|
+
if (getWs() && store.get('connected')) {
|
|
559
|
+
getWs().send(JSON.stringify({ type: "switch_session", id: id }));
|
|
560
|
+
}
|
|
561
|
+
});
|
|
543
562
|
});
|
|
544
563
|
})(s.id);
|
|
545
564
|
|
|
@@ -1102,11 +1121,12 @@ function renderSearchResults(container, query) {
|
|
|
1102
1121
|
|
|
1103
1122
|
(function (id) {
|
|
1104
1123
|
el.addEventListener("click", function () {
|
|
1105
|
-
if (getWs() && store.get('connected')) {
|
|
1106
|
-
getWs().send(JSON.stringify({ type: "switch_session", id: id }));
|
|
1107
|
-
}
|
|
1108
1124
|
if (dismissOverlayPanels) dismissOverlayPanels();
|
|
1109
|
-
|
|
1125
|
+
closeMobileSheetThen(function () {
|
|
1126
|
+
if (getWs() && store.get('connected')) {
|
|
1127
|
+
getWs().send(JSON.stringify({ type: "switch_session", id: id }));
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1110
1130
|
});
|
|
1111
1131
|
})(s.id);
|
|
1112
1132
|
|
package/lib/server.js
CHANGED
|
@@ -955,10 +955,16 @@ function createServer(opts) {
|
|
|
955
955
|
var pSm = pCtx.getSessionManager();
|
|
956
956
|
if (!pSm) return;
|
|
957
957
|
var projectTitle = status.title || status.project || pSlug;
|
|
958
|
+
var projectIcon = status.icon || null;
|
|
958
959
|
pSm.sessions.forEach(function (s) {
|
|
959
960
|
if (!s.hidden && s.history && s.history.length > 0) {
|
|
960
|
-
|
|
961
|
-
|
|
961
|
+
// Push a shallow copy annotated with project metadata rather than
|
|
962
|
+
// mutating the live session object with transient UI fields.
|
|
963
|
+
allSessions.push(Object.assign({}, s, {
|
|
964
|
+
_projectTitle: projectTitle,
|
|
965
|
+
_projectSlug: pSlug,
|
|
966
|
+
_projectIcon: projectIcon,
|
|
967
|
+
}));
|
|
962
968
|
}
|
|
963
969
|
});
|
|
964
970
|
});
|
package/lib/ws-schema.js
CHANGED
|
@@ -443,8 +443,10 @@ var schema = {
|
|
|
443
443
|
// Schedules (hub-level)
|
|
444
444
|
// -----------------------------------------------------------------------
|
|
445
445
|
"schedule_create": { direction: "c2s", handler: "lib/project-loop.js", description: "Create a new schedule" },
|
|
446
|
-
"hub_schedules_list":
|
|
447
|
-
"hub_schedules":
|
|
446
|
+
"hub_schedules_list": { direction: "c2s", handler: "lib/project-loop.js", description: "Request the hub schedules list" },
|
|
447
|
+
"hub_schedules": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Hub schedules list" },
|
|
448
|
+
"hub_recent_sessions_list": { direction: "c2s", handler: "lib/project-loop.js", description: "Request cross-project recent sessions for hub" },
|
|
449
|
+
"hub_recent_sessions": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Cross-project recent sessions list for hub" },
|
|
448
450
|
"schedule_run_started": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled run has started" },
|
|
449
451
|
"schedule_run_finished": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled run has finished" },
|
|
450
452
|
|
|
@@ -971,6 +971,107 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
971
971
|
}
|
|
972
972
|
|
|
973
973
|
|
|
974
|
+
// --- Model enrichment ---
|
|
975
|
+
// Maps raw string model IDs returned by stream.supportedModels() into rich
|
|
976
|
+
// objects with displayName, supportsEffort, supportedEffortLevels, and
|
|
977
|
+
// supportsThinking capability flags. The downstream model_info WS message
|
|
978
|
+
// carries these objects so the UI can drive visibility without vendor checks.
|
|
979
|
+
|
|
980
|
+
var CLAUDE_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
981
|
+
|
|
982
|
+
// Canonical display-name table. Keys are substrings of the model ID (lowercased).
|
|
983
|
+
// Order matters: more-specific keys (e.g. "opus-4") must precede family keys (e.g. "opus").
|
|
984
|
+
var CLAUDE_MODEL_DISPLAY_NAMES = [
|
|
985
|
+
// Opus 4.x family
|
|
986
|
+
{ key: "claude-opus-4-5", label: "Opus 4.5" },
|
|
987
|
+
{ key: "claude-opus-4-6", label: "Opus 4.6" },
|
|
988
|
+
{ key: "claude-opus-4", label: "Opus 4" },
|
|
989
|
+
{ key: "claude-opus-3-7", label: "Opus 3.7" },
|
|
990
|
+
{ key: "claude-opus-3-5", label: "Opus 3.5" },
|
|
991
|
+
{ key: "claude-opus-3", label: "Opus 3" },
|
|
992
|
+
// Sonnet 4.x
|
|
993
|
+
{ key: "claude-sonnet-4-5", label: "Sonnet 4.5" },
|
|
994
|
+
{ key: "claude-sonnet-4-6", label: "Sonnet 4.6" },
|
|
995
|
+
{ key: "claude-sonnet-4", label: "Sonnet 4" },
|
|
996
|
+
{ key: "claude-sonnet-3-7", label: "Sonnet 3.7" },
|
|
997
|
+
{ key: "claude-sonnet-3-5", label: "Sonnet 3.5" },
|
|
998
|
+
{ key: "claude-sonnet-3", label: "Sonnet 3" },
|
|
999
|
+
// Haiku 4.x
|
|
1000
|
+
{ key: "claude-haiku-3-5", label: "Haiku 3.5" },
|
|
1001
|
+
{ key: "claude-haiku-3", label: "Haiku 3" },
|
|
1002
|
+
// Generic family fallbacks
|
|
1003
|
+
{ key: "opus", label: "Opus" },
|
|
1004
|
+
{ key: "sonnet", label: "Sonnet" },
|
|
1005
|
+
{ key: "haiku", label: "Haiku" },
|
|
1006
|
+
];
|
|
1007
|
+
|
|
1008
|
+
function claudeDisplayName(modelId) {
|
|
1009
|
+
var lower = modelId.toLowerCase();
|
|
1010
|
+
// Strip pinned-version suffix like "[1m]"
|
|
1011
|
+
var clean = lower.replace(/\[.*?\]$/, "").trim();
|
|
1012
|
+
for (var i = 0; i < CLAUDE_MODEL_DISPLAY_NAMES.length; i++) {
|
|
1013
|
+
if (clean.indexOf(CLAUDE_MODEL_DISPLAY_NAMES[i].key) !== -1) {
|
|
1014
|
+
return CLAUDE_MODEL_DISPLAY_NAMES[i].label;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
// Fallback: strip "claude-" prefix, title-case remainder
|
|
1018
|
+
return modelId.replace(/^claude-/i, "");
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
function claudeModelSupportsThinking(modelId) {
|
|
1022
|
+
// Haiku models do not support extended thinking
|
|
1023
|
+
var lower = (modelId || "").toLowerCase();
|
|
1024
|
+
return lower.indexOf("haiku") === -1;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// Models known to support effort control. Currently all Claude 4.x opus/sonnet
|
|
1028
|
+
// models support effort; haiku does not (no reasoning). Defaults to true for
|
|
1029
|
+
// unknown models so new releases are not accidentally silenced.
|
|
1030
|
+
function claudeModelSupportsEffort(modelId) {
|
|
1031
|
+
var lower = (modelId || "").toLowerCase();
|
|
1032
|
+
if (lower.indexOf("haiku") !== -1) return false;
|
|
1033
|
+
return true;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* Enrich a raw model ID string (or passthrough if already object) into a rich
|
|
1038
|
+
* model descriptor object.
|
|
1039
|
+
* @param {string|object} model
|
|
1040
|
+
* @returns {{ value, displayName, supportsEffort, supportedEffortLevels, supportsThinking }}
|
|
1041
|
+
*/
|
|
1042
|
+
function enrichClaudeModel(model) {
|
|
1043
|
+
// Already a rich object — passthrough but ensure all fields present
|
|
1044
|
+
if (model && typeof model === "object") {
|
|
1045
|
+
var v = model.value || "";
|
|
1046
|
+
return {
|
|
1047
|
+
value: v,
|
|
1048
|
+
displayName: model.displayName || claudeDisplayName(v),
|
|
1049
|
+
supportsEffort: Object.prototype.hasOwnProperty.call(model, "supportsEffort") ? model.supportsEffort : claudeModelSupportsEffort(v),
|
|
1050
|
+
supportedEffortLevels: model.supportedEffortLevels || CLAUDE_EFFORT_LEVELS,
|
|
1051
|
+
supportsThinking: Object.prototype.hasOwnProperty.call(model, "supportsThinking") ? model.supportsThinking : claudeModelSupportsThinking(v),
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
// Plain string
|
|
1055
|
+
var value = String(model || "");
|
|
1056
|
+
return {
|
|
1057
|
+
value: value,
|
|
1058
|
+
displayName: claudeDisplayName(value),
|
|
1059
|
+
supportsEffort: claudeModelSupportsEffort(value),
|
|
1060
|
+
supportedEffortLevels: CLAUDE_EFFORT_LEVELS,
|
|
1061
|
+
supportsThinking: claudeModelSupportsThinking(value),
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
function enrichClaudeModels(models) {
|
|
1066
|
+
if (!models || !models.length) return models;
|
|
1067
|
+
var result = [];
|
|
1068
|
+
for (var i = 0; i < models.length; i++) {
|
|
1069
|
+
result.push(enrichClaudeModel(models[i]));
|
|
1070
|
+
}
|
|
1071
|
+
return result;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
|
|
974
1075
|
// --- Adapter factory ---
|
|
975
1076
|
|
|
976
1077
|
function resolveClaudeBinaryPath() {
|
|
@@ -1025,91 +1126,6 @@ function createClaudeAdapter(opts) {
|
|
|
1025
1126
|
// Path to worker script (sdk-bridge uses this to spawn worker processes)
|
|
1026
1127
|
workerScriptPath: workerScriptPath,
|
|
1027
1128
|
|
|
1028
|
-
/**
|
|
1029
|
-
* Initialize the adapter. Performs SDK warmup to discover models, skills, etc.
|
|
1030
|
-
* If linuxUser is provided (via initOpts.linuxUser), delegates to a worker process.
|
|
1031
|
-
*
|
|
1032
|
-
* @param {object} initOpts
|
|
1033
|
-
* @param {string} [initOpts.cwd]
|
|
1034
|
-
* @param {boolean} [initOpts.dangerouslySkipPermissions]
|
|
1035
|
-
* @param {string} [initOpts.linuxUser] - OS user for worker isolation
|
|
1036
|
-
* @returns {Promise<{ models, defaultModel, skills, slashCommands, fastModeState, capabilities }>}
|
|
1037
|
-
*/
|
|
1038
|
-
init: async function(initOpts) {
|
|
1039
|
-
var linuxUser = initOpts && initOpts.linuxUser;
|
|
1040
|
-
if (linuxUser) {
|
|
1041
|
-
return initViaWorker(linuxUser, initOpts);
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
var sdk = await loadSDK();
|
|
1045
|
-
var ac = new AbortController();
|
|
1046
|
-
var mq = createMessageQueue();
|
|
1047
|
-
mq.push({ type: "user", message: { role: "user", content: [{ type: "text", text: "hi" }] } });
|
|
1048
|
-
mq.end();
|
|
1049
|
-
|
|
1050
|
-
var warmupOptions = {
|
|
1051
|
-
cwd: (initOpts && initOpts.cwd) || _cwd,
|
|
1052
|
-
settingSources: ["user", "project", "local"],
|
|
1053
|
-
abortController: ac,
|
|
1054
|
-
settings: { disableAllHooks: true },
|
|
1055
|
-
};
|
|
1056
|
-
if (_claudeBinaryPath) warmupOptions.pathToClaudeCodeExecutable = _claudeBinaryPath;
|
|
1057
|
-
|
|
1058
|
-
if (initOpts && initOpts.dangerouslySkipPermissions) {
|
|
1059
|
-
warmupOptions.permissionMode = "bypassPermissions";
|
|
1060
|
-
warmupOptions.allowDangerouslySkipPermissions = true;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
var result = {
|
|
1064
|
-
models: [],
|
|
1065
|
-
defaultModel: "",
|
|
1066
|
-
skills: [],
|
|
1067
|
-
slashCommands: [],
|
|
1068
|
-
fastModeState: null,
|
|
1069
|
-
capabilities: {
|
|
1070
|
-
thinking: true,
|
|
1071
|
-
betas: true,
|
|
1072
|
-
rewind: true,
|
|
1073
|
-
sessionResume: true,
|
|
1074
|
-
promptSuggestions: true,
|
|
1075
|
-
elicitation: true,
|
|
1076
|
-
fileCheckpointing: true,
|
|
1077
|
-
contextCompacting: true,
|
|
1078
|
-
toolPolicy: ["ask", "allow-all"],
|
|
1079
|
-
},
|
|
1080
|
-
};
|
|
1081
|
-
|
|
1082
|
-
try {
|
|
1083
|
-
var stream = sdk.query({ prompt: mq, options: warmupOptions });
|
|
1084
|
-
|
|
1085
|
-
for await (var msg of stream) {
|
|
1086
|
-
if (msg.type === "system" && msg.subtype === "init") {
|
|
1087
|
-
result.skills = msg.skills || [];
|
|
1088
|
-
result.defaultModel = msg.model || "";
|
|
1089
|
-
result.slashCommands = msg.slash_commands || [];
|
|
1090
|
-
result.fastModeState = msg.fast_mode_state || null;
|
|
1091
|
-
|
|
1092
|
-
try {
|
|
1093
|
-
var models = await stream.supportedModels();
|
|
1094
|
-
result.models = models || [];
|
|
1095
|
-
_cachedModels = result.models;
|
|
1096
|
-
} catch (e) {
|
|
1097
|
-
// supportedModels may fail, models list will be empty
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
ac.abort();
|
|
1101
|
-
break;
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
} catch (e) {
|
|
1105
|
-
if (e && e.name !== "AbortError" && !(e.message && e.message.indexOf("aborted") !== -1)) {
|
|
1106
|
-
throw e;
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
return result;
|
|
1111
|
-
},
|
|
1112
|
-
|
|
1113
1129
|
/**
|
|
1114
1130
|
* Return cached list of supported models.
|
|
1115
1131
|
* @returns {Promise<string[]>}
|
|
@@ -1391,76 +1407,10 @@ function createClaudeAdapter(opts) {
|
|
|
1391
1407
|
return handle;
|
|
1392
1408
|
}
|
|
1393
1409
|
|
|
1394
|
-
// --- Worker warmup (internal) ---
|
|
1395
|
-
|
|
1396
|
-
async function initViaWorker(linuxUser, initOpts) {
|
|
1397
|
-
var worker;
|
|
1398
|
-
try {
|
|
1399
|
-
worker = spawnWorker(linuxUser, workerScriptPath, (initOpts && initOpts.cwd) || _cwd);
|
|
1400
|
-
} catch (e) {
|
|
1401
|
-
throw new Error("Failed to spawn warmup worker for " + linuxUser + ": " + (e.message || e));
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
var result = await new Promise(function(resolve, reject) {
|
|
1405
|
-
var warmupDone = false;
|
|
1406
|
-
|
|
1407
|
-
worker.onMessage(function(msg) {
|
|
1408
|
-
if (msg.type === "warmup_done" && !warmupDone) {
|
|
1409
|
-
warmupDone = true;
|
|
1410
|
-
var r = msg.result || {};
|
|
1411
|
-
resolve({
|
|
1412
|
-
models: r.models || [],
|
|
1413
|
-
defaultModel: r.model || "",
|
|
1414
|
-
skills: r.skills || [],
|
|
1415
|
-
slashCommands: r.slashCommands || [],
|
|
1416
|
-
fastModeState: r.fastModeState || null,
|
|
1417
|
-
capabilities: {
|
|
1418
|
-
thinking: true,
|
|
1419
|
-
betas: true,
|
|
1420
|
-
rewind: true,
|
|
1421
|
-
sessionResume: true,
|
|
1422
|
-
promptSuggestions: true,
|
|
1423
|
-
elicitation: true,
|
|
1424
|
-
fileCheckpointing: true,
|
|
1425
|
-
contextCompacting: true,
|
|
1426
|
-
toolPolicy: ["ask", "allow-all"],
|
|
1427
|
-
},
|
|
1428
|
-
});
|
|
1429
|
-
worker.kill();
|
|
1430
|
-
} else if (msg.type === "warmup_error" && !warmupDone) {
|
|
1431
|
-
warmupDone = true;
|
|
1432
|
-
worker.kill();
|
|
1433
|
-
reject(new Error(msg.error || "Warmup failed"));
|
|
1434
|
-
}
|
|
1435
|
-
});
|
|
1436
|
-
|
|
1437
|
-
// Handle case where worker fails to connect
|
|
1438
|
-
worker.readyPromise.catch(function(e) {
|
|
1439
|
-
if (!warmupDone) {
|
|
1440
|
-
warmupDone = true;
|
|
1441
|
-
cleanupWorker(worker);
|
|
1442
|
-
reject(new Error("Warmup worker failed to connect: " + (e.message || e)));
|
|
1443
|
-
}
|
|
1444
|
-
});
|
|
1445
|
-
});
|
|
1446
|
-
|
|
1447
|
-
// Wait for worker to be ready, then send warmup command
|
|
1448
|
-
// This is inside the Promise above, but we need readyPromise first
|
|
1449
|
-
// Actually, let's restructure: wait for ready, then send warmup
|
|
1450
|
-
// The Promise constructor above registers message handlers, but we need
|
|
1451
|
-
// to await readyPromise separately.
|
|
1452
|
-
|
|
1453
|
-
// Rethinking: the Promise above is returned directly. We need to await
|
|
1454
|
-
// readyPromise before sending warmup. Let me use a different approach.
|
|
1455
|
-
|
|
1456
|
-
return result;
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
// Override initViaWorker to properly sequence ready + warmup
|
|
1460
1410
|
adapter.init = async function(initOpts) {
|
|
1461
1411
|
var linuxUser = initOpts && initOpts.linuxUser;
|
|
1462
1412
|
if (!linuxUser) {
|
|
1463
|
-
// In-process warmup
|
|
1413
|
+
// In-process warmup
|
|
1464
1414
|
var sdk = await loadSDK();
|
|
1465
1415
|
var ac = new AbortController();
|
|
1466
1416
|
var mq = createMessageQueue();
|
|
@@ -1511,7 +1461,7 @@ function createClaudeAdapter(opts) {
|
|
|
1511
1461
|
|
|
1512
1462
|
try {
|
|
1513
1463
|
var models = await stream.supportedModels();
|
|
1514
|
-
result.models = models || [];
|
|
1464
|
+
result.models = enrichClaudeModels(models || []);
|
|
1515
1465
|
_cachedModels = result.models;
|
|
1516
1466
|
} catch (e) {
|
|
1517
1467
|
// supportedModels may fail, models list will be empty
|
|
@@ -1560,8 +1510,10 @@ function createClaudeAdapter(opts) {
|
|
|
1560
1510
|
if (msg.type === "warmup_done" && !warmupDone) {
|
|
1561
1511
|
warmupDone = true;
|
|
1562
1512
|
var r = msg.result || {};
|
|
1513
|
+
var enrichedModels = enrichClaudeModels(r.models || []);
|
|
1514
|
+
_cachedModels = enrichedModels;
|
|
1563
1515
|
resolve({
|
|
1564
|
-
models:
|
|
1516
|
+
models: enrichedModels,
|
|
1565
1517
|
defaultModel: r.model || "",
|
|
1566
1518
|
skills: r.skills || [],
|
|
1567
1519
|
slashCommands: r.slashCommands || [],
|
|
@@ -1051,6 +1051,57 @@ function createCodexQueryHandle(appServer, queryOpts) {
|
|
|
1051
1051
|
return handle;
|
|
1052
1052
|
}
|
|
1053
1053
|
|
|
1054
|
+
// --- Model enrichment ---
|
|
1055
|
+
// Curated model descriptors for Codex/OpenAI models. These are used as the
|
|
1056
|
+
// authoritative list after init because the Codex app-server does not expose a
|
|
1057
|
+
// models/list endpoint. Update this table when OpenAI releases new models.
|
|
1058
|
+
//
|
|
1059
|
+
// supportsEffort: whether the model accepts an effort/reasoning-effort parameter
|
|
1060
|
+
// supportedEffortLevels: ordered list of valid effort values for the model
|
|
1061
|
+
// supportsThinking: whether extended thinking UI should be shown (Codex uses effort
|
|
1062
|
+
// as its equivalent of thinking depth; the thinking toggle itself is Claude-only)
|
|
1063
|
+
|
|
1064
|
+
var CODEX_EFFORT_LEVELS = ["minimal", "low", "medium", "high", "xhigh"];
|
|
1065
|
+
var CODEX_EFFORT_LEVELS_STANDARD = ["low", "medium", "high"]; // models without xhigh/minimal
|
|
1066
|
+
|
|
1067
|
+
var CODEX_DEFAULT_MODELS = [
|
|
1068
|
+
{
|
|
1069
|
+
value: "gpt-5.4",
|
|
1070
|
+
displayName: "GPT-5.4",
|
|
1071
|
+
supportsEffort: true,
|
|
1072
|
+
supportedEffortLevels: CODEX_EFFORT_LEVELS,
|
|
1073
|
+
supportsThinking: false,
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
value: "gpt-5.4-mini",
|
|
1077
|
+
displayName: "GPT-5.4 Mini",
|
|
1078
|
+
supportsEffort: true,
|
|
1079
|
+
supportedEffortLevels: CODEX_EFFORT_LEVELS_STANDARD,
|
|
1080
|
+
supportsThinking: false,
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
value: "gpt-5.3-codex",
|
|
1084
|
+
displayName: "GPT-5.3 Codex",
|
|
1085
|
+
supportsEffort: true,
|
|
1086
|
+
supportedEffortLevels: CODEX_EFFORT_LEVELS,
|
|
1087
|
+
supportsThinking: false,
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
value: "gpt-5.3-codex-spark",
|
|
1091
|
+
displayName: "GPT-5.3 Codex Spark",
|
|
1092
|
+
supportsEffort: true,
|
|
1093
|
+
supportedEffortLevels: CODEX_EFFORT_LEVELS_STANDARD,
|
|
1094
|
+
supportsThinking: false,
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
value: "gpt-5.2",
|
|
1098
|
+
displayName: "GPT-5.2",
|
|
1099
|
+
supportsEffort: true,
|
|
1100
|
+
supportedEffortLevels: CODEX_EFFORT_LEVELS,
|
|
1101
|
+
supportsThinking: false,
|
|
1102
|
+
},
|
|
1103
|
+
];
|
|
1104
|
+
|
|
1054
1105
|
// --- Adapter factory ---
|
|
1055
1106
|
|
|
1056
1107
|
function createCodexAdapter(opts) {
|
|
@@ -1307,15 +1358,10 @@ function createCodexAdapter(opts) {
|
|
|
1307
1358
|
throw createShutdownError();
|
|
1308
1359
|
}
|
|
1309
1360
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
_cachedModels =
|
|
1313
|
-
|
|
1314
|
-
"gpt-5.4-mini",
|
|
1315
|
-
"gpt-5.3-codex",
|
|
1316
|
-
"gpt-5.3-codex-spark",
|
|
1317
|
-
"gpt-5.2",
|
|
1318
|
-
];
|
|
1361
|
+
// Use curated default model list. CODEX_DEFAULT_MODELS entries are already
|
|
1362
|
+
// rich descriptor objects with capability flags; no further enrichment needed.
|
|
1363
|
+
_cachedModels = CODEX_DEFAULT_MODELS.slice();
|
|
1364
|
+
console.log("[codex] App-server initialized, models: " + _cachedModels.map(function(m) { return m.value; }).join(", "));
|
|
1319
1365
|
|
|
1320
1366
|
// Discover skills: built-in Codex skills + Claude skills
|
|
1321
1367
|
var skillNames = [];
|
package/package.json
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.3.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
|
-
"clagentic": "./bin/cli.js",
|
|
10
9
|
"clagentic-console": "./bin/cli.js"
|
|
11
10
|
},
|
|
12
11
|
"scripts": {
|