codepiper 0.1.3 → 0.1.4
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/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/packages/web/dist/assets/{AnalyticsPage-BYagkp3s.js → AnalyticsPage-tt9VQaeG.js} +1 -1
- package/packages/web/dist/assets/{PoliciesPage-BPJeu1hF.js → PoliciesPage-GcKOy8iE.js} +1 -1
- package/packages/web/dist/assets/{SessionDetailPage-BC2DfzCW.js → SessionDetailPage-CXhaRigf.js} +1 -1
- package/packages/web/dist/assets/SettingsPage-XpiwINnF.js +37 -0
- package/packages/web/dist/assets/{WorkflowsPage-CRyRneVm.js → WorkflowsPage-ByyUhe7P.js} +1 -1
- package/packages/web/dist/assets/{index-BuCQxpOr.js → index-DcbqZfqt.js} +3 -3
- package/packages/web/dist/assets/{pencil-CjFCN0Ny.js → pencil-CSMVe0ds.js} +1 -1
- package/packages/web/dist/assets/{refresh-cw-5PEoFw1w.js → refresh-cw-CdfhRXCd.js} +1 -1
- package/packages/web/dist/assets/{tabs-NNVeDvzk.js → tabs-Ckbv8J0d.js} +1 -1
- package/packages/web/dist/assets/{trash-2-T1eK0jKE.js → trash-2-DCNTb20S.js} +1 -1
- package/packages/web/dist/index.html +1 -1
- package/packages/web/dist/assets/SettingsPage-DK3nS17U.js +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,11 @@ This project follows [Semantic Versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.4] - 2026-02-20
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- Normalized npm `bin` path (`bin/codepiper`) to prevent npm publish auto-correction.
|
|
13
|
+
|
|
9
14
|
## [0.1.3] - 2026-02-20
|
|
10
15
|
|
|
11
16
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i,j as e}from"./react-vendor-B5MgMUHH.js";import{c as A,a as f,f as h,u as U,S as ne,b as le,d as ce,e as de,g as N,B as xe,M as me,A as he,Z as pe}from"./index-
|
|
1
|
+
import{r as i,j as e}from"./react-vendor-B5MgMUHH.js";import{c as A,a as f,f as h,u as U,S as ne,b as le,d as ce,e as de,g as N,B as xe,M as me,A as he,Z as pe}from"./index-DcbqZfqt.js";import{R as g,A as B,C as E,X as w,Y as S,T as v,a as u,B as K,b as F,P as ue,d as fe,e as je}from"./chart-vendor-DlOHLaCG.js";import"./monaco-core-DQ5Mk8AK.js";/**
|
|
2
2
|
* @license lucide-react v0.564.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as c,j as e}from"./react-vendor-B5MgMUHH.js";import{c as z,S as V,b as O,d as U,e as q,g as y,h as v,i as B,j as f,u,B as p,P as D,I as j,D as S,k as $,l as F,m as I,n as E,o as R,p as T,C as X,q as J,X as K,r as L}from"./index-
|
|
1
|
+
import{r as c,j as e}from"./react-vendor-B5MgMUHH.js";import{c as z,S as V,b as O,d as U,e as q,g as y,h as v,i as B,j as f,u,B as p,P as D,I as j,D as S,k as $,l as F,m as I,n as E,o as R,p as T,C as X,q as J,X as K,r as L}from"./index-DcbqZfqt.js";import{T as _}from"./trash-2-DCNTb20S.js";import{P as Q,L as k}from"./pencil-CSMVe0ds.js";import{T as Y,a as Z,b as C,c as P}from"./tabs-Ckbv8J0d.js";import"./monaco-core-DQ5Mk8AK.js";import"./chart-vendor-DlOHLaCG.js";/**
|
|
2
2
|
* @license lucide-react v0.564.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
package/packages/web/dist/assets/{SessionDetailPage-BC2DfzCW.js → SessionDetailPage-CXhaRigf.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monacoSetup-DvBj52bT.js","assets/monaco-react-DfZNWvtW.js","assets/react-vendor-B5MgMUHH.js","assets/monaco-core-DQ5Mk8AK.js","assets/monaco-core-B_19GPAS.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as u,j as t,k as ur,l as hs,o as gt,m as pt,n as wn,p as At,q as Vt,t as ps,w as dr,E as xs,x as kn,y as Rt,z as ke,A as gs,C as bs,D as We,F as Zt,G as ys,H as St,I as ft,J as vs,M as ws,K as ks,u as js}from"./react-vendor-B5MgMUHH.js";import{c as K,j as A,q as xt,i as Gt,S as mr,b as fr,G as jn,d as hr,e as pr,g as pn,s as Ns,a as Qe,t as xr,C as gr,u as q,T as Cs,v as Ss,B as Ke,P as Es,X as et,r as Rs,h as Et,L as br,w as Ae,x as yr,M as vr,y as en,z as wr,E as Ts,F as As,H as Ms,J as Ds,K as Ps,N as Ls,O as _s,Q as Fs,R as zs,U as $s,I as Is,V as Os,W as Bs,Y as Hs,_ as Us,$ as qs}from"./index-
|
|
2
|
+
import{r as u,j as t,k as ur,l as hs,o as gt,m as pt,n as wn,p as At,q as Vt,t as ps,w as dr,E as xs,x as kn,y as Rt,z as ke,A as gs,C as bs,D as We,F as Zt,G as ys,H as St,I as ft,J as vs,M as ws,K as ks,u as js}from"./react-vendor-B5MgMUHH.js";import{c as K,j as A,q as xt,i as Gt,S as mr,b as fr,G as jn,d as hr,e as pr,g as pn,s as Ns,a as Qe,t as xr,C as gr,u as q,T as Cs,v as Ss,B as Ke,P as Es,X as et,r as Rs,h as Et,L as br,w as Ae,x as yr,M as vr,y as en,z as wr,E as Ts,F as As,H as Ms,J as Ds,K as Ps,N as Ls,O as _s,Q as Fs,R as zs,U as $s,I as Is,V as Os,W as Bs,Y as Hs,_ as Us,$ as qs}from"./index-DcbqZfqt.js";import{_ as In}from"./monaco-core-DQ5Mk8AK.js";import{R as Vs}from"./refresh-cw-CdfhRXCd.js";import{L as On,P as Ks}from"./pencil-CSMVe0ds.js";import{x as Gs,a as Ws}from"./terminal-vendor-Cs8KPbV3.js";import{T as Qs,a as Ys,b as Xs,c as kt}from"./tabs-Ckbv8J0d.js";import"./chart-vendor-DlOHLaCG.js";/**
|
|
3
3
|
* @license lucide-react v0.564.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{r as a,j as e}from"./react-vendor-B5MgMUHH.js";import{c as $,F as gs,a0 as Y,j as C,u as t,a1 as ys,a2 as vs,z as js,r as pe,Z as Ns,a3 as Re,a4 as ws,a as Ue,a5 as ks,a6 as Me,D as J,k as qe,B as P,P as X,l as ee,m as se,n as te,o as ae,I as T,p as re,a7 as he,C as Ss,q as Cs,a8 as V,a9 as Ps,x as Le,aa as Es,ab as me,ac as As}from"./index-DcbqZfqt.js";import{R as $e}from"./refresh-cw-CdfhRXCd.js";import{T as We}from"./trash-2-DCNTb20S.js";import{T as Ds,a as Fs,b as G,c as Q}from"./tabs-Ckbv8J0d.js";import"./monaco-core-DQ5Mk8AK.js";import"./chart-vendor-DlOHLaCG.js";/**
|
|
2
|
+
* @license lucide-react v0.564.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Ts=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],_s=$("bug",Ts);/**
|
|
7
|
+
* @license lucide-react v0.564.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Rs=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Ie=$("key",Rs);/**
|
|
12
|
+
* @license lucide-react v0.564.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Us=[["path",{d:"M5 12h14",key:"1ays0h"}]],Ve=$("minus",Us);/**
|
|
17
|
+
* @license lucide-react v0.564.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Ms=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Ke=$("pen",Ms);/**
|
|
22
|
+
* @license lucide-react v0.564.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Ls=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Be=$("rotate-ccw",Ls);/**
|
|
27
|
+
* @license lucide-react v0.564.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const $s=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Is=$("shield-check",$s);/**
|
|
32
|
+
* @license lucide-react v0.564.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const Hs=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],qs=$("shield-off",Hs);function _({checked:r,onClick:m,disabled:d=!1,danger:u=!1,compact:h=!1,title:x}){return e.jsx("button",{type:"button",role:"switch","aria-checked":r,onClick:m,disabled:d,title:x,className:Ue("inline-flex shrink-0 items-center rounded-full border px-0.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",h?"h-5 w-9":"h-6 w-11",r?u?"border-red-400/70 bg-red-500/95":"border-cyan-400/70 bg-cyan-500/95":"border-border/70 bg-muted-foreground/25"),children:e.jsx("span",{className:Ue("pointer-events-none block rounded-full bg-white shadow-[0_1px_2px_rgba(0,0,0,0.3)] transition-transform",h?"h-4 w-4":"h-5 w-5",r?h?"translate-x-4":"translate-x-5":"translate-x-0")})})}const Ws=[{enabledKey:"wsPtyPasteEnabled",label:"WS PTY paste transport",description:"Enables pty_paste chunk transport for large clipboard input."},{enabledKey:"latencyProbesEnabled",label:"Terminal latency probes",description:"Captures key-to-echo, scroll-to-paint, and reconnect-resync latency metrics."},{enabledKey:"diagnosticsPanelEnabled",label:"Hidden diagnostics panel",description:"Allows Ctrl/Cmd+Shift+D diagnostics overlay in terminal view."},{enabledKey:"codexAppServerSpikeEnabled",label:"Codex app-server spike (scaffold)",description:"Experimental provider wiring path for future Codex app-server transport; currently no-op runtime scaffold."}];function He(){return{wsPtyPasteEnabled:!0,latencyProbesEnabled:!0,diagnosticsPanelEnabled:!1,codexAppServerSpikeEnabled:!1,wsPtyPasteCanaryPercent:100,latencyProbesCanaryPercent:100,diagnosticsPanelCanaryPercent:0}}const Vs={feature_disabled:"Daemon push feature is disabled (`CODEPIPER_PUSH_ENABLED` != 1).",missing_vapid_public_key:"Daemon VAPID public key is missing (`CODEPIPER_PUSH_PUBLIC_KEY`).",missing_vapid_private_key:"Daemon VAPID private key is missing (`CODEPIPER_PUSH_PRIVATE_KEY`).",invalid_vapid_configuration:"Daemon VAPID configuration is invalid.",daemon_notifications_disabled:"Global notifications are disabled in daemon settings.",daemon_system_notifications_disabled:"System notifications are disabled in daemon settings.",not_available:"Daemon push runtime status is unavailable."};function Ks(r){return Vs[r]??r.replace(/_/g," ")}function Z(){return typeof window>"u"||typeof window.Notification>"u"||!window.isSecureContext?"unsupported":window.Notification.permission}function W(){return typeof window<"u"&&window.isSecureContext&&"serviceWorker"in navigator&&"PushManager"in window}function Bs(){return null}function Os(r){const m="=".repeat((4-r.length%4)%4),d=`${r}${m}`.replace(/-/g,"+").replace(/_/g,"/"),u=window.atob(d),h=new Uint8Array(new ArrayBuffer(u.length));for(let x=0;x<u.length;x+=1)h[x]=u.charCodeAt(x);return h.buffer}function xe(r){if(!r)return null;const m=new Uint8Array(r);let d="";for(const u of m)d+=String.fromCharCode(u);return window.btoa(d).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function zs(r,m){var u;const d=(u=r.options)==null?void 0:u.applicationServerKey;return d?xe(d)===m:!0}function Ys(r){const m=xe(r.getKey("p256dh")),d=xe(r.getKey("auth"));return m&&d?{endpoint:r.endpoint,expirationTime:r.expirationTime??null,keys:{p256dh:m,auth:d}}:null}async function ce(){if(!W())return null;try{const r=await navigator.serviceWorker.getRegistration();if(r)return Re(r),r;const m=await navigator.serviceWorker.register(ws());return Re(m),m}catch{return null}}async function Gs(r){return await new Promise((m,d)=>{const u=new FileReader;u.onload=()=>{if(typeof u.result=="string"){m(u.result);return}d(new Error("Failed to read sound file"))},u.onerror=()=>d(u.error??new Error("Failed to read sound file")),u.readAsDataURL(r)})}function Qs(){const{refreshSettings:r}=gs(),[m,d]=a.useState(!1),[u,h]=a.useState("ask"),[x,f]=a.useState(!0),[y,p]=a.useState(!1),[b,i]=a.useState(!1),[o,k]=a.useState(!1),[w,D]=a.useState(!0),[v,c]=a.useState({}),[g,F]=a.useState({default:Y}),[R,K]=a.useState(null),[U,ne]=a.useState(()=>Z()),[I,Oe]=a.useState({localEndpoint:null,daemonHasLocalEndpoint:!1,daemonSubscriptionCount:0,checkedAt:null}),[B,be]=a.useState(!1),[fe,ge]=a.useState(null),[E,ye]=a.useState(null),[ve,je]=a.useState(null),[oe,Ne]=a.useState(!1),[we,ze]=a.useState(He()),[Ye,Ge]=a.useState(!0),[S,ke]=a.useState(!1),[N,Se]=a.useState(!1),O=a.useCallback(s=>{d(s.preserveSessions),h(s.defaultPolicyAction??"ask"),f(s.forwardSshAuthSock??!0),p(s.codexHostAccessProfileEnabled??!1),i(s.notificationsEnabled??!1),k(s.systemNotificationsEnabled??!1),D(s.notificationSoundsEnabled??!0),c(s.notificationEventDefaults??{}),F({default:Y,...s.notificationSoundMap??{}}),ne(Z());const n=s.terminalFeatures??He();ze(n)},[]),Ce=a.useCallback(async()=>{try{const{settings:s}=await C.getDaemonSettings();O(s)}catch{t.error("Failed to load daemon settings")}finally{Ge(!1)}},[O]);a.useEffect(()=>{Ce()},[Ce]);const A=a.useCallback(async s=>{ke(!0);try{const{settings:n}=await C.updateDaemonSettings(s);return O(n),r(),n}finally{ke(!1)}},[r,O]),Qe=async()=>{const s=!m;try{await A({preserveSessions:s}),t.success(s?"Sessions will be preserved on daemon restart":"Sessions will be stopped on daemon shutdown")}catch{t.error("Failed to update setting")}},Ze=async()=>{const s=u==="deny"?"ask":"deny";try{await A({defaultPolicyAction:s}),t.success(s==="deny"?"Unmatched permissions will now be denied by default":"Unmatched permissions will now prompt for approval")}catch{t.error("Failed to update setting")}},Xe=async()=>{const s=!x;try{await A({forwardSshAuthSock:s}),t.success(s?"SSH agent forwarding is enabled for new sessions":"SSH agent forwarding is disabled for new sessions")}catch{t.error("Failed to update setting")}},Je=async()=>{const s=!y;try{await A({codexHostAccessProfileEnabled:s}),t.success(s?"Codex host-access profile enabled for new Codex sessions":"Codex host-access profile disabled")}catch{t.error("Failed to update setting")}},es=async s=>{const n=!we[s.enabledKey],l={[s.enabledKey]:n};try{await A({terminalFeatures:l}),t.success(`${s.label} ${n?"enabled":"disabled"}`)}catch{t.error(`Failed to update ${s.label}`)}},ss=async()=>{const s=!b;try{await A({notificationsEnabled:s}),t.success(s?"Notifications enabled":"Notifications disabled")}catch{t.error("Failed to update notification setting")}},ts=async()=>{if(!b)return;const s=!w;try{await A({notificationSoundsEnabled:s}),t.success(s?"Notification sounds enabled":"Notification sounds disabled")}catch{t.error("Failed to update notification sound setting")}},ie=a.useCallback(()=>{const s=Bs();return s||(typeof(E==null?void 0:E.publicKey)=="string"&&E.publicKey.trim()?E.publicKey.trim():null)},[E==null?void 0:E.publicKey]),de=a.useCallback(async s=>{if(!W())return{status:"skipped",reason:"unsupported"};if(Z()!=="granted")return{status:"skipped",reason:"permission_denied"};const n=await ce();if(!n)return{status:"error",message:"Service worker is not available for push sync"};const l=ie();let j=await n.pushManager.getSubscription();if(s!=null&&s.forceRenew&&j){try{await C.deletePushSubscription(j.endpoint)}catch{}await j.unsubscribe().catch(()=>{}),j=null}if(j&&l&&!zs(j,l)){try{await C.deletePushSubscription(j.endpoint)}catch{}await j.unsubscribe().catch(()=>{}),j=null}if(!j){if(!l)return{status:"skipped",reason:"missing_key"};try{j=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Os(l)})}catch(L){return{status:"error",message:L instanceof Error?L.message:"Push subscription request failed unexpectedly"}}}const q=Ys(j);if(!q)return{status:"skipped",reason:"missing_keys"};try{return await C.upsertPushSubscription(q),{status:"synced"}}catch(L){return{status:"error",message:L instanceof Error?L.message:"Failed to sync push subscription with daemon"}}},[ie]),as=a.useCallback(async()=>{if(!W())return{status:"skipped",reason:"unsupported"};const s=await ce();if(!s)return{status:"error",message:"Service worker is not available for push cleanup"};const n=await s.pushManager.getSubscription();if(!n)return{status:"skipped",reason:"not_subscribed"};try{await C.deletePushSubscription(n.endpoint)}catch{}try{await n.unsubscribe()}catch(l){return{status:"error",message:l instanceof Error?l.message:"Failed to unsubscribe push subscription"}}return{status:"synced"}},[]),M=a.useCallback(async()=>{be(!0),ge(null),je(null);try{let s=null;if(W()){const l=await ce();if(l){const j=await l.pushManager.getSubscription();s=(j==null?void 0:j.endpoint)??null}}let n=[];try{n=(await C.listPushSubscriptions()).subscriptions}catch(l){ge(l instanceof Error?l.message:"Failed to load daemon push subscriptions")}try{const l=await C.getPushDeliveryStatus();ye(l.status)}catch(l){ye(null),je(l instanceof Error?l.message:"Failed to load daemon push runtime status")}Oe({localEndpoint:s,daemonHasLocalEndpoint:s!==null&&n.some(l=>l.endpoint===s),daemonSubscriptionCount:n.length,checkedAt:Date.now()})}finally{be(!1)}},[]);a.useEffect(()=>{M()},[M]);const rs=async()=>{const s=await de({forceRenew:!0});s.status==="synced"?t.success("Push subscription synced"):s.status==="skipped"?s.reason==="missing_key"?t.error("Cannot sync push subscription: daemon/web push public key is unavailable"):s.reason==="permission_denied"?t.error("Cannot sync push subscription: notification permission is not granted"):s.reason==="unsupported"?t.error("Push is not supported on this browser"):t.error("Push subscription is not available to sync"):t.error(`Push sync failed: ${s.message}`),await M()},ns=async()=>{if(!oe){Ne(!0);try{let{result:s}=await C.sendTestPushNotification();if(!s.skipped&&s.delivered===0&&s.failed>0&&(await de({forceRenew:!0})).status==="synced"&&(s=(await C.sendTestPushNotification()).result),s.skipped)s.reason==="no_subscriptions"?t.error("Cannot send test push: no browser subscription is registered"):t.error("Cannot send test push: daemon push runtime is unavailable");else if(s.delivered>0){const n=s.failed>0||s.expired>0?` (${s.failed} failed, ${s.expired} expired)`:"";t.success(`Test push delivered to ${s.delivered}/${s.attempted}${n}`)}else t.error(`Test push reached 0/${s.attempted} subscriptions (${s.failed} failed, ${s.expired} expired)`)}catch(s){t.error(s instanceof Error?s.message:"Failed to send test push notification")}finally{Ne(!1),await M()}}},os=async()=>{if(!b)return;if(!!o){try{const l=await as();await A({systemNotificationsEnabled:!1}),await M(),t.success("System notifications disabled"),l.status==="error"&&t.error(`Push cleanup warning: ${l.message}`)}catch{t.error("Failed to update system notification setting")}return}const n=Z();if(ne(n),n==="unsupported"){t.error("System notifications are unavailable on this browser or origin");return}try{const l=n==="granted"?"granted":await window.Notification.requestPermission();if(ne(l),l!=="granted"){await A({systemNotificationsEnabled:!1}),t.error("System notification permission was not granted");return}const j=await de();await A({systemNotificationsEnabled:!0}),await M(),j.status==="synced"?t.success("System notifications enabled (push synced)"):j.status==="skipped"?j.reason==="missing_key"?t.success("System notifications enabled (push key unavailable)"):j.reason==="unsupported"?t.success("System notifications enabled (push unavailable on this browser)"):t.success("System notifications enabled"):t.error(`System notifications enabled, but push sync failed: ${j.message}`)}catch{t.error("Failed to enable system notifications")}},is=a.useMemo(()=>{const s=new Map(ys.map(n=>[n.key,n]));for(const n of Object.keys(v))s.has(n)||s.set(n,{key:n,label:n});for(const n of Object.keys(g))n!=="default"&&(s.has(n)||s.set(n,{key:n,label:n}));return Array.from(s.values()).sort((n,l)=>n.label.localeCompare(l.label))},[v,g]),ds=async s=>{if(!b)return;const n=v[s]===!1,l={...v,[s]:n};try{await A({notificationEventDefaults:l}),t.success(`${s} ${n?"enabled":"disabled"}`)}catch{t.error(`Failed to update ${s}`)}},Pe=a.useCallback(async s=>{const n=vs(g,s);try{const l=new Audio(n);l.volume=.55,await l.play()}catch{t.error("Unable to preview sound (browser playback may be blocked)")}},[g]),cs=async()=>{const s={...g,default:Y};try{await A({notificationSoundMap:s}),t.success("Default notification sound reset to built-in")}catch{t.error("Failed to reset default sound")}},ls=async s=>{const n={...g};delete n[s];try{await A({notificationSoundMap:n}),t.success(`Using default sound for ${s}`)}catch{t.error(`Failed to reset ${s} sound`)}},Ee=async(s,n)=>{if(n){if(!ks(n)){t.error("Upload a supported audio file (mp3, wav, ogg, m4a, webm, aac, flac)");return}if(n.size>Me){t.error(`Sound file is too large. Maximum size is ${Math.round(Me/1024)}KB.`);return}K(s);try{const l=await Gs(n),j={...g,[s]:l};await A({notificationSoundMap:j}),t.success(s==="default"?"Uploaded new default notification sound":`Uploaded custom sound for ${s}`)}catch{t.error("Failed to upload notification sound")}finally{K(null)}}},us=async()=>{if(!N){Se(!0);try{const s=await C.restartDaemon();t.success(s.message),window.setTimeout(()=>{window.location.reload()},2500)}catch(s){Se(!1),t.error(s instanceof Error?s.message:"Failed to restart daemon")}}},Ae=u==="deny",H=U==="unsupported",ms=U==="denied",xs=U==="default",z=W(),ps=ie()!==null,De=!H,Fe=I.localEndpoint!==null,hs=!!(E!=null&&E.enabled&&E.configured),Te=U==="granted"&&z,bs=(g.default||Y).startsWith("data:"),fs=U==="unsupported"?"Unsupported":U==="default"?"Pending":U;return Ye?e.jsx("div",{className:"flex justify-center items-center h-24",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-cyan-500/30 border-t-cyan-500 rounded-full animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading settings..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Be,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Session Preservation"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 ml-6",children:"Keep active tmux sessions running across daemon restarts."}),e.jsxs("div",{className:"flex items-center gap-3 ml-6",children:[e.jsx(_,{checked:m,onClick:Qe,disabled:S||N}),e.jsx("span",{className:"text-sm",children:m?"Preserve sessions on restart":"Stop sessions on shutdown"})]})]}),e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ie,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"SSH Agent Forwarding"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 ml-6",children:"Forward SSH agent env vars (`SSH_AUTH_SOCK`, `SSH_AGENT_PID`) into new sessions only."}),e.jsxs("div",{className:"flex items-center gap-3 ml-6",children:[e.jsx(_,{checked:x,onClick:Xe,disabled:S||N}),e.jsx("span",{className:"text-sm",children:x?"Forward SSH agent to new sessions":"Do not forward SSH agent"})]})]}),e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(js,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Notifications"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 ml-6",children:"Control notification delivery for completed turns, system banners, and sounds."}),e.jsxs("div",{className:"ml-6 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:"Enable notifications"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Master switch for all notification delivery."})]}),e.jsx(_,{checked:b,onClick:ss,disabled:S||N})]}),!b&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Notifications are off. In-app banners, system alerts, and push delivery are paused until re-enabled."}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:"System notifications"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Requires browser permission and a secure context. Permission is requested only when enabling."})]}),e.jsx(_,{checked:o,onClick:os,disabled:S||N||!b||H})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:"Notification sounds"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enables in-app notification audio cues when supported by browser playback policy."})]}),e.jsx(_,{checked:w,onClick:ts,disabled:S||N||!b})]}),H&&e.jsx("p",{className:"text-xs text-amber-400/90",children:"System notifications are unavailable here. Use HTTPS (or localhost) and a browser that supports the Notification API."}),De&&!z&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Web push is not supported on this browser; local system notifications can still work."}),De&&z&&!ps&&e.jsx("div",{className:"rounded-md border border-border/60 bg-muted/20 px-2.5 py-2",children:e.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Web push is not configured: no public key is available from daemon runtime or web env. Configure daemon VAPID keys and restart daemon. Local system notifications still work on this device."})}),!H&&ms&&e.jsx("p",{className:"text-xs text-amber-400/90",children:"Browser permission is currently denied. Re-enable permission from browser site settings to turn this back on."}),!H&&xs&&e.jsx("div",{className:"rounded-md border border-border/60 bg-muted/20 px-2.5 py-2",children:e.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Notification permission is pending. Enable System notifications to prompt browser permission."})}),e.jsxs("div",{className:"rounded-md border border-border/70 bg-muted/20 p-3 space-y-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Push delivery health"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shows whether this browser push subscription is synced with daemon storage."})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5 shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>void M(),disabled:S||N||B,className:"inline-flex h-8 items-center gap-1 px-2.5 rounded-md text-xs border border-border bg-background/70 hover:bg-accent/60 transition-colors disabled:opacity-50",children:[e.jsx($e,{className:`h-3.5 w-3.5 ${B?"animate-spin":""}`}),"Refresh"]}),e.jsx("button",{type:"button",onClick:()=>void rs(),disabled:S||N||B||!Te,className:"h-8 px-2.5 rounded-md text-xs border border-border bg-background/70 hover:bg-accent/60 transition-colors disabled:opacity-50",children:"Resync"}),e.jsx("button",{type:"button",onClick:()=>void ns(),disabled:S||N||B||oe,className:"h-8 px-2.5 rounded-md text-xs border border-border bg-background/70 hover:bg-accent/60 transition-colors disabled:opacity-50",children:oe?"Testing...":"Test push"})]})]}),e.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[e.jsxs("p",{className:"text-muted-foreground",children:["Daemon push runtime:"," ",e.jsx("span",{className:"text-foreground",children:E?hs?"Ready":E.enabled?"Misconfigured":"Disabled":"Unknown"})]}),e.jsxs("p",{className:"text-muted-foreground",children:["Browser push support:"," ",e.jsx("span",{className:"text-foreground",children:z?"Supported":"Unavailable"})]}),e.jsxs("p",{className:"text-muted-foreground",children:["Notification permission:"," ",e.jsx("span",{className:"text-foreground capitalize",children:fs})]}),e.jsxs("p",{className:"text-muted-foreground",children:["Local subscription:"," ",e.jsx("span",{className:"text-foreground",children:Fe?"Active":"Not subscribed"})]}),e.jsxs("p",{className:"text-muted-foreground",children:["Daemon sync status:"," ",e.jsx("span",{className:"text-foreground",children:Fe?I.daemonHasLocalEndpoint?"Synced":"Missing in daemon":I.daemonSubscriptionCount>0?"No local subscription":"No subscriptions"})]}),e.jsxs("p",{className:"text-muted-foreground sm:col-span-2",children:["Stored daemon subscriptions:"," ",e.jsx("span",{className:"text-foreground",children:I.daemonSubscriptionCount}),I.checkedAt?e.jsxs(e.Fragment,{children:[" ","· Last checked:"," ",e.jsx("span",{className:"text-foreground",children:new Date(I.checkedAt).toLocaleTimeString()})]}):null]})]}),E&&E.reasons.length>0&&e.jsx("div",{className:"space-y-1",children:E.reasons.map(s=>e.jsx("p",{className:"text-[11px] text-muted-foreground",children:Ks(s)},s))}),fe&&e.jsx("p",{className:"text-xs text-amber-400/90",children:fe}),ve&&e.jsx("p",{className:"text-xs text-amber-400/90",children:ve}),!Te&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Resync is available when browser permission is granted and push is supported."})]}),e.jsxs("div",{className:"rounded-md border border-border/70 bg-muted/20 p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Default sound"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:bs?"Custom uploaded sound":"Built-in CodePiper soft chime"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void Pe("session.turn_completed"),disabled:S||N||!b,className:"px-2 py-1 rounded-md text-xs border border-border bg-background/70 hover:bg-accent/60 transition-colors disabled:opacity-50",children:"Test"}),e.jsx("button",{type:"button",onClick:cs,disabled:S||N||!b,className:"px-2 py-1 rounded-md text-xs border border-border bg-background/70 hover:bg-accent/60 transition-colors disabled:opacity-50",children:"Use built-in"}),e.jsxs("label",{className:"px-2 py-1 rounded-md text-xs border border-border bg-background/70 hover:bg-accent/60 transition-colors cursor-pointer",children:[R==="default"?"Uploading...":"Upload",e.jsx("input",{type:"file",accept:"audio/*,.mp3,.wav,.ogg,.m4a,.aac,.webm,.flac",className:"hidden",disabled:S||N||!b,onChange:s=>{var l;const n=((l=s.target.files)==null?void 0:l[0])??null;Ee("default",n),s.currentTarget.value=""}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Per-event overrides"}),is.map(s=>{const n=v[s.key]!==!1,l=g[s.key],j=`notification-sound-${s.key.replace(/[^a-zA-Z0-9-_]/g,"-")}`;return e.jsxs("div",{className:"rounded-md border border-border/60 bg-background/40 p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:s.label}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s.key})]}),e.jsx(_,{compact:!0,checked:n,onClick:()=>void ds(s.key),disabled:S||N||!b,title:n?"Event enabled":"Event disabled"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:l?"Custom sound override":"Uses default sound"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void Pe(s.key),disabled:S||N||!b,className:"px-2 py-1 rounded-md text-[11px] border border-border bg-background/70 hover:bg-accent/60 transition-colors disabled:opacity-50",children:"Test"}),l&&e.jsx("button",{type:"button",onClick:()=>void ls(s.key),disabled:S||N||!b,className:"px-2 py-1 rounded-md text-[11px] border border-border bg-background/70 hover:bg-accent/60 transition-colors disabled:opacity-50",children:"Use default"}),e.jsx("label",{htmlFor:j,className:"px-2 py-1 rounded-md text-[11px] border border-border bg-background/70 hover:bg-accent/60 transition-colors cursor-pointer",children:R===s.key?"Uploading...":"Upload"}),e.jsx("input",{id:j,type:"file",accept:"audio/*,.mp3,.wav,.ogg,.m4a,.aac,.webm,.flac",className:"hidden",disabled:S||N||!b,onChange:q=>{var _e;const L=((_e=q.target.files)==null?void 0:_e[0])??null;Ee(s.key,L),q.currentTarget.value=""}})]})]})]},s.key)})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Uploaded sounds are stored as settings payloads and apply to all clients connected to this daemon."})]})]})]}),e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ie,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Codex Host Access Profile"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 ml-6",children:"When enabled, new Codex sessions launch with `--sandbox danger-full-access -a on-request` to support host-level workflows like GPG signing."}),e.jsxs("div",{className:"flex items-center gap-3 ml-6",children:[e.jsx(_,{checked:y,onClick:Je,disabled:S||N}),e.jsx("span",{className:"text-sm",children:y?"Enable host access profile for new Codex sessions":"Use default Codex sandbox profile"})]})]}),e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(pe,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Default Policy Action"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 ml-6",children:"Applies only when no policy rule matches a permission request."}),e.jsxs("div",{className:"flex items-center gap-3 ml-6",children:[e.jsx(_,{checked:Ae,onClick:Ze,disabled:S||N,danger:!0}),e.jsx("span",{className:"text-sm",children:Ae?"Auto-deny unmatched requests":"Ask for unmatched requests"})]})]}),e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ns,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Terminal Feature Rollout"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 ml-6",children:"Enable or disable terminal transport features for this daemon."}),e.jsx("div",{className:"ml-6 space-y-4",children:Ws.map(s=>e.jsxs("div",{className:"rounded-md border border-border/70 bg-muted/20 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s.description})]}),e.jsx(_,{checked:we[s.enabledKey],onClick:()=>void es(s),disabled:S||N})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Single-user deployment: this flag is on/off only."})]},s.enabledKey))})]}),e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(_s,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Daemon Lifecycle"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 ml-6",children:"Restart daemon from the dashboard to apply daemon-level changes."}),e.jsxs("div",{className:"ml-6 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:us,disabled:S||N,className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md border border-border bg-muted/30 hover:bg-muted/50 text-sm disabled:opacity-50 transition-colors",children:[e.jsx($e,{className:`h-4 w-4 ${N?"animate-spin":""}`}),N?"Restarting...":"Restart Daemon"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Expected reconnect in a few seconds."})]})]})]})}let Zs=0;function le(){return{id:`row-${++Zs}`,key:"",value:""}}function Xs({onCreated:r}){const[m,d]=a.useState(!1),[u,h]=a.useState(!1),[x,f]=a.useState(""),[y,p]=a.useState(""),[b,i]=a.useState([le()]),o=()=>i([...b,le()]),k=v=>{b.length<=1||i(b.filter((c,g)=>g!==v))},w=(v,c,g)=>{i(b.map((F,R)=>R===v?{...F,[c]:g}:F))},D=async()=>{if(!x.trim()){t.error("Name is required");return}const v={};for(const c of b)c.key.trim()&&(v[c.key.trim()]=c.value);if(Object.keys(v).length===0){t.error("At least one variable is required");return}try{h(!0),await C.createEnvSet({name:x.trim(),description:y.trim()||void 0,vars:v}),t.success(`Env set "${x}" created`),d(!1),f(""),p(""),i([le()]),r()}catch(c){t.error(c instanceof Error?c.message:"Failed to create env set")}finally{h(!1)}};return e.jsxs(J,{open:m,onOpenChange:d,children:[e.jsx(qe,{asChild:!0,children:e.jsxs(P,{className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:[e.jsx(X,{className:"h-4 w-4 mr-1.5"}),"New Env Set"]})}),e.jsxs(ee,{className:"border-border bg-popover max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(se,{children:[e.jsx(te,{children:"Create Env Set"}),e.jsx(ae,{className:"text-muted-foreground/60",children:"Define a named collection of environment variables."})]}),e.jsx("div",{className:"border border-amber-500/20 bg-amber-500/[0.04] rounded-lg px-3 py-2.5",children:e.jsx("p",{className:"text-[11px] text-amber-300/80 leading-relaxed",children:"Variables are encrypted at rest. Not intended for critical production secrets."})}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Name"}),e.jsx(T,{placeholder:"dev-api-keys",value:x,onChange:v=>f(v.target.value),className:"bg-background border-border"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Description (optional)"}),e.jsx(T,{placeholder:"API keys for development environment",value:y,onChange:v=>p(v.target.value),className:"bg-background border-border"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-2 block",children:"Variables"}),e.jsx("div",{className:"space-y-2",children:b.map((v,c)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{placeholder:"KEY",value:v.key,onChange:g=>w(c,"key",g.target.value),className:"bg-background border-border font-mono text-xs flex-[2]"}),e.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"="}),e.jsx(T,{type:"password",placeholder:"value",value:v.value,onChange:g=>w(c,"value",g.target.value),className:"bg-background border-border font-mono text-xs flex-[3]"}),e.jsx(P,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-red-400",onClick:()=>k(c),disabled:b.length<=1,children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]},v.id))}),e.jsxs(P,{variant:"outline",size:"sm",onClick:o,className:"mt-2 text-xs h-8 border-dashed",children:[e.jsx(X,{className:"h-3 w-3 mr-1"}),"Add Variable"]})]})]}),e.jsxs(re,{children:[e.jsx(P,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(P,{onClick:D,disabled:u,className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:u?"Creating...":"Create"})]})]})]})}let Js=0;function ue(r="",m=""){return{id:`erow-${++Js}`,key:r,value:m}}function et({envSet:r,open:m,onOpenChange:d,onUpdated:u}){const[h,x]=a.useState(!1),[f,y]=a.useState(r.name),[p,b]=a.useState(r.description||""),[i,o]=a.useState(()=>{const c=Object.entries(r.maskedVars??{});return c.length>0?c.map(([g])=>ue(g,"")):[ue()]}),k=()=>o([...i,ue()]),w=c=>{i.length<=1||o(i.filter((g,F)=>F!==c))},D=(c,g,F)=>{o(i.map((R,K)=>K===c?{...R,[g]:F}:R))},v=async()=>{if(!f.trim()){t.error("Name is required");return}const c={};for(const g of i)g.key.trim()&&(c[g.key.trim()]=g.value);try{x(!0),await C.updateEnvSet(r.id,{name:f.trim(),description:p.trim()||void 0,vars:c}),t.success("Env set updated"),u()}catch(g){t.error(g instanceof Error?g.message:"Failed to update env set")}finally{x(!1)}};return e.jsx(J,{open:m,onOpenChange:d,children:e.jsxs(ee,{className:"border-border bg-popover max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(se,{children:[e.jsx(te,{children:"Edit Env Set"}),e.jsx(ae,{className:"text-muted-foreground/60",children:"Update variables. Re-enter any values you want to change (shown masked)."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Name"}),e.jsx(T,{value:f,onChange:c=>y(c.target.value),className:"bg-background border-border"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Description"}),e.jsx(T,{value:p,onChange:c=>b(c.target.value),className:"bg-background border-border"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-2 block",children:"Variables"}),e.jsx("div",{className:"space-y-2",children:i.map((c,g)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{placeholder:"KEY",value:c.key,onChange:F=>D(g,"key",F.target.value),className:"bg-background border-border font-mono text-xs flex-[2]"}),e.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"="}),e.jsx(T,{type:"password",placeholder:"value",value:c.value,onChange:F=>D(g,"value",F.target.value),className:"bg-background border-border font-mono text-xs flex-[3]"}),e.jsx(P,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0 text-muted-foreground hover:text-red-400",onClick:()=>w(g),disabled:i.length<=1,children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]},c.id))}),e.jsxs(P,{variant:"outline",size:"sm",onClick:k,className:"mt-2 text-xs h-8 border-dashed",children:[e.jsx(X,{className:"h-3 w-3 mr-1"}),"Add Variable"]})]})]}),e.jsxs(re,{children:[e.jsx(P,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(P,{onClick:v,disabled:h,className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:h?"Saving...":"Save"})]})]})})}function st(){const[r,m]=a.useState([]),[d,u]=a.useState(!0),[h,x]=a.useState(null),[f,y]=a.useState(new Set),p=a.useCallback(async()=>{try{const o=await C.getEnvSets();m(o.envSets)}catch{t.error("Failed to load env sets")}finally{u(!1)}},[]);a.useEffect(()=>{p()},[p]);const b=async o=>{try{await C.deleteEnvSet(o.id),t.success(`Deleted env set "${o.name}"`),p()}catch{t.error("Failed to delete env set")}},i=o=>{y(k=>{const w=new Set(k);return w.has(o)?w.delete(o):w.add(o),w})};return d?e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-cyan-500/30 border-t-cyan-500 rounded-full animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading env sets..."})]})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Named collections of environment variables to inject into sessions."})}),e.jsx(Xs,{onCreated:p})]}),e.jsx("div",{className:"border border-amber-500/20 bg-amber-500/[0.04] rounded-lg px-4 py-3 mb-4",children:e.jsx("p",{className:"text-xs text-amber-300/80 leading-relaxed",children:"Environment variables are encrypted at rest but this is not intended for critical secrets like production API keys or database passwords. Use a dedicated secrets manager for production credentials."})}),r.length===0?e.jsxs("div",{className:"border border-dashed border-border rounded-xl p-12 text-center",children:[e.jsx(he,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"No env sets yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Create an env set to inject environment variables into sessions."})]}):e.jsx("div",{className:"grid gap-3",children:r.map(o=>{const k=o.varCount,w=f.has(o.id);return e.jsxs("div",{className:"group border border-border rounded-xl bg-card/50 hover:bg-card/80 transition-all",children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("button",{type:"button",onClick:()=>i(o.id),className:"w-9 h-9 rounded-lg bg-violet-500/[0.08] flex items-center justify-center shrink-0 hover:bg-violet-500/[0.15] transition-colors",children:w?e.jsx(Ss,{className:"h-4 w-4 text-violet-400"}):e.jsx(Cs,{className:"h-4 w-4 text-violet-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:o.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o.description||`${k} variable${k!==1?"s":""}`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[11px] font-mono text-muted-foreground/60 tabular-nums",children:[k," var",k!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(P,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",onClick:()=>x(o),children:e.jsx(Ke,{className:"h-3.5 w-3.5"})}),e.jsx(P,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-red-400",onClick:()=>b(o),children:e.jsx(We,{className:"h-3.5 w-3.5"})})]})]})]}),w&&e.jsx("div",{className:"border-t border-border px-4 py-3",children:e.jsx("div",{className:"space-y-1.5",children:Object.entries(o.maskedVars).map(([D,v])=>e.jsxs("div",{className:"flex items-center gap-2 font-mono text-xs",children:[e.jsx("span",{className:"text-cyan-400 shrink-0",children:D}),e.jsx("span",{className:"text-muted-foreground/40",children:"="}),e.jsx("span",{className:"text-muted-foreground truncate",children:v})]},D))})})]},o.id)})}),h&&e.jsx(et,{envSet:h,open:!0,onOpenChange:o=>{o||x(null)},onUpdated:()=>{x(null),p()}})]})}function tt({onClose:r,onEnabled:m}){const[d,u]=a.useState("qr"),[h,x]=a.useState(null),[f,y]=a.useState(""),[p,b]=a.useState([]),[i,o]=a.useState(""),[k,w]=a.useState(!1),D=async()=>{w(!0),o("");try{const c=await V.mfaSetup();x({qrDataUrl:c.qrDataUrl,secret:c.secret})}catch(c){o(c.message||"Failed to start MFA setup")}finally{w(!1)}},v=async()=>{w(!0),o("");try{const c=await V.mfaVerify(f);b(c.recoveryCodes),u("recovery"),m()}catch(c){o(c.message||"Invalid code")}finally{w(!1)}};return h||k||i||D(),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg shadow-lg w-full max-w-md mx-4 p-6",children:[d==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Set Up Two-Factor Authentication"}),h?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, 1Password, etc.)"}),e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("img",{src:h.qrDataUrl,alt:"TOTP QR Code",className:"w-48 h-48"})}),e.jsxs("details",{className:"mb-4",children:[e.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer",children:"Can't scan? Enter this key manually"}),e.jsx("code",{className:"block mt-2 p-2 bg-muted rounded text-xs font-mono break-all",children:h.secret})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"mfa-code",className:"block text-sm font-medium mb-1",children:"Enter the 6-digit code from your app"}),e.jsx("input",{id:"mfa-code",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:f,onChange:c=>y(c.target.value.replace(/\D/g,"")),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground tracking-widest text-center text-lg focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"000000",autoFocus:!0})]}),i&&e.jsx("div",{className:"p-2 rounded bg-destructive/10 text-destructive text-sm",children:i}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:r,className:"flex-1 py-2 px-4 rounded-md border border-border text-foreground hover:bg-muted transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:v,disabled:k||f.length!==6,className:"flex-1 py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:k?"Verifying...":"Verify"})]})]})]}):k?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"Generating QR code..."}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-destructive mb-2",children:i}),e.jsx("button",{type:"button",onClick:D,className:"text-sm text-primary hover:underline",children:"Try again"})]})]}),d==="recovery"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Save Your Recovery Codes"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Store these codes in a safe place. Each code can only be used once to sign in if you lose access to your authenticator app."}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mb-4 p-3 bg-muted rounded-md",children:p.map(c=>e.jsx("code",{className:"text-sm font-mono text-center py-1",children:c},c))}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(p.join(`
|
|
37
|
+
`))},className:"w-full mb-3 py-2 px-4 rounded-md border border-border text-foreground hover:bg-muted transition-colors text-sm",children:"Copy to clipboard"}),e.jsx("button",{type:"button",onClick:r,className:"w-full py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors",children:"Done"})]})]})})}function at(){return e.jsxs("div",{className:"space-y-8",children:[e.jsx(rt,{}),e.jsx(nt,{}),e.jsx(ot,{})]})}function rt(){const[r,m]=a.useState(""),[d,u]=a.useState(""),[h,x]=a.useState(""),[f,y]=a.useState(""),[p,b]=a.useState(!1),i=async o=>{if(o.preventDefault(),y(""),d.length<8){y("New password must be at least 8 characters");return}if(d!==h){y("Passwords do not match");return}b(!0);try{await V.changePassword(r,d),t.success("Password changed successfully"),m(""),u(""),x("")}catch(k){y(k.message||"Failed to change password")}finally{b(!1)}};return e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(he,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Change Password"})]}),e.jsxs("form",{onSubmit:i,className:"space-y-3 max-w-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"current-password",className:"block text-xs font-medium text-muted-foreground mb-1",children:"Current Password"}),e.jsx("input",{id:"current-password",type:"password",value:r,onChange:o=>m(o.target.value),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground text-sm placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"new-password",className:"block text-xs font-medium text-muted-foreground mb-1",children:"New Password"}),e.jsx("input",{id:"new-password",type:"password",value:d,onChange:o=>u(o.target.value),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground text-sm placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"Minimum 8 characters",required:!0,minLength:8})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm-new-password",className:"block text-xs font-medium text-muted-foreground mb-1",children:"Confirm New Password"}),e.jsx("input",{id:"confirm-new-password",type:"password",value:h,onChange:o=>x(o.target.value),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground text-sm placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",required:!0,minLength:8})]}),f&&e.jsx("div",{className:"p-2 rounded-md bg-destructive/10 text-destructive text-xs",children:f}),e.jsx("button",{type:"submit",disabled:p||!r||d.length<8,className:"py-2 px-4 rounded-md bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:p?"Changing...":"Change Password"})]})]})}function nt(){const{mfaEnabled:r,checkAuth:m}=Ps(),[d,u]=a.useState(!1);return e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(pe,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Two-Factor Authentication"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 ml-6",children:"Add an extra layer of security using an authenticator app."}),e.jsx("div",{className:"flex items-center gap-3 ml-6",children:r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-emerald-500",children:[e.jsx(Is,{className:"h-3.5 w-3.5"}),"Enabled"]}),e.jsx("button",{type:"button",onClick:()=>{var h;if(typeof((h=navigator.clipboard)==null?void 0:h.writeText)!="function"){t.error("Clipboard access is unavailable in this browser context");return}navigator.clipboard.writeText("codepiper auth reset-mfa").then(()=>{t.success("CLI command copied: codepiper auth reset-mfa")}).catch(()=>{t.error("Failed to copy command")})},className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Copy disable command"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(qs,{className:"h-3.5 w-3.5"}),"Not enabled"]}),e.jsx("button",{type:"button",onClick:()=>u(!0),className:"py-1.5 px-3 rounded-md bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/90 transition-colors",children:"Enable 2FA"})]})}),r&&e.jsx("div",{className:"mt-4 ml-6 p-3 rounded-md border border-border bg-muted/40",children:e.jsxs("p",{className:"text-xs text-muted-foreground leading-relaxed",children:["For security hardening, MFA disable is CLI-only. Run"," ",e.jsx("code",{className:"font-mono text-foreground",children:"codepiper auth reset-mfa"})," from a trusted terminal on this machine."]})}),d&&e.jsx(tt,{onClose:()=>u(!1),onEnabled:()=>{m()}})]})}function ot(){const[r,m]=a.useState([]),[d,u]=a.useState(!0),[h,x]=a.useState(!1),f=a.useCallback(async()=>{try{const i=await V.listSessions();m(i.sessions)}catch{t.error("Failed to load sessions")}finally{u(!1)}},[]);a.useEffect(()=>{f()},[f]);const y=async()=>{x(!0);try{await V.revokeAllSessions(),t.success("All other sessions revoked"),f()}catch{t.error("Failed to revoke sessions")}finally{x(!1)}},p=i=>new Date(i).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),b=i=>i?i.includes("Firefox")?"Firefox":i.includes("Edg/")?"Edge":i.includes("Chrome")?"Chrome":i.includes("Safari")?"Safari":i.includes("curl")?"curl":"Browser":"Unknown device";return e.jsxs("div",{className:"border border-border rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Active Sessions"})]}),r.length>1&&e.jsxs("button",{type:"button",onClick:y,disabled:h,className:"flex items-center gap-1.5 text-xs text-destructive hover:underline disabled:opacity-50",children:[e.jsx(Es,{className:"h-3 w-3"}),h?"Revoking...":"Revoke all other sessions"]})]}),d?e.jsx("div",{className:"flex justify-center items-center h-24",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-cyan-500/30 border-t-cyan-500 rounded-full animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading sessions..."})]})}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No active sessions"}):e.jsx("div",{className:"space-y-2",children:r.map((i,o)=>e.jsx("div",{className:"flex items-center justify-between p-3 rounded-md bg-muted/30 border border-border/50",children:e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Le,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[b(i.userAgent),o===0&&e.jsx("span",{className:"ml-2 text-xs text-emerald-500 font-normal",children:"(current)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[i.ipAddress||"Unknown IP"," · Last active"," ",p(i.lastUsedAt)]})]})]})},`${i.createdAt}-${i.ipAddress}`))})]})}function it({onCreated:r}){const[m,d]=a.useState(!1),[u,h]=a.useState(!1),[x,f]=a.useState(""),[y,p]=a.useState(""),b=async()=>{if(!x.trim()){t.error("Workspace name is required");return}if(!y.trim()){t.error("Path is required");return}try{h(!0),await C.createWorkspace({name:x.trim(),path:y.trim()}),t.success(`Workspace "${x}" created`),d(!1),f(""),p(""),r()}catch(i){t.error(i instanceof Error?i.message:"Failed to create workspace")}finally{h(!1)}};return e.jsxs(J,{open:m,onOpenChange:d,children:[e.jsx(qe,{asChild:!0,children:e.jsxs(P,{className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:[e.jsx(X,{className:"h-4 w-4 mr-1.5"}),"New Workspace"]})}),e.jsxs(ee,{className:"border-border bg-popover max-w-md",children:[e.jsxs(se,{children:[e.jsx(te,{children:"Create Workspace"}),e.jsx(ae,{className:"text-muted-foreground/60",children:"Bookmark a directory for quick access when creating sessions."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Name"}),e.jsx(T,{placeholder:"my-project",value:x,onChange:i=>f(i.target.value),className:"bg-background border-border"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Directory Path"}),e.jsx(T,{placeholder:"/home/user/projects/my-project",value:y,onChange:i=>p(i.target.value),className:"bg-background border-border font-mono text-sm"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/50 mt-1",children:"Must be an absolute path"})]})]}),e.jsxs(re,{children:[e.jsx(P,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(P,{onClick:b,disabled:u,className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:u?"Creating...":"Create"})]})]})]})}function dt({workspace:r,open:m,onOpenChange:d,onUpdated:u}){const[h,x]=a.useState(!1),[f,y]=a.useState(r.name),[p,b]=a.useState(r.path),i=async()=>{if(!f.trim()){t.error("Workspace name is required");return}if(!p.trim()){t.error("Path is required");return}try{x(!0),await C.updateWorkspace(r.id,{name:f.trim(),path:p.trim()}),t.success("Workspace updated"),u()}catch(o){t.error(o instanceof Error?o.message:"Failed to update workspace")}finally{x(!1)}};return e.jsx(J,{open:m,onOpenChange:d,children:e.jsxs(ee,{className:"border-border bg-popover max-w-md",children:[e.jsxs(se,{children:[e.jsx(te,{children:"Edit Workspace"}),e.jsx(ae,{className:"text-muted-foreground/60",children:"Update workspace name or directory path."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Name"}),e.jsx(T,{value:f,onChange:o=>y(o.target.value),className:"bg-background border-border"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Directory Path"}),e.jsx(T,{value:p,onChange:o=>b(o.target.value),className:"bg-background border-border font-mono text-sm"})]})]}),e.jsxs(re,{children:[e.jsx(P,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(P,{onClick:i,disabled:h,className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:h?"Saving...":"Save"})]})]})})}function ct(){const[r,m]=a.useState([]),[d,u]=a.useState(!0),[h,x]=a.useState(null),f=a.useCallback(async()=>{try{const p=await C.getWorkspaces();m(p.workspaces)}catch{t.error("Failed to load workspaces")}finally{u(!1)}},[]);a.useEffect(()=>{f()},[f]);const y=async p=>{try{await C.deleteWorkspace(p.id),t.success(`Deleted workspace "${p.name}"`),f()}catch{t.error("Failed to delete workspace")}};return d?e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-cyan-500/30 border-t-cyan-500 rounded-full animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading workspaces..."})]})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Save frequently-used directories for quick session creation."})}),e.jsx(it,{onCreated:f})]}),r.length===0?e.jsxs("div",{className:"border border-dashed border-border rounded-xl p-12 text-center",children:[e.jsx(me,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"No workspaces yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Create a workspace to bookmark a directory for faster session creation."})]}):e.jsx("div",{className:"grid gap-3",children:r.map(p=>e.jsx("div",{className:"group border border-border rounded-xl p-4 bg-card/50 hover:bg-card/80 transition-all",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-cyan-500/[0.08] flex items-center justify-center shrink-0",children:e.jsx(me,{className:"h-4 w-4 text-cyan-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:p.name}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:p.path})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(P,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",onClick:()=>x(p),children:e.jsx(Ke,{className:"h-3.5 w-3.5"})}),e.jsx(P,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-red-400",onClick:()=>y(p),children:e.jsx(We,{className:"h-3.5 w-3.5"})})]})]})},p.id))}),h&&e.jsx(dt,{workspace:h,open:!0,onOpenChange:p=>{p||x(null)},onUpdated:()=>{x(null),f()}})]})}function gt(){return e.jsxs("div",{className:"p-4 md:p-8 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-4 md:mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3 mb-1",children:[e.jsx(As,{className:"h-5 w-5 md:h-6 md:w-6 text-cyan-400"}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:"Settings"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 ml-7 md:ml-9",children:"Manage workspaces, environment variables, and security"})]}),e.jsxs(Ds,{defaultValue:"workspaces",children:[e.jsxs(Fs,{className:"bg-muted/50 border border-border mb-4 md:mb-6",children:[e.jsxs(G,{value:"workspaces",className:"data-[state=active]:bg-background data-[state=active]:text-foreground text-xs md:text-sm gap-1.5",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),"Workspaces"]}),e.jsxs(G,{value:"env-sets",className:"data-[state=active]:bg-background data-[state=active]:text-foreground text-xs md:text-sm gap-1.5",children:[e.jsx(he,{className:"h-3.5 w-3.5"}),"Env Sets"]}),e.jsxs(G,{value:"security",className:"data-[state=active]:bg-background data-[state=active]:text-foreground text-xs md:text-sm gap-1.5",children:[e.jsx(pe,{className:"h-3.5 w-3.5"}),"Security"]}),e.jsxs(G,{value:"daemon",className:"data-[state=active]:bg-background data-[state=active]:text-foreground text-xs md:text-sm gap-1.5",children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),"Daemon"]})]}),e.jsx(Q,{value:"workspaces",children:e.jsx(ct,{})}),e.jsx(Q,{value:"env-sets",children:e.jsx(st,{})}),e.jsx(Q,{value:"security",children:e.jsx(at,{})}),e.jsx(Q,{value:"daemon",children:e.jsx(Qs,{})})]})]})}export{gt as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as e}from"./react-vendor-B5MgMUHH.js";import{G as n,i,j as c,u as m}from"./index-
|
|
1
|
+
import{r,j as e}from"./react-vendor-B5MgMUHH.js";import{G as n,i,j as c,u as m}from"./index-DcbqZfqt.js";import"./monaco-core-DQ5Mk8AK.js";import"./chart-vendor-DlOHLaCG.js";function b(){const[t,d]=r.useState([]),[a,l]=r.useState(!0);return r.useEffect(()=>{(async()=>{try{const o=await c.getWorkflows();d(o.workflows)}catch{m.error("Failed to load workflows")}finally{l(!1)}})()},[]),e.jsxs("div",{className:"p-4 md:p-8 max-w-7xl mx-auto",children:[e.jsx("div",{className:"flex justify-between items-center mb-4 md:mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:"Workflows"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Orchestrate multi-step session automations"})]})}),a?e.jsx("div",{className:"flex justify-center items-center h-64",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-cyan-500/30 border-t-cyan-500 rounded-full animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading workflows..."})]})}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 rounded-xl border border-border bg-card/80",children:[e.jsx(n,{className:"h-10 w-10 text-muted-foreground/20 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"No workflows defined"}),e.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Create workflows via the CLI:"," ",e.jsx("code",{className:"bg-muted/50 px-1.5 py-0.5 rounded text-[11px] font-mono border border-border",children:"codepiper workflow create"})]})]}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(s=>e.jsxs("div",{className:"rounded-xl border border-border bg-card/80 backdrop-blur-sm p-5 hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:s.name}),e.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/50 bg-muted/50 px-1.5 py-0.5 rounded border border-border",children:s.id})]}),s.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:s.description}),e.jsxs("p",{className:"text-[11px] text-muted-foreground/50",children:["Created ",i(s.createdAt)]})]},s.id))})]})}export{b as WorkflowsPage};
|