@circuitwall/jarela 2.5.0 → 2.5.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 (188) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +5 -5
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/react-loadable-manifest.json +2 -2
  6. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next/standalone/.next/server/app/_not-found.html +2 -2
  14. package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
  15. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  16. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  17. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  19. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +8 -1
  20. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
  21. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +8 -1
  22. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +8 -1
  24. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +8 -1
  26. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +8 -1
  28. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +7 -0
  30. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js +7 -0
  32. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/v1/credentials/route.js +7 -0
  34. package/.next/standalone/.next/server/app/api/v1/credentials/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js +8 -1
  36. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js +7 -0
  38. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js +7 -0
  40. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js +8 -1
  42. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js +8 -1
  44. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/api/v1/events/route.js +8 -1
  46. package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js +8 -1
  48. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js +8 -1
  50. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js.nft.json +1 -1
  51. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js +8 -1
  52. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js.nft.json +1 -1
  53. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js +8 -1
  54. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/api/v1/extensions/route.js +8 -1
  56. package/.next/standalone/.next/server/app/api/v1/extensions/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js +8 -1
  58. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js +8 -1
  60. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js.nft.json +1 -1
  61. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +8 -1
  62. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.nft.json +1 -1
  63. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js +7 -0
  64. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js.nft.json +1 -1
  65. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js +7 -0
  66. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js.nft.json +1 -1
  67. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/callback/route.js +22 -1
  68. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/start/route.js +22 -1
  69. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/status/route.js +22 -1
  70. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/callback/route.js +19 -2
  71. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/start/route.js +19 -2
  72. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/status/route.js +19 -2
  73. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js +12 -2
  74. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js.nft.json +1 -1
  75. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js +7 -0
  76. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js.nft.json +1 -1
  77. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js +7 -0
  78. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js.nft.json +1 -1
  79. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js +7 -0
  80. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js.nft.json +1 -1
  81. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js +7 -0
  82. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js.nft.json +1 -1
  83. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js +7 -0
  84. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js.nft.json +1 -1
  85. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js +12 -2
  86. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js.nft.json +1 -1
  87. package/.next/standalone/.next/server/app/api/v1/packages/route.js +12 -2
  88. package/.next/standalone/.next/server/app/api/v1/packages/route.js.nft.json +1 -1
  89. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +8 -1
  90. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.nft.json +1 -1
  91. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +7 -0
  92. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.nft.json +1 -1
  93. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js +7 -0
  94. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js.nft.json +1 -1
  95. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js +7 -0
  96. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js.nft.json +1 -1
  97. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js +8 -1
  98. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js.nft.json +1 -1
  99. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js +7 -0
  100. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js.nft.json +1 -1
  101. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +52 -45
  102. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.nft.json +1 -1
  103. package/.next/standalone/.next/server/app/api/v1/tools/route.js +8 -1
  104. package/.next/standalone/.next/server/app/api/v1/tools/route.js.nft.json +1 -1
  105. package/.next/standalone/.next/server/app/api/v1/update/apply/route.js.nft.json +1 -1
  106. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js +8 -1
  107. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js.nft.json +1 -1
  108. package/.next/standalone/.next/server/app/api/v1/watchers/route.js +8 -1
  109. package/.next/standalone/.next/server/app/api/v1/watchers/route.js.nft.json +1 -1
  110. package/.next/standalone/.next/server/app/page.js +73385 -73375
  111. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  112. package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  113. package/.next/standalone/.next/server/app-paths-manifest.json +5 -5
  114. package/.next/standalone/.next/server/chunks/1433.js +1 -1
  115. package/.next/standalone/.next/server/chunks/210.js +6 -6
  116. package/.next/standalone/.next/server/chunks/3524.js +31 -15
  117. package/.next/standalone/.next/server/chunks/3566.js +1 -1
  118. package/.next/standalone/.next/server/chunks/4189.js +1 -1
  119. package/.next/standalone/.next/server/chunks/{9590.js → 423.js} +10 -3
  120. package/.next/standalone/.next/server/chunks/4596.js +5 -2
  121. package/.next/standalone/.next/server/chunks/46.js +7 -0
  122. package/.next/standalone/.next/server/chunks/540.js +29 -5
  123. package/.next/standalone/.next/server/chunks/5585.js +41 -3
  124. package/.next/standalone/.next/server/chunks/5908.js +10 -10
  125. package/.next/standalone/.next/server/chunks/{3399.js → 6058.js} +485 -3
  126. package/.next/standalone/.next/server/chunks/{9164.js → 6190.js} +13828 -13581
  127. package/.next/standalone/.next/server/chunks/{1388.js → 8842.js} +5961 -5793
  128. package/.next/standalone/.next/server/chunks/9032.js +5 -5
  129. package/.next/standalone/.next/server/chunks/{7547.js → 9217.js} +485 -3
  130. package/.next/standalone/.next/server/instrumentation.js +7 -0
  131. package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
  132. package/.next/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  133. package/.next/standalone/.next/server/middleware.js +7 -0
  134. package/.next/standalone/.next/server/pages/404.html +2 -2
  135. package/.next/standalone/.next/server/pages/500.html +1 -1
  136. package/.next/standalone/.next/server/preview-props.json +3 -3
  137. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  138. package/.next/standalone/.next/static/chunks/app/{page-2ef8d75d40eb4311.js → page-4112e14360a9909e.js} +1291 -1281
  139. package/.next/standalone/.next/static/css/{c160ea862133acd2.css → 5b30046ba49144c5.css} +2 -2
  140. package/.next/standalone/docs/adoption/changesets.json +151 -0
  141. package/.next/standalone/package.json +2 -1
  142. package/CHANGELOG.md +46 -0
  143. package/browser-extension/background.js +5 -539
  144. package/browser-extension/lib/form-editing.mjs +541 -0
  145. package/components/chat/MessageBubble.tsx +4 -736
  146. package/components/chat/MessageContent.tsx +749 -0
  147. package/components/dashboard/DashboardPanel.test.tsx +34 -0
  148. package/components/dashboard/DashboardPanel.tsx +1 -1
  149. package/components/layout/MenuPanel.tsx +1 -1
  150. package/components/ui/BootScreen.test.tsx +1 -0
  151. package/components/ui/BootScreen.tsx +1 -0
  152. package/components/ui/ServerStatus.test.tsx +50 -0
  153. package/components/ui/ServerStatus.tsx +10 -8
  154. package/hooks/useSSE.test.ts +46 -0
  155. package/lib/agents/llm.ts +1 -1
  156. package/lib/agents/output-validator/validator.test.ts +4 -0
  157. package/lib/agents/output-validator/validator.ts +1 -1
  158. package/lib/agents/prompt-registry.test.ts +11 -0
  159. package/lib/agents/prompt-registry.ts +13 -0
  160. package/lib/agents/retry-prompts.ts +17 -0
  161. package/lib/agents/run-retry.ts +671 -0
  162. package/lib/agents/run-thread.retry.test.ts +176 -2
  163. package/lib/agents/run-thread.test.ts +6 -6
  164. package/lib/agents/run-thread.ts +9 -717
  165. package/lib/agents/stream-collector.test.ts +28 -4
  166. package/lib/agents/stream-collector.ts +5 -28
  167. package/lib/agents/tool-outcomes.ts +61 -0
  168. package/lib/documents/remote/confluence.test.ts +65 -0
  169. package/lib/documents/remote/confluence.ts +35 -9
  170. package/lib/documents/remote/jira.ts +1 -1
  171. package/lib/health/probes.test.ts +32 -0
  172. package/lib/health/probes.ts +29 -14
  173. package/lib/integrations/atlassian/manifest.ts +5 -3
  174. package/lib/integrations/github/manifest.ts +7 -4
  175. package/lib/integrations/gmail-oauth.ts +16 -1
  176. package/lib/integrations/microsoft-oauth.ts +17 -2
  177. package/lib/integrations/outlook/manifest.ts +10 -8
  178. package/lib/stores/integrations.ts +1 -0
  179. package/lib/tools/communications/calendar-aliases.test.ts +77 -1
  180. package/lib/tools/communications/gmail.test.ts +13 -0
  181. package/lib/tools/communications/ms-graph.test.ts +26 -3
  182. package/lib/tools/communications/ms-graph.ts +9 -11
  183. package/lib/tools/communications/outlook-calendar.ts +94 -17
  184. package/lib/tools/packages/default-packages/atlassian.ts +8 -2
  185. package/package.json +2 -1
  186. package/scripts/standalone-footprint.mjs +1 -1
  187. /package/.next/standalone/.next/static/{544OFJV-q0RC6Gjgje4LT → VZXMorlOmSmi3dUr7K5UX}/_buildManifest.js +0 -0
  188. /package/.next/standalone/.next/static/{544OFJV-q0RC6Gjgje4LT → VZXMorlOmSmi3dUr7K5UX}/_ssgManifest.js +0 -0
@@ -159,14 +159,14 @@ function useTheme() {
159
159
  /***/ 39852:
160
160
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
161
161
 
162
- Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 67264));
162
+ Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 92966));
163
163
  ;
164
164
  Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 12283));
165
165
 
166
166
 
167
167
  /***/ }),
168
168
 
169
- /***/ 67264:
169
+ /***/ 92966:
170
170
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
171
171
 
172
172
  "use strict";
@@ -5209,34 +5209,20 @@ function unwrapLangChainSerializable(payload, depth = 0) {
5209
5209
  return obj;
5210
5210
  }
5211
5211
 
5212
- // EXTERNAL MODULE: ./node_modules/react-markdown/lib/index.js + 90 modules
5213
- var lib = __webpack_require__(66804);
5214
- // EXTERNAL MODULE: ./node_modules/remark-gfm/lib/index.js + 56 modules
5215
- var remark_gfm_lib = __webpack_require__(32957);
5216
- // EXTERNAL MODULE: ./node_modules/rehype-raw/lib/index.js + 30 modules
5217
- var rehype_raw_lib = __webpack_require__(17848);
5218
- // EXTERNAL MODULE: ./node_modules/rehype-highlight/lib/index.js + 43 modules
5219
- var rehype_highlight_lib = __webpack_require__(63437);
5220
- // EXTERNAL MODULE: ./node_modules/hast-util-sanitize/lib/schema.js
5221
- var schema = __webpack_require__(94764);
5222
- // EXTERNAL MODULE: ./node_modules/rehype-sanitize/lib/index.js + 1 modules
5223
- var rehype_sanitize_lib = __webpack_require__(63835);
5224
- // EXTERNAL MODULE: ./node_modules/highlight.js/styles/github-dark.css
5225
- var github_dark = __webpack_require__(2620);
5226
5212
  // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/link.mjs
5227
5213
  var icons_link = __webpack_require__(91161);
5228
- // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/external-link.mjs
5229
- var external_link = __webpack_require__(1275);
5230
5214
  // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/user.mjs
5231
5215
  var user = __webpack_require__(93744);
5232
5216
  // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/users.mjs
5233
5217
  var users = __webpack_require__(57465);
5218
+ // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/external-link.mjs
5219
+ var external_link = __webpack_require__(1275);
5234
5220
  // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/shield-check.mjs
5235
5221
  var shield_check = __webpack_require__(50981);
5236
- // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/copy.mjs
5237
- var copy = __webpack_require__(99314);
5238
5222
  // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/link-2.mjs
5239
5223
  var link_2 = __webpack_require__(51128);
5224
+ // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/copy.mjs
5225
+ var copy = __webpack_require__(99314);
5240
5226
  // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/pause.mjs
5241
5227
  var pause = __webpack_require__(79267);
5242
5228
  // EXTERNAL MODULE: ./node_modules/lucide-react/dist/esm/icons/play.mjs
@@ -5546,8 +5532,6 @@ function MetaChipRow({ thinking, cacheRead, cacheCreation }) {
5546
5532
  });
5547
5533
  }
5548
5534
 
5549
- // EXTERNAL MODULE: ./components/ui/Dialog.tsx + 1 modules
5550
- var Dialog = __webpack_require__(64723);
5551
5535
  ;// ./lib/ui/routing-decision.ts
5552
5536
  function formatRoutingDecisionSummary(decision) {
5553
5537
  const source = decision.source === "heuristic" ? "auto-routed" : decision.source === "agent_override" ? "agent-selected" : decision.source === "pinned" ? "pinned" : "default fallback";
@@ -5851,19 +5835,24 @@ function safeTranscriptFailureReason(code) {
5851
5835
  }
5852
5836
  }
5853
5837
 
5854
- ;// ./components/chat/MessageBubble.tsx
5855
- /* __next_internal_client_entry_do_not_use__ MessageBubble auto */
5856
-
5857
-
5858
-
5859
-
5860
-
5861
-
5862
-
5863
-
5864
-
5865
-
5866
-
5838
+ // EXTERNAL MODULE: ./node_modules/highlight.js/styles/github-dark.css
5839
+ var github_dark = __webpack_require__(2620);
5840
+ // EXTERNAL MODULE: ./node_modules/react-markdown/lib/index.js + 90 modules
5841
+ var lib = __webpack_require__(66804);
5842
+ // EXTERNAL MODULE: ./node_modules/remark-gfm/lib/index.js + 56 modules
5843
+ var remark_gfm_lib = __webpack_require__(32957);
5844
+ // EXTERNAL MODULE: ./node_modules/rehype-raw/lib/index.js + 30 modules
5845
+ var rehype_raw_lib = __webpack_require__(17848);
5846
+ // EXTERNAL MODULE: ./node_modules/rehype-highlight/lib/index.js + 43 modules
5847
+ var rehype_highlight_lib = __webpack_require__(63437);
5848
+ // EXTERNAL MODULE: ./node_modules/hast-util-sanitize/lib/schema.js
5849
+ var schema = __webpack_require__(94764);
5850
+ // EXTERNAL MODULE: ./node_modules/rehype-sanitize/lib/index.js + 1 modules
5851
+ var rehype_sanitize_lib = __webpack_require__(63835);
5852
+ // EXTERNAL MODULE: ./components/ui/Dialog.tsx + 1 modules
5853
+ var Dialog = __webpack_require__(64723);
5854
+ ;// ./components/chat/MessageContent.tsx
5855
+ /* __next_internal_client_entry_do_not_use__ MarkdownContent,ContentPartView auto */
5867
5856
 
5868
5857
 
5869
5858
 
@@ -5875,61 +5864,6 @@ function safeTranscriptFailureReason(code) {
5875
5864
 
5876
5865
 
5877
5866
 
5878
- // Best-effort plain-text projection of a (possibly structured) message body
5879
- // for the TTS endpoint. Strips markdown noise, code fences, refs blocks,
5880
- // and structured content parts so the spoken output doesn't read aloud
5881
- // asterisks, backticks, or URLs. The string is also cropped to keep TTS
5882
- // requests cheap — voices read about 150wpm so 5000 chars is several minutes.
5883
- function plainTextForTts(content) {
5884
- let text = "";
5885
- if (typeof content === "string") text = content;
5886
- else if (Array.isArray(content)) {
5887
- for (const part of content){
5888
- if (part && typeof part === "object" && "type" in part) {
5889
- const p = part;
5890
- if (p.type === "text" && typeof p.text === "string") text += `${p.text}\n`;
5891
- }
5892
- }
5893
- }
5894
- text = text.replace(/<refs>[\s\S]*?<\/refs>/gi, " ").replace(/```[\s\S]*?```/g, " [code] ").replace(/`([^`]+)`/g, "$1").replace(/!\[[^\]]*\]\([^)]*\)/g, " ").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/[#>*_~]+/g, " ").replace(/\s+/g, " ").trim();
5895
- return text.length > 5000 ? text.slice(0, 5000) : text;
5896
- }
5897
- // Splits "<refs>…</refs>" off the end of a message, returning the parsed refs
5898
- // and the body without the block. Defensive against partial blocks emitted
5899
- // mid-stream and against the agent forgetting the closing tag.
5900
- function extractRefs(text) {
5901
- const match = /<refs>([\s\S]*?)<\/refs>/i.exec(text);
5902
- if (!match) return {
5903
- body: text,
5904
- refs: []
5905
- };
5906
- const inner = match[1];
5907
- const refs = [];
5908
- const linkRe = /\[([^\]]+)\]\(([^)]+)\)/g;
5909
- let m;
5910
- while((m = linkRe.exec(inner)) !== null){
5911
- const url = m[2].trim();
5912
- if (/^https?:\/\//.test(url)) refs.push({
5913
- title: m[1].trim(),
5914
- url
5915
- });
5916
- }
5917
- // Also catch bare-URL lines for resilience.
5918
- if (refs.length === 0) {
5919
- for (const line of inner.split("\n")){
5920
- const u = line.trim().match(/^https?:\/\/\S+/);
5921
- if (u) refs.push({
5922
- title: u[0].replace(/^https?:\/\/(www\.)?/, "").slice(0, 60),
5923
- url: u[0]
5924
- });
5925
- }
5926
- }
5927
- const body = (text.slice(0, match.index) + text.slice(match.index + match[0].length)).trimEnd();
5928
- return {
5929
- body,
5930
- refs
5931
- };
5932
- }
5933
5867
  // Tracks which TTS clips have started auto-playing this session so a clip
5934
5868
  // only autoplays once. Re-renders of the same <audio> (message refetched,
5935
5869
  // scroll into view, list re-render) won't trigger a replay. Keyed by the
@@ -5952,229 +5886,1188 @@ function InlineAudio({ href }) {
5952
5886
  }
5953
5887
  });
5954
5888
  }
5955
- function parseCapturedContext(raw) {
5956
- if (!raw.startsWith("📎 Captured from ")) return null;
5957
- const linkRe = /^📎 Captured from \[([^\]]+)\]\((https?:\/\/[^)]+)\)\s*\n?/;
5958
- const bareRe = /^📎 Captured from <(https?:\/\/[^>]+)>\s*\n?/;
5959
- let title = "";
5960
- let url = "";
5961
- let rest = raw;
5962
- const lm = linkRe.exec(raw);
5963
- if (lm) {
5964
- title = lm[1];
5965
- url = lm[2];
5966
- rest = raw.slice(lm[0].length);
5967
- } else {
5968
- const bm = bareRe.exec(raw);
5969
- if (!bm) return null;
5970
- url = bm[1];
5971
- title = url;
5972
- rest = raw.slice(bm[0].length);
5973
- }
5974
- const out = {
5975
- title,
5976
- url,
5977
- selector: null,
5978
- truncated: false,
5979
- originalBytes: null,
5980
- body: ""
5981
- };
5982
- const sm = /^Element: `([^`]+)`\s*\n?/.exec(rest);
5983
- if (sm) {
5984
- out.selector = sm[1];
5985
- rest = rest.slice(sm[0].length);
5986
- }
5987
- const tm = /^>\s*⚠[^\n]*?\(original was ([\d,]+) bytes\)[^\n]*\n?/.exec(rest);
5988
- if (tm) {
5989
- out.truncated = true;
5990
- out.originalBytes = Number(tm[1].replace(/,/g, ""));
5991
- rest = rest.slice(tm[0].length);
5889
+ // Sanitizer schema = GitHub default + extras the agent is told it can use.
5890
+ // Anything not listed here gets stripped (scripts, event handlers, javascript: URLs).
5891
+ const sanitizeSchema = {
5892
+ ...schema/* defaultSchema */.j,
5893
+ tagNames: [
5894
+ ...schema/* defaultSchema */.j.tagNames ?? [],
5895
+ "details",
5896
+ "summary",
5897
+ "mark",
5898
+ "kbd",
5899
+ "sub",
5900
+ "sup",
5901
+ "abbr",
5902
+ "small",
5903
+ "aside",
5904
+ "figure",
5905
+ "figcaption",
5906
+ "dl",
5907
+ "dt",
5908
+ "dd",
5909
+ "audio",
5910
+ "source"
5911
+ ],
5912
+ attributes: {
5913
+ ...schema/* defaultSchema */.j.attributes ?? {},
5914
+ "*": [
5915
+ ...(schema/* defaultSchema */.j.attributes ?? {})["*"] ?? [],
5916
+ "className",
5917
+ "title"
5918
+ ],
5919
+ aside: [
5920
+ "className"
5921
+ ],
5922
+ abbr: [
5923
+ "title"
5924
+ ],
5925
+ details: [
5926
+ "open"
5927
+ ],
5928
+ audio: [
5929
+ "src",
5930
+ "controls",
5931
+ "preload",
5932
+ "loop",
5933
+ "autoplay",
5934
+ "muted"
5935
+ ],
5936
+ source: [
5937
+ "src",
5938
+ "type"
5939
+ ]
5992
5940
  }
5993
- rest = rest.replace(/^\s*\n/, "").replace(/^---\s*\n?/, "").replace(/^\n+/, "");
5994
- out.body = rest;
5995
- return out;
5996
- }
5997
- // Header-always-visible card for page captures. Body collapsed by default;
5998
- // the user can expand to read the captured page text inline. The agent
5999
- // already has the full text in the thread regardless of expand state — this
6000
- // is purely a UI affordance to keep ~100KB blobs from blowing the chat layout.
6001
- function CapturedContextCard({ ctx, accent }) {
6002
- const hostname = (()=>{
5941
+ };
5942
+ // Module-scope plugin arrays — passing fresh array literals to ReactMarkdown
5943
+ // on every render of MarkdownContent forced react-markdown's internal
5944
+ // useMemo() inputs to differ each time, defeating its plugin-pipeline
5945
+ // memoization. Hoisting these makes the references stable across renders.
5946
+ const MD_REMARK_PLUGINS = [
5947
+ remark_gfm_lib/* default */.A
5948
+ ];
5949
+ // rehype-highlight runs after rehype-raw (so any raw HTML <code> blocks are
5950
+ // also highlighted) and before rehype-sanitize (so the spans/classes it adds
5951
+ // pass through the sanitizer's allow-list rather than being stripped).
5952
+ const MD_REHYPE_PLUGINS = [
5953
+ rehype_raw_lib/* default */.A,
5954
+ [
5955
+ rehype_highlight_lib/* default */.A,
5956
+ {
5957
+ detect: true,
5958
+ ignoreMissing: true
5959
+ }
5960
+ ],
5961
+ [
5962
+ rehype_sanitize_lib/* default */.A,
5963
+ sanitizeSchema
5964
+ ]
5965
+ ];
5966
+ function isLikelyLocalFileHref(href) {
5967
+ if (!href || href.startsWith("#")) return false;
5968
+ if (/^(mailto|tel|javascript|data|blob):/i.test(href)) return false;
5969
+ if (/^file:\/\//i.test(href)) return true;
5970
+ if (/^[A-Za-z]:[\\/]/.test(href) || href.startsWith("~/") || href.startsWith("~\\")) return true;
5971
+ if (/^https?:\/\//i.test(href)) {
6003
5972
  try {
6004
- return new URL(ctx.url).hostname;
5973
+ const url = new URL(href);
5974
+ if (![
5975
+ "localhost",
5976
+ "127.0.0.1",
5977
+ "[::1]",
5978
+ "::1"
5979
+ ].includes(url.hostname)) return false;
5980
+ return !/^\/(api|_next)(\/|$)/.test(url.pathname);
6005
5981
  } catch {
6006
- return ctx.url;
6007
- }
6008
- })();
6009
- const chips = /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
6010
- children: [
6011
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
6012
- href: ctx.url,
6013
- target: "_blank",
6014
- rel: "noopener noreferrer",
6015
- onClick: (e)=>e.stopPropagation(),
6016
- className: "inline-flex items-center gap-1 underline decoration-dotted hover:decoration-solid truncate max-w-[18rem]",
6017
- title: ctx.url,
6018
- children: [
6019
- /*#__PURE__*/ (0,jsx_runtime.jsx)(icons_link/* default */.A, {
6020
- size: 9,
6021
- className: "shrink-0"
6022
- }),
6023
- /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6024
- className: "truncate",
6025
- children: hostname
6026
- })
6027
- ]
6028
- }),
6029
- ctx.selector && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6030
- className: `px-1.5 py-0.5 rounded font-mono ${accent ? "bg-white/15" : "bg-surface-3"}`,
6031
- title: ctx.selector,
6032
- children: ctx.selector.length > 36 ? `…${ctx.selector.slice(-33)}` : ctx.selector
6033
- }),
6034
- ctx.truncated && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6035
- className: `px-1.5 py-0.5 rounded ${accent ? "bg-amber-300/25 text-amber-50" : "bg-amber-900/30 text-amber-300"}`,
6036
- title: ctx.originalBytes ? `Original was ${ctx.originalBytes.toLocaleString()} bytes` : undefined,
6037
- children: "truncated to 100KB"
6038
- })
6039
- ]
6040
- });
6041
- const sections = ctx.body ? [
6042
- {
6043
- label: "Captured content",
6044
- defaultOpen: false,
6045
- content: /*#__PURE__*/ (0,jsx_runtime.jsx)("p", {
6046
- className: "whitespace-pre-wrap text-[12.5px] leading-relaxed opacity-90",
6047
- children: ctx.body
6048
- })
5982
+ return false;
6049
5983
  }
6050
- ] : [];
6051
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(StructuredTurnCard, {
6052
- categoryKey: "page_capture",
6053
- Icon: paperclip/* default */.A,
6054
- title: ctx.title || hostname,
6055
- titleTooltip: ctx.url,
6056
- chips: chips,
6057
- sections: sections,
6058
- accent: accent
6059
- });
5984
+ }
5985
+ if (href.startsWith("/")) return false;
5986
+ if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return false;
5987
+ return /(^\.\.?[\\/]|[\\/]|\.[A-Za-z0-9]{1,12}(?:[?#]|$))/.test(href);
6060
5988
  }
6061
- // Browser-extension turn card. The prompt format and parser live in
6062
- // `lib/api/extension-turn-prompt` so the compose/parse pair stays in sync
6063
- // between the server handler and this view.
6064
- function ExtensionTurnCard({ ctx, accent }) {
6065
- const hostname = ctx.url ? (()=>{
5989
+ function LocalFileLink({ href, threadId, children, className, title }) {
5990
+ const [preview, setPreview] = (0,react.useState)(null);
5991
+ const [loading, setLoading] = (0,react.useState)(false);
5992
+ const [openError, setOpenError] = (0,react.useState)(null);
5993
+ const openDefault = (0,react.useCallback)(async ()=>{
5994
+ setOpenError(null);
5995
+ const res = await fetch("/api/v1/local-file", {
5996
+ method: "POST",
5997
+ headers: {
5998
+ "Content-Type": "application/json"
5999
+ },
6000
+ body: JSON.stringify({
6001
+ href,
6002
+ thread_id: threadId ?? undefined
6003
+ })
6004
+ });
6005
+ const body = await res.json().catch(()=>({}));
6006
+ if (!res.ok) throw new Error(body.error ?? `HTTP ${res.status}`);
6007
+ (0,ui_toasts/* pushToast */.Iz)({
6008
+ kind: "success",
6009
+ source: "system",
6010
+ sourceLabel: "Chat",
6011
+ title: "Opening file",
6012
+ body: "Sent the file to the operating system default app.",
6013
+ agent_id: null,
6014
+ thread_id: threadId ?? null,
6015
+ ttl: 1800
6016
+ });
6017
+ }, [
6018
+ href,
6019
+ threadId
6020
+ ]);
6021
+ const activate = (0,react.useCallback)(async ()=>{
6022
+ setLoading(true);
6023
+ setOpenError(null);
6066
6024
  try {
6067
- return new URL(ctx.url).hostname;
6068
- } catch {
6069
- return ctx.url;
6025
+ const params = new URLSearchParams({
6026
+ href
6027
+ });
6028
+ if (threadId) params.set("thread_id", threadId);
6029
+ const res = await fetch(`/api/v1/local-file?${params.toString()}`);
6030
+ const body = await res.json().catch(()=>({}));
6031
+ if (!res.ok) throw new Error(body.error ?? `HTTP ${res.status}`);
6032
+ const info = body;
6033
+ setPreview(info);
6034
+ if (!info.renderable) await openDefault();
6035
+ } catch (err) {
6036
+ const msg = (0,utils_error/* errorMessage */.g)(err);
6037
+ setOpenError(msg);
6038
+ (0,ui_toasts/* pushToast */.Iz)({
6039
+ kind: "error",
6040
+ source: "system",
6041
+ sourceLabel: "Chat",
6042
+ title: "Could not open file",
6043
+ body: msg,
6044
+ agent_id: null,
6045
+ thread_id: threadId ?? null,
6046
+ ttl: 5000
6047
+ });
6048
+ } finally{
6049
+ setLoading(false);
6070
6050
  }
6071
- })() : null;
6072
- const chips = ctx.url || ctx.selector || ctx.selectedText ? /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
6051
+ }, [
6052
+ href,
6053
+ openDefault,
6054
+ threadId
6055
+ ]);
6056
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
6057
+ className: "inline-flex flex-col max-w-full align-baseline",
6073
6058
  children: [
6074
- ctx.url && hostname && /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
6075
- href: ctx.url,
6076
- target: "_blank",
6077
- rel: "noopener noreferrer",
6078
- onClick: (e)=>e.stopPropagation(),
6079
- className: "inline-flex items-center gap-1 underline decoration-dotted hover:decoration-solid truncate max-w-[18rem]",
6080
- title: ctx.url,
6059
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("button", {
6060
+ type: "button",
6061
+ className: `${className ?? ""} inline-flex items-baseline gap-1 text-left underline decoration-dotted hover:decoration-solid break-all`.trim(),
6062
+ title: title ?? href,
6063
+ onClick: activate,
6064
+ disabled: loading,
6081
6065
  children: [
6082
- /*#__PURE__*/ (0,jsx_runtime.jsx)(icons_link/* default */.A, {
6083
- size: 9,
6084
- className: "shrink-0"
6066
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(file_text/* default */.A, {
6067
+ size: 12,
6068
+ className: "relative top-0.5 shrink-0"
6085
6069
  }),
6086
6070
  /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6087
- className: "truncate",
6088
- children: ctx.title || hostname
6071
+ children: children
6072
+ }),
6073
+ loading && /*#__PURE__*/ (0,jsx_runtime.jsx)(loader_circle/* default */.A, {
6074
+ size: 11,
6075
+ className: "relative top-0.5 shrink-0 animate-spin"
6089
6076
  })
6090
6077
  ]
6091
6078
  }),
6092
- ctx.selector && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6093
- className: `px-1.5 py-0.5 rounded font-mono ${accent ? "bg-white/15" : "bg-surface-3"}`,
6094
- title: ctx.selector,
6095
- children: ctx.selector.length > 36 ? `…${ctx.selector.slice(-33)}` : ctx.selector
6096
- }),
6097
- ctx.selectedText && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6098
- className: `px-1.5 py-0.5 rounded ${accent ? "bg-white/15" : "bg-surface-3"}`,
6099
- children: `${ctx.selectedText.length.toLocaleString()} chars selected`
6100
- })
6101
- ]
6102
- }) : null;
6103
- const sections = [];
6104
- if (ctx.instruction) {
6105
- sections.push({
6106
- label: "Instruction",
6107
- defaultOpen: false,
6108
- content: /*#__PURE__*/ (0,jsx_runtime.jsx)(MarkdownContent, {
6109
- text: ctx.instruction
6110
- })
6111
- });
6112
- }
6113
- if (ctx.selectedText || ctx.pageContext) {
6114
- sections.push({
6115
- label: "Context",
6116
- defaultOpen: false,
6117
- content: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6118
- className: "flex flex-col gap-2",
6079
+ preview?.renderable && typeof preview.snippet === "string" && /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
6080
+ className: "not-prose my-2 block rounded-md border border-border/60 bg-surface-2 overflow-hidden",
6119
6081
  children: [
6120
- ctx.selectedText && /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6082
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
6083
+ className: "flex items-center justify-between gap-2 px-2 py-1 text-[10px] text-fg-faint bg-surface-3",
6121
6084
  children: [
6122
- /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6123
- className: `text-[9.5px] uppercase tracking-wide mb-0.5 ${accent ? "text-white/55" : "text-fg-faint"}`,
6124
- children: "Selected"
6085
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6086
+ className: "truncate",
6087
+ title: preview.path,
6088
+ children: preview.path
6125
6089
  }),
6126
- /*#__PURE__*/ (0,jsx_runtime.jsx)("p", {
6127
- className: "whitespace-pre-wrap text-[12.5px] leading-relaxed opacity-90",
6128
- children: ctx.selectedText
6090
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("button", {
6091
+ type: "button",
6092
+ onClick: openDefault,
6093
+ className: "inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border/60 bg-surface-2 text-fg-muted hover:text-fg shrink-0",
6094
+ children: [
6095
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(external_link/* default */.A, {
6096
+ size: 10
6097
+ }),
6098
+ "Open"
6099
+ ]
6129
6100
  })
6130
6101
  ]
6131
6102
  }),
6132
- ctx.pageContext && /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6103
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("code", {
6104
+ className: "block max-h-72 overflow-auto whitespace-pre-wrap break-words px-3 py-2 text-xs leading-relaxed text-fg-muted bg-[#0d1117]",
6133
6105
  children: [
6134
- /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6135
- className: `text-[9.5px] uppercase tracking-wide mb-0.5 ${accent ? "text-white/55" : "text-fg-faint"}`,
6136
- children: "Page"
6137
- }),
6138
- /*#__PURE__*/ (0,jsx_runtime.jsx)("p", {
6139
- className: "whitespace-pre-wrap text-[12px] leading-relaxed opacity-80",
6140
- children: ctx.pageContext
6141
- })
6106
+ preview.snippet,
6107
+ preview.truncated ? "\n..." : ""
6142
6108
  ]
6143
6109
  })
6144
6110
  ]
6111
+ }),
6112
+ openError && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6113
+ className: "text-[11px] text-rose-400 mt-1",
6114
+ children: openError
6145
6115
  })
6146
- });
6147
- }
6148
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(StructuredTurnCard, {
6149
- categoryKey: "extension",
6150
- Icon: zap/* default */.A,
6151
- title: ctx.actionLabel,
6152
- chips: chips,
6153
- sections: sections,
6154
- accent: accent
6116
+ ]
6155
6117
  });
6156
6118
  }
6157
- const AUTOMATION_ACTIVITY_SOURCE = {
6158
- scheduled_task: {
6159
- label: "Scheduled task",
6160
- Icon: clock/* default */.A
6161
- },
6162
- watcher: {
6163
- label: "Watcher",
6164
- Icon: eye/* default */.A
6165
- },
6166
- bridge: {
6167
- label: "Bridge",
6168
- Icon: message_circle/* default */.A
6119
+ function reactChildrenToText(children) {
6120
+ if (children == null || typeof children === "boolean") return "";
6121
+ if (typeof children === "string" || typeof children === "number") return String(children);
6122
+ if (Array.isArray(children)) return children.map(reactChildrenToText).join("");
6123
+ if (typeof children === "object" && "props" in children) {
6124
+ return reactChildrenToText(children.props.children);
6169
6125
  }
6170
- };
6171
- const AUTOMATION_ACTIVITY_STATUS = {
6172
- queued: {
6173
- copy: "Queued",
6174
- cls: "border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300"
6175
- },
6176
- checking: {
6177
- copy: "Checking…",
6126
+ return "";
6127
+ }
6128
+ // Markdown image renderer with a one-time automatic retry. If both attempts
6129
+ // fail (common on transient local-network/SW races), show a compact fallback
6130
+ // with explicit actions instead of a broken image icon.
6131
+ function ResilientMarkdownImage({ src, alt }) {
6132
+ const [retryNonce, setRetryNonce] = (0,react.useState)(0);
6133
+ const [failed, setFailed] = (0,react.useState)(false);
6134
+ const [open, setOpen] = (0,react.useState)(false);
6135
+ const objectUrl = (0,react.useMemo)(()=>src instanceof Blob ? URL.createObjectURL(src) : null, [
6136
+ src
6137
+ ]);
6138
+ (0,react.useEffect)(()=>{
6139
+ return ()=>{
6140
+ if (objectUrl) URL.revokeObjectURL(objectUrl);
6141
+ };
6142
+ }, [
6143
+ objectUrl
6144
+ ]);
6145
+ const normalizedSrc = typeof src === "string" ? src : objectUrl ?? "";
6146
+ const effectiveSrc = normalizedSrc ? `${normalizedSrc}${normalizedSrc.includes("?") ? "&" : "?"}retry=${retryNonce}` : "";
6147
+ if (!normalizedSrc) {
6148
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6149
+ className: "my-2 px-3 py-2 rounded border border-rose-800/60 bg-rose-950/30 text-xs text-rose-700 dark:text-rose-300",
6150
+ children: "Invalid image URL in markdown."
6151
+ });
6152
+ }
6153
+ if (failed) {
6154
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6155
+ className: "my-2 px-3 py-2 rounded border border-amber-700/50 bg-amber-900/20 text-xs text-amber-300",
6156
+ children: [
6157
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6158
+ children: "Image failed to load."
6159
+ }),
6160
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6161
+ className: "mt-1 flex items-center gap-2",
6162
+ children: [
6163
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
6164
+ type: "button",
6165
+ className: "px-2 py-1 rounded border border-amber-500/60 hover:bg-amber-900/30",
6166
+ onClick: ()=>{
6167
+ setFailed(false);
6168
+ setRetryNonce((n)=>n + 1);
6169
+ },
6170
+ children: "Retry"
6171
+ }),
6172
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("a", {
6173
+ href: normalizedSrc,
6174
+ target: "_blank",
6175
+ rel: "noopener noreferrer",
6176
+ className: "underline decoration-dotted hover:decoration-solid break-all",
6177
+ children: "Open image"
6178
+ })
6179
+ ]
6180
+ })
6181
+ ]
6182
+ });
6183
+ }
6184
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
6185
+ children: [
6186
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("img", {
6187
+ src: effectiveSrc,
6188
+ alt: alt ?? "image",
6189
+ loading: "lazy",
6190
+ className: "rounded-lg border border-border/50 cursor-zoom-in hover:border-fg-faint transition-colors",
6191
+ onClick: ()=>setOpen(true),
6192
+ onError: ()=>{
6193
+ if (retryNonce === 0) {
6194
+ setRetryNonce(1);
6195
+ return;
6196
+ }
6197
+ setFailed(true);
6198
+ }
6199
+ }),
6200
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(ImagePreviewDialog, {
6201
+ src: normalizedSrc,
6202
+ alt: alt ?? "image",
6203
+ open: open,
6204
+ onClose: ()=>setOpen(false)
6205
+ })
6206
+ ]
6207
+ });
6208
+ }
6209
+ // Renders a Google Maps Embed inside an iframe whose src points at our
6210
+ // server-side proxy (/api/v1/maps/embed). The proxy injects the API key so
6211
+ // it never appears in chat HTML. Triggered by ```map fenced blocks emitted
6212
+ // by the agent — see PRESENTATION_CTX in lib/agents/run-thread.ts.
6213
+ function MapEmbed({ payload }) {
6214
+ const [retryNonce, setRetryNonce] = (0,react.useState)(0);
6215
+ const [failed, setFailed] = (0,react.useState)(false);
6216
+ let params = null;
6217
+ let parseError = null;
6218
+ try {
6219
+ const obj = JSON.parse(payload);
6220
+ const sp = new URLSearchParams();
6221
+ for (const k of [
6222
+ "q",
6223
+ "center",
6224
+ "zoom",
6225
+ "origin",
6226
+ "destination",
6227
+ "search",
6228
+ "mode"
6229
+ ]){
6230
+ const v = obj[k];
6231
+ if (typeof v === "string" && v.length > 0) sp.set(k, v);
6232
+ else if (typeof v === "number") sp.set(k, String(v));
6233
+ }
6234
+ if ([
6235
+ ...sp.keys()
6236
+ ].length === 0) parseError = "no recognized fields (q / center / origin+destination / search)";
6237
+ else params = sp;
6238
+ } catch (e) {
6239
+ parseError = (0,utils_error/* errorMessage */.g)(e);
6240
+ }
6241
+ if (!params) {
6242
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6243
+ className: "my-2 px-3 py-2 rounded border border-rose-800/60 bg-rose-950/30 text-xs text-rose-700 dark:text-rose-300",
6244
+ children: [
6245
+ "Invalid map block: ",
6246
+ parseError
6247
+ ]
6248
+ });
6249
+ }
6250
+ const src = `/api/v1/maps/embed?${params.toString()}${retryNonce > 0 ? `&retry=${retryNonce}` : ""}`;
6251
+ if (failed) {
6252
+ const q = params.get("q") ?? params.get("search") ?? params.get("center") ?? "";
6253
+ const direct = q ? `https://www.google.com/maps?q=${encodeURIComponent(q)}` : "https://www.google.com/maps";
6254
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6255
+ className: "my-2 px-3 py-2 rounded border border-amber-700/50 bg-amber-900/20 text-xs text-amber-300",
6256
+ children: [
6257
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6258
+ children: "Map failed to load."
6259
+ }),
6260
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6261
+ className: "mt-1 flex items-center gap-2",
6262
+ children: [
6263
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
6264
+ type: "button",
6265
+ className: "px-2 py-1 rounded border border-amber-500/60 hover:bg-amber-900/30",
6266
+ onClick: ()=>{
6267
+ setFailed(false);
6268
+ setRetryNonce((n)=>n + 1);
6269
+ },
6270
+ children: "Retry"
6271
+ }),
6272
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("a", {
6273
+ href: direct,
6274
+ target: "_blank",
6275
+ rel: "noopener noreferrer",
6276
+ className: "underline decoration-dotted hover:decoration-solid",
6277
+ children: "Open in Google Maps"
6278
+ })
6279
+ ]
6280
+ })
6281
+ ]
6282
+ });
6283
+ }
6284
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6285
+ className: "my-2 rounded overflow-hidden border border-border bg-surface-2",
6286
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)("iframe", {
6287
+ src: src,
6288
+ title: "Map",
6289
+ width: "100%",
6290
+ height: "320",
6291
+ loading: "lazy",
6292
+ referrerPolicy: "no-referrer-when-downgrade",
6293
+ allowFullScreen: true,
6294
+ style: {
6295
+ border: 0,
6296
+ display: "block"
6297
+ },
6298
+ onError: ()=>{
6299
+ if (retryNonce === 0) {
6300
+ setRetryNonce(1);
6301
+ return;
6302
+ }
6303
+ setFailed(true);
6304
+ }
6305
+ })
6306
+ });
6307
+ }
6308
+ // Memoized: this component appears under every assistant bubble and during
6309
+ // streaming gets re-rendered on every rAF flush. The inner ReactMarkdown
6310
+ // pipeline (remark + rehype passes, syntax highlighting via rehypeHighlight,
6311
+ // custom <a> / <code> renderers) is the expensive part — re-running it
6312
+ // against unchanged text on every parent render shows up as jank on long
6313
+ // threads. With memo, only the in-flight bubble re-renders during streaming;
6314
+ // persisted siblings sit idle.
6315
+ const MarkdownContent = /*#__PURE__*/ (0,react.memo)(function MarkdownContent({ text, streaming, onInAppLink, unverifiedLinks, sourceManifest, threadId }) {
6316
+ // Inline-citation pre-processor. The agent writes `[3]` markers in-prose;
6317
+ // we resolve each to a markdown link `[3](href)` BEFORE react-markdown
6318
+ // parses the string so the existing <a> renderer below picks it up with
6319
+ // no special-casing. Markers whose number isn't in the manifest are
6320
+ // left untouched (they'll show as plain `[3]` text) so an invented
6321
+ // number is visibly un-linked rather than silently mis-routed.
6322
+ const renderedText = (0,react.useMemo)(()=>{
6323
+ if (!sourceManifest || sourceManifest.size === 0) return text;
6324
+ return text.replace(/(?<!\])\[(\d+)\]/g, (match, raw)=>{
6325
+ const entry = sourceManifest.get(parseInt(raw, 10));
6326
+ return entry ? `[${raw}](${entry.href})` : match;
6327
+ });
6328
+ }, [
6329
+ text,
6330
+ sourceManifest
6331
+ ]);
6332
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6333
+ className: "prose prose-invert prose-sm max-w-none jarela-rich min-w-0",
6334
+ children: [
6335
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(lib/* Markdown */.oz, {
6336
+ remarkPlugins: MD_REMARK_PLUGINS,
6337
+ rehypePlugins: MD_REHYPE_PLUGINS,
6338
+ components: {
6339
+ a ({ href, children, ...rest }) {
6340
+ const parsed = href ? parseHref(href) : undefined;
6341
+ const isUnverified = !!(href && unverifiedLinks?.has(href));
6342
+ // Detect citation markers: link text is literally `[N]` where N
6343
+ // is a positive integer. These are rendered as small superscript
6344
+ // chips (Wikipedia-style) so they're scannable as citations and
6345
+ // distinct from ordinary inline links.
6346
+ const isCitationMarker = Array.isArray(children) && children.length === 1 ? typeof children[0] === "string" && /^\[\d+\]$/.test(children[0]) : typeof children === "string" && /^\[\d+\]$/.test(children);
6347
+ const citationText = isCitationMarker ? Array.isArray(children) ? children[0] : children : null;
6348
+ // Inline audio: any link to a local /api/v1/files/*.{wav,mp3,ogg,webm,m4a}
6349
+ // becomes a native <audio controls> player. The original anchor
6350
+ // text is dropped — the player IS the answer. An `?autoplay=1`
6351
+ // query string lets the agent (via generate_voice) ask the
6352
+ // browser to start playback immediately.
6353
+ if (href && /^\/api\/v1\/files\/[^?#]+\.(wav|mp3|ogg|webm|m4a)(\?|#|$)/i.test(href)) {
6354
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(InlineAudio, {
6355
+ href: href
6356
+ });
6357
+ }
6358
+ const unverifiedCls = isUnverified ? "decoration-warn decoration-wavy underline-offset-2" : "";
6359
+ const unverifiedTitle = isUnverified ? "Agent did not visit this source in this conversation — the citation may be invented." : undefined;
6360
+ if (href && isLikelyLocalFileHref(href)) {
6361
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)(LocalFileLink, {
6362
+ href: href,
6363
+ threadId: threadId,
6364
+ title: unverifiedTitle ?? rest.title,
6365
+ className: `${rest.className ?? ""} ${unverifiedCls}`.trim(),
6366
+ children: [
6367
+ children,
6368
+ isUnverified && /*#__PURE__*/ (0,jsx_runtime.jsx)("sup", {
6369
+ className: "text-warn ml-0.5",
6370
+ "aria-label": "unverified citation",
6371
+ children: "⚠"
6372
+ })
6373
+ ]
6374
+ });
6375
+ }
6376
+ const inApp = !!parsed && !parsed.external && (!!parsed.tab || !!parsed.hash || !!parsed.thread && !!parsed.agent);
6377
+ // Citation-marker rendering: superscript chip with a tooltip
6378
+ // showing the source label so the user can preview what the
6379
+ // marker points to without clicking. The href is still active
6380
+ // (jumps to anchor for #msg-… or opens external for URLs).
6381
+ if (isCitationMarker && href) {
6382
+ const markerNum = parseInt(citationText.replace(/[\[\]]/g, ""), 10);
6383
+ const entry = Number.isFinite(markerNum) ? sourceManifest?.get(markerNum) : undefined;
6384
+ const title = entry?.label ?? unverifiedTitle ?? href;
6385
+ const isAnchor = href.startsWith("#");
6386
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)("a", {
6387
+ ...rest,
6388
+ href: href,
6389
+ target: isAnchor || inApp ? undefined : "_blank",
6390
+ rel: isAnchor || inApp ? undefined : "noopener noreferrer",
6391
+ title: title,
6392
+ onClick: inApp && onInAppLink ? (e)=>{
6393
+ e.preventDefault();
6394
+ onInAppLink(href);
6395
+ } : undefined,
6396
+ className: "jarela-citation",
6397
+ children: citationText
6398
+ });
6399
+ }
6400
+ if (inApp && href && onInAppLink) {
6401
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
6402
+ ...rest,
6403
+ href: href,
6404
+ title: unverifiedTitle ?? rest.title,
6405
+ className: `${rest.className ?? ""} ${unverifiedCls}`.trim(),
6406
+ onClick: (e)=>{
6407
+ e.preventDefault();
6408
+ onInAppLink(href);
6409
+ },
6410
+ children: [
6411
+ children,
6412
+ isUnverified && /*#__PURE__*/ (0,jsx_runtime.jsx)("sup", {
6413
+ className: "text-warn ml-0.5",
6414
+ "aria-label": "unverified citation",
6415
+ children: "⚠"
6416
+ })
6417
+ ]
6418
+ });
6419
+ }
6420
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
6421
+ ...rest,
6422
+ href: href,
6423
+ target: "_blank",
6424
+ rel: "noopener noreferrer",
6425
+ title: unverifiedTitle ?? rest.title,
6426
+ className: `${rest.className ?? ""} ${unverifiedCls}`.trim(),
6427
+ children: [
6428
+ children,
6429
+ isUnverified && /*#__PURE__*/ (0,jsx_runtime.jsx)("sup", {
6430
+ className: "text-warn ml-0.5",
6431
+ "aria-label": "unverified citation",
6432
+ children: "⚠"
6433
+ })
6434
+ ]
6435
+ });
6436
+ },
6437
+ pre ({ children }) {
6438
+ // CodeFence renders its own <pre>, so collapse react-markdown's
6439
+ // outer wrapper to avoid <pre><pre>...</pre></pre>.
6440
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
6441
+ children: children
6442
+ });
6443
+ },
6444
+ code ({ className, children }) {
6445
+ const match = /language-(\w+)/.exec(className ?? "");
6446
+ if (match?.[1] === "map") {
6447
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(MapEmbed, {
6448
+ payload: reactChildrenToText(children).replace(/\n$/, "")
6449
+ });
6450
+ }
6451
+ if (match?.[1] === "mermaid") {
6452
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(MermaidFence, {
6453
+ source: reactChildrenToText(children).replace(/\n$/, "")
6454
+ });
6455
+ }
6456
+ return match ? /*#__PURE__*/ (0,jsx_runtime.jsx)(CodeFence, {
6457
+ language: match[1],
6458
+ className: className ?? "",
6459
+ children: children
6460
+ }) : /*#__PURE__*/ (0,jsx_runtime.jsx)("code", {
6461
+ className: "bg-surface-2 px-1 rounded text-fg-muted break-all",
6462
+ children: children
6463
+ });
6464
+ },
6465
+ img ({ src, alt }) {
6466
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(ResilientMarkdownImage, {
6467
+ src: src,
6468
+ alt: alt
6469
+ });
6470
+ }
6471
+ },
6472
+ children: renderedText
6473
+ }),
6474
+ streaming && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6475
+ className: "jarela-stream-caret",
6476
+ "aria-hidden": "true"
6477
+ })
6478
+ ]
6479
+ });
6480
+ });
6481
+ function CodeFence({ language, className, children }) {
6482
+ const [copied, setCopied] = (0,react.useState)(false);
6483
+ const codeText = (0,react.useMemo)(()=>reactChildrenToText(children).replace(/\n$/, ""), [
6484
+ children
6485
+ ]);
6486
+ const copyCode = (0,react.useCallback)(()=>{
6487
+ void navigator.clipboard.writeText(codeText).then(()=>{
6488
+ setCopied(true);
6489
+ setTimeout(()=>setCopied(false), 1200);
6490
+ }).catch(console.error);
6491
+ }, [
6492
+ codeText
6493
+ ]);
6494
+ // rehype-highlight already populated `className` with `hljs language-X`
6495
+ // plus per-token spans inside `children`. The `hljs` class drives styling
6496
+ // from the imported github-dark theme.
6497
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6498
+ className: "relative my-2 rounded-md overflow-hidden border border-border/60",
6499
+ children: [
6500
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6501
+ className: "flex items-center justify-between px-2 py-1 text-[10px] bg-surface-3 text-fg-faint uppercase tracking-wide",
6502
+ children: [
6503
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6504
+ children: language
6505
+ }),
6506
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("button", {
6507
+ onClick: copyCode,
6508
+ className: "inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border/60 bg-surface-2 text-fg-muted hover:text-fg transition-colors",
6509
+ title: "Copy code",
6510
+ "aria-label": "Copy code",
6511
+ children: [
6512
+ copied ? /*#__PURE__*/ (0,jsx_runtime.jsx)(check/* default */.A, {
6513
+ size: 10
6514
+ }) : /*#__PURE__*/ (0,jsx_runtime.jsx)(copy/* default */.A, {
6515
+ size: 10
6516
+ }),
6517
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6518
+ children: copied ? "Copied" : "Copy"
6519
+ })
6520
+ ]
6521
+ })
6522
+ ]
6523
+ }),
6524
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("pre", {
6525
+ className: "m-0 p-3 text-xs leading-relaxed overflow-x-auto bg-[#0d1117]",
6526
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)("code", {
6527
+ className: className,
6528
+ children: children
6529
+ })
6530
+ })
6531
+ ]
6532
+ });
6533
+ }
6534
+ function MermaidFence({ source }) {
6535
+ const renderId = `mermaid-${(0,react.useId)().replace(/[^a-zA-Z0-9_-]/g, "")}`;
6536
+ const [svg, setSvg] = (0,react.useState)(null);
6537
+ const [error, setError] = (0,react.useState)(null);
6538
+ (0,react.useEffect)(()=>{
6539
+ let cancelled = false;
6540
+ setSvg(null);
6541
+ setError(null);
6542
+ void (async ()=>{
6543
+ try {
6544
+ const [{ default: mermaid }, { default: DOMPurify }] = await Promise.all([
6545
+ Promise.all(/* import() */[__webpack_require__.e(866), __webpack_require__.e(8367), __webpack_require__.e(1992), __webpack_require__.e(3308)]).then(__webpack_require__.bind(__webpack_require__, 43328)),
6546
+ __webpack_require__.e(/* import() */ 1992).then(__webpack_require__.bind(__webpack_require__, 91992))
6547
+ ]);
6548
+ mermaid.initialize({
6549
+ startOnLoad: false,
6550
+ securityLevel: "strict",
6551
+ theme: "base"
6552
+ });
6553
+ const result = await mermaid.render(renderId, source);
6554
+ if (cancelled) return;
6555
+ setSvg(DOMPurify.sanitize(result.svg, {
6556
+ USE_PROFILES: {
6557
+ svg: true
6558
+ }
6559
+ }));
6560
+ } catch (err) {
6561
+ if (!cancelled) setError(err instanceof Error ? err.message : String(err));
6562
+ }
6563
+ })();
6564
+ return ()=>{
6565
+ cancelled = true;
6566
+ };
6567
+ }, [
6568
+ renderId,
6569
+ source
6570
+ ]);
6571
+ if (error) {
6572
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6573
+ className: "my-2 rounded-md border border-warn/40 bg-warn/5 p-2",
6574
+ children: [
6575
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("p", {
6576
+ className: "mb-1 text-[10px] uppercase tracking-wide text-warn",
6577
+ children: "Mermaid preview unavailable"
6578
+ }),
6579
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(CodeFence, {
6580
+ language: "mermaid",
6581
+ className: "language-mermaid",
6582
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
6583
+ children: source
6584
+ })
6585
+ })
6586
+ ]
6587
+ });
6588
+ }
6589
+ if (!svg) {
6590
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6591
+ className: "my-2 rounded-md border border-border/60 bg-surface-3/40 p-3 text-xs text-fg-faint",
6592
+ children: "Rendering diagram..."
6593
+ });
6594
+ }
6595
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6596
+ className: "my-2 max-w-full overflow-x-auto rounded-md border border-border/60 bg-surface-2 p-3",
6597
+ dangerouslySetInnerHTML: {
6598
+ __html: svg
6599
+ },
6600
+ role: "img",
6601
+ "aria-label": "Mermaid diagram"
6602
+ });
6603
+ }
6604
+ function ContentPartView({ part, isUser, onInAppLink, unverifiedLinks, sourceManifest, threadId }) {
6605
+ if (part.type === "text") {
6606
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(MarkdownContent, {
6607
+ text: part.text,
6608
+ onInAppLink: onInAppLink,
6609
+ unverifiedLinks: unverifiedLinks,
6610
+ sourceManifest: sourceManifest,
6611
+ threadId: threadId
6612
+ });
6613
+ }
6614
+ if (part.type === "image") {
6615
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(ClickableImage, {
6616
+ src: `data:${part.media_type};base64,${part.data}`
6617
+ });
6618
+ }
6619
+ if (part.type === "image_ref") {
6620
+ // Ref-based image — server-hosted at /api/v1/files/[name]. See ADR-0065.
6621
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(ClickableImage, {
6622
+ src: `/api/v1/files/${encodeURIComponent(part.name)}`
6623
+ });
6624
+ }
6625
+ if (part.type === "file_ref") {
6626
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(AttachmentLink, {
6627
+ href: `/api/v1/files/${encodeURIComponent(part.name)}`,
6628
+ filename: part.filename
6629
+ });
6630
+ }
6631
+ // File attachment — render an inline player for audio/video so voice
6632
+ // notes and short clips from the WhatsApp bridge are usable in-bubble.
6633
+ // Other file types still fall through to a download/open-in-new-tab link.
6634
+ const file = part;
6635
+ const dataUrl = `data:${file.media_type};base64,${file.data}`;
6636
+ // For text files our data field is plain text, not base64. Detect and wrap.
6637
+ const href = /^text\/|^application\/json$/.test(file.media_type) ? `data:${file.media_type};charset=utf-8,${encodeURIComponent(file.data)}` : dataUrl;
6638
+ if (file.media_type.startsWith("audio/")) {
6639
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6640
+ className: "mt-1 max-w-md",
6641
+ children: [
6642
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("audio", {
6643
+ controls: true,
6644
+ className: "w-full",
6645
+ src: dataUrl
6646
+ }),
6647
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6648
+ className: "mt-0.5 text-[10px] text-fg-faint truncate",
6649
+ children: file.name
6650
+ })
6651
+ ]
6652
+ });
6653
+ }
6654
+ if (file.media_type.startsWith("video/")) {
6655
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6656
+ className: "mt-1 max-w-md",
6657
+ children: [
6658
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("video", {
6659
+ controls: true,
6660
+ playsInline: true,
6661
+ className: "w-full rounded-xl border border-border/40",
6662
+ style: {
6663
+ maxHeight: "400px"
6664
+ },
6665
+ src: dataUrl
6666
+ }),
6667
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6668
+ className: "mt-0.5 text-[10px] text-fg-faint truncate",
6669
+ children: file.name
6670
+ })
6671
+ ]
6672
+ });
6673
+ }
6674
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(AttachmentLink, {
6675
+ href: href,
6676
+ filename: file.name
6677
+ });
6678
+ }
6679
+ function AttachmentLink({ href, filename }) {
6680
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
6681
+ href: href,
6682
+ target: "_blank",
6683
+ rel: "noopener noreferrer",
6684
+ className: "inline-flex items-center gap-1.5 px-2.5 py-1.5 mt-1 rounded-lg border border-border/60 bg-surface-3/60 hover:bg-surface-3 hover:border-border text-[11px] text-fg-muted transition-colors",
6685
+ title: "Open in new tab",
6686
+ children: [
6687
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(paperclip/* default */.A, {
6688
+ size: 11,
6689
+ className: "text-fg-faint shrink-0"
6690
+ }),
6691
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6692
+ className: "truncate max-w-[200px]",
6693
+ children: filename
6694
+ })
6695
+ ]
6696
+ });
6697
+ }
6698
+ // Image attachment — thumbnail in the bubble, click for a full-screen lightbox.
6699
+ // Accepts either a `data:` URL (inline base64) or a `/api/v1/files/[name]`
6700
+ // URL (disk-hosted ref, see ADR-0065). Both render identically.
6701
+ function ClickableImage({ src }) {
6702
+ const [open, setOpen] = (0,react.useState)(false);
6703
+ const [naturalSize, setNaturalSize] = (0,react.useState)(null);
6704
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
6705
+ children: [
6706
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("img", {
6707
+ src: src,
6708
+ alt: "attached image",
6709
+ onLoad: (e)=>{
6710
+ const img = e.currentTarget;
6711
+ if (img.naturalWidth > 0 && img.naturalHeight > 0) {
6712
+ setNaturalSize({
6713
+ width: img.naturalWidth,
6714
+ height: img.naturalHeight
6715
+ });
6716
+ }
6717
+ },
6718
+ onClick: ()=>setOpen(true),
6719
+ className: "block w-full max-w-full rounded-xl mt-1 border border-border/40 cursor-zoom-in hover:border-fg-faint transition-colors",
6720
+ style: {
6721
+ width: naturalSize ? `min(100%, ${naturalSize.width}px)` : "100%",
6722
+ maxHeight: naturalSize ? `min(82dvh, ${naturalSize.height}px)` : "82dvh",
6723
+ objectFit: "contain"
6724
+ }
6725
+ }),
6726
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(ImagePreviewDialog, {
6727
+ src: src,
6728
+ alt: "attached image",
6729
+ open: open,
6730
+ onClose: ()=>setOpen(false)
6731
+ })
6732
+ ]
6733
+ });
6734
+ }
6735
+ function ImagePreviewDialog({ src, alt, open, onClose }) {
6736
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(Dialog/* Dialog */.l, {
6737
+ open: open,
6738
+ onClose: onClose,
6739
+ title: "Image preview",
6740
+ size: "full",
6741
+ align: "center",
6742
+ level: "elevated",
6743
+ padded: false,
6744
+ fitViewport: true,
6745
+ footer: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6746
+ className: "flex items-center justify-end gap-2 px-4 pb-3",
6747
+ children: [
6748
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("a", {
6749
+ href: src,
6750
+ target: "_blank",
6751
+ rel: "noopener noreferrer",
6752
+ className: "px-2.5 py-1.5 rounded-md border border-border/70 bg-surface-3 text-xs text-fg-muted hover:text-fg hover:border-border",
6753
+ children: "Open in new tab"
6754
+ }),
6755
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
6756
+ type: "button",
6757
+ onClick: onClose,
6758
+ className: "px-2.5 py-1.5 rounded-md border border-border/70 bg-surface-3 text-xs text-fg-muted hover:text-fg hover:border-border",
6759
+ children: "Close"
6760
+ })
6761
+ ]
6762
+ }),
6763
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6764
+ className: "h-full w-full min-w-0 bg-black/95 flex items-center justify-center",
6765
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)("img", {
6766
+ src: src,
6767
+ alt: alt,
6768
+ className: "block max-h-full max-w-full h-auto w-auto object-contain"
6769
+ })
6770
+ })
6771
+ });
6772
+ }
6773
+
6774
+ ;// ./components/chat/MessageBubble.tsx
6775
+ /* __next_internal_client_entry_do_not_use__ MessageBubble auto */
6776
+
6777
+
6778
+
6779
+
6780
+
6781
+
6782
+
6783
+
6784
+
6785
+
6786
+
6787
+
6788
+
6789
+
6790
+
6791
+
6792
+
6793
+ // Best-effort plain-text projection of a (possibly structured) message body
6794
+ // for the TTS endpoint. Strips markdown noise, code fences, refs blocks,
6795
+ // and structured content parts so the spoken output doesn't read aloud
6796
+ // asterisks, backticks, or URLs. The string is also cropped to keep TTS
6797
+ // requests cheap — voices read about 150wpm so 5000 chars is several minutes.
6798
+ function plainTextForTts(content) {
6799
+ let text = "";
6800
+ if (typeof content === "string") text = content;
6801
+ else if (Array.isArray(content)) {
6802
+ for (const part of content){
6803
+ if (part && typeof part === "object" && "type" in part) {
6804
+ const p = part;
6805
+ if (p.type === "text" && typeof p.text === "string") text += `${p.text}\n`;
6806
+ }
6807
+ }
6808
+ }
6809
+ text = text.replace(/<refs>[\s\S]*?<\/refs>/gi, " ").replace(/```[\s\S]*?```/g, " [code] ").replace(/`([^`]+)`/g, "$1").replace(/!\[[^\]]*\]\([^)]*\)/g, " ").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/[#>*_~]+/g, " ").replace(/\s+/g, " ").trim();
6810
+ return text.length > 5000 ? text.slice(0, 5000) : text;
6811
+ }
6812
+ // Splits "<refs>…</refs>" off the end of a message, returning the parsed refs
6813
+ // and the body without the block. Defensive against partial blocks emitted
6814
+ // mid-stream and against the agent forgetting the closing tag.
6815
+ function extractRefs(text) {
6816
+ const match = /<refs>([\s\S]*?)<\/refs>/i.exec(text);
6817
+ if (!match) return {
6818
+ body: text,
6819
+ refs: []
6820
+ };
6821
+ const inner = match[1];
6822
+ const refs = [];
6823
+ const linkRe = /\[([^\]]+)\]\(([^)]+)\)/g;
6824
+ let m;
6825
+ while((m = linkRe.exec(inner)) !== null){
6826
+ const url = m[2].trim();
6827
+ if (/^https?:\/\//.test(url)) refs.push({
6828
+ title: m[1].trim(),
6829
+ url
6830
+ });
6831
+ }
6832
+ // Also catch bare-URL lines for resilience.
6833
+ if (refs.length === 0) {
6834
+ for (const line of inner.split("\n")){
6835
+ const u = line.trim().match(/^https?:\/\/\S+/);
6836
+ if (u) refs.push({
6837
+ title: u[0].replace(/^https?:\/\/(www\.)?/, "").slice(0, 60),
6838
+ url: u[0]
6839
+ });
6840
+ }
6841
+ }
6842
+ const body = (text.slice(0, match.index) + text.slice(match.index + match[0].length)).trimEnd();
6843
+ return {
6844
+ body,
6845
+ refs
6846
+ };
6847
+ }
6848
+ function parseCapturedContext(raw) {
6849
+ if (!raw.startsWith("📎 Captured from ")) return null;
6850
+ const linkRe = /^📎 Captured from \[([^\]]+)\]\((https?:\/\/[^)]+)\)\s*\n?/;
6851
+ const bareRe = /^📎 Captured from <(https?:\/\/[^>]+)>\s*\n?/;
6852
+ let title = "";
6853
+ let url = "";
6854
+ let rest = raw;
6855
+ const lm = linkRe.exec(raw);
6856
+ if (lm) {
6857
+ title = lm[1];
6858
+ url = lm[2];
6859
+ rest = raw.slice(lm[0].length);
6860
+ } else {
6861
+ const bm = bareRe.exec(raw);
6862
+ if (!bm) return null;
6863
+ url = bm[1];
6864
+ title = url;
6865
+ rest = raw.slice(bm[0].length);
6866
+ }
6867
+ const out = {
6868
+ title,
6869
+ url,
6870
+ selector: null,
6871
+ truncated: false,
6872
+ originalBytes: null,
6873
+ body: ""
6874
+ };
6875
+ const sm = /^Element: `([^`]+)`\s*\n?/.exec(rest);
6876
+ if (sm) {
6877
+ out.selector = sm[1];
6878
+ rest = rest.slice(sm[0].length);
6879
+ }
6880
+ const tm = /^>\s*⚠[^\n]*?\(original was ([\d,]+) bytes\)[^\n]*\n?/.exec(rest);
6881
+ if (tm) {
6882
+ out.truncated = true;
6883
+ out.originalBytes = Number(tm[1].replace(/,/g, ""));
6884
+ rest = rest.slice(tm[0].length);
6885
+ }
6886
+ rest = rest.replace(/^\s*\n/, "").replace(/^---\s*\n?/, "").replace(/^\n+/, "");
6887
+ out.body = rest;
6888
+ return out;
6889
+ }
6890
+ // Header-always-visible card for page captures. Body collapsed by default;
6891
+ // the user can expand to read the captured page text inline. The agent
6892
+ // already has the full text in the thread regardless of expand state — this
6893
+ // is purely a UI affordance to keep ~100KB blobs from blowing the chat layout.
6894
+ function CapturedContextCard({ ctx, accent }) {
6895
+ const hostname = (()=>{
6896
+ try {
6897
+ return new URL(ctx.url).hostname;
6898
+ } catch {
6899
+ return ctx.url;
6900
+ }
6901
+ })();
6902
+ const chips = /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
6903
+ children: [
6904
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
6905
+ href: ctx.url,
6906
+ target: "_blank",
6907
+ rel: "noopener noreferrer",
6908
+ onClick: (e)=>e.stopPropagation(),
6909
+ className: "inline-flex items-center gap-1 underline decoration-dotted hover:decoration-solid truncate max-w-[18rem]",
6910
+ title: ctx.url,
6911
+ children: [
6912
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(icons_link/* default */.A, {
6913
+ size: 9,
6914
+ className: "shrink-0"
6915
+ }),
6916
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6917
+ className: "truncate",
6918
+ children: hostname
6919
+ })
6920
+ ]
6921
+ }),
6922
+ ctx.selector && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6923
+ className: `px-1.5 py-0.5 rounded font-mono ${accent ? "bg-white/15" : "bg-surface-3"}`,
6924
+ title: ctx.selector,
6925
+ children: ctx.selector.length > 36 ? `…${ctx.selector.slice(-33)}` : ctx.selector
6926
+ }),
6927
+ ctx.truncated && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6928
+ className: `px-1.5 py-0.5 rounded ${accent ? "bg-amber-300/25 text-amber-50" : "bg-amber-900/30 text-amber-300"}`,
6929
+ title: ctx.originalBytes ? `Original was ${ctx.originalBytes.toLocaleString()} bytes` : undefined,
6930
+ children: "truncated to 100KB"
6931
+ })
6932
+ ]
6933
+ });
6934
+ const sections = ctx.body ? [
6935
+ {
6936
+ label: "Captured content",
6937
+ defaultOpen: false,
6938
+ content: /*#__PURE__*/ (0,jsx_runtime.jsx)("p", {
6939
+ className: "whitespace-pre-wrap text-[12.5px] leading-relaxed opacity-90",
6940
+ children: ctx.body
6941
+ })
6942
+ }
6943
+ ] : [];
6944
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(StructuredTurnCard, {
6945
+ categoryKey: "page_capture",
6946
+ Icon: paperclip/* default */.A,
6947
+ title: ctx.title || hostname,
6948
+ titleTooltip: ctx.url,
6949
+ chips: chips,
6950
+ sections: sections,
6951
+ accent: accent
6952
+ });
6953
+ }
6954
+ // Browser-extension turn card. The prompt format and parser live in
6955
+ // `lib/api/extension-turn-prompt` so the compose/parse pair stays in sync
6956
+ // between the server handler and this view.
6957
+ function ExtensionTurnCard({ ctx, accent }) {
6958
+ const hostname = ctx.url ? (()=>{
6959
+ try {
6960
+ return new URL(ctx.url).hostname;
6961
+ } catch {
6962
+ return ctx.url;
6963
+ }
6964
+ })() : null;
6965
+ const chips = ctx.url || ctx.selector || ctx.selectedText ? /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
6966
+ children: [
6967
+ ctx.url && hostname && /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
6968
+ href: ctx.url,
6969
+ target: "_blank",
6970
+ rel: "noopener noreferrer",
6971
+ onClick: (e)=>e.stopPropagation(),
6972
+ className: "inline-flex items-center gap-1 underline decoration-dotted hover:decoration-solid truncate max-w-[18rem]",
6973
+ title: ctx.url,
6974
+ children: [
6975
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(icons_link/* default */.A, {
6976
+ size: 9,
6977
+ className: "shrink-0"
6978
+ }),
6979
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6980
+ className: "truncate",
6981
+ children: ctx.title || hostname
6982
+ })
6983
+ ]
6984
+ }),
6985
+ ctx.selector && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6986
+ className: `px-1.5 py-0.5 rounded font-mono ${accent ? "bg-white/15" : "bg-surface-3"}`,
6987
+ title: ctx.selector,
6988
+ children: ctx.selector.length > 36 ? `…${ctx.selector.slice(-33)}` : ctx.selector
6989
+ }),
6990
+ ctx.selectedText && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6991
+ className: `px-1.5 py-0.5 rounded ${accent ? "bg-white/15" : "bg-surface-3"}`,
6992
+ children: `${ctx.selectedText.length.toLocaleString()} chars selected`
6993
+ })
6994
+ ]
6995
+ }) : null;
6996
+ const sections = [];
6997
+ if (ctx.instruction) {
6998
+ sections.push({
6999
+ label: "Instruction",
7000
+ defaultOpen: false,
7001
+ content: /*#__PURE__*/ (0,jsx_runtime.jsx)(MarkdownContent, {
7002
+ text: ctx.instruction
7003
+ })
7004
+ });
7005
+ }
7006
+ if (ctx.selectedText || ctx.pageContext) {
7007
+ sections.push({
7008
+ label: "Context",
7009
+ defaultOpen: false,
7010
+ content: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7011
+ className: "flex flex-col gap-2",
7012
+ children: [
7013
+ ctx.selectedText && /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7014
+ children: [
7015
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7016
+ className: `text-[9.5px] uppercase tracking-wide mb-0.5 ${accent ? "text-white/55" : "text-fg-faint"}`,
7017
+ children: "Selected"
7018
+ }),
7019
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("p", {
7020
+ className: "whitespace-pre-wrap text-[12.5px] leading-relaxed opacity-90",
7021
+ children: ctx.selectedText
7022
+ })
7023
+ ]
7024
+ }),
7025
+ ctx.pageContext && /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7026
+ children: [
7027
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7028
+ className: `text-[9.5px] uppercase tracking-wide mb-0.5 ${accent ? "text-white/55" : "text-fg-faint"}`,
7029
+ children: "Page"
7030
+ }),
7031
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("p", {
7032
+ className: "whitespace-pre-wrap text-[12px] leading-relaxed opacity-80",
7033
+ children: ctx.pageContext
7034
+ })
7035
+ ]
7036
+ })
7037
+ ]
7038
+ })
7039
+ });
7040
+ }
7041
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(StructuredTurnCard, {
7042
+ categoryKey: "extension",
7043
+ Icon: zap/* default */.A,
7044
+ title: ctx.actionLabel,
7045
+ chips: chips,
7046
+ sections: sections,
7047
+ accent: accent
7048
+ });
7049
+ }
7050
+ const AUTOMATION_ACTIVITY_SOURCE = {
7051
+ scheduled_task: {
7052
+ label: "Scheduled task",
7053
+ Icon: clock/* default */.A
7054
+ },
7055
+ watcher: {
7056
+ label: "Watcher",
7057
+ Icon: eye/* default */.A
7058
+ },
7059
+ bridge: {
7060
+ label: "Bridge",
7061
+ Icon: message_circle/* default */.A
7062
+ }
7063
+ };
7064
+ const AUTOMATION_ACTIVITY_STATUS = {
7065
+ queued: {
7066
+ copy: "Queued",
7067
+ cls: "border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300"
7068
+ },
7069
+ checking: {
7070
+ copy: "Checking…",
6178
7071
  cls: "border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300"
6179
7072
  },
6180
7073
  action: {
@@ -6304,355 +7197,116 @@ function AutomationActivityRow({ activity }) {
6304
7197
  children: details.map(({ label, value })=>/*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6305
7198
  className: "flex gap-1.5 whitespace-pre-wrap break-words",
6306
7199
  children: [
6307
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
6308
- className: "shrink-0 font-medium opacity-70",
6309
- children: [
6310
- label,
6311
- ":"
6312
- ]
6313
- }),
6314
- /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6315
- className: label === "Error" ? "text-rose-700 dark:text-rose-300" : "text-fg-muted",
6316
- children: value
6317
- })
6318
- ]
6319
- }, label))
6320
- }) : null
6321
- ]
6322
- })
6323
- });
6324
- }
6325
- function CategorySourceBadge({ category }) {
6326
- const def = CATEGORY_BADGE[category];
6327
- if (!def) return null;
6328
- const { label, Icon, cls } = def;
6329
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6330
- className: `inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full border text-[10px] font-medium mb-1.5 self-start ${cls}`,
6331
- children: [
6332
- /*#__PURE__*/ (0,jsx_runtime.jsx)(Icon, {
6333
- size: 9,
6334
- className: "shrink-0"
6335
- }),
6336
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
6337
- children: [
6338
- label,
6339
- " reply"
6340
- ]
6341
- })
6342
- ]
6343
- });
6344
- }
6345
- // Auto-collapses any bubble whose rendered content would exceed `threshold`
6346
- // pixels. Applied to long user/assistant text so a captured-and-pasted code
6347
- // block or a multi-screen agent answer doesn't push the rest of the
6348
- // conversation off-screen. Detection is observation-based (ResizeObserver on
6349
- // scrollHeight) so it works for markdown, code blocks, images, and embeds
6350
- // uniformly without needing a per-content-type heuristic.
6351
- function CollapsibleLong({ children, threshold = 480, accent, streaming = false, defaultOpen = false }) {
6352
- const innerRef = (0,react.useRef)(null);
6353
- const [overflows, setOverflows] = (0,react.useState)(false);
6354
- const [open, setOpen] = (0,react.useState)(defaultOpen);
6355
- // Latched true once the user has been treated as "actively reading" this
6356
- // bubble — either the first measurement saw the content fit, OR the
6357
- // bubble was ever observed streaming, OR it was rendered as the latest
6358
- // turn (just streamed, the user is mid-read). From that point, growing
6359
- // past the threshold or remounting must NOT snap it closed.
6360
- const firstFitRef = (0,react.useRef)(defaultOpen);
6361
- const wasStreamingRef = (0,react.useRef)(false);
6362
- if (streaming) wasStreamingRef.current = true;
6363
- (0,react.useEffect)(()=>{
6364
- const el = innerRef.current;
6365
- if (!el) return;
6366
- const check = ()=>{
6367
- const over = el.scrollHeight > threshold + 24;
6368
- setOverflows(over);
6369
- if (!firstFitRef.current) {
6370
- if (!over || wasStreamingRef.current || defaultOpen) {
6371
- firstFitRef.current = true;
6372
- setOpen(true);
6373
- }
6374
- }
6375
- };
6376
- check();
6377
- const ro = new ResizeObserver(check);
6378
- ro.observe(el);
6379
- return ()=>ro.disconnect();
6380
- }, [
6381
- threshold,
6382
- defaultOpen
6383
- ]);
6384
- const collapsed = overflows && !open;
6385
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6386
- className: "flex flex-col min-w-0",
6387
- children: [
6388
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6389
- ref: innerRef,
6390
- className: collapsed ? "relative overflow-hidden min-w-0" : "min-w-0",
6391
- style: collapsed ? {
6392
- maxHeight: threshold
6393
- } : undefined,
6394
- children: [
6395
- children,
6396
- collapsed && /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6397
- className: `pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t ${accent ? "from-black/30" : "from-surface-1/90"} to-transparent`
6398
- })
6399
- ]
6400
- }),
6401
- overflows && /*#__PURE__*/ (0,jsx_runtime.jsxs)("button", {
6402
- type: "button",
6403
- onClick: ()=>setOpen((v)=>!v),
6404
- className: `mt-1.5 self-start inline-flex items-center gap-1 text-[11px] ${accent ? "text-white/85 hover:text-white" : "text-fg-faint hover:text-fg-muted"}`,
6405
- "aria-expanded": open,
6406
- children: [
6407
- /*#__PURE__*/ (0,jsx_runtime.jsx)(CollapseChevron, {
6408
- open: open,
6409
- size: 10
6410
- }),
6411
- open ? "Show less" : "Show more"
6412
- ]
6413
- })
6414
- ]
6415
- });
6416
- }
6417
- // Sanitizer schema = GitHub default + extras the agent is told it can use.
6418
- // Anything not listed here gets stripped (scripts, event handlers, javascript: URLs).
6419
- const sanitizeSchema = {
6420
- ...schema/* defaultSchema */.j,
6421
- tagNames: [
6422
- ...schema/* defaultSchema */.j.tagNames ?? [],
6423
- "details",
6424
- "summary",
6425
- "mark",
6426
- "kbd",
6427
- "sub",
6428
- "sup",
6429
- "abbr",
6430
- "small",
6431
- "aside",
6432
- "figure",
6433
- "figcaption",
6434
- "dl",
6435
- "dt",
6436
- "dd",
6437
- "audio",
6438
- "source"
6439
- ],
6440
- attributes: {
6441
- ...schema/* defaultSchema */.j.attributes ?? {},
6442
- "*": [
6443
- ...(schema/* defaultSchema */.j.attributes ?? {})["*"] ?? [],
6444
- "className",
6445
- "title"
6446
- ],
6447
- aside: [
6448
- "className"
6449
- ],
6450
- abbr: [
6451
- "title"
6452
- ],
6453
- details: [
6454
- "open"
6455
- ],
6456
- audio: [
6457
- "src",
6458
- "controls",
6459
- "preload",
6460
- "loop",
6461
- "autoplay",
6462
- "muted"
6463
- ],
6464
- source: [
6465
- "src",
6466
- "type"
6467
- ]
6468
- }
6469
- };
6470
- // Module-scope plugin arrays — passing fresh array literals to ReactMarkdown
6471
- // on every render of MarkdownContent forced react-markdown's internal
6472
- // useMemo() inputs to differ each time, defeating its plugin-pipeline
6473
- // memoization. Hoisting these makes the references stable across renders.
6474
- const MD_REMARK_PLUGINS = [
6475
- remark_gfm_lib/* default */.A
6476
- ];
6477
- // rehype-highlight runs after rehype-raw (so any raw HTML <code> blocks are
6478
- // also highlighted) and before rehype-sanitize (so the spans/classes it adds
6479
- // pass through the sanitizer's allow-list rather than being stripped).
6480
- const MD_REHYPE_PLUGINS = [
6481
- rehype_raw_lib/* default */.A,
6482
- [
6483
- rehype_highlight_lib/* default */.A,
6484
- {
6485
- detect: true,
6486
- ignoreMissing: true
6487
- }
6488
- ],
6489
- [
6490
- rehype_sanitize_lib/* default */.A,
6491
- sanitizeSchema
6492
- ]
6493
- ];
6494
- function isLikelyLocalFileHref(href) {
6495
- if (!href || href.startsWith("#")) return false;
6496
- if (/^(mailto|tel|javascript|data|blob):/i.test(href)) return false;
6497
- if (/^file:\/\//i.test(href)) return true;
6498
- if (/^[A-Za-z]:[\\/]/.test(href) || href.startsWith("~/") || href.startsWith("~\\")) return true;
6499
- if (/^https?:\/\//i.test(href)) {
6500
- try {
6501
- const url = new URL(href);
6502
- if (![
6503
- "localhost",
6504
- "127.0.0.1",
6505
- "[::1]",
6506
- "::1"
6507
- ].includes(url.hostname)) return false;
6508
- return !/^\/(api|_next)(\/|$)/.test(url.pathname);
6509
- } catch {
6510
- return false;
6511
- }
6512
- }
6513
- if (href.startsWith("/")) return false;
6514
- if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return false;
6515
- return /(^\.\.?[\\/]|[\\/]|\.[A-Za-z0-9]{1,12}(?:[?#]|$))/.test(href);
6516
- }
6517
- function LocalFileLink({ href, threadId, children, className, title }) {
6518
- const [preview, setPreview] = (0,react.useState)(null);
6519
- const [loading, setLoading] = (0,react.useState)(false);
6520
- const [openError, setOpenError] = (0,react.useState)(null);
6521
- const openDefault = (0,react.useCallback)(async ()=>{
6522
- setOpenError(null);
6523
- const res = await fetch("/api/v1/local-file", {
6524
- method: "POST",
6525
- headers: {
6526
- "Content-Type": "application/json"
6527
- },
6528
- body: JSON.stringify({
6529
- href,
6530
- thread_id: threadId ?? undefined
6531
- })
6532
- });
6533
- const body = await res.json().catch(()=>({}));
6534
- if (!res.ok) throw new Error(body.error ?? `HTTP ${res.status}`);
6535
- (0,ui_toasts/* pushToast */.Iz)({
6536
- kind: "success",
6537
- source: "system",
6538
- sourceLabel: "Chat",
6539
- title: "Opening file",
6540
- body: "Sent the file to the operating system default app.",
6541
- agent_id: null,
6542
- thread_id: threadId ?? null,
6543
- ttl: 1800
6544
- });
6545
- }, [
6546
- href,
6547
- threadId
6548
- ]);
6549
- const activate = (0,react.useCallback)(async ()=>{
6550
- setLoading(true);
6551
- setOpenError(null);
6552
- try {
6553
- const params = new URLSearchParams({
6554
- href
6555
- });
6556
- if (threadId) params.set("thread_id", threadId);
6557
- const res = await fetch(`/api/v1/local-file?${params.toString()}`);
6558
- const body = await res.json().catch(()=>({}));
6559
- if (!res.ok) throw new Error(body.error ?? `HTTP ${res.status}`);
6560
- const info = body;
6561
- setPreview(info);
6562
- if (!info.renderable) await openDefault();
6563
- } catch (err) {
6564
- const msg = (0,utils_error/* errorMessage */.g)(err);
6565
- setOpenError(msg);
6566
- (0,ui_toasts/* pushToast */.Iz)({
6567
- kind: "error",
6568
- source: "system",
6569
- sourceLabel: "Chat",
6570
- title: "Could not open file",
6571
- body: msg,
6572
- agent_id: null,
6573
- thread_id: threadId ?? null,
6574
- ttl: 5000
6575
- });
6576
- } finally{
6577
- setLoading(false);
6578
- }
7200
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
7201
+ className: "shrink-0 font-medium opacity-70",
7202
+ children: [
7203
+ label,
7204
+ ":"
7205
+ ]
7206
+ }),
7207
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
7208
+ className: label === "Error" ? "text-rose-700 dark:text-rose-300" : "text-fg-muted",
7209
+ children: value
7210
+ })
7211
+ ]
7212
+ }, label))
7213
+ }) : null
7214
+ ]
7215
+ })
7216
+ });
7217
+ }
7218
+ function CategorySourceBadge({ category }) {
7219
+ const def = CATEGORY_BADGE[category];
7220
+ if (!def) return null;
7221
+ const { label, Icon, cls } = def;
7222
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7223
+ className: `inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full border text-[10px] font-medium mb-1.5 self-start ${cls}`,
7224
+ children: [
7225
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(Icon, {
7226
+ size: 9,
7227
+ className: "shrink-0"
7228
+ }),
7229
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
7230
+ children: [
7231
+ label,
7232
+ " reply"
7233
+ ]
7234
+ })
7235
+ ]
7236
+ });
7237
+ }
7238
+ // Auto-collapses any bubble whose rendered content would exceed `threshold`
7239
+ // pixels. Applied to long user/assistant text so a captured-and-pasted code
7240
+ // block or a multi-screen agent answer doesn't push the rest of the
7241
+ // conversation off-screen. Detection is observation-based (ResizeObserver on
7242
+ // scrollHeight) so it works for markdown, code blocks, images, and embeds
7243
+ // uniformly without needing a per-content-type heuristic.
7244
+ function CollapsibleLong({ children, threshold = 480, accent, streaming = false, defaultOpen = false }) {
7245
+ const innerRef = (0,react.useRef)(null);
7246
+ const [overflows, setOverflows] = (0,react.useState)(false);
7247
+ const [open, setOpen] = (0,react.useState)(defaultOpen);
7248
+ // Latched true once the user has been treated as "actively reading" this
7249
+ // bubble — either the first measurement saw the content fit, OR the
7250
+ // bubble was ever observed streaming, OR it was rendered as the latest
7251
+ // turn (just streamed, the user is mid-read). From that point, growing
7252
+ // past the threshold or remounting must NOT snap it closed.
7253
+ const firstFitRef = (0,react.useRef)(defaultOpen);
7254
+ const wasStreamingRef = (0,react.useRef)(false);
7255
+ if (streaming) wasStreamingRef.current = true;
7256
+ (0,react.useEffect)(()=>{
7257
+ const el = innerRef.current;
7258
+ if (!el) return;
7259
+ const check = ()=>{
7260
+ const over = el.scrollHeight > threshold + 24;
7261
+ setOverflows(over);
7262
+ if (!firstFitRef.current) {
7263
+ if (!over || wasStreamingRef.current || defaultOpen) {
7264
+ firstFitRef.current = true;
7265
+ setOpen(true);
7266
+ }
7267
+ }
7268
+ };
7269
+ check();
7270
+ const ro = new ResizeObserver(check);
7271
+ ro.observe(el);
7272
+ return ()=>ro.disconnect();
6579
7273
  }, [
6580
- href,
6581
- openDefault,
6582
- threadId
7274
+ threshold,
7275
+ defaultOpen
6583
7276
  ]);
6584
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
6585
- className: "inline-flex flex-col max-w-full align-baseline",
7277
+ const collapsed = overflows && !open;
7278
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7279
+ className: "flex flex-col min-w-0",
6586
7280
  children: [
6587
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("button", {
6588
- type: "button",
6589
- className: `${className ?? ""} inline-flex items-baseline gap-1 text-left underline decoration-dotted hover:decoration-solid break-all`.trim(),
6590
- title: title ?? href,
6591
- onClick: activate,
6592
- disabled: loading,
7281
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7282
+ ref: innerRef,
7283
+ className: collapsed ? "relative overflow-hidden min-w-0" : "min-w-0",
7284
+ style: collapsed ? {
7285
+ maxHeight: threshold
7286
+ } : undefined,
6593
7287
  children: [
6594
- /*#__PURE__*/ (0,jsx_runtime.jsx)(file_text/* default */.A, {
6595
- size: 12,
6596
- className: "relative top-0.5 shrink-0"
6597
- }),
6598
- /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6599
- children: children
6600
- }),
6601
- loading && /*#__PURE__*/ (0,jsx_runtime.jsx)(loader_circle/* default */.A, {
6602
- size: 11,
6603
- className: "relative top-0.5 shrink-0 animate-spin"
7288
+ children,
7289
+ collapsed && /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7290
+ className: `pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t ${accent ? "from-black/30" : "from-surface-1/90"} to-transparent`
6604
7291
  })
6605
7292
  ]
6606
7293
  }),
6607
- preview?.renderable && typeof preview.snippet === "string" && /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
6608
- className: "not-prose my-2 block rounded-md border border-border/60 bg-surface-2 overflow-hidden",
7294
+ overflows && /*#__PURE__*/ (0,jsx_runtime.jsxs)("button", {
7295
+ type: "button",
7296
+ onClick: ()=>setOpen((v)=>!v),
7297
+ className: `mt-1.5 self-start inline-flex items-center gap-1 text-[11px] ${accent ? "text-white/85 hover:text-white" : "text-fg-faint hover:text-fg-muted"}`,
7298
+ "aria-expanded": open,
6609
7299
  children: [
6610
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("span", {
6611
- className: "flex items-center justify-between gap-2 px-2 py-1 text-[10px] text-fg-faint bg-surface-3",
6612
- children: [
6613
- /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6614
- className: "truncate",
6615
- title: preview.path,
6616
- children: preview.path
6617
- }),
6618
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("button", {
6619
- type: "button",
6620
- onClick: openDefault,
6621
- className: "inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border/60 bg-surface-2 text-fg-muted hover:text-fg shrink-0",
6622
- children: [
6623
- /*#__PURE__*/ (0,jsx_runtime.jsx)(external_link/* default */.A, {
6624
- size: 10
6625
- }),
6626
- "Open"
6627
- ]
6628
- })
6629
- ]
7300
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(CollapseChevron, {
7301
+ open: open,
7302
+ size: 10
6630
7303
  }),
6631
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("code", {
6632
- className: "block max-h-72 overflow-auto whitespace-pre-wrap break-words px-3 py-2 text-xs leading-relaxed text-fg-muted bg-[#0d1117]",
6633
- children: [
6634
- preview.snippet,
6635
- preview.truncated ? "\n..." : ""
6636
- ]
6637
- })
7304
+ open ? "Show less" : "Show more"
6638
7305
  ]
6639
- }),
6640
- openError && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
6641
- className: "text-[11px] text-rose-400 mt-1",
6642
- children: openError
6643
7306
  })
6644
7307
  ]
6645
7308
  });
6646
7309
  }
6647
- function reactChildrenToText(children) {
6648
- if (children == null || typeof children === "boolean") return "";
6649
- if (typeof children === "string" || typeof children === "number") return String(children);
6650
- if (Array.isArray(children)) return children.map(reactChildrenToText).join("");
6651
- if (typeof children === "object" && "props" in children) {
6652
- return reactChildrenToText(children.props.children);
6653
- }
6654
- return "";
6655
- }
6656
7310
  const GRADIENTS = [
6657
7311
  "from-violet-500 to-indigo-600",
6658
7312
  "from-blue-500 to-cyan-600",
@@ -6896,359 +7550,6 @@ function parseContent(raw) {
6896
7550
  }
6897
7551
  return raw;
6898
7552
  }
6899
- // Markdown image renderer with a one-time automatic retry. If both attempts
6900
- // fail (common on transient local-network/SW races), show a compact fallback
6901
- // with explicit actions instead of a broken image icon.
6902
- function ResilientMarkdownImage({ src, alt }) {
6903
- const [retryNonce, setRetryNonce] = (0,react.useState)(0);
6904
- const [failed, setFailed] = (0,react.useState)(false);
6905
- const [open, setOpen] = (0,react.useState)(false);
6906
- const objectUrl = (0,react.useMemo)(()=>src instanceof Blob ? URL.createObjectURL(src) : null, [
6907
- src
6908
- ]);
6909
- (0,react.useEffect)(()=>{
6910
- return ()=>{
6911
- if (objectUrl) URL.revokeObjectURL(objectUrl);
6912
- };
6913
- }, [
6914
- objectUrl
6915
- ]);
6916
- const normalizedSrc = typeof src === "string" ? src : objectUrl ?? "";
6917
- const effectiveSrc = normalizedSrc ? `${normalizedSrc}${normalizedSrc.includes("?") ? "&" : "?"}retry=${retryNonce}` : "";
6918
- if (!normalizedSrc) {
6919
- return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6920
- className: "my-2 px-3 py-2 rounded border border-rose-800/60 bg-rose-950/30 text-xs text-rose-700 dark:text-rose-300",
6921
- children: "Invalid image URL in markdown."
6922
- });
6923
- }
6924
- if (failed) {
6925
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6926
- className: "my-2 px-3 py-2 rounded border border-amber-700/50 bg-amber-900/20 text-xs text-amber-300",
6927
- children: [
6928
- /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
6929
- children: "Image failed to load."
6930
- }),
6931
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
6932
- className: "mt-1 flex items-center gap-2",
6933
- children: [
6934
- /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
6935
- type: "button",
6936
- className: "px-2 py-1 rounded border border-amber-500/60 hover:bg-amber-900/30",
6937
- onClick: ()=>{
6938
- setFailed(false);
6939
- setRetryNonce((n)=>n + 1);
6940
- },
6941
- children: "Retry"
6942
- }),
6943
- /*#__PURE__*/ (0,jsx_runtime.jsx)("a", {
6944
- href: normalizedSrc,
6945
- target: "_blank",
6946
- rel: "noopener noreferrer",
6947
- className: "underline decoration-dotted hover:decoration-solid break-all",
6948
- children: "Open image"
6949
- })
6950
- ]
6951
- })
6952
- ]
6953
- });
6954
- }
6955
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
6956
- children: [
6957
- /*#__PURE__*/ (0,jsx_runtime.jsx)("img", {
6958
- src: effectiveSrc,
6959
- alt: alt ?? "image",
6960
- loading: "lazy",
6961
- className: "rounded-lg border border-border/50 cursor-zoom-in hover:border-fg-faint transition-colors",
6962
- onClick: ()=>setOpen(true),
6963
- onError: ()=>{
6964
- if (retryNonce === 0) {
6965
- setRetryNonce(1);
6966
- return;
6967
- }
6968
- setFailed(true);
6969
- }
6970
- }),
6971
- /*#__PURE__*/ (0,jsx_runtime.jsx)(ImagePreviewDialog, {
6972
- src: normalizedSrc,
6973
- alt: alt ?? "image",
6974
- open: open,
6975
- onClose: ()=>setOpen(false)
6976
- })
6977
- ]
6978
- });
6979
- }
6980
- // Renders a Google Maps Embed inside an iframe whose src points at our
6981
- // server-side proxy (/api/v1/maps/embed). The proxy injects the API key so
6982
- // it never appears in chat HTML. Triggered by ```map fenced blocks emitted
6983
- // by the agent — see PRESENTATION_CTX in lib/agents/run-thread.ts.
6984
- function MapEmbed({ payload }) {
6985
- const [retryNonce, setRetryNonce] = (0,react.useState)(0);
6986
- const [failed, setFailed] = (0,react.useState)(false);
6987
- let params = null;
6988
- let parseError = null;
6989
- try {
6990
- const obj = JSON.parse(payload);
6991
- const sp = new URLSearchParams();
6992
- for (const k of [
6993
- "q",
6994
- "center",
6995
- "zoom",
6996
- "origin",
6997
- "destination",
6998
- "search",
6999
- "mode"
7000
- ]){
7001
- const v = obj[k];
7002
- if (typeof v === "string" && v.length > 0) sp.set(k, v);
7003
- else if (typeof v === "number") sp.set(k, String(v));
7004
- }
7005
- if ([
7006
- ...sp.keys()
7007
- ].length === 0) parseError = "no recognized fields (q / center / origin+destination / search)";
7008
- else params = sp;
7009
- } catch (e) {
7010
- parseError = (0,utils_error/* errorMessage */.g)(e);
7011
- }
7012
- if (!params) {
7013
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7014
- className: "my-2 px-3 py-2 rounded border border-rose-800/60 bg-rose-950/30 text-xs text-rose-700 dark:text-rose-300",
7015
- children: [
7016
- "Invalid map block: ",
7017
- parseError
7018
- ]
7019
- });
7020
- }
7021
- const src = `/api/v1/maps/embed?${params.toString()}${retryNonce > 0 ? `&retry=${retryNonce}` : ""}`;
7022
- if (failed) {
7023
- const q = params.get("q") ?? params.get("search") ?? params.get("center") ?? "";
7024
- const direct = q ? `https://www.google.com/maps?q=${encodeURIComponent(q)}` : "https://www.google.com/maps";
7025
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7026
- className: "my-2 px-3 py-2 rounded border border-amber-700/50 bg-amber-900/20 text-xs text-amber-300",
7027
- children: [
7028
- /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7029
- children: "Map failed to load."
7030
- }),
7031
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7032
- className: "mt-1 flex items-center gap-2",
7033
- children: [
7034
- /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
7035
- type: "button",
7036
- className: "px-2 py-1 rounded border border-amber-500/60 hover:bg-amber-900/30",
7037
- onClick: ()=>{
7038
- setFailed(false);
7039
- setRetryNonce((n)=>n + 1);
7040
- },
7041
- children: "Retry"
7042
- }),
7043
- /*#__PURE__*/ (0,jsx_runtime.jsx)("a", {
7044
- href: direct,
7045
- target: "_blank",
7046
- rel: "noopener noreferrer",
7047
- className: "underline decoration-dotted hover:decoration-solid",
7048
- children: "Open in Google Maps"
7049
- })
7050
- ]
7051
- })
7052
- ]
7053
- });
7054
- }
7055
- return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7056
- className: "my-2 rounded overflow-hidden border border-border bg-surface-2",
7057
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)("iframe", {
7058
- src: src,
7059
- title: "Map",
7060
- width: "100%",
7061
- height: "320",
7062
- loading: "lazy",
7063
- referrerPolicy: "no-referrer-when-downgrade",
7064
- allowFullScreen: true,
7065
- style: {
7066
- border: 0,
7067
- display: "block"
7068
- },
7069
- onError: ()=>{
7070
- if (retryNonce === 0) {
7071
- setRetryNonce(1);
7072
- return;
7073
- }
7074
- setFailed(true);
7075
- }
7076
- })
7077
- });
7078
- }
7079
- // Memoized: this component appears under every assistant bubble and during
7080
- // streaming gets re-rendered on every rAF flush. The inner ReactMarkdown
7081
- // pipeline (remark + rehype passes, syntax highlighting via rehypeHighlight,
7082
- // custom <a> / <code> renderers) is the expensive part — re-running it
7083
- // against unchanged text on every parent render shows up as jank on long
7084
- // threads. With memo, only the in-flight bubble re-renders during streaming;
7085
- // persisted siblings sit idle.
7086
- const MarkdownContent = /*#__PURE__*/ (0,react.memo)(function MarkdownContent({ text, streaming, onInAppLink, unverifiedLinks, sourceManifest, threadId }) {
7087
- // Inline-citation pre-processor. The agent writes `[3]` markers in-prose;
7088
- // we resolve each to a markdown link `[3](href)` BEFORE react-markdown
7089
- // parses the string so the existing <a> renderer below picks it up with
7090
- // no special-casing. Markers whose number isn't in the manifest are
7091
- // left untouched (they'll show as plain `[3]` text) so an invented
7092
- // number is visibly un-linked rather than silently mis-routed.
7093
- const renderedText = (0,react.useMemo)(()=>{
7094
- if (!sourceManifest || sourceManifest.size === 0) return text;
7095
- return text.replace(/(?<!\])\[(\d+)\]/g, (match, raw)=>{
7096
- const entry = sourceManifest.get(parseInt(raw, 10));
7097
- return entry ? `[${raw}](${entry.href})` : match;
7098
- });
7099
- }, [
7100
- text,
7101
- sourceManifest
7102
- ]);
7103
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7104
- className: "prose prose-invert prose-sm max-w-none jarela-rich min-w-0",
7105
- children: [
7106
- /*#__PURE__*/ (0,jsx_runtime.jsx)(lib/* Markdown */.oz, {
7107
- remarkPlugins: MD_REMARK_PLUGINS,
7108
- rehypePlugins: MD_REHYPE_PLUGINS,
7109
- components: {
7110
- a ({ href, children, ...rest }) {
7111
- const parsed = href ? parseHref(href) : undefined;
7112
- const isUnverified = !!(href && unverifiedLinks?.has(href));
7113
- // Detect citation markers: link text is literally `[N]` where N
7114
- // is a positive integer. These are rendered as small superscript
7115
- // chips (Wikipedia-style) so they're scannable as citations and
7116
- // distinct from ordinary inline links.
7117
- const isCitationMarker = Array.isArray(children) && children.length === 1 ? typeof children[0] === "string" && /^\[\d+\]$/.test(children[0]) : typeof children === "string" && /^\[\d+\]$/.test(children);
7118
- const citationText = isCitationMarker ? Array.isArray(children) ? children[0] : children : null;
7119
- // Inline audio: any link to a local /api/v1/files/*.{wav,mp3,ogg,webm,m4a}
7120
- // becomes a native <audio controls> player. The original anchor
7121
- // text is dropped — the player IS the answer. An `?autoplay=1`
7122
- // query string lets the agent (via generate_voice) ask the
7123
- // browser to start playback immediately.
7124
- if (href && /^\/api\/v1\/files\/[^?#]+\.(wav|mp3|ogg|webm|m4a)(\?|#|$)/i.test(href)) {
7125
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(InlineAudio, {
7126
- href: href
7127
- });
7128
- }
7129
- const unverifiedCls = isUnverified ? "decoration-warn decoration-wavy underline-offset-2" : "";
7130
- const unverifiedTitle = isUnverified ? "Agent did not visit this source in this conversation — the citation may be invented." : undefined;
7131
- if (href && isLikelyLocalFileHref(href)) {
7132
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)(LocalFileLink, {
7133
- href: href,
7134
- threadId: threadId,
7135
- title: unverifiedTitle ?? rest.title,
7136
- className: `${rest.className ?? ""} ${unverifiedCls}`.trim(),
7137
- children: [
7138
- children,
7139
- isUnverified && /*#__PURE__*/ (0,jsx_runtime.jsx)("sup", {
7140
- className: "text-warn ml-0.5",
7141
- "aria-label": "unverified citation",
7142
- children: "⚠"
7143
- })
7144
- ]
7145
- });
7146
- }
7147
- const inApp = !!parsed && !parsed.external && (!!parsed.tab || !!parsed.hash || !!parsed.thread && !!parsed.agent);
7148
- // Citation-marker rendering: superscript chip with a tooltip
7149
- // showing the source label so the user can preview what the
7150
- // marker points to without clicking. The href is still active
7151
- // (jumps to anchor for #msg-… or opens external for URLs).
7152
- if (isCitationMarker && href) {
7153
- const markerNum = parseInt(citationText.replace(/[\[\]]/g, ""), 10);
7154
- const entry = Number.isFinite(markerNum) ? sourceManifest?.get(markerNum) : undefined;
7155
- const title = entry?.label ?? unverifiedTitle ?? href;
7156
- const isAnchor = href.startsWith("#");
7157
- return /*#__PURE__*/ (0,jsx_runtime.jsx)("a", {
7158
- ...rest,
7159
- href: href,
7160
- target: isAnchor || inApp ? undefined : "_blank",
7161
- rel: isAnchor || inApp ? undefined : "noopener noreferrer",
7162
- title: title,
7163
- onClick: inApp && onInAppLink ? (e)=>{
7164
- e.preventDefault();
7165
- onInAppLink(href);
7166
- } : undefined,
7167
- className: "jarela-citation",
7168
- children: citationText
7169
- });
7170
- }
7171
- if (inApp && href && onInAppLink) {
7172
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
7173
- ...rest,
7174
- href: href,
7175
- title: unverifiedTitle ?? rest.title,
7176
- className: `${rest.className ?? ""} ${unverifiedCls}`.trim(),
7177
- onClick: (e)=>{
7178
- e.preventDefault();
7179
- onInAppLink(href);
7180
- },
7181
- children: [
7182
- children,
7183
- isUnverified && /*#__PURE__*/ (0,jsx_runtime.jsx)("sup", {
7184
- className: "text-warn ml-0.5",
7185
- "aria-label": "unverified citation",
7186
- children: "⚠"
7187
- })
7188
- ]
7189
- });
7190
- }
7191
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
7192
- ...rest,
7193
- href: href,
7194
- target: "_blank",
7195
- rel: "noopener noreferrer",
7196
- title: unverifiedTitle ?? rest.title,
7197
- className: `${rest.className ?? ""} ${unverifiedCls}`.trim(),
7198
- children: [
7199
- children,
7200
- isUnverified && /*#__PURE__*/ (0,jsx_runtime.jsx)("sup", {
7201
- className: "text-warn ml-0.5",
7202
- "aria-label": "unverified citation",
7203
- children: "⚠"
7204
- })
7205
- ]
7206
- });
7207
- },
7208
- pre ({ children }) {
7209
- // CodeFence renders its own <pre>, so collapse react-markdown's
7210
- // outer wrapper to avoid <pre><pre>...</pre></pre>.
7211
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
7212
- children: children
7213
- });
7214
- },
7215
- code ({ className, children }) {
7216
- const match = /language-(\w+)/.exec(className ?? "");
7217
- if (match?.[1] === "map") {
7218
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(MapEmbed, {
7219
- payload: reactChildrenToText(children).replace(/\n$/, "")
7220
- });
7221
- }
7222
- if (match?.[1] === "mermaid") {
7223
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(MermaidFence, {
7224
- source: reactChildrenToText(children).replace(/\n$/, "")
7225
- });
7226
- }
7227
- return match ? /*#__PURE__*/ (0,jsx_runtime.jsx)(CodeFence, {
7228
- language: match[1],
7229
- className: className ?? "",
7230
- children: children
7231
- }) : /*#__PURE__*/ (0,jsx_runtime.jsx)("code", {
7232
- className: "bg-surface-2 px-1 rounded text-fg-muted break-all",
7233
- children: children
7234
- });
7235
- },
7236
- img ({ src, alt }) {
7237
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(ResilientMarkdownImage, {
7238
- src: src,
7239
- alt: alt
7240
- });
7241
- }
7242
- },
7243
- children: renderedText
7244
- }),
7245
- streaming && /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
7246
- className: "jarela-stream-caret",
7247
- "aria-hidden": "true"
7248
- })
7249
- ]
7250
- });
7251
- });
7252
7553
  function ReferencesPanel({ sources }) {
7253
7554
  const [open, setOpen] = (0,react.useState)(false);
7254
7555
  if (sources.length === 0) return null;
@@ -7680,308 +7981,9 @@ function RefsFooter({ refs }) {
7680
7981
  ]
7681
7982
  });
7682
7983
  }
7683
- function CodeFence({ language, className, children }) {
7684
- const [copied, setCopied] = (0,react.useState)(false);
7685
- const codeText = (0,react.useMemo)(()=>reactChildrenToText(children).replace(/\n$/, ""), [
7686
- children
7687
- ]);
7688
- const copyCode = (0,react.useCallback)(()=>{
7689
- void navigator.clipboard.writeText(codeText).then(()=>{
7690
- setCopied(true);
7691
- setTimeout(()=>setCopied(false), 1200);
7692
- }).catch(console.error);
7693
- }, [
7694
- codeText
7695
- ]);
7696
- // rehype-highlight already populated `className` with `hljs language-X`
7697
- // plus per-token spans inside `children`. The `hljs` class drives styling
7698
- // from the imported github-dark theme.
7699
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7700
- className: "relative my-2 rounded-md overflow-hidden border border-border/60",
7701
- children: [
7702
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7703
- className: "flex items-center justify-between px-2 py-1 text-[10px] bg-surface-3 text-fg-faint uppercase tracking-wide",
7704
- children: [
7705
- /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
7706
- children: language
7707
- }),
7708
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("button", {
7709
- onClick: copyCode,
7710
- className: "inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border/60 bg-surface-2 text-fg-muted hover:text-fg transition-colors",
7711
- title: "Copy code",
7712
- "aria-label": "Copy code",
7713
- children: [
7714
- copied ? /*#__PURE__*/ (0,jsx_runtime.jsx)(check/* default */.A, {
7715
- size: 10
7716
- }) : /*#__PURE__*/ (0,jsx_runtime.jsx)(copy/* default */.A, {
7717
- size: 10
7718
- }),
7719
- /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
7720
- children: copied ? "Copied" : "Copy"
7721
- })
7722
- ]
7723
- })
7724
- ]
7725
- }),
7726
- /*#__PURE__*/ (0,jsx_runtime.jsx)("pre", {
7727
- className: "m-0 p-3 text-xs leading-relaxed overflow-x-auto bg-[#0d1117]",
7728
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)("code", {
7729
- className: className,
7730
- children: children
7731
- })
7732
- })
7733
- ]
7734
- });
7735
- }
7736
- function MermaidFence({ source }) {
7737
- const renderId = `mermaid-${(0,react.useId)().replace(/[^a-zA-Z0-9_-]/g, "")}`;
7738
- const [svg, setSvg] = (0,react.useState)(null);
7739
- const [error, setError] = (0,react.useState)(null);
7740
- (0,react.useEffect)(()=>{
7741
- let cancelled = false;
7742
- setSvg(null);
7743
- setError(null);
7744
- void (async ()=>{
7745
- try {
7746
- const [{ default: mermaid }, { default: DOMPurify }] = await Promise.all([
7747
- Promise.all(/* import() */[__webpack_require__.e(866), __webpack_require__.e(8367), __webpack_require__.e(1992), __webpack_require__.e(3308)]).then(__webpack_require__.bind(__webpack_require__, 43328)),
7748
- __webpack_require__.e(/* import() */ 1992).then(__webpack_require__.bind(__webpack_require__, 91992))
7749
- ]);
7750
- mermaid.initialize({
7751
- startOnLoad: false,
7752
- securityLevel: "strict",
7753
- theme: "base"
7754
- });
7755
- const result = await mermaid.render(renderId, source);
7756
- if (cancelled) return;
7757
- setSvg(DOMPurify.sanitize(result.svg, {
7758
- USE_PROFILES: {
7759
- svg: true
7760
- }
7761
- }));
7762
- } catch (err) {
7763
- if (!cancelled) setError(err instanceof Error ? err.message : String(err));
7764
- }
7765
- })();
7766
- return ()=>{
7767
- cancelled = true;
7768
- };
7769
- }, [
7770
- renderId,
7771
- source
7772
- ]);
7773
- if (error) {
7774
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7775
- className: "my-2 rounded-md border border-warn/40 bg-warn/5 p-2",
7776
- children: [
7777
- /*#__PURE__*/ (0,jsx_runtime.jsx)("p", {
7778
- className: "mb-1 text-[10px] uppercase tracking-wide text-warn",
7779
- children: "Mermaid preview unavailable"
7780
- }),
7781
- /*#__PURE__*/ (0,jsx_runtime.jsx)(CodeFence, {
7782
- language: "mermaid",
7783
- className: "language-mermaid",
7784
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
7785
- children: source
7786
- })
7787
- })
7788
- ]
7789
- });
7790
- }
7791
- if (!svg) {
7792
- return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7793
- className: "my-2 rounded-md border border-border/60 bg-surface-3/40 p-3 text-xs text-fg-faint",
7794
- children: "Rendering diagram..."
7795
- });
7796
- }
7797
- return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7798
- className: "my-2 max-w-full overflow-x-auto rounded-md border border-border/60 bg-surface-2 p-3",
7799
- dangerouslySetInnerHTML: {
7800
- __html: svg
7801
- },
7802
- role: "img",
7803
- "aria-label": "Mermaid diagram"
7804
- });
7805
- }
7806
- function ContentPartView({ part, isUser, onInAppLink, unverifiedLinks, sourceManifest, threadId }) {
7807
- if (part.type === "text") {
7808
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(MarkdownContent, {
7809
- text: part.text,
7810
- onInAppLink: onInAppLink,
7811
- unverifiedLinks: unverifiedLinks,
7812
- sourceManifest: sourceManifest,
7813
- threadId: threadId
7814
- });
7815
- }
7816
- if (part.type === "image") {
7817
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(ClickableImage, {
7818
- src: `data:${part.media_type};base64,${part.data}`
7819
- });
7820
- }
7821
- if (part.type === "image_ref") {
7822
- // Ref-based image — server-hosted at /api/v1/files/[name]. See ADR-0065.
7823
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(ClickableImage, {
7824
- src: `/api/v1/files/${encodeURIComponent(part.name)}`
7825
- });
7826
- }
7827
- if (part.type === "file_ref") {
7828
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
7829
- href: `/api/v1/files/${encodeURIComponent(part.name)}`,
7830
- target: "_blank",
7831
- rel: "noopener noreferrer",
7832
- className: "inline-flex items-center gap-1.5 px-2.5 py-1.5 mt-1 rounded-lg border border-border/60 bg-surface-3/60 hover:bg-surface-3 hover:border-border text-[11px] text-fg-muted transition-colors",
7833
- title: "Open in new tab",
7834
- children: [
7835
- /*#__PURE__*/ (0,jsx_runtime.jsx)(paperclip/* default */.A, {
7836
- size: 11,
7837
- className: "text-fg-faint shrink-0"
7838
- }),
7839
- /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
7840
- className: "truncate max-w-[200px]",
7841
- children: part.filename
7842
- })
7843
- ]
7844
- });
7845
- }
7846
- // File attachment — render an inline player for audio/video so voice
7847
- // notes and short clips from the WhatsApp bridge are usable in-bubble.
7848
- // Other file types still fall through to a download/open-in-new-tab link.
7849
- const file = part;
7850
- const dataUrl = `data:${file.media_type};base64,${file.data}`;
7851
- // For text files our data field is plain text, not base64. Detect and wrap.
7852
- const href = /^text\/|^application\/json$/.test(file.media_type) ? `data:${file.media_type};charset=utf-8,${encodeURIComponent(file.data)}` : dataUrl;
7853
- if (file.media_type.startsWith("audio/")) {
7854
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7855
- className: "mt-1 max-w-md",
7856
- children: [
7857
- /*#__PURE__*/ (0,jsx_runtime.jsx)("audio", {
7858
- controls: true,
7859
- className: "w-full",
7860
- src: dataUrl
7861
- }),
7862
- /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7863
- className: "mt-0.5 text-[10px] text-fg-faint truncate",
7864
- children: file.name
7865
- })
7866
- ]
7867
- });
7868
- }
7869
- if (file.media_type.startsWith("video/")) {
7870
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7871
- className: "mt-1 max-w-md",
7872
- children: [
7873
- /*#__PURE__*/ (0,jsx_runtime.jsx)("video", {
7874
- controls: true,
7875
- playsInline: true,
7876
- className: "w-full rounded-xl border border-border/40",
7877
- style: {
7878
- maxHeight: "400px"
7879
- },
7880
- src: dataUrl
7881
- }),
7882
- /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7883
- className: "mt-0.5 text-[10px] text-fg-faint truncate",
7884
- children: file.name
7885
- })
7886
- ]
7887
- });
7888
- }
7889
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)("a", {
7890
- href: href,
7891
- target: "_blank",
7892
- rel: "noopener noreferrer",
7893
- className: "inline-flex items-center gap-1.5 px-2.5 py-1.5 mt-1 rounded-lg border border-border/60 bg-surface-3/60 hover:bg-surface-3 hover:border-border text-[11px] text-fg-muted transition-colors",
7894
- title: "Open in new tab",
7895
- children: [
7896
- /*#__PURE__*/ (0,jsx_runtime.jsx)(paperclip/* default */.A, {
7897
- size: 11,
7898
- className: "text-fg-faint shrink-0"
7899
- }),
7900
- /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
7901
- className: "truncate max-w-[200px]",
7902
- children: file.name
7903
- })
7904
- ]
7905
- });
7906
- }
7907
7984
  function hasImageAttachment(content) {
7908
7985
  return Array.isArray(content) && content.some((part)=>part.type === "image" || part.type === "image_ref");
7909
7986
  }
7910
- // Image attachment — thumbnail in the bubble, click for a full-screen lightbox.
7911
- // Accepts either a `data:` URL (inline base64) or a `/api/v1/files/[name]`
7912
- // URL (disk-hosted ref, see ADR-0065). Both render identically.
7913
- function ClickableImage({ src }) {
7914
- const [open, setOpen] = (0,react.useState)(false);
7915
- const [naturalSize, setNaturalSize] = (0,react.useState)(null);
7916
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
7917
- children: [
7918
- /*#__PURE__*/ (0,jsx_runtime.jsx)("img", {
7919
- src: src,
7920
- alt: "attached image",
7921
- onLoad: (e)=>{
7922
- const img = e.currentTarget;
7923
- if (img.naturalWidth > 0 && img.naturalHeight > 0) {
7924
- setNaturalSize({
7925
- width: img.naturalWidth,
7926
- height: img.naturalHeight
7927
- });
7928
- }
7929
- },
7930
- onClick: ()=>setOpen(true),
7931
- className: "block w-full max-w-full rounded-xl mt-1 border border-border/40 cursor-zoom-in hover:border-fg-faint transition-colors",
7932
- style: {
7933
- width: naturalSize ? `min(100%, ${naturalSize.width}px)` : "100%",
7934
- maxHeight: naturalSize ? `min(82dvh, ${naturalSize.height}px)` : "82dvh",
7935
- objectFit: "contain"
7936
- }
7937
- }),
7938
- /*#__PURE__*/ (0,jsx_runtime.jsx)(ImagePreviewDialog, {
7939
- src: src,
7940
- alt: "attached image",
7941
- open: open,
7942
- onClose: ()=>setOpen(false)
7943
- })
7944
- ]
7945
- });
7946
- }
7947
- function ImagePreviewDialog({ src, alt, open, onClose }) {
7948
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(Dialog/* Dialog */.l, {
7949
- open: open,
7950
- onClose: onClose,
7951
- title: "Image preview",
7952
- size: "full",
7953
- align: "center",
7954
- level: "elevated",
7955
- padded: false,
7956
- fitViewport: true,
7957
- footer: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
7958
- className: "flex items-center justify-end gap-2 px-4 pb-3",
7959
- children: [
7960
- /*#__PURE__*/ (0,jsx_runtime.jsx)("a", {
7961
- href: src,
7962
- target: "_blank",
7963
- rel: "noopener noreferrer",
7964
- className: "px-2.5 py-1.5 rounded-md border border-border/70 bg-surface-3 text-xs text-fg-muted hover:text-fg hover:border-border",
7965
- children: "Open in new tab"
7966
- }),
7967
- /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
7968
- type: "button",
7969
- onClick: onClose,
7970
- className: "px-2.5 py-1.5 rounded-md border border-border/70 bg-surface-3 text-xs text-fg-muted hover:text-fg hover:border-border",
7971
- children: "Close"
7972
- })
7973
- ]
7974
- }),
7975
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
7976
- className: "h-full w-full min-w-0 bg-black/95 flex items-center justify-center",
7977
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)("img", {
7978
- src: src,
7979
- alt: alt,
7980
- className: "block max-h-full max-w-full h-auto w-auto object-contain"
7981
- })
7982
- })
7983
- });
7984
- }
7985
7987
  function messageTextForCopy(content) {
7986
7988
  if (typeof content === "string") return content;
7987
7989
  return content.map((part)=>{
@@ -29842,6 +29844,7 @@ async function ping() {
29842
29844
  }
29843
29845
  }
29844
29846
  function ServerStatus() {
29847
+ const [launching, setLaunching] = (0,react.useState)(true);
29845
29848
  const [down, setDown] = (0,react.useState)(false);
29846
29849
  const wasDownRef = (0,react.useRef)(false);
29847
29850
  const failureCountRef = (0,react.useRef)(0);
@@ -29865,6 +29868,7 @@ function ServerStatus() {
29865
29868
  return;
29866
29869
  }
29867
29870
  failureCountRef.current = 0;
29871
+ setLaunching(false);
29868
29872
  if (wasDownRef.current) {
29869
29873
  // Server recovered after the overlay actually showed — full reload
29870
29874
  // to drop any stale in-memory state (EventSource queues, agent
@@ -29889,23 +29893,28 @@ function ServerStatus() {
29889
29893
  document.removeEventListener("visibilitychange", onVisible);
29890
29894
  };
29891
29895
  }, []);
29892
- if (!down) return null;
29896
+ if (!launching && !down) return null;
29893
29897
  return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
29898
+ role: "status",
29899
+ "aria-live": "polite",
29894
29900
  className: "fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm",
29895
29901
  children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
29896
29902
  className: "mx-4 max-w-sm w-full flex flex-col items-center gap-3 rounded-xl border border-border bg-surface text-fg px-6 py-5 text-center shadow-lg",
29897
29903
  children: [
29898
- /*#__PURE__*/ (0,jsx_runtime.jsx)(cloud_off/* default */.A, {
29904
+ down ? /*#__PURE__*/ (0,jsx_runtime.jsx)(cloud_off/* default */.A, {
29899
29905
  size: 28,
29900
29906
  className: "text-amber-500"
29907
+ }) : /*#__PURE__*/ (0,jsx_runtime.jsx)(loader_circle/* default */.A, {
29908
+ size: 28,
29909
+ className: "animate-spin text-fg-muted"
29901
29910
  }),
29902
29911
  /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
29903
29912
  className: "text-sm font-medium",
29904
- children: "Server unavailable"
29913
+ children: down ? "Server unavailable" : "Launching Jarela"
29905
29914
  }),
29906
29915
  /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
29907
29916
  className: "text-xs text-fg-muted",
29908
- children: "Lost connection to Jarela. Retrying…"
29917
+ children: down ? "Cannot connect to Jarela. Retrying..." : "Waiting for the local server..."
29909
29918
  }),
29910
29919
  /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
29911
29920
  className: "flex items-center gap-2 text-xs text-fg-subtle",
@@ -29915,11 +29924,11 @@ function ServerStatus() {
29915
29924
  className: "animate-spin"
29916
29925
  }),
29917
29926
  /*#__PURE__*/ (0,jsx_runtime.jsx)("span", {
29918
- children: "Reconnecting"
29927
+ children: down ? "Reconnecting" : "Starting up"
29919
29928
  })
29920
29929
  ]
29921
29930
  }),
29922
- /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
29931
+ down && /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
29923
29932
  type: "button",
29924
29933
  onClick: ()=>window.location.reload(),
29925
29934
  className: "mt-1 text-xs underline text-fg-subtle hover:text-fg",
@@ -30712,6 +30721,7 @@ function BootScreen({ agents, agentsLoaded, activeAgentId, preferredThreadId, on
30712
30721
  const adoptionTitle = adoption?.is_first_adoption ? `Adopting ${adoption.current_version}` : `Updated to ${adoption?.current_version ?? "new version"}`;
30713
30722
  const adoptionNeedsAttention = adoption?.checklist.some((item)=>item.status === "needs_attention") === true;
30714
30723
  return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
30724
+ "data-testid": "boot-screen",
30715
30725
  role: "status",
30716
30726
  "aria-live": "polite",
30717
30727
  "aria-hidden": dismissing,
@@ -31207,7 +31217,7 @@ function MenuPanel({ activeTab, agentId, agents, onClose, onAgentChange, onSetTa
31207
31217
  }, tab);
31208
31218
  };
31209
31219
  return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
31210
- className: "glass-elevated fixed right-0 bottom-0 w-full sm:w-[26rem] max-w-full border-l border-border/60 z-40 flex flex-col pb-safe",
31220
+ className: "glass-elevated fixed right-0 bottom-0 w-full sm:w-[26rem] max-w-full border-l border-border/60 z-[60] flex flex-col pb-safe",
31211
31221
  style: {
31212
31222
  top: "calc(3rem + var(--app-safe-top))"
31213
31223
  },
@@ -33534,7 +33544,7 @@ function DashboardPanel() {
33534
33544
  const avgDailyCostUsd = data ? data.summary.estimated_cost_usd / Math.max(data.days, 1) : 0;
33535
33545
  const toggleDay = (day)=>setSelectedDay((prev)=>prev === day ? null : day);
33536
33546
  return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
33537
- className: "relative h-full overflow-y-auto p-4 md:p-6 space-y-4",
33547
+ className: "relative h-full overflow-y-auto p-4 md:p-6 space-y-4 [--bg-primary:var(--color-surface)] [--bg-secondary:var(--color-surface-2)] [--text-primary:var(--color-fg)] [--text-secondary:var(--color-fg-muted)] [--border:var(--color-border)] [--accent:var(--color-accent)]",
33538
33548
  children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
33539
33549
  className: "mx-auto max-w-7xl space-y-4",
33540
33550
  children: [
@@ -34244,4 +34254,4 @@ function AppShell() {
34244
34254
  /******/ _N_E = __webpack_exports__;
34245
34255
  /******/ }
34246
34256
  ]);
34247
- //# sourceMappingURL=page-2ef8d75d40eb4311.js.map
34257
+ //# sourceMappingURL=page-4112e14360a9909e.js.map