@hellcoder/companion 0.100.1-preview.20260611055453.fc6fbdf → 0.101.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/assets/{AgentsPage-7oHDiJoh.js → AgentsPage-BhKdcyXZ.js} +1 -1
  2. package/dist/assets/{CronManager-fsEUcByi.js → CronManager-DRZ66TkG.js} +1 -1
  3. package/dist/assets/{IntegrationsPage-DhiOq9T9.js → IntegrationsPage-ClTWLg6W.js} +1 -1
  4. package/dist/assets/{LinearOAuthSettingsPage-DJ3p4Zyh.js → LinearOAuthSettingsPage-CWz5AdGt.js} +1 -1
  5. package/dist/assets/{LinearSettingsPage-EJXrPlao.js → LinearSettingsPage-di0JH5lO.js} +1 -1
  6. package/dist/assets/{Playground-BJi1T7KP.js → Playground-BVqqQ5J3.js} +1 -1
  7. package/dist/assets/{PromptsPage-DiMm5U1r.js → PromptsPage-C1oMpJK9.js} +1 -1
  8. package/dist/assets/{RunsPage-LPrcOaUc.js → RunsPage-B2Z2eRQO.js} +1 -1
  9. package/dist/assets/{SandboxManager-9KiHL5rI.js → SandboxManager-CaBqRrPE.js} +1 -1
  10. package/dist/assets/{SettingsPage-BXy1ZF1F.js → SettingsPage-C4WdQ-ba.js} +1 -1
  11. package/dist/assets/{TailscalePage-ycECxxya.js → TailscalePage-trYybm9W.js} +1 -1
  12. package/dist/assets/index-BCS1TCne.css +1 -0
  13. package/dist/assets/index-BY3_XaK9.js +134 -0
  14. package/dist/assets/{sw-register-Duj0Mw6k.js → sw-register-Cf5LH9-W.js} +1 -1
  15. package/dist/index.html +2 -2
  16. package/dist/sw.js +1 -1
  17. package/package.json +1 -1
  18. package/server/claude-adapter.test.ts +114 -0
  19. package/server/claude-adapter.ts +56 -8
  20. package/server/claude-session-history.ts +15 -0
  21. package/server/routes.ts +20 -0
  22. package/server/session-export.test.ts +169 -0
  23. package/server/session-export.ts +382 -0
  24. package/dist/assets/index-D-JiBkdW.js +0 -134
  25. package/dist/assets/index-DwVmncqT.css +0 -1
@@ -1,4 +1,4 @@
1
- import{r,j as e,u as Be,a as z,x as ae,F as ye,L as ne,t as Ee,B as we,y as Oe,E as Ie}from"./index-D-JiBkdW.js";const ze="companion_public_url_dismissed";function De({publicUrl:t}){const[i,d]=r.useState(()=>localStorage.getItem(ze)==="1");return t||i?null:e.jsxs("div",{className:"mb-4 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-400 text-xs flex items-start justify-between gap-3",role:"alert",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"No public URL configured."})," ","Webhook URLs currently use your browser address, which external services like Linear may not be able to reach."," ",e.jsx("a",{href:"#/settings",className:"underline hover:text-amber-300",children:"Set your public URL in Settings"}),"."]}),e.jsx("button",{onClick:()=>{localStorage.setItem(ze,"1"),d(!0)},className:"text-amber-400 hover:text-amber-200 transition-colors cursor-pointer flex-shrink-0","aria-label":"Dismiss public URL banner",children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})})]})}function He({steps:t,currentStep:i,completedSteps:d}){return e.jsx("nav",{"aria-label":"Setup progress",className:"flex items-center gap-0 w-full mb-8",children:t.map((a,m)=>{const u=m+1,h=d.has(u),g=u===i,v=!h&&!g;return e.jsxs("div",{className:"flex items-center flex-1 last:flex-none",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[e.jsx("div",{className:`flex items-center justify-center w-8 h-8 rounded-full text-xs font-semibold border-2 transition-colors ${h?"bg-cc-success/15 border-cc-success text-cc-success":g?"bg-cc-primary/15 border-cc-primary text-cc-primary":"bg-cc-hover border-cc-border text-cc-muted"}`,"aria-current":g?"step":void 0,"aria-label":`Step ${u}: ${a.label}${h?" (completed)":g?" (current)":""}`,children:h?e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):u}),e.jsx("span",{className:`text-[10px] whitespace-nowrap ${v?"text-cc-muted":g?"text-cc-primary font-medium":"text-cc-success"}`,children:a.label})]}),m<t.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-2 mt-[-18px] rounded ${d.has(u)?"bg-cc-success/40":"bg-cc-border"}`})]},u)})})}function Pe({onNext:t}){const i=Be(m=>m.publicUrl),d=i||window.location.origin,a=!!i;return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"pt-1",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-widest text-cc-primary font-medium mb-2",children:"Linear Agent Setup"}),e.jsx("h2",{className:"text-xl font-semibold text-cc-fg tracking-tight leading-tight",children:"Connect your Linear workspace"}),e.jsx("p",{className:"mt-2 text-sm text-cc-muted leading-relaxed max-w-md",children:"This wizard connects the Agent Interaction SDK so your agent can respond to @mentions in Linear issues."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-5 h-5 rounded-full flex items-center justify-center ${a?"bg-cc-success/15 text-cc-success":"bg-cc-warning/15 text-cc-warning"}`,children:a?e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("span",{className:"text-[10px] font-bold",children:"!"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] text-cc-fg font-medium",children:"Public URL"}),e.jsx("p",{className:"text-xs text-cc-muted mt-0.5 leading-relaxed",children:a?e.jsx(e.Fragment,{children:e.jsx("code",{className:"px-1 py-0.5 rounded bg-cc-hover text-[10px] font-mono-code",children:i})}):e.jsxs(e.Fragment,{children:["Not set. Linear needs to reach your instance. Configure in ",e.jsx("a",{href:"#/integrations/tailscale",className:"text-cc-primary hover:underline",children:"Tailscale"})," or ",e.jsx("a",{href:"#/settings",className:"text-cc-primary hover:underline",children:"Settings"}),"."]})})]})]}),e.jsx("div",{className:"border-t border-cc-border/50"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0 w-5 h-5 rounded-full flex items-center justify-center bg-cc-hover text-cc-muted",children:e.jsx("span",{className:"text-[10px] font-semibold",children:"1"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] text-cc-fg font-medium",children:"Create a Linear OAuth app"}),e.jsx("p",{className:"text-xs text-cc-muted mt-0.5 leading-relaxed",children:e.jsx("a",{href:"https://linear.app/settings/api",target:"_blank",rel:"noopener noreferrer",className:"text-cc-primary hover:underline",children:"Linear → Settings → API → OAuth Applications"})}),e.jsxs("dl",{className:"mt-3 space-y-2.5 text-xs",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-cc-muted",children:"Webhooks"}),e.jsxs("dd",{className:"text-cc-fg mt-0.5",children:["Enable and subscribe to ",e.jsx("strong",{children:"Agent session events"})]})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-cc-muted",children:"Scope"}),e.jsx("dd",{className:"mt-0.5",children:e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-cc-hover text-cc-fg text-[10px] font-mono-code",children:"app:mentionable"})})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-cc-muted",children:"Redirect URI"}),e.jsx("dd",{className:"mt-0.5",children:e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-cc-hover text-cc-fg text-[10px] font-mono-code break-all",children:`${d}/api/linear/oauth/callback`})})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-cc-muted",children:"Webhook URL"}),e.jsx("dd",{className:"mt-0.5",children:e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-cc-hover text-cc-fg text-[10px] font-mono-code break-all",children:`${d}/api/linear/agent-webhook`})})]})]})]})]})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{onClick:t,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Next"})})]})}function Ue({onNext:t,onBack:i,selectedConnectionId:d}){const[a,m]=r.useState([]),[u,h]=r.useState(!0),[g,v]=r.useState(d||""),[j,o]=r.useState("");r.useEffect(()=>{z.listLinearOAuthConnections().then(b=>{m(b.connections),o(""),d?b.connections.some(p=>p.id===d)&&v(d):b.connections.length===1&&v(b.connections[0].id)}).catch(b=>o(b instanceof Error?b.message:String(b))).finally(()=>h(!1))},[d]);const y=a.find(b=>b.id===g),k=!!g&&(y==null?void 0:y.status)==="connected";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-cc-fg",children:"Select OAuth Connection"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Choose which Linear OAuth app this agent should use for @mention triggers."})]}),j&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:j}),u?e.jsx("p",{className:"text-sm text-cc-muted",children:"Loading connections..."}):a.length===0?e.jsxs("div",{className:"rounded-lg border border-cc-border bg-cc-bg p-5 text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"No OAuth connections found."}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Create an OAuth app connection first, then come back to set up the agent."}),e.jsx("a",{href:"#/integrations/linear-oauth",className:"inline-flex px-4 py-2.5 rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors",children:"Go to OAuth Settings"})]}):e.jsxs("div",{className:"space-y-3",children:[a.map(b=>{const C=g===b.id,p=b.status==="connected";return e.jsxs("button",{type:"button",onClick:()=>v(b.id),className:`w-full text-left p-4 rounded-lg border transition-colors cursor-pointer ${C?"border-cc-primary bg-cc-primary/5":"border-cc-border hover:border-cc-border hover:bg-cc-hover/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${C?"border-cc-primary":"border-cc-border"}`,children:C&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-cc-primary"})}),e.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:b.name})]}),e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full border flex-shrink-0 ${p?"bg-cc-success/10 text-cc-success border-cc-success/20":"bg-cc-hover text-cc-muted border-cc-border"}`,children:p?"Connected":"Not installed"})]}),!p&&C&&e.jsxs("p",{className:"mt-2 ml-6 text-xs text-cc-warning",children:["This connection needs to be installed to a workspace first."," ",e.jsx("a",{href:"#/integrations/linear-oauth",className:"text-cc-primary underline",onClick:S=>S.stopPropagation(),children:"Install now"})]})]},b.id)}),e.jsx("a",{href:"#/integrations/linear-oauth",className:"block text-center text-xs text-cc-primary hover:underline py-2",children:"+ Create a new OAuth connection"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("button",{onClick:i,className:"px-4 py-2.5 rounded-lg text-sm font-medium text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"}),e.jsx("button",{onClick:()=>k&&t(g),disabled:!k,className:`px-4 py-2.5 rounded-lg text-sm font-medium transition-colors ${k?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:"Next"})]})]})}const Ve=`You are an AI agent responding to a Linear issue. The issue context will be provided when you are @mentioned.
1
+ import{r,j as e,u as Be,a as z,x as ae,F as ye,L as ne,t as Ee,B as we,y as Oe,E as Ie}from"./index-BY3_XaK9.js";const ze="companion_public_url_dismissed";function De({publicUrl:t}){const[i,d]=r.useState(()=>localStorage.getItem(ze)==="1");return t||i?null:e.jsxs("div",{className:"mb-4 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-400 text-xs flex items-start justify-between gap-3",role:"alert",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"No public URL configured."})," ","Webhook URLs currently use your browser address, which external services like Linear may not be able to reach."," ",e.jsx("a",{href:"#/settings",className:"underline hover:text-amber-300",children:"Set your public URL in Settings"}),"."]}),e.jsx("button",{onClick:()=>{localStorage.setItem(ze,"1"),d(!0)},className:"text-amber-400 hover:text-amber-200 transition-colors cursor-pointer flex-shrink-0","aria-label":"Dismiss public URL banner",children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})})]})}function He({steps:t,currentStep:i,completedSteps:d}){return e.jsx("nav",{"aria-label":"Setup progress",className:"flex items-center gap-0 w-full mb-8",children:t.map((a,m)=>{const u=m+1,h=d.has(u),g=u===i,v=!h&&!g;return e.jsxs("div",{className:"flex items-center flex-1 last:flex-none",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[e.jsx("div",{className:`flex items-center justify-center w-8 h-8 rounded-full text-xs font-semibold border-2 transition-colors ${h?"bg-cc-success/15 border-cc-success text-cc-success":g?"bg-cc-primary/15 border-cc-primary text-cc-primary":"bg-cc-hover border-cc-border text-cc-muted"}`,"aria-current":g?"step":void 0,"aria-label":`Step ${u}: ${a.label}${h?" (completed)":g?" (current)":""}`,children:h?e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):u}),e.jsx("span",{className:`text-[10px] whitespace-nowrap ${v?"text-cc-muted":g?"text-cc-primary font-medium":"text-cc-success"}`,children:a.label})]}),m<t.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-2 mt-[-18px] rounded ${d.has(u)?"bg-cc-success/40":"bg-cc-border"}`})]},u)})})}function Pe({onNext:t}){const i=Be(m=>m.publicUrl),d=i||window.location.origin,a=!!i;return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"pt-1",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-widest text-cc-primary font-medium mb-2",children:"Linear Agent Setup"}),e.jsx("h2",{className:"text-xl font-semibold text-cc-fg tracking-tight leading-tight",children:"Connect your Linear workspace"}),e.jsx("p",{className:"mt-2 text-sm text-cc-muted leading-relaxed max-w-md",children:"This wizard connects the Agent Interaction SDK so your agent can respond to @mentions in Linear issues."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-5 h-5 rounded-full flex items-center justify-center ${a?"bg-cc-success/15 text-cc-success":"bg-cc-warning/15 text-cc-warning"}`,children:a?e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("span",{className:"text-[10px] font-bold",children:"!"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] text-cc-fg font-medium",children:"Public URL"}),e.jsx("p",{className:"text-xs text-cc-muted mt-0.5 leading-relaxed",children:a?e.jsx(e.Fragment,{children:e.jsx("code",{className:"px-1 py-0.5 rounded bg-cc-hover text-[10px] font-mono-code",children:i})}):e.jsxs(e.Fragment,{children:["Not set. Linear needs to reach your instance. Configure in ",e.jsx("a",{href:"#/integrations/tailscale",className:"text-cc-primary hover:underline",children:"Tailscale"})," or ",e.jsx("a",{href:"#/settings",className:"text-cc-primary hover:underline",children:"Settings"}),"."]})})]})]}),e.jsx("div",{className:"border-t border-cc-border/50"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0 w-5 h-5 rounded-full flex items-center justify-center bg-cc-hover text-cc-muted",children:e.jsx("span",{className:"text-[10px] font-semibold",children:"1"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] text-cc-fg font-medium",children:"Create a Linear OAuth app"}),e.jsx("p",{className:"text-xs text-cc-muted mt-0.5 leading-relaxed",children:e.jsx("a",{href:"https://linear.app/settings/api",target:"_blank",rel:"noopener noreferrer",className:"text-cc-primary hover:underline",children:"Linear → Settings → API → OAuth Applications"})}),e.jsxs("dl",{className:"mt-3 space-y-2.5 text-xs",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-cc-muted",children:"Webhooks"}),e.jsxs("dd",{className:"text-cc-fg mt-0.5",children:["Enable and subscribe to ",e.jsx("strong",{children:"Agent session events"})]})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-cc-muted",children:"Scope"}),e.jsx("dd",{className:"mt-0.5",children:e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-cc-hover text-cc-fg text-[10px] font-mono-code",children:"app:mentionable"})})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-cc-muted",children:"Redirect URI"}),e.jsx("dd",{className:"mt-0.5",children:e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-cc-hover text-cc-fg text-[10px] font-mono-code break-all",children:`${d}/api/linear/oauth/callback`})})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-cc-muted",children:"Webhook URL"}),e.jsx("dd",{className:"mt-0.5",children:e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-cc-hover text-cc-fg text-[10px] font-mono-code break-all",children:`${d}/api/linear/agent-webhook`})})]})]})]})]})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{onClick:t,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Next"})})]})}function Ue({onNext:t,onBack:i,selectedConnectionId:d}){const[a,m]=r.useState([]),[u,h]=r.useState(!0),[g,v]=r.useState(d||""),[j,o]=r.useState("");r.useEffect(()=>{z.listLinearOAuthConnections().then(b=>{m(b.connections),o(""),d?b.connections.some(p=>p.id===d)&&v(d):b.connections.length===1&&v(b.connections[0].id)}).catch(b=>o(b instanceof Error?b.message:String(b))).finally(()=>h(!1))},[d]);const y=a.find(b=>b.id===g),k=!!g&&(y==null?void 0:y.status)==="connected";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-cc-fg",children:"Select OAuth Connection"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Choose which Linear OAuth app this agent should use for @mention triggers."})]}),j&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:j}),u?e.jsx("p",{className:"text-sm text-cc-muted",children:"Loading connections..."}):a.length===0?e.jsxs("div",{className:"rounded-lg border border-cc-border bg-cc-bg p-5 text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"No OAuth connections found."}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Create an OAuth app connection first, then come back to set up the agent."}),e.jsx("a",{href:"#/integrations/linear-oauth",className:"inline-flex px-4 py-2.5 rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors",children:"Go to OAuth Settings"})]}):e.jsxs("div",{className:"space-y-3",children:[a.map(b=>{const C=g===b.id,p=b.status==="connected";return e.jsxs("button",{type:"button",onClick:()=>v(b.id),className:`w-full text-left p-4 rounded-lg border transition-colors cursor-pointer ${C?"border-cc-primary bg-cc-primary/5":"border-cc-border hover:border-cc-border hover:bg-cc-hover/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${C?"border-cc-primary":"border-cc-border"}`,children:C&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-cc-primary"})}),e.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:b.name})]}),e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full border flex-shrink-0 ${p?"bg-cc-success/10 text-cc-success border-cc-success/20":"bg-cc-hover text-cc-muted border-cc-border"}`,children:p?"Connected":"Not installed"})]}),!p&&C&&e.jsxs("p",{className:"mt-2 ml-6 text-xs text-cc-warning",children:["This connection needs to be installed to a workspace first."," ",e.jsx("a",{href:"#/integrations/linear-oauth",className:"text-cc-primary underline",onClick:S=>S.stopPropagation(),children:"Install now"})]})]},b.id)}),e.jsx("a",{href:"#/integrations/linear-oauth",className:"block text-center text-xs text-cc-primary hover:underline py-2",children:"+ Create a new OAuth connection"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("button",{onClick:i,className:"px-4 py-2.5 rounded-lg text-sm font-medium text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"}),e.jsx("button",{onClick:()=>k&&t(g),disabled:!k,className:`px-4 py-2.5 rounded-lg text-sm font-medium transition-colors ${k?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:"Next"})]})]})}const Ve=`You are an AI agent responding to a Linear issue. The issue context will be provided when you are @mentioned.
2
2
 
3
3
  Read the issue details carefully, then complete the requested task. When done, summarize what you did.
4
4
 
@@ -1 +1 @@
1
- import{r as a,a as j,j as e,t as W,w as _,x as B,y as U,z as Y,F as q}from"./index-D-JiBkdW.js";function z(s,p,c=!0){a.useEffect(()=>{if(!c)return;function d(o){s.some(m=>m.current&&m.current.contains(o.target))||p()}return document.addEventListener("pointerdown",d),()=>document.removeEventListener("pointerdown",d)},[s,p,c])}function J(s){const p=s-Date.now();if(p<=0)return"now";const c=Math.floor(p/6e4);if(c<60)return`in ${c}m`;const d=Math.floor(c/60);return d<24?`in ${d}h`:`in ${Math.floor(d/24)}d`}function F(s,p){if(!p)return"One-time";const c=s.trim().split(/\s+/);if(c.length!==5)return s;const[d,o,g,m,x]=c;if(s==="* * * * *")return"Every minute";if(o==="*"&&g==="*"&&m==="*"&&x==="*"&&d.startsWith("*/")){const l=parseInt(d.slice(2),10);return l===1?"Every minute":`Every ${l} minutes`}if(d==="0"&&g==="*"&&m==="*"&&x==="*"){if(o==="*")return"Every hour";if(o.startsWith("*/")){const l=parseInt(o.slice(2),10);return l===1?"Every hour":`Every ${l} hours`}}if(g==="*"&&m==="*"&&d!=="*"&&o!=="*"&&!o.includes("/")&&!o.includes(",")){const l=parseInt(o,10),y=parseInt(d,10);if(!isNaN(l)&&!isNaN(y)){const u=l>=12?"PM":"AM",w=l===0?12:l>12?l-12:l,r=y.toString().padStart(2,"0"),v=`${w}:${r} ${u}`;if(x==="*")return`Every day at ${v}`;if(x==="1-5")return`Weekdays at ${v}`;if(x==="0,6")return`Weekends at ${v}`}}return s}const $={name:"",prompt:"",recurring:!0,schedule:"0 8 * * *",oneTimeDate:"",backendType:"claude",model:B("claude"),cwd:""},G=[{label:"Every hour",value:"0 * * * *"},{label:"Every day at 8am",value:"0 8 * * *"},{label:"Every 2 hours",value:"0 */2 * * *"},{label:"Weekdays at 9am",value:"0 9 * * 1-5"}];function X({onClose:s,embedded:p=!1}){const[c,d]=a.useState([]),[o,g]=a.useState(!0),[m,x]=a.useState(""),[l,y]=a.useState(null),[u,w]=a.useState($),[r,v]=a.useState($),[h,M]=a.useState(!1),[f,S]=a.useState(!1),[k,E]=a.useState(new Set),n=a.useCallback(()=>{j.listCronJobs().then(d).catch(()=>{}).finally(()=>g(!1))},[]);a.useEffect(()=>{n();const t=setInterval(n,1e4);return()=>clearInterval(t)},[n]);async function C(){const t=r.name.trim(),i=r.prompt.trim();if(!t||!i)return;M(!0),x("");let N=r.schedule;!r.recurring&&r.oneTimeDate&&(N=new Date(r.oneTimeDate).toISOString());try{await j.createCronJob({name:t,prompt:i,schedule:N,recurring:r.recurring,backendType:r.backendType,model:r.model.trim()||void 0,cwd:r.cwd.trim()||void 0}),v($),S(!1),n()}catch(b){x(b instanceof Error?b.message:String(b))}finally{M(!1)}}function R(t){y(t.id),w({name:t.name,prompt:t.prompt,recurring:t.recurring,schedule:t.schedule,oneTimeDate:"",backendType:t.backendType,model:t.model,cwd:t.cwd}),x("")}function D(){y(null),x("")}async function L(){if(!l)return;const t=u.name.trim(),i=u.prompt.trim();if(!t||!i)return;let N=u.schedule;!u.recurring&&u.oneTimeDate&&(N=new Date(u.oneTimeDate).toISOString());try{await j.updateCronJob(l,{name:t,prompt:i,schedule:N,recurring:u.recurring,backendType:u.backendType,model:u.model.trim()||void 0,cwd:u.cwd.trim()||void 0}),y(null),x(""),n()}catch(b){x(b instanceof Error?b.message:String(b))}}async function A(t){try{await j.deleteCronJob(t),l===t&&y(null),n()}catch(i){x(i instanceof Error?i.message:String(i))}}async function I(t){try{await j.toggleCronJob(t),n()}catch(i){x(i instanceof Error?i.message:String(i))}}async function P(t){E(i=>new Set(i).add(t));try{await j.runCronJob(t),n()}catch(i){x(i instanceof Error?i.message:String(i))}finally{E(i=>{const N=new Set(i);return N.delete(t),N})}}if(p)return e.jsx("div",{className:"h-full bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto",children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 sm:px-6 py-6 sm:py-10 pb-safe",children:[e.jsx("div",{className:"flex items-start justify-between gap-3 mb-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Scheduled Tasks"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-cc-muted leading-relaxed",children:"Run autonomous Claude Code or Codex sessions on a schedule."})]})}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 mb-5",children:[e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:()=>S(!f),className:`flex items-center gap-1.5 px-3.5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer shrink-0 ${f?"bg-cc-active text-cc-fg":"bg-cc-primary hover:bg-cc-primary-hover text-white"}`,children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:f?e.jsx("path",{d:"M18 6 6 18M6 6l12 12"}):e.jsx("path",{d:"M12 5v14M5 12h14"})}),e.jsx("span",{className:"hidden sm:inline",children:f?"Cancel":"New Task"})]})]}),f&&e.jsxs("div",{className:"mb-6 rounded-xl bg-cc-card p-4 sm:p-5 space-y-3",style:{animation:"fadeSlideIn 150ms ease-out"},children:[e.jsx(T,{form:r,onChange:v}),e.jsx("p",{className:"text-[10px] text-cc-muted",children:"Scheduled tasks run with full autonomy (bypassPermissions)"}),m&&f&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 text-xs text-cc-error",children:m}),e.jsx("div",{className:"flex items-center justify-end pt-1",children:e.jsx("button",{onClick:C,disabled:!r.name.trim()||!r.prompt.trim()||h,className:`px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${r.name.trim()&&r.prompt.trim()&&!h?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:h?"Creating...":"Create"})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-[12px] text-cc-muted",children:[e.jsxs("span",{children:[c.length," task",c.length!==1?"s":""]}),c.filter(t=>t.enabled).length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-cc-border",children:"·"}),e.jsxs("span",{children:[c.filter(t=>t.enabled).length," active"]})]})]}),o?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"Loading scheduled tasks..."}):c.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"No scheduled tasks yet."}):e.jsx("div",{className:"space-y-1",children:c.map(t=>l===t.id?e.jsxs("div",{className:"rounded-xl bg-cc-card p-4 space-y-3",style:{animation:"fadeSlideIn 150ms ease-out"},children:[e.jsx(T,{form:u,onChange:w}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:D,className:"px-3 py-2.5 min-h-[44px] text-sm rounded-lg text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{onClick:()=>void L(),className:"px-4 py-2.5 min-h-[44px] text-sm rounded-lg font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Save"})]})]},t.id):e.jsx(K,{job:t,isRunning:k.has(t.id),onStartEdit:()=>R(t),onDelete:()=>void A(t.id),onToggle:()=>void I(t.id),onRunNow:()=>void P(t.id)},t.id))}),m&&!f&&e.jsx("div",{className:"mt-4 px-3 py-2 rounded-lg bg-cc-error/10 text-xs text-cc-error",children:m})]})});const O=m&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 text-xs text-cc-error",children:m}),H=o?e.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"Loading scheduled tasks..."}):c.length===0?e.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"No scheduled tasks yet."}):e.jsx("div",{className:"space-y-3",children:c.map(t=>e.jsxs("div",{className:"rounded-xl bg-cc-card overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg flex-1 truncate",children:t.name}),e.jsx("span",{className:`text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 ${t.backendType==="codex"?"text-blue-500 bg-blue-500/10":"text-[#5BA8A0] bg-[#5BA8A0]/10"}`,children:t.backendType==="codex"?"Codex":"Claude"}),t.consecutiveFailures>0&&e.jsxs("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-error bg-cc-error/10",children:[t.consecutiveFailures," fail",t.consecutiveFailures!==1?"s":""]}),e.jsx("button",{onClick:()=>I(t.id),className:`relative w-10 h-6 rounded-full transition-colors cursor-pointer shrink-0 ${t.enabled?"bg-cc-primary":"bg-cc-border"}`,title:t.enabled?"Disable":"Enable",children:e.jsx("span",{className:`absolute top-[3px] w-[18px] h-[18px] rounded-full bg-white transition-transform ${t.enabled?"left-[19px]":"left-[3px]"}`})}),l===t.id?e.jsx("button",{onClick:D,className:"text-xs px-2 py-1.5 min-h-[44px] text-cc-muted hover:text-cc-fg cursor-pointer",children:"Cancel"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>P(t.id),disabled:k.has(t.id),className:`text-xs px-2 py-1.5 min-h-[44px] cursor-pointer ${k.has(t.id)?"text-cc-muted cursor-not-allowed":"text-cc-primary hover:text-cc-primary-hover"}`,children:k.has(t.id)?"Running...":"Run Now"}),e.jsx("button",{onClick:()=>R(t),className:"text-xs px-2 py-1.5 min-h-[44px] text-cc-muted hover:text-cc-fg cursor-pointer",children:"Edit"}),e.jsx("button",{onClick:()=>A(t.id),className:"text-xs px-2 py-1.5 min-h-[44px] text-cc-muted hover:text-cc-error cursor-pointer",children:"Delete"})]})]}),l===t.id&&e.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[e.jsx(T,{form:u,onChange:w}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:L,className:"px-4 py-2.5 min-h-[44px] text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white rounded-lg transition-colors cursor-pointer",children:"Save"}),e.jsx("button",{onClick:D,className:"px-3 py-2.5 min-h-[44px] text-sm font-medium text-cc-muted hover:text-cc-fg rounded-lg transition-colors cursor-pointer",children:"Cancel"})]})]}),l!==t.id&&e.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsx("div",{className:"text-xs text-cc-muted truncate",title:t.prompt,children:t.prompt}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-cc-muted",children:[e.jsx("span",{children:F(t.schedule,t.recurring)}),t.nextRunAt!=null&&t.enabled&&e.jsxs("span",{children:["Next: ",J(t.nextRunAt)]}),t.lastRunAt!=null&&e.jsxs("span",{className:"flex items-center gap-1",children:["Last: ",W(t.lastRunAt),t.consecutiveFailures===0?e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-success",children:e.jsx("path",{d:"M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2.5-2.5a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z"})}):e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-error",children:e.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})]}),t.totalRuns>0&&e.jsxs("span",{children:[t.totalRuns," run",t.totalRuns!==1?"s":""]}),t.cwd&&e.jsx("span",{className:"font-mono-code truncate max-w-[200px]",title:t.cwd,children:t.cwd})]})]})]},t.id))}),V=e.jsxs("div",{className:"rounded-xl bg-cc-card overflow-hidden",children:[e.jsxs("button",{onClick:()=>S(!f),className:"w-full flex items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-cc-hover transition-colors",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`w-3 h-3 text-cc-muted transition-transform ${f?"rotate-90":""}`,children:e.jsx("path",{d:"M6 4l4 4-4 4",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("span",{className:"text-sm font-medium text-cc-fg",children:"New Scheduled Task"})]}),f&&e.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[e.jsx(T,{form:r,onChange:v}),e.jsx("div",{className:"text-[10px] text-cc-muted",children:"Scheduled tasks run with full autonomy (bypassPermissions)"}),e.jsx("button",{onClick:C,disabled:!r.name.trim()||!r.prompt.trim()||h,className:`px-4 py-2.5 min-h-[44px] text-sm font-medium rounded-lg transition-colors ${r.name.trim()&&r.prompt.trim()&&!h?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:h?"Creating...":"Create"})]})]}),Z=e.jsxs("div",{className:"w-full max-w-2xl max-h-[90dvh] sm:max-h-[80dvh] mx-0 sm:mx-4 flex flex-col bg-cc-bg rounded-t-[14px] sm:rounded-[14px] shadow-2xl overflow-hidden",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 py-3 sm:py-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Scheduled Tasks"}),e.jsx("p",{className:"text-xs text-cc-muted mt-0.5",children:"Run autonomous Claude Code or Codex sessions on a schedule"})]}),s&&e.jsx("button",{onClick:s,className:"w-8 h-8 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 py-3 sm:py-4 pb-safe space-y-4",children:[O,H,V]})]});return _.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/50",onClick:s,children:Z}),document.body)}function K({job:s,isRunning:p,onStartEdit:c,onDelete:d,onToggle:o,onRunNow:g}){return e.jsxs("div",{className:"group flex items-start gap-3 px-3 py-3 min-h-[44px] rounded-lg hover:bg-cc-hover/60 transition-colors",children:[e.jsx("div",{className:"shrink-0 mt-0.5 w-7 h-7 rounded-md bg-cc-primary/10 flex items-center justify-center",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5 text-cc-primary",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 6v6l4 2"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:s.name}),e.jsx("span",{className:`text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 ${s.backendType==="codex"?"text-blue-500 bg-blue-500/10":"text-[#5BA8A0] bg-[#5BA8A0]/10"}`,children:s.backendType==="codex"?"Codex":"Claude"}),s.consecutiveFailures>0&&e.jsxs("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-error bg-cc-error/10",children:[s.consecutiveFailures," fail",s.consecutiveFailures!==1?"s":""]}),!s.enabled&&e.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-muted bg-cc-hover",children:"Paused"})]}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted line-clamp-1 leading-relaxed",children:s.prompt}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 mt-1 text-[11px] text-cc-muted",children:[e.jsx("span",{children:F(s.schedule,s.recurring)}),s.nextRunAt!=null&&s.enabled&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-cc-border",children:"·"}),e.jsxs("span",{children:["Next ",J(s.nextRunAt)]})]}),s.lastRunAt!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-cc-border",children:"·"}),e.jsxs("span",{className:"flex items-center gap-0.5",children:["Last ",W(s.lastRunAt),s.consecutiveFailures===0?e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 text-cc-success",children:e.jsx("path",{d:"M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2.5-2.5a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z"})}):e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 text-cc-error",children:e.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})]})]}),s.totalRuns>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-cc-border",children:"·"}),e.jsxs("span",{children:[s.totalRuns," run",s.totalRuns!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:o,className:`relative w-9 h-5 rounded-full transition-colors cursor-pointer shrink-0 ${s.enabled?"bg-cc-primary":"bg-cc-border"}`,title:s.enabled?"Disable":"Enable",children:e.jsx("span",{className:`absolute top-[2px] w-4 h-4 rounded-full bg-white transition-transform ${s.enabled?"left-[17px]":"left-[2px]"}`})}),e.jsx("button",{onClick:g,disabled:p,className:`p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md transition-colors cursor-pointer ${p?"text-cc-muted cursor-not-allowed":"text-cc-primary hover:bg-cc-primary/10"}`,"aria-label":"Run now",title:p?"Running...":"Run now",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M8 5v14l11-7z"})})}),e.jsx("button",{onClick:c,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-active transition-colors cursor-pointer","aria-label":"Edit",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5Z"})]})}),e.jsx("button",{onClick:d,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-error hover:bg-cc-error/10 transition-colors cursor-pointer","aria-label":"Delete",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14Z"})})})]})]})}function T({form:s,onChange:p}){const c=n=>p({...s,...n}),[d,o]=a.useState(null),[g,m]=a.useState(!1),x=a.useRef(null),[l,y]=a.useState(!1),[u,w]=a.useState(!1),r=a.useRef(null),v=d||U(s.backendType),h=v.find(n=>n.value===s.model)||v[0];a.useEffect(()=>{o(null),s.backendType==="codex"&&j.getBackendModels(s.backendType).then(n=>{if(n.length>0){const C=Y(n);o(C),C.some(R=>R.value===s.model)||c({model:C[0].value})}}).catch(()=>{})},[s.backendType]),a.useEffect(()=>{s.model||c({model:B(s.backendType)})},[]);const M=a.useMemo(()=>[x],[]),f=a.useCallback(()=>m(!1),[]);z(M,f,g);const S=a.useMemo(()=>[r],[]),k=a.useCallback(()=>w(!1),[]);z(S,k,u);const E=s.cwd?s.cwd.split("/").pop()||s.cwd:"Select folder";return e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("input",{type:"text",value:s.name,onChange:n=>c({name:n.target.value}),placeholder:"Task name (e.g. Daily test suite)",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("textarea",{value:s.prompt,onChange:n=>c({prompt:n.target.value}),placeholder:"Prompt for the session (e.g. Run the test suite and fix any failures)",rows:4,className:"w-full px-3 py-2.5 text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 resize-y transition-shadow",style:{minHeight:"100px"}}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>c({recurring:!0}),className:`px-2.5 py-2 min-h-[44px] text-xs font-medium rounded-lg transition-colors cursor-pointer ${s.recurring?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:"Recurring"}),e.jsx("button",{onClick:()=>c({recurring:!1}),className:`px-2.5 py-2 min-h-[44px] text-xs font-medium rounded-lg transition-colors cursor-pointer ${s.recurring?"bg-cc-hover text-cc-muted hover:text-cc-fg":"bg-cc-primary text-white"}`,children:"One-time"})]}),s.recurring?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:G.map(n=>e.jsx("button",{onClick:()=>c({schedule:n.value}),className:`px-2.5 py-2 min-h-[44px] text-xs font-medium rounded-md transition-colors cursor-pointer ${s.schedule===n.value?"bg-cc-primary/20 text-cc-primary":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:n.label},n.value))}),e.jsx("input",{type:"text",value:s.schedule,onChange:n=>c({schedule:n.target.value}),placeholder:"Cron expression (e.g. 0 8 * * *)",className:"w-full px-3 py-2.5 min-h-[44px] text-sm font-mono-code bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("div",{className:"text-[10px] text-cc-muted",children:F(s.schedule,!0)})]}):e.jsx("input",{type:"datetime-local",value:s.oneTimeDate,onChange:n=>c({oneTimeDate:n.target.value}),className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("div",{className:"relative",ref:r,children:[e.jsxs("button",{onClick:()=>w(!u),className:"flex items-center gap-1.5 px-2.5 py-2 min-h-[44px] text-xs font-medium text-cc-fg rounded-lg hover:bg-cc-hover transition-colors cursor-pointer",children:[e.jsx("span",{children:s.backendType==="codex"?"Codex":"Claude Code"}),e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-50",children:e.jsx("path",{d:"M4 6l4 4 4-4"})})]}),u&&e.jsx("div",{className:"absolute left-0 bottom-full mb-1 w-40 bg-cc-card rounded-xl shadow-lg z-10 py-1",children:[{value:"claude",label:"Claude Code"},{value:"codex",label:"Codex"}].map(n=>e.jsx("button",{onClick:()=>{c({backendType:n.value,model:B(n.value)}),w(!1)},className:`w-full px-3 py-2.5 min-h-[44px] text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer ${n.value===s.backendType?"text-cc-primary font-medium":"text-cc-fg"}`,children:n.label},n.value))})]}),e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>m(!g),className:"flex items-center gap-1.5 px-2.5 py-2 min-h-[44px] text-xs text-cc-muted hover:text-cc-fg rounded-lg hover:bg-cc-hover transition-colors cursor-pointer",children:[e.jsx("span",{children:h==null?void 0:h.icon}),e.jsx("span",{children:h==null?void 0:h.label}),e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-50",children:e.jsx("path",{d:"M4 6l4 4 4-4"})})]}),g&&e.jsx("div",{className:"absolute left-0 bottom-full mb-1 w-52 bg-cc-card rounded-xl shadow-lg z-10 py-1",children:v.map(n=>e.jsxs("button",{onClick:()=>{c({model:n.value}),m(!1)},className:`w-full px-3 py-2.5 min-h-[44px] text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2 ${n.value===s.model?"text-cc-primary font-medium":"text-cc-fg"}`,children:[e.jsx("span",{children:n.icon}),n.label]},n.value))})]}),e.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-1.5 px-2.5 py-2 min-h-[44px] text-xs text-cc-muted hover:text-cc-fg rounded-lg hover:bg-cc-hover transition-colors cursor-pointer",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 opacity-60",children:e.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})}),e.jsx("span",{className:"max-w-[200px] truncate font-mono-code",children:E}),e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-50",children:e.jsx("path",{d:"M4 6l4 4 4-4"})})]}),l&&e.jsx(q,{initialPath:s.cwd||"",onSelect:n=>c({cwd:n}),onClose:()=>y(!1)})]})]})}export{X as CronManager};
1
+ import{r as a,a as j,j as e,t as W,w as _,x as B,y as U,z as Y,F as q}from"./index-BY3_XaK9.js";function z(s,p,c=!0){a.useEffect(()=>{if(!c)return;function d(o){s.some(m=>m.current&&m.current.contains(o.target))||p()}return document.addEventListener("pointerdown",d),()=>document.removeEventListener("pointerdown",d)},[s,p,c])}function J(s){const p=s-Date.now();if(p<=0)return"now";const c=Math.floor(p/6e4);if(c<60)return`in ${c}m`;const d=Math.floor(c/60);return d<24?`in ${d}h`:`in ${Math.floor(d/24)}d`}function F(s,p){if(!p)return"One-time";const c=s.trim().split(/\s+/);if(c.length!==5)return s;const[d,o,g,m,x]=c;if(s==="* * * * *")return"Every minute";if(o==="*"&&g==="*"&&m==="*"&&x==="*"&&d.startsWith("*/")){const l=parseInt(d.slice(2),10);return l===1?"Every minute":`Every ${l} minutes`}if(d==="0"&&g==="*"&&m==="*"&&x==="*"){if(o==="*")return"Every hour";if(o.startsWith("*/")){const l=parseInt(o.slice(2),10);return l===1?"Every hour":`Every ${l} hours`}}if(g==="*"&&m==="*"&&d!=="*"&&o!=="*"&&!o.includes("/")&&!o.includes(",")){const l=parseInt(o,10),y=parseInt(d,10);if(!isNaN(l)&&!isNaN(y)){const u=l>=12?"PM":"AM",w=l===0?12:l>12?l-12:l,r=y.toString().padStart(2,"0"),v=`${w}:${r} ${u}`;if(x==="*")return`Every day at ${v}`;if(x==="1-5")return`Weekdays at ${v}`;if(x==="0,6")return`Weekends at ${v}`}}return s}const $={name:"",prompt:"",recurring:!0,schedule:"0 8 * * *",oneTimeDate:"",backendType:"claude",model:B("claude"),cwd:""},G=[{label:"Every hour",value:"0 * * * *"},{label:"Every day at 8am",value:"0 8 * * *"},{label:"Every 2 hours",value:"0 */2 * * *"},{label:"Weekdays at 9am",value:"0 9 * * 1-5"}];function X({onClose:s,embedded:p=!1}){const[c,d]=a.useState([]),[o,g]=a.useState(!0),[m,x]=a.useState(""),[l,y]=a.useState(null),[u,w]=a.useState($),[r,v]=a.useState($),[h,M]=a.useState(!1),[f,S]=a.useState(!1),[k,E]=a.useState(new Set),n=a.useCallback(()=>{j.listCronJobs().then(d).catch(()=>{}).finally(()=>g(!1))},[]);a.useEffect(()=>{n();const t=setInterval(n,1e4);return()=>clearInterval(t)},[n]);async function C(){const t=r.name.trim(),i=r.prompt.trim();if(!t||!i)return;M(!0),x("");let N=r.schedule;!r.recurring&&r.oneTimeDate&&(N=new Date(r.oneTimeDate).toISOString());try{await j.createCronJob({name:t,prompt:i,schedule:N,recurring:r.recurring,backendType:r.backendType,model:r.model.trim()||void 0,cwd:r.cwd.trim()||void 0}),v($),S(!1),n()}catch(b){x(b instanceof Error?b.message:String(b))}finally{M(!1)}}function R(t){y(t.id),w({name:t.name,prompt:t.prompt,recurring:t.recurring,schedule:t.schedule,oneTimeDate:"",backendType:t.backendType,model:t.model,cwd:t.cwd}),x("")}function D(){y(null),x("")}async function L(){if(!l)return;const t=u.name.trim(),i=u.prompt.trim();if(!t||!i)return;let N=u.schedule;!u.recurring&&u.oneTimeDate&&(N=new Date(u.oneTimeDate).toISOString());try{await j.updateCronJob(l,{name:t,prompt:i,schedule:N,recurring:u.recurring,backendType:u.backendType,model:u.model.trim()||void 0,cwd:u.cwd.trim()||void 0}),y(null),x(""),n()}catch(b){x(b instanceof Error?b.message:String(b))}}async function A(t){try{await j.deleteCronJob(t),l===t&&y(null),n()}catch(i){x(i instanceof Error?i.message:String(i))}}async function I(t){try{await j.toggleCronJob(t),n()}catch(i){x(i instanceof Error?i.message:String(i))}}async function P(t){E(i=>new Set(i).add(t));try{await j.runCronJob(t),n()}catch(i){x(i instanceof Error?i.message:String(i))}finally{E(i=>{const N=new Set(i);return N.delete(t),N})}}if(p)return e.jsx("div",{className:"h-full bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto",children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 sm:px-6 py-6 sm:py-10 pb-safe",children:[e.jsx("div",{className:"flex items-start justify-between gap-3 mb-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Scheduled Tasks"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-cc-muted leading-relaxed",children:"Run autonomous Claude Code or Codex sessions on a schedule."})]})}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 mb-5",children:[e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:()=>S(!f),className:`flex items-center gap-1.5 px-3.5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer shrink-0 ${f?"bg-cc-active text-cc-fg":"bg-cc-primary hover:bg-cc-primary-hover text-white"}`,children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:f?e.jsx("path",{d:"M18 6 6 18M6 6l12 12"}):e.jsx("path",{d:"M12 5v14M5 12h14"})}),e.jsx("span",{className:"hidden sm:inline",children:f?"Cancel":"New Task"})]})]}),f&&e.jsxs("div",{className:"mb-6 rounded-xl bg-cc-card p-4 sm:p-5 space-y-3",style:{animation:"fadeSlideIn 150ms ease-out"},children:[e.jsx(T,{form:r,onChange:v}),e.jsx("p",{className:"text-[10px] text-cc-muted",children:"Scheduled tasks run with full autonomy (bypassPermissions)"}),m&&f&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 text-xs text-cc-error",children:m}),e.jsx("div",{className:"flex items-center justify-end pt-1",children:e.jsx("button",{onClick:C,disabled:!r.name.trim()||!r.prompt.trim()||h,className:`px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${r.name.trim()&&r.prompt.trim()&&!h?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:h?"Creating...":"Create"})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-[12px] text-cc-muted",children:[e.jsxs("span",{children:[c.length," task",c.length!==1?"s":""]}),c.filter(t=>t.enabled).length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-cc-border",children:"·"}),e.jsxs("span",{children:[c.filter(t=>t.enabled).length," active"]})]})]}),o?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"Loading scheduled tasks..."}):c.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"No scheduled tasks yet."}):e.jsx("div",{className:"space-y-1",children:c.map(t=>l===t.id?e.jsxs("div",{className:"rounded-xl bg-cc-card p-4 space-y-3",style:{animation:"fadeSlideIn 150ms ease-out"},children:[e.jsx(T,{form:u,onChange:w}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:D,className:"px-3 py-2.5 min-h-[44px] text-sm rounded-lg text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{onClick:()=>void L(),className:"px-4 py-2.5 min-h-[44px] text-sm rounded-lg font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Save"})]})]},t.id):e.jsx(K,{job:t,isRunning:k.has(t.id),onStartEdit:()=>R(t),onDelete:()=>void A(t.id),onToggle:()=>void I(t.id),onRunNow:()=>void P(t.id)},t.id))}),m&&!f&&e.jsx("div",{className:"mt-4 px-3 py-2 rounded-lg bg-cc-error/10 text-xs text-cc-error",children:m})]})});const O=m&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 text-xs text-cc-error",children:m}),H=o?e.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"Loading scheduled tasks..."}):c.length===0?e.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"No scheduled tasks yet."}):e.jsx("div",{className:"space-y-3",children:c.map(t=>e.jsxs("div",{className:"rounded-xl bg-cc-card overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg flex-1 truncate",children:t.name}),e.jsx("span",{className:`text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 ${t.backendType==="codex"?"text-blue-500 bg-blue-500/10":"text-[#5BA8A0] bg-[#5BA8A0]/10"}`,children:t.backendType==="codex"?"Codex":"Claude"}),t.consecutiveFailures>0&&e.jsxs("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-error bg-cc-error/10",children:[t.consecutiveFailures," fail",t.consecutiveFailures!==1?"s":""]}),e.jsx("button",{onClick:()=>I(t.id),className:`relative w-10 h-6 rounded-full transition-colors cursor-pointer shrink-0 ${t.enabled?"bg-cc-primary":"bg-cc-border"}`,title:t.enabled?"Disable":"Enable",children:e.jsx("span",{className:`absolute top-[3px] w-[18px] h-[18px] rounded-full bg-white transition-transform ${t.enabled?"left-[19px]":"left-[3px]"}`})}),l===t.id?e.jsx("button",{onClick:D,className:"text-xs px-2 py-1.5 min-h-[44px] text-cc-muted hover:text-cc-fg cursor-pointer",children:"Cancel"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>P(t.id),disabled:k.has(t.id),className:`text-xs px-2 py-1.5 min-h-[44px] cursor-pointer ${k.has(t.id)?"text-cc-muted cursor-not-allowed":"text-cc-primary hover:text-cc-primary-hover"}`,children:k.has(t.id)?"Running...":"Run Now"}),e.jsx("button",{onClick:()=>R(t),className:"text-xs px-2 py-1.5 min-h-[44px] text-cc-muted hover:text-cc-fg cursor-pointer",children:"Edit"}),e.jsx("button",{onClick:()=>A(t.id),className:"text-xs px-2 py-1.5 min-h-[44px] text-cc-muted hover:text-cc-error cursor-pointer",children:"Delete"})]})]}),l===t.id&&e.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[e.jsx(T,{form:u,onChange:w}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:L,className:"px-4 py-2.5 min-h-[44px] text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white rounded-lg transition-colors cursor-pointer",children:"Save"}),e.jsx("button",{onClick:D,className:"px-3 py-2.5 min-h-[44px] text-sm font-medium text-cc-muted hover:text-cc-fg rounded-lg transition-colors cursor-pointer",children:"Cancel"})]})]}),l!==t.id&&e.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsx("div",{className:"text-xs text-cc-muted truncate",title:t.prompt,children:t.prompt}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-cc-muted",children:[e.jsx("span",{children:F(t.schedule,t.recurring)}),t.nextRunAt!=null&&t.enabled&&e.jsxs("span",{children:["Next: ",J(t.nextRunAt)]}),t.lastRunAt!=null&&e.jsxs("span",{className:"flex items-center gap-1",children:["Last: ",W(t.lastRunAt),t.consecutiveFailures===0?e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-success",children:e.jsx("path",{d:"M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2.5-2.5a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z"})}):e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-error",children:e.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})]}),t.totalRuns>0&&e.jsxs("span",{children:[t.totalRuns," run",t.totalRuns!==1?"s":""]}),t.cwd&&e.jsx("span",{className:"font-mono-code truncate max-w-[200px]",title:t.cwd,children:t.cwd})]})]})]},t.id))}),V=e.jsxs("div",{className:"rounded-xl bg-cc-card overflow-hidden",children:[e.jsxs("button",{onClick:()=>S(!f),className:"w-full flex items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-cc-hover transition-colors",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`w-3 h-3 text-cc-muted transition-transform ${f?"rotate-90":""}`,children:e.jsx("path",{d:"M6 4l4 4-4 4",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("span",{className:"text-sm font-medium text-cc-fg",children:"New Scheduled Task"})]}),f&&e.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[e.jsx(T,{form:r,onChange:v}),e.jsx("div",{className:"text-[10px] text-cc-muted",children:"Scheduled tasks run with full autonomy (bypassPermissions)"}),e.jsx("button",{onClick:C,disabled:!r.name.trim()||!r.prompt.trim()||h,className:`px-4 py-2.5 min-h-[44px] text-sm font-medium rounded-lg transition-colors ${r.name.trim()&&r.prompt.trim()&&!h?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:h?"Creating...":"Create"})]})]}),Z=e.jsxs("div",{className:"w-full max-w-2xl max-h-[90dvh] sm:max-h-[80dvh] mx-0 sm:mx-4 flex flex-col bg-cc-bg rounded-t-[14px] sm:rounded-[14px] shadow-2xl overflow-hidden",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 py-3 sm:py-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Scheduled Tasks"}),e.jsx("p",{className:"text-xs text-cc-muted mt-0.5",children:"Run autonomous Claude Code or Codex sessions on a schedule"})]}),s&&e.jsx("button",{onClick:s,className:"w-8 h-8 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 py-3 sm:py-4 pb-safe space-y-4",children:[O,H,V]})]});return _.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/50",onClick:s,children:Z}),document.body)}function K({job:s,isRunning:p,onStartEdit:c,onDelete:d,onToggle:o,onRunNow:g}){return e.jsxs("div",{className:"group flex items-start gap-3 px-3 py-3 min-h-[44px] rounded-lg hover:bg-cc-hover/60 transition-colors",children:[e.jsx("div",{className:"shrink-0 mt-0.5 w-7 h-7 rounded-md bg-cc-primary/10 flex items-center justify-center",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5 text-cc-primary",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 6v6l4 2"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:s.name}),e.jsx("span",{className:`text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 ${s.backendType==="codex"?"text-blue-500 bg-blue-500/10":"text-[#5BA8A0] bg-[#5BA8A0]/10"}`,children:s.backendType==="codex"?"Codex":"Claude"}),s.consecutiveFailures>0&&e.jsxs("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-error bg-cc-error/10",children:[s.consecutiveFailures," fail",s.consecutiveFailures!==1?"s":""]}),!s.enabled&&e.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-muted bg-cc-hover",children:"Paused"})]}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted line-clamp-1 leading-relaxed",children:s.prompt}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 mt-1 text-[11px] text-cc-muted",children:[e.jsx("span",{children:F(s.schedule,s.recurring)}),s.nextRunAt!=null&&s.enabled&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-cc-border",children:"·"}),e.jsxs("span",{children:["Next ",J(s.nextRunAt)]})]}),s.lastRunAt!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-cc-border",children:"·"}),e.jsxs("span",{className:"flex items-center gap-0.5",children:["Last ",W(s.lastRunAt),s.consecutiveFailures===0?e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 text-cc-success",children:e.jsx("path",{d:"M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2.5-2.5a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z"})}):e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 text-cc-error",children:e.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})]})]}),s.totalRuns>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-cc-border",children:"·"}),e.jsxs("span",{children:[s.totalRuns," run",s.totalRuns!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:o,className:`relative w-9 h-5 rounded-full transition-colors cursor-pointer shrink-0 ${s.enabled?"bg-cc-primary":"bg-cc-border"}`,title:s.enabled?"Disable":"Enable",children:e.jsx("span",{className:`absolute top-[2px] w-4 h-4 rounded-full bg-white transition-transform ${s.enabled?"left-[17px]":"left-[2px]"}`})}),e.jsx("button",{onClick:g,disabled:p,className:`p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md transition-colors cursor-pointer ${p?"text-cc-muted cursor-not-allowed":"text-cc-primary hover:bg-cc-primary/10"}`,"aria-label":"Run now",title:p?"Running...":"Run now",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M8 5v14l11-7z"})})}),e.jsx("button",{onClick:c,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-active transition-colors cursor-pointer","aria-label":"Edit",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5Z"})]})}),e.jsx("button",{onClick:d,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-error hover:bg-cc-error/10 transition-colors cursor-pointer","aria-label":"Delete",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14Z"})})})]})]})}function T({form:s,onChange:p}){const c=n=>p({...s,...n}),[d,o]=a.useState(null),[g,m]=a.useState(!1),x=a.useRef(null),[l,y]=a.useState(!1),[u,w]=a.useState(!1),r=a.useRef(null),v=d||U(s.backendType),h=v.find(n=>n.value===s.model)||v[0];a.useEffect(()=>{o(null),s.backendType==="codex"&&j.getBackendModels(s.backendType).then(n=>{if(n.length>0){const C=Y(n);o(C),C.some(R=>R.value===s.model)||c({model:C[0].value})}}).catch(()=>{})},[s.backendType]),a.useEffect(()=>{s.model||c({model:B(s.backendType)})},[]);const M=a.useMemo(()=>[x],[]),f=a.useCallback(()=>m(!1),[]);z(M,f,g);const S=a.useMemo(()=>[r],[]),k=a.useCallback(()=>w(!1),[]);z(S,k,u);const E=s.cwd?s.cwd.split("/").pop()||s.cwd:"Select folder";return e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("input",{type:"text",value:s.name,onChange:n=>c({name:n.target.value}),placeholder:"Task name (e.g. Daily test suite)",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("textarea",{value:s.prompt,onChange:n=>c({prompt:n.target.value}),placeholder:"Prompt for the session (e.g. Run the test suite and fix any failures)",rows:4,className:"w-full px-3 py-2.5 text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 resize-y transition-shadow",style:{minHeight:"100px"}}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>c({recurring:!0}),className:`px-2.5 py-2 min-h-[44px] text-xs font-medium rounded-lg transition-colors cursor-pointer ${s.recurring?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:"Recurring"}),e.jsx("button",{onClick:()=>c({recurring:!1}),className:`px-2.5 py-2 min-h-[44px] text-xs font-medium rounded-lg transition-colors cursor-pointer ${s.recurring?"bg-cc-hover text-cc-muted hover:text-cc-fg":"bg-cc-primary text-white"}`,children:"One-time"})]}),s.recurring?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:G.map(n=>e.jsx("button",{onClick:()=>c({schedule:n.value}),className:`px-2.5 py-2 min-h-[44px] text-xs font-medium rounded-md transition-colors cursor-pointer ${s.schedule===n.value?"bg-cc-primary/20 text-cc-primary":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:n.label},n.value))}),e.jsx("input",{type:"text",value:s.schedule,onChange:n=>c({schedule:n.target.value}),placeholder:"Cron expression (e.g. 0 8 * * *)",className:"w-full px-3 py-2.5 min-h-[44px] text-sm font-mono-code bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("div",{className:"text-[10px] text-cc-muted",children:F(s.schedule,!0)})]}):e.jsx("input",{type:"datetime-local",value:s.oneTimeDate,onChange:n=>c({oneTimeDate:n.target.value}),className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("div",{className:"relative",ref:r,children:[e.jsxs("button",{onClick:()=>w(!u),className:"flex items-center gap-1.5 px-2.5 py-2 min-h-[44px] text-xs font-medium text-cc-fg rounded-lg hover:bg-cc-hover transition-colors cursor-pointer",children:[e.jsx("span",{children:s.backendType==="codex"?"Codex":"Claude Code"}),e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-50",children:e.jsx("path",{d:"M4 6l4 4 4-4"})})]}),u&&e.jsx("div",{className:"absolute left-0 bottom-full mb-1 w-40 bg-cc-card rounded-xl shadow-lg z-10 py-1",children:[{value:"claude",label:"Claude Code"},{value:"codex",label:"Codex"}].map(n=>e.jsx("button",{onClick:()=>{c({backendType:n.value,model:B(n.value)}),w(!1)},className:`w-full px-3 py-2.5 min-h-[44px] text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer ${n.value===s.backendType?"text-cc-primary font-medium":"text-cc-fg"}`,children:n.label},n.value))})]}),e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>m(!g),className:"flex items-center gap-1.5 px-2.5 py-2 min-h-[44px] text-xs text-cc-muted hover:text-cc-fg rounded-lg hover:bg-cc-hover transition-colors cursor-pointer",children:[e.jsx("span",{children:h==null?void 0:h.icon}),e.jsx("span",{children:h==null?void 0:h.label}),e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-50",children:e.jsx("path",{d:"M4 6l4 4 4-4"})})]}),g&&e.jsx("div",{className:"absolute left-0 bottom-full mb-1 w-52 bg-cc-card rounded-xl shadow-lg z-10 py-1",children:v.map(n=>e.jsxs("button",{onClick:()=>{c({model:n.value}),m(!1)},className:`w-full px-3 py-2.5 min-h-[44px] text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2 ${n.value===s.model?"text-cc-primary font-medium":"text-cc-fg"}`,children:[e.jsx("span",{children:n.icon}),n.label]},n.value))})]}),e.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-1.5 px-2.5 py-2 min-h-[44px] text-xs text-cc-muted hover:text-cc-fg rounded-lg hover:bg-cc-hover transition-colors cursor-pointer",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 opacity-60",children:e.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})}),e.jsx("span",{className:"max-w-[200px] truncate font-mono-code",children:E}),e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-50",children:e.jsx("path",{d:"M4 6l4 4 4-4"})})]}),l&&e.jsx(q,{initialPath:s.cwd||"",onSelect:n=>c({cwd:n}),onClose:()=>y(!1)})]})]})}export{X as CronManager};
@@ -1 +1 @@
1
- import{r,a,j as e,u as N,n as y,b as _,L as h}from"./index-D-JiBkdW.js";function L({embedded:d=!1}){const[g,p]=r.useState(!1),[b,v]=r.useState(""),[x,f]=r.useState(""),[s,m]=r.useState(null),[c,j]=r.useState([]),[o,w]=r.useState([]);r.useEffect(()=>{a.getTailscaleStatus().then(m).catch(()=>m({installed:!1,binaryPath:null,connected:!1,dnsName:null,funnelActive:!1,funnelUrl:null,error:"Could not reach Tailscale status endpoint"})),a.getSettings().then(t=>{if(t.linearApiKeyConfigured)return a.getLinearConnection().then(n=>{p(n.connected);const i=n.viewerName||n.viewerEmail||"Connected account",l=n.teamName?` • ${n.teamName}`:"";v(`${i}${l}`)})}).catch(t=>f(t instanceof Error?t.message:String(t))),a.listLinearOAuthConnections().then(t=>j(t.connections)).catch(()=>{}),a.listAgents().then(t=>{w(t.filter(n=>{var i,l;return(l=(i=n.triggers)==null?void 0:i.linear)==null?void 0:l.enabled}))}).catch(()=>{})},[]);const u=c.filter(t=>t.status==="connected").length;return e.jsx("div",{className:`${d?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Integrations"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Connect tools and open their dedicated settings page."})]}),!d&&e.jsx("button",{onClick:()=>{const t=N.getState().currentSessionId;t?y(t):_()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"})]}),x&&e.jsx("div",{className:"mb-4 px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:x}),e.jsxs("section",{className:"group relative overflow-hidden rounded-3xl border border-cc-border/80 bg-cc-card p-5 pb-16 sm:p-7 sm:pb-7 transition-all duration-300 hover:border-cc-primary/35 hover:shadow-[0_18px_44px_rgba(0,0,0,0.18)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(80%_140%_at_100%_0%,rgba(251,146,60,0.18),transparent_52%)]"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-30 bg-[linear-gradient(120deg,transparent_0%,rgba(255,255,255,0.04)_35%,transparent_62%)]"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cc-border bg-cc-hover/55 px-3 py-1.5 text-xs tracking-wide text-cc-muted",children:[e.jsx(h,{className:"h-3.5 w-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear Tickets"}),g&&e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-cc-success shadow-[0_0_0_3px_rgba(34,197,94,0.15)]","aria-label":"Connected",title:"Connected"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:e.jsx("h2",{className:"text-[clamp(1.45rem,2.6vw,2rem)] font-semibold leading-[1.12] tracking-tight text-cc-fg",children:"Issue context before first prompt"})}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-cc-muted sm:text-[15px]",children:"Connect your workspace, search an issue from Home, and inject scope automatically when a session starts."}),e.jsx("div",{className:"mt-4 inline-flex max-w-full items-center rounded-lg border border-cc-border/80 bg-black/10 px-3 py-1.5 text-xs text-cc-muted/95",children:e.jsx("span",{className:"truncate",children:b||"No workspace linked yet"})})]}),e.jsx("div",{className:"absolute bottom-0 right-0 sm:bottom-0 sm:right-0 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/integrations/linear"},"aria-label":"Open Linear Tickets settings",title:"Open Linear Tickets settings",className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-cc-primary/28 bg-cc-primary/12 text-cc-fg transition-colors hover:border-cc-primary/50 hover:bg-cc-primary/20 focus:outline-none focus:ring-2 focus:ring-cc-primary/35 cursor-pointer",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M9.67 4.53 10 2h4l.33 2.53a7.9 7.9 0 0 1 1.7.7l2.03-1.55 2.83 2.83-1.55 2.03c.28.54.51 1.1.7 1.7L22 10v4l-2.53.33a7.9 7.9 0 0 1-.7 1.7l1.55 2.03-2.83 2.83-2.03-1.55c-.54.28-1.1.51-1.7.7L14 22h-4l-.33-2.53a7.9 7.9 0 0 1-1.7-.7l-2.03 1.55-2.83-2.83 1.55-2.03a7.9 7.9 0 0 1-.7-1.7L2 14v-4l2.53-.33c.19-.6.42-1.16.7-1.7L3.68 5.94 6.5 3.1l2.03 1.55c.54-.28 1.1-.51 1.7-.7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.2"})]})})})]})]}),e.jsxs("section",{className:"group relative mt-6 overflow-hidden rounded-3xl border border-cc-border/80 bg-cc-card p-5 pb-16 sm:p-7 sm:pb-7 transition-all duration-300 hover:border-cc-primary/35 hover:shadow-[0_18px_44px_rgba(0,0,0,0.18)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(80%_140%_at_100%_0%,rgba(124,58,237,0.18),transparent_52%)]"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-30 bg-[linear-gradient(120deg,transparent_0%,rgba(255,255,255,0.04)_35%,transparent_62%)]"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cc-border bg-cc-hover/55 px-3 py-1.5 text-xs tracking-wide text-cc-muted",children:[e.jsx(h,{className:"h-3.5 w-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear OAuth Apps"}),u>0&&e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-cc-success shadow-[0_0_0_3px_rgba(34,197,94,0.15)]","aria-label":"Connected",title:"Connected"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:e.jsx("h2",{className:"text-[clamp(1.45rem,2.6vw,2rem)] font-semibold leading-[1.12] tracking-tight text-cc-fg",children:"Agent triggers via Linear"})}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-cc-muted sm:text-[15px]",children:"Create OAuth apps to trigger agents from @mentions in Linear issues. Each app can connect to a different workspace."}),e.jsx("div",{className:"mt-4 inline-flex max-w-full items-center rounded-lg border border-cc-border/80 bg-black/10 px-3 py-1.5 text-xs text-cc-muted/95",children:e.jsxs("span",{className:"truncate",children:[c.length===0?"No OAuth apps configured":`${c.length} app${c.length!==1?"s":""}, ${u} connected`,o.length>0&&` · ${o.length} agent${o.length!==1?"s":""}`]})})]}),e.jsxs("div",{className:"absolute bottom-0 right-0 sm:bottom-0 sm:right-0 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{window.location.hash="#/agents?setup=linear"},"aria-label":"Set up Linear Agent",title:"Set up Linear Agent",className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-full border border-violet-500/28 bg-violet-500/12 text-xs font-medium text-cc-fg transition-colors hover:border-violet-500/50 hover:bg-violet-500/20 focus:outline-none focus:ring-2 focus:ring-violet-500/35 cursor-pointer",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 opacity-60","aria-hidden":"true",children:e.jsx("path",{d:"M8 1.5a2.5 2.5 0 00-2.5 2.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5S9.38 1.5 8 1.5zM4 8a4 4 0 00-4 4v1.5a.5.5 0 00.5.5h15a.5.5 0 00.5-.5V12a4 4 0 00-4-4H4z"})}),"Setup Agent"]}),e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/integrations/linear-oauth"},"aria-label":"Open Linear OAuth settings",title:"Open Linear OAuth settings",className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-violet-500/28 bg-violet-500/12 text-cc-fg transition-colors hover:border-violet-500/50 hover:bg-violet-500/20 focus:outline-none focus:ring-2 focus:ring-violet-500/35 cursor-pointer",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M9.67 4.53 10 2h4l.33 2.53a7.9 7.9 0 0 1 1.7.7l2.03-1.55 2.83 2.83-1.55 2.03c.28.54.51 1.1.7 1.7L22 10v4l-2.53.33a7.9 7.9 0 0 1-.7 1.7l1.55 2.03-2.83 2.83-2.03-1.55c-.54.28-1.1.51-1.7.7L14 22h-4l-.33-2.53a7.9 7.9 0 0 1-1.7-.7l-2.03 1.55-2.83-2.83 1.55-2.03a7.9 7.9 0 0 1-.7-1.7L2 14v-4l2.53-.33c.19-.6.42-1.16.7-1.7L3.68 5.94 6.5 3.1l2.03 1.55c.54-.28 1.1-.51 1.7-.7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.2"})]})})]})]})]}),e.jsxs("section",{className:"group relative mt-6 overflow-hidden rounded-3xl border border-cc-border/80 bg-cc-card p-5 pb-16 sm:p-7 sm:pb-7 transition-all duration-300 hover:border-cc-primary/35 hover:shadow-[0_18px_44px_rgba(0,0,0,0.18)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(80%_140%_at_100%_0%,rgba(6,182,212,0.18),transparent_52%)]"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-30 bg-[linear-gradient(120deg,transparent_0%,rgba(255,255,255,0.04)_35%,transparent_62%)]"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cc-border bg-cc-hover/55 px-3 py-1.5 text-xs tracking-wide text-cc-muted",children:[e.jsx("svg",{className:"h-3.5 w-3.5 text-cc-fg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),e.jsx("span",{children:"Tailscale"}),(s==null?void 0:s.funnelActive)&&e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-cc-success shadow-[0_0_0_3px_rgba(34,197,94,0.15)]","aria-label":"Funnel active",title:"Funnel active"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:e.jsx("h2",{className:"text-[clamp(1.45rem,2.6vw,2rem)] font-semibold leading-[1.12] tracking-tight text-cc-fg",children:"HTTPS access in one click"})}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-cc-muted sm:text-[15px]",children:"Use Tailscale Funnel to expose your Companion over HTTPS with automatic TLS certificates."}),e.jsx("div",{className:"mt-4 inline-flex max-w-full items-center rounded-lg border border-cc-border/80 bg-black/10 px-3 py-1.5 text-xs text-cc-muted/95",children:e.jsx("span",{className:"truncate",children:s===null?"Checking...":s.funnelActive&&s.funnelUrl?s.funnelUrl:s.connected?s.dnsName||"Connected":s.installed?"Not connected":"Not installed"})})]}),e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/integrations/tailscale"},"aria-label":"Open Tailscale settings",title:"Open Tailscale settings",className:"absolute bottom-0 right-0 sm:bottom-0 sm:right-0 inline-flex h-10 w-10 items-center justify-center rounded-full border border-cc-primary/28 bg-cc-primary/12 text-cc-fg transition-colors hover:border-cc-primary/50 hover:bg-cc-primary/20 focus:outline-none focus:ring-2 focus:ring-cc-primary/35 cursor-pointer",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M9.67 4.53 10 2h4l.33 2.53a7.9 7.9 0 0 1 1.7.7l2.03-1.55 2.83 2.83-1.55 2.03c.28.54.51 1.1.7 1.7L22 10v4l-2.53.33a7.9 7.9 0 0 1-.7 1.7l1.55 2.03-2.83 2.83-2.03-1.55c-.54.28-1.1.51-1.7.7L14 22h-4l-.33-2.53a7.9 7.9 0 0 1-1.7-.7l-2.03 1.55-2.83-2.83 1.55-2.03a7.9 7.9 0 0 1-.7-1.7L2 14v-4l2.53-.33c.19-.6.42-1.16.7-1.7L3.68 5.94 6.5 3.1l2.03 1.55c.54-.28 1.1-.51 1.7-.7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.2"})]})})]})]})]})})}export{L as IntegrationsPage};
1
+ import{r,a,j as e,u as N,n as y,b as _,L as h}from"./index-BY3_XaK9.js";function L({embedded:d=!1}){const[g,p]=r.useState(!1),[b,v]=r.useState(""),[x,f]=r.useState(""),[s,m]=r.useState(null),[c,j]=r.useState([]),[o,w]=r.useState([]);r.useEffect(()=>{a.getTailscaleStatus().then(m).catch(()=>m({installed:!1,binaryPath:null,connected:!1,dnsName:null,funnelActive:!1,funnelUrl:null,error:"Could not reach Tailscale status endpoint"})),a.getSettings().then(t=>{if(t.linearApiKeyConfigured)return a.getLinearConnection().then(n=>{p(n.connected);const i=n.viewerName||n.viewerEmail||"Connected account",l=n.teamName?` • ${n.teamName}`:"";v(`${i}${l}`)})}).catch(t=>f(t instanceof Error?t.message:String(t))),a.listLinearOAuthConnections().then(t=>j(t.connections)).catch(()=>{}),a.listAgents().then(t=>{w(t.filter(n=>{var i,l;return(l=(i=n.triggers)==null?void 0:i.linear)==null?void 0:l.enabled}))}).catch(()=>{})},[]);const u=c.filter(t=>t.status==="connected").length;return e.jsx("div",{className:`${d?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Integrations"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Connect tools and open their dedicated settings page."})]}),!d&&e.jsx("button",{onClick:()=>{const t=N.getState().currentSessionId;t?y(t):_()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"})]}),x&&e.jsx("div",{className:"mb-4 px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:x}),e.jsxs("section",{className:"group relative overflow-hidden rounded-3xl border border-cc-border/80 bg-cc-card p-5 pb-16 sm:p-7 sm:pb-7 transition-all duration-300 hover:border-cc-primary/35 hover:shadow-[0_18px_44px_rgba(0,0,0,0.18)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(80%_140%_at_100%_0%,rgba(251,146,60,0.18),transparent_52%)]"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-30 bg-[linear-gradient(120deg,transparent_0%,rgba(255,255,255,0.04)_35%,transparent_62%)]"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cc-border bg-cc-hover/55 px-3 py-1.5 text-xs tracking-wide text-cc-muted",children:[e.jsx(h,{className:"h-3.5 w-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear Tickets"}),g&&e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-cc-success shadow-[0_0_0_3px_rgba(34,197,94,0.15)]","aria-label":"Connected",title:"Connected"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:e.jsx("h2",{className:"text-[clamp(1.45rem,2.6vw,2rem)] font-semibold leading-[1.12] tracking-tight text-cc-fg",children:"Issue context before first prompt"})}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-cc-muted sm:text-[15px]",children:"Connect your workspace, search an issue from Home, and inject scope automatically when a session starts."}),e.jsx("div",{className:"mt-4 inline-flex max-w-full items-center rounded-lg border border-cc-border/80 bg-black/10 px-3 py-1.5 text-xs text-cc-muted/95",children:e.jsx("span",{className:"truncate",children:b||"No workspace linked yet"})})]}),e.jsx("div",{className:"absolute bottom-0 right-0 sm:bottom-0 sm:right-0 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/integrations/linear"},"aria-label":"Open Linear Tickets settings",title:"Open Linear Tickets settings",className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-cc-primary/28 bg-cc-primary/12 text-cc-fg transition-colors hover:border-cc-primary/50 hover:bg-cc-primary/20 focus:outline-none focus:ring-2 focus:ring-cc-primary/35 cursor-pointer",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M9.67 4.53 10 2h4l.33 2.53a7.9 7.9 0 0 1 1.7.7l2.03-1.55 2.83 2.83-1.55 2.03c.28.54.51 1.1.7 1.7L22 10v4l-2.53.33a7.9 7.9 0 0 1-.7 1.7l1.55 2.03-2.83 2.83-2.03-1.55c-.54.28-1.1.51-1.7.7L14 22h-4l-.33-2.53a7.9 7.9 0 0 1-1.7-.7l-2.03 1.55-2.83-2.83 1.55-2.03a7.9 7.9 0 0 1-.7-1.7L2 14v-4l2.53-.33c.19-.6.42-1.16.7-1.7L3.68 5.94 6.5 3.1l2.03 1.55c.54-.28 1.1-.51 1.7-.7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.2"})]})})})]})]}),e.jsxs("section",{className:"group relative mt-6 overflow-hidden rounded-3xl border border-cc-border/80 bg-cc-card p-5 pb-16 sm:p-7 sm:pb-7 transition-all duration-300 hover:border-cc-primary/35 hover:shadow-[0_18px_44px_rgba(0,0,0,0.18)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(80%_140%_at_100%_0%,rgba(124,58,237,0.18),transparent_52%)]"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-30 bg-[linear-gradient(120deg,transparent_0%,rgba(255,255,255,0.04)_35%,transparent_62%)]"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cc-border bg-cc-hover/55 px-3 py-1.5 text-xs tracking-wide text-cc-muted",children:[e.jsx(h,{className:"h-3.5 w-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear OAuth Apps"}),u>0&&e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-cc-success shadow-[0_0_0_3px_rgba(34,197,94,0.15)]","aria-label":"Connected",title:"Connected"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:e.jsx("h2",{className:"text-[clamp(1.45rem,2.6vw,2rem)] font-semibold leading-[1.12] tracking-tight text-cc-fg",children:"Agent triggers via Linear"})}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-cc-muted sm:text-[15px]",children:"Create OAuth apps to trigger agents from @mentions in Linear issues. Each app can connect to a different workspace."}),e.jsx("div",{className:"mt-4 inline-flex max-w-full items-center rounded-lg border border-cc-border/80 bg-black/10 px-3 py-1.5 text-xs text-cc-muted/95",children:e.jsxs("span",{className:"truncate",children:[c.length===0?"No OAuth apps configured":`${c.length} app${c.length!==1?"s":""}, ${u} connected`,o.length>0&&` · ${o.length} agent${o.length!==1?"s":""}`]})})]}),e.jsxs("div",{className:"absolute bottom-0 right-0 sm:bottom-0 sm:right-0 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{window.location.hash="#/agents?setup=linear"},"aria-label":"Set up Linear Agent",title:"Set up Linear Agent",className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-full border border-violet-500/28 bg-violet-500/12 text-xs font-medium text-cc-fg transition-colors hover:border-violet-500/50 hover:bg-violet-500/20 focus:outline-none focus:ring-2 focus:ring-violet-500/35 cursor-pointer",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 opacity-60","aria-hidden":"true",children:e.jsx("path",{d:"M8 1.5a2.5 2.5 0 00-2.5 2.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5S9.38 1.5 8 1.5zM4 8a4 4 0 00-4 4v1.5a.5.5 0 00.5.5h15a.5.5 0 00.5-.5V12a4 4 0 00-4-4H4z"})}),"Setup Agent"]}),e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/integrations/linear-oauth"},"aria-label":"Open Linear OAuth settings",title:"Open Linear OAuth settings",className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-violet-500/28 bg-violet-500/12 text-cc-fg transition-colors hover:border-violet-500/50 hover:bg-violet-500/20 focus:outline-none focus:ring-2 focus:ring-violet-500/35 cursor-pointer",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M9.67 4.53 10 2h4l.33 2.53a7.9 7.9 0 0 1 1.7.7l2.03-1.55 2.83 2.83-1.55 2.03c.28.54.51 1.1.7 1.7L22 10v4l-2.53.33a7.9 7.9 0 0 1-.7 1.7l1.55 2.03-2.83 2.83-2.03-1.55c-.54.28-1.1.51-1.7.7L14 22h-4l-.33-2.53a7.9 7.9 0 0 1-1.7-.7l-2.03 1.55-2.83-2.83 1.55-2.03a7.9 7.9 0 0 1-.7-1.7L2 14v-4l2.53-.33c.19-.6.42-1.16.7-1.7L3.68 5.94 6.5 3.1l2.03 1.55c.54-.28 1.1-.51 1.7-.7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.2"})]})})]})]})]}),e.jsxs("section",{className:"group relative mt-6 overflow-hidden rounded-3xl border border-cc-border/80 bg-cc-card p-5 pb-16 sm:p-7 sm:pb-7 transition-all duration-300 hover:border-cc-primary/35 hover:shadow-[0_18px_44px_rgba(0,0,0,0.18)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(80%_140%_at_100%_0%,rgba(6,182,212,0.18),transparent_52%)]"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-30 bg-[linear-gradient(120deg,transparent_0%,rgba(255,255,255,0.04)_35%,transparent_62%)]"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cc-border bg-cc-hover/55 px-3 py-1.5 text-xs tracking-wide text-cc-muted",children:[e.jsx("svg",{className:"h-3.5 w-3.5 text-cc-fg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),e.jsx("span",{children:"Tailscale"}),(s==null?void 0:s.funnelActive)&&e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-cc-success shadow-[0_0_0_3px_rgba(34,197,94,0.15)]","aria-label":"Funnel active",title:"Funnel active"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:e.jsx("h2",{className:"text-[clamp(1.45rem,2.6vw,2rem)] font-semibold leading-[1.12] tracking-tight text-cc-fg",children:"HTTPS access in one click"})}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-cc-muted sm:text-[15px]",children:"Use Tailscale Funnel to expose your Companion over HTTPS with automatic TLS certificates."}),e.jsx("div",{className:"mt-4 inline-flex max-w-full items-center rounded-lg border border-cc-border/80 bg-black/10 px-3 py-1.5 text-xs text-cc-muted/95",children:e.jsx("span",{className:"truncate",children:s===null?"Checking...":s.funnelActive&&s.funnelUrl?s.funnelUrl:s.connected?s.dnsName||"Connected":s.installed?"Not connected":"Not installed"})})]}),e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/integrations/tailscale"},"aria-label":"Open Tailscale settings",title:"Open Tailscale settings",className:"absolute bottom-0 right-0 sm:bottom-0 sm:right-0 inline-flex h-10 w-10 items-center justify-center rounded-full border border-cc-primary/28 bg-cc-primary/12 text-cc-fg transition-colors hover:border-cc-primary/50 hover:bg-cc-primary/20 focus:outline-none focus:ring-2 focus:ring-cc-primary/35 cursor-pointer",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M9.67 4.53 10 2h4l.33 2.53a7.9 7.9 0 0 1 1.7.7l2.03-1.55 2.83 2.83-1.55 2.03c.28.54.51 1.1.7 1.7L22 10v4l-2.53.33a7.9 7.9 0 0 1-.7 1.7l1.55 2.03-2.83 2.83-2.03-1.55c-.54.28-1.1.51-1.7.7L14 22h-4l-.33-2.53a7.9 7.9 0 0 1-1.7-.7l-2.03 1.55-2.83-2.83 1.55-2.03a7.9 7.9 0 0 1-.7-1.7L2 14v-4l2.53-.33c.19-.6.42-1.16.7-1.7L3.68 5.94 6.5 3.1l2.03 1.55c.54-.28 1.1-.51 1.7-.7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.2"})]})})]})]})]})})}export{L as IntegrationsPage};
@@ -1 +1 @@
1
- import{r,a as i,j as e,u as X,n as Y,b as Z,L as M}from"./index-D-JiBkdW.js";function te({embedded:C=!1}){const[o,B]=r.useState([]),[P,U]=r.useState(!0),[S,q]=r.useState(""),[g,A]=r.useState(!1),[l,k]=r.useState(""),[d,I]=r.useState(""),[u,L]=r.useState(""),[m,O]=r.useState(""),[b,D]=r.useState(!1),[E,x]=r.useState(""),[f,$]=r.useState(null),[v,_]=r.useState(null),[F,h]=r.useState(""),[j,R]=r.useState(null),[z,H]=r.useState([]),[w,p]=r.useState(null),a=r.useCallback(async()=>{try{const t=await i.listLinearOAuthConnections();B(t.connections)}catch(t){q(t instanceof Error?t.message:String(t))}finally{U(!1)}},[]),W=r.useCallback(async()=>{try{const t=await i.listAgents();H(t)}catch{}},[]);r.useEffect(()=>{a(),W();let t;const s=window.location.hash;if(s.includes("oauth_success=true"))p({type:"success",message:"OAuth app connected to workspace successfully!"}),window.location.hash="#/integrations/linear-oauth",t=setTimeout(()=>p(null),5e3);else if(s.includes("oauth_error=")){const c=s.match(/oauth_error=([^&]*)/);let n;try{n=decodeURIComponent((c==null?void 0:c[1])||"OAuth failed")}catch{n=(c==null?void 0:c[1])||"OAuth failed"}p({type:"error",message:n}),window.location.hash="#/integrations/linear-oauth"}return()=>{t&&clearTimeout(t)}},[a,W]);async function G(t){t.preventDefault();const s=l.trim(),c=d.trim(),n=u.trim(),T=m.trim();if(!s||!c||!n||!T){x("All fields are required.");return}D(!0),x("");try{await i.createLinearOAuthConnection({name:s,oauthClientId:c,oauthClientSecret:n,webhookSecret:T}),k(""),I(""),L(""),O(""),A(!1),await a()}catch(N){x(N instanceof Error?N.message:String(N))}finally{D(!1)}}async function J(t){if(f!==t){$(t),h("");return}_(t),$(null);try{await i.deleteLinearOAuthConnection(t),h(""),await a()}catch(s){h(s instanceof Error?s.message:String(s)),await a()}finally{_(null)}}async function K(t){R(t);try{const s=await i.getLinearOAuthConnectionAuthorizeUrl(t,"/#/integrations/linear-oauth");window.open(s.url,"_self")}catch(s){p({type:"error",message:s instanceof Error?s.message:String(s)}),R(null)}}function Q(t,s=16){return t.length<=s?t:t.slice(0,s)+"..."}function V(t){return z.filter(s=>{var c,n;return((n=(c=s.triggers)==null?void 0:c.linear)==null?void 0:n.oauthConnectionId)===t})}const y=o.filter(t=>t.status==="connected").length;return e.jsx("div",{className:`${C?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Linear OAuth Apps"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Manage OAuth app connections for Linear agent integrations."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{window.location.hash="#/integrations"},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Integrations"}),!C&&e.jsx("button",{onClick:()=>{const t=X.getState().currentSessionId;t?Y(t):Z()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"})]})]}),e.jsxs("div",{className:"mb-4 px-3 py-2 rounded-lg bg-cc-hover/60 border border-cc-border text-sm text-cc-muted",children:["Looking for ticket integration?"," ",e.jsx("a",{href:"#/settings/linear",className:"text-cc-primary underline cursor-pointer",children:"Linear Tickets Settings"})]}),w&&e.jsx("div",{className:`mb-4 px-3 py-2 rounded-lg text-xs border ${w.type==="success"?"bg-cc-success/10 border-cc-success/20 text-cc-success":"bg-cc-error/10 border-cc-error/20 text-cc-error"}`,children:w.message}),e.jsxs("section",{className:"relative overflow-hidden bg-cc-card border border-cc-border rounded-xl p-4 sm:p-6 mb-4",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none bg-[radial-gradient(circle_at_top_right,rgba(124,58,237,0.1),transparent_45%)]"}),e.jsxs("div",{className:"relative flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-full border border-cc-border bg-cc-hover/60 text-xs text-cc-muted",children:[e.jsx(M,{className:"w-3.5 h-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear OAuth"})]}),e.jsx("h2",{className:"mt-3 text-lg sm:text-xl font-semibold text-cc-fg",children:"OAuth app connections for agent workflows"}),e.jsx("p",{className:"mt-1.5 text-sm text-cc-muted max-w-2xl",children:"Each connection represents a Linear OAuth app. Agents reference these connections to receive @mentions and interact with Linear issues."})]}),e.jsxs("div",{className:"shrink-0 rounded-xl border border-cc-border bg-cc-bg px-3 py-2 text-right min-w-[170px]",children:[e.jsx("p",{className:"text-[11px] text-cc-muted uppercase tracking-wide",children:"Status"}),e.jsx("p",{className:`mt-1 text-sm font-medium ${y>0?"text-cc-success":"text-cc-muted"}`,children:y>0?`${y} connected`:"Not connected"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-cc-muted truncate",children:o.length>0?`${o.length} connection${o.length!==1?"s":""} configured`:"No connections yet"})]})]})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-sm font-semibold text-cc-fg flex items-center gap-2",children:[e.jsx(M,{className:"w-4 h-4 text-cc-fg"}),e.jsx("span",{children:"OAuth Connections"})]}),e.jsx("button",{type:"button",onClick:()=>{A(!g),x(""),h("")},className:"px-3 py-2 rounded-lg text-sm font-medium transition-colors bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer",children:g?"Cancel":"Add Connection"})]}),S&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:S}),F&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:F}),g&&e.jsxs("form",{onSubmit:G,className:"border border-cc-border rounded-lg p-4 space-y-3 bg-cc-bg",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-oauth-name",children:"Connection Name"}),e.jsx("input",{id:"new-oauth-name",type:"text",value:l,onChange:t=>k(t.target.value),placeholder:'e.g. "Production App", "Dev App"',className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-oauth-client-id",children:"OAuth Client ID"}),e.jsx("input",{id:"new-oauth-client-id",type:"text",value:d,onChange:t=>I(t.target.value),placeholder:"OAuth app client ID from Linear",className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-oauth-client-secret",children:"OAuth Client Secret"}),e.jsx("input",{id:"new-oauth-client-secret",type:"password",value:u,onChange:t=>L(t.target.value),placeholder:"OAuth app client secret",className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-oauth-webhook-secret",children:"Webhook Secret"}),e.jsx("input",{id:"new-oauth-webhook-secret",type:"password",value:m,onChange:t=>O(t.target.value),placeholder:"Webhook signing secret from Linear",className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),E&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:E}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"submit",disabled:b||!l.trim()||!d.trim()||!u.trim()||!m.trim(),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${b||!l.trim()||!d.trim()||!u.trim()||!m.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:b?"Saving...":"Save"})})]}),P?e.jsx("p",{className:"text-sm text-cc-muted",children:"Loading connections..."}):o.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"No OAuth connections yet."}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:"Add your first OAuth app connection to enable Linear agent integrations."})]}):e.jsx("div",{className:"space-y-3",children:o.map(t=>{const s=V(t.id);return e.jsx("div",{className:"border border-cc-border rounded-lg overflow-hidden",children:e.jsxs("div",{className:"p-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg",children:t.name}),e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full border ${t.status==="connected"?"bg-cc-success/10 text-cc-success border-cc-success/20":"bg-cc-hover text-cc-muted border-cc-border"}`,children:t.status==="connected"?"Connected":"Disconnected"})]}),e.jsxs("p",{className:"mt-1 text-xs text-cc-muted truncate",children:["Client ID: ",Q(t.oauthClientId)]}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:t.status==="connected"?"Ready to receive @mentions and post updates back to Linear.":"This app may already be installed in Linear, but Companion no longer has a valid OAuth token. Reconnect it to restore agent replies."}),s.length>0&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:s.map(c=>e.jsxs("span",{className:"px-2 py-0.5 text-[10px] rounded-md bg-cc-hover text-cc-muted",children:["Agent: ",c.name]},c.id))})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>K(t.id),disabled:j===t.id,"aria-label":t.status==="connected"?`Manage ${t.name}`:`Reconnect ${t.name}`,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${j===t.id?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-violet-600 hover:bg-violet-700 text-white cursor-pointer"}`,children:j===t.id?"Redirecting...":t.status==="connected"?"Manage in Linear":"Reconnect to Workspace"}),e.jsx("button",{type:"button",onClick:()=>J(t.id),disabled:v===t.id,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${v===t.id?"bg-cc-hover text-cc-muted cursor-not-allowed":f===t.id?"bg-cc-error hover:bg-cc-error/90 text-white cursor-pointer":"bg-cc-error/10 hover:bg-cc-error/20 text-cc-error cursor-pointer"}`,children:v===t.id?"Deleting...":f===t.id?"Confirm Delete":"Delete"})]})]})},t.id)})})]})]})})}export{te as LinearOAuthSettingsPage};
1
+ import{r,a as i,j as e,u as X,n as Y,b as Z,L as M}from"./index-BY3_XaK9.js";function te({embedded:C=!1}){const[o,B]=r.useState([]),[P,U]=r.useState(!0),[S,q]=r.useState(""),[g,A]=r.useState(!1),[l,k]=r.useState(""),[d,I]=r.useState(""),[u,L]=r.useState(""),[m,O]=r.useState(""),[b,D]=r.useState(!1),[E,x]=r.useState(""),[f,$]=r.useState(null),[v,_]=r.useState(null),[F,h]=r.useState(""),[j,R]=r.useState(null),[z,H]=r.useState([]),[w,p]=r.useState(null),a=r.useCallback(async()=>{try{const t=await i.listLinearOAuthConnections();B(t.connections)}catch(t){q(t instanceof Error?t.message:String(t))}finally{U(!1)}},[]),W=r.useCallback(async()=>{try{const t=await i.listAgents();H(t)}catch{}},[]);r.useEffect(()=>{a(),W();let t;const s=window.location.hash;if(s.includes("oauth_success=true"))p({type:"success",message:"OAuth app connected to workspace successfully!"}),window.location.hash="#/integrations/linear-oauth",t=setTimeout(()=>p(null),5e3);else if(s.includes("oauth_error=")){const c=s.match(/oauth_error=([^&]*)/);let n;try{n=decodeURIComponent((c==null?void 0:c[1])||"OAuth failed")}catch{n=(c==null?void 0:c[1])||"OAuth failed"}p({type:"error",message:n}),window.location.hash="#/integrations/linear-oauth"}return()=>{t&&clearTimeout(t)}},[a,W]);async function G(t){t.preventDefault();const s=l.trim(),c=d.trim(),n=u.trim(),T=m.trim();if(!s||!c||!n||!T){x("All fields are required.");return}D(!0),x("");try{await i.createLinearOAuthConnection({name:s,oauthClientId:c,oauthClientSecret:n,webhookSecret:T}),k(""),I(""),L(""),O(""),A(!1),await a()}catch(N){x(N instanceof Error?N.message:String(N))}finally{D(!1)}}async function J(t){if(f!==t){$(t),h("");return}_(t),$(null);try{await i.deleteLinearOAuthConnection(t),h(""),await a()}catch(s){h(s instanceof Error?s.message:String(s)),await a()}finally{_(null)}}async function K(t){R(t);try{const s=await i.getLinearOAuthConnectionAuthorizeUrl(t,"/#/integrations/linear-oauth");window.open(s.url,"_self")}catch(s){p({type:"error",message:s instanceof Error?s.message:String(s)}),R(null)}}function Q(t,s=16){return t.length<=s?t:t.slice(0,s)+"..."}function V(t){return z.filter(s=>{var c,n;return((n=(c=s.triggers)==null?void 0:c.linear)==null?void 0:n.oauthConnectionId)===t})}const y=o.filter(t=>t.status==="connected").length;return e.jsx("div",{className:`${C?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Linear OAuth Apps"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Manage OAuth app connections for Linear agent integrations."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{window.location.hash="#/integrations"},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Integrations"}),!C&&e.jsx("button",{onClick:()=>{const t=X.getState().currentSessionId;t?Y(t):Z()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"})]})]}),e.jsxs("div",{className:"mb-4 px-3 py-2 rounded-lg bg-cc-hover/60 border border-cc-border text-sm text-cc-muted",children:["Looking for ticket integration?"," ",e.jsx("a",{href:"#/settings/linear",className:"text-cc-primary underline cursor-pointer",children:"Linear Tickets Settings"})]}),w&&e.jsx("div",{className:`mb-4 px-3 py-2 rounded-lg text-xs border ${w.type==="success"?"bg-cc-success/10 border-cc-success/20 text-cc-success":"bg-cc-error/10 border-cc-error/20 text-cc-error"}`,children:w.message}),e.jsxs("section",{className:"relative overflow-hidden bg-cc-card border border-cc-border rounded-xl p-4 sm:p-6 mb-4",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none bg-[radial-gradient(circle_at_top_right,rgba(124,58,237,0.1),transparent_45%)]"}),e.jsxs("div",{className:"relative flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-full border border-cc-border bg-cc-hover/60 text-xs text-cc-muted",children:[e.jsx(M,{className:"w-3.5 h-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear OAuth"})]}),e.jsx("h2",{className:"mt-3 text-lg sm:text-xl font-semibold text-cc-fg",children:"OAuth app connections for agent workflows"}),e.jsx("p",{className:"mt-1.5 text-sm text-cc-muted max-w-2xl",children:"Each connection represents a Linear OAuth app. Agents reference these connections to receive @mentions and interact with Linear issues."})]}),e.jsxs("div",{className:"shrink-0 rounded-xl border border-cc-border bg-cc-bg px-3 py-2 text-right min-w-[170px]",children:[e.jsx("p",{className:"text-[11px] text-cc-muted uppercase tracking-wide",children:"Status"}),e.jsx("p",{className:`mt-1 text-sm font-medium ${y>0?"text-cc-success":"text-cc-muted"}`,children:y>0?`${y} connected`:"Not connected"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-cc-muted truncate",children:o.length>0?`${o.length} connection${o.length!==1?"s":""} configured`:"No connections yet"})]})]})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-sm font-semibold text-cc-fg flex items-center gap-2",children:[e.jsx(M,{className:"w-4 h-4 text-cc-fg"}),e.jsx("span",{children:"OAuth Connections"})]}),e.jsx("button",{type:"button",onClick:()=>{A(!g),x(""),h("")},className:"px-3 py-2 rounded-lg text-sm font-medium transition-colors bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer",children:g?"Cancel":"Add Connection"})]}),S&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:S}),F&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:F}),g&&e.jsxs("form",{onSubmit:G,className:"border border-cc-border rounded-lg p-4 space-y-3 bg-cc-bg",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-oauth-name",children:"Connection Name"}),e.jsx("input",{id:"new-oauth-name",type:"text",value:l,onChange:t=>k(t.target.value),placeholder:'e.g. "Production App", "Dev App"',className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-oauth-client-id",children:"OAuth Client ID"}),e.jsx("input",{id:"new-oauth-client-id",type:"text",value:d,onChange:t=>I(t.target.value),placeholder:"OAuth app client ID from Linear",className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-oauth-client-secret",children:"OAuth Client Secret"}),e.jsx("input",{id:"new-oauth-client-secret",type:"password",value:u,onChange:t=>L(t.target.value),placeholder:"OAuth app client secret",className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-oauth-webhook-secret",children:"Webhook Secret"}),e.jsx("input",{id:"new-oauth-webhook-secret",type:"password",value:m,onChange:t=>O(t.target.value),placeholder:"Webhook signing secret from Linear",className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),E&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:E}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"submit",disabled:b||!l.trim()||!d.trim()||!u.trim()||!m.trim(),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${b||!l.trim()||!d.trim()||!u.trim()||!m.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:b?"Saving...":"Save"})})]}),P?e.jsx("p",{className:"text-sm text-cc-muted",children:"Loading connections..."}):o.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"No OAuth connections yet."}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:"Add your first OAuth app connection to enable Linear agent integrations."})]}):e.jsx("div",{className:"space-y-3",children:o.map(t=>{const s=V(t.id);return e.jsx("div",{className:"border border-cc-border rounded-lg overflow-hidden",children:e.jsxs("div",{className:"p-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg",children:t.name}),e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full border ${t.status==="connected"?"bg-cc-success/10 text-cc-success border-cc-success/20":"bg-cc-hover text-cc-muted border-cc-border"}`,children:t.status==="connected"?"Connected":"Disconnected"})]}),e.jsxs("p",{className:"mt-1 text-xs text-cc-muted truncate",children:["Client ID: ",Q(t.oauthClientId)]}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:t.status==="connected"?"Ready to receive @mentions and post updates back to Linear.":"This app may already be installed in Linear, but Companion no longer has a valid OAuth token. Reconnect it to restore agent replies."}),s.length>0&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:s.map(c=>e.jsxs("span",{className:"px-2 py-0.5 text-[10px] rounded-md bg-cc-hover text-cc-muted",children:["Agent: ",c.name]},c.id))})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>K(t.id),disabled:j===t.id,"aria-label":t.status==="connected"?`Manage ${t.name}`:`Reconnect ${t.name}`,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${j===t.id?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-violet-600 hover:bg-violet-700 text-white cursor-pointer"}`,children:j===t.id?"Redirecting...":t.status==="connected"?"Manage in Linear":"Reconnect to Workspace"}),e.jsx("button",{type:"button",onClick:()=>J(t.id),disabled:v===t.id,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${v===t.id?"bg-cc-hover text-cc-muted cursor-not-allowed":f===t.id?"bg-cc-error hover:bg-cc-error/90 text-white cursor-pointer":"bg-cc-error/10 hover:bg-cc-error/20 text-cc-error cursor-pointer"}`,children:v===t.id?"Deleting...":f===t.id?"Confirm Delete":"Delete"})]})]})},t.id)})})]})]})})}export{te as LinearOAuthSettingsPage};
@@ -1 +1 @@
1
- import{r as o,a as x,j as e,u as M,n as Q,b as X,L as _}from"./index-D-JiBkdW.js";function Z({embedded:I=!1}){const[m,O]=o.useState([]),[H,V]=o.useState(!0),[C,q]=o.useState(""),[v,L]=o.useState(!1),[g,$]=o.useState(""),[p,A]=o.useState(""),[N,E]=o.useState(!1),[W,u]=o.useState(""),[s,c]=o.useState(null),[j,D]=o.useState(null),[y,F]=o.useState(null),l=o.useCallback(async()=>{try{const t=await x.listLinearConnections();O(t.connections)}catch(t){q(t instanceof Error?t.message:String(t))}finally{V(!1)}},[]);o.useEffect(()=>{l()},[l]);async function B(t){t.preventDefault();const a=g.trim(),i=p.trim();if(!a||!i){u("Name and API key are required.");return}E(!0),u("");try{const r=await x.createLinearConnection({name:a,apiKey:i});r.error?u(r.error):($(""),A(""),L(!1),await l())}catch(r){u(r instanceof Error?r.message:String(r))}finally{E(!1)}}async function R(t){D(t);try{await x.verifyLinearConnection(t),await l()}catch{await l()}finally{D(null)}}async function U(t){F(t);try{await x.deleteLinearConnection(t),(s==null?void 0:s.connectionId)===t&&c(null),await l()}catch{await l()}finally{F(null)}}async function z(t){if((s==null?void 0:s.connectionId)===t.id){c(null);return}const a={connectionId:t.id,teams:[],loadingStates:!0,autoTransition:t.autoTransition,autoTransitionTeamId:"",autoTransitionStateId:t.autoTransitionStateId,autoTransitionStateName:t.autoTransitionStateName,autoTransitionWorkflowStates:[],archiveTransition:t.archiveTransition,archiveTransitionTeamId:"",archiveTransitionStateId:t.archiveTransitionStateId,archiveTransitionStateName:t.archiveTransitionStateName,archiveTransitionWorkflowStates:[],saving:!1,saved:!1,error:""};c(a);try{const r=(await x.getLinearStates(t.id)).teams,n=r[0];let b="",w=[],K=t.autoTransitionStateId;if(t.autoTransitionStateName&&r.length>0)for(const d of r){const h=d.states.find(k=>k.name===t.autoTransitionStateName);if(h){b=d.id,w=d.states,K=h.id;break}}!b&&n&&(b=n.id,w=n.states);let f="",S=[],P=t.archiveTransitionStateId;if(t.archiveTransitionStateName&&r.length>0)for(const d of r){const h=d.states.find(k=>k.name===t.archiveTransitionStateName);if(h){f=d.id,S=d.states,P=h.id;break}}!f&&n&&(f=n.id,S=n.states),c(d=>d&&d.connectionId===t.id?{...d,teams:r,loadingStates:!1,autoTransitionTeamId:b,autoTransitionStateId:K,autoTransitionWorkflowStates:w,archiveTransitionTeamId:f,archiveTransitionStateId:P,archiveTransitionWorkflowStates:S}:d)}catch{c(i=>i&&i.connectionId===t.id?{...i,loadingStates:!1}:i)}}async function G(){if(s){c(t=>t&&{...t,saving:!0,saved:!1,error:""});try{await x.updateLinearConnection(s.connectionId,{autoTransition:s.autoTransition,autoTransitionStateId:s.autoTransitionStateId,autoTransitionStateName:s.autoTransitionStateName,archiveTransition:s.archiveTransition,archiveTransitionStateId:s.archiveTransitionStateId,archiveTransitionStateName:s.archiveTransitionStateName}),c(t=>t&&{...t,saving:!1,saved:!0}),setTimeout(()=>c(t=>t&&{...t,saved:!1}),1800),await l()}catch(t){c(a=>a&&{...a,saving:!1,error:t instanceof Error?t.message:String(t)})}}}const T=m.filter(t=>t.connected).length,J=m.length>0;return e.jsx("div",{className:`${I?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Linear Settings"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Connect Linear for issue context injection and agent @mentions via the Agent SDK."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{window.location.hash="#/integrations"},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Integrations"}),!I&&e.jsx("button",{onClick:()=>{const t=M.getState().currentSessionId;t?Q(t):X()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"})]})]}),e.jsxs("section",{className:"relative overflow-hidden bg-cc-card border border-cc-border rounded-xl p-4 sm:p-6 mb-4",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none bg-[radial-gradient(circle_at_top_right,rgba(124,58,237,0.1),transparent_45%)]"}),e.jsxs("div",{className:"relative flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-full border border-cc-border bg-cc-hover/60 text-xs text-cc-muted",children:[e.jsx(_,{className:"w-3.5 h-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear Integration"})]}),e.jsx("h2",{className:"mt-3 text-lg sm:text-xl font-semibold text-cc-fg",children:"Turn issues into concrete session context"}),e.jsx("p",{className:"mt-1.5 text-sm text-cc-muted max-w-2xl",children:"Search and attach the right Linear issue before the first prompt, so the companion starts with scope, state, and links."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-[11px]",children:[e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"Issue lookup on Home"}),e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"Context injection on start"}),e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"No key exposure in API responses"})]})]}),e.jsxs("div",{className:"shrink-0 rounded-xl border border-cc-border bg-cc-bg px-3 py-2 text-right min-w-[170px]",children:[e.jsx("p",{className:"text-[11px] text-cc-muted uppercase tracking-wide",children:"Status"}),e.jsx("p",{className:`mt-1 text-sm font-medium ${T>0?"text-cc-success":"text-cc-muted"}`,children:T>0?`${T} connected`:"Not connected"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-cc-muted truncate",children:J?`${m.length} connection${m.length!==1?"s":""} configured`:"No connections yet"})]})]})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-sm font-semibold text-cc-fg flex items-center gap-2",children:[e.jsx(_,{className:"w-4 h-4 text-cc-fg"}),e.jsx("span",{children:"Linear Connections"})]}),e.jsx("button",{type:"button",onClick:()=>{L(!v),u("")},className:"px-3 py-2 rounded-lg text-sm font-medium transition-colors bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer",children:v?"Cancel":"Add Connection"})]}),C&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:C}),v&&e.jsxs("form",{onSubmit:B,className:"border border-cc-border rounded-lg p-4 space-y-3 bg-cc-bg",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-conn-name",children:"Connection Name"}),e.jsx("input",{id:"new-conn-name",type:"text",value:g,onChange:t=>$(t.target.value),placeholder:'e.g. "Work", "Personal"',className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-conn-key",children:"API Key"}),e.jsx("input",{id:"new-conn-key",type:"password",value:p,onChange:t=>A(t.target.value),placeholder:"lin_api_...",className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:"The key is verified automatically when saved."})]}),W&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:W}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"submit",disabled:N||!g.trim()||!p.trim(),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${N||!g.trim()||!p.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:N?"Saving...":"Save"})})]}),H?e.jsx("p",{className:"text-sm text-cc-muted",children:"Loading connections..."}):m.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"No Linear connections yet."}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:"Add your first connection to search and attach Linear issues to sessions."})]}):e.jsx("div",{className:"space-y-3",children:m.map(t=>e.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"p-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg",children:t.name}),e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full border ${t.connected?"bg-cc-success/10 text-cc-success border-cc-success/20":"bg-cc-error/10 text-cc-error border-cc-error/20"}`,children:t.connected?"Connected":"Not connected"})]}),e.jsxs("p",{className:"mt-1 text-xs text-cc-muted truncate",children:[t.workspaceName&&t.viewerName?`${t.viewerName} -- ${t.workspaceName}`:t.workspaceName||t.viewerName||"Unverified"," ","· Key ending in ...",t.apiKeyLast4]}),(t.autoTransition||t.archiveTransition)&&e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[t.autoTransition&&t.autoTransitionStateName&&e.jsxs("span",{className:"px-2 py-0.5 text-[10px] rounded-md bg-cc-hover text-cc-muted",children:["Auto-transition: ",t.autoTransitionStateName]}),t.archiveTransition&&t.archiveTransitionStateName&&e.jsxs("span",{className:"px-2 py-0.5 text-[10px] rounded-md bg-cc-hover text-cc-muted",children:["On archive: ",t.archiveTransitionStateName]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>z(t),disabled:!t.connected,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${t.connected?(s==null?void 0:s.connectionId)===t.id?"bg-cc-active text-cc-fg cursor-pointer":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:(s==null?void 0:s.connectionId)===t.id?"Close":"Edit"}),e.jsx("button",{type:"button",onClick:()=>R(t.id),disabled:j===t.id,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${j===t.id?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:j===t.id?"Checking...":"Verify"}),e.jsx("button",{type:"button",onClick:()=>U(t.id),disabled:y===t.id,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${y===t.id?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-error/10 hover:bg-cc-error/20 text-cc-error cursor-pointer"}`,children:y===t.id?"Deleting...":"Delete"})]})]}),(s==null?void 0:s.connectionId)===t.id&&e.jsxs("div",{className:"border-t border-cc-border p-4 space-y-5 bg-cc-bg/50",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg",children:"Auto-transition"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Automatically move the linked issue to a chosen status when starting a session."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s.autoTransition,onClick:()=>c(a=>a&&{...a,autoTransition:!a.autoTransition}),className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${s.autoTransition?"bg-cc-primary":"bg-cc-hover"}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${s.autoTransition?"translate-x-4":"translate-x-0"}`})}),e.jsx("span",{className:"text-sm text-cc-fg",children:s.autoTransition?"Enabled":"Disabled"})]}),s.autoTransition&&s.teams.length>1&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:`auto-team-${t.id}`,children:"Team"}),e.jsx("select",{id:`auto-team-${t.id}`,value:s.autoTransitionTeamId,onChange:a=>{const i=a.target.value,r=s.teams.find(n=>n.id===i);c(n=>n&&{...n,autoTransitionTeamId:i,autoTransitionWorkflowStates:(r==null?void 0:r.states)||[],autoTransitionStateId:"",autoTransitionStateName:""})},className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60",children:s.teams.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.key,")"]},a.id))})]}),s.autoTransition&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:`auto-state-${t.id}`,children:"Target status"}),s.loadingStates?e.jsx("p",{className:"text-xs text-cc-muted",children:"Loading workflow states..."}):s.autoTransitionWorkflowStates.length===0?e.jsx("p",{className:"text-xs text-cc-muted",children:"No workflow states found."}):e.jsxs("select",{id:`auto-state-${t.id}`,value:s.autoTransitionStateId,onChange:a=>{const i=s.autoTransitionWorkflowStates.find(r=>r.id===a.target.value);c(r=>r&&{...r,autoTransitionStateId:a.target.value,autoTransitionStateName:(i==null?void 0:i.name)||""})},className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60",children:[e.jsx("option",{value:"",children:"Select a status..."}),s.autoTransitionWorkflowStates.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]})]}),e.jsx("div",{className:"border-t border-cc-border"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg",children:"On session archive"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"When archiving a session linked to a Linear issue that is not done, optionally move it to a chosen status."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s.archiveTransition,onClick:()=>c(a=>a&&{...a,archiveTransition:!a.archiveTransition}),className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${s.archiveTransition?"bg-cc-primary":"bg-cc-hover"}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${s.archiveTransition?"translate-x-4":"translate-x-0"}`})}),e.jsx("span",{className:"text-sm text-cc-fg",children:s.archiveTransition?"Enabled":"Disabled"})]}),s.archiveTransition&&s.teams.length>1&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:`archive-team-${t.id}`,children:"Team"}),e.jsx("select",{id:`archive-team-${t.id}`,value:s.archiveTransitionTeamId,onChange:a=>{const i=a.target.value,r=s.teams.find(n=>n.id===i);c(n=>n&&{...n,archiveTransitionTeamId:i,archiveTransitionWorkflowStates:(r==null?void 0:r.states)||[],archiveTransitionStateId:"",archiveTransitionStateName:""})},className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60",children:s.teams.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.key,")"]},a.id))})]}),s.archiveTransition&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:`archive-state-${t.id}`,children:"Target status"}),s.loadingStates?e.jsx("p",{className:"text-xs text-cc-muted",children:"Loading workflow states..."}):s.archiveTransitionWorkflowStates.length===0?e.jsx("p",{className:"text-xs text-cc-muted",children:"No workflow states found."}):e.jsxs("select",{id:`archive-state-${t.id}`,value:s.archiveTransitionStateId,onChange:a=>{const i=s.archiveTransitionWorkflowStates.find(r=>r.id===a.target.value);c(r=>r&&{...r,archiveTransitionStateId:a.target.value,archiveTransitionStateName:(i==null?void 0:i.name)||""})},className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60",children:[e.jsx("option",{value:"",children:"Select a status..."}),s.archiveTransitionWorkflowStates.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]})]}),s.error&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:s.error}),s.saved&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:"Connection settings saved."}),(()=>{const a=s.saving||s.autoTransition&&!s.autoTransitionStateId||s.archiveTransition&&!s.archiveTransitionStateId;return e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:G,disabled:a,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${a?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:s.saving?"Saving...":"Save Settings"})})})()]})]},t.id))})]}),e.jsxs("div",{className:"mt-4 px-3 py-3 rounded-xl bg-cc-card border border-cc-border text-sm text-cc-muted",children:["Looking for OAuth app settings for agent triggers?"," ",e.jsx("a",{href:"#/integrations/linear-oauth",className:"text-cc-primary underline cursor-pointer",children:"Linear OAuth Apps"})]}),e.jsxs("section",{className:"mt-4 grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-cc-muted",children:"1. Configure"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"Add a Linear API key and verify the connection."})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-cc-muted",children:"2. Select"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"From Home, search an issue by key or title in one click."})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-cc-muted",children:"3. Start"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"The issue details are injected as startup context."})]})]})]})})}export{Z as LinearSettingsPage};
1
+ import{r as o,a as x,j as e,u as M,n as Q,b as X,L as _}from"./index-BY3_XaK9.js";function Z({embedded:I=!1}){const[m,O]=o.useState([]),[H,V]=o.useState(!0),[C,q]=o.useState(""),[v,L]=o.useState(!1),[g,$]=o.useState(""),[p,A]=o.useState(""),[N,E]=o.useState(!1),[W,u]=o.useState(""),[s,c]=o.useState(null),[j,D]=o.useState(null),[y,F]=o.useState(null),l=o.useCallback(async()=>{try{const t=await x.listLinearConnections();O(t.connections)}catch(t){q(t instanceof Error?t.message:String(t))}finally{V(!1)}},[]);o.useEffect(()=>{l()},[l]);async function B(t){t.preventDefault();const a=g.trim(),i=p.trim();if(!a||!i){u("Name and API key are required.");return}E(!0),u("");try{const r=await x.createLinearConnection({name:a,apiKey:i});r.error?u(r.error):($(""),A(""),L(!1),await l())}catch(r){u(r instanceof Error?r.message:String(r))}finally{E(!1)}}async function R(t){D(t);try{await x.verifyLinearConnection(t),await l()}catch{await l()}finally{D(null)}}async function U(t){F(t);try{await x.deleteLinearConnection(t),(s==null?void 0:s.connectionId)===t&&c(null),await l()}catch{await l()}finally{F(null)}}async function z(t){if((s==null?void 0:s.connectionId)===t.id){c(null);return}const a={connectionId:t.id,teams:[],loadingStates:!0,autoTransition:t.autoTransition,autoTransitionTeamId:"",autoTransitionStateId:t.autoTransitionStateId,autoTransitionStateName:t.autoTransitionStateName,autoTransitionWorkflowStates:[],archiveTransition:t.archiveTransition,archiveTransitionTeamId:"",archiveTransitionStateId:t.archiveTransitionStateId,archiveTransitionStateName:t.archiveTransitionStateName,archiveTransitionWorkflowStates:[],saving:!1,saved:!1,error:""};c(a);try{const r=(await x.getLinearStates(t.id)).teams,n=r[0];let b="",w=[],K=t.autoTransitionStateId;if(t.autoTransitionStateName&&r.length>0)for(const d of r){const h=d.states.find(k=>k.name===t.autoTransitionStateName);if(h){b=d.id,w=d.states,K=h.id;break}}!b&&n&&(b=n.id,w=n.states);let f="",S=[],P=t.archiveTransitionStateId;if(t.archiveTransitionStateName&&r.length>0)for(const d of r){const h=d.states.find(k=>k.name===t.archiveTransitionStateName);if(h){f=d.id,S=d.states,P=h.id;break}}!f&&n&&(f=n.id,S=n.states),c(d=>d&&d.connectionId===t.id?{...d,teams:r,loadingStates:!1,autoTransitionTeamId:b,autoTransitionStateId:K,autoTransitionWorkflowStates:w,archiveTransitionTeamId:f,archiveTransitionStateId:P,archiveTransitionWorkflowStates:S}:d)}catch{c(i=>i&&i.connectionId===t.id?{...i,loadingStates:!1}:i)}}async function G(){if(s){c(t=>t&&{...t,saving:!0,saved:!1,error:""});try{await x.updateLinearConnection(s.connectionId,{autoTransition:s.autoTransition,autoTransitionStateId:s.autoTransitionStateId,autoTransitionStateName:s.autoTransitionStateName,archiveTransition:s.archiveTransition,archiveTransitionStateId:s.archiveTransitionStateId,archiveTransitionStateName:s.archiveTransitionStateName}),c(t=>t&&{...t,saving:!1,saved:!0}),setTimeout(()=>c(t=>t&&{...t,saved:!1}),1800),await l()}catch(t){c(a=>a&&{...a,saving:!1,error:t instanceof Error?t.message:String(t)})}}}const T=m.filter(t=>t.connected).length,J=m.length>0;return e.jsx("div",{className:`${I?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Linear Settings"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Connect Linear for issue context injection and agent @mentions via the Agent SDK."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{window.location.hash="#/integrations"},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Integrations"}),!I&&e.jsx("button",{onClick:()=>{const t=M.getState().currentSessionId;t?Q(t):X()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"})]})]}),e.jsxs("section",{className:"relative overflow-hidden bg-cc-card border border-cc-border rounded-xl p-4 sm:p-6 mb-4",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none bg-[radial-gradient(circle_at_top_right,rgba(124,58,237,0.1),transparent_45%)]"}),e.jsxs("div",{className:"relative flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-full border border-cc-border bg-cc-hover/60 text-xs text-cc-muted",children:[e.jsx(_,{className:"w-3.5 h-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear Integration"})]}),e.jsx("h2",{className:"mt-3 text-lg sm:text-xl font-semibold text-cc-fg",children:"Turn issues into concrete session context"}),e.jsx("p",{className:"mt-1.5 text-sm text-cc-muted max-w-2xl",children:"Search and attach the right Linear issue before the first prompt, so the companion starts with scope, state, and links."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-[11px]",children:[e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"Issue lookup on Home"}),e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"Context injection on start"}),e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"No key exposure in API responses"})]})]}),e.jsxs("div",{className:"shrink-0 rounded-xl border border-cc-border bg-cc-bg px-3 py-2 text-right min-w-[170px]",children:[e.jsx("p",{className:"text-[11px] text-cc-muted uppercase tracking-wide",children:"Status"}),e.jsx("p",{className:`mt-1 text-sm font-medium ${T>0?"text-cc-success":"text-cc-muted"}`,children:T>0?`${T} connected`:"Not connected"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-cc-muted truncate",children:J?`${m.length} connection${m.length!==1?"s":""} configured`:"No connections yet"})]})]})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-sm font-semibold text-cc-fg flex items-center gap-2",children:[e.jsx(_,{className:"w-4 h-4 text-cc-fg"}),e.jsx("span",{children:"Linear Connections"})]}),e.jsx("button",{type:"button",onClick:()=>{L(!v),u("")},className:"px-3 py-2 rounded-lg text-sm font-medium transition-colors bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer",children:v?"Cancel":"Add Connection"})]}),C&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:C}),v&&e.jsxs("form",{onSubmit:B,className:"border border-cc-border rounded-lg p-4 space-y-3 bg-cc-bg",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-conn-name",children:"Connection Name"}),e.jsx("input",{id:"new-conn-name",type:"text",value:g,onChange:t=>$(t.target.value),placeholder:'e.g. "Work", "Personal"',className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"new-conn-key",children:"API Key"}),e.jsx("input",{id:"new-conn-key",type:"password",value:p,onChange:t=>A(t.target.value),placeholder:"lin_api_...",className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/60"}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:"The key is verified automatically when saved."})]}),W&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:W}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"submit",disabled:N||!g.trim()||!p.trim(),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${N||!g.trim()||!p.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:N?"Saving...":"Save"})})]}),H?e.jsx("p",{className:"text-sm text-cc-muted",children:"Loading connections..."}):m.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"No Linear connections yet."}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:"Add your first connection to search and attach Linear issues to sessions."})]}):e.jsx("div",{className:"space-y-3",children:m.map(t=>e.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"p-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg",children:t.name}),e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full border ${t.connected?"bg-cc-success/10 text-cc-success border-cc-success/20":"bg-cc-error/10 text-cc-error border-cc-error/20"}`,children:t.connected?"Connected":"Not connected"})]}),e.jsxs("p",{className:"mt-1 text-xs text-cc-muted truncate",children:[t.workspaceName&&t.viewerName?`${t.viewerName} -- ${t.workspaceName}`:t.workspaceName||t.viewerName||"Unverified"," ","· Key ending in ...",t.apiKeyLast4]}),(t.autoTransition||t.archiveTransition)&&e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[t.autoTransition&&t.autoTransitionStateName&&e.jsxs("span",{className:"px-2 py-0.5 text-[10px] rounded-md bg-cc-hover text-cc-muted",children:["Auto-transition: ",t.autoTransitionStateName]}),t.archiveTransition&&t.archiveTransitionStateName&&e.jsxs("span",{className:"px-2 py-0.5 text-[10px] rounded-md bg-cc-hover text-cc-muted",children:["On archive: ",t.archiveTransitionStateName]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>z(t),disabled:!t.connected,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${t.connected?(s==null?void 0:s.connectionId)===t.id?"bg-cc-active text-cc-fg cursor-pointer":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:(s==null?void 0:s.connectionId)===t.id?"Close":"Edit"}),e.jsx("button",{type:"button",onClick:()=>R(t.id),disabled:j===t.id,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${j===t.id?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:j===t.id?"Checking...":"Verify"}),e.jsx("button",{type:"button",onClick:()=>U(t.id),disabled:y===t.id,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${y===t.id?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-error/10 hover:bg-cc-error/20 text-cc-error cursor-pointer"}`,children:y===t.id?"Deleting...":"Delete"})]})]}),(s==null?void 0:s.connectionId)===t.id&&e.jsxs("div",{className:"border-t border-cc-border p-4 space-y-5 bg-cc-bg/50",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg",children:"Auto-transition"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Automatically move the linked issue to a chosen status when starting a session."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s.autoTransition,onClick:()=>c(a=>a&&{...a,autoTransition:!a.autoTransition}),className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${s.autoTransition?"bg-cc-primary":"bg-cc-hover"}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${s.autoTransition?"translate-x-4":"translate-x-0"}`})}),e.jsx("span",{className:"text-sm text-cc-fg",children:s.autoTransition?"Enabled":"Disabled"})]}),s.autoTransition&&s.teams.length>1&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:`auto-team-${t.id}`,children:"Team"}),e.jsx("select",{id:`auto-team-${t.id}`,value:s.autoTransitionTeamId,onChange:a=>{const i=a.target.value,r=s.teams.find(n=>n.id===i);c(n=>n&&{...n,autoTransitionTeamId:i,autoTransitionWorkflowStates:(r==null?void 0:r.states)||[],autoTransitionStateId:"",autoTransitionStateName:""})},className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60",children:s.teams.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.key,")"]},a.id))})]}),s.autoTransition&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:`auto-state-${t.id}`,children:"Target status"}),s.loadingStates?e.jsx("p",{className:"text-xs text-cc-muted",children:"Loading workflow states..."}):s.autoTransitionWorkflowStates.length===0?e.jsx("p",{className:"text-xs text-cc-muted",children:"No workflow states found."}):e.jsxs("select",{id:`auto-state-${t.id}`,value:s.autoTransitionStateId,onChange:a=>{const i=s.autoTransitionWorkflowStates.find(r=>r.id===a.target.value);c(r=>r&&{...r,autoTransitionStateId:a.target.value,autoTransitionStateName:(i==null?void 0:i.name)||""})},className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60",children:[e.jsx("option",{value:"",children:"Select a status..."}),s.autoTransitionWorkflowStates.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]})]}),e.jsx("div",{className:"border-t border-cc-border"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg",children:"On session archive"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"When archiving a session linked to a Linear issue that is not done, optionally move it to a chosen status."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s.archiveTransition,onClick:()=>c(a=>a&&{...a,archiveTransition:!a.archiveTransition}),className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${s.archiveTransition?"bg-cc-primary":"bg-cc-hover"}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${s.archiveTransition?"translate-x-4":"translate-x-0"}`})}),e.jsx("span",{className:"text-sm text-cc-fg",children:s.archiveTransition?"Enabled":"Disabled"})]}),s.archiveTransition&&s.teams.length>1&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:`archive-team-${t.id}`,children:"Team"}),e.jsx("select",{id:`archive-team-${t.id}`,value:s.archiveTransitionTeamId,onChange:a=>{const i=a.target.value,r=s.teams.find(n=>n.id===i);c(n=>n&&{...n,archiveTransitionTeamId:i,archiveTransitionWorkflowStates:(r==null?void 0:r.states)||[],archiveTransitionStateId:"",archiveTransitionStateName:""})},className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60",children:s.teams.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.key,")"]},a.id))})]}),s.archiveTransition&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:`archive-state-${t.id}`,children:"Target status"}),s.loadingStates?e.jsx("p",{className:"text-xs text-cc-muted",children:"Loading workflow states..."}):s.archiveTransitionWorkflowStates.length===0?e.jsx("p",{className:"text-xs text-cc-muted",children:"No workflow states found."}):e.jsxs("select",{id:`archive-state-${t.id}`,value:s.archiveTransitionStateId,onChange:a=>{const i=s.archiveTransitionWorkflowStates.find(r=>r.id===a.target.value);c(r=>r&&{...r,archiveTransitionStateId:a.target.value,archiveTransitionStateName:(i==null?void 0:i.name)||""})},className:"w-full px-3 py-2.5 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60",children:[e.jsx("option",{value:"",children:"Select a status..."}),s.archiveTransitionWorkflowStates.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]})]}),s.error&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:s.error}),s.saved&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:"Connection settings saved."}),(()=>{const a=s.saving||s.autoTransition&&!s.autoTransitionStateId||s.archiveTransition&&!s.archiveTransitionStateId;return e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:G,disabled:a,className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${a?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:s.saving?"Saving...":"Save Settings"})})})()]})]},t.id))})]}),e.jsxs("div",{className:"mt-4 px-3 py-3 rounded-xl bg-cc-card border border-cc-border text-sm text-cc-muted",children:["Looking for OAuth app settings for agent triggers?"," ",e.jsx("a",{href:"#/integrations/linear-oauth",className:"text-cc-primary underline cursor-pointer",children:"Linear OAuth Apps"})]}),e.jsxs("section",{className:"mt-4 grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-cc-muted",children:"1. Configure"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"Add a Linear API key and verify the connection."})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-cc-muted",children:"2. Select"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"From Home, search an issue by key or title in one click."})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-cc-muted",children:"3. Start"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"The issue details are injected as startup context."})]})]})]})})}export{Z as LinearSettingsPage};
@@ -1,4 +1,4 @@
1
- import{r as u,j as e,u as j,n as xe,b as me,P as f,C as pe,A as J,M as v,T as w,G as M,L as Y,D as P,S as L,c as B,d as U,e as Q,f as X,h as ue,i as he,k as ge,U as be,l as fe,m as se,o as te,a as je,p as ve,q as _,v as we}from"./index-D-JiBkdW.js";const Ne=new Set(["pulling_image","running_init_script","building_image"]);function A({steps:t,error:c}){const[n,i]=u.useState({}),[r,m]=u.useState(new Set),l=u.useRef(new Map),h=u.useCallback(o=>x=>{x?l.current.set(o,x):l.current.delete(o)},[]);return u.useEffect(()=>{for(const o of t)o.detail&&Ne.has(o.step)&&(i(x=>{const a=x[o.step]||[];return a.length===0||a[a.length-1]!==o.detail?{...x,[o.step]:[...a,o.detail]}:x}),m(x=>{if(x.has(o.step))return x;const a=new Set(x);return a.add(o.step),a}))},[t]),u.useEffect(()=>{var o;for(const x of l.current.values())(o=x.scrollTo)==null||o.call(x,{top:x.scrollHeight})},[n]),t.length===0?null:e.jsxs("div",{className:"w-full max-w-md mx-auto mt-4 mb-2",children:[e.jsx("div",{className:"space-y-1.5",children:t.map(o=>{const x=n[o.step],a=x&&x.length>0,y=r.has(o.step);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 py-1",children:[e.jsxs("div",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:[o.status==="in_progress"&&e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-cc-primary/30 border-t-cc-primary rounded-full animate-spin"}),o.status==="done"&&e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-success",children:e.jsx("path",{d:"M13.25 4.75L6 12 2.75 8.75",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),o.status==="error"&&e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-error",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]}),e.jsx("span",{className:`text-sm flex-1 ${o.status==="in_progress"?"text-cc-fg font-medium":o.status==="done"?"text-cc-muted":"text-cc-error"}`,children:o.label}),a&&e.jsx("button",{onClick:()=>m(N=>{const p=new Set(N);return p.has(o.step)?p.delete(o.step):p.add(o.step),p}),className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:y?"Hide logs":"Show logs"})]}),a&&y&&e.jsx("pre",{ref:h(o.step),className:"ml-[26px] mt-1 mb-1 px-3 py-2 text-[10px] font-mono-code bg-black/20 border border-cc-border rounded-md text-cc-muted max-h-[150px] overflow-auto whitespace-pre-wrap",children:x.slice(-30).join(`
1
+ import{r as u,j as e,u as j,n as xe,b as me,P as f,C as pe,A as J,M as v,T as w,G as M,L as Y,D as P,S as L,c as B,d as U,e as Q,f as X,h as ue,i as he,k as ge,U as be,l as fe,m as se,o as te,a as je,p as ve,q as _,v as we}from"./index-BY3_XaK9.js";const Ne=new Set(["pulling_image","running_init_script","building_image"]);function A({steps:t,error:c}){const[n,i]=u.useState({}),[r,m]=u.useState(new Set),l=u.useRef(new Map),h=u.useCallback(o=>x=>{x?l.current.set(o,x):l.current.delete(o)},[]);return u.useEffect(()=>{for(const o of t)o.detail&&Ne.has(o.step)&&(i(x=>{const a=x[o.step]||[];return a.length===0||a[a.length-1]!==o.detail?{...x,[o.step]:[...a,o.detail]}:x}),m(x=>{if(x.has(o.step))return x;const a=new Set(x);return a.add(o.step),a}))},[t]),u.useEffect(()=>{var o;for(const x of l.current.values())(o=x.scrollTo)==null||o.call(x,{top:x.scrollHeight})},[n]),t.length===0?null:e.jsxs("div",{className:"w-full max-w-md mx-auto mt-4 mb-2",children:[e.jsx("div",{className:"space-y-1.5",children:t.map(o=>{const x=n[o.step],a=x&&x.length>0,y=r.has(o.step);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 py-1",children:[e.jsxs("div",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:[o.status==="in_progress"&&e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-cc-primary/30 border-t-cc-primary rounded-full animate-spin"}),o.status==="done"&&e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-success",children:e.jsx("path",{d:"M13.25 4.75L6 12 2.75 8.75",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),o.status==="error"&&e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-error",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]}),e.jsx("span",{className:`text-sm flex-1 ${o.status==="in_progress"?"text-cc-fg font-medium":o.status==="done"?"text-cc-muted":"text-cc-error"}`,children:o.label}),a&&e.jsx("button",{onClick:()=>m(N=>{const p=new Set(N);return p.has(o.step)?p.delete(o.step):p.add(o.step),p}),className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:y?"Hide logs":"Show logs"})]}),a&&y&&e.jsx("pre",{ref:h(o.step),className:"ml-[26px] mt-1 mb-1 px-3 py-2 text-[10px] font-mono-code bg-black/20 border border-cc-border rounded-md text-cc-muted max-h-[150px] overflow-auto whitespace-pre-wrap",children:x.slice(-30).join(`
2
2
  `)})]},o.step)})}),c&&e.jsx("div",{className:"mt-2.5 px-3 py-2 rounded-lg bg-cc-error/5 border border-cc-error/20",children:e.jsx("p",{className:"text-xs text-cc-error whitespace-pre-wrap",children:c})})]})}const b="playground-session";function g(t){return{request_id:`perm-${Math.random().toString(36).slice(2,8)}`,tool_use_id:`tu-${Math.random().toString(36).slice(2,8)}`,timestamp:Date.now(),...t}}const ne=g({tool_name:"Bash",input:{command:"git log --oneline -20 && npm run build",description:"View recent commits and build the project"},permission_suggestions:[{type:"addRules",rules:[{toolName:"Bash",ruleContent:"git log --oneline -20 && npm run build"}],behavior:"allow",destination:"session"},{type:"addRules",rules:[{toolName:"Bash",ruleContent:"git log --oneline -20 && npm run build"}],behavior:"allow",destination:"projectSettings"}]}),ye=g({tool_name:"Edit",input:{file_path:"/Users/stan/Dev/project/src/utils/format.ts",old_string:`export function formatDate(d: Date) {
3
3
  return d.toISOString();
4
4
  }`,new_string:`export function formatDate(d: Date, locale = "en-US") {
@@ -1,4 +1,4 @@
1
- import{r as o,u as X,a as Z,j as e,n as ne,b as ae,F as Y}from"./index-D-JiBkdW.js";function me({embedded:r=!1}){const[a,i]=o.useState([]),[b,h]=o.useState(!0),[l,f]=o.useState(!1),[j,d]=o.useState(""),[v,P]=o.useState(""),[y,E]=o.useState(""),[u,N]=o.useState("global"),[p,w]=o.useState([]),[A,F]=o.useState(!1),[g,$]=o.useState(null),[D,S]=o.useState(""),[G,C]=o.useState(""),[L,k]=o.useState("global"),[M,m]=o.useState([]),[se,H]=o.useState(!1),[z,re]=o.useState(""),[B,q]=o.useState(!1),U=X(t=>t.currentSessionId),x=X(t=>{var s,c;return t.currentSessionId&&(((s=t.sessions.get(t.currentSessionId))==null?void 0:s.cwd)||((c=t.sdkSessions.find(n=>n.sessionId===t.currentSessionId))==null?void 0:c.cwd))||""}),I=o.useMemo(()=>{const t=z.trim().toLowerCase();return t?a.filter(s=>`${s.name}
1
+ import{r as o,u as X,a as Z,j as e,n as ne,b as ae,F as Y}from"./index-BY3_XaK9.js";function me({embedded:r=!1}){const[a,i]=o.useState([]),[b,h]=o.useState(!0),[l,f]=o.useState(!1),[j,d]=o.useState(""),[v,P]=o.useState(""),[y,E]=o.useState(""),[u,N]=o.useState("global"),[p,w]=o.useState([]),[A,F]=o.useState(!1),[g,$]=o.useState(null),[D,S]=o.useState(""),[G,C]=o.useState(""),[L,k]=o.useState("global"),[M,m]=o.useState([]),[se,H]=o.useState(!1),[z,re]=o.useState(""),[B,q]=o.useState(!1),U=X(t=>t.currentSessionId),x=X(t=>{var s,c;return t.currentSessionId&&(((s=t.sessions.get(t.currentSessionId))==null?void 0:s.cwd)||((c=t.sdkSessions.find(n=>n.sessionId===t.currentSessionId))==null?void 0:c.cwd))||""}),I=o.useMemo(()=>{const t=z.trim().toLowerCase();return t?a.filter(s=>`${s.name}
2
2
  ${s.content}
3
3
  ${s.scope}`.toLowerCase().includes(t)):a},[a,z]),V=a.length,J=I.length,T=o.useMemo(()=>{const t=I.filter(n=>n.scope==="global"),s=I.filter(n=>n.scope==="project"),c=new Map;for(const n of s){const _=n.projectPaths??(n.projectPath?[n.projectPath]:[]),W=_.length>0?_.slice().sort().join(`
4
4
  `):"(no folder)",oe=_.length>0?_.map(Q=>Q.split("/").pop()||Q).join(", "):"(no folder)";c.has(W)||c.set(W,{label:oe,prompts:[]}),c.get(W).prompts.push(n)}return{globalPrompts:t,folderGroups:c}},[I]),R=o.useCallback(async()=>{h(!0),d("");try{const t=await Z.listPrompts();i(t)}catch(t){d(t instanceof Error?t.message:String(t))}finally{h(!1)}},[]);o.useEffect(()=>{R()},[R]);async function ce(t){if(t.preventDefault(),!(!v.trim()||!y.trim())){if(u==="project"&&p.length===0){d("Select at least one project folder");return}f(!0),d("");try{await Z.createPrompt({name:v.trim(),content:y.trim(),scope:u,projectPaths:u==="project"?p:void 0}),P(""),E(""),N("global"),w([]),q(!1),await R()}catch(s){d(s instanceof Error?s.message:String(s))}finally{f(!1)}}}async function K(t){try{await Z.deletePrompt(t),await R()}catch(s){d(s instanceof Error?s.message:String(s))}}async function O(){if(!(!g||!D.trim()||!G.trim())){if(L==="project"&&M.length===0){d("Select at least one project folder");return}try{await Z.updatePrompt(g,{name:D.trim(),content:G.trim(),scope:L,projectPaths:L==="project"?M:void 0}),$(null),S(""),C(""),k("global"),m([]),await R()}catch(t){d(t instanceof Error?t.message:String(t))}}}return e.jsxs("div",{className:`${r?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:[e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Saved Prompts"}),e.jsxs("p",{className:"mt-0.5 text-[13px] text-cc-muted leading-relaxed",children:["Create reusable prompts — insert with ",e.jsx("code",{className:"text-cc-fg text-xs bg-cc-hover rounded px-1 py-0.5",children:"@title"})," in the composer."]})]}),!r&&e.jsx("button",{onClick:()=>{U?ne(U):ae()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer shrink-0",children:"Back"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 mb-5",children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-cc-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.35-4.35"})]}),e.jsx("input",{value:z,onChange:t=>re(t.target.value),placeholder:"Search by title or content...",className:"w-full pl-9 pr-3 py-2.5 min-h-[44px] text-sm bg-cc-card rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]}),e.jsxs("button",{onClick:()=>q(!B),className:`flex items-center gap-1.5 px-3.5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer shrink-0 ${B?"bg-cc-active text-cc-fg":"bg-cc-primary hover:bg-cc-primary-hover text-white"}`,children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:B?e.jsx("path",{d:"M18 6 6 18M6 6l12 12"}):e.jsx("path",{d:"M12 5v14M5 12h14"})}),e.jsx("span",{className:"hidden sm:inline",children:B?"Cancel":"New Prompt"})]})]}),B&&e.jsx("form",{onSubmit:ce,className:"mb-6",style:{animation:"fadeSlideIn 150ms ease-out"},children:e.jsx(te,{mode:"create",name:v,content:y,scope:u,folders:p,error:j,saving:l,submitLabel:l?"Saving...":"Create Prompt",onNameChange:P,onContentChange:E,onScopeChange:t=>{N(t),t==="project"&&p.length===0&&x&&w([x])},onRemoveFolder:t=>w(s=>s.filter(c=>c!==t)),onAddFolder:()=>F(!0)})}),e.jsx("div",{className:"flex items-center gap-2 mb-3 text-[12px] text-cc-muted",children:e.jsx("span",{children:J===V?`${V} prompt${V!==1?"s":""}`:`${J} of ${V}`})}),b?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"Loading prompts..."}):a.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"No prompts yet."}):I.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"No prompts match your search."}):e.jsxs("div",{className:"space-y-4",children:[T.globalPrompts.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-[11px] uppercase tracking-wider text-cc-muted font-semibold mb-1.5 px-1",children:"Global"}),e.jsx("div",{className:"space-y-1",children:T.globalPrompts.map(t=>e.jsx(ee,{prompt:t,isEditing:g===t.id,error:j,editName:D,editContent:G,editScope:L,editFolders:M,cwd:x,onEditNameChange:S,onEditContentChange:C,onEditScopeChange:s=>{k(s),s==="project"&&M.length===0&&x&&m([x])},onEditRemoveFolder:s=>m(c=>c.filter(n=>n!==s)),onEditAddFolder:()=>H(!0),onStartEdit:()=>{$(t.id),S(t.name),C(t.content),k(t.scope),m(t.projectPaths??(t.projectPath?[t.projectPath]:[]))},onCancelEdit:()=>{$(null),S(""),C(""),k("global"),m([])},onSaveEdit:()=>void O(),onDelete:()=>void K(t.id)},t.id))})]}),Array.from(T.folderGroups.entries()).map(([t,s])=>e.jsxs("div",{children:[e.jsx("h2",{className:"text-[11px] uppercase tracking-wider text-cc-muted font-semibold mb-1.5 px-1",children:s.label}),e.jsx("div",{className:"space-y-1",children:s.prompts.map(c=>e.jsx(ee,{prompt:c,isEditing:g===c.id,error:j,editName:D,editContent:G,editScope:L,editFolders:M,cwd:x,onEditNameChange:S,onEditContentChange:C,onEditScopeChange:n=>{k(n),n==="project"&&M.length===0&&x&&m([x])},onEditRemoveFolder:n=>m(_=>_.filter(W=>W!==n)),onEditAddFolder:()=>H(!0),onStartEdit:()=>{$(c.id),S(c.name),C(c.content),k(c.scope),m(c.projectPaths??(c.projectPath?[c.projectPath]:[]))},onCancelEdit:()=>{$(null),S(""),C(""),k("global"),m([])},onSaveEdit:()=>void O(),onDelete:()=>void K(c.id)},c.id))})]},t))]})]}),A&&e.jsx(Y,{initialPath:x||"/",onSelect:t=>{w(s=>s.includes(t)?s:[...s,t]),F(!1)},onClose:()=>F(!1)}),se&&e.jsx(Y,{initialPath:x||"/",onSelect:t=>{m(s=>s.includes(t)?s:[...s,t]),H(!1)},onClose:()=>H(!1)})]})}function ie({scope:r,onScopeChange:a,folders:i,onRemoveFolder:b,onAddFolder:h}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium uppercase tracking-[0.24em] text-cc-muted",children:"Scope"}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted/80",children:"Choose whether this prompt should be available everywhere or only inside specific repos."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button","aria-pressed":r==="global",onClick:()=>a("global"),className:`inline-flex min-h-[40px] items-center rounded-full border px-4 py-2 text-sm transition-colors cursor-pointer ${r==="global"?"border-cc-primary/40 text-cc-primary bg-cc-primary/10 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)]":"border-cc-border text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:"Global"}),e.jsx("button",{type:"button","aria-pressed":r==="project",onClick:()=>a("project"),className:`inline-flex min-h-[40px] items-center rounded-full border px-4 py-2 text-sm transition-colors cursor-pointer ${r==="project"?"border-cc-primary/40 text-cc-primary bg-cc-primary/10 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)]":"border-cc-border text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:"Project folders"})]}),r==="project"&&e.jsxs("div",{className:"rounded-2xl border border-cc-border/70 bg-cc-bg/60 p-3 space-y-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-cc-fg",children:"Project folders"}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:"Prompts scoped to folders only appear when the active session is inside one of those paths."})]})}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(l=>e.jsxs("span",{className:"inline-flex min-h-[32px] items-center gap-1.5 rounded-full border border-cc-border/80 bg-cc-hover px-3 py-1.5 text-xs font-mono-code text-cc-fg",children:[e.jsx("span",{className:"truncate max-w-[200px]",title:l,children:l.split("/").pop()||l}),e.jsx("button",{type:"button",onClick:()=>b(l),className:"text-cc-muted hover:text-cc-error cursor-pointer shrink-0","aria-label":`Remove folder ${l}`,children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]},l))}),e.jsxs("button",{type:"button",onClick:h,className:"inline-flex min-h-[40px] items-center gap-1.5 rounded-full border border-dashed border-cc-border px-3 py-2 text-sm text-cc-muted transition-colors cursor-pointer hover:text-cc-fg hover:bg-cc-hover",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3 h-3",children:e.jsx("path",{d:"M8 3v10M3 8h10",strokeLinecap:"round"})}),"Add folder"]})]})]})}function te({mode:r,name:a,content:i,scope:b,folders:h,saving:l=!1,error:f,submitLabel:j,cancelLabel:d="Cancel",onNameChange:v,onContentChange:P,onScopeChange:y,onRemoveFolder:E,onAddFolder:u,onSubmit:N,onCancel:p}){const w=!!(a.trim()&&i.trim()),A=i.split(/\r?\n/).length,F=i.length;return e.jsxs("section",{className:"overflow-hidden rounded-[28px] border border-cc-border/70 bg-cc-card shadow-[0_20px_60px_rgba(0,0,0,0.22)]",children:[e.jsx("div",{className:"border-b border-cc-border/60 bg-[linear-gradient(135deg,rgba(255,255,255,0.04),rgba(255,255,255,0))] px-5 py-4 sm:px-6",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.28em] text-cc-primary/80",children:r==="create"?"Prompt Studio":"Edit Prompt"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-cc-fg",children:r==="create"?"Write with room to think":"Refine this saved prompt"}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-cc-muted",children:"Structure the title, scope, and body separately so longer instructions stay easy to review before saving."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-cc-muted",children:[e.jsxs("span",{className:"inline-flex min-h-[32px] items-center rounded-full border border-cc-border/70 bg-cc-bg/60 px-3",children:[A," line",A>1?"s":""]}),e.jsxs("span",{className:"inline-flex min-h-[32px] items-center rounded-full border border-cc-border/70 bg-cc-bg/60 px-3",children:[F," char",F>1?"s":""]})]})]})}),e.jsxs("div",{className:"grid gap-0 lg:grid-cols-[minmax(280px,340px)_minmax(0,1fr)]",children:[e.jsx("div",{className:"border-b border-cc-border/60 p-5 sm:p-6 lg:border-b-0 lg:border-r",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium uppercase tracking-[0.24em] text-cc-muted",htmlFor:r==="create"?"prompt-name":void 0,children:"Title"}),e.jsx("input",{id:r==="create"?"prompt-name":void 0,type:"text",value:a,onChange:g=>v(g.target.value),placeholder:"review-pr",className:"w-full rounded-2xl border border-cc-border/70 bg-cc-bg px-4 py-3 text-sm text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsxs("p",{className:"mt-2 text-xs leading-relaxed text-cc-muted",children:["Use a short handle that is easy to insert with ",e.jsx("code",{className:"rounded bg-cc-hover px-1 py-0.5 text-[11px] text-cc-fg",children:"@title"}),"."]})]}),e.jsx(ie,{scope:b,onScopeChange:y,folders:h,onRemoveFolder:E,onAddFolder:u}),e.jsxs("div",{className:"rounded-2xl border border-dashed border-cc-border/70 bg-cc-bg/40 p-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.24em] text-cc-muted",children:"Storage"}),e.jsxs("p",{className:"mt-2 text-sm leading-relaxed text-cc-muted",children:["Saved in ",e.jsx("code",{className:"text-[11px] text-cc-fg",children:"~/.companion/prompts.json"})," and available from the composer autocomplete."]})]})]})}),e.jsx("div",{className:"p-5 sm:p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium uppercase tracking-[0.24em] text-cc-muted",htmlFor:r==="create"?"prompt-content":void 0,children:"Content"}),e.jsx("p",{className:"text-sm text-cc-muted",children:"Longer prompts stay readable here. Leave breathing room for detailed review flows, checklists, or operating instructions."})]})}),e.jsx("textarea",{id:r==="create"?"prompt-content":void 0,value:i,onChange:g=>P(g.target.value),placeholder:"Review this PR and summarize risks, regressions, and missing tests.",rows:r==="create"?14:10,className:"min-h-[320px] w-full resize-y rounded-[24px] border border-cc-border/70 bg-cc-bg px-4 py-4 text-sm leading-7 text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow lg:min-h-[420px]"}),f&&e.jsx("div",{className:"rounded-2xl border border-cc-error/20 bg-cc-error/10 px-4 py-3 text-sm text-cc-error",children:f}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-cc-border/60 pt-4",children:[p&&e.jsx("button",{type:"button",onClick:p,className:"min-h-[44px] rounded-full px-4 py-2.5 text-sm text-cc-muted transition-colors cursor-pointer hover:bg-cc-hover hover:text-cc-fg",children:d}),e.jsx("button",{type:N?"button":"submit",onClick:N,disabled:l||!w,className:`min-h-[44px] rounded-full px-5 py-2.5 text-sm font-medium transition-colors ${l||!w?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary text-white cursor-pointer hover:bg-cc-primary-hover"}`,children:j})]})]})})]})]})}function le({prompt:r}){if(r.scope==="global")return e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-cc-muted opacity-60",children:"global"});const a=r.projectPaths??(r.projectPath?[r.projectPath]:[]);return a.length===0?null:e.jsx("span",{className:"inline-flex items-center gap-1 flex-wrap",children:a.map(i=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-cc-primary/8 text-cc-primary/70 font-mono-code",title:i,children:i.split("/").pop()||i},i))})}function ee({prompt:r,isEditing:a,error:i,editName:b,editContent:h,editScope:l,editFolders:f,onEditNameChange:j,onEditContentChange:d,onEditScopeChange:v,onEditRemoveFolder:P,onEditAddFolder:y,onStartEdit:E,onCancelEdit:u,onSaveEdit:N,onDelete:p}){return a?e.jsx("div",{className:"rounded-2xl",style:{animation:"fadeSlideIn 150ms ease-out"},children:e.jsx(te,{mode:"edit",name:b,content:h,scope:l,folders:f,error:i,submitLabel:"Save",onNameChange:j,onContentChange:d,onScopeChange:v,onRemoveFolder:P,onAddFolder:y,onCancel:u,onSubmit:N})}):e.jsxs("div",{className:"group flex items-start gap-3 px-3 py-3 min-h-[44px] rounded-lg hover:bg-cc-hover/60 transition-colors",children:[e.jsx("div",{className:"shrink-0 mt-0.5 w-7 h-7 rounded-md bg-cc-primary/10 flex items-center justify-center",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5 text-cc-primary",children:e.jsx("path",{d:"M7 8h10M7 12h6M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H8l-4 4V5Z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:r.name}),e.jsx(le,{prompt:r})]}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted line-clamp-2 leading-relaxed",children:r.content})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:E,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-active transition-colors cursor-pointer","aria-label":"Edit",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5Z"})]})}),e.jsx("button",{onClick:p,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-error hover:bg-cc-error/10 transition-colors cursor-pointer","aria-label":"Delete",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14Z"})})})]})]})}export{me as PromptsPage};
@@ -1 +1 @@
1
- import{r,a as N,j as e,t as I}from"./index-D-JiBkdW.js";function g(c){switch(c){case"manual":return"Manual";case"webhook":return"Webhook";case"schedule":return"Schedule";case"linear":return"Linear";default:return c}}function v(c){switch(c){case"manual":return"bg-blue-500/10 text-blue-600 dark:text-blue-400";case"webhook":return"bg-purple-500/10 text-purple-600 dark:text-purple-400";case"schedule":return"bg-amber-500/10 text-amber-600 dark:text-amber-400";case"linear":return"bg-violet-500/10 text-violet-600 dark:text-violet-400";default:return"bg-cc-hover text-cc-muted"}}function E(c){return c.error?{label:"Error",color:"text-cc-error"}:c.success?{label:"Success",color:"text-cc-success"}:c.completedAt?{label:"Unknown",color:"text-cc-muted"}:{label:"Running",color:"text-cc-warning"}}function y(c,x){const l=(x||Date.now())-c;if(l<1e3)return"<1s";if(l<6e4)return`${Math.round(l/1e3)}s`;const u=Math.floor(l/6e4),h=Math.round(l%6e4/1e3);return`${u}m ${h}s`}function T(){const[c,x]=r.useState([]),[m,l]=r.useState([]),[u,h]=r.useState(0),[k,w]=r.useState(!0),[n,A]=r.useState("all"),[i,S]=r.useState("all"),[o,C]=r.useState(""),[s,f]=r.useState(null),p=r.useCallback(async()=>{try{const t={limit:100};n!=="all"&&(t.triggerType=n),i!=="all"&&(t.status=i),o&&(t.agentId=o);const a=await N.listExecutions(t);x(a.executions),h(a.total)}catch(t){console.error("[runs] Failed to fetch executions:",t)}finally{w(!1)}},[n,i,o]),b=r.useCallback(async()=>{try{const t=await N.listAgents();l(t)}catch(t){console.error("[runs] Failed to fetch agents:",t)}},[]);r.useEffect(()=>{b()},[b]),r.useEffect(()=>{p();const t=setInterval(p,5e3);return()=>clearInterval(t)},[p]);const j=t=>{const a=m.find(d=>d.id===t);return(a==null?void 0:a.name)||t};return e.jsxs("div",{className:"h-full flex flex-col bg-cc-bg",children:[e.jsxs("div",{className:"shrink-0 border-b border-cc-border px-6 py-4",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Runs"}),e.jsx("p",{className:"text-sm text-cc-muted mt-1",children:"Monitor agent executions across all triggers"})]}),e.jsxs("div",{className:"shrink-0 border-b border-cc-border px-6 py-3 flex items-center gap-4 flex-wrap",children:[e.jsxs("select",{value:o,onChange:t=>C(t.target.value),className:"text-sm rounded-md border border-cc-border bg-cc-input-bg text-cc-fg px-2 py-1","aria-label":"Filter by agent",children:[e.jsx("option",{value:"",children:"All agents"}),m.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx("div",{className:"flex items-center gap-1",children:["all","manual","webhook","schedule","linear"].map(t=>e.jsx("button",{onClick:()=>A(t),className:`text-xs px-2.5 py-1 rounded-full transition-colors ${n===t?"bg-cc-fg text-cc-bg":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="all"?"All triggers":g(t)},t))}),e.jsx("div",{className:"flex items-center gap-1",children:["all","running","success","error"].map(t=>e.jsx("button",{onClick:()=>S(t),className:`text-xs px-2.5 py-1 rounded-full transition-colors ${i===t?"bg-cc-fg text-cc-bg":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="all"?"All statuses":t.charAt(0).toUpperCase()+t.slice(1)},t))}),e.jsxs("span",{className:"text-xs text-cc-muted ml-auto",children:[u," total"]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:k?e.jsx("div",{className:"text-sm text-cc-muted text-center py-12",children:"Loading..."}):c.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"mb-3 flex justify-center text-cc-muted",children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-8 h-8",children:e.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5a.75.75 0 011.5 0v3.19l2.03 2.03a.75.75 0 01-1.06 1.06l-2.25-2.25A.75.75 0 017.25 8V4.5z"})})}),e.jsx("p",{className:"text-sm text-cc-muted",children:"No executions found"}),e.jsx("p",{className:"text-xs text-cc-muted mt-1",children:"Run an agent to see executions here"})]}):e.jsxs("table",{className:"w-full text-sm",role:"table",children:[e.jsx("thead",{className:"sticky top-0 bg-cc-card backdrop-blur",children:e.jsxs("tr",{className:"text-left text-xs text-cc-muted uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Agent"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Trigger"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Started"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Duration"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Session"})]})}),e.jsx("tbody",{className:"divide-y divide-cc-border/50",children:c.map(t=>{const a=E(t),d=(s==null?void 0:s.sessionId)===t.sessionId;return e.jsxs("tr",{onClick:()=>f(d?null:t),className:`cursor-pointer transition-colors ${d?"bg-cc-active":"hover:bg-cc-hover"}`,children:[e.jsx("td",{className:"px-6 py-3",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-cc-fg font-medium",children:j(t.agentId)})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${v(t.triggerType)}`,children:g(t.triggerType)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`font-medium ${a.color}`,children:[!t.completedAt&&!t.error&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-cc-warning mr-1.5 animate-pulse"}),a.label]})}),e.jsx("td",{className:"px-4 py-3 text-cc-muted",children:I(t.startedAt)}),e.jsx("td",{className:"px-4 py-3 text-cc-muted font-mono text-xs",children:y(t.startedAt,t.completedAt)}),e.jsx("td",{className:"px-4 py-3",children:t.sessionId&&e.jsx("a",{href:`#/session/${t.sessionId}`,onClick:$=>$.stopPropagation(),className:"text-cc-primary hover:text-cc-primary-hover text-xs font-mono underline",children:"Open"})})]},`${t.sessionId}-${t.startedAt}`)})})]})}),s&&e.jsxs("div",{className:"shrink-0 border-t border-cc-border bg-cc-card px-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg",children:"Execution Details"}),e.jsx("button",{onClick:()=>f(null),className:"text-cc-muted hover:text-cc-fg text-sm transition-colors","aria-label":"Close details",children:"Close"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Agent"}),e.jsx("p",{className:"text-cc-fg font-medium",children:j(s.agentId)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Trigger"}),e.jsx("p",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${v(s.triggerType)}`,children:g(s.triggerType)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Started"}),e.jsx("p",{className:"text-cc-fg",children:new Date(s.startedAt).toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Duration"}),e.jsx("p",{className:"text-cc-fg font-mono",children:y(s.startedAt,s.completedAt)})]})]}),s.error&&e.jsx("div",{className:"mt-3 p-2 bg-cc-error/10 rounded text-sm text-cc-error font-mono whitespace-pre-wrap",children:s.error}),s.sessionId&&e.jsx("a",{href:`#/session/${s.sessionId}`,className:"mt-3 inline-flex items-center gap-1 text-sm text-cc-primary hover:text-cc-primary-hover",children:"Open session to view live output"})]})]})}export{T as RunsPage};
1
+ import{r,a as N,j as e,t as I}from"./index-BY3_XaK9.js";function g(c){switch(c){case"manual":return"Manual";case"webhook":return"Webhook";case"schedule":return"Schedule";case"linear":return"Linear";default:return c}}function v(c){switch(c){case"manual":return"bg-blue-500/10 text-blue-600 dark:text-blue-400";case"webhook":return"bg-purple-500/10 text-purple-600 dark:text-purple-400";case"schedule":return"bg-amber-500/10 text-amber-600 dark:text-amber-400";case"linear":return"bg-violet-500/10 text-violet-600 dark:text-violet-400";default:return"bg-cc-hover text-cc-muted"}}function E(c){return c.error?{label:"Error",color:"text-cc-error"}:c.success?{label:"Success",color:"text-cc-success"}:c.completedAt?{label:"Unknown",color:"text-cc-muted"}:{label:"Running",color:"text-cc-warning"}}function y(c,x){const l=(x||Date.now())-c;if(l<1e3)return"<1s";if(l<6e4)return`${Math.round(l/1e3)}s`;const u=Math.floor(l/6e4),h=Math.round(l%6e4/1e3);return`${u}m ${h}s`}function T(){const[c,x]=r.useState([]),[m,l]=r.useState([]),[u,h]=r.useState(0),[k,w]=r.useState(!0),[n,A]=r.useState("all"),[i,S]=r.useState("all"),[o,C]=r.useState(""),[s,f]=r.useState(null),p=r.useCallback(async()=>{try{const t={limit:100};n!=="all"&&(t.triggerType=n),i!=="all"&&(t.status=i),o&&(t.agentId=o);const a=await N.listExecutions(t);x(a.executions),h(a.total)}catch(t){console.error("[runs] Failed to fetch executions:",t)}finally{w(!1)}},[n,i,o]),b=r.useCallback(async()=>{try{const t=await N.listAgents();l(t)}catch(t){console.error("[runs] Failed to fetch agents:",t)}},[]);r.useEffect(()=>{b()},[b]),r.useEffect(()=>{p();const t=setInterval(p,5e3);return()=>clearInterval(t)},[p]);const j=t=>{const a=m.find(d=>d.id===t);return(a==null?void 0:a.name)||t};return e.jsxs("div",{className:"h-full flex flex-col bg-cc-bg",children:[e.jsxs("div",{className:"shrink-0 border-b border-cc-border px-6 py-4",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Runs"}),e.jsx("p",{className:"text-sm text-cc-muted mt-1",children:"Monitor agent executions across all triggers"})]}),e.jsxs("div",{className:"shrink-0 border-b border-cc-border px-6 py-3 flex items-center gap-4 flex-wrap",children:[e.jsxs("select",{value:o,onChange:t=>C(t.target.value),className:"text-sm rounded-md border border-cc-border bg-cc-input-bg text-cc-fg px-2 py-1","aria-label":"Filter by agent",children:[e.jsx("option",{value:"",children:"All agents"}),m.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx("div",{className:"flex items-center gap-1",children:["all","manual","webhook","schedule","linear"].map(t=>e.jsx("button",{onClick:()=>A(t),className:`text-xs px-2.5 py-1 rounded-full transition-colors ${n===t?"bg-cc-fg text-cc-bg":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="all"?"All triggers":g(t)},t))}),e.jsx("div",{className:"flex items-center gap-1",children:["all","running","success","error"].map(t=>e.jsx("button",{onClick:()=>S(t),className:`text-xs px-2.5 py-1 rounded-full transition-colors ${i===t?"bg-cc-fg text-cc-bg":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="all"?"All statuses":t.charAt(0).toUpperCase()+t.slice(1)},t))}),e.jsxs("span",{className:"text-xs text-cc-muted ml-auto",children:[u," total"]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:k?e.jsx("div",{className:"text-sm text-cc-muted text-center py-12",children:"Loading..."}):c.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"mb-3 flex justify-center text-cc-muted",children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-8 h-8",children:e.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5a.75.75 0 011.5 0v3.19l2.03 2.03a.75.75 0 01-1.06 1.06l-2.25-2.25A.75.75 0 017.25 8V4.5z"})})}),e.jsx("p",{className:"text-sm text-cc-muted",children:"No executions found"}),e.jsx("p",{className:"text-xs text-cc-muted mt-1",children:"Run an agent to see executions here"})]}):e.jsxs("table",{className:"w-full text-sm",role:"table",children:[e.jsx("thead",{className:"sticky top-0 bg-cc-card backdrop-blur",children:e.jsxs("tr",{className:"text-left text-xs text-cc-muted uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Agent"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Trigger"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Started"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Duration"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Session"})]})}),e.jsx("tbody",{className:"divide-y divide-cc-border/50",children:c.map(t=>{const a=E(t),d=(s==null?void 0:s.sessionId)===t.sessionId;return e.jsxs("tr",{onClick:()=>f(d?null:t),className:`cursor-pointer transition-colors ${d?"bg-cc-active":"hover:bg-cc-hover"}`,children:[e.jsx("td",{className:"px-6 py-3",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-cc-fg font-medium",children:j(t.agentId)})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${v(t.triggerType)}`,children:g(t.triggerType)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`font-medium ${a.color}`,children:[!t.completedAt&&!t.error&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-cc-warning mr-1.5 animate-pulse"}),a.label]})}),e.jsx("td",{className:"px-4 py-3 text-cc-muted",children:I(t.startedAt)}),e.jsx("td",{className:"px-4 py-3 text-cc-muted font-mono text-xs",children:y(t.startedAt,t.completedAt)}),e.jsx("td",{className:"px-4 py-3",children:t.sessionId&&e.jsx("a",{href:`#/session/${t.sessionId}`,onClick:$=>$.stopPropagation(),className:"text-cc-primary hover:text-cc-primary-hover text-xs font-mono underline",children:"Open"})})]},`${t.sessionId}-${t.startedAt}`)})})]})}),s&&e.jsxs("div",{className:"shrink-0 border-t border-cc-border bg-cc-card px-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg",children:"Execution Details"}),e.jsx("button",{onClick:()=>f(null),className:"text-cc-muted hover:text-cc-fg text-sm transition-colors","aria-label":"Close details",children:"Close"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Agent"}),e.jsx("p",{className:"text-cc-fg font-medium",children:j(s.agentId)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Trigger"}),e.jsx("p",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${v(s.triggerType)}`,children:g(s.triggerType)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Started"}),e.jsx("p",{className:"text-cc-fg",children:new Date(s.startedAt).toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Duration"}),e.jsx("p",{className:"text-cc-fg font-mono",children:y(s.startedAt,s.completedAt)})]})]}),s.error&&e.jsx("div",{className:"mt-3 p-2 bg-cc-error/10 rounded text-sm text-cc-error font-mono whitespace-pre-wrap",children:s.error}),s.sessionId&&e.jsx("a",{href:`#/session/${s.sessionId}`,className:"mt-3 inline-flex items-center gap-1 text-sm text-cc-primary hover:text-cc-primary-hover",children:"Open session to view live output"})]})]})}export{T as RunsPage};