@hellcoder/companion 0.119.0 → 0.120.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/assets/{AgentsPage-TD9AO1Er.js → AgentsPage-V7NBPNSh.js} +5 -5
  2. package/dist/assets/CronManager-CGfXlVZS.js +1 -0
  3. package/dist/assets/{DashboardPage-CQc0PLwb.js → DashboardPage-N7MWZiJQ.js} +1 -1
  4. package/dist/assets/{IntegrationsPage-ChVMH0yi.js → IntegrationsPage-DRP477b0.js} +1 -1
  5. package/dist/assets/{LinearOAuthSettingsPage-Bb7Tu4o3.js → LinearOAuthSettingsPage-CPW4TQuD.js} +1 -1
  6. package/dist/assets/{LinearSettingsPage-BxKEO7CY.js → LinearSettingsPage-BwVTEKqs.js} +1 -1
  7. package/dist/assets/{MagicUIDashboard-j4axrj9-.js → MagicUIDashboard-exuRY5LQ.js} +1 -1
  8. package/dist/assets/MagicUIView-AKoy6jOb.js +1 -0
  9. package/dist/assets/{Playground-DlNnNZL_.js → Playground-BiEa7THU.js} +6 -6
  10. package/dist/assets/{PromptsPage-C-VOgj-R.js → PromptsPage-BYtZdliB.js} +1 -1
  11. package/dist/assets/{RunsPage-Ce99iVIk.js → RunsPage-DD6KPNKm.js} +1 -1
  12. package/dist/assets/{SandboxManager-ZtcsgPxE.js → SandboxManager-C8tBjBXY.js} +1 -1
  13. package/dist/assets/SettingsPage-77tDzDuD.js +1 -0
  14. package/dist/assets/{TailscalePage-C61E10pR.js → TailscalePage-B0TbcOPL.js} +1 -1
  15. package/dist/assets/index-BM8QkiV8.js +140 -0
  16. package/dist/assets/index-CUfPwiv5.css +1 -0
  17. package/dist/assets/{sw-register-NM2AysKf.js → sw-register-Cr16zatT.js} +1 -1
  18. package/dist/index.html +2 -2
  19. package/dist/sw.js +1 -1
  20. package/package.json +1 -1
  21. package/server/codex-app-server.ts +61 -0
  22. package/server/codex-auth.test.ts +254 -0
  23. package/server/codex-auth.ts +315 -0
  24. package/server/codex-models.ts +2 -43
  25. package/server/protocol/codex-upstream/ClientRequest.ts.txt +62 -17
  26. package/server/protocol/codex-upstream/README.md +1 -1
  27. package/server/protocol/codex-upstream/ServerNotification.ts.txt +52 -4
  28. package/server/protocol/codex-upstream/ServerRequest.ts.txt +4 -1
  29. package/server/protocol/codex-upstream/v2/DynamicToolCallParams.ts.txt +1 -1
  30. package/server/routes/codex-auth-routes.test.ts +115 -0
  31. package/server/routes/codex-auth-routes.ts +49 -0
  32. package/server/routes.ts +2 -0
  33. package/dist/assets/CronManager-DQXJXJO2.js +0 -1
  34. package/dist/assets/MagicUIView-D6jNdxHM.js +0 -1
  35. package/dist/assets/SettingsPage-QEkLsk5w.js +0 -1
  36. package/dist/assets/index-CnVoJw43.js +0 -140
  37. package/dist/assets/index-DB85gIpd.css +0 -1
@@ -1 +1 @@
1
- import{r as a,a as N,j as t,t as w,e as T,n as P}from"./index-CnVoJw43.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-BM8QkiV8.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-CnVoJw43.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-BM8QkiV8.js";function L({embedded:d=!1}){const[g,p]=r.useState(!1),[b,v]=r.useState(""),[x,f]=r.useState(""),[s,m]=r.useState(null),[c,j]=r.useState([]),[o,w]=r.useState([]);r.useEffect(()=>{a.getTailscaleStatus().then(m).catch(()=>m({installed:!1,binaryPath:null,connected:!1,dnsName:null,funnelActive:!1,funnelUrl:null,error:"Could not reach Tailscale status endpoint"})),a.getSettings().then(t=>{if(t.linearApiKeyConfigured)return a.getLinearConnection().then(n=>{p(n.connected);const i=n.viewerName||n.viewerEmail||"Connected account",l=n.teamName?` • ${n.teamName}`:"";v(`${i}${l}`)})}).catch(t=>f(t instanceof Error?t.message:String(t))),a.listLinearOAuthConnections().then(t=>j(t.connections)).catch(()=>{}),a.listAgents().then(t=>{w(t.filter(n=>{var i,l;return(l=(i=n.triggers)==null?void 0:i.linear)==null?void 0:l.enabled}))}).catch(()=>{})},[]);const u=c.filter(t=>t.status==="connected").length;return e.jsx("div",{className:`${d?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Integrations"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Connect tools and open their dedicated settings page."})]}),!d&&e.jsx("button",{onClick:()=>{const t=N.getState().currentSessionId;t?y(t):_()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Back"})]}),x&&e.jsx("div",{className:"mb-4 px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:x}),e.jsxs("section",{className:"group relative overflow-hidden rounded-3xl border border-cc-border/80 bg-cc-card p-5 pb-16 sm:p-7 sm:pb-7 transition-all duration-300 hover:border-cc-primary/35 hover:shadow-[0_18px_44px_rgba(0,0,0,0.18)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(80%_140%_at_100%_0%,rgba(251,146,60,0.18),transparent_52%)]"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-30 bg-[linear-gradient(120deg,transparent_0%,rgba(255,255,255,0.04)_35%,transparent_62%)]"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cc-border bg-cc-hover/55 px-3 py-1.5 text-xs tracking-wide text-cc-muted",children:[e.jsx(h,{className:"h-3.5 w-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear Tickets"}),g&&e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-cc-success shadow-[0_0_0_3px_rgba(34,197,94,0.15)]","aria-label":"Connected",title:"Connected"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:e.jsx("h2",{className:"text-[clamp(1.45rem,2.6vw,2rem)] font-semibold leading-[1.12] tracking-tight text-cc-fg",children:"Issue context before first prompt"})}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-cc-muted sm:text-[15px]",children:"Connect your workspace, search an issue from Home, and inject scope automatically when a session starts."}),e.jsx("div",{className:"mt-4 inline-flex max-w-full items-center rounded-lg border border-cc-border/80 bg-black/10 px-3 py-1.5 text-xs text-cc-muted/95",children:e.jsx("span",{className:"truncate",children:b||"No workspace linked yet"})})]}),e.jsx("div",{className:"absolute bottom-0 right-0 sm:bottom-0 sm:right-0 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/integrations/linear"},"aria-label":"Open Linear Tickets settings",title:"Open Linear Tickets settings",className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-cc-primary/28 bg-cc-primary/12 text-cc-fg transition-colors hover:border-cc-primary/50 hover:bg-cc-primary/20 focus:outline-none focus:ring-2 focus:ring-cc-primary/35 cursor-pointer",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M9.67 4.53 10 2h4l.33 2.53a7.9 7.9 0 0 1 1.7.7l2.03-1.55 2.83 2.83-1.55 2.03c.28.54.51 1.1.7 1.7L22 10v4l-2.53.33a7.9 7.9 0 0 1-.7 1.7l1.55 2.03-2.83 2.83-2.03-1.55c-.54.28-1.1.51-1.7.7L14 22h-4l-.33-2.53a7.9 7.9 0 0 1-1.7-.7l-2.03 1.55-2.83-2.83 1.55-2.03a7.9 7.9 0 0 1-.7-1.7L2 14v-4l2.53-.33c.19-.6.42-1.16.7-1.7L3.68 5.94 6.5 3.1l2.03 1.55c.54-.28 1.1-.51 1.7-.7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.2"})]})})})]})]}),e.jsxs("section",{className:"group relative mt-6 overflow-hidden rounded-3xl border border-cc-border/80 bg-cc-card p-5 pb-16 sm:p-7 sm:pb-7 transition-all duration-300 hover:border-cc-primary/35 hover:shadow-[0_18px_44px_rgba(0,0,0,0.18)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(80%_140%_at_100%_0%,rgba(124,58,237,0.18),transparent_52%)]"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-30 bg-[linear-gradient(120deg,transparent_0%,rgba(255,255,255,0.04)_35%,transparent_62%)]"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cc-border bg-cc-hover/55 px-3 py-1.5 text-xs tracking-wide text-cc-muted",children:[e.jsx(h,{className:"h-3.5 w-3.5 text-cc-fg"}),e.jsx("span",{children:"Linear OAuth Apps"}),u>0&&e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-cc-success shadow-[0_0_0_3px_rgba(34,197,94,0.15)]","aria-label":"Connected",title:"Connected"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:e.jsx("h2",{className:"text-[clamp(1.45rem,2.6vw,2rem)] font-semibold leading-[1.12] tracking-tight text-cc-fg",children:"Agent triggers via Linear"})}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-cc-muted sm:text-[15px]",children:"Create OAuth apps to trigger agents from @mentions in Linear issues. Each app can connect to a different workspace."}),e.jsx("div",{className:"mt-4 inline-flex max-w-full items-center rounded-lg border border-cc-border/80 bg-black/10 px-3 py-1.5 text-xs text-cc-muted/95",children:e.jsxs("span",{className:"truncate",children:[c.length===0?"No OAuth apps configured":`${c.length} app${c.length!==1?"s":""}, ${u} connected`,o.length>0&&` · ${o.length} agent${o.length!==1?"s":""}`]})})]}),e.jsxs("div",{className:"absolute bottom-0 right-0 sm:bottom-0 sm:right-0 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{window.location.hash="#/agents?setup=linear"},"aria-label":"Set up Linear Agent",title:"Set up Linear Agent",className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-full border border-violet-500/28 bg-violet-500/12 text-xs font-medium text-cc-fg transition-colors hover:border-violet-500/50 hover:bg-violet-500/20 focus:outline-none focus:ring-2 focus:ring-violet-500/35 cursor-pointer",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 opacity-60","aria-hidden":"true",children:e.jsx("path",{d:"M8 1.5a2.5 2.5 0 00-2.5 2.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5S9.38 1.5 8 1.5zM4 8a4 4 0 00-4 4v1.5a.5.5 0 00.5.5h15a.5.5 0 00.5-.5V12a4 4 0 00-4-4H4z"})}),"Setup Agent"]}),e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/integrations/linear-oauth"},"aria-label":"Open Linear OAuth settings",title:"Open Linear OAuth settings",className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-violet-500/28 bg-violet-500/12 text-cc-fg transition-colors hover:border-violet-500/50 hover:bg-violet-500/20 focus:outline-none focus:ring-2 focus:ring-violet-500/35 cursor-pointer",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M9.67 4.53 10 2h4l.33 2.53a7.9 7.9 0 0 1 1.7.7l2.03-1.55 2.83 2.83-1.55 2.03c.28.54.51 1.1.7 1.7L22 10v4l-2.53.33a7.9 7.9 0 0 1-.7 1.7l1.55 2.03-2.83 2.83-2.03-1.55c-.54.28-1.1.51-1.7.7L14 22h-4l-.33-2.53a7.9 7.9 0 0 1-1.7-.7l-2.03 1.55-2.83-2.83 1.55-2.03a7.9 7.9 0 0 1-.7-1.7L2 14v-4l2.53-.33c.19-.6.42-1.16.7-1.7L3.68 5.94 6.5 3.1l2.03 1.55c.54-.28 1.1-.51 1.7-.7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.2"})]})})]})]})]}),e.jsxs("section",{className:"group relative mt-6 overflow-hidden rounded-3xl border border-cc-border/80 bg-cc-card p-5 pb-16 sm:p-7 sm:pb-7 transition-all duration-300 hover:border-cc-primary/35 hover:shadow-[0_18px_44px_rgba(0,0,0,0.18)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(80%_140%_at_100%_0%,rgba(6,182,212,0.18),transparent_52%)]"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-30 bg-[linear-gradient(120deg,transparent_0%,rgba(255,255,255,0.04)_35%,transparent_62%)]"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cc-border bg-cc-hover/55 px-3 py-1.5 text-xs tracking-wide text-cc-muted",children:[e.jsx("svg",{className:"h-3.5 w-3.5 text-cc-fg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),e.jsx("span",{children:"Tailscale"}),(s==null?void 0:s.funnelActive)&&e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-cc-success shadow-[0_0_0_3px_rgba(34,197,94,0.15)]","aria-label":"Funnel active",title:"Funnel active"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:e.jsx("h2",{className:"text-[clamp(1.45rem,2.6vw,2rem)] font-semibold leading-[1.12] tracking-tight text-cc-fg",children:"HTTPS access in one click"})}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-cc-muted sm:text-[15px]",children:"Use Tailscale Funnel to expose your Companion over HTTPS with automatic TLS certificates."}),e.jsx("div",{className:"mt-4 inline-flex max-w-full items-center rounded-lg border border-cc-border/80 bg-black/10 px-3 py-1.5 text-xs text-cc-muted/95",children:e.jsx("span",{className:"truncate",children:s===null?"Checking...":s.funnelActive&&s.funnelUrl?s.funnelUrl:s.connected?s.dnsName||"Connected":s.installed?"Not connected":"Not installed"})})]}),e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/integrations/tailscale"},"aria-label":"Open Tailscale settings",title:"Open Tailscale settings",className:"absolute bottom-0 right-0 sm:bottom-0 sm:right-0 inline-flex h-10 w-10 items-center justify-center rounded-full border border-cc-primary/28 bg-cc-primary/12 text-cc-fg transition-colors hover:border-cc-primary/50 hover:bg-cc-primary/20 focus:outline-none focus:ring-2 focus:ring-cc-primary/35 cursor-pointer",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4.5 w-4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M9.67 4.53 10 2h4l.33 2.53a7.9 7.9 0 0 1 1.7.7l2.03-1.55 2.83 2.83-1.55 2.03c.28.54.51 1.1.7 1.7L22 10v4l-2.53.33a7.9 7.9 0 0 1-.7 1.7l1.55 2.03-2.83 2.83-2.03-1.55c-.54.28-1.1.51-1.7.7L14 22h-4l-.33-2.53a7.9 7.9 0 0 1-1.7-.7l-2.03 1.55-2.83-2.83 1.55-2.03a7.9 7.9 0 0 1-.7-1.7L2 14v-4l2.53-.33c.19-.6.42-1.16.7-1.7L3.68 5.94 6.5 3.1l2.03 1.55c.54-.28 1.1-.51 1.7-.7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.2"})]})})]})]})]})})}export{L as IntegrationsPage};
@@ -1 +1 @@
1
- import{r,a as i,j as e,u as X,n as Y,b as Z,L as M}from"./index-CnVoJw43.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-BM8QkiV8.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-CnVoJw43.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-BM8QkiV8.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{N as C,O as D,r,u as m,Q as P,j as O}from"./index-CnVoJw43.js";const A=`/* MagicUI iframe runtime.
1
+ import{O as C,Q as D,r,u as m,R as P,j as O}from"./index-BM8QkiV8.js";const A=`/* MagicUI iframe runtime.
2
2
  *
3
3
  * Plain dependency-free JS (Chart.js UMD is inlined separately by the host).
4
4
  * Runs inside a sandboxed, opaque-origin iframe with a no-network CSP.
@@ -0,0 +1 @@
1
+ import{u as l,r as s,c as k,j as r,D as M,M as R,P as _,d as C}from"./index-BM8QkiV8.js";import{d as P,t as D,M as E}from"./MagicUIDashboard-exuRY5LQ.js";const N=4e3;function A({sessionId:t}){const u=l(e=>e.pendingPermissions.get(t)),h=l(e=>e.removePermission),m=l(e=>e.connectionStatus.get(t)??"disconnected"),x=l(e=>e.cliConnected.get(t)??!1),i=s.useMemo(()=>u?Array.from(u.values()):[],[u]),[a,g]=s.useState(new Set),f=s.useRef(new Set),c=s.useRef(new Map);s.useEffect(()=>{for(const e of i){const n=e.request_id;f.current.has(n)||a.has(n)||c.current.has(n)||c.current.set(n,setTimeout(()=>{c.current.delete(n),f.current.has(n)||g(o=>new Set(o).add(n))},N))}for(const[e,n]of c.current)i.some(o=>o.request_id===e)||(clearTimeout(n),c.current.delete(e))},[i,a]),s.useEffect(()=>()=>{for(const e of c.current.values())clearTimeout(e);c.current.clear()},[]);const b=s.useCallback(e=>{f.current.add(e);const n=c.current.get(e);n&&(clearTimeout(n),c.current.delete(e))},[]),v=s.useCallback((e,n)=>{var d;const o=(d=l.getState().pendingPermissions.get(t))==null?void 0:d.get(e);o&&(k(t,P(o,n)),h(t,e))},[t,h]),w=s.useCallback(()=>{g(e=>{var o;const n=new Set(e);for(const d of((o=l.getState().pendingPermissions.get(t))==null?void 0:o.values())??[])n.add(d.request_id);return n})},[t]),j=s.useMemo(()=>i.filter(e=>!a.has(e.request_id)).map(D),[i,a]),p=s.useMemo(()=>i.filter(e=>a.has(e.request_id)),[i,a]),S=m==="connected"&&!x;return r.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[(S||m==="disconnected")&&r.jsxs("div",{className:"px-4 py-1.5 bg-gradient-to-r from-cc-warning/8 to-cc-warning/4 border-b border-cc-warning/15 flex items-center justify-center gap-2",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cc-warning animate-[pulse-dot_1.5s_ease-in-out_infinite] shrink-0"}),r.jsx("span",{className:"text-xs text-cc-warning font-medium",children:m==="disconnected"?"Reconnecting to session…":"CLI disconnected — switch to Standard view to reconnect"})]}),r.jsx("div",{className:"h-36 shrink-0 border-b border-cc-border relative overflow-hidden","aria-label":"Raw session output",children:r.jsx(M,{value:"compact",children:r.jsx(R,{sessionId:t})})}),r.jsx("div",{className:"flex-1 min-h-0 relative bg-cc-bg",children:r.jsx(E,{sessionId:t,decisions:j,onDecisionAck:b,onDecisionResponse:v,onRuntimeError:w})}),p.length>0&&r.jsx("div",{className:"shrink-0 max-h-[50dvh] overflow-y-auto border-t border-cc-border bg-cc-card",children:p.map(e=>r.jsx(_,{permission:e,sessionId:t},e.request_id))}),r.jsx(C,{sessionId:t})]})}export{A as MagicUIView};