synabun 2.4.1 → 2.4.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 (295) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +1 -1
  3. package/browser-extension/content.js +56 -14
  4. package/browser-extension/engine.js +158 -8
  5. package/browser-extension/manifest.json +3 -1
  6. package/browser-extension/protocol.js +91 -6
  7. package/browser-extension/service-worker.js +13 -5
  8. package/browser-extension/tokens.css +1 -1
  9. package/docs/browser-extension-bridge.md +24 -4
  10. package/lib/data-home-files.js +4 -2
  11. package/lib/first-launch-protection.js +8 -2
  12. package/lib/update-snapshot.js +11 -4
  13. package/mcp-server/dist/http.d.ts.map +1 -1
  14. package/mcp-server/dist/http.js +25 -2
  15. package/mcp-server/dist/http.js.map +1 -1
  16. package/mcp-server/dist/index.d.ts.map +1 -1
  17. package/mcp-server/dist/index.js +62 -17
  18. package/mcp-server/dist/index.js.map +1 -1
  19. package/mcp-server/dist/services/browser-bench.d.ts +22 -22
  20. package/mcp-server/dist/services/memory-maintenance.d.ts +1 -0
  21. package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -1
  22. package/mcp-server/dist/services/memory-maintenance.js +34 -45
  23. package/mcp-server/dist/services/memory-maintenance.js.map +1 -1
  24. package/mcp-server/dist/services/memory-migration-copy.d.ts +144 -0
  25. package/mcp-server/dist/services/memory-migration-copy.d.ts.map +1 -0
  26. package/mcp-server/dist/services/memory-migration-copy.js +467 -0
  27. package/mcp-server/dist/services/memory-migration-copy.js.map +1 -0
  28. package/mcp-server/dist/services/memory-migration-worker.d.ts +2 -0
  29. package/mcp-server/dist/services/memory-migration-worker.d.ts.map +1 -0
  30. package/mcp-server/dist/services/memory-migration-worker.js +60 -0
  31. package/mcp-server/dist/services/memory-migration-worker.js.map +1 -0
  32. package/mcp-server/dist/services/memory-retrieval.d.ts +4 -0
  33. package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -1
  34. package/mcp-server/dist/services/memory-retrieval.js +188 -40
  35. package/mcp-server/dist/services/memory-retrieval.js.map +1 -1
  36. package/mcp-server/dist/services/memory-schema.d.ts +58 -2
  37. package/mcp-server/dist/services/memory-schema.d.ts.map +1 -1
  38. package/mcp-server/dist/services/memory-schema.js +190 -13
  39. package/mcp-server/dist/services/memory-schema.js.map +1 -1
  40. package/mcp-server/dist/services/memory-sessions.d.ts +19 -1
  41. package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
  42. package/mcp-server/dist/services/memory-sessions.js +56 -20
  43. package/mcp-server/dist/services/memory-sessions.js.map +1 -1
  44. package/mcp-server/dist/services/memory-verification.d.ts.map +1 -1
  45. package/mcp-server/dist/services/memory-verification.js +8 -5
  46. package/mcp-server/dist/services/memory-verification.js.map +1 -1
  47. package/mcp-server/dist/services/neural-interface.d.ts +5 -0
  48. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  49. package/mcp-server/dist/services/neural-interface.js +19 -2
  50. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  51. package/mcp-server/dist/services/retrieval-reader-worker.d.ts +2 -0
  52. package/mcp-server/dist/services/retrieval-reader-worker.d.ts.map +1 -0
  53. package/mcp-server/dist/services/retrieval-reader-worker.js +76 -0
  54. package/mcp-server/dist/services/retrieval-reader-worker.js.map +1 -0
  55. package/mcp-server/dist/services/retrieval-reader.d.ts +38 -0
  56. package/mcp-server/dist/services/retrieval-reader.d.ts.map +1 -0
  57. package/mcp-server/dist/services/retrieval-reader.js +145 -0
  58. package/mcp-server/dist/services/retrieval-reader.js.map +1 -0
  59. package/mcp-server/dist/services/sqlite-write.d.ts +14 -0
  60. package/mcp-server/dist/services/sqlite-write.d.ts.map +1 -0
  61. package/mcp-server/dist/services/sqlite-write.js +94 -0
  62. package/mcp-server/dist/services/sqlite-write.js.map +1 -0
  63. package/mcp-server/dist/services/sqlite.d.ts +39 -0
  64. package/mcp-server/dist/services/sqlite.d.ts.map +1 -1
  65. package/mcp-server/dist/services/sqlite.js +249 -8
  66. package/mcp-server/dist/services/sqlite.js.map +1 -1
  67. package/mcp-server/dist/services/tool-catalog.d.ts +1 -1
  68. package/mcp-server/dist/services/typesafe-config.d.ts +7 -1
  69. package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
  70. package/mcp-server/dist/services/typesafe-config.js +32 -10
  71. package/mcp-server/dist/services/typesafe-config.js.map +1 -1
  72. package/mcp-server/dist/services/typesafe.d.ts.map +1 -1
  73. package/mcp-server/dist/services/typesafe.js +9 -7
  74. package/mcp-server/dist/services/typesafe.js.map +1 -1
  75. package/mcp-server/dist/services/vector-cache.d.ts +32 -0
  76. package/mcp-server/dist/services/vector-cache.d.ts.map +1 -1
  77. package/mcp-server/dist/services/vector-cache.js +161 -8
  78. package/mcp-server/dist/services/vector-cache.js.map +1 -1
  79. package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
  80. package/mcp-server/dist/tools/agents.d.ts +11 -7
  81. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  82. package/mcp-server/dist/tools/agents.js +27 -9
  83. package/mcp-server/dist/tools/agents.js.map +1 -1
  84. package/mcp-server/dist/tools/browser-advanced.d.ts +1 -1
  85. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  86. package/mcp-server/dist/tools/browser-advanced.js +10 -3
  87. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  88. package/mcp-server/dist/tools/browser-extension-setup.d.ts +5 -0
  89. package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -0
  90. package/mcp-server/dist/tools/browser-extension-setup.js +23 -0
  91. package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -0
  92. package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
  93. package/mcp-server/dist/tools/browser-interact.js +6 -1
  94. package/mcp-server/dist/tools/browser-interact.js.map +1 -1
  95. package/mcp-server/dist/tools/fb-groups.d.ts +2 -2
  96. package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
  97. package/mcp-server/dist/tools/tool-groups.d.ts +1 -1
  98. package/mcp-server/package-lock.json +2 -2
  99. package/mcp-server/package.json +1 -1
  100. package/mcp-server/src/http.ts +20 -2
  101. package/mcp-server/src/index.ts +59 -17
  102. package/mcp-server/src/services/memory-maintenance.ts +31 -28
  103. package/mcp-server/src/services/memory-migration-copy.ts +419 -0
  104. package/mcp-server/src/services/memory-migration-worker.ts +55 -0
  105. package/mcp-server/src/services/memory-retrieval.ts +173 -32
  106. package/mcp-server/src/services/memory-schema.ts +194 -12
  107. package/mcp-server/src/services/memory-sessions.ts +54 -21
  108. package/mcp-server/src/services/memory-verification.ts +7 -4
  109. package/mcp-server/src/services/neural-interface.ts +22 -2
  110. package/mcp-server/src/services/retrieval-reader-worker.ts +67 -0
  111. package/mcp-server/src/services/retrieval-reader.ts +131 -0
  112. package/mcp-server/src/services/sqlite-write.ts +60 -0
  113. package/mcp-server/src/services/sqlite.ts +246 -8
  114. package/mcp-server/src/services/typesafe-config.ts +25 -6
  115. package/mcp-server/src/services/typesafe.ts +9 -7
  116. package/mcp-server/src/services/vector-cache.ts +154 -9
  117. package/mcp-server/src/tools/agents.ts +26 -9
  118. package/mcp-server/src/tools/browser-advanced.ts +10 -3
  119. package/mcp-server/src/tools/browser-extension-setup.ts +30 -0
  120. package/mcp-server/src/tools/browser-interact.ts +5 -1
  121. package/neural-interface/i18n/en.json +263 -1
  122. package/neural-interface/i18n/pt-BR.json +264 -2
  123. package/neural-interface/lib/agents/split.js +32 -4
  124. package/neural-interface/lib/assistant-api.js +19 -8
  125. package/neural-interface/lib/assistant-brains/claude.js +2 -0
  126. package/neural-interface/lib/assistant-catalog.js +2 -2
  127. package/neural-interface/lib/assistant-config.js +0 -7
  128. package/neural-interface/lib/assistant-dispatch.js +257 -95
  129. package/neural-interface/lib/assistant-persona.js +16 -4
  130. package/neural-interface/lib/assistant-pricing.js +65 -14
  131. package/neural-interface/lib/assistant-router.js +131 -47
  132. package/neural-interface/lib/assistant-run-wait.js +45 -28
  133. package/neural-interface/lib/assistant-runtime.js +39 -33
  134. package/neural-interface/lib/backup-contents.js +158 -0
  135. package/neural-interface/lib/backup-crypto-io.js +330 -0
  136. package/neural-interface/lib/backup-crypto-worker.js +130 -0
  137. package/neural-interface/lib/backup-crypto.js +525 -0
  138. package/neural-interface/lib/backup-download.js +268 -0
  139. package/neural-interface/lib/backup-encryption.js +318 -0
  140. package/neural-interface/lib/backup-groups.js +287 -0
  141. package/neural-interface/lib/backup-restore-session.js +176 -0
  142. package/neural-interface/lib/backup-restore-stage.js +60 -0
  143. package/neural-interface/lib/backup-service.js +788 -233
  144. package/neural-interface/lib/backup-zip-reader.js +30 -18
  145. package/neural-interface/lib/backup-zip-writer.js +34 -10
  146. package/neural-interface/lib/browser-extension-adapter.js +89 -13
  147. package/neural-interface/lib/browser-extension-bridge.js +18 -7
  148. package/neural-interface/lib/claude-agent-bridge.js +1 -0
  149. package/neural-interface/lib/claude-session-cleanup.js +5 -1
  150. package/neural-interface/lib/cli-update-planner.js +105 -6
  151. package/neural-interface/lib/client-diagnostics.js +42 -0
  152. package/neural-interface/lib/confined-fs.js +7 -2
  153. package/neural-interface/lib/coordination/README.md +8 -2
  154. package/neural-interface/lib/coordination/contract.js +161 -0
  155. package/neural-interface/lib/coordination/database.js +999 -0
  156. package/neural-interface/lib/coordination/operations.js +436 -0
  157. package/neural-interface/lib/coordination/service.js +68 -537
  158. package/neural-interface/lib/coordination/storage-worker.js +101 -0
  159. package/neural-interface/lib/coordination/store.js +219 -1111
  160. package/neural-interface/lib/db.js +70 -32
  161. package/neural-interface/lib/health-count.js +37 -0
  162. package/neural-interface/lib/loop-stall.js +139 -0
  163. package/neural-interface/lib/maritaca/client.js +2 -2
  164. package/neural-interface/lib/maritaca/models.js +12 -17
  165. package/neural-interface/lib/maritaca/opencode.js +4 -2
  166. package/neural-interface/lib/memory-api.js +9 -1
  167. package/neural-interface/lib/memory-session-capture.js +42 -10
  168. package/neural-interface/lib/memory-store-gate.js +313 -0
  169. package/neural-interface/lib/memory-store-migrate.js +65 -0
  170. package/neural-interface/lib/memory-timers.js +7 -7
  171. package/neural-interface/lib/native-loop-providers.js +13 -16
  172. package/neural-interface/lib/native-loop-runtime.js +28 -7
  173. package/neural-interface/lib/opencode-build-preflight.js +18 -1
  174. package/neural-interface/lib/opencode-native-boundary.js +69 -8
  175. package/neural-interface/lib/opencode-provider-view.js +14 -3
  176. package/neural-interface/lib/opencode-v2-ws-requests.js +31 -1
  177. package/neural-interface/lib/opencode2-client.js +2 -1
  178. package/neural-interface/lib/recall-impact.js +122 -0
  179. package/neural-interface/lib/scratch-evidence.js +420 -0
  180. package/neural-interface/lib/scratch-process-guard.js +139 -0
  181. package/neural-interface/lib/scratch-references.js +279 -0
  182. package/neural-interface/lib/scratch-retention-core.js +385 -0
  183. package/neural-interface/lib/scratch-retention-worker.js +37 -0
  184. package/neural-interface/lib/scratch-retention.js +151 -0
  185. package/neural-interface/lib/session-cache-builder.js +31 -43
  186. package/neural-interface/lib/session-cache-worker.js +157 -0
  187. package/neural-interface/lib/session-indexer.js +28 -21
  188. package/neural-interface/lib/session-search-index.js +85 -0
  189. package/neural-interface/lib/skills/creation.js +1 -1
  190. package/neural-interface/lib/sqlite-integrity-worker.js +3 -1
  191. package/neural-interface/lib/style-guide/store.js +43 -3
  192. package/neural-interface/lib/system-restore.js +50 -0
  193. package/neural-interface/lib/teams/api.js +15 -6
  194. package/neural-interface/lib/teams/claims.js +67 -31
  195. package/neural-interface/lib/teams/index.js +7 -7
  196. package/neural-interface/lib/teams/integration.js +40 -40
  197. package/neural-interface/lib/teams/landing.js +6 -6
  198. package/neural-interface/lib/teams/recovery.js +24 -23
  199. package/neural-interface/lib/teams/scheduler.js +194 -95
  200. package/neural-interface/lib/teams/state.js +14 -14
  201. package/neural-interface/lib/teams/worktrees.js +27 -27
  202. package/neural-interface/lib/whatsapp/bridge.js +2 -1
  203. package/neural-interface/lib/worker-confinement.js +47 -2
  204. package/neural-interface/lib/worker-mcp-channel.js +2 -0
  205. package/neural-interface/lib/worker-resume.js +5 -0
  206. package/neural-interface/lib/worker-stop.js +86 -0
  207. package/neural-interface/package-lock.json +2 -2
  208. package/neural-interface/package.json +1 -1
  209. package/neural-interface/public/index.html +233 -24
  210. package/neural-interface/public/onboarding.html +259 -34
  211. package/neural-interface/public/shared/agents/studio/ax-library.js +0 -6
  212. package/neural-interface/public/shared/agents/studio/ax-main.js +14 -7
  213. package/neural-interface/public/shared/agy/agy-options.js +11 -0
  214. package/neural-interface/public/shared/agy/agy-panel.js +29 -10
  215. package/neural-interface/public/shared/agy/agy-styles.js +14 -12
  216. package/neural-interface/public/shared/agy/agy-tabs-logic.js +4 -1
  217. package/neural-interface/public/shared/api.js +1 -1
  218. package/neural-interface/public/shared/assistant/asst-api.js +3 -3
  219. package/neural-interface/public/shared/assistant/asst-brain-picker.js +13 -6
  220. package/neural-interface/public/shared/assistant/asst-control.js +2 -0
  221. package/neural-interface/public/shared/assistant/asst-motion-gate.js +78 -4
  222. package/neural-interface/public/shared/assistant/asst-panel.js +18 -2
  223. package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -0
  224. package/neural-interface/public/shared/assistant/asst-render.js +105 -38
  225. package/neural-interface/public/shared/assistant/asst-route.js +100 -21
  226. package/neural-interface/public/shared/assistant/asst-routes-editor.js +1 -1
  227. package/neural-interface/public/shared/assistant/asst-sidepanel.js +4 -2
  228. package/neural-interface/public/shared/assistant/asst-state.js +11 -0
  229. package/neural-interface/public/shared/assistant/asst-styles.js +10 -23
  230. package/neural-interface/public/shared/assistant/route-identity.js +2 -1
  231. package/neural-interface/public/shared/cdx/cdx-render.js +9 -0
  232. package/neural-interface/public/shared/cdx/cdx-settings.js +3 -1
  233. package/neural-interface/public/shared/cdx/cdx-styles.js +6 -0
  234. package/neural-interface/public/shared/cdx/cdx-tabs.js +29 -9
  235. package/neural-interface/public/shared/client-diagnostics.js +94 -0
  236. package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
  237. package/neural-interface/public/shared/cp/cp-styles.js +1 -1
  238. package/neural-interface/public/shared/effort-i18n.js +118 -0
  239. package/neural-interface/public/shared/html-shell.js +4 -52
  240. package/neural-interface/public/shared/loading-diagnostic-entry.js +64 -0
  241. package/neural-interface/public/shared/memory-store-wait.js +52 -0
  242. package/neural-interface/public/shared/morelogin-profile-field.js +1 -1
  243. package/neural-interface/public/shared/mtc/mtc-logic.js +2 -1
  244. package/neural-interface/public/shared/mtc/mtc-panel.js +8 -1
  245. package/neural-interface/public/shared/mtc/mtc-styles.js +13 -12
  246. package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +7 -0
  247. package/neural-interface/public/shared/ocp-v2/ocp-v2-location-logic.js +109 -0
  248. package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +8 -1
  249. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +118 -6
  250. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +27 -3
  251. package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +13 -0
  252. package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +2 -1
  253. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -93
  254. package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +17 -6
  255. package/neural-interface/public/shared/output-format.js +294 -0
  256. package/neural-interface/public/shared/provider-icons.js +6 -0
  257. package/neural-interface/public/shared/schedules-view.js +2 -1
  258. package/neural-interface/public/shared/server-presence.js +77 -0
  259. package/neural-interface/public/shared/settings/settings-backup-contents.js +241 -0
  260. package/neural-interface/public/shared/settings/settings-backup-download.js +298 -0
  261. package/neural-interface/public/shared/settings/settings-backup-encryption-pane.js +335 -0
  262. package/neural-interface/public/shared/settings/settings-backup-encryption.js +545 -0
  263. package/neural-interface/public/shared/settings/settings-ia.js +1 -1
  264. package/neural-interface/public/shared/skills/studio/sx-geometry.js +12 -3
  265. package/neural-interface/public/shared/skills/studio/sx-main.js +14 -7
  266. package/neural-interface/public/shared/studio-attention.js +6 -0
  267. package/neural-interface/public/shared/styles.css +341 -437
  268. package/neural-interface/public/shared/transcript-rows.js +28 -3
  269. package/neural-interface/public/shared/tray-auto-close.js +18 -5
  270. package/neural-interface/public/shared/ui-agents.js +1 -2
  271. package/neural-interface/public/shared/ui-automation-studio.js +168 -108
  272. package/neural-interface/public/shared/ui-claude-panel.js +42 -65
  273. package/neural-interface/public/shared/ui-loading.js +124 -17
  274. package/neural-interface/public/shared/ui-native-loop-router.js +10 -0
  275. package/neural-interface/public/shared/ui-navbar.js +2 -1
  276. package/neural-interface/public/shared/ui-output.js +533 -0
  277. package/neural-interface/public/shared/ui-schedules-studio.js +165 -128
  278. package/neural-interface/public/shared/ui-scroll-follow.js +97 -6
  279. package/neural-interface/public/shared/ui-sessions.js +2 -2
  280. package/neural-interface/public/shared/ui-settings-entry.js +18 -0
  281. package/neural-interface/public/shared/ui-settings.js +224 -65
  282. package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
  283. package/neural-interface/public/shared/ui-tooltip.js +16 -0
  284. package/neural-interface/public/shared/ui-tutorial.js +5 -6
  285. package/neural-interface/public/shared/ui-worker-end.js +27 -8
  286. package/neural-interface/public/shared/worker-end.js +9 -4
  287. package/neural-interface/public/variant/2d/main.js +5 -0
  288. package/neural-interface/public/variant/3d/app.js +10 -0
  289. package/neural-interface/public/variant/3d/main.js +5 -1
  290. package/neural-interface/scripts/scratch-retention.mjs +20 -0
  291. package/neural-interface/server.js +477 -139
  292. package/npm-shrinkwrap.json +2 -2
  293. package/package.json +1 -1
  294. package/scripts/restore-data-home-from-backup.mjs +175 -8
  295. package/setup.js +18 -4
@@ -44,8 +44,8 @@
44
44
  // open is the character on screen, its face a live rig (liveAsk,
45
45
  // activateRigs); every other card's face is a painted still.
46
46
 
47
- import { assistantEventKey, fmtCost, fmtElapsed, isRemovableRun, isTerminalRunStatus, modelShortName, providerShortLabel, routeTargetLabel, runTone, summarizeMailbox } from './asst-state.js';
48
- import { createRouteLine } from './asst-route.js';
47
+ import { assistantEventKey, displayProvider, fmtCost, fmtElapsed, isRemovableRun, isTerminalRunStatus, modelShortName, providerShortLabel, routeTargetLabel, runTone, summarizeMailbox } from './asst-state.js';
48
+ import { createRouteLine, routeClassLabel } from './asst-route.js';
49
49
  import { closeMenu, isMenuOpen } from './asst-menu.js';
50
50
  import { computerToolName, describeComputerAction, frameUrls, markerPercent, openFrameLightbox, parseComputerResult, swapImage } from './asst-computer.js';
51
51
  import * as mascotLib from '../synabun-mascot.js';
@@ -55,11 +55,12 @@ import { injectRackStyles } from './asst-rack-styles.js';
55
55
  import { injectSceneStyles } from './asst-scene-styles.js';
56
56
  import { activityScene, compactActivity, isLivePhase, runChip, sceneOfClass, sceneSvg, stagePhase } from './asst-scenes.js';
57
57
  import { STAGE_TIMING, createWorkerStage } from './asst-run-stage.js';
58
- import { createMotionGate } from './asst-motion-gate.js';
58
+ import { SETTLE_FRAMES, createMotionGate } from './asst-motion-gate.js';
59
59
  import { createStyleCache } from './asst-style-cache.js';
60
60
  import { formatRunTokens } from './asst-usage.js';
61
61
  import { sanitizeHtmlString, sanitizeInto } from './asst-sanitize.js';
62
62
  import { decorateCodeBlocks } from '../ui-code-copy.js';
63
+ import { decorateOutput } from '../ui-output.js';
63
64
  import { renderStreamingMarkdown } from '../streaming-markdown.js';
64
65
  import { automationView } from './asst-automation.js';
65
66
  import { guessFollowups, splitFollowups } from './asst-followups.js';
@@ -70,7 +71,8 @@ import { createLimitDock } from './asst-limit-dock.js';
70
71
  import { createLimitWait } from './asst-limit-wait.js';
71
72
  import { synabunToolKey, synabunToolLabel } from '../synabun-tools.js';
72
73
  import { normalizeToolHeartbeat } from '../tool-heartbeat.js';
73
- import { closedSidepanelOf, createShownGate } from '../sidepanel-shown.js';
74
+ import { createStickyScrollController } from '../ui-scroll-follow.js';
75
+ import { createShownGate } from '../sidepanel-shown.js';
74
76
 
75
77
  // ── Markdown (lazy marked, the vendored build the sidepanels use too) ───────────────
76
78
  let _marked = null;
@@ -221,8 +223,9 @@ export function updateRunCard(card, run, opts = {}) {
221
223
  const provider = run.provider || 'claude-code';
222
224
  const icon = card.querySelector('.asst-run-icon');
223
225
  if (icon) {
224
- icon.innerHTML = typeof opts.providerIcon === 'function' ? (opts.providerIcon(provider) || '') : '';
225
- const color = typeof opts.providerColor === 'function' ? opts.providerColor(provider) : '';
226
+ const brand = displayProvider(run) || provider;
227
+ icon.innerHTML = typeof opts.providerIcon === 'function' ? (opts.providerIcon(brand) || '') : '';
228
+ const color = typeof opts.providerColor === 'function' ? opts.providerColor(brand) : '';
226
229
  if (color) card.style.setProperty('--asst-provider-color', color);
227
230
  }
228
231
  const title = card.querySelector('.asst-run-title');
@@ -257,7 +260,7 @@ export function updateRunCard(card, run, opts = {}) {
257
260
  if (run.agentRef) bits.push(`<span>${esc(run.agentRef)}</span>`);
258
261
  if (run.route && typeof run.route === 'object') {
259
262
  const r = run.route;
260
- const routeBits = [r.taskClassLabel || r.taskClass || t('assistant.routes.task', 'task')];
263
+ const routeBits = [(r.taskClass ? routeClassLabel(r.taskClass, r.taskClassLabel || r.taskClass, t) : r.taskClassLabel) || t('assistant.routes.task', 'task')];
261
264
  if (r.status === 'pending') routeBits.push(t('assistant.routes.state.pending', 'waiting for your choice'));
262
265
  else if (r.decidedBy === 'budget' || r.source === 'budget') routeBits.push(t('assistant.routes.budgetDecision', 'budget re-route'));
263
266
  else if (r.decidedBy === 'user') routeBits.push(t('assistant.routes.youChose', 'you chose'));
@@ -511,7 +514,11 @@ const SUGGESTION_KINDS = { computer: 'computer', web: 'web', fix: 'edit', skill:
511
514
  * ({ status, resetsAt } | null), brainProvider() → the brain's provider id, onLimitRetry(text)
512
515
  * (Retry now on the Assistant's own limit card: send `text`), onSwitchProvider(anchorEl, { excludeProvider, retryText })
513
516
  * (Continue with another provider on the Assistant's own limit card: the host opens its own
514
- * provider picker anchored on anchorEl and decides what a pick does) }
517
+ * provider picker anchored on anchorEl and decides what a pick does),
518
+ * onMotionMark(holderEl, off) (a holder's off-screen mark changed, asst-motion-gate.js: a host that
519
+ * skips far rows keeps the holder's row plain until the mark is styled),
520
+ * onRackFolded(rackRow) (a rack's stage has folded and its row was measured: `is-folding` just left
521
+ * the row, which a host that skips far rows kept plain while it carried it) }
515
522
  */
516
523
  export function createRenderer(transcriptEl, hooks = {}) {
517
524
  loadMarked();
@@ -530,8 +537,22 @@ export function createRenderer(transcriptEl, hooks = {}) {
530
537
  // The open card's slot under every row (asst-ask-tail.js): a card that waits on the user is drawn
531
538
  // there, above the "Working…" row, until it is answered; rows appended meanwhile go above it.
532
539
  const askTail = createAskTail($msgs, { anchor: () => (working?.parentNode === $msgs ? working : null) });
533
- let followTail = true;
534
- let scrollFrame = 0;
540
+ // The transcript follows its bottom through the shared sidepanel controller (ui-scroll-follow.js), as
541
+ // the Claude, Codex, OpenCode and Maritaca panels do: one follow state, detached only by a real upward
542
+ // movement or wheel/keyboard/touch intent (never by the controller's own scroll events), reattached at
543
+ // the bottom, and a MutationObserver/ResizeObserver watch that follows late layout (an image arriving, a
544
+ // font swap, a highlight pass) and a message area whose height changes. Its writes are instant: the
545
+ // transcript's smooth scroll-behavior is for the reader's own scrolling, not for the follow. A closed
546
+ // side panel's transcript is not laid out: the controller keeps the scroll until the panel is shown.
547
+ const scrollFollow = createStickyScrollController($msgs);
548
+ let followHeld = false; // the empty state is up: nothing follows (holdFollow)
549
+ // A cleared transcript's old offset outlives its rows until the next layout: an empty state drawn now would
550
+ // open part-way down, off its character. Back to the top, when the panel is shown if it is closed (no layout
551
+ // there); rows that arrived meanwhile are the follow's.
552
+ const topGate = createShownGate($msgs, () => {
553
+ if (!followHeld && $msgs.firstElementChild) return;
554
+ try { $msgs.scrollTo({ top: 0, behavior: 'instant' }); } catch { $msgs.scrollTop = 0; }
555
+ });
535
556
  let emptyEl = null;
536
557
  let hero = null; // the empty state's character: { rig, el, box, parked, leaving, held, dock, egg, target }
537
558
  const mcpWarned = new Set();
@@ -589,7 +610,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
589
610
  try { fontSet?.addEventListener?.('loadingdone', onFontsLoaded); } catch { /* no FontFaceSet events */ }
590
611
  const stopFontWatch = () => { try { fontSet?.removeEventListener?.('loadingdone', onFontsLoaded); } catch { /* gone */ } };
591
612
  // The transcript's loops run only while their holder is on screen (run cards, racks, route lines).
592
- const motion = createMotionGate();
613
+ const motion = createMotionGate({ onMark: hooks.onMotionMark });
593
614
  const stageResizes = typeof ResizeObserver === 'function' ? new ResizeObserver((entries) => {
594
615
  for (const entry of entries) {
595
616
  const seen = stageWidths.get(entry.target);
@@ -620,13 +641,6 @@ export function createRenderer(transcriptEl, hooks = {}) {
620
641
  const SEEN_MAX = 5000;
621
642
  let snapshot = null;
622
643
 
623
- $msgs.addEventListener('scroll', () => {
624
- // Inside a closed side panel nobody scrolls: the follow stays what it was, and no height is read
625
- // (reading it lays the hidden panel out; sidepanel-shown.js).
626
- if (closedSidepanelOf($msgs)) return;
627
- followTail = isNearBottom();
628
- }, { passive: true });
629
-
630
644
  const t = (key, fallback, params) => {
631
645
  const v = typeof hooks.t === 'function' ? hooks.t(key, params) : undefined;
632
646
  if (v && v !== key && typeof v === 'string') return v;
@@ -665,22 +679,23 @@ export function createRenderer(transcriptEl, hooks = {}) {
665
679
  return $msgs.scrollHeight - $msgs.scrollTop - $msgs.clientHeight < 48;
666
680
  }
667
681
 
668
- // The scroll to the newest row, on the next frame. A transcript inside a closed side panel has no layout:
669
- // scrolling it there read its height, which made the engine lay the whole hidden panel out, at every load
670
- // and for every row a session added meanwhile. The scroll is kept and made when the panel is shown.
671
- const endGate = createShownGate($msgs, () => {
672
- if (scrollFrame) return;
673
- scrollFrame = requestAnimationFrame(() => {
674
- scrollFrame = 0;
675
- if (closedSidepanelOf($msgs)) { endGate.request(); return; } // closed again before the frame
676
- $msgs.scrollTop = $msgs.scrollHeight;
677
- });
678
- });
679
-
682
+ // The scroll to the newest row: the shared controller's follow write, on its generation-checked frame.
683
+ // A transcript inside a closed side panel has no layout: scrolling it there read its height, which made
684
+ // the engine lay the whole hidden panel out, at every load and for every row a session added meanwhile.
685
+ // The controller keeps the scroll and makes it when the panel is shown (ui-scroll-follow.js).
680
686
  function scrollEnd(force = false) {
681
- if (!force && !followTail) return;
682
- if (scrollFrame) return;
683
- endGate.request();
687
+ scrollFollow.scrollToBottom({ force });
688
+ }
689
+
690
+ // The empty state is not a transcript to follow: its bottom is the starters, and following it when a long
691
+ // draft grows the composer pushed the character out of view (parkHero then has no hero to hand off). The
692
+ // controller is off while it is the only thing here, and the first real row starts the follow, whatever
693
+ // the reader did to the empty state's scroll meanwhile.
694
+ function holdFollow(held) {
695
+ if (followHeld === held) return;
696
+ followHeld = held;
697
+ if (!held) scrollFollow.setFollowing(true);
698
+ scrollFollow.setActive(!held);
684
699
  }
685
700
 
686
701
  function root() { return { container: $msgs, stream: null, key: null, msgId: null, lastAt: 0 }; }
@@ -710,6 +725,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
710
725
  closeEmptyMenu();
711
726
  emptyEl.remove();
712
727
  emptyEl = null;
728
+ holdFollow(false);
713
729
  }
714
730
 
715
731
  /** A menu opened from the empty state's project picker does not outlive it. */
@@ -975,6 +991,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
975
991
  mdInto(body, text);
976
992
  // Every code block gets the shared Copy button (../ui-code-copy.js), also each piece a stream draws.
977
993
  decorateCodeBlocks(body);
994
+ // The reading layer all six panels share (../ui-output.js): a table's frame, task items, a diff's lines.
995
+ decorateOutput(body);
978
996
  body.querySelectorAll('pre code').forEach((code) => {
979
997
  const lang = (code.className || '').replace('language-', '').trim();
980
998
  if (lang) code.parentElement.dataset.lang = lang;
@@ -1642,7 +1660,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
1642
1660
  receipt: { btn: q('.asst-rack-receipt'), face: q('.asst-rack-receipt-face'), text: q('.asst-rack-receipt-text'), failed: q('.asst-rack-receipt-failed'), clock: q('.asst-rack-receipt-clock'), faceBuilt: false, pose: '', svg: null },
1643
1661
  ledger: q('.asst-rack-ledger'), statusEl: q('.asst-rack-status'), alertEl: q('.asst-rack-alert'), timelineEl: null, timelineSig: '',
1644
1662
  rig: null, target: null, held: false, holdUntil: 0, holdTimer: 0, pose: null, awake: null, awakeKey: null,
1645
- bubble: { step: null, since: 0, key: '', open: false }, stageTimer: 0, clearTimer: 0,
1663
+ bubble: { step: null, since: 0, key: '', open: false }, stageTimer: 0, clearTimer: 0, foldFrame: 0,
1646
1664
  sr: { last: 0, timer: 0, pending: '' },
1647
1665
  };
1648
1666
  row._rack = rack;
@@ -1868,6 +1886,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
1868
1886
  if (staged) {
1869
1887
  clearTimeout(rack.clearTimer);
1870
1888
  rack.clearTimer = 0;
1889
+ foldMeasured(rack, true); // a fold that was still being measured is over: the stage is back
1871
1890
  rack.row.classList.add('is-staged');
1872
1891
  watchStageWidth(rack, true);
1873
1892
  if (!rack.rig) {
@@ -1882,6 +1901,11 @@ export function createRenderer(transcriptEl, hooks = {}) {
1882
1901
  // Fold the stage into the receipt; a rack above the viewport folds at once and the scroll position absorbs it.
1883
1902
  // Keyboard focus inside the stage (the bubble, its Copy) moves to the receipt, which takes the stage's place.
1884
1903
  const row = rack.row;
1904
+ // From here until the fold has been measured (foldMeasured) the row is laid out for real, wherever it is.
1905
+ // A settled rack is skipped off screen (asst-rack-styles.js; as a transcript row, transcript-rows.js), and
1906
+ // a skipped box keeps the height it was skipped at: a rack that settled off screen, or left the screen
1907
+ // while it folded, stayed as tall as its stage (or half folded) until the reader came back to it.
1908
+ row.classList.add('is-folding');
1885
1909
  const focused = rack.stage.el.contains(document.activeElement);
1886
1910
  let above = false;
1887
1911
  if (!calm() && row.isConnected) {
@@ -1894,7 +1918,14 @@ export function createRenderer(transcriptEl, hooks = {}) {
1894
1918
  row.classList.remove('is-staged');
1895
1919
  void row.offsetHeight; // apply without the transition
1896
1920
  row.classList.remove('is-instant');
1897
- if (h) $msgs.scrollTop = Math.max(0, $msgs.scrollTop - h);
1921
+ if (h) {
1922
+ if (scrollFollow.isFollowing()) {
1923
+ scrollFollow.scrollToBottom({ immediate: true });
1924
+ } else {
1925
+ const top = Math.max(0, $msgs.scrollTop - h);
1926
+ try { $msgs.scrollTo({ top, behavior: 'instant' }); } catch { $msgs.scrollTop = top; }
1927
+ }
1928
+ }
1898
1929
  } else {
1899
1930
  row.classList.remove('is-staged');
1900
1931
  }
@@ -1937,6 +1968,34 @@ export function createRenderer(transcriptEl, hooks = {}) {
1937
1968
  s.err.hidden = true;
1938
1969
  s.bubble.querySelector('.asst-bubble-copy')?.remove();
1939
1970
  rack.bubble = { step: null, since: 0, key: '', open: false };
1971
+ // A settled rack scrolled offscreen (content-visibility: auto) can freeze its
1972
+ // fold transitions in WebKit; clear any still-running fold transitions once folded.
1973
+ try {
1974
+ for (const a of rack.row.getAnimations?.() || []) a.cancel();
1975
+ for (const a of s.el.getAnimations?.() || []) a.cancel();
1976
+ } catch { /* ignore */ }
1977
+ foldMeasured(rack);
1978
+ }
1979
+
1980
+ /**
1981
+ * The fold is over. Its row stays laid out (`is-folding`) for SETTLE_FRAMES more frames: the first may be the
1982
+ * one the fold ended in, so by the last the folded height has been laid out and reported to whoever measures
1983
+ * rows (the size a skipped box is given). Then the mark goes and the host is told (`onRackFolded`), so a row
1984
+ * it kept plain meanwhile may be skipped again. `now`: the stage is back, the mark goes at once. Nothing is
1985
+ * read here, and a page that draws no frame keeps the row laid out until it draws again.
1986
+ */
1987
+ function foldMeasured(rack, now = false) {
1988
+ if (rack.foldFrame) { cancelAnimationFrame(rack.foldFrame); rack.foldFrame = 0; }
1989
+ const { row } = rack;
1990
+ if (!row.classList.contains('is-folding')) return;
1991
+ let left = now || typeof requestAnimationFrame !== 'function' ? 0 : SETTLE_FRAMES;
1992
+ const frame = () => {
1993
+ rack.foldFrame = 0;
1994
+ if (left-- > 0) { rack.foldFrame = requestAnimationFrame(frame); return; }
1995
+ row.classList.remove('is-folding');
1996
+ if (typeof hooks.onRackFolded === 'function') { try { hooks.onRackFolded(row); } catch { /* the fold stands */ } }
1997
+ };
1998
+ frame();
1940
1999
  }
1941
2000
 
1942
2001
  /**
@@ -3003,6 +3062,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
3003
3062
  clearTimeout(rack.clearTimer);
3004
3063
  clearTimeout(rack.sr.timer);
3005
3064
  clearTimeout(rack.holdTimer);
3065
+ if (rack.foldFrame) cancelAnimationFrame(rack.foldFrame);
3066
+ rack.foldFrame = 0;
3006
3067
  rack.stageTimer = 0;
3007
3068
  rack.clearTimer = 0;
3008
3069
  rack.sr.timer = 0;
@@ -3381,6 +3442,9 @@ export function createRenderer(transcriptEl, hooks = {}) {
3381
3442
  function revealRun(runId) {
3382
3443
  const card = runCards.get(runId);
3383
3444
  if (!card?.isConnected) return false;
3445
+ // Leaving the bottom on purpose: detach first, so the follow does not read this jump's own mutations
3446
+ // as new content and write the bottom back over the smooth scroll before its first scroll event.
3447
+ scrollFollow.setFollowing(false);
3384
3448
  const top = card.getBoundingClientRect().top - $msgs.getBoundingClientRect().top + $msgs.scrollTop - 16;
3385
3449
  try { $msgs.scrollTo({ top: Math.max(0, top), behavior: calm() ? 'auto' : 'smooth' }); } catch { $msgs.scrollTop = Math.max(0, top); }
3386
3450
  card.classList.remove('is-revealed');
@@ -3625,6 +3689,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
3625
3689
  if (ended) row.atEnd = true;
3626
3690
  prune();
3627
3691
  if (racks.size) syncRacks();
3692
+ holdFollow(false); // a real row, even when the empty state stays above it
3628
3693
  scrollEnd();
3629
3694
  }
3630
3695
  return row.el;
@@ -3633,6 +3698,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
3633
3698
  // ── Empty state ──
3634
3699
  function showEmpty() {
3635
3700
  if (emptyEl || $msgs.querySelector(':scope > :not(.asst-working)')) return;
3701
+ holdFollow(true);
3636
3702
  emptyEl = el('div', 'asst-empty');
3637
3703
  // One column, one hierarchy: the character and the heading, the greeting when there is one,
3638
3704
  // the starters, then the context line (Project · Budget). No lead: the starters say what it can do.
@@ -4166,7 +4232,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
4166
4232
  }
4167
4233
 
4168
4234
  function clear() {
4169
- if (scrollFrame) { cancelAnimationFrame(scrollFrame); scrollFrame = 0; }
4235
+ scrollFollow.setFollowing(true);
4170
4236
  clearTimeout(recutTimer);
4171
4237
  recutTimer = 0;
4172
4238
  toRecut.clear();
@@ -4208,13 +4274,14 @@ export function createRenderer(transcriptEl, hooks = {}) {
4208
4274
  closeEmptyMenu();
4209
4275
  $msgs.innerHTML = '';
4210
4276
  emptyEl = null;
4211
- followTail = true;
4277
+ holdFollow(false);
4278
+ topGate.request();
4212
4279
  }
4213
4280
 
4214
4281
  return {
4215
4282
  el: $msgs,
4216
4283
  clear,
4217
- destroy: () => { clear(); endGate.cancel(); stageResizes?.disconnect(); limitDock.destroy(); stopFontWatch(); },
4284
+ destroy: () => { clear(); scrollFollow.destroy(); topGate.cancel(); stageResizes?.disconnect(); limitDock.destroy(); stopFontWatch(); },
4218
4285
  appendUser,
4219
4286
  appendAssistantMarkdown,
4220
4287
  appendStatus,
@@ -26,8 +26,11 @@ import { closeMenu, isMenuOpen, openMenu } from './asst-menu.js';
26
26
  import { decorateControlHead } from './asst-control.js';
27
27
  import { accountSummary } from '../account-view.js';
28
28
  import { accountUsageText, autoAccountLabel } from '../account-usage.js';
29
+ import { registerLaunchPrefetch } from '../launch-prefetch.js';
30
+ import { createLazyModule } from '../lazy-module.js';
29
31
  import {
30
32
  DEFAULT_ROUTE_MODE,
33
+ displayProvider,
31
34
  fmtConfidence,
32
35
  modelShortName,
33
36
  normalizeBrain,
@@ -89,6 +92,40 @@ function tf(t) {
89
92
  };
90
93
  }
91
94
 
95
+ /**
96
+ * A task class in the user's language, keyed by its id (`assistant.routes.taskClass.<id>`); the server's
97
+ * label (English) is the fallback. `lower` is the sentence form.
98
+ */
99
+ export function routeClassLabel(taskClass, serverLabel, t, { lower = false } = {}) {
100
+ const tr = tf(t);
101
+ const id = str(taskClass);
102
+ const base = str(serverLabel) || humanizeClass(id);
103
+ const label = id ? tr(`assistant.routes.taskClass.${id}`, base) : base;
104
+ return lower ? label.toLowerCase() : label;
105
+ }
106
+
107
+ /**
108
+ * An effort id in the user's language (`assistant.routes.effortWord.<id>`), for display only: the id that is
109
+ * sent back to the server never changes. A locale that only repeats the id (English), or has no key, and an
110
+ * id nothing names (an OpenCode variant) keep `fallback` (default: the card's own word, "none" → "off").
111
+ */
112
+ export function routeEffortLabel(effort, t, fallback) {
113
+ const id = str(effort);
114
+ const raw = routeEffortWord(id);
115
+ const base = fallback == null ? raw : fallback;
116
+ if (!id) return base;
117
+ const v = tf(t)(`assistant.routes.effortWord.${id.toLowerCase()}`, '');
118
+ return v && v !== raw ? v : base;
119
+ }
120
+
121
+ /** A row's title with its trailing effort word in the user's language (the stored title stays English). */
122
+ export function routeTitleLocalized(o, t) {
123
+ const title = str(o?.title);
124
+ if (!o?.titleEffort || !o?.effort) return title;
125
+ const word = routeEffortLabel(o.effort, t);
126
+ return word === routeEffortWord(o.effort) ? title : `${routeTitleWithoutEffort(title, o.effort)} · ${word}`;
127
+ }
128
+
92
129
  function humanizeClass(value) {
93
130
  const s = str(value).replace(/[_-]+/g, ' ');
94
131
  return s ? s[0].toUpperCase() + s.slice(1) : 'General';
@@ -197,6 +234,7 @@ export function normalizeRouteRequest(packet) {
197
234
  needsVision: req.needsVision === true,
198
235
  // Image / video creation: the medium the model must generate ('image' | 'video'), always on a worker.
199
236
  requires: req.requires === 'image' || req.requires === 'video' ? req.requires : null,
237
+ needsHost: req.needsHost === true || req.sides?.dispatch?.code === 'host_only',
200
238
  dispatchOnly: req.dispatchOnly === true,
201
239
  // Design: only models that can see.
202
240
  visionOnly: req.visionOnly === true,
@@ -359,6 +397,7 @@ export function routeOptions(n, { brainLabel = '', t = null } = {}) {
359
397
  }
360
398
  const kept = [];
361
399
  for (const o of options) {
400
+ if (n.needsHost && o.kind !== 'direct') continue;
362
401
  const twin = kept.find(k => sameRouteTarget(k, o));
363
402
  if (twin) {
364
403
  if (defaultId === o.id) defaultId = twin.id;
@@ -426,10 +465,13 @@ export function routeCardSides(n, options, { t = null } = {}) {
426
465
  const usable = list.filter((o) => !o.disabled);
427
466
  const said = server?.[kind] || null;
428
467
  const out = { kind, options: list, available: usable.length > 0, reason: null, code: null, needsPick: false, defaultId: null };
468
+ if (kind === 'dispatch' && n?.needsHost) {
469
+ return { ...out, options: [], available: false, code: 'host_only', reason: tr('assistant.routes.side.hostOnly', 'This task requires host access in this conversation.') };
470
+ }
429
471
  out.defaultId = (usable.find((o) => o.id === n?.defaultOptionId) || usable.find((o) => o.id === n?.defaults?.[kind]) || usable.find((o) => o.selected) || usable[0])?.id || null;
430
472
  if (out.available) return out;
431
473
  if (kind === 'direct' && n?.dispatchOnly) {
432
- return { ...out, code: 'worker_only', reason: tr('assistant.routes.side.workerOnly', '{taskClass} always runs on a worker.', { taskClass: n.taskClassLabel || humanizeClass(n.taskClass) }) };
474
+ return { ...out, code: 'worker_only', reason: tr('assistant.routes.side.workerOnly', '{taskClass} always runs on a worker.', { taskClass: routeClassLabel(n.taskClass, n.taskClassLabel, t) }) };
433
475
  }
434
476
  if (kind === 'direct' && (said?.code === 'account_worker' || arr(options).some((o) => o.kind === 'dispatch' && o.accountKind === 'direct'))) {
435
477
  return { ...out, code: 'account_worker', reason: tr('assistant.routes.side.accountWorker', "This conversation's account can't take it now, so it runs on a worker.") };
@@ -448,7 +490,7 @@ export function routeCardSides(n, options, { t = null } = {}) {
448
490
  const chosen = arr(options).find((o) => o.selected && !o.disabled);
449
491
  let initial = chosen ? (chosen.kind === 'direct' ? 'direct' : 'dispatch') : null;
450
492
  if (!initial || !sides[initial].available) initial = sides.direct.available && sides.direct.defaultId ? 'direct' : 'dispatch';
451
- return { initial, sides };
493
+ return { initial: n?.needsHost ? 'direct' : initial, sides };
452
494
  }
453
495
 
454
496
  /** control_response payload for a route card. `decline:true` is the Cancel answer. */
@@ -548,7 +590,7 @@ export function routeLineParts(route, phase = 'decided', { brainLabel = '', t =
548
590
  const tr = tf(t);
549
591
  const r = obj(route) || {};
550
592
  const target = obj(r.target);
551
- const cls = firstStr(r.taskClassLabel, r.taskClass) || tr('assistant.routes.task', 'task');
593
+ const cls = (r.taskClass ? routeClassLabel(r.taskClass, firstStr(r.taskClassLabel, r.taskClass), t) : firstStr(r.taskClassLabel)) || tr('assistant.routes.task', 'task');
552
594
  const kind = target ? (str(target.kind) || 'direct') : '';
553
595
  const effort = target ? str(target.effort) : '';
554
596
  const confidence = fmtConfidence(r.confidence);
@@ -560,6 +602,7 @@ export function routeLineParts(route, phase = 'decided', { brainLabel = '', t =
560
602
  state = str(r.needs) === 'vision' ? tr('assistant.routes.reason.noSeeingModel', 'no model can see images') : tr('assistant.routes.reason.noCapableModel', 'no model can make this');
561
603
  }
562
604
  else if (str(r.reasonCode) === 'budget_exhausted') state = routeBudgetReason({ dry: r.dry }, t);
605
+ else if (str(r.reasonCode) === 'BUDGET_UNPRICED') state = routeBudgetReason({ provider: r.provider, unpriced: true }, t);
563
606
  else if (phase === 'declined') state = tr('assistant.routes.state.declined', 'declined');
564
607
  else if (phase === 'cancelled') state = tr('assistant.routes.state.cancelled', 'cancelled');
565
608
  let decided = '';
@@ -576,7 +619,7 @@ export function routeLineParts(route, phase = 'decided', { brainLabel = '', t =
576
619
  if (r.plannedSplit?.workers) meta.push(tf(t)('assistant.routes.splitWorkers', '{count} workers planned', { count: r.plannedSplit.workers }));
577
620
  const accountLabel = routeDisplayAccount(target, t);
578
621
  if (accountLabel) meta.push(accountLabel);
579
- if (effort && effort !== 'off') meta.push(routeEffortWord(effort));
622
+ if (effort && effort !== 'off') meta.push(routeEffortLabel(effort, t));
580
623
  if (confidence) meta.push(confidence);
581
624
  return {
582
625
  taskClass: cls,
@@ -607,6 +650,11 @@ function correctionText(c, tr) {
607
650
  }
608
651
  if (c.reason === 'remembered_route') return tr('assistant.routes.correction.remembered', 'your saved route {to} replaced {from}', { to: str(c.to), from: str(c.from) });
609
652
  if (c.reason === 'remembered_disabled') return tr('assistant.routes.correction.rememberedDisabled', 'saved route {from} is disabled, kept the pick', { from: str(c.from) });
653
+ if (c.reason === 'remembered_host') return tr('assistant.routes.correction.rememberedHost', 'Skipped the saved route {from} because this task requires host access.', { from: str(c.from) });
654
+ if (c.reason === 'superseded_run_active' && arr(c.runs).length) {
655
+ const runs = c.runs.map(r => [str(r?.runId), str(r?.title)].filter(Boolean).join(' — ')).filter(Boolean).join(', ');
656
+ return tr('assistant.routes.correction.supersededRunActive', 'Workers from the previous dispatch are still active ({runs}).', { runs });
657
+ }
610
658
  // A "here" pick that runs on a worker: another account, or another provider than this conversation's.
611
659
  if (c.reason === 'account_worker') return tr('assistant.routes.correction.accountWorker', '{to}: runs on a worker, because this conversation belongs to another account', { to: str(c.to) });
612
660
  if (c.reason === 'other_provider' && c.provider) return tr('assistant.routes.correction.otherProvider', "{provider} is not this conversation's provider, so it runs on a worker", { provider: providerLabel(c.provider) });
@@ -718,9 +766,10 @@ export function createRouteLine(route, opts = {}) {
718
766
  arrow.hidden = !p.targetLabel && !p.pending && !p.kindLabel;
719
767
  kindEl.textContent = p.kindLabel;
720
768
  kindEl.hidden = !p.kindLabel;
721
- iconEl.innerHTML = p.targetLabel ? providerIconHtml(p.provider, opts) : '';
769
+ const brand = displayProvider(current.route?.target) || p.provider;
770
+ iconEl.innerHTML = p.targetLabel ? providerIconHtml(brand, opts) : '';
722
771
  iconEl.hidden = !iconEl.innerHTML;
723
- if (p.provider) iconEl.style.color = providerColor(p.provider); else iconEl.style.color = '';
772
+ if (p.provider) iconEl.style.color = providerColor(brand); else iconEl.style.color = '';
724
773
  targetEl.textContent = p.targetLabel;
725
774
  targetEl.hidden = !p.targetLabel;
726
775
  metaEl.textContent = p.meta.length ? `· ${p.meta.join(' · ')}` : '';
@@ -903,7 +952,7 @@ export function renderRouteCard(container, input, hooks = {}) {
903
952
  card.dataset.requestId = n.requestId;
904
953
  card.dataset.routeId = n.routeId;
905
954
  card.setAttribute('role', 'group');
906
- const heading = tr('assistant.routes.cardTitle', 'Route this request · {taskClass}', { taskClass: n.taskClassLabel });
955
+ const heading = tr('assistant.routes.cardTitle', 'Route this request · {taskClass}', { taskClass: routeClassLabel(n.taskClass, n.taskClassLabel, hooks.t) });
907
956
  card.setAttribute('aria-label', heading);
908
957
 
909
958
  const head = el('div', 'asst-control-head');
@@ -933,8 +982,9 @@ export function renderRouteCard(container, input, hooks = {}) {
933
982
  const sidesEl = el('div', 'asst-route-sides');
934
983
  sidesEl.setAttribute('role', 'radiogroup');
935
984
  sidesEl.setAttribute('aria-label', tr('assistant.routes.side.label', 'Where it runs'));
985
+ const visibleSides = n.needsHost ? ['direct'] : ROUTE_SIDES;
936
986
  const sideBtns = {};
937
- for (const kind of ROUTE_SIDES) {
987
+ for (const kind of visibleSides) {
938
988
  const btn = el('button', 'asst-route-side', kind === 'direct' ? tr('assistant.routes.side.here', 'Here') : tr('assistant.routes.side.dispatch', 'Dispatch'));
939
989
  btn.type = 'button';
940
990
  btn.dataset.side = kind;
@@ -953,6 +1003,7 @@ export function renderRouteCard(container, input, hooks = {}) {
953
1003
  card.appendChild(list);
954
1004
 
955
1005
  function optionRow(o) {
1006
+ const brand = displayProvider(o);
956
1007
  const row = el('div', 'asst-route-option');
957
1008
  row.setAttribute('role', 'radio');
958
1009
  row.dataset.optionId = o.id;
@@ -960,17 +1011,17 @@ export function renderRouteCard(container, input, hooks = {}) {
960
1011
  row.setAttribute('aria-disabled', o.disabled ? 'true' : 'false');
961
1012
  row.tabIndex = -1;
962
1013
  const kindWord = o.kind && o.kind !== 'direct' ? routeKindWord(o.kind, hooks.t) : '';
963
- const sub = [kindWord, o.agentRef, routeDisplayAccount(o, hooks.t), o.effort && o.effort !== 'off' && !o.titleEffort ? routeEffortWord(o.effort) : '', o.price ? priceText(o.price) : '', o.vision ? tr('assistant.brain.vision', 'vision') : '', o.reason].filter(Boolean).join(' · ');
1014
+ const sub = [kindWord, o.agentRef, routeDisplayAccount(o, hooks.t), o.effort && o.effort !== 'off' && !o.titleEffort ? routeEffortLabel(o.effort, hooks.t) : '', o.price ? priceText(o.price) : '', o.vision ? tr('assistant.brain.vision', 'vision') : '', o.reason].filter(Boolean).join(' · ');
964
1015
  row.innerHTML = `
965
1016
  <span class="asst-route-num" aria-hidden="true">${esc(o.number)}</span>
966
- <span class="asst-route-opt-icon asst-icon" aria-hidden="true"${o.provider ? ` style="color:${esc(providerColor(o.provider))}"` : ''}>${providerIconHtml(o.provider, hooks)}</span>
1017
+ <span class="asst-route-opt-icon asst-icon" aria-hidden="true"${o.provider ? ` style="color:${esc(providerColor(brand))}"` : ''}>${providerIconHtml(brand, hooks)}</span>
967
1018
  <span class="asst-route-opt-main">
968
1019
  <span class="asst-route-opt-title"></span>
969
1020
  ${sub ? '<span class="asst-route-opt-sub"></span>' : ''}
970
1021
  ${o.warning || (o.disabled && o.disabledReason) ? '<span class="asst-route-opt-warn"></span>' : ''}
971
1022
  </span>
972
1023
  ${o.badgeText ? `<span class="asst-route-badge" data-badge="${esc(o.badge || '')}"></span>` : ''}`;
973
- row.querySelector('.asst-route-opt-title').textContent = o.title;
1024
+ row.querySelector('.asst-route-opt-title').textContent = routeTitleLocalized(o, hooks.t);
974
1025
  if (sub) row.querySelector('.asst-route-opt-sub').textContent = sub;
975
1026
  const warn = row.querySelector('.asst-route-opt-warn');
976
1027
  if (warn) warn.textContent = o.accountError ? routeAccountError(o.accountError, hooks.t) : o.disabled && o.disabledReason ? o.disabledReason : o.warning;
@@ -1013,7 +1064,7 @@ export function renderRouteCard(container, input, hooks = {}) {
1013
1064
  /** The switch, its note (why the other side is unavailable, what a worker side still needs, else what the side means) and the Run label. */
1014
1065
  function syncSides() {
1015
1066
  card.dataset.side = state.side;
1016
- for (const kind of ROUTE_SIDES) {
1067
+ for (const kind of visibleSides) {
1017
1068
  const btn = sideBtns[kind];
1018
1069
  const side = view.sides[kind];
1019
1070
  const on = state.side === kind;
@@ -1078,11 +1129,15 @@ export function renderRouteCard(container, input, hooks = {}) {
1078
1129
  }
1079
1130
  function syncFields() {
1080
1131
  const target = selected();
1081
- setFieldLabel(otherBtn, target ? routeTargetLabel(target) : tr('assistant.routes.other', 'Other model…'));
1132
+ // The router's "Do it here with ‹model›" label reads in the user's language, like the list rows.
1133
+ const targetText = !target ? '' : target.kind === 'direct' && /^do it here with\s+/i.test(str(target.label))
1134
+ ? tr('assistant.routes.doHere', 'Do it here with {model}', { model: routeHereModelLabel(target) || modelShortName(target.model) || target.id })
1135
+ : routeTargetLabel(target);
1136
+ setFieldLabel(otherBtn, target ? targetText : tr('assistant.routes.other', 'Other model…'));
1082
1137
  otherBtn.setAttribute('aria-label', tr('assistant.brain.model', 'Model'));
1083
1138
  otherBtn.disabled = busy();
1084
1139
  setFieldLabel(effortBtn, !target?.effort ? tr('assistant.routes.editorEffortAuto', 'Auto')
1085
- : target.effort === ROUTE_EFFORT_OFF ? tr('assistant.routes.editorEffortOff', 'Off') : target.effort);
1140
+ : target.effort === ROUTE_EFFORT_OFF ? tr('assistant.routes.editorEffortOff', 'Off') : routeEffortLabel(target.effort, hooks.t, target.effort));
1086
1141
  effortBtn.setAttribute('aria-label', tr('assistant.brain.effort', 'Thinking effort'));
1087
1142
  setFieldLabel(accountBtn, routeDisplayAccount(target, hooks.t) || tr('assistant.routes.account.workersDefault', 'Workers default'));
1088
1143
  accountBtn.setAttribute('aria-label', tr('assistant.brain.account', 'Account profile'));
@@ -1097,7 +1152,7 @@ export function renderRouteCard(container, input, hooks = {}) {
1097
1152
  const choices = routeEffortChoices(target.provider, catalogModelRow(target.provider, target.model));
1098
1153
  openMenu(effortBtn, { title: tr('assistant.brain.effort', 'Thinking effort'), placement: 'auto', items: [
1099
1154
  { kind: 'radio', label: tr('assistant.routes.editorEffortAuto', 'Auto'), selected: !target.effort, onSelect: () => editTarget({ effort: null }) },
1100
- ...choices.map(e => ({ kind: 'radio', label: e.off ? tr('assistant.routes.editorEffortOff', 'Off') : e.label, selected: target.effort === e.id, onSelect: () => editTarget({ effort: e.id }) })),
1155
+ ...choices.map(e => ({ kind: 'radio', label: e.off ? tr('assistant.routes.editorEffortOff', 'Off') : routeEffortLabel(e.id, hooks.t, e.label), selected: target.effort === e.id, onSelect: () => editTarget({ effort: e.id }) })),
1101
1156
  ] });
1102
1157
  });
1103
1158
  accountBtn.addEventListener('click', async () => {
@@ -1176,7 +1231,9 @@ export function renderRouteCard(container, input, hooks = {}) {
1176
1231
  rememberInput.type = 'checkbox';
1177
1232
  rememberInput.addEventListener('change', () => { state.remember = rememberInput.checked; });
1178
1233
  // `remember.label` is the task-class label ("Code"), not a sentence.
1179
- const text = tr('assistant.routes.rememberFor', 'Use this choice for {taskClass} tasks', { taskClass: (n.remember.label || n.taskClassLabel).toLowerCase() });
1234
+ // A key per class carries the whole phrase so the plural noun agrees ("tarefas rápidas"); the generic one is the fallback.
1235
+ const rememberClass = n.remember.taskClass || n.taskClass;
1236
+ const text = tr(`assistant.routes.rememberForClass.${rememberClass}`, '') || tr('assistant.routes.rememberFor', 'Use this choice for {taskClass} tasks', { taskClass: routeClassLabel(rememberClass, n.remember.label || n.taskClassLabel, hooks.t, { lower: true }) });
1180
1237
  label.append(rememberInput, el('span', null, text));
1181
1238
  if (n.remember.current) label.appendChild(el('span', 'asst-route-remember-current', tr('assistant.routes.rememberCurrent', 'now: {current}', { current: n.remember.current })));
1182
1239
  card.appendChild(label);
@@ -1188,7 +1245,7 @@ export function renderRouteCard(container, input, hooks = {}) {
1188
1245
  card.appendChild(error);
1189
1246
 
1190
1247
  const actions = el('div', 'asst-control-actions');
1191
- const cancelBtn = el('button', 'asst-btn asst-btn-secondary asst-route-cancel', n.decline.label || tr('common.cancel', 'Cancel'));
1248
+ const cancelBtn = el('button', 'asst-btn asst-btn-secondary asst-route-cancel', (n.decline.label && n.decline.label !== 'Cancel' ? n.decline.label : tr('common.cancel', 'Cancel')));
1192
1249
  cancelBtn.type = 'button';
1193
1250
  // When the server does not accept a decline, the card can only be answered.
1194
1251
  cancelBtn.hidden = !n.decline.allowed;
@@ -1388,11 +1445,13 @@ export function renderRouteCard(container, input, hooks = {}) {
1388
1445
  return collapse(phase, route);
1389
1446
  },
1390
1447
  /** ROUTE_INVALID: keep (or re-open) the card with the message. */
1391
- fail(message) {
1448
+ fail(message, code) {
1392
1449
  clearTimers();
1393
1450
  restore();
1394
1451
  setPending(false, '');
1395
- error.textContent = message || tr('assistant.routes.invalid', 'That route is not available. Pick another option.');
1452
+ error.textContent = n.needsHost && code === 'ROUTE_IS_DIRECT'
1453
+ ? view.sides.dispatch.reason
1454
+ : message || tr('assistant.routes.invalid', 'That route is not available. Pick another option.');
1396
1455
  error.hidden = false;
1397
1456
  if (expires) { tick(); if (!state.expired) state.timer = setInterval(tick, 1000); }
1398
1457
  entry.focus();
@@ -1403,8 +1462,28 @@ export function renderRouteCard(container, input, hooks = {}) {
1403
1462
  }
1404
1463
 
1405
1464
  // ── Routes editor (draft, modes, task choices) ───────────────────────────────
1406
- // Its model lists still come only through asst-route-models.js.
1407
- export { openRoutesEditor } from './asst-routes-editor.js';
1465
+ // Its model lists still come only through asst-route-models.js. The module loads in an idle moment after the page
1466
+ // is shown or at the first open, whichever comes first (lazy-module.js), so the page does not wait for it at boot.
1467
+ // A browser keeps a failed module address failed for the life of the page (a server restart can refuse the idle
1468
+ // load), so a later attempt asks under a new address. A failed load never ran, so there is still one editor.
1469
+ let routesEditorAttempts = 0;
1470
+ const routesEditorModule = createLazyModule(() => {
1471
+ const attempt = routesEditorAttempts++;
1472
+ return attempt ? import(`./asst-routes-editor.js?retry=${attempt}`) : import('./asst-routes-editor.js');
1473
+ }, { name: 'Routes editor' });
1474
+ if (typeof document !== 'undefined') registerLaunchPrefetch('assistant-routes-editor', () => routesEditorModule.load(), { order: 16 });
1475
+
1476
+ export function openRoutesEditor(hooks = {}) {
1477
+ const loaded = routesEditorModule.module;
1478
+ if (loaded) return loaded.openRoutesEditor(hooks);
1479
+ // Focus can move during the load: the control that opened the editor is the one it gives focus back to.
1480
+ const opened = { ...hooks, returnTo: hooks.returnTo ?? globalThis.document?.activeElement };
1481
+ return routesEditorModule.load().then(mod => mod.openRoutesEditor(opened), (err) => {
1482
+ const text = hooks.t?.('assistant.routes.loadFailed');
1483
+ hooks.onToast?.(typeof text === 'string' && text !== 'assistant.routes.loadFailed' ? text : 'Could not load model routes');
1484
+ throw err;
1485
+ });
1486
+ }
1408
1487
 
1409
1488
  // ── Models manager (Assistant → Models…) ───────────────────────────────────
1410
1489
 
@@ -96,7 +96,7 @@ export async function openRoutesEditor(hooks = {}) {
96
96
  if (editor) { editor.focus(); return editor; }
97
97
  const tr = translator(hooks.t);
98
98
  const id = `asst-routes-${++uid}`;
99
- const returnTo = document.activeElement;
99
+ const returnTo = hooks.returnTo ?? document.activeElement;
100
100
  const overlay = el('div', 'asst-modal-overlay asst-routes-overlay');
101
101
  overlay.setAttribute('role', 'dialog'); overlay.setAttribute('aria-modal', 'true'); overlay.setAttribute('aria-labelledby', `${id}-title`);
102
102
  const modal = el('div', 'asst-modal asst-routes-modal');
@@ -30,7 +30,6 @@ import { brainLabel, readStoredBrain, restoredSessionName } from './asst-state.j
30
30
  import { closeMenu, isMenuOpen, openMenu } from './asst-menu.js';
31
31
  import { injectAssistantSidepanelStyles } from './asst-sidepanel-styles.js';
32
32
  import { createMascot, mascotCameoSvg } from '../synabun-mascot.js';
33
- import { createTutorialPreview } from '../ui-tutorial-preview.js';
34
33
 
35
34
  const PANEL_OWNER = 'assistant-sidepanel';
36
35
  const HOST_ID = 'sidepanel';
@@ -652,8 +651,11 @@ export function assistantPanelPeekable() {
652
651
  * Assistant is blocked. restore() puts back the panel's visibility, the docked
653
652
  * peers and the last-active panels, unless the tour ended on its hand-off to a
654
653
  * live tab ('done'): then the panel stays and the tab's composer takes the focus.
654
+ * The preview loads here, before anything of the panel changes: only a tour needs it.
655
655
  */
656
- export function beginAssistantTour({ onPreviewSend = () => {} } = {}) {
656
+ export async function beginAssistantTour({ onPreviewSend = () => {} } = {}) {
657
+ if (assistantBlocked()) return null;
658
+ const { createTutorialPreview } = await import('../ui-tutorial-preview.js');
657
659
  if (assistantBlocked()) return null;
658
660
  ensurePanel();
659
661
  const wasVisible = _visible;