@hellcoder/companion 0.108.1-preview.20260719081154.9a11f0f → 0.109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentsPage-DI5hdCnz.js → AgentsPage-Dye7KBqi.js} +1 -1
- package/dist/assets/{CronManager-yX8i4C_S.js → CronManager-DTlT02dA.js} +1 -1
- package/dist/assets/{DashboardPage-D1nc0wHf.js → DashboardPage-fvKg3Yqp.js} +1 -1
- package/dist/assets/{IntegrationsPage-iSfvR9vX.js → IntegrationsPage-F68cGNc0.js} +1 -1
- package/dist/assets/{LinearOAuthSettingsPage-omExXsGc.js → LinearOAuthSettingsPage-SoGpGzIF.js} +1 -1
- package/dist/assets/{LinearSettingsPage-C4oBf1iO.js → LinearSettingsPage-CPvMIKgr.js} +1 -1
- package/dist/assets/{Playground-CjiZI9QY.js → Playground-CF7prjX2.js} +1 -1
- package/dist/assets/{PromptsPage-CU6z49U6.js → PromptsPage-vx71p6l9.js} +1 -1
- package/dist/assets/{RunsPage-mcU7OUoZ.js → RunsPage-CH4PZDnZ.js} +1 -1
- package/dist/assets/{SandboxManager-BkYS-dK5.js → SandboxManager-YH5E0Jto.js} +1 -1
- package/dist/assets/{SettingsPage-CyHMmTBB.js → SettingsPage-B2dQwyjl.js} +1 -1
- package/dist/assets/{TailscalePage-CRyiyMcJ.js → TailscalePage-OvQqy343.js} +1 -1
- package/dist/assets/index-Daik8cew.js +136 -0
- package/dist/assets/{sw-register-Dqdfho7x.js → sw-register-CcXhHDAn.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/server/settings-manager.test.ts +3 -1
- package/server/settings-manager.ts +2 -2
- package/dist/assets/index-DOle27vf.js +0 -136
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r,j as e,u as Be,a as E,z as ae,F as ye,L as ne,t as ze,H as Ne,B as Ie,I as Oe}from"./index-DOle27vf.js";const Ee="companion_public_url_dismissed";function De({publicUrl:t}){const[i,d]=r.useState(()=>localStorage.getItem(Ee)==="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(Ee,"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,j=!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 ${j?"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,j]=r.useState(d||""),[y,l]=r.useState("");r.useEffect(()=>{E.listLinearOAuthConnections().then(b=>{m(b.connections),l(""),d?b.connections.some(p=>p.id===d)&&j(d):b.connections.length===1&&j(b.connections[0].id)}).catch(b=>l(b instanceof Error?b.message:String(b))).finally(()=>h(!1))},[d]);const N=a.find(b=>b.id===g),k=!!g&&(N==null?void 0:N.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."})]}),y&&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:y}),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:()=>j(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 E,z as ae,F as ye,L as ne,t as ze,H as Ne,B as Ie,I as Oe}from"./index-Daik8cew.js";const Ee="companion_public_url_dismissed";function De({publicUrl:t}){const[i,d]=r.useState(()=>localStorage.getItem(Ee)==="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(Ee,"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,j=!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 ${j?"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,j]=r.useState(d||""),[y,l]=r.useState("");r.useEffect(()=>{E.listLinearOAuthConnections().then(b=>{m(b.connections),l(""),d?b.connections.some(p=>p.id===d)&&j(d):b.connections.length===1&&j(b.connections[0].id)}).catch(b=>l(b instanceof Error?b.message:String(b))).finally(()=>h(!1))},[d]);const N=a.find(b=>b.id===g),k=!!g&&(N==null?void 0:N.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."})]}),y&&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:y}),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:()=>j(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,y as _,z as B,B as U,E as Y,F as q}from"./index-DOle27vf.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,E]=a.useState(!1),[f,S]=a.useState(!1),[k,M]=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;E(!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{E(!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){M(i=>new Set(i).add(t));try{await j.runCronJob(t),n()}catch(i){x(i instanceof Error?i.message:String(i))}finally{M(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 E=a.useMemo(()=>[x],[]),f=a.useCallback(()=>m(!1),[]);z(E,f,g);const S=a.useMemo(()=>[r],[]),k=a.useCallback(()=>w(!1),[]);z(S,k,u);const M=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:M}),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,y as _,z as B,B as U,E as Y,F as q}from"./index-Daik8cew.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,E]=a.useState(!1),[f,S]=a.useState(!1),[k,M]=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;E(!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{E(!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){M(i=>new Set(i).add(t));try{await j.runCronJob(t),n()}catch(i){x(i instanceof Error?i.message:String(i))}finally{M(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 E=a.useMemo(()=>[x],[]),f=a.useCallback(()=>m(!1),[]);z(E,f,g);const S=a.useMemo(()=>[r],[]),k=a.useCallback(()=>w(!1),[]);z(S,k,u);const M=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:M}),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 as a,a as N,j as t,t as w,e as T,n as P}from"./index-DOle27vf.js";const I=[{id:"all",label:"All"},{id:"unfinished",label:"Unfinished"},{id:"awaiting_user",label:"Needs input"},{id:"completed",label:"Completed"},{id:"archivable",label:"Archivable"}],D={completed:{label:"Completed",className:"bg-cc-success/10 text-cc-success border-cc-success/20",dotClassName:"bg-cc-success"},in_progress:{label:"In progress",className:"bg-cc-primary/10 text-cc-primary border-cc-primary/20",dotClassName:"bg-cc-primary"},awaiting_user:{label:"Needs input",className:"bg-cc-warning/10 text-cc-warning border-cc-warning/20",dotClassName:"bg-cc-warning"},stalled:{label:"Stalled",className:"bg-cc-error/10 text-cc-error border-cc-error/20",dotClassName:"bg-cc-error"}};function $(e,s){switch(s){case"all":return!0;case"unfinished":return e.status==="in_progress"||e.status==="stalled";case"awaiting_user":return e.status==="awaiting_user";case"completed":return e.status==="completed";case"archivable":return e.archivable&&!e.companionArchived}}function U(e){const s=new Map;for(const i of e){const c=i.cwd.replace(/\/+$/,"")||"/";let n=s.get(c);n||(n={key:c,label:T(c),sessions:[],lastActivityAt:0},s.set(c,n)),n.sessions.push(i),n.lastActivityAt=Math.max(n.lastActivityAt,i.lastActivityAt)}const l=Array.from(s.values()).sort((i,c)=>c.lastActivityAt-i.lastActivityAt);for(const i of l)i.sessions.sort((c,n)=>n.lastActivityAt-c.lastActivityAt);return l}function E(e){return e.displayName||e.slug||`Session ${e.sessionId.slice(0,8)}`}function L({status:e}){const s=D[e];return t.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full border text-[11px] font-medium whitespace-nowrap ${s.className}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${s.dotClassName}`,"aria-hidden":"true"}),s.label]})}function _({progress:e}){const s=e.total>0?Math.round(e.processed/e.total*100):0,l=e.total>0?`Summarizing session ${Math.min(e.processed+1,e.total)} of ${e.total}${e.currentSession?` — ${e.currentSession}`:""}`:"Scanning sessions...";return t.jsxs("div",{className:"rounded-xl border border-cc-border bg-cc-card p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm text-cc-fg",children:l}),e.total>0&&t.jsxs("span",{className:"text-xs text-cc-muted tabular-nums",children:[s,"%"]})]}),t.jsx("div",{role:"progressbar","aria-label":"Dashboard update progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e.total>0?s:void 0,className:"h-2 w-full rounded-full bg-cc-hover overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full bg-cc-primary transition-all duration-500 ${e.total===0?"animate-pulse w-1/4":""}`,style:e.total>0?{width:`${Math.max(s,3)}%`}:void 0})}),e.failed>0&&t.jsxs("p",{className:"mt-2 text-[11px] text-cc-warning",children:[e.failed," session",e.failed===1?"":"s"," failed so far"]})]})}function B({session:e,onArchived:s}){const[l,i]=a.useState(!1),[c,n]=a.useState(""),p=!!e.companionSessionId&&e.archivable&&!e.companionArchived,b=[e.userName?`by ${e.userName}`:null,e.gitBranch?e.gitBranch:null,`active ${w(e.lastActivityAt)}`].filter(Boolean);async function h(){if(e.companionSessionId){i(!0),n("");try{await N.archiveSession(e.companionSessionId,{linearTransition:"none"}),s(e.companionSessionId)}catch(d){n(d instanceof Error?d.message:String(d))}finally{i(!1)}}}return t.jsx("li",{className:"rounded-lg border border-cc-border bg-cc-bg p-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.companionSessionId&&!e.companionArchived?t.jsx("button",{type:"button",onClick:()=>P(e.companionSessionId),className:"text-sm font-medium text-cc-fg hover:text-cc-primary truncate cursor-pointer text-left",title:"Open session",children:E(e)}):t.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:E(e)}),t.jsx(L,{status:e.status}),e.companionArchived&&t.jsx("span",{className:"text-[11px] text-cc-muted border border-cc-border rounded-full px-2 py-0.5",children:"Archived"}),!e.companionSessionId&&t.jsx("span",{className:"text-[11px] text-cc-muted border border-cc-border rounded-full px-2 py-0.5",title:"Discovered from ~/.claude — not launched through the companion",children:"External"})]}),t.jsx("p",{className:"mt-1.5 text-sm text-cc-fg/90 leading-relaxed",children:e.summary}),e.openItems.length>0&&t.jsx("ul",{className:"mt-2 space-y-1",children:e.openItems.map(d=>t.jsxs("li",{className:"text-xs text-cc-muted flex items-start gap-1.5",children:[t.jsx("span",{className:"mt-1 w-1 h-1 rounded-full bg-cc-muted shrink-0","aria-hidden":"true"}),d]},d))}),t.jsx("p",{className:"mt-2 text-[11px] text-cc-muted",children:b.join(" · ")}),c&&t.jsx("p",{className:"mt-1 text-[11px] text-cc-error",children:c})]}),p&&t.jsx("button",{type:"button",onClick:h,disabled:l,className:`shrink-0 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors ${l?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:l?"Archiving...":"Archive"})]})})}function z(){var C;const[e,s]=a.useState(null),[l,i]=a.useState(!0),[c,n]=a.useState(""),[p,b]=a.useState(""),[h,d]=a.useState("all"),[u,g]=a.useState(null),[f,M]=a.useState(new Set),m=a.useRef(null),v=a.useCallback(async()=>{try{const r=await N.getDashboard();s(r),g(r.progress.state==="running"?r.progress:null),n("")}catch(r){n(r instanceof Error?r.message:String(r))}finally{i(!1)}},[]);a.useEffect(()=>{v()},[v]),a.useEffect(()=>{if(!u||u.state!=="running"){m.current&&(clearInterval(m.current),m.current=null);return}if(!m.current)return m.current=setInterval(async()=>{try{const r=await N.getDashboardRunStatus();r.progress.state==="running"?g(r.progress):(g(null),v())}catch{}},1500),()=>{m.current&&(clearInterval(m.current),m.current=null)}},[u,v]);async function k(){b("");try{await N.runDashboardUpdate(),g({state:"running",trigger:"manual",total:0,processed:0,failed:0})}catch(r){b(r instanceof Error?r.message:String(r))}}const y=(u==null?void 0:u.state)==="running",A=a.useMemo(()=>e?e.sessions.filter(r=>!(r.companionSessionId&&f.has(r.companionSessionId))).filter(r=>$(r,h)):[],[e,h,f]),R=a.useMemo(()=>{const r=new Map;if(!e)return r;const x=e.sessions.filter(o=>!(o.companionSessionId&&f.has(o.companionSessionId)));for(const o of I)r.set(o.id,x.filter(j=>$(j,o.id)).length);return r},[e,f]),S=a.useMemo(()=>U(A),[A]);return t.jsx("div",{className:"h-full overflow-y-auto bg-cc-bg",children:t.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-6 space-y-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Project Dashboard"}),t.jsx("p",{className:"mt-0.5 text-xs text-cc-muted",children:e!=null&&e.runMeta?`Last updated ${w(e.runMeta.lastRunCompletedAt)} (${e.runMeta.trigger==="manual"?"manual":"nightly"} run, ${e.runMeta.model})`:"No summarization run yet"})]}),t.jsx("button",{type:"button",onClick:k,disabled:y||l||!(e!=null&&e.claudeCliAvailable),className:`px-3 py-2 min-h-[40px] rounded-lg text-sm font-medium transition-colors ${y||l||!(e!=null&&e.claudeCliAvailable)?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:y?"Updating...":"Update now"})]}),c&&t.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}),p&&t.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:p}),e&&!e.claudeCliAvailable&&t.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-warning/10 border border-cc-warning/20 text-xs text-cc-warning",children:"The Claude Code CLI was not found — the summarizer uses your Claude Code login to generate summaries, so the CLI must be installed on this machine."}),e&&e.claudeCliAvailable&&!e.enabled&&t.jsxs("div",{className:"px-3 py-2 rounded-lg bg-cc-primary/10 border border-cc-primary/20 text-xs text-cc-fg",children:['Nightly updates are off — summaries only refresh when you press "Update now".'," ",t.jsx("a",{href:"#/settings",className:"underline hover:no-underline",children:"Enable them in Settings"}),"."]}),((C=e==null?void 0:e.runMeta)==null?void 0:C.lastRunStatus)==="error"&&t.jsxs("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:["The last run failed",e.runMeta.lastRunError?`: ${e.runMeta.lastRunError}`:"."]}),y&&u&&t.jsx(_,{progress:u}),l?t.jsx("div",{className:"text-sm text-cc-muted py-12 text-center",children:"Loading dashboard..."}):!e||e.sessions.length===0?t.jsxs("div",{className:"rounded-xl border border-cc-border bg-cc-card p-8 text-center",children:[t.jsx("p",{className:"text-sm text-cc-fg font-medium",children:"No session summaries yet"}),t.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:'Press "Update now" to summarize your recent Claude Code sessions, or enable the nightly run in Settings to keep this dashboard fresh automatically.'})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",role:"group","aria-label":"Filter sessions",children:I.map(r=>{const x=h===r.id,o=R.get(r.id)??0;return t.jsxs("button",{type:"button",onClick:()=>d(r.id),"aria-pressed":x,className:`px-2.5 py-1.5 rounded-full text-xs font-medium transition-colors cursor-pointer ${x?"bg-cc-primary text-white":"bg-cc-hover hover:bg-cc-active text-cc-fg"}`,children:[r.label," ",t.jsx("span",{className:x?"opacity-80":"text-cc-muted",children:o})]},r.id)})}),S.length===0?t.jsx("div",{className:"text-sm text-cc-muted py-8 text-center",children:"No sessions match this filter."}):S.map(r=>t.jsxs("section",{"aria-label":`Project ${r.label}`,className:"rounded-xl border border-cc-border bg-cc-card p-4",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-3",children:[t.jsx("h2",{className:"text-sm font-semibold text-cc-fg truncate",title:r.key,children:r.label}),t.jsxs("span",{className:"text-[11px] text-cc-muted whitespace-nowrap",children:[r.sessions.length," session",r.sessions.length===1?"":"s"," · active ",w(r.lastActivityAt)]})]}),t.jsx("ul",{className:"space-y-2",children:r.sessions.map(x=>t.jsx(B,{session:x,onArchived:o=>M(j=>new Set(j).add(o))},x.sessionId))})]},r.key))]})]})})}export{z as DashboardPage};
|
|
1
|
+
import{r as a,a as N,j as t,t as w,e as T,n as P}from"./index-Daik8cew.js";const I=[{id:"all",label:"All"},{id:"unfinished",label:"Unfinished"},{id:"awaiting_user",label:"Needs input"},{id:"completed",label:"Completed"},{id:"archivable",label:"Archivable"}],D={completed:{label:"Completed",className:"bg-cc-success/10 text-cc-success border-cc-success/20",dotClassName:"bg-cc-success"},in_progress:{label:"In progress",className:"bg-cc-primary/10 text-cc-primary border-cc-primary/20",dotClassName:"bg-cc-primary"},awaiting_user:{label:"Needs input",className:"bg-cc-warning/10 text-cc-warning border-cc-warning/20",dotClassName:"bg-cc-warning"},stalled:{label:"Stalled",className:"bg-cc-error/10 text-cc-error border-cc-error/20",dotClassName:"bg-cc-error"}};function $(e,s){switch(s){case"all":return!0;case"unfinished":return e.status==="in_progress"||e.status==="stalled";case"awaiting_user":return e.status==="awaiting_user";case"completed":return e.status==="completed";case"archivable":return e.archivable&&!e.companionArchived}}function U(e){const s=new Map;for(const i of e){const c=i.cwd.replace(/\/+$/,"")||"/";let n=s.get(c);n||(n={key:c,label:T(c),sessions:[],lastActivityAt:0},s.set(c,n)),n.sessions.push(i),n.lastActivityAt=Math.max(n.lastActivityAt,i.lastActivityAt)}const l=Array.from(s.values()).sort((i,c)=>c.lastActivityAt-i.lastActivityAt);for(const i of l)i.sessions.sort((c,n)=>n.lastActivityAt-c.lastActivityAt);return l}function E(e){return e.displayName||e.slug||`Session ${e.sessionId.slice(0,8)}`}function L({status:e}){const s=D[e];return t.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full border text-[11px] font-medium whitespace-nowrap ${s.className}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${s.dotClassName}`,"aria-hidden":"true"}),s.label]})}function _({progress:e}){const s=e.total>0?Math.round(e.processed/e.total*100):0,l=e.total>0?`Summarizing session ${Math.min(e.processed+1,e.total)} of ${e.total}${e.currentSession?` — ${e.currentSession}`:""}`:"Scanning sessions...";return t.jsxs("div",{className:"rounded-xl border border-cc-border bg-cc-card p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm text-cc-fg",children:l}),e.total>0&&t.jsxs("span",{className:"text-xs text-cc-muted tabular-nums",children:[s,"%"]})]}),t.jsx("div",{role:"progressbar","aria-label":"Dashboard update progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e.total>0?s:void 0,className:"h-2 w-full rounded-full bg-cc-hover overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full bg-cc-primary transition-all duration-500 ${e.total===0?"animate-pulse w-1/4":""}`,style:e.total>0?{width:`${Math.max(s,3)}%`}:void 0})}),e.failed>0&&t.jsxs("p",{className:"mt-2 text-[11px] text-cc-warning",children:[e.failed," session",e.failed===1?"":"s"," failed so far"]})]})}function B({session:e,onArchived:s}){const[l,i]=a.useState(!1),[c,n]=a.useState(""),p=!!e.companionSessionId&&e.archivable&&!e.companionArchived,b=[e.userName?`by ${e.userName}`:null,e.gitBranch?e.gitBranch:null,`active ${w(e.lastActivityAt)}`].filter(Boolean);async function h(){if(e.companionSessionId){i(!0),n("");try{await N.archiveSession(e.companionSessionId,{linearTransition:"none"}),s(e.companionSessionId)}catch(d){n(d instanceof Error?d.message:String(d))}finally{i(!1)}}}return t.jsx("li",{className:"rounded-lg border border-cc-border bg-cc-bg p-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.companionSessionId&&!e.companionArchived?t.jsx("button",{type:"button",onClick:()=>P(e.companionSessionId),className:"text-sm font-medium text-cc-fg hover:text-cc-primary truncate cursor-pointer text-left",title:"Open session",children:E(e)}):t.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:E(e)}),t.jsx(L,{status:e.status}),e.companionArchived&&t.jsx("span",{className:"text-[11px] text-cc-muted border border-cc-border rounded-full px-2 py-0.5",children:"Archived"}),!e.companionSessionId&&t.jsx("span",{className:"text-[11px] text-cc-muted border border-cc-border rounded-full px-2 py-0.5",title:"Discovered from ~/.claude — not launched through the companion",children:"External"})]}),t.jsx("p",{className:"mt-1.5 text-sm text-cc-fg/90 leading-relaxed",children:e.summary}),e.openItems.length>0&&t.jsx("ul",{className:"mt-2 space-y-1",children:e.openItems.map(d=>t.jsxs("li",{className:"text-xs text-cc-muted flex items-start gap-1.5",children:[t.jsx("span",{className:"mt-1 w-1 h-1 rounded-full bg-cc-muted shrink-0","aria-hidden":"true"}),d]},d))}),t.jsx("p",{className:"mt-2 text-[11px] text-cc-muted",children:b.join(" · ")}),c&&t.jsx("p",{className:"mt-1 text-[11px] text-cc-error",children:c})]}),p&&t.jsx("button",{type:"button",onClick:h,disabled:l,className:`shrink-0 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors ${l?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:l?"Archiving...":"Archive"})]})})}function z(){var C;const[e,s]=a.useState(null),[l,i]=a.useState(!0),[c,n]=a.useState(""),[p,b]=a.useState(""),[h,d]=a.useState("all"),[u,g]=a.useState(null),[f,M]=a.useState(new Set),m=a.useRef(null),v=a.useCallback(async()=>{try{const r=await N.getDashboard();s(r),g(r.progress.state==="running"?r.progress:null),n("")}catch(r){n(r instanceof Error?r.message:String(r))}finally{i(!1)}},[]);a.useEffect(()=>{v()},[v]),a.useEffect(()=>{if(!u||u.state!=="running"){m.current&&(clearInterval(m.current),m.current=null);return}if(!m.current)return m.current=setInterval(async()=>{try{const r=await N.getDashboardRunStatus();r.progress.state==="running"?g(r.progress):(g(null),v())}catch{}},1500),()=>{m.current&&(clearInterval(m.current),m.current=null)}},[u,v]);async function k(){b("");try{await N.runDashboardUpdate(),g({state:"running",trigger:"manual",total:0,processed:0,failed:0})}catch(r){b(r instanceof Error?r.message:String(r))}}const y=(u==null?void 0:u.state)==="running",A=a.useMemo(()=>e?e.sessions.filter(r=>!(r.companionSessionId&&f.has(r.companionSessionId))).filter(r=>$(r,h)):[],[e,h,f]),R=a.useMemo(()=>{const r=new Map;if(!e)return r;const x=e.sessions.filter(o=>!(o.companionSessionId&&f.has(o.companionSessionId)));for(const o of I)r.set(o.id,x.filter(j=>$(j,o.id)).length);return r},[e,f]),S=a.useMemo(()=>U(A),[A]);return t.jsx("div",{className:"h-full overflow-y-auto bg-cc-bg",children:t.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-6 space-y-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Project Dashboard"}),t.jsx("p",{className:"mt-0.5 text-xs text-cc-muted",children:e!=null&&e.runMeta?`Last updated ${w(e.runMeta.lastRunCompletedAt)} (${e.runMeta.trigger==="manual"?"manual":"nightly"} run, ${e.runMeta.model})`:"No summarization run yet"})]}),t.jsx("button",{type:"button",onClick:k,disabled:y||l||!(e!=null&&e.claudeCliAvailable),className:`px-3 py-2 min-h-[40px] rounded-lg text-sm font-medium transition-colors ${y||l||!(e!=null&&e.claudeCliAvailable)?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:y?"Updating...":"Update now"})]}),c&&t.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}),p&&t.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:p}),e&&!e.claudeCliAvailable&&t.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-warning/10 border border-cc-warning/20 text-xs text-cc-warning",children:"The Claude Code CLI was not found — the summarizer uses your Claude Code login to generate summaries, so the CLI must be installed on this machine."}),e&&e.claudeCliAvailable&&!e.enabled&&t.jsxs("div",{className:"px-3 py-2 rounded-lg bg-cc-primary/10 border border-cc-primary/20 text-xs text-cc-fg",children:['Nightly updates are off — summaries only refresh when you press "Update now".'," ",t.jsx("a",{href:"#/settings",className:"underline hover:no-underline",children:"Enable them in Settings"}),"."]}),((C=e==null?void 0:e.runMeta)==null?void 0:C.lastRunStatus)==="error"&&t.jsxs("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:["The last run failed",e.runMeta.lastRunError?`: ${e.runMeta.lastRunError}`:"."]}),y&&u&&t.jsx(_,{progress:u}),l?t.jsx("div",{className:"text-sm text-cc-muted py-12 text-center",children:"Loading dashboard..."}):!e||e.sessions.length===0?t.jsxs("div",{className:"rounded-xl border border-cc-border bg-cc-card p-8 text-center",children:[t.jsx("p",{className:"text-sm text-cc-fg font-medium",children:"No session summaries yet"}),t.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:'Press "Update now" to summarize your recent Claude Code sessions, or enable the nightly run in Settings to keep this dashboard fresh automatically.'})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",role:"group","aria-label":"Filter sessions",children:I.map(r=>{const x=h===r.id,o=R.get(r.id)??0;return t.jsxs("button",{type:"button",onClick:()=>d(r.id),"aria-pressed":x,className:`px-2.5 py-1.5 rounded-full text-xs font-medium transition-colors cursor-pointer ${x?"bg-cc-primary text-white":"bg-cc-hover hover:bg-cc-active text-cc-fg"}`,children:[r.label," ",t.jsx("span",{className:x?"opacity-80":"text-cc-muted",children:o})]},r.id)})}),S.length===0?t.jsx("div",{className:"text-sm text-cc-muted py-8 text-center",children:"No sessions match this filter."}):S.map(r=>t.jsxs("section",{"aria-label":`Project ${r.label}`,className:"rounded-xl border border-cc-border bg-cc-card p-4",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-3",children:[t.jsx("h2",{className:"text-sm font-semibold text-cc-fg truncate",title:r.key,children:r.label}),t.jsxs("span",{className:"text-[11px] text-cc-muted whitespace-nowrap",children:[r.sessions.length," session",r.sessions.length===1?"":"s"," · active ",w(r.lastActivityAt)]})]}),t.jsx("ul",{className:"space-y-2",children:r.sessions.map(x=>t.jsx(B,{session:x,onArchived:o=>M(j=>new Set(j).add(o))},x.sessionId))})]},r.key))]})]})})}export{z as DashboardPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,a,j as e,u as N,n as y,b as _,L as h}from"./index-DOle27vf.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-Daik8cew.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};
|
package/dist/assets/{LinearOAuthSettingsPage-omExXsGc.js → LinearOAuthSettingsPage-SoGpGzIF.js}
RENAMED
|
@@ -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-DOle27vf.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-Daik8cew.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-DOle27vf.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-Daik8cew.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 v,n as me,b as xe,P as j,C as pe,A as J,M as f,T as w,G as M,L as Y,D as P,S as L,c as U,d as B,f as Q,h as X,k as ue,l as he,m as ge,U as be,o as fe,p as se,q as te,a as je,v as ve,w as _,x as we}from"./index-
|
|
1
|
+
import{r as u,j as e,u as v,n as me,b as xe,P as j,C as pe,A as J,M as f,T as w,G as M,L as Y,D as P,S as L,c as U,d as B,f as Q,h as X,k as ue,l as he,m as ge,U as be,o as fe,p as se,q as te,a as je,v as ve,w as _,x as we}from"./index-Daik8cew.js";const Ne=new Set(["pulling_image","running_init_script","building_image"]);function A({steps:t,error:c}){const[n,i]=u.useState({}),[r,x]=u.useState(new Set),l=u.useRef(new Map),h=u.useCallback(o=>m=>{m?l.current.set(o,m):l.current.delete(o)},[]);return u.useEffect(()=>{for(const o of t)o.detail&&Ne.has(o.step)&&(i(m=>{const a=m[o.step]||[];return a.length===0||a[a.length-1]!==o.detail?{...m,[o.step]:[...a,o.detail]}:m}),x(m=>{if(m.has(o.step))return m;const a=new Set(m);return a.add(o.step),a}))},[t]),u.useEffect(()=>{var o;for(const m of l.current.values())(o=m.scrollTo)==null||o.call(m,{top:m.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 m=n[o.step],a=m&&m.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:()=>x(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:m.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") {
|