synabun 2.4.2 → 2.4.4

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 (220) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +1 -1
  3. package/docs/browser-extension-bridge.md +83 -34
  4. package/lib/release-npm-ci.mjs +23 -1
  5. package/mcp-server/dist/http.d.ts.map +1 -1
  6. package/mcp-server/dist/http.js +8 -1
  7. package/mcp-server/dist/http.js.map +1 -1
  8. package/mcp-server/dist/services/identity.d.ts +2 -0
  9. package/mcp-server/dist/services/identity.d.ts.map +1 -1
  10. package/mcp-server/dist/services/identity.js +4 -0
  11. package/mcp-server/dist/services/identity.js.map +1 -1
  12. package/mcp-server/dist/services/memory-client.d.ts +5 -0
  13. package/mcp-server/dist/services/memory-client.d.ts.map +1 -1
  14. package/mcp-server/dist/services/memory-client.js +21 -2
  15. package/mcp-server/dist/services/memory-client.js.map +1 -1
  16. package/mcp-server/dist/services/memory-writer.d.ts +3 -0
  17. package/mcp-server/dist/services/memory-writer.d.ts.map +1 -1
  18. package/mcp-server/dist/services/memory-writer.js +7 -1
  19. package/mcp-server/dist/services/memory-writer.js.map +1 -1
  20. package/mcp-server/dist/services/neural-interface.d.ts +11 -1
  21. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  22. package/mcp-server/dist/services/neural-interface.js +68 -18
  23. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  24. package/mcp-server/dist/services/typesafe-config.d.ts +38 -2
  25. package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
  26. package/mcp-server/dist/services/typesafe-config.js +260 -8
  27. package/mcp-server/dist/services/typesafe-config.js.map +1 -1
  28. package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
  29. package/mcp-server/dist/tools/agents.d.ts +3 -1
  30. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  31. package/mcp-server/dist/tools/agents.js +11 -6
  32. package/mcp-server/dist/tools/agents.js.map +1 -1
  33. package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -1
  34. package/mcp-server/dist/tools/browser-extension-setup.js +8 -2
  35. package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -1
  36. package/mcp-server/dist/tools/browser-observe.d.ts +11 -0
  37. package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
  38. package/mcp-server/dist/tools/browser-observe.js +113 -27
  39. package/mcp-server/dist/tools/browser-observe.js.map +1 -1
  40. package/mcp-server/dist/tools/browser-readers.d.ts +6 -0
  41. package/mcp-server/dist/tools/browser-readers.d.ts.map +1 -0
  42. package/mcp-server/dist/tools/browser-readers.js +17 -0
  43. package/mcp-server/dist/tools/browser-readers.js.map +1 -0
  44. package/mcp-server/dist/tools/remember.d.ts.map +1 -1
  45. package/mcp-server/dist/tools/remember.js +6 -2
  46. package/mcp-server/dist/tools/remember.js.map +1 -1
  47. package/mcp-server/dist/tools/youtube/analytics.d.ts +4 -0
  48. package/mcp-server/dist/tools/youtube/analytics.d.ts.map +1 -1
  49. package/mcp-server/dist/tools/youtube/analytics.js +25 -20
  50. package/mcp-server/dist/tools/youtube/analytics.js.map +1 -1
  51. package/mcp-server/dist/tools/youtube/helpers.d.ts +5 -1
  52. package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
  53. package/mcp-server/dist/tools/youtube/helpers.js +7 -3
  54. package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
  55. package/mcp-server/dist/tools/youtube/navigate.d.ts +2 -0
  56. package/mcp-server/dist/tools/youtube/navigate.d.ts.map +1 -1
  57. package/mcp-server/dist/tools/youtube/navigate.js +5 -3
  58. package/mcp-server/dist/tools/youtube/navigate.js.map +1 -1
  59. package/mcp-server/dist/tools/youtube/playlist.js +2 -2
  60. package/mcp-server/dist/tools/youtube/playlist.js.map +1 -1
  61. package/mcp-server/dist/tools/youtube/readers.d.ts +4 -0
  62. package/mcp-server/dist/tools/youtube/readers.d.ts.map +1 -0
  63. package/mcp-server/dist/tools/youtube/readers.js +15 -0
  64. package/mcp-server/dist/tools/youtube/readers.js.map +1 -0
  65. package/mcp-server/package-lock.json +5 -5
  66. package/mcp-server/package.json +1 -1
  67. package/mcp-server/src/http.ts +8 -1
  68. package/mcp-server/src/services/identity.ts +5 -0
  69. package/mcp-server/src/services/memory-client.ts +32 -12
  70. package/mcp-server/src/services/memory-writer.ts +5 -2
  71. package/mcp-server/src/services/neural-interface.ts +66 -19
  72. package/mcp-server/src/services/typesafe-config.ts +268 -7
  73. package/mcp-server/src/tools/agents.ts +12 -6
  74. package/mcp-server/src/tools/browser-extension-setup.ts +8 -2
  75. package/mcp-server/src/tools/browser-observe.ts +117 -28
  76. package/mcp-server/src/tools/browser-readers.ts +19 -0
  77. package/mcp-server/src/tools/remember.ts +6 -1
  78. package/mcp-server/src/tools/youtube/analytics.ts +26 -28
  79. package/mcp-server/src/tools/youtube/helpers.ts +8 -2
  80. package/mcp-server/src/tools/youtube/navigate.ts +6 -7
  81. package/mcp-server/src/tools/youtube/playlist.ts +2 -2
  82. package/mcp-server/src/tools/youtube/readers.ts +15 -0
  83. package/neural-interface/i18n/en.json +189 -1
  84. package/neural-interface/i18n/pt-BR.json +196 -8
  85. package/neural-interface/lib/assistant-api.js +123 -0
  86. package/neural-interface/lib/assistant-brains/claude.js +10 -0
  87. package/neural-interface/lib/assistant-brains/opencode.js +121 -7
  88. package/neural-interface/lib/assistant-dispatch.js +302 -44
  89. package/neural-interface/lib/assistant-envelope.js +40 -0
  90. package/neural-interface/lib/assistant-memory.js +3 -1
  91. package/neural-interface/lib/assistant-persona.js +6 -0
  92. package/neural-interface/lib/assistant-router.js +18 -8
  93. package/neural-interface/lib/assistant-runtime.js +182 -11
  94. package/neural-interface/lib/assistant-task-prompt.js +15 -2
  95. package/neural-interface/lib/browser-connection-state.js +20 -0
  96. package/neural-interface/lib/browser-extension-adapter.js +221 -17
  97. package/neural-interface/lib/browser-extension-archive.js +149 -0
  98. package/neural-interface/lib/browser-extension-bridge.js +46 -10
  99. package/neural-interface/lib/browser-extension-folder.js +635 -76
  100. package/neural-interface/lib/browser-extension-package.js +201 -0
  101. package/neural-interface/lib/browser-extension-pin.js +84 -0
  102. package/neural-interface/lib/browser-extension-pin.json +35 -0
  103. package/{browser-extension/protocol.js → neural-interface/lib/browser-extension-protocol.js} +111 -13
  104. package/neural-interface/lib/browser-extension-setup.js +108 -19
  105. package/neural-interface/lib/browser-extension-update.js +104 -0
  106. package/neural-interface/lib/browser-extraction.js +38 -14
  107. package/neural-interface/lib/claude-bg-tasks.js +183 -0
  108. package/neural-interface/lib/claude-history.js +12 -1
  109. package/neural-interface/lib/cli-install.js +23 -3
  110. package/neural-interface/lib/cli-update-planner.js +67 -4
  111. package/neural-interface/lib/confined-fs.js +25 -0
  112. package/neural-interface/lib/coordination/operations.js +2 -0
  113. package/neural-interface/lib/db.js +39 -16
  114. package/neural-interface/lib/editor-completion-opencode.js +2 -2
  115. package/neural-interface/lib/git-bash/manager.js +28 -3
  116. package/neural-interface/lib/git-status-runner.js +31 -3
  117. package/neural-interface/lib/loop-inventory.js +162 -0
  118. package/neural-interface/lib/loop-stall.js +74 -4
  119. package/neural-interface/lib/memory-session-capture.js +157 -66
  120. package/neural-interface/lib/native-loop-providers.js +82 -13
  121. package/neural-interface/lib/native-loop-runtime.js +23 -2
  122. package/neural-interface/lib/opencode-protocol.js +4 -2
  123. package/neural-interface/lib/opencode-shell-read.js +107 -0
  124. package/neural-interface/lib/opencode-stop-failures.js +40 -0
  125. package/neural-interface/lib/opencode-turn-release.js +173 -0
  126. package/neural-interface/lib/opencode-v2-client.js +4 -1
  127. package/neural-interface/lib/opencode-v2-ws-requests.js +34 -0
  128. package/neural-interface/lib/opencode2-client.js +341 -6
  129. package/neural-interface/lib/opencode2-translate.js +161 -4
  130. package/neural-interface/lib/peer-identity.js +62 -16
  131. package/neural-interface/lib/session-cache-builder.js +66 -18
  132. package/neural-interface/lib/session-capture-gate.js +42 -0
  133. package/neural-interface/lib/session-indexer.js +28 -20
  134. package/neural-interface/lib/teams/scheduler.js +3 -2
  135. package/neural-interface/lib/terminal-token-redaction.js +83 -0
  136. package/neural-interface/lib/ui-blob-api.js +14 -5
  137. package/neural-interface/lib/ui-blob-store.js +302 -39
  138. package/neural-interface/lib/whatsapp/bridge.js +52 -6
  139. package/neural-interface/package-lock.json +5 -5
  140. package/neural-interface/package.json +1 -1
  141. package/neural-interface/public/extension-setup.html +6 -2
  142. package/neural-interface/public/shared/agy/agy-panel.js +38 -10
  143. package/neural-interface/public/shared/assistant/asst-agents-dock.js +4 -0
  144. package/neural-interface/public/shared/assistant/asst-api.js +67 -0
  145. package/neural-interface/public/shared/assistant/asst-composer.js +85 -12
  146. package/neural-interface/public/shared/assistant/asst-panel.js +354 -11
  147. package/neural-interface/public/shared/assistant/asst-rack-styles.js +23 -0
  148. package/neural-interface/public/shared/assistant/asst-render.js +343 -10
  149. package/neural-interface/public/shared/assistant/asst-scenes.js +12 -0
  150. package/neural-interface/public/shared/assistant/asst-shell-logic.js +200 -0
  151. package/neural-interface/public/shared/assistant/asst-shell.js +111 -0
  152. package/neural-interface/public/shared/assistant/asst-sidepanel.js +18 -1
  153. package/neural-interface/public/shared/assistant/asst-state.js +241 -2
  154. package/neural-interface/public/shared/assistant/asst-steer.js +294 -0
  155. package/neural-interface/public/shared/assistant/asst-styles.js +21 -0
  156. package/neural-interface/public/shared/bg-tasks/bg-tasks-claude.js +147 -0
  157. package/neural-interface/public/shared/bg-tasks/bg-tasks-model.js +527 -0
  158. package/neural-interface/public/shared/bg-tasks/bg-tasks-panel.js +161 -0
  159. package/neural-interface/public/shared/bg-tasks/bg-tasks-view.js +508 -0
  160. package/neural-interface/public/shared/browser-extension-updates.js +88 -0
  161. package/neural-interface/public/shared/cdx/cdx-tabs.js +25 -0
  162. package/neural-interface/public/shared/cp/cp-bg-tasks.js +130 -0
  163. package/neural-interface/public/shared/extension-setup/es-page.js +25 -12
  164. package/neural-interface/public/shared/extension-setup/es-view.js +25 -10
  165. package/neural-interface/public/shared/extension-update-view.js +34 -0
  166. package/neural-interface/public/shared/mtc/mtc-panel.js +17 -2
  167. package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +5 -0
  168. package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +1 -0
  169. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +34 -2
  170. package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +7 -1
  171. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +26 -1
  172. package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +39 -6
  173. package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +20 -1
  174. package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-block.js +165 -0
  175. package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-logic.js +350 -0
  176. package/neural-interface/public/shared/ocp-v2/ocp-v2-shell.js +108 -0
  177. package/neural-interface/public/shared/ocp-v2/ocp-v2-state.js +49 -3
  178. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +40 -0
  179. package/neural-interface/public/shared/ocp-v2/ocp-v2-tools-logic.js +20 -5
  180. package/neural-interface/public/shared/ocp-v2/ocp-v2-tools.js +7 -1
  181. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +7 -2
  182. package/neural-interface/public/shared/settings/settings-browser-extension.js +61 -13
  183. package/neural-interface/public/shared/settings/settings-extension-update.js +114 -0
  184. package/neural-interface/public/shared/shell-stop-view.js +83 -0
  185. package/neural-interface/public/shared/styles.css +4 -0
  186. package/neural-interface/public/shared/tour/tour-actor.js +14 -3
  187. package/neural-interface/public/shared/tray-auto-close.js +36 -6
  188. package/neural-interface/public/shared/ui-claude-panel.js +130 -1
  189. package/neural-interface/public/shared/ui-native-loop-router.js +45 -3
  190. package/neural-interface/public/shared/ui-notifications.js +23 -4
  191. package/neural-interface/public/shared/ui-scroll-follow.js +4 -0
  192. package/neural-interface/public/shared/ui-settings-entry.js +6 -0
  193. package/neural-interface/public/shared/ui-tray-columns.js +9 -2
  194. package/neural-interface/public/shared/worker-end.js +18 -0
  195. package/neural-interface/scripts/patch-node-pty.mjs +151 -0
  196. package/neural-interface/scripts/rebuild-pty.js +10 -0
  197. package/neural-interface/server.js +725 -308
  198. package/npm-shrinkwrap.json +5 -5
  199. package/package.json +1 -2
  200. package/browser-extension/content.js +0 -231
  201. package/browser-extension/engine.js +0 -658
  202. package/browser-extension/icons/icon-128.png +0 -0
  203. package/browser-extension/icons/icon-16.png +0 -0
  204. package/browser-extension/icons/icon-32.png +0 -0
  205. package/browser-extension/icons/icon-48.png +0 -0
  206. package/browser-extension/icons/status-off-16.png +0 -0
  207. package/browser-extension/icons/status-off-32.png +0 -0
  208. package/browser-extension/icons/status-off-48.png +0 -0
  209. package/browser-extension/icons/status-on-16.png +0 -0
  210. package/browser-extension/icons/status-on-32.png +0 -0
  211. package/browser-extension/icons/status-on-48.png +0 -0
  212. package/browser-extension/manifest.json +0 -58
  213. package/browser-extension/popup-strings.js +0 -250
  214. package/browser-extension/popup-view.js +0 -151
  215. package/browser-extension/popup.css +0 -166
  216. package/browser-extension/popup.html +0 -108
  217. package/browser-extension/popup.js +0 -359
  218. package/browser-extension/service-worker.js +0 -283
  219. package/browser-extension/setup-content.js +0 -36
  220. package/browser-extension/tokens.css +0 -326
@@ -30,7 +30,7 @@ import { fetchToolCatalog } from '../agent-runtime-options.js';
30
30
  import { emit, on, state as appState } from '../state.js';
31
31
  import { storage } from '../storage.js';
32
32
  import { KEYS } from '../constants.js';
33
- import { t } from '../i18n.js';
33
+ import { getLocale, t } from '../i18n.js';
34
34
  // The account words of the brain picker and the accounts manager (account-view.js) in the page's language.
35
35
  // Here, not in those modules: node tests load them, and i18n.js reads the page's storage.
36
36
  import '../account-i18n.js';
@@ -60,6 +60,9 @@ import { createRovingToolbar } from './asst-roving.js';
60
60
  import { openAccountsManager } from './asst-accounts.js';
61
61
  import { createAgentsDock } from './asst-agents-dock.js';
62
62
  import { activityOf } from './asst-scenes.js';
63
+ import { steerBreakBefore, steerNoticeText, steerTranslator } from './asst-state.js'; // steer's boot part (asst-steer.js loads on demand: steerModule)
64
+ import { registerLaunchPrefetch } from '../launch-prefetch.js';
65
+ import { createLazyModule } from '../lazy-module.js';
63
66
  import { createUsageGauge } from './asst-usage.js';
64
67
  import { closeMenu, currentMenuAnchor, isMenuOpen, openMenu } from './asst-menu.js';
65
68
  import { createRouteModeControl, openModelsManager, openRoutesEditor, refreshModelsManager, renderRouteCard, routeModeLabel } from './asst-route.js';
@@ -67,17 +70,18 @@ import { prewarmRoutesEditor } from './asst-route-models.js';
67
70
  import { budgetChipText, budgetSpendText, budgetTone, closeBudgetEditor, createBudgetController, mountBudgetChip, openBudgetEditor } from './asst-budget.js';
68
71
  import { computerRemoteView, createComputerPanel, createComputerToggle, normalizeComputerRemote, openFrameLightbox, closeFrameLightbox, requestDesktopStatus, requestDesktopStop } from './asst-computer.js';
69
72
  import {
70
- applyLimit, applyLimitPacket, applyUsagePacket, BRAIN_PROVIDERS, brainLabel, createRenameWriter, createTabState, DEFAULT_ROUTE_MODE, deserializeTabState, fmtCost, fmtRunLine, limitExpiresIn, limitNoticeText, modelShortName,
73
+ applyLimit, applyLimitPacket, applyUsagePacket, usagePacketValid, BRAIN_PROVIDERS, brainLabel, createRenameWriter, createTabState, DEFAULT_ROUTE_MODE, deserializeTabState, fmtCost, fmtRunLine, limitExpiresIn, limitNoticeText, modelShortName,
71
74
  brainModePatch, isBrainProvider, normalizeBrain, normalizeComputerMode, permissionModeLabel, normalizeRouteMode, normalizeTestDensity, projectLabel, providerMeta, providerShortLabel, readStoredBrain, runFromPayload,
72
75
  serializeTabState, sessionStatus, slashBrainEffort, tabStorageKey, userSessionTitle, conversationCanWait,
73
76
  } from './asst-state.js';
74
77
  import { idleQueue } from '../idle-queue.js';
78
+ import { listAssistantBackgroundTasks, readAssistantBackgroundOutput, stopAssistantBackgroundTask } from './asst-api.js';
75
79
  import { watchTranscriptRows } from '../transcript-rows.js';
76
80
  import { createMarkSettle } from './asst-motion-gate.js';
77
81
  import {
78
82
  closeAssistantSession, dispatchAssistantRun, escalateAssistantRun, focusAssistantRun, getAssistantRun,
79
83
  fetchManageCatalog, getAssistantRunResult, getAssistantSession, getAssistantSessionUsage, getRouting, killAllAssistantRuns, removeAssistantRun, clearFinishedAssistantRuns,
80
- listAssistantSessions, patchAssistantSession, patchHiddenModels, setAdminSandbox, stopAssistantRun, uploadAssistantAttachment,
84
+ listAssistantSessions, patchAssistantSession, patchHiddenModels, setAdminSandbox, stopAssistantRun, uploadAssistantAttachment, readAssistantShellOutput,
81
85
  } from './asst-api.js';
82
86
 
83
87
  const ICON_SESSIONS = '<svg viewBox="0 0 24 24"><path d="M3 6h18M3 12h18M3 18h12"/></svg>';
@@ -90,6 +94,17 @@ const ICON_CLOSE = '<svg viewBox="0 0 24 24"><line x1="18" y1="6" x2="6" y2="18"
90
94
  const ICON_TRASH = '<svg viewBox="0 0 24 24"><path d="M3 6h18M8 6V4.5A1.5 1.5 0 0 1 9.5 3h5A1.5 1.5 0 0 1 16 4.5V6M18.5 6l-.8 13a2 2 0 0 1-2 1.9H8.3a2 2 0 0 1-2-1.9L5.5 6M10 11v6M14 11v6"/></svg>';
91
95
  const REPLAY_WAIT_MS = 1500; // a replay that stops short of its count is drawn after this long
92
96
 
97
+ // Steer's controller and its POST (asst-steer.js) load in an idle moment after the page is shown or at the first
98
+ // steer, whichever comes first (lazy-module.js), so the page does not wait for them at boot; what the panel draws
99
+ // with from the first frame is in asst-state.js. A browser keeps a failed module address failed for the life of the
100
+ // page (a server restart can refuse the idle load), so a later attempt asks under a new address.
101
+ let steerAttempts = 0;
102
+ const steerModule = createLazyModule(() => {
103
+ const attempt = steerAttempts++;
104
+ return attempt ? import(`./asst-steer.js?retry=${attempt}`) : import('./asst-steer.js');
105
+ }, { name: 'Assistant steer' });
106
+ if (typeof document !== 'undefined') registerLaunchPrefetch('assistant-steer', () => steerModule.load(), { order: 17 });
107
+
93
108
  function el(tag, className, text) {
94
109
  const node = document.createElement(tag);
95
110
  if (className) node.className = className;
@@ -223,6 +238,7 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
223
238
  <div class="asst-bar-group" data-group="computer"></div>
224
239
  </div>
225
240
  <div class="asst-bar-right">
241
+ <button type="button" class="asst-iconbtn asst-act-bgtasks" hidden aria-pressed="false" data-tooltip="${esc(tt('bgTasks.toggle', 'Background tasks'))}" aria-label="${esc(tt('bgTasks.toggle', 'Background tasks'))}"><svg viewBox="0 0 24 24"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg></button>
226
242
  <button type="button" class="asst-iconbtn asst-act-agents" hidden aria-pressed="false" data-tooltip="${esc(tt('assistant.topbar.agents', 'Dispatched agents'))}" aria-label="${esc(tt('assistant.topbar.agents', 'Dispatched agents'))}">${ICON_AGENTS}<span class="asst-count">0</span></button>
227
243
  <button type="button" class="asst-cost" hidden aria-label="${esc(tt('assistant.budget.title', 'Budget'))}"></button>
228
244
  <button type="button" class="asst-iconbtn asst-act-sessions" data-tooltip="${esc(tt('assistant.topbar.sessions', 'Sessions'))}" aria-label="${esc(tt('assistant.topbar.sessions', 'Sessions'))}" aria-haspopup="menu" aria-expanded="false">${ICON_SESSIONS}</button>
@@ -252,12 +268,88 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
252
268
  const announcer = root.querySelector('.asst-announce');
253
269
  const agentsBtn = root.querySelector('.asst-act-agents');
254
270
  const agentsCount = agentsBtn.querySelector('.asst-count');
271
+ const bgBtn = root.querySelector('.asst-act-bgtasks');
255
272
  const sessionsBtn = root.querySelector('.asst-act-sessions');
256
273
  const newBtn = root.querySelector('.asst-act-new');
257
274
  const moreBtn = root.querySelector('.asst-act-more');
258
275
  // Every bar element is held above: from here on the bar may live outside the root.
259
276
  if (host.toolbarSlot) host.toolbarSlot.appendChild(barEl);
260
277
 
278
+ // ── Background tasks (public/shared/bg-tasks/): the Claude brain's background shells and watches ──
279
+ // The view takes the transcript's place in the panel; the bar's toggle and the host's pill carry "⟳ N".
280
+ // Its modules load on first use, for a Claude brain only: never before the page is shown
281
+ // (tests/boot-critical-path.test.mjs). Events that arrive while they load wait in order.
282
+ let bg = null;
283
+ let bgLoad = null;
284
+ let bgPending = [];
285
+ let bgScroll = 0;
286
+ let paintBadge = null;
287
+ const bgClaude = () => (st.brain?.provider || 'claude-code') === 'claude-code';
288
+ function ensureBg() {
289
+ if (bg || destroyed) return Promise.resolve(bg);
290
+ bgLoad ||= Promise.all([import('../bg-tasks/bg-tasks-panel.js'), import('../bg-tasks/bg-tasks-claude.js'), import('../bg-tasks/bg-tasks-view.js'), import('../cp/cp-bg-tasks.js')])
291
+ .then(([panelMod, claudeMod, viewMod, cpMod]) => {
292
+ if (destroyed) return null;
293
+ paintBadge = viewMod.paintBgBadge;
294
+ bg = panelMod.createBgTasksPanel({
295
+ key: `assistant:${sessionId}`,
296
+ factsOf: (ev) => (bgClaude() ? claudeMod.claudeFactsFromEvent(ev) : []),
297
+ liveFactOf: (tasks) => claudeMod.claudeLiveFact(tasks),
298
+ storage,
299
+ t,
300
+ overlay: false,
301
+ api: {
302
+ list: () => listAssistantBackgroundTasks(sessionId),
303
+ output: ({ taskId, cursor, tail, limit }) => readAssistantBackgroundOutput(sessionId, { taskId, cursor, tail, limit }),
304
+ stop: (taskId) => stopAssistantBackgroundTask(sessionId, taskId),
305
+ },
306
+ onChange: () => paintBgButton(),
307
+ onShownChange: (shown) => {
308
+ // In place of the transcript: the transcript keeps its place for when the view closes.
309
+ if (shown) { bgScroll = transcriptEl.scrollTop; transcriptEl.hidden = true; }
310
+ else { transcriptEl.hidden = false; transcriptEl.scrollTop = bgScroll; }
311
+ paintBgButton();
312
+ },
313
+ });
314
+ cpMod.wireNoticeCardClicks(transcriptEl, (taskId) => openBg(taskId));
315
+ const pending = bgPending;
316
+ bgPending = [];
317
+ for (const ev of pending) feedBg(ev);
318
+ return bg;
319
+ })
320
+ .catch(() => { bgLoad = null; return null; });
321
+ return bgLoad;
322
+ }
323
+ /** One live event of the brain: its facts, and a task's report as a card. */
324
+ function feedBg(ev) {
325
+ if (!bg) { if (bgPending.length < 500) bgPending.push(ev); ensureBg(); return; }
326
+ let cards = [];
327
+ try { cards = bg.onEvent(ev); } catch { cards = []; }
328
+ for (const { view } of cards) if (view) renderer.appendNode(bg.card(view));
329
+ }
330
+ const bgRelevant = (ev) => ev.type === 'assistant' || ev.type === 'user'
331
+ || (ev.type === 'system' && (String(ev.subtype || '').startsWith('task_') || ev.subtype === 'background_tasks_changed'));
332
+ function rebuildBg() { if (bgClaude()) ensureBg().then((b) => b?.rebuild()).catch(() => {}); }
333
+ function paintBgButton() {
334
+ if (destroyed || !bg) return;
335
+ const counts = bg.counts();
336
+ const open = bg.isShown();
337
+ bgBtn.hidden = !counts.total && !open;
338
+ bgBtn.classList.toggle('active', open);
339
+ bgBtn.setAttribute('aria-pressed', String(open));
340
+ paintBadge?.(bgBtn, counts.running, { t, corner: true, onClick: () => toggleBg() });
341
+ try { host.setBackgroundTasks?.(counts.running, () => openBg()); } catch { /* an older host */ }
342
+ }
343
+ function openBg(taskId = null) {
344
+ if (!bg) return;
345
+ bg.show(root, taskId);
346
+ // Right where the transcript is (the host appends it last).
347
+ const view = root.querySelector(':scope > .sbt-view');
348
+ if (view && view.previousElementSibling !== transcriptEl) transcriptEl.after(view);
349
+ }
350
+ function toggleBg() { if (!bg) return; if (bg.isShown()) bg.hide(); else openBg(); }
351
+ bgBtn.addEventListener('click', () => toggleBg());
352
+
261
353
  // ── Helpers ──
262
354
  // A worker-only provider provider-icons.js does not know yet keeps its own name (asst-state.js providerMeta).
263
355
  const providerIcon = (p) => providerMeta(p).icon;
@@ -534,8 +626,45 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
534
626
  || (c.contains('asst-rack') && (row.dataset.state !== 'settled' || c.contains('is-folding')));
535
627
  },
536
628
  });
629
+ // The shell commands of an OpenCode brain: what they are comes over the socket, what they print is read in
630
+ // pages only while a block shows it (asst-shell-logic.js). Display data, in this tab only. Its modules load with
631
+ // the first command, so a tab of another brain, and the app's first paint, never pay for them.
632
+ let shellTracker = null;
633
+ let shellParts = null; // { logic, block } once loaded
634
+ let shellLoading = null;
635
+ let shellsListed = false; // this server tells commands (it sends the list on every attach)
636
+ let shellPackets = [];
637
+ function applyShellPacket(packet) {
638
+ if (packet.type === 'assistant:shell') shellTracker.apply(packet.shell);
639
+ else shellTracker.applyList(packet.shells);
640
+ }
641
+ function receiveShellPacket(packet) {
642
+ shellsListed = true;
643
+ if (shellTracker) { applyShellPacket(packet); return; }
644
+ if (packet.type === 'assistant:shells' && !packet.shells?.length && !shellLoading) return;
645
+ shellPackets.push(packet);
646
+ shellLoading ||= Promise.all([import('./asst-shell-logic.js'), import('./asst-shell.js')]).then(([logic, block]) => {
647
+ if (destroyed) return;
648
+ shellParts = { logic, block };
649
+ shellTracker = logic.createShellTracker({ read: (args) => readAssistantShellOutput(sessionId, args) });
650
+ shellTracker.onChange((shell) => renderer.noteShell(shell));
651
+ const waiting = shellPackets;
652
+ shellPackets = [];
653
+ for (const held of waiting) applyShellPacket(held);
654
+ }).catch((error) => { shellLoading = null; shellPackets = []; console.warn('[assistant] the terminal block did not load', error); });
655
+ }
537
656
  const renderer = createRenderer(transcriptEl, {
538
657
  t,
658
+ // A steer read from the journal: "Interrupted.", the break and the notice, as the live view drew them.
659
+ onSteerEntry: (steer) => steerEntry(steer),
660
+ shells: {
661
+ forCall: (id) => shellTracker?.forCall(id) || null,
662
+ view: (id) => shellTracker?.view(id) || null,
663
+ label: (shell) => shellParts?.logic.shellStateLabel(shell, tt) || '',
664
+ failedLate: (shell) => !!shellParts?.logic.shellFailedLate(shell),
665
+ supported: () => shellsListed,
666
+ terminal: (id, callbacks) => shellParts.block.mountShellTerminal(shellTracker, id, { t: tt, ...callbacks }),
667
+ },
539
668
  providerIcon,
540
669
  providerColor,
541
670
  copy: clipCopy,
@@ -543,6 +672,10 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
543
672
  onStopRun: (runId) => stopRun(runId),
544
673
  onReadRun: (runId) => readRun(runId),
545
674
  onEscalateRun: (runId, target) => escalateRun(runId, target),
675
+ // Steer (asst-steer.js): the card's one-line input, or the composer's target chip.
676
+ onSteerRun: (runId, text) => steerRunFromCard(runId, text),
677
+ onSteerRunInComposer: (runId, text) => steerTargetFromCard(runId, text),
678
+ locale: () => getLocale(),
546
679
  onMemoryClick: (id) => { if (id) emit('memory:open', { id }); },
547
680
  onMotionMark: (el) => { markSettle.hold(transcriptRowOf(el)); },
548
681
  onRackFolded: (row) => { rowWatcher.reconsider(row); },
@@ -644,6 +777,7 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
644
777
  onToast: toast,
645
778
  onRemoveQueued: (idx) => { if (idx >= 0) { st.queue.splice(idx, 1); composer.setQueue(st.queue); } },
646
779
  onSubmit: (payload) => submit(payload),
780
+ locale: () => getLocale(),
647
781
  // Files that do not go inline: saved on the server, the prompt carries the path.
648
782
  uploadFile: (file, opts) => uploadAssistantAttachment(file, { ...opts, sessionId }),
649
783
  });
@@ -740,6 +874,9 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
740
874
  onStop: (runId) => stopRun(runId),
741
875
  onRead: (runId) => readRun(runId),
742
876
  onEscalate: (runId, target) => escalateRun(runId, target),
877
+ onSteer: (runId, text) => steerRunFromCard(runId, text),
878
+ onSteerInComposer: (runId, text) => steerTargetFromCard(runId, text),
879
+ locale: () => getLocale(),
743
880
  onStopAll: () => stopAll(),
744
881
  onRemove: (runId) => removeRun(runId),
745
882
  onClearFinished: () => clearFinished(),
@@ -791,19 +928,20 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
791
928
  }).catch(() => { /* older servers do not expose usage */ });
792
929
  }
793
930
  function applyUsage(packet) {
794
- if (packet?.sessionId === sessionId && (!packet.task?.id || !Number.isSafeInteger(packet.task?.tokens?.total) || packet.task.tokens.total < 0)) {
931
+ if (packet?.sessionId === sessionId && !usagePacketValid(packet)) {
795
932
  if (!usageWarned) { console.warn('[assistant] invalid usage packet'); usageWarned = true; }
796
933
  return;
797
934
  }
798
935
  const was = st.usageView;
799
936
  if (!applyUsagePacket(st, packet)) return;
800
937
  if (!usage.apply(st.usageView)) { st.usageView = was; return; }
801
- for (const agent of st.usageView.task.agents || []) {
938
+ for (const agent of st.usageView.task?.agents || []) {
802
939
  if (agent.scope !== 'run' || !agent.runId) continue;
803
940
  const tokens = agent.tokens || null;
804
941
  const fidelity = agent.fidelity || st.usageView.task.fidelity;
805
942
  dock.patchUsageRun(agent.runId, tokens, fidelity);
806
943
  renderer.patchRunUsage(agent.runId, tokens, fidelity);
944
+ if (Number.isSafeInteger(tokens?.total)) steer.onRunTokens(agent.runId, tokens.total);
807
945
  }
808
946
  persist();
809
947
  }
@@ -878,6 +1016,11 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
878
1016
 
879
1017
  function handlePacket(packet) {
880
1018
  if (destroyed || !packet?.type) return;
1019
+ // A command's state is live state, never history: it is not one of the packets a reattach counted.
1020
+ if (packet.type === 'assistant:shell' || packet.type === 'assistant:shells') {
1021
+ if (!packet.sessionId || packet.sessionId === sessionId) receiveShellPacket(packet);
1022
+ return;
1023
+ }
881
1024
  if (replay && packet.type !== 'reattach_result') {
882
1025
  replay.packets.push(packet);
883
1026
  if ((replay.left -= 1) <= 0) flushReplay();
@@ -913,6 +1056,7 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
913
1056
  lockControl(packet.request_id, resolvedLabel(packet.origin, tt('assistant.control.state.answered', 'Answered')));
914
1057
  return;
915
1058
  case 'reattach_result':
1059
+ rebuildBg();
916
1060
  // Whether a turn runs now: a route the journal left open is that turn's, or nobody's.
917
1061
  renderer.reattached(!!(packet.ok && packet.running));
918
1062
  if (packet.ok) {
@@ -931,17 +1075,42 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
931
1075
  case 'stderr':
932
1076
  if (packet.text?.trim()) renderer.appendStatus(packet.text.trim());
933
1077
  return;
1078
+ case 'steered':
1079
+ // The brain's turn was cut by a steer (lib/assistant-runtime.js: { target: 'brain', text, at }): one notice
1080
+ // where it was cut (this window's own steer drew it already), from the journal too.
1081
+ steer.onSteered(packet);
1082
+ return;
934
1083
  case 'turn_started':
935
1084
  // The CLI began a turn on its own (a background agent finished, a
936
1085
  // scheduled wakeup fired); its `done` finishes it.
937
1086
  if (!st.running) setRunning(true);
938
1087
  return;
939
1088
  case 'done':
1089
+ renderer.clearStopFailure?.();
940
1090
  finishTurn({ aborted: false });
941
1091
  return;
942
1092
  case 'aborted':
1093
+ renderer.clearStopFailure?.();
943
1094
  finishTurn({ aborted: true });
944
1095
  return;
1096
+ case 'stop_failed':
1097
+ // Stop could not end a command in the background: the turn goes on (its Stop button too), and the panel
1098
+ // says which and why; from the second failure, "Stop anyway" ends the turn here. (The words load only now.)
1099
+ stopView().then((view) => {
1100
+ const failure = view?.describeStopFailure(packet, t);
1101
+ if (!failure) return;
1102
+ renderer.appendStopFailure(failure.message, failure.canForce
1103
+ ? { forceLabel: view.shellStopText('anyway', {}, t), onForce: () => sock.send({ type: 'abort', force: true }) }
1104
+ : {});
1105
+ announce(failure.message);
1106
+ });
1107
+ return;
1108
+ case 'stop_abandoned':
1109
+ stopView().then((view) => {
1110
+ const left = view?.describeAbandoned(packet.shells, t);
1111
+ if (left) renderer.appendStatus(left, 'warn');
1112
+ });
1113
+ return;
945
1114
  case 'error': {
946
1115
  // The server no longer has this session: no error row and no retry loop; the host closes the tab.
947
1116
  if (packet.code === 'SESSION_NOT_FOUND') { sessionGone(); return; }
@@ -972,6 +1141,7 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
972
1141
  applySessionMeta(packet.session || packet);
973
1142
  return;
974
1143
  case 'assistant:dispatch': {
1144
+ steer.onSteered(packet); // a 'steered' run event rides here too
975
1145
  const run = runFromPayload(packet);
976
1146
  if (run) { dock.upsertRun(run); renderer.upsertRunCard(dock.getRun(run.runId) || run); tip('run', () => renderer.getRunCard(run.runId)); }
977
1147
  return;
@@ -1013,6 +1183,8 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
1013
1183
  if (!ev?.type) return;
1014
1184
  // One registry for what is on screen (the renderer's): the journal snapshot registers there too.
1015
1185
  if (!renderer.claimEvent(ev)) return;
1186
+ // The Background tasks registry hears every live event; a replayed one is history (the rebuild reads it).
1187
+ if (!replaying && bgClaude() && bgRelevant(ev)) feedBg(ev);
1016
1188
  const draw = (event) => renderer.handleEvent(event, replaying ? { replay: true } : undefined);
1017
1189
  switch (ev.type) {
1018
1190
  case 'synabun.dispatch': {
@@ -1057,6 +1229,11 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
1057
1229
  case 'synabun.cost':
1058
1230
  applyCost(ev);
1059
1231
  return;
1232
+ case 'steered':
1233
+ case 'synabun.steered':
1234
+ // The brain's turn was cut by a steer (this window's, another's, WhatsApp's): one notice where it was cut.
1235
+ if (!replaying) steer.onSteered(ev);
1236
+ return;
1060
1237
  default:
1061
1238
  draw(ev);
1062
1239
  }
@@ -1507,6 +1684,147 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
1507
1684
  syncBlocked();
1508
1685
  }
1509
1686
 
1687
+ // ── Steer: redirect work under way (asst-steer.js) ──
1688
+ const steerT = steerTranslator(t, getLocale());
1689
+ let steerAvailable = true; // an older server answers without the route: then Enter while busy queues
1690
+ /** The kinds of the transcript rows above `row`, nearest first (steerBreakBefore reads them). */
1691
+ function rowKindsAbove(row, max = 6) {
1692
+ const kinds = [];
1693
+ for (let node = row?.previousElementSibling; node && kinds.length < max; node = node.previousElementSibling) {
1694
+ const c = node.classList;
1695
+ // The cut turn's own rows under its reply (its usage / automation line, a route line) are 'route'.
1696
+ kinds.push(c.contains('msg-assistant') ? 'assistant' : c.contains('asst-divider') ? 'divider' : c.contains('msg-user') ? 'user' : c.contains('asst-status') ? 'status' : c.contains('asst-route-line') ? 'route' : 'other');
1697
+ }
1698
+ return kinds;
1699
+ }
1700
+ /** "#2 Fix the login bug": the run as the tray numbers it. */
1701
+ function runLabelOf(run) {
1702
+ if (!run) return '';
1703
+ const index = dock.getRuns().findIndex((r) => r.runId === run.runId);
1704
+ const title = String(run.title || run.task || run.runId || '').replace(/\s+/g, ' ').trim().slice(0, 60);
1705
+ return index >= 0 ? `#${index + 1} ${title}` : title;
1706
+ }
1707
+ function steerNotice(text, { kind = 'steer', action = null, cut = false, quiet = false } = {}) {
1708
+ const row = renderer.appendStatus(text, kind === 'steer' ? 'info' : kind === 'error' ? 'error' : 'warn');
1709
+ if (!row) return null;
1710
+ // A steer that cut the Assistant's own reply: a break between that reply and what follows (asst-state.js).
1711
+ if (steerBreakBefore({ kind, cut, prevKinds: rowKindsAbove(row) })) {
1712
+ const rule = document.createElement('div');
1713
+ rule.className = 'asst-divider asst-steer-break';
1714
+ rule.setAttribute('role', 'separator');
1715
+ row.before(rule);
1716
+ }
1717
+ row.classList.add('asst-steer-notice');
1718
+ row.dataset.steer = kind;
1719
+ if (action?.label && typeof action.run === 'function') {
1720
+ const button = document.createElement('button');
1721
+ button.type = 'button';
1722
+ button.className = 'asst-btn asst-btn-secondary asst-steer-retry';
1723
+ button.textContent = action.label;
1724
+ button.addEventListener('click', async () => {
1725
+ button.disabled = true;
1726
+ const outcome = await action.run();
1727
+ if (outcome === false) button.disabled = false;
1728
+ else button.remove();
1729
+ });
1730
+ row.appendChild(button);
1731
+ }
1732
+ if (!quiet) announce(text);
1733
+ return row;
1734
+ }
1735
+ /** A steer read from the journal (asst-render.js drawSteer): what the live view drew for it, in the same order. */
1736
+ function steerEntry({ target = 'brain', runId = null, title = '', text = '', cut = false } = {}) {
1737
+ if (!String(text).trim()) return;
1738
+ if (target === 'run') {
1739
+ const run = runId ? dock.getRun(runId) : null;
1740
+ steerNotice(steerNoticeText(text, steerT, { run: runLabelOf(run) || String(title || runId || '').slice(0, 60) }), { kind: 'steer', quiet: true });
1741
+ return;
1742
+ }
1743
+ // The cut turn ended "Interrupted." live (its 'aborted' is not journaled), above that turn's usage / route lines;
1744
+ // a saved one there already is not drawn twice.
1745
+ if (cut) {
1746
+ const aborted = tt('assistant.status.aborted', 'Aborted.');
1747
+ const row = renderer.appendStatus(aborted);
1748
+ let above = row?.previousElementSibling || null;
1749
+ let firstRoute = null;
1750
+ while (above?.classList.contains('asst-route-line')) { firstRoute = above; above = above.previousElementSibling; }
1751
+ if (row && above?.classList.contains('asst-status') && String(above.textContent || '').trim() === aborted) row.remove();
1752
+ else if (row && firstRoute) firstRoute.before(row);
1753
+ }
1754
+ steerNotice(steerNoticeText(text, steerT), { kind: 'steer', cut, quiet: true });
1755
+ }
1756
+ // The controller is made once asst-steer.js has loaded (steerModule); until then `steer` waits for the load, and a
1757
+ // load that fails leaves the plain path: the words are sent, or queued behind the turn that runs.
1758
+ let steerCtl = null;
1759
+ const makeSteer = ({ createSteerController, postSteer }) => (steerCtl ||= createSteerController({
1760
+ t: steerT,
1761
+ sessionId: () => sessionId,
1762
+ isRunning: () => st.running,
1763
+ steerable: () => steerAvailable,
1764
+ setSteerable: (value) => { steerAvailable = value !== false; composer.setSteerable(steerAvailable); },
1765
+ post: (body) => postSteer(body),
1766
+ queue: (payload) => { st.queue.push(payload); composer.setQueue(st.queue); return 'queued'; },
1767
+ send: (payload) => (sendQuery(payload) ? 'sent' : false),
1768
+ promptText: (payload) => buildPromptText(payload),
1769
+ getRun: (runId) => dock.getRun(runId),
1770
+ runLabel: runLabelOf,
1771
+ patchRun: (runId, patch) => { const run = dock.patchRun(runId, patch); if (run) renderer.syncRun(run); return run; },
1772
+ setActivity: (runId, activity) => { renderer.setRunActivity(runId, activity); dock.setRunActivity(runId, activity); },
1773
+ notice: steerNotice,
1774
+ setTarget: (target, text = '') => {
1775
+ composer.setSteerTarget(target);
1776
+ if (target && text && !composer.getText().trim()) composer.setText(text);
1777
+ },
1778
+ focusComposer: () => composer.focus(),
1779
+ }));
1780
+ const steerNow = () => steerCtl || (steerModule.module ? makeSteer(steerModule.module) : null);
1781
+ const steerLoaded = () => steerModule.load().then(makeSteer);
1782
+ /** Run `fn(controller)` now when it is there, else after the load (in order); nothing when the load fails. */
1783
+ const withSteer = (fn) => {
1784
+ const ctl = steerNow();
1785
+ if (ctl) return fn(ctl);
1786
+ steerLoaded().then((c) => { if (!destroyed) fn(c); }, () => {});
1787
+ return undefined;
1788
+ };
1789
+ const steerUnavailable = (err) => steerNotice(steerT('failed', { error: err?.message || String(err || '?') }), { kind: 'error' });
1790
+ const steer = {
1791
+ async submit(payload) {
1792
+ let ctl = steerNow();
1793
+ if (!ctl) {
1794
+ try { ctl = await steerLoaded(); } catch (err) {
1795
+ if (payload.steerTarget?.runId) { steerUnavailable(err); return false; } // the words stay in the composer
1796
+ if (st.running) { st.queue.push(payload); composer.setQueue(st.queue); return 'queued'; }
1797
+ return sendQuery(payload) ? 'sent' : false;
1798
+ }
1799
+ }
1800
+ return ctl.submit(payload);
1801
+ },
1802
+ async steerRun(runId, text) {
1803
+ let ctl = steerNow();
1804
+ if (!ctl) { try { ctl = await steerLoaded(); } catch (err) { steerUnavailable(err); return false; } }
1805
+ return ctl.steerRun(runId, text);
1806
+ },
1807
+ targetRun: (runId, text, opts) => withSteer((ctl) => ctl.targetRun(runId, text, opts)),
1808
+ // Before the load nothing of this panel is marked steering: the packet is read once the controller is there.
1809
+ onSteered: (packet) => withSteer((ctl) => ctl.onSteered(packet)) === true,
1810
+ onTurnStarted: (runId) => withSteer((ctl) => ctl.onTurnStarted(runId)) === true,
1811
+ // Only a loaded controller has marked a run: before the load there is nothing to take away.
1812
+ onRunOutput: (runId, payload, activity) => steerNow()?.onRunOutput(runId, payload, activity) === true,
1813
+ onRunTokens: (runId, total) => steerNow()?.onRunTokens(runId, total) === true,
1814
+ };
1815
+ /** The card's one-line input: true when the steer went (the input closes). */
1816
+ async function steerRunFromCard(runId, text) {
1817
+ const outcome = await steer.steerRun(runId, text);
1818
+ const went = outcome === 'steered' || outcome === 'ended';
1819
+ if (went) composer.focus(); // the input closes: focus goes back to the composer
1820
+ return went;
1821
+ }
1822
+ /** The card hands its run to the composer: the next message steers it. */
1823
+ function steerTargetFromCard(runId, text = '') {
1824
+ const index = dock.getRuns().findIndex((r) => r.runId === runId);
1825
+ return steer.targetRun(runId, text, { index: index >= 0 ? index + 1 : null });
1826
+ }
1827
+
1510
1828
  // ── Sending ──
1511
1829
  function sendQuery(payload) {
1512
1830
  if (guestBlocked()) return false;
@@ -1555,11 +1873,9 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
1555
1873
  const handled = await runSlash(parsed, payload);
1556
1874
  return handled === false ? false : 'sent';
1557
1875
  }
1558
- if (st.running) {
1559
- st.queue.push(payload);
1560
- composer.setQueue(st.queue);
1561
- return 'queued';
1562
- }
1876
+ // Steer (asst-steer.js): Enter while a turn runs cuts it and sends now, a targeted run is steered,
1877
+ // Queue (Alt+Enter, or a server that cannot steer) waits for the turn as before.
1878
+ if (payload.mode || payload.steerTarget || st.running) return steer.submit(payload);
1563
1879
  return sendQuery(payload) ? 'sent' : false;
1564
1880
  }
1565
1881
 
@@ -1698,6 +2014,13 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
1698
2014
  }
1699
2015
  }
1700
2016
 
2017
+ // What a Stop that could not end a command says (public/shared/shell-stop-view.js), loaded on its first use.
2018
+ let stopViewLoad = null;
2019
+ function stopView() {
2020
+ stopViewLoad ||= import('../shell-stop-view.js').catch(() => { stopViewLoad = null; return null; });
2021
+ return stopViewLoad;
2022
+ }
2023
+
1701
2024
  function abort() {
1702
2025
  if (!st.running && !controls.size) return;
1703
2026
  sock.send({ type: 'abort' });
@@ -2242,6 +2565,10 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
2242
2565
  surfaces.forEach((node) => node.addEventListener('focusin', onFocusIn));
2243
2566
 
2244
2567
  // ── Bus ──
2568
+ // A panel banner has no transcript row, focus change, sound or effect on the running turn.
2569
+ if (!isGuest()) void import('../browser-extension-updates.js').then(({ watchExtensionUpdateMention }) => {
2570
+ if (!destroyed) unsubs.push(watchExtensionUpdateMention(t, (text, action) => banner('extension-update', text, { tone: 'info', action })));
2571
+ }).catch(error => console.warn('[assistant] Browser extension notice unavailable:', error.message));
2245
2572
  unsubs.push(on('sync:assistant:session-updated', (msg) => { const s = msg?.session || msg; if (s?.id === sessionId) applySessionMeta(s); }));
2246
2573
  unsubs.push(on('sync:assistant:budget', (msg) => { if ((msg?.assistantSessionId || msg?.sessionId) === sessionId) budgetController.receiveSession(msg.budget); }));
2247
2574
  unsubs.push(on('sync:assistant:budget-changed', () => budgetController.load()));
@@ -2275,12 +2602,26 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
2275
2602
  unsubs.push(on('sync:sidepanel:provider-event', (msg) => {
2276
2603
  const runId = msg?.run?.runId;
2277
2604
  if (!runId || !dock.getRun(runId)) return;
2605
+ // A steered run's next turn begins: "Steering…" goes, it works as usual.
2606
+ const evType = msg.event?.type;
2607
+ if (evType === 'turn_started' || evType === 'turn.started' || (evType === 'system' && msg.event?.subtype === 'init')) steer.onTurnStarted(runId);
2608
+ if (steer.onSteered(msg.event ? { ...msg.event, runId } : null)) return;
2278
2609
  const activity = activityOf(msg.event);
2610
+ // The steer's turn shows something (text, a call, thinking): "Steering…" goes.
2611
+ steer.onRunOutput(runId, msg.event, activity);
2279
2612
  if (!activity) return;
2280
2613
  const stamped = { ...activity, at: Date.now() };
2281
2614
  renderer.setRunActivity(runId, stamped);
2282
2615
  dock.setRunActivity(runId, stamped);
2283
2616
  }));
2617
+ // A run of this session steered (here, in another window, by the brain's agent_send steer:true): "Steering…" and
2618
+ // the notice, once. The run event may come on its own or inside a dispatch update.
2619
+ for (const name of ['sync:assistant:steered', 'sync:assistant:run-steered', 'sync:assistant:dispatch']) {
2620
+ unsubs.push(on(name, (msg) => {
2621
+ const owned = !msg?.assistantSessionId || msg.assistantSessionId === sessionId;
2622
+ if (owned) steer.onSteered(name === 'sync:assistant:dispatch' ? msg : { ...msg, type: 'steered' });
2623
+ }));
2624
+ }
2284
2625
  unsubs.push(on('sync:assistant:desktop', (msg) => computerPanel.applyDesktop(msg)));
2285
2626
  unsubs.push(on('sync:assistant:desktop-setup', (msg) => computerPanel.applySetup(msg)));
2286
2627
  // Models switched on/off elsewhere: the open Models manager reloads (the menus drop their cache on their own).
@@ -2450,16 +2791,18 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
2450
2791
  /** The session's status as its host shows it: the brain's own with its dispatched agents' (sessionStatus). */
2451
2792
  getStatus: () => st.shownStatus || 'idle',
2452
2793
  focus: () => composer.focus(),
2453
- onShown: () => { loadConversation(); syncTabLabel(); renderer.scrollEnd(true); if (visible()) composer.focus(); director.touch(); },
2794
+ onShown: () => { loadConversation(); syncTabLabel(); renderer.scrollEnd(true); if (visible()) composer.focus(); director.touch(); rebuildBg(); },
2454
2795
  /** The tab is wanted (shown, or about to be used): its conversation loads now instead of in idle time. */
2455
2796
  wake: () => loadConversation(),
2456
2797
  onHidden: () => { closeMenu(); picker.close(); director.stopTyping(); },
2457
2798
  counts: () => dock.counts(),
2458
2799
  destroy: ({ closeServer = false } = {}) => {
2459
2800
  if (destroyed) return;
2801
+ try { bg?.dispose({ forget: closeServer }); } catch { /* ignore */ }
2460
2802
  destroyed = true;
2461
2803
  cancelIdleLoad?.();
2462
2804
  cancelIdleLoad = null;
2805
+ shellTracker?.destroy();
2463
2806
  if (persistTimer) { clearTimeout(persistTimer); persistTimer = null; }
2464
2807
  clearTimeout(announceTimer);
2465
2808
  if (replay) { clearTimeout(replay.timer); replay = null; }
@@ -471,6 +471,29 @@ export const RACK_CSS = `
471
471
  .asst-rack .asst-station[data-kind="computer"]:not(.is-open) .asst-tool-body { display: none; }
472
472
  .asst-rack .asst-computer-frame { margin: 4px 0 2px 18px; }
473
473
 
474
+ /* ── A shell command's live output ──────────────────────────────── */
475
+ .asst-tool[data-shell="running"] > .asst-tool-hdr > .asst-tool-mark { color: var(--rk-gold); }
476
+ .asst-term { min-width: 0; margin-top: 6px; }
477
+ .asst-term-note { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 4px; color: var(--rk-text-3); font-size: 11px; line-height: 1.45; }
478
+ .asst-term > .asst-term-note { margin: 0 0 3px; }
479
+ .asst-term-note[hidden] { display: none; }
480
+ .asst-term-note-text { flex: 1 1 auto; min-width: 0; }
481
+ /* One text node, appended to: no wrapping to redo, its layout kept to itself, and the wheel stops at its ends. */
482
+ .asst-rack .asst-tool-section.asst-term-out {
483
+ max-height: 280px;
484
+ overflow: auto;
485
+ overscroll-behavior: contain;
486
+ contain: content;
487
+ white-space: pre;
488
+ overflow-wrap: normal;
489
+ tab-size: 8;
490
+ }
491
+ .asst-rack .asst-tool-section.asst-term-out[hidden] { display: none; }
492
+ .asst-term-foot { display: flex; align-items: center; gap: 4px; min-height: 22px; color: var(--rk-text-3); font-size: 11px; }
493
+ .asst-term-state { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
494
+ .asst-term-foot > .asst-copy { margin-left: 0; }
495
+ .asst-term-load, .asst-term-jump { flex: none; margin-top: 0; }
496
+
474
497
  .asst-tool-sec + .asst-tool-sec { margin-top: 6px; }
475
498
  .asst-tool-sec-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
476
499
  .asst-rack .asst-tool-label { margin: 0; color: var(--rk-text-3); font-size: 11px; letter-spacing: 0; text-transform: none; }