@spencerboucher/switchyard 0.20.0 → 0.22.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/README.md +20 -16
- package/dist/policies/worker.js +1866 -1777
- package/dist/switchyard.mjs +5526 -4684
- package/package.json +1 -1
- package/web-dist/assets/AutomationView-DwZ_2m9J.js +2 -0
- package/web-dist/assets/AutomationView-DwZ_2m9J.js.map +1 -0
- package/web-dist/assets/Checkbox-DR78wXsg.js +2 -0
- package/web-dist/assets/{Checkbox-BnRsg6ki.js.map → Checkbox-DR78wXsg.js.map} +1 -1
- package/web-dist/assets/DangerZone-CBnW9h0p.js +2 -0
- package/web-dist/assets/{DangerZone-BicyqXv8.js.map → DangerZone-CBnW9h0p.js.map} +1 -1
- package/web-dist/assets/Field-DS2BMoqA.js +2 -0
- package/web-dist/assets/{Field-Cp-08kpe.js.map → Field-DS2BMoqA.js.map} +1 -1
- package/web-dist/assets/{Markdown-BPWc6K6m.js → Markdown-BIO6MBTM.js} +7 -7
- package/web-dist/assets/{Markdown-BPWc6K6m.js.map → Markdown-BIO6MBTM.js.map} +1 -1
- package/web-dist/assets/NavigationEditor-C0J7vDXL.js +2 -0
- package/web-dist/assets/NavigationEditor-C0J7vDXL.js.map +1 -0
- package/web-dist/assets/Overlay-DPZqU_vB.js +2 -0
- package/web-dist/assets/Overlay-DPZqU_vB.js.map +1 -0
- package/web-dist/assets/Priority-0hv1Vpg7.js +2 -0
- package/web-dist/assets/{Priority-ZGpTH645.js.map → Priority-0hv1Vpg7.js.map} +1 -1
- package/web-dist/assets/RadioCards-CN5xELnc.js +2 -0
- package/web-dist/assets/RadioCards-CN5xELnc.js.map +1 -0
- package/web-dist/assets/ScopeSelect-BaJjip1Y.js +2 -0
- package/web-dist/assets/ScopeSelect-BaJjip1Y.js.map +1 -0
- package/web-dist/assets/SegmentedControl-CRmhE-Kn.js +2 -0
- package/web-dist/assets/SegmentedControl-CRmhE-Kn.js.map +1 -0
- package/web-dist/assets/Select-CN7M29ap.js +2 -0
- package/web-dist/assets/{Select-DHRR7IAK.js.map → Select-CN7M29ap.js.map} +1 -1
- package/web-dist/assets/Switch-CZMY83Fw.js +2 -0
- package/web-dist/assets/{Switch-D5pVfZgf.js.map → Switch-CZMY83Fw.js.map} +1 -1
- package/web-dist/assets/Tabs-_1w3hoAR.js +2 -0
- package/web-dist/assets/Tabs-_1w3hoAR.js.map +1 -0
- package/web-dist/assets/TextLink-BpF2vLiL.js +2 -0
- package/web-dist/assets/{TextLink-BGtYWCW9.js.map → TextLink-BpF2vLiL.js.map} +1 -1
- package/web-dist/assets/UINodeRenderer-DqIkLhF8.js +4 -0
- package/web-dist/assets/UINodeRenderer-DqIkLhF8.js.map +1 -0
- package/web-dist/assets/UnfilteredNote-22-Qjb-f.js +2 -0
- package/web-dist/assets/UnfilteredNote-22-Qjb-f.js.map +1 -0
- package/web-dist/assets/api-RftVSu44.js +2 -0
- package/web-dist/assets/api-RftVSu44.js.map +1 -0
- package/web-dist/assets/{arrow-down-Dn3KG_JI.js → arrow-down-CzjHSpfM.js} +2 -2
- package/web-dist/assets/{arrow-down-Dn3KG_JI.js.map → arrow-down-CzjHSpfM.js.map} +1 -1
- package/web-dist/assets/{arrow-up-BiPtOqqy.js → arrow-up-B4YU8Bg0.js} +2 -2
- package/web-dist/assets/{arrow-up-BiPtOqqy.js.map → arrow-up-B4YU8Bg0.js.map} +1 -1
- package/web-dist/assets/attention-CEgIsUuq.js +2 -0
- package/web-dist/assets/attention-CEgIsUuq.js.map +1 -0
- package/web-dist/assets/automations-DnydDML9.js +2 -0
- package/web-dist/assets/{automations-IX9DQNk8.js.map → automations-DnydDML9.js.map} +1 -1
- package/web-dist/assets/board-BPxxc8G4.js +6 -0
- package/web-dist/assets/board-BPxxc8G4.js.map +1 -0
- package/web-dist/assets/{calendar-clock-DVlat602.js → calendar-clock-B3bQkNKq.js} +2 -2
- package/web-dist/assets/{calendar-clock-DVlat602.js.map → calendar-clock-B3bQkNKq.js.map} +1 -1
- package/web-dist/assets/chevron-right-DuAbbYQ-.js +2 -0
- package/web-dist/assets/{chevron-right-BM1IJI2z.js.map → chevron-right-DuAbbYQ-.js.map} +1 -1
- package/web-dist/assets/code-D5IB7jTT.js +28 -0
- package/web-dist/assets/code-D5IB7jTT.js.map +1 -0
- package/web-dist/assets/{core.esm-C4dCvG0s.js → core.esm-BbOnWvFK.js} +2 -2
- package/web-dist/assets/{core.esm-C4dCvG0s.js.map → core.esm-BbOnWvFK.js.map} +1 -1
- package/web-dist/assets/describe-DWsoiUix.js +5 -0
- package/web-dist/assets/describe-DWsoiUix.js.map +1 -0
- package/web-dist/assets/enroll-CV77Sk6h.js +2 -0
- package/web-dist/assets/{enroll-GUEF5Uxu.js.map → enroll-CV77Sk6h.js.map} +1 -1
- package/web-dist/assets/git-branch-Dr8PvfHN.js +2 -0
- package/web-dist/assets/git-branch-Dr8PvfHN.js.map +1 -0
- package/web-dist/assets/grip-vertical-Bc5pJHHF.js +2 -0
- package/web-dist/assets/grip-vertical-Bc5pJHHF.js.map +1 -0
- package/web-dist/assets/{hand-B6lvj014.js → hand-B2TrADIv.js} +2 -2
- package/web-dist/assets/{hand-B6lvj014.js.map → hand-B2TrADIv.js.map} +1 -1
- package/web-dist/assets/haptics-O69vKVoK.js +2 -0
- package/web-dist/assets/haptics-O69vKVoK.js.map +1 -0
- package/web-dist/assets/index-BXQwol8u.css +2 -0
- package/web-dist/assets/index-cmIcNnnF.js +17 -0
- package/web-dist/assets/index-cmIcNnnF.js.map +1 -0
- package/web-dist/assets/{link-2-CCq9WzMy.js → link-2-M5ENDPWT.js} +2 -2
- package/web-dist/assets/{link-2-CCq9WzMy.js.map → link-2-M5ENDPWT.js.map} +1 -1
- package/web-dist/assets/logic-CG2E-voG.js +2 -0
- package/web-dist/assets/{logic-BnSIy9_P.js.map → logic-CG2E-voG.js.map} +1 -1
- package/web-dist/assets/logic-D_vBBkcD.js +4 -0
- package/web-dist/assets/logic-D_vBBkcD.js.map +1 -0
- package/web-dist/assets/more-CVjg2O5h.js +2 -0
- package/web-dist/assets/more-CVjg2O5h.js.map +1 -0
- package/web-dist/assets/pencil-y_4AgVa2.js +2 -0
- package/web-dist/assets/pencil-y_4AgVa2.js.map +1 -0
- package/web-dist/assets/{play-NHO6U6cY.js → play-CYKX2aVL.js} +2 -2
- package/web-dist/assets/{play-NHO6U6cY.js.map → play-CYKX2aVL.js.map} +1 -1
- package/web-dist/assets/{plus-C83uJhbf.js → plus-B6uH1yKa.js} +2 -2
- package/web-dist/assets/{plus-C83uJhbf.js.map → plus-B6uH1yKa.js.map} +1 -1
- package/web-dist/assets/policyLogic-CioD2rMm.js +2 -0
- package/web-dist/assets/{policyLogic-DqKyFQEW.js.map → policyLogic-CioD2rMm.js.map} +1 -1
- package/web-dist/assets/prefs-V29Ms2ZL.js +2 -0
- package/web-dist/assets/prefs-V29Ms2ZL.js.map +1 -0
- package/web-dist/assets/queue-BGK9c062.js +2 -0
- package/web-dist/assets/queue-BGK9c062.js.map +1 -0
- package/web-dist/assets/repo-CuL_qbqU.js +5 -0
- package/web-dist/assets/repo-CuL_qbqU.js.map +1 -0
- package/web-dist/assets/{rotate-ccw-BRrlVEAQ.js → rotate-ccw-DvfmNYNE.js} +2 -2
- package/web-dist/assets/{rotate-ccw-BRrlVEAQ.js.map → rotate-ccw-DvfmNYNE.js.map} +1 -1
- package/web-dist/assets/{search-C5H14z0D.js → search-GTFKEqAS.js} +2 -2
- package/web-dist/assets/{search-C5H14z0D.js.map → search-GTFKEqAS.js.map} +1 -1
- package/web-dist/assets/selection-CAMJBh5A.js +9 -0
- package/web-dist/assets/selection-CAMJBh5A.js.map +1 -0
- package/web-dist/assets/settings-o7k_MPK7.js +9 -0
- package/web-dist/assets/settings-o7k_MPK7.js.map +1 -0
- package/web-dist/assets/states-BUWwUyu-.js +60 -0
- package/web-dist/assets/states-BUWwUyu-.js.map +1 -0
- package/web-dist/assets/{terminal-CATQN_17.js → terminal-DGVFZER3.js} +2 -2
- package/web-dist/assets/{terminal-CATQN_17.js.map → terminal-DGVFZER3.js.map} +1 -1
- package/web-dist/assets/terminal-login-Gy6aLzgC.js +2 -0
- package/web-dist/assets/{terminal-login-BdkmJdOO.js.map → terminal-login-Gy6aLzgC.js.map} +1 -1
- package/web-dist/assets/useBreakpoint-DoLUoCMf.js +2 -0
- package/web-dist/assets/useBreakpoint-DoLUoCMf.js.map +1 -0
- package/web-dist/assets/useIndicator-BKqIsw2Q.js +2 -0
- package/web-dist/assets/useIndicator-BKqIsw2Q.js.map +1 -0
- package/web-dist/assets/useNow-BS_9T7IY.js +2 -0
- package/web-dist/assets/useNow-BS_9T7IY.js.map +1 -0
- package/web-dist/assets/useResource-CPN6cDQ5.js +2 -0
- package/web-dist/assets/useResource-CPN6cDQ5.js.map +1 -0
- package/web-dist/assets/useSwipeTabs-XRK0_O6T.js +2 -0
- package/web-dist/assets/useSwipeTabs-XRK0_O6T.js.map +1 -0
- package/web-dist/assets/workboard-FE6bAMnW.js +3 -0
- package/web-dist/assets/workboard-FE6bAMnW.js.map +1 -0
- package/web-dist/index.html +7 -7
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-B4O_teaB.js +0 -2
- package/web-dist/assets/AutomationView-B4O_teaB.js.map +0 -1
- package/web-dist/assets/Button-C7TQGuSX.js +0 -2
- package/web-dist/assets/Button-C7TQGuSX.js.map +0 -1
- package/web-dist/assets/Card-DzHrwFrv.js +0 -2
- package/web-dist/assets/Card-DzHrwFrv.js.map +0 -1
- package/web-dist/assets/Checkbox-BnRsg6ki.js +0 -2
- package/web-dist/assets/DangerZone-BicyqXv8.js +0 -2
- package/web-dist/assets/Field-Cp-08kpe.js +0 -2
- package/web-dist/assets/Priority-ZGpTH645.js +0 -2
- package/web-dist/assets/SegmentedControl-Cvkz7C_A.js +0 -2
- package/web-dist/assets/SegmentedControl-Cvkz7C_A.js.map +0 -1
- package/web-dist/assets/Select-DHRR7IAK.js +0 -2
- package/web-dist/assets/Switch-D5pVfZgf.js +0 -2
- package/web-dist/assets/Tabs-2GilVMsH.js +0 -2
- package/web-dist/assets/Tabs-2GilVMsH.js.map +0 -1
- package/web-dist/assets/TextLink-BGtYWCW9.js +0 -2
- package/web-dist/assets/UINodeRenderer-BaANWHvJ.js +0 -4
- package/web-dist/assets/UINodeRenderer-BaANWHvJ.js.map +0 -1
- package/web-dist/assets/UnfilteredNote-zVO8ajSi.js +0 -2
- package/web-dist/assets/UnfilteredNote-zVO8ajSi.js.map +0 -1
- package/web-dist/assets/ViewSelect-C9gNftWK.js +0 -2
- package/web-dist/assets/ViewSelect-C9gNftWK.js.map +0 -1
- package/web-dist/assets/api-DMrk4xwq.js +0 -2
- package/web-dist/assets/api-DMrk4xwq.js.map +0 -1
- package/web-dist/assets/attention-B9uawu1d.js +0 -2
- package/web-dist/assets/attention-B9uawu1d.js.map +0 -1
- package/web-dist/assets/automations-IX9DQNk8.js +0 -2
- package/web-dist/assets/board-BUAI4L7M.js +0 -6
- package/web-dist/assets/board-BUAI4L7M.js.map +0 -1
- package/web-dist/assets/check-CEnbWw4D.js +0 -2
- package/web-dist/assets/check-CEnbWw4D.js.map +0 -1
- package/web-dist/assets/chevron-right-BM1IJI2z.js +0 -2
- package/web-dist/assets/code-Dav4E15n.js +0 -25
- package/web-dist/assets/code-Dav4E15n.js.map +0 -1
- package/web-dist/assets/describe-B66LJTqU.js +0 -2
- package/web-dist/assets/describe-B66LJTqU.js.map +0 -1
- package/web-dist/assets/describe-BeFxHr2Y.js +0 -5
- package/web-dist/assets/describe-BeFxHr2Y.js.map +0 -1
- package/web-dist/assets/enroll-GUEF5Uxu.js +0 -2
- package/web-dist/assets/external-link-B3hnazCa.js +0 -2
- package/web-dist/assets/external-link-B3hnazCa.js.map +0 -1
- package/web-dist/assets/index-BUZpNu-R.js +0 -22
- package/web-dist/assets/index-BUZpNu-R.js.map +0 -1
- package/web-dist/assets/index-C9iuCGwg.css +0 -2
- package/web-dist/assets/keyboardLayers-BZOygMAH.js +0 -2
- package/web-dist/assets/keyboardLayers-BZOygMAH.js.map +0 -1
- package/web-dist/assets/logic-BBQ4d1GC.js +0 -4
- package/web-dist/assets/logic-BBQ4d1GC.js.map +0 -1
- package/web-dist/assets/logic-BnSIy9_P.js +0 -2
- package/web-dist/assets/more-C1oPXLVM.js +0 -2
- package/web-dist/assets/more-C1oPXLVM.js.map +0 -1
- package/web-dist/assets/pencil-DeML-0z2.js +0 -2
- package/web-dist/assets/pencil-DeML-0z2.js.map +0 -1
- package/web-dist/assets/policyLogic-DqKyFQEW.js +0 -2
- package/web-dist/assets/queue-DWSd1kia.js +0 -2
- package/web-dist/assets/queue-DWSd1kia.js.map +0 -1
- package/web-dist/assets/repo-DRwGWCut.js +0 -2
- package/web-dist/assets/repo-DRwGWCut.js.map +0 -1
- package/web-dist/assets/settings-B0IbaTOd.js +0 -12
- package/web-dist/assets/settings-B0IbaTOd.js.map +0 -1
- package/web-dist/assets/states-hyf_ATdQ.js +0 -58
- package/web-dist/assets/states-hyf_ATdQ.js.map +0 -1
- package/web-dist/assets/terminal-login-BdkmJdOO.js +0 -2
- package/web-dist/assets/timer-DFrvOKOy.js +0 -2
- package/web-dist/assets/timer-DFrvOKOy.js.map +0 -1
- package/web-dist/assets/useBreakpoint-BYCN9s8X.js +0 -2
- package/web-dist/assets/useBreakpoint-BYCN9s8X.js.map +0 -1
- package/web-dist/assets/useNow-DXyC-YfE.js +0 -2
- package/web-dist/assets/useNow-DXyC-YfE.js.map +0 -1
- package/web-dist/assets/useResource-DYNGG9XS.js +0 -2
- package/web-dist/assets/useResource-DYNGG9XS.js.map +0 -1
- package/web-dist/assets/workboard-BJCZsLp5.js +0 -3
- package/web-dist/assets/workboard-BJCZsLp5.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,y as t}from"./Button-C7TQGuSX.js";function n(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function r(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function i(){return a.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var a={stubThis:e=>e};function o(e){let{id:t}=e;return{...e,id:r(t),transports:e.transports,type:e.type}}function s(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var c=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function l({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new c({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new c({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new c({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new c({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new c({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new c({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new c({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new c({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!s(t))return new c({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new c({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new c({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new c({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var u=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},d=[`cross-platform`,`platform`];function f(e){if(e&&!(d.indexOf(e)<0))return e}async function p(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:a=!1}=e;if(!i())throw Error(`WebAuthn is not supported in this browser`);let s={...t,challenge:r(t.challenge),user:{...t.user,id:r(t.user.id)},excludeCredentials:t.excludeCredentials?.map(o)},c={};a&&(c.mediation=`conditional`),c.publicKey=s,c.signal=u.createNewAbortSignal();let d;try{d=await navigator.credentials.create(c)}catch(e){throw l({error:e,options:c})}if(!d)throw Error(`Registration was not completed`);let{id:p,rawId:h,response:g,type:_}=d,v;typeof g.getTransports==`function`&&(v=g.getTransports());let y;if(typeof g.getPublicKeyAlgorithm==`function`)try{y=g.getPublicKeyAlgorithm()}catch(e){m(`getPublicKeyAlgorithm()`,e)}let b;if(typeof g.getPublicKey==`function`)try{let e=g.getPublicKey();e!==null&&(b=n(e))}catch(e){m(`getPublicKey()`,e)}let x;if(typeof g.getAuthenticatorData==`function`)try{x=n(g.getAuthenticatorData())}catch(e){m(`getAuthenticatorData()`,e)}return{id:p,rawId:n(h),response:{attestationObject:n(g.attestationObject),clientDataJSON:n(g.clientDataJSON),transports:v,publicKeyAlgorithm:y,publicKey:b,authenticatorData:x},type:_,clientExtensionResults:d.getClientExtensionResults(),authenticatorAttachment:f(d.authenticatorAttachment)}}function m(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function h(){if(!i())return g.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?g.stubThis(new Promise(e=>e(!1))):g.stubThis(e.isConditionalMediationAvailable())}var g={stubThis:e=>e};function _({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new c({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new c({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!s(t))return new c({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new c({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new c({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function v(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:a=!1,verifyBrowserAutofillInput:s=!0}=e;if(!i())throw Error(`WebAuthn is not supported in this browser`);let c;t.allowCredentials?.length!==0&&(c=t.allowCredentials?.map(o));let l={...t,challenge:r(t.challenge),allowCredentials:c},d={};if(a){if(!await h())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&s)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');d.mediation=`conditional`,l.allowCredentials=[]}d.publicKey=l,d.signal=u.createNewAbortSignal();let p;try{p=await navigator.credentials.get(d)}catch(e){throw _({error:e,options:d})}if(!p)throw Error(`Authentication was not completed`);let{id:m,rawId:g,response:v,type:y}=p,b;return v.userHandle&&(b=n(v.userHandle)),{id:m,rawId:n(g),response:{authenticatorData:n(v.authenticatorData),clientDataJSON:n(v.clientDataJSON),signature:n(v.signature),userHandle:b},type:y,clientExtensionResults:p.getClientExtensionResults(),authenticatorAttachment:f(p.authenticatorAttachment)}}var y=e(t(),1);function b(e){return e instanceof Error&&(e.name===`NotAllowedError`||e.name===`AbortError`)}function x(){let[e,t]=(0,y.useState)(!1),n=(0,y.useRef)(0),r=(0,y.useRef)(!1),i=(0,y.useCallback)(e=>{r.current=e,t(e)},[]),a=(0,y.useCallback)(()=>{n.current++,u.cancelCeremony(),r.current=!1,t(!1)},[]),o=(0,y.useCallback)(async e=>{let t=++n.current;i(!0);try{let r=await e();return n.current===t?(i(!1),{ok:!0,value:r}):{ok:!1,canceled:!0}}catch(e){if(n.current!==t||(i(!1),b(e)))return{ok:!1,canceled:!0};throw e}},[i]);return(0,y.useEffect)(()=>()=>{r.current&&(n.current++,u.cancelCeremony())},[]),{waiting:e,run:o,cancel:a}}var S=2e3;function C(e){return{phase:`waiting`,startedAt:e,message:null}}function w(e,t){if(e.phase!==`waiting`)return e;if(t.type===`cancel`)return{...e,phase:`canceled`};if(t.now-e.startedAt>=6e5&&t.type!==`claim`)return{...e,phase:`timeout`};switch(t.type){case`tick`:return e;case`claim`:return t.result.status===`done`?{...e,phase:`done`}:t.now-e.startedAt>=6e5?{...e,phase:`timeout`}:e;case`claim_error`:return t.code===`unauthorized`||t.code===`invalid_request`?{...e,phase:`failed`,message:t.message}:e}}function T(e,t){return e.phase===`waiting`&&t}var E=`This account is not allowed to sign in to this server.`,D={enrollment_expired:"This sign-in link has expired. Links are valid for 10 minutes. Run `switchyard pair` on the server for a new one.",enrollment_used:"This sign-in link was already used. Each link signs in one browser. Run `switchyard pair` on the server for a new one.",invalid_request:`The sign-in request was rejected. Try again.`,network:`Could not reach the coordinator. Check your connection and try again.`,rate_limited:`Too many attempts. Wait a minute and try again.`,unsupported_capability:`This sign-in method is not available on this server.`,unauthorized:`That sign-in was not accepted. Try again, or use another sign-in method.`};function O(e,t){let n=t?.trim()||null;switch(e){case`forbidden`:return n??E;case`oidc_failed`:return`Single sign-on failed: ${n??`the identity provider returned an error.`}`;case`unsupported_capability`:return n??D.unsupported_capability;default:return D[e]??n??`Sign-in failed (${e}).`}}function k(e){switch(e){case`enrollment_expired`:return`Sign-in link expired`;case`enrollment_used`:return`Sign-in link already used`;case`forbidden`:return`Not allowed`;case`oidc_failed`:return`Single sign-on failed`;case`rate_limited`:return`Too many attempts`;default:return`Sign-in failed`}}function A(e=navigator.userAgent){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)||/Macintosh/.test(e)&&navigator.maxTouchPoints>1?`iPad`:/Android/.test(e)?`Android`:/Macintosh|Mac OS X/.test(e)?`Mac`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:`device`;return`${/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:`Browser`} on ${t}`}export{k as a,C as c,p as d,i as f,O as i,x as l,S as n,w as o,A as r,T as s,D as t,v as u};
|
|
2
|
-
//# sourceMappingURL=logic-BnSIy9_P.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e,l as t,t as n}from"./Button-C7TQGuSX.js";import{t as r}from"./chevron-right-BM1IJI2z.js";import{n as i,t as a}from"./timer-DFrvOKOy.js";import{R as o,_n as s,pn as c}from"./index-BUZpNu-R.js";var l=e(),u=[{to:`/tasks`,label:`Tasks`,description:`Automation tasks and review`,icon:i},{to:`/queue`,label:`Queue`,description:`Running and queued runs`,icon:a},{to:`/automations`,label:`Automations`,description:`Schedules, webhooks and history`,icon:c},{to:`/settings`,label:`Settings`,description:`Hosts, devices, projects, notifications`,icon:s}];function d(){return(0,l.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col gap-3 px-4 pb-4 safe-pt-4`,children:[(0,l.jsx)(`h1`,{className:`text-lg font-semibold`,children:`More`}),(0,l.jsx)(`ul`,{"aria-label":`More navigation`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`overflow-hidden rounded-lg border border-border bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent`,children:u.map(({to:e,label:n,description:i,icon:a})=>(0,l.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,l.jsxs)(t,{to:e,"data-keyboard-item":!0,className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,l.jsx)(a,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,l.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`block font-medium`,children:n}),(0,l.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:i})]}),(0,l.jsx)(r,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},e))}),(0,l.jsx)(n,{variant:`secondary`,onClick:()=>o.getState().setHelpOpen(!0),children:`Keyboard shortcuts`})]})}export{d as default};
|
|
2
|
-
//# sourceMappingURL=more-C1oPXLVM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"more-C1oPXLVM.js","names":["require_jsx_runtime","Link","Button","ChevronRight","ListChecks","Timer","usePalette","Settings","Workflow","import_jsx_runtime","ITEMS","MoreView","Icon","label","description","to"],"sources":["../../src/features/more/index.tsx"],"sourcesContent":["import { ChevronRight, ListChecks, type LucideIcon, Settings, Timer, Workflow } from \"lucide-react\";\nimport { Link } from \"react-router\";\nimport { Button } from \"../../components/ui/Button\";\nimport { usePalette } from \"../palette/registry\";\n\nconst ITEMS: { to: string; label: string; description: string; icon: LucideIcon }[] = [\n { to: \"/tasks\", label: \"Tasks\", description: \"Automation tasks and review\", icon: ListChecks },\n { to: \"/queue\", label: \"Queue\", description: \"Running and queued runs\", icon: Timer },\n {\n to: \"/automations\",\n label: \"Automations\",\n description: \"Schedules, webhooks and history\",\n icon: Workflow,\n },\n {\n to: \"/settings\",\n label: \"Settings\",\n description: \"Hosts, devices, projects, notifications\",\n icon: Settings,\n },\n];\n\n/** Mobile \"More\": Tasks, Queue, Automations and Settings (spec 10). */\nexport default function MoreView() {\n return (\n <div className=\"mx-auto flex w-full max-w-xl flex-col gap-3 px-4 pb-4 safe-pt-4\">\n <h1 className=\"text-lg font-semibold\">More</h1>\n <ul\n aria-label=\"More navigation\"\n tabIndex={-1}\n data-keyboard-scope\n data-keyboard-default\n className=\"overflow-hidden rounded-lg border border-border bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent\"\n >\n {ITEMS.map(({ to, label, description, icon: Icon }) => (\n <li key={to} className=\"border-b border-border last:border-b-0\">\n <Link\n to={to}\n data-keyboard-item\n className=\"tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2\"\n >\n <Icon aria-hidden className=\"size-5 shrink-0 text-muted\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block font-medium\">{label}</span>\n <span className=\"block truncate text-sm text-muted\">{description}</span>\n </span>\n <ChevronRight aria-hidden className=\"size-4 shrink-0 text-subtle\" />\n </Link>\n </li>\n ))}\n </ul>\n <Button variant=\"secondary\" onClick={() => usePalette.getState().setHelpOpen(true)}>\n Keyboard shortcuts\n </Button>\n </div>\n );\n}\n"],"mappings":"A,wNAKMU,EAAgF,CACpF,CAAE,GAAI,SAAU,MAAO,QAAS,YAAa,8BAA+B,KAAMN,CAAW,EAC7F,CAAE,GAAI,SAAU,MAAO,QAAS,YAAa,0BAA2B,KAAMC,CAAM,EACpF,CACE,GAAI,eACJ,MAAO,cACP,YAAa,kCACb,KAAMG,CACR,EACA,CACE,GAAI,YACJ,MAAO,WACP,YAAa,0CACb,KAAMD,CACR,CACF,EAGA,SAAwBI,GAAW,CACjC,OACE,EAAAF,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,kEAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,wBAAwB,SAAA,MAAQ,CAAA,GAC9C,EAAAA,EAAA,IAAA,CAAC,KAAD,CACE,aAAW,kBACX,SAAU,GACV,sBAAA,GACA,wBAAA,GACA,UAAU,wIAET,SAAAC,EAAM,KAAK,CAAE,KAAI,QAAO,cAAa,KAAME,MAC1C,EAAAH,EAAA,IAAA,CAAC,KAAD,CAAa,UAAU,yCACrB,UAAA,EAAAA,EAAA,KAAA,CAACR,EAAD,CACM,KACJ,qBAAA,GACA,UAAU,oEAHZ,SAAA,EAKE,EAAAQ,EAAA,IAAA,CAACG,EAAD,CAAM,cAAA,GAAY,UAAU,4BAA8B,CAAA,GAC1D,EAAAH,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,iBAAhB,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,oBAAqB,SAAAI,CAAY,CAAA,GACjD,EAAAJ,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,oCAAqC,SAAAK,CAAkB,CAAA,CACnE,C,IACN,EAAAL,EAAA,IAAA,CAACN,EAAD,CAAc,cAAA,GAAY,UAAU,6BAA+B,CAAA,CAC/D,C,EACJ,EAbKY,CAaL,CACL,CACC,CAAA,GACJ,EAAAN,EAAA,IAAA,CAACP,EAAD,CAAQ,QAAQ,YAAY,YAAeI,EAAW,SAAS,CAAC,CAAC,YAAY,EAAI,EAAG,SAAA,oBAE5E,CAAA,CACL,C,EAET,C"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./Button-C7TQGuSX.js";var t={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};t.node;var n=e(t),r={name:`pencil`,size:24,node:[[`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`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};r.node;var i=e(r);export{n,i as t};
|
|
2
|
-
//# sourceMappingURL=pencil-DeML-0z2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pencil-DeML-0z2.js","names":["__iconData","createLucideIcon","__iconData$1","GitBranch","__iconData","Pencil"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/git-branch.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/pencil.mjs"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"git-branch\",\n size: 24,\n node: [\n [\"path\", { d: \"M15 6a9 9 0 0 0-9 9V3\", key: \"1cii5b\" }],\n [\"circle\", { cx: \"18\", cy: \"6\", r: \"3\", key: \"1h7g24\" }],\n [\"circle\", { cx: \"6\", cy: \"18\", r: \"3\", key: \"fqmcym\" }]\n ]\n};\n__iconData.node;\nconst GitBranch = createLucideIcon(__iconData);\n\nexport { __iconData, GitBranch as default };\n//# sourceMappingURL=git-branch.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"pencil\",\n size: 24,\n node: [\n [\n \"path\",\n {\n 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\",\n key: \"1a8usu\"\n }\n ],\n [\"path\", { d: \"m15 5 4 4\", key: \"1mk7zo\" }]\n ]\n};\n__iconData.node;\nconst Pencil = createLucideIcon(__iconData);\n\nexport { __iconData, Pencil as default };\n//# sourceMappingURL=pencil.mjs.map\n"],"ignoreList":[0,1],"mappings":"A,yCASA,IAAMA,EAAa,CACjB,KAAM,aACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,wBAAyB,IAAK,QAAS,CAAC,EACtD,CAAC,SAAU,CAAE,GAAI,KAAM,GAAI,IAAK,EAAG,IAAK,IAAK,QAAS,CAAC,EACvD,CAAC,SAAU,CAAE,GAAI,IAAK,GAAI,KAAM,EAAG,IAAK,IAAK,QAAS,CAAC,CACzD,CACF,EACAA,EAAW,KACX,IAAMG,EAAYF,EAAiBD,CAAU,ECVvCI,EAAa,CACjB,KAAM,SACN,KAAM,GACN,KAAM,CACJ,CACE,OACA,CACE,EAAG,mIACH,IAAK,QACP,CACF,EACA,CAAC,OAAQ,CAAE,EAAG,YAAa,IAAK,QAAS,CAAC,CAC5C,CACF,EACAA,EAAW,KACX,IAAMC,EAASJ,EAAiBG,CAAU,E"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./Button-C7TQGuSX.js";import{Bt as t,Ht as n,Vt as r,zt as i}from"./states-hyf_ATdQ.js";var a={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};a.node;var o=e(a),s=`${t} At 80% of a continuation budget, approval is required, including for cheap models. At 100%, the next continuation is stopped for expensive or unclassified models; explicitly cheap models have no hard budget stop. Missing or stale usage blocks continuation when a limit is configured. There is no mid-turn spending guarantee.`;function c(e){let t=e.bridge;if(t?.policyState===`active`){let e=t.policyPhases.map(e=>e===`tool_call`?`Tool call`:`API request`);return e.length?`Active: ${e.join(`, `)}`:`Not enforced: no active policy phases`}return t?.policyState===`initializing`?`Not enforced: protection initializing`:t?.policyState===`lost`?`Not enforced: protection connection lost`:`Not enforced: reload or restart this session to enable protection`}function l(e){return i.safeParse(e)}function u(e){return n.safeParse(e)}function d(e){return r.safeParse(e)}function f(e){return e===`ALLOW`?`Allow`:e===`ASK`?`Ask`:e===`DENY`?`Deny`:`No match`}export{d as a,u as i,c as n,f as o,l as r,o as s,s as t};
|
|
2
|
-
//# sourceMappingURL=policyLogic-DqKyFQEW.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,i as t,l as n,n as r,o as i,r as a,y as o}from"./Button-C7TQGuSX.js";import{S as s,u as c,v as l}from"./keyboardLayers-BZOygMAH.js";import{L as u,Pt as d,an as f,b as p,c as m,f as h,i as g,m as _,n as v,on as y,r as b,s as x,t as S,u as C}from"./states-hyf_ATdQ.js";import{t as w}from"./calendar-clock-DVlat602.js";import{r as T}from"./Priority-ZGpTH645.js";import{l as E,p as D,s as O}from"./useBreakpoint-BYCN9s8X.js";import{t as k}from"./external-link-B3hnazCa.js";import{B as A,a as j,m as M,t as N,x as P}from"./useNow-DXyC-YfE.js";import{t as F}from"./link-2-CCq9WzMy.js";import{t as I}from"./timer-DFrvOKOy.js";import{c as L}from"./index-BUZpNu-R.js";import{t as R}from"./UnfilteredNote-zVO8ajSi.js";var z={name:`folder-lock`,size:24,node:[[`rect`,{width:`8`,height:`5`,x:`14`,y:`17`,rx:`1`,key:`19aais`}],[`path`,{d:`M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5`,key:`1w6v7t`}],[`path`,{d:`M20 17v-2a2 2 0 1 0-4 0v2`,key:`pwaxnr`}]]};z.node;var B=i(z),V={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};V.node;var H=i(V),U={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};U.node;var W=i(U),G={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};G.node;var K=i(G),q=e(o(),1),J=t(),Y={dependency:F,host_offline:E,project_limit:H,workspace_occupied:B,scheduled_time:w,invalid_configuration:_,dispatch_paused:s,project_automation_disabled:W,not_ready:p,already_dispatched:l,retry_backoff:K};function X(){let e=N(),t=u(e=>e.tasks),n=u(e=>e.runs),r=u(e=>e.hydrated),i=y(e.error)&&e.error.status===404,a=!!e.data&&(!Array.isArray(e.data.running)||!Array.isArray(e.data.queued)),o=(0,q.useMemo)(()=>e.data&&!a?e.data.running.map(e=>({taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})):Object.values(n).filter(e=>P(e)&&e.state!==`queued`).map(e=>({taskId:e.taskId,runId:e.id,sessionId:e.sessionId})),[e.data,n,a]),s=(0,q.useMemo)(()=>e.data&&!a?e.data.queued.map(e=>({taskId:e.taskId,eligibility:e.eligibility})):Object.values(t).filter(e=>e.state===`ready`&&!e.hiddenFromBoard).sort((e,t)=>e.priority-t.priority||e.position-t.position).map(e=>({taskId:e.id,eligibility:void 0})),[e.data,t,a]),c=!e.data&&e.loading&&!e.error||!r,l=!!e.error&&!i&&!e.data;return a?(0,J.jsx)(b,{title:`The coordinator sent a queue this version cannot read`,error:`GET /api/now returned an unexpected shape. Check that the web app and coordinator versions match.`}):(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-4 px-4 pb-4 safe-pt-4 md:px-6`,children:[(0,J.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,J.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`Queue`}),(0,J.jsx)(j,{})]}),(0,J.jsx)(R,{what:`tasks`}),(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Pausing stops new work from starting. Runs already in progress keep going.`}),(0,J.jsx)(x,{subject:`queue`,show:!!e.data}),i&&(0,J.jsx)(C,{capability:`Queue explanations`,reason:`This coordinator does not report why queued tasks are waiting. The list below comes from local data.`}),e.error!=null&&!i&&(0,J.jsx)(v,{compact:!0,title:`Could not refresh running and queued work`,error:f(e.error),onRetry:e.reload}),c?(0,J.jsx)(m,{label:`Loading running and queued work…`}):l&&o.length===0&&s.length===0?null:o.length===0&&s.length===0?(0,J.jsx)(S,{icon:(0,J.jsx)(I,{className:`size-8`}),title:`Nothing running or queued`,description:`Move a task to Ready on the board and the dispatcher starts it when it is eligible.`,action:{label:`Go to Tasks`,to:L.tasks}}):(0,J.jsxs)(`section`,{"aria-label":`Running and queued tasks`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`grid min-w-0 grid-cols-1 gap-4 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent xl:grid-cols-2 xl:items-start`,children:[(0,J.jsxs)(`section`,{"aria-labelledby":`now-running`,className:`flex min-w-0 flex-col gap-2`,children:[(0,J.jsxs)(`h2`,{id:`now-running`,className:`text-base font-semibold`,children:[`Running `,(0,J.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,o.length,`)`]})]}),o.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Nothing is running.`}):(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:o.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Z,{taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})},e.runId))})]}),(0,J.jsxs)(`section`,{"aria-labelledby":`now-queued`,className:`flex min-w-0 flex-col gap-2`,children:[(0,J.jsxs)(`h2`,{id:`now-queued`,className:`text-base font-semibold`,children:[`Queued `,(0,J.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,s.length,`)`]})]}),s.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No Ready tasks are waiting.`}):(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:s.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Q,{task:t[e.taskId],taskId:e.taskId,eligibility:e.eligibility})},e.taskId))})]})]})]})}function Z({taskId:e,runId:t,sessionId:i}){let a=u(t=>t.tasks[e]),o=u(e=>e.runs[t]),s=u(e=>o?.hostId?e.hosts[o.hostId]:void 0),l=u(e=>a?e.projects[a.projectId]:void 0),d=!!s&&s.connectivity!==`connected`;return(0,J.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[o?(0,J.jsx)(c,{kind:`run`,value:o.state,size:`sm`}):(0,J.jsx)(c,{kind:`task`,value:`in_progress`,size:`sm`}),(0,J.jsx)(n,{to:L.task(e),"data-keyboard-item":!0,className:`min-w-0 flex-1 basis-48 font-medium break-words hover:underline`,children:a?.title??`Task`}),(i??a?.sessionId)&&(0,J.jsxs)(n,{to:L.session(i??a?.sessionId),className:r(`secondary`,`sm`),children:[(0,J.jsx)(k,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:[l?.name,s?`on ${s.name}`:null,o?.attempt&&o.attempt>1?`attempt ${o.attempt}`:null,o?.startedAt?`started ${h(o.startedAt)}`:null,o?.controlMode===`human`?`you have control`:`automation`].filter(Boolean).join(` · `)}),o?.state===`uncertain`&&s&&(0,J.jsx)(`p`,{className:`text-sm text-warning`,children:(0,J.jsxs)(`span`,{className:`text-text`,children:[`Waiting for host `,s.name,` to confirm launch. It is never started elsewhere.`]})}),d&&s&&(0,J.jsx)(g,{compact:!0,hostName:s.name,connectivity:s.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:s.lastSeenAt})]})}function Q({task:e,taskId:t,eligibility:r}){let i=u(t=>e?t.projects[e.projectId]:void 0),[o,s]=(0,q.useState)(!1),c=(0,q.useId)(),l=r?r.eligible?D:Y[r.wait]:I,p=r?r.eligible?`Starting on ${r.hostName}`:M[r.wait]:`Waiting for dispatch`,m=r&&!r.eligible?r.message:null;return(0,J.jsxs)(`article`,{"data-testid":`now-queued-row`,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 sm:flex-row sm:items-center`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsx)(n,{to:L.task(t),"data-keyboard-item":!0,className:`min-w-0 font-medium break-words hover:underline`,children:e?.title??`Task`}),i&&(0,J.jsx)(`span`,{className:`text-xs text-muted`,children:i.name}),(0,J.jsxs)(`p`,{className:`flex min-w-0 items-start gap-1.5 text-sm`,children:[(0,J.jsx)(l,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 ${r?.eligible?`text-success`:`text-warning`}`}),(0,J.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:p}),m&&m!==p?(0,J.jsxs)(`span`,{className:`text-muted`,children:[`: `,m]}):null]})]})]}),e&&(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,J.jsx)(`label`,{htmlFor:c,className:`text-sm text-muted`,children:`Priority`}),(0,J.jsx)(T,{id:c,width:`auto`,value:e.priority,disabled:o,onChange:async t=>{s(!0);try{await A(e.id,{priority:t}),O.success(`"${e.title}" is now ${d[t]} priority`)}catch(e){O.error(`Could not change priority: ${f(e)}`)}finally{s(!1)}}}),o&&(0,J.jsx)(a,{label:`Saving priority`})]})]})}export{X as default};
|
|
2
|
-
//# sourceMappingURL=queue-DWSd1kia.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue-DWSd1kia.js","names":["__iconData","__iconData","__iconData","useMemo","useState","useId","__toESM","require_jsx_runtime","Link","buttonClasses","createLucideIcon","Spinner","require_react","CirclePause","StatusChip","LoaderCircle","useSyncStore","PRIORITY_LABELS","errorMessage","Inbox","LoadingState","formatRelative","HostUnavailable","TriangleAlert","ErrorState","isApiError","FatalError","LastKnownNote","EmptyState","UnsupportedCapability","CalendarClock","PrioritySelect","WifiOff","CircleCheck","toast","ExternalLink","updateTask","DispatchToggle","WAIT_LABELS","useNow","isRunActive","Link2","Timer","ROUTES","UnfilteredNote","__iconData$3","FolderLock","__iconData$2","Gauge","__iconData$1","PowerOff","__iconData","RotateCw","import_react","import_jsx_runtime","WAIT_ICONS","QueueView","now","tasks","s","runs","hydrated","unsupported","malformed","running","r","queued","q","t","a","b","loading","fatal","RunningRow","QueuedRow","task","taskId","run","runId","host","project","offline","sessionId","busy","setBusy","id","Icon","eligibility","waitLabel","detail","p","err"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/folder-lock.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/gauge.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/power-off.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.mjs","../../src/features/queue/index.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"folder-lock\",\n size: 24,\n node: [\n [\"rect\", { width: \"8\", height: \"5\", x: \"14\", y: \"17\", rx: \"1\", key: \"19aais\" }],\n [\n \"path\",\n {\n d: \"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5\",\n key: \"1w6v7t\"\n }\n ],\n [\"path\", { d: \"M20 17v-2a2 2 0 1 0-4 0v2\", key: \"pwaxnr\" }]\n ]\n};\n__iconData.node;\nconst FolderLock = createLucideIcon(__iconData);\n\nexport { __iconData, FolderLock as default };\n//# sourceMappingURL=folder-lock.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"gauge\",\n size: 24,\n node: [\n [\"path\", { d: \"m12 14 4-4\", key: \"9kzdfg\" }],\n [\"path\", { d: \"M3.34 19a10 10 0 1 1 17.32 0\", key: \"19p75a\" }]\n ]\n};\n__iconData.node;\nconst Gauge = createLucideIcon(__iconData);\n\nexport { __iconData, Gauge as default };\n//# sourceMappingURL=gauge.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"power-off\",\n size: 24,\n node: [\n [\"path\", { d: \"M18.36 6.64A9 9 0 0 1 20.77 15\", key: \"dxknvb\" }],\n [\"path\", { d: \"M6.16 6.16a9 9 0 1 0 12.68 12.68\", key: \"1x7qb5\" }],\n [\"path\", { d: \"M12 2v4\", key: \"3427ic\" }],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }]\n ]\n};\n__iconData.node;\nconst PowerOff = createLucideIcon(__iconData);\n\nexport { __iconData, PowerOff as default };\n//# sourceMappingURL=power-off.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"rotate-cw\",\n size: 24,\n node: [\n [\"path\", { d: \"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\", key: \"1p45f6\" }],\n [\"path\", { d: \"M21 3v5h-5\", key: \"1q7to0\" }]\n ]\n};\n__iconData.node;\nconst RotateCw = createLucideIcon(__iconData);\n\nexport { __iconData, RotateCw as default };\n//# sourceMappingURL=rotate-cw.mjs.map\n","import type { Eligibility, Task } from \"@switchyard/protocol\";\nimport { PRIORITY_LABELS } from \"@switchyard/protocol\";\nimport {\n CalendarClock,\n CircleCheck,\n CirclePause,\n ExternalLink,\n FolderLock,\n Gauge,\n Inbox,\n Link2,\n LoaderCircle,\n type LucideIcon,\n PowerOff,\n RotateCw,\n Timer,\n TriangleAlert,\n WifiOff,\n} from \"lucide-react\";\nimport { useId, useMemo, useState } from \"react\";\nimport { Link } from \"react-router\";\nimport { ROUTES } from \"../../app/routes\";\nimport { buttonClasses } from \"../../components/ui/Button\";\nimport { PrioritySelect } from \"../../components/ui/Priority\";\nimport { Spinner } from \"../../components/ui/Spinner\";\nimport { StatusChip } from \"../../components/ui/StatusChip\";\nimport {\n EmptyState,\n ErrorState,\n FatalError,\n HostUnavailable,\n LastKnownNote,\n LoadingState,\n UnsupportedCapability,\n} from \"../../components/ui/states\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { formatRelative } from \"../../lib/time\";\nimport { errorMessage, isApiError } from \"../../sync/api\";\nimport { useSyncStore } from \"../../sync/store\";\nimport { updateTask } from \"../board/api\";\nimport { DispatchToggle } from \"../board/BoardChrome\";\nimport { isRunActive, WAIT_LABELS, type WaitReason } from \"../board/logic\";\nimport { UnfilteredNote } from \"../views/UnfilteredNote\";\nimport { useNow } from \"./useNow\";\n\nconst WAIT_ICONS: Record<WaitReason, LucideIcon> = {\n dependency: Link2,\n host_offline: WifiOff,\n project_limit: Gauge,\n workspace_occupied: FolderLock,\n scheduled_time: CalendarClock,\n invalid_configuration: TriangleAlert,\n dispatch_paused: CirclePause,\n project_automation_disabled: PowerOff,\n not_ready: Inbox,\n already_dispatched: LoaderCircle,\n retry_backoff: RotateCw,\n};\n\n/** /queue: running and queued work, each queued row explaining its wait. */\nexport default function QueueView() {\n const now = useNow();\n const tasks = useSyncStore((s) => s.tasks);\n const runs = useSyncStore((s) => s.runs);\n const hydrated = useSyncStore((s) => s.hydrated);\n const unsupported = isApiError(now.error) && now.error.status === 404;\n const malformed =\n !!now.data && (!Array.isArray(now.data.running) || !Array.isArray(now.data.queued));\n\n // Running from the server, or from the store when the endpoint is unavailable.\n const running = useMemo(() => {\n if (now.data && !malformed)\n return now.data.running.map((r) => ({\n taskId: r.taskId,\n runId: r.runId,\n sessionId: r.sessionId,\n }));\n return Object.values(runs)\n .filter((r) => isRunActive(r) && r.state !== \"queued\")\n .map((r) => ({ taskId: r.taskId, runId: r.id, sessionId: r.sessionId }));\n }, [now.data, runs, malformed]);\n const queued = useMemo(() => {\n if (now.data && !malformed)\n return now.data.queued.map((q) => ({\n taskId: q.taskId,\n eligibility: q.eligibility as Eligibility | undefined,\n }));\n return Object.values(tasks)\n .filter((t) => t.state === \"ready\" && !t.hiddenFromBoard)\n .sort((a, b) => a.priority - b.priority || a.position - b.position)\n .map((t) => ({ taskId: t.id, eligibility: undefined as Eligibility | undefined }));\n }, [now.data, tasks, malformed]);\n\n const loading = (!now.data && now.loading && !now.error) || !hydrated;\n const fatal = !!now.error && !unsupported && !now.data;\n if (malformed)\n return (\n <FatalError\n title=\"The coordinator sent a queue this version cannot read\"\n error=\"GET /api/now returned an unexpected shape. Check that the web app and coordinator versions match.\"\n />\n );\n\n return (\n <div className=\"flex w-full min-w-0 flex-col gap-4 px-4 pb-4 safe-pt-4 md:px-6\">\n <header className=\"flex min-w-0 flex-wrap items-center gap-3\">\n <h1 className=\"flex-1 text-lg font-semibold\">Queue</h1>\n <DispatchToggle />\n </header>\n <UnfilteredNote what=\"tasks\" />\n <p className=\"text-sm text-muted\">\n Pausing stops new work from starting. Runs already in progress keep going.\n </p>\n <LastKnownNote subject=\"queue\" show={!!now.data} />\n {unsupported && (\n <UnsupportedCapability\n capability=\"Queue explanations\"\n reason=\"This coordinator does not report why queued tasks are waiting. The list below comes from local data.\"\n />\n )}\n {now.error != null && !unsupported && (\n <ErrorState\n compact\n title=\"Could not refresh running and queued work\"\n error={errorMessage(now.error)}\n onRetry={now.reload}\n />\n )}\n\n {loading ? (\n <LoadingState label=\"Loading running and queued work…\" />\n ) : fatal && running.length === 0 && queued.length === 0 ? null : running.length === 0 &&\n queued.length === 0 ? (\n <EmptyState\n icon={<Timer className=\"size-8\" />}\n title=\"Nothing running or queued\"\n description=\"Move a task to Ready on the board and the dispatcher starts it when it is eligible.\"\n action={{ label: \"Go to Tasks\", to: ROUTES.tasks }}\n />\n ) : (\n <section\n aria-label=\"Running and queued tasks\"\n tabIndex={-1}\n data-keyboard-scope\n data-keyboard-default\n className=\"grid min-w-0 grid-cols-1 gap-4 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent xl:grid-cols-2 xl:items-start\"\n >\n <section aria-labelledby=\"now-running\" className=\"flex min-w-0 flex-col gap-2\">\n <h2 id=\"now-running\" className=\"text-base font-semibold\">\n Running <span className=\"text-sm font-normal text-muted\">({running.length})</span>\n </h2>\n {running.length === 0 ? (\n <p className=\"text-sm text-muted\">Nothing is running.</p>\n ) : (\n <ul className=\"flex min-w-0 flex-col gap-2\">\n {running.map((r) => (\n <li key={r.runId}>\n <RunningRow taskId={r.taskId} runId={r.runId} sessionId={r.sessionId} />\n </li>\n ))}\n </ul>\n )}\n </section>\n <section aria-labelledby=\"now-queued\" className=\"flex min-w-0 flex-col gap-2\">\n <h2 id=\"now-queued\" className=\"text-base font-semibold\">\n Queued <span className=\"text-sm font-normal text-muted\">({queued.length})</span>\n </h2>\n {queued.length === 0 ? (\n <p className=\"text-sm text-muted\">No Ready tasks are waiting.</p>\n ) : (\n <ul className=\"flex min-w-0 flex-col gap-2\">\n {queued.map((q) => (\n <li key={q.taskId}>\n <QueuedRow\n task={tasks[q.taskId]}\n taskId={q.taskId}\n eligibility={q.eligibility}\n />\n </li>\n ))}\n </ul>\n )}\n </section>\n </section>\n )}\n </div>\n );\n}\n\nfunction RunningRow({\n taskId,\n runId,\n sessionId,\n}: {\n taskId: string;\n runId: string;\n sessionId: string | null;\n}) {\n const task = useSyncStore((s) => s.tasks[taskId]);\n const run = useSyncStore((s) => s.runs[runId]);\n const host = useSyncStore((s) => (run?.hostId ? s.hosts[run.hostId] : undefined));\n const project = useSyncStore((s) => (task ? s.projects[task.projectId] : undefined));\n const offline = !!host && host.connectivity !== \"connected\";\n return (\n <article className=\"flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3\">\n <div className=\"flex min-w-0 flex-wrap items-start gap-2\">\n {run ? (\n <StatusChip kind=\"run\" value={run.state} size=\"sm\" />\n ) : (\n <StatusChip kind=\"task\" value=\"in_progress\" size=\"sm\" />\n )}\n <Link\n to={ROUTES.task(taskId)}\n data-keyboard-item\n className=\"min-w-0 flex-1 basis-48 font-medium break-words hover:underline\"\n >\n {task?.title ?? \"Task\"}\n </Link>\n {(sessionId ?? task?.sessionId) && (\n <Link\n to={ROUTES.session((sessionId ?? task?.sessionId) as string)}\n className={buttonClasses(\"secondary\", \"sm\")}\n >\n <ExternalLink aria-hidden className=\"size-3.5\" />\n Open session\n </Link>\n )}\n </div>\n <p className=\"text-xs text-muted\">\n {[\n project?.name,\n host ? `on ${host.name}` : null,\n run?.attempt && run.attempt > 1 ? `attempt ${run.attempt}` : null,\n run?.startedAt ? `started ${formatRelative(run.startedAt)}` : null,\n run?.controlMode === \"human\" ? \"you have control\" : \"automation\",\n ]\n .filter(Boolean)\n .join(\" · \")}\n </p>\n {run?.state === \"uncertain\" && host && (\n <p className=\"text-sm text-warning\">\n <span className=\"text-text\">\n Waiting for host {host.name} to confirm launch. It is never started elsewhere.\n </span>\n </p>\n )}\n {offline && host && (\n <HostUnavailable\n compact\n hostName={host.name}\n connectivity={host.connectivity === \"reconnecting\" ? \"reconnecting\" : \"unreachable\"}\n lastSeenAt={host.lastSeenAt}\n />\n )}\n </article>\n );\n}\n\nfunction QueuedRow({\n task,\n taskId,\n eligibility,\n}: {\n task: Task | undefined;\n taskId: string;\n eligibility?: Eligibility;\n}) {\n const project = useSyncStore((s) => (task ? s.projects[task.projectId] : undefined));\n const [busy, setBusy] = useState(false);\n const id = useId();\n const Icon = eligibility\n ? eligibility.eligible\n ? CircleCheck\n : WAIT_ICONS[eligibility.wait]\n : Timer;\n const waitLabel = eligibility\n ? eligibility.eligible\n ? `Starting on ${eligibility.hostName}`\n : WAIT_LABELS[eligibility.wait]\n : \"Waiting for dispatch\";\n const detail = eligibility && !eligibility.eligible ? eligibility.message : null;\n return (\n <article\n data-testid=\"now-queued-row\"\n className=\"flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 sm:flex-row sm:items-center\"\n >\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <Link\n to={ROUTES.task(taskId)}\n data-keyboard-item\n className=\"min-w-0 font-medium break-words hover:underline\"\n >\n {task?.title ?? \"Task\"}\n </Link>\n {project && <span className=\"text-xs text-muted\">{project.name}</span>}\n <p className=\"flex min-w-0 items-start gap-1.5 text-sm\">\n <Icon\n aria-hidden\n className={`mt-0.5 size-4 shrink-0 ${eligibility?.eligible ? \"text-success\" : \"text-warning\"}`}\n />\n <span className=\"min-w-0 break-words\">\n <span className=\"font-medium\">{waitLabel}</span>\n {detail && detail !== waitLabel ? <span className=\"text-muted\">: {detail}</span> : null}\n </span>\n </p>\n </div>\n {task && (\n <div className=\"flex shrink-0 items-center gap-2\">\n <label htmlFor={id} className=\"text-sm text-muted\">\n Priority\n </label>\n <PrioritySelect\n id={id}\n width=\"auto\"\n value={task.priority}\n disabled={busy}\n onChange={async (p) => {\n setBusy(true);\n try {\n await updateTask(task.id, { priority: p });\n toast.success(`\"${task.title}\" is now ${PRIORITY_LABELS[p]} priority`);\n } catch (err) {\n toast.error(`Could not change priority: ${errorMessage(err)}`);\n } finally {\n setBusy(false);\n }\n }}\n />\n {busy && <Spinner label=\"Saving priority\" />}\n </div>\n )}\n </article>\n );\n}\n"],"ignoreList":[0,1,2,3],"mappings":"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"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,i as t,o as n,t as r,y as i}from"./Button-C7TQGuSX.js";import{a,an as o,f as s,on as c,rn as l,tn as u}from"./states-hyf_ATdQ.js";import{s as d}from"./useBreakpoint-BYCN9s8X.js";import{t as f}from"./TextLink-BGtYWCW9.js";import{t as p}from"./Card-DzHrwFrv.js";import{t as m}from"./Checkbox-BnRsg6ki.js";var h={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};h.node;var g=n(h),_={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};_.node;var v=n(_),y=e(i(),1),b=t();function x({host:e,compact:t}){let[n,i]=(0,y.useState)(null),[h,g]=(0,y.useState)(new Set),[_,v]=(0,y.useState)(null),[x,S]=(0,y.useState)(!1),C=e.connectivity===`connected`;if((0,y.useEffect)(()=>{if(!C)return;let t=!0;return u(`/api/hosts/${encodeURIComponent(e.id)}/project-suggestions`).then(e=>{t&&(i(e.suggestions),g(new Set(e.suggestions.filter(e=>e.preselected).map(e=>e.rootPath))))},e=>{t&&!c(e,`unsupported_capability`)&&v(e)}),()=>{t=!1}},[e.id,C]),!n||n.length===0)return _?(0,b.jsx)(a,{error:_}):null;if(t)return(0,b.jsxs)(`p`,{"data-testid":`project-suggestions-line`,className:`flex flex-wrap items-baseline justify-center gap-x-1.5 px-2 pb-3 text-center text-xs text-muted`,children:[(0,b.jsxs)(`span`,{children:[n.length,` `,n.length===1?`repository`:`repositories`,` found in your Pi history`]}),(0,b.jsx)(f,{to:`/settings/projects`,size:`xs`,variant:`action`,children:`Review`})]});let w=async()=>{S(!0);let t=0,r=[];for(let i of n.filter(e=>h.has(e.rootPath)))try{await l(`/api/projects`,{name:i.name,hostId:e.id,path:i.rootPath}),t+=1}catch(e){c(e,`conflict`)?t+=1:r.push(`${i.name}: ${o(e)}`)}S(!1),t>0&&d.success(`Added ${t} project${t===1?``:`s`}`);for(let e of r)d.error(e);i(e=>e?.filter(e=>!h.has(e.rootPath))??null),g(new Set)};return(0,b.jsx)(p,{testId:`project-suggestions`,title:`Suggested from your Pi history`,description:`Repositories you used with Pi in the last 30 days on ${e.name}.`,actions:(0,b.jsx)(r,{variant:`primary`,size:`sm`,busy:x,disabled:h.size===0,onClick:()=>void w(),children:`Add selected`}),children:(0,b.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(e=>(0,b.jsx)(`li`,{children:(0,b.jsx)(m,{label:e.name,description:(0,b.jsxs)(`span`,{className:`font-mono text-xs break-all text-muted`,children:[e.rootPath,` · `,e.sessionCount,` session`,e.sessionCount===1?``:`s`,` · last`,` `,s(e.lastActivityAt)]}),checked:h.has(e.rootPath),onChange:t=>g(n=>{let r=new Set(n);return t?r.add(e.rootPath):r.delete(e.rootPath),r})})},e.rootPath))})})}function S(e){return e.startsWith(`local:`)?`Local only`:e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``)}function C(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.repoIdentity.toLowerCase().includes(n)}export{g as a,v as i,S as n,x as r,C as t};
|
|
2
|
-
//# sourceMappingURL=repo-DRwGWCut.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repo-DRwGWCut.js","names":["__iconData","useState","__toESM","require_jsx_runtime","createLucideIcon","Button","require_react","errorMessage","formatRelative","isApiError","apiPost","apiGet","toast","TextLink","Card","Checkbox","__iconData$1","BellOff","__iconData","Send","import_react","import_jsx_runtime","ProjectSuggestions","items","setItems","checked","setChecked","error","setError","busy","setBusy","connected","host","alive","r","s","InlineError","compact","add","added","failed","i","f","prev","next","on","repoLabel","identity","matchesProject","q","query","p"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/bell-off.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/send.mjs","../../src/features/settings/ProjectSuggestions.tsx","../../src/lib/repo.ts"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"bell-off\",\n size: 24,\n node: [\n [\"path\", { d: \"M10.268 21a2 2 0 0 0 3.464 0\", key: \"vwvbt9\" }],\n [\n \"path\",\n {\n d: \"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742\",\n key: \"178tsu\"\n }\n ],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }],\n [\"path\", { d: \"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05\", key: \"1hqiys\" }]\n ]\n};\n__iconData.node;\nconst BellOff = createLucideIcon(__iconData);\n\nexport { __iconData, BellOff as default };\n//# sourceMappingURL=bell-off.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"send\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z\",\n key: \"1ffxy3\"\n }\n ],\n [\"path\", { d: \"m21.854 2.147-10.94 10.939\", key: \"12cjpa\" }]\n ]\n};\n__iconData.node;\nconst Send = createLucideIcon(__iconData);\n\nexport { __iconData, Send as default };\n//# sourceMappingURL=send.mjs.map\n","import type { Host, ProjectSuggestionsResponse } from \"@switchyard/protocol\";\nimport { useEffect, useState } from \"react\";\nimport { Button } from \"../../components/ui/Button\";\nimport { Card } from \"../../components/ui/Card\";\nimport { Checkbox } from \"../../components/ui/Checkbox\";\nimport { InlineError } from \"../../components/ui/states\";\nimport { TextLink } from \"../../components/ui/TextLink\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { formatRelative } from \"../../lib/time\";\nimport { apiGet, apiPost, errorMessage, isApiError } from \"../../sync/api\";\n\n/**\n * Repositories used with Pi recently on a host, to add as projects in one step. `compact` (the\n * narrow Sessions navigator) is one line linking to Settings > Projects, where the full list is.\n */\nexport function ProjectSuggestions({ host, compact }: { host: Host; compact?: boolean }) {\n const [items, setItems] = useState<ProjectSuggestionsResponse[\"suggestions\"] | null>(null);\n const [checked, setChecked] = useState<Set<string>>(new Set());\n const [error, setError] = useState<unknown>(null);\n const [busy, setBusy] = useState(false);\n const connected = host.connectivity === \"connected\";\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: load once per host and connection\n useEffect(() => {\n if (!connected) return;\n let alive = true;\n apiGet<ProjectSuggestionsResponse>(\n `/api/hosts/${encodeURIComponent(host.id)}/project-suggestions`,\n ).then(\n (r) => {\n if (!alive) return;\n setItems(r.suggestions);\n setChecked(new Set(r.suggestions.filter((s) => s.preselected).map((s) => s.rootPath)));\n },\n (e) => {\n if (alive && !isApiError(e, \"unsupported_capability\")) setError(e);\n },\n );\n return () => {\n alive = false;\n };\n }, [host.id, connected]);\n\n if (!items || items.length === 0) {\n return error ? <InlineError error={error} /> : null;\n }\n\n if (compact) {\n return (\n <p\n data-testid=\"project-suggestions-line\"\n className=\"flex flex-wrap items-baseline justify-center gap-x-1.5 px-2 pb-3 text-center text-xs text-muted\"\n >\n <span>\n {items.length} {items.length === 1 ? \"repository\" : \"repositories\"} found in your Pi\n history\n </span>\n <TextLink to=\"/settings/projects\" size=\"xs\" variant=\"action\">\n Review\n </TextLink>\n </p>\n );\n }\n\n const add = async () => {\n setBusy(true);\n let added = 0;\n const failed: string[] = [];\n for (const s of items.filter((i) => checked.has(i.rootPath))) {\n try {\n await apiPost(\"/api/projects\", { name: s.name, hostId: host.id, path: s.rootPath });\n added += 1;\n } catch (e) {\n if (isApiError(e, \"conflict\")) added += 1;\n else failed.push(`${s.name}: ${errorMessage(e)}`);\n }\n }\n setBusy(false);\n if (added > 0) toast.success(`Added ${added} project${added === 1 ? \"\" : \"s\"}`);\n for (const f of failed) toast.error(f);\n setItems((prev) => prev?.filter((i) => !checked.has(i.rootPath)) ?? null);\n setChecked(new Set());\n };\n\n return (\n <Card\n testId=\"project-suggestions\"\n title=\"Suggested from your Pi history\"\n description={`Repositories you used with Pi in the last 30 days on ${host.name}.`}\n actions={\n <Button\n variant=\"primary\"\n size=\"sm\"\n busy={busy}\n disabled={checked.size === 0}\n onClick={() => void add()}\n >\n Add selected\n </Button>\n }\n >\n <ul className=\"flex flex-col gap-1\">\n {items.map((s) => (\n <li key={s.rootPath}>\n <Checkbox\n label={s.name}\n description={\n <span className=\"font-mono text-xs break-all text-muted\">\n {s.rootPath} · {s.sessionCount} session{s.sessionCount === 1 ? \"\" : \"s\"} · last{\" \"}\n {formatRelative(s.lastActivityAt)}\n </span>\n }\n checked={checked.has(s.rootPath)}\n onChange={(on) =>\n setChecked((prev) => {\n const next = new Set(prev);\n if (on) next.add(s.rootPath);\n else next.delete(s.rootPath);\n return next;\n })\n }\n />\n </li>\n ))}\n </ul>\n </Card>\n );\n}\n","import type { Project } from \"@switchyard/protocol\";\n\n/** \"Local only\" for repositories without a remote (`local:<sha|path>`), else the remote without its scheme. */\nexport function repoLabel(identity: string): string {\n if (identity.startsWith(\"local:\")) return \"Local only\";\n return identity.replace(/^[a-z][a-z0-9+.-]*:\\/\\//i, \"\");\n}\n\n/** Case-insensitive match on project name or remote. */\nexport function matchesProject(p: Pick<Project, \"name\" | \"repoIdentity\">, query: string): boolean {\n const q = query.trim().toLowerCase();\n if (!q) return true;\n return p.name.toLowerCase().includes(q) || p.repoIdentity.toLowerCase().includes(q);\n}\n"],"ignoreList":[0,1],"mappings":"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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{S as e,_ as t,a as n,d as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,t as f,v as p,y as m}from"./Button-C7TQGuSX.js";import{C as h,b as g,o as _,p as v,u as y,v as b,w as x}from"./keyboardLayers-BZOygMAH.js";import{$t as S,Ct as C,Dt as w,Ft as T,It as E,J as ee,L as D,M as te,Mt as O,O as k,Qt as ne,Rt as re,St as ie,Tt as ae,Wt as oe,_ as se,a as A,an as j,c as M,en as ce,f as N,gt as le,h as ue,i as de,in as fe,jt as pe,kt as me,m as he,n as P,nn as F,on as ge,p as _e,r as ve,rn as I,s as L,t as R,tn as ye,u as be,v as xe,wt as Se,xt as Ce}from"./states-hyf_ATdQ.js";import{a as we,i as Te,n as Ee,r as De,t as Oe}from"./repo-DRwGWCut.js";import{t as ke}from"./chevron-right-BM1IJI2z.js";import{d as Ae,f as je,n as Me,p as Ne,r as Pe,s as z,t as Fe,u as Ie}from"./useBreakpoint-BYCN9s8X.js";import{a as Le,i as Re,o as ze,r as B,t as V}from"./Field-Cp-08kpe.js";import{t as Be}from"./UINodeRenderer-BaANWHvJ.js";import{n as Ve,t as He}from"./pencil-DeML-0z2.js";import{t as Ue}from"./plus-C83uJhbf.js";import{n as We,t as Ge}from"./DangerZone-BicyqXv8.js";import{t as Ke}from"./search-C5H14z0D.js";import{t as qe}from"./terminal-CATQN_17.js";import{a as Je,i as Ye,o as Xe,r as Ze,s as Qe,t as $e}from"./policyLogic-DqKyFQEW.js";import{A as et,An as tt,C as nt,D as rt,Dn as it,E as H,M as U,N as at,O as ot,On as st,S as ct,T as lt,a as ut,an as W,bn as dt,c as ft,fn as pt,gn as mt,i as ht,in as gt,j as _t,k as G,mn as vt,n as yt,nn as bt,o as xt,on as St,r as Ct,s as wt,sn as Tt,t as Et,vn as Dt,w as Ot,wn as kt,x as At,xn as jt,yn as Mt}from"./index-BUZpNu-R.js";import{t as Nt}from"./TextLink-BGtYWCW9.js";import{n as Pt,t as K}from"./useResource-DYNGG9XS.js";import{t as q}from"./Card-DzHrwFrv.js";import{t as J}from"./Select-DHRR7IAK.js";import{n as Y,t as Ft}from"./Switch-D5pVfZgf.js";import{c as It,r as Lt,s as Rt}from"./describe-B66LJTqU.js";import{t as zt}from"./Checkbox-BnRsg6ki.js";import{d as Bt,f as Vt,l as Ht,r as Ut}from"./logic-BnSIy9_P.js";var Wt={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};Wt.node;var Gt=l(Wt),Kt={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Kt.node;var qt=l(Kt),Jt={name:`folder-search`,size:24,node:[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]};Jt.node;var Yt=l(Jt),Xt={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};Xt.node;var Zt=l(Xt),Qt={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Qt.node;var $t=l(Qt),en={name:`shield-off`,size:24,node:[[`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`}]]};en.node;var tn=l(en),nn={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};nn.node;var rn=l(nn),an={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};an.node;var on=l(an),X=e(m(),1),Z=a(),sn=`Preview action — not sent to Pi`;function cn(e){return`${sn}\n${JSON.stringify(e,null,2)}`}function ln({initialJson:e=``}){let t=(0,X.useId)(),[n,r]=(0,X.useState)(e),[i,a]=(0,X.useState)(()=>{try{return e?w(e):null}catch{return null}}),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)([]),p=e=>{c||d(t=>[...t.slice(-99),cn(e)])},m=e=>{a(null),d([]);try{a(w(e)),s(null)}catch(e){s(e instanceof Error?e.message:String(e))}};return(0,Z.jsxs)(`details`,{className:`min-w-0 rounded-lg border border-border p-4`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`Portable UI preview`}),(0,Z.jsxs)(`div`,{className:`mt-3 flex min-w-0 flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Developer tool. Run adapter:preview with an explicitly selected trusted adapter in a separate Node process (not a sandbox), then paste or upload its JSON here. This browser only renders portable UI and simulates actions. Nothing is installed, persisted or sent to Pi or the server.`}),(0,Z.jsx)(`label`,{htmlFor:`${t}-json`,className:`text-sm font-medium`,children:`Preview JSON (up to 1 MiB)`}),(0,Z.jsx)(`textarea`,{id:`${t}-json`,className:`min-h-40 w-full rounded border border-border bg-surface p-2 font-mono text-xs`,value:n,onChange:e=>r(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(f,{onClick:()=>m(n),children:`Render preview`}),(0,Z.jsxs)(`label`,{className:`text-sm`,children:[`Upload preview JSON`,(0,Z.jsx)(`input`,{type:`file`,accept:`.json,application/json`,className:`ml-2 max-w-full`,onChange:async e=>{let t=e.target.files?.[0];if(t){if(t.size>1048576)a(null),s(`Preview exceeds 1 MiB input limit`);else try{let e=await t.text();r(e),m(e)}catch(e){s(String(e))}}}})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked)}),`Simulate read-only / disabled`]}),(0,Z.jsx)(f,{variant:`secondary`,onClick:()=>{r(``),a(null),d([]),s(null)},children:`Clear preview`})]}),o&&(0,Z.jsx)(`pre`,{role:`alert`,className:`max-h-52 overflow-auto whitespace-pre-wrap break-words text-sm text-danger`,children:o}),i&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h3`,{className:`font-medium`,children:[i.name,` · `,i.adapter.id,`@`,i.adapter.version]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 2xl:grid-cols-[minmax(0,1fr)_390px]`,children:[(0,Z.jsx)(un,{preview:i,phone:!1,disabled:c,onAction:p}),(0,Z.jsx)(un,{preview:i,phone:!0,disabled:c,onAction:p})]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{children:`Steps and diagnostics`}),(0,Z.jsxs)(`ul`,{className:`text-sm`,children:[i.steps.map(e=>(0,Z.jsxs)(`li`,{children:[e.index+1,`. `,e.kind,`: `,e.ok?`OK`:e.error]},e.index)),i.diagnostics.map((e,t)=>(0,Z.jsxs)(`li`,{children:[e.level,`: `,e.message]},`${t}-${e.at}`))]})]})]}),(0,Z.jsxs)(`section`,{"aria-label":`Preview action log`,className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-medium`,children:`Local simulated actions`}),u.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No preview actions yet.`}),(0,Z.jsx)(`pre`,{"aria-live":`polite`,className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-xs`,children:u.join(`
|
|
2
|
-
|
|
3
|
-
`)})]})]})]})}function un({preview:e,phone:t,disabled:n,onAction:r}){let i=e=>{n||r(e)},a=(e,t,r=!1)=>(0,Z.jsx)(Be,{node:e,disabled:n||r,busy:!1,onRespond:e=>{r||i({...t,payload:e})},onAction:e=>{r||i({...t,actionId:e})},onOpenFile:e=>i({source:`file`,payload:{path:e}})}),o=e=>(0,Z.jsxs)(`article`,{className:`min-w-0 rounded border border-border p-3`,children:[(0,Z.jsx)(`h4`,{className:`mb-2 text-sm font-semibold`,children:e.title}),e.node?a(e.node,{source:e.contribution?.placement??`panel`,adapterId:e.adapterId,actionId:e.contribution?.actionId}):(0,Z.jsx)(`p`,{className:`text-sm`,children:e.mobileFallback}),e.contribution?.actionId&&[`palette.item`,`slash.command`].includes(e.contribution.placement)&&e.node?.t!==`form`&&(0,Z.jsxs)(f,{disabled:n,onClick:()=>i({source:e.contribution.placement,adapterId:e.adapterId,actionId:e.contribution.actionId}),children:[`Simulate `,e.title]})]},JSON.stringify([e.adapterId,e.slot]));return(0,Z.jsx)(`section`,{"aria-label":t?`Phone preview 390px`:`Desktop preview`,className:`min-w-0 max-w-full overflow-x-auto rounded-xl border border-border bg-surface-1 p-3`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&(e.preventDefault(),e.stopPropagation(),i({source:`link`,payload:{href:t.getAttribute(`href`)}}))},children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,style:t?{width:390,maxWidth:`100%`}:void 0,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[t?`Phone · 390px`:`Desktop · portable UI`,n?` · Read-only`:``]}),e.panels.filter(e=>!e.contribution).map(o),[`sidebar.header`,`session.panel`,`composer.pill`,`palette.item`,`slash.command`,`sidebar.footer`].map(n=>{let r=e.panels.filter(e=>e.contribution?.placement===n).sort((e,t)=>(e.contribution?.order??0)-(t.contribution?.order??0));return r.length?(0,Z.jsxs)(`section`,{"aria-label":n,className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-xs text-muted`,children:t&&n.startsWith(`sidebar.`)?`Details · ${n}`:n}),r.map(o)]},n):null}),e.interactions.map(e=>(0,Z.jsxs)(`article`,{"aria-label":`Question: ${e.request.title}`,className:`min-w-0 rounded border border-border p-3`,children:[(0,Z.jsxs)(`h4`,{className:`mb-2 text-sm font-semibold`,children:[e.request.title,` · `,e.state]}),a(e.presentation,{source:`interaction`,requestId:e.request.id},e.state===`resolved`)]},e.request.id)),e.cards.map((e,t)=>(0,Z.jsx)(`article`,{className:`min-w-0 rounded border border-border p-3`,children:a(e,{source:`card`,payload:{index:t}})},`card-${t}`))]})})}function dn(e,t,n){let r=new Set,i=[];for(let a of[...e??[],...t]){let e=a.hostId??(a.sessionId?n[a.sessionId]?.hostId:void 0),t=e?{...a,hostId:e}:a,o=JSON.stringify([t.hostId??null,t.at,t.adapterId,t.sessionId,t.message]);r.has(o)||(r.add(o),i.push(t))}return i.sort((e,t)=>t.at.localeCompare(e.at))}function fn(e){return K(e)&&K(e.versions)}var pn=`/api/diagnostics`,mn={active:{icon:Ne,label:`Active`,tone:`success`},disabled:{icon:g,label:`Disabled`,tone:`neutral`},error:{icon:je,label:`Error`,tone:`danger`}};function hn({status:e}){let t=mn[e]??mn.error;return(0,Z.jsx)(_,{icon:t.icon,label:t.label,tone:t.tone})}var gn={project:`Project`,owner:`Owner`,plugin:`Plugin`,bundled:`Bundled`},_n={info:{icon:Ie,label:`Info`,tone:`info`},warning:{icon:he,label:`Warning`,tone:`warning`},error:{icon:je,label:`Error`,tone:`danger`}};function vn({level:e}){let t=_n[e]??_n.info;return(0,Z.jsx)(_,{icon:t.icon,label:t.label,tone:t.tone})}function yn(e){let t=D(e=>e.diagnostics),n=D(e=>e.sessions);return(0,X.useMemo)(()=>dn(e,t,n),[e,t,n])}function bn(){let e=U(),t=D(e=>e.adapters),n=D(e=>e.hosts),r=Pt(`/api/diagnostics`,K),i=yn(Array.isArray(r.data?.diagnostics)?r.data.diagnostics:void 0),a=(0,X.useMemo)(()=>Object.entries(t).filter(([,e])=>e.length>0).map(([e,t])=>({hostId:e,hostName:n[e]?.name??`Removed host`,adapters:[...t].sort((e,t)=>e.id.localeCompare(t.id))})).sort((e,t)=>e.hostName.localeCompare(t.hostName)),[t,n]);return(0,Z.jsxs)(H,{title:`Adapters`,description:`Adapters translate Pi extensions into Switchyard cards, panels and interactions. Each host reports its own.`,children:[(0,Z.jsx)(L,{}),r.error!==null&&!r.loading&&!r.fatal&&(0,Z.jsx)(P,{compact:!0,title:`Could not load adapter diagnostics history`,error:r.error,onRetry:r.reload}),e?a.length===0?(0,Z.jsx)(R,{icon:(0,Z.jsx)(xe,{className:`size-8`}),title:`No adapters reported`,description:`Hosts report adapters when their agent connects. Check that your hosts are connected.`,action:{label:`Open hosts`,to:G(`hosts`)}}):a.map(e=>(0,Z.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,Z.jsx)(o,{to:G(`hosts/${encodeURIComponent(e.hostId)}`),className:`hover:underline`,children:e.hostName})}),e.adapters.map(t=>(0,Z.jsx)(xn,{adapter:t,diagnostics:i.filter(n=>n.adapterId===t.id&&n.hostId===e.hostId)},`${t.tier}:${t.id}`))]},e.hostId)):(0,Z.jsx)(M,{label:`Loading adapters…`}),i.some(e=>!e.hostId)&&(0,Z.jsxs)(`section`,{"aria-label":`Unscoped adapter diagnostics`,className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Unscoped diagnostics`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`These events do not identify a host or a known session.`}),(0,Z.jsx)(Sn,{diagnostics:i.filter(e=>!e.hostId&&e.adapterId)})]}),(0,Z.jsx)(pt,{fallback:(e,t)=>(0,Z.jsx)(P,{compact:!0,title:`Portable UI preview failed`,error:e,onRetry:t}),children:(0,Z.jsx)(ln,{})})]})}function xn({adapter:e,diagnostics:t}){return(0,Z.jsxs)(q,{title:(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),actions:(0,Z.jsx)(hn,{status:e.status}),children:[(0,Z.jsx)(ct,{items:[[`Version`,e.version],[`Tier`,gn[e.tier]??e.tier],[`Target extension`,(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.target.extension},`t`)],[`Version range`,(0,Z.jsx)(`span`,{className:`font-mono`,children:e.target.versionRange},`r`)],[`Tested versions`,e.target.testedVersions.length?e.target.testedVersions.join(`, `):`None recorded`],[`Capabilities`,e.capabilities.length?e.capabilities.join(`, `):`None`],[`Web renderer`,e.webRenderer?`Yes (runs in a sandboxed frame; mobile uses a fallback)`:`No (native cards only)`],...e.detail?[[`Detail`,e.detail]]:[]]}),(0,Z.jsx)(`h3`,{className:`mt-3 mb-1 text-sm font-semibold`,children:`Recent diagnostics`}),t.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics for this adapter.`}):(0,Z.jsx)(Sn,{diagnostics:t})]})}function Sn({diagnostics:e}){return(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:e.slice(0,10).map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,Z.jsx)(vn,{level:e.level}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),e.sessionId&&(0,Z.jsx)(o,{className:`text-accent hover:underline`,to:`/code/${encodeURIComponent(e.sessionId)}?tab=extensions`,children:`Session extensions`}),(0,Z.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:_e(e.at)})]},`${e.at}-${t}`))})}var Cn=`switchyard coordinator backup <file>`,wn=`switchyard coordinator restore <file>`;function Tn(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function En(e,t){return t==null?`None`:typeof t==`string`&&/At$|time|date/i.test(e)?_e(t):typeof t==`object`?JSON.stringify(t):String(t)}function Dn(){let e=Pt(pn,fn),t=e.data&&K(e.data.backup)?e.data.backup:null;return(0,Z.jsxs)(H,{title:`Backups`,description:`The coordinator keeps all state in one SQLite database. Back it up from the machine that runs the coordinator.`,children:[(0,Z.jsxs)(q,{title:`Back up`,children:[(0,Z.jsx)(`p`,{className:`mb-2 text-sm`,children:`Writes a consistent copy of the database to a file while the coordinator keeps running.`}),(0,Z.jsx)(Re,{text:Cn,label:`Backup command`,copyLabel:`Copy command`})]}),(0,Z.jsxs)(q,{title:`Restore`,children:[(0,Z.jsxs)(`p`,{className:`mb-2 text-sm`,children:[`Restore refuses to run while the coordinator is running: stop it first. The current database is kept next to it as`,` `,(0,Z.jsx)(`code`,{className:`break-all`,children:`coordinator.db.bak-<ts>`}),`.`]}),(0,Z.jsx)(Re,{text:wn,label:`Restore command`,copyLabel:`Copy command`}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:`Hosts keep running sessions during a coordinator restart and replay their events when it comes back.`})]}),(0,Z.jsx)(q,{title:`Last backup`,children:e.fatal?(0,Z.jsx)(ve,{error:e.error}):e.error&&!e.loading&&!e.data?(0,Z.jsx)(P,{compact:!0,title:`Could not load backup info`,error:e.error,onRetry:e.reload}):e.data?t&&Object.keys(t).length>0?(0,Z.jsx)(ct,{items:Object.entries(t).map(([e,t])=>[Tn(e),En(e,t)])}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No backup info is recorded by the coordinator. Keep track of your backup files yourself, or schedule the backup command with cron or launchd.`}):(0,Z.jsx)(M,{label:`Loading backup info…`})})]})}var On={browser:`Browser`,pwa:`Home Screen app`,terminal:`Terminal`,cli:`CLI`},kn={granted:`allowed`,denied:`blocked`,default:`not requested`,unknown:`unknown`};function An({kind:e}){return(0,Z.jsx)(e===`pwa`?rn:e===`browser`?Zt:qe,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`})}function jn(){let e=U(),t=D(e=>e.devices),n=D(e=>e.terminals),r=D(e=>e.views);tt(e=>e.me);let i=it(),a=(0,X.useMemo)(()=>Object.values(t).filter(e=>e.revokedAt===null).sort((e,t)=>Number(t.id===i)-Number(e.id===i)||(t.lastSeenAt??``).localeCompare(e.lastSeenAt??``)),[t,i]),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(null),w=async()=>{if(h){y(!0),x(null);try{await I(`/api/devices/${encodeURIComponent(h.id)}/revoke`),z.success(`${h.name} revoked`),g(null)}catch(e){x(e)}finally{y(!1)}}},T=async e=>{C(e.id);try{await F(`/api/devices/${encodeURIComponent(e.id)}`,{preferredMobile:!0}),z.success(`${e.name} is now the preferred mobile device`)}catch(e){z.error(`Could not set the preferred device: ${j(e)}`)}finally{C(null)}},E=async()=>{if(!o)return;let e=c.trim();if(e){d(!0),m(null);try{await F(`/api/devices/${encodeURIComponent(o.id)}`,{name:e}),z.success(`Renamed to ${e}`),s(null)}catch(e){m(e)}finally{d(!1)}}};return(0,Z.jsxs)(H,{testId:`settings-devices`,title:`Devices`,description:`Browsers, Home Screen apps and terminals signed in to this coordinator. Revoke one to sign it out.`,children:[(0,Z.jsx)(L,{}),e?a.length===0?(0,Z.jsx)(R,{icon:(0,Z.jsx)(Mt,{className:`size-8`}),title:`No devices`,description:`Browsers and terminals appear here once they sign in.`}):(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:a.map(e=>{let t=e.id===i;return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,Z.jsx)(An,{kind:e.kind}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),t&&(0,Z.jsx)(_,{icon:Zt,tone:`info`,label:`This device`}),e.preferredMobile&&(0,Z.jsx)(_,{icon:on,tone:`success`,label:`Preferred mobile`})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted`,children:[(0,Z.jsx)(`span`,{children:On[e.kind]}),(0,Z.jsxs)(`span`,{children:[`Last seen `,N(e.lastSeenAt)]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e.push.subscribed?(0,Z.jsx)(Gt,{"aria-hidden":!0,className:`size-4 shrink-0`}):(0,Z.jsx)(we,{"aria-hidden":!0,className:`size-4 shrink-0`}),e.push.subscribed?`Push subscribed`:`No push subscription`,`, permission`,` `,kn[e.push.permission]]})]}),Object.values(n).some(t=>t.deviceId===e.id)&&(0,Z.jsx)(`ul`,{"data-testid":`device-terminals`,className:`flex flex-col text-sm text-muted`,children:Object.values(n).filter(t=>t.deviceId===e.id).sort((e,t)=>e.id.localeCompare(t.id)).map(e=>(0,Z.jsxs)(`li`,{children:[e.kind,` `,e.name,` · mirrors `,Lt(e,r),` · seen`,` `,N(e.lastSeenAt)]},e.id))})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[!e.preferredMobile&&(0,Z.jsx)(f,{size:`sm`,icon:(0,Z.jsx)(on,{className:`size-4`}),busy:S===e.id,onClick:()=>T(e),children:`Set as preferred mobile device`}),(0,Z.jsx)(f,{size:`sm`,variant:`ghost`,"data-testid":`device-rename`,icon:(0,Z.jsx)(He,{className:`size-4`}),onClick:()=>{m(null),l(e.name),s(e)},children:`Rename`}),(0,Z.jsx)(f,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Z.jsx)(tn,{className:`size-4`}),onClick:()=>{x(null),g(e)},children:`Revoke`})]})]},e.id)})}):(0,Z.jsx)(M,{label:`Loading devices…`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`The preferred mobile device receives push notifications when no desktop was recently active.`}),(0,Z.jsx)(St,{open:o!==null,onClose:()=>s(null),title:`Rename device`,confirmLabel:`Save`,danger:!1,busy:u,error:p,confirmDisabled:!c.trim(),onConfirm:E,children:(0,Z.jsx)(W,{"aria-label":`Device name`,maxLength:80,value:c,autoComplete:`off`,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c.trim()&&!u&&E()}})}),(0,Z.jsxs)(St,{open:h!==null,onClose:()=>g(null),title:h?`Revoke ${h.name}?`:`Revoke device`,confirmLabel:`Revoke device`,busy:v,error:b,onConfirm:w,children:[(0,Z.jsx)(`p`,{className:`text-sm`,children:`Its credential stops working immediately and its push subscription is removed. To use it again, sign in on it again.`}),h?.id===i&&(0,Z.jsx)(`p`,{className:`text-sm font-medium text-danger`,children:`This is the device you are using now. Revoking it signs you out here.`})]})]})}function Mn(){let e=bt(e=>e.sendWithEnter),t=bt(e=>e.collapseWork),n=bt(e=>e.set),r=Fe(),i=Me();tt(e=>e.me);let a=it(),o=D(e=>a?e.devices[a]:void 0);return(0,Z.jsxs)(H,{title:`This device`,description:`These preferences are stored in this browser only; your other devices keep their own.`,children:[(0,Z.jsx)(q,{title:`Composer`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Y,{label:`Send with Enter`,description:`On desktop, Enter sends the message and Shift+Enter inserts a newline. When off, Enter inserts a newline; send with the Send button.`,checked:e,onChange:e=>n(`sendWithEnter`,e)}),(0,Z.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On mobile, Return always inserts a newline and messages are sent with the Send button.`,r===`mobile`||i?` That applies on this device now.`:``]})]})}),(0,Z.jsx)(q,{title:`Transcript`,children:(0,Z.jsx)(Y,{label:`Fold finished turns`,description:`Collapse the tool calls and thinking of each finished turn into one line. The final reply always shows.`,checked:t,onChange:e=>n(`collapseWork`,e)})}),(0,Z.jsx)(q,{title:`Identity`,children:(0,Z.jsx)(ct,{items:[[`Name`,o?.name??`Unknown`],[`Kind`,o?On[o.kind]:`Unknown`],[`Device ID`,(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:a??`Unknown`},`id`)]]})})]})}var Q=e=>e==null||e===``?`Unknown`:String(e);function Nn(){let e=Pt(pn,fn),t=e.data,n=yn(Array.isArray(t?.diagnostics)?t.diagnostics:void 0),r=D(e=>e.hosts),i=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{icon:(0,Z.jsx)(ze,{className:`size-4`}),disabled:!t,onClick:()=>t&&Le(JSON.stringify(t,null,2),`Diagnostics JSON copied`),children:`Copy diagnostics JSON`}),(0,Z.jsx)(f,{busy:e.loading&&!!t,icon:(0,Z.jsx)(se,{className:`size-4`}),onClick:e.reload,children:`Refresh`})]}),a;if(e.fatal)a=(0,Z.jsx)(ve,{error:e.error,diagnosticsHref:`/settings/diagnostics`});else if(e.error&&!e.loading&&!t)a=(0,Z.jsx)(P,{title:`Could not load diagnostics`,error:e.error,onRetry:e.reload});else if(!t)a=(0,Z.jsx)(M,{label:`Loading diagnostics…`});else{let i=t.migrationLevel!==void 0&&t.latestMigration!==void 0&&t.migrationLevel>=t.latestMigration,o=(t.hosts??[]).filter(e=>!e.revokedAt);a=(0,Z.jsxs)(Z.Fragment,{children:[e.error&&!e.loading?(0,Z.jsx)(P,{compact:!0,title:`Refresh failed`,error:e.error,onRetry:e.reload}):null,(0,Z.jsx)(q,{title:`Versions`,children:(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsxs)(`table`,{className:`w-full min-w-0 text-left text-sm`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-border text-muted`,children:[(0,Z.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Component`}),(0,Z.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:`Version`})]})}),(0,Z.jsxs)(`tbody`,{children:[Object.entries(t.versions).map(([e,t])=>(0,Z.jsxs)(`tr`,{className:`border-b border-border last:border-b-0`,children:[(0,Z.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal capitalize`,children:e}),(0,Z.jsx)(`td`,{className:`py-1 font-mono break-all`,children:Q(t)})]},e)),(0,Z.jsxs)(`tr`,{children:[(0,Z.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal`,children:`Supported Pi`}),(0,Z.jsx)(`td`,{className:`py-1 font-mono`,children:ee})]})]})]})})}),(0,Z.jsx)(q,{title:`Coordinator`,children:(0,Z.jsx)(ct,{items:[[`Database migration`,(0,Z.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{children:[`Level `,Q(t.migrationLevel),` of `,Q(t.latestMigration)]}),i?(0,Z.jsx)(_,{icon:Ne,tone:`success`,label:`Up to date`}):(0,Z.jsx)(_,{icon:he,tone:`warning`,label:`Behind latest`})]},`m`)],[`Public URL`,(0,Z.jsx)(`span`,{className:`break-all`,children:Q(t.publicUrl)},`u`)],[`Events`,t.events?`Seq ${Q(t.events.minSeq)} to ${Q(t.events.maxSeq)} stored (current ${Q(t.events.currentSeq)}, oldest retained ${Q(t.events.minRetainedSeq)})`:`Unknown`],[`Event retention`,t.events?.retentionDays==null?`Unknown`:`${t.events.retentionDays} days`],[`Push`,t.push?`${t.push.vapidConfigured?`VAPID keys configured`:`VAPID keys not configured`}, ${Q(t.push.subscriptions)} subscription(s)`:`Unknown`],[`Connected clients`,`${Q(t.clients?.connectedDevices)} device(s)`]]})}),(0,Z.jsx)(q,{title:`Hosts`,children:o.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No hosts enrolled.`}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:o.map(e=>{let t=r[e.id];return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,Z.jsx)(y,{kind:`host`,value:t?.connectivity??e.connectivity}),(0,Z.jsx)(Ot,{host:e})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Agent `,Q(e.agentVersion),` · Last seen `,N(e.lastSeenAt)]}),e.unsupported&&e.unsupported.length>0&&(0,Z.jsx)(`ul`,{className:`list-disc pl-5 text-xs text-muted`,children:e.unsupported.map(e=>(0,Z.jsxs)(`li`,{className:`break-words`,children:[e.capability,`: `,e.reason]},e.capability))})]},e.id)})})}),(0,Z.jsx)(q,{title:`Recent diagnostics`,children:n.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics recorded.`}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:n.slice(0,100).map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,Z.jsx)(vn,{level:e.level}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.message,e.adapterId&&(0,Z.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Adapter `,e.adapterId]})]}),(0,Z.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:_e(e.at)})]},`${e.at}-${t}`))})})]})}return(0,Z.jsxs)(H,{title:`Diagnostics`,description:`Versions, database state, hosts and recent problems. Copy the JSON when reporting a problem.`,actions:i,children:[(0,Z.jsx)(L,{}),a]})}function Pn(e){return I(`/api/enrollments`,{kind:e})}function Fn({expiresAt:e,onRenew:t,busy:n}){let r=_t(e);return r!==null&&r<=0?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,role:`status`,children:[(0,Z.jsx)(he,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:`Expired: create a new link`}),(0,Z.jsx)(f,{size:`sm`,busy:n,icon:(0,Z.jsx)(se,{className:`size-4`}),onClick:t,children:`Create new link`})]}):(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted`,children:[(0,Z.jsx)(Ae,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,Z.jsxs)(`span`,{children:[`Expires in`,` `,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:r===null?`unknown`:rt(r)}),`. Single use.`]})]})}function In({busy:e,error:t,onRetry:n}){return e?(0,Z.jsx)(M,{label:`Creating a single-use link…`}):t?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(A,{error:t}),(0,Z.jsx)(f,{icon:(0,Z.jsx)(se,{className:`size-4`}),onClick:n,children:`Retry`})]}):null}function Ln(e){let t=et(e),n=t.find(e=>!Ce(e));return n?{folders:t,problem:`"${n}" is not an absolute path or a ~/ path.`}:t.length>20?{folders:t,problem:`Use at most 20 folders.`}:{folders:t,problem:null}}function Rn(e,t=Date.now()){return e?e.state===`running`?`Scanning…`:e.state===`failed`?`Last scan failed ${N(e.finishedAt??e.startedAt,t)}: ${e.errors.at(-1)??`unknown error`}`:`Last scanned ${N(e.finishedAt,t)}: ${e.repositories} repositories, ${e.checkoutsAdded} new checkouts, ${e.projectsCreated} new projects.`:`Not scanned yet.`}function zn({host:e}){let t=(0,X.useId)(),n=(e.projectFolders??[]).join(`
|
|
4
|
-
`),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),d=r??n,p=r!==null&&r!==n,{folders:m,problem:h}=Ln(d),g=e.projectScan,_=s||g?.state===`running`,v=e.connectivity===`connected`,y=n?v?_?`A scan is running`:null:`${e.name} is offline`:`Save a folder first`,b=async()=>{o(!0),u(null);try{await F(`/api/hosts/${encodeURIComponent(e.id)}`,{projectFolders:m}),z.success(`Project folders saved`),i(null)}catch(e){u(e)}finally{o(!1)}},x=async()=>{c(!0),u(null);try{let t=await I(`/api/hosts/${encodeURIComponent(e.id)}/scan-projects`);z.success(`Found ${t.repositories} repositories; ${t.projectsCreated} new projects`)}catch(e){u(e)}finally{c(!1)}},S=p?h:null;return(0,Z.jsx)(q,{title:`Project folders`,description:`Every Git repository directly inside these folders becomes a project, or another checkout of the project with the same remote. Folders are rescanned when the host connects and every 10 minutes; nothing is removed automatically.`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsx)(V,{id:`${t}-folders`,label:`Folders on this host`,hint:`One per line: an absolute path or ~/..., e.g. ~/Projects.`,error:S,children:(0,Z.jsx)(gt,{id:`${t}-folders`,value:d,onChange:e=>i(e.target.value),minRows:3,placeholder:`~/Projects`,className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,...B(`${t}-folders`,{hint:!0,error:S})})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(f,{variant:`primary`,icon:(0,Z.jsx)(We,{className:`size-4`}),busy:a,disabled:!p||!!h,onClick:b,children:`Save folders`}),(0,Z.jsx)(f,{icon:(0,Z.jsx)(Yt,{className:`size-4`}),busy:s,disabled:!!y,title:y??void 0,onClick:x,children:`Scan now`})]}),(0,Z.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-muted`,children:s?`Scanning…`:Rn(g)}),g&&g.state!==`running`&&g.errors.length>0&&(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-0.5 text-xs text-muted`,children:g.errors.map(e=>(0,Z.jsx)(`li`,{className:`break-words`,children:e},e))}),(0,Z.jsx)(A,{error:l})]})})}var Bn={prompt:`Prompt`,steer:`Steer a running turn`,followUp:`Queue follow-up`,abort:`Abort`,resume:`Resume`,rename:`Rename session`,importInactive:`Import inactive sessions`,extensionDialogs:`Extension dialogs`,customUi:`Custom extension UI`,widgetsText:`Text widgets`,widgetsComponent:`Component widgets`,tokenAccounting:`Token accounting`,costAccounting:`Cost accounting`};function Vn(){let e=U(),t=k(),[n,r]=(0,X.useState)(!1),i=t.filter(e=>e.connectivity!==`connected`);return(0,Z.jsxs)(H,{testId:`settings-hosts`,title:`Hosts`,description:`Machines that run Pi sessions through the Switchyard host agent.`,actions:(0,Z.jsx)(f,{variant:`primary`,icon:(0,Z.jsx)(Ue,{className:`size-4`}),onClick:()=>r(!0),children:`Add host`}),children:[(0,Z.jsx)(L,{}),e?t.length===0?(0,Z.jsx)(R,{icon:(0,Z.jsx)(Dt,{className:`size-8`}),title:`No hosts yet`,description:`Add a host to run Pi sessions. You will get a command to run on that machine.`,action:{label:`Add host`,onClick:()=>r(!0)}}):(0,Z.jsxs)(Z.Fragment,{children:[i.length===1&&(0,Z.jsx)(de,{compact:!0,hostName:i[0].name,connectivity:i[0].connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:i[0].lastSeenAt}),i.length>1&&(0,Z.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,Z.jsx)(ue,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:Hn(i.map(e=>e.name))}),(0,Z.jsx)(`div`,{className:`text-muted`,children:`Work on them keeps its last known state; nothing is restarted elsewhere.`})]})]}),(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,Z.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Z.jsx)(Un,{host:e})},e.id))})]}):(0,Z.jsx)(M,{label:`Loading hosts…`}),(0,Z.jsx)(Kn,{open:n,onClose:()=>r(!1)})]})}function Hn(e){return`${e.length} hosts are not connected: ${e.join(`, `)}`}function Un({host:e}){return(0,Z.jsxs)(o,{to:G(`hosts/${encodeURIComponent(e.id)}`),state:Pe,className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,Z.jsx)(Dt,{"aria-hidden":!0,className:`size-5 shrink-0 self-center text-muted`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-sm text-muted`,children:nt[e.platform]})]}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(y,{kind:`host`,value:e.connectivity}),(0,Z.jsx)(Ot,{host:e}),e.connectivity!==`connected`&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Last seen `,N(e.lastSeenAt)]})]})]}),(0,Z.jsx)(ke,{"aria-hidden":!0,className:`size-4 shrink-0 self-center text-subtle`})]})}var Wn=`@spencerboucher/switchyard`;function Gn(e){return[`npm install -g ${Wn}`,e,`switchyard host install-service`].join(`
|
|
5
|
-
`)}function Kn({open:e,onClose:t}){let[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),c=async()=>{a(!0),s(null);try{r(await Pn(`host`))}catch(e){s(e)}finally{a(!1)}},l=()=>{r(null),s(null),t()};return(0,Z.jsx)(Tt,{open:e,onClose:l,title:`Add host`,description:`Enroll a machine that runs Pi. Provider credentials stay on that machine.`,footer:(0,Z.jsx)(f,{onClick:l,children:`Done`}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!n&&!i&&!o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-sm`,children:`Create a single-use enrollment, then run the command it shows on the new host. The host appears here once its agent connects.`}),(0,Z.jsx)(f,{variant:`primary`,onClick:c,children:`Create enrollment command`})]}),(0,Z.jsx)(In,{busy:i,error:o,onRetry:c}),n&&!i&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-sm`,children:`Run this on the host, as the user that should run Pi (it needs Node 24 or newer, git and Pi):`}),(0,Z.jsx)(Re,{text:n.command?Gn(n.command):n.url,label:n.command?`Host setup commands`:`Host enrollment link`,copyLabel:`Copy commands`}),(0,Z.jsx)(Fn,{expiresAt:n.expiresAt,onRenew:c,busy:i})]})]})})}function qn(){let{hostId:e=``}=p(),n=U(),r=D(t=>t.hosts[e]),i=D(t=>t.adapters[e]),a=D(e=>e.checkouts),o=D(e=>e.projects),s=t(),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),_=(0,X.useMemo)(()=>Object.values(a).filter(t=>t.hostId===e).sort((e,t)=>e.path.localeCompare(t.path)),[a,e]),v={to:G(`hosts`),label:`Hosts`};if(!n)return(0,Z.jsx)(H,{title:`Host`,back:v,children:(0,Z.jsx)(M,{label:`Loading host…`})});if(!r||r.revokedAt)return(0,Z.jsx)(H,{title:`Host`,back:v,children:(0,Z.jsx)(R,{icon:(0,Z.jsx)(Dt,{className:`size-8`}),title:r?`This host was revoked`:`Host not found`,description:r?`${r.name} was revoked ${N(r.revokedAt)}. Add it again to use it.`:`It may have been revoked or never enrolled with this coordinator.`,action:{label:`Back to hosts`,to:G(`hosts`)}})});let b=async()=>{d(!0),h(null);try{await I(`/api/hosts/${encodeURIComponent(r.id)}/revoke`),z.success(`Host ${r.name} revoked`),l(!1),s(G(`hosts`))}catch(e){h(e)}finally{d(!1)}},x=r.capabilities,S=e=>x?.unsupported.find(t=>t.capability===e)?.reason,C=x?.unsupported.filter(e=>!me.includes(e.capability))??[];return(0,Z.jsxs)(H,{title:r.name,description:`${nt[r.platform]} host`,back:v,children:[(0,Z.jsx)(L,{}),r.connectivity!==`connected`&&(0,Z.jsx)(de,{compact:!0,hostName:r.name,connectivity:r.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:r.lastSeenAt}),(0,Z.jsx)(q,{title:`Connectivity and versions`,children:(0,Z.jsx)(ct,{items:[[`Status`,(0,Z.jsx)(y,{kind:`host`,value:r.connectivity},`s`)],[`Last seen`,r.lastSeenAt?`${N(r.lastSeenAt)} (${_e(r.lastSeenAt)})`:`Never`],[`Platform`,nt[r.platform]],[`Agent version`,(0,Z.jsx)(`span`,{className:`font-mono`,children:r.agentVersion},`a`)],[`Pi`,(0,Z.jsx)(Ot,{host:r},`p`)],[`Enrolled`,_e(r.createdAt)]]})}),r.usage&&r.usage.length>0&&(0,Z.jsx)(q,{title:`Subscription usage`,children:(0,Z.jsx)(ct,{items:r.usage.map(e=>[e.provider===`anthropic`?`Claude`:`ChatGPT`,e.status===`available`?e.windows.map(e=>`${e.id===`five_hour`?`Session`:`Weekly`} ${Math.round(e.usedPct)}% used, resets ${N(e.resetsAt)}`).join(`; `)||`No limits reported`:e.message??e.status])})}),(0,Z.jsx)(q,{title:`Capabilities`,description:`What Pi on this host supports. Unsupported features are hidden or explained in sessions.`,children:x?(0,Z.jsxs)(`ul`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[me.map(e=>{let t=x[e],n=S(e);return(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[t?(0,Z.jsx)(Ne,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,Z.jsx)(g,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:Bn[e]}),(0,Z.jsxs)(`span`,{className:`text-muted`,children:[`: `,t?`Supported`:`Not supported`]}),!t&&n&&(0,Z.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:n})]})]},e)}),C.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[(0,Z.jsx)(g,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`font-medium break-words`,children:e.capability}),(0,Z.jsx)(`span`,{className:`text-muted`,children:`: Not supported`}),(0,Z.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:e.reason})]})]},e.capability))]}):(0,Z.jsx)(be,{capability:`Capability report`,reason:`This host has not reported its Pi capabilities yet. It may be offline, or Pi may be missing or incompatible.`})}),(0,Z.jsx)(zn,{host:r}),(0,Z.jsx)(q,{title:`Checkout mappings`,description:`Project clones on this host. Sessions and runs for a project use these paths.`,children:_.length===0?(0,Z.jsx)(R,{className:`py-4`,title:`No checkouts on this host`,description:`Create a project or add a checkout to an existing project.`,action:{label:`Open projects`,to:G(`projects`)}}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:_.map(e=>(0,Z.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,Z.jsx)(Nt,{to:G(`projects/${encodeURIComponent(e.projectId)}`),variant:`action`,children:o[e.projectId]?.name??`Unknown project`}),(0,Z.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id))})}),(0,Z.jsx)(q,{title:`Adapters`,actions:(0,Z.jsx)(Nt,{to:G(`adapters`),size:`sm`,variant:`action`,children:`All adapters`}),children:!i||i.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No adapters reported by this host.`}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:i.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),(0,Z.jsx)(`span`,{className:`text-muted`,children:e.version}),(0,Z.jsx)(hn,{status:e.status})]},e.id))})}),(0,Z.jsx)(Ge,{description:`Revoking disconnects the host agent and invalidates its credential. Sessions on it are not moved elsewhere.`,children:(0,Z.jsx)(f,{variant:`danger`,icon:(0,Z.jsx)(tn,{className:`size-4`}),onClick:()=>{h(null),l(!0)},children:`Revoke host`})}),(0,Z.jsx)(St,{open:c,onClose:()=>l(!1),title:`Revoke ${r.name}?`,confirmLabel:`Revoke host`,busy:u,error:m,onConfirm:b,children:(0,Z.jsx)(`p`,{className:`text-sm`,children:`The host agent is disconnected and its credential stops working. Sessions on it are not moved or restarted elsewhere. To use this machine again, add it as a new host.`})})]})}var Jn={granted:{icon:Gt,label:`Allowed`,tone:`success`,guidance:`This device can show Switchyard notifications.`},denied:{icon:we,label:`Blocked`,tone:`danger`,guidance:`Notifications are blocked for this site. Allow them in your browser's site settings (or the system notification settings for the Home Screen app), then reload.`},default:{icon:kt,label:`Not requested yet`,tone:`neutral`,guidance:`Enable notifications to hear about sessions that need input, failed, or are ready for review.`},unknown:{icon:kt,label:`Unknown`,tone:`neutral`,guidance:`The browser did not report a permission state. Try enabling notifications.`},unsupported:{icon:g,label:`Not supported`,tone:`warning`,guidance:`This browser cannot receive web push here. On iPhone and iPad, add Switchyard to the Home Screen first.`}};function Yn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function Xn(e){let t=K(e)&&K(e.settings)?e.settings:e;return!K(t)||typeof t.privatePreviews!=`boolean`?null:{quietHours:K(t.quietHours)?t.quietHours:null,privatePreviews:t.privatePreviews,preferredDeviceId:typeof t.preferredDeviceId==`string`?t.preferredDeviceId:null}}function Zn(){let[e,t]=(0,X.useState)(()=>ht()),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(null),c=yt()&&!Ct();(0,X.useEffect)(()=>{let e=!0;Et().then(t=>e&&r(t!==null)).catch(()=>e&&r(!1));let n=()=>{document.visibilityState===`visible`&&t(ht())};return document.addEventListener(`visibilitychange`,n),()=>{e=!1,document.removeEventListener(`visibilitychange`,n)}},[]);let l=()=>{a(`enable`),s(null),xt().then(e=>{t(e),e===`granted`?(r(!0),z.success(`Notifications enabled on this device`)):e===`denied`&&z.error(`Notifications were blocked. Allow them in your browser settings.`)}).catch(e=>{s(e),t(ht())}).finally(()=>a(null))},u=async()=>{a(`disable`),s(null);try{await wt(),r(!1),z.success(`Notifications disabled on this device`)}catch(e){s(e)}finally{a(null)}},d=async()=>{a(`test`),s(null);try{await ut(),z.success(`Test notification sent. It can take a few seconds to arrive.`)}catch(e){s(e),z.error(`Test notification failed: ${j(e)}`)}finally{a(null)}},p=Jn[e]??Jn.unknown;return(0,Z.jsxs)(H,{testId:`settings-notifications`,title:`Notifications`,description:`Push notifications for sessions that need input, failed, or are ready for review.`,children:[(0,Z.jsx)(q,{title:`This device`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Permission:`}),(0,Z.jsx)(_,{icon:p.icon,label:p.label,tone:p.tone}),n!==null&&e===`granted`&&(0,Z.jsx)(`span`,{className:`text-muted`,children:n?`Subscribed to push`:`Not subscribed to push`})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:p.guidance}),c&&(0,Z.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-sm`,children:[(0,Z.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[(0,Z.jsx)(rn,{"aria-hidden":!0,className:`size-4 shrink-0`}),`On iPhone and iPad, notifications need the Home Screen app`]}),(0,Z.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,Z.jsx)(`li`,{children:`Tap Share`}),(0,Z.jsx)(`li`,{children:`Add to Home Screen`}),(0,Z.jsx)(`li`,{children:`Open Switchyard from the Home Screen`}),(0,Z.jsx)(`li`,{children:`Enable notifications here`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e!==`unsupported`&&!(e===`granted`&&n)&&(0,Z.jsx)(f,{variant:`primary`,icon:(0,Z.jsx)(Gt,{className:`size-4`}),busy:i===`enable`,disabled:i!==null&&i!==`enable`,onClick:l,children:`Enable notifications`}),n&&(0,Z.jsx)(f,{icon:(0,Z.jsx)(we,{className:`size-4`}),busy:i===`disable`,disabled:i!==null&&i!==`disable`,onClick:u,children:`Disable on this device`}),(0,Z.jsx)(f,{icon:(0,Z.jsx)(Te,{className:`size-4`}),busy:i===`test`,disabled:i!==null&&i!==`test`,onClick:d,children:`Send test notification`})]}),e===`unsupported`&&(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Enabling is not possible in this browser. A test notification still goes to your other subscribed devices.`}),(0,Z.jsx)(A,{error:o}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Delivery and clearing are best effort: browsers and operating systems may delay, group or keep notifications even after you answer elsewhere.`})]})}),(0,Z.jsx)(Qn,{})]})}function Qn(){let e=Pt(`/api/me/notification-settings`,e=>!!Xn(e)),t=(0,X.useMemo)(()=>e.data?Xn(e.data):null,[e.data]),n=e.error instanceof ne&&e.error.status===404;return(0,Z.jsx)(q,{title:`Delivery preferences`,description:`Shared by all your devices. Attention items in Switchyard are unaffected.`,children:n?(0,Z.jsx)(be,{capability:`Notification settings`,reason:`This coordinator does not expose notification settings yet`}):e.fatal?(0,Z.jsx)(ve,{error:e.error}):e.error&&!e.loading&&!t?(0,Z.jsx)(P,{compact:!0,title:`Could not load notification settings`,error:e.error,onRetry:e.reload}):t?(0,Z.jsx)(er,{settings:t,onSaved:t=>e.setData(t)}):(0,Z.jsx)(M,{label:`Loading notification settings…`})})}var $n=/^\d{2}:\d{2}$/;function er({settings:e,onSaved:t}){let n=(0,X.useId)(),r=D(e=>e.devices),i=(0,X.useMemo)(()=>Object.values(r).filter(e=>e.revokedAt===null).sort((e,t)=>e.name.localeCompare(t.name)),[r]),[a,o]=(0,X.useState)(e.quietHours!==null),[s,c]=(0,X.useState)(e.quietHours?.start??`22:00`),[l,u]=(0,X.useState)(e.quietHours?.end??`07:00`),[d,p]=(0,X.useState)(e.quietHours?.timezone??Yn()),[m,h]=(0,X.useState)(e.privatePreviews),[g,_]=(0,X.useState)(e.preferredDeviceId??``),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(null),S=a&&!$n.test(s)?`Use a time like 22:00.`:null,C=a&&!$n.test(l)?`Use a time like 07:00.`:null,w=a&&!d.trim()?`Enter a time zone, e.g. Europe/Berlin.`:null,T=!g||i.some(e=>e.id===g);return(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:async e=>{if(e.preventDefault(),S||C||w)return;let n={quietHours:a?{start:s,end:l,timezone:d.trim()}:null,privatePreviews:m,preferredDeviceId:g||null};y(!0),x(null);try{t(Xn(await F(`/api/me/notification-settings`,n))??n),z.success(`Notification preferences saved`)}catch(e){x(e)}finally{y(!1)}},noValidate:!0,children:[(0,Z.jsx)(Y,{label:`Quiet hours`,description:`No push notifications during these hours. Attention items still collect in Switchyard.`,checked:a,onChange:o}),a&&(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-3`,children:[(0,Z.jsx)(V,{id:`${n}-start`,label:`From`,error:S,children:(0,Z.jsx)(W,{id:`${n}-start`,type:`time`,value:s,onChange:e=>c(e.target.value),...B(`${n}-start`,{error:S})})}),(0,Z.jsx)(V,{id:`${n}-end`,label:`Until`,error:C,children:(0,Z.jsx)(W,{id:`${n}-end`,type:`time`,value:l,onChange:e=>u(e.target.value),...B(`${n}-end`,{error:C})})}),(0,Z.jsx)(V,{id:`${n}-tz`,label:`Time zone`,error:w,children:(0,Z.jsx)(W,{id:`${n}-tz`,value:d,onChange:e=>p(e.target.value),autoCapitalize:`off`,spellCheck:!1,...B(`${n}-tz`,{error:w})})})]}),(0,Z.jsx)(Y,{label:`Private previews`,description:`Hide task and session text in notifications; show only the status, e.g. Needs input.`,checked:m,onChange:h}),(0,Z.jsx)(V,{id:`${n}-device`,label:`Preferred device`,hint:`Receives push when no desktop was recently active.`,children:(0,Z.jsxs)(J,{id:`${n}-device`,value:g,onChange:e=>_(e.target.value),...B(`${n}-device`,{hint:!0}),children:[(0,Z.jsx)(`option`,{value:``,children:`Automatic (the preferred mobile device)`}),i.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.push.subscribed?``:` (no push subscription)`]},e.id)),!T&&(0,Z.jsxs)(`option`,{value:g,children:[`Unknown device (`,g,`)`]})]})}),(0,Z.jsx)(A,{error:b}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(f,{type:`submit`,variant:`primary`,busy:v,icon:(0,Z.jsx)(We,{className:`size-4`}),children:`Save preferences`})})]})}var tr=e=>`/api/policies/${encodeURIComponent(e)}`,nr={list:()=>ye(`/api/policies`),create:e=>I(`/api/policies`,e),update:(e,t)=>F(tr(e),t),remove:(e,t)=>S(tr(e),{method:`DELETE`,query:{expectedRevision:t}}),settings:()=>ye(`/api/policies/settings`),updateSettings:e=>fe(`/api/policies/settings`,e),test:e=>I(`/api/policies/test`,e)},$=`w-full rounded-md border border-border bg-surface px-2 py-1 text-sm`,rr=()=>({scope:`server`,scopeId:``,name:``,priority:`0`,enabled:!0,phases:[`tool_call`],expression:``}),ir=e=>({...e,scopeId:e.scopeId??``,priority:String(e.priority)});function ar(){let e=D(e=>e.sessions),t=D(e=>e.profiles),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(rr),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(`tool_call`),[x,S]=(0,X.useState)(`bash`),[C,w]=(0,X.useState)(`{}`),[T,E]=(0,X.useState)(null),[ee,te]=(0,X.useState)(``),O=(0,X.useCallback)(async()=>{let[e,t]=await Promise.all([nr.list(),nr.settings()]);r(e),a(t),s(t.modelClassifications)},[]);(0,X.useEffect)(()=>{O().catch(e=>m(j(e)))},[O]);let k=async(e,t=!1)=>{g(!0),m(``),t&&te(``);try{await e()}catch(e){let n=e instanceof ne&&e.details!==void 0?` ${JSON.stringify(e.details)}`:``;(t?te:m)(`${j(e)}${n}`)}finally{g(!1)}};return(0,Z.jsxs)(H,{title:`Policies`,description:`Guardrails for tool calls and API requests; not an OS sandbox.`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:$e}),p&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`font-semibold`,children:`Rules`}),n.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No rules.`}),n.map(e=>(0,Z.jsxs)(`article`,{className:`rounded-md border border-border p-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`strong`,{children:e.name}),(0,Z.jsxs)(`span`,{children:[e.builtIn?`Built-in`:`Custom`,` · `,e.scope,e.scopeId?`: ${e.scopeId}`:``,` · priority `,e.priority,` ·`,` `,e.phases.map(e=>e===`tool_call`?`Tool call`:`API request`).join(`, `)]}),(0,Z.jsx)(f,{size:`sm`,onClick:()=>{l(e),d(ir(e))},children:`Edit`}),(0,Z.jsx)(f,{size:`sm`,disabled:h,onClick:()=>void k(async()=>{await nr.update(e.id,{expectedRevision:e.revision,enabled:!e.enabled}),await O()}),children:e.enabled?`Disable`:`Enable`}),!e.builtIn&&(0,Z.jsx)(f,{size:`sm`,disabled:h,onClick:()=>{window.confirm(`Delete ${e.name}?`)&&k(async()=>{await nr.remove(e.id,e.revision),await O()})},children:`Delete`})]}),(0,Z.jsx)(`p`,{children:e.enabled?`Enabled`:`Disabled`}),(0,Z.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words`,children:e.expression})]},e.id))]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`font-semibold`,children:c?`Edit ${c.name}`:`New rule`}),(0,Z.jsxs)(`label`,{children:[`Name`,(0,Z.jsx)(`input`,{className:$,value:u.name,onChange:e=>d({...u,name:e.target.value})})]}),(0,Z.jsxs)(`label`,{children:[`Scope`,(0,Z.jsxs)(`select`,{className:$,disabled:!!c,value:u.scope,onChange:e=>d({...u,scope:e.target.value,scopeId:``}),children:[(0,Z.jsx)(`option`,{value:`server`,children:`Server`}),(0,Z.jsx)(`option`,{value:`profile`,children:`Profile`}),(0,Z.jsx)(`option`,{value:`session`,children:`Session`})]})]}),u.scope!==`server`&&(0,Z.jsxs)(`label`,{children:[u.scope===`profile`?`Profile`:`Session`,(0,Z.jsxs)(`select`,{className:$,disabled:!!c,value:u.scopeId,onChange:e=>d({...u,scopeId:e.target.value}),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose…`}),u.scope===`profile`?Object.values(t).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)):Object.values(e).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,Z.jsxs)(`label`,{children:[`Priority`,(0,Z.jsx)(`input`,{className:$,type:`number`,value:u.priority,onChange:e=>d({...u,priority:e.target.value})})]}),(0,Z.jsxs)(`label`,{children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:u.enabled,onChange:e=>d({...u,enabled:e.target.checked})}),` `,`Enabled`]}),(0,Z.jsxs)(`fieldset`,{children:[(0,Z.jsx)(`legend`,{children:`Phases`}),[[`tool_call`,`Tool call`],[`request`,`API request`]].map(([e,t])=>(0,Z.jsxs)(`label`,{className:`mr-4`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:u.phases.includes(e),onChange:t=>d({...u,phases:t.target.checked?[...u.phases,e]:u.phases.filter(t=>t!==e)})}),` `,t]},e))]}),(0,Z.jsxs)(`label`,{children:[`CEL expression`,(0,Z.jsx)(`textarea`,{className:$,rows:5,value:u.expression,onChange:e=>d({...u,expression:e.target.value})})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(f,{disabled:h,onClick:()=>k(async()=>{if(!u.priority.trim())throw Error(`Priority: enter a whole number.`);let e=Ze({...u,scopeId:u.scope===`server`?null:u.scopeId,priority:Number(u.priority)});if(!e.success)throw Error(e.error.issues.map(e=>`${e.path.join(`.`)||`Rule`}: ${e.message}`).join(`; `));if(c){let{name:t,priority:n,enabled:r,phases:i,expression:a}=e.data;await nr.update(c.id,{expectedRevision:c.revision,name:t,priority:n,enabled:r,phases:i,expression:a})}else await nr.create(e.data);l(null),d(rr()),await O()}),children:`Save rule`}),c&&(0,Z.jsx)(f,{onClick:()=>{l(null),d(rr())},children:`Cancel`})]})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`font-semibold`,children:`Model classification`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Unknown models count as expensive.`}),o.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(`label`,{children:[`Provider`,(0,Z.jsx)(`input`,{className:$,value:e.provider,onChange:e=>s(o.map((n,r)=>r===t?{...n,provider:e.target.value}:n))})]}),(0,Z.jsxs)(`label`,{children:[`Model ID`,(0,Z.jsx)(`input`,{className:$,value:e.modelId,onChange:e=>s(o.map((n,r)=>r===t?{...n,modelId:e.target.value}:n))})]}),(0,Z.jsxs)(`label`,{children:[`Classification`,(0,Z.jsxs)(`select`,{className:$,value:e.classification,onChange:e=>s(o.map((n,r)=>r===t?{...n,classification:e.target.value}:n)),children:[(0,Z.jsx)(`option`,{value:`cheap`,children:`Cheap`}),(0,Z.jsx)(`option`,{value:`expensive`,children:`Expensive`})]})]}),(0,Z.jsx)(f,{onClick:()=>s(o.filter((e,n)=>t!==n)),children:`Remove`})]},`${t}-${i?.revision}`)),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(f,{onClick:()=>s([...o,{provider:``,modelId:``,classification:`expensive`}]),children:`Add model`}),(0,Z.jsx)(f,{disabled:h||!i,onClick:()=>k(async()=>{if(!i)return;let e=Ye({expectedRevision:i.revision,modelClassifications:o});if(!e.success)throw Error(e.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `));await nr.updateSettings(e.data),await O()}),children:`Save classifications`})]})]}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`font-semibold`,children:`Test rules`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Read-only policy test. The sample command is not executed. No approval or counter update is applied; a test result is not permission to execute later.`}),ee&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:ee}),(0,Z.jsxs)(`label`,{children:[`Session`,(0,Z.jsxs)(`select`,{className:$,value:_,onChange:e=>v(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose…`}),Object.values(e).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,Z.jsxs)(`label`,{children:[`Phase`,(0,Z.jsxs)(`select`,{className:$,value:y,onChange:e=>{let t=e.target.value;b(t),S(t===`tool_call`?`bash`:`task.create`),E(null)},children:[(0,Z.jsx)(`option`,{value:`tool_call`,children:`Tool call`}),(0,Z.jsx)(`option`,{value:`request`,children:`API request`})]})]}),y===`tool_call`?(0,Z.jsxs)(`label`,{children:[`Tool name`,(0,Z.jsx)(`input`,{className:$,value:x,onChange:e=>S(e.target.value)})]}):(0,Z.jsxs)(`label`,{children:[`Action`,(0,Z.jsx)(`select`,{className:$,value:x,onChange:e=>S(e.target.value),children:[`task.create`,`message.send`,`inbox.read`,`run.continue`].map(e=>(0,Z.jsx)(`option`,{children:e},e))})]}),(0,Z.jsxs)(`label`,{children:[`Sample arguments (JSON object)`,(0,Z.jsx)(`textarea`,{className:$,rows:4,value:C,onChange:e=>w(e.target.value)})]}),(0,Z.jsx)(f,{disabled:h,onClick:()=>k(async()=>{E(null);let e;try{e=JSON.parse(C)}catch{throw Error(`Sample arguments must be valid JSON.`)}let t=Je({sessionId:_,phase:y,tool:y===`tool_call`?{name:x,args:e}:null,request:y===`request`?{method:x,args:e}:null});if(!t.success)throw Error(t.error.issues.map(e=>`${e.path.join(`.`)||`Test`}: ${e.message}`).join(`; `));E(await nr.test(t.data))},!0),children:`Test`}),T&&(0,Z.jsxs)(`div`,{className:`rounded-md border border-border p-3 text-sm`,children:[(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`strong`,{children:Xe(T.verdict)}),T.reason&&`: ${T.reason}`]}),(0,Z.jsx)(`p`,{children:T.enforcement.explanation}),(0,Z.jsxs)(`p`,{children:[`Enforced phases: `,T.enforcement.phases.join(`, `)||`Not enforced`,`. Pre-provider: Not enforced.`]}),(0,Z.jsx)(`ul`,{children:T.trace.map(e=>(0,Z.jsxs)(`li`,{children:[e.ruleId,` (revision `,e.ruleRevision,`): `,Xe(e.verdict),e.reason&&` — ${e.reason}`,e.granted&&` · granted`,e.overridden&&` · overridden`]},e.ruleId))}),(0,Z.jsx)(`p`,{children:`Proposed updates (not applied):`}),(0,Z.jsx)(`pre`,{className:`overflow-auto`,children:JSON.stringify(T.proposedStateUpdates,null,2)})]})]})]})}var or={ask:`Ask`,approve:`Approve`,ignore:`Ignore`},sr={ask:`Ask before trusting project-local Pi settings and extensions.`,approve:`Trust project-local Pi settings and extensions automatically.`,ignore:`Never load project-local Pi settings or extensions.`},cr=T.options,lr={all:`Loads your extensions, skills and prompt templates.`,vanilla:`Starts Pi with --no-extensions --no-skills --no-prompt-templates (also no built-in MCP). Your logins, default model and AGENTS.md still apply, and Switchyard's model, effort, context and command controls keep working.`};function ur(e){let t=[];return e.forEach((e,n)=>{let r=O.safeParse(e);r.success||t.push(`Line ${n+1} (${e}): ${r.error.issues[0]?.message??`invalid argument`}`)}),t}function dr(){let e=U(),t=D(e=>e.profiles),n=D(e=>e.projects),r=(0,X.useMemo)(()=>Object.values(t).sort((e,t)=>e.name.localeCompare(t.name)),[t]),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(null),p=async()=>{if(o){l(!0),d(null);try{await ce(`/api/profiles/${encodeURIComponent(o.id)}`),z.success(`Profile ${o.name} deleted`),s(null)}catch(e){d(e)}finally{l(!1)}}},m=e=>Object.values(n).filter(t=>t.defaultProfileId===e).map(e=>e.name);return(0,Z.jsxs)(H,{title:`Pi profiles`,description:`Presets for provider, model, thinking level and Pi flags. Sessions keep a snapshot of the profile they started with.`,actions:(0,Z.jsx)(f,{variant:`primary`,icon:(0,Z.jsx)(Ue,{className:`size-4`}),onClick:()=>a(`new`),children:`New profile`}),children:[(0,Z.jsx)(L,{}),e?r.length===0?(0,Z.jsx)(R,{icon:(0,Z.jsx)(mt,{className:`size-8`}),title:`No profiles`,description:`Create a profile to choose a provider and model for sessions.`,action:{label:`New profile`,onClick:()=>a(`new`)}}):(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=m(e.id);return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`break-words text-muted`,children:[e.provider??`Default provider`,` / `,e.model??`default model`,` · Thinking`,` `,e.thinking??`default`,` · Project trust `,or[e.projectTrust],e.resources===`vanilla`&&` · Vanilla Pi`]}),e.extraArgs.length>0&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-xs text-muted`,children:e.extraArgs.join(` `)}),t.length>0&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Default for `,t.join(`, `)]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(f,{size:`sm`,icon:(0,Z.jsx)(He,{className:`size-4`}),onClick:()=>a(e),children:`Edit`}),(0,Z.jsx)(f,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Z.jsx)(Qe,{className:`size-4`}),onClick:()=>{d(null),s(e)},children:`Delete`})]})]},e.id)})}):(0,Z.jsx)(M,{label:`Loading profiles…`}),i&&(0,Z.jsx)(fr,{profile:i===`new`?null:i,onClose:()=>a(null)},i===`new`?`new`:i.id),(0,Z.jsx)(St,{open:o!==null,onClose:()=>s(null),title:o?`Delete ${o.name}?`:`Delete profile`,confirmLabel:`Delete profile`,busy:c,error:u,onConfirm:p,children:(0,Z.jsx)(`p`,{className:`text-sm`,children:`Existing sessions keep their snapshot of this profile. Projects that use it as their default must be changed first.`})})]})}function fr({profile:e,onClose:t}){let n=(0,X.useId)(),[r,i]=(0,X.useState)(e?.name??``),[a,o]=(0,X.useState)(e?.provider??``),[s,c]=(0,X.useState)(e?.model??``),[l,u]=(0,X.useState)(e?.thinking??``),[d,p]=(0,X.useState)(e?.projectTrust??`ask`),[m,h]=(0,X.useState)(e?.resources??`all`),[g,_]=(0,X.useState)((e?.extraArgs??[]).join(`
|
|
6
|
-
`)),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),w=et(g),T=ur(w),E=v&&!r.trim()?`Enter a profile name.`:null,ee=T.length?T.join(`
|
|
7
|
-
`):null,D=async n=>{if(n.preventDefault(),y(!0),!r.trim()||T.length)return;let i={name:r.trim(),provider:a.trim()||null,model:s.trim()||null,thinking:l||null,projectTrust:d,resources:m,extraArgs:w};x(!0),C(null);try{e?(await F(`/api/profiles/${encodeURIComponent(e.id)}`,i),z.success(`Profile ${i.name} saved`)):(await I(`/api/profiles`,i),z.success(`Profile ${i.name} created`)),t()}catch(e){C(e)}finally{x(!1)}},te=`${n}-form`;return(0,Z.jsx)(Tt,{open:!0,onClose:b?()=>void 0:t,dismissOnBackdrop:!b,title:e?`Edit ${e.name}`:`New profile`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{onClick:t,disabled:b,children:`Cancel`}),(0,Z.jsx)(f,{type:`submit`,form:te,variant:`primary`,busy:b,children:e?`Save profile`:`Create profile`})]}),children:(0,Z.jsxs)(`form`,{id:te,className:`flex min-w-0 flex-col gap-4`,onSubmit:D,noValidate:!0,children:[(0,Z.jsx)(V,{id:`${n}-name`,label:`Name`,error:E,children:(0,Z.jsx)(W,{id:`${n}-name`,value:r,onChange:e=>i(e.target.value),...B(`${n}-name`,{error:E})})}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(V,{id:`${n}-provider`,label:`Provider`,hint:`Empty uses Pi's default.`,children:(0,Z.jsx)(W,{id:`${n}-provider`,value:a,onChange:e=>o(e.target.value),placeholder:`anthropic`,autoCapitalize:`off`,spellCheck:!1,...B(`${n}-provider`,{hint:!0})})}),(0,Z.jsx)(V,{id:`${n}-model`,label:`Model`,hint:`Empty uses Pi's default.`,children:(0,Z.jsx)(W,{id:`${n}-model`,value:s,onChange:e=>c(e.target.value),autoCapitalize:`off`,spellCheck:!1,...B(`${n}-model`,{hint:!0})})})]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(V,{id:`${n}-thinking`,label:`Thinking`,children:(0,Z.jsxs)(J,{id:`${n}-thinking`,value:l,onChange:e=>u(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Default (none)`}),cr.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})}),(0,Z.jsx)(V,{id:`${n}-trust`,label:`Project trust`,hint:sr[d],children:(0,Z.jsx)(J,{id:`${n}-trust`,value:d,onChange:e=>p(e.target.value),...B(`${n}-trust`,{hint:!0}),children:Object.keys(or).map(e=>(0,Z.jsx)(`option`,{value:e,children:or[e]},e))})})]}),(0,Z.jsx)(V,{id:`${n}-resources`,label:`Resources`,hint:lr[m],children:(0,Z.jsxs)(J,{id:`${n}-resources`,value:m,onChange:e=>h(e.target.value),...B(`${n}-resources`,{hint:!0}),children:[(0,Z.jsx)(`option`,{value:`all`,children:`Your Pi setup`}),(0,Z.jsx)(`option`,{value:`vanilla`,children:`Vanilla Pi`})]})}),(0,Z.jsx)(V,{id:`${n}-extra`,label:`Extra Pi arguments`,hint:`One long flag per line, e.g. --max-turns=40. Session, mode and extension flags are managed by Switchyard.`,error:ee,children:(0,Z.jsx)(gt,{id:`${n}-extra`,value:g,minRows:3,onChange:e=>_(e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1,...B(`${n}-extra`,{hint:!0,error:ee})})}),(0,Z.jsx)(A,{error:S})]})})}var pr={managed:`Managed by Switchyard`,discovered:`Discovered worktree`,main:`Main checkout`},mr={none:{icon:x,label:`No setup`,tone:`neutral`},running:{icon:b,label:`Setup running`,tone:`info`},succeeded:{icon:Ne,label:`Setup succeeded`,tone:`success`},failed:{icon:je,label:`Setup failed`,tone:`danger`}};function hr(e){let t=[e.dirty?`Uncommitted changes (${e.changedFiles} file${e.changedFiles===1?``:`s`})`:`Clean`];return(e.ahead||e.behind)&&t.push(`${e.ahead} ahead, ${e.behind} behind`),t.push(e.unmerged?`Not merged into base`:`Merged`),t.join(` · `)}function gr({project:e}){let t=D(e=>e.workspaces),n=D(e=>e.hosts),r=(0,X.useMemo)(()=>Object.values(t).filter(t=>t.projectId===e.id&&t.archivedAt===null).sort((e,t)=>Number(t.provenance===`main`)-Number(e.provenance===`main`)||(e.branch??``).localeCompare(t.branch??``)),[t,e.id]),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(null),c=async e=>{s(e.id);try{await I(`/api/workspaces/${encodeURIComponent(e.id)}/refresh`),z.success(`Workspace status refreshed`)}catch(e){z.error(`Could not refresh: ${j(e)}`)}finally{s(null)}};return(0,Z.jsxs)(q,{title:`Workspaces`,description:`Worktrees where sessions and runs work. Removing one never deletes its branch.`,children:[r.length===0?(0,Z.jsx)(R,{className:`py-4`,title:`No workspaces`,description:`Workspaces appear after a checkout is discovered. Use Refresh to discover them again.`}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:r.map(e=>{let t=n[e.hostId],r=t?.connectivity!==`connected`,i=mr[e.setup.state]??mr.none;return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1.5 py-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Ve,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-all font-mono font-medium`,children:e.branch??`(detached HEAD)`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted`,children:pr[e.provenance]})]}),(0,Z.jsxs)(`div`,{className:`break-all font-mono text-xs text-muted`,children:[t?.name?`${t.name}: `:``,e.path]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:hr(e.git)}),(0,Z.jsx)(_,{icon:i.icon,label:i.label,tone:i.tone,spin:e.setup.state===`running`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(f,{size:`sm`,icon:(0,Z.jsx)(se,{className:`size-4`}),busy:o===e.id,disabled:r,onClick:()=>c(e),children:`Refresh status`}),e.provenance!==`main`&&(0,Z.jsx)(f,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Z.jsx)(Qe,{className:`size-4`}),disabled:r,onClick:()=>a(e),children:`Remove`}),e.provenance===`main`&&(0,Z.jsx)(`span`,{className:`text-xs text-muted`,children:`The main checkout cannot be removed; remove the project's checkout instead.`}),r&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Host `,t?.name??`unknown`,` is `,t?.connectivity??`unknown`,`: refresh and removal need it online.`]})]})]},e.id)})}),i&&(0,Z.jsx)(_r,{workspace:t[i.id]??i,onClose:()=>a(null)},i.id)]})}function _r({workspace:e,onClose:t}){let[n,r]=(0,X.useState)(e.git.dirty),[i,a]=(0,X.useState)(e.git.unmerged),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(null),m=n&&!o||i&&!c;return(0,Z.jsxs)(St,{open:!0,onClose:t,title:`Remove workspace?`,description:(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.branch??e.path}),confirmLabel:`Remove workspace`,busy:u,error:f,onConfirm:async()=>{d(!0),p(null);try{await I(`/api/workspaces/${encodeURIComponent(e.id)}/remove`,{force:{dirty:o,unmerged:c}}),z.success(`Workspace ${e.branch??e.path} removed`),t()}catch(e){ge(e,`workspace_dirty`)&&r(!0),ge(e,`workspace_unmerged`)&&a(!0),p(e)}finally{d(!1)}},confirmDisabled:m,disabledReason:`Check the boxes above to confirm what will be lost.`,children:[(0,Z.jsxs)(`p`,{className:`text-sm`,children:[`The worktree at `,(0,Z.jsx)(`span`,{className:`break-all font-mono`,children:e.path}),` is deleted from the host. The branch is kept.`]}),n&&(0,Z.jsx)(zt,{label:`Discard uncommitted changes`,description:e.git.dirty?`${e.git.changedFiles} changed file${e.git.changedFiles===1?``:`s`} will be lost.`:`The host reported uncommitted changes; they will be lost.`,checked:o,onChange:s}),i&&(0,Z.jsx)(zt,{label:`Remove although the branch is not merged`,description:`Commits stay on the branch, but the workspace is gone.`,checked:c,onChange:l})]})}var vr=`Inside the repository, for example .worktrees or .git/worktrees-switchyard`;function yr(e){let t=e.trim();return t?t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.includes(`\\`)?`Use a relative path inside the repository, e.g. .worktrees.`:t.split(`/`).includes(`..`)?`The folder must stay inside the repository (no ..).`:E.safeParse(t).success?null:`Use a plain relative path such as .worktrees (no empty or . segments).`:`Enter a folder inside the repository, e.g. .worktrees.`}function br(){let{projectId:e=``}=p(),t=U(),n=D(t=>t.projects[e]),r=D(e=>e.hosts),i=D(e=>e.profiles),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)([]),l=k(),u=(0,X.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),d={to:G(`projects`),label:`Projects`};return t?n?(0,Z.jsxs)(H,{title:n.name,description:(0,Z.jsx)(`span`,{className:`break-all`,title:n.repoIdentity,children:Ee(n.repoIdentity)}),back:d,actions:(0,Z.jsx)(f,{busy:a,icon:(0,Z.jsx)(se,{className:`size-4`}),onClick:async()=>{o(!0);try{let e=await I(`/api/projects/${encodeURIComponent(n.id)}/refresh`),t=Array.isArray(e?.errors)?e.errors:[];c(t),t.length?z.error(`Refreshed with ${t.length} checkout error(s)`):z.success(`Workspaces refreshed`)}catch(e){z.error(`Refresh failed: ${j(e)}`)}finally{o(!1)}},children:`Refresh`}),children:[(0,Z.jsx)(L,{}),s&&s.length>0&&(0,Z.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Some checkouts could not be refreshed`}),(0,Z.jsx)(`ul`,{className:`list-disc pl-5`,children:s.map(e=>(0,Z.jsx)(`li`,{className:`break-words`,children:e.message},e.checkoutId))})]}),(0,Z.jsx)(xr,{project:n,hosts:l,profiles:u},n.id),(0,Z.jsx)(Sr,{project:n,hosts:l,hostsById:r}),(0,Z.jsx)(gr,{project:n})]}):(0,Z.jsx)(H,{title:`Project`,back:d,children:(0,Z.jsx)(R,{icon:(0,Z.jsx)(jt,{className:`size-8`}),title:`Project not found`,description:`It may have been removed, or this link is from another coordinator.`,action:{label:`Back to projects`,to:G(`projects`)}})}):(0,Z.jsx)(H,{title:`Project`,back:d,children:(0,Z.jsx)(M,{label:`Loading project…`})})}function xr({project:e,hosts:t,profiles:n}){let r=(0,X.useId)(),[i,a]=(0,X.useState)(e.name),[o,s]=(0,X.useState)(e.setupCommand??``),[c,l]=(0,X.useState)(e.checks.join(`
|
|
8
|
-
`)),[u,d]=(0,X.useState)(String(e.maxConcurrentRuns)),[p,m]=(0,X.useState)(e.automationEnabled),[h,g]=(0,X.useState)(e.workspaceSharing),[_,v]=(0,X.useState)(e.ensureSessions??!1),[y,b]=(0,X.useState)(e.removeLanded??!1),[x,S]=(0,X.useState)(e.defaultProfileId??``),[C,w]=(0,X.useState)(e.defaultHostId??``),[T,E]=(0,X.useState)(e.worktreeDir??`.worktrees`),[ee,D]=(0,X.useState)(!1),[te,O]=(0,X.useState)(null),k=Number(u),ne=i.trim()?null:`Enter a project name.`,re=Number.isInteger(k)&&k>=1&&k<=32?null:`Use a whole number from 1 to 32.`,ie=yr(T),ae=async t=>{if(t.preventDefault(),!(ne||re||ie)){D(!0),O(null);try{await F(`/api/projects/${encodeURIComponent(e.id)}`,{name:i.trim(),setupCommand:o.trim()||null,checks:et(c),maxConcurrentRuns:k,automationEnabled:p,ensureSessions:_,removeLanded:y,workspaceSharing:h,defaultProfileId:x||null,defaultHostId:C||null,worktreeDir:T.trim()}),z.success(`Project settings saved`)}catch(e){O(e)}finally{D(!1)}}},oe=!C||t.some(e=>e.id===C),se=!x||n.some(e=>e.id===x);return(0,Z.jsx)(q,{title:`Project settings`,children:(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:ae,noValidate:!0,children:[(0,Z.jsx)(V,{id:`${r}-name`,label:`Name`,error:ne,children:(0,Z.jsx)(W,{id:`${r}-name`,value:i,onChange:e=>a(e.target.value),...B(`${r}-name`,{error:ne})})}),(0,Z.jsx)(V,{id:`${r}-setup`,label:`Setup command`,hint:`Runs in each new workspace before the first session, e.g. pnpm install. Leave empty for none.`,children:(0,Z.jsx)(W,{id:`${r}-setup`,value:o,onChange:e=>s(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...B(`${r}-setup`,{hint:!0})})}),(0,Z.jsx)(V,{id:`${r}-checks`,label:`Checks`,hint:`One command per line. Runs must pass these before review.`,children:(0,Z.jsx)(gt,{id:`${r}-checks`,value:c,minRows:3,onChange:e=>l(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...B(`${r}-checks`,{hint:!0})})}),(0,Z.jsx)(V,{id:`${r}-runs`,label:`Max concurrent runs`,hint:`Between 1 and 32.`,error:re,children:(0,Z.jsx)(W,{id:`${r}-runs`,type:`number`,inputMode:`numeric`,min:1,max:32,step:1,value:u,onChange:e=>d(e.target.value),className:`max-w-32`,...B(`${r}-runs`,{hint:!0,error:re})})}),(0,Z.jsx)(V,{id:`${r}-worktree`,label:`Worktree folder`,hint:vr,error:ie,children:(0,Z.jsx)(W,{id:`${r}-worktree`,"data-testid":`project-worktree-dir`,value:T,onChange:e=>E(e.target.value),placeholder:pe,className:`font-mono`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...B(`${r}-worktree`,{hint:!0,error:ie})})}),(0,Z.jsx)(Y,{label:`Auto-start Ready tasks`,description:`When off, Ready tasks in this project wait instead of starting automatically.`,checked:p,onChange:m}),(0,Z.jsx)(Y,{label:`Keep a session in every worktree`,description:`When a worktree first appears without a session, start one. Closing that session does not bring it back.`,checked:_,onChange:v}),(0,Z.jsx)(Y,{label:`Remove merged worktrees`,description:`Ten minutes after a worktree's pull request is merged, archive its sessions and remove the worktree and local branch. Skipped while a session is running or the worktree has unpushed or uncommitted changes.`,checked:y,onChange:b}),(0,Z.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Workspace sharing`}),[[`single_writer`,`Single writer`,`Automation runs wait while another session is live in the workspace. Safest.`],[`shared`,`Shared`,`Several sessions may write in the same workspace at once. Their changes can interleave.`]].map(([e,t,n])=>(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`input`,{id:`${r}-sharing-${e}`,type:`radio`,name:`${r}-sharing`,value:e,checked:h===e,onChange:()=>g(e),"aria-describedby":`${r}-sharing-${e}-desc`,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,Z.jsxs)(`label`,{htmlFor:`${r}-sharing-${e}`,className:`min-w-0 text-sm`,children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:t}),(0,Z.jsx)(`span`,{id:`${r}-sharing-${e}-desc`,className:`block text-muted`,children:n})]})]},e))]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(V,{id:`${r}-profile`,label:`Default Pi profile`,children:(0,Z.jsxs)(J,{id:`${r}-profile`,value:x,onChange:e=>S(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`None (use the coordinator default)`}),n.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)),!se&&(0,Z.jsx)(`option`,{value:x,children:`Removed profile`})]})}),(0,Z.jsx)(V,{id:`${r}-host`,label:`Default host`,hint:`Runs start here when the task does not choose a host.`,children:(0,Z.jsxs)(J,{id:`${r}-host`,value:C,onChange:e=>w(e.target.value),...B(`${r}-host`,{hint:!0}),children:[(0,Z.jsx)(`option`,{value:``,children:`None (any host with a checkout)`}),t.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id)),!oe&&(0,Z.jsx)(`option`,{value:C,children:`Removed host`})]})})]}),(0,Z.jsx)(A,{error:te}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(f,{type:`submit`,variant:`primary`,busy:ee,icon:(0,Z.jsx)(We,{className:`size-4`}),children:`Save project`})})]})})}function Sr({project:e,hosts:t,hostsById:n}){let r=D(e=>e.checkouts),i=(0,X.useMemo)(()=>Object.values(r).filter(t=>t.projectId===e.id).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),[r,e.id]),[a,o]=(0,X.useState)(!1);return(0,Z.jsxs)(q,{title:`Checkouts`,description:`Clones of this repository. Add one per host that should run this project.`,actions:(0,Z.jsx)(f,{size:`sm`,icon:(0,Z.jsx)(Ue,{className:`size-4`}),onClick:()=>o(!0),children:`Add checkout`}),children:[i.length===0?(0,Z.jsx)(R,{className:`py-4`,title:`No checkouts`,description:`Add a checkout so sessions and runs have somewhere to work.`,action:{label:`Add checkout`,onClick:()=>o(!0)}}):(0,Z.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:i.map(e=>{let t=n[e.hostId];return(0,Z.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t?.name??`Unknown host`}),t&&t.connectivity!==`connected`&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,t.connectivity,`)`]})]}),(0,Z.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id)})}),(0,Z.jsx)(Cr,{open:a,onClose:()=>o(!1),project:e,hosts:t})]})}function Cr({open:e,onClose:t,project:n,hosts:r}){let i=(0,X.useId)(),a=r.filter(e=>e.connectivity===`connected`),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),_=o||a[0]?.id||``,v=u||c?at(c):null,y=()=>{p||(d(!1),g(null),t())},b=async e=>{if(e.preventDefault(),d(!0),_&&!at(c)){m(!0),g(null);try{await I(`/api/projects/${encodeURIComponent(n.id)}/checkouts`,{hostId:_,path:c.trim()}),z.success(`Checkout added`),l(``),d(!1),t()}catch(e){g(e)}finally{m(!1)}}},x=`${i}-form`;return(0,Z.jsx)(Tt,{open:e,onClose:y,dismissOnBackdrop:!p,title:`Add checkout`,description:`Another clone of ${n.repoIdentity}.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{onClick:y,disabled:p,children:`Cancel`}),(0,Z.jsx)(f,{type:`submit`,form:x,variant:`primary`,busy:p,disabled:a.length===0,children:`Add checkout`})]}),children:(0,Z.jsxs)(`form`,{id:x,className:`flex min-w-0 flex-col gap-4`,onSubmit:b,noValidate:!0,children:[a.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No host is connected. The checkout is inspected on its host, so the host must be online.`}),(0,Z.jsx)(V,{id:`${i}-host`,label:`Host`,hint:`Only connected hosts are listed.`,children:(0,Z.jsxs)(J,{id:`${i}-host`,value:_,onChange:e=>s(e.target.value),disabled:a.length===0,...B(`${i}-host`,{hint:!0}),children:[a.length===0&&(0,Z.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(V,{id:`${i}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing clone of this repository.`,error:v,children:(0,Z.jsx)(W,{id:`${i}-path`,value:c,onChange:e=>l(e.target.value),placeholder:`/Users/me/src/app`,className:`font-mono`,autoCapitalize:`off`,autoComplete:`off`,spellCheck:!1,...B(`${i}-path`,{hint:!0,error:v})})}),(0,Z.jsx)(A,{error:h})]})})}var wr=e=>G(`projects/${encodeURIComponent(e)}`);function Tr(){let e=U(),t=te(),n=k().filter(e=>!e.revokedAt&&e.connectivity===`connected`),[r,i]=(0,X.useState)(``),a=t.filter(e=>Oe(e,r)),s=D(e=>e.checkouts),l=D(e=>e.workspaces),u=(0,X.useMemo)(()=>{let e={},t=t=>(e[t]??={checkouts:0,workspaces:0},e[t]);for(let e of Object.values(s))t(e.projectId).checkouts++;for(let e of Object.values(l))e.archivedAt||t(e.projectId).workspaces++;return e},[s,l]);return(0,Z.jsxs)(H,{testId:`settings-projects`,title:`Projects`,description:`A project is one repository. It can have checkouts on several hosts. Repositories in a host's project folders are added automatically.`,actions:(0,Z.jsxs)(o,{to:G(`projects/new`),state:Pe,className:c(`primary`),children:[(0,Z.jsx)(Ue,{"aria-hidden":!0,className:`size-4`}),`New project`]}),children:[(0,Z.jsx)(L,{}),n.map(e=>(0,Z.jsx)(De,{host:e},e.id)),e?t.length===0?(0,Z.jsx)(R,{icon:(0,Z.jsx)(jt,{className:`size-8`}),title:`No projects yet`,description:`Create a project from a Git checkout on one of your hosts.`,action:{label:`New project`,to:G(`projects/new`)}}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`relative max-w-md`,children:[(0,Z.jsx)(Ke,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-subtle`}),(0,Z.jsx)(W,{type:`search`,"aria-label":`Search projects`,placeholder:`Search projects by name or remote`,value:r,onChange:e=>i(e.target.value),className:`pl-8`})]}),a.length===0?(0,Z.jsx)(R,{className:`py-4`,title:`No matches`,description:`No project matches "${r.trim()}".`,action:{label:`Clear search`,onClick:()=>i(``)}}):(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:a.map(e=>(0,Z.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Z.jsx)(Er,{project:e,counts:u[e.id]})},e.id))})]}):(0,Z.jsx)(M,{label:`Loading projects…`})]})}function Er({project:e,counts:t}){let n=t??{checkouts:0,workspaces:0};return(0,Z.jsxs)(o,{to:wr(e.id),state:Pe,className:`tap flex min-w-0 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,Z.jsx)(jt,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted`,title:e.repoIdentity,children:Ee(e.repoIdentity)}),(0,Z.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-xs text-subtle`,children:[(0,Z.jsxs)(`span`,{children:[n.checkouts,` checkout`,n.checkouts===1?``:`s`]}),(0,Z.jsxs)(`span`,{children:[n.workspaces,` workspace`,n.workspaces===1?``:`s`]}),!e.automationEnabled&&(0,Z.jsx)(`span`,{children:`Auto-start off`})]})]}),(0,Z.jsx)(ke,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}function Dr(){let e=U(),n=k(),r=D(e=>e.profiles),i=(0,X.useMemo)(()=>Object.values(r).sort((e,t)=>e.name.localeCompare(t.name)),[r]),a=n.filter(e=>e.connectivity===`connected`),o=t(),s=(0,X.useId)(),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(``),[v,y]=(0,X.useState)(pe),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(null),E=u||a[0]?.id||``,ee=b&&!c.trim()?`Enter a project name.`:null,te=b&&!E?`Choose a connected host.`:null,O=b||p?at(p):null,ne=yr(v),re=async e=>{if(e.preventDefault(),x(!0),c.trim()&&E&&!at(p)&&!ne){C(!0),T(null);try{let e=await I(`/api/projects`,{name:c.trim(),hostId:E,path:p.trim(),defaultProfileId:h||null,worktreeDir:v.trim()});z.success(`Project ${c.trim()} created`),o(e?.id?wr(e.id):G(`projects`),{replace:!0})}catch(e){T(e)}finally{C(!1)}}},ie={to:G(`projects`),label:`Projects`};return e?(0,Z.jsxs)(H,{title:`New project`,description:`Switchyard inspects the checkout on the host, then discovers its worktrees.`,back:ie,children:[a.length===0&&(0,Z.jsx)(be,{capability:`Creating a project`,reason:n.length===0?`No hosts are enrolled. Add a host first.`:`No host is connected. The checkout is inspected on its host, so the host must be online.`,fallback:(0,Z.jsx)(Nt,{to:G(`hosts`),variant:`action`,children:`Open hosts`})}),(0,Z.jsx)(q,{children:(0,Z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:re,noValidate:!0,children:[(0,Z.jsx)(V,{id:`${s}-name`,label:`Name`,error:ee,children:(0,Z.jsx)(W,{id:`${s}-name`,value:c,onChange:e=>l(e.target.value),autoComplete:`off`,...B(`${s}-name`,{error:ee})})}),(0,Z.jsx)(V,{id:`${s}-host`,label:`Host`,hint:`Only connected hosts are listed.`,error:te,children:(0,Z.jsxs)(J,{id:`${s}-host`,value:E,onChange:e=>d(e.target.value),disabled:a.length===0,...B(`${s}-host`,{hint:!0,error:te}),children:[a.length===0&&(0,Z.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(V,{id:`${s}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing Git checkout, e.g. /Users/me/src/app.`,error:O,children:(0,Z.jsx)(W,{id:`${s}-path`,value:p,onChange:e=>m(e.target.value),placeholder:`/Users/me/src/app`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...B(`${s}-path`,{hint:!0,error:O})})}),(0,Z.jsx)(V,{id:`${s}-worktree`,label:`Worktree folder`,hint:vr,error:ne,children:(0,Z.jsx)(W,{id:`${s}-worktree`,value:v,onChange:e=>y(e.target.value),placeholder:pe,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...B(`${s}-worktree`,{hint:!0,error:ne})})}),(0,Z.jsx)(V,{id:`${s}-profile`,label:`Default Pi profile (optional)`,children:(0,Z.jsxs)(J,{id:`${s}-profile`,value:h,onChange:e=>g(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`None`}),i.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(A,{error:w}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(f,{type:`submit`,variant:`primary`,busy:S,icon:(0,Z.jsx)(qt,{className:`size-4`}),disabled:a.length===0,children:`Create project`}),a.length===0&&(0,Z.jsx)(_,{icon:qt,label:`Needs a connected host`})]})]})})]}):(0,Z.jsx)(H,{title:`New project`,back:ie,children:(0,Z.jsx)(M,{})})}function Or(){let e=Pt(`/api/auth/methods`,ot),[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=async()=>{if(r){o(!0),c(null);try{await ce(`/api/auth/passkeys/${encodeURIComponent(r.id)}`),z.success(`Passkey ${r.name} removed`),i(null),e.reload()}catch(e){c(e)}finally{o(!1)}}},v=async()=>{p(!0),h(null);try{await I(`/api/logout`),u(!1),st(null)}catch(e){h(e)}finally{p(!1)}},y=e.data,b=y?.passkeyAvailability,x=Vt(),S=y?b?.available?x?null:`This browser does not support passkeys.`:b?.reason??`Passkeys are not available on this server.`:null;return(0,Z.jsxs)(H,{testId:`settings-signin`,title:`Sign-in`,description:`How you sign in to Switchyard on new devices. Each signed-in device keeps its own revocable credential.`,children:[(0,Z.jsx)(L,{}),e.loading&&!y?(0,Z.jsx)(M,{label:`Loading sign-in methods…`}):e.error&&!y?(0,Z.jsx)(P,{title:`Could not load sign-in methods`,error:e.error,onRetry:e.reload}):y?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(q,{title:`Passkeys`,description:`Sign in on any device with its fingerprint, face or screen lock. Passkeys are stored on this server only as public keys.`,actions:(0,Z.jsx)(f,{"data-testid":`passkey-add`,variant:`primary`,icon:(0,Z.jsx)(Ue,{className:`size-4`}),disabled:S!==null,onClick:()=>n(!0),children:`Add a passkey`}),children:[S&&(0,Z.jsxs)(`p`,{role:`status`,className:`mb-3 flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-sm`,children:[(0,Z.jsx)(he,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Adding a passkey is unavailable: `,S]})]}),y.passkeys.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No passkeys yet. Add one as a backup to single sign-on, or to sign in without it.`}):(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border`,children:y.passkeys.map(e=>(0,Z.jsxs)(`li`,{"data-testid":`passkey-row`,className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-border px-3 py-2 last:border-b-0`,children:[(0,Z.jsx)(dt,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`break-words font-medium`,children:e.name}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 text-sm text-muted`,children:[(0,Z.jsxs)(`span`,{children:[`Added `,N(e.createdAt)]}),(0,Z.jsxs)(`span`,{children:[`Last used `,N(e.lastUsedAt)]})]})]}),(0,Z.jsx)(f,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Z.jsx)(Qe,{className:`size-4`}),"aria-label":`Remove passkey ${e.name}`,onClick:()=>{c(null),i(e)},children:`Remove`})]},e.id))})]}),(0,Z.jsx)(q,{title:`Single sign-on`,description:`Configured on the server`,children:y.oidc?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(ct,{items:[[`Button label`,y.oidc.label],[`Provider`,(0,Z.jsx)(`span`,{className:`break-all`,children:y.oidc.issuer},`i`)],[`Allowed account`,y.oidc.ownerMatch],[`Status`,y.oidc.status===`ready`?(0,Z.jsx)(_,{icon:Ne,tone:`success`,label:`Ready`},`s`):(0,Z.jsx)(_,{icon:he,tone:`danger`,label:`Error`},`s`)]]}),y.oidc.status===`error`&&y.oidc.error&&(0,Z.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:y.oidc.error})]}):(0,Z.jsxs)(`p`,{"data-testid":`signin-oidc-status`,className:`text-sm text-muted`,children:[`Not configured. Set the `,(0,Z.jsx)(`code`,{children:`SWITCHYARD_OIDC_*`}),` variables on the server to sign in with an identity provider.`]})})]}):null,(0,Z.jsx)(q,{title:`This device`,description:`Signing out removes this device's credential here. Other devices stay signed in; revoke a device in Settings › Devices to cut it off.`,children:(0,Z.jsx)(f,{icon:(0,Z.jsx)($t,{className:`size-4`}),onClick:()=>{h(null),u(!0)},children:`Sign out of this device`})}),(0,Z.jsx)(kr,{open:t,onClose:()=>n(!1),onAdded:()=>{n(!1),e.reload()}}),(0,Z.jsx)(St,{open:r!==null,onClose:()=>i(null),title:r?`Remove passkey ${r.name}?`:`Remove passkey`,confirmLabel:`Remove passkey`,busy:a,error:s,onConfirm:g,children:(0,Z.jsxs)(`p`,{className:`text-sm`,children:[`Devices already signed in stay signed in. This passkey can no longer sign in new devices.`,y&&y.passkeys.length===1&&!y.oidc?` It is your only passkey and no single sign-on is set up: afterwards new browsers need switchyard pair run on the server.`:``]})}),(0,Z.jsx)(St,{open:l,onClose:()=>u(!1),title:`Sign out of this device?`,confirmLabel:`Sign out`,busy:d,error:m,onConfirm:v,children:(0,Z.jsxs)(`p`,{className:`text-sm`,children:[`You will need single sign-on, a passkey or `,(0,Z.jsx)(`code`,{children:`switchyard pair`}),` on the server to sign in here again.`]})})]})}function kr({open:e,onClose:t,onAdded:n}){let r=(0,X.useId)(),[i,a]=(0,X.useState)(()=>Ut()),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),u=Ht(),p=i.trim()?null:`Enter a name for this passkey.`,m=()=>{if(u.waiting)u.cancel();else if(o)return;l(null),t()},h=async e=>{if(e.preventDefault(),!p){s(!0),l(null);try{let{challengeId:e,options:t}=await I(`/api/auth/passkeys/register/options`),r=await u.run(()=>Bt({optionsJSON:t}));if(!r.ok){s(!1);return}let a=r.value;await I(`/api/auth/passkeys/register/verify`,{challengeId:e,name:i.trim().slice(0,80),response:a}),z.success(`Passkey added`),n()}catch(e){l(e instanceof Error&&e.name===`NotAllowedError`?Error(`The passkey prompt was canceled or timed out. Try again.`):e instanceof Error?e:Error(j(e)))}finally{s(!1)}}},g=`${r}-form`;return(0,Z.jsx)(Tt,{open:e,onClose:m,dismissOnBackdrop:!o||u.waiting,title:`Add a passkey`,description:`Name it after where it is stored, then confirm with your device.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{onClick:m,disabled:o&&!u.waiting,children:`Cancel`}),(0,Z.jsx)(f,{type:`submit`,form:g,variant:`primary`,busy:o,children:`Create passkey`})]}),children:(0,Z.jsxs)(`form`,{id:g,className:`flex min-w-0 flex-col gap-4`,onSubmit:h,noValidate:!0,children:[(0,Z.jsx)(V,{id:`${r}-name`,label:`Passkey name`,error:p,children:(0,Z.jsx)(W,{id:`${r}-name`,value:i,maxLength:80,autoComplete:`off`,onChange:e=>a(e.target.value),...B(`${r}-name`,{error:p})})}),u.waiting&&(0,Z.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-muted`,children:[(0,Z.jsx)(d,{}),` Waiting for your passkey… Cancel stops it.`]}),(0,Z.jsx)(A,{error:c})]})})}function Ar(e){let t=re(e);return t===`view`?`view:${e.viewId}`:t}function jr(e){return e.startsWith(`view:`)?{mirror:`view`,viewId:e.slice(5)}:{mirror:e===`all`?`all`:`none`}}function Mr(){let e=U(),t=D(e=>e.terminals),n=D(e=>e.views),r=D(e=>e.hosts),[i,a]=(0,X.useState)(null),o=(0,X.useMemo)(()=>Object.values(t).sort((e,t)=>e.machine.localeCompare(t.machine)||e.id.localeCompare(t.id)),[t]),s=(0,X.useMemo)(()=>Object.values(n).sort((e,t)=>e.name.localeCompare(t.name)),[n]),c=async(e,t)=>{a(e.id);try{await fe(`/api/terminals/${encodeURIComponent(e.id)}/binding`,jr(t))}catch(t){z.error(`Could not change ${e.kind} ${e.name}: ${j(t)}`)}finally{a(null)}};return(0,Z.jsxs)(H,{testId:`settings-terminals`,title:`Terminals`,description:`herdr and tmux sessions running the Switchyard plugin. Each one mirrors nothing, every session, or one view: a tab or window per active branch. Pi you start by hand in any of them shows up either way.`,children:[(0,Z.jsx)(L,{}),e?o.length===0?(0,Z.jsx)(R,{icon:(0,Z.jsx)(vt,{className:`size-8`}),title:`No terminals`,description:`A herdr or tmux session appears here once the Switchyard plugin runs in it, or after switchyard terminals bind.`}):(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:o.map(e=>{let t=Ar(e),a=t.startsWith(`view:`)&&!n[e.viewId??``],o=e.hostId&&r[e.hostId]?.name||e.machine;return(0,Z.jsxs)(`li`,{"data-testid":`terminal-row`,className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,Z.jsx)(vt,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Z.jsxs)(`span`,{className:`min-w-0 break-words font-medium`,children:[e.kind,` `,e.name]}),(0,Z.jsxs)(`span`,{className:`text-sm text-muted`,children:[`on `,o,` ·`,` `,le(e)?`seen ${N(e.lastSeenAt)}`:`plugin not running`,(e.shows?.length??0)>0&&` · ${e.shows.length} mirrored`]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`text-muted`,children:`Mirrors`}),(0,Z.jsxs)(J,{width:`auto`,"aria-label":`What ${e.kind} ${e.name} mirrors`,value:t,disabled:i===e.id,onChange:t=>void c(e,t.target.value),children:[(0,Z.jsx)(`option`,{value:`none`,children:`Nothing`}),(0,Z.jsx)(`option`,{value:`all`,children:`Everything`}),s.map(e=>(0,Z.jsxs)(`option`,{value:`view:${e.id}`,children:[`View: `,e.name]},e.id)),a&&(0,Z.jsx)(`option`,{value:t,children:`Deleted view`})]})]})]},e.id)})}):(0,Z.jsx)(M,{label:`Loading terminals…`})]})}var Nr=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),Pr=e=>e.split(`
|
|
9
|
-
`).map(e=>e.trim()).filter(Boolean);function Fr(e,t){return e?{name:e.name,hostId:e.hostId,owner:e.owner,repositories:(e.repositories??[]).join(`
|
|
10
|
-
`),extraRepositories:(e.extraRepositories??[]).join(`
|
|
11
|
-
`),board:e.board?String(e.board.projectNumber):``,statusField:e.board?.statusField??`Status`,onStart:e.board?.onStart??``,onReview:e.board?.onReview??``,follow:Se(e),backlog:C(e).join(`, `),priorityField:e.board?.priorityField??``,writeBack:e.writeBack,moveShared:e.moveShared,worktrees:ae(e),enabled:e.enabled}:{name:``,hostId:t,owner:``,repositories:``,extraRepositories:``,board:``,statusField:`Status`,onStart:``,onReview:``,follow:`assigned`,backlog:``,priorityField:``,writeBack:!1,moveShared:!0,worktrees:!0,enabled:!0}}function Ir(e){let t={},n=e.name.trim();n?n.length>60&&(t.name=`Use 60 characters or fewer.`):t.name=`Enter a name.`,e.hostId||(t.hostId=`Choose a host.`),ie.safeParse(e.owner.trim()).success||(t.owner=`Enter a GitHub organization or user name.`),Pr(e.repositories).some(e=>!oe.safeParse(e).success)&&(t.repositories=`Use owner/name, one per line.`);let r=Pr(e.extraRepositories);r.some(e=>!oe.safeParse(e).success)?t.extraRepositories=`Use owner/name, one per line.`:r.length>20&&(t.extraRepositories=`Use 20 repositories or fewer.`);let i=e.board.trim();return i&&!/^[1-9][0-9]*$/.test(i)&&(t.board=`Enter the board's number, as in its URL.`),Nr(e.backlog).length>20&&(t.backlog=`Use 20 columns or fewer.`),t}function Lr(e){let t=Pr(e.repositories),n=e.board.trim();return{name:e.name.trim(),hostId:e.hostId,owner:e.owner.trim(),repositories:t.length?t:null,extraRepositories:Pr(e.extraRepositories),board:n?{projectNumber:Number(n),statusField:e.statusField.trim()||`Status`,onStart:e.onStart.trim()||null,onReview:e.onReview.trim()||null,backlog:Nr(e.backlog),priorityField:e.priorityField.trim()||null}:null,follow:n?e.follow:`assigned`,writeBack:n?e.writeBack:!1,moveShared:e.moveShared,worktrees:e.worktrees,enabled:e.enabled}}function Rr(e,t){let n=(()=>{if(!e.writeBack||!e.board)return`Off`;let t=[e.board.onStart?`To "${e.board.onStart}" when work starts`:null,e.board.onReview?`${e.board.onStart?`to`:`To`} "${e.board.onReview}" when a pull request opens`:null].filter(e=>!!e);return t.length===0?`On, but no columns are set`:`${t.join(`, `)}${e.moveShared?``:`; never shared cards`}`})();return[[`GitHub`,`${e.owner}${e.repositories?`: ${e.repositories.join(`, `)}`:` (all repositories)`}${e.extraRepositories?.length?`, plus ${e.extraRepositories.join(`, `)}`:``}`],[`Follows`,Se(e)===`board`?`Every open issue on the board`:`Issues assigned to ${e.login??`you`}`],[`Signed in as`,e.login??`Not synced yet`],[`Host`,t],[`Board`,e.board?`#${e.board.projectNumber}, field ${e.board.statusField}${e.board.priorityField?`, priority ${e.board.priorityField}`:``}${C(e).length?`; hides ${C(e).join(`, `)} until started`:``}`:`None`],[`Moves cards`,n]]}function zr(){let{trackers:e,error:t,reload:n}=Rt();(0,X.useEffect)(()=>n(),[]);let[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),d=async()=>{if(a){c(!0),u(null);try{await ce(`/api/trackers/${encodeURIComponent(a.id)}`),It.getState().remove(a.id),z.success(`Tracker ${a.name} deleted`),o(null)}catch(e){u(e)}finally{c(!1)}}};return(0,Z.jsxs)(H,{title:`Trackers`,description:`A tracker follows your GitHub issues (those assigned to you, or every open issue on a Projects board), makes worktrees for their branches, and is the source of a view of its projects.`,testId:`trackers-section`,actions:(0,Z.jsx)(f,{variant:`primary`,icon:(0,Z.jsx)(Ue,{className:`size-4`}),onClick:()=>i(`new`),children:`New tracker`}),children:[e===null&&t?(0,Z.jsx)(P,{title:`Could not load trackers`,error:t,onRetry:n}):e===null?(0,Z.jsx)(M,{label:`Loading trackers…`}):e.length===0?(0,Z.jsx)(R,{icon:(0,Z.jsx)(h,{className:`size-8`}),title:`No trackers`,description:`Add one to bring your GitHub issues onto the board.`,action:{label:`New tracker`,onClick:()=>i(`new`)}}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.map(e=>(0,Z.jsx)(Br,{tracker:e,onEdit:()=>i(e),onDelete:()=>{u(null),o(e)}},e.id))}),(0,Z.jsx)(Hr,{editing:r,onClose:()=>i(null)}),(0,Z.jsx)(St,{open:a!==null,onClose:()=>o(null),title:`Delete this tracker?`,description:`Its issues are removed. Its view stays, with its current projects as your own filter.`,confirmLabel:`Delete tracker`,danger:!0,busy:s,error:l,onConfirm:()=>void d()})]})}function Br({tracker:e,onEdit:n,onDelete:r}){let i=D(e=>e.hosts),a=D(e=>e.views),o=D(e=>e.projects),s=D(e=>e.issues),[,c]=At(),l=t(),[u,d]=(0,X.useState)(!1),p=Object.values(a).find(t=>t.trackerId===e.id)??null,m=Object.values(s).filter(t=>t.trackerId===e.id).length,h=(0,X.useMemo)(()=>(p?.projectIds??[]).map(e=>o[e]).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name)),[p,o]),g=async()=>{d(!0);try{let t=await I(`/api/trackers/${encodeURIComponent(e.id)}/sync`,{});It.getState().upsert(t),t.lastError?z.error(`${t.name}: ${t.lastError}`):z.success(`Synced ${t.name}`)}catch(e){z.error(j(e))}finally{d(!1)}},_=e=>{p&&c(p.id),l(e)};return(0,Z.jsx)(q,{testId:`tracker-${e.id}`,title:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.name,!e.enabled&&(0,Z.jsx)(v,{tone:`neutral`,children:`Paused`})]}),actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{size:`sm`,icon:(0,Z.jsx)(se,{className:`size-4`}),busy:u,onClick:()=>void g(),children:`Sync now`}),(0,Z.jsx)(f,{size:`sm`,icon:(0,Z.jsx)(He,{className:`size-4`}),onClick:n,children:`Edit`}),(0,Z.jsx)(f,{size:`sm`,variant:`danger`,icon:(0,Z.jsx)(Qe,{className:`size-4`}),onClick:r,children:`Delete`})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(ct,{items:[...Rr(e,i[e.hostId]?.name??e.hostId),[`Last sync`,e.lastSyncedAt?N(e.lastSyncedAt):`Never`],[`Issues`,String(m)],[`View`,p?(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[p.name,(0,Z.jsx)(Nt,{onClick:()=>_(ft.code),children:`Sessions`}),(0,Z.jsx)(Nt,{onClick:()=>_(ft.board),children:`Board`})]},`view`):`Created after the first successful sync`]]}),e.lastError&&(0,Z.jsx)(`p`,{role:`status`,className:`rounded-md border border-border bg-danger-soft px-3 py-2 text-sm break-words`,children:e.lastError}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Projects`}),h.length===0?(0,Z.jsxs)(`p`,{className:`text-sm text-muted`,children:[e.extraRepositories?.length?`No projects for this tracker here yet.`:`No projects from ${e.owner} here yet.`,` `,`Add its repositories in Settings › Projects.`]}):(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border`,children:h.map(e=>(0,Z.jsx)(Vr,{project:e},e.id))})]})]})})}function Vr({project:e}){let[t,n]=(0,X.useState)(null),r=async(t,r)=>{n(t);try{await F(`/api/projects/${encodeURIComponent(e.id)}`,{[t]:r})}catch(e){z.error(j(e))}finally{n(null)}};return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 py-2`,children:[(0,Z.jsx)(o,{to:ft.settings(`projects/${e.id}`),className:`min-w-0 flex-[1_1_10rem] truncate text-sm font-medium text-accent hover:underline`,children:e.name}),(0,Z.jsx)(Ft,{label:`Keep a session in every worktree of ${e.name}`,onText:`Session per worktree`,offText:`Session per worktree`,checked:e.ensureSessions??!1,busy:t===`ensureSessions`,onChange:e=>void r(`ensureSessions`,e)}),(0,Z.jsx)(Ft,{label:`Remove merged worktrees of ${e.name}`,onText:`Remove merged`,offText:`Remove merged`,checked:e.removeLanded??!1,busy:t===`removeLanded`,onChange:e=>void r(`removeLanded`,e)})]})}function Hr({editing:e,onClose:t}){let n=k(),r=D(e=>e.issues),i=(n.find(e=>e.connectivity===`connected`)??n[0])?.id??``,a=e&&e!==`new`?e:null,o=e===null?`closed`:a?.id??`new`,[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(()=>Fr(null,i)),[d,p]=(0,X.useState)({}),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(null),v=(0,X.useId)();s!==o&&(c(o),u(Fr(a,i)),p({}),_(null));let y=(0,X.useMemo)(()=>a?Object.values(r).find(e=>e.trackerId===a.id&&e.board)?.board?.options.map(e=>e.name)??[]:[],[r,a]),b=(e,t)=>u(n=>({...n,[e]:t})),x=l.board.trim()!==``,S=async()=>{let e=Ir(l);if(p(e),!(Object.keys(e).length>0)){h(!0),_(null);try{let e=Lr(l),n=a?await F(`/api/trackers/${encodeURIComponent(a.id)}`,e):await I(`/api/trackers`,e);It.getState().upsert(n),z.success(`Tracker ${n.name} saved`),t()}catch(e){_(e)}finally{h(!1)}}},C=ge(g,`conflict`)?j(g):null;return(0,Z.jsx)(Tt,{open:e!==null,onClose:t,title:a?`Edit tracker`:`New tracker`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{onClick:t,children:`Cancel`}),(0,Z.jsx)(f,{variant:`primary`,busy:m,onClick:()=>void S(),children:`Save`})]}),children:(0,Z.jsxs)(`div`,{"data-testid":`tracker-form`,className:`flex flex-col gap-3`,children:[(0,Z.jsx)(V,{label:`Name`,error:d.name??C,children:e=>(0,Z.jsx)(W,{...e,value:l.name,maxLength:60,onChange:e=>b(`name`,e.target.value)})}),(0,Z.jsx)(V,{label:`Host`,hint:`Its gh login reads your issues.`,error:d.hostId,children:e=>(0,Z.jsxs)(J,{...e,value:l.hostId,onChange:e=>b(`hostId`,e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose a host`}),n.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(V,{label:`GitHub owner`,hint:`An organization or user, such as fieldgoalco.`,error:d.owner,children:e=>(0,Z.jsx)(W,{...e,value:l.owner,spellCheck:!1,onChange:e=>b(`owner`,e.target.value)})}),(0,Z.jsx)(V,{label:`Repositories`,optional:!0,hint:`One owner/name per line. Leave empty for every repository of the owner.`,error:d.repositories,children:e=>(0,Z.jsx)(gt,{...e,rows:3,value:l.repositories,spellCheck:!1,onChange:e=>b(`repositories`,e.target.value)})}),(0,Z.jsx)(V,{label:`Repositories of other owners`,optional:!0,hint:`One owner/name per line. Their projects join this tracker's view, and issues assigned to you there are tracked too.`,error:d.extraRepositories,children:e=>(0,Z.jsx)(gt,{...e,rows:2,value:l.extraRepositories,spellCheck:!1,onChange:e=>b(`extraRepositories`,e.target.value)})}),(0,Z.jsx)(V,{label:`Board number`,optional:!0,hint:`A GitHub Projects board of the owner. Needs the project scope: gh auth refresh -s project.`,error:d.board,children:e=>(0,Z.jsx)(W,{...e,inputMode:`numeric`,value:l.board,onChange:e=>b(`board`,e.target.value)})}),x&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`datalist`,{id:v,children:y.map(e=>(0,Z.jsx)(`option`,{value:e},e))}),(0,Z.jsx)(V,{label:`Issues to follow`,hint:`On the board, issues need no assignee.`,children:e=>(0,Z.jsxs)(J,{...e,value:l.follow,onChange:e=>b(`follow`,e.target.value),children:[(0,Z.jsx)(`option`,{value:`assigned`,children:`Assigned to me`}),(0,Z.jsx)(`option`,{value:`board`,children:`Every open issue on the board`})]})}),(0,Z.jsx)(V,{label:`Status field`,children:e=>(0,Z.jsx)(W,{...e,value:l.statusField,onChange:e=>b(`statusField`,e.target.value)})}),(0,Z.jsx)(V,{label:`Column when work starts`,optional:!0,children:e=>(0,Z.jsx)(W,{...e,list:v,value:l.onStart,onChange:e=>b(`onStart`,e.target.value)})}),(0,Z.jsx)(V,{label:`Column when a pull request opens`,optional:!0,children:e=>(0,Z.jsx)(W,{...e,list:v,value:l.onReview,onChange:e=>b(`onReview`,e.target.value)})}),(0,Z.jsx)(V,{label:`Backlog columns`,optional:!0,hint:`Cards in these columns are not tracked until they have a branch or pull request. Separate names with commas.`,error:d.backlog,children:e=>(0,Z.jsx)(W,{...e,value:l.backlog,onChange:e=>b(`backlog`,e.target.value)})}),(0,Z.jsx)(V,{label:`Priority field`,optional:!0,hint:`A single-select field, such as Priority. Not-started issues are listed by it.`,children:e=>(0,Z.jsx)(W,{...e,value:l.priorityField,onChange:e=>b(`priorityField`,e.target.value)})}),(0,Z.jsx)(Y,{label:`Move cards on GitHub`,description:l.follow===`board`?`Cards assigned to you or to nobody, only the status field, and only from the column Switchyard last saw.`:`Only cards assigned to you, only the status field, and only from the column Switchyard last saw.`,checked:l.writeBack,onChange:e=>b(`writeBack`,e)}),l.writeBack&&(0,Z.jsx)(Y,{label:`Also move cards assigned to others too`,checked:l.moveShared,onChange:e=>b(`moveShared`,e)})]}),(0,Z.jsx)(Y,{label:`Make worktrees for issue branches`,description:`Off: Switchyard only links the worktrees you make and never creates one.`,checked:l.worktrees,onChange:e=>b(`worktrees`,e)}),(0,Z.jsx)(Y,{label:`Sync this tracker`,checked:l.enabled,onChange:e=>b(`enabled`,e)}),g!==null&&!C&&(0,Z.jsx)(P,{compact:!0,title:`Could not save`,error:j(g)})]})})}function Ur(){let e=Fe(),t=e===`mobile`,n=(0,Z.jsxs)(s,{children:[(0,Z.jsx)(u,{index:!0,element:t?(0,Z.jsx)(qr,{}):(0,Z.jsx)(r,{to:G(`hosts`),replace:!0})}),(0,Z.jsx)(u,{path:`hosts`,element:(0,Z.jsx)(Vn,{})}),(0,Z.jsx)(u,{path:`hosts/:hostId`,element:(0,Z.jsx)(qn,{})}),(0,Z.jsx)(u,{path:`devices`,element:(0,Z.jsx)(jn,{})}),(0,Z.jsx)(u,{path:`sign-in`,element:(0,Z.jsx)(Or,{})}),(0,Z.jsx)(u,{path:`projects`,element:(0,Z.jsx)(Tr,{})}),(0,Z.jsx)(u,{path:`projects/new`,element:(0,Z.jsx)(Dr,{})}),(0,Z.jsx)(u,{path:`projects/:projectId`,element:(0,Z.jsx)(br,{})}),(0,Z.jsx)(u,{path:`trackers`,element:(0,Z.jsx)(zr,{})}),(0,Z.jsx)(u,{path:`profiles`,element:(0,Z.jsx)(dr,{})}),(0,Z.jsx)(u,{path:`policies`,element:(0,Z.jsx)(ar,{})}),(0,Z.jsx)(u,{path:`terminals`,element:(0,Z.jsx)(Mr,{})}),(0,Z.jsx)(u,{path:`adapters`,element:(0,Z.jsx)(bn,{})}),(0,Z.jsx)(u,{path:`notifications`,element:(0,Z.jsx)(Zn,{})}),(0,Z.jsx)(u,{path:`backups`,element:(0,Z.jsx)(Dn,{})}),(0,Z.jsx)(u,{path:`diagnostics`,element:(0,Z.jsx)(Nn,{})}),(0,Z.jsx)(u,{path:`device`,element:(0,Z.jsx)(Mn,{})}),(0,Z.jsx)(u,{path:`*`,element:(0,Z.jsx)(Jr,{})})]});return t?(0,Z.jsx)(`div`,{className:`min-w-0`,children:n}):(0,Z.jsxs)(`div`,{className:`flex min-h-full min-w-0`,children:[(0,Z.jsx)(Gr,{compact:e===`compact`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:n})]})}function Wr(){let{pathname:e}=i(),t=e.split(`/`),n=t.indexOf(`settings`);return n>=0&&(t[n+1]??null)||null}function Gr({compact:e}){let t=Wr();return(0,Z.jsx)(`div`,{className:n(`shrink-0 border-r border-border`,e?`w-52`:`w-60`),children:(0,Z.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent sticky top-0 flex max-h-dvh flex-col gap-1 overflow-y-auto px-2 py-4`,children:[(0,Z.jsx)(`h2`,{className:`mb-1 px-3 py-1 text-base font-semibold`,children:`Settings`}),lt.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`h3`,{className:`px-3 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:e.label}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.sections.map(({path:e,label:r,icon:i})=>{let a=t===e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(o,{to:G(e),"data-keyboard-item":!0,"aria-current":a?`page`:void 0,className:n(`tap flex h-10 items-center gap-3 rounded-md px-3 text-sm font-medium`,a?`bg-accent-soft text-text`:`text-muted hover:bg-surface-2 hover:text-text`),children:[(0,Z.jsx)(i,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r})]})},e)})})]},e.label))]})})}function Kr(){let e=D(e=>e.hosts),t=D(e=>e.devices),n=D(e=>e.projects),r=D(e=>e.profiles),i=D(e=>e.adapters),a=D(e=>e.hydrated);return(0,X.useMemo)(()=>{if(!a)return{};let o=Object.values(e).filter(e=>e.revokedAt===null),s=o.filter(e=>e.connectivity===`connected`).length,c=Object.values(i).reduce((e,t)=>e+t.length,0),l=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return{hosts:`${l(o.length,`host`)}, ${s} connected`,devices:l(Object.values(t).filter(e=>e.revokedAt===null).length,`device`),projects:l(Object.keys(n).length,`project`),profiles:l(Object.keys(r).length,`profile`),adapters:l(c,`adapter`)}},[e,t,n,r,i,a])}function qr(){let e=Kr();return(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-xl flex-col gap-3 px-4 py-4`,children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,Z.jsx)(L,{}),(0,Z.jsx)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,tabIndex:-1,"data-keyboard-scope":!0,"data-keyboard-default":!0,className:`focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent`,children:lt.map(t=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`px-1 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:t.label}),(0,Z.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.sections.map(({path:t,label:n,description:r,icon:i})=>(0,Z.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Z.jsxs)(o,{to:G(t),state:Pe,"data-keyboard-item":!0,className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,Z.jsx)(i,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:n}),(0,Z.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:e[t]??r})]}),(0,Z.jsx)(ke,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},t))})]},t.label))})]})}function Jr(){return(0,Z.jsx)(R,{title:`Settings page not found`,description:`This link does not match a settings section.`,action:{label:`Open Settings`,to:G()}})}export{Ur as default};
|
|
12
|
-
//# sourceMappingURL=settings-B0IbaTOd.js.map
|