@clagentic/console 1.12.0-beta.2 → 1.12.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSES/README.md +5 -0
  2. package/bin/cli.js +4 -2
  3. package/lib/agent-roster-ws.js +84 -0
  4. package/lib/agent-roster.js +312 -0
  5. package/lib/auth-required-notify.js +42 -0
  6. package/lib/build-sha.json +2 -2
  7. package/lib/build-update-notify.js +45 -0
  8. package/lib/build-update-offer.js +3 -4
  9. package/lib/build-update-standing.js +34 -14
  10. package/lib/cli/session-subcommands.js +26 -8
  11. package/lib/client-address.js +44 -0
  12. package/lib/daemon.js +25 -10
  13. package/lib/idle-compaction-setting.js +203 -0
  14. package/lib/mcp-bridge-credential.js +41 -0
  15. package/lib/notification-prefs.js +16 -22
  16. package/lib/notify/core.js +53 -18
  17. package/lib/notify/payload.js +2 -3
  18. package/lib/notify/type-registry.js +17 -0
  19. package/lib/notify/types.js +38 -1
  20. package/lib/outbound-access.js +12 -1
  21. package/lib/outbound-entry.js +8 -1
  22. package/lib/project-connection.js +9 -8
  23. package/lib/project-filesystem.js +23 -0
  24. package/lib/project-loop.js +16 -19
  25. package/lib/project-notifications.js +68 -7
  26. package/lib/project-sessions.js +9 -0
  27. package/lib/project-user-mention.js +22 -34
  28. package/lib/project-user-message.js +208 -4
  29. package/lib/project-user-shell.js +298 -0
  30. package/lib/project.js +26 -4
  31. package/lib/prompt-answer.js +145 -0
  32. package/lib/prompt-expiry.js +50 -0
  33. package/lib/prompt-registry.js +24 -1
  34. package/lib/prompt-source.js +16 -0
  35. package/lib/public/app.js +31 -2
  36. package/lib/public/css/agent-messages.css +96 -0
  37. package/lib/public/css/agent-roster.css +93 -0
  38. package/lib/public/css/diagnostics.css +1 -1
  39. package/lib/public/css/input.css +20 -141
  40. package/lib/public/css/login-panel.css +73 -0
  41. package/lib/public/css/menus.css +2 -2
  42. package/lib/public/css/sidebar.css +11 -0
  43. package/lib/public/css/team-panel.css +1 -6
  44. package/lib/public/css/team-view.css +101 -0
  45. package/lib/public/css/title-bar.css +10 -0
  46. package/lib/public/css/user-shell.css +144 -0
  47. package/lib/public/index.html +41 -7
  48. package/lib/public/modules/agent-avatar-picker.js +162 -0
  49. package/lib/public/modules/agent-avatar.js +153 -0
  50. package/lib/public/modules/agent-messages.js +285 -0
  51. package/lib/public/modules/agent-roster.js +157 -0
  52. package/lib/public/modules/app-connection.js +12 -0
  53. package/lib/public/modules/app-messages.js +55 -16
  54. package/lib/public/modules/app-notifications.js +59 -29
  55. package/lib/public/modules/app-panels.js +26 -3
  56. package/lib/public/modules/app-rate-limit.js +8 -165
  57. package/lib/public/modules/app-rendering.js +22 -7
  58. package/lib/public/modules/collapsible-text.js +33 -18
  59. package/lib/public/modules/compaction-state.js +34 -0
  60. package/lib/public/modules/custom-icons.js +23 -5
  61. package/lib/public/modules/diagnostics.js +52 -55
  62. package/lib/public/modules/injected-identity.js +24 -21
  63. package/lib/public/modules/input.js +176 -15
  64. package/lib/public/modules/login-panel.js +136 -0
  65. package/lib/public/modules/login-parser.js +73 -0
  66. package/lib/public/modules/login-tab.js +66 -0
  67. package/lib/public/modules/notifications.js +9 -1
  68. package/lib/public/modules/notify-client.js +114 -21
  69. package/lib/public/modules/pending-term-request.js +30 -0
  70. package/lib/public/modules/project-icon.js +22 -2
  71. package/lib/public/modules/queued-button.js +11 -0
  72. package/lib/public/modules/scheduled-input-actions.js +12 -4
  73. package/lib/public/modules/scheduled-outbox.js +230 -0
  74. package/lib/public/modules/send-now.js +200 -0
  75. package/lib/public/modules/server-settings.js +47 -1
  76. package/lib/public/modules/shell-card.js +76 -0
  77. package/lib/public/modules/shell-line.js +49 -0
  78. package/lib/public/modules/shell-queue.js +253 -0
  79. package/lib/public/modules/shell-settings-controls.js +76 -0
  80. package/lib/public/modules/sidebar-mobile.js +3 -3
  81. package/lib/public/modules/sidebar-sessions.js +8 -0
  82. package/lib/public/modules/sidebar-users.js +5 -7
  83. package/lib/public/modules/team-panel.js +30 -88
  84. package/lib/public/modules/team-view.js +211 -0
  85. package/lib/public/modules/terminal-links.js +18 -0
  86. package/lib/public/modules/terminal.js +65 -4
  87. package/lib/public/modules/tools.js +19 -0
  88. package/lib/public/modules/user-shell.js +824 -0
  89. package/lib/public/notify-sw-logic.js +35 -83
  90. package/lib/public/notify-target.js +70 -10
  91. package/lib/public/style.css +5 -0
  92. package/lib/public/sw.js +7 -3
  93. package/lib/queued-chat.js +392 -0
  94. package/lib/scheduled-input/ws.js +67 -9
  95. package/lib/sdk-bridge.js +122 -43
  96. package/lib/sdk-message-processor.js +46 -39
  97. package/lib/server-auth.js +6 -4
  98. package/lib/server-dm.js +11 -20
  99. package/lib/server-settings.js +39 -1
  100. package/lib/server.js +83 -19
  101. package/lib/session-directory.js +33 -8
  102. package/lib/session-end.js +97 -0
  103. package/lib/session-input-ipc.js +26 -0
  104. package/lib/session-input.js +176 -9
  105. package/lib/session-resume.js +1 -0
  106. package/lib/session-settings-file.js +53 -0
  107. package/lib/sessions.js +49 -5
  108. package/lib/team-traffic-ws.js +68 -0
  109. package/lib/team-traffic.js +318 -0
  110. package/lib/usage-store.js +7 -0
  111. package/lib/user-shell-settings.js +105 -0
  112. package/lib/ws-schema.js +27 -4
  113. package/lib/yoke/adapters/claude-capabilities.js +2 -0
  114. package/lib/yoke/adapters/claude-vendor.js +6 -0
  115. package/lib/yoke/adapters/claude-worker.js +39 -11
  116. package/lib/yoke/adapters/claude.js +218 -6
  117. package/lib/yoke/adapters/codex-capabilities.js +6 -1
  118. package/lib/yoke/adapters/codex-user-shell.js +265 -0
  119. package/lib/yoke/adapters/codex-vendor.js +7 -0
  120. package/lib/yoke/adapters/codex.js +186 -52
  121. package/lib/yoke/codex-app-server.js +8 -2
  122. package/lib/yoke/interface.js +54 -1
  123. package/lib/yoke/mcp-bridge-server.js +12 -8
  124. package/lib/yoke/registry.js +32 -0
  125. package/lib/yoke/user-shell.js +224 -0
  126. package/package.json +1 -1
  127. package/lib/public/modules/build-notice-gate.js +0 -73
@@ -0,0 +1,157 @@
1
+ // agent-roster.js - the Team view's agent roster: every agent identity the
2
+ // console has seen (a session's agent, a sub-agent a Task or Agent call named,
3
+ // an injected sender), with first and last seen, where it was seen, and an
4
+ // avatar the operator can change.
5
+ //
6
+ // The server (lib/agent-roster.js) owns the roster. It sends agent_roster on
7
+ // connect and on request, limited to the projects this connection may read, and
8
+ // nudges every client with agent_roster_changed after a change; the client then
9
+ // asks again, so the section updates live and a reload or daemon restart rebuilds
10
+ // the same view. Choosing an avatar sends agent_avatar_set; the nudge brings the
11
+ // new roster back, and agent-avatar.js redraws each avatar on the page, not just
12
+ // this section's.
13
+
14
+ import { getWs } from "./ws-ref.js";
15
+ import { registerTeamSection, isSectionContainerShown } from "./team-view.js";
16
+ import { relativeTime } from "./relative-time.js";
17
+ import { setAgentAvatars, refreshAgentAvatars, createAgentAvatar } from "./agent-avatar.js";
18
+ import { buildAvatarPicker } from "./agent-avatar-picker.js";
19
+
20
+ var SECTION_ID = "agent-roster";
21
+ var AVATAR_SIZE = 40;
22
+
23
+ var agents = null;
24
+ var pickerKey = null;
25
+ var failure = null;
26
+ var activeContainer = null;
27
+
28
+ var SOURCE_LABEL = { session: "session agent", subagent: "sub-agent", sender: "sender" };
29
+
30
+ function el(tag, className, text) {
31
+ var node = document.createElement(tag);
32
+ if (className) node.className = className;
33
+ if (text !== undefined && text !== null) node.textContent = text;
34
+ return node;
35
+ }
36
+
37
+ function send(payload) {
38
+ var ws = getWs();
39
+ if (!ws || ws.readyState !== 1) return false;
40
+ ws.send(JSON.stringify(payload));
41
+ return true;
42
+ }
43
+
44
+ export function emptyStateText(list) {
45
+ if (list === null) return "Loading the agent roster.";
46
+ return "No agents seen yet. An agent appears here once it runs a session, is started as a sub-agent, or sends input to a session.";
47
+ }
48
+
49
+ export function placeText(place) {
50
+ var where = [];
51
+ if (place.project) where.push(place.project);
52
+ return (SOURCE_LABEL[place.source] || place.source) + (where.length ? " in " + where.join(", ") : "");
53
+ }
54
+
55
+ function timeText(ts) {
56
+ return ts ? relativeTime(ts) : "";
57
+ }
58
+
59
+ // --- Views ---
60
+
61
+ function choose(key, ref) {
62
+ failure = null;
63
+ send({ type: "agent_avatar_set", key: key, avatar: ref });
64
+ }
65
+
66
+ function renderRow(agent) {
67
+ var open = agent.key === pickerKey;
68
+ var row = el("div", "ar-row" + (open ? " open" : ""));
69
+ row.setAttribute("data-agent-key", agent.key);
70
+
71
+ var head = el("div", "ar-head");
72
+ head.appendChild(createAgentAvatar(agent.key, AVATAR_SIZE, "ar-avatar"));
73
+
74
+ var main = el("div", "ar-main");
75
+ main.appendChild(el("div", "ar-name", agent.key));
76
+ var seen = el("div", "ar-seen");
77
+ seen.appendChild(el("span", "ar-first", "First seen " + timeText(agent.firstSeen)));
78
+ seen.appendChild(el("span", "ar-last", "Last seen " + timeText(agent.lastSeen)));
79
+ main.appendChild(seen);
80
+ var places = el("div", "ar-places");
81
+ (agent.places || []).forEach(function (p) { places.appendChild(el("span", "ar-place", placeText(p))); });
82
+ main.appendChild(places);
83
+ head.appendChild(main);
84
+
85
+ var change = el("button", "ar-change", open ? "Close" : "Change avatar");
86
+ change.setAttribute("type", "button");
87
+ change.addEventListener("click", function () {
88
+ pickerKey = open ? null : agent.key;
89
+ paint();
90
+ });
91
+ head.appendChild(change);
92
+ row.appendChild(head);
93
+
94
+ if (open) {
95
+ row.appendChild(buildAvatarPicker(agent.key, function (ref) { choose(agent.key, ref); }));
96
+ if (failure && failure.key === agent.key) row.appendChild(el("div", "ar-failure", "The avatar could not be saved: " + failure.error + "."));
97
+ }
98
+ return row;
99
+ }
100
+
101
+ function paint() {
102
+ var container = activeContainer;
103
+ if (!container) return;
104
+ container.innerHTML = "";
105
+ var list = agents || [];
106
+ if (!list.length) {
107
+ var empty = el("div", "ar-empty", emptyStateText(agents));
108
+ empty.setAttribute("data-empty", "true");
109
+ container.appendChild(empty);
110
+ return;
111
+ }
112
+ var wrap = el("div", "ar-list");
113
+ list.forEach(function (agent) { wrap.appendChild(renderRow(agent)); });
114
+ container.appendChild(wrap);
115
+ }
116
+
117
+ function renderSection(container) {
118
+ activeContainer = container;
119
+ paint();
120
+ send({ type: "agent_roster_request" });
121
+ }
122
+
123
+ registerTeamSection({ id: SECTION_ID, title: "Agents", render: renderSection });
124
+
125
+ // --- Messages from the server ---
126
+
127
+ // The agents and their avatar choices, without the sighting times that change
128
+ // on every use: while a picker is open, a roster that differs only in times does
129
+ // not redraw it, so a seed being typed is not lost.
130
+ function choicesSignature(list) {
131
+ return JSON.stringify((list || []).map(function (a) { return [a.key, a.avatar || null]; }));
132
+ }
133
+
134
+ export function handleAgentRoster(msg) {
135
+ var before = choicesSignature(agents);
136
+ agents = Array.isArray(msg.agents) ? msg.agents : [];
137
+ setAgentAvatars(agents);
138
+ refreshAgentAvatars();
139
+ if (activeContainer && !isSectionContainerShown(activeContainer)) activeContainer = null;
140
+ if (!activeContainer) return;
141
+ if (pickerKey && before === choicesSignature(agents)) return;
142
+ paint();
143
+ }
144
+
145
+ // The roster changed. The nudge carries no content: this connection asks, and the
146
+ // server answers with only what it may read. Asked whether or not the Team view
147
+ // is open, since every avatar on the page resolves from the answer.
148
+ export function handleAgentRosterChanged() {
149
+ send({ type: "agent_roster_request" });
150
+ }
151
+
152
+ export function handleAgentAvatarSetResult(msg) {
153
+ if (msg.ok) return;
154
+ failure = { key: msg.key, error: msg.error || "unknown error" };
155
+ if (activeContainer && !isSectionContainerShown(activeContainer)) activeContainer = null;
156
+ if (activeContainer) paint();
157
+ }
@@ -15,8 +15,11 @@ import { isHomeHubVisible } from './app-home-hub.js';
15
15
  import { resetTerminals } from './terminal.js';
16
16
  import { closeDmUserPicker } from './sidebar-users.js';
17
17
  import { openDm } from './app-dm.js';
18
+ import { takePendingPeer } from './notify-client.js';
18
19
  import { getPaletteVersion } from './command-palette.js';
19
20
  import { sessionActivity, indicatorClass } from './activity-state.js';
21
+ import { clearScheduledOutboxOnReconnect } from './scheduled-outbox.js';
22
+ import { requestScheduledInputList } from './scheduled-input-actions.js';
20
23
  import { createBuildGuard, showReloadBanner } from './build-guard.js';
21
24
 
22
25
  var reconnectTimer = null;
@@ -197,6 +200,11 @@ export function setStatus(status) {
197
200
  }
198
201
 
199
202
  function onConnected() {
203
+ // A Fire now or Cancel sent before the drop may never be answered: free the
204
+ // rows and ask for the server's list, which redraws what is armed.
205
+ clearScheduledOutboxOnReconnect();
206
+ requestScheduledInputList();
207
+
200
208
  // Flush any extension messages that arrived before WS was ready
201
209
  flushPendingExtMessages();
202
210
 
@@ -216,6 +224,10 @@ function onConnected() {
216
224
 
217
225
  // Session restore is now server-driven (user-presence.json).
218
226
  try { localStorage.removeItem("clagentic-active-dm"); localStorage.removeItem("clay-active-dm"); } catch (e) {}
227
+ // A tapped message notification opened this page before the connection: open
228
+ // its conversation now.
229
+ var pendingPeer = takePendingPeer();
230
+ if (pendingPeer) openDm(pendingPeer);
219
231
 
220
232
  // If the home hub was visible when the connection came up (common on mobile
221
233
  // PWA cold-start where showHomeHub() fires before the WS is open), re-request
@@ -36,6 +36,7 @@ import { handleAgentsList, handleAgentFavoriteToggled } from './agent-picker.js'
36
36
  import { handleProjectAgentsList, requestProjectAgents } from './at-agents.js';
37
37
  import { handleFindInSessionResults } from './session-search.js';
38
38
  import { handleInputSync, autoResize, resetAutoResize, builtinCommands } from './input.js';
39
+ import { compactingFromSessionList } from './compaction-state.js';
39
40
  import { startThinking, appendThinking, stopThinking, resetThinkingGroup, createToolItem, updateToolExecuting, updateToolResult, markAllToolsDone, closeToolGroup, removeToolFromGroup, resetToolState, getTools, getPlanContent, setPlanContent, renderPlanBanner, renderPlanCard, getTodoTools, handleTodoWrite, handleTaskCreate, handleTaskUpdate, applyDeadSessionTodoCompaction, isPlanFilePath, enableMainInput, addTurnMeta, updateSubagentActivity, addSubagentToolEntry, markSubagentDone, initSubagentStop, updateSubagentProgress, updateSubagentTaskStatus, applyPromptMessage, hasPendingPrompts } from './tools.js';
40
41
  import { showDoneNotification, playDoneSound, isNotifAlertEnabled, isNotifSoundEnabled } from './notifications.js';
41
42
  import { handleNotificationPrefs, isSurfaceWanted } from './notification-prefs.js';
@@ -44,8 +45,10 @@ import { isProjectSettingsOpen, refreshProjectSettingsModels, handleInstructions
44
45
  import { updateSettingsModels, updateSettingsStats, updateDaemonConfig, handleSharedEnv, handleSharedEnvSaved, updateSsLiteVisibility } from './server-settings.js';
45
46
  import { handleRenameCustomIconResult } from './custom-icons-settings.js';
46
47
  import { handlePermissionSettings, handlePermissionModeApplied } from './permission-settings.js';
47
- import { handleTermList, handleTermCreated, sendTerminalCommand, handleTermOutput, handleTermResized, handleTermExited, handleTermClosed } from './terminal.js';
48
- import { updateTerminalList, handleContextSourcesState } from './context-sources.js';
48
+ import { handleShellResult, handleUserShellSettings, handleSessionShown, handleHistoryReplayed, handleMessageDelivered, handleQueuedMessageCancelled, handleQueuedMessageTracked, handleQueuedMessageSendNow } from './user-shell.js';
49
+ import { handleTermList, handleTermCreated, sendTerminalCommand, markLoginTerminal, handleTermOutput, handleTermResized, handleTermExited, handleTermClosed } from './terminal.js';
50
+ import { consumePendingTerm } from './pending-term-request.js';
51
+ import { updateTerminalList,handleContextSourcesState } from './context-sources.js';
49
52
  import { handleNotesList, handleNoteCreated, handleNoteUpdated, handleNoteDeleted } from './sticky-notes.js';
50
53
  import { handleSkillInstalled, handleSkillUninstalled } from './skills.js';
51
54
  import { applyVendorRegistry, defaultVendorId } from './vendor-registry.js';
@@ -65,15 +68,18 @@ import { updateProjectList, resetClientState, showUpdateAvailable, handleRemoveP
65
68
  import { updateHistorySentinel, prependOlderHistory } from './app-header.js';
66
69
  import { hideHomeHub, handleHubSchedules, handleHubRecentSessions } from './app-home-hub.js';
67
70
  import { openDm, enterDmMode, exitDmMode, appendDmMessage, showDmTypingIndicator } from './app-dm.js';
71
+ import { failScheduledRequests, completeScheduledRequest } from './scheduled-outbox.js';
68
72
  import { handleRateLimitEvent, updateRateLimitUsage, applyScheduledInputList, handleFastModeState, restoreRateLimitStateForSession, forgetSessionRateLimitState } from './app-rate-limit.js';
69
73
  import { handleRemoteCursorMove, handleRemoteCursorLeave, handleRemoteSelection, clearRemoteCursors } from './app-cursors.js';
70
74
  import { showLoopBanner, updateLoopBanner, updateLoopInputVisibility, updateLoopPendingBanner, showRalphApprovalBar, updateRalphApprovalStatus, openRalphPreviewModal, showExecModal, updateExecModalStatus } from './app-loop-ui.js';
71
75
  import { handleSkillInstallWs } from './app-skills-install.js';
72
76
  import { handleSessionGrants } from './session-grants.js';
73
- import { handleNotificationsState, handleNotificationCreated, handleNotificationDismissed, handleNotificationDismissedAll, showUpdateBanner } from './app-notifications.js';
77
+ import { handleNotificationsState, handleNotificationCreated, handleNotificationDismissed, handleNotificationDismissedAll } from './app-notifications.js';
74
78
  import { handleMentionStart, handleMentionActivity, handleMentionStream, handleMentionDone, handleMentionError, renderMentionUser, renderMentionResponse, renderUserMention } from './mention.js';
75
79
  import { handleTeamState, handleTeamMemberUpdate, handleTeamTaskUpdate, handleTeamMessage as handleTeamMsg, handleTeamGone } from './team-panel.js';
76
- import { addDiagnostic, refreshDiagnostic, retractDiagnostics, settleBuildUpdateRequest } from './diagnostics.js';
80
+ import { handleTeamTraffic, handleTeamTrafficChanged } from './agent-messages.js';
81
+ import { handleAgentRoster, handleAgentRosterChanged, handleAgentAvatarSetResult } from './agent-roster.js';
82
+ import { addDiagnostic, retractDiagnostics, settleBuildUpdateRequest } from './diagnostics.js';
77
83
  import { handleHistoryMeta, handleHistoryDone } from './app-history-replay.js';
78
84
  import { shouldApplyActivityEdge } from './activity-latch.js';
79
85
  import { deriveSessionListProcessing } from './activity-state.js';
@@ -169,7 +175,10 @@ registerHandlers({
169
175
  prependOlderHistory(msg.items, msg.meta);
170
176
  },
171
177
 
172
- history_done: handleHistoryDone,
178
+ history_done: function (msg) {
179
+ handleHistoryDone(msg);
180
+ handleHistoryReplayed();
181
+ },
173
182
 
174
183
  info: function (msg) {
175
184
  if (msg.text && !msg.project && !msg.cwd) {
@@ -202,11 +211,11 @@ registerHandlers({
202
211
  },
203
212
 
204
213
  update_available: function (msg) {
205
- // In multi-user mode, only show update UI to admins
214
+ // The settings button is for the admin who asked; the banner and the push
215
+ // reach admins through the notification core (update_available).
206
216
  checkAdminAccess().then(function (isAdmin) {
207
217
  if (!isAdmin) return;
208
218
  showUpdateAvailable(msg);
209
- showUpdateBanner(msg);
210
219
  });
211
220
  },
212
221
 
@@ -294,6 +303,12 @@ registerHandlers({
294
303
  },
295
304
 
296
305
  permission_settings: handlePermissionSettings,
306
+ shell_result: handleShellResult,
307
+ message_delivered: handleMessageDelivered,
308
+ queued_message_cancelled: handleQueuedMessageCancelled,
309
+ queued_message_tracked: handleQueuedMessageTracked,
310
+ queued_message_send_now: handleQueuedMessageSendNow,
311
+ user_shell_settings: handleUserShellSettings,
297
312
  permission_mode_applied: handlePermissionModeApplied,
298
313
 
299
314
  config_state: function (msg) {
@@ -439,6 +454,8 @@ registerHandlers({
439
454
  // not importable under plain Node (see that function's own doc comment
440
455
  // for why), so leaving this inline would leave only a hand-copied
441
456
  // reimplementation testable, not the shipped code.
457
+ var _compaction = compactingFromSessionList(msg.sessions || [], store.get('activeSessionId'));
458
+ if (_compaction.found) store.set({ sessionCompacting: _compaction.compacting });
442
459
  var _projection = deriveSessionListProcessing(msg.sessions || [], store.get('activeSessionId'));
443
460
  if (_projection.found) {
444
461
  store.set({ processing: _projection.active });
@@ -523,7 +540,7 @@ registerHandlers({
523
540
  // session_switched now always carries msg.isProcessing
524
541
  // (project-connection.js's hydration path previously omitted it —
525
542
  // sessions.js's own switchSession() send already had it).
526
- store.set({ activeSessionId: msg.id, cliSessionId: msg.cliSessionId || null, vendorCapabilities: msg.capabilities || {}, sessionIsProcessing: !!msg.isProcessing });
543
+ store.set({ sessionCompacting: !!msg.compacting, activeSessionId: msg.id, cliSessionId: msg.cliSessionId || null, vendorCapabilities: msg.capabilities || {}, sessionIsProcessing: !!msg.isProcessing });
527
544
  // NOTE: the 'processing' projection itself is applied further down,
528
545
  // AFTER resetClientState() (PEACHES finding 1, lr-5edd64 8th
529
546
  // recurrence) — see the comment down there for why the ordering
@@ -611,6 +628,9 @@ registerHandlers({
611
628
  // Restore draft for incoming session
612
629
  var draft = store.get('sessionDrafts')[store.get('activeSessionId')] || "";
613
630
  inputEl.value = draft;
631
+ // Queued chat of a session left behind, or of a page that was reloaded, comes
632
+ // back to the composer in front of the draft.
633
+ handleSessionShown(inputEl);
614
634
  // Reset the autoResize line-count cache before the rAF so the skip-
615
635
  // guard never freezes the textarea at the outgoing session's height.
616
636
  resetAutoResize();
@@ -651,7 +671,7 @@ registerHandlers({
651
671
  addUserMessage("Execute the following plan. Do NOT re-enter plan mode — just implement it step by step.", msg.images || null, msg.pastes || null, msg.from, msg.fromName);
652
672
  } else {
653
673
  // Injected input names its sender; it never takes the local user's place.
654
- addUserMessage(msg.text, msg.images || null, msg.pastes || null, msg.from, msg.fromName, injectedFromMessage(msg));
674
+ addUserMessage(msg.text, msg.images || null, msg.pastes || null, msg.from, msg.fromName, injectedFromMessage(msg), !!msg.sentMidTurn);
655
675
  }
656
676
  },
657
677
 
@@ -759,7 +779,13 @@ registerHandlers({
759
779
  // transition and pushes a fresh 'context_usage' message (see the 'status'
760
780
  // handler in sdk-message-processor.js), which the context_usage handler
761
781
  // below already applies to the meter.
762
- compacting: function (msg) {},
782
+ // The sidebar follows the compacting flag on the session list entry; this
783
+ // drives the session view's own state for the span the server reports.
784
+ compacting: function (msg) {
785
+ // History replays recorded events; only the live span, or the session list
786
+ // entry, says whether compaction is running now.
787
+ if (!store.get('replayingHistory')) store.set({ sessionCompacting: !!msg.active });
788
+ },
763
789
 
764
790
  thinking_start: function (msg) {
765
791
  removePreThinking();
@@ -976,6 +1002,9 @@ registerHandlers({
976
1002
  // collapses to ONE optimistic raise (input.js) with no manual clears.
977
1003
  error: function (msg) {
978
1004
  removePreThinking();
1005
+ // Only an error that names its request frees a row; any other error is not
1006
+ // about a scheduled request.
1007
+ failScheduledRequests(msg.text, msg.requestId);
979
1008
  addSystemMessage(msg.text, true);
980
1009
  },
981
1010
 
@@ -1020,6 +1049,12 @@ registerHandlers({
1020
1049
  // names the session, which may not be the one on screen (lr-0827ba).
1021
1050
  scheduled_input_list: applyScheduledInputList,
1022
1051
 
1052
+ // The answer to a Fire now or Cancel that carried a requestId: frees the row
1053
+ // that sent it, which a list push cannot do for a recurring schedule.
1054
+ scheduled_request_result: function (msg) {
1055
+ completeScheduledRequest(msg.requestId);
1056
+ },
1057
+
1023
1058
  // The original scheduled-message names, still sent for a browser running an
1024
1059
  // older client; this client takes its state from scheduled_input_list alone.
1025
1060
  scheduled_message_queued: function () {},
@@ -1113,12 +1148,12 @@ registerHandlers({
1113
1148
 
1114
1149
  term_created: function (msg) {
1115
1150
  handleTermCreated(msg);
1116
- if (store.get('pendingTermCommand')) {
1117
- var cmd = store.get('pendingTermCommand');
1118
- store.set({ pendingTermCommand: null });
1151
+ var pending = consumePendingTerm(store, msg);
1152
+ if (pending) {
1153
+ if (pending.vendor) markLoginTerminal(msg.id, pending.vendor);
1119
1154
  // Small delay to let terminal initialize
1120
1155
  setTimeout(function() {
1121
- sendTerminalCommand(cmd);
1156
+ sendTerminalCommand(pending.command);
1122
1157
  }, 300);
1123
1158
  }
1124
1159
  },
@@ -1287,13 +1322,17 @@ registerHandlers({
1287
1322
  team_task_update: handleTeamTaskUpdate,
1288
1323
  team_message: handleTeamMsg,
1289
1324
  team_gone: handleTeamGone,
1325
+ team_traffic: handleTeamTraffic,
1326
+ team_traffic_changed: handleTeamTrafficChanged,
1327
+ agent_roster: handleAgentRoster,
1328
+ agent_roster_changed: handleAgentRosterChanged,
1329
+ agent_avatar_set_result: handleAgentAvatarSetResult,
1290
1330
 
1291
1331
  diagnostic: function (msg) {
1292
1332
  // Diagnostic events from CLI stderr (stage 4/5, lr-8294, epic lr-1a52).
1293
1333
  // Future sources (e.g. settings preflight from stage 5/5 lr-1a26) will
1294
1334
  // also arrive via this same type — the render path must not assume CLI origin.
1295
- if (msg.refresh === true) refreshDiagnostic(msg);
1296
- else addDiagnostic(msg);
1335
+ addDiagnostic(msg);
1297
1336
  },
1298
1337
 
1299
1338
  diagnostic_retract: function (msg) {
@@ -11,12 +11,14 @@ import { getWs } from './ws-ref.js';
11
11
  import { getCachedProjects } from './app-projects.js';
12
12
  import { userAvatarUrl } from './avatar.js';
13
13
  import { openTerminal } from './terminal.js';
14
+ import { newTermRequestId } from './pending-term-request.js';
14
15
  import { askWording } from './prompt-kinds/index.js';
15
16
  import { wirePromptBanner, restoreUnconfirmedBanners, bannerActions } from './prompt-banner.js';
16
17
  import { promptLabelHtml } from './prompt-label.js';
17
18
  import { isSurfaceWanted, shouldChimeForNotification } from './notification-prefs.js';
18
19
  import { playDoneSound, isNotifSoundEnabled } from './notifications.js';
19
- import { initNotifyClient, noteNotificationsState, routeTo, takePendingSession } from './notify-client.js';
20
+ import { initNotifyClient, noteNotificationsState, routeTo, takePendingSession, takePendingPlace, registerPlace } from './notify-client.js';
21
+ import { applyBuildOffer, withdrawBuildOffer, openDiagnosticsPanel } from './diagnostics.js';
20
22
  import '../notify-sw-logic.js';
21
23
 
22
24
  // The server dismisses a prompt's banner once the prompt settles, however it
@@ -29,11 +31,8 @@ var bannerContainer = null;
29
31
  var bellBtn = null;
30
32
  var badgeEl = null;
31
33
 
32
- // --- Update available banner state ---
33
- // Server pushes update_available on an hourly boundary; dismissal is
34
- // per-banner-instance and doesn't need to persist. The next server push
35
- // (next hour) acts as a fresh ping.
36
- var pendingUpdateMsg = null;
34
+ var BUILD_OFFER_TYPE = "build_update_offer";
35
+
37
36
  var activeAuthRequiredMsg = null;
38
37
  var authReminderVisible = false;
39
38
 
@@ -51,6 +50,9 @@ export function initAppNotifications() {
51
50
  document.body.appendChild(bannerContainer);
52
51
 
53
52
  initNotifyClient();
53
+ // The build-update offer's action (the restart button) lives in the
54
+ // diagnostics panel; a tap on its banner or push opens it.
55
+ registerPlace(BUILD_OFFER_TYPE, openDiagnosticsPanel);
54
56
 
55
57
  if (bellBtn) {
56
58
  bellBtn.addEventListener("click", function (e) {
@@ -68,11 +70,8 @@ function showAllBanners() {
68
70
  // Clear existing banners first
69
71
  if (bannerContainer) bannerContainer.innerHTML = "";
70
72
 
71
- // Re-add update banner if present (may be suppressed by recent dismiss)
72
- if (pendingUpdateMsg) showUpdateBanner(pendingUpdateMsg);
73
-
74
73
  for (var i = 0; i < notifications.length; i++) {
75
- showBanner(notifications[i], false);
74
+ showNotificationBanner(notifications[i], false);
76
75
  }
77
76
 
78
77
  if (activeAuthRequiredMsg) showAuthRequiredBanner(activeAuthRequiredMsg);
@@ -95,12 +94,20 @@ function showAllBanners() {
95
94
  // Banner
96
95
  // ========================================================
97
96
 
97
+ // An update notice has its own banner (the "Update now" action); every other
98
+ // notification renders from the generic one.
99
+ function showNotificationBanner(notif, autoDismissMs) {
100
+ if (notif.type === "update_available") showUpdateBanner({ version: notif.meta && notif.meta.version }, notif.id);
101
+ else showBanner(notif, autoDismissMs);
102
+ }
103
+
98
104
  function showBanner(notif, autoDismissMs) {
99
105
  if (!bannerContainer) return;
100
106
 
101
107
  var isEmpty = notif.id === "_empty";
102
108
  var isPermission = notif.type === "permission_request" && notif.meta && notif.meta.requestId;
103
109
  var isAuthRequired = notif.type === "auth_required";
110
+ var isBuildOffer = notif.type === BUILD_OFFER_TYPE;
104
111
  var isUserMention = notif.type === "user_mention";
105
112
  var isReminder = notif.type === "permission_reminder";
106
113
  var projectIcon = isEmpty ? null : getProjectIcon(notif.slug);
@@ -177,11 +184,13 @@ function showBanner(notif, autoDismissMs) {
177
184
 
178
185
  if (!isEmpty) {
179
186
  if (!isAuthRequired) {
180
- // Click banner body -> navigate + dismiss
187
+ // Click banner body -> navigate + dismiss. An offer is not declined by
188
+ // looking at it: its tap opens the place the restart lives in, and only
189
+ // its close button declines it.
181
190
  banner.addEventListener("click", function (e) {
182
191
  if (e.target.closest(".notif-banner-close")) return;
183
192
  removeBanner(banner);
184
- dismissNotif(notif.id);
193
+ if (!isBuildOffer) dismissNotif(notif.id);
185
194
  navigateToNotification(notif);
186
195
  });
187
196
  }
@@ -221,7 +230,8 @@ function showBanner(notif, autoDismissMs) {
221
230
  activeAuthRequiredMsg = null;
222
231
  removeBanner(banner);
223
232
  dismissNotif(notif.id);
224
- startLoginCommand(authLoginFor(notif).loginCommand);
233
+ var login = authLoginFor(notif);
234
+ startLoginCommand(login.loginCommand, login.vendor);
225
235
  showLoginReminderBanner();
226
236
  });
227
237
  }
@@ -236,12 +246,15 @@ function showBanner(notif, autoDismissMs) {
236
246
  }
237
247
  }
238
248
 
239
- function startLoginCommand(loginCommand) {
249
+ function startLoginCommand(loginCommand, vendor) {
240
250
  var ws = getWs();
241
251
  if (!ws || ws.readyState !== 1 || !loginCommand) return;
242
252
  var termCommand = loginCommand + "\n";
243
- store.set({ pendingTermCommand: termCommand });
244
- ws.send(JSON.stringify({ type: "term_create", cols: 80, rows: 24 }));
253
+ // The terminal that answers this request id is this login's: marking it
254
+ // makes its output, and only its output, feed the sign-in panel.
255
+ var requestId = newTermRequestId();
256
+ store.set({ pendingTermCommand: termCommand, pendingLoginVendor: vendor || "", pendingTermRequestId: requestId });
257
+ ws.send(JSON.stringify({ type: "term_create", cols: 80, rows: 24, requestId: requestId }));
245
258
  openTerminal();
246
259
  }
247
260
 
@@ -324,8 +337,6 @@ export function showAuthRequiredBanner(msg) {
324
337
  loginCommand: loginCommand,
325
338
  }),
326
339
  });
327
- var existing = bannerContainer.querySelector('[data-auth-banner="true"]');
328
- if (existing) removeBanner(existing);
329
340
  showBanner(activeAuthRequiredMsg, false);
330
341
  }
331
342
 
@@ -419,17 +430,30 @@ export function handleNotificationsState(msg) {
419
430
  unreadCount = msg.unreadCount || 0;
420
431
  updateBadge();
421
432
  dropBannersOfEndedPrompts(msg.livePrompts || null);
433
+ syncBuildOffer(notifications);
422
434
  noteNotificationsState(notifications, msg.livePrompts);
423
435
 
424
436
  // A route waiting on the connection (a project switch, a deep link) opens
425
437
  // its session now that this project's socket is up.
426
438
  var ws = getWs();
439
+ // A cold-start tap on a system notice names its type: open that place.
440
+ var pendingPlace = takePendingPlace();
441
+ if (pendingPlace) routeTo({ slug: null, sessionId: null }, pendingPlace);
427
442
  if (ws && ws.readyState === 1) {
428
443
  var pendingId = takePendingSession();
429
444
  if (pendingId !== null) ws.send(JSON.stringify({ type: "switch_session", id: pendingId }));
430
445
  }
431
446
  }
432
447
 
448
+ // The offer's diagnostics entry follows the server's list, which every connect
449
+ // sends: the held offer is shown, and an entry whose offer is gone (closed while
450
+ // this page was away) is withdrawn, so a dead restart action cannot stay.
451
+ function syncBuildOffer(list) {
452
+ var offer = list.filter(function (n) { return n.type === BUILD_OFFER_TYPE; })[0];
453
+ if (offer) applyBuildOffer(offer);
454
+ else withdrawBuildOffer();
455
+ }
456
+
433
457
  // A prompt banner and a reminder are tied to a live prompt. The server's list
434
458
  // (sent on every connect) and its live-prompt record are the truth: after a
435
459
  // daemon restart no prompt survives, and the dismissals were sent to a
@@ -466,6 +490,7 @@ export function handleNotificationCreated(msg) {
466
490
  notifications.unshift(notif);
467
491
  unreadCount = msg.unreadCount;
468
492
  updateBadge();
493
+ if (notif.type === BUILD_OFFER_TYPE) applyBuildOffer(notif);
469
494
 
470
495
  // A banner stays until acted on when the type registry says so (the
471
496
  // notification's persistent flag; lib/notify/types.js), or when it carries
@@ -478,12 +503,14 @@ export function handleNotificationCreated(msg) {
478
503
  // still been added to the list and counted above: only the alert and the
479
504
  // sound are skipped. A sound plays only while the page is hidden, like the
480
505
  // finished turn's own chime.
481
- if (isSurfaceWanted("banner", notif.category)) showBanner(notif, _autoDismiss);
506
+ if (isSurfaceWanted("banner", notif.category)) showNotificationBanner(notif, _autoDismiss);
482
507
  if (shouldChimeForNotification(notif, isNotifSoundEnabled())) playDoneSound();
483
508
  }
484
509
 
485
510
  export function handleNotificationDismissed(msg) {
486
511
  var ids = msg.ids || [];
512
+ var closedOffer = notifications.some(function (n) { return n.type === BUILD_OFFER_TYPE && ids.indexOf(n.id) !== -1; });
513
+ if (closedOffer) withdrawBuildOffer();
487
514
  notifications = notifications.filter(function (n) { return ids.indexOf(n.id) === -1; });
488
515
  unreadCount = msg.unreadCount;
489
516
  updateBadge();
@@ -497,6 +524,7 @@ export function handleNotificationDismissed(msg) {
497
524
  }
498
525
 
499
526
  export function handleNotificationDismissedAll() {
527
+ withdrawBuildOffer();
500
528
  notifications = [];
501
529
  unreadCount = 0;
502
530
  updateBadge();
@@ -524,7 +552,7 @@ function updateBadge() {
524
552
  // The one router (notify-client.js) opens the notification's project and
525
553
  // session; the slug is part of the target, as session ids repeat across projects.
526
554
  function navigateToNotification(notif) {
527
- routeTo({ slug: notif.slug, sessionId: notif.sessionId, requestId: notif.meta && notif.meta.requestId });
555
+ routeTo({ slug: notif.slug, sessionId: notif.sessionId, requestId: notif.meta && notif.meta.requestId, peerId: notif.peerId }, notif.type);
528
556
  }
529
557
 
530
558
  // Build the sender avatar URL for a user_mention notification banner.
@@ -555,21 +583,16 @@ function buildUserMentionAvatarSrc(notif) {
555
583
  // Update available banner
556
584
  // ========================================================
557
585
 
558
- export function showUpdateBanner(msg) {
586
+ function showUpdateBanner(msg, notifId) {
559
587
  if (!msg || !msg.version) return;
560
- pendingUpdateMsg = msg;
561
588
  if (!bannerContainer) return;
562
589
 
563
- // Remove any existing update banner
564
- var existing = bannerContainer.querySelector('[data-notif-id="_update"]');
565
- if (existing) removeBanner(existing);
566
-
567
590
  var isHeadless = store.get('isHeadlessMode');
568
591
  var updTag = msg.version.indexOf("-beta") !== -1 ? "beta" : "latest";
569
592
 
570
593
  var banner = document.createElement("div");
571
594
  banner.className = "notif-banner notif-banner-update";
572
- banner.setAttribute("data-notif-id", "_update");
595
+ banner.setAttribute("data-notif-id", notifId || "_update");
573
596
 
574
597
  var actionsHtml = '';
575
598
  if (!isHeadless) {
@@ -598,6 +621,12 @@ export function showUpdateBanner(msg) {
598
621
  banner.classList.add("show");
599
622
  });
600
623
 
624
+ // A tap on the notice opens the update UI, like a tap on its push.
625
+ banner.addEventListener("click", function (e) {
626
+ if (e.target.closest("button")) return;
627
+ routeTo({ slug: null, sessionId: null }, "update_available");
628
+ });
629
+
601
630
  // "Update now" button
602
631
  var updateBtn = banner.querySelector(".notif-banner-update-now");
603
632
  if (updateBtn) {
@@ -612,12 +641,13 @@ export function showUpdateBanner(msg) {
612
641
  });
613
642
  }
614
643
 
615
- // Close button -> dismiss. No local throttle; the server pushes a new
616
- // update_available on the next hour boundary, which re-shows naturally.
644
+ // Close button -> dismiss. No local throttle; the next hourly check raises
645
+ // a new update_available, which re-shows naturally.
617
646
  var closeBtn = banner.querySelector(".notif-banner-close");
618
647
  if (closeBtn) {
619
648
  closeBtn.addEventListener("click", function (e) {
620
649
  e.stopPropagation();
650
+ if (notifId) dismissNotif(notifId);
621
651
  removeBanner(banner);
622
652
  });
623
653
  }