@uniqbit/mate-core 1.0.0-canary.6 → 1.0.0-canary.8

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 (249) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/package.json +6 -3
  3. package/src/cli/commands/artifact/delivery/submit.ts +6 -4
  4. package/src/cli/commands/artifact/finish/command.ts +28 -11
  5. package/src/cli/commands/artifact/pending/command.ts +71 -7
  6. package/src/cli/commands/cap/tokensave.ts +2 -2
  7. package/src/cli/commands/companion/update.ts +2 -3
  8. package/src/cli/commands/doctor.ts +67 -4
  9. package/src/cli/commands/friction.ts +558 -0
  10. package/src/cli/commands/install.ts +8 -4
  11. package/src/cli/commands/plugin/install.ts +82 -35
  12. package/src/cli/commands/studio/connection.ts +53 -0
  13. package/src/cli/commands/studio/routes.ts +3 -0
  14. package/src/cli/commands/studio/selection.ts +10 -1
  15. package/src/cli/commands/studio/server.ts +31 -0
  16. package/src/cli/commands/studio/service-host.ts +3 -0
  17. package/src/cli/commands/studio/services.ts +25 -0
  18. package/src/cli/commands/triage.ts +172 -0
  19. package/src/cli/commands/vscode/release-vsix.json +2 -2
  20. package/src/cli/install-plan.tsx +3 -0
  21. package/src/cli/main.ts +85 -19
  22. package/src/cli/plugin-commands.ts +6 -1
  23. package/src/cli/usage.ts +12 -2
  24. package/src/create-mate.ts +11 -5
  25. package/src/distribution.ts +2 -0
  26. package/src/factory-host.ts +6 -0
  27. package/src/hooks/validate-artifact-path.ts +64 -14
  28. package/src/index.ts +1 -0
  29. package/src/lib/delivery/merge-git.ts +31 -7
  30. package/src/lib/delivery/overlap.ts +14 -1
  31. package/src/lib/delivery/repository-access.ts +11 -6
  32. package/src/lib/delivery/staging/apply-chain.ts +25 -7
  33. package/src/lib/delivery/staging/linked-merges.ts +175 -0
  34. package/src/lib/delivery/staging/naming.ts +3 -0
  35. package/src/lib/delivery/staging/openspec-type.ts +38 -7
  36. package/src/lib/delivery/staging/pending.ts +153 -11
  37. package/src/lib/delivery/staging/preflight.ts +239 -0
  38. package/src/lib/delivery/staging/project.ts +243 -104
  39. package/src/lib/delivery/staging/replay.ts +5 -3
  40. package/src/lib/delivery/staging/settle-linked.ts +5 -119
  41. package/src/lib/delivery/staging/submit.ts +139 -18
  42. package/src/lib/delivery/submit-change.ts +163 -37
  43. package/src/lib/friction/describe.ts +42 -0
  44. package/src/lib/friction/fields.ts +60 -0
  45. package/src/lib/friction/mark.ts +194 -0
  46. package/src/lib/friction/view/model.ts +67 -0
  47. package/src/lib/friction/view/read.ts +145 -0
  48. package/src/lib/friction/view/select.ts +54 -0
  49. package/src/lib/openspec-cli.ts +10 -5
  50. package/src/lib/orchestrator/adapters/claude.ts +5 -4
  51. package/src/lib/orchestrator/adapters/opencode.ts +2 -0
  52. package/src/lib/orchestrator/root-context.ts +23 -6
  53. package/src/lib/package-paths.ts +23 -15
  54. package/src/lib/session-attribution.ts +3 -7
  55. package/src/lib/skills-cli.ts +38 -0
  56. package/src/lib/tool-manifest.ts +73 -0
  57. package/src/lib/triage/context.ts +312 -0
  58. package/src/lib/triage/launch.ts +52 -0
  59. package/src/lib/triage/prepare.ts +112 -0
  60. package/src/lib/triage/session.ts +126 -0
  61. package/src/opencode/companion-hooks.ts +53 -5
  62. package/src/opencode/projected-guidance.ts +2 -0
  63. package/src/playbooks/companion-guidance.ts +2 -2
  64. package/src/plugin-api.ts +6 -0
  65. package/src/runtime/command-arg.ts +15 -0
  66. package/src/runtime/command-friction.ts +97 -0
  67. package/src/runtime/companion-guidance.ts +33 -16
  68. package/src/runtime/friction-fingerprint.ts +35 -0
  69. package/src/runtime/friction-log.ts +376 -0
  70. package/src/runtime/friction-recorder.ts +212 -0
  71. package/src/runtime/friction-retention.ts +1 -0
  72. package/src/runtime/friction-state.ts +110 -0
  73. package/src/runtime/friction-switch.ts +26 -0
  74. package/src/runtime/friction-vocabulary.ts +42 -0
  75. package/src/runtime/git-tracked.ts +13 -2
  76. package/src/runtime/projected-guidance.ts +2 -1
  77. package/src/runtime/secret-values.ts +16 -0
  78. package/src/runtime/session-id.ts +24 -0
  79. package/src/runtime/session-prepare-runner.ts +3 -0
  80. package/src/runtime/workflow/next-handoff-process.ts +2 -1
  81. package/src/studio.ts +47 -1
  82. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +5 -1
  83. package/src/templates/capabilities/react-doctor/mate-react-doctor/SKILL.md +28 -0
  84. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +42 -4
  85. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +27 -2
  86. package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +23 -1
  87. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +26 -1
  88. package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +28 -0
  89. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +28 -3
  90. package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +28 -0
  91. package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +28 -0
  92. package/src/templates/mate-skills/agents/mate-grilling/SKILL.md +25 -0
  93. package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +28 -0
  94. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +28 -3
  95. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +28 -6
  96. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +27 -2
  97. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +28 -0
  98. package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +24 -2
  99. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +42 -4
  100. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +27 -2
  101. package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +23 -1
  102. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +26 -1
  103. package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +28 -0
  104. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +28 -3
  105. package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +28 -0
  106. package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +28 -0
  107. package/src/templates/mate-skills/claude/mate-grilling/SKILL.md +25 -0
  108. package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +28 -0
  109. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +28 -3
  110. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +28 -6
  111. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +27 -2
  112. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +28 -0
  113. package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +24 -2
  114. package/src/templates/triage/PLAYBOOK.md +120 -0
  115. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +108 -108
  116. package/src/tools/setup/capabilities/graphify.ts +23 -1
  117. package/src/tools/setup/capabilities/rtk.ts +46 -94
  118. package/src/tools/setup/capabilities/tokensave.ts +76 -54
  119. package/src/tools/setup/dynamic-plugins/audiences.ts +28 -14
  120. package/src/tools/setup/dynamic-plugins/hydrate.ts +32 -14
  121. package/src/tools/setup/dynamic-plugins/install.ts +2 -0
  122. package/src/tools/setup/dynamic-plugins/installed.ts +73 -0
  123. package/src/tools/setup/dynamic-plugins/loader.ts +12 -10
  124. package/src/tools/setup/dynamic-plugins/local.ts +492 -0
  125. package/src/tools/setup/dynamic-plugins/paths.ts +34 -6
  126. package/src/tools/setup/dynamic-plugins/verify.ts +34 -14
  127. package/src/tools/setup/dynamic-plugins/workspaces.ts +17 -8
  128. package/src/tools/setup/mate.ts +26 -1
  129. package/src/tools/setup/plugin.ts +5 -0
  130. package/src/tools/setup/plugins/gitignore.ts +45 -12
  131. package/src/tools/setup/service.ts +12 -0
  132. package/src/tools/setup/utils.ts +10 -1
  133. package/src/tools/setup.ts +16 -2
  134. package/studio-dist/client/assets/app-ggXJ_QVh.css +2 -0
  135. package/studio-dist/client/assets/button-amJ3g5oD.js +1 -0
  136. package/studio-dist/client/assets/cn-BQPKiwI4.js +1 -0
  137. package/studio-dist/client/assets/combobox-CJ7aGFid.js +1 -0
  138. package/studio-dist/client/assets/{companion-view-BVaZNtiI.js → companion-view-C_N237bf.js} +1 -1
  139. package/studio-dist/client/assets/fields-BAiGkJ5N.js +1 -0
  140. package/studio-dist/client/assets/friction-DqOU59v7.js +1 -0
  141. package/studio-dist/client/assets/getting-started-djaQeWlu.js +1 -0
  142. package/studio-dist/client/assets/getting-started-yp42dj5S.js +1 -0
  143. package/studio-dist/client/assets/getting-started._topic-C9zVXz_m.js +1 -0
  144. package/studio-dist/client/assets/getting-started.index-DWbDKICP.js +1 -0
  145. package/studio-dist/client/assets/graph-BYaD_5Bq.js +2 -0
  146. package/studio-dist/client/assets/{graph-canvas-DDuzsNSx.js → graph-canvas-ySGKMhmk.js} +1 -1
  147. package/studio-dist/client/assets/guides-D6T6W_jV.js +1 -0
  148. package/studio-dist/client/assets/index-Qx7reRPD.js +40 -0
  149. package/studio-dist/client/assets/markdown-view-jMiaBTSO.js +1 -0
  150. package/studio-dist/client/assets/panel-C4bf_h2W.js +1 -0
  151. package/studio-dist/client/assets/plugins._service._view-y6f2FDAB.js +1 -0
  152. package/studio-dist/client/assets/prepaint-CKsXyJOR.js +27 -0
  153. package/studio-dist/client/assets/{queries-axYk2u9L.js → queries-Dfp5deWj.js} +1 -1
  154. package/studio-dist/client/assets/react-BYUSgtBs.js +1 -0
  155. package/studio-dist/client/assets/reports-JFSwSueq.js +1 -0
  156. package/studio-dist/client/assets/routes-BdOWSgzK.js +1 -0
  157. package/studio-dist/client/assets/search-CXosfvYh.js +1 -0
  158. package/studio-dist/client/assets/select-BHYYWPhK.js +1 -0
  159. package/studio-dist/client/assets/skills-Bo9FLsBd.js +1 -0
  160. package/studio-dist/client/assets/{specs-DU1kqcp5.js → specs-BrCOjOch.js} +1 -1
  161. package/studio-dist/client/assets/specs-view-CdE2rlli.js +1 -0
  162. package/studio-dist/client/assets/{steps-DhIFuAZy.js → steps-CKUno4lh.js} +1 -1
  163. package/studio-dist/client/assets/store-C3vJq8Wj.js +1 -0
  164. package/studio-dist/client/assets/{studio-BR9j15J0.js → studio-0ueISxwP.js} +8 -8
  165. package/studio-dist/client/assets/{studio-queries-CFP_yTpr.js → studio-queries-BflKt9va.js} +2 -2
  166. package/studio-dist/client/assets/{usage-CHmwtkoM.js → usage-BLsLy0nN.js} +16 -16
  167. package/studio-dist/client/assets/useAnchoredPopupScrollLock-DC7f8GOp.js +1 -0
  168. package/studio-dist/client/assets/useMutation-uJUrejsi.js +1 -0
  169. package/studio-dist/client/assets/vault-BB1B_OhR.js +1 -0
  170. package/studio-dist/client/assets/warnings-CqOOGlPD.js +1 -0
  171. package/studio-dist/client/assets/workflow-BFzmI-06.js +1 -0
  172. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-DAbZ6fzY.js → __23tanstack-start-server-fn-resolver-gVfW5vIV.js} +30 -14
  173. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +66 -50
  174. package/studio-dist/server/assets/{button-BfoNadNR.js → button-D6bvrFmm.js} +226 -3478
  175. package/studio-dist/server/assets/cn-FXJAM0KO.js +5528 -0
  176. package/studio-dist/server/assets/combobox-D2MbYV1O.js +484 -0
  177. package/studio-dist/server/assets/{companion-view-DHUjPpA0.js → companion-view-Mf1ANbMb.js} +2 -2
  178. package/studio-dist/server/assets/{companions-kBrJZAd6.js → companions-Dr6IpNAb.js} +1 -1
  179. package/studio-dist/server/assets/{fields-BD_c65T1.js → fields-B4mAPETz.js} +2 -1
  180. package/studio-dist/server/assets/friction-9a5S1m7U.js +943 -0
  181. package/studio-dist/server/assets/friction-CWOTjpCV.js +62 -0
  182. package/studio-dist/server/assets/{getting-started-7P0oyWaM.js → getting-started-RU6tYU2Q.js} +2 -2
  183. package/studio-dist/server/assets/{getting-started._topic-B1mV0kGz.js → getting-started._topic-C02HGrC6.js} +2 -2
  184. package/studio-dist/server/assets/{getting-started.index-CeGtvUsm.js → getting-started.index-EzLRosbb.js} +2 -2
  185. package/studio-dist/server/assets/{graph-BWtmJOH2.js → graph-B11ITte0.js} +1 -1
  186. package/studio-dist/server/assets/{graph-DSDVEELZ.js → graph-CZ2H9Fzr.js} +8 -8
  187. package/studio-dist/server/assets/{graph-canvas-CID9Nksc.js → graph-canvas-rP5TT14Z.js} +2 -2
  188. package/studio-dist/server/assets/{guides-Bm3RbUB-.js → guides-B8HdeK_C.js} +1 -1
  189. package/studio-dist/server/assets/{guides-BLJenHwQ.js → guides-BGftp4wf.js} +1 -1
  190. package/studio-dist/server/assets/{guides.server-rHHqRuzV.js → guides.server-DqFQAStf.js} +1 -1
  191. package/studio-dist/server/assets/{markdown-view-D3v9x-cM.js → markdown-view-CArpV-CS.js} +1 -1
  192. package/studio-dist/server/assets/{panel-yqOl5GMU.js → panel-DR0iq46J.js} +4 -3
  193. package/studio-dist/server/assets/{plugins._service._view-DwqJX7s9.js → plugins._service._view-n7u2k5dF.js} +11 -6
  194. package/studio-dist/server/assets/prepaint-B28ClcPN.js +45 -0
  195. package/studio-dist/server/assets/{queries-DYmGrhNO.js → queries-D-yVP9i0.js} +1 -1
  196. package/studio-dist/server/assets/react-CiBZPDs8.js +45 -0
  197. package/studio-dist/server/assets/{reports-C4Y_Jd-x.js → reports-B9k98oE6.js} +1 -1
  198. package/studio-dist/server/assets/{reports-7yaPz7aP.js → reports-C2SmTgqh.js} +7 -7
  199. package/studio-dist/server/assets/{router-Dnoq5auE.js → router-CPt0TAk_.js} +654 -1565
  200. package/studio-dist/server/assets/{routes-Cok4p3mK.js → routes-CwH8LEy2.js} +8 -8
  201. package/studio-dist/server/assets/{search-DUK7Jl6f.js → search-b-yQesv3.js} +25 -2
  202. package/studio-dist/server/assets/{combobox-oxUI6r4V.js → select-C3i6TTX-.js} +35 -514
  203. package/studio-dist/server/assets/{shell-DNVXedgE.js → shell-CagqZZMZ.js} +4 -3
  204. package/studio-dist/server/assets/{skills-D8qdXSku.js → skills-C21Mg_8-.js} +8 -8
  205. package/studio-dist/server/assets/{skills-pKmuAs0F.js → skills-DGg0mWDM.js} +1 -1
  206. package/studio-dist/server/assets/{specs-DeHYUNFp.js → specs-DetoMiaB.js} +4 -4
  207. package/studio-dist/server/assets/{specs-view-BGn-5Ik_.js → specs-view-CmbfLDwN.js} +10 -9
  208. package/studio-dist/server/assets/{steps-CV7Yk7L7.js → steps-D1tYAyWZ.js} +1 -1
  209. package/studio-dist/server/assets/store-aC-I6f6o.js +93 -0
  210. package/studio-dist/server/assets/{studio-CB94np48.js → studio-qRvQjRpz.js} +47 -2
  211. package/studio-dist/server/assets/{studio-queries-BqZGBE70.js → studio-queries-Dqf-3nzj.js} +66 -8
  212. package/studio-dist/server/assets/{usage-M6Gi6Km7.js → usage-CS4CBK9D.js} +13 -44
  213. package/studio-dist/server/assets/{usage-j5jR9gX9.js → usage-Cwle9-xY.js} +1 -1
  214. package/studio-dist/server/assets/useAnchoredPopupScrollLock-BjMNgXv9.js +756 -0
  215. package/studio-dist/server/assets/useMutation-DpBIuWXt.js +690 -0
  216. package/studio-dist/server/assets/{vault-lBlvSyD4.js → vault-CEBBRLMb.js} +1 -1
  217. package/studio-dist/server/assets/{vault-PqVmssmW.js → vault-DVQidlId.js} +6 -6
  218. package/studio-dist/server/assets/{views-CsFp1i1G.js → views-UgO0Qz_g.js} +2 -2
  219. package/studio-dist/server/assets/{warnings-BDs34j_m.js → warnings-C7hgXpdk.js} +2 -2
  220. package/studio-dist/server/assets/{workflow-T0eEldsa.js → workflow-6dZZ1ofw.js} +9 -9
  221. package/studio-dist/server/server.js +2 -2
  222. package/tool-manifest.yaml +85 -0
  223. package/studio-dist/client/assets/app-BFVyWHGo.css +0 -2
  224. package/studio-dist/client/assets/button-D6LrRkOG.js +0 -1
  225. package/studio-dist/client/assets/combobox-Dk2MMZWE.js +0 -1
  226. package/studio-dist/client/assets/fields-D_FYhxQr.js +0 -1
  227. package/studio-dist/client/assets/getting-started-ByWRg7hC.js +0 -1
  228. package/studio-dist/client/assets/getting-started-DZSjYC-b.js +0 -1
  229. package/studio-dist/client/assets/getting-started._topic-C6OyQ4G6.js +0 -1
  230. package/studio-dist/client/assets/getting-started.index-BkmPHdEm.js +0 -1
  231. package/studio-dist/client/assets/graph-7jm2XzyL.js +0 -2
  232. package/studio-dist/client/assets/guides-D9VTjWXP.js +0 -1
  233. package/studio-dist/client/assets/index-BBmFpG4y.js +0 -40
  234. package/studio-dist/client/assets/markdown-view-RL5YvfZg.js +0 -1
  235. package/studio-dist/client/assets/panel-B8F8sOKQ.js +0 -1
  236. package/studio-dist/client/assets/plugins._service._view-CynxTbMx.js +0 -1
  237. package/studio-dist/client/assets/react-r45OnJCw.js +0 -27
  238. package/studio-dist/client/assets/reports-BCAyXh6p.js +0 -1
  239. package/studio-dist/client/assets/routes-BFPqq89E.js +0 -1
  240. package/studio-dist/client/assets/skills-DTks_uBx.js +0 -1
  241. package/studio-dist/client/assets/specs-view-omrd_5P3.js +0 -1
  242. package/studio-dist/client/assets/store-DJ5cncKA.js +0 -1
  243. package/studio-dist/client/assets/useBaseQuery-BlC-AZ35.js +0 -1
  244. package/studio-dist/client/assets/vault-DRg8MScm.js +0 -1
  245. package/studio-dist/client/assets/warnings-UHFy6HAp.js +0 -1
  246. package/studio-dist/client/assets/workflow-Bv9vSfVV.js +0 -1
  247. package/studio-dist/server/assets/react-BO0uMhpm.js +0 -89
  248. package/studio-dist/server/assets/store-CWDGIp6x.js +0 -280
  249. package/studio-dist/server/assets/useBaseQuery-Tv_QJt9r.js +0 -2051
@@ -1,20 +1,23 @@
1
- import { B as skipToken, D as hashKey, E as functionalUpdate, F as partialMatchKey, G as lazyRouteComponent, J as Link, K as createFileRoute, L as resolveQueryValue, M as matchMutation, N as matchQuery, O as hashQueryKeyByOptions, P as noop, R as shallowEqualObjects, X as useParams, Y as useNavigate, a as companionViewQuery, c as pluginAttentionQuery, l as reportsQuery, m as vaultQuery, n as afterRefresh, q as createRootRouteWithContext, s as holdShellForMode, t as afterEvent, u as shellQuery, v as getShell, y as createSsrRpc, z as shouldThrowError } from "./studio-queries-BqZGBE70.js";
2
- import { a as Removable, c as notifyManager, d as QueryClientProvider, f as useQueryClient, i as Query, l as focusManager, n as defaultThrowOnError, o as createRetryer, r as QueryObserver, s as onlineManager, t as useBaseQuery, u as Subscribable } from "./useBaseQuery-Tv_QJt9r.js";
3
1
  import { a as useRouter, c as _getAssetMatches, m as createNonReactiveReadonlyStore, p as createNonReactiveMutableStore, u as RouterCore } from "./useSelector-DUmCUXAs.js";
4
2
  import { i as __exportAll, n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
3
+ import { a as QueryObserver, d as focusManager, f as Subscribable, i as defaultThrowOnError, l as onlineManager, m as useQueryClient, o as Query, p as QueryClientProvider, r as useBaseQuery, t as cn, u as notifyManager } from "./cn-FXJAM0KO.js";
4
+ import { D as TERMINAL_SOCKET_ROUTE, E as TERMINAL_SESSIONS_ROUTE, F as functionalUpdate, H as matchQuery, I as hashKey, K as replaceEqualDeep, L as hashQueryKeyByOptions, O as TERMINAL_WASM, T as TERMINAL_SESSIONS_END_ROUTE, U as noop, V as matchMutation, W as partialMatchKey, X as skipToken, a as companionViewQuery, at as useNavigate, b as studioFetch, c as pluginAttentionQuery, it as Link, k as queryOptions, l as reportsQuery, m as vaultQuery, n as afterRefresh, nt as createFileRoute, ot as useParams, q as resolveQueryValue, rt as createRootRouteWithContext, s as holdShellForMode, t as afterEvent, tt as lazyRouteComponent, u as shellQuery, v as getShell, w as STUDIO_EVENTS_ROUTE, x as probeStudio, y as createSsrRpc } from "./studio-queries-Dqf-3nzj.js";
5
5
  import { r as redirect } from "./redirect-BaZ_QyqF.js";
6
6
  import { a as useMatches, c as appendUniqueUserTags, d as resolveManifestCssLink, i as require_react_dom, l as getAssetCrossOrigin, n as createServerFn, o as Outlet, s as useHydrated, u as getScriptPreloadAttrs } from "../server.js";
7
7
  import { s as escapeHtml } from "./utils-C9CX1kcy.js";
8
- import { D as viewsFor, S as STUDIO_MODES, b as MODE_VIEWS, g as COMPANION_DIGEST_PATTERN, i as stepStage, n as LIGHT_PALETTE, p as defaultWorkflow, r as stagesBeforeWork, t as DARK_PALETTE, x as SHARED_VIEWS } from "./studio-CB94np48.js";
9
- import { a as THEME_STORAGE_KEY, i as STUDIO_PREPAINT_SCRIPT, n as COMPANION_STORAGE_KEY, o as VAULT_TREE_STORAGE_KEY, r as RAIL_STORAGE_KEY, t as create } from "./react-BO0uMhpm.js";
8
+ import { D as SHARED_VIEWS, E as MODE_VIEWS, N as viewsFor, O as STUDIO_MODES, S as COMPANION_DIGEST_PATTERN, g as MARK_STATES, i as stepStage, n as LIGHT_PALETTE, p as defaultWorkflow, r as stagesBeforeWork, t as DARK_PALETTE } from "./studio-qRvQjRpz.js";
9
+ import { a as VAULT_TREE_STORAGE_KEY, i as THEME_STORAGE_KEY, n as RAIL_STORAGE_KEY, r as STUDIO_PREPAINT_SCRIPT, t as COMPANION_STORAGE_KEY } from "./prepaint-B28ClcPN.js";
10
+ import { n as loadView, r as registeredCompanion, t as loadHeld } from "./queries-D-yVP9i0.js";
10
11
  import { t as formatCollectedAt } from "./model-PyPALjii.js";
11
- import { n as loadView, r as registeredCompanion, t as loadHeld } from "./queries-DYmGrhNO.js";
12
- import { n as validateSpecsSearch, r as validateStudioSearch, t as canonicalHref } from "./search-DUK7Jl6f.js";
13
- import { a as Count, l as PageHeader, n as popupStoreSelectors, t as createInitialPopupStoreState } from "./store-CWDGIp6x.js";
14
- import { $ as ToggleGroup, $n as getFrameElement, $t as triggerOpenStateMapping, A as useFloatingParentNodeId, An as inputClear, At as getPaddingObject, B as FocusGuard, Bn as triggerPress, Bt as stopEvent, C as useAnimationsFinished, Cr as useId, Ct as getAlignmentAxis, D as FloatingNode, Dn as focusOut, Dr as useQuery, Dt as getOppositeAxis, En as escapeKey, Et as getExpandedPlacements, F as CLICK_TRIGGER_IDENTIFIER, Fn as none, Ft as rectToClientRect, G as useValueAsRef, Gn as useButton, Gt as isTargetInsideEnabledTrigger, H as visuallyHiddenInput, Hn as createChangeEventDetails, Ht as getNodeChildren, I as DISABLED_TRANSITIONS_STYLE, It as round, J as Timeout, Jn as useIsoLayoutEffect, Jt as matchesFocusVisible, K as mergeCleanups, Kn as ownerDocument, Kt as isTypeableCombobox, Ln as pointer, Lt as isMouseLikePointerType, M as FloatingPortal, Mn as itemPress, Mt as getSideAxis, N as useFloatingPortalNode, Nn as keyboard, Nt as max, O as FloatingTree, On as imperativeAction, Ot as getOppositeAxisPlacements, Pn as listNavigation, Pt as min, Q as fastComponentRef, Qn as getDocumentElement, Qt as pressableTriggerOpenStateMapping, R as POPUP_COLLISION_AVOIDANCE, Rn as triggerFocus, Rt as isVirtualClick, S as useOpenChangeComplete, Sn as CompositeList, Sr as useBaseUiId, St as getAlignment, T as useDismiss, Tn as disabled, Tr as cn, Tt as getAxisLength, Un as createGenericEventDetails, Ut as getFloatingFocusElement, V as visuallyHidden, W as useAnimationFrame, Wn as useCompositeListItem, Wt as isInteractiveElement, X as useOnMount, Xn as getComputedStyle$1, Xt as popupStateMapping, Y as useTimeout, Yn as useStableCallback, Yt as triggerDisabled, Z as fastComponent, Zn as getContainingBlock, Zt as popupTransitionStateMapping, _ as usePopupInteractionProps, _n as webkit, _r as EMPTY_OBJECT, a as ReactStore, ar as isContainingBlock, b as useTriggerDataForwarding, bn as mac, br as useMergedRefs, bt as evaluate, c as PopupTriggerMap, cn as ARROW_LEFT, cr as isLastTraversableNode, ct as isOutsideEvent, d as applyPopupOpenChange, dn as activeElement, dr as isTableElement, dt as getGridNavigatedIndex, er as getNodeName, et as ToggleGroupItem, f as attachPreventUnmountOnClose, fn as closest, fr as isTopLayer, ft as getMaxListIndex, g as useOpenStateTransitions, gn as gecko, gr as EMPTY_ARRAY, gt as isIndexOutOfListBounds, h as useImplicitActiveTrigger, hr as mergeProps, i as FloatingRootStore, ir as getWindow, j as useFloatingTree, jn as inputPress, jt as getSide, k as useFloatingNodeId, kn as inputChange, kt as getOppositePlacement, l as FOCUSABLE_POPUP_PROPS, ln as ARROW_RIGHT, lr as isOverflowElement, m as createPopupOpenState, mn as getTarget, mr as useRenderElement, mt as getNextListIndex, nr as getOverflowAncestors, nt as useDirection, on as transitionStatusMapping, or as isElement, p as createDefaultInitialFocus, pn as contains, pr as isWebKit, pt as getMinListIndex, q as addEventListener, qn as formatErrorMessage, qt as isTypeableElement, r as Icon, rr as getParentNode, rt as COMPOSITE_KEYS, s as require_shim, sn as ARROW_DOWN, sr as isHTMLElement, st as getTabbableNearElement, t as Button, tr as getNodeScroll, tt as useToolbarRootContext, u as PopupHandleAttachment, un as ARROW_UP, v as usePopupRootStore, vn as android, vr as NOOP, vt as clamp, wn as closePress, wr as useControlled, wt as getAlignmentSides, x as useUnmountAfterClose, xr as useRefWithInit, xt as floor, y as usePopupRootSync, yn as ios, yt as createCoords, z as createAttribute, zn as triggerHover, zt as isVirtualPointerEvent } from "./button-BfoNadNR.js";
15
- import { _ as inertValue, a as InternalBackdrop, c as useLabelableId, d as useRegisterFieldControl, f as DEFAULT_FIELD_ROOT_CONTEXT, g as fieldValidityMapping, h as DEFAULT_FIELD_STATE_ATTRIBUTES, i as useScrollLock, l as useLabelableContext, m as useFieldRootContext, n as Kbd, o as useSetFieldFocused, p as FieldRootContext, r as Separator, s as useValueChanged, t as Input, u as useFormContext, v as FloatingFocusManager, y as enqueueFocus } from "./fields-BD_c65T1.js";
16
- import "./__23tanstack-start-server-fn-resolver-DAbZ6fzY.js";
17
- import { t as getGuide } from "./guides-BLJenHwQ.js";
12
+ import { a as FRICTION_VIEW_DAYS, i as validateStudioSearch, n as oneOf, o as frictionViewDays, r as validateSpecsSearch, t as canonicalHref } from "./search-b-yQesv3.js";
13
+ import { t as create } from "./react-CiBZPDs8.js";
14
+ import { A as useFloatingParentNodeId, An as android, Ar as NOOP, At as clamp, B as FocusGuard, Bn as imperativeAction, Bt as getOppositeAxisPlacements, C as useAnimationsFinished, Cn as activeElement, Cr as isTableElement, Ct as getGridNavigatedIndex, D as FloatingNode, Dr as mergeProps, En as getTarget, Er as useRenderElement, F as CLICK_TRIGGER_IDENTIFIER, Ft as getAlignmentAxis, G as useValueAsRef, Gn as keyboard, Gt as max, H as visuallyHiddenInput, Hn as inputClear, Ht as getPaddingObject, I as DISABLED_TRANSITIONS_STYLE, In as closePress, Ir as useControlled, It as getAlignmentSides, J as Timeout, Jt as round, K as mergeCleanups, Kt as min, Ln as disabled, Lr as useQuery, Lt as getAxisLength, M as FloatingPortal, Mn as mac, Mr as useMergedRefs, Mt as evaluate, N as useFloatingPortalNode, Nr as useRefWithInit, Nt as floor, O as FloatingTree, On as gecko, Or as EMPTY_ARRAY, Ot as isIndexOutOfListBounds, Pn as CompositeList, Pr as useBaseUiId, Pt as getAlignment, Q as fastComponentRef, Qn as triggerPress, Qt as stopEvent, R as POPUP_COLLISION_AVOIDANCE, Rn as escapeKey, Rt as getExpandedPlacements, S as useOpenChangeComplete, T as useDismiss, Tn as contains, Tr as isWebKit, Un as inputPress, Ut as getSide, V as visuallyHidden, Vn as inputChange, Vt as getOppositePlacement, Wn as itemPress, Wt as getSideAxis, X as useOnMount, Xn as triggerFocus, Y as useTimeout, Yn as pointer, Yt as isMouseLikePointerType, Z as fastComponent, Zn as triggerHover, _ as usePopupInteractionProps, _r as isContainingBlock, a as ReactStore, an as isTypeableElement, ar as formatErrorMessage, at as PageHeader, b as useTriggerDataForwarding, br as isLastTraversableNode, bt as isOutsideEvent, c as PopupTriggerMap, cn as popupStateMapping, cr as getComputedStyle$1, d as applyPopupOpenChange, dn as triggerOpenStateMapping, dr as getFrameElement, dt as ToggleGroup, en as getNodeChildren, er as createChangeEventDetails, f as attachPreventUnmountOnClose, fr as getNodeName, ft as ToggleGroupItem, g as useOpenStateTransitions, gr as getWindow, h as useImplicitActiveTrigger, hr as getParentNode, ht as COMPOSITE_KEYS, ir as ownerDocument, j as useFloatingTree, jn as ios, jt as createCoords, k as useFloatingNodeId, kn as webkit, kr as EMPTY_OBJECT, l as FOCUSABLE_POPUP_PROPS, ln as popupTransitionStateMapping, lr as getContainingBlock, lt as StatusWord, m as createPopupOpenState, mr as getOverflowAncestors, mt as useDirection, nn as isInteractiveElement, nr as useCompositeListItem, on as matchesFocusVisible, or as useIsoLayoutEffect, p as createDefaultInitialFocus, pr as getNodeScroll, pt as useToolbarRootContext, q as addEventListener, qn as none, qt as rectToClientRect, r as Icon, rn as isTargetInsideEnabledTrigger, rr as useButton, rt as ListCard, s as require_shim, sn as triggerDisabled, sr as useStableCallback, t as Button, tr as createGenericEventDetails, tt as Count, u as PopupHandleAttachment, un as pressableTriggerOpenStateMapping, ur as getDocumentElement, v as usePopupRootStore, vn as transitionStatusMapping, vr as isElement, wn as closest, wr as isTopLayer, x as useUnmountAfterClose, xr as isOverflowElement, y as usePopupRootSync, yr as isHTMLElement, yt as getTabbableNearElement, z as createAttribute, zn as focusOut, zt as getOppositeAxis } from "./button-D6bvrFmm.js";
15
+ import { _ as inertValue, a as InternalBackdrop, c as useLabelableId, d as useRegisterFieldControl, f as DEFAULT_FIELD_ROOT_CONTEXT, g as fieldValidityMapping, h as DEFAULT_FIELD_STATE_ATTRIBUTES, i as useScrollLock, l as useLabelableContext, m as useFieldRootContext, n as Kbd, o as useSetFieldFocused, p as FieldRootContext, r as Separator, s as useValueChanged, t as Input, u as useFormContext, v as FloatingFocusManager } from "./fields-B4mAPETz.js";
16
+ import { n as Mutation, t as useMutation } from "./useMutation-DpBIuWXt.js";
17
+ import "./__23tanstack-start-server-fn-resolver-gVfW5vIV.js";
18
+ import { t as getGuide } from "./guides-BGftp4wf.js";
19
+ import { n as popupStoreSelectors, t as createInitialPopupStoreState } from "./store-aC-I6f6o.js";
20
+ import { S as useClick, _ as resolveSelectedIndex, a as hasNullItemLabel, b as useListNavigation, d as compareItemEquality, f as defaultItemEquality, g as removeItem, h as isSelectedValueDirty, i as flattenLeafItems, l as stringifyAsLabel, m as findSelectionIndex, n as useOpenInteractionType, o as isGroupedItems, p as findItemIndex, r as useOpenMethodTriggerProps, t as useAnchoredPopupScrollLock, u as stringifyAsValue, v as selectedValueIncludes, x as useFloatingRootContext, y as useOnFirstRender } from "./useAnchoredPopupScrollLock-BjMNgXv9.js";
18
21
  // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/ssr/bodyScripts.js
19
22
  function getSsrBodyScriptParts(matches, manifest, nonce, routeScriptAttrs) {
20
23
  const assetMatches = _getAssetMatches(matches);
@@ -606,314 +609,6 @@ function dehydrateQuery(query, serializeData, shouldRedactErrors) {
606
609
  ...query.queryType && { queryType: query.queryType }
607
610
  };
608
611
  }
609
- // ../../node_modules/.bun/@tanstack+query-core@5.105.3/node_modules/@tanstack/query-core/build/modern/mutation.js
610
- /**
611
- * Represents a single mutation attempt. A `Mutation` holds the mutation's
612
- * options, state (data/error/status), and the `MutationObserver`s currently
613
- * subscribed to it.
614
- *
615
- * Instances are created and managed internally by `MutationCache`; application
616
- * code typically interacts with mutations indirectly through `QueryClient` or
617
- * a framework hook like `useMutation`. Direct access to a `Mutation` instance
618
- * is possible via `mutationCache.find()`/`getAll()` for inspecting cache state.
619
- * @example
620
- * ```ts
621
- * const mutationCache = queryClient.getMutationCache()
622
- *
623
- * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
624
- * ```
625
- */
626
- var Mutation = class extends Removable {
627
- #client;
628
- #observers;
629
- #mutationCache;
630
- #retryer;
631
- constructor(config) {
632
- super();
633
- this.#client = config.client;
634
- this.mutationId = config.mutationId;
635
- this.#mutationCache = config.mutationCache;
636
- this.#observers = [];
637
- this.state = config.state || getDefaultState();
638
- this.setOptions(config.options);
639
- this.scheduleGc();
640
- }
641
- /**
642
- * Replaces the mutation's options and applies their `gcTime`.
643
- * @internal
644
- * @param options - The new mutation options.
645
- */
646
- setOptions(options) {
647
- this.options = options;
648
- this.updateGcTime(this.options.gcTime);
649
- }
650
- /**
651
- * The `meta` object passed in the mutation's options, if any.
652
- * @returns The mutation's `meta`, or `undefined` if none was set.
653
- */
654
- get meta() {
655
- return this.options.meta;
656
- }
657
- /**
658
- * Subscribes an observer to the mutation and stops its garbage collection.
659
- * @internal
660
- * @param observer - The observer to add. Adding an observer that is already subscribed does
661
- * nothing.
662
- */
663
- addObserver(observer) {
664
- if (!this.#observers.includes(observer)) {
665
- this.#observers.push(observer);
666
- this.clearGcTimeout();
667
- this.#mutationCache.notify({
668
- type: "observerAdded",
669
- mutation: this,
670
- observer
671
- });
672
- }
673
- }
674
- /**
675
- * Unsubscribes an observer from the mutation.
676
- * @internal
677
- * @param observer - The observer to remove. Garbage collection is scheduled afterwards.
678
- */
679
- removeObserver(observer) {
680
- this.#observers = this.#observers.filter((x) => x !== observer);
681
- this.scheduleGc();
682
- this.#mutationCache.notify({
683
- type: "observerRemoved",
684
- mutation: this,
685
- observer
686
- });
687
- }
688
- optionalRemove() {
689
- if (!this.#observers.length) {
690
- if (this.state.status === "pending") this.scheduleGc();
691
- else this.#mutationCache.remove(this);
692
- }
693
- }
694
- /**
695
- * Resumes a mutation that is currently paused or was restored from a
696
- * dehydrated, still-`pending` state.
697
- *
698
- * - If this mutation has an active retryer (it paused mid-attempt, e.g. due
699
- * to the network mode or scope-based queuing), its retryer is resumed.
700
- * - Otherwise, if the mutation's status is still `pending` (e.g. it was
701
- * dehydrated while an attempt was in flight and never got a retryer in
702
- * this instance), `execute` is called again with the last known variables.
703
- * - Otherwise the mutation has already settled and this resolves immediately
704
- * without running anything again.
705
- * @returns A promise that settles with the resumed mutation: it rejects if the mutation fails.
706
- * It resolves immediately if the mutation has already settled.
707
- * @see {@link Mutation#execute}
708
- * @example
709
- * ```ts
710
- * // typically driven by reconnect handling, e.g. queryClient.resumePausedMutations()
711
- * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
712
- * await mutation?.continue()
713
- * ```
714
- */
715
- continue() {
716
- return this.#retryer?.continue() ?? (this.state.status === "pending" ? this.execute(this.state.variables) : Promise.resolve());
717
- }
718
- /**
719
- * Runs the mutation function for the given variables through a retryer, and
720
- * drives the mutation's state and lifecycle callbacks through to settlement.
721
- *
722
- * If this mutation's state is already `pending` when `execute` is called
723
- * (i.e. it was restored, still in-flight, from a dehydrated state), the
724
- * `onMutate` step is skipped and a `continue` action is dispatched to
725
- * unpause it; otherwise a `pending` action is dispatched first, then the
726
- * mutation cache's `onMutate` and the mutation's own `onMutate` option are
727
- * awaited in that order, and the resulting context is stored.
728
- *
729
- * The mutation function is then run (subject to `retry`/`retryDelay`/
730
- * `networkMode`, and to the mutation cache's scope-based serialization).
731
- * On success, the cache's `onSuccess`/`onSettled` callbacks run before the
732
- * mutation's own `onSuccess`/`onSettled` options, a `success` action is
733
- * dispatched, and the resolved data is returned. On failure, the same
734
- * cache-then-option ordering is used for `onError`/`onSettled`, but each of
735
- * those four callbacks is individually caught so that a throwing callback
736
- * cannot mask the original error; an `error` action is then dispatched and
737
- * the original error is re-thrown.
738
- * @param variables - The variables passed to the `mutationFn`.
739
- * @returns A promise that resolves with the mutation's data, or rejects with its error.
740
- * @see {@link Mutation#continue}
741
- * @example
742
- * ```ts
743
- * // Called internally by `MutationObserver.mutate` and `Mutation.continue` —
744
- * // applications normally trigger mutations through those, not this method.
745
- * const data = await mutation.execute(variables)
746
- * ```
747
- */
748
- async execute(variables) {
749
- const onContinue = () => {
750
- this.#dispatch({ type: "continue" });
751
- };
752
- const mutationFnContext = {
753
- client: this.#client,
754
- meta: this.options.meta,
755
- mutationKey: this.options.mutationKey
756
- };
757
- const retryer = this.#retryer = createRetryer({
758
- fn: () => {
759
- if (!this.options.mutationFn) return Promise.reject(/* @__PURE__ */ new Error("No mutationFn found"));
760
- return this.options.mutationFn(variables, mutationFnContext);
761
- },
762
- onFail: (failureCount, error) => {
763
- this.#dispatch({
764
- type: "failed",
765
- failureCount,
766
- error
767
- });
768
- },
769
- onPause: () => {
770
- this.#dispatch({ type: "pause" });
771
- },
772
- onContinue,
773
- retry: this.options.retry ?? 0,
774
- retryDelay: this.options.retryDelay,
775
- networkMode: this.options.networkMode,
776
- canRun: () => this.#mutationCache.canRun(this)
777
- });
778
- const restored = this.state.status === "pending";
779
- const isPaused = !retryer.canStart();
780
- try {
781
- if (restored) onContinue();
782
- else {
783
- this.#dispatch({
784
- type: "pending",
785
- variables,
786
- isPaused
787
- });
788
- if (this.#mutationCache.config.onMutate) await this.#mutationCache.config.onMutate(variables, this, mutationFnContext);
789
- const context = await this.options.onMutate?.(variables, mutationFnContext);
790
- if (context !== this.state.context) this.#dispatch({
791
- type: "pending",
792
- context,
793
- variables,
794
- isPaused
795
- });
796
- }
797
- if (this.state.isPaused && retryer.canStart()) onContinue();
798
- const data = await retryer.start();
799
- await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this, mutationFnContext);
800
- await this.options.onSuccess?.(data, variables, this.state.context, mutationFnContext);
801
- await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this, mutationFnContext);
802
- await this.options.onSettled?.(data, null, variables, this.state.context, mutationFnContext);
803
- this.#dispatch({
804
- type: "success",
805
- data
806
- });
807
- return data;
808
- } catch (error) {
809
- try {
810
- await this.#mutationCache.config.onError?.(error, variables, this.state.context, this, mutationFnContext);
811
- } catch (e) {
812
- Promise.reject(e);
813
- }
814
- try {
815
- await this.options.onError?.(error, variables, this.state.context, mutationFnContext);
816
- } catch (e) {
817
- Promise.reject(e);
818
- }
819
- try {
820
- await this.#mutationCache.config.onSettled?.(void 0, error, this.state.variables, this.state.context, this, mutationFnContext);
821
- } catch (e) {
822
- Promise.reject(e);
823
- }
824
- try {
825
- await this.options.onSettled?.(void 0, error, variables, this.state.context, mutationFnContext);
826
- } catch (e) {
827
- Promise.reject(e);
828
- }
829
- this.#dispatch({
830
- type: "error",
831
- error
832
- });
833
- throw error;
834
- } finally {
835
- if (this.#retryer === retryer) this.#retryer = void 0;
836
- this.#mutationCache.runNext(this);
837
- }
838
- }
839
- #dispatch(action) {
840
- const reducer = (state) => {
841
- switch (action.type) {
842
- case "failed": return {
843
- ...state,
844
- failureCount: action.failureCount,
845
- failureReason: action.error
846
- };
847
- case "pause": return {
848
- ...state,
849
- isPaused: true
850
- };
851
- case "continue": return {
852
- ...state,
853
- isPaused: false
854
- };
855
- case "pending": return {
856
- ...state,
857
- context: action.context,
858
- data: void 0,
859
- failureCount: 0,
860
- failureReason: null,
861
- error: null,
862
- isPaused: action.isPaused,
863
- status: "pending",
864
- variables: action.variables,
865
- submittedAt: Date.now()
866
- };
867
- case "success": return {
868
- ...state,
869
- data: action.data,
870
- failureCount: 0,
871
- failureReason: null,
872
- error: null,
873
- status: "success",
874
- isPaused: false
875
- };
876
- case "error": return {
877
- ...state,
878
- data: void 0,
879
- error: action.error,
880
- failureCount: state.failureCount + 1,
881
- failureReason: action.error,
882
- isPaused: false,
883
- status: "error"
884
- };
885
- }
886
- };
887
- this.state = reducer(this.state);
888
- notifyManager.batch(() => {
889
- this.#observers.forEach((observer) => {
890
- observer.onMutationUpdate(action);
891
- });
892
- this.#mutationCache.notify({
893
- mutation: this,
894
- type: "updated",
895
- action
896
- });
897
- });
898
- }
899
- };
900
- /**
901
- * Returns the initial state of a mutation: `'idle'`, with no data, error, or variables.
902
- * @returns The initial mutation state.
903
- */
904
- function getDefaultState() {
905
- return {
906
- context: void 0,
907
- data: void 0,
908
- error: null,
909
- failureCount: 0,
910
- failureReason: null,
911
- isPaused: false,
912
- status: "idle",
913
- variables: void 0,
914
- submittedAt: 0
915
- };
916
- }
917
612
  // ../../node_modules/.bun/@tanstack+query-core@5.105.3/node_modules/@tanstack/query-core/build/modern/mutationCache.js
918
613
  /**
919
614
  * The `MutationCache` is the storage for mutations.
@@ -1136,197 +831,6 @@ var MutationCache = class extends Subscribable {
1136
831
  function scopeFor(mutation) {
1137
832
  return mutation.options.scope?.id;
1138
833
  }
1139
- // ../../node_modules/.bun/@tanstack+query-core@5.105.3/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
1140
- /**
1141
- * Observes a single mutation and derives a `MutationObserverResult` from it.
1142
- * A framework hook like `useMutation` creates one `MutationObserver` per hook
1143
- * call, keeps it stable across re-renders, calls `setOptions` when the options
1144
- * passed to the hook change, subscribes to it to re-render on updates, and
1145
- * reads `getCurrentResult()` for the value to return. Calling `mutate()`
1146
- * builds a new underlying `Mutation` in the `MutationCache` and executes it.
1147
- * @example
1148
- * ```ts
1149
- * const observer = new MutationObserver(queryClient, {
1150
- * mutationFn: (variables: { title: string }) => addPost(variables),
1151
- * })
1152
- * ```
1153
- */
1154
- var MutationObserver = class extends Subscribable {
1155
- #client;
1156
- #currentResult = void 0;
1157
- #currentMutation;
1158
- #mutateOptions;
1159
- constructor(client, options) {
1160
- super();
1161
- this.#client = client;
1162
- this.setOptions(options);
1163
- this.bindMethods();
1164
- this.#updateResult();
1165
- }
1166
- /**
1167
- * Binds the methods of the result (`mutate` and `reset`) to the observer, so they keep working when
1168
- * destructured from it.
1169
- */
1170
- bindMethods() {
1171
- this.mutate = this.mutate.bind(this);
1172
- this.reset = this.reset.bind(this);
1173
- }
1174
- /**
1175
- * Updates the observer's options.
1176
- *
1177
- * If the new `mutationKey` differs from the previous one (and both were
1178
- * defined), the observer is reset, detaching it from the mutation it was
1179
- * observing. Otherwise, if the currently observed mutation is still
1180
- * `pending`, its options are updated in place as well.
1181
- * @param options - The new mutation observer options. They are defaulted with {@link
1182
- * QueryClient#defaultMutationOptions} before being applied.
1183
- * @example
1184
- * ```ts
1185
- * observer.setOptions({
1186
- * mutationFn: (variables: { title: string }) => addPost(variables),
1187
- * onSuccess: (data) => console.log(data),
1188
- * })
1189
- * ```
1190
- */
1191
- setOptions(options) {
1192
- const prevOptions = this.options;
1193
- this.options = this.#client.defaultMutationOptions(options);
1194
- if (!shallowEqualObjects(this.options, prevOptions)) this.#client.getMutationCache().notify({
1195
- type: "observerOptionsUpdated",
1196
- mutation: this.#currentMutation,
1197
- observer: this
1198
- });
1199
- if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();
1200
- else if (this.#currentMutation?.state.status === "pending") this.#currentMutation.setOptions(this.options);
1201
- }
1202
- onSubscribe() {
1203
- if (this.listeners.size === 1 && this.#currentMutation) {
1204
- this.#currentMutation.addObserver(this);
1205
- this.#updateResult();
1206
- }
1207
- }
1208
- onUnsubscribe() {
1209
- if (!this.hasListeners()) this.#currentMutation?.removeObserver(this);
1210
- }
1211
- /**
1212
- * Updates the observer's result when the observed mutation changes, and notifies its listeners.
1213
- * @internal
1214
- * @param action - The action that updated the observed mutation, passed on to the observer's
1215
- * callbacks.
1216
- */
1217
- onMutationUpdate(action) {
1218
- this.#updateResult();
1219
- this.#notify(action);
1220
- }
1221
- /**
1222
- * Returns the observer's current result, derived from the observed
1223
- * mutation's state (or the default, `idle` state if no mutation has been
1224
- * built yet, e.g. before the first `mutate()` call or after `reset()`).
1225
- * @returns The observer's latest result.
1226
- */
1227
- getCurrentResult() {
1228
- return this.#currentResult;
1229
- }
1230
- /**
1231
- * Detaches the observer from the mutation it is currently observing (if
1232
- * any) and resets the observed result back to its default, `idle` state.
1233
- *
1234
- * This does not cancel an in-flight mutation; the mutation itself keeps
1235
- * running to completion and its own callbacks still fire, but this
1236
- * observer stops reflecting its state and a subsequent `mutate()` call
1237
- * will build a brand new mutation.
1238
- * @see {@link MutationObserver#mutate}
1239
- * @example
1240
- * ```ts
1241
- * observer.reset()
1242
- * ```
1243
- */
1244
- reset() {
1245
- this.#currentMutation?.removeObserver(this);
1246
- this.#currentMutation = void 0;
1247
- this.#updateResult();
1248
- this.#notify();
1249
- }
1250
- /**
1251
- * Builds a new `Mutation` in the `MutationCache` using the observer's
1252
- * current options, detaches this observer from any previously observed
1253
- * mutation, attaches it to the new one, and executes it with the given
1254
- * variables.
1255
- *
1256
- * The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are
1257
- * invoked once the mutation settles, in addition to any callbacks defined
1258
- * on the observer's own options.
1259
- * @param variables - The variables passed to the `mutationFn`.
1260
- * @param options - Per-call `onSuccess`, `onError`, and `onSettled` callbacks.
1261
- * @returns A promise that resolves with the mutation's data, or rejects with its error.
1262
- * @example
1263
- * ```ts
1264
- * await observer.mutate(
1265
- * { title: 'New post' },
1266
- * { onSuccess: (data) => console.log(data) },
1267
- * )
1268
- * ```
1269
- */
1270
- mutate(variables, options) {
1271
- this.#mutateOptions = options;
1272
- this.#currentMutation?.removeObserver(this);
1273
- this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);
1274
- this.#currentMutation.addObserver(this);
1275
- return this.#currentMutation.execute(variables);
1276
- }
1277
- #updateResult() {
1278
- const state = this.#currentMutation?.state ?? getDefaultState();
1279
- this.#currentResult = {
1280
- ...state,
1281
- isPending: state.status === "pending",
1282
- isSuccess: state.status === "success",
1283
- isError: state.status === "error",
1284
- isIdle: state.status === "idle",
1285
- mutate: this.mutate,
1286
- reset: this.reset
1287
- };
1288
- }
1289
- #notify(action) {
1290
- notifyManager.batch(() => {
1291
- const mutateOptions = this.#mutateOptions;
1292
- if (mutateOptions && this.hasListeners()) {
1293
- const variables = this.#currentResult.variables;
1294
- const onMutateResult = this.#currentResult.context;
1295
- const context = {
1296
- client: this.#client,
1297
- meta: this.options.meta,
1298
- mutationKey: this.options.mutationKey
1299
- };
1300
- if (action?.type === "success") {
1301
- try {
1302
- mutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);
1303
- } catch (e) {
1304
- Promise.reject(e);
1305
- }
1306
- try {
1307
- mutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);
1308
- } catch (e) {
1309
- Promise.reject(e);
1310
- }
1311
- } else if (action?.type === "error") {
1312
- try {
1313
- mutateOptions.onError?.(action.error, variables, onMutateResult, context);
1314
- } catch (e) {
1315
- Promise.reject(e);
1316
- }
1317
- try {
1318
- mutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);
1319
- } catch (e) {
1320
- Promise.reject(e);
1321
- }
1322
- }
1323
- }
1324
- this.listeners.forEach((listener) => {
1325
- listener(this.#currentResult);
1326
- });
1327
- });
1328
- }
1329
- };
1330
834
  // ../../node_modules/.bun/@tanstack+query-core@5.105.3/node_modules/@tanstack/query-core/build/modern/queryCache.js
1331
835
  /**
1332
836
  * The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta
@@ -2354,191 +1858,130 @@ function useSuspenseQuery(options, queryClient) {
2354
1858
  placeholderData: void 0
2355
1859
  }, QueryObserver, queryClient);
2356
1860
  }
2357
- // ../../node_modules/.bun/@tanstack+react-query@5.105.3+cef22a3c7e8b4cef/node_modules/@tanstack/react-query/build/modern/useMutation.js
1861
+ // ../../node_modules/.bun/@tanstack+react-query@5.105.3+cef22a3c7e8b4cef/node_modules/@tanstack/react-query/build/modern/useMutationState.js
2358
1862
  /**
2359
- * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
2360
- * `useMutation` is the hook for that.
2361
- * @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.
1863
+ * The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending`
1864
+ * (useful for app-wide loading indicators).
1865
+ * @param filters - The {@link MutationFilters} to narrow down the matched mutations.
2362
1866
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
2363
1867
  * be used.
2364
- * @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second
2365
- * argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared
2366
- * mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call callbacks
2367
- * fire only for the latest call you've made, and only while the component is still mounted — unmounting before
2368
- * the mutation settles removes the subscription and prevents them from firing.
2369
- * @throws {Error} The mutation error, when `throwOnError` is `true` or returns `true` for it, so that it is
2370
- * thrown to the nearest error boundary.
2371
- * @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look
2372
- * the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).
1868
+ * @returns Will be the `number` of the mutations that your application currently has `pending`.
2373
1869
  * @example
2374
1870
  * ```tsx
2375
- * import { useMutation, useQueryClient } from '@tanstack/react-query'
1871
+ * import { useIsMutating } from '@tanstack/react-query'
2376
1872
  *
2377
- * function AddTodo() {
2378
- * const queryClient = useQueryClient()
2379
- *
2380
- * const addMutation = useMutation({
2381
- * mutationFn: addTodo,
2382
- * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
2383
- * })
1873
+ * function PostsMutatingIndicator() {
1874
+ * // How many mutations matching the posts prefix are in progress?
1875
+ * const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })
2384
1876
  *
2385
- * return (
2386
- * <button
2387
- * onClick={() =>
2388
- * addMutation.mutate('Item', {
2389
- * onError: (error) => console.error('Failed to add item:', error),
2390
- * })
2391
- * }
2392
- * >
2393
- * Add
2394
- * </button>
2395
- * )
1877
+ * return isMutatingPosts ? <span>Saving posts...</span> : null
2396
1878
  * }
2397
1879
  * ```
1880
+ */
1881
+ function useIsMutating(filters, queryClient) {
1882
+ const client = useQueryClient(queryClient);
1883
+ return useMutationState({ filters: {
1884
+ ...filters,
1885
+ status: "pending"
1886
+ } }, client).length;
1887
+ }
1888
+ /**
1889
+ * Creates snapshot getters that share equal selected results across renders.
1890
+ * A new getter is created on each render. Each getter caches its snapshot until the matching mutations
1891
+ * or their states change.
1892
+ * @returns A factory for snapshot getters with a shared result cache.
1893
+ */
1894
+ function createSnapshotFactory() {
1895
+ let previousResult;
1896
+ return (mutationCache, options) => {
1897
+ let inputs = [];
1898
+ let snapshot;
1899
+ return () => {
1900
+ const mutations = mutationCache.findAll(options.filters);
1901
+ const nextInputs = mutations.flatMap((mutation) => [mutation, mutation.state]);
1902
+ if (!snapshot || nextInputs.length !== inputs.length || nextInputs.some((input, index) => !Object.is(input, inputs[index]))) {
1903
+ inputs = nextInputs;
1904
+ snapshot = replaceEqualDeep(previousResult, mutations.map((mutation) => options.select ? options.select(mutation) : mutation.state));
1905
+ previousResult = snapshot;
1906
+ }
1907
+ return snapshot;
1908
+ };
1909
+ };
1910
+ }
1911
+ /**
1912
+ * `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass
1913
+ * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation
1914
+ * state.
1915
+ * @param options - The `filters` to narrow down matched mutations, and an optional `select` to transform the
1916
+ * mutation state.
1917
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
1918
+ * be used.
1919
+ * @returns Will be an Array of whatever `select` returns for each matching mutation.
2398
1920
  * @example
2399
- * Rendering the mutation's own state, rather than just firing it off:
1921
+ * Get all variables of all running mutations:
2400
1922
  * ```tsx
2401
- * import { useMutation, useQueryClient } from '@tanstack/react-query'
2402
- *
2403
- * function AddTodo() {
2404
- * const queryClient = useQueryClient()
1923
+ * import { useMutationState } from '@tanstack/react-query'
2405
1924
  *
2406
- * const addMutation = useMutation({
2407
- * mutationFn: addTodo,
2408
- * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
1925
+ * function PendingPosts() {
1926
+ * const pendingVariables = useMutationState({
1927
+ * filters: { status: 'pending' },
1928
+ * select: (mutation) => mutation.state.variables,
2409
1929
  * })
2410
1930
  *
2411
- * return (
2412
- * <div>
2413
- * {addMutation.isPending ? (
2414
- * 'Adding todo...'
2415
- * ) : (
2416
- * <>
2417
- * {addMutation.isError ? (
2418
- * <div>An error occurred: {addMutation.error.message}</div>
2419
- * ) : null}
2420
- * <button onClick={() => addMutation.mutate('Item')}>Add</button>
2421
- * </>
2422
- * )}
2423
- * </div>
2424
- * )
1931
+ * return <>{pendingVariables.length} posts saving...</>
2425
1932
  * }
2426
1933
  * ```
2427
1934
  * @example
2428
- * Optimistic update via `onMutate`, rolling back on `onError`:
1935
+ * Get all data for specific mutations via the `mutationKey`:
2429
1936
  * ```tsx
2430
- * import { useMutation, useQueryClient } from '@tanstack/react-query'
2431
- *
2432
- * function AddTodo() {
2433
- * const queryClient = useQueryClient()
2434
- *
2435
- * const addMutation = useMutation({
2436
- * mutationFn: addTodo,
2437
- * onMutate: async (newTodo) => {
2438
- * await queryClient.cancelQueries({ queryKey: ['todos'] })
2439
- * const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])
1937
+ * import { useMutation, useMutationState } from '@tanstack/react-query'
2440
1938
  *
2441
- * queryClient.setQueryData<Array<string>>(['todos'], (old) => [
2442
- * ...(old ?? []),
2443
- * newTodo,
2444
- * ])
1939
+ * const mutationKey = ['posts']
2445
1940
  *
2446
- * // Passed to `onError` as `onMutateResult` if the mutation fails.
2447
- * return { previousTodos }
2448
- * },
2449
- * onError: (_err, _newTodo, onMutateResult) => {
2450
- * queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)
2451
- * },
2452
- * onSettled: () => {
2453
- * queryClient.invalidateQueries({ queryKey: ['todos'] })
2454
- * },
1941
+ * function Posts() {
1942
+ * // Some mutation that we want to get the state for
1943
+ * const mutation = useMutation({
1944
+ * mutationKey,
1945
+ * mutationFn: createPosts,
2455
1946
  * })
2456
1947
  *
2457
- * return (
2458
- * <button onClick={() => addMutation.mutate('Item')}>Add</button>
2459
- * )
2460
- * }
2461
- * ```
2462
- * @example
2463
- * Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a
2464
- * promise per call instead, so you can wait for all of them when they succeed:
2465
- * ```tsx
2466
- * import { useMutation, useQueryClient } from '@tanstack/react-query'
2467
- *
2468
- * function AddTodos() {
2469
- * const queryClient = useQueryClient()
2470
- *
2471
- * const addMutation = useMutation({
2472
- * mutationFn: addTodo,
2473
- * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
1948
+ * const savedPosts = useMutationState({
1949
+ * // this mutation key needs to match the mutation key of the given mutation (see above)
1950
+ * filters: { mutationKey, status: 'success' },
1951
+ * select: (mutation) => mutation.state.data,
2474
1952
  * })
2475
1953
  *
2476
- * async function handleAddAll(todos: Array<string>) {
2477
- * try {
2478
- * await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))
2479
- * } catch (error) {
2480
- * console.error('Failed to add todos:', error)
2481
- * }
2482
- * }
2483
- *
2484
1954
  * return (
2485
- * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>
2486
- * Add all
1955
+ * <button onClick={() => mutation.mutate(['New Post'])}>
1956
+ * Create post ({savedPosts.length} saved so far)
2487
1957
  * </button>
2488
1958
  * )
2489
1959
  * }
2490
1960
  * ```
2491
1961
  * @example
2492
- * If some of the mutations above can fail independently of the others, and you want to know which ones
2493
- * did — rather than losing that information the moment the first one rejects — swap `Promise.all` for
2494
- * `Promise.allSettled`:
1962
+ * Access the latest successful mutation data via the `mutationKey`. Each invocation of `mutate` adds a new
1963
+ * entry to the mutation cache for `gcTime` milliseconds — with the `status: 'success'` filter below, check the
1964
+ * last item that `useMutationState` returns to get the latest successful invocation:
2495
1965
  * ```tsx
2496
- * import { useMutation, useQueryClient } from '@tanstack/react-query'
2497
- *
2498
- * function AddTodos() {
2499
- * const queryClient = useQueryClient()
1966
+ * import { useMutationState } from '@tanstack/react-query'
2500
1967
  *
2501
- * const addMutation = useMutation({
2502
- * mutationFn: addTodo,
2503
- * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
1968
+ * function LatestPost() {
1969
+ * const savedPosts = useMutationState({
1970
+ * filters: { mutationKey: ['posts'], status: 'success' },
1971
+ * select: (mutation) => mutation.state.data,
2504
1972
  * })
2505
1973
  *
2506
- * async function handleAddAll(todos: Array<string>) {
2507
- * const addResults = await Promise.allSettled(
2508
- * todos.map((todo) => addMutation.mutateAsync(todo)),
2509
- * )
2510
- *
2511
- * addResults.forEach((addResult, index) => {
2512
- * if (addResult.status === 'rejected') {
2513
- * console.error(`Failed to add "${todos[index]}":`, addResult.reason)
2514
- * }
2515
- * })
2516
- * }
1974
+ * const latestSavedPost = savedPosts[savedPosts.length - 1]
2517
1975
  *
2518
- * return (
2519
- * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>
2520
- * Add all
2521
- * </button>
2522
- * )
1976
+ * return <>{latestSavedPost ? 'Saved' : 'Nothing saved yet'}</>
2523
1977
  * }
2524
1978
  * ```
2525
1979
  */
2526
- function useMutation(options, queryClient) {
2527
- const client = useQueryClient(queryClient);
2528
- const [observer] = import_react.useState(() => new MutationObserver(client, options));
2529
- import_react.useEffect(() => {
2530
- observer.setOptions(options);
2531
- }, [observer, options]);
2532
- const result = import_react.useSyncExternalStore(import_react.useCallback((onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
2533
- const mutate = import_react.useCallback((...args) => {
2534
- observer.mutate(args[0], args[1]).catch(noop);
2535
- }, [observer]);
2536
- if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) throw result.error;
2537
- return {
2538
- ...result,
2539
- mutate,
2540
- mutateAsync: result.mutate
2541
- };
1980
+ function useMutationState(options = {}, queryClient) {
1981
+ const mutationCache = useQueryClient(queryClient).getMutationCache();
1982
+ const [createSnapshot] = import_react.useState(() => createSnapshotFactory());
1983
+ const getSnapshot = createSnapshot(mutationCache, options);
1984
+ return import_react.useSyncExternalStore(import_react.useCallback((onStoreChange) => mutationCache.subscribe(notifyManager.batchCalls(onStoreChange)), [mutationCache]), getSnapshot, getSnapshot);
2542
1985
  }
2543
1986
  // ../../node_modules/.bun/@tanstack+router-ssr-query-core@1.169.3+3554ab4a3d907bbf/node_modules/@tanstack/router-ssr-query-core/dist/esm/index.js
2544
1987
  var shouldDehydrateAllQueries = () => true;
@@ -2661,19 +2104,6 @@ var BRAND_SVGS = {
2661
2104
  symbolOnDark: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" width=\"256\" height=\"256\" role=\"img\" aria-labelledby=\"title\"><title id=\"title\">mate logo</title><g id=\"symbol\"><path fill=\"#F4F0E8\" d=\"M36 16H144V240H36A20 20 0 0 1 16 220V36A20 20 0 0 1 36 16Z\"/><path fill=\"#7FD0A6\" d=\"M160 16H220A20 20 0 0 1 240 36V80H160Z M160 96H240V160H160Z M160 176H240V220A20 20 0 0 1 220 240H160Z\"/></g></svg>",
2662
2105
  favicon: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" width=\"256\" height=\"256\" role=\"img\" aria-labelledby=\"title\"><title id=\"title\">mate logo</title><rect width=\"256\" height=\"256\" rx=\"48\" fill=\"#1F2421\"/><g id=\"symbol\" transform=\"translate(32 32) scale(0.75)\"><path fill=\"#F4F0E8\" d=\"M36 16H144V240H36A20 20 0 0 1 16 220V36A20 20 0 0 1 36 16Z\"/><path fill=\"#7FD0A6\" d=\"M160 16H220A20 20 0 0 1 240 36V80H160Z M160 96H240V160H160Z M160 176H240V220A20 20 0 0 1 220 240H160Z\"/></g></svg>"
2663
2106
  };
2664
- // ../mate-core/src/cli/commands/studio/routes.ts
2665
- /** A hosted report's HTML is served at this prefix plus its id. */
2666
- var REPORT_VIEW_PREFIX = "/studio/reports/";
2667
- /** A service plugin's routes: `/api/plugins/<service id>/…`. */
2668
- var SERVICE_ROUTE_PREFIX = "/api/plugins/";
2669
- /** One event stream per page: board, reports and markdown tree changes for a companion. */
2670
- var STUDIO_EVENTS_ROUTE = "/api/events";
2671
- /** The terminal's WASM core, loaded by Studio's bundled terminal from Studio itself. */
2672
- var TERMINAL_WASM = `/studio/terminal/wterm.wasm`;
2673
- /** The terminal's WebSocket, and its session list and end calls. */
2674
- var TERMINAL_SOCKET_ROUTE = "/api/terminal";
2675
- var TERMINAL_SESSIONS_ROUTE = "/api/terminal/sessions";
2676
- var TERMINAL_SESSIONS_END_ROUTE = "/api/terminal/sessions/end";
2677
2107
  // src/styles/palette.ts
2678
2108
  /** Each of these also gets a `--<name>-soft` tint: this share of the colour over the card surface. */
2679
2109
  var TINTED_TOKENS = [
@@ -2760,6 +2190,7 @@ var VIEW_PATHS = {
2760
2190
  specs: "/specs",
2761
2191
  reports: "/reports",
2762
2192
  usage: "/usage",
2193
+ friction: "/friction",
2763
2194
  graph: "/graph"
2764
2195
  };
2765
2196
  /** A view's page title is its navigation label. */
@@ -2772,6 +2203,7 @@ var VIEW_TITLES = {
2772
2203
  specs: "Specs",
2773
2204
  reports: "Reports",
2774
2205
  usage: "Usage",
2206
+ friction: "Friction",
2775
2207
  graph: "Graph"
2776
2208
  };
2777
2209
  var MODE_TITLES = {
@@ -2794,6 +2226,7 @@ var VIEW_DESCRIPTIONS = {
2794
2226
  specs: "Capabilities by Area, with their requirements.",
2795
2227
  reports: "Reports agents published for this companion.",
2796
2228
  usage: "Token usage across this companion and every linked Working Repository.",
2229
+ friction: "Where Mate got in your agents' way, recorded on this machine.",
2797
2230
  graph: "Capabilities, Areas and repositories, and how they connect."
2798
2231
  },
2799
2232
  analysis: {
@@ -2805,11 +2238,12 @@ var VIEW_DESCRIPTIONS = {
2805
2238
  specs: "Capabilities by Area, with their requirements.",
2806
2239
  reports: "Reports agents published for this companion.",
2807
2240
  usage: "Token usage across this companion and every linked Working Repository.",
2241
+ friction: "Where Mate got in the agents' way, recorded on this machine.",
2808
2242
  graph: "Capabilities, Areas and repositories, and how they connect."
2809
2243
  }
2810
2244
  };
2811
2245
  // src/styles/app.css?url
2812
- var app_default = "/assets/app-BFVyWHGo.css";
2246
+ var app_default = "/assets/app-ggXJ_QVh.css";
2813
2247
  // src/terminal/keys.ts
2814
2248
  /** Browser storage keys and sizes of the agent terminal, shared by the page and its scripts. */
2815
2249
  var TERMINAL_TAB_KEY = "mate-studio-terminal-tab";
@@ -2818,6 +2252,10 @@ var TERMINAL_WIDTH_KEY = "mate-studio-terminal-width";
2818
2252
  var TERMINAL_COLLAPSED_KEY = "mate-studio-terminal-collapsed";
2819
2253
  var TERMINAL_MAX_WIDTH_RATIO = .7;
2820
2254
  // src/stores/terminal-ui.ts
2255
+ /** The workspace view holding the sidebar collapsed, if any. */
2256
+ function heldBy(workspace, released) {
2257
+ return workspace && !released.includes(workspace) ? workspace : null;
2258
+ }
2821
2259
  function clampWidth(px) {
2822
2260
  return Math.round(Math.max(360, Math.min(px, window.innerWidth * TERMINAL_MAX_WIDTH_RATIO)));
2823
2261
  }
@@ -2835,6 +2273,8 @@ var useTerminalUi = create((set, get) => ({
2835
2273
  drawerOpen: false,
2836
2274
  viewing: null,
2837
2275
  controller: null,
2276
+ workspace: null,
2277
+ released: [],
2838
2278
  setCollapsed: (collapsed) => {
2839
2279
  document.documentElement.toggleAttribute("data-terminal-collapsed", collapsed);
2840
2280
  save$1(TERMINAL_COLLAPSED_KEY, String(collapsed));
@@ -2852,7 +2292,14 @@ var useTerminalUi = create((set, get) => ({
2852
2292
  set({ viewing });
2853
2293
  },
2854
2294
  register: (controller) => set({ controller }),
2295
+ setWorkspace: (workspace) => set({ workspace }),
2296
+ release: (view) => {
2297
+ if (get().collapsed) get().setCollapsed(false);
2298
+ if (!get().released.includes(view)) set({ released: [...get().released, view] });
2299
+ },
2855
2300
  reveal: () => {
2301
+ const held = heldBy(get().workspace, get().released);
2302
+ if (held) get().release(held);
2856
2303
  if (get().collapsed) get().setCollapsed(false);
2857
2304
  if (window.matchMedia?.("(max-width: 1200px)").matches) set({ drawerOpen: true });
2858
2305
  }
@@ -3067,83 +2514,6 @@ function useDelayGroup(store, options = { open: false }) {
3067
2514
  isInstantPhase
3068
2515
  ]);
3069
2516
  }
3070
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useClick.mjs
3071
- /**
3072
- * Opens or closes the floating element when clicking the reference element.
3073
- * @see https://floating-ui.com/docs/useClick
3074
- */
3075
- function useClick(store, props = {}) {
3076
- const { enabled = true, event: eventOption = "click", toggle = true, ignoreMouse = false, stickIfOpen = true, touchOpenDelay = 0, reason = triggerPress } = props;
3077
- const dataRef = store.context.dataRef;
3078
- const pointerTypeRef = import_react.useRef(void 0);
3079
- const frame = useAnimationFrame();
3080
- const touchOpenTimeout = useTimeout();
3081
- const reference = import_react.useMemo(() => {
3082
- function setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType) {
3083
- const details = createChangeEventDetails(reason, nativeEvent, target);
3084
- if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) touchOpenTimeout.start(touchOpenDelay, () => {
3085
- store.setOpen(true, details);
3086
- });
3087
- else store.setOpen(nextOpen, details);
3088
- }
3089
- function getNextOpen(open, currentTarget, isClickLikeOpenEvent) {
3090
- const openEvent = dataRef.current.openEvent;
3091
- const hasClickedOnInactiveTrigger = store.select("domReferenceElement") !== currentTarget;
3092
- if (open && hasClickedOnInactiveTrigger) return true;
3093
- if (!open) return true;
3094
- if (!toggle) return true;
3095
- if (openEvent && (typeof stickIfOpen === "function" ? stickIfOpen() : stickIfOpen)) return !isClickLikeOpenEvent(openEvent.type);
3096
- return false;
3097
- }
3098
- return {
3099
- onPointerDown(event) {
3100
- pointerTypeRef.current = isMouseLikePointerType(event.pointerType, true) && isVirtualPointerEvent(event.nativeEvent) ? "virtual" : event.pointerType;
3101
- },
3102
- onMouseDown(event) {
3103
- const pointerType = pointerTypeRef.current;
3104
- const nativeEvent = event.nativeEvent;
3105
- const open = store.select("open");
3106
- if (event.button !== 0 || eventOption === "click" || isMouseLikePointerType(pointerType, true) && ignoreMouse) return;
3107
- const nextOpen = getNextOpen(open, event.currentTarget, (openEventType) => openEventType === "click" || openEventType === "mousedown");
3108
- const target = getTarget(nativeEvent);
3109
- const isTypeable = isTypeableElement(target);
3110
- if (isTypeable || pointerType === "virtual") {
3111
- setOpenWithTouchDelay(nextOpen, nativeEvent, isTypeable ? target : event.currentTarget, pointerType);
3112
- return;
3113
- }
3114
- const eventCurrentTarget = event.currentTarget;
3115
- frame.request(() => {
3116
- setOpenWithTouchDelay(nextOpen, nativeEvent, eventCurrentTarget, pointerType);
3117
- });
3118
- },
3119
- onClick(event) {
3120
- if (eventOption === "mousedown-only") return;
3121
- const pointerType = pointerTypeRef.current;
3122
- if (eventOption === "mousedown" && pointerType) {
3123
- pointerTypeRef.current = void 0;
3124
- return;
3125
- }
3126
- if (isMouseLikePointerType(pointerType, true) && ignoreMouse) return;
3127
- setOpenWithTouchDelay(getNextOpen(store.select("open"), event.currentTarget, (openEventType) => openEventType === "click" || openEventType === "mousedown" || openEventType === "keydown" || openEventType === "keyup"), event.nativeEvent, event.currentTarget, pointerType);
3128
- },
3129
- onKeyDown() {
3130
- pointerTypeRef.current = void 0;
3131
- }
3132
- };
3133
- }, [
3134
- dataRef,
3135
- eventOption,
3136
- ignoreMouse,
3137
- reason,
3138
- store,
3139
- stickIfOpen,
3140
- toggle,
3141
- frame,
3142
- touchOpenTimeout,
3143
- touchOpenDelay
3144
- ]);
3145
- return import_react.useMemo(() => enabled ? { reference } : EMPTY_OBJECT, [enabled, reference]);
3146
- }
3147
2517
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3148
2518
  function createVirtualElement(domElement, data) {
3149
2519
  let offsetX = null;
@@ -3304,44 +2674,6 @@ function usePopupHandleStore(handle) {
3304
2674
  }, [handle]);
3305
2675
  return (0, import_shim.useSyncExternalStore)(subscribe, getSnapshot, () => handle?.serverStore);
3306
2676
  }
3307
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
3308
- function useFloatingRootContext(options) {
3309
- const { open = false, onOpenChange, elements = {} } = options;
3310
- const floatingId = useId();
3311
- const nested = useFloatingParentNodeId() != null;
3312
- const store = useRefWithInit(() => new FloatingRootStore({
3313
- open,
3314
- transitionStatus: void 0,
3315
- onOpenChange,
3316
- referenceElement: elements.reference ?? null,
3317
- floatingElement: elements.floating ?? null,
3318
- triggerElements: new PopupTriggerMap(),
3319
- floatingId,
3320
- syncOnly: false,
3321
- nested
3322
- })).current;
3323
- useIsoLayoutEffect(() => {
3324
- const valuesToSync = {
3325
- open,
3326
- floatingId
3327
- };
3328
- if (elements.reference !== void 0) {
3329
- valuesToSync.referenceElement = elements.reference;
3330
- valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
3331
- }
3332
- if (elements.floating !== void 0) valuesToSync.floatingElement = elements.floating;
3333
- store.update(valuesToSync);
3334
- }, [
3335
- open,
3336
- floatingId,
3337
- elements.reference,
3338
- elements.floating,
3339
- store
3340
- ]);
3341
- store.context.onOpenChange = onOpenChange;
3342
- store.context.nested = nested;
3343
- return store;
3344
- }
3345
2677
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
3346
2678
  var isMacSafari = mac && webkit;
3347
2679
  /**
@@ -3848,473 +3180,52 @@ function useHoverReferenceInteraction(store, props = {}) {
3848
3180
  onPointerDown: setPointerRef,
3849
3181
  onPointerEnter: setPointerRef,
3850
3182
  onMouseMove(event) {
3851
- const { nativeEvent } = event;
3852
- const trigger = event.currentTarget;
3853
- const currentDomReference = store.select("domReferenceElement");
3854
- const currentOpen = store.select("open");
3855
- const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
3856
- if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) return;
3857
- if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
3858
- const floatingElement = store.select("floatingElement");
3859
- if (floatingElement) {
3860
- const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
3861
- applySafePolygonPointerEventsMutation(instance, {
3862
- scopeElement,
3863
- referenceElement: trigger,
3864
- floatingElement
3865
- });
3866
- }
3867
- }
3868
- const restMsValue = getRestMs(restMsRef.current);
3869
- if (currentOpen && !isOverInactive || restMsValue === 0) return;
3870
- if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) return;
3871
- instance.restTimeout.clear();
3872
- function handleMouseMove() {
3873
- instance.restTimeoutPending = false;
3874
- if (isClickLikeOpenEvent$1()) return;
3875
- const latestOpen = store.select("open");
3876
- if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) store.setOpen(true, createChangeEventDetails(triggerHover, nativeEvent, trigger));
3877
- }
3878
- if (instance.pointerType === "touch") import_react_dom.flushSync(() => {
3879
- handleMouseMove();
3880
- });
3881
- else if (isOverInactive && currentOpen) handleMouseMove();
3882
- else {
3883
- instance.restTimeoutPending = true;
3884
- instance.restTimeout.start(restMsValue, handleMouseMove);
3885
- }
3886
- }
3887
- };
3888
- }, [
3889
- enabled,
3890
- instance,
3891
- isClickLikeOpenEvent$1,
3892
- isOverInactiveTrigger,
3893
- mouseOnly,
3894
- store,
3895
- restMsRef,
3896
- checkShouldOpen
3897
- ]);
3898
- }
3899
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useListNavigation.mjs
3900
- function isStationaryWebKitPointer(event) {
3901
- return webkit && event.movementX === 0 && event.movementY === 0;
3902
- }
3903
- function doSwitch(orientation, vertical, horizontal) {
3904
- switch (orientation) {
3905
- case "vertical": return vertical;
3906
- case "horizontal": return horizontal;
3907
- default: return vertical || horizontal;
3908
- }
3909
- }
3910
- function isMainOrientationKey(key, orientation) {
3911
- return doSwitch(orientation, key === "ArrowUp" || key === "ArrowDown", key === "ArrowLeft" || key === "ArrowRight");
3912
- }
3913
- function isMainOrientationToEndKey(key, orientation, rtl) {
3914
- return doSwitch(orientation, key === "ArrowDown", rtl ? key === "ArrowLeft" : key === "ArrowRight") || key === "Enter" || key === " " || key === "";
3915
- }
3916
- function isCrossOrientationOpenKey(key, orientation, rtl) {
3917
- return doSwitch(orientation, rtl ? key === ARROW_LEFT : key === ARROW_RIGHT, key === ARROW_DOWN);
3918
- }
3919
- function isCrossOrientationCloseKey(key, orientation, rtl, grid) {
3920
- const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;
3921
- const horizontal = key === ARROW_UP;
3922
- if (orientation === "both" || orientation === "horizontal" && grid) return key === "Escape";
3923
- return doSwitch(orientation, vertical, horizontal);
3924
- }
3925
- /**
3926
- * Adds arrow key-based navigation of a list of items, either using real DOM
3927
- * focus or virtual focus.
3928
- * @see https://floating-ui.com/docs/useListNavigation
3929
- */
3930
- function useListNavigation(store, props) {
3931
- const { listRef, activeIndex, onNavigate: onNavigateProp = () => {}, enabled = true, selectedIndex = null, allowEscape = false, loopFocus = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = "auto", focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices = void 0, orientation = "vertical", triggerOrientation = orientation, parentOrientation, id, resetOnPointerLeave = true, externalTree, nestedReturnFocusRef, grid: navigateGrid } = props;
3932
- const isGrid = navigateGrid != null;
3933
- const open = store.useState("open");
3934
- const floatingElement = store.useState("floatingElement");
3935
- const domReferenceElement = store.useState("domReferenceElement");
3936
- const dataRef = store.context.dataRef;
3937
- const floatingFocusElement = getFloatingFocusElement(floatingElement);
3938
- const typeableComboboxReference = isTypeableCombobox(domReferenceElement);
3939
- const floatingFocusElementRef = useValueAsRef(floatingFocusElement);
3940
- const parentId = useFloatingParentNodeId();
3941
- const tree = useFloatingTree(externalTree);
3942
- const focusItemOnOpenRef = import_react.useRef(focusItemOnOpen);
3943
- const indexRef = import_react.useRef(selectedIndex ?? -1);
3944
- const keyRef = import_react.useRef(null);
3945
- const isPointerModalityRef = import_react.useRef(true);
3946
- const onNavigate = useStableCallback((event) => {
3947
- onNavigateProp(indexRef.current === -1 ? null : indexRef.current, event);
3948
- });
3949
- const previousMountedRef = import_react.useRef(!!floatingElement);
3950
- const previousOpenRef = import_react.useRef(open);
3951
- const forceSyncFocusRef = import_react.useRef(false);
3952
- const forceScrollIntoViewRef = import_react.useRef(false);
3953
- const cancelQueuedFocusRef = import_react.useRef(null);
3954
- const disabledIndicesRef = useValueAsRef(disabledIndices);
3955
- const latestOpenRef = useValueAsRef(open);
3956
- const selectedIndexRef = useValueAsRef(selectedIndex);
3957
- const resetOnPointerLeaveRef = useValueAsRef(resetOnPointerLeave);
3958
- const focusFrame = useAnimationFrame();
3959
- const waitForListPopulatedFrame = useAnimationFrame();
3960
- const focusItem = useStableCallback(() => {
3961
- focusFrame.cancel();
3962
- function runFocus(item) {
3963
- if (!virtual) cancelQueuedFocusRef.current = enqueueFocus(item, {
3964
- sync: forceSyncFocusRef.current,
3965
- preventScroll: true
3966
- });
3967
- }
3968
- const initialItem = listRef.current[indexRef.current];
3969
- const forceScrollIntoView = forceScrollIntoViewRef.current;
3970
- if (initialItem) runFocus(initialItem);
3971
- (forceSyncFocusRef.current ? (callback) => callback() : (callback) => focusFrame.request(callback))(() => {
3972
- const waitedItem = listRef.current[indexRef.current] || initialItem;
3973
- if (!waitedItem) return;
3974
- if (!initialItem) runFocus(waitedItem);
3975
- if (item && (forceScrollIntoView || !isPointerModalityRef.current)) waitedItem.scrollIntoView?.({
3976
- block: "nearest",
3977
- inline: "nearest"
3978
- });
3979
- });
3980
- });
3981
- useIsoLayoutEffect(() => {
3982
- dataRef.current.orientation = orientation;
3983
- }, [dataRef, orientation]);
3984
- useIsoLayoutEffect(() => {
3985
- if (!open) keyRef.current = null;
3986
- if (!open || focusItemOnOpen !== "auto") focusItemOnOpenRef.current = focusItemOnOpen;
3987
- }, [open, focusItemOnOpen]);
3988
- useIsoLayoutEffect(() => {
3989
- if (!enabled) return;
3990
- if (open && floatingElement) {
3991
- indexRef.current = selectedIndex ?? -1;
3992
- if (focusItemOnOpenRef.current && selectedIndex != null) {
3993
- forceScrollIntoViewRef.current = true;
3994
- onNavigate();
3995
- }
3996
- } else if (previousMountedRef.current) {
3997
- indexRef.current = -1;
3998
- onNavigate();
3999
- }
4000
- }, [
4001
- enabled,
4002
- open,
4003
- floatingElement,
4004
- selectedIndex,
4005
- onNavigate
4006
- ]);
4007
- useIsoLayoutEffect(() => {
4008
- if (!enabled) return;
4009
- if (!open) {
4010
- forceSyncFocusRef.current = false;
4011
- return;
4012
- }
4013
- if (!floatingElement) return;
4014
- if (activeIndex == null) {
4015
- forceSyncFocusRef.current = false;
4016
- if (selectedIndexRef.current != null) return;
4017
- if (previousMountedRef.current) {
4018
- indexRef.current = -1;
4019
- focusItem();
4020
- }
4021
- if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {
4022
- let runs = 0;
4023
- const waitForListPopulated = () => {
4024
- if (listRef.current[0] == null) {
4025
- if (runs < 2) (runs ? (callback) => waitForListPopulatedFrame.request(callback) : queueMicrotask)(waitForListPopulated);
4026
- runs += 1;
4027
- } else {
4028
- indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, triggerOrientation, rtl) || nested ? getMinListIndex(listRef) : getMaxListIndex(listRef);
4029
- keyRef.current = null;
4030
- onNavigate();
4031
- }
4032
- };
4033
- waitForListPopulated();
4034
- }
4035
- } else if (!isIndexOutOfListBounds(listRef.current, activeIndex)) {
4036
- indexRef.current = activeIndex;
4037
- focusItem();
4038
- forceScrollIntoViewRef.current = false;
4039
- }
4040
- }, [
4041
- enabled,
4042
- open,
4043
- floatingElement,
4044
- activeIndex,
4045
- selectedIndexRef,
4046
- nested,
4047
- listRef,
4048
- triggerOrientation,
4049
- rtl,
4050
- onNavigate,
4051
- focusItem,
4052
- waitForListPopulatedFrame
4053
- ]);
4054
- useIsoLayoutEffect(() => {
4055
- if (!enabled || floatingElement || !tree || virtual || !previousMountedRef.current) return;
4056
- const nodes = tree.nodesRef.current;
4057
- const parent = nodes.find((node) => node.id === parentId)?.context?.elements.floating;
4058
- const activeEl = activeElement(ownerDocument(domReferenceElement ?? parent ?? null));
4059
- const treeContainsActiveEl = nodes.some((node) => node.context && contains(node.context.elements.floating, activeEl));
4060
- if (parent && !treeContainsActiveEl && isPointerModalityRef.current) parent.focus({ preventScroll: true });
4061
- }, [
4062
- enabled,
4063
- floatingElement,
4064
- domReferenceElement,
4065
- tree,
4066
- parentId,
4067
- virtual
4068
- ]);
4069
- useIsoLayoutEffect(() => {
4070
- previousOpenRef.current = open;
4071
- previousMountedRef.current = !!floatingElement;
4072
- });
4073
- const hasActiveIndex = activeIndex != null;
4074
- const syncCurrentTarget = useStableCallback((event) => {
4075
- if (!latestOpenRef.current) return;
4076
- const index = listRef.current.indexOf(event.currentTarget);
4077
- if (index !== -1 && (indexRef.current !== index || activeIndex !== index)) {
4078
- indexRef.current = index;
4079
- onNavigate(event);
4080
- }
4081
- });
4082
- const getParentOrientation = useStableCallback(() => {
4083
- return parentOrientation ?? tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.dataRef?.current.orientation;
4084
- });
4085
- const getMinEnabledIndex = useStableCallback(() => {
4086
- return getMinListIndex(listRef, disabledIndicesRef.current);
4087
- });
4088
- const commonOnKeyDown = useStableCallback((event) => {
4089
- isPointerModalityRef.current = false;
4090
- forceSyncFocusRef.current = true;
4091
- if (event.which === 229) return;
4092
- if (!latestOpenRef.current && event.currentTarget === floatingFocusElementRef.current) return;
4093
- if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl, isGrid)) {
4094
- if (!isMainOrientationKey(event.key, getParentOrientation())) stopEvent(event);
4095
- store.setOpen(false, createChangeEventDetails(listNavigation, event.nativeEvent));
4096
- const returnElement = nestedReturnFocusRef?.current ?? domReferenceElement;
4097
- if (isHTMLElement(returnElement)) returnElement.focus();
4098
- return;
4099
- }
4100
- if (activeIndex != null && activeIndex !== indexRef.current && !isIndexOutOfListBounds(listRef.current, activeIndex)) indexRef.current = activeIndex;
4101
- const currentIndex = indexRef.current;
4102
- const minIndex = getMinListIndex(listRef, disabledIndices);
4103
- const maxIndex = getMaxListIndex(listRef, disabledIndices);
4104
- if (!typeableComboboxReference) {
4105
- if (event.key === "Home") {
4106
- stopEvent(event);
4107
- indexRef.current = minIndex;
4108
- onNavigate(event);
4109
- }
4110
- if (event.key === "End") {
4111
- stopEvent(event);
4112
- indexRef.current = maxIndex;
4113
- onNavigate(event);
4114
- }
4115
- }
4116
- if (navigateGrid != null) {
4117
- const index = navigateGrid(event, indexRef.current, listRef, orientation, loopFocus, rtl, disabledIndices, minIndex, maxIndex);
4118
- if (index != null && index !== indexRef.current) {
4119
- indexRef.current = index;
4120
- onNavigate(event);
4121
- }
4122
- if (orientation === "both") return;
4123
- }
4124
- if (isMainOrientationKey(event.key, orientation)) {
4125
- stopEvent(event);
4126
- const focusedElement = activeElement(event.currentTarget.ownerDocument);
4127
- if (open && !virtual && contains(event.currentTarget, focusedElement) && !listRef.current.some((item) => item != null && contains(item, focusedElement))) {
4128
- indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
4129
- onNavigate(event);
4130
- if (activeIndex === indexRef.current) focusItem();
4131
- return;
4132
- }
4133
- const { index, wrapped } = getNextListIndex(listRef.current, currentIndex, {
4134
- decrement: !isMainOrientationToEndKey(event.key, orientation, rtl),
4135
- loopFocus,
4136
- allowEscape,
4137
- disabledIndices,
4138
- minIndex,
4139
- maxIndex
4140
- });
4141
- if (wrapped) forceSyncFocusRef.current = false;
4142
- indexRef.current = index;
4143
- onNavigate(event);
4144
- }
4145
- });
4146
- const item = import_react.useMemo(() => {
4147
- return {
4148
- onFocus(event) {
4149
- forceSyncFocusRef.current = true;
4150
- syncCurrentTarget(event);
4151
- },
4152
- onClick({ currentTarget }) {
4153
- if (!virtual) currentTarget.focus({ preventScroll: true });
4154
- },
4155
- onMouseMove(event) {
4156
- if (isStationaryWebKitPointer(event)) return;
4157
- forceSyncFocusRef.current = true;
4158
- forceScrollIntoViewRef.current = false;
4159
- if (focusItemOnHover) syncCurrentTarget(event);
4160
- },
4161
- onPointerLeave(event) {
4162
- if (!latestOpenRef.current || !isPointerModalityRef.current || event.pointerType === "touch") return;
4163
- forceSyncFocusRef.current = true;
4164
- const relatedTarget = event.relatedTarget;
4165
- if (!focusItemOnHover || listRef.current.includes(relatedTarget)) return;
4166
- if (!resetOnPointerLeaveRef.current) return;
4167
- cancelQueuedFocusRef.current?.();
4168
- cancelQueuedFocusRef.current = null;
4169
- indexRef.current = -1;
4170
- onNavigate(event);
4171
- if (!virtual) {
4172
- const floatingFocusEl = floatingFocusElementRef.current;
4173
- const activeEl = activeElement(ownerDocument(floatingFocusEl));
4174
- if (floatingFocusEl && contains(floatingFocusEl, activeEl)) floatingFocusEl.focus({ preventScroll: true });
4175
- }
4176
- }
4177
- };
4178
- }, [
4179
- syncCurrentTarget,
4180
- latestOpenRef,
4181
- floatingFocusElementRef,
4182
- focusItemOnHover,
4183
- listRef,
4184
- onNavigate,
4185
- resetOnPointerLeaveRef,
4186
- virtual
4187
- ]);
4188
- const ariaActiveDescendantProp = import_react.useMemo(() => {
4189
- return virtual && open && hasActiveIndex && { "aria-activedescendant": `${id}-${activeIndex}` };
4190
- }, [
4191
- virtual,
4192
- open,
4193
- hasActiveIndex,
4194
- id,
4195
- activeIndex
4196
- ]);
4197
- const floating = import_react.useMemo(() => {
4198
- return {
4199
- ...!typeableComboboxReference ? ariaActiveDescendantProp : {},
4200
- onKeyDown(event) {
4201
- if (event.key === "Tab" && event.shiftKey && open && !virtual) {
4202
- const target = getTarget(event.nativeEvent);
4203
- if (target && !contains(floatingFocusElementRef.current, target)) return;
4204
- stopEvent(event);
4205
- const details = createChangeEventDetails(focusOut, event.nativeEvent);
4206
- store.setOpen(false, details);
4207
- const returnElement = nestedReturnFocusRef?.current ?? domReferenceElement;
4208
- if (!details.isCanceled && isHTMLElement(returnElement)) returnElement.focus();
4209
- return;
4210
- }
4211
- commonOnKeyDown(event);
4212
- },
4213
- onPointerMove(event) {
4214
- if (isStationaryWebKitPointer(event)) return;
4215
- isPointerModalityRef.current = true;
4216
- }
4217
- };
4218
- }, [
4219
- ariaActiveDescendantProp,
4220
- commonOnKeyDown,
4221
- floatingFocusElementRef,
4222
- typeableComboboxReference,
4223
- store,
4224
- open,
4225
- virtual,
4226
- domReferenceElement,
4227
- nestedReturnFocusRef
4228
- ]);
4229
- const trigger = import_react.useMemo(() => {
4230
- function openOnNavigationKeyDown(event) {
4231
- store.setOpen(true, createChangeEventDetails(listNavigation, event.nativeEvent, event.currentTarget));
4232
- }
4233
- function checkVirtualMouse(event) {
4234
- if (focusItemOnOpen === "auto" && isVirtualClick(event.nativeEvent)) focusItemOnOpenRef.current = !virtual;
4235
- }
4236
- function checkVirtualPointer(event) {
4237
- focusItemOnOpenRef.current = focusItemOnOpen;
4238
- if (focusItemOnOpen === "auto" && isVirtualPointerEvent(event.nativeEvent)) focusItemOnOpenRef.current = true;
4239
- }
4240
- return {
4241
- onKeyDown(event) {
3183
+ const { nativeEvent } = event;
3184
+ const trigger = event.currentTarget;
3185
+ const currentDomReference = store.select("domReferenceElement");
4242
3186
  const currentOpen = store.select("open");
4243
- isPointerModalityRef.current = false;
4244
- const isArrowKey = event.key.startsWith("Arrow");
4245
- const isParentCrossOpenKey = isCrossOrientationOpenKey(event.key, getParentOrientation(), rtl);
4246
- const isMainKey = isMainOrientationKey(event.key, currentOpen ? orientation : triggerOrientation);
4247
- const isNavigationKey = (nested ? isParentCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === "";
4248
- if (virtual && currentOpen && (!nested || isTypeableElement(event.currentTarget))) return commonOnKeyDown(event);
4249
- if (!currentOpen && !openOnArrowKeyDown && isArrowKey) return;
4250
- if (isNavigationKey) {
4251
- const isParentMainKey = isMainOrientationKey(event.key, getParentOrientation());
4252
- keyRef.current = nested && isParentMainKey ? null : event.key;
4253
- }
4254
- if (nested) {
4255
- if (isParentCrossOpenKey) {
4256
- stopEvent(event);
4257
- if (currentOpen) {
4258
- indexRef.current = getMinEnabledIndex();
4259
- onNavigate(event);
4260
- if (virtual) floatingFocusElementRef.current?.focus();
4261
- } else openOnNavigationKeyDown(event);
3187
+ const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
3188
+ if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) return;
3189
+ if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
3190
+ const floatingElement = store.select("floatingElement");
3191
+ if (floatingElement) {
3192
+ const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
3193
+ applySafePolygonPointerEventsMutation(instance, {
3194
+ scopeElement,
3195
+ referenceElement: trigger,
3196
+ floatingElement
3197
+ });
4262
3198
  }
4263
- return;
4264
3199
  }
4265
- if (isMainKey) {
4266
- if (selectedIndexRef.current != null) indexRef.current = selectedIndexRef.current;
4267
- stopEvent(event);
4268
- if (!currentOpen && openOnArrowKeyDown) openOnNavigationKeyDown(event);
4269
- else commonOnKeyDown(event);
4270
- if (currentOpen) onNavigate(event);
3200
+ const restMsValue = getRestMs(restMsRef.current);
3201
+ if (currentOpen && !isOverInactive || restMsValue === 0) return;
3202
+ if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) return;
3203
+ instance.restTimeout.clear();
3204
+ function handleMouseMove() {
3205
+ instance.restTimeoutPending = false;
3206
+ if (isClickLikeOpenEvent$1()) return;
3207
+ const latestOpen = store.select("open");
3208
+ if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) store.setOpen(true, createChangeEventDetails(triggerHover, nativeEvent, trigger));
4271
3209
  }
4272
- },
4273
- onFocus(event) {
4274
- if (event.target !== event.currentTarget) return;
4275
- if (store.select("open") && !virtual) {
4276
- indexRef.current = -1;
4277
- onNavigate(event);
3210
+ if (instance.pointerType === "touch") import_react_dom.flushSync(() => {
3211
+ handleMouseMove();
3212
+ });
3213
+ else if (isOverInactive && currentOpen) handleMouseMove();
3214
+ else {
3215
+ instance.restTimeoutPending = true;
3216
+ instance.restTimeout.start(restMsValue, handleMouseMove);
4278
3217
  }
4279
- },
4280
- onPointerDown: checkVirtualPointer,
4281
- onPointerEnter: checkVirtualPointer,
4282
- onMouseDown: checkVirtualMouse,
4283
- onClick: checkVirtualMouse
3218
+ }
4284
3219
  };
4285
3220
  }, [
4286
- commonOnKeyDown,
4287
- focusItemOnOpen,
4288
- getMinEnabledIndex,
4289
- nested,
4290
- onNavigate,
4291
- store,
4292
- openOnArrowKeyDown,
4293
- orientation,
4294
- triggerOrientation,
4295
- getParentOrientation,
4296
- rtl,
4297
- selectedIndexRef,
4298
- virtual,
4299
- floatingFocusElementRef
4300
- ]);
4301
- const reference = import_react.useMemo(() => {
4302
- return {
4303
- ...ariaActiveDescendantProp,
4304
- ...trigger
4305
- };
4306
- }, [ariaActiveDescendantProp, trigger]);
4307
- return import_react.useMemo(() => enabled ? {
4308
- reference,
4309
- floating,
4310
- item,
4311
- trigger
4312
- } : {}, [
4313
3221
  enabled,
4314
- reference,
4315
- floating,
4316
- trigger,
4317
- item
3222
+ instance,
3223
+ isClickLikeOpenEvent$1,
3224
+ isOverInactiveTrigger,
3225
+ mouseOnly,
3226
+ store,
3227
+ restMsRef,
3228
+ checkShouldOpen
4318
3229
  ]);
4319
3230
  }
4320
3231
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
@@ -6781,6 +5692,99 @@ function Tooltip({ label, children, side = "right", disabled = false, className
6781
5692
  }) })]
6782
5693
  });
6783
5694
  }
5695
+ // src/stores/connection.ts
5696
+ /** The page's connection state, for Studio's own components. */
5697
+ var useConnectionState = create(() => ({ state: "online" }));
5698
+ var FIRST_RETRY_MS = 1e3;
5699
+ var MAX_RETRY_MS = 3e4;
5700
+ var browserTimers = {
5701
+ set: (run, ms) => setTimeout(run, ms),
5702
+ clear: (handle) => clearTimeout(handle)
5703
+ };
5704
+ /**
5705
+ * Tracks the page's connection: a suspected failure starts a probe and only the probe's result
5706
+ * changes the state. While not online it probes again with backoff; on recovery it refetches
5707
+ * every query before telling subscribers.
5708
+ */
5709
+ function createConnectionMonitor({ queryClient, probe = () => probeStudio(), target = window, isVisible = () => document.visibilityState === "visible", timers = browserTimers }) {
5710
+ const listeners = /* @__PURE__ */ new Set();
5711
+ let probing = false;
5712
+ let retry = null;
5713
+ let delay = FIRST_RETRY_MS;
5714
+ let disposed = false;
5715
+ const settle = (next) => {
5716
+ if (disposed) return;
5717
+ const changed = next !== useConnectionState.getState().state;
5718
+ if (next === "online") delay = FIRST_RETRY_MS;
5719
+ else {
5720
+ retry = timers.set(() => {
5721
+ retry = null;
5722
+ run();
5723
+ }, delay);
5724
+ delay = Math.min(delay * 2, MAX_RETRY_MS);
5725
+ }
5726
+ if (!changed) return;
5727
+ useConnectionState.setState({ state: next });
5728
+ if (next === "online") queryClient.invalidateQueries();
5729
+ for (const listener of listeners) try {
5730
+ listener(next);
5731
+ } catch (error) {
5732
+ console.error(error);
5733
+ }
5734
+ };
5735
+ const run = async () => {
5736
+ if (probing || disposed) return;
5737
+ if (retry !== null) {
5738
+ timers.clear(retry);
5739
+ retry = null;
5740
+ }
5741
+ probing = true;
5742
+ let next;
5743
+ try {
5744
+ next = await probe();
5745
+ } catch {
5746
+ next = "offline";
5747
+ } finally {
5748
+ probing = false;
5749
+ }
5750
+ settle(next);
5751
+ };
5752
+ const now = () => void run();
5753
+ const onVisible = () => {
5754
+ if (isVisible()) now();
5755
+ };
5756
+ target.addEventListener("online", now);
5757
+ target.addEventListener("visibilitychange", onVisible);
5758
+ return {
5759
+ state: () => useConnectionState.getState().state,
5760
+ suspect() {
5761
+ if (retry !== null) return;
5762
+ now();
5763
+ },
5764
+ subscribe(listener) {
5765
+ listeners.add(listener);
5766
+ return () => void listeners.delete(listener);
5767
+ },
5768
+ dispose() {
5769
+ disposed = true;
5770
+ if (retry !== null) timers.clear(retry);
5771
+ target.removeEventListener("online", now);
5772
+ target.removeEventListener("visibilitychange", onVisible);
5773
+ listeners.clear();
5774
+ }
5775
+ };
5776
+ }
5777
+ var current = null;
5778
+ /** Starts the page's one monitor; browser only, so SSR never touches `window`. */
5779
+ function startConnectionMonitor(options) {
5780
+ current?.dispose();
5781
+ current = createConnectionMonitor(options);
5782
+ return current;
5783
+ }
5784
+ /** The page's monitor; `null` during SSR and before the router started it. */
5785
+ function studioConnection() {
5786
+ return current;
5787
+ }
6784
5788
  // src/stores/page-ui.ts
6785
5789
  var toastTimer;
6786
5790
  var reportTimer;
@@ -6839,8 +5843,10 @@ function useStudioEvents(digest) {
6839
5843
  const queryClient = useQueryClient();
6840
5844
  (0, import_react.useEffect)(() => {
6841
5845
  if (!digest || typeof EventSource === "undefined") return;
6842
- const source = new EventSource(`${STUDIO_EVENTS_ROUTE}?companion=${encodeURIComponent(digest)}`);
6843
- source.addEventListener("message", (message) => {
5846
+ const connection = studioConnection();
5847
+ let source;
5848
+ let waiting = null;
5849
+ const onMessage = (message) => {
6844
5850
  let event;
6845
5851
  try {
6846
5852
  event = JSON.parse(message.data);
@@ -6853,8 +5859,27 @@ function useStudioEvents(digest) {
6853
5859
  title: event.title
6854
5860
  });
6855
5861
  afterEvent(queryClient, digest, event.type);
6856
- });
6857
- return () => source.close();
5862
+ };
5863
+ const onError = () => {
5864
+ connection?.suspect();
5865
+ if (source.readyState !== EventSource.CLOSED || !connection || waiting) return;
5866
+ waiting = connection.subscribe((state) => {
5867
+ if (state !== "online") return;
5868
+ waiting?.();
5869
+ waiting = null;
5870
+ open();
5871
+ });
5872
+ };
5873
+ const open = () => {
5874
+ source = new EventSource(`${STUDIO_EVENTS_ROUTE}?companion=${encodeURIComponent(digest)}`);
5875
+ source.addEventListener("message", onMessage);
5876
+ source.addEventListener("error", onError);
5877
+ };
5878
+ open();
5879
+ return () => {
5880
+ waiting?.();
5881
+ source.close();
5882
+ };
6858
5883
  }, [digest, queryClient]);
6859
5884
  }
6860
5885
  // src/lib/page-actions.ts
@@ -7049,14 +6074,6 @@ var useAppearance = create((set, get) => ({
7049
6074
  set({ rail: next });
7050
6075
  }
7051
6076
  }));
7052
- // ../../node_modules/.bun/@base-ui+utils@0.5.0+9e489665888c9e4a/node_modules/@base-ui/utils/useOnFirstRender.mjs
7053
- function useOnFirstRender(fn) {
7054
- const ref = import_react.useRef(true);
7055
- if (ref.current) {
7056
- ref.current = false;
7057
- fn();
7058
- }
7059
- }
7060
6077
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/gridNavigation.mjs
7061
6078
  /**
7062
6079
  * Positional arguments are deliberate: property names of an options object
@@ -7123,134 +6140,6 @@ function useComboboxInputValueContext() {
7123
6140
  function useComboboxHasItemsContext() {
7124
6141
  return import_react.useContext(ComboboxHasItemsContext);
7125
6142
  }
7126
- // ../../node_modules/.bun/@base-ui+utils@0.5.0+9e489665888c9e4a/node_modules/@base-ui/utils/areArraysEqual.mjs
7127
- /**
7128
- * Compares two arrays element-wise.
7129
- *
7130
- * The default comparison is `Object.is`, so `NaN` equals `NaN` and `0` does not equal `-0`.
7131
- */
7132
- function areArraysEqual(array1, array2, itemComparer = Object.is) {
7133
- const { length } = array1;
7134
- if (length !== array2.length) return false;
7135
- for (let i = 0; i < length; i += 1) if (!itemComparer(array1[i], array2[i])) return false;
7136
- return true;
7137
- }
7138
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/internals/itemEquality.mjs
7139
- var defaultItemEquality = (itemValue, selectedValue) => Object.is(itemValue, selectedValue);
7140
- function compareItemEquality(itemValue, selectedValue, comparer) {
7141
- if (itemValue == null || selectedValue == null) return Object.is(itemValue, selectedValue);
7142
- return comparer(itemValue, selectedValue);
7143
- }
7144
- function isSelectedValueDirty(currentValue, initialValue, comparer) {
7145
- if (Array.isArray(currentValue) && Array.isArray(initialValue)) return !areArraysEqual(currentValue, initialValue, (itemValue, initialItemValue) => compareItemEquality(itemValue, initialItemValue, comparer));
7146
- return currentValue !== initialValue;
7147
- }
7148
- function selectedValueIncludes(selectedValues, itemValue, comparer) {
7149
- if (!selectedValues) return false;
7150
- return selectedValues.some((selectedValue) => {
7151
- if (selectedValue === void 0) return false;
7152
- return compareItemEquality(itemValue, selectedValue, comparer);
7153
- });
7154
- }
7155
- function findItemIndex(itemValues, selectedValue, comparer) {
7156
- if (!itemValues) return -1;
7157
- return itemValues.findIndex((itemValue) => {
7158
- if (itemValue === void 0) return false;
7159
- return compareItemEquality(itemValue, selectedValue, comparer);
7160
- });
7161
- }
7162
- function createSelectionMatcher(selectedValues, comparer) {
7163
- if (comparer !== defaultItemEquality) return (itemValue) => selectedValueIncludes(selectedValues, itemValue, comparer);
7164
- const index = new Set(selectedValues);
7165
- index.delete(void 0);
7166
- return (itemValue) => index.has(itemValue) && (itemValue !== 0 || selectedValues.some((v) => Object.is(itemValue, v)));
7167
- }
7168
- function findSelectionIndex(itemValues, selectedValue, comparer, multiple) {
7169
- const index = multiple && Array.isArray(selectedValue) ? itemValues.findIndex(createSelectionMatcher(selectedValue, comparer)) : findItemIndex(itemValues, selectedValue, comparer);
7170
- return index === -1 ? null : index;
7171
- }
7172
- /** Resolves the first selected index as items register or change. */
7173
- function resolveSelectedIndex(index, itemValue, registry, selectedValues, comparer, currentIndex) {
7174
- if (selectedValueIncludes(selectedValues, itemValue, comparer)) return currentIndex != null && index > currentIndex && selectedValueIncludes(selectedValues, registry[currentIndex], comparer) ? currentIndex : index;
7175
- return index === currentIndex ? findSelectionIndex(registry, selectedValues, comparer, true) : currentIndex;
7176
- }
7177
- function removeItem(selectedValues, itemValue, comparer) {
7178
- return selectedValues.filter((selectedValue) => !compareItemEquality(itemValue, selectedValue, comparer));
7179
- }
7180
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/internals/serializeValue.mjs
7181
- function serializeValue(value) {
7182
- if (value == null) return "";
7183
- if (typeof value === "string") return value;
7184
- try {
7185
- return JSON.stringify(value);
7186
- } catch {
7187
- return String(value);
7188
- }
7189
- }
7190
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/internals/resolveValueLabel.mjs
7191
- function isGroup(item) {
7192
- return typeof item === "object" && item != null && Array.isArray(item.items);
7193
- }
7194
- function isGroupedItems(items) {
7195
- return isGroup(items?.[0]);
7196
- }
7197
- function flattenLeafItems(items) {
7198
- return isGroupedItems(items) ? items.flatMap((group) => group.items) : items;
7199
- }
7200
- /**
7201
- * Checks if the items array contains an item with a null value that has a non-null label.
7202
- */
7203
- function hasNullItemLabel(items) {
7204
- if (!Array.isArray(items)) return items != null && "null" in items;
7205
- const arrayItems = items;
7206
- if (isGroupedItems(arrayItems)) {
7207
- for (const group of arrayItems) for (const item of group.items) if (item && item.value == null && item.label != null) return true;
7208
- return false;
7209
- }
7210
- for (const item of arrayItems) if (item && item.value == null && item.label != null) return true;
7211
- return false;
7212
- }
7213
- function stringifyAsLabel(item, itemToStringLabel) {
7214
- if (itemToStringLabel && item != null) return itemToStringLabel(item) ?? "";
7215
- if (item && typeof item === "object") {
7216
- if ("label" in item && item.label != null) return String(item.label);
7217
- if ("value" in item) return String(item.value);
7218
- }
7219
- return serializeValue(item);
7220
- }
7221
- function stringifyAsValue(item, itemToStringValue) {
7222
- if (itemToStringValue && item != null) return itemToStringValue(item) ?? "";
7223
- if (item && typeof item === "object" && "value" in item && "label" in item) return serializeValue(item.value);
7224
- return serializeValue(item);
7225
- }
7226
- function resolveSelectedLabel(value, items, itemToStringLabel) {
7227
- function fallback() {
7228
- return stringifyAsLabel(value, itemToStringLabel);
7229
- }
7230
- if (itemToStringLabel && value != null) return itemToStringLabel(value);
7231
- if (value && typeof value === "object" && "label" in value && value.label != null) return value.label;
7232
- if (items && !Array.isArray(items)) return (Object.hasOwn(items, value) ? items[value] : void 0) ?? fallback();
7233
- if (Array.isArray(items)) {
7234
- const flatItems = flattenLeafItems(items);
7235
- if (value == null || typeof value !== "object") {
7236
- const match = flatItems.find((item) => item.value === value);
7237
- if (match && match.label != null) return match.label;
7238
- return fallback();
7239
- }
7240
- if ("value" in value) {
7241
- const match = flatItems.find((item) => item && item.value === value.value);
7242
- if (match && match.label != null) return match.label;
7243
- }
7244
- }
7245
- return fallback();
7246
- }
7247
- function resolveMultipleLabels(values, items, itemToStringLabel) {
7248
- return values.reduce((acc, value, index) => {
7249
- if (index > 0) acc.push(", ");
7250
- acc.push(/*#__PURE__*/ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: resolveSelectedLabel(value, items, itemToStringLabel) }, index));
7251
- return acc;
7252
- }, []);
7253
- }
7254
6143
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/combobox/store.mjs
7255
6144
  /**
7256
6145
  * Non-reactive values shared with the combobox parts. Nothing here is observable through
@@ -7384,60 +6273,6 @@ function getFilter(options = {}) {
7384
6273
  * Matches items against a query using `Intl.Collator` for robust string matching.
7385
6274
  */
7386
6275
  var useCoreFilter = getFilter;
7387
- // ../../node_modules/.bun/@base-ui+utils@0.5.0+9e489665888c9e4a/node_modules/@base-ui/utils/useEnhancedClickHandler.mjs
7388
- /**
7389
- * Provides a cross-browser way to determine the type of the pointer used to click.
7390
- * Safari and Firefox do not provide the PointerEvent to the click handler (they use MouseEvent) yet.
7391
- * Additionally, this implementation detects if the click was triggered by the keyboard.
7392
- *
7393
- * @param handler The function to be called when the button is clicked. The first parameter is the original event and the second parameter is the pointer type.
7394
- */
7395
- function useEnhancedClickHandler(handler) {
7396
- const lastClickInteractionTypeRef = import_react.useRef("");
7397
- const handlePointerDown = import_react.useCallback((event) => {
7398
- if (event.defaultPrevented) return;
7399
- lastClickInteractionTypeRef.current = event.pointerType;
7400
- handler(event, event.pointerType);
7401
- }, [handler]);
7402
- return {
7403
- onClick: import_react.useCallback((event) => {
7404
- if (event.detail === 0) {
7405
- handler(event, "keyboard");
7406
- return;
7407
- }
7408
- if ("pointerType" in event) handler(event, event.pointerType);
7409
- else handler(event, lastClickInteractionTypeRef.current);
7410
- lastClickInteractionTypeRef.current = "";
7411
- }, [handler]),
7412
- onPointerDown: handlePointerDown
7413
- };
7414
- }
7415
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/useOpenInteractionType.mjs
7416
- function useOpenMethodTriggerProps(open, setOpenMethod) {
7417
- const { onClick, onPointerDown } = useEnhancedClickHandler(useStableCallback((_, interactionType) => {
7418
- if (!(typeof open === "function" ? open() : open)) setOpenMethod(interactionType || (ios ? "touch" : ""));
7419
- }));
7420
- return import_react.useMemo(() => ({
7421
- onClick,
7422
- onPointerDown
7423
- }), [onClick, onPointerDown]);
7424
- }
7425
- /**
7426
- * Determines the interaction type (keyboard, mouse, touch, etc.) that opened the component.
7427
- *
7428
- * @param open The open state of the component.
7429
- */
7430
- function useOpenInteractionType(open) {
7431
- const [openMethod, setOpenMethod] = import_react.useState(null);
7432
- const triggerProps = useOpenMethodTriggerProps(open, setOpenMethod);
7433
- useValueChanged(open, (previousOpen) => {
7434
- if (previousOpen && !open) setOpenMethod(null);
7435
- });
7436
- return import_react.useMemo(() => ({
7437
- openMethod,
7438
- triggerProps
7439
- }), [openMethod, triggerProps]);
7440
- }
7441
6276
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/scrollable.mjs
7442
6277
  function isScrollableY(element, allowOverflowIntent = false) {
7443
6278
  const { overflowY } = getComputedStyle$1(element);
@@ -8874,30 +7709,6 @@ function useInitialLiveRegionTextMutation(present = true) {
8874
7709
  ]);
8875
7710
  return rootRef;
8876
7711
  }
8877
- // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/useAnchoredPopupScrollLock.mjs
8878
- var VIEWPORT_WIDTH_TOLERANCE_PX = 20;
8879
- /**
8880
- * Manages scroll lock for anchored popups. For non-touch opens, scroll lock is applied when
8881
- * enabled. For touch opens, scroll lock is applied only when the positioner width is effectively
8882
- * viewport-sized.
8883
- */
8884
- function useAnchoredPopupScrollLock(enabled, touchOpen, positionerElement, referenceElement) {
8885
- const [touchOpenShouldLockScroll, setTouchOpenShouldLockScroll] = import_react.useState(false);
8886
- useIsoLayoutEffect(() => {
8887
- if (!enabled || !touchOpen || positionerElement == null) {
8888
- setTouchOpenShouldLockScroll(false);
8889
- return;
8890
- }
8891
- const viewportWidth = ownerDocument(positionerElement).documentElement.clientWidth;
8892
- const popupWidth = positionerElement.offsetWidth;
8893
- setTouchOpenShouldLockScroll(viewportWidth > 0 && popupWidth > 0 && popupWidth >= viewportWidth - VIEWPORT_WIDTH_TOLERANCE_PX);
8894
- }, [
8895
- enabled,
8896
- touchOpen,
8897
- positionerElement
8898
- ]);
8899
- useScrollLock(enabled && (!touchOpen || touchOpenShouldLockScroll), referenceElement);
8900
- }
8901
7712
  // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/combobox/group/ComboboxGroupContext.mjs
8902
7713
  var ComboboxGroupContext = /*#__PURE__*/ import_react.createContext(void 0);
8903
7714
  function useComboboxGroupContext() {
@@ -9123,7 +7934,8 @@ function ComboboxItemVirtualizedIndex(props) {
9123
7934
  const { componentProps, forwardedRef } = props;
9124
7935
  const isItemEqualToValue = useComboboxRootContext().useState("isItemEqualToValue");
9125
7936
  const { flatFilteredValues } = useComboboxDerivedItemsContext();
9126
- const indexFromFilter = findItemIndex(flatFilteredValues, componentProps.value ?? null, isItemEqualToValue);
7937
+ const lookupValue = componentProps.value ?? null;
7938
+ const indexFromFilter = findItemIndex(flatFilteredValues, lookupValue, isItemEqualToValue);
9127
7939
  return /*#__PURE__*/ (0, import_jsx_runtime.jsx)(ComboboxItemInner, {
9128
7940
  componentProps,
9129
7941
  forwardedRef,
@@ -9866,7 +8678,11 @@ var LIBRARY_ORDER = [
9866
8678
  "vault",
9867
8679
  "graph"
9868
8680
  ];
9869
- var INSIGHTS_ORDER = ["usage", "reports"];
8681
+ var INSIGHTS_ORDER = [
8682
+ "usage",
8683
+ "friction",
8684
+ "reports"
8685
+ ];
9870
8686
  var VIEW_ICONS = {
9871
8687
  dashboard: "home",
9872
8688
  workflow: "flow",
@@ -9876,6 +8692,7 @@ var VIEW_ICONS = {
9876
8692
  vault: "folder",
9877
8693
  reports: "chart",
9878
8694
  usage: "chart",
8695
+ friction: "alert",
9879
8696
  graph: "graph"
9880
8697
  };
9881
8698
  /** Core's views in Studio's order; a view the order does not name yet goes last, never missing. */
@@ -10403,7 +9220,8 @@ var PopoverTrigger$1 = fastComponentRef(function PopoverTrigger(componentProps,
10403
9220
  isActiveTrigger: isTriggerActive,
10404
9221
  isClosing: () => store.select("transitionStatus") === "ending"
10405
9222
  });
10406
- const click = useClick(floatingContext, { stickIfOpen: useStableCallback(() => store.context.stickIfOpen) });
9223
+ const getStickIfOpen = useStableCallback(() => store.context.stickIfOpen);
9224
+ const click = useClick(floatingContext, { stickIfOpen: getStickIfOpen });
10407
9225
  const interactionTypeProps = useOpenMethodTriggerProps(() => store.select("open"), (interactionType) => {
10408
9226
  store.set("openMethod", interactionType);
10409
9227
  });
@@ -10937,6 +9755,209 @@ function AddCompanionDialog({ open, onClose, onAdded }) {
10937
9755
  })
10938
9756
  });
10939
9757
  }
9758
+ // src/components/friction-recording.tsx
9759
+ var REACH = "friction-recording-reach";
9760
+ function RecordingState({ recording }) {
9761
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StatusWord, {
9762
+ marker: recording ? "build" : "idle",
9763
+ children: ["Recording is ", recording ? "on" : "off"]
9764
+ });
9765
+ }
9766
+ function RecordingReach() {
9767
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9768
+ id: REACH,
9769
+ className: "m-0 text-xs text-muted",
9770
+ children: "Applies to all companions on the machine that runs Studio."
9771
+ });
9772
+ }
9773
+ /** A successful Retry removes itself; focus then goes to the recording button. */
9774
+ function useRetryFocus(isSuccess) {
9775
+ const button = (0, import_react.useRef)(null);
9776
+ const retried = (0, import_react.useRef)(false);
9777
+ (0, import_react.useEffect)(() => {
9778
+ if (!isSuccess || !retried.current) return;
9779
+ retried.current = false;
9780
+ button.current?.focus();
9781
+ }, [isSuccess]);
9782
+ return {
9783
+ button,
9784
+ retried: () => {
9785
+ retried.current = true;
9786
+ }
9787
+ };
9788
+ }
9789
+ /** With `recording` unknown, the button is disabled and claims neither state. */
9790
+ function RecordingButton({ recording, toggle, ref }) {
9791
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
9792
+ ref,
9793
+ size: "sm",
9794
+ variant: recording === false ? "primary" : "default",
9795
+ disabled: recording === void 0 || toggle.pending,
9796
+ "aria-describedby": REACH,
9797
+ onClick: () => toggle.onChange(!recording),
9798
+ children: recording === void 0 ? "Turn recording on or off" : `Turn recording ${recording ? "off" : "on"}`
9799
+ });
9800
+ }
9801
+ // src/server/friction.ts
9802
+ function validateFrictionInput(input) {
9803
+ if (typeof input?.companion !== "string" || !COMPANION_DIGEST_PATTERN.test(input.companion)) throw new Error("No registered companion was selected");
9804
+ const days = frictionViewDays(input.days);
9805
+ if (!days) throw new Error(`The friction period is one of ${FRICTION_VIEW_DAYS.join(", ")} days`);
9806
+ return {
9807
+ companion: input.companion,
9808
+ days
9809
+ };
9810
+ }
9811
+ function validateRecordingInput(input) {
9812
+ if (typeof input?.recording !== "boolean") throw new Error("Recording is on or off");
9813
+ return { recording: input.recording };
9814
+ }
9815
+ var getFriction = createServerFn({ method: "GET" }).validator(validateFrictionInput).handler(createSsrRpc("3d0d77471aa778cecabd4e5db91ab864e236510fba212a7e364cf9ee35750729"));
9816
+ var getFrictionRecording = createServerFn({ method: "GET" }).handler(createSsrRpc("f1599335a08f9f65c30311d4e51c4cfad933345d616c61c8945d5183444c2503"));
9817
+ var setFrictionRecording = createServerFn({ method: "POST" }).validator(validateRecordingInput).handler(createSsrRpc("129eb7026f249381cdf25972dd63a821750853b2ea77ea3a1fdd22b56f1b24ec"));
9818
+ var optionalText = (value, name) => {
9819
+ if (value === void 0) return void 0;
9820
+ if (typeof value !== "string") throw new Error(`The ${name} is text`);
9821
+ return value;
9822
+ };
9823
+ function validateMarkInput(input) {
9824
+ if (typeof input?.target !== "string" || input.target === "") throw new Error("A mark names a fingerprint or a report");
9825
+ const state = oneOf(MARK_STATES, input.state);
9826
+ if (!state) throw new Error(`A mark sets one of ${MARK_STATES.join(", ")}`);
9827
+ return {
9828
+ target: input.target,
9829
+ state,
9830
+ note: optionalText(input.note, "note"),
9831
+ link: optionalText(input.link, "link")
9832
+ };
9833
+ }
9834
+ var markFriction = createServerFn({ method: "POST" }).validator(validateMarkInput).handler(createSsrRpc("e257827a07a72fbb27ff303a6d721f51ae699f21ddaaa8fb7b1f33203d573c56"));
9835
+ // src/lib/friction-query.ts
9836
+ var SCOPE = "friction";
9837
+ var MACHINE_WIDE = "machine";
9838
+ var frictionKey = (owner, ...rest) => [
9839
+ owner,
9840
+ SCOPE,
9841
+ ...rest
9842
+ ];
9843
+ var isFrictionQuery = ({ queryKey: [, scope] }) => scope === SCOPE;
9844
+ var frictionQuery = (companion, days) => queryOptions({
9845
+ queryKey: frictionKey(companion, days),
9846
+ queryFn: () => getFriction({ data: {
9847
+ companion,
9848
+ days
9849
+ } }),
9850
+ retry: false,
9851
+ refetchOnWindowFocus: false
9852
+ });
9853
+ var frictionRecordingQuery = queryOptions({
9854
+ queryKey: frictionKey(MACHINE_WIDE, "recording"),
9855
+ queryFn: () => getFrictionRecording(),
9856
+ retry: false,
9857
+ refetchOnWindowFocus: false
9858
+ });
9859
+ var RECORDING_CHANGE = [SCOPE, "set-recording"];
9860
+ function useSetFrictionRecording() {
9861
+ const client = useQueryClient();
9862
+ const pending = useIsMutating({ mutationKey: RECORDING_CHANGE }) > 0;
9863
+ const change = useMutation({
9864
+ mutationKey: RECORDING_CHANGE,
9865
+ mutationFn: (recording) => setFrictionRecording({ data: { recording } }),
9866
+ onSuccess: async ({ recording }) => {
9867
+ await client.cancelQueries({ predicate: isFrictionQuery });
9868
+ client.setQueriesData({ predicate: isFrictionQuery }, (held) => held && {
9869
+ ...held,
9870
+ recording
9871
+ });
9872
+ return client.invalidateQueries({ predicate: isFrictionQuery });
9873
+ }
9874
+ });
9875
+ return {
9876
+ pending,
9877
+ error: change.isError ? `Recording could not be turned ${change.variables ? "on" : "off"}: ${change.error.message}` : void 0,
9878
+ onChange: (recording) => change.mutate(recording)
9879
+ };
9880
+ }
9881
+ function useMarkFriction() {
9882
+ const client = useQueryClient();
9883
+ return useMutation({
9884
+ mutationKey: [SCOPE, "mark"],
9885
+ mutationFn: (mark) => markFriction({ data: mark }),
9886
+ onSuccess: async (result) => {
9887
+ if (!result.ok) return;
9888
+ await client.cancelQueries({ predicate: isFrictionQuery });
9889
+ await client.invalidateQueries({ predicate: isFrictionQuery });
9890
+ }
9891
+ }).mutateAsync;
9892
+ }
9893
+ // src/lib/use-browser.ts
9894
+ var subscribe$1 = () => () => {};
9895
+ /**
9896
+ * `true` once the page runs in the browser. Queries the shell starts only for counts wait for
9897
+ * it, so the server-rendered document never holds its stream open for them.
9898
+ */
9899
+ function useBrowser() {
9900
+ return (0, import_react.useSyncExternalStore)(subscribe$1, () => true, () => false);
9901
+ }
9902
+ // src/shell/global-features.tsx
9903
+ function RecordingRow({ status, note, action }) {
9904
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9905
+ className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-4 py-3",
9906
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9907
+ className: "grid min-w-0 flex-[1_1_16rem] gap-0.5",
9908
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9909
+ className: "flex flex-wrap items-center gap-x-3 gap-y-0.5",
9910
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", {
9911
+ className: "text-sm font-semibold",
9912
+ children: "Friction recording"
9913
+ }), status]
9914
+ }), note]
9915
+ }), action]
9916
+ });
9917
+ }
9918
+ function GlobalFeatures() {
9919
+ const query = useQuery({
9920
+ ...frictionRecordingQuery,
9921
+ enabled: useBrowser()
9922
+ });
9923
+ const toggle = useSetFrictionRecording();
9924
+ const { button: recordingButton, retried } = useRetryFocus(query.isSuccess);
9925
+ const recording = query.data?.recording;
9926
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ListCard, {
9927
+ title: "Global features",
9928
+ children: [query.isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingRow, {
9929
+ note: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9930
+ className: "m-0 text-xs text-bad",
9931
+ role: "alert",
9932
+ children: "The recording state could not be read."
9933
+ }),
9934
+ action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
9935
+ size: "sm",
9936
+ disabled: query.isFetching,
9937
+ onClick: () => {
9938
+ retried();
9939
+ query.refetch();
9940
+ },
9941
+ children: "Retry"
9942
+ })
9943
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingRow, {
9944
+ status: recording === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
9945
+ className: "text-xs text-muted",
9946
+ children: "Checking…"
9947
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingState, { recording }),
9948
+ note: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingReach, {}),
9949
+ action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingButton, {
9950
+ ref: recordingButton,
9951
+ recording,
9952
+ toggle
9953
+ })
9954
+ }), toggle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9955
+ className: "m-0 border-t border-rule-soft px-4 py-2 text-sm wrap-anywhere text-bad",
9956
+ role: "alert",
9957
+ children: toggle.error
9958
+ }) : null]
9959
+ });
9960
+ }
10940
9961
  // src/shell/companion-picker.tsx
10941
9962
  var svgUri = (svg) => `data:image/svg+xml;base64,${btoa(svg)}`;
10942
9963
  var SYMBOL_COLOR_URI = svgUri(BRAND_SVGS.symbolColor);
@@ -11306,60 +10327,92 @@ function CompanionSwitcher({ companions, selected, writable = false, addsCompani
11306
10327
  addsCompanions && writable ? adding.dialog : null
11307
10328
  ] });
11308
10329
  }
11309
- /** The page while no companion is selected: every registered companion, and how to add one. */
11310
10330
  function CompanionPicker({ companions, writable = false, addsCompanions = false }) {
11311
10331
  const select = useSelectCompanion();
11312
10332
  const prefetch = usePrefetchCompanion();
11313
10333
  const deletion = useCompanionDeletion(null);
11314
10334
  const adding = useCompanionAdd();
11315
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
11316
- className: "mx-auto grid w-full max-w-[760px] gap-5 px-8 py-16 max-sm:px-4",
11317
- "aria-label": "Companion Repositories",
11318
- children: [
11319
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
11320
- className: "grid gap-1.5",
11321
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
11322
- className: "m-0 text-[1.7rem] font-semibold tracking-[-0.02em]",
11323
- children: companions.length === 0 ? "No Companion Repository" : "Choose a Companion Repository"
11324
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
11325
- className: "m-0 text-muted",
11326
- children: companions.length === 0 ? "No Companion Repository is registered on this machine." : "Studio serves one companion at a time, and remembers the one you choose for your next visit."
11327
- })]
11328
- }),
11329
- companions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
11330
- className: "overflow-hidden rounded-card border border-rule",
11331
- children: companions.map((companion) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompanionRow, {
11332
- companion,
11333
- selected: false,
11334
- roomy: true,
11335
- onChoose: () => select(companion.digest),
11336
- onIntent: () => prefetch(companion.digest),
11337
- writable,
11338
- onDelete: () => deletion.ask(companion)
11339
- }, companion.digest))
11340
- }) : null,
11341
- addsCompanions && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
11342
- type: "button",
11343
- "data-add-companion": "",
11344
- onClick: adding.ask,
11345
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "plus" }), "Add companion…"]
11346
- }) }) : null,
11347
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
11348
- className: "m-0 text-sm text-muted",
11349
- children: [
11350
- "To add one, run",
11351
- " ",
11352
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
11353
- className: "rounded-[6px] border border-rule bg-surface px-1.5 font-mono text-xs",
11354
- children: "mate companion setup"
11355
- }),
11356
- " ",
11357
- "in a Working Repository."
11358
- ]
11359
- }),
11360
- deletion.dialog,
11361
- addsCompanions && writable ? adding.dialog : null
11362
- ]
10335
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
10336
+ className: "mx-auto grid w-full max-w-[760px] gap-8 px-8 py-16 max-sm:px-4",
10337
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlobalFeatures, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
10338
+ className: "grid gap-5",
10339
+ "aria-label": "Companion Repositories",
10340
+ children: [
10341
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
10342
+ className: "grid gap-1.5",
10343
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
10344
+ className: "m-0 text-[1.7rem] font-semibold tracking-[-0.02em]",
10345
+ children: companions.length === 0 ? "No Companion Repository" : "Choose a Companion Repository"
10346
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
10347
+ className: "m-0 text-muted",
10348
+ children: companions.length === 0 ? "No Companion Repository is registered on this machine." : "Studio serves one companion at a time, and remembers the one you choose for your next visit."
10349
+ })]
10350
+ }),
10351
+ companions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
10352
+ className: "overflow-hidden rounded-card border border-rule",
10353
+ children: companions.map((companion) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompanionRow, {
10354
+ companion,
10355
+ selected: false,
10356
+ roomy: true,
10357
+ onChoose: () => select(companion.digest),
10358
+ onIntent: () => prefetch(companion.digest),
10359
+ writable,
10360
+ onDelete: () => deletion.ask(companion)
10361
+ }, companion.digest))
10362
+ }) : null,
10363
+ addsCompanions && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
10364
+ type: "button",
10365
+ "data-add-companion": "",
10366
+ onClick: adding.ask,
10367
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "plus" }), "Add companion…"]
10368
+ }) }) : null,
10369
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
10370
+ className: "m-0 text-sm text-muted",
10371
+ children: [
10372
+ "To add one, run",
10373
+ " ",
10374
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
10375
+ className: "rounded-[6px] border border-rule bg-surface px-1.5 font-mono text-xs",
10376
+ children: "mate companion setup"
10377
+ }),
10378
+ " ",
10379
+ "in a Working Repository."
10380
+ ]
10381
+ }),
10382
+ deletion.dialog,
10383
+ addsCompanions && writable ? adding.dialog : null
10384
+ ]
10385
+ })]
10386
+ });
10387
+ }
10388
+ // src/shell/connection-banner.tsx
10389
+ var MESSAGES = {
10390
+ offline: "Connection to Studio lost",
10391
+ "signed-out": "Connection to Studio lost — reload to sign in again",
10392
+ expired: "Session expired — open the address Studio printed when it started",
10393
+ "host-refused": "Studio does not answer to this host"
10394
+ };
10395
+ var reloadPage = () => location.reload();
10396
+ /**
10397
+ * Above the view while the page has lost Studio; the view and its data stay. Reloading is the
10398
+ * person's choice, so an unsaved edit is never lost to it.
10399
+ */
10400
+ function ConnectionBanner({ reload = reloadPage }) {
10401
+ const state = useConnectionState((current) => current.state);
10402
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
10403
+ role: "status",
10404
+ "aria-live": "polite",
10405
+ children: state === "online" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
10406
+ className: "mx-8 mt-3 flex items-center gap-3 rounded-card border border-warn bg-warn-soft px-4 py-2.5 text-sm max-sm:mx-4",
10407
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
10408
+ className: "flex-1",
10409
+ children: MESSAGES[state]
10410
+ }), state === "host-refused" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
10411
+ size: "sm",
10412
+ onClick: reload,
10413
+ children: "Reload"
10414
+ })]
10415
+ })
11363
10416
  });
11364
10417
  }
11365
10418
  // src/shell/navigation-progress.tsx
@@ -11393,15 +10446,6 @@ function ViewPlaceholder() {
11393
10446
  ]
11394
10447
  });
11395
10448
  }
11396
- // src/lib/use-browser.ts
11397
- var subscribe$1 = () => () => {};
11398
- /**
11399
- * `true` once the page runs in the browser. Queries the shell starts only for counts wait for
11400
- * it, so the server-rendered document never holds its stream open for them.
11401
- */
11402
- function useBrowser() {
11403
- return (0, import_react.useSyncExternalStore)(subscribe$1, () => true, () => false);
11404
- }
11405
10449
  // src/shell/sidebar.tsx
11406
10450
  var MODE_ICONS = {
11407
10451
  engineering: "code",
@@ -12110,7 +11154,7 @@ function useTerminalSessions() {
12110
11154
  const sessions = useQuery({
12111
11155
  queryKey: sessionsKey,
12112
11156
  queryFn: async () => {
12113
- const response = await fetch(TERMINAL_SESSIONS_ROUTE, { credentials: "same-origin" });
11157
+ const response = await studioFetch(TERMINAL_SESSIONS_ROUTE);
12114
11158
  return response.ok ? (await response.json()).sessions : [];
12115
11159
  },
12116
11160
  refetchInterval: 5e3
@@ -12215,12 +11259,13 @@ function useTerminalClient(mount, companion) {
12215
11259
  * A direct grid child of `.shell`: sticky positioning breaks under an ancestor that sets
12216
11260
  * `overflow`. Lives in the root layout, so its session survives navigation between views.
12217
11261
  */
12218
- function TerminalSidebar({ terminal }) {
11262
+ function TerminalSidebar({ terminal, heldBy }) {
12219
11263
  const target = terminal.target;
12220
11264
  const mount = (0, import_react.useRef)(null);
12221
11265
  const { client, state, status, reconnectable, choice, setChoice } = useTerminalClient(mount, target?.digest ?? "");
12222
11266
  const { sessions, end } = useTerminalSessions();
12223
11267
  const ui = useTerminalUi();
11268
+ const collapsed = ui.collapsed || Boolean(heldBy);
12224
11269
  (0, import_react.useEffect)(() => {
12225
11270
  if (!ui.drawerOpen) return;
12226
11271
  const close = (event) => {
@@ -12245,9 +11290,9 @@ function TerminalSidebar({ terminal }) {
12245
11290
  className: ICON_BUTTON,
12246
11291
  id: "terminal-expand",
12247
11292
  "aria-controls": "terminal-body",
12248
- "aria-expanded": !ui.collapsed,
11293
+ "aria-expanded": !collapsed,
12249
11294
  "aria-label": "Expand the terminal",
12250
- onClick: () => ui.setCollapsed(false),
11295
+ onClick: () => heldBy ? ui.release(heldBy) : ui.setCollapsed(false),
12251
11296
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "left" })
12252
11297
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
12253
11298
  className: "terminal-dot",
@@ -12277,7 +11322,7 @@ function TerminalSidebar({ terminal }) {
12277
11322
  className: ICON_BUTTON,
12278
11323
  id: "terminal-collapse",
12279
11324
  "aria-controls": "terminal-body",
12280
- "aria-expanded": !ui.collapsed,
11325
+ "aria-expanded": !collapsed,
12281
11326
  "aria-label": "Collapse the terminal",
12282
11327
  onClick: () => ui.setCollapsed(true),
12283
11328
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "right" })
@@ -12469,11 +11514,18 @@ function StudioLayout({ search }) {
12469
11514
  const view = useMatches({ select: (matches) => matches.findLast((match) => match.staticData.view)?.staticData.view }) ?? "dashboard";
12470
11515
  const pluginParams = useMatches({ select: (matches) => matches.findLast((match) => match.staticData.pluginView)?.params });
12471
11516
  const pluginView = pluginParams ? shell.pluginViews.find((entry) => entry.service === pluginParams.service && entry.view === pluginParams.view) : void 0;
11517
+ const workspace = pluginView?.layout === "workspace";
11518
+ const workspaceKey = pluginView ? `${pluginView.service}/${pluginView.view}` : null;
11519
+ const released = useTerminalUi((state) => state.released);
11520
+ const held = heldBy(workspace ? workspaceKey : null, released);
12472
11521
  const digest = shell.selected?.digest;
12473
11522
  useStudioEvents(digest);
12474
11523
  useStudioClicks();
12475
11524
  useRailKey();
12476
11525
  usePrefetchViews(shell.selected ? search : {}, shell.studioMode, shell.enabledModes);
11526
+ (0, import_react.useEffect)(() => {
11527
+ useTerminalUi.getState().setWorkspace(workspace ? workspaceKey : null);
11528
+ }, [workspace, workspaceKey]);
12477
11529
  (0, import_react.useEffect)(() => {
12478
11530
  if (!digest) return;
12479
11531
  try {
@@ -12486,6 +11538,7 @@ function StudioLayout({ search }) {
12486
11538
  "data-companion": digest,
12487
11539
  "data-terminal": shell.terminal ? "" : void 0,
12488
11540
  "data-picker": shell.selected ? void 0 : "",
11541
+ "data-terminal-held": held ? "" : void 0,
12489
11542
  children: [
12490
11543
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NavigationProgress, {}),
12491
11544
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TopBar, {
@@ -12497,10 +11550,10 @@ function StudioLayout({ search }) {
12497
11550
  search,
12498
11551
  view
12499
11552
  }) : null,
12500
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("main", {
11553
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", {
12501
11554
  className: "studio-main flex min-h-0 min-w-0 flex-col overflow-auto",
12502
11555
  id: "studio-main",
12503
- children: shell.selected ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
11556
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectionBanner, {}), shell.selected && workspace ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Outlet, {}) : shell.selected ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
12504
11557
  title: pluginView ? pluginView.label : VIEW_TITLES[view],
12505
11558
  description: pluginView ? pluginView.description ?? "" : VIEW_DESCRIPTIONS[shell.studioMode][view]
12506
11559
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
@@ -12510,9 +11563,12 @@ function StudioLayout({ search }) {
12510
11563
  companions: shell.companions,
12511
11564
  writable: shell.writable,
12512
11565
  addsCompanions: shell.addsCompanions
12513
- })
11566
+ })]
12514
11567
  }),
12515
- shell.terminal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TerminalSidebar, { terminal: shell.terminal }) : null
11568
+ shell.terminal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TerminalSidebar, {
11569
+ terminal: shell.terminal,
11570
+ heldBy: held
11571
+ }) : null
12516
11572
  ]
12517
11573
  }),
12518
11574
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommandPalette, {
@@ -12552,7 +11608,7 @@ function Toasts({ search }) {
12552
11608
  }
12553
11609
  // src/routes/__root.tsx
12554
11610
  var FAVICON_URI = `data:image/svg+xml;base64,${btoa(BRAND_SVGS.favicon)}`;
12555
- var Route$12 = createRootRouteWithContext()({
11611
+ var Route$13 = createRootRouteWithContext()({
12556
11612
  validateSearch: validateStudioSearch,
12557
11613
  loaderDeps: ({ search }) => search,
12558
11614
  ssr: true,
@@ -12593,7 +11649,7 @@ var Route$12 = createRootRouteWithContext()({
12593
11649
  component: RootLayout
12594
11650
  });
12595
11651
  function RootLayout() {
12596
- const { companion, studioMode } = Route$12.useSearch();
11652
+ const { companion, studioMode } = Route$13.useSearch();
12597
11653
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StudioLayout, { search: {
12598
11654
  companion,
12599
11655
  studioMode
@@ -12606,8 +11662,8 @@ function RootDocument({ children }) {
12606
11662
  });
12607
11663
  }
12608
11664
  // src/routes/index.tsx
12609
- var $$splitComponentImporter$11 = () => import("./routes-Cok4p3mK.js");
12610
- var Route$11 = createFileRoute("/")({
11665
+ var $$splitComponentImporter$12 = () => import("./routes-CwH8LEy2.js");
11666
+ var Route$12 = createFileRoute("/")({
12611
11667
  staticData: { view: "dashboard" },
12612
11668
  validateSearch: (raw) => typeof raw.change === "string" && raw.change !== "" ? { change: raw.change } : {},
12613
11669
  loaderDeps: ({ search }) => ({
@@ -12616,9 +11672,20 @@ var Route$11 = createFileRoute("/")({
12616
11672
  }),
12617
11673
  ssr: true,
12618
11674
  loader: async ({ context, deps }) => await registeredCompanion(context.queryClient, deps) ? loadView(context.queryClient, companionViewQuery("dashboard", deps)) : null,
12619
- component: lazyRouteComponent($$splitComponentImporter$11, "component")
11675
+ component: lazyRouteComponent($$splitComponentImporter$12, "component")
12620
11676
  });
12621
11677
  /** Each mode reads its own Overview; the server's effective mode picks it, not the address. */
11678
+ // src/routes/friction.tsx
11679
+ var $$splitComponentImporter$11 = () => import("./friction-9a5S1m7U.js");
11680
+ var Route$11 = createFileRoute("/friction")({
11681
+ staticData: { view: "friction" },
11682
+ loaderDeps: ({ search }) => ({
11683
+ companion: search.companion,
11684
+ studioMode: search.studioMode
11685
+ }),
11686
+ loader: ({ context, deps }) => registeredCompanion(context.queryClient, deps),
11687
+ component: lazyRouteComponent($$splitComponentImporter$11, "component")
11688
+ });
12622
11689
  // src/routes/getting-started.tsx
12623
11690
  var $$splitComponentImporter$10 = () => import("./getting-started-B136TP57.js");
12624
11691
  var Route$10 = createFileRoute("/getting-started")({
@@ -12627,7 +11694,7 @@ var Route$10 = createFileRoute("/getting-started")({
12627
11694
  component: lazyRouteComponent($$splitComponentImporter$10, "component")
12628
11695
  });
12629
11696
  // src/routes/graph.tsx
12630
- var $$splitComponentImporter$9 = () => import("./graph-DSDVEELZ.js").then((n) => n.t);
11697
+ var $$splitComponentImporter$9 = () => import("./graph-CZ2H9Fzr.js").then((n) => n.t);
12631
11698
  var text$1 = (value) => typeof value === "string" && value.length > 0 && value.length <= 1024 ? value : void 0;
12632
11699
  var Route$9 = createFileRoute("/graph")({
12633
11700
  validateSearch: (raw) => text$1(raw.node) ? { node: text$1(raw.node) } : {},
@@ -12636,7 +11703,7 @@ var Route$9 = createFileRoute("/graph")({
12636
11703
  component: lazyRouteComponent($$splitComponentImporter$9, "component")
12637
11704
  });
12638
11705
  // src/routes/reports.tsx
12639
- var $$splitComponentImporter$8 = () => import("./reports-7yaPz7aP.js");
11706
+ var $$splitComponentImporter$8 = () => import("./reports-C2SmTgqh.js");
12640
11707
  var Route$8 = createFileRoute("/reports")({
12641
11708
  staticData: { view: "reports" },
12642
11709
  loaderDeps: ({ search }) => ({
@@ -12650,7 +11717,7 @@ var Route$8 = createFileRoute("/reports")({
12650
11717
  component: lazyRouteComponent($$splitComponentImporter$8, "component")
12651
11718
  });
12652
11719
  // src/routes/skills.tsx
12653
- var $$splitComponentImporter$7 = () => import("./skills-D8qdXSku.js");
11720
+ var $$splitComponentImporter$7 = () => import("./skills-C21Mg_8-.js");
12654
11721
  var Route$7 = createFileRoute("/skills")({
12655
11722
  staticData: { view: "skills" },
12656
11723
  loaderDeps: ({ search }) => ({
@@ -12662,7 +11729,7 @@ var Route$7 = createFileRoute("/skills")({
12662
11729
  component: lazyRouteComponent($$splitComponentImporter$7, "component")
12663
11730
  });
12664
11731
  // src/routes/specs.tsx
12665
- var $$splitComponentImporter$6 = () => import("./specs-DeHYUNFp.js");
11732
+ var $$splitComponentImporter$6 = () => import("./specs-DetoMiaB.js");
12666
11733
  var Route$6 = createFileRoute("/specs")({
12667
11734
  staticData: { view: "specs" },
12668
11735
  validateSearch: validateSpecsSearch,
@@ -12675,7 +11742,7 @@ var Route$6 = createFileRoute("/specs")({
12675
11742
  component: lazyRouteComponent($$splitComponentImporter$6, "component")
12676
11743
  });
12677
11744
  // src/routes/usage.tsx
12678
- var $$splitComponentImporter$5 = () => import("./usage-M6Gi6Km7.js");
11745
+ var $$splitComponentImporter$5 = () => import("./usage-CS4CBK9D.js");
12679
11746
  var Route$5 = createFileRoute("/usage")({
12680
11747
  staticData: { view: "usage" },
12681
11748
  loaderDeps: ({ search }) => ({
@@ -12686,7 +11753,7 @@ var Route$5 = createFileRoute("/usage")({
12686
11753
  component: lazyRouteComponent($$splitComponentImporter$5, "component")
12687
11754
  });
12688
11755
  // src/routes/vault.tsx
12689
- var $$splitComponentImporter$4 = () => import("./vault-PqVmssmW.js");
11756
+ var $$splitComponentImporter$4 = () => import("./vault-DVQidlId.js");
12690
11757
  var text = (value) => typeof value === "string" && value ? value : void 0;
12691
11758
  var Route$4 = createFileRoute("/vault")({
12692
11759
  staticData: { view: "vault" },
@@ -12708,7 +11775,7 @@ var Route$4 = createFileRoute("/vault")({
12708
11775
  component: lazyRouteComponent($$splitComponentImporter$4, "component")
12709
11776
  });
12710
11777
  // src/routes/workflow.tsx
12711
- var $$splitComponentImporter$3 = () => import("./workflow-T0eEldsa.js");
11778
+ var $$splitComponentImporter$3 = () => import("./workflow-6dZZ1ofw.js");
12712
11779
  var Route$3 = createFileRoute("/workflow")({
12713
11780
  staticData: { view: "workflow" },
12714
11781
  loaderDeps: ({ search }) => ({
@@ -12720,7 +11787,7 @@ var Route$3 = createFileRoute("/workflow")({
12720
11787
  component: lazyRouteComponent($$splitComponentImporter$3, "component")
12721
11788
  });
12722
11789
  // src/routes/getting-started.index.tsx
12723
- var $$splitComponentImporter$2 = () => import("./getting-started.index-CeGtvUsm.js");
11790
+ var $$splitComponentImporter$2 = () => import("./getting-started.index-EzLRosbb.js");
12724
11791
  var Route$2 = createFileRoute("/getting-started/")({
12725
11792
  loaderDeps: ({ search }) => search,
12726
11793
  ssr: true,
@@ -12728,7 +11795,7 @@ var Route$2 = createFileRoute("/getting-started/")({
12728
11795
  component: lazyRouteComponent($$splitComponentImporter$2, "component")
12729
11796
  });
12730
11797
  // src/routes/getting-started.$topic.tsx
12731
- var $$splitComponentImporter$1 = () => import("./getting-started._topic-B1mV0kGz.js");
11798
+ var $$splitComponentImporter$1 = () => import("./getting-started._topic-C02HGrC6.js");
12732
11799
  var Route$1 = createFileRoute("/getting-started/$topic")({
12733
11800
  loaderDeps: ({ search }) => search,
12734
11801
  ssr: true,
@@ -12736,57 +11803,62 @@ var Route$1 = createFileRoute("/getting-started/$topic")({
12736
11803
  component: lazyRouteComponent($$splitComponentImporter$1, "component")
12737
11804
  });
12738
11805
  // src/routes/plugins.$service.$view.tsx
12739
- var $$splitComponentImporter = () => import("./plugins._service._view-DwqJX7s9.js");
11806
+ var $$splitComponentImporter = () => import("./plugins._service._view-n7u2k5dF.js");
12740
11807
  /** A view a plugin service ships as its own module; Studio mounts it in the layout. */
12741
11808
  var Route = createFileRoute("/plugins/$service/$view")({
12742
11809
  staticData: { pluginView: true },
12743
11810
  component: lazyRouteComponent($$splitComponentImporter, "component")
12744
11811
  });
12745
11812
  // src/route-tree.gen.ts
12746
- var IndexRoute = Route$11.update({
11813
+ var IndexRoute = Route$12.update({
12747
11814
  id: "/",
12748
11815
  path: "/",
12749
- getParentRoute: () => Route$12
11816
+ getParentRoute: () => Route$13
11817
+ });
11818
+ var FrictionRoute = Route$11.update({
11819
+ id: "/friction",
11820
+ path: "/friction",
11821
+ getParentRoute: () => Route$13
12750
11822
  });
12751
11823
  var GettingStartedRoute = Route$10.update({
12752
11824
  id: "/getting-started",
12753
11825
  path: "/getting-started",
12754
- getParentRoute: () => Route$12
11826
+ getParentRoute: () => Route$13
12755
11827
  });
12756
11828
  var GraphRoute = Route$9.update({
12757
11829
  id: "/graph",
12758
11830
  path: "/graph",
12759
- getParentRoute: () => Route$12
11831
+ getParentRoute: () => Route$13
12760
11832
  });
12761
11833
  var ReportsRoute = Route$8.update({
12762
11834
  id: "/reports",
12763
11835
  path: "/reports",
12764
- getParentRoute: () => Route$12
11836
+ getParentRoute: () => Route$13
12765
11837
  });
12766
11838
  var SkillsRoute = Route$7.update({
12767
11839
  id: "/skills",
12768
11840
  path: "/skills",
12769
- getParentRoute: () => Route$12
11841
+ getParentRoute: () => Route$13
12770
11842
  });
12771
11843
  var SpecsRoute = Route$6.update({
12772
11844
  id: "/specs",
12773
11845
  path: "/specs",
12774
- getParentRoute: () => Route$12
11846
+ getParentRoute: () => Route$13
12775
11847
  });
12776
11848
  var UsageRoute = Route$5.update({
12777
11849
  id: "/usage",
12778
11850
  path: "/usage",
12779
- getParentRoute: () => Route$12
11851
+ getParentRoute: () => Route$13
12780
11852
  });
12781
11853
  var VaultRoute = Route$4.update({
12782
11854
  id: "/vault",
12783
11855
  path: "/vault",
12784
- getParentRoute: () => Route$12
11856
+ getParentRoute: () => Route$13
12785
11857
  });
12786
11858
  var WorkflowRoute = Route$3.update({
12787
11859
  id: "/workflow",
12788
11860
  path: "/workflow",
12789
- getParentRoute: () => Route$12
11861
+ getParentRoute: () => Route$13
12790
11862
  });
12791
11863
  var GettingStartedIndexRoute = Route$2.update({
12792
11864
  id: "/",
@@ -12801,7 +11873,7 @@ var GettingStartedTopicRoute = Route$1.update({
12801
11873
  var PluginsServiceViewRoute = Route.update({
12802
11874
  id: "/plugins/$service/$view",
12803
11875
  path: "/plugins/$service/$view",
12804
- getParentRoute: () => Route$12
11876
+ getParentRoute: () => Route$13
12805
11877
  });
12806
11878
  var GettingStartedRouteChildren = {
12807
11879
  GettingStartedTopicRoute,
@@ -12809,6 +11881,7 @@ var GettingStartedRouteChildren = {
12809
11881
  };
12810
11882
  var rootRouteChildren = {
12811
11883
  IndexRoute,
11884
+ FrictionRoute,
12812
11885
  GettingStartedRoute: GettingStartedRoute._addFileChildren(GettingStartedRouteChildren),
12813
11886
  GraphRoute,
12814
11887
  ReportsRoute,
@@ -12819,15 +11892,31 @@ var rootRouteChildren = {
12819
11892
  WorkflowRoute,
12820
11893
  PluginsServiceViewRoute
12821
11894
  };
12822
- var routeTree = Route$12._addFileChildren(rootRouteChildren)._addFileTypes();
11895
+ var routeTree = Route$13._addFileChildren(rootRouteChildren)._addFileTypes();
11896
+ // src/lib/query-client.ts
11897
+ /**
11898
+ * The page's query client. In the browser every failed query or mutation makes the page's
11899
+ * connection monitor probe; during SSR there is no monitor, so `window` stays untouched.
11900
+ */
11901
+ function createStudioQueryClient() {
11902
+ let monitor = null;
11903
+ const suspect = () => monitor?.suspect();
11904
+ const queryClient = new QueryClient({
11905
+ queryCache: new QueryCache({ onError: suspect }),
11906
+ mutationCache: new MutationCache({ onError: suspect }),
11907
+ defaultOptions: { queries: {
11908
+ staleTime: 5e3,
11909
+ gcTime: Infinity
11910
+ } }
11911
+ });
11912
+ if (typeof window !== "undefined") monitor = startConnectionMonitor({ queryClient });
11913
+ return queryClient;
11914
+ }
12823
11915
  // src/router.tsx
12824
11916
  var router_exports = /* @__PURE__ */ __exportAll({ getRouter: () => getRouter });
12825
11917
  /** One router and query client per request on the server, one per page in the browser. */
12826
11918
  function getRouter() {
12827
- const queryClient = new QueryClient({ defaultOptions: { queries: {
12828
- staleTime: 5e3,
12829
- gcTime: Infinity
12830
- } } });
11919
+ const queryClient = createStudioQueryClient();
12831
11920
  const router = createRouter({
12832
11921
  routeTree,
12833
11922
  context: { queryClient },
@@ -12841,4 +11930,4 @@ function getRouter() {
12841
11930
  });
12842
11931
  return router;
12843
11932
  }
12844
- export { findItemIndex as $, DialogBackdrop as A, useListEmpty as B, groupChanges as C, DialogPortal as D, DialogRoot as E, ComboboxList as F, getComboboxPopupId as G, triggerStateAttributesMapping as H, ComboboxInput as I, resolveSelectedLabel as J, hasNullItemLabel as K, ComboboxInternalDismissButton as L, ComboboxItem as M, useComboboxItemContext as N, DialogPopup as O, useAnchoredPopupScrollLock as P, defaultItemEquality as Q, ComboboxPositionerContext as R, changeStep as S, useSuspenseQuery as St, DialogTitle$1 as T, AriaCombobox as U, usePopupSide as V, useOpenInteractionType as W, stringifyAsValue as X, stringifyAsLabel as Y, compareItemEquality as Z, GROUP_TITLES as _, useFloatingRootContext as _t, Route$3 as a, useComboboxInputValueContext as at, changePath as b, SERVICE_ROUTE_PREFIX as bt, Route$6 as c, useAppearance as ct, Route$9 as d, Tooltip as dt, findSelectionIndex as et, Route$11 as f, usePositioner as ft, CHANGE_GROUPS as g, getRouter, useListNavigation as gt, useMediaQuery as h, platform as ht, Route$2 as i, useComboboxFloatingContext as it, ComboboxEmpty as j, DialogClose$1 as k, Route$7 as l, useVaultUi as lt, ViewPlaceholder as m, useAnchorPositioning as mt, Route as n, removeItem as nt, Route$4 as o, useComboboxRootContext as ot, useBrowser as p, getDisabledMountTransitionStyles as pt, resolveMultipleLabels as q, Route$1 as r, resolveSelectedIndex as rt, Route$5 as s, useOnFirstRender as st, router_exports as t, isSelectedValueDirty as tt, Route$8 as u, usePageUi as ut, activeChanges as v, useClick as vt, inField as w, changeProgress as x, useMutation as xt, changeGroup as y, REPORT_VIEW_PREFIX as yt, useComboboxPositionerContext as z };
11933
+ export { useComboboxInputValueContext as $, changeStep as A, ComboboxItem as B, useMediaQuery as C, changeGroup as D, activeChanges as E, DialogPortal as F, ComboboxPositionerContext as G, ComboboxList as H, DialogPopup as I, usePopupSide as J, useComboboxPositionerContext as K, DialogClose$1 as L, inField as M, DialogTitle$1 as N, changePath as O, DialogRoot as P, useComboboxFloatingContext as Q, DialogBackdrop as R, useRetryFocus as S, GROUP_TITLES as T, ComboboxInput as U, useComboboxItemContext as V, ComboboxInternalDismissButton as W, AriaCombobox as X, triggerStateAttributesMapping as Y, getComboboxPopupId as Z, useMarkFriction as _, Route$3 as a, Tooltip as at, RecordingReach as b, Route$6 as c, useAnchorPositioning as ct, Route$9 as d, useComboboxRootContext as et, Route$11 as f, frictionQuery as g, getRouter, useBrowser as h, Route$2 as i, studioConnection as it, groupChanges as j, changeProgress as k, Route$7 as l, platform as lt, ViewPlaceholder as m, Route as n, useVaultUi as nt, Route$4 as o, usePositioner as ot, Route$12 as p, useListEmpty as q, Route$1 as r, usePageUi as rt, Route$5 as s, getDisabledMountTransitionStyles as st, router_exports as t, useAppearance as tt, Route$8 as u, useSuspenseQuery as ut, useSetFrictionRecording as v, CHANGE_GROUPS as w, RecordingState as x, RecordingButton as y, ComboboxEmpty as z };