specrails-desktop 2.34.1 → 2.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/client/dist/assets/ActivityFeedPage-LCBJ5WiD.js +1 -0
  2. package/client/dist/assets/AgentBrowserCapture-B-xQpyZr.js +1 -0
  3. package/client/dist/assets/AgentModeAnalyticsPane-BI1Vcf3T.js +2 -0
  4. package/client/dist/assets/AgentModeCodePane-BTRwCl9h.js +2 -0
  5. package/client/dist/assets/AgentModeJobsPane-VzeBJLqP.js +1 -0
  6. package/client/dist/assets/AgentsPage-CJj1K24O.js +87 -0
  7. package/client/dist/assets/AnalyticsPage-CQpV5_fX.js +1 -0
  8. package/client/dist/assets/CodePage-9-tFh0jB.js +2 -0
  9. package/client/dist/assets/DesktopAnalyticsPage-BcZ0_O_C.js +1 -0
  10. package/client/dist/assets/DocsDialog-BPAzDICW.js +11 -0
  11. package/client/dist/assets/DocsPage-Dqo4Hn6G.js +11 -0
  12. package/client/dist/assets/IntegrationsPage-Bhy58lnQ.js +1 -0
  13. package/client/dist/assets/InteractiveJobComposer-D36fZWai.js +19 -0
  14. package/client/dist/assets/JobDetailModal-BxsktbkQ.js +1 -0
  15. package/client/dist/assets/JobDetailPage-WWyCy6Sp.js +1 -0
  16. package/client/dist/assets/JobsPage-CEbM7uxU.js +1 -0
  17. package/client/dist/assets/{LoopBuilderPage-B1GJJ0QZ.js → LoopBuilderPage-CYsSN8io.js} +2 -2
  18. package/client/dist/assets/LoopPreviewModal-BJhgX5wY.js +1 -0
  19. package/client/dist/assets/LoopsPage-DB4OqMot.js +1 -0
  20. package/client/dist/assets/MinimizedChatsContext-CcjBHMHd.js +1 -0
  21. package/client/dist/assets/PluginsPage-CR8K4nM_.js +2 -0
  22. package/client/dist/assets/{ProjectSettingsDialog-D6Vxjpv5.js → ProjectSettingsDialog-C45-qhF4.js} +1 -1
  23. package/client/dist/assets/ReviewPacketPage-Cz_QQeC3.js +1 -0
  24. package/client/dist/assets/TemplatePreviewModal-wFBd2vQP.js +1 -0
  25. package/client/dist/assets/TicketDetailModal-BvZoyDAL.js +14 -0
  26. package/client/dist/assets/{Trans-CTqw6rr9.js → Trans-DXZ-BLXb.js} +1 -1
  27. package/client/dist/assets/agent-BQgKv_2F.js +1 -0
  28. package/client/dist/assets/agent-C1NRDJqL.js +1 -0
  29. package/client/dist/assets/agent-CLNleiy6.js +1 -0
  30. package/client/dist/assets/agent-CmceArkQ.js +1 -0
  31. package/client/dist/assets/agent-D3UxQ3SR.js +1 -0
  32. package/client/dist/assets/agent-DB1JeE64.js +1 -0
  33. package/client/dist/assets/agent-DXkHcQ-D.js +1 -0
  34. package/client/dist/assets/agent-DjJJJ2M8.js +1 -0
  35. package/client/dist/assets/ban-E4EaZe3a.js +1 -0
  36. package/client/dist/assets/bot-DzuuuC5R.js +1 -0
  37. package/client/dist/assets/{browser-DxP-alBK.js → browser-BgqHDMXP.js} +1 -1
  38. package/client/dist/assets/{browser-CyR1Kp3m.js → browser-CsKJtrpv.js} +1 -1
  39. package/client/dist/assets/browser-Cu58EpZU.js +1 -0
  40. package/client/dist/assets/{browser-rRCwi7Y7.js → browser-CvXOJm-j.js} +1 -1
  41. package/client/dist/assets/{browser-CvgDySd9.js → browser-DOrFh1c7.js} +1 -1
  42. package/client/dist/assets/{browser-DwZljcRh.js → browser-DQv_Jo7x.js} +1 -1
  43. package/client/dist/assets/{browser-C25DkQiO.js → browser-LPgxvJu2.js} +1 -1
  44. package/client/dist/assets/{browser-CiJ7-L32.js → browser-eL-3MIEI.js} +1 -1
  45. package/client/dist/assets/button-CJqFnUOL.js +1 -0
  46. package/client/dist/assets/{chunk-KS7C4IRE-Cx5sqopX.js → chunk-KS7C4IRE-DEKu087k.js} +1 -1
  47. package/client/dist/assets/{commands-DyUZQ1FI.js → commands-6tYQih5m.js} +1 -1
  48. package/client/dist/assets/{commands-B9RZO4qS.js → commands-BK2QinXN.js} +1 -1
  49. package/client/dist/assets/{commands-Bbxu8kLU.js → commands-C2Nca76h.js} +1 -1
  50. package/client/dist/assets/{commands-CDU3qv68.js → commands-CKdLihNX.js} +1 -1
  51. package/client/dist/assets/{commands-DTQBF_q5.js → commands-CYIBTAlc.js} +1 -1
  52. package/client/dist/assets/{commands-hOtKuOXc.js → commands-CjUtYJIM.js} +1 -1
  53. package/client/dist/assets/{commands-BEwbAjtD.js → commands-Cq_u_8y9.js} +1 -1
  54. package/client/dist/assets/{commands-CzezgtQj.js → commands-D_ZHYQug.js} +1 -1
  55. package/client/dist/assets/core-B3mKBIh5.js +1 -0
  56. package/client/dist/assets/dashboard-B9GhC5ku.js +1 -0
  57. package/client/dist/assets/dashboard-C8WOEiPu.js +1 -0
  58. package/client/dist/assets/dashboard-CBnv6zOI.js +1 -0
  59. package/client/dist/assets/dashboard-CaP0fU87.js +1 -0
  60. package/client/dist/assets/dashboard-D4ZZ4x84.js +1 -0
  61. package/client/dist/assets/dashboard-DmuTQBX8.js +1 -0
  62. package/client/dist/assets/dashboard-DynLYj3d.js +1 -0
  63. package/client/dist/assets/dashboard-zj4gGFJ1.js +1 -0
  64. package/client/dist/assets/dialog-CdWCb02j.js +45 -0
  65. package/client/dist/assets/dist-js-CWeUdf5Z.js +1 -0
  66. package/client/dist/assets/dist-js-Rlh4FLH5.js +1 -0
  67. package/client/dist/assets/event-Bt7f3wXe.js +1 -0
  68. package/client/dist/assets/file-text-BcLCfcWZ.js +1 -0
  69. package/client/dist/assets/{formatDistanceToNow-BOuXgebD.js → formatDistanceToNow-C0ImhVKp.js} +1 -1
  70. package/client/dist/assets/{getTimezoneOffsetInMilliseconds-EjGOpn4b.js → getTimezoneOffsetInMilliseconds-owhDdTXs.js} +1 -1
  71. package/client/dist/assets/git-refresh-wTW0rO0Z.js +1 -0
  72. package/client/dist/assets/i18n-DwgvwTnx.js +2 -0
  73. package/client/dist/assets/index-DhjjFyU5.js +66 -0
  74. package/client/dist/assets/index-xBFsOEiJ.css +2 -0
  75. package/client/dist/assets/jira-api-CcZMcEN5.js +1 -0
  76. package/client/dist/assets/loops-B7YpGizO.js +1 -0
  77. package/client/dist/assets/{loops-CMMQOw2P.js → loops-BomD2J-h.js} +1 -1
  78. package/client/dist/assets/{loops-B2_97D26.js → loops-BrQHSQw3.js} +1 -1
  79. package/client/dist/assets/{loops-BwxCndZk.js → loops-BvBwvTPA.js} +1 -1
  80. package/client/dist/assets/{loops-BISOkuCu.js → loops-CODk6Slz.js} +1 -1
  81. package/client/dist/assets/{loops-CD19kEzq.js → loops-DC6k-Ym-.js} +1 -1
  82. package/client/dist/assets/{loops-aEb4RxN2.js → loops-DSEg8-uY.js} +1 -1
  83. package/client/dist/assets/{loops-Bo6w_peZ.js → loops-DhCoXD_v.js} +1 -1
  84. package/client/dist/assets/narration-4Z2VUhZw.js +1 -0
  85. package/client/dist/assets/narration-BGuiEDj3.js +1 -0
  86. package/client/dist/assets/narration-BuSoqRmv.js +1 -0
  87. package/client/dist/assets/narration-CB9t29fy.js +1 -0
  88. package/client/dist/assets/narration-CU3x8FHD.js +1 -0
  89. package/client/dist/assets/narration-CWeXhfP5.js +1 -0
  90. package/client/dist/assets/narration-DRaDnhT5.js +1 -0
  91. package/client/dist/assets/narration-DtEbQgCw.js +1 -0
  92. package/client/dist/assets/packet-B1IxaL5f.js +1 -0
  93. package/client/dist/assets/packet-Bh5kkbiB.js +1 -0
  94. package/client/dist/assets/packet-By8fqYxW.js +1 -0
  95. package/client/dist/assets/packet-CZdvA44E.js +1 -0
  96. package/client/dist/assets/packet-CrjHRQCP.js +1 -0
  97. package/client/dist/assets/packet-Dwi2pTtx.js +1 -0
  98. package/client/dist/assets/packet-_-ZIa0IR.js +1 -0
  99. package/client/dist/assets/packet-n0W6E1Hn.js +1 -0
  100. package/client/dist/assets/save-B6wGWwBR.js +1 -0
  101. package/client/dist/assets/settings-Bd0x4TBa.js +1 -0
  102. package/client/dist/assets/settings-C1-7cXzC.js +1 -0
  103. package/client/dist/assets/settings-CAFaT38b.js +1 -0
  104. package/client/dist/assets/settings-Ct3v1nW2.js +1 -0
  105. package/client/dist/assets/settings-DHh7_IF5.js +1 -0
  106. package/client/dist/assets/settings-DQXAmdcv.js +1 -0
  107. package/client/dist/assets/settings-guzlhpup.js +1 -0
  108. package/client/dist/assets/settings-sZfTPMEH.js +1 -0
  109. package/client/dist/assets/{spending-BpYPsevQ.js → spending-BQX3P7Cq.js} +1 -1
  110. package/client/dist/assets/useDesktop-BzX769yH.js +1 -0
  111. package/client/dist/index.html +29 -31
  112. package/docs/internals/embedded-browser-native-webview-evaluation.md +161 -0
  113. package/docs/internals/review-packet.md +212 -0
  114. package/package.json +1 -1
  115. package/server/dist/accept-ladder.js +61 -0
  116. package/server/dist/agent-chat-manager.js +22 -1
  117. package/server/dist/agent-defaults.js +359 -0
  118. package/server/dist/agent-operator-prompt.js +13 -5
  119. package/server/dist/browser-playwright.js +39 -2
  120. package/server/dist/db.js +38 -0
  121. package/server/dist/delivery-evidence.js +242 -0
  122. package/server/dist/desktop-router.js +23 -0
  123. package/server/dist/feature-flags.js +23 -0
  124. package/server/dist/loop-command-catalog.js +33 -0
  125. package/server/dist/loop-executors.js +12 -2
  126. package/server/dist/loop-factory.js +16 -1
  127. package/server/dist/loops-router.js +2 -0
  128. package/server/dist/mcp/tools/rails.js +16 -0
  129. package/server/dist/project-registry.js +33 -1
  130. package/server/dist/project-router-loop-runs.js +27 -2
  131. package/server/dist/providers/claude-adapter.js +39 -2
  132. package/server/dist/queue-manager.js +47 -4
  133. package/server/dist/rail-isolated-launch.js +101 -2
  134. package/server/dist/rail-pr-store.js +40 -3
  135. package/server/dist/rails-router.js +124 -3
  136. package/server/dist/review-packet.js +327 -0
  137. package/server/dist/revision-seed.js +73 -0
  138. package/server/dist/run-duration-stats.js +71 -0
  139. package/server/dist/stuck-run-detector.js +153 -0
  140. package/server/dist/telemetry-receiver.js +22 -0
  141. package/client/dist/assets/ActivityFeedPage-B4yaoZsD.js +0 -1
  142. package/client/dist/assets/AgentBrowserCapture-Bhykbzog.js +0 -1
  143. package/client/dist/assets/AgentModeAnalyticsPane-prvv23b7.js +0 -2
  144. package/client/dist/assets/AgentModeCodePane-BmxySwPP.js +0 -2
  145. package/client/dist/assets/AgentModeJobsPane-BvW6tTmU.js +0 -1
  146. package/client/dist/assets/AgentsPage-DinMMQPm.js +0 -87
  147. package/client/dist/assets/AnalyticsPage-d5GmoZY2.js +0 -1
  148. package/client/dist/assets/CodePage-Cgbj4lpK.js +0 -2
  149. package/client/dist/assets/DesktopAnalyticsPage-DbbZi6fw.js +0 -1
  150. package/client/dist/assets/DocsDialog-B87oF3aC.js +0 -11
  151. package/client/dist/assets/DocsPage-CqJ-yRkh.js +0 -11
  152. package/client/dist/assets/IntegrationsPage-Bs00_tl4.js +0 -1
  153. package/client/dist/assets/InteractiveJobComposer-nPGDKuCk.js +0 -19
  154. package/client/dist/assets/JobDetailModal-duouGMzi.js +0 -1
  155. package/client/dist/assets/JobDetailPage-Cw3Hu579.js +0 -1
  156. package/client/dist/assets/JobsPage-DYyV-qWT.js +0 -1
  157. package/client/dist/assets/LoopPreviewModal-Md6KF7rU.js +0 -1
  158. package/client/dist/assets/LoopsPage-BKNiwsy1.js +0 -1
  159. package/client/dist/assets/MinimizedChatsContext-CHsu3NCX.js +0 -1
  160. package/client/dist/assets/PluginsPage-r682uE6n.js +0 -2
  161. package/client/dist/assets/TemplatePreviewModal-DcgWnn23.js +0 -1
  162. package/client/dist/assets/TicketDetailModal-BPaqyvrs.js +0 -14
  163. package/client/dist/assets/agent-Bd-q3Wqp.js +0 -1
  164. package/client/dist/assets/agent-BlvdW4Hv.js +0 -1
  165. package/client/dist/assets/agent-C-KQhxeM.js +0 -1
  166. package/client/dist/assets/agent-Ca15w5eu.js +0 -1
  167. package/client/dist/assets/agent-D6fKaoMd.js +0 -1
  168. package/client/dist/assets/agent-HFMYMTbB.js +0 -1
  169. package/client/dist/assets/agent-QIEbkBjg.js +0 -1
  170. package/client/dist/assets/agent-mTCsAbCl.js +0 -1
  171. package/client/dist/assets/api-B2M7CtDw.js +0 -1
  172. package/client/dist/assets/arrow-left-CpIR4j7G.js +0 -1
  173. package/client/dist/assets/arrow-up-right-9DoMn7fD.js +0 -1
  174. package/client/dist/assets/browser-CXUcnTMI.js +0 -1
  175. package/client/dist/assets/button-BUIIBQPT.js +0 -1
  176. package/client/dist/assets/chevron-right-CViMxucY.js +0 -1
  177. package/client/dist/assets/dashboard-BHRqsGCV.js +0 -1
  178. package/client/dist/assets/dashboard-Bfr90vOl.js +0 -1
  179. package/client/dist/assets/dashboard-CTsM8x3m.js +0 -1
  180. package/client/dist/assets/dashboard-CqC6wX0h.js +0 -1
  181. package/client/dist/assets/dashboard-CuZtAszc.js +0 -1
  182. package/client/dist/assets/dashboard-DAcqIc-n.js +0 -1
  183. package/client/dist/assets/dashboard-DekiV-86.js +0 -1
  184. package/client/dist/assets/dashboard-DoDczc5S.js +0 -1
  185. package/client/dist/assets/dialog-CzIekCw0.js +0 -45
  186. package/client/dist/assets/dist-Cez5CRkX.js +0 -1
  187. package/client/dist/assets/dist-js-B1s_CM_v.js +0 -1
  188. package/client/dist/assets/dist-js-BNETKUa_.js +0 -1
  189. package/client/dist/assets/external-link-BcU5EWZp.js +0 -1
  190. package/client/dist/assets/file-text-CFT-xXKN.js +0 -1
  191. package/client/dist/assets/i18n-nJQvD5zJ.js +0 -2
  192. package/client/dist/assets/index-DCN5QbDm.css +0 -2
  193. package/client/dist/assets/index-DdC_faQv.js +0 -63
  194. package/client/dist/assets/jira-api-Bhixwn-d.js +0 -1
  195. package/client/dist/assets/loops-CnxqL8IL.js +0 -1
  196. package/client/dist/assets/save-28sIlCdr.js +0 -1
  197. package/client/dist/assets/settings-BveOJoaI.js +0 -1
  198. package/client/dist/assets/settings-Cj1C6F5k.js +0 -1
  199. package/client/dist/assets/settings-CuVwOpe0.js +0 -1
  200. package/client/dist/assets/settings-D5X4DfRc.js +0 -1
  201. package/client/dist/assets/settings-DXwxe-BW.js +0 -1
  202. package/client/dist/assets/settings-Di81Ba_V.js +0 -1
  203. package/client/dist/assets/settings-jbLjCYC_.js +0 -1
  204. package/client/dist/assets/settings-wIZNPFnn.js +0 -1
  205. package/client/dist/assets/useBrowserCaptureSession-BBXBN0Na.js +0 -1
  206. package/client/dist/assets/useDesktop-B6Du2N83.js +0 -1
  207. package/client/dist/assets/useSharedWebSocket-DK96ctb7.js +0 -1
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r,n as i,u as a}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as o}from"./i18n-nJQvD5zJ.js";import{n as s}from"./createLucideIcon-Bjbbp_KS.js";import{n as c}from"./dist-bVqfYmby.js";import{c as l,l as u}from"./MinimizedChatsContext-CHsu3NCX.js";import{t as d}from"./chevron-right-CViMxucY.js";import{i as f,n as p,r as ee,t as te}from"./InteractiveJobComposer-nPGDKuCk.js";import{o as m}from"./TicketDetailModal-BPaqyvrs.js";import{t as ne}from"./circle-x-CMYsN4ZH.js";import{t as h}from"./download-CFHyyHcw.js";import{t as g}from"./loader-circle-DcygOQpC.js";import{r as _}from"./useSharedWebSocket-DK96ctb7.js";import{t as v}from"./api-B2M7CtDw.js";import{r as y}from"./useDesktop-B6Du2N83.js";import{t as b}from"./button-BUIIBQPT.js";import{t as x}from"./utils-BC4DHlz2.js";import{t as re}from"./formatDistanceToNow-BOuXgebD.js";import{Dt as S,F as C,I as ie,M as w,N as T,S as E,Tt as D,at as O,gt as k,n as ae,x as A}from"./index-DdC_faQv.js";import{n as j}from"./job-time-BCL7wee9.js";import{t as M}from"./format-command-C0D9IPmV.js";var N=e(t(),1),P=n();function F(e,t){let n=j(e),r=(typeof t==`number`?t:j(t)?.getTime()??NaN)-(n?.getTime()??NaN);if(!Number.isFinite(r)||r<0)return`—`;let i=Math.round(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60),o=i%60;return a<60?`${a}m ${o}s`:`${Math.floor(a/60)}h ${a%60}m`}function I(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}var L={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function R(e,t){if(t.type===`reset`)return L;if(t.type===`consume`){let{events:n}=t,r=e.lastSeenIdx>n.length?n.length:e.lastSeenIdx;if(n.length<=r)return r===e.lastSeenIdx?e:{...e,lastSeenIdx:r};let{steps:i,actionKey:a,actionArg:o}=e;for(let e=r;e<n.length;e++){let t=E(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``)}return{steps:i,actionKey:a,actionArg:o,lastSeenIdx:n.length}}return e}function oe({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=s(`jobs`),[c,l]=(0,N.useState)(n),d=(0,N.useMemo)(()=>I(t),[t]),f=e.status===`running`,p=e.status===`completed`,[ee,te]=(0,N.useState)(()=>Date.now());(0,N.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>te(Date.now()),1e3);return()=>window.clearInterval(e)},[f]);let[m,h]=(0,N.useReducer)(R,L),_=(0,N.useRef)(e.id);(0,N.useEffect)(()=>{_.current!==e.id&&(_.current=e.id,h({type:`reset`})),h({type:`consume`,events:t})},[e.id,t]);let[v,y]=(0,N.useState)(!0);(0,N.useEffect)(()=>{if(!f)return;y(!0);let e=window.setTimeout(()=>y(!1),8e3);return()=>window.clearTimeout(e)},[f,e.id]);let b=e.finished_at?F(e.started_at,e.finished_at):f?F(e.started_at,ee):`—`,re=!!e.total_cost_usd_estimated,C=e.total_cost_usd==null?null:`${re?`~`:``}$${e.total_cost_usd.toFixed(4)}`,ie=e.num_turns==null?null:String(e.num_turns),w=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),T=w==null?null:`${(w/1e3).toFixed(1)}k`,E=(0,N.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),D=f&&m.steps===0?`connecting`:m.actionKey||`thinking`,O=A.has(D)&&m.actionArg!==``,k=A.has(D)&&!O?`working`:D,ae=O?o(`statusPanel.activity.${k}`,{arg:m.actionArg}):o(`statusPanel.activity.${k}`),j=E??(f&&m.steps===0?o(`statusPanel.activity.starting`):null),M=m.steps>0?o(`statusPanel.steps`,{count:m.steps}):null,oe=o(f?`statusPanel.inProgress`:p?`statusPanel.completed`:`statusPanel.failed`),H=f?`border-accent-info/20 bg-accent-info/5`:p?`border-emerald-500/20 aurora-light:border-accent-success/30 bg-emerald-500/5 aurora-light:bg-accent-success/5`:`border-red-500/20 aurora-light:border-destructive/30 bg-red-500/5 aurora-light:bg-destructive/5`,se=f?g:p?S:ne,U=f?`w-4 h-4 text-accent-info shrink-0 animate-spin`:p?`w-4 h-4 text-emerald-400 aurora-light:text-accent-success shrink-0`:`w-4 h-4 text-red-400 aurora-light:text-destructive shrink-0`;return(0,P.jsxs)(`div`,{className:x(`mx-4 my-2 rounded-xl border transition-colors duration-500`,H),children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>l(!c),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,P.jsx)(se,{className:U,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:oe}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,P.jsx)(`span`,{className:`tabular-nums`,children:b}),f?M&&(0,P.jsx)(`span`,{className:`tabular-nums`,children:M}):(0,P.jsxs)(P.Fragment,{children:[C&&(0,P.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:C}),d.length>0&&(0,P.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:d.length})})]})]}),(0,P.jsx)(u,{className:x(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,c&&`rotate-180`)})]}),c&&(0,P.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:f?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,P.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,P.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,P.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,P.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:o(`statusPanel.liveTooltip`),"aria-label":o(`statusPanel.liveTooltip`)})]}),(0,P.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:b})]}),(0,P.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,P.jsx)(g,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),j&&(0,P.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:j}),(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:ae}),M&&(0,P.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,M]})]})]}),v&&(0,P.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,P.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:o(`statusPanel.zoneFinalPending`)}),(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,P.jsx)(V,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,P.jsx)(V,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,P.jsx)(V,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,P.jsx)(z,{label:o(`statusPanel.duration`),value:b}),(0,P.jsx)(B,{label:o(`statusPanel.cost`),value:C,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,P.jsx)(B,{label:o(`statusPanel.turns`),value:ie,naCaption:o(`statusPanel.notAvailable`)}),(0,P.jsx)(B,{label:o(`statusPanel.tokens`),value:T,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,P.jsx)(z,{label:o(`statusPanel.totalCost`),value:r.costUnavailable?`—`:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,P.jsx)(z,{label:o(`statusPanel.totalTokens`),value:r.tokensUnavailable?`—`:`${(r.nullTokenCount??0)>0?`≥`:``}${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&!r.costUnavailable&&(0,P.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:o(`statusPanel.pipelinePartialTooltip`),children:o(`statusPanel.pipelinePartial`,{count:r.nullCostCount??0})}),r.costUnavailable&&(0,P.jsx)(`p`,{"data-testid":`pipeline-cost-unavailable`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,children:o(`statusPanel.pipelineCostUnavailable`)}),(r.nullTokenCount??0)>0&&(0,P.jsx)(`p`,{"data-testid":`pipeline-usage-coverage-hint`,className:`text-[10px] text-muted-foreground/70 mt-1`,title:o(`statusPanel.pipelineUsageTooltip`),children:r.tokensUnavailable?o(`statusPanel.pipelineUsageUnavailable`):o(`statusPanel.pipelineUsagePartial`,{count:r.nullTokenCount??0})})]}),d.length>0&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,P.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80 aurora-light:text-accent-info`,children:e},e))})]})]})})]})}function z({label:e,value:t,valueClass:n}){return(0,P.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,P.jsx)(`p`,{className:x(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function B({label:e,value:t,valueClass:n,naCaption:r}){return(0,P.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,P.jsx)(`p`,{className:x(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function V({label:e,caption:t,tooltip:n}){return(0,P.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,P.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,P.jsx)(D,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,P.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var H=4;function se({tickets:e,onTicketClick:t}){let{t:n}=s(`jobs`),[r,i]=(0,N.useState)(!1);if(e.length===0)return null;let a=e.length>=H&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,P.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,P.jsx)(U,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,P.jsx)(u,{className:`w-3 h-3`})]}),r&&e.length>=H&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,P.jsx)(l,{className:`w-3 h-3`})]})]})}function U({ticket:e,onClick:t}){let{t:n}=s(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,P.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,P.jsx)(`span`,{className:x(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,P.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,P.jsxs)(`span`,{className:x(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,P.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var W={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.completed`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queued`}};function G(){let{t:e}=s(`jobs`),{id:t}=a(),{activeProjectId:n,projects:l}=y(),u=l.find(e=>e.id===n)?.provider,ne=r(),{openTicketDetail:g}=m(),[S,E]=(0,N.useState)(null),[D,A]=(0,N.useState)([]),[j,F]=(0,N.useState)([]),[I,L]=(0,N.useState)({}),[R,z]=(0,N.useState)([]),[B,V]=(0,N.useState)(!0),[H,U]=(0,N.useState)(!1),[G,K]=(0,N.useState)(!1),q=(0,N.useRef)(!1),J=(0,N.useRef)(null);(0,N.useEffect)(()=>{q.current=!1,J.current=null,K(!1)},[t]),(0,N.useEffect)(()=>{if(!t)return;let e=new AbortController;E(null),A([]),F([]),L({}),V(!0),U(!1);async function n(){try{let n=await fetch(`${v()}/jobs/${t}`,{signal:e.signal});if(n.status===404){U(!0);return}if(!n.ok)throw Error(`Failed to fetch job`);let r=await n.json();E(r.job),A(r.events)}catch(e){if(e.name===`AbortError`)return;U(!0)}finally{e.signal.aborted||V(!1)}}return n(),()=>e.abort()},[t,n]),(0,N.useEffect)(()=>{if(!S?.pipeline_id){z([]);return}let e=S.pipeline_id;fetch(`${v()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&z(e.jobs)}).catch(()=>{})},[S?.pipeline_id,S?.status]);let Y=(0,N.useRef)(n);Y.current=n;let ce=(0,N.useRef)(null);ce.current=S?.status??null;let X=(0,N.useRef)([]),Z=(0,N.useRef)(null),le=(0,N.useCallback)(()=>{Z.current=null;let e=X.current;e.length!==0&&(X.current=[],A(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),Q=(0,N.useCallback)(e=>{let t=X.current;t.push(e),t.length>1e4&&(X.current=t.slice(-8e3)),Z.current||=requestAnimationFrame(le)},[le]);(0,N.useEffect)(()=>()=>{Z.current&&cancelAnimationFrame(Z.current)},[]);let ue=(0,N.useCallback)(e=>{let n=e;if(!(Y.current&&n.projectId&&n.projectId!==Y.current)){if(n.type===`init`){let e=n.phaseDefinitions??[];F(e);let t={};for(let r of e)t[r.key]=n.phases?.[r.key]??`idle`;L(t)}else if(n.type===`event`&&n.jobId===t){let e={id:Date.now(),job_id:t??``,seq:n.seq??0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};Q(e)}else if(n.type===`log`&&n.processId===t){let e={id:Date.now(),job_id:t??``,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};Q(e)}else if(n.type===`job.finalized`&&n.jobId===t||n.type===`job.interactive`&&n.jobId===t||(n.type===`loop.run_paused`||n.type===`loop.run_resumed`)&&n.loopRunId===t)fetch(`${v()}/jobs/${t}`).then(e=>e.json()).then(e=>E(e.job)).catch(()=>{});else if(n.type===`phase`){let e=n.phase,t=n.state;L(n=>({...n,[e]:t}))}else if(n.type===`queue`){let e=n.jobs?.find(e=>e.id===t);if(e){let n=e.status,r=ce.current;E(e=>e&&{...e,status:n}),(n===`completed`||n===`failed`||n===`canceled`||n===`running`&&r!==`running`)&&fetch(`${v()}/jobs/${t}`).then(e=>e.json()).then(e=>E(e.job)).catch(()=>{})}}}},[t,Q]),{registerHandler:de,unregisterHandler:fe}=_();(0,N.useEffect)(()=>(de(`job-detail-${t}`,ue),()=>fe(`job-detail-${t}`)),[t,ue,de,fe]),(0,N.useEffect)(()=>{if(!t||!S||S.status!==`running`||S.hasTelemetry)return;let e=setInterval(()=>{fetch(`${v()}/jobs/${t}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&E(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[t,S?.status,S?.hasTelemetry]);async function pe(){if(!t)return;let n=await ae({projectId:null,jobId:t});n.ok?c.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):n.httpStatus===null?c.error(e(`detail.toast.networkError`)):c.error(e(`detail.toast.failed`),{description:n.error})}async function me(){if(S)try{let t=await fetch(`${v()}/jobs/${S.id}/diagnostic`);if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`detail.toast.exportFailedHttp`,{status:t.status}))}let n=await t.blob(),r=URL.createObjectURL(n),i=new Date().toISOString().slice(0,10),a=document.createElement(`a`);a.href=r,a.download=`specrails-diagnostic-${S.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){c.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function he(){if(!(!S||q.current)){q.current=!0,K(!0),J.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${S.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${v()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":J.current},body:JSON.stringify({rerunOfJobId:S.id})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));J.current=null,c.success(e(`detail.toast.jobRequeued`)),ne(`/jobs/${n.jobId}`)}catch(e){c.error(e.message)}finally{q.current=!1,K(!1)}}}if(B)return(0,P.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,P.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,P.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(H||!S)return(0,P.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,P.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:t})}),(0,P.jsx)(b,{asChild:!0,variant:`outline`,size:`sm`,children:(0,P.jsxs)(i,{to:`/`,children:[(0,P.jsx)(k,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=W[S.status]??W.queued,ge=S.status===`running`,_e=S.status===`completed`||S.status===`failed`,ve=!!S.interactive,ye=ve&&ge,be=(S.tickets?.length??0)>0,xe=S.command.startsWith(`loop:`),Se=R.length>1?{totalCostUsd:R.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:R.some(e=>e.total_cost_usd==null),costEstimated:R.some(e=>!!e.total_cost_usd_estimated),nullCostCount:R.filter(e=>e.total_cost_usd==null).length,costUnavailable:R.every(e=>e.total_cost_usd==null),totalTokensIn:R.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:R.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:R.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:R.reduce((e,t)=>e+(t.tokens_cache_create??0),0),nullTokenCount:R.filter(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null).length,tokensUnavailable:R.every(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null),jobCount:R.length}:null;return(0,P.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,P.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,P.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,P.jsx)(k,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,P.jsx)(d,{className:`w-3 h-3`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:t?.slice(0,8)})})]}),be&&(0,P.jsx)(se,{tickets:S.tickets??[],onTicketClick:g}),(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,P.jsxs)(w,{children:[(0,P.jsx)(C,{asChild:!0,children:(0,P.jsx)(`div`,{children:(0,P.jsx)(ie,{variant:$.variant,children:e($.labelKey)})})}),(0,P.jsx)(T,{children:e($.tooltipKey)})]}),(0,P.jsx)(`code`,{className:x(`font-mono text-foreground/90 truncate`,be?`text-xs text-muted-foreground`:`text-sm`),children:M(S.command,u)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,P.jsx)(`span`,{children:S.started_at?e(`detail.startedAgo`,{timeAgo:re(new Date(S.started_at),{addSuffix:!0,locale:o()})}):e(`detail.queuedWaiting`)}),S.model&&(0,P.jsx)(`span`,{className:`text-muted-foreground/40`,children:S.model})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[S.hasTelemetry&&(0,P.jsxs)(w,{children:[(0,P.jsx)(C,{asChild:!0,children:(0,P.jsxs)(b,{variant:`outline`,size:`sm`,className:`h-7`,onClick:me,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,P.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,P.jsx)(T,{children:e(`detail.exportDiagnosticTooltip`)})]}),_e&&(0,P.jsxs)(w,{children:[(0,P.jsx)(C,{asChild:!0,children:(0,P.jsxs)(b,{variant:`outline`,size:`sm`,onClick:he,disabled:G,"aria-busy":G,className:`h-7`,children:[(0,P.jsx)(O,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,P.jsx)(T,{children:e(`detail.reExecuteTooltip`)})]}),ge&&(0,P.jsxs)(w,{children:[(0,P.jsx)(C,{asChild:!0,children:(0,P.jsx)(b,{variant:`outline`,size:`sm`,onClick:pe,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(ve?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,P.jsx)(T,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,P.jsx)(f,{phases:I,phaseDefinitions:j})]}),(S.status===`running`||S.status===`completed`||S.status===`failed`)&&(0,P.jsx)(oe,{job:S,events:D,defaultOpen:S.status===`completed`||S.status===`running`,pipelineTotals:Se??void 0,phases:I,phaseDefinitions:j}),(0,P.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:xe?(0,P.jsx)(p,{events:D,jobStatus:S.status,variant:`page`}):(0,P.jsx)(ee,{events:D})}),ye&&(0,P.jsx)(te,{jobId:S.id,settleMode:S.interactiveSettleMode,initialAcceptingTurns:S.interactiveAcceptingTurns,kind:S.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{G as default};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as i}from"./i18n-nJQvD5zJ.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s}from"./dist-bVqfYmby.js";import{t as c}from"./circle-x-CMYsN4ZH.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{t as d}from"./x-CBMI9ejn.js";import{a as f}from"./auth-D_5bQv5W.js";import{t as p}from"./api-B2M7CtDw.js";import{i as m,r as h}from"./useDesktop-B6Du2N83.js";import{t as g}from"./button-BUIIBQPT.js";import{a as _,c as v,i as y,n as b,o as ee,r as x,s as S,t as te}from"./dialog-CzIekCw0.js";import{n as ne,t as re}from"./lib-CGdyxIWg.js";import{t as C}from"./formatDistanceToNow-BOuXgebD.js";import{Dt as w,Et as T,F as E,I as ie,M as D,N as O,mt as ae,t as k}from"./index-DdC_faQv.js";import{n as A,t as j}from"./job-time-BCL7wee9.js";import{t as oe}from"./format-command-C0D9IPmV.js";import{t as M}from"./ExportDropdown-BrtfWzEG.js";var se=o(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),N=e(t(),1),P=n();function F(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function I(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function L(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function R({label:e,a:t,b:n,highlight:r}){return(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,P.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,P.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function z(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function ce({jobIds:e,onClose:t}){let{t:n}=a(`jobs`),[r,i]=(0,N.useState)(null),[o,s]=(0,N.useState)(!0),[l,u]=(0,N.useState)(null),{panelRef:f,panelStyle:m,headerHandleProps:h,resizeHandles:g,isFloating:_,guardBackdrop:y}=v();(0,N.useEffect)(()=>{let t=new AbortController;return fetch(`${p()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i(e),s(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),s(!1))}),()=>t.abort()},[e]);function b(e,t){return(0,P.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,P.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,P.jsx)(w,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,P.jsx)(c,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,P.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:y(t),children:[(0,P.jsxs)(`div`,{ref:f,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:m,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between ${_?`cursor-grab active:cursor-grabbing`:``}`,...h,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,P.jsx)(d,{className:`w-4 h-4`})})]}),o&&(0,P.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,P.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,P.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:l})}),r&&(()=>{let[e,t]=r.jobs,i=z(e.durationMs,t.durationMs,!0),a=z(e.totalCostUsd,t.totalCostUsd,!0),o=z(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,P.jsx)(`div`,{}),b(e,0),b(t,1)]}),(0,P.jsx)(R,{label:n(`comparison.duration`),a:F(e.durationMs),b:F(t.durationMs),highlight:i}),(0,P.jsx)(R,{label:n(`comparison.cost`),a:I(e.totalCostUsd),b:I(t.totalCostUsd),highlight:a}),(0,P.jsx)(R,{label:n(`comparison.tokensOut`),a:L(e.tokensOut),b:L(t.tokensOut),highlight:o}),(0,P.jsx)(R,{label:n(`comparison.tokensIn`),a:L(e.tokensIn),b:L(t.tokensIn),highlight:null}),(0,P.jsx)(R,{label:n(`comparison.cacheRead`),a:L(e.tokensCacheRead),b:L(t.tokensCacheRead),highlight:null}),(0,P.jsx)(R,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,P.jsx)(R,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,P.jsx)(S,{handles:g})]})}var le={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},ue=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],de={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function fe(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function pe(e,t){let n=A(e),r=A(t);if(!n||!r)return null;let i=r.getTime()-n.getTime();if(i<0)return null;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}function me(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function he(e){let t=A(e);return t?C(t,{addSuffix:!0,locale:i()}):`—`}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function B(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function _e(e,t,n){if(!t&&!n)return!0;let r=A(e);if(!r)return!0;let i=r.getTime();return!(t&&i<ge(t)||n&&i>B(n))}var V=10;function H({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:o,onProposalClick:c,onProposalDelete:d}){let{t:f}=a(`jobs`),m=r(),{activeProjectId:ne,projects:re}=h(),C=re.find(e=>e.id===ne)?.provider,[w,k]=(0,N.useState)(null),[A,M]=(0,N.useState)(``),[F,I]=(0,N.useState)(``),[L,R]=(0,N.useState)(!1),[z,H]=(0,N.useState)(``),[U,W]=(0,N.useState)(``),[G,ve]=(0,N.useState)(!1),[K,q]=(0,N.useState)(null),[J,ye]=(0,N.useState)(V),[Y,be]=(0,N.useState)(!1),[X,Z]=(0,N.useState)([]),[xe,Q]=(0,N.useState)(null),{panelRef:Se,panelStyle:Ce,headerHandleProps:we,resizeHandles:Te,isFloating:Ee,guardBackdrop:De}=v();(0,N.useEffect)(()=>{ye(V)},[e.length]);function Oe(){be(e=>!e),Z([])}function ke(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>w&&e.status!==w?!1:_e(j(e),A,F)),Ae=e.filter(e=>_e(j(e),z,U)).length;async function je(e){ve(!0);try{let t={};e===`range`&&(z&&(t.from=new Date(ge(z)).toISOString()),U&&(t.to=new Date(B(U)).toISOString()));let n=await fetch(`${p()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();s.success(f(`recent.toast.cleared`,{count:e.deleted})),R(!1),H(``),W(``),o?.()}else s.error(f(`recent.toast.clearFailed`))}catch{s.error(f(`recent.toast.networkError`))}finally{ve(!1)}}let Me=n?(0,P.jsxs)(`div`,{role:`alert`,"data-testid":`jobs-load-error`,className:`flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,P.jsx)(u,{className:`h-4 w-4 shrink-0`}),(0,P.jsx)(`span`,{className:`flex-1`,children:f(`recent.loadFailed`)}),i&&(0,P.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,onClick:i,disabled:t,children:f(`common:actions.retry`)})]}):null;return n&&e.length===0?(0,P.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,P.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,P.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,P.jsx)(T,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,P.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:f(`recent.emptyTitle`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:f(`recent.emptyDescription`)})]}):(0,P.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${w===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterAll`,{count:e.length})}),ue.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(w===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${w===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterStatus`,{status:f(`statusName.${t}`),count:n})},t)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`input`,{type:`date`,value:A,onChange:e=>M(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.fromDate`)}),(0,P.jsx)(`input`,{type:`date`,value:F,onChange:e=>I(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.toDate`)}),(A||F)&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>{M(``),I(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:f(`recent.clear`)}),(0,P.jsxs)(D,{children:[(0,P.jsx)(E,{asChild:!0,children:(0,P.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${Y?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:Oe,children:(0,P.jsx)(se,{className:`w-3.5 h-3.5`})})}),(0,P.jsx)(O,{children:f(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,P.jsxs)(D,{children:[(0,P.jsx)(E,{asChild:!0,children:(0,P.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>R(!0),children:(0,P.jsx)(l,{className:`w-3.5 h-3.5`})})}),(0,P.jsx)(O,{children:f(`recent.clearJobs`)})]})]})]}),Y&&(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,P.jsxs)(`span`,{children:[X.length===0&&f(`recent.selectTwoToCompare`),X.length===1&&f(`recent.selectOneMore`),X.length===2&&f(`recent.readyToCompare`)]}),X.length===2&&(0,P.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:f(`recent.compareAction`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,P.jsx)(`span`,{className:`w-14`,children:f(`recent.colStatus`)}),(0,P.jsx)(`span`,{className:`flex-1 min-w-0`,children:f(`recent.colCommand`)}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,P.jsx)(`span`,{className:`w-14 text-right`,children:f(`recent.colDuration`)}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colTokens`)}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colCost`)}),(0,P.jsx)(`span`,{className:`w-20 text-right`,children:f(`recent.colStarted`)})]})]}),(0,P.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,J).map(e=>{let t=le[e.status]??le.queued,n=fe(e.total_cost_usd),r=pe(e.started_at,e.finished_at),i=me((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),o=a?e.id.replace(`proposal:`,``):null,s=X.includes(e.id),u=Y&&!a&&X.length===2&&!s,d=()=>{if(Y&&!a){ke(e.id);return}a&&o?c?.(o):m(`/jobs/${e.id}`)};return(0,P.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${s?`bg-accent/70 ring-1 ring-border`:u?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:d,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d()))},children:[(0,P.jsxs)(D,{children:[(0,P.jsx)(E,{asChild:!0,children:(0,P.jsx)(`div`,{children:(0,P.jsx)(ie,{variant:t.variant,children:f(t.labelKey)})})}),(0,P.jsx)(O,{children:f(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,P.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${de[e.priority].className}`,children:f(de[e.priority].labelKey)}),e.profile_name&&(0,P.jsxs)(D,{children:[(0,P.jsx)(E,{asChild:!0,children:(0,P.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,P.jsx)(O,{children:f(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,P.jsxs)(D,{children:[(0,P.jsx)(E,{asChild:!0,children:(0,P.jsx)(ae,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,P.jsxs)(O,{children:[f(`recent.pipelinePart`),e.depends_on_job_id&&` ${f(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,P.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:oe(e.command,C)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,P.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,P.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:he(e.started_at)}),a&&o&&(0,P.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),q(o)},title:f(`recent.deleteProposal`),children:(0,P.jsx)(l,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>J&&(0,P.jsx)(`div`,{className:`pt-1 text-center`,children:(0,P.jsx)(`button`,{type:`button`,onClick:()=>ye(e=>e+V),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:f(`recent.loadMore`,{count:$.length-J})})}),L&&(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:De(()=>R(!1)),children:[(0,P.jsxs)(`div`,{ref:Se,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:Ce,children:[(0,P.jsxs)(`div`,{...we,className:Ee?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:f(`recent.clearModal.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:f(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,P.jsx)(g,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:G,onClick:()=>je(`all`),children:f(`recent.clearModal.clearAll`,{count:e.length})}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f(`recent.clearModal.orByRange`)}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(`input`,{type:`date`,value:z,onChange:e=>H(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:f(`recent.clearModal.fromPlaceholder`)}),(0,P.jsx)(`input`,{type:`date`,value:U,onChange:e=>W(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:f(`recent.clearModal.toPlaceholder`)})]}),(0,P.jsx)(g,{variant:`outline`,size:`sm`,className:`w-full`,disabled:G||!z&&!U,onClick:()=>je(`range`),children:z||U?f(`recent.clearModal.clearInRange`,{count:Ae}):f(`recent.clearModal.clearRange`)})]}),(0,P.jsx)(g,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>R(!1),children:f(`common:actions.cancel`)})]}),(0,P.jsx)(S,{handles:Te})]}),(0,P.jsx)(te,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,P.jsxs)(b,{className:`max-w-sm`,children:[(0,P.jsxs)(_,{children:[(0,P.jsx)(ee,{children:f(`recent.deleteProposalConfirm.title`)}),(0,P.jsx)(x,{children:f(`recent.deleteProposalConfirm.description`)})]}),(0,P.jsxs)(y,{children:[(0,P.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>q(null),children:f(`common:actions.cancel`)}),(0,P.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{K&&d?.(K),q(null)},children:f(`common:actions.delete`)})]})]})}),xe&&(0,P.jsx)(ce,{jobIds:xe,onClose:()=>{Q(null),Z([]),be(!1)}})]})}var U={input:`page.proposal.status.input`,exploring:`page.proposal.status.exploring`,review:`page.proposal.status.review`,refining:`page.proposal.status.refining`,creating_issue:`page.proposal.status.creatingIssue`,created:`page.proposal.status.created`,cancelled:`page.proposal.status.cancelled`};function W(e){return`${f}/api/projects/${encodeURIComponent(e)}`}function G(){let{t:e}=a(`jobs`),{activeProjectId:t}=h(),{recentJobs:n}=k(t),{data:r,isFirstLoad:i,isLoading:o,error:c,refresh:l}=m({namespace:`jobs`,projectId:t,initialValue:n,fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${W(e)}/jobs?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch jobs: ${n.status}`);return(await n.json()).jobs},pollInterval:1e4}),{data:u,isFirstLoad:d,isLoading:f,error:v,refresh:x}=m({namespace:`proposals`,projectId:t,initialValue:[],fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${W(e)}/propose?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals},pollInterval:1e4}),S={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},C=u.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,enqueued_at:e.created_at,status:S[e.status]??`queued`})),w=[...r,...C].sort((e,t)=>(A(j(t))?.getTime()??0)-(A(j(e))?.getTime()??0)),[T,E]=(0,N.useState)(null),D=(0,N.useCallback)(async e=>{try{let t=await fetch(`${p()}/propose/${e}`);if(!t.ok)return;let n=await t.json();E(n.proposal)}catch{}},[]),O=(0,N.useCallback)(async t=>{try{(await fetch(`${p()}/propose/${t}`,{method:`DELETE`})).ok&&(s.success(e(`page.proposalDeleted`)),await x())}catch{}},[x,e]);return(0,P.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,P.jsx)(M,{baseUrl:`${p()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,P.jsx)(H,{jobs:w,isLoading:i||d||o||f,error:c??v,onRetry:()=>{Promise.all([l(),x()])},onJobsCleared:l,onProposalClick:D,onProposalDelete:O}),(0,P.jsx)(te,{open:T!==null,onOpenChange:e=>!e&&E(null),children:(0,P.jsx)(b,{className:`max-w-3xl glass-card`,children:T&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(_,{children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(ee,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,P.jsx)(ie,{variant:T.status===`created`?`success`:T.status===`cancelled`?`destructive`:`secondary`,children:e(U[T.status]??`page.proposal.status.unknown`,{status:T.status})})]})}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:T.idea}),T.result_markdown?(0,P.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,P.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,P.jsx)(ne,{remarkPlugins:[re],children:T.result_markdown})})}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),T.issue_url&&(0,P.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,P.jsx)(`a`,{href:T.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:T.issue_url})]}),(0,P.jsxs)(y,{children:[(0,P.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{O(T.id),E(null)},children:e(`common:actions.delete`)}),(0,P.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>E(null),children:e(`common:actions.close`)})]})]})})})]})}export{G as default};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{l as i}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{t as o}from"./brain-DI9lHkKY.js";import{t as s}from"./pencil-C9RkrIPZ.js";import{t as c}from"./button-BUIIBQPT.js";import{t as l}from"./utils-BC4DHlz2.js";import{$ as u,pt as d}from"./index-DdC_faQv.js";import{r as f,t as p}from"./TemplatePreviewModal-DcgWnn23.js";var m=e(t(),1),h=e(r(),1),g=n();function _({loop:e,onClose:t}){let{t:n}=a(`loops`),r=i();return(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,h.createPortal)((0,g.jsxs)(`div`,{"data-testid":`loop-preview-modal`,className:`fixed inset-0 z-[65] flex items-center justify-center p-4`,children:[(0,g.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t,"aria-hidden":!0}),(0,g.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":e.name,className:`relative flex max-h-[80vh] w-full max-w-lg flex-col gap-4 overflow-hidden rounded-xl border border-border/30 bg-popover p-6 shadow-xl backdrop-blur-md`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 pr-6`,children:[(0,g.jsx)(o,{className:`h-4 w-4 shrink-0 text-accent-highlight`}),(0,g.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold text-foreground`,children:e.name}),(0,g.jsxs)(`span`,{className:l(`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide`,e.locked?`border-accent-info/40 bg-accent-info/10 text-accent-info`:e.status===`published`?`border-accent-success/40 bg-accent-success/10 text-accent-success`:`border-border/60 bg-surface/60 text-foreground/60`),children:[e.locked&&(0,g.jsx)(d,{className:`h-2.5 w-2.5`}),e.locked?n(`preview.builtin`):n(`status.${e.status??`draft`}`,{defaultValue:e.status??``})]})]}),e.description&&(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description})]}),(0,g.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?n(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):n(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,g.jsxs)(`div`,{className:`min-h-0 space-y-1.5 overflow-y-auto pr-1`,children:[(0,g.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:n(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let r=p[e.type]??u,i=f(e);return(0,g.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,g.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[t+1,`.`]}),(0,g.jsx)(r,{className:`h-3.5 w-3.5 text-accent-primary`}),n(`builder.nodes.${e.type}`)]}),i&&(0,g.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground`,children:i})]},e.id)})]}),(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[(0,g.jsx)(c,{variant:`ghost`,onClick:t,children:n(`common:actions.close`)}),!e.locked&&(0,g.jsxs)(c,{"data-testid":`loop-preview-open-builder`,onClick:()=>{t(),r(`/loops/${encodeURIComponent(e.id)}/edit`)},children:[(0,g.jsx)(s,{className:`mr-1.5 h-3.5 w-3.5`}),n(`preview.openInBuilder`)]})]})]})]}),document.body)}export{_ as LoopPreviewModal};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o}from"./dist-bVqfYmby.js";import{t as s}from"./download-CFHyyHcw.js";import{t as c}from"./pencil-C9RkrIPZ.js";import{t as l}from"./play-DNlrawbS.js";import{t as u}from"./plus-CsnjfkmX.js";import{t as d}from"./sparkles-DrY8hb0X.js";import{t as f}from"./trash-2-BOU3WdZZ.js";import{t as p}from"./upload-DYMjAQ6M.js";import{n as m,r as h}from"./useDesktop-B6Du2N83.js";import{t as g}from"./button-BUIIBQPT.js";import{t as _}from"./utils-BC4DHlz2.js";import{a as v,i as ee,n as te,o as ne,r as re,t as y}from"./dialog-CzIekCw0.js";import{a as b,p as x,r as S,t as C}from"./provider-capabilities-Doej9lfa.js";import{A as w,C as T,Ct as E,O as ie,T as D,Y as O,j as k,k as A,w as j,wt as M}from"./index-DdC_faQv.js";import{n as N}from"./TemplatePreviewModal-DcgWnn23.js";var P=a(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),ae=a(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),F=e(t(),1);function oe(e){return{specrailsLoops:1,loops:e.map(e=>({name:e.name,description:e.description,graph:e.graph}))}}function I(e){let t=e;return!!t&&typeof t.name==`string`&&!!t.graph&&typeof t.graph==`object`}function se(e){let t;try{t=JSON.parse(e)}catch{throw Error(`invalid-json`)}let n=(Array.isArray(t)?t:Array.isArray(t?.loops)?t.loops:I(t)?[t]:[]).filter(I);if(n.length===0)throw Error(`no-loops`);return n.map(e=>({name:e.name,description:e.description??null,graph:e.graph}))}function ce(e){return e.length===1?`${e[0].name.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`loop`}.loop.json`:`specrails-loops-${e.length}.json`}var le=[`API`,`Automation`,`CI`,`Database`,`Debugging`,`DevOps`,`Docs`,`Git`,`Maintenance`,`Performance`,`Planning`,`Quality`,`Review`,`Security`,`Testing`];function ue(e,t){let n=t.query.trim().toLowerCase(),r=t.categories;return e.filter(e=>r.length>0&&!(e.category&&r.includes(e.category))?!1:!n||`${e.name} ${e.description} ${e.tags.join(` `)} ${e.category??``} ${e.searchTerms??``}`.toLowerCase().includes(n))}function de(e){let t=new Map;for(let n of e)n.category&&t.set(n.category,(t.get(n.category)??0)+1);let n=[];for(let e of le){let r=t.get(e);r&&(n.push({category:e,count:r}),t.delete(e))}for(let e of[...t.keys()].sort())n.push({category:e,count:t.get(e)});return n}var L=n();function fe({loop:e,projects:t,onClose:n,onExecute:r}){let{t:a}=i(`loops`),o=e!==null,[s,c]=(0,F.useState)(``),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),_=t.find(e=>e.id===(s||t[0]?.id)),T=(0,F.useMemo)(()=>_?.providers??(_?.provider?[_.provider]:[]),[_]),E=u||T[0]||``,D=(0,F.useMemo)(()=>k(E),[E]),O=b(E),j=f&&(D.some(e=>e.value===f)||O&&A(f))?f:w(E),M=x(E,j),N=M.includes(m)?m:C(E,j)??``,P=M.length>0;return(0,L.jsx)(y,{open:o,onOpenChange:e=>{e||n()},children:(0,L.jsx)(te,{movableResizable:!0,className:`max-w-sm`,children:e&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(v,{children:[(0,L.jsx)(ne,{children:a(`run.title`,{name:e.name})}),(0,L.jsx)(re,{children:a(`run.subtitle`)})]}),(0,L.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.project`)}),t.length===0?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`run.noProjects`)}):(0,L.jsx)(`select`,{"aria-label":a(`run.project`),"data-testid":`run-project-select`,value:s||t[0]?.id,onChange:e=>{c(e.target.value),d(``),p(``),h(``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.name},e.id))}),T.length>1&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.provider`)}),(0,L.jsx)(`select`,{"aria-label":a(`run.provider`),value:E,onChange:e=>{d(e.target.value),p(``),h(``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:T.map(e=>(0,L.jsx)(`option`,{value:e,children:S(e)},e))})]}),D.length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.model`)}),O?(0,L.jsx)(ie,{value:j,options:D,ariaLabel:a(`run.model`),testId:`run-model-select`,className:`w-full px-2 py-1 text-xs`,onCommit:e=>{p(e),h(C(E,e)??``)}}):(0,L.jsx)(`select`,{"aria-label":a(`run.model`),"data-testid":`run-model-select`,value:j,onChange:e=>{let t=e.target.value;p(t),h(C(E,t)??``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:D.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),P&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.effort`)}),(0,L.jsx)(`select`,{"aria-label":a(`run.effort`),value:N,onChange:e=>h(e.target.value),className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:M.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))})]}),(0,L.jsxs)(ee,{children:[(0,L.jsx)(g,{variant:`ghost`,onClick:n,children:a(`common:actions.cancel`)}),(0,L.jsxs)(g,{onClick:()=>{let e=s||t[0]?.id;e&&r({projectId:e,provider:T.length>1?E:void 0,model:D.length>0?j:void 0,effort:P?N:void 0})},disabled:t.length===0,children:[(0,L.jsx)(l,{className:`w-3.5 h-3.5 mr-1.5`}),a(`run.execute`)]})]})]})})})}var R={draft:`bg-accent-secondary/15 text-accent-secondary ring-accent-secondary/40`,published:`bg-accent-success/15 text-accent-success ring-accent-success/40`};function z({status:e}){let{t}=i(`loops`);return(0,L.jsx)(`span`,{className:_(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ring-1 ring-inset`,R[e]),children:t(`status.${e}`)})}function B({onOpenBuilder:e}={}){let{t}=i(`loops`),n=r(),a=(0,F.useCallback)(e=>e.replace(/:/g,`_`),[]),c=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.name`,{defaultValue:n}),[t,a]),l=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.description`,{defaultValue:n}),[t,a]),[p,b]=(0,F.useState)([]),[x,S]=(0,F.useState)([]),[C,w]=(0,F.useState)([]),[ie,k]=(0,F.useState)(!0),[A,I]=(0,F.useState)(null),[le,R]=(0,F.useState)(null),[z,B]=(0,F.useState)(`use`),[U,W]=(0,F.useState)(null),[G,pe]=(0,F.useState)(new Set),me=`specrails-desktop:loop-template-filter`,he=(()=>{try{let e=localStorage.getItem(me),t=e?JSON.parse(e):null;return{query:typeof t?.query==`string`?t.query:``,categories:Array.isArray(t?.categories)?t.categories:[]}}catch{return{query:``,categories:[]}}})(),[K,ge]=(0,F.useState)(he.query),[q,_e]=(0,F.useState)(he.categories);(0,F.useEffect)(()=>{try{localStorage.setItem(me,JSON.stringify({query:K,categories:q}))}catch{}},[K,q]);let ve=(0,F.useCallback)(e=>{_e(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),ye=(0,F.useCallback)(()=>{ge(``),_e([])},[]),be=(0,F.useRef)(null),{projects:xe,setActiveProjectId:Se}=h(),Ce=(0,F.useCallback)(e=>{pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),J=(0,F.useCallback)(e=>{if(e.length===0)return;let t=new Blob([JSON.stringify(oe(e),null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=ce(e),r.click(),URL.revokeObjectURL(n)},[]),Y=(0,F.useCallback)(async()=>{try{let[e,t]=await Promise.all([D.list(),D.templates()]);b(e),S(t)}catch{o.error(t(`errors.load`))}finally{k(!1)}try{w(await D.factoryLoops())}catch{w([])}},[t]);(0,F.useEffect)(()=>{Y()},[Y]);let we=(0,F.useCallback)(async e=>{try{let n=se(await e.text()),{imported:r,skipped:i}=await D.importLoops(n);await Y(),r.length&&o.success(t(`import.done`,{count:r.length})),i.length&&o.warning(t(`import.skipped`,{count:i.length,names:i.join(`, `)})),!r.length&&!i.length&&o.warning(t(`import.invalid`))}catch(e){let n=e instanceof Error?e.message:``;o.error(t(n===`invalid-json`||n===`no-loops`?`import.invalid`:`errors.save`))}},[Y,t]),X=(0,F.useCallback)(t=>{e?e(t):n(`/loops/${t}/edit`)},[e,n]),Te=(0,F.useCallback)(async()=>{try{let e=await D.create({name:t(`newLoopName`)});X(e.id)}catch{o.error(t(`errors.save`))}},[t,X]),Z=(0,F.useCallback)(async e=>{try{let t=await D.fromTemplate(e);X(t.id)}catch{o.error(t(`errors.save`))}},[t,X]),Ee=(0,F.useCallback)(async e=>{try{let t=await D.forkFactory(e);X(t.id)}catch{o.error(t(`errors.save`))}},[t,X]),De=(0,F.useCallback)(async({projectId:e,provider:r,model:i,effort:a})=>{let s=U;if(s){W(null);try{let{loopRunId:c}=await D.runStandalone(e,s.id,{aiEngine:r,model:i,reasoning_effort:a});Se(e),n(`/jobs/${c}`),o.success(t(`run.launched`,{name:s.name}))}catch{o.error(t(`errors.save`))}}},[U,n,Se,t]),Oe=(0,F.useCallback)(e=>{B(`fork`),R({id:e.id,name:c(e.id,e.name),description:l(e.id,e.description),tags:e.requiredCapability?[e.requiredCapability]:e.claudeOnly?[`claude-only`]:[],graph:e.graph})},[c,l]),ke=(0,F.useCallback)(async e=>{try{await D.publish(e),await Y()}catch(e){e instanceof j?o.error(t(`errors.publishInvalid`)):o.error(t(`errors.save`))}},[t,Y]),Ae=(0,F.useCallback)(async e=>{try{await D.unpublish(e),await Y()}catch{o.error(t(`errors.save`))}},[t,Y]),je=(0,F.useCallback)(async e=>{try{await D.duplicate(e),await Y()}catch{o.error(t(`errors.save`))}},[t,Y]),Me=(0,F.useCallback)(e=>I(e),[]),Ne=(0,F.useCallback)(async()=>{let e=A;if(e){I(null);try{await D.remove(e),await Y()}catch{o.error(t(`errors.save`))}}},[A,t,Y]),Q=p.filter(e=>e.status===`draft`),$=p.filter(e=>e.status===`published`),Pe=de(x),Fe=ue(x.map(e=>({...e,searchTerms:`${c(e.id,e.name)} ${l(e.id,e.description)} ${e.category?t(`categories.${e.category}`,{defaultValue:e.category}):``}`})),{query:K,categories:q}),Ie=K.trim()!==``||q.length>0;return(0,L.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 py-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,L.jsx)(O,{className:`w-5 h-5 text-accent-primary`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:t(`title`)}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:t(`subtitle`)})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[G.size>0&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>J(p.filter(e=>G.has(e.id))),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,L.jsx)(P,{className:`w-3.5 h-3.5`}),t(`actions.export`),` (`,G.size,`)`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>be.current?.click(),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,L.jsx)(ae,{className:`w-3.5 h-3.5`}),t(`actions.import`)]}),(0,L.jsx)(`input`,{ref:be,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&we(t),e.target.value=``}}),(0,L.jsxs)(`button`,{type:`button`,onClick:Te,className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium bg-accent-primary text-white hover:bg-accent-primary/90`,children:[(0,L.jsx)(u,{className:`w-3.5 h-3.5`}),t(`newLoop`)]})]})]}),ie?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`…`}):(0,L.jsxs)(`div`,{className:`space-y-8`,children:[Q.length===0&&$.length===0&&(0,L.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t(`empty.title`)}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t(`empty.body`)})]}),$.length>0&&(0,L.jsx)(V,{title:t(`sections.published`),children:$.map(e=>(0,L.jsx)(H,{loop:e,selected:G.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>X(e.id),onUnpublish:()=>Ae(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id),onRun:T(e.graph)?void 0:()=>W(e)},e.id))}),Q.length>0&&(0,L.jsx)(V,{title:t(`sections.drafts`),children:Q.map(e=>(0,L.jsx)(H,{loop:e,selected:G.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>X(e.id),onPublish:()=>ke(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id)},e.id))}),C.length>0&&(0,L.jsx)(V,{title:t(`sections.builtIn`),children:C.map(e=>(0,L.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`factory-loop-card`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(O,{className:`w-3.5 h-3.5 text-accent-primary`}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:c(e.id,e.name)}),(0,L.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:t(`builtInBadge`)})]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:l(e.id,e.description)}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>Oe(e),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,L.jsx)(E,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>void Ee(e.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,L.jsx)(M,{className:`w-3 h-3`}),t(`actions.fork`)]})]})]},e.id))}),x.length>0&&(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,L.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`sections.templates`)}),(0,L.jsx)(`input`,{type:`search`,value:K,onChange:e=>ge(e.target.value),placeholder:t(`gallery.search`),"aria-label":t(`gallery.search`),"data-testid":`template-search`,className:`h-7 w-48 max-w-full rounded-md border border-border bg-surface/40 px-2.5 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:ring-1 focus:ring-accent-primary`})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3`,"data-testid":`category-chips`,children:[Pe.map(({category:e,count:n})=>{let r=q.includes(e);return(0,L.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ve(e),className:_(`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] border transition-colors`,r?`border-accent-primary bg-accent-primary/15 text-accent-primary`:`border-border bg-surface/40 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[t(`categories.${e}`,{defaultValue:e}),(0,L.jsx)(`span`,{className:`opacity-60 tabular-nums`,children:n})]},e)}),Ie&&(0,L.jsx)(`button`,{type:`button`,onClick:ye,className:`inline-flex items-center h-6 px-2 rounded-full text-[11px] text-accent-primary hover:underline`,children:t(`gallery.clearFilter`)})]}),Fe.length===0?(0,L.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,"data-testid":`template-empty`,children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`gallery.noResults`)}),(0,L.jsx)(`button`,{type:`button`,onClick:ye,className:`mt-2 text-xs text-accent-primary hover:underline`,children:t(`gallery.clearFilter`)})]}):(0,L.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:Fe.map(e=>(0,L.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`template-card`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(d,{className:`w-3.5 h-3.5 text-accent-highlight flex-shrink-0`}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:c(e.id,e.name)}),e.category&&(0,L.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info flex-shrink-0`,children:t(`categories.${e.category}`,{defaultValue:e.category})})]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:l(e.id,e.description)}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[T(e.graph)?(0,L.jsx)(`span`,{title:t(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:t(`gallery.needsSpec`)}):(0,L.jsx)(`span`,{title:t(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:t(`gallery.standalone`)}),e.tags.map(e=>(0,L.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{B(`use`),R({...e,name:c(e.id,e.name),description:l(e.id,e.description)})},className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,L.jsx)(E,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>Z(e.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,L.jsx)(s,{className:`w-3 h-3`}),t(`actions.use`)]})]})]},e.id))})]})]})]}),(0,L.jsx)(y,{open:A!==null,onOpenChange:e=>{e||I(null)},children:(0,L.jsxs)(te,{className:`max-w-sm`,children:[(0,L.jsxs)(v,{children:[(0,L.jsxs)(ne,{className:`flex items-center gap-2`,children:[(0,L.jsx)(f,{className:`w-4 h-4 text-destructive`}),p.find(e=>e.id===A)?.name??t(`actions.delete`)]}),(0,L.jsx)(re,{children:t(`confirmDelete`)})]}),(0,L.jsxs)(ee,{children:[(0,L.jsx)(g,{variant:`ghost`,onClick:()=>I(null),children:t(`common:actions.cancel`)}),(0,L.jsx)(g,{variant:`destructive`,onClick:()=>void Ne(),children:t(`common:actions.delete`)})]})]})}),(0,L.jsx)(N,{template:le,mode:z,onClose:()=>R(null),onUse:e=>{R(null),z===`fork`?Ee(e):Z(e)}}),(0,L.jsx)(fe,{loop:U?{id:U.id,name:U.name}:null,projects:xe.map(e=>({id:e.id,name:e.name,providers:m(e)})),onClose:()=>W(null),onExecute:De})]})}function V({title:e,children:t}){return(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2`,children:e}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t})]})}function H({loop:e,selected:t,onToggleSelect:n,onEdit:r,onPublish:a,onUnpublish:o,onDuplicate:u,onExport:d,onDelete:m,onRun:h}){let{t:g}=i(`loops`),_=e.graph?.nodes?.length??0;return(0,L.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`loop-card`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:t,onChange:n,"aria-label":g(`actions.select`,{name:e.name}),className:`accent-accent-primary flex-shrink-0`}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.name})]}),(0,L.jsx)(z,{status:e.status})]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`card.nodes`,{count:_})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[h&&(0,L.jsx)(U,{icon:l,label:g(`actions.run`),onClick:h}),(0,L.jsx)(U,{icon:c,label:g(`actions.edit`),onClick:r}),a&&(0,L.jsx)(U,{icon:p,label:g(`actions.publish`),onClick:a}),o&&(0,L.jsx)(U,{icon:s,label:g(`actions.unpublish`),onClick:o}),(0,L.jsx)(U,{icon:M,label:g(`actions.duplicate`),onClick:u}),(0,L.jsx)(U,{icon:P,label:g(`actions.export`),onClick:d}),(0,L.jsx)(U,{icon:f,label:g(`actions.delete`),onClick:m,danger:!0})]})]})}function U({icon:e,label:t,onClick:n,danger:r}){return(0,L.jsx)(`button`,{type:`button`,onClick:n,title:t,"aria-label":t,className:_(`inline-flex items-center justify-center w-7 h-7 rounded-md transition-colors`,r?`text-muted-foreground hover:text-destructive hover:bg-destructive/10`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,L.jsx)(e,{className:`w-3.5 h-3.5`})})}export{B as default};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{l as i}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{t as s}from"./sparkles-DrY8hb0X.js";import{t as c}from"./x-CBMI9ejn.js";import{r as l}from"./useSharedWebSocket-DK96ctb7.js";import{r as u}from"./useDesktop-B6Du2N83.js";var d=o(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),f=o(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),p=o(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),m=o(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),h=e(t(),1),g=[`title`,`description`,`labels`,`priority`,`acceptanceCriteria`],_={title:``,description:``,labels:[],priority:`medium`,acceptanceCriteria:[]};function v(e){return!e||typeof e!=`object`?!1:e.type===`spec_draft.update`}var y=e(r(),1),b=n(),x=42;function S(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=x?t:t.slice(0,x-1).trimEnd()+`…`}function C({chat:e,projectName:t,onRestore:n,onClose:r}){let{t:i}=a(`chat`),o=S(e.label);return(0,b.jsxs)(`div`,{"data-testid":`minimized-chat-chip-${e.id}`,className:`grid items-start gap-2 w-full max-w-full`,style:{gridTemplateColumns:`auto minmax(0, 1fr) auto`},children:[(0,b.jsx)(w,{kind:e.kind}),(0,b.jsxs)(`button`,{type:`button`,onClick:n,className:`min-w-0 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50 rounded overflow-hidden`,"aria-label":i(`chip.restore`,{label:e.label}),title:e.label,children:[(0,b.jsx)(`div`,{className:`text-sm font-medium text-foreground truncate`,children:o}),(0,b.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5 truncate`,children:i(`chip.continueEditing`,{projectName:t})})]}),(0,b.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-6 h-6 rounded text-muted-foreground hover:text-foreground hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50`,"aria-label":i(`chip.close`,{label:e.label}),children:(0,b.jsx)(c,{className:`w-3.5 h-3.5`})})]})}function w({kind:e}){let{t}=a(`chat`);return(0,b.jsx)(e===`ai-edit`?s:m,{className:`w-4 h-4 text-accent-primary flex-shrink-0 mt-0.5`,"aria-label":t(e===`ai-edit`?`chip.kindAiEdit`:`chip.kindExploreSpec`)})}function T({chats:e,projects:t,hidden:n,onRestore:r,onClose:i}){let{t:o}=a(`chat`),s=(0,h.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.id,n.name);return e},[t]),c=(0,h.useMemo)(()=>[...e].sort((e,t)=>t.createdAt-e.createdAt),[e]);return n||c.length===0?null:(0,y.createPortal)((0,b.jsxs)(`div`,{"data-testid":`minimized-chats-dock`,"aria-label":o(`dock.minimizedSessions`,{count:c.length}),className:`fixed bottom-4 right-14 z-[70] flex flex-col-reverse gap-2 w-[320px] max-w-[calc(100vw-15rem)] max-h-[70vh] overflow-y-auto pointer-events-none`,children:[c.map(e=>(0,b.jsx)(`div`,{className:`pointer-events-auto glass-card border border-border/30 rounded-lg p-3 shadow-lg w-full`,children:(0,b.jsx)(C,{chat:e,projectName:s.get(e.projectId)??o(`dock.unknownProject`),onRestore:()=>r(e.id),onClose:()=>i(e.id)})},e.id)),c.length>1&&(0,b.jsxs)(`div`,{className:`pointer-events-auto self-end inline-flex items-center gap-1 rounded-full bg-card/80 border border-border/40 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur-sm`,children:[(0,b.jsx)(p,{className:`w-3 h-3`}),o(`dock.minimizedCount`,{count:c.length})]})]}),document.body)}var E=(0,h.createContext)(null),D=`specrails-desktop:minimized-chats`,O=`specrails-desktop:minimized-chats-pending`,k=50,A=8e3;function j(){return F(D)}function M(e){L(D,e)}function N(){return F(O)}function P(e){L(O,e)}function F(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(R):[]}catch{return[]}}function I(e){return e.length<=k?e:[...e].sort((e,t)=>e.createdAt-t.createdAt).slice(e.length-k)}function L(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(I(t)))}catch{}}function R(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.id!=`string`||typeof t.projectId!=`string`||typeof t.label!=`string`||typeof t.restoreRoute!=`string`||typeof t.createdAt!=`number`||t.kind!==`explore-spec`&&t.kind!==`ai-edit`||!t.params||typeof t.params!=`object`)}function z(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function B(e){return e.kind===`explore-spec`?e.params.resumeConversationId??`pending:${e.params.pendingSpecId}`:e.params.resumeRefineId??`agent:${e.params.agentId}`}function V(e,t){return e.kind!==t.kind||e.projectId!==t.projectId?!1:B(e)===B(t)}function H({children:e}){let{projects:t,activeProjectId:n,setActiveProjectId:r}=u(),a=i(),{registerHandler:o,unregisterHandler:s}=l(),[c,d]=(0,h.useState)(()=>j()),[f,p]=(0,h.useState)([]),m=(0,h.useRef)(c);m.current=c;let g=(0,h.useRef)(f);g.current=f;let _=(0,h.useRef)(new Map),y=(0,h.useRef)(t);y.current=t;let x=(0,h.useRef)(!1);(0,h.useEffect)(()=>{if(x.current)return;x.current=!0;let e=N();P([]),e.length!==0&&d(t=>{let n=[...t];for(let t of e)n.some(e=>e.id===t.id||V(e,t))||n.push(t);return M(n),m.current=n,n})},[]),(0,h.useEffect)(()=>{let e=_.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear()}},[]),(0,h.useEffect)(()=>{M(c)},[c]),(0,h.useEffect)(()=>{P(f)},[f]);let S=(0,h.useRef)(()=>{}),C=(0,h.useRef)(()=>{});(0,h.useEffect)(()=>{let e=`minimized-chats:spec-draft`;return o(e,e=>{if(!v(e))return;let t=e.conversationId,n=m.current.find(e=>e.kind===`explore-spec`&&e.params.resumeConversationId===t);if(!n)return;let r=e.draft;r.title?.trim()&&S.current(n.id,r.title);let i={};r.title!==void 0&&(i.title=r.title),r.description!==void 0&&(i.description=r.description),r.priority!==void 0&&(i.priority=r.priority),r.labels!==void 0&&(i.labels=r.labels),r.acceptanceCriteria!==void 0&&(i.acceptanceCriteria=r.acceptanceCriteria),Object.keys(i).length>0&&C.current(n.id,i)}),()=>s(e)},[o,s]),(0,h.useEffect)(()=>{if(t.length===0)return;let e=new Set(t.map(e=>e.id));d(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(M(n),m.current=n,n)}),p(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(P(n),g.current=n,n)})},[t]);let w=(0,h.useCallback)(e=>{let t=z(),n={...e,id:t,createdAt:Date.now()};if(d(e=>{let t=I([...e.filter(e=>!V(e,n)),n]);return M(t),m.current=t,t}),e.kind===`explore-spec`){let t=e.params.resumeConversationId;t&&fetch(`/api/projects/${e.projectId}/chat/conversations/${t}/minimize`,{method:`POST`}).catch(()=>{})}return t},[]),D=(0,h.useCallback)(e=>{let t=_.current.get(e);t&&(clearTimeout(t),_.current.delete(e))},[]),O=(0,h.useCallback)(e=>{D(e),d(t=>{let n=t.filter(t=>t.id!==e);return M(n),m.current=n,n}),p(t=>{let n=t.filter(t=>t.id!==e);return n.length===t.length?t:(P(n),g.current=n,n)})},[D]),k=(0,h.useCallback)((e,t)=>{let n=t.trim();n&&d(t=>{let r=t.map(t=>t.id===e&&t.label!==n?{...t,label:n}:t);return r===t?t:(m.current=r,r)})},[]),F=(0,h.useCallback)((e,t)=>{d(n=>{let r=n.map(n=>{if(n.id!==e||n.kind!==`explore-spec`)return n;let r={...n.params.draftOverrides??{},...t};return{...n,params:{...n.params,draftOverrides:r}}});return m.current=r,r})},[]),L=(0,h.useCallback)(e=>{let t=m.current.find(t=>t.id===e);if(!t||y.current.length>0&&!y.current.some(e=>e.id===t.projectId))return;if(t.kind===`explore-spec`){let e=t.params.resumeConversationId;e&&fetch(`/api/projects/${t.projectId}/chat/conversations/${e}/restore`,{method:`POST`}).catch(()=>{})}n!==t.projectId&&r(t.projectId),a(t.restoreRoute),p(n=>{let r=[...n.filter(t=>t.id!==e),t];return P(r),g.current=r,r}),d(t=>{let n=t.filter(t=>t.id!==e);return M(n),m.current=n,n}),D(e);let i=setTimeout(()=>{_.current.delete(e),g.current.some(t=>t.id===e)&&(p(t=>{let n=t.filter(t=>t.id!==e);return P(n),g.current=n,n}),d(n=>{if(n.some(n=>n.id===e||V(n,t)))return n;let r=[...n,t];return M(r),m.current=r,r}))},A);_.current.set(e,i)},[n,r,a,D]),R=(0,h.useRef)(L);R.current=L;let B=(0,h.useRef)(O);B.current=O,S.current=k,C.current=F;let H=(0,h.useCallback)((e,t)=>{let n=g.current,r=n.findIndex(n=>n.kind===e&&n.projectId===t);if(r===-1)return null;let i=n[r];return D(i.id),p(e=>{let t=e.filter(e=>e.id!==i.id);return P(t),t}),g.current=n.filter(e=>e.id!==i.id),i},[D]),U=(0,h.useCallback)(e=>{let t=z(),i={...e,id:t,createdAt:Date.now()};n!==e.projectId&&r(e.projectId),a(e.restoreRoute),p(e=>{let t=[...e,i];return P(t),g.current=t,t}),D(t);let o=setTimeout(()=>{_.current.delete(t),g.current.some(e=>e.id===t)&&(p(e=>{let n=e.filter(e=>e.id!==t);return P(n),g.current=n,n}),d(e=>{if(e.some(e=>e.id===t||V(e,i)))return e;let n=[...e,i];return M(n),m.current=n,n}))},A);_.current.set(t,o)},[n,r,a,D]),W=(0,h.useMemo)(()=>({chats:c,pendingRestores:f,minimize:w,updateLabel:k,patchExploreSpecDraft:F,close:O,restore:L,takePendingRestore:H,triggerResume:U}),[c,f,w,k,F,O,L,H,U]);return(0,b.jsxs)(E.Provider,{value:W,children:[e,(0,b.jsx)(T,{chats:c,projects:t,hidden:!1,onRestore:L,onClose:O})]})}function U(){return(0,h.useContext)(E)||{chats:[],pendingRestores:[],minimize:()=>``,updateLabel:()=>{},patchExploreSpecDraft:()=>{},close:()=>{},restore:()=>{},takePendingRestore:()=>null,triggerResume:()=>{}}}function W(e,t,n){let{pendingRestores:r,takePendingRestore:i}=U(),a=(0,h.useRef)(n);a.current=n,(0,h.useEffect)(()=>{if(!t)return;let n=i(e,t);n&&a.current(n)},[r,e,t,i])}export{g as a,p as c,_ as i,f as l,U as n,v as o,W as r,m as s,H as t,d as u};
@@ -1,2 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{n as a}from"./dist-bVqfYmby.js";import{t as o}from"./download-CFHyyHcw.js";import{t as s}from"./loader-circle-DcygOQpC.js";import{t as c}from"./search-Cq_gE3Ik.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{a as d}from"./auth-D_5bQv5W.js";import{r as f}from"./useSharedWebSocket-DK96ctb7.js";import{n as p,r as m}from"./useDesktop-B6Du2N83.js";import{t as h}from"./button-BUIIBQPT.js";import{t as g}from"./utils-BC4DHlz2.js";import{a as _,n as v,o as y,r as b,t as x}from"./dialog-CzIekCw0.js";import{t as S}from"./jira-api-Bhixwn-d.js";import{r as C}from"./provider-capabilities-Doej9lfa.js";import{Dt as w,ct as T,et as E,kt as D,nt as ee,tt as O,v as k}from"./index-DdC_faQv.js";var A=i(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),te=i(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),j=i(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),M=i(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),N=i(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),P=i(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),F=e(t(),1),I=n(),ne=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],L={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function R({onConnected:e,onSkip:t,apiBase:n}){let{t:i}=r(`jira`),[o,s]=(0,F.useState)(1),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,g]=(0,F.useState)(`idle`),[_,v]=(0,F.useState)(null),[y,b]=(0,F.useState)(`cloud`),[x,C]=(0,F.useState)([]),[w,T]=(0,F.useState)(``),[E,D]=(0,F.useState)(``),[ee,O]=(0,F.useState)(``),[A,te]=(0,F.useState)(!1),[j,M]=(0,F.useState)([]),[N,P]=(0,F.useState)({}),[R,re]=(0,F.useState)(``),[H,U]=(0,F.useState)(!1),W=()=>({baseUrl:c.trim(),accountEmail:u.trim()||null,token:f});async function G(){g(`testing`);try{let e=await S.test(W(),n);g(`ok`),v(e.displayName),b(e.deployment)}catch(e){g(`error`),a.error(V(e,i))}}async function K(){s(2),te(!0);try{let{projects:e}=await S.discoverProjects({...W(),query:w.trim()||void 0},n);C(e)}catch(e){a.error(V(e,i))}finally{te(!1)}}async function q(){if(s(3),E)try{let{statuses:e}=await S.discoverStatuses({...W(),projectKey:E},n);M(e)}catch{M([])}}async function J(){U(!0);try{let t=Object.fromEntries(Object.entries(N).filter(([,e])=>e));await S.connect({...W(),jiraProjectKey:E.trim(),statusMap:Object.keys(t).length?t:null,discardStatus:R.trim()||null},n),a.success(i(`status.connected`,{key:E.trim()})),e()}catch(e){a.error(V(e,i))}finally{U(!1)}}return(0,I.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-wizard`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`wizard.step`,{current:o,total:4})}),t&&(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-muted-foreground hover:text-foreground hover:underline`,"data-testid":`jira-later`,children:i(`wizard.later`)})]}),o===1&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:i(`wizard.step1Title`)}),(0,I.jsx)(z,{label:i(`creds.baseUrlLabel`),help:i(`creds.baseUrlHelp`),children:(0,I.jsx)(k,{value:c,onChange:e=>{l(e.target.value),g(`idle`)},placeholder:i(`creds.baseUrlPlaceholder`)})}),(0,I.jsx)(z,{label:i(`creds.emailLabel`),help:i(`creds.emailHelp`),children:(0,I.jsx)(k,{value:u,onChange:e=>{d(e.target.value),g(`idle`)},placeholder:i(`creds.emailPlaceholder`)})}),(0,I.jsx)(z,{label:i(`creds.tokenLabel`),help:i(`creds.tokenHelp`),children:(0,I.jsx)(k,{type:`password`,value:f,onChange:e=>{p(e.target.value),g(`idle`)}})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(h,{size:`sm`,variant:`outline`,onClick:G,disabled:!c.trim()||!f.trim()||m===`testing`,children:i(m===`testing`?`creds.testing`:m===`ok`?`creds.retest`:`creds.test`)}),m===`ok`&&(0,I.jsxs)(`span`,{className:`text-xs text-accent-success`,"data-testid":`jira-test-ok`,children:[`✓ `,i(`creds.testOk`,{name:_??``}),` · `,i(y===`cloud`?`review.cloud`:`review.dc`)]})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(h,{size:`sm`,onClick:K,disabled:m!==`ok`,children:i(`wizard.next`)})})]}),o===2&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:i(`wizard.step2Title`)}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(k,{value:w,onChange:e=>T(e.target.value),placeholder:i(`project.searchPlaceholder`)}),(0,I.jsx)(h,{size:`sm`,variant:`outline`,onClick:K,children:i(`project.searchPlaceholder`)})]}),A?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`project.loading`)}):x.length===0?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`project.none`)}):(0,I.jsx)(`div`,{className:`max-h-48 space-y-1 overflow-y-auto`,"data-testid":`jira-project-list`,children:x.map(e=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>{D(e.key),O(e.name)},className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm hover:bg-muted ${E===e.key?`bg-muted`:``}`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:e.key}),(0,I.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.name})]},e.id))}),(0,I.jsx)(z,{label:i(`project.manualLabel`),children:(0,I.jsx)(k,{value:E,onChange:e=>{D(e.target.value.toUpperCase()),O(``)},placeholder:i(`project.manualPlaceholder`)})}),(0,I.jsxs)(`div`,{className:`flex justify-between`,children:[(0,I.jsx)(h,{size:`sm`,variant:`ghost`,onClick:()=>s(1),children:i(`wizard.back`)}),(0,I.jsx)(h,{size:`sm`,onClick:q,disabled:!E.trim(),children:i(`wizard.next`)})]})]}),o===3&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:i(`wizard.step3Title`)}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`mapping.intro`)}),ne.map(e=>(0,I.jsx)(z,{label:i(`mapping.${L[e]}`),children:(0,I.jsxs)(`select`,{value:N[e]??``,onChange:t=>P(n=>({...n,[e]:t.target.value||void 0})),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,children:[(0,I.jsx)(`option`,{value:``,children:i(`mapping.auto`)}),j.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id))]})},e)),(0,I.jsx)(z,{label:i(`discard.configLabel`),help:i(`discard.configHelp`),children:(0,I.jsxs)(`select`,{value:R,onChange:e=>re(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,I.jsx)(`option`,{value:``,children:i(`discard.configNone`)}),j.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}),(0,I.jsxs)(`div`,{className:`flex justify-between`,children:[(0,I.jsx)(h,{size:`sm`,variant:`ghost`,onClick:()=>s(2),children:i(`wizard.back`)}),(0,I.jsx)(h,{size:`sm`,onClick:()=>s(4),children:i(`wizard.next`)})]})]}),o===4&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:i(`wizard.step4Title`)}),(0,I.jsxs)(`dl`,{className:`space-y-1 text-sm`,children:[(0,I.jsx)(B,{label:i(`review.site`),value:c}),(0,I.jsx)(B,{label:i(`review.project`),value:ee?`${E} — ${ee}`:E}),(0,I.jsx)(B,{label:i(`review.account`),value:_??u}),(0,I.jsx)(B,{label:i(`review.type`),value:i(y===`cloud`?`review.cloud`:`review.dc`)}),(0,I.jsx)(B,{label:i(`discard.reviewLabel`),value:R||i(`discard.configNone`)})]}),(0,I.jsxs)(`div`,{className:`flex justify-between`,children:[(0,I.jsx)(h,{size:`sm`,variant:`ghost`,onClick:()=>s(3),children:i(`wizard.back`)}),(0,I.jsx)(h,{size:`sm`,onClick:J,disabled:H,children:i(H?`wizard.connecting`:`wizard.connect`)})]})]})]})}function z({label:e,help:t,children:n}){return(0,I.jsxs)(`label`,{className:`block space-y-1`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e}),n,t&&(0,I.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:t})]})}function B({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,I.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,I.jsx)(`dd`,{className:`truncate text-right font-medium`,children:t})]})}function V(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var re=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],H={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function U({state:e,onChanged:t,apiBase:n}){let{t:i}=r(`jira`),o=e.connection,[s,c]=(0,F.useState)(o.enabled),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)([]),[g,_]=(0,F.useState)([]),[v,y]=(0,F.useState)(o.discardStatus??``),[b,x]=(0,F.useState)(o.statusMap??{}),C=e.outbox??{pending:0,inflight:0,done:0,dead:0},w=(0,F.useCallback)(async()=>{try{let{ops:e}=n?await S.listOutbox(`dead`,n):await S.listOutbox(`dead`);m(e)}catch{m([])}},[n]);(0,F.useEffect)(()=>{w()},[w]),(0,F.useEffect)(()=>{let e=!1;return S.listStatuses(n).then(({statuses:t})=>{e||_(t)}).catch(()=>{e||_([])}),()=>{e=!0}},[n]);async function T(e){let r=v;y(e);try{n?await S.patchConnection({discardStatus:e||null},n):await S.patchConnection({discardStatus:e||null}),t()}catch(e){y(r),a.error(G(e,i))}}async function E(e,r){let o=b,s={...b,[e]:r||void 0};x(s);let c=Object.fromEntries(Object.entries(s).filter(([,e])=>e));try{n?await S.patchConnection({statusMap:Object.keys(c).length?c:null},n):await S.patchConnection({statusMap:Object.keys(c).length?c:null}),t()}catch(e){x(o),a.error(G(e,i))}}async function D(){let e=!s;c(e),f(!0);try{n?await S.setEnabled(e,n):await S.setEnabled(e)}catch(t){c(!e),a.error(G(t,i))}finally{f(!1)}}async function ee(){u(!0);try{let e=n?await S.syncNow(n):await S.syncNow();a.success(i(`status.syncedToast`,{count:e.upserted}))}catch(e){a.error(G(e,i))}finally{u(!1)}}async function O(){if(window.confirm(i(`status.disconnectConfirm`))){f(!0);try{n?await S.disconnect(n):await S.disconnect(),a.success(i(`status.disconnectedToast`)),t()}catch(e){a.error(G(e,i))}finally{f(!1)}}}async function k(e){try{n?await S.retryOutbox(e,n):await S.retryOutbox(e),await w()}catch(e){a.error(G(e,i))}}let A=C.pending+C.inflight;return(0,I.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:i(`status.connected`,{key:o.jiraProjectKey})}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.baseUrl,` · `,o.deployment===`cloud`?i(`review.cloud`):i(`review.dc`)]})]}),(0,I.jsx)(`a`,{href:`${o.baseUrl}/browse/${o.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:i(`badge.openInJira`)})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:i(`status.enabledLabel`)}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(s?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s,"aria-label":i(`status.enabledLabel`),disabled:d,onClick:D,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${s?`bg-accent-success`:`bg-input`}`,children:(0,I.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${s?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,I.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:i(`wizard.step3Title`)}),(0,I.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`mapping.intro`)}),(0,I.jsx)(`div`,{className:`space-y-2`,children:re.map(e=>(0,I.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`mapping.${H[e]}`)}),(0,I.jsxs)(`select`,{value:b[e]??``,onChange:t=>void E(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,I.jsx)(`option`,{value:``,children:i(`mapping.auto`)}),g.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!g.some(t=>t.name===b[e])&&(0,I.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,I.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:i(`discard.configLabel`)}),(0,I.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`discard.configHelp`)}),(0,I.jsxs)(`select`,{value:v,onChange:e=>void T(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,I.jsx)(`option`,{value:``,children:i(`discard.configNone`)}),g.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id)),v&&!g.some(e=>e.name===v)&&(0,I.jsx)(`option`,{value:v,children:v})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(h,{variant:`outline`,size:`sm`,onClick:ee,disabled:l,children:i(l?`status.syncing`:`status.syncNow`)}),(0,I.jsx)(h,{variant:`ghost`,size:`sm`,onClick:O,disabled:d,className:`text-destructive`,children:i(`status.disconnect`)})]}),(0,I.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:i(`outbox.title`)}),C.dead>0?(0,I.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:i(`outbox.dead`,{count:C.dead})}):A>0?(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.pending`,{count:A})}):(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.allSynced`)}),p.length>0&&(0,I.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`outbox.deadHelp`)}),p.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,I.jsxs)(`span`,{className:`truncate text-xs`,children:[W(e,i),` · `,e.deadReason??e.lastError??``]}),(0,I.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>k(e.id),children:i(`outbox.retry`)})]},e.id))]})]})]})}function W(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function G(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var K=new Set([`claude`,`codex`,`kimi`]);function q(e){return{provider:e,label:e===`codex`?`Codex`:`Claude`,active:!1,available:!1,detectedRoute:!1,requests:0,inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0,outputSavingsPercent:0,outputSavingsMethod:`none`,outputSavingsAllocated:!1}}function J(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:q(`codex`),claude:q(`claude`)},lastIssue:null}}var Y={installed:!1,installSource:null,version:null,executablePath:null,uvPath:null,port:8787,phase:`idle`,activeProviders:{codex:!1,claude:!1},availableProviders:{codex:!1,claude:!1},detectedRoutes:{codex:!1,claude:!1},proxyRunning:!1,proxyPid:null,learning:{enabled:!1,baselineReady:!1,baselineSamples:0,updatedAt:null,lastIssue:null},metrics:J(),lastIssue:null,updatedAt:null};function ie(e){let t=e?.metrics??J();return{...Y,...e,activeProviders:{...Y.activeProviders,...e?.activeProviders},availableProviders:{...Y.availableProviders,...e?.availableProviders},detectedRoutes:{...Y.detectedRoutes,...e?.detectedRoutes},learning:{...Y.learning,...e?.learning},metrics:{...J(),...t,providers:{codex:{...q(`codex`),...t.providers?.codex},claude:{...q(`claude`),...t.providers?.claude}}}}}async function X(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok){let t=n.issue;throw Object.assign(Error(t?.title??n.error??`HTTP ${e.status}`),{payload:n})}return n}function Z(e){return`${d}/api/projects/${e}`}function Q(e,t=`en`){if(!Number.isFinite(e))return`0`;try{return Intl.NumberFormat(t,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}catch{return Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}}function $(e,t,n){return`${Q(e,t)} ${n}`}function ae(){let{t:e}=r(`integrations`),{projects:t}=m(),{registerHandler:n,unregisterHandler:i}=f(),[a,o]=(0,F.useState)(``),[s,l]=(0,F.useState)(`all`),[u,p]=(0,F.useState)(Y),[h,S]=(0,F.useState)(!0),[C,w]=(0,F.useState)(null),[D,k]=(0,F.useState)([]),[A,M]=(0,F.useState)(!1),[N,P]=(0,F.useState)(!1),[ne,L]=(0,F.useState)(null),[R,z]=(0,F.useState)({jira:0,serena:0,projects:0}),B=(0,F.useCallback)(async()=>{try{let e=await fetch(`${d}/api/global-plugins/headroom`).then(e=>X(e));p(ie(e.state))}finally{S(!1)}},[]);(0,F.useEffect)(()=>{B()},[B]),(0,F.useEffect)(()=>(n(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&k(e=>[...e.slice(-80),t.line]),B())}),()=>i(`plugins-page`)),[n,i,B]),(0,F.useEffect)(()=>{let e=!1;async function n(){let n=await Promise.all(t.map(async e=>{let[t,n]=await Promise.all([fetch(`${Z(e.id)}/jira/connection`).then(e=>X(e)).catch(()=>({connected:!1})),fetch(`${Z(e.id)}/plugins`).then(e=>X(e)).catch(()=>({plugins:[]}))]),r=n.plugins.find(e=>e.name===`serena`);return{jira:+!!t.connected,serena:r&&r.status!==`not-installed`&&r.status!==`orphan`?1:0}}));e||z({jira:n.reduce((e,t)=>e+t.jira,0),serena:n.reduce((e,t)=>e+t.serena,0),projects:t.length})}return n(),()=>{e=!0}},[t]);async function V(e,t){w(e),k([]);try{let e=(await t()).state;e&&p(ie(e))}catch(e){let t=e.payload;t?.state&&p(ie(t.state))}finally{w(null),B()}}let re=(0,F.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:j,description:e(`plugins.catalog.headroom.description`),installed:u.installed,status:u.lastIssue?`attention`:u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?`external-active`:`active`:u.installSource===`system`?`external`:`installed`:`available`,statusLabel:u.lastIssue?e(`plugins.status.attention`):u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?e(`plugins.status.externalActive`):e(`plugins.status.active`):u.installSource===`system`?e(`plugins.status.external`):e(`plugins.status.installed`):e(`plugins.status.available`),actionKind:u.lastIssue?`review`:u.installed?`manage`:`install`,actionLabel:u.lastIssue?e(`plugins.actions.review`):u.installed?e(`plugins.actions.manage`):e(`plugins.actions.install`),busy:C===`install`,action:()=>{if(u.lastIssue||u.installed){M(!0);return}V(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>X(e)))}}],[u,C,e]),H=(0,F.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:te,description:e(`plugins.catalog.jira.description`),installed:R.jira>0,status:R.jira>0?`configured`:`available`,statusLabel:R.jira>0?e(`plugins.status.configuredCount`,{count:R.jira}):e(`plugins.status.available`),actionKind:R.jira>0?`manage`:`install`,actionLabel:R.jira>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>L(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:E,description:e(`plugins.catalog.serena.description`),installed:R.serena>0,status:R.serena>0?`installed`:`available`,statusLabel:R.serena>0?e(`plugins.status.installedCount`,{count:R.serena}):e(`plugins.status.available`),actionKind:R.serena>0?`manage`:`install`,actionLabel:R.serena>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>L(`serena`)}],[R,e]),U=a.trim().toLowerCase(),W=t=>`${t.title} ${t.description} ${t.statusLabel} ${e(`plugins.scope.${t.scope}`)}`.toLowerCase().includes(U),G=[...re,...H].filter(e=>s!==`all`&&e.scope!==s?!1:W(e)),K=G.filter(e=>e.scope===`global`&&e.installed),q=G.filter(e=>e.scope===`project`&&e.installed),J=G.filter(e=>e.scope===`global`&&!e.installed),Q=G.filter(e=>e.scope===`project`&&!e.installed),$=K.length>0||q.length>0,ae=J.length>0||Q.length>0,ce=[u.installed,R.jira>0,R.serena>0].filter(Boolean).length;return(0,I.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(`div`,{className:`grid h-9 w-9 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,I.jsx)(T,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:e(`plugins.page.title`)}),(0,I.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`plugins.page.subtitle`)})]}),(0,I.jsxs)(`div`,{className:`mr-12 flex items-center gap-2 rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,children:[(0,I.jsx)(ee,{className:`h-3.5 w-3.5 text-accent-success`}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:e(`plugins.page.readyCount`,{count:ce})})]})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,I.jsxs)(`label`,{className:`relative flex-1`,children:[(0,I.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,I.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:e(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,I.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(t=>(0,I.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:g(`rounded-md px-3 text-xs capitalize transition-colors`,s===t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e(`plugins.filters.${t}`)},t))})]})]}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,I.jsxs)(`section`,{className:`mb-6`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,I.jsx)(O,{className:`h-3.5 w-3.5`}),e(`plugins.sections.installed`)]}),$?(0,I.jsx)(oe,{globalPlugins:K,projectPlugins:q}):(0,I.jsx)(se,{text:e(U?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,I.jsx)(T,{className:`h-3.5 w-3.5`}),e(`plugins.sections.available`)]}),ae?(0,I.jsx)(oe,{globalPlugins:J,projectPlugins:Q}):(0,I.jsx)(se,{text:e(U?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,I.jsx)(x,{open:A,onOpenChange:M,children:(0,I.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,I.jsxs)(_,{children:[(0,I.jsx)(y,{children:e(`plugins.headroom.title`)}),(0,I.jsx)(b,{children:e(`plugins.headroom.dialogDescription`)})]}),(0,I.jsx)(de,{state:u,loading:h,busy:C,logs:D,onInstall:()=>V(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>X(e))),onToggleProvider:(e,t)=>V(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${d}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>X(e))),onDeactivateAll:()=>V(`deactivate-all`,async()=>{let e={state:u};for(let t of[`codex`,`claude`])u.activeProviders[t]&&(e=await fetch(`${d}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>X(e)));return e}),onUninstall:()=>V(`uninstall`,()=>fetch(`${d}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>X(e))),onSetPort:e=>V(`port`,()=>fetch(`${d}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>X(e))),onOpenDiagnostics:()=>P(!0)})]})}),(0,I.jsx)(ve,{plugin:ne,projects:t,onClose:()=>L(null)}),(0,I.jsx)(xe,{open:N,onClose:()=>P(!1)})]})}function oe({globalPlugins:e,projectPlugins:t}){let{t:n}=r(`integrations`);return(0,I.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(le,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,I.jsx)(ue,{plugin:e},e.id))})]}),t.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(le,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,I.jsx)(ue,{plugin:e},e.id))})]})]})}function se({text:e}){return(0,I.jsx)(`div`,{className:`flex h-[74px] max-w-[320px] items-center rounded-lg border border-dashed border-border bg-card/35 px-3 text-xs text-muted-foreground`,children:e})}function ce({scope:e}){let{t}=r(`integrations`);return(0,I.jsx)(`span`,{className:g(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function le({title:e,detail:t,scope:n}){return(0,I.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,I.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,I.jsx)(ce,{scope:n}),(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,I.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,I.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function ue({plugin:e}){let{t}=r(`integrations`),n=e.icon,i=e.scope===`global`,a=e.status===`attention`,c=e.busy?s:e.actionKind===`install`?o:e.actionKind===`review`?u:N,l=g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,a?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,I.jsxs)(`article`,{className:`grid h-[88px] w-full grid-cols-[38px_minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-card/70 px-3 transition-colors hover:border-accent-primary/35 hover:bg-card`,children:[(0,I.jsx)(`div`,{className:g(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,i?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,I.jsx)(n,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,I.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,I.jsx)(ce,{scope:e.scope}),(0,I.jsx)(`span`,{className:l,children:e.statusLabel})]})]}),(0,I.jsxs)(`button`,{type:`button`,disabled:e.busy,onClick:e.action,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-muted disabled:opacity-50`,children:[(0,I.jsx)(c,{className:g(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function de({state:e,loading:t,busy:n,logs:i,onInstall:a,onToggleProvider:c,onDeactivateAll:u,onUninstall:d,onSetPort:f,onOpenDiagnostics:p}){let{t:m}=r(`integrations`),[h,g]=(0,F.useState)(String(e.port)),[_,v]=(0,F.useState)(!1);(0,F.useEffect)(()=>g(String(e.port)),[e.port]),(0,F.useEffect)(()=>{e.installed||v(!1)},[e.installed]);let y=e.activeProviders.codex||e.activeProviders.claude,b=e.installSource===`system`;return(0,I.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`grid h-10 w-10 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,I.jsx)(j,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold`,children:m(`plugins.headroom.title`)}),(0,I.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:m(`plugins.headroom.panelDescription`)})]})]}),(0,I.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,I.jsx)(fe,{label:m(`plugins.headroom.metrics.install`),value:t?m(`plugins.headroom.metrics.checking`):e.installed?m(`plugins.headroom.metrics.ready`):m(`plugins.headroom.metrics.missing`),good:e.installed}),(0,I.jsx)(fe,{label:m(`plugins.headroom.metrics.source`),value:e.installSource===`system`?m(`plugins.headroom.metrics.system`):e.installSource===`managed`?m(`plugins.headroom.metrics.specrails`):m(`plugins.headroom.metrics.none`),good:e.installed}),(0,I.jsx)(fe,{label:m(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:m(y?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!y})]}),e.lastIssue&&(0,I.jsx)(pe,{issue:e.lastIssue}),e.installed?(0,I.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,I.jsx)(_e,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>c(`codex`,e.activeProviders.codex)}),(0,I.jsx)(_e,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>c(`claude`,e.activeProviders.claude)}),y&&(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:u,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,I.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(M,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:a,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,I.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(o,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,I.jsx)(me,{state:e}),(0,I.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,I.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:m(`plugins.headroom.port.label`)}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,I.jsx)(`button`,{type:`button`,disabled:!!n||Number(h)===e.port,onClick:()=>f(Number(h)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:m(`plugins.headroom.port.apply`)})]})]}),i.length>0&&(0,I.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:i.join(`
2
- `)}),(0,I.jsxs)(`button`,{type:`button`,onClick:p,className:`mb-2 flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border text-xs hover:bg-muted/50`,children:[(0,I.jsx)(P,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.viewDiagnostics`)]}),e.installed&&(0,I.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/5 p-3`,children:_?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:m(b?`plugins.headroom.confirmDetach`:`plugins.headroom.confirmUninstall`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:!!n,onClick:()=>v(!1),className:`h-8 rounded-md border border-border text-xs hover:bg-muted/50 disabled:opacity-50`,children:m(`plugins.actions.cancel`)}),(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:d,className:`flex h-8 items-center justify-center gap-2 rounded-md bg-destructive px-2 text-xs font-medium text-destructive-foreground disabled:opacity-50`,children:[n===`uninstall`?(0,I.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(l,{className:`h-3.5 w-3.5`}),m(b?`plugins.headroom.actions.detach`:`plugins.headroom.actions.uninstall`)]})]})]}):(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:()=>v(!0),className:`flex h-8 w-full items-center justify-center gap-2 rounded-md text-xs font-medium text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:[(0,I.jsx)(l,{className:`h-3.5 w-3.5`}),m(b?`plugins.headroom.actions.detachHeadroom`:`plugins.headroom.actions.uninstallHeadroom`)]})})]})}function fe({label:e,value:t,good:n}){return(0,I.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-2`,children:[(0,I.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,I.jsx)(`div`,{className:g(`mt-0.5 font-medium`,n?`text-foreground`:`text-accent-warning`),children:t})]})}function pe({issue:e}){let{t}=r(`integrations`),n=`plugins.headroom.issues.${e.code}`,i=t(`${n}.title`,{defaultValue:e.title}),a=t(`${n}.guidance`,{defaultValue:e.guidance});return(0,I.jsx)(`div`,{className:`mb-3 rounded-lg border border-accent-warning/35 bg-accent-warning/10 p-3`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(u,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:i}),(0,I.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:a}),(0,I.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(`plugins.headroom.issueCode`,{code:e.code})})]})]})})}function me({state:e}){let{t,i18n:n}=r(`integrations`),i=e.metrics,a=i.outputSavingsAvailable,o=[`codex`,`claude`].map(e=>({provider:e,metric:i.providers[e]})),s=t(`plugins.headroom.savings.tokens`),c=o.reduce((e,{metric:t})=>({inputTokens:e.inputTokens+t.inputTokens,inputTokensSaved:e.inputTokensSaved+t.inputTokensSaved,outputTokens:e.outputTokens+t.outputTokens,outputTokensSaved:e.outputTokensSaved+t.outputTokensSaved}),{inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0}),l=o.some(({metric:e})=>e.inputTokensSaved>0),u=o.some(({metric:e})=>e.active),d=t(a?`plugins.headroom.savings.statusInputOutput`:l?`plugins.headroom.savings.statusInputOnly`:u?`plugins.headroom.savings.statusRouting`:`plugins.headroom.savings.statusInactive`),f=a||l;return(0,I.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(D,{className:`h-3.5 w-3.5 text-accent-primary`}),(0,I.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t(`plugins.headroom.savings.title`)})]}),(0,I.jsx)(`span`,{className:g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px]`,f?`border-accent-success/25 bg-accent-success/10 text-accent-success`:u?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-border bg-muted text-muted-foreground`),children:d})]}),(0,I.jsxs)(`div`,{className:`mb-2 rounded-md bg-muted/35 px-2.5 py-2`,children:[(0,I.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase text-muted-foreground`,children:t(`plugins.headroom.savings.totals`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.jsx)(he,{label:t(`plugins.headroom.savings.input`),processed:c.inputTokens>0?$(c.inputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:$(c.inputTokensSaved,n.language,s)}),(0,I.jsx)(he,{align:`right`,label:t(`plugins.headroom.savings.output`),processed:c.outputTokens>0?$(c.outputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:a?$(c.outputTokensSaved,n.language,s):t(`plugins.headroom.savings.noData`)})]})]}),(0,I.jsx)(`div`,{className:`grid gap-2`,children:o.map(({provider:e,metric:t})=>(0,I.jsx)(ge,{metric:t,outputAvailable:i.outputSavingsAvailable},e))}),(0,I.jsx)(`div`,{className:`mt-2 flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:i.updatedAt?t(`plugins.headroom.savings.updatedLive`):t(`plugins.headroom.savings.baselineSamples`,{count:e.learning.baselineSamples})})]})}function he({label:e,processed:t,saved:n,detail:i,align:a=`left`}){let{t:o}=r(`integrations`);return(0,I.jsxs)(`div`,{className:g(`min-w-0`,a===`right`&&`text-right`),children:[(0,I.jsx)(`div`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,I.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.processed`)}),(0,I.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:t})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.saved`)}),(0,I.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:n})]})]}),i&&(0,I.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,children:i})]})}function ge({metric:e,outputAvailable:t}){let{t:n,i18n:i}=r(`integrations`),a=!e.available,o=a||!e.active,s=n(`plugins.headroom.savings.tokens`),c=e.inputTokens>0?$(e.inputTokens,i.language,s):n(`plugins.headroom.savings.noData`),l=$(e.inputTokensSaved,i.language,s),u=e.outputTokens>0?$(e.outputTokens,i.language,s):n(`plugins.headroom.savings.noData`),d=t?$(e.outputTokensSaved,i.language,s):e.active?n(`plugins.headroom.savings.noData`):n(`plugins.headroom.savings.off`),f=e.requests>0?n(`plugins.headroom.savings.requestCount`,{count:Q(e.requests,i.language)}):a?n(`plugins.headroom.provider.noProjectUsesProvider`):e.active?n(`plugins.headroom.savings.inputSavingsActive`):n(`plugins.headroom.savings.routeDisabled`);return(0,I.jsxs)(`div`,{className:g(`rounded-md border border-border bg-card/45 px-2.5 py-2`,o&&`opacity-70`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),e.detectedRoute&&(0,I.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-0.5 text-[9px] uppercase text-accent-primary`,children:n(`plugins.headroom.savings.detected`)})]}),(0,I.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:f}),(0,I.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-3`,children:[(0,I.jsx)(he,{label:n(`plugins.headroom.savings.input`),processed:c,saved:l}),(0,I.jsx)(he,{align:`right`,label:n(`plugins.headroom.savings.output`),processed:u,saved:d})]})]})}function _e({provider:e,active:t,available:n,detectedRoute:i,busy:a,onClick:o}){let{t:c}=r(`integrations`),l=c(n?t?`plugins.headroom.provider.routedThroughHeadroom`:i?`plugins.headroom.provider.detectedExternalRoute`:`plugins.headroom.provider.notRouted`:`plugins.headroom.provider.noProjectUsesProvider`);return(0,I.jsxs)(`button`,{type:`button`,onClick:o,disabled:a||!n,className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background/45 p-3 text-left hover:bg-muted/35 disabled:opacity-50`,children:[(0,I.jsx)(`div`,{className:g(`grid h-8 w-8 place-items-center rounded-md`,t?`bg-accent-success/15 text-accent-success`:`bg-muted text-muted-foreground`),children:a?(0,I.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(A,{className:`h-3.5 w-3.5`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium capitalize`,children:e}),(0,I.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:l})]}),(0,I.jsx)(`span`,{className:g(`h-5 w-9 rounded-full p-0.5 transition-colors`,t?`bg-accent-success`:`bg-muted`),children:(0,I.jsx)(`span`,{className:g(`block h-4 w-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-4`)})})]})}function ve({plugin:e,projects:t,onClose:n}){let{t:i}=r(`integrations`),[a,o]=(0,F.useState)(``);(0,F.useEffect)(()=>o(``),[e]);let s=t.find(e=>e.id===a)??null;return(0,I.jsx)(x,{open:!!e,onOpenChange:e=>{e||n()},children:(0,I.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-3xl overflow-x-hidden p-4 sm:p-6`,children:[(0,I.jsxs)(_,{children:[(0,I.jsx)(y,{children:i(e===`jira`?`plugins.projectWizard.configureJira`:`plugins.projectWizard.installSerena`)}),(0,I.jsx)(b,{children:i(`plugins.projectWizard.description`)})]}),(0,I.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,I.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-3`,children:[(0,I.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:i(`plugins.projectWizard.chooseProject`)}),(0,I.jsx)(`div`,{className:`max-h-[52vh] space-y-1 overflow-auto`,children:t.map(t=>{let n=e===`serena`&&!p(t).some(e=>K.has(e));return(0,I.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>o(t.id),className:g(`w-full rounded-md px-2 py-2 text-left transition-colors`,t.id===a?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/45 hover:text-foreground`,n&&`cursor-not-allowed opacity-45`),children:[(0,I.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t.name}),(0,I.jsx)(`div`,{className:`truncate text-[10px]`,children:n?i(`plugins.projectWizard.requiresSupportedProvider`,{defaultValue:`Requires Claude, Codex, or Kimi`}):t.path})]},t.id)})})]}),(0,I.jsx)(`div`,{className:`min-h-[360px] rounded-lg border border-border bg-card/70 p-4`,children:s?e===`jira`?(0,I.jsx)(ye,{project:s,onDone:n}):(0,I.jsx)(be,{project:s,onDone:n}):(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:i(`plugins.projectWizard.selectProjectToContinue`)})})]})]})})}function ye({project:e,onDone:t}){let{t:n}=r(`integrations`),i=Z(e.id),[a,o]=(0,F.useState)(null),[c,l]=(0,F.useState)(!0),[u,d]=(0,F.useState)(null),f=(0,F.useCallback)(async()=>{l(!0),d(null);try{let e=await fetch(`${i}/jira/connection`).then(e=>X(e));o(e)}catch(e){o({connected:!1}),d(e.message)}finally{l(!1)}},[i]);return(0,F.useEffect)(()=>{f()},[f]),c?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,I.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),n(`plugins.jira.loading`,{defaultValue:`Loading Jira...`})]}):a?.connected&&a.connection?(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.jira.configuredDescription`,{defaultValue:`Manage the Jira project, status mapping, discard status, sync, and connection state.`})})]}),(0,I.jsx)(U,{state:a,apiBase:i,onChanged:()=>{f()}})]}):(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:u?n(`plugins.jira.loadFailed`,{message:u,defaultValue:`Could not load the current Jira configuration: ${u}`}):n(`plugins.jira.notConfiguredDescription`,{defaultValue:`Connect this project to Jira.`})})]}),(0,I.jsx)(R,{apiBase:i,onConnected:()=>{f()},onSkip:t})]})}function be({project:e,onDone:t}){let{t:n}=r(`integrations`),i=(0,F.useMemo)(()=>p(e).filter(e=>K.has(e)),[e]),a=i.includes(e.provider)?e.provider:i[0]??e.provider,[c,l]=(0,F.useState)(a),[d,f]=(0,F.useState)(null),[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(!1),[v,y]=(0,F.useState)(null),b=(0,F.useRef)(0);(0,F.useEffect)(()=>{l(a),f(null),h(null)},[e.id,a]);let x=(0,F.useCallback)(async()=>{let t=++b.current;y(null);try{let n=`?provider=${encodeURIComponent(c)}`,r=await fetch(`${Z(e.id)}/plugins${n}`).then(e=>X(e));if(t!==b.current)return;let i=r.plugins.find(e=>e.name===`serena`)??null;if(f(i),h(null),i?.status===`not-installed`){let r=await fetch(`${Z(e.id)}/plugins/serena/preview-install${n}`).then(e=>X(e));t===b.current&&h(r)}}catch(e){t===b.current&&y(e.message)}},[e.id,c]);(0,F.useEffect)(()=>{x()},[x]);async function S(){_(!0),y(null);try{await fetch(`${Z(e.id)}/plugins/serena/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:c})}).then(e=>X(e)),await x(),t()}catch(e){y(e.message)}finally{_(!1)}}let T=(m?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum),E=d?n(`plugins.projectStatus.${d.status}`,{defaultValue:d.status}):``,D=d?.name===`serena`?n(`plugins.catalog.serena.description`):d?.description;return!d&&!v?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,I.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),` `,n(`plugins.serena.loading`)]}):(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.serena.titleForProject`,{name:e.name})}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.serena.description`)})]}),(0,I.jsxs)(`label`,{className:`block space-y-1`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:n(`plugins.serena.provider`,{defaultValue:`AI provider`})}),(0,I.jsx)(`select`,{"aria-label":n(`plugins.serena.provider`,{defaultValue:`AI provider`}),value:c,disabled:g,onChange:e=>{f(null),h(null),l(e.target.value)},className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs`,children:i.map(e=>(0,I.jsx)(`option`,{value:e,children:C(e)},e))})]}),d&&(0,I.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-3`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:n(`plugins.serena.status`,{status:E})}),D&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:D})]}),m&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.files`)}),(0,I.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:m.files.map(e=>(0,I.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path]},e.path))})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.prerequisites`)}),(0,I.jsx)(`ul`,{className:`space-y-1 text-xs`,children:m.requirements.map(e=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.installed&&e.executable&&e.meetsMinimum?(0,I.jsx)(w,{className:`h-3 w-3 text-accent-success`}):(0,I.jsx)(u,{className:`h-3 w-3 text-accent-warning`}),(0,I.jsxs)(`span`,{children:[e.name,e.minVersion?` >= ${e.minVersion}`:``]}),e.version&&(0,I.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]})]},e.name))})]})]}),v&&(0,I.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:v}),(0,I.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md border border-border px-3 py-1.5 text-xs`,children:n(`plugins.actions.cancel`)}),(0,I.jsxs)(`button`,{type:`button`,disabled:g||d?.status!==`not-installed`||!T,onClick:S,className:`flex items-center gap-2 rounded-md bg-accent-primary px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:[g?(0,I.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(o,{className:`h-3.5 w-3.5`}),n(`plugins.actions.install`)]})]})]})}function xe({open:e,onClose:t}){let{t:n}=r(`integrations`),[i,a]=(0,F.useState)(null);return(0,F.useEffect)(()=>{e&&fetch(`${d}/api/global-plugins/headroom/diagnostics`).then(e=>X(e)).then(a).catch(e=>a({error:e.message}))},[e]),(0,I.jsx)(x,{open:e,onOpenChange:e=>{e||t()},children:(0,I.jsxs)(v,{className:`max-w-3xl`,children:[(0,I.jsxs)(_,{children:[(0,I.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,I.jsx)(N,{className:`h-4 w-4`}),` `,n(`plugins.diagnostics.title`)]}),(0,I.jsx)(b,{children:n(`plugins.diagnostics.description`)})]}),(0,I.jsx)(`pre`,{className:`max-h-[62vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background p-3 text-xs`,children:JSON.stringify(i,null,2)})]})})}export{ae as default};
@@ -1 +0,0 @@
1
- import{t as e}from"./jsx-runtime-zu2_FqZY.js";import{n as t}from"./createLucideIcon-Bjbbp_KS.js";import{t as n}from"./brain-DI9lHkKY.js";import{t as r}from"./download-CFHyyHcw.js";import{t as i}from"./git-branch-BRM0F5GN.js";import{t as a}from"./play-DNlrawbS.js";import{t as o}from"./button-BUIIBQPT.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./dialog-CzIekCw0.js";import{$ as p,C as m,Z as h,wt as g}from"./index-DdC_faQv.js";var _=e(),v={start:a,"ai-step":n,shell:h,decider:i,condition:i,end:p};function y(e){return e.type===`ai-step`?typeof e.data?.prompt==`string`?e.data.prompt:null:e.type===`shell`?typeof e.data?.command==`string`?e.data.command:null:e.type===`decider`?typeof e.data?.goal==`string`?e.data.goal:null:e.type===`end`?e.data?.outcome===`failure`?`failure`:`success`:null}function b({template:e,onClose:i,onUse:a,mode:h=`use`}){let{t:b}=t(`loops`);return(0,_.jsx)(f,{open:e!==null,onOpenChange:e=>{e||i()},children:(0,_.jsx)(l,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(s,{children:[(0,_.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,_.jsx)(n,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,_.jsx)(d,{children:e.description})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[m(e.graph)?(0,_.jsx)(`span`,{title:b(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:b(`gallery.needsSpec`)}):(0,_.jsx)(`span`,{title:b(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:b(`gallery.standalone`)}),e.category&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:b(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?b(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):b(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,_.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,_.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:b(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=v[e.type]??p,r=y(e);return(0,_.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,_.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),b(`builder.nodes.${e.type}`)]}),r&&(0,_.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,_.jsxs)(c,{children:[(0,_.jsx)(o,{variant:`ghost`,onClick:i,children:b(`common:actions.cancel`)}),(0,_.jsxs)(o,{onClick:()=>a(e.id),children:[h===`fork`?(0,_.jsx)(g,{className:`w-3.5 h-3.5 mr-1.5`}):(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),b(h===`fork`?`actions.fork`:`actions.use`)]})]})]})})})}export{b as n,y as r,v as t};