@clagentic/console 1.8.0 → 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 (64) 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/generated/claude-model-catalog.json +180 -0
  7. package/lib/model-catalog.js +202 -0
  8. package/lib/model-families.js +243 -0
  9. package/lib/project-connection.js +30 -5
  10. package/lib/project-loop.js +46 -2
  11. package/lib/project-sessions.js +133 -21
  12. package/lib/project-user-message.js +70 -3
  13. package/lib/project.js +11 -1
  14. package/lib/public/app.js +14 -4
  15. package/lib/public/css/base.css +14 -0
  16. package/lib/public/css/home-hub.css +28 -8
  17. package/lib/public/css/icon-strip.css +17 -0
  18. package/lib/public/css/menus.css +67 -0
  19. package/lib/public/css/messages.css +11 -0
  20. package/lib/public/css/mobile-nav.css +22 -0
  21. package/lib/public/css/server-settings.css +72 -0
  22. package/lib/public/css/sidebar.css +15 -0
  23. package/lib/public/css/title-bar.css +10 -1
  24. package/lib/public/index.html +4 -0
  25. package/lib/public/modules/activity-latch.js +159 -0
  26. package/lib/public/modules/activity-state.js +157 -0
  27. package/lib/public/modules/app-connection.js +10 -4
  28. package/lib/public/modules/app-favicon.js +88 -1
  29. package/lib/public/modules/app-home-hub.js +14 -11
  30. package/lib/public/modules/app-loop-ui.js +90 -2
  31. package/lib/public/modules/app-messages.js +117 -28
  32. package/lib/public/modules/app-panels.js +184 -56
  33. package/lib/public/modules/app-projects.js +28 -8
  34. package/lib/public/modules/app-rate-limit.js +14 -2
  35. package/lib/public/modules/model-families.js +230 -0
  36. package/lib/public/modules/project-settings.js +1 -0
  37. package/lib/public/modules/scheduler.js +5 -0
  38. package/lib/public/modules/server-settings.js +14 -12
  39. package/lib/public/modules/settings-defaults.js +151 -41
  40. package/lib/public/modules/sidebar-mobile.js +32 -22
  41. package/lib/public/modules/sidebar-projects.js +42 -14
  42. package/lib/public/modules/sidebar-sessions.js +168 -48
  43. package/lib/public/modules/tools.js +22 -12
  44. package/lib/sdk-bridge.js +389 -35
  45. package/lib/sdk-message-processor.js +215 -7
  46. package/lib/sdk-skill-discovery.js +46 -6
  47. package/lib/sdk-slash-enrichment.js +5 -2
  48. package/lib/server-hub-sessions.js +70 -0
  49. package/lib/server.js +79 -22
  50. package/lib/session-activity.js +289 -0
  51. package/lib/sessions.js +104 -3
  52. package/lib/smtp.js +10 -1
  53. package/lib/terminal-manager.js +40 -0
  54. package/lib/utils.js +44 -0
  55. package/lib/ws-schema.js +17 -0
  56. package/lib/yoke/adapters/claude-worker.js +6 -2
  57. package/lib/yoke/adapters/claude.js +384 -88
  58. package/lib/yoke/adapters/codex.js +239 -31
  59. package/package.json +2 -2
  60. package/scripts/check-test-count.js +397 -0
  61. package/scripts/generate-model-catalog.js +337 -0
  62. package/scripts/test-file-completion-reporter.js +43 -0
  63. package/lib/model-context-windows.js +0 -65
  64. package/lib/public/modules/model-context-windows.js +0 -62
@@ -15,6 +15,7 @@ import { refreshMobileChatSheet } from './sidebar-mobile.js';
15
15
  import { openAgentPicker, openAgentPickerForPreferred } from './agent-picker.js';
16
16
  import { getCachedProjects } from './app-projects.js';
17
17
  import { positionPopover } from './popover-position.js';
18
+ import { sessionActivity, rollupActivity, indicatorClass } from './activity-state.js';
18
19
 
19
20
 
20
21
  // --- Session state ---
@@ -52,12 +53,23 @@ var armedDeleteTimer = null;
52
53
 
53
54
  // Active inline-rename tracking (session or loop). A full session-list
54
55
  // rebuild (innerHTML = "") detaches the rename <input> from the DOM without
55
- // firing a real user "blur" — the browser's synthetic blur-on-removal still
56
- // invokes commitRename(), but it operates on a textSpan that renderSessionList
57
- // is about to throw away, so the typed title is silently discarded. Tracking
58
- // the active commit/cancel lets renderSessionList settle it cleanly (using the
59
- // input's *current* value) before tearing the list down, instead of losing it.
60
- var activeRename = null; // { commit, cancel } or null
56
+ // firing a real user "blur" — but the browser DOES synthesize a blur event
57
+ // on detach, and the input's own blur listener is still attached at that
58
+ // instant. Committing on every rebuild (the original design here) turned
59
+ // out to be wrong: an actively-streaming session broadcasts session_list
60
+ // many times per turn, so the rename committed within a keystroke or two,
61
+ // sending a partial title as a real rename_session (durable write +
62
+ // permanent titleManuallySet=true — see lr-16b88d). `suspend()` captures
63
+ // the in-progress edit (value + caret) AND settles it as suspended (same
64
+ // short-circuit `settled` flag commit/cancel use) — no commit, no cancel,
65
+ // no WS send — so the detach-induced synthetic blur that fires the instant
66
+ // the rebuild's innerHTML="" runs is a no-op on the old input. renderSessionList
67
+ // then reassigns activeRename to null and, if a real rebuild ran, re-opens
68
+ // the rename afterward with the captured snapshot (see the suspendedRename
69
+ // re-open block at the end of renderSessionList). Precedent: scheduler.js's
70
+ // `cancelled` short-circuit flag / detach-as-blur handling (lr-fb49-E/F
71
+ // family) — suspend() is that same pattern applied to preserve-not-drop.
72
+ var activeRename = null; // { type, id, currentTitle, commit, cancel, suspend } or null
61
73
 
62
74
  export function openResumePicker() {
63
75
  openResumePickerModal();
@@ -746,40 +758,61 @@ function showLoopCtxMenu(anchorBtn, loopId, loopName, childCount) {
746
758
 
747
759
  // --- Inline rename ---
748
760
 
749
- function startInlineRename(sessionId, currentTitle) {
761
+ // resume: optional { value, selectionStart, selectionEnd } captured by a
762
+ // prior suspend() — restores the in-progress edit instead of starting fresh
763
+ // from currentTitle. Passed by renderSessionList() when re-opening a rename
764
+ // after a real rebuild tore the previous <input> down.
765
+ //
766
+ // LIFECYCLE GUARD (lr-16b88d PEACHES finding): `settled` alone is not
767
+ // enough once suspend() exists. A rebuild's innerHTML="" detaches this
768
+ // <input> without a real user blur, but the browser still SYNTHESIZES a
769
+ // blur event on detach — and that listener (registered below) is still
770
+ // attached at that moment. Without a guard, that synthetic blur fires
771
+ // commitRename() and ships the suspended partial edit as a real
772
+ // rename_session, exactly the bug this task exists to fix. suspend() must
773
+ // therefore flip `settled` itself (same short-circuit commit/cancel use),
774
+ // so the detach-induced blur that fires immediately afterward is a no-op —
775
+ // mirrors scheduler.js:609-621's `cancelled` short-circuit / detach-as-blur
776
+ // precedent.
777
+ function startInlineRename(sessionId, currentTitle, resume) {
750
778
  var el = getSessionListEl().querySelector('.session-item[data-session-id="' + sessionId + '"]');
751
779
  if (!el) return;
752
780
  var textSpan = el.querySelector(".session-item-text");
753
781
  if (!textSpan) return;
754
782
 
755
783
  // Settle (not silently drop) any rename already in progress elsewhere in
756
- // the list before starting a new one.
784
+ // the list before starting a new one. This is a real user-driven "start a
785
+ // different rename" action, not a rebuild-induced detach — commit here is
786
+ // correct (matches existing blur-to-commit semantics for switching target).
757
787
  if (activeRename) activeRename.commit();
758
788
 
759
789
  var input = document.createElement("input");
760
790
  input.type = "text";
761
791
  input.className = "session-rename-input";
762
- input.value = currentTitle || "New Session";
792
+ input.value = resume ? resume.value : (currentTitle || "New Session");
763
793
 
764
794
  var originalHtml = textSpan.innerHTML;
765
795
  textSpan.innerHTML = "";
766
796
  textSpan.appendChild(input);
767
797
  input.focus();
768
- input.select();
798
+ if (resume) {
799
+ input.setSelectionRange(resume.selectionStart, resume.selectionEnd);
800
+ } else {
801
+ input.select();
802
+ }
769
803
 
770
804
  var settled = false;
771
805
 
772
806
  function commitRename() {
773
807
  if (settled) return;
774
808
  settled = true;
775
- activeRename = null;
809
+ if (activeRename && activeRename.commit === commitRename) activeRename = null;
776
810
  var newTitle = input.value.trim();
777
811
  if (newTitle && newTitle !== currentTitle && getWs() && store.get('connected')) {
778
812
  getWs().send(JSON.stringify({ type: "rename_session", id: sessionId, title: newTitle }));
779
813
  }
780
814
  // Restore text (server will send updated session_list). Guard against the
781
- // textSpan already having been detached/replaced by a rebuild that ran
782
- // this same settle path via activeRename.commit() at its top.
815
+ // textSpan already having been detached/replaced by a rebuild.
783
816
  if (getSessionListEl().contains(textSpan)) {
784
817
  textSpan.innerHTML = originalHtml;
785
818
  if (newTitle && newTitle !== currentTitle) {
@@ -791,10 +824,23 @@ function startInlineRename(sessionId, currentTitle) {
791
824
  function cancelRename() {
792
825
  if (settled) return;
793
826
  settled = true;
794
- activeRename = null;
827
+ if (activeRename && activeRename.commit === commitRename) activeRename = null;
795
828
  if (getSessionListEl().contains(textSpan)) textSpan.innerHTML = originalHtml;
796
829
  }
797
830
 
831
+ // Capture the live edit AND settle it as suspended — no commit, no cancel,
832
+ // no WS send, but `settled` flips to true so the synthetic blur the
833
+ // upcoming innerHTML="" teardown fires against this exact input becomes a
834
+ // no-op (see the LIFECYCLE GUARD comment above). Does not clear
835
+ // module-level `activeRename` itself — the caller (renderSessionList)
836
+ // owns reassigning that slot once it knows whether a real rebuild ran and,
837
+ // if so, once the re-opened rename has installed its own activeRename.
838
+ function suspendRename() {
839
+ if (settled) return null;
840
+ settled = true;
841
+ return { value: input.value, selectionStart: input.selectionStart, selectionEnd: input.selectionEnd };
842
+ }
843
+
798
844
  input.addEventListener("keydown", function (e) {
799
845
  if (e.key === "Enter") { e.preventDefault(); commitRename(); }
800
846
  if (e.key === "Escape") { e.preventDefault(); cancelRename(); }
@@ -802,10 +848,19 @@ function startInlineRename(sessionId, currentTitle) {
802
848
  input.addEventListener("blur", commitRename);
803
849
  input.addEventListener("click", function (e) { e.stopPropagation(); });
804
850
 
805
- activeRename = { commit: commitRename, cancel: cancelRename };
851
+ activeRename = {
852
+ type: "session",
853
+ id: sessionId,
854
+ currentTitle: currentTitle,
855
+ commit: commitRename,
856
+ cancel: cancelRename,
857
+ suspend: suspendRename,
858
+ };
806
859
  }
807
860
 
808
- function startLoopInlineRename(loopId, currentName) {
861
+ // resume: see startInlineRename's matching parameter. See startInlineRename's
862
+ // LIFECYCLE GUARD comment — identical reasoning applies here.
863
+ function startLoopInlineRename(loopId, currentName, resume) {
809
864
  var el = getSessionListEl().querySelector('.session-loop-group[data-loop-id="' + loopId + '"]');
810
865
  if (!el) return;
811
866
  var textSpan = el.querySelector(".session-item-text");
@@ -816,20 +871,24 @@ function startLoopInlineRename(loopId, currentName) {
816
871
  var input = document.createElement("input");
817
872
  input.type = "text";
818
873
  input.className = "session-rename-input";
819
- input.value = currentName || "Loop";
874
+ input.value = resume ? resume.value : (currentName || "Loop");
820
875
 
821
876
  var originalHtml = textSpan.innerHTML;
822
877
  textSpan.innerHTML = "";
823
878
  textSpan.appendChild(input);
824
879
  input.focus();
825
- input.select();
880
+ if (resume) {
881
+ input.setSelectionRange(resume.selectionStart, resume.selectionEnd);
882
+ } else {
883
+ input.select();
884
+ }
826
885
 
827
886
  var settled = false;
828
887
 
829
888
  function commitRename() {
830
889
  if (settled) return;
831
890
  settled = true;
832
- activeRename = null;
891
+ if (activeRename && activeRename.commit === commitRename) activeRename = null;
833
892
  var newName = input.value.trim();
834
893
  if (newName && newName !== currentName && getWs() && store.get('connected')) {
835
894
  getWs().send(JSON.stringify({ type: "loop_registry_rename", id: loopId, name: newName }));
@@ -847,10 +906,17 @@ function startLoopInlineRename(loopId, currentName) {
847
906
  function cancelRename() {
848
907
  if (settled) return;
849
908
  settled = true;
850
- activeRename = null;
909
+ if (activeRename && activeRename.commit === commitRename) activeRename = null;
851
910
  if (getSessionListEl().contains(textSpan)) textSpan.innerHTML = originalHtml;
852
911
  }
853
912
 
913
+ // See startInlineRename's suspendRename — same settle-without-committing.
914
+ function suspendRename() {
915
+ if (settled) return null;
916
+ settled = true;
917
+ return { value: input.value, selectionStart: input.selectionStart, selectionEnd: input.selectionEnd };
918
+ }
919
+
854
920
  input.addEventListener("keydown", function (e) {
855
921
  if (e.key === "Enter") { e.preventDefault(); commitRename(); }
856
922
  if (e.key === "Escape") { e.preventDefault(); cancelRename(); }
@@ -858,7 +924,14 @@ function startLoopInlineRename(loopId, currentName) {
858
924
  input.addEventListener("blur", commitRename);
859
925
  input.addEventListener("click", function (e) { e.stopPropagation(); });
860
926
 
861
- activeRename = { commit: commitRename, cancel: cancelRename };
927
+ activeRename = {
928
+ type: "loop",
929
+ id: loopId,
930
+ currentTitle: currentName,
931
+ commit: commitRename,
932
+ cancel: cancelRename,
933
+ suspend: suspendRename,
934
+ };
862
935
  }
863
936
 
864
937
  // --- Date grouping / highlighting ---
@@ -903,8 +976,10 @@ function renderLoopChild(s) {
903
976
  var textSpan = document.createElement("span");
904
977
  textSpan.className = "session-item-text";
905
978
  var textHtml = "";
906
- if (s.isProcessing) {
907
- textHtml += '<span class="session-processing"></span>';
979
+ var childActivityState = sessionActivity(s, store.get('myUserId'));
980
+ var childActivityCls = indicatorClass(childActivityState);
981
+ if (childActivityCls) {
982
+ textHtml += '<span class="session-processing ' + childActivityCls + '" title="' + escapeHtml(childActivityState.label) + '"></span>';
908
983
  }
909
984
  if (s.loop) {
910
985
  var isRalphChild = s.loop.source === "ralph";
@@ -972,15 +1047,15 @@ function renderLoopGroup(loopId, children, groupKey) {
972
1047
 
973
1048
  var expanded = expandedLoopGroups.has(gk);
974
1049
  var hasActive = false;
975
- var anyProcessing = false;
976
1050
  var latestSession = visibleChildren[0];
977
1051
  for (var ci = 0; ci < visibleChildren.length; ci++) {
978
1052
  if (visibleChildren[ci].active) hasActive = true;
979
- if (visibleChildren[ci].isProcessing) anyProcessing = true;
980
1053
  if ((visibleChildren[ci].lastActivity || 0) > (latestSession.lastActivity || 0)) {
981
1054
  latestSession = visibleChildren[ci];
982
1055
  }
983
1056
  }
1057
+ // lr-66c118: replaces the open-coded anyProcessing OR-loop above.
1058
+ var groupActivityCls = indicatorClass(rollupActivity(visibleChildren, store.get('myUserId')));
984
1059
 
985
1060
  var loopName = (visibleChildren[0].loop && visibleChildren[0].loop.name) || "Loop";
986
1061
  var isRalph = visibleChildren[0].loop && visibleChildren[0].loop.source === "ralph";
@@ -1020,8 +1095,8 @@ function renderLoopGroup(loopId, children, groupKey) {
1020
1095
  var textSpan = document.createElement("span");
1021
1096
  textSpan.className = "session-item-text";
1022
1097
  var textHtml = "";
1023
- if (anyProcessing) {
1024
- textHtml += '<span class="session-processing"></span>';
1098
+ if (groupActivityCls) {
1099
+ textHtml += '<span class="session-processing ' + groupActivityCls + '"></span>';
1025
1100
  }
1026
1101
  var groupIcon = isRalph ? "repeat" : "calendar-clock";
1027
1102
  var iconClass = isRalph ? "" : " scheduled";
@@ -1094,15 +1169,15 @@ function renderLoopRun(parentGk, startedAtKey, sessions, isRalph) {
1094
1169
  var timeLabel = startedAt ? new Date(startedAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : "Unknown";
1095
1170
 
1096
1171
  var hasActive = false;
1097
- var anyProcessing = false;
1098
1172
  var latestSession = sessions[0];
1099
1173
  for (var i = 0; i < sessions.length; i++) {
1100
1174
  if (sessions[i].active) hasActive = true;
1101
- if (sessions[i].isProcessing) anyProcessing = true;
1102
1175
  if ((sessions[i].lastActivity || 0) > (latestSession.lastActivity || 0)) {
1103
1176
  latestSession = sessions[i];
1104
1177
  }
1105
1178
  }
1179
+ // lr-66c118: replaces the open-coded anyProcessing OR-loop above.
1180
+ var runActivityCls = indicatorClass(rollupActivity(sessions, store.get('myUserId')));
1106
1181
 
1107
1182
  var wrapper = document.createElement("div");
1108
1183
  wrapper.className = "session-loop-run-wrapper";
@@ -1129,8 +1204,8 @@ function renderLoopRun(parentGk, startedAtKey, sessions, isRalph) {
1129
1204
  var textSpan = document.createElement("span");
1130
1205
  textSpan.className = "session-item-text";
1131
1206
  var textHtml = "";
1132
- if (anyProcessing) {
1133
- textHtml += '<span class="session-processing"></span>';
1207
+ if (runActivityCls) {
1208
+ textHtml += '<span class="session-processing ' + runActivityCls + '"></span>';
1134
1209
  }
1135
1210
  textHtml += '<span class="session-loop-run-time">' + escapeHtml(timeLabel) + '</span>';
1136
1211
  textHtml += '<span class="session-loop-count' + (isRalph ? "" : " scheduled") + '">' + sessions.length + '</span>';
@@ -1173,8 +1248,10 @@ function renderSessionItem(s) {
1173
1248
  var textSpan = document.createElement("span");
1174
1249
  textSpan.className = "session-item-text";
1175
1250
  var textHtml = "";
1176
- if (s.isProcessing) {
1177
- textHtml += '<span class="session-processing"></span>';
1251
+ var itemActivityState = sessionActivity(s, store.get('myUserId'));
1252
+ var itemActivityCls = indicatorClass(itemActivityState);
1253
+ if (itemActivityCls) {
1254
+ textHtml += '<span class="session-processing ' + itemActivityCls + '" title="' + escapeHtml(itemActivityState.label) + '"></span>';
1178
1255
  }
1179
1256
  if (s.sessionVisibility === "private") {
1180
1257
  textHtml += '<span class="session-private-icon" title="Private session">' + iconHtml("lock") + '</span>';
@@ -1234,7 +1311,11 @@ function renderSessionItem(s) {
1234
1311
 
1235
1312
  // --- Main session list ---
1236
1313
 
1314
+ // lr-66c118: the activity field below is the derived class (indicatorClass/
1315
+ // sessionActivity), not a raw processing-flag read — also captures an
1316
+ // ownerId-driven tone change a boolean would have missed.
1237
1317
  function _fingerprintSessions(list, expanded, expandedRuns) {
1318
+ var myUserId = store.get('myUserId');
1238
1319
  var parts = [];
1239
1320
  for (var i = 0; i < list.length; i++) {
1240
1321
  var s = list[i];
@@ -1242,7 +1323,7 @@ function _fingerprintSessions(list, expanded, expandedRuns) {
1242
1323
  s.id + "," +
1243
1324
  (s.title || "") + "," +
1244
1325
  (s.active ? "1" : "0") + "," +
1245
- (s.isProcessing ? "1" : "0") + "," +
1326
+ indicatorClass(sessionActivity(s, myUserId)) + "," +
1246
1327
  (s.bookmarked ? "1" : "0") + "," +
1247
1328
  // favoriteOrder drives sort order within the favorites section
1248
1329
  // (compareSessionListItems) and unread drives the badge — both must be
@@ -1266,23 +1347,21 @@ function _fingerprintSessions(list, expanded, expandedRuns) {
1266
1347
  export function renderSessionList(sessions) {
1267
1348
  if (sessions) cachedSessions = sessions;
1268
1349
 
1269
- // A full rebuild below (innerHTML = "") detaches the in-progress rename
1270
- // <input> / armed-delete "x" button without a real user action. Settle
1271
- // both cleanly first: commit the rename using its current value (matching
1272
- // existing blur-to-commit behavior) and clear the armed-delete affordance
1273
- // so the rebuilt button doesn't silently delete on the next single click.
1274
- if (activeRename) activeRename.commit();
1275
- clearArmedSessionDelete();
1276
-
1277
- // Skip full rebuild when session data hasn't changed. Server often
1278
- // re-broadcasts session_list after unrelated events (session switches,
1279
- // WS reconnects, presence updates). Each rebuild does innerHTML="" on the
1280
- // entire sidebar list + re-creates all elements + calls refreshIcons().
1281
- // Include search state so filter changes always trigger a rebuild.
1350
+ // Compute the fingerprint FIRST, before touching activeRename at all.
1351
+ // suspend() settles the rename's input (see its LIFECYCLE GUARD comment) —
1352
+ // it must only be called when a real rebuild is about to tear that input
1353
+ // down. Calling it unconditionally (including on a no-op render, where the
1354
+ // input stays live in the DOM untouched) would settle an edit that was
1355
+ // never actually interrupted, silently disabling its real blur/Enter/
1356
+ // Escape handling. This ordering is the fix for the lr-16b88d PEACHES
1357
+ // finding that the original version suspended before knowing whether a
1358
+ // rebuild would run.
1282
1359
  var fp = _fingerprintSessions(cachedSessions, expandedLoopGroups, expandedLoopRuns) +
1283
1360
  "|sq:" + searchQuery + "|sm:" + (searchMatchIds ? searchMatchIds.size : "null");
1284
1361
  if (fp === _sessionListFingerprint) {
1285
- // Still need to refresh mobile sheet and search UI on null calls
1362
+ // No-op render: nothing is going to be torn down, so the active rename's
1363
+ // input stays live in the DOM untouched — leave activeRename alone.
1364
+ // Still need to refresh mobile sheet and search UI on null calls.
1286
1365
  if (refreshMobileChatSheet) refreshMobileChatSheet();
1287
1366
  syncHeaderSearchUi();
1288
1367
  if (updatePageTitle) updatePageTitle();
@@ -1290,6 +1369,33 @@ export function renderSessionList(sessions) {
1290
1369
  }
1291
1370
  _sessionListFingerprint = fp;
1292
1371
 
1372
+ // A real rebuild below (innerHTML = "") detaches the in-progress rename
1373
+ // <input> from the DOM without a real user action. Force-committing it
1374
+ // here (the original design) sent a partial title as a real rename_session
1375
+ // on nearly every broadcast from an actively-streaming session — see
1376
+ // lr-16b88d. Instead, capture the in-progress edit via suspend(), which
1377
+ // both snapshots {value, selectionStart, selectionEnd} AND settles the
1378
+ // rename as suspended (no commit, no cancel, no WS send) so the detach-
1379
+ // induced synthetic blur that fires the instant innerHTML="" runs below is
1380
+ // a no-op on the OLD input. Clear the module-level activeRename slot
1381
+ // immediately after: this rebuild is the only owner of the decision to
1382
+ // re-open it, and no code between here and the re-open below may treat a
1383
+ // stale reference to the just-torn-down rename as still committable.
1384
+ var suspendedRename = null;
1385
+ if (activeRename) {
1386
+ var snapshot = activeRename.suspend();
1387
+ if (snapshot) {
1388
+ suspendedRename = {
1389
+ type: activeRename.type,
1390
+ id: activeRename.id,
1391
+ currentTitle: activeRename.currentTitle,
1392
+ snapshot: snapshot,
1393
+ };
1394
+ }
1395
+ activeRename = null;
1396
+ }
1397
+ clearArmedSessionDelete();
1398
+
1293
1399
  // If mobile chat sheet is open, refresh it
1294
1400
  if (refreshMobileChatSheet) refreshMobileChatSheet();
1295
1401
 
@@ -1414,6 +1520,20 @@ export function renderSessionList(sessions) {
1414
1520
  // no-op when schedules are outside the 3-minute window or the timer is
1415
1521
  // already running, so calling it here is safe and low-cost.
1416
1522
  startCountdownTimer();
1523
+
1524
+ // Re-open the in-progress rename this rebuild just tore down, restoring
1525
+ // the typed value + caret (lr-16b88d). If the target session/loop no
1526
+ // longer exists post-rebuild (deleted, or filtered out by a new search),
1527
+ // startInlineRename()/startLoopInlineRename() find no matching element and
1528
+ // no-op, and activeRename is left null — the edit is silently dropped in
1529
+ // that case, but it was already unaddressable, not force-committed.
1530
+ if (suspendedRename) {
1531
+ if (suspendedRename.type === "loop") {
1532
+ startLoopInlineRename(suspendedRename.id, suspendedRename.currentTitle, suspendedRename.snapshot);
1533
+ } else {
1534
+ startInlineRename(suspendedRename.id, suspendedRename.currentTitle, suspendedRename.snapshot);
1535
+ }
1536
+ }
1417
1537
  }
1418
1538
 
1419
1539
  // --- Search results ---
@@ -24,6 +24,16 @@ var inPlanMode = false;
24
24
  var planContent = null;
25
25
  var currentPlanCardEl = null;
26
26
 
27
+ // --- Backgrounded subagent (Task tool) liveness tracking ---
28
+ // lr-255e originally added this (keyed by parentToolId, the same id used for
29
+ // the stop-button dedup guard below) so callers could avoid clearing the
30
+ // "thinking dots" indicator out from under a still-running subagent. lr-66c118
31
+ // removed the last such caller (hasActiveSubagents() had no consumers left
32
+ // once setActivity collapsed to a single optimistic raise site) but the
33
+ // tracking dict itself is still load-bearing for the Stop button UI
34
+ // (initSubagentStop/updateSubagentTaskStatus/markSubagentDone below).
35
+ var activeSubagentToolIds = {};
36
+
27
37
  // --- Todo state ---
28
38
  var todoItems = [];
29
39
  var todoWidgetEl = null;
@@ -345,7 +355,6 @@ export function renderAskUserQuestion(toolId, input) {
345
355
 
346
356
  ctx.addToMessages(container);
347
357
  disableMainInput();
348
- ctx.setActivity(null);
349
358
  maybeScrollToBottom();
350
359
  }
351
360
 
@@ -581,7 +590,6 @@ function renderFormalPermission(requestId, toolName, toolInput, decisionReason)
581
590
 
582
591
  pendingPermissions[requestId] = container;
583
592
  refreshIcons(container);
584
- ctx.setActivity(null);
585
593
  maybeScrollToBottom();
586
594
  }
587
595
 
@@ -688,7 +696,6 @@ function renderPlanPermission(requestId) {
688
696
 
689
697
  pendingPermissions[requestId] = container;
690
698
  refreshIcons(container);
691
- ctx.setActivity(null);
692
699
  maybeScrollToBottom();
693
700
  // Focus the feedback input after render
694
701
  setTimeout(function () { feedbackInput.focus(); }, 50);
@@ -843,7 +850,6 @@ function renderConversationalPermission(requestId, toolName, toolInput, mateId,
843
850
  ctx.addToMessages(container);
844
851
  pendingPermissions[requestId] = container;
845
852
  refreshIcons(container);
846
- ctx.setActivity(null);
847
853
  maybeScrollToBottom();
848
854
  }
849
855
 
@@ -1070,7 +1076,6 @@ export function renderElicitationRequest(msg) {
1070
1076
 
1071
1077
  pendingElicitations[msg.requestId] = container;
1072
1078
  refreshIcons(container);
1073
- ctx.setActivity(null);
1074
1079
  maybeScrollToBottom();
1075
1080
  }
1076
1081
 
@@ -1498,7 +1503,6 @@ export function startThinking() {
1498
1503
  currentThinking = { el: el, fullText: "", startTime: Date.now() };
1499
1504
  refreshIcons(el);
1500
1505
  maybeScrollToBottom();
1501
- ctx.setActivity("thinking");
1502
1506
  return;
1503
1507
  }
1504
1508
 
@@ -1523,7 +1527,6 @@ export function startThinking() {
1523
1527
  maybeScrollToBottom();
1524
1528
  thinkingGroup = { el: el, count: 0, totalDuration: 0 };
1525
1529
  currentThinking = { el: el, fullText: "", startTime: Date.now() };
1526
- ctx.setActivity("thinking");
1527
1530
  }
1528
1531
 
1529
1532
  export function appendThinking(text) {
@@ -1640,7 +1643,6 @@ export function createToolItem(id, name) {
1640
1643
  maybeScrollToBottom();
1641
1644
 
1642
1645
  tools[id] = { el: el, name: name, input: null, done: false, groupId: currentToolGroup.id };
1643
- ctx.setActivity("Running " + name + "...");
1644
1646
  }
1645
1647
 
1646
1648
  export function updateToolExecuting(id, name, input) {
@@ -1670,8 +1672,6 @@ export function updateToolExecuting(id, name, input) {
1670
1672
  })(name, input);
1671
1673
  }
1672
1674
 
1673
- ctx.setActivity(toolActivityText(name, input));
1674
-
1675
1675
  var subtitleText = tool.el.querySelector(".tool-subtitle-text");
1676
1676
  if (subtitleText) subtitleText.textContent = toolActivityText(name, input);
1677
1677
 
@@ -2008,6 +2008,7 @@ export function markAllToolsDone() {
2008
2008
  }
2009
2009
 
2010
2010
  // --- Sub-agent (Task tool) log ---
2011
+
2011
2012
  export function updateSubagentActivity(parentToolId, text) {
2012
2013
  var tool = tools[parentToolId];
2013
2014
  if (!tool || !tool.el) return;
@@ -2024,7 +2025,6 @@ export function updateSubagentActivity(parentToolId, text) {
2024
2025
  tool.el.appendChild(log);
2025
2026
  }
2026
2027
 
2027
- ctx.setActivity(text);
2028
2028
  maybeScrollToBottom();
2029
2029
  }
2030
2030
 
@@ -2058,7 +2058,6 @@ export function addSubagentToolEntry(parentToolId, toolName, toolId, text) {
2058
2058
  // Auto-scroll to latest entry
2059
2059
  log.scrollTop = log.scrollHeight;
2060
2060
 
2061
- ctx.setActivity(text);
2062
2061
  maybeScrollToBottom();
2063
2062
  }
2064
2063
 
@@ -2107,6 +2106,7 @@ export function updateSubagentProgress(parentToolId, usage, lastToolName, summar
2107
2106
  }
2108
2107
 
2109
2108
  export function initSubagentStop(parentToolId, taskId) {
2109
+ activeSubagentToolIds[parentToolId] = true;
2110
2110
  var tool = tools[parentToolId];
2111
2111
  if (!tool || !tool.el) return;
2112
2112
  var header = tool.el.querySelector(".tool-header");
@@ -2124,6 +2124,9 @@ export function initSubagentStop(parentToolId, taskId) {
2124
2124
  }
2125
2125
 
2126
2126
  export function updateSubagentTaskStatus(parentToolId, patch) {
2127
+ if (patch.status === "failed" || patch.status === "killed") {
2128
+ delete activeSubagentToolIds[parentToolId];
2129
+ }
2127
2130
  var tool = tools[parentToolId];
2128
2131
  if (!tool || !tool.el) return;
2129
2132
  if (patch.description) {
@@ -2147,6 +2150,12 @@ export function updateSubagentTaskStatus(parentToolId, patch) {
2147
2150
  }
2148
2151
 
2149
2152
  export function markSubagentDone(parentToolId, status, summary, usage) {
2153
+ delete activeSubagentToolIds[parentToolId];
2154
+ // lr-66c118: the lr-255e hasActiveSubagents()-gated setActivity clear
2155
+ // call is removed — setActivity collapses to ONE optimistic raise
2156
+ // (input.js). activeSubagentToolIds tracking itself is unchanged and
2157
+ // still governs the real per-tool subagent UI below.
2158
+
2150
2159
  var tool = tools[parentToolId];
2151
2160
  if (!tool || !tool.el) return;
2152
2161
 
@@ -2272,6 +2281,7 @@ export function resetToolState() {
2272
2281
  currentToolGroup = null;
2273
2282
  toolGroupCounter = 0;
2274
2283
  toolGroups = {};
2284
+ activeSubagentToolIds = {};
2275
2285
  // NOTE: do NOT reset _lastCumulativeCost here — it must persist across
2276
2286
  // turns so addTurnMeta can compute per-turn deltas. It is only cleared
2277
2287
  // on new conversation via resetTurnMetaCost().