@tangle-network/agent-app 0.61.4 → 0.62.0

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 (307) hide show
  1. package/dist/{DesignCanvas-L6J72JQ2.js → DesignCanvas-IQKYAEC4.js} +3 -2
  2. package/dist/{DesignCanvasEditor-QFQD63MR.js → DesignCanvasEditor-O7OCZTGC.js} +5 -4
  3. package/dist/{TimelineEditor-7KBPJQLT.js → TimelineEditor-VB2UJ34D.js} +4 -2
  4. package/dist/VaultPane-AYW7CO33.js +8 -0
  5. package/dist/agent-profiles/d1.js +1 -1
  6. package/dist/agent-profiles/index.d.ts +0 -82
  7. package/dist/agent-profiles/index.js +1 -21
  8. package/dist/agent-profiles/self-management.d.ts +0 -55
  9. package/dist/alerting/index.d.ts +1 -1
  10. package/dist/alerting/index.js +1 -3
  11. package/dist/alerting/slack.d.ts +6 -79
  12. package/dist/app-auth/drizzle.d.ts +17 -271
  13. package/dist/app-auth/drizzle.js +6 -2
  14. package/dist/app-auth/drizzle.js.map +1 -1
  15. package/dist/app-auth/index.js +3 -3
  16. package/dist/assets/types.d.ts +2 -1
  17. package/dist/assistant/AssistantPanel.d.ts +1 -1
  18. package/dist/assistant/index.js +635 -392
  19. package/dist/assistant/index.js.map +1 -1
  20. package/dist/billing/identity-locks.d.ts +5 -0
  21. package/dist/billing/index.js +1 -1
  22. package/dist/brand-extraction/index.js.map +1 -1
  23. package/dist/brand-extraction/types.d.ts +2 -1
  24. package/dist/chat-react/index.js +6 -5
  25. package/dist/chat-routes/attachment-write-safety.d.ts +4 -0
  26. package/dist/chat-routes/draft-persistence.d.ts +2 -14
  27. package/dist/chat-routes/index.d.ts +1 -0
  28. package/dist/chat-routes/index.js +853 -773
  29. package/dist/chat-routes/index.js.map +1 -1
  30. package/dist/chat-routes/sandbox-model-source.d.ts +20 -0
  31. package/dist/chat-routes/stored-attachments.d.ts +18 -0
  32. package/dist/chat-routes/turn-admission.d.ts +1 -1
  33. package/dist/chat-routes/turn-execution.d.ts +2 -2
  34. package/dist/chat-routes/turn-route-contracts.d.ts +3 -29
  35. package/dist/chat-store/core.d.ts +19 -1
  36. package/dist/chat-store/index.js.map +1 -1
  37. package/dist/chat-store/store.d.ts +3 -29
  38. package/dist/{chunk-ATQQCG4I.js → chunk-2VJLLRVV.js} +2 -2
  39. package/dist/{chunk-R4X5474U.js → chunk-52SDU43B.js} +12 -27
  40. package/dist/chunk-52SDU43B.js.map +1 -0
  41. package/dist/{chunk-MDRH3SDA.js → chunk-54YIL7WM.js} +3 -3
  42. package/dist/{chunk-6QJ3GB3A.js → chunk-5GSZGTPJ.js} +2 -2
  43. package/dist/{chunk-5IM2CLYX.js → chunk-6JEDSKFH.js} +232 -218
  44. package/dist/chunk-6JEDSKFH.js.map +1 -0
  45. package/dist/{chunk-6PRQ45QE.js → chunk-6OG4244Y.js} +1 -1
  46. package/dist/chunk-6OG4244Y.js.map +1 -0
  47. package/dist/{chunk-ZDPUC6CM.js → chunk-6ZVSMA4T.js} +3 -3
  48. package/dist/{chunk-TXUAGSFR.js → chunk-76MPX7JQ.js} +47 -1
  49. package/dist/chunk-76MPX7JQ.js.map +1 -0
  50. package/dist/{chunk-BOQ4HVVH.js → chunk-7ISHKBAD.js} +61 -52
  51. package/dist/chunk-7ISHKBAD.js.map +1 -0
  52. package/dist/chunk-7PULOECS.js +22 -0
  53. package/dist/chunk-7PULOECS.js.map +1 -0
  54. package/dist/{chunk-KJODHPWM.js → chunk-CPVGRQ43.js} +511 -339
  55. package/dist/chunk-CPVGRQ43.js.map +1 -0
  56. package/dist/{chunk-LO6VQ35O.js → chunk-CQZVJVME.js} +2 -2
  57. package/dist/{chunk-Y43PXON2.js → chunk-EFQUAWWF.js} +577 -546
  58. package/dist/chunk-EFQUAWWF.js.map +1 -0
  59. package/dist/{chunk-FPNZMIAW.js → chunk-ELX5YITO.js} +1 -1
  60. package/dist/chunk-ELX5YITO.js.map +1 -0
  61. package/dist/chunk-FGAROAUF.js +19 -0
  62. package/dist/chunk-FGAROAUF.js.map +1 -0
  63. package/dist/{chunk-HN6MZ2XL.js → chunk-FTNGGR37.js} +641 -466
  64. package/dist/chunk-FTNGGR37.js.map +1 -0
  65. package/dist/{chunk-G4F2NWZH.js → chunk-FZ3ZFVAC.js} +4 -4
  66. package/dist/{chunk-UCCSJX64.js → chunk-GIEUZBQQ.js} +1112 -644
  67. package/dist/chunk-GIEUZBQQ.js.map +1 -0
  68. package/dist/{chunk-MEKOWH5E.js → chunk-IVBREL7A.js} +785 -526
  69. package/dist/chunk-IVBREL7A.js.map +1 -0
  70. package/dist/{chunk-WSEXFTN4.js → chunk-JBXNU5WD.js} +26 -26
  71. package/dist/chunk-JBXNU5WD.js.map +1 -0
  72. package/dist/{chunk-F2VX6TTJ.js → chunk-JRCZHDRG.js} +2 -41
  73. package/dist/chunk-JRCZHDRG.js.map +1 -0
  74. package/dist/{chunk-LXYQOOXU.js → chunk-JRW6LCIA.js} +552 -302
  75. package/dist/chunk-JRW6LCIA.js.map +1 -0
  76. package/dist/{chunk-TVPH5T4F.js → chunk-KS4I7KVC.js} +16 -22
  77. package/dist/{chunk-TVPH5T4F.js.map → chunk-KS4I7KVC.js.map} +1 -1
  78. package/dist/{chunk-J2BBYVGF.js → chunk-MRZP65DZ.js} +1 -117
  79. package/dist/chunk-MRZP65DZ.js.map +1 -0
  80. package/dist/{chunk-4ZSLX3LY.js → chunk-OODZCBSM.js} +1 -1
  81. package/dist/chunk-OODZCBSM.js.map +1 -0
  82. package/dist/chunk-P4RRC4AO.js +47 -0
  83. package/dist/chunk-P4RRC4AO.js.map +1 -0
  84. package/dist/{chunk-ORQD4AUO.js → chunk-PCAY23GS.js} +1 -6
  85. package/dist/chunk-PCAY23GS.js.map +1 -0
  86. package/dist/{chunk-NMZUW6VJ.js → chunk-PEJ5OP5B.js} +3 -3
  87. package/dist/chunk-PEJ5OP5B.js.map +1 -0
  88. package/dist/{chunk-NHYRIM4I.js → chunk-PIPNDZ6H.js} +304 -194
  89. package/dist/chunk-PIPNDZ6H.js.map +1 -0
  90. package/dist/{chunk-L7LQRJGD.js → chunk-TCJ4TMOW.js} +37 -33
  91. package/dist/{chunk-L7LQRJGD.js.map → chunk-TCJ4TMOW.js.map} +1 -1
  92. package/dist/chunk-UHSUY6H6.js +79 -0
  93. package/dist/chunk-UHSUY6H6.js.map +1 -0
  94. package/dist/{chunk-PDD5A43Y.js → chunk-UTL6TEN6.js} +3 -3
  95. package/dist/{chunk-VJBFCNAU.js → chunk-UW2DKTEM.js} +123 -130
  96. package/dist/chunk-UW2DKTEM.js.map +1 -0
  97. package/dist/{chunk-S27DKRI6.js → chunk-VDYEVCQQ.js} +2 -2
  98. package/dist/{chunk-UFQM46NV.js → chunk-VK3F4N4U.js} +2 -2
  99. package/dist/{chunk-6ZIC6OG5.js → chunk-VYBTQK25.js} +126 -122
  100. package/dist/chunk-VYBTQK25.js.map +1 -0
  101. package/dist/{chunk-RL3Z747H.js → chunk-W2BV2XOC.js} +1491 -700
  102. package/dist/chunk-W2BV2XOC.js.map +1 -0
  103. package/dist/{chunk-FUZETA6Z.js → chunk-X6SZGQTK.js} +2 -2
  104. package/dist/{chunk-CD2LQXY6.js → chunk-XOHE6SKU.js} +14 -16
  105. package/dist/{chunk-CD2LQXY6.js.map → chunk-XOHE6SKU.js.map} +1 -1
  106. package/dist/{chunk-ZBB5KQ6B.js → chunk-Y3GO6SG3.js} +73 -66
  107. package/dist/chunk-Y3GO6SG3.js.map +1 -0
  108. package/dist/chunk-ZAMHLXNS.js +56 -0
  109. package/dist/chunk-ZAMHLXNS.js.map +1 -0
  110. package/dist/{chunk-RHFN7TUV.js → chunk-ZDHCV462.js} +47 -44
  111. package/dist/{chunk-RHFN7TUV.js.map → chunk-ZDHCV462.js.map} +1 -1
  112. package/dist/chunk-ZOS3D26Z.js +72 -0
  113. package/dist/chunk-ZOS3D26Z.js.map +1 -0
  114. package/dist/design-canvas/index.js +32 -32
  115. package/dist/design-canvas/index.js.map +1 -1
  116. package/dist/design-canvas-react/components/DesignCanvas.d.ts +1 -1
  117. package/dist/design-canvas-react/components/Workspace.d.ts +1 -1
  118. package/dist/design-canvas-react/components/glyphs.d.ts +31 -40
  119. package/dist/design-canvas-react/components/transform-math.d.ts +0 -8
  120. package/dist/design-canvas-react/components/use-workspace-keyboard.d.ts +2 -2
  121. package/dist/design-canvas-react/contracts.d.ts +2 -2
  122. package/dist/design-canvas-react/engine.js +1 -1
  123. package/dist/design-canvas-react/index.js +9 -7
  124. package/dist/design-canvas-react/index.js.map +1 -1
  125. package/dist/design-canvas-react/lazy.js +1 -1
  126. package/dist/eval/calibration.d.ts +1 -38
  127. package/dist/eval/index.d.ts +2 -4
  128. package/dist/eval/index.js +0 -84
  129. package/dist/eval/index.js.map +1 -1
  130. package/dist/harness/index.d.ts +1 -1
  131. package/dist/harness/index.js +1 -1
  132. package/dist/harness/session-selection.d.ts +2 -2
  133. package/dist/hub-approvals/index.js +1 -1
  134. package/dist/hub-approvals/result.d.ts +1 -1
  135. package/dist/hub-approvals-react/index.js +4 -4
  136. package/dist/hub-approvals-react/index.js.map +1 -1
  137. package/dist/hub-approvals-react/parts.d.ts +1 -1
  138. package/dist/launch-invariants/cli.js +4 -4
  139. package/dist/launch-invariants/index.js +3 -3
  140. package/dist/launch-invariants/testing.js +4 -4
  141. package/dist/legibility/cli.js +1 -1
  142. package/dist/legibility/index.js +1 -1
  143. package/dist/{mention-editor-B23OMFT2.js → mention-editor-4BKBMWIK.js} +83 -57
  144. package/dist/mention-editor-4BKBMWIK.js.map +1 -0
  145. package/dist/missions/index.js +144 -137
  146. package/dist/missions/index.js.map +1 -1
  147. package/dist/operator/index.js +1 -1
  148. package/dist/peer-floors/check.js +1 -1
  149. package/dist/peer-floors/cli.js +6 -14
  150. package/dist/peer-floors/cli.js.map +1 -1
  151. package/dist/peer-floors/source-entries.d.ts +6 -0
  152. package/dist/platform/index.js +10 -10
  153. package/dist/preset-cloudflare/index.js +1 -1
  154. package/dist/profile/index.d.ts +0 -1
  155. package/dist/profile/index.js +1 -422
  156. package/dist/profile/index.js.map +1 -1
  157. package/dist/profile-editor/server.d.ts +0 -1
  158. package/dist/profile-editor/server.js +0 -1
  159. package/dist/profile-editor/server.js.map +1 -1
  160. package/dist/public-consultation/index.d.ts +2 -2
  161. package/dist/public-consultation/index.js +6 -6
  162. package/dist/record/drizzle.js +156 -148
  163. package/dist/record/drizzle.js.map +1 -1
  164. package/dist/runtime/index.js +4 -4
  165. package/dist/runtime/router-turn.js +3 -3
  166. package/dist/sandbox/index.js +5 -5
  167. package/dist/sequences/drizzle.js +5 -15
  168. package/dist/sequences/drizzle.js.map +1 -1
  169. package/dist/sequences/index.d.ts +1 -0
  170. package/dist/sequences/index.js +18 -14
  171. package/dist/sequences/index.js.map +1 -1
  172. package/dist/sequences/row-mapping.d.ts +7 -0
  173. package/dist/sequences-react/components/TimelineEditor.d.ts +0 -40
  174. package/dist/sequences-react/components/TimelineHistory.d.ts +31 -0
  175. package/dist/sequences-react/components/glyphs.d.ts +12 -21
  176. package/dist/sequences-react/components/index.d.ts +0 -2
  177. package/dist/sequences-react/components/interaction-math.d.ts +3 -3
  178. package/dist/sequences-react/contracts.d.ts +1 -1
  179. package/dist/sequences-react/engine/snap.d.ts +2 -2
  180. package/dist/sequences-react/index.js +4 -4
  181. package/dist/sequences-react/index.js.map +1 -1
  182. package/dist/settings-react/index.js +13 -30
  183. package/dist/settings-react/index.js.map +1 -1
  184. package/dist/settings-react/timezone-picker.d.ts +0 -6
  185. package/dist/signoff/browser-budget.d.ts +6 -1
  186. package/dist/signoff/cli.d.ts +0 -7
  187. package/dist/signoff/cli.js +1 -2
  188. package/dist/signoff/cli.js.map +1 -1
  189. package/dist/signoff/index.js +1 -1
  190. package/dist/skills/index.d.ts +1 -1
  191. package/dist/skills/index.js +5 -25
  192. package/dist/skills/marketplace.d.ts +1 -75
  193. package/dist/skills-placement/box.js +3 -4
  194. package/dist/skills-placement/box.js.map +1 -1
  195. package/dist/skills-placement/index.js +3 -4
  196. package/dist/spend/cli-args.d.ts +1 -1
  197. package/dist/spend/cli.js +3 -3
  198. package/dist/spend/cli.js.map +1 -1
  199. package/dist/spend/index.js +1 -1
  200. package/dist/stories/design-canvas/fixtures.d.ts +1 -14
  201. package/dist/stream/index.js +17 -17
  202. package/dist/studio/generation.d.ts +1 -1
  203. package/dist/studio/index.js +1 -1
  204. package/dist/studio-react/index.js +353 -184
  205. package/dist/studio-react/index.js.map +1 -1
  206. package/dist/studio-react/studio-composer.d.ts +1 -5
  207. package/dist/studio-react/studio-history-screen.d.ts +1 -1
  208. package/dist/teams/invitations-api.d.ts +3 -3
  209. package/dist/teams/invitations-api.js +74 -72
  210. package/dist/teams/invitations-api.js.map +1 -1
  211. package/dist/teams/member-sync.d.ts +2 -0
  212. package/dist/teams/members-api.d.ts +2 -2
  213. package/dist/teams/members-api.js +1 -1
  214. package/dist/teams-react/index.js +28 -45
  215. package/dist/teams-react/index.js.map +1 -1
  216. package/dist/tools/index.js +1 -1
  217. package/dist/tools/mcp-arguments.d.ts +1 -1
  218. package/dist/trace/index.d.ts +1 -18
  219. package/dist/trace/index.js +1 -36
  220. package/dist/trace/index.js.map +1 -1
  221. package/dist/trace/mission-flow.d.ts +1 -59
  222. package/dist/turn-health/index.d.ts +1 -1
  223. package/dist/turn-health/index.js +2 -2
  224. package/dist/turn-health/sink.d.ts +2 -1
  225. package/dist/turn-trace/index.js +2 -4
  226. package/dist/turn-trace/recorder.d.ts +0 -2
  227. package/dist/vault/VaultPane.d.ts +0 -20
  228. package/dist/vault/VaultPaneOperations.d.ts +318 -0
  229. package/dist/vault/index.js +2 -1
  230. package/dist/vault/index.js.map +1 -1
  231. package/dist/vault/lazy.js +1 -1
  232. package/dist/web-react/agent-profile-editor.d.ts +1 -2
  233. package/dist/web-react/agent-profile-editor.js +6 -5
  234. package/dist/web-react/chat-composer.d.ts +1 -1
  235. package/dist/web-react/durable-plan-flow.d.ts +6 -1
  236. package/dist/web-react/editor-glyphs.d.ts +12 -0
  237. package/dist/web-react/focus-navigation.d.ts +12 -0
  238. package/dist/web-react/history-controls.d.ts +37 -0
  239. package/dist/web-react/index.js +36 -34
  240. package/dist/web-react/interaction-question-card.d.ts +1 -1
  241. package/dist/web-react/record-grid-writes.d.ts +31 -0
  242. package/dist/web-react/record-grid.d.ts +1 -48
  243. package/dist/web-react/session-history-panel.d.ts +1 -9
  244. package/dist/web-react/use-document-dark.d.ts +1 -0
  245. package/dist/workspace-export/engine.d.ts +1 -6
  246. package/dist/workspace-export/index.js +198 -185
  247. package/dist/workspace-export/index.js.map +1 -1
  248. package/dist/workspace-export/routes.d.ts +1 -1
  249. package/dist/workspace-react/index.js +9 -8
  250. package/dist/workspace-react/index.js.map +1 -1
  251. package/package.json +1 -11
  252. package/dist/VaultPane-RXL3WLA2.js +0 -7
  253. package/dist/agent-profiles/reaper.d.ts +0 -31
  254. package/dist/agent-profiles/reaper.js +0 -29
  255. package/dist/agent-profiles/reaper.js.map +0 -1
  256. package/dist/chunk-4ZSLX3LY.js.map +0 -1
  257. package/dist/chunk-5IM2CLYX.js.map +0 -1
  258. package/dist/chunk-6OSJNJA2.js +0 -251
  259. package/dist/chunk-6OSJNJA2.js.map +0 -1
  260. package/dist/chunk-6PRQ45QE.js.map +0 -1
  261. package/dist/chunk-6ZIC6OG5.js.map +0 -1
  262. package/dist/chunk-BDEBQ4WO.js +0 -38
  263. package/dist/chunk-BDEBQ4WO.js.map +0 -1
  264. package/dist/chunk-BOQ4HVVH.js.map +0 -1
  265. package/dist/chunk-F2VX6TTJ.js.map +0 -1
  266. package/dist/chunk-FPNZMIAW.js.map +0 -1
  267. package/dist/chunk-HN6MZ2XL.js.map +0 -1
  268. package/dist/chunk-J2BBYVGF.js.map +0 -1
  269. package/dist/chunk-KJODHPWM.js.map +0 -1
  270. package/dist/chunk-LTWJYNEC.js +0 -100
  271. package/dist/chunk-LTWJYNEC.js.map +0 -1
  272. package/dist/chunk-LXYQOOXU.js.map +0 -1
  273. package/dist/chunk-MEKOWH5E.js.map +0 -1
  274. package/dist/chunk-NHYRIM4I.js.map +0 -1
  275. package/dist/chunk-NMZUW6VJ.js.map +0 -1
  276. package/dist/chunk-ORQD4AUO.js.map +0 -1
  277. package/dist/chunk-R4X5474U.js.map +0 -1
  278. package/dist/chunk-RL3Z747H.js.map +0 -1
  279. package/dist/chunk-TXUAGSFR.js.map +0 -1
  280. package/dist/chunk-UCCSJX64.js.map +0 -1
  281. package/dist/chunk-VJBFCNAU.js.map +0 -1
  282. package/dist/chunk-WSEXFTN4.js.map +0 -1
  283. package/dist/chunk-Y43PXON2.js.map +0 -1
  284. package/dist/chunk-ZBB5KQ6B.js.map +0 -1
  285. package/dist/eval/parity.d.ts +0 -74
  286. package/dist/mention-editor-B23OMFT2.js.map +0 -1
  287. package/dist/profile/humanizer-skill.d.ts +0 -23
  288. package/dist/profile/humanizer-skill.vendored.d.ts +0 -4
  289. package/dist/sequences-react/components/BrandMark.d.ts +0 -10
  290. package/dist/skills/marketplace-drizzle.d.ts +0 -121
  291. package/dist/skills/marketplace-drizzle.js +0 -34
  292. package/dist/skills/marketplace-drizzle.js.map +0 -1
  293. package/dist/teams-react/components/BrandMark.d.ts +0 -10
  294. /package/dist/{DesignCanvas-L6J72JQ2.js.map → DesignCanvas-IQKYAEC4.js.map} +0 -0
  295. /package/dist/{DesignCanvasEditor-QFQD63MR.js.map → DesignCanvasEditor-O7OCZTGC.js.map} +0 -0
  296. /package/dist/{TimelineEditor-7KBPJQLT.js.map → TimelineEditor-VB2UJ34D.js.map} +0 -0
  297. /package/dist/{VaultPane-RXL3WLA2.js.map → VaultPane-AYW7CO33.js.map} +0 -0
  298. /package/dist/{chunk-ATQQCG4I.js.map → chunk-2VJLLRVV.js.map} +0 -0
  299. /package/dist/{chunk-MDRH3SDA.js.map → chunk-54YIL7WM.js.map} +0 -0
  300. /package/dist/{chunk-6QJ3GB3A.js.map → chunk-5GSZGTPJ.js.map} +0 -0
  301. /package/dist/{chunk-ZDPUC6CM.js.map → chunk-6ZVSMA4T.js.map} +0 -0
  302. /package/dist/{chunk-LO6VQ35O.js.map → chunk-CQZVJVME.js.map} +0 -0
  303. /package/dist/{chunk-G4F2NWZH.js.map → chunk-FZ3ZFVAC.js.map} +0 -0
  304. /package/dist/{chunk-PDD5A43Y.js.map → chunk-UTL6TEN6.js.map} +0 -0
  305. /package/dist/{chunk-S27DKRI6.js.map → chunk-VDYEVCQQ.js.map} +0 -0
  306. /package/dist/{chunk-UFQM46NV.js.map → chunk-VK3F4N4U.js.map} +0 -0
  307. /package/dist/{chunk-FUZETA6Z.js.map → chunk-X6SZGQTK.js.map} +0 -0
@@ -36,10 +36,12 @@ import {
36
36
  textToVideoSibling,
37
37
  userSafeGenerationMessage,
38
38
  validateCustomImageSize
39
- } from "../chunk-6PRQ45QE.js";
39
+ } from "../chunk-6OG4244Y.js";
40
40
  import {
41
+ loadHistoryPage,
42
+ useHistoryControls,
41
43
  useInfiniteScroll
42
- } from "../chunk-BDEBQ4WO.js";
44
+ } from "../chunk-UHSUY6H6.js";
43
45
  import {
44
46
  CheckGlyph,
45
47
  ChevronDown,
@@ -49,7 +51,10 @@ import {
49
51
  POPOVER_SURFACE_ATTR,
50
52
  PopoverSurface,
51
53
  usePopover
52
- } from "../chunk-R4X5474U.js";
54
+ } from "../chunk-52SDU43B.js";
55
+ import {
56
+ containDialogTab
57
+ } from "../chunk-ZAMHLXNS.js";
53
58
  import {
54
59
  ProviderLogo
55
60
  } from "../chunk-RASGKEAL.js";
@@ -922,7 +927,7 @@ function isMediaCatalog(value) {
922
927
  return typeof defaults[type] === "string" && Array.isArray(rows) && rows.every((row) => isRecord(row) && typeof row.id === "string" && Boolean(row.id.trim()) && typeof row.name === "string" && row.type === type && typeof row.status === "string" && ["available", "limited", "unavailable"].includes(row.status) && (row.provider === void 0 || typeof row.provider === "string") && (row.reason === void 0 || typeof row.reason === "string") && (row.options === void 0 || isRecord(row.options)));
923
928
  });
924
929
  }
925
- function StudioComposer({
930
+ function useStudioComposerViewState({
926
931
  workspaceId,
927
932
  onGenerated,
928
933
  variant = "home",
@@ -1065,6 +1070,252 @@ function StudioComposer({
1065
1070
  const referenceSupported = catalogReady && !laneDown && type === "video" && Boolean(imageToVideoSibling(modelId) ?? textToVideoSibling(modelId));
1066
1071
  const modelReady = catalogReady && (Boolean(modelOption) || unlistedSibling) && modelOption?.status !== "unavailable" && !catalogLoading && !catalogError;
1067
1072
  const canSubmit = Boolean(workspaceId) && modelReady && Boolean(prompt.trim()) && !isSubmitting;
1073
+ const {
1074
+ selectModel,
1075
+ chooseModel,
1076
+ setOption,
1077
+ attachReference,
1078
+ removeReference,
1079
+ generate
1080
+ } = createStudioGenerationActions({
1081
+ setSelectedModels,
1082
+ type,
1083
+ referenceImageUrl,
1084
+ setReferenceImageUrl,
1085
+ setOptionValues,
1086
+ modelId,
1087
+ workspaceId,
1088
+ submitLockRef,
1089
+ isSubmitting,
1090
+ prompt,
1091
+ modelReady,
1092
+ setIsSubmitting,
1093
+ setError,
1094
+ values,
1095
+ onGenerated,
1096
+ setPrompt,
1097
+ referenceSupported,
1098
+ audioSupported
1099
+ });
1100
+ const notice = error;
1101
+ const laneLabel = SEGMENTS.find((segment) => segment.type === type).label;
1102
+ const blockedReasons = [...new Set(curatedModels.map((model) => model.reason?.trim()).filter(Boolean))];
1103
+ const sharedBlockReason = curatedModels.every((model) => Boolean(model.reason?.trim())) && blockedReasons.length === 1 ? blockedReasons[0] : void 0;
1104
+ const laneDownMessage = curatedModels.length === 0 ? `No ${laneLabel.toLowerCase()} models are available` : sharedBlockReason ?? `${laneLabel} models are unavailable`;
1105
+ const loadingModels = Boolean(workspaceId) && (catalogLoading || !catalog && !catalogError);
1106
+ const modelStatus = loadingModels ? "Loading media models\u2026" : catalogError ?? (laneDown ? laneDownMessage : null);
1107
+ const showModelMenu = catalogReady && curatedModels.length > 0;
1108
+ const triggerBrand = modelOption?.maker?.trim() || modelOption?.provider;
1109
+ const pickerModels = useMemo2(() => curatedModels.map((model) => pickerModel(model, type)), [curatedModels, type]);
1110
+ const modelDisplayName = laneDown ? "Unavailable" : modelOption?.name || modelId || "Select a model";
1111
+ const modelUnavailable = laneDown || modelOption?.status === "unavailable";
1112
+ const canReloadModels = Boolean(workspaceId) && !loadingModels && Boolean(catalogError || catalogReady && curatedModels.length === 0);
1113
+ const { settingParams, settings } = createStudioGenerationSettings({ type, params, values, options, setOption, modelId });
1114
+ if (audioSupported) {
1115
+ const audioOn = (values.audio ?? audioMeta?.default) === true;
1116
+ settings.splice(Math.min(2, settings.length), 0, {
1117
+ key: "audio",
1118
+ label: "Audio",
1119
+ summary: audioOn ? "Audio on" : "Audio off",
1120
+ value: audioOn,
1121
+ choices: [],
1122
+ onSelect: (next) => setOption("audio", next),
1123
+ onToggle: () => setOption("audio", !audioOn),
1124
+ icon: AudioLines
1125
+ });
1126
+ }
1127
+ function reloadModels() {
1128
+ if (!workspaceId || catalogLoading || catalogPendingRef.current) return;
1129
+ catalogPendingRef.current = true;
1130
+ setCatalogLoading(true);
1131
+ setCatalogRequest((current) => current + 1);
1132
+ }
1133
+ return {
1134
+ variant,
1135
+ className,
1136
+ prompt,
1137
+ setPrompt,
1138
+ generate,
1139
+ modelStatus,
1140
+ laneWarningId,
1141
+ type,
1142
+ loadingModels,
1143
+ canReloadModels,
1144
+ reloadModels,
1145
+ catalogError,
1146
+ setType,
1147
+ bandRef,
1148
+ showModelMenu,
1149
+ laneDown,
1150
+ modelId,
1151
+ chooseModel,
1152
+ pickerModels,
1153
+ laneLabel,
1154
+ modelDisplayName,
1155
+ modelUnavailable,
1156
+ triggerBrand,
1157
+ settings,
1158
+ referenceSupported,
1159
+ referenceImageUrl,
1160
+ attachReference,
1161
+ removeReference,
1162
+ pickReferenceImage,
1163
+ canSubmit,
1164
+ sendTone,
1165
+ notice
1166
+ };
1167
+ }
1168
+ function StudioComposer(props) {
1169
+ const view = useStudioComposerViewState(props);
1170
+ return /* @__PURE__ */ jsx2(StudioComposerView, { ...view });
1171
+ }
1172
+ function StudioComposerView({
1173
+ variant,
1174
+ className,
1175
+ prompt,
1176
+ setPrompt,
1177
+ generate,
1178
+ modelStatus,
1179
+ laneWarningId,
1180
+ type,
1181
+ loadingModels,
1182
+ canReloadModels,
1183
+ reloadModels,
1184
+ catalogError,
1185
+ setType,
1186
+ bandRef,
1187
+ showModelMenu,
1188
+ laneDown,
1189
+ modelId,
1190
+ chooseModel,
1191
+ pickerModels,
1192
+ laneLabel,
1193
+ modelDisplayName,
1194
+ modelUnavailable,
1195
+ triggerBrand,
1196
+ settings,
1197
+ referenceSupported,
1198
+ referenceImageUrl,
1199
+ attachReference,
1200
+ removeReference,
1201
+ pickReferenceImage,
1202
+ canSubmit,
1203
+ sendTone,
1204
+ notice
1205
+ }) {
1206
+ return /* @__PURE__ */ jsxs2(
1207
+ "section",
1208
+ {
1209
+ "data-variant": variant,
1210
+ className: `studio-composer-card @container/studio-composer rounded-2xl border bg-[var(--well,var(--color-card))] p-2.5 shadow-raised transition ${focusFieldWithin} ${className ?? ""}`,
1211
+ children: [
1212
+ /* @__PURE__ */ jsx2(
1213
+ "textarea",
1214
+ {
1215
+ value: prompt,
1216
+ onChange: (event) => setPrompt(event.target.value),
1217
+ onKeyDown: (event) => {
1218
+ if (event.key !== "Enter" || event.shiftKey) return;
1219
+ event.preventDefault();
1220
+ void generate();
1221
+ },
1222
+ rows: 3,
1223
+ "aria-label": "Prompt",
1224
+ "aria-describedby": modelStatus ? laneWarningId : void 0,
1225
+ placeholder: type === "speech" ? "Write the words to speak\u2026" : `Describe the ${type} you want to create\u2026`,
1226
+ className: "block min-h-[66px] w-full resize-none border-0 bg-transparent px-1.5 pb-1 pt-1.5 text-[14.5px] leading-relaxed outline-none placeholder:text-muted-foreground"
1227
+ }
1228
+ ),
1229
+ modelStatus && /* @__PURE__ */ jsxs2("div", { id: laneWarningId, role: "status", className: "flex flex-wrap items-center gap-2 px-1.5 pb-3 pt-1.5 text-[14px] text-muted-foreground", children: [
1230
+ /* @__PURE__ */ jsxs2("span", { className: "flex min-w-0 max-w-full items-start gap-2", children: [
1231
+ !loadingModels && /* @__PURE__ */ jsx2(TriangleAlert, { "aria-hidden": true, className: "mt-0.5 h-4 w-4 shrink-0 text-warning", strokeWidth: 2 }),
1232
+ /* @__PURE__ */ jsx2("span", { className: "min-w-0", children: modelStatus })
1233
+ ] }),
1234
+ canReloadModels && /* @__PURE__ */ jsx2("button", { type: "button", onClick: reloadModels, className: "rounded-md px-1 font-medium text-foreground underline underline-offset-4 hover:decoration-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring", children: catalogError ? "Retry models" : "Refresh models" })
1235
+ ] }),
1236
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-wrap items-center gap-2 @[640px]/studio-composer:flex-nowrap", children: [
1237
+ /* @__PURE__ */ jsx2(MediaTypeSegments, { value: type, segments: SEGMENTS, onChange: setType }),
1238
+ /* @__PURE__ */ jsxs2(ComposerBand, { bandRef, resetKey: type, children: [
1239
+ showModelMenu && /* @__PURE__ */ jsx2("div", { className: "flex-none", children: /* @__PURE__ */ jsx2(
1240
+ ModelPicker,
1241
+ {
1242
+ value: laneDown ? "" : textToVideoSibling(modelId) ?? modelId,
1243
+ onChange: chooseModel,
1244
+ models: pickerModels,
1245
+ priorityGroup: { label: `${laneLabel} models`, match: () => true },
1246
+ "aria-label": `Model: ${modelDisplayName}${modelUnavailable ? " (unavailable)" : ""}`,
1247
+ triggerContent: /* @__PURE__ */ jsxs2("span", { className: "contents", children: [
1248
+ modelUnavailable && /* @__PURE__ */ jsx2(TriangleAlert, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-warning", strokeWidth: 2 }),
1249
+ !laneDown && triggerBrand && /* @__PURE__ */ jsx2("span", { className: "shrink-0", "aria-hidden": true, children: /* @__PURE__ */ jsx2(ProviderLogo, { provider: triggerBrand, size: 16 }) }),
1250
+ /* @__PURE__ */ jsx2("span", { className: "max-w-[160px] truncate leading-normal", children: modelDisplayName })
1251
+ ] })
1252
+ }
1253
+ ) }),
1254
+ settings.length > 0 && /* @__PURE__ */ jsx2("div", { className: "studio-pill-in flex-none", children: /* @__PURE__ */ jsx2(GenerationSettings, { settings, bandRef, resetKey: `${type}:${modelId}` }) }),
1255
+ referenceSupported && /* @__PURE__ */ jsx2("div", { className: "studio-pill-in flex-none", children: /* @__PURE__ */ jsx2(
1256
+ ReferencePill,
1257
+ {
1258
+ url: referenceImageUrl,
1259
+ onAttach: attachReference,
1260
+ onRemove: removeReference,
1261
+ pick: pickReferenceImage,
1262
+ bandRef
1263
+ }
1264
+ ) }, `${type}-reference`)
1265
+ ] }),
1266
+ /* @__PURE__ */ jsx2(
1267
+ "button",
1268
+ {
1269
+ type: "button",
1270
+ "aria-label": "Generate",
1271
+ title: "Generate",
1272
+ disabled: !canSubmit,
1273
+ onClick: () => void generate(),
1274
+ className: `ml-auto inline-flex h-8 w-8 flex-none items-center justify-center rounded-full ${sendTone === "primary" ? "bg-primary text-primary-foreground" : "bg-foreground text-background"} transition ${sendTone === "primary" ? "hover:bg-primary/90" : "hover:opacity-90"} disabled:cursor-not-allowed disabled:opacity-40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-card`,
1275
+ children: /* @__PURE__ */ jsx2(ArrowUp, { className: "h-4 w-4", strokeWidth: 2 })
1276
+ }
1277
+ )
1278
+ ] }),
1279
+ notice && /* @__PURE__ */ jsx2("p", { className: "px-1.5 pt-1.5 text-[14px] text-destructive", children: notice })
1280
+ ]
1281
+ }
1282
+ );
1283
+ }
1284
+ function asText(value) {
1285
+ return typeof value === "string" ? value : typeof value === "number" ? String(value) : void 0;
1286
+ }
1287
+ function asWireScalar(value) {
1288
+ return typeof value === "string" || typeof value === "number" ? value : void 0;
1289
+ }
1290
+ function choicesForSetting(param, meta, value) {
1291
+ if (!meta) return [];
1292
+ const choices = choicesFor(param, meta).map((choice) => ({
1293
+ value: choice,
1294
+ label: optionValueLabel(param, choice)
1295
+ }));
1296
+ if (value === void 0 || choices.some((choice) => choice.value === value)) return choices;
1297
+ return [...choices, { value, label: `${optionValueLabel(param, value)} \xB7 custom` }];
1298
+ }
1299
+ function createStudioGenerationActions({
1300
+ setSelectedModels,
1301
+ type,
1302
+ referenceImageUrl,
1303
+ setReferenceImageUrl,
1304
+ setOptionValues,
1305
+ modelId,
1306
+ workspaceId,
1307
+ submitLockRef,
1308
+ isSubmitting,
1309
+ prompt,
1310
+ modelReady,
1311
+ setIsSubmitting,
1312
+ setError,
1313
+ values,
1314
+ onGenerated,
1315
+ setPrompt,
1316
+ referenceSupported,
1317
+ audioSupported
1318
+ }) {
1068
1319
  function selectModel(id) {
1069
1320
  setSelectedModels((current) => ({ ...current, [type]: id }));
1070
1321
  }
@@ -1164,19 +1415,16 @@ function StudioComposer({
1164
1415
  setIsSubmitting(false);
1165
1416
  }
1166
1417
  }
1167
- const notice = error;
1168
- const laneLabel = SEGMENTS.find((segment) => segment.type === type).label;
1169
- const blockedReasons = [...new Set(curatedModels.map((model) => model.reason?.trim()).filter(Boolean))];
1170
- const sharedBlockReason = curatedModels.every((model) => Boolean(model.reason?.trim())) && blockedReasons.length === 1 ? blockedReasons[0] : void 0;
1171
- const laneDownMessage = curatedModels.length === 0 ? `No ${laneLabel.toLowerCase()} models are available` : sharedBlockReason ?? `${laneLabel} models are unavailable`;
1172
- const loadingModels = Boolean(workspaceId) && (catalogLoading || !catalog && !catalogError);
1173
- const modelStatus = loadingModels ? "Loading media models\u2026" : catalogError ?? (laneDown ? laneDownMessage : null);
1174
- const showModelMenu = catalogReady && curatedModels.length > 0;
1175
- const triggerBrand = modelOption?.maker?.trim() || modelOption?.provider;
1176
- const pickerModels = useMemo2(() => curatedModels.map((model) => pickerModel(model, type)), [curatedModels, type]);
1177
- const modelDisplayName = laneDown ? "Unavailable" : modelOption?.name || modelId || "Select a model";
1178
- const modelUnavailable = laneDown || modelOption?.status === "unavailable";
1179
- const canReloadModels = Boolean(workspaceId) && !loadingModels && Boolean(catalogError || catalogReady && curatedModels.length === 0);
1418
+ return { selectModel, chooseModel, setOption, attachReference, removeReference, generate };
1419
+ }
1420
+ function createStudioGenerationSettings({
1421
+ type,
1422
+ params,
1423
+ values,
1424
+ options,
1425
+ setOption,
1426
+ modelId
1427
+ }) {
1180
1428
  const settingParams = type === "video" ? ["aspect_ratio", "duration", ...params.filter((param) => param !== "aspect_ratio" && param !== "duration")].filter((param) => params.includes(param)) : params;
1181
1429
  const settings = settingParams.map((param) => {
1182
1430
  const value = values[param] ?? options?.[param]?.default;
@@ -1208,117 +1456,7 @@ function StudioComposer({
1208
1456
  } : {}
1209
1457
  };
1210
1458
  });
1211
- if (audioSupported) {
1212
- const audioOn = (values.audio ?? audioMeta?.default) === true;
1213
- settings.splice(Math.min(2, settings.length), 0, {
1214
- key: "audio",
1215
- label: "Audio",
1216
- summary: audioOn ? "Audio on" : "Audio off",
1217
- value: audioOn,
1218
- choices: [],
1219
- onSelect: (next) => setOption("audio", next),
1220
- onToggle: () => setOption("audio", !audioOn),
1221
- icon: AudioLines
1222
- });
1223
- }
1224
- function reloadModels() {
1225
- if (!workspaceId || catalogLoading || catalogPendingRef.current) return;
1226
- catalogPendingRef.current = true;
1227
- setCatalogLoading(true);
1228
- setCatalogRequest((current) => current + 1);
1229
- }
1230
- return /* @__PURE__ */ jsxs2(
1231
- "section",
1232
- {
1233
- "data-variant": variant,
1234
- className: `studio-composer-card @container/studio-composer rounded-2xl border bg-[var(--well,var(--color-card))] p-2.5 shadow-raised transition ${focusFieldWithin} ${className ?? ""}`,
1235
- children: [
1236
- /* @__PURE__ */ jsx2(
1237
- "textarea",
1238
- {
1239
- value: prompt,
1240
- onChange: (event) => setPrompt(event.target.value),
1241
- onKeyDown: (event) => {
1242
- if (event.key !== "Enter" || event.shiftKey) return;
1243
- event.preventDefault();
1244
- void generate();
1245
- },
1246
- rows: 3,
1247
- "aria-label": "Prompt",
1248
- "aria-describedby": modelStatus ? laneWarningId : void 0,
1249
- placeholder: type === "speech" ? "Write the words to speak\u2026" : `Describe the ${type} you want to create\u2026`,
1250
- className: "block min-h-[66px] w-full resize-none border-0 bg-transparent px-1.5 pb-1 pt-1.5 text-[14.5px] leading-relaxed outline-none placeholder:text-muted-foreground"
1251
- }
1252
- ),
1253
- modelStatus && /* @__PURE__ */ jsxs2("div", { id: laneWarningId, role: "status", className: "flex flex-wrap items-center gap-2 px-1.5 pb-3 pt-1.5 text-[14px] text-muted-foreground", children: [
1254
- /* @__PURE__ */ jsxs2("span", { className: "flex min-w-0 max-w-full items-start gap-2", children: [
1255
- !loadingModels && /* @__PURE__ */ jsx2(TriangleAlert, { "aria-hidden": true, className: "mt-0.5 h-4 w-4 shrink-0 text-warning", strokeWidth: 2 }),
1256
- /* @__PURE__ */ jsx2("span", { className: "min-w-0", children: modelStatus })
1257
- ] }),
1258
- canReloadModels && /* @__PURE__ */ jsx2("button", { type: "button", onClick: reloadModels, className: "rounded-md px-1 font-medium text-foreground underline underline-offset-4 hover:decoration-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring", children: catalogError ? "Retry models" : "Refresh models" })
1259
- ] }),
1260
- /* @__PURE__ */ jsxs2("div", { className: "flex flex-wrap items-center gap-2 @[640px]/studio-composer:flex-nowrap", children: [
1261
- /* @__PURE__ */ jsx2(MediaTypeSegments, { value: type, segments: SEGMENTS, onChange: setType }),
1262
- /* @__PURE__ */ jsxs2(ComposerBand, { bandRef, resetKey: type, children: [
1263
- showModelMenu && /* @__PURE__ */ jsx2("div", { className: "flex-none", children: /* @__PURE__ */ jsx2(
1264
- ModelPicker,
1265
- {
1266
- value: laneDown ? "" : textToVideoSibling(modelId) ?? modelId,
1267
- onChange: chooseModel,
1268
- models: pickerModels,
1269
- priorityGroup: { label: `${laneLabel} models`, match: () => true },
1270
- "aria-label": `Model: ${modelDisplayName}${modelUnavailable ? " (unavailable)" : ""}`,
1271
- triggerContent: /* @__PURE__ */ jsxs2("span", { className: "contents", children: [
1272
- modelUnavailable && /* @__PURE__ */ jsx2(TriangleAlert, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-warning", strokeWidth: 2 }),
1273
- !laneDown && triggerBrand && /* @__PURE__ */ jsx2("span", { className: "shrink-0", "aria-hidden": true, children: /* @__PURE__ */ jsx2(ProviderLogo, { provider: triggerBrand, size: 16 }) }),
1274
- /* @__PURE__ */ jsx2("span", { className: "max-w-[160px] truncate leading-normal", children: modelDisplayName })
1275
- ] })
1276
- }
1277
- ) }),
1278
- settings.length > 0 && /* @__PURE__ */ jsx2("div", { className: "studio-pill-in flex-none", children: /* @__PURE__ */ jsx2(GenerationSettings, { settings, bandRef, resetKey: `${type}:${modelId}` }) }),
1279
- referenceSupported && /* @__PURE__ */ jsx2("div", { className: "studio-pill-in flex-none", children: /* @__PURE__ */ jsx2(
1280
- ReferencePill,
1281
- {
1282
- url: referenceImageUrl,
1283
- onAttach: attachReference,
1284
- onRemove: removeReference,
1285
- pick: pickReferenceImage,
1286
- bandRef
1287
- }
1288
- ) }, `${type}-reference`)
1289
- ] }),
1290
- /* @__PURE__ */ jsx2(
1291
- "button",
1292
- {
1293
- type: "button",
1294
- "aria-label": "Generate",
1295
- title: "Generate",
1296
- disabled: !canSubmit,
1297
- onClick: () => void generate(),
1298
- className: `ml-auto inline-flex h-8 w-8 flex-none items-center justify-center rounded-full ${sendTone === "primary" ? "bg-primary text-primary-foreground" : "bg-foreground text-background"} transition ${sendTone === "primary" ? "hover:bg-primary/90" : "hover:opacity-90"} disabled:cursor-not-allowed disabled:opacity-40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-card`,
1299
- children: /* @__PURE__ */ jsx2(ArrowUp, { className: "h-4 w-4", strokeWidth: 2 })
1300
- }
1301
- )
1302
- ] }),
1303
- notice && /* @__PURE__ */ jsx2("p", { className: "px-1.5 pt-1.5 text-[14px] text-destructive", children: notice })
1304
- ]
1305
- }
1306
- );
1307
- }
1308
- function asText(value) {
1309
- return typeof value === "string" ? value : typeof value === "number" ? String(value) : void 0;
1310
- }
1311
- function asWireScalar(value) {
1312
- return typeof value === "string" || typeof value === "number" ? value : void 0;
1313
- }
1314
- function choicesForSetting(param, meta, value) {
1315
- if (!meta) return [];
1316
- const choices = choicesFor(param, meta).map((choice) => ({
1317
- value: choice,
1318
- label: optionValueLabel(param, choice)
1319
- }));
1320
- if (value === void 0 || choices.some((choice) => choice.value === value)) return choices;
1321
- return [...choices, { value, label: `${optionValueLabel(param, value)} \xB7 custom` }];
1459
+ return { settingParams, settings };
1322
1460
  }
1323
1461
 
1324
1462
  // src/studio-react/generation-notice.tsx
@@ -2387,21 +2525,7 @@ function StudioConfirmDialog({
2387
2525
  onCancel();
2388
2526
  return;
2389
2527
  }
2390
- if (event.key !== "Tab") return;
2391
- const focusable = panelRef.current?.querySelectorAll(
2392
- 'button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
2393
- );
2394
- if (!focusable || focusable.length === 0) return;
2395
- const first = focusable[0];
2396
- const last = focusable[focusable.length - 1];
2397
- const active = document.activeElement;
2398
- if (event.shiftKey && active === first) {
2399
- event.preventDefault();
2400
- last?.focus();
2401
- } else if (!event.shiftKey && active === last) {
2402
- event.preventDefault();
2403
- first?.focus();
2404
- }
2528
+ containDialogTab(event, panelRef.current);
2405
2529
  }
2406
2530
  return createPortal2(
2407
2531
  /* @__PURE__ */ jsx8(
@@ -3142,50 +3266,26 @@ function useGenerationHistory({
3142
3266
  loadingMoreRef.current = true;
3143
3267
  lastOpRef.current = "more";
3144
3268
  setPhase("loadingMore");
3145
- void (async () => {
3146
- try {
3147
- const page = await current.fetchPage({
3148
- q: current.q.trim(),
3149
- type: current.type,
3150
- cursor,
3151
- signal: controller.signal
3152
- });
3153
- if (seq !== seqRef.current) return;
3269
+ void loadHistoryPage(
3270
+ () => current.fetchPage({
3271
+ q: current.q.trim(),
3272
+ type: current.type,
3273
+ cursor,
3274
+ signal: controller.signal
3275
+ }),
3276
+ (page) => {
3154
3277
  setItems((previous) => mergeGenerationPages(previous, page.items));
3155
3278
  setNextCursor(page.nextCursor ?? null);
3156
- setPhase("idle");
3157
- } catch {
3158
- if (controller.signal.aborted || seq !== seqRef.current) return;
3159
- setPhase("error");
3160
- } finally {
3161
- if (seq === seqRef.current) loadingMoreRef.current = false;
3162
- }
3163
- })();
3164
- }, []);
3165
- const retry = useCallback11(() => {
3166
- if (lastOpRef.current === "more") loadMore();
3167
- else setReloadKey((key) => key + 1);
3168
- }, [loadMore]);
3169
- const reload = useCallback11(() => {
3170
- setReloadKey((key) => key + 1);
3279
+ },
3280
+ { controller, seq, seqRef, setPhase, onSettled: () => {
3281
+ loadingMoreRef.current = false;
3282
+ } }
3283
+ );
3171
3284
  }, []);
3172
- useEffect13(
3173
- () => () => {
3174
- resetAbortRef.current?.abort();
3175
- loadMoreAbortRef.current?.abort();
3176
- },
3177
- []
3285
+ return useHistoryControls(
3286
+ { items, nextCursor, phase, loadMore },
3287
+ { lastOpRef, setReloadKey, resetAbortRef, loadMoreAbortRef }
3178
3288
  );
3179
- return {
3180
- items,
3181
- hasMore: nextCursor !== null,
3182
- isLoadingFirst: phase === "loadingFirst",
3183
- isLoadingMore: phase === "loadingMore",
3184
- isError: phase === "error",
3185
- loadMore,
3186
- retry,
3187
- reload
3188
- };
3189
3289
  }
3190
3290
 
3191
3291
  // src/studio-react/studio-history-screen.tsx
@@ -3217,7 +3317,7 @@ function skeletonCells(count, keyPrefix) {
3217
3317
  function hasOpenPopover2() {
3218
3318
  return typeof document !== "undefined" && document.querySelector(`[${POPOVER_SURFACE_ATTR}]`) !== null;
3219
3319
  }
3220
- function StudioHistoryScreen({
3320
+ function useStudioHistoryScreenViewState({
3221
3321
  fetchPage,
3222
3322
  initialPage,
3223
3323
  onBack,
@@ -3346,6 +3446,75 @@ function StudioHistoryScreen({
3346
3446
  title: "Your history is empty.",
3347
3447
  body: "Everything you generate is kept here until you delete it."
3348
3448
  };
3449
+ return {
3450
+ className,
3451
+ selectMode,
3452
+ exitSelectMode,
3453
+ selected,
3454
+ batchDownload,
3455
+ actions,
3456
+ savePopover,
3457
+ setSaveOpen,
3458
+ saveOpen,
3459
+ selectedRows,
3460
+ batchSave,
3461
+ savePending,
3462
+ setConfirmTargets,
3463
+ onBack,
3464
+ query,
3465
+ setQuery,
3466
+ type,
3467
+ setType,
3468
+ history,
3469
+ rows,
3470
+ emptyCopy,
3471
+ isFiltered,
3472
+ clearFilters,
3473
+ setViewer,
3474
+ toggleSelect,
3475
+ onSaved,
3476
+ sentinelRef,
3477
+ viewerRow,
3478
+ confirmTargets,
3479
+ confirmDelete
3480
+ };
3481
+ }
3482
+ function StudioHistoryScreen(props) {
3483
+ const view = useStudioHistoryScreenViewState(props);
3484
+ return /* @__PURE__ */ jsx12(StudioHistoryScreenView, { ...view });
3485
+ }
3486
+ function StudioHistoryScreenView({
3487
+ className,
3488
+ selectMode,
3489
+ exitSelectMode,
3490
+ selected,
3491
+ batchDownload,
3492
+ actions,
3493
+ savePopover,
3494
+ setSaveOpen,
3495
+ saveOpen,
3496
+ selectedRows,
3497
+ batchSave,
3498
+ savePending,
3499
+ setConfirmTargets,
3500
+ onBack,
3501
+ query,
3502
+ setQuery,
3503
+ type,
3504
+ setType,
3505
+ history,
3506
+ rows,
3507
+ emptyCopy,
3508
+ isFiltered,
3509
+ clearFilters,
3510
+ setViewer,
3511
+ toggleSelect,
3512
+ onSaved,
3513
+ sentinelRef,
3514
+ viewerRow,
3515
+ confirmTargets,
3516
+ confirmDelete
3517
+ }) {
3349
3518
  return /* @__PURE__ */ jsxs11("div", { className: `studio-hist-wrap pb-[72px] ${className ?? ""}`, children: [
3350
3519
  selectMode ? /* @__PURE__ */ jsxs11("div", { className: BAR, children: [
3351
3520
  /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 text-[13.5px] font-medium", children: [