@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
@@ -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 ---
@@ -25,13 +25,13 @@ var planContent = null;
25
25
  var currentPlanCardEl = null;
26
26
 
27
27
  // --- Backgrounded subagent (Task tool) liveness tracking ---
28
- // lr-255e: the parent turn's SDK stream ends with a normal 'result' message
29
- // as soon as a Task tool call is dispatched -- the Task itself keeps running
30
- // as a background child. app-messages.js's 'result' handler unconditionally
31
- // called setActivity(null), which killed the "thinking dots" indicator even
32
- // though a subagent was still actively working. Tracking live subagents here
33
- // (keyed by parentToolId, the same id used for the stop-button dedup guard)
34
- // lets callers ask hasActiveSubagents() before clearing the indicator.
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
35
  var activeSubagentToolIds = {};
36
36
 
37
37
  // --- Todo state ---
@@ -355,7 +355,6 @@ export function renderAskUserQuestion(toolId, input) {
355
355
 
356
356
  ctx.addToMessages(container);
357
357
  disableMainInput();
358
- ctx.setActivity(null);
359
358
  maybeScrollToBottom();
360
359
  }
361
360
 
@@ -591,7 +590,6 @@ function renderFormalPermission(requestId, toolName, toolInput, decisionReason)
591
590
 
592
591
  pendingPermissions[requestId] = container;
593
592
  refreshIcons(container);
594
- ctx.setActivity(null);
595
593
  maybeScrollToBottom();
596
594
  }
597
595
 
@@ -698,7 +696,6 @@ function renderPlanPermission(requestId) {
698
696
 
699
697
  pendingPermissions[requestId] = container;
700
698
  refreshIcons(container);
701
- ctx.setActivity(null);
702
699
  maybeScrollToBottom();
703
700
  // Focus the feedback input after render
704
701
  setTimeout(function () { feedbackInput.focus(); }, 50);
@@ -853,7 +850,6 @@ function renderConversationalPermission(requestId, toolName, toolInput, mateId,
853
850
  ctx.addToMessages(container);
854
851
  pendingPermissions[requestId] = container;
855
852
  refreshIcons(container);
856
- ctx.setActivity(null);
857
853
  maybeScrollToBottom();
858
854
  }
859
855
 
@@ -1080,7 +1076,6 @@ export function renderElicitationRequest(msg) {
1080
1076
 
1081
1077
  pendingElicitations[msg.requestId] = container;
1082
1078
  refreshIcons(container);
1083
- ctx.setActivity(null);
1084
1079
  maybeScrollToBottom();
1085
1080
  }
1086
1081
 
@@ -1508,7 +1503,6 @@ export function startThinking() {
1508
1503
  currentThinking = { el: el, fullText: "", startTime: Date.now() };
1509
1504
  refreshIcons(el);
1510
1505
  maybeScrollToBottom();
1511
- ctx.setActivity("thinking");
1512
1506
  return;
1513
1507
  }
1514
1508
 
@@ -1533,7 +1527,6 @@ export function startThinking() {
1533
1527
  maybeScrollToBottom();
1534
1528
  thinkingGroup = { el: el, count: 0, totalDuration: 0 };
1535
1529
  currentThinking = { el: el, fullText: "", startTime: Date.now() };
1536
- ctx.setActivity("thinking");
1537
1530
  }
1538
1531
 
1539
1532
  export function appendThinking(text) {
@@ -1650,7 +1643,6 @@ export function createToolItem(id, name) {
1650
1643
  maybeScrollToBottom();
1651
1644
 
1652
1645
  tools[id] = { el: el, name: name, input: null, done: false, groupId: currentToolGroup.id };
1653
- ctx.setActivity("Running " + name + "...");
1654
1646
  }
1655
1647
 
1656
1648
  export function updateToolExecuting(id, name, input) {
@@ -1680,8 +1672,6 @@ export function updateToolExecuting(id, name, input) {
1680
1672
  })(name, input);
1681
1673
  }
1682
1674
 
1683
- ctx.setActivity(toolActivityText(name, input));
1684
-
1685
1675
  var subtitleText = tool.el.querySelector(".tool-subtitle-text");
1686
1676
  if (subtitleText) subtitleText.textContent = toolActivityText(name, input);
1687
1677
 
@@ -2019,19 +2009,6 @@ export function markAllToolsDone() {
2019
2009
 
2020
2010
  // --- Sub-agent (Task tool) log ---
2021
2011
 
2022
- // lr-255e: whether any backgrounded Task subagent is still running for the
2023
- // current session. Callers (e.g. app-messages.js's 'result' handler) use
2024
- // this to decide whether it's safe to clear the "thinking dots" indicator —
2025
- // the parent turn's own stream can end while a dispatched subagent keeps
2026
- // working, and the indicator must stay up until the LAST live subagent
2027
- // actually finishes.
2028
- export function hasActiveSubagents() {
2029
- for (var id in activeSubagentToolIds) {
2030
- if (activeSubagentToolIds.hasOwnProperty(id)) return true;
2031
- }
2032
- return false;
2033
- }
2034
-
2035
2012
  export function updateSubagentActivity(parentToolId, text) {
2036
2013
  var tool = tools[parentToolId];
2037
2014
  if (!tool || !tool.el) return;
@@ -2048,7 +2025,6 @@ export function updateSubagentActivity(parentToolId, text) {
2048
2025
  tool.el.appendChild(log);
2049
2026
  }
2050
2027
 
2051
- ctx.setActivity(text);
2052
2028
  maybeScrollToBottom();
2053
2029
  }
2054
2030
 
@@ -2082,7 +2058,6 @@ export function addSubagentToolEntry(parentToolId, toolName, toolId, text) {
2082
2058
  // Auto-scroll to latest entry
2083
2059
  log.scrollTop = log.scrollHeight;
2084
2060
 
2085
- ctx.setActivity(text);
2086
2061
  maybeScrollToBottom();
2087
2062
  }
2088
2063
 
@@ -2176,13 +2151,10 @@ export function updateSubagentTaskStatus(parentToolId, patch) {
2176
2151
 
2177
2152
  export function markSubagentDone(parentToolId, status, summary, usage) {
2178
2153
  delete activeSubagentToolIds[parentToolId];
2179
- // lr-255e: the parent turn's 'result' already fired (and, per hasActiveSubagents(),
2180
- // may have skipped clearing the indicator because this subagent was still live).
2181
- // Once the last live subagent finishes, clear the indicator here too so it
2182
- // doesn't linger until some unrelated later message happens to null it out.
2183
- if (!hasActiveSubagents()) {
2184
- ctx.setActivity(null);
2185
- }
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.
2186
2158
 
2187
2159
  var tool = tools[parentToolId];
2188
2160
  if (!tool || !tool.el) return;