@clagentic/console 1.9.0-beta.1 → 1.9.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.
Files changed (50) hide show
  1. package/bin/cli.js +12 -1
  2. package/lib/agents.js +13 -3
  3. package/lib/build-sha.json +2 -2
  4. package/lib/cli/ipc-subcommands.js +40 -4
  5. package/lib/daemon.js +25 -1
  6. package/lib/project-connection.js +15 -2
  7. package/lib/project-loop.js +46 -2
  8. package/lib/project-sessions.js +31 -3
  9. package/lib/project-user-message.js +70 -3
  10. package/lib/project.js +7 -1
  11. package/lib/public/app.js +14 -4
  12. package/lib/public/css/base.css +14 -0
  13. package/lib/public/css/home-hub.css +28 -8
  14. package/lib/public/css/icon-strip.css +17 -0
  15. package/lib/public/css/messages.css +11 -0
  16. package/lib/public/css/mobile-nav.css +22 -0
  17. package/lib/public/css/sidebar.css +15 -0
  18. package/lib/public/css/title-bar.css +10 -1
  19. package/lib/public/index.html +1 -0
  20. package/lib/public/modules/activity-latch.js +159 -0
  21. package/lib/public/modules/activity-state.js +157 -0
  22. package/lib/public/modules/app-connection.js +10 -4
  23. package/lib/public/modules/app-favicon.js +88 -1
  24. package/lib/public/modules/app-home-hub.js +14 -11
  25. package/lib/public/modules/app-loop-ui.js +86 -2
  26. package/lib/public/modules/app-messages.js +118 -54
  27. package/lib/public/modules/app-panels.js +91 -32
  28. package/lib/public/modules/app-projects.js +28 -8
  29. package/lib/public/modules/app-rate-limit.js +13 -1
  30. package/lib/public/modules/sidebar-mobile.js +32 -22
  31. package/lib/public/modules/sidebar-projects.js +42 -14
  32. package/lib/public/modules/sidebar-sessions.js +168 -48
  33. package/lib/public/modules/tools.js +11 -39
  34. package/lib/sdk-bridge.js +301 -22
  35. package/lib/sdk-message-processor.js +98 -15
  36. package/lib/sdk-skill-discovery.js +46 -6
  37. package/lib/sdk-slash-enrichment.js +5 -2
  38. package/lib/server-hub-sessions.js +70 -0
  39. package/lib/server.js +24 -22
  40. package/lib/session-activity.js +8 -1
  41. package/lib/sessions.js +47 -1
  42. package/lib/smtp.js +10 -1
  43. package/lib/ws-schema.js +16 -0
  44. package/lib/yoke/adapters/claude.js +7 -1
  45. package/lib/yoke/adapters/codex.js +219 -31
  46. package/package.json +2 -2
  47. package/scripts/check-test-count.js +397 -0
  48. package/scripts/test-file-completion-reporter.js +43 -0
  49. package/lib/model-context-windows.js +0 -74
  50. package/lib/public/modules/model-context-windows.js +0 -71
package/bin/cli.js CHANGED
@@ -33,7 +33,7 @@ var { forkDaemon, devMode, setDaemonWatcherOpts } = require("../lib/cli/daemon-l
33
33
  var { setup, promptRestoreProjects, showMainMenu } = require("../lib/cli/menus");
34
34
  var { getLocalIP } = require("../lib/cli/net-detect");
35
35
  var { log, a, sym } = require("../lib/cli/tui");
36
- var { handleShutdown, handleRestart, handleAdd, handleRemove, handleList } = require("../lib/cli/ipc-subcommands");
36
+ var { handleShutdown, handleRestart, handleAdd, handleRemove, handleList, handleActivityDiagnostics } = require("../lib/cli/ipc-subcommands");
37
37
 
38
38
  var args = process.argv.slice(2);
39
39
 
@@ -69,6 +69,7 @@ var noRestart = false;
69
69
  var addPath = null;
70
70
  var removePath = null;
71
71
  var listMode = false;
72
+ var activityDiagnosticsMode = false;
72
73
  var dangerouslySkipPermissions = false;
73
74
  var headlessMode = false;
74
75
  var watchMode = false;
@@ -118,6 +119,8 @@ for (var i = 0; i < args.length; i++) {
118
119
  i++;
119
120
  } else if (args[i] === "--list") {
120
121
  listMode = true;
122
+ } else if (args[i] === "--activity-diagnostics") {
123
+ activityDiagnosticsMode = true;
121
124
  } else if (args[i] === "--headless") {
122
125
  headlessMode = true;
123
126
  autoYes = true;
@@ -132,6 +135,7 @@ for (var i = 0; i < args.length; i++) {
132
135
  console.log(" clagentic-console --add <path> Add a project to the running daemon");
133
136
  console.log(" clagentic-console --remove <path> Remove a project from the running daemon");
134
137
  console.log(" clagentic-console --list List registered projects");
138
+ console.log(" clagentic-console --activity-diagnostics Print activity-divergence probe totals as JSON (agent-readable)");
135
139
  console.log(" clagentic-console release list-betas List promotable beta versions (maintainer/release-engineering)");
136
140
  console.log("");
137
141
  console.log("Options:");
@@ -149,6 +153,7 @@ for (var i = 0; i < args.length; i++) {
149
153
  console.log(" --add <path> Add a project directory (use '.' for current)");
150
154
  console.log(" --remove <path> Remove a project directory");
151
155
  console.log(" --list List all registered projects");
156
+ console.log(" --activity-diagnostics Print activity-divergence probe totals as JSON");
152
157
  console.log(" --headless Start daemon and exit immediately (implies --yes)");
153
158
  console.log(" --multi-user Start in multi-user mode (use with --yes for headless)");
154
159
  console.log(" --os-users Enable OS-level user isolation (Linux, requires root + --multi-user)");
@@ -194,6 +199,12 @@ if (listMode) {
194
199
  return;
195
200
  }
196
201
 
202
+ // --- Handle --activity-diagnostics before anything else ---
203
+ if (activityDiagnosticsMode) {
204
+ handleActivityDiagnostics();
205
+ return;
206
+ }
207
+
197
208
  // --multi-user / --os-users are now handled in the main entry flow (setup wizard or repeat run)
198
209
  // Flags are parsed above and applied during forkDaemon()
199
210
 
package/lib/agents.js CHANGED
@@ -83,6 +83,12 @@ function slugifyAgentName(name) {
83
83
  // enforcement in the query setup path.
84
84
  //
85
85
  // agentName: the agent identity string (e.g. "agentic-director").
86
+ // globalAgentsDir: optional override of AGENTS_SOURCE_DIR. On a shared
87
+ // multi-user daemon, callers resolve the SESSION OWNER's home
88
+ // (os-users.getLinuxUserHome(linuxUser)) and pass
89
+ // path.join(thatHome, ".claude", "agents") here so the on-disk agent
90
+ // definition is read from the invoking user's own home, not the daemon
91
+ // process's REAL_HOME (lr-3ccc78 twin of the skill-discovery fix).
86
92
  // Returns: string[] of tool names if the tools field is a valid JSON array,
87
93
  // null if the file is absent, the frontmatter is missing, or the
88
94
  // tools field cannot be parsed.
@@ -90,11 +96,12 @@ function slugifyAgentName(name) {
90
96
  // Failures are silent (logged at debug level) — callers treat null as "no
91
97
  // restriction from this source" and fall through to whatever the SDK applies
92
98
  // via claudeOpts.agent.
93
- function readAgentToolsFromFile(agentName) {
99
+ function readAgentToolsFromFile(agentName, globalAgentsDir) {
94
100
  if (!agentName || typeof agentName !== "string") return null;
95
101
  var slug = slugifyAgentName(agentName);
96
102
  if (!slug) return null;
97
- var filePath = path.join(AGENTS_SOURCE_DIR, slug + ".md");
103
+ var baseDir = (typeof globalAgentsDir === "string" && globalAgentsDir) ? globalAgentsDir : AGENTS_SOURCE_DIR;
104
+ var filePath = path.join(baseDir, slug + ".md");
98
105
  var raw;
99
106
  try {
100
107
  raw = fs.readFileSync(filePath, "utf8");
@@ -256,7 +263,10 @@ function _readAgentsFromDir(agentsDir) {
256
263
  return results;
257
264
  }
258
265
 
259
- // _globalAgentsDir is an optional override used in tests; callers must not pass it.
266
+ // _globalAgentsDir is an optional override of the global agents directory.
267
+ // Tests use it to point at a fixture dir; production callers on a shared
268
+ // multi-user daemon pass the session owner's own ~/.claude/agents (see
269
+ // readAgentToolsFromFile above, lr-3ccc78).
260
270
  function readProjectAgents(projectDir, _globalAgentsDir) {
261
271
  if (!projectDir || typeof projectDir !== "string") return [];
262
272
 
@@ -1,4 +1,4 @@
1
1
  {
2
- "sha": "4cb76e53f5a2ad0701ab1fb6ab73005c0b07902d",
3
- "writtenAt": "2026-08-03T23:53:06.975Z"
2
+ "sha": "99208748c957f643a44ee6fab76a8fc1891f3b1b",
3
+ "writtenAt": "2026-08-27T22:24:59.717Z"
4
4
  }
@@ -1,10 +1,15 @@
1
1
  // lib/cli/ipc-subcommands.js
2
2
  //
3
3
  // One-shot IPC subcommand handlers for bin/cli.js: --shutdown, --restart,
4
- // --add <path>, --remove <path>, --list. Each of these talks to the running
5
- // daemon over the Unix socket and exits the process directly (they never
6
- // return control to the caller) — extracted verbatim from bin/cli.js
7
- // (lr-4e49 Part 1), no behavior change.
4
+ // --add <path>, --remove <path>, --list, --activity-diagnostics. Each of
5
+ // these talks to the running daemon over the Unix socket and exits the
6
+ // process directly (they never return control to the caller) —
7
+ // --shutdown/--restart/--add/--remove/--list extracted verbatim from
8
+ // bin/cli.js (lr-4e49 Part 1), no behavior change.
9
+ // --activity-diagnostics added by lr-8b476f: the only agent-readable
10
+ // (Bash+Read, no browser/WS/devtools) retrieval path for the lr-58c813
11
+ // server-side activity-divergence probe. Prints raw JSON to stdout so a
12
+ // read-only crew agent can run this directly.
8
13
 
9
14
  var fs = require("fs");
10
15
  var path = require("path");
@@ -177,10 +182,41 @@ function handleList() {
177
182
  });
178
183
  }
179
184
 
185
+ // lr-8b476f: prints the activity-divergence probe totals (same data
186
+ // process_stats's WS response folds in, see lib/daemon.js's
187
+ // "get_activity_diagnostics" IPC case) as raw JSON to stdout. This is the
188
+ // retrieval path for a read-only crew agent (Bash+Read only, no browser,
189
+ // no WS client, no devtools): `clagentic-console --activity-diagnostics`.
190
+ function handleActivityDiagnostics() {
191
+ var diagConfig = loadConfig();
192
+ isDaemonAliveAsync(diagConfig).then(function (alive) {
193
+ if (!alive) {
194
+ console.error("No running daemon. Start with: npx @clagentic/console");
195
+ process.exit(1);
196
+ }
197
+ sendIPCCommand(socketPath(), { cmd: "get_activity_diagnostics" }).then(function (res) {
198
+ if (!res.ok) {
199
+ console.error("Failed: " + (res.error || "unknown error"));
200
+ process.exit(1);
201
+ return;
202
+ }
203
+ // Raw JSON to stdout — the point is machine readability, not a
204
+ // human-formatted summary (contrast handleList's formatted output).
205
+ console.log(JSON.stringify({
206
+ activeLiveCount: res.activeLiveCount,
207
+ activityDivergenceCount: res.activityDivergenceCount,
208
+ activityDivergenceRecentSamples: res.activityDivergenceRecentSamples,
209
+ }, null, 2));
210
+ process.exit(0);
211
+ });
212
+ });
213
+ }
214
+
180
215
  module.exports = {
181
216
  handleShutdown: handleShutdown,
182
217
  handleRestart: handleRestart,
183
218
  handleAdd: handleAdd,
184
219
  handleRemove: handleRemove,
185
220
  handleList: handleList,
221
+ handleActivityDiagnostics: handleActivityDiagnostics,
186
222
  };
package/lib/daemon.js CHANGED
@@ -31,7 +31,7 @@ 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
33
  var { validateCloneUrl, buildCloneArgs } = require("./clone-validate");
34
- var { DEFAULT_MEM_AVAILABLE_MIN_MB, DEFAULT_TOKENS_PER_MB_HEADROOM, getActiveLiveCount } = require("./sdk-bridge");
34
+ var { DEFAULT_MEM_AVAILABLE_MIN_MB, DEFAULT_TOKENS_PER_MB_HEADROOM, getActiveLiveCount, buildActivityDiagnosticsResponse } = require("./sdk-bridge");
35
35
  var { startMemoryHighWatcher, checkAppliedMemoryCeiling } = require("./memory-limits");
36
36
  var { createDrain } = require("./drain");
37
37
  var { shedMemory } = require("./memory-shed");
@@ -1553,6 +1553,30 @@ var ipc = createIPCServer(socketPath(), function (msg) {
1553
1553
  uptime: process.uptime(),
1554
1554
  };
1555
1555
 
1556
+ // lr-8b476f: agent-readable counterpart to the WS-only process_stats
1557
+ // handler (lib/project-sessions.js:668-709). Reads the same shared
1558
+ // module-level counter (lib/sdk-bridge.js) that process_stats already
1559
+ // folds into its response via getMemoryStats() — buildActivityDiagnosticsResponse
1560
+ // is unit-tested directly (test/activity-diagnostics-retrieval-lr-8b476f.test.js),
1561
+ // since daemon.js has no module.exports and cannot be required
1562
+ // in-process without binding real sockets/HTTP servers.
1563
+ //
1564
+ // Read-only, mutates nothing. Gated the same way every other IPC
1565
+ // command on this socket is gated: CONFIG_DIR (containing daemon.sock)
1566
+ // is chmod 0700 (ensureConfigDir, lib/config.js), so only the daemon's
1567
+ // own OS user can connect at all — no new auth surface is introduced,
1568
+ // and none is copied from process_stats's WS gap (lr-2016fe) either,
1569
+ // since this is a different transport with its own (stricter, OS-level)
1570
+ // gate rather than an unaudited role check.
1571
+ //
1572
+ // Samples carry no session-identifying field, matching process_stats's
1573
+ // BOBBIE-remediated shape exactly (lib/sdk-bridge.js
1574
+ // _recordActivityDivergenceIfAny) — this command reads the SAME
1575
+ // samples, so nothing new is exposed by adding this second retrieval
1576
+ // path.
1577
+ case "get_activity_diagnostics":
1578
+ return buildActivityDiagnosticsResponse();
1579
+
1556
1580
  case "set_pin": {
1557
1581
  config.pinHash = msg.pinHash || null;
1558
1582
  relay.setAuthToken(config.pinHash);
@@ -229,7 +229,17 @@ function attachConnection(ctx) {
229
229
  // lr-041af8: carry the restored session's own effective model — see
230
230
  // effectiveSessionModel() in sessions.js and the model_info/config_state
231
231
  // fix above in this same connect handler.
232
- sendTo(ws, { type: "session_switched", id: active.localId, cliSessionId: active.cliSessionId || null, loop: active.loop || null, vendor: active.vendor || null, model: sm.effectiveSessionModel(active), hasHistory: _hasHistory, capabilities: _vendorCaps, agentName: active.agentName || null });
232
+ // This hydration send previously omitted isProcessing — sessions.js's
233
+ // switchSession() send DOES carry it, but a client that hydrates via
234
+ // THIS path (fresh connect / reconnect) never got the authoritative
235
+ // reconciled value here, only via the separate status:"processing"
236
+ // send below (guarded by active.isProcessing) — and that separate
237
+ // message carried no session-scoping (see localId note below), so a
238
+ // client's derived 'sessionIsProcessing' could lag or desync from
239
+ // server truth across a reconnect. Carrying it directly on
240
+ // session_switched matches switchSession() and gives the client a
241
+ // single authoritative snapshot value to reconcile the footer against.
242
+ sendTo(ws, { type: "session_switched", id: active.localId, cliSessionId: active.cliSessionId || null, loop: active.loop || null, vendor: active.vendor || null, model: sm.effectiveSessionModel(active), hasHistory: _hasHistory, capabilities: _vendorCaps, isProcessing: !!active.isProcessing, agentName: active.agentName || null });
233
243
  // Send per-session context sources
234
244
  var sessionSources = loadContextSources(slug, active.localId);
235
245
  sendTo(ws, { type: "context_sources_state", active: sessionSources });
@@ -239,7 +249,10 @@ function attachConnection(ctx) {
239
249
  sm.replayHistory(active, undefined, ws, hydrateImageRefs);
240
250
 
241
251
  if (active.isProcessing) {
242
- sendTo(ws, { type: "status", status: "processing" });
252
+ // Carry localId so the client can session-scope this edge (matching
253
+ // the scheduled_message_* pattern) instead of writing the global
254
+ // 'processing' latch blind to which session it belongs to.
255
+ sendTo(ws, { type: "status", status: "processing", localId: active.localId });
243
256
  }
244
257
  var pendingIds = Object.keys(active.pendingPermissions);
245
258
  for (var pi = 0; pi < pendingIds.length; pi++) {
@@ -769,11 +769,31 @@ function attachLoop(ctx) {
769
769
  var lastCoderSession = sm.sessions.get(loopState.currentSessionId);
770
770
  if (lastCoderSession) {
771
771
  lastCoderSession.singleTurn = false;
772
- lastCoderSession.loop.active = false;
773
772
  _loopOwnerUserId = lastCoderSession.ownerId || null;
774
773
  }
775
774
  }
776
775
 
776
+ // lr-fd38ac: clear the stale-resumability marker on EVERY session that
777
+ // belongs to this loop run, not just the last coder session. Four
778
+ // writers set `session.loop.active = true` (coder at runNextIteration(),
779
+ // judge at runJudge(), crafting at the two wizard-crafting sites) — every
780
+ // judge session and every prior iteration's coder session was left
781
+ // permanently orphaned at active:true, and the one session this used to
782
+ // fix reverted across a daemon restart because the clear was never
783
+ // persisted (sessions.js:109 writes session.loop into the on-disk meta
784
+ // line; sessions.js:711 rehydrates it — an in-memory-only clear never
785
+ // reaches either). Persist the clear on each session so it survives a
786
+ // restart and so switching into ANY finished loop session (coder, judge,
787
+ // any iteration) is resumable, not just the last one.
788
+ if (loopState.loopId) {
789
+ sm.sessions.forEach(function (s) {
790
+ if (s && s.loop && s.loop.loopId === loopState.loopId && s.loop.active) {
791
+ s.loop.active = false;
792
+ sm.saveSessionFile(s);
793
+ }
794
+ });
795
+ }
796
+
777
797
  loopState.active = false;
778
798
  loopState.phase = "done";
779
799
  loopState.stopping = false;
@@ -956,6 +976,23 @@ function attachLoop(ctx) {
956
976
  // lr-e31b: Queue a human message for delivery at the next iteration
957
977
  // boundary. See the comment in runNextIteration() for why this is
958
978
  // boundary-delivered rather than injected into the live iteration.
979
+ //
980
+ // lr-6fe5fc: this gate and the client's queue-mode UI gate
981
+ // (isLoopQueueSession() in app-loop-ui.js) are intentionally NOT the
982
+ // same predicate. This one answers "does the project have a running
983
+ // loop that will accept a queued message at all" — loopState.active
984
+ // alone, since pendingUserMessages is a single project-wide queue
985
+ // delivered at the next iteration boundary regardless of which session
986
+ // sent the WS message (loop_message carries no sessionId — see
987
+ // input.js). The client's gate additionally requires the loop's
988
+ // current session to be the one actually being viewed, which is a UX
989
+ // constraint (don't claim "queued for the next iteration" on a session
990
+ // that has nothing to do with that queue) this server-side accept
991
+ // check has no need to enforce, since it is already correctly scoped
992
+ // to the one loop this project can run at a time. Collapsing these
993
+ // into one shared function would misrepresent one of the two questions
994
+ // as the other; each stays the single authority for what it actually
995
+ // answers.
959
996
  if (msg.type === "loop_message") {
960
997
  if (!loopState.active) {
961
998
  sendTo(ws, { type: "loop_message_error", text: "No loop is currently running." });
@@ -1365,7 +1402,8 @@ function attachLoop(ctx) {
1365
1402
  // connected (most-recently-active) project crowded out the genuinely most
1366
1403
  // recent sessions overall. getAllProjectSessions returns annotated shallow
1367
1404
  // copies carrying _projectSlug/_projectTitle/_projectIcon for every project.
1368
- var allSessions = getAllProjectSessions ? getAllProjectSessions(true) : [];
1405
+ var hubUserId = ws._clayUser ? ws._clayUser.id : null;
1406
+ var allSessions = getAllProjectSessions ? getAllProjectSessions(true, hubUserId) : [];
1369
1407
  // Sort newest-first by lastActivity
1370
1408
  allSessions.sort(function (a, b) {
1371
1409
  return (b.lastActivity || b.createdAt || 0) - (a.lastActivity || a.createdAt || 0);
@@ -1393,6 +1431,12 @@ function attachLoop(ctx) {
1393
1431
  // state on this field so only the actually-notifying session's
1394
1432
  // row lights up, not every sibling row in the same project.
1395
1433
  unread: getSessionUnread(ws, sessProjectSlug, s.localId),
1434
+ // lr-66c118: multi-user activity tone. ownerId was already on the
1435
+ // session object (createSession) but never projected onto this
1436
+ // wire shape — the frontend derivation module (activity-state.js)
1437
+ // needs it to distinguish "my activity" from "another user's
1438
+ // activity" the same way session_list already does.
1439
+ ownerId: s.ownerId || null,
1396
1440
  };
1397
1441
  });
1398
1442
  sendTo(ws, { type: "hub_recent_sessions", sessions: mapped });
@@ -11,9 +11,25 @@ var sessionActivity = require("./session-activity");
11
11
  // Kick off SDK agent discovery in the background at module load.
12
12
  // Errors are swallowed inside refresh(); the cache starts empty and fills
13
13
  // when the SDK subprocess completes initialization (~9s on this box).
14
- agentsModule.refresh().catch(function (e) {
15
- console.error("[project-sessions] initial agent refresh failed:", e && e.message ? e.message : e);
16
- });
14
+ //
15
+ // lr-795882: skipped under `node --test` (NODE_TEST_CONTEXT is set natively
16
+ // by the test runner itself — not a project-invented flag). This module is
17
+ // required, directly or transitively via lib/project.js, by ~18 test files;
18
+ // none of them exercise agent discovery, so this was spawning a real
19
+ // @anthropic-ai/claude-agent-sdk subprocess purely as an unrequested
20
+ // module-load side effect on every full suite run. refresh()'s SDK session
21
+ // is aborted in a finally block (lib/agents.js) but the underlying process
22
+ // exit is deferred by the SDK's own internal debounce, so the spawned
23
+ // subprocess could still be alive — holding the event loop open — well
24
+ // after the module that triggered it finished loading. This was the root
25
+ // cause package.json's --test-force-exit was added to paper over (see
26
+ // 5c17b6d) and was never actually fixed, only masked. Tests that need real
27
+ // agent discovery call agentsModule.refresh() themselves explicitly.
28
+ if (!process.env.NODE_TEST_CONTEXT) {
29
+ agentsModule.refresh().catch(function (e) {
30
+ console.error("[project-sessions] initial agent refresh failed:", e && e.message ? e.message : e);
31
+ });
32
+ }
17
33
 
18
34
  // Format a user's answer to an ask_user_questions card as a plain user
19
35
  // message so the MCP path can feed it back to the agent on the next turn.
@@ -677,6 +693,18 @@ function attachSessions(ctx) {
677
693
  memAvailableMB: memAvailMB,
678
694
  activeLiveCount: memStats.activeLiveCount !== undefined ? memStats.activeLiveCount : null,
679
695
  maxConcurrentSessions: memStats.maxConcurrentSessions !== undefined ? memStats.maxConcurrentSessions : null,
696
+ // lr-58c813: baseline instrumentation for the lr-5edd64 redesign —
697
+ // count of session.isProcessing !== sessionActivity.isSessionActive(session)
698
+ // divergences observed since daemon start, plus a bounded ring
699
+ // buffer of the most recent occurrences. Read-only counter; does not
700
+ // reflect or affect what any renderer displays. Samples carry no
701
+ // session identifier (BOBBIE finding): this handler has no
702
+ // admin/role gate, unlike its update_now/kill_process siblings, so
703
+ // any authenticated client on a shared project could otherwise read
704
+ // another user's session id through it. Fixing that pre-existing
705
+ // gate gap is out of scope for this instrumentation-only PR.
706
+ activityDivergenceCount: memStats.activityDivergenceCount !== undefined ? memStats.activityDivergenceCount : null,
707
+ activityDivergenceRecentSamples: memStats.activityDivergenceRecentSamples || [],
680
708
  });
681
709
  return true;
682
710
  }
@@ -25,6 +25,57 @@ var fs = require("fs");
25
25
  * digestDmTurn,
26
26
  * adapter - YOKE adapter instance
27
27
  */
28
+ // lr-62157d: code-point-aware truncation to a max length. Plain
29
+ // String#substring/slice indexes by UTF-16 code unit, so a cut that lands
30
+ // inside a surrogate pair (e.g. most emoji, many CJK supplementary-plane
31
+ // characters) produces a lone unpaired surrogate — renders as a broken/
32
+ // replacement glyph. Array.from(str) iterates a string by Unicode code
33
+ // point (correctly reassembling surrogate pairs), so slicing the resulting
34
+ // array and rejoining never splits one. BOBBIE fnd (PR #406 review):
35
+ // pasted content is now a title source (see deriveProvisionalTitle below),
36
+ // and pasted text is far more likely to contain emoji/CJK than a typed
37
+ // first line, making this newly reachable in a way it wasn't before. No
38
+ // existing helper for this in the codebase (every other truncation call
39
+ // site uses plain substring — out of scope here, this is a minimal fix
40
+ // for the newly-reachable path only, not a codebase-wide truncation sweep).
41
+ function truncateCodePointSafe(str, maxLen) {
42
+ var codePoints = Array.from(str);
43
+ if (codePoints.length <= maxLen) return str;
44
+ return codePoints.slice(0, maxLen).join("");
45
+ }
46
+
47
+ // lr-62157d: pure helper — derives the FIRST-message provisional title
48
+ // (before any turn has completed / before autoGenerateTitle can run).
49
+ // Prefers real message text; falls back to the first paste when text is
50
+ // empty (a >=500-char paste is diverted server-side into msg.pastes[] with
51
+ // msg.text empty by the client's paste-chip handling — see input.js — so
52
+ // msg.text alone previously always fell through to the "Image" literal for
53
+ // a text paste, not just a genuine image-only message). "Image" is reserved
54
+ // for the case where neither text nor a paste is present. Whitespace is
55
+ // collapsed before truncating since pastes are commonly multi-line and an
56
+ // un-normalized 50-char slice renders as a broken sidebar entry.
57
+ // Exported as _test_deriveProvisionalTitle (see codex.js's
58
+ // _test_resolveTitleModel for the established convention) so this is
59
+ // directly unit-testable without constructing the full WS message handler.
60
+ function deriveProvisionalTitle(msg) {
61
+ var source = msg && msg.text;
62
+ if (!source && msg && msg.pastes && msg.pastes.length > 0) {
63
+ source = msg.pastes[0];
64
+ }
65
+ // PEACHES fnd-439007: msg is raw client-controlled WS JSON with no
66
+ // server-side schema validation (see project-connection.js's bare
67
+ // JSON.parse) — the bundled browser client only ever sends strings in
68
+ // pastes[] (input.js's paste handler pushes p.text, always a string), but
69
+ // nothing enforces that for an arbitrary WS client. A non-string entry
70
+ // (e.g. an object) must not reach .replace(), which only exists on
71
+ // strings — fall through to the "Image" literal instead, exactly the case
72
+ // it was originally written for.
73
+ var collapsed = typeof source === "string"
74
+ ? truncateCodePointSafe(source.replace(/\s+/g, " ").trim(), 50)
75
+ : "";
76
+ return collapsed || "Image";
77
+ }
78
+
28
79
  function attachUserMessage(ctx) {
29
80
  var cwd = ctx.cwd;
30
81
  var slug = ctx.slug;
@@ -302,7 +353,19 @@ function attachUserMessage(ctx) {
302
353
  if (!msg.text && (!msg.images || msg.images.length === 0) && (!msg.pastes || msg.pastes.length === 0)) return true;
303
354
 
304
355
  var session = getSessionForWs(ws);
305
- if (!session) return true;
356
+ if (!session) {
357
+ // lr-5450ef: this used to be a bare `return true` — the message was
358
+ // silently swallowed with no feedback to the sender whatsoever (not
359
+ // even a server log line), the same silence-to-UI failure class as
360
+ // the pendingMessages buffering fixed alongside this in sdk-bridge.js.
361
+ // getSessionForWs returning null here means the client's websocket
362
+ // has no session bound to it (e.g. stale/detached client, session
363
+ // deleted from under it) — surface that instead of pretending the
364
+ // message was handled.
365
+ console.error("[project-user-message] Dropping user message: no session bound to this websocket (slug=" + slug + ")");
366
+ sendTo(ws, { type: "error", text: "Clagentic: Console couldn't find your session — try reloading." });
367
+ return true;
368
+ }
306
369
 
307
370
  // Bind vendor to session on first message (if not already set)
308
371
  if (!session.vendor && msg.vendor) {
@@ -353,7 +416,11 @@ function attachUserMessage(ctx) {
353
416
  sendToSessionOthers(ws, session.localId, hydrateImageRefs(userMsg2));
354
417
 
355
418
  if (!session.title) {
356
- session.title = (msg.text || "Image").substring(0, 50);
419
+ session.title = deriveProvisionalTitle(msg);
420
+ // This is only a provisional title — autoGenerateTitle (sdk-bridge.js)
421
+ // is allowed to overwrite it once a real LLM-generated title is ready,
422
+ // as long as the user hasn't manually renamed the session since.
423
+ session.titleProvisional = true;
357
424
  sm.saveSessionFile(session);
358
425
  sm.broadcastSessionList();
359
426
  // Sync auto-title to SDK
@@ -660,5 +727,5 @@ function attachUserMessage(ctx) {
660
727
  };
661
728
  }
662
729
 
663
- module.exports = { attachUserMessage: attachUserMessage };
730
+ module.exports = { attachUserMessage: attachUserMessage, _test_deriveProvisionalTitle: deriveProvisionalTitle };
664
731
 
package/lib/project.js CHANGED
@@ -2,7 +2,7 @@ var fs = require("fs");
2
2
  var path = require("path");
3
3
  var os = require("os");
4
4
  var crypto = require("crypto");
5
- var { createSessionManager } = require("./sessions");
5
+ var { createSessionManager, stampActivityLocalId } = require("./sessions");
6
6
  var { createSDKBridge, createMessageQueue } = require("./sdk-bridge");
7
7
  var { createTerminalManager } = require("./terminal-manager");
8
8
  var { createNotesManager } = require("./notes");
@@ -381,6 +381,11 @@ function createProjectContext(opts) {
381
381
  }
382
382
 
383
383
  function sendToSession(sessionId, obj) {
384
+ // Stamp localId on status/done/auth_required so the client can
385
+ // session-scope the edge write instead of applying it blind to
386
+ // whichever session is currently focused — see sessions.js's
387
+ // stampActivityLocalId doc comment for the full rationale/type list.
388
+ stampActivityLocalId(sessionId, obj);
384
389
  var data = JSON.stringify(obj);
385
390
  for (var ws of clients) {
386
391
  if (ws.readyState === 1 && ws._clayActiveSession === sessionId) {
@@ -390,6 +395,7 @@ function createProjectContext(opts) {
390
395
  }
391
396
 
392
397
  function sendToSessionOthers(sender, sessionId, obj) {
398
+ stampActivityLocalId(sessionId, obj);
393
399
  var data = JSON.stringify(obj);
394
400
  for (var ws of clients) {
395
401
  if (ws !== sender && ws.readyState === 1 && ws._clayActiveSession === sessionId) {
package/lib/public/app.js CHANGED
@@ -52,7 +52,7 @@ import { getWs as _getWsRef, setWs as _setWsRef } from './modules/ws-ref.js';
52
52
  import { initHomeHub, showHomeHub as _hubShowHomeHub, hideHomeHub as _hubHideHomeHub, handleHubSchedules as _hubHandleHubSchedules, renderHomeHub as _hubRenderHomeHub, isHomeHubVisible } from './modules/app-home-hub.js';
53
53
  import { initRateLimit, handleRateLimitEvent as _rlHandleRateLimitEvent, updateRateLimitUsage as _rlUpdateRateLimitUsage, addScheduledMessageBubble as _rlAddScheduledMessageBubble, removeScheduledMessageBubble as _rlRemoveScheduledMessageBubble, handleFastModeState as _rlHandleFastModeState, getScheduledMsgEl, resetRateLimitState } from './modules/app-rate-limit.js';
54
54
  import { initCursors, handleRemoteCursorMove as _curHandleRemoteCursorMove, handleRemoteCursorLeave as _curHandleRemoteCursorLeave, handleRemoteSelection as _curHandleRemoteSelection, clearRemoteCursors as _curClearRemoteCursors, initCursorToggle } from './modules/app-cursors.js';
55
- import { initFavicon, updateFavicon as _favUpdateFavicon, setSendBtnMode as _favSetSendBtnMode, blinkIO as _favBlinkIO, blinkSessionDot as _favBlinkSessionDot, updateCrossProjectBlink as _favUpdateCrossProjectBlink, startUrgentBlink as _favStartUrgentBlink, stopUrgentBlink as _favStopUrgentBlink, setActivity as _favSetActivity, drawFaviconAnimFrame as _favDrawFaviconAnimFrame } from './modules/app-favicon.js';
55
+ import { initFavicon, initActivityFooter, updateFavicon as _favUpdateFavicon, setSendBtnMode as _favSetSendBtnMode, blinkIO as _favBlinkIO, blinkSessionDot as _favBlinkSessionDot, updateCrossProjectBlink as _favUpdateCrossProjectBlink, startUrgentBlink as _favStartUrgentBlink, stopUrgentBlink as _favStopUrgentBlink, setActivity as _favSetActivity, drawFaviconAnimFrame as _favDrawFaviconAnimFrame } from './modules/app-favicon.js';
56
56
  import { initHeader, closeSessionInfoPopover as _hdrCloseSessionInfoPopover, updateHistorySentinel as _hdrUpdateHistorySentinel, requestMoreHistory as _hdrRequestMoreHistory, prependOlderHistory as _hdrPrependOlderHistory } from './modules/app-header.js';
57
57
  import { initMisc, flushPendingExtMessages, showImageModal as _miscShowImageModal, closeImageModal as _miscCloseImageModal, showPasteModal as _miscShowPasteModal, closePasteModal as _miscClosePasteModal, showConfirm as _miscShowConfirm, hideConfirm as _miscHideConfirm, showForceChangePinOverlay as _miscShowForceChangePinOverlay, sendExtensionCommand as _miscSendExtensionCommand, handleExtensionResult as _miscHandleExtensionResult } from './modules/app-misc.js';
58
58
  import { initSkillInstall, requireSkills as _siRequireSkills, handleSkillInstallWs as _siHandleSkillInstallWs } from './modules/app-skills-install.js';
@@ -60,13 +60,14 @@ import { initLoopUi, updateLoopInputVisibility as _loopUpdateLoopInputVisibility
60
60
  import { initLoopWizard, openRalphWizard as _loopOpenRalphWizard, closeRalphWizard as _loopCloseRalphWizard, getWizardSource as _loopGetWizardSource } from './modules/app-loop-wizard.js';
61
61
  import { initAppNotifications, handleNotificationsState as _notifHandleState, handleNotificationCreated as _notifHandleCreated, handleNotificationDismissed as _notifHandleDismissed, handleNotificationDismissedAll as _notifHandleDismissedAll } from './modules/app-notifications.js';
62
62
  import { createStore, store } from './modules/store.js';
63
- import { initPanels, updateConfigChip as _panUpdateConfigChip, getModelEffortLevels as _panGetModelEffortLevels, accumulateUsage as _panAccumulateUsage, updateUsagePanel as _panUpdateUsagePanel, resetUsage as _panResetUsage, toggleUsagePanel as _panToggleUsagePanel, formatTokens as _panFormatTokens, updateStatusPanel as _panUpdateStatusPanel, requestProcessStats as _panRequestProcessStats, toggleStatusPanel as _panToggleStatusPanel, accumulateContext as _panAccumulateContext, updateContextPanel as _panUpdateContextPanel, resetContext as _panResetContext, resetContextData as _panResetContextData, minimizeContext as _panMinimizeContext, expandContext as _panExpandContext, toggleContextPanel as _panToggleContextPanel, getContextView as _panGetContextView, renderCtxPopover as _panRenderCtxPopover, hideCtxPopover as _panHideCtxPopover, formatBytes as _panFormatBytes, formatUptime as _panFormatUptime, getModelSupportsEffort as _panGetModelSupportsEffort, getSessionUsage, setSessionUsage, getContextData, setContextData, setContextView as _panSetContextView, applyContextView as _panApplyContextView } from './modules/app-panels.js';
63
+ import { initPanels, updateConfigChip as _panUpdateConfigChip, getModelEffortLevels as _panGetModelEffortLevels, accumulateUsage as _panAccumulateUsage, updateUsagePanel as _panUpdateUsagePanel, resetUsage as _panResetUsage, toggleUsagePanel as _panToggleUsagePanel, formatTokens as _panFormatTokens, updateStatusPanel as _panUpdateStatusPanel, requestProcessStats as _panRequestProcessStats, toggleStatusPanel as _panToggleStatusPanel, accumulateContext as _panAccumulateContext, updateContextPanel as _panUpdateContextPanel, resetContext as _panResetContext, resetContextData as _panResetContextData, minimizeContext as _panMinimizeContext, expandContext as _panExpandContext, toggleContextPanel as _panToggleContextPanel, getContextView as _panGetContextView, renderCtxPopover as _panRenderCtxPopover, hideCtxPopover as _panHideCtxPopover, formatBytes as _panFormatBytes, formatUptime as _panFormatUptime, getModelSupportsEffort as _panGetModelSupportsEffort, getSessionUsage, setSessionUsage, setContextData, setContextView as _panSetContextView, applyContextView as _panApplyContextView, getEffectiveContextFill as _panGetEffectiveContextFill } from './modules/app-panels.js';
64
64
  import { initProjects, onProjectListUpdated, onResetClientState, updateProjectList as _projUpdateProjectList, renderProjectList as _projRenderProjectList, renderTopbarPresence as _projRenderTopbarPresence, switchProject as _projSwitchProject, resetClientState as _projResetClientState, confirmRemoveProject as _projConfirmRemoveProject, handleRemoveProjectCheckResult as _projHandleRemoveProjectCheckResult, handleRemoveProjectResult as _projHandleRemoveProjectResult, openAddProjectModal as _projOpenAddProjectModal, closeAddProjectModal as _projCloseAddProjectModal, handleBrowseDirResult as _projHandleBrowseDirResult, handleAddProjectResult as _projHandleAddProjectResult, handleCloneProgress as _projHandleCloneProgress, showUpdateAvailable as _projShowUpdateAvailable, getCachedProjects, setCachedProjects, getCachedProjectCount, getCachedRemovedProjects, setCachedRemovedProjects } from './modules/app-projects.js';
65
65
  import { initRendering, addToMessages as _renAddToMessages, scrollToBottom as _renScrollToBottom, forceScrollToBottom as _renForceScrollToBottom, addUserMessage as _renAddUserMessage, getMsgTime as _renGetMsgTime, shouldGroupMessage as _renShouldGroupMessage, ensureAssistantBlock as _renEnsureAssistantBlock, addCopyHandler as _renAddCopyHandler, appendDelta as _renAppendDelta, flushStreamBuffer as _renFlushStreamBuffer, finalizeAssistantBlock as _renFinalizeAssistantBlock, addSystemMessage as _renAddSystemMessage, addConflictMessage as _renAddConflictMessage, addContextOverflowMessage as _renAddContextOverflowMessage, showClaudePreThinking as _renShowClaudePreThinking, showSuggestionChips as _renShowSuggestionChips, hideSuggestionChips as _renHideSuggestionChips, getGhostSuggestion as _renGetGhostSuggestion, getTurnCounter, setTurnCounter, getPrependAnchor, setPrependAnchor, getActivityEl, setActivityEl, getIsUserScrolledUp, setIsUserScrolledUp, getStickyBottom, armStickyBottom, disarmStickyBottom } from './modules/app-rendering.js';
66
66
  import { initDm, openDm as _dmOpenDm, enterDmMode as _dmEnterDmMode, exitDmMode as _dmExitDmMode, appendDmMessage as _dmAppendDmMessage, showDmTypingIndicator as _dmShowDmTypingIndicator, handleDmSend as _dmHandleDmSend } from './modules/app-dm.js';
67
67
  import { initMention, handleMentionStart, handleMentionStream, handleMentionDone, handleMentionError, handleMentionActivity, renderMentionUser, renderMentionResponse } from './modules/mention.js';
68
68
  import { initTeamPanel } from './modules/team-panel.js';
69
69
  import { initDiagnostics } from './modules/diagnostics.js';
70
+ import { getActivityEdgeLedger } from './modules/activity-latch.js';
70
71
 
71
72
  // --- Base path for multi-project routing ---
72
73
  var slugMatch = location.pathname.match(/^\/p\/([a-z0-9_-]+)/);
@@ -540,6 +541,7 @@ import { initDiagnostics } from './modules/diagnostics.js';
540
541
 
541
542
  // --- Favicon module ---
542
543
  initFavicon();
544
+ initActivityFooter();
543
545
 
544
546
  // --- Header module (rename, info popover, history) ---
545
547
  initHeader();
@@ -574,8 +576,10 @@ import { initDiagnostics } from './modules/diagnostics.js';
574
576
  stopUrgentBlink: function() { stopUrgentBlink(); },
575
577
  showImageModal: showImageModal,
576
578
  getContextPercent: function() {
577
- var cd = getContextData();
578
- return cd.contextWindow > 0 ? Math.round((cd.input / cd.contextWindow) * 100) : 0;
579
+ // lr-3af675: route through the same (used, win) pair the header bar
580
+ // and popover render from, so this label can never disagree with them.
581
+ var fill = _panGetEffectiveContextFill();
582
+ return fill.win > 0 ? Math.round((fill.used / fill.win) * 100) : 0;
579
583
  },
580
584
  getClaudeAvatar: function () { return CLAUDE_CODE_AVATAR; },
581
585
  });
@@ -1031,6 +1035,12 @@ import { initDiagnostics } from './modules/diagnostics.js';
1031
1035
  // --- Diagnostics panel (lr-8294, epic lr-1a52) ---
1032
1036
  initDiagnostics();
1033
1037
 
1038
+ // lr-58c813: expose the client-side activity-edge accept/reject ledger for
1039
+ // production retrieval without a debugger — open devtools console and run
1040
+ // `window.__clagenticActivityLedger()`. Read-only accessor over a plain
1041
+ // counter object (activity-latch.js); does not affect rendering.
1042
+ window.__clagenticActivityLedger = getActivityEdgeLedger;
1043
+
1034
1044
  // --- Messages module (uses direct imports, no ctx injection needed) ---
1035
1045
 
1036
1046
  // --- Connection module ---
@@ -57,6 +57,20 @@ img.emoji {
57
57
  --error: #FF4D6A;
58
58
  --success: #29D9A8;
59
59
  --warning: #4A7FE8;
60
+ /* lr-66c118: --danger was referenced with two DISAGREEING fallbacks
61
+ (#F24822 at sidebar.css:1713, #e74c3c at icon-strip.css/mention.css)
62
+ but never defined here. Defining it settles both call sites on one
63
+ color; #e74c3c matches the existing unread/alert red already used
64
+ throughout (session-unread-badge, hub-recent-dot.alert, etc). */
65
+ --danger: #e74c3c;
66
+ /* lr-66c118: multi-user activity tone — a THIRD color, distinct from
67
+ --success (own activity, green) and --danger (alert, red). Violet is
68
+ maximally hue-separated from both and from --accent (cyan) /
69
+ --accent2/--warning (blue), which already carry meaning. Hue alone is
70
+ not sufficient at 6-8px (deuteranopia/protanopia; violet/blue
71
+ confusion) — render sites must pair this with a shape difference
72
+ (ring vs filled disc), never ship on hue alone. */
73
+ --activity-other: #B77BF3;
60
74
  --accent-8: rgba(0, 207, 255, 0.08);
61
75
  --accent-12: rgba(0, 207, 255, 0.12);
62
76
  --accent-15: rgba(0, 207, 255, 0.15);
@@ -297,6 +297,12 @@
297
297
  background: var(--success);
298
298
  box-shadow: 0 0 6px rgba(80, 250, 123, 0.4);
299
299
  }
300
+ /* Multi-user tone (lr-66c118): ring shape, see .hub-recent-dot.other */
301
+ .hub-project-dot.other {
302
+ background: transparent;
303
+ border: 1.5px solid var(--activity-other, #B77BF3);
304
+ box-shadow: 0 0 4px rgba(183, 123, 243, 0.4);
305
+ }
300
306
  .hub-project-icon {
301
307
  font-size: 14px;
302
308
  width: 20px;
@@ -491,18 +497,32 @@
491
497
  opacity: 1;
492
498
  box-shadow: 0 0 6px rgba(80, 250, 123, 0.4);
493
499
  }
494
- /* Alert state — color precedence LOCKED (andy, lr-0aa7b6):
495
- alert(red) > processing(green) > live(green) > idle(grey). This class is
496
- applied instead of .processing when the row's session is notifying, so
497
- red always wins visually even if the session is also active. Same red
498
- used by .icon-strip-project-badge (unread badge). Formerly a SEPARATE
499
- right-side dot (.hub-recent-alert-dot, removed) — now just another color
500
- state of the single left dot. */
500
+ /* Alert state — color precedence LOCKED (andy, lr-0aa7b6), promoted into
501
+ activity-state.js's indicatorClass() as the canonical derivation for
502
+ every surface (lr-66c118): alert(red) > processing(green) > idle(grey).
503
+ ("live" never existed as a separate CSS class from "processing" anywhere
504
+ in the codebase — the old 4-state comment here was aspirational, not
505
+ real; reconciled to the 3 states actually shipped.) This class is applied
506
+ instead of .processing when the row's session is notifying, so red always
507
+ wins visually even if the session is also active. Same red used by
508
+ .icon-strip-project-badge (unread badge), now tokenized as --danger.
509
+ Formerly a SEPARATE right-side dot (.hub-recent-alert-dot, removed) — now
510
+ just another color state of the single left dot. */
501
511
  .hub-recent-dot.alert {
502
- background: #e74c3c;
512
+ background: var(--danger, #e74c3c);
503
513
  opacity: 1;
504
514
  box-shadow: 0 0 6px rgba(231, 76, 60, 0.5);
505
515
  }
516
+ /* Multi-user tone (lr-66c118): another user's activity — distinct violet
517
+ hue AND a ring shape (transparent center, colored border) instead of a
518
+ filled disc, so the state is distinguishable at 7px even under a
519
+ red/green color-vision deficiency (hue alone must not ship alone). */
520
+ .hub-recent-dot.other {
521
+ background: transparent;
522
+ opacity: 1;
523
+ border: 1.5px solid var(--activity-other, #B77BF3);
524
+ box-shadow: 0 0 4px rgba(183, 123, 243, 0.4);
525
+ }
506
526
  .hub-recent-project-icon {
507
527
  font-size: 14px;
508
528
  width: 20px;