specrails-desktop 2.48.0 → 2.49.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 (121) hide show
  1. package/client/dist/assets/{ActivityFeedPage-CGq6QhP5.js → ActivityFeedPage-FdZBSmTU.js} +1 -1
  2. package/client/dist/assets/{AgentBrowserCapture-C4GZ-kdf.js → AgentBrowserCapture-Dr8kZotA.js} +1 -1
  3. package/client/dist/assets/{AgentModeAnalyticsPane-_IPmL0ZS.js → AgentModeAnalyticsPane-DXQSjYe-.js} +2 -2
  4. package/client/dist/assets/{AgentModeCodePane-B5WG5DOP.js → AgentModeCodePane-DcVV6EBy.js} +2 -2
  5. package/client/dist/assets/AgentModeJobsPane-a9f-g56c.js +1 -0
  6. package/client/dist/assets/AgentsPage-CTv4UVdp.js +87 -0
  7. package/client/dist/assets/{AnalyticsPage-BUMsKtsJ.js → AnalyticsPage-BbXPcz3a.js} +1 -1
  8. package/client/dist/assets/CodePage-CIigb_O0.js +3 -0
  9. package/client/dist/assets/DesktopAnalyticsPage-DZhN5jVh.js +1 -0
  10. package/client/dist/assets/{DocsDialog-ccQETHKB.js → DocsDialog-DzrqPxuj.js} +2 -2
  11. package/client/dist/assets/{DocsPage-DzEgplB3.js → DocsPage-B1AUuk0U.js} +1 -1
  12. package/client/dist/assets/{ExportDropdown-B8bBGopr.js → ExportDropdown-IPutNYvD.js} +1 -1
  13. package/client/dist/assets/InteractiveJobComposer-jg3xE_GX.js +19 -0
  14. package/client/dist/assets/{JobDetailModal-BYXmuTDe.js → JobDetailModal-BS-htwqZ.js} +1 -1
  15. package/client/dist/assets/JobDetailPage-CKYtQV5a.js +1 -0
  16. package/client/dist/assets/JobsPage-DFJm0bw0.js +1 -0
  17. package/client/dist/assets/{LoopBuilderPage-DQE-7Vby.js → LoopBuilderPage-ujkA2U0T.js} +2 -2
  18. package/client/dist/assets/LoopPreviewModal-BYOrnmcp.js +1 -0
  19. package/client/dist/assets/LoopsPage-DRcT1ikP.js +1 -0
  20. package/client/dist/assets/{MinimizedChatsContext-UpnqccPx.js → MinimizedChatsContext-CX1i2kQ8.js} +1 -1
  21. package/client/dist/assets/{PluginsPage-CjgVvmpW.js → PluginsPage-BR9ZTqxR.js} +2 -2
  22. package/client/dist/assets/{ProjectSettingsDialog-D6vBCoay.js → ProjectSettingsDialog-SAfCqXzC.js} +1 -1
  23. package/client/dist/assets/RepositoryDeliveries-DqmlG0Zs.js +5 -0
  24. package/client/dist/assets/{RepositoryScopeSelector-0Gz_fR1E.js → RepositoryScopeSelector-DG8KKPrm.js} +1 -1
  25. package/client/dist/assets/ReviewPacketPage-BoqahYNC.js +4 -0
  26. package/client/dist/assets/TemplatePreviewModal-CK5OoImj.js +1 -0
  27. package/client/dist/assets/TicketDetailModalContext-D2MEhRwJ.js +14 -0
  28. package/client/dist/assets/{Trans-9pHTy2fH.js → Trans-BLljsfHR.js} +1 -1
  29. package/client/dist/assets/agent-B76BhAyE.js +1 -0
  30. package/client/dist/assets/agent-BII69Nc0.js +1 -0
  31. package/client/dist/assets/agent-BIO4q6b0.js +1 -0
  32. package/client/dist/assets/agent-ButS6kwl.js +1 -0
  33. package/client/dist/assets/agent-CVeMLIu4.js +1 -0
  34. package/client/dist/assets/agent-CYFBDwFD.js +1 -0
  35. package/client/dist/assets/agent-D3jkMipn.js +1 -0
  36. package/client/dist/assets/agent-DSrflYFL.js +1 -0
  37. package/client/dist/assets/{formatDistanceToNow-w_2U5pm0.js → formatDistanceToNow-CbQZkD8M.js} +1 -1
  38. package/client/dist/assets/{getTimezoneOffsetInMilliseconds-BRymg1Kk.js → getTimezoneOffsetInMilliseconds-pBVK3rJC.js} +1 -1
  39. package/client/dist/assets/index-CjAPu3wb.js +80 -0
  40. package/client/dist/assets/index-UDzndadF.css +2 -0
  41. package/client/dist/assets/{jira-api-BqHbSdxK.js → jira-api-f-sYCIuX.js} +1 -1
  42. package/client/dist/assets/packet-BTRySHoQ.js +1 -0
  43. package/client/dist/assets/packet-BsRimSfZ.js +1 -0
  44. package/client/dist/assets/packet-C0pcMd6x.js +1 -0
  45. package/client/dist/assets/packet-C8qzvgrZ.js +1 -0
  46. package/client/dist/assets/packet-DF-iwqqY.js +1 -0
  47. package/client/dist/assets/packet-DQ_GnT2b.js +1 -0
  48. package/client/dist/assets/packet-Nb8BLI5h.js +1 -0
  49. package/client/dist/assets/packet-r7J14m89.js +1 -0
  50. package/client/dist/assets/{project-repositories-BsCs1PPA.js → project-repositories-DAjJbFhm.js} +1 -1
  51. package/client/dist/assets/{spending-hcgxHP4O.js → spending-DJBbdJyD.js} +1 -1
  52. package/client/dist/assets/{useDesktop-CAisjKWC.js → useDesktop-BJ8IRBRt.js} +1 -1
  53. package/client/dist/assets/useRuntimeRuns-Ch1KUc7k.js +1 -0
  54. package/client/dist/assets/{useSharedWebSocket-BHIfW4QT.js → useSharedWebSocket-BN3Lmehi.js} +2 -2
  55. package/client/dist/index.html +17 -17
  56. package/docs/guide/de/integrations/6-agent-chat.md +8 -0
  57. package/docs/guide/en/integrations/6-agent-chat.md +8 -0
  58. package/docs/guide/es/integrations/6-agent-chat.md +8 -0
  59. package/docs/guide/fr/integrations/6-agent-chat.md +8 -0
  60. package/docs/guide/it/integrations/6-agent-chat.md +8 -0
  61. package/docs/guide/ja/integrations/6-agent-chat.md +8 -0
  62. package/docs/guide/pt/integrations/6-agent-chat.md +8 -0
  63. package/docs/guide/zh/integrations/6-agent-chat.md +8 -0
  64. package/docs/internals/mission-rail-cards.md +130 -0
  65. package/docs/internals/review-packet.md +16 -3
  66. package/docs/mcp.md +24 -1
  67. package/package.json +1 -1
  68. package/server/dist/agent-chat-manager.js +97 -2
  69. package/server/dist/agent-chat-router.js +57 -1
  70. package/server/dist/agent-context-resolver.js +15 -0
  71. package/server/dist/agent-cwd-manager.js +1 -1
  72. package/server/dist/agent-failure-briefing.js +90 -0
  73. package/server/dist/agent-fence-promotion.js +8 -1
  74. package/server/dist/agent-operator-prompt.js +69 -1
  75. package/server/dist/agent-runtime-controls-router.js +17 -0
  76. package/server/dist/agent-store.js +40 -0
  77. package/server/dist/delivery-evidence.js +159 -0
  78. package/server/dist/desktop-db.js +11 -0
  79. package/server/dist/feature-flags.js +20 -0
  80. package/server/dist/mcp/guide.js +7 -0
  81. package/server/dist/mcp/tools/jobs.js +91 -4
  82. package/server/dist/mcp/tools/rails.js +2 -2
  83. package/server/dist/mission-run-notify.js +170 -0
  84. package/server/dist/rail-isolated-launch.js +47 -0
  85. package/server/dist/rail-launch-parser.js +182 -0
  86. package/server/dist/rail-pr-store.js +20 -0
  87. package/server/dist/rails-router.js +98 -5
  88. package/server/dist/review-packet.js +35 -2
  89. package/client/dist/assets/AgentModeJobsPane-w1N_HIXh.js +0 -1
  90. package/client/dist/assets/AgentsPage-CmwnnT46.js +0 -87
  91. package/client/dist/assets/CodePage-PjgywJPS.js +0 -3
  92. package/client/dist/assets/DesktopAnalyticsPage-BXY1pH4y.js +0 -1
  93. package/client/dist/assets/InteractiveJobComposer-CEwGkJ8F.js +0 -19
  94. package/client/dist/assets/JobDetailPage-CWp6MwJj.js +0 -1
  95. package/client/dist/assets/JobsPage-D1O1uyG8.js +0 -1
  96. package/client/dist/assets/LoopPreviewModal-Bk7zIXD5.js +0 -1
  97. package/client/dist/assets/LoopsPage-CqG7mx56.js +0 -1
  98. package/client/dist/assets/RepositoryDeliveries-C36ipKp_.js +0 -5
  99. package/client/dist/assets/ReviewPacketPage-Dr9RYs7q.js +0 -1
  100. package/client/dist/assets/TemplatePreviewModal-sCMHYFJo.js +0 -1
  101. package/client/dist/assets/TicketDetailModalContext-C5GgJlEt.js +0 -14
  102. package/client/dist/assets/agent-BdT0SB1D.js +0 -1
  103. package/client/dist/assets/agent-Bh9K7iEt.js +0 -1
  104. package/client/dist/assets/agent-C4ibdFk9.js +0 -1
  105. package/client/dist/assets/agent-CSFY22Zo.js +0 -1
  106. package/client/dist/assets/agent-DAnqxUn8.js +0 -1
  107. package/client/dist/assets/agent-DTQiu0Mi.js +0 -1
  108. package/client/dist/assets/agent-T54WuR_Y.js +0 -1
  109. package/client/dist/assets/agent-i75WDZOA.js +0 -1
  110. package/client/dist/assets/brain-DI9lHkKY.js +0 -1
  111. package/client/dist/assets/format-duration-NJVPOPBG.js +0 -1
  112. package/client/dist/assets/index-D0ScFZvR.css +0 -2
  113. package/client/dist/assets/index-DORCrgbI.js +0 -77
  114. package/client/dist/assets/packet-BNW8ODQw.js +0 -1
  115. package/client/dist/assets/packet-CXYvfdjy.js +0 -1
  116. package/client/dist/assets/packet-CtIlB8YE.js +0 -1
  117. package/client/dist/assets/packet-DA1SJkMH.js +0 -1
  118. package/client/dist/assets/packet-DYcWfBip.js +0 -1
  119. package/client/dist/assets/packet-DseX9yKC.js +0 -1
  120. package/client/dist/assets/packet-_m5aOy_d.js +0 -1
  121. package/client/dist/assets/packet-qOemUAm3.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{u as r}from"./chunk-KS7C4IRE-DEKu087k.js";import{l as i,m as a,r as o}from"./useSharedWebSocket-BHIfW4QT.js";import{n as s,t as c}from"./createLucideIcon-Bjbbp_KS.js";import{a as l,i as u,r as d,s as f}from"./useDesktop-CAisjKWC.js";import{t as p}from"./circle-x-CMYsN4ZH.js";import{t as m}from"./trash-2-BOU3WdZZ.js";import{t as h}from"./triangle-alert-H9T4jAmh.js";import{t as g}from"./x-CBMI9ejn.js";import{M as _,a as v,i as y,j as b,l as x,o as ee,r as te,t as ne}from"./dialog-xXB2q5HJ.js";import{n as re,t as ie}from"./lib-CGdyxIWg.js";import{t as S}from"./formatDistanceToNow-w_2U5pm0.js";import{t as C}from"./button-Ccc9Dc-D.js";import{E as ae,It as oe,K as w,Lt as T,Tt as se,U as E,W as D,t as O,v as k}from"./index-DORCrgbI.js";import{n as A,t as j}from"./job-time-BCL7wee9.js";import{t as M}from"./format-command-C0D9IPmV.js";import{t as N}from"./ExportDropdown-B8bBGopr.js";var ce=c(`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`}]]),P=e(t(),1),F=n();function I(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 L(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function R(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function z({label:e,a:t,b:n,highlight:r}){return(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,F.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,F.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function B(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function le({jobIds:e,onClose:t}){let{t:n}=s(`jobs`),[r,i]=(0,P.useState)(null),[a,o]=(0,P.useState)(!0),[c,u]=(0,P.useState)(null),{panelRef:d,panelStyle:f,headerHandleProps:m,resizeHandles:h,isFloating:v,guardBackdrop:y}=_();(0,P.useEffect)(()=>{let t=new AbortController;return fetch(`${l()}/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),o(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),o(!1))}),()=>t.abort()},[e]);function x(e,t){return(0,F.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,F.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,F.jsx)(T,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,F.jsx)(p,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,F.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,F.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:y(t),children:[(0,F.jsxs)(`div`,{ref:d,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:f,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between ${v?`cursor-grab active:cursor-grabbing`:``}`,...m,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,F.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,F.jsx)(g,{className:`w-4 h-4`})})]}),a&&(0,F.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,F.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),c&&(0,F.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:c})}),r&&(()=>{let[e,t]=r.jobs,i=B(e.durationMs,t.durationMs,!0),a=B(e.totalCostUsd,t.totalCostUsd,!0),o=B(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,F.jsx)(`div`,{}),x(e,0),x(t,1)]}),(0,F.jsx)(z,{label:n(`comparison.duration`),a:I(e.durationMs),b:I(t.durationMs),highlight:i}),(0,F.jsx)(z,{label:n(`comparison.cost`),a:L(e.totalCostUsd),b:L(t.totalCostUsd),highlight:a}),(0,F.jsx)(z,{label:n(`comparison.tokensOut`),a:R(e.tokensOut),b:R(t.tokensOut),highlight:o}),(0,F.jsx)(z,{label:n(`comparison.tokensIn`),a:R(e.tokensIn),b:R(t.tokensIn),highlight:null}),(0,F.jsx)(z,{label:n(`comparison.cacheRead`),a:R(e.tokensCacheRead),b:R(t.tokensCacheRead),highlight:null}),(0,F.jsx)(z,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,F.jsx)(z,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,F.jsx)(b,{handles:h})]})}var V={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?S(t,{addSuffix:!0,locale:a()}):`—`}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function _e(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function ve(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>_e(n))}var H=10;function U({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:a,onProposalClick:o,onProposalDelete:c}){let{t:u}=s(`jobs`),p=r(),{activeProjectId:g,projects:re}=d(),ie=re.find(e=>e.id===g)?.provider,[S,T]=(0,P.useState)(null),[O,k]=(0,P.useState)(``),[A,N]=(0,P.useState)(``),[I,L]=(0,P.useState)(!1),[R,z]=(0,P.useState)(``),[B,U]=(0,P.useState)(``),[W,G]=(0,P.useState)(!1),[K,q]=(0,P.useState)(null),[J,ye]=(0,P.useState)(H),[Y,be]=(0,P.useState)(!1),[X,Z]=(0,P.useState)([]),[xe,Q]=(0,P.useState)(null),{panelRef:Se,panelStyle:Ce,headerHandleProps:we,resizeHandles:Te,isFloating:Ee,guardBackdrop:De}=_();(0,P.useEffect)(()=>{ye(H)},[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=>S&&e.status!==S?!1:ve(j(e),O,A)),Ae=e.filter(e=>ve(j(e),R,B)).length;async function je(e){G(!0);try{let t={};e===`range`&&(R&&(t.from=new Date(ge(R)).toISOString()),B&&(t.to=new Date(_e(B)).toISOString()));let n=await fetch(`${l()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();f.success(u(`recent.toast.cleared`,{count:e.deleted})),L(!1),z(``),U(``),a?.()}else f.error(u(`recent.toast.clearFailed`))}catch{f.error(u(`recent.toast.networkError`))}finally{G(!1)}}let Me=n?(0,F.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,F.jsx)(h,{className:`h-4 w-4 shrink-0`}),(0,F.jsx)(`span`,{className:`flex-1`,children:u(`recent.loadFailed`)}),i&&(0,F.jsx)(C,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,onClick:i,disabled:t,children:u(`common:actions.retry`)})]}):null;return n&&e.length===0?(0,F.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,F.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,F.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,F.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,F.jsx)(oe,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:u(`recent.emptyTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:u(`recent.emptyDescription`)})]}):(0,F.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>T(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${S===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:u(`recent.filterAll`,{count:e.length})}),ue.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,F.jsx)(`button`,{type:`button`,onClick:()=>T(S===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${S===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:u(`recent.filterStatus`,{status:u(`statusName.${t}`),count:n})},t)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`date`,value:O,onChange:e=>k(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:u(`recent.fromDate`)}),(0,F.jsx)(`input`,{type:`date`,value:A,onChange:e=>N(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:u(`recent.toDate`)}),(O||A)&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{k(``),N(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:u(`recent.clear`)}),(0,F.jsxs)(E,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(C,{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,F.jsx)(ce,{className:`w-3.5 h-3.5`})})}),(0,F.jsx)(D,{children:u(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,F.jsxs)(E,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>L(!0),children:(0,F.jsx)(m,{className:`w-3.5 h-3.5`})})}),(0,F.jsx)(D,{children:u(`recent.clearJobs`)})]})]})]}),Y&&(0,F.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,F.jsxs)(`span`,{children:[X.length===0&&u(`recent.selectTwoToCompare`),X.length===1&&u(`recent.selectOneMore`),X.length===2&&u(`recent.readyToCompare`)]}),X.length===2&&(0,F.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:u(`recent.compareAction`)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,F.jsx)(`span`,{className:`w-14`,children:u(`recent.colStatus`)}),(0,F.jsx)(`span`,{className:`flex-1 min-w-0`,children:u(`recent.colCommand`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,F.jsx)(`span`,{className:`w-14 text-right`,children:u(`recent.colDuration`)}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:u(`recent.colTokens`)}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:u(`recent.colCost`)}),(0,F.jsx)(`span`,{className:`w-20 text-right`,children:u(`recent.colStarted`)})]})]}),(0,F.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,J).map(e=>{let t=V[e.status]??V.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:`),s=a?e.id.replace(`proposal:`,``):null,c=X.includes(e.id),l=Y&&!a&&X.length===2&&!c,d=()=>{if(Y&&!a){ke(e.id);return}a&&s?o?.(s):p(`/jobs/${e.id}`)};return(0,F.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${c?`bg-accent/70 ring-1 ring-border`:l?`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,F.jsxs)(E,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(`div`,{children:(0,F.jsx)(ae,{variant:t.variant,children:u(t.labelKey)})})}),(0,F.jsx)(D,{children:u(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,F.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${de[e.priority].className}`,children:u(de[e.priority].labelKey)}),e.profile_name&&(0,F.jsxs)(E,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.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,F.jsx)(D,{children:u(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,F.jsxs)(E,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(se,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,F.jsxs)(D,{children:[u(`recent.pipelinePart`),e.depends_on_job_id&&` ${u(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,F.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:M(e.command,ie)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,F.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,F.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:he(e.started_at)}),a&&s&&(0,F.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(s)},title:u(`recent.deleteProposal`),children:(0,F.jsx)(m,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>J&&(0,F.jsx)(`div`,{className:`pt-1 text-center`,children:(0,F.jsx)(`button`,{type:`button`,onClick:()=>ye(e=>e+H),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:u(`recent.loadMore`,{count:$.length-J})})}),I&&(0,F.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:De(()=>L(!1)),children:[(0,F.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,F.jsxs)(`div`,{...we,className:Ee?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,F.jsx)(`h3`,{className:`text-sm font-semibold`,children:u(`recent.clearModal.title`)}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:u(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,F.jsx)(C,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:W,onClick:()=>je(`all`),children:u(`recent.clearModal.clearAll`,{count:e.length})}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`recent.clearModal.orByRange`)}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(`input`,{type:`date`,value:R,onChange:e=>z(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:u(`recent.clearModal.fromPlaceholder`)}),(0,F.jsx)(`input`,{type:`date`,value:B,onChange:e=>U(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:u(`recent.clearModal.toPlaceholder`)})]}),(0,F.jsx)(C,{variant:`outline`,size:`sm`,className:`w-full`,disabled:W||!R&&!B,onClick:()=>je(`range`),children:R||B?u(`recent.clearModal.clearInRange`,{count:Ae}):u(`recent.clearModal.clearRange`)})]}),(0,F.jsx)(C,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>L(!1),children:u(`common:actions.cancel`)})]}),(0,F.jsx)(b,{handles:Te})]}),(0,F.jsx)(ne,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,F.jsxs)(te,{className:`max-w-sm`,children:[(0,F.jsxs)(ee,{children:[(0,F.jsx)(x,{children:u(`recent.deleteProposalConfirm.title`)}),(0,F.jsx)(y,{children:u(`recent.deleteProposalConfirm.description`)})]}),(0,F.jsxs)(v,{children:[(0,F.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>q(null),children:u(`common:actions.cancel`)}),(0,F.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{K&&c?.(K),q(null)},children:u(`common:actions.delete`)})]})]})}),xe&&(0,F.jsx)(le,{jobIds:xe,onClose:()=>{Q(null),Z([]),be(!1)}})]})}var W={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 G(e){return`${i}/api/projects/${encodeURIComponent(e)}`}function K(){let[e,t]=(0,P.useState)(!1),{registerHandler:n,unregisterHandler:r}=o(),{t:i}=s(`jobs`),{activeProjectId:a}=d(),{recentJobs:c}=O(a),{data:p,isFirstLoad:m,isLoading:h,error:g,refresh:_}=u({namespace:`jobs`,projectId:a,initialValue:c,fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${G(e)}/jobs?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch jobs: ${n.status}`);return(await n.json()).jobs},pollInterval:1e4});(0,P.useEffect)(()=>(n(`jobs-runtime-continuation`,e=>{let t=e;t.type===`runtime.continuation`&&t.projectId===a&&_()}),()=>r(`jobs-runtime-continuation`)),[a,_,n,r]);let{data:y,isFirstLoad:b,isLoading:S,error:oe,refresh:w}=u({namespace:`proposals`,projectId:a,initialValue:[],fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${G(e)}/propose?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals},pollInterval:1e4}),T={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},se=y.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:T[e.status]??`queued`})),E=[...p,...se].sort((e,t)=>(A(j(t))?.getTime()??0)-(A(j(e))?.getTime()??0)),[D,M]=(0,P.useState)(null),ce=(0,P.useCallback)(async e=>{try{let t=await fetch(`${l()}/propose/${e}`);if(!t.ok)return;let n=await t.json();M(n.proposal)}catch{}},[]),I=(0,P.useCallback)(async e=>{try{(await fetch(`${l()}/propose/${e}`,{method:`DELETE`})).ok&&(f.success(i(`page.proposalDeleted`)),await w())}catch{}},[w,i]);return(0,F.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,F.jsx)(`h1`,{className:`text-sm font-semibold`,children:i(`page.title`)}),(0,F.jsx)(N,{baseUrl:`${l()}/jobs/export`,label:i(`page.exportJobs`)})]}),a&&(0,F.jsxs)(`details`,{className:`mb-4 rounded-lg border border-border`,onToggle:e=>t(e.currentTarget.open),children:[(0,F.jsx)(`summary`,{className:`cursor-pointer p-3 text-sm`,children:i(`agentRuntime:runs.title`)}),e&&(0,F.jsx)(k,{projectId:a})]}),(0,F.jsx)(U,{jobs:E,isLoading:m||b||h||S,error:g??oe,onRetry:()=>{Promise.all([_(),w()])},onJobsCleared:_,onProposalClick:ce,onProposalDelete:I}),(0,F.jsx)(ne,{open:D!==null,onOpenChange:e=>!e&&M(null),children:(0,F.jsx)(te,{className:`max-w-3xl glass-card`,children:D&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(ee,{children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(x,{className:`flex-1 min-w-0`,children:i(`page.proposal.title`)}),(0,F.jsx)(ae,{variant:D.status===`created`?`success`:D.status===`cancelled`?`destructive`:`secondary`,children:i(W[D.status]??`page.proposal.status.unknown`,{status:D.status})})]})}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:D.idea}),D.result_markdown?(0,F.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,F.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,F.jsx)(re,{remarkPlugins:[ie],children:D.result_markdown})})}):(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:i(`page.proposal.noContent`)}),D.issue_url&&(0,F.jsxs)(`div`,{className:`text-xs`,children:[i(`page.proposal.githubIssue`),` `,(0,F.jsx)(`a`,{href:D.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:D.issue_url})]}),(0,F.jsxs)(v,{children:[(0,F.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{I(D.id),M(null)},children:i(`common:actions.delete`)}),(0,F.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>M(null),children:i(`common:actions.close`)})]})]})})})]})}export{K 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{u as i}from"./chunk-KS7C4IRE-DEKu087k.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"./square-Ci-PFcFe.js";import{t as l}from"./utils-BC4DHlz2.js";import{t as u}from"./button-Ccc9Dc-D.js";import{wt as d}from"./index-DORCrgbI.js";import{r as f,t as p}from"./TemplatePreviewModal-sCMHYFJo.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]??c,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)(u,{variant:`ghost`,onClick:t,children:n(`common:actions.close`)}),!e.locked&&(0,g.jsxs)(u,{"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{u as r}from"./chunk-KS7C4IRE-DEKu087k.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o,r as s,s as c}from"./useDesktop-CAisjKWC.js";import{_ as l,n as u,s as d,u as f}from"./provider-capabilities-Vi1ZGvAK.js";import{t as p}from"./download-CFHyyHcw.js";import{t as m}from"./pencil-C9RkrIPZ.js";import{n as h}from"./square-Ci-PFcFe.js";import{t as g}from"./plus-CsnjfkmX.js";import{t as _}from"./sparkles-DrY8hb0X.js";import{t as v}from"./trash-2-BOU3WdZZ.js";import{t as y}from"./upload-DYMjAQ6M.js";import{a as ee,i as te,l as ne,o as re,r as ie,t as b}from"./dialog-xXB2q5HJ.js";import{t as x}from"./utils-BC4DHlz2.js";import{t as S}from"./button-Ccc9Dc-D.js";import{t as C}from"./RepositoryScopeSelector-0Gz_fR1E.js";import{Ft as w,J as ae,Pt as T,T as oe,_ as E,at as D,g as O,h as k,q as A,w as j}from"./index-DORCrgbI.js";import{n as M}from"./TemplatePreviewModal-sCMHYFJo.js";var N=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`}]]),P=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 I(e){return{specrailsLoops:1,loops:e.map(e=>({name:e.name,description:e.description,graph:e.graph}))}}function L(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:L(t)?[t]:[]).filter(L);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 R=[`API`,`Automation`,`CI`,`Database`,`Debugging`,`DevOps`,`Docs`,`Git`,`Maintenance`,`Performance`,`Planning`,`Quality`,`Review`,`Security`,`Testing`];function le(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 ue(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 R){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 z=n();function de({loop:e,projects:t,onClose:n,onExecute:r}){let{t:a}=i(`loops`),o=e!==null,[s,c]=(0,F.useState)(``),[p,m]=(0,F.useState)(``),[g,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(``),[x,w]=(0,F.useState)(),T=t.find(e=>e.id===(s||t[0]?.id)),E=(0,F.useMemo)(()=>T?.providers??(T?.provider?[T.provider]:[]),[T]),D=p||E[0]||``,O=(0,F.useMemo)(()=>oe(D),[D]),k=f(D),M=g&&(O.some(e=>e.value===g)||k&&ae(g))?g:j(D),N=l(D,M),P=N.includes(v)?v:u(D,M)??``,I=N.length>0;return(0,z.jsx)(b,{open:o,onOpenChange:e=>{e||n()},children:(0,z.jsx)(ie,{movableResizable:!0,className:`max-w-sm`,children:e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(re,{children:[(0,z.jsx)(ne,{children:a(`run.title`,{name:e.name})}),(0,z.jsx)(te,{children:a(`run.subtitle`)})]}),(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.project`)}),t.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`run.noProjects`)}):(0,z.jsx)(`select`,{"aria-label":a(`run.project`),"data-testid":`run-project-select`,value:s||t[0]?.id,onChange:e=>{c(e.target.value),m(``),_(``),y(``),w(void 0)},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,z.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,z.jsx)(C,{repositories:T?.repositories??[],value:x,onChange:w}),E.length>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.provider`)}),(0,z.jsx)(`select`,{"aria-label":a(`run.provider`),value:D,onChange:e=>{m(e.target.value),_(``),y(``)},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:E.map(e=>(0,z.jsx)(`option`,{value:e,children:d(e)},e))})]}),O.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.model`)}),k?(0,z.jsx)(A,{value:M,options:O,ariaLabel:a(`run.model`),testId:`run-model-select`,className:`w-full px-2 py-1 text-xs`,onCommit:e=>{_(e),y(u(D,e)??``)}}):(0,z.jsx)(`select`,{"aria-label":a(`run.model`),"data-testid":`run-model-select`,value:M,onChange:e=>{let t=e.target.value;_(t),y(u(D,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:O.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),I&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.effort`)}),(0,z.jsx)(`select`,{"aria-label":a(`run.effort`),value:P,onChange:e=>y(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:N.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),(0,z.jsxs)(ee,{children:[(0,z.jsx)(S,{variant:`ghost`,onClick:n,children:a(`common:actions.cancel`)}),(0,z.jsxs)(S,{onClick:()=>{let e=s||t[0]?.id;e&&r({projectId:e,...x?{repositoryIds:x}:{},provider:E.length>1?D:void 0,model:O.length>0?M:void 0,effort:I?P:void 0})},disabled:t.length===0,children:[(0,z.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),a(`run.execute`)]})]})]})})})}var B={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 V({status:e}){let{t}=i(`loops`);return(0,z.jsx)(`span`,{className:x(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ring-1 ring-inset`,B[e]),children:t(`status.${e}`)})}function H({onOpenBuilder:e}={}){let{t}=i(`loops`),n=r(),a=(0,F.useCallback)(e=>e.replace(/:/g,`_`),[]),l=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.name`,{defaultValue:n}),[t,a]),u=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.description`,{defaultValue:n}),[t,a]),[d,f]=(0,F.useState)([]),[m,h]=(0,F.useState)([]),[y,C]=(0,F.useState)([]),[ae,oe]=(0,F.useState)(!0),[A,j]=(0,F.useState)(null),[L,R]=(0,F.useState)(null),[B,V]=(0,F.useState)(`use`),[H,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}=s(),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(I(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([E.list(),E.templates()]);f(e),h(t)}catch{c.error(t(`errors.load`))}finally{oe(!1)}try{C(await E.factoryLoops())}catch{C([])}},[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 E.importLoops(n);await Y(),r.length&&c.success(t(`import.done`,{count:r.length})),i.length&&c.warning(t(`import.skipped`,{count:i.length,names:i.join(`, `)})),!r.length&&!i.length&&c.warning(t(`import.invalid`))}catch(e){let n=e instanceof Error?e.message:``;c.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 E.create({name:t(`newLoopName`)});X(e.id)}catch{c.error(t(`errors.save`))}},[t,X]),Z=(0,F.useCallback)(async e=>{try{let t=await E.fromTemplate(e);X(t.id)}catch{c.error(t(`errors.save`))}},[t,X]),Ee=(0,F.useCallback)(async e=>{try{let t=await E.forkFactory(e);X(t.id)}catch{c.error(t(`errors.save`))}},[t,X]),De=(0,F.useCallback)(async({projectId:e,provider:r,model:i,effort:a,repositoryIds:o})=>{let s=H;if(s){W(null);try{let{loopRunId:l}=await E.runStandalone(e,s.id,{aiEngine:r,model:i,reasoning_effort:a,...o?{repositoryIds:o}:{}});Se(e),n(`/jobs/${l}`),c.success(t(`run.launched`,{name:s.name}))}catch{c.error(t(`errors.save`))}}},[H,n,Se,t]),Oe=(0,F.useCallback)(e=>{V(`fork`),R({id:e.id,name:l(e.id,e.name),description:u(e.id,e.description),tags:e.requiredCapability?[e.requiredCapability]:e.claudeOnly?[`claude-only`]:[],graph:e.graph})},[l,u]),ke=(0,F.useCallback)(async e=>{try{await E.publish(e),await Y()}catch(e){e instanceof O?c.error(t(`errors.publishInvalid`)):c.error(t(`errors.save`))}},[t,Y]),Ae=(0,F.useCallback)(async e=>{try{await E.unpublish(e),await Y()}catch{c.error(t(`errors.save`))}},[t,Y]),je=(0,F.useCallback)(async e=>{try{await E.duplicate(e),await Y()}catch{c.error(t(`errors.save`))}},[t,Y]),Me=(0,F.useCallback)(e=>j(e),[]),Ne=(0,F.useCallback)(async()=>{let e=A;if(e){j(null);try{await E.remove(e),await Y()}catch{c.error(t(`errors.save`))}}},[A,t,Y]),Q=d.filter(e=>e.status===`draft`),$=d.filter(e=>e.status===`published`),Pe=ue(m),Fe=le(m.map(e=>({...e,searchTerms:`${l(e.id,e.name)} ${u(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,z.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[(0,z.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 py-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(D,{className:`w-5 h-5 text-accent-primary`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:t(`title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:t(`subtitle`)})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[G.size>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>J(d.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,z.jsx)(N,{className:`w-3.5 h-3.5`}),t(`actions.export`),` (`,G.size,`)`]}),(0,z.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,z.jsx)(P,{className:`w-3.5 h-3.5`}),t(`actions.import`)]}),(0,z.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,z.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,z.jsx)(g,{className:`w-3.5 h-3.5`}),t(`newLoop`)]})]})]}),ae?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`…`}):(0,z.jsxs)(`div`,{className:`space-y-8`,children:[Q.length===0&&$.length===0&&(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t(`empty.title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t(`empty.body`)})]}),$.length>0&&(0,z.jsx)(U,{title:t(`sections.published`),children:$.map(e=>(0,z.jsx)(fe,{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:k(e.graph)?void 0:()=>W(e)},e.id))}),Q.length>0&&(0,z.jsx)(U,{title:t(`sections.drafts`),children:Q.map(e=>(0,z.jsx)(fe,{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))}),y.length>0&&(0,z.jsx)(U,{title:t(`sections.builtIn`),children:y.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`factory-loop-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(D,{className:`w-3.5 h-3.5 text-accent-primary`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:l(e.id,e.name)}),(0,z.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:t(`builtInBadge`)})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:u(e.id,e.description)}),e.launchable===!1&&(0,z.jsxs)(`p`,{className:`text-[11px] text-accent-info/90 flex items-start gap-1.5`,"data-testid":`factory-loop-automatic`,children:[(0,z.jsx)(_,{className:`w-3 h-3 mt-0.5 shrink-0`,"aria-hidden":!0}),t(`automaticOnly`)]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.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,z.jsx)(T,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,z.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,z.jsx)(w,{className:`w-3 h-3`}),t(`actions.fork`)]})]})]},e.id))}),m.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`sections.templates`)}),(0,z.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,z.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,z.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ve(e),className:x(`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,z.jsx)(`span`,{className:`opacity-60 tabular-nums`,children:n})]},e)}),Ie&&(0,z.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,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,"data-testid":`template-empty`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`gallery.noResults`)}),(0,z.jsx)(`button`,{type:`button`,onClick:ye,className:`mt-2 text-xs text-accent-primary hover:underline`,children:t(`gallery.clearFilter`)})]}):(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:Fe.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`template-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(_,{className:`w-3.5 h-3.5 text-accent-highlight flex-shrink-0`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:l(e.id,e.name)}),e.category&&(0,z.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,z.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:u(e.id,e.description)}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[k(e.graph)?(0,z.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,z.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,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{V(`use`),R({...e,name:l(e.id,e.name),description:u(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,z.jsx)(T,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,z.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,z.jsx)(p,{className:`w-3 h-3`}),t(`actions.use`)]})]})]},e.id))})]})]})]}),(0,z.jsx)(b,{open:A!==null,onOpenChange:e=>{e||j(null)},children:(0,z.jsxs)(ie,{className:`max-w-sm`,children:[(0,z.jsxs)(re,{children:[(0,z.jsxs)(ne,{className:`flex items-center gap-2`,children:[(0,z.jsx)(v,{className:`w-4 h-4 text-destructive`}),d.find(e=>e.id===A)?.name??t(`actions.delete`)]}),(0,z.jsx)(te,{children:t(`confirmDelete`)})]}),(0,z.jsxs)(ee,{children:[(0,z.jsx)(S,{variant:`ghost`,onClick:()=>j(null),children:t(`common:actions.cancel`)}),(0,z.jsx)(S,{variant:`destructive`,onClick:()=>void Ne(),children:t(`common:actions.delete`)})]})]})}),(0,z.jsx)(M,{template:L,mode:B,onClose:()=>R(null),onUse:e=>{R(null),B===`fork`?Ee(e):Z(e)}}),(0,z.jsx)(de,{loop:H?{id:H.id,name:H.name}:null,projects:xe.map(e=>({id:e.id,name:e.name,providers:o(e),repositories:e.repositories})),onClose:()=>W(null),onExecute:De})]})}function U({title:e,children:t}){return(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2`,children:e}),(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t})]})}function fe({loop:e,selected:t,onToggleSelect:n,onEdit:r,onPublish:a,onUnpublish:o,onDuplicate:s,onExport:c,onDelete:l,onRun:u}){let{t:d}=i(`loops`),f=e.graph?.nodes?.length??0;return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`loop-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t,onChange:n,"aria-label":d(`actions.select`,{name:e.name}),className:`accent-accent-primary flex-shrink-0`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.name})]}),(0,z.jsx)(V,{status:e.status})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d(`card.nodes`,{count:f})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[u&&(0,z.jsx)(W,{icon:h,label:d(`actions.run`),onClick:u}),(0,z.jsx)(W,{icon:m,label:d(`actions.edit`),onClick:r}),a&&(0,z.jsx)(W,{icon:y,label:d(`actions.publish`),onClick:a}),o&&(0,z.jsx)(W,{icon:p,label:d(`actions.unpublish`),onClick:o}),(0,z.jsx)(W,{icon:w,label:d(`actions.duplicate`),onClick:s}),(0,z.jsx)(W,{icon:N,label:d(`actions.export`),onClick:c}),(0,z.jsx)(W,{icon:v,label:d(`actions.delete`),onClick:l,danger:!0})]})]})}function W({icon:e,label:t,onClick:n,danger:r}){return(0,z.jsx)(`button`,{type:`button`,onClick:n,title:t,"aria-label":t,className:x(`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,z.jsx)(e,{className:`w-3.5 h-3.5`})})}export{H as default};
@@ -1,5 +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"./useSharedWebSocket-BHIfW4QT.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{i as o}from"./useDesktop-CAisjKWC.js";import{a as s,i as c,l,o as u,r as d,t as f}from"./dialog-xXB2q5HJ.js";import{t as p}from"./button-Ccc9Dc-D.js";var m=new Set([`building`,`on_review`,`pr_draft`,`pr_ready`,`no_changes`,`completed`,`pr_closed`,`superseded`,`merged`,`discarded`,`implementation_failed`,`pr_failed`]),h=new Set([`none`,`local-only`,`pushed`,`pr-created`]),g=new Set([`running`,`succeeded`,`partially_succeeded`,`failed`,`unknown`]),_=new Set([`pending`,`ready`,`delivered`,`partial`,`no_changes`,`retryable_failure`,`blocked`,`not_started`,`unknown`]),v=new Set([`create-pr`,`publish`,`discard`,`poll-merge`,`merge-local`,`dismiss`,`reopen`,`acknowledge-no-changes`,`recover-and-retry`,`checkout`]),y=new Set([`implementation_running`,`implementation_failed`,`ready_for_review`,`partial_success`,`partial_delivery`,`existing_pr_updated`,`no_changes`,`commit_failed`,`branch_verification_failed`,`push_failed`,`settlement_interrupted`,`recovery_unavailable`,`operation_interrupted`,`delivery_failed`,`pr_draft_ready`,`pr_ready`,`pr_closed`,`merged`,`discarded`,`superseded`,`cleanup_incomplete`,`status_failed`,`ref_mismatch`]);function b(e){return typeof e==`string`&&y.has(e)}var x=`previous delivery action was interrupted by restart`;function S(e,t){return e===`operation_interrupted`||typeof t==`string`&&t.toLowerCase().includes(x)}var C=e=>typeof e==`string`&&e.length>0?e:null,w=e=>typeof e==`string`&&e.length>0?e:null;function T(e){if(!e)return null;let t=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(e)?`${e.replace(` `,`T`)}Z`:e,n=Date.parse(t);return Number.isFinite(n)?n:null}function ee(e,t){let n=T(e),r=T(t);return n==null||r==null?null:r<n?-1:+(r>n)}function te(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.ticketId!=`number`||!Number.isFinite(t.ticketId)||typeof t.branch!=`string`)return null;let n=typeof t.implementationOutcome==`string`&&g.has(t.implementationOutcome)?t.implementationOutcome:void 0,r=typeof t.deliveryOutcome==`string`&&_.has(t.deliveryOutcome)?t.deliveryOutcome:void 0;return{ticketId:t.ticketId,branch:t.branch,succeeded:t.succeeded===!0,...C(t.runId)?{runId:C(t.runId)}:{},...n?{implementationOutcome:n}:{},...r?{deliveryOutcome:r}:{},initialSha:w(t.initialSha),finalSha:w(t.finalSha),...typeof t.changed==`boolean`?{changed:t.changed}:{},failureCode:w(t.failureCode),...t.branchOwnership===`created`||t.branchOwnership===`preexisting`||t.branchOwnership===`borrowed-pr`?{branchOwnership:t.branchOwnership}:{},worktreePath:w(t.worktreePath)}}function E(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=C(n.prDeliveryId)??C(n.id),i=typeof n.railIndex==`number`&&Number.isFinite(n.railIndex)?n.railIndex:t;if(!r||i==null||typeof n.decision!=`string`||!m.has(n.decision))return null;let a=typeof n.implementationOutcome==`string`&&g.has(n.implementationOutcome)?n.implementationOutcome:void 0,o=typeof n.deliveryOutcome==`string`&&_.has(n.deliveryOutcome)?n.deliveryOutcome:void 0,s=(Array.isArray(n.units)?n.units:Array.isArray(n.branches)?n.branches:[]).map(te).filter(e=>e!==null);return{prDeliveryId:r,railIndex:i,railKey:typeof n.railKey==`string`?n.railKey:``,ticketIds:Array.isArray(n.ticketIds)?n.ticketIds.filter(e=>typeof e==`number`&&Number.isFinite(e)):[],baseBranch:typeof n.baseBranch==`string`?n.baseBranch:``,branch:w(n.branch),prUrl:w(n.prUrl),prNumber:typeof n.prNumber==`number`&&Number.isInteger(n.prNumber)&&n.prNumber>0?n.prNumber:null,prState:typeof n.prState==`string`&&h.has(n.prState)?n.prState:`none`,decision:n.decision,runIds:Array.isArray(n.runIds)?n.runIds.filter(e=>typeof e==`string`&&e.length>0):s.map(e=>e.runId).filter(e=>typeof e==`string`&&e.length>0),originConversationId:w(n.originConversationId),createdAt:typeof n.createdAt==`string`?n.createdAt:void 0,updatedAt:typeof n.updatedAt==`string`?n.updatedAt:void 0,...a?{implementationOutcome:a}:{},...o?{deliveryOutcome:o}:{},statusCode:w(n.statusCode),statusDetail:w(n.statusDetail),deliverySha:w(n.deliverySha),isContinuation:n.isContinuation===!0,supersedesDeliveryId:w(n.supersedesDeliveryId),restoredFromDeliveryId:w(n.restoredFromDeliveryId),operation:typeof n.operation==`string`&&v.has(n.operation)?n.operation:null,cleanupWarnings:Array.isArray(n.cleanupWarnings)?n.cleanupWarnings.filter(e=>typeof e==`string`&&e.length>0):[],safetyArchives:Array.isArray(n.safetyArchives)?n.safetyArchives.filter(e=>typeof e==`string`&&e.length>0):[],units:s,executionManifest:n.executionManifest&&typeof n.executionManifest==`object`&&n.executionManifest.version===1?n.executionManifest:void 0,repositoryDeliveries:Array.isArray(n.repositoryDeliveries)?n.repositoryDeliveries.slice(0,100).flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;if(typeof t.repositoryId!=`string`||typeof t.deliveryId!=`string`||typeof t.name!=`string`||typeof t.path!=`string`)return[];let n=E({...t,prDeliveryId:t.deliveryId,repositoryDeliveries:void 0},i);return n?[{repositoryId:t.repositoryId,deliveryId:t.deliveryId,name:t.name,path:t.path,baseBranch:n.baseBranch,...C(t.integrationBranch)?{integrationBranch:C(t.integrationBranch)}:{},branch:n.branch,deliverySha:n.deliverySha??null,decision:n.decision,implementationOutcome:n.implementationOutcome??`unknown`,deliveryOutcome:n.deliveryOutcome??`unknown`,statusCode:n.statusCode??null,statusDetail:n.statusDetail??null,prUrl:n.prUrl,prNumber:n.prNumber,runIds:n.runIds,worktreeIds:Array.isArray(t.worktreeIds)?t.worktreeIds.filter(e=>typeof e==`string`):[]}]:[]}):void 0}}function ne(e){let t=D(e);if(t.terminal||t.deliveryBlocked||t.implementationFailed||t.noChanges||e.decision===`building`||e.decision===`implementation_failed`)return null;if(e.branch||e.deliverySha)return e.branch&&/^[0-9a-f]{40,64}$/i.test(e.deliverySha??``)?e.branch:null;let n=e.units??[];if(n.length!==1)return null;let r=n[0];return!r.succeeded||r.implementationOutcome===`failed`||r.deliveryOutcome===`blocked`||r.deliveryOutcome===`no_changes`||r.changed===!1?null:r.branch&&/^[0-9a-f]{40,64}$/i.test(r.finalSha??``)?r.branch:null}function D(e){let t=e.units??[],n=t.length>0?t.filter(e=>e.implementationOutcome===`succeeded`||e.implementationOutcome==null&&e.succeeded).length:e.implementationOutcome===`failed`?0:e.ticketIds.length,r=t.length>0?t.filter(e=>e.implementationOutcome===`failed`||e.implementationOutcome==null&&!e.succeeded).length:e.implementationOutcome===`failed`?e.ticketIds.length:0,i=e.decision===`no_changes`||e.decision===`completed`||e.deliveryOutcome===`no_changes`||e.statusCode===`no_changes`,a=e.implementationOutcome===`partially_succeeded`||e.deliveryOutcome===`partial`||n>0&&r>0,o=t.length>0?t.filter(e=>e.deliveryOutcome===`ready`||e.deliveryOutcome===`delivered`||e.deliveryOutcome==null&&e.succeeded).length:a?0:n,s=a&&o===0,c=e.implementationOutcome===`failed`||e.implementationOutcome==null&&e.decision===`implementation_failed`,l=e.deliveryOutcome===`retryable_failure`,u=!c&&!l&&(s||e.deliveryOutcome===`blocked`||[`commit_failed`,`branch_verification_failed`,`settlement_interrupted`,`recovery_unavailable`,`status_failed`,`ref_mismatch`,`delivery_failed`].includes(e.statusCode??``)),d=e.isContinuation===!0,f=[...new Set((e.runIds??[]).filter(e=>typeof e==`string`&&e.length>0))],p=f.length===1?f[0]:null,m=p&&e.branch?t.filter(t=>t.runId===p&&t.branch===e.branch):[],h=[...new Set(m.map(e=>e.worktreePath).filter(e=>!!e))],g=(e.statusCode===`settlement_interrupted`||e.statusCode===`recovery_unavailable`)&&d?h:[...new Set(t.map(e=>e.worktreePath).filter(e=>!!e))],_=e.decision===`pr_failed`&&e.deliveryOutcome===`blocked`&&u&&d&&!!e.prUrl&&!!e.branch&&f.length===1&&m.length>0&&h.length<=1&&e.statusCode===`settlement_interrupted`&&(e.implementationOutcome===`succeeded`||e.implementationOutcome===`partially_succeeded`),v=e.decision===`pr_failed`&&e.deliveryOutcome===`blocked`&&u&&d&&e.statusCode===`recovery_unavailable`,y=v&&!!e.prUrl&&!!e.branch&&f.length===1&&m.length>0&&h.length<=1&&(e.implementationOutcome===`succeeded`||e.implementationOutcome===`partially_succeeded`),b=g.length>0||v&&!!e.deliverySha,x=!c&&l&&(e.statusCode===`push_failed`||d||!!e.prUrl),S=!c&&l&&!x,C=e.decision===`pr_closed`,w=e.decision===`superseded`;return{noChanges:i,partial:a,partialUndeliverable:s,implementationFailed:c,deliveryBlocked:u,retryablePush:x,retryablePrCreation:S,manualRecovery:_,recoveryUnavailable:v,recoveryRecheck:y,hasDiscardableRecoveryResult:b,continuation:d,localOnly:e.prState===`local-only`,closed:C,superseded:w,terminal:e.decision===`merged`||e.decision===`discarded`||e.decision===`completed`||w,succeededCount:n,deliverableCount:o,failedCount:r,totalCount:t.length>0?t.length:e.ticketIds.length,units:t,cleanupWarnings:e.cleanupWarnings??[],safetyArchives:e.safetyArchives??[],recoveryWorktreePaths:g}}var re=a(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),O=`specrails:git-changed`;function ie(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(O,{detail:{projectId:e}}))}function ae(e){if(typeof window>`u`)return()=>{};let t=t=>{let n=t.detail?.projectId;typeof n==`string`&&n&&e(n)};return window.addEventListener(O,t),()=>window.removeEventListener(O,t)}var k=e(t(),1),oe=`"\\/bfnrtu`;function A(e){return e===` `||e===` `||e===`\r`||e===`
2
- `}function se(e){let t=new Set,n=e.trim(),r=/^```[A-Za-z0-9_-]*[ \t]*\r?\n/.exec(n);r&&(n=n.slice(r[0].length),t.add(`nested_fence`));let i=/\r?\n[ \t]*```[ \t]*$/.exec(n);i&&(n=n.slice(0,i.index),t.add(`nested_fence`));let a=n.indexOf(`{`),o=n.lastIndexOf(`}`);a!==-1&&o>a&&(a>0||o<n.length-1)&&(n=n.slice(a,o+1),t.add(`trimmed_wrapper`));let s=``,c=!1;for(let e=0;e<n.length;e++){let r=n[e];if(c){if(r===`\\`){let i=n[e+1];if(i===void 0){t.add(`dangling_escape`);break}if(oe.includes(i)){s+=r+i,e+=1;continue}s+=i===`
3
- `?`\\n`:i,e+=1,t.add(`invalid_escape`);continue}if(r===`"`){let i=e+1;for(;i<n.length&&A(n[i]);)i+=1;let a=n[i];if(a===void 0||a===`,`||a===`}`||a===`]`||a===`:`){c=!1,s+=r;continue}s+=`\\"`,t.add(`inner_quote`);continue}if(r===`
4
- `){s+=`\\n`,t.add(`raw_newline`);continue}if(r===`\r`){t.add(`raw_newline`);continue}if(r===` `){s+=`\\t`,t.add(`raw_control`);continue}let i=r.charCodeAt(0);if(i<32){s+=`\\u`+i.toString(16).padStart(4,`0`),t.add(`raw_control`);continue}s+=r;continue}if(r===`"`){c=!0,s+=r;continue}if(r===`,`){let i=e+1;for(;i<n.length&&A(n[i]);)i+=1;if(n[i]===`}`||n[i]===`]`){t.add(`trailing_comma`);continue}s+=r;continue}if(r===`/`&&n[e+1]===`/`){let r=n.indexOf(`
5
- `,e);e=r===-1?n.length:r,t.add(`comment`);continue}if(r===`/`&&n[e+1]===`*`){let r=n.indexOf(`*/`,e+2);e=r===-1?n.length:r+1,t.add(`comment`);continue}s+=r}return{text:s,repairs:[...t]}}function ce(e,t){let n=e instanceof Error?e.message:String(e),r=/position (\d+)/i.exec(n),i=r?Number(r[1]):null,a=null;if(i!==null&&Number.isFinite(i)){let e=Math.max(0,i-40),n=Math.min(t.length,i+40);a=t.slice(e,n).replace(/\s+/g,` `)}return{error:n,position:i,excerpt:a}}function j(e){try{return{ok:!0,value:JSON.parse(e),repaired:!1,repairs:[]}}catch(t){let{text:n,repairs:r}=se(e);try{return{ok:!0,value:JSON.parse(n),repaired:!0,repairs:r}}catch{return{ok:!1,...ce(t,e)}}}}var M=/```blueprint-draft\s*\n([\s\S]*?)\n\s*```/g,N=/```blueprint-draft(?![\s\S]*?\n\s*```)/,P=/```(?:json|JSON)?[ \t]*\r?\n(?=[ \t]*\{)([\s\S]*?)\r?\n[ \t]*```(?=[ \t]*(?:\r?\n|$))/g,F=/```(?:json|JSON)?[ \t]*\r?\n[ \t]*\{(?=[\s\S]*"blueprintVersion")(?![\s\S]*?\n[ \t]*```)/,le=/```(?:blueprint-draft|spec-detail|spec-audit)(?![\s\S]*?\n\s*```)/,ue=new Set([`planned`,`committed`,`done`]),de=new Set([`scaffold`,`feature`,`verification`]),fe=new Set([`critical`,`high`,`medium`,`low`]);function I(e){return typeof e==`string`?e:``}function L(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function pe(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{};return{name:I(t.name),pitch:I(t.pitch),audience:I(t.audience)}}function me(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={language:I(t.language),framework:I(t.framework),db:I(t.db)};return typeof t.notes==`string`&&t.notes!==``&&(n.notes=t.notes),n}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n,r=I(e.id),i=I(e.title);if(r===``&&i===``)continue;let a={id:r,title:i,goal:I(e.goal),status:ue.has(e.status)?e.status:`planned`,plannedSpecs:L(e.plannedSpecs)};if(Array.isArray(e.ticketIds)){let t=e.ticketIds.filter(e=>typeof e==`number`&&Number.isInteger(e));t.length>0&&(a.ticketIds=t)}t.push(a)}return t}function z(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n,r=I(e.title);if(r===``)continue;let i={kind:de.has(e.kind)?e.kind:`feature`,title:r,shortSummary:I(e.shortSummary),description:I(e.description),acceptanceCriteria:L(e.acceptanceCriteria),priority:fe.has(e.priority)?e.priority:`medium`,labels:L(e.labels)};typeof e.dependsOnIndex==`number`&&Number.isInteger(e.dependsOnIndex)&&e.dependsOnIndex>=0&&(i.dependsOnIndex=e.dependsOnIndex),Array.isArray(e.repositoryIds)&&e.repositoryIds.length>0&&e.repositoryIds.every(e=>typeof e==`string`&&e.trim())&&new Set(e.repositoryIds).size===e.repositoryIds.length&&(i.repositoryIds=[...e.repositoryIds]),t.push(i)}return t}function B(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return typeof t.blueprintVersion!=`number`||!Number.isInteger(t.blueprintVersion)?null:{blueprintVersion:t.blueprintVersion,product:pe(t.product),coreFlow:I(t.coreFlow),platform:I(t.platform),stack:me(t.stack),assumptions:L(t.assumptions),milestones:R(t.milestones),specsComplete:t.specsComplete===!0,m1Specs:z(t.m1Specs)}}var he=/^[ \t]*\r?\n?[ \t]*```[ \t]*(?=\r?\n|$)/;function V(e){let t=e.indexOf(`"m1Specs"`);return t===-1?0:(e.slice(t).match(/"title"\s*:/g)??[]).length}function ge(e){if(!e||!e.includes(`"blueprintVersion"`))return e??``;let t=e=>!e.includes("```")||!e.includes(`"blueprintVersion"`)?e:(P.lastIndex=0,e.replace(P,(e,t)=>{if(!t.includes(`"blueprintVersion"`))return e;let n=j(t);return!n.ok||!B(n.value)?e:"```blueprint-draft\n"+t+"\n```"})),n=``,r=0;M.lastIndex=0;let i;for(;(i=M.exec(e))!==null;)n+=t(e.slice(r,i.index))+i[0],r=i.index+i[0].length;return n+t(e.slice(r))}function _e(e){let t=ge(e??``);if(!t||!t.includes("```blueprint-draft")&&!F.test(t))return{stripped:t??``,blueprint:null,rawBlueprint:null,hadBlocks:!1,rejected:[],repaired:!1,truncated:!1};let n=null,r=null,i=!1,a=!1,o=[],s=``,c=0,l=0;M.lastIndex=0;let u;for(;(u=M.exec(t))!==null;){a=!0,s+=t.slice(c,u.index),c=u.index+u[0].length;let e=he.exec(t.slice(c));e&&(c+=e[0].length,M.lastIndex=c);let d=l;l+=1;let f=j(u[1]);if(!f.ok){let e=f.excerpt?` near: …${f.excerpt}…`:``;o.push({index:d,reason:`invalid_json`,detail:`${f.error}${e}`});continue}let p=B(f.value);if(!p){o.push({index:d,reason:`missing_version`,detail:`the payload is not a blueprint object with an integer blueprintVersion`});continue}n=p,r=f.value,i=f.repaired}let d=t.slice(c),f=N.exec(d)??F.exec(d),p=!1;if(f){a=!0,p=!0;let e=V(d.slice(f.index));o.push({index:l,reason:`truncated`,detail:e>0?`the block was cut off before its closing fence after ${e} spec title(s) had started`:`the block was cut off before its closing fence`}),s+=d.slice(0,f.index)}else s+=d;return{stripped:s,blueprint:n,rawBlueprint:r,hadBlocks:a,rejected:o,repaired:i,truncated:p}}function ve(e){if(!e)return{generating:!1,specsStarted:0};if(e.includes("```blueprint-draft")){let t=N.exec(e);if(t)return{generating:!0,specsStarted:V(e.slice(t.index))}}let t=F.exec(e);if(t)return{generating:!0,specsStarted:V(e.slice(t.index))};let n=/```spec-(?:detail|audit)(?![\s\S]*?\n\s*```)/.exec(e);return n?{generating:!0,specsStarted:(e.slice(n.index).match(/"title"\s*:/g)??[]).length}:{generating:!1,specsStarted:0}}function ye(e){if(!e)return``;let t=(/```(?:blueprint-draft|spec-detail|spec-audit)/.test(e)?le.exec(e):null)??F.exec(e);return t?e.slice(0,t.index):e}function be(e){return e?{product:e.product.name!==``&&e.product.pitch!==``,coreFlow:e.coreFlow!==``,platform:e.platform!==``,stack:e.stack.language!==``||e.stack.framework!==``,milestones:e.milestones.length>0}:{product:!1,coreFlow:!1,platform:!1,stack:!1,milestones:!1}}function xe(e){return`M${e}`}var H=new Set([`planned`,`committed`,`running`,`delivered`,`done`]),Se=new Set([`running`,`waiting`,`paused`,`awaiting_approval`,`completed`,`cancelled`]),U=(e,t=0)=>typeof e==`number`&&Number.isFinite(e)?e:t,W=e=>typeof e==`string`?e:null,G=e=>Array.isArray(e)?e.filter(e=>typeof e==`number`):[],Ce=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[];function we(e){let t=e&&typeof e==`object`?e:{};return{total:U(t.total),done:U(t.done),onReview:U(t.onReview),inProgress:U(t.inProgress),todo:U(t.todo),failed:U(t.failed)}}function Te(e){if(!e||typeof e!=`object`)return null;let t=e,n=W(t.id);return n?{id:n,railIndex:U(t.railIndex,-1),ticketIds:G(t.ticketIds),decision:W(t.decision)??`building`,branch:W(t.branch),baseBranch:W(t.baseBranch)??``,prUrl:W(t.prUrl),prNumber:typeof t.prNumber==`number`?t.prNumber:null,prState:W(t.prState)??`none`,createdAt:W(t.createdAt)}:null}function Ee(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.railIndex==`number`?{railIndex:t.railIndex,name:W(t.name),ticketIds:G(t.ticketIds),active:t.active===!0,runId:W(t.runId),startedAt:W(t.startedAt),delivery:Te(t.delivery),chunkIndex:typeof t.chunkIndex==`number`?t.chunkIndex:null}:null}function K(e){if(!e||typeof e!=`object`)return null;let t=e,n=W(t.id),r=W(t.status);if(!n||!r||!Se.has(r))return null;let i=Array.isArray(t.launched)?t.launched.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.chunk!=`number`||typeof t.railIndex!=`number`?[]:[{chunk:t.chunk,railIndex:t.railIndex,ticketIds:G(t.ticketIds),runIds:Ce(t.runIds),deliveryId:W(t.deliveryId)}]}):[];return{id:n,milestoneN:U(t.milestoneN,0),mode:t.mode===`parallel`?`parallel`:`sequential`,status:r,pauseReason:W(t.pauseReason),autoAdvance:t.autoAdvance!==!1,nextChunk:U(t.nextChunk),totalChunks:U(t.totalChunks),currentRailIndex:typeof t.currentRailIndex==`number`?t.currentRailIndex:null,headBranch:W(t.headBranch),launched:i,updatedAt:W(t.updatedAt)??``}}function q(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e,n=W(t.id);if(!n||typeof t.n!=`number`)return[];let r=W(t.state),i=W(t.storedStatus);return[{id:n,n:t.n,title:W(t.title)??``,storedStatus:i===`done`||i===`committed`?i:`planned`,state:r&&H.has(r)?r:`planned`,counts:we(t.counts),rails:Array.isArray(t.rails)?t.rails.flatMap(e=>{let t=Ee(e);return t?[t]:[]}):[],chain:K(t.chain)}]}):[]}function De(e){let t=Math.max(0,e.total);if(t===0)return[];let n=Math.min(e.failed,e.todo);return[[`done`,e.done],[`onReview`,e.onReview],[`inProgress`,e.inProgress],[`failed`,n],[`todo`,Math.max(0,e.todo-n)]].filter(([,e])=>e>0).map(([e,n])=>({key:e,count:n,pct:Math.round(n/t*1e3)/10}))}function Oe(e){return e.done+e.onReview}function J(e){return e!==null&&(e.status===`running`||e.status===`waiting`)}function Y(e){return e!==null&&e.status===`awaiting_approval`}function ke(e){return e.counts.todo>0&&!J(e.chain)&&e.chain?.status!==`paused`&&!Y(e.chain)}function Ae(e){let t=new Set;for(let n of e){let e=n.chain;if(!e||e.mode!==`sequential`)continue;let r=[...e.launched].sort((e,t)=>e.chunk-t.chunk);for(let e=0;e<r.length-1;e++){let n=r[e].deliveryId;n&&t.add(n)}}return t}function je(e){if(!e)return{key:`unknown`,detail:``};let t=e.indexOf(`:`);return t<0?{key:e,detail:``}:{key:e.slice(0,t),detail:e.slice(t+1)}}var X=new Set([`on_review`,`no_changes`,`pr_draft`,`pr_ready`,`pr_failed`,`implementation_failed`,`pr_closed`]);function Me(e){let t=e.rails.map(e=>e.delivery).filter(e=>e!==null&&X.has(e.decision));return t.length===0?null:t.find(e=>e.decision===`on_review`)??t[0]}var Z=(0,k.createContext)(null);function Ne(){try{return r??Z}catch{return Z}}var Pe=Ne(),Fe=0;function Q(e){let t=(0,k.useContext)(Pe),{data:n,isLoading:r,refresh:i}=o({namespace:`milestone-progress`,projectId:e,initialValue:null,fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`/api/projects/${e}/blueprint`,{cache:`no-store`,signal:t});if(n.status===404)return{blueprint:null,progress:[]};if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();return{blueprint:B(r.blueprint),progress:q(r.progress)}}}),[a,s]=(0,k.useState)(null),c=(0,k.useRef)(e);(0,k.useEffect)(()=>{c.current=e,s(null)},[e]),(0,k.useEffect)(()=>{if(!t)return;let{registerHandler:e,unregisterHandler:n}=t,r=`milestone-progress:${++Fe}`;return e(r,e=>{let t=e;!t||t.type!==`blueprint.milestone_progress`||!t.projectId||t.projectId!==c.current||s({projectId:t.projectId,progress:q(t.progress)})}),()=>n(r)},[t]);let l=(0,k.useMemo)(()=>a&&a.projectId===e?a.progress:n?.progress??[],[a,e,n]),u=n===null?null:n.blueprint!==null,d=(0,k.useCallback)(async()=>{s(null),await i()},[i]);return{blueprint:n?.blueprint??null,progress:l,hasBlueprint:u,loading:r,refresh:d}}function Ie(e){let{progress:t}=Q(e);return(0,k.useMemo)(()=>Ae(t),[t])}var $=n();function Le({deliveryId:e,repositories:t,busy:n,onAct:r,onCheckout:a}){let{t:o}=i(`dashboard`),[m,h]=(0,k.useState)(null);if(!t?.length)return null;let g=m?.deliveryId===e?t.find(e=>e.repositoryId===m.repositoryId&&![`merged`,`completed`,`discarded`,`superseded`].includes(e.decision)):null;return(0,$.jsxs)(`div`,{className:`w-full space-y-2`,"data-testid":`repository-deliveries`,children:[t.map(t=>{let i=[`merged`,`completed`,`discarded`,`superseded`].includes(t.decision),s=t.deliveryOutcome===`blocked`,c=!!t.deliverySha&&!s&&t.implementationOutcome===`succeeded`,l=(i,a,o=!1)=>(0,$.jsx)(p,{size:`sm`,variant:`outline`,disabled:n,onClick:()=>{o?h({deliveryId:e,repositoryId:t.repositoryId,action:i}):r(i,t.repositoryId)},children:a});return(0,$.jsxs)(`section`,{className:`rounded-md border border-border/60 p-2 text-xs`,"aria-label":t.name,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`strong`,{children:t.name}),(0,$.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[t.branch??`…`,` → `,t.integrationBranch??t.baseBranch]}),(0,$.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:o(`common:repositoryDelivery.${t.decision}`)})]}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-muted-foreground`,children:t.path}),t.deliverySha&&(0,$.jsx)(`p`,{className:`font-mono text-muted-foreground`,children:t.deliverySha.slice(0,12)}),t.statusDetail&&(0,$.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-muted-foreground`,children:t.statusDetail}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[t.prUrl&&(0,$.jsxs)(`a`,{className:`underline`,href:t.prUrl,target:`_blank`,rel:`noreferrer`,children:[`PR #`,t.prNumber]}),!i&&(0,$.jsxs)($.Fragment,{children:[c&&!t.prUrl&&l(`create-pr`,o(`railPr.createPr`)),c&&t.prUrl&&t.deliveryOutcome===`retryable_failure`&&l(`create-pr`,o(`railPr.retryPush`)),c&&l(`merge-local`,o(`railPr.mergeLocal`),!0),c&&t.branch&&a&&(0,$.jsx)(p,{size:`sm`,variant:`outline`,disabled:n,onClick:()=>void a(t.repositoryId),children:o(`railPr.checkout`)}),t.prUrl&&t.decision===`pr_draft`&&l(`publish`,o(`railPr.publish`)),t.prUrl&&t.decision===`pr_closed`&&l(`reopen`,o(`railPr.reopen`)),t.prUrl&&l(`poll-merge`,o(`railPr.verifyPr`)),t.decision===`no_changes`&&l(`acknowledge-no-changes`,o(`railPr.markDone`),!0),s&&l(`recover-and-retry`,o(`railPr.retry`))]})]})]},t.repositoryId)}),(0,$.jsx)(f,{open:!!g,onOpenChange:e=>{e||h(null)},children:(0,$.jsxs)(d,{children:[(0,$.jsxs)(u,{children:[(0,$.jsx)(l,{children:o(m?.action===`merge-local`?`railPr.mergeLocalConfirmTitle`:`railPr.markDoneConfirmTitle`)}),(0,$.jsxs)(c,{children:[g?.name,` · `,o(m?.action===`merge-local`?`railPr.mergeLocalConfirmBody`:`railPr.markDoneConfirmBody`,{base:g?.integrationBranch??g?.baseBranch})]})]}),(0,$.jsxs)(s,{children:[(0,$.jsx)(p,{variant:`ghost`,onClick:()=>h(null),children:o(`common:actions.cancel`)}),(0,$.jsx)(p,{disabled:n||!g,onClick:()=>{let t=m;h(null),t&&t.deliveryId===e&&g&&r(t.action,t.repositoryId)},children:o(`common:actions.confirm`)})]})]})})]})}export{E as C,b as D,S as E,ne as O,re as S,D as T,be as _,Y as a,ie as b,K as c,ke as d,xe as f,ye as g,B as h,X as i,q as l,Me as m,Q as n,J as o,De as p,Ie as r,je as s,Le as t,Oe as u,ve as v,ee as w,ae as x,_e as y};
@@ -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{d as r,f as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{B as ee,U as te,n as ne}from"./TicketDetailModalContext-C5GgJlEt.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{a as c,r as re}from"./useDesktop-CAisjKWC.js";import{C as ie,S as ae,T as oe,b as se,r as ce,t as le}from"./RepositoryDeliveries-C36ipKp_.js";import{n as ue}from"./save-B6wGWwBR.js";import{u as de}from"./MinimizedChatsContext-UpnqccPx.js";import{t as l}from"./loader-circle-DcygOQpC.js";import{t as u}from"./sparkles-DrY8hb0X.js";import{t as d}from"./triangle-alert-H9T4jAmh.js";import{t as f}from"./utils-BC4DHlz2.js";import{n as p,t as m}from"./lib-CGdyxIWg.js";import{Bt as h,Gt as fe,Ot as pe,d as me,ft as g,zt as _}from"./index-DORCrgbI.js";var he=s(`circle-dollar-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]),v=s(`file-diff`,[[`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:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),y=e(t(),1),b=n();function x({children:e,muted:t=!1,className:n}){let r=(0,y.useMemo)(()=>({a:({href:e,children:t})=>(0,b.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-accent-primary underline decoration-accent-primary/40 underline-offset-2 hover:decoration-accent-primary`,children:t}),img:()=>null,code:({className:e,children:t})=>e?(0,b.jsx)(`code`,{className:e,children:t}):(0,b.jsx)(`code`,{className:`rounded-md border border-border/50 bg-background-deep/60 px-1.5 py-px font-mono text-[0.85em] text-accent-info`,children:t})}),[]);return(0,b.jsx)(`div`,{"data-testid":`packet-markdown`,className:f(`prose prose-invert prose-sm max-w-none leading-relaxed`,`prose-p:my-1.5 prose-headings:mt-3 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold`,`prose-strong:text-foreground prose-ul:my-1.5 prose-ol:my-1.5 prose-li:my-0.5 prose-li:marker:text-accent-primary/70`,`prose-pre:my-2 prose-pre:rounded-lg prose-pre:border prose-pre:border-border/50 prose-pre:bg-background-deep/60 prose-pre:text-xs`,`prose-blockquote:border-accent-primary/40 prose-blockquote:text-muted-foreground prose-hr:border-border/50`,t?`text-muted-foreground`:`text-foreground/85`,n),children:(0,b.jsx)(p,{remarkPlugins:[m],skipHtml:!0,components:r,children:e})})}var S=(e={})=>({verbs:[],acceptMeaning:null,fineControlOnly:!1,inFlight:!1,terminal:!1,requiresIrreversibleConfirm:!1,...e});function ge(e){let{decision:t,presentation:n,prUrl:r,canCreatePr:i}=e;if(t===`building`)return S({inFlight:!0});if(t===`merged`||t===`discarded`||n.superseded)return S({terminal:!0});if(n.manualRecovery||n.recoveryUnavailable||n.recoveryRecheck||n.retryablePush||n.retryablePrCreation||n.closed||n.deliveryBlocked&&!n.implementationFailed)return S({fineControlOnly:!0});if(n.noChanges)return S({verbs:[`accept`,`request-changes`],acceptMeaning:`mark-done`});if(n.implementationFailed)return S({verbs:n.succeededCount>0?[`request-changes`,`discard`]:[`discard`]});if(t===`pr_draft`)return S(r?{verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:`publish`}:{fineControlOnly:!0});if(t===`pr_ready`)return S({verbs:[`request-changes`,`discard`]});if(t===`on_review`){let e=i?`create-pr`:`merge-local`;return S({verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:e,requiresIrreversibleConfirm:e===`merge-local`})}return S({fineControlOnly:!0})}function _e(e,t){if(e===`discard`)return`discard`;if(e===`request-changes`)return null;switch(t.acceptMeaning){case`create-pr`:return`create-pr`;case`publish`:return`publish`;case`merge-local`:return`merge-local`;case`mark-done`:return`acknowledge-no-changes`;default:return null}}var ve=[`app-verified`,`ai-reported`,`reviewer-score`],ye={"app-verified":g,"ai-reported":u,"reviewer-score":v},be={"app-verified":`text-accent-success border-accent-success/30 bg-accent-success/5`,"ai-reported":`text-accent-highlight border-accent-highlight/30 bg-accent-highlight/5`,"reviewer-score":`text-accent-info border-accent-info/30 bg-accent-info/5`};function C({item:e}){let{t}=o(`packet`);return(0,b.jsxs)(`li`,{className:`flex flex-col gap-1 py-1.5`,children:[(0,b.jsx)(`span`,{className:`text-sm text-foreground`,children:t(e.code,{...e.values??{},defaultValue:e.code})}),e.rawExcerpt?(0,b.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded border border-border/60 bg-background-deep/60 p-2 text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:e.rawExcerpt}):null]})}function w({title:e,children:t,defaultOpen:n=!1,badge:r}){let[i,a]=(0,y.useState)(n);return(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-surface/40`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-4 py-3 text-left`,"aria-expanded":i,children:[i?(0,b.jsx)(h,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,b.jsx)(_,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`flex-1 text-sm font-medium text-foreground`,children:e}),r]}),i?(0,b.jsx)(`div`,{className:`border-t border-border/60 px-4 py-3`,children:t}):null]})}function T(e={}){let t=r(),n=e.prDeliveryId??t.prDeliveryId,{t:s}=o([`packet`,`common`]),u=a(),[f,p]=i(),m=f.get(`repositoryId`),h=(0,y.useRef)(0),g=e.onClose??(()=>u(`/`)),{activeProjectId:_}=re(),v=ce(_),S=n?v.has(n):!1,{act:T,checkout:xe}=me(),{openTicketDetail:Se}=ne(),E=JSON.stringify([_,n,m]),D=(0,y.useRef)({key:E,epoch:0});D.current.key!==E&&(D.current={key:E,epoch:D.current.epoch+1});let O=D.current.epoch,k=(0,y.useRef)(!0);(0,y.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let A=(0,y.useCallback)(()=>k.current&&D.current.key===E&&D.current.epoch===O,[E,O]),[j,M]=(0,y.useState)(null),N=j?.key===E&&j.epoch===O?j:null,P=N?.data??null,F=N?.loading??!0,I=N?.error??null,[L,R]=(0,y.useState)(null),[Ce,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(null),[H,U]=(0,y.useState)(``),[W,G]=(0,y.useState)(!1),[we,K]=(0,y.useState)(null),[Te,q]=(0,y.useState)(!1),J=(0,y.useCallback)(async()=>{if(!n||!_||!A())return;let e=++h.current,t=()=>A()&&h.current===e;M(e=>({key:E,epoch:O,data:e?.key===E&&e.epoch===O?e.data:null,loading:!0,error:null}));try{let e=m?`?repositoryId=${encodeURIComponent(m)}`:``,r=await fetch(`${c()}/rails/pr-deliveries/${n}/packet${e}`);if(!t())return;if(!r.ok){M({key:E,epoch:O,data:null,loading:!1,error:r.status===404?`notFound`:`loadFailed`});return}let i=await r.json();if(!t())return;M({key:E,epoch:O,data:i,loading:!1,error:null})}catch{if(!t())return;M({key:E,epoch:O,data:null,loading:!1,error:`loadFailed`})}},[n,_,m,E,O,A]);(0,y.useEffect)(()=>(J(),z(!1),q(!1),R(null),V(null),K(null),G(!1),U(``),()=>{h.current++}),[J]);let Y=(0,y.useMemo)(()=>ie(P?.snapshot),[P?.snapshot]),X=P?.packet??null,Z=F||L!==null||W||!!Y?.operation,Ee=P?.acceptCapability??null,Q=(0,y.useMemo)(()=>{if(!X)return null;let e=oe({decision:X.decision,ticketIds:X.ticketIds,prState:X.prUrl?`pr-created`:`none`,statusCode:X.statusCode,prUrl:X.prUrl,runIds:X.runIds});return ge({decision:X.decision,presentation:e,prUrl:X.prUrl,canCreatePr:Ee?.target===`create-pr`})},[X,Ee]),$=(0,y.useCallback)(async e=>{if(!X||!Q||Z||!A())return;let t=_e(e,Q);if(t){V(null),R(e);try{let e=await(m&&Y?T(Y.railIndex,t,Y.decision,Y.prDeliveryId,m):T(X.railIndex,t,X.decision,X.prDeliveryId));if(!A())return;e.ok?_&&se(_):V(e.status===409&&e.error===`stale_decision`?`alreadyResolved`:`actionFailed`),await J()}finally{A()&&(R(null),z(!1))}}},[T,_,J,X,Q,Y,m,Z,A]),De=(0,y.useCallback)(async()=>{if(!(!X||!H.trim()||!_||Z||!A())){K(null),G(!0);try{let e=await fetch(`${c()}/rails/${X.railIndex}/launch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({revisionOfDeliveryId:Y?.prDeliveryId??X.prDeliveryId,revisionNote:H.trim(),...Y?.executionManifest?{repositoryIds:Y.executionManifest.selectedRepositoryIds}:{}})});if(!A())return;if(!e.ok){let t=await e.json().catch(()=>null);if(!A())return;K(t?.error===`invalid_revision_target`?`revisionStale`:`revisionFailed`);return}U(``),q(!1),await J()}catch{A()&&K(`revisionFailed`)}finally{A()&&G(!1)}}},[_,J,X,H,Y,Z,A]);if(F&&!X)return(0,b.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,b.jsx)(l,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}),s(`common:states.loading`)]});if(I||!X||!Q)return(0,b.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-center gap-4 p-10 text-center`,children:[(0,b.jsx)(d,{className:`size-6 text-accent-warning`,"aria-hidden":!0}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(I===`notFound`?`error.notFound`:`error.loadFailed`)}),(0,b.jsx)(`button`,{type:`button`,onClick:g,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface`,children:s(`backToBoard`)})]});let Oe=ve.map(e=>({tier:e,items:X.proof.filter(t=>t.tier===e)})).filter(e=>e.items.length>0),ke=X.cost.totalUsd===null?`—`:`${X.cost.estimated?`~`:``}$${X.cost.totalUsd.toFixed(2)}`;return(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 p-6`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:g,className:`flex w-fit items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,b.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),s(`backToBoard`)]}),Y?.repositoryDeliveries?.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[s(`common:repositories.select`),(0,b.jsxs)(`select`,{value:m??``,onChange:e=>{let t=new URLSearchParams(f);e.target.value?t.set(`repositoryId`,e.target.value):t.delete(`repositoryId`),p(t,{replace:!0})},className:`rounded border border-border bg-background px-2 py-1`,children:[(0,b.jsx)(`option`,{value:``,children:s(`common:repositories.all`)}),Y.repositoryDeliveries.map(e=>(0,b.jsx)(`option`,{value:e.repositoryId,children:e.name},e.repositoryId))]})]}),(0,b.jsx)(le,{deliveryId:Y.prDeliveryId,repositories:Y.repositoryDeliveries,busy:Z,onAct:async(e,t)=>{if(!(Z||!A())){R(`accept`);try{let n=await T(Y.railIndex,e,Y.decision,Y.prDeliveryId,t);if(!A())return;n.ok||V(`actionFailed`),await J()}finally{A()&&R(null)}}},onCheckout:async e=>{if(!(Z||!A())){R(`accept`);try{let t=await xe(Y.railIndex,Y.prDeliveryId,e);if(!A())return;t.ok||V(`actionFailed`),await J()}finally{A()&&R(null)}}}})]}):null,(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-surface/60 p-5 shadow-sm`,children:[(0,b.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:s(X.headlineCode,{count:X.totalCount,succeeded:X.succeededCount,total:X.totalCount,defaultValue:X.headlineCode})}),(0,b.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[X.confidence?.overall!==null&&X.confidence?.overall!==void 0?(0,b.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-accent-info/30 bg-accent-info/10 px-2 py-0.5 text-accent-info`,title:s(`confidence.tooltip`),children:s(`confidence.pill`,{overall:X.confidence.overall})}):(0,b.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-muted-foreground`,children:s(`confidence.unavailable`)}),(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,b.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),s(`cost.thisBuild`,{amount:ke})]}),X.prUrl?(0,b.jsxs)(`a`,{href:X.prUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent-info hover:underline`,children:[(0,b.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),s(`openPr`,{number:X.prNumber??``})]}):null]}),Q.fineControlOnly?(0,b.jsx)(`p`,{className:`mt-4 rounded-md border border-accent-warning/30 bg-accent-warning/5 px-3 py-2 text-xs text-accent-warning`,children:s(`fineControlOnly`)}):Q.inFlight?(0,b.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,b.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}),s(`stillWorking`)]}):Q.terminal?(0,b.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:s(`alreadyResolved`)}):(0,b.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[Q.verbs.includes(`accept`)&&(!Y?.repositoryDeliveries?.length||m)?Ce?(0,b.jsxs)(`div`,{className:`flex w-full flex-col gap-2 rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,b.jsx)(`p`,{className:`text-xs text-foreground`,children:s(`accept.irreversibleWarning`)}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:()=>void $(`accept`),disabled:Z,className:`rounded-md bg-destructive px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept-confirm`,children:s(`accept.irreversibleConfirm`)}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>z(!1),className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground`,children:s(`common:actions.cancel`)})]})]}):(0,b.jsxs)(`button`,{type:`button`,onClick:()=>{Q.requiresIrreversibleConfirm?z(!0):$(`accept`)},disabled:Z,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-success px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept`,children:[L===`accept`?(0,b.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,b.jsx)(de,{className:`size-4`,"aria-hidden":!0}),s(`accept.${Q.acceptMeaning??`generic`}`)]}):null,Q.verbs.includes(`request-changes`)?(0,b.jsxs)(`button`,{type:`button`,onClick:()=>q(e=>!e),disabled:Z||W,"aria-expanded":Te,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-request-changes`,children:[(0,b.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),s(`requestChanges.label`)]}):null,Q.verbs.includes(`discard`)?(0,b.jsxs)(`button`,{type:`button`,onClick:()=>void $(`discard`),disabled:Z,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-discard`,children:[L===`discard`?(0,b.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,b.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),s(`discard.label`)]}):null]}),S&&Q.verbs.includes(`discard`)?(0,b.jsx)(`p`,{className:`mt-3 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-accent-warning`,"data-testid":`packet-discard-stacked-note`,children:s(`discard.stackedNote`)}):null,B?(0,b.jsx)(`p`,{className:`mt-3 text-xs text-accent-warning`,children:s(`error.${B}`)}):null,Te?(0,b.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 rounded-md border border-border/70 bg-background-deep/40 p-3`,children:[(0,b.jsx)(`label`,{htmlFor:`packet-revision-note`,className:`text-xs font-medium text-foreground`,children:s(`requestChanges.prompt`)}),(0,b.jsx)(`textarea`,{id:`packet-revision-note`,value:H,onChange:e=>U(e.target.value),rows:2,placeholder:s(`requestChanges.placeholder`),className:`resize-y rounded-md border border-border bg-surface px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground`,"data-testid":`packet-revision-input`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>void De(),disabled:Z||H.trim().length===0,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-revision-submit`,children:[W?(0,b.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,b.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),s(`requestChanges.submit`)]}),(0,b.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:s(`requestChanges.hint`)})]}),we?(0,b.jsx)(`p`,{className:`text-xs text-accent-warning`,children:s(`error.${we}`)}):null]}):null]}),X.driftNudges.length>0?(0,b.jsxs)(`div`,{className:`rounded-lg border border-accent-highlight/30 bg-accent-highlight/5 p-4`,"data-testid":`packet-drift-nudges`,children:[(0,b.jsx)(`h2`,{className:`mb-1 text-sm font-medium text-accent-highlight`,children:s(`drift.title`)}),(0,b.jsx)(`ul`,{className:`space-y-1 text-xs text-foreground`,children:X.driftNudges.map(e=>(0,b.jsx)(`li`,{children:s(e.code,{...e.values,defaultValue:e.code})},e.code))}),(0,b.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:s(`drift.advisory`)})]}):null,X.versions.length>1?(0,b.jsxs)(w,{title:s(`versions.title`,{count:X.versions.length}),badge:(0,b.jsx)(pe,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),children:[(0,b.jsx)(`ol`,{className:`space-y-2`,"data-testid":`packet-versions`,children:X.versions.map(e=>(0,b.jsxs)(`li`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:e.current?`font-medium text-foreground`:`text-muted-foreground`,children:s(`versions.label`,{version:e.version})}),e.current?(0,b.jsx)(`span`,{className:`rounded-full border border-accent-primary/40 bg-accent-primary/10 px-1.5 text-[10px] text-accent-primary`,children:s(`versions.current`)}):null,(0,b.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.costUsd===null?`—`:`${e.costEstimated?`~`:``}$${e.costUsd.toFixed(2)}`})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.revisionNote??s(`versions.originalBuild`)})]},e.prDeliveryId))}),(0,b.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:s(`cost.allVersions`,{amount:X.chainCostUsd===null?`—`:`${X.chainCostEstimated?`~`:``}$${X.chainCostUsd.toFixed(2)}`})})]}):null,X.watchOut.length>0?(0,b.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/5 p-4`,children:[(0,b.jsxs)(`h2`,{className:`mb-2 flex items-center gap-1.5 text-sm font-medium text-accent-warning`,children:[(0,b.jsx)(d,{className:`size-4`,"aria-hidden":!0}),s(`watchOut.title`)]}),(0,b.jsx)(`ul`,{className:`space-y-1`,children:X.watchOut.map((e,t)=>(0,b.jsx)(C,{item:e},`${e.code}-${t}`))})]}):null,(0,b.jsx)(w,{title:s(`sections.whatYouAsked`),defaultOpen:!0,children:(0,b.jsx)(`ul`,{className:`space-y-3`,children:X.sections.map(e=>(0,b.jsxs)(`li`,{className:`text-sm`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>Se(e.ticketId),className:`text-accent-primary hover:underline`,children:[`#`,e.ticketId,` `,e.title??``]}),e.problem?(0,b.jsx)(x,{muted:!0,className:`mt-1`,children:e.problem}):null]},e.ticketId))})}),(0,b.jsx)(w,{title:s(`sections.whatIDid`),children:(0,b.jsx)(`ul`,{className:`space-y-3`,children:X.sections.map(e=>(0,b.jsxs)(`li`,{className:`text-sm`,children:[(0,b.jsxs)(`div`,{className:`font-medium text-foreground`,children:[`#`,e.ticketId,e.title?(0,b.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,e.title]}):null]}),e.solution?(0,b.jsx)(x,{className:`mt-1`,children:e.solution}):(0,b.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:s(`noSolutionRecorded`)}),e.solutionOverflow?(0,b.jsxs)(`details`,{className:`group mt-2 rounded-lg border border-border/50 bg-background-deep/30`,children:[(0,b.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-1.5 text-xs font-medium text-accent-primary/90 hover:text-accent-primary`,children:s(`sections.fullSolution`)}),(0,b.jsx)(x,{className:`px-3 pb-3`,children:e.solutionOverflow})]}):null,e.churn?(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s(`churn.line`,{files:e.churn.filesTouched,added:e.churn.addedLines,removed:e.churn.removedLines})}):(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s(`churn.batchNotSplittable`)})]},e.ticketId))})}),(0,b.jsx)(w,{title:s(`sections.howItWasChecked`),badge:X.evidenceUnavailable?(0,b.jsx)(`span`,{className:`rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-[10px] text-muted-foreground`,children:s(`proof.evidenceUnavailable`)}):void 0,children:(0,b.jsx)(`div`,{className:`space-y-4`,children:Oe.map(({tier:e,items:t})=>{let n=ye[e];return(0,b.jsxs)(`div`,{className:`rounded-md border px-3 py-2 ${be[e]}`,children:[(0,b.jsxs)(`h3`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium`,children:[(0,b.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),s(`tier.${e}.title`)]}),(0,b.jsx)(`p`,{className:`mb-2 text-[11px] opacity-80`,children:s(`tier.${e}.caveat`)}),(0,b.jsx)(`ul`,{className:`space-y-1`,children:t.map((e,t)=>(0,b.jsx)(C,{item:e},`${e.code}-${t}`))})]},e)})})})]})}export{T 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{n as a,t as o}from"./square-Ci-PFcFe.js";import{a as s,i as c,l,o as u,r as d,t as f}from"./dialog-xXB2q5HJ.js";import{t as p}from"./button-Ccc9Dc-D.js";import{Ft as m,ct as h,h as g}from"./index-DORCrgbI.js";var _=e(),v={start:a,"ai-step":n,shell:h,decider:i,condition:i,end:o};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)(d,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(u,{children:[(0,_.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,_.jsx)(n,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,_.jsx)(c,{children:e.description})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[g(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]??o,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)(s,{children:[(0,_.jsx)(p,{variant:`ghost`,onClick:i,children:b(`common:actions.cancel`)}),(0,_.jsxs)(p,{onClick:()=>a(e.id),children:[h===`fork`?(0,_.jsx)(m,{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};