@clagentic/console 1.6.0 → 1.7.0-beta.1

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 (85) hide show
  1. package/bin/cli.js +20 -102
  2. package/deploy/clagentic-console.service +10 -1
  3. package/lib/agents-favorites.js +0 -1
  4. package/lib/agents.js +0 -10
  5. package/lib/cli-sessions.js +0 -12
  6. package/lib/codex-defaults.js +4 -1
  7. package/lib/config.js +0 -8
  8. package/lib/daemon.js +88 -9
  9. package/lib/dm.js +0 -1
  10. package/lib/ipc.js +129 -59
  11. package/lib/loop-handoff.js +5 -1
  12. package/lib/memory-limits.js +214 -36
  13. package/lib/memory-shed.js +207 -0
  14. package/lib/notes.js +0 -20
  15. package/lib/os-users.js +0 -3
  16. package/lib/project-connection.js +31 -5
  17. package/lib/project-external-trigger.js +2 -1
  18. package/lib/project-filesystem.js +18 -11
  19. package/lib/project-knowledge.js +0 -8
  20. package/lib/project-loop.js +162 -9
  21. package/lib/project-sessions.js +87 -21
  22. package/lib/project-user-mention.js +2 -1
  23. package/lib/project-user-message.js +16 -5
  24. package/lib/project.js +14 -25
  25. package/lib/public/app.js +1 -2
  26. package/lib/public/css/channel-layout.css +25 -158
  27. package/lib/public/css/diagnostics.css +17 -1
  28. package/lib/public/css/icon-strip.css +1 -32
  29. package/lib/public/css/input.css +0 -56
  30. package/lib/public/css/loop.css +94 -0
  31. package/lib/public/css/messages.css +23 -4
  32. package/lib/public/css/mobile-nav.css +0 -124
  33. package/lib/public/index.html +11 -11
  34. package/lib/public/modules/app-connection.js +2 -1
  35. package/lib/public/modules/app-favicon.js +1 -1
  36. package/lib/public/modules/app-loop-ui.js +140 -4
  37. package/lib/public/modules/app-messages.js +17 -11
  38. package/lib/public/modules/app-projects.js +1 -1
  39. package/lib/public/modules/custom-icons.js +15 -1
  40. package/lib/public/modules/dom-refs.js +1 -2
  41. package/lib/public/modules/emoji-picker.js +6 -1
  42. package/lib/public/modules/filebrowser.js +33 -9
  43. package/lib/public/modules/input.js +39 -0
  44. package/lib/public/modules/scheduler.js +20 -6
  45. package/lib/public/modules/sidebar-mobile.js +0 -64
  46. package/lib/public/modules/sidebar-projects.js +90 -25
  47. package/lib/public/modules/sidebar-sessions.js +80 -13
  48. package/lib/public/modules/stt.js +2 -6
  49. package/lib/public/modules/tool-palette.js +0 -1
  50. package/lib/public/modules/tools.js +2 -6
  51. package/lib/public/style.css +0 -1
  52. package/lib/scheduler.js +0 -1
  53. package/lib/sdk-bridge.js +126 -194
  54. package/lib/sdk-message-processor.js +24 -9
  55. package/lib/sdk-permission-ownership.js +51 -0
  56. package/lib/server-auth.js +25 -18
  57. package/lib/server-dm.js +1 -1
  58. package/lib/server-skills.js +9 -1
  59. package/lib/server.js +18 -3
  60. package/lib/session-search.js +4 -299
  61. package/lib/sessions.js +467 -82
  62. package/lib/smtp.js +0 -15
  63. package/lib/user-presence.js +0 -12
  64. package/lib/users-preferences.js +2 -2
  65. package/lib/users.js +0 -5
  66. package/lib/utils.js +56 -0
  67. package/lib/ws-schema.js +3 -14
  68. package/lib/yoke/adapters/codex.js +96 -10
  69. package/lib/yoke/codex-local-image.js +79 -0
  70. package/package.json +1 -1
  71. package/scripts/postinstall.js +16 -11
  72. package/lib/ask-user-mcp-server.js +0 -121
  73. package/lib/project-memory.js +0 -39
  74. package/lib/public/console-icon.png +0 -0
  75. package/lib/public/css/debate.css +0 -1610
  76. package/lib/public/favicon-banded-32.png +0 -0
  77. package/lib/public/favicon-dark.svg +0 -32
  78. package/lib/public/favicon.svg +0 -32
  79. package/lib/public/icon-banded-96.png +0 -0
  80. package/lib/public/icons/email/gmail.svg +0 -7
  81. package/lib/public/icons/email/outlook.svg +0 -35
  82. package/lib/public/icons/email/yahoo.svg +0 -1
  83. package/lib/public/modules/events.js +0 -21
  84. package/lib/public/modules/state.js +0 -3
  85. package/lib/sdk-worker.js +0 -730
@@ -1079,88 +1079,6 @@
1079
1079
  gap: 6px;
1080
1080
  }
1081
1081
 
1082
- /* --- Mate profile sheet --- */
1083
- .mate-profile-header {
1084
- display: flex;
1085
- align-items: center;
1086
- gap: 12px;
1087
- padding: 16px 16px 12px;
1088
- }
1089
-
1090
- .mate-profile-avatar {
1091
- width: 40px;
1092
- height: 40px;
1093
- border-radius: 50%;
1094
- flex-shrink: 0;
1095
- object-fit: cover;
1096
- border: 2px solid rgba(255, 255, 255, 0.2);
1097
- }
1098
-
1099
- .mate-profile-info {
1100
- flex: 1;
1101
- min-width: 0;
1102
- }
1103
-
1104
- .mate-profile-name {
1105
- font-size: 17px;
1106
- font-weight: 600;
1107
- color: var(--text);
1108
- white-space: nowrap;
1109
- overflow: hidden;
1110
- text-overflow: ellipsis;
1111
- }
1112
-
1113
- .mate-profile-desc {
1114
- font-size: 13px;
1115
- color: var(--text-muted);
1116
- margin-top: 2px;
1117
- white-space: nowrap;
1118
- overflow: hidden;
1119
- text-overflow: ellipsis;
1120
- }
1121
-
1122
- .mate-profile-action {
1123
- display: flex;
1124
- align-items: center;
1125
- gap: 12px;
1126
- width: 100%;
1127
- min-height: 48px;
1128
- padding: 12px 16px;
1129
- background: none;
1130
- border: none;
1131
- border-radius: 10px;
1132
- color: var(--text-secondary);
1133
- font-family: "Pretendard", system-ui, sans-serif;
1134
- font-size: 15px;
1135
- cursor: pointer;
1136
- text-align: left;
1137
- touch-action: manipulation;
1138
- -webkit-tap-highlight-color: transparent;
1139
- transition: background 0.15s;
1140
- }
1141
-
1142
- .mate-profile-action:active {
1143
- background: rgba(var(--overlay-rgb), 0.06);
1144
- }
1145
-
1146
- .mate-profile-action .lucide {
1147
- width: 20px;
1148
- height: 20px;
1149
- color: var(--text-muted);
1150
- flex-shrink: 0;
1151
- }
1152
-
1153
- .mate-profile-action-count {
1154
- margin-left: auto;
1155
- font-size: 12px;
1156
- font-weight: 600;
1157
- color: var(--text-dimmer);
1158
- background: rgba(var(--overlay-rgb), 0.06);
1159
- padding: 2px 8px;
1160
- border-radius: 8px;
1161
- flex-shrink: 0;
1162
- }
1163
-
1164
1082
  /* --- More sheet menu items --- */
1165
1083
  .mobile-more-item {
1166
1084
  display: flex;
@@ -1311,46 +1229,4 @@
1311
1229
  margin-left: auto;
1312
1230
  }
1313
1231
 
1314
- /* ---- Mobile mate DM: force bubble layout for user messages ---- */
1315
- body.mate-dm-active .msg-user {
1316
- display: flex !important;
1317
- flex-direction: column !important;
1318
- align-items: flex-end !important;
1319
- gap: initial !important;
1320
- max-width: 100% !important;
1321
- padding: 0 20px !important;
1322
- margin: 0 0 8px !important;
1323
- border-radius: initial !important;
1324
- justify-content: initial !important;
1325
- }
1326
- body.mate-dm-active .msg-user .dm-bubble-avatar-me {
1327
- display: none !important;
1328
- }
1329
- body.mate-dm-active .msg-user .dm-bubble-content {
1330
- display: flex !important;
1331
- flex-direction: column !important;
1332
- align-items: flex-end !important;
1333
- flex: initial !important;
1334
- width: 100% !important;
1335
- }
1336
- body.mate-dm-active .msg-user .dm-bubble-header {
1337
- display: none !important;
1338
- }
1339
- body.mate-dm-active .msg-user .bubble {
1340
- background: var(--user-bubble) !important;
1341
- border-radius: 20px 20px 4px 20px !important;
1342
- padding: 12px 18px !important;
1343
- max-width: 85% !important;
1344
- width: fit-content !important;
1345
- font-size: 15px !important;
1346
- line-height: 1.55 !important;
1347
- white-space: pre-wrap !important;
1348
- word-wrap: break-word !important;
1349
- }
1350
- body.mate-dm-active .msg-user .msg-actions {
1351
- display: flex !important;
1352
- }
1353
- body.mate-dm-active .msg-user:hover {
1354
- background: initial !important;
1355
- }
1356
1232
  }
@@ -27,18 +27,18 @@
27
27
  <style>
28
28
  @media(max-width:768px){
29
29
  /* User messages: vertical stack, avatar on top, right-aligned */
30
- body.wide-view:not(.mate-dm-active) .msg-user{flex-direction:column!important;align-items:flex-end!important;gap:4px!important;max-width:100%!important;padding:0 16px!important;margin:0 0 8px!important;justify-content:initial!important}
31
- body.wide-view:not(.mate-dm-active) .msg-user .dm-bubble-avatar-me{order:-1!important}
32
- body.wide-view:not(.mate-dm-active) .msg-user .dm-bubble-content{display:flex!important;flex-direction:column!important;align-items:flex-end!important;width:100%!important;flex:initial!important}
33
- body.wide-view:not(.mate-dm-active) .msg-user .bubble{background:var(--user-bubble)!important;border-radius:20px 20px 4px 20px!important;padding:12px 18px!important;max-width:85%!important;width:fit-content!important;font-size:15px!important;line-height:1.55!important;white-space:pre-wrap!important;word-wrap:break-word!important}
34
- body.wide-view:not(.mate-dm-active) .msg-user:hover{background:initial!important}
30
+ body.wide-view .msg-user{flex-direction:column!important;align-items:flex-end!important;gap:4px!important;max-width:100%!important;padding:0 16px!important;margin:0 0 8px!important;justify-content:initial!important}
31
+ body.wide-view .msg-user .dm-bubble-avatar-me{order:-1!important}
32
+ body.wide-view .msg-user .dm-bubble-content{display:flex!important;flex-direction:column!important;align-items:flex-end!important;width:100%!important;flex:initial!important}
33
+ body.wide-view .msg-user .bubble{background:var(--user-bubble)!important;border-radius:20px 20px 4px 20px!important;padding:12px 18px!important;max-width:85%!important;width:fit-content!important;font-size:15px!important;line-height:1.55!important;white-space:pre-wrap!important;word-wrap:break-word!important}
34
+ body.wide-view .msg-user:hover{background:initial!important}
35
35
  /* Assistant messages: row (avatar left), keep channel style */
36
- body.wide-view:not(.mate-dm-active) .msg-assistant{max-width:100%!important;padding:4px 16px!important;margin:0 0 12px!important}
37
- body.wide-view:not(.mate-dm-active) .msg-assistant .md-content{background:initial!important;border-radius:initial!important;padding:initial!important}
38
- body.wide-view:not(.mate-dm-active) .thinking-item,
39
- body.wide-view:not(.mate-dm-active) .tool-item,
40
- body.wide-view:not(.mate-dm-active) .tool-group{max-width:100%!important}
41
- body.wide-view:not(.mate-dm-active) .turn-meta{max-width:100%!important}
36
+ body.wide-view .msg-assistant{max-width:100%!important;padding:4px 16px!important;margin:0 0 12px!important}
37
+ body.wide-view .msg-assistant .md-content{background:initial!important;border-radius:initial!important;padding:initial!important}
38
+ body.wide-view .thinking-item,
39
+ body.wide-view .tool-item,
40
+ body.wide-view .tool-group{max-width:100%!important}
41
+ body.wide-view .turn-meta{max-width:100%!important}
42
42
  }
43
43
  </style>
44
44
  </head>
@@ -158,7 +158,7 @@ function onConnected() {
158
158
 
159
159
  export function connect() {
160
160
  var ws = getWs();
161
- if (ws) { ws.onclose = null; ws.close(); }
161
+ if (ws) { ws.onclose = null; ws.onmessage = null; ws.onerror = null; ws.close(); }
162
162
  if (connectTimeoutId) { clearTimeout(connectTimeoutId); connectTimeoutId = null; }
163
163
 
164
164
  var protocol = location.protocol === "https:" ? "wss:" : "ws:";
@@ -170,6 +170,7 @@ export function connect() {
170
170
  if (!store.get('connected')) {
171
171
  newWs.onclose = null;
172
172
  newWs.onerror = null;
173
+ newWs.onmessage = null;
173
174
  newWs.close();
174
175
  connect();
175
176
  }
@@ -167,7 +167,7 @@ export function blinkSessionDot(sessionId) {
167
167
  export function updateCrossProjectBlink() {
168
168
  if (crossProjectBlinkTimer) { clearTimeout(crossProjectBlinkTimer); crossProjectBlinkTimer = null; }
169
169
  function doBlink() {
170
- var dots = document.querySelectorAll("#icon-strip-projects .icon-strip-item:not(.active) .icon-strip-status.processing, #icon-strip-projects .icon-strip-wt-item:not(.active) .icon-strip-status.processing, #icon-strip-users .icon-strip-mate:not(.active) .icon-strip-status.processing");
170
+ var dots = document.querySelectorAll("#icon-strip-projects .icon-strip-item:not(.active) .icon-strip-status.processing, #icon-strip-projects .icon-strip-wt-item:not(.active) .icon-strip-status.processing");
171
171
  // Also blink mobile chat chip dots (same icon-strip-status class inside chips)
172
172
  var mobileDots = document.querySelectorAll(".mobile-chat-chip .icon-strip-status.processing");
173
173
  var allDots = [];
@@ -156,13 +156,27 @@ function sendLoopStart() {
156
156
  // Loop UI (exported)
157
157
  // ========================================================
158
158
 
159
+ // lr-e31b: An active (non-crafting) loop iteration session used to hide the
160
+ // composer outright, leaving no way for a human to get a message into a
161
+ // running loop. Loop iterations are single-turn SDK sessions whose input
162
+ // stream is closed immediately after the first push (see the comment in
163
+ // project-loop.js runNextIteration()), so a live message cannot be injected
164
+ // into the in-flight turn — it is queued and delivered at the next
165
+ // iteration boundary instead. The composer stays visible and enabled;
166
+ // input.js routes the send through `loop_message` while loopQueueMode is set.
159
167
  export function updateLoopInputVisibility(loop) {
160
168
  var inputArea = document.getElementById("input-area");
161
169
  if (!inputArea) return;
162
- if (loop && loop.active && loop.role !== "crafting") {
163
- inputArea.style.display = "none";
164
- } else {
165
- inputArea.style.display = "";
170
+ inputArea.style.display = "";
171
+ var queueMode = !!(loop && loop.active && loop.role !== "crafting");
172
+ store.set({ loopQueueMode: queueMode });
173
+ var inputEl = document.getElementById("input");
174
+ if (inputEl) {
175
+ if (queueMode) {
176
+ inputEl.placeholder = "Message queues for the next loop iteration…";
177
+ } else if (inputEl.placeholder.indexOf("queues for the next loop iteration") !== -1) {
178
+ inputEl.placeholder = "Message Claude Code...";
179
+ }
166
180
  }
167
181
  }
168
182
 
@@ -281,6 +295,7 @@ export function showLoopBanner(show) {
281
295
  }
282
296
  });
283
297
  updateLoopButton();
298
+ updateLoopPendingBanner();
284
299
  }
285
300
 
286
301
  export function updateLoopBanner(iteration, maxIterations, phase) {
@@ -299,6 +314,127 @@ export function updateLoopBanner(iteration, maxIterations, phase) {
299
314
  statusEl.textContent = text;
300
315
  }
301
316
 
317
+ // lr-e31b: Render (or clear) the "N queued" pill in the running-loop sticky
318
+ // banner so the human can see a message they sent is waiting for the next
319
+ // iteration boundary rather than wondering if it was silently dropped.
320
+ // lr-4a9c: the pill is now clickable — it expands into a per-message list
321
+ // with a dismiss button so a message queued by mistake doesn't have to wait
322
+ // for delivery.
323
+ export function updateLoopPendingBanner() {
324
+ var stickyEl = document.getElementById("ralph-sticky");
325
+ if (!stickyEl || !stickyEl.classList.contains("ralph-running")) return;
326
+ var header = stickyEl.querySelector(".ralph-sticky-header");
327
+ if (!header) return;
328
+ var pending = store.get('loopPendingMessages') || [];
329
+ var pill = document.getElementById("loop-pending-pill");
330
+ if (pending.length === 0) {
331
+ if (pill) pill.remove();
332
+ closeLoopPendingPopover();
333
+ return;
334
+ }
335
+ var label = pending.length + " message" + (pending.length > 1 ? "s" : "") + " queued";
336
+ if (!pill) {
337
+ pill = document.createElement("button");
338
+ pill.id = "loop-pending-pill";
339
+ pill.type = "button";
340
+ pill.className = "ralph-sticky-pending";
341
+ pill.title = "Click to view and remove queued messages";
342
+ var statusEl2 = document.getElementById("loop-status");
343
+ if (statusEl2 && statusEl2.parentNode) {
344
+ statusEl2.parentNode.insertBefore(pill, statusEl2.nextSibling);
345
+ } else {
346
+ header.appendChild(pill);
347
+ }
348
+ pill.addEventListener("click", function (e) {
349
+ e.stopPropagation();
350
+ toggleLoopPendingPopover(pill);
351
+ });
352
+ }
353
+ pill.textContent = label;
354
+
355
+ // Keep an already-open popover's list in sync (e.g. after a remove
356
+ // confirmation or a new message being queued while it's open).
357
+ if (document.getElementById("loop-pending-popover")) {
358
+ renderLoopPendingPopoverList();
359
+ }
360
+ }
361
+
362
+ // ========================================================
363
+ // Pending-message popover: list + per-item dismiss (lr-4a9c)
364
+ // ========================================================
365
+
366
+ function closeLoopPendingPopover() {
367
+ var existing = document.getElementById("loop-pending-popover");
368
+ if (existing) existing.remove();
369
+ }
370
+
371
+ function toggleLoopPendingPopover(anchorEl) {
372
+ var existing = document.getElementById("loop-pending-popover");
373
+ if (existing) {
374
+ closeLoopPendingPopover();
375
+ return;
376
+ }
377
+
378
+ var popover = document.createElement("div");
379
+ popover.id = "loop-pending-popover";
380
+ popover.className = "loop-pending-popover";
381
+ anchorEl.parentNode.appendChild(popover);
382
+ renderLoopPendingPopoverList();
383
+
384
+ // Close on outside click (deferred so this click doesn't immediately close it).
385
+ setTimeout(function () {
386
+ document.addEventListener("click", onOutsideClick);
387
+ }, 0);
388
+ function onOutsideClick(e) {
389
+ var pop = document.getElementById("loop-pending-popover");
390
+ if (!pop) {
391
+ document.removeEventListener("click", onOutsideClick);
392
+ return;
393
+ }
394
+ if (!pop.contains(e.target) && e.target !== anchorEl) {
395
+ closeLoopPendingPopover();
396
+ document.removeEventListener("click", onOutsideClick);
397
+ }
398
+ }
399
+ }
400
+
401
+ function renderLoopPendingPopoverList() {
402
+ var popover = document.getElementById("loop-pending-popover");
403
+ if (!popover) return;
404
+ var pending = store.get('loopPendingMessages') || [];
405
+ if (pending.length === 0) {
406
+ closeLoopPendingPopover();
407
+ return;
408
+ }
409
+
410
+ var html = '<div class="loop-pending-popover-title">Queued for next iteration</div><ul class="loop-pending-list">';
411
+ for (var i = 0; i < pending.length; i++) {
412
+ var m = pending[i];
413
+ var preview = (m.text || "").length > 140 ? m.text.substring(0, 140) + "…" : (m.text || "");
414
+ html += '<li class="loop-pending-item" data-id="' + escapeHtml(m.id || "") + '">' +
415
+ '<span class="loop-pending-item-text">' + escapeHtml(preview) + '</span>' +
416
+ '<button type="button" class="loop-pending-item-remove" title="Remove this queued message">' + iconHtml("x") + '</button>' +
417
+ '</li>';
418
+ }
419
+ html += '</ul>';
420
+ popover.innerHTML = html;
421
+ refreshIcons();
422
+
423
+ var removeBtns = popover.querySelectorAll(".loop-pending-item-remove");
424
+ for (var bi = 0; bi < removeBtns.length; bi++) {
425
+ removeBtns[bi].addEventListener("click", function (e) {
426
+ e.stopPropagation();
427
+ var li = this.closest(".loop-pending-item");
428
+ var id = li && li.getAttribute("data-id");
429
+ if (!id) return;
430
+ var ws = getWs();
431
+ if (ws && ws.readyState === 1) {
432
+ ws.send(JSON.stringify({ type: "loop_message_remove", id: id }));
433
+ }
434
+ });
435
+ }
436
+ }
437
+
302
438
  export function updateRalphBars() {
303
439
  // Task source uses the scheduler panel, not the sticky bar
304
440
  var s = store.snap();
@@ -46,7 +46,7 @@ import { hideHomeHub, handleHubSchedules, handleHubRecentSessions } from './app-
46
46
  import { openDm, enterDmMode, exitDmMode, appendDmMessage, showDmTypingIndicator } from './app-dm.js';
47
47
  import { handleRateLimitEvent, updateRateLimitUsage, addScheduledMessageBubble, removeScheduledMessageBubble, handleFastModeState } from './app-rate-limit.js';
48
48
  import { handleRemoteCursorMove, handleRemoteCursorLeave, handleRemoteSelection, clearRemoteCursors } from './app-cursors.js';
49
- import { showLoopBanner, updateLoopBanner, updateLoopInputVisibility, showRalphApprovalBar, updateRalphApprovalStatus, openRalphPreviewModal, showExecModal, updateExecModalStatus } from './app-loop-ui.js';
49
+ import { showLoopBanner, updateLoopBanner, updateLoopInputVisibility, updateLoopPendingBanner, showRalphApprovalBar, updateRalphApprovalStatus, openRalphPreviewModal, showExecModal, updateExecModalStatus } from './app-loop-ui.js';
50
50
  import { handleSkillInstallWs } from './app-skills-install.js';
51
51
  import { handleNotificationsState, handleNotificationCreated, handleNotificationDismissed, handleNotificationDismissedAll, showUpdateBanner } from './app-notifications.js';
52
52
  import { handleMentionStart, handleMentionActivity, handleMentionStream, handleMentionDone, handleMentionError, renderMentionUser, renderMentionResponse, renderUserMention } from './mention.js';
@@ -1407,11 +1407,10 @@ export function processMessage(msg) {
1407
1407
 
1408
1408
  var _libn = store.get('loopBannerName');
1409
1409
  addSystemMessage((_libn || "Loop") + " iteration #" + msg.iteration + " started", false);
1410
- // Lock input only if the user is currently viewing the loop's coder session.
1411
- if (msg.sessionId && store.get('activeSessionId') === msg.sessionId) {
1412
- inputEl.disabled = true;
1413
- inputEl.placeholder = (_libn || "Loop") + " is running...";
1414
- }
1410
+ // lr-e31b: The composer stays enabled (not locked) while viewing the
1411
+ // loop's own session — updateLoopInputVisibility() already switched
1412
+ // it into queue mode so a human message is queued for the next
1413
+ // iteration boundary rather than dropped or blocked outright.
1415
1414
  break;
1416
1415
 
1417
1416
  case "loop_judging":
@@ -1419,11 +1418,7 @@ export function processMessage(msg) {
1419
1418
  store.set({ loopCurrentSessionId: msg.sessionId || _ljs.loopCurrentSessionId });
1420
1419
  updateLoopBanner(_ljs.loopIteration, _ljs.loopMaxIterations, "judging");
1421
1420
  addSystemMessage("Judging iteration #" + msg.iteration + "...", false);
1422
- // Lock input only if the user is currently viewing the judge session.
1423
- if (msg.sessionId && store.get('activeSessionId') === msg.sessionId) {
1424
- inputEl.disabled = true;
1425
- inputEl.placeholder = (_ljs.loopBannerName || "Loop") + " is judging...";
1426
- }
1421
+ // lr-e31b: composer stays enabled in queue mode (see loop_iteration above).
1427
1422
  break;
1428
1423
 
1429
1424
  case "loop_verdict":
@@ -1457,6 +1452,17 @@ export function processMessage(msg) {
1457
1452
  addSystemMessage((store.get('loopBannerName') || "Loop") + " error: " + msg.text, true);
1458
1453
  break;
1459
1454
 
1455
+ // lr-e31b: server-confirmed queue of human messages awaiting delivery
1456
+ // at the next loop iteration boundary.
1457
+ case "loop_pending_messages":
1458
+ store.set({ loopPendingMessages: msg.messages || [] });
1459
+ updateLoopPendingBanner();
1460
+ break;
1461
+
1462
+ case "loop_message_error":
1463
+ addSystemMessage((store.get('loopBannerName') || "Loop") + ": " + msg.text, true);
1464
+ break;
1465
+
1460
1466
  // --- Ralph Wizard / Crafting ---
1461
1467
  case "ralph_phase":
1462
1468
  var _rps = { ralphPhase: msg.phase || "idle" };
@@ -261,7 +261,7 @@ export function updateProjectList(msg) {
261
261
  if (msg.dmConversations) store.set({ cachedDmConversations: msg.dmConversations });
262
262
  // renderUserStrip is handled by the store subscriber
263
263
  var st2 = store.snap();
264
- if (document.body.classList.contains("mate-dm-active") || document.body.classList.contains("wide-view")) {
264
+ if (document.body.classList.contains("wide-view")) {
265
265
  var refreshedMyUser = st2.cachedAllUsers.find(function (u) { return u.id === st2.myUserId; });
266
266
  if (refreshedMyUser) {
267
267
  document.body.dataset.myDisplayName = refreshedMyUser.displayName || refreshedMyUser.username || "";
@@ -52,6 +52,16 @@ export function fetchCustomIconList() {
52
52
  */
53
53
  export function uploadCustomIcon(slug, file) {
54
54
  return new Promise(function (resolve) {
55
+ // Defense-in-depth (lr-6c9930): FileReader.readAsArrayBuffer(null/undefined)
56
+ // throws synchronously inside the Promise executor rather than firing
57
+ // onerror, so a caller bug that passes a missing file previously left
58
+ // this Promise permanently unresolved — no .then(), no failure toast,
59
+ // upload looked like it did nothing. Reject the bad input explicitly
60
+ // instead of relying on FileReader to fail safely.
61
+ if (!file) {
62
+ resolve({ ok: false, error: "No file selected" });
63
+ return;
64
+ }
55
65
  var reader = new FileReader();
56
66
  reader.onload = function (ev) {
57
67
  fetch("/api/custom-emoji/" + encodeURIComponent(slug), {
@@ -69,7 +79,11 @@ export function uploadCustomIcon(slug, file) {
69
79
  });
70
80
  };
71
81
  reader.onerror = function () { resolve({ ok: false, error: "Failed to read file" }); };
72
- reader.readAsArrayBuffer(file);
82
+ try {
83
+ reader.readAsArrayBuffer(file);
84
+ } catch (e) {
85
+ resolve({ ok: false, error: "Failed to read file" });
86
+ }
73
87
  });
74
88
  }
75
89
 
@@ -16,6 +16,5 @@ export function getSessionListEl() { return ref("session-list"); }
16
16
 
17
17
  export function getStatusDot() {
18
18
  return document.querySelector("#icon-strip-projects .icon-strip-item.active .icon-strip-status") ||
19
- document.querySelector("#icon-strip-projects .icon-strip-wt-item.active .icon-strip-status") ||
20
- document.querySelector("#icon-strip-users .icon-strip-mate.active .icon-strip-status");
19
+ document.querySelector("#icon-strip-projects .icon-strip-wt-item.active .icon-strip-status");
21
20
  }
@@ -273,8 +273,13 @@ export function buildEmojiPicker(opts) {
273
273
  var hasDup = existing.some(function (e) { return e.slug === slug; });
274
274
 
275
275
  function proceed() {
276
+ // Capture pendingFile before hideSlugConfirm() clears it (lr-6c9930)
277
+ // — hideSlugConfirm() nulls pendingFile, so reading it after that
278
+ // call always passes null into uploadCustomIcon(), which then fails
279
+ // silently (see custom-icons.js hardening below).
280
+ var file = pendingFile;
276
281
  hideSlugConfirm();
277
- uploadCustomIcon(slug, pendingFile).then(function (result) {
282
+ uploadCustomIcon(slug, file).then(function (result) {
278
283
  if (!result.ok) {
279
284
  // lr-0847: the picker previously swallowed upload failures here
280
285
  // (bare `return`), so a failed upload looked identical to a
@@ -28,7 +28,7 @@ var inlineDiffActive = false;
28
28
  var gitDiffCache = {}; // hash -> diff text
29
29
  var pendingGitDiff = null; // callback for pending git diff
30
30
  var fileAtCache = {}; // hash -> file content
31
- var pendingFileAt = null; // callback for pending file-at
31
+ var pendingFileAt = null; // { hash, cb } for the in-flight fs_file_at request, or null
32
32
 
33
33
  export function initFileBrowser(_ctx) {
34
34
  ctx = _ctx;
@@ -433,6 +433,8 @@ export function resetFileBrowser() {
433
433
  pendingGitDiff = null;
434
434
  fileAtCache = {};
435
435
  pendingFileAt = null;
436
+ pendingReadPath = null;
437
+ pendingOpenMode = null;
436
438
  // Clear tree UI
437
439
  if (ctx && ctx.fileTreeEl) ctx.fileTreeEl.innerHTML = "";
438
440
  // Hide the file browser panel, show sessions panel
@@ -444,12 +446,13 @@ export function resetFileBrowser() {
444
446
  if (sessionsHeaderContent) sessionsHeaderContent.classList.remove("hidden");
445
447
  }
446
448
 
447
- var pendingOpenMode = null; // { type: "diff", oldStr, newStr } or null
449
+ var pendingOpenMode = null; // { path, type: "diff", oldStr, newStr } or null
450
+ var pendingReadPath = null; // path of the in-flight fs_read request, for correlating the reply
448
451
 
449
452
  export function openFile(filePath, opts) {
450
453
  if (!filePath) return;
451
454
  if (opts && opts.diff) {
452
- pendingOpenMode = { type: "diff", oldStr: opts.diff.oldStr, newStr: opts.diff.newStr };
455
+ pendingOpenMode = { path: filePath, type: "diff", oldStr: opts.diff.oldStr, newStr: opts.diff.newStr };
453
456
  } else {
454
457
  pendingOpenMode = null;
455
458
  }
@@ -525,6 +528,7 @@ function requestDirectory(dirPath) {
525
528
  }
526
529
 
527
530
  function requestFileContent(filePath) {
531
+ pendingReadPath = filePath;
528
532
  if (ctx.ws && ctx.connected) {
529
533
  ctx.ws.send(JSON.stringify({ type: "fs_read", path: filePath }));
530
534
  }
@@ -792,6 +796,12 @@ function restoreExpanded(expandedSet) {
792
796
  }
793
797
 
794
798
  export function handleFsRead(msg) {
799
+ // Correlate against the in-flight request — a reply for a path we're no
800
+ // longer waiting on (e.g. the user opened a different file, or the
801
+ // request raced a fs_watch-triggered handleFileChanged) must be dropped
802
+ // rather than silently applied to whatever is currently open.
803
+ if (msg.path !== pendingReadPath) return;
804
+ pendingReadPath = null;
795
805
  showFileContent(msg);
796
806
  }
797
807
 
@@ -965,8 +975,11 @@ function showFileContent(msg) {
965
975
  sendWatch(msg.path);
966
976
  refreshIcons();
967
977
 
968
- // If opened with a diff request, show full-file split diff in wide mode
969
- if (pendingOpenMode && pendingOpenMode.type === "diff" && currentContent != null) {
978
+ // If opened with a diff request, show full-file split diff in wide mode.
979
+ // Guard against a stale pendingOpenMode meant for a different path (e.g.
980
+ // the diff-open request was superseded by a plain openFile() before the
981
+ // fs_read reply arrived).
982
+ if (pendingOpenMode && pendingOpenMode.path === msg.path && pendingOpenMode.type === "diff" && currentContent != null) {
970
983
  var diffOpts = pendingOpenMode;
971
984
  pendingOpenMode = null;
972
985
  historyVisible = false;
@@ -1200,6 +1213,10 @@ function requestGitDiff(hash, hash2) {
1200
1213
  }
1201
1214
 
1202
1215
  export function handleFileHistory(msg) {
1216
+ // Drop replies for a file that is no longer open — otherwise a slow
1217
+ // fs_file_history_result for the previous file can land after the user
1218
+ // has already switched to a different one and get applied to it.
1219
+ if (msg.path !== currentFilePath) return;
1203
1220
  currentHistoryEntries = msg.entries || [];
1204
1221
  var historyBtn = document.getElementById("file-viewer-history");
1205
1222
 
@@ -1237,8 +1254,12 @@ export function handleFileAt(msg) {
1237
1254
  if (msg.hash && msg.content !== undefined) {
1238
1255
  fileAtCache[msg.hash] = msg.content;
1239
1256
  }
1240
- if (pendingFileAt) {
1241
- var cb = pendingFileAt;
1257
+ // Only resolve the pending callback if this reply matches the hash it is
1258
+ // waiting on — otherwise a reply for an earlier, superseded request (e.g.
1259
+ // the user picked a different compare entry before the first fs_file_at
1260
+ // came back) would resolve the wrong callback with the wrong content.
1261
+ if (pendingFileAt && pendingFileAt.hash === msg.hash) {
1262
+ var cb = pendingFileAt.cb;
1242
1263
  pendingFileAt = null;
1243
1264
  cb(msg);
1244
1265
  }
@@ -1558,8 +1579,11 @@ function resolveEntryContent(entry, cb) {
1558
1579
  cb(fileAtCache[entry.hash]);
1559
1580
  return;
1560
1581
  }
1561
- pendingFileAt = function () {
1562
- cb(fileAtCache[entry.hash] || "");
1582
+ pendingFileAt = {
1583
+ hash: entry.hash,
1584
+ cb: function () {
1585
+ cb(fileAtCache[entry.hash] || "");
1586
+ },
1563
1587
  };
1564
1588
  requestFileAt(entry.hash);
1565
1589
  return;
@@ -201,6 +201,28 @@ export function sendMessage() {
201
201
 
202
202
  var pastes = pendingPastes.map(function (p) { return p.text; });
203
203
 
204
+ // lr-e31b: Viewing an active (non-crafting) loop iteration session — the
205
+ // SDK input stream for that iteration is already closed (single-turn), so
206
+ // the message cannot be injected live. Queue it server-side for delivery
207
+ // at the next iteration boundary instead of sending a normal "message".
208
+ // Images/pastes are not supported on this path (loop_message is text-only
209
+ // server-side) — fold paste text into the message body, drop images.
210
+ if (store.get("loopQueueMode")) {
211
+ var queueText = text;
212
+ if (pastes.length > 0) {
213
+ queueText = queueText ? queueText + "\n\n" + pastes.join("\n\n") : pastes.join("\n\n");
214
+ }
215
+ if (!queueText) return;
216
+ ctx.ws.send(JSON.stringify({ type: "loop_message", text: queueText }));
217
+ ctx.addSystemMessage("Queued for the next loop iteration: " + queueText, false);
218
+ ctx.inputEl.value = "";
219
+ sendInputSync();
220
+ clearPendingImages();
221
+ autoResize();
222
+ ctx.inputEl.focus();
223
+ return;
224
+ }
225
+
204
226
  // Scheduled message: queue message with timer delay
205
227
  if (scheduleDelayMs > 0) {
206
228
  var resetsAt = Date.now() + scheduleDelayMs;
@@ -256,10 +278,24 @@ export function sendMessage() {
256
278
  }
257
279
 
258
280
  var INPUT_MAX_HEIGHT = 120;
281
+ var INPUT_MIN_HEIGHT = 24; // matches #input's CSS min-height (input.css)
259
282
  var autoResizeLastLines = 1;
260
283
  var autoResizeAtMax = false; // true when last measured height hit INPUT_MAX_HEIGHT
261
284
  var autoResizeSoftWrapTick = 0; // throttle the soft-wrap scrollHeight check
262
285
  var autoResizeFrame = null;
286
+ var autoResizeLastGrowth = -1; // last value written to --input-growth, avoids redundant writes
287
+
288
+ // Publish how far the textarea has grown past its single-line height as a
289
+ // CSS var so #new-msg-btn (messages.css) can anchor above the composer
290
+ // instead of colliding with it when the composer expands (lr-4a3d). Runs
291
+ // through the same rAF-batched autoResize() path already used for typing,
292
+ // so this adds no extra observers/listeners.
293
+ function publishComposerGrowth(newH) {
294
+ var growth = Math.max(0, newH - INPUT_MIN_HEIGHT);
295
+ if (growth === autoResizeLastGrowth) return;
296
+ autoResizeLastGrowth = growth;
297
+ document.documentElement.style.setProperty("--input-growth", growth + "px");
298
+ }
263
299
 
264
300
  // Reset the line-count cache so the next autoResize() always measures.
265
301
  // Call before any situation where the textarea content is replaced externally
@@ -273,6 +309,8 @@ export function resetAutoResize() {
273
309
  autoResizeLastLines = -1;
274
310
  autoResizeAtMax = false;
275
311
  autoResizeSoftWrapTick = 0;
312
+ autoResizeLastGrowth = -1;
313
+ publishComposerGrowth(INPUT_MIN_HEIGHT);
276
314
  }
277
315
 
278
316
  export function scheduleAutoResize() {
@@ -334,6 +372,7 @@ export function autoResize() {
334
372
  var newH = Math.min(ctx.inputEl.scrollHeight, INPUT_MAX_HEIGHT);
335
373
  autoResizeAtMax = (newH >= INPUT_MAX_HEIGHT);
336
374
  ctx.inputEl.style.height = newH + "px";
375
+ publishComposerGrowth(newH);
337
376
  }
338
377
 
339
378
  // --- File path extraction from clipboard ---