@spencerboucher/switchyard 0.6.0 → 0.8.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 +6 -6
- package/dist/bridge/switchyard-terminal.js +158 -2
- package/dist/switchyard.mjs +1332 -769
- package/package.json +1 -1
- package/web-dist/assets/AutomationView-GCthHkym.js +2 -0
- package/web-dist/assets/AutomationView-GCthHkym.js.map +1 -0
- package/web-dist/assets/Badge-CEMI3YyI.js +2 -0
- package/web-dist/assets/Badge-CEMI3YyI.js.map +1 -0
- package/web-dist/assets/InteractionCard-DaLqafmA.js +6 -0
- package/web-dist/assets/InteractionCard-DaLqafmA.js.map +1 -0
- package/web-dist/assets/{Menu-GymfuHGP.js → Menu-BcKiEc6X.js} +2 -2
- package/web-dist/assets/{Menu-GymfuHGP.js.map → Menu-BcKiEc6X.js.map} +1 -1
- package/web-dist/assets/{SegmentedControl-ChdVilXb.js → SegmentedControl-BZPzNU08.js} +2 -2
- package/web-dist/assets/{SegmentedControl-ChdVilXb.js.map → SegmentedControl-BZPzNU08.js.map} +1 -1
- package/web-dist/assets/Tabs-COH5EMql.js +184 -0
- package/web-dist/assets/Tabs-COH5EMql.js.map +1 -0
- package/web-dist/assets/TextArea-CeMEPZn4.js +2 -0
- package/web-dist/assets/TextArea-CeMEPZn4.js.map +1 -0
- package/web-dist/assets/attention-BAdea2kA.js +2 -0
- package/web-dist/assets/attention-BAdea2kA.js.map +1 -0
- package/web-dist/assets/automations-DSFUzB0w.js +2 -0
- package/web-dist/assets/automations-DSFUzB0w.js.map +1 -0
- package/web-dist/assets/board-eQ3H8yCp.js +10 -0
- package/web-dist/assets/board-eQ3H8yCp.js.map +1 -0
- package/web-dist/assets/c-Cz4nF6n_.js +1 -0
- package/web-dist/assets/c-SSSlmE39.js +2 -0
- package/web-dist/assets/c-SSSlmE39.js.map +1 -0
- package/web-dist/assets/code-D7JmYMKe.js +13 -0
- package/web-dist/assets/code-D7JmYMKe.js.map +1 -0
- package/web-dist/assets/cpp-Cts1PyIS.js +2 -0
- package/web-dist/assets/cpp-Cts1PyIS.js.map +1 -0
- package/web-dist/assets/cpp-DzjeI0uH.js +1 -0
- package/web-dist/assets/css-BGIxQoYs.js +2 -0
- package/web-dist/assets/css-BGIxQoYs.js.map +1 -0
- package/web-dist/assets/css-DgaLhXQH.js +1 -0
- package/web-dist/assets/describe-C1YimBXJ.js +5 -0
- package/web-dist/assets/describe-C1YimBXJ.js.map +1 -0
- package/web-dist/assets/diff-woXpYk--.js +2 -0
- package/web-dist/assets/diff-woXpYk--.js.map +1 -0
- package/web-dist/assets/dist-B_RpNOcK.js +56 -0
- package/web-dist/assets/dist-B_RpNOcK.js.map +1 -0
- package/web-dist/assets/dockerfile-IyjqRm3v.js +2 -0
- package/web-dist/assets/dockerfile-IyjqRm3v.js.map +1 -0
- package/web-dist/assets/enroll-1OCy5r50.js +2 -0
- package/web-dist/assets/enroll-1OCy5r50.js.map +1 -0
- package/web-dist/assets/github-dark-C-LZuMrd.js +2 -0
- package/web-dist/assets/github-dark-C-LZuMrd.js.map +1 -0
- package/web-dist/assets/github-light-EUqPIrTm.js +2 -0
- package/web-dist/assets/github-light-EUqPIrTm.js.map +1 -0
- package/web-dist/assets/go-rLFTqkRN.js +2 -0
- package/web-dist/assets/go-rLFTqkRN.js.map +1 -0
- package/web-dist/assets/html-BMn1ogTm.js +2 -0
- package/web-dist/assets/html-BMn1ogTm.js.map +1 -0
- package/web-dist/assets/html-BWDvXlHg.js +1 -0
- package/web-dist/assets/index-BhpEXLav.js +11 -0
- package/web-dist/assets/index-BhpEXLav.js.map +1 -0
- package/web-dist/assets/index-DUeOwDZ6.css +2 -0
- package/web-dist/assets/java-BtIQNnN0.js +2 -0
- package/web-dist/assets/java-BtIQNnN0.js.map +1 -0
- package/web-dist/assets/java-_ATy9zCa.js +1 -0
- package/web-dist/assets/javascript-BzbQS41l.js +2 -0
- package/web-dist/assets/javascript-BzbQS41l.js.map +1 -0
- package/web-dist/assets/javascript-CpIGwZ_Y.js +1 -0
- package/web-dist/assets/json-qhed-kSA.js +2 -0
- package/web-dist/assets/json-qhed-kSA.js.map +1 -0
- package/web-dist/assets/jsonc-CYpm1nAK.js +2 -0
- package/web-dist/assets/jsonc-CYpm1nAK.js.map +1 -0
- package/web-dist/assets/jsx-C4yDKi0A.js +1 -0
- package/web-dist/assets/jsx-D3KKoC5L.js +2 -0
- package/web-dist/assets/jsx-D3KKoC5L.js.map +1 -0
- package/web-dist/assets/logic-CBvFOyIo.js +2 -0
- package/web-dist/assets/logic-CBvFOyIo.js.map +1 -0
- package/web-dist/assets/lua-DjuecEsk.js +2 -0
- package/web-dist/assets/lua-DjuecEsk.js.map +1 -0
- package/web-dist/assets/lua-fPRBWD-V.js +1 -0
- package/web-dist/assets/{more-CRGJsz6E.js → more-RjVyxPaz.js} +2 -2
- package/web-dist/assets/{more-CRGJsz6E.js.map → more-RjVyxPaz.js.map} +1 -1
- package/web-dist/assets/now-CDjeFSLD.js +2 -0
- package/web-dist/assets/now-CDjeFSLD.js.map +1 -0
- package/web-dist/assets/python-gzcpVVnB.js +2 -0
- package/web-dist/assets/python-gzcpVVnB.js.map +1 -0
- package/web-dist/assets/ruby-Bx-U2qjP.js +2 -0
- package/web-dist/assets/ruby-Bx-U2qjP.js.map +1 -0
- package/web-dist/assets/rust-DpiIf5JO.js +2 -0
- package/web-dist/assets/rust-DpiIf5JO.js.map +1 -0
- package/web-dist/assets/scss-8bKmll0B.js +2 -0
- package/web-dist/assets/scss-8bKmll0B.js.map +1 -0
- package/web-dist/assets/send-BKjswHxB.js +2 -0
- package/web-dist/assets/send-BKjswHxB.js.map +1 -0
- package/web-dist/assets/settings-tH4UuIfJ.js +7 -0
- package/web-dist/assets/settings-tH4UuIfJ.js.map +1 -0
- package/web-dist/assets/shared-CRX6KSBm.js +3 -0
- package/web-dist/assets/shared-CRX6KSBm.js.map +1 -0
- package/web-dist/assets/shellscript-CVTB3cr6.js +1 -0
- package/web-dist/assets/shellscript-CqHdAlCp.js +2 -0
- package/web-dist/assets/shellscript-CqHdAlCp.js.map +1 -0
- package/web-dist/assets/sliders-horizontal-DAoirila.js +2 -0
- package/web-dist/assets/sliders-horizontal-DAoirila.js.map +1 -0
- package/web-dist/assets/sql-CNu3Or2W.js +2 -0
- package/web-dist/assets/sql-CNu3Or2W.js.map +1 -0
- package/web-dist/assets/sql-CfM2IJm3.js +1 -0
- package/web-dist/assets/states-DXozulGZ.js +2 -0
- package/web-dist/assets/states-DXozulGZ.js.map +1 -0
- package/web-dist/assets/swift-CyEgAFGc.js +2 -0
- package/web-dist/assets/swift-CyEgAFGc.js.map +1 -0
- package/web-dist/assets/terminal-login-CW2rE50W.js +2 -0
- package/web-dist/assets/terminal-login-CW2rE50W.js.map +1 -0
- package/web-dist/assets/toml-CcmNWLt0.js +2 -0
- package/web-dist/assets/toml-CcmNWLt0.js.map +1 -0
- package/web-dist/assets/tsx-BOvsFOI6.js +2 -0
- package/web-dist/assets/tsx-BOvsFOI6.js.map +1 -0
- package/web-dist/assets/tsx-CGosfAUg.js +1 -0
- package/web-dist/assets/typescript-Bb1J8qyy.js +1 -0
- package/web-dist/assets/typescript-j_1H8WHN.js +2 -0
- package/web-dist/assets/typescript-j_1H8WHN.js.map +1 -0
- package/web-dist/assets/useNow-C_B7JgMM.js +2 -0
- package/web-dist/assets/{useNow-Bc_NlDY3.js.map → useNow-C_B7JgMM.js.map} +1 -1
- package/web-dist/assets/xml-DuKfbPI6.js +1 -0
- package/web-dist/assets/xml-WY0zc4PG.js +2 -0
- package/web-dist/assets/xml-WY0zc4PG.js.map +1 -0
- package/web-dist/assets/yaml-DDA_XMNu.js +1 -0
- package/web-dist/assets/yaml-DijMHRDA.js +2 -0
- package/web-dist/assets/yaml-DijMHRDA.js.map +1 -0
- package/web-dist/index.html +4 -3
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-DgZn3ltn.js +0 -2
- package/web-dist/assets/AutomationView-DgZn3ltn.js.map +0 -1
- package/web-dist/assets/InteractionCard-cvPWKSu1.js +0 -4
- package/web-dist/assets/InteractionCard-cvPWKSu1.js.map +0 -1
- package/web-dist/assets/Markdown-jXkvZeRp.js +0 -31
- package/web-dist/assets/Markdown-jXkvZeRp.js.map +0 -1
- package/web-dist/assets/Overlay-oYnnwvFM.js +0 -2
- package/web-dist/assets/Overlay-oYnnwvFM.js.map +0 -1
- package/web-dist/assets/TextArea-BsQHOQMe.js +0 -2
- package/web-dist/assets/TextArea-BsQHOQMe.js.map +0 -1
- package/web-dist/assets/attention-Bxg9W15n.js +0 -2
- package/web-dist/assets/attention-Bxg9W15n.js.map +0 -1
- package/web-dist/assets/automations-DdB97dnL.js +0 -2
- package/web-dist/assets/automations-DdB97dnL.js.map +0 -1
- package/web-dist/assets/board-s4LuDPcg.js +0 -10
- package/web-dist/assets/board-s4LuDPcg.js.map +0 -1
- package/web-dist/assets/code-B0KXn7lD.js +0 -8
- package/web-dist/assets/code-B0KXn7lD.js.map +0 -1
- package/web-dist/assets/describe-C_3FJuSs.js +0 -5
- package/web-dist/assets/describe-C_3FJuSs.js.map +0 -1
- package/web-dist/assets/dist-Bgkh2hc5.js +0 -56
- package/web-dist/assets/dist-Bgkh2hc5.js.map +0 -1
- package/web-dist/assets/enroll-DijmoolY.js +0 -2
- package/web-dist/assets/enroll-DijmoolY.js.map +0 -1
- package/web-dist/assets/index-C5n2QB-Y.css +0 -2
- package/web-dist/assets/index-Cf6ZUCfK.js +0 -11
- package/web-dist/assets/index-Cf6ZUCfK.js.map +0 -1
- package/web-dist/assets/logic-D_Eq9DMW.js +0 -2
- package/web-dist/assets/logic-D_Eq9DMW.js.map +0 -1
- package/web-dist/assets/now-D6lDofYy.js +0 -2
- package/web-dist/assets/now-D6lDofYy.js.map +0 -1
- package/web-dist/assets/settings-Csal1F-W.js +0 -8
- package/web-dist/assets/settings-Csal1F-W.js.map +0 -1
- package/web-dist/assets/sliders-horizontal-S3tmwxsP.js +0 -2
- package/web-dist/assets/sliders-horizontal-S3tmwxsP.js.map +0 -1
- package/web-dist/assets/states-DrTQuYXw.js +0 -2
- package/web-dist/assets/states-DrTQuYXw.js.map +0 -1
- package/web-dist/assets/useNow-Bc_NlDY3.js +0 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{_ as e,a as t,f as n,i as r,m as i,n as a,o,p as s,t as c,u as l}from"./jsx-runtime-D13aM9HY.js";import{n as u,t as d}from"./Badge-CEMI3YyI.js";import{A as f,E as p,G as m,I as h,M as g,N as _,O as v,P as y,U as b,V as x,W as S,_ as C,a as w,c as T,d as E,f as D,g as O,h as k,i as A,j,k as M,l as N,m as P,n as F,o as I,p as ee,t as L,u as te,x as ne,y as re}from"./states-DXozulGZ.js";import{n as ie}from"./presence-05bJD5G3.js";import{i as ae,n as oe,r as se,t as R}from"./Menu-BcKiEc6X.js";import{t as ce}from"./arrow-left-C6YWM6y6.js";import{a as le,n as z,o as B,r as ue,s as de,t as fe}from"./Tabs-COH5EMql.js";import{n as pe,t as me}from"./server-SxFxIScj.js";import{n as V,r as H,t as he}from"./sliders-horizontal-DAoirila.js";import{t as U}from"./chevron-right-evVLS6hq.js";import{t as ge}from"./copy-oWgGHmkS.js";import{a as _e,i as ve,n as ye,o as be,r as xe,t as Se}from"./InteractionCard-DaLqafmA.js";import{n as Ce,t as we}from"./pencil-DI8QbCN8.js";import{t as Te}from"./hand-UPoHamrn.js";import{t as Ee}from"./link-2-CaMlUDRG.js";import{t as De}from"./play-CjoDg3ws.js";import{t as Oe}from"./plus-BLP-wIYD.js";import{t as ke}from"./search-C6cn5WOo.js";import{t as Ae}from"./send-BKjswHxB.js";import{t as je}from"./trash-C6X2OLrI.js";import{C as Me,O as Ne,P as Pe,a as Fe,c as Ie,f as W,l as G,m as Le,o as K,r as Re,s as ze,v as Be,x as Ve,y as He}from"./index-BhpEXLav.js";import{a as Ue,i as We,n as Ge,o as Ke,r as qe,s as q,t as Je}from"./TextArea-CeMEPZn4.js";import{l as Ye}from"./dist-B_RpNOcK.js";import{t as Xe}from"./SegmentedControl-BZPzNU08.js";var Ze={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Ze.node;var Qe=a(Ze),$e={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};$e.node;var et=a($e),tt={name:`brain`,size:24,node:[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4`,key:`5nuw1p`}],[`path`,{d:`M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294`,key:`18ldcf`}],[`path`,{d:`M17.996 5.125a4 4 0 012.526 5.77`,key:`1sdu8q`}],[`path`,{d:`M18 18a4 4 0 002-7.465`,key:`7xqqvr`}],[`path`,{d:`M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517`,key:`t46ysz`}],[`path`,{d:`M6 18a4 4 0 01-2-7.465`,key:`1y2m15`}],[`path`,{d:`M6.004 5.125a4 4 0 00-2.526 5.77`,key:`3cw1ss`}]]};tt.node;var nt=a(tt),rt={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};rt.node;var it=a(rt),at={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};at.node;var ot=a(at),st={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};st.node;var ct=a(st),lt={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};lt.node;var ut=a(lt),dt={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};dt.node;var ft=a(dt),pt={name:`ellipsis-vertical`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]],aliases:[`more-vertical`]};pt.node;var mt=a(pt),ht={name:`file-braces`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]],aliases:[`file-json`]};ht.node;var gt=a(ht),_t={name:`file-diff`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]};_t.node;var vt=a(_t),yt={name:`file-image`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]};yt.node;var bt=a(yt),xt={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};xt.node;var St=a(xt),Ct={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};Ct.node;var wt=a(Ct),Tt={name:`folder-open`,size:24,node:[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 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.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]};Tt.node;var Et=a(Tt),Dt={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Dt.node;var Ot=a(Dt),kt={name:`image-plus`,size:24,node:[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};kt.node;var At=a(kt),jt={name:`list-plus`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]};jt.node;var Mt=a(jt),Nt={name:`message-square-plus`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]};Nt.node;var Pt=a(Nt),Ft={name:`mouse-pointer-click`,size:24,node:[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]};Ft.node;var It=a(Ft),Lt={name:`navigation`,size:24,node:[[`polygon`,{points:`3 11 22 2 13 21 11 13 3 11`,key:`1ltx0t`}]]};Lt.node;var Rt=a(Lt),zt={name:`network`,size:24,node:[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]};zt.node;var Bt=a(zt),Vt={name:`panel-right-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]};Vt.node;var Ht=a(Vt),Ut={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};Ut.node;var Wt=a(Ut),Gt={name:`search-x`,size:24,node:[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]};Gt.node;var Kt=a(Gt),qt={name:`send-horizontal`,size:24,node:[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]],aliases:[`send-horizonal`]};qt.node;var Jt=a(qt),Yt={name:`shrink`,size:24,node:[[`path`,{d:`m15 15 6 6m-6-6v4.8m0-4.8h4.8`,key:`17vawe`}],[`path`,{d:`M9 19.8V15m0 0H4.2M9 15l-6 6`,key:`chjx8e`}],[`path`,{d:`M15 4.2V9m0 0h4.8M15 9l6-6`,key:`lav6yq`}],[`path`,{d:`M9 4.2V9m0 0H4.2M9 9 3 3`,key:`1pxi2q`}]]};Yt.node;var Xt=a(Yt),Zt={name:`slash`,size:24,node:[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]};Zt.node;var Qt=a(Zt),$t={name:`text-wrap`,size:24,node:[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]],aliases:[`wrap-text`]};$t.node;var en=a($t),tn={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};tn.node;var nn=a(tn),rn={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};rn.node;var an=a(rn),on={name:`wand-sparkles`,size:24,node:[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]],aliases:[`wand-2`]};on.node;var sn=a(on),J=e(i(),1),Y=c();function cn({value:e,min:t,max:n,onChange:r,label:i,pane:a=`before`,step:o=16,onReset:s,className:c}){let l=(0,J.useRef)(null),u=e=>Math.round(Math.min(n,Math.max(t,e))),d=a===`before`?1:-1;return(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i,"aria-valuenow":Math.round(e),"aria-valuemin":t,"aria-valuemax":n,tabIndex:0,className:k(`group relative z-10 w-1.5 shrink-0 cursor-col-resize touch-none select-none`,`focus-visible:outline-none`,c),onPointerDown:t=>{t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),l.current={x:t.clientX,value:e}},onPointerMove:e=>{l.current&&r(u(l.current.value+d*(e.clientX-l.current.x)))},onPointerUp:e=>{l.current=null,e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{l.current=null},onDoubleClick:s,onKeyDown:i=>{let a=i.shiftKey?o*4:o;if(i.key===`ArrowRight`)r(u(e+d*a));else if(i.key===`ArrowLeft`)r(u(e-d*a));else if(i.key===`Home`)r(t);else if(i.key===`End`)r(n);else if(i.key===`Enter`&&s)s();else return;i.preventDefault()},children:(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border group-hover:w-0.5 group-hover:bg-accent group-focus-visible:w-0.5 group-focus-visible:bg-accent`})})}var ln=(0,J.createContext)({mobile:!1}),un=()=>(0,J.useContext)(ln),dn=[`starting`,`idle`,`running`,`waiting_input`],fn=[`running`,`waiting_input`];function pn(e){return dn.includes(e.runtime)}function mn(e){return fn.includes(e.runtime)}function hn(e){return e.replaceAll(`/`,`-`)}var gn=`.worktrees`;function _n(e,t,n=gn){return`${e.replace(/\/+$/,``)}/${n}/${hn(t.trim())}`}function vn(e){let t=e.trim();return t?/\s/.test(t)?`Branch names cannot contain spaces.`:t.startsWith(`-`)?`Branch names cannot start with '-'.`:t.startsWith(`/`)||t.endsWith(`/`)?`Branch names cannot start or end with '/'.`:t.includes(`..`)?`Branch names cannot contain '..'.`:t.includes(`//`)?`Branch names cannot contain '//'.`:t.endsWith(`.lock`)||t.endsWith(`.`)?`Branch names cannot end with '.lock' or '.'.`:[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)||/[~^:?*[\\]/.test(t)||t.includes(`@{`)?`Branch names cannot contain ~ ^ : ? * [ \\ or '@{'.`:null:`Enter a branch name.`}var yn=[{value:`projects`,label:`Projects`,hint:`Sessions under each project`},{value:`worktrees`,label:`Worktrees`,hint:`Project, then branch or worktree`},{value:`recent`,label:`Recent`,hint:`One list, needs-you first`},{value:`hosts`,label:`Hosts`,hint:`Host, then project`}];function bn(e,t){let n=new Set;for(let t of Object.values(e))t.sessionId&&t.resolvedAt===null&&n.add(t.sessionId);for(let e of Object.values(t))e.state===`pending`&&n.add(e.sessionId);return n}function xn(e){return e.replace(/\/+$/,``).split(`/`).pop()||e}function Sn(e,t){return e?e.branch?e.branch:`${xn(e.path)} (detached)`:t?xn(t):`No workspace`}function Cn(e,t,n,r={}){return{key:e,kind:t,label:n,detail:null,path:null,hostState:null,groups:[],rows:[],sessionCount:0,...r}}function wn(e,t){return t?.name??(e?`Unknown project`:`Other sessions`)}function Tn(e){return e.ws?e.ws.provenance===`main`?null:Sn(e.ws):e.projectId===null?xn(e.session.cwd):null}function En(e){let t=``;for(let n of e.rows)n.session.lastActivityAt>t&&(t=n.session.lastActivityAt);for(let n of e.groups){let e=En(n);e>t&&(t=e)}return t}function Dn(e){let t=e=>e.key.endsWith(`__none`)||e.kind===`host`&&e.label===`Unknown host`?1:0;return e.sort((e,n)=>t(e)-t(n)||e.label.localeCompare(n.label))}function On(e){return e.sessionCount=e.rows.length+e.groups.reduce((e,t)=>e+On(t),0),e.sessionCount}function kn(e,t){let n=t.layout??`projects`,r=t.query.trim().toLowerCase(),i=bn(e.attention,e.interactions),a=[];for(let n of Object.values(e.sessions)){if(n.archivedAt!==null||n.provenance===`subagent`&&!t.showSubagents)continue;let o=i.has(n.id);if(t.filter===`active`&&!pn(n)&&!o||t.filter===`attention`&&!o)continue;let s=n.workspaceId?e.workspaces[n.workspaceId]??null:null,c=n.projectId??s?.projectId??null,l=c?e.projects[c]??null:null,u=s?.hostId??n.hostId,d=e.hosts[u]?.name??`Unknown host`;(!r||[n.title,n.subtitle??``,s?.branch??``,l?.name??``,d,n.cwd].join(`
|
|
2
|
+
`).toLowerCase().includes(r))&&a.push({session:n,attention:o,ws:s,projectId:c,project:l,hostId:u,hostName:d})}a.sort((e,t)=>Number(t.attention)-Number(e.attention)||t.session.lastActivityAt.localeCompare(e.session.lastActivityAt));let o=(e,t)=>({session:e.session,attention:e.attention,...t});if(n===`recent`)return{groups:[],rows:a.map(e=>o(e,{project:wn(e.projectId,e.project),host:e.hostName,branch:Tn(e)}))};if(n===`hosts`){let t=new Map;for(let n of a){let r=t.get(n.hostId);if(!r){let i=e.hosts[n.hostId];r=Cn(`h:${n.hostId}`,`host`,n.hostName,{hostState:i?i.revokedAt?`unreachable`:i.connectivity:`unreachable`}),t.set(n.hostId,r)}let i=`${r.key}/p:${n.projectId??`__none`}`,a=r.groups.find(e=>e.key===i);a||(a=Cn(i,`project`,wn(n.projectId,n.project)),r.groups.push(a)),a.rows.push(o(n,{project:null,host:null,branch:Tn(n)}))}let n=Dn([...t.values()]);for(let e of n)Dn(e.groups),On(e);return{groups:n,rows:[]}}let s=new Map,c=t=>{let n=`p:${t??`__none`}`,r=s.get(n);return r||(r=Cn(n,`project`,wn(t,t?e.projects[t]??null:null)),s.set(n,r)),r};if(n===`projects`){let n=new Map;for(let e of a){let t=c(e.projectId);t.rows.push(o(e,{project:null,host:e.hostName,branch:Tn(e)}));let r=n.get(t)??new Set;r.add(e.hostId),n.set(t,r)}for(let[e,t]of n)if(t.size===1){e.detail=e.rows[0].host;for(let t of e.rows)t.host=null}if(t.filter===`all`&&!r)for(let t of Object.values(e.projects))c(t.id);let i=Dn([...s.values()]);for(let e of i)On(e);return{groups:i,rows:[]}}let l=new Map,u=new Map,d=(t,n,r,i)=>{let a=n?`w:${n.id}`:`w:${t.key}:cwd:${r}:${i}`,o=l.get(a);return o||(o=Cn(a,`workspace`,Sn(n,i),{detail:e.hosts[r]?.name??`Unknown host`,path:n?.path??null}),l.set(a,o),u.set(o,n),t.groups.push(o)),o};for(let e of a)d(c(e.projectId),e.ws,e.hostId,e.session.cwd).rows.push(o(e,{project:null,host:null,branch:null}));if(t.filter===`all`){for(let t of Object.values(e.workspaces)){if(t.archivedAt)continue;let n=e.projects[t.projectId]??null;(!r||[t.branch??``,n?.name??``,t.path].join(`
|
|
3
|
+
`).toLowerCase().includes(r))&&d(c(t.projectId),t,t.hostId,t.path)}if(!r)for(let t of Object.values(e.projects))c(t.id)}let f=Dn([...s.values()]);for(let e of f){e.groups.sort((e,t)=>{let n=En(e),r=En(t);return n===r?(u.get(e)?.provenance===`main`?0:1)-(u.get(t)?.provenance===`main`?0:1)||e.label.localeCompare(t.label):r.localeCompare(n)});let t=e.groups.length===1?e.groups[0]:null;t&&(t.path===null||u.get(t)?.provenance===`main`)&&(e.rows=t.rows,e.detail=t.detail,e.groups=[]),On(e)}return{groups:f,rows:[]}}function An(e){return e.rows.length===0&&e.groups.every(e=>e.sessionCount===0&&e.groups.length===0)}function jn(e){let t=[],n=e=>{for(let r of e)t.push(r.key),n(r.groups)};return n(e.groups),t}var Mn=[`queued`,`dispatching`,`uncertain`,`running`,`waiting_input`,`checking`];function Nn(e,t){if(t.runId&&e[t.runId])return e[t.runId];let n=null;for(let r of Object.values(e))r.sessionId===t.id&&Mn.includes(r.state)&&(!n||r.createdAt>n.createdAt)&&(n=r);return n}function Pn(e){return e?e.controlMode:`none`}var Fn={automation:`Automation`,human:`You have control`,none:`Manual session`};function In(e,t){return e?.revokedAt?`unreachable`:e?.connectivity??t.connectivity}var Ln=`Subagent: view only. Live control is not supported.`;function Rn(e){return e.provenance===`subagent`&&e.readOnly}function zn(e){let{session:t,hostLink:n}=e;return t.readOnly?{reason:Ln}:t.archivedAt?{reason:`Session archived: unarchive it to send`}:n===`connected`?t.runtime===`starting`?{reason:`Starting… you can send once Pi is ready`,pending:!0}:!pn(t)&&!t.nativeHandle?{reason:`Session stopped: no native Pi session to resume`}:t.compacting?{reason:`Compacting context: you can send when it finishes`}:null:{reason:n===`reconnecting`?`Host offline: ${e.hostName} is reconnecting`:`Host offline: ${e.hostName} is unreachable`}}function Bn(e,t){return mn(e)?{prompt:!1,steer:t?.steer===!0,followUp:!t||t.followUp}:{prompt:!0,steer:!1,followUp:!1}}function Vn(e,t,n){let r=new Map(t.map(e=>[e.itemId,e])),i=[],a=new Set;for(let t of e){let e=r.get(t.id)??null;e&&r.delete(t.id),t.kind===`interaction`&&a.add(t.data.interactionId),i.push({type:`item`,key:t.id,item:t,stream:e})}let o=[...r.values()].sort((e,t)=>(e.order??2**53-1)-(t.order??2**53-1));for(let e of o)(e.text||e.thinking||e.toolArgs||e.toolOutput)&&i.push({type:`stream`,key:`stream:${e.itemId}`,stream:e});for(let e of n)a.has(e.id)||i.push({type:`interaction`,key:`interaction:${e.id}`,interaction:e});return i}function Hn(e,t){if(t===null)return e.length;let n=e.findIndex(e=>e.key===t);return n<0?0:e.length-n-1}function Un(e){return`interaction-${e}`}function Wn(e){let t=/^data:([^;,]+)?(;base64)?,(.*)$/s.exec(e);return t?.[2]?{mimeType:t[1]??`application/octet-stream`,data:t[3]??``}:null}function Gn(e){return new Promise((t,n)=>{if(!e.type.startsWith(`image/`)){n(Error(`${e.name} is not an image`));return}if(e.size>10485760){n(Error(`${e.name} is larger than 10 MB`));return}let r=new FileReader;r.onerror=()=>n(r.error??Error(`Could not read ${e.name}`)),r.onload=()=>{let i=Wn(String(r.result??``));i?t({id:`att_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,name:e.name,mimeType:i.mimeType||e.type,data:i.data,size:e.size}):n(Error(`Could not read ${e.name}`))},r.readAsDataURL(e)})}function Kn(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function qn(e,t=6){let n=e.replace(/\n+$/,``).split(`
|
|
4
|
+
`);if(n.length<=t&&e.length<=600)return{text:e,truncated:!1};let r=n.slice(-t).join(`
|
|
5
|
+
`);return{text:r.length>600?r.slice(-600):r,truncated:!0}}var Jn=6;function Yn(e,t,n){if(e<=0)return{nav:t,insp:n};let r=n===null?Jn:12,i=t+(n??0)+r+420-e,a=n,o=t;if(i>0&&a!==null){let e=Math.min(i,a-K.inspector.min);a-=e,i-=e}if(i>0){let e=Math.min(i,o-K.navigator.min);o-=e}return{nav:o,insp:a}}var Xn=[{name:`model`,description:`Switch this session's model`,source:`switchyard`,argumentHint:`<provider>/<model>`},{name:`thinking`,description:`Set the effort (thinking level)`,source:`switchyard`,argumentHint:`<level>`},{name:`compact`,description:`Compact the session context`,source:`switchyard`,argumentHint:`[instructions]`},{name:`name`,description:`Rename this session`,source:`switchyard`,argumentHint:`<name>`},{name:`new`,description:`Start a new session in this workspace`,source:`switchyard`,argumentHint:`[prompt]`},{name:`fork`,description:`Start a new session from one of your messages`,source:`switchyard`,argumentHint:null},{name:`clone`,description:`Copy this conversation into a new session`,source:`switchyard`,argumentHint:null},{name:`tree`,description:`Start a new session from any point in the conversation tree`,source:`switchyard`,argumentHint:null},{name:`resume`,description:`Open another Pi session from this folder`,source:`switchyard`,argumentHint:null},{name:`reload`,description:`Reload extensions, skills, prompts and context files`,source:`switchyard`,argumentHint:null},{name:`export`,description:`Download this session's .jsonl file`,source:`switchyard`,argumentHint:null},{name:`session`,description:`Show session info and stats`,source:`switchyard`,argumentHint:null},{name:`copy`,description:`Copy the last reply to the clipboard`,source:`switchyard`,argumentHint:null}],Zn=[{name:`settings`,description:`Open settings menu`,source:`terminal`,argumentHint:null},{name:`scoped-models`,description:`Enable/disable models for Ctrl+P cycling`,source:`terminal`,argumentHint:null},{name:`import`,description:`Import and resume a session from a JSONL file`,source:`terminal`,argumentHint:null},{name:`share`,description:`Share session via a Radius artifact or a GitHub gist`,source:`terminal`,argumentHint:null},{name:`bug`,description:`Report a bug to the Pi developers`,source:`terminal`,argumentHint:`<description>`},{name:`changelog`,description:`Show changelog entries`,source:`terminal`,argumentHint:null},{name:`hotkeys`,description:`Show all keyboard shortcuts`,source:`terminal`,argumentHint:null},{name:`trust`,description:`Save project trust decision for future sessions`,source:`terminal`,argumentHint:null},{name:`login`,description:`Configure provider authentication`,source:`terminal`,argumentHint:`<provider>`},{name:`logout`,description:`Remove provider authentication`,source:`terminal`,argumentHint:null},{name:`quit`,description:`Quit Pi`,source:`terminal`,argumentHint:null}],Qn=Zn.map(e=>e.name),$n={extension:0,prompt:1,skill:2};function er(e,t){let n=new Set([...e.map(e=>e.name),...t.map(e=>e.name)]),r=Zn.filter(e=>!n.has(e.name)).sort((e,t)=>e.name.localeCompare(t.name)),i=new Set(e.map(e=>e.name)),a=t.filter(e=>!i.has(e.name)).map(e=>({name:e.name,description:e.description,source:e.source,argumentHint:e.argumentHint??null})).sort((e,t)=>($n[e.source]??9)-($n[t.source]??9)||e.name.localeCompare(t.name));return[...e,...a,...r]}function tr(e){return!e.includes(`
|
|
6
|
+
`)&&e.length<=500&&/^\/\S+ /.test(e)}function nr(e,t,n){return e.endsWith(t)?e.slice(0,e.length-t.length)+n+(n.endsWith(` `)?``:` `):e}function rr(e,t){if(e.includes(`
|
|
7
|
+
`))return null;let n=/^\/(\S+)[ \t]/.exec(e);if(!n)return null;let r=t.find(e=>e.name===n[1]);return r?.argumentHint?{name:r.name,hint:r.argumentHint}:null}function ir(e,t,n=50){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[];return e.forEach((e,t)=>{let n=e.name.toLowerCase(),a=n.startsWith(r)?0:n.includes(r)?1:(e.description??``).toLowerCase().includes(r)?2:-1;a>=0&&i.push({e,score:a,i:t})}),i.sort((e,t)=>e.score-t.score||e.i-t.i),i.slice(0,n).map(e=>e.e)}function ar(e){let t=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(e.trim());if(!t)return null;let n=t[1],r=(t[2]??``).trim();switch(n){case`model`:{if(!r)return{kind:`model-picker`};let e=r.indexOf(`/`);return e<=0||e===r.length-1||/\s/.test(r)?{kind:`invalid`,reason:`Use /model <provider>/<model>, or /model alone to pick one`}:{kind:`model`,provider:r.slice(0,e),modelId:r.slice(e+1)}}case`thinking`:{let e=Ye.safeParse(r.toLowerCase());return e.success?{kind:`thinking`,level:e.data}:{kind:`invalid`,reason:`Use /thinking <level>: ${Ye.options.join(`, `)}`}}case`compact`:return{kind:`compact`,instructions:r||null};case`name`:return r?r.length>200?{kind:`invalid`,reason:`Session names are at most 200 characters`}:{kind:`name`,title:r}:{kind:`invalid`,reason:`Use /name <new name>`};case`new`:return{kind:`new`,prompt:r};case`fork`:case`clone`:case`tree`:case`resume`:case`reload`:case`export`:case`session`:case`copy`:return{kind:n};default:return Qn.includes(n)?{kind:`terminal-only`,name:n}:null}}function or(e,t,n=!0){return e.kind===`invalid`?e.reason:e.kind===`terminal-only`?`/${e.name} is a Pi terminal command: open the session's terminal to use it`:e.kind===`compact`&&t?`Wait for the run to finish before compacting`:!n&&(e.kind===`fork`||e.kind===`clone`||e.kind===`tree`||e.kind===`export`||e.kind===`reload`)?`This session has no Pi session file yet`:e.kind===`reload`&&t?`Wait for the run to finish before reloading`:null}function sr(e){let t=e.name??``,n=/^[^:/]{1,40}:\s+(.+)$/.exec(t);n&&(t=n[1]),t||=e.id.slice(e.id.lastIndexOf(`/`)+1);let r=`${e.provider}/`;t.toLowerCase().startsWith(r.toLowerCase())&&(t=t.slice(r.length));let i=/^Claude\s+(.+)$/.exec(t);return i&&(t=i[1]),t||ur(e)}function cr(e,t){return e.filter(e=>e.scoped===!0||t&&e.provider===t.provider&&e.id===t.id)}function lr(e,t){let n=t?e.indexOf(t):-1;return Math.max(n,0)}function ur(e){return e.name??e.id}function dr(e){return[e.name,e.provider&&e.model?`${e.provider}/${e.model}`:e.model??null,e.thinking?`effort ${e.thinking}`:null].filter(Boolean).join(` · `)}function fr(e){let t=e.model;if(!t)return dr(e.profileSnapshot);let n=e.thinking&&t.thinkingLevels.length>1?` · effort ${e.thinking}`:``;return`${ur(t)}${n}`}function pr(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean),r=[];for(let t of e){let e=`${t.provider}/${t.id} ${t.name??``}`.toLowerCase();if(!n.every(t=>e.includes(t)))continue;let i=r.find(e=>e.provider===t.provider);i||(i={provider:t.provider,models:[]},r.push(i)),i.models.push(t)}return r}function mr(e){let t=e.stats?.context;if(!t)return null;let n=e=>e.toLocaleString(`en-US`),r=e.compacting?`Compacting…`:t.percent===null?`—`:`${Math.round(t.percent)}%`,i=t.tokens===null?`Known after the next reply (window ${n(t.window)} tokens)`:`${n(t.tokens)} of ${n(t.window)} tokens`,a=t.percent??0;return{label:r,detail:i,percent:t.percent,tone:a>=90?`danger`:a>=75?`warning`:`muted`}}function hr(e,t){return!t&&e?.capabilities?.sessionControls===!0}var gr=[];function _r(e){let t=y(t=>e?t.hosts[e.hostId]:void 0),n=y(t=>e?.projectId?t.projects[e.projectId]:void 0),r=y(t=>e?.workspaceId?t.workspaces[e.workspaceId]:void 0),i=y(e=>e.runs),a=y(e=>e.tasks),o=y(t=>e?t.adapters[e.hostId]??gr:gr);return(0,J.useMemo)(()=>{if(!e)return null;let s=Nn(i,e),c=e.taskId??s?.taskId??null;return{session:e,host:t,hostName:t?.name??`Unknown host`,link:In(t,e),project:n,workspace:r,run:s,task:c?a[c]:void 0,control:Pn(s),adapters:o}},[e,t,n,r,i,a,o])}function vr(e,t={}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(null),o=(0,J.useRef)(e);o.current=e;let s=(0,J.useRef)(t);s.current=t;let c=(0,J.useRef)(!0);return(0,J.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]),{run:(0,J.useCallback)(async(...e)=>{r(!0),a(null);try{let t=await o.current(...e),{success:n}=s.current,r=typeof n==`function`?n(t):n;return r&&G.success(r),!0}catch(e){return c.current&&a(e),s.current.errorToast&&G.error(S(e)),!1}finally{c.current&&r(!1)}},[]),busy:n,error:i,reset:(0,J.useCallback)(()=>a(null),[])}}function yr(e,t=1e3){let[n,r]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{if(!e)return;r(Date.now());let n=setInterval(()=>r(Date.now()),t);return()=>clearInterval(n)},[e,t]),n}var br=`sy:draft:`,xr=`sy:review:`;function Sr(e){try{return localStorage.getItem(e)}catch{return null}}function Cr(e,t){try{t===null||t===``?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function wr(e){return Sr(br+e)??``}var Tr=new Map;function Er(e,t){let n=Tr.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{Tr.delete(e),Cr(br+e,t)},300);Tr.set(e,{timer:r,text:t})}function Dr(e){let t=Tr.get(e);t&&(clearTimeout(t.timer),Tr.delete(e),Cr(br+e,t.text))}function Or(e,t){let n=Tr.get(e);n&&clearTimeout(n.timer),Tr.delete(e),Cr(br+e,t)}function kr(e){let t=Tr.get(e);t&&clearTimeout(t.timer),Tr.delete(e),Cr(br+e,null)}typeof window<`u`&&window.addEventListener(`pagehide`,()=>{for(let e of[...Tr.keys()])Dr(e)});function Ar(e){let[t,n]=(0,J.useState)(()=>e?wr(e):``),r=(0,J.useRef)(e);return(0,J.useEffect)(()=>(r.current=e,n(e?wr(e):``),()=>{e&&Dr(e)}),[e]),[t,(0,J.useCallback)(e=>{n(e),r.current&&Er(r.current,e)},[]),(0,J.useCallback)(()=>{n(``),r.current&&kr(r.current)},[])]}function jr(e){let t=Sr(xr+e);if(!t)return[];try{let e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}function Mr(e,t){Cr(xr+e,t.length?JSON.stringify(t):null)}function Nr(e){let t=[`Please address these review comments:`,``];for(let n of e){let e=n.line===null?n.file:`${n.file}:${n.line}`;t.push(`- ${e}: ${n.text}`),n.excerpt&&t.push(` > ${n.excerpt}`)}return t.join(`
|
|
8
|
+
`)}function Pr(e){let[t,n]=(0,J.useState)(()=>e?jr(e):[]);(0,J.useEffect)(()=>{n(e?jr(e):[])},[e]);let r=(0,J.useCallback)(t=>{n(t),e&&Mr(e,t)},[e]);return{comments:t,add:(0,J.useCallback)(t=>{let r={...t,id:`rc_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,createdAt:new Date().toISOString()};n(t=>{let n=[...t,r];return e&&Mr(e,n),n})},[e]),remove:(0,J.useCallback)(t=>{n(n=>{let r=n.filter(e=>e.id!==t);return e&&Mr(e,r),r})},[e]),clear:(0,J.useCallback)(()=>r([]),[r]),set:r}}var X=e=>`/api/sessions/${encodeURIComponent(e)}`,Fr=e=>`/api/workspaces/${encodeURIComponent(e)}`,Ir=e=>`/api/tasks/${encodeURIComponent(e)}`,Z={createSession:e=>b(`/api/sessions`,e),prompt:(e,t)=>b(`${X(e)}/prompt`,t),models:(e,t)=>x(`${X(e)}/models`,void 0,t),commands:(e,t)=>x(`${X(e)}/commands`,void 0,t),tree:e=>x(`${X(e)}/tree`),branch:(e,t,n)=>b(`${X(e)}/branch`,{entryId:t,fork:n}),reload:e=>b(`${X(e)}/reload`),exportFile:e=>x(`${X(e)}/export`),importable:e=>x(`/api/sessions/importable`,{hostId:e}),importSession:(e,t,n)=>b(`/api/sessions/import`,{hostId:e,sessionFile:t,projectId:n}),complete:(e,t,n)=>b(`${X(e)}/complete`,{text:t},n),setModel:(e,t,n)=>b(`${X(e)}/model`,{provider:t,modelId:n}),setThinking:(e,t)=>b(`${X(e)}/thinking`,{level:t}),compact:(e,t)=>b(`${X(e)}/compact`,t?{instructions:t}:{}),abort:(e,t=!1)=>b(`${X(e)}/abort`,{clearQueue:t}),stop:e=>b(`${X(e)}/stop`),resume:e=>b(`${X(e)}/resume`),takeover:e=>b(`${X(e)}/takeover`),returnToAutomation:e=>b(`${X(e)}/return-to-automation`),rename:(e,t)=>b(`${X(e)}/rename`,{title:t}),archive:e=>b(`${X(e)}/archive`),unarchive:e=>b(`${X(e)}/unarchive`),adapterAction:(e,t,n,r)=>b(`${X(e)}/adapter-action`,{adapterId:t,actionId:n,payload:r}),diff:(e,t,n)=>x(`${Fr(e)}/diff`,t?{file:t}:void 0,n),files:async(e,t,n)=>Lr(await x(`${Fr(e)}/files`,{dir:t},n)),file:async(e,t,n)=>Rr(await x(`${Fr(e)}/file`,{path:t},n)),refreshWorkspace:e=>b(`${Fr(e)}/refresh`),requestChanges:(e,t)=>b(`${Ir(e)}/request-changes`,{feedback:t}),accept:(e,t)=>b(`${Ir(e)}/accept`,t?{confirm:!0}:{})};function Lr(e){let t=Array.isArray(e)?e:e?.entries??e?.files??[];return Array.isArray(t)?t.filter(e=>e&&typeof e.name==`string`).sort((e,t)=>(e.kind===`dir`?0:1)-(t.kind===`dir`?0:1)||e.name.localeCompare(t.name)):[]}function Rr(e){if(typeof e==`string`)return{text:e,binary:!1,truncated:!1,size:null,base64:null};let t=e??{},n=typeof t.content==`string`?t.content:typeof t.text==`string`?t.text:null;return{text:n,binary:t.binary===!0||n===null&&t.encoding===`base64`,truncated:t.truncated===!0,size:typeof t.size==`number`?t.size:null,base64:t.encoding===`base64`&&typeof t.content==`string`?t.content:null}}function zr(e){let t=e.workspace,n=e.link===`connected`,[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(0),p=t?.id??null;return(0,J.useEffect)(()=>{if(!p||!n)return;let e=new AbortController;return o(!0),c(null),Z.diff(p,void 0,e.signal).then(e=>{i(e),u(new Date().toISOString())}).catch(t=>{e.signal.aborted||c(t)}).finally(()=>{e.signal.aborted||o(!1)}),()=>e.abort()},[p,n,d]),(0,J.useEffect)(()=>{i(null),u(null)},[p]),{result:r,parsed:(0,J.useMemo)(()=>{let e=new Map;if(r?.patch)for(let t of _e(r.patch))e.set(t.path,t);return e},[r]),loading:a,error:s,fetchedAt:l,outdated:!!t&&!!l&&t.updatedAt>l,refresh:(0,J.useCallback)(()=>f(e=>e+1),[])}}function Br(e,t,n){let r=n?t.parsed.get(n):void 0,[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(0),u=e.workspace?.id;if((0,J.useEffect)(()=>{if(!n||r||!u||e.link!==`connected`)return;let t=new AbortController;return s(null),Z.diff(u,n,t.signal).then(e=>{let t=e.patch?_e(e.patch):[];a({path:n,file:t.find(e=>e.path===n)??t[0]??null})}).catch(e=>{t.signal.aborted||s(e)}),()=>t.abort()},[n,r,u,e.link,c,t.fetchedAt]),!n)return{file:null,loading:!1,error:null,retry:()=>{}};if(r)return{file:r,loading:!1,error:null,retry:()=>{}};let d=i?.path===n?i:null;return{file:d?.file??null,loading:!d&&!o,error:o,retry:()=>l(e=>e+1)}}var Vr={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,binary:`Binary`};function Hr({files:e,selected:t,onSelect:n,commentCounts:r,large:i}){return(0,Y.jsx)(`ul`,{"aria-label":`Changed files`,className:`flex min-w-0 flex-col`,children:e.map(e=>{let a=r.get(e.path)??0;return(0,Y.jsx)(`li`,{className:`min-w-0`,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-current":t===e.path?`true`:void 0,onClick:()=>n(e.path),className:k(`tap flex w-full min-w-0 items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-surface-2`,i?`min-h-12 py-2`:`py-1.5`,t===e.path&&`bg-accent-soft`),children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-mono text-xs`,title:e.path,children:e.path}),(0,Y.jsxs)(`span`,{className:`block text-xs text-muted`,children:[Vr[e.status],a>0&&` · ${a} comment${a===1?``:`s`}`]})]}),(0,Y.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,e.added,(0,Y.jsx)(`span`,{className:`sr-only`,children:` added`})]}),` `,(0,Y.jsxs)(`span`,{className:`text-danger`,children:[`-`,e.deleted,(0,Y.jsx)(`span`,{className:`sr-only`,children:` deleted`})]})]}),i&&(0,Y.jsx)(U,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},e.path)})})}function Ur({ctx:e,diff:t,path:n,comments:r,onComment:i}){let a=Br(e,t,n);if(a.error)return(0,Y.jsx)(F,{compact:!0,title:`Could not load this diff`,error:a.error,onRetry:a.retry});if(a.loading)return(0,Y.jsx)(I,{label:`Loading diff…`});if(!a.file)return(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No textual diff for this file.`});let o=new Set(r.filter(e=>e.file===n).map(e=>e.line));return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(ve,{files:[a.file],onLineClick:({file:e,line:t})=>i({file:e,line:t.newLine??t.oldLine,excerpt:t.text}),isLineMarked:({line:e})=>o.has(e.newLine??e.oldLine)}),(0,Y.jsx)(N,{size:`sm`,variant:`ghost`,icon:(0,Y.jsx)(Pt,{className:`size-4`}),onClick:()=>i({file:n,line:null,excerpt:null}),className:`self-start`,children:`Comment on this file`})]})}function Wr({draft:e,mobile:t,onClose:n,onSave:r}){let[i,a]=(0,J.useState)(``),o=(0,J.useRef)(null);(0,J.useEffect)(()=>a(``),[e]);let s=t?Ue:qe,c=e?e.line===null?e.file:`${e.file}:${e.line}`:``;return(0,Y.jsxs)(s,{open:!!e,onClose:n,title:`Add review comment`,description:c,initialFocus:o,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(N,{onClick:n,children:`Cancel`}),(0,Y.jsx)(N,{variant:`primary`,disabled:!i.trim(),onClick:()=>r(i.trim()),children:`Add comment`})]}),children:[e?.excerpt&&(0,Y.jsx)(`pre`,{className:`mb-2 max-w-full overflow-x-auto rounded bg-surface-2 px-2 py-1 font-mono text-xs`,children:e.excerpt}),(0,Y.jsx)(`label`,{htmlFor:`sy-review-comment`,className:`sr-only`,children:`Comment`}),(0,Y.jsx)(Je,{id:`sy-review-comment`,ref:o,minRows:3,value:i,placeholder:`What should change here?`,onChange:e=>a(e.target.value)}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Comments are collected and sent together, never one at a time.`})]})}function Gr({ctx:e,review:t}){let{session:n,task:r}=e,[i,a]=(0,J.useState)(``),o=zn({session:n,hostLink:e.link,hostName:e.hostName}),s=vr(()=>Z.prompt(n.id,{text:Nr(t.comments),mode:mn(n)?`followUp`:`prompt`}),{success:`Review comments sent as one follow-up.`}),c=[...i.trim()?[i.trim()]:[],...t.comments.map(e=>`${e.line===null?e.file:`${e.file}:${e.line}`}: ${e.text}`)],l=vr(()=>Z.requestChanges(r.id,c),{success:`Changes requested. The task stays in Review until a new attempt starts.`}),u=vr(e=>Z.accept(r.id,e),{success:`Task accepted and marked Done.`}),d=m(u.error,`invalid_transition`)&&u.error.details?.needsConfirm===!0,f=r?.state===`review`,p=t.comments.length===0?`Add comments by selecting diff lines`:o?.reason;return(0,Y.jsxs)(`section`,{"aria-label":`Review`,className:`flex min-w-0 flex-col gap-2 border-t border-border pt-3`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[`Review comments`,t.comments.length>0&&` (${t.comments.length})`]}),t.comments.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`Select a diff line to add a comment.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.comments.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 rounded-md border border-border px-2 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.line===null?e.file:`${e.file}:${e.line}`}),(0,Y.jsx)(`p`,{className:`text-sm break-words whitespace-pre-wrap`,children:e.text})]}),(0,Y.jsx)(q,{size:`sm`,label:`Remove comment`,icon:(0,Y.jsx)(je,{className:`size-3.5`}),onClick:()=>t.remove(e.id)})]},e.id))}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(N,{size:`sm`,variant:f?`secondary`:`primary`,icon:(0,Y.jsx)(Ae,{className:`size-3.5`}),disabled:!!p,busy:s.busy,onClick:()=>void s.run().then(e=>e&&t.clear()),children:`Send as one follow-up`}),t.comments.length>0&&(0,Y.jsx)(N,{size:`sm`,variant:`ghost`,onClick:t.clear,children:`Clear all`})]}),p&&t.comments.length>0&&(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:p}),s.error!==null&&(0,Y.jsx)(F,{compact:!0,title:`Comments not sent; they are kept.`,error:S(s.error),onRetry:()=>void s.run().then(e=>e&&t.clear())}),r&&f&&(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 rounded-md border border-border p-3`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[`Task review: `,r.title]}),(0,Y.jsx)(`label`,{htmlFor:`sy-overall-feedback`,className:`text-xs font-medium text-muted`,children:`Overall feedback (optional, sent with the comments above)`}),(0,Y.jsx)(Je,{id:`sy-overall-feedback`,minRows:2,value:i,onChange:e=>a(e.target.value)}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(N,{size:`sm`,icon:(0,Y.jsx)(nn,{className:`size-3.5`}),disabled:c.length===0,busy:l.busy,onClick:()=>void l.run().then(e=>{e&&(t.clear(),a(``))}),children:`Request changes`}),(0,Y.jsx)(N,{size:`sm`,variant:`primary`,icon:(0,Y.jsx)(pe,{className:`size-3.5`}),busy:u.busy,onClick:()=>void u.run(!1),children:`Accept task`})]}),c.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Request changes needs at least one comment.`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Accepting marks the task Done. It does not merge or push.`}),l.error!==null&&(0,Y.jsx)(F,{compact:!0,title:`Could not request changes`,error:S(l.error)}),u.error!==null&&(d?(0,Y.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 rounded-md bg-warning-soft p-2 text-sm`,children:[(0,Y.jsx)(`p`,{className:`break-words`,children:S(u.error)}),(0,Y.jsx)(N,{size:`sm`,variant:`primary`,className:`self-start`,busy:u.busy,onClick:()=>void u.run(!0),children:`Accept anyway`})]}):(0,Y.jsx)(F,{compact:!0,title:`Could not accept`,error:S(u.error)}))]}),r?.review.changesRequested&&r.state===`review`&&(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Changes requested. The task stays in Review until a new attempt is requested.`})]})}function Kr(e){return(0,J.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.file,(t.get(n.file)??0)+1);return t},[e])}function qr({ctx:e}){return e.workspace?(0,Y.jsx)(A,{compact:!0,hostName:e.hostName,connectivity:e.link===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:e.host?.lastSeenAt,detail:`Changes are read from the host; they load when it reconnects.`}):(0,Y.jsx)(T,{capability:`Changes`,reason:`This session is not linked to a Switchyard workspace (it runs in ${e.session.cwd}).`,fallback:`Open a session in a project workspace to review changes.`})}function Jr({diff:e}){return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-muted`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[e.result?`Against ${e.result.base}`:``,e.fetchedAt&&` · updated ${P(e.fetchedAt)}`,e.outdated&&` · workspace changed since`]}),(0,Y.jsx)(N,{size:`sm`,variant:e.outdated?`secondary`:`ghost`,icon:(0,Y.jsx)(C,{className:`size-3.5`}),busy:e.loading,onClick:e.refresh,children:e.loading?`Refreshing…`:`Refresh`})]})}function Yr({ctx:e}){let t=zr(e),n=Pr(e.session.id),r=Kr(n.comments),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),c=t.result?.files??[];return!e.workspace||e.link!==`connected`?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(qr,{ctx:e}),n.comments.length>0&&(0,Y.jsx)(Gr,{ctx:e,review:n})]}):(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsx)(Jr,{diff:t}),t.error!==null&&!t.result?(0,Y.jsx)(F,{compact:!0,title:`Could not load changes`,error:t.error,onRetry:t.refresh}):t.result?c.length===0?(0,Y.jsx)(L,{icon:(0,Y.jsx)(vt,{className:`size-8`}),title:`No changes yet`,description:`Nothing differs from ${t.result.base} in this workspace.`,className:`py-6`}):(0,Y.jsxs)(Y.Fragment,{children:[t.error!==null&&(0,Y.jsx)(F,{compact:!0,title:`Refresh failed; showing earlier changes`,error:t.error,onRetry:t.refresh}),(0,Y.jsx)(Hr,{files:c,selected:i,onSelect:e=>a(t=>t===e?null:e),commentCounts:r}),i&&(0,Y.jsx)(Ur,{ctx:e,diff:t,path:i,comments:n.comments,onComment:s})]}):(0,Y.jsx)(I,{label:`Loading changes…`}),(0,Y.jsx)(Gr,{ctx:e,review:n}),(0,Y.jsx)(Wr,{draft:o,mobile:!1,onClose:()=>s(null),onSave:e=>{o&&n.add({...o,text:e}),s(null)}})]})}function Xr({ctx:e}){let t=zr(e),n=Pr(e.session.id),r=Kr(n.comments),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),c=t.result?.files??[],l=i?c.findIndex(e=>e.path===i):-1;return i&&l>=0?(0,Y.jsx)(Zr,{ctx:e,diff:t,file:c[l],index:l,total:c.length,comments:n.comments,onBack:()=>a(null),onPrev:()=>a(c[l-1]?.path??i),onNext:()=>a(c[l+1]?.path??i),commentDraft:o,setCommentDraft:s,onSaveComment:e=>{o&&n.add({...o,text:e}),s(null)}}):(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 px-3 py-3`,children:[!e.workspace||e.link!==`connected`?(0,Y.jsx)(qr,{ctx:e}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Jr,{diff:t}),t.error!==null&&!t.result?(0,Y.jsx)(F,{title:`Could not load changes`,error:t.error,onRetry:t.refresh}):t.result?c.length===0?(0,Y.jsx)(L,{icon:(0,Y.jsx)(vt,{className:`size-8`}),title:`No changes yet`,description:`Nothing differs from ${t.result.base} in this workspace.`}):(0,Y.jsx)(Hr,{files:c,selected:null,onSelect:a,commentCounts:r,large:!0}):(0,Y.jsx)(I,{label:`Loading changes…`})]}),(0,Y.jsx)(Gr,{ctx:e,review:n})]})}function Zr({ctx:e,diff:t,file:n,index:r,total:i,comments:a,onBack:o,onPrev:s,onNext:c,commentDraft:l,setCommentDraft:u,onSaveComment:d}){Fe(!0);let f=(0,J.useRef)(null);(0,J.useEffect)(()=>f.current?.focus(),[n.path]);let p=a.filter(e=>e.file===n.path).length;return(0,Y.jsxs)(`section`,{"aria-label":`Diff of ${n.path}`,className:`fixed inset-0 z-40 flex min-w-0 flex-col bg-bg safe-pt safe-px`,onKeyDown:e=>{e.key===`Escape`&&!l&&(e.preventDefault(),o())},children:[(0,Y.jsxs)(`header`,{className:`flex min-w-0 shrink-0 items-center gap-1 border-b border-border bg-surface px-2 py-1.5`,children:[(0,Y.jsx)(q,{ref:f,label:`Back to changed files`,icon:(0,Y.jsx)(ce,{className:`size-4`}),onClick:o}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate font-mono text-xs`,title:n.path,children:n.path}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted`,children:[`File `,r+1,` of `,i,` · +`,n.added,` -`,n.deleted,p>0&&` · ${p} comment${p===1?``:`s`}`]})]}),(0,Y.jsx)(q,{label:`Previous file`,icon:(0,Y.jsx)(H,{className:`size-4`}),disabled:r===0,onClick:s}),(0,Y.jsx)(q,{label:`Next file`,icon:(0,Y.jsx)(U,{className:`size-4`}),disabled:r>=i-1,onClick:c})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-2 py-2 safe-pb`,children:[(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-muted`,children:`Tap a line to add a review comment.`}),(0,Y.jsx)(Ur,{ctx:e,diff:t,path:n.path,comments:a,onComment:u})]}),(0,Y.jsx)(Wr,{draft:l,mobile:!0,onClose:()=>u(null),onSave:d})]})}function Qr(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`action`&&typeof t.actionId==`string`||t.type===`resize`&&typeof t.height==`number`}function $r({hostId:e,adapterId:t,node:n,state:r,onAction:i,title:a,className:o,minHeight:s=80,maxHeight:c=1200}){let l=(0,J.useRef)(null),[u,d]=(0,J.useState)(s),[f,p]=(0,J.useState)(!1),m=(0,J.useRef)(i);m.current=i,(0,J.useEffect)(()=>{let e=e=>{e.source===l.current?.contentWindow&&Qr(e.data)&&(e.data.type===`resize`?d(Math.min(c,Math.max(s,Math.ceil(e.data.height)))):m.current?.(e.data.actionId,e.data.payload))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[s,c]),(0,J.useEffect)(()=>{f&&l.current?.contentWindow?.postMessage({type:`render`,node:n,state:r},`*`)},[f,n,r]);let h=`/adapter-frames/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return(0,Y.jsx)(`iframe`,{ref:l,title:a,src:h,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,loading:`lazy`,onLoad:()=>p(!0),style:{height:u},className:k(`block w-full rounded-md border border-border bg-surface`,o)})}function ei({ctx:e,className:t}){if(e.control===`none`)return null;let n=e.control===`automation`;return(0,Y.jsx)(W,{kind:`custom`,size:`sm`,className:t,status:{label:Fn[e.control],icon:n?et:Te,tone:n?`info`:`neutral`}})}function ti({ctx:e}){return(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1 text-xs text-muted`,children:[(0,Y.jsx)(me,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.hostName}),e.link!==`connected`&&(0,Y.jsx)(W,{kind:`host`,value:e.link,size:`sm`,className:`ml-1`})]})}function ni(e,t){return[{id:`rename`,label:`Rename`,icon:(0,Y.jsx)(we,{className:`size-4`}),onSelect:t.openRename,disabled:e.session.readOnly},{id:`archive`,label:`Archive`,icon:(0,Y.jsx)(Qe,{className:`size-4`}),onSelect:t.requestArchive,disabled:!!t.archiveBlocked,hint:t.archiveBlocked??void 0},{id:`info`,label:`Native session information`,icon:(0,Y.jsx)(Me,{className:`size-4`}),onSelect:t.openInfo}]}function ri({ctx:e,actions:t,inspector:n}){let{session:i,project:a,workspace:o,task:s}=e;return(0,Y.jsxs)(`header`,{className:`flex min-w-0 shrink-0 flex-col gap-1.5 border-b border-border bg-surface px-4 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-base font-semibold`,title:i.title,children:i.title}),s&&(0,Y.jsxs)(r,{to:`/tasks/${encodeURIComponent(s.id)}`,className:te(`ghost`,`sm`),title:`Open linked task: ${s.title}`,children:[(0,Y.jsx)(He,{"aria-hidden":!0,className:`size-4`}),(0,Y.jsx)(`span`,{className:`hidden xl:inline`,children:`Open linked task`}),(0,Y.jsx)(`span`,{className:`xl:hidden`,children:`Task`})]}),t.canTakeover&&(0,Y.jsx)(N,{size:`sm`,icon:(0,Y.jsx)(Te,{className:`size-3.5`}),busy:t.busy.takeover,onClick:t.takeover,children:`Take over`}),t.canReturn&&(0,Y.jsx)(N,{size:`sm`,icon:(0,Y.jsx)(et,{className:`size-3.5`}),busy:t.busy.ret,onClick:t.returnToAutomation,children:`Return to automation`}),t.canResume&&(0,Y.jsx)(N,{size:`sm`,icon:(0,Y.jsx)(De,{className:`size-3.5`}),busy:t.busy.resume,onClick:t.resume,children:`Resume`}),t.canStop&&(0,Y.jsx)(N,{size:`sm`,variant:`danger`,icon:(0,Y.jsx)(Be,{className:`size-3.5`}),busy:t.busy.stop,onClick:t.requestStop,children:`Stop`}),(0,Y.jsx)(R,{label:`Session menu`,items:ni(e,t),trigger:e=>(0,Y.jsx)(q,{...e,label:`Session menu`,icon:(0,Y.jsx)(mt,{className:`size-4`})})}),(0,Y.jsx)(q,{label:n.label,"aria-expanded":n.open,icon:n.open?(0,Y.jsx)(Ht,{className:`size-4`}):(0,Y.jsx)(oe,{className:`size-4`}),onClick:n.toggle})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(W,{kind:`runtime`,value:i.runtime,size:`sm`}),(0,Y.jsx)(ei,{ctx:e}),(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1 text-xs text-muted`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:a?.name??`No project`}),(0,Y.jsx)(Ce,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate font-mono`,children:Sn(o,i.cwd)})]}),(0,Y.jsx)(ti,{ctx:e}),i.readOnly&&(0,Y.jsx)(`span`,{className:k(`text-xs text-muted`),children:`Subagent: view only. Live control is not supported.`})]})]})}function Q({title:e,children:t,className:n}){return(0,Y.jsxs)(`section`,{"aria-label":e,className:k(`flex min-w-0 flex-col gap-2`,n),children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),t]})}function ii({ctx:e,actions:t}){let n=e.control!==`none`;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(ei,{ctx:e}),!n&&(0,Y.jsx)(`span`,{className:`text-sm text-muted`,children:`Manual session: no automation run controls it.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(N,{icon:(0,Y.jsx)(Te,{className:`size-4`}),disabled:!t.canTakeover,busy:t.busy.takeover,onClick:t.takeover,children:`Take over`}),(0,Y.jsx)(N,{icon:(0,Y.jsx)(et,{className:`size-4`}),disabled:!t.canReturn,busy:t.busy.ret,onClick:t.returnToAutomation,children:`Return to automation`}),(0,Y.jsx)(N,{variant:`danger`,icon:(0,Y.jsx)(Be,{className:`size-4`}),disabled:!t.canStop,busy:t.busy.stop,onClick:t.requestStop,children:`Stop`})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[n?e.control===`automation`?`Taking over pauses automatic continuations; Pi keeps running.`:`You have control; returning lets automation continue.`:`Take over and Return to automation apply to sessions run by a task.`,` `,!t.canStop&&(e.link===`connected`?`Stop is available while Pi is running.`:`Stop needs the host to be online.`)]})]})}function ai({run:e}){return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-0.5 rounded-md border border-border px-2 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`text-sm font-medium`,children:[`Attempt `,e.attempt]}),(0,Y.jsx)(W,{kind:`run`,value:e.state,size:`sm`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:e.startedAt?P(e.startedAt):P(e.createdAt)})]}),e.outcome&&(0,Y.jsx)(`p`,{className:`text-xs break-words text-muted`,children:e.outcome.summary}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[e.usage.accounting===`available`?[e.usage.tokens===null?null:`${e.usage.tokens.toLocaleString()} tokens`,e.usage.costUsd===null?null:`$${e.usage.costUsd.toFixed(2)}`].filter(Boolean).join(` · `)||`No usage reported`:e.usage.note??`Token/cost accounting not reported`,e.continuationsUsed>0&&` · ${e.continuationsUsed} continuations`]})]})}function oi({task:e,run:t}){let n=t?.limits??e.policy.continuation;return(0,Y.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-sm`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Continuation`}),(0,Y.jsx)(`dd`,{children:n.enabled?`Enabled`:`Off: stops after one turn`}),n.enabled&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Continuations`}),(0,Y.jsxs)(`dd`,{children:[t?`${t.continuationsUsed} of `:`up to `,n.maxContinuations]}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Time limit`}),(0,Y.jsxs)(`dd`,{children:[n.maxElapsedMinutes,` min`]}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Token limit`}),(0,Y.jsx)(`dd`,{children:n.maxTokens?.toLocaleString()??`None`}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Cost limit`}),(0,Y.jsx)(`dd`,{children:n.maxCostUsd===null?`None`:`$${n.maxCostUsd}`})]}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Checks`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.policy.completion.checks===null?`Project checks`:e.policy.completion.checks.length?e.policy.completion.checks.join(`, `):`None`}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Human review`}),(0,Y.jsx)(`dd`,{children:e.policy.completion.requireHumanReview?`Required`:`Not required`})]})}function si({ctx:e,actions:t,showControls:n=!0}){let{task:i,run:a}=e,o=j(i?.id),s=y(e=>e.tasks);return i?(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-semibold break-words`,children:i.title}),(0,Y.jsx)(W,{kind:`task`,value:i.state,size:`sm`})]}),i.blocked&&(0,Y.jsxs)(`p`,{className:`text-sm text-warning`,children:[`Blocked: `,i.blocked.reason]}),(0,Y.jsxs)(r,{to:`/tasks/${encodeURIComponent(i.id)}`,className:te(`secondary`,`sm`,`self-start`),children:[(0,Y.jsx)(He,{"aria-hidden":!0,className:`size-4`}),`Open task`]})]}),(0,Y.jsx)(Q,{title:`Objective`,children:i.objective?(0,Y.jsx)(ue,{text:i.objective}):(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No objective written.`})}),(0,Y.jsx)(Q,{title:`Acceptance criteria`,children:i.acceptanceCriteria.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`None.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.acceptanceCriteria.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-2 text-sm`,children:[(0,Y.jsx)(Pe,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Y.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]},e))})}),(0,Y.jsx)(Q,{title:`Dependencies`,children:i.dependencies.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`None.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.dependencies.map(e=>{let t=s[e];return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[t?(0,Y.jsx)(W,{kind:`task`,value:t.state,size:`sm`}):null,(0,Y.jsx)(r,{to:`/tasks/${encodeURIComponent(e)}`,className:`min-w-0 truncate text-accent underline underline-offset-2`,children:t?.title??e})]},e)})})}),(0,Y.jsx)(Q,{title:`Limits`,children:(0,Y.jsx)(oi,{task:i,run:a})}),n&&(0,Y.jsx)(Q,{title:`Control`,children:(0,Y.jsx)(ii,{ctx:e,actions:t})}),(0,Y.jsx)(Q,{title:`Run history`,children:o.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No runs yet.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,Y.jsx)(ai,{run:e},e.id))})})]}):(0,Y.jsx)(L,{icon:(0,Y.jsx)(He,{className:`size-8`}),title:`No linked task`,description:`This session was started directly. Tasks are optional; create one on the Board to automate work.`,action:{label:`Open Board`,to:`/board`},className:`py-6`})}var ci={active:{label:`Active`,tone:`success`},disabled:{label:`Disabled`,tone:`neutral`},error:{label:`Error`,tone:`danger`}};function li({a:e}){let t=ci[e.status];return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-0.5 rounded-md border border-border px-2 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono text-sm`,children:e.id}),(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[`v`,e.version]}),(0,Y.jsxs)(`span`,{className:`rounded-full border border-border px-1.5 text-xs text-muted`,children:[`Tier: `,e.tier]}),(0,Y.jsx)(W,{kind:`custom`,size:`sm`,status:{label:t.label,tone:t.tone,icon:e.status===`active`?Pe:Be}})]}),(0,Y.jsxs)(`p`,{className:`text-xs break-words text-muted`,children:[`For `,e.target.extension,` `,e.target.versionRange,e.target.testedVersions.length>0&&` (tested ${e.target.testedVersions.join(`, `)})`]}),e.capabilities.length>0&&(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Provides: `,e.capabilities.join(`, `)]}),e.detail&&(0,Y.jsx)(`p`,{className:`text-xs break-words text-warning`,children:e.detail})]})}function ui({ctx:e,panel:t}){let{mobile:n,openFile:r}=un(),i=(n,r)=>{Z.adapterAction(e.session.id,t.adapterId,n,r).then(()=>G.success(`Action sent`)).catch(e=>G.error(S(e)))},a;return a=t.webRenderer&&!n&&e.host?(0,Y.jsx)($r,{hostId:e.session.hostId,adapterId:t.adapterId,node:t.node,title:t.title,onAction:i}):t.node?(0,Y.jsxs)(Y.Fragment,{children:[t.webRenderer&&n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Showing the portable version; this panel's custom renderer is desktop-only.`}),(0,Y.jsx)(xe,{node:t.node,onAction:e=>i(e),onOpenFile:r})]}):(0,Y.jsx)(T,{capability:`This panel`,reason:`It only has a custom web renderer, which is desktop-only and is not shown on mobile.`,fallback:(0,Y.jsx)(`p`,{className:`text-sm`,children:t.mobileFallback??`The adapter provides no mobile fallback text.`})}),(0,Y.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-border p-2`,children:[(0,Y.jsxs)(`header`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Y.jsx)(`h4`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:t.title}),(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-subtle`,children:t.adapterId})]}),a]})}function di({ctx:e}){let t=v(e.session.id),n=y(e=>e.diagnostics),i=(0,J.useMemo)(()=>new Set(e.adapters.map(e=>e.id)),[e.adapters]),a=(0,J.useMemo)(()=>n.filter(t=>t.sessionId===e.session.id||t.sessionId===null&&t.adapterId!==null&&i.has(t.adapterId)).slice(-20).reverse(),[n,e.session.id,i]),o=e.host?.capabilities;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,Y.jsx)(Q,{title:`Panels`,children:t.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No extension panels for this session.`}):t.map(t=>(0,Y.jsx)(ui,{ctx:e,panel:t},`${t.adapterId}:${t.slot}`))}),(0,Y.jsx)(Q,{title:`Adapters on ${e.hostName}`,children:e.adapters.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No adapters reported by this host.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.adapters.map(e=>(0,Y.jsx)(li,{a:e},e.id))})}),(o?.unsupported.length||e.host?.piCompatible===!1)&&(0,Y.jsxs)(Q,{title:`Runtime limitations`,children:[e.host?.piCompatible===!1&&(0,Y.jsx)(T,{capability:`This Pi version`,reason:`Pi ${e.host.piVersion??`(not found)`} on ${e.hostName} is outside the tested range.`}),o?.unsupported.map(e=>(0,Y.jsx)(T,{capability:e.capability,reason:e.reason},e.capability))]}),(0,Y.jsxs)(Q,{title:`Diagnostics`,children:[a.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:a.map((e,t)=>(0,Y.jsxs)(`li`,{className:`min-w-0 rounded-md bg-surface-2 px-2 py-1 text-xs`,children:[(0,Y.jsx)(`span`,{className:k(`font-medium`,e.level===`error`&&`text-danger`,e.level===`warning`&&`text-warning`),children:e.level===`error`?`Error`:e.level===`warning`?`Warning`:`Info`}),` `,e.adapterId&&(0,Y.jsxs)(`span`,{className:`font-mono`,children:[e.adapterId,`: `]}),(0,Y.jsx)(`span`,{className:`break-words`,children:e.message}),` `,(0,Y.jsx)(`span`,{className:`text-subtle`,children:ee(e.at)})]},`${e.at}-${t}`))}),(0,Y.jsx)(r,{to:`/settings/diagnostics`,className:`text-sm text-accent underline`,children:`All diagnostics`})]})]})}function fi({ctx:e,actions:t}){let{session:n,workspace:i,host:a}=e,o=h(n.id).items.filter(e=>e.kind===`subagent`),s=mr(n);return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5 px-3 py-3`,children:[(0,Y.jsx)(Q,{title:`Automation and control`,children:(0,Y.jsx)(ii,{ctx:e,actions:t})}),(0,Y.jsx)(Q,{title:`Task`,children:(0,Y.jsx)(si,{ctx:e,actions:t,showControls:!1})}),(0,Y.jsxs)(Q,{title:`Host and workspace`,children:[e.link!==`connected`&&(0,Y.jsx)(A,{compact:!0,hostName:e.hostName,connectivity:e.link===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:a?.lastSeenAt}),(0,Y.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-sm`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Host`}),(0,Y.jsxs)(`dd`,{className:`min-w-0 break-words`,children:[e.hostName,a?.piVersion&&` · Pi ${a.piVersion}`]}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Branch`}),(0,Y.jsxs)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:[Sn(i,n.cwd),i?.baseBranch&&` (from ${i.baseBranch})`]}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Path`}),(0,Y.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:i?.path??n.cwd}),i&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Git`}),(0,Y.jsxs)(`dd`,{children:[i.git.dirty?`${i.git.changedFiles} changed files`:`Clean`,i.git.ahead>0&&` · ${i.git.ahead} ahead`,i.git.behind>0&&` · ${i.git.behind} behind`]})]}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Profile`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words`,children:n.profileSnapshot.name}),n.model&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Model`}),(0,Y.jsxs)(`dd`,{className:`min-w-0 break-words`,children:[`${ur(n.model)} (${n.model.provider}/${n.model.id})`,n.thinking&&` · effort ${n.thinking}`]})]}),s&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Context`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words`,children:`${s.label} · ${s.detail}`})]})]})]}),(0,Y.jsx)(Q,{title:`Subagents`,children:o.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No subagents in the loaded transcript.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(e=>e.kind===`subagent`?(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.data.label}),(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:e.data.status}),e.data.linkedSessionId&&(0,Y.jsx)(r,{to:`/code/${encodeURIComponent(e.data.linkedSessionId)}`,className:`text-accent underline`,children:`Open (view only)`})]},e.id):null)})}),(0,Y.jsx)(Q,{title:`Extensions`,children:(0,Y.jsx)(di,{ctx:e})})]})}function pi({text:e,lang:t,wrap:n,className:r}){let i=de(e,t),a=e.split(`
|
|
9
|
+
`);return a.length>1&&a[a.length-1]===``&&a.pop(),(0,Y.jsx)(`section`,{"aria-label":`File contents`,className:k(`sy-code min-w-0 overflow-auto overscroll-contain bg-surface-2 py-2 font-mono text-xs leading-5`,r),children:(0,Y.jsx)(`pre`,{className:k(`px-3`,n?`break-all whitespace-pre-wrap`:`w-max min-w-full whitespace-pre`),children:(0,Y.jsx)(`code`,{children:a.map((e,t)=>{let n=i?.[t];return(0,Y.jsxs)(`span`,{children:[n?n.map((e,t)=>(0,Y.jsx)(`span`,{style:e.style,children:e.content},t)):e,t<a.length-1?`
|
|
10
|
+
`:``]},t)})})})})}var mi={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,bmp:`image/bmp`,ico:`image/x-icon`},hi={added:{letter:`A`,tone:`text-success`},untracked:{letter:`U`,tone:`text-success`},modified:{letter:`M`,tone:`text-warning`},renamed:{letter:`R`,tone:`text-warning`},deleted:{letter:`D`,tone:`text-danger`},binary:{letter:`B`,tone:`text-muted`}};function gi(e){let t=e.split(`/`).filter(Boolean);return t.pop(),t.join(`/`)}function _i(e){let t=e.split(`/`).filter(Boolean);return t.pop(),t.map((e,n)=>t.slice(0,n+1).join(`/`))}function vi(e){return(/\.([A-Za-z0-9]+)$/.exec(e)?.[1]??``).toLowerCase()}function yi(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function bi(e){let t=vi(e);return t===`json`||t===`jsonc`?gt:[`md`,`mdx`,`markdown`,`txt`].includes(t)?St:t in mi?bt:B(e)?be:wt}function xi(e,t,n){return e.path?e.path.startsWith(`${t.path}/`)?e.path.slice(t.path.length+1):e.path:n?`${n}/${e.name}`:e.name}function Si({status:e}){if(!e)return null;let t=hi[e];return(0,Y.jsx)(`span`,{title:Vr[e],className:k(`shrink-0 font-mono text-[11px] font-semibold`,t.tone),children:t.letter})}function Ci({ctx:e,openPath:t}){let n=e.workspace,r=e.link===`connected`,[i,a]=(0,J.useState)(new Map),[o,s]=(0,J.useState)(new Set),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(null),m=zr(e),h=(0,J.useRef)(null),g=(0,J.useMemo)(()=>new Map(m.result?.files.map(e=>[e.path,e.status])??[]),[m.result]),_=(0,J.useMemo)(()=>{let e=new Set;for(let t of g.keys())for(let n of _i(t))e.add(n);return e},[g]),v=n?.id,y=(0,J.useCallback)((e,t=!1)=>{v&&(a(n=>{let r=n.get(e);return r&&!t&&(r===`loading`||Array.isArray(r))?n:new Map(n).set(e,`loading`)}),Z.files(v,e).then(t=>a(n=>new Map(n).set(e,t)),t=>a(n=>new Map(n).set(e,{error:t}))))},[v]);(0,J.useEffect)(()=>{if(v&&r){a(new Map),y(``,!0);for(let e of o)y(e,!0)}},[v,r]),(0,J.useEffect)(()=>{if(!t||!n)return;let e=t.path.startsWith(`${n.path}/`)?t.path.slice(n.path.length+1):t.path.replace(/^\.\//,``);l(e);let r=_i(e);s(e=>new Set([...e,...r]));for(let e of r)y(e)},[t,n,y]);let b=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),y(e)),n})};if(!n)return(0,Y.jsx)(T,{capability:`File browsing`,reason:`This session is not linked to a Switchyard workspace (it runs in ${e.session.cwd}).`});if(!r)return(0,Y.jsx)(A,{compact:!0,hostName:e.hostName,connectivity:e.link===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:e.host?.lastSeenAt,detail:`Files are read from the host; browsing resumes when it reconnects.`});if(c!==null)return(0,Y.jsx)(wi,{ctx:e,file:c,status:g.get(c),onBack:()=>l(null)});let x=[],S=[],C=(e,t)=>{let r=i.get(e);if(r===void 0||r===`loading`)(e!==``||r===`loading`)&&S.push({dir:e,depth:t,state:`loading`});else if(!Array.isArray(r))S.push({dir:e,depth:t,state:r});else for(let i of r){let r=xi(i,n,e);x.push({entry:i,rel:r,depth:t}),i.kind===`dir`&&o.has(r)&&C(r,t+1)}};C(``,0);let w=u.trim().toLowerCase(),E=[];if(w){for(let[e,t]of i)if(Array.isArray(t))for(let r of t){let t=xi(r,n,e);r.kind!==`dir`&&t.toLowerCase().includes(w)&&E.push({entry:r,rel:t,depth:0})}E.sort((e,t)=>e.rel.localeCompare(t.rel))}let D=i.get(``),O=w?E.slice(0,200):x,j=f&&O.some(e=>e.rel===f)?f:O[0]?.rel,M=(e,t)=>{let n=[...h.current?.querySelectorAll(`[role=treeitem]`)??[]];n[n.indexOf(e)+t]?.focus()};return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 px-2 py-2`,children:[(0,Y.jsx)(Ge,{type:`search`,"aria-label":`Filter files`,placeholder:`Filter files`,value:u,onChange:e=>d(e.target.value),className:`w-full`}),D&&!Array.isArray(D)&&D!==`loading`?(0,Y.jsx)(F,{compact:!0,title:`Could not list this folder`,error:D.error,onRetry:()=>y(``,!0)}):D===void 0||D===`loading`?(0,Y.jsx)(I,{label:`Loading folder…`}):w&&E.length===0?(0,Y.jsx)(L,{title:`No matching files`,className:`py-6`}):!w&&x.length===0?(0,Y.jsx)(L,{title:`Empty folder`,className:`py-6`}):(0,Y.jsxs)(`div`,{ref:h,role:`tree`,"aria-label":`Workspace files`,className:`flex min-w-0 flex-col`,children:[O.map(({entry:e,rel:t,depth:n})=>{let r=e.kind===`dir`,i=r&&o.has(t),a=r?i?Et:Ot:e.kind===`symlink`?Ee:bi(e.name),s=g.get(t);return(0,Y.jsx)(`div`,{role:`none`,className:`min-w-0`,children:(0,Y.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-selected":!1,"aria-expanded":r?i:void 0,tabIndex:t===j?0:-1,onFocus:()=>p(t),style:{paddingLeft:8+n*14},className:`flex h-8 w-full min-w-0 items-center gap-1.5 rounded pr-2 text-left text-[13px] hover:bg-surface-2`,onClick:()=>r?b(t):l(t),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),M(e.currentTarget,1);else if(e.key===`ArrowUp`)e.preventDefault(),M(e.currentTarget,-1);else if(e.key===`ArrowRight`&&r&&!i)e.preventDefault(),b(t);else if(e.key===`ArrowLeft`){if(e.preventDefault(),r&&i)b(t);else if(t.includes(`/`)){let e=gi(t);h.current?.querySelector(`[data-path="${CSS.escape(e)}"]`)?.focus()}}},"data-path":t,children:[w?null:r?(0,Y.jsx)(U,{"aria-hidden":!0,className:k(`size-4 shrink-0 text-muted transition-transform`,i&&`rotate-90`)}):(0,Y.jsx)(`span`,{className:`size-4 shrink-0`}),(0,Y.jsx)(a,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:k(`min-w-0 flex-1 truncate`,w&&`font-mono text-xs`),children:[w?t:e.name,(0,Y.jsxs)(`span`,{className:`sr-only`,children:[` `,r?`folder`:`file`]})]}),r&&_.has(t)&&(0,Y.jsx)(`span`,{title:`Contains changes`,className:`size-1.5 shrink-0 rounded-full bg-warning`}),!r&&(0,Y.jsx)(Si,{status:s}),!r&&e.size!==null&&(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-subtle tabular-nums`,children:yi(e.size)})]})},t)}),!w&&S.map(e=>(0,Y.jsx)(`div`,{role:`none`,style:{paddingLeft:8+e.depth*14},children:e.state===`loading`?(0,Y.jsx)(`span`,{className:`flex h-8 items-center text-xs text-muted`,children:`Loading…`}):(0,Y.jsx)(F,{compact:!0,title:`Could not list this folder`,error:e.state.error,onRetry:()=>y(e.dir,!0)})},`x-${e.dir}`))]}),w&&(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Searches folders you have opened.`})]})}function wi({ctx:e,file:t,status:n,onBack:r}){let i=e.workspace,[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!0),[d,f]=(0,J.useState)(0),[p,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(`preview`),[v,y]=(0,J.useState)(null),b=t.split(`/`).pop()??t,x=vi(t),S=[`md`,`mdx`,`markdown`].includes(x),C=x===`svg`,w=mi[x],T=bi(b);(0,J.useEffect)(()=>{let e=new AbortController;return u(!0),c(null),o(null),Z.file(i.id,t,e.signal).then(e=>o(e)).catch(t=>{e.signal.aborted||c(t)}).finally(()=>{e.signal.aborted||u(!1)}),()=>e.abort()},[i.id,t,d]);let E=a&&!a.binary?a.text:null,D=E===null?null:E.replace(/\n$/,``).split(`
|
|
11
|
+
`).length,O=gi(t),A=e=>{navigator.clipboard?.writeText(e).then(()=>G.success(`Copied`))},j=`flex justify-center bg-[conic-gradient(var(--sy-surface-2)_25%,var(--sy-surface)_0_50%,var(--sy-surface-2)_0_75%,var(--sy-surface)_0)] bg-[length:16px_16px] p-4`,M;return l?M=(0,Y.jsx)(I,{label:`Loading file…`}):s===null?a&&w&&a.base64?M=(0,Y.jsx)(`div`,{className:j,children:(0,Y.jsx)(`img`,{alt:b,className:`max-h-[60vh] max-w-full`,src:`data:${w};base64,${a.base64}`,onLoad:e=>y(`${e.currentTarget.naturalWidth}×${e.currentTarget.naturalHeight}`)})}):E!==null&&C&&g===`preview`?M=(0,Y.jsx)(`div`,{className:j,children:(0,Y.jsx)(`img`,{alt:b,className:`max-h-[60vh] max-w-full`,src:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(E)}`})}):E!==null&&S&&g===`preview`?M=(0,Y.jsx)(`div`,{className:`px-4 py-2`,children:(0,Y.jsx)(ue,{text:E})}):E===null?a&&(M=(0,Y.jsx)(L,{title:`Binary file`,description:`${a.size===null?`Unknown size`:yi(a.size)} — not shown`})):M=(0,Y.jsx)(pi,{text:E,lang:B(t),wrap:p}):M=m(s,`too_large`)?(0,Y.jsx)(L,{title:`Too large to preview`,description:`Switchyard previews files up to 1 MB.`}):(0,Y.jsx)(F,{compact:!0,title:`Could not read this file`,error:s,onRetry:()=>f(e=>e+1)}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border px-3 pt-2 pb-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(q,{size:`sm`,label:`Back to files`,icon:(0,Y.jsx)(ce,{className:`size-4`}),onClick:r}),(0,Y.jsx)(T,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Y.jsx)(`h3`,{className:`min-w-0 flex-1 truncate font-medium`,children:b}),n&&(0,Y.jsx)(`span`,{className:k(`shrink-0 text-xs font-medium`,hi[n].tone),children:Vr[n]})]}),(0,Y.jsxs)(`p`,{className:`min-w-0 truncate text-xs text-muted`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:O||(i.branch??`root`)}),a?.size!=null&&` · ${yi(a.size)}`,D!==null&&` · ${D} lines`,v&&` · ${v}`]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(S||C)&&E!==null&&(0,Y.jsx)(Xe,{label:`View`,value:g,onChange:_,options:[{value:`preview`,label:`Preview`},{value:`source`,label:`Source`}]}),E!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(q,{size:`sm`,label:p?`Don't wrap lines`:`Wrap lines`,"aria-pressed":p,icon:(0,Y.jsx)(en,{className:`size-4`}),onClick:()=>h(e=>!e)}),(0,Y.jsx)(q,{size:`sm`,label:`Copy contents`,icon:(0,Y.jsx)(ge,{className:`size-4`}),onClick:()=>A(E)})]}),(0,Y.jsx)(q,{size:`sm`,label:`Copy path`,icon:(0,Y.jsx)(Ee,{className:`size-4`}),onClick:()=>A(t)})]})]}),(0,Y.jsx)(`div`,{className:`min-w-0 pb-3`,children:M})]})}function Ti({ctx:e,actions:t,tab:n,onTab:r,openPath:i,className:a,hideTitle:o}){let s=(0,J.useId)(),c=v(e.session.id),l=e.workspace?.git.changedFiles??0;return(0,Y.jsxs)(`aside`,{"data-testid":`inspector`,"aria-label":`Inspector`,className:k(`flex min-h-0 min-w-0 flex-col bg-surface`,a),children:[!o&&(0,Y.jsx)(`h2`,{className:`sr-only`,children:`Inspector`}),(0,Y.jsx)(z,{idPrefix:s,label:`Inspector`,value:n,onChange:e=>r(e),className:`shrink-0 px-2`,scrollable:!0,tabs:[{id:`changes`,label:`Changes`,badge:(0,Y.jsx)(u,{count:l,label:`changed files`,tone:`neutral`})},{id:`files`,label:`Files`},{id:`task`,label:`Task`},{id:`extensions`,label:`Extensions`,badge:(0,Y.jsx)(u,{count:c.length,label:`panels`,tone:`neutral`})}]}),(0,Y.jsxs)(fe,{idPrefix:s,id:n,className:k(`relative min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain`,n===`files`?`p-0`:`p-3`),children:[n===`changes`&&(0,Y.jsx)(Yr,{ctx:e}),n===`files`&&(0,Y.jsx)(Ci,{ctx:e,openPath:i}),n===`task`&&(0,Y.jsx)(si,{ctx:e,actions:t}),n===`extensions`&&(0,Y.jsx)(di,{ctx:e})]})]})}function Ei(e){return{filter:`active`,query:``,collapsed:[],layout:e?`recent`:`projects`,showSubagents:!1}}function Di({selectedId:e,onNewSession:t,variant:n,className:r,style:i}){let a=n===`screen`,o=Ei(a),[s,c]=ze(a?`sessionList`:`navigator`,o),l={...o,...s},u=y(e=>e.hydrated),d=y(e=>e.projects),m=y(e=>e.workspaces),h=y(e=>e.sessions),g=y(e=>e.hosts),_=y(e=>e.attention),v=y(e=>e.interactions),b=p(),x=f(),S=(0,J.useMemo)(()=>kn({projects:d,workspaces:m,sessions:h,hosts:g,attention:_,interactions:v},{filter:l.filter,query:l.query,layout:l.layout,showSubagents:l.showSubagents}),[d,m,h,g,_,v,l.filter,l.query,l.layout,l.showSubagents]),C=new Set(l.collapsed),w=e=>{let t=new Set(C);t.has(e)?t.delete(e):t.add(e),c({...l,collapsed:[...t]})},T=jn(S),E=[{id:`layout-heading`,heading:`Group sessions`},...yn.map(e=>({id:`layout-${e.value}`,label:e.label,hint:e.hint,kind:`radio`,checked:l.layout===e.value,onSelect:()=>c({...l,layout:e.value})})),`separator`,{id:`subagents`,label:`Show subagents`,kind:`checkbox`,checked:l.showSubagents,onSelect:()=>c({...l,showSubagents:!l.showSubagents})}],D=T.some(e=>!C.has(e)),O=a?[{value:`active`,label:`Active`},{value:`attention`,label:`Needs input`},{value:`all`,label:`All`}]:[{value:`active`,label:`Active`},{value:`all`,label:`All`}],A;return A=u?b.length===0?(0,Y.jsx)(L,{icon:(0,Y.jsx)(me,{className:`size-8`}),title:`Connect a host`,description:`Sessions run on a host: a computer with Pi and the Switchyard host agent.`,action:{label:`Connect a host`,to:`/settings/hosts`},secondaryAction:x.length===0?{label:`Add a project`,to:`/settings/projects`}:void 0}):x.length===0?(0,Y.jsx)(L,{icon:(0,Y.jsx)(V,{className:`size-8`}),title:`Add a project`,description:`Point Switchyard at a Git checkout on one of your hosts to start sessions there.`,action:{label:`Add a project`,to:`/settings/projects`}}):An(S)?l.query?(0,Y.jsx)(L,{icon:(0,Y.jsx)(ke,{className:`size-8`}),title:`No matches`,description:`Nothing matches "${l.query}".`,action:{label:`Clear search`,onClick:()=>c({...l,query:``})}}):(0,Y.jsx)(L,{title:l.filter===`attention`?`Nothing needs your input`:l.filter===`active`?`No active sessions`:`No sessions yet`,description:`Start a session in one of your projects; a task is not required.`,action:{label:`New session`,onClick:t},secondaryAction:l.filter===`all`?void 0:{label:`Show all`,onClick:()=>c({...l,filter:`all`})}}):l.layout===`recent`?(0,Y.jsx)(`ul`,{"aria-label":`Recent sessions`,className:`flex min-w-0 flex-col gap-0.5 pb-4`,children:S.rows.map(t=>(0,Y.jsx)(ji,{row:t,indent:0,selected:t.session.id===e,screen:a},t.session.id))}):(0,Y.jsx)(`ul`,{"aria-label":l.layout===`hosts`?`Hosts`:`Projects`,className:`flex min-w-0 flex-col gap-1 pb-4`,children:S.groups.map(t=>(0,Y.jsx)(ki,{group:t,depth:0,collapsed:C,toggle:w,selectedId:e,screen:a,emptyText:l.layout===`worktrees`?`No workspaces discovered yet.`:`No sessions.`},t.key))}):(0,Y.jsx)(I,{label:`Loading sessions…`}),(0,Y.jsxs)(`nav`,{"data-testid":`navigator`,"aria-label":`Sessions`,style:i,className:k(`flex min-h-0 min-w-0 flex-col bg-surface`,r),children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-3 pt-3 pb-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h2`,{className:k(`min-w-0 flex-1 font-semibold`,a?`text-lg`:`text-sm`),children:`Sessions`}),(0,Y.jsx)(N,{"data-testid":`new-session`,size:`sm`,variant:`primary`,icon:(0,Y.jsx)(Oe,{className:`size-4`}),onClick:t,disabled:!u||b.length===0||x.length===0,title:b.length===0?`Connect a host first`:x.length===0?`Add a project first`:void 0,children:`New session`})]}),(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(ke,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-subtle`}),(0,Y.jsx)(Ge,{type:`search`,"aria-label":`Search sessions`,placeholder:`Search sessions, branches`,value:l.query,onChange:e=>c({...l,query:e.target.value}),className:`pl-8`})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,Y.jsx)(Xe,{label:`Session filter`,options:O,value:l.filter,onChange:e=>c({...l,filter:e}),className:`min-w-0 flex-1`,block:!0}),(0,Y.jsx)(R,{label:`View options`,items:E,trigger:e=>(0,Y.jsx)(q,{...e,label:`View options`,icon:(0,Y.jsx)(he,{className:`size-4`})})}),S.groups.length>0&&(0,Y.jsx)(q,{label:D?`Collapse all`:`Expand all`,icon:D?(0,Y.jsx)(ct,{className:`size-4`}):(0,Y.jsx)(ut,{className:`size-4`}),onClick:()=>c({...l,collapsed:D?T:[]})})]})]}),(0,Y.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-2 pt-2`,children:A})]})}function Oi({group:e,depth:t,open:n}){let r=n?se:U;return t===0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),e.kind===`host`&&(0,Y.jsx)(me,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.label,e.detail&&(0,Y.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted`,children:e.detail})]}),e.hostState&&e.hostState!==`connected`&&(0,Y.jsx)(W,{kind:`host`,value:e.hostState,size:`sm`}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-xs font-normal text-muted`,children:[e.sessionCount,(0,Y.jsx)(`span`,{className:`sr-only`,children:` sessions`})]})]}):e.kind===`workspace`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted`}),(0,Y.jsx)(Ce,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-mono text-xs`,title:e.path??void 0,children:e.label}),e.detail&&(0,Y.jsx)(`span`,{className:`block truncate text-xs text-muted`,children:e.detail})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted`}),(0,Y.jsx)(V,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:e.label})]})}function ki({group:e,depth:t,collapsed:n,toggle:r,selectedId:i,screen:a,emptyText:o}){let s=!n.has(e.key);return(0,Y.jsxs)(`li`,{className:`min-w-0`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>r(e.key),className:k(`tap flex w-full min-w-0 items-center gap-1.5 rounded-md text-left hover:bg-surface-2`,t===0?`px-1.5 py-1.5 text-sm font-semibold`:`py-1 pr-1.5 pl-4`),children:(0,Y.jsx)(Oi,{group:e,depth:t,open:s})}),s&&(0,Y.jsxs)(`ul`,{className:k(`flex min-w-0 flex-col`,t>0&&`gap-0.5 py-0.5`),children:[e.rows.length===0&&e.groups.length===0&&(0,Y.jsx)(`li`,{className:`px-7 py-1 text-xs text-muted`,children:o}),e.groups.map(e=>(0,Y.jsx)(ki,{group:e,depth:t+1,collapsed:n,toggle:r,selectedId:i,screen:a,emptyText:o},e.key)),e.rows.map(e=>(0,Y.jsx)(ji,{row:e,indent:t===0?1:2,selected:e.session.id===i,screen:a},e.session.id))]})]})}var Ai=[`pl-2`,`pl-7`,`pl-9`];function ji({row:e,indent:t,selected:n,screen:i}){let{session:a,attention:o}=e,s=[ee(a.lastActivityAt),e.project,e.host,e.branch].filter(Boolean).join(` · `);return(0,Y.jsx)(`li`,{className:`min-w-0`,children:(0,Y.jsxs)(r,{"data-testid":`session-row`,to:`/code/${encodeURIComponent(a.id)}`,"aria-current":n?`page`:void 0,className:k(`tap flex min-w-0 flex-col gap-0.5 rounded-md py-1.5 pr-2 hover:bg-surface-2`,Ai[t],i&&`py-2.5`,n&&`bg-accent-soft hover:bg-accent-soft`),children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:a.title}),o&&(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 text-xs font-medium text-warning`,children:[(0,Y.jsx)(re,{"aria-hidden":!0,className:`size-3.5`}),`Needs you`]})]}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-x-1.5`,children:[(0,Y.jsx)(W,{kind:`runtime`,value:a.runtime,size:`sm`}),a.provenance===`subagent`&&(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:`Subagent`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted`,children:s})]})]})})}var Mi=new Map;function Ni(e,t){t.trim()&&Mi.set(e,t)}function Pi(e){return Mi.get(e)??null}var Fi=`tap block h-9 w-full rounded-md border border-border bg-surface px-2 text-base text-text md:text-sm focus:border-accent focus:outline-none disabled:opacity-55`;function Ii({label:e,htmlFor:t,hint:n,children:r}){return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsx)(`label`,{htmlFor:t,className:`text-sm font-medium`,children:e}),r,n&&(0,Y.jsx)(`div`,{className:`text-xs text-muted`,children:n})]})}function Li(e){return!!e&&!e.revokedAt&&e.connectivity===`connected`}function Ri(e){let t=f(),n=y(e=>e.workspaces),r=y(e=>e.checkouts),i=y(e=>e.profiles),a=y(e=>e.hosts),o=Ie(e=>e.selectedProjectId),s=(0,J.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(`new`),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(``),[b,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(``),[w,T]=(0,J.useState)(``);(0,J.useEffect)(()=>{if(!e)return;let n=t.find(e=>e.id===o)??t[0]??null;l(n?.id??``)},[e]);let E=t.find(e=>e.id===c),D=(0,J.useMemo)(()=>Object.values(n).filter(e=>e.projectId===c&&!e.archivedAt).sort((e,t)=>(e.provenance===`main`?0:1)-(t.provenance===`main`?0:1)||(e.branch??``).localeCompare(t.branch??``)),[n,c]),O=(0,J.useMemo)(()=>Object.values(r).filter(e=>e.projectId===c),[r,c]);(0,J.useEffect)(()=>{if(!E)return;let e=O.find(e=>e.hostId===E.defaultHostId&&Li(a[e.hostId]))??O.find(e=>Li(a[e.hostId]))??O[0];g(e?.id??``);let t=D.find(e=>Li(a[e.hostId]))??D[0];m(t?.id??``),C(E.defaultProfileId??s[0]?.id??``),x(``)},[c]);let k=n[p],A=r[h],j=u===`existing`?k?.hostId:A?.hostId,M=j?a[j]:void 0,N=[];if(E||N.push(`Select a project.`),u===`existing`&&!k&&N.push(`Select a workspace.`),u===`new`){A||N.push(`Select a host checkout.`);let e=vn(_);e&&N.push(e)}return M&&!Li(M)&&N.push(`Host ${M.name} is offline.`),M&&!M.piCompatible&&N.push(`Pi ${M.piVersion??`(not found)`} on ${M.name} is outside the tested range.`),{projects:t,profiles:s,hosts:a,projectWorkspaces:D,projectCheckouts:O,project:E,workspace:k,checkout:A,host:M,preview:u===`existing`?k?{branch:Sn(k),path:k.path}:null:A&&_.trim()?{branch:_.trim(),path:_n(A.path,_,E?.worktreeDir)}:null,problems:N,values:{projectId:c,mode:u,workspaceId:p,checkoutId:h,branch:_,base:b,profileId:S,prompt:w},set:{projectId:l,mode:d,workspaceId:m,checkoutId:g,branch:v,base:x,profileId:C,prompt:T},reset:()=>{v(``),x(``),T(``)}}}function zi({form:e,id:t}){return(0,Y.jsx)(Ii,{label:`Project`,htmlFor:`${t}-project`,children:(0,Y.jsx)(`select`,{id:`${t}-project`,className:Fi,value:e.values.projectId,onChange:t=>e.set.projectId(t.target.value),children:e.projects.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})})}function Bi({form:e,id:t}){let{values:n,set:r,hosts:i}=e;return(0,Y.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Workspace`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`${t}-wsmode`,checked:n.mode===`new`,onChange:()=>r.mode(`new`),className:`size-4`}),`Create a new worktree`]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`${t}-wsmode`,checked:n.mode===`existing`,onChange:()=>r.mode(`existing`),disabled:e.projectWorkspaces.length===0,className:`size-4`}),`Use an existing workspace`,e.projectWorkspaces.length===0&&(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:`(none discovered)`})]})]}),n.mode===`existing`?(0,Y.jsx)(Ii,{label:`Existing workspace`,htmlFor:`${t}-ws`,hint:e.host?`Runs on ${e.host.name}`:void 0,children:(0,Y.jsx)(`select`,{id:`${t}-ws`,className:Fi,value:n.workspaceId,onChange:e=>r.workspaceId(e.target.value),children:e.projectWorkspaces.map(e=>{let t=i[e.hostId];return(0,Y.jsxs)(`option`,{value:e.id,disabled:!Li(t),children:[Sn(e),` on `,t?.name??`unknown host`,Li(t)?``:` (host offline)`]},e.id)})})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ii,{label:`Host and checkout`,htmlFor:`${t}-checkout`,children:(0,Y.jsxs)(`select`,{id:`${t}-checkout`,className:Fi,value:n.checkoutId,onChange:e=>r.checkoutId(e.target.value),children:[e.projectCheckouts.length===0&&(0,Y.jsx)(`option`,{value:``,children:`No checkouts`}),e.projectCheckouts.map(e=>{let t=i[e.hostId];return(0,Y.jsxs)(`option`,{value:e.id,disabled:!Li(t),children:[t?.name??`Unknown host`,`: `,e.path,Li(t)?``:` (host offline)`]},e.id)})]})}),(0,Y.jsx)(Ii,{label:`New branch`,htmlFor:`${t}-branch`,hint:n.branch?vn(n.branch):void 0,children:(0,Y.jsx)(Ge,{id:`${t}-branch`,value:n.branch,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`e.g. fix/login-retry`,onChange:e=>r.branch(e.target.value)})}),(0,Y.jsx)(Ii,{label:`Base branch (optional)`,htmlFor:`${t}-base`,hint:`Defaults to ${e.checkout?.defaultBranch??`the default branch`}.`,children:(0,Y.jsx)(Ge,{id:`${t}-base`,value:n.base,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:e.checkout?.defaultBranch??`main`,onChange:e=>r.base(e.target.value)})})]})]})}function Vi({form:e,id:t}){let n=e.profiles.find(t=>t.id===e.values.profileId);return(0,Y.jsx)(Ii,{label:`Pi profile`,htmlFor:`${t}-profile`,hint:n?[n.provider,n.model,n.thinking?`effort ${n.thinking}`:null].filter(Boolean).join(` · `)||`Pi defaults`:void 0,children:(0,Y.jsx)(`select`,{id:`${t}-profile`,className:Fi,value:e.values.profileId,onChange:t=>e.set.profileId(t.target.value),children:e.profiles.map(t=>(0,Y.jsxs)(`option`,{value:t.id,children:[t.name,e.project?.defaultProfileId===t.id?` (project default)`:``]},t.id))})})}function Hi({form:e,id:t}){return(0,Y.jsx)(Ii,{label:`Initial prompt (optional)`,htmlFor:`${t}-prompt`,children:(0,Y.jsx)(Je,{id:`${t}-prompt`,minRows:3,maxHeight:`30vh`,value:e.values.prompt,placeholder:`What should Pi work on?`,onChange:t=>e.set.prompt(t.target.value)})})}function Ui({form:e}){return(0,Y.jsxs)(`section`,{"aria-label":`Preview`,"data-testid":`new-session-preview`,className:`flex min-w-0 flex-col gap-1 rounded-md border border-border bg-surface-2 p-3 text-sm`,children:[(0,Y.jsxs)(`h3`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,Y.jsx)(Ce,{"aria-hidden":!0,className:`size-4`}),`Result`]}),e.preview?(0,Y.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Branch`}),(0,Y.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:e.preview.branch}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Path`}),(0,Y.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:e.preview.path}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Host`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.host?.name??`Unknown`})]}):(0,Y.jsx)(`p`,{className:`text-muted`,children:`Choose a workspace to see the branch and path.`}),e.values.mode===`new`&&e.preview&&(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`A new Git worktree is created at this path.`})]})}function Wi({problems:e}){return e.length===0?null:(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-muted`,"aria-live":`polite`,children:e.map(e=>(0,Y.jsx)(`li`,{children:e},e))})}var Gi=[`Project`,`Workspace`,`Profile`,`Prompt`];function Ki({open:e,onClose:t,onCreated:n,mobile:r}){let i=(0,J.useId)(),a=Ri(e),[o,s]=(0,J.useState)(0),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null);(0,J.useEffect)(()=>{e||(s(0),d(null),l(!1))},[e]);let f=async()=>{if(a.problems.length||c)return;let e=a.values;l(!0),d(null);try{let t=await Z.createSession({projectId:e.projectId,workspace:e.mode===`existing`?{existingId:e.workspaceId}:{checkoutId:e.checkoutId,newBranch:e.branch.trim(),base:e.base.trim()||null},profileId:e.profileId||null,prompt:e.prompt});y.getState().upsertSessionIfMissing(t),Ni(t.id,e.prompt),a.reset(),n(t.id)}catch(e){d(e)}finally{l(!1)}},p=u===null?null:(0,Y.jsx)(F,{compact:!0,title:`Could not create the session`,error:S(u),onRetry:()=>void f()});if(!r)return(0,Y.jsx)(qe,{open:e,onClose:t,title:`New session`,description:`A task is not required.`,dismissOnBackdrop:!c,className:`max-w-xl`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(N,{onClick:t,children:`Cancel`}),(0,Y.jsx)(N,{variant:`primary`,busy:c,disabled:a.problems.length>0,onClick:()=>void f(),children:`Create session`})]}),children:a.projects.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`Add a project in Settings first.`}):(0,Y.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),f()},children:[(0,Y.jsx)(zi,{form:a,id:i}),(0,Y.jsx)(Bi,{form:a,id:i}),(0,Y.jsx)(Vi,{form:a,id:i}),(0,Y.jsx)(Hi,{form:a,id:i}),(0,Y.jsx)(Ui,{form:a}),(0,Y.jsx)(Wi,{problems:a.problems}),p]})});let m=o===Gi.length-1,h=o===0?a.project?[]:[`Select a project.`]:o===1?a.problems.filter(e=>e!==`Select a project.`):[];return(0,Y.jsxs)(Ue,{open:e,onClose:t,title:`New session: ${Gi[o]}`,description:`Step ${o+1} of ${Gi.length}`,dismissOnBackdrop:!c,footer:(0,Y.jsxs)(Y.Fragment,{children:[o>0&&(0,Y.jsx)(N,{onClick:()=>s(e=>e-1),disabled:c,children:`Back`}),m?(0,Y.jsx)(N,{variant:`primary`,busy:c,disabled:a.problems.length>0,onClick:()=>void f(),children:`Create session`}):(0,Y.jsx)(N,{variant:`primary`,disabled:h.length>0,onClick:()=>s(e=>e+1),children:`Next`})]}),children:[(0,Y.jsx)(`ol`,{"aria-label":`Steps`,className:`mb-3 flex gap-1`,children:Gi.map((e,t)=>(0,Y.jsx)(`li`,{"aria-current":t===o?`step`:void 0,className:k(`h-1 flex-1 rounded-full`,t<=o?`bg-accent`:`bg-border`),children:(0,Y.jsxs)(`span`,{className:`sr-only`,children:[e,t<o?` (done)`:``]})},e))}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[o===0&&(0,Y.jsx)(zi,{form:a,id:i}),o===1&&(0,Y.jsx)(Bi,{form:a,id:i}),o===2&&(0,Y.jsx)(Vi,{form:a,id:i}),o===3&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Hi,{form:a,id:i}),(0,Y.jsx)(Ui,{form:a})]}),o===1&&(0,Y.jsx)(Ui,{form:a}),(0,Y.jsx)(Wi,{problems:m?a.problems:h}),p]})]})}function $({label:e,value:t}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:t})]})}function qi({session:e,hostLabel:t,open:n,onClose:r}){let i=mr(e),a=e.stats;return(0,Y.jsx)(qe,{open:n,onClose:r,title:`Native session information`,children:(0,Y.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-2 text-sm`,children:[(0,Y.jsx)($,{label:`Switchyard session`,value:e.id}),(0,Y.jsx)($,{label:`Pi session id`,value:e.nativeHandle?.sessionId??`Not started`}),(0,Y.jsx)($,{label:`Session file`,value:e.nativeHandle?.sessionFile??`None yet`}),(0,Y.jsx)($,{label:`Host`,value:t}),(0,Y.jsx)($,{label:`Working directory`,value:e.cwd}),(0,Y.jsx)($,{label:`Origin`,value:e.provenance}),(0,Y.jsx)($,{label:`Profile`,value:e.profileSnapshot.name}),(0,Y.jsx)($,{label:`Created`,value:P(e.createdAt)}),a?.tokens!=null&&(0,Y.jsx)($,{label:`Tokens`,value:a.tokens.toLocaleString(`en-US`)}),a?.costUsd!=null&&(0,Y.jsx)($,{label:`Cost`,value:`$${a.costUsd.toFixed(2)}`}),i&&(0,Y.jsx)($,{label:`Context`,value:`${i.label} (${i.detail})`})]})})}function Ji(e){let{session:t,run:r,control:i}=e,a=n(),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(t.title),u=vr(()=>Z.takeover(t.id),{success:`You have control. Automatic continuations are paused.`,errorToast:!0}),d=vr(()=>Z.returnToAutomation(t.id),{success:`Returned to automation.`,errorToast:!0}),f=vr(()=>Z.stop(t.id),{success:`Session stopped.`}),p=vr(()=>Z.resume(t.id),{success:`Session resumed.`,errorToast:!0}),m=vr(e=>Z.rename(t.id,e),{success:`Session renamed.`}),h=vr(()=>Z.archive(t.id),{success:`Session archived.`}),g=e.link===`connected`,_=()=>{s(null),f.reset(),m.reset(),h.reset()},v=t.archivedAt?`Already archived`:mn(t)?`Stop the session before archiving it`:null,y=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(qe,{open:o===`stop`,onClose:_,title:`Stop this session?`,description:`Stops the current execution and clears queued messages.`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(N,{onClick:_,children:`Cancel`}),(0,Y.jsx)(N,{variant:`danger`,busy:f.busy,onClick:()=>void f.run().then(e=>e&&s(null)),children:`Stop session`})]}),children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:r?`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.`}),f.error!==null&&(0,Y.jsx)(F,{compact:!0,title:`Could not stop`,error:S(f.error)})]}),(0,Y.jsx)(qe,{open:o===`rename`,onClose:_,title:`Rename session`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(N,{onClick:_,children:`Cancel`}),(0,Y.jsx)(N,{variant:`primary`,type:`submit`,form:`sy-rename-form`,busy:m.busy,disabled:!c.trim(),children:`Save`})]}),children:(0,Y.jsxs)(`form`,{id:`sy-rename-form`,onSubmit:e=>{e.preventDefault(),c.trim()&&m.run(c.trim()).then(e=>e&&s(null))},className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`label`,{htmlFor:`sy-rename-input`,className:`text-sm font-medium`,children:`Title`}),(0,Y.jsx)(Ge,{id:`sy-rename-input`,value:c,maxLength:200,onChange:e=>l(e.target.value)}),m.error!==null&&(0,Y.jsx)(F,{compact:!0,title:`Could not rename`,error:S(m.error)})]})}),(0,Y.jsxs)(qe,{open:o===`archive`,onClose:_,title:`Archive this session?`,description:`It leaves the navigator. The Pi session file stays on the host.`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(N,{onClick:_,children:`Cancel`}),(0,Y.jsx)(N,{variant:`primary`,busy:h.busy,onClick:()=>void h.run().then(e=>{e&&(s(null),a(`/code`))}),children:`Archive`})]}),children:[t.runtime===`idle`&&(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`The idle Pi process is stopped first.`}),h.error!==null&&(0,Y.jsx)(F,{compact:!0,title:`Could not archive`,error:S(h.error)})]}),(0,Y.jsx)(qi,{session:t,hostLabel:`${e.hostName} (${e.link})`,open:o===`info`,onClose:_})]});return{canTakeover:i===`automation`,canReturn:i===`human`,canStop:mn(t)&&g,canResume:!pn(t)&&!!t.nativeHandle&&!t.readOnly&&g,archiveBlocked:v,takeover:()=>void u.run(),returnToAutomation:()=>void d.run(),requestStop:()=>s(`stop`),resume:()=>void p.run(),openRename:()=>{l(t.title),s(`rename`)},requestArchive:()=>{v?G.info(v):s(`archive`)},openInfo:()=>s(`info`),busy:{takeover:u.busy,ret:d.busy,stop:f.busy,resume:p.busy},dialogs:y}}function Yi({view:e,open:t,busy:n,mobile:r,onClose:i,onRun:a}){if(!e)return null;let o=e.actions.length>0?(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions.map(e=>(0,Y.jsx)(N,{size:`sm`,variant:e.tone===`primary`?`primary`:e.tone===`danger`?`danger`:`secondary`,disabled:n,onClick:()=>a(e.command),children:e.label},e.command))}):void 0,s=(0,Y.jsx)(xe,{node:e.body});return r?(0,Y.jsx)(Ue,{open:t,onClose:i,title:e.title,footer:o,children:s}):(0,Y.jsx)(We,{open:t,onClose:i,title:e.title,footer:o,width:720,children:s})}function Xi({open:e,onOpenChange:t,trigger:n,label:r,side:i=`bottom`,align:a=`start`,initialFocus:o,className:s,fitViewport:c,children:l}){let u=(0,J.useId)(),d=(0,J.useRef)(null),f=(0,J.useRef)(null);Ke(d,e,()=>t(!1),o);let[p,m]=(0,J.useState)(null);return(0,J.useLayoutEffect)(()=>{if(!e||!c){m(null);return}let t=()=>{let e=f.current?.getBoundingClientRect();if(!e)return;let t=Math.min(288,window.innerWidth-16),n=Math.min(Math.max(e.left,8),window.innerWidth-t-8);m(i===`top`?{position:`fixed`,width:t,left:n,bottom:window.innerHeight-e.top+4}:{position:`fixed`,width:t,left:n,top:e.bottom+4})};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,c,i]),(0,J.useEffect)(()=>{if(!e)return;let n=e=>{let n=e.target;!d.current?.contains(n)&&!f.current?.contains(n)&&t(!1)};return document.addEventListener(`pointerdown`,n),()=>document.removeEventListener(`pointerdown`,n)},[e,t]),(0,Y.jsxs)(`div`,{className:`relative inline-flex`,children:[n({ref:f,onClick:()=>t(!e),"aria-haspopup":`dialog`,"aria-expanded":e,"aria-controls":u}),e&&(0,Y.jsx)(`div`,{ref:d,id:u,role:`dialog`,"aria-label":r,tabIndex:-1,style:p??void 0,className:k(p?`fixed`:`absolute`,`z-40 max-w-[calc(100vw-1rem)] rounded-lg border border-border bg-surface p-3 shadow-pop`,!p&&(i===`top`?`bottom-full mb-1`:`top-full mt-1`),!p&&(a===`end`?`right-0`:`left-0`),s),children:l})]})}function Zi({icon:e,label:t,ariaLabel:n,disabled:r,className:i,...a}){return(0,Y.jsxs)(`button`,{type:`button`,disabled:r,"aria-label":n,className:k(`tap inline-flex h-8 min-w-0 items-center gap-1.5 rounded-md bg-surface-2 px-2.5 text-xs font-medium text-text transition-colors hover:bg-border disabled:opacity-55`,i),...a,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-muted`,children:e}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]})}function Qi({session:e,searchInFooter:t,searchRef:n,onChosen:r}){let[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(`favorites`),g=(0,J.useCallback)(()=>{let t=new AbortController;return s(null),Z.models(e.id,t.signal).then(e=>a(e.models),e=>{t.signal.aborted||s(e)}),()=>t.abort()},[e.id]);(0,J.useEffect)(()=>g(),[g]);let _=async t=>{p(!0),l(null);try{await Z.setModel(e.id,t.provider,t.id),G.success(`Model: ${ur(t)}`),r()}catch(e){l(e)}finally{p(!1)}},v=i?.some(e=>e.scoped===!0)??!1,y=v&&m===`favorites`,b=i&&y?cr(i,e.model??null):i,x=b?pr(b,u):[],S=(0,Y.jsx)(Ge,{ref:n,placeholder:`Search models`,"aria-label":`Search models`,value:u,onChange:e=>d(e.target.value)});return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[!t&&S,v&&(0,Y.jsx)(Xe,{label:`Show`,value:m,onChange:h,options:[{value:`favorites`,label:`Favorites`},{value:`all`,label:`All`}]}),c!=null&&(0,Y.jsx)(F,{compact:!0,title:`Could not change`,error:c}),(0,Y.jsx)(`div`,{className:`flex max-h-[60vh] min-w-0 flex-col gap-3 overflow-y-auto`,children:o==null?i?x.length===0?y?(0,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No favorites match`}),(0,Y.jsx)(N,{size:`sm`,variant:`ghost`,onClick:()=>h(`all`),children:`Search all models`})]}):(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No models match`}):x.map(t=>(0,Y.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`h3`,{className:`text-xs font-medium text-muted`,children:t.provider}),t.models.map(t=>{let n=e.model?.provider===t.provider&&e.model.id===t.id;return(0,Y.jsxs)(`button`,{type:`button`,disabled:f,"aria-current":n?`true`:void 0,onClick:()=>void _(t),className:`tap flex min-h-11 min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-surface-2 disabled:opacity-55`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate`,children:ur(t)}),(0,Y.jsxs)(`span`,{className:`block truncate font-mono text-xs text-muted`,children:[t.provider,`/`,t.id,t.contextWindow!==null&&` · ${Math.round(t.contextWindow/1e3)}k context`]})]}),n&&(0,Y.jsx)(pe,{"aria-hidden":!0,className:`size-4`})]},t.id)})]},t.provider)):(0,Y.jsx)(I,{label:`Loading models…`}):(0,Y.jsx)(F,{title:`Could not load models`,error:o,onRetry:g})}),t&&(0,Y.jsx)(`div`,{className:`sticky bottom-0 bg-surface pt-2`,children:S})]})}function $i({session:e,enabled:t,mobile:n,open:r,onOpenChange:i}){let a=(0,J.useRef)(null),o=e.model;if(!o)return null;let s=sr(o),c=t?`Model: ${s}. Change model`:`Model: ${s}`,l=t=>(0,Y.jsx)(Qi,{session:e,searchInFooter:t,searchRef:a,onChosen:()=>i(!1)});return n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Zi,{className:`max-w-[60vw]`,icon:(0,Y.jsx)(ft,{className:`size-3.5`}),label:s,ariaLabel:c,disabled:!t,onClick:()=>i(!0)}),(0,Y.jsx)(Ue,{open:r,onClose:()=>i(!1),title:`Model`,children:l(!0)})]}):(0,Y.jsx)(Xi,{open:r,onOpenChange:i,side:`top`,align:`start`,label:`Model`,className:`w-96`,initialFocus:a,trigger:e=>(0,Y.jsx)(Zi,{...e,className:`max-w-64`,icon:(0,Y.jsx)(ft,{className:`size-3.5`}),label:s,ariaLabel:c,disabled:!t}),children:l(!1)})}function ea(e){let t=e.model?.thinkingLevels??[],n=e.thinking??t[0]??`off`,[r,i]=(0,J.useState)(n),a=(0,J.useRef)(null),o=(0,J.useRef)({draft:r,session:e});o.current={draft:r,session:e};let s=(0,J.useCallback)(e=>{let t=o.current.session;e!==t.thinking&&Z.setThinking(t.id,e).catch(e=>{G.error(S(e)),i(t.thinking??t.model?.thinkingLevels[0]??`off`)})},[]),c=(0,J.useCallback)(()=>{a.current!==null&&(clearTimeout(a.current),a.current=null,s(o.current.draft))},[s]);return(0,J.useEffect)(()=>{a.current===null&&i(n)},[e.thinking,e.model?.id]),(0,J.useEffect)(()=>c,[]),{level:r,setLevel:e=>{i(e),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,s(e)},400)},flush:c}}function ta({levels:e,level:t,onChange:n,large:r}){let i=lr(e,t),a=Math.max(e.length-1,1),o=e=>`calc(8px + (100% - 16px) * ${e/a})`;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:`Effort`}),(0,Y.jsx)(`span`,{className:`text-sm font-medium capitalize`,children:t})]}),(0,Y.jsxs)(`div`,{className:k(`group relative w-full`,r?`h-11`:`h-8`),children:[(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-x-2 top-1/2 h-0.5 -translate-y-1/2 rounded-full bg-border-strong`}),(0,Y.jsx)(`div`,{className:`pointer-events-none absolute left-2 top-1/2 h-0.5 -translate-y-1/2 rounded-full bg-accent transition-[width]`,style:{width:`calc((100% - 16px) * ${i/a})`}}),e.map((e,t)=>(0,Y.jsx)(`span`,{"aria-hidden":!0,"data-effort-dot":t===i?`selected`:void 0,className:k(`pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full transition-all`,t===i?`size-4 bg-accent ring-4 ring-accent-soft group-has-[input:focus-visible]:outline-2 group-has-[input:focus-visible]:outline-offset-2 group-has-[input:focus-visible]:outline-accent`:t<i?`size-2.5 bg-accent`:`size-2.5 bg-border-strong`),style:{left:o(t)}},e)),(0,Y.jsx)(`input`,{type:`range`,min:0,max:e.length-1,step:1,value:i,onChange:t=>n(e[Number(t.target.value)]),"aria-label":`Effort`,"aria-valuetext":t,className:`peer absolute inset-0 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0 [&::-moz-range-thumb]:size-4 [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none`})]}),(0,Y.jsx)(`div`,{className:`relative h-4 text-[11px] text-muted`,children:e.map((e,t)=>(0,Y.jsx)(`span`,{className:k(`absolute top-0 -translate-x-1/2 whitespace-nowrap`,t===i&&`font-medium text-text`),style:{left:o(t)},children:e},e))}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Applies from the next turn.`})]})}function na({session:e,enabled:t,mobile:n}){let[r,i]=(0,J.useState)(!1),a=ea(e),o=e.model?.thinkingLevels??[];if(!e.model||o.length<=1)return null;let s=e=>{e||a.flush(),i(e)},c={icon:(0,Y.jsx)(nt,{className:`size-3.5`}),label:a.level,ariaLabel:`Effort: ${a.level}`,disabled:!t,className:`shrink-0 capitalize`};return(0,Y.jsx)(Xi,{open:r,onOpenChange:s,side:`top`,align:`start`,label:`Effort`,className:`w-72`,fitViewport:n,trigger:e=>(0,Y.jsx)(Zi,{...e,...c}),children:(0,Y.jsx)(ta,{levels:o,level:a.level,onChange:a.setLevel,large:n})})}function ra({session:e,enabled:t}){let n=mr(e);if(!n)return null;let r=mn(e),i=t?e.compacting?`Compaction is running`:r?`Wait for the run to finish`:void 0:`The session is not running`,a=[{id:`detail`,heading:n.detail},{id:`compact`,label:`Compact now`,icon:(0,Y.jsx)(Xt,{className:`size-4`}),disabled:!!i,hint:i,onSelect:()=>{Z.compact(e.id).then(()=>G.success(`Compacting context`),e=>G.error(S(e)))}}],o={danger:`bg-danger`,warning:`bg-warning`,muted:`bg-subtle`}[n.tone];return(0,Y.jsx)(R,{side:`top`,align:`start`,label:`Context`,items:a,className:`w-full`,trigger:t=>(0,Y.jsxs)(`button`,{type:`button`,...t,"aria-label":e.compacting?`Context compacting`:`Context ${n.label} used`,title:n.detail,className:`relative flex w-full items-center gap-2 py-0.5 text-[11px] leading-4 text-muted transition-colors before:absolute before:inset-x-0 before:-top-3 before:bottom-0 before:content-[''] hover:text-text [@media(pointer:coarse)]:before:-top-6`,children:[(0,Y.jsx)(`span`,{className:`h-[3px] flex-1 overflow-hidden rounded-full bg-surface-2`,children:(0,Y.jsx)(`span`,{className:k(`block h-full rounded-full transition-[width]`,o),style:{width:`${Math.min(100,n.percent??0)}%`}})}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:n.label})]})})}function ia({mobile:e,...t}){return e?(0,Y.jsx)(Ue,{...t}):(0,Y.jsx)(qe,{...t})}function aa({session:e,mode:t,open:n,mobile:r,onClose:i,onPick:a}){let[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!n)return;s(null),l(null);let t=!0;return Z.tree(e.id).then(e=>t&&s(e.rows),e=>t&&l(e)),()=>{t=!1}},[n,e.id]);let u=o===null?[]:t===`fork`?o.filter(e=>e.role===`user`&&e.activeBranch).reverse():o;return(0,Y.jsx)(ia,{mobile:r,open:n,onClose:i,title:t===`fork`?`Fork from a message`:`Start a new session from…`,children:c===null?o===null?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`Loading…`}):u.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`Nothing to branch from yet`}):(0,Y.jsx)(`ul`,{className:`flex max-h-[60vh] flex-col gap-1 overflow-y-auto`,children:u.map(e=>(0,Y.jsx)(`li`,{style:{paddingLeft:`${Math.min(e.depth,8)*12}px`},children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e.entryId),className:k(`flex w-full min-w-0 items-start gap-2 rounded-md border-l-2 px-2 py-1.5 text-left text-sm hover:bg-surface-2`,e.activeBranch?`border-accent`:`border-transparent`),children:[(0,Y.jsx)(`span`,{className:`w-8 shrink-0 text-xs text-muted`,children:e.role===`user`?`You`:`Pi`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.text||`(empty)`}),e.label&&(0,Y.jsx)(d,{children:e.label}),e.leaf&&(0,Y.jsx)(d,{children:`current`})]})},e.entryId))}):(0,Y.jsx)(F,{compact:!0,title:`Could not load the conversation`,error:S(c)})})}function oa({session:e,open:t,mobile:n,onClose:r,onOpen:i}){let[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1);(0,J.useEffect)(()=>{if(!t)return;o(null),c(null);let n=!0;return Z.importable(e.hostId).then(e=>n&&o(e),e=>n&&c(e)),()=>{n=!1}},[t,e.hostId]);let d=(a??[]).filter(t=>t.cwd===e.cwd&&t.sessionFile!==e.nativeHandle?.sessionFile).sort((e,t)=>String(t.mtime).localeCompare(String(e.mtime))),f=async t=>{try{if(t.importedSessionId){i(t.importedSessionId);return}u(!0);let n=await Z.importSession(e.hostId,t.sessionFile,e.projectId);y.getState().upsertSessionIfMissing(n),i(n.id)}catch(e){c(e)}finally{u(!1)}};return(0,Y.jsx)(ia,{mobile:n,open:t,onClose:r,title:`Open another Pi session`,children:s===null?a===null?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`Loading…`}):d.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No other Pi sessions in this folder`}):(0,Y.jsx)(`ul`,{className:`flex max-h-[60vh] flex-col gap-1 overflow-y-auto`,children:d.map(e=>{let t=e.importedSessionId!==null||e.inactive;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,disabled:!t||l,onClick:()=>void f(e),className:`flex w-full min-w-0 flex-col rounded-md px-2 py-1.5 text-left text-sm hover:bg-surface-2 disabled:opacity-60`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.name??e.sessionId}),(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[ee(e.mtime),!t&&` · Open in Pi; close it there to import`]})]})},e.sessionFile)})}):(0,Y.jsx)(F,{compact:!0,title:`Could not open it`,error:S(s)})})}var sa={switchyard:`Switchyard`,extension:`Extension`,prompt:`Prompt`,skill:`Skill`,terminal:`Terminal only`};function ca({id:e,items:t,active:n,onPick:r,onHover:i,className:a}){return(0,Y.jsx)(`div`,{className:a,children:(0,Y.jsx)(`div`,{role:`listbox`,id:e,"aria-label":`Arguments`,"data-testid":`arg-completions`,className:`max-h-72 overflow-y-auto`,children:t.map((t,a)=>(0,Y.jsx)(`div`,{role:`option`,id:`${e}-${a}`,"aria-selected":a===n,tabIndex:-1,className:k(`cursor-pointer rounded-md px-2 py-1.5 text-sm`,a===n&&`bg-surface-2`),onMouseDown:e=>e.preventDefault(),onClick:()=>r(t.value),onKeyDown:()=>void 0,onMouseEnter:()=>i?.(a),children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:t.label}),t.description&&(0,Y.jsx)(`span`,{className:`truncate text-xs text-muted`,children:t.description})]})},t.value))})})}function la({id:e,entries:t,active:n,onPick:r,onHover:i,status:a,className:o}){let s=(0,J.useRef)(null);return(0,J.useEffect)(()=>{s.current?.querySelector(`[id="${e}-${n}"]`)?.scrollIntoView?.({block:`nearest`})},[n,e]),(0,Y.jsxs)(`div`,{className:o,children:[(0,Y.jsx)(`div`,{ref:s,role:`listbox`,id:e,"aria-label":`Commands`,className:`max-h-72 overflow-y-auto`,children:t.map((t,a)=>(0,Y.jsxs)(`div`,{role:`option`,id:`${e}-${a}`,"aria-selected":a===n,"aria-disabled":t.source===`terminal`||void 0,tabIndex:-1,className:k(`cursor-pointer rounded-md px-2 py-1.5 text-sm`,a===n&&`bg-surface-2`,t.source===`terminal`&&`opacity-60`),onMouseDown:e=>e.preventDefault(),onClick:()=>r(t),onKeyDown:()=>void 0,onMouseEnter:()=>i?.(a),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`/`,t.name]}),t.argumentHint&&(0,Y.jsx)(`span`,{className:`text-muted`,children:t.argumentHint}),(0,Y.jsx)(d,{className:`ml-auto`,children:sa[t.source]})]}),t.description&&(0,Y.jsx)(`div`,{className:`truncate text-xs text-muted`,children:t.description})]},`${t.source}:${t.name}`))}),a&&(0,Y.jsx)(`p`,{className:`px-2 py-1 text-xs text-muted`,children:a})]})}var ua={for:``,items:[],prefix:``};function da(e,t,n){let[r,i]=(0,J.useState)(ua);return(0,J.useEffect)(()=>{if(!n||!tr(t)){i(ua);return}let r=new AbortController,a=setTimeout(()=>{Z.complete(e,t,r.signal).then(e=>{r.signal.aborted||i({for:t,items:e.items,prefix:e.prefix})}).catch(()=>{r.signal.aborted||i(ua)})},150);return()=>{clearTimeout(a),r.abort()}},[e,t,n]),r.for===t?{items:r.items.filter(e=>e.value!==r.prefix),prefix:r.prefix}:{items:[],prefix:``}}var fa=new Map,pa=3e4;function ma(e,t){let[n,r]=(0,J.useState)(fa.get(e)?.commands??[]),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(null),c=(0,J.useRef)(null),l=(0,J.useCallback)(()=>{let n=fa.get(e);if(r(n?.commands??[]),s(null),a(!1),c.current?.abort(),!t||n&&Date.now()-n.at<pa)return;let i=new AbortController;c.current=i,a(!0),Z.commands(e,i.signal).then(t=>{i.signal.aborted||(fa.set(e,{at:Date.now(),commands:t.commands}),r(t.commands))}).catch(e=>{i.signal.aborted||s(e)}).finally(()=>{i.signal.aborted||a(!1)})},[e,t]);return(0,J.useEffect)(()=>(l(),()=>c.current?.abort()),[l]),{commands:n,loading:i,error:o,refresh:l}}var ha=`Automation is active; take over to stop automatic continuations`;function ga({ctx:e,draft:t,setDraft:r,clearDraft:i,mobile:a,onTakeover:o,takeoverBusy:s,onResume:c,resumeBusy:l,className:u}){let{session:d,host:f}=e,p=Ie(e=>e.sendWithEnter),[m,h]=(0,J.useState)([]),[g,_]=(0,J.useState)(null),[v,b]=(0,J.useState)(null),[x,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)(!1),[D,A]=(0,J.useState)(!1),[j,M]=(0,J.useState)(!1),[P,I]=(0,J.useState)(0),[ee,L]=(0,J.useState)(!1),[te,ne]=(0,J.useState)(null),[re,ie]=(0,J.useState)(!1),[ae,oe]=(0,J.useState)(null),se=n(),R=(0,J.useRef)(null),ce=(0,J.useRef)(null),le=(0,J.useRef)(null),z=(0,J.useId)();Fe(a&&x),(0,J.useEffect)(()=>{h([]),b(null)},[d.id]);let B=zn({session:d,hostLink:e.link,hostName:e.hostName}),ue=Bn(d,f?.capabilities),de=mn(d),fe=t.trim(),pe=!fe,me=e.adapters.filter(e=>e.status===`active`&&e.capabilities.includes(`commands`)),V=!a&&!j&&/^\/\S*$/.test(t)&&x,H=hr(f,B),{commands:he,error:U,loading:ge,refresh:_e}=ma(d.id,H),ve=H?er(Xn,he):[],[ye,be]=(0,J.useState)(!1),xe=da(d.id,t,H&&x&&!V),Se=xe.items.length>0&&!ye,Ce=H&&!V&&!Se?rr(t,ve):null,we=e=>{r(nr(t,xe.prefix,e)),R.current?.focus()},Ee=V?ir(ve,t.slice(1)):[],Oe=H?ar(fe):null,ke=Oe?or(Oe,de,!!d.nativeHandle):null,Ae=e=>se(`/code/${encodeURIComponent(e)}`),je=async e=>{if(!d.projectId||!d.workspaceId)throw Error(`This session has no project workspace`);let t=await Z.createSession({projectId:d.projectId,workspace:{existingId:d.workspaceId},prompt:e});return y.getState().upsertSessionIfMissing(t),e&&Ni(t.id,e),t},Me=async e=>{if(e.session){y.getState().upsertSessionIfMissing(e.session),e.prefill&&Or(e.session.id,e.prefill),Z.resume(e.session.id).catch(()=>{}),Ae(e.session.id);return}let t=await je(``);Or(t.id,e.prefill??``),Ae(t.id)},Ne=async e=>{ie(!0);try{let t=await Z.prompt(d.id,{text:e,mode:`prompt`});t?.result?.view?ne(t.result.view):(ne(null),G.success(`Ran ${e}`))}catch(e){G.error(S(e))}finally{ie(!1)}},Pe=async e=>{let t=ae===`fork`;oe(null);try{await Me(await Z.branch(d.id,e,t))}catch(e){G.error(S(e))}},W=e=>{r(`/${e.name} `),R.current?.focus()};(0,J.useEffect)(()=>{I(0),be(!1)},[t]),(0,J.useEffect)(()=>{(V||D)&&_e()},[V,D]);let K=async e=>{if(B||pe||g||ke)return;let n=t;_(e),b(null);try{if(Oe){await Re(Oe),R.current?.value===n&&i(),M(!1);return}let t=await Z.prompt(d.id,{text:fe,mode:e,images:m.map(e=>({mimeType:e.mimeType,data:e.data})),clientMessageId:`cm_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`});R.current?.value===n&&i(),h([]),M(!1),t?.result?.view&&ne(t.result.view),t?.automationActive?G.info(ha):e===`followUp`?G.success(`Follow-up queued`):e===`steer`&&G.success(`Steering message sent`)}catch(t){b({error:t,mode:e})}finally{_(null)}},Re=async e=>{switch(e.kind){case`model-picker`:L(!0);return;case`model`:await Z.setModel(d.id,e.provider,e.modelId),G.success(`Model: ${e.provider}/${e.modelId}`);return;case`thinking`:await Z.setThinking(d.id,e.level),G.success(`Effort: ${e.level}`);return;case`compact`:await Z.compact(d.id,e.instructions),G.success(`Compacting context`);return;case`name`:await Z.rename(d.id,e.title),G.success(`Session renamed`);return;case`new`:Ae((await je(e.prompt)).id);return;case`fork`:oe(`fork`);return;case`tree`:oe(`tree`);return;case`resume`:oe(`resume`);return;case`clone`:await Me(await Z.branch(d.id,null,!1));return;case`reload`:await Z.reload(d.id),G.success(`Reloading Pi…`);return;case`export`:{let e=await Z.exportFile(d.id),t=URL.createObjectURL(new Blob([e.content],{type:`application/x-ndjson`})),n=document.createElement(`a`);n.href=t,n.download=e.fileName,n.click(),URL.revokeObjectURL(t);return}case`session`:oe(`info`);return;case`copy`:d.lastAssistantText?(await navigator.clipboard.writeText(d.lastAssistantText),G.success(`Copied the last reply`)):G.info(`No reply to copy yet`);return;default:return}},ze=ue.prompt?`prompt`:ue.followUp?`followUp`:ue.steer?`steer`:null,Be=async e=>{if(e)for(let t of Array.from(e))try{let e=await Gn(t);h(t=>[...t,e])}catch(e){G.error(S(e))}},Ve=B?B.reason:ke||(de&&!ze?`Pi is running and this runtime cannot queue messages; wait or stop the session`:pe&&m.length>0?`Add a message to send with the images`:null),He=(0,J.useRef)(null),We=(e,t)=>a?{onPointerDown:e=>e.preventDefault(),onTouchStart:e=>{let t=e.touches[0];He.current=t?{x:t.screenX,y:t.screenY}:null},onTouchEnd:n=>{let r=He.current;He.current=null;let i=n.changedTouches[0];r&&i&&(Math.hypot(i.screenX-r.x,i.screenY-r.y)>12||(n.preventDefault(),t&&(K(e),R.current?.blur())))}}:void 0,Ge=H&&d.model?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($i,{session:d,enabled:H,mobile:a,open:ee,onOpenChange:L}),(0,Y.jsx)(`span`,{className:k(`contents`,de&&`max-md:hidden`),children:(0,Y.jsx)(na,{session:d,enabled:H,mobile:a})})]}):null,Ke=d.queue.steering.length+d.queue.followUp.length;return(0,Y.jsxs)(`section`,{"data-testid":`composer`,"aria-label":`Composer`,className:k(`shrink-0 border-t border-border bg-surface px-3 pt-2 pb-2 md:px-6`,u),children:[(0,Y.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-2`,children:[H&&d.model&&(0,Y.jsx)(ra,{session:d,enabled:H}),e.control===`automation`&&!B&&(0,Y.jsxs)(`div`,{role:`note`,className:`flex flex-wrap items-center gap-2 rounded-md bg-warning-soft px-3 py-1.5 text-sm`,children:[(0,Y.jsx)(O,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:ha}),o&&(0,Y.jsx)(N,{size:`sm`,icon:(0,Y.jsx)(Te,{className:`size-3.5`}),busy:s,onClick:o,children:`Take over`})]}),e.control===`human`&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-muted`,children:[(0,Y.jsx)(Te,{"aria-hidden":!0,className:`size-3.5`}),`You have control. Automatic continuations are paused.`]}),B&&(0,Y.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-2 rounded-md bg-surface-2 px-3 py-1.5 text-sm`,children:[B.pending&&(0,Y.jsx)(E,{className:`size-4 shrink-0 text-info`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 font-medium`,children:B.reason}),B.action===`resume`&&c&&(0,Y.jsx)(N,{size:`sm`,variant:`primary`,icon:(0,Y.jsx)(De,{className:`size-3.5`}),busy:l,onClick:c,children:`Resume`})]}),Ke>0&&(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[d.queue.steering.length>0&&`${d.queue.steering.length} steering message${d.queue.steering.length===1?``:`s`} pending. `,d.queue.followUp.length>0&&`${d.queue.followUp.length} follow-up${d.queue.followUp.length===1?``:`s`} queued.`]}),m.length>0&&(0,Y.jsx)(`ul`,{"aria-label":`Attachments`,className:`flex flex-wrap gap-2`,children:m.map(e=>(0,Y.jsxs)(`li`,{className:`relative flex items-center gap-2 rounded-md border border-border bg-surface-2 py-1 pr-1 pl-1`,children:[(0,Y.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`size-9 rounded object-cover`}),(0,Y.jsx)(`span`,{className:`max-w-32 truncate text-xs`,children:e.name}),(0,Y.jsx)(q,{size:`sm`,label:`Remove ${e.name}`,icon:(0,Y.jsx)(Le,{className:`size-3.5`}),onClick:()=>h(t=>t.filter(t=>t.id!==e.id))})]},e.id))}),(0,Y.jsxs)(`div`,{className:`relative min-w-0`,children:[Se&&(0,Y.jsx)(ca,{className:`absolute bottom-full left-0 z-20 mb-1 w-full rounded-lg border border-border bg-surface p-1 shadow-pop`,id:`${z}-args`,items:xe.items,active:Math.min(P,xe.items.length-1),onPick:we,onHover:I}),V&&H&&(0,Y.jsx)(la,{className:`absolute bottom-full left-0 z-20 mb-1 w-full rounded-lg border border-border bg-surface p-1 shadow-pop`,id:`${z}-cmds`,entries:Ee,active:P,onPick:W,onHover:I,status:ge&&he.length===0?`Loading Pi's commands…`:U?`Pi's commands could not be loaded: ${S(U)}`:Ee.length===0?`No matching command; Enter sends the text to Pi`:null}),Ce&&(0,Y.jsxs)(`p`,{"data-testid":`command-args-hint`,className:`absolute bottom-full left-0 z-10 mb-1 rounded-md bg-surface px-2 py-0.5 font-mono text-xs text-muted`,children:[`/`,Ce.name,` `,Ce.hint]}),V&&!H&&(0,Y.jsx)(_a,{className:`absolute bottom-full left-0 z-20 mb-1 w-full rounded-lg border border-border bg-surface p-3 shadow-pop`,adapters:me.map(e=>e.id),onClose:()=>M(!0)}),(0,Y.jsx)(`label`,{htmlFor:`${z}-input`,className:`sr-only`,children:`Message to Pi`}),(0,Y.jsx)(Je,{id:`${z}-input`,ref:R,value:t,minRows:a?1:2,maxHeight:`33vh`,disabled:d.readOnly,...V&&H?{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":!0,"aria-controls":`${z}-cmds`,"aria-activedescendant":Ee.length?`${z}-cmds-${P}`:void 0}:{},"aria-describedby":Ve?`${z}-reason`:void 0,placeholder:d.readOnly?Ln:de?`Steer Pi or queue a follow-up…`:`Message Pi… ( / for commands)`,onChange:e=>{r(e.target.value),e.target.value.startsWith(`/`)||M(!1)},onFocus:()=>C(!0),onBlur:()=>C(!1),onPaste:e=>{let t=[...e.clipboardData.files].filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Be(t))},enterKeyHint:a?`enter`:`send`,onKeyDown:e=>{if(Se){let t=xe.items.length;if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),I(n=>e.key===`ArrowDown`?(n+1)%t:(n-1+t)%t);return}if(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){e.preventDefault(),we(xe.items[Math.min(P,t-1)].value);return}if(e.key===`Escape`){e.preventDefault(),be(!0);return}}if(V&&H&&Ee.length>0){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=Ee.length;I(n=>e.key===`ArrowDown`?(n+1)%t:(n-1+t)%t);return}if(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){e.preventDefault(),W(Ee[Math.min(P,Ee.length-1)]);return}}e.key===`Escape`&&V?(e.preventDefault(),M(!0)):e.key!==`Enter`||e.nativeEvent.isComposing||a||(p?!e.shiftKey:e.metaKey||e.ctrlKey)&&(e.preventDefault(),ze&&K(ze))}})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,Y.jsx)(`input`,{ref:ce,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,onChange:e=>{Be(e.target.files),e.target.value=``,T(!1)}}),(0,Y.jsx)(`input`,{ref:le,type:`file`,accept:`image/*`,capture:`environment`,hidden:!0,onChange:e=>{Be(e.target.files),e.target.value=``,T(!1)}}),(0,Y.jsx)(q,{label:`Attach images`,icon:(0,Y.jsx)(Wt,{className:`size-4`}),disabled:d.readOnly,onClick:()=>a?T(!0):ce.current?.click()}),(0,Y.jsx)(q,{label:`Commands`,icon:(0,Y.jsx)(Qt,{className:`size-4`}),disabled:d.readOnly,onClick:()=>{a?A(!0):(t.startsWith(`/`)||r(`/${t}`),M(!1),R.current?.focus())}}),Ge?(0,Y.jsx)(`div`,{"data-testid":`session-controls`,className:`flex min-w-0 flex-1 items-center gap-1 max-md:overflow-hidden`,children:Ge}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`hidden min-w-0 flex-1 truncate text-xs text-muted sm:inline`,title:`Profile, model and effort come from the session's Pi profile (Settings › Profiles). They apply when a session starts.`,children:fr(d)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 sm:hidden`})]}),!a&&!de&&(0,Y.jsx)(`span`,{className:`hidden text-xs text-subtle lg:inline`,children:p?`Enter to send · Shift+Enter for newline`:`Ctrl+Enter to send`}),de?(0,Y.jsxs)(Y.Fragment,{children:[ue.steer&&(0,Y.jsx)(N,{size:`sm`,className:`shrink-0`,icon:(0,Y.jsx)(Rt,{className:`size-3.5`}),busy:g===`steer`,disabled:!!B||pe||!!ke||g!==null&&g!==`steer`,onClick:()=>void K(`steer`),...We(`steer`,!B&&!pe&&!ke&&(g===null||g===`steer`)),children:(0,Y.jsx)(`span`,{className:`max-[379px]:sr-only`,children:`Steer`})}),ue.followUp&&(0,Y.jsxs)(N,{size:`sm`,variant:`primary`,className:`shrink-0`,icon:(0,Y.jsx)(Mt,{className:`size-3.5`}),busy:g===`followUp`,disabled:!!B||pe||!!ke||g!==null&&g!==`followUp`,onClick:()=>void K(`followUp`),...We(`followUp`,!B&&!pe&&!ke&&(g===null||g===`followUp`)),children:[(0,Y.jsx)(`span`,{className:`max-[379px]:hidden`,children:`Queue follow-up`}),(0,Y.jsx)(`span`,{className:`min-[380px]:hidden`,children:`Queue`})]})]}):(0,Y.jsx)(N,{size:`sm`,variant:`primary`,icon:(0,Y.jsx)(Jt,{className:`size-3.5`}),busy:g===`prompt`,disabled:!!B||pe||!!ke,onClick:()=>void K(`prompt`),...We(`prompt`,!B&&!pe&&!ke&&g===null),children:`Send`})]}),de&&!ue.steer&&f?.capabilities&&(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Immediate steering is not supported by this runtime; messages are queued as follow-ups.`}),Ve&&!B&&(0,Y.jsx)(`p`,{id:`${z}-reason`,className:`text-xs text-muted`,children:Ve}),B&&(0,Y.jsxs)(`p`,{id:`${z}-reason`,className:`sr-only`,children:[`Sending is unavailable: `,B.reason]}),v&&(0,Y.jsx)(F,{compact:!0,title:`Message not sent. Your draft is kept.`,error:S(v.error),onRetry:()=>void K(v.mode)})]}),(0,Y.jsx)(Ue,{open:w,onClose:()=>T(!1),title:`Attach images`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(N,{block:!0,icon:(0,Y.jsx)(At,{className:`size-4`}),onClick:()=>ce.current?.click(),children:`Choose photos`}),(0,Y.jsx)(N,{block:!0,icon:(0,Y.jsx)(it,{className:`size-4`}),onClick:()=>le.current?.click(),children:`Take photo`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Images up to 10 MB are sent with your next message.`})]})}),(0,Y.jsxs)(Ue,{open:D,onClose:()=>A(!1),title:`Commands`,children:[H?(0,Y.jsx)(la,{id:`${z}-sheet-cmds`,entries:ve,active:-1,status:ge&&he.length===0?`Loading Pi's commands…`:U?`Pi's commands could not be loaded: ${S(U)}`:null,onPick:e=>{r(`/${e.name} `),A(!1),requestAnimationFrame(()=>R.current?.focus())}}):(0,Y.jsx)(_a,{adapters:me.map(e=>e.id)}),(0,Y.jsx)(`div`,{className:`mt-3`,children:(0,Y.jsx)(N,{block:!0,variant:`primary`,onClick:()=>{t.startsWith(`/`)||r(`/${t}`),A(!1),requestAnimationFrame(()=>R.current?.focus())},children:`Start a command`})})]}),(0,Y.jsx)(aa,{session:d,mode:ae===`fork`?`fork`:`tree`,open:ae===`tree`||ae===`fork`,mobile:a,onClose:()=>oe(null),onPick:e=>void Pe(e)}),(0,Y.jsx)(oa,{session:d,open:ae===`resume`,mobile:a,onClose:()=>oe(null),onOpen:e=>{oe(null),Ae(e)}}),(0,Y.jsx)(qi,{session:d,hostLabel:`${e.hostName} (${e.link})`,open:ae===`info`,onClose:()=>oe(null)}),(0,Y.jsx)(Yi,{view:te,open:!!te,busy:re,mobile:a,onClose:()=>ne(null),onRun:e=>void Ne(e)})]})}function _a({adapters:e,onClose:t,className:n}){return(0,Y.jsxs)(`div`,{role:`note`,"aria-label":`Slash commands`,className:n,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0 flex-1 text-sm`,children:[`Text starting with `,(0,Y.jsx)(`code`,{className:`font-mono`,children:`/`}),` is sent to Pi as a command (extension commands and prompt templates). Switchyard does not list Pi's commands; type the command name.`]}),t&&(0,Y.jsx)(q,{size:`sm`,label:`Close command hint`,icon:(0,Y.jsx)(Le,{className:`size-3.5`}),onClick:t})]}),e.length>0&&(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-muted`,children:[`Extensions with commands on this host: `,e.join(`, `)]})]})}var va=160,ya=60;function ba(e){return Math.max(ya,e*1e3/va)}function xa(e,t,n,r){return e>=t?t:Math.min(t,e+Math.max(1,Math.round(r*n/1e3)))}function Sa(e,t){let n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0,r=t&&!n,i=(0,J.useRef)(r?0:e.length),a=(0,J.useRef)(0),[o,s]=(0,J.useState)(i.current);return(0,J.useEffect)(()=>{if(!r){i.current=e.length,s(e.length);return}i.current>e.length&&(i.current=e.length),a.current=Math.max(a.current,ba(e.length-i.current));let t=0,n=performance.now(),o=r=>{let c=xa(i.current,e.length,r-n,a.current);n=r,c!==i.current&&(i.current=c,s(c)),c<e.length?t=requestAnimationFrame(o):a.current=0};return t=requestAnimationFrame(o),()=>cancelAnimationFrame(t)},[e,r]),r?e.slice(0,Math.min(o,e.length)):e}function Ca(e){let{entry:t}=e;if(t.type===`stream`)return(0,Y.jsx)(La,{stream:t.stream});if(t.type===`interaction`)return(0,Y.jsx)(Ia,{interaction:t.interaction,readOnly:e.interactionReadOnly,highlight:e.highlightInteractionId===t.interaction.id});let{item:n,stream:r}=t;switch(n.kind){case`user`:return(0,Y.jsx)(Ta,{item:n});case`assistant`:return(0,Y.jsx)(Ea,{text:n.data.text+(r?.text??``),thinking:r?.thinking??``,streaming:!!r||n.data.streaming===!0});case`thinking`:return(0,Y.jsx)(Da,{text:n.data.text+(r?.thinking??``),live:!!r});case`tool`:return(0,Y.jsx)(ka,{data:n.data,stream:r,sessionId:e.sessionId});case`notice`:return(0,Y.jsx)(Ma,{level:n.data.level,text:n.data.text});case`system`:return(0,Y.jsx)(Na,{text:n.data.text,suggestion:n.data.suggestion===!0,draftEmpty:e.draftEmpty,onUse:e.onUseSuggestion});case`subagent`:return(0,Y.jsx)(Pa,{data:n.data});case`interaction`:return(0,Y.jsx)(Fa,{interactionId:n.data.interactionId,readOnly:e.interactionReadOnly,highlight:e.highlightInteractionId===n.data.interactionId})}}function wa({icon:e,children:t}){return(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,Y.jsx)(e,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),t]})}function Ta({item:e}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-surface-2 px-3 py-2`,children:[(0,Y.jsxs)(wa,{icon:an,children:[`You `,(0,Y.jsxs)(`span`,{className:`font-normal text-subtle`,children:[`· `,P(e.at)]})]}),(0,Y.jsx)(`p`,{className:`text-sm break-words whitespace-pre-wrap`,children:e.data.text}),e.data.images?(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-muted`,children:[e.data.images,` image`,e.data.images===1?``:`s`,` attached`]}):null]})}function Ea({text:e,thinking:t,streaming:n}){let r=Sa(e,n),i=Sa(t,n);return(0,Y.jsxs)(`div`,{className:`min-w-0 px-1`,children:[(0,Y.jsxs)(wa,{icon:et,children:[`Pi`,n&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-normal`,children:[(0,Y.jsx)(E,{className:`size-3`}),`Writing…`]})]}),t&&(0,Y.jsx)(Da,{text:i,live:!0}),e?(0,Y.jsx)(ue,{text:r}):!t&&(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`…`})]})}function Da({text:e,live:t}){return(0,Y.jsxs)(`details`,{className:`group min-w-0 rounded-md border border-border bg-surface px-3 py-1.5`,children:[(0,Y.jsxs)(`summary`,{className:`tap flex cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,Y.jsx)(U,{"aria-hidden":!0,className:`size-3.5 transition-transform group-open:rotate-90`}),(0,Y.jsx)(nt,{"aria-hidden":!0,className:`size-3.5`}),t?`Thinking…`:`Thinking`]}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs break-words whitespace-pre-wrap text-muted`,children:e})]})}var Oa={running:{label:`Running`,icon:Ve},ok:{label:`Done`,icon:Pe},error:{label:`Failed`,icon:Ne}};function ka({data:e,stream:t,sessionId:n}){let{mobile:r,openFile:i}=un(),[a,o]=(0,J.useState)(!1),s=e.status===`running`,c=yr(s),l=e.durationMs??(s?Math.max(0,c-Date.parse(e.startedAt)):null),u=Oa[e.status],d=u.icon,f=Kn(e.args)||t?.toolArgs||``,p=e.output+(t?.toolOutput??``),m=qn(p);return(0,Y.jsxs)(`article`,{"data-testid":`tool-card`,"aria-label":`Tool ${e.name}: ${u.label}`,className:`min-w-0 rounded-md border border-border bg-surface`,children:[(0,Y.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 px-3 py-2`,children:[s?(0,Y.jsx)(E,{className:`size-4 text-info`}):(0,Y.jsx)(d,{"aria-hidden":!0,className:k(`size-4 shrink-0`,e.status===`ok`&&`text-success`,e.status===`error`&&`text-danger`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono text-sm font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:k(`text-xs`,e.status===`error`?`text-danger`:s?`text-info`:`text-muted`),children:u.label}),l!==null&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-subtle tabular-nums`,children:D(l)}),e.summary&&(0,Y.jsx)(`p`,{className:`w-full min-w-0 truncate text-xs text-muted`,title:e.summary,children:e.summary})]}),e.card&&(0,Y.jsx)(`div`,{className:`border-t border-border px-3 py-2`,children:(0,Y.jsx)(xe,{node:e.card,onAction:t=>{e.adapterId&&Z.adapterAction(n,e.adapterId,t).then(()=>G.success(`Action sent`)).catch(e=>G.error(S(e)))},onOpenFile:i})}),(f||p)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 border-t border-border px-3 py-1.5`,children:[f&&(0,Y.jsxs)(`details`,{className:`group min-w-0`,children:[(0,Y.jsxs)(`summary`,{className:`tap flex cursor-pointer list-none items-center gap-1 text-xs font-medium text-muted`,children:[(0,Y.jsx)(U,{"aria-hidden":!0,className:`size-3.5 transition-transform group-open:rotate-90`}),`Arguments`]}),(0,Y.jsx)(le,{text:f,className:`mt-1`,maxHeight:`16rem`})]}),p&&(r?(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`text-xs font-medium text-muted`,children:[`Output`,m.truncated?` (last lines)`:``]}),(0,Y.jsx)(le,{text:m.text,className:`mt-1`}),m.truncated&&(0,Y.jsx)(N,{size:`sm`,variant:`ghost`,onClick:()=>o(!0),children:`Show full output`}),(0,Y.jsx)(Ue,{open:a,onClose:()=>o(!1),title:`${e.name} output`,children:(0,Y.jsx)(le,{text:p})})]}):(0,Y.jsxs)(`details`,{className:`group min-w-0`,children:[(0,Y.jsxs)(`summary`,{className:`tap flex cursor-pointer list-none items-center gap-1 text-xs font-medium text-muted`,children:[(0,Y.jsx)(U,{"aria-hidden":!0,className:`size-3.5 transition-transform group-open:rotate-90`}),`Output`,(0,Y.jsxs)(`span`,{className:`font-normal text-subtle`,children:[`(`,p.split(`
|
|
12
|
+
`).length,` lines)`]})]}),(0,Y.jsx)(le,{text:p,className:`mt-1`,maxHeight:`24rem`})]}))]})]})}var Aa={info:Me,warning:O,error:ne},ja={info:`Notice`,warning:`Warning`,error:`Error`};function Ma({level:e,text:t}){let n=Aa[e];return(0,Y.jsxs)(`div`,{role:e===`error`?`alert`:`note`,className:k(`flex min-w-0 items-start gap-2 rounded-md border px-3 py-2 text-sm`,e===`info`&&`border-border bg-surface-2`,e===`warning`&&`border-transparent bg-warning-soft`,e===`error`&&`border-transparent bg-danger-soft`),children:[(0,Y.jsx)(n,{"aria-hidden":!0,className:k(`mt-0.5 size-4 shrink-0`,e===`warning`&&`text-warning`,e===`error`&&`text-danger`,e===`info`&&`text-muted`)}),(0,Y.jsxs)(`span`,{className:`sr-only`,children:[ja[e],`: `]}),(0,Y.jsx)(`span`,{className:`min-w-0 break-words whitespace-pre-wrap`,children:t})]})}function Na({text:e,suggestion:t,draftEmpty:n,onUse:r}){return t?(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-md border border-dashed border-border-strong px-3 py-2`,children:[(0,Y.jsx)(wa,{icon:sn,children:`Suggested next message`}),(0,Y.jsx)(`p`,{className:`text-sm break-words whitespace-pre-wrap`,children:e}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(N,{size:`sm`,disabled:!n,onClick:()=>r(e),children:`Use suggestion`}),(0,Y.jsx)(N,{size:`sm`,variant:`ghost`,icon:(0,Y.jsx)(ge,{className:`size-3.5`}),onClick:()=>void navigator.clipboard?.writeText(e).then(()=>G.success(`Copied`)),children:`Copy`}),!n&&(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:`Your draft is not empty; clear it to use this suggestion.`})]})]}):(0,Y.jsx)(`p`,{className:`px-1 text-xs break-words whitespace-pre-wrap text-muted`,children:e})}function Pa({data:e}){let t=y(t=>e.linkedSessionId?t.sessions[e.linkedSessionId]:void 0),n=e.status.toLowerCase(),i=/run|start|progress/.test(n)?Ve:/fail|error/.test(n)?Ne:/done|complete|success|ok/.test(n)?Pe:Bt;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-md border border-border bg-surface px-3 py-2`,children:[i===Ve?(0,Y.jsx)(E,{className:`mt-0.5 size-4 text-muted`}):(0,Y.jsx)(i,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:`Subagent`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium`,children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:e.status})]}),e.linkedSessionId?(0,Y.jsxs)(r,{to:`/code/${encodeURIComponent(e.linkedSessionId)}`,className:`text-sm text-accent underline underline-offset-2`,children:[`Open `,t?.title??`subagent session`]}):(0,Y.jsx)(`p`,{className:`text-xs break-all text-muted`,children:e.sessionFile?`Session file: ${e.sessionFile}`:`Session not linked yet.`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Subagent: view only. Live control is not supported.`})]})]})}function Fa({interactionId:e,readOnly:t,highlight:n}){let r=y(t=>t.interactions[e]);return r?(0,Y.jsx)(Ia,{interaction:r,readOnly:t,highlight:n}):(0,Y.jsx)(`p`,{id:Un(e),className:`px-1 text-xs text-muted`,children:`Question (details not loaded yet)`})}function Ia({interaction:e,readOnly:t,highlight:n}){return(0,Y.jsx)(`div`,{"data-testid":`interaction-card`,"data-interaction-id":e.id,"data-state":e.state,className:k(`min-w-0 scroll-mt-16 transition-shadow`,n&&`ring-2 ring-accent ring-offset-2 ring-offset-bg`),children:(0,Y.jsx)(Se,{id:Un(e.id),interaction:e,readOnlyReason:e.state===`pending`||e.state===`unsupported`?t:null,className:`w-full`})})}function La({stream:e}){return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(e.text||e.thinking)&&(0,Y.jsx)(Ea,{text:e.text,thinking:e.thinking,streaming:!0}),(e.toolArgs||e.toolOutput)&&(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border bg-surface px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,Y.jsx)(E,{className:`size-3.5`}),`Tool running…`]}),e.toolArgs&&(0,Y.jsx)(le,{text:e.toolArgs,className:`mt-1`,maxHeight:`8rem`}),e.toolOutput&&(0,Y.jsx)(le,{text:qn(e.toolOutput).text,className:`mt-1`})]})]})}function Ra({sessionId:e,detail:t,showPrompt:n}){let r=n?Pi(e):null;return(0,Y.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`starting-card`,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`size-4 text-info`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:`Starting session`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:t??`Starting Pi…`}),r&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:`Your first prompt (sent when Pi is ready)`}),(0,Y.jsx)(`div`,{className:`line-clamp-6 rounded-md bg-surface-2 px-3 py-2 text-sm break-words whitespace-pre-wrap`,children:r})]})]})}function za(e,t,n=!1){let r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=e.scrollTop+(i.top-r.top)-Math.max(0,(r.height-i.height)/2);e.scrollTo({top:Math.max(0,a),behavior:n?`smooth`:`auto`})}var Ba=160,Va=4e3;function Ha({sessionId:e,draftEmpty:t,onUseSuggestion:n,interactionReadOnly:r,focusInteractionId:i,className:a}){let o=h(e),s=_(e),c=M(e),l=y(t=>t.sessions[e]),u=l?.runtime===`starting`,d=y(e=>e.loadOlderTranscript),f=y(e=>e.loadTranscript),p=(0,J.useMemo)(()=>Vn(o.items,s,c),[o.items,s,c]),m=(0,J.useRef)(null),g=(0,J.useRef)(!0),[v,b]=(0,J.useState)(!0),[x,S]=(0,J.useState)(null),C=(0,J.useRef)(null),[T,E]=(0,J.useState)(null),D=p.length?p[p.length-1].key:null,O=p.length?p[0].key:null,A=s.reduce((e,t)=>e+t.text.length+t.thinking.length+t.toolArgs.length+t.toolOutput.length,0);(0,J.useEffect)(()=>{g.current=!0,b(!0),S(null),C.current=null},[e]);let j=(0,J.useCallback)(()=>{let t=m.current;t&&o.hasMore&&!o.loading&&(C.current=t.scrollHeight,d(e))},[o.hasMore,o.loading,d,e]),P=()=>{let e=m.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<=48;t!==g.current&&(g.current=t,b(t),S(t?null:D)),e.scrollTop<Ba&&j()};(0,J.useLayoutEffect)(()=>{let e=m.current;if(e){if(C.current!==null){let t=e.scrollHeight-C.current;if(C.current=null,!g.current&&t>0){e.scrollTop+=t;return}}if(g.current){let t=p[p.length-1],n=t?.type===`interaction`&&ye(t.interaction.presentation)?e.querySelector(`[data-testid="document-interaction"]:last-of-type`):null;e.scrollTop=n?Math.max(0,n.offsetTop-8):e.scrollHeight}}},[p.length,D,O,A,o.loaded]);let ee=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{if(!o.loaded||ee.current===e)return;let t=[...c].reverse().find(e=>ye(e.presentation));if(ee.current=e,!t||i)return;let n=document.getElementById(Un(t.id));n&&m.current&&(g.current=!1,b(!1),S(D),m.current.scrollTop=Math.max(0,n.offsetTop-8))});let L=(0,J.useRef)(null),te=(0,J.useRef)(0);(0,J.useLayoutEffect)(()=>{if(!i||L.current===i||!o.loaded)return;let e=document.getElementById(Un(i));e?(L.current=i,te.current=0,g.current=!1,b(!1),S(D),m.current&&za(m.current,e),E(i)):o.hasMore&&!o.loading&&te.current<5&&(te.current++,j())}),(0,J.useEffect)(()=>{if(!T)return;let e=setTimeout(()=>E(null),Va);return()=>clearTimeout(e)},[T]);let ne=()=>{let e=m.current;e&&(g.current=!0,b(!0),S(null),e.scrollTo({top:e.scrollHeight,behavior:`smooth`}))},re=()=>{let e=c[0];if(!e)return;let t=document.getElementById(Un(e.id));t&&(g.current=!1,b(!1),S(D),m.current&&za(m.current,t,!0),E(e.id),(t.querySelector(`input, select, textarea, button:not([disabled])`)??t).focus({preventScroll:!0}))},ie=v?0:Hn(p,x);return(0,Y.jsxs)(`div`,{className:k(`relative flex min-h-0 min-w-0 flex-1 flex-col`,a),children:[c.length>0&&(0,Y.jsx)(`div`,{"data-testid":`needs-answer-strip`,className:`shrink-0 px-3 pt-2`,children:(0,Y.jsx)(w,{count:c.length,onOpen:re,label:c.length===1?`Needs your answer: ${c[0].title}`:`${c.length} questions need your answer`})}),(0,Y.jsx)(`div`,{ref:m,"data-testid":`transcript`,role:`log`,"aria-live":`off`,"aria-label":`Transcript`,onScroll:P,className:`relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-3 py-3 md:px-6 [overflow-anchor:none] focus-visible:outline-offset-[-2px]`,children:(0,Y.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-3`,children:[o.loaded&&o.hasMore&&(0,Y.jsx)(`div`,{className:`flex justify-center`,children:(0,Y.jsx)(N,{size:`sm`,variant:`ghost`,busy:o.loading,onClick:j,children:`Load earlier messages`})}),o.error&&o.loaded&&(0,Y.jsx)(F,{compact:!0,title:`Could not load more of the transcript`,error:o.error,onRetry:j}),!o.loaded&&o.error?(0,Y.jsx)(F,{title:`Could not load the transcript`,error:o.error,onRetry:()=>void f(e,{force:!0})}):!o.loaded&&p.length===0?(0,Y.jsx)(I,{label:`Loading transcript…`}):p.length===0&&!u?(0,Y.jsx)(`p`,{className:`py-10 text-center text-sm text-muted`,children:`No messages yet. Write a prompt below to start.`}):p.map(i=>(0,Y.jsx)(Ca,{entry:i,sessionId:e,interactionReadOnly:r,draftEmpty:t,onUseSuggestion:n,highlightInteractionId:T},i.key)),u&&(0,Y.jsx)(Ra,{sessionId:e,detail:l?.runtimeDetail??null,showPrompt:p.length===0}),o.stale&&o.loaded&&(0,Y.jsx)(`p`,{role:`status`,className:`text-center text-xs text-muted`,children:`Refreshing transcript…`})]})}),!v&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-3 flex justify-center`,children:(0,Y.jsxs)(N,{"data-testid":`jump-to-latest`,size:`sm`,variant:`secondary`,className:`pointer-events-auto shadow-pop`,icon:(0,Y.jsx)(ae,{className:`size-4`}),onClick:ne,children:[`Jump to latest`,ie>0?` (${ie})`:``]})})]})}function Ua(e){return e.session.readOnly?`${Ln} Answer in the parent session.`:e.link===`connected`?null:`Host ${e.hostName} is offline; answers can be sent when it reconnects.`}function Wa({ctx:e,actions:t}){let{session:n}=e,i=y(e=>e.loadTranscript),a=Rn(n);return(0,J.useEffect)(()=>{a&&i(n.id,{force:!0})},[a,n.id,i]),(0,Y.jsxs)(Y.Fragment,{children:[e.link!==`connected`&&(0,Y.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:(0,Y.jsx)(A,{compact:!0,hostName:e.hostName,connectivity:e.link===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:e.host?.lastSeenAt,detail:`Showing the last known transcript. Sending and answers resume when the host reconnects.`})}),n.runtime===`failed`&&(0,Y.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:(0,Y.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-start gap-2 rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,Y.jsx)(ne,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:`This session failed`}),(0,Y.jsx)(`div`,{className:`break-words text-muted`,children:n.runtimeDetail??`Pi exited with an error.`}),(0,Y.jsx)(r,{to:`/settings/diagnostics`,className:`text-accent underline`,children:`Open diagnostics`})]}),t.canResume&&(0,Y.jsx)(N,{size:`sm`,icon:(0,Y.jsx)(De,{className:`size-3.5`}),busy:t.busy.resume,onClick:t.resume,children:`Resume`})]})}),n.runtime===`interrupted`&&n.runtimeDetail&&(0,Y.jsxs)(`p`,{role:`status`,className:`shrink-0 px-4 pt-2 text-sm text-muted`,children:[`Interrupted: `,n.runtimeDetail]}),n.archivedAt&&(0,Y.jsx)(`p`,{role:`status`,className:`shrink-0 px-4 pt-2 text-sm text-muted`,children:`This session is archived.`})]})}function Ga(e){let[t,n,r]=Ar(e);return{draft:t,setDraft:n,clearDraft:r,onUseSuggestion:e=>{t.trim()===``&&n(e)}}}function Ka({ctx:e,actions:t,focusInteractionId:n,inspector:r}){let i=Ga(e.session.id);return(0,Y.jsxs)(`section`,{"data-testid":`conversation`,"aria-label":`Conversation`,className:`flex h-full min-h-0 min-w-0 flex-col bg-bg`,children:[(0,Y.jsx)(ri,{ctx:e,actions:t,inspector:r}),(0,Y.jsx)(Wa,{ctx:e,actions:t}),(0,Y.jsx)(Ha,{sessionId:e.session.id,draftEmpty:i.draft.trim()===``,onUseSuggestion:i.onUseSuggestion,interactionReadOnly:Ua(e),focusInteractionId:n}),(0,Y.jsx)(ga,{ctx:e,draft:i.draft,setDraft:i.setDraft,clearDraft:i.clearDraft,mobile:!1,onTakeover:t.takeover,takeoverBusy:t.busy.takeover,onResume:t.resume,resumeBusy:t.busy.resume}),t.dialogs]})}function qa(e){return e?e===`changes`?`changes`:`details`:`chat`}function Ja({ctx:e,actions:t,focusInteractionId:i,tabRequest:a}){let{session:o,project:s,workspace:c,task:l}=e,u=n(),[d,f]=(0,J.useState)(()=>qa(a?.tab)),[p,m]=(0,J.useState)(!1),h=M(o.id),g=Ga(o.id),_=a?`${a.tab}:${a.key}`:null;(0,J.useEffect)(()=>f(qa(a?.tab)),[o.id,i,_]);let v=(0,J.useMemo)(()=>({mobile:!0,openInspector:e=>f(e===`changes`?`changes`:`details`)}),[]),y=[...l?[{id:`task`,label:`Open linked task`,icon:(0,Y.jsx)(He,{className:`size-4`}),onSelect:()=>u(`/tasks/${encodeURIComponent(l.id)}`)}]:[],...t.canResume?[{id:`resume`,label:`Resume`,icon:(0,Y.jsx)(De,{className:`size-4`}),onSelect:t.resume}]:[],...ni(e,t)];return(0,Y.jsx)(ln.Provider,{value:v,children:(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex min-w-0 flex-col bg-bg`,children:[(0,Y.jsxs)(`header`,{className:`flex min-w-0 shrink-0 items-center gap-1 border-b border-border bg-surface px-1.5 py-1 safe-pt`,children:[(0,Y.jsx)(r,{to:`/code`,"aria-label":`Back to sessions`,title:`Back to sessions`,className:te(`ghost`,`md`,`size-11 px-0`),children:(0,Y.jsx)(ce,{"aria-hidden":!0,className:`size-5`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(`h1`,{className:`truncate text-base leading-6 font-semibold`,title:o.title,children:o.title})}),(0,Y.jsx)(W,{kind:`runtime`,value:o.runtime,size:`sm`,className:`shrink-0`}),(0,Y.jsx)(R,{label:`Session actions`,items:y,trigger:e=>(0,Y.jsx)(q,{...e,label:`More actions`,icon:(0,Y.jsx)(mt,{className:`size-5`})})})]}),(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-border bg-surface px-3`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":p,"aria-controls":`sy-session-meta`,onClick:()=>m(e=>!e),className:`tap flex w-full min-w-0 items-center gap-2 py-1.5 text-left text-xs text-muted`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[s?.name??`No project`,` · `,Sn(c,o.cwd),` ·`,` `,e.hostName,e.link===`connected`?``:` (offline)`,` · `,Fn[e.control]]}),p?(0,Y.jsx)(ot,{"aria-hidden":!0,className:`size-4 shrink-0`}):(0,Y.jsx)(se,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:p?`Hide details`:`Show details`})]}),p&&(0,Y.jsxs)(`dl`,{id:`sy-session-meta`,className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 pb-2 text-xs`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Project`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words`,children:s?.name??`None`}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Branch`}),(0,Y.jsx)(`dd`,{className:`min-w-0 font-mono break-all`,children:Sn(c,o.cwd)}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Host`}),(0,Y.jsxs)(`dd`,{className:`min-w-0 break-words`,children:[e.hostName,` (`,e.link,`)`]}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Control`}),(0,Y.jsxs)(`dd`,{children:[(0,Y.jsx)(ei,{ctx:e}),e.control===`none`&&`Manual session`]}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Path`}),(0,Y.jsx)(`dd`,{className:`min-w-0 font-mono break-all`,children:o.cwd}),(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Profile`}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words`,children:o.profileSnapshot.name})]})]}),(0,Y.jsx)(`div`,{className:`shrink-0 bg-surface px-3 py-2`,"data-testid":`mobile-tabs`,children:(0,Y.jsx)(Xe,{label:`Session view`,block:!0,value:d,onChange:f,options:[{value:`chat`,label:`Chat`,badge:h.length>0?(0,Y.jsxs)(`span`,{className:`rounded-full bg-warning-soft px-1.5 text-xs text-warning`,children:[h.length,(0,Y.jsx)(`span`,{className:`sr-only`,children:` pending questions`})]}):void 0},{value:`changes`,label:`Changes`},{value:`details`,label:`Details`}]})}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[d===`chat`&&(0,Y.jsxs)(`section`,{"data-testid":`conversation`,"aria-label":`Chat`,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(Wa,{ctx:e,actions:t}),(0,Y.jsx)(Ha,{sessionId:o.id,draftEmpty:g.draft.trim()===``,onUseSuggestion:g.onUseSuggestion,interactionReadOnly:Ua(e),focusInteractionId:i}),(0,Y.jsx)(ga,{ctx:e,draft:g.draft,setDraft:g.setDraft,clearDraft:g.clearDraft,mobile:!0,onTakeover:t.takeover,takeoverBusy:t.busy.takeover,onResume:t.resume,resumeBusy:t.busy.resume,className:`safe-pb`})]}),d===`changes`&&(0,Y.jsx)(`section`,{"aria-label":`Changes`,className:`relative min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Y.jsx)(Xr,{ctx:e})}),d===`details`&&(0,Y.jsx)(`section`,{"aria-label":`Details`,className:`relative min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Y.jsx)(fi,{ctx:e,actions:t})})]}),t.dialogs]})})}function Ya(){let e=(0,J.useRef)(null),[t,n]=(0,J.useState)(0);return(0,J.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 Xa({missing:e}){return e?(0,Y.jsx)(L,{icon:(0,Y.jsx)(Kt,{className:`size-8`}),title:`Session not found`,description:`It may have been archived, or this link points to another coordinator.`,action:{label:`Back to sessions`,to:`/code`}}):(0,Y.jsx)(L,{icon:(0,Y.jsx)(It,{className:`size-8`}),title:`Select a session`,description:`Pick a session in the navigator, or start a new one.`})}function Za({compact:e,...t}){let r=n(),i=Ie(e=>e.paneSizes),a=Ie(e=>e.setPaneSize),o=Ie(e=>e.inspectorCollapsed),s=Ie(e=>e.set),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),[f,p]=Ya(),m=_r(t.session),h=!e&&!o&&!!m,g=Yn(p,i.navigator,h?i.inspector:null),_=(0,J.useCallback)(e=>{l(!1),r(`/code/${encodeURIComponent(e)}`)},[r]);return(0,Y.jsxs)(`div`,{ref:f,className:`absolute inset-0 flex min-w-0 overflow-hidden`,children:[(0,Y.jsx)(Di,{variant:`pane`,selectedId:t.sessionId,onNewSession:()=>l(!0),className:`shrink-0 border-r border-border`,style:{width:g.nav}}),(0,Y.jsx)(cn,{label:`Resize navigator`,value:g.nav,min:K.navigator.min,max:K.navigator.max,onChange:e=>a(`navigator`,e),onReset:()=>a(`navigator`,K.navigator.default),className:`-ml-1.5`}),(0,Y.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1`,style:{minWidth:420},children:!t.hydrated&&t.sessionId?(0,Y.jsx)(I,{label:`Loading session…`}):m?(0,Y.jsx)(Qa,{ctx:m,compact:e,showInspector:h,inspectorWidth:g.insp,setInspectorWidth:e=>a(`inspector`,e),collapsed:o,setCollapsed:e=>s(`inspectorCollapsed`,e),drawerOpen:u,setDrawerOpen:d,focusInteractionId:t.focusInteractionId,tabRequest:t.tabRequest},m.session.id):(0,Y.jsx)(Xa,{missing:!!t.sessionId})}),(0,Y.jsx)(Ki,{open:c,onClose:()=>l(!1),onCreated:_,mobile:!1})]})}function Qa({ctx:e,compact:t,showInspector:n,inspectorWidth:r,setInspectorWidth:i,collapsed:a,setCollapsed:o,drawerOpen:s,setDrawerOpen:c,focusInteractionId:l,tabRequest:u}){let d=Ji(e),[f,p]=(0,J.useState)(u?.tab??`changes`),[m,h]=(0,J.useState)(null),g=(0,J.useCallback)(e=>{p(e),t?c(!0):o(!1)},[t,c,o]),_=(0,J.useMemo)(()=>({mobile:!1,openInspector:g,openFile:e=>{h({path:e,nonce:Date.now()}),g(`files`)}}),[g]),v=u?`${u.tab}:${u.key}`:null;(0,J.useEffect)(()=>{u&&g(u.tab)},[v]),(0,J.useEffect)(()=>{t||c(!1)},[t,c]);let y=t?s:!a,b={open:y,label:y?`Hide inspector`:`Show inspector`,toggle:()=>t?c(!s):o(!a)};return(0,Y.jsxs)(ln.Provider,{value:_,children:[(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex min-w-0`,children:[(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,Y.jsx)(Ka,{ctx:e,actions:d,focusInteractionId:l,inspector:b})}),n&&r!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(cn,{label:`Resize inspector`,pane:`after`,value:r,min:K.inspector.min,max:K.inspector.max,onChange:i,onReset:()=>i(K.inspector.default),className:`-mr-1.5`}),(0,Y.jsx)(`div`,{className:`min-h-0 shrink-0 border-l border-border`,style:{width:r},children:(0,Y.jsx)(Ti,{ctx:e,actions:d,tab:f,onTab:p,openPath:m,className:`h-full`})})]})]}),t&&(0,Y.jsx)(We,{open:s,onClose:()=>c(!1),title:`Inspector`,width:440,className:`[&>div:last-child]:p-0`,children:(0,Y.jsx)(Ti,{ctx:e,actions:d,tab:f,onTab:p,openPath:m,hideTitle:!0})})]})}function $a(e){let t=n(),[r,i]=(0,J.useState)(!1),a=_r(e.session),o=(0,J.useCallback)(e=>{i(!1),t(`/code/${encodeURIComponent(e)}`)},[t]);return e.sessionId?e.hydrated?a?(0,Y.jsx)(eo,{ctx:a,focus:e.focusInteractionId,tabRequest:e.tabRequest},a.session.id):(0,Y.jsx)(Xa,{missing:!0}):(0,Y.jsx)(I,{label:`Loading session…`}):(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex min-w-0 flex-col`,children:[(0,Y.jsx)(Di,{variant:`screen`,selectedId:null,onNewSession:()=>i(!0),className:`min-h-0 flex-1 safe-pt`}),(0,Y.jsx)(Ki,{open:r,onClose:()=>i(!1),onCreated:o,mobile:!0})]})}function eo({ctx:e,focus:t,tabRequest:n}){let r=Ji(e);return(0,Y.jsx)(Ja,{ctx:e,actions:r,focusInteractionId:t,tabRequest:n})}var to=[`changes`,`files`,`task`,`extensions`];function no(){let{sessionId:e}=s(),n=e??null,[r]=t(),i=r.get(`interaction`),a=r.get(`tab`),c=a&&to.includes(a)?a:null,{key:u}=l(),d=Re(),f=y(e=>e.hydrated),p=g(n),m=Ie(e=>e.lastSessionId),h=g(m),_=Ie(e=>e.set);if(ie(p?p.id:null),(0,J.useEffect)(()=>{p&&p.id!==Ie.getState().lastSessionId&&_(`lastSessionId`,p.id)},[p,_]),!n&&d!==`mobile`&&f&&h&&h.archivedAt===null)return(0,Y.jsx)(o,{to:`/code/${encodeURIComponent(h.id)}`,replace:!0});let v={session:p,sessionId:n,hydrated:f,focusInteractionId:i,tabRequest:c?{tab:c,key:u}:null};return d===`mobile`?(0,Y.jsx)($a,{...v}):(0,Y.jsx)(Za,{...v,compact:d===`compact`})}export{no as default};
|
|
13
|
+
//# sourceMappingURL=code-D7JmYMKe.js.map
|