specrails-desktop 2.61.0 → 2.63.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.
- package/cli/dist/specrails-desktop.js +39 -5
- package/client/dist/assets/ActivityFeedPage-Bn2MpG5M.js +1 -0
- package/client/dist/assets/{AgentBrowserCapture-CkNWDZT3.js → AgentBrowserCapture-CHlXWdXq.js} +1 -1
- package/client/dist/assets/AgentModeAnalyticsPane-yj-YCgrK.js +2 -0
- package/client/dist/assets/AgentModeCodePane-Xczcyghb.js +2 -0
- package/client/dist/assets/{AgentModeJobsPane-U1J6PaBo.js → AgentModeJobsPane-DtOW01ln.js} +1 -1
- package/client/dist/assets/AgentsPage-BMfJ4mzU.js +118 -0
- package/client/dist/assets/AnalyticsPage-CGn5cgtc.js +1 -0
- package/client/dist/assets/BarChart-BDMqVFJy.js +55 -0
- package/client/dist/assets/CodePage-C8NIginr.js +3 -0
- package/client/dist/assets/DesktopAnalyticsPage-C87r4y26.js +1 -0
- package/client/dist/assets/{DocsDialog-CSlMPemn.js → DocsDialog-Z50a_KPv.js} +1 -1
- package/client/dist/assets/{DocsPage-BKlYAvWq.js → DocsPage-DIArbEPl.js} +1 -1
- package/client/dist/assets/{ExportDropdown-CweP_1GP.js → ExportDropdown-CJdCqYd7.js} +1 -1
- package/client/dist/assets/IntegrationsPage-EAipiDWm.js +1 -0
- package/client/dist/assets/InteractiveJobComposer-BxLh4me-.js +19 -0
- package/client/dist/assets/{JobDetailModal-DYyGq1Vp.js → JobDetailModal-C7dWoRu6.js} +1 -1
- package/client/dist/assets/JobDetailPage-Ilu294WS.js +1 -0
- package/client/dist/assets/JobsPage-fPq1hefb.js +1 -0
- package/client/dist/assets/LoopBuilderPage-5M7IypEP.js +1 -0
- package/client/dist/assets/{LoopPreviewModal-DkLRfsYX.js → LoopPreviewModal-ChI3NQC7.js} +1 -1
- package/client/dist/assets/{LoopWindowSurface-CuACkXFV.js → LoopWindowSurface-D1WB9i-9.js} +1 -1
- package/client/dist/assets/LoopsPage-CCwc0Biu.js +2 -0
- package/client/dist/assets/MinimizedChatsContext-eH_KaAZ1.js +1 -0
- package/client/dist/assets/PluginsPage-DfDfEfbW.js +2 -0
- package/client/dist/assets/ProjectSettingsDialog-9NHnG8JQ.js +1 -0
- package/client/dist/assets/RepositoryDeliveries-DgzNnJmn.js +5 -0
- package/client/dist/assets/{RepositoryScopeSelector-CeCr6Jz-.js → RepositoryScopeSelector-BSgUqk_u.js} +1 -1
- package/client/dist/assets/ReviewPacketPage-D34bGpSA.js +4 -0
- package/client/dist/assets/{TemplatePreviewModal-B8yd1AGU.js → TemplatePreviewModal-CcfSxWQ7.js} +1 -1
- package/client/dist/assets/TicketDetailModalContext-BoafEcm4.js +16 -0
- package/client/dist/assets/Trans-CVSryAL1.js +1 -0
- package/client/dist/assets/agent-5bSixVzz.js +1 -0
- package/client/dist/assets/agent-BR4EHfhq.js +1 -0
- package/client/dist/assets/agent-C0IKkJP8.js +1 -0
- package/client/dist/assets/agent-C7li9ayC.js +1 -0
- package/client/dist/assets/agent-D0dRmEen.js +1 -0
- package/client/dist/assets/{agent-BjttZLIl.js → agent-DZVGHm7H.js} +1 -1
- package/client/dist/assets/agent-Dip4h2YE.js +1 -0
- package/client/dist/assets/agent-Pp-P-n1p.js +1 -0
- package/client/dist/assets/ban-wqfdzoXt.js +1 -0
- package/client/dist/assets/{button-D1xExSTF.js → button-4FS1ZDTp.js} +1 -1
- package/client/dist/assets/chevron-up-6EFqEHBj.js +1 -0
- package/client/dist/assets/chunk-OB3PAWPO-B1EMk45A.js +3 -0
- package/client/dist/assets/circle-x-D2ttKotB.js +1 -0
- package/client/dist/assets/createLucideIcon-DtODIU64.js +1 -0
- package/client/dist/assets/{dialog-CMgps2MY.js → dialog-DtdR05v1.js} +1 -1
- package/client/dist/assets/download-C9wP_42h.js +1 -0
- package/client/dist/assets/external-link-CZ6Q-v1-.js +1 -0
- package/client/dist/assets/file-text-C0blZHLh.js +1 -0
- package/client/dist/assets/{formatDistanceToNow-DZ3VWsHq.js → formatDistanceToNow-NVM6rK3i.js} +1 -1
- package/client/dist/assets/{getTimezoneOffsetInMilliseconds-9JiGlFrx.js → getTimezoneOffsetInMilliseconds-ZHg7WpdH.js} +1 -1
- package/client/dist/assets/git-branch-yf6LE1Bw.js +1 -0
- package/client/dist/assets/index-Culan6y7.js +83 -0
- package/client/dist/assets/index-D1v33giW.css +2 -0
- package/client/dist/assets/jira-api-Bl8xEIpk.js +1 -0
- package/client/dist/assets/jsx-runtime-BbYvbtY8.js +1 -0
- package/client/dist/assets/layers-BCLTgHXO.js +1 -0
- package/client/dist/assets/{lib-C7Mhm-gT.js → lib-CQJT8S6Q.js} +1 -1
- package/client/dist/assets/{lib-CGdyxIWg.js → lib-DWJfei6y.js} +1 -1
- package/client/dist/assets/loader-circle-BqV9xYGf.js +1 -0
- package/client/dist/assets/{loop-layout-BF8xMiNv.js → loop-layout-CyXj9223.js} +1 -1
- package/client/dist/assets/pencil-CxrRbDwb.js +1 -0
- package/client/dist/assets/plus-fHDdjBk1.js +1 -0
- package/client/dist/assets/{project-repositories-CadLZOnr.js → project-repositories-CvJf1a6H.js} +1 -1
- package/client/dist/assets/react-dom-DDD8FYaU.js +1 -0
- package/client/dist/assets/rotate-ccw-DalJAQQX.js +1 -0
- package/client/dist/assets/save-LmPSfsvZ.js +1 -0
- package/client/dist/assets/search-BDVp3fkH.js +1 -0
- package/client/dist/assets/{settings-Dn-pXukr.js → settings-BO2N-oPf.js} +1 -1
- package/client/dist/assets/{settings-ByVE7jdZ.js → settings-BQChAs_w.js} +1 -1
- package/client/dist/assets/{settings-BBj_kZaD.js → settings-BzmYlcQB.js} +1 -1
- package/client/dist/assets/{settings-COlH_P33.js → settings-CGjXb6TX.js} +1 -1
- package/client/dist/assets/{settings-D77mC_Lb.js → settings-CMxEWY46.js} +1 -1
- package/client/dist/assets/{settings-DZKy7MqN.js → settings-C_dRSgI2.js} +1 -1
- package/client/dist/assets/{settings-B5Hy_Kol.js → settings-Hw7av-B1.js} +1 -1
- package/client/dist/assets/settings-nryN6wuS.js +1 -0
- package/client/dist/assets/sparkles-CCfUdFGY.js +1 -0
- package/client/dist/assets/spending-BfjSJjBd.js +1 -0
- package/client/dist/assets/square-D0JTbRSR.js +1 -0
- package/client/dist/assets/trash-D8zYUmTg.js +1 -0
- package/client/dist/assets/triangle-alert-Cxpn8bqr.js +1 -0
- package/client/dist/assets/upload-CCHvUkRs.js +1 -0
- package/client/dist/assets/{useDesktop-DKNbOF0u.js → useDesktop-C5JVBeur.js} +1 -1
- package/client/dist/assets/{useRuntimeRuns-D3YMw9qx.js → useRuntimeRuns-DohBmeg8.js} +1 -1
- package/client/dist/assets/useSharedWebSocket-CNOvmgTr.js +2 -0
- package/client/dist/assets/{value-s-gzBeyF.js → value-DtOOK0wQ.js} +1 -1
- package/client/dist/assets/x-Bu7X_eR2.js +1 -0
- package/client/dist/assets/zap-bugHyWzQ.js +1 -0
- package/client/dist/index.html +44 -41
- package/docs/ci-cd.md +8 -1
- package/docs/customizing.md +1 -0
- package/docs/getting-started.md +1 -1
- package/docs/guide/de/integrations/6-agent-chat.md +11 -0
- package/docs/guide/de/settings/5-project-environment.md +27 -0
- package/docs/guide/en/integrations/6-agent-chat.md +11 -0
- package/docs/guide/en/settings/5-project-environment.md +27 -0
- package/docs/guide/es/integrations/6-agent-chat.md +11 -0
- package/docs/guide/es/settings/5-project-environment.md +27 -0
- package/docs/guide/fr/integrations/6-agent-chat.md +11 -0
- package/docs/guide/fr/settings/5-project-environment.md +27 -0
- package/docs/guide/it/integrations/6-agent-chat.md +11 -0
- package/docs/guide/it/settings/5-project-environment.md +27 -0
- package/docs/guide/ja/integrations/6-agent-chat.md +11 -0
- package/docs/guide/ja/settings/5-project-environment.md +27 -0
- package/docs/guide/pt/integrations/6-agent-chat.md +11 -0
- package/docs/guide/pt/settings/5-project-environment.md +27 -0
- package/docs/guide/zh/integrations/6-agent-chat.md +11 -0
- package/docs/guide/zh/settings/5-project-environment.md +27 -0
- package/docs/internals/README.md +1 -0
- package/docs/internals/agent-sessions.md +157 -0
- package/docs/internals/api-reference.md +35 -4
- package/docs/internals/configuration.md +80 -5
- package/docs/internals/core-runtime-updates.md +10 -3
- package/docs/internals/operations-runbook.md +11 -0
- package/docs/internals/programmatic-agent-runtime.md +1 -1
- package/docs/internals/safe-pr-review-flow.md +15 -0
- package/docs/internals/source-map.md +42 -1
- package/docs/mcp.md +1 -1
- package/docs/platforms/macos.md +2 -0
- package/docs/platforms/windows-parity.md +4 -4
- package/docs/platforms/windows.md +9 -9
- package/local-runner/dist/specrails-local-runner.js +1 -1
- package/mcp-bridge/dist/specrails-mcp.js +82 -15
- package/package.json +8 -9
- package/server/dist/agent-mcp-config.js +41 -0
- package/server/dist/core-compat.js +2 -0
- package/server/dist/desktop-db.js +101 -4
- package/server/dist/desktop-router.js +31 -2
- package/server/dist/index.js +58 -0
- package/server/dist/mcp/tools/app-settings.js +11 -0
- package/server/dist/mcp/tools/env.js +38 -3
- package/server/dist/mcp/tools/mission.js +45 -2
- package/server/dist/mcp/tools/specs.js +2 -2
- package/server/dist/modules/accounting/runtime/result-event.js +9 -1
- package/server/dist/modules/agent-runtime/runtime/agent-runtime-controls.js +25 -0
- package/server/dist/modules/agent-sessions/adapters/host-process.js +73 -0
- package/server/dist/modules/agent-sessions/adapters/http.js +31 -0
- package/server/dist/modules/agent-sessions/adapters/rpc-client.js +147 -0
- package/server/dist/modules/agent-sessions/application/session-event-pump.js +99 -0
- package/server/dist/modules/agent-sessions/domain/availability.js +25 -0
- package/server/dist/modules/agent-sessions/domain/errors.js +23 -0
- package/server/dist/modules/agent-sessions/domain/host-state.js +80 -0
- package/server/dist/modules/agent-sessions/domain/projection.js +147 -0
- package/server/dist/modules/agent-sessions/domain/protocol.js +59 -0
- package/server/dist/modules/agent-sessions/domain/subagent-policy.js +34 -0
- package/server/dist/modules/agent-sessions/index.js +31 -0
- package/server/dist/modules/agent-sessions/ports.js +2 -0
- package/server/dist/modules/agent-sessions/runtime/core-sessions-availability.js +43 -0
- package/server/dist/modules/agent-sessions/runtime/session-host-registry.js +226 -0
- package/server/dist/modules/agents/runtime/agent-store.js +3 -1
- package/server/dist/modules/execution/runtime/queue-manager.js +8 -0
- package/server/dist/modules/loops/runtime/loop-executors.js +1 -0
- package/server/dist/modules/loops/runtime/loop-implement-recipe.js +15 -4
- package/server/dist/modules/loops/runtime/loop-run-manager.js +11 -0
- package/server/dist/modules/missions/runtime/agent-chat-manager.js +137 -40
- package/server/dist/modules/missions/runtime/agent-chat-router.js +68 -0
- package/server/dist/modules/missions/runtime/agent-operator-prompt.js +8 -9
- package/server/dist/modules/missions/runtime/agent-session-store.js +133 -0
- package/server/dist/modules/missions/runtime/core-session-runner.js +204 -0
- package/server/dist/modules/missions/runtime/mission-core-sessions.js +286 -0
- package/server/dist/modules/missions/runtime/mission-session-projector.js +168 -0
- package/server/dist/modules/project-settings/adapters/http.js +38 -2
- package/server/dist/modules/project-settings/adapters/sqlite.js +30 -2
- package/server/dist/modules/project-settings/domain.js +24 -0
- package/server/dist/modules/project-settings/index.js +2 -1
- package/server/dist/modules/specs/runtime/spec-models.js +1 -1
- package/server/dist/path-resolver.js +135 -20
- package/server/dist/plugins/codex-spawn.js +15 -7
- package/server/dist/project-env.js +265 -17
- package/server/dist/project-registry.js +46 -0
- package/server/dist/project-router-settings.js +24 -1
- package/server/dist/providers/claude-adapter.js +6 -1
- package/server/dist/worktree-node-modules.js +95 -1
- package/client/dist/assets/ActivityFeedPage-Wi5XNgoG.js +0 -1
- package/client/dist/assets/AgentModeAnalyticsPane-CXz2j-Bt.js +0 -2
- package/client/dist/assets/AgentModeCodePane-DnsBPtpS.js +0 -2
- package/client/dist/assets/AgentsPage-CXrqu5vo.js +0 -118
- package/client/dist/assets/AnalyticsPage-Cvtt-LOO.js +0 -1
- package/client/dist/assets/BarChart-nBOMNfiy.js +0 -33
- package/client/dist/assets/CodePage-D35o-MFO.js +0 -3
- package/client/dist/assets/DesktopAnalyticsPage-CsDFy5rp.js +0 -1
- package/client/dist/assets/IntegrationsPage-Bhy58lnQ.js +0 -1
- package/client/dist/assets/InteractiveJobComposer-CFKvbQeJ.js +0 -19
- package/client/dist/assets/JobDetailPage-C6gpdYvj.js +0 -1
- package/client/dist/assets/JobsPage-CgS0pnKd.js +0 -1
- package/client/dist/assets/LoopBuilderPage-jUp20DSZ.js +0 -1
- package/client/dist/assets/LoopsPage-ClSrWzDd.js +0 -2
- package/client/dist/assets/MinimizedChatsContext-CroAs6Kh.js +0 -1
- package/client/dist/assets/PluginsPage-nCKQOwRL.js +0 -2
- package/client/dist/assets/ProjectSettingsDialog-BVDYwllU.js +0 -1
- package/client/dist/assets/RepositoryDeliveries-DJCm1pZr.js +0 -5
- package/client/dist/assets/ReviewPacketPage-kTErrEjx.js +0 -4
- package/client/dist/assets/TicketDetailModalContext-YBJX3RmP.js +0 -16
- package/client/dist/assets/Trans-D5eOjfvG.js +0 -1
- package/client/dist/assets/agent--8QAfoXL.js +0 -1
- package/client/dist/assets/agent-3HxXkIWX.js +0 -1
- package/client/dist/assets/agent-CpFCz32T.js +0 -1
- package/client/dist/assets/agent-DVnw6ybO.js +0 -1
- package/client/dist/assets/agent-Z5s_GTP0.js +0 -1
- package/client/dist/assets/agent-hv57-zyG.js +0 -1
- package/client/dist/assets/agent-xGrZ_aN1.js +0 -1
- package/client/dist/assets/chunk-KS7C4IRE-DEKu087k.js +0 -3
- package/client/dist/assets/circle-x-CMYsN4ZH.js +0 -1
- package/client/dist/assets/createLucideIcon-Bjbbp_KS.js +0 -1
- package/client/dist/assets/download-CFHyyHcw.js +0 -1
- package/client/dist/assets/external-link-D6XxC_Cu.js +0 -1
- package/client/dist/assets/file-text-BcLCfcWZ.js +0 -1
- package/client/dist/assets/git-branch-BRM0F5GN.js +0 -1
- package/client/dist/assets/index-Bfunvi6w.css +0 -2
- package/client/dist/assets/index-lTGJJTuk.js +0 -83
- package/client/dist/assets/jira-api-Bp0zXwjg.js +0 -1
- package/client/dist/assets/jsx-runtime-zu2_FqZY.js +0 -1
- package/client/dist/assets/loader-circle-DcygOQpC.js +0 -1
- package/client/dist/assets/pencil-C9RkrIPZ.js +0 -1
- package/client/dist/assets/plus-CsnjfkmX.js +0 -1
- package/client/dist/assets/react-dom-DiWzBDP9.js +0 -1
- package/client/dist/assets/rotate-ccw-Wh4id13q.js +0 -1
- package/client/dist/assets/save-OsUqVn99.js +0 -1
- package/client/dist/assets/search-Cq_gE3Ik.js +0 -1
- package/client/dist/assets/settings-Dbyd6gmj.js +0 -1
- package/client/dist/assets/sparkles-DrY8hb0X.js +0 -1
- package/client/dist/assets/spending-DQDNtM8q.js +0 -1
- package/client/dist/assets/square-Ci-PFcFe.js +0 -1
- package/client/dist/assets/trash-2-BOU3WdZZ.js +0 -1
- package/client/dist/assets/triangle-alert-H9T4jAmh.js +0 -1
- package/client/dist/assets/upload-DYMjAQ6M.js +0 -1
- package/client/dist/assets/useSharedWebSocket-DaWuiO0S.js +0 -2
- package/client/dist/assets/x-CBMI9ejn.js +0 -1
- package/client/dist/assets/zap-CUOlvtT1.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{r}from"./useDesktop-C5JVBeur.js";import i from"./LoopsPage-CCwc0Biu.js";import a from"./LoopBuilderPage-5M7IypEP.js";var o=e(t(),1),s=n();function c(){let{projects:e,isLoading:t,setActiveProjectId:n}=r(),[c,l]=(0,o.useState)(()=>new URLSearchParams(window.location.search).get(`loopId`)),u=(0,o.useRef)(!1),d=new URLSearchParams(window.location.search).get(`projectId`);return(0,o.useEffect)(()=>{!t&&!u.current&&(u.current=!0,n(e.some(e=>e.id===d)?d:null))},[t,d,e,n]),(0,s.jsx)(`div`,{className:`flex-1 min-h-0 bg-background`,children:c?(0,s.jsx)(a,{loopId:c,onExit:()=>l(null)},c):(0,s.jsx)(i,{onOpenBuilder:l})})}export{c as LoopWindowSurface};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{u as r}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as i,t as a}from"./createLucideIcon-DtODIU64.js";import{n as o,r as s,s as c}from"./useDesktop-C5JVBeur.js";import{_ as l,s as u,t as d,u as f}from"./provider-capabilities-lePfeT_Y.js";import{t as p}from"./download-C9wP_42h.js";import{t as m}from"./external-link-CZ6Q-v1-.js";import{t as h}from"./pencil-CxrRbDwb.js";import{n as g}from"./square-D0JTbRSR.js";import{t as _}from"./plus-fHDdjBk1.js";import{t as v}from"./rotate-ccw-DalJAQQX.js";import{t as y}from"./sparkles-CCfUdFGY.js";import{t as b}from"./trash-D8zYUmTg.js";import{t as x}from"./upload-CCHvUkRs.js";import{a as S,i as C,l as w,o as T,r as E,t as D}from"./dialog-DtdR05v1.js";import{t as O}from"./utils-BC4DHlz2.js";import{t as k}from"./button-4FS1ZDTp.js";import{t as ee}from"./RepositoryScopeSelector-BSgUqk_u.js";import{Gt as A,Q as j,Wt as M,Z as N,at as P,cn as te,it as F,mt as I,ot as ne,rt as L,sn as re,st as R}from"./index-Culan6y7.js";import{n as ie}from"./TemplatePreviewModal-CcfSxWQ7.js";var z={name:`file-down`,size:24,node:[[`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`}]]};z.node;var ae=a(z),B={name:`file-up`,size:24,node:[[`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`}]]};B.node;var oe=a(B),V=e(t(),1),H=n(),U=[`invalid`,`needs_attention`,`convertible`,`running`,`current`];function se({onConvert:e}){let{t}=i(`loops`),[n,r]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(``),l=(0,V.useRef)(!0);(0,V.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]);async function u(){o(!0),c(``),r(null);try{let e=await P.migration();l.current&&r(e)}catch(e){l.current&&c(e instanceof Error&&e.message?e.message:t(`migration.failed`))}finally{l.current&&o(!1)}}let d=n?n.loops.filter(e=>e.state!==`current`):[];return(0,H.jsxs)(`section`,{className:`rounded-lg border border-border p-3 space-y-2`,"aria-label":t(`migration.title`),children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:t(`migration.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`migration.description`)})]}),(0,H.jsx)(k,{size:`sm`,variant:`secondary`,disabled:a,onClick:()=>void u(),children:t(a?`migration.checking`:`migration.check`)})]}),s&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:s}),n&&(0,H.jsxs)(`div`,{role:`status`,className:`space-y-2 text-xs`,children:[(0,H.jsx)(`p`,{children:U.filter(e=>n.summary[e]>0).map(e=>t(`migration.states.${e}`)+`: `+n.summary[e]).join(` · `)||t(`migration.empty`)}),d.length===0&&n.loops.length>0&&(0,H.jsx)(`p`,{className:`text-muted-foreground`,children:t(`migration.allCurrent`)}),(0,H.jsx)(`ul`,{className:`space-y-1`,children:d.map(n=>(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:n.name}),(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[t(`migration.states.${n.state}`),n.status===`published`?` · ${t(`status.published`)}`:``]}),n.issues.slice(0,3).map((e,t)=>(0,H.jsx)(`span`,{className:`text-destructive`,children:e.message},t)),n.state===`convertible`&&(0,H.jsx)(k,{size:`sm`,variant:`ghost`,onClick:()=>e(n.id),children:t(`actions.convert`)})]},n.id))})]})]})}function ce(e){return{specrailsLoops:1,loops:e.map(e=>({name:e.name,description:e.description,graph:e.graph}))}}function W(e){let t=e;return!!t&&typeof t.name==`string`&&!!t.graph&&typeof t.graph==`object`}function le(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:W(t)?[t]:[]).filter(W);if(n.length===0)throw Error(`no-loops`);return n.map(e=>({name:e.name,description:e.description??null,graph:e.graph}))}function ue(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 G=[`API`,`Automation`,`CI`,`Database`,`Debugging`,`DevOps`,`Docs`,`Git`,`Maintenance`,`Performance`,`Planning`,`Quality`,`Review`,`Security`,`Testing`];function de(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 fe(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 G){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}function pe({loop:e,projects:t,onClose:n,onExecute:r}){let{t:a}=i(`loops`),o=e!==null,[s,c]=(0,V.useState)(``),[p,m]=(0,V.useState)(``),[h,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(),O=t.find(e=>e.id===(s||t[0]?.id)),A=(0,V.useMemo)(()=>O?.providers??(O?.provider?[O.provider]:[]),[O]),M=p||A[0]||``,P=(0,V.useMemo)(()=>R(M),[M]),te=f(M),F=h&&(P.some(e=>e.value===h)||te&&j(h))?h:ne(M),I=l(M,F),L=I.includes(v)?v:d(M,F)??``,re=I.length>0;return(0,H.jsx)(D,{open:o,onOpenChange:e=>{e||n()},children:(0,H.jsx)(E,{movableResizable:!0,className:`max-w-sm`,children:e&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(T,{children:[(0,H.jsx)(w,{children:a(`run.title`,{name:e.name})}),(0,H.jsx)(C,{children:a(`run.subtitle`)})]}),(0,H.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.project`)}),t.length===0?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`run.noProjects`)}):(0,H.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(``),x(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,H.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,H.jsx)(ee,{repositories:O?.repositories??[],value:b,onChange:x}),A.length>1&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.provider`)}),(0,H.jsx)(`select`,{"aria-label":a(`run.provider`),value:M,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:A.map(e=>(0,H.jsx)(`option`,{value:e,children:u(e)},e))})]}),P.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.model`)}),te?(0,H.jsx)(N,{value:F,options:P,ariaLabel:a(`run.model`),testId:`run-model-select`,className:`w-full px-2 py-1 text-xs`,onCommit:e=>{_(e),y(d(M,e)??``)}}):(0,H.jsx)(`select`,{"aria-label":a(`run.model`),"data-testid":`run-model-select`,value:F,onChange:e=>{let t=e.target.value;_(t),y(d(M,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:P.map(e=>(0,H.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),re&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.effort`)}),(0,H.jsx)(`select`,{"aria-label":a(`run.effort`),value:L,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:I.map(e=>(0,H.jsx)(`option`,{value:e,children:e},e))})]}),(0,H.jsxs)(S,{children:[(0,H.jsx)(k,{variant:`ghost`,onClick:n,children:a(`common:actions.cancel`)}),(0,H.jsxs)(k,{onClick:()=>{let e=s||t[0]?.id;e&&r({projectId:e,...b?{repositoryIds:b}:{},provider:A.length>1?M:void 0,model:P.length>0?F:void 0,effort:re?L:void 0})},disabled:t.length===0,children:[(0,H.jsx)(g,{className:`w-3.5 h-3.5 mr-1.5`}),a(`run.execute`)]})]})]})})})}function me({loop:e,projects:t,onClose:n,onConverted:r}){let{t:a}=i(`loops`),[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(``),f=e.graph.nodes.some(e=>e.type===`shell`&&!e.data?.repositoryId),p=t.flatMap(e=>(e.repositories??[]).map(t=>({key:JSON.stringify([e.id,t.id]),id:t.id,label:`${e.name} / ${t.name}`}))),m=p.find(e=>e.key===o);async function h(){l(!0),d(``);try{r((await P.convert(e.id,m?.id)).loop)}catch(e){d(e instanceof F?e.errors.map(e=>`${e.nodeId?e.nodeId+`: `:``}${e.message}`).join(`
|
|
2
|
+
`):e instanceof Error&&e.message===`engine_unsupported`?a(`conversion.coreRequired`):e instanceof Error?a(`conversion.error`)+`: `+e.message:a(`conversion.error`))}finally{l(!1)}}return(0,H.jsx)(D,{open:!0,onOpenChange:e=>{!e&&!c&&n()},children:(0,H.jsxs)(E,{children:[(0,H.jsxs)(T,{children:[(0,H.jsx)(w,{children:a(`conversion.title`,{name:e.name})}),(0,H.jsx)(C,{children:a(`conversion.description`)})]}),f&&(0,H.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[a(`conversion.repository`),(0,H.jsxs)(`select`,{className:`rounded border border-border bg-background p-2`,value:o,onChange:e=>s(e.target.value),disabled:c,children:[(0,H.jsx)(`option`,{value:``,children:a(`conversion.selectRepository`)}),p.map(e=>(0,H.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]}),u&&(0,H.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap text-sm text-destructive`,children:u}),(0,H.jsxs)(S,{children:[(0,H.jsx)(k,{variant:`outline`,disabled:c,onClick:n,children:a(`common:actions.cancel`)}),(0,H.jsx)(k,{disabled:c||f&&!m,onClick:()=>void h(),children:a(c?`conversion.pending`:`conversion.submit`)})]})]})})}var K={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 q({status:e}){let{t}=i(`loops`);return(0,H.jsx)(`span`,{className:O(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ring-1 ring-inset`,K[e]),children:t(`status.${e}`)})}function he({onOpenBuilder:e,onWindowOpened:t}={}){let{t:n}=i(`loops`),a=r(),l=(0,V.useCallback)(e=>e.replace(/:/g,`_`),[]),u=(0,V.useCallback)((e,t)=>n(`catalog.${l(e)}.name`,{defaultValue:t}),[n,l]),d=(0,V.useCallback)((e,t)=>n(`catalog.${l(e)}.description`,{defaultValue:t}),[n,l]),[f,h]=(0,V.useState)([]),[g,x]=(0,V.useState)([]),[ee,A]=(0,V.useState)(!0),[j,N]=(0,V.useState)(null),[ne,R]=(0,V.useState)(null),[z,B]=(0,V.useState)(null),[U,W]=(0,V.useState)(null),[G,K]=(0,V.useState)(null),[q,he]=(0,V.useState)(new Set),J=`specrails-desktop:loop-template-filter`,ve=(()=>{try{let e=localStorage.getItem(J),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:[]}}})(),[Y,ye]=(0,V.useState)(ve.query),[X,be]=(0,V.useState)(ve.categories);(0,V.useEffect)(()=>{try{localStorage.setItem(J,JSON.stringify({query:Y,categories:X}))}catch{}},[Y,X]);let xe=(0,V.useCallback)(e=>{be(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),Se=(0,V.useCallback)(()=>{ye(``),be([])},[]),Ce=(0,V.useRef)(null),{projects:we,activeProjectId:Te,setActiveProjectId:Ee}=s(),De=(0,V.useCallback)(e=>{he(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Z=(0,V.useCallback)(e=>{if(e.length===0)return;let t=new Blob([JSON.stringify(ce(e),null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=ue(e),r.click(),URL.revokeObjectURL(n)},[]),Oe=(0,V.useCallback)(async e=>{try{let t=await P.legacyGraph(e.id);Z([{...e,name:n(`actions.originalCopyName`,{name:e.name}),graph:t.graph}])}catch{c.error(n(`errors.exportLegacy`))}},[Z,n]),Q=(0,V.useCallback)(async()=>{try{let[e,t]=await Promise.all([P.list(),P.templates()]);h(e),x(t)}catch{c.error(n(`errors.load`))}finally{A(!1)}},[n]);(0,V.useEffect)(()=>{Q()},[Q]);let ke=(0,V.useCallback)(async e=>{try{let t=le(await e.text()),{imported:r,skipped:i}=await P.importLoops(t);await Q(),r.length&&c.success(n(`import.done`,{count:r.length})),i.length&&c.warning(n(`import.skipped`,{count:i.length,names:i.join(`, `)})),!r.length&&!i.length&&c.warning(n(`import.invalid`))}catch(e){let t=e instanceof Error?e.message:``;c.error(n(t===`invalid-json`||t===`no-loops`?`import.invalid`:`errors.save`))}},[Q,n]),$=(0,V.useCallback)(t=>{e?e(t):a(`/loops/${t}/edit`)},[e,a]),Ae=(0,V.useCallback)(async()=>{try{let e=await P.create({name:n(`newLoopName`)});$(e.id)}catch{c.error(n(`errors.save`))}},[n,$]),je=(0,V.useCallback)(async e=>{try{let t=await P.fromTemplate(e);$(t.id)}catch{c.error(n(`errors.save`))}},[n,$]),Me=(0,V.useCallback)(async({projectId:e,provider:t,model:r,effort:i,repositoryIds:o})=>{let s=U;if(s){W(null);try{let{loopRunId:l}=await P.runStandalone(e,s.id,{aiEngine:t,model:r,reasoning_effort:i,...o?{repositoryIds:o}:{}});Ee(e),a(`/jobs/${l}`),c.success(n(`run.launched`,{name:s.name}))}catch{c.error(n(`errors.save`))}}},[U,a,Ee,n]),Ne=(0,V.useCallback)(async e=>{try{await P.publish(e),await Q()}catch(e){e instanceof F?c.error(n(`errors.publishInvalid`)):c.error(n(`errors.save`))}},[n,Q]),Pe=(0,V.useCallback)(async e=>{try{await P.unpublish(e),await Q()}catch{c.error(n(`errors.save`))}},[n,Q]),Fe=(0,V.useCallback)(async e=>{try{await P.duplicate(e),await Q()}catch{c.error(n(`errors.save`))}},[n,Q]),Ie=(0,V.useCallback)(async()=>{let e=z;if(e){B(null);try{await P.restoreBuiltin(e),await Q(),c.success(n(`builder.builtin.restored`))}catch{c.error(n(`errors.save`))}}},[z,n,Q]),Le=(0,V.useCallback)(e=>N(e),[]),Re=(0,V.useCallback)(async()=>{let e=j;if(e){N(null);try{await P.remove(e),await Q()}catch{c.error(n(`errors.save`))}}},[j,n,Q]),ze=f.filter(e=>e.builtinId),Be=f.filter(e=>!e.builtinId),Ve=Be.filter(e=>e.status===`draft`),He=Be.filter(e=>e.status===`published`),Ue=fe(g),We=de(g.map(e=>({...e,searchTerms:`${u(e.id,e.name)} ${d(e.id,e.description)} ${e.category?n(`categories.${e.category}`,{defaultValue:e.category}):``}`})),{query:Y,categories:X}),Ge=Y.trim()!==``||X.length>0;return(0,H.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[(0,H.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 py-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,H.jsx)(I,{className:`w-5 h-5 text-accent-primary`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:n(`title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:n(`subtitle`)})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!re()&&(0,H.jsxs)(`button`,{type:`button`,onClick:()=>void te(Te).then(()=>t?.()).catch(e=>c.error(String(e))),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs border border-border hover:bg-muted`,children:[(0,H.jsx)(m,{className:`w-3.5 h-3.5`}),n(`window.open`)]}),q.size>0&&(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Z(f.filter(e=>q.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,H.jsx)(ae,{className:`w-3.5 h-3.5`}),n(`actions.export`),` (`,q.size,`)`]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Ce.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,H.jsx)(oe,{className:`w-3.5 h-3.5`}),n(`actions.import`)]}),(0,H.jsx)(`input`,{ref:Ce,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&ke(t),e.target.value=``}}),(0,H.jsxs)(`button`,{type:`button`,onClick:Ae,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,H.jsx)(_,{className:`w-3.5 h-3.5`}),n(`newLoop`)]})]})]}),ee?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`…`}):(0,H.jsxs)(`div`,{className:`space-y-8`,children:[Ve.length===0&&He.length===0&&(0,H.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:n(`empty.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:n(`empty.body`)})]}),f.length>0&&(0,H.jsx)(se,{onConvert:e=>{let t=f.find(t=>t.id===e);t&&K(t)}}),He.length>0&&(0,H.jsx)(ge,{title:n(`sections.published`),children:He.map(e=>(0,H.jsx)(_e,{loop:e,selected:q.has(e.id),onToggleSelect:()=>De(e.id),onEdit:()=>$(e.id),onUnpublish:()=>Pe(e.id),onDuplicate:()=>Fe(e.id),onExport:()=>Z([e]),onExportLegacy:e.hasLegacyGraph?()=>void Oe(e):void 0,onConvert:e.graph.nodes.some(e=>e.type===`core`)?void 0:()=>K(e),onDelete:()=>Le(e.id),onRun:L(e.graph)?void 0:()=>W(e)},e.id))}),Ve.length>0&&(0,H.jsx)(ge,{title:n(`sections.drafts`),children:Ve.map(e=>(0,H.jsx)(_e,{loop:e,selected:q.has(e.id),onToggleSelect:()=>De(e.id),onEdit:()=>$(e.id),onPublish:()=>Ne(e.id),onDuplicate:()=>Fe(e.id),onExport:()=>Z([e]),onExportLegacy:e.hasLegacyGraph?()=>void Oe(e):void 0,onConvert:e.graph.nodes.some(e=>e.type===`core`)?void 0:()=>K(e),onDelete:()=>Le(e.id)},e.id))}),ze.length>0&&(0,H.jsx)(ge,{title:n(`sections.builtIn`),children:ze.map(e=>(0,H.jsx)(_e,{loop:{...e,name:e.builtinModified?e.name:u(e.id,e.name)},builtIn:!0,selected:q.has(e.id),onToggleSelect:()=>De(e.id),onEdit:()=>$(e.id),onPublish:e.status===`draft`?()=>Ne(e.id):void 0,onDuplicate:()=>Fe(e.id),onExport:()=>Z([e]),onRestore:e.builtinModified?()=>B(e.id):void 0},e.id))}),g.length>0&&(0,H.jsxs)(`section`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,H.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`sections.templates`)}),(0,H.jsx)(`input`,{type:`search`,value:Y,onChange:e=>ye(e.target.value),placeholder:n(`gallery.search`),"aria-label":n(`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,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3`,"data-testid":`category-chips`,children:[Ue.map(({category:e,count:t})=>{let r=X.includes(e);return(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>xe(e),className:O(`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:[n(`categories.${e}`,{defaultValue:e}),(0,H.jsx)(`span`,{className:`opacity-60 tabular-nums`,children:t})]},e)}),Ge&&(0,H.jsx)(`button`,{type:`button`,onClick:Se,className:`inline-flex items-center h-6 px-2 rounded-full text-[11px] text-accent-primary hover:underline`,children:n(`gallery.clearFilter`)})]}),We.length===0?(0,H.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,"data-testid":`template-empty`,children:[(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`gallery.noResults`)}),(0,H.jsx)(`button`,{type:`button`,onClick:Se,className:`mt-2 text-xs text-accent-primary hover:underline`,children:n(`gallery.clearFilter`)})]}):(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:We.map(e=>(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`template-card`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(y,{className:`w-3.5 h-3.5 text-accent-highlight flex-shrink-0`}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:u(e.id,e.name)}),e.category&&(0,H.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:n(`categories.${e.category}`,{defaultValue:e.category})})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:d(e.id,e.description)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[L(e.graph)?(0,H.jsx)(`span`,{title:n(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:n(`gallery.needsSpec`)}):(0,H.jsx)(`span`,{title:n(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:n(`gallery.standalone`)}),e.tags.map(e=>(0,H.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>R({...e,name:u(e.id,e.name),description:d(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,H.jsx)(M,{className:`w-3 h-3`}),n(`actions.preview`)]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>je(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,H.jsx)(p,{className:`w-3 h-3`}),n(`actions.use`)]})]})]},e.id))})]})]})]}),(0,H.jsx)(D,{open:j!==null,onOpenChange:e=>{e||N(null)},children:(0,H.jsxs)(E,{className:`max-w-sm`,children:[(0,H.jsxs)(T,{children:[(0,H.jsxs)(w,{className:`flex items-center gap-2`,children:[(0,H.jsx)(b,{className:`w-4 h-4 text-destructive`}),f.find(e=>e.id===j)?.name??n(`actions.delete`)]}),(0,H.jsx)(C,{children:n(`confirmDelete`)})]}),(0,H.jsxs)(S,{children:[(0,H.jsx)(k,{variant:`ghost`,onClick:()=>N(null),children:n(`common:actions.cancel`)}),(0,H.jsx)(k,{variant:`destructive`,onClick:()=>void Re(),children:n(`common:actions.delete`)})]})]})}),(0,H.jsx)(D,{open:z!==null,onOpenChange:e=>{e||B(null)},children:(0,H.jsxs)(E,{className:`max-w-sm`,children:[(0,H.jsxs)(T,{children:[(0,H.jsxs)(w,{className:`flex items-center gap-2`,children:[(0,H.jsx)(v,{className:`w-4 h-4`}),n(`builder.builtin.confirmTitle`)]}),(0,H.jsx)(C,{children:n(`builder.builtin.confirmBody`)})]}),(0,H.jsxs)(S,{children:[(0,H.jsx)(k,{variant:`ghost`,onClick:()=>B(null),children:n(`common:actions.cancel`)}),(0,H.jsx)(k,{"data-testid":`confirm-restore-builtin`,onClick:()=>void Ie(),children:n(`actions.restoreBuiltin`)})]})]})}),(0,H.jsx)(ie,{template:ne,onClose:()=>R(null),onUse:e=>{R(null),je(e)}}),G&&(0,H.jsx)(me,{loop:G,projects:we,onClose:()=>K(null),onConverted:e=>{h(t=>t.map(t=>t.id===e.id?e:t)),K(null),$(e.id)}},G.id),(0,H.jsx)(pe,{loop:U?{id:U.id,name:U.name}:null,projects:we.map(e=>({id:e.id,name:e.name,providers:o(e),repositories:e.repositories})),onClose:()=>W(null),onExecute:Me})]})}function ge({title:e,children:t}){return(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2`,children:e}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t})]})}function _e({loop:e,builtIn:t=!1,selected:n,onToggleSelect:r,onEdit:a,onPublish:o,onUnpublish:s,onDuplicate:c,onExport:l,onExportLegacy:u,onConvert:d,onDelete:f,onRun:m,onRestore:_}){let{t:y}=i(`loops`),S=e.graph?.nodes?.length??0;return(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":t?`builtin-loop-card`:`loop-card`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:r,"aria-label":y(`actions.select`,{name:e.name}),className:`accent-accent-primary flex-shrink-0`}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.name})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[t&&(0,H.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,"data-testid":`builtin-badge`,children:y(`builtInBadge`)}),(0,H.jsx)(q,{status:e.status})]})]}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[y(`card.nodes`,{count:S}),t&&e.builtinModified&&(0,H.jsxs)(`span`,{className:`ml-1.5 text-accent-secondary`,children:[`· `,y(`card.builtinModified`)]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[m&&(0,H.jsx)(J,{icon:g,label:y(`actions.run`),onClick:m}),(0,H.jsx)(J,{icon:h,label:y(`actions.edit`),onClick:a}),o&&(0,H.jsx)(J,{icon:x,label:y(`actions.publish`),onClick:o}),s&&(0,H.jsx)(J,{icon:p,label:y(`actions.unpublish`),onClick:s}),(0,H.jsx)(J,{icon:A,label:y(`actions.duplicate`),onClick:c}),(0,H.jsx)(J,{icon:ae,label:y(`actions.export`),onClick:l}),u&&(0,H.jsx)(J,{icon:ae,label:y(`actions.exportLegacy`),onClick:u}),d&&(0,H.jsx)(J,{icon:I,label:y(`actions.convert`),onClick:d}),_&&(0,H.jsx)(J,{icon:v,label:y(`actions.restoreBuiltin`),onClick:_}),f&&(0,H.jsx)(J,{icon:b,label:y(`actions.delete`),onClick:f,danger:!0})]})]})}function J({icon:e,label:t,onClick:n,danger:r}){return(0,H.jsx)(`button`,{type:`button`,onClick:n,title:t,"aria-label":t,className:O(`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,H.jsx)(e,{className:`w-3.5 h-3.5`})})}export{he as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{t as r}from"./react-dom-DDD8FYaU.js";import{u as i}from"./chunk-OB3PAWPO-B1EMk45A.js";import{r as a}from"./useSharedWebSocket-CNOvmgTr.js";import{n as o,t as s}from"./createLucideIcon-DtODIU64.js";import{r as c}from"./useDesktop-C5JVBeur.js";import{t as l}from"./chevron-up-6EFqEHBj.js";import{t as u}from"./sparkles-CCfUdFGY.js";import{t as d}from"./x-Bu7X_eR2.js";var f={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};f.node;var p=s(f),m={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};m.node;var h=s(m),g=e(t(),1),_=[`title`,`description`,`labels`,`priority`,`acceptanceCriteria`,`repositoryIds`],v={title:``,description:``,labels:[],priority:`medium`,acceptanceCriteria:[]};function y(e){return!e||typeof e!=`object`?!1:e.type===`spec_draft.update`}var b=e(r(),1),x=n(),S=42;function C(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=S?t:t.slice(0,S-1).trimEnd()+`…`}function w({chat:e,projectName:t,onRestore:n,onClose:r}){let{t:i}=o(`chat`),a=C(e.label);return(0,x.jsxs)(`div`,{"data-testid":`minimized-chat-chip-${e.id}`,className:`grid items-start gap-2 w-full max-w-full`,style:{gridTemplateColumns:`auto minmax(0, 1fr) auto`},children:[(0,x.jsx)(T,{kind:e.kind}),(0,x.jsxs)(`button`,{type:`button`,onClick:n,className:`min-w-0 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50 rounded overflow-hidden`,"aria-label":i(`chip.restore`,{label:e.label}),title:e.label,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-foreground truncate`,children:a}),(0,x.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5 truncate`,children:i(`chip.continueEditing`,{projectName:t})})]}),(0,x.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-6 h-6 rounded text-muted-foreground hover:text-foreground hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50`,"aria-label":i(`chip.close`,{label:e.label}),children:(0,x.jsx)(d,{className:`w-3.5 h-3.5`})})]})}function T({kind:e}){let{t}=o(`chat`);return(0,x.jsx)(e===`ai-edit`?u:h,{className:`w-4 h-4 text-accent-primary flex-shrink-0 mt-0.5`,"aria-label":t(e===`ai-edit`?`chip.kindAiEdit`:`chip.kindExploreSpec`)})}function E({chats:e,projects:t,hidden:n,onRestore:r,onClose:i}){let{t:a}=o(`chat`),s=(0,g.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.id,n.name);return e},[t]),c=(0,g.useMemo)(()=>[...e].sort((e,t)=>t.createdAt-e.createdAt),[e]);return n||c.length===0?null:(0,b.createPortal)((0,x.jsxs)(`div`,{"data-testid":`minimized-chats-dock`,"aria-label":a(`dock.minimizedSessions`,{count:c.length}),className:`fixed bottom-4 right-14 z-[70] flex flex-col-reverse gap-2 w-[320px] max-w-[calc(100vw-15rem)] max-h-[70vh] overflow-y-auto pointer-events-none`,children:[c.map(e=>(0,x.jsx)(`div`,{className:`pointer-events-auto glass-card border border-border/30 rounded-lg p-3 shadow-lg w-full`,children:(0,x.jsx)(w,{chat:e,projectName:s.get(e.projectId)??a(`dock.unknownProject`),onRestore:()=>r(e.id),onClose:()=>i(e.id)})},e.id)),c.length>1&&(0,x.jsxs)(`div`,{className:`pointer-events-auto self-end inline-flex items-center gap-1 rounded-full bg-card/80 border border-border/40 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur-sm`,children:[(0,x.jsx)(l,{className:`w-3 h-3`}),a(`dock.minimizedCount`,{count:c.length})]})]}),document.body)}var D=(0,g.createContext)(null),O=`specrails-desktop:minimized-chats`,k=`specrails-desktop:minimized-chats-pending`,A=50,j=8e3;function M(){return I(O)}function N(e){R(O,e)}function P(){return I(k)}function F(e){R(k,e)}function I(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(z):[]}catch{return[]}}function L(e){return e.length<=A?e:[...e].sort((e,t)=>e.createdAt-t.createdAt).slice(e.length-A)}function R(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(L(t)))}catch{}}function z(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.id!=`string`||typeof t.projectId!=`string`||typeof t.label!=`string`||typeof t.restoreRoute!=`string`||typeof t.createdAt!=`number`||t.kind!==`explore-spec`&&t.kind!==`ai-edit`||!t.params||typeof t.params!=`object`)}function B(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function V(e){return e.kind===`explore-spec`?e.params.resumeConversationId??`pending:${e.params.pendingSpecId}`:e.params.resumeRefineId??`agent:${e.params.agentId}`}function H(e,t){return e.kind!==t.kind||e.projectId!==t.projectId?!1:V(e)===V(t)}function U({children:e}){let{projects:t,activeProjectId:n,setActiveProjectId:r}=c(),o=i(),{registerHandler:s,unregisterHandler:l}=a(),[u,d]=(0,g.useState)(()=>M()),[f,p]=(0,g.useState)([]),m=(0,g.useRef)(u);m.current=u;let h=(0,g.useRef)(f);h.current=f;let _=(0,g.useRef)(new Map),v=(0,g.useRef)(t);v.current=t;let b=(0,g.useRef)(!1);(0,g.useEffect)(()=>{if(b.current)return;b.current=!0;let e=P();F([]),e.length!==0&&d(t=>{let n=[...t];for(let t of e)n.some(e=>e.id===t.id||H(e,t))||n.push(t);return N(n),m.current=n,n})},[]),(0,g.useEffect)(()=>{let e=_.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear()}},[]),(0,g.useEffect)(()=>{N(u)},[u]),(0,g.useEffect)(()=>{F(f)},[f]);let S=(0,g.useRef)(()=>{}),C=(0,g.useRef)(()=>{});(0,g.useEffect)(()=>{let e=`minimized-chats:spec-draft`;return s(e,e=>{if(!y(e))return;let t=e.conversationId,n=m.current.find(e=>e.kind===`explore-spec`&&e.params.resumeConversationId===t);if(!n)return;let r=e.draft;r.title?.trim()&&S.current(n.id,r.title);let i={};r.title!==void 0&&(i.title=r.title),r.description!==void 0&&(i.description=r.description),r.priority!==void 0&&(i.priority=r.priority),r.labels!==void 0&&(i.labels=r.labels),r.repositoryIds!==void 0&&(i.repositoryIds=r.repositoryIds),r.acceptanceCriteria!==void 0&&(i.acceptanceCriteria=r.acceptanceCriteria),Object.keys(i).length>0&&C.current(n.id,i)}),()=>l(e)},[s,l]),(0,g.useEffect)(()=>{if(t.length===0)return;let e=new Set(t.map(e=>e.id));d(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(N(n),m.current=n,n)}),p(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(F(n),h.current=n,n)})},[t]);let w=(0,g.useCallback)(e=>{let t=B(),n={...e,id:t,createdAt:Date.now()};if(d(e=>{let t=L([...e.filter(e=>!H(e,n)),n]);return N(t),m.current=t,t}),e.kind===`explore-spec`){let t=e.params.resumeConversationId;t&&fetch(`/api/projects/${e.projectId}/chat/conversations/${t}/minimize`,{method:`POST`}).catch(()=>{})}return t},[]),T=(0,g.useCallback)(e=>{let t=_.current.get(e);t&&(clearTimeout(t),_.current.delete(e))},[]),O=(0,g.useCallback)(e=>{T(e),d(t=>{let n=t.filter(t=>t.id!==e);return N(n),m.current=n,n}),p(t=>{let n=t.filter(t=>t.id!==e);return n.length===t.length?t:(F(n),h.current=n,n)})},[T]),k=(0,g.useCallback)((e,t)=>{let n=t.trim();n&&d(t=>{let r=t.map(t=>t.id===e&&t.label!==n?{...t,label:n}:t);return r===t?t:(m.current=r,r)})},[]),A=(0,g.useCallback)((e,t)=>{d(n=>{let r=n.map(n=>{if(n.id!==e||n.kind!==`explore-spec`)return n;let r={...n.params.draftOverrides??{},...t};return{...n,params:{...n.params,draftOverrides:r}}});return m.current=r,r})},[]),I=(0,g.useCallback)(e=>{let t=m.current.find(t=>t.id===e);if(!t||v.current.length>0&&!v.current.some(e=>e.id===t.projectId))return;if(t.kind===`explore-spec`){let e=t.params.resumeConversationId;e&&fetch(`/api/projects/${t.projectId}/chat/conversations/${e}/restore`,{method:`POST`}).catch(()=>{})}n!==t.projectId&&r(t.projectId),o(t.restoreRoute),p(n=>{let r=[...n.filter(t=>t.id!==e),t];return F(r),h.current=r,r}),d(t=>{let n=t.filter(t=>t.id!==e);return N(n),m.current=n,n}),T(e);let i=setTimeout(()=>{_.current.delete(e),h.current.some(t=>t.id===e)&&(p(t=>{let n=t.filter(t=>t.id!==e);return F(n),h.current=n,n}),d(n=>{if(n.some(n=>n.id===e||H(n,t)))return n;let r=[...n,t];return N(r),m.current=r,r}))},j);_.current.set(e,i)},[n,r,o,T]),R=(0,g.useRef)(I);R.current=I;let z=(0,g.useRef)(O);z.current=O,S.current=k,C.current=A;let V=(0,g.useCallback)((e,t)=>{let n=h.current,r=n.findIndex(n=>n.kind===e&&n.projectId===t);if(r===-1)return null;let i=n[r];return T(i.id),p(e=>{let t=e.filter(e=>e.id!==i.id);return F(t),t}),h.current=n.filter(e=>e.id!==i.id),i},[T]),U=(0,g.useCallback)(e=>{let t=B(),i={...e,id:t,createdAt:Date.now()};n!==e.projectId&&r(e.projectId),o(e.restoreRoute),p(e=>{let t=[...e,i];return F(t),h.current=t,t}),T(t);let a=setTimeout(()=>{_.current.delete(t),h.current.some(e=>e.id===t)&&(p(e=>{let n=e.filter(e=>e.id!==t);return F(n),h.current=n,n}),d(e=>{if(e.some(e=>e.id===t||H(e,i)))return e;let n=[...e,i];return N(n),m.current=n,n}))},j);_.current.set(t,a)},[n,r,o,T]),W=(0,g.useMemo)(()=>({chats:u,pendingRestores:f,minimize:w,updateLabel:k,patchExploreSpecDraft:A,close:O,restore:I,takePendingRestore:V,triggerResume:U}),[u,f,w,k,A,O,I,V,U]);return(0,x.jsxs)(D.Provider,{value:W,children:[e,(0,x.jsx)(E,{chats:u,projects:t,hidden:!1,onRestore:I,onClose:O})]})}function W(){return(0,g.useContext)(D)||{chats:[],pendingRestores:[],minimize:()=>``,updateLabel:()=>{},patchExploreSpecDraft:()=>{},close:()=>{},restore:()=>{},takePendingRestore:()=>null,triggerResume:()=>{}}}function G(e,t,n){let{pendingRestores:r,takePendingRestore:i}=W(),a=(0,g.useRef)(n);a.current=n,(0,g.useEffect)(()=>{if(!t)return;let n=i(e,t);n&&a.current(n)},[r,e,t,i])}export{_ as a,p as c,v as i,W as n,y as o,G as r,h as s,U as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{l as r,r as i,t as a}from"./useSharedWebSocket-CNOvmgTr.js";import{n as o,t as s}from"./createLucideIcon-DtODIU64.js";import{n as c,r as l,s as u}from"./useDesktop-C5JVBeur.js";import{s as d}from"./provider-capabilities-lePfeT_Y.js";import{t as f}from"./download-C9wP_42h.js";import{t as p}from"./external-link-CZ6Q-v1-.js";import{t as m}from"./loader-circle-BqV9xYGf.js";import{t as h}from"./search-BDVp3fkH.js";import{t as g}from"./trash-D8zYUmTg.js";import{t as _}from"./triangle-alert-Cxpn8bqr.js";import{n as v,t as y}from"./jira-api-Bl8xEIpk.js";import{i as b,l as x,o as S,r as C,t as w}from"./dialog-DtdR05v1.js";import{t as T}from"./utils-BC4DHlz2.js";import{t as E}from"./button-4FS1ZDTp.js";import{Ct as D,Jt as O,Ot as k,W as A,Zt as j,bt as M,kt as N,ln as ee,un as te,xt as ne,yt as re}from"./index-Culan6y7.js";var P={name:`earth`,size:24,node:[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`globe-2`]};P.node;var ie=s(P),F={name:`folder-kanban`,size:24,node:[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]};F.node;var ae=s(F),I={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};I.node;var L=s(I),R=e(t(),1),z=n(),B=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],oe={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function V(e){let{activeProjectId:t}=l();return(0,z.jsx)(H,{...e},e.apiBase??t??`legacy`)}function H({onConnected:e,onSkip:t,apiBase:n}){let{t:r}=o(`jira`),[i,a]=(0,R.useState)(1),[s,c]=(0,R.useState)(``),[l,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(`idle`),[g,_]=(0,R.useState)(null),[v,b]=(0,R.useState)(`cloud`),[x,S]=(0,R.useState)([]),[C,w]=(0,R.useState)(``),[T,D]=(0,R.useState)(``),[O,k]=(0,R.useState)(``),[j,M]=(0,R.useState)(!1),[N,ee]=(0,R.useState)([]),[te,ne]=(0,R.useState)({}),[re,P]=(0,R.useState)(``),[ie,F]=(0,R.useState)(!1),[ae,I]=(0,R.useState)(!1),L=(0,R.useRef)(0),V=(0,R.useRef)(!0);(0,R.useEffect)(()=>(V.current=!0,()=>{V.current=!1,L.current++}),[]);let[H,se]=(0,R.useState)(!1),K=()=>({baseUrl:s.trim(),accountEmail:l.trim()||null,token:f});async function ce(){h(`testing`);try{let e=await y.test(K(),n);if(!V.current)return;h(`ok`),_(e.displayName),b(e.deployment)}catch(e){if(!V.current)return;h(`error`),u.error(G(e,r))}}async function q(){a(2),M(!0);try{let{projects:e}=await y.discoverProjects({...K(),query:C.trim()||void 0},n);if(!V.current)return;S(e)}catch(e){V.current&&u.error(G(e,r))}finally{V.current&&M(!1)}}async function le(){a(3),await J()}async function J(){if(!T)return;let e=++L.current;F(!0);try{let{statuses:t}=await y.discoverStatuses({...K(),projectKey:T},n);if(!V.current||e!==L.current)return;ee(t),I(!1)}catch{V.current&&e===L.current&&I(!0)}finally{V.current&&e===L.current&&F(!1)}}function ue(e,t){e!==T&&(L.current++,ee([]),ne({}),P(``),I(!1),F(!1)),D(e),k(t)}async function Y(){se(!0);try{let t=Object.fromEntries(Object.entries(te).filter(([,e])=>e));if(await y.connect({...K(),jiraProjectKey:T.trim(),statusMap:Object.keys(t).length?t:null,discardStatus:re.trim()||null},n),!V.current)return;u.success(r(`status.connected`,{key:T.trim()})),e()}catch(e){V.current&&u.error(G(e,r))}finally{V.current&&se(!1)}}return(0,z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-wizard`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`wizard.step`,{current:i,total:4})}),t&&(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-muted-foreground hover:text-foreground hover:underline`,"data-testid":`jira-later`,children:r(`wizard.later`)})]}),i===1&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step1Title`)}),(0,z.jsx)(U,{label:r(`creds.baseUrlLabel`),help:r(`creds.baseUrlHelp`),children:(0,z.jsx)(A,{value:s,onChange:e=>{c(e.target.value),h(`idle`)},placeholder:r(`creds.baseUrlPlaceholder`)})}),(0,z.jsx)(U,{label:r(`creds.emailLabel`),help:r(`creds.emailHelp`),children:(0,z.jsx)(A,{value:l,onChange:e=>{d(e.target.value),h(`idle`)},placeholder:r(`creds.emailPlaceholder`)})}),(0,z.jsx)(U,{label:r(`creds.tokenLabel`),help:r(`creds.tokenHelp`),children:(0,z.jsx)(A,{type:`password`,value:f,onChange:e=>{p(e.target.value),h(`idle`)}})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(E,{size:`sm`,variant:`outline`,onClick:ce,disabled:!s.trim()||!f.trim()||m===`testing`,children:r(m===`testing`?`creds.testing`:m===`ok`?`creds.retest`:`creds.test`)}),m===`ok`&&(0,z.jsxs)(`span`,{className:`text-xs text-accent-success`,"data-testid":`jira-test-ok`,children:[`✓ `,r(`creds.testOk`,{name:g??``}),` · `,r(v===`cloud`?`review.cloud`:`review.dc`)]})]}),(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(E,{size:`sm`,onClick:q,disabled:m!==`ok`,children:r(`wizard.next`)})})]}),i===2&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step2Title`)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(A,{value:C,onChange:e=>w(e.target.value),placeholder:r(`project.searchPlaceholder`)}),(0,z.jsx)(E,{size:`sm`,variant:`outline`,onClick:q,children:r(`project.searchPlaceholder`)})]}),j?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.loading`)}):x.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.none`)}):(0,z.jsx)(`div`,{className:`max-h-48 space-y-1 overflow-y-auto`,"data-testid":`jira-project-list`,children:x.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>ue(e.key,e.name),className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm hover:bg-muted ${T===e.key?`bg-muted`:``}`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.key}),(0,z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.name})]},e.id))}),(0,z.jsx)(U,{label:r(`project.manualLabel`),children:(0,z.jsx)(A,{value:T,onChange:e=>ue(e.target.value.toUpperCase(),``),placeholder:r(`project.manualPlaceholder`)})}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>a(1),children:r(`wizard.back`)}),(0,z.jsx)(E,{size:`sm`,onClick:le,disabled:!T.trim(),children:r(`wizard.next`)})]})]}),i===3&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step3Title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`mapping.intro`)}),ae&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:r(`mapping.loadFailed`)}),(0,z.jsx)(E,{size:`sm`,variant:`outline`,disabled:ie,onClick:()=>void J(),children:r(`mapping.retry`)})]}),ie&&(0,z.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:r(`mapping.loading`)}),B.map(e=>(0,z.jsx)(U,{label:r(`mapping.${oe[e]}`),children:(0,z.jsxs)(`select`,{value:te[e]??``,onChange:t=>ne(n=>({...n,[e]:t.target.value||void 0})),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,children:[(0,z.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),N.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id))]})},e)),(0,z.jsx)(U,{label:r(`discard.configLabel`),help:r(`discard.configHelp`),children:(0,z.jsxs)(`select`,{value:re,onChange:e=>P(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,z.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),N.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>a(2),children:r(`wizard.back`)}),(0,z.jsx)(E,{size:`sm`,onClick:()=>a(4),children:r(`wizard.next`)})]})]}),i===4&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step4Title`)}),(0,z.jsxs)(`dl`,{className:`space-y-1 text-sm`,children:[(0,z.jsx)(W,{label:r(`review.site`),value:s}),(0,z.jsx)(W,{label:r(`review.project`),value:O?`${T} — ${O}`:T}),(0,z.jsx)(W,{label:r(`review.account`),value:g??l}),(0,z.jsx)(W,{label:r(`review.type`),value:r(v===`cloud`?`review.cloud`:`review.dc`)}),(0,z.jsx)(W,{label:r(`discard.reviewLabel`),value:re||r(`discard.configNone`)})]}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>a(3),children:r(`wizard.back`)}),(0,z.jsx)(E,{size:`sm`,onClick:Y,disabled:H,children:r(H?`wizard.connecting`:`wizard.connect`)})]})]})]})}function U({label:e,help:t,children:n}){return(0,z.jsxs)(`label`,{className:`block space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e}),n,t&&(0,z.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:t})]})}function W({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,z.jsx)(`dd`,{className:`truncate text-right font-medium`,children:t})]})}function G(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var se={pending:0,inflight:0,done:0,dead:0};function K({projectId:e,baseUrl:t,apiBase:n,initialCounts:r,refreshToken:i}){let{t:s}=o(`jira`),[c,l]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(()=>new Set),h=(0,R.useRef)(!0),g=(0,R.useRef)(0),_=(0,R.useContext)(a),v=(0,R.useId)(),b=(0,R.useCallback)(async()=>{if(!h.current)return;let e=++g.current;try{let t=n?await y.listOutbox(`dead`,n):await y.listOutbox(`dead`);if(!h.current||e!==g.current)return;l({...t,ops:t.ops.filter(e=>e.state===`dead`)}),f(!1)}catch{h.current&&e===g.current&&f(!0)}},[n]);(0,R.useEffect)(()=>(h.current=!0,b(),()=>{h.current=!1,g.current++}),[b,i,r?.dead,r?.pending,r?.inflight,r?.done,r?.superseded]),(0,R.useEffect)(()=>{if(_)return _.registerHandler(v,t=>{if(!t||typeof t!=`object`)return;let n=t;n.type===`jira.outbox_changed`&&n.projectId===e&&b()}),()=>_.unregisterHandler(v)},[_,v,e,b]);async function x(e){if(!p.has(e)){m(t=>new Set(t).add(e));try{n?await y.retryOutbox(e,n):await y.retryOutbox(e),h.current&&await b()}catch(e){h.current&&u.error(e instanceof Error?e.message:s(`errors.generic`))}finally{h.current&&m(t=>{let n=new Set(t);return n.delete(e),n})}}}let S=c?.counts??r??se,C=S.pending+S.inflight;return(0,z.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:s(`outbox.title`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs ${S.dead>0?`text-accent-warning`:`text-muted-foreground`}`,children:S.dead>0?s(`outbox.dead`,{count:S.dead}):C>0?s(`outbox.pending`,{count:C}):s(S.superseded?`outbox.nonePending`:`outbox.allSynced`)}),d&&(0,z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:s(`outbox.loadFailed`)}),(0,z.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void b(),children:s(`outbox.retry`)})]}),!!c?.ops.length&&(0,z.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`outbox.deadHelp`)}),c.ops.map(e=>{let n=e.targetStatus||(e.logicalState?s(`mapping.${ce(e.logicalState)}`):null),r=e.deadReason??e.lastError??``;return(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-2 rounded border border-border/60 px-2 py-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 space-y-1 text-xs`,children:[(0,z.jsxs)(`p`,{className:`break-words`,children:[e.jiraKey?(0,z.jsx)(`a`,{href:`${t.replace(/\/$/,``)}/browse/${encodeURIComponent(e.jiraKey)}`,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent-primary hover:underline`,children:e.jiraKey}):(0,z.jsx)(`span`,{className:`font-medium`,children:s(`outbox.issueFallback`,{id:e.jiraIssueId})}),` · `,s(e.opType===`transition`?`outbox.opTransition`:e.opType===`comment`?`outbox.opComment`:e.opType===`update`?`outbox.opUpdate`:`outbox.opCreate`)]}),n&&(0,z.jsx)(`p`,{className:`break-words text-muted-foreground`,children:s(`outbox.target`,{status:n})}),(0,z.jsx)(`p`,{className:`max-h-32 overflow-y-auto whitespace-pre-wrap break-words text-muted-foreground`,children:r})]}),(0,z.jsx)(E,{className:`shrink-0`,variant:`outline`,size:`sm`,disabled:p.has(e.id),onClick:()=>void x(e.id),children:s(p.has(e.id)?`outbox.retrying`:`outbox.retry`)})]},e.id)})]})]})}function ce(e){return e===`in_progress`?`inProgress`:e===`on_review`?`onReview`:e}var q=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],le={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function J(e){let{activeProjectId:t}=l(),n=`${e.apiBase??t??``}:${e.state.connection.projectId}`;return(0,z.jsx)(ue,{...e},n)}function ue({state:e,onChanged:t,apiBase:n}){let{t:r}=o(`jira`),i=e.connection,[a,s]=(0,R.useState)(i.enabled),[c,l]=(0,R.useState)(!1),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(0),[h,g]=(0,R.useState)([]),[_,v]=(0,R.useState)(i.discardStatus??``),[b,x]=(0,R.useState)(i.statusMap??{}),[S,C]=(0,R.useState)(!1),[w,T]=(0,R.useState)(!1),D=(0,R.useRef)(0),O=(0,R.useRef)(!0),k=(0,R.useCallback)(async()=>{let e=++D.current;T(!0);try{let{statuses:t}=await y.listStatuses(n);if(!O.current||e!==D.current)return;g(t),C(!1)}catch{O.current&&e===D.current&&C(!0)}finally{O.current&&e===D.current&&T(!1)}},[n]);(0,R.useEffect)(()=>(O.current=!0,k(),()=>{O.current=!1,D.current++}),[k]);async function A(e){let i=_;v(e);try{if(n?await y.patchConnection({discardStatus:e||null},n):await y.patchConnection({discardStatus:e||null}),!O.current)return;t()}catch(e){if(!O.current)return;v(i),u.error(Y(e,r))}}async function j(e,i){let a=b,o={...b,[e]:i||void 0};x(o);let s=Object.fromEntries(Object.entries(o).filter(([,e])=>e));try{if(n?await y.patchConnection({statusMap:Object.keys(s).length?s:null},n):await y.patchConnection({statusMap:Object.keys(s).length?s:null}),!O.current)return;m(e=>e+1),t()}catch(e){if(!O.current)return;x(a),u.error(Y(e,r))}}async function M(){let e=!a;s(e),f(!0);try{n?await y.setEnabled(e,n):await y.setEnabled(e)}catch(t){if(!O.current)return;s(!e),u.error(Y(t,r))}finally{O.current&&f(!1)}}async function N(){l(!0);try{let e=n?await y.syncNow(n):await y.syncNow();if(!O.current)return;u.success(r(`status.syncedToast`,{count:e.upserted})),m(e=>e+1)}catch(e){O.current&&u.error(Y(e,r))}finally{O.current&&l(!1)}}async function ee(){if(window.confirm(r(`status.disconnectConfirm`))){f(!0);try{if(n?await y.disconnect(n):await y.disconnect(),!O.current)return;u.success(r(`status.disconnectedToast`)),t()}catch(e){O.current&&u.error(Y(e,r))}finally{O.current&&f(!1)}}}return(0,z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:r(`status.connected`,{key:i.jiraProjectKey})}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i.baseUrl,` · `,i.deployment===`cloud`?r(`review.cloud`):r(`review.dc`)]})]}),(0,z.jsx)(`a`,{href:`${i.baseUrl}/browse/${i.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:r(`badge.openInJira`)})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`status.enabledLabel`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(a?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,z.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":r(`status.enabledLabel`),disabled:d,onClick:M,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${a?`bg-accent-success`:`bg-input`}`,children:(0,z.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${a?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`wizard.step3Title`)}),(0,z.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`mapping.intro`)}),S&&(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:r(`mapping.loadFailed`)}),(0,z.jsx)(E,{variant:`outline`,size:`sm`,disabled:w,onClick:()=>void k(),children:r(`mapping.retry`)})]}),w&&(0,z.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-muted-foreground`,children:r(`mapping.loading`)}),(0,z.jsx)(`div`,{className:`space-y-2`,children:q.map(e=>(0,z.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`mapping.${le[e]}`)}),(0,z.jsxs)(`select`,{value:b[e]??``,onChange:t=>void j(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,z.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),h.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!h.some(t=>t.name===b[e])&&(0,z.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`discard.configLabel`)}),(0,z.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`discard.configHelp`)}),(0,z.jsxs)(`select`,{value:_,onChange:e=>void A(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,z.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),h.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id)),_&&!h.some(e=>e.name===_)&&(0,z.jsx)(`option`,{value:_,children:_})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(E,{variant:`outline`,size:`sm`,onClick:N,disabled:c,children:r(c?`status.syncing`:`status.syncNow`)}),(0,z.jsx)(E,{variant:`ghost`,size:`sm`,onClick:ee,disabled:d,className:`text-destructive`,children:r(`status.disconnect`)})]}),(0,z.jsx)(K,{projectId:i.projectId,baseUrl:i.baseUrl,apiBase:n,initialCounts:e.outbox,refreshToken:p})]})}function Y(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var de=new Set([`claude`,`codex`,`kimi`]);function fe(e){return{provider:e,label:e===`codex`?`Codex`:`Claude`,active:!1,available:!1,detectedRoute:!1,requests:0,inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0,outputSavingsPercent:0,outputSavingsMethod:`none`,outputSavingsAllocated:!1}}function pe(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:fe(`codex`),claude:fe(`claude`)},lastIssue:null}}var X={installed:!1,installSource:null,version:null,executablePath:null,uvPath:null,port:8787,phase:`idle`,activeProviders:{codex:!1,claude:!1},availableProviders:{codex:!1,claude:!1},detectedRoutes:{codex:!1,claude:!1},proxyRunning:!1,proxyPid:null,learning:{enabled:!1,baselineReady:!1,baselineSamples:0,updatedAt:null,lastIssue:null},metrics:pe(),lastIssue:null,updatedAt:null};function me(e){let t=e?.metrics??pe();return{...X,...e,activeProviders:{...X.activeProviders,...e?.activeProviders},availableProviders:{...X.availableProviders,...e?.availableProviders},detectedRoutes:{...X.detectedRoutes,...e?.detectedRoutes},learning:{...X.learning,...e?.learning},metrics:{...pe(),...t,providers:{codex:{...fe(`codex`),...t.providers?.codex},claude:{...fe(`claude`),...t.providers?.claude}}}}}async function Z(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok){let t=n.issue;throw Object.assign(Error(t?.title??n.error??`HTTP ${e.status}`),{payload:n})}return n}function Q(e){return`${r}/api/projects/${e}`}function he(e,t=`en`){if(!Number.isFinite(e))return`0`;try{return Intl.NumberFormat(t,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}catch{return Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}}function $(e,t,n){return`${he(e,t)} ${n}`}function ge({onWindowOpened:e}={}){let{t}=o(`integrations`),{projects:n}=l(),{registerHandler:a,unregisterHandler:s}=i(),[c,d]=(0,R.useState)(``),[f,m]=(0,R.useState)(`all`),[g,_]=(0,R.useState)(X),[v,y]=(0,R.useState)(!0),[E,D]=(0,R.useState)(null),[O,A]=(0,R.useState)([]),[j,P]=(0,R.useState)(!1),[ie,F]=(0,R.useState)(!1),[I,L]=(0,R.useState)(null),[B,oe]=(0,R.useState)({jira:0,serena:0,projects:0}),V=(0,R.useCallback)(async()=>{try{let e=await fetch(`${r}/api/global-plugins/headroom`).then(e=>Z(e));_(me(e.state))}finally{y(!1)}},[]);(0,R.useEffect)(()=>{V()},[V]),(0,R.useEffect)(()=>(a(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&A(e=>[...e.slice(-80),t.line]),V())}),()=>s(`plugins-page`)),[a,s,V]),(0,R.useEffect)(()=>{let e=!1;async function t(){let t=await Promise.all(n.map(async e=>{let[t,n]=await Promise.all([fetch(`${Q(e.id)}/jira/connection`).then(e=>Z(e)).catch(()=>({connected:!1})),fetch(`${Q(e.id)}/plugins`).then(e=>Z(e)).catch(()=>({plugins:[]}))]),r=n.plugins.find(e=>e.name===`serena`);return{jira:+!!t.connected,serena:r&&r.status!==`not-installed`&&r.status!==`orphan`?1:0}}));e||oe({jira:t.reduce((e,t)=>e+t.jira,0),serena:t.reduce((e,t)=>e+t.serena,0),projects:n.length})}return t(),()=>{e=!0}},[n]);async function H(e,t){D(e),A([]);try{let e=(await t()).state;e&&_(me(e))}catch(e){let t=e.payload;t?.state&&_(me(t.state))}finally{D(null),V()}}let U=(0,R.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:N,description:t(`plugins.catalog.headroom.description`),installed:g.installed,status:g.lastIssue?`attention`:g.installed?g.activeProviders.codex||g.activeProviders.claude?g.installSource===`system`?`external-active`:`active`:g.installSource===`system`?`external`:`installed`:`available`,statusLabel:g.lastIssue?t(`plugins.status.attention`):g.installed?g.activeProviders.codex||g.activeProviders.claude?g.installSource===`system`?t(`plugins.status.externalActive`):t(`plugins.status.active`):g.installSource===`system`?t(`plugins.status.external`):t(`plugins.status.installed`):t(`plugins.status.available`),actionKind:g.lastIssue?`review`:g.installed?`manage`:`install`,actionLabel:g.lastIssue?t(`plugins.actions.review`):g.installed?t(`plugins.actions.manage`):t(`plugins.actions.install`),busy:E===`install`,action:()=>{if(g.lastIssue||g.installed){P(!0);return}H(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>Z(e)))}}],[g,E,t]),W=(0,R.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:ae,description:t(`plugins.catalog.jira.description`),installed:B.jira>0,status:B.jira>0?`configured`:`available`,statusLabel:B.jira>0?t(`plugins.status.configuredCount`,{count:B.jira}):t(`plugins.status.available`),actionKind:B.jira>0?`manage`:`install`,actionLabel:B.jira>0?t(`plugins.actions.manage`):t(`plugins.actions.install`),action:()=>L(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:re,description:t(`plugins.catalog.serena.description`),installed:B.serena>0,status:B.serena>0?`installed`:`available`,statusLabel:B.serena>0?t(`plugins.status.installedCount`,{count:B.serena}):t(`plugins.status.available`),actionKind:B.serena>0?`manage`:`install`,actionLabel:B.serena>0?t(`plugins.actions.manage`):t(`plugins.actions.install`),action:()=>L(`serena`)}],[B,t]),G=c.trim().toLowerCase(),se=e=>`${e.title} ${e.description} ${e.statusLabel} ${t(`plugins.scope.${e.scope}`)}`.toLowerCase().includes(G),K=[...U,...W].filter(e=>f!==`all`&&e.scope!==f?!1:se(e)),ce=K.filter(e=>e.scope===`global`&&e.installed),q=K.filter(e=>e.scope===`project`&&e.installed),le=K.filter(e=>e.scope===`global`&&!e.installed),J=K.filter(e=>e.scope===`project`&&!e.installed),ue=ce.length>0||q.length>0,Y=le.length>0||J.length>0,de=[g.installed,B.jira>0,B.serena>0].filter(Boolean).length;return(0,z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,z.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`grid h-9 w-9 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,z.jsx)(k,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:t(`plugins.page.title`)}),(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t(`plugins.page.subtitle`)})]}),!ee()&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void te().then(()=>e?.()).catch(e=>u.error(String(e))),className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-2 text-xs hover:bg-muted`,children:[(0,z.jsx)(p,{className:`h-3.5 w-3.5`}),t(`plugins.page.openWindow`)]}),(0,z.jsxs)(`div`,{className:`mr-12 flex items-center gap-2 rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,children:[(0,z.jsx)(ne,{className:`h-3.5 w-3.5 text-accent-success`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:t(`plugins.page.readyCount`,{count:de})})]})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,z.jsxs)(`label`,{className:`relative flex-1`,children:[(0,z.jsx)(h,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,z.jsx)(`input`,{value:c,onChange:e=>d(e.target.value),placeholder:t(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,z.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:T(`rounded-md px-3 text-xs capitalize transition-colors`,f===e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:t(`plugins.filters.${e}`)},e))})]})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,z.jsxs)(`section`,{className:`mb-6`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(M,{className:`h-3.5 w-3.5`}),t(`plugins.sections.installed`)]}),ue?(0,z.jsx)(_e,{globalPlugins:ce,projectPlugins:q}):(0,z.jsx)(ve,{text:t(G?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(k,{className:`h-3.5 w-3.5`}),t(`plugins.sections.available`)]}),Y?(0,z.jsx)(_e,{globalPlugins:le,projectPlugins:J}):(0,z.jsx)(ve,{text:t(G?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,z.jsx)(w,{open:j,onOpenChange:P,children:(0,z.jsxs)(C,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(x,{children:t(`plugins.headroom.title`)}),(0,z.jsx)(b,{children:t(`plugins.headroom.dialogDescription`)})]}),(0,z.jsx)(Se,{state:g,loading:v,busy:E,logs:O,onInstall:()=>H(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>Z(e))),onToggleProvider:(e,t)=>H(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${r}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>Z(e))),onDeactivateAll:()=>H(`deactivate-all`,async()=>{let e={state:g};for(let t of[`codex`,`claude`])g.activeProviders[t]&&(e=await fetch(`${r}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>Z(e)));return e}),onUninstall:()=>H(`uninstall`,()=>fetch(`${r}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>Z(e))),onSetPort:e=>H(`port`,()=>fetch(`${r}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>Z(e))),onOpenDiagnostics:()=>F(!0)})]})}),(0,z.jsx)(ke,{plugin:I,projects:n,onClose:()=>L(null)}),(0,z.jsx)(Me,{open:ie,onClose:()=>F(!1)})]})}function _e({globalPlugins:e,projectPlugins:t}){let{t:n}=o(`integrations`);return(0,z.jsxs)(`div`,{className:T(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsx)(be,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,z.jsx)(xe,{plugin:e},e.id))})]}),t.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsx)(be,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,z.jsx)(xe,{plugin:e},e.id))})]})]})}function ve({text:e}){return(0,z.jsx)(`div`,{className:`flex h-[74px] max-w-[320px] items-center rounded-lg border border-dashed border-border bg-card/35 px-3 text-xs text-muted-foreground`,children:e})}function ye({scope:e}){let{t}=o(`integrations`);return(0,z.jsx)(`span`,{className:T(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function be({title:e,detail:t,scope:n}){return(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,z.jsx)(`div`,{className:T(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,z.jsx)(ye,{scope:n}),(0,z.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,z.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,z.jsx)(`div`,{className:T(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function xe({plugin:e}){let{t}=o(`integrations`),n=e.icon,r=e.scope===`global`,i=e.status===`attention`,a=e.busy?m:e.actionKind===`install`?f:e.actionKind===`review`?_:D,s=T(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,i?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,z.jsxs)(`article`,{className:`grid h-[88px] w-full grid-cols-[38px_minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-card/70 px-3 transition-colors hover:border-accent-primary/35 hover:bg-card`,children:[(0,z.jsx)(`div`,{className:T(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,r?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,z.jsx)(n,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,z.jsx)(ye,{scope:e.scope}),(0,z.jsx)(`span`,{className:s,children:e.statusLabel})]})]}),(0,z.jsxs)(`button`,{type:`button`,disabled:e.busy,onClick:e.action,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-muted disabled:opacity-50`,children:[(0,z.jsx)(a,{className:T(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function Se({state:e,loading:t,busy:n,logs:r,onInstall:i,onToggleProvider:a,onDeactivateAll:s,onUninstall:c,onSetPort:l,onOpenDiagnostics:u}){let{t:d}=o(`integrations`),[p,h]=(0,R.useState)(String(e.port)),[_,y]=(0,R.useState)(!1);(0,R.useEffect)(()=>h(String(e.port)),[e.port]),(0,R.useEffect)(()=>{e.installed||y(!1)},[e.installed]);let b=e.activeProviders.codex||e.activeProviders.claude,x=e.installSource===`system`;return(0,z.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,z.jsx)(`div`,{className:`grid h-10 w-10 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,z.jsx)(N,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold`,children:d(`plugins.headroom.title`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:d(`plugins.headroom.panelDescription`)})]})]}),(0,z.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,z.jsx)(Ce,{label:d(`plugins.headroom.metrics.install`),value:t?d(`plugins.headroom.metrics.checking`):e.installed?d(`plugins.headroom.metrics.ready`):d(`plugins.headroom.metrics.missing`),good:e.installed}),(0,z.jsx)(Ce,{label:d(`plugins.headroom.metrics.source`),value:e.installSource===`system`?d(`plugins.headroom.metrics.system`):e.installSource===`managed`?d(`plugins.headroom.metrics.specrails`):d(`plugins.headroom.metrics.none`),good:e.installed}),(0,z.jsx)(Ce,{label:d(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:d(b?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!b})]}),e.lastIssue&&(0,z.jsx)(we,{issue:e.lastIssue}),e.installed?(0,z.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,z.jsx)(Oe,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>a(`codex`,e.activeProviders.codex)}),(0,z.jsx)(Oe,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>a(`claude`,e.activeProviders.claude)}),b&&(0,z.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:s,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(L,{className:`h-3.5 w-3.5`}),d(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,z.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:i,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(f,{className:`h-3.5 w-3.5`}),d(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,z.jsx)(Te,{state:e}),(0,z.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,z.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:d(`plugins.headroom.port.label`)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,z.jsx)(`button`,{type:`button`,disabled:!!n||Number(p)===e.port,onClick:()=>l(Number(p)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:d(`plugins.headroom.port.apply`)})]})]}),r.length>0&&(0,z.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:r.join(`
|
|
2
|
+
`)}),(0,z.jsxs)(`button`,{type:`button`,onClick:u,className:`mb-2 flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border text-xs hover:bg-muted/50`,children:[(0,z.jsx)(v,{className:`h-3.5 w-3.5`}),d(`plugins.headroom.actions.viewDiagnostics`)]}),e.installed&&(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/5 p-3`,children:_?(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:d(x?`plugins.headroom.confirmDetach`:`plugins.headroom.confirmUninstall`)}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:!!n,onClick:()=>y(!1),className:`h-8 rounded-md border border-border text-xs hover:bg-muted/50 disabled:opacity-50`,children:d(`plugins.actions.cancel`)}),(0,z.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:c,className:`flex h-8 items-center justify-center gap-2 rounded-md bg-destructive px-2 text-xs font-medium text-destructive-foreground disabled:opacity-50`,children:[n===`uninstall`?(0,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),d(x?`plugins.headroom.actions.detach`:`plugins.headroom.actions.uninstall`)]})]})]}):(0,z.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:()=>y(!0),className:`flex h-8 w-full items-center justify-center gap-2 rounded-md text-xs font-medium text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:[(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),d(x?`plugins.headroom.actions.detachHeadroom`:`plugins.headroom.actions.uninstallHeadroom`)]})})]})}function Ce({label:e,value:t,good:n}){return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:T(`mt-0.5 font-medium`,n?`text-foreground`:`text-accent-warning`),children:t})]})}function we({issue:e}){let{t}=o(`integrations`),n=`plugins.headroom.issues.${e.code}`,r=t(`${n}.title`,{defaultValue:e.title}),i=t(`${n}.guidance`,{defaultValue:e.guidance});return(0,z.jsx)(`div`,{className:`mb-3 rounded-lg border border-accent-warning/35 bg-accent-warning/10 p-3`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-xs font-medium`,children:r}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:i}),(0,z.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(`plugins.headroom.issueCode`,{code:e.code})})]})]})})}function Te({state:e}){let{t,i18n:n}=o(`integrations`),r=e.metrics,i=r.outputSavingsAvailable,a=[`codex`,`claude`].map(e=>({provider:e,metric:r.providers[e]})),s=t(`plugins.headroom.savings.tokens`),c=a.reduce((e,{metric:t})=>({inputTokens:e.inputTokens+t.inputTokens,inputTokensSaved:e.inputTokensSaved+t.inputTokensSaved,outputTokens:e.outputTokens+t.outputTokens,outputTokensSaved:e.outputTokensSaved+t.outputTokensSaved}),{inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0}),l=a.some(({metric:e})=>e.inputTokensSaved>0),u=a.some(({metric:e})=>e.active),d=t(i?`plugins.headroom.savings.statusInputOutput`:l?`plugins.headroom.savings.statusInputOnly`:u?`plugins.headroom.savings.statusRouting`:`plugins.headroom.savings.statusInactive`),f=i||l;return(0,z.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(j,{className:`h-3.5 w-3.5 text-accent-primary`}),(0,z.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t(`plugins.headroom.savings.title`)})]}),(0,z.jsx)(`span`,{className:T(`shrink-0 rounded border px-1.5 py-0.5 text-[10px]`,f?`border-accent-success/25 bg-accent-success/10 text-accent-success`:u?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-border bg-muted text-muted-foreground`),children:d})]}),(0,z.jsxs)(`div`,{className:`mb-2 rounded-md bg-muted/35 px-2.5 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase text-muted-foreground`,children:t(`plugins.headroom.savings.totals`)}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,z.jsx)(Ee,{label:t(`plugins.headroom.savings.input`),processed:c.inputTokens>0?$(c.inputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:$(c.inputTokensSaved,n.language,s)}),(0,z.jsx)(Ee,{align:`right`,label:t(`plugins.headroom.savings.output`),processed:c.outputTokens>0?$(c.outputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:i?$(c.outputTokensSaved,n.language,s):t(`plugins.headroom.savings.noData`)})]})]}),(0,z.jsx)(`div`,{className:`grid gap-2`,children:a.map(({provider:e,metric:t})=>(0,z.jsx)(De,{metric:t,outputAvailable:r.outputSavingsAvailable},e))}),(0,z.jsx)(`div`,{className:`mt-2 flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:r.updatedAt?t(`plugins.headroom.savings.updatedLive`):t(`plugins.headroom.savings.baselineSamples`,{count:e.learning.baselineSamples})})]})}function Ee({label:e,processed:t,saved:n,detail:r,align:i=`left`}){let{t:a}=o(`integrations`);return(0,z.jsxs)(`div`,{className:T(`min-w-0`,i===`right`&&`text-right`),children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,z.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:a(`plugins.headroom.savings.processed`)}),(0,z.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:t})]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:a(`plugins.headroom.savings.saved`)}),(0,z.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:n})]})]}),r&&(0,z.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,children:r})]})}function De({metric:e,outputAvailable:t}){let{t:n,i18n:r}=o(`integrations`),i=!e.available,a=i||!e.active,s=n(`plugins.headroom.savings.tokens`),c=e.inputTokens>0?$(e.inputTokens,r.language,s):n(`plugins.headroom.savings.noData`),l=$(e.inputTokensSaved,r.language,s),u=e.outputTokens>0?$(e.outputTokens,r.language,s):n(`plugins.headroom.savings.noData`),d=t?$(e.outputTokensSaved,r.language,s):e.active?n(`plugins.headroom.savings.noData`):n(`plugins.headroom.savings.off`),f=e.requests>0?n(`plugins.headroom.savings.requestCount`,{count:he(e.requests,r.language)}):i?n(`plugins.headroom.provider.noProjectUsesProvider`):e.active?n(`plugins.headroom.savings.inputSavingsActive`):n(`plugins.headroom.savings.routeDisabled`);return(0,z.jsxs)(`div`,{className:T(`rounded-md border border-border bg-card/45 px-2.5 py-2`,a&&`opacity-70`),children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),e.detectedRoute&&(0,z.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-0.5 text-[9px] uppercase text-accent-primary`,children:n(`plugins.headroom.savings.detected`)})]}),(0,z.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:f}),(0,z.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-3`,children:[(0,z.jsx)(Ee,{label:n(`plugins.headroom.savings.input`),processed:c,saved:l}),(0,z.jsx)(Ee,{align:`right`,label:n(`plugins.headroom.savings.output`),processed:u,saved:d})]})]})}function Oe({provider:e,active:t,available:n,detectedRoute:r,busy:i,onClick:a}){let{t:s}=o(`integrations`),c=s(n?t?`plugins.headroom.provider.routedThroughHeadroom`:r?`plugins.headroom.provider.detectedExternalRoute`:`plugins.headroom.provider.notRouted`:`plugins.headroom.provider.noProjectUsesProvider`);return(0,z.jsxs)(`button`,{type:`button`,onClick:a,disabled:i||!n,className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background/45 p-3 text-left hover:bg-muted/35 disabled:opacity-50`,children:[(0,z.jsx)(`div`,{className:T(`grid h-8 w-8 place-items-center rounded-md`,t?`bg-accent-success/15 text-accent-success`:`bg-muted text-muted-foreground`),children:i?(0,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(ie,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`text-xs font-medium capitalize`,children:e}),(0,z.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:c})]}),(0,z.jsx)(`span`,{className:T(`h-5 w-9 rounded-full p-0.5 transition-colors`,t?`bg-accent-success`:`bg-muted`),children:(0,z.jsx)(`span`,{className:T(`block h-4 w-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-4`)})})]})}function ke({plugin:e,projects:t,onClose:n}){let{t:r}=o(`integrations`),[i,a]=(0,R.useState)(``);(0,R.useEffect)(()=>a(``),[e]);let s=t.find(e=>e.id===i)??null;return(0,z.jsx)(w,{open:!!e,onOpenChange:e=>{e||n()},children:(0,z.jsxs)(C,{className:`w-[calc(100vw-2rem)] max-w-3xl overflow-x-hidden p-4 sm:p-6`,children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(x,{children:r(e===`jira`?`plugins.projectWizard.configureJira`:`plugins.projectWizard.installSerena`)}),(0,z.jsx)(b,{children:r(`plugins.projectWizard.description`)})]}),(0,z.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-3`,children:[(0,z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:r(`plugins.projectWizard.chooseProject`)}),(0,z.jsx)(`div`,{className:`max-h-[52vh] space-y-1 overflow-auto`,children:t.map(t=>{let n=e===`serena`&&!c(t).some(e=>de.has(e));return(0,z.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>a(t.id),className:T(`w-full rounded-md px-2 py-2 text-left transition-colors`,t.id===i?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/45 hover:text-foreground`,n&&`cursor-not-allowed opacity-45`),children:[(0,z.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t.name}),(0,z.jsx)(`div`,{className:`truncate text-[10px]`,children:n?r(`plugins.projectWizard.requiresSupportedProvider`,{defaultValue:`Requires Claude or Codex`}):t.path})]},t.id)})})]}),(0,z.jsx)(`div`,{className:`min-h-[360px] rounded-lg border border-border bg-card/70 p-4`,children:s?e===`jira`?(0,z.jsx)(Ae,{project:s,onDone:n}):(0,z.jsx)(je,{project:s,onDone:n}):(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:r(`plugins.projectWizard.selectProjectToContinue`)})})]})]})})}function Ae({project:e,onDone:t}){let{t:n}=o(`integrations`),r=Q(e.id),[i,a]=(0,R.useState)(null),[s,c]=(0,R.useState)(!0),[l,u]=(0,R.useState)(null),d=(0,R.useCallback)(async()=>{c(!0),u(null);try{let e=await fetch(`${r}/jira/connection`).then(e=>Z(e));a(e)}catch(e){a({connected:!1}),u(e.message)}finally{c(!1)}},[r]);return(0,R.useEffect)(()=>{d()},[d]),s?(0,z.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,z.jsx)(m,{className:`mr-2 h-4 w-4 animate-spin`}),n(`plugins.jira.loading`,{defaultValue:`Loading Jira...`})]}):i?.connected&&i.connection?(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.jira.configuredDescription`,{defaultValue:`Manage the Jira project, status mapping, discard status, sync, and connection state.`})})]}),(0,z.jsx)(J,{state:i,apiBase:r,onChanged:()=>{d()}})]}):(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l?n(`plugins.jira.loadFailed`,{message:l,defaultValue:`Could not load the current Jira configuration: ${l}`}):n(`plugins.jira.notConfiguredDescription`,{defaultValue:`Connect this project to Jira.`})})]}),(0,z.jsx)(V,{apiBase:r,onConnected:()=>{d()},onSkip:t})]})}function je({project:e,onDone:t}){let{t:n}=o(`integrations`),r=(0,R.useMemo)(()=>c(e).filter(e=>de.has(e)),[e]),i=r.includes(e.provider)?e.provider:r[0]??e.provider,[a,s]=(0,R.useState)(i),[l,u]=(0,R.useState)(null),[p,h]=(0,R.useState)(null),[g,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(null),x=(0,R.useRef)(0);(0,R.useEffect)(()=>{s(i),u(null),h(null)},[e.id,i]);let S=(0,R.useCallback)(async()=>{let t=++x.current;b(null);try{let n=`?provider=${encodeURIComponent(a)}`,r=await fetch(`${Q(e.id)}/plugins${n}`).then(e=>Z(e));if(t!==x.current)return;let i=r.plugins.find(e=>e.name===`serena`)??null;if(u(i),h(null),i?.status===`not-installed`){let r=await fetch(`${Q(e.id)}/plugins/serena/preview-install${n}`).then(e=>Z(e));t===x.current&&h(r)}}catch(e){t===x.current&&b(e.message)}},[e.id,a]);(0,R.useEffect)(()=>{S()},[S]);async function C(){v(!0),b(null);try{await fetch(`${Q(e.id)}/plugins/serena/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:a})}).then(e=>Z(e)),await S(),t()}catch(e){b(e.message)}finally{v(!1)}}let w=(p?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum),T=l?n(`plugins.projectStatus.${l.status}`,{defaultValue:l.status}):``,E=l?.name===`serena`?n(`plugins.catalog.serena.description`):l?.description;return!l&&!y?(0,z.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,z.jsx)(m,{className:`mr-2 h-4 w-4 animate-spin`}),` `,n(`plugins.serena.loading`)]}):(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.serena.titleForProject`,{name:e.name})}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.serena.description`)})]}),(0,z.jsxs)(`label`,{className:`block space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium`,children:n(`plugins.serena.provider`,{defaultValue:`AI provider`})}),(0,z.jsx)(`select`,{"aria-label":n(`plugins.serena.provider`,{defaultValue:`AI provider`}),value:a,disabled:g,onChange:e=>{u(null),h(null),s(e.target.value)},className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs`,children:r.map(e=>(0,z.jsx)(`option`,{value:e,children:d(e)},e))})]}),l&&(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-3`,children:[(0,z.jsx)(`div`,{className:`text-xs font-medium`,children:n(`plugins.serena.status`,{status:T})}),E&&(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:E})]}),p&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.files`)}),(0,z.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:p.files.map(e=>(0,z.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path]},e.path))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.prerequisites`)}),(0,z.jsx)(`ul`,{className:`space-y-1 text-xs`,children:p.requirements.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.installed&&e.executable&&e.meetsMinimum?(0,z.jsx)(O,{className:`h-3 w-3 text-accent-success`}):(0,z.jsx)(_,{className:`h-3 w-3 text-accent-warning`}),(0,z.jsxs)(`span`,{children:[e.name,e.minVersion?` >= ${e.minVersion}`:``]}),e.version&&(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]})]},e.name))})]})]}),y&&(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:y}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md border border-border px-3 py-1.5 text-xs`,children:n(`plugins.actions.cancel`)}),(0,z.jsxs)(`button`,{type:`button`,disabled:g||l?.status!==`not-installed`||!w,onClick:C,className:`flex items-center gap-2 rounded-md bg-accent-primary px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:[g?(0,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(f,{className:`h-3.5 w-3.5`}),n(`plugins.actions.install`)]})]})]})}function Me({open:e,onClose:t}){let{t:n}=o(`integrations`),[i,a]=(0,R.useState)(null);return(0,R.useEffect)(()=>{e&&fetch(`${r}/api/global-plugins/headroom/diagnostics`).then(e=>Z(e)).then(a).catch(e=>a({error:e.message}))},[e]),(0,z.jsx)(w,{open:e,onOpenChange:e=>{e||t()},children:(0,z.jsxs)(C,{className:`max-w-3xl`,children:[(0,z.jsxs)(S,{children:[(0,z.jsxs)(x,{className:`flex items-center gap-2`,children:[(0,z.jsx)(D,{className:`h-4 w-4`}),` `,n(`plugins.diagnostics.title`)]}),(0,z.jsx)(b,{children:n(`plugins.diagnostics.description`)})]}),(0,z.jsx)(`pre`,{className:`max-h-[62vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background p-3 text-xs`,children:JSON.stringify(i,null,2)})]})})}export{ge as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{n as r,t as i}from"./createLucideIcon-DtODIU64.js";import{r as a}from"./useDesktop-C5JVBeur.js";import{t as o}from"./git-branch-yf6LE1Bw.js";import{i as s,l as c,o as l,r as u,t as d}from"./dialog-DtdR05v1.js";import{t as f}from"./utils-BC4DHlz2.js";import{St as p,_ as m,a as h,bt as g,en as _,g as v,gt as y,h as b,i as x,jt as S,n as C,o as w,r as T,rn as E,s as D,yt as O}from"./index-Culan6y7.js";var k={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};k.node;var A=i(k),j=e(t(),1),M=n(),N=[{id:`general`,icon:g,labelKey:`projectDialog.nav.general`},{id:`agentRuntime`,icon:_,labelKey:`projectDialog.nav.agentRuntime`},{id:`subagents`,icon:S,labelKey:`projectDialog.nav.subagents`},{id:`branch`,icon:o,labelKey:`projectDialog.nav.branch`},{id:`environment`,icon:A,labelKey:`projectDialog.nav.environment`},{id:`budget`,icon:y,labelKey:`projectDialog.nav.budget`},{id:`telemetry`,icon:E,labelKey:`projectDialog.nav.telemetry`},{id:`terminal`,icon:O,labelKey:`projectDialog.nav.terminal`}];function P({open:e,onClose:t}){let{t:n}=r(`settings`),{activeProjectId:i,projects:o}=a(),g=o.find(e=>e.id===i),[_,y]=(0,j.useState)(`general`),S=e=>f(`space-y-5`,_===e?``:`hidden`);return(0,M.jsx)(d,{open:e,onOpenChange:e=>{e||t()},children:(0,M.jsxs)(u,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,M.jsxs)(l,{children:[(0,M.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,M.jsx)(p,{className:`w-4 h-4`}),g?n(`projectDialog.title`,{name:g.name}):n(`page.title`)]}),(0,M.jsx)(s,{children:n(`projectDialog.description`)})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,M.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:N.map(e=>{let t=e.icon;return(0,M.jsxs)(`button`,{type:`button`,onClick:()=>y(e.id),className:f(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,_===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,M.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,M.jsx)(`span`,{className:`truncate`,children:n(e.labelKey)})]},e.id)})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,M.jsxs)(`div`,{className:S(`general`),children:[(0,M.jsx)(b,{}),(0,M.jsx)(x,{})]}),(0,M.jsx)(`div`,{className:S(`agentRuntime`),children:(0,M.jsx)(D,{})}),(0,M.jsx)(`div`,{className:S(`subagents`),children:(0,M.jsx)(m,{})}),(0,M.jsx)(`div`,{className:S(`branch`),children:(0,M.jsx)(T,{})}),(0,M.jsx)(`div`,{className:S(`environment`),children:(0,M.jsx)(w,{})}),(0,M.jsx)(`div`,{className:S(`budget`),children:(0,M.jsx)(C,{})}),(0,M.jsx)(`div`,{className:S(`telemetry`),children:(0,M.jsx)(h,{})}),(0,M.jsx)(`div`,{className:S(`terminal`),children:(0,M.jsx)(v,{mode:`project`})})]})]})]})})}export{P as ProjectSettingsDialog};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{t as r}from"./useSharedWebSocket-CNOvmgTr.js";import{n as i,t as a}from"./createLucideIcon-DtODIU64.js";import{i as o}from"./useDesktop-C5JVBeur.js";import{a as s,i as c,l,o as u,r as d,t as f}from"./dialog-DtdR05v1.js";import{t as p}from"./button-4FS1ZDTp.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`,`restart_pending`,`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 O={name:`send-horizontal`,size:24,node:[[`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`}]],aliases:[`send-horizonal`]};O.node;var re=a(O),k=e(t(),1),ie=`"\\/bfnrtu`;function A(e){return e===` `||e===` `||e===`\r`||e===`
|
|
2
|
+
`}function ae(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(ie.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 oe(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}=ae(e);try{return{ok:!0,value:JSON.parse(n),repaired:!0,repairs:r}}catch{return{ok:!1,...oe(t,e)}}}}var M=`specrails:git-changed`;function se(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(M,{detail:{projectId:e}}))}function ce(e){if(typeof window>`u`)return()=>{};let t=t=>{let n=t.detail?.projectId;typeof n==`string`&&n&&e(n)};return window.addEventListener(M,t),()=>window.removeEventListener(M,t)}var N=/```blueprint-draft\s*\n([\s\S]*?)\n\s*```/g,P=/```blueprint-draft(?![\s\S]*?\n\s*```)/,F=/```(?:json|JSON)?[ \t]*\r?\n(?=[ \t]*\{)([\s\S]*?)\r?\n[ \t]*```(?=[ \t]*(?:\r?\n|$))/g,I=/```(?: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 L(e){return typeof e==`string`?e:``}function R(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:L(t.name),pitch:L(t.pitch),audience:L(t.audience)}}function me(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={language:L(t.language),framework:L(t.framework),db:L(t.db)};return typeof t.notes==`string`&&t.notes!==``&&(n.notes=t.notes),n}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=L(e.id),i=L(e.title);if(r===``&&i===``)continue;let a={id:r,title:i,goal:L(e.goal),status:ue.has(e.status)?e.status:`planned`,plannedSpecs:R(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 he(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=L(e.title);if(r===``)continue;let i={kind:de.has(e.kind)?e.kind:`feature`,title:r,shortSummary:L(e.shortSummary),description:L(e.description),acceptanceCriteria:R(e.acceptanceCriteria),priority:fe.has(e.priority)?e.priority:`medium`,labels:R(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:L(t.coreFlow),platform:L(t.platform),stack:me(t.stack),assumptions:R(t.assumptions),milestones:z(t.milestones),specsComplete:t.specsComplete===!0,m1Specs:he(t.m1Specs)}}var ge=/^[ \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 _e(e){if(!e||!e.includes(`"blueprintVersion"`))return e??``;let t=e=>!e.includes("```")||!e.includes(`"blueprintVersion"`)?e:(F.lastIndex=0,e.replace(F,(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;N.lastIndex=0;let i;for(;(i=N.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 ve(e){let t=_e(e??``);if(!t||!t.includes("```blueprint-draft")&&!I.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;N.lastIndex=0;let u;for(;(u=N.exec(t))!==null;){a=!0,s+=t.slice(c,u.index),c=u.index+u[0].length;let e=ge.exec(t.slice(c));e&&(c+=e[0].length,N.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=P.exec(d)??I.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 ye(e){if(!e)return{generating:!1,specsStarted:0};if(e.includes("```blueprint-draft")){let t=P.exec(e);if(t)return{generating:!0,specsStarted:V(e.slice(t.index))}}let t=I.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 be(e){if(!e)return``;let t=(/```(?:blueprint-draft|spec-detail|spec-audit)/.test(e)?le.exec(e):null)??I.exec(e);return t?e.slice(0,t.index):e}function xe(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 Se(e){return`M${e}`}var H=new Set([`planned`,`committed`,`running`,`delivered`,`done`]),Ce=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`):[],we=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[];function Te(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 Ee(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 De(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:Ee(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||!Ce.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:we(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:Te(t.counts),rails:Array.isArray(t.rails)?t.rails.flatMap(e=>{let t=De(e);return t?[t]:[]}):[],chain:K(t.chain)}]}):[]}function Oe(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 ke(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 Ae(e){return e.counts.todo>0&&!J(e.chain)&&e.chain?.status!==`paused`&&!Y(e.chain)}function je(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 Me(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 Ne(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 Pe(){try{return r??Z}catch{return Z}}var Fe=Pe(),Ie=0;function Q(e){let t=(0,k.useContext)(Fe),{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:${++Ie}`;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 Le(e){let{progress:t}=Q(e);return(0,k.useMemo)(()=>je(t),[t])}var $=n();function Re({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{re as C,S as D,D as E,b as O,j as S,ee as T,xe as _,Y as a,se as b,K as c,Ae as d,Se as f,be as g,B as h,X as i,ne as k,q as l,Ne as m,Q as n,J as o,Oe as p,Le as r,Me as s,Re as t,ke as u,ye as v,E as w,ce as x,ve as y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BbYvbtY8.js";import{n as t}from"./createLucideIcon-DtODIU64.js";import{r as n}from"./useDesktop-C5JVBeur.js";import{t as r}from"./project-repositories-CvJf1a6H.js";var i=e();function a({value:e,onChange:a,disabled:o=!1,repositories:s,workspaceOnly:c=!1,workspaceSelection:l,onWorkspaceChange:u,showSingle:d=!1,label:f,hint:p}){let{t:m}=t(`common`),{activeProjectId:h,projects:g}=n(),_=s??r(g.find(e=>e.id===h)),v=_.find(e=>e.isPrimary),y=e??(v?[v.id]:[]),b=y.some(e=>!_.some(t=>t.id===e));if(c){let e=_.filter(e=>y.includes(e.id)&&(e.workspacePaths?.length||e.workspacePath));return e.length?(0,i.jsxs)(`fieldset`,{className:`space-y-2`,disabled:o,children:[(0,i.jsx)(`legend`,{className:`text-xs font-medium`,children:m(`repositories.launchWorkspaces`)}),(0,i.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m(`repositories.launchWorkspaceHint`)}),e.map(e=>{let t=e.workspacePaths??[e.workspacePath],n=l?.[e.id]??t;return(0,i.jsxs)(`div`,{className:`space-y-1`,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium`,children:e.name}),t.map(t=>(0,i.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,title:t,children:[(0,i.jsx)(`input`,{type:`checkbox`,"data-agent-interactive":!0,checked:n.includes(t),disabled:o||n.length===1&&n[0]===t,onChange:r=>u?.({...Object.fromEntries(Object.entries(l??{}).filter(([e])=>y.includes(e))),[e.id]:r.target.checked?[...n,t]:n.filter(e=>e!==t)})}),(0,i.jsx)(`span`,{className:`break-all`,children:t})]},t))]},e.id)})]}):null}return!d&&_.length<=1&&!b?null:(0,i.jsxs)(`fieldset`,{className:`space-y-2`,disabled:o,children:[(0,i.jsx)(`legend`,{className:`mb-1 text-xs font-medium`,children:f??m(`repositories.specScope`)}),(0,i.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p??m(`repositories.scopeHint`)}),(0,i.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[_.map(e=>(0,i.jsxs)(`label`,{title:e.workspacePaths?.join(`
|
|
2
2
|
`)??e.workspacePath??e.path,className:`flex items-center gap-2 rounded border border-border px-2 py-1.5 text-xs`,children:[(0,i.jsx)(`input`,{type:`checkbox`,"data-agent-interactive":!0,checked:y.includes(e.id),"aria-label":e.available===!1?`${m(`repositories.unavailable`)}: ${e.name}`:void 0,disabled:o||(e.available===!1||e.kind===`folder`&&!e.isPrimary)&&!y.includes(e.id)||y.length===1&&y[0]===e.id,onChange:t=>a(t.target.checked?[...y,e.id]:y.filter(t=>t!==e.id))}),(0,i.jsx)(`span`,{children:e.name}),e.available===!1&&(0,i.jsxs)(`span`,{className:`text-destructive`,children:[` `,m(`repositories.unavailable`)]}),e.workspacePaths?.map(e=>(0,i.jsx)(`span`,{className:`text-muted-foreground`,children:e},e)),!e.workspacePaths&&e.workspacePath&&(0,i.jsx)(`span`,{className:`text-muted-foreground`,children:e.workspacePath}),e.kind===`folder`&&!e.isPrimary&&(0,i.jsx)(`span`,{className:`text-muted-foreground`,children:m(`repositories.contextOnly`)})]},e.id)),y.filter(e=>!_.some(t=>t.id===e)).map(e=>(0,i.jsxs)(`label`,{className:`flex items-center gap-2 rounded border border-destructive px-2 py-1.5 text-xs`,children:[(0,i.jsx)(`input`,{type:`checkbox`,"data-agent-interactive":!0,checked:!0,disabled:o||y.length===1,onChange:()=>a(y.filter(t=>t!==e))}),m(`repositories.unavailable`),`: `,e]},e))]}),b&&(0,i.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:m(`repositories.invalidSelection`)})]})}export{a as t};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{d as r,f as i,u as a}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as ee,t as o}from"./createLucideIcon-DtODIU64.js";import{a as s,r as te}from"./useDesktop-C5JVBeur.js";import{H as ne,K as re,n as ie}from"./TicketDetailModalContext-BoafEcm4.js";import{C as ae,E as oe,b as se,r as ce,t as le,w as ue}from"./RepositoryDeliveries-DgzNnJmn.js";import{n as de}from"./save-LmPSfsvZ.js";import{t as fe}from"./ban-wqfdzoXt.js";import{n as pe}from"./chevron-up-6EFqEHBj.js";import{n as c}from"./file-text-C0blZHLh.js";import{t as l}from"./loader-circle-BqV9xYGf.js";import{t as u}from"./sparkles-CCfUdFGY.js";import{t as me}from"./triangle-alert-Cxpn8bqr.js";import{t as he}from"./utils-BC4DHlz2.js";import{n as d,t as f}from"./lib-DWJfei6y.js";import{Tt as ge,Xt as p,xt as m,y as _e}from"./index-Culan6y7.js";var h={name:`circle-dollar-sign`,size:24,node:[[`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`}]]};h.node;var ve=o(h),g={name:`file-diff`,size:24,node:[[`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`}]]};g.node;var _=o(g),v=e(t(),1),y=n();function b(e){return e.split(/\n{2,}/).map(e=>{if(e.includes(`
|
|
2
|
+
`))return e;let t=e.match(/(?:^|\s)(\d{1,2})\.\s+(?=\S)/g);return!t||t.length<3?e:e.replace(/\s+(\d{1,2})\.\s+(?=\S)/g,(e,t,n)=>n===0?e:`\n${t}. `)}).join(`
|
|
3
|
+
|
|
4
|
+
`)}function x({children:e,muted:t=!1,className:n}){let r=(0,v.useMemo)(()=>({a:({href:e,children:t})=>(0,y.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,y.jsx)(`code`,{className:e,children:t}):(0,y.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,y.jsx)(`div`,{"data-testid":`packet-markdown`,className:he(`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,y.jsx)(d,{remarkPlugins:[f],skipHtml:!0,components:r,children:b(e)})})}var S=(e={})=>({verbs:[],acceptMeaning:null,fineControlOnly:!1,inFlight:!1,terminal:!1,requiresIrreversibleConfirm:!1,...e});function ye(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 be(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 xe=[`app-verified`,`ai-reported`,`reviewer-score`],Se={"app-verified":m,"ai-reported":u,"reviewer-score":_},Ce={"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}=ee(`packet`);return(0,y.jsxs)(`li`,{className:`flex flex-col gap-1 py-1.5`,children:[(0,y.jsx)(`span`,{className:`text-sm text-foreground`,children:t(e.code,{...e.values??{},defaultValue:e.code})}),e.rawExcerpt?(0,y.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 we(e){return e.implementationOutcome===`failed`?`failed`:e.deliveryOutcome===`no_changes`||e.implementationOutcome===`succeeded`&&e.changed===!1?`noChanges`:e.deliveryOutcome===`not_started`?`notStarted`:e.implementationOutcome===`succeeded`?`succeeded`:`unknown`}var w={resolved:`border-accent-success/40 bg-accent-success/10 text-accent-success`,partial:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,blocked:`border-destructive/40 bg-destructive/10 text-destructive`,unreported:`border-border bg-background-deep/50 text-muted-foreground`},Te={succeeded:`border-accent-success/40 bg-accent-success/10 text-accent-success`,noChanges:`border-accent-info/40 bg-accent-info/10 text-accent-info`,failed:`border-destructive/40 bg-destructive/10 text-destructive`,notStarted:`border-border bg-background-deep/50 text-muted-foreground`,unknown:`border-border bg-background-deep/50 text-muted-foreground`};function T({title:e,children:t,defaultOpen:n=!1,badge:r}){let[i,a]=(0,v.useState)(n);return(0,y.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-surface/40`,children:[(0,y.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,y.jsx)(p,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,y.jsx)(c,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,y.jsx)(`span`,{className:`flex-1 text-sm font-medium text-foreground`,children:e}),r]}),i?(0,y.jsx)(`div`,{className:`border-t border-border/60 px-4 py-3`,children:t}):null]})}function E(e={}){let t=r(),n=e.prDeliveryId??t.prDeliveryId,{t:o}=ee([`packet`,`common`]),c=a(),[u,he]=i(),d=u.get(`repositoryId`),f=(0,v.useRef)(0),p=e.onClose??(()=>c(`/`)),{activeProjectId:m}=te(),h=ce(m),g=n?h.has(n):!1,{act:_,checkout:b}=_e(),{openTicketDetail:S}=ie(),E=JSON.stringify([m,n,d]),D=(0,v.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,v.useRef)(!0);(0,v.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let A=(0,v.useCallback)(()=>k.current&&D.current.key===E&&D.current.epoch===O,[E,O]),[j,M]=(0,v.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,v.useState)(null),[Ee,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(null),[H,U]=(0,v.useState)(``),[W,G]=(0,v.useState)(!1),[De,K]=(0,v.useState)(null),[Oe,q]=(0,v.useState)(!1),J=(0,v.useCallback)(async()=>{if(!n||!m||!A())return;let e=++f.current,t=()=>A()&&f.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=d?`?repositoryId=${encodeURIComponent(d)}`:``,r=await fetch(`${s()}/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,d,E,O,A]);(0,v.useEffect)(()=>(J(),z(!1),q(!1),R(null),V(null),K(null),G(!1),U(``),()=>{f.current++}),[J]);let Y=(0,v.useMemo)(()=>ue(P?.snapshot),[P?.snapshot]),X=P?.packet??null,Z=F||L!==null||W||!!Y?.operation,ke=P?.acceptCapability??null,Q=(0,v.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 ye({decision:X.decision,presentation:e,prUrl:X.prUrl,canCreatePr:ke?.target===`create-pr`})},[X,ke]),$=(0,v.useCallback)(async e=>{if(!X||!Q||Z||!A())return;let t=be(e,Q);if(t){V(null),R(e);try{let e=await(d&&Y?_(Y.railIndex,t,Y.decision,Y.prDeliveryId,d):_(X.railIndex,t,X.decision,X.prDeliveryId));if(!A())return;e.ok?m&&se(m):V(e.status===409&&e.error===`stale_decision`?`alreadyResolved`:`actionFailed`),await J()}finally{A()&&(R(null),z(!1))}}},[_,m,J,X,Q,Y,d,Z,A]),Ae=(0,v.useCallback)(async()=>{if(!(!X||!H.trim()||!m||Z||!A())){K(null),G(!0);try{let t=await fetch(`${s()}/rails/${X.railIndex}/launch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({loopId:`factory:sdd-quick-openspec`,revisionOfDeliveryId:Y?.prDeliveryId??X.prDeliveryId,revisionNote:H.trim(),...Y?.executionManifest?{repositoryIds:Y.executionManifest.selectedRepositoryIds}:{}})});if(!A())return;if(!t.ok){let e=await t.json().catch(()=>null);if(!A())return;K(e?.error===`invalid_revision_target`?`revisionStale`:`revisionFailed`);return}U(``),q(!1);let r=await t.json().catch(()=>null);if(!A())return;r?.prDeliveryId&&r.prDeliveryId!==n?e.onClose?e.onClose():c(`/review/${encodeURIComponent(r.prDeliveryId)}`):await J()}catch{A()&&K(`revisionFailed`)}finally{A()&&G(!1)}}},[m,J,X,H,Y,Z,A,n,e.onClose,c]);if(F&&!X)return(0,y.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,y.jsx)(l,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}),o(`common:states.loading`)]});if(I||!X||!Q)return(0,y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-center gap-4 p-10 text-center`,children:[(0,y.jsx)(me,{className:`size-6 text-accent-warning`,"aria-hidden":!0}),(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(I===`notFound`?`error.notFound`:`error.loadFailed`)}),(0,y.jsx)(`button`,{type:`button`,onClick:p,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface`,children:o(`backToBoard`)})]});let je=xe.map(e=>({tier:e,items:X.proof.filter(t=>t.tier===e)})).filter(e=>e.items.length>0),Me=X.cost.totalUsd===null?`—`:`${X.cost.estimated?`~`:``}$${X.cost.totalUsd.toFixed(2)}`;return(0,y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 p-6`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:p,className:`flex w-fit items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,y.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),o(`backToBoard`)]}),Y?.repositoryDeliveries?.length?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[o(`common:repositories.select`),(0,y.jsxs)(`select`,{value:d??``,onChange:e=>{let t=new URLSearchParams(u);e.target.value?t.set(`repositoryId`,e.target.value):t.delete(`repositoryId`),he(t,{replace:!0})},className:`rounded border border-border bg-background px-2 py-1`,children:[(0,y.jsx)(`option`,{value:``,children:o(`common:repositories.all`)}),Y.repositoryDeliveries.map(e=>(0,y.jsx)(`option`,{value:e.repositoryId,children:e.name},e.repositoryId))]})]}),(0,y.jsx)(le,{deliveryId:Y.prDeliveryId,repositories:Y.repositoryDeliveries,busy:Z,onAct:async(e,t)=>{if(!(Z||!A())){R(`accept`);try{let n=await _(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 b(Y.railIndex,Y.prDeliveryId,e);if(!A())return;t.ok||V(`actionFailed`),await J()}finally{A()&&R(null)}}}})]}):null,(0,y.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-surface/60 p-5 shadow-sm`,children:[(0,y.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:o(X.headlineCode,{count:X.totalCount,succeeded:X.succeededCount,total:X.totalCount,defaultValue:X.headlineCode})}),(0,y.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,y.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:o(`confidence.tooltip`),children:o(`confidence.pill`,{overall:X.confidence.overall})}):(0,y.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:o(`confidence.unavailable`)}),(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,y.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),o(`cost.thisBuild`,{amount:Me})]}),X.prUrl?(0,y.jsxs)(`a`,{href:X.prUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent-info hover:underline`,children:[(0,y.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),o(`openPr`,{number:X.prNumber??``})]}):null]}),Q.fineControlOnly?(0,y.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:o(`fineControlOnly`)}):Q.inFlight?(0,y.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}),o(`stillWorking`)]}):Q.terminal?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:o(`alreadyResolved`)}):(0,y.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[Q.verbs.includes(`accept`)&&(!Y?.repositoryDeliveries?.length||d)?Ee?(0,y.jsxs)(`div`,{className:`flex w-full flex-col gap-2 rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,y.jsx)(`p`,{className:`text-xs text-foreground`,children:o(`accept.irreversibleWarning`)}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.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:o(`accept.irreversibleConfirm`)}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>z(!1),className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground`,children:o(`common:actions.cancel`)})]})]}):(0,y.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,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,y.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),o(`accept.${Q.acceptMeaning??`generic`}`)]}):null,Q.verbs.includes(`request-changes`)?(0,y.jsxs)(`button`,{type:`button`,onClick:()=>q(e=>!e),disabled:Z||W,"aria-expanded":Oe,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,y.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),o(`requestChanges.label`)]}):null,Q.verbs.includes(`discard`)?(0,y.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,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,y.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),o(`discard.label`)]}):null]}),g&&Q.verbs.includes(`discard`)?(0,y.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:o(`discard.stackedNote`)}):null,B?(0,y.jsx)(`p`,{className:`mt-3 text-xs text-accent-warning`,children:o(`error.${B}`)}):null,Oe?(0,y.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 rounded-md border border-border/70 bg-background-deep/40 p-3`,children:[(0,y.jsx)(`label`,{htmlFor:`packet-revision-note`,className:`text-xs font-medium text-foreground`,children:o(`requestChanges.prompt`)}),(0,y.jsx)(`textarea`,{id:`packet-revision-note`,value:H,onChange:e=>U(e.target.value),rows:2,placeholder:o(`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,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>void Ae(),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,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,y.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),o(`requestChanges.submit`)]}),(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:o(`requestChanges.hint`)})]}),De?(0,y.jsx)(`p`,{className:`text-xs text-accent-warning`,children:o(`error.${De}`)}):null]}):null]}),X.driftNudges.length>0?(0,y.jsxs)(`div`,{className:`rounded-lg border border-accent-highlight/30 bg-accent-highlight/5 p-4`,"data-testid":`packet-drift-nudges`,children:[(0,y.jsx)(`h2`,{className:`mb-1 text-sm font-medium text-accent-highlight`,children:o(`drift.title`)}),(0,y.jsx)(`ul`,{className:`space-y-1 text-xs text-foreground`,children:X.driftNudges.map(e=>(0,y.jsx)(`li`,{children:o(e.code,{...e.values,defaultValue:e.code})},e.code))}),(0,y.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:o(`drift.advisory`)})]}):null,X.versions.length>1?(0,y.jsxs)(T,{title:o(`versions.title`,{count:X.versions.length}),badge:(0,y.jsx)(ge,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),children:[(0,y.jsx)(`ol`,{className:`space-y-2`,"data-testid":`packet-versions`,children:X.versions.map(e=>(0,y.jsxs)(`li`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:e.current?`font-medium text-foreground`:`text-muted-foreground`,children:o(`versions.label`,{version:e.version})}),e.current?(0,y.jsx)(`span`,{className:`rounded-full border border-accent-primary/40 bg-accent-primary/10 px-1.5 text-[10px] text-accent-primary`,children:o(`versions.current`)}):null,(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.costUsd===null?`—`:`${e.costEstimated?`~`:``}$${e.costUsd.toFixed(2)}`})]}),(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.revisionNote??o(`versions.originalBuild`)})]},e.prDeliveryId))}),(0,y.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:o(`cost.allVersions`,{amount:X.chainCostUsd===null?`—`:`${X.chainCostEstimated?`~`:``}$${X.chainCostUsd.toFixed(2)}`})})]}):null,X.watchOut.length>0?(0,y.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/5 p-4`,children:[(0,y.jsxs)(`h2`,{className:`mb-2 flex items-center gap-1.5 text-sm font-medium text-accent-warning`,children:[(0,y.jsx)(me,{className:`size-4`,"aria-hidden":!0}),o(`watchOut.title`)]}),(0,y.jsx)(`ul`,{className:`space-y-1`,children:X.watchOut.map((e,t)=>(0,y.jsx)(C,{item:e},`${e.code}-${t}`))})]}):null,(0,y.jsx)(T,{title:o(`sections.whatYouAsked`),defaultOpen:!0,children:(0,y.jsx)(`ul`,{className:`space-y-3`,children:X.sections.map(e=>(0,y.jsxs)(`li`,{className:`text-sm`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>S(e.ticketId),className:`text-accent-primary hover:underline`,children:[`#`,e.ticketId,` `,e.title??``]}),e.problem?(0,y.jsx)(x,{muted:!0,className:`mt-1`,children:e.problem}):null]},e.ticketId))})}),X.followUp&&(0,y.jsxs)(T,{title:o(`followUp.title`,{count:X.followUp.comments.length}),defaultOpen:!0,children:[(0,y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:o(`followUp.caveat`)}),(0,y.jsx)(`ul`,{className:`space-y-3`,"data-testid":`packet-follow-up`,children:X.followUp.comments.map(e=>{let t=X.followUpReport?.find(t=>t.commentId===e.id)??null,n=t?t.verdict:`unreported`;return(0,y.jsxs)(`li`,{className:`rounded-md border border-border/50 bg-background-deep/30 px-3 py-2 text-sm`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`rounded bg-surface/70 px-1 font-mono text-[10px] text-muted-foreground`,children:e.id}),e.path?(0,y.jsxs)(`span`,{className:`font-mono text-xs text-accent-info`,children:[e.path,e.line?`:${e.line}`:``]}):null,(0,y.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${w[n]}`,"data-testid":`packet-follow-up-verdict`,children:o(`followUp.verdict.${n}`)}),(0,y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[o(`followUp.source.${e.source===`github`?`github`:`pasted`}`),e.author?` · ${e.author}`:``]})]}),(0,y.jsx)(x,{muted:!0,className:`mt-1`,children:e.body}),t?(0,y.jsxs)(`dl`,{className:`mt-1 grid gap-x-3 gap-y-0.5 text-xs text-muted-foreground sm:grid-cols-[auto_1fr]`,children:[t.files?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.files`)}),(0,y.jsx)(`dd`,{className:`font-mono`,children:t.files})]}):null,t.tests?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.tests`)}),(0,y.jsx)(`dd`,{children:t.tests})]}):null,t.notes?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.notes`)}),(0,y.jsx)(`dd`,{children:t.notes})]}):null]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`followUp.noReport`)})]},e.id)})}),X.followUp.scope.excludedChanges.length>0&&(0,y.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,y.jsxs)(`span`,{className:`font-medium`,children:[o(`followUp.excluded`),`:`]}),` `,X.followUp.scope.excludedChanges.join(` · `)]})]}),X.specAddenda&&X.specAddenda.length>0&&(0,y.jsxs)(T,{title:o(`addenda.title`,{count:X.specAddenda.length}),defaultOpen:!0,children:[(0,y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:o(`addenda.caveat`)}),(0,y.jsx)(`ul`,{className:`space-y-2`,"data-testid":`packet-addenda`,children:X.specAddenda.map(e=>{let t=X.specAddendaReport?.find(t=>t.addendumId===e.id)??null,n=t?t.verdict:`unreported`,r=n===`applied`?w.resolved:w[n];return(0,y.jsxs)(`li`,{className:`rounded-md border border-border/50 bg-background-deep/30 px-3 py-2 text-sm`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`span`,{className:`font-mono text-xs text-accent-primary`,children:[`#`,e.ticketId]}),(0,y.jsx)(`span`,{className:`rounded-full border border-border/50 px-1.5 py-px text-[10px] text-muted-foreground`,children:o(`addenda.kind.${e.kind}`)}),(0,y.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,y.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${r}`,"data-testid":`packet-addenda-verdict`,children:o(`addenda.verdict.${n}`)})]}),t?(0,y.jsxs)(`dl`,{className:`mt-1 grid gap-x-3 gap-y-0.5 text-xs text-muted-foreground sm:grid-cols-[auto_1fr]`,children:[t.files?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.files`)}),(0,y.jsx)(`dd`,{className:`font-mono`,children:t.files})]}):null,t.tests?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.tests`)}),(0,y.jsx)(`dd`,{children:t.tests})]}):null,t.notes?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.notes`)}),(0,y.jsx)(`dd`,{children:t.notes})]}):null]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`addenda.noReport`)})]},e.id)})})]}),(0,y.jsx)(T,{title:o(`sections.whatIDid`),children:(0,y.jsx)(`ul`,{className:`space-y-3`,children:X.sections.map(e=>(0,y.jsxs)(`li`,{className:`text-sm`,"data-testid":`packet-done-${e.ticketId}`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`span`,{className:`font-medium text-foreground`,children:[`#`,e.ticketId]}),e.title?(0,y.jsx)(`span`,{className:`text-foreground/80`,children:e.title}):null,(()=>{let t=we(e);return(0,y.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${Te[t]}`,"data-testid":`packet-outcome-pill`,children:o(`outcome.${t}`)})})()]}),e.churn?(0,y.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[o(`churn.line`,{files:e.churn.filesTouched,added:e.churn.addedLines,removed:e.churn.removedLines}),` · `,e.churn.testFilesTouched.length>0?o(`churn.testFiles`,{count:e.churn.testFilesTouched.length}):o(`churn.noTestFiles`)]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`churn.batchNotSplittable`)}),e.solution?(0,y.jsxs)(`details`,{className:`group mt-2 rounded-md border border-border/50 bg-background-deep/30 px-3 py-2`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-muted-foreground group-open:text-foreground/80`,children:o(`planned.title`)}),(0,y.jsx)(`p`,{className:`mt-1 text-[11px] italic text-muted-foreground/80`,children:o(`planned.caveat`)}),(0,y.jsx)(x,{className:`mt-2`,children:e.solutionOverflow??e.solution})]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`noSolutionRecorded`)})]},e.ticketId))})}),(0,y.jsx)(T,{title:o(`sections.howItWasChecked`),badge:X.evidenceUnavailable?(0,y.jsx)(`span`,{className:`rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-[10px] text-muted-foreground`,children:o(`proof.evidenceUnavailable`)}):void 0,children:(0,y.jsx)(`div`,{className:`space-y-4`,children:je.map(({tier:e,items:t})=>{let n=Se[e];return(0,y.jsxs)(`div`,{className:`rounded-md border px-3 py-2 ${Ce[e]}`,children:[(0,y.jsxs)(`h3`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium`,children:[(0,y.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),o(`tier.${e}.title`)]}),(0,y.jsx)(`p`,{className:`mb-2 text-[11px] opacity-80`,children:o(`tier.${e}.caveat`)}),(0,y.jsx)(`ul`,{className:`space-y-1`,children:t.map((e,t)=>(0,y.jsx)(C,{item:e},`${e.code}-${t}`))})]},e)})})})]})}export{E as default};
|
package/client/dist/assets/{TemplatePreviewModal-B8yd1AGU.js → TemplatePreviewModal-CcfSxWQ7.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BbYvbtY8.js";import{n as t}from"./createLucideIcon-DtODIU64.js";import{t as n}from"./download-C9wP_42h.js";import{t as r}from"./git-branch-yf6LE1Bw.js";import{n as i,t as a}from"./square-D0JTbRSR.js";import{a as o,i as s,l as c,o as l,r as u,t as d}from"./dialog-DtdR05v1.js";import{t as f}from"./button-4FS1ZDTp.js";import{$t as p,_t as m,rt as h}from"./index-Culan6y7.js";var g=e(),_={core:p,start:i,"ai-step":p,shell:m,decider:r,condition:r,end:a};function v(e){if(e.type===`core`){let t=e.data?.params;return t?String(t.text??t.prompt??t.goal??t.expr??t.question??t.message??t.ref??t.body??t.outcome??JSON.stringify(t,null,2)):null}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 y({template:e,onClose:r,onUse:i}){let{t:m}=t(`loops`);return(0,g.jsx)(d,{open:e!==null,onOpenChange:e=>{e||r()},children:(0,g.jsx)(u,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(l,{children:[(0,g.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,g.jsx)(p,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,g.jsx)(s,{children:e.description})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h(e.graph)?(0,g.jsx)(`span`,{title:m(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:m(`gallery.needsSpec`)}):(0,g.jsx)(`span`,{title:m(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:m(`gallery.standalone`)}),e.category&&(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:m(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,g.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?m(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):m(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,g.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,g.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:m(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=_[e.type]??a,r=v(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] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,g.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),m(e.type===`core`?`builder.core.pieces.${e.data?.kind}`:`builder.nodes.${e.type}`)]}),r&&(0,g.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,g.jsxs)(o,{children:[(0,g.jsx)(f,{variant:`ghost`,onClick:r,children:m(`common:actions.cancel`)}),(0,g.jsxs)(f,{onClick:()=>i(e.id),children:[(0,g.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),m(`actions.use`)]})]})]})})})}export{y as n,v as r,_ as t};
|