@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
@@ -0,0 +1,943 @@
1
+ import { S as useRetryFocus, _ as useMarkFriction, b as RecordingReach, f as Route, g as frictionQuery, h as useBrowser, v as useSetFrictionRecording, x as RecordingState, y as RecordingButton } from "./router-CPt0TAk_.js";
2
+ import { B as keepPreviousData } from "./studio-queries-Dqf-3nzj.js";
3
+ import { Lr as useQuery, et as CommandLine, it as PAGE_PAD, lt as StatusWord, nt as EmptyNote, ot as Pills, r as Icon, rt as ListCard, t as Button, tt as Count, ut as ViewLoading } from "./button-D6bvrFmm.js";
4
+ import { _ as REPORT_KINDS, h as FRICTION_STATES, m as selectFriction$1, y as SUBJECT_TYPES } from "./studio-qRvQjRpz.js";
5
+ import { n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
6
+ import { a as Select, c as SelectTrigger, l as SelectValue, o as SelectContent, s as SelectItem } from "./select-C3i6TTX-.js";
7
+ import { t as cn } from "./cn-FXJAM0KO.js";
8
+ import { a as FRICTION_VIEW_DAYS, n as oneOf } from "./search-b-yQesv3.js";
9
+ import { t as Input } from "./fields-B4mAPETz.js";
10
+ // ../mate-core/src/runtime/framework.ts
11
+ /**
12
+ * Framework identity: names everything identity-shaped — state directories
13
+ * (`~/.mate`, `.mate/`), managed-block markers, `MATE_*` env values, usage
14
+ * output, command hints, error prefixes, agent guidance, and permission
15
+ * entries. The distribution is always invoked as `mate`.
16
+ *
17
+ * Lives under `runtime/` because the import-isolated runtime subpath derives
18
+ * repo-local `.mate/` paths from it; `../framework` re-exports it.
19
+ */
20
+ var FRAMEWORK_NAME = "mate";
21
+ // ../mate-core/src/runtime/command-arg.ts
22
+ /**
23
+ * Quotes one argument of a command a person pastes into a shell. Plain words stay bare and double
24
+ * quotes are used where cmd.exe, PowerShell and POSIX shells all keep the text unchanged; any
25
+ * other text falls back to POSIX single quotes.
26
+ */
27
+ function quoteCommandArg(value) {
28
+ if (/^[\w:./+=-]+$/.test(value)) return value;
29
+ if (!/["$`\\!%]/.test(value)) return `"${value}"`;
30
+ return `'${value.replaceAll("'", `'\\''`)}'`;
31
+ }
32
+ /** One command line from its words, each quoted with `quoteCommandArg`. */
33
+ function formatCommand(words) {
34
+ return words.map(quoteCommandArg).join(" ");
35
+ }
36
+ // src/views/friction/mark-actions.tsx
37
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
38
+ var import_jsx_runtime = require_jsx_runtime();
39
+ var STATE_WORDS = {
40
+ fixed: {
41
+ label: "Fixed",
42
+ marker: "done"
43
+ },
44
+ reported: {
45
+ label: "Reported",
46
+ marker: "review"
47
+ },
48
+ dismissed: {
49
+ label: "Dismissed",
50
+ marker: "idle"
51
+ }
52
+ };
53
+ var BY = {
54
+ person: "by a person",
55
+ triage: "by triage",
56
+ studio: "in Studio"
57
+ };
58
+ var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
59
+ /** The item's Friction State as one word with its marker; nothing for an unmarked item. */
60
+ function StateWord({ state }) {
61
+ if (!state) return null;
62
+ const word = STATE_WORDS[state.state];
63
+ return state.reopened ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusWord, {
64
+ marker: "warn",
65
+ children: "Reopened"
66
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusWord, {
67
+ marker: word.marker,
68
+ children: word.label
69
+ });
70
+ }
71
+ function ItemState({ state, time }) {
72
+ const word = STATE_WORDS[state.state];
73
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
74
+ className: "m-0 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-muted",
75
+ children: [
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateWord, { state }),
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
78
+ state.reopened ? "Fixed, then recorded again; marked " : `${word.label} `,
79
+ BY[state.by],
80
+ " ",
81
+ time
82
+ ] }),
83
+ state.state === "reported" && state.eventsSince !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
84
+ className: "tabular-nums",
85
+ children: [plural(state.eventsSince, "event"), " since reported"]
86
+ }) : null,
87
+ state.link ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
88
+ href: state.link,
89
+ target: "_blank",
90
+ rel: "noreferrer",
91
+ className: "text-text underline",
92
+ children: state.link
93
+ }) : null,
94
+ state.note ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
95
+ className: "text-text",
96
+ children: state.note
97
+ }) : null
98
+ ]
99
+ });
100
+ }
101
+ var NOTE = {
102
+ label: "Note (optional)",
103
+ key: "note",
104
+ type: "text"
105
+ };
106
+ var MARKS = {
107
+ fixed: {
108
+ action: "Mark fixed",
109
+ field: NOTE
110
+ },
111
+ reported: {
112
+ action: "Mark reported",
113
+ field: {
114
+ label: "Issue link (optional)",
115
+ key: "link",
116
+ type: "url"
117
+ }
118
+ },
119
+ dismissed: {
120
+ action: "Dismiss",
121
+ field: NOTE
122
+ }
123
+ };
124
+ function MarkActions({ name, handled, onMark }) {
125
+ const [draft, setDraft] = (0, import_react.useState)(null);
126
+ const [text, setText] = (0, import_react.useState)("");
127
+ const [pending, setPending] = (0, import_react.useState)(false);
128
+ const [refusal, setRefusal] = (0, import_react.useState)(null);
129
+ const fieldId = (0, import_react.useId)();
130
+ const field = (0, import_react.useRef)(null);
131
+ const openers = (0, import_react.useRef)({});
132
+ const cancelled = (0, import_react.useRef)(null);
133
+ (0, import_react.useEffect)(() => {
134
+ if (draft) field.current?.focus();
135
+ else if (cancelled.current) openers.current[cancelled.current]?.focus();
136
+ cancelled.current = null;
137
+ }, [draft]);
138
+ const close = () => {
139
+ setDraft(null);
140
+ setText("");
141
+ setRefusal(null);
142
+ };
143
+ const cancel = () => {
144
+ if (pending) return;
145
+ cancelled.current = draft;
146
+ close();
147
+ };
148
+ async function submit(state, input = {}) {
149
+ setPending(true);
150
+ setRefusal(null);
151
+ const refused = await onMark(state, input);
152
+ setPending(false);
153
+ if (refused) setRefusal(refused);
154
+ else close();
155
+ }
156
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
157
+ className: "grid gap-1.5",
158
+ children: [draft ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
159
+ "aria-label": `${MARKS[draft].action}: ${name}`,
160
+ className: "flex flex-wrap items-end gap-2",
161
+ onSubmit: (event) => {
162
+ event.preventDefault();
163
+ submit(draft, { [MARKS[draft].field.key]: text });
164
+ },
165
+ onKeyDown: (event) => {
166
+ if (event.key === "Escape") cancel();
167
+ },
168
+ children: [
169
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
170
+ htmlFor: fieldId,
171
+ className: "grid gap-1 text-xs text-muted",
172
+ children: [MARKS[draft].field.label, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
173
+ id: fieldId,
174
+ ref: field,
175
+ type: MARKS[draft].field.type,
176
+ value: text,
177
+ onChange: (event) => setText(event.target.value),
178
+ className: "h-8 w-72 max-w-full"
179
+ })]
180
+ }),
181
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
182
+ size: "sm",
183
+ variant: "primary",
184
+ type: "submit",
185
+ disabled: pending,
186
+ children: MARKS[draft].action
187
+ }),
188
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
189
+ size: "sm",
190
+ onClick: cancel,
191
+ disabled: pending,
192
+ children: "Cancel"
193
+ })
194
+ ]
195
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
196
+ role: "group",
197
+ "aria-label": `Mark ${name}`,
198
+ className: "flex flex-wrap gap-2",
199
+ children: [FRICTION_STATES.map((state) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
200
+ ref: (button) => {
201
+ openers.current[state] = button;
202
+ },
203
+ size: "sm",
204
+ disabled: pending,
205
+ onClick: () => setDraft(state),
206
+ children: MARKS[state].action
207
+ }, state)), handled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
208
+ size: "sm",
209
+ disabled: pending,
210
+ onClick: () => void submit("open"),
211
+ children: "Reopen"
212
+ }) : null]
213
+ }), refusal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
214
+ className: "m-0 max-w-[70ch] text-xs text-bad",
215
+ role: "alert",
216
+ children: refusal
217
+ }) : null]
218
+ });
219
+ }
220
+ // src/views/friction/select-friction.ts
221
+ var DEFAULT_FRICTION_FILTERS = {
222
+ state: "open",
223
+ sort: "repeats"
224
+ };
225
+ function filtersFromSearch(search) {
226
+ return {
227
+ state: search.frictionState ?? DEFAULT_FRICTION_FILTERS.state,
228
+ type: search.frictionType,
229
+ kind: search.frictionKind,
230
+ sort: search.frictionSort ?? DEFAULT_FRICTION_FILTERS.sort
231
+ };
232
+ }
233
+ /** Defaults leave the address, so it stays short. */
234
+ function searchFromFilters(filters) {
235
+ return {
236
+ frictionState: filters.state === DEFAULT_FRICTION_FILTERS.state ? void 0 : filters.state,
237
+ frictionType: filters.type,
238
+ frictionKind: filters.kind,
239
+ frictionSort: filters.sort === DEFAULT_FRICTION_FILTERS.sort ? void 0 : filters.sort
240
+ };
241
+ }
242
+ /** Core's selection in the chosen order; most repeated is the view's own order. */
243
+ function selectFriction(view, filters) {
244
+ const shown = selectFriction$1(view, filters);
245
+ if (filters.sort !== "recent") return shown;
246
+ return {
247
+ ...shown,
248
+ groups: shown.groups.toSorted((a, b) => a.lastSeen < b.lastSeen ? 1 : a.lastSeen > b.lastSeen ? -1 : 0)
249
+ };
250
+ }
251
+ // src/views/friction/friction-view.tsx
252
+ var PERIODS = FRICTION_VIEW_DAYS.map((days) => ({
253
+ value: String(days),
254
+ label: `${days} days`
255
+ }));
256
+ var STATES = [
257
+ {
258
+ value: "open",
259
+ label: "Open"
260
+ },
261
+ {
262
+ value: "handled",
263
+ label: "Handled"
264
+ },
265
+ {
266
+ value: "all",
267
+ label: "All"
268
+ }
269
+ ];
270
+ var ANY = "any";
271
+ var KINDS = [{
272
+ value: ANY,
273
+ label: "All kinds"
274
+ }, ...REPORT_KINDS.map((kind) => ({
275
+ value: kind,
276
+ label: kind
277
+ }))];
278
+ var SORTS = [{
279
+ value: "repeats",
280
+ label: "Most repeated in one session"
281
+ }, {
282
+ value: "recent",
283
+ label: "Most recent"
284
+ }];
285
+ var RECORDED_SECTION = {
286
+ id: "friction-recorded",
287
+ title: "Recorded friction"
288
+ };
289
+ var REPORTS_SECTION = {
290
+ id: "friction-agent-reports",
291
+ title: "Agent reports"
292
+ };
293
+ var DATE_TIME = new Intl.DateTimeFormat(void 0, {
294
+ dateStyle: "medium",
295
+ timeStyle: "short"
296
+ });
297
+ /** Filled in after hydration: the server's time zone may differ from the viewer's. */
298
+ function FrictionTime({ at }) {
299
+ const browser = useBrowser();
300
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("time", {
301
+ dateTime: at,
302
+ children: browser ? DATE_TIME.format(Date.parse(at)) : ""
303
+ });
304
+ }
305
+ var DETAILS = "m-0 grid grid-cols-[max-content_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1 @md:grid-cols-[6rem_minmax(0,1fr)]";
306
+ function Detail({ label, children }) {
307
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", {
308
+ className: "text-muted",
309
+ children: label
310
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
311
+ className: "m-0 min-w-0",
312
+ children
313
+ })] });
314
+ }
315
+ function Counted({ label, counts }) {
316
+ const entries = Object.entries(counts);
317
+ if (entries.length === 0) return null;
318
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
319
+ label,
320
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
321
+ className: "flex flex-wrap gap-x-3 gap-y-1",
322
+ children: entries.map(([name, count]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
323
+ className: "font-mono tabular-nums",
324
+ children: [
325
+ name,
326
+ " ",
327
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
328
+ className: "text-muted",
329
+ children: ["×", count]
330
+ })
331
+ ]
332
+ }, name))
333
+ })
334
+ });
335
+ }
336
+ function ItemFooter({ name, target, item, onMark }) {
337
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
338
+ className: "mt-1 grid gap-1.5",
339
+ children: [
340
+ item.state ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemState, {
341
+ state: item.state,
342
+ time: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: item.state.at })
343
+ }) : null,
344
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkActions, {
345
+ name,
346
+ handled: !item.open,
347
+ onMark
348
+ }),
349
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
350
+ role: "group",
351
+ "aria-label": `Triage ${name}`,
352
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",
353
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
354
+ className: "m-0 text-muted",
355
+ children: "To investigate this item, run in your own terminal, in a repository of its companion:"
356
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
357
+ className: "w-full max-w-xl min-w-0",
358
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommandLine, {
359
+ text: formatCommand([
360
+ FRAMEWORK_NAME,
361
+ "triage",
362
+ target
363
+ ]),
364
+ label: "command"
365
+ })
366
+ })]
367
+ })
368
+ ]
369
+ });
370
+ }
371
+ function Fields({ fields }) {
372
+ const shown = fields.filter(([, text]) => text);
373
+ if (shown.length === 0) return null;
374
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dl", {
375
+ className: cn(DETAILS, "max-w-[70ch] text-sm"),
376
+ children: shown.map(([label, text]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
377
+ label,
378
+ children: text
379
+ }, label))
380
+ });
381
+ }
382
+ function Row({ focusKey, line, summary, children }) {
383
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", {
384
+ className: "border-t border-rule-soft first:border-t-0",
385
+ "data-friction-item": focusKey,
386
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
387
+ className: "group/friction",
388
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("summary", {
389
+ className: "grid cursor-pointer list-none grid-cols-[auto_minmax(0,1fr)] gap-x-2 px-4 py-2.5 hover:bg-surface focus-visible:-outline-offset-2 [&::-webkit-details-marker]:hidden",
390
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
391
+ name: "right",
392
+ className: "mt-1 size-3.5 text-muted transition-transform group-open/friction:rotate-90 motion-reduce:transition-none"
393
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
394
+ className: cn("flex min-w-0 flex-wrap items-baseline gap-x-4 gap-y-1", line),
395
+ children: summary
396
+ })]
397
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
398
+ className: "mr-4 mb-3 ml-9.5 grid gap-1.5 border-l border-rule-soft pl-3",
399
+ children
400
+ })]
401
+ })
402
+ });
403
+ }
404
+ var FACTS = "flex flex-wrap items-baseline gap-x-3 gap-y-0.5 font-mono text-xs whitespace-nowrap text-muted tabular-nums";
405
+ var LAST_SEEN_TRACK = "minmax(32ch,max-content)";
406
+ var AT_TRACK = "minmax(22ch,max-content)";
407
+ var STATE_TRACK = "11ch";
408
+ function Gap({ wide }) {
409
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
410
+ "aria-hidden": "true",
411
+ className: cn("hidden", wide)
412
+ });
413
+ }
414
+ function groupCounts(group) {
415
+ return [
416
+ `at most ${group.maxPerSession} in one session`,
417
+ plural(group.events, "event"),
418
+ plural(group.sessions, "session"),
419
+ group.reports.length > 0 ? plural(group.reports.length, "report") : null
420
+ ];
421
+ }
422
+ function groupTracks(groups, columns) {
423
+ const counts = groups.map(groupCounts);
424
+ const widest = (column) => Math.max(...counts.map((row) => row[column]?.length ?? 0), 0);
425
+ const tracks = [
426
+ 0,
427
+ 1,
428
+ 2
429
+ ].map((column) => `${widest(column)}ch`);
430
+ if (columns.reports) tracks.push(`${widest(3)}ch`);
431
+ tracks.push(LAST_SEEN_TRACK);
432
+ if (columns.state) tracks.push(STATE_TRACK);
433
+ return tracks.join(" ");
434
+ }
435
+ function reportTracks(stateColumn) {
436
+ return stateColumn ? `${AT_TRACK} ${STATE_TRACK}` : AT_TRACK;
437
+ }
438
+ var factsStyle = (tracks) => ({ "--friction-facts": tracks });
439
+ function StateCell({ state, column, wide }) {
440
+ if (state) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
441
+ className: "font-sans",
442
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateWord, { state })
443
+ });
444
+ return column ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Gap, { wide }) : null;
445
+ }
446
+ function GroupItem({ group, columns, onMark }) {
447
+ const [peak, events, sessions, reports] = groupCounts(group);
448
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
449
+ focusKey: group.fingerprint,
450
+ line: "@5xl:grid @5xl:grid-cols-[minmax(0,1fr)_auto]",
451
+ summary: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
452
+ className: "m-0 min-w-0 flex-[1_1_16rem] text-base font-semibold",
453
+ children: group.title
454
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
455
+ className: cn(FACTS, "@3xl:grid @3xl:grid-cols-(--friction-facts)"),
456
+ children: [
457
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: peak }),
458
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: events }),
459
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: sessions }),
460
+ reports ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: reports }) : columns.reports ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Gap, { wide: "@3xl:block" }) : null,
461
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["last seen ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: group.lastSeen })] }),
462
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateCell, {
463
+ state: group.state,
464
+ column: columns.state,
465
+ wide: "@3xl:block"
466
+ })
467
+ ]
468
+ })] }),
469
+ children: [
470
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
471
+ className: cn(DETAILS, "text-xs"),
472
+ children: [
473
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
474
+ label: "Fingerprint",
475
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
476
+ className: "font-mono",
477
+ children: group.fingerprint
478
+ })
479
+ }),
480
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
481
+ label: "First seen",
482
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: group.firstSeen })
483
+ }),
484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
485
+ label: "Last seen",
486
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: group.lastSeen })
487
+ }),
488
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counted, {
489
+ label: "Mate",
490
+ counts: group.versions
491
+ }),
492
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counted, {
493
+ label: "Paths",
494
+ counts: group.paths
495
+ }),
496
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counted, {
497
+ label: "Flags",
498
+ counts: group.flags
499
+ })
500
+ ]
501
+ }),
502
+ group.reports.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
503
+ "aria-label": `Reports on ${group.title}`,
504
+ className: "mt-1",
505
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", {
506
+ className: "m-0 text-xs font-semibold text-muted",
507
+ children: plural(group.reports.length, "report")
508
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
509
+ className: "m-0 list-none p-0",
510
+ children: group.reports.map((report) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
511
+ className: "grid gap-1 border-t border-rule-soft py-2 first:border-t-0",
512
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
513
+ className: "flex flex-wrap items-baseline gap-x-2 text-xs text-muted",
514
+ children: [
515
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
516
+ className: "font-semibold text-text",
517
+ children: report.kind
518
+ }),
519
+ report.cost ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: report.cost }) : null,
520
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: report.at })
521
+ ]
522
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fields, { fields: [
523
+ ["Expected", report.expected],
524
+ ["Evidence", report.evidence],
525
+ ["Workaround", report.workaround]
526
+ ] })]
527
+ }, report.id))
528
+ })]
529
+ }) : null,
530
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemFooter, {
531
+ name: group.title,
532
+ target: group.fingerprint,
533
+ item: group,
534
+ onMark
535
+ })
536
+ ]
537
+ });
538
+ }
539
+ function FreeReportItem({ report, stateColumn, onMark }) {
540
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
541
+ focusKey: report.id,
542
+ line: "@3xl:grid @3xl:grid-cols-[minmax(0,1fr)_auto]",
543
+ summary: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
544
+ className: "flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1",
545
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
546
+ className: "m-0 min-w-0 font-mono text-sm leading-[1.375rem] font-semibold",
547
+ children: report.subject
548
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
549
+ className: "rounded-full border border-rule bg-page px-2 font-mono text-[0.7rem] text-text",
550
+ children: report.kind
551
+ })]
552
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
553
+ className: cn(FACTS, "@3xl:grid @3xl:grid-cols-(--friction-facts)"),
554
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: report.at }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateCell, {
555
+ state: report.state,
556
+ column: stateColumn,
557
+ wide: "@3xl:block"
558
+ })]
559
+ })] }),
560
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fields, { fields: [
561
+ ["Expected", report.expected],
562
+ ["Cost", report.cost],
563
+ ["Evidence", report.evidence],
564
+ ["Workaround", report.workaround]
565
+ ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemFooter, {
566
+ name: report.subject,
567
+ target: report.id,
568
+ item: report,
569
+ onMark
570
+ })]
571
+ });
572
+ }
573
+ function Hidden({ hidden, onShowAll }) {
574
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
575
+ hidden === 1 ? "1 item is" : `${hidden} items are`,
576
+ " hidden by the filters.",
577
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
578
+ size: "sm",
579
+ onClick: onShowAll,
580
+ "data-show-all": true,
581
+ "aria-label": `Show all, including ${plural(hidden, "hidden item")}`,
582
+ children: "Show all"
583
+ })
584
+ ] });
585
+ }
586
+ function Overview({ view, shown, empty, onShowAll }) {
587
+ const sections = [[RECORDED_SECTION, shown.groups.length], [REPORTS_SECTION, shown.freeReports.length]];
588
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
589
+ "aria-label": "Overview",
590
+ className: "grid gap-2 text-sm",
591
+ children: [
592
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
593
+ className: "flex flex-wrap items-baseline gap-x-5 gap-y-1",
594
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
595
+ className: "m-0",
596
+ children: [
597
+ plural(view.events, "event"),
598
+ " in ",
599
+ plural(view.sessions, "session"),
600
+ " in the last",
601
+ " ",
602
+ view.days,
603
+ " days for the selected companion."
604
+ ]
605
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
606
+ "aria-label": "Friction sections",
607
+ className: "flex flex-wrap gap-x-4 gap-y-1",
608
+ children: sections.map(([{ id, title }, count]) => count > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
609
+ href: `#${id}`,
610
+ className: "inline-flex items-center gap-1.5 rounded-control underline",
611
+ children: [title, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Count, { value: count })]
612
+ }, id) : null)
613
+ })]
614
+ }),
615
+ !empty && shown.hidden > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
616
+ className: "m-0 flex flex-wrap items-center gap-2 text-muted",
617
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Hidden, {
618
+ hidden: shown.hidden,
619
+ onShowAll
620
+ })
621
+ }) : null,
622
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
623
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2",
624
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
625
+ className: "m-0 text-muted",
626
+ children: "To investigate, run this in your own terminal, inside the affected repository:"
627
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
628
+ className: "w-48 max-w-full",
629
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommandLine, {
630
+ text: `${FRAMEWORK_NAME} triage`,
631
+ label: "command"
632
+ })
633
+ })]
634
+ })
635
+ ]
636
+ });
637
+ }
638
+ function Recording({ recording, toggle, button }) {
639
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
640
+ className: "grid gap-1",
641
+ children: [
642
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
643
+ className: "flex flex-wrap items-center gap-3",
644
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingState, { recording }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingButton, {
645
+ ref: button,
646
+ recording,
647
+ toggle
648
+ })]
649
+ }),
650
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingReach, {}),
651
+ toggle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
652
+ className: "m-0 text-sm text-bad",
653
+ role: "alert",
654
+ children: toggle.error
655
+ }) : null
656
+ ]
657
+ });
658
+ }
659
+ function FilterSelect({ label, options, value, onChange, note, disabled }) {
660
+ const id = (0, import_react.useId)();
661
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
662
+ className: "flex items-center gap-2",
663
+ children: [
664
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
665
+ htmlFor: id,
666
+ className: "text-xs text-muted",
667
+ children: label
668
+ }),
669
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, {
670
+ items: options,
671
+ value,
672
+ disabled,
673
+ onValueChange: (next) => {
674
+ if (next !== null) onChange(next);
675
+ },
676
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTrigger, {
677
+ id,
678
+ "aria-describedby": note ? `${id}-note` : void 0,
679
+ className: "h-7 w-auto",
680
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, {})
681
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, {
682
+ value: option.value,
683
+ children: option.label
684
+ }, option.value)) })]
685
+ }),
686
+ note ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
687
+ id: `${id}-note`,
688
+ className: "text-xs text-muted",
689
+ children: note
690
+ }) : null
691
+ ]
692
+ });
693
+ }
694
+ function Filters({ view, shown, filters, onFilters }) {
695
+ const types = [{
696
+ value: ANY,
697
+ label: "All types"
698
+ }, ...shown.types.map((type) => ({
699
+ value: type,
700
+ label: type
701
+ }))];
702
+ const noReports = selectFriction(view, {
703
+ ...filters,
704
+ kind: void 0
705
+ }).freeReports.length === 0;
706
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
707
+ className: "flex flex-wrap items-center gap-x-5 gap-y-2",
708
+ children: [
709
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterSelect, {
710
+ label: "Type",
711
+ options: types,
712
+ value: shown.type ?? ANY,
713
+ onChange: (type) => onFilters({
714
+ ...filters,
715
+ type: oneOf(SUBJECT_TYPES, type)
716
+ })
717
+ }),
718
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterSelect, {
719
+ label: "Kind",
720
+ options: KINDS,
721
+ value: filters.kind ?? ANY,
722
+ onChange: (kind) => onFilters({
723
+ ...filters,
724
+ kind: oneOf(REPORT_KINDS, kind)
725
+ }),
726
+ note: "Agent reports only",
727
+ disabled: noReports && filters.kind === void 0
728
+ }),
729
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterSelect, {
730
+ label: "Sort",
731
+ options: SORTS,
732
+ value: filters.sort,
733
+ onChange: (sort) => onFilters({
734
+ ...filters,
735
+ sort
736
+ })
737
+ })
738
+ ]
739
+ });
740
+ }
741
+ function Lists({ shown, empty, markItem, onShowAll }) {
742
+ if (empty) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EmptyNote, {
743
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2",
744
+ children: ["No item matches the filters. ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Hidden, {
745
+ hidden: shown.hidden,
746
+ onShowAll
747
+ })]
748
+ });
749
+ const groupColumns = {
750
+ reports: shown.groups.some((group) => group.reports.length > 0),
751
+ state: shown.groups.some((group) => group.state !== null)
752
+ };
753
+ const reportState = shown.freeReports.some((report) => report.state !== null);
754
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
755
+ className: "grid gap-4",
756
+ children: [shown.groups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
757
+ ...RECORDED_SECTION,
758
+ count: shown.groups.length,
759
+ className: "wrap-anywhere",
760
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
761
+ className: "@container m-0 list-none p-0",
762
+ style: factsStyle(groupTracks(shown.groups, groupColumns)),
763
+ children: shown.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupItem, {
764
+ group,
765
+ columns: groupColumns,
766
+ onMark: markItem(group.fingerprint, group.title)
767
+ }, group.fingerprint))
768
+ })
769
+ }) : null, shown.freeReports.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
770
+ ...REPORTS_SECTION,
771
+ count: shown.freeReports.length,
772
+ hint: "These reports are not attached to a recorded event.",
773
+ className: "wrap-anywhere",
774
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
775
+ className: "@container m-0 list-none p-0",
776
+ style: factsStyle(reportTracks(reportState)),
777
+ children: shown.freeReports.map((report) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FreeReportItem, {
778
+ report,
779
+ stateColumn: reportState,
780
+ onMark: markItem(report.id, report.subject)
781
+ }, report.id))
782
+ })
783
+ }) : null]
784
+ });
785
+ }
786
+ function FrictionPanel({ view, days, onDays, toggle, filters, onFilters, mark, recordingButton }) {
787
+ const recorded = view.events > 0 || view.freeReports.length > 0;
788
+ const shown = selectFriction(view, filters);
789
+ const [marked, setMarked] = (0, import_react.useState)(null);
790
+ const panel = (0, import_react.useRef)(null);
791
+ (0, import_react.useEffect)(() => {
792
+ if (!marked) return;
793
+ const row = (key) => key === null ? null : panel.current?.querySelector(`[data-friction-item="${CSS.escape(key)}"] summary`);
794
+ (row(marked.key) ?? row(marked.next) ?? panel.current?.querySelector("[data-show-all]"))?.focus();
795
+ }, [marked]);
796
+ const markItem = (key, name) => async (state, input) => {
797
+ const order = [...shown.groups.map((group) => group.fingerprint), ...shown.freeReports.map((report) => report.id)];
798
+ const index = order.indexOf(key);
799
+ const next = order[index + 1] ?? order[index - 1] ?? null;
800
+ let result;
801
+ try {
802
+ result = await mark({
803
+ target: key,
804
+ state,
805
+ ...input
806
+ });
807
+ } catch (error) {
808
+ return `The mark could not be saved: ${error instanceof Error ? error.message : String(error)}`;
809
+ }
810
+ if (!result.ok) return result.reason;
811
+ setMarked((last) => ({
812
+ announcementKey: (last?.announcementKey ?? 0) + 1,
813
+ key,
814
+ next,
815
+ message: `${name}: ${state === "open" ? "reopened" : `marked ${state}`}.`
816
+ }));
817
+ return null;
818
+ };
819
+ const showAll = () => {
820
+ [...panel.current?.querySelectorAll("[aria-label=\"State\"] button") ?? []].find((button) => button.textContent === "All")?.focus();
821
+ onFilters({
822
+ state: "all",
823
+ sort: filters.sort
824
+ });
825
+ };
826
+ const empty = shown.groups.length === 0 && shown.freeReports.length === 0;
827
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
828
+ ref: panel,
829
+ className: cn(PAGE_PAD, "grid min-w-0 gap-4 pt-3 pb-6"),
830
+ children: [
831
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Recording, {
832
+ recording: view.recording,
833
+ toggle,
834
+ button: recordingButton
835
+ }),
836
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
837
+ className: "grid gap-2",
838
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
839
+ className: "flex flex-wrap items-center gap-x-5 gap-y-2",
840
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pills, {
841
+ label: "Period",
842
+ options: PERIODS,
843
+ value: String(days),
844
+ onChange: (value) => onDays(Number(value))
845
+ }), recorded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pills, {
846
+ label: "State",
847
+ options: STATES,
848
+ value: filters.state,
849
+ onChange: (state) => onFilters({
850
+ ...filters,
851
+ state
852
+ })
853
+ }) : null]
854
+ }), recorded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Filters, {
855
+ view,
856
+ shown,
857
+ filters,
858
+ onFilters
859
+ }) : null]
860
+ }),
861
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
862
+ "aria-live": "polite",
863
+ className: "sr-only",
864
+ children: marked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: marked.message }, marked.announcementKey) : null
865
+ }),
866
+ recorded ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
867
+ view.recording ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
868
+ className: "m-0 text-sm text-muted",
869
+ children: "Recording is off: nothing new is recorded. The records below were made while it was on."
870
+ }),
871
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Overview, {
872
+ view,
873
+ shown,
874
+ empty,
875
+ onShowAll: showAll
876
+ }),
877
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Lists, {
878
+ shown,
879
+ empty,
880
+ markItem,
881
+ onShowAll: showAll
882
+ })
883
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyNote, { children: view.recording ? `No friction was recorded in the last ${view.days} days.` : `Friction recording shows where Mate gets in an agent's way: its refusals and the ${FRAMEWORK_NAME} commands that fail in agent sessions on this machine. Recording is off; turn it on to start.` })
884
+ ]
885
+ });
886
+ }
887
+ function Friction({ companion, days, onDays, filters, onFilters }) {
888
+ const query = useQuery({
889
+ ...frictionQuery(companion, days),
890
+ enabled: useBrowser(),
891
+ placeholderData: keepPreviousData
892
+ });
893
+ const toggle = useSetFrictionRecording();
894
+ const mark = useMarkFriction();
895
+ const { button: recordingButton, retried } = useRetryFocus(query.isSuccess);
896
+ if (!query.data && !query.isError) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ViewLoading, { title: "Reading the Friction Log…" });
897
+ const failed = query.isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
898
+ className: cn(PAGE_PAD, "pt-3 text-sm"),
899
+ role: "alert",
900
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
901
+ className: "m-0 text-bad",
902
+ children: "The Friction Log could not be read."
903
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
904
+ className: "mt-3",
905
+ onClick: () => {
906
+ retried();
907
+ query.refetch();
908
+ },
909
+ disabled: query.isFetching,
910
+ children: "Retry"
911
+ })]
912
+ }) : null;
913
+ if (!query.data) return failed;
914
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [failed, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionPanel, {
915
+ view: query.data,
916
+ days,
917
+ onDays,
918
+ toggle,
919
+ filters,
920
+ onFilters,
921
+ mark,
922
+ recordingButton
923
+ })] });
924
+ }
925
+ // src/routes/friction.tsx?tsr-split=component
926
+ var SplitComponent = function FrictionRoute() {
927
+ const search = Route.useSearch();
928
+ const navigate = Route.useNavigate();
929
+ return search.companion ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Friction, {
930
+ companion: search.companion,
931
+ days: search.frictionDays ?? 30,
932
+ onDays: (frictionDays) => void navigate({ search: (previous) => ({
933
+ ...previous,
934
+ frictionDays
935
+ }) }),
936
+ filters: filtersFromSearch(search),
937
+ onFilters: (filters) => void navigate({ search: (previous) => ({
938
+ ...previous,
939
+ ...searchFromFilters(filters)
940
+ }) })
941
+ }, search.companion) : null;
942
+ };
943
+ export { SplitComponent as component };