synabun 2.2.0 → 2.2.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 (166) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +1 -1
  3. package/hooks/claude-code/pre-websearch.mjs +4 -1
  4. package/hooks/claude-code/prompt-submit.mjs +7 -0
  5. package/lib/release-scan.mjs +23 -10
  6. package/lib/virustotal.mjs +143 -39
  7. package/mcp-server/dist/http.d.ts +19 -0
  8. package/mcp-server/dist/http.d.ts.map +1 -1
  9. package/mcp-server/dist/http.js +55 -13
  10. package/mcp-server/dist/http.js.map +1 -1
  11. package/mcp-server/dist/index.d.ts.map +1 -1
  12. package/mcp-server/dist/index.js +14 -9
  13. package/mcp-server/dist/index.js.map +1 -1
  14. package/mcp-server/dist/services/browser-route-flow.d.ts +118 -0
  15. package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -0
  16. package/mcp-server/dist/services/browser-route-flow.js +339 -0
  17. package/mcp-server/dist/services/browser-route-flow.js.map +1 -0
  18. package/mcp-server/dist/services/desktop-client.js +2 -2
  19. package/mcp-server/dist/services/desktop-client.js.map +1 -1
  20. package/mcp-server/dist/services/identity.d.ts +66 -3
  21. package/mcp-server/dist/services/identity.d.ts.map +1 -1
  22. package/mcp-server/dist/services/identity.js +61 -4
  23. package/mcp-server/dist/services/identity.js.map +1 -1
  24. package/mcp-server/dist/services/neural-interface.d.ts +112 -1
  25. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  26. package/mcp-server/dist/services/neural-interface.js +555 -61
  27. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  28. package/mcp-server/dist/tools/bluesky.d.ts +20 -7
  29. package/mcp-server/dist/tools/bluesky.d.ts.map +1 -1
  30. package/mcp-server/dist/tools/bluesky.js +147 -45
  31. package/mcp-server/dist/tools/bluesky.js.map +1 -1
  32. package/mcp-server/dist/tools/browser-advanced.d.ts +11 -2
  33. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  34. package/mcp-server/dist/tools/browser-advanced.js +131 -18
  35. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  36. package/mcp-server/dist/tools/browser-cheatsheet.d.ts +2 -0
  37. package/mcp-server/dist/tools/browser-cheatsheet.d.ts.map +1 -1
  38. package/mcp-server/dist/tools/browser-cheatsheet.js +3 -0
  39. package/mcp-server/dist/tools/browser-cheatsheet.js.map +1 -1
  40. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
  41. package/mcp-server/dist/tools/morelogin.js +4 -2
  42. package/mcp-server/dist/tools/morelogin.js.map +1 -1
  43. package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
  44. package/mcp-server/dist/tools/youtube/helpers.d.ts +1 -0
  45. package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
  46. package/mcp-server/dist/tools/youtube/helpers.js +1 -1
  47. package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
  48. package/mcp-server/package-lock.json +2 -2
  49. package/mcp-server/package.json +1 -1
  50. package/mcp-server/src/http.ts +58 -12
  51. package/mcp-server/src/index.ts +15 -9
  52. package/mcp-server/src/services/browser-route-flow.ts +402 -0
  53. package/mcp-server/src/services/desktop-client.ts +2 -2
  54. package/mcp-server/src/services/identity.ts +80 -4
  55. package/mcp-server/src/services/neural-interface.ts +572 -70
  56. package/mcp-server/src/tools/bluesky.ts +164 -51
  57. package/mcp-server/src/tools/browser-advanced.ts +121 -17
  58. package/mcp-server/src/tools/browser-cheatsheet.ts +3 -0
  59. package/mcp-server/src/tools/morelogin.ts +4 -2
  60. package/mcp-server/src/tools/youtube/helpers.ts +2 -2
  61. package/neural-interface/i18n/en.json +27 -0
  62. package/neural-interface/i18n/pt-BR.json +27 -0
  63. package/neural-interface/lib/assistant-api.js +64 -23
  64. package/neural-interface/lib/assistant-brains/codex.js +6 -1
  65. package/neural-interface/lib/assistant-catalog.js +20 -2
  66. package/neural-interface/lib/assistant-dispatch.js +31 -2
  67. package/neural-interface/lib/assistant-persona.js +1 -0
  68. package/neural-interface/lib/assistant-runtime.js +15 -1
  69. package/neural-interface/lib/assistant-tools.js +10 -1
  70. package/neural-interface/lib/browser-automation-routes.js +84 -0
  71. package/neural-interface/lib/browser-execution.js +16 -3
  72. package/neural-interface/lib/browser-owner.js +48 -0
  73. package/neural-interface/lib/browser-session-close.js +84 -0
  74. package/neural-interface/lib/browser-start-handoff.js +202 -0
  75. package/neural-interface/lib/browser-tool-policy.js +21 -4
  76. package/neural-interface/lib/browser-wedge-retire.js +64 -0
  77. package/neural-interface/lib/claude-agent-bridge.js +36 -1
  78. package/neural-interface/lib/claude-background-hold.js +239 -0
  79. package/neural-interface/lib/exec-loop-command.js +8 -0
  80. package/neural-interface/lib/http-guards.js +11 -6
  81. package/neural-interface/lib/loop-logger.js +6 -1
  82. package/neural-interface/lib/mcp-external-servers.js +64 -13
  83. package/neural-interface/lib/native-loop-providers.js +122 -10
  84. package/neural-interface/lib/native-loop-runtime.js +112 -11
  85. package/neural-interface/lib/opencode-native-boundary.js +155 -21
  86. package/neural-interface/lib/owner-authority.js +113 -37
  87. package/neural-interface/lib/page-session.js +81 -23
  88. package/neural-interface/lib/peer-identity.js +311 -47
  89. package/neural-interface/lib/provider-panel-api-key-auth.js +7 -2
  90. package/neural-interface/lib/pty-host/core.js +36 -0
  91. package/neural-interface/lib/pty-host/protocol.js +2 -0
  92. package/neural-interface/lib/skills/api-v2.js +13 -2
  93. package/neural-interface/lib/skills/creation-api.js +3 -1
  94. package/neural-interface/lib/skills/evals-api.js +5 -1
  95. package/neural-interface/lib/social-write-pacing.js +151 -0
  96. package/neural-interface/lib/terminal-token-redaction.js +293 -0
  97. package/neural-interface/lib/terminal-tokens.js +359 -0
  98. package/neural-interface/lib/worker-mcp-channel.js +45 -10
  99. package/neural-interface/package-lock.json +2 -2
  100. package/neural-interface/package.json +1 -1
  101. package/neural-interface/public/shared/agy/agy-render.js +41 -1
  102. package/neural-interface/public/shared/agy/agy-styles.js +5 -0
  103. package/neural-interface/public/shared/api.js +1 -0
  104. package/neural-interface/public/shared/assistant/asst-api.js +14 -2
  105. package/neural-interface/public/shared/assistant/asst-computer.js +73 -4
  106. package/neural-interface/public/shared/assistant/asst-limit-wait.js +3 -1
  107. package/neural-interface/public/shared/assistant/asst-motion-gate.js +80 -0
  108. package/neural-interface/public/shared/assistant/asst-panel.js +8 -4
  109. package/neural-interface/public/shared/assistant/asst-render.js +72 -11
  110. package/neural-interface/public/shared/assistant/asst-scene-styles.js +55 -23
  111. package/neural-interface/public/shared/assistant/asst-scenes.js +225 -79
  112. package/neural-interface/public/shared/assistant/asst-sidepanel-styles.js +4 -4
  113. package/neural-interface/public/shared/assistant/asst-style-cache.js +44 -0
  114. package/neural-interface/public/shared/assistant/asst-styles.js +26 -5
  115. package/neural-interface/public/shared/cdx/cdx-render.js +73 -7
  116. package/neural-interface/public/shared/cdx/cdx-tabs.js +3 -3
  117. package/neural-interface/public/shared/cp/cp-agents.js +8 -0
  118. package/neural-interface/public/shared/cp/cp-permissions.js +18 -2
  119. package/neural-interface/public/shared/cp/cp-rehydrate.js +25 -1
  120. package/neural-interface/public/shared/cp/cp-tasks-model.js +33 -0
  121. package/neural-interface/public/shared/judgments-log-origins.js +29 -0
  122. package/neural-interface/public/shared/loading-teardown.js +34 -0
  123. package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +23 -0
  124. package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +6 -1
  125. package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +13 -0
  126. package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +3 -1
  127. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +5 -2
  128. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +16 -86
  129. package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +6 -0
  130. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +88 -72
  131. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +5 -2
  132. package/neural-interface/public/shared/owner-access.js +134 -0
  133. package/neural-interface/public/shared/owner-authority-view.js +92 -0
  134. package/neural-interface/public/shared/page-session.js +143 -14
  135. package/neural-interface/public/shared/poll-backoff.js +59 -0
  136. package/neural-interface/public/shared/settings/settings-data.js +6 -1
  137. package/neural-interface/public/shared/settings/settings-kit.js +11 -3
  138. package/neural-interface/public/shared/settings/settings-shell.js +7 -0
  139. package/neural-interface/public/shared/shown-children.js +72 -0
  140. package/neural-interface/public/shared/static-bg-state.js +22 -0
  141. package/neural-interface/public/shared/storage-retry.js +47 -0
  142. package/neural-interface/public/shared/storage.js +25 -4
  143. package/neural-interface/public/shared/styles.css +109 -8
  144. package/neural-interface/public/shared/synabun-mascot.js +27 -8
  145. package/neural-interface/public/shared/synabun-ticker.js +147 -12
  146. package/neural-interface/public/shared/synabun-tools.js +173 -0
  147. package/neural-interface/public/shared/tool-heartbeat.js +43 -0
  148. package/neural-interface/public/shared/tool-list-picker.js +3 -1
  149. package/neural-interface/public/shared/tool-list-view.js +23 -4
  150. package/neural-interface/public/shared/ui-automation-studio.js +8 -1
  151. package/neural-interface/public/shared/ui-claude-panel.js +238 -90
  152. package/neural-interface/public/shared/ui-judgments.js +37 -10
  153. package/neural-interface/public/shared/ui-loading.js +5 -4
  154. package/neural-interface/public/shared/ui-navbar.js +6 -0
  155. package/neural-interface/public/shared/ui-owner-access.js +191 -0
  156. package/neural-interface/public/shared/ui-owner-authority.js +162 -0
  157. package/neural-interface/public/shared/ui-sessions.js +45 -16
  158. package/neural-interface/public/shared/ui-settings.js +86 -15
  159. package/neural-interface/public/shared/ui-terminal.js +15 -7
  160. package/neural-interface/public/shared/ui-tutorial-preview.js +4 -0
  161. package/neural-interface/public/shared/ui-update.js +3 -0
  162. package/neural-interface/public/shared/ui-whiteboard.js +4 -0
  163. package/neural-interface/public/shared/window-keys.js +38 -0
  164. package/neural-interface/server.js +1240 -238
  165. package/npm-shrinkwrap.json +2 -2
  166. package/package.json +1 -1
@@ -17,6 +17,7 @@ import { state, emit, on } from './state.js';
17
17
  import { forgetGreeting, mountGreeting } from './greeting/greeting-card.js';
18
18
  import { fetchClaudeSessions, fetchBrowserSessions, searchSessions } from './api.js';
19
19
  import { createFrameRenderer } from './utils.js';
20
+ import { refreshPageSession } from './page-session.js';
20
21
  import { notify, NOTIF_TYPE } from './ui-notifications.js';
21
22
  import { registerSidepanel, setSidepanelVisible, syncSidepanelLayout, focusSidepanel, openAnotherSidepanelSession, isHostedSessionFocused } from './ui-sidepanel-windows.js';
22
23
  import { mountCliBanner } from './ui-cli-banner.js';
@@ -36,7 +37,7 @@ import { buildAgentCard, ensureAgentScope, noteAgentActivity, updateAgentTodoBad
36
37
  import { renderPermissionCard, renderPlanApprovalCard, renderElicitationCard, decorateAskCard, askAnnotations, markAskAnswered, PERMISSION_MODES, MODE_LABELS } from './cp/cp-permissions.js';
37
38
  import { normalizeSession, changedStartSettings, sessionFlags, sessionRows, fastModeSupported, fastModeReason, mergeSessionModels, parseMcpServerLines, formatMcpServerLines } from './cp/cp-session-model.js';
38
39
  import { renderSessionSettingsCard } from './cp/cp-session-settings.js';
39
- import { describeOrigin, reconcileTasks, adoptLiveTasks, describeHistorySystemRow, workEndedByRestart, isTaskRunning } from './cp/cp-tasks-model.js';
40
+ import { describeOrigin, reconcileTasks, adoptLiveTasks, describeHistorySystemRow, workEndedByRestart, isTaskRunning, endRunningTasks, backgroundWaitLine } from './cp/cp-tasks-model.js';
40
41
  import { renderTasksCard } from './cp/cp-tasks.js';
41
42
  import { sessionListLabel, collectTags, tagSession as tagClaudeSession, sessionActionsAvailable, sessionOpsSupported, labelledSessionIds, mergeSessionSearch, writeSessionTitle, forkSession as forkClaudeSession, deleteSession as deleteClaudeSession, fetchSubagentMessages, forkTitle, entryBefore, promptText, removeFrom, sessionRowParts, fillSelectOptions } from './cp/cp-sessions.js';
42
43
  import { contextCard, usageCard, mcpRows, rewindPreviewText, rewindResultText } from './cp/cp-usage-model.js';
@@ -50,6 +51,8 @@ import { CP_STYLES } from './cp/cp-styles.js';
50
51
  import { TEMPORARY_CAPABILITY, keepsNothing, chooseTemporary, applyTemporary, temporaryRefusal, endTemporary, leaveTemporary, tabAfterTemporary, persistableTabs, temporaryBlocks, reattaches } from './cp/cp-temporary.js';
51
52
  import { paintTemporary } from './cp/cp-temporary-view.js';
52
53
  import { renderMarkdown } from './cp/cp-markdown.js';
54
+ import { synabunToolKey, synabunToolLabel, synabunToolSummary, synabunToolGroup } from './synabun-tools.js';
55
+ import { normalizeToolHeartbeat } from './tool-heartbeat.js';
53
56
  import { sanitizeStoredHtml } from './assistant/asst-sanitize.js';
54
57
  import { escapeHtml, classToken } from './cp/cp-markdown.js';
55
58
  import { rehydrateStoredTranscript } from './cp/cp-rehydrate.js';
@@ -85,9 +88,12 @@ const ICON_CHECK = '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" s
85
88
  const ICON_X = '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4l8 8M12 4l-8 8"/></svg>';
86
89
 
87
90
  // ── SynaBun MCP tool registry ──
88
- const SYNABUN_PREFIX = 'mcp__SynaBun__';
89
- function isSynaBunTool(name) { return name?.startsWith(SYNABUN_PREFIX); }
90
- function synaBunToolKey(name) { return name?.replace(SYNABUN_PREFIX, '') || ''; }
91
+ // Which call is SynaBun's, and the name and summary of one this registry does not
92
+ // list, come from synabun-tools.js (every panel's): `mcp__SynaBun__x` in any letter
93
+ // case, a plugin's copy of the server, OpenCode's `SynaBun_x`. Every SynaBun tool
94
+ // gets the branded card; the registry only adds an icon and a summary of its own.
95
+ function isSynaBunTool(name) { return synabunToolKey(name) != null; }
96
+ function synaBunToolKey(name) { return synabunToolKey(name) || ''; }
91
97
 
92
98
  const SB_ICON_RECALL = '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2C5.2 2 3 4.2 3 7c0 1.8 1 3.4 2.4 4.2V13h5.2v-1.8C12 10.4 13 8.8 13 7c0-2.8-2.2-5-5-5z"/><path d="M6 13.5h4M6.5 15h3"/><circle cx="11.5" cy="4" r="2.5"/><path d="M10.5 4h2M11.5 3v2"/></svg>';
93
99
  const SB_ICON_REMEMBER = '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2C5.2 2 3 4.2 3 7c0 1.8 1 3.4 2.4 4.2V13h5.2v-1.8C12 10.4 13 8.8 13 7c0-2.8-2.2-5-5-5z"/><path d="M6 13.5h4M6.5 15h3"/><path d="M7 6.5h2M8 5.5v2"/></svg>';
@@ -118,25 +124,17 @@ const SYNABUN_TOOLS = {
118
124
  loop: { label: 'Loop', group: 'system', icon: SB_ICON_LOOP, detailFn: i => i.action || '' },
119
125
  tictactoe: { label: 'Tic-Tac-Toe', group: 'fun', icon: SB_ICON_TICTACTOE, detailFn: i => i.action || '' },
120
126
  };
121
- const SYNABUN_GROUPS = {
122
- browser: { label: 'Browser', group: 'browser', icon: SB_ICON_BROWSER, detailFn: i => i.url || i.selector || i.text || '' },
123
- discord: { label: 'Discord', group: 'discord', icon: SB_ICON_DISCORD, detailFn: i => i.action || i.channel_id || '' },
124
- whiteboard: { label: 'Whiteboard', group: 'whiteboard', icon: SB_ICON_WHITEBOARD, detailFn: i => i.id || '' },
125
- card: { label: 'Card', group: 'card', icon: SB_ICON_CARD, detailFn: i => i.card_id || '' },
126
- browser_extract: { label: 'Extract', group: 'browser', icon: SB_ICON_BROWSER, detailFn: i => i.url || i.selector || '' },
127
- };
127
+ // The icon of a SynaBun tool the registry does not list, by its group (the logo otherwise).
128
+ const SYNABUN_GROUP_ICONS = { browser: SB_ICON_BROWSER, discord: SB_ICON_DISCORD, whiteboard: SB_ICON_WHITEBOARD, card: SB_ICON_CARD, memory: SB_ICON_MEMORIES };
128
129
 
130
+ /** The card of a SynaBun tool: { label, group, icon, detailFn }; null only for a call that is not SynaBun's. */
129
131
  function getSynaBunMeta(name) {
130
- const key = synaBunToolKey(name);
132
+ const raw = synabunToolKey(name);
133
+ if (raw == null) return null;
134
+ const key = raw.toLowerCase();
131
135
  if (Object.prototype.hasOwnProperty.call(SYNABUN_TOOLS, key)) return SYNABUN_TOOLS[key];
132
- for (const [prefix, meta] of Object.entries(SYNABUN_GROUPS)) {
133
- if (key.startsWith(prefix + '_') || key === prefix) {
134
- const action = key.slice(prefix.length + 1) || '';
135
- const actionLabel = action.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
136
- return { ...meta, label: actionLabel ? `${meta.label}: ${actionLabel}` : meta.label };
137
- }
138
- }
139
- return null;
136
+ const group = synabunToolGroup(key);
137
+ return { label: synabunToolLabel(key), group, icon: SYNABUN_GROUP_ICONS[group] || SYNABUN_LOGO_ICON, detailFn: i => synabunToolSummary(key, i) };
140
138
  }
141
139
 
142
140
  function toolIconSvg(name) {
@@ -419,6 +417,7 @@ function buildPanel() {
419
417
  </div>
420
418
  <div class="cp-input-area">
421
419
  <div class="cp-input-wrap">
420
+ <span class="cp-spin-ring" aria-hidden="true"><i></i></span>
422
421
  <div class="cp-image-preview" id="cp-image-preview"></div>
423
422
  <div class="cp-input-inner">
424
423
  <textarea class="cp-input" id="cp-input" placeholder="Message SynaBun..." rows="1" autocomplete="off" spellcheck="false"></textarea>
@@ -1061,26 +1060,17 @@ function injectStyles() {
1061
1060
  margin-top: 8px; transition: opacity 0.3s, border-color 0.2s, box-shadow 0.3s;
1062
1061
  }
1063
1062
  .perm-card { position: relative; }
1064
- .perm-card::before {
1065
- content: '';
1066
- position: absolute; inset: 0;
1067
- border-radius: 8px;
1068
- padding: 1px;
1069
- pointer-events: none;
1063
+ /* A card that waits on you turns an amber ring inside its edge: the shared .cp-spin-ring (with the
1064
+ composer's, below), turning only while the card is .active-perm. */
1065
+ .perm-card > .cp-spin-ring { border-radius: 8px; }
1066
+ .perm-card > .cp-spin-ring > i {
1070
1067
  background: conic-gradient(
1071
- from var(--cp-border-angle, 0deg),
1072
1068
  rgba(245,180,60,0.0) 0%,
1073
1069
  rgba(245,180,60,0.55) 25%,
1074
1070
  rgba(245,180,60,0.1) 50%,
1075
1071
  rgba(245,180,60,0.55) 75%,
1076
1072
  rgba(245,180,60,0.0) 100%
1077
1073
  );
1078
- -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
1079
- -webkit-mask-composite: xor;
1080
- mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
1081
- mask-composite: exclude;
1082
- opacity: 0;
1083
- transition: opacity 0.4s;
1084
1074
  }
1085
1075
  .perm-card.active-perm {
1086
1076
  border-color: rgba(245,180,60,0.25);
@@ -1088,9 +1078,10 @@ function injectStyles() {
1088
1078
  box-shadow: 0 0 16px rgba(245,180,60,0.08), 0 0 40px rgba(245,180,60,0.04);
1089
1079
  animation: cp-perm-glow 2.5s ease-in-out infinite;
1090
1080
  }
1091
- .perm-card.active-perm::before {
1092
- opacity: 1;
1093
- animation: cp-border-spin 3s linear infinite;
1081
+ .perm-card.active-perm > .cp-spin-ring { opacity: 1; }
1082
+ .perm-card.active-perm > .cp-spin-ring > i {
1083
+ animation: cp-spin-ring-turn 3s linear infinite;
1084
+ will-change: rotate;
1094
1085
  }
1095
1086
  .perm-card:hover { border-color: var(--b-light); }
1096
1087
  .perm-card.active-perm:hover { border-color: rgba(245,180,60,0.4); }
@@ -1234,47 +1225,64 @@ function injectStyles() {
1234
1225
  transition: background 0.4s;
1235
1226
  min-width: 0;
1236
1227
  }
1237
- .cp-input-wrap::before {
1238
- content: '';
1228
+ /* ── Spinning border ring (composer focus, a waiting permission card) ──
1229
+ A conic gradient turning inside the 1px edge, the mask keeping only the ring. The gradient is a
1230
+ square box that turns (rotate, run by the compositor) under the mask, and only while its owner's
1231
+ state is on; an animated custom property (the old --cp-border-angle, @property + a conic gradient
1232
+ from it) restyled and repainted the owner on the main thread 60 times a second. The ring is a size
1233
+ container and the square 142cqmax + 4px, wider than the owner's diagonal at any shape, so what
1234
+ the mask shows is the same conic gradient at every angle. Markup: <span class="cp-spin-ring"
1235
+ aria-hidden="true"><i></i></span>, the owner's first child. */
1236
+ .cp-spin-ring {
1239
1237
  position: absolute; inset: 0;
1240
- border-radius: 14px;
1241
1238
  padding: 1px;
1239
+ overflow: hidden;
1242
1240
  pointer-events: none;
1241
+ container-type: size;
1242
+ -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
1243
+ -webkit-mask-composite: xor;
1244
+ mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
1245
+ mask-composite: exclude;
1246
+ opacity: 0;
1247
+ transition: opacity 0.4s;
1248
+ }
1249
+ .cp-spin-ring > i {
1250
+ position: absolute; left: 50%; top: 50%;
1251
+ width: calc(142cqmax + 4px);
1252
+ aspect-ratio: 1;
1253
+ translate: -50% -50%;
1254
+ }
1255
+ @keyframes cp-spin-ring-turn {
1256
+ to { rotate: 360deg; }
1257
+ }
1258
+ body.ui-interacting .cp-spin-ring > i { animation-play-state: paused !important; }
1259
+ /* Reduced motion: the ring holds still where the turn starts (the focus / waiting look stays). */
1260
+ @media (prefers-reduced-motion: reduce) {
1261
+ .cp-spin-ring > i { animation: none !important; will-change: auto !important; }
1262
+ }
1263
+ .cp-input-wrap > .cp-spin-ring { border-radius: 14px; }
1264
+ .cp-input-wrap > .cp-spin-ring > i {
1243
1265
  background: conic-gradient(
1244
- from var(--cp-border-angle, 0deg),
1245
1266
  rgba(212,162,127,0.0) 0%,
1246
1267
  rgba(212,162,127,0.35) 25%,
1247
1268
  rgba(212,162,127,0.10) 50%,
1248
1269
  rgba(212,162,127,0.35) 75%,
1249
1270
  rgba(212,162,127,0.0) 100%
1250
1271
  );
1251
- -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
1252
- -webkit-mask-composite: xor;
1253
- mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
1254
- mask-composite: exclude;
1255
- opacity: 0;
1256
- transition: opacity 0.4s;
1257
1272
  }
1258
- .cp-input-wrap:focus-within::before {
1259
- opacity: 1;
1260
- animation: cp-border-spin 3s linear infinite;
1273
+ .cp-input-wrap:focus-within > .cp-spin-ring { opacity: 1; }
1274
+ .cp-input-wrap:focus-within > .cp-spin-ring > i {
1275
+ animation: cp-spin-ring-turn 3s linear infinite;
1276
+ will-change: rotate;
1261
1277
  }
1262
1278
  .cp-input-wrap:focus-within {
1263
1279
  background: rgba(212,162,127,0.03);
1264
1280
  box-shadow: 0 0 20px rgba(212,162,127,0.04), 0 0 60px rgba(212,162,127,0.015);
1265
1281
  }
1266
- @keyframes cp-border-spin {
1267
- to { --cp-border-angle: 360deg; }
1268
- }
1269
1282
  @keyframes cp-perm-glow {
1270
1283
  0%, 100% { box-shadow: 0 0 16px rgba(245,180,60,0.08), 0 0 40px rgba(245,180,60,0.04); }
1271
1284
  50% { box-shadow: 0 0 20px rgba(245,180,60,0.14), 0 0 50px rgba(245,180,60,0.07); }
1272
1285
  }
1273
- @property --cp-border-angle {
1274
- syntax: '<angle>';
1275
- initial-value: 0deg;
1276
- inherits: false;
1277
- }
1278
1286
 
1279
1287
  .cp-input-inner {
1280
1288
  display: flex; align-items: flex-end;
@@ -1870,7 +1878,9 @@ function injectStyles() {
1870
1878
  .cp-messages pre code[class*="diff"] {
1871
1879
  display: block; white-space: pre;
1872
1880
  }
1873
- .cp-messages pre:has(code[class*="diff"]) {
1881
+ /* A diff block, as addCopyButtons() found it (data-diff-wrapped, set once). Not :has(code[class*="diff"]): a
1882
+ class test inside :has() re-checked the page on every class change anywhere (css-has-performance test). */
1883
+ .cp-messages pre:has(code[data-diff-wrapped]) {
1874
1884
  background: rgba(0,0,0,0.4);
1875
1885
  border-color: rgba(140,160,200,0.15);
1876
1886
  }
@@ -1883,6 +1893,7 @@ function injectStyles() {
1883
1893
 
1884
1894
  /* ── MCP collapse markers ── */
1885
1895
  .tool-mcp-badge {
1896
+ border: none; cursor: pointer; line-height: 1.4;
1886
1897
  margin-left: 6px; padding: 1px 6px; border-radius: 4px;
1887
1898
  background: rgba(255,195,0,0.14); color: rgba(255,210,60,0.9);
1888
1899
  font-size: 9px; font-family: 'JetBrains Mono', monospace; font-weight: 600;
@@ -2301,52 +2312,53 @@ function injectStyles() {
2301
2312
  }
2302
2313
 
2303
2314
  /* ── Claude session pills in shared tray ── */
2304
- @property --cp-pill-angle {
2305
- syntax: '<angle>';
2306
- initial-value: 0deg;
2307
- inherits: false;
2308
- }
2309
2315
  .cp-session-pill {
2310
2316
  position: relative;
2311
2317
  overflow: hidden;
2312
2318
  border-color: rgba(212, 162, 127, 0.14);
2313
2319
  transition: border-color 0.2s;
2314
2320
  }
2315
- .cp-session-pill::before {
2316
- content: '';
2321
+ /* A working pill's ring: a conic gradient turning inside the 1px border (the mask keeps only the
2322
+ ring). The gradient is a square box that turns (rotate, run by the compositor) under the mask; an
2323
+ animated custom property (the old --cp-pill-angle) repainted the pill on the main thread every
2324
+ frame for as long as a session worked. The square is wider than the pill's diagonal, so the ring
2325
+ is the same conic gradient at every angle. */
2326
+ .cp-pill-ring {
2317
2327
  position: absolute; inset: 0;
2328
+ display: none;
2318
2329
  border-radius: 8px;
2319
2330
  padding: 1px;
2331
+ overflow: hidden;
2320
2332
  pointer-events: none;
2321
- background: transparent;
2322
2333
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
2323
2334
  -webkit-mask-composite: xor;
2324
2335
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
2325
2336
  mask-composite: exclude;
2326
- opacity: 0;
2327
- }
2328
- .cp-session-pill.cp-pill-running {
2329
- border-color: transparent;
2330
2337
  }
2331
- .cp-session-pill.cp-pill-running::before {
2338
+ .cp-pill-ring > i {
2339
+ position: absolute; left: 50%; top: 50%;
2340
+ width: calc(100% + 32px);
2341
+ aspect-ratio: 1;
2342
+ translate: -50% -50%;
2332
2343
  background: conic-gradient(
2333
- from var(--cp-pill-angle, 0deg),
2334
2344
  rgba(212,162,127,0.0) 0%,
2335
2345
  rgba(212,162,127,0.6) 25%,
2336
2346
  rgba(212,162,127,0.12) 50%,
2337
2347
  rgba(212,162,127,0.6) 75%,
2338
2348
  rgba(212,162,127,0.0) 100%
2339
2349
  );
2340
- animation: cp-pill-border-spin 2.4s linear infinite;
2341
- opacity: 1;
2350
+ animation: cp-pill-ring-turn 2.4s linear infinite;
2342
2351
  }
2343
- @keyframes cp-pill-border-spin {
2344
- to { --cp-pill-angle: 360deg; }
2352
+ .cp-session-pill.cp-pill-running {
2353
+ border-color: transparent;
2354
+ }
2355
+ .cp-session-pill.cp-pill-running .cp-pill-ring { display: block; }
2356
+ @keyframes cp-pill-ring-turn {
2357
+ to { rotate: 360deg; }
2345
2358
  }
2346
2359
  .cp-session-pill:hover { border-color: rgba(212, 162, 127, 0.28); }
2347
- .cp-session-pill:hover.cp-pill-running::before {
2360
+ .cp-session-pill:hover .cp-pill-ring > i {
2348
2361
  background: conic-gradient(
2349
- from var(--cp-pill-angle, 0deg),
2350
2362
  rgba(212,162,127,0.0) 0%,
2351
2363
  rgba(212,162,127,0.8) 25%,
2352
2364
  rgba(212,162,127,0.20) 50%,
@@ -2362,11 +2374,11 @@ function injectStyles() {
2362
2374
  html.desktop-titlebar--win32 .cp-session-pill.cp-pill-running:hover {
2363
2375
  border-color: rgba(212, 162, 127, 0.62);
2364
2376
  }
2365
- html.platform-win32 .cp-session-pill.cp-pill-running::before,
2366
- html.desktop-titlebar--win32 .cp-session-pill.cp-pill-running::before {
2367
- animation: none;
2368
- opacity: 0;
2377
+ html.platform-win32 .cp-session-pill.cp-pill-running .cp-pill-ring,
2378
+ html.desktop-titlebar--win32 .cp-session-pill.cp-pill-running .cp-pill-ring {
2379
+ display: none;
2369
2380
  }
2381
+ body.ui-interacting .cp-pill-ring > i { animation-play-state: paused; }
2370
2382
  .cp-session-pill .term-minimized-pill-icon { color: rgba(212, 162, 127, 0.45); transition: color 0.2s; }
2371
2383
  .cp-session-pill.cp-pill-running .term-minimized-pill-icon { color: rgba(212, 162, 127, 1); }
2372
2384
  .cp-session-pill:hover .term-minimized-pill-icon { color: rgba(212, 162, 127, 0.85); }
@@ -2401,6 +2413,12 @@ function injectStyles() {
2401
2413
  pointer-events: none;
2402
2414
  }
2403
2415
  @keyframes cp-pill-pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }
2416
+ /* Reduced motion: the ring, the dot and the edge hold still (the working look stays). */
2417
+ @media (prefers-reduced-motion: reduce) {
2418
+ .cp-pill-ring > i,
2419
+ .cp-session-pill.cp-pill-running .term-minimized-pill-label::before,
2420
+ .cp-session-pill.cp-pill-running::after { animation: none; }
2421
+ }
2404
2422
 
2405
2423
  /* ── Think intensity toggle ── */
2406
2424
  /* ── Shared toggle base ── */
@@ -3238,6 +3256,7 @@ function _createTrayPill(tab) {
3238
3256
  pill.className = 'term-minimized-pill cp-session-pill';
3239
3257
  pill.dataset.tabId = tab.id;
3240
3258
  pill.innerHTML = `
3259
+ <span class="cp-pill-ring" aria-hidden="true"><i></i></span>
3241
3260
  <span class="term-minimized-pill-icon">${_CP_ICON_SVG}</span>
3242
3261
  <span class="term-minimized-pill-label">${escH(tab.label)}</span>
3243
3262
  <button class="term-minimized-pill-close" data-tooltip="Close" data-tooltip-pos="top">&times;</button>
@@ -4728,6 +4747,28 @@ function _renderHistoryRow(tab, $msgs, m) {
4728
4747
  return;
4729
4748
  }
4730
4749
  if (m.role === 'assistant') {
4750
+ // Only calls, right after an assistant row (its words, or the calls before them): the same
4751
+ // row, as the live path shows a run of calls (toolRunRow).
4752
+ const onlyCalls = !m.text && !m.thinking && Array.isArray(m.tools) && m.tools.length > 0
4753
+ && m.tools.every(t => t && typeof t === 'object' && t.name && t.name !== 'AskUserQuestion' && t.name !== 'ExitPlanMode');
4754
+ const runRow = onlyCalls ? toolRunRowIn($msgs, live ? tab.thinkingEl : null, { afterWords: true }) : null;
4755
+ if (runRow) {
4756
+ const runWrap = runRow.querySelector(':scope > .msg-content');
4757
+ for (const t of m.tools) {
4758
+ const card = buildTool(t, tab);
4759
+ if (!card) continue;
4760
+ if (t.id && $msgs._replayCards instanceof Map) $msgs._replayCards.set(String(t.id), card);
4761
+ runWrap.appendChild(card);
4762
+ }
4763
+ if (m.uuid) runRow.dataset.uuids = [runRow.dataset.uuids, m.uuid].filter(Boolean).join(' ');
4764
+ if (live && tab._pendingResults instanceof Map && tab._pendingResults.size) {
4765
+ for (const t of m.tools) {
4766
+ const ev = t?.id ? takePendingResult(tab, t.id) : null;
4767
+ if (ev) { try { updateToolResult(tab, ev); } catch {} }
4768
+ }
4769
+ }
4770
+ return;
4771
+ }
4731
4772
  const el = document.createElement('div'); el.className = 'msg msg-assistant';
4732
4773
  if (m.uuid) el.dataset.uuids = m.uuid;
4733
4774
  const avatar = document.createElement('div'); avatar.className = 'msg-avatar';
@@ -5770,6 +5811,10 @@ function _processTabMsg(tab, msg) {
5770
5811
 
5771
5812
  function handleTabEvent(tab, ev) {
5772
5813
  if (!ev?.type) return;
5814
+ // A call running past 30 s gets a heartbeat whose parent_tool_use_id is the call
5815
+ // itself, not a subagent: it is progress of that call, never a subagent's card
5816
+ // (tool-heartbeat.js).
5817
+ ev = normalizeToolHeartbeat(ev);
5773
5818
 
5774
5819
  // ── Subagent scope routing (SDK engine) ──
5775
5820
  // Messages emitted by a Task subagent carry parent_tool_use_id; route them to
@@ -6263,6 +6308,13 @@ function handleStreamDelta(tab, apiEvent) {
6263
6308
  // (with full input) when the complete message arrives. No buildTool side
6264
6309
  // effects fire for ghosts.
6265
6310
  if (tab._stream.blockType === 'tool_use' && apiEvent.content_block?.id && apiEvent.content_block?.name !== 'AskUserQuestion') {
6311
+ // A message that opens with a tool call, right after a row of tool calls: the same row.
6312
+ const joined = !tab._stream.el ? toolRunRow(tab) : null;
6313
+ if (joined) {
6314
+ tab._stream.el = joined;
6315
+ tab._stream.joined = true;
6316
+ if (tab._stream.msgId) { tab.currentMsgId = tab._stream.msgId; tab.currentMsgEl = joined; tab._joinedMsgId = tab._stream.msgId; }
6317
+ }
6266
6318
  if (!tab._stream.el) {
6267
6319
  const el = document.createElement('div');
6268
6320
  el.className = 'msg msg-assistant';
@@ -6286,7 +6338,11 @@ function handleStreamDelta(tab, apiEvent) {
6286
6338
  ghost.className = 'tool-card tool-streaming';
6287
6339
  ghost.dataset.toolId = cb.id;
6288
6340
  ghost.dataset.toolName = cb.name || '';
6289
- ghost.innerHTML = `<div class="tool-hdr"><span class="tool-icon">${toolIconSvg(cb.name)}</span><span class="tool-name">${esc(cb.name || 'tool')}</span><span class="tool-detail">…</span></div>`;
6341
+ const sbMeta = getSynaBunMeta(cb.name);
6342
+ if (sbMeta) ghost.classList.add('synabun-card');
6343
+ ghost.innerHTML = sbMeta
6344
+ ? `<div class="tool-hdr synabun-hdr"><span class="tool-icon synabun-icon">${SYNABUN_LOGO_ICON}</span><span class="tool-name synabun-name">${esc(sbMeta.label)}</span><span class="tool-detail">…</span></div>`
6345
+ : `<div class="tool-hdr"><span class="tool-icon">${toolIconSvg(cb.name)}</span><span class="tool-name">${esc(cb.name || 'tool')}</span><span class="tool-detail">…</span></div>`;
6290
6346
  wrapEl.appendChild(ghost);
6291
6347
  try { if (!tab._agentScope) setActivity(tab, cpActivityVerb(cb.name, {})); } catch {}
6292
6348
  if (tab === activeTab()) scrollEnd();
@@ -6360,6 +6416,7 @@ function handleStreamDelta(tab, apiEvent) {
6360
6416
  // Lazy-create row + body on first visible text. Keeps empty/whitespace-only
6361
6417
  // text blocks from leaving a blank row next to the avatar.
6362
6418
  if (!tab._stream.bodyEl && tab._stream.textBuf.trim()) {
6419
+ if (tab._stream.joined) { tab._stream.el = null; tab._stream.joined = false; tab._joinedMsgId = null; }
6363
6420
  if (!tab._stream.el) {
6364
6421
  const el = document.createElement('div');
6365
6422
  el.className = 'msg msg-assistant';
@@ -6675,6 +6732,25 @@ function _cleanupEmptyAssistantRow(el) {
6675
6732
  return false;
6676
6733
  }
6677
6734
 
6735
+ /**
6736
+ * The assistant row a message of tool calls alone continues: the last row of the
6737
+ * transcript (the thinking indicator aside), with an avatar, ending on a tool card.
6738
+ * Anything after it (a note, a permission or question card, a turn footer, a status
6739
+ * line, the user's prompt) ends the run. null when there is none.
6740
+ */
6741
+ function toolRunRowIn($msgs, skip = null, { afterWords = false } = {}) {
6742
+ if (!$msgs) return null;
6743
+ let prev = $msgs.lastElementChild;
6744
+ if (prev && skip && prev === skip) prev = prev.previousElementSibling;
6745
+ if (!prev?.classList?.contains('msg-assistant') || prev.dataset.workerQuestionId) return null;
6746
+ if (!prev.querySelector(':scope > .msg-avatar')) return null;
6747
+ const last = prev.querySelector(':scope > .msg-content')?.lastElementChild;
6748
+ if (last?.classList?.contains('tool-card')) return prev;
6749
+ // (History: a transcript keeps the words and the calls of one message on two lines.)
6750
+ return afterWords && last?.classList?.contains('msg-body') ? prev : null;
6751
+ }
6752
+ function toolRunRow(tab) { return toolRunRowIn(tab?.messagesEl, tab?.thinkingEl); }
6753
+
6678
6754
  function renderAssistant(tab, msg) {
6679
6755
  const $msgs = tab.messagesEl;
6680
6756
  if (!$msgs) return;
@@ -6717,6 +6793,14 @@ function renderAssistant(tab, msg) {
6717
6793
  saveTabs();
6718
6794
  }
6719
6795
 
6796
+ // A message whose cards joined the row before it (toolRunRow) and that now carries words or
6797
+ // thinking: those go in a row of their own, below; its cards stay where they are.
6798
+ let ownRow = false;
6799
+ if (msgId && msgId === tab._joinedMsgId && msgId === tab.currentMsgId && tab.currentMsgEl
6800
+ && (texts.some(b => (b.text || '').trim()) || thinks.some(b => (b.thinking || '').trim()))) {
6801
+ tab.currentMsgEl = null; tab.currentMsgId = null; tab._joinedMsgId = null; ownRow = true;
6802
+ }
6803
+
6720
6804
  // Partial message dedup
6721
6805
  if (msgId && msgId === tab.currentMsgId && tab.currentMsgEl) {
6722
6806
  const wrap = tab.currentMsgEl.querySelector('.msg-content');
@@ -6768,7 +6852,10 @@ function renderAssistant(tab, msg) {
6768
6852
  const existingToolIds = new Set([...wrap.querySelectorAll('.tool-card, .plan-card')].map(c => c.dataset.toolId));
6769
6853
  for (const t of regularTools) {
6770
6854
  if (!existingToolIds.has(t.id || '')) {
6771
- wrap.appendChild(buildTool(t, tab));
6855
+ // (Already shown in another row: the cards of a message split by toolRunRow.)
6856
+ const elsewhere = t.id ? $msgs.querySelector(`.tool-card[data-tool-id="${CSS.escape(t.id)}"], .plan-card[data-tool-id="${CSS.escape(t.id)}"]`) : null;
6857
+ if (!elsewhere) wrap.appendChild(buildTool(t, tab));
6858
+ else if (elsewhere.classList.contains('tool-streaming')) elsewhere.replaceWith(buildTool(t, tab));
6772
6859
  } else {
6773
6860
  // Backfill streaming ghost stubs with the real card now that full input arrived
6774
6861
  const ghost = wrap.querySelector(`.tool-card.tool-streaming[data-tool-id="${CSS.escape(t.id || '')}"]`);
@@ -6797,7 +6884,23 @@ function renderAssistant(tab, msg) {
6797
6884
  return;
6798
6885
  }
6799
6886
 
6800
- // New assistant message
6887
+ // New assistant message. One that is only tool calls, right after a row whose last item is a
6888
+ // tool card, is the same stretch of work: its cards join that row (one avatar for the run of
6889
+ // calls, the way parallel calls share one), instead of a row per call.
6890
+ const shownTools = ownRow ? regularTools.filter(t => !t.id || !$msgs.querySelector(`.tool-card[data-tool-id="${CSS.escape(t.id)}"]`)) : regularTools;
6891
+ const joined = !ownRow && !thinks.length && !texts.some(b => (b.text || '').trim()) && !askTools.length && !extras.any && shownTools.length
6892
+ ? toolRunRow(tab) : null;
6893
+ if (joined) {
6894
+ const joinedWrap = joined.querySelector(':scope > .msg-content');
6895
+ for (const t of shownTools) joinedWrap.appendChild(buildTool(t, tab));
6896
+ if (msgId) { tab.currentMsgId = msgId; tab.currentMsgEl = joined; tab._joinedMsgId = msgId; }
6897
+ const postPlanJ = $msgs.querySelector('.post-plan-card')?.closest('.msg');
6898
+ if (postPlanJ && postPlanJ !== $msgs.lastElementChild) $msgs.appendChild(postPlanJ);
6899
+ if (tab.thinkingEl && tab.thinkingEl.parentNode === $msgs && tab.thinkingEl !== $msgs.lastElementChild) $msgs.appendChild(tab.thinkingEl);
6900
+ if (tab === activeTab()) scrollEnd();
6901
+ scheduleSessionSnapshotSave(tab);
6902
+ return;
6903
+ }
6801
6904
  const el = document.createElement('div');
6802
6905
  el.className = 'msg msg-assistant';
6803
6906
  const avatar = document.createElement('div');
@@ -6829,7 +6932,7 @@ function renderAssistant(tab, msg) {
6829
6932
  wrap.appendChild(body);
6830
6933
  }
6831
6934
  }
6832
- for (const t of regularTools) wrap.appendChild(buildTool(t, tab));
6935
+ for (const t of shownTools) wrap.appendChild(buildTool(t, tab));
6833
6936
  for (const t of askTools) wrap.appendChild(buildAskFromToolUse(tab, t));
6834
6937
  el.appendChild(wrap);
6835
6938
  $msgs.appendChild(el);
@@ -10103,7 +10206,9 @@ function showBrowserEmbed(sessionId, url) {
10103
10206
  if (!_cpWsReconnAttempted) {
10104
10207
  _cpWsReconnAttempted = true;
10105
10208
  console.log('[claude-panel] Browser WS closed, retrying once for', sessionId);
10106
- setTimeout(() => {
10209
+ setTimeout(async () => {
10210
+ // A socket refused for an earlier boot's page secret never says why: ask for this boot's first.
10211
+ await refreshPageSession(window);
10107
10212
  if (_browserEmbed?.sessionId !== sessionId) return;
10108
10213
  const proto2 = location.protocol === 'https:' ? 'wss:' : 'ws:';
10109
10214
  const ws2 = new WebSocket(`${proto2}//${location.host}/ws/browser/${sessionId}`);
@@ -10518,6 +10623,16 @@ function _onMessagesClick(e) {
10518
10623
  });
10519
10624
  return;
10520
10625
  }
10626
+ // A run of repeated MCP calls: its badge shows or folds the calls after the first.
10627
+ const mcpBadge = e.target.closest('.tool-mcp-badge');
10628
+ if (mcpBadge) {
10629
+ const first = mcpBadge.closest('.tool-card');
10630
+ if (first) {
10631
+ first.dataset.mcpOpen = first.dataset.mcpOpen === '1' ? '0' : '1';
10632
+ try { collapseAdjacentMcpTools(first.parentElement); } catch {}
10633
+ }
10634
+ return;
10635
+ }
10521
10636
  // File links (a.file-link, and the links of a message's Markdown) are taken by _fileLinkOptions below.
10522
10637
  const hdr = e.target.closest('.tool-hdr');
10523
10638
  if (hdr && !e.target.closest('button, a, input, select, textarea')) {
@@ -10699,6 +10814,8 @@ export async function attachClaudeAutomation(run, { focus = !!run?.focus, isCanc
10699
10814
  tab._automationResumes = Math.max(tab._automationResumes || 0, resumes);
10700
10815
  if (suspended) _showRunSuspended(tab, run);
10701
10816
  else tab._automationSuspendedAt = null;
10817
+ // An ended run's CLI is gone, and every background shell or Monitor with it.
10818
+ if (!running && !suspended) _endRunBackgroundWork(tab);
10702
10819
  // (A dispatched worker's failure, with its reason, is on its end card.)
10703
10820
  if (run.status === 'failed' && run.error && !isDispatchedRun(run) && tab._automationLifecycleError !== run.error) {
10704
10821
  tab._automationLifecycleError = run.error;
@@ -10750,6 +10867,13 @@ export function handleClaudeAutomationEvent(runId, payload) {
10750
10867
  appendError(tab, event.message || 'Claude Code automation failed');
10751
10868
  return true;
10752
10869
  }
10870
+ // The run's turn waits for its own background work (lib/claude-background-hold.js): say so once per change.
10871
+ if (event.type === 'synabun.background_wait') {
10872
+ const line = backgroundWaitLine(event);
10873
+ if (line && line !== tab._backgroundWaitLine) appendStatus(tab, line);
10874
+ tab._backgroundWaitLine = line || null;
10875
+ return true;
10876
+ }
10753
10877
  handleTabMsg(tab, { type: 'event', event, fromRun: true });
10754
10878
  // Background agents still running keep a warm worker's "Task complete" away.
10755
10879
  if (event.type === 'system' || event.type === 'result') updateWorkerEndBusy(runId, hasLiveBackgroundWork(tab));
@@ -10821,6 +10945,23 @@ function _closeCutOffTools(tab) {
10821
10945
  _setBackgroundWork(tab, []);
10822
10946
  }
10823
10947
 
10948
+ // A run that ended (completed, stopped, failed): its CLI process is gone, so nothing it ran in the background runs
10949
+ // any more. The tasks it never reported the end of (the run closed its query first) are ended here, or the
10950
+ // Background work card shows them running forever.
10951
+ function _endRunBackgroundWork(tab) {
10952
+ let changed = false;
10953
+ try { changed = endRunningTasks(tab.tasks) > 0; } catch {}
10954
+ let shells = false;
10955
+ for (const task of tab.bgTasks?.values?.() || []) {
10956
+ if (task?.status === 'running') { task.status = 'stopped'; shells = true; }
10957
+ }
10958
+ if (shells) { try { renderBgTray(tab); } catch {} }
10959
+ if ((tab.backgroundWork || []).length) _setBackgroundWork(tab, []);
10960
+ else if (changed || shells) updatePillRunning(tab);
10961
+ // An open tasks card follows along.
10962
+ if ((changed || shells) && tab.messagesEl?.querySelector('.cp-tasks-card')) { try { _openTasks(tab); } catch {} }
10963
+ }
10964
+
10824
10965
  // The end of a worker the Assistant dispatched (ui-worker-end.js): one card,
10825
10966
  // the last row of its transcript. Its button closes this tab the way the X
10826
10967
  // does (a warm worker that finished its task is completed, one still at work
@@ -11545,11 +11686,18 @@ function collapseAdjacentMcpTools($msgs) {
11545
11686
  const flush = () => {
11546
11687
  if (group.length < 2) { group = []; return; }
11547
11688
  const first = group[0];
11548
- const badge = document.createElement('span');
11689
+ // The badge shows the calls it folds away and folds them again (_onMessagesClick):
11690
+ // what each of them did stays one click away.
11691
+ const open = first.dataset.mcpOpen === '1';
11692
+ const badge = document.createElement('button');
11693
+ badge.type = 'button';
11549
11694
  badge.className = 'tool-mcp-badge';
11550
11695
  badge.textContent = `×${group.length}`;
11551
- first.querySelector('.tool-hdr')?.appendChild(badge);
11552
- for (let i = 1; i < group.length; i++) group[i].classList.add('cp-mcp-collapsed');
11696
+ badge.setAttribute('aria-expanded', open ? 'true' : 'false');
11697
+ badge.title = open ? 'Fold the repeated calls' : `Show all ${group.length} calls`;
11698
+ const hdr = first.querySelector('.tool-hdr');
11699
+ if (hdr) hdr.insertBefore(badge, hdr.querySelector(':scope > .tool-chevron'));
11700
+ if (!open) for (let i = 1; i < group.length; i++) group[i].classList.add('cp-mcp-collapsed');
11553
11701
  group = [];
11554
11702
  };
11555
11703
  // True if `c` is the next tool-card sibling after `prev` (same parent, only