@hellcoder/companion 0.108.1-preview.20260719080019.e8c410a → 0.109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentsPage-DI5hdCnz.js → AgentsPage-Dye7KBqi.js} +1 -1
- package/dist/assets/{CronManager-yX8i4C_S.js → CronManager-DTlT02dA.js} +1 -1
- package/dist/assets/{DashboardPage-D1nc0wHf.js → DashboardPage-fvKg3Yqp.js} +1 -1
- package/dist/assets/{IntegrationsPage-iSfvR9vX.js → IntegrationsPage-F68cGNc0.js} +1 -1
- package/dist/assets/{LinearOAuthSettingsPage-omExXsGc.js → LinearOAuthSettingsPage-SoGpGzIF.js} +1 -1
- package/dist/assets/{LinearSettingsPage-C4oBf1iO.js → LinearSettingsPage-CPvMIKgr.js} +1 -1
- package/dist/assets/{Playground-CjiZI9QY.js → Playground-CF7prjX2.js} +1 -1
- package/dist/assets/{PromptsPage-CU6z49U6.js → PromptsPage-vx71p6l9.js} +1 -1
- package/dist/assets/{RunsPage-mcU7OUoZ.js → RunsPage-CH4PZDnZ.js} +1 -1
- package/dist/assets/{SandboxManager-BkYS-dK5.js → SandboxManager-YH5E0Jto.js} +1 -1
- package/dist/assets/{SettingsPage-CyHMmTBB.js → SettingsPage-B2dQwyjl.js} +1 -1
- package/dist/assets/{TailscalePage-CRyiyMcJ.js → TailscalePage-OvQqy343.js} +1 -1
- package/dist/assets/index-Daik8cew.js +136 -0
- package/dist/assets/{sw-register-Dqdfho7x.js → sw-register-CcXhHDAn.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/server/settings-manager.test.ts +3 -1
- package/server/settings-manager.ts +2 -2
- package/dist/assets/index-DOle27vf.js +0 -136
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as o,u as X,a as Z,j as e,n as ne,b as ae,F as Y}from"./index-
|
|
1
|
+
import{r as o,u as X,a as Z,j as e,n as ne,b as ae,F as Y}from"./index-Daik8cew.js";function me({embedded:r=!1}){const[a,i]=o.useState([]),[b,h]=o.useState(!0),[l,f]=o.useState(!1),[j,d]=o.useState(""),[v,P]=o.useState(""),[y,E]=o.useState(""),[u,N]=o.useState("global"),[p,w]=o.useState([]),[A,F]=o.useState(!1),[g,$]=o.useState(null),[D,S]=o.useState(""),[G,C]=o.useState(""),[L,k]=o.useState("global"),[M,m]=o.useState([]),[se,H]=o.useState(!1),[z,re]=o.useState(""),[B,q]=o.useState(!1),U=X(t=>t.currentSessionId),x=X(t=>{var s,c;return t.currentSessionId&&(((s=t.sessions.get(t.currentSessionId))==null?void 0:s.cwd)||((c=t.sdkSessions.find(n=>n.sessionId===t.currentSessionId))==null?void 0:c.cwd))||""}),I=o.useMemo(()=>{const t=z.trim().toLowerCase();return t?a.filter(s=>`${s.name}
|
|
2
2
|
${s.content}
|
|
3
3
|
${s.scope}`.toLowerCase().includes(t)):a},[a,z]),V=a.length,J=I.length,T=o.useMemo(()=>{const t=I.filter(n=>n.scope==="global"),s=I.filter(n=>n.scope==="project"),c=new Map;for(const n of s){const _=n.projectPaths??(n.projectPath?[n.projectPath]:[]),W=_.length>0?_.slice().sort().join(`
|
|
4
4
|
`):"(no folder)",oe=_.length>0?_.map(Q=>Q.split("/").pop()||Q).join(", "):"(no folder)";c.has(W)||c.set(W,{label:oe,prompts:[]}),c.get(W).prompts.push(n)}return{globalPrompts:t,folderGroups:c}},[I]),R=o.useCallback(async()=>{h(!0),d("");try{const t=await Z.listPrompts();i(t)}catch(t){d(t instanceof Error?t.message:String(t))}finally{h(!1)}},[]);o.useEffect(()=>{R()},[R]);async function ce(t){if(t.preventDefault(),!(!v.trim()||!y.trim())){if(u==="project"&&p.length===0){d("Select at least one project folder");return}f(!0),d("");try{await Z.createPrompt({name:v.trim(),content:y.trim(),scope:u,projectPaths:u==="project"?p:void 0}),P(""),E(""),N("global"),w([]),q(!1),await R()}catch(s){d(s instanceof Error?s.message:String(s))}finally{f(!1)}}}async function K(t){try{await Z.deletePrompt(t),await R()}catch(s){d(s instanceof Error?s.message:String(s))}}async function O(){if(!(!g||!D.trim()||!G.trim())){if(L==="project"&&M.length===0){d("Select at least one project folder");return}try{await Z.updatePrompt(g,{name:D.trim(),content:G.trim(),scope:L,projectPaths:L==="project"?M:void 0}),$(null),S(""),C(""),k("global"),m([]),await R()}catch(t){d(t instanceof Error?t.message:String(t))}}}return e.jsxs("div",{className:`${r?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:[e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Saved Prompts"}),e.jsxs("p",{className:"mt-0.5 text-[13px] text-cc-muted leading-relaxed",children:["Create reusable prompts — insert with ",e.jsx("code",{className:"text-cc-fg text-xs bg-cc-hover rounded px-1 py-0.5",children:"@title"})," in the composer."]})]}),!r&&e.jsx("button",{onClick:()=>{U?ne(U):ae()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer shrink-0",children:"Back"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 mb-5",children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-cc-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.35-4.35"})]}),e.jsx("input",{value:z,onChange:t=>re(t.target.value),placeholder:"Search by title or content...",className:"w-full pl-9 pr-3 py-2.5 min-h-[44px] text-sm bg-cc-card rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]}),e.jsxs("button",{onClick:()=>q(!B),className:`flex items-center gap-1.5 px-3.5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer shrink-0 ${B?"bg-cc-active text-cc-fg":"bg-cc-primary hover:bg-cc-primary-hover text-white"}`,children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:B?e.jsx("path",{d:"M18 6 6 18M6 6l12 12"}):e.jsx("path",{d:"M12 5v14M5 12h14"})}),e.jsx("span",{className:"hidden sm:inline",children:B?"Cancel":"New Prompt"})]})]}),B&&e.jsx("form",{onSubmit:ce,className:"mb-6",style:{animation:"fadeSlideIn 150ms ease-out"},children:e.jsx(te,{mode:"create",name:v,content:y,scope:u,folders:p,error:j,saving:l,submitLabel:l?"Saving...":"Create Prompt",onNameChange:P,onContentChange:E,onScopeChange:t=>{N(t),t==="project"&&p.length===0&&x&&w([x])},onRemoveFolder:t=>w(s=>s.filter(c=>c!==t)),onAddFolder:()=>F(!0)})}),e.jsx("div",{className:"flex items-center gap-2 mb-3 text-[12px] text-cc-muted",children:e.jsx("span",{children:J===V?`${V} prompt${V!==1?"s":""}`:`${J} of ${V}`})}),b?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"Loading prompts..."}):a.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"No prompts yet."}):I.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"No prompts match your search."}):e.jsxs("div",{className:"space-y-4",children:[T.globalPrompts.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-[11px] uppercase tracking-wider text-cc-muted font-semibold mb-1.5 px-1",children:"Global"}),e.jsx("div",{className:"space-y-1",children:T.globalPrompts.map(t=>e.jsx(ee,{prompt:t,isEditing:g===t.id,error:j,editName:D,editContent:G,editScope:L,editFolders:M,cwd:x,onEditNameChange:S,onEditContentChange:C,onEditScopeChange:s=>{k(s),s==="project"&&M.length===0&&x&&m([x])},onEditRemoveFolder:s=>m(c=>c.filter(n=>n!==s)),onEditAddFolder:()=>H(!0),onStartEdit:()=>{$(t.id),S(t.name),C(t.content),k(t.scope),m(t.projectPaths??(t.projectPath?[t.projectPath]:[]))},onCancelEdit:()=>{$(null),S(""),C(""),k("global"),m([])},onSaveEdit:()=>void O(),onDelete:()=>void K(t.id)},t.id))})]}),Array.from(T.folderGroups.entries()).map(([t,s])=>e.jsxs("div",{children:[e.jsx("h2",{className:"text-[11px] uppercase tracking-wider text-cc-muted font-semibold mb-1.5 px-1",children:s.label}),e.jsx("div",{className:"space-y-1",children:s.prompts.map(c=>e.jsx(ee,{prompt:c,isEditing:g===c.id,error:j,editName:D,editContent:G,editScope:L,editFolders:M,cwd:x,onEditNameChange:S,onEditContentChange:C,onEditScopeChange:n=>{k(n),n==="project"&&M.length===0&&x&&m([x])},onEditRemoveFolder:n=>m(_=>_.filter(W=>W!==n)),onEditAddFolder:()=>H(!0),onStartEdit:()=>{$(c.id),S(c.name),C(c.content),k(c.scope),m(c.projectPaths??(c.projectPath?[c.projectPath]:[]))},onCancelEdit:()=>{$(null),S(""),C(""),k("global"),m([])},onSaveEdit:()=>void O(),onDelete:()=>void K(c.id)},c.id))})]},t))]})]}),A&&e.jsx(Y,{initialPath:x||"/",onSelect:t=>{w(s=>s.includes(t)?s:[...s,t]),F(!1)},onClose:()=>F(!1)}),se&&e.jsx(Y,{initialPath:x||"/",onSelect:t=>{m(s=>s.includes(t)?s:[...s,t]),H(!1)},onClose:()=>H(!1)})]})}function ie({scope:r,onScopeChange:a,folders:i,onRemoveFolder:b,onAddFolder:h}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium uppercase tracking-[0.24em] text-cc-muted",children:"Scope"}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted/80",children:"Choose whether this prompt should be available everywhere or only inside specific repos."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button","aria-pressed":r==="global",onClick:()=>a("global"),className:`inline-flex min-h-[40px] items-center rounded-full border px-4 py-2 text-sm transition-colors cursor-pointer ${r==="global"?"border-cc-primary/40 text-cc-primary bg-cc-primary/10 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)]":"border-cc-border text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:"Global"}),e.jsx("button",{type:"button","aria-pressed":r==="project",onClick:()=>a("project"),className:`inline-flex min-h-[40px] items-center rounded-full border px-4 py-2 text-sm transition-colors cursor-pointer ${r==="project"?"border-cc-primary/40 text-cc-primary bg-cc-primary/10 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)]":"border-cc-border text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:"Project folders"})]}),r==="project"&&e.jsxs("div",{className:"rounded-2xl border border-cc-border/70 bg-cc-bg/60 p-3 space-y-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-cc-fg",children:"Project folders"}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted",children:"Prompts scoped to folders only appear when the active session is inside one of those paths."})]})}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(l=>e.jsxs("span",{className:"inline-flex min-h-[32px] items-center gap-1.5 rounded-full border border-cc-border/80 bg-cc-hover px-3 py-1.5 text-xs font-mono-code text-cc-fg",children:[e.jsx("span",{className:"truncate max-w-[200px]",title:l,children:l.split("/").pop()||l}),e.jsx("button",{type:"button",onClick:()=>b(l),className:"text-cc-muted hover:text-cc-error cursor-pointer shrink-0","aria-label":`Remove folder ${l}`,children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]},l))}),e.jsxs("button",{type:"button",onClick:h,className:"inline-flex min-h-[40px] items-center gap-1.5 rounded-full border border-dashed border-cc-border px-3 py-2 text-sm text-cc-muted transition-colors cursor-pointer hover:text-cc-fg hover:bg-cc-hover",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3 h-3",children:e.jsx("path",{d:"M8 3v10M3 8h10",strokeLinecap:"round"})}),"Add folder"]})]})]})}function te({mode:r,name:a,content:i,scope:b,folders:h,saving:l=!1,error:f,submitLabel:j,cancelLabel:d="Cancel",onNameChange:v,onContentChange:P,onScopeChange:y,onRemoveFolder:E,onAddFolder:u,onSubmit:N,onCancel:p}){const w=!!(a.trim()&&i.trim()),A=i.split(/\r?\n/).length,F=i.length;return e.jsxs("section",{className:"overflow-hidden rounded-[28px] border border-cc-border/70 bg-cc-card shadow-[0_20px_60px_rgba(0,0,0,0.22)]",children:[e.jsx("div",{className:"border-b border-cc-border/60 bg-[linear-gradient(135deg,rgba(255,255,255,0.04),rgba(255,255,255,0))] px-5 py-4 sm:px-6",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.28em] text-cc-primary/80",children:r==="create"?"Prompt Studio":"Edit Prompt"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-cc-fg",children:r==="create"?"Write with room to think":"Refine this saved prompt"}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-cc-muted",children:"Structure the title, scope, and body separately so longer instructions stay easy to review before saving."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-cc-muted",children:[e.jsxs("span",{className:"inline-flex min-h-[32px] items-center rounded-full border border-cc-border/70 bg-cc-bg/60 px-3",children:[A," line",A>1?"s":""]}),e.jsxs("span",{className:"inline-flex min-h-[32px] items-center rounded-full border border-cc-border/70 bg-cc-bg/60 px-3",children:[F," char",F>1?"s":""]})]})]})}),e.jsxs("div",{className:"grid gap-0 lg:grid-cols-[minmax(280px,340px)_minmax(0,1fr)]",children:[e.jsx("div",{className:"border-b border-cc-border/60 p-5 sm:p-6 lg:border-b-0 lg:border-r",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium uppercase tracking-[0.24em] text-cc-muted",htmlFor:r==="create"?"prompt-name":void 0,children:"Title"}),e.jsx("input",{id:r==="create"?"prompt-name":void 0,type:"text",value:a,onChange:g=>v(g.target.value),placeholder:"review-pr",className:"w-full rounded-2xl border border-cc-border/70 bg-cc-bg px-4 py-3 text-sm text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsxs("p",{className:"mt-2 text-xs leading-relaxed text-cc-muted",children:["Use a short handle that is easy to insert with ",e.jsx("code",{className:"rounded bg-cc-hover px-1 py-0.5 text-[11px] text-cc-fg",children:"@title"}),"."]})]}),e.jsx(ie,{scope:b,onScopeChange:y,folders:h,onRemoveFolder:E,onAddFolder:u}),e.jsxs("div",{className:"rounded-2xl border border-dashed border-cc-border/70 bg-cc-bg/40 p-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.24em] text-cc-muted",children:"Storage"}),e.jsxs("p",{className:"mt-2 text-sm leading-relaxed text-cc-muted",children:["Saved in ",e.jsx("code",{className:"text-[11px] text-cc-fg",children:"~/.companion/prompts.json"})," and available from the composer autocomplete."]})]})]})}),e.jsx("div",{className:"p-5 sm:p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium uppercase tracking-[0.24em] text-cc-muted",htmlFor:r==="create"?"prompt-content":void 0,children:"Content"}),e.jsx("p",{className:"text-sm text-cc-muted",children:"Longer prompts stay readable here. Leave breathing room for detailed review flows, checklists, or operating instructions."})]})}),e.jsx("textarea",{id:r==="create"?"prompt-content":void 0,value:i,onChange:g=>P(g.target.value),placeholder:"Review this PR and summarize risks, regressions, and missing tests.",rows:r==="create"?14:10,className:"min-h-[320px] w-full resize-y rounded-[24px] border border-cc-border/70 bg-cc-bg px-4 py-4 text-sm leading-7 text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow lg:min-h-[420px]"}),f&&e.jsx("div",{className:"rounded-2xl border border-cc-error/20 bg-cc-error/10 px-4 py-3 text-sm text-cc-error",children:f}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-cc-border/60 pt-4",children:[p&&e.jsx("button",{type:"button",onClick:p,className:"min-h-[44px] rounded-full px-4 py-2.5 text-sm text-cc-muted transition-colors cursor-pointer hover:bg-cc-hover hover:text-cc-fg",children:d}),e.jsx("button",{type:N?"button":"submit",onClick:N,disabled:l||!w,className:`min-h-[44px] rounded-full px-5 py-2.5 text-sm font-medium transition-colors ${l||!w?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary text-white cursor-pointer hover:bg-cc-primary-hover"}`,children:j})]})]})})]})]})}function le({prompt:r}){if(r.scope==="global")return e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-cc-muted opacity-60",children:"global"});const a=r.projectPaths??(r.projectPath?[r.projectPath]:[]);return a.length===0?null:e.jsx("span",{className:"inline-flex items-center gap-1 flex-wrap",children:a.map(i=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-cc-primary/8 text-cc-primary/70 font-mono-code",title:i,children:i.split("/").pop()||i},i))})}function ee({prompt:r,isEditing:a,error:i,editName:b,editContent:h,editScope:l,editFolders:f,onEditNameChange:j,onEditContentChange:d,onEditScopeChange:v,onEditRemoveFolder:P,onEditAddFolder:y,onStartEdit:E,onCancelEdit:u,onSaveEdit:N,onDelete:p}){return a?e.jsx("div",{className:"rounded-2xl",style:{animation:"fadeSlideIn 150ms ease-out"},children:e.jsx(te,{mode:"edit",name:b,content:h,scope:l,folders:f,error:i,submitLabel:"Save",onNameChange:j,onContentChange:d,onScopeChange:v,onRemoveFolder:P,onAddFolder:y,onCancel:u,onSubmit:N})}):e.jsxs("div",{className:"group flex items-start gap-3 px-3 py-3 min-h-[44px] rounded-lg hover:bg-cc-hover/60 transition-colors",children:[e.jsx("div",{className:"shrink-0 mt-0.5 w-7 h-7 rounded-md bg-cc-primary/10 flex items-center justify-center",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5 text-cc-primary",children:e.jsx("path",{d:"M7 8h10M7 12h6M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H8l-4 4V5Z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:r.name}),e.jsx(le,{prompt:r})]}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted line-clamp-2 leading-relaxed",children:r.content})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:E,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-active transition-colors cursor-pointer","aria-label":"Edit",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5Z"})]})}),e.jsx("button",{onClick:p,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-error hover:bg-cc-error/10 transition-colors cursor-pointer","aria-label":"Delete",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14Z"})})})]})]})}export{me as PromptsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,a as N,j as e,t as I}from"./index-
|
|
1
|
+
import{r,a as N,j as e,t as I}from"./index-Daik8cew.js";function g(c){switch(c){case"manual":return"Manual";case"webhook":return"Webhook";case"schedule":return"Schedule";case"linear":return"Linear";default:return c}}function v(c){switch(c){case"manual":return"bg-blue-500/10 text-blue-600 dark:text-blue-400";case"webhook":return"bg-purple-500/10 text-purple-600 dark:text-purple-400";case"schedule":return"bg-amber-500/10 text-amber-600 dark:text-amber-400";case"linear":return"bg-violet-500/10 text-violet-600 dark:text-violet-400";default:return"bg-cc-hover text-cc-muted"}}function E(c){return c.error?{label:"Error",color:"text-cc-error"}:c.success?{label:"Success",color:"text-cc-success"}:c.completedAt?{label:"Unknown",color:"text-cc-muted"}:{label:"Running",color:"text-cc-warning"}}function y(c,x){const l=(x||Date.now())-c;if(l<1e3)return"<1s";if(l<6e4)return`${Math.round(l/1e3)}s`;const u=Math.floor(l/6e4),h=Math.round(l%6e4/1e3);return`${u}m ${h}s`}function T(){const[c,x]=r.useState([]),[m,l]=r.useState([]),[u,h]=r.useState(0),[k,w]=r.useState(!0),[n,A]=r.useState("all"),[i,S]=r.useState("all"),[o,C]=r.useState(""),[s,f]=r.useState(null),p=r.useCallback(async()=>{try{const t={limit:100};n!=="all"&&(t.triggerType=n),i!=="all"&&(t.status=i),o&&(t.agentId=o);const a=await N.listExecutions(t);x(a.executions),h(a.total)}catch(t){console.error("[runs] Failed to fetch executions:",t)}finally{w(!1)}},[n,i,o]),b=r.useCallback(async()=>{try{const t=await N.listAgents();l(t)}catch(t){console.error("[runs] Failed to fetch agents:",t)}},[]);r.useEffect(()=>{b()},[b]),r.useEffect(()=>{p();const t=setInterval(p,5e3);return()=>clearInterval(t)},[p]);const j=t=>{const a=m.find(d=>d.id===t);return(a==null?void 0:a.name)||t};return e.jsxs("div",{className:"h-full flex flex-col bg-cc-bg",children:[e.jsxs("div",{className:"shrink-0 border-b border-cc-border px-6 py-4",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Runs"}),e.jsx("p",{className:"text-sm text-cc-muted mt-1",children:"Monitor agent executions across all triggers"})]}),e.jsxs("div",{className:"shrink-0 border-b border-cc-border px-6 py-3 flex items-center gap-4 flex-wrap",children:[e.jsxs("select",{value:o,onChange:t=>C(t.target.value),className:"text-sm rounded-md border border-cc-border bg-cc-input-bg text-cc-fg px-2 py-1","aria-label":"Filter by agent",children:[e.jsx("option",{value:"",children:"All agents"}),m.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx("div",{className:"flex items-center gap-1",children:["all","manual","webhook","schedule","linear"].map(t=>e.jsx("button",{onClick:()=>A(t),className:`text-xs px-2.5 py-1 rounded-full transition-colors ${n===t?"bg-cc-fg text-cc-bg":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="all"?"All triggers":g(t)},t))}),e.jsx("div",{className:"flex items-center gap-1",children:["all","running","success","error"].map(t=>e.jsx("button",{onClick:()=>S(t),className:`text-xs px-2.5 py-1 rounded-full transition-colors ${i===t?"bg-cc-fg text-cc-bg":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="all"?"All statuses":t.charAt(0).toUpperCase()+t.slice(1)},t))}),e.jsxs("span",{className:"text-xs text-cc-muted ml-auto",children:[u," total"]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:k?e.jsx("div",{className:"text-sm text-cc-muted text-center py-12",children:"Loading..."}):c.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"mb-3 flex justify-center text-cc-muted",children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-8 h-8",children:e.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5a.75.75 0 011.5 0v3.19l2.03 2.03a.75.75 0 01-1.06 1.06l-2.25-2.25A.75.75 0 017.25 8V4.5z"})})}),e.jsx("p",{className:"text-sm text-cc-muted",children:"No executions found"}),e.jsx("p",{className:"text-xs text-cc-muted mt-1",children:"Run an agent to see executions here"})]}):e.jsxs("table",{className:"w-full text-sm",role:"table",children:[e.jsx("thead",{className:"sticky top-0 bg-cc-card backdrop-blur",children:e.jsxs("tr",{className:"text-left text-xs text-cc-muted uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Agent"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Trigger"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Started"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Duration"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Session"})]})}),e.jsx("tbody",{className:"divide-y divide-cc-border/50",children:c.map(t=>{const a=E(t),d=(s==null?void 0:s.sessionId)===t.sessionId;return e.jsxs("tr",{onClick:()=>f(d?null:t),className:`cursor-pointer transition-colors ${d?"bg-cc-active":"hover:bg-cc-hover"}`,children:[e.jsx("td",{className:"px-6 py-3",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-cc-fg font-medium",children:j(t.agentId)})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${v(t.triggerType)}`,children:g(t.triggerType)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`font-medium ${a.color}`,children:[!t.completedAt&&!t.error&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-cc-warning mr-1.5 animate-pulse"}),a.label]})}),e.jsx("td",{className:"px-4 py-3 text-cc-muted",children:I(t.startedAt)}),e.jsx("td",{className:"px-4 py-3 text-cc-muted font-mono text-xs",children:y(t.startedAt,t.completedAt)}),e.jsx("td",{className:"px-4 py-3",children:t.sessionId&&e.jsx("a",{href:`#/session/${t.sessionId}`,onClick:$=>$.stopPropagation(),className:"text-cc-primary hover:text-cc-primary-hover text-xs font-mono underline",children:"Open"})})]},`${t.sessionId}-${t.startedAt}`)})})]})}),s&&e.jsxs("div",{className:"shrink-0 border-t border-cc-border bg-cc-card px-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg",children:"Execution Details"}),e.jsx("button",{onClick:()=>f(null),className:"text-cc-muted hover:text-cc-fg text-sm transition-colors","aria-label":"Close details",children:"Close"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Agent"}),e.jsx("p",{className:"text-cc-fg font-medium",children:j(s.agentId)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Trigger"}),e.jsx("p",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${v(s.triggerType)}`,children:g(s.triggerType)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Started"}),e.jsx("p",{className:"text-cc-fg",children:new Date(s.startedAt).toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Duration"}),e.jsx("p",{className:"text-cc-fg font-mono",children:y(s.startedAt,s.completedAt)})]})]}),s.error&&e.jsx("div",{className:"mt-3 p-2 bg-cc-error/10 rounded text-sm text-cc-error font-mono whitespace-pre-wrap",children:s.error}),s.sessionId&&e.jsx("a",{href:`#/session/${s.sessionId}`,className:"mt-3 inline-flex items-center gap-1 text-sm text-cc-primary hover:text-cc-primary-hover",children:"Open session to view live output"})]})]})}export{T as RunsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,a as r,j as t,i as d}from"./index-
|
|
1
|
+
import{r as e,a as r,j as t,i as d}from"./index-Daik8cew.js";function V({embedded:x=!1}){const c=d(),[m,l]=e.useState([]),[f,a]=e.useState(!0),[S,g]=e.useState(""),[h,p]=e.useState(!1),[b,N]=e.useState(!1),[w,E]=e.useState(null),[n,o]=e.useState(null),s=e.useRef(null),[I,j]=e.useState(""),[v,A]=e.useState(""),[C,D]=e.useState(null),[R,k]=e.useState(""),[y,B]=e.useState(""),[O,T]=e.useState(null),[_,L]=e.useState(null);e.useRef({});const[M,P]=e.useState(""),i=e.useCallback(()=>{r.listSandboxes().then(l).catch(()=>{}).finally(()=>a(!1))},[]);return e.useEffect(()=>{{a(!1);return}},[i,c]),e.useEffect(()=>{if(!n||n.status!=="pulling"){s.current&&(clearInterval(s.current),s.current=null);return}return s.current||(s.current=setInterval(()=>{r.getImageStatus("the-companion:latest").then(u=>o(u)).catch(()=>{})},2e3)),()=>{s.current&&(clearInterval(s.current),s.current=null)}},[n]),t.jsx("div",{className:"h-full bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto overflow-x-hidden",children:t.jsxs("div",{className:"max-w-2xl mx-auto px-4 sm:px-6 py-6 sm:py-10 pb-safe",children:[t.jsx("h1",{className:"text-lg font-semibold mb-3",children:"Sandboxes"}),t.jsxs("div",{className:"rounded-xl bg-cc-card p-4 text-sm text-cc-muted leading-relaxed",children:[t.jsxs("p",{className:"mb-2",children:["Sandbox / container support is ",t.jsx("strong",{className:"text-cc-fg",children:"disabled"})," in this build."]}),t.jsxs("p",{className:"mb-2",children:["It relied on the upstream"," ",t.jsx("code",{className:"text-[12px] font-mono-code text-cc-fg",children:"the-companion"})," Docker image, which is no longer maintained — so the fork no longer pulls or runs it."]}),t.jsxs("p",{children:["To re-enable (e.g. with your own image), build the frontend with"," ",t.jsx("code",{className:"text-[12px] font-mono-code text-cc-fg",children:"VITE_SANDBOX_ENABLED=true"})," ","and run the server with"," ",t.jsx("code",{className:"text-[12px] font-mono-code text-cc-fg",children:"COMPANION_SANDBOX_ENABLED=1"}),"."]})]})]})})}export{V as SandboxManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,u as o,g as mt,a as c,j as e,n as ht,b as ft,s as bt}from"./index-DOle27vf.js";const re=[{id:"general",label:"General"},{id:"webhooks",label:"Webhooks"},{id:"authentication",label:"Authentication"},{id:"notifications",label:"Notifications"},{id:"providers",label:"Providers"},{id:"anthropic",label:"Anthropic"},{id:"ai-validation",label:"AI Validation"},{id:"dashboard",label:"Dashboard"},{id:"updates",label:"Updates"},{id:"telemetry",label:"Telemetry"},{id:"environments",label:"Environments"}];function vt({embedded:ie=!1}){const[p,le]=s.useState(""),[de,ue]=s.useState("claude-sonnet-4-6"),[d,xe]=s.useState(!1),[w,We]=s.useState(!0),[b,S]=s.useState(!1),[pe,g]=s.useState(""),[me,v]=s.useState(!1),ze=o(t=>t.darkMode),Je=o(t=>t.toggleDarkMode),he=o(t=>t.diffBase),Xe=o(t=>t.setDiffBase),Ze=o(t=>t.notificationSound),et=o(t=>t.toggleNotificationSound),fe=o(t=>t.notificationDesktop),be=o(t=>t.setNotificationDesktop),r=o(t=>t.updateInfo),P=o(t=>t.setUpdateInfo),tt=o(t=>t.setUpdateOverlayActive),st=typeof Notification<"u",[x,y]=s.useState("stable"),[C,I]=s.useState(!1),[A,V]=s.useState(!0),[ge,D]=s.useState("loopback"),[O,ve]=s.useState(!1),[M,ye]=s.useState(!1),[je,j]=s.useState(""),[Ne,U]=s.useState(""),[ke,at]=s.useState(mt()),[E,$]=s.useState(!1),[L,K]=s.useState(!0),[F,H]=s.useState(!1),[B,Q]=s.useState(!1),[we,_]=s.useState("claude-haiku-4-5"),[Se,G]=s.useState(3),[Ce,q]=s.useState(30),[T,Y]=s.useState(""),[Ae,Ue]=s.useState("general"),[ct,Ee]=s.useState(!1),[W,Te]=s.useState(!1),[N,m]=s.useState(null),[h,Re]=s.useState(""),[z,Pe]=s.useState(!1),[f,Ie]=s.useState(""),[J,Ve]=s.useState(!1),[X,De]=s.useState(!1),[nt,Z]=s.useState(!1),[Oe,Me]=s.useState(""),[ot,$e]=s.useState(!1),[rt,Le]=s.useState(!1),[k,Ke]=s.useState(null),[ee,Fe]=s.useState(!1),[u,He]=s.useState(null),[R,it]=s.useState(0),[te,Be]=s.useState(!1),[se,Qe]=s.useState(!1),[lt,_e]=s.useState(!1),Ge=s.useRef(null),ae=s.useRef({});s.useEffect(()=>{const t=Ge.current;if(!t)return;const a=new IntersectionObserver(n=>{var Ye;let i=null;for(const oe of n)oe.isIntersecting&&(!i||oe.boundingClientRect.top<i.boundingClientRect.top)&&(i=oe);(Ye=i==null?void 0:i.target)!=null&&Ye.id&&Ue(i.target.id)},{root:t,rootMargin:"-10% 0px -70% 0px",threshold:0});for(const n of re){const i=ae.current[n.id];i&&a.observe(i)}return()=>a.disconnect()},[w]);const qe=s.useCallback(t=>{Ue(t);const a=ae.current[t];a&&a.scrollIntoView({behavior:"smooth",block:"start"})},[]);s.useEffect(()=>{c.getSettings().then(t=>{xe(t.anthropicApiKeyConfigured),Pe(t.claudeCodeOAuthTokenConfigured),Ve(t.openaiApiKeyConfigured),ue(t.anthropicModel||"claude-sonnet-4-6"),typeof t.aiValidationEnabled=="boolean"&&$(t.aiValidationEnabled),typeof t.aiValidationAutoApprove=="boolean"&&K(t.aiValidationAutoApprove),typeof t.aiValidationAutoDeny=="boolean"&&H(t.aiValidationAutoDeny),typeof t.dashboardEnabled=="boolean"&&Q(t.dashboardEnabled),typeof t.dashboardModel=="string"&&t.dashboardModel&&_(t.dashboardModel),typeof t.dashboardRunHour=="number"&&G(t.dashboardRunHour),typeof t.dashboardMaxSessionsPerRun=="number"&&q(t.dashboardMaxSessionsPerRun),(t.updateChannel==="stable"||t.updateChannel==="prerelease")&&y(t.updateChannel),typeof t.dockerAutoUpdate=="boolean"&&I(t.dockerAutoUpdate),typeof t.proactiveKeepaliveEnabled=="boolean"&&V(t.proactiveKeepaliveEnabled),(t.cliBridgeMode==="loopback"||t.cliBridgeMode==="jsonHandoff")&&D(t.cliBridgeMode),typeof t.publicUrl=="string"&&(Y(t.publicUrl),o.getState().setPublicUrl(t.publicUrl))}).catch(t=>g(t instanceof Error?t.message:String(t))).finally(()=>We(!1)),c.getAuthToken().then(t=>Ke(t.token)).catch(()=>{})},[]);async function dt(t){t.preventDefault(),S(!0),g(""),v(!1);try{const a=p.trim(),n={anthropicModel:de.trim()||"claude-sonnet-4-6"};a&&(n.anthropicApiKey=a);const i=await c.updateSettings(n);xe(i.anthropicApiKeyConfigured),le(""),v(!0),setTimeout(()=>v(!1),1800)}catch(a){g(a instanceof Error?a.message:String(a))}finally{S(!1)}}async function ce(t){const a=t==="aiValidationEnabled"?E:t==="aiValidationAutoApprove"?L:F,n=!a;t==="aiValidationEnabled"?$(n):t==="aiValidationAutoApprove"?K(n):H(n);try{await c.updateSettings({[t]:n})}catch{t==="aiValidationEnabled"?$(a):t==="aiValidationAutoApprove"?K(a):H(a)}}async function ut(){const t=B;Q(!t);try{await c.updateSettings({dashboardEnabled:!t})}catch{Q(t)}}async function ne(t,a){try{await c.updateSettings(t)}catch{a()}}async function xt(){ve(!0),j(""),U("");try{const t=await c.forceCheckForUpdate();P(t),t.updateAvailable&&t.latestVersion?j(`Update v${t.latestVersion} is available.`):j("You are up to date.")}catch(t){U(t instanceof Error?t.message:String(t))}finally{ve(!1)}}async function pt(){ye(!0),j(""),U("");try{localStorage.setItem("companion_docker_prompt_pending","1");const t=await c.triggerUpdate();j(t.message),tt(!0)}catch(t){localStorage.removeItem("companion_docker_prompt_pending"),U(t instanceof Error?t.message:String(t)),ye(!1)}}const l=s.useCallback(t=>a=>{ae.current[t]=a},[]);return e.jsxs("div",{className:`${ie?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased flex flex-col`,children:[e.jsx("div",{className:"shrink-0 max-w-5xl w-full mx-auto px-4 sm:px-8 pt-6 sm:pt-10",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:"Settings"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Configure API access, notifications, appearance, and workspace defaults."})]}),!ie&&e.jsx("button",{onClick:()=>{const t=o.getState().currentSessionId;t?ht(t):ft()},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.jsx("div",{className:"sm:hidden shrink-0 border-b border-cc-border",children:e.jsx("nav",{className:"flex gap-1 px-4 py-2 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","aria-label":"Settings categories",children:re.map(t=>e.jsx("button",{type:"button",onClick:()=>qe(t.id),className:`shrink-0 px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${Ae===t.id?"text-cc-primary bg-cc-primary/8":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:t.label},t.id))})}),e.jsxs("div",{className:"flex-1 min-h-0 flex max-w-5xl w-full mx-auto",children:[e.jsx("nav",{className:"hidden sm:flex flex-col gap-0.5 w-44 shrink-0 pt-2 pr-6 pl-8 sticky top-0 self-start","aria-label":"Settings categories",children:re.map(t=>e.jsx("button",{type:"button",onClick:()=>qe(t.id),className:`text-left px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${Ae===t.id?"text-cc-primary bg-cc-primary/8":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:t.label},t.id))}),e.jsx("div",{ref:Ge,className:"flex-1 min-w-0 overflow-y-auto px-4 sm:px-8 sm:pl-0 pb-safe",children:e.jsxs("div",{className:"space-y-10 py-4 sm:py-2",children:[e.jsxs("section",{id:"general",ref:l("general"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"General"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:Je,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Theme"}),e.jsx("span",{className:"text-xs text-cc-muted",children:ze?"Dark":"Light"})]}),e.jsxs("button",{type:"button",onClick:()=>Xe(he==="last-commit"?"default-branch":"last-commit"),className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Diff compare against"}),e.jsx("span",{className:"text-xs text-cc-muted",children:he==="last-commit"?"Last commit (HEAD)":"Default branch"})]}),e.jsx("p",{className:"text-xs text-cc-muted px-1",children:"Last commit shows only uncommitted changes. Default branch shows all changes since diverging from main."}),e.jsx("div",{className:"pt-3 border-t border-cc-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Claude Code bridge mode"}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted",children:'How the Companion hands the bridge URL to the spawned Claude Code CLI. Loopback is the default fix for Claude Code v1.2.1+ which rejects the literal "localhost". JSON handoff is the more robust just-every/code-style approach: writes a temp descriptor with a one-shot token and passes its path via CLAUDE_BRIDGE_CONFIG.'})]}),e.jsxs("select",{"aria-label":"CLI bridge mode",value:ge,onChange:async t=>{const a=t.target.value==="jsonHandoff"?"jsonHandoff":"loopback",n=ge;D(a);try{await c.updateSettings({cliBridgeMode:a})}catch{D(n)}},className:"ml-3 px-2 py-1.5 text-xs bg-cc-bg rounded-lg border border-cc-border text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary",children:[e.jsx("option",{value:"loopback",children:"Loopback (default)"}),e.jsx("option",{value:"jsonHandoff",children:"JSON handoff (experimental)"})]})]})}),e.jsxs("div",{className:"pt-3 border-t border-cc-border",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":A,"aria-label":"Proactive keepalive relaunch",onClick:async()=>{const t=!A,a=A;V(t);try{await c.updateSettings({proactiveKeepaliveEnabled:t})}catch{V(a)}},className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Proactive keepalive relaunch"}),e.jsx("span",{className:"text-xs text-cc-muted",children:A?"On":"Off"})]}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted px-1",children:"When on (default), a CLI process that exits unexpectedly with no browser attached is automatically relaunched to keep long-running sessions (agents, cron) alive. Turn off to experiment with letting dead sessions stay dead."})]})]})]}),e.jsxs("section",{id:"webhooks",ref:l("webhooks"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Webhooks"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"The public URL is used for webhook URLs that external services (Linear, GitHub) send events to. Set this to the externally-reachable address of your Companion instance."}),e.jsxs("p",{className:"text-xs text-cc-muted",children:["Tip:"," ",e.jsx("a",{href:"#/integrations/tailscale",className:"text-cc-primary hover:underline",children:"Use the Tailscale integration"})," ","to get an HTTPS URL automatically."]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-cc-fg mb-1.5",htmlFor:"public-url",children:"Public URL"}),e.jsx("input",{id:"public-url",type:"url","aria-label":"Public URL",value:T,onChange:t=>Y(t.target.value),placeholder:"https://your-domain.example.com",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary font-mono-code"}),e.jsx("p",{className:"mt-1.5 text-[10px] text-cc-muted",children:T?`Using: ${T}`:`Fallback: ${typeof window<"u"?window.location.origin:"http://localhost:3456"}`})]}),e.jsx("button",{type:"button",onClick:async()=>{S(!0),g("");try{const t=await c.updateSettings({publicUrl:T.trim()});Y(t.publicUrl),o.getState().setPublicUrl(t.publicUrl),v(!0),setTimeout(()=>v(!1),1800)}catch(t){g(t instanceof Error?t.message:String(t))}finally{S(!1)}},disabled:b,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-primary text-white hover:opacity-90 transition-opacity disabled:opacity-50 cursor-pointer",children:b?"Saving...":me?"Saved!":"Save Public URL"})]})]}),e.jsxs("section",{id:"authentication",ref:l("authentication"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Authentication"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Use the auth token or QR code to connect additional devices (e.g. mobile over Tailscale)."}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",children:"Auth Token"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg font-mono-code select-all break-all flex items-center",children:k?ee?k:"••••••••••••••••":e.jsx("span",{className:"text-cc-muted",children:"Loading..."})}),e.jsx("button",{type:"button",onClick:()=>Fe(t=>!t),className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",title:ee?"Hide token":"Show token",children:ee?"Hide":"Show"}),e.jsx("button",{type:"button",onClick:()=>{k&&navigator.clipboard.writeText(k).then(()=>{_e(!0),setTimeout(()=>_e(!1),1500)})},disabled:!k,className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Copy token to clipboard",children:lt?"Copied":"Copy"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",children:"Mobile Login QR"}),u&&u.length>0?e.jsxs("div",{className:"space-y-3",children:[u.length>1&&e.jsx("div",{className:"flex gap-1",children:u.map((t,a)=>e.jsx("button",{type:"button",onClick:()=>it(a),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors cursor-pointer ${a===R?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t.label},t.label))}),e.jsx("div",{className:"inline-block rounded-lg bg-white p-2",children:e.jsx("img",{src:u[R].qrDataUrl,alt:`QR code for ${u[R].label} login`,className:"w-48 h-48"})}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-bg text-sm font-mono-code text-cc-fg break-all select-all",children:u[R].url}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Scan with your phone's camera app — it will open the URL and auto-authenticate."})]}):u&&u.length===0?e.jsx("p",{className:"text-xs text-cc-muted",children:"No remote addresses detected (LAN or Tailscale). Connect to a network to generate a QR code."}):e.jsx("button",{type:"button",onClick:async()=>{Be(!0);try{const t=await c.getAuthQr();He(t.qrCodes)}catch{}finally{Be(!1)}},disabled:te,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${te?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:te?"Generating...":"Show QR Code"})]}),e.jsxs("div",{className:"pt-2",children:[e.jsx("button",{type:"button",onClick:async()=>{if(confirm("Regenerate auth token? All existing sessions on other devices will be signed out.")){Qe(!0);try{const t=await c.regenerateAuthToken();Ke(t.token),Fe(!0),He(null)}catch{}finally{Qe(!1)}}},disabled:se,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${se?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-error/10 hover:bg-cc-error/20 text-cc-error cursor-pointer"}`,children:se?"Regenerating...":"Regenerate Token"}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:"Creates a new token. All other signed-in devices will need to re-authenticate."})]})]})]}),e.jsxs("section",{id:"notifications",ref:l("notifications"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Notifications"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:et,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Sound"}),e.jsx("span",{className:"text-xs text-cc-muted",children:Ze?"On":"Off"})]}),st&&e.jsxs("button",{type:"button",onClick:async()=>{if(fe)be(!1);else{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted")return;be(!0)}},className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Desktop Alerts"}),e.jsx("span",{className:"text-xs text-cc-muted",children:fe?"On":"Off"})]})]})]}),e.jsxs("section",{id:"providers",ref:l("providers"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Providers"}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Configure authentication tokens for Claude Code and Codex. These are injected into sessions automatically."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"claude-code-token",children:"Claude Code OAuth Token"}),e.jsxs("p",{className:"text-xs text-cc-muted",children:["Run ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"claude setup-token"})," in your terminal, then paste the token here."]}),e.jsx("input",{id:"claude-code-token",type:"password",value:z&&!ot&&!h?"••••••••••••••••":h,onChange:t=>Re(t.target.value),onFocus:()=>$e(!0),onBlur:()=>$e(!1),placeholder:z?"Enter a new token to replace":"Paste token from claude setup-token",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("p",{className:"text-xs text-cc-muted",children:z?"Claude Code token configured":"Claude Code token not configured"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"openai-api-key",children:"OpenAI API Key (Codex)"}),e.jsxs("p",{className:"text-xs text-cc-muted",children:["Used to authenticate Codex sessions. You can also use ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"codex --login"})," for device-based auth."]}),e.jsx("input",{id:"openai-api-key",type:"password",value:J&&!rt&&!f?"••••••••••••••••":f,onChange:t=>Ie(t.target.value),onFocus:()=>Le(!0),onBlur:()=>Le(!1),placeholder:J?"Enter a new key to replace":"sk-...",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("p",{className:"text-xs text-cc-muted",children:J?"OpenAI key configured":"OpenAI key not configured"})]}),Oe&&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:Oe}),nt&&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:"Provider settings saved."}),e.jsx("button",{type:"button",disabled:X||!h.trim()&&!f.trim(),onClick:async()=>{De(!0),Me(""),Z(!1);try{const t={};h.trim()&&(t.claudeCodeOAuthToken=h.trim()),f.trim()&&(t.openaiApiKey=f.trim());const a=await c.updateSettings(t);Pe(a.claudeCodeOAuthTokenConfigured),Ve(a.openaiApiKeyConfigured),Re(""),Ie(""),Z(!0),setTimeout(()=>Z(!1),1800)}catch(t){Me(t instanceof Error?t.message:String(t))}finally{De(!1)}},className:`px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${X||!h.trim()&&!f.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:X?"Saving...":"Save Provider Settings"})]})]}),e.jsxs("section",{id:"anthropic",ref:l("anthropic"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Anthropic"}),e.jsxs("form",{onSubmit:dt,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"anthropic-key",children:"Anthropic API Key"}),e.jsx("input",{id:"anthropic-key",type:"password",value:d&&!ct&&!p?"••••••••••••••••":p,onChange:t=>{le(t.target.value),m(null)},onFocus:()=>Ee(!0),onBlur:()=>Ee(!1),placeholder:d?"Enter a new key to replace":"sk-ant-api03-...",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:"Auto-renaming is disabled until this key is configured."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"anthropic-model",children:"Anthropic Model"}),e.jsx("input",{id:"anthropic-model",type:"text",value:de,onChange:t=>ue(t.target.value),placeholder:"claude-sonnet-4-6",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]}),pe&&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:pe}),me&&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:"Settings saved."}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-cc-muted",children:w?"Loading...":d?"Anthropic key configured":"Anthropic key not configured"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",disabled:W||!p.trim(),onClick:async()=>{Te(!0),m(null);try{const t=await c.verifyAnthropicKey(p.trim());m(t),setTimeout(()=>m(null),5e3)}catch(t){m({valid:!1,error:t instanceof Error?t.message:String(t)}),setTimeout(()=>m(null),5e3)}finally{Te(!1)}},className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${W||!p.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:W?"Verifying...":"Verify"}),e.jsx("button",{type:"submit",disabled:b||w,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${b||w?"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"})]})]}),N&&e.jsx("div",{className:`px-3 py-2 rounded-lg text-xs ${N.valid?"bg-cc-success/10 border border-cc-success/20 text-cc-success":"bg-cc-error/10 border border-cc-error/20 text-cc-error"}`,children:N.valid?"API key is valid.":`Invalid API key${N.error?`: ${N.error}`:"."}`})]})]}),e.jsxs("section",{id:"ai-validation",ref:l("ai-validation"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"AI Validation"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-cc-muted leading-relaxed",children:"When enabled, an AI model evaluates tool calls before they execute. Safe operations are auto-approved, dangerous ones are blocked, and uncertain cases are shown to you with a recommendation. Requires an Anthropic API key. These settings serve as defaults for new sessions. Each session can override AI validation independently via the shield icon in the session header."}),e.jsxs("button",{type:"button",onClick:()=>ce("aiValidationEnabled"),disabled:!d,className:`w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg transition-colors ${d?"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed opacity-60"}`,children:[e.jsx("span",{className:"text-sm",children:"AI Validation Mode"}),e.jsx("span",{className:`text-xs font-medium ${E&&d?"text-cc-success":"text-cc-muted"}`,children:E&&d?"On":"Off"})]}),!d&&e.jsx("p",{className:"text-[11px] text-cc-warning",children:"Configure an Anthropic API key above to enable AI validation."}),E&&d&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>ce("aiValidationAutoApprove"),className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm",children:"Auto-approve safe tools"}),e.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5",children:"Automatically allow read-only tools and benign commands"})]}),e.jsx("span",{className:`text-xs font-medium ${L?"text-cc-success":"text-cc-muted"}`,children:L?"On":"Off"})]}),e.jsxs("button",{type:"button",onClick:()=>ce("aiValidationAutoDeny"),className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm",children:"Auto-deny dangerous tools"}),e.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5",children:"Automatically block destructive commands like rm -rf"})]}),e.jsx("span",{className:`text-xs font-medium ${F?"text-cc-success":"text-cc-muted"}`,children:F?"On":"Off"})]})]})]})]}),e.jsxs("section",{id:"dashboard",ref:l("dashboard"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Project Dashboard"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs text-cc-muted leading-relaxed",children:["A nightly job summarizes every session with recent activity so the"," ",e.jsx("a",{href:"#/dashboard",className:"underline hover:no-underline",children:"dashboard"})," ",'can show where each project stands. It runs through the Claude Code CLI with the same login your normal sessions use — no separate API key needed. This is opt-in because it spends tokens every night. You can always refresh manually with "Update now" on the dashboard, even when the nightly run is off.']}),e.jsxs("button",{type:"button",onClick:ut,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:[e.jsx("span",{className:"text-sm",children:"Nightly dashboard updates"}),e.jsx("span",{className:`text-xs font-medium ${B?"text-cc-success":"text-cc-muted"}`,children:B?"On":"Off"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"dashboard-model",children:"Summarization model"}),e.jsxs("select",{id:"dashboard-model",value:we,onChange:t=>{const a=we;_(t.target.value),ne({dashboardModel:t.target.value},()=>_(a))},className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow",children:[e.jsx("option",{value:"claude-haiku-4-5",children:"Claude Haiku 4.5 — cheapest, recommended"}),e.jsx("option",{value:"claude-sonnet-4-6",children:"Claude Sonnet 4.6"}),e.jsx("option",{value:"claude-sonnet-5",children:"Claude Sonnet 5"})]}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:"Summarize-and-classify doesn't need an expensive model — Haiku keeps the nightly cost low."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"dashboard-run-hour",children:"Run at"}),e.jsx("select",{id:"dashboard-run-hour",value:Se,onChange:t=>{const a=Se,n=Number(t.target.value);G(n),ne({dashboardRunHour:n},()=>G(a))},className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow",children:Array.from({length:24},(t,a)=>e.jsxs("option",{value:a,children:[String(a).padStart(2,"0"),":00"]},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"dashboard-max-sessions",children:"Max sessions per run"}),e.jsx("select",{id:"dashboard-max-sessions",value:Ce,onChange:t=>{const a=Ce,n=Number(t.target.value);q(n),ne({dashboardMaxSessionsPerRun:n},()=>q(a))},className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow",children:[10,20,30,50,100,200].map(t=>e.jsx("option",{value:t,children:t},t))})]})]})]})]}),e.jsxs("section",{id:"updates",ref:l("updates"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Updates"}),e.jsxs("div",{className:"space-y-3",children:[r?e.jsxs("p",{className:"text-xs text-cc-muted",children:["Current version: v",r.currentVersion,r.latestVersion?` • Latest: v${r.latestVersion}`:"",r.channel==="prerelease"?" (prerelease)":""]}):e.jsx("p",{className:"text-xs text-cc-muted",children:"Version information not loaded yet."}),e.jsxs("div",{children:[e.jsx("span",{id:"update-channel-label",className:"block text-sm font-medium mb-1.5",children:"Update Channel"}),e.jsxs("div",{className:"flex gap-1",role:"radiogroup","aria-labelledby":"update-channel-label",children:[e.jsx("button",{type:"button",role:"radio","aria-checked":x==="stable",onClick:async()=>{if(x!=="stable"){y("stable");try{await c.updateSettings({updateChannel:"stable"})}catch{y("prerelease");return}try{const t=await c.forceCheckForUpdate();P(t)}catch{}}},className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${x==="stable"?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg hover:bg-cc-active"}`,children:"Stable"}),e.jsx("button",{type:"button",role:"radio","aria-checked":x==="prerelease",onClick:async()=>{if(x!=="prerelease"){y("prerelease");try{await c.updateSettings({updateChannel:"prerelease"})}catch{y("stable");return}try{const t=await c.forceCheckForUpdate();P(t)}catch{}}},className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${x==="prerelease"?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg hover:bg-cc-active"}`,children:"Prerelease"})]}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:x==="prerelease"?"Tracking prerelease channel. You will receive preview builds from the latest main branch.":"Tracking stable channel. You will only receive versioned releases."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Auto-update Docker image"}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted",children:"Automatically re-pull the sandbox Docker image when updating The Companion"})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":C,onClick:async()=>{const t=!C;I(t);try{await c.updateSettings({dockerAutoUpdate:t})}catch{I(!t)}},className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${C?"bg-cc-primary":"bg-cc-hover"}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform transition-transform ${C?"translate-x-5":"translate-x-0"}`})})]}),Ne&&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:Ne}),je&&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:je}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:xt,disabled:O,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${O?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:O?"Checking...":"Check for updates"}),r!=null&&r.isServiceMode?e.jsx("button",{type:"button",onClick:pt,disabled:M||r.updateInProgress||!r.updateAvailable,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${M||r.updateInProgress||!r.updateAvailable?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:M||r.updateInProgress?"Updating...":"Update & Restart"}):e.jsxs("p",{className:"text-xs text-cc-muted self-center",children:["Install service mode with ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"the-companion install"})," to enable one-click updates."]})]})]})]}),e.jsxs("section",{id:"telemetry",ref:l("telemetry"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Telemetry"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Anonymous product analytics and crash reports via PostHog to improve reliability."}),e.jsxs("button",{type:"button",onClick:()=>{const t=!ke;bt(t),at(t)},className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Usage analytics and errors"}),e.jsx("span",{className:"text-xs text-cc-muted",children:ke?"On":"Off"})]}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Browser Do Not Track is respected automatically."})]})]}),e.jsxs("section",{id:"environments",ref:l("environments"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Environments"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Manage reusable environment profiles used when creating sessions."}),e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/environments"},className:"px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Open Environments Page"})]})]})]})})]})]})}export{vt as SettingsPage};
|
|
1
|
+
import{r as s,u as o,g as mt,a as c,j as e,n as ht,b as ft,s as bt}from"./index-Daik8cew.js";const re=[{id:"general",label:"General"},{id:"webhooks",label:"Webhooks"},{id:"authentication",label:"Authentication"},{id:"notifications",label:"Notifications"},{id:"providers",label:"Providers"},{id:"anthropic",label:"Anthropic"},{id:"ai-validation",label:"AI Validation"},{id:"dashboard",label:"Dashboard"},{id:"updates",label:"Updates"},{id:"telemetry",label:"Telemetry"},{id:"environments",label:"Environments"}];function vt({embedded:ie=!1}){const[p,le]=s.useState(""),[de,ue]=s.useState("claude-sonnet-4-6"),[d,xe]=s.useState(!1),[w,We]=s.useState(!0),[b,S]=s.useState(!1),[pe,g]=s.useState(""),[me,v]=s.useState(!1),ze=o(t=>t.darkMode),Je=o(t=>t.toggleDarkMode),he=o(t=>t.diffBase),Xe=o(t=>t.setDiffBase),Ze=o(t=>t.notificationSound),et=o(t=>t.toggleNotificationSound),fe=o(t=>t.notificationDesktop),be=o(t=>t.setNotificationDesktop),r=o(t=>t.updateInfo),P=o(t=>t.setUpdateInfo),tt=o(t=>t.setUpdateOverlayActive),st=typeof Notification<"u",[x,y]=s.useState("stable"),[C,I]=s.useState(!1),[A,V]=s.useState(!0),[ge,D]=s.useState("loopback"),[O,ve]=s.useState(!1),[M,ye]=s.useState(!1),[je,j]=s.useState(""),[Ne,U]=s.useState(""),[ke,at]=s.useState(mt()),[E,$]=s.useState(!1),[L,K]=s.useState(!0),[F,H]=s.useState(!1),[B,Q]=s.useState(!1),[we,_]=s.useState("claude-haiku-4-5"),[Se,G]=s.useState(3),[Ce,q]=s.useState(30),[T,Y]=s.useState(""),[Ae,Ue]=s.useState("general"),[ct,Ee]=s.useState(!1),[W,Te]=s.useState(!1),[N,m]=s.useState(null),[h,Re]=s.useState(""),[z,Pe]=s.useState(!1),[f,Ie]=s.useState(""),[J,Ve]=s.useState(!1),[X,De]=s.useState(!1),[nt,Z]=s.useState(!1),[Oe,Me]=s.useState(""),[ot,$e]=s.useState(!1),[rt,Le]=s.useState(!1),[k,Ke]=s.useState(null),[ee,Fe]=s.useState(!1),[u,He]=s.useState(null),[R,it]=s.useState(0),[te,Be]=s.useState(!1),[se,Qe]=s.useState(!1),[lt,_e]=s.useState(!1),Ge=s.useRef(null),ae=s.useRef({});s.useEffect(()=>{const t=Ge.current;if(!t)return;const a=new IntersectionObserver(n=>{var Ye;let i=null;for(const oe of n)oe.isIntersecting&&(!i||oe.boundingClientRect.top<i.boundingClientRect.top)&&(i=oe);(Ye=i==null?void 0:i.target)!=null&&Ye.id&&Ue(i.target.id)},{root:t,rootMargin:"-10% 0px -70% 0px",threshold:0});for(const n of re){const i=ae.current[n.id];i&&a.observe(i)}return()=>a.disconnect()},[w]);const qe=s.useCallback(t=>{Ue(t);const a=ae.current[t];a&&a.scrollIntoView({behavior:"smooth",block:"start"})},[]);s.useEffect(()=>{c.getSettings().then(t=>{xe(t.anthropicApiKeyConfigured),Pe(t.claudeCodeOAuthTokenConfigured),Ve(t.openaiApiKeyConfigured),ue(t.anthropicModel||"claude-sonnet-4-6"),typeof t.aiValidationEnabled=="boolean"&&$(t.aiValidationEnabled),typeof t.aiValidationAutoApprove=="boolean"&&K(t.aiValidationAutoApprove),typeof t.aiValidationAutoDeny=="boolean"&&H(t.aiValidationAutoDeny),typeof t.dashboardEnabled=="boolean"&&Q(t.dashboardEnabled),typeof t.dashboardModel=="string"&&t.dashboardModel&&_(t.dashboardModel),typeof t.dashboardRunHour=="number"&&G(t.dashboardRunHour),typeof t.dashboardMaxSessionsPerRun=="number"&&q(t.dashboardMaxSessionsPerRun),(t.updateChannel==="stable"||t.updateChannel==="prerelease")&&y(t.updateChannel),typeof t.dockerAutoUpdate=="boolean"&&I(t.dockerAutoUpdate),typeof t.proactiveKeepaliveEnabled=="boolean"&&V(t.proactiveKeepaliveEnabled),(t.cliBridgeMode==="loopback"||t.cliBridgeMode==="jsonHandoff")&&D(t.cliBridgeMode),typeof t.publicUrl=="string"&&(Y(t.publicUrl),o.getState().setPublicUrl(t.publicUrl))}).catch(t=>g(t instanceof Error?t.message:String(t))).finally(()=>We(!1)),c.getAuthToken().then(t=>Ke(t.token)).catch(()=>{})},[]);async function dt(t){t.preventDefault(),S(!0),g(""),v(!1);try{const a=p.trim(),n={anthropicModel:de.trim()||"claude-sonnet-4-6"};a&&(n.anthropicApiKey=a);const i=await c.updateSettings(n);xe(i.anthropicApiKeyConfigured),le(""),v(!0),setTimeout(()=>v(!1),1800)}catch(a){g(a instanceof Error?a.message:String(a))}finally{S(!1)}}async function ce(t){const a=t==="aiValidationEnabled"?E:t==="aiValidationAutoApprove"?L:F,n=!a;t==="aiValidationEnabled"?$(n):t==="aiValidationAutoApprove"?K(n):H(n);try{await c.updateSettings({[t]:n})}catch{t==="aiValidationEnabled"?$(a):t==="aiValidationAutoApprove"?K(a):H(a)}}async function ut(){const t=B;Q(!t);try{await c.updateSettings({dashboardEnabled:!t})}catch{Q(t)}}async function ne(t,a){try{await c.updateSettings(t)}catch{a()}}async function xt(){ve(!0),j(""),U("");try{const t=await c.forceCheckForUpdate();P(t),t.updateAvailable&&t.latestVersion?j(`Update v${t.latestVersion} is available.`):j("You are up to date.")}catch(t){U(t instanceof Error?t.message:String(t))}finally{ve(!1)}}async function pt(){ye(!0),j(""),U("");try{localStorage.setItem("companion_docker_prompt_pending","1");const t=await c.triggerUpdate();j(t.message),tt(!0)}catch(t){localStorage.removeItem("companion_docker_prompt_pending"),U(t instanceof Error?t.message:String(t)),ye(!1)}}const l=s.useCallback(t=>a=>{ae.current[t]=a},[]);return e.jsxs("div",{className:`${ie?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased flex flex-col`,children:[e.jsx("div",{className:"shrink-0 max-w-5xl w-full mx-auto px-4 sm:px-8 pt-6 sm:pt-10",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:"Settings"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Configure API access, notifications, appearance, and workspace defaults."})]}),!ie&&e.jsx("button",{onClick:()=>{const t=o.getState().currentSessionId;t?ht(t):ft()},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.jsx("div",{className:"sm:hidden shrink-0 border-b border-cc-border",children:e.jsx("nav",{className:"flex gap-1 px-4 py-2 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","aria-label":"Settings categories",children:re.map(t=>e.jsx("button",{type:"button",onClick:()=>qe(t.id),className:`shrink-0 px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${Ae===t.id?"text-cc-primary bg-cc-primary/8":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:t.label},t.id))})}),e.jsxs("div",{className:"flex-1 min-h-0 flex max-w-5xl w-full mx-auto",children:[e.jsx("nav",{className:"hidden sm:flex flex-col gap-0.5 w-44 shrink-0 pt-2 pr-6 pl-8 sticky top-0 self-start","aria-label":"Settings categories",children:re.map(t=>e.jsx("button",{type:"button",onClick:()=>qe(t.id),className:`text-left px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${Ae===t.id?"text-cc-primary bg-cc-primary/8":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:t.label},t.id))}),e.jsx("div",{ref:Ge,className:"flex-1 min-w-0 overflow-y-auto px-4 sm:px-8 sm:pl-0 pb-safe",children:e.jsxs("div",{className:"space-y-10 py-4 sm:py-2",children:[e.jsxs("section",{id:"general",ref:l("general"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"General"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:Je,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Theme"}),e.jsx("span",{className:"text-xs text-cc-muted",children:ze?"Dark":"Light"})]}),e.jsxs("button",{type:"button",onClick:()=>Xe(he==="last-commit"?"default-branch":"last-commit"),className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Diff compare against"}),e.jsx("span",{className:"text-xs text-cc-muted",children:he==="last-commit"?"Last commit (HEAD)":"Default branch"})]}),e.jsx("p",{className:"text-xs text-cc-muted px-1",children:"Last commit shows only uncommitted changes. Default branch shows all changes since diverging from main."}),e.jsx("div",{className:"pt-3 border-t border-cc-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Claude Code bridge mode"}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted",children:'How the Companion hands the bridge URL to the spawned Claude Code CLI. Loopback is the default fix for Claude Code v1.2.1+ which rejects the literal "localhost". JSON handoff is the more robust just-every/code-style approach: writes a temp descriptor with a one-shot token and passes its path via CLAUDE_BRIDGE_CONFIG.'})]}),e.jsxs("select",{"aria-label":"CLI bridge mode",value:ge,onChange:async t=>{const a=t.target.value==="jsonHandoff"?"jsonHandoff":"loopback",n=ge;D(a);try{await c.updateSettings({cliBridgeMode:a})}catch{D(n)}},className:"ml-3 px-2 py-1.5 text-xs bg-cc-bg rounded-lg border border-cc-border text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary",children:[e.jsx("option",{value:"loopback",children:"Loopback (default)"}),e.jsx("option",{value:"jsonHandoff",children:"JSON handoff (experimental)"})]})]})}),e.jsxs("div",{className:"pt-3 border-t border-cc-border",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":A,"aria-label":"Proactive keepalive relaunch",onClick:async()=>{const t=!A,a=A;V(t);try{await c.updateSettings({proactiveKeepaliveEnabled:t})}catch{V(a)}},className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Proactive keepalive relaunch"}),e.jsx("span",{className:"text-xs text-cc-muted",children:A?"On":"Off"})]}),e.jsx("p",{className:"mt-1 text-xs text-cc-muted px-1",children:"When on (default), a CLI process that exits unexpectedly with no browser attached is automatically relaunched to keep long-running sessions (agents, cron) alive. Turn off to experiment with letting dead sessions stay dead."})]})]})]}),e.jsxs("section",{id:"webhooks",ref:l("webhooks"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Webhooks"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"The public URL is used for webhook URLs that external services (Linear, GitHub) send events to. Set this to the externally-reachable address of your Companion instance."}),e.jsxs("p",{className:"text-xs text-cc-muted",children:["Tip:"," ",e.jsx("a",{href:"#/integrations/tailscale",className:"text-cc-primary hover:underline",children:"Use the Tailscale integration"})," ","to get an HTTPS URL automatically."]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-cc-fg mb-1.5",htmlFor:"public-url",children:"Public URL"}),e.jsx("input",{id:"public-url",type:"url","aria-label":"Public URL",value:T,onChange:t=>Y(t.target.value),placeholder:"https://your-domain.example.com",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary font-mono-code"}),e.jsx("p",{className:"mt-1.5 text-[10px] text-cc-muted",children:T?`Using: ${T}`:`Fallback: ${typeof window<"u"?window.location.origin:"http://localhost:3456"}`})]}),e.jsx("button",{type:"button",onClick:async()=>{S(!0),g("");try{const t=await c.updateSettings({publicUrl:T.trim()});Y(t.publicUrl),o.getState().setPublicUrl(t.publicUrl),v(!0),setTimeout(()=>v(!1),1800)}catch(t){g(t instanceof Error?t.message:String(t))}finally{S(!1)}},disabled:b,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-primary text-white hover:opacity-90 transition-opacity disabled:opacity-50 cursor-pointer",children:b?"Saving...":me?"Saved!":"Save Public URL"})]})]}),e.jsxs("section",{id:"authentication",ref:l("authentication"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Authentication"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Use the auth token or QR code to connect additional devices (e.g. mobile over Tailscale)."}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",children:"Auth Token"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg font-mono-code select-all break-all flex items-center",children:k?ee?k:"••••••••••••••••":e.jsx("span",{className:"text-cc-muted",children:"Loading..."})}),e.jsx("button",{type:"button",onClick:()=>Fe(t=>!t),className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",title:ee?"Hide token":"Show token",children:ee?"Hide":"Show"}),e.jsx("button",{type:"button",onClick:()=>{k&&navigator.clipboard.writeText(k).then(()=>{_e(!0),setTimeout(()=>_e(!1),1500)})},disabled:!k,className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"Copy token to clipboard",children:lt?"Copied":"Copy"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",children:"Mobile Login QR"}),u&&u.length>0?e.jsxs("div",{className:"space-y-3",children:[u.length>1&&e.jsx("div",{className:"flex gap-1",children:u.map((t,a)=>e.jsx("button",{type:"button",onClick:()=>it(a),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors cursor-pointer ${a===R?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t.label},t.label))}),e.jsx("div",{className:"inline-block rounded-lg bg-white p-2",children:e.jsx("img",{src:u[R].qrDataUrl,alt:`QR code for ${u[R].label} login`,className:"w-48 h-48"})}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-bg text-sm font-mono-code text-cc-fg break-all select-all",children:u[R].url}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Scan with your phone's camera app — it will open the URL and auto-authenticate."})]}):u&&u.length===0?e.jsx("p",{className:"text-xs text-cc-muted",children:"No remote addresses detected (LAN or Tailscale). Connect to a network to generate a QR code."}):e.jsx("button",{type:"button",onClick:async()=>{Be(!0);try{const t=await c.getAuthQr();He(t.qrCodes)}catch{}finally{Be(!1)}},disabled:te,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${te?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:te?"Generating...":"Show QR Code"})]}),e.jsxs("div",{className:"pt-2",children:[e.jsx("button",{type:"button",onClick:async()=>{if(confirm("Regenerate auth token? All existing sessions on other devices will be signed out.")){Qe(!0);try{const t=await c.regenerateAuthToken();Ke(t.token),Fe(!0),He(null)}catch{}finally{Qe(!1)}}},disabled:se,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${se?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-error/10 hover:bg-cc-error/20 text-cc-error cursor-pointer"}`,children:se?"Regenerating...":"Regenerate Token"}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:"Creates a new token. All other signed-in devices will need to re-authenticate."})]})]})]}),e.jsxs("section",{id:"notifications",ref:l("notifications"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Notifications"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:et,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Sound"}),e.jsx("span",{className:"text-xs text-cc-muted",children:Ze?"On":"Off"})]}),st&&e.jsxs("button",{type:"button",onClick:async()=>{if(fe)be(!1);else{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted")return;be(!0)}},className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Desktop Alerts"}),e.jsx("span",{className:"text-xs text-cc-muted",children:fe?"On":"Off"})]})]})]}),e.jsxs("section",{id:"providers",ref:l("providers"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Providers"}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Configure authentication tokens for Claude Code and Codex. These are injected into sessions automatically."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"claude-code-token",children:"Claude Code OAuth Token"}),e.jsxs("p",{className:"text-xs text-cc-muted",children:["Run ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"claude setup-token"})," in your terminal, then paste the token here."]}),e.jsx("input",{id:"claude-code-token",type:"password",value:z&&!ot&&!h?"••••••••••••••••":h,onChange:t=>Re(t.target.value),onFocus:()=>$e(!0),onBlur:()=>$e(!1),placeholder:z?"Enter a new token to replace":"Paste token from claude setup-token",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("p",{className:"text-xs text-cc-muted",children:z?"Claude Code token configured":"Claude Code token not configured"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"openai-api-key",children:"OpenAI API Key (Codex)"}),e.jsxs("p",{className:"text-xs text-cc-muted",children:["Used to authenticate Codex sessions. You can also use ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"codex --login"})," for device-based auth."]}),e.jsx("input",{id:"openai-api-key",type:"password",value:J&&!rt&&!f?"••••••••••••••••":f,onChange:t=>Ie(t.target.value),onFocus:()=>Le(!0),onBlur:()=>Le(!1),placeholder:J?"Enter a new key to replace":"sk-...",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("p",{className:"text-xs text-cc-muted",children:J?"OpenAI key configured":"OpenAI key not configured"})]}),Oe&&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:Oe}),nt&&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:"Provider settings saved."}),e.jsx("button",{type:"button",disabled:X||!h.trim()&&!f.trim(),onClick:async()=>{De(!0),Me(""),Z(!1);try{const t={};h.trim()&&(t.claudeCodeOAuthToken=h.trim()),f.trim()&&(t.openaiApiKey=f.trim());const a=await c.updateSettings(t);Pe(a.claudeCodeOAuthTokenConfigured),Ve(a.openaiApiKeyConfigured),Re(""),Ie(""),Z(!0),setTimeout(()=>Z(!1),1800)}catch(t){Me(t instanceof Error?t.message:String(t))}finally{De(!1)}},className:`px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${X||!h.trim()&&!f.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:X?"Saving...":"Save Provider Settings"})]})]}),e.jsxs("section",{id:"anthropic",ref:l("anthropic"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Anthropic"}),e.jsxs("form",{onSubmit:dt,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"anthropic-key",children:"Anthropic API Key"}),e.jsx("input",{id:"anthropic-key",type:"password",value:d&&!ct&&!p?"••••••••••••••••":p,onChange:t=>{le(t.target.value),m(null)},onFocus:()=>Ee(!0),onBlur:()=>Ee(!1),placeholder:d?"Enter a new key to replace":"sk-ant-api03-...",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:"Auto-renaming is disabled until this key is configured."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"anthropic-model",children:"Anthropic Model"}),e.jsx("input",{id:"anthropic-model",type:"text",value:de,onChange:t=>ue(t.target.value),placeholder:"claude-sonnet-4-6",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]}),pe&&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:pe}),me&&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:"Settings saved."}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-cc-muted",children:w?"Loading...":d?"Anthropic key configured":"Anthropic key not configured"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",disabled:W||!p.trim(),onClick:async()=>{Te(!0),m(null);try{const t=await c.verifyAnthropicKey(p.trim());m(t),setTimeout(()=>m(null),5e3)}catch(t){m({valid:!1,error:t instanceof Error?t.message:String(t)}),setTimeout(()=>m(null),5e3)}finally{Te(!1)}},className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${W||!p.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:W?"Verifying...":"Verify"}),e.jsx("button",{type:"submit",disabled:b||w,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${b||w?"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"})]})]}),N&&e.jsx("div",{className:`px-3 py-2 rounded-lg text-xs ${N.valid?"bg-cc-success/10 border border-cc-success/20 text-cc-success":"bg-cc-error/10 border border-cc-error/20 text-cc-error"}`,children:N.valid?"API key is valid.":`Invalid API key${N.error?`: ${N.error}`:"."}`})]})]}),e.jsxs("section",{id:"ai-validation",ref:l("ai-validation"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"AI Validation"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-cc-muted leading-relaxed",children:"When enabled, an AI model evaluates tool calls before they execute. Safe operations are auto-approved, dangerous ones are blocked, and uncertain cases are shown to you with a recommendation. Requires an Anthropic API key. These settings serve as defaults for new sessions. Each session can override AI validation independently via the shield icon in the session header."}),e.jsxs("button",{type:"button",onClick:()=>ce("aiValidationEnabled"),disabled:!d,className:`w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg transition-colors ${d?"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed opacity-60"}`,children:[e.jsx("span",{className:"text-sm",children:"AI Validation Mode"}),e.jsx("span",{className:`text-xs font-medium ${E&&d?"text-cc-success":"text-cc-muted"}`,children:E&&d?"On":"Off"})]}),!d&&e.jsx("p",{className:"text-[11px] text-cc-warning",children:"Configure an Anthropic API key above to enable AI validation."}),E&&d&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>ce("aiValidationAutoApprove"),className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm",children:"Auto-approve safe tools"}),e.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5",children:"Automatically allow read-only tools and benign commands"})]}),e.jsx("span",{className:`text-xs font-medium ${L?"text-cc-success":"text-cc-muted"}`,children:L?"On":"Off"})]}),e.jsxs("button",{type:"button",onClick:()=>ce("aiValidationAutoDeny"),className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm",children:"Auto-deny dangerous tools"}),e.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5",children:"Automatically block destructive commands like rm -rf"})]}),e.jsx("span",{className:`text-xs font-medium ${F?"text-cc-success":"text-cc-muted"}`,children:F?"On":"Off"})]})]})]})]}),e.jsxs("section",{id:"dashboard",ref:l("dashboard"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Project Dashboard"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs text-cc-muted leading-relaxed",children:["A nightly job summarizes every session with recent activity so the"," ",e.jsx("a",{href:"#/dashboard",className:"underline hover:no-underline",children:"dashboard"})," ",'can show where each project stands. It runs through the Claude Code CLI with the same login your normal sessions use — no separate API key needed. This is opt-in because it spends tokens every night. You can always refresh manually with "Update now" on the dashboard, even when the nightly run is off.']}),e.jsxs("button",{type:"button",onClick:ut,className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:[e.jsx("span",{className:"text-sm",children:"Nightly dashboard updates"}),e.jsx("span",{className:`text-xs font-medium ${B?"text-cc-success":"text-cc-muted"}`,children:B?"On":"Off"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"dashboard-model",children:"Summarization model"}),e.jsxs("select",{id:"dashboard-model",value:we,onChange:t=>{const a=we;_(t.target.value),ne({dashboardModel:t.target.value},()=>_(a))},className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow",children:[e.jsx("option",{value:"claude-haiku-4-5",children:"Claude Haiku 4.5 — cheapest, recommended"}),e.jsx("option",{value:"claude-sonnet-4-6",children:"Claude Sonnet 4.6"}),e.jsx("option",{value:"claude-sonnet-5",children:"Claude Sonnet 5"})]}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:"Summarize-and-classify doesn't need an expensive model — Haiku keeps the nightly cost low."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"dashboard-run-hour",children:"Run at"}),e.jsx("select",{id:"dashboard-run-hour",value:Se,onChange:t=>{const a=Se,n=Number(t.target.value);G(n),ne({dashboardRunHour:n},()=>G(a))},className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow",children:Array.from({length:24},(t,a)=>e.jsxs("option",{value:a,children:[String(a).padStart(2,"0"),":00"]},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",htmlFor:"dashboard-max-sessions",children:"Max sessions per run"}),e.jsx("select",{id:"dashboard-max-sessions",value:Ce,onChange:t=>{const a=Ce,n=Number(t.target.value);q(n),ne({dashboardMaxSessionsPerRun:n},()=>q(a))},className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow",children:[10,20,30,50,100,200].map(t=>e.jsx("option",{value:t,children:t},t))})]})]})]})]}),e.jsxs("section",{id:"updates",ref:l("updates"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Updates"}),e.jsxs("div",{className:"space-y-3",children:[r?e.jsxs("p",{className:"text-xs text-cc-muted",children:["Current version: v",r.currentVersion,r.latestVersion?` • Latest: v${r.latestVersion}`:"",r.channel==="prerelease"?" (prerelease)":""]}):e.jsx("p",{className:"text-xs text-cc-muted",children:"Version information not loaded yet."}),e.jsxs("div",{children:[e.jsx("span",{id:"update-channel-label",className:"block text-sm font-medium mb-1.5",children:"Update Channel"}),e.jsxs("div",{className:"flex gap-1",role:"radiogroup","aria-labelledby":"update-channel-label",children:[e.jsx("button",{type:"button",role:"radio","aria-checked":x==="stable",onClick:async()=>{if(x!=="stable"){y("stable");try{await c.updateSettings({updateChannel:"stable"})}catch{y("prerelease");return}try{const t=await c.forceCheckForUpdate();P(t)}catch{}}},className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${x==="stable"?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg hover:bg-cc-active"}`,children:"Stable"}),e.jsx("button",{type:"button",role:"radio","aria-checked":x==="prerelease",onClick:async()=>{if(x!=="prerelease"){y("prerelease");try{await c.updateSettings({updateChannel:"prerelease"})}catch{y("stable");return}try{const t=await c.forceCheckForUpdate();P(t)}catch{}}},className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer ${x==="prerelease"?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg hover:bg-cc-active"}`,children:"Prerelease"})]}),e.jsx("p",{className:"mt-1.5 text-xs text-cc-muted",children:x==="prerelease"?"Tracking prerelease channel. You will receive preview builds from the latest main branch.":"Tracking stable channel. You will only receive versioned releases."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Auto-update Docker image"}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted",children:"Automatically re-pull the sandbox Docker image when updating The Companion"})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":C,onClick:async()=>{const t=!C;I(t);try{await c.updateSettings({dockerAutoUpdate:t})}catch{I(!t)}},className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${C?"bg-cc-primary":"bg-cc-hover"}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform transition-transform ${C?"translate-x-5":"translate-x-0"}`})})]}),Ne&&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:Ne}),je&&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:je}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:xt,disabled:O,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${O?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:O?"Checking...":"Check for updates"}),r!=null&&r.isServiceMode?e.jsx("button",{type:"button",onClick:pt,disabled:M||r.updateInProgress||!r.updateAvailable,className:`px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${M||r.updateInProgress||!r.updateAvailable?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:M||r.updateInProgress?"Updating...":"Update & Restart"}):e.jsxs("p",{className:"text-xs text-cc-muted self-center",children:["Install service mode with ",e.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"the-companion install"})," to enable one-click updates."]})]})]})]}),e.jsxs("section",{id:"telemetry",ref:l("telemetry"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Telemetry"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Anonymous product analytics and crash reports via PostHog to improve reliability."}),e.jsxs("button",{type:"button",onClick:()=>{const t=!ke;bt(t),at(t)},className:"w-full flex items-center justify-between px-3 py-3 min-h-[44px] rounded-lg text-sm bg-cc-hover text-cc-fg hover:bg-cc-active transition-colors cursor-pointer",children:[e.jsx("span",{children:"Usage analytics and errors"}),e.jsx("span",{className:"text-xs text-cc-muted",children:ke?"On":"Off"})]}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Browser Do Not Track is respected automatically."})]})]}),e.jsxs("section",{id:"environments",ref:l("environments"),children:[e.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:"Environments"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-cc-muted",children:"Manage reusable environment profiles used when creating sessions."}),e.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/environments"},className:"px-3 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Open Environments Page"})]})]})]})})]})]})}export{vt as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,a as i,j as e,u as d,n as N,b as y}from"./index-DOle27vf.js";function T({embedded:x=!1}){const[t,r]=l.useState(null),[a,h]=l.useState(!0),[c,o]=l.useState(!1),[g,m]=l.useState(!1);l.useEffect(()=>{i.getTailscaleStatus().then(r).catch(()=>r(null)).finally(()=>h(!1))},[]);async function u(){const s=await i.getTailscaleStatus().catch(()=>null);s&&r(s)}async function p(){o(!0);try{const s=await i.startTailscaleFunnel();r(s),s.funnelUrl&&!s.error&&!s.warning&&d.getState().setPublicUrl(s.funnelUrl)}catch(s){await u(),r(n=>n?{...n,error:s instanceof Error?s.message:String(s)}:null)}finally{o(!1)}}async function b(){o(!0);try{const s=await i.stopTailscaleFunnel();r(s);const n=d.getState().publicUrl;(!n||n===(t==null?void 0:t.funnelUrl))&&d.getState().setPublicUrl("")}catch(s){await u(),r(n=>n?{...n,error:s instanceof Error?s.message:String(s)}:null)}finally{o(!1)}}function f(){t!=null&&t.funnelUrl&&navigator.clipboard.writeText(t.funnelUrl).then(()=>{m(!0),setTimeout(()=>m(!1),1800)}).catch(()=>{})}const j=t?t.installed?t.connected?t.funnelActive?"Funnel active":"Ready":"Not connected":"Not installed":"Loading...",v=t?!t.installed||!t.connected?"text-cc-muted":t.funnelActive?"text-cc-success":"text-amber-500":"text-cc-muted";return e.jsx("div",{className:`${x?"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:"Tailscale Settings"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Expose your Companion over HTTPS with Tailscale Funnel."})]}),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"}),!x&&e.jsx("button",{onClick:()=>{const s=d.getState().currentSessionId;s?N(s):y()},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(6,182,212,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("svg",{className:"w-3.5 h-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 Integration"})]}),e.jsx("h2",{className:"mt-3 text-lg sm:text-xl font-semibold text-cc-fg",children:"HTTPS access in one click"}),e.jsx("p",{className:"mt-1.5 text-sm text-cc-muted max-w-2xl",children:"Tailscale Funnel exposes your Companion to the internet over HTTPS with automatic TLS certificates. No configuration needed."}),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:"Automatic TLS"}),e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"Stable *.ts.net domain"}),e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"No API keys needed"})]})]}),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 ${v}`,children:j}),e.jsx("p",{className:"mt-0.5 text-[11px] text-cc-muted truncate",children:(t==null?void 0:t.dnsName)||"No machine name"})]})]})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-4",children:[e.jsxs("h2",{className:"text-sm font-semibold text-cc-fg flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 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 Funnel"})]}),a&&e.jsx("p",{className:"text-sm text-cc-muted",children:"Checking Tailscale status..."}),!a&&!t&&e.jsx("p",{className:"text-sm text-cc-muted",children:"Could not check Tailscale status."}),!a&&t&&!t.installed&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"Tailscale is not installed on this machine. Install it to enable one-click HTTPS."}),e.jsxs("a",{href:"https://tailscale.com/download",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors",children:["Install Tailscale",e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})]}),!a&&t&&t.installed&&!t.connected&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"Tailscale is installed but not connected to a tailnet."}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-hover text-xs text-cc-fg font-mono-code",children:"tailscale up"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Run this command to connect to your Tailscale network."})]}),!a&&t&&t.installed&&t.connected&&!t.funnelActive&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-cc-muted",children:["Tailscale is connected as ",e.jsx("span",{className:"font-medium text-cc-fg",children:t.dnsName}),". Enable Funnel to expose your Companion over HTTPS."]}),t.needsOperatorMode&&!t.error&&e.jsxs("div",{className:"space-y-2 px-3 py-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[e.jsx("p",{className:"text-xs text-amber-500 font-medium",children:"Setup needed: Tailscale operator mode"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"On Linux, Tailscale requires operator mode to manage Funnel. Run this command first:"}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-hover text-xs text-cc-fg font-mono-code",children:"sudo tailscale set --operator=$USER"})]}),e.jsx("button",{type:"button",onClick:p,disabled:c,className:`px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${c?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:c?"Starting...":"Enable HTTPS via Tailscale Funnel"})]}),!a&&t&&t.installed&&t.connected&&t.funnelActive&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"Funnel is active. Your Companion is accessible at:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:t.funnelUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"flex-1 px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-primary font-mono-code truncate flex items-center hover:underline",children:t.funnelUrl}),e.jsx("button",{type:"button",onClick:f,className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:g?"Copied!":"Copy"})]}),e.jsx("p",{className:"text-xs text-cc-muted",children:"This URL has been automatically set as your Public URL in Settings."}),e.jsx("button",{type:"button",onClick:b,disabled:c,className:`px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${c?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-error/10 hover:bg-cc-error/20 text-cc-error cursor-pointer"}`,children:c?"Stopping...":"Disable Funnel"})]}),(t==null?void 0:t.error)&&t.needsOperatorMode&&e.jsxs("div",{className:"space-y-3 px-3 py-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[e.jsx("p",{className:"text-sm font-medium text-amber-500",children:"Operator mode required"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"On Linux, Tailscale requires operator mode to manage Funnel without sudo. Run this command once in your terminal:"}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-hover text-xs text-cc-fg font-mono-code",children:"sudo tailscale set --operator=$USER"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"After running the command, click Retry to enable Funnel."}),e.jsx("button",{type:"button",onClick:p,disabled:c,className:`px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${c?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:c?"Retrying...":"Retry"})]}),(t==null?void 0:t.warning)&&e.jsxs("div",{className:"space-y-2 px-3 py-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[e.jsx("p",{className:"text-sm font-medium text-amber-500",children:"URL may not be publicly accessible"}),e.jsx("p",{className:"text-xs text-cc-muted",children:t.warning}),e.jsxs("a",{href:"https://login.tailscale.com/admin/acls",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs text-cc-primary hover:underline",children:["Open Tailscale admin console",e.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})]}),(t==null?void 0:t.error)&&!t.needsOperatorMode&&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:t.error})]}),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. Install"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"Install Tailscale on your machine and sign in."})]}),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. Enable"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"One click to get an HTTPS URL with automatic TLS."})]}),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. Done"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"Webhooks and remote access just work."})]})]})]})})}export{T as TailscalePage};
|
|
1
|
+
import{r as l,a as i,j as e,u as d,n as N,b as y}from"./index-Daik8cew.js";function T({embedded:x=!1}){const[t,r]=l.useState(null),[a,h]=l.useState(!0),[c,o]=l.useState(!1),[g,m]=l.useState(!1);l.useEffect(()=>{i.getTailscaleStatus().then(r).catch(()=>r(null)).finally(()=>h(!1))},[]);async function u(){const s=await i.getTailscaleStatus().catch(()=>null);s&&r(s)}async function p(){o(!0);try{const s=await i.startTailscaleFunnel();r(s),s.funnelUrl&&!s.error&&!s.warning&&d.getState().setPublicUrl(s.funnelUrl)}catch(s){await u(),r(n=>n?{...n,error:s instanceof Error?s.message:String(s)}:null)}finally{o(!1)}}async function b(){o(!0);try{const s=await i.stopTailscaleFunnel();r(s);const n=d.getState().publicUrl;(!n||n===(t==null?void 0:t.funnelUrl))&&d.getState().setPublicUrl("")}catch(s){await u(),r(n=>n?{...n,error:s instanceof Error?s.message:String(s)}:null)}finally{o(!1)}}function f(){t!=null&&t.funnelUrl&&navigator.clipboard.writeText(t.funnelUrl).then(()=>{m(!0),setTimeout(()=>m(!1),1800)}).catch(()=>{})}const j=t?t.installed?t.connected?t.funnelActive?"Funnel active":"Ready":"Not connected":"Not installed":"Loading...",v=t?!t.installed||!t.connected?"text-cc-muted":t.funnelActive?"text-cc-success":"text-amber-500":"text-cc-muted";return e.jsx("div",{className:`${x?"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:"Tailscale Settings"}),e.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Expose your Companion over HTTPS with Tailscale Funnel."})]}),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"}),!x&&e.jsx("button",{onClick:()=>{const s=d.getState().currentSessionId;s?N(s):y()},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(6,182,212,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("svg",{className:"w-3.5 h-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 Integration"})]}),e.jsx("h2",{className:"mt-3 text-lg sm:text-xl font-semibold text-cc-fg",children:"HTTPS access in one click"}),e.jsx("p",{className:"mt-1.5 text-sm text-cc-muted max-w-2xl",children:"Tailscale Funnel exposes your Companion to the internet over HTTPS with automatic TLS certificates. No configuration needed."}),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:"Automatic TLS"}),e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"Stable *.ts.net domain"}),e.jsx("span",{className:"px-2 py-1 rounded-md bg-cc-hover text-cc-muted",children:"No API keys needed"})]})]}),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 ${v}`,children:j}),e.jsx("p",{className:"mt-0.5 text-[11px] text-cc-muted truncate",children:(t==null?void 0:t.dnsName)||"No machine name"})]})]})]}),e.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-4",children:[e.jsxs("h2",{className:"text-sm font-semibold text-cc-fg flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 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 Funnel"})]}),a&&e.jsx("p",{className:"text-sm text-cc-muted",children:"Checking Tailscale status..."}),!a&&!t&&e.jsx("p",{className:"text-sm text-cc-muted",children:"Could not check Tailscale status."}),!a&&t&&!t.installed&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"Tailscale is not installed on this machine. Install it to enable one-click HTTPS."}),e.jsxs("a",{href:"https://tailscale.com/download",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors",children:["Install Tailscale",e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})]}),!a&&t&&t.installed&&!t.connected&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"Tailscale is installed but not connected to a tailnet."}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-hover text-xs text-cc-fg font-mono-code",children:"tailscale up"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Run this command to connect to your Tailscale network."})]}),!a&&t&&t.installed&&t.connected&&!t.funnelActive&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-cc-muted",children:["Tailscale is connected as ",e.jsx("span",{className:"font-medium text-cc-fg",children:t.dnsName}),". Enable Funnel to expose your Companion over HTTPS."]}),t.needsOperatorMode&&!t.error&&e.jsxs("div",{className:"space-y-2 px-3 py-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[e.jsx("p",{className:"text-xs text-amber-500 font-medium",children:"Setup needed: Tailscale operator mode"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"On Linux, Tailscale requires operator mode to manage Funnel. Run this command first:"}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-hover text-xs text-cc-fg font-mono-code",children:"sudo tailscale set --operator=$USER"})]}),e.jsx("button",{type:"button",onClick:p,disabled:c,className:`px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${c?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:c?"Starting...":"Enable HTTPS via Tailscale Funnel"})]}),!a&&t&&t.installed&&t.connected&&t.funnelActive&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-cc-muted",children:"Funnel is active. Your Companion is accessible at:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:t.funnelUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"flex-1 px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-primary font-mono-code truncate flex items-center hover:underline",children:t.funnelUrl}),e.jsx("button",{type:"button",onClick:f,className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:g?"Copied!":"Copy"})]}),e.jsx("p",{className:"text-xs text-cc-muted",children:"This URL has been automatically set as your Public URL in Settings."}),e.jsx("button",{type:"button",onClick:b,disabled:c,className:`px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${c?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-error/10 hover:bg-cc-error/20 text-cc-error cursor-pointer"}`,children:c?"Stopping...":"Disable Funnel"})]}),(t==null?void 0:t.error)&&t.needsOperatorMode&&e.jsxs("div",{className:"space-y-3 px-3 py-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[e.jsx("p",{className:"text-sm font-medium text-amber-500",children:"Operator mode required"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"On Linux, Tailscale requires operator mode to manage Funnel without sudo. Run this command once in your terminal:"}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-hover text-xs text-cc-fg font-mono-code",children:"sudo tailscale set --operator=$USER"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"After running the command, click Retry to enable Funnel."}),e.jsx("button",{type:"button",onClick:p,disabled:c,className:`px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${c?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:c?"Retrying...":"Retry"})]}),(t==null?void 0:t.warning)&&e.jsxs("div",{className:"space-y-2 px-3 py-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[e.jsx("p",{className:"text-sm font-medium text-amber-500",children:"URL may not be publicly accessible"}),e.jsx("p",{className:"text-xs text-cc-muted",children:t.warning}),e.jsxs("a",{href:"https://login.tailscale.com/admin/acls",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs text-cc-primary hover:underline",children:["Open Tailscale admin console",e.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})]})]}),(t==null?void 0:t.error)&&!t.needsOperatorMode&&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:t.error})]}),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. Install"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"Install Tailscale on your machine and sign in."})]}),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. Enable"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"One click to get an HTTPS URL with automatic TLS."})]}),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. Done"}),e.jsx("p",{className:"mt-1 text-sm text-cc-fg",children:"Webhooks and remote access just work."})]})]})]})})}export{T as TailscalePage};
|