@clagentic/console 1.4.0-beta.1 → 1.4.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/daemon.js +70 -22
- package/lib/project-loop.js +17 -23
- package/lib/project-sessions.js +19 -1
- package/lib/project.js +8 -0
- package/lib/public/app.js +17 -3
- package/lib/public/css/input.css +5 -0
- package/lib/public/modules/app-header.js +7 -1
- package/lib/public/modules/app-messages.js +10 -5
- package/lib/public/modules/command-palette.js +3 -0
- package/lib/public/modules/input.js +18 -2
- package/lib/public/modules/overlay-history.js +62 -0
- package/lib/public/modules/project-settings.js +3 -0
- package/lib/public/modules/scheduler.js +3 -0
- package/lib/public/modules/server-settings.js +4 -1
- package/lib/public/modules/session-search.js +3 -0
- package/lib/public/modules/sticky-notes.js +3 -0
- package/lib/sdk-bridge.js +72 -13
- package/lib/sdk-message-processor.js +21 -10
- package/lib/sdk-skill-discovery.js +199 -1
- package/lib/sdk-slash-enrichment.js +64 -0
- package/lib/sdk-worker.js +17 -0
- package/lib/sdk-workflow-discovery.js +151 -0
- package/lib/server.js +9 -2
- package/lib/sessions.js +2 -0
- package/lib/updater.js +15 -6
- package/lib/yoke/adapters/claude-worker.js +17 -0
- package/lib/yoke/adapters/claude.js +13 -3
- package/lib/yoke/adapters/codex.js +53 -4
- package/package.json +2 -2
package/lib/daemon.js
CHANGED
|
@@ -30,6 +30,7 @@ var { checkAclSupport, grantProjectAccess, revokeProjectAccess, provisionAllUser
|
|
|
30
30
|
var usersModule = require("./users");
|
|
31
31
|
var { createWorktree, removeWorktree, isWorktree } = require("./worktree");
|
|
32
32
|
var { isWorktreeSlug, scanAndRegisterWorktrees, rescanWorktrees, cleanupWorktreesForParent, getFilteredRemovedProjects, registerWorktreeSlug, unregisterWorktreeSlug } = require("./daemon-projects");
|
|
33
|
+
var { DEFAULT_MEM_AVAILABLE_MIN_MB } = require("./sdk-bridge");
|
|
33
34
|
|
|
34
35
|
var daemonVersion = require("../package.json").version;
|
|
35
36
|
var configFile = process.env.CLAGENTIC_CONFIG || process.env.CLAY_CONFIG || require("./config").configPath();
|
|
@@ -845,6 +846,7 @@ var relay = createServer({
|
|
|
845
846
|
lanIp: lanIp || null,
|
|
846
847
|
updateChannel: config.updateChannel || "stable",
|
|
847
848
|
imageRetentionDays: config.imageRetentionDays !== undefined ? config.imageRetentionDays : 7,
|
|
849
|
+
memAvailableMinMB: config.memAvailableMinMB !== undefined ? config.memAvailableMinMB : DEFAULT_MEM_AVAILABLE_MIN_MB,
|
|
848
850
|
};
|
|
849
851
|
},
|
|
850
852
|
onSetImageRetention: function (days) {
|
|
@@ -906,6 +908,14 @@ var relay = createServer({
|
|
|
906
908
|
console.log("[daemon] Auto-continue on rate limit:", want, "(web)");
|
|
907
909
|
return { ok: true, autoContinueOnRateLimit: want };
|
|
908
910
|
},
|
|
911
|
+
onSetMemAvailableThreshold: function (mb) {
|
|
912
|
+
var val = parseInt(mb, 10);
|
|
913
|
+
if (isNaN(val) || val < 0) val = DEFAULT_MEM_AVAILABLE_MIN_MB;
|
|
914
|
+
config.memAvailableMinMB = val;
|
|
915
|
+
saveConfig(config);
|
|
916
|
+
console.log("[daemon] MemAvailable threshold:", val, "MB (web)");
|
|
917
|
+
return { ok: true, memAvailableMinMB: val };
|
|
918
|
+
},
|
|
909
919
|
onGetToolPalettes: function () {
|
|
910
920
|
return config.toolPalettes || {};
|
|
911
921
|
},
|
|
@@ -1282,6 +1292,15 @@ var ipc = createIPCServer(socketPath(), function (msg) {
|
|
|
1282
1292
|
return { ok: true };
|
|
1283
1293
|
}
|
|
1284
1294
|
|
|
1295
|
+
case "set_mem_available_threshold": {
|
|
1296
|
+
var memMB = parseInt(msg.value, 10);
|
|
1297
|
+
if (isNaN(memMB) || memMB < 0) memMB = DEFAULT_MEM_AVAILABLE_MIN_MB;
|
|
1298
|
+
config.memAvailableMinMB = memMB;
|
|
1299
|
+
saveConfig(config);
|
|
1300
|
+
console.log("[daemon] MemAvailable threshold:", memMB, "MB (cli)");
|
|
1301
|
+
return { ok: true, memAvailableMinMB: memMB };
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1285
1304
|
case "enable_recovery": {
|
|
1286
1305
|
if (!msg.urlPath || !msg.password) return { ok: false, error: "missing urlPath or password" };
|
|
1287
1306
|
relay.setRecovery(msg.urlPath, msg.password);
|
|
@@ -1325,28 +1344,57 @@ var ipc = createIPCServer(socketPath(), function (msg) {
|
|
|
1325
1344
|
// This is the only reliable path — npx installs to a cache location that the
|
|
1326
1345
|
// restart wrapper does not consult, so npx-spawned daemons get replaced by the
|
|
1327
1346
|
// old global version on the next supervised restart.
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1347
|
+
// Resolve + install asynchronously. ipc.js awaits a returned Promise, so
|
|
1348
|
+
// returning an async IIFE here is safe without changing the outer handler.
|
|
1349
|
+
return (async function () {
|
|
1350
|
+
var { execFileSync: execFileUpd } = require("child_process");
|
|
1351
|
+
var updater = require("./updater");
|
|
1352
|
+
|
|
1353
|
+
// Resolve the target version the same way the startup updater does, then
|
|
1354
|
+
// install that EXACT version — never a bare dist-tag. Installing @latest/
|
|
1355
|
+
// @beta is unsafe: the tag can point at an older version than what is
|
|
1356
|
+
// running (e.g. a beta machine whose @latest resolves to an older stable),
|
|
1357
|
+
// which silently downgrades the daemon. We mirror checkAndUpdate: on the
|
|
1358
|
+
// beta channel (or a pre-release current version) consider both beta and
|
|
1359
|
+
// latest and take the newest; on stable consider latest only. Then guard
|
|
1360
|
+
// with isNewer so a downgrade is impossible.
|
|
1361
|
+
var isBetaCh = config.updateChannel === "beta" || (daemonVersion && daemonVersion.includes("-"));
|
|
1362
|
+
var updTags = isBetaCh ? ["beta", "latest"] : ["latest"];
|
|
1363
|
+
var updTarget = null;
|
|
1364
|
+
for (var _ut = 0; _ut < updTags.length; _ut++) {
|
|
1365
|
+
var _cand = await updater.fetchVersion(updTags[_ut] === "beta" ? "beta" : "stable");
|
|
1366
|
+
if (_cand && (!updTarget || updater.isNewer(_cand, updTarget))) {
|
|
1367
|
+
updTarget = _cand;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
if (!updTarget || !updater.isNewer(updTarget, daemonVersion)) {
|
|
1372
|
+
console.log("[daemon] No newer version available (current " + daemonVersion + ", best candidate " + (updTarget || "none") + "). Skipping update.");
|
|
1373
|
+
relay.broadcastAll({ type: "update_failed", error: "Already on the latest available version (" + daemonVersion + ")" });
|
|
1374
|
+
return { ok: false, error: "Already up to date (" + daemonVersion + ")" };
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
var updOk = false;
|
|
1378
|
+
try {
|
|
1379
|
+
console.log("[daemon] Installing @clagentic/console@" + updTarget + " globally (current " + daemonVersion + ")...");
|
|
1380
|
+
execFileUpd("npm", ["install", "-g", "@clagentic/console@" + updTarget], {
|
|
1381
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
1382
|
+
timeout: 120000,
|
|
1383
|
+
encoding: "utf8",
|
|
1384
|
+
});
|
|
1385
|
+
console.log("[daemon] Global install complete. Shutting down for supervised restart.");
|
|
1386
|
+
updOk = true;
|
|
1387
|
+
} catch (updErr) {
|
|
1388
|
+
console.log("[daemon] Global install failed:", updErr.message);
|
|
1389
|
+
relay.broadcastAll({ type: "update_failed", error: updErr.message });
|
|
1390
|
+
return { ok: false, error: updErr.message };
|
|
1391
|
+
}
|
|
1392
|
+
if (updOk) {
|
|
1393
|
+
updateHandoff = true;
|
|
1394
|
+
setTimeout(function () { gracefulShutdown(); }, 100);
|
|
1395
|
+
}
|
|
1396
|
+
return { ok: true };
|
|
1397
|
+
})();
|
|
1350
1398
|
}
|
|
1351
1399
|
|
|
1352
1400
|
default:
|
package/lib/project-loop.js
CHANGED
|
@@ -1144,37 +1144,31 @@ function attachLoop(ctx) {
|
|
|
1144
1144
|
|
|
1145
1145
|
// --- Hub: cross-project recent sessions ---
|
|
1146
1146
|
if (msg.type === "hub_recent_sessions_list") {
|
|
1147
|
-
//
|
|
1148
|
-
//
|
|
1149
|
-
//
|
|
1150
|
-
//
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
var
|
|
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
|
-
});
|
|
1147
|
+
// Gather EVERY project uniformly (includeSelf=true) so the global recency
|
|
1148
|
+
// sort is honest. Previously self was special-cased: other projects came
|
|
1149
|
+
// through getAllProjectSessions() and self's sessions were appended
|
|
1150
|
+
// separately. Combined with a too-small top-10 slice, the currently
|
|
1151
|
+
// connected (most-recently-active) project crowded out the genuinely most
|
|
1152
|
+
// recent sessions overall. getAllProjectSessions returns annotated shallow
|
|
1153
|
+
// copies carrying _projectSlug/_projectTitle/_projectIcon for every project.
|
|
1154
|
+
var allSessions = getAllProjectSessions ? getAllProjectSessions(true) : [];
|
|
1166
1155
|
// Sort newest-first by lastActivity
|
|
1167
1156
|
allSessions.sort(function (a, b) {
|
|
1168
1157
|
return (b.lastActivity || b.createdAt || 0) - (a.lastActivity || a.createdAt || 0);
|
|
1169
1158
|
});
|
|
1170
|
-
|
|
1171
|
-
|
|
1159
|
+
// The global sort above is the actual fix: every project is gathered
|
|
1160
|
+
// uniformly, so the top-N is the genuinely most-recent overall rather
|
|
1161
|
+
// than whatever the connected project happened to touch. The Hub card
|
|
1162
|
+
// shows 10; selection is now honest, so 10 is a display cap, not a
|
|
1163
|
+
// project-biased pool.
|
|
1164
|
+
var top = allSessions.slice(0, 10);
|
|
1165
|
+
var mapped = top.map(function (s) {
|
|
1172
1166
|
return {
|
|
1173
1167
|
id: s.localId,
|
|
1174
1168
|
title: s.title || "New Session",
|
|
1175
1169
|
lastActivity: s.lastActivity || s.createdAt || 0,
|
|
1176
|
-
projectSlug: s._projectSlug ||
|
|
1177
|
-
projectTitle: s._projectTitle ||
|
|
1170
|
+
projectSlug: s._projectSlug || slug,
|
|
1171
|
+
projectTitle: s._projectTitle || slug,
|
|
1178
1172
|
projectIcon: s._projectIcon || null,
|
|
1179
1173
|
vendor: s.vendor || null,
|
|
1180
1174
|
agentName: s.agentName || null,
|
package/lib/project-sessions.js
CHANGED
|
@@ -2,6 +2,7 @@ var fs = require("fs");
|
|
|
2
2
|
var path = require("path");
|
|
3
3
|
var { execFileSync } = require("child_process");
|
|
4
4
|
var { CODEX_DEFAULTS, getCodexConfig } = require("./codex-defaults");
|
|
5
|
+
var { readMemAvailableMB } = require("./sdk-bridge");
|
|
5
6
|
var agentsModule = require("./agents");
|
|
6
7
|
var agentsFavorites = require("./agents-favorites");
|
|
7
8
|
var relayClaims = require("./relay-agent-claims");
|
|
@@ -574,6 +575,10 @@ function attachSessions(ctx) {
|
|
|
574
575
|
if (s.isProcessing) processingCount++;
|
|
575
576
|
});
|
|
576
577
|
var mem = process.memoryUsage();
|
|
578
|
+
// lr-2d91: Include memory pressure fields so the admin panel can show
|
|
579
|
+
// pressure building before the MemAvailable gate fires.
|
|
580
|
+
var memStats = (sdk && typeof sdk.getMemoryStats === "function") ? sdk.getMemoryStats() : {};
|
|
581
|
+
var memAvailMB = readMemAvailableMB();
|
|
577
582
|
sendTo(ws, {
|
|
578
583
|
type: "process_stats",
|
|
579
584
|
pid: process.pid,
|
|
@@ -588,6 +593,9 @@ function attachSessions(ctx) {
|
|
|
588
593
|
processing: processingCount,
|
|
589
594
|
clients: clients.size,
|
|
590
595
|
terminals: tm.list().length,
|
|
596
|
+
memAvailableMB: memAvailMB,
|
|
597
|
+
activeLiveCount: memStats.activeLiveCount !== undefined ? memStats.activeLiveCount : null,
|
|
598
|
+
maxConcurrentSessions: memStats.maxConcurrentSessions !== undefined ? memStats.maxConcurrentSessions : null,
|
|
591
599
|
});
|
|
592
600
|
return true;
|
|
593
601
|
}
|
|
@@ -1546,7 +1554,8 @@ function attachSessions(ctx) {
|
|
|
1546
1554
|
|
|
1547
1555
|
// --- Daemon config / server management (admin-only in multi-user mode) ---
|
|
1548
1556
|
if (msg.type === "get_daemon_config" || msg.type === "set_pin" || msg.type === "set_keep_awake" ||
|
|
1549
|
-
msg.type === "set_auto_continue" || msg.type === "set_image_retention" || msg.type === "
|
|
1557
|
+
msg.type === "set_auto_continue" || msg.type === "set_image_retention" || msg.type === "set_mem_available_threshold" ||
|
|
1558
|
+
msg.type === "shutdown_server" || msg.type === "restart_server") {
|
|
1550
1559
|
if (usersModule.isMultiUser()) {
|
|
1551
1560
|
var _wsUser = ws._clayUser;
|
|
1552
1561
|
if (!_wsUser || _wsUser.role !== "admin") {
|
|
@@ -1598,6 +1607,15 @@ function attachSessions(ctx) {
|
|
|
1598
1607
|
return true;
|
|
1599
1608
|
}
|
|
1600
1609
|
|
|
1610
|
+
if (msg.type === "set_mem_available_threshold") {
|
|
1611
|
+
if (typeof opts.onSetMemAvailableThreshold === "function") {
|
|
1612
|
+
var matResult = opts.onSetMemAvailableThreshold(msg.value);
|
|
1613
|
+
sendTo(ws, { type: "set_mem_available_threshold_result", ok: matResult.ok, memAvailableMinMB: matResult.memAvailableMinMB });
|
|
1614
|
+
send({ type: "mem_available_threshold_changed", memAvailableMinMB: matResult.memAvailableMinMB });
|
|
1615
|
+
}
|
|
1616
|
+
return true;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1601
1619
|
if (msg.type === "shutdown_server") {
|
|
1602
1620
|
if (typeof opts.onShutdown === "function") {
|
|
1603
1621
|
sendTo(ws, { type: "shutdown_server_result", ok: true });
|
package/lib/project.js
CHANGED
|
@@ -583,6 +583,14 @@ function createProjectContext(opts) {
|
|
|
583
583
|
}
|
|
584
584
|
return false;
|
|
585
585
|
},
|
|
586
|
+
// lr-2d91: Live config callback so sdk-bridge reads the current threshold on
|
|
587
|
+
// every query — not a stale value cached at bridge creation time.
|
|
588
|
+
getConfig: function () {
|
|
589
|
+
if (typeof opts.onGetDaemonConfig === "function") {
|
|
590
|
+
return opts.onGetDaemonConfig();
|
|
591
|
+
}
|
|
592
|
+
return {};
|
|
593
|
+
},
|
|
586
594
|
});
|
|
587
595
|
|
|
588
596
|
// --- Loop engine (delegated to project-loop.js) ---
|
package/lib/public/app.js
CHANGED
|
@@ -26,8 +26,8 @@ import { initContextSources, updateTerminalList, updateBrowserTabList, handleCon
|
|
|
26
26
|
import { initStickyNotes, handleNotesList, handleNoteCreated, handleNoteUpdated, handleNoteDeleted, openArchive, closeArchive, isArchiveOpen, hideNotes, showNotes, isNotesVisible, createNote } from './modules/sticky-notes.js';
|
|
27
27
|
import { initTheme, getThemeColor, getComputedVar, onThemeChange, getCurrentTheme, getChatLayout } from './modules/theme.js';
|
|
28
28
|
import { initTools, resetToolState, saveToolState, restoreToolState, renderAskUserQuestion, markAskUserAnswered, renderPermissionRequest, markPermissionResolved, markPermissionCancelled, renderElicitationRequest, markElicitationResolved, renderPlanBanner, renderPlanCard, handleTodoWrite, handleTaskCreate, handleTaskUpdate, startThinking, appendThinking, stopThinking, resetThinkingGroup, createToolItem, updateToolExecuting, updateToolResult, markAllToolsDone, addTurnMeta, resetTurnMetaCost, enableMainInput, getTools, getPlanContent, setPlanContent, isPlanFilePath, getTodoTools, updateSubagentActivity, addSubagentToolEntry, markSubagentDone, updateSubagentProgress, initSubagentStop, closeToolGroup, removeToolFromGroup } from './modules/tools.js';
|
|
29
|
-
import { initServerSettings, updateSettingsStats, updateSettingsModels, updateDaemonConfig, handleSetPinResult, handleKeepAwakeChanged, handleAutoContinueChanged, handleRestartResult, handleShutdownResult, handleSharedEnv, handleSharedEnvSaved, handleGlobalClaudeMdRead, handleGlobalClaudeMdWrite } from './modules/server-settings.js';
|
|
30
|
-
import { initProjectSettings, handleInstructionsRead, handleInstructionsWrite, handleProjectEnv, handleProjectEnvSaved, isProjectSettingsOpen, handleProjectSharedEnv, handleProjectSharedEnvSaved, handleProjectOwnerChanged } from './modules/project-settings.js';
|
|
29
|
+
import { initServerSettings, updateSettingsStats, updateSettingsModels, updateDaemonConfig, handleSetPinResult, handleKeepAwakeChanged, handleAutoContinueChanged, handleRestartResult, handleShutdownResult, handleSharedEnv, handleSharedEnvSaved, handleGlobalClaudeMdRead, handleGlobalClaudeMdWrite, isSettingsOpen, closeSettings } from './modules/server-settings.js';
|
|
30
|
+
import { initProjectSettings, handleInstructionsRead, handleInstructionsWrite, handleProjectEnv, handleProjectEnvSaved, isProjectSettingsOpen, closeProjectSettings, handleProjectSharedEnv, handleProjectSharedEnvSaved, handleProjectOwnerChanged } from './modules/project-settings.js';
|
|
31
31
|
import { initSkills, handleSkillInstalled, handleSkillUninstalled } from './modules/skills.js';
|
|
32
32
|
import { initMcp } from './modules/mcp-ui.js';
|
|
33
33
|
import { initScheduler, resetScheduler, handleLoopRegistryUpdated, handleScheduleRunStarted, handleScheduleRunFinished, handleLoopScheduled, openSchedulerToTab, isSchedulerOpen, closeScheduler, enterCraftingMode, exitCraftingMode, handleLoopRegistryFiles, getUpcomingSchedules } from './modules/scheduler.js';
|
|
@@ -41,7 +41,8 @@ import { initProjectSwitcher } from './modules/project-switcher.js';
|
|
|
41
41
|
import { initAdmin, checkAdminAccess } from './modules/admin.js';
|
|
42
42
|
import { initSessionSearch, toggleSearch, closeSearch, isSearchOpen, handleFindInSessionResults, onHistoryPrepended as onSessionSearchHistoryPrepended } from './modules/session-search.js';
|
|
43
43
|
import { initTooltips, registerTooltip } from './modules/tooltip.js';
|
|
44
|
-
import { initCommandPalette, handlePaletteSessionSwitch, setPaletteVersion } from './modules/command-palette.js';
|
|
44
|
+
import { initCommandPalette, handlePaletteSessionSwitch, setPaletteVersion, isCommandPaletteOpen, closeCommandPalette } from './modules/command-palette.js';
|
|
45
|
+
import { consumeOverlayPopstate, hasOverlayState } from './modules/overlay-history.js';
|
|
45
46
|
import { initAgentPicker } from './modules/agent-picker.js';
|
|
46
47
|
import { initLongPress } from './modules/longpress.js';
|
|
47
48
|
import { initConnection, connect as _connConnect, setStatus as _connSetStatus, scheduleReconnect as _connScheduleReconnect, cancelReconnect as _connCancelReconnect } from './modules/app-connection.js';
|
|
@@ -614,6 +615,19 @@ import { initMention, handleMentionStart, handleMentionStream, handleMentionDone
|
|
|
614
615
|
function switchProject(slug) { _projSwitchProject(slug); }
|
|
615
616
|
|
|
616
617
|
window.addEventListener("popstate", function () {
|
|
618
|
+
// Mobile swipe-back / browser back: if an overlay pushed a sentinel history
|
|
619
|
+
// entry, close that overlay and consume the event — do not navigate.
|
|
620
|
+
if (hasOverlayState()) {
|
|
621
|
+
consumeOverlayPopstate();
|
|
622
|
+
// Close whichever overlay is open (priority order: most-modal first).
|
|
623
|
+
if (isCommandPaletteOpen()) { closeCommandPalette(); return; }
|
|
624
|
+
if (isSettingsOpen()) { closeSettings(); return; }
|
|
625
|
+
if (isProjectSettingsOpen()) { closeProjectSettings(); return; }
|
|
626
|
+
if (isSearchOpen()) { closeSearch(); return; }
|
|
627
|
+
if (isArchiveOpen()) { closeArchive(); return; }
|
|
628
|
+
if (isSchedulerOpen()) { closeScheduler(); return; }
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
617
631
|
var m = location.pathname.match(/^\/p\/([a-z0-9_-]+)/);
|
|
618
632
|
var newSlug = m ? m[1] : null;
|
|
619
633
|
if (newSlug && newSlug !== store.get('currentSlug')) {
|
package/lib/public/css/input.css
CHANGED
|
@@ -859,11 +859,16 @@ body.mate-dm-active #input-wrapper,
|
|
|
859
859
|
font-weight: 600;
|
|
860
860
|
font-size: 14px;
|
|
861
861
|
font-family: "Roboto Mono", monospace;
|
|
862
|
+
flex-shrink: 0;
|
|
862
863
|
}
|
|
863
864
|
|
|
864
865
|
.slash-item .slash-desc {
|
|
865
866
|
color: var(--text-muted);
|
|
866
867
|
font-size: 13px;
|
|
868
|
+
overflow: hidden;
|
|
869
|
+
white-space: nowrap;
|
|
870
|
+
text-overflow: ellipsis;
|
|
871
|
+
min-width: 0;
|
|
867
872
|
}
|
|
868
873
|
|
|
869
874
|
/* ==========================================================================
|
|
@@ -90,9 +90,15 @@ export function initHeader() {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
var s = store.snap();
|
|
93
|
+
var vendor = s.currentVendor || "claude";
|
|
93
94
|
if (s.cliSessionId) addRow("Session ID", s.cliSessionId);
|
|
94
95
|
if (s.activeSessionId) addRow("Local ID", s.activeSessionId);
|
|
95
|
-
if (s.cliSessionId)
|
|
96
|
+
if (s.cliSessionId) {
|
|
97
|
+
var resumeCmd = vendor === "codex"
|
|
98
|
+
? "codex resume " + s.cliSessionId
|
|
99
|
+
: "claude --resume " + s.cliSessionId;
|
|
100
|
+
addRow("Resume", resumeCmd);
|
|
101
|
+
}
|
|
96
102
|
|
|
97
103
|
document.body.appendChild(pop);
|
|
98
104
|
sessionInfoPopover = pop;
|
|
@@ -277,14 +277,19 @@ export function processMessage(msg) {
|
|
|
277
277
|
connectOverlay.classList.remove("hidden");
|
|
278
278
|
break;
|
|
279
279
|
|
|
280
|
-
case "slash_commands":
|
|
280
|
+
case "slash_commands": {
|
|
281
|
+
// Backward compat: server sends {name,desc,type}[] since lr-1c7f;
|
|
282
|
+
// older server versions may still send string[].
|
|
281
283
|
var reserved = new Set(builtinCommands.map(function (c) { return c.name; }));
|
|
282
|
-
|
|
283
|
-
return
|
|
284
|
-
|
|
285
|
-
|
|
284
|
+
var enriched = (msg.commands || []).map(function (cmd) {
|
|
285
|
+
if (typeof cmd === "string") return { name: cmd, desc: "", type: "skill" };
|
|
286
|
+
return cmd;
|
|
287
|
+
});
|
|
288
|
+
store.set({ slashCommands: enriched.filter(function (cmd) {
|
|
289
|
+
return !reserved.has(cmd.name);
|
|
286
290
|
}) });
|
|
287
291
|
break;
|
|
292
|
+
}
|
|
288
293
|
|
|
289
294
|
case "model_info": {
|
|
290
295
|
// Drop stale model_info from a vendor that doesn't match the active
|
|
@@ -2,6 +2,7 @@ import { userAvatarUrl } from './avatar.js';
|
|
|
2
2
|
import { escapeHtml } from './utils.js';
|
|
3
3
|
import { refreshIcons } from './icons.js';
|
|
4
4
|
import { openSearch as openSessionSearch } from './session-search.js';
|
|
5
|
+
import { pushOverlayState, popOverlayState } from './overlay-history.js';
|
|
5
6
|
|
|
6
7
|
function formatRelativeDate(ts) {
|
|
7
8
|
if (!ts) return "";
|
|
@@ -75,6 +76,7 @@ export function isCommandPaletteOpen() {
|
|
|
75
76
|
|
|
76
77
|
export function openCommandPalette() {
|
|
77
78
|
if (!paletteEl) return;
|
|
79
|
+
pushOverlayState();
|
|
78
80
|
paletteEl.classList.remove("hidden");
|
|
79
81
|
var searchbar = document.getElementById("cmd-palette-btn");
|
|
80
82
|
if (searchbar) searchbar.style.visibility = "hidden";
|
|
@@ -90,6 +92,7 @@ export function openCommandPalette() {
|
|
|
90
92
|
|
|
91
93
|
export function closeCommandPalette() {
|
|
92
94
|
if (!paletteEl) return;
|
|
95
|
+
popOverlayState();
|
|
93
96
|
paletteEl.classList.add("hidden");
|
|
94
97
|
var searchbar = document.getElementById("cmd-palette-btn");
|
|
95
98
|
if (searchbar) searchbar.style.visibility = "";
|
|
@@ -66,11 +66,27 @@ export function setScheduleBtnDisabled(disabled) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export var builtinCommands = [
|
|
69
|
-
|
|
69
|
+
// Core CLI built-in commands (handled by the Claude CLI itself, not user skills)
|
|
70
|
+
{ name: "bug", desc: "Submit a bug report" },
|
|
71
|
+
{ name: "clear", desc: "Clear conversation history and start fresh" },
|
|
72
|
+
{ name: "compact", desc: "Compact conversation with optional summary focus" },
|
|
70
73
|
{ name: "context", desc: "Context window usage" },
|
|
74
|
+
{ name: "doctor", desc: "Check Claude Code installation health" },
|
|
75
|
+
{ name: "help", desc: "Get help and list available commands" },
|
|
76
|
+
{ name: "init", desc: "Initialize a project with a CLAUDE.md guide file" },
|
|
77
|
+
{ name: "login", desc: "Switch Anthropic accounts" },
|
|
78
|
+
{ name: "logout", desc: "Log out from Anthropic account" },
|
|
79
|
+
{ name: "memory", desc: "Edit Claude's memory files" },
|
|
80
|
+
{ name: "review", desc: "Review a pull request" },
|
|
71
81
|
{ name: "rewind", desc: "Toggle rewind mode" },
|
|
72
|
-
{ name: "usage", desc: "Toggle usage panel" },
|
|
73
82
|
{ name: "status", desc: "Process status and resource usage" },
|
|
83
|
+
{ name: "usage", desc: "Show usage statistics and costs" },
|
|
84
|
+
{ name: "vim", desc: "Enter vim mode for input" },
|
|
85
|
+
// Note: skills/workflows shipped with the CLI (code-review, workflow, loop, etc.)
|
|
86
|
+
// are intentionally NOT listed here — they are discovered dynamically via
|
|
87
|
+
// sdk-skill-discovery and sdk-workflow-discovery and will appear with real
|
|
88
|
+
// descriptions through the slash_commands WS message (lr-7d8d, lr-7bd3, lr-1c7f).
|
|
89
|
+
// Adding them here would filter them OUT of the dynamic discovery path.
|
|
74
90
|
];
|
|
75
91
|
|
|
76
92
|
// --- Send ---
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// overlay-history.js — mobile swipe-back / browser-back overlay dismissal
|
|
2
|
+
//
|
|
3
|
+
// Problem: on mobile PWAs, a back swipe fires a browser `popstate` event.
|
|
4
|
+
// If no app-level history entry exists for the open overlay, the browser
|
|
5
|
+
// navigates away (exits the PWA or goes to the previous real page).
|
|
6
|
+
//
|
|
7
|
+
// Pattern:
|
|
8
|
+
// - Each overlay calls pushOverlayState() on open.
|
|
9
|
+
// - Each overlay's close function calls popOverlayState().
|
|
10
|
+
// - The central popstate handler in app.js:
|
|
11
|
+
// 1. Calls consumeOverlayPopstate() — returns true if an overlay entry
|
|
12
|
+
// was active (and suppresses the redundant history.back() in the
|
|
13
|
+
// subsequent popOverlayState() call).
|
|
14
|
+
// 2. If true, calls the appropriate close function and returns.
|
|
15
|
+
// 3. Otherwise falls through to normal project-switch logic.
|
|
16
|
+
//
|
|
17
|
+
// The key invariant: history.back() must be called exactly once per sentinel.
|
|
18
|
+
// When the user closes via UI (X / Escape), popOverlayState() calls
|
|
19
|
+
// history.back() to remove the sentinel. When the browser already did the
|
|
20
|
+
// pop (back swipe), consumeOverlayPopstate() sets a suppress flag so the
|
|
21
|
+
// close function's popOverlayState() call is a no-op.
|
|
22
|
+
|
|
23
|
+
var _depth = 0;
|
|
24
|
+
var _suppressBack = false;
|
|
25
|
+
|
|
26
|
+
// Call when an overlay opens. Pushes a sentinel history entry.
|
|
27
|
+
export function pushOverlayState() {
|
|
28
|
+
_depth++;
|
|
29
|
+
history.pushState({ overlay: true, depth: _depth }, "");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Call when an overlay closes. If the close is user-initiated (not from a
|
|
33
|
+
// popstate callback), calls history.back() to remove the sentinel we pushed.
|
|
34
|
+
// If _suppressBack is set (we're inside the popstate handler), skip the
|
|
35
|
+
// history.back() — it already happened.
|
|
36
|
+
export function popOverlayState() {
|
|
37
|
+
if (_depth > 0) {
|
|
38
|
+
_depth--;
|
|
39
|
+
if (_suppressBack) {
|
|
40
|
+
_suppressBack = false;
|
|
41
|
+
} else {
|
|
42
|
+
history.back();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Returns true if at least one overlay history entry is active.
|
|
48
|
+
export function hasOverlayState() {
|
|
49
|
+
return _depth > 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Called by the popstate handler before invoking the overlay close function.
|
|
53
|
+
// Marks that history.back() should be suppressed in the upcoming
|
|
54
|
+
// popOverlayState() call (since the browser already did the pop).
|
|
55
|
+
// Returns true if an overlay entry was consumed, false if none was active.
|
|
56
|
+
export function consumeOverlayPopstate() {
|
|
57
|
+
if (_depth > 0) {
|
|
58
|
+
_suppressBack = true;
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
@@ -3,6 +3,7 @@ import { refreshIcons } from './icons.js';
|
|
|
3
3
|
import { buildEmojiPicker } from './emoji-picker.js';
|
|
4
4
|
import { showToast } from './utils.js';
|
|
5
5
|
import { parseEmojis } from './markdown.js';
|
|
6
|
+
import { pushOverlayState, popOverlayState } from './overlay-history.js';
|
|
6
7
|
import { closeFileViewer } from './filebrowser.js';
|
|
7
8
|
import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar, renderBetaCard } from './settings-defaults.js';
|
|
8
9
|
|
|
@@ -212,12 +213,14 @@ export function openProjectSettings(slug, project) {
|
|
|
212
213
|
closeFileViewer();
|
|
213
214
|
|
|
214
215
|
// Show panel
|
|
216
|
+
pushOverlayState();
|
|
215
217
|
panelEl.classList.remove("hidden");
|
|
216
218
|
refreshIcons();
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
export function closeProjectSettings() {
|
|
220
222
|
if (!panelEl) return;
|
|
223
|
+
popOverlayState();
|
|
221
224
|
panelEl.classList.add("hidden");
|
|
222
225
|
closePsEmojiPicker();
|
|
223
226
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { iconHtml } from './icons.js';
|
|
9
9
|
import { showToast } from './utils.js';
|
|
10
|
+
import { pushOverlayState, popOverlayState } from './overlay-history.js';
|
|
10
11
|
import { renderModelList, renderModeList, renderEffortBar, renderThinkingBar } from './settings-defaults.js';
|
|
11
12
|
import { store } from './store.js';
|
|
12
13
|
import { initSchedulerConfig, setupCreateModal, openCreateModal, openCreateModalWithRecord, closeCreateModal, removePreview, getPreviewEl, showPreviewOnCell, showPreviewOnSlot, showPreviewForCreate, applyDraggedTask, parseCronSimple } from './scheduler-config.js';
|
|
@@ -353,6 +354,7 @@ function updateCraftingHeader() {
|
|
|
353
354
|
function openScheduler() {
|
|
354
355
|
if (panelOpen) return;
|
|
355
356
|
panelOpen = true;
|
|
357
|
+
pushOverlayState();
|
|
356
358
|
ensurePanel();
|
|
357
359
|
if (!panel) return;
|
|
358
360
|
|
|
@@ -393,6 +395,7 @@ function openScheduler() {
|
|
|
393
395
|
export function closeScheduler() {
|
|
394
396
|
if (!panelOpen) return;
|
|
395
397
|
panelOpen = false;
|
|
398
|
+
popOverlayState();
|
|
396
399
|
stopNowLineTimer();
|
|
397
400
|
if (currentMode === "crafting") {
|
|
398
401
|
unparentChat();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// server-settings.js — Full-screen server settings overlay
|
|
2
2
|
import { refreshIcons } from './icons.js';
|
|
3
3
|
import { showToast, copyToClipboard } from './utils.js';
|
|
4
|
+
import { pushOverlayState, popOverlayState } from './overlay-history.js';
|
|
4
5
|
import { parseEnvString, looksLikeEnv } from './project-settings.js';
|
|
5
6
|
import { checkAdminAccess, loadAdminSection } from './admin.js';
|
|
6
7
|
import { closeFileViewer } from './filebrowser.js';
|
|
@@ -475,6 +476,7 @@ function switchSection(sectionName) {
|
|
|
475
476
|
|
|
476
477
|
function openSettings() {
|
|
477
478
|
closeFileViewer();
|
|
479
|
+
pushOverlayState();
|
|
478
480
|
settingsEl.classList.remove("hidden");
|
|
479
481
|
settingsBtn.classList.add("active");
|
|
480
482
|
refreshIcons(settingsEl);
|
|
@@ -513,7 +515,8 @@ function resetShutdownForm() {
|
|
|
513
515
|
if (errorEl) errorEl.classList.add("hidden");
|
|
514
516
|
}
|
|
515
517
|
|
|
516
|
-
function closeSettings() {
|
|
518
|
+
export function closeSettings() {
|
|
519
|
+
popOverlayState();
|
|
517
520
|
settingsEl.classList.add("hidden");
|
|
518
521
|
settingsBtn.classList.remove("active");
|
|
519
522
|
if (statsTimer) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// --- In-session search (Cmd+F / Ctrl+F) ---
|
|
2
2
|
import { escapeHtml } from './utils.js';
|
|
3
3
|
import { iconHtml, refreshIcons } from './icons.js';
|
|
4
|
+
import { pushOverlayState, popOverlayState } from './overlay-history.js';
|
|
4
5
|
|
|
5
6
|
var ctx = null;
|
|
6
7
|
var searchBarEl = null;
|
|
@@ -95,6 +96,7 @@ function isSearchOpen() {
|
|
|
95
96
|
|
|
96
97
|
function openSearch(prefill) {
|
|
97
98
|
if (!searchBarEl) return;
|
|
99
|
+
pushOverlayState();
|
|
98
100
|
searchBarEl.classList.remove("hidden");
|
|
99
101
|
var btn = document.getElementById("find-in-session-btn");
|
|
100
102
|
if (btn) btn.classList.add("active");
|
|
@@ -111,6 +113,7 @@ function openSearch(prefill) {
|
|
|
111
113
|
|
|
112
114
|
function closeSearch() {
|
|
113
115
|
if (!searchBarEl) return;
|
|
116
|
+
popOverlayState();
|
|
114
117
|
searchBarEl.classList.add("hidden");
|
|
115
118
|
var btn = document.getElementById("find-in-session-btn");
|
|
116
119
|
if (btn) btn.classList.remove("active");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { refreshIcons, iconHtml } from './icons.js';
|
|
2
|
+
import { pushOverlayState, popOverlayState } from './overlay-history.js';
|
|
2
3
|
|
|
3
4
|
var ctx;
|
|
4
5
|
var notes = new Map(); // id -> { data, el }
|
|
@@ -1128,6 +1129,7 @@ function renderArchiveCards() {
|
|
|
1128
1129
|
export function openArchive() {
|
|
1129
1130
|
if (archiveOpen) return;
|
|
1130
1131
|
archiveOpen = true;
|
|
1132
|
+
pushOverlayState();
|
|
1131
1133
|
|
|
1132
1134
|
var messagesEl = document.getElementById("messages");
|
|
1133
1135
|
var appEl = document.getElementById("app");
|
|
@@ -1192,6 +1194,7 @@ export function openArchive() {
|
|
|
1192
1194
|
export function closeArchive() {
|
|
1193
1195
|
if (!archiveOpen) return;
|
|
1194
1196
|
archiveOpen = false;
|
|
1197
|
+
popOverlayState();
|
|
1195
1198
|
|
|
1196
1199
|
var archive = document.getElementById("notes-archive");
|
|
1197
1200
|
var messagesEl = document.getElementById("messages");
|