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
@@ -0,0 +1,64 @@
1
+ // The complete wire format. Neither a health body, a translated subtitle, a URL,
2
+ // nor an exception/refusal message belongs in the trail or the server log.
3
+ export const DIAGNOSTIC_BATCH = 20;
4
+ const loadingTitles = [
5
+ 'loading.serverOffline', 'loading.connectionFailed', 'loading.health.databaseUnreachable.title',
6
+ 'loading.health.remoteUnreachable.title', 'loading.health.authError.title', 'loading.health.connectionError.title',
7
+ ];
8
+
9
+ const bool = value => typeof value === 'boolean';
10
+ const count = value => Number.isInteger(value) && value >= 1 && value <= 20;
11
+ const oneOf = (...values) => value => values.includes(value);
12
+ const states = oneOf('idle', 'launching', 'starting', 'waiting', 'stalled', 'failed', 'online', 'restarting', 'refused');
13
+ const moduleName = oneOf('entry', 'app');
14
+ const bootTag = value => typeof value === 'string' && /^(?:[0-9a-f]{8})?$/.test(value);
15
+ const events = {
16
+ 'startup-shown': {},
17
+ 'startup-status': { reason: oneOf('offline', 'loading', 'manual-retry') },
18
+ 'boot-complete': {},
19
+ // The first frame's overlay handed to the app's shell (taken over, or a shell's own overlay replaced it), and the
20
+ // first frame's fallback ended by the app's boot.
21
+ 'startup-adopt': { mode: oneOf('adopted', 'duplicate') },
22
+ 'boot-cleanup': { adopted: bool, removed: bool, hidden: bool, aborted: bool },
23
+ 'overlay-dedupe': { removed: count },
24
+ 'overlay-error': { title: oneOf(...loadingTitles, 'other'), serverOffline: bool },
25
+ 'overlay-reveal': { reason: oneOf('init', 'show', 'restart', 'probe') },
26
+ 'overlay-conceal': { reason: oneOf('hide', 'recovered', 'dismissed') },
27
+ 'hide-skipped': { state: states },
28
+ 'bridge-created': { reason: oneOf('restart', 'offline'), state: states },
29
+ 'bridge-stopped': { state: states },
30
+ 'bridge-state': { state: states },
31
+ 'bridge-probe': { result: oneOf('healthy', 'stopping', 'unhealthy', 'unreachable'), seenBoot: bootTag },
32
+ 'restart-request': { asked: bool, announced: bool, restartShown: bool, hasBridge: bool },
33
+ 'restart-snapshot': { asked: bool, accepted: bool, down: bool, refused: bool },
34
+ 'recover': { seenBoot: bootTag, needsReload: bool, appWasVisible: bool, restartShown: bool, reloadPending: bool },
35
+ 'reload-scheduled': { reason: oneOf('startup', 'restart', 'boot-changed', 'unknown-boot') },
36
+ 'probe-miss': { reason: oneOf('unreachable', 'unhealthy', 'stopping', 'boot-changed'), confirmation: bool },
37
+ // Probes went unanswered and the offline screen was held back (server-presence.js): the server is only slow, or
38
+ // the tab is hidden and cannot tell. Then the answer that ended that row, with how long it lasted.
39
+ 'probe-held': { reason: oneOf('slow', 'hidden'), misses: count },
40
+ 'probe-answered': { misses: count, seconds: value => Number.isInteger(value) && value >= 0 && value <= 3600 },
41
+ 'import-failed': { module: moduleName },
42
+ 'import-retry': { module: moduleName },
43
+ };
44
+
45
+ function matches(object, fields) {
46
+ return object !== null && typeof object === 'object' && !Array.isArray(object)
47
+ && Object.keys(object).length === Object.keys(fields).length
48
+ && Object.entries(fields).every(([key, accepts]) => Object.hasOwn(object, key) && accepts(object[key]));
49
+ }
50
+
51
+ const envelope = {
52
+ iso: s => typeof s === 'string' && /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(s)
53
+ && Number.isFinite(Date.parse(s)) && new Date(s).toISOString() === s,
54
+ pageId: s => typeof s === 'string' && /^[a-f0-9]{12}$/.test(s),
55
+ currentBoot: bootTag,
56
+ visibility: oneOf('visible', 'hidden', 'prerender'),
57
+ event: s => typeof s === 'string' && Object.hasOwn(events, s),
58
+ data: value => value !== null && typeof value === 'object',
59
+ };
60
+
61
+ export function validDiagnosticEntry(entry) {
62
+ return matches(entry, envelope) && matches(entry.data, events[entry.event]);
63
+ }
64
+
@@ -0,0 +1,52 @@
1
+ // SynaBun — the page while the memory database is being upgraded.
2
+ //
3
+ // /api/health answers `ok: true` with a `store` block while the store is migrating (or its upgrade failed): the server
4
+ // is up, so this is never the offline screen. A page that starts then waits here, says what is happening, and goes on
5
+ // with its normal boot when the store is back, instead of reading a 503 as "connection failed".
6
+ //
7
+ // No imports and no DOM unless `show` touches it: tests/memory-store-wait.test.mjs runs it under node.
8
+
9
+ /** What a health answer asks the page to show, or null when the store can be read. */
10
+ export function memoryStoreHold(health) {
11
+ const state = health?.store?.state;
12
+ if (state === 'migrating') return { state, titleKey: 'loading.memoryStore.migratingTitle', subKey: 'loading.memoryStore.migratingSub' };
13
+ if (state === 'failed') return { state, titleKey: 'loading.memoryStore.failedTitle', detail: String(health.store.note || '') };
14
+ return null;
15
+ }
16
+
17
+ /**
18
+ * Wait until the store can be read. Resolves true when it had to wait (what was fetched meanwhile is stale), false
19
+ * when it did not. A health request that fails is not a verdict: the page's own presence check decides about offline.
20
+ * @param {object} health the answer the page already has
21
+ * @param {{ fetchHealth: () => Promise<object>, show: (hold: object) => void, sleep?: (ms: number) => Promise<void>, intervalMs?: number }} io
22
+ */
23
+ export async function waitForMemoryStore(health, { fetchHealth, show, sleep = (ms) => new Promise((done) => setTimeout(done, ms)), intervalMs = 2000 }) {
24
+ let hold = memoryStoreHold(health);
25
+ if (!hold) return false;
26
+ let shown = '';
27
+ while (hold) {
28
+ const key = `${hold.state}\n${hold.detail || ''}`;
29
+ if (key !== shown) { shown = key; show(hold); }
30
+ await sleep(intervalMs);
31
+ const next = await fetchHealth().catch(() => null);
32
+ // No answer, or an answer without the block from a server that is restarting: keep what is shown and ask again.
33
+ if (next?.ok === true) hold = memoryStoreHold(next);
34
+ }
35
+ return true;
36
+ }
37
+
38
+ /** The page's side: the loading overlay says it, in the page's language. */
39
+ export function holdForMemoryStore(health, { fetchHealth, t, showLoadingError, document: doc = globalThis.document }) {
40
+ return waitForMemoryStore(health, {
41
+ fetchHealth,
42
+ show(hold) {
43
+ if (hold.state === 'failed') { showLoadingError(t(hold.titleKey), hold.detail, false); return; }
44
+ const overlay = doc?.getElementById('loading-overlay');
45
+ overlay?.classList.remove('error', 'server-offline');
46
+ const text = doc?.getElementById('loading-text');
47
+ const sub = doc?.getElementById('loading-sub');
48
+ if (text) text.textContent = t(hold.titleKey);
49
+ if (sub) sub.textContent = t(hold.subKey);
50
+ },
51
+ });
52
+ }
@@ -178,7 +178,7 @@ function fieldHTML(field) {
178
178
  <div class="sched-form-stack">
179
179
  <div class="sched-form-control">
180
180
  ${popup}
181
- ${refresh('sched-icon-btn')}
181
+ ${refresh('sx-icon-btn sched-icon-btn')}
182
182
  </div>
183
183
  <p class="sched-help${warn ? ' sched-help--warn' : ''}" id="${esc(id)}-help"${status}>${help}</p>
184
184
  </div>
@@ -416,7 +416,8 @@ export function usageParts(usage, costBrl, T) {
416
416
  if (output) parts.push(T('usage_out', { value: fmt(output) }));
417
417
  if (cached) parts.push(T('usage_cached', { value: fmt(cached) }));
418
418
  }
419
- // A cost of exactly 0 is a free model's answer (S5-free) and is shown as R$ 0,00; null is "no price known".
419
+ // A cost of exactly 0 is a free model's answer (none is listed since S5-free was retired on 2026-11-18) and is
420
+ // shown as R$ 0,00; null is "no price known".
420
421
  if (costBrl !== null && costBrl !== undefined && Number.isFinite(Number(costBrl)) && (Number(costBrl) > 0 || usage)) parts.push(T('costBrl', { value: formatBrl(costBrl) }));
421
422
  return parts;
422
423
  }
@@ -1164,7 +1164,14 @@ function wire() {
1164
1164
  transcript?.addEventListener('keydown', (event) => {
1165
1165
  if (event.target.matches?.('.mtc-plan-feedback') && event.key === 'Enter' && (event.metaKey || event.ctrlKey)) { event.preventDefault(); runPlanAction('feedback'); }
1166
1166
  });
1167
- $('.mtc-jump')?.addEventListener('click', () => { const rt = runtimeOf(activeTab()); if (rt) rt.scrolledUp = false; if (transcript) transcript.scrollTop = transcript.scrollHeight; renderTranscript(); });
1167
+ $('.mtc-jump')?.addEventListener('click', () => {
1168
+ const rt = runtimeOf(activeTab());
1169
+ if (rt) rt.scrolledUp = false;
1170
+ _scroll?.scrollToBottom({ force: true, immediate: true });
1171
+ const jump = $('.mtc-jump');
1172
+ if (jump) jump.hidden = true;
1173
+ updateScrollEdges();
1174
+ });
1168
1175
  const form = $('.mtc-composer');
1169
1176
  const input = $('.mtc-input');
1170
1177
  form?.addEventListener('submit', (event) => { event.preventDefault(); if (activeTab()?.running) stop(); else send(); });
@@ -6,10 +6,13 @@
6
6
  // its mark and nothing else. Every rule below uses a token; add a value to the block first.
7
7
 
8
8
  import { installCodeCopy } from '../ui-code-copy.js';
9
+ import { installOutput } from '../ui-output.js';
9
10
 
10
11
  export function injectMaritacaStyles() {
11
12
  // The Copy button of every code block: its stylesheet and its one click listener, in this document.
12
13
  installCodeCopy(document);
14
+ // The reading layer of an agent's answer (prose, tables, code): one stylesheet for the six panels.
15
+ installOutput(document);
13
16
  if (document.getElementById('maritaca-panel-styles')) return;
14
17
  const style = document.createElement('style');
15
18
  style.id = 'maritaca-panel-styles';
@@ -146,18 +149,9 @@ export function injectMaritacaStyles() {
146
149
  .mtc-msg-user .mtc-msg-card { max-width: 85%; border-radius: var(--mtc-radius-lg); background: var(--mtc-surface-2); padding: var(--mtc-space-2) var(--mtc-space-3); }
147
150
  .mtc-msg-text { white-space: pre-wrap; word-break: break-word; font-size: var(--mtc-fs-md); line-height: var(--mtc-lh); }
148
151
  .mtc-msg-agent { flex-direction: column; color: var(--mtc-text); word-break: break-word; gap: 4px; }
149
- .mtc-md { font-size: var(--mtc-fs-md); line-height: var(--mtc-lh); color: var(--mtc-text); min-width: 0; overflow-wrap: anywhere; }
150
- .mtc-md > :first-child { margin-top: 0; } .mtc-md > :last-child { margin-bottom: 0; }
151
- .mtc-md :is(p, ul, ol, pre, blockquote, table) { margin: 0 0 8px; }
152
- .mtc-md :is(h1, h2, h3, h4) { margin: 12px 0 6px; font-size: var(--mtc-fs-lg); font-weight: 600; line-height: var(--mtc-lh-tight); }
153
- .mtc-md :is(ul, ol) { padding-left: 18px; }
154
- .mtc-md a { color: var(--mtc-link); }
155
- .mtc-md code { font-family: var(--mtc-mono); font-size: 0.92em; background: var(--mtc-surface-2); padding: 1px 4px; border-radius: var(--mtc-radius-sm); }
156
- .mtc-md pre { background: var(--mtc-surface-1); border-radius: var(--mtc-radius-md); padding: 8px 10px; overflow-x: auto; font: var(--mtc-fs-sm)/1.55 var(--mtc-mono); }
157
- .mtc-md pre code { background: none; padding: 0; }
158
- .mtc-md blockquote { border-left: 2px solid var(--mtc-border-strong); padding-left: 10px; color: var(--mtc-text-2); }
159
- .mtc-md table { border-collapse: collapse; display: block; overflow-x: auto; }
160
- .mtc-md :is(th, td) { border: 1px solid var(--mtc-border); padding: 3px 8px; text-align: left; }
152
+ /* An answer's prose, tables and code are the shared reading layer (../ui-output.js): one system for the six
153
+ side panels. A tag is never styled here again; this panel's voice is its link colour. */
154
+ .mtc-md { --sbo-link: var(--mtc-link); }
161
155
  .mtc-thought { margin: 2px 0; font-size: var(--mtc-fs-sm); color: var(--mtc-text-3); flex-shrink: 0; }
162
156
  .mtc-thought summary { cursor: pointer; list-style: none; padding: 4px 0; display: inline-flex; align-items: center; gap: 6px; }
163
157
  .mtc-thought summary::-webkit-details-marker { display: none; }
@@ -435,6 +429,13 @@ export function injectMaritacaStyles() {
435
429
  @media (prefers-reduced-motion: reduce) {
436
430
  .mtc-panel, .mtc-panel *, .mtc-panel *::before, .mtc-panel *::after, .mtc-session-pill, .mtc-session-pill *, .mtc-pop, .mtc-pop * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
437
431
  }
432
+
433
+ /* ── Reading pass (2026-11-21) ──
434
+ An answer's prose, tables and code are ../ui-output.js. Here: what the user wrote reads at the answer's size,
435
+ a turn's footer is legible, and a touch screen (no hover) always shows a message's Copy / Edit / Retry. */
436
+ .mtc-msg-text { font-size: var(--mtc-fs-lg); }
437
+ .mtc-turn-foot { font-size: var(--mtc-fs-sm); }
438
+ @media (hover: none) { .mtc-turn-actions { opacity: 1; } }
438
439
  `;
439
440
  document.head.appendChild(style);
440
441
  }
@@ -16,6 +16,8 @@
16
16
  // shown: a session with many sub-agents costs a store and a pill each.
17
17
  // ─────────────────────────────────────────────────────────────────────────────
18
18
 
19
+ import { getProviderMeta, isMaritacaModel } from '../provider-icons.js';
20
+
19
21
  import { state, emit } from '../state.js';
20
22
  import { injectStyles } from './ocp-v2-styles.js';
21
23
  import { getDefaultStore } from './ocp-v2-state.js';
@@ -547,6 +549,11 @@ export function createChildPanel({
547
549
  function renderPill() {
548
550
  if (!_trayPill || _destroyed) return;
549
551
  const s = store.getState();
552
+ const brand = isMaritacaModel(s.model || s.sessionInfo?.model) ? 'maritaca' : 'opencode';
553
+ if (_trayPill.dataset.modelBrand !== brand) {
554
+ _trayPill.querySelector('.term-minimized-pill-icon').innerHTML = brand === 'maritaca' ? getProviderMeta(brand).icon : OPENCODE_ICON;
555
+ _trayPill.dataset.modelBrand = brand;
556
+ }
550
557
  const said = pillState(s, { visible: _visible, started });
551
558
  const arrows = '↳'.repeat(Math.max(1, Math.min(3, (Number(depth) || 0) + 1)));
552
559
  _pillLabel.textContent = `${arrows} ${sessionTitleFor(store)}`;
@@ -0,0 +1,109 @@
1
+ // ─────────────────────────────────────────────────────────────────────────────
2
+ // OpenCode V2 — a session whose folder is gone
3
+ //
4
+ // OpenCode binds a session to the folder it was created in, for good. When that
5
+ // folder no longer exists (a worktree that was removed, a project that was
6
+ // moved), OpenCode 2 still lists the session and even creates a new one there,
7
+ // and then refuses every prompt of it: 404 "Location not found: <folder>".
8
+ // Sending another folder with the prompt changes nothing.
9
+ //
10
+ // So the panel cannot repair such a session: it moves on. This module decides
11
+ // (DOM-free, unit-tested; the server imports the message and the code):
12
+ // • which folder an error says is gone, and whether it is this panel's;
13
+ // • where to go instead: the registered project the folder was inside (the
14
+ // project root of a removed worktree), else no project at all, which is the
15
+ // folder SynaBun's OpenCode serve runs in;
16
+ // • what to tell the user.
17
+ // ocp-v2-panel.js does the moving (a new session in the other folder).
18
+ // ─────────────────────────────────────────────────────────────────────────────
19
+
20
+ /** The `code` of a refusal SynaBun's server makes for a folder that does not exist. */
21
+ export const LOCATION_MISSING_CODE = 'LOCATION_MISSING';
22
+
23
+ /** OpenCode's own sentence for it; SynaBun's server refuses in the same words, so one reading covers both. */
24
+ export function locationNotFoundMessage(directory) {
25
+ return `Location not found: ${String(directory || '').trim()}`;
26
+ }
27
+
28
+ const LOCATION_NOT_FOUND_RE = /Location not found:\s*(\S.*?)\s*$/i;
29
+
30
+ /** The folder an error message says is gone, or null when it says nothing of the kind. */
31
+ export function missingLocationOf(message) {
32
+ const text = typeof message === 'string' ? message : String(message?.message || message?.error || '');
33
+ const match = text.match(LOCATION_NOT_FOUND_RE);
34
+ return match ? match[1] : null;
35
+ }
36
+
37
+ // A folder as it is compared: one kind of separator, no trailing one, and no
38
+ // letter case on a Windows drive path.
39
+ function folderKey(folder) {
40
+ let key = String(folder || '').trim().replace(/\\/g, '/');
41
+ if (key.length > 1) key = key.replace(/\/+$/, '') || '/';
42
+ if (/^[A-Za-z]:(\/|$)/.test(key)) key = key.toLowerCase();
43
+ return key;
44
+ }
45
+
46
+ /** Whether two paths name the same folder (separators, a trailing slash, a Windows drive's case). */
47
+ export function sameFolder(a, b) {
48
+ const left = folderKey(a);
49
+ return !!left && left === folderKey(b);
50
+ }
51
+
52
+ /** Whether `folder` is `parent` or inside it. */
53
+ export function folderInside(folder, parent) {
54
+ const inner = folderKey(folder);
55
+ const outer = folderKey(parent);
56
+ if (!inner || !outer) return false;
57
+ if (inner === outer) return true;
58
+ return inner.startsWith(outer.endsWith('/') ? outer : `${outer}/`);
59
+ }
60
+
61
+ const projectPathOf = (project) => (typeof project === 'string' ? project : String(project?.path || ''));
62
+
63
+ /**
64
+ * Where to work instead of a folder that is gone: the deepest registered
65
+ * project that contains it (and is not one of `avoid`, the folders already
66
+ * found gone), else '' — no project, the folder the serve itself runs in.
67
+ */
68
+ export function fallbackProjectFor(missing, projects, { avoid = [] } = {}) {
69
+ const gone = [missing, ...avoid].filter(Boolean);
70
+ let best = '';
71
+ for (const project of Array.isArray(projects) ? projects : []) {
72
+ const path = projectPathOf(project);
73
+ if (!path || !folderInside(missing, path)) continue;
74
+ if (gone.some((folder) => sameFolder(folder, path))) continue;
75
+ if (folderKey(path).length > folderKey(best).length) best = path;
76
+ }
77
+ return best;
78
+ }
79
+
80
+ /**
81
+ * The folder an error names as gone, when it is this panel's: the project it
82
+ * is on, or the folder of the session on screen. Null otherwise (an error about
83
+ * something else, or about a folder that is not this panel's to leave).
84
+ */
85
+ export function missingPanelLocation({ message, cwd = '', sessionDirectory = '' } = {}) {
86
+ const missing = missingLocationOf(message);
87
+ if (!missing) return null;
88
+ return sameFolder(missing, cwd) || sameFolder(missing, sessionDirectory) ? missing : null;
89
+ }
90
+
91
+ /** What the user is told once the panel has moved on. */
92
+ export function locationRecoveryNotice({ missing, fallback } = {}) {
93
+ const gone = `The folder ${missing} no longer exists, so OpenCode cannot run a session there.`;
94
+ return fallback
95
+ ? `${gone} A new session was started in ${fallback}. Send your message again.`
96
+ : `${gone} A new session was started without a project: choose one in the project menu, then send your message again.`;
97
+ }
98
+
99
+ /**
100
+ * The move for a folder that is gone: `{ missing, fallback, notice }`, or null
101
+ * when there is nowhere better to go (the panel is already on no project, and
102
+ * no registered project holds the folder: moving again would change nothing).
103
+ */
104
+ export function planLocationRecovery({ missing, cwd = '', projects = [], avoid = [] } = {}) {
105
+ if (!missing) return null;
106
+ const fallback = fallbackProjectFor(missing, projects, { avoid });
107
+ if (!fallback && !folderKey(cwd)) return null;
108
+ return { missing, fallback, notice: locationRecoveryNotice({ missing, fallback }) };
109
+ }
@@ -5,6 +5,8 @@
5
5
  // as { providerID, modelID } so api.send() can pass it through to OpenCode.
6
6
  // ─────────────────────────────────────────────────────────────────────────────
7
7
 
8
+ import { getProviderMeta, isMaritacaModel } from '../provider-icons.js';
9
+
8
10
  import { fetchProvidersFull } from './ocp-v2-providers.js';
9
11
  import { opencodeProviders } from '../opencode-providers.js';
10
12
  import { modelRowMeta } from './ocp-v2-status-logic.js';
@@ -219,6 +221,7 @@ function applyLabelFromState() {
219
221
  }
220
222
  const label = m.modelID || '';
221
223
  _label.textContent = label || _dd?.dataset.placeholder || 'model...';
224
+ if (isMaritacaModel(m)) _label.insertAdjacentHTML('afterbegin', maritacaMark());
222
225
  _dd?.classList.add('has-value');
223
226
  }
224
227
 
@@ -615,6 +618,10 @@ function connectProviderOption() {
615
618
  return opt;
616
619
  }
617
620
 
621
+ function maritacaMark() {
622
+ return `<span class="ocpv2-model-mark" aria-hidden="true">${getProviderMeta('maritaca').icon}</span>`;
623
+ }
624
+
618
625
  function makeOption(provId, entry, currentFull, favorites) {
619
626
  const fullId = `${provId}/${entry.id}`;
620
627
  const badges = capBadgesHtml(entry._obj);
@@ -631,7 +638,7 @@ function makeOption(provId, entry, currentFull, favorites) {
631
638
  // every row maps onto the same 4-column grid (name | meta | caps | star).
632
639
  const meta = modelRowMeta(entry._obj);
633
640
  opt.innerHTML =
634
- `<span class="ocpv2-dd-model-name">${escHtml(entry.id)}</span>`
641
+ `<span class="ocpv2-dd-model-name">${isMaritacaModel(fullId) ? maritacaMark() : ''}${escHtml(entry.id)}</span>`
635
642
  + `<span class="ocpv2-dd-model-meta">${meta.status ? `<span class="ocpv2-dd-model-status">${escHtml(meta.status)}</span>` : ''}${escHtml(meta.price)}</span>`
636
643
  + `<span class="ocpv2-dd-caps">${badges}</span>`;
637
644
 
@@ -1,4 +1,6 @@
1
1
  import { syncOpenCodeWorkerQuestions, forgetWorkerQuestions } from './ocp-v2-ws.js';
2
+ import { getProviderMeta, isMaritacaModel } from '../provider-icons.js';
3
+
2
4
  import { workerRestart } from '../worker-restart.js';
3
5
  import { t } from '../i18n.js';
4
6
  import { hostedSidepanelId, sidepanelHost } from '../ui-sidepanel-runtime.js';
@@ -37,6 +39,7 @@ import { closeWithPromptsConfirm, prefilledDraft, samePrompts } from './ocp-v2-c
37
39
  import { setSelectOptions, projectOptionRows } from './ocp-v2-select.js';
38
40
  import { replyFailed, replyError } from './ocp-v2-caps.js';
39
41
  import { rehydratePanelSession, recoveredErrorSweep } from './ocp-v2-rehydrate.js';
42
+ import { missingLocationOf, missingPanelLocation, planLocationRecovery, sameFolder } from './ocp-v2-location-logic.js';
40
43
  import { headerStatus } from './ocp-v2-render-logic.js';
41
44
  import { runTurnLive } from '../sidepanel-session-status.js';
42
45
  import {
@@ -104,6 +107,7 @@ let _statusEl = null;
104
107
  let _titleEl = null;
105
108
  let _tabSessionIds = []; // ordered session IDs that own a tray pill
106
109
  let _tabPills = new Map(); // sessionId -> pill element
110
+ const maritacaTabs = new Set();
107
111
  let _tabInfoCache = new Map(); // sessionId -> last-known session info (title, etc.)
108
112
  const _automationRunIds = new Map(); // sessionId -> native loop runId
109
113
  // The sessions whose automation run is live. The ownership module keeps the set, so that the socket layer
@@ -140,6 +144,9 @@ let _docClickWired = false;
140
144
  let _healTimer = null;
141
145
  let _healingPromise = null;
142
146
  let _healRetryCount = 0;
147
+ // Folders OpenCode said are gone ("Location not found"), and the move away from one that is under way.
148
+ const _goneLocations = new Set();
149
+ let _locationRecovery = null;
143
150
  const _sessionTitleState = new Map(); // sessionId -> { state, title, requestId, controller }
144
151
  const _titleReassertTimers = new Map();
145
152
  // Renames whose request is out. Until the server has answered, the title a
@@ -635,7 +642,7 @@ function buildPanel() {
635
642
  (runId) => fetch('/api/loop/stop', {
636
643
  method: 'POST',
637
644
  headers: { 'Content-Type': 'application/json' },
638
- body: JSON.stringify({ runId }),
645
+ body: JSON.stringify({ runId, action: 'stop' }),
639
646
  }).catch(() => {}),
640
647
  );
641
648
  if (stopped) saveAutomationTabs();
@@ -719,10 +726,12 @@ function handleStoreEvent(event, stateSnapshot) {
719
726
  if (event?.type === 'running:set' && !nextState.running && nextState.sessionId) {
720
727
  _titleNeedsReassert(nextState.sessionId);
721
728
  }
729
+ if (event?.type === 'config:model') rememberTabBrand(nextState.sessionId, nextState.model);
722
730
  if (event?.type === 'session:info') keepOwnSessionTitle(nextState);
723
731
  if (TRANSCRIPT_EVENTS.has(event?.type)) queueHeaderSync();
724
732
  else syncHeader();
725
733
  maybeScheduleAutoHeal(event, nextState);
734
+ maybeRecoverMissingLocation(event, nextState);
726
735
  }
727
736
 
728
737
  // A message, a part or a streamed chunk changes nothing the header or the pills show (headerStatus and the tab
@@ -877,9 +886,86 @@ function isRecoverablePanelError(err) {
877
886
  const msg = String(err?.message || err?.error || err || '').trim();
878
887
  if (!msg) return true;
879
888
  if (/choose continue|question reply failed|plan action failed|could not create plan file|could not read the plan|rename failed|could not delete|could not unarchive|not queued/i.test(msg)) return false;
889
+ // A folder that is gone is not a lost connection: maybeRecoverMissingLocation moves the panel on.
890
+ if (missingLocationOf(msg)) return false;
880
891
  return /websocket|closed|disconnect|offline|reconnect|request timeout|timeout|network|failed|server|session|opencode|send|boot|no session|not connected/i.test(msg);
881
892
  }
882
893
 
894
+ // ── A session whose folder is gone ───────────────────────────────────────────
895
+ // OpenCode binds a session to the folder it was created in and refuses every
896
+ // prompt of one whose folder no longer exists ("Location not found: …"): a
897
+ // worktree that was removed, a project that was moved. Nothing repairs such a
898
+ // session, so the panel moves on by itself: a new session in the registered
899
+ // project the folder was inside (else with no project), and a notice that says
900
+ // so. The prompt that failed is back in the box by then, and the box is the
901
+ // panel's: it stays. ocp-v2-location-logic.js decides; this is the panel's own
902
+ // rebinding (repair), so a choice the user makes meanwhile still wins.
903
+ function isGoneLocation(folder) {
904
+ for (const gone of _goneLocations) if (sameFolder(gone, folder)) return true;
905
+ return false;
906
+ }
907
+
908
+ function maybeRecoverMissingLocation(event, s) {
909
+ if (event?.type !== 'error:push' || !_panelEl || _locationRecovery) return;
910
+ const last = s.errors[s.errors.length - 1];
911
+ if (!last || last.notice) return;
912
+ const missing = missingPanelLocation({
913
+ message: last.message, cwd: s.cwd || '', sessionDirectory: s.sessionInfo?.directory || '',
914
+ });
915
+ if (!missing) return;
916
+ const at = captureBinding(getDefaultStore());
917
+ _locationRecovery = recoverMissingLocation(missing, at)
918
+ .catch((err) => console.warn('[ocp-v2-panel] missing-folder recovery failed', err))
919
+ .finally(() => { _locationRecovery = null; });
920
+ }
921
+
922
+ async function recoverMissingLocation(missing, at) {
923
+ // The send that failed settles first (its text and attachments return to the box).
924
+ await new Promise((resolve) => setTimeout(resolve, 0));
925
+ const projects = await loadProjectsOnce();
926
+ // The user went somewhere else meanwhile: that choice stands.
927
+ if (!at.isCurrent()) return;
928
+ _goneLocations.add(missing);
929
+ // A folder the panel moves to may be gone as well (a registered project that was deleted): the next one, then none.
930
+ for (let attempt = 0; attempt < 4; attempt += 1) {
931
+ const plan = planLocationRecovery({ missing, cwd: getState().cwd || '', projects, avoid: [..._goneLocations] });
932
+ if (!plan) return;
933
+ const moved = await moveToFolder(plan.fallback);
934
+ if (moved.ok) {
935
+ pushError({ message: plan.notice, notice: true });
936
+ return;
937
+ }
938
+ if (!moved.missing || !sameFolder(moved.missing, plan.fallback)) {
939
+ pushError({ message: moved.error });
940
+ return;
941
+ }
942
+ _goneLocations.add(moved.missing);
943
+ }
944
+ }
945
+
946
+ // The panel on `folder` ('' for no project) with a new session, leaving the one on screen.
947
+ async function moveToFolder(folder) {
948
+ const next = String(folder || '');
949
+ const nav = _nav.repair();
950
+ setCwd(next);
951
+ if (next) storage.setItem(STOR_PROJECT, next);
952
+ else storage.removeItem(STOR_PROJECT);
953
+ if (nav.sessionId) {
954
+ nav.apply(() => {
955
+ clearMessages();
956
+ setSession(null, null);
957
+ bindPrimarySession(getDefaultStore(), null);
958
+ });
959
+ }
960
+ try {
961
+ await startFreshSession({ cwd: next || undefined, nav });
962
+ return { ok: true };
963
+ } catch (err) {
964
+ const error = err?.message || 'New session failed';
965
+ return { ok: false, error, missing: missingLocationOf(error) };
966
+ }
967
+ }
968
+
883
969
  // ── Session picker + rename ─────────────────────────────────────────────────
884
970
 
885
971
  function sessionTitleFor(stateOrSession) {
@@ -1471,7 +1557,8 @@ async function switchToSession(sid, info = null, { nav } = {}) {
1471
1557
  const dirFromInfo = info?.directory;
1472
1558
  if (dirFromInfo && dirFromInfo !== getState().cwd) {
1473
1559
  setCwd(dirFromInfo);
1474
- storage.setItem(STOR_PROJECT, dirFromInfo);
1560
+ // (Not a folder OpenCode said is gone: the next new session would start there.)
1561
+ if (!isGoneLocation(dirFromInfo)) storage.setItem(STOR_PROJECT, dirFromInfo);
1475
1562
  }
1476
1563
  });
1477
1564
  if (!bound) { ensureTab(sid, info); renderPill(); return; }
@@ -1498,8 +1585,9 @@ async function restoreSessionSelections(sid, info) {
1498
1585
  const dir = full.directory;
1499
1586
  if (dir && dir !== getState().cwd) {
1500
1587
  setCwd(dir);
1501
- storage.setItem(STOR_PROJECT, dir);
1588
+ if (!isGoneLocation(dir)) storage.setItem(STOR_PROJECT, dir);
1502
1589
  }
1590
+ rememberTabBrand(sid, full.model);
1503
1591
  applySessionSelections(getDefaultStore(), full);
1504
1592
  // Fresh metadata too: keeps the title right after a switch.
1505
1593
  getDefaultStore().setSessionInfo(full);
@@ -1625,6 +1713,10 @@ async function boot() {
1625
1713
  for (const sid of savedTabs) {
1626
1714
  const info = byId.get(sid);
1627
1715
  if (info) {
1716
+ if (info.model) {
1717
+ if (isMaritacaModel(info.model)) maritacaTabs.add(sid);
1718
+ else maritacaTabs.delete(sid);
1719
+ }
1628
1720
  liveTabs.push(sid);
1629
1721
  _tabInfoCache.set(sid, info);
1630
1722
  ensureOpenCodeTitleState(sid, info, { manual: true });
@@ -2152,7 +2244,9 @@ function loadTabSessions() {
2152
2244
  try {
2153
2245
  const raw = storage.getItem(STOR_TABS);
2154
2246
  if (!raw) return [];
2155
- return readSavedTabs(JSON.parse(raw))
2247
+ const tabs = readSavedTabs(JSON.parse(raw));
2248
+ for (const tab of tabs) if (tab.modelBrand === 'maritaca') maritacaTabs.add(tab.sessionId);
2249
+ return tabs
2156
2250
  .map(({ sessionId }) => sessionId)
2157
2251
  .filter((sessionId) => !_foreignActiveAutomationSessions.has(sessionId));
2158
2252
  } catch { return []; }
@@ -2169,7 +2263,7 @@ function saveTabSessions() {
2169
2263
  .map((row) => row.sessionId));
2170
2264
  const preserved = existing.filter(({ sessionId }) => foreignSessionIds.has(sessionId) && !_tabSessionIds.includes(sessionId));
2171
2265
  const tabs = _tabSessionIds.map((sessionId) => ({
2172
- ...savedById.get(sessionId), sessionId, needsYou: tabNeedsYou(sessionId),
2266
+ ...savedById.get(sessionId), sessionId, modelBrand: maritacaTabs.has(sessionId) ? 'maritaca' : undefined, needsYou: tabNeedsYou(sessionId),
2173
2267
  }));
2174
2268
  storage.setItem(STOR_TABS, JSON.stringify([...tabs, ...preserved]));
2175
2269
  _savedTabWaiting = new Map(tabs.map(({ sessionId, needsYou }) => [sessionId, needsYou]));
@@ -2198,10 +2292,20 @@ function syncSavedTabWaiting() {
2198
2292
  if (_tabSessionIds.some((sid) => _savedTabWaiting.get(sid) !== tabNeedsYou(sid))) saveTabSessions();
2199
2293
  }
2200
2294
 
2295
+ function rememberTabBrand(sessionId, model) {
2296
+ if (!sessionId || !model) return;
2297
+ const maritaca = isMaritacaModel(model);
2298
+ if (maritaca === maritacaTabs.has(sessionId)) return;
2299
+ if (maritaca) maritacaTabs.add(sessionId);
2300
+ else maritacaTabs.delete(sessionId);
2301
+ if (_tabSessionIds.includes(sessionId)) saveTabSessions();
2302
+ }
2303
+
2201
2304
  function ensureTab(sessionId, info = null) {
2202
2305
  if (!sessionId) return;
2203
2306
  if (info) _tabInfoCache.set(sessionId, info);
2204
2307
  if (!_tabSessionIds.includes(sessionId)) {
2308
+ rememberTabBrand(sessionId, info?.model || (sessionId === getState().sessionId && getState().model));
2205
2309
  _tabSessionIds.push(sessionId);
2206
2310
  saveTabSessions();
2207
2311
  }
@@ -2216,7 +2320,7 @@ function dismissAutomationSession(sessionId) {
2216
2320
  endWorkerRunOnClose(runId, () => fetch('/api/loop/stop', {
2217
2321
  method: 'POST',
2218
2322
  headers: { 'Content-Type': 'application/json' },
2219
- body: JSON.stringify({ runId }),
2323
+ body: JSON.stringify({ runId, action: 'tab_close' }),
2220
2324
  }).catch(() => {}));
2221
2325
  }
2222
2326
  return true;
@@ -2285,6 +2389,7 @@ function removeTab(sessionId, { byUser = false } = {}) {
2285
2389
  _tabSessionIds = _tabSessionIds.filter((s) => s !== sessionId);
2286
2390
  if (_tabSessionIds.length !== before) saveTabSessions();
2287
2391
  _tabInfoCache.delete(sessionId);
2392
+ maritacaTabs.delete(sessionId);
2288
2393
  const titleState = _sessionTitleState.get(sessionId);
2289
2394
  titleState?.controller?.abort();
2290
2395
  _sessionTitleState.delete(sessionId);
@@ -2326,6 +2431,8 @@ function createTabPill(sessionId) {
2326
2431
  pill.className = 'term-minimized-pill ocpv2-session-pill';
2327
2432
  pill.dataset.owner = PANEL_OWNER;
2328
2433
  pill.dataset.sessionId = sessionId;
2434
+ pill.getAutomationRunId = () => _automationRunIds.get(sessionId);
2435
+ pill.hasQueuedWorkerPrompts = () => _automationRunIds.has(sessionId) && promptsWaitingFor(sessionId).length > 0;
2329
2436
  pill.innerHTML = `
2330
2437
  <span class="ocpv2-pill-ring" aria-hidden="true"><i></i></span>
2331
2438
  <span class="term-minimized-pill-icon">${OPENCODE_ICON}</span>
@@ -2425,6 +2532,11 @@ function renderPill() {
2425
2532
  if (!pill) continue;
2426
2533
  _tabPills.set(sid, pill);
2427
2534
  }
2535
+ const brand = maritacaTabs.has(sid) ? 'maritaca' : 'opencode';
2536
+ if (pill.dataset.modelBrand !== brand) {
2537
+ pill.querySelector('.term-minimized-pill-icon').innerHTML = brand === 'maritaca' ? getProviderMeta(brand).icon : OPENCODE_ICON;
2538
+ pill.dataset.modelBrand = brand;
2539
+ }
2428
2540
  const labelEl = pill.querySelector('.term-minimized-pill-label');
2429
2541
  // Written only when it changed: the same text again is still a new text node, which the tray's
2430
2542
  // observer (ui-navbar.js) answers by going through every pill.