@spencerboucher/switchyard 0.22.0 → 0.24.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 +17 -7
- package/dist/bridge/switchyard-terminal.js +2 -0
- package/dist/policies/worker.js +199 -73
- package/dist/switchyard.mjs +17974 -14444
- package/package.json +1 -1
- package/web-dist/assets/AutomationView-BiSxKpgA.js +2 -0
- package/web-dist/assets/AutomationView-BiSxKpgA.js.map +1 -0
- package/web-dist/assets/Checkbox-CneW7ZHn.js +2 -0
- package/web-dist/assets/{Checkbox-DR78wXsg.js.map → Checkbox-CneW7ZHn.js.map} +1 -1
- package/web-dist/assets/DangerZone-tpxj5S8V.js +2 -0
- package/web-dist/assets/{DangerZone-CBnW9h0p.js.map → DangerZone-tpxj5S8V.js.map} +1 -1
- package/web-dist/assets/Field-0rAadZ7B.js +2 -0
- package/web-dist/assets/Field-0rAadZ7B.js.map +1 -0
- package/web-dist/assets/NavigationEditor-DE3vVnHw.js +2 -0
- package/web-dist/assets/{NavigationEditor-C0J7vDXL.js.map → NavigationEditor-DE3vVnHw.js.map} +1 -1
- package/web-dist/assets/Overlay-kkZVSidv.js +2 -0
- package/web-dist/assets/{Overlay-DPZqU_vB.js.map → Overlay-kkZVSidv.js.map} +1 -1
- package/web-dist/assets/{Priority-0hv1Vpg7.js → Priority-VTOBYjs9.js} +2 -2
- package/web-dist/assets/{Priority-0hv1Vpg7.js.map → Priority-VTOBYjs9.js.map} +1 -1
- package/web-dist/assets/RadioCards-Oy23yrpF.js +2 -0
- package/web-dist/assets/{RadioCards-CN5xELnc.js.map → RadioCards-Oy23yrpF.js.map} +1 -1
- package/web-dist/assets/ScopeRepository-BU9I7Gs_.js +6 -0
- package/web-dist/assets/ScopeRepository-BU9I7Gs_.js.map +1 -0
- package/web-dist/assets/ScopeSelect-7ZYRzci5.js +2 -0
- package/web-dist/assets/ScopeSelect-7ZYRzci5.js.map +1 -0
- package/web-dist/assets/SegmentedControl-CCObjCnv.js +2 -0
- package/web-dist/assets/SegmentedControl-CCObjCnv.js.map +1 -0
- package/web-dist/assets/Select-CRC4mF4U.js +2 -0
- package/web-dist/assets/{Select-CN7M29ap.js.map → Select-CRC4mF4U.js.map} +1 -1
- package/web-dist/assets/StructuredValue-DdwqFsZd.js +5 -0
- package/web-dist/assets/StructuredValue-DdwqFsZd.js.map +1 -0
- package/web-dist/assets/Switch-llihKH_2.js +2 -0
- package/web-dist/assets/{Switch-CZMY83Fw.js.map → Switch-llihKH_2.js.map} +1 -1
- package/web-dist/assets/Tabs-CIolUgNo.js +184 -0
- package/web-dist/assets/Tabs-CIolUgNo.js.map +1 -0
- package/web-dist/assets/{TextLink-BpF2vLiL.js → TextLink-BJlPjvKn.js} +2 -2
- package/web-dist/assets/{TextLink-BpF2vLiL.js.map → TextLink-BJlPjvKn.js.map} +1 -1
- package/web-dist/assets/{UINodeRenderer-DqIkLhF8.js → UINodeRenderer-DwZNt-8y.js} +3 -3
- package/web-dist/assets/{UINodeRenderer-DqIkLhF8.js.map → UINodeRenderer-DwZNt-8y.js.map} +1 -1
- package/web-dist/assets/UnfilteredNote-B77oGOcW.js +2 -0
- package/web-dist/assets/{UnfilteredNote-22-Qjb-f.js.map → UnfilteredNote-B77oGOcW.js.map} +1 -1
- package/web-dist/assets/api-C7CMr6g-.js +2 -0
- package/web-dist/assets/api-C7CMr6g-.js.map +1 -0
- package/web-dist/assets/{arrow-down-CzjHSpfM.js → arrow-down-Bqx9CSB1.js} +2 -2
- package/web-dist/assets/{arrow-down-CzjHSpfM.js.map → arrow-down-Bqx9CSB1.js.map} +1 -1
- package/web-dist/assets/{arrow-up-B4YU8Bg0.js → arrow-up-D0b2fv0Q.js} +2 -2
- package/web-dist/assets/{arrow-up-B4YU8Bg0.js.map → arrow-up-D0b2fv0Q.js.map} +1 -1
- package/web-dist/assets/attention-DMhF0I-p.js +2 -0
- package/web-dist/assets/attention-DMhF0I-p.js.map +1 -0
- package/web-dist/assets/auth-vd8OFoQx.js +2 -0
- package/web-dist/assets/auth-vd8OFoQx.js.map +1 -0
- package/web-dist/assets/automations-Dz_JHvUj.js +2 -0
- package/web-dist/assets/{automations-DnydDML9.js.map → automations-Dz_JHvUj.js.map} +1 -1
- package/web-dist/assets/board-CMfIsKrb.js +6 -0
- package/web-dist/assets/board-CMfIsKrb.js.map +1 -0
- package/web-dist/assets/{calendar-clock-B3bQkNKq.js → calendar-clock-C5cMYlld.js} +2 -2
- package/web-dist/assets/{calendar-clock-B3bQkNKq.js.map → calendar-clock-C5cMYlld.js.map} +1 -1
- package/web-dist/assets/chevron-right-5ip-ZfOW.js +2 -0
- package/web-dist/assets/{chevron-right-DuAbbYQ-.js.map → chevron-right-5ip-ZfOW.js.map} +1 -1
- package/web-dist/assets/code-BpPDYwth.js +24 -0
- package/web-dist/assets/code-BpPDYwth.js.map +1 -0
- package/web-dist/assets/{core.esm-BbOnWvFK.js → core.esm-C_QgTrGe.js} +2 -2
- package/web-dist/assets/{core.esm-BbOnWvFK.js.map → core.esm-C_QgTrGe.js.map} +1 -1
- package/web-dist/assets/{describe-DWsoiUix.js → describe-Bd1JbydU.js} +3 -3
- package/web-dist/assets/describe-Bd1JbydU.js.map +1 -0
- package/web-dist/assets/enroll-B_ZjVnEj.js +2 -0
- package/web-dist/assets/{enroll-CV77Sk6h.js.map → enroll-B_ZjVnEj.js.map} +1 -1
- package/web-dist/assets/external-link-DeLk0jmb.js +2 -0
- package/web-dist/assets/external-link-DeLk0jmb.js.map +1 -0
- package/web-dist/assets/{git-branch-Dr8PvfHN.js → git-branch-DuApoZes.js} +2 -2
- package/web-dist/assets/{git-branch-Dr8PvfHN.js.map → git-branch-DuApoZes.js.map} +1 -1
- package/web-dist/assets/{grip-vertical-Bc5pJHHF.js → grip-vertical-DfKSP8jp.js} +2 -2
- package/web-dist/assets/{grip-vertical-Bc5pJHHF.js.map → grip-vertical-DfKSP8jp.js.map} +1 -1
- package/web-dist/assets/{hand-B2TrADIv.js → hand-ryhCgGbh.js} +2 -2
- package/web-dist/assets/{hand-B2TrADIv.js.map → hand-ryhCgGbh.js.map} +1 -1
- package/web-dist/assets/index-BXoBPAUR.js +17 -0
- package/web-dist/assets/index-BXoBPAUR.js.map +1 -0
- package/web-dist/assets/index-Bm6tklht.css +2 -0
- package/web-dist/assets/{link-2-M5ENDPWT.js → link-2-pHvZvxCs.js} +2 -2
- package/web-dist/assets/{link-2-M5ENDPWT.js.map → link-2-pHvZvxCs.js.map} +1 -1
- package/web-dist/assets/logic-3so3T0af.js +4 -0
- package/web-dist/assets/logic-3so3T0af.js.map +1 -0
- package/web-dist/assets/logic-uhnfzaYJ.js +2 -0
- package/web-dist/assets/{logic-CG2E-voG.js.map → logic-uhnfzaYJ.js.map} +1 -1
- package/web-dist/assets/more-C41VHBVG.js +2 -0
- package/web-dist/assets/{more-CVjg2O5h.js.map → more-C41VHBVG.js.map} +1 -1
- package/web-dist/assets/{pencil-y_4AgVa2.js → pencil-BoQa6LEV.js} +2 -2
- package/web-dist/assets/{pencil-y_4AgVa2.js.map → pencil-BoQa6LEV.js.map} +1 -1
- package/web-dist/assets/{play-CYKX2aVL.js → play-DjTVY8Ej.js} +2 -2
- package/web-dist/assets/{play-CYKX2aVL.js.map → play-DjTVY8Ej.js.map} +1 -1
- package/web-dist/assets/{plus-B6uH1yKa.js → plus-BQPgQYui.js} +2 -2
- package/web-dist/assets/{plus-B6uH1yKa.js.map → plus-BQPgQYui.js.map} +1 -1
- package/web-dist/assets/{policyLogic-CioD2rMm.js → policyLogic-cyMrhCM6.js} +2 -2
- package/web-dist/assets/{policyLogic-CioD2rMm.js.map → policyLogic-cyMrhCM6.js.map} +1 -1
- package/web-dist/assets/{prefs-V29Ms2ZL.js → prefs-CkiUftvR.js} +2 -2
- package/web-dist/assets/{prefs-V29Ms2ZL.js.map → prefs-CkiUftvR.js.map} +1 -1
- package/web-dist/assets/preload-helper-B_HW6k8N.js +9 -0
- package/web-dist/assets/preload-helper-B_HW6k8N.js.map +1 -0
- package/web-dist/assets/queue-CSCmR2Xf.js +2 -0
- package/web-dist/assets/{queue-BGK9c062.js.map → queue-CSCmR2Xf.js.map} +1 -1
- package/web-dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/web-dist/assets/{rotate-ccw-DvfmNYNE.js → rotate-ccw-C07CP9JG.js} +2 -2
- package/web-dist/assets/{rotate-ccw-DvfmNYNE.js.map → rotate-ccw-C07CP9JG.js.map} +1 -1
- package/web-dist/assets/{search-GTFKEqAS.js → search-bqDM8qB0.js} +2 -2
- package/web-dist/assets/{search-GTFKEqAS.js.map → search-bqDM8qB0.js.map} +1 -1
- package/web-dist/assets/settings-iTwK6CzQ.js +6 -0
- package/web-dist/assets/settings-iTwK6CzQ.js.map +1 -0
- package/web-dist/assets/states-goHGz_CJ.js +60 -0
- package/web-dist/assets/{states-BUWwUyu-.js.map → states-goHGz_CJ.js.map} +1 -1
- package/web-dist/assets/{terminal-DGVFZER3.js → terminal-BFJK8pLS.js} +2 -2
- package/web-dist/assets/{terminal-DGVFZER3.js.map → terminal-BFJK8pLS.js.map} +1 -1
- package/web-dist/assets/terminal-login-DwI8gUw-.js +2 -0
- package/web-dist/assets/{terminal-login-Gy6aLzgC.js.map → terminal-login-DwI8gUw-.js.map} +1 -1
- package/web-dist/assets/useBreakpoint-C7ONetzK.js +2 -0
- package/web-dist/assets/{useBreakpoint-DoLUoCMf.js.map → useBreakpoint-C7ONetzK.js.map} +1 -1
- package/web-dist/assets/useNow-BFhACgmu.js +2 -0
- package/web-dist/assets/{useNow-BS_9T7IY.js.map → useNow-BFhACgmu.js.map} +1 -1
- package/web-dist/assets/useResource-Br3v4Sui.js +2 -0
- package/web-dist/assets/useResource-Br3v4Sui.js.map +1 -0
- package/web-dist/assets/useSwipeTabs-_JvGirwa.js +2 -0
- package/web-dist/assets/useSwipeTabs-_JvGirwa.js.map +1 -0
- package/web-dist/assets/workboard-IozvaLbf.js +3 -0
- package/web-dist/assets/workboard-IozvaLbf.js.map +1 -0
- package/web-dist/index.html +9 -7
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-DwZ_2m9J.js +0 -2
- package/web-dist/assets/AutomationView-DwZ_2m9J.js.map +0 -1
- package/web-dist/assets/Checkbox-DR78wXsg.js +0 -2
- package/web-dist/assets/DangerZone-CBnW9h0p.js +0 -2
- package/web-dist/assets/Field-DS2BMoqA.js +0 -2
- package/web-dist/assets/Field-DS2BMoqA.js.map +0 -1
- package/web-dist/assets/Markdown-BIO6MBTM.js +0 -184
- package/web-dist/assets/Markdown-BIO6MBTM.js.map +0 -1
- package/web-dist/assets/NavigationEditor-C0J7vDXL.js +0 -2
- package/web-dist/assets/Overlay-DPZqU_vB.js +0 -2
- package/web-dist/assets/RadioCards-CN5xELnc.js +0 -2
- package/web-dist/assets/ScopeSelect-BaJjip1Y.js +0 -2
- package/web-dist/assets/ScopeSelect-BaJjip1Y.js.map +0 -1
- package/web-dist/assets/SegmentedControl-CRmhE-Kn.js +0 -2
- package/web-dist/assets/SegmentedControl-CRmhE-Kn.js.map +0 -1
- package/web-dist/assets/Select-CN7M29ap.js +0 -2
- package/web-dist/assets/Switch-CZMY83Fw.js +0 -2
- package/web-dist/assets/Tabs-_1w3hoAR.js +0 -2
- package/web-dist/assets/Tabs-_1w3hoAR.js.map +0 -1
- package/web-dist/assets/UnfilteredNote-22-Qjb-f.js +0 -2
- package/web-dist/assets/api-RftVSu44.js +0 -2
- package/web-dist/assets/api-RftVSu44.js.map +0 -1
- package/web-dist/assets/attention-CEgIsUuq.js +0 -2
- package/web-dist/assets/attention-CEgIsUuq.js.map +0 -1
- package/web-dist/assets/automations-DnydDML9.js +0 -2
- package/web-dist/assets/board-BPxxc8G4.js +0 -6
- package/web-dist/assets/board-BPxxc8G4.js.map +0 -1
- package/web-dist/assets/chevron-right-DuAbbYQ-.js +0 -2
- package/web-dist/assets/code-D5IB7jTT.js +0 -28
- package/web-dist/assets/code-D5IB7jTT.js.map +0 -1
- package/web-dist/assets/describe-DWsoiUix.js.map +0 -1
- package/web-dist/assets/enroll-CV77Sk6h.js +0 -2
- package/web-dist/assets/index-BXQwol8u.css +0 -2
- package/web-dist/assets/index-cmIcNnnF.js +0 -17
- package/web-dist/assets/index-cmIcNnnF.js.map +0 -1
- package/web-dist/assets/logic-CG2E-voG.js +0 -2
- package/web-dist/assets/logic-D_vBBkcD.js +0 -4
- package/web-dist/assets/logic-D_vBBkcD.js.map +0 -1
- package/web-dist/assets/more-CVjg2O5h.js +0 -2
- package/web-dist/assets/queue-BGK9c062.js +0 -2
- package/web-dist/assets/repo-CuL_qbqU.js +0 -5
- package/web-dist/assets/repo-CuL_qbqU.js.map +0 -1
- package/web-dist/assets/selection-CAMJBh5A.js +0 -9
- package/web-dist/assets/selection-CAMJBh5A.js.map +0 -1
- package/web-dist/assets/settings-o7k_MPK7.js +0 -9
- package/web-dist/assets/settings-o7k_MPK7.js.map +0 -1
- package/web-dist/assets/states-BUWwUyu-.js +0 -60
- package/web-dist/assets/terminal-login-Gy6aLzgC.js +0 -2
- package/web-dist/assets/useBreakpoint-DoLUoCMf.js +0 -2
- package/web-dist/assets/useIndicator-BKqIsw2Q.js +0 -2
- package/web-dist/assets/useIndicator-BKqIsw2Q.js.map +0 -1
- package/web-dist/assets/useNow-BS_9T7IY.js +0 -2
- package/web-dist/assets/useResource-CPN6cDQ5.js +0 -2
- package/web-dist/assets/useResource-CPN6cDQ5.js.map +0 -1
- package/web-dist/assets/useSwipeTabs-XRK0_O6T.js +0 -2
- package/web-dist/assets/useSwipeTabs-XRK0_O6T.js.map +0 -1
- package/web-dist/assets/workboard-FE6bAMnW.js +0 -3
- package/web-dist/assets/workboard-FE6bAMnW.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{fn as e,hn as t}from"./states-BUWwUyu-.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=t(e(),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-CG2E-voG.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{Kt as e,Qt as t,St as n,W as r,Yt as i,Zt as a,_ as o,d as s,fn as c,g as l,hn as u,m as d,n as f,un as p,v as m}from"./states-BUWwUyu-.js";import{_ as h,g,i as _,m as v,n as y,p as b,t as x,u as S,v as C}from"./Overlay-DPZqU_vB.js";import{Bt as w,H as T,Ht as E,O as D,Rt as O,U as k,Vt as A,Wt as j,mt as M,y as N,z as P}from"./selection-CAMJBh5A.js";import{t as F}from"./arrow-up-B4YU8Bg0.js";import{t as I}from"./UINodeRenderer-DqIkLhF8.js";import{t as L}from"./Field-DS2BMoqA.js";import{t as R}from"./useBreakpoint-DoLUoCMf.js";import{$ as ee,G as z,K as B,W as V}from"./index-cmIcNnnF.js";import{t as H}from"./TextLink-BpF2vLiL.js";import{n as U,t as te}from"./Markdown-BIO6MBTM.js";import{t as W}from"./haptics-O69vKVoK.js";import{a as G,n as ne,t as K}from"./api-RftVSu44.js";var q=u(c(),1),re=`An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.`,ie=[{id:`abort`,label:`Stop the run`,tone:`danger`},{id:`message`,label:`Send a message to Pi`,tone:`primary`}];function ae(e){if(e.t===`actions`)return e;if(e.t===`section`)for(let t of e.children){let e=ae(t);if(e)return e}return null}function oe(e){return e.state===`unsupported`||e.source.kind===`unsupported_custom`}function se(e){let t=(ae(e.presentation)?.actions??[]).filter(e=>e.id===`abort`||e.id===`message`).map(e=>({id:e.id,label:e.label,tone:e.tone==="default"?`secondary`:e.tone??(e.id===`abort`?`danger`:`primary`)}));return{answerable:e.state===`unsupported`&&e.resolution===null,actions:t.length>0?t:ie,copy:re}}function ce(e){return e===`running`||e===`waiting_input`?`followUp`:`prompt`}var J=d();function Y(e){switch(e.t){case`form`:case`confirm`:case`actions`:return!0;case`list`:return e.items.some(Y);case`section`:return e.children.some(Y);case`tabs`:return e.tabs.some(e=>e.children.some(Y));default:return!1}}function X(e){return e===`host`?`the host`:e===`pi`?`Pi`:`a device`}function le({interaction:e,readOnlyReason:n,className:o,onAnswered:c,id:u,sticky:d,flush:p,mode:h=`card`,keys:g=!0,planAnchorId:_}){let v=r(e=>e.upsertInteraction),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(null),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(null),[D,O]=(0,q.useState)(null),k=D&&D.id===e.id&&D.revision>e.revision?D:e,A=k.state===`pending`,j=oe(k),M=r(e=>e.sessions[k.sessionId]?.runtime),[N,P]=(0,q.useState)(!1),[F,L]=(0,q.useState)(``),z=async e=>{b(!0),S(null),E(e);try{let t=await i(`/api/interactions/${encodeURIComponent(k.id)}/answer`,{revision:k.revision,response:e});return t?.interaction&&(v(t.interaction),O(t.interaction),c?.(t.interaction)),!0}catch(e){if(t(e,`already_answered`)){let t=e.details?.interaction;t&&(v(t),O(t)),w(t?.resolution?.summary??`answered on another device`)}else S(e);return!1}finally{b(!1)}},B=async()=>{let e=F.trim();if(e){b(!0),S(null);try{await i(`/api/sessions/${encodeURIComponent(k.sessionId)}/prompt`,{text:e,mode:ce(M)})}catch(e){S(e),b(!1);return}b(!1),await z({kind:`action`,actionId:`message`})&&(P(!1),L(``))}},V=R();if(A&&!C&&!j&&he(k.presentation))return(0,J.jsx)(ye,{id:u,interaction:k,node:k.presentation,onRespond:e=>void z(e),busy:y,disabled:!!n,disabledReason:n??null,part:h===`reader`?`reader`:h===`dock`?`answers`:`all`,planAnchorId:_,mobile:V===`mobile`,sticky:d??!0,flush:p??!1,className:o});let H=h===`dock`;return(0,J.jsxs)(`article`,{id:u,"aria-label":`Question: ${k.title}`,className:m(H?`flex min-w-0 flex-col gap-2`:`flex min-w-0 flex-col gap-3 border-l-2 py-1 pl-3`,!H&&(A?`border-warning`:`border-border`),o),children:[H?(0,J.jsx)(`h3`,{className:`text-sm font-semibold break-words`,children:k.title}):(0,J.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,J.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-semibold break-words`,children:k.title}),(0,J.jsx)(ee,{kind:`interaction`,value:k.state,size:`sm`})]}),C&&(0,J.jsxs)(`p`,{role:`status`,className:`rounded-md bg-surface-2 px-3 py-2 text-sm`,children:[`Already answered: `,C]}),j?(0,J.jsx)(ue,{interaction:k,readOnlyReason:n??null,busy:y,answered:C!==null,composing:N,message:F,setMessage:L,onAction:e=>{e===`message`?P(!0):z({kind:`action`,actionId:e})},onSend:()=>void B(),onCancelMessage:()=>P(!1)}):A&&!C?(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:n}),(0,J.jsx)(I,{node:k.presentation,onRespond:e=>void z(e),busy:y,disabled:!!n,dock:H?{title:k.title,keys:g&&k.kind===`question`}:void 0}),!n&&!Y(k.presentation)&&(0,J.jsx)(`div`,{children:(0,J.jsx)(s,{busy:y,onClick:()=>void z({kind:`cancel`}),children:`Dismiss`})}),y&&(0,J.jsx)(`p`,{role:`status`,className:`text-sm text-muted`,children:`Sending answer… waiting for the host to confirm.`})]}):C?null:k.resolution?(0,J.jsxs)(`p`,{className:`text-sm text-muted`,children:[k.state===`resolved`?`Answered`:`Closed`,` by`,` `,X(k.resolution.by),` `,l(k.resolution.at),`:`,` `,(0,J.jsx)(`span`,{className:`text-text`,children:k.resolution.summary})]}):(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:k.state===`expired`?`This question expired before it was answered (Pi closed the dialog).`:`This question was canceled.`}),x!==null&&(0,J.jsx)(f,{compact:!0,title:`Answer not delivered`,error:a(x),onRetry:T?()=>void z(T):void 0})]})}function ue({interaction:e,readOnlyReason:t,busy:n,answered:r,composing:i,message:a,setMessage:o,onAction:c,onSend:u,onCancelMessage:d}){let f=se(e);return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:f.copy}),e.resolution?(0,J.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Chosen by `,X(e.resolution.by),` `,l(e.resolution.at),`: `,(0,J.jsx)(`span`,{className:`text-text`,children:e.resolution.summary})]}):!f.answerable||r?null:t?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:t}):i?(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,J.jsx)(V,{"aria-label":`Message for Pi`,value:a,onChange:e=>o(e.target.value),rows:3,autoFocus:!0,placeholder:`Tell Pi what to do instead`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(s,{variant:`primary`,busy:n,disabled:!a.trim(),onClick:u,children:`Send message`}),(0,J.jsx)(s,{disabled:n,onClick:d,children:`Cancel`})]})]}):(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.actions.map(e=>(0,J.jsx)(s,{variant:e.tone,busy:n&&e.id===`abort`,disabled:n,onClick:()=>c(e.id),children:e.label},e.id))})]})}function de(e){if(e.t!==`section`||e.children.length<2)return null;let t=e.children[e.children.length-1];if(t?.t!==`actions`)return null;let n=e.children.slice(0,-1);return n.some(Y)?null:{body:{...e,children:n},actions:t}}function fe(e,t){let n=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches;e?.scrollIntoView({behavior:n?`auto`:`smooth`,block:t})}function pe(e){let[t,n]=(0,q.useState)(!0);return(0,q.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>n(!!e?.isIntersecting));return r.observe(t),()=>r.disconnect()},[e]),t}function me(e){if(e.t===`markdown`)return e.text;if(e.t===`section`)for(let t of e.children){let e=me(t);if(e!==null)return e}return null}function he(e){if(!de(e))return!1;let t=me(e);return t!==null&&(t.length>=400||t.split(`
|
|
2
|
-
`).length>=12)}function ge(e){let t=/^\s*#{1,6}\s+(.+?)\s*(?:\n+|$)/.exec(e);return t?.[1]?{title:t[1],rest:e.slice(t[0].length)}:{title:null,rest:e}}function _e(e){let t=[],n=!1;for(let r of e.split(`
|
|
3
|
-
`)){/^\s*```/.test(r)&&(n=!n);let e=n?null:/^##\s+(.+?)\s*$/.exec(r);e?.[1]&&t.push({text:e[1],id:U(e[1])})}return t}function ve(e,t){let[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(null),o=e.join(`|`);(0,q.useEffect)(()=>{if(typeof IntersectionObserver>`u`||!e.length)return;let n=e.map(e=>t.current?.querySelector(`#${CSS.escape(e)}`)).filter(e=>!!e),i=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&r(t.target.id)},{rootMargin:`-56px 0px -70% 0px`});for(let e of n)i.observe(e);let o=()=>a(null);return window.addEventListener(`wheel`,o,{passive:!0}),window.addEventListener(`touchmove`,o,{passive:!0}),window.addEventListener(`keydown`,o),()=>{i.disconnect(),window.removeEventListener(`wheel`,o),window.removeEventListener(`touchmove`,o),window.removeEventListener(`keydown`,o)}},[o,t]);let s=i??n;return(0,q.useEffect)(()=>{let e=t.current;if(e){for(let t of e.querySelectorAll(`h2[data-active]`))delete t.dataset.active;if(s){let t=e.querySelector(`#${CSS.escape(s)}`);t&&(t.dataset.active=`true`)}}},[s,o,t]),[s,a]}function ye({id:e,interaction:t,node:n,onRespond:r,busy:i,disabled:a,disabledReason:o,part:c,planAnchorId:l,mobile:u,sticky:d,flush:f,className:p}){let h=(0,q.useRef)(null),g=(0,q.useRef)(null),v=(0,q.useRef)(null),y=pe(v),[b,x]=(0,q.useState)(!1),C=de(n),{title:w,rest:T}=ge((C?.body.t===`section`?C.body.children.find(e=>e.t===`markdown`):void 0)?.text??``),E=_e(T),[D,O]=ve(E.map(e=>e.id),h);if(C?.body.t!==`section`)return null;let k=C.actions.actions,A=C.body.children.find(e=>e.t===`section`),j=t.title,M=w??j,N=e=>{x(!1),r({kind:`action`,actionId:e})},P=(e,t)=>e===0||t===`primary`?`primary`:t===`danger`?`danger`:`secondary`,L=!a&&!y,R=`h-auto! min-h-9 min-w-0 py-1.5 text-left leading-tight whitespace-normal!`,z=e=>fe(e,`start`),B=()=>c===`answers`?l?document.getElementById(l):null:g.current,V=c!==`answers`||l!==void 0,U=u?(0,J.jsxs)(J.Fragment,{children:[V&&(0,J.jsx)(S,{label:`Plan start`,icon:(0,J.jsx)(F,{className:`size-4`}),variant:`secondary`,onClick:()=>z(B())}),k.length>2?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(s,{variant:`primary`,disabled:i,className:m(R,`flex-1`),onClick:()=>N(k[0].id),children:k[0].label}),(0,J.jsxs)(s,{variant:`secondary`,onClick:()=>x(!0),children:[`More (`,k.length-1,`)`]})]}):k.map((e,t)=>(0,J.jsx)(s,{variant:P(t,e.tone),disabled:i,className:m(R,`flex-1`),onClick:()=>N(e.id),children:e.label},e.id))]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`max-w-[16rem] min-w-0 shrink truncate text-sm font-medium`,title:j,children:j}),(0,J.jsx)(`div`,{className:`grid min-w-0 flex-1 grid-cols-[repeat(auto-fit,minmax(11rem,1fr))] gap-2`,children:k.map((e,t)=>(0,J.jsx)(s,{variant:P(t,e.tone),disabled:i,className:m(R,`w-full md:text-center`),onClick:()=>N(e.id),children:e.label},e.id))}),V&&(0,J.jsx)(S,{label:`Plan start`,icon:(0,J.jsx)(F,{className:`size-4`}),variant:`secondary`,size:`sm`,onClick:()=>z(B())})]}),W=(0,J.jsx)(_,{open:b,onClose:()=>x(!1),title:j,children:(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:k.map((e,t)=>(0,J.jsx)(s,{block:!0,variant:P(t,e.tone),disabled:i,className:R,onClick:()=>N(e.id),children:e.label},e.id))})});if(c===`answers`)return(0,J.jsxs)(`article`,{"aria-label":`Question: ${j}`,"data-testid":`plan-answers`,className:m(`flex min-w-0 flex-col gap-2`,p),children:[u&&(0,J.jsx)(`p`,{className:`text-sm font-medium`,children:j}),o?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:o}):(0,J.jsx)(`div`,{"data-testid":`answer-bar`,className:`flex min-w-0 items-center gap-2 md:gap-3`,children:U}),W]});let G=c===`reader`;return(0,J.jsxs)(`article`,{id:e,"data-testid":`document-interaction`,"aria-label":`Question: ${j}`,className:m(`w-full min-w-0 self-stretch border-t border-border`,p),children:[(0,J.jsxs)(`header`,{className:m(`z-10 flex min-w-0 items-center gap-2 border-b border-border bg-bg px-4 py-2 md:px-6`,d&&(f?`md:sticky md:top-0`:`max-md:static md:sticky md:-top-3`)),children:[(0,J.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[15px] leading-snug font-semibold md:text-sm`,children:M}),u&&!G&&(0,J.jsx)(ee,{kind:`interaction`,value:t.state,size:`sm`,className:`[&>span]:sr-only`}),!G&&!a&&!y&&(0,J.jsx)(H,{size:`xs`,className:`shrink-0`,onClick:()=>fe(v.current,`center`),children:`Jump to options ↓`})]}),A&&(0,J.jsx)(`aside`,{className:`mx-4 mt-3 rounded-md bg-warning-soft px-3 py-2 text-sm md:mx-6`,children:(0,J.jsx)(I,{node:A})}),(0,J.jsxs)(`div`,{className:`px-4 py-4 md:grid md:grid-cols-[13rem_minmax(0,1fr)] 2xl:grid-cols-[15rem_minmax(0,1fr)] md:gap-8 md:px-6`,children:[E.length>0&&(0,J.jsx)(`nav`,{"aria-label":`Plan sections`,className:`hidden md:block`,children:(0,J.jsxs)(`ol`,{className:`sticky top-16 flex flex-col gap-0.5 border-l border-border text-sm`,children:[(0,J.jsx)(`li`,{children:(0,J.jsx)(`button`,{type:`button`,className:`-ml-px block w-full truncate border-l-2 border-transparent py-1 pl-3 text-left text-muted hover:text-text`,onClick:()=>z(g.current),children:`Start`})}),E.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(`button`,{type:`button`,"aria-current":D===e.id,className:`-ml-px block w-full truncate border-l-2 border-transparent py-1 pl-3 text-left text-muted hover:text-text aria-[current=true]:border-accent aria-[current=true]:text-text`,onClick:()=>{O(e.id),z(h.current?.querySelector(`#${CSS.escape(e.id)}`)??null)},children:e.text})},e.id))]})}),(0,J.jsx)(`div`,{ref:g,className:`min-w-0 scroll-mt-14`,children:(0,J.jsx)(`div`,{ref:h,className:`sy-prose-compact max-w-[80ch] min-w-0 2xl:max-w-[100ch] min-[1800px]:text-base [&_h2]:scroll-mt-14`,children:(0,J.jsx)(te,{text:T,headingIds:!0,className:`text-inherit`})})})]}),!G&&(0,J.jsxs)(`section`,{ref:v,"data-testid":`plan-options`,"aria-label":j,className:`border-t border-border px-4 py-3 md:px-6`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:j}),!a&&(0,J.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 md:flex-row md:flex-wrap`,children:k.map((e,t)=>(0,J.jsx)(s,{variant:P(t,e.tone),size:`md`,disabled:i,className:m(R,`md:text-center`),onClick:()=>N(e.id),children:e.label},e.id))}),(0,J.jsx)(H,{size:`xs`,className:`mt-2`,icon:(0,J.jsx)(F,{"aria-hidden":!0,className:`size-3.5`}),onClick:()=>z(g.current),children:`Back to the plan start`})]}),!G&&L&&(0,J.jsx)(`div`,{"data-testid":`answer-bar`,className:m(`z-10 flex min-w-0 items-center gap-2 border-t border-border bg-bg px-4 py-2 md:gap-3 md:px-6`,d&&!f?`sticky -bottom-3`:`sticky bottom-0`),children:U}),!G&&W]})}var be={red:`bg-[#e5484d] text-white`,orange:`bg-[#f76b15] text-white`,blue:`bg-[#0090ff] text-white`,gray:`bg-[#6e7681] text-white`,green:`bg-[#30a46c] text-white`},xe=`transform 260ms cubic-bezier(0.2, 0.9, 0.25, 1)`,Se=`input, textarea, select, [contenteditable], [data-no-swipe]`,Z=null;function Ce({leading:e=[],trailing:t=[],disabled:n,children:r,className:i,contentClassName:a}){let o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=(0,q.useRef)(!1),[l,u]=(0,q.useState)(0),[d,f]=(0,q.useState)(!1),p=(0,q.useRef)(0),_=(0,q.useRef)({leading:e,trailing:t});_.current={leading:e,trailing:t};let y=!n&&(e.length>0||t.length>0),x=()=>o.current?.offsetWidth||320,S=(e,t)=>{let n=o.current;n&&(n.style.transition=t?xe:`none`,n.style.transform=e===0?``:`translateX(${e}px)`),p.current=e,u(e)},w=(0,q.useRef)(()=>{});w.current=()=>{S(0,!0),f(!1),Z===T&&(Z=null)};let[T]=(0,q.useState)(()=>()=>w.current()),E=async(e,t)=>{if(W(),e.removes){let n=x();f(!0),S(t===`leading`?n:-n,!0);try{await e.onAction()}catch{w.current();return}let r=o.current?.parentElement;r&&!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches&&r.animate?.([{height:`${r.offsetHeight}px`},{height:`0px`}],{duration:220,easing:`cubic-bezier(0.2, 0.8, 0.2, 1)`,fill:`forwards`})}else w.current(),await e.onAction()},D=l!==0;(0,q.useEffect)(()=>{if(!D)return;let e=e=>{o.current?.parentElement?.contains(e.target)||s.current||w.current()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[D]),(0,q.useEffect)(()=>()=>{Z===T&&(Z=null)},[T]);let O=e=>{y&&e.isPrimary&&(e.pointerType===`touch`||e.pointerType===`pen`)&&(e.target.closest(Se)||(c.current=!1,s.current={id:e.pointerId,x:e.clientX,y:e.clientY,axis:null,start:p.current,raw:p.current,full:!1,samples:[]}))},k=e=>{let t=s.current;if(!t||e.pointerId!==t.id)return;let n=e.clientX-t.x;if(t.axis===null){if(t.axis=v(n,e.clientY-t.y),t.axis===null)return;if(t.axis===`y`){s.current=null;return}c.current=!0,e.currentTarget.setPointerCapture?.(e.pointerId),Z&&Z!==T&&Z()}let{leading:r,trailing:i}=_.current,a=x(),o=t.start+n;o>0&&r.length===0&&(o=g(o,a)*.15),o<0&&i.length===0&&(o=g(o,a)*.15),t.raw=o,t.samples.push({t:e.timeStamp,v:o}),t.samples=t.samples.slice(-12);let l=(o>0?r.length:i.length)*76,u=l>0&&Math.abs(o)>=b(a,l);u!==t.full&&(t.full=u,f(u),W()),S(o,!1)},A=e=>{let t=s.current;if(s.current=null,t?.axis!==`x`)return;let{leading:n,trailing:r}=_.current;if(e.type===`pointercancel`)return w.current();let i=h(t.raw,C(t.samples),{width:x(),reveal:{leading:n.length*76,trailing:r.length*76},fullSwipe:{leading:!0,trailing:!0}});if(i.kind===`close`)return w.current();let a=i.side===`leading`?n:r,o=a[0];if(!o)return w.current();if(i.kind===`commit`)return void E(o,i.side);f(!1),S((i.side===`leading`?1:-1)*a.length*76,!0),Z=T},j=l>0?`leading`:`trailing`,M=l>0?e:t,N=j===`trailing`?[...M].reverse():M;return(0,J.jsxs)(`div`,{className:m(`relative overflow-hidden`,i),"data-swipe-row":!0,children:[l!==0&&M.length>0&&(0,J.jsx)(`div`,{"aria-hidden":!0,className:m(`absolute inset-y-0 flex`,j===`leading`?`left-0`:`right-0`),style:{width:Math.abs(l)},children:N.map(e=>{let t=e===M[0];return(0,J.jsxs)(`button`,{type:`button`,tabIndex:-1,"data-swipe-action":e.id,onClick:()=>void E(e,j),style:{flexGrow:d?+!!t:1,flexBasis:0},className:m(`flex min-w-0 flex-col items-center justify-center gap-1 overflow-hidden text-xs font-semibold whitespace-nowrap transition-[flex-grow] duration-200`,be[e.tone],d&&t&&(j===`leading`?`items-start pl-6`:`items-end pr-6`)),children:[e.icon,e.label]},e.id)})}),(0,J.jsx)(`div`,{ref:o,className:m(`relative touch-pan-y bg-surface`,a),onPointerDown:O,onPointerMove:k,onPointerUp:A,onPointerCancel:A,onClickCapture:e=>{c.current?(c.current=!1,e.preventDefault(),e.stopPropagation()):p.current!==0&&(e.preventDefault(),e.stopPropagation(),w.current())},children:r})]})}function we(e){let t=r(e=>e.issues);return(0,q.useMemo)(()=>{let n=Object.values(t),r=e?A(n)(e):null;return{linked:r,candidates:e&&!r?n.filter(t=>w(t,e,n)===null).sort(O):[],canUnlink:!!r&&E(r)===null}},[t,e])}function Te({open:e,onClose:t,workspace:n,candidates:r}){let[i,o]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),u=()=>{l(null),t()},d=async e=>{if(!i){o(e.id),l(null);try{await ne(e.id,n.id),B.success(`Linked to #${e.number}`),u()}catch(e){l(e)}finally{o(null)}}};return(0,J.jsx)(y,{open:e,onClose:u,title:`Link to issue`,description:`Link ${n.branch} to an issue that has no branch yet. Its sessions then stay in the issue's scope.`,footer:(0,J.jsx)(s,{onClick:u,children:`Cancel`}),children:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[c!==null&&(0,J.jsx)(f,{compact:!0,title:`Could not link`,error:a(c)}),r.length===0&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No issue without a branch in this project.`}),(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-1`,children:r.map(e=>(0,J.jsx)(`li`,{className:`min-w-0`,children:(0,J.jsxs)(`button`,{type:`button`,disabled:!!i,"aria-busy":i===e.id,onClick:()=>void d(e),className:`tap flex w-full min-w-0 flex-col rounded-md px-2 py-1.5 text-left hover:bg-surface-2 disabled:opacity-55`,children:[(0,J.jsxs)(`span`,{className:`truncate text-sm`,children:[`#`,e.number,` `,e.title]}),(0,J.jsxs)(`span`,{className:`truncate text-xs text-muted`,children:[e.repository,e.board?.priority?` · ${e.board.priority.name}`:``]})]})},e.id))})]})})}var Ee=[];function De(e,n,i){let o=i&&!!e&&!n,[s,c]=(0,q.useState)(null);return(0,q.useEffect)(()=>{if(!o||!e)return;let n=new AbortController;return c({id:e,lookup:{state:`loading`}}),K.get(e,n.signal).then(e=>{r.getState().upsertSessionIfMissing(e),c(null)},r=>{n.signal.aborted||c({id:e,lookup:t(r,`not_found`)?{state:`missing`}:{state:`error`,error:a(r)}})}),()=>n.abort()},[o,e]),o?s?.id===e?s.lookup:{state:`loading`}:{state:`idle`}}function Oe(e){let t=r(t=>e?t.hosts[e.hostId]:void 0),n=r(t=>e?.projectId?t.projects[e.projectId]:void 0),i=r(t=>e?.workspaceId?t.workspaces[e.workspaceId]:void 0),a=r(e=>e.runs),o=r(e=>e.tasks),s=r(t=>e?t.adapters[e.hostId]??Ee:Ee);return(0,q.useMemo)(()=>{if(!e)return null;let r=M(a,e),c=e.taskId??r?.taskId??null;return{session:e,host:t,hostName:t?.name??`Unknown host`,link:P(t,e),project:n,workspace:i,run:r,task:c?o[c]:void 0,control:N(r),adapters:s}},[e,t,n,i,a,o,s])}function Q(e,t={}){let[n,r]=(0,q.useState)(!1),[i,o]=(0,q.useState)(null),s=(0,q.useRef)(e);s.current=e;let c=(0,q.useRef)(t);c.current=t;let l=(0,q.useRef)(!0);return(0,q.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),{run:(0,q.useCallback)(async(...e)=>{r(!0),o(null);try{let t=await s.current(...e),{success:n}=c.current,r=typeof n==`function`?n(t):n;return r&&B.success(r),!0}catch(e){return l.current&&o(e),c.current.errorToast&&B.error(a(e)),!1}finally{l.current&&r(!1)}},[]),busy:n,error:i,reset:(0,q.useCallback)(()=>o(null),[])}}function ke(e,t=1e3){let[n,r]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{if(!e)return;r(Date.now());let n=setInterval(()=>r(Date.now()),t);return()=>clearInterval(n)},[e,t]),n}function Ae(){let e=(0,q.useRef)(null),[t,n]=(0,q.useState)(0);return(0,q.useLayoutEffect)(()=>{let t=e.current;if(!t)return;n(t.clientWidth);let r=new ResizeObserver(([e])=>{e&&n(e.contentRect.width)});return r.observe(t),()=>r.disconnect()},[]),[e,t]}function $({label:e,value:t}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`dt`,{className:`text-muted`,children:e}),(0,J.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:t})]})}function je({session:e,hostLabel:t,open:n,onClose:r}){let i=D(e),a=e.stats;return(0,J.jsx)(y,{open:n,onClose:r,title:`Session info`,children:(0,J.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-2 text-sm`,children:[(0,J.jsx)($,{label:`Switchyard session`,value:e.id}),(0,J.jsx)($,{label:`Pi session id`,value:e.nativeHandle?.sessionId??`Not started`}),(0,J.jsx)($,{label:`Session file`,value:e.nativeHandle?.sessionFile??`None yet`}),(0,J.jsx)($,{label:`Host`,value:t}),(0,J.jsx)($,{label:`Working directory`,value:e.cwd}),(0,J.jsx)($,{label:`Origin`,value:e.provenance}),(0,J.jsx)($,{label:`Profile`,value:e.profileSnapshot.name}),(0,J.jsx)($,{label:`Created`,value:o(e.createdAt)}),a?.tokens!=null&&(0,J.jsx)($,{label:`Tokens`,value:a.tokens.toLocaleString(`en-US`)}),a?.costUsd!=null&&(0,J.jsx)($,{label:`Cost`,value:`$${a.costUsd.toFixed(2)}`}),i&&(0,J.jsx)($,{label:`Context`,value:`${i.label} (${i.detail})`})]})})}function Me(t){let{session:o,run:c,control:l}=t,u=p(),[d,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(o.title),_=we(o.provenance===`subagent`?null:t.workspace),v=r(e=>e.attention),b=(0,q.useMemo)(()=>Object.values(v).filter(e=>e.sessionId===o.id&&!e.resolvedAt&&n(e.reason)),[v,o.id]),S=r(e=>{if(o.provenance===`subagent`||o.archivedAt)return!1;let t=Object.values(e.sessions).filter(e=>e.archivedAt===null&&e.provenance!==`subagent`&&(o.workspaceId?e.workspaceId===o.workspaceId:e.workspaceId===null&&e.hostId===o.hostId&&e.cwd===o.cwd));return j(t)?.id===o.id}),C=Q(()=>K.takeover(o.id),{success:`You have control. Automatic continuations are paused.`,errorToast:!0}),w=Q(()=>K.returnToAutomation(o.id),{success:`Returned to automation.`,errorToast:!0}),E=Q(()=>K.stop(o.id),{success:`Session stopped.`}),D=Q(()=>K.resume(o.id),{success:`Session resumed.`,errorToast:!0}),O=Q(e=>K.rename(o.id,e),{success:`Session renamed.`}),A=Q(()=>K.cacheAlert(o.id,!o.cacheAlert),{errorToast:!0}),M=Q(()=>K.archive(o.id),{success:`Session archived.`}),N=Q(()=>K.unarchive(o.id),{success:`Session unarchived.`,errorToast:!0}),P=t.link===`connected`,F=()=>{m(null),E.reset(),O.reset(),M.reset()},I=T(o)?`Stop the session before archiving it`:null,R=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(x,{open:d===`stop`,onClose:F,title:`Stop this session?`,description:`Stops the current execution and clears queued messages.`,confirmLabel:`Stop session`,busy:E.busy,error:E.error,errorTitle:`Could not stop`,onConfirm:()=>void E.run().then(e=>e&&m(null)),children:(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:c?`The task keeps its run, marked interrupted and blocked (Stopped by user). Automation settings are unchanged.`:`Pi stays available; you can send a new message afterwards.`})}),(0,J.jsx)(y,{open:d===`rename`,onClose:F,title:`Rename session`,footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(s,{onClick:F,children:`Cancel`}),(0,J.jsx)(s,{variant:`primary`,type:`submit`,form:`sy-rename-form`,busy:O.busy,disabled:!h.trim(),children:`Save`})]}),children:(0,J.jsxs)(`form`,{id:`sy-rename-form`,onSubmit:e=>{e.preventDefault(),h.trim()&&O.run(h.trim()).then(e=>e&&m(null))},className:`flex flex-col gap-2`,children:[(0,J.jsx)(L,{id:`sy-rename-input`,label:`Title`,children:(0,J.jsx)(z,{id:`sy-rename-input`,value:h,maxLength:200,onChange:e=>g(e.target.value)})}),O.error!==null&&(0,J.jsx)(f,{compact:!0,title:`Could not rename`,error:a(O.error)})]})}),(0,J.jsx)(x,{open:d===`archive`,onClose:F,title:`Archive this session?`,description:`It leaves the navigator. The Pi session file stays on the host.`,danger:!1,confirmLabel:`Archive`,busy:M.busy,error:M.error,errorTitle:`Could not archive`,onConfirm:()=>void M.run().then(e=>{e&&(m(null),u(`/code`))}),children:o.runtime===`idle`&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`The idle Pi process is stopped first.`})}),t.workspace&&(0,J.jsx)(Te,{open:d===`link`,onClose:F,workspace:t.workspace,candidates:_.candidates}),(0,J.jsx)(je,{session:o,hostLabel:`${t.hostName} (${t.link})`,open:d===`info`,onClose:F})]});return{canTakeover:l===`automation`,canReturn:l===`human`,canStop:T(o)&&P,canResume:!k(o)&&!!o.nativeHandle&&!o.readOnly&&P,archiveBlocked:I,takeover:()=>void C.run(),returnToAutomation:()=>void w.run(),requestStop:()=>m(`stop`),resume:()=>void D.run(),openRename:()=>{g(o.title),m(`rename`)},requestArchive:()=>{I?B.info(I):m(`archive`)},openInfo:()=>m(`info`),toggleCacheAlert:()=>void A.run(),unarchive:()=>void N.run(),dismissAttention:b.length>0?()=>{Promise.all(b.map(Ne)).then(()=>B.success(`Cleared. A question Pi is still waiting on stays.`)).catch(e=>B.error(a(e)))}:null,setPinned:(t,n)=>{let r=`/api/scopes/${encodeURIComponent(t)}/sessions/${encodeURIComponent(o.id)}`;(n?i(r):e(r)).catch(e=>B.error(a(e)))},isPrimary:S,setPrimary:e=>{K.setPrimary(o.id,e).catch(e=>B.error(a(e)))},newInBranch:o.projectId&&o.workspaceId?()=>{K.createSession({projectId:o.projectId,workspace:{existingId:o.workspaceId},prompt:``}).then(e=>{r.getState().upsertSessionIfMissing(e),u(`/code/${encodeURIComponent(e.id)}`)}).catch(e=>B.error(a(e)))}:null,issueLink:t.workspace&&o.provenance!==`subagent`?{..._,open:()=>m(`link`),unlink:()=>{let e=_.linked;e&&G(e.id).then(()=>B.success(`Unlinked from #${e.number}`)).catch(e=>B.error(a(e)))}}:null,busy:{takeover:C.busy,ret:w.busy,stop:E.busy,resume:D.busy,unarchive:N.busy},dialogs:R}}async function Ne(e){let t=await i(`/api/attention/${encodeURIComponent(e.id)}/dismiss`),n=t&&typeof t==`object`&&`id`in t?t:{...e,resolvedAt:new Date().toISOString()};return r.setState(t=>t.attention[e.id]?{attention:{...t.attention,[e.id]:n}}:{}),n}var Pe=[`needs_input`,`failed`,`ready_for_review`,`unsupported_interaction`,`host_unreachable`,`cache_expiring`];function Fe(e){let t=Object.fromEntries(Pe.map(e=>[e,[]]));for(let n of e)t[n.reason]?.push(n);return t}var Ie={dismiss:`Marks it as seen and moves it to Dismissed; it stays open, and a question keeps flagging its session.`,clear:`Resolves it now: the session loses this flag and the item moves to History.`,clearNeedsInput:`Removes this session's Needs input flag and moves it to History; a question Pi is still waiting on stays.`};function Le(e){return e===`dismissed`||e===`history`?e:`open`}function Re(e,t){return t===`history`?[]:e.filter(e=>t===`open`?!e.acknowledgedAt:!!e.acknowledgedAt)}function ze(e,t,n){return[e?.name,t?.title,n&&n.title!==t?.title?n.title:null].filter(Boolean).join(` · `)||`Switchyard`}export{X as _,Le as a,Me as c,Q as d,ke as f,le as g,Ce as h,Fe as i,je as l,De as m,Pe as n,Re as o,Oe as p,ze as r,Ne as s,Ie as t,Ae as u,he as v,oe as y};
|
|
4
|
-
//# sourceMappingURL=logic-D_vBBkcD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic-D_vBBkcD.js","names":["useState","_Fragment","useRef","useRef","useState","useMemo","useState","useState","useMemo","useRef","useCallback","_Fragment","useState","useMemo","_Fragment","apiDelete","isApiError","isInputAttentionReason","useSyncStore","apiPost","errorMessage","formatTime","Button","require_react","formatRelative","__toESM","require_jsx_runtime","ErrorState","useNavigate","cn","swipeResult","Sheet","lockAxis","Dialog","fullSwipeAt","ConfirmDialog","IconButton","velocity","issueLinkProblem","isBusy","issueUnlinkProblem","contextMeter","compareIssues","isLive","issueLookup","primarySession","runForSession","automationControl","hostLink","ArrowUp","UINodeRenderer","Field","useBreakpoint","StatusChip","TextInput","toast","TextArea","TextLink","headingSlug","Markdown","haptic","unlinkIssue","linkIssue","codeApi","import_react","UNSUPPORTED_COPY","DEFAULT_ACTIONS","findActions","node","c","found","isUnsupported","i","unsupportedView","offered","a","messageMode","runtime","import_jsx_runtime","hasInteractive","t","byLabel","by","InteractionCard","fromProps","upsert","s","busy","setBusy","error","setError","alreadyAnswered","setAlreadyAnswered","lastResponse","setLastResponse","acked","setAcked","interaction","pending","unsupported","sessionRuntime","composing","setComposing","message","setMessage","respond","response","res","onAnswered","other","sendMessage","text","bp","isDocumentPresentation","DocumentInteraction","r","readOnlyReason","mode","sticky","flush","dock","className","UnsupportedBody","actionId","keys","view","answered","onSend","onCancelMessage","onAction","splitPresentation","last","rest","scrollTo","calm","el","useOnScreen","visible","setVisible","ref","io","firstMarkdown","m","md","leadingHeading","documentSections","out","fence","line","useActiveSection","active","setActive","pinned","setPinned","key","ids","els","root","e","entries","release","shown","h","bodyRef","startRef","optionsRef","optionsVisible","sheet","setSheet","split","heading","sections","pinSection","options","changes","question","title","answer","onRespond","variant","tone","showBar","disabled","wrapBtn","jump","anchor","part","planAnchorId","planStart","barContent","mobile","o","moreSheet","disabledReason","reader","TONE","SETTLE","SKIP","closeOpenRow","SwipeRow","fg","drag","dragged","offset","setOffset","full","setFull","offsetRef","actions","leading","trailing","width","place","animate","to","closeRef","stableClose","run","action","w","side","row","isOpen","onDoc","onPointerDown","onPointerMove","d","dx","l","raw","rubberBand","reveal","isFull","onPointerUp","list","outer","contentClassName","useIssueLink","issues","linked","workspace","LinkIssueDialog","close","onClose","pick","issue","candidates","NO_ADAPTERS","useSessionLookup","absent","hydrated","sessionId","session","result","setResult","ctrl","useSessionContext","host","project","runs","tasks","adapters","taskId","useMutation","fnRef","fn","optsRef","opts","mounted","args","msg","success","useNow","now","setNow","ms","useElementWidth","setWidth","ro","entry","InfoRow","label","value","SessionInfoDialog","meter","stats","hostLabel","useSessionActions","ctx","navigate","dialog","setDialog","setTitle","link","attention","st","inputAttention","isPrimary","peers","x","takeover","ret","stop","resume","rename","cacheAlert","archive","unarchive","connected","archiveBlocked","dialogs","ok","control","dismissAttentionItem","path","scopeId","primary","item","next","ATTENTION_GROUPS","groupAttention","items","ATTENTION_ACTION_HELP","normalizeShow","v","visibleAttention","show","all","attentionMeta","task"],"sources":["../../src/components/intent/unsupported.ts","../../src/components/intent/InteractionCard.tsx","../../src/components/ui/SwipeRow.tsx","../../src/features/workboard/LinkIssue.tsx","../../src/features/code/hooks.ts","../../src/features/code/SessionInfoDialog.tsx","../../src/features/code/SessionActions.tsx","../../src/features/attention/logic.ts"],"sourcesContent":["import type { Interaction, UINode } from \"@switchyard/protocol\";\n\n/** What actually happened when an extension opened a terminal-only `ctx.ui.custom()` dialog. */\nexport const UNSUPPORTED_COPY =\n \"An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.\";\n\nexport interface UnsupportedAction {\n id: \"abort\" | \"message\";\n label: string;\n tone: \"primary\" | \"secondary\" | \"danger\";\n}\n\nconst DEFAULT_ACTIONS: UnsupportedAction[] = [\n { id: \"abort\", label: \"Stop the run\", tone: \"danger\" },\n { id: \"message\", label: \"Send a message to Pi\", tone: \"primary\" },\n];\n\nfunction findActions(node: UINode): Extract<UINode, { t: \"actions\" }> | null {\n if (node.t === \"actions\") return node;\n if (node.t === \"section\") {\n for (const c of node.children) {\n const found = findActions(c);\n if (found) return found;\n }\n }\n return null;\n}\n\nexport interface UnsupportedView {\n /** True until a person chose one of the alternatives. */\n answerable: boolean;\n actions: UnsupportedAction[];\n copy: string;\n}\n\nexport function isUnsupported(i: Interaction): boolean {\n return i.state === \"unsupported\" || i.source.kind === \"unsupported_custom\";\n}\n\n/** The alternatives the host offers for an unsupported dialog (stop the run, message). */\nexport function unsupportedView(i: Interaction): UnsupportedView {\n const node = findActions(i.presentation);\n const offered = (node?.actions ?? [])\n .filter(\n (a): a is typeof a & { id: \"abort\" | \"message\" } => a.id === \"abort\" || a.id === \"message\",\n )\n .map((a) => ({\n id: a.id,\n label: a.label,\n tone: (a.tone === \"default\"\n ? \"secondary\"\n : (a.tone ?? (a.id === \"abort\" ? \"danger\" : \"primary\"))) as UnsupportedAction[\"tone\"],\n }));\n return {\n answerable: i.state === \"unsupported\" && i.resolution === null,\n actions: offered.length > 0 ? offered : DEFAULT_ACTIONS,\n copy: UNSUPPORTED_COPY,\n };\n}\n\n/** A follow-up while Pi is still working queues behind the current turn. */\nexport function messageMode(runtime: string | undefined): \"prompt\" | \"followUp\" {\n return runtime === \"running\" || runtime === \"waiting_input\" ? \"followUp\" : \"prompt\";\n}\n","import type { Interaction, InteractionResponse, UINode } from \"@switchyard/protocol\";\nimport { ArrowUp } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useBreakpoint } from \"../../app/useBreakpoint\";\nimport { cn } from \"../../lib/cn\";\nimport { formatRelative } from \"../../lib/time\";\nimport { apiPost, errorMessage, isApiError } from \"../../sync/api\";\nimport { useSyncStore } from \"../../sync/store\";\nimport { Button } from \"../ui/Button\";\nimport { IconButton } from \"../ui/IconButton\";\nimport { Sheet } from \"../ui/Overlay\";\nimport { StatusChip } from \"../ui/StatusChip\";\nimport { ErrorState } from \"../ui/states\";\nimport { TextArea } from \"../ui/TextArea\";\nimport { TextLink } from \"../ui/TextLink\";\nimport { headingSlug, Markdown } from \"./Markdown\";\nimport { UINodeRenderer } from \"./UINodeRenderer\";\nimport { isUnsupported, messageMode, unsupportedView } from \"./unsupported\";\n\nexport interface InteractionCardProps {\n interaction: Interaction;\n /** Read-only session or host offline: show the question without answer controls. */\n readOnlyReason?: string | null;\n className?: string;\n /** Called after the coordinator acknowledged an answer. */\n onAnswered?: (interaction: Interaction) => void;\n /** DOM id (deep links scroll to it). */\n id?: string;\n /**\n * `card` (default) is the whole question. The session view splits it: `dock` is the answer\n * controls above the composer, `reader` a plan's text in the transcript.\n */\n mode?: \"card\" | \"dock\" | \"reader\";\n /** dock mode: number keys may answer a question (off where several questions share a page). */\n keys?: boolean;\n /** dock mode: DOM id of the plan's text in the transcript, for Plan start. */\n planAnchorId?: string;\n /** Stick the document header to the top of its scroller (false when the page scrolls). */\n sticky?: boolean;\n /** The page itself scrolls (no padded scroller): pin the header and bar flush. */\n flush?: boolean;\n}\n\nfunction hasInteractive(node: UINode): boolean {\n switch (node.t) {\n case \"form\":\n case \"confirm\":\n case \"actions\":\n return true;\n case \"list\":\n return node.items.some(hasInteractive);\n case \"section\":\n return node.children.some(hasInteractive);\n case \"tabs\":\n return node.tabs.some((t) => t.children.some(hasInteractive));\n default:\n return false;\n }\n}\n\nexport function byLabel(by: string): string {\n if (by === \"host\") return \"the host\";\n if (by === \"pi\") return \"Pi\";\n return \"a device\";\n}\n\n/**\n * A runtime interaction (extension dialog). Posts the answer with the\n * interaction revision and waits for the acknowledgement; there is no\n * optimistic resolution. A 409 shows \"Already answered: <summary>\".\n */\nexport function InteractionCard({\n interaction: fromProps,\n readOnlyReason,\n className,\n onAnswered,\n id,\n sticky,\n flush,\n mode = \"card\",\n keys = true,\n planAnchorId,\n}: InteractionCardProps) {\n const upsert = useSyncStore((s) => s.upsertInteraction);\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<unknown>(null);\n const [alreadyAnswered, setAlreadyAnswered] = useState<string | null>(null);\n const [lastResponse, setLastResponse] = useState<InteractionResponse | null>(null);\n // The acknowledged interaction from the answer/409 response, until the prop catches up.\n const [acked, setAcked] = useState<Interaction | null>(null);\n const interaction =\n acked && acked.id === fromProps.id && acked.revision > fromProps.revision ? acked : fromProps;\n\n const pending = interaction.state === \"pending\";\n const unsupported = isUnsupported(interaction);\n const sessionRuntime = useSyncStore((s) => s.sessions[interaction.sessionId]?.runtime);\n const [composing, setComposing] = useState(false);\n const [message, setMessage] = useState(\"\");\n\n const respond = async (response: InteractionResponse): Promise<boolean> => {\n setBusy(true);\n setError(null);\n setLastResponse(response);\n try {\n const res = await apiPost<{ status: string; interaction: Interaction }>(\n `/api/interactions/${encodeURIComponent(interaction.id)}/answer`,\n { revision: interaction.revision, response },\n );\n if (res?.interaction) {\n upsert(res.interaction);\n setAcked(res.interaction);\n onAnswered?.(res.interaction);\n }\n return true;\n } catch (e) {\n if (isApiError(e, \"already_answered\")) {\n const other = (e.details as { interaction?: Interaction } | undefined)?.interaction;\n if (other) {\n upsert(other);\n setAcked(other);\n }\n setAlreadyAnswered(other?.resolution?.summary ?? \"answered on another device\");\n } else {\n setError(e);\n }\n return false;\n } finally {\n setBusy(false);\n }\n };\n\n /** \"Send a message to Pi\": deliver the message first, then record the choice. */\n const sendMessage = async () => {\n const text = message.trim();\n if (!text) return;\n setBusy(true);\n setError(null);\n try {\n await apiPost(`/api/sessions/${encodeURIComponent(interaction.sessionId)}/prompt`, {\n text,\n mode: messageMode(sessionRuntime),\n });\n } catch (e) {\n setError(e);\n setBusy(false);\n return;\n }\n setBusy(false);\n if (await respond({ kind: \"action\", actionId: \"message\" })) {\n setComposing(false);\n setMessage(\"\");\n }\n };\n\n const bp = useBreakpoint();\n if (\n pending &&\n !alreadyAnswered &&\n !unsupported &&\n isDocumentPresentation(interaction.presentation)\n ) {\n return (\n <DocumentInteraction\n id={id}\n interaction={interaction}\n node={interaction.presentation}\n onRespond={(r) => void respond(r)}\n busy={busy}\n disabled={!!readOnlyReason}\n disabledReason={readOnlyReason ?? null}\n part={mode === \"reader\" ? \"reader\" : mode === \"dock\" ? \"answers\" : \"all\"}\n planAnchorId={planAnchorId}\n mobile={bp === \"mobile\"}\n sticky={sticky ?? true}\n flush={flush ?? false}\n className={className}\n />\n );\n }\n\n const dock = mode === \"dock\";\n return (\n <article\n id={id}\n aria-label={`Question: ${interaction.title}`}\n className={cn(\n dock ? \"flex min-w-0 flex-col gap-2\" : \"flex min-w-0 flex-col gap-3 border-l-2 py-1 pl-3\",\n !dock && (pending ? \"border-warning\" : \"border-border\"),\n className,\n )}\n >\n {dock ? (\n <h3 className=\"text-sm font-semibold break-words\">{interaction.title}</h3>\n ) : (\n <header className=\"flex min-w-0 flex-wrap items-start gap-2\">\n <h3 className=\"min-w-0 flex-1 text-sm font-semibold break-words\">{interaction.title}</h3>\n <StatusChip kind=\"interaction\" value={interaction.state} size=\"sm\" />\n </header>\n )}\n\n {alreadyAnswered && (\n <p role=\"status\" className=\"rounded-md bg-surface-2 px-3 py-2 text-sm\">\n Already answered: {alreadyAnswered}\n </p>\n )}\n\n {unsupported ? (\n <UnsupportedBody\n interaction={interaction}\n readOnlyReason={readOnlyReason ?? null}\n busy={busy}\n answered={alreadyAnswered !== null}\n composing={composing}\n message={message}\n setMessage={setMessage}\n onAction={(actionId) => {\n if (actionId === \"message\") setComposing(true);\n else void respond({ kind: \"action\", actionId });\n }}\n onSend={() => void sendMessage()}\n onCancelMessage={() => setComposing(false)}\n />\n ) : pending && !alreadyAnswered ? (\n <>\n {readOnlyReason && <p className=\"text-sm text-muted\">{readOnlyReason}</p>}\n <UINodeRenderer\n node={interaction.presentation}\n onRespond={(r) => void respond(r)}\n busy={busy}\n disabled={!!readOnlyReason}\n dock={\n dock\n ? { title: interaction.title, keys: keys && interaction.kind === \"question\" }\n : undefined\n }\n />\n {!readOnlyReason && !hasInteractive(interaction.presentation) && (\n <div>\n <Button busy={busy} onClick={() => void respond({ kind: \"cancel\" })}>\n Dismiss\n </Button>\n </div>\n )}\n {busy && (\n <p role=\"status\" className=\"text-sm text-muted\">\n Sending answer… waiting for the host to confirm.\n </p>\n )}\n </>\n ) : alreadyAnswered ? null : interaction.resolution ? (\n <p className=\"text-sm text-muted\">\n {interaction.state === \"resolved\" ? \"Answered\" : \"Closed\"} by{\" \"}\n {byLabel(interaction.resolution.by)} {formatRelative(interaction.resolution.at)}:{\" \"}\n <span className=\"text-text\">{interaction.resolution.summary}</span>\n </p>\n ) : (\n <p className=\"text-sm text-muted\">\n {interaction.state === \"expired\"\n ? \"This question expired before it was answered (Pi closed the dialog).\"\n : \"This question was canceled.\"}\n </p>\n )}\n\n {error !== null && (\n <ErrorState\n compact\n title=\"Answer not delivered\"\n error={errorMessage(error)}\n onRetry={lastResponse ? () => void respond(lastResponse) : undefined}\n />\n )}\n </article>\n );\n}\n\n/** A terminal-only dialog: what happened, and the alternatives the host offers until one is chosen. */\nfunction UnsupportedBody({\n interaction,\n readOnlyReason,\n busy,\n answered,\n composing,\n message,\n setMessage,\n onAction,\n onSend,\n onCancelMessage,\n}: {\n interaction: Interaction;\n readOnlyReason: string | null;\n busy: boolean;\n answered: boolean;\n composing: boolean;\n message: string;\n setMessage: (t: string) => void;\n onAction: (actionId: \"abort\" | \"message\") => void;\n onSend: () => void;\n onCancelMessage: () => void;\n}) {\n const view = unsupportedView(interaction);\n return (\n <div className=\"flex min-w-0 flex-col gap-2\">\n <p className=\"text-sm text-muted\">{view.copy}</p>\n {interaction.resolution ? (\n <p className=\"text-sm text-muted\">\n Chosen by {byLabel(interaction.resolution.by)} {formatRelative(interaction.resolution.at)}\n : <span className=\"text-text\">{interaction.resolution.summary}</span>\n </p>\n ) : !view.answerable || answered ? null : readOnlyReason ? (\n <p className=\"text-sm text-muted\">{readOnlyReason}</p>\n ) : composing ? (\n <div className=\"flex min-w-0 flex-col gap-2\">\n <TextArea\n aria-label=\"Message for Pi\"\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n rows={3}\n autoFocus\n placeholder=\"Tell Pi what to do instead\"\n />\n <div className=\"flex flex-wrap gap-2\">\n <Button variant=\"primary\" busy={busy} disabled={!message.trim()} onClick={onSend}>\n Send message\n </Button>\n <Button disabled={busy} onClick={onCancelMessage}>\n Cancel\n </Button>\n </div>\n </div>\n ) : (\n <div className=\"flex flex-wrap gap-2\">\n {view.actions.map((a) => (\n <Button\n key={a.id}\n variant={a.tone}\n busy={busy && a.id === \"abort\"}\n disabled={busy}\n onClick={() => onAction(a.id)}\n >\n {a.label}\n </Button>\n ))}\n </div>\n )}\n </div>\n );\n}\n\n/** A content section that ends in a row of actions (a plan with its options), if `node` is one. */\nexport function splitPresentation(node: UINode): { body: UINode; actions: UINode } | null {\n if (node.t !== \"section\" || node.children.length < 2) return null;\n const last = node.children[node.children.length - 1];\n if (last?.t !== \"actions\") return null;\n const rest = node.children.slice(0, -1);\n if (rest.some(hasInteractive)) return null;\n return { body: { ...node, children: rest }, actions: last };\n}\n\nfunction scrollTo(el: HTMLElement | null, block: \"start\" | \"center\") {\n const calm = window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;\n el?.scrollIntoView({ behavior: calm ? \"auto\" : \"smooth\", block });\n}\n\n/** True while `el` is (at least partly) on screen; assumed visible without IntersectionObserver. */\nfunction useOnScreen(ref: React.RefObject<HTMLElement | null>): boolean {\n const [visible, setVisible] = useState(true);\n useEffect(() => {\n const el = ref.current;\n if (!el || typeof IntersectionObserver === \"undefined\") return;\n const io = new IntersectionObserver(([e]) => setVisible(!!e?.isIntersecting));\n io.observe(el);\n return () => io.disconnect();\n }, [ref]);\n return visible;\n}\n\nfunction firstMarkdown(node: UINode): string | null {\n if (node.t === \"markdown\") return node.text;\n if (node.t === \"section\") {\n for (const c of node.children) {\n const m = firstMarkdown(c);\n if (m !== null) return m;\n }\n }\n return null;\n}\n\n/** A long document with trailing options (a plan awaiting approval). */\nexport function isDocumentPresentation(node: UINode): boolean {\n if (!splitPresentation(node)) return false;\n const md = firstMarkdown(node);\n return md !== null && (md.length >= 400 || md.split(\"\\n\").length >= 12);\n}\n\n/** The first heading of a document, its text and the markdown without it. */\nexport function leadingHeading(md: string): { title: string | null; rest: string } {\n const m = /^\\s*#{1,6}\\s+(.+?)\\s*(?:\\n+|$)/.exec(md);\n return m?.[1] ? { title: m[1], rest: md.slice(m[0].length) } : { title: null, rest: md };\n}\n\n/** `##` headings of a document, for the outline. */\nexport function documentSections(md: string): { text: string; id: string }[] {\n const out: { text: string; id: string }[] = [];\n let fence = false;\n for (const line of md.split(\"\\n\")) {\n if (/^\\s*```/.test(line)) fence = !fence;\n const m = !fence ? /^##\\s+(.+?)\\s*$/.exec(line) : null;\n if (m?.[1]) out.push({ text: m[1], id: headingSlug(m[1]) });\n }\n return out;\n}\n\n/** Id of the outline entry whose heading is the last one scrolled past the top. */\nfunction useActiveSection(ids: string[], root: React.RefObject<HTMLElement | null>) {\n const [active, setActive] = useState<string | null>(null);\n const [pinned, setPinned] = useState<string | null>(null);\n const key = ids.join(\"|\");\n // biome-ignore lint/correctness/useExhaustiveDependencies: `key` stands for `ids`\n useEffect(() => {\n if (typeof IntersectionObserver === \"undefined\" || !ids.length) return;\n const els = ids\n .map((i) => root.current?.querySelector<HTMLElement>(`#${CSS.escape(i)}`))\n .filter((e): e is HTMLElement => !!e);\n const io = new IntersectionObserver(\n (entries) => {\n for (const e of entries) if (e.isIntersecting) setActive(e.target.id);\n },\n { rootMargin: \"-56px 0px -70% 0px\" },\n );\n for (const e of els) io.observe(e);\n // A click on an entry near the end cannot scroll it to the top: it stays selected until the\n // reader scrolls again.\n const release = () => setPinned(null);\n window.addEventListener(\"wheel\", release, { passive: true });\n window.addEventListener(\"touchmove\", release, { passive: true });\n window.addEventListener(\"keydown\", release);\n return () => {\n io.disconnect();\n window.removeEventListener(\"wheel\", release);\n window.removeEventListener(\"touchmove\", release);\n window.removeEventListener(\"keydown\", release);\n };\n }, [key, root]);\n const shown = pinned ?? active;\n // Mark the heading in the text that the outline highlights.\n // biome-ignore lint/correctness/useExhaustiveDependencies: `key` stands for `ids`\n useEffect(() => {\n const r = root.current;\n if (!r) return;\n for (const h of r.querySelectorAll<HTMLElement>(\"h2[data-active]\")) delete h.dataset.active;\n if (shown) {\n const el = r.querySelector<HTMLElement>(`#${CSS.escape(shown)}`);\n if (el) el.dataset.active = \"true\";\n }\n }, [shown, key, root]);\n return [shown, setPinned] as const;\n}\n\n/**\n * Document question (a plan awaiting approval): no card of its own. The plan's own heading titles\n * it, the question labels the answers, revisions come first. Phone: compact header, prose, a bar\n * with the answers pinned to the bottom. Desktop: a section outline beside prose at a readable\n * measure, and a wrapping bar of answers. The bar hides while the inline options are on screen.\n *\n * `part` splits it for the session view: `reader` is the text alone (in the transcript) and\n * `answers` the question with its options (in the request dock).\n */\nfunction DocumentInteraction({\n id,\n interaction,\n node,\n onRespond,\n busy,\n disabled,\n disabledReason,\n part,\n planAnchorId,\n mobile,\n sticky,\n flush,\n className,\n}: {\n id?: string;\n interaction: Interaction;\n node: UINode;\n onRespond: (r: InteractionResponse) => void;\n busy: boolean;\n disabled: boolean;\n disabledReason: string | null;\n part: \"all\" | \"reader\" | \"answers\";\n planAnchorId?: string;\n mobile: boolean;\n sticky: boolean;\n flush: boolean;\n className?: string;\n}) {\n const bodyRef = useRef<HTMLDivElement>(null);\n const startRef = useRef<HTMLDivElement>(null);\n const optionsRef = useRef<HTMLElement>(null);\n const optionsVisible = useOnScreen(optionsRef);\n const [sheet, setSheet] = useState(false);\n const split = splitPresentation(node);\n const md =\n split?.body.t === \"section\"\n ? (split.body.children.find((c) => c.t === \"markdown\") as\n | Extract<UINode, { t: \"markdown\" }>\n | undefined)\n : undefined;\n const { title: heading, rest } = leadingHeading(md?.text ?? \"\");\n const sections = documentSections(rest);\n const [active, pinSection] = useActiveSection(\n sections.map((s) => s.id),\n bodyRef,\n );\n if (split?.body.t !== \"section\") return null;\n const options = (split.actions as Extract<UINode, { t: \"actions\" }>).actions;\n const changes = split.body.children.find((c) => c.t === \"section\");\n const question = interaction.title;\n const title = heading ?? question;\n const answer = (actionId: string) => {\n setSheet(false);\n onRespond({ kind: \"action\", actionId });\n };\n const variant = (i: number, tone?: string) =>\n i === 0 || tone === \"primary\" ? \"primary\" : tone === \"danger\" ? \"danger\" : \"secondary\";\n const showBar = !disabled && !optionsVisible;\n const wrapBtn = \"h-auto! min-h-9 min-w-0 py-1.5 text-left leading-tight whitespace-normal!\";\n const jump = (el: HTMLElement | null) => scrollTo(el, \"start\");\n // The dock's answers have no text of their own: Plan start goes to the reader in the transcript.\n const anchor = () =>\n part === \"answers\"\n ? planAnchorId\n ? document.getElementById(planAnchorId)\n : null\n : startRef.current;\n const planStart = part !== \"answers\" || planAnchorId !== undefined;\n const barContent = mobile ? (\n <>\n {planStart && (\n <IconButton\n label=\"Plan start\"\n icon={<ArrowUp className=\"size-4\" />}\n variant=\"secondary\"\n onClick={() => jump(anchor())}\n />\n )}\n {options.length > 2 ? (\n <>\n <Button\n variant=\"primary\"\n disabled={busy}\n className={cn(wrapBtn, \"flex-1\")}\n onClick={() => answer(options[0]!.id)}\n >\n {options[0]!.label}\n </Button>\n <Button variant=\"secondary\" onClick={() => setSheet(true)}>\n More ({options.length - 1})\n </Button>\n </>\n ) : (\n options.map((o, i) => (\n <Button\n key={o.id}\n variant={variant(i, o.tone)}\n disabled={busy}\n className={cn(wrapBtn, \"flex-1\")}\n onClick={() => answer(o.id)}\n >\n {o.label}\n </Button>\n ))\n )}\n </>\n ) : (\n <>\n <span className=\"max-w-[16rem] min-w-0 shrink truncate text-sm font-medium\" title={question}>\n {question}\n </span>\n <div className=\"grid min-w-0 flex-1 grid-cols-[repeat(auto-fit,minmax(11rem,1fr))] gap-2\">\n {options.map((o, i) => (\n <Button\n key={o.id}\n variant={variant(i, o.tone)}\n disabled={busy}\n className={cn(wrapBtn, \"w-full md:text-center\")}\n onClick={() => answer(o.id)}\n >\n {o.label}\n </Button>\n ))}\n </div>\n {planStart && (\n <IconButton\n label=\"Plan start\"\n icon={<ArrowUp className=\"size-4\" />}\n variant=\"secondary\"\n size=\"sm\"\n onClick={() => jump(anchor())}\n />\n )}\n </>\n );\n const moreSheet = (\n <Sheet open={sheet} onClose={() => setSheet(false)} title={question}>\n <div className=\"flex flex-col gap-2\">\n {options.map((o, i) => (\n <Button\n key={o.id}\n block\n variant={variant(i, o.tone)}\n disabled={busy}\n className={wrapBtn}\n onClick={() => answer(o.id)}\n >\n {o.label}\n </Button>\n ))}\n </div>\n </Sheet>\n );\n if (part === \"answers\") {\n return (\n <article\n aria-label={`Question: ${question}`}\n data-testid=\"plan-answers\"\n className={cn(\"flex min-w-0 flex-col gap-2\", className)}\n >\n {mobile && <p className=\"text-sm font-medium\">{question}</p>}\n {disabledReason ? (\n <p className=\"text-sm text-muted\">{disabledReason}</p>\n ) : (\n <div data-testid=\"answer-bar\" className=\"flex min-w-0 items-center gap-2 md:gap-3\">\n {barContent}\n </div>\n )}\n {moreSheet}\n </article>\n );\n }\n const reader = part === \"reader\";\n return (\n <article\n id={id}\n data-testid=\"document-interaction\"\n aria-label={`Question: ${question}`}\n className={cn(\n \"w-full min-w-0 self-stretch border-t border-border\",\n\n className,\n )}\n >\n <header\n className={cn(\n \"z-10 flex min-w-0 items-center gap-2 border-b border-border bg-bg px-4 py-2 md:px-6\",\n sticky && (flush ? \"md:sticky md:top-0\" : \"max-md:static md:sticky md:-top-3\"),\n )}\n >\n <h3 className=\"min-w-0 flex-1 truncate text-[15px] leading-snug font-semibold md:text-sm\">\n {title}\n </h3>\n {mobile && !reader && (\n <StatusChip\n kind=\"interaction\"\n value={interaction.state}\n size=\"sm\"\n className=\"[&>span]:sr-only\"\n />\n )}\n {!reader && !disabled && !optionsVisible && (\n <TextLink\n size=\"xs\"\n className=\"shrink-0\"\n onClick={() => scrollTo(optionsRef.current, \"center\")}\n >\n Jump to options ↓\n </TextLink>\n )}\n </header>\n {changes && (\n <aside className=\"mx-4 mt-3 rounded-md bg-warning-soft px-3 py-2 text-sm md:mx-6\">\n <UINodeRenderer node={changes} />\n </aside>\n )}\n <div className=\"px-4 py-4 md:grid md:grid-cols-[13rem_minmax(0,1fr)] 2xl:grid-cols-[15rem_minmax(0,1fr)] md:gap-8 md:px-6\">\n {sections.length > 0 && (\n <nav aria-label=\"Plan sections\" className=\"hidden md:block\">\n <ol className=\"sticky top-16 flex flex-col gap-0.5 border-l border-border text-sm\">\n <li>\n <button\n type=\"button\"\n className=\"-ml-px block w-full truncate border-l-2 border-transparent py-1 pl-3 text-left text-muted hover:text-text\"\n onClick={() => jump(startRef.current)}\n >\n Start\n </button>\n </li>\n {sections.map((s) => (\n <li key={s.id}>\n <button\n type=\"button\"\n aria-current={active === s.id}\n className=\"-ml-px block w-full truncate border-l-2 border-transparent py-1 pl-3 text-left text-muted hover:text-text aria-[current=true]:border-accent aria-[current=true]:text-text\"\n onClick={() => {\n pinSection(s.id);\n jump(\n bodyRef.current?.querySelector<HTMLElement>(`#${CSS.escape(s.id)}`) ?? null,\n );\n }}\n >\n {s.text}\n </button>\n </li>\n ))}\n </ol>\n </nav>\n )}\n <div ref={startRef} className=\"min-w-0 scroll-mt-14\">\n <div\n ref={bodyRef}\n className=\"sy-prose-compact max-w-[80ch] min-w-0 2xl:max-w-[100ch] min-[1800px]:text-base [&_h2]:scroll-mt-14\"\n >\n <Markdown text={rest} headingIds className=\"text-inherit\" />\n </div>\n </div>\n </div>\n {!reader && (\n <section\n ref={optionsRef}\n data-testid=\"plan-options\"\n aria-label={question}\n className=\"border-t border-border px-4 py-3 md:px-6\"\n >\n <p className=\"mb-2 text-sm font-medium\">{question}</p>\n {!disabled && (\n <div className=\"flex min-w-0 flex-col gap-2 md:flex-row md:flex-wrap\">\n {options.map((o, i) => (\n <Button\n key={o.id}\n variant={variant(i, o.tone)}\n size=\"md\"\n disabled={busy}\n className={cn(wrapBtn, \"md:text-center\")}\n onClick={() => answer(o.id)}\n >\n {o.label}\n </Button>\n ))}\n </div>\n )}\n <TextLink\n size=\"xs\"\n className=\"mt-2\"\n icon={<ArrowUp aria-hidden className=\"size-3.5\" />}\n onClick={() => jump(startRef.current)}\n >\n Back to the plan start\n </TextLink>\n </section>\n )}\n {!reader && showBar && (\n <div\n data-testid=\"answer-bar\"\n className={cn(\n \"z-10 flex min-w-0 items-center gap-2 border-t border-border bg-bg px-4 py-2 md:gap-3 md:px-6\",\n sticky && !flush ? \"sticky -bottom-3\" : \"sticky bottom-0\",\n )}\n >\n {barContent}\n </div>\n )}\n {!reader && moreSheet}\n </article>\n );\n}\n","import { type ReactNode, useEffect, useRef, useState } from \"react\";\nimport { cn } from \"../../lib/cn\";\nimport {\n fullSwipeAt,\n lockAxis,\n REVEAL,\n rubberBand,\n type SwipeSide,\n swipeResult,\n velocity,\n} from \"../../lib/gestures\";\nimport { haptic } from \"../../lib/haptics\";\n\nexport interface SwipeAction {\n id: string;\n label: string;\n icon: ReactNode;\n tone: \"red\" | \"orange\" | \"blue\" | \"gray\" | \"green\";\n onAction: () => unknown;\n /** The row leaves the list when this succeeds: it slides out, and back if the action fails. */\n removes?: boolean;\n}\n\n/** Saturated, theme-independent colours, as in native swipe actions. */\nconst TONE: Record<SwipeAction[\"tone\"], string> = {\n red: \"bg-[#e5484d] text-white\",\n orange: \"bg-[#f76b15] text-white\",\n blue: \"bg-[#0090ff] text-white\",\n gray: \"bg-[#6e7681] text-white\",\n green: \"bg-[#30a46c] text-white\",\n};\n\nconst SETTLE = \"transform 260ms cubic-bezier(0.2, 0.9, 0.25, 1)\";\nconst SKIP = \"input, textarea, select, [contenteditable], [data-no-swipe]\";\n\nlet closeOpenRow: (() => void) | null = null;\n\ninterface Drag {\n id: number;\n x: number;\n y: number;\n axis: \"x\" | \"y\" | null;\n start: number;\n raw: number;\n full: boolean;\n samples: { t: number; v: number }[];\n}\n\n/**\n * A row that reveals actions when dragged sideways (touch and pen only), like a native list:\n * `leading` actions sit under the left edge, `trailing` under the right. The first action of a\n * side is the outermost one; a long swipe runs it, a shorter one leaves the buttons open.\n */\nexport function SwipeRow({\n leading = [],\n trailing = [],\n disabled,\n children,\n className,\n contentClassName,\n}: {\n leading?: SwipeAction[];\n trailing?: SwipeAction[];\n disabled?: boolean;\n children: ReactNode;\n className?: string;\n contentClassName?: string;\n}) {\n const fg = useRef<HTMLDivElement>(null);\n const drag = useRef<Drag | null>(null);\n const dragged = useRef(false);\n // The row's offset drives the action layer; the foreground moves through its style directly.\n const [offset, setOffset] = useState(0);\n const [full, setFull] = useState(false);\n const offsetRef = useRef(0);\n const actions = useRef({ leading, trailing });\n actions.current = { leading, trailing };\n const active = !disabled && (leading.length > 0 || trailing.length > 0);\n\n const width = () => fg.current?.offsetWidth || 320;\n const place = (to: number, animate: boolean) => {\n const el = fg.current;\n if (el) {\n el.style.transition = animate ? SETTLE : \"none\";\n el.style.transform = to === 0 ? \"\" : `translateX(${to}px)`;\n }\n offsetRef.current = to;\n setOffset(to);\n };\n const closeRef = useRef(() => {});\n closeRef.current = () => {\n place(0, true);\n setFull(false);\n if (closeOpenRow === stableClose) closeOpenRow = null;\n };\n const [stableClose] = useState(() => () => closeRef.current());\n\n const run = async (action: SwipeAction, side: SwipeSide) => {\n haptic();\n if (action.removes) {\n const w = width();\n setFull(true);\n place(side === \"leading\" ? w : -w, true);\n try {\n await action.onAction();\n } catch {\n closeRef.current();\n return;\n }\n // Close the gap it leaves; the list drops the row when the change arrives.\n const row = fg.current?.parentElement;\n if (row && !window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches) {\n row.animate?.([{ height: `${row.offsetHeight}px` }, { height: \"0px\" }], {\n duration: 220,\n easing: \"cubic-bezier(0.2, 0.8, 0.2, 1)\",\n fill: \"forwards\",\n });\n }\n return;\n }\n closeRef.current();\n await action.onAction();\n };\n\n // While a row is open, a touch anywhere else closes it.\n const isOpen = offset !== 0;\n useEffect(() => {\n if (!isOpen) return;\n const onDoc = (e: PointerEvent) => {\n if (fg.current?.parentElement?.contains(e.target as Node)) return;\n if (!drag.current) closeRef.current();\n };\n document.addEventListener(\"pointerdown\", onDoc, true);\n return () => document.removeEventListener(\"pointerdown\", onDoc, true);\n }, [isOpen]);\n useEffect(\n () => () => {\n if (closeOpenRow === stableClose) closeOpenRow = null;\n },\n [stableClose],\n );\n\n const onPointerDown = (e: React.PointerEvent) => {\n if (!active || !e.isPrimary || (e.pointerType !== \"touch\" && e.pointerType !== \"pen\")) return;\n if ((e.target as HTMLElement).closest(SKIP)) return;\n dragged.current = false;\n drag.current = {\n id: e.pointerId,\n x: e.clientX,\n y: e.clientY,\n axis: null,\n start: offsetRef.current,\n raw: offsetRef.current,\n full: false,\n samples: [],\n };\n };\n const onPointerMove = (e: React.PointerEvent) => {\n const d = drag.current;\n if (!d || e.pointerId !== d.id) return;\n const dx = e.clientX - d.x;\n if (d.axis === null) {\n d.axis = lockAxis(dx, e.clientY - d.y);\n if (d.axis === null) return;\n if (d.axis === \"y\") {\n drag.current = null;\n return;\n }\n dragged.current = true;\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n if (closeOpenRow && closeOpenRow !== stableClose) closeOpenRow();\n }\n const { leading: l, trailing: t } = actions.current;\n const w = width();\n let raw = d.start + dx;\n // A side without actions resists, like the end of a list.\n if (raw > 0 && l.length === 0) raw = rubberBand(raw, w) * 0.15;\n if (raw < 0 && t.length === 0) raw = rubberBand(raw, w) * 0.15;\n d.raw = raw;\n d.samples.push({ t: e.timeStamp, v: raw });\n d.samples = d.samples.slice(-12);\n const reveal = (raw > 0 ? l.length : t.length) * REVEAL;\n const isFull = reveal > 0 && Math.abs(raw) >= fullSwipeAt(w, reveal);\n if (isFull !== d.full) {\n d.full = isFull;\n setFull(isFull);\n haptic();\n }\n place(raw, false);\n };\n const onPointerUp = (e: React.PointerEvent) => {\n const d = drag.current;\n drag.current = null;\n if (d?.axis !== \"x\") return;\n const { leading: l, trailing: t } = actions.current;\n if (e.type === \"pointercancel\") return closeRef.current();\n const res = swipeResult(d.raw, velocity(d.samples), {\n width: width(),\n reveal: { leading: l.length * REVEAL, trailing: t.length * REVEAL },\n fullSwipe: { leading: true, trailing: true },\n });\n if (res.kind === \"close\") return closeRef.current();\n const list = res.side === \"leading\" ? l : t;\n const outer = list[0];\n if (!outer) return closeRef.current();\n if (res.kind === \"commit\") return void run(outer, res.side);\n setFull(false);\n place((res.side === \"leading\" ? 1 : -1) * list.length * REVEAL, true);\n closeOpenRow = stableClose;\n };\n\n const side: SwipeSide = offset > 0 ? \"leading\" : \"trailing\";\n const list = offset > 0 ? leading : trailing;\n // Outermost first: on the right the first action is rightmost, so lay them out reversed.\n const shown = side === \"trailing\" ? [...list].reverse() : list;\n return (\n <div className={cn(\"relative overflow-hidden\", className)} data-swipe-row>\n {offset !== 0 && list.length > 0 && (\n <div\n aria-hidden\n className={cn(\"absolute inset-y-0 flex\", side === \"leading\" ? \"left-0\" : \"right-0\")}\n style={{ width: Math.abs(offset) }}\n >\n {shown.map((a) => {\n const outer = a === list[0];\n return (\n <button\n key={a.id}\n type=\"button\"\n tabIndex={-1}\n data-swipe-action={a.id}\n onClick={() => void run(a, side)}\n style={{ flexGrow: full ? (outer ? 1 : 0) : 1, flexBasis: 0 }}\n className={cn(\n \"flex min-w-0 flex-col items-center justify-center gap-1 overflow-hidden text-xs font-semibold whitespace-nowrap transition-[flex-grow] duration-200\",\n TONE[a.tone],\n full && outer && (side === \"leading\" ? \"items-start pl-6\" : \"items-end pr-6\"),\n )}\n >\n {a.icon}\n {a.label}\n </button>\n );\n })}\n </div>\n )}\n <div\n ref={fg}\n className={cn(\"relative touch-pan-y bg-surface\", contentClassName)}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onClickCapture={(e) => {\n if (dragged.current) {\n dragged.current = false;\n e.preventDefault();\n e.stopPropagation();\n } else if (offsetRef.current !== 0) {\n e.preventDefault();\n e.stopPropagation();\n closeRef.current();\n }\n }}\n >\n {children}\n </div>\n </div>\n );\n}\n","import {\n compareIssues,\n issueLinkProblem,\n issueLookup,\n issueUnlinkProblem,\n type TrackedIssue,\n type Workspace,\n} from \"@switchyard/protocol\";\nimport { useMemo, useState } from \"react\";\nimport { Button } from \"../../components/ui/Button\";\nimport { Dialog } from \"../../components/ui/Overlay\";\nimport { ErrorState } from \"../../components/ui/states\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { errorMessage } from \"../../sync/api\";\nimport { useSyncStore } from \"../../sync/store\";\nimport { linkIssue } from \"./api\";\n\n/** A workspace's issue, the issues it could be linked to, and whether its link can be undone here. */\nexport function useIssueLink(workspace: Workspace | null | undefined): {\n linked: TrackedIssue | null;\n candidates: TrackedIssue[];\n canUnlink: boolean;\n} {\n const issues = useSyncStore((s) => s.issues);\n return useMemo(() => {\n const list = Object.values(issues);\n const linked = workspace ? issueLookup(list)(workspace) : null;\n const candidates =\n workspace && !linked\n ? list.filter((i) => issueLinkProblem(i, workspace, list) === null).sort(compareIssues)\n : [];\n return { linked, candidates, canUnlink: !!linked && issueUnlinkProblem(linked) === null };\n }, [issues, workspace]);\n}\n\n/** Pick a not-started issue to link a worktree's branch to. */\nexport function LinkIssueDialog({\n open,\n onClose,\n workspace,\n candidates,\n}: {\n open: boolean;\n onClose: () => void;\n workspace: Workspace;\n candidates: TrackedIssue[];\n}) {\n const [busy, setBusy] = useState<string | null>(null);\n const [error, setError] = useState<unknown>(null);\n const close = () => {\n setError(null);\n onClose();\n };\n const pick = async (issue: TrackedIssue) => {\n if (busy) return;\n setBusy(issue.id);\n setError(null);\n try {\n await linkIssue(issue.id, workspace.id);\n toast.success(`Linked to #${issue.number}`);\n close();\n } catch (e) {\n setError(e);\n } finally {\n setBusy(null);\n }\n };\n return (\n <Dialog\n open={open}\n onClose={close}\n title=\"Link to issue\"\n description={`Link ${workspace.branch} to an issue that has no branch yet. Its sessions then stay in the issue's scope.`}\n footer={<Button onClick={close}>Cancel</Button>}\n >\n <div className=\"flex min-w-0 flex-col gap-2\">\n {error !== null && (\n <ErrorState compact title=\"Could not link\" error={errorMessage(error)} />\n )}\n {candidates.length === 0 && (\n <p className=\"text-sm text-muted\">No issue without a branch in this project.</p>\n )}\n <ul className=\"flex min-w-0 flex-col gap-1\">\n {candidates.map((i) => (\n <li key={i.id} className=\"min-w-0\">\n <button\n type=\"button\"\n disabled={!!busy}\n aria-busy={busy === i.id}\n onClick={() => void pick(i)}\n className=\"tap flex w-full min-w-0 flex-col rounded-md px-2 py-1.5 text-left hover:bg-surface-2 disabled:opacity-55\"\n >\n <span className=\"truncate text-sm\">\n #{i.number} {i.title}\n </span>\n <span className=\"truncate text-xs text-muted\">\n {i.repository}\n {i.board?.priority ? ` · ${i.board.priority.name}` : \"\"}\n </span>\n </button>\n </li>\n ))}\n </ul>\n </div>\n </Dialog>\n );\n}\n","import type {\n AdapterInfo,\n Host,\n Project,\n Run,\n Session,\n Task,\n Workspace,\n} from \"@switchyard/protocol\";\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { errorMessage, isApiError } from \"../../sync/api\";\nimport { useSyncStore } from \"../../sync/store\";\nimport { codeApi } from \"./api\";\nimport {\n type AutomationControl,\n automationControl,\n type HostLink,\n hostLink,\n runForSession,\n} from \"./model\";\n\nexport interface SessionContext {\n session: Session;\n host: Host | undefined;\n hostName: string;\n link: HostLink;\n project: Project | undefined;\n workspace: Workspace | undefined;\n run: Run | null;\n task: Task | undefined;\n control: AutomationControl;\n adapters: AdapterInfo[];\n}\n\nconst NO_ADAPTERS: AdapterInfo[] = [];\n\nexport type SessionLookup =\n | { state: \"idle\" }\n | { state: \"loading\" }\n | { state: \"missing\" }\n | { state: \"error\"; error: string };\n\n/**\n * A session the snapshot leaves out (archived) is fetched by id and kept in the sync store, so\n * its URL still opens after a reload and live events (Unarchive) update it.\n */\nexport function useSessionLookup(\n sessionId: string | null,\n session: Session | undefined,\n hydrated: boolean,\n): SessionLookup {\n const absent = hydrated && !!sessionId && !session;\n const [result, setResult] = useState<{ id: string; lookup: SessionLookup } | null>(null);\n useEffect(() => {\n if (!absent || !sessionId) return;\n const ctrl = new AbortController();\n setResult({ id: sessionId, lookup: { state: \"loading\" } });\n codeApi.get(sessionId, ctrl.signal).then(\n (s) => {\n useSyncStore.getState().upsertSessionIfMissing(s);\n setResult(null);\n },\n (e) => {\n if (ctrl.signal.aborted) return;\n setResult({\n id: sessionId,\n lookup: isApiError(e, \"not_found\")\n ? { state: \"missing\" }\n : { state: \"error\", error: errorMessage(e) },\n });\n },\n );\n return () => ctrl.abort();\n }, [absent, sessionId]);\n if (!absent) return { state: \"idle\" };\n return result?.id === sessionId ? result.lookup : { state: \"loading\" };\n}\n\n/** Everything the session views need about one session, from the store. */\nexport function useSessionContext(session: Session | undefined): SessionContext | null {\n const host = useSyncStore((s) => (session ? s.hosts[session.hostId] : undefined));\n const project = useSyncStore((s) =>\n session?.projectId ? s.projects[session.projectId] : undefined,\n );\n const workspace = useSyncStore((s) =>\n session?.workspaceId ? s.workspaces[session.workspaceId] : undefined,\n );\n const runs = useSyncStore((s) => s.runs);\n const tasks = useSyncStore((s) => s.tasks);\n const adapters = useSyncStore((s) =>\n session ? (s.adapters[session.hostId] ?? NO_ADAPTERS) : NO_ADAPTERS,\n );\n return useMemo(() => {\n if (!session) return null;\n const run = runForSession(runs, session);\n const taskId = session.taskId ?? run?.taskId ?? null;\n return {\n session,\n host,\n hostName: host?.name ?? \"Unknown host\",\n link: hostLink(host, session),\n project,\n workspace,\n run,\n task: taskId ? tasks[taskId] : undefined,\n control: automationControl(run),\n adapters,\n };\n }, [session, host, project, workspace, runs, tasks, adapters]);\n}\n\nexport interface Mutation<A extends unknown[]> {\n run: (...args: A) => Promise<boolean>;\n busy: boolean;\n error: unknown;\n reset: () => void;\n}\n\n/**\n * Wrap a REST mutation: busy state, error kept for inline display (with\n * retry), and a success toast only after the coordinator acknowledged.\n */\nexport function useMutation<A extends unknown[], R>(\n fn: (...args: A) => Promise<R>,\n opts: { success?: string | ((r: R) => string | null); errorToast?: boolean } = {},\n): Mutation<A> {\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<unknown>(null);\n const fnRef = useRef(fn);\n fnRef.current = fn;\n const optsRef = useRef(opts);\n optsRef.current = opts;\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const run = useCallback(async (...args: A) => {\n setBusy(true);\n setError(null);\n try {\n const r = await fnRef.current(...args);\n const { success } = optsRef.current;\n const msg = typeof success === \"function\" ? success(r) : success;\n if (msg) toast.success(msg);\n return true;\n } catch (e) {\n if (mounted.current) setError(e);\n if (optsRef.current.errorToast) toast.error(errorMessage(e));\n return false;\n } finally {\n if (mounted.current) setBusy(false);\n }\n }, []);\n const reset = useCallback(() => setError(null), []);\n return { run, busy, error, reset };\n}\n\n/** Re-render every `ms` while `active` (elapsed timers). */\nexport function useNow(active: boolean, ms = 1000): number {\n const [now, setNow] = useState(() => Date.now());\n useEffect(() => {\n if (!active) return;\n setNow(Date.now());\n const t = setInterval(() => setNow(Date.now()), ms);\n return () => clearInterval(t);\n }, [active, ms]);\n return now;\n}\n\n/** Width of an element, kept current with a ResizeObserver. */\nexport function useElementWidth<T extends HTMLElement>() {\n const ref = useRef<T>(null);\n const [width, setWidth] = useState(0);\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n setWidth(el.clientWidth);\n const ro = new ResizeObserver(([entry]) => {\n if (entry) setWidth(entry.contentRect.width);\n });\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n return [ref, width] as const;\n}\n","import type { Session } from \"@switchyard/protocol\";\nimport { Dialog } from \"../../components/ui/Overlay\";\nimport { formatTime } from \"../../lib/time\";\nimport { contextMeter } from \"./model\";\n\nfunction InfoRow({ label, value }: { label: string; value: string }) {\n return (\n <>\n <dt className=\"text-muted\">{label}</dt>\n <dd className=\"min-w-0 font-mono text-xs break-all\">{value}</dd>\n </>\n );\n}\n\nexport interface SessionInfoDialogProps {\n session: Session;\n hostLabel: string;\n open: boolean;\n onClose: () => void;\n}\n\n/** Session ids, Pi session file, tokens, cost and context. */\nexport function SessionInfoDialog({ session, hostLabel, open, onClose }: SessionInfoDialogProps) {\n const meter = contextMeter(session);\n const stats = session.stats;\n return (\n <Dialog open={open} onClose={onClose} title=\"Session info\">\n <dl className=\"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-2 text-sm\">\n <InfoRow label=\"Switchyard session\" value={session.id} />\n <InfoRow label=\"Pi session id\" value={session.nativeHandle?.sessionId ?? \"Not started\"} />\n <InfoRow label=\"Session file\" value={session.nativeHandle?.sessionFile ?? \"None yet\"} />\n <InfoRow label=\"Host\" value={hostLabel} />\n <InfoRow label=\"Working directory\" value={session.cwd} />\n <InfoRow label=\"Origin\" value={session.provenance} />\n <InfoRow label=\"Profile\" value={session.profileSnapshot.name} />\n <InfoRow label=\"Created\" value={formatTime(session.createdAt)} />\n {stats?.tokens != null && (\n <InfoRow label=\"Tokens\" value={stats.tokens.toLocaleString(\"en-US\")} />\n )}\n {stats?.costUsd != null && <InfoRow label=\"Cost\" value={`$${stats.costUsd.toFixed(2)}`} />}\n {meter && <InfoRow label=\"Context\" value={`${meter.label} (${meter.detail})`} />}\n </dl>\n </Dialog>\n );\n}\n","import {\n type AttentionItem,\n isInputAttentionReason,\n primarySession,\n type TrackedIssue,\n} from \"@switchyard/protocol\";\nimport { type ReactNode, useMemo, useState } from \"react\";\nimport { useNavigate } from \"react-router\";\nimport { Button } from \"../../components/ui/Button\";\nimport { Field } from \"../../components/ui/Field\";\nimport { ConfirmDialog, Dialog } from \"../../components/ui/Overlay\";\nimport { ErrorState } from \"../../components/ui/states\";\nimport { TextInput } from \"../../components/ui/TextArea\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { apiDelete, apiPost, errorMessage } from \"../../sync/api\";\nimport { useSyncStore } from \"../../sync/store\";\nimport { unlinkIssue } from \"../workboard/api\";\nimport { LinkIssueDialog, useIssueLink } from \"../workboard/LinkIssue\";\nimport { codeApi } from \"./api\";\nimport type { SessionContext } from \"./hooks\";\nimport { useMutation } from \"./hooks\";\nimport { isBusy, isLive } from \"./model\";\nimport { SessionInfoDialog } from \"./SessionInfoDialog\";\n\nexport interface SessionActions {\n canTakeover: boolean;\n canReturn: boolean;\n canStop: boolean;\n canResume: boolean;\n /** Why archive is unavailable, or null. */\n archiveBlocked: string | null;\n takeover: () => void;\n returnToAutomation: () => void;\n requestStop: () => void;\n resume: () => void;\n openRename: () => void;\n requestArchive: () => void;\n openInfo: () => void;\n toggleCacheAlert: () => void;\n unarchive: () => void;\n /** Clear this session's \"Needs input\" flag (its open input attention), or null when it has none. */\n dismissAttention: (() => void) | null;\n /** Pin the session to a scope, or unpin it. */\n setPinned: (scopeId: string, pinned: boolean) => void;\n /** This session is its branch's primary session. */\n isPrimary: boolean;\n setPrimary: (primary: boolean) => void;\n /** Start another session in this session's workspace, or null when it has none. */\n newInBranch: (() => void) | null;\n /** Link this worktree's branch to an issue, or undo it; null without a worktree. */\n issueLink: {\n linked: TrackedIssue | null;\n candidates: TrackedIssue[];\n canUnlink: boolean;\n open: () => void;\n unlink: () => void;\n } | null;\n busy: { takeover: boolean; ret: boolean; stop: boolean; resume: boolean; unarchive: boolean };\n /** Confirmation and form dialogs; render once in the view. */\n dialogs: ReactNode;\n}\n\n/** Session control and menu actions with confirmation dialogs (no optimistic success). */\nexport function useSessionActions(ctx: SessionContext): SessionActions {\n const { session, run, control } = ctx;\n const navigate = useNavigate();\n const [dialog, setDialog] = useState<null | \"stop\" | \"rename\" | \"archive\" | \"info\" | \"link\">(\n null,\n );\n const [title, setTitle] = useState(session.title);\n const link = useIssueLink(session.provenance === \"subagent\" ? null : ctx.workspace);\n const attention = useSyncStore((st) => st.attention);\n const inputAttention = useMemo(\n () =>\n Object.values(attention).filter(\n (a) => a.sessionId === session.id && !a.resolvedAt && isInputAttentionReason(a.reason),\n ),\n [attention, session.id],\n );\n const isPrimary = useSyncStore((st) => {\n if (session.provenance === \"subagent\" || session.archivedAt) return false;\n const peers = Object.values(st.sessions).filter(\n (x) =>\n x.archivedAt === null &&\n x.provenance !== \"subagent\" &&\n (session.workspaceId\n ? x.workspaceId === session.workspaceId\n : x.workspaceId === null && x.hostId === session.hostId && x.cwd === session.cwd),\n );\n return primarySession(peers)?.id === session.id;\n });\n\n const takeover = useMutation(() => codeApi.takeover(session.id), {\n success: \"You have control. Automatic continuations are paused.\",\n errorToast: true,\n });\n const ret = useMutation(() => codeApi.returnToAutomation(session.id), {\n success: \"Returned to automation.\",\n errorToast: true,\n });\n const stop = useMutation(() => codeApi.stop(session.id), { success: \"Session stopped.\" });\n const resume = useMutation(() => codeApi.resume(session.id), {\n success: \"Session resumed.\",\n errorToast: true,\n });\n const rename = useMutation((t: string) => codeApi.rename(session.id, t), {\n success: \"Session renamed.\",\n });\n const cacheAlert = useMutation(() => codeApi.cacheAlert(session.id, !session.cacheAlert), {\n errorToast: true,\n });\n const archive = useMutation(() => codeApi.archive(session.id), { success: \"Session archived.\" });\n const unarchive = useMutation(() => codeApi.unarchive(session.id), {\n success: \"Session unarchived.\",\n errorToast: true,\n });\n\n const connected = ctx.link === \"connected\";\n const close = () => {\n setDialog(null);\n stop.reset();\n rename.reset();\n archive.reset();\n };\n\n const archiveBlocked = isBusy(session) ? \"Stop the session before archiving it\" : null;\n\n const dialogs = (\n <>\n <ConfirmDialog\n open={dialog === \"stop\"}\n onClose={close}\n title=\"Stop this session?\"\n description=\"Stops the current execution and clears queued messages.\"\n confirmLabel=\"Stop session\"\n busy={stop.busy}\n error={stop.error}\n errorTitle=\"Could not stop\"\n onConfirm={() => void stop.run().then((ok) => ok && setDialog(null))}\n >\n <p className=\"text-sm text-muted\">\n {run\n ? \"The task keeps its run, marked interrupted and blocked (Stopped by user). Automation settings are unchanged.\"\n : \"Pi stays available; you can send a new message afterwards.\"}\n </p>\n </ConfirmDialog>\n\n <Dialog\n open={dialog === \"rename\"}\n onClose={close}\n title=\"Rename session\"\n footer={\n <>\n <Button onClick={close}>Cancel</Button>\n <Button\n variant=\"primary\"\n type=\"submit\"\n form=\"sy-rename-form\"\n busy={rename.busy}\n disabled={!title.trim()}\n >\n Save\n </Button>\n </>\n }\n >\n <form\n id=\"sy-rename-form\"\n onSubmit={(e) => {\n e.preventDefault();\n if (!title.trim()) return;\n void rename.run(title.trim()).then((ok) => ok && setDialog(null));\n }}\n className=\"flex flex-col gap-2\"\n >\n <Field id=\"sy-rename-input\" label=\"Title\">\n <TextInput\n id=\"sy-rename-input\"\n value={title}\n maxLength={200}\n onChange={(e) => setTitle(e.target.value)}\n />\n </Field>\n {rename.error !== null && (\n <ErrorState compact title=\"Could not rename\" error={errorMessage(rename.error)} />\n )}\n </form>\n </Dialog>\n\n <ConfirmDialog\n open={dialog === \"archive\"}\n onClose={close}\n title=\"Archive this session?\"\n description=\"It leaves the navigator. The Pi session file stays on the host.\"\n danger={false}\n confirmLabel=\"Archive\"\n busy={archive.busy}\n error={archive.error}\n errorTitle=\"Could not archive\"\n onConfirm={() =>\n void archive.run().then((ok) => {\n if (!ok) return;\n setDialog(null);\n navigate(\"/code\");\n })\n }\n >\n {session.runtime === \"idle\" && (\n <p className=\"text-sm text-muted\">The idle Pi process is stopped first.</p>\n )}\n </ConfirmDialog>\n\n {ctx.workspace && (\n <LinkIssueDialog\n open={dialog === \"link\"}\n onClose={close}\n workspace={ctx.workspace}\n candidates={link.candidates}\n />\n )}\n\n <SessionInfoDialog\n session={session}\n hostLabel={`${ctx.hostName} (${ctx.link})`}\n open={dialog === \"info\"}\n onClose={close}\n />\n </>\n );\n\n return {\n canTakeover: control === \"automation\",\n canReturn: control === \"human\",\n canStop: isBusy(session) && connected,\n canResume: !isLive(session) && !!session.nativeHandle && !session.readOnly && connected,\n archiveBlocked,\n takeover: () => void takeover.run(),\n returnToAutomation: () => void ret.run(),\n requestStop: () => setDialog(\"stop\"),\n resume: () => void resume.run(),\n openRename: () => {\n setTitle(session.title);\n setDialog(\"rename\");\n },\n requestArchive: () => {\n if (archiveBlocked) toast.info(archiveBlocked);\n else setDialog(\"archive\");\n },\n openInfo: () => setDialog(\"info\"),\n toggleCacheAlert: () => void cacheAlert.run(),\n unarchive: () => void unarchive.run(),\n dismissAttention:\n inputAttention.length > 0\n ? () => {\n void Promise.all(inputAttention.map(dismissAttentionItem))\n .then(() => toast.success(\"Cleared. A question Pi is still waiting on stays.\"))\n .catch((e) => toast.error(errorMessage(e)));\n }\n : null,\n setPinned: (scopeId, pinned) => {\n const path = `/api/scopes/${encodeURIComponent(scopeId)}/sessions/${encodeURIComponent(session.id)}`;\n void (pinned ? apiPost(path) : apiDelete(path)).catch((e) => toast.error(errorMessage(e)));\n },\n isPrimary,\n setPrimary: (primary) => {\n void codeApi.setPrimary(session.id, primary).catch((e) => toast.error(errorMessage(e)));\n },\n newInBranch:\n session.projectId && session.workspaceId\n ? () => {\n void codeApi\n .createSession({\n projectId: session.projectId!,\n workspace: { existingId: session.workspaceId! },\n prompt: \"\",\n })\n .then((s) => {\n useSyncStore.getState().upsertSessionIfMissing(s);\n navigate(`/code/${encodeURIComponent(s.id)}`);\n })\n .catch((e) => toast.error(errorMessage(e)));\n }\n : null,\n issueLink:\n ctx.workspace && session.provenance !== \"subagent\"\n ? {\n ...link,\n open: () => setDialog(\"link\"),\n unlink: () => {\n const i = link.linked;\n if (!i) return;\n void unlinkIssue(i.id)\n .then(() => toast.success(`Unlinked from #${i.number}`))\n .catch((e) => toast.error(errorMessage(e)));\n },\n }\n : null,\n busy: {\n takeover: takeover.busy,\n ret: ret.busy,\n stop: stop.busy,\n resume: resume.busy,\n unarchive: unarchive.busy,\n },\n dialogs,\n };\n}\n\n/** Resolve one attention item by hand and store the result. */\nexport async function dismissAttentionItem(item: AttentionItem): Promise<AttentionItem> {\n const res = await apiPost<AttentionItem>(`/api/attention/${encodeURIComponent(item.id)}/dismiss`);\n const next =\n res && typeof res === \"object\" && \"id\" in res\n ? res\n : { ...item, resolvedAt: new Date().toISOString() };\n useSyncStore.setState((st) =>\n st.attention[item.id] ? { attention: { ...st.attention, [item.id]: next } } : {},\n );\n return next;\n}\n","import type { AttentionItem, AttentionReason, Project, Session, Task } from \"@switchyard/protocol\";\n\nexport const ATTENTION_GROUPS: AttentionReason[] = [\n \"needs_input\",\n \"failed\",\n \"ready_for_review\",\n \"unsupported_interaction\",\n \"host_unreachable\",\n \"cache_expiring\",\n];\n\n/** Group open attention by reason, keeping the input order within a group. */\nexport function groupAttention(items: AttentionItem[]): Record<AttentionReason, AttentionItem[]> {\n const out = Object.fromEntries(ATTENTION_GROUPS.map((r) => [r, [] as AttentionItem[]])) as Record<\n AttentionReason,\n AttentionItem[]\n >;\n for (const a of items) out[a.reason]?.push(a);\n return out;\n}\n\n/** Tooltips and accessible descriptions of the attention actions: what each does and leaves. */\nexport const ATTENTION_ACTION_HELP = {\n dismiss:\n \"Marks it as seen and moves it to Dismissed; it stays open, and a question keeps flagging its session.\",\n clear: \"Resolves it now: the session loses this flag and the item moves to History.\",\n clearNeedsInput:\n \"Removes this session's Needs input flag and moves it to History; a question Pi is still waiting on stays.\",\n} as const;\n\nexport type AttentionShow = \"open\" | \"dismissed\" | \"history\";\n\n/** Stored prefs from before History: \"all\" (open + dismissed) and unknown values read as \"open\". */\nexport function normalizeShow(v: unknown): AttentionShow {\n return v === \"dismissed\" || v === \"history\" ? v : \"open\";\n}\n\n/** Unacknowledged items for \"open\", acknowledged for \"dismissed\"; [] for \"history\". */\nexport function visibleAttention(all: AttentionItem[], show: AttentionShow): AttentionItem[] {\n if (show === \"history\") return [];\n return all.filter((a) => (show === \"open\" ? !a.acknowledgedAt : !!a.acknowledgedAt));\n}\n\n/** \"project · task · session\" (session only when its title differs from the task's), else \"Switchyard\". */\nexport function attentionMeta(project?: Project, task?: Task, session?: Session): string {\n return (\n [project?.name, task?.title, session && session.title !== task?.title ? session.title : null]\n .filter(Boolean)\n .join(\" · \") || \"Switchyard\"\n );\n}\n"],"mappings":"A,syBAGaiE,GACX,wHAQIC,GAAuC,CAC3C,CAAE,GAAI,QAAS,MAAO,eAAgB,KAAM,QAAS,EACrD,CAAE,GAAI,UAAW,MAAO,uBAAwB,KAAM,SAAU,CAClE,EAEA,SAASC,GAAY,EAAwD,CAC3E,GAAIC,EAAK,IAAM,UAAW,OAAOA,EACjC,GAAIA,EAAK,IAAM,UACb,IAAK,IAAMC,KAAKD,EAAK,SAAU,CAC7B,IAAME,EAAQH,GAAYE,CAAC,EAC3B,GAAIC,EAAO,OAAOA,CACpB,CAEF,OAAO,IACT,CASA,SAAgBC,GAAc,EAAyB,CACrD,OAAOC,EAAE,QAAU,eAAiBA,EAAE,OAAO,OAAS,oBACxD,CAGA,SAAgBC,GAAgB,EAAiC,CAE/D,IAAMC,GADOP,GAAYK,EAAE,YACV,CAAA,EAAM,SAAW,CAAC,EAAA,C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AiB,IAAK,GAAM,CAAC5M,EAAG,CAAC,CAAoB,CAAC,CAAC,EAItF,IAAK,IAAMxC,KAAKsP,EAAO/K,EAAIvE,EAAE,OAAO,EAAE,KAAKA,CAAC,EAC5C,OAAOuE,CACT,CAGA,IAAagL,GAAwB,CACnC,QACE,wGACF,MAAO,8EACP,gBACE,2GACJ,EAKA,SAAgBC,GAAc,EAA2B,CACvD,OAAOC,IAAM,aAAeA,IAAM,UAAYA,EAAI,MACpD,CAGA,SAAgBC,GAAiB,EAAsB,EAAsC,CAE3F,OADIC,IAAS,UAAkB,CAAC,EACzBC,EAAI,OAAQ,GAAOD,IAAS,OAAS,CAAC3P,EAAE,eAAiB,CAAC,CAACA,EAAE,cAAe,CACrF,CAGA,SAAgB6P,GAAc,EAAmB,EAAa,EAA2B,CACvF,MACE,CAACtE,GAAS,KAAMuE,GAAM,MAAO7E,GAAWA,EAAQ,QAAU6E,GAAM,MAAQ7E,EAAQ,MAAQ,IAAI,CAAC,CAC1F,OAAO,OAAO,CAAC,CACf,KAAK,KAAK,GAAK,YAEtB,C"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{A as e,d as t,fn as n,hn as r,m as i,nn as a}from"./states-BUWwUyu-.js";import{b as o,i as s}from"./Overlay-DPZqU_vB.js";import{t as c}from"./chevron-right-DuAbbYQ-.js";import{t as l}from"./pencil-y_4AgVa2.js";import{t as u}from"./useBreakpoint-DoLUoCMf.js";import{H as d,m as f}from"./index-cmIcNnnF.js";import{t as p}from"./NavigationEditor-C0J7vDXL.js";var m=r(n(),1),h=i();function g(){let{more:n}=f(),r=e(),[i,g]=(0,m.useState)(!1),_=u()===`mobile`;return(0,h.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col gap-3 px-4 pb-4 safe-pt-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`More`}),(0,h.jsx)(t,{size:`sm`,variant:`ghost`,icon:(0,h.jsx)(l,{className:`size-4`}),onClick:()=>g(!0),children:`Edit`})]}),(0,h.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:n.map(({id:e,to:t,label:n,description:i,icon:s,badge:l})=>(0,h.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,h.jsxs)(a,{to:t,"data-keyboard-item":!0,className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2 active:bg-surface-2`,children:[(0,h.jsx)(s,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block font-medium`,children:n}),(0,h.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:i})]}),l===`attention`&&(0,h.jsx)(o,{count:r,label:`need attention`}),(0,h.jsx)(c,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},e))}),!_&&(0,h.jsx)(t,{variant:`secondary`,onClick:()=>d.getState().setHelpOpen(!0),children:`Keyboard shortcuts`}),(0,h.jsx)(s,{open:i,onClose:()=>g(!1),title:`Edit navigation`,description:`Choose the bottom bar and the order of every page.`,footer:(0,h.jsx)(t,{variant:`primary`,onClick:()=>g(!1),children:`Done`}),children:(0,h.jsx)(p,{})})]})}export{g as default};
|
|
2
|
-
//# sourceMappingURL=more-CVjg2O5h.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{D as e,Qt as t,T as n,W as r,Zt as i,c as a,f as o,fn as s,g as c,hn as l,i as u,m as d,n as f,nn as p,p as m,r as h,s as g,t as _,u as v,vt as y,y as b}from"./states-BUWwUyu-.js";import{C as x}from"./Overlay-DPZqU_vB.js";import{t as S}from"./calendar-clock-B3bQkNKq.js";import{r as C}from"./Priority-0hv1Vpg7.js";import{i as w}from"./useResource-CPN6cDQ5.js";import{B as T,a as E,m as D,t as O,x as k}from"./useNow-BS_9T7IY.js";import{t as A}from"./link-2-M5ENDPWT.js";import{$ as j,K as M,gt as N,rt as P,st as F,t as I,yt as L}from"./index-cmIcNnnF.js";import{t as R}from"./UnfilteredNote-22-Qjb-f.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=e(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=e(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=e(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=e(G),q=l(s(),1),J=d(),Y={dependency:A,host_offline:P,project_limit:H,workspace_occupied:B,scheduled_time:S,invalid_configuration:b,dispatch_paused:N,project_automation_disabled:W,not_ready:n,already_dispatched:F,retry_backoff:K};function X(){let e=O(),n=r(e=>e.tasks),o=r(e=>e.runs),s=r(e=>e.hydrated),c=t(e.error)&&e.error.status===404,l=!!e.data&&(!Array.isArray(e.data.running)||!Array.isArray(e.data.queued)),u=(0,q.useMemo)(()=>e.data&&!l?e.data.running.map(e=>({taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})):Object.values(o).filter(e=>k(e)&&e.state!==`queued`).map(e=>({taskId:e.taskId,runId:e.id,sessionId:e.sessionId})),[e.data,o,l]),d=(0,q.useMemo)(()=>e.data&&!l?e.data.queued.map(e=>({taskId:e.taskId,eligibility:e.eligibility})):Object.values(n).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,n,l]),p=!e.data&&e.loading&&!e.error||!s,m=!!e.error&&!c&&!e.data;return l?(0,J.jsx)(h,{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)(E,{})]}),(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)(g,{subject:`queue`,show:!!e.data}),c&&(0,J.jsx)(v,{capability:`Queue explanations`,reason:`This coordinator does not report why queued tasks are waiting. The list below comes from local data.`}),e.error!=null&&!c&&(0,J.jsx)(f,{compact:!0,title:`Could not refresh running and queued work`,error:i(e.error),onRetry:e.reload}),p?(0,J.jsx)(a,{label:`Loading running and queued work…`}):m&&u.length===0&&d.length===0?null:u.length===0&&d.length===0?(0,J.jsx)(_,{icon:(0,J.jsx)(x,{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:I.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:[`(`,u.length,`)`]})]}),u.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:u.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:[`(`,d.length,`)`]})]}),d.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:d.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Q,{task:n[e.taskId],taskId:e.taskId,eligibility:e.eligibility})},e.taskId))})]})]})]})}function Z({taskId:e,runId:t,sessionId:n}){let i=r(t=>t.tasks[e]),a=r(e=>e.runs[t]),s=r(e=>a?.hostId?e.hosts[a.hostId]:void 0),l=r(e=>i?e.projects[i.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:[a?(0,J.jsx)(j,{kind:`run`,value:a.state,size:`sm`}):(0,J.jsx)(j,{kind:`task`,value:`in_progress`,size:`sm`}),(0,J.jsx)(p,{to:I.task(e),"data-keyboard-item":!0,className:`min-w-0 flex-1 basis-48 font-medium break-words hover:underline`,children:i?.title??`Task`}),(n??i?.sessionId)&&(0,J.jsxs)(p,{to:I.session(n??i?.sessionId),className:o(`secondary`,`sm`),children:[(0,J.jsx)(w,{"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,a?.attempt&&a.attempt>1?`attempt ${a.attempt}`:null,a?.startedAt?`started ${c(a.startedAt)}`:null,a?.controlMode===`human`?`you have control`:`automation`].filter(Boolean).join(` · `)}),a?.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)(u,{compact:!0,hostName:s.name,connectivity:s.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:s.lastSeenAt})]})}function Q({task:e,taskId:t,eligibility:n}){let a=r(t=>e?t.projects[e.projectId]:void 0),[o,s]=(0,q.useState)(!1),c=(0,q.useId)(),l=n?n.eligible?L:Y[n.wait]:x,u=n?n.eligible?`Starting on ${n.hostName}`:D[n.wait]:`Waiting for dispatch`,d=n&&!n.eligible?n.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)(p,{to:I.task(t),"data-keyboard-item":!0,className:`min-w-0 font-medium break-words hover:underline`,children:e?.title??`Task`}),a&&(0,J.jsx)(`span`,{className:`text-xs text-muted`,children:a.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 ${n?.eligible?`text-success`:`text-warning`}`}),(0,J.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:u}),d&&d!==u?(0,J.jsxs)(`span`,{className:`text-muted`,children:[`: `,d]}):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)(C,{id:c,width:`auto`,value:e.priority,disabled:o,onChange:async t=>{s(!0);try{await T(e.id,{priority:t}),M.success(`"${e.title}" is now ${y[t]} priority`)}catch(e){M.error(`Could not change priority: ${i(e)}`)}finally{s(!1)}}}),o&&(0,J.jsx)(m,{label:`Saving priority`})]})]})}export{X as default};
|
|
2
|
-
//# sourceMappingURL=queue-BGK9c062.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{At as e,D as t,Ft as n,Jt as r,Kt as i,Mt as a,Nt as o,P as s,Qt as c,R as l,W as u,Yt as d,Zt as f,a as p,d as m,fn as h,g,hn as _,jt as v,m as y,n as b,qt as x}from"./states-BUWwUyu-.js";import{n as S,t as C}from"./Overlay-DPZqU_vB.js";import{t as w}from"./Field-DS2BMoqA.js";import{G as T,K as E,W as D,t as O}from"./index-cmIcNnnF.js";import{t as k}from"./TextLink-BpF2vLiL.js";import{n as A,t as j}from"./RadioCards-CN5xELnc.js";import{t as M}from"./Select-CN7M29ap.js";import{n as N}from"./Switch-CZMY83Fw.js";import{a as P,n as F}from"./ScopeSelect-BaJjip1Y.js";import{t as I}from"./Checkbox-DR78wXsg.js";var L={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`}]]};L.node;var R=t(L),z={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};z.node;var B=t(z),V=_(h(),1),H=y();function U({draft:e,errors:t,set:n,hosts:r,columns:i}){let a=(0,V.useId)(),o=e.board.trim()!==``;return(0,H.jsxs)(`div`,{"data-testid":`github-source-form`,className:`flex flex-col gap-3`,children:[(0,H.jsx)(w,{label:`Host`,hint:`Its gh login reads your issues.`,error:t.hostId,children:t=>(0,H.jsxs)(M,{...t,value:e.hostId,onChange:e=>n(`hostId`,e.target.value),children:[(0,H.jsx)(`option`,{value:``,children:`Choose a host`}),r.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,H.jsx)(w,{label:`GitHub owner`,hint:`An organization or user, such as fieldgoalco.`,error:t.owner,children:t=>(0,H.jsx)(T,{...t,value:e.owner,spellCheck:!1,onChange:e=>n(`owner`,e.target.value)})}),(0,H.jsx)(w,{label:`Repositories`,optional:!0,hint:`One owner/name per line. Leave empty for every repository of the owner.`,error:t.repositories,children:t=>(0,H.jsx)(D,{...t,rows:3,value:e.repositories,spellCheck:!1,onChange:e=>n(`repositories`,e.target.value)})}),(0,H.jsx)(w,{label:`Repositories of other owners`,optional:!0,hint:`One owner/name per line. Their projects join this scope, and issues assigned to you there are tracked too.`,error:t.extraRepositories,children:t=>(0,H.jsx)(D,{...t,rows:2,value:e.extraRepositories,spellCheck:!1,onChange:e=>n(`extraRepositories`,e.target.value)})}),(0,H.jsxs)(`fieldset`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`legend`,{className:`text-sm font-semibold`,children:`Projects board`}),(0,H.jsx)(w,{label:`Board number`,optional:!0,hint:`A GitHub Projects board of the owner. Needs the project permission on your gh login: gh auth refresh -s project.`,error:t.board,children:t=>(0,H.jsx)(T,{...t,inputMode:`numeric`,value:e.board,onChange:e=>n(`board`,e.target.value)})}),o&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`datalist`,{id:a,children:i.map(e=>(0,H.jsx)(`option`,{value:e},e))}),(0,H.jsx)(w,{label:`Issues to follow`,hint:`On the board, issues need no assignee.`,children:t=>(0,H.jsxs)(M,{...t,value:e.follow,onChange:e=>n(`follow`,e.target.value),children:[(0,H.jsx)(`option`,{value:`assigned`,children:`Assigned to me`}),(0,H.jsx)(`option`,{value:`board`,children:`Every open issue on the board`})]})}),(0,H.jsx)(w,{label:`Status field`,children:t=>(0,H.jsx)(T,{...t,value:e.statusField,onChange:e=>n(`statusField`,e.target.value)})}),(0,H.jsx)(w,{label:`Column when work starts`,optional:!0,children:t=>(0,H.jsx)(T,{...t,list:a,value:e.onStart,onChange:e=>n(`onStart`,e.target.value)})}),(0,H.jsx)(w,{label:`Column when a pull request opens`,optional:!0,children:t=>(0,H.jsx)(T,{...t,list:a,value:e.onReview,onChange:e=>n(`onReview`,e.target.value)})}),(0,H.jsx)(w,{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:t.backlog,children:t=>(0,H.jsx)(T,{...t,value:e.backlog,onChange:e=>n(`backlog`,e.target.value)})}),(0,H.jsx)(w,{label:`Priority field`,optional:!0,hint:`A single-select field, such as Priority. Not-started issues are listed by it.`,children:t=>(0,H.jsx)(T,{...t,value:e.priorityField,onChange:e=>n(`priorityField`,e.target.value)})}),(0,H.jsx)(N,{label:`Move cards on GitHub`,description:e.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:e.writeBack,onChange:e=>n(`writeBack`,e)}),e.writeBack&&(0,H.jsx)(N,{label:`Also move cards assigned to others too`,checked:e.moveShared,onChange:e=>n(`moveShared`,e)})]})]}),(0,H.jsx)(N,{label:`Make worktrees for issue branches`,description:`Off: Switchyard only links the worktrees you make and never creates one.`,checked:e.worktrees,onChange:e=>n(`worktrees`,e)}),(0,H.jsx)(N,{label:`Sync this scope`,checked:e.enabled,onChange:e=>n(`enabled`,e)}),(0,H.jsx)(`p`,{className:`text-xs text-muted`,children:`Its projects are the ones in Settings › Projects whose repositories this covers.`})]})}var W=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),G=e=>e.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(Boolean);function K(e,t){let n=e?.source??null;return n?{name:e?.name??``,hostId:n.hostId,owner:n.owner,repositories:(n.repositories??[]).join(`
|
|
3
|
-
`),extraRepositories:(n.extraRepositories??[]).join(`
|
|
4
|
-
`),board:n.board?String(n.board.projectNumber):``,statusField:n.board?.statusField??`Status`,onStart:n.board?.onStart??``,onReview:n.board?.onReview??``,follow:a(n),backlog:v(n).join(`, `),priorityField:n.board?.priorityField??``,writeBack:n.writeBack,moveShared:n.moveShared,worktrees:o(n),enabled:n.enabled}:{name:e?.name??``,hostId:t,owner:``,repositories:``,extraRepositories:``,board:``,statusField:`Status`,onStart:``,onReview:``,follow:`assigned`,backlog:``,priorityField:``,writeBack:!1,moveShared:!0,worktrees:!0,enabled:!0}}function q(t){let r={},i=t.name.trim();i?i.length>60&&(r.name=`Use 60 characters or fewer.`):r.name=`Enter a name.`,t.hostId||(r.hostId=`Choose a host.`),e.safeParse(t.owner.trim()).success||(r.owner=`Enter a GitHub organization or user name.`),G(t.repositories).some(e=>!n.safeParse(e).success)&&(r.repositories=`Use owner/name, one per line.`);let a=G(t.extraRepositories);a.some(e=>!n.safeParse(e).success)?r.extraRepositories=`Use owner/name, one per line.`:a.length>20&&(r.extraRepositories=`Use 20 repositories or fewer.`);let o=t.board.trim();return o&&!/^[1-9][0-9]*$/.test(o)&&(r.board=`Enter the board's number, as in its URL.`),W(t.backlog).length>20&&(r.backlog=`Use 20 columns or fewer.`),r}function J(e){let t=G(e.repositories),n=e.board.trim(),r={hostId:e.hostId,owner:e.owner.trim(),repositories:t.length?t:null,extraRepositories:G(e.extraRepositories),board:n?{projectNumber:Number(n),statusField:e.statusField.trim()||`Status`,onStart:e.onStart.trim()||null,onReview:e.onReview.trim()||null,backlog:W(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};return{name:e.name.trim(),source:r}}function Y(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`}`})(),r=[[`GitHub`,`${e.owner}${e.repositories?`: ${e.repositories.join(`, `)}`:` (all repositories)`}${e.extraRepositories?.length?`, plus ${e.extraRepositories.join(`, `)}`:``}`],[`Host`,e.login?`${t}, signed in to GitHub as ${e.login}`:`${t}, not synced yet`]];return e.board&&(r.push([`Board`,`#${e.board.projectNumber}, field ${e.board.statusField}${e.board.priorityField?`, priority ${e.board.priorityField}`:``}${v(e).length?`; hides ${v(e).join(`, `)} until started`:``}`]),r.push([`Moves cards`,n])),r}var X=[{value:`projects`,label:`Projects you choose`,explanation:`Sessions in the projects you check, plus any session you pin.`},{value:`pins`,label:`Pins only`,explanation:`Only the sessions you pin to it.`},{value:`github`,label:`GitHub issues`,explanation:`Issues assigned to you or on a Projects board, and the sessions working on them.`}];function ee(e){return e?.source?`github`:e?.mode===`pinned`?`pins`:`projects`}function Z(e,t){return{name:e?.name??``,contents:ee(e),projectIds:e?.projectIds??[],hostIds:e?.hostIds??[],github:K(e,t)}}function te(e){let t=q({...e.github,name:e.name});return e.contents===`github`?t:t.name?{name:t.name}:{}}function ne(e,t){let n=e.name.trim(),r=e.hostIds.length?e.hostIds:null;return e.contents===`github`?{name:n,mode:`all`,hostIds:r,source:J({...e.github,name:n}).source}:{name:n,mode:e.contents===`pins`?`pinned`:`all`,projectIds:e.projectIds.length?e.projectIds:null,hostIds:r,...t?.source?{source:null}:{}}}function Q(e,t){return!!t?.source&&e.contents!==`github`}function re({scope:e,describe:t,onNavigate:n}){let r=u(e=>e.clients),i=u(e=>e.hosts),a=P(e,Object.values(r),i),o=e.name.trim().replace(/\s+/g,`-`);return(0,H.jsxs)(`dl`,{"data-testid":`scope-about`,className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-md bg-surface-2 px-3 py-2 text-sm`,children:[(0,H.jsx)(`dt`,{className:`text-muted`,children:`Contains`}),(0,H.jsx)(`dd`,{className:`min-w-0`,children:t(e)}),(0,H.jsx)(`dt`,{className:`text-muted`,children:`Mirrored in`}),(0,H.jsxs)(`dd`,{className:`flex min-w-0 flex-col gap-0.5`,children:[a??(0,H.jsx)(`span`,{children:`No client.`}),!a&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`text-muted`,children:[`To mirror it in herdr, choose it in`,` `,(0,H.jsx)(k,{to:O.settings(`clients`),onClick:n,children:`Settings › Clients`}),`, or run:`]}),(0,H.jsxs)(`code`,{className:`block break-all text-xs`,children:[`switchyard clients bind herdr:`,o,` --scope `,e.name]})]})]})]})}function $(e,t,n){return n?[...e,t]:e.filter(e=>e!==t)}function ie({editing:e,onClose:t,onSaved:n}){let{scopes:a,describe:o}=F(),p=l(),h=s(),g=u(e=>e.issues),_=(h.find(e=>e.connectivity===`connected`)??h[0])?.id??``,v=e&&e!==`new`?a[e]??null:null,y=e??`closed`,[x,D]=(0,V.useState)(null),[O,k]=(0,V.useState)(()=>Z(null,_)),[A,M]=(0,V.useState)({}),[N,P]=(0,V.useState)(!1),[L,R]=(0,V.useState)(null),[z,B]=(0,V.useState)(!1);x!==y&&(D(y),k(Z(v,_)),M({}),R(null),B(!1));let W=(0,V.useMemo)(()=>v?Object.values(g).find(e=>e.scopeId===v.id&&e.board)?.board?.options.map(e=>e.name)??[]:[],[g,v]),G=(e,t)=>k(n=>({...n,github:{...n.github,[e]:t}})),K=async()=>{let e=te(O);if(M(e),Object.keys(e).length>0)return;P(!0),R(null);let i=ne(O,v);try{let e=v?await r(`/api/scopes/${encodeURIComponent(v.id)}`,i):await d(`/api/scopes`,i);E.success(`Scope ${e.name} saved`),n(e.id),t()}catch(e){R(e)}finally{P(!1)}},q=async()=>{if(v){P(!0);try{await i(`/api/scopes/${encodeURIComponent(v.id)}`),E.success(`Scope ${v.name} deleted`),B(!1),t()}catch(e){R(e)}finally{P(!1)}}},J=c(L,`conflict`)?f(L):null,Y=e!==null;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(S,{open:Y&&!z,onClose:t,title:v?`Edit scope`:`New scope`,description:`A scope is a named part of your work, shown on Sessions and the Board.`,footer:(0,H.jsxs)(H.Fragment,{children:[v&&(0,H.jsx)(m,{variant:`danger`,onClick:()=>B(!0),className:`mr-auto`,children:`Delete`}),(0,H.jsx)(m,{onClick:t,children:`Cancel`}),(0,H.jsx)(m,{variant:`primary`,busy:N,disabled:!O.name.trim(),onClick:()=>void K(),children:Q(O,v)?`Save and disconnect GitHub`:`Save`})]}),children:(0,H.jsxs)(`div`,{"data-testid":`scope-form`,className:`flex flex-col gap-3`,children:[v&&(0,H.jsx)(re,{scope:v,describe:o,onNavigate:t}),(0,H.jsx)(w,{label:`Name`,id:`sy-scope-name`,error:A.name??J,children:e=>(0,H.jsx)(T,{...e,value:O.name,maxLength:60,onChange:e=>k({...O,name:e.target.value})})}),(0,H.jsx)(j,{legend:`Contains`,columns:1,value:O.contents,options:X,onChange:e=>k({...O,contents:e})}),Q(O,v)&&(0,H.jsx)(`p`,{role:`status`,className:`rounded-md border border-border bg-warning-soft px-3 py-2 text-sm`,children:`Saving disconnects GitHub: this scope's issues leave the Board. Its sessions and worktrees stay.`}),O.contents===`projects`&&(0,H.jsxs)(`fieldset`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`legend`,{className:`text-sm font-medium`,children:`Projects (none checked: any)`}),p.map(e=>(0,H.jsx)(I,{label:e.name,checked:O.projectIds.includes(e.id),onChange:t=>k({...O,projectIds:$(O.projectIds,e.id,t)})},e.id))]}),O.contents===`github`&&(0,H.jsx)(U,{draft:O.github,errors:A,set:G,hosts:h,columns:W}),O.contents!==`pins`&&!!v?.hostIds?.length&&(0,H.jsxs)(`fieldset`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`legend`,{className:`text-sm font-medium`,children:`Hosts (none checked: any)`}),h.map(e=>(0,H.jsx)(I,{label:e.name,checked:O.hostIds.includes(e.id),onChange:t=>k({...O,hostIds:$(O.hostIds,e.id,t)})},e.id))]}),L!==null&&!J&&(0,H.jsx)(b,{compact:!0,title:`Could not save`,error:f(L)})]})}),(0,H.jsx)(C,{open:Y&&z,onClose:()=>B(!1),title:`Delete this scope?`,description:`Sessions are not affected. Clients mirroring it then mirror nothing and keep their tabs.${v?.source?` Its issues are removed from the Board.`:``}`,confirmLabel:`Delete scope`,busy:N,error:L,onConfirm:()=>void q()})]})}function ae({host:e,compact:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(new Set),[o,s]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),h=e.connectivity===`connected`;if((0,V.useEffect)(()=>{if(!h)return;let t=!0;return x(`/api/hosts/${encodeURIComponent(e.id)}/project-suggestions`).then(e=>{t&&(r(e.suggestions),a(new Set(e.suggestions.filter(e=>e.preselected).map(e=>e.rootPath))))},e=>{t&&!c(e,`unsupported_capability`)&&s(e)}),()=>{t=!1}},[e.id,h]),!n||n.length===0)return o?(0,H.jsx)(p,{error:o}):null;if(t)return(0,H.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,H.jsxs)(`span`,{children:[n.length,` `,n.length===1?`repository`:`repositories`,` found in your Pi history`]}),(0,H.jsx)(k,{to:`/settings/projects`,size:`xs`,variant:`action`,children:`Review`})]});let _=async()=>{u(!0);let t=0,o=[];for(let r of n.filter(e=>i.has(e.rootPath)))try{await d(`/api/projects`,{name:r.name,hostId:e.id,path:r.rootPath}),t+=1}catch(e){c(e,`conflict`)?t+=1:o.push(`${r.name}: ${f(e)}`)}u(!1),t>0&&E.success(`Added ${t} project${t===1?``:`s`}`);for(let e of o)E.error(e);r(e=>e?.filter(e=>!i.has(e.rootPath))??null),a(new Set)};return(0,H.jsx)(A,{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,H.jsx)(m,{variant:`primary`,size:`sm`,busy:l,disabled:i.size===0,onClick:()=>void _(),children:`Add selected`}),children:(0,H.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(I,{label:e.name,description:(0,H.jsxs)(`span`,{className:`font-mono text-xs break-all text-muted`,children:[e.rootPath,` · `,e.sessionCount,` session`,e.sessionCount===1?``:`s`,` · last`,` `,g(e.lastActivityAt)]}),checked:i.has(e.rootPath),onChange:t=>a(n=>{let r=new Set(n);return t?r.add(e.rootPath):r.delete(e.rootPath),r})})},e.rootPath))})})}function oe(e){return e.startsWith(`local:`)?`Local only`:e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``)}function se(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.repoIdentity.toLowerCase().includes(n)}export{Y as a,ie as i,oe as n,B as o,ae as r,R as s,se as t};
|
|
5
|
-
//# sourceMappingURL=repo-CuL_qbqU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repo-CuL_qbqU.js","names":["__iconData","useId","_Fragment","_Fragment","useState","useMemo","useState","GitHubLogin","createLucideIcon","GitHubRepository","apiPatch","apiDelete","sourceFollow","sourceMakesWorktrees","useHosts","isApiError","useProjects","useSyncStore","apiPost","errorMessage","InlineError","Button","require_react","__toESM","sourceBacklog","require_jsx_runtime","ErrorState","apiGet","Dialog","ConfirmDialog","Field","TextInput","toast","TextArea","ROUTES","TextLink","Card","RadioCards","Select","SwitchRow","shownIn","useScopeDescriber","Checkbox","__iconData$1","Send","__iconData","SquareTerminal","import_react","import_jsx_runtime","GitHubSourceFields","columnsId","hasBoard","draft","errors","p","set","hosts","h","columns","c","v","backlogOf","text","s","lines","l","draftOf","t","scope","defaultHostId","validateDraft","e","name","d","r","extra","board","bodyOf","repos","source","sourceFacts","moves","parts","rows","hostName","CONTENTS_OPTIONS","contentsOf","scopeDraftOf","validateScopeDraft","all","scopeBodyOf","hostIds","disconnects","ScopeAbout","clients","shown","session","describe","onNavigate","toggle","on","list","id","x","ScopeDialog","projects","issues","defaultHost","editing","scopes","key","draftKey","setDraftKey","setDraft","setErrors","busy","setBusy","error","setError","confirmDelete","setConfirmDelete","o","setGithub","k","save","found","body","saved","onSaved","onClose","remove","conflict","open","ProjectSuggestions","items","setItems","checked","setChecked","connected","host","alive","compact","add","added","failed","i","f","prev","formatRelative","next","repoLabel","identity","matchesProject","q","query"],"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/send.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/square-terminal.mjs","../../src/features/scopes/GitHubSourceFields.tsx","../../src/features/scopes/githubSourceLogic.ts","../../src/features/scopes/scopeFormLogic.ts","../../src/features/scopes/ScopeDialog.tsx","../../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: \"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","/**\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: \"square-terminal\",\n size: 24,\n node: [\n [\"path\", { d: \"m7 11 2-2-2-2\", key: \"1lz0vl\" }],\n [\"path\", { d: \"M11 13h4\", key: \"1p7l4v\" }],\n [\"rect\", { width: \"18\", height: \"18\", x: \"3\", y: \"3\", rx: \"2\", ry: \"2\", key: \"1m3agn\" }]\n ],\n aliases: [\"terminal-square\"]\n};\n__iconData.node;\nconst SquareTerminal = createLucideIcon(__iconData);\n\nexport { __iconData, SquareTerminal as default };\n//# sourceMappingURL=square-terminal.mjs.map\n","import type { Host } from \"@switchyard/protocol\";\nimport { useId } from \"react\";\nimport { Field } from \"../../components/ui/Field\";\nimport { Select } from \"../../components/ui/Select\";\nimport { SwitchRow } from \"../../components/ui/Switch\";\nimport { TextArea, TextInput } from \"../../components/ui/TextArea\";\nimport type { GitHubSourceDraft, GitHubSourceDraftErrors } from \"./githubSourceLogic\";\n\n/** The fields of a GitHub source, inside the scope form. The name belongs to the form. */\nexport function GitHubSourceFields({\n draft,\n errors,\n set,\n hosts,\n columns,\n}: {\n draft: GitHubSourceDraft;\n errors: GitHubSourceDraftErrors;\n set: <K extends keyof GitHubSourceDraft>(k: K, v: GitHubSourceDraft[K]) => void;\n hosts: Host[];\n /** The board's column names, for the column inputs' suggestions. */\n columns: string[];\n}) {\n const columnsId = useId();\n const hasBoard = draft.board.trim() !== \"\";\n return (\n <div data-testid=\"github-source-form\" className=\"flex flex-col gap-3\">\n <Field label=\"Host\" hint=\"Its gh login reads your issues.\" error={errors.hostId}>\n {(p) => (\n <Select {...p} value={draft.hostId} onChange={(e) => set(\"hostId\", e.target.value)}>\n <option value=\"\">Choose a host</option>\n {hosts.map((h) => (\n <option key={h.id} value={h.id}>\n {h.name}\n </option>\n ))}\n </Select>\n )}\n </Field>\n <Field\n label=\"GitHub owner\"\n hint=\"An organization or user, such as fieldgoalco.\"\n error={errors.owner}\n >\n {(p) => (\n <TextInput\n {...p}\n value={draft.owner}\n spellCheck={false}\n onChange={(e) => set(\"owner\", e.target.value)}\n />\n )}\n </Field>\n <Field\n label=\"Repositories\"\n optional\n hint=\"One owner/name per line. Leave empty for every repository of the owner.\"\n error={errors.repositories}\n >\n {(p) => (\n <TextArea\n {...p}\n rows={3}\n value={draft.repositories}\n spellCheck={false}\n onChange={(e) => set(\"repositories\", e.target.value)}\n />\n )}\n </Field>\n <Field\n label=\"Repositories of other owners\"\n optional\n hint=\"One owner/name per line. Their projects join this scope, and issues assigned to you there are tracked too.\"\n error={errors.extraRepositories}\n >\n {(p) => (\n <TextArea\n {...p}\n rows={2}\n value={draft.extraRepositories}\n spellCheck={false}\n onChange={(e) => set(\"extraRepositories\", e.target.value)}\n />\n )}\n </Field>\n <fieldset className=\"flex flex-col gap-3\">\n <legend className=\"text-sm font-semibold\">Projects board</legend>\n <Field\n label=\"Board number\"\n optional\n hint=\"A GitHub Projects board of the owner. Needs the project permission on your gh login: gh auth refresh -s project.\"\n error={errors.board}\n >\n {(p) => (\n <TextInput\n {...p}\n inputMode=\"numeric\"\n value={draft.board}\n onChange={(e) => set(\"board\", e.target.value)}\n />\n )}\n </Field>\n {hasBoard && (\n <>\n <datalist id={columnsId}>\n {columns.map((c) => (\n <option key={c} value={c} />\n ))}\n </datalist>\n <Field label=\"Issues to follow\" hint=\"On the board, issues need no assignee.\">\n {(p) => (\n <Select\n {...p}\n value={draft.follow}\n onChange={(e) => set(\"follow\", e.target.value as GitHubSourceDraft[\"follow\"])}\n >\n <option value=\"assigned\">Assigned to me</option>\n <option value=\"board\">Every open issue on the board</option>\n </Select>\n )}\n </Field>\n <Field label=\"Status field\">\n {(p) => (\n <TextInput\n {...p}\n value={draft.statusField}\n onChange={(e) => set(\"statusField\", e.target.value)}\n />\n )}\n </Field>\n <Field label=\"Column when work starts\" optional>\n {(p) => (\n <TextInput\n {...p}\n list={columnsId}\n value={draft.onStart}\n onChange={(e) => set(\"onStart\", e.target.value)}\n />\n )}\n </Field>\n <Field label=\"Column when a pull request opens\" optional>\n {(p) => (\n <TextInput\n {...p}\n list={columnsId}\n value={draft.onReview}\n onChange={(e) => set(\"onReview\", e.target.value)}\n />\n )}\n </Field>\n <Field\n label=\"Backlog columns\"\n optional\n hint=\"Cards in these columns are not tracked until they have a branch or pull request. Separate names with commas.\"\n error={errors.backlog}\n >\n {(p) => (\n <TextInput\n {...p}\n value={draft.backlog}\n onChange={(e) => set(\"backlog\", e.target.value)}\n />\n )}\n </Field>\n <Field\n label=\"Priority field\"\n optional\n hint=\"A single-select field, such as Priority. Not-started issues are listed by it.\"\n >\n {(p) => (\n <TextInput\n {...p}\n value={draft.priorityField}\n onChange={(e) => set(\"priorityField\", e.target.value)}\n />\n )}\n </Field>\n <SwitchRow\n label=\"Move cards on GitHub\"\n description={\n draft.follow === \"board\"\n ? \"Cards assigned to you or to nobody, only the status field, and only from the column Switchyard last saw.\"\n : \"Only cards assigned to you, only the status field, and only from the column Switchyard last saw.\"\n }\n checked={draft.writeBack}\n onChange={(v) => set(\"writeBack\", v)}\n />\n {draft.writeBack && (\n <SwitchRow\n label=\"Also move cards assigned to others too\"\n checked={draft.moveShared}\n onChange={(v) => set(\"moveShared\", v)}\n />\n )}\n </>\n )}\n </fieldset>\n <SwitchRow\n label=\"Make worktrees for issue branches\"\n description=\"Off: Switchyard only links the worktrees you make and never creates one.\"\n checked={draft.worktrees}\n onChange={(v) => set(\"worktrees\", v)}\n />\n <SwitchRow\n label=\"Sync this scope\"\n checked={draft.enabled}\n onChange={(v) => set(\"enabled\", v)}\n />\n <p className=\"text-xs text-muted\">\n Its projects are the ones in Settings › Projects whose repositories this covers.\n </p>\n </div>\n );\n}\n","import {\n GitHubLogin,\n GitHubRepository,\n type GitHubSource,\n type GitHubSourceInput,\n type Scope,\n sourceBacklog,\n sourceFollow,\n sourceMakesWorktrees,\n} from \"@switchyard/protocol\";\n\n/** The GitHub scope form's fields, as typed. */\nexport interface GitHubSourceDraft {\n /** Overlaid by the scope form's name (scopeFormLogic.ts). */\n name: string;\n hostId: string;\n owner: string;\n /** One owner/name per line; empty: every repository of the owner. */\n repositories: string;\n /** One owner/name per line: repositories of other owners. */\n extraRepositories: string;\n /** A Projects board number; empty: none. */\n board: string;\n statusField: string;\n onStart: string;\n onReview: string;\n /** Which issues to follow. */\n follow: \"assigned\" | \"board\";\n /** Backlog columns, comma-separated. */\n backlog: string;\n /** The board's priority field; empty: none. */\n priorityField: string;\n writeBack: boolean;\n moveShared: boolean;\n worktrees: boolean;\n enabled: boolean;\n}\n\nexport type GitHubSourceDraftErrors = Partial<\n Record<\n \"name\" | \"hostId\" | \"owner\" | \"repositories\" | \"extraRepositories\" | \"board\" | \"backlog\",\n string\n >\n>;\n\nconst backlogOf = (text: string) =>\n text\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean);\n\nconst lines = (text: string) =>\n text\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter(Boolean);\n\n/** The draft for a new GitHub scope (`scope` null), or for a scope's source (none yet: defaults). */\nexport function draftOf(scope: Scope | null, defaultHostId: string): GitHubSourceDraft {\n const t = scope?.source ?? null;\n if (!t)\n return {\n name: scope?.name ?? \"\",\n hostId: defaultHostId,\n owner: \"\",\n repositories: \"\",\n extraRepositories: \"\",\n board: \"\",\n statusField: \"Status\",\n onStart: \"\",\n onReview: \"\",\n follow: \"assigned\",\n backlog: \"\",\n priorityField: \"\",\n writeBack: false,\n moveShared: true,\n worktrees: true,\n enabled: true,\n };\n return {\n name: scope?.name ?? \"\",\n hostId: t.hostId,\n owner: t.owner,\n repositories: (t.repositories ?? []).join(\"\\n\"),\n extraRepositories: (t.extraRepositories ?? []).join(\"\\n\"),\n board: t.board ? String(t.board.projectNumber) : \"\",\n statusField: t.board?.statusField ?? \"Status\",\n onStart: t.board?.onStart ?? \"\",\n onReview: t.board?.onReview ?? \"\",\n follow: sourceFollow(t),\n backlog: sourceBacklog(t).join(\", \"),\n priorityField: t.board?.priorityField ?? \"\",\n writeBack: t.writeBack,\n moveShared: t.moveShared,\n worktrees: sourceMakesWorktrees(t),\n enabled: t.enabled,\n };\n}\n\nexport function validateDraft(d: GitHubSourceDraft): GitHubSourceDraftErrors {\n const e: GitHubSourceDraftErrors = {};\n const name = d.name.trim();\n if (!name) e.name = \"Enter a name.\";\n else if (name.length > 60) e.name = \"Use 60 characters or fewer.\";\n if (!d.hostId) e.hostId = \"Choose a host.\";\n if (!GitHubLogin.safeParse(d.owner.trim()).success)\n e.owner = \"Enter a GitHub organization or user name.\";\n if (lines(d.repositories).some((r) => !GitHubRepository.safeParse(r).success))\n e.repositories = \"Use owner/name, one per line.\";\n const extra = lines(d.extraRepositories);\n if (extra.some((r) => !GitHubRepository.safeParse(r).success))\n e.extraRepositories = \"Use owner/name, one per line.\";\n else if (extra.length > 20) e.extraRepositories = \"Use 20 repositories or fewer.\";\n const board = d.board.trim();\n if (board && !/^[1-9][0-9]*$/.test(board)) e.board = \"Enter the board's number, as in its URL.\";\n if (backlogOf(d.backlog).length > 20) e.backlog = \"Use 20 columns or fewer.\";\n return e;\n}\n\n/** The full request body for POST and PATCH /api/scopes: the scope's name and its source. */\nexport function bodyOf(d: GitHubSourceDraft): { name: string; source: GitHubSourceInput } {\n const repos = lines(d.repositories);\n const board = d.board.trim();\n const source: GitHubSourceInput = {\n hostId: d.hostId,\n owner: d.owner.trim(),\n repositories: repos.length ? repos : null,\n extraRepositories: lines(d.extraRepositories),\n board: board\n ? {\n projectNumber: Number(board),\n statusField: d.statusField.trim() || \"Status\",\n onStart: d.onStart.trim() || null,\n onReview: d.onReview.trim() || null,\n backlog: backlogOf(d.backlog),\n priorityField: d.priorityField.trim() || null,\n }\n : null,\n follow: board ? d.follow : \"assigned\",\n writeBack: board ? d.writeBack : false,\n moveShared: d.moveShared,\n worktrees: d.worktrees,\n enabled: d.enabled,\n };\n return { name: d.name.trim(), source };\n}\n\n/** Label/value rows describing a scope's GitHub source. */\nexport function sourceFacts(t: GitHubSource, hostName: string): [string, string][] {\n const moves = (() => {\n if (!t.writeBack || !t.board) return \"Off\";\n const parts = [\n t.board.onStart ? `To \"${t.board.onStart}\" when work starts` : null,\n t.board.onReview\n ? `${t.board.onStart ? \"to\" : \"To\"} \"${t.board.onReview}\" when a pull request opens`\n : null,\n ].filter((p): p is string => !!p);\n if (parts.length === 0) return \"On, but no columns are set\";\n return `${parts.join(\", \")}${t.moveShared ? \"\" : \"; never shared cards\"}`;\n })();\n const rows: [string, string][] = [\n [\n \"GitHub\",\n `${t.owner}${t.repositories ? `: ${t.repositories.join(\", \")}` : \" (all repositories)\"}${\n t.extraRepositories?.length ? `, plus ${t.extraRepositories.join(\", \")}` : \"\"\n }`,\n ],\n [\n \"Host\",\n t.login ? `${hostName}, signed in to GitHub as ${t.login}` : `${hostName}, not synced yet`,\n ],\n ];\n if (t.board) {\n rows.push([\n \"Board\",\n `#${t.board.projectNumber}, field ${t.board.statusField}${\n t.board.priorityField ? `, priority ${t.board.priorityField}` : \"\"\n }${sourceBacklog(t).length ? `; hides ${sourceBacklog(t).join(\", \")} until started` : \"\"}`,\n ]);\n rows.push([\"Moves cards\", moves]);\n }\n return rows;\n}\n","import type { Scope, ScopeInput, ScopePatch } from \"@switchyard/protocol\";\nimport {\n bodyOf,\n draftOf,\n type GitHubSourceDraft,\n type GitHubSourceDraftErrors,\n validateDraft,\n} from \"./githubSourceLogic\";\n\n/** What a scope contains: the one choice that decides its mode and whether GitHub feeds it. */\nexport type ScopeContents = \"projects\" | \"pins\" | \"github\";\n\nexport interface ScopeDraft {\n name: string;\n contents: ScopeContents;\n /** Checked projects; empty: any. Shown under \"projects\"; sent under \"pins\" too, so the choice survives a round trip. */\n projectIds: string[];\n /** Checked hosts; empty: any. */\n hostIds: string[];\n github: GitHubSourceDraft;\n}\nexport type ScopeDraftErrors = GitHubSourceDraftErrors;\n\nexport const CONTENTS_OPTIONS: { value: ScopeContents; label: string; explanation: string }[] = [\n {\n value: \"projects\",\n label: \"Projects you choose\",\n explanation: \"Sessions in the projects you check, plus any session you pin.\",\n },\n { value: \"pins\", label: \"Pins only\", explanation: \"Only the sessions you pin to it.\" },\n {\n value: \"github\",\n label: \"GitHub issues\",\n explanation: \"Issues assigned to you or on a Projects board, and the sessions working on them.\",\n },\n];\n\nexport function contentsOf(scope: Scope | null): ScopeContents {\n if (scope?.source) return \"github\";\n return scope?.mode === \"pinned\" ? \"pins\" : \"projects\";\n}\n\nexport function scopeDraftOf(scope: Scope | null, defaultHostId: string): ScopeDraft {\n return {\n name: scope?.name ?? \"\",\n contents: contentsOf(scope),\n projectIds: scope?.projectIds ?? [],\n hostIds: scope?.hostIds ?? [],\n github: draftOf(scope, defaultHostId),\n };\n}\n\nexport function validateScopeDraft(d: ScopeDraft): ScopeDraftErrors {\n const all = validateDraft({ ...d.github, name: d.name });\n if (d.contents === \"github\") return all;\n return all.name ? { name: all.name } : {};\n}\n\n/** The body for POST (new) or PATCH (`scope` given) /api/scopes. */\nexport function scopeBodyOf(d: ScopeDraft, scope: Scope | null): ScopeInput & ScopePatch {\n const name = d.name.trim();\n const hostIds = d.hostIds.length ? d.hostIds : null;\n if (d.contents === \"github\") {\n // GitHub keeps the projects of a GitHub scope: sending projectIds would be refused.\n return { name, mode: \"all\", hostIds, source: bodyOf({ ...d.github, name }).source };\n }\n return {\n name,\n mode: d.contents === \"pins\" ? \"pinned\" : \"all\",\n projectIds: d.projectIds.length ? d.projectIds : null,\n hostIds,\n ...(scope?.source ? { source: null } : {}),\n };\n}\n\n/** True when saving removes a GitHub source the scope has now. */\nexport function disconnects(d: ScopeDraft, scope: Scope | null): boolean {\n return !!scope?.source && d.contents !== \"github\";\n}\n","import type { Scope } from \"@switchyard/protocol\";\nimport { useMemo, useState } from \"react\";\nimport { ROUTES } from \"../../app/routes\";\nimport { Button } from \"../../components/ui/Button\";\nimport { Checkbox } from \"../../components/ui/Checkbox\";\nimport { Field } from \"../../components/ui/Field\";\nimport { ConfirmDialog, Dialog } from \"../../components/ui/Overlay\";\nimport { RadioCards } from \"../../components/ui/RadioCards\";\nimport { ErrorState } from \"../../components/ui/states\";\nimport { TextInput } from \"../../components/ui/TextArea\";\nimport { TextLink } from \"../../components/ui/TextLink\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { apiDelete, apiPatch, apiPost, errorMessage, isApiError } from \"../../sync/api\";\nimport { useHosts, useProjects, useSyncStore } from \"../../sync/store\";\nimport { shownIn } from \"./describe\";\nimport { GitHubSourceFields } from \"./GitHubSourceFields\";\nimport type { GitHubSourceDraft } from \"./githubSourceLogic\";\nimport { useScopeDescriber } from \"./ScopeSelect\";\nimport {\n CONTENTS_OPTIONS,\n disconnects,\n type ScopeDraft,\n type ScopeDraftErrors,\n scopeBodyOf,\n scopeDraftOf,\n validateScopeDraft,\n} from \"./scopeFormLogic\";\n\n/** What a scope contains and the clients that mirror it. */\nfunction ScopeAbout({\n scope,\n describe,\n onNavigate,\n}: {\n scope: Scope;\n describe: (v: Scope) => string;\n onNavigate: () => void;\n}) {\n const clients = useSyncStore((s) => s.clients);\n const hosts = useSyncStore((s) => s.hosts);\n const shown = shownIn(scope, Object.values(clients), hosts);\n const session = scope.name.trim().replace(/\\s+/g, \"-\");\n return (\n <dl\n data-testid=\"scope-about\"\n className=\"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-md bg-surface-2 px-3 py-2 text-sm\"\n >\n <dt className=\"text-muted\">Contains</dt>\n <dd className=\"min-w-0\">{describe(scope)}</dd>\n <dt className=\"text-muted\">Mirrored in</dt>\n <dd className=\"flex min-w-0 flex-col gap-0.5\">\n {shown ?? <span>No client.</span>}\n {!shown && (\n <>\n <span className=\"text-muted\">\n To mirror it in herdr, choose it in{\" \"}\n <TextLink to={ROUTES.settings(\"clients\")} onClick={onNavigate}>\n Settings › Clients\n </TextLink>\n , or run:\n </span>\n <code className=\"block break-all text-xs\">\n switchyard clients bind herdr:{session} --scope {scope.name}\n </code>\n </>\n )}\n </dd>\n </dl>\n );\n}\n\nfunction toggle(list: string[], id: string, on: boolean): string[] {\n return on ? [...list, id] : list.filter((x) => x !== id);\n}\n\n/**\n * Create, edit and delete scopes. `editing` is a scope id, \"new\", or null (closed). Empty project\n * and host selections mean \"any\".\n */\nexport function ScopeDialog({\n editing,\n onClose,\n onSaved,\n}: {\n editing: string | \"new\" | null;\n onClose: () => void;\n onSaved: (id: string) => void;\n}) {\n const { scopes, describe } = useScopeDescriber();\n const projects = useProjects();\n const hosts = useHosts();\n const issues = useSyncStore((s) => s.issues);\n const defaultHost = (hosts.find((h) => h.connectivity === \"connected\") ?? hosts[0])?.id ?? \"\";\n const scope: Scope | null = editing && editing !== \"new\" ? (scopes[editing] ?? null) : null;\n const key = editing ?? \"closed\";\n const [draftKey, setDraftKey] = useState<string | null>(null);\n const [draft, setDraft] = useState<ScopeDraft>(() => scopeDraftOf(null, defaultHost));\n const [errors, setErrors] = useState<ScopeDraftErrors>({});\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<unknown>(null);\n const [confirmDelete, setConfirmDelete] = useState(false);\n if (draftKey !== key) {\n setDraftKey(key);\n setDraft(scopeDraftOf(scope, defaultHost));\n setErrors({});\n setError(null);\n setConfirmDelete(false);\n }\n const columns = useMemo(() => {\n if (!scope) return [];\n const withBoard = Object.values(issues).find((x) => x.scopeId === scope.id && x.board);\n return withBoard?.board?.options.map((o) => o.name) ?? [];\n }, [issues, scope]);\n const setGithub = <K extends keyof GitHubSourceDraft>(k: K, v: GitHubSourceDraft[K]) =>\n setDraft((d) => ({ ...d, github: { ...d.github, [k]: v } }));\n\n const save = async () => {\n const found = validateScopeDraft(draft);\n setErrors(found);\n if (Object.keys(found).length > 0) return;\n setBusy(true);\n setError(null);\n const body = scopeBodyOf(draft, scope);\n try {\n const saved = scope\n ? await apiPatch<Scope>(`/api/scopes/${encodeURIComponent(scope.id)}`, body)\n : await apiPost<Scope>(\"/api/scopes\", body);\n toast.success(`Scope ${saved.name} saved`);\n onSaved(saved.id);\n onClose();\n } catch (e) {\n setError(e);\n } finally {\n setBusy(false);\n }\n };\n const remove = async () => {\n if (!scope) return;\n setBusy(true);\n try {\n await apiDelete(`/api/scopes/${encodeURIComponent(scope.id)}`);\n toast.success(`Scope ${scope.name} deleted`);\n setConfirmDelete(false);\n onClose();\n } catch (e) {\n setError(e);\n } finally {\n setBusy(false);\n }\n };\n\n const conflict = isApiError(error, \"conflict\") ? errorMessage(error) : null;\n const open = editing !== null;\n return (\n <>\n <Dialog\n open={open && !confirmDelete}\n onClose={onClose}\n title={scope ? \"Edit scope\" : \"New scope\"}\n description=\"A scope is a named part of your work, shown on Sessions and the Board.\"\n footer={\n <>\n {scope && (\n <Button variant=\"danger\" onClick={() => setConfirmDelete(true)} className=\"mr-auto\">\n Delete\n </Button>\n )}\n <Button onClick={onClose}>Cancel</Button>\n <Button\n variant=\"primary\"\n busy={busy}\n disabled={!draft.name.trim()}\n onClick={() => void save()}\n >\n {disconnects(draft, scope) ? \"Save and disconnect GitHub\" : \"Save\"}\n </Button>\n </>\n }\n >\n <div data-testid=\"scope-form\" className=\"flex flex-col gap-3\">\n {scope && <ScopeAbout scope={scope} describe={describe} onNavigate={onClose} />}\n <Field label=\"Name\" id=\"sy-scope-name\" error={errors.name ?? conflict}>\n {(p) => (\n <TextInput\n {...p}\n value={draft.name}\n maxLength={60}\n onChange={(e) => setDraft({ ...draft, name: e.target.value })}\n />\n )}\n </Field>\n <RadioCards\n legend=\"Contains\"\n columns={1}\n value={draft.contents}\n options={CONTENTS_OPTIONS}\n onChange={(contents) => setDraft({ ...draft, contents })}\n />\n {disconnects(draft, scope) && (\n <p\n role=\"status\"\n className=\"rounded-md border border-border bg-warning-soft px-3 py-2 text-sm\"\n >\n Saving disconnects GitHub: this scope's issues leave the Board. Its sessions and\n worktrees stay.\n </p>\n )}\n {draft.contents === \"projects\" && (\n <fieldset className=\"flex flex-col gap-1\">\n <legend className=\"text-sm font-medium\">Projects (none checked: any)</legend>\n {projects.map((p) => (\n <Checkbox\n key={p.id}\n label={p.name}\n checked={draft.projectIds.includes(p.id)}\n onChange={(on) =>\n setDraft({ ...draft, projectIds: toggle(draft.projectIds, p.id, on) })\n }\n />\n ))}\n </fieldset>\n )}\n {draft.contents === \"github\" && (\n <GitHubSourceFields\n draft={draft.github}\n errors={errors}\n set={setGithub}\n hosts={hosts}\n columns={columns}\n />\n )}\n {/* Where sessions run is the navigator's Where filter; only scopes that already\n limit hosts keep this, so they can be changed or cleared. */}\n {draft.contents !== \"pins\" && !!scope?.hostIds?.length && (\n <fieldset className=\"flex flex-col gap-1\">\n <legend className=\"text-sm font-medium\">Hosts (none checked: any)</legend>\n {hosts.map((h) => (\n <Checkbox\n key={h.id}\n label={h.name}\n checked={draft.hostIds.includes(h.id)}\n onChange={(on) =>\n setDraft({ ...draft, hostIds: toggle(draft.hostIds, h.id, on) })\n }\n />\n ))}\n </fieldset>\n )}\n {error !== null && !conflict && (\n <ErrorState compact title=\"Could not save\" error={errorMessage(error)} />\n )}\n </div>\n </Dialog>\n <ConfirmDialog\n open={open && confirmDelete}\n onClose={() => setConfirmDelete(false)}\n title=\"Delete this scope?\"\n description={`Sessions are not affected. Clients mirroring it then mirror nothing and keep their tabs.${scope?.source ? \" Its issues are removed from the Board.\" : \"\"}`}\n confirmLabel=\"Delete scope\"\n busy={busy}\n error={error}\n onConfirm={() => void remove()}\n />\n </>\n );\n}\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(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