specrails-desktop 2.31.2 → 2.32.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/client/dist/assets/{ActivityFeedPage-Cdccp1kl.js → ActivityFeedPage-DvnFkjVG.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-DUwwfVOf.js → AgentBrowserCapture-CBjcliD7.js} +1 -1
- package/client/dist/assets/{AgentModeCodePane-B1Fu0f_G.js → AgentModeCodePane-CokuFVdV.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-DA6wQKKt.js → AgentModeJobsPane-rf_DlWNo.js} +1 -1
- package/client/dist/assets/{AgentsPage-CR72XsPj.js → AgentsPage-B648IzGI.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-CPnl0xkM.js → AnalyticsPage-0rBoULPX.js} +1 -1
- package/client/dist/assets/{CodePage-BYY7EF1b.js → CodePage-ju302Vl7.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-9PUjsD8C.js → DesktopAnalyticsPage-gBRVqiw6.js} +1 -1
- package/client/dist/assets/{DocsDialog-zngqdI-4.js → DocsDialog-BzO5dg2B.js} +1 -1
- package/client/dist/assets/{DocsPage-CDJH_q9M.js → DocsPage-Db_uxr1j.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-drUo56r7.js → InteractiveJobComposer-_jmsE_Az.js} +1 -1
- package/client/dist/assets/{JobDetailModal-CWmzaRXG.js → JobDetailModal-DPHh2WOS.js} +1 -1
- package/client/dist/assets/{JobDetailPage-xlzBYZEJ.js → JobDetailPage-7nwHyHGV.js} +1 -1
- package/client/dist/assets/{JobsPage-Dcnol1Y6.js → JobsPage-C_6YrcmE.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-D3q7EoNM.js → LoopBuilderPage-DJ1UPDwL.js} +1 -1
- package/client/dist/assets/{LoopPreviewModal-Q8osegkj.js → LoopPreviewModal-12cUnljK.js} +1 -1
- package/client/dist/assets/{LoopsPage-CATnNd1X.js → LoopsPage-CHYK0Xjr.js} +1 -1
- package/client/dist/assets/{MinimizedChatsContext-DIsnQMVz.js → MinimizedChatsContext-Gt6KQySM.js} +1 -1
- package/client/dist/assets/{PluginsPage-BOh6z0zK.js → PluginsPage-E59oQmwc.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-CNcANqEL.js → ProjectSettingsDialog-DQTLQ7ie.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-4EpqyErX.js → TemplatePreviewModal-nXUcDgfk.js} +1 -1
- package/client/dist/assets/{TicketDetailModal-BfV4tnvr.js → TicketDetailModal-C-tHW-2s.js} +3 -3
- package/client/dist/assets/{Trans-cWtExGkC.js → Trans-B2i5HVcM.js} +1 -1
- package/client/dist/assets/{dist-js-Cn09PP3z.js → dist-js-CkTZKBF9.js} +1 -1
- package/client/dist/assets/{dist-js-mq5XA-4f.js → dist-js-ClShHcGa.js} +1 -1
- package/client/dist/assets/{formatDistanceToNow-DUyzS4rr.js → formatDistanceToNow-BjGwPf6I.js} +1 -1
- package/client/dist/assets/{getTimezoneOffsetInMilliseconds-BCIwmmTj.js → getTimezoneOffsetInMilliseconds-CSCbUI4W.js} +1 -1
- package/client/dist/assets/{i18n-D21Pr8Sj.js → i18n-Ch-Db_x2.js} +2 -2
- package/client/dist/assets/{index-CzNyrRn5.js → index-kCUcnT8G.js} +6 -6
- package/client/dist/assets/loops-B2_97D26.js +1 -0
- package/client/dist/assets/loops-BISOkuCu.js +1 -0
- package/client/dist/assets/loops-Bo6w_peZ.js +1 -0
- package/client/dist/assets/loops-BwxCndZk.js +1 -0
- package/client/dist/assets/loops-CD19kEzq.js +1 -0
- package/client/dist/assets/loops-CMMQOw2P.js +1 -0
- package/client/dist/assets/loops-CnxqL8IL.js +1 -0
- package/client/dist/assets/loops-aEb4RxN2.js +1 -0
- package/client/dist/assets/{spending-BCyUxoOI.js → spending-Dq43JYmD.js} +1 -1
- package/client/dist/assets/{useBrowserCaptureSession-CkVCDzer.js → useBrowserCaptureSession-TTO8vHtd.js} +1 -1
- package/client/dist/assets/{useDesktop-DCP_MHp9.js → useDesktop-DUvS4fuP.js} +1 -1
- package/client/dist/index.html +11 -11
- package/package.json +1 -1
- package/server/dist/loop-executors.js +5 -2
- package/server/dist/loop-factory.js +7 -5
- package/server/dist/loop-graph.js +4 -3
- package/server/dist/loop-run-manager.js +7 -3
- package/server/dist/loop-templates.js +4 -3
- package/server/dist/profiles-router.js +24 -1
- package/server/dist/rail-isolated-launch.js +15 -0
- package/server/dist/spawn-lifecycle.js +1 -1
- package/server/dist/worktree-node-modules.js +158 -0
- package/client/dist/assets/loops-BzfXWEwO.js +0 -1
- package/client/dist/assets/loops-CPpgMapU.js +0 -1
- package/client/dist/assets/loops-CWWbKuVL.js +0 -1
- package/client/dist/assets/loops-Crc9It8o.js +0 -1
- package/client/dist/assets/loops-DH2hZcbK.js +0 -1
- package/client/dist/assets/loops-DS5TmvIU.js +0 -1
- package/client/dist/assets/loops-P2f0cN8-.js +0 -1
- package/client/dist/assets/loops-fJV-9hH7.js +0 -1
package/client/dist/assets/{MinimizedChatsContext-DIsnQMVz.js → MinimizedChatsContext-Gt6KQySM.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{t as o}from"./sparkles-DrY8hb0X.js";import{t as s}from"./x-CBMI9ejn.js";import{n as c}from"./useSharedWebSocket-DaPh7QBL.js";import{r as l}from"./useDesktop-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{t as o}from"./sparkles-DrY8hb0X.js";import{t as s}from"./x-CBMI9ejn.js";import{n as c}from"./useSharedWebSocket-DaPh7QBL.js";import{r as l}from"./useDesktop-DUvS4fuP.js";var u=a(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),d=a(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),f=a(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),p=a(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),m=e(t(),1),h=[`title`,`description`,`labels`,`priority`,`acceptanceCriteria`],g={title:``,description:``,labels:[],priority:`medium`,acceptanceCriteria:[]};function _(e){return!e||typeof e!=`object`?!1:e.type===`spec_draft.update`}var v=n(),y=42;function b(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=y?t:t.slice(0,y-1).trimEnd()+`…`}function x({chat:e,projectName:t,onRestore:n,onClose:r}){let{t:a}=i(`chat`),o=b(e.label);return(0,v.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,v.jsx)(S,{kind:e.kind}),(0,v.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":a(`chip.restore`,{label:e.label}),title:e.label,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground truncate`,children:o}),(0,v.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5 truncate`,children:a(`chip.continueEditing`,{projectName:t})})]}),(0,v.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":a(`chip.close`,{label:e.label}),children:(0,v.jsx)(s,{className:`w-3.5 h-3.5`})})]})}function S({kind:e}){let{t}=i(`chat`);return(0,v.jsx)(e===`ai-edit`?o:p,{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 C({chats:e,projects:t,hidden:n,onRestore:r,onClose:a}){let{t:o}=i(`chat`),s=(0,m.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.id,n.name);return e},[t]),c=(0,m.useMemo)(()=>[...e].sort((e,t)=>t.createdAt-e.createdAt),[e]);return n||c.length===0?null:(0,v.jsxs)(`div`,{"data-testid":`minimized-chats-dock`,"aria-label":o(`dock.minimizedSessions`,{count:c.length}),className:`fixed bottom-4 right-14 z-[70] flex flex-col-reverse gap-2 w-[320px] max-w-[calc(100vw-15rem)] max-h-[70vh] overflow-y-auto pointer-events-none`,children:[c.map(e=>(0,v.jsx)(`div`,{className:`pointer-events-auto glass-card border border-border/30 rounded-lg p-3 shadow-lg w-full`,children:(0,v.jsx)(x,{chat:e,projectName:s.get(e.projectId)??o(`dock.unknownProject`),onRestore:()=>r(e.id),onClose:()=>a(e.id)})},e.id)),c.length>1&&(0,v.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,v.jsx)(f,{className:`w-3 h-3`}),o(`dock.minimizedCount`,{count:c.length})]})]})}var w=(0,m.createContext)(null),T=`specrails-desktop:minimized-chats`,E=`specrails-desktop:minimized-chats-pending`,D=50,O=8e3;function k(){return N(T)}function A(e){F(T,e)}function j(){return N(E)}function M(e){F(E,e)}function N(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(I):[]}catch{return[]}}function P(e){return e.length<=D?e:[...e].sort((e,t)=>e.createdAt-t.createdAt).slice(e.length-D)}function F(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(P(t)))}catch{}}function I(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 L(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function R(e){return e.kind===`explore-spec`?e.params.resumeConversationId??`pending:${e.params.pendingSpecId}`:e.params.resumeRefineId??`agent:${e.params.agentId}`}function z(e,t){return e.kind!==t.kind||e.projectId!==t.projectId?!1:R(e)===R(t)}function B({children:e}){let{projects:t,activeProjectId:n,setActiveProjectId:i,setupProjectIds:a}=l(),o=r(),{registerHandler:s,unregisterHandler:u}=c(),[d,f]=(0,m.useState)(()=>k()),[p,h]=(0,m.useState)([]),g=(0,m.useRef)(d);g.current=d;let y=(0,m.useRef)(p);y.current=p;let b=(0,m.useRef)(new Map),x=(0,m.useRef)(t);x.current=t;let S=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(S.current)return;S.current=!0;let e=j();M([]),e.length!==0&&f(t=>{let n=[...t];for(let t of e)n.some(e=>e.id===t.id||z(e,t))||n.push(t);return A(n),g.current=n,n})},[]),(0,m.useEffect)(()=>{let e=b.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear()}},[]),(0,m.useEffect)(()=>{A(d)},[d]),(0,m.useEffect)(()=>{M(p)},[p]);let T=(0,m.useRef)(()=>{}),E=(0,m.useRef)(()=>{});(0,m.useEffect)(()=>{let e=`minimized-chats:spec-draft`;return s(e,e=>{if(!_(e))return;let t=e.conversationId,n=g.current.find(e=>e.kind===`explore-spec`&&e.params.resumeConversationId===t);if(!n)return;let r=e.draft;r.title?.trim()&&T.current(n.id,r.title);let i={};r.title!==void 0&&(i.title=r.title),r.description!==void 0&&(i.description=r.description),r.priority!==void 0&&(i.priority=r.priority),r.labels!==void 0&&(i.labels=r.labels),r.acceptanceCriteria!==void 0&&(i.acceptanceCriteria=r.acceptanceCriteria),Object.keys(i).length>0&&E.current(n.id,i)}),()=>u(e)},[s,u]),(0,m.useEffect)(()=>{if(t.length===0)return;let e=new Set(t.map(e=>e.id));f(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(A(n),g.current=n,n)}),h(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(M(n),y.current=n,n)})},[t]);let D=(0,m.useCallback)(e=>{let t=L(),n={...e,id:t,createdAt:Date.now()};if(f(e=>{let t=P([...e.filter(e=>!z(e,n)),n]);return A(t),g.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},[]),N=(0,m.useCallback)(e=>{let t=b.current.get(e);t&&(clearTimeout(t),b.current.delete(e))},[]),F=(0,m.useCallback)(e=>{N(e),f(t=>{let n=t.filter(t=>t.id!==e);return A(n),g.current=n,n}),h(t=>{let n=t.filter(t=>t.id!==e);return n.length===t.length?t:(M(n),y.current=n,n)})},[N]),I=(0,m.useCallback)((e,t)=>{let n=t.trim();n&&f(t=>{let r=t.map(t=>t.id===e&&t.label!==n?{...t,label:n}:t);return r===t?t:(g.current=r,r)})},[]),R=(0,m.useCallback)((e,t)=>{f(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 g.current=r,r})},[]),B=(0,m.useCallback)(e=>{let t=g.current.find(t=>t.id===e);if(!t||x.current.length>0&&!x.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&&i(t.projectId),o(t.restoreRoute),h(n=>{let r=[...n.filter(t=>t.id!==e),t];return M(r),y.current=r,r}),f(t=>{let n=t.filter(t=>t.id!==e);return A(n),g.current=n,n}),N(e);let r=setTimeout(()=>{b.current.delete(e),y.current.some(t=>t.id===e)&&(h(t=>{let n=t.filter(t=>t.id!==e);return M(n),y.current=n,n}),f(n=>{if(n.some(n=>n.id===e||z(n,t)))return n;let r=[...n,t];return A(r),g.current=r,r}))},O);b.current.set(e,r)},[n,i,o,N]),V=(0,m.useRef)(B);V.current=B;let H=(0,m.useRef)(F);H.current=F,T.current=I,E.current=R;let U=(0,m.useCallback)((e,t)=>{let n=y.current,r=n.findIndex(n=>n.kind===e&&n.projectId===t);if(r===-1)return null;let i=n[r];return N(i.id),h(e=>{let t=e.filter(e=>e.id!==i.id);return M(t),t}),y.current=n.filter(e=>e.id!==i.id),i},[N]),W=(0,m.useCallback)(e=>{let t=L(),r={...e,id:t,createdAt:Date.now()};n!==e.projectId&&i(e.projectId),o(e.restoreRoute),h(e=>{let t=[...e,r];return M(t),y.current=t,t}),N(t);let a=setTimeout(()=>{b.current.delete(t),y.current.some(e=>e.id===t)&&(h(e=>{let n=e.filter(e=>e.id!==t);return M(n),y.current=n,n}),f(e=>{if(e.some(e=>e.id===t||z(e,r)))return e;let n=[...e,r];return A(n),g.current=n,n}))},O);b.current.set(t,a)},[n,i,o,N]),G=(0,m.useMemo)(()=>({chats:d,pendingRestores:p,minimize:D,updateLabel:I,patchExploreSpecDraft:R,close:F,restore:B,takePendingRestore:U,triggerResume:W}),[d,p,D,I,R,F,B,U,W]),K=n!==null&&a.has(n);return(0,v.jsxs)(w.Provider,{value:G,children:[e,(0,v.jsx)(C,{chats:d,projects:t,hidden:K,onRestore:B,onClose:F})]})}function V(){return(0,m.useContext)(w)||{chats:[],pendingRestores:[],minimize:()=>``,updateLabel:()=>{},patchExploreSpecDraft:()=>{},close:()=>{},restore:()=>{},takePendingRestore:()=>null,triggerResume:()=>{}}}function H(e,t,n){let{pendingRestores:r,takePendingRestore:i}=V(),a=(0,m.useRef)(n);a.current=n,(0,m.useEffect)(()=>{if(!t)return;let n=i(e,t);n&&a.current(n)},[r,e,t,i])}export{h as a,f as c,g as i,d as l,V as n,_ as o,H as r,p as s,B as t,u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{n as a}from"./dist-bVqfYmby.js";import{t as o}from"./download-CFHyyHcw.js";import{t as s}from"./loader-circle-DcygOQpC.js";import{t as c}from"./search-Cq_gE3Ik.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{a as d}from"./auth-D_5bQv5W.js";import{n as f}from"./useSharedWebSocket-DaPh7QBL.js";import{n as p,r as m}from"./useDesktop-DCP_MHp9.js";import{t as h}from"./button-BUIIBQPT.js";import{t as g}from"./utils-BC4DHlz2.js";import{a as _,n as v,o as y,r as b,t as x}from"./dialog-CzIekCw0.js";import{t as S}from"./jira-api-BgFIr8eD.js";import{r as C}from"./provider-capabilities-BvoExILy.js";import{at as w,jt as T,kt as E,nt as D,rt as O,tt as ee,u as k,ut as A}from"./index-CzNyrRn5.js";var j=i(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),te=i(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),ne=i(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),re=i(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),M=i(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),N=e(t(),1),P=n(),ie=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],F={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function I({state:e,onChanged:t,apiBase:n}){let{t:i}=r(`jira`),o=e.connection,[s,c]=(0,N.useState)(o.enabled),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)([]),[g,_]=(0,N.useState)([]),[v,y]=(0,N.useState)(o.discardStatus??``),[b,x]=(0,N.useState)(o.statusMap??{}),C=e.outbox??{pending:0,inflight:0,done:0,dead:0},w=(0,N.useCallback)(async()=>{try{let{ops:e}=n?await S.listOutbox(`dead`,n):await S.listOutbox(`dead`);m(e)}catch{m([])}},[n]);(0,N.useEffect)(()=>{w()},[w]),(0,N.useEffect)(()=>{let e=!1;return S.listStatuses(n).then(({statuses:t})=>{e||_(t)}).catch(()=>{e||_([])}),()=>{e=!0}},[n]);async function T(e){let r=v;y(e);try{n?await S.patchConnection({discardStatus:e||null},n):await S.patchConnection({discardStatus:e||null}),t()}catch(e){y(r),a.error(R(e,i))}}async function E(e,r){let o=b,s={...b,[e]:r||void 0};x(s);let c=Object.fromEntries(Object.entries(s).filter(([,e])=>e));try{n?await S.patchConnection({statusMap:Object.keys(c).length?c:null},n):await S.patchConnection({statusMap:Object.keys(c).length?c:null}),t()}catch(e){x(o),a.error(R(e,i))}}async function D(){let e=!s;c(e),f(!0);try{n?await S.setEnabled(e,n):await S.setEnabled(e)}catch(t){c(!e),a.error(R(t,i))}finally{f(!1)}}async function O(){u(!0);try{let e=n?await S.syncNow(n):await S.syncNow();a.success(i(`status.syncedToast`,{count:e.upserted}))}catch(e){a.error(R(e,i))}finally{u(!1)}}async function ee(){if(window.confirm(i(`status.disconnectConfirm`))){f(!0);try{n?await S.disconnect(n):await S.disconnect(),a.success(i(`status.disconnectedToast`)),t()}catch(e){a.error(R(e,i))}finally{f(!1)}}}async function k(e){try{n?await S.retryOutbox(e,n):await S.retryOutbox(e),await w()}catch(e){a.error(R(e,i))}}let A=C.pending+C.inflight;return(0,P.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:i(`status.connected`,{key:o.jiraProjectKey})}),(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.baseUrl,` · `,o.deployment===`cloud`?i(`review.cloud`):i(`review.dc`)]})]}),(0,P.jsx)(`a`,{href:`${o.baseUrl}/browse/${o.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:i(`badge.openInJira`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:i(`status.enabledLabel`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(s?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,P.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s,"aria-label":i(`status.enabledLabel`),disabled:d,onClick:D,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${s?`bg-accent-success`:`bg-input`}`,children:(0,P.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${s?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,P.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:i(`wizard.step3Title`)}),(0,P.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`mapping.intro`)}),(0,P.jsx)(`div`,{className:`space-y-2`,children:ie.map(e=>(0,P.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`mapping.${F[e]}`)}),(0,P.jsxs)(`select`,{value:b[e]??``,onChange:t=>void E(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,P.jsx)(`option`,{value:``,children:i(`mapping.auto`)}),g.map(e=>(0,P.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!g.some(t=>t.name===b[e])&&(0,P.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,P.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:i(`discard.configLabel`)}),(0,P.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`discard.configHelp`)}),(0,P.jsxs)(`select`,{value:v,onChange:e=>void T(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,P.jsx)(`option`,{value:``,children:i(`discard.configNone`)}),g.map(e=>(0,P.jsx)(`option`,{value:e.name,children:e.name},e.id)),v&&!g.some(e=>e.name===v)&&(0,P.jsx)(`option`,{value:v,children:v})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(h,{variant:`outline`,size:`sm`,onClick:O,disabled:l,children:i(l?`status.syncing`:`status.syncNow`)}),(0,P.jsx)(h,{variant:`ghost`,size:`sm`,onClick:ee,disabled:d,className:`text-destructive`,children:i(`status.disconnect`)})]}),(0,P.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:i(`outbox.title`)}),C.dead>0?(0,P.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:i(`outbox.dead`,{count:C.dead})}):A>0?(0,P.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.pending`,{count:A})}):(0,P.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.allSynced`)}),p.length>0&&(0,P.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`outbox.deadHelp`)}),p.map(e=>(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,P.jsxs)(`span`,{className:`truncate text-xs`,children:[L(e,i),` · `,e.deadReason??e.lastError??``]}),(0,P.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>k(e.id),children:i(`outbox.retry`)})]},e.id))]})]})]})}function L(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function R(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var z=new Set([`claude`,`codex`,`kimi`]);function B(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 V(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:B(`codex`),claude:B(`claude`)},lastIssue:null}}var H={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:V(),lastIssue:null,updatedAt:null};function U(e){let t=e?.metrics??V();return{...H,...e,activeProviders:{...H.activeProviders,...e?.activeProviders},availableProviders:{...H.availableProviders,...e?.availableProviders},detectedRoutes:{...H.detectedRoutes,...e?.detectedRoutes},learning:{...H.learning,...e?.learning},metrics:{...V(),...t,providers:{codex:{...B(`codex`),...t.providers?.codex},claude:{...B(`claude`),...t.providers?.claude}}}}}async function W(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 G(e){return`${d}/api/projects/${e}`}function K(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 q(e,t,n){return`${K(e,t)} ${n}`}function J(){let{t:e}=r(`integrations`),{projects:t}=m(),{registerHandler:n,unregisterHandler:i}=f(),[a,o]=(0,N.useState)(``),[s,l]=(0,N.useState)(`all`),[u,p]=(0,N.useState)(H),[h,S]=(0,N.useState)(!0),[C,w]=(0,N.useState)(null),[T,E]=(0,N.useState)([]),[k,j]=(0,N.useState)(!1),[re,M]=(0,N.useState)(!1),[ie,F]=(0,N.useState)(null),[I,L]=(0,N.useState)({jira:0,serena:0,projects:0}),R=(0,N.useCallback)(async()=>{try{let e=await fetch(`${d}/api/global-plugins/headroom`).then(e=>W(e));p(U(e.state))}finally{S(!1)}},[]);(0,N.useEffect)(()=>{R()},[R]),(0,N.useEffect)(()=>(n(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&E(e=>[...e.slice(-80),t.line]),R())}),()=>i(`plugins-page`)),[n,i,R]),(0,N.useEffect)(()=>{let e=!1;async function n(){let n=await Promise.all(t.map(async e=>{let[t,n]=await Promise.all([fetch(`${G(e.id)}/jira/connection`).then(e=>W(e)).catch(()=>({connected:!1})),fetch(`${G(e.id)}/plugins`).then(e=>W(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||L({jira:n.reduce((e,t)=>e+t.jira,0),serena:n.reduce((e,t)=>e+t.serena,0),projects:t.length})}return n(),()=>{e=!0}},[t]);async function z(e,t){w(e),E([]);try{let e=(await t()).state;e&&p(U(e))}catch(e){let t=e.payload;t?.state&&p(U(t.state))}finally{w(null),R()}}let B=(0,N.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:ne,description:e(`plugins.catalog.headroom.description`),installed:u.installed,status:u.lastIssue?`attention`:u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?`external-active`:`active`:u.installSource===`system`?`external`:`installed`:`available`,statusLabel:u.lastIssue?e(`plugins.status.attention`):u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?e(`plugins.status.externalActive`):e(`plugins.status.active`):u.installSource===`system`?e(`plugins.status.external`):e(`plugins.status.installed`):e(`plugins.status.available`),actionKind:u.lastIssue?`review`:u.installed?`manage`:`install`,actionLabel:u.lastIssue?e(`plugins.actions.review`):u.installed?e(`plugins.actions.manage`):e(`plugins.actions.install`),busy:C===`install`,action:()=>{if(u.lastIssue||u.installed){j(!0);return}z(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>W(e)))}}],[u,C,e]),V=(0,N.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:te,description:e(`plugins.catalog.jira.description`),installed:I.jira>0,status:I.jira>0?`configured`:`available`,statusLabel:I.jira>0?e(`plugins.status.configuredCount`,{count:I.jira}):e(`plugins.status.available`),actionKind:I.jira>0?`manage`:`install`,actionLabel:I.jira>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>F(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:ee,description:e(`plugins.catalog.serena.description`),installed:I.serena>0,status:I.serena>0?`installed`:`available`,statusLabel:I.serena>0?e(`plugins.status.installedCount`,{count:I.serena}):e(`plugins.status.available`),actionKind:I.serena>0?`manage`:`install`,actionLabel:I.serena>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>F(`serena`)}],[I,e]),K=a.trim().toLowerCase(),q=t=>`${t.title} ${t.description} ${t.statusLabel} ${e(`plugins.scope.${t.scope}`)}`.toLowerCase().includes(K),J=[...B,...V].filter(e=>s!==`all`&&e.scope!==s?!1:q(e)),Y=J.filter(e=>e.scope===`global`&&e.installed),X=J.filter(e=>e.scope===`project`&&e.installed),Z=J.filter(e=>e.scope===`global`&&!e.installed),Q=J.filter(e=>e.scope===`project`&&!e.installed),ce=Y.length>0||X.length>0,le=Z.length>0||Q.length>0,$=[u.installed,I.jira>0,I.serena>0].filter(Boolean).length;return(0,P.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,P.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,P.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,P.jsx)(A,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:e(`plugins.page.title`)}),(0,P.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`plugins.page.subtitle`)})]}),(0,P.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,P.jsx)(O,{className:`h-3.5 w-3.5 text-accent-success`}),(0,P.jsx)(`span`,{className:`text-muted-foreground`,children:e(`plugins.page.readyCount`,{count:$})})]})]}),(0,P.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,P.jsxs)(`label`,{className:`relative flex-1`,children:[(0,P.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,P.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:e(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,P.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(t=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:g(`rounded-md px-3 text-xs capitalize transition-colors`,s===t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e(`plugins.filters.${t}`)},t))})]})]}),(0,P.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,P.jsxs)(`section`,{className:`mb-6`,children:[(0,P.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,P.jsx)(D,{className:`h-3.5 w-3.5`}),e(`plugins.sections.installed`)]}),ce?(0,P.jsx)(ae,{globalPlugins:Y,projectPlugins:X}):(0,P.jsx)(oe,{text:e(K?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,P.jsxs)(`section`,{children:[(0,P.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,P.jsx)(A,{className:`h-3.5 w-3.5`}),e(`plugins.sections.available`)]}),le?(0,P.jsx)(ae,{globalPlugins:Z,projectPlugins:Q}):(0,P.jsx)(oe,{text:e(K?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,P.jsx)(x,{open:k,onOpenChange:j,children:(0,P.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,P.jsxs)(_,{children:[(0,P.jsx)(y,{children:e(`plugins.headroom.title`)}),(0,P.jsx)(b,{children:e(`plugins.headroom.dialogDescription`)})]}),(0,P.jsx)(se,{state:u,loading:h,busy:C,logs:T,onInstall:()=>z(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>W(e))),onToggleProvider:(e,t)=>z(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${d}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>W(e))),onDeactivateAll:()=>z(`deactivate-all`,async()=>{let e={state:u};for(let t of[`codex`,`claude`])u.activeProviders[t]&&(e=await fetch(`${d}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>W(e)));return e}),onUninstall:()=>z(`uninstall`,()=>fetch(`${d}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>W(e))),onSetPort:e=>z(`port`,()=>fetch(`${d}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>W(e))),onOpenDiagnostics:()=>M(!0)})]})}),(0,P.jsx)(fe,{plugin:ie,projects:t,onClose:()=>F(null)}),(0,P.jsx)(he,{open:re,onClose:()=>M(!1)})]})}function ae({globalPlugins:e,projectPlugins:t}){let{t:n}=r(`integrations`);return(0,P.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,P.jsxs)(`section`,{children:[(0,P.jsx)(X,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,P.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,P.jsx)(Z,{plugin:e},e.id))})]}),t.length>0&&(0,P.jsxs)(`section`,{children:[(0,P.jsx)(X,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,P.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,P.jsx)(Z,{plugin:e},e.id))})]})]})}function oe({text:e}){return(0,P.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 Y({scope:e}){let{t}=r(`integrations`);return(0,P.jsx)(`span`,{className:g(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function X({title:e,detail:t,scope:n}){return(0,P.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,P.jsx)(Y,{scope:n}),(0,P.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,P.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,P.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function Z({plugin:e}){let{t}=r(`integrations`),n=e.icon,i=e.scope===`global`,a=e.status===`attention`,c=e.busy?s:e.actionKind===`install`?o:e.actionKind===`review`?u:w,l=g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,a?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,P.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,P.jsx)(`div`,{className:g(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,i?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,P.jsx)(n,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,P.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,P.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,P.jsx)(Y,{scope:e.scope}),(0,P.jsx)(`span`,{className:l,children:e.statusLabel})]})]}),(0,P.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,P.jsx)(c,{className:g(`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:i,onInstall:a,onToggleProvider:c,onDeactivateAll:u,onUninstall:d,onSetPort:f,onOpenDiagnostics:p}){let{t:m}=r(`integrations`),[h,g]=(0,N.useState)(String(e.port)),[_,v]=(0,N.useState)(!1);(0,N.useEffect)(()=>g(String(e.port)),[e.port]),(0,N.useEffect)(()=>{e.installed||v(!1)},[e.installed]);let y=e.activeProviders.codex||e.activeProviders.claude,b=e.installSource===`system`;return(0,P.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,P.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,P.jsx)(ne,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold`,children:m(`plugins.headroom.title`)}),(0,P.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:m(`plugins.headroom.panelDescription`)})]})]}),(0,P.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,P.jsx)(Q,{label:m(`plugins.headroom.metrics.install`),value:t?m(`plugins.headroom.metrics.checking`):e.installed?m(`plugins.headroom.metrics.ready`):m(`plugins.headroom.metrics.missing`),good:e.installed}),(0,P.jsx)(Q,{label:m(`plugins.headroom.metrics.source`),value:e.installSource===`system`?m(`plugins.headroom.metrics.system`):e.installSource===`managed`?m(`plugins.headroom.metrics.specrails`):m(`plugins.headroom.metrics.none`),good:e.installed}),(0,P.jsx)(Q,{label:m(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:m(y?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!y})]}),e.lastIssue&&(0,P.jsx)(ce,{issue:e.lastIssue}),e.installed?(0,P.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,P.jsx)(de,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>c(`codex`,e.activeProviders.codex)}),(0,P.jsx)(de,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>c(`claude`,e.activeProviders.claude)}),y&&(0,P.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:u,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,P.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,P.jsx)(re,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,P.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:a,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,P.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,P.jsx)(o,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,P.jsx)(le,{state:e}),(0,P.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,P.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:m(`plugins.headroom.port.label`)}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,P.jsx)(`button`,{type:`button`,disabled:!!n||Number(h)===e.port,onClick:()=>f(Number(h)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:m(`plugins.headroom.port.apply`)})]})]}),i.length>0&&(0,P.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:i.join(`
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{n as a}from"./dist-bVqfYmby.js";import{t as o}from"./download-CFHyyHcw.js";import{t as s}from"./loader-circle-DcygOQpC.js";import{t as c}from"./search-Cq_gE3Ik.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{a as d}from"./auth-D_5bQv5W.js";import{n as f}from"./useSharedWebSocket-DaPh7QBL.js";import{n as p,r as m}from"./useDesktop-DUvS4fuP.js";import{t as h}from"./button-BUIIBQPT.js";import{t as g}from"./utils-BC4DHlz2.js";import{a as _,n as v,o as y,r as b,t as x}from"./dialog-CzIekCw0.js";import{t as S}from"./jira-api-BgFIr8eD.js";import{r as C}from"./provider-capabilities-BvoExILy.js";import{at as w,jt as T,kt as E,nt as D,rt as O,tt as ee,u as k,ut as A}from"./index-kCUcnT8G.js";var j=i(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),te=i(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),ne=i(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),re=i(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),M=i(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),N=e(t(),1),P=n(),ie=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],F={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function I({state:e,onChanged:t,apiBase:n}){let{t:i}=r(`jira`),o=e.connection,[s,c]=(0,N.useState)(o.enabled),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)([]),[g,_]=(0,N.useState)([]),[v,y]=(0,N.useState)(o.discardStatus??``),[b,x]=(0,N.useState)(o.statusMap??{}),C=e.outbox??{pending:0,inflight:0,done:0,dead:0},w=(0,N.useCallback)(async()=>{try{let{ops:e}=n?await S.listOutbox(`dead`,n):await S.listOutbox(`dead`);m(e)}catch{m([])}},[n]);(0,N.useEffect)(()=>{w()},[w]),(0,N.useEffect)(()=>{let e=!1;return S.listStatuses(n).then(({statuses:t})=>{e||_(t)}).catch(()=>{e||_([])}),()=>{e=!0}},[n]);async function T(e){let r=v;y(e);try{n?await S.patchConnection({discardStatus:e||null},n):await S.patchConnection({discardStatus:e||null}),t()}catch(e){y(r),a.error(R(e,i))}}async function E(e,r){let o=b,s={...b,[e]:r||void 0};x(s);let c=Object.fromEntries(Object.entries(s).filter(([,e])=>e));try{n?await S.patchConnection({statusMap:Object.keys(c).length?c:null},n):await S.patchConnection({statusMap:Object.keys(c).length?c:null}),t()}catch(e){x(o),a.error(R(e,i))}}async function D(){let e=!s;c(e),f(!0);try{n?await S.setEnabled(e,n):await S.setEnabled(e)}catch(t){c(!e),a.error(R(t,i))}finally{f(!1)}}async function O(){u(!0);try{let e=n?await S.syncNow(n):await S.syncNow();a.success(i(`status.syncedToast`,{count:e.upserted}))}catch(e){a.error(R(e,i))}finally{u(!1)}}async function ee(){if(window.confirm(i(`status.disconnectConfirm`))){f(!0);try{n?await S.disconnect(n):await S.disconnect(),a.success(i(`status.disconnectedToast`)),t()}catch(e){a.error(R(e,i))}finally{f(!1)}}}async function k(e){try{n?await S.retryOutbox(e,n):await S.retryOutbox(e),await w()}catch(e){a.error(R(e,i))}}let A=C.pending+C.inflight;return(0,P.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:i(`status.connected`,{key:o.jiraProjectKey})}),(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.baseUrl,` · `,o.deployment===`cloud`?i(`review.cloud`):i(`review.dc`)]})]}),(0,P.jsx)(`a`,{href:`${o.baseUrl}/browse/${o.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:i(`badge.openInJira`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:i(`status.enabledLabel`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(s?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,P.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s,"aria-label":i(`status.enabledLabel`),disabled:d,onClick:D,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${s?`bg-accent-success`:`bg-input`}`,children:(0,P.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${s?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,P.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:i(`wizard.step3Title`)}),(0,P.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`mapping.intro`)}),(0,P.jsx)(`div`,{className:`space-y-2`,children:ie.map(e=>(0,P.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`mapping.${F[e]}`)}),(0,P.jsxs)(`select`,{value:b[e]??``,onChange:t=>void E(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,P.jsx)(`option`,{value:``,children:i(`mapping.auto`)}),g.map(e=>(0,P.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!g.some(t=>t.name===b[e])&&(0,P.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,P.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:i(`discard.configLabel`)}),(0,P.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`discard.configHelp`)}),(0,P.jsxs)(`select`,{value:v,onChange:e=>void T(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,P.jsx)(`option`,{value:``,children:i(`discard.configNone`)}),g.map(e=>(0,P.jsx)(`option`,{value:e.name,children:e.name},e.id)),v&&!g.some(e=>e.name===v)&&(0,P.jsx)(`option`,{value:v,children:v})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(h,{variant:`outline`,size:`sm`,onClick:O,disabled:l,children:i(l?`status.syncing`:`status.syncNow`)}),(0,P.jsx)(h,{variant:`ghost`,size:`sm`,onClick:ee,disabled:d,className:`text-destructive`,children:i(`status.disconnect`)})]}),(0,P.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:i(`outbox.title`)}),C.dead>0?(0,P.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:i(`outbox.dead`,{count:C.dead})}):A>0?(0,P.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.pending`,{count:A})}):(0,P.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.allSynced`)}),p.length>0&&(0,P.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`outbox.deadHelp`)}),p.map(e=>(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,P.jsxs)(`span`,{className:`truncate text-xs`,children:[L(e,i),` · `,e.deadReason??e.lastError??``]}),(0,P.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>k(e.id),children:i(`outbox.retry`)})]},e.id))]})]})]})}function L(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function R(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var z=new Set([`claude`,`codex`,`kimi`]);function B(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 V(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:B(`codex`),claude:B(`claude`)},lastIssue:null}}var H={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:V(),lastIssue:null,updatedAt:null};function U(e){let t=e?.metrics??V();return{...H,...e,activeProviders:{...H.activeProviders,...e?.activeProviders},availableProviders:{...H.availableProviders,...e?.availableProviders},detectedRoutes:{...H.detectedRoutes,...e?.detectedRoutes},learning:{...H.learning,...e?.learning},metrics:{...V(),...t,providers:{codex:{...B(`codex`),...t.providers?.codex},claude:{...B(`claude`),...t.providers?.claude}}}}}async function W(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 G(e){return`${d}/api/projects/${e}`}function K(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 q(e,t,n){return`${K(e,t)} ${n}`}function J(){let{t:e}=r(`integrations`),{projects:t}=m(),{registerHandler:n,unregisterHandler:i}=f(),[a,o]=(0,N.useState)(``),[s,l]=(0,N.useState)(`all`),[u,p]=(0,N.useState)(H),[h,S]=(0,N.useState)(!0),[C,w]=(0,N.useState)(null),[T,E]=(0,N.useState)([]),[k,j]=(0,N.useState)(!1),[re,M]=(0,N.useState)(!1),[ie,F]=(0,N.useState)(null),[I,L]=(0,N.useState)({jira:0,serena:0,projects:0}),R=(0,N.useCallback)(async()=>{try{let e=await fetch(`${d}/api/global-plugins/headroom`).then(e=>W(e));p(U(e.state))}finally{S(!1)}},[]);(0,N.useEffect)(()=>{R()},[R]),(0,N.useEffect)(()=>(n(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&E(e=>[...e.slice(-80),t.line]),R())}),()=>i(`plugins-page`)),[n,i,R]),(0,N.useEffect)(()=>{let e=!1;async function n(){let n=await Promise.all(t.map(async e=>{let[t,n]=await Promise.all([fetch(`${G(e.id)}/jira/connection`).then(e=>W(e)).catch(()=>({connected:!1})),fetch(`${G(e.id)}/plugins`).then(e=>W(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||L({jira:n.reduce((e,t)=>e+t.jira,0),serena:n.reduce((e,t)=>e+t.serena,0),projects:t.length})}return n(),()=>{e=!0}},[t]);async function z(e,t){w(e),E([]);try{let e=(await t()).state;e&&p(U(e))}catch(e){let t=e.payload;t?.state&&p(U(t.state))}finally{w(null),R()}}let B=(0,N.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:ne,description:e(`plugins.catalog.headroom.description`),installed:u.installed,status:u.lastIssue?`attention`:u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?`external-active`:`active`:u.installSource===`system`?`external`:`installed`:`available`,statusLabel:u.lastIssue?e(`plugins.status.attention`):u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?e(`plugins.status.externalActive`):e(`plugins.status.active`):u.installSource===`system`?e(`plugins.status.external`):e(`plugins.status.installed`):e(`plugins.status.available`),actionKind:u.lastIssue?`review`:u.installed?`manage`:`install`,actionLabel:u.lastIssue?e(`plugins.actions.review`):u.installed?e(`plugins.actions.manage`):e(`plugins.actions.install`),busy:C===`install`,action:()=>{if(u.lastIssue||u.installed){j(!0);return}z(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>W(e)))}}],[u,C,e]),V=(0,N.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:te,description:e(`plugins.catalog.jira.description`),installed:I.jira>0,status:I.jira>0?`configured`:`available`,statusLabel:I.jira>0?e(`plugins.status.configuredCount`,{count:I.jira}):e(`plugins.status.available`),actionKind:I.jira>0?`manage`:`install`,actionLabel:I.jira>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>F(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:ee,description:e(`plugins.catalog.serena.description`),installed:I.serena>0,status:I.serena>0?`installed`:`available`,statusLabel:I.serena>0?e(`plugins.status.installedCount`,{count:I.serena}):e(`plugins.status.available`),actionKind:I.serena>0?`manage`:`install`,actionLabel:I.serena>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>F(`serena`)}],[I,e]),K=a.trim().toLowerCase(),q=t=>`${t.title} ${t.description} ${t.statusLabel} ${e(`plugins.scope.${t.scope}`)}`.toLowerCase().includes(K),J=[...B,...V].filter(e=>s!==`all`&&e.scope!==s?!1:q(e)),Y=J.filter(e=>e.scope===`global`&&e.installed),X=J.filter(e=>e.scope===`project`&&e.installed),Z=J.filter(e=>e.scope===`global`&&!e.installed),Q=J.filter(e=>e.scope===`project`&&!e.installed),ce=Y.length>0||X.length>0,le=Z.length>0||Q.length>0,$=[u.installed,I.jira>0,I.serena>0].filter(Boolean).length;return(0,P.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,P.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,P.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,P.jsx)(A,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:e(`plugins.page.title`)}),(0,P.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`plugins.page.subtitle`)})]}),(0,P.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,P.jsx)(O,{className:`h-3.5 w-3.5 text-accent-success`}),(0,P.jsx)(`span`,{className:`text-muted-foreground`,children:e(`plugins.page.readyCount`,{count:$})})]})]}),(0,P.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,P.jsxs)(`label`,{className:`relative flex-1`,children:[(0,P.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,P.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:e(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,P.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(t=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:g(`rounded-md px-3 text-xs capitalize transition-colors`,s===t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e(`plugins.filters.${t}`)},t))})]})]}),(0,P.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,P.jsxs)(`section`,{className:`mb-6`,children:[(0,P.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,P.jsx)(D,{className:`h-3.5 w-3.5`}),e(`plugins.sections.installed`)]}),ce?(0,P.jsx)(ae,{globalPlugins:Y,projectPlugins:X}):(0,P.jsx)(oe,{text:e(K?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,P.jsxs)(`section`,{children:[(0,P.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,P.jsx)(A,{className:`h-3.5 w-3.5`}),e(`plugins.sections.available`)]}),le?(0,P.jsx)(ae,{globalPlugins:Z,projectPlugins:Q}):(0,P.jsx)(oe,{text:e(K?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,P.jsx)(x,{open:k,onOpenChange:j,children:(0,P.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,P.jsxs)(_,{children:[(0,P.jsx)(y,{children:e(`plugins.headroom.title`)}),(0,P.jsx)(b,{children:e(`plugins.headroom.dialogDescription`)})]}),(0,P.jsx)(se,{state:u,loading:h,busy:C,logs:T,onInstall:()=>z(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>W(e))),onToggleProvider:(e,t)=>z(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${d}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>W(e))),onDeactivateAll:()=>z(`deactivate-all`,async()=>{let e={state:u};for(let t of[`codex`,`claude`])u.activeProviders[t]&&(e=await fetch(`${d}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>W(e)));return e}),onUninstall:()=>z(`uninstall`,()=>fetch(`${d}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>W(e))),onSetPort:e=>z(`port`,()=>fetch(`${d}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>W(e))),onOpenDiagnostics:()=>M(!0)})]})}),(0,P.jsx)(fe,{plugin:ie,projects:t,onClose:()=>F(null)}),(0,P.jsx)(he,{open:re,onClose:()=>M(!1)})]})}function ae({globalPlugins:e,projectPlugins:t}){let{t:n}=r(`integrations`);return(0,P.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,P.jsxs)(`section`,{children:[(0,P.jsx)(X,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,P.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,P.jsx)(Z,{plugin:e},e.id))})]}),t.length>0&&(0,P.jsxs)(`section`,{children:[(0,P.jsx)(X,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,P.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,P.jsx)(Z,{plugin:e},e.id))})]})]})}function oe({text:e}){return(0,P.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 Y({scope:e}){let{t}=r(`integrations`);return(0,P.jsx)(`span`,{className:g(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function X({title:e,detail:t,scope:n}){return(0,P.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,P.jsx)(Y,{scope:n}),(0,P.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,P.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,P.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function Z({plugin:e}){let{t}=r(`integrations`),n=e.icon,i=e.scope===`global`,a=e.status===`attention`,c=e.busy?s:e.actionKind===`install`?o:e.actionKind===`review`?u:w,l=g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,a?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,P.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,P.jsx)(`div`,{className:g(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,i?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,P.jsx)(n,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,P.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,P.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,P.jsx)(Y,{scope:e.scope}),(0,P.jsx)(`span`,{className:l,children:e.statusLabel})]})]}),(0,P.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,P.jsx)(c,{className:g(`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:i,onInstall:a,onToggleProvider:c,onDeactivateAll:u,onUninstall:d,onSetPort:f,onOpenDiagnostics:p}){let{t:m}=r(`integrations`),[h,g]=(0,N.useState)(String(e.port)),[_,v]=(0,N.useState)(!1);(0,N.useEffect)(()=>g(String(e.port)),[e.port]),(0,N.useEffect)(()=>{e.installed||v(!1)},[e.installed]);let y=e.activeProviders.codex||e.activeProviders.claude,b=e.installSource===`system`;return(0,P.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,P.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,P.jsx)(ne,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold`,children:m(`plugins.headroom.title`)}),(0,P.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:m(`plugins.headroom.panelDescription`)})]})]}),(0,P.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,P.jsx)(Q,{label:m(`plugins.headroom.metrics.install`),value:t?m(`plugins.headroom.metrics.checking`):e.installed?m(`plugins.headroom.metrics.ready`):m(`plugins.headroom.metrics.missing`),good:e.installed}),(0,P.jsx)(Q,{label:m(`plugins.headroom.metrics.source`),value:e.installSource===`system`?m(`plugins.headroom.metrics.system`):e.installSource===`managed`?m(`plugins.headroom.metrics.specrails`):m(`plugins.headroom.metrics.none`),good:e.installed}),(0,P.jsx)(Q,{label:m(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:m(y?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!y})]}),e.lastIssue&&(0,P.jsx)(ce,{issue:e.lastIssue}),e.installed?(0,P.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,P.jsx)(de,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>c(`codex`,e.activeProviders.codex)}),(0,P.jsx)(de,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>c(`claude`,e.activeProviders.claude)}),y&&(0,P.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:u,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,P.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,P.jsx)(re,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,P.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:a,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,P.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,P.jsx)(o,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,P.jsx)(le,{state:e}),(0,P.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,P.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:m(`plugins.headroom.port.label`)}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,P.jsx)(`button`,{type:`button`,disabled:!!n||Number(h)===e.port,onClick:()=>f(Number(h)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:m(`plugins.headroom.port.apply`)})]})]}),i.length>0&&(0,P.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:i.join(`
|
|
2
2
|
`)}),(0,P.jsxs)(`button`,{type:`button`,onClick:p,className:`mb-2 flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border text-xs hover:bg-muted/50`,children:[(0,P.jsx)(M,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.viewDiagnostics`)]}),e.installed&&(0,P.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/5 p-3`,children:_?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:m(b?`plugins.headroom.confirmDetach`:`plugins.headroom.confirmUninstall`)}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:!!n,onClick:()=>v(!1),className:`h-8 rounded-md border border-border text-xs hover:bg-muted/50 disabled:opacity-50`,children:m(`plugins.actions.cancel`)}),(0,P.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:d,className:`flex h-8 items-center justify-center gap-2 rounded-md bg-destructive px-2 text-xs font-medium text-destructive-foreground disabled:opacity-50`,children:[n===`uninstall`?(0,P.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,P.jsx)(l,{className:`h-3.5 w-3.5`}),m(b?`plugins.headroom.actions.detach`:`plugins.headroom.actions.uninstall`)]})]})]}):(0,P.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:()=>v(!0),className:`flex h-8 w-full items-center justify-center gap-2 rounded-md text-xs font-medium text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:[(0,P.jsx)(l,{className:`h-3.5 w-3.5`}),m(b?`plugins.headroom.actions.detachHeadroom`:`plugins.headroom.actions.uninstallHeadroom`)]})})]})}function Q({label:e,value:t,good:n}){return(0,P.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-2`,children:[(0,P.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,P.jsx)(`div`,{className:g(`mt-0.5 font-medium`,n?`text-foreground`:`text-accent-warning`),children:t})]})}function ce({issue:e}){let{t}=r(`integrations`),n=`plugins.headroom.issues.${e.code}`,i=t(`${n}.title`,{defaultValue:e.title}),a=t(`${n}.guidance`,{defaultValue:e.guidance});return(0,P.jsx)(`div`,{className:`mb-3 rounded-lg border border-accent-warning/35 bg-accent-warning/10 p-3`,children:(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,P.jsx)(u,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium`,children:i}),(0,P.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:a}),(0,P.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(`plugins.headroom.issueCode`,{code:e.code})})]})]})})}function le({state:e}){let{t,i18n:n}=r(`integrations`),i=e.metrics,a=i.outputSavingsAvailable,o=[`codex`,`claude`].map(e=>({provider:e,metric:i.providers[e]})),s=t(`plugins.headroom.savings.tokens`),c=o.reduce((e,{metric:t})=>({inputTokens:e.inputTokens+t.inputTokens,inputTokensSaved:e.inputTokensSaved+t.inputTokensSaved,outputTokens:e.outputTokens+t.outputTokens,outputTokensSaved:e.outputTokensSaved+t.outputTokensSaved}),{inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0}),l=o.some(({metric:e})=>e.inputTokensSaved>0),u=o.some(({metric:e})=>e.active),d=t(a?`plugins.headroom.savings.statusInputOutput`:l?`plugins.headroom.savings.statusInputOnly`:u?`plugins.headroom.savings.statusRouting`:`plugins.headroom.savings.statusInactive`),f=a||l;return(0,P.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,P.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(T,{className:`h-3.5 w-3.5 text-accent-primary`}),(0,P.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t(`plugins.headroom.savings.title`)})]}),(0,P.jsx)(`span`,{className:g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px]`,f?`border-accent-success/25 bg-accent-success/10 text-accent-success`:u?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-border bg-muted text-muted-foreground`),children:d})]}),(0,P.jsxs)(`div`,{className:`mb-2 rounded-md bg-muted/35 px-2.5 py-2`,children:[(0,P.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase text-muted-foreground`,children:t(`plugins.headroom.savings.totals`)}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,P.jsx)($,{label:t(`plugins.headroom.savings.input`),processed:c.inputTokens>0?q(c.inputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:q(c.inputTokensSaved,n.language,s)}),(0,P.jsx)($,{align:`right`,label:t(`plugins.headroom.savings.output`),processed:c.outputTokens>0?q(c.outputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:a?q(c.outputTokensSaved,n.language,s):t(`plugins.headroom.savings.noData`)})]})]}),(0,P.jsx)(`div`,{className:`grid gap-2`,children:o.map(({provider:e,metric:t})=>(0,P.jsx)(ue,{metric:t,outputAvailable:i.outputSavingsAvailable},e))}),(0,P.jsx)(`div`,{className:`mt-2 flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:i.updatedAt?t(`plugins.headroom.savings.updatedLive`):t(`plugins.headroom.savings.baselineSamples`,{count:e.learning.baselineSamples})})]})}function $({label:e,processed:t,saved:n,detail:i,align:a=`left`}){let{t:o}=r(`integrations`);return(0,P.jsxs)(`div`,{className:g(`min-w-0`,a===`right`&&`text-right`),children:[(0,P.jsx)(`div`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,P.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,P.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.processed`)}),(0,P.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:t})]}),(0,P.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,P.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.saved`)}),(0,P.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:n})]})]}),i&&(0,P.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,children:i})]})}function ue({metric:e,outputAvailable:t}){let{t:n,i18n:i}=r(`integrations`),a=!e.available,o=a||!e.active,s=n(`plugins.headroom.savings.tokens`),c=e.inputTokens>0?q(e.inputTokens,i.language,s):n(`plugins.headroom.savings.noData`),l=q(e.inputTokensSaved,i.language,s),u=e.outputTokens>0?q(e.outputTokens,i.language,s):n(`plugins.headroom.savings.noData`),d=t?q(e.outputTokensSaved,i.language,s):e.active?n(`plugins.headroom.savings.noData`):n(`plugins.headroom.savings.off`),f=e.requests>0?n(`plugins.headroom.savings.requestCount`,{count:K(e.requests,i.language)}):a?n(`plugins.headroom.provider.noProjectUsesProvider`):e.active?n(`plugins.headroom.savings.inputSavingsActive`):n(`plugins.headroom.savings.routeDisabled`);return(0,P.jsxs)(`div`,{className:g(`rounded-md border border-border bg-card/45 px-2.5 py-2`,o&&`opacity-70`),children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),e.detectedRoute&&(0,P.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,P.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:f}),(0,P.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-3`,children:[(0,P.jsx)($,{label:n(`plugins.headroom.savings.input`),processed:c,saved:l}),(0,P.jsx)($,{align:`right`,label:n(`plugins.headroom.savings.output`),processed:u,saved:d})]})]})}function de({provider:e,active:t,available:n,detectedRoute:i,busy:a,onClick:o}){let{t:c}=r(`integrations`),l=c(n?t?`plugins.headroom.provider.routedThroughHeadroom`:i?`plugins.headroom.provider.detectedExternalRoute`:`plugins.headroom.provider.notRouted`:`plugins.headroom.provider.noProjectUsesProvider`);return(0,P.jsxs)(`button`,{type:`button`,onClick:o,disabled:a||!n,className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background/45 p-3 text-left hover:bg-muted/35 disabled:opacity-50`,children:[(0,P.jsx)(`div`,{className:g(`grid h-8 w-8 place-items-center rounded-md`,t?`bg-accent-success/15 text-accent-success`:`bg-muted text-muted-foreground`),children:a?(0,P.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,P.jsx)(j,{className:`h-3.5 w-3.5`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium capitalize`,children:e}),(0,P.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:l})]}),(0,P.jsx)(`span`,{className:g(`h-5 w-9 rounded-full p-0.5 transition-colors`,t?`bg-accent-success`:`bg-muted`),children:(0,P.jsx)(`span`,{className:g(`block h-4 w-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-4`)})})]})}function fe({plugin:e,projects:t,onClose:n}){let{t:i}=r(`integrations`),[a,o]=(0,N.useState)(``);(0,N.useEffect)(()=>o(``),[e]);let s=t.find(e=>e.id===a)??null;return(0,P.jsx)(x,{open:!!e,onOpenChange:e=>{e||n()},children:(0,P.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-3xl overflow-x-hidden p-4 sm:p-6`,children:[(0,P.jsxs)(_,{children:[(0,P.jsx)(y,{children:i(e===`jira`?`plugins.projectWizard.configureJira`:`plugins.projectWizard.installSerena`)}),(0,P.jsx)(b,{children:i(`plugins.projectWizard.description`)})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,P.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-3`,children:[(0,P.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:i(`plugins.projectWizard.chooseProject`)}),(0,P.jsx)(`div`,{className:`max-h-[52vh] space-y-1 overflow-auto`,children:t.map(t=>{let n=e===`serena`&&!p(t).some(e=>z.has(e));return(0,P.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>o(t.id),className:g(`w-full rounded-md px-2 py-2 text-left transition-colors`,t.id===a?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/45 hover:text-foreground`,n&&`cursor-not-allowed opacity-45`),children:[(0,P.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t.name}),(0,P.jsx)(`div`,{className:`truncate text-[10px]`,children:n?i(`plugins.projectWizard.requiresSupportedProvider`,{defaultValue:`Requires Claude, Codex, or Kimi`}):t.path})]},t.id)})})]}),(0,P.jsx)(`div`,{className:`min-h-[360px] rounded-lg border border-border bg-card/70 p-4`,children:s?e===`jira`?(0,P.jsx)(pe,{project:s,onDone:n}):(0,P.jsx)(me,{project:s,onDone:n}):(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:i(`plugins.projectWizard.selectProjectToContinue`)})})]})]})})}function pe({project:e,onDone:t}){let{t:n}=r(`integrations`),i=G(e.id),[a,o]=(0,N.useState)(null),[c,l]=(0,N.useState)(!0),[u,d]=(0,N.useState)(null),f=(0,N.useCallback)(async()=>{l(!0),d(null);try{let e=await fetch(`${i}/jira/connection`).then(e=>W(e));o(e)}catch(e){o({connected:!1}),d(e.message)}finally{l(!1)}},[i]);return(0,N.useEffect)(()=>{f()},[f]),c?(0,P.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,P.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),n(`plugins.jira.loading`,{defaultValue:`Loading Jira...`})]}):a?.connected&&a.connection?(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,P.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,P.jsx)(I,{state:a,apiBase:i,onChanged:()=>{f()}})]}):(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:u?n(`plugins.jira.loadFailed`,{message:u,defaultValue:`Could not load the current Jira configuration: ${u}`}):n(`plugins.jira.notConfiguredDescription`,{defaultValue:`Connect this project to Jira.`})})]}),(0,P.jsx)(k,{apiBase:i,onConnected:()=>{f()},onSkip:t})]})}function me({project:e,onDone:t}){let{t:n}=r(`integrations`),i=(0,N.useMemo)(()=>p(e).filter(e=>z.has(e)),[e]),a=i.includes(e.provider)?e.provider:i[0]??e.provider,[c,l]=(0,N.useState)(a),[d,f]=(0,N.useState)(null),[m,h]=(0,N.useState)(null),[g,_]=(0,N.useState)(!1),[v,y]=(0,N.useState)(null),b=(0,N.useRef)(0);(0,N.useEffect)(()=>{l(a),f(null),h(null)},[e.id,a]);let x=(0,N.useCallback)(async()=>{let t=++b.current;y(null);try{let n=`?provider=${encodeURIComponent(c)}`,r=await fetch(`${G(e.id)}/plugins${n}`).then(e=>W(e));if(t!==b.current)return;let i=r.plugins.find(e=>e.name===`serena`)??null;if(f(i),h(null),i?.status===`not-installed`){let r=await fetch(`${G(e.id)}/plugins/serena/preview-install${n}`).then(e=>W(e));t===b.current&&h(r)}}catch(e){t===b.current&&y(e.message)}},[e.id,c]);(0,N.useEffect)(()=>{x()},[x]);async function S(){_(!0),y(null);try{await fetch(`${G(e.id)}/plugins/serena/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:c})}).then(e=>W(e)),await x(),t()}catch(e){y(e.message)}finally{_(!1)}}let w=(m?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum),T=d?n(`plugins.projectStatus.${d.status}`,{defaultValue:d.status}):``,D=d?.name===`serena`?n(`plugins.catalog.serena.description`):d?.description;return!d&&!v?(0,P.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,P.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),` `,n(`plugins.serena.loading`)]}):(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.serena.titleForProject`,{name:e.name})}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.serena.description`)})]}),(0,P.jsxs)(`label`,{className:`block space-y-1`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium`,children:n(`plugins.serena.provider`,{defaultValue:`AI provider`})}),(0,P.jsx)(`select`,{"aria-label":n(`plugins.serena.provider`,{defaultValue:`AI provider`}),value:c,disabled:g,onChange:e=>{f(null),h(null),l(e.target.value)},className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs`,children:i.map(e=>(0,P.jsx)(`option`,{value:e,children:C(e)},e))})]}),d&&(0,P.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-3`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium`,children:n(`plugins.serena.status`,{status:T})}),D&&(0,P.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:D})]}),m&&(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.files`)}),(0,P.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:m.files.map(e=>(0,P.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path]},e.path))})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.prerequisites`)}),(0,P.jsx)(`ul`,{className:`space-y-1 text-xs`,children:m.requirements.map(e=>(0,P.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.installed&&e.executable&&e.meetsMinimum?(0,P.jsx)(E,{className:`h-3 w-3 text-accent-success`}):(0,P.jsx)(u,{className:`h-3 w-3 text-accent-warning`}),(0,P.jsxs)(`span`,{children:[e.name,e.minVersion?` >= ${e.minVersion}`:``]}),e.version&&(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]})]},e.name))})]})]}),v&&(0,P.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:v}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,P.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,P.jsxs)(`button`,{type:`button`,disabled:g||d?.status!==`not-installed`||!w,onClick:S,className:`flex items-center gap-2 rounded-md bg-accent-primary px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:[g?(0,P.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,P.jsx)(o,{className:`h-3.5 w-3.5`}),n(`plugins.actions.install`)]})]})]})}function he({open:e,onClose:t}){let{t:n}=r(`integrations`),[i,a]=(0,N.useState)(null);return(0,N.useEffect)(()=>{e&&fetch(`${d}/api/global-plugins/headroom/diagnostics`).then(e=>W(e)).then(a).catch(e=>a({error:e.message}))},[e]),(0,P.jsx)(x,{open:e,onOpenChange:e=>{e||t()},children:(0,P.jsxs)(v,{className:`max-w-3xl`,children:[(0,P.jsxs)(_,{children:[(0,P.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,P.jsx)(w,{className:`h-4 w-4`}),` `,n(`plugins.diagnostics.title`)]}),(0,P.jsx)(b,{children:n(`plugins.diagnostics.description`)})]}),(0,P.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{J as default};
|
package/client/dist/assets/{ProjectSettingsDialog-CNcANqEL.js → ProjectSettingsDialog-DQTLQ7ie.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./git-branch-BRM0F5GN.js";import{r as o}from"./useDesktop-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./git-branch-BRM0F5GN.js";import{r as o}from"./useDesktop-DUvS4fuP.js";import{t as s}from"./utils-BC4DHlz2.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-CzIekCw0.js";import{Ft as p,Z as m,_ as h,g,h as _,it as v,m as y,nt as b,p as x,tt as S,v as C}from"./index-kCUcnT8G.js";var w=i(`key-round`,[[`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`}]]),T=e(t(),1),E=n(),D=[{id:`general`,icon:b,labelKey:`projectDialog.nav.general`},{id:`branch`,icon:a,labelKey:`projectDialog.nav.branch`},{id:`environment`,icon:w,labelKey:`projectDialog.nav.environment`},{id:`budget`,icon:m,labelKey:`projectDialog.nav.budget`},{id:`telemetry`,icon:p,labelKey:`projectDialog.nav.telemetry`},{id:`terminal`,icon:S,labelKey:`projectDialog.nav.terminal`}];function O({open:e,onClose:t}){let{t:n}=r(`settings`),{activeProjectId:i,projects:a}=o(),p=a.find(e=>e.id===i),[m,b]=(0,T.useState)(`general`),S=e=>s(`space-y-5`,m===e?``:`hidden`);return(0,E.jsx)(f,{open:e,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(l,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,E.jsxs)(c,{children:[(0,E.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,E.jsx)(v,{className:`w-4 h-4`}),p?n(`projectDialog.title`,{name:p.name}):n(`page.title`)]}),(0,E.jsx)(d,{children:n(`projectDialog.description`)})]}),(0,E.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,E.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:D.map(e=>{let t=e.icon;return(0,E.jsxs)(`button`,{type:`button`,onClick:()=>b(e.id),className:s(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,m===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,E.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,E.jsx)(`span`,{className:`truncate`,children:n(e.labelKey)})]},e.id)})}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,E.jsx)(`div`,{className:S(`general`),children:(0,E.jsx)(_,{})}),(0,E.jsx)(`div`,{className:S(`branch`),children:(0,E.jsx)(y,{})}),(0,E.jsx)(`div`,{className:S(`environment`),children:(0,E.jsx)(h,{})}),(0,E.jsx)(`div`,{className:S(`budget`),children:(0,E.jsx)(x,{})}),(0,E.jsx)(`div`,{className:S(`telemetry`),children:(0,E.jsx)(g,{})}),(0,E.jsx)(`div`,{className:S(`terminal`),children:(0,E.jsx)(C,{mode:`project`})})]})]})]})})}export{O as ProjectSettingsDialog};
|
package/client/dist/assets/{TemplatePreviewModal-4EpqyErX.js → TemplatePreviewModal-nXUcDgfk.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-zu2_FqZY.js";import{n as t}from"./createLucideIcon-Bjbbp_KS.js";import{t as n}from"./brain-DI9lHkKY.js";import{t as r}from"./download-CFHyyHcw.js";import{t as i}from"./git-branch-BRM0F5GN.js";import{t as a}from"./play-DNlrawbS.js";import{t as o}from"./button-BUIIBQPT.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./dialog-CzIekCw0.js";import{Et as p,Q as m,et as h,w as g}from"./index-
|
|
1
|
+
import{t as e}from"./jsx-runtime-zu2_FqZY.js";import{n as t}from"./createLucideIcon-Bjbbp_KS.js";import{t as n}from"./brain-DI9lHkKY.js";import{t as r}from"./download-CFHyyHcw.js";import{t as i}from"./git-branch-BRM0F5GN.js";import{t as a}from"./play-DNlrawbS.js";import{t as o}from"./button-BUIIBQPT.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./dialog-CzIekCw0.js";import{Et as p,Q as m,et as h,w as g}from"./index-kCUcnT8G.js";var _=e(),v={start:a,"ai-step":n,shell:m,decider:i,condition:i,end:h};function y(e){return e.type===`ai-step`?typeof e.data?.prompt==`string`?e.data.prompt:null:e.type===`shell`?typeof e.data?.command==`string`?e.data.command:null:e.type===`decider`?typeof e.data?.goal==`string`?e.data.goal:null:e.type===`end`?e.data?.outcome===`failure`?`failure`:`success`:null}function b({template:e,onClose:i,onUse:a,mode:m=`use`}){let{t:b}=t(`loops`);return(0,_.jsx)(f,{open:e!==null,onOpenChange:e=>{e||i()},children:(0,_.jsx)(l,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(s,{children:[(0,_.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,_.jsx)(n,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,_.jsx)(d,{children:e.description})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[g(e.graph)?(0,_.jsx)(`span`,{title:b(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:b(`gallery.needsSpec`)}):(0,_.jsx)(`span`,{title:b(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:b(`gallery.standalone`)}),e.category&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:b(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?b(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):b(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,_.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,_.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:b(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=v[e.type]??h,r=y(e);return(0,_.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,_.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),b(`builder.nodes.${e.type}`)]}),r&&(0,_.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,_.jsxs)(c,{children:[(0,_.jsx)(o,{variant:`ghost`,onClick:i,children:b(`common:actions.cancel`)}),(0,_.jsxs)(o,{onClick:()=>a(e.id),children:[m===`fork`?(0,_.jsx)(p,{className:`w-3.5 h-3.5 mr-1.5`}):(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),b(m===`fork`?`actions.fork`:`actions.use`)]})]})]})})})}export{b as n,y as r,v as t};
|