waterplane 0.1.22 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/packages/extensions/android-apps/waterplane-plugin.json +4 -1
- package/packages/extensions/copilot-usage/waterplane-plugin.json +7 -2
- package/packages/extensions/desktop/waterplane-plugin.json +5 -0
- package/packages/extensions/ocr/waterplane-plugin.json +5 -1
- package/packages/extensions/requirements/waterplane-plugin.json +3 -3
- package/packages/extensions/scorecard/waterplane-plugin.json +2 -1
- package/packages/extensions/token-stats/waterplane-plugin.json +4 -3
- package/packages/host/dist/backends/index.js +12 -1
- package/packages/host/dist/backends/index.js.map +1 -1
- package/packages/host/dist/binguard.d.ts +13 -1
- package/packages/host/dist/binguard.js +28 -2
- package/packages/host/dist/binguard.js.map +1 -1
- package/packages/host/dist/plugins/pluginassets.d.ts +17 -0
- package/packages/host/dist/plugins/pluginassets.js +27 -1
- package/packages/host/dist/plugins/pluginassets.js.map +1 -1
- package/packages/host/dist/plugins/pluginregistry.d.ts +3 -1
- package/packages/host/dist/plugins/pluginregistry.js +8 -1
- package/packages/host/dist/plugins/pluginregistry.js.map +1 -1
- package/packages/host/dist/routes/apisystem.js +14 -0
- package/packages/host/dist/routes/apisystem.js.map +1 -1
- package/packages/host/dist/routes/apitable.d.ts +2 -0
- package/packages/host/dist/routes/apitable.js.map +1 -1
- package/packages/host/dist/server/http.js +1 -0
- package/packages/host/dist/server/http.js.map +1 -1
- package/packages/web/dist/assets/index-Csb7jynu.js +170 -0
- package/packages/web/dist/assets/index-Cz9Haocy.css +1 -0
- package/packages/web/dist/assets/{sheets-CrfRr6Um.js → sheets-CqsP9w1V.js} +64 -64
- package/packages/web/dist/build-id.txt +1 -1
- package/packages/web/dist/buildstamp.json +1 -1
- package/packages/web/dist/index.html +3 -3
- package/packages/web/dist/sw.js +2 -2
- package/release.json +3 -3
- package/packages/web/dist/assets/index-BllRvpkw.js +0 -170
- package/packages/web/dist/assets/index-DUiYLEts.css +0 -1
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import{$s as e,A as t,As as n,Bc as r,Bs as i,Cc as a,Ct as o,Dc as s,Ds as c,Dt as l,Ec as u,Eo as d,Es as f,F as p,Gi as m,Hc as h,Hn as g,Ho as _,Hs as v,I as y,Iu as b,L as x,M as S,Nu as C,Os as w,Ot as T,P as E,Qs as D,Qu as O,R as k,Rc as A,Ss as j,St as M,Ti as ee,Ts as N,Uc as P,Uu as F,Vc as I,Vi as te,Vn as L,Wu as R,X as ne,Xt as z,Yt as B,Zc as V,Zn as H,Zs as re,_c as ie,_s as U,_u as ae,ao as oe,ba as W,bs as se,bt as ce,cc as le,dc as ue,ea as de,ec as fe,el as pe,eo as me,f as he,fc as ge,gc as _e,gt as ve,hc as ye,ho as be,hs as xe,ht as Se,ic as Ce,io as we,iu as Te,k as Ee,ka as De,ko as Oe,l as ke,lc as Ae,mc as je,mu as Me,nc as Ne,no as Pe,oo as Fe,ot as Ie,pc as Le,pr as Re,pt as ze,pu as Be,rc as Ve,rd as He,ro as Ue,sc as We,st as Ge,ta as Ke,tc as qe,to as Je,tr as Ye,tu as Xe,uc as Ze,vc as Qe,vu as $e,wc as et,ws as tt,wt as nt,xa as rt,xc as it,xo as at,xr as ot,xs as st,xt as ct,yc as lt,yi as ut,ys as dt,yu as ft}from"./shared-DBaaGttP.js";import{C as pt,E as mt,S as ht,T as gt,b as _t,f as vt,h as G,l as yt,m as bt,n as xt,p as St,t as Ct,u as wt,w as Tt,x as Et,y as Dt}from"./demo-ad3g3HDa.js";import{$ as Ot,$a as kt,$c as At,$d as jt,$i as Mt,$l as Nt,$n as Pt,$o as Ft,$r as It,$s as Lt,$t as Rt,$u as zt,A as Bt,Aa as Vt,Ac as Ht,Ad as Ut,Ai as Wt,Al as Gt,An as Kt,Ao as qt,Ar as Jt,As as Yt,At as Xt,Au as Zt,B as Qt,Ba as $t,Bc as en,Bd as tn,Bi as nn,Bl as rn,Bn as an,Bo as on,Br as sn,Bs as cn,Bt as ln,Bu as un,C as dn,Ca as fn,Cc as pn,Cd as mn,Cf as hn,Ci as gn,Cl as _n,Cn as vn,Co as yn,Cr as bn,Cs as xn,Ct as Sn,Cu as Cn,D as wn,Da as Tn,Dc as En,Dd as Dn,Df as On,Di as kn,Dl as An,Dn as jn,Do as Mn,Dr as Nn,Ds as Pn,Dt as Fn,Du as In,E as Ln,Ea as Rn,Ec as zn,Ed as Bn,Ef as Vn,Ei as Hn,El as Un,En as Wn,Eo as Gn,Er as Kn,Es as qn,Et as Jn,Eu as Yn,F as Xn,Fa as Zn,Fc as Qn,Fd as $n,Fi as er,Fl as tr,Fn as nr,Fo as rr,Fr as ir,Fs as ar,Ft as or,Fu as sr,G as cr,Ga as lr,Gc as ur,Gd as dr,Gi as fr,Gl as pr,Gn as mr,Go as hr,Gr as gr,Gs as _r,Gt as vr,Gu as yr,H as br,Ha as xr,Hc as Sr,Hd as Cr,Hi as wr,Hl as Tr,Hn as Er,Ho as Dr,Hr as Or,Hs as kr,Ht as Ar,Hu as jr,I as Mr,Ia as Nr,Ic as Pr,Id as Fr,Ii as Ir,Il as Lr,In as Rr,Io as zr,Ir as Br,Is as Vr,It as Hr,Iu as Ur,J as Wr,Ja as Gr,Jc as Kr,Jd as qr,Ji as Jr,Jl as Yr,Jn as Xr,Jo as Zr,Jr as Qr,Js as $r,Jt as ei,Ju as ti,K as ni,Ka as ri,Kc as ii,Kd as ai,Ki as oi,Kl as si,Kn as ci,Ko as li,Kr as ui,Ks as di,Kt as fi,Ku as pi,L as mi,La as hi,Lc as gi,Ld as _i,Li as vi,Ll as yi,Ln as bi,Lo as xi,Lr as Si,Ls as Ci,Lt as wi,Lu as Ti,M as Ei,Ma as Di,Mc as Oi,Md as ki,Mi as Ai,Ml as ji,Mn as Mi,Mo as Ni,Mr as Pi,Ms as Fi,Mt as Ii,Mu as Li,N as Ri,Na as zi,Nc as Bi,Nd as Vi,Ni as Hi,Nl as Ui,Nn as Wi,No as Gi,Nr as Ki,Ns as qi,Nt as Ji,Nu as Yi,O as Xi,Oa as Zi,Oc as Qi,Od as $i,Oi as ea,Ol as ta,On as na,Oo as ra,Or as ia,Os as aa,Ot as oa,Ou as sa,P as ca,Pa as la,Pc as ua,Pd as da,Pi as fa,Pl as K,Pn as pa,Po as ma,Pr as ha,Ps as ga,Pt as _a,Pu as va,Q as ya,Qa as ba,Qc as xa,Qd as Sa,Qi as Ca,Ql as wa,Qn as Ta,Qo as Ea,Qr as Da,Qs as Oa,Qt as ka,Qu as Aa,R as ja,Ra as Ma,Rc as Na,Rd as Pa,Ri as Fa,Rl as Ia,Rn as La,Ro as Ra,Rr as za,Rs as Ba,Rt as Va,Ru as Ha,S as Ua,Sa as Wa,Sc as Ga,Sd as Ka,Sf as qa,Si as Ja,Sl as Ya,Sn as Xa,So as Za,Sr as Qa,Ss as $a,St as eo,Su as to,T as no,Ta as ro,Tc as io,Td as ao,Tf as oo,Ti as so,Tl as co,Tn as lo,To as uo,Tr as fo,Ts as po,Tt as mo,Tu as ho,U as go,Ua as _o,Uc as vo,Ud as yo,Ui as bo,Ul as xo,Un as So,Uo as Co,Ur as wo,Us as To,Ut as Eo,Uu as Do,V as Oo,Va as ko,Vc as Ao,Vd as jo,Vi as Mo,Vl as No,Vn as Po,Vo as Fo,Vr as Io,Vs as Lo,Vt as Ro,Vu as zo,W as Bo,Wa as Vo,Wc as Ho,Wd as Uo,Wi as Wo,Wl as Go,Wn as Ko,Wo as qo,Wr as Jo,Ws as Yo,Wt as Xo,Wu as Zo,X as Qo,Xa as $o,Xc as es,Xd as ts,Xi as ns,Xl as rs,Xn as is,Xo as as,Xr as os,Xs as ss,Xt as cs,Xu as ls,Y as us,Ya as ds,Yc as fs,Yd as ps,Yi as ms,Yl as hs,Yn as gs,Yo as _s,Yr as vs,Ys as ys,Yt as bs,Yu as xs,Z as Ss,Za as Cs,Zc as ws,Zd as Ts,Zi as Es,Zl as Ds,Zn as Os,Zo as ks,Zs as As,Zt as js,Zu as Ms,_ as Ns,_a as Ps,_c as Fs,_d as Is,_f as Ls,_i as Rs,_l as zs,_n as Bs,_o as Vs,_r as Hs,_s as Us,_t as Ws,_u as Gs,a as Ks,aa as qs,ac as Js,ad as Ys,af as Xs,ai as Zs,al as Qs,an as $s,ao as ec,ar as tc,as as nc,at as rc,au as ic,b as ac,ba as oc,bc as sc,bd as cc,bf as lc,bi as uc,bl as dc,bn as fc,bo as pc,br as mc,bs as hc,bt as gc,bu as _c,c as vc,ca as yc,cc as bc,cd as xc,cf as Sc,ci as Cc,cl as q,cn as wc,co as Tc,cr as Ec,cs as Dc,ct as Oc,cu as kc,d as Ac,da as jc,dc as Mc,dd as Nc,df as Pc,di as Fc,dl as Ic,dn as Lc,do as Rc,dr as zc,ds as Bc,dt as Vc,du as Hc,ea as Uc,ec as Wc,ed as Gc,ef as Kc,el as J,en as qc,eo as Jc,er as Yc,es as Xc,et as Zc,eu as Qc,f as $c,fa as el,fc as tl,fd as nl,ff as rl,fi as il,fl as al,fn as ol,fo as sl,fr as cl,fs as ll,ft as ul,fu as dl,g as fl,ga as pl,gc as Y,gd as ml,gf as hl,gi as gl,gl as _l,gn as vl,go as yl,gr as bl,gt as xl,gu as Sl,h as Cl,ha as wl,hc as Tl,hd as El,hf as Dl,hi as Ol,hl as kl,hn as Al,ho as jl,hr as Ml,hs as Nl,ht as Pl,hu as Fl,i as Il,ia as Ll,ic as Rl,id as zl,if as Bl,ii as Vl,il as Hl,in as Ul,io as Wl,ir as Gl,is as Kl,it as ql,iu as Jl,j as Yl,ja as Xl,jc as Zl,jd as Ql,ji as $l,jl as eu,jn as tu,jo as nu,jr as ru,js as iu,jt as au,ju as ou,k as su,ka as cu,kc as lu,kd as uu,ki as du,kl as fu,kn as pu,ko as mu,kr as hu,ks as gu,kt as _u,ku as vu,l as yu,la as bu,lc as xu,ld as Su,lf as Cu,li as wu,ll as Tu,ln as Eu,lo as Du,lr as Ou,ls as ku,lt as Au,lu as ju,m as Mu,ma as Nu,mc as Pu,md as Fu,mf as Iu,mi as Lu,ml as Ru,mn as zu,mo as Bu,mr as Vu,ms as Hu,mt as Uu,mu as Wu,n as Gu,na as Ku,nc as qu,nd as Ju,nf as Yu,ni as Xu,nl as Zu,nn as Qu,no as $u,nr as ed,ns as td,nt as nd,nu as rd,o as id,oa as ad,oc as od,od as sd,of as cd,oi as ld,ol as ud,on as dd,or as fd,os as pd,ot as md,ou as hd,p as gd,pa as _d,pc as vd,pd as yd,pf as bd,pi as xd,pl as Sd,pn as Cd,po as wd,pr as Td,ps as Ed,pt as Dd,pu as Od,q as kd,qa as Ad,qc as jd,qd as Md,qi as Nd,ql as Pd,qn as Fd,qo as Id,qr as Ld,qs as Rd,qt as zd,qu as Bd,r as Vd,ra as Hd,rc as Ud,rd as Wd,rf as Gd,ri as Kd,rl as qd,rn as Jd,ro as Yd,rr as Xd,rs as Zd,rt as Qd,ru as $d,s as ef,sa as tf,sc as nf,sd as rf,sf as af,si as of,sl as sf,sn as cf,so as lf,sr as uf,ss as df,st as ff,su as pf,t as mf,ta as hf,tc as gf,td as _f,tf as vf,ti as yf,tl as X,tn as bf,to as xf,tr as Sf,ts as Cf,tt as wf,tu as Tf,u as Ef,ua as Df,uc as Of,ud as kf,uf as Af,ui as jf,ul as Mf,un as Nf,uo as Pf,ur as Ff,us as If,ut as Lf,uu as Rf,v as zf,va as Bf,vc as Vf,vd as Hf,vf as Uf,vi as Wf,vl as Gf,vn as Kf,vo as qf,vr as Jf,vs as Yf,vt as Xf,vu as Zf,w as Qf,wa as $f,wc as ep,wd as tp,wf as np,wi as rp,wl as ip,wn as ap,wo as op,wr as sp,ws as cp,wt as lp,wu as up,x as dp,xa as fp,xc as pp,xd as mp,xf as hp,xi as gp,xl as _p,xn as vp,xo as yp,xr as bp,xs as xp,xt as Sp,xu as Cp,y as wp,ya as Tp,yc as Ep,yd as Dp,yf as Op,yi as kp,yl as Ap,yn as jp,yo as Mp,yr as Np,ys as Pp,yt as Fp,yu as Ip,z as Lp,za as Rp,zc as zp,zd as Bp,zi as Vp,zl as Hp,zn as Up,zo as Wp,zr as Gp,zs as Kp,zt as qp,zu as Jp}from"./sheets-CrfRr6Um.js";import{i as Yp,n as Xp,r as Zp,t as Qp}from"./react-CjmvHigY.js";import{$i as $p,A as em,At as tm,B as nm,Bi as rm,Ci as im,Cn as am,Ct as om,D as sm,Di as cm,Dn as lm,Ei as um,En as dm,Er as fm,Fi as pm,Fn as mm,Fr as hm,Gi as gm,Gr as _m,Gt as vm,Hi as ym,Hn as bm,In as xm,Ir as Sm,It as Cm,J as wm,Jn as Tm,Jr as Em,K as Dm,Ki as Om,Kn as km,Kr as Am,L as jm,Li as Mm,Lr as Nm,Lt as Pm,M as Fm,Mi as Im,Mn as Lm,Mr as Rm,Nr as zm,O as Bm,Oi as Vm,On as Hm,Ot as Um,P as Wm,Pn as Gm,Pr as Km,Pt as qm,Qi as Jm,Qr as Ym,R as Xm,Rr as Zm,Rt as Qm,S as $m,Si as eh,Sn as th,St as nh,Ti as rh,Tt as ih,Ut as ah,Vr as oh,W as sh,Wn as ch,X as lh,Xi as uh,Xr as dh,Y as fh,Yi as ph,Yn as mh,Yt as hh,Z as gh,Zr as _h,_ as vh,_i as yh,_n as bh,ai as xh,an as Sh,b as Ch,c as wh,dr as Th,ea as Eh,ei as Dh,et as Oh,fn as kh,g as Ah,gn as jh,gr as Mh,gt as Nh,h as Ph,hi as Fh,hn as Ih,i as Lh,ia as Rh,ii as zh,ir as Bh,it as Vh,jr as Hh,k as Uh,kt as Wh,ln as Gh,lr as Kh,m as qh,mi as Jh,mr as Yh,mt as Xh,na as Zh,ni as Qh,oa as $h,oi as eg,ot as tg,pi as ng,qn as rg,r as ig,rn as ag,rr as og,rt as sg,s as cg,sn as lg,ta as ug,tn as dg,u as fg,ui as pg,ut as mg,vi as hg,vn as gg,wn as _g,xi as vg,xn as yg,xt as bg,yi as xg,yn as Sg,z as Cg,zn as wg,zt as Tg}from"./icons-D8RlmSLR.js";import{n as Eg,t as Dg}from"./xterm-BHsKrDzh.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Z=Yp(),Og=Xp();async function kg(e,t){let[n,r]=await Promise.all([Dn.artifacts(e,`outbox`,void 0,{signal:t}).then(e=>e.files).catch(()=>[]),Dn.inbox(e,t).catch(()=>[])]);return[...n,...r].map(e=>e.relPath).filter(Boolean)}function Ag(e,t){return ou(e??``,t=>kg(e,t),{enabled:t&&!!e}).data??void 0}var jg={fresh:0,warm:1,heavy:2,steep:3},Mg=60;function Ng(e,t,n){if((jg[n[e]]??0)>=jg[t])return{notice:!1,next:n};let r={...n,[e]:t},i=Object.keys(r);if(i.length>Mg)for(let e of i.slice(0,i.length-Mg))delete r[e];return{notice:!0,next:r}}function Pg(e,t,n){if(t==null){if(!(e in n))return{notice:!1,next:n};let t={...n};return delete t[e],{notice:!1,next:t}}if(n[e]===t)return{notice:!1,next:n};let r={...n,[e]:t},i=Object.keys(r);if(i.length>Mg)for(let e of i.slice(0,i.length-Mg))delete r[e];return{notice:!0,next:r}}var Fg={warn:1,high:2};function Ig(e,t,n){if(!t||(Fg[n[e]]??0)>=Fg[t])return{notice:!1,next:n};let r={...n,[e]:t},i=Object.keys(r);if(i.length>Mg)for(let e of i.slice(0,i.length-Mg))delete r[e];return{notice:!0,next:r}}function Lg(){let e=X(`spendWarn`),t=Qi();return n=>n?we(n.contextSpark?.costUsd,t,e):null}function Rg(e){let t=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!e||!e.running)return;let n=Xe(e.contextSpark,{lastTurnAt:e.lastTurnAt,turnActive:e.turnActive,now:Date.now()});if(!n||n.level===`fresh`)return;let r=t.current??=ht(G.costNoticed,{}),{notice:i,next:a}=Ng(e.id,n.level,r);i&&(t.current=a,mt(G.costNoticed,a),K(n.advice?`${n.note} ${n.advice}`:n.note))},[e]);let n=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!e)return;let t=e.contextSpark,r=e.running?Te(t?.liveAgentTok,t?.liveAgentAt,Date.now(),fs()):null,i=n.current??=ht(G.agentNoticed,{}),{notice:a,next:o}=Pg(e.id,r?t?.liveAgentId??`agent`:null,i);o!==i&&(n.current=o,mt(G.agentNoticed,o)),a&&r&&K(r)},[e]);let r=(0,Z.useRef)(null),i=Lg()(e);(0,Z.useEffect)(()=>{if(!e||!i)return;let t=r.current??=ht(G.spendNoticed,{}),{notice:n,next:a}=Ig(e.id,i.level,t);n&&(r.current=a,mt(G.spendNoticed,a),K(`${i.text} Marks are set in Settings › Sessions › spend marks. Nothing was stopped.`))},[e,i]);let a=(0,Z.useRef)(new Set);(0,Z.useEffect)(()=>{if(!e)return;let t=e.budget,{notice:n,next:r}=nu(e.id,t?.verdict.state===`over`,a.current);a.current=r,n&&t&&K(qt(e.title,t))},[e])}function zg(e,t){let[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(e){i.current=!0,r(!1);return}if(!i.current)return;i.current=!1,r(!0);let n=window.setTimeout(()=>r(!1),t);return()=>window.clearTimeout(n)},[e,t]),n}var Bg=6e3,Vg=2e4,Hg=9e4,Ug=1500,Wg=5e3,Gg=45e3;function Kg(e,t=!1){return e.map(e=>t?`failed ${e.ackId}`:e.ackId).join(`
|
|
2
|
-
`)}var qg=`pending:`,Jg=e=>!!e?.startsWith(qg),Yg=e=>`${qg}${e}`,Xg=`${qg}later:`,Zg=e=>!!e?.startsWith(Xg),Qg=e=>`${Xg}${e}`,$g=(e,t)=>Jg(e)&&t?`create:${t}`:e;function e_(e,t){let n=e.attempts??0,r=1+Math.min(3,n);return e.mode===`op`?(t==null?Vg:Math.max(Vg,Math.min(12e4,t*6)))*r:e.mode===`backlog`||e.mode===`upload`?Bg*r:Hg}function t_(e,t,n=Date.now()){let r=(e.tries??0)+1;return{...e,status:`queued`,attempts:t?Math.max(0,(e.attempts??1)-1):e.attempts,tries:r,retryAt:n+ie(r)}}function n_(e){return e.pendingCreate&&e.holdUntilIdle?!0:void 0}function r_(e,t,n){let r=new Set;for(let i of e)i.status!==`queued`||i.pendingCreate||(i.mode??`input`)===`input`&&(!t.has(i.sessionId)||n.has(i.sessionId))&&r.add(i.sessionId);return[...r]}function i_(e,t){if(e.mode===`op`){let t=e.cwd.split(`/`).filter(Boolean).pop()??``;return e.op?.t===`schedule.run`?`Scheduled run, by hand`:e.sessionId===`fanout`?`Fan-out`:e.sessionId.startsWith(`fu:`)?`Fan-out follow-up`:e.sessionId.startsWith(`build:`)?`${t||`repo`} · builds`:`${t||`repo`} · new session`}let n=t.find(t=>t.id===e.sessionId);return n?`${n.title}${e.mode===`backlog`?` · backlog`:``}`:`${e.cwd.split(`/`).filter(Boolean).pop()??e.cwd}${e.mode===`backlog`?` · backlog`:` · session gone`}`}function a_(e,t=Date.now()){let n=e.map(e=>e.sentAt??e.ts),r=n.length?Math.min(...n):t,i=Math.max(0,Math.round((t-r)/1e3)),a=e.length>1?` (${e.length})`:``,o=e.some(e=>e.mode===`upload`)?`Uploading`:`Sending`,s=e.filter(e=>e.status===`queued`&&e.retryAt!=null).map(e=>e.retryAt);if(s.length===e.length&&s.length){let n=Math.max(1e3,Math.min(...s)-t),r=n<6e4?`${Math.round(n/1e3)}s`:`${Math.round(n/6e4)} min`,i=e.length===1&&e[0].waitReason?` — ${e[0].waitReason}`:``;return`${o}${a}…${i?`${i};`:``} retrying in ${r}`}return`${o}${a}… ${i}s${i>=20?` — no receipt yet, will retry`:``}`}function o_(e){let t=Mo(e).trim().replace(/\s+/g,` `);return t?t.length>64?`${t.slice(0,64)}…`:t:e.mode===`upload`?`a file`:`an action`}function s_(e){return new Set(e.filter(V).map(e=>e.id))}function c_(e,t){for(let n of e)if(!t.has(n))return!0;return!1}function l_(e,t){return{...e,status:`pending`,attempts:(e.attempts??0)+1,sentAt:t,firstTryAt:e.firstTryAt??t,waitReason:void 0}}function u_(e){let t=e.firstTryAt;return e.mode===`upload`?null:e.mode===`op`?e.op?t==null?e.op:me(e.op,t):null:e.mode===`backlog`?{t:`backlog.add`,text:e.text,repoDir:e.cwd,label:e.label??e.text.slice(0,40),fire:e.fire,targetSessionId:e.targetSessionId,autoFire:e.autoFire,ackId:e.ackId,firstSentAt:t,steps:e.steps,resume:e.resume,...typeof e.closeWhenDone==`boolean`?{closeWhenDone:e.closeWhenDone}:{},...e.flagWhenDone?{flagWhenDone:!0}:{},...e.budget?{budget:e.budget}:{},...e.launch?{launch:e.launch}:{},...e.pastBudget?{pastBudget:!0}:{}}:e.answer?{t:`session.input`,id:e.sessionId,data:e.text,ackId:e.ackId,firstSentAt:t,expectPrompt:e.answer.fingerprint,promptSubmit:e.answer.submitBox,promptChoice:e.answer.choice,...e.answer.text===void 0?{}:{promptText:e.answer.text}}:{t:`session.input`,id:e.sessionId,data:e.text,ackId:e.ackId,firstSentAt:t,submit:!0,cwd:e.cwd,view:e.view}}function d_(e){return`sending “${e}”…`}var f_=`pending:`;function p_(e){let t=e.remembered;if(t?.startsWith(f_)){let n=t.slice(8);if(e.pendingAlive(n))return{do:`enter`,ack:n}}else if(t){let n=e.sessions.find(e=>e.id===t);if(n&&n.running)return{do:`attach`,id:n.id}}let n=e.sessions.find(t=>t.running&&!t.companionOf&&t.cwd===e.cwd&&e.isShell(t.backend));return n?{do:`attach`,id:n.id}:{do:`open`}}function m_(e,t,n){return e===`${f_}${t}`?n:e}function h_(e,t,n){let r=!1,i={};for(let[a,o]of Object.entries(e)){let e=m_(o,t,n);e!==o&&(r=!0),i[a]=e}return r?i:e}function g_(e){return`back to ${e}`}function __(e,t){return!!e&&!!t&&e.sessionId===t}var v_=Cn({}),y_=Cn(null);function b_(e,t,n){v_.set(n=>n[e]===t?n:{...n,[e]:t}),n&&y_.set(()=>({sessionId:t,to:n}))}function x_(e,t){v_.set(n=>h_(n,e,t)),y_.set(n=>{if(!n)return n;let r=m_(n.sessionId,e,t);return r===n.sessionId?n:{...n,sessionId:r}})}function S_(){y_.set(null)}var C_=3e4;function w_(e){return e?.adoptedAt&&Date.now()-e.adoptedAt>C_?void 0:e}function T_(e,t,n){let r=(0,Z.useRef)(new Map),i=(0,Z.useMemo)(()=>{if(!Jg(e))return null;let n=e.slice(qg.length);return t.find(e=>e.ackId===n&&Jp(e))??null},[t,e]);return{pendingKept:r,pendingEntry:i,pendingSession:(0,Z.useMemo)(()=>{if(e&&!Jg(e)){if(n.some(t=>t.id===e))return null;let t=w_(r.current.get(e));return t?.adoptedAt?{id:e,cwd:t.cwd,title:t.title,remoteControl:!1,running:!0,createdAt:t.ts}:null}if(!Jg(e))return null;if(Zg(e)){let t=e.slice(Xg.length);return{id:e,cwd:t,title:Fu(t)||`new session`,remoteControl:!1,running:!0,createdAt:Date.now()}}let t=i,a=w_(r.current.get(e.slice(qg.length)));if(!t&&!a)return null;let o=t?.op,s=t?.cwd||a?.cwd||``;return{id:e,cwd:s,title:o?.title||a?.title||Fu(s)||`new session`,remoteControl:!1,running:!0,createdAt:t?.ts??a?.ts??Date.now(),model:o?.launch?.model,effort:o?.launch?.effort,permissionMode:o?.launch?.permissionMode,remoteControlled:o?.launch?.remoteControlled}},[i,e,n])}}function E_(e){let{outboxRef:t,pendingKept:n,activeIdRef:r,connRef:i,wantNavRef:a,buffers:o,pendingEntry:s}=e,c=t=>e.writeOutbox(t),l=(t,n)=>e.addOutbox(t,n),u=(t,n,r,i)=>e.queueOp(t,n,r,i),d=e.setOverlay,f=e.setActiveId,p=e.setLastVisitedId;function m(e){let n=t.current.find(t=>Jp(t)&&t.cwd===e&&t.status!==`failed`);n&&g(n.ackId)}function h(e){a.current=!1,d(null),f(Qg(e))}function g(e){let r=t.current.find(t=>t.ackId===e),i=r?.op;for(r&&n.current.set(e,{cwd:r.cwd,title:i?.title||Fu(r.cwd),ts:r.ts});n.current.size>8;)n.current.delete(n.current.keys().next().value);a.current=!1,d(null),f(Yg(e))}function _(){let e=s,n=e?.op;if(!e||e.status!==`failed`||n?.t!==`session.create`)return;q(`action:session.pending.retry`);let r=t.current.filter(t=>t.mode===`input`&&t.createAck===e.ackId&&t.status===`failed`).sort((e,t)=>e.ts-t.ts),a=new Set([e.ackId,...r.map(e=>e.ackId)]);c(t.current.filter(e=>!a.has(e.ackId)));let o=Bd(),{ackId:l,...d}=n;u(d,e.sessionId,e.text,{cwd:e.cwd,focus:!0,ackId:o});for(let e of r)y(e.cwd,e.text,o,e.kind===`command`?`command`:`prompt`);g(o),K(i.current.status===`open`?`trying again…`:`queued — it opens when the link is back`)}function v(e,t){let i=Yg(e),a=n.current.get(e);if(a){let r={...a,adoptedAt:Date.now()};n.current.set(e,r),n.current.set(t,r)}if(x_(e,t),r.current!==i)return;let s=jr(i);s&&Aa(t,s),Aa(i,``),o.current.has(t)||o.current.set(t,[]),f(t),p(t)}function y(e,t,n,r=`prompt`){l({ackId:Bd(),sessionId:`create:${e}`,cwd:e,text:t,ts:Date.now(),status:`queued`,attempts:0,kind:r,mode:`input`,pendingCreate:!0,holdUntilIdle:!0,createAck:n,armed:!0})}function b(e,n){let r=new Set(Ae(t.current,e,n).map(e=>e.ackId));c(t.current.map(e=>r.has(e.ackId)?{...e,noTtl:!0}:e))}function x(e,n,r){let i=new Set(Ae(t.current,e,r).map(e=>e.ackId));c(t.current.map(e=>i.has(e.ackId)?(_i(),{...e,status:`failed`,reason:n,failedAt:Date.now()}):e))}function S(e,n){let r=e.upload?.relPath;if(!r)return;let i=e=>e.text.includes(r)||e.mode===`op`&&JSON.stringify(e.op??``).includes(r);c(t.current.map(t=>t.ackId!==e.ackId&&t.status===`queued`&&t.sessionId===e.sessionId&&i(t)?(_i(),{...t,status:`failed`,reason:n,failedAt:Date.now()}):t))}return{enterPending:g,enterOldestPending:m,enterLater:h,retryPendingCreate:_,adoptPendingSession:v,queueSessionPrompt:y,holdForLaunch:b,failPendingCreates:x,failDependentUploads:S}}function D_(e){let{connRef:t,sessionsRef:n,backendsRef:r,exitedRef:i,outboxRef:a,ackTimers:o,uploadsInFlight:s,uploadAborts:c,busyLanesRef:l,budgetHeldLanesRef:u,busySerialRef:d,serialWatchRef:f,budgetRef:p,autoSendRef:h,holdQueueRef:g,flushIdleReason:_,queueBlockedRef:v,readModeRef:y,serialSessionsRef:b,sessions:x}=e,{inflightRef:S,upBytesRef:C}=e.up,w=()=>e.up.refreshUploadLabel(),T=t=>e.writeOutbox(t),E=(t,n)=>e.addOutbox(t,n),D=t=>e.addOutboxFirstInLane(t),O=(t,n,r)=>e.failOutbox(t,n,r),k=t=>e.holdWall(t),A=(t,n,r,i)=>e.queueSessionPrompt(t,n,r,i);async function j(e,t=!0){if(e.mode!==`upload`)return;let n=e.upload?await yo(`uploads`,e.ackId):null;n&&e.upload&&await sn(e.upload.relPath,n),t&&await Cr(`uploads`,e.ackId)}function M(e){return e_(e,Bp())}function N(e){let t=Date.now();T(a.current.map(n=>{if(n.ackId!==e||n.status===`failed`)return n;let r=(n.round??0)+1,i=Qe(r);return{...n,status:`queued`,attempts:0,round:r,retryAt:t+i,waitReason:`the desktop hasn't answered yet`}}));let n=a.current.find(t=>t.ackId===e);n&&(n.round??0)===1&&K(`still sending — the desktop hasn't confirmed yet. Retrying in ${Math.round(Qe(1)/6e4)} min; your text is safe.`)}function P(e,n=Bg){let r=window.setTimeout(()=>{o.current.delete(e);let n=a.current,r=t.current.status!==`open`;n.some(t=>t.ackId===e&&t.status===`pending`)&&(Ql(),T(n.map(t=>t.ackId===e?t_(t,r):t))),I()},n);o.current.set(e,r)}function F(){if(t.current.status!==`open`||Nc().pending.includes(`sessions`))return[];let e=new Set(n.current.filter(e=>e.running).map(e=>e.id));return r_(a.current,e,i.current)}function I(i=!1){if(i&&(g.current=!1,T(a.current.map(e=>e.status===`queued`?{...e,armed:!0,retryAt:void 0,waitReason:void 0,holdUntilIdle:e.holdUntilIdle&&(e.pendingCreate||k(e.sessionId))?!0:void 0}:e))),t.current.status!==`open`)return _.current=qe([],{online:!1,queued:1}),0;let c=F(),m=Ze(a.current,{now:Date.now(),inflight:[...o.current.keys(),...s.current],maxAttempts:8,minTryMs:_e,busyLanes:l.current,busySerial:(()=>{let e=Ne(ea(n.current,r.current),f.current,Date.now());return d.current=e.busy,f.current=e.watches,e.busy})(),budgetBlocked:p.current?.verdict.blocked??!1,goneLanes:c,budgetHeldLanes:u.current});m.release.length&&T(We(a.current,m.release));for(let e of m.expire)Fr(),N(e.ackId);let y={autoSend:h.current,hold:g.current},b=0,x=[...m.blocked];for(let e of m.send){if(!Ve(e,y)){x.push({ackId:e.ackId,sessionId:e.sessionId,reason:`gate`});continue}let n=Date.now(),r=l_(e,n);if(T(a.current.map(t=>t.ackId===e.ackId?l_(t,n):t)),e.mode===`upload`){ie(e),b++;continue}let i=u_(r);i&&t.current.send(i),P(e.ackId,M(e)),b++}let S=new Map(x.map(e=>[e.ackId,e.reason]));return v.current=S,e.setQueueBlocked(S),_.current=b?null:qe(x,{online:!0,queued:a.current.filter(e=>e.status===`queued`).length,serialText:(()=>{let e=x.find(e=>e.reason===`serial`),t=e&&a.current.find(t=>t.ackId===e.ackId);return t?.serial?du(t.serial,n.current,r.current):void 0})()}),b}function te(e=`nothing queued`){return _.current??e}function L(){window.setTimeout(()=>{I()},450)}function R(e){let t=ye(a.current,e)[0],n=t?{relPath:t,reason:`it never uploaded`}:Ti(e);return n?`${n.relPath.split(`/`).pop()} — ${n.reason}. Re-attach it before sending.`:null}function ne(e,t){let n=R(e);if(n)return K(n),!1;let r=Le(a.current,e,t);return r.some((e,t)=>e!==a.current[t])&&T(r),!0}function B(e){let t=R(e.join(`
|
|
3
|
-
`));return!t||(K(t),!1)}function V(e,n,r,i,a=!1){if(!a&&z(r)){let t=x.find(t=>t.id===e);t&&(t.hooked?t.turnActive:t.running&&!t.idle)&&(a=!0,K(`${r.trim().split(/\s+/)[0]} opens a view — held until this turn ends`))}if(!ne(r,$g(e,n)))return!1;if(Zg(e))return K(`this session starts only when its backlog item runs — write it in the box and Send`),!1;if(Jg(e))return A(n,r,e.slice(qg.length),i),I(),!0;let o=Bd(),s=t.current.status!==`open`;return E({ackId:o,sessionId:e,cwd:n,text:r,ts:Date.now(),status:`queued`,attempts:0,kind:i,mode:`input`,offline:s,armed:!s,holdUntilIdle:a||void 0,view:y.current?`read`:`term`}),s||ae(e),I(),!0}function H(e,n,r,i){let a=i?.ackId??Bd(),o=t.current.status!==`open`,s=i?.cwd??``,c=(i?.serial??b.current)&&e.t===`session.create`&&e.prompt&&s?Ce(s):void 0;return E({ackId:a,sessionId:n,cwd:s,text:r,ts:Date.now(),status:`queued`,attempts:0,mode:`op`,serial:c,op:{...e,ackId:a},focus:i?.focus&&!o?!0:void 0,offline:o,armed:!o},i?.frontOfLane),i?.track&&yn(a),o||ae(n),I(),o}async function re(e,t,n,r,i){r=$g(r,i);let a=Bd(),{name:o,relPath:s}=ls(n);return await dr(`uploads`,a,t),await yo(`uploads`,a)?(E({ackId:a,sessionId:r,cwd:i,text:`file · ${o}`,ts:Date.now(),status:`queued`,attempts:0,mode:`upload`,upload:{repoId:e,name:o,relPath:s,size:t.size,type:t.type||`application/octet-stream`},armed:!0}),I(),{relPath:s,ackId:a}):null}async function ie(e){let n=e.upload;if(!n){O(e.ackId,`not an image`),L();return}s.current.add(e.ackId);let r=new AbortController;c.current.set(e.ackId,r),S.current++,C.current.startedAt||(C.current.startedAt=Date.now()),C.current.total+=n.size,w();let i=0,o=Date.now(),l=!1,u=0,d=()=>{window.clearTimeout(u),u=window.setTimeout(()=>{l=!0,r.abort(new ee(`upload`,Gg))},Gg)};d();try{let t=await yo(`uploads`,e.ackId);if(!t){O(e.ackId,`the file's bytes are no longer on this device`);return}let s=await Dn.uploadInbox(n.repoId,t,n.name,r.signal,e=>{C.current.sent+=Math.max(0,e-i),i=e,d(),w()},!0),c=s.saved?.[0]?.relPath;if(!c){O(e.ackId,s.skipped?.[0]?.error||`the host refused the file`);return}Bu(n.repoId,c,s.saved[0].mtime),ms(n.size,Date.now()-o),Cr(`uploads`,e.ackId),c!==n.relPath&&U(n.relPath,c),T(a.current.filter(t=>t.ackId!==e.ackId))}catch(n){if(n?.permanent){O(e.ackId,n.message);return}let r=lt({responded:n?.responded,stalled:l,socketOpen:t.current.status===`open`});T(a.current.map(t=>t.ackId===e.ackId&&t.status===`pending`?t_(t,r):t))}finally{window.clearTimeout(u),C.current.sent+=Math.max(0,n.size-i),S.current=Math.max(0,S.current-1),w(),c.current.delete(e.ackId),s.current.delete(e.ackId),L()}}function U(t,n){T(a.current.map(e=>{if(!e.text.includes(t))return e;let r=e.text.split(t).join(n);if(e.mode===`op`&&e.op){let i={...e.op};return typeof i.text==`string`&&(i.text=i.text.split(t).join(n)),typeof i.prompt==`string`&&(i.prompt=i.prompt.split(t).join(n)),{...e,text:r,op:i}}return{...e,text:r,label:e.mode===`backlog`?r.slice(0,40):e.label}})),e.setCompose(e=>e.includes(t)?e.split(t).join(n):e)}function ae(e){let t=a.current.filter(t=>t.sessionId===e&&t.status===`queued`&&!t.armed);t.length&&(T(a.current.map(t=>t.sessionId===e&&t.status===`queued`?{...t,armed:!0}:t)),K(`sending ${t.length} earlier queued message${t.length>1?`s`:``} first`))}function oe(e){if(!ne(e.text,e.targetSessionId??e.repoDir))return null;let n=Bd(),r=t.current.status!==`open`;return E({ackId:n,sessionId:e.targetSessionId??e.repoDir,cwd:e.repoDir,text:e.text,ts:Date.now(),status:`queued`,attempts:0,mode:`backlog`,label:e.label,fire:e.fire,autoFire:e.autoFire,targetSessionId:e.targetSessionId,steps:e.steps&&e.steps.length>1?e.steps:void 0,resume:e.resume||void 0,closeWhenDone:typeof e.closeWhenDone==`boolean`?e.closeWhenDone:void 0,flagWhenDone:e.flagWhenDone===!0||void 0,budget:e.budget,launch:e.launch,pastBudget:e.pastBudget||void 0,offline:r,armed:!r}),r||ae(e.targetSessionId??e.repoDir),I(),r}function W(e,n,r,i,a,o){let s=e.prompt;if(!s)return;let c=t.current.status!==`open`;D({ackId:Bd(),sessionId:e.id,cwd:e.cwd,text:n,ts:Date.now(),status:`queued`,attempts:0,mode:`input`,answer:{fingerprint:m(s),question:s.question,label:r,...i?{submitBox:!0}:{},...a==null?{}:{choice:a},...o===void 0?{}:{text:o}},offline:c,armed:!0}),K(c?`answer saved — “${r}” goes out when the link is back`:d_(r)),I()}return{retainUploadBytes:j,ackWindowFor:M,nextRound:N,armAckTimeout:P,goneLanes:F,flushOutbox:I,idleReason:te,releaseLane:L,uploadRefusal:R,guardUploadRefs:ne,guardChain:B,submitInput:V,queueOp:H,queueImageUpload:re,runUpload:ie,rewriteQueuedPath:U,armLane:ae,queueBacklog:oe,answerPrompt:W}}function O_(t){let{outboxRef:n,outbox:r,pendingKept:i,activeIdRef:a,connRef:o,sessions:s,activeId:c}=t,l=e=>t.writeOutbox(e),u=e=>t.flushOutbox(e),d=e=>t.idleReason(e),f=e=>t.holdWall(e),p=(e,n)=>t.retainUploadBytes(e,n),m=(e,n,r)=>t.failPendingCreates(e,n,r),h=(e,n,r)=>t.queueSessionPrompt(e,n,r),g=t.openSend,_=t.sendTargetFor,v=t.setActiveId,y=t.setCompose;function b(){let e=fr(r);if(!e){K(bo(r)?`those are files, not text — open the message that names one and re-attach it there`:`nothing to put back — the failed items are actions, not text`);return}let t=r.filter(e=>e.status===`failed`&&e.mode!==`op`).length-1;g({prompts:[Mo(e)],target:_(e.sessionId,e.cwd),cwdHint:e.cwd,repoId:F(e),ackId:e.ackId,repair:!0,openAfter:!0,origin:t>0?`This one never went — ${t} more under Manage`:`This one never went`})}function x(){for(let e of n.current)e.status===`failed`&&e.mode===`upload`&&p(e);l(n.current.filter(e=>e.status!==`failed`))}function S(e,t){l(n.current.map(n=>{if(n.ackId!==e||n.status!==`queued`)return n;if(n.mode===`op`){let e=n.op;return e?.t===`session.create`?{...n,text:t,op:{...e,prompt:t}}:!e||e.t!==`fanout.run`&&e.t!==`fanout.followup`?n:{...n,text:t,op:{...e,text:t}}}return{...n,text:t,label:n.mode===`backlog`?t.slice(0,40):n.label}}))}function C(t,r){let i=n.current,a=i.find(e=>e.ackId===t);return a?re(a)?(q(`action:queue.retarget`),l(e(i,t,{...r,ackId:Bd()})),K(r.mode===`backlog`?`moved to that repo's backlog`:`moved to that session`),!0):(K(a.mode===`op`?`an action can't be re-aimed`:`already on its way`),!1):!1}function w(t){let r=n.current,i=r.find(e=>e.ackId===t);if(!i)return;if(!re(i)){K(`already on its way`);return}if(z(i.text??``)){i.holdUntilIdle||T(t),K(Fc(`idle`,{online:o.current.status===`open`,holder:`phone`,phoneHold:`opens-a-view`}));return}q(`action:queue.handtodesktop`);let a=Bd();l(e(r,t,{sessionId:i.sessionId,cwd:i.cwd,ackId:a,mode:`backlog`,targetSessionId:i.sessionId}).map(e=>e.ackId===a?{...e,autoFire:!0,holdUntilIdle:void 0,kind:void 0}:e)),u(),K(Fc(`idle`,{online:o.current.status===`open`,holder:`desktop`}))}function T(e){q(`action:queue.hold`),l(n.current.map(t=>t.ackId===e&&t.status===`queued`?{...t,holdUntilIdle:!t.holdUntilIdle||void 0}:t)),u()}function E(e){q(`action:queue.serial`),l(n.current.map(t=>t.ackId===e&&t.status===`queued`&&zo(t)?{...t,serial:t.serial?void 0:Ce(t.cwd)}:t)),u()}function O(e){return n.current.filter(t=>t.mode!==`op`||t.status===`pending`?!1:t.op?.t===`schedule.run`?t.op.id===e:t.op?.t===`schedule.save`&&t.op.entry?.id===e)}function k(e){if(!e.length)return;let t=new Set(e.map(e=>e.ackId));l(n.current.filter(e=>!t.has(e.ackId)))}function A(e){let t=n.current.find(t=>t.ackId===e);i.current.delete(e),a.current===Yg(e)&&v(null),t?p(t):Cr(`uploads`,e),t?.mode===`upload`&&t.upload&&ti(t.upload.relPath,`the upload was canceled`),l(n.current.filter(t=>t.ackId!==e)),t&&Jp(t)&&m(t.sessionId,`the session it was queued for was discarded`,t.ackId)}function j(e,t){let r=n.current.find(t=>t.ackId===e);!r||!Jp(r)||r.status!==`queued`?K(`that session is already on its way`):(q(`action:queue.addprompt`),h(r.cwd,t,r.ackId),K(`queued — it runs after the one before it finishes`))}function M(e,t){l(D(n.current,e,t))}function ee(e){let t=n.current,r=t.find(t=>t.ackId===e);if(!r)return;if(r.status===`failed`){if(!Hi(r)){K(Ai(r)?`it may already be in that session — open it and look, or rewrite it to send a fresh copy`:`the desktop remembers refusing this exact message — rewrite it to send it as a new one`);return}r.mode===`upload`&&r.upload&&(sr(r.upload.relPath),Gp(r.upload.relPath)),t=l(t.map(t=>t.ackId===e?{...t,status:`queued`,attempts:0,tries:0,round:void 0,retryAt:void 0,waitReason:void 0,ts:Date.now(),reason:void 0,armed:!0}:t))}let i=t.find(t=>t.ackId===e);if(!i)return;let a=t.indexOf(i),o=t.filter((e,t)=>t<a&&e.sessionId===i.sessionId&&e.status===`queued`&&!e.armed),s=i.holdUntilIdle&&!i.pendingCreate?f(i.sessionId):null;s?K(s):(l(t.map((t,n)=>t.ackId===e?{...t,armed:!0,retryAt:void 0,waitReason:void 0,serial:void 0,holdUntilIdle:n_(t)}:n<a&&t.sessionId===i.sessionId&&t.status===`queued`?{...t,armed:!0,retryAt:void 0,waitReason:void 0,holdUntilIdle:n_(t)}:t)),u()?o.length&&K(`${o.length} earlier message${o.length>1?`s`:``} in this session go first`):K(d(`nothing left to send`)))}function N(){let e=n.current.filter(Hi);if(!e.length){K(`nothing to try again`);return}for(let t of e)t.mode===`upload`&&t.upload&&(sr(t.upload.relPath),Gp(t.upload.relPath));let t=new Set(e.map(e=>e.ackId));l(n.current.map(e=>t.has(e.ackId)?{...e,status:`queued`,attempts:0,tries:0,round:void 0,retryAt:void 0,waitReason:void 0,ts:Date.now(),reason:void 0,failState:void 0,failedAt:void 0,armed:!0}:e));let r=u();K(r?`${e.length} back in the queue — sending…`:`${e.length} back in the queue — ${d(`waiting`)}`)}function P(e){let t=n.current.find(t=>t.ackId===e);if(!t)return;if(t.mode===`op`){K(`that's an action — discard it instead`);return}if(t.pendingCreate){A(e),y(e=>e?`${e}\n${t.text}`:t.text),K(`moved into the message box`);return}A(e);let r=s.find(e=>e.id===t.sessionId);if(!r){y(e=>e?`${e}\n${t.text}`:t.text),K(`moved into the message box`);return}let i=jr(r.id),a=i?`${i}\n${t.text}`:t.text;Aa(r.id,a),c===r.id&&y(a),K(`moved into ${r.title}'s message box`)}function F(e){return t.repoForCwd(e.cwd)?.id??null}return{restoreOutbox:b,dismissOutbox:x,editQueued:S,retargetQueued:C,handToDesktop:w,toggleHoldQueued:T,toggleSerialQueued:E,scheduleQueueRows:O,dropScheduleQueue:k,removeQueued:A,addPromptToQueuedCreate:j,moveQueued:M,sendQueuedNow:ee,retryFailedQueued:N,restoreQueued:P,repoIdOfEntry:F}}function k_(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(0),[i,a]=(0,Z.useState)(null),o=(0,Z.useRef)(0),s=(0,Z.useRef)(0),c=(0,Z.useRef)({sent:0,total:0,startedAt:0,fullAt:0}),l=(0,Z.useRef)(new Set),u=(0,Z.useRef)(null);function d(){let e=o.current;if(r(s.current),e<=0){c.current={sent:0,total:0,startedAt:0,fullAt:0},t(null),a(null);return}let n=Date.now(),{sent:i,total:l,startedAt:u}=c.current,d=u?n-u:0,f=d>700&&i>4e4?i/1024/(d/1e3):null,p=l>0&&i>=l;p?c.current.fullAt||(c.current.fullAt=n):c.current.fullAt=0;let m=c.current.fullAt?Math.round((n-c.current.fullAt)/1e3):0,h=l>0?p?100:Math.min(99,Math.round(i/l*100)):0,g=l>i?Jr(l-i,f):null;t(l<=0?`Uploading ${e}…`:p?`Sent ${Is(l)} · waiting for the host${m>2?` · ${m}s`:``}`:`Uploading ${e} · ${h}% · ${Is(i)}/${Is(l)}${f?` · ${Math.round(f)} kB/s`:``}${g?` · ${g}`:``}`),a({sent:i,total:l,pct:h,kbps:f,waiting:p})}let f=e!=null,p=zg(f,900);return(0,Z.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>d(),1e3);return()=>window.clearInterval(e)},[f]),{uploading:e,parking:n,upProg:i,setUploading:t,setUpProg:a,inflightRef:o,parkingRef:s,upBytesRef:c,allBufsRef:l,uploadBufRef:u,refreshUploadLabel:d,uploadPending:f,uploadRowLinger:p}}function A_(e){let{inflightRef:t,parkingRef:n,upBytesRef:r,allBufsRef:i,uploadBufRef:a,setUploading:o,setUpProg:s}=e.up,c=()=>e.up.refreshUploadLabel(),{uploadsInFlight:l,uploadAborts:u,sessionsRef:d,activeIdRef:f,composeTextRef:p,connRef:m,repos:h}=e,g=e.getActive,_=(t,n,r,i,a)=>e.queueImageUpload(t,n,r,i,a),v=t=>e.removeQueued(t),y=t=>e.queueBacklog(t),b=(t,n,r,i,a)=>e.submitInput(t,n,r,i,a),x=t=>e.pushHistory(t),S=e.setCompose;function C(e){let t=a.current;if(t&&!t.closed&&t.repoId===e)return t;let n=g(),r=n?{id:n.id,cwd:n.cwd}:void 0,o={repoId:e,slots:[],started:0,done:0,closed:!1,submit:!1,queue:!1,ctrl:new AbortController,ackIds:[],target:r};return i.current.add(o),a.current=o}function w(e,r,i,a,o){let s=e.started++;e.slots[s]=null,t.current++,n.current++,c(),(async()=>{let l=null,u=h.find(t=>t.id===e.repoId)?.worktreePath??e.repoId,d=e.target?.id??`create:${u}`;try{let t=r instanceof Blob?r:await r,{width:n}=Nd(),s=await ns(t,i,n),c=await _(e.repoId,s.blob,s.name,d,e.target?.cwd??u);if(!c)e.fail??=`this browser can't hold files offline — reconnect and re-attach`,K(e.fail);else{e.ackIds.push(c.ackId);let t=await Promise.resolve(a),n=s.width&&s.height?{w:s.width,h:s.height}:o??null,r=t?Gl(t,n):``;l=r?`${c.relPath} (marked: ${r})`:c.relPath}}catch{e.fail??=`couldn't read that image`}t.current=Math.max(0,t.current-1),n.current=Math.max(0,n.current-1),e.ctrl.signal.aborted?c():(e.slots[s]=l,e.done++,c(),E(e))})()}function T(){let e=new Set(l.current);for(let t of i.current){t.ctrl.abort();for(let n of t.ackIds)e.add(n)}if(a.current){a.current.ctrl.abort();for(let t of a.current.ackIds)e.add(t)}if(i.current.clear(),a.current=null,e.size||t.current){for(let t of e)u.current.get(t)?.abort(),v(t);t.current=0,n.current=0,r.current={sent:0,total:0,startedAt:0,fullAt:0},o(null),s(null),K(`Uploads canceled`)}}function E(t){if(t.finalized||t.done<t.started||!t.closed)return;t.finalized=!0,i.current.delete(t),a.current===t&&(a.current=null);let n=t.slots.filter(e=>!!e);if(!n.length){K(t.fail??`Upload failed`);return}let r=n.join(` `);$i(r);let o=t.target?d.current.find(e=>e.id===t.target.id&&e.running):null,s=!t.target||f.current===t.target.id,c=p.current,l=c?`${c}${c.endsWith(` `)?``:` `}${r}`:r;if(t.queue&&t.target){let i=(s?l:r).trim();if(y({text:i,repoDir:t.target.cwd,label:i.slice(0,40),targetSessionId:o?t.target.id:void 0,autoFire:!0})===null)return;x(i),s&&S(``),s&&Zg(t.target.id)&&e.setActiveId(null),K(o?`Attached ${n.length} · ${Fc(`idle`,{online:m.current.status===`open`,holder:`desktop`})}`:`Attached ${n.length} · waiting in this repo's backlog — it opens a session of its own when it runs`)}else if(t.submit&&o){let e=s?l:r;if(!b(o.id,o.cwd,e,e.trimStart().startsWith(`/`)?`command`:`prompt`))return;x(e),s&&S(``),K(`Attached ${n.length} · submitted`)}else s?(S(l),K(t.submit&&!Zg(t.target?.id)?`Attached ${n.length} · session gone, in box`:`Attached ${n.length} · ready`)):K(`Attached ${n.length} · copied (switched away)`)}return{ensureUploadBuf:C,queueUpload:w,cancelUploads:T,settleUploads:E}}function j_(e){let{ackTimers:t,outboxRef:n,serialWatchRef:r}=e,i=e,a=t=>e.writeOutbox(t),o=t=>e.flushOutbox(t),s=(t,n,r)=>e.failOutbox(t,n,r),c=()=>e.releaseLane(),l=e.applyDeliverySettled,u=(t,n,r)=>e.failPendingCreates(t,n,r),d=(t,n)=>e.adoptPendingSession(t,n),f=(t,n)=>e.holdForLaunch(t,n);function p(e){let r=t.current.get(e.ackId);r!=null&&(clearTimeout(r),t.current.delete(e.ackId)),e.ok?a(n.current.filter(t=>t.ackId!==e.ackId)):s(e.ackId,e.reason||`could not queue`),c()}function m(e){let o=t.current.get(e.ackId);o!=null&&(clearTimeout(o),t.current.delete(e.ackId));let l=n.current.find(t=>t.ackId===e.ackId);Za(e.ackId,e.ok,e.runId,e.reason),l?.op?.t===`signin.continue`&&K(e.reason||(e.ok?`continuing after the sign-in`:`nothing was continued`)),e.ok?(a(n.current.filter(t=>t.ackId!==e.ackId)),l&&Jp(l)&&(l.serial&&e.sessionId&&(r.current=[...r.current.filter(e=>e.group!==l.serial),{group:l.serial,sessionId:e.sessionId,at:Date.now()}]),e.sessionId?(a(le(n.current,l.sessionId,e.sessionId,Date.now(),l.ackId)),d(l.ackId,e.sessionId)):e.launchId?f(l.sessionId,l.ackId):u(l.sessionId,`the session was never named — re-aim these or discard them`,l.ackId)),l?.focus&&e.sessionId&&i.focusSession(e.sessionId)):(s(e.ackId,e.reason||`could not start`,`refused`),l?.op?.t===`intent.requeue`&&K(e.reason||`it was not put back — the desktop refused it`)),c()}function h(e){let r=t.current.get(e.ackId);r!=null&&(clearTimeout(r),t.current.delete(e.ackId));let i=n.current.find(t=>t.ackId===e.ackId);if(e.ok)e.state===`forked`?K(e.reason||`forked into a new session`):i&&$n(Date.now()-i.ts),i?.answer&&Ui(d_(i.answer.label)),a(n.current.filter(t=>t.ackId!==e.ackId)),c();else if(e.retryable)a(n.current.map(t=>t.ackId===e.ackId&&t.status===`pending`?{...t_(t,!1),waitReason:e.reason||void 0}:t)),c();else if(e.state===`rescued`)a(n.current.filter(t=>t.ackId!==e.ackId)),K(e.reason||`that session is gone — the words are a backlog item now`),c();else{if(s(e.ackId,e.reason||`session gone`,e.state===`unconfirmed`||e.state===`unsubmitted`||e.state===`stale`?e.state:`other`),e.state===`stale`){let e=i?.answer;K(e?`“${e.label}” wasn't sent — that question is gone: ${e.question.slice(0,60)}`:`answer not sent — that question is gone`)}else e.state===`unsubmitted`&&K(`prompt is in the composer but Return didn't take — open the session and press Return`);c()}}function g(e){for(let t of e.items)l(t)}function _(e){l(e.item)}function v(e){i.setLaunches(e.launches);for(let t of e.launches)(t.state===`failed`||t.state===`canceled`)&&u(`create:${t.cwd}`,t.reason||`the session never opened`,t.id)}function y(e){a(le(n.current,`create:${e.cwd}`,e.sessionId,Date.now(),e.id)),d(e.id,e.sessionId),o()}function b(e){let t={budget:e.budget,verdict:e.verdict,...e.periods?{periods:e.periods}:{}};i.setBudget(t),i.budgetRef.current=t,e.verdict.blocked||o()}return{onBacklogAck:p,onOpAck:m,onInputAck:h,onDeliveryList:g,onDeliverySettled:_,onLaunchList:v,onLaunchOpened:y,onBudget:b}}function M_(e,t,n){if(!Array.isArray(e)||!e.length)return{doc:t,n:0};let r=new Set(t.notes.map(e=>e.id)),i=new Map(t.tombs.map(e=>[e.id,e.gone])),a=new Map,o=t;for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;if(typeof e.id!=`string`||!e.id||typeof e.text!=`string`||!e.text.trim()||r.has(e.id))continue;let s=typeof e.ts==`number`&&Number.isFinite(e.ts)?e.ts:n,c=i.get(e.id);if(c!==void 0&&c>=s)continue;let l=a.get(e.id);if(l!==void 0&&l>=s)continue;let u={id:e.id,text:e.text,ts:s},d=Array.isArray(e.steps)?e.steps.filter(e=>typeof e==`string`&&!!e.trim()):[];d.length&&(u.steps=d),typeof e.cwd==`string`&&e.cwd&&(u.cwd=e.cwd),o=Ye(o,u),a.set(e.id,s)}return{doc:o,n:a.size}}function N_(){if(Et(G.padRescueMigrated))return 0;let e=()=>Tt(G.padRescueMigrated,String(Date.now())),{doc:t,n}=M_(ht(G.padRescue,[]),yr(),Date.now());return n?_f(t)?(e(),n):0:(e(),0)}function P_(e){if(Et(G.giveupsMigrated))return e;let t=ht(G.giveups,[]);if(Tt(G.giveupsMigrated,String(Date.now())),!Array.isArray(t)||!t.length)return e;let n=new Set(e.map(e=>e.ackId)),r=new Map(Zo().map(e=>[e.id,e])),i=[];for(let e of t){if(!e||e.retriedAt||e.ackId&&n.has(e.ackId)||e.bytes||e.kind===`file`||e.kind===`answer`)continue;let t=e.padId?r.get(e.padId):void 0,a=(t?[t.text,...t.steps??[]].join(`
|
|
4
|
-
|
|
5
|
-
`):e.text??``).trim();if(!a)continue;let o=e.cwd??``;i.push({ackId:Bd(),sessionId:o||`unknown`,cwd:o,text:a,ts:e.ts??Date.now(),status:`failed`,mode:`backlog`,label:a.slice(0,40),failedAt:e.ts??Date.now(),failState:e.failState,reason:e.reason?`${e.reason}${t?``:e.clipped?` (only the shortened copy was kept)`:``}`:`this one never reached a session`})}return i.length?[...e,...i.sort((e,t)=>e.ts-t.ts)]:e}function F_(e){to(Do);let t=up(Cp),n=up(_c),{conn:r,...i}=e,{status:a,connRef:o,reconnectAsk:s,setReconnectAsk:c}=r,{sessions:l}=i,u=Ip(l),d=Ip(i.backends),f=Ip(i.activeId),p=xa(`confirmQueue`),[m,h]=(0,Z.useState)(null),g=(0,Z.useRef)(null),[_,v]=(0,Z.useState)([]),y=Ip(_),[,b]=(0,Z.useState)(0),x=t.some(e=>e.status===`pending`||e.status===`queued`&&e.retryAt!=null);(0,Z.useEffect)(()=>{if(!x)return;let e=window.setInterval(()=>b(e=>e+1),1e3);return()=>window.clearInterval(e)},[x]);let S=zg(t.some(e=>e.status!==`failed`),Ug),C=(0,Z.useRef)(t),w=(0,Z.useRef)(new Map),T=(0,Z.useRef)(new Set),E=(0,Z.useRef)(new Map),D=(0,Z.useRef)(new Set),O=(0,Z.useRef)(new Set),k=(0,Z.useRef)(new Set),j=(0,Z.useRef)([]),M=(0,Z.useRef)(new Map),ee=(0,Z.useRef)(!1),N=(0,Z.useRef)(null),P=(0,Z.useRef)(new Map),{pendingKept:F,pendingEntry:I,pendingSession:L}=T_(i.activeId,t,l),R=k_(),ne={...i,connRef:o,status:a,reconnectAsk:s,setReconnectAsk:c,sessionsRef:u,backendsRef:d,activeIdRef:f,getActive:()=>l.find(e=>e.id===i.activeId)??L,budgetRef:g,setBudget:h,launchesRef:y,setLaunches:v,serialSessionsRef:xa(`serialSessions`),confirmQueueRef:p,autoSendRef:xa(`autoSend`)},z=ne,B={...ne,outbox:t,outboxRef:C,ackTimers:w,uploadsInFlight:T,uploadAborts:E,busyLanesRef:D,budgetHeldLanesRef:O,busySerialRef:k,serialWatchRef:j,holdQueueRef:ee,flushIdleReason:N,queueBlockedRef:P,setQueueBlocked:e=>_c.set(e),pendingKept:F,pendingEntry:I,up:R},V=e=>B.writeOutbox(e),re=e=>B.flushOutbox(e),ie=(e,t)=>B.retainUploadBytes(e,t),U=(e,t,n)=>B.failPendingCreates(e,t,n),ae=(e,t)=>B.failDependentUploads(e,t);function oe(e){let t=u.current.find(t=>t.id===e);if(!t)return null;let n=ge({...kn(t,d.current),turnActive:void 0});return n===`limit`?`blocked on a usage limit — it goes out at the reset`:n===`auth`?`that session is signed out — it goes out once you sign in there`:n===`net`?`the desktop is retrying that session's last turn after a network error — it goes out once that gets through`:n===`awaitingAnswer`?t.awaitingInput?`a dialog is open in that session — answer it first`:`a question is on screen in that session — answer it first`:null}function W(e){return zt(e),C.current=e,Cp.set(e),Pt(e.filter(e=>e.status!==`failed`).length),e}function se(e,t=!1){let n=C.current,r=t?je(n,e.sessionId):n.length,i=[...n.slice(0,r),e,...n.slice(r)];if(i.length>500){let e=i.length-500,t=new Set(i.filter(e=>e.status!==`failed`).slice(0,e).map(e=>e.ackId));t.size&&(i=i.map(e=>t.has(e.ackId)?(_i(),{...e,status:`failed`,reason:`queue full — older messages were pushed out`,failedAt:Date.now()}):e),K(`queue full — ${t.size} older message${t.size>1?`s`:``} stopped; their words are in ${ec.activity}`))}if(i.length>1e3){let e=i.filter(e=>e.status===`failed`),t=new Set(e.slice(0,i.length-Li).map(e=>e.ackId));t.size&&(i=i.filter(e=>!t.has(e.ackId)),K(`${t.size} of the oldest failed sends had to be dropped — this device is out of room for them`))}V(i)}function ce(e){se(e,!0)}function le(e,t,n){let r=C.current,i=r.find(t=>t.ackId===e&&t.status!==`failed`);if(i&&(_i(),K(Wt(n,t,z.overlayRef.current===`queue`)),V(r.map(r=>r.ackId===e?{...r,status:`failed`,reason:t,failState:n??`other`,failedAt:Date.now()}:r)),Jp(i)&&U(i.sessionId,`the session never opened — ${t}`,i.ackId),i.mode===`upload`&&i.upload)){ti(i.upload.relPath,`it never uploaded — ${t}`),ie(i,!1),ae(i,`the image it refers to never uploaded — ${t}`);for(let e of z.launchesRef.current)e.state===`waiting`&&e.needs.includes(i.upload.relPath)&&o.current.send({t:`launch.cancel`,id:e.id})}}function de(e){if(!e.ackId||e.verdict===`open`)return;let t=C.current.find(t=>t.ackId===e.ackId&&t.status===`failed`);if(!t)return;if(e.verdict===`landed`){V(C.current.filter(e=>e.ackId!==t.ackId)),K(`“${t.text.slice(0,40)}${t.text.length>40?`…`:``}” did run after all — cleared from the queue`);return}let n=e.verdict===`composer`?`still in that session's composer — open it and press Return`:e.reason??(e.verdict===`absent`?`checked — it never landed`:`still unreadable — the desktop could not tell`);V(C.current.map(e=>e.ackId===t.ackId?{...e,reason:n,hostSettled:!0}:e))}Object.assign(B,{writeOutbox:W,addOutbox:se,addOutboxFirstInLane:ce,failOutbox:le,applyDeliverySettled:de,holdWall:oe}),Object.assign(B,D_(B)),Object.assign(B,E_(B)),Object.assign(B,O_(B)),Object.assign(B,A_(B));let fe=j_(B);(0,Z.useEffect)(()=>{if(a!==`open`)return;let e=C.current.filter(e=>e.status===`queued`&&e.offline&&!e.armed);if(p.current&&e.length>0){ee.current=!0,c(!0),re();return}ee.current=!1;let t=re();if(t>0){let e=C.current.filter(e=>e.status!==`failed`).length;K(e>t?`sending ${e} queued messages…`:`sent ${t} queued message${t>1?`s`:``}`)}},[a]);let pe=t.filter(e=>e.status===`queued`&&e.offline&&!e.armed);(0,Z.useEffect)(()=>{s&&!pe.length&&(ee.current=!1,c(!1))},[s,pe.length]),(0,Z.useEffect)(()=>{if(a===`open`)return;let e=C.current.filter(e=>e.status===`pending`&&e.mode!==`upload`);if(!e.length)return;for(let t of e){let e=w.current.get(t.ackId);e!=null&&(clearTimeout(e),w.current.delete(t.ackId))}let t=new Set(e.map(e=>e.ackId));V(C.current.map(e=>t.has(e.ackId)?{...e,status:`queued`,attempts:Math.max(0,(e.attempts??1)-1),retryAt:void 0,waitReason:void 0}:e))},[a]),(0,Z.useEffect)(()=>{let e=window.setInterval(()=>{re()},Wg);return()=>window.clearInterval(e)},[]);let me=t.filter(e=>e.status===`queued`).length,he=(0,Z.useRef)(me);he.current=me,(0,Z.useEffect)(()=>{let e=`queue`,t=()=>navigator.serviceWorker?.getRegistration?.(),n=()=>{try{t()?.then(t=>t?.getNotifications({tag:e}).then(e=>e.forEach(e=>e.close())).catch(()=>{})).catch(()=>{})}catch{}},r=()=>{let r=he.current;if(r<=0)n();else if(`Notification`in window&&Notification.permission===`granted`)try{t()?.then(t=>t?.showNotification(`Messages still queued`,{body:`${r} message${r>1?`s`:``} waiting to go out. Open ${A.name} to send ${r>1?`them`:`it`}.`,tag:e,silent:!0})).catch(()=>{})}catch{}},i=()=>{document.visibilityState===`hidden`?r():n()};return window.addEventListener(`pagehide`,r),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`pagehide`,r),document.removeEventListener(`visibilitychange`,i)}},[]),(0,Z.useEffect)(()=>{if(!(me>0))try{navigator.serviceWorker?.getRegistration?.()?.then(e=>e?.getNotifications({tag:`queue`}).then(e=>e.forEach(e=>e.close())).catch(()=>{})).catch(()=>{})}catch{}},[me]),(0,Z.useEffect)(()=>{let e=e=>ue(kn(e,d.current));D.current=new Set(l.filter(e).map(e=>e.id));let t=s_(l),n=c_(O.current,t);O.current=t;{let e=Ne(ea(l,d.current),j.current,Date.now());k.current=e.busy,j.current=e.watches}let r=!1,i=M.current;for(let t of l){let n=e(t);i.get(t.id)&&!n&&(r=!0),i.set(t.id,n)}let a=new Set(l.map(e=>e.id));for(let e of i.keys())a.has(e)||i.delete(e);(r||n)&&re()},[l,i.backends]);let[_e,ve]=(0,Z.useState)(0);(0,Z.useEffect)(()=>Sa(()=>ve(e=>e+1)),[]),(0,Z.useEffect)(()=>{let e=t.filter(e=>e.status===`queued`||e.status===`pending`).length;ki(e+Ts(te))},[t,_e]),(0,Z.useEffect)(()=>{let e=C.current.map(e=>e.status===`pending`?{...e,status:`queued`,retryAt:void 0,waitReason:void 0}:e),t=new Set(e.filter(Jp).map(e=>e.sessionId)),n=new Set(e.filter(Jp).map(e=>e.ackId)),r=e=>e.pendingCreate&&(e.createAck?!n.has(e.createAck):!t.has(e.sessionId));e=e.map(e=>r(e)?(_i(),{...e,pendingCreate:void 0,status:`failed`,reason:`the session it was queued for is gone`,failedAt:Date.now()}):e),V(P_(e));let i=N_();i&&K(H(i))},[]);let ye=B,be=(...e)=>Object.fromEntries(e.map(e=>[e,ye[e]]));return{...be(`writeOutbox`,`addOutbox`,`addOutboxFirstInLane`,`failOutbox`,`applyDeliverySettled`,`holdWall`),...be(`retainUploadBytes`,`ackWindowFor`,`nextRound`,`armAckTimeout`,`goneLanes`,`flushOutbox`,`idleReason`,`releaseLane`,`uploadRefusal`,`guardUploadRefs`,`guardChain`,`submitInput`,`queueOp`,`queueImageUpload`,`runUpload`,`rewriteQueuedPath`,`armLane`,`queueBacklog`,`answerPrompt`),...be(`enterPending`,`enterOldestPending`,`enterLater`,`retryPendingCreate`,`adoptPendingSession`,`queueSessionPrompt`,`holdForLaunch`,`failPendingCreates`,`failDependentUploads`),...be(`restoreOutbox`,`dismissOutbox`,`editQueued`,`retargetQueued`,`handToDesktop`,`toggleHoldQueued`,`toggleSerialQueued`,`scheduleQueueRows`,`dropScheduleQueue`,`removeQueued`,`addPromptToQueuedCreate`,`moveQueued`,`sendQueuedNow`,`retryFailedQueued`,`restoreQueued`,`repoIdOfEntry`),...fe,entries:t,outboxRef:C,blocked:n,holdQueueRef:ee,flushIdleReason:N,parkedSends:pe,sendSettled:S,budget:m,launches:_,laneLabel:e=>i_(e,l),PENDING_PREFIX:qg,isPendingId:Jg,pendingLaneId:Yg,laneFor:$g,pendingEntry:I,pendingSession:L,uploads:{uploading:R.uploading,parking:R.parking,upProg:R.upProg,current:()=>R.uploadBufRef.current,ensureUploadBuf:ye.ensureUploadBuf,queueUpload:ye.queueUpload,settleUploads:ye.settleUploads,cancelUploads:ye.cancelUploads,parkingRef:R.parkingRef,uploadBufRef:R.uploadBufRef,allBufsRef:R.allBufsRef,uploadPending:R.uploadPending,uploadRowLinger:R.uploadRowLinger}}}var I_=e=>dt(e);function L_(e,t,n){if(n?.v===1)return!1;let r=t?.model;if(!r)return!1;let i=xp(e,t?.backend)?.models.where;return i?i[r]===`hosted`:!1}function R_(){let e=ht(G.hostedAck,null);return e&&typeof e.v==`number`?e:null}function z_(e=Date.now()){let t={at:e,v:1};return mt(G.hostedAck,t),t}function B_(){_t(G.hostedAck)}var Q=Qp();function V_({primary:e,targets:t,onOpen:n,onClose:r}){let[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(``),u=ou(e.id,()=>Dn.gitBranches(e.id)),d=u.data;function f(n){if(e.branch===n)return e.worktreePath;let r=t.find(t=>t.repoName===e.repoName&&t.branch===n);return r?r.worktreePath:null}async function p(t){s(null);let r=f(t);if(r){n(r,`${e.repoName} · ${t}`);return}a(t);let i=await Dn.newWorktree(e.id,t);a(null),i.path?n(i.path,`${e.repoName} · ${i.branch??t}`):s(i.error||`could not create worktree`)}return(0,Q.jsxs)(`div`,{className:`sheet`,children:[(0,Q.jsx)(If,{title:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(og,{size:16}),` `,e.repoName,` · branch`]}),onClose:r}),(0,Q.jsxs)(`div`,{className:`form`,children:[(0,Q.jsx)(`input`,{className:`search`,placeholder:`Filter, or type a new branch name…`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c.trim()&&p(c.trim())}}),c.trim()&&!d?.some(e=>e.name===c.trim())&&(0,Q.jsxs)(`button`,{className:`send`,disabled:!!i,onClick:()=>p(c.trim()),children:[(0,Q.jsx)(Um,{size:16}),` Create & open “`,c.trim(),`”`]})]}),o&&(0,Q.jsx)(`div`,{className:`err`,children:o}),(0,Q.jsxs)(`div`,{className:`list`,children:[(0,Q.jsx)(Zd,{res:u,empty:!d?.length,thing:`branches`,noun:`branch list`,children:`No local branches.`}),d?.filter(e=>e.name.toLowerCase().includes(c.trim().toLowerCase())).map(e=>{let t=!!f(e.name);return(0,Q.jsxs)(Kl,{as:`button`,disabled:i===e.name,onClick:()=>p(e.name),children:[(0,Q.jsx)(`span`,{className:`gstat ${e.current?`g-added`:``}`,children:e.current?`●`:`○`}),(0,Q.jsx)(pd,{className:`mono`,children:e.name}),(0,Q.jsx)(nc,{children:i===e.name?`creating…`:e.current?`primary`:t?`worktree`:`new worktree`})]},e.name)})]})]})}function H_({cur:e,backends:t,modelInput:n,setModelInput:r,submitInput:i,relaunch:a,sessionCan:o,sessionCant:s,onClose:c}){let l=Ba(t,e.backend),u=o(e,`slash`),d=aa(t,e.backend),f=t=>{i(e.id,e.cwd,`/model ${t}`,`command`),c(),K(`/model ${t}`)},p=t=>a(e,t),m=e=>u?f(e):p({model:e}),h=Vr(t,e.backend,u),g=t=>{h?(i(e.id,e.cwd,`/effort ${t}`,`command`),c(),K(`/effort ${t}`)):p({effort:t})};return(0,Q.jsxs)(`div`,{className:`sheet`,children:[(0,Q.jsx)(If,{title:`Switch model`,onClose:c}),(0,Q.jsxs)(Dc,{children:[`Current: `,pa(e.model)||`default`,e.effort?` · ${e.effort}`:``,`.`,` `,u?(0,Q.jsxs)(Q.Fragment,{children:[`Picking a model sends `,(0,Q.jsx)(`span`,{className:`mono`,children:`/model`}),` to this session.`]}):`Picking a model is a launch flag here — it kills and relaunches this session.`]}),(0,Q.jsxs)(`div`,{className:`list`,children:[l.aliases.length>0&&(0,Q.jsx)(`div`,{className:`section`,children:`Aliases`}),l.aliases.map(t=>(0,Q.jsxs)(Kl,{as:`button`,onClick:()=>m(t),children:[(0,Q.jsx)(pd,{className:`mono`,children:t}),e.model===t&&(0,Q.jsx)(df,{tone:`ok`,children:`current`})]},t)),l.ids.length>0&&(0,Q.jsx)(`div`,{className:`section`,children:`Versions`}),l.ids.map(t=>(0,Q.jsxs)(Kl,{as:`button`,onClick:()=>m(t),children:[(0,Q.jsx)(pd,{className:`mono`,children:t}),e.model===t&&(0,Q.jsx)(df,{tone:`ok`,children:`current`})]},t)),(0,Q.jsx)(`div`,{className:`section`,children:`Custom`}),l.freeText&&(0,Q.jsx)(Dc,{children:gu(t,e.backend)}),(0,Q.jsxs)(`div`,{className:`form`,children:[(0,Q.jsx)(`input`,{className:`search mono`,placeholder:l.ids[0]?`e.g. ${l.ids[0]}`:`model id`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n.trim()&&(m(n.trim()),r(``))}}),(0,Q.jsx)(`button`,{className:`send`,onClick:()=>{n.trim()?(m(n.trim()),r(``)):K(`type a model id first`)},children:u?`Send /model`:`Relaunch on it`})]}),u?(0,Q.jsx)(Kl,{as:`button`,onClick:()=>{i(e.id,e.cwd,`/model`,`command`),c()},children:(0,Q.jsx)(pd,{children:`Open the model picker…`})}):(0,Q.jsx)(Cf,{cants:[{label:`the CLI’s own model picker`,reason:s(e,`slash`)}]})]}),d.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Dc,{children:h?(0,Q.jsxs)(Q.Fragment,{children:[`Picking an effort sends `,(0,Q.jsx)(`span`,{className:`mono`,children:`/effort`}),` to this session.`]}):`Effort is a launch flag here — picking it kills + relaunches this session.`}),(0,Q.jsx)(`div`,{className:`form`,children:(0,Q.jsx)(`div`,{className:`annot-tools`,children:d.map(t=>(0,Q.jsx)(Y,{className:e.effort===t?`active`:``,onClick:()=>g(t),children:t},t))})})]}):(0,Q.jsx)(Cf,{cants:[{label:`effort`,reason:s(e,`effort`)??`this session has no effort setting`}]})]})}function U_(e){let{backends:t,launch:n,setOverlay:r}=e;return{branches:()=>e.branchPick?(0,Q.jsx)(V_,{primary:e.branchPick,targets:e.repos,onClose:()=>{r(null),e.setBranchPick(null)},onOpen:(t,n)=>{r(null),e.setBranchPick(null),e.openCwd(t,n)}}):null,new:()=>(0,Q.jsx)(ap,{root:e.root,repos:e.repos,onClose:()=>r(null),onChanged:e.refreshRepos,onOpen:e.openCwd,backends:Rd(t)?[...Us(t)]:void 0,backend:n.backend,onBackend:e.pickBackend,onBuildApp:Cd}),launchask:()=>{if(!e.launchAskFor)return null;let i=e.launchAskFor;return(0,Q.jsx)(Al,{title:i.title,backends:t,defaults:n,budget:i.budget,onRecheck:e.recheckBackends,onStart:(t,n)=>{e.setLaunchAskFor(null),r(null),i.run(t,n)},onClose:()=>{e.setLaunchAskFor(null),r(null),i.onCancel?.()}})},hostedack:()=>{if(!e.hostedAskFor)return null;let n=e.hostedAskFor;return(0,Q.jsx)(zu,{title:n.title,backends:t,launch:n.launch,onAccept:()=>{z_(),e.setHostedAskFor(null),r(null),n.run(n.launch,n.budget)},onClose:()=>{e.setHostedAskFor(null),r(null),n.onCancel?.()}})},model:()=>e.active?(0,Q.jsx)(H_,{cur:e.active,backends:t,modelInput:e.modelInput,setModelInput:e.setModelInput,submitInput:e.submitInput,relaunch:e.relaunch,sessionCan:e.sessionCan,sessionCant:e.sessionCant,onClose:()=>r(null)}):null}}var W_=`This desktop can’t open a shell — it needs an update.`,G_=1200;function K_(e){let{backends:t,setOverlay:n,geomRef:r,setRepos:i,setReposAt:a,setReposFailAt:o}=e,s=xa(`launchAsk`),{queueOp:l,enterPending:u,queueSessionPrompt:d}=e.queue,f=e.repoForCwd,[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(qo),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(``),C=(0,Z.useRef)(t);C.current=t;function w(){Dn.repos().then(e=>{i(e),as(e),a(Date.now()),kf(`repos`)}).catch(()=>{o(Date.now())})}function T(e){v(t=>{let n={...t,...e};return Object.keys(n).forEach(e=>{n[e]||delete n[e]}),mt(G.launch,n),n})}let E=e=>qi(e,C.current);function D(e){let{launch:t,...n}=e,i=t?ar(t,C.current):null;return i&&K(i),{t:`session.create`,...n,cols:r.current.cols,rows:r.current.rows,...t?{launch:E(t)}:null}}function O(t,r,i){let a=cp(C.current,r.launch?.backend);if(a&&!di(s.current,!!r.resume,!!r.override))return K(`Not started — ${a}`),r.onCancel?.(),!0;if(di(s.current,!!r.resume,!!r.override)){let a=c(e.repos,t);return m({title:a,run:(e,t)=>{k(a,e,i,r.onCancel,t)||i(e,t)},onCancel:r.onCancel,budget:r.budget}),n(`launchask`),!0}return!r.resume&&k(c(e.repos,t),r.launch,i,r.onCancel,void 0)}function k(e,t,r,i,a){return!t||!L_(C.current,t,R_())?!1:(q(`overlay:hostedack`),g({title:e,launch:t,run:r,onCancel:i,budget:a}),n(`hostedack`),!0)}let A=(e,n)=>Yt(t,e?hc(e):void 0,n),j=(e,n)=>po(t,e?hc(e):void 0,n),M=e=>{if(e.unadopted)return(0,Z.createElement)(Xc,null,e.unadopted);if(Fi(t,e.launch?.backend)||Mi(e))return null;let n=po(t,e.launch?.backend,`resumePick`);return n?(0,Z.createElement)(Xc,null,n):null},ee=e=>T({backend:e,model:void 0,effort:void 0});function N(t){let n=e.openingCwds().get(t.worktreePath);n&&K(n.status===`pending`?`${n.n>1?`${n.n} already opening`:`one already opening`} in ${t.repoName} — this is another`:`${n.n>1?`${n.n} already queued`:`one already queued`} in ${t.repoName} — this is another`),!O(I_(t),{launch:_},(e,n)=>P(t,e,n??void 0))&&P(t,_)}function P(e,t,n){let r=Bd();l(D({cwd:e.worktreePath,title:dt(e),launch:t,...n?{budget:n}:{}}),`create:${e.worktreePath}`,`open ${dt(e)}`,{cwd:e.worktreePath,focus:!0,ackId:r})&&q(`action:repo.new.offline`),u(r)}function F(e){let t=Yo(C.current);return t?(q(`action:shell.new`),R(e.worktreePath,`shell · ${dt(e)}`,!1,void 0,{backend:t.id})):(K(W_),null)}function I(e){let t=Yo(C.current);return t?(q(`action:shell.companion`),R(e.cwd,`shell · ${e.title}`,!1,void 0,{backend:t.id},void 0,void 0,e.id)):(K(W_),null)}function te(){return Yo(C.current)?null:W_}function L(t,n={}){let r=Yo(C.current);if(!r)return K(W_),null;let i=Yn(),a=n.cwd||e.root,o=p_({remembered:v_.get()[t]??null,sessions:i.world.sessions,cwd:a,isShell:e=>Fi(C.current,e),pendingAlive:e=>i.queue.entries.some(t=>t.ackId===e&&t.status!==`failed`)}),s=null;if(o.do===`attach`){let e=i.world.sessions.find(e=>e.id===o.id);q(`action:shell.focus`),i.nav.attach(e),s=e.id}else o.do===`enter`?(u(o.ack),s=Yg(o.ack)):(q(`action:shell.new`),s=R(a,n.title||`shell · ${Fu(a)}`,!1,void 0,{backend:r.id}));return s?(b_(t,s,n.back),s):null}function R(e,t,n=!1,r,i,a,o,s){if(n&&Fi(C.current,i?.backend)&&(n=!1,r=void 0,a=void 0),O(t,{resume:n,override:!!i,launch:i??_},(i,c)=>{R(e,t,n,r,i,a,c===void 0?o:c??void 0,s)}))return null;q(n?`action:session.resume`:`action:session.new`);let c=Bd();return l(D({cwd:e,title:t,resume:n,resumeMode:r,resumeSessionId:a,launch:i??_,...o?{budget:o}:{},...s?{companionOf:s}:{}}),`create:${e}`,`${n?`resume`:`open`} ${t}`,{cwd:e,focus:!0,ackId:c}),u(c),Yg(c)}async function ne(e){let t=f(e)?.id;if(!t)return null;try{let e=await Promise.race([Dn.gitStatus(t),new Promise(e=>setTimeout(()=>e(null),G_))]),n=e?.files.length??0;return!e||e.clean||n===0?null:`The worktree has ${n} uncommitted change${n===1?``:`s`} — those edits stay exactly as they are, but the reopened session won't remember making them.`}catch{return null}}async function z(e,t){let n=t.sourceId||Mi(e);if(!n){K(`This session's conversation is not identified yet, so it cannot be cut here.`);return}let r={...t,sourceId:n};if(r.mode===`reset`){let t=await ne(e.cwd),n=[`This session reopens holding the conversation up to just before turn #${r.n}. #${r.n} and everything after it are left behind.`,...e.turnActive?[`A turn is running right now — it will be interrupted.`]:[],`Nothing is deleted: the later turns stay on disk under this conversation and stay listed in the archive. Deleting one is a separate act.`,`No file in the repo is touched — only the conversation is rewound.`,...t?[t]:[]];if(!await Lt({title:`Reset to before #${r.n}?`,lines:n,confirmLabel:`Reset`}))return}let i=r.mode===`fork`?`${e.title} (before #${r.n})`:e.title,a={model:e.model,effort:e.effort,permissionMode:e.permissionMode,remoteControlled:e.remoteControlled,backend:e.backend},o=l(D({cwd:e.cwd,title:i,launch:a,resumeMode:`fork`,resumeSessionId:r.sourceId,forkAtTurn:r.turnId,...r.mode===`reset`?{replaceSessionId:e.id}:null}),`create:${e.cwd}`,r.mode===`fork`?`fork ${e.title} before #${r.n}`:`reset ${e.title} to before #${r.n}`,{cwd:e.cwd,focus:!0});K(o?`queued — the link dropped; it runs when it is back`:r.mode===`fork`?`forking before #${r.n} — a new session opens here`:`resetting to before #${r.n}…`)}function B(r,i,a){let o={model:r.model,effort:r.effort,permissionMode:r.permissionMode,remoteControlled:r.remoteControlled,backend:r.backend},s=E({...o,...i}),c=Mi(r),u=a?.prompt?.trim()||void 0,d=u?q_(u):[];l(D({cwd:r.cwd,title:r.title,launch:s,replaceSessionId:r.id,...u?{prompt:u}:{},...d.length?{needs:d}:{},...c?{resumeMode:`continue`,resumeSessionId:c}:{}}),`create:${r.cwd}`,`relaunch ${r.title} · ${pu(s,$a(t,s.backend),t)}`,{cwd:r.cwd,focus:!a?.quiet||e.active?.id===r.id,frontOfLane:d.length>0}),!a?.quiet&&(n(null),K(`relaunch · ${pu(s,$a(t,s.backend),t)}`))}function V(e,t,n,r,i,a,o,s){if(O(t,{override:!!i,launch:i??_,onCancel:o,budget:s},(i,c)=>V(e,t,n,r,i,a,o,c===void 0?s:c??void 0)))return;let c=i??_;q(`action:session.newprompt`);let f=n.map(e=>e.trim()).filter(Boolean),[p,...m]=f,h=q_(p??``),g=Bd(),v=l(D({cwd:e,title:t,prompt:p,launch:c,needs:h.length?h:void 0,...s?{budget:s}:{},...a?{resume:!0,resumeMode:`continue`}:{}}),`create:${e}`,p??`open ${t}`,{cwd:e,focus:!0,frontOfLane:h.length>0,ackId:g,serial:r});for(let t of m)d(e,t,g);u(g);let y=m.length>0;K(v?y?`queued — the session opens and runs ${f.length} prompts when the link is back`:`queued — the session opens and runs this when the link is back`:y?`starting… ${m.length} more queued behind it`:`starting…`)}return{launch:_,setLaunch:v,setLaunchOpt:T,pickBackend:ee,wireLaunch:E,sessionCan:A,sessionCant:j,reopenCant:M,refreshRepos:w,openRepo:N,openShell:F,openCompanionShell:I,focusShell:L,shellCant:te,openCwd:R,runForkRequest:z,startSessionWithPrompt:V,relaunch:B,setBranchPick:b,sheets:U_({backends:t,launch:_,root:e.root,repos:e.repos,active:e.active,launchAskFor:p,setLaunchAskFor:m,hostedAskFor:h,setHostedAskFor:g,branchPick:y,setBranchPick:b,modelInput:x,setModelInput:S,setOverlay:n,submitInput:e.queue.submitInput,refreshRepos:w,openCwd:R,pickBackend:ee,relaunch:B,sessionCan:A,sessionCant:j,recheckBackends:()=>{Yn().conn.send({t:`backends.recheck`})}})}}function q_(e){let t=new Set;for(let n of e.matchAll(/\.claude\/inbox\/[A-Za-z0-9._-]+/g))t.add(n[0]);return[...t]}var J_=e=>e.preventDefault();function Y_(e){let{q:t,status:n,reconnectAsk:r,setReconnectAsk:i,autoSend:a,confirmQueue:o,pullRecords:s,setOverlay:c,stripSessionId:l}=e,{entries:u,parkedSends:d,sendSettled:f,holdQueueRef:p,flushIdleReason:m,flushOutbox:h,idleReason:g,restoreOutbox:_,dismissOutbox:v,laneLabel:y}=t,b=Date.now(),x=u.filter(e=>fa(e,b)===`confirming`),S=u.filter(e=>$l(fa(e,b))),C=e=>fa(e,b)===`retrying`,w=u.filter(e=>e.status===`queued`&&!C(e)),T=l&&n===`open`&&!p.current&&w.length>0&&w.every(e=>e.sessionId===l)?[]:w,E=u.filter(e=>e.status===`pending`||C(e)),D=E.length>0,O=r&&d.length>0,k=(0,Q.jsx)(Ca,{records:s,onRemove:e=>{q(`action:pull.strip.remove`);for(let t of e)vo.remove(t.item.id);let t=e.filter(e=>!e.local).map(e=>({t:`pull.dismiss`,id:e.item.id})),n=`removed ${e.length===1?e[0].item.name:`${e.length} stopped downloads`}`;t.length?Yn().conn.liveSendAll(t,n,`${n} here — the desktop's queue still lists ${t.length===1?`it`:`them`} until the link is back`):K(n)},onOpen:()=>{q(`overlay:pull`),c(`pull`)}}),A=Ho(s,ur()).length>0,j=S.length?{rows:S,label:`not delivered`,icon:vh}:x.length?{rows:x,label:`being confirmed`,icon:bm}:T.length?{rows:T,label:`queued`,icon:n===`open`?p.current?Cm:bm:Ym}:{rows:E,label:`sending`,icon:yg};return!O&&!S.length&&!x.length&&!T.length&&!D&&!A&&!f?null:(0,Q.jsxs)(Q.Fragment,{children:[k,(0,Q.jsx)(Mt,{records:s}),r&&d.length>0&&(0,Q.jsx)(_d,{slot:`queue-ask`,stowKey:Kg(d),label:`send what you queued?`,detail:String(d.length),icon:bg,children:(0,Q.jsxs)(`div`,{className:`outbox-recover ask`,children:[(0,Q.jsx)(bg,{size:14}),(0,Q.jsxs)(`span`,{children:[`Back online — send `,d.length,` message`,d.length>1?`s`:``,` you queued while offline?`]}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:()=>{q(`action:queue.confirm.send`);let e=h(!0);i(!1),K(e?`sending queued messages…`:g(`nothing left to send`))},children:[(0,Q.jsx)(sg,{size:14}),` Send`]}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:()=>{q(`action:queue.confirm.review`),c(`queue`)},children:[(0,Q.jsx)(lm,{size:14}),` Review`]}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:()=>{q(`action:queue.confirm.hold`),i(!1)},title:`keep them queued — nothing is sent until you release it`,children:[(0,Q.jsx)(Lh,{size:14}),` Hold`]}),(0,Q.jsx)(Df,{})]})}),S.length===0&&x.length===0&&w.length===0&&!D&&f&&(0,Q.jsxs)(`div`,{className:`outbox-recover sending`,children:[(0,Q.jsx)(rh,{size:14}),(0,Q.jsx)(`span`,{children:`sent`})]}),(S.length>0||x.length>0||T.length>0||D)&&(0,Q.jsx)(_d,{slot:`queue`,stowKey:Kg(j.rows,S.length>0),label:j.label,detail:String(j.rows.length),icon:j.icon,children:(0,Q.jsx)(`div`,{className:`outbox-recover ${S.length?`failed`:x.length?`confirming`:T.length?`queued`:`sending`}`,children:S.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vh,{size:14}),(0,Q.jsxs)(`span`,{children:[S.length,` message`,S.length>1?`s`:``,` not delivered`,S.length===1&&S[0].reason?` — ${S[0].reason}`:``]}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:_,children:[(0,Q.jsx)(Xh,{size:14}),` Restore`]}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:()=>{q(`action:queue.manage`),ha(S,`the messages that were not delivered`)},children:[(0,Q.jsx)(lm,{size:14}),` Manage`]}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:v,children:[(0,Q.jsx)(Lh,{size:14}),` Dismiss`]}),(0,Q.jsx)(Df,{}),S.length>1?(0,Q.jsxs)(`div`,{className:`outbox-which`,children:[S.slice(0,3).map(e=>(0,Q.jsxs)(`button`,{className:`outbox-which-row`,onPointerDown:J_,title:`open this one in ${ec.activity}`,onClick:()=>{q(`action:queue.which`),ha([e],`the message you tapped`)},children:[(0,Q.jsx)(`span`,{className:`outbox-which-where`,children:y(e)}),(0,Q.jsx)(`span`,{className:`outbox-which-text`,children:o_(e)})]},e.ackId)),S.length>3?(0,Q.jsxs)(`button`,{className:`outbox-which-row more`,onPointerDown:J_,onClick:()=>{q(`action:queue.which.more`),ha(S,`the messages that were not delivered`)},children:[S.length-3,` more — open the list`]}):null]}):null]}):x.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bm,{size:14}),(0,Q.jsx)(`span`,{children:er(x.length)}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:()=>{q(`action:queue.confirming`),ha(x,`the messages the desktop is still confirming`)},children:[(0,Q.jsx)(lm,{size:14}),` Which`]}),(0,Q.jsx)(Df,{})]}):T.length>0?(0,Q.jsxs)(Q.Fragment,{children:[n===`open`?p.current?(0,Q.jsx)(Cm,{size:14}):(0,Q.jsx)(bm,{size:14}):(0,Q.jsx)(Ym,{size:14}),(0,Q.jsxs)(`span`,{children:[T.length,` queued`,p.current?` — held until you send them`:n===`open`?D?` — going out one per session`:m.current?` — ${m.current}`:` — going out one per session`:` — will send when the connection is back`]}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:()=>{q(`action:outbox.retry`),h(!0)||K(g(`nothing left to send`))},children:[(0,Q.jsx)(Xh,{size:14}),` Send now`]}),(n!==`open`||p.current||!(a&&!o))&&(0,Q.jsxs)(Y,{className:a&&!o?`active`:``,onPointerDown:J_,title:a&&!o?`queued messages go out by themselves as soon as the connection is back — tap to hold them instead`:`send everything queued the moment the connection is back, without asking`,onClick:()=>{let e=!(a&&!o);q(`action:outbox.auto`),J(`autoSend`,e),J(`confirmQueue`,!e),e&&(p.current=!1,i(!1),h()),K(e?`auto-send on — the queue goes out as soon as the link is back`:`auto-send off — the queue waits for “Send now”`)},children:[(0,Q.jsx)(ig,{size:14}),` auto `,a&&!o?`on`:`off`]}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:()=>{q(`action:queue.manage`),ha(T,`the messages still waiting to go out`)},children:[(0,Q.jsx)(lm,{size:14}),` Manage`]}),(0,Q.jsx)(Df,{})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yg,{size:14,className:`spin`}),(0,Q.jsx)(`span`,{children:a_(E)}),(0,Q.jsxs)(Y,{onPointerDown:J_,onClick:()=>{q(`action:queue.manage`),ha(E,`the messages going out now`)},children:[(0,Q.jsx)(lm,{size:14}),` Manage`]}),(0,Q.jsx)(Df,{})]})})})]})}function X_(e,t){if(!e||e.kind===`after`)return null;if(e.kind===`at`){if(e.rule.kind===`once`&&!(typeof e.rule.at==`number`&&e.rule.at>t))return null;let{name:n,...r}=e;return r}return e}function Z_(e){return e===`now`||e===`idle`?e:null}function Q_(e){return e===`this`||e===`new`?e:null}function $_(e,t,n,r,i=40){if(!t)return e;let a={...e[t],at:r};if(n.mode!==void 0){let e=Z_(n.mode);e?a.mode=e:delete a.mode}if(n.when!==void 0){let e=X_(n.when,r);e?a.when=e:delete a.when}if(n.where!==void 0){let e=Q_(n.where);e?a.where=e:delete a.where}let o={...e,[t]:a},s=Object.keys(o);if(s.length<=i)return o;s.sort((e,t)=>(o[e].at??0)-(o[t].at??0));for(let e of s.slice(0,s.length-i))delete o[e];return o}function ev(e,t){return t?Z_(e[t]?.mode)??`now`:`now`}function tv(e,t){return t?Q_(e[t]?.where)??`this`:`this`}function nv(e,t,n){return t?X_(e[t]?.when,n):null}function rv(e){return`When is set the way you last sent to ${e} — open When to change it`}function iv(e){let{connRef:t,liveSend:n,liveSendAll:r,queue:i,sessions:o,getVisibleRepos:s,intents:c,usage:l,launch:u,wireLaunch:d,geomRef:p,repoForCwd:m,startSessionWithPrompt:h,setOverlay:_,attach:v}=e,{pendingSession:y,budget:x}=i,{guardChain:S,guardUploadRefs:C,queueOp:w,submitInput:T,queueBacklog:E,writeOutbox:D,outboxRef:k,addOutbox:A,flushOutbox:j,queueImageUpload:M}=i,ee=i.entries,N=cu(),[P,I]=(0,Z.useState)(null),te=(0,Z.useRef)(null);te.current=P;let ne=(0,Z.useRef)(null),z=(0,Z.useRef)(ht(G.sendMemory,{}));function B(e,t){let n=$_(z.current,e,t,Date.now());n!==z.current&&(z.current=n,mt(G.sendMemory,n))}function V(e,t){let n=t.kind===`at`?{kind:`at`,rule:t.rule,graceMin:t.graceMin}:t.kind===`after`?{kind:`after`,id:t.id,onlyIfOk:t.onlyIfOk,title:t.title}:{kind:t.kind},i=t.kind===`at`?F(t.rule):t.kind===`now`?ba:a(t,Wl(t,l??void 0)),o=[...new Set(e.flatMap(e=>{let t=c.find(t=>t.id===e)?.cwd,n=t?m(t):null,r=n?f(n):t?Fu(t):``;return r?[r]:[]}))],s=x?.verdict.blocked&&kt(e,c).length>0?x.verdict.resumeAt?it(x.verdict.resumeAt):`it clears`:null,u=t.kind===`at`?so(e.length,i):rp(e.length,i,o,s),d=t.kind===`at`?c.find(t=>t.id===e[0])?.cwd:void 0;return d&&Rs(e[0],d),r(e.map(e=>({t:`intent.update`,id:e,patch:{trigger:n,...t.kind===`at`?{holdForHost:!!t.waitUntilFree}:{}}})),u,Hn)}let H=(e,n)=>{let i=c.find(t=>t.id===e[0]),a=i?.trigger.kind===`at`?{kind:`at`,rule:i.trigger.rule,graceMin:i.trigger.graceMin,...i.holdForHost?{waitUntilFree:!0}:{}}:Pf(36e5),u=!1;return(0,Q.jsx)(Lc,{seed:{retime:{ids:e},when:a,draftKey:`send.retime`},sessions:o,repos:s(),outbox:ee,online:t.current.status===`open`,usage:l,intents:c,buildName:N,onAttach:async()=>[],onAnnotate:()=>{},onSend:t=>(u=V(e,t.when),u),onClose:()=>u?n.onSent():n.onCancel(),budgetHeld:x?.verdict.blocked?{note:b(x.verdict),resumeAt:x.verdict.resumeAt,ids:kt(e,c)}:null,onPastBudget:e=>{r(e.map(e=>({t:`intent.waive`,id:e,rung:`budget`,on:!0})),$u(e.length),`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`)&&n.onSent()}})};function re(e,t){let n=e?o.find(t=>t.id===e&&t.running):void 0;return n?{kind:`session`,sessionId:n.id,cwd:n.cwd}:t?{kind:`repo`,cwd:t}:void 0}function ie(e){let t=e.target.kind===`repos`,n=e.payload.kind===`prompt`?e.payload.steps:[],r=n[0]??``;return{prompts:n.length?[...n]:[r],target:t&&e.target.kind===`repos`?{kind:`repos`,dirs:e.target.dirs,...e.budget?{budget:e.budget}:{},...e.launch?{launch:e.launch}:{},...e.flagWhenDone?{flagWhenDone:!0}:{}}:{kind:`repo`,cwd:e.cwd,...typeof e.closeWhenDone==`boolean`?{closeWhenDone:e.closeWhenDone}:{},...e.flagWhenDone?{flagWhenDone:!0}:{},...e.budget?{budget:e.budget}:{},...e.launch?{launch:e.launch}:{}},when:e.trigger.kind===`at`?{kind:`at`,rule:e.trigger.rule,graceMin:e.trigger.graceMin??120,name:e.label||R(e.title,r)||void 0,waitUntilFree:e.serial===!0&&e.holdForHost===!0||void 0}:void 0,cwdHint:e.cwd||null,scheduleId:e.id,origin:`Editing a schedule`}}function U(e){let t=e.action;return{prompts:t.kind===`backlog`&&t.steps?.length?[...t.steps]:[O(t)],target:t.kind===`fanout`?{kind:`repos`,dirs:t.dirs,...t.budget?{budget:t.budget}:{},...t.launch?{launch:t.launch}:{}}:{kind:`repo`,cwd:t.repoDir,...t.kind===`backlog`&&typeof t.closeWhenDone==`boolean`?{closeWhenDone:t.closeWhenDone}:{},...t.kind===`backlog`&&t.flagWhenDone?{flagWhenDone:!0}:{},...t.kind===`backlog`&&t.budget?{budget:t.budget}:{},...t.kind===`backlog`&&t.launch?{launch:t.launch}:{}},when:{kind:`at`,rule:e.rule,graceMin:e.graceMin??120,name:R(e.name,O(t))||void 0,waitUntilFree:e.waitUntilFree},cwdHint:t.kind===`fanout`?t.dirs[0]??null:t.repoDir,scheduleId:e.id,origin:`Editing a schedule`}}function ae(e){let t=(y?[...o,y]:o).find(t=>t.id===e);t&&v(t)}function oe(e){let t=Gc(Rc,(e.prompts?.length?e.prompts:[``]).join(`\f`),e.cwdHint);t===`kept`?K(L):t===`refused`&&K(g),ne.current=null,I(sl(e,t)),_(`send`)}function W(e,r){let i=e.prompts.map(e=>e.trim()).filter(Boolean),a=i[0]??``,o=a.slice(0,40),s=e=>e.trimStart().startsWith(`/`)?`command`:`prompt`;if(e.target.kind!==`shell`&&!S(i))return!1;let g=r.scheduleId?c.find(e=>e.id===r.scheduleId)??null:null,_=Tc(e,g);if(_.kind===`refuse`)return K(_.why),!1;if(_.kind===`patch`&&g){let t=e.target.kind===`repo`||e.target.kind===`repos`?e.target.budget:void 0;if(JSON.stringify(t??null)!==JSON.stringify(g.budget??null))return K(`a budget can't be changed on a row that is already waiting — remove the budget change, or post this as a new row`),!1;let r={payload:{kind:`prompt`,steps:i},trigger:e.when.kind===`after`?{kind:`after`,id:e.when.id,onlyIfOk:e.when.onlyIfOk,title:e.when.title}:e.when.kind===`at`?{kind:`at`,rule:e.when.rule,graceMin:e.when.graceMin}:{kind:e.when.kind===`idle`?`idle`:`now`},target:e.target.kind===`session`?{kind:`session`,sessionId:e.target.sessionId}:{kind:`repo`},cwd:e.target.kind===`session`||e.target.kind===`repo`?e.target.cwd:void 0,resume:e.target.kind===`repo`?!!e.target.resume:void 0,closeWhenDone:e.target.kind===`repo`?e.target.closeWhenDone??null:void 0,flagWhenDone:e.target.kind===`repo`?Du(e.target,e.when)??null:void 0,launch:e.target.kind===`repo`?e.target.launch?d(e.target.launch):null:void 0,holdForHost:e.when.kind===`at`?!!e.when.waitUntilFree:void 0,label:o};return q(`action:send.retime`),n({t:`intent.update`,id:g.id,patch:r},lf(e.when),`no connection — this row's clock lives on the desktop and nothing here changed. Its words are still in the box.`)?(e.when.kind===`at`&&g.cwd&&Rs(g.id,g.cwd),!0):!1}if(e.when.kind===`at`&&e.target.kind===`session`){let t=e.when,n=e.target,s={id:r.scheduleId??`i_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,cwd:n.cwd,payload:{kind:`prompt`,steps:i},target:{kind:`session`,sessionId:n.sessionId},trigger:{kind:`at`,rule:t.rule,graceMin:t.graceMin},holdForHost:t.waitUntilFree||void 0,auto:!0,pinned:!0,label:o};if(q(`action:send.clockSession`),!C(i.join(`
|
|
6
|
-
`),n.sessionId))return!1;let c=w({t:`intent.post`,intent:s},n.sessionId,a,{cwd:n.cwd});Rs(s.id,n.cwd);let u=i.length>1?` · ${i.length} turns`:``,d=Wl(e.when,l??void 0),f=d==null?`when its window opens`:it(d);return K(c?`Queued offline${u} — it reaches the desktop when the link is back, then waits for ${f}`:`Queued${u} for ${f} — it goes to that session, or to its conversation reopened if the session has gone`),!0}if(e.when.kind===`at`){let t=g?.budget&&(e.target.kind!==`repo`&&e.target.kind!==`repos`||!e.target.budget)?{budget:null}:{},n=e.target.kind===`repos`?{kind:`fanout`,dirs:e.target.dirs,text:a,...e.target.kind===`repos`&&e.target.budget?{budget:e.target.budget}:t,...e.target.launch?{launch:d(e.target.launch)}:{}}:{kind:`backlog`,repoDir:e.target.cwd,text:a,autoFire:!0,...i.length>1?{steps:i}:{},...e.target.kind===`repo`&&typeof e.target.closeWhenDone==`boolean`?{closeWhenDone:e.target.closeWhenDone}:{},...Du(e.target,e.when)?{flagWhenDone:!0}:{},...e.target.kind===`repo`&&e.target.budget?{budget:e.target.budget}:t,...e.target.kind===`repo`&&e.target.launch?{launch:d(e.target.launch)}:{}},o={id:r.scheduleId??`s_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,name:(e.when.name??``).trim()||a.split(`
|
|
7
|
-
`)[0].slice(0,60),enabled:!0,rule:e.when.rule,action:n,createdAt:Date.now(),nextAt:Wl(e.when,l??void 0),graceMin:e.when.graceMin,waitUntilFree:e.when.waitUntilFree};q(`action:schedule.save`);let s=w({t:`schedule.save`,entry:o},`sched:${o.id}`,o.name),c=i.length>1?` · ${i.length} turns`:``,u=e.target.kind===`repo`&&!He(e.when.rule),p=m(e.target.kind===`repo`?e.target.cwd:``),h=u?` in ${p?f(p):`that repo`}`:``;return u&&e.target.kind===`repo`&&Rs(o.id,e.target.cwd),e.target.kind===`repos`&&i.length>1?K(`scheduled the first step — a sweep is ONE prompt, so the other ${i.length-1} were dropped`):K(u?s?`queued${c} — it is saved to the backlog when the link is back`:`queued${h}${c} for ${o.nextAt==null?`when its window opens`:it(o.nextAt)} — it is in the backlog`:s?`queued${c} — the schedule is saved when the link is back`:`schedule saved${c}`),!0}if(e.when.kind===`after`){let t=e.when;if(e.target.kind===`repos`&&i.length>1)return K(`a sweep is ONE prompt — the other ${i.length-1} step${i.length===2?``:`s`} would be dropped, so nothing was sent`),!1;let n=e.target.kind===`repos`?e.target.dirs[0]??``:e.target.cwd,r=e.target.kind===`session`?{kind:`session`,sessionId:e.target.sessionId}:e.target.kind===`repos`?{kind:`repos`,dirs:e.target.dirs}:{kind:`repo`},s={id:`i_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,cwd:n,payload:{kind:`prompt`,steps:i},target:r,trigger:{kind:`after`,id:t.id,onlyIfOk:t.onlyIfOk,title:t.title},serial:e.target.kind!==`session`||void 0,auto:!0,pinned:e.target.kind===`session`||void 0,resume:e.target.kind===`repo`?e.target.resume:void 0,closeWhenDone:e.target.kind===`repo`?e.target.closeWhenDone:void 0,flagWhenDone:Du(e.target,e.when),budget:e.target.kind===`repo`||e.target.kind===`repos`?e.target.budget:void 0,...(e.target.kind===`repos`||e.target.kind===`repo`)&&e.target.launch?{launch:d(e.target.launch)}:{},label:o};q(`action:send.after`);let c=e.target.kind===`session`?e.target.sessionId:n;if(!C(i.join(`
|
|
8
|
-
`),c))return!1;let l=w({t:`intent.post`,intent:s},c,a,{cwd:n}),u=i.length>1?` · ${i.length} turns`:``,f=t.title?`“${t.title}”`:`the item before it`;return K(l?`Queued offline${u} — it reaches the desktop when the link is back, then waits for ${f}`:`Queued${u} — it goes in after ${f} finishes`),!0}let v=e.when.kind===`idle`;switch(e.target.kind){case`session`:{let n=e.target.sessionId,r=e.target.cwd,a=0,o=!1;for(let[e,t]of i.entries()){if(e===0&&!v){if(!T(n,r,t,s(t)))return!1;a++;continue}let i=E({text:t,repoDir:r,label:t.slice(0,40),targetSessionId:n,autoFire:!0});if(i===null)return K(`part of that chain could not be queued — its words are still in the box`),!1;o||=i,a++}if(!a)return!1;let c=i.length>1?` · ${i.length-1} more behind it`:``;return K(o||t.current.status!==`open`?`queued — it reaches the desktop when the link is back${c}`:v?`queued on the desktop — it goes in when this session is free${c}`:`sent${c}`),!0}case`repo`:{let t=e.target.cwd;if(!v){let n=m(t),a=e.target.launch??(e.launchChosen?u:void 0);return h(t,n?dt(n):Fu(t),i,e.sequential,a,e.target.resume,()=>{oe({prompts:i,target:e.target,cwdHint:t,repoId:r.repoId,origin:r.origin}),K(`nothing was started — your words are back in the send sheet`)},e.target.budget),!0}let n=E({text:a,steps:i,repoDir:t,label:o,autoFire:!0,resume:e.target.resume,closeWhenDone:e.target.closeWhenDone,budget:e.target.budget,flagWhenDone:Du(e.target,e.when),...e.target.launch?{launch:d(e.target.launch)}:{}});if(n===null)return!1;let s=i.length>1?` · ${i.length} turns`:``;return K(n?`Queued offline${s} · it reaches the desktop when the link is back`:`Queued${s} · a new session when this repo is free`),!0}case`repos`:{if(!e.sequential){let t=w({t:`fanout.run`,dirs:e.target.dirs,text:a,launch:d(e.target.launch??u),...e.target.budget?{budget:e.target.budget}:{},...Du(e.target,e.when)?{flagWhenDone:!0}:{},cols:p.current.cols,rows:p.current.rows},`fanout`,a);return i.length>1?K(`a sweep is ONE prompt — the other ${i.length-1} steps were dropped`):K(t?`queued — the sweep runs when the link is back`:`fanning out to ${e.target.dirs.length} repo${e.target.dirs.length===1?``:`s`}`),!0}let t=0,n=!1;for(let r of e.target.dirs){let s=E({text:a,steps:i,repoDir:r,label:o,autoFire:!0,budget:e.target.budget,flagWhenDone:Du(e.target,e.when),...e.target.launch?{launch:d(e.target.launch)}:{}});if(s===null)return K(`part of that sweep could not be queued — its words are still in the box`),!1;n||=s,t++}if(!t)return!1;let r=i.length>1?` · ${i.length} turns each`:``;return K(n?`Queued offline · ${t} repo${t===1?``:`s`}${r} when the link is back`:`Queued for ${t} repo${t===1?``:`s`}${r} — one at a time in each`),!0}case`shell`:{let t=Tn(e.target.cwd,e.target.buildId),n=w({t:`build.run`,repoDir:e.target.cwd,buildId:e.target.buildId},Vt(e.target.cwd),Xl(t),{cwd:e.target.cwd});return K(Di(n,t)),!0}}}function se(e){e.ackId&&D(k.current.filter(t=>t.ackId!==e.ackId)),e.padId&&Ms([e.padId])}async function ce(e,n,r){q(`action:resend.reattach`);let i=await Io(e);if(!i){K(`those bytes are no longer on this phone`);return}let a=Bd(),o=e.split(`/`).pop()||`file`;await dr(`uploads`,a,i),await yo(`uploads`,a)?(A({ackId:a,sessionId:r,cwd:r,text:`file · ${o}`,ts:Date.now(),status:`queued`,attempts:0,mode:`upload`,upload:{repoId:n,name:o,relPath:e,size:i.size,type:i.type||`application/octet-stream`},armed:!0}),sr(e),await Gp(e),j(),K(t.current.status===`open`?`re-attached — uploading`:`re-attached — uploads when the link is back`)):K(`couldn't park the file on this device`)}let le=(0,Z.useRef)(null),ue=(0,Z.useRef)(null);function de(e,t,n){return q(`action:resend.replace`),ue.current?.(null),new Promise(e=>{ue.current=async t=>{ue.current=null,e(t)};let r=le.current;r?(r.value=``,r.dataset.repoId=t,r.dataset.cwd=n,r.click()):(ue.current=null,e(null))})}async function fe(e){let t=e.target,n=t.files?.[0]??null,r=t.dataset.repoId??``,i=t.dataset.cwd??``,a=ue.current;if(!n||!r||!a)a?.(null);else try{let{width:e}=Nd(),t=await ns(n,n.name,e),o=await M(r,t.blob,t.name,i,i);a(o?.relPath??null),K(o?`attached — it uploads before the message`:`couldn't park that file`)}catch{a(null),K(`couldn't read that file`)}}return{sendSeed:P,setSendSeed:I,sendSeedRef:te,sendResumeRef:ne,sendMemRef:z,noteSendAim:B,openSend:oe,openSent:ae,dispatchIntent:W,retireSendSource:se,seedFromIntent:ie,seedFromSchedule:U,sendTargetFor:re,retimeMany:V,renderRetime:H,reattachKept:ce,pickReplacement:de,onPickReplacement:fe,replacePick:le,buildNames:N}}var av=` `;function ov(e){return e.replace(/\r?\n/g,`\r`)}function sv(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length-n;return``.repeat(r)+ov(t.slice(n))}var cv={Enter:`\r`,Tab:` `,Escape:`\x1B`,ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Home:`\x1B[H`,End:`\x1B[F`,PageUp:`\x1B[5~`,PageDown:`\x1B[6~`,Delete:`\x1B[3~`};function lv(e){if(e.metaKey)return null;if(e.ctrlKey&&!e.altKey&&/^[a-zA-Z]$/.test(e.key))return String.fromCharCode(e.key.toUpperCase().charCodeAt(0)-64);let t=cv[e.key];return t?e.key===`Enter`&&e.altKey?`\x1B\r`:t:null}var uv={ctrl:`off`,alt:`off`,shift:`off`},dv=e=>({ctrl:e.ctrl!==`off`,alt:e.alt!==`off`,shift:e.shift!==`off`});function fv(e){return e===`off`?`once`:e===`once`?`lock`:`off`}function pv(e){return{ctrl:e.ctrl===`lock`?`lock`:`off`,alt:e.alt===`lock`?`lock`:`off`,shift:e.shift===`lock`?`lock`:`off`}}function mv(e){return e===``?`backspace`:e===`\r`?`enter`:e===` `?`tab`:e===` `?`space`:e}var hv={Enter:`enter`,Tab:`tab`,Escape:`esc`,ArrowUp:`up`,ArrowDown:`down`,ArrowLeft:`left`,ArrowRight:`right`,Home:`home`,End:`end`,PageUp:`pgup`,PageDown:`pgdn`,Delete:`delete`,Backspace:`backspace`};function gv(e){let[t,n]=(0,Z.useState)(uv),r=(0,Z.useRef)(uv),i=e=>{r.current=e,n(e)};function a(t,n){let a=dv(r.current);if(!M(a)){e(n);return}let o=ce(a,t);`refused`in o?K(`${o.refused}. Nothing was sent.`):(q(`action:chord.send`),e(o.bytes)),i(pv(r.current))}let o=ct(dv(t),``).replace(/\+$/,``);return{mods:t,armed:M(dv(t)),heldName:o,tapMod(e){i({...r.current,[e]:fv(r.current[e])})},clear(){i(uv)},sendKey:a,sendTyped(t){if(!t)return;if(!M(dv(r.current))){e(t);return}let n=Array.from(t),i=0;for(;i<n.length&&M(dv(r.current));)a(mv(n[i]),n[i]),i++;i<n.length&&e(n.slice(i).join(``))}}}var _v=/(?:^|[\s[(])(?:password|passphrase|passcode|pin)\b(?:'[^']*'|"[^"]*"|[^:'"\n]){0,160}:$/i;function vv(e){let t=e.replace(/\s+$/,``);return!t||t.length>200||!_v.test(t)?null:t.trim()}var yv=200,bv=new Set;function xv(){let[e,t]=(0,Z.useState)(``),n=(0,Z.useRef)(``);n.current=e;let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(Fo),[o,s]=(0,Z.useState)(-1),c=(0,Z.useRef)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1);function h(){let e=r.current;if(!e)return;e.style.height=`auto`;let t=e.offsetHeight-e.clientHeight;e.style.height=`${Math.min(e.scrollHeight+t,yv)}px`}(0,Z.useLayoutEffect)(h,[e]);function g(e){let t=e.trim();t&&(a(e=>{let n=[...e.filter(e=>e!==t),t].slice(-50);return mt(G.cmdHistory,n),n}),s(-1),u(!1))}function _(e){t(t=>t?`${t}${t.endsWith(` `)?``:` `}${e}`:e)}return{compose:e,setCompose:t,composeNow:n,composeRef:r,cmdHistory:i,histIdx:o,setHistIdx:s,histStash:c,clearArmed:l,setClearArmed:u,composeFocused:d,setComposeFocused:f,snippetOpen:p,setSnippetOpen:m,pushHistory:g,insertCompose:_,growCompose:h}}function Sv(e,t){let{compose:n,setCompose:r,composeNow:i,composeRef:a,cmdHistory:o,histIdx:s,setHistIdx:c,histStash:l,clearArmed:u,setClearArmed:d,setSnippetOpen:f,pushHistory:p}=e,{active:m,pending:h,activeId:g,sessions:_,readerShown:v,enterSends:S,cliModeOn:C,setCliModeOn:w,repoForCwd:T}=t,{connRef:E,send:D}=t.conn,O=Ip(g),{submitInput:A,queueBacklog:j}=t.queue,{parkingRef:M}=t.queue.uploads,{dispatchIntent:ee,openSend:N,noteSendAim:P,sendMemRef:F}=t.sender,I=xa(`closeKbOnSend`),te=xa(`btwToCli`),L=xa(`busySend`);function R(){let e=()=>{t.showCli(),K(`switched to the CLI for the /btw answer — the book button above brings the reader back`)};te.current===`switch`?e():te.current!==`stay`&&Wc({title:`Switch to the CLI to read the answer?`,lines:[`The CLI answers /btw in an overlay of its own and keeps no record of it, so the reader cannot show it.`,`It stays readable in the CLI until the overlay is closed (Esc).`],confirmLabel:`switch`,cancelLabel:`stay`,tone:`info`,rememberLabel:`don't ask again`}).then(({ok:t,remember:n})=>{n&&(J(`btwToCli`,t?`switch`:`stay`),t||K(`won't ask again — Settings › Writing & reading › /btw from the reader changes it`)),t&&(q(`action:compose.btwToCli`),e())})}let[ne,H]=(0,Z.useState)(`now`),[re,ie]=(0,Z.useState)(`this`),[U,ae]=(0,Z.useState)(null),[oe,W]=(0,Z.useState)(!1),se=(0,Z.useRef)(av),ce=(0,Z.useRef)(null),le=gv(Ne),ue=(C||le.armed)&&!h&&!v,de=(0,Z.useRef)(!1);function fe(e){!le.armed&&!C?(de.current=document.activeElement===a.current,se.current=av,le.tapMod(e),Le()):le.tapMod(e)}let me=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{le.armed?(me.current=!0,se.current=av):me.current&&(me.current=!1,!C&&!de.current&&a.current?.blur())},[le.armed]),(0,Z.useEffect)(()=>{le.clear()},[g,h,v]);let he=Zg(g);(0,Z.useEffect)(()=>{let e=ce.current;e&&e===g&&Aa(e,n)},[n,g]),(0,Z.useEffect)(()=>{g?(ce.current=g,r(jr(g)),W(!1)):ce.current=null},[g]),(0,Z.useEffect)(()=>{he?(H(`idle`),ie(`new`),ae(null)):(H(ev(F.current,m?.cwd)),ie(tv(F.current,m?.cwd)),ae(null))},[m?.cwd,he]);let ge=rr({read:()=>i.current,write:e=>r(e),key:()=>O.current??``});function _e(t,n,r={}){let i=C;C&&(w(!1),se.current=av),le.clear();let a=O.current===t,o=a?e.composeNow.current:jr(t)??``,s=n.trim()!==``&&o.includes(n.trim()),c=o.trim()!==``;if(s)return{leftCli:i,already:s,joined:c};if(r.ownLine){let r=c?`${o.replace(/\s+$/,``)}\n${n}`:n;a?e.setCompose(r):Aa(t,r)}else a?e.insertCompose(n):Aa(t,o?`${o}${o.endsWith(` `)?``:` `}${n}`:n);return{leftCli:i,already:s,joined:c}}function ve(t,n){return e.composeNow.current===t&&(e.composeNow.current=n,e.setCompose(n),!0)}let[ye,be]=(0,Z.useState)(null),[xe,Se]=(0,Z.useState)(null),[Ce,we]=(0,Z.useState)(``),[Te,Ee]=(0,Z.useState)(!1);function De(e){let t=vv(e);be(t),t||(we(``),Ee(!1),Se(null))}(0,Z.useEffect)(()=>{be(null),we(``),Ee(!1),Se(null)},[g]);let Oe=ye&&ye!==xe&&!h&&!ue&&Fi(null,m?.backend)?ye:null;function ke(){ye&&Se(ye),we(``),Ee(!1)}let Ae=Ip(Oe);function je(){let e=O.current,t=Ae.current;return!e||!t?null:{sessionId:e,askLine:t,fill(n){return!n||O.current!==e||Ae.current!==t?!1:(we(n),Ee(!1),!0)}}}function Me(){m&&(Ce?E.current.status===`open`?(q(`action:compose.secret.send`),Ne(`${Ce}\r`),we(``),Ee(!1)):K(`link is down — a password is never queued; send it once the link is back`):K(`type the password first — Send types it into the prompt`))}function Ne(e){m&&(h?K(`no terminal yet — keys reach the CLI once the session opens`):D({t:`session.input`,id:m.id,data:e}))}function Pe(e){if(o.length===0)return;if(d(!1),s===-1){if(e>0)return;l.current=n;let t=o.length-1;c(t),r(o[t]);return}let t=s+e;t<0?(c(0),r(o[0])):t>=o.length?(c(-1),r(l.current)):(c(t),r(o[t]))}function Fe(){u?(r(``),c(-1),l.current=``,d(!1)):(d(!0),K(`Tap clear again to wipe the message box`))}function Ie(e){r(t=>(t&&!/\s$/.test(t)?t+`
|
|
9
|
-
`:t)+e.text),c(-1),d(!1),f(!1),a.current?.focus()}function Le(){let e=a.current;if(e){e.focus();try{e.setSelectionRange(e.value.length,e.value.length)}catch{}}}function Re(){let e=!C;q(e?`action:cli.on`:`action:cli.off`),le.clear(),w(e),se.current=av,e&&(Le(),K(E.current.status===`open`?`CLI mode — keys go straight to the session; full screen while the keyboard is up (corner button brings the header back)`:`CLI mode — link is down, so keystrokes are NOT queued`))}function ze(e){e.nativeEvent.isComposing||Be(e.target)}function Be(e){let t=sv(se.current,e.value);se.current=av,e.value=av,t&&le.sendTyped(t)}function Ve(e){if(e.nativeEvent.isComposing||e.keyCode===229)return;let t=lv(e);if(!t)return;e.preventDefault();let n=hv[e.key];le.armed&&n?le.sendKey(n,t):Ne(t)}function He(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&!e.nativeEvent.isComposing?(e.preventDefault(),(n.trim()||fd())&&Ke()):e.key===`Enter`&&S&&(e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||e.nativeEvent.isComposing||e.keyCode===229||(e.preventDefault(),(n.trim()||fd())&&Ke()))}function Ue(){if(!m)return{refuse:``};if(re===`new`)return{target:{kind:`repo`,cwd:m.cwd}};if(re===`other`){if(!U)return{refuse:yf};let e=_.find(e=>e.id===U&&e.running);return e?{target:{kind:`session`,sessionId:e.id,cwd:e.cwd}}:{refuse:xd(_.find(e=>e.id===U)?.title??null)}}return{target:{kind:`session`,sessionId:m.id,cwd:m.cwd}}}function We(){he||(ie(`this`),ae(null),P(m?.cwd,{where:`this`}))}let Ge=re===`other`&&U?_.find(e=>e.id===U&&e.running)??null:null;function Ke(e,i=!1,a,o=!1,s=!1,c=!1){let l=!i&&m&&re===`this`?fd():null;if(l){let t=e??ne;Lt({title:`Send the picture too?`,lines:[`With the picture: the marked picture goes up and this message is sent with its path, once it lands.`,n?`Text only: just the words — the picture stays open to finish.`:`The message box is empty, so without it there is nothing to send.`],confirmLabel:`With the picture`,cancelLabel:`Text only`,tone:`info`}).then(n=>{n?(q(`action:compose.send.picture`),l(t===`idle`?`queue`:`run`)):Ke(e,!0)});return}if(!m||!n)return;if(M.current>0){K(`still reading that picture — Send goes the moment it is readable`);return}let u=Zs({how:a??e??ne,explicit:e!==void 0||a!==void 0,aimedHere:re===`this`,turnActive:!!m.turnActive,pending:h,localCmd:z(n),pref:L.current});if(u===`ask`){let e=t.queue.budget;Oa(Kd(e?.verdict.blocked?b(e.verdict):null)).then(e=>{if(!e)return;let t=e.ok?`now`:`idle`;q(e.alt?`action:compose.busy.pastbudget`:`action:compose.busy.${t}`),e.remember&&(J(`busySend`,t),K(Vl(t))),Ke(void 0,!0,t,!!e.alt)});return}let d=e??u,f=m.budget;if(!s&&d===`now`&&re===`this`&&f?.cfg.hard&&V(m)&&!z(n)){Lt(Nl(pe(f.verdict))).then(t=>{q(t?`action:compose.hardbudget.send`:`action:compose.hardbudget.keep`),t&&Ke(e,!0,d,o,!0)});return}let g=!c&&d===`now`&&re===`this`&&!h&&!z(n)?y(m.cliVersion,t.cliInstalled):null,_=g?`${m.id}|${g.installed}`:``;if(g&&!Jd(m.id,g.installed)&&!bv.has(_)){let i=k(g,{turnActive:m.turnActive,agents:m.agents?.length,shells:m.shells,resumeId:Mi(m)});if(!i.cant&&!i.loses){let i=m;Oa({...x(g),tone:`info`}).then(a=>{if(!a)return;if(!a.ok){q(`action:compose.restart.sendOld`),bv.add(_),Ke(e,!0,d,o,!0,!0);return}q(`action:compose.restart.thenSend`);let s=n;t.relaunch(i,{},{prompt:s}),p(s),r(``),qe()});return}}let S=e??ne;q(`action:compose.send.${d}`);let C=n,w=E.current.status===`open`;if(re!==`this`){let e=Ue();if(`refuse`in e){e.refuse&&K(e.refuse),re===`other`&&U&&We();return}let n=e.target.cwd;if(!ee({prompts:[C],target:e.target,when:d===`idle`?{kind:`idle`}:{kind:`now`},sequential:!1},{prompts:[C],target:e.target,cwdHint:n,repoId:T(n)?.id??null,origin:m.title}))return;if(p(C),r(``),he){qe(),t.leave();return}P(m.cwd,{mode:S,where:re}),H(S),qe();return}let D=z(C),O=d===`idle`&&!h&&!D?`desktop`:`phone`;if(d===`idle`&&O===`desktop`){let e=j({text:C.trim(),repoDir:m.cwd,label:C.trim().slice(0,40),targetSessionId:m.id,autoFire:!0,...o?{pastBudget:!0}:{}});if(e===null)return;p(C),r(``);let t=o?Xu(!e):Fc(`idle`,{online:!e,holder:O});t&&K(t),P(m.cwd,{mode:S}),H(S),qe();return}if(!A(m.id,m.cwd,C,C.trimStart().startsWith(`/`)?`command`:`prompt`,d===`idle`))return;p(C),r(``);let N=Fc(d,{online:w,holder:O,phoneHold:D?`opens-a-view`:`session-not-open`});N&&K(N),v&&d!==`idle`&&B(C)&&R(),P(m.cwd,{mode:S}),H(S),qe()}function qe(){I.current&&a.current?.blur()}function Je(){if(!m)return;q(`action:compose.options`);let e=nv(F.current,m.cwd,Date.now()),i=Ue(),a=m.id,o=n;N({prompts:n?[n]:[``],target:`target`in i?i.target:{kind:`session`,sessionId:m.id,cwd:m.cwd},cwdHint:m.cwd,repoId:T(m.cwd)?.id??null,...e?{when:e}:{},origin:e&&e.kind!==`now`?`${m.title} · ${rv(T(m.cwd)?.repoName??Fu(m.cwd))}`:m.title,onPosted:()=>{O.current===a?(r(``),Zg(a)&&t.leave()):jr(a)===o&&Aa(a,``)}})}function Ye(){let e=n.trim();if(!e){K(Da);return}q(`action:compose.pad`);let t=Ue(),i=`target`in t?t.target.cwd:m?.cwd,a=Yi({id:xs(),text:e,ts:Date.now(),...i?{cwd:i}:{}});a?K(a):(p(n),r(``),K(It))}function Xe(e){if(!m)return;q(`action:hdrcmd.send`);let t=e.text;A(m.id,m.cwd,t,t.trimStart().startsWith(`/`)?`command`:`prompt`)&&(p(t),K(E.current.status===`open`?`sent ${e.title}`:`queued ${e.title} — sends when the link is back`))}return{...e,sendMode:ne,setSendMode:H,sendWhere:re,setSendWhere:ie,sendWhereSid:U,setSendWhereSid:ae,sendMenu:oe,setSendMenu:W,cliMode:ue,enterSends:S,voice:ge,aimedSession:Ge,noteSendAim:P,chord:le,tapChordMod:fe,sendInput:Ne,stepHistory:Pe,clearCompose:Fe,appendSnippet:Ie,focusPipe:Le,toggleCliMode:Re,onPipeInput:ze,flushPipe:Be,onPipeKey:Ve,onComposeKey:He,aimHere:We,sendCompose:Ke,openComposeSend:Je,keepOnPad:Ye,runHeaderCmd:Xe,seedDraft:_e,typeOn:ve,sendNow:()=>Ke(`now`),secretAskLine:Oe,secret:Ce,setSecret:we,secretShown:Te,setSecretShown:Ee,noteCursorLine:De,dismissSecret:ke,sendSecret:Me,secretFillContext:je}}var Cv=su(Xn,Yn);function wv(e){Kr().onFrame(e),Ao().onText(e),Cv.dispatch(e)}function Tv(e){return Cv.runCommand(e)}function Ev(){return Cv.boot()}var Dv=class{held=[];flushing=!1;keep(e,t){return!this.held||t>0&&!this.flushing?!1:(this.held.length<1e3&&this.held.push(e),!0)}subscribed(e,t){this.held&&!this.flushing&&(this.flushing=!0,e(()=>{let e=this.held??[];this.held=null,this.flushing=!1;for(let n of e)t(n)}))}},Ov=1e4,kv=4e4;function Av(e){return Math.min(Ov*2**Math.min(Number.isFinite(e)?Math.max(0,Math.floor(e)):0,8),kv)}function jv(e){let t=Fe(Je(e,Date.now()));return jo(`up`,t.length,`socket`),t}function Mv(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof Blob<`u`&&e instanceof Blob?e.size:0}var Nv=12e3,Pv=1200,Fv=2,Iv=8e3,Lv=3e4,Rv=4e3,zv=null;function Bv(e){zv=e}var Vv=class{url;dial;ws=null;listeners=new Set;binaryListeners=new Set;early=new Dv;queue=[];reconnectTimer=null;dialTimer=null;dialsCut=0;heartbeatTimer=null;awaitingPong=!1;pingAt=0;probeResolve=null;probeTimer=null;probeAt=0;verifyTimer=null;verifyPending=!1;verifyPings=0;watchdogTimer=null;authPaused=!1;redialing=!1;heldToken=!1;dialGuard=null;status=`connecting`;constructor(e,t=null){this.url=e,this.dial=t,this.connect();let n=()=>{(typeof document>`u`||document.visibilityState===`visible`)&&this.verifyAlive()};typeof document<`u`&&(document.addEventListener(`visibilitychange`,n),document.addEventListener(`resume`,n),document.addEventListener(`freeze`,()=>this.dropSocketForSleep())),typeof window<`u`&&(window.addEventListener(`online`,n),window.addEventListener(`focus`,n),window.addEventListener(`pageshow`,n),window.addEventListener(`pagehide`,()=>this.dropSocketForSleep()),window.addEventListener(Xr,()=>this.verifyAlive()))}dropSocketForSleep(){this.stopHeartbeat();try{this.ws?.close()}catch{}}verifyAlive(){if(!this.authPaused){if(this.armWatchdog(),!this.ws||this.ws.readyState!==WebSocket.OPEN){if(this.ws&&this.ws.readyState===WebSocket.CONNECTING)return;this.forceReconnect()}else this.verifyTimer??(this.verifyPings=0,this.sendVerifyPing())}}sendVerifyPing(){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)this.forceReconnect();else{this.verifyPending=!0,this.verifyPings++,this.pingAt=Date.now();try{this.ws.send(jv({t:`ping`}))}catch{this.forceReconnect();return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.verifyPending&&(this.verifyPending=!1,this.verifyPings<Fv?this.sendVerifyPing():this.forceReconnect())},Pv)}}probe(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN||this.probeResolve)return Promise.resolve(null);try{this.ws.send(jv({t:`ping`}))}catch{return Promise.resolve(null)}let t=Date.now();return new Promise(n=>{this.probeResolve=e=>n(e),this.probeTimer=window.setTimeout(()=>this.settleProbe(null),e),this.probeAt=t})}settleProbe(e){this.probeTimer!=null&&(window.clearTimeout(this.probeTimer),this.probeTimer=null);let t=this.probeResolve;this.probeResolve=null,t&&t(e)}armWatchdog(){this.clearWatchdog(),this.watchdogTimer=window.setTimeout(()=>{this.watchdogTimer=null,this.maybeForceReload()},Iv)}async maybeForceReload(){if(this.status!==`open`){if(zv?.())this.armWatchdog();else if((typeof document>`u`||document.visibilityState===`visible`)&&(typeof navigator>`u`||navigator.onLine!==!1)&&await this.hostReachable()&&(this.hasShellCache()||await this.hostReachable())&&this.ws?.readyState!==WebSocket.OPEN&&(typeof navigator<`u`&&navigator.serviceWorker?.controller||await this.hostReachable()&&this.ws?.readyState!==WebSocket.OPEN)){try{let e=Number(sessionStorage.getItem(G.lastForcedReload)||0);if(Date.now()-e<Lv)return;sessionStorage.setItem(G.lastForcedReload,String(Date.now()))}catch{}Vi(),location.reload()}}}hasShellCache(){try{return!!navigator.serviceWorker?.controller}catch{return!1}}async hostReachable(){try{let e=new AbortController,t=window.setTimeout(()=>e.abort(),Rv);try{return(await fetch(`/api/health`,{cache:`no-store`,signal:e.signal,credentials:`same-origin`})).ok}finally{window.clearTimeout(t)}}catch{return!1}}clearWatchdog(){this.watchdogTimer!=null&&(window.clearTimeout(this.watchdogTimer),this.watchdogTimer=null)}reconnect(){this.authPaused=!1,this.armWatchdog(),this.forceReconnect()}get dialUrl(){return this.url}get tokenHeld(){return this.heldToken}setDialGuard(e){this.dialGuard=e}redial(e){e===this.url&&this.ws&&this.ws.readyState<=WebSocket.OPEN||(this.url=e,this.authPaused=!1,this.redialing=!0,this.forceReconnect())}startHeartbeat(){this.stopHeartbeat(),this.awaitingPong=!1,this.heartbeatTimer=window.setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&(document.visibilityState===`hidden`&&xo(Hp())?this.awaitingPong=!1:this.awaitingPong?(this.awaitingPong=!1,this.forceReconnect()):(this.awaitingPong=!0,this.pingAt=Date.now(),this.ws.send(jv({t:`ping`}))))},Nv)}stopHeartbeat(){this.heartbeatTimer!=null&&(window.clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}forceReconnect(){this.clearDialFuse(),this.reconnectTimer!=null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null);let e=this.ws;if(e){e.onopen=e.onmessage=e.onclose=e.onerror=null;try{e.close()}catch{}this.ws=null}this.connect()}connect(){if(this.redialing)this.redialing=!1;else if(this.dialGuard)try{this.url=this.dialGuard(this.url)||this.url}catch{}this.status=`connecting`,this.emitStatus();let e,t=Uf(bd(this.url));this.heldToken=t&&!!lc();try{let n=hp(t?null:lc());e=this.dial?this.dial(this.url,n):n?new WebSocket(this.url,n):new WebSocket(this.url)}catch{this.status=`closed`,this.emitStatus(),this.scheduleReconnect();return}this.ws=e,this.armDialFuse(e);try{e.binaryType=`arraybuffer`}catch{}e.onopen=()=>{this.clearDialFuse(),this.dialsCut=0,this.status=`open`,this.clearWatchdog(),this.verifyPending=!1,this.emitStatus(),this.send({t:`hello`,protocol:2});let e=this.queue;this.queue=[];for(let t of e)this.send(t);this.startHeartbeat()},e.onmessage=n=>{let r=typeof n.data!=`string`;if(r?jo(`down`,Mv(n.data),`socket`):jo(`down`,n.data.length,`socket`),Su(),this.awaitingPong=!1,this.verifyPending=!1,this.verifyTimer!=null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null),this.clearWatchdog(),r){n.data instanceof ArrayBuffer&&this.deliverBinary(n.data);return}let i;try{i=oe(n.data)}catch{return}i.t===`pong`?(this.pingAt&&=(da(Date.now()-this.pingAt),0),this.probeResolve&&this.settleProbe(Date.now()-this.probeAt)):i.t===`authRequired`&&t?e.close():(i.t===`authRequired`&&(this.authPaused=!0,this.clearWatchdog()),this.deliver(i))},e.onclose=()=>{this.clearDialFuse(),this.status=`closed`,this.settleProbe(null),this.stopHeartbeat(),this.emitStatus(),this.scheduleReconnect()},e.onerror=()=>e.close()}armDialFuse(e){this.clearDialFuse(),this.dialTimer=window.setTimeout(()=>{if(this.dialTimer=null,this.ws===e&&e.readyState===WebSocket.CONNECTING){this.dialsCut++,e.onopen=e.onmessage=e.onclose=e.onerror=null;try{e.close()}catch{}this.ws=null,this.status=`closed`,this.emitStatus(),this.scheduleReconnect()}},Av(this.dialsCut))}clearDialFuse(){this.dialTimer!=null&&(window.clearTimeout(this.dialTimer),this.dialTimer=null)}scheduleReconnect(){this.authPaused||(this.reconnectTimer??=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},1e3))}emitStatus(){ai(this.status),this.deliver({t:`error`,message:this.status,context:`__status`})}deliver(e){this.early.keep(e,this.listeners.size)||this.fanOut(e)}fanOut(e){for(let t of this.listeners)try{t(e)}catch(t){console.error(`%s socket listener failed on %s`,h,String(e.t),t)}}deliverBinary(e){for(let t of this.binaryListeners)try{t(e)}catch(e){console.error(`${h} binary listener failed`,e)}}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(jv(e)):this.queue.push(e)}trySend(e){return!this.ws||this.ws.readyState!==WebSocket.OPEN?!1:(this.ws.send(jv(e)),!0)}on(e){return this.listeners.add(e),this.early.subscribed(queueMicrotask,e=>this.fanOut(e)),()=>this.listeners.delete(e)}onBinary(e){return this.binaryListeners.add(e),()=>this.binaryListeners.delete(e)}},Hv=null;function Uv(){if(!Hv){let e=Op();if(!e)throw Error(`no host paired — open the host setup screen`);let t=Ct();Hv=t?new Vv(e,t.dial):new Vv(e)}return Hv}var Wv=1800,Gv={enabled:!1,gateTailscale:!1,canManage:!1};function Kv(){let e=(0,Z.useRef)(Uv()),[t,n]=(0,Z.useState)(()=>e.current.status);(0,Z.useEffect)(()=>{n(e.current.status)},[]);let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)({tailscaleIp:null,tailscaleBin:null,httpsUrl:null,lanIps:[],hostPort:8770,root:``,auth:Gv}),s=e=>o(t=>({...t,...e})),c=e=>s({tailscaleIp:e.tailscaleIp,tailscaleBin:e.tailscaleBin,root:e.root,httpsUrl:e.httpsUrl??null,lanIps:e.lanIps,hostPort:e.port,auth:e.auth}),[l,u]=(0,Z.useState)(!1),d=e.current.send.bind(e.current);function f(t,n,r){return e.current.status===`open`?(d(t),K(n),!0):(K(r??`no connection — the desktop didn't get that. Try again when the link is back.`),!1)}function p(t,n,r){if(!t.length)return!1;if(e.current.status!==`open`)return K(r??`no connection — the desktop didn't get that. Try again when the link is back.`),!1;for(let e of t)d(e);return K(n),!0}function m(t,n=`no connection — the host can't be asked from here`){return e.current.status===`open`?(d(t),!0):(K(n),!1)}let h=(0,Z.useRef)(Date.now());return(0,Z.useEffect)(()=>{if(t===`open`){h.current=Date.now(),i(!1);return}let e=Math.max(0,Wv-(Date.now()-h.current)),n=window.setTimeout(()=>i(!0),e);return()=>window.clearTimeout(n)},[t]),{connRef:e,status:t,setStatus:n,connVisible:r,info:a,setInfo:s,noteWelcome:c,send:d,liveSend:f,liveSendAll:p,liveAsk:m,reconnectAsk:l,setReconnectAsk:u}}function qv(e,t,n){let r=[[null,null,null]];n&&r.push([null,null,n]),e&&r.push([e,null,n]),t&&r.push([e,t,n]),r.forEach(([e,t,n],r)=>{let i=Gs(e,t,n),a={navRoute:i,navDepth:r},o=Zf(e,t,n);r===0?history.replaceState(a,``,o):history.pushState(a,``,o),Jl.keys[r]=i}),Jl.depth=r.length-1,Jl.keys.length=r.length,Qc()}function Jv(e,t,n,r){let i=ju(),a=Gs(e,t,n),o=history.state,s=o?.navRoute===a?o.navDepth||0:-1,c=$d(Jl.keys,Jl.depth,a,r,s);if(c.kind===`seed`)Yr(a),qv(e,t,n);else if(c.kind===`known`)Jl.depth=c.depth,Jl.keys[c.depth]=a,Qc();else if(c.kind===`go`)Jl.depth+=c.delta,c.forget&&rs(Jl.depth);else if(c.kind===`push`){wa(Jl.depth);let r=Zf(e,t,n),i=Jl.depth+1,o={navRoute:a,navDepth:i};history.pushState(o,``,r),Jl.depth=i,Jl.keys[i]=a,Jl.keys.length=i+1,Qc()}rd(Jl.depth,Jl.keys[Jl.depth]??``,c.how),c.kind===`go`&&history.go(c.delta),hs(i);let l=t?hd(t):null;yc(Zf(e,t,n),Date.now(),l&&t?{navRoute:a,navParams:{overlay:t,params:{...l}}}:null)}function Yv(){let e=ju(),t=history.state,n=Sl(t,{...Fl(),focusRepo:Wu()},Jl.keys,Jl.depth);return!n.adopt&&Nt(n.depth)&&n.depth>0?(Jl.depth=n.depth,hs(e),history.back(),null):(Jl.depth=n.depth,n.key&&(Jl.keys[n.depth]=n.key),n.adopt&&n.key&&(history.replaceState({navRoute:n.key,navDepth:n.depth},``),Jl.keys.length=n.depth+1),Qc(),n.adopt||Tf(n.depth,n.key),rd(n.depth,Jl.keys[n.depth]??``,n.adopt?`push`:`return`),hs(e),{activeId:n.activeId,overlay:n.overlay})}function Xv(){let e=(0,Z.useRef)(Fl()).current,t=(0,Z.useRef)(!1),[n,r]=(0,Z.useState)(e.activeId),[i,a]=(0,Z.useState)(e.image?`swipe`:e.file&&Gn(e.file.relPath)?`gallery`:e.overlay),o=e=>a(t=>t===e?null:t),s=Ip(i),[c,l]=(0,Z.useState)(()=>Wu()),u=(0,Z.useSyncExternalStore)(Rf,ic);return(0,Z.useEffect)(()=>{let e=!t.current;t.current=!0,Jv(n,i,c,e)},[n,i,c,u]),(0,Z.useEffect)(()=>{let e=()=>{let e=Yv();e&&(r(e.activeId),a(e.overlay),l(Wu()))};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[]),(0,Z.useEffect)(()=>hn(`Back`,()=>Jl.depth<=0||Ds()?!1:(history.back(),!0),``),[]),{initRoute:e,activeId:n,setActiveId:r,overlay:i,setOverlay:a,closeSheet:o,overlayRef:s,focusRepo:c,setFocusRepo:l}}var Zv=4e3,Qv=`pty`,$v=65536,ey=3e4,ty=3e5,ny=12;function ry(e){let t=e.indexOf(`\x1B`);return t>0&&t<=1024?e.slice(t):e}async function iy(e,t,n,r){if(!t||n==null)return;let i={sessionId:e,tail:ry(t.slice(-65536)),seq:n,savedAt:Date.now(),boot:r};await dr(Qv,e,i);let a=await Uo(Qv);if(!(a.length<=ny))for(let e of[...a].sort((e,t)=>t.savedAt-e.savedAt).slice(ny))await Cr(Qv,e.sessionId)}async function ay(){return(await Uo(Qv)).filter(e=>e&&e.sessionId&&typeof e.tail==`string`)}var oy=9e5;function sy(e,t,n,r,i){let a=oy*(i?4:1);return e.filter(e=>e.id!==t).slice(0,12).filter(e=>!(e.running&&!e.idle)||r-(n.get(e.id)??0)>=a).map(e=>e.id)}var cy=!1;async function ly(e,t,n){if(!cy){cy=!0;try{for(let r of e){n.set(r,Date.now());try{let e=await t.fetchTail(r,t.heldSeq(r));e&&e.data&&!t.attached(r)&&await t.apply(r,e)}catch{n.delete(r)}}}finally{cy=!1}}}function uy(e,t,n,r){if(r)return e.set(t,n?[n]:[]),!0;let i=e.get(t)??[];return i.push(n),e.set(t,i),!1}function dy(e,t,n){return((e??``)+t).slice(-n)}function fy(e,t,n=!1){let r=new Map;for(let i of e)!n&&(t.buffers.get(i.sessionId)?.length??0)>0||(t.buffers.set(i.sessionId,[i.tail]),r.set(i.sessionId,i.savedAt),i.boot&&(t.lastSeqById.set(i.sessionId,i.seq),t.restore.set(i.sessionId,i.seq),t.resumeBoot.set(i.sessionId,i.boot)));return r}function py(e,t){return[...e].sort((e,n)=>+(n.id===t)-(e.id===t)||n.createdAt-e.createdAt).map(e=>e.id)}function my(e){let{activeId:t,setActiveId:n,setOverlay:r,sessions:i}=e,{connRef:a,send:o,status:s}=e.conn,c=(0,Z.useRef)(null),l=(0,Z.useRef)(new Map),u=(0,Z.useRef)(new Map),d=(0,Z.useRef)(new Map),f=(0,Z.useRef)(new Map),[p,m]=(0,Z.useState)(new Map),h=(0,Z.useRef)(new Map),g=(0,Z.useRef)(new Map),_=(0,Z.useRef)(void 0),v=(0,Z.useRef)(new Set),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[C,w]=(0,Z.useState)(0),[T,E]=(0,Z.useState)(()=>Dt(G.readMode)),D=(0,Z.useRef)(T);D.current=T;let[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(0),[M,ee]=(0,Z.useState)(null);function N(e){ee(t=>({kind:e,key:(t?.key??0)+1}))}let P=(0,Z.useRef)({cols:80,rows:30}),F=(0,Z.useRef)(null),I=(0,Z.useRef)(s),te=Ip(i),L=(0,Z.useRef)(!1),R=(0,Z.useRef)(null),ne=(0,Z.useRef)(void 0),[z,B]=(0,Z.useState)(0),V=Ip(s);function H(e){R.current===e&&ve(e),h.current.delete(e),g.current.delete(e),m(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}function re(t){if(q(`action:session.attach`),e.noteVisited(t.id),r(null),ee(null),!y){n(t.id);return}let i=h.current.get(t.id);i==null&&!p.has(t.id)&&l.current.set(t.id,[]),F.current=t.id,n(t.id),o({t:`session.attach`,id:t.id,resumeSeq:i,resumeBoot:g.current.get(t.id)??_.current}),D.current||zp(t.id)}function ie(){U(!0)}function U(t){let n=e.getActive();if(!n)return;let r=n.id;l.current.set(r,[]),w(e=>e+1),t&&a.current.reconnect(),o({t:`session.detach`,id:r}),o({t:`session.attach`,id:r}),setTimeout(()=>{let{cols:e,rows:t}=P.current;o({t:`session.resize`,id:r,cols:e,rows:Math.max(12,t-1)}),setTimeout(()=>o({t:`session.resize`,id:r,cols:e,rows:t}),120)},280)}function ae(e){E(e),gt(G.readMode,e),e?j(e=>e+1):setTimeout(()=>U(!1),0)}function oe(e,t=!0){q(`action:session.read`),D.current=!0,ae(!0),re(e),t&&N(`outline`)}function W(){j(e=>e+1)}function se(t){l.current.has(t)||l.current.set(t,[]),F.current=t,n(t),e.noteVisited(t),r(null),o({t:`session.attach`,id:t})}function ce(e){_.current=e,F.current&&!D.current&&zp(F.current),me.current()}function le(e){e.id===F.current&&e.idle&&W(),e.idle&&!(D.current&&e.id===F.current)&&zp(e.id)}function ue(e){let t=yd(e.dataB64);uy(l.current,e.id,t,e.full)&&F.current===e.id&&w(e=>e+1),e.seq!=null&&u.current.set(e.id,e.seq),H(e.id),!e.full&&t&&(d.current.set(e.id,Date.now()),f.current.set(e.id,dy(f.current.get(e.id),t,Zv))),S(e=>e+1)}function de(t){v.current.add(t.id),S(e=>e+1),e.onExit()}let fe=()=>c.current?.snapshot()??[];(0,Z.useEffect)(()=>{s===`open`&&I.current!==`open`&&(F.current=null),I.current=s},[s]),(0,Z.useEffect)(()=>{t?L.current||F.current!==t&&i.some(e=>e.id===t)&&y&&(F.current=t,o({t:`session.attach`,id:t,resumeSeq:u.current.get(t),resumeBoot:g.current.get(t)??_.current}),D.current||zp(t)):F.current=null},[t,i,y,z]);let pe=Ip(s),me=(0,Z.useRef)(()=>{});me.current=()=>{if(pe.current!==`open`)return;let e=py(te.current,F.current);e.length&&en(e).then(()=>{let e=sy([...te.current].sort((e,t)=>t.createdAt-e.createdAt),F.current,he.current,Date.now(),pr());return e.length?ly(e,ge,he.current):void 0})};let he=(0,Z.useRef)(new Map),ge={fetchTail:(e,t)=>Dn.screenTail(e,t),heldSeq:e=>{let t=g.current.get(e);return t&&t!==_.current?void 0:u.current.get(e)},attached:e=>F.current===e,apply:async(e,t)=>{let n=t.boot??_.current;await iy(e,t.data,t.seq,n),fy([{sessionId:e,tail:ry(t.data.slice(-$v)),seq:t.seq,savedAt:Date.now(),boot:n}],{buffers:l.current,lastSeqById:u.current,restore:h.current,resumeBoot:g.current},!0),m(t=>new Map(t).set(e,Date.now()))}};(0,Z.useEffect)(()=>{let e=()=>{(document.visibilityState===`visible`||Go(Hp(),hl()))&&me.current()},t=setInterval(e,ty);return document.addEventListener(`visibilitychange`,e),e(),()=>{clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[]),(0,Z.useEffect)(()=>{let e=!1;return ay().then(t=>{if(e)return;let n=fy(t,{buffers:l.current,lastSeqById:u.current,restore:h.current,resumeBoot:g.current});n.size&&m(n)}).finally(()=>{e||b(!0)}),Jn(),()=>{e=!0}},[]),(0,Z.useEffect)(()=>{let e=t;if(!e)return;let n=()=>{Fn(e),!h.current.has(e)&&iy(e,(l.current.get(e)??[]).join(``),u.current.get(e),_.current)},r=window.setInterval(()=>{L.current||n()},ey);return window.addEventListener(`pagehide`,n),window.addEventListener(`freeze`,n),()=>{window.clearInterval(r),window.removeEventListener(`pagehide`,n),window.removeEventListener(`freeze`,n),n()}},[t]);function _e(e){Fn(e),!h.current.has(e)&&iy(e,(l.current.get(e)??[]).join(``),u.current.get(e),_.current)}function ve(e){R.current=null,window.clearTimeout(ne.current),L.current&&(_e(e),o({t:`session.detach`,id:e}))}return(0,Z.useEffect)(()=>{let e=t;if(!e||Jg(e))return;let n,r=()=>{let t=Hp();if(!xo(t)||L.current)return;L.current=!0,_e(e),o({t:`session.detach`,id:e});let r=Tr(t);r!=null&&(n=window.setInterval(i,r))},i=()=>{L.current&&!R.current&&V.current===`open`&&(R.current=e,o({t:`session.attach`,id:e,resumeSeq:u.current.get(e),resumeBoot:g.current.get(e)??_.current}),ne.current=window.setTimeout(()=>ve(e),2e4),me.current())},a=()=>{window.clearInterval(n),n=void 0,L.current&&(L.current=!1,R.current=null,window.clearTimeout(ne.current),F.current=null,B(e=>e+1))},s=()=>{document.visibilityState===`hidden`?r():a()};return document.addEventListener(`visibilitychange`,s),document.visibilityState===`hidden`&&r(),()=>{document.removeEventListener(`visibilitychange`,s),window.clearInterval(n),L.current&&(L.current=!1,R.current=null,window.clearTimeout(ne.current))}},[t]),(0,Z.useEffect)(()=>{if(t&&!Jg(t))return()=>o({t:`session.detach`,id:t})},[t]),{termRef:c,geomRef:P,buffers:l,lastPtyAt:d,ptyTail:f,exitedRef:v,staleAt:p,writeSeq:x,termNonce:C,readMode:T,readModeRef:D,setView:ae,openReader:oe,readerCmd:M,fireReader:N,outlineJump:O,setOutlineJump:k,transcriptNonce:A,attach:re,focus:se,refreshTerminal:ie,hostAnsweredFor:H,onWelcome:ce,onSessionUpdated:le,onPty:ue,onSessionExit:de,snapshot:fe}}function hy(e,t=1){return`${t>1?`archived ${t} sessions`:`archived ${e}`} — the conversation is kept: reopen it under “Recently closed”, or in Archive`}function gy(e,t){let{connRef:n,send:r,liveSend:i,liveAsk:a}=e,o=_y(e,Wp,sa,(e,t)=>({t:`session.star`,id:e,starred:t})),s=_y(e,Ra,In,(e,t)=>({t:`session.followup`,id:e,on:t}));function c(e){q(`action:session.close`),e.running?a({t:`session.closecheck`,id:e.id},`no connection — the desktop didn't get that, the session is still open`):(us(e.id),i({t:`session.remove`,id:e.id},hy(e.title),`no connection — the desktop didn't get that, the session is still listed`))}function l(){let e=t().filter(e=>!e.running&&!Up(e));if(e.length){if(n.current.status!==`open`)K(`no connection — the desktop didn't get that, the sessions are still listed`);else{for(let t of e)r({t:`session.remove`,id:t.id});K(hy(e[0].title,e.length))}}}function u(e){let n=[];if(e.isRepo&&(e.dirty&&n.push(`• uncommitted changes (no commit done)`),!e.isMain&&e.unmerged>0&&n.push(`• ${e.unmerged} commit(s) not merged to ${e.mainBranch||`main`}`)),e.shells?.length){let t=S(p(e.shells,Date.now()),e.shells);t&&n.push(`• ${t}`)}let i=t().find(t=>t.id===e.id)?.title??e.branch??`session`;if(n.length===0){us(e.id),r({t:`session.remove`,id:e.id}),K(hy(i));return}let a=e.branch||`this session`,o=n.map(e=>e.replace(/^• /,``)),s=t=>{us(e.id),r({t:`session.remove`,id:e.id}),K(t)};xa(`confirmClose`).current?(async()=>{let{ok:e,remember:t}=await Wc({title:`Close ${a}?`,lines:o,confirmLabel:`Close anyway`,tone:`warn`});e&&(t?(J(`confirmClose`,!1),s(`won't ask again — Settings › Sessions › ask before closing a session turns it back on`)):s(hy(i)))})():s(`${hy(i)} — left: ${o.join(`; `)}`)}function d(e,t){q(`action:session.star`),o.press(e,t)}function f(e,t){q(`action:session.followup`),s.press(e,t)}function m(e,t){o.settle(e,t),s.settle(e,t)}return{pendingStars:o.pending,toggleStar:d,pendingFollowUps:s.pending,toggleFollowUp:f,settleStars:m,closeSession:c,archivedToast:hy,clearExited:l,onCloseCheck:u}}function _y(e,t,n,r){let{connRef:i,status:a,send:o}=e,[s,c]=(0,Z.useState)(()=>hr(t)),l=(0,Z.useRef)(s);l.current=s,(0,Z.useEffect)(()=>{if(a===`open`)for(let[e,t]of Object.entries(l.current))i.current.send(r(e,t))},[a]);function u(e){l.current=e,c(e),_s(t,e)}return{pending:s,press(e,t){u({...l.current,[e]:t}),o(r(e,t))},settle(e,t){let r=Zt(l.current,e,t,n);r&&u(r)}}}var vy=[`default`,`acceptEdits`,`plan`,`auto`],yy=[`bypassPermissions`,`dontAsk`],by={default:{mode:`default`,title:`Manual`,desc:`Asks for approval before each edit and command`,icon:`hand`},acceptEdits:{mode:`acceptEdits`,title:`Edit automatically`,desc:`Edits files without asking; still asks before other commands`,icon:`code`},plan:{mode:`plan`,title:`Plan`,desc:`Explores the code and presents a plan before editing`,icon:`scroll`},auto:{mode:`auto`,title:`Auto`,desc:`Approves actions that pass a safety check, pauses for anything risky`,icon:`zap`},bypassPermissions:{mode:`bypassPermissions`,title:`Bypass permissions`,desc:`Runs every tool call without asking — nothing is checked`,icon:`shieldOff`},dontAsk:{mode:`dontAsk`,title:`Don’t ask`,desc:`Never shows an approval prompt — the permission rules decide alone`,icon:`lock`}};function xy(e){return by[e]?.title??e}function Sy(e){return e.liveMode?{mode:e.liveMode,source:`live`}:e.permissionMode?{mode:e.permissionMode,source:`launch`}:{mode:null,source:`unknown`}}function Cy(e,t=`the CLI’s footer`){let n=t===`the CLI’s footer`;return e.source===`live`?`Now: ${xy(e.mode)}, read ${n?`off`:`from`} ${t}.`:e.source===`launch`?`Launched in ${xy(e.mode)}. ${n?`The footer`:`Its mode`} can’t be read right now, so it may have changed since.`:`${n?`The footer`:`Its mode`} can’t be read right now and this session launched with no mode flag, so its mode is not known here.`}function wy(e,t,n=!0){let r=vy.filter(t=>e.includes(t));for(let i of yy)e.includes(i)&&(!n||t.liveMode===i||t.permissionMode===i)&&r.push(i);return r.map(e=>by[e])}function Ty(e,t){return t.source===`live`&&t.mode===e?{kind:`none`,say:`already in ${xy(e)}`}:yy.includes(e)?{kind:`confirm`}:{kind:`send`}}function Ey(e){return e.reason?e.reason:e.mode?`now in ${xy(e.mode)}`:`the desktop switched, but could not read the footer afterwards`}var Dy=12e3;function Oy(e){return`the desktop did not answer the switch to ${xy(e)} — check the footer in the terminal`}function ky(e){return e.liveMode&&e.liveMode!=="default"?e.liveMode:null}function Ay(e){return e===!0?`on`:e===!1?`off`:`unknown`}function jy(e){let t=Ay(e);return t===`on`?`on for this session — the CLI confirmed it`:t===`off`?`off — the CLI confirmed it`:`not known — the CLI hasn’t confirmed it yet`}function My(e){return`/effort ultracode ${e?`on`:`off`}`}var Ny=new Map,Py=new Set,Fy=()=>{for(let e of Py)e()};function Iy(e,t){let n=Ny.get(e);n&&window.clearTimeout(n.timer);let r=window.setTimeout(()=>{Ny.get(e)?.timer===r&&(Ny.delete(e),Fy(),K(Oy(t)))},Dy);Ny.set(e,{mode:t,timer:r}),Fy()}function Ly(e){let t=Ny.get(e.id);t&&(window.clearTimeout(t.timer),Ny.delete(e.id),Fy()),K(Ey(e))}function Ry(e){return(0,Z.useSyncExternalStore)(e=>(Py.add(e),()=>{Py.delete(e)}),()=>Ny.get(e)?.mode??null)}function zy(e,t){let n=Ip(e);(0,Z.useEffect)(()=>{let{connRef:e,setBackends:r,setSessions:i,setRecent:a,setClosed:o,setUpdate:s,setMeter:c,setIntents:l,updateResultSeenRef:u,wantNavRef:d}=t,f=e.current.on(t=>{let{conn:f,term:p,verbs:m,q:h,focusSession:g}=n.current;switch(t.t){case`welcome`:hf.noteWelcome(t,e.current.dialUrl),t.protocol!==2&&K(t.protocol>2?`the desktop is newer than this app — reload to update`:"the desktop is older than this app — run `npm run restart` there"),r(null),f.noteWelcome(t);{let e=ps(t);e&&K(e.announced?`desktop restarted — back${e.downMs==null?``:` after ${Md(e.downMs)}`}`:`desktop restarted without warning (crash?)${e.downMs==null?``:` — back after ${Md(e.downMs)}`}`)}vo.pump(),p.onWelcome(t.bootId);break;case`backends`:r(t.list);break;case`host.restarting`:{qr(Date.now(),t.reason);let e=ts().usualMs;K(`desktop is restarting${t.reason?` (${t.reason})`:``}${e==null?` — the app cannot reach it until it is back`:` — usually back in ~${Md(e)}`}`);break}case`auth.state`:f.setInfo({auth:t.auth});break;case`backlog.ack`:h.onBacklogAck(t);break;case`op.ack`:gr(t.ackId,t.ok,t.filed,Ms),h.onOpAck(t);break;case`session.list`:i(t.sessions),m.settleStars(t.sessions,!0),ks(t.sessions),kf(`sessions`);break;case`recent.list`:a(t.recent),Ea(G.snapRecent,t.recent);break;case`closed.list`:o(t.closed),Ea(G.snapClosed,t.closed);break;case`input.ack`:h.onInputAck(t);break;case`delivery.list`:h.onDeliveryList(t);break;case`delivery.settled`:h.onDeliverySettled(t);break;case`session.created`:i(e=>[...e.filter(e=>e.id!==t.session.id),t.session]),p.buffers.current.set(t.session.id,[]),d.current&&g(t.session.id);break;case`session.focus`:g(t.id);break;case`session.updated`:m.settleStars([t.session],!1),i(e=>{let n=e.map(e=>e.id===t.session.id?t.session:e);return ks(n),n}),p.onSessionUpdated(t.session);break;case`pty`:p.onPty(t);break;case`session.exit`:p.onSessionExit(t);break;case`session.closecheck`:m.onCloseCheck(t);break;case`session.history`:p.hostAnsweredFor(t.id),oa(t.id,t.entries);break;case`session.named`:K(t.name?`named “${t.name}”`:t.reason??`no name was written`);break;case`session.moded`:Ly(t);break;case`update.status`:s(t.info),t.info.lastResult&&t.info.lastResult.at>u.current&&(u.current=t.info.lastResult.at,K(t.info.lastResult.ok?`Claude updated`:`Update failed: ${t.info.lastResult.message}`));break;case`budget.state`:h.onBudget(t);break;case`settings.all`:zl(t.doc);break;case`settings.update`:Ju(t.key,t.value,t.ts);break;case`toast`:K(t.text);break;case`meter.status`:c(t.summary);break;case`intent.list`:l(t.intents);break;case`intent.changed`:l(e=>{let n=e.findIndex(e=>e.id===t.intent.id);if(n<0)return[t.intent,...e];let r=e.slice();return r[n]=t.intent,r});break;case`launch.list`:h.onLaunchList(t);break;case`launch.opened`:h.onLaunchOpened(t);break;case`error`:t.context===`__status`&&f.setStatus(t.message)}}),p=e.current.on(wv),m=e.current.onBinary(e=>Ao().onBinary(e));return()=>{f(),p(),m()}},[])}var By=`theme.textScale.iconScale.termZoom.readerZoom.scrollZoom.gitZoom.textDumpWrap.sessionTabs.sessionTabsCount.sessionTabsOrder.sessionTabsLimit.sessionTabsSync.netPulse.localRtBar.unfoldToEnd.typingRoom.closeKbOnSend.shortcutCard.busySend.btwToCli.toolbarOpen.readMode.cliMode.termCostOpen.termCornerPos.hintChip.annHintHidden`.split(`.`),Vy=[G.outbox,G.pad,G.compose,G.fileRemarks,G.padRescue,G.padRescueMigrated,G.giveups,G.giveupsMigrated,G.syncTs,G.hosts,G.hostActive,G.hostSwitch,G.hostsGone,W,G.tokenSeal,G.tokenSealOn,G.tokenSealDead,G.tokenSealAuth,G.appLock,G.appLockBlob,bt,...rt,G.brandMigrated,G.brandStores];async function Hy(){try{for(let e of Object.keys(localStorage))Vy.some(t=>e.startsWith(t))||localStorage.removeItem(e)}catch{}try{let e=await caches.keys();await Promise.all(e.filter(e=>!On.some(t=>e.startsWith(t))).map(e=>caches.delete(e)))}catch{}try{let e=await navigator.serviceWorker.getRegistrations();await Promise.all(e.map(e=>e.unregister()))}catch{}location.reload()}function Uy({err:e}){let t=e instanceof Error?`${e.name}: ${e.message}`:String(e);return(0,Q.jsxs)(`div`,{className:`boot-fail`,children:[(0,Q.jsxs)(`h2`,{children:[jt(),` couldn't start`]}),(0,Q.jsx)(`pre`,{children:t}),(0,Q.jsxs)(`div`,{className:`boot-fail-acts`,children:[(0,Q.jsx)(`button`,{onClick:()=>location.reload(),children:`Reload`}),(0,Q.jsx)(`button`,{onClick:()=>{Hy()},children:`Reset caches & reload`})]}),(0,Q.jsx)(`p`,{children:`Queued text and prompt-pad drafts are kept by the reset.`})]})}var Wy=class extends Z.Component{state={err:null};static getDerivedStateFromError(e){return{err:e}}componentDidCatch(e,t){console.error(`${h} render failed`,e,t.componentStack)}render(){return this.state.err?(0,Q.jsx)(Uy,{err:this.state.err}):this.props.children}};function Gy(){let e=null,t=t=>{e||=t};window.addEventListener(`error`,e=>t(e.error||e.message)),window.addEventListener(`unhandledrejection`,e=>t(e.reason)),setTimeout(()=>{let t=document.getElementById(`root`);if(!t||t.childElementCount>0)return;t.innerHTML=``;let n=document.createElement(`div`);n.className=`boot-fail`;let r=e?e instanceof Error?`${e.name}: ${e.message}`:String(e):`The app scripts loaded but nothing rendered.`;n.innerHTML=`<h2></h2><pre></pre>`,n.querySelector(`h2`).textContent=`${jt()} couldn't start`,n.querySelector(`pre`).textContent=r;let i=document.createElement(`div`);i.className=`boot-fail-acts`;let a=document.createElement(`button`);a.textContent=`Reload`,a.onclick=()=>location.reload();let o=document.createElement(`button`);o.textContent=`Reset caches & reload`,o.onclick=()=>{Hy()},i.append(a,o),n.append(i),t.append(n)},4e3)}var Ky=class extends Z.Component{state={err:!1};static getDerivedStateFromError(){return{err:!0}}componentDidCatch(e,t){console.error(`${h} sheet "${this.props.name}" failed`,e,t.componentStack);let n=e instanceof Error?`${e.name}: ${e.message}`:String(e);try{this.props.onFail(this.props.name,n)}catch{}}render(){return this.state.err?null:this.props.children}},qy=Bt(Xn,Yn);function Jy(e,t){return qy.rows(e,t).map(e=>(0,Z.createElement)(Z.Fragment,{key:e.key},e.node))}var Yy=new Set([`dontAsk`,`bypassPermissions`]),Xy=[`The agent will edit files, run shell commands, and push — with no approval prompt and no chance to say no.`,`Use it only in a repo whose contents you could afford to lose.`,`Sessions you start from any of your clients will use this until you change it back.`],Zy=[{key:`warnPct`,label:`orange at`,suffix:`% of week`},{key:`highPct`,label:`red at`,suffix:`% of week`},{key:`warnUsd`,label:`orange at`,prefix:`$`,suffix:`without a week reading`},{key:`highUsd`,label:`red at`,prefix:`$`,suffix:`without a week reading`}];function Qy(){let e=X(`spendWarn`),[t,n]=(0,Z.useState)({}),[r,i]=(0,Z.useState)(null),a=r=>{let a=t[r];if(a==null)return;let o=Number(a.trim().replace(`,`,`.`).replace(/^\$|%$/g,``));if(n(e=>{let{[r]:t,...n}=e;return n}),!(o>0)||!Number.isFinite(o)){i(`“${a}” is not a number above zero — kept ${String(e[r])}.`);return}let s={...e,[r]:o},c=r.endsWith(`Pct`)?[`warnPct`,`highPct`]:[`warnUsd`,`highUsd`];s[c[1]]>s[c[0]]?r.endsWith(`Pct`)&&o>100?i(`A share of the week cannot be more than 100%.`):(i(null),q(`action:spendWarn.set`),J(`spendWarn`,Ue(s))):i(`Red has to be above orange — kept what was there.`)},o=[`warnPct`,`highPct`,`warnUsd`,`highUsd`].every(t=>e[t]===Pe[t]);return(0,Q.jsxs)(tl,{id:`spend-warn`,label:`spend marks`,icon:vh,on:e.on,onChange:()=>{q(`action:spendWarn.toggle`),J(`spendWarn`,{...e,on:!e.on})},note:e.on?(0,Q.jsxs)(Q.Fragment,{children:[`A session's Σ figure gets an orange triangle at `,e.warnPct,`% of the week and a red one at `,e.highPct,`% — $`,e.warnUsd,` and $`,e.highUsd,` where there is no weekly limit reading.`]}):(0,Q.jsx)(Q.Fragment,{children:`Off: no session's spend is marked, whatever it reaches.`}),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Which scale.`}),` With a subscription, the desktop measures what one percent of your week is in list-price dollars from its own `,(0,Q.jsx)(`code`,{children:`/usage`}),` readings, and the marks are a share of that. With an API key there is no weekly limit, so the dollar pair applies — and also on a subscription until the week has been measured.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Where the dollar defaults come from.`}),` On a Max plan one percent of a week measured at about $15 of list price, so 2% ≈ $30 and 5% ≈ $75. Another plan moves that rate; the percent pair follows it on its own.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What a mark does.`}),` It is a readout: one toast the first time a session passes each mark, and the triangle beside its spend. Nothing is paused or refused — for that, give a session its own budget.`]}),!o&&(0,Q.jsxs)(`p`,{children:[`Defaults: `,Pe.warnPct,`% / `,Pe.highPct,`% of week, $`,Pe.warnUsd,` / $`,Pe.highUsd,`.`]})]}),children:[e.on&&Zy.map(r=>(0,Q.jsxs)(`div`,{className:`set-item`,children:[(0,Q.jsx)(`label`,{className:`set-lead`,htmlFor:`spend-warn-${r.key}`,children:(0,Q.jsx)(`span`,{className:`set-lbl`,style:{color:r.key.startsWith(`warn`)?`var(--warn)`:`var(--dead)`},children:r.label})}),(0,Q.jsxs)(`div`,{className:`budget-input`,children:[r.prefix&&(0,Q.jsx)(`span`,{className:`budget-affix`,children:r.prefix}),(0,Q.jsx)(`input`,{id:`spend-warn-${r.key}`,inputMode:`decimal`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:t[r.key]??String(e[r.key]),onChange:e=>n(t=>({...t,[r.key]:e.target.value})),onBlur:()=>a(r.key),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}}),r.suffix&&(0,Q.jsx)(`span`,{className:`budget-affix`,children:r.suffix})]})]},r.key)),r&&(0,Q.jsx)(`div`,{className:`set-warn`,children:r})]})}var $y=(e,t)=>{let n=e.find(e=>e.worktreePath===t);if(n)return n;let r=null;for(let n of e){let e=n.worktreePath.replace(/\/+$/,``);e&&t.startsWith(e+`/`)&&(!r||e.length>r.worktreePath.replace(/\/+$/,``).length)&&(r=n)}return r},eb=(e,t)=>{let n=$y(e,t.cwd);return n?N(n):Fu(t.cwd)},tb=(e,t)=>{let n=$y(e,t.cwd);return n?f(n):Fu(t.cwd)},nb=(e,t)=>{let n=e.find(e=>N(e)===t);return n?f(n):t},rb=(e,t)=>{let n=$y(e,t.cwd);return n?`${N(n)} · ${n.branch}`:Fu(t.cwd)},ib=(e,t)=>{let n=$y(e,t.cwd);return n?xe(n):Fu(t.cwd)},ab=(e,t)=>ib(e,t)||(t.tabTitle??``).trim()||tb(e,t),ob=e=>`${e.status===`pending`?`opening…`:`queued`} ${e.n}`,sb=e=>`${e.n>1?`${e.n} sessions `:``}${e.status===`pending`?`opening — waiting for the desktop to confirm`:`queued — opens when the link is back`}`,cb=e=>`repo setup: ${e.issues} ${e.ok?`thing to look at`:`issue`}${e.issues>1?`s`:``}${e.fixable?`, ${e.fixable} one-tap fixable`:``} — open the checklist`,lb=e=>e&&e.issues>0?`repo readings · ${e.issues}`:`repo readings`,ub=e=>e&&e.issues>0?cb(e):`open this repo's readings`;function db(e,n,r){let i=[...e].sort((e,t)=>(e.createdAt??0)-(t.createdAt??0)),a=i;if(n.length){let e=new Map(i.map(e=>[e.id,e]));a=[];for(let t of n){let n=e.get(t);n&&(a.push(n),e.delete(t))}for(let t of i)e.has(t.id)&&a.push(t)}let o=new Map;for(let e of a){let t=r(e),n=o.get(t);n?n.push(e):o.set(t,[e])}return t([...o.values()].flat())}function fb(e,t,n){let r=new Set(t),i=e.filter(e=>n.has(e)&&!r.has(e));return[...t,...i]}function pb(e,t,n,r){if(!n||n===t)return null;let i=e.find(e=>e.id===t),a=e.find(e=>e.id===n);if(!i||!a||r(i)!==r(a))return null;let o=e.map(e=>e.id),s=o.indexOf(t),c=o.indexOf(n);return s===-1||c===-1?null:(o.splice(s,1),o.splice(c,0,t),o)}function mb(e,t,n,r){return t?e.filter(e=>n(e,t.status)&&(!t.repo||r(e)===t.repo)):e}function hb(e,t,n){let r=new Map;for(let i of e){let e=n(i),a=r.get(e)??{wait:0,blocked:0,coding:0,done:0,exited:0};a[t(i)]++,r.set(e,a)}return r}var gb=(e,t)=>[...e.values()].reduce((e,n)=>e+n[t],0);function _b(e,t){let n=new Map;for(let r of e)if(r.starred){let e=t(r);n.set(e,(n.get(e)??0)+1)}return n}function vb(e,t){let n=new Map,r=new Map;for(let i of e){if(!i.running)continue;let e=t(i),a=n.get(e)??0;r.set(i.id,a),n.set(e,a+1)}return r}var yb=[`name`,`sessions`],bb={name:`alphabetical`,sessions:`most open sessions first`};function xb(e,t){let n=new Map;for(let r of e)if(r.running){let e=t(r);n.set(e,(n.get(e)??0)+1)}return n}function Sb(e,t,n,r,i=[],a){let o=new Map,s=[];for(let t of e){let e=r(t),n=o.get(e);n||(n=[],o.set(e,n),s.push(e)),n.push(t)}for(let e of t){let t=N(e);n&&!i.includes(t)||o.has(t)||(o.set(t,[]),s.push(t))}return s.sort((e,t)=>(a?(a.get(t)??0)-(a.get(e)??0):0)||e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0})),s.map(e=>({repoName:e,sessions:o.get(e)??[]}))}function Cb(e){return e===`rows`?null:e===`unread`?`Waiting for the desktop's repo list.`:`No repos under host root.`}function wb(e,t,n,r){let i=new Map,a=(e,t)=>{if(n.has(t))return;let a=r(e);if(!a)return;let o=i.get(a);o?o.push(t):i.set(a,[t])};for(let t of e)t.status!==`failed`&&t.cwd&&a(t.cwd,Wo(t.ackId));for(let e of t)e.archived||e.state!==`queued`&&e.state!==`blocked`||v(e)||e.cwd&&a(e.cwd,wr(e.id));return i}function Tb(e,t,n){let r=t.filter(e=>!e.archived&&(e.groupId==null||e.groupId===e.id)&&Ir(e.state,e.blockReason??null)===`needsYou`),i=new Set(t.filter(e=>!e.archived&&(e.state===`queued`||e.state===`blocked`||e.state===`starting`)).map(e=>e.id));return[...e.filter(e=>(e.status===`queued`||e.status===`failed`)&&!i.has(e.ackId)).map(e=>Wo(e.ackId)),...r.map(e=>wr(e.id))].filter(e=>!n.has(e))}function Eb(e,t){let n=new Set(e),r=t.filter(e=>n.has(wr(e.id))),a=new Set(r.map(e=>e.cwd));return r.length===e.length&&a.size===1&&r[0].cwd&&r.every(i)?{kind:`backlog`,cwd:r[0].cwd,ids:r.map(e=>e.id)}:{kind:`activity`}}var Db=e=>!!e.starred||mr(e);function Ob(e,t,n,r){let i=t?e.filter(e=>r(e)===t):[...e];return n?i.filter(e=>!Db(e)):i}function kb(e,t,n){let r=(t?e.filter(e=>n(e)===t):e).filter(Db);return{n:r.length,starred:r.filter(e=>e.starred).length,flagged:r.filter(mr).length}}function Ab(e,t,n,r){return n?kb(e,t,r).n:0}function jb(e){let t=e.starred&&e.flagged?`starred & flagged`:e.flagged?`flagged`:`starred`;return`${e.n} ${t}`}function Mb(e,t){let n=e.toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return!0;let r=t.filter(Boolean).join(`
|
|
10
|
-
`).toLowerCase();return n.every(e=>r.includes(e))}async function Nb(e){if(!fu())return;Tt(G.tabsSaverAsked,`1`);let t=await Oa({title:`Stop sharing tab order while ${kl[e]} is on?`,lines:[`Shared, every tab you open sends a small update to the desktop so your other devices order their tabs the same way.`,`Stopped, this device keeps its own order. Settings › Appearance › same tab order on every device turns it back on.`],confirmLabel:`stop sharing`,cancelLabel:`keep sharing`});t&&(t.ok?(J(`tabsSync`,!1),At.reload(`tabsSort`),K(`tab order kept on this device — Settings › Appearance shares it again`)):K(`tab order still shared`))}var Pb=()=>navigator.connection;async function Fb(){let e=co({app:pr(),phoneData:!!Pb()?.saveData,battery:await Ta()});e?_n(e,fu(),Et(G.tabsSaverAsked)===`1`)&&Nb(e):_t(G.tabsSaverAsked)}var Ib=!1;function Lb(){if(!(Ib||typeof document>`u`)){Ib=!0,setTimeout(()=>{Fb()},4e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Fb()});try{Pb()?.addEventListener(`change`,()=>{Fb()})}catch{}}}var Rb=16;function zb(){let e=X(`theme`),t=X(`txtScale`),n=X(`icScale`),r=X(`tZoom`),i=X(`tabsOn`),a=X(`tabsN`),o=X(`tabsSort`),s=X(`tabsMax`),c=X(`tabsSync`),l=X(`netPulse`),u=X(`unfoldToEnd`),d=X(`repoSort`),f=X(`localRtBar`),p=X(`agentWarn`),m=Af(r,-1,t),h=Af(r,1,t),g=e=>{J(`tabsN`,e),K(`${e} tabs across the strip`)},_=e=>{J(`tabsMax`,e),K(`at most ${e} session tabs`)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qu,{id:`theme`,radio:!0,label:`theme`,icon:Uh,value:e,options:[[`system`,`follow device`,Uh],[`light`,`light`,Bm],[`dark`,`dark`,hh]].map(([e,t,n])=>({value:e,label:t,icon:n})),onChange:e=>{J(`theme`,e),K(`theme: ${e===`system`?`following this device (${yi()})`:e}`)},note:e===`system`?`Following this device — it is ${yi()} right now, and switches with it.`:`Always ${e} on this device, whatever its OS says.`,more:(0,Q.jsx)(`p`,{children:`Per device, not per account: the phone in a dark room and the desktop under a window want different answers, and “follow device” is how each one gets its own.`})}),(0,Q.jsx)(qu,{id:`text-size`,label:`text size`,icon:Ah,value:t,options:Sc.map(e=>({value:e.value,label:e.label,icon:Ah,style:{fontSize:`${Math.round(14*e.value)}px`}})),onChange:e=>{q(`action:uiscale.text`),J(`txtScale`,e)},note:`Everywhere — the lists, the sheets and the terminal.`,more:(0,Q.jsx)(`p`,{children:`The buttons are drawn at the size they set, so the one you can read comfortably is the one to press.`})}),(0,Q.jsx)(qu,{id:`icon-size`,label:`icon size`,icon:wg,value:n,options:af.map(e=>({value:e.value,label:e.label})),onChange:e=>{q(`action:uiscale.icon`),J(`icScale`,e)},note:`Separately from the text — an icon too small to hit is not the same complaint as text too small to read.`,more:(0,Q.jsx)(`p`,{children:`Wanting big text with compact chrome is not a contradiction. Charts and graphs are left alone — scaling those would move the data rather than enlarge it.`})}),(0,Q.jsx)(Mc,{id:`terminal-zoom`,label:`terminal size`,icon:sm,readout:(0,Q.jsxs)(Q.Fragment,{children:[rl(t,r),`px`,m==null?` · smallest`:h==null?` · biggest`:``]}),onLess:m==null?null:()=>ws(m),onMore:h==null?null:()=>ws(h),lessLabel:`smaller`,moreLabel:`bigger`,extra:r!==1&&(0,Q.jsxs)(Y,{onClick:()=>ws(1),title:`back to the text size on its own — ${rl(t,1)}px`,children:[(0,Q.jsx)(Xh,{size:Rb}),` default`]}),note:`Terminal only, on top of the text size above — a smaller console font is a BIGGER grid.`,more:(0,Q.jsx)(`p`,{children:`So the CLI gets more columns and rows to draw in and a wide diff stops wrapping. The desktop is told the new size the moment you tap. The same two buttons float in the terminal's top-right corner, which is where they are worth using: you can see what you are changing while you change it.`})}),(0,Q.jsx)(gf,{id:`repo-colours`,label:`repo colours`,icon:Qm,opens:!0,onClick:()=>{q(`action:repocolor.open`),Yn().nav.open(`repocolor`)},note:`Every repo gets a colour of its own — the group header, the row stripes and the session tab all wear it.`,more:(0,Q.jsxs)(`p`,{children:[`Pick the `,(0,Q.jsx)(`b`,{children:`ring`}),` the colours come from (including one that survives colour blindness), `,(0,Q.jsx)(`b`,{children:`pin a colour`}),` to a repo by hand, and see which repos ended up sharing one. Synced: a repo recognised by one colour on the phone and another on the desktop is not recognised at all.`]})}),(0,Q.jsx)(tl,{id:`tabs`,label:`session tabs`,icon:Lm,on:i,onChange:()=>{let e=!i;J(`tabsOn`,e),q(`action:sessiontabs.${e?`on`:`off`}`),K(e?`session tabs on — ${a} fit this screen, the rest scroll sideways`:`session tabs off`)},note:`A row of the sessions you have open, above every screen, each one coloured by its repo.`,more:(0,Q.jsx)(`p`,{children:`It answers the question the launcher makes you work for: what else is open, and can I get back to it without leaving this screen. Each tab is named in four words or fewer by the desktop, once, off the summary it already writes — until then it wears the repo and branch it has everywhere else. The × closes that session and asks first; the conversation is kept either way.`})}),i&&(0,Q.jsx)(Mc,{id:`tabs-count`,label:`tabs that fit`,icon:Lm,readout:(0,Q.jsxs)(Q.Fragment,{children:[a,` tabs`,a===2?` · widest`:a===8?` · narrowest`:``]}),onLess:a>2?()=>g(a-1):null,onMore:a<8?()=>g(a+1):null,lessLabel:`wider`,moreLabel:`narrower`,note:`The narrowest a tab gets, between 2 and 8 across. Fewer open, each is as wide as its name. It hides nothing.`,more:(0,Q.jsx)(`p`,{children:`Up to the limit below, every open session is on the strip and the rest scroll sideways; what this decides is the narrowest a tab gets once the strip fills, and therefore how much of its name you can read then. With fewer open, each tab is as wide as its name.`})}),i&&(0,Q.jsx)(Mc,{id:`tabs-limit`,label:`most tabs shown`,icon:Lm,readout:(0,Q.jsxs)(Q.Fragment,{children:[s,` tabs`,s===50?` · most`:s===2?` · fewest`:``]}),onLess:s>2?()=>_(s-1):null,onMore:s<50?()=>_(s+1):null,lessLabel:`fewer`,moreLabel:`more`,note:`How many sessions the strip draws, in the order below. The rest are counted at its end.`,more:(0,Q.jsx)(`p`,{children:`Past this number the strip stops and says how many it left off — every session is still in the launcher. The one you are in is always drawn, even when the order would put it past the cut.`})}),i&&(0,Q.jsx)(qu,{id:`tabs-order`,radio:!0,label:`tab order`,icon:Lm,value:o,options:Gf.map(e=>({value:e,label:Ap[e]})),onChange:e=>{J(`tabsSort`,e),q(`action:sessiontabs.order.${e}`),K(`session tabs: ${Ap[e]}`)},note:`Three orders, three different things to want.`,more:(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`In the order opened`}),` never moves, so a tab's position is something you learn and reach without reading it. `,(0,Q.jsx)(`b`,{children:`Most opened first`}),` keeps the ones you actually go back to under your thumb. `,(0,Q.jsx)(`b`,{children:`Last opened first`}),` answers “where was I” instead — the one order that moves under you. Tabs that tie keep the order they were started in, so nothing shuffles on its own.`]})}),i&&(0,Q.jsx)(tl,{id:`tabs-sync`,label:`same tab order on every device`,icon:Lm,on:c,onChange:()=>{let e=!c;J(`tabsSync`,e),At.reload(`tabsSort`),q(`action:sessiontabs.sync.${e?`on`:`off`}`),K(e?`tab order shared with your other devices`:`tab order kept on this device only`)},note:c?`The order above, and which session you opened last or most, follow you between devices.`:`This device keeps its own order and its own record of what you opened.`,more:(0,Q.jsxs)(`p`,{children:[`On, a session you open on the desktop moves to the front here too under `,(0,Q.jsx)(`b`,{children:`last opened first`}),`, and picking an order on one device picks it on all of them that have this on. How many tabs fit and how many are shown stay per device — they are about the screen. Off, this device goes back to the order and record it kept for itself; pinned files are always this device's. When data saver or the phone's battery saver comes on, you are asked once whether to stop sharing.`]})}),(0,Q.jsx)(qu,{id:`repo-order`,radio:!0,label:`repo order`,icon:$p,value:d,options:yb.map(e=>({value:e,label:bb[e]})),onChange:e=>{J(`repoSort`,e),q(`action:reposort.${e}`),K(`repos: ${bb[e]}`)},note:`The launcher's repo list. Most open sessions first breaks ties alphabetically. Per device.`,more:(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Alphabetical`}),` never moves, so a repo's place is something you learn. `,(0,Q.jsx)(`b`,{children:`Most open sessions first`}),` keeps the repos you are working in on top — and moves a repo when a session in it starts or ends.`]})}),(0,Q.jsx)(tl,{id:`unfold-to-end`,label:`unfolding a repo shows its last row`,icon:ug,on:u,onChange:()=>{let e=!u;J(`unfoldToEnd`,e),q(`action:unfoldtoend.${e?`on`:`off`}`),K(e?`unfolding a repo scrolls to its last row`:`unfolding a repo scrolls to its header`)},note:`On the launcher, tapping a repo's chevron scrolls down until the last revealed row is on screen. Off, it scrolls to the repo's header instead. Per device.`}),(0,Q.jsx)(tl,{id:`net-pulse`,label:`connection strip`,icon:$h,on:l,onChange:()=>{let e=!l;J(`netPulse`,e),q(`action:netpulse.${e?`on`:`off`}`),K(e?`connection strip on — pings every 3s while the app is open`:`connection strip off`)},note:`A permanent bar: a state dot, the last ~90 seconds of round-trip times as a graph, and the current number.`,more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`It exists because every other connection readout here is retrospective — the banner appears once the socket is already gone, the activity strip once a request is already slow, and connection health only when you go and open it. None of them answers “is it bad right now, or is the app just being slow?”, which is the question you have while looking at a screen that has not changed.`}),(0,Q.jsx)(`p`,{children:`A graph rather than a number because an average cannot tell a steady 250 ms apart from 30 ms with every fourth ping lost, and only one of those is the link that eats prompts — unanswered pings are drawn as their own red marks, never averaged away.`}),(0,Q.jsx)(`p`,{children:`Costs one extra ping every 3 seconds, only while the app is in the foreground, and it only ever watches: a missed probe is drawn and nothing else, never a reconnect. Tap the bar for the full history.`})]})}),(0,Q.jsx)(qu,{id:`local-rt`,radio:!0,label:`desktop strip`,icon:oh,value:f,options:Gt.map(e=>({value:e,label:eu[e]})),onChange:e=>{J(`localRtBar`,e),q(`action:localrt.${e}`),K(e===`off`?`desktop strip off`:`desktop strip: ${eu[e]}`)},note:`A line for the desktop: how busy its CPU and GPU are and how much memory is left — and, while a local model is loaded, that model up front.`,more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`“While a model is loaded” still polls`}),` — it cannot know whether to draw itself without asking — so what it saves is a line of screen, not battery and not the desktop's work. Pick “always on” to keep it pinned, which is the only way to watch a model `,(0,Q.jsx)(`i`,{children:`not`}),` be there.`]}),(0,Q.jsx)(`p`,{children:`It exists for the one question a hosted model never raises and a local one raises constantly — “is the thing I am talking to still resident, or is the desktop swapping?” With no model loaded it is the machine itself — CPU, GPU, memory available, amber when memory is tight. Tap it for the full readout.`})]})}),(0,Q.jsx)(Hb,{id:`agent-warn`,label:`warn above this many agents`,icon:Im,cfg:p,k:`warn`,note:(0,Q.jsx)(Q.Fragment,{children:`The desktop strip's agent count turns amber, and says so once, when more than this many agents run at once — sessions mid-turn plus their subagents.`})}),(0,Q.jsx)(Hb,{id:`agent-alarm`,label:`alarm above this many agents`,icon:sh,cfg:p,k:`alarm`,note:(0,Q.jsx)(Q.Fragment,{children:`…and red, with a second notice, above this many. Nothing is stopped or refused at either mark.`}),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What counts.`}),` Every session on this desktop whose turn is running, plus every subagent (the Agent/Task tool) running under any session, background ones included. A session that is idle while its subagents work counts once per subagent, never also for itself.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Where it shows.`}),` On the desktop strip, between the CPU and the GPU. Past a mark the strip shows itself even when it is switched off above; its × hides it until the count passes your next mark. Tap the number for the count over time and which sessions hold the agents.`]})]})}),(0,Q.jsx)(gf,{id:`ui-reset`,label:`reset UI settings to default`,icon:Xh,onClick:()=>{(async()=>{if(await Lt({title:`Reset UI settings?`,lines:[`Theme, text and icon size, zooms, the strips, session tabs, layout switches and the ? button go back to their defaults on this phone.`,`Drafts, queued prompts, header commands, pins and everything synced stay as they are.`],confirmLabel:`Reset and reload`})){q(`action:settings.uiReset`);for(let e of By)_t(G[e]);location.reload()}})()},note:`Everything about how this phone draws the app, back to how it shipped. Your words and synced choices are kept.`})]})}function Bb({voice:e}){let t=X(`enterSends`),n=X(`dictLang`),r=X(`dictLangCodes`),i=X(`dictTerms`),a=X(`typingRoom`),o=X(`closeKbOnSend`),s=X(`shortcutCard`),c=Cl(),l=X(`btwToCli`),u=X(`busySend`),d=X(`toolsMode`),f=X(`hints`),p=X(`hintChip`),m=Se(r,n,Tu()),h=Ge(i),g=Ie(i);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qu,{id:`enter-sends`,radio:!0,label:`the Return key`,icon:_m,value:t?`send`:`newline`,options:[{value:`send`,label:`sends`},{value:`newline`,label:`inserts a newline`}],onChange:e=>J(`enterSends`,e===`send`),note:t?`Return sends the message (the key is labelled “send”). Shift/Ctrl/⌘+Return inserts a newline.`:`Return inserts a newline; only the Send button sends.`}),e.supported&&(0,Q.jsx)(qu,{id:`dictate-lang`,radio:!0,label:`dictation is read as`,icon:Gm,value:n,options:m.map(e=>({value:e.code,label:e.code===`auto`?`auto`:e.label,title:ve(e.code)})),onChange:e=>{q(`action:voice.lang`),J(`dictLang`,e)},note:ve(n),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`The phone used to send its own system language, and whisper `,(0,Q.jsx)(`b`,{children:`told`}),` a language does not transcribe another one — it translates into it. English spoken into a German phone came back as fluent German prose.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`auto`}),` is the answer for anybody who works in two languages: the transcriber detects what was said. Pin one where a short clip or a sentence full of English identifiers gets detected wrong.`]}),e.engine===`browser`&&(0,Q.jsxs)(`p`,{children:[`This phone is using the `,(0,Q.jsx)(`b`,{children:`browser's`}),` recogniser, which has no auto-detect and is given its language when the recording starts — so `,(0,Q.jsx)(`b`,{children:`auto`}),` here means this device's own language, and a change applies to the next recording.`]})]})}),e.supported&&(0,Q.jsx)(od,{id:`dictate-langs`,label:`languages on the microphone`,icon:Gm,value:m.map(e=>e.code),options:ze(Tu()).map(e=>({value:e.code,label:e.code===`auto`?`auto`:e.label})),onChange:e=>{q(`action:voice.langs`),J(`dictLangCodes`,e)},note:`The picker beside the microphone lists these — ${m.length} of ${ze(Tu()).length}.`,more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`Turn them all off and it goes back to `,(0,Q.jsx)(`b`,{children:`auto`}),`, English and German: a picker with nothing in it is a dead tap. The language in use is always listed, whether or not it is lit here.`]}),(0,Q.jsx)(`p`,{children:`Every language here is one the desktop's transcriber knows. Your phone's own language is in the list even when this app does not otherwise name it.`})]})}),e.supported&&(0,Q.jsx)(Ud,{id:`dictate-terms`,label:`words dictation should know`,icon:Xm,note:h.length?`${h.length} term${h.length===1?``:`s`}: ${h.slice(0,6).map(e=>e.term).join(`, `)}${h.length>6?`, …`:``}${g?` — ${g} more past the limit of 60 are not used`:``}`:`None yet. One per line, e.g. BA3 — optionally followed by what it comes out as: BA3: bee a three, be a 3`,more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`One term per line. After a colon, what it keeps coming back as, comma-separated: `,(0,Q.jsx)(`b`,{children:`BA3: bee a three, be a 3`}),`. A line starting with # is a comment.`]}),e.engine===`host`?(0,Q.jsxs)(`p`,{children:[`The desktop's transcriber is `,(0,Q.jsx)(`b`,{children:`told`}),` these words before it listens, which is what makes it spell them your way. Whatever still comes out wrong is corrected afterwards from the list after the colon.`]}):(0,Q.jsxs)(`p`,{children:[`This phone is using the `,(0,Q.jsx)(`b`,{children:`browser's`}),` recogniser, which cannot be told words in advance — here the list only corrects what comes out, so the part after the colon does the work.`]}),(0,Q.jsxs)(`p`,{children:[`A term that arrives split (`,(0,Q.jsx)(`b`,{children:`BA 3`}),`, `,(0,Q.jsx)(`b`,{children:`B.A.3`}),`) is joined back without being listed, and one with a digit or an inner capital is re-cased (`,(0,Q.jsx)(`b`,{children:`ba3`}),` → `,(0,Q.jsx)(`b`,{children:`BA3`}),`). An ordinary word is never re-cased, so `,(0,Q.jsx)(`b`,{children:`Go`}),` leaves "go" alone.`]})]}),children:(0,Q.jsx)(`textarea`,{className:`guardrail-text`,rows:4,value:i,placeholder:`BA3: bee a three, be a 3
|
|
11
|
-
Tiptoi`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>J(`dictTerms`,e.target.value)})}),(0,Q.jsx)(tl,{id:`close-kb-on-send`,label:`close the keyboard after Send`,icon:mm,on:o,onChange:()=>J(`closeKbOnSend`,!o),note:o?`Once a message goes, the keyboard drops so the answer gets the whole screen. Tap the box to type again.`:`The keyboard stays up after a send, ready for the next message.`}),c&&(0,Q.jsx)(tl,{id:`shortcut-card`,label:`hold Ctrl to see shortcuts`,icon:Em,on:s,onChange:()=>J(`shortcutCard`,!s),note:s?`Hold Ctrl, ⌘ or Alt alone for half a second and a card lists what each key does with it right now. Letting go hides it.`:`Holding a modifier shows nothing. The shortcuts themselves still work.`}),(0,Q.jsx)(qu,{id:`busy-send`,radio:!0,label:`Send while it works`,icon:bm,value:u,options:[{value:``,label:`ask`},{value:`now`,label:`send now`},{value:`idle`,label:`when it's free`}],onChange:e=>J(`busySend`,e),note:u===`now`?`Send on a session that is still working hands the words to claude, which takes them at its next pause.`:u===`idle`?`Send on a session that is still working hands the words to the desktop, which sends them when the turn ends.`:`Send on a session that is still working asks: send now, or when it's free.`}),(0,Q.jsx)(qu,{id:`btw-to-cli`,radio:!0,label:`/btw from the reader`,icon:sm,value:l,options:[{value:``,label:`ask`},{value:`switch`,label:`switch to the CLI`},{value:`stay`,label:`stay`}],onChange:e=>J(`btwToCli`,e),note:l===`switch`?`A /btw sent from the reader switches to the CLI, where its answer is — the reader cannot show it.`:l===`stay`?`A /btw sent from the reader stays in the reader; its row has an open the CLI button for the answer.`:`After a /btw sent from the reader, asks whether to switch to the CLI, where its answer is.`}),(0,Q.jsx)(tl,{id:`typing-room`,label:`typing room`,icon:xg,on:a,onChange:()=>J(`typingRoom`,!a),note:a?`While the caret is in the box, everything above it is hidden except the output and the outline button.`:`The header, status line, key row and file strips stay up while you type.`,more:(0,Q.jsx)(`p`,{children:`On, the keyboard costs the terminal nothing — tap the terminal to get the header back. Measured: with all the chrome up, a phone keyboard left two lines of output.`})}),(0,Q.jsx)(qu,{id:`reader-tools`,radio:!0,label:`tool calls in the reader`,icon:pm,value:d,options:[[`fold`,`fold runs`],[`list`,`one row each`],[`full`,`download details`]].map(([e,t])=>({value:e,label:t})),onChange:e=>J(`toolsMode`,e),note:d===`fold`?`A run of tool calls collapses into one “N tool calls” line, so the conversation stays on screen.`:d===`list`?`Every tool call gets its own row.`:`Tool inputs and results come down with the transcript — everything is there offline.`,more:d===`full`?(0,Q.jsx)(`p`,{children:`At the cost of a much bigger download and a much bigger offline cache, which is what makes a long conversation slow to load on a phone.`}):(0,Q.jsx)(`p`,{children:`What a call ran and what came back stays on the host until you open one. Tap a folded run to see the calls, tap one to load it.`})}),(0,Q.jsx)(qu,{id:`hints-mode`,radio:!0,label:`button hints`,icon:eg,value:f.mode,options:[[`first`,`explain once`],[`press`,`long-press only`],[`off`,`off`]].map(([e,t])=>({value:e,label:t})),onChange:e=>J(`hints`,{mode:e,seen:Ic()}),note:f.mode===`first`?`The handful of actions whose icon can't be guessed explain themselves the first time you tap them, then never again.`:f.mode===`press`?`Nothing interrupts a tap. Long-press any button to read what it does.`:`No hints at all — not even on long-press.`,more:(0,Q.jsx)(`p`,{children:`Hold, re-aim, fork, fan out and keep-newest are the ones that cannot be guessed from an icon. A long press never fires the button it explains.`})}),(0,Q.jsx)(gf,{id:`hints-explain`,label:`explain mode`,icon:eg,onClick:()=>{Ru(!0),Yn().nav.close(`settings`)},note:`Turns every tap into an explanation until you leave it — the way back after everything has been dismissed.`,more:(0,Q.jsx)(`p`,{children:`Also on the “?” chip in the launcher and session headers.`})}),(0,Q.jsx)(tl,{id:`hints-chip`,label:`? button in the headers`,icon:eg,on:p!==`hidden`,onChange:()=>J(`hintChip`,p===`hidden`?`asked`:`hidden`),note:p===`hidden`?`Removed from the launcher and session headers. Long-press any button, or explain mode above, still explains it.`:`The ? in the launcher and session headers turns on explain mode. Leaving it the first time asks whether it can go.`}),(0,Q.jsx)(gf,{id:`hints-reset`,label:`explain them again`,icon:Xh,cant:f.seen===0?`nothing has been dismissed yet`:void 0,onClick:()=>{Sd(),At.reload(`hints`),K(`hints reset`)},note:f.seen===0?`Dismissals follow you to your other devices.`:`${f.seen} dismissed. This makes them all first-time again, on every device.`})]})}function Vb({install:e,reconnect:t}){let n=Uu(),r=X(`autoSend`),i=X(`serialSessions`),a=X(`confirmQueue`),o=X(`saver`),s=X(`bgFresh`),c=Yn().queue.entries.filter(e=>e.status===`queued`);return(0,Q.jsxs)(Q.Fragment,{children:[e.installed?(0,Q.jsx)(Ud,{id:`install`,label:`install this app`,icon:rh,note:`Running as an installed app.`}):n===`insecure`?(0,Q.jsx)(Ud,{id:`install`,label:`install this app`,icon:nm,children:(0,Q.jsxs)(vd,{children:[`Installing needs a secure context — you're on `,location.protocol,`//`,location.host,`, and a service worker can't register over plain HTTP. Front the host with TLS (the command under Notifications), reopen on the HTTPS name, then install from here.`]})}):e.canInstall?(0,Q.jsx)(gf,{id:`install`,label:`install this app`,icon:nm,onClick:async()=>{q(`action:install.app`);let t=e.evt.current;if(!t)K(`install offer expired — reload and try again`);else{e.evt.current=null,e.taken();try{t.prompt(),await t.userChoice}catch{K(`install cancelled`)}}},note:`Adds it to your home screen and runs it full-screen, without browser chrome.`}):fl()?(0,Q.jsx)(Ud,{id:`install`,label:`install this app`,icon:nm,note:(0,Q.jsxs)(Q.Fragment,{children:[`To install: tap Share, then `,(0,Q.jsx)(`b`,{children:`Add to Home Screen`}),`. iOS has no in-app install button.`]})}):(0,Q.jsx)(Ud,{id:`install`,label:`install this app`,icon:nm,note:`No install offer from this browser right now — it may already be installed, or the browser needs another visit first.`}),(0,Q.jsx)(tl,{id:`auto-send`,label:`auto-send the queue`,icon:sg,on:r,onChange:()=>{J(`autoSend`,!r),K(r?`queued messages wait for “Send now”`:`queued messages will send themselves`)},note:(0,Q.jsxs)(Q.Fragment,{children:[`Messages sent while the link is down go out the moment the host is reachable again.`,c.length>0?` ${c.length} waiting now.`:``]}),more:(0,Q.jsx)(`p`,{children:`They are kept in this browser, so a reload or the phone killing the tab doesn't lose them — Return included. Several messages for the SAME session go out one at a time, in order, each waiting for the one before it to be submitted. The host de-duplicates delivery receipts, so a re-send can never type the same prompt twice. Off holds them until you tap “Send now”.`})}),(0,Q.jsx)(tl,{id:`serial-sessions`,label:`one session at a time per repo`,icon:lm,on:i,onChange:()=>{J(`serialSessions`,!i),K(i?`queued work all starts at once`:`queued work runs one session at a time per repo`)},note:`On, a queued open waits until every session in that directory has finished its turn.`,more:(0,Q.jsx)(`p`,{children:`Queue five prompts for one repo on a train and, with this off, all five open their own agent the second the link is back: one account's usage limit spent five ways in parallel, five half-finished turns when it runs out, and five agents editing the same working tree. A worktree counts as its own directory — that is what makes running work in parallel safe in the first place. Only opens that carry a prompt are held (a bare terminal runs nothing), and “Send this one now” always overrides it.`})}),(0,Q.jsx)(tl,{id:`confirm-queue`,label:`ask on reconnect`,icon:bg,on:a,onChange:()=>{a&&(t.holdRef.current=!1,t.setReconnectAsk(!1),t.flush()),J(`confirmQueue`,!a),K(a?`the queue drains without asking`:`you'll be asked before the queue goes out`)},note:`Text typed offline was written against what the session looked like THEN — ask before it goes out.`,more:(0,Q.jsx)(`p`,{children:`Send it, review and edit it first, or hold it. Off = it just goes (subject to auto-send above). A message you send with the link UP is never held by this.`})}),c.length>0&&(0,Q.jsx)(gf,{id:`queue-manage`,label:`manage ${c.length} queued`,icon:lm,opens:!0,onClick:()=>{q(`action:queue.manage`),Yn().nav.open(`queue`)}}),(0,Q.jsx)(tl,{id:`data-saver`,label:`data saver`,icon:bg,on:o,onChange:()=>{let e=!o;J(`saver`,e),q(`action:datasaver`),K(e?`data saver on — smaller images, slower polling`:`data saver off`),e&&Nb(`app`)},note:`For a roaming or hotel link: smaller image copies, slower background polling. Per device.`,more:(0,Q.jsx)(`p`,{children:`Asks the host for smaller images in the grids and the full-screen viewer — “full res” is always one tap away — and slows the reader view's background polling.`})}),(0,Q.jsx)(Of,{id:`bg-fresh`,label:`in the background`,icon:rm,min:0,max:Ia.length-1,step:1,value:Math.max(0,Ia.indexOf(s)),readout:rn(s),onInput:e=>J(`bgFresh`,Ia[e]??s),onCommit:()=>q(`action:bgfresh`),note:No(s),more:(0,Q.jsx)(`p`,{children:`Battery against how recent the screen is that you can read with no signal. Left is fresher, right saves more. Takes effect the next time the app goes to the background. Per device.`})})]})}function Hb({id:e,label:t,icon:n,cfg:r,k:i,note:a,more:o}){let s=[...Zu,0],c=r[i],l=s.indexOf(c);l<0&&(l=s.findIndex(e=>e>c)),l<0&&(l=s.length-2);let u=e=>{q(`action:agentWarn.${i}`),J(`agentWarn`,{...r,[i]:e})};return(0,Q.jsx)(Mc,{id:e,label:t,icon:n,readout:c===0?`off`:String(c),onLess:l>0?()=>u(s[l-1]):null,onMore:l>=0&&l<s.length-1?()=>u(s[l+1]):null,lessLabel:`fewer`,moreLabel:s[l+1]===0?`off`:`more`,note:a,more:o})}var Ub=Cn(``),Wb=0,Gb=Cn(``);function Kb(e){let t=up(Ub),n=Jo(),r=up(Or),i=e.pluginView?r:null,a=i??n,o=e.pluginView?`pluginSettings`:`settings`;(0,Z.useEffect)(()=>(Wb++,()=>{Wb--,queueMicrotask(()=>{Wb===0&&(wo.set(null),Or.set(null))})}),[]);let s=Yn(),{status:c}=s.conn,{tailscaleIp:l}=s.conn.info,u=Tl(t,a);return(0,Q.jsxs)(`div`,{className:`sheet`,children:[(0,Q.jsx)(If,{title:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Oh,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),` Settings`]}),onClose:()=>s.nav.close(o),children:(0,Q.jsxs)(`div`,{className:`conn conn-${c}`,children:[c,l?` · ${l}`:``]})}),(0,Q.jsx)(ro,{keys:te,thing:`your settings`}),(0,Q.jsx)(`div`,{className:`set-doors set-doors-top`,children:(0,Q.jsxs)(`button`,{className:`set-door`,title:`Every plugin: on or off, what it does, where it shows up`,onClick:()=>s.nav.open(`pluginManager`),children:[(0,Q.jsx)(ih,{size:14}),` Plugins`]})}),(0,Q.jsx)(xu,{value:t,onChange:e=>{wo.set(null),Or.set(null),Ub.set(e)}}),(0,Q.jsx)(Pu,{value:u,children:(0,Q.jsxs)(`div`,{className:`settings`,children:[(0,Q.jsxs)(Js,{id:`sessions`,title:`Sessions`,icon:Im,children:[Jy(`sessions`,{to:0}),(0,Q.jsx)(qb,{pickBackend:e.pickBackend}),Jy(`sessions`,{from:0})]}),(0,Q.jsx)(Js,{id:`notifications`,title:`Notifications`,icon:Mm,children:Jy(`notifications`)}),(0,Q.jsxs)(Js,{id:`appearance`,title:`Appearance`,icon:Uh,children:[Jy(`appearance`,{to:0}),(0,Q.jsx)(zb,{}),Jy(`appearance`,{from:0})]}),(0,Q.jsxs)(Js,{id:`writing`,title:`Writing & reading`,icon:_m,children:[Jy(`writing`,{to:0}),(0,Q.jsx)(Bb,{voice:e.voice}),Jy(`writing`,{from:0})]}),(0,Q.jsxs)(Js,{id:`offline`,title:`Offline & data`,icon:nm,children:[Jy(`offline`,{to:0}),(0,Q.jsx)(Vb,{install:e.install,reconnect:e.reconnect}),Jy(`offline`,{from:0})]}),(0,Q.jsxs)(Js,{id:`connection`,title:`Connection`,icon:zm,children:[Jy(`connection`,{to:0}),(0,Q.jsx)(Jb,{redial:e.redial}),Jy(`connection`,{from:0})]}),(0,Q.jsxs)(Js,{id:`tools`,title:`Tools & diagnostics`,icon:wh,children:[Jy(`tools`,{to:-10}),(0,Q.jsxs)(`div`,{className:`set-doors`,children:[Jy(`tools`,{from:-10,to:0}),(0,Q.jsx)(Yb,{})]}),Jy(`tools`,{from:0})]}),(0,Q.jsx)(Rl,{tally:u,onClear:()=>{i?s.nav.close(o):(wo.set(null),Ub.set(``))}})]})})]})}function qb({pickBackend:e}){let t=Yn(),n=t.world.backends,i=t.world.launch,a=t.launch.setOpt,o=X(`launchAsk`),s=X(`closeWhenDone`),c=X(`confirmClose`),l=X(`localSessions`);return(0,Q.jsxs)(Q.Fragment,{children:[Rd(n)&&(0,Q.jsxs)(bc,{id:`launch-backend`,label:`backend`,control:(0,Q.jsx)(`select`,{value:i.backend??`claude`,onChange:t=>e(t.target.value===`claude`?void 0:t.target.value),children:Us(n).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:xn(e)},e.id))}),note:(0,Q.jsxs)(Q.Fragment,{children:[`What a new session runs.`,ys(n,i.backend)?` ${ys(n,i.backend)}.`:``,Pp(n,i.backend)?` ${Pp(n,i.backend)}`:``]}),more:(0,Q.jsx)(`p`,{children:`Sessions already open keep the binary they started with. The window size is said only when it is known — never a 0k, and never claude's window borrowed for a local model.`}),children:[cp(n,i.backend)&&(0,Q.jsx)(nf,{className:`act-cants`,children:(0,Q.jsx)(Xc,{children:cp(n,i.backend)})}),(0,Q.jsx)(Cf,{className:`set-note`,cants:[[`context meter`,`contextMeter`],[`transcript`,`transcript`],[`slash commands`,`slash`],[`effort`,`effort`],[`remote control`,`remoteControl`]].flatMap(([e,t])=>{let r=po(n,i.backend,t);return r?[{label:e,reason:r}]:[]})})]}),(0,Q.jsx)(bc,{id:`launch-model`,label:`model`,control:(0,Q.jsx)(vn,{backends:n,backend:i.backend,value:i.model,onChange:e=>a({model:e})})}),aa(n,i.backend).length===0&&po(n,i.backend,`effort`)&&(0,Q.jsx)(nf,{children:po(n,i.backend,`effort`)}),aa(n,i.backend).length>0&&(0,Q.jsx)(bc,{id:`launch-effort`,label:`effort`,control:(0,Q.jsxs)(`select`,{value:i.effort??``,onChange:e=>a({effort:e.target.value||void 0}),children:[(0,Q.jsx)(`option`,{value:``,children:`default`}),aa(n,i.backend).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})}),ga(n,i.backend).length>0&&(0,Q.jsxs)(bc,{id:`launch-permission`,label:`permission`,control:(0,Q.jsxs)(`select`,{className:i.permissionMode&&Yy.has(i.permissionMode)?`danger`:``,value:i.permissionMode??``,onChange:e=>{let t=e.target.value||void 0;!t||!Yy.has(t)?a({permissionMode:t}):(e.target.value=i.permissionMode??``,(async()=>{await Lt({title:t,lines:Xy,confirmLabel:`Run without asking`})&&a({permissionMode:t})})())},children:[(0,Q.jsx)(`option`,{value:``,children:`default`}),ga(n,i.backend).map(e=>(0,Q.jsxs)(`option`,{value:e,children:[e,Yy.has(e)?` — no approvals`:``]},e))]}),children:[i.permissionMode&&Yy.has(i.permissionMode)&&(0,Q.jsxs)(nf,{className:`danger-note`,children:[(0,Q.jsx)(gh,{size:13,style:{verticalAlign:`-2px`}}),` New sessions run every tool call without asking. Nothing will stop a destructive command.`,` `,(0,Q.jsx)(`button`,{className:`link-btn`,onClick:()=>a({permissionMode:void 0}),children:`back to default`})]}),ar(i,n)&&(0,Q.jsx)(vd,{tone:`plain`,children:ar(i,n)})]}),Yt(n,i.backend,`remoteControl`)&&(0,Q.jsx)(tl,{id:`launch-remote`,label:`remote control`,icon:bg,on:!!i.remoteControlled,onChange:()=>a({remoteControlled:!i.remoteControlled}),note:`Starts new sessions with --remote-control, so they are steerable from claude.ai.`,more:(0,Q.jsx)(`p`,{children:`Applies to sessions you start from here. Sessions already open keep the flags they were started with.`})}),(0,Q.jsx)(tl,{id:`launch-ask`,label:`ask before each launch`,icon:eg,on:o,onChange:()=>{q(`action:launchAsk.toggle`),J(`launchAsk`,!o)},note:(0,Q.jsxs)(Q.Fragment,{children:[`On, starting a new session asks `,Rd(n)?`which backend and model`:`which model`,` first, starting from the values above.`]}),more:(0,Q.jsx)(`p`,{children:`The answer applies to that session only — these defaults stay as they are. Resuming a conversation never asks: it keeps the launch it was recorded with.`})}),(0,Q.jsx)(Qy,{}),(0,Q.jsx)(tl,{id:`confirm-close`,label:`ask before closing a session`,icon:Nm,on:c,onChange:()=>{q(`action:confirmClose.toggle`),J(`confirmClose`,!c),K(c?`sessions close without asking`:`you'll be asked before a close loses work`)},note:`On, closing a session with uncommitted changes, commits not merged or shells still running asks first.`,more:(0,Q.jsx)(`p`,{children:`Off, the close goes straight through and the toast still names what was left behind. Its conversation stays under “Recently closed” either way; uncommitted changes stay in the working tree.`})}),(0,Q.jsx)(gf,{id:`automation`,label:ec.automation,icon:Vm,opens:!0,onClick:()=>{q(`overlay:schedule`),kp(null)},note:`Prompts that run on their own: on a clock, every week, or around a usage window.`}),(0,Q.jsx)(tl,{id:`close-when-done`,label:`close automatic sessions when done`,icon:Zm,on:s,onChange:()=>{q(`action:closeWhenDone.toggle`),J(`closeWhenDone`,!s)},note:s?(0,Q.jsx)(Q.Fragment,{children:`On: a session that a backlog or scheduled item opened closes itself once its work is done and it has sat idle for 10 minutes (the desktop's default). Its conversation stays under “Recently closed” and reopens where it left off.`}):(0,Q.jsx)(Q.Fragment,{children:`Off: a session that a backlog or scheduled item opened stays open until you close it, so you can read it and carry on in it.`}),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Which sessions this covers.`}),` Only the ones `,A.name,` opens for work you queued: a backlog item (whether the backlog fired it or you tapped fire), each run of a scheduled item, a prompt an agent posted for later, and the session that continues one of these after a usage limit. Their titles start with “backlog ·”.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Never closed by this.`}),` Sessions you open yourself, the backlog's “open a session here”, one prompt sent to several repos, a launch you queued for later, and anything you reopened from “Recently closed”.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What “done” means.`}),` The turn has ended and the idle wait (10 minutes by default) has passed with nobody watching it on a phone, no background agent and no background shell still running under it. A session waiting on your answer is never closed.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`One item, its own answer.`}),` Open a row on the backlog (or use the choice under “To” when you schedule one) to say “keep open” or “close when done” for that item only; it wins over this switch.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What a slot is.`}),` The desktop runs at most 3 automatic sessions at the same time (the default; `,(0,Q.jsx)(`code`,{children:r(`BACKLOG_SESSIONS`)}),` on the desktop changes it). A “backlog ·” session holds one of those slots only while it is working (a turn running, a box waiting on you, a background shell or agent still going); finished and idle, it holds none, even left open. The backlog's “open a session here” counts the same way. Sessions you open yourself never do.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Why there is a limit.`}),` Every session is a real `,(0,Q.jsx)(`code`,{children:`claude`}),` process on your desktop, using its memory and your account's usage. Without a limit, a desktop that comes back after a few days with a pile of due items would start them all inside a minute.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Leaving sessions open does not stop queued work.`}),` With this switch off, finished sessions stay open for you to read, and the next backlog or scheduled item still starts as soon as fewer than 3 are working. When all 3 are working, it waits and says “waiting for a free slot”; a slot frees itself when one goes idle, and “close one to make room” lists the working ones if you want to stop one sooner.`]})]})}),(0,Q.jsx)(qu,{id:`local-sessions`,label:`local model sessions at once`,icon:oh,value:l,options:[{value:``,label:`desktop default`},{value:`1`,label:`1`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`0`,label:`no limit`}],onChange:e=>{q(`action:localSessions.set`),J(`localSessions`,e)},note:l===`0`?(0,Q.jsx)(Q.Fragment,{children:`No limit: automatic work on a local model starts whenever it is due, even while another local session is working.`}):l?(0,Q.jsxs)(Q.Fragment,{children:[`At most `,l,` session`,l===`1`?``:`s`,` on a local model working at once. Queued work waits for the local model; one you start yourself still starts, and says so.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`The desktop's own setting — 1 unless `,(0,Q.jsx)(`code`,{children:r(`LOCAL_SESSIONS`)}),` says otherwise.`]}),more:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What counts.`}),` A session on a model that runs on this desktop (Claude Code on a local model, or another backend on a local model) while a turn is running. An open local session that is idle holds nothing.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`What waits.`}),` Backlog items, scheduled work, prompts an agent posted for later, and each repo of a sweep. Their row says “waiting for the local model — 1 local session is working”.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`The model is loaded first.`}),` Before queued work opens on a local model, the desktop loads that model on Ollama and waits for it. If Ollama is not running or does not have the model, the row says so and tries again; it never switches to another model.`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`b`,{children:`Background helpers.`}),` A summary or naming pass sent to the same local runner is skipped while a local coding session is working on a different model, so it cannot swap that model out mid-turn.`]})]})}),(0,Q.jsx)(gf,{id:`hosted-notice`,label:`show the hosted-model notice again`,icon:Xh,onClick:()=>{q(`action:hostedAck.reset`),B_(),K(`hosted-model notice reset — the next hosted launch will show it again`)},note:`The first session on a model that runs on somebody else's server stops once and says what that means.`,more:(0,Q.jsx)(`p`,{children:`After you accept, it stays out of the way. Local models and Claude Code never show it.`})})]})}function Jb({redial:e}){let t=Yn(),n=t.conn.info.auth,i=t.conn.status,a=up(Gb);return(0,Q.jsxs)(Q.Fragment,{children:[n.canManage?(0,Q.jsx)(Ud,{id:`lan-password`,label:`LAN password`,icon:gg,note:n.enabled?`A password is set. Devices reaching this host over the local network (not Tailscale) must enter it.`:`No password set. While a LAN interface is bound (${r(`ALLOW_PUBLIC`)}=1), LAN devices are blocked until you set one here.`,more:(0,Q.jsx)(`p`,{children:`Changing or clearing the password logs out every gated device. Password management is only available on this trusted path — LAN devices can never set it.`}),children:(0,Q.jsxs)(`div`,{className:`set-chips`,children:[(0,Q.jsx)(`input`,{className:`auth-input`,type:`password`,placeholder:n.enabled?`new password`:`set a password`,value:a,onChange:e=>Gb.set(e.target.value),style:{maxWidth:220}}),a.length>=4?(0,Q.jsx)(Y,{variant:`primary`,onClick:()=>{t.conn.send({t:`auth.set`,password:a}),Gb.set(``),K(n.enabled?`password changed`:`password set`)},children:n.enabled?`change`:`set password`}):(0,Q.jsx)(`span`,{className:`set-cant-why`,children:a.length===0?`type a password of at least four characters`:`at least four characters`}),n.enabled&&(0,Q.jsx)(Y,{variant:`danger`,onClick:()=>{t.conn.send({t:`auth.clear`}),K(`password cleared — LAN blocked`)},children:`clear`})]})}):(0,Q.jsx)(gf,{id:`lan-logout`,label:`log out this device`,icon:gg,onClick:async()=>{await Dn.auth.logout(),e()},note:`Connected over the local network (authenticated). The password is managed from the desktop or a Tailscale connection.`}),n.canManage&&n.enabled&&(0,Q.jsx)(tl,{id:`lan-gate-tailscale`,label:`gate Tailscale too`,icon:gg,on:n.gateTailscale,onChange:()=>t.conn.liveSend({t:`auth.gateTailscale`,enabled:!n.gateTailscale},n.gateTailscale?`Tailscale devices no longer need the password`:`Tailscale devices now need the password`),note:`Require the password from Tailscale peers as well. Off = Tailscale trusted; loopback stays exempt either way.`}),(0,Q.jsx)(gf,{id:`sync-push`,label:`use this device's copy`,icon:_h,cant:i===`open`?void 0:`no connection to the host right now`,onClick:()=>{let e=rf();K(e?`pushing ${e} setting${e===1?``:`s`} from this device`:`nothing to push`)},note:`Makes this device's copy the one every other client gets. The newest edit wins.`,more:(0,Q.jsx)(`p`,{children:`Prompt templates, fan-out presets, header commands, the prompt pad, the toolbar layout and your new-session defaults are kept on the host, so every client — this phone, a desktop tab, the Android app — has the same ones. The send queue, drafts and anything about this device's link stay here. If a client adopted the wrong list (the first one to connect after an update seeds the host), push from the device that has the good one.`})})]})}function Yb(){let e=Yn().nav.open;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(gf,{id:`tool-net-health`,compact:!0,label:`connection health`,icon:$h,title:`what the link has been doing to your prompts`,onClick:()=>{q(`overlay:nethealth`),e(`nethealth`)}}),(0,Q.jsx)(gf,{id:`tool-storage`,compact:!0,label:`storage`,icon:km,title:`what this phone is holding, and what clearing any of it would cost`,onClick:()=>{q(`overlay:storage`),e(`storage`)}}),(0,Q.jsx)(gf,{id:`tool-speedtest`,compact:!0,label:`speed test`,icon:Bh,title:`connection speed test + diagnostics`,onClick:()=>e(`speedtest`)}),(0,Q.jsx)(gf,{id:`tool-host-stat`,compact:!0,label:`host stat`,icon:oh,title:`host CPU / memory load`,onClick:()=>void Dd()}),(0,Q.jsx)(gf,{id:`tool-repo-setup`,compact:!0,label:`repo setup`,icon:Hm,title:`repo setup checklist`,onClick:()=>e(`setup`)}),(0,Q.jsx)(gf,{id:`tool-secret`,compact:!0,label:`secret`,icon:xm,title:`set a secret (write-only)`,onClick:()=>e(`secret`)}),(0,Q.jsx)(gf,{id:`tool-features`,compact:!0,label:`feature usage`,icon:um,title:`which features you actually use (and which you never do)`,onClick:()=>e(`features`)})]})}function Xb(e){let{send:t,sessions:n,pendingSession:r,removeQueued:i}=e,{sendSeed:a,setSendSeed:o,sendResumeRef:s,dispatchIntent:c,noteSendAim:l,retireSendSource:u,openSent:d}=t;return a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Lc,{seed:a,sessions:r&&!Zg(r.id)?[...n,r]:n,repos:e.visibleRepos,outbox:e.outbox,online:e.online,usage:e.usage,intents:e.intents,backends:e.backends,launchDefaults:e.launch,buildName:t.buildNames,onAttach:e.onAttach,onAnnotate:e.onAnnotate,onBrowseRepoFiles:e.onBrowseRepoFiles,resume:s.current,onDecide:e=>{s.current=e},onReattach:t.reattachKept,onReplace:t.pickReplacement,onSend:e=>{if(!c(e,a))return!1;let t=e.target.kind===`session`||e.target.kind===`repo`?e.target.cwd:null;return t&&l(t,{when:e.when}),u(a),a.onPosted?.(),a.openAfter&&e.target.kind===`session`&&d(e.target.sessionId),!0},onDiscard:a.ackId||a.padId?()=>{q(`action:send.discard`),a.ackId&&i(a.ackId),a.padId&&Ms([a.padId]),Ur(Rc),K(`discarded`)}:void 0,onClose:()=>{s.current=null,o(null),e.closeSheet(`send`)}}),(0,Q.jsx)(`input`,{ref:t.replacePick,type:`file`,hidden:!0,onChange:t.onPickReplacement})]}):null}var Zb=Yl(Xn);pf(e=>Zb.sheets.get(Od(e))?.keep?.()??null),kc((e,t)=>Zb.leave(e,t));var Qb=new Map;for(let[e,t]of Zb.sheets){let n=/^feature:([^/]+)\//.exec(e);if(!n)continue;let r=()=>t.render(Yn());Qb.set(e,()=>(0,Z.createElement)($c,{feature:n[1],what:`its sheet`,children:(0,Z.createElement)(r)}))}function $b(){let e={};for(let[t,n]of Zb.sheets)e[t]=Qb.get(t)??(()=>n.render(Yn()));return e}function ex(e){let{overlay:t,setOverlay:n,closeSheet:r,connRef:i,status:a,setReconnectAsk:o,submitInput:s,holdQueueRef:c,flushOutbox:l,removeQueued:u,pendingSession:d,insertCompose:f,setOutlineJump:p,setView:m,active:h,sessions:g,visibleRepos:_,outbox:v,usage:y,intents:b,launchCore:x,sessionCant:S,pickBackend:C,refreshRepos:w,sendCore:T,sendSeed:E,voice:D,installed:O,canInstall:k,installEvt:A,setCanInstall:j,gitRepoId:M,activeRepoId:ee,repos:N,reposAt:P,backends:F}=e,I=(e,t)=>{n(null),K(`${e} failed to open — ${t}`)},te=e=>(0,Q.jsx)(Kb,{pluginView:e,pickBackend:C,voice:D,install:{installed:O,canInstall:k,evt:A,taken:()=>j(!1)},reconnect:{holdRef:c,setReconnectAsk:o,flush:l},redial:()=>i.current.reconnect()}),L={...$b(),...x.sheets,slash:()=>h?(0,Q.jsx)(ac,{cwd:h.cwd,backends:F,backend:cn(F,hc(h))?hc(h):void 0,onClose:()=>n(null),unsupported:cn(F,hc(h))?void 0:S(h,`slash`)??void 0,onPick:(e,t)=>{t?(n(null),s(h.id,h.cwd,e,`command`)&&K(i.current.status===`open`?`running ${e}`:`${e} queued — it runs when the link is back`)):(f(e),n(null))}}):null,settings:()=>te(!1),pluginSettings:()=>te(!0),git:()=>{let e=Wu(),t=Va(M,e,ee,N);if(!t)return(0,Q.jsx)(zf,{focus:e,list:gi({rows:N,readAt:P}),session:!!h,onClose:()=>n(null)});let r=N.find(e=>e.id===t);return(0,Q.jsx)(wp,{repoId:t,onAskAgent:r?e=>T.openSend(zi(e,r)):void 0,stored:r?.gitFailed,failures:r?.gitFailures,onDone:or,onBrowse:()=>Qa(t,`git`),fileSheet:r?(e,n)=>(0,Q.jsx)(ed,{repoId:t,repoName:r.repoName,path:e.path,edit:e.edit,onClose:n}):void 0,onClose:()=>{n(null),w()}})},outline:()=>h?(0,Q.jsx)(gc,{sessionId:h.id,title:h.title,onJump:e=>{q(`action:outline.jump`),p({n:e,key:Date.now()}),m(!0),n(null)},onClose:()=>n(null)}):null,send:()=>E?(0,Q.jsx)(Xb,{send:T,sessions:g,pendingSession:d,visibleRepos:_,outbox:v,online:a===`open`,usage:y,intents:b,removeQueued:u,backends:F,launch:x.launch,closeSheet:r,onAttach:(e,t)=>Td(t,e),onAnnotate:(e,t)=>Ou(t,e,`send`),onBrowseRepoFiles:sp}):null},R=t?L[t]?.()??null:null;return R?(0,Q.jsx)(Ky,{name:t??``,onFail:I,children:R},t??``):null}function tx(e){let{connRef:t,setLaunch:n,setHiddenRepoIds:r}=e;(0,Z.useEffect)(()=>(Wd(e=>t.current.send(e)),sd(e=>{switch(e){case G.launch:n(qo());break;case G.hiddenRepos:r(Co());break;case G.repoColors:op()}})),[])}function nx(e){let{repos:t,focusRepo:n,outbox:r,bl:i}=e,[a,o]=(0,Z.useState)(Co),s=(0,Z.useMemo)(()=>na(t.filter(e=>!a.has(e.id)&&(!n||N(e)===n))),[t,a,n]),c=(0,Z.useMemo)(()=>na(t.filter(e=>a.has(e.id)&&(!n||N(e)===n))),[t,a,n]),l=(0,Z.useMemo)(()=>new Set(c.map(e=>e.worktreePath)),[c]),u=(0,Z.useMemo)(()=>{let e=new Map;for(let t of r){if(!Jp(t)||!t.cwd||t.status===`failed`)continue;let n=e.get(t.cwd);e.set(t.cwd,{status:n?.status===`pending`?`pending`:t.status,n:(n?.n??0)+1})}return e},[r]),d=(0,Z.useMemo)(()=>n?new Set(t.filter(e=>N(e)===n).map(e=>e.worktreePath)):null,[t,n]),f=e=>!d||d.has(e)||Fu(e)===n,p=(0,Z.useCallback)(e=>!l.has(e)&&(!d||d.has(e)||Fu(e)===n),[l,d,n]),m=(0,Z.useMemo)(()=>i.items.filter(e=>p(e.repoDir)),[i.items,p]);function h(e){o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),mt(G.hiddenRepos,[...n]),n})}return{hiddenRepoIds:a,setHiddenRepoIds:o,toggleHideRepo:h,visibleRepos:s,hiddenRepos:c,hiddenRepoPaths:l,openingCwds:u,focusPaths:d,cwdInFocus:f,cwdVisible:p,visibleBacklogItems:m}}function rx(e,t){let{setOverlay:n,activeRepoId:r,active:i,readMode:a,fireReader:o,send:s,geomRef:c}=t,l=e=>ix(e,t);switch(q(`toolbar:${e}`),e){case`model`:n(`model`);break;case`cmd`:n(`slash`);break;case`diff`:ln(r,n)||K(`not a known repo`);break;case`ctx`:l(`/context`);break;case`usage`:l(`/usage`);break;case`teleport`:l(`/teleport`);break;case`remote`:l(`/remote-control`);break;case`tasks`:l(`/tasks`);break;case`backlog`:vs(i?.cwd);break;case`history`:n(`history`);break;case`outline`:if(!i){K(`no active session`);break}a?o(`outline`):n(`outline`);break;case`find`:if(!i){K(`no active session`);break}a?o(`find`):_u(i.id);break;case`refresh`:if(!i){K(`no active session`);break}a?o(`refresh`):K(`refresh is the reader's — the terminal is live`);break;case`scrollback`:eo();break;case`fork`:if(!i)break;s({t:`session.fork`,id:i.id,cols:c.current.cols,rows:c.current.rows}),K(`forking conversation into a new session…`);break;case`companion`:if(!i){K(`no active session`);break}t.openCompanionShell(i);break;default:Tv(e)}}function ix(e,t){let{active:n,submitInput:r}=t;n&&(q(`action:slash:${e.split(/\s/)[0].replace(/[^a-zA-Z0-9-]/g,``)||`other`}`),r(n.id,n.cwd,e,`command`))}var ax=1e4;function ox(e){let{refreshRepos:t,activeId:n,repos:r,overlay:i}=e,a=r.some(e=>e.gitRunning||e.buildRunning);(0,Z.useEffect)(()=>{if(n||!a)return;let e=setInterval(t,ax);return()=>clearInterval(e)},[n,a]);let o=(0,Z.useRef)(i);(0,Z.useEffect)(()=>{o.current===`git`&&i!==`git`&&t(),o.current=i},[i])}function sx(e){let{status:t,refreshRepos:n,activeId:r,active:i,wantNavRef:a,firedIdRef:o,bl:s,sessions:c,attach:l,repos:u,overlay:d}=e;(0,Z.useEffect)(()=>{n()},[t]),(0,Z.useEffect)(()=>{r&&n()},[r,i?.idle]),(0,Z.useEffect)(()=>{r||n()},[r]);let f=(0,Z.useRef)(d);(0,Z.useEffect)(()=>{let e=f.current;f.current=d,e&&!d&&!r&&n()},[d]),ox({refreshRepos:n,activeId:r,repos:u,overlay:d}),(0,Z.useEffect)(()=>{if(r)return;let e=()=>{document.visibilityState===`visible`&&n()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[r]),(0,Z.useEffect)(()=>{if(!a.current||!o.current)return;let e=s.items.find(e=>e.id===o.current);if(e?.status===`running`&&e.sessionId){let t=c.find(t=>t.id===e.sessionId);t&&(a.current=!1,o.current=null,l(t))}},[s.items,c])}function cx(){let e=(0,Z.useRef)(null),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(()=>Ns());return(0,Z.useEffect)(()=>{let t=t=>{t.preventDefault(),e.current=t,n(!0)},r=()=>{e.current=null,n(!1),i(!0),K(`installed — open it from your home screen`)};return window.addEventListener(`beforeinstallprompt`,t),window.addEventListener(`appinstalled`,r),()=>{window.removeEventListener(`beforeinstallprompt`,t),window.removeEventListener(`appinstalled`,r)}},[]),{installEvt:e,canInstall:t,setCanInstall:n,installed:r}}function lx(e,t,n,r=null){let i=an(e,r),a=(e,r,a)=>{let o=n?`${e} tag-fresh`:e,s=n?`something new since you last looked${r?` · `:``}${r}`:r,c=n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(em,{size:11,fill:`currentColor`}),` `,a]}):a;if(!t)return(0,Q.jsx)(df,{className:o,title:s,children:c});let l=t.isOn(i);return(0,Q.jsx)(df,{className:`${o} tag-filter${l?` on`:``}`,role:`button`,tabIndex:0,title:`${s}${s?` · `:``}${l?`showing only these — tap to clear the filter`:`tap to show only the ${lo[i]} sessions`}`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t.toggle(i))},onClick:e=>{e.stopPropagation(),t.toggle(i)},children:c})},o=nr(e,r);return a(o.cls,o.title,o.body)}function ux(e,t){let n=e.limit;return!n||n.blocked||!e.running||n.autoContinue===t?null:n.autoContinue?(0,Q.jsxs)(df,{className:`limit-on`,title:`set for this session: auto-continue after a usage-limit reset is ON here — the global setting is off`,children:[(0,Q.jsx)(bm,{size:12}),` auto`]}):(0,Q.jsxs)(df,{className:`limit-off`,title:`set for this session: auto-continue after a usage-limit reset is OFF here — the global setting is on, so a hit limit waits for you in this session only`,children:[(0,Q.jsx)(bm,{size:12}),` no auto`]})}function dx(e){let t=jn(e);return t&&(0,Q.jsx)(df,{className:t.cls,title:t.title,children:t.body})}function fx(e){let t=Wi(e);return t&&(0,Q.jsx)(df,{className:t.cls,title:t.title,children:t.body})}function px(e){let t=e.contextSpark,n=e.running?Te(t?.liveAgentTok,t?.liveAgentAt,Date.now(),fs()):null;return!n||t?.liveAgentTok==null?null:(0,Q.jsxs)(df,{className:`cost-heavy`,title:`${n}\n\nTap the context readout for the whole picture. Nothing here stops it.`,children:[(0,Q.jsx)(Im,{size:12}),` `,t.liveAgentType?`${t.liveAgentType} `:`agent `,`re-reads `,Be(t.liveAgentTok)]})}function mx(e,t){let n=e.shellList;if(!n?.length)return null;let r=p(n,Date.now()),i=r.working>0?`coding`:`idle`;return(0,Q.jsxs)(df,{className:`${i} tag-filter`,role:`button`,tabIndex:0,title:`tap to see what each background shell is doing`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())},onClick:e=>{e.stopPropagation(),t()},children:[(0,Q.jsx)(Fm,{size:12}),` `,E(r)]})}var hx=e=>e?.contextSpark?.turns||null,gx=e=>e==null?``:` · ${e} turn${e===1?``:`s`} logged so far`;function _x(e,t){let n=mu(e,Date.now());return n?(0,Q.jsxs)(df,{className:`${n.cls} tag-filter`,role:`button`,tabIndex:0,title:n.title,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())},onClick:e=>{e.stopPropagation(),t()},children:[(0,Q.jsx)(fg,{size:12}),` `,n.text]}):null}function vx(e){let{sessions:t,backends:n,sessionRepoName:r}=e,i=X(`agentWarn`),a=(0,Z.useRef)(`ok`);(0,Z.useEffect)(()=>{let e=t.map(e=>{let t=r(e);return{id:e.id,label:ta(e,t,Un(t)),repo:t,working:!e.idle&&an(e,n)===`coding`,agents:e.running?(e.agents??[]).map(e=>({what:e.what,model:e.model,startedAt:e.startedAt})):[]}}),o=Qs(e.map(e=>({working:e.working,agents:e.agents.length}))),s=qd(o.total,i);sf(o,e,s),ud(a.current,s)&&K(Hl(o,s,i)),a.current=s},[t,n,i])}Ys(G.tabOpensShared,(e,t)=>dc(e,t,Date.now())),sd(ip,[G.tabOrderShared,G.tabOpensShared]),Lb();function yx(e){let{sessions:t,sessionRepoName:n,activeId:r,repos:i,attach:a,closeSession:o,backends:s}=e;(0,Z.useEffect)(()=>{Ya(t.map(e=>{let t=n(e);return{id:e.id,label:ta(e,t),repo:t,status:an(e,s),createdAt:e.createdAt,...An(e,hx(e)),...e.companionOf?{companionOf:e.companionOf}:{}}}),r,i)},[t,r,i,s]),(0,Z.useEffect)(()=>{let e=e=>e.detail?.id??``,n=n=>{let r=t.find(t=>t.id===e(n));r&&a(r)},r=n=>{let r=t.find(t=>t.id===e(n));r&&o(r)};return window.addEventListener(_l,n),window.addEventListener(zs,r),()=>{window.removeEventListener(_l,n),window.removeEventListener(zs,r)}}),vx({sessions:t,backends:s,sessionRepoName:n})}var bx=be;function xx(e){let t=at(e);return t?{notif:t}:e===bx?{view:`notifications`}:e.startsWith(`plugin:`)&&e.length>7?{plugin:e.slice(7)}:{sessionId:e}}function Sx(e){if(!e.startsWith(`host:`))return null;let t=e.indexOf(`|`);if(t<0)return null;let n=e.slice(5,t),r=e.slice(t+1);return!De(n)||r.startsWith(`host:`)?null:{hostId:n,rest:r}}function Cx(e){let{reposRef:t,initRoute:n,sessions:r,attach:i,setOverlay:a}=e;(0,Z.useEffect)(()=>{pc(e=>{let n=t.current.find(t=>t.id===e);return n?{repoName:n.repoName,repoDir:n.worktreePath}:void 0})},[]),(0,Z.useEffect)(()=>{n.file&&!Gn(n.file.relPath)&&yp(n.file),n.plugin&&dn(n.plugin),n.notif&&Hr(n.notif)},[]),(0,Z.useEffect)(()=>{if(!(`serviceWorker`in navigator))return;let e=e=>{if(e.data?.type===`open-session`){let t=r.find(t=>t.id===e.data.sessionId);t&&i(t)}else if(!Sr(e.data)){if(e.data?.type===`open-pulls`)a(`pull`);else if(e.data?.type===`download-file`&&e.data.file){let t=e.data.file;Gn(t.relPath)?mc(t):yp(t)}else if(e.data?.type===`open-image`&&e.data.image){let t=r.find(t=>t.id===e.data.sessionId);t&&i(t),hu(e.data.image,e.data.sessionId)}else e.data?.type===`open-plugin`&&typeof e.data.plugin==`string`?dn(e.data.plugin):e.data?.type===`open-notif`&&e.data.item&&Hr(e.data.item)}};return navigator.serviceWorker.addEventListener(`message`,e),()=>navigator.serviceWorker.removeEventListener(`message`,e)},[r]);let o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(null);(0,Z.useEffect)(()=>is(e=>{let t=Sx(e);if(t&&t.hostId!==Oc()){Au(t.hostId,t.rest);return}let n=t?t.rest:e;if(!n)return;let r=xx(n);`plugin`in r?dn(r.plugin):`notif`in r?Hr(r.notif):`view`in r?wi():(o.current=n,c(n))}),[]),(0,Z.useEffect)(()=>{let e=o.current;if(!e)return;let t=r.find(t=>t.id===e);t&&(o.current=null,c(null),i(t))},[r,s])}function wx(e){let{outbox:t,activityFiled:n,activityConfirmedDone:r,allBufsRef:i}=e,a=t.filter(e=>e.status===`failed`&&!n.has(`queue:${e.ackId}`)&&!r.has(`queue:${e.ackId}`)).length;(0,Z.useEffect)(()=>{Pa(a)},[a]),(0,Z.useEffect)(()=>(Bv(()=>zc()||i.current.size>0),()=>Bv(null)),[])}function Tx(){let[e,t]=(0,Z.useState)(()=>Zr(G.snapSessions,[])),[n,r]=(0,Z.useState)(()=>Zr(G.snapRecent,[])),[i,a]=(0,Z.useState)(()=>Zr(G.snapClosed,[])),[o,s]=(0,Z.useState)(()=>Zr(G.snapRepos,[])),[c,l]=(0,Z.useState)(li),[u,d]=(0,Z.useState)(0),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null);return{sessionsRaw:e,setSessions:t,recent:n,setRecent:r,closed:i,setClosed:a,repos:o,setRepos:s,reposAt:c,setReposAt:l,reposFailAt:u,setReposFailAt:d,intents:f,setIntents:p,backends:m,setBackends:h,update:g,setUpdate:_,meter:v,setMeter:y,updateResultSeenRef:(0,Z.useRef)(0)}}var Ex=400,Dx=2e3,Ox=ut,kx=400;function Ax(){let e=xc(e=>e.ops),[,t]=(0,Z.useState)(0),n=(0,Z.useRef)(!1),r=(0,Z.useRef)(!1),[i,a]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!e.length)return;let n=window.setInterval(()=>t(e=>e+1),500);return()=>window.clearInterval(n)},[e.length]),(0,Z.useEffect)(()=>{if(e.length){a(!1);return}if(!n.current)return;a(!0);let t=window.setTimeout(()=>{n.current=!1,r.current=!1,a(!1)},kx);return()=>window.clearTimeout(t)},[e.length]);let o=e.length?e.reduce((e,t)=>e.started<=t.started?e:t):null,s=o?Date.now()-o.started:0;if(o&&s>=Ex&&(n.current=!0),o&&s>=Dx&&(r.current=!0),!n.current||!o&&!i)return null;let c=Math.floor(s/1e3),l=!!o&&s>=Ox;return(0,Q.jsxs)(`div`,{className:`net-activity${l?` stalled`:``}`,role:`status`,"aria-live":`polite`,children:[(0,Q.jsx)(`div`,{className:`net-bar`,children:(0,Q.jsx)(`span`,{})}),r.current&&o&&(0,Q.jsxs)(`div`,{className:`net-chip`,children:[l?(0,Q.jsx)(vh,{size:12}):(0,Q.jsx)(th,{size:12,className:`spin`}),(0,Q.jsxs)(`span`,{children:[o.label,e.length>1?` +${e.length-1}`:``,` · `,c,`s`,l?Vn(oo(),np()?.id??null):``]})]})]})}function jx(e,t,n){return t.trim()?e.filter(e=>!n(e)):[...e]}function Mx(e){if(!e)return[];let t=[];for(let n of Array.from(e.items??[])){if(n.kind!==`file`)continue;let e=n.getAsFile();e&&t.push(e)}return t.length?t:Array.from(e.files??[])}var Nx=e=>!!e&&Array.from(e.types??[]).includes(`Files`);function Px(e,t){let n=Yn(),r=n.world.activeRepo?.id;r?zc()?Ec(e).then(r=>{r?(n.say.track(`action:attach.${t}.repeat`),n.say.toast(`That picture is already open for marking — not added twice`)):Fx(e,t)}):(n.say.track(`action:attach.${t}`),n.files.attachFiles(e,r)):n.say.toast(`No repo for this session — files have nowhere to go`)}function Fx(e,t){let n=Yn(),r=e.filter(si).length,i=r===e.length?r===1?`this picture`:`these ${r} pictures`:e.length===1?`this file`:`these ${e.length} files`;n.say.confirm({title:`Append ${i}?`,lines:[r?`Pictures are marked next, after the one on screen — its marks stay.`:`Uploaded into the inbox, its path added to the message.`],confirmLabel:`Append`,cancelLabel:`Leave it`,tone:`info`}).then(r=>{r&&(n.say.track(`action:attach.${t}.append`),cl(e))})}function Ix(){let[e,t]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let e=e=>{let t=jx(Mx(e.clipboardData),e.clipboardData?.getData(`text/plain`)??``,si),n=e.target,r=Yn();Jt({files:t.length,editable:!!n&&(n.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(n.tagName)),inCompose:!!n?.closest?.(`.compose, .ann-prompt`),sheet:r.nav.overlay!=null,annotating:zc(),repoId:r.world.activeRepo?.id??null,handled:e.defaultPrevented})!==`ignore`&&(e.preventDefault(),Px(t,`paste`))},t=e=>{Nx(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`))};return document.addEventListener(`paste`,e),document.addEventListener(`dragover`,t),document.addEventListener(`drop`,t),()=>{document.removeEventListener(`paste`,e),document.removeEventListener(`dragover`,t),document.removeEventListener(`drop`,t)}},[]),{dragOver:e,dropProps:{onDragOver(e){Nx(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,t(!0))},onDragLeave(e){e.currentTarget.contains(e.relatedTarget)||t(!1)},onDrop(e){if(!Nx(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),t(!1);let n=Mx(e.dataTransfer);n.length&&Px(n,`drop`)}}}}function Lx(){try{return typeof window<`u`&&window.isSecureContext&&typeof navigator.mediaDevices?.getDisplayMedia==`function`}catch{return!1}}function Rx(e,t){return e===`NotAllowedError`?/system/i.test(t)?`The system refused screen capture — allow this browser under Privacy & Security → Screen Recording, then restart it`:null:e===`NotFoundError`?`No window or screen to capture was offered`:e===`NotSupportedError`||e===`TypeError`?`This browser cannot capture a window`:`Window capture failed: ${t||e}`}function zx(e){let t=e=>String(e).padStart(2,`0`);return`window-${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}.png`}async function Bx(){let e;try{let t=globalThis.CaptureController,n=t?new t:void 0;e=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:`window`},audio:!1,selfBrowserSurface:`exclude`,surfaceSwitching:`exclude`,monitorTypeSurfaces:`include`,...n?{controller:n}:{}});try{n?.setFocusBehavior?.(`no-focus-change`)}catch{}}catch(e){let t=e,n=Rx(t?.name??``,t?.message??``);return n?{error:n}:{cancelled:!0}}try{let t=await Vx(e);return t?{file:new File([t],zx(new Date),{type:`image/png`})}:{error:`The window gave no picture`}}catch(e){return{error:`Window capture failed: ${e?.message||e}`}}finally{for(let t of e.getTracks())t.stop()}}async function Vx(e){let t=document.createElement(`video`);t.muted=!0,t.playsInline=!0,t.srcObject=e;try{await t.play(),await new Promise(e=>{let n=t,r=setTimeout(e,1e3);n.requestVideoFrameCallback?n.requestVideoFrameCallback(()=>{clearTimeout(r),e()}):t.readyState>=2?(clearTimeout(r),e()):t.addEventListener(`loadeddata`,()=>{clearTimeout(r),e()},{once:!0})});let e=t.videoWidth,n=t.videoHeight;if(!e||!n)return null;let r=document.createElement(`canvas`);r.width=e,r.height=n;let i=r.getContext(`2d`);return i?(i.drawImage(t,0,0,e,n),await new Promise(e=>r.toBlob(e,`image/png`))):null}finally{t.srcObject=null}}var Hx=16,$=e=>e.preventDefault();function Ux(){try{return window.matchMedia?.(`(pointer: coarse)`).matches??!1}catch{return!1}}function Wx(e){let{api:t,active:n,sessions:r,outbox:i,online:a,repoForCwd:o,activeRepoId:s,pickImageFor:c,pickFileFor:l,visibleBacklogItems:u,setOverlay:d}=e,{uploading:f,parking:p,upProg:m,uploadPending:h,uploadRowLinger:g,cancelUploads:_}=e.uploads,{compose:v,setCompose:y,composeRef:b,cmdHistory:x,histIdx:S,setHistIdx:C,clearArmed:w,setClearArmed:T,setComposeFocused:E,snippetOpen:D,setSnippetOpen:O,sendMode:k,setSendMode:A,sendWhere:j,setSendWhere:M,sendWhereSid:ee,setSendWhereSid:N,sendMenu:P,setSendMenu:F,cliMode:I,enterSends:te,voice:L,aimedSession:R,stepHistory:ne,clearCompose:z,appendSnippet:B,chord:V,toggleCliMode:H,onPipeInput:re,flushPipe:ie,onPipeKey:U,onComposeKey:ae,aimHere:oe,sendCompose:W,openComposeSend:se,keepOnPad:ce,noteSendAim:le,secretAskLine:ue,secret:de,setSecret:fe,secretShown:pe,setSecretShown:me,dismissSecret:he,sendSecret:ge,secretFillContext:_e}=t,ve=I||Fi(null,n.backend),ye=Pl(),{dragOver:be,dropProps:xe}=Ix();(0,Z.useLayoutEffect)(()=>{t.growCompose()},[I]);let Se=n?.id,Ce=Zg(Se);(0,Z.useEffect)(()=>{Jg(Se)&&!Ux()&&b.current?.focus()},[Se,b]);let we=ru();return(0,Z.useEffect)(()=>{if(!we||!Jf()||Ux()||I)return;let e=b.current;if(e){e.focus();try{e.setSelectionRange(e.value.length,e.value.length)}catch{}}},[we,b,I]),(0,Q.jsxs)(Q.Fragment,{children:[n&&!Ce&&(()=>{let e=ld(j,{repoName:o(n.cwd)?.repoName??Fu(n.cwd),sessionName:R?st(R):null});return e?(0,Q.jsxs)(`div`,{className:`compose-aim`,children:[(0,Q.jsxs)(`span`,{className:`compose-aim-what`,children:[(0,Q.jsx)(wh,{size:12}),` `,e]}),(0,Q.jsxs)(Y,{onPointerDown:$,title:`send to ${il(`this`)} instead — the conversation on screen`,onClick:()=>{q(`action:compose.where.here`),oe()},children:[(0,Q.jsx)(sg,{size:12}),` `,`aim it here`]})]}):null})(),(0,Q.jsxs)(`div`,{className:`compose${be?` drop-over`:``}`,...xe,children:[(h||g)&&(0,Q.jsxs)(`div`,{className:`upload-progress`,title:`images upload in the background; a prompt naming one is delivered after it lands`,children:[(0,Q.jsxs)(`div`,{className:`upload-progress-line`,children:[h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yg,{size:12,className:`spin`}),` `,f,p>0?` · still reading it`:``]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(rh,{size:12}),` uploads done`]}),h&&(0,Q.jsxs)(Y,{className:`upload-cancel`,onPointerDown:$,onClick:_,title:`cancel uploads`,children:[(0,Q.jsx)(Lh,{size:12}),` cancel`]})]}),h&&v.trim()&&(0,Q.jsxs)(`div`,{className:`upload-acts`,children:[(0,Q.jsx)(`span`,{className:`upload-acts-what`,children:p>0?`Send goes as soon as the picture is readable`:`your prompt is ready to go — it is delivered after the picture lands`}),(0,Q.jsxs)(Y,{onPointerDown:$,"data-hint":`queue.sendnow`,title:`post it now — if it names a picture still moving, the queue still delivers it after the bytes`,onClick:()=>{q(`action:upload.sendnow`),W(`now`)},children:[(0,Q.jsx)(ig,{size:14}),` send now`]}),(0,Q.jsxs)(Y,{onPointerDown:$,"data-hint":`queue.hold`,title:`park it until this session is free, instead of typing it in mid-turn`,onClick:()=>{q(`action:upload.hold`),W(`idle`)},children:[(0,Q.jsx)(bm,{size:14}),` let it wait`]})]}),(0,Q.jsx)(`div`,{className:`upload-bar`,children:(0,Q.jsx)(`div`,{className:`upload-bar-fill${m?.waiting?` waiting`:``}`,style:{width:`${m&&m.total>0?m.pct:0}%`}})})]}),n&&(0,Q.jsx)(za,{compact:!0,debounceMs:700,text:v,repoId:o(n.cwd)?.id??null,outbox:i,online:a,onRemove:e=>y(t=>jl(t,e))}),P&&!I&&(0,Q.jsxs)(`div`,{className:`row-more send-more`,children:[!Ce&&(0,Q.jsxs)(`div`,{className:`send-where`,children:[(0,Q.jsx)(`span`,{className:`send-where-lead`,children:`Runs in`}),Cc().map(e=>(0,Q.jsxs)(`button`,{className:`more-act${j===e.key?` on`:``}`,onPointerDown:$,title:e.title,onClick:()=>{q(`action:compose.where.${e.key}`),M(e.key),e.key!==`other`&&N(null),le(n?.cwd,{where:e.key})},children:[e.key===`new`?(0,Q.jsx)(Um,{size:Hx}):e.key===`other`?(0,Q.jsx)(wh,{size:Hx}):(0,Q.jsx)(sg,{size:Hx}),e.label]},e.key))]}),j===`other`&&(()=>{let e=r.filter(e=>e.running&&e.id!==n?.id);return e.length?(0,Q.jsx)(`div`,{className:`send-where-pick`,children:e.map(e=>(0,Q.jsxs)(`button`,{className:`row${ee===e.id?` sched-on`:``}`,onPointerDown:$,title:`send to ${st(e)}`,onClick:()=>{q(`action:compose.where.pick`),N(e.id)},children:[(0,Q.jsx)(pd,{children:e.title}),(0,Q.jsx)(Si,{s:e}),(0,Q.jsx)(nc,{children:e.turnActive?`working`:`idle`})]},e.id))}):(0,Q.jsx)(`div`,{className:`send-where-pick`,children:(0,Q.jsxs)(Zd,{children:[`No other session is open — `,(0,Q.jsx)(`em`,{children:`a new session`}),` opens one.`]})})})(),of().map(e=>(0,Q.jsxs)(`button`,{className:`more-act${e.mode&&k===e.mode?` on`:``}`,onPointerDown:$,title:e.title,onClick:()=>{F(!1),e.mode?A(e.mode):e.key===`pad`?ce():se()},children:[e.icon===`hourglass`?(0,Q.jsx)(bm,{size:Hx}):e.icon===`elsewhere`?(0,Q.jsx)(yh,{size:Hx}):e.icon===`pad`?(0,Q.jsx)(vm,{size:Hx}):(0,Q.jsx)(sg,{size:Hx}),e.label]},e.key)),(0,Q.jsxs)(`button`,{className:`more-act more-close`,onPointerDown:$,title:`close this menu — nothing is sent and the mode stays as it is`,onClick:()=>F(!1),children:[(0,Q.jsx)(Lh,{size:Hx}),` close`]})]}),D&&(0,Q.jsxs)(`div`,{className:`snippet-pop`,children:[(0,Q.jsxs)(`div`,{className:`snippet-pop-head`,children:[(0,Q.jsx)(`span`,{children:`Snippets`}),(0,Q.jsxs)(Y,{onPointerDown:$,onClick:()=>{O(!1),d(`snippets`)},title:`Manage snippets`,children:[(0,Q.jsx)(qm,{size:14}),` manage`]}),(0,Q.jsx)(Y,{onPointerDown:$,onClick:()=>O(!1),title:`Close`,children:(0,Q.jsx)(Lh,{size:14})})]}),(0,Q.jsxs)(`div`,{className:`snippet-pop-list`,children:[ye.length===0&&(0,Q.jsx)(Zd,{children:`No snippets yet — tap “manage” to add one.`}),ye.map(e=>(0,Q.jsxs)(`button`,{className:`snippet-pop-item`,onPointerDown:$,title:e.text,onClick:()=>{q(`action:snippet.insert`),B(e)},children:[(0,Q.jsx)(`span`,{className:`snippet-pop-title`,children:e.title}),(0,Q.jsx)(`span`,{className:`snippet-pop-preview`,children:e.text.replace(/\s+/g,` `).trim()})]},e.id))]})]}),ue?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`secret-ask`,children:[(0,Q.jsx)(xm,{size:12}),`asked on screen: `,(0,Q.jsx)(`code`,{children:ue}),` — typed straight in, never kept as a draft or in history`]}),(0,Q.jsxs)(`div`,{className:`secret-row`,children:[(0,Q.jsx)(`input`,{type:pe?`text`:`password`,value:de,onChange:e=>fe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),ge())},placeholder:`password`,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,spellCheck:!1,enterKeyHint:`send`,onFocus:()=>E(!0),onBlur:()=>E(!1)}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>me(e=>!e),"aria-pressed":pe,title:pe?`Hide what is typed`:`Show what is typed`,children:pe?(0,Q.jsx)(Rm,{size:18}):(0,Q.jsx)(Hh,{size:18})})]}),(0,Q.jsxs)(`div`,{className:`compose-bar`,children:[(0,Q.jsxs)(Y,{className:`secret-other`,onPointerDown:$,onClick:he,title:`Back to the message box — this line is not asking for a password`,children:[(0,Q.jsx)(Lh,{size:14}),` not a password`]}),(()=>{let e=_e();return e?Ln(e):[]})().map(e=>(0,Q.jsxs)(Y,{onPointerDown:$,title:e.unavailable??e.label,onClick:()=>{e.unavailable?K(e.unavailable):(q(`action:compose.secret.fill`),e.open())},children:[(0,Q.jsx)(e.icon,{size:14}),` `,e.label]},e.key)),(0,Q.jsx)(`div`,{className:`send-split`,children:(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:ge,title:`Type it into the prompt and press Enter — nothing is kept`,children:[(0,Q.jsx)(xm,{size:Hx}),` Send`]})})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{ref:b,className:I?`pipe`:void 0,"data-compose":``,value:I?av:v,onChange:I?re:e=>{y(e.target.value),C(-1),T(!1)},onCompositionEnd:I?e=>ie(e.currentTarget):void 0,placeholder:`Message or /command…`,rows:2,autoCapitalize:ve?`off`:void 0,autoCorrect:ve?`off`:void 0,spellCheck:!ve&&void 0,enterKeyHint:I?`enter`:te?`send`:`enter`,onKeyDown:I?U:ae,onFocus:()=>E(!0),onBlur:()=>E(!1)}),I?(0,Q.jsxs)(`div`,{className:`compose-bar cli-bar`,children:[(0,Q.jsxs)(`span`,{className:`cli-note${a?``:` warn`}`,children:[(0,Q.jsx)(sm,{size:13}),V.armed?` ${V.heldName} held — the next key you type or tap goes with it${a?``:` (link is down: it is dropped, not held)`}`:a?` keys go straight to the session — nothing is queued or confirmed`:` link is down — these keystrokes are dropped, not held`]}),V.armed?(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:V.clear,title:`Let go of the held keys — your draft comes back`,children:[(0,Q.jsx)(Lh,{size:Hx}),` let go`]}):(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:H,title:`Back to composing — messages queue, survive a dead link and are confirmed on the host`,children:[(0,Q.jsx)(Lh,{size:Hx}),` leave CLI`]})]}):(0,Q.jsxs)(`div`,{className:`compose-bar`,children:[(0,Q.jsxs)(`div`,{className:`compose-scroll`,children:[(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>x.length===0?K(`nothing sent yet — no earlier message to recall`):ne(-1),title:`Previous sent command`,children:(0,Q.jsx)(Om,{size:18})}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>S===-1?K(`this is your draft — there is nothing newer`):ne(1),title:`Next sent command`,children:(0,Q.jsx)(Jm,{size:18})}),(0,Q.jsx)(`button`,{className:`mic ${w?`on`:``}`,onPointerDown:$,onClick:()=>v?z():K(`the message box is already empty`),title:w?`Tap again to clear`:`Clear message box`,children:(0,Q.jsx)(Ch,{size:18})}),(0,Q.jsx)(ma,{voice:L,onPointerDown:$}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>s?c(s):K(`not a known repo`),title:`Send image to this repo`,children:(0,Q.jsx)(cm,{size:18})}),Lx()&&(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>s?void Bx().then(e=>{`file`in e?Px([e.file],`window`):`error`in e&&K(e.error)}):K(`not a known repo`),title:`Picture of a window or screen on this computer — opens in the annotator, then attached`,children:(0,Q.jsx)(Rh,{size:18})}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>s?l(s):K(`not a known repo`),title:`Attach a file of any kind (PDF, doc, zip, audio…) to this repo — images open in the annotator`,children:(0,Q.jsx)(Pm,{size:18})}),(0,Q.jsx)(`button`,{className:`mic ${D?`on`:``}`,onPointerDown:$,onClick:()=>O(e=>!e),title:`Insert a saved snippet`,children:(0,Q.jsx)(om,{size:18})}),(0,Q.jsx)(`button`,{className:`mic`,onPointerDown:$,onClick:()=>d(`pad`),title:`Prompt pad — park this thought without picking a target yet`,children:(0,Q.jsx)(vm,{size:18})}),(()=>{let e=uc(n?u.filter(e=>e.repoDir===n.cwd):u),t=[...e.waiting,...e.failed];return(0,Q.jsxs)(`button`,{className:`mic show-backlog`,onPointerDown:$,onClick:()=>n&&t.length?Ld(n.cwd,t,gp(e)):vs(n?.cwd),title:n?`Backlog for this repo — ${Ja(e)}`:`Show backlog`,children:[(0,Q.jsx)(_g,{size:18}),e.waiting.length>0&&(0,Q.jsxs)(`span`,{className:`mic-badge`,children:[(0,Q.jsx)(bm,{size:9}),e.waiting.length]}),e.failed.length>0&&(0,Q.jsxs)(`span`,{className:`mic-badge failed`,children:[(0,Q.jsx)(Fh,{size:9}),e.failed.length]})]})})()]}),(0,Q.jsxs)(`div`,{className:`send-split`,children:[(0,Q.jsxs)(`button`,{className:`send`,onPointerDown:$,onClick:()=>W(),title:wu(k,j,R?st(R):null),children:[k===`idle`?(0,Q.jsx)(bm,{size:Hx}):(0,Q.jsx)(sg,{size:Hx}),` `,jf(k)]}),(0,Q.jsx)(`button`,{className:`send send-mode${P?` on`:``}`,onPointerDown:$,onClick:()=>F(e=>!e),"aria-expanded":P,"data-hint":`compose.options`,title:`Change what Send does — which session it runs in, and now or when it's free — or send it somewhere else or later`,children:(0,Q.jsx)(yh,{size:14})})]})]})]})]})]})}var Gx=14;function Kx({view:e,onSendNow:t,onPastBudget:n,onHold:r,onOpenQueue:i,onOpenBacklog:a,keepFocus:o,editableText:s,onEdit:c,onCancel:l}){let[u,d]=(0,Z.useState)(null);if(u)return(0,Q.jsx)(`div`,{className:`nextp nextp-editing`,children:(0,Q.jsxs)(`div`,{className:`form`,style:{width:`100%`},children:[(0,Q.jsx)(Gi,{inline:!0,rows:3,prompts:[u.text],autoFocus:!0,onChange:e=>d({...u,text:e[0]??``}),placeholder:`the next prompt…`}),!u.text.trim()&&(0,Q.jsx)(Dc,{children:`Nothing to save — type the prompt, or cancel to keep it as it was.`}),(0,Q.jsxs)(Kl,{children:[u.text.trim()&&(0,Q.jsx)(`button`,{className:`send`,onClick:()=>{let e=u.text.trim();e&&c(u.id,u.holder,e)&&d(null)},children:`Save`}),(0,Q.jsx)(Y,{onClick:()=>d(null),children:`Cancel`})]})]})});if(!e)return null;let f=s(e.id,e.holder);return(0,Q.jsx)(_d,{slot:`next-prompt`,stowKey:`${e.holder}:${e.id}`,label:`next prompt`,detail:e.behind>0?`+${e.behind}`:void 0,icon:e.held?bm:ig,children:(0,Q.jsxs)(`div`,{className:`nextp${e.held?` nextp-held`:``}`,children:[(0,Q.jsx)(`span`,{className:`nextp-mark`,children:e.held?(0,Q.jsx)(bm,{size:Gx}):(0,Q.jsx)(ig,{size:Gx})}),(0,Q.jsxs)(`span`,{className:`nextp-body`,children:[(0,Q.jsxs)(`span`,{className:`nextp-words`,children:[`next: `,e.words]}),e.tie&&(0,Q.jsx)(`span`,{className:`nextp-why nextp-tie`,children:e.tie}),(0,Q.jsxs)(`span`,{className:`nextp-why`,children:[e.why,e.behind>0?` · ${e.behind} more behind it`:``]}),e.held&&!e.wall&&(0,Q.jsx)(`span`,{className:`nextp-why`,children:Yd(!1)}),e.budgetHeld&&!e.wall&&(0,Q.jsx)(`span`,{className:`nextp-why`,children:`past the budget: it still waits for this turn to end`})]}),e.held?e.wall?(0,Q.jsx)(`span`,{className:`nextp-cant`,children:e.wall}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Y,{"data-hint":`queue.sendnow`,onPointerDown:o,title:Yd(!1),onClick:()=>t(e.id,e.holder),children:[(0,Q.jsx)(ig,{size:Gx}),` send now`]}),e.budgetHeld&&(0,Q.jsxs)(Y,{onPointerDown:o,title:`lifts the usage budget for this prompt only — it still goes in when this session is free`,onClick:()=>n(e.id),children:[(0,Q.jsx)(Bh,{size:Gx}),` `,xf(1)]})]}):(0,Q.jsxs)(Y,{"data-hint":`queue.hold`,onPointerDown:o,title:`hand it to the desktop and let it go in when this session is free, instead of typing it in mid-turn`,onClick:()=>r(e.id),children:[(0,Q.jsx)(bm,{size:Gx}),` when it's free`]}),f!=null&&(0,Q.jsxs)(Y,{onPointerDown:o,title:`rewrite this prompt before it goes in`,onClick:()=>d({id:e.id,holder:e.holder,text:f}),children:[(0,Q.jsx)(qm,{size:Gx}),` edit`]}),f!=null&&(0,Q.jsxs)(Y,{onPointerDown:o,title:`don't send it — the words are kept on the pad`,onClick:()=>l(e.id,e.holder),children:[(0,Q.jsx)(Lh,{size:Gx}),` cancel`]}),e.holder===`desktop`?(0,Q.jsxs)(Y,{onPointerDown:o,title:`this repo's waiting work on the desktop`,onClick:a,children:[(0,Q.jsx)(_g,{size:Gx}),` backlog`]}):(0,Q.jsxs)(Y,{onPointerDown:o,title:`the whole queue for every session`,onClick:i,children:[(0,Q.jsx)(lm,{size:Gx}),` queue`]}),(0,Q.jsx)(Df,{})]})})}function qx(e,t){return t?`timed · ${e} · tied to this conversation — it goes into this session; close it before then and the desktop reopens this conversation and sends it there`:`timed · ${e} · tied to this session — keep it open until then; closed, it waits with nowhere to go`}function Jx(e){let t=e.trim().replace(/\s+/g,` `);return t.length>56?`${t.slice(0,56)}…`:t}function Yx(e,t){let n=t(e).trim().replace(/\s+/g,` `);return n?Jx(n):e.mode===`upload`?`a file`:`an action`}function Xx(e){if(!e.sessionId)return null;let t=e.entries.filter(t=>t.sessionId===e.sessionId),n=t.filter(e=>e.status===`queued`),r=n[0],i=e.pinned??[];if(!r&&!i.length)return null;let a=!!r&&t.slice(0,t.indexOf(r)).some(e=>e.mode===`upload`&&e.status!==`failed`);if(!e.busy&&!e.wall&&e.online&&!a&&(r||!i.length))return null;if(!r){let t=i[0],n=e.wall??t.why??(e.busy?`waits for this turn to end`:`the desktop runs it when this session is free`);return{holder:`desktop`,id:t.id,words:Jx(t.words),held:!0,behind:i.length-1,why:!e.online&&e.asOf?`${n} · as of ${e.asOf}`:n,tie:t.tie??null,budgetHeld:!!t.budgetHeld&&e.online,wall:e.wall??(e.online?null:`no connection — the desktop is holding it and runs it when this session is free`)}}let o=!!r.holdUntilIdle,s=e.wall?e.wall:e.online?a?`waits for the picture it names to finish uploading`:o?`waits for this turn to end`:`goes in as soon as the queue reaches it`:`waits for the link`;return{holder:`phone`,id:r.ackId,words:Yx(r,e.prose),held:o,behind:n.length-1,why:s,tie:null,budgetHeld:!1,wall:e.wall??(e.online?a?`the picture it names is still uploading — it goes the moment the bytes land`:null:`no connection — it goes the moment the link is back`)}}function Zx(e){let{active:t,outboxRef:n,isPendingId:r,sendQueuedNow:i,editQueued:a,toggleHoldQueued:o,handToDesktop:s,liveSend:c,setOverlay:l}=e,{items:u,waiting:d,snapAt:f}=os(),p=new Map(e.intents.map(e=>[e.id,e])),m=Date.now(),h=(t,r)=>{if(r===`phone`){let e=n.current.find(e=>e.ackId===t);return e&&un(e)?e.text:null}let i=u.find(e=>e.id===t);return i&&i.status===`queued`&&e.online?i.text:null};return(0,Q.jsx)(Kx,{view:Xx({entries:e.outbox,sessionId:t.id,busy:t.hooked?!!t.turnActive:!!t.running&&!t.idle,online:e.online,wall:e.holdWall(t.id),prose:Mo,pinned:u.filter(e=>e.targetSessionId===t.id&&e.autoFire&&e.status===`queued`).sort((e,t)=>e.order-t.order).map(e=>({id:e.id,words:e.text,why:d[e.id],budgetHeld:(()=>{let t=p.get(e.id);return!!t&&Jc(t,m,p)})(),tie:e.at?qx(e.at.nextAt==null?F(e.at.rule):`${Dp(e.at.nextAt)} (${F(e.at.rule)})`,!!e.reopensConv):void 0})),asOf:e.online?void 0:f?nl(f):void 0}),onSendNow:(e,t)=>{q(`action:nextprompt.sendnow`),t===`phone`?i(e):c({t:`backlog.fire`,id:e},`running it now…`,Hn)},editableText:h,onEdit:(n,r,i)=>{if(q(`action:nextprompt.edit`),r===`desktop`&&!e.online)return K(Hn),!1;if(h(n,r)==null){let e=Yi({id:xs(),text:i,ts:Date.now(),...t.cwd?{cwd:t.cwd}:{}});return e?(K(e),!1):(K(`it already went in — your edit is kept on the pad`),!0)}return r===`phone`?(a(n,i),K(`edited`),!0):c({t:`backlog.update`,id:n,text:i},`edited`,Hn)},onCancel:(n,r)=>{q(`action:nextprompt.cancel`);let i=h(n,r);if(i==null){K(r===`desktop`&&!e.online?Hn:`it already went in`);return}let a=Yi({id:xs(),text:i,ts:Date.now(),...t.cwd?{cwd:t.cwd}:{}});a?K(a):r===`phone`?(e.removeQueued(n),K(`canceled — the words are kept on the pad`)):c({t:`backlog.remove`,id:n},`canceled — the words are kept on the pad`,Hn)},onPastBudget:e=>{q(`action:nextprompt.pastbudget`),c({t:`intent.waive`,id:e,rung:`budget`,on:!0},$u(1),Hn)},onHold:e=>{q(`action:nextprompt.hold`);let t=n.current.find(t=>t.ackId===e);!t||r(t.sessionId)?(o(e),K(`held on this phone — it goes in when this session opens. Leave the app open`)):s(e)},onOpenQueue:()=>{q(`overlay:queue`),l(`queue`)},onOpenBacklog:()=>{q(`overlay:backlog`),vs(t.cwd)},keepFocus:$})}function Qx(e,t,n){if(n.pending)return null;let r=Ee(e,t);return r?.to===`cli`?{on:`shell`,cli:r.target}:r?.to===`shell`?{on:`cli`,shell:r.target}:null}function $x(e,t,n,r){if(n.pending)return null;let i=Qx(e,t,n),a;if(i?.on===`cli`)a=[{kind:`cli`,on:!0},{kind:`shell`,on:!1,target:i.shell}];else if(i?.on===`shell`)a=[{kind:`cli`,on:!1,target:i.cli},{kind:`shell`,on:!0}];else if(r.length)a=[{kind:n.shell||e.companionOf?`shell`:`cli`,on:!0}];else return null;return[...a,...r.map(e=>({kind:`view`,view:e}))]}var eS=16,tS=`
|
|
12
|
-
tap for both windows, their reset times and the token history`,nS=`
|
|
13
|
-
tap for its quota windows and the readings kept`,rS=e=>e.source===`claude`;function iS({f:e,size:t,gauge:n=!0}){return(0,Q.jsxs)(Q.Fragment,{children:[n&&(0,Q.jsx)(Bh,{size:t}),!e.noSess&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:(e.sess??0)>=80?`usage-hot`:``,children:e.sess==null?`?`:`${e.sess}%`}),e.sessResetAt!=null&&(0,Q.jsxs)(`span`,{className:`usage-unit usage-reset`,children:[(0,Q.jsx)(Dh,{size:11}),` `,Dp(e.sessResetAt)]}),(0,Q.jsx)(`span`,{className:`usage-sep`,children:`/`})]}),(0,Q.jsx)(`span`,{className:(e.wk??0)>=80?`usage-hot`:``,children:e.wk==null?`?`:`${e.wk}%`}),(0,Q.jsx)(`span`,{className:`usage-unit`,children:`wk`})]})}function aS({seg:e,size:t,gauge:n=!0}){return(0,Q.jsxs)(Q.Fragment,{children:[n&&(0,Q.jsx)(Bh,{size:t}),(0,Q.jsx)(`span`,{className:`usage-label`,children:e.label}),(0,Q.jsx)(`span`,{className:e.hot?`usage-hot`:``,children:e.text}),e.unit&&(0,Q.jsx)(`span`,{className:`usage-unit`,children:e.unit})]})}function oS(e,t,n=Date.now()){return`${rS(e)&&t?mn(t):Oe(e.reading,n)}${rS(e)?tS:nS}${Bi(e.hidden)}`}function sS({sessions:e}){let t=pn(),n=Qn(io(),e),{segments:r}=d(n,3),i=e=>{q(`overlay:tokens`),Ep(Pr(e.source))},a=()=>{let e=ua(t);return(0,Q.jsx)(Y,{className:`usage-key${Zl(e)?` danger`:``}`,title:`${mn(t)}${tS}`,onClick:()=>{q(`overlay:tokens`),Ep(null)},children:(0,Q.jsx)(iS,{f:e,size:eS})},`claude`)};if(!r.length)return a();let o=lu(r,t),s=o||r.length>1,c=r.map((e,n)=>{let r=rS(e)?Ht(e.reading,t):null,a=!s||!o&&n===0;return(0,Q.jsx)(Y,{className:`usage-key${s?` usage-seg`:``}${(r?Zl(r):e.hot)?` danger`:``}`,title:oS(e,t),onClick:()=>i(e),children:r?(0,Q.jsx)(iS,{f:r,size:eS,gauge:a}):(0,Q.jsx)(aS,{seg:e,size:eS,gauge:a})},e.source)});return s?(0,Q.jsxs)(`div`,{className:`usage-multi`,children:[o&&a(),c]}):(0,Q.jsx)(Q.Fragment,{children:c})}function cS({backend:e}){let t=pn(),n=io(),{segments:r}=d(Oi(n,e),3),i=e=>{q(`overlay:tokens`),Ep(e?Pr(e.source):null)},a=(e,t,n)=>(0,Q.jsxs)(nc,{className:`usage-inline${(e.sess??0)>=80?` danger`:``}`,title:t,onClick:()=>i(n),children:[(0,Q.jsx)(Bh,{size:11}),!e.noSess&&(0,Q.jsxs)(Q.Fragment,{children:[` sess `,e.sess==null?`?`:`${e.sess}%`,e.sessResetAt!=null&&(0,Q.jsxs)(Q.Fragment,{children:[` resets `,Dp(e.sessResetAt)]}),` ·`]}),` `,`wk `,e.wk==null?`?`:`${e.wk}%`]},n?.source??`claude`);return r.length?(0,Q.jsx)(Q.Fragment,{children:r.map(e=>rS(e)?a(Ht(e.reading,t),oS(e,t),e):(0,Q.jsxs)(nc,{className:`usage-inline${e.hot?` danger`:``}`,title:oS(e,t),onClick:()=>i(e),children:[(0,Q.jsx)(Bh,{size:11}),` `,e.label,` `,e.text,e.unit?` ${e.unit}`:``]},e.source))}):a(ua(t),`${mn(t)}${tS}`,null)}async function lS(e,t){let n=await ff({title:`Name this session`,initial:se(e),placeholder:`what this session is about`,note:`Shown on the tab, the row and the header — up to 4 words, 30 characters.`});if(!n)return;let r=U(n);if(!r){K(`that name was not kept — one word longer than the tab, or an ellipsis in it`);return}q(`action:session.rename`);let i=r===n.trim()?``:` (shortened to fit the tab)`;t({t:`session.rename`,id:e.id,title:r},`named “${r}”${i}`,`no connection — the name lives on the desktop and was not changed`)}var uS=()=>null;function dS(e,t,n,r){q(`action:launcher.${t}${e.key}`),r?.(),e.unavailable?K(e.unavailable):n>0&&e.openCount?e.openCount():e.open()}function fS({it:e,size:t,onOpen:n}){let r=(e.useCount??uS)(),i=Xi(r),a=e.icon;return(0,Q.jsxs)(`button`,{className:`more-act${i?` notif-btn`:``}`,title:e.unavailable??(i?r.title:e.title??`open ${e.label}`),onClick:()=>dS(e,``,i,n),children:[(0,Q.jsx)(a,{size:t}),e.label,i>0&&(0,Q.jsx)(`span`,{className:`notif-badge`,children:Ar(i)})]})}function pS({size:e,onOpen:t}){jd();let n=dp();return n.length?(0,Q.jsx)(Q.Fragment,{children:n.map(n=>(0,Q.jsx)($c,{feature:n.feature,what:`its ${n.label} menu line`,children:(0,Q.jsx)(fS,{it:n,size:e,onOpen:t})},n.key))}):null}function mS({it:e,size:t,where:n}){let r=e.useCount(),i=Xi(r);if(!i)return null;let a=e.icon;return(0,Q.jsxs)(Y,{className:`notif-btn`,"aria-label":r.title,title:r.title,onClick:()=>dS(e,n,i),children:[(0,Q.jsx)(a,{size:t}),(0,Q.jsx)(`span`,{className:`notif-badge`,children:Ar(i)})]})}function hS({items:e,size:t,where:n}){let r=Ri(e);return r.length?(0,Q.jsx)(Q.Fragment,{children:r.map(e=>(0,Q.jsx)($c,{feature:e.feature,what:`its ${e.label} header key`,children:(0,Q.jsx)(mS,{it:e,size:t,where:n})},e.key))}):null}function gS({size:e}){return jd(),(0,Q.jsx)(hS,{items:dp(),size:e,where:`key.`})}function _S({items:e,base:t}){let n=ca(t,e.map(e=>e.useCount()));return n>0?(0,Q.jsx)(`span`,{className:`mic-badge`,children:Ar(n)}):null}function vS({base:e}){jd();let t=dp().filter(e=>e.useCount);return t.length?(0,Q.jsx)($c,{feature:t.map(e=>e.feature).join(`, `),what:`the menu badge`,children:(0,Q.jsx)(_S,{items:t,base:e},t.map(e=>e.key).join(`|`))},t.map(e=>e.key).join(`|`)):e>0?(0,Q.jsx)(`span`,{className:`mic-badge`,children:Ar(e)}):null}var yS=Cn((()=>{let e=ht(G.headerViews,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]})());function bS(e){yS.set(e),mt(G.headerViews,e)}function xS(e){let t=yS.get();t.includes(e)||bS([...t,e])}function SS(e){let t=yS.get();t.includes(e)&&bS(t.filter(t=>t!==e))}function CS(){return up(yS)}var wS=`Flag for follow up`,TS=`Done — clear flag`,ES=e=>e?` fu-${e.by}`:``;function DS(e,t,n){if(t){let t=e.followUp?`flagged here`:`flag cleared here`;return n?`${t} — the desktop has not confirmed it yet`:`${t} — offline, so it is only on this phone until the link is back`}return e.followUp?`${TS} — ${_(e.followUp)}`:`${wS} — a one-shot mark; opening the session does not clear it`}var OS=({on:e,size:t})=>(0,Q.jsx)(Mh,{size:t,fill:e?`currentColor`:`none`});function kS({f:e}){return(0,Q.jsxs)(`span`,{className:`fu-line${ES(e)}`,children:[(0,Q.jsx)(Mh,{size:12,fill:`currentColor`}),` `,_(e)]})}var AS=Ei(Xn,Yn);function jS(e,t){return AS.item(e,t)}var MS=16;function NS(e,t,n=!1){let{active:r,pending:i,status:a,activeRepo:o,toolbarCfg:s,pendingStars:c,toggleStar:l,pendingFollowUps:u,toggleFollowUp:d,setOverlay:f,runToolbar:p,backends:m}=e;if(!n&&s.hidden.includes(t.id))return null;let h=!n,g=()=>{n||wl(t.id)},_=Fi(m,r?.backend);if(t.id===`model`&&_||t.id===`logins`&&!_||t.id===`companion`&&(_||i||!Yo(m)))return null;switch(t.id){case`untracked`:return!o||!mi(o)?null:(0,Q.jsxs)(Y,{className:`count`,title:Lp(o),onClick:()=>{g(),ln(o.id,f)},children:[(0,Q.jsx)(fm,{size:MS}),` `,o.changedCount>0&&o.changedCount,ja(o)&&(0,Q.jsxs)(`span`,{className:`git-ab`,children:[` `,ja(o)]})]},`untracked`);case`star`:{if(!r||i)return null;let e=r.id in c;return(0,Q.jsxs)(Y,{className:`star-btn${r.starred?` starred`:``}${e?` star-pending`:``}`,"data-hint":`session.star`,title:e?a===`open`?`starred here — the desktop has not confirmed it yet`:`starred here — offline, so it is only on this phone until the link is back`:r.starred?`unstar (prima interest)`:`star — mark as prima interest to come back to`,onClick:()=>{g(),l(r.id,!r.starred)},children:[(0,Q.jsx)(em,{size:MS,fill:r.starred?`currentColor`:`none`}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,r.starred?`starred`:`star`]})]},`star`)}case`followup`:{if(!r||i)return null;let e=!!r.followUp;return(0,Q.jsxs)(Y,{className:`fu-btn${ES(r.followUp)}${r.id in u?` star-pending`:``}`,"data-hint":`session.followup`,"aria-pressed":e,title:DS(r,r.id in u,a===`open`),onClick:()=>{g(),d(r.id,!e)},children:[(0,Q.jsx)(OS,{on:e,size:MS}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,e?`Done — clear flag`:`Flag for follow up`]})]},`followup`)}case`bookmark`:return!r||i?null:(0,Q.jsx)(Xf,{active:r,repo:o,online:a===`open`,compact:n,dismiss:g},`bookmark`);default:{let e=Ua(r).find(e=>e.key===t.id);if(e)return e.useCount?(0,Q.jsx)($c,{feature:e.feature,what:`its ${e.label} menu line`,children:(0,Q.jsx)(PS,{ext:e,label:h,dismiss:g})},t.id):(0,Q.jsxs)(Y,{title:e.unavailable??e.label,onClick:()=>{g(),q(`toolbar:${t.id}`),e.unavailable?K(e.unavailable):e.open()},children:[(0,Q.jsx)(e.icon,{size:MS}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,e.label]})]},t.id);let n=jS(t.id,{label:h,dismiss:g,openMenu:()=>pl(!0),active:r});if(n!==void 0)return(0,Q.jsx)(Z.Fragment,{children:n},t.id);let i=Mf[`toolbar:${t.id}`],a=t.id===`outline`?hx(r):null;return(0,Q.jsxs)(Y,{"data-hint":`toolbar:${t.id}`,title:`${i?`${i.title} — ${i.what}`:t.name}${gx(a)}`,onClick:()=>{g(),p(t.id)},children:[(0,Q.jsx)(t.Icon,{size:MS}),h&&(0,Q.jsxs)(Q.Fragment,{children:[` `,t.id===`model`?pa(r?.model)||`model`:t.name]}),a==null?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,a]})]},t.id)}}}function PS({ext:e,label:t,dismiss:n}){let r=e.useCount(),i=Xi(r);return(0,Q.jsxs)(Y,{className:i?`notif-btn`:void 0,title:e.unavailable??(i?r.title:e.label),onClick:()=>{n(),q(`toolbar:${e.key}`),e.unavailable?K(e.unavailable):i>0&&e.openCount?e.openCount():e.open()},children:[(0,Q.jsx)(e.icon,{size:MS}),t&&(0,Q.jsxs)(Q.Fragment,{children:[` `,e.label]}),i>0&&(0,Q.jsx)(`span`,{className:`notif-badge`,children:Ar(i)})]})}function FS({c:e,usedOrder:t,refreshTerminal:n}){let{active:r,pending:i,toolbarCfg:a,setOverlay:o}=e;return i?(0,Q.jsx)(Cf,{className:`toolbar-cants toolbar-cants-menu`,cants:[{label:`terminal keys`,reason:`there is no CLI to type into until the session opens`},{label:`slash commands`,reason:`there is no CLI to type into until the session opens`},{label:`reader, context, /usage`,reason:`the conversation starts when the session does`}]}):(0,Q.jsxs)(`div`,{className:`toolbar`,role:`menu`,"aria-label":`toolbar`,children:[(0,Q.jsxs)(Y,{title:`refresh terminal`,onClick:()=>{wl(),n()},children:[(0,Q.jsx)(Xh,{size:MS}),` refresh`]}),r.remoteUrl&&(0,Q.jsxs)(Y,{onClick:()=>{wl(),window.open(r.remoteUrl,`_blank`)},title:`open in app`,children:[(0,Q.jsx)(nm,{size:MS}),` open in app`]}),fn(a,t).map(t=>NS(e,t)),wn(r.id).map(e=>(0,Q.jsxs)(Y,{title:e.unavailable??`open ${e.label} — adds its tab to the header`,onClick:()=>{wl(),q(`action:view.${e.key}.menu`),e.unavailable?K(e.unavailable):(xS(e.key),e.open())},children:[(0,Q.jsx)(e.icon,{size:MS}),` `,e.label]},e.key)),(0,Q.jsxs)(Y,{title:`customize toolbar`,onClick:()=>{wl(),o(`toolbar`)},children:[(0,Q.jsx)(Oh,{size:MS}),` customize`]})]})}var IS=()=>{let e=ht(G.toldNoticed,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]};function LS(e,t,n,r){return RS(e,r)&&!n.includes(t)}var RS=(e,t)=>e===`none`&&t!==`shell`;function zS(e){let t=IS().filter(t=>t!==e);mt(G.toldNoticed,[...t,e].slice(-32))}var BS=e=>`${e} was not told about the outbox, so it may not know that what you should see goes in .claude/outbox/ — say so in your prompt when you want a file here.`,VS=e=>`Shown once for ${e} on this phone — the crossed-out speech icon beside the title brings it back.`,HS=(e,t)=>e===`none`&&t!==`shell`,US=e=>`askrules:${e}`,WS=(e,t,n,r)=>HS(e,r)&&!n.includes(US(t)),GS=e=>`Ask-before rules are not enforced in a ${e} session: neither the CLI nor this app's gate can make it stop and ask, so a command your rules would hold back can run without a tap.`,KS=e=>`Shown once for ${e} on this phone — the shield-with-question-mark icon beside the title brings it back.`;function qS(e){let t=IS().filter(t=>t!==US(e));mt(G.toldNoticed,[...t,US(e)].slice(-32))}function JS({active:e,backends:t}){let n=e.backend??`claude`,r=Fi(t,e.backend)?`shell`:void 0,[i,a]=(0,Z.useState)(()=>LS(e.told,n,IS(),r));if(!RS(e.told,r))return null;let o=t?.find(e=>e.id===n)?.label??n;return i?(0,Q.jsxs)(Dc,{className:`told-note`,role:`note`,children:[BS(o),` `,(0,Q.jsx)(`button`,{className:`link-btn`,onClick:()=>{zS(n),a(!1),K(VS(o))},children:`got it`})]}):(0,Q.jsx)(`button`,{className:`link-btn told-mark`,title:BS(o),"aria-label":`${o} was not told about the outbox — read why`,onClick:()=>a(!0),children:(0,Q.jsx)(Gh,{size:12,"aria-hidden":`true`})})}function YS({active:e,backends:t}){let n=Fi(t,e.backend)?`shell`:void 0;return HS(e.askRulesVia,n)?(0,Q.jsx)(XS,{active:e,backends:t}):null}function XS({active:e,backends:t}){let{rules:n}=yl(),r=e.backend??`claude`,i=Fi(t,e.backend)?`shell`:void 0,[a,o]=(0,Z.useState)(()=>WS(e.askRulesVia,r,IS(),i));if(n.length===0)return null;let s=t?.find(e=>e.id===r)?.label??r;return a?(0,Q.jsxs)(Dc,{className:`told-note`,role:`note`,children:[GS(s),` `,(0,Q.jsx)(`button`,{className:`link-btn`,onClick:()=>{qS(r),o(!1),K(KS(s))},children:`got it`})]}):(0,Q.jsx)(`button`,{className:`link-btn told-mark`,title:GS(s),"aria-label":`Ask-before rules are not enforced in ${s} — read why`,onClick:()=>o(!0),children:(0,Q.jsx)(wm,{size:12,"aria-hidden":`true`})})}function ZS({off:e,hidden:t,children:n}){let{frame:r,cap:i,capped:a,grip:o}=Sp({key:G.sessChromeH,off:e,showAllEvent:`action:chrome.showAll`,capEvent:`action:chrome.cap`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:r,className:`sess-chrome${a?` capped`:``}`,style:a?{maxHeight:`${i}px`}:void 0,children:n}),!t&&(0,Q.jsx)(`div`,{className:`sess-chrome-grip${a?` capped`:``}`,role:`separator`,"aria-orientation":`horizontal`,tabIndex:0,"aria-label":a?`header shortened — tap to show all of it, or drag down for more`:`drag up to hide the bottom of the header`,title:a?`header shortened — tap to show all of it, or drag down for more`:`drag up to hide the bottom of the header — the status line goes first`,...o,children:a&&(0,Q.jsx)(hg,{size:12,"aria-hidden":`true`})})]})}var QS=16,$S=54,eC=12,tC=new Set([`star`,`followup`,`bookmark`]);function nC(e){let{active:t,sessions:r,pending:i,pendingEntry:a,status:o,liveSend:s,backends:c,sessionCan:l,sessionRepoName:u,repoForCwd:d,setActiveId:f,setOverlay:p,removeQueued:m,closeSession:h,chrome:g,hdrShown:_,headerCmds:v,runHeaderCmd:y,refreshTerminal:b,toolbar:x}=e,{chromeHidden:S,typingMode:C,typingPeeking:T,setTypingPeek:E,setFullScreen:D}=g,O=fp(),k=Wa(),A=ep(),M=Qi(),ee=Lg(),N=Ii(),P=l(t,`contextSeries`)&&l(t,`contextMeter`)&&t.contextLeft!=null,F=jn(t)?.cls??null;return(0,Q.jsxs)(ZS,{off:S||O||T,hidden:S,children:[(0,Q.jsxs)(`header`,{className:`topbar sess-top`,style:Ka(u(t)),children:[(0,Q.jsx)(`button`,{className:`back`,onClick:()=>f(null),children:(0,Q.jsx)(eh,{size:24})}),(0,Q.jsxs)(`div`,{className:`brand`,children:[w(d(t.cwd),j(t.title)||t.title),(0,Q.jsxs)(nc,{className:$a(c,t.backend)?`row-foreign`:void 0,children:[` `,pu(Po(t),$a(c,t.backend),c)]}),(0,Q.jsx)(Qd,{}),(0,Q.jsx)(JS,{active:t,backends:c},t.id),(0,Q.jsx)(YS,{active:t,backends:c},`ar:${t.id}`),t.tabTitle?(0,Q.jsxs)(`span`,{className:`brand-name`,children:[(0,Q.jsx)(Cg,{size:12,"aria-hidden":`true`}),` `,t.tabTitle]}):null]}),(0,Q.jsxs)(`div`,{className:`hdr-view`,children:[(0,Q.jsx)(iC,{active:t,sessions:r,pending:i,backends:c}),$f(x.toolbarCfg).filter(e=>tC.has(e.id)).map(e=>(0,Q.jsx)(`span`,{className:`hdr-pin`,children:NS(x,e,!0)},e.id)),!i&&(0,Q.jsx)(Y,{className:`hdr-name-btn`,title:t.tabTitle?`write this session a new name — one cheap call on the desktop`:`name this session — one cheap call on the desktop`,"aria-label":`name this session`,onClick:()=>{q(`action:session.name`),s({t:`session.name`,id:t.id},`writing a name for this session…`)},children:(0,Q.jsx)(Cg,{size:QS})}),!i&&(0,Q.jsx)(Y,{className:`hdr-name-btn`,title:`type a name for this session`,"aria-label":`rename this session`,onClick:()=>{lS(t,s)},children:(0,Q.jsx)(qm,{size:QS})})]}),(0,Q.jsxs)(`div`,{className:`hdr-row2`,children:[(0,Q.jsxs)(`div`,{className:`hdr-cmds`,children:[$f(x.toolbarCfg).filter(e=>e.id!==`outline`&&!tC.has(e.id)).map(e=>(0,Q.jsx)(`span`,{className:`hdr-pin`,children:NS(x,e,!0)},e.id)),_.map(e=>(0,Q.jsx)(Y,{className:`hdr-cmd`,title:e.text,onClick:()=>y(e),children:e.title},e.id)),(0,Q.jsx)(Y,{className:`hdr-cmd hdr-cmd-manage`,title:`header commands — one-tap chips you configure`,onClick:()=>{q(`action:hdrcmd.manage`),p(`hdrcmd`)},children:v.length?(0,Q.jsx)(qm,{size:12}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Um,{size:12}),` command`]})})]}),(0,Q.jsx)(`div`,{className:`hdr-ctl`,children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ac,{compact:!0}),!i&&(0,Q.jsx)(hS,{items:Ua(t).filter(e=>!(x.toolbarCfg.pinned??[]).includes(e.key)),size:QS,where:`session.key.`}),(0,Q.jsx)(_a,{size:QS}),i?(0,Q.jsx)(Y,{variant:`danger`,title:Zg(t.id)?`close — nothing was queued; a draft stays here for next time`:`drop this open — the prompts written for it stay in ${ec.activity}`,onClick:()=>{let e=a?.ackId;f(null),e&&(m(e),K(`open dropped`))},children:(0,Q.jsx)(Lh,{size:QS})}):(0,Q.jsx)(Y,{variant:`danger`,title:t.running?`close session — reopen under “Recently closed”`:`remove session`,onClick:()=>{h(t),f(null)},children:(0,Q.jsx)(Lh,{size:QS})}),(0,Q.jsx)(Y,{className:`burger-btn${O?` active`:``}`,title:O?`close the menu`:`menu — refresh, slash commands, files, and the rest`,"aria-label":`toolbar`,"aria-expanded":O,onClick:()=>pl(!O),children:(0,Q.jsx)(kh,{size:QS})})]})})]}),S&&!i&&!(x.toolbarCfg.pinned??[]).includes(`outline`)&&(0,Q.jsxs)(Y,{className:`hdr-typing-keep hdr-typing-outline`,onPointerDown:$,title:`outline — where you are in this session${gx(hx(t))}`,onClick:()=>x.runToolbar(`outline`),children:[(0,Q.jsx)(am,{size:QS}),hx(t)==null?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,hx(t)]})]}),S&&(0,Q.jsx)(Y,{className:`hdr-typing-keep hdr-typing-menu`,onPointerDown:$,title:C?`show the header, status and keys again — the keyboard stays up`:`leave full screen — the header, status and toolbar come back`,"aria-label":`show hidden controls`,"aria-expanded":!1,onClick:()=>{C?(q(`action:typing.peek`),E(!0)):(q(`action:fullscreen.off`),D(!1))},children:(0,Q.jsx)(kh,{size:QS})}),T&&(0,Q.jsx)(Y,{className:`hdr-typing-hide`,onPointerDown:$,title:`hide these again and give the rows back to the output`,"aria-label":`hide controls`,"aria-expanded":!0,onClick:()=>{q(`action:typing.hide`),E(!1)},children:(0,Q.jsx)(xg,{size:QS})}),O&&(0,Q.jsx)(FS,{c:x,usedOrder:k,refreshTerminal:b})]}),i&&(0,Q.jsxs)(`div`,{className:`sess-status`,children:[(0,Q.jsx)(nc,{children:d(t.cwd)?dt(n(d(t.cwd))):t.cwd}),(0,Q.jsx)(nc,{children:Zg(t.id)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bm,{size:11}),` starts when its backlog item runs`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yg,{size:11,className:a?.status===`failed`?``:`spin`}),` `,a?.status===`failed`?`not started`:!a||a.status===`pending`?`opening…`:o===`open`?`queued`:`queued — waiting for the link`]})})]}),!i&&(0,Q.jsxs)(`div`,{className:`sess-status`,children:[lx(t,void 0,void 0,c),t.asking&&!t.prompt&&!t.awaitingInput&&(0,Q.jsxs)(`button`,{className:`row-sub ack-asking`,title:`mark “${t.asking.text}” as handled — clears the “asked you” badge and the waiting count here. Nothing is typed into the session, and the next turn's question raises it again.`,onClick:()=>{q(`action:session.ackAsking`),s({t:`session.ackAsking`,id:t.id,text:t.asking.text},`marked as handled — nothing was typed into the session`)},children:[(0,Q.jsx)(rh,{size:12}),` mark handled`]}),t.createdAt&&t.running&&(0,Q.jsxs)(nc,{children:[(0,Q.jsx)(Dh,{size:11}),` open `,ml(t.createdAt)]}),l(t,`usageLimits`)&&A.kind===`windows`&&(0,Q.jsx)(cS,{backend:t.backend}),l(t,`usageLimits`)&&A.kind===`usd`&&(0,Q.jsxs)(nc,{className:`usage-inline${A.chip.hot?` danger`:``}`,title:`${A.chip.title}\ntap for the token history`,onClick:()=>{q(`overlay:tokens`),p(`tokens`)},children:[(0,Q.jsx)(Bh,{size:11}),` `,A.chip.text]}),$r(t.sideChannel)&&(0,Q.jsxs)(nc,{className:`act-cant`,children:[(0,Q.jsx)(qh,{size:11}),` `,$r(t.sideChannel)]}),ux(t,N),mx(t,()=>Qo(t)),!P&&dx(t),l(t,`contextSeries`)&&(0,Q.jsxs)(`button`,{className:`row-sub usage-inline`,"data-hint":`session.context`,title:`${l(t,`contextMeter`)&&t.contextTotalTok!=null?`context window: ${Hf(t.contextUsedTok??0)} of ${Hf(t.contextTotalTok)} tokens`:`context window`}${ae(t.contextSpark?.usageTok)?`\n${$e(t.contextSpark.usageTok,t.contextSpark.agentTok??null)}`:``}\ntap for the graph: how it filled, and where it compacted`,onClick:()=>{q(`overlay:context`),la()},children:[l(t,`contextMeter`)&&t.contextSpark?(0,Q.jsx)(xr,{spark:t.contextSpark,width:54,height:14}):(0,Q.jsx)(um,{size:11}),l(t,`contextMeter`)?t.contextTotalTok==null?t.contextLeft==null?(0,Q.jsx)(Q.Fragment,{children:` context`}):(0,Q.jsxs)(Q.Fragment,{children:[` context `,(0,Q.jsx)(rC,{pct:t.contextLeft,warm:F})]}):(0,Q.jsxs)(Q.Fragment,{children:[` context `,Hf(t.contextUsedTok??0),`/`,Hf(t.contextTotalTok),t.contextLeft!=null&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(rC,{pct:t.contextLeft,warm:F})]})]}):(0,Q.jsx)(Q.Fragment,{children:` context`}),(()=>{let e=t.contextSpark;if(e&&Vo(e,$S,eC)){let n=ft(e.costUsd,M),r=ee(t);return(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(_o,{spark:e,width:$S,height:eC,warn:r}),n&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:r?`spend-warn-${r.level}`:void 0,children:n})]})]})}return ae(e?.usageTok)?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Dm,{size:11}),` used `,ae(e?.usageTok)]}):null})()]}),fx(t),px(t),_x(t,()=>Ni(null)),(0,Q.jsx)(Ot,{s:t})]})]})}function rC({pct:e,warm:t}){return(0,Q.jsxs)(`span`,{className:t?`ctx-free ${t}`:`ctx-free`,children:[e,`% free`]})}function iC({active:e,sessions:t,pending:n,backends:r}){let i=CS(),a=n?[]:wn(e.id).filter(e=>i.includes(e.key)),o=$x(e,t,{pending:n,shell:Fi(r,e.backend)},a);if(!o)return null;let s=e;for(let e of o)e.kind===`cli`&&!e.on&&(s=e.target);let c=Yf(r,s.backend),l=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Im,{size:14,"aria-hidden":`true`}),` `,c]}),u=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Fm,{size:14,"aria-hidden":`true`}),` Shell`]});return(0,Q.jsx)(`div`,{className:`pair-tabs`,role:`tablist`,"aria-label":a.length?`session, its shell or a view of it`:`session or its shell`,"data-hint":`hdr.pair`,children:o.map(e=>{if(e.kind===`view`){let t=e.view,n=t.icon;return(0,Q.jsxs)(`span`,{className:`pair-view`,children:[(0,Q.jsxs)(`button`,{className:`pair-tab`,role:`tab`,"aria-selected":`false`,onPointerDown:$,title:t.unavailable??`open ${t.label}`,onClick:()=>{q(`action:view.${t.key}`),t.unavailable?K(t.unavailable):t.open()},children:[(0,Q.jsx)(n,{size:14,"aria-hidden":`true`}),` `,t.label]}),(0,Q.jsx)(`button`,{className:`pair-tab pair-view-x`,onPointerDown:$,"aria-label":`close the ${t.label} tab`,title:`close the ${t.label} tab — ☰ menu opens it again`,onClick:()=>{q(`action:view.${t.key}.unpin`),SS(t.key)},children:(0,Q.jsx)(Lh,{size:14,"aria-hidden":`true`})})]},t.key)}let t=e.kind===`cli`?l:u;if(e.on)return(0,Q.jsx)(`span`,{className:`pair-tab on`,role:`tab`,"aria-selected":`true`,children:t},e.kind);let n=e.target;return e.kind===`cli`?(0,Q.jsx)(`button`,{className:`pair-tab`,role:`tab`,"aria-selected":`false`,onPointerDown:$,title:`back to the CLI session this shell belongs to`,onClick:()=>{q(`action:companion.to.cli`),_p(n.id)},children:t},`cli`):(0,Q.jsx)(`button`,{className:`pair-tab`,role:`tab`,"aria-selected":`false`,onPointerDown:$,title:`switch to this session's companion shell`,onClick:()=>{q(`action:companion.to.shell`),_p(n.id)},children:t},`shell`)})})}function aC({activeId:e}){let t=up(y_);if(!t||!__(t,e))return null;let n=g_(t.to.label);return(0,Q.jsxs)(`div`,{className:`filter-bar return-bar`,children:[(0,Q.jsxs)(`button`,{className:`return-go`,title:`open the ${t.to.label} again — this shell stays open`,onClick:()=>{q(`action:shell.return`),t.to.open()},children:[(0,Q.jsx)(Ph,{size:14}),` `,(0,Q.jsx)(`span`,{className:`filter-bar-txt`,children:n})]}),(0,Q.jsx)(`button`,{className:`filter-bar-clear`,"aria-label":`hide ${n}`,title:`hide ${n}`,onClick:()=>{S_(),K(`Hidden. The shell button on the ${t.to.label} brings it back.`)},children:(0,Q.jsx)(Lh,{size:13})})]})}function oC({session:e,onSendLogin:t}){let n=Re(e)?.kind;return n===`auth`?e.login?(0,Q.jsx)(sC,{login:e.login,id:e.id}):e.signedOut&&e.running?(0,Q.jsx)(cC,{onSendLogin:t}):null:n===`net`&&e.netRetry&&e.running?(0,Q.jsx)(lC,{id:e.id,retry:e.netRetry}):null}function sC({login:e,id:t}){return(0,Q.jsx)(_d,{slot:`login`,stowKey:`${e.url}\n${e.awaitingCode?`await`:``}`,label:`sign-in link`,icon:xm,children:(0,Q.jsxs)(`div`,{className:`approve login`,children:[(0,Q.jsxs)(`div`,{className:`login-head`,children:[(0,Q.jsxs)(`span`,{className:`login-title`,children:[(0,Q.jsx)(xm,{size:14}),` sign-in link`]}),(0,Q.jsx)(`span`,{className:`login-age`,title:`when the CLI printed this link`,children:nl(e.at)}),(0,Q.jsx)(Df,{})]}),(0,Q.jsx)(yu,{url:e.url,openLabel:`Open sign-in page`,onOpen:zd,onCopy:e=>void Xo(e),onPasteCode:e.awaitingCode?()=>void ul(t):void 0,children:e.awaitingCode&&(0,Q.jsxs)(`div`,{className:`approve-hint`,children:[`the CLI is waiting for the code — sign in, then `,(0,Q.jsx)(`b`,{children:`paste code`}),` (or type it in the compose bar)`]})})]})})}function cC({onSendLogin:e}){return(0,Q.jsx)(_d,{slot:`login`,stowKey:`signed-out`,label:`signed out`,icon:bh,children:(0,Q.jsxs)(`div`,{className:`approve login`,children:[(0,Q.jsxs)(`div`,{className:`login-head`,children:[(0,Q.jsxs)(`span`,{className:`login-title`,children:[(0,Q.jsx)(bh,{size:14}),` Claude is signed out on this desktop`]}),(0,Q.jsx)(Df,{})]}),(0,Q.jsxs)(`div`,{className:`approve-hint`,children:[`Your message was not sent to Claude. Sign in first: tap `,(0,Q.jsx)(`b`,{children:`Sign in`}),` below, or type `,(0,Q.jsx)(`b`,{children:`/login`}),` in the message box and send it. Claude then shows a sign-in link here — open it, sign in, and paste the code back.`]}),(0,Q.jsx)(`div`,{className:`approve-opts`,children:(0,Q.jsxs)(`button`,{className:`approve-btn primary`,onClick:e,children:[(0,Q.jsx)(bh,{size:14}),` Sign in (sends /login)`]})})]})})}function lC({id:e,retry:t}){let[n,r]=(0,Z.useState)(()=>Date.now()),i=t.nextAt!=null&&!t.dismissed;(0,Z.useEffect)(()=>{if(!i)return;let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[i]);let a=ot(t,n);if(!a||t.dismissed)return null;let o=t.state===`gaveup`;return(0,Q.jsxs)(`div`,{className:`approve netretry`,role:`status`,children:[(0,Q.jsxs)(`div`,{className:`approve-opts`,children:[(0,Q.jsxs)(`span`,{className:`netretry-line`,children:[(0,Q.jsx)(cg,{size:14,"aria-hidden":`true`}),` `,a]}),o&&(0,Q.jsxs)(`button`,{className:`approve-btn`,onClick:()=>Ol(e),title:`Retry now types “continue” into that session, the way the automatic retry does; the work completes on the next real reply.`,children:[(0,Q.jsx)(Wh,{size:14,"aria-hidden":`true`}),` retry now`]}),(0,Q.jsxs)(`button`,{className:`approve-btn`,onClick:()=>Lu(e,o),title:o?`hide this line — work waiting on this session stays stalled, with its note on its own row`:`stop the desktop retrying this turn — it types nothing`,children:[(0,Q.jsx)(Lh,{size:14,"aria-hidden":`true`}),` `,o?`dismiss`:`cancel`]}),!o&&(0,Q.jsxs)(`button`,{className:`approve-btn`,onClick:gl,title:`stop the desktop retrying network errors in every session — Settings › Sessions brings it back`,children:[(0,Q.jsx)($m,{size:14,"aria-hidden":`true`}),` turn off`]})]}),(0,Q.jsx)(`div`,{className:`approve-hint`,children:t.error})]})}var uC={...he.dark},dC={...he.light,cursor:he.light.foreground,cursorAccent:he.light.background,selectionBackground:`rgba(21, 100, 204, .22)`,black:`#24292f`,red:`#cf222e`,green:`#116329`,yellow:`#4d2d00`,blue:`#0550ae`,magenta:`#6639ba`,cyan:`#1b7c83`,white:`#6e7781`,brightBlack:`#57606a`,brightRed:`#a40e26`,brightGreen:`#1a7f37`,brightYellow:`#633c01`,brightBlue:`#0969da`,brightMagenta:`#8250df`,brightCyan:`#1b7c83`,brightWhite:`#24292f`};function fC(e){let t=e===`light`?dC:uC,n=ke(e,Gd());return n===he[e]?t:e===`light`?{...t,...n,cursor:n.foreground,cursorAccent:n.background}:{...t,...n}}var pC=450,mC=400,hC=2500,gC=3e4;function _C(e){let t=e.buffer.active,n=[];for(let r=0;r<e.rows;r++){let e=t.getLine(t.viewportY+r);n.push(e?e.translateToString(!0).replace(/\s+$/,``):``)}return n}function vC(e,t){let n=e.querySelector(`.xterm-screen`);if(!n||!t.rows)return null;let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();return i.height?{top:i.top-r.top,left:i.left-r.left,width:i.width,rowH:i.height/t.rows,rows:t.rows}:null}var yC=(0,Z.forwardRef)(function({pending:e,writeSeq:t,onInput:n,onResize:r,linkUp:i,onScreen:a,onCursorLine:o,onReachBack:s,onScrollStalled:c,onLongPress:u,children:d},f){let p=(0,Z.useRef)(null),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(0),_=(0,Z.useRef)({cols:0,rows:0}),v=(0,Z.useRef)({linkUp:i,onScreen:a,onCursorLine:o,onReachBack:s,onScrollStalled:c,onLongPress:u});v.current={linkUp:i,onScreen:a,onCursorLine:o,onReachBack:s,onScrollStalled:c,onLongPress:u};let y=(0,Z.useRef)(void 0),b=(0,Z.useRef)(void 0),x=(0,Z.useRef)(0);(0,Z.useEffect)(()=>{let e=new Eg({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:cd(),theme:fC(yi()),scrollback:5e3,convertEol:!1}),t=new Dg;e.loadAddon(t);let r=()=>{t.fit(),e.cols>l(e.cols)&&e.resize(l(e.cols),e.rows)};e.open(p.current),p.current.querySelector(`.xterm-helper-textarea`)?.setAttribute(`inputmode`,`none`),r(),e.attachCustomKeyEventHandler(t=>t.type!==`keydown`||!t.ctrlKey||t.shiftKey||t.altKey||t.key.toLowerCase()!==`c`||!e.hasSelection()?!0:(navigator.clipboard?.writeText(e.getSelection()).catch(()=>{}),!1)),e.onData(n),m.current=e;let i=Lr(t=>{e.options.theme=fC(t)}),a=Xs(()=>{e.options.fontSize=cd();try{r()}catch{return}S(e.cols,e.rows)});h.current=t,S(e.cols,e.rows);let o,s=new ResizeObserver(()=>{clearTimeout(o),o=window.setTimeout(()=>{try{let t=C();r(),S(e.cols,e.rows),t&&e.scrollToBottom()}catch{}},150)});s.observe(p.current);let c=p.current,u=0,d=0,f=0,g=!1,_,w=()=>{clearTimeout(_),_=void 0},T=()=>{let t=e.buffer.active;return t.getLine(t.viewportY)?.translateToString(!0)??``},E=()=>c.querySelector(`.xterm-rows > div`)?.getBoundingClientRect().height||16,D=e=>{if(n(`\x1b[<${e<0?64:65};1;1M`.repeat(Math.abs(e))),e>=0)return;clearTimeout(b.current);let t=T();b.current=window.setTimeout(()=>{T()===t&&(Date.now()-x.current<gC||(x.current=Date.now(),v.current.onScrollStalled?.()))},hC)},O=t=>{if(w(),t.touches.length!==1){g=!1;return}u=t.touches[0].clientY,d=t.touches[0].clientX,f=0,g=!1;let n=d,r=u;_=window.setTimeout(()=>{_=void 0;let t=vC(c,e);if(!t)return;let i=Math.floor((r-c.getBoundingClientRect().top-t.top)/t.rowH);i>=0&&i<t.rows&&v.current.onLongPress?.(i,n,r)},pC)},k=t=>{if(t.touches.length!==1)return;let n=t.touches[0].clientY-u,r=t.touches[0].clientX-d;if(_!==void 0&&Math.hypot(r,n)>8&&w(),!g){if(Math.abs(n)<8||Math.abs(r)>Math.abs(n))return;g=!0}t.preventDefault(),f-=n,u=t.touches[0].clientY;let i=E(),a=Math.trunc(f/i);if(a!==0){if(f-=a*i,e.buffer.active.type===`normal`){e.scrollLines(a);return}if(!v.current.linkUp){a<0&&(g=!1,v.current.onReachBack?.());return}D(a)}};return c.addEventListener(`touchstart`,O,{passive:!0}),c.addEventListener(`touchmove`,k,{passive:!1}),c.addEventListener(`touchend`,w,{passive:!0}),c.addEventListener(`touchcancel`,w,{passive:!0}),()=>{try{e.buffer.active.type===`alternate`&&v.current.onScreen?.(_C(e))}catch{}clearTimeout(o),clearTimeout(y.current),clearTimeout(b.current),s.disconnect(),i(),a(),c.removeEventListener(`touchstart`,O),c.removeEventListener(`touchmove`,k),c.removeEventListener(`touchend`,w),c.removeEventListener(`touchcancel`,w),w(),e.dispose(),m.current=null}},[]),(0,Z.useEffect)(()=>{let t=m.current;if(!t||g.current>=e.length)return;let n=C();for(let n=g.current;n<e.length;n++)t.write(e[n]);g.current=e.length,n&&t.scrollToBottom(),clearTimeout(y.current),y.current=window.setTimeout(()=>{if(m.current){if(v.current.onCursorLine&&!m.current.modes.synchronizedOutputMode){let e=m.current.buffer.active;v.current.onCursorLine(e.getLine(e.baseY+e.cursorY)?.translateToString(!0,0,e.cursorX)??``)}m.current.buffer.active.type===`alternate`&&(m.current.modes.synchronizedOutputMode||v.current.onScreen?.(_C(m.current)))}},mC)},[t,e]);function S(e,t){if(!T(e,t))return;let n=_.current;(n.cols!==e||n.rows!==t)&&(_.current={cols:e,rows:t},r(e,t))}function C(){let e=m.current;return!e||e.buffer.active.viewportY>=e.buffer.active.baseY}return(0,Z.useImperativeHandle)(f,()=>({focus(){m.current?.focus()},snapshot(){return m.current?_C(m.current):[]},rowBox(){return m.current&&p.current?vC(p.current,m.current):null},getText(){let e=m.current;if(!e)return``;let t=t=>{let n=e.buffer[t],r=[];for(let e=0;e<n.length;e++){let t=n.getLine(e);t&&r.push(t.translateToString(!0))}for(;r.length&&r[r.length-1]===``;)r.pop();return r.join(`
|
|
14
|
-
`)};return[t(`normal`),e.buffer.active.type===`alternate`?t(`alternate`):``].filter(Boolean).join(`
|
|
15
|
-
|
|
16
|
-
— current screen —
|
|
17
|
-
|
|
18
|
-
`)}}),[]),(0,Q.jsx)(`div`,{ref:p,style:{width:`100%`,height:`100%`,position:`relative`},children:d})}),bC=18,xC=520,SC=`[data-hint="term.read"]`;function CC({chunks:e,writeSeq:t,cols:n,rows:r,leaving:i,onGone:a,onOpen:o}){let s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),u=(0,Z.useRef)({arr:null,n:0}),[d,f]=(0,Z.useState)(0),[p,m]=(0,Z.useState)(1),[h,g]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=new Eg({cols:Math.max(20,n),rows:Math.max(5,r),fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:cd(),theme:fC(yi()),cursorBlink:!1,disableStdin:!0,scrollback:0});e.open(c.current),c.current.querySelector(`.xterm-helper-textarea`)?.setAttribute(`inputmode`,`none`),l.current=e,u.current={arr:null,n:0};let t=Lr(t=>{e.options.theme=fC(t)});return()=>{t(),l.current=null,e.dispose()}},[]),(0,Z.useEffect)(()=>{let t=l.current;if(!t)return;let i=u.current,a=Math.max(20,n),o=Math.max(5,r);if((t.cols!==a||t.rows!==o)&&(t.resize(a,o),i.arr=null),(i.arr!==e||i.n>e.length)&&(t.reset(),i.arr=e,i.n=0),!(i.n>=e.length)){for(let n=i.n;n<e.length;n++)t.write(e[n]);i.n=e.length,t.write(``,()=>{if(l.current!==t||t.modes.synchronizedOutputMode)return;let e=t.buffer.active,n=-1;for(let r=0;r<t.rows;r++)e.getLine(e.viewportY+r)?.translateToString(!0).trim()&&(n=r);f(Math.min(bC,n+1));let r=c.current?.querySelector(`.xterm-screen`),i=s.current;if(r&&i){let e=r.offsetWidth;m(e>0?Math.min(1,i.clientWidth/e):1),g(r.offsetHeight/t.rows)}})}},[t,e,n,r]),(0,Z.useLayoutEffect)(()=>{if(!i)return;let e=s.current,t=document.querySelector(SC),n=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches;if(!e||!t||n||d===0){a();return}let r=e.getBoundingClientRect(),o=t.getBoundingClientRect();Object.assign(e.style,{position:`fixed`,left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,margin:`0`,zIndex:`40`,transformOrigin:`top left`,pointerEvents:`none`});let c=o.width/r.width,l=o.height/r.height,u=e.animate([{transform:`none`,opacity:1,borderRadius:`8px`},{transform:`translate(${o.left-r.left}px, ${o.top-r.top}px) scale(${c}, ${l})`,opacity:.35,borderRadius:`40px`}],{duration:xC,easing:`cubic-bezier(.55,0,.25,1)`,fill:`forwards`});return u.onfinish=()=>{t.classList.add(`cli-catch`),window.setTimeout(()=>t.classList.remove(`cli-catch`),450),a()},()=>{u.onfinish=null}},[i]);let _=d&&h?Math.ceil(d*h*p):0;return(0,Q.jsxs)(`div`,{className:`cli-peek-wrap`,children:[!d&&(0,Q.jsx)(Zd,{children:`No turns recorded yet.`}),(0,Q.jsx)(`div`,{ref:s,className:`cli-peek${d?``:` cli-peek-blank`}`,style:{height:_},role:`button`,tabIndex:0,"aria-label":`open the CLI`,onClick:o,onKeyDown:e=>{e.key===`Enter`&&o()},children:(0,Q.jsx)(`div`,{ref:c,className:`cli-peek-grid`,style:{transform:`scale(${p})`}})}),d>0&&!i&&(0,Q.jsxs)(`div`,{className:`cli-peek-cap muted`,children:[(0,Q.jsx)(sm,{size:12}),` no turns yet — this is the top of the CLI; the conversation appears here once you send`]})]})}function wC(e,t){return!!e&&t&&e.kind===`trust`&&e.options.length>0}var TC=Zp(),EC={hand:rg,code:dh,scroll:tg,zap:ig,shieldOff:fh,lock:gg};function DC({mode:e,size:t=16}){let n=EC[by[e]?.icon??`hand`];return(0,Q.jsx)(n,{size:t,"aria-hidden":!0})}function OC(e,t,n){let r=Ci(e,t.backend)?Lo(e,t.backend):[];return{rows:wy(r,t,kr(e,t.backend)),ultraOk:r.length>0&&kr(e,t.backend)&&n&&aa(e,t.backend).length>0}}function kC(e,t,n){let r=OC(e,t,n);return r.rows.length>0||r.ultraOk}function AC({cur:e,backends:t,canSlash:n,submitInput:r,liveAsk:i,onClose:a}){let o=Ry(e.id),{rows:s,ultraOk:c}=OC(t,e,n),l=Sy(e);if(s.length===0&&!c){let n=Fi(t,e.backend)?null:Kp(t,e.backend);return n?(0,Q.jsx)(Dc,{className:`mode-sec`,children:n}):null}let u=t=>{q(`action:mode.${t}`),i({t:`session.mode`,id:e.id,mode:t},`no connection — a mode switch is never queued; try again when the link is back`)&&Iy(e.id,t)},d=async e=>{let t=Ty(e,l);t.kind===`none`?K(t.say):t.kind===`confirm`&&(a(),!await Lt({title:`Switch this session to ${xy(e)}?`,lines:[...Xy.slice(0,2),`This session only — new sessions keep their own launch mode.`],confirmLabel:`Switch to ${xy(e)}`}))||u(e)},f=t=>{let n=My(t);q(`action:ultracode.${t?`on`:`off`}`),r(e.id,e.cwd,n,`command`)&&K(n)},p=Ay(e.ultracode);return(0,Q.jsxs)(`div`,{className:`mode-sec`,children:[s.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mode-head muted`,children:kr(t,e.backend)?`Mode · shift+tab on the desktop`:`Mode`}),(0,Q.jsx)(Dc,{className:`mode-now`,children:Cy(l,kr(t,e.backend)?void 0:xp(t,e.backend)?.label??`this backend`)}),(0,Q.jsx)(`div`,{className:`mode-rows`,role:`group`,"aria-label":`permission mode`,children:s.map(e=>{let t=l.mode===e.mode,n=o===e.mode;return(0,Q.jsxs)(`button`,{className:`mode-row${t&&l.source===`live`?` cur`:``}`,"aria-pressed":t&&l.source===`live`,onClick:()=>void d(e.mode),children:[(0,Q.jsx)(`span`,{className:`mode-ico`,children:(0,Q.jsx)(DC,{mode:e.mode})}),(0,Q.jsxs)(`span`,{className:`mode-txt`,children:[(0,Q.jsx)(`span`,{className:`mode-title`,children:e.title}),(0,Q.jsx)(`span`,{className:`mode-desc muted`,children:n?`switching…`:e.desc})]}),(0,Q.jsx)(`span`,{className:`mode-mark`,children:n?(0,Q.jsx)(th,{size:16,className:`spin`}):t&&l.source===`live`?(0,Q.jsx)(rh,{size:16}):t?(0,Q.jsx)(`span`,{className:`muted`,children:`at launch`}):null})]},e.mode)})})]}),c&&(0,Q.jsxs)(`div`,{className:`mode-ultra`,children:[(0,Q.jsx)(`span`,{className:`mode-ico`,children:(0,Q.jsx)(Cg,{size:16,"aria-hidden":!0})}),(0,Q.jsxs)(`span`,{className:`mode-txt`,children:[(0,Q.jsx)(`span`,{className:`mode-title`,children:`Ultracode`}),(0,Q.jsx)(`span`,{className:`mode-desc muted`,children:jy(e.ultracode)})]}),(0,Q.jsxs)(`span`,{className:`mode-acts`,children:[p!==`on`&&(0,Q.jsx)(Y,{onClick:()=>f(!0),children:`turn on`}),p!==`off`&&(0,Q.jsx)(Y,{onClick:()=>f(!1),children:`turn off`})]})]})]})}var jC=new Map;function MC(e){return(0,TC.createPortal)((0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`model-wheel-scrim`,onPointerDown:t=>{t.preventDefault(),e.onClose()}}),(0,Q.jsx)(NC,{anchor:e.anchor,children:(0,Q.jsx)(PC,{...e})})]}),document.body)}function NC({anchor:e,children:t}){let n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(8);return(0,Z.useLayoutEffect)(()=>{let t=n.current;if(!t)return;let r=()=>{let n=e.current?.getBoundingClientRect();i(Xa(n?n.bottom:0,t.offsetHeight,window.innerHeight))};r();let a=new ResizeObserver(r);return a.observe(t),window.addEventListener(`resize`,r),()=>{a.disconnect(),window.removeEventListener(`resize`,r)}},[e]),(0,Q.jsx)(`div`,{ref:n,className:`model-wheel-place`,style:{"--mw-top":`${r}px`},children:t})}function PC({cur:e,backends:t,canSlash:n,submitInput:r,relaunch:i,liveAsk:a,onClose:o}){let s=kC(t,e,n),c=(0,Q.jsx)(AC,{cur:e,backends:t,canSlash:n,submitInput:r,liveAsk:a,onClose:o}),l=Ba(t,e.backend),u=aa(t,e.backend),[d,f]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]),jp(l).length===0&&!e.model)return(0,Q.jsxs)(`div`,{className:`model-wheel-pop`,role:`dialog`,"aria-label":`model wheel`,children:[(0,Q.jsx)(FC,{onClose:o,withMode:s}),(0,Q.jsx)(Dc,{children:`This backend did not name its models, so there is nothing to put on a wheel. Switch model in the menu takes a typed id.`}),c]});let p=vp(e,l),m=jC.get(e.id);m&&fc(m,p,l.ids)&&jC.delete(e.id);let h=m&&jC.has(e.id)?m:null,g=d?Bs(p,d,{slash:n,effort:Vr(t,e.backend,!0)}):null,_=d?`${d.model}${d.effort?` · ${d.effort}`:``}`:``,v=Mi(e)?`the conversation is resumed`:`no conversation id is known, so it starts clean`,y=g?g.kind===`none`?p.from===`turn`?`The last turn already ran on ${_}.`:`This session started on ${_}.`:g.kind===`live`?`Sends ${g.commands.join(` then `)}.`:`Kills and relaunches this session on ${_}; ${v}.`:`Tap or drag to a point${u.length>0?` — centre is low effort, the rim is max`:``}.${u.length>0?``:` This backend has no effort setting.`}`,b=Xe(e.contextSpark,{lastTurnAt:e.lastTurnAt,turnActive:e.turnActive,now:Date.now()}),x=d&&g&&g.kind!==`none`?Kf({from:{model:p.model,effort:p.effort},to:d,ids:l.ids,tok:b?.tok??null,baseTok:b?.baseTok??null,cold:C(e.lastTurnAt,Date.now(),e.turnActive)}):null;return(0,Q.jsxs)(`div`,{className:`model-wheel-pop`,role:`dialog`,"aria-label":`model wheel`,children:[(0,Q.jsx)(FC,{onClose:o,withMode:s}),(0,Q.jsxs)(vl,{cat:l,efforts:u,current:{model:p.model,effort:p.effort},value:d,onPick:f,onClear:()=>f(null),says:y,now:(0,Q.jsxs)(Q.Fragment,{children:[p.from===`turn`?(0,Q.jsxs)(Q.Fragment,{children:[`Last turn ran on `,e.turnModel,e.turnEffort?` · ${e.turnEffort}`:``]}):(0,Q.jsxs)(Q.Fragment,{children:[`Started on `,e.model||`the default model`,e.effort?` · ${e.effort}`:u.length>0?` · default effort`:``]}),h&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`br`,{}),`Sent `,h.commands.join(` then `),` `,nl(h.at),`; no turn has run on it yet.`]})]}),children:[x&&(0,Q.jsx)(Dc,{className:`mw-cost`,children:x}),g&&g.kind!==`none`&&(0,Q.jsx)(`button`,{className:`send mw-apply`,onClick:()=>{if(g&&g.kind!==`none`){if(q(`action:modelwheel.${g.kind}`),g.kind===`live`){for(let t of g.commands)r(e.id,e.cwd,t,`command`);jC.set(e.id,{commands:g.commands,model:g.model,effort:g.effort,at:Date.now()}),K(g.commands.join(` · `))}else i(e,g.patch);o()}},children:g.kind===`live`?`Switch to ${_}`:`Relaunch on ${_}`}),c]})]})}function FC({onClose:e,withMode:t}){return(0,Q.jsxs)(`div`,{className:`mw-head`,children:[(0,Q.jsxs)(`span`,{children:[`Model · effort`,t?` · mode`:``]}),(0,Q.jsx)(Y,{"aria-label":`close the model wheel`,onClick:e,children:(0,Q.jsx)(Lh,{size:16})})]})}var IC=`2.1.304`,LC=[{name:`shift+tab`,does:`next permission mode`,seq:[{m:{shift:!0},key:`tab`}]},{name:`ctrl+o`,does:`show / hide the transcript`,seq:[{m:{ctrl:!0},key:`o`}]},{name:`ctrl+t`,does:`show / hide the todo list`,seq:[{m:{ctrl:!0},key:`t`}]},{name:`ctrl+b`,does:`send the running command to the background`,seq:[{m:{ctrl:!0},key:`b`}]},{name:`ctrl+r`,does:`search earlier prompts`,seq:[{m:{ctrl:!0},key:`r`}]},{name:`ctrl+s`,does:`stash the prompt being typed`,seq:[{m:{ctrl:!0},key:`s`}]},{name:`ctrl+_`,does:`undo in the prompt`,seq:[{m:{ctrl:!0},key:`_`}]},{name:`ctrl+l`,does:`clear the prompt`,seq:[{m:{ctrl:!0},key:`l`}]},{name:`ctrl+j`,does:`new line in the prompt`,seq:[{m:{ctrl:!0},key:`j`}]},{name:`alt+p`,does:`model picker`,seq:[{m:{alt:!0},key:`p`}]},{name:`alt+t`,does:`thinking on / off`,seq:[{m:{alt:!0},key:`t`}]},{name:`alt+o`,does:`fast mode on / off`,seq:[{m:{alt:!0},key:`o`}]},{name:`esc esc`,does:`jump back to an earlier prompt — from an empty prompt while idle; mid-turn the first Esc stops the turn`,seq:[{m:{},key:`esc`},{m:{},key:`esc`}]}];function RC(e){let t=[];for(let n of e.seq){let e=ce(n.m,n.key);if(!(`bytes`in e))return null;t.push(e.bytes)}return t}var zC=16,BC=150;function VC({sendInput:e,onClose:t}){(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),e.preventDefault(),t())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t]);function n(n){let r=LC[n],i=RC(r);i?(q(`action:keys.send`),i.forEach((t,n)=>n===0?e(t):window.setTimeout(()=>e(t),n*BC)),t(),K(`sent ${r.name} — ${r.does}`)):K(`${r.name} has no terminal bytes. Nothing was sent.`)}return(0,Q.jsxs)(`div`,{className:`keys-pop`,role:`dialog`,"aria-label":`claude's shortcuts`,children:[(0,Q.jsxs)(`div`,{className:`keys-pop-head`,children:[(0,Q.jsxs)(`span`,{className:`muted`,children:[`claude `,IC,`'s default keys — a remapped keybindings.json has others`]}),(0,Q.jsx)(Y,{onPointerDown:$,onClick:t,title:`close the list`,"aria-label":`close the list`,children:(0,Q.jsx)(Lh,{size:zC})})]}),(0,Q.jsx)(`div`,{className:`keys-pop-list`,children:LC.map((e,t)=>(0,Q.jsxs)(`button`,{className:`keys-pop-row`,onPointerDown:$,onClick:()=>n(t),title:`${e.name} — ${e.does}`,children:[(0,Q.jsx)(`span`,{className:`keys-pop-key`,children:e.name}),(0,Q.jsx)(`span`,{className:`keys-pop-does`,children:e.does})]},e.name))})]})}var HC=16,UC=e=>{e.preventDefault(),document.activeElement?.blur()},WC=e=>[{label:`Esc`,title:`Esc — close a menu or interrupt ${e}`,data:`\x1B`,key:`esc`},{label:`Tab`,title:`Tab — complete`,data:` `,key:`tab`},{label:(0,Q.jsx)(Om,{size:HC}),title:`up — move the selection in a box`,data:`\x1B[A`,key:`up`,nav:!0},{label:(0,Q.jsx)(Jm,{size:HC}),title:`down — move the selection in a box`,data:`\x1B[B`,key:`down`,nav:!0},{label:(0,Q.jsx)(uh,{size:HC}),title:`left`,data:`\x1B[D`,key:`left`,nav:!0},{label:(0,Q.jsx)(ph,{size:HC}),title:`right`,data:`\x1B[C`,key:`right`,nav:!0},{label:`^C`,title:`Ctrl-C — cancel`,data:``},{label:(0,Q.jsx)(_m,{size:HC}),title:`Return — confirm the selection`,data:`\r`,key:`enter`}],GC=[{mod:`ctrl`,label:`Ctrl`},{mod:`alt`,label:`Alt`},{mod:`shift`,label:`Shift`}],KC={off:``,once:`next`,lock:`lock`},qC=(e,t)=>t===`off`?`${e} — tap, then a key (on this row or typed): it goes with ${e}. Tap twice to lock.`:t===`once`?`${e} is held for the next key. Tap again to lock it, a third time to let go.`:`${e} is locked for every key until you tap it again.`;function JC({active:e,backends:t,compose:n,keysOpen:r,setKeysOpen:i}){let{cliMode:a,sendInput:s,toggleCliMode:c}=n,l=JSON.stringify(e.keyHints??[]),[u,d]=(0,Z.useState)({of:``,keys:[]}),f=u.of===l?u.keys:[],p=e.keyHints??[],m=e=>{let t=o(e.key);if(!t||f.includes(e.key))return null;let r=`${e.key} — ${e.verb} (the CLI names this key on screen now)`;return(0,Q.jsxs)(Y,{className:`key-hint`,title:r,"aria-label":r,onPointerDown:$,onClick:()=>{n.chord.clear(),s(t),e.key!==`shift+tab`&&d({of:l,keys:[...f,e.key]})},children:[nt(e.key),` `,(0,Q.jsx)(`span`,{className:`key-hint-verb`,children:e.verb})]},`hint:${e.key}`)};return(0,Q.jsxs)(`div`,{className:`keys`,children:[p.filter(e=>e.key!==`shift+tab`).map(m),WC(iu(t,e.backend)).map((e,t)=>(0,Q.jsx)(Y,{title:e.title,"aria-label":e.title,onPointerDown:e.nav&&!a?UC:$,onClick:()=>e.key?n.chord.sendKey(e.key,e.data):s(e.data),children:e.label},t)),GC.map(({mod:e,label:t})=>{let r=n.chord.mods[e];return(0,Q.jsxs)(Y,{className:`mod-key${r===`off`?``:` active`}`,title:qC(t,r),"aria-label":qC(t,r),"aria-pressed":r!==`off`,onPointerDown:$,onClick:()=>n.tapChordMod(e),children:[(0,Q.jsx)(`span`,{children:t}),r!==`off`&&(0,Q.jsx)(`span`,{className:`mod-state`,children:KC[r]})]},e)}),kr(t,e.backend)&&(0,Q.jsxs)(Y,{className:r?`active`:void 0,onPointerDown:$,onClick:()=>i(e=>!e),"aria-expanded":r,title:`claude's own shortcuts (ctrl+o transcript, ctrl+t todos, alt+p model…) — one tap each`,"aria-label":`claude's shortcuts`,children:[(0,Q.jsx)(mm,{size:HC}),` Keys`]}),(0,Q.jsxs)(Y,{className:`cli-key ${a?`active`:``}`,"data-hint":`compose.cli`,onPointerDown:$,onClick:c,title:a?`CLI mode is on — every key you type goes straight to the session. Tap to go back to composing (queued, confirmed sends).`:`CLI mode — type directly at the CLI instead of composing a message: keystrokes go through as you type, nothing is queued or echo-checked.`,children:[(0,Q.jsx)(sm,{size:HC}),` CLI`]}),p.filter(e=>e.key===`shift+tab`).map(m)]})}function YC(e,t){let[n,r]=(0,Z.useState)(null),i=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{let t=!0,n=async()=>{let n=await Na(e).catch(()=>null);t&&n&&n.value.updatedAt!==i.current&&(i.current=n.value.updatedAt,r(n.value.turns))};return n().then(()=>zp(e,!0)).catch(()=>void 0).then(n),()=>{t=!1}},[e,t]),n}function XC({sessionId:e,refreshKey:t,busy:n,turnStartedAt:r,nextTurn:i,usdPerWeekPct:a,weekIncl:o,weekRefused:s,onOpenCost:c,chipOnly:l}){let u=YC(e,t),[d,f]=(0,Z.useState)(()=>Dt(G.termCostOpen)),p=(0,Z.useMemo)(()=>ko(u??[]),[u]),m=(0,Z.useMemo)(()=>Rp(u??[]),[u]);if(!u||!m)return null;let h=$t(m,n,r);return(0,Q.jsx)(hi,{className:`tcs`,bodyClass:`tcs-body`,growsUp:!0,t:m,which:h,open:d&&!l,onToggle:()=>{let e=!d;q(e?`action:term.cost.open`:`action:term.cost.close`),gt(G.termCostOpen,e),f(e)},onChip:l&&c?()=>{q(`action:term.cost`),c()}:void 0,slots:p,agentsSoFar:Ma(u,m.id),usdPerWeekPct:a,weekIncl:o,weekRefused:s??null,onOpen:c,trackId:`action:term.cost`,next:h===`last`&&m.id===u[u.length-1]?.id?Me(i):null,why:!0})}var ZC=e=>e.onSessionScreen&&e.typingRoom&&e.composeFocused;function QC(e){let t=ZC(e),n=t&&!e.cliMode,r=n&&!e.typingPeek,i=n&&e.typingPeek,a=t&&e.cliMode,o=(e.fullScreen||a)&&e.onSessionScreen&&!r&&!(t&&e.typingPeek);return{typingMode:r,typingPeeking:i,fullMode:o,chromeHidden:r||o}}function $C(e){let{chromeHidden:t}=QC(e),n=!t;return{fullScreen:n,typingPeek:ZC(e)?!n:e.typingPeek}}var ew=40;function tw(e,t,n){if(!e||Math.abs(e.w-n)>2)return{next:{baseH:t,minH:t,w:n},closed:!1};let r={...e,minH:Math.min(e.minH,t),w:n};return{next:r,closed:r.baseH-r.minH>=120&&t>=r.baseH-ew}}var nw=16,rw=e=>`${e} line${e>1?`s`:``}`;function iw(e){return ei(e.join(`
|
|
19
|
-
`))?(K(`quoted ${rw(e.length)} into compose`),!0):!1}async function aw(e){try{await navigator.clipboard.writeText(e.join(`
|
|
20
|
-
`)),K(`copied ${rw(e.length)}`)}catch{K(`clipboard unavailable (needs https) — quote puts the lines in compose instead`)}}function ow({at:e,onPick:t,onCancel:n}){let r=(0,Z.useRef)(null);return Hc(!0,n),(0,Z.useEffect)(()=>{let e=e=>{r.current?.contains(e.target)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[n]),(0,Q.jsxs)(`div`,{ref:r,className:`tpick-menu`,style:{left:Math.max(8,Math.min(e.x-110,window.innerWidth-236)),top:e.y+220>window.innerHeight?Math.max(8,e.y-220):e.y+28},children:[(0,Q.jsxs)(Y,{onClick:t,children:[(0,Q.jsx)(Hm,{size:nw}),` pick lines`]}),(0,Q.jsxs)(Y,{onClick:()=>{n(),fi()},children:[(0,Q.jsx)(lg,{size:nw}),` answer list`]}),(0,Q.jsxs)(Y,{onClick:n,children:[(0,Q.jsx)(Wm,{size:nw}),` select text`]}),(0,Q.jsxs)(Y,{onClick:()=>{window.getSelection()?.removeAllRanges(),n()},children:[(0,Q.jsx)(Lh,{size:nw}),` cancel`]})]})}function sw({count:e,off:t,hint:n,lines:r,onStop:i}){return Hc(!0,i),(0,Q.jsxs)(`div`,{className:`tpick-bar`,children:[(0,Q.jsx)(`span`,{className:`tpick-count`,children:e?(0,Q.jsxs)(Q.Fragment,{children:[e,` picked`,t?(0,Q.jsxs)(Q.Fragment,{children:[`, `,t,` out of view`]}):null]}):n}),e>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Y,{onClick:()=>{iw(r())&&i()},children:[(0,Q.jsx)(om,{size:nw}),` quote`]}),(0,Q.jsxs)(Y,{onClick:()=>void aw(r()),children:[(0,Q.jsx)(Am,{size:nw}),` copy`]}),(0,Q.jsxs)(Y,{title:`copy with this session's reference — to paste into another session`,onClick:()=>void vr(r().join(`
|
|
21
|
-
`)),children:[(0,Q.jsx)(gm,{size:nw}),` copy + ref`]}),(0,Q.jsxs)(Y,{onClick:()=>{let e=r();i(),fi(e)},children:[(0,Q.jsx)(lg,{size:nw}),` answer`]})]}),(0,Q.jsxs)(Y,{onClick:i,children:[(0,Q.jsx)(Lh,{size:nw}),` `,e?`cancel`:`done`]})]})}function cw(e,t){let n,r=0,i=0,a=()=>{clearTimeout(n),n=void 0},o=e=>{if(a(),e.touches.length!==1)return;let o=e.touches[0],s=e.target;r=o.clientX,i=o.clientY,n=window.setTimeout(()=>{n=void 0,t(r,i,s)},450)},s=e=>{n!==void 0&&e.touches.length===1&&Math.hypot(e.touches[0].clientX-r,e.touches[0].clientY-i)>8&&a()};return e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),e.addEventListener(`touchend`,a,{passive:!0}),e.addEventListener(`touchcancel`,a,{passive:!0}),()=>{a(),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s),e.removeEventListener(`touchend`,a),e.removeEventListener(`touchcancel`,a)}}var lw=150;function uw(e,t){let n=new Set;return e.map(e=>{if(e.row>=0&&t[e.row]===e.text&&!n.has(e.row))return n.add(e.row),e;let r=-1;return t.forEach((t,i)=>{t===e.text&&!n.has(i)&&(r<0||Math.abs(i-e.row)<Math.abs(r-e.row))&&(r=i)}),r>=0&&n.add(r),{text:e.text,row:r}})}function dw(e,t,n){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)({grid:[],box:null}),d=(0,Z.useRef)(void 0),f=()=>{let t=e.current;if(!t)return;let n=t.snapshot();u({grid:n,box:t.rowBox()}),c(e=>e.length?uw(e,n):e)};(0,Z.useEffect)(()=>{i(null),o(!1),c([])},[n]),(0,Z.useEffect)(()=>{if(a)return clearTimeout(d.current),d.current=window.setTimeout(f,lw),()=>clearTimeout(d.current)},[a,t]),(0,Z.useEffect)(()=>{if(!a)return;let e=()=>{clearTimeout(d.current),d.current=window.setTimeout(f,lw)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[a]);let p=e=>{let t=l.grid[e];t?.trim()&&c(n=>n.some(t=>t.row===e)?n.filter(t=>t.row!==e):[...n,{text:t,row:e}])},m=t=>{q(`action:termpick.start`),window.getSelection()?.removeAllRanges(),i(null);let n=e.current,r=n?.snapshot()??[];u({grid:r,box:n?.rowBox()??null}),c(t!=null&&r[t]?.trim()?[{text:r[t],row:t}]:[]),o(!0)},h=()=>{o(!1),c([])},g=(0,Z.useCallback)(()=>i(null),[]),_=()=>(s.every(e=>e.row>=0)?[...s].sort((e,t)=>e.row-t.row):s).map(e=>e.text),v=(e,t,n)=>{a||i({row:e,x:t,y:n})},y=new Set(s.filter(e=>e.row>=0).map(e=>e.row)),b=s.filter(e=>e.row<0).length,{box:x,grid:S}=l,C=a&&x?(0,Q.jsx)(`div`,{className:`tpick-layer`,style:{top:x.top,left:x.left,width:x.width,height:x.rowH*x.rows},children:Array.from({length:x.rows},(e,t)=>{let n=!!S[t]?.trim();return(0,Q.jsx)(`div`,{className:`tpick-row${y.has(t)?` on`:``}`,style:{height:x.rowH},onClick:e=>{e.stopPropagation(),p(t)},children:n&&(0,Q.jsx)(`span`,{className:`tpick-box`,style:{width:x.rowH-3,height:x.rowH-3},children:y.has(t)&&(0,Q.jsx)(rh,{size:Math.max(10,x.rowH-5),strokeWidth:3})})},t)})}):null,w=r&&(0,Q.jsx)(ow,{at:r,onPick:()=>m(r.row),onCancel:g}),T=a&&(0,Q.jsx)(sw,{count:s.length,off:b,hint:`tap lines to pick them — panning still scrolls`,lines:_,onStop:h});return{onLongPress:v,gutter:C,chrome:(0,Q.jsxs)(Q.Fragment,{children:[w,T]})}}var fw=`.tr-body .tr-p, .tr-body .tr-list > li, .tr-body .tr-h, .tr-body .tr-quote, .tr-body .tr-code`,pw=`tpick`;function mw(e){let t=e.innerText.trim(),n=e.tagName===`LI`?e.parentElement:null;return n?.tagName===`OL`?`${(Number(n.start)||1)+[...n.children].indexOf(e)}. ${t}`:t}function hw(e,t,n){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)([]),l=(0,Z.useRef)(!1);l.current=a;let u=(0,Z.useCallback)(e=>{for(let t of e)delete t.el.dataset[pw]},[]),d=(0,Z.useCallback)(()=>{o(!1),c(e=>(u(e),[]))},[u]),f=(0,Z.useCallback)(()=>i(null),[]);(0,Z.useEffect)(()=>{i(null),d()},[t,n,d]),(0,Z.useEffect)(()=>{let t=e.current;if(t)return cw(t,(e,t,n)=>{if(l.current)return;let r=n instanceof Element?n.closest(fw):null;i({x:e,y:t,el:r})})},[e,n]),(0,Z.useEffect)(()=>{let t=e.current;if(!t||!a)return;let n=e=>{let n=e.target instanceof Element?e.target.closest(fw):null;n&&t.contains(n)&&(e.preventDefault(),e.stopPropagation(),c(e=>e.some(e=>e.el===n)?(delete n.dataset[pw],e.filter(e=>e.el!==n)):(n.dataset[pw]=`1`,[...e,{el:n,text:mw(n)}])))};return t.addEventListener(`click`,n,!0),t.classList.add(`tpick-reading`),()=>{t.removeEventListener(`click`,n,!0),t.classList.remove(`tpick-reading`)}},[e,a,n]);let p=e=>{q(`action:readpick.start`),window.getSelection()?.removeAllRanges(),i(null),e&&(e.dataset[pw]=`1`),c(e?[{el:e,text:mw(e)}]:[]),o(!0)},m=()=>[...s.filter(e=>e.el.isConnected).sort((e,t)=>e.el.compareDocumentPosition(t.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),...s.filter(e=>!e.el.isConnected)].map(e=>e.text),h=s.filter(e=>!e.el.isConnected).length;return{chrome:(0,Q.jsxs)(Q.Fragment,{children:[r&&(0,Q.jsx)(ow,{at:r,onPick:()=>p(r.el),onCancel:f}),a&&(0,Q.jsx)(sw,{count:s.length,off:h,hint:`tap paragraphs or list items to pick them`,lines:m,onStop:d})]})}}function gw(e,t){let[n,r]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(!t)return;let n=!0;return Na(e).then(t=>{n&&r(t?{id:e,savedAt:t.savedAt}:null)}).catch(()=>{n&&r(null)}),()=>{n=!1}},[e,t]),t&&n?.id===e?n.savedAt:null}function _w(e,t,n){return e<=1||t<=0||n<=0?e:Math.max(1,e-Math.floor(t/n))}function vw(e,t,n){return Math.max(0,e-t)*n}var yw={x:0,y:0},bw=40,xw=8,Sw=16,Cw=12,ww=4,Tw=350;function Ew(){let e=ht(G.termCornerPos,null);if(!e||!Number.isFinite(e.x)||!Number.isFinite(e.y))return yw;let t=Number.isInteger(e.cols)&&e.cols>=1?e.cols:void 0;return{x:e.x,y:e.y,...t?{cols:t}:{}}}function Dw(e,t,n){let r=e.offsetParent;if(!r)return n;let i=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=i.left-t.x,s=i.top-t.y,c=a.left-o,l=a.right-xw-(o+i.width),u=a.top-s,d=a.bottom-(s+i.height);return{x:Math.round(Math.min(Math.max(n.x,c),Math.max(c,l))),y:Math.round(Math.min(Math.max(n.y,u),Math.max(u,d)))}}function Ow(e){let t=(0,Z.useRef)(null),[n,r]=(0,Z.useState)(Ew),i=(0,Z.useRef)(n);i.current=n;let a=(0,Z.useRef)(null),o=(0,Z.useRef)(0),s=(0,Z.useRef)(bw),c=(0,Z.useCallback)(()=>{let e=t.current;if(!e)return;let n=Dw(e,i.current,i.current);(n.x!==i.current.x||n.y!==i.current.y)&&r(n)},[]);(0,Z.useLayoutEffect)(c,[c,n.cols]),(0,Z.useEffect)(()=>(window.addEventListener(`resize`,c),()=>window.removeEventListener(`resize`,c)),[c]);let l=e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let n=t.current,r=n?n.children.length:0,o=i.current,c=n?.offsetParent;if(n&&c&&r>1&&!o.cols){let t=c.getBoundingClientRect().right,i=t-xw-n.getBoundingClientRect().right,a=t-Sw-e.clientX-i;s.current=Math.max(Cw,a/(r-.5))}let l=s.current,u=o.cols?Math.min(o.cols,r):r,d={x:o.x+vw(r,u,l),y:o.y};a.current={id:e.pointerId,sx:e.clientX,sy:e.clientY,base:d,moved:!1,n:r,step:l}},u=e=>{let n=a.current,o=t.current;if(!n||n.id!==e.pointerId||!o)return;let s=e.clientX-n.sx,c=e.clientY-n.sy;if(!n.moved&&Math.hypot(s,c)<ww)return;n.moved=!0;let l={x:n.base.x+s,y:n.base.y+c},u=o.offsetParent,d=u?u.getBoundingClientRect().right-xw-(o.getBoundingClientRect().right-i.current.x):l.x,f=_w(n.n,l.x-d,n.step),p=Dw(o,i.current,l);r(f<n.n?{...p,cols:f}:p)},d=t=>{let n=a.current;if(!n||n.id!==t.pointerId)return;if(a.current=null,n.moved){mt(G.termCornerPos,i.current);return}let r=Date.now();r-o.current<Tw?(o.current=0,p(),e(!0)):(o.current=r,e(!1))},f=()=>{a.current=null},p=()=>{r(yw),mt(G.termCornerPos,yw)},m=n.x!==0||n.y!==0;return{ref:t,style:m||n.cols?{...m?{transform:`translate(${n.x}px, ${n.y}px)`}:{},...n.cols?{display:`grid`,gridTemplateColumns:`repeat(${n.cols}, auto)`}:{}}:void 0,handle:{onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:f}}}function kw(e,t){return e.defaultPrevented||e.isComposing||t.editable||t.inTerminal||e.ctrlKey||e.altKey||e.metaKey||e.key===`Escape`||e.key===`Tab`||t.activatable&&(e.key===`Enter`||e.key===` `)?null:e.key===`Backspace`?``:e.key.length===1?e.key:lv(e)}function Aw(e){let t=e?.tagName?.toUpperCase()??``;return{editable:t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||!!e?.isContentEditable,inTerminal:!!e?.closest?.(`.xterm`),activatable:!!e?.closest?.(`button, a[href], summary, [role=button]`)}}var jw=`#root > .ws-panel, [role=dialog], .bl-modal-backdrop`;function Mw(e,t,n,r){let i=i=>{kw(i,Aw(i.target))!=null&&e.setTimeout(()=>{if(r())return;let e=kw(i,Aw(i.target));e!=null&&(t(e),n())},0)};return e.addEventListener(`keydown`,i),()=>e.removeEventListener(`keydown`,i)}var Nw=16;function Pw({zoom:e,active:t,pending:n,readerShown:r,readMode:i,setView:a,sessionCan:o,chrome:s,wheel:c,openOutline:l}){let[u,d]=(0,Z.useState)(!1),f=Ow(e=>K(e?`buttons back in the corner`:`drag the grip to move these buttons; double-tap it to put them back`)),p=(0,Z.useRef)(null),{chromeHidden:m,setFullScreen:h,setTypingPeek:g,chromeIn:_}=s,v=X(`txtScale`),y=X(`tZoom`),b=X(`rZoom`),x=e!==!1,S=r?b:y,C=r?Cu:Af,w=r?es:ws,T=r?`reader`:`console`,E=C(S,-1,v),D=C(S,1,v),O=r?``:`, i.e. more columns and rows for the CLI to draw in`,k=r?``:`, i.e. fewer columns and rows`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{ref:f.ref,className:`term-zoom`,"data-hint":`term.zoom`,style:f.style,children:[(0,Q.jsx)(Y,{className:`term-zoom-grip`,"data-hint":`term.grip`,"aria-label":`move these buttons`,title:`drag to move these buttons; double-tap to put them back`,...f.handle,children:(0,Q.jsx)(mh,{size:Nw})}),(0,Q.jsx)(jc,{iconSize:Nw}),!n&&l&&(0,Q.jsxs)(Y,{className:`term-zoom-outline`,"data-hint":`toolbar:outline`,onPointerDown:$,"aria-label":`outline`,title:`outline — where you are in this session${gx(hx(t))}`,onClick:l,children:[(0,Q.jsx)(am,{size:Nw}),hx(t)==null?null:(0,Q.jsx)(`span`,{className:`term-zoom-count`,children:hx(t)})]}),!n&&o(t,`transcript`)&&!(t.cliSetup&&t.running)&&(0,Q.jsx)(Y,{"data-hint":`term.read`,onPointerDown:$,"aria-label":i?`back to the terminal`:`reader view`,title:i?`back to the terminal`:`reader view — scrollable, searchable transcript of this conversation`,onClick:()=>{q(`action:read.toggle`),a(!i)},children:i?(0,Q.jsx)(sm,{size:Nw}):(0,Q.jsx)(pm,{size:Nw})}),!n&&!Fi(c.backends,t.backend)&&(()=>{let e=ky(t),n=`model, effort and mode${e?` — now ${xy(e)}`:``}`;return(0,Q.jsxs)(Y,{ref:p,className:[u&&`active`,e&&`mw-badged`].filter(Boolean).join(` `),"data-hint":`term.modelwheel`,onPointerDown:$,"aria-label":n,"aria-expanded":u,title:n,onClick:()=>{q(`action:modelwheel.open`),d(e=>!e)},children:[(0,Q.jsx)(nh,{size:Nw}),e&&(0,Q.jsx)(`span`,{className:`mw-badge`,children:(0,Q.jsx)(DC,{mode:e,size:12})})]})})(),x&&(0,Q.jsx)(Sn,{smaller:E,bigger:D,onZoom:w,what:T,subject:`the ${T}`,smallerHint:O,biggerHint:k,endClassName:`term-zoom-px muted`,iconSize:Nw}),(0,Q.jsx)(Y,{className:m?`active`:void 0,"data-hint":`term.fullscreen`,onPointerDown:$,"aria-label":m?`leave full screen`:`full screen`,"aria-pressed":m,title:m?`leave full screen — the header, status and toolbar come back`:`full screen — hide the header, status and toolbar and give the rows to the ${r?`conversation`:`output`}. No keyboard${r?``:`: the Esc/arrow row stays`}.`,onClick:()=>{let e=$C(_);q(e.fullScreen?`action:fullscreen.on`:`action:fullscreen.off`),h(e.fullScreen),g(e.typingPeek)},children:m?(0,Q.jsx)(ag,{size:Nw}):(0,Q.jsx)(Ih,{size:Nw})})]}),u&&!n&&!Fi(c.backends,t.backend)&&(0,Q.jsx)(MC,{cur:t,backends:c.backends,canSlash:o(t,`slash`),submitInput:c.submitInput,relaunch:c.relaunch,liveAsk:c.liveAsk,anchor:p,onClose:()=>d(!1)})]})}function Fw(e){let{active:t,pending:n,conn:r,term:i,q:a,compose:o,launch:s,chrome:c,backends:l,readerShown:u,hiddenSlash:d,activeRepoId:f,transportKnown:p,setActiveId:h,closeSession:g,openOutline:_}=e,{pendingEntry:v}=a,{status:y,connVisible:b,send:x}=r,{tailscaleIp:S}=r.info,{termRef:C,geomRef:w,buffers:T,lastPtyAt:E,ptyTail:D,exitedRef:O,staleAt:k,writeSeq:A,termNonce:j,readMode:M,setView:ee,readerCmd:N,outlineJump:P,transcriptNonce:F}=i,I=a.entries,{answerPrompt:te,retryPendingCreate:L,submitInput:R}=a,{cliMode:ne,sendInput:z,focusPipe:B}=o,[V,H]=(0,Z.useState)(!1),{sessionCan:re,openCwd:ie,runForkRequest:U}=s,{dismissedReply:ae,setDismissedReply:oe}=c,[W,se]=(0,Z.useState)(``),ce=Qi(),le=zn(),ue=En(),de=dw(C,A,t.id),pe=t.prompt?I.filter(e=>e.answer?.fingerprint===m(t.prompt)&&e.status!==`failed`).map(e=>({label:e.answer.label})):[],me=(e,n,r,i,a)=>te(t,e,n,r,i,a),he=gw(t.id,!u&&!n&&y!==`open`&&b&&!(T.current.get(t.id)??[]).some(e=>e.length>0)),ge=(0,Z.useRef)(null),_e=hw(ge,t.id,u),ve=M&&!!t.cliSetup&&t.running,ye=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{ve?ye.current!==t.id&&(ye.current=t.id,K(Pn(l,t.backend))):ye.current===t.id&&(ye.current=null,M&&t.running&&!t.cliSetup&&K(qn(l,t.backend)))},[ve,t.id,t.running,t.cliSetup,t.backend,l,M]);let be=(0,Z.useRef)(z);be.current=z,(0,Z.useEffect)(()=>u||n?void 0:Mw(window,e=>be.current(e),()=>C.current?.focus(),()=>!!document.querySelector(jw)),[u,n,C]);let xe=X(`toolsMode`),Se=X(`txtScale`),Ce=X(`rZoom`),we=e=>(0,Q.jsx)(Pw,{zoom:e,active:t,pending:n,readerShown:u,readMode:M,setView:ee,sessionCan:re,chrome:c,openOutline:_,wheel:{backends:l,submitInput:R,relaunch:s.relaunch,liveAsk:r.liveAsk}});return Zg(t.id)?(0,Q.jsx)(`div`,{className:`term-area term-later`,children:(0,Q.jsx)(`div`,{className:`term-overlay as-card`,children:(0,Q.jsxs)(`div`,{className:`term-overlay-box`,children:[(0,Q.jsx)(bm,{size:16}),(0,Q.jsx)(`span`,{children:`The session starts only once this backlog item runs.`}),(0,Q.jsxs)(`span`,{className:`term-overlay-hint`,children:[`Send queues it for when this repo is free; the arrow beside Send has `,(0,Q.jsx)(`em`,{children:`elsewhere or later…`}),` for a clock. Write, chain and attach here — nothing is queued until you send.`]})]})})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`term-area`,children:[!n&&(0,Q.jsx)(td,{className:`toolbar-cants`,cants:To(l,hc(t),{hiddenSlash:d})}),!n&&_r(l,t.backend)&&(0,Q.jsx)(`div`,{className:`act-cants toolbar-cants`,children:(0,Q.jsxs)(`span`,{className:`act-cant`,children:[(0,Q.jsx)(sm,{size:11}),` `,_r(l,t.backend)]})}),(0,Q.jsxs)(`div`,{className:`term-wrap`,children:[b&&y!==`open`&&(0,Q.jsxs)(`div`,{className:`conn-banner floating conn-${y}`,children:[y===`closed`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vh,{size:12}),` connection lost — reconnecting…`]}):`connecting…`,S?` · ${S}`:``]}),u?(0,Q.jsxs)(`div`,{ref:ge,className:`tr-zoom`,style:{"--ui-font":String(Pc(Se,Ce))},children:[(0,Q.jsx)(Fp,{sessionId:t.id,refreshKey:F,status:{running:t.running,busy:t.hooked?!!t.turnActive:t.running&&!t.idle,exact:!!t.hooked,waiting:!!t.prompt,prompt:t.prompt,suggestion:t.suggestion,awaitingInput:!!t.awaitingInput,asking:t.asking,agents:t.agents,shells:t.shells,shellList:t.shellList,blocked:!!t.limit?.blocked,turnStartedAt:t.turnStartedAt,lastOutputAt:E.current.get(t.id),tail:D.current.get(t.id),linkDown:y!==`open`},onShowCli:()=>ee(!1),cliPeek:n?void 0:(e,n)=>(0,Q.jsx)(CC,{chunks:T.current.get(t.id)??[],writeSeq:A,cols:w.current.cols,rows:w.current.rows,leaving:e,onGone:n,onOpen:()=>{q(`action:read.peekToCli`),ee(!1)}}),onAnswer:me,onStop:()=>z(`\x1B`),queuedAnswers:pe,cmd:N??void 0,toolsMode:xe,fork:re(t,`fork`)?{online:y===`open`,hasId:!!Mi(t),run:e=>void U(t,e)}:void 0,jumpTo:P??void 0,onOpenCost:la,nextTurn:Xe(t.contextSpark,{lastTurnAt:t.lastTurnAt,turnActive:t.turnActive,now:Date.now()}),usdPerWeekPct:ce,weekIncl:le,weekRefused:ue,onOpenShells:()=>Qo(t),files:f?{repoId:f,url:(e,t,n)=>{let r=Dn.artifactUrl(f,e);return t?Pd(r,t,n):r},open:e=>Nn(f,e),known:p,toShell:e=>Wr(t,e)}:void 0,onToast:K},t.id),_e.chrome]}):(()=>{let e=T.current.get(t.id)??[],r=e.some(e=>e.length>0),i=k.get(t.id),s=y!==`open`&&b,c=!t.running||y!==`open`&&O.current.has(t.id),u=i??E.current.get(t.id),d=n?`pending`:c?`ended`:s?`offline`:r?null:`empty`,f=!r;return(0,Q.jsxs)(`div`,{className:`term-stage`,children:[(0,Q.jsx)(`div`,{className:`term-canvas${i==null?``:` stale`}`,onClick:ne?B:void 0,children:(0,Q.jsx)(yC,{ref:C,pending:e,writeSeq:A,onInput:z,onResize:(e,r)=>{w.current={cols:e,rows:r},n||x({t:`session.resize`,id:t.id,cols:e,rows:r})},linkUp:y===`open`,onScreen:e=>lp(t.id,e),onCursorLine:o.noteCursorLine,onReachBack:()=>{q(`action:scrollback.reachback`),eo()},onScrollStalled:()=>K(`no new output from that scroll — “scrollback” reads this device's own copy`),onLongPress:de.onLongPress,children:de.gutter},`${t.id}:${j}`)}),we(!f),de.chrome,V&&!n&&kr(l,t.backend)&&!wC(t.prompt,t.running)&&(0,Q.jsx)(VC,{sendInput:z,onClose:()=>H(!1)}),wC(t.prompt,t.running)&&(0,Q.jsx)(`div`,{className:`term-answer`,"data-box":`trust`,children:(0,Q.jsx)(au,{prompt:t.prompt,queued:pe,suggestion:t.suggestion,onAnswer:me,ev:`term.trust`})}),d&&(0,Q.jsx)(`div`,{className:`term-overlay ${f?`as-card`:`as-chip`} term-overlay-${d}${d===`pending`&&v?.status===`failed`?` failed`:``}`,children:(0,Q.jsxs)(`div`,{className:`term-overlay-box`,children:[d===`empty`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(th,{size:16,className:`spin`}),` `,(0,Q.jsx)(`span`,{children:`no output yet — the session is running and hasn’t printed anything`})]}),d===`offline`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ym,{size:16}),(0,Q.jsxs)(`span`,{children:[`offline — `,r?(0,Q.jsxs)(Q.Fragment,{children:[`output as of `,u?nl(u):`the last connection`]}):(0,Q.jsx)(Q.Fragment,{children:`nothing cached for this session yet`})]}),f&&(0,Q.jsx)(`span`,{className:`term-overlay-hint`,children:`It reappears the moment the tunnel is back. Anything you send is queued, not lost.`}),f&&he!=null&&(0,Q.jsxs)(`span`,{className:`term-overlay-hint`,children:[`The conversation was saved on this phone `,nl(he),` — the reader shows it.`]}),(mo(t.id)||f&&he!=null)&&(0,Q.jsxs)(`span`,{className:`term-overlay-acts`,children:[f&&he!=null&&(0,Q.jsxs)(Y,{title:`the conversation as saved on this phone`,onClick:()=>{q(`action:read.offline`),ee(!0)},children:[(0,Q.jsx)(pm,{size:14}),` read it`]}),mo(t.id)&&(0,Q.jsxs)(Y,{title:`earlier output, read from this device (pan up on the terminal does the same)`,onClick:eo,children:[(0,Q.jsx)(tg,{size:14}),` scrollback`]})]})]}),d===`pending`&&(()=>{let e=v?.status===`failed`,t=v?.status===`pending`,n=!t&&y===`open`&&v?a.blocked.get(v.ackId):void 0;return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(vh,{size:16}):(0,Q.jsx)(th,{size:16,className:`spin`}),(0,Q.jsx)(`span`,{children:e?(0,Q.jsxs)(Q.Fragment,{children:[`the session was not started — `,v?.reason||`the desktop refused it`]}):v?n?(0,Q.jsxs)(Q.Fragment,{children:[`not opened yet — `,fe(n)]}):t||y===`open`?(0,Q.jsx)(Q.Fragment,{children:`warming up the CLI for you…`}):(0,Q.jsx)(Q.Fragment,{children:`offline — the session will be created once you are back online`}):(0,Q.jsx)(Q.Fragment,{children:`the desktop has it — the session opens in a moment…`})}),(0,Q.jsx)(`span`,{className:`term-overlay-hint`,children:e?`Anything typed here is still in the queue and can be re-aimed from ${ec.activity}.`:`Write, chain and attach now — it all goes into this session the moment it opens.`}),(0,Q.jsxs)(`span`,{className:`term-overlay-acts`,children:[e&&(0,Q.jsxs)(Y,{title:`try this open again`,onClick:L,children:[(0,Q.jsx)(Xh,{size:14}),` try again`]}),(0,Q.jsxs)(Y,{title:e?`back to the launcher`:`stop waiting — the open stays queued and can be dropped in ${ec.activity}`,onClick:()=>h(null),children:[(0,Q.jsx)(eh,{size:14}),` back`]})]})]})})(),d===`ended`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Lh,{size:16}),(0,Q.jsxs)(`span`,{children:[`session ended`,s?` · offline, so this is the last state we saw`:``]}),(0,Q.jsxs)(`span`,{className:`term-overlay-acts`,children:[(0,Q.jsxs)(Y,{title:`reopen this session — ${tu(!!Mi(t))}`,onClick:()=>ie(t.cwd,t.title,!0,`continue`,{model:t.model,effort:t.effort,permissionMode:t.permissionMode,backend:t.backend},Mi(t)),children:[(0,Q.jsx)(Xh,{size:14}),` reopen`]}),(0,Q.jsxs)(Y,{title:`remove this session from the list`,onClick:()=>{g(t),h(null)},children:[(0,Q.jsx)(Lh,{size:14}),` close`]})]})]})]})})]})})(),u&&we(),!n&&(0,Q.jsx)(cr,{session:t,readMode:M})]})]}),!n&&!u&&re(t,`transcript`)&&(0,Q.jsx)(XC,{sessionId:t.id,refreshKey:F,busy:t.hooked?!!t.turnActive:t.running&&!t.idle,turnStartedAt:t.turnStartedAt,nextTurn:Xe(t.contextSpark,{lastTurnAt:t.lastTurnAt,turnActive:t.turnActive,now:Date.now()}),usdPerWeekPct:ce,weekIncl:le,weekRefused:ue,onOpenCost:la,chipOnly:c.chromeHidden},t.id),(0,Q.jsx)(oC,{session:t,onSendLogin:()=>o.runHeaderCmd(Ji)}),!t.login&&vc(t)&&(0,Q.jsx)(ef,{links:t.links??[],awaitingCode:!!t.awaitingCode,onOpen:zd,onCopy:e=>void Xo(e),onCopyCode:Eo,onPasteCode:()=>void ul(t.id),onLogins:kd}),!t.prompt&&t.suggestion?.reply!=null&&t.suggestion.reply!==ae&&(0,Q.jsx)(id,{suggestion:t.suggestion,onSend:e=>{R(t.id,t.cwd,e,`prompt`),oe(t.suggestion.reply)},onDismiss:()=>oe(t.suggestion.reply)},t.id+`:`+t.suggestion.reply),!t.prompt&&t.running&&!t.turnActive&&t.cliSuggestion&&t.cliSuggestion!==W&&(t.suggestion?.reply==null||t.suggestion.reply===ae)&&(0,Q.jsx)(Xt,{text:t.cliSuggestion,onSend:e=>{R(t.id,t.cwd,e,`prompt`),se(e)},onDismiss:()=>se(t.cliSuggestion),ev:`term`}),!n&&!u&&(0,Q.jsx)(JC,{active:t,backends:l,compose:o,keysOpen:V,setKeysOpen:H}),(0,Q.jsx)(Yc,{sessionId:t.id}),!n&&(0,Q.jsx)(Bo,{session:t,readMode:u})]})}function Iw(e){let{active:t,pending:n,conn:r,term:i,q:a,compose:o,launch:s,chrome:c,backends:l,sessions:u,update:d,readerShown:f,activeRepo:p,transportKnown:m,visibleBacklogItems:h,repoForCwd:g,sessionRepoName:_,setActiveId:v,setOverlay:y,runToolbar:b}=e,{pendingStars:x,toggleStar:S,pendingFollowUps:C,toggleFollowUp:w,closeSession:T}=e.verbs,{status:E,liveSend:D,liveAsk:O,reconnectAsk:k,setReconnectAsk:A}=r,j=a.entries,{pendingEntry:M,outboxRef:ee,holdWall:N,isPendingId:P,sendQueuedNow:F,editQueued:I,toggleHoldQueued:te,handToDesktop:L,removeQueued:R}=a,{uploading:ne,parking:z,upProg:B,uploadPending:V,uploadRowLinger:H,cancelUploads:re}=a.uploads,{chromeHidden:ie,fullMode:U}=c,ae=p?.id??null,oe=Bf(),W=oc(),se=Nu(),ce=X(`autoSend`),le=X(`confirmQueue`),ue=Tp(s.sessionCan(t,`slash`)),de={active:t,pending:n,status:E,activeRepo:p,toolbarCfg:W,pendingStars:x,toggleStar:S,pendingFollowUps:C,toggleFollowUp:w,setOverlay:y,runToolbar:b,backends:l};return(0,Q.jsx)(el,{children:(0,Q.jsxs)(`div`,{className:`screen${ie?` typing`:``}${U?` fullscreen`:``}${f?` reading`:``}`,children:[(0,Q.jsx)(nC,{active:t,sessions:u,pending:n,pendingEntry:M,status:E,liveSend:D,backends:l,sessionCan:s.sessionCan,sessionRepoName:_,repoForCwd:g,setActiveId:v,setOverlay:y,removeQueued:R,closeSession:T,chrome:c,hdrShown:Zg(t.id)?[]:ue.shown,headerCmds:oe,runHeaderCmd:o.runHeaderCmd,refreshTerminal:i.refreshTerminal,toolbar:de}),(0,Q.jsx)(aC,{activeId:t.id}),(0,Q.jsx)(qc,{httpsUrl:r.info.httpsUrl}),(0,Q.jsx)(ka,{update:d,liveAsk:O,liveSend:D}),!n&&(0,Q.jsx)(js,{active:t,update:d,relaunch:s.relaunch}),(0,Q.jsx)(Fw,{active:t,pending:n,conn:r,term:i,q:a,compose:o,launch:s,chrome:c,backends:l,readerShown:f,hiddenSlash:ue.hiddenSlash,activeRepoId:ae,transportKnown:m,setActiveId:v,closeSession:T,openOutline:(W.pinned??[]).includes(`outline`)?()=>b(`outline`):void 0}),(0,Q.jsx)(Zx,{active:t,outbox:j,outboxRef:ee,online:E===`open`,holdWall:N,isPendingId:P,sendQueuedNow:F,editQueued:I,removeQueued:R,toggleHoldQueued:te,handToDesktop:L,liveSend:D,setOverlay:y,intents:e.intents}),(0,Q.jsx)(Y_,{q:a,status:E,reconnectAsk:k,setReconnectAsk:A,autoSend:ce,confirmQueue:le,pullRecords:se,setOverlay:y,stripSessionId:t.id}),(0,Q.jsx)(Wx,{api:o,active:t,sessions:u,outbox:j,online:E===`open`,repoForCwd:g,uploads:{uploading:ne,parking:z,upProg:B,uploadPending:V,uploadRowLinger:H,cancelUploads:re},activeRepoId:ae,pickImageFor:bl,pickFileFor:Ml,visibleBacklogItems:h,setOverlay:y}),(0,Q.jsx)(Ax,{})]})})}function Lw(e){let{activeId:t,active:n,composeFocused:r,setComposeFocused:i,composeRef:a,cliMode:o}=e,[s,c]=(0,Z.useState)(``),l=X(`typingRoom`),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),g=e=>(!!e!==m&&h(!!e),e),_={onSessionScreen:!!n&&!m,typingRoom:l,composeFocused:r,cliMode:o,typingPeek:f,fullScreen:u},{typingMode:v,typingPeeking:y,fullMode:b,chromeHidden:x}=QC(_);return(0,Z.useEffect)(()=>{let e=document.documentElement;return x?e.dataset.typing=`1`:delete e.dataset.typing,()=>{delete e.dataset.typing}},[x]),(0,Z.useEffect)(()=>{m&&i(!1)},[m]),(0,Z.useEffect)(()=>{r||p(!1)},[r]),(0,Z.useEffect)(()=>{if(!r)return;let e=window.visualViewport,t=null,n=0,i=()=>tw(t,e?.height??window.innerHeight,e?.width??window.innerWidth),o=()=>{t=i().next,clearTimeout(n),n=window.setTimeout(()=>{let e=i();t=e.next,e.closed&&a.current?.blur()},350)};return t=i().next,e?.addEventListener(`resize`,o),window.addEventListener(`resize`,o),()=>{clearTimeout(n),e?.removeEventListener(`resize`,o),window.removeEventListener(`resize`,o)}},[r]),(0,Z.useEffect)(()=>{p(!1)},[t]),(0,Z.useEffect)(()=>{t||d(!1)},[t]),{fullScreen:u,setFullScreen:d,typingPeek:f,setTypingPeek:p,dismissedReply:s,setDismissedReply:c,typingMode:v,typingPeeking:y,fullMode:b,chromeHidden:x,chromeIn:_,drawnSheet:g}}var Rw=`<?xml version="1.0" encoding="UTF-8"?>
|
|
22
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
23
|
-
<defs>
|
|
24
|
-
<clipPath id="aclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
25
|
-
<linearGradient id="asky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0A1B28"/><stop offset="1" stop-color="#10324A"/></linearGradient>
|
|
26
|
-
<linearGradient id="asea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0F5A66"/><stop offset="1" stop-color="#061219"/></linearGradient>
|
|
27
|
-
<linearGradient id="awarm" gradientUnits="userSpaceOnUse" x1="60" y1="140" x2="300" y2="320"><stop offset="0" stop-color="#F5A93F"/><stop offset="1" stop-color="#EC6F55"/></linearGradient>
|
|
28
|
-
<radialGradient id="aglow" cx=".74" cy=".62" r=".42">
|
|
29
|
-
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.34"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
30
|
-
<clipPath id="arip"><rect x="30" y="344" width="380" height="12"/><rect x="46" y="364" width="356" height="11"/><rect x="30" y="384" width="332" height="10"/><rect x="46" y="404" width="308" height="9"/><rect x="30" y="424" width="284" height="8"/><rect x="46" y="444" width="260" height="7"/><rect x="30" y="464" width="236" height="6"/><rect x="46" y="484" width="212" height="5"/></clipPath>
|
|
31
|
-
<linearGradient id="afade" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".9"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>
|
|
32
|
-
<mask id="arm"><rect y="330" width="512" height="182" fill="url(#afade)"/></mask>
|
|
33
|
-
</defs>
|
|
34
|
-
<g clip-path="url(#aclip)">
|
|
35
|
-
<rect width="512" height="512" fill="url(#asky)"/>
|
|
36
|
-
<circle cx="74" cy="70" r="2" fill="#E9F4F2" opacity=".5"/><circle cx="150" cy="104" r="1.4" fill="#E9F4F2" opacity=".5"/><circle cx="412" cy="76" r="2.2" fill="#E9F4F2" opacity=".5"/><circle cx="462" cy="146" r="1.3" fill="#E9F4F2" opacity=".5"/><circle cx="334" cy="56" r="1.5" fill="#E9F4F2" opacity=".5"/><circle cx="226" cy="48" r="1.1" fill="#E9F4F2" opacity=".5"/><circle cx="40" cy="150" r="1.2" fill="#E9F4F2" opacity=".5"/>
|
|
37
|
-
<rect width="512" height="512" fill="url(#aglow)"/>
|
|
38
|
-
<rect y="330" width="512" height="182" fill="url(#asea)"/>
|
|
39
|
-
<path d="M40,172 L4,168 M44,292 L10,296" stroke="#E9F4F2" stroke-width="4" stroke-linecap="round" opacity=".22"/>
|
|
40
|
-
|
|
41
|
-
<g transform="rotate(7 286 228)">
|
|
42
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#awarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
43
|
-
<path d="M272,228 L84,228" stroke="url(#awarm)" stroke-width="22" stroke-linecap="round"/>
|
|
44
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#awarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
45
|
-
<path d="M140,160 L270,228" stroke="#fff" stroke-opacity=".28" stroke-width="7" stroke-linecap="round"/>
|
|
46
|
-
<circle cx="250" cy="228" r="6.5" fill="#0A1B28" opacity=".5"/>
|
|
47
|
-
</g>
|
|
48
|
-
|
|
49
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
50
|
-
<animate attributeName="opacity" values="1;1;.12;.12" keyTimes="0;.5;.56;1" dur="1.1s" repeatCount="indefinite"/>
|
|
51
|
-
</rect>
|
|
52
|
-
<g mask="url(#arm)"><g clip-path="url(#arip)" opacity="0.4"><g transform="translate(0,660) scale(1,-1)">
|
|
53
|
-
|
|
54
|
-
<g transform="rotate(7 286 228)">
|
|
55
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="#F5A93F" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
56
|
-
<path d="M272,228 L84,228" stroke="#F5A93F" stroke-width="22" stroke-linecap="round"/>
|
|
57
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="#F5A93F" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
58
|
-
|
|
59
|
-
</g>
|
|
60
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
61
|
-
</rect></g></g></g>
|
|
62
|
-
<path d="M300,338 q11,-5 22,0 t22,0 t22,0 t22,0 t22,0 t22,0 t22,0" fill="none" stroke="#E9F4F2" stroke-width="3" opacity=".5"/>
|
|
63
|
-
</g></svg>
|
|
64
|
-
`,zw=`<?xml version="1.0" encoding="UTF-8"?>
|
|
65
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
66
|
-
<defs>
|
|
67
|
-
<clipPath id="sclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
68
|
-
<linearGradient id="ssky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0A1B28"/><stop offset="1" stop-color="#10324A"/></linearGradient>
|
|
69
|
-
<linearGradient id="ssea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0F5A66"/><stop offset="1" stop-color="#061219"/></linearGradient>
|
|
70
|
-
<linearGradient id="swarm" gradientUnits="userSpaceOnUse" x1="60" y1="140" x2="300" y2="320"><stop offset="0" stop-color="#F5A93F"/><stop offset="1" stop-color="#EC6F55"/></linearGradient>
|
|
71
|
-
<radialGradient id="sglow" cx=".74" cy=".62" r=".42">
|
|
72
|
-
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.34"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
73
|
-
<clipPath id="srip"><rect x="30" y="344" width="380" height="12"/><rect x="46" y="364" width="356" height="11"/><rect x="30" y="384" width="332" height="10"/><rect x="46" y="404" width="308" height="9"/><rect x="30" y="424" width="284" height="8"/><rect x="46" y="444" width="260" height="7"/><rect x="30" y="464" width="236" height="6"/><rect x="46" y="484" width="212" height="5"/></clipPath>
|
|
74
|
-
<linearGradient id="sfade" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".9"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>
|
|
75
|
-
<mask id="srm"><rect y="330" width="512" height="182" fill="url(#sfade)"/></mask>
|
|
76
|
-
</defs>
|
|
77
|
-
<g clip-path="url(#sclip)">
|
|
78
|
-
<rect width="512" height="512" fill="url(#ssky)"/>
|
|
79
|
-
|
|
80
|
-
<rect width="512" height="512" fill="url(#sglow)"/>
|
|
81
|
-
<rect y="330" width="512" height="182" fill="url(#ssea)"/>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<g transform="rotate(7 286 228)">
|
|
85
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#swarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
86
|
-
<path d="M272,228 L84,228" stroke="url(#swarm)" stroke-width="22" stroke-linecap="round"/>
|
|
87
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#swarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
88
|
-
|
|
89
|
-
</g>
|
|
90
|
-
|
|
91
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
92
|
-
</rect>
|
|
93
|
-
|
|
94
|
-
</g></svg>
|
|
95
|
-
`,Bw=`<?xml version="1.0" encoding="UTF-8"?>
|
|
96
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
97
|
-
<defs>
|
|
98
|
-
<clipPath id="lclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
99
|
-
<linearGradient id="lsky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#F4F8F7"/><stop offset="1" stop-color="#E3EFEE"/></linearGradient>
|
|
100
|
-
<linearGradient id="lsea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#BFDDDB"/><stop offset="1" stop-color="#93C1BF"/></linearGradient>
|
|
101
|
-
<linearGradient id="lwarm" gradientUnits="userSpaceOnUse" x1="60" y1="140" x2="300" y2="320"><stop offset="0" stop-color="#F5A93F"/><stop offset="1" stop-color="#EC6F55"/></linearGradient>
|
|
102
|
-
<radialGradient id="lglow" cx=".74" cy=".62" r=".42">
|
|
103
|
-
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.22"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
104
|
-
<clipPath id="lrip"><rect x="30" y="344" width="380" height="12"/><rect x="46" y="364" width="356" height="11"/><rect x="30" y="384" width="332" height="10"/><rect x="46" y="404" width="308" height="9"/><rect x="30" y="424" width="284" height="8"/><rect x="46" y="444" width="260" height="7"/><rect x="30" y="464" width="236" height="6"/><rect x="46" y="484" width="212" height="5"/></clipPath>
|
|
105
|
-
<linearGradient id="lfade" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".9"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>
|
|
106
|
-
<mask id="lrm"><rect y="330" width="512" height="182" fill="url(#lfade)"/></mask>
|
|
107
|
-
</defs>
|
|
108
|
-
<g clip-path="url(#lclip)">
|
|
109
|
-
<rect width="512" height="512" fill="url(#lsky)"/>
|
|
110
|
-
|
|
111
|
-
<rect width="512" height="512" fill="url(#lglow)"/>
|
|
112
|
-
<rect y="330" width="512" height="182" fill="url(#lsea)"/>
|
|
113
|
-
<path d="M40,172 L4,168 M44,292 L10,296" stroke="#0A1620" stroke-width="4" stroke-linecap="round" opacity=".22"/>
|
|
114
|
-
|
|
115
|
-
<g transform="rotate(7 286 228)">
|
|
116
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#lwarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
117
|
-
<path d="M272,228 L84,228" stroke="url(#lwarm)" stroke-width="22" stroke-linecap="round"/>
|
|
118
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#lwarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
119
|
-
<path d="M140,160 L270,228" stroke="#fff" stroke-opacity=".28" stroke-width="7" stroke-linecap="round"/>
|
|
120
|
-
<circle cx="250" cy="228" r="6.5" fill="#0A1B28" opacity=".5"/>
|
|
121
|
-
</g>
|
|
122
|
-
|
|
123
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#EC6F55">
|
|
124
|
-
</rect>
|
|
125
|
-
<g mask="url(#lrm)"><g clip-path="url(#lrip)" opacity="0.45"><g transform="translate(0,660) scale(1,-1)">
|
|
126
|
-
|
|
127
|
-
<g transform="rotate(7 286 228)">
|
|
128
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="#F5A93F" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
129
|
-
<path d="M272,228 L84,228" stroke="#F5A93F" stroke-width="22" stroke-linecap="round"/>
|
|
130
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="#F5A93F" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
131
|
-
|
|
132
|
-
</g>
|
|
133
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#F5A93F">
|
|
134
|
-
</rect></g></g></g>
|
|
135
|
-
<path d="M300,338 q11,-5 22,0 t22,0 t22,0 t22,0 t22,0 t22,0 t22,0" fill="none" stroke="#fff" stroke-width="3" opacity=".5"/>
|
|
136
|
-
</g></svg>
|
|
137
|
-
`,Vw=`<?xml version="1.0" encoding="UTF-8"?>
|
|
138
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
139
|
-
<defs>
|
|
140
|
-
<clipPath id="slclip"><rect width="512" height="512" rx="114"/></clipPath>
|
|
141
|
-
<linearGradient id="slsky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#F4F8F7"/><stop offset="1" stop-color="#E3EFEE"/></linearGradient>
|
|
142
|
-
<linearGradient id="slsea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#BFDDDB"/><stop offset="1" stop-color="#93C1BF"/></linearGradient>
|
|
143
|
-
<linearGradient id="slwarm" gradientUnits="userSpaceOnUse" x1="60" y1="140" x2="300" y2="320"><stop offset="0" stop-color="#F5A93F"/><stop offset="1" stop-color="#EC6F55"/></linearGradient>
|
|
144
|
-
<radialGradient id="slglow" cx=".74" cy=".62" r=".42">
|
|
145
|
-
<stop offset="0" stop-color="#F5A93F" stop-opacity="0.22"/><stop offset="1" stop-color="#F5A93F" stop-opacity="0"/></radialGradient>
|
|
146
|
-
<clipPath id="slrip"><rect x="30" y="344" width="380" height="12"/><rect x="46" y="364" width="356" height="11"/><rect x="30" y="384" width="332" height="10"/><rect x="46" y="404" width="308" height="9"/><rect x="30" y="424" width="284" height="8"/><rect x="46" y="444" width="260" height="7"/><rect x="30" y="464" width="236" height="6"/><rect x="46" y="484" width="212" height="5"/></clipPath>
|
|
147
|
-
<linearGradient id="slfade" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".9"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>
|
|
148
|
-
<mask id="slrm"><rect y="330" width="512" height="182" fill="url(#slfade)"/></mask>
|
|
149
|
-
</defs>
|
|
150
|
-
<g clip-path="url(#slclip)">
|
|
151
|
-
<rect width="512" height="512" fill="url(#slsky)"/>
|
|
152
|
-
|
|
153
|
-
<rect width="512" height="512" fill="url(#slglow)"/>
|
|
154
|
-
<rect y="330" width="512" height="182" fill="url(#slsea)"/>
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
<g transform="rotate(7 286 228)">
|
|
158
|
-
<path d="M128,146 L286,228 L128,310" fill="none" stroke="url(#slwarm)" stroke-width="50" stroke-linecap="round" stroke-linejoin="round"/>
|
|
159
|
-
<path d="M272,228 L84,228" stroke="url(#slwarm)" stroke-width="22" stroke-linecap="round"/>
|
|
160
|
-
<path d="M92,204 L104,228 L92,252" fill="none" stroke="url(#slwarm)" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
|
161
|
-
|
|
162
|
-
</g>
|
|
163
|
-
|
|
164
|
-
<rect x="318" y="302" width="128" height="28" rx="9" fill="#EC6F55">
|
|
165
|
-
</rect>
|
|
166
|
-
|
|
167
|
-
</g>
|
|
168
|
-
<rect x="6" y="6" width="500" height="500" rx="108" fill="none" stroke="#0A1B28" stroke-opacity=".14" stroke-width="12"/></svg>
|
|
169
|
-
`;function Hw(e){return e<64}var Uw=e=>e.replace(/<\?xml[^>]*\?>/,``).replace(/<animate\b[^>]*\/>/g,``).replace(/<(animate)\b[^>]*>[\s\S]*?<\/\1>/g,``),Ww=e=>`data:image/svg+xml;charset=utf-8,${encodeURIComponent(Uw(e))}`,Gw={dark:{full:Ww(Rw),small:Ww(zw)},light:{full:Ww(Bw),small:Ww(Vw)}};function Kw(){let[e,t]=(0,Z.useState)(yi);return(0,Z.useEffect)(()=>Lr(e=>t(e)),[]),e}function qw({size:e=32,label:t=jt()}){let n=Gw[Kw()];return(0,Q.jsx)(`img`,{className:`logo`,src:Hw(e)?n.small:n.full,alt:t,width:e,height:e,style:{display:`block`,width:e,height:e,flex:`0 0 auto`}})}var Jw=4,Yw=20;function Xw(e){let t=e.querySelector(`.topbar`);if(!t)return 0;let n=[...t.children].map(e=>e.getBoundingClientRect()).filter(e=>e.height>0);if(!n.length)return 0;let r=Math.min(...n.map(e=>e.top)),i=Math.max(...n.filter(e=>e.top<r+Yw).map(e=>e.bottom)),a=getComputedStyle(t);return Math.ceil(i-e.getBoundingClientRect().top+parseFloat(a.paddingBottom)+parseFloat(a.borderBottomWidth))}function Zw({off:e,children:t}){let n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)({natural:0,line:0});(0,Z.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=Math.ceil(e.getBoundingClientRect().height),n=Xw(e);i(e=>e.natural===t&&e.line===n?e:{natural:t,line:n})};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);let{frame:a,cap:o,capped:s,cut:c,grip:l}=Sp({key:G.launcherChromeH,off:e,floorPx:r.line,showAllEvent:`action:launcherChrome.showAll`,capEvent:`action:launcherChrome.cap`}),u=c?`top shortened — tap to show all of it, or drag down for more`:`drag up to hide what is under the first line`,d=r.natural>r.line+Jw;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:a,className:`sess-chrome${s?` capped`:``}`,style:s?{maxHeight:`${Math.max(o??0,r.line)}px`}:void 0,children:(0,Q.jsx)(`div`,{ref:n,children:t})}),!e&&(d||c)&&(0,Q.jsx)(`div`,{className:`sess-chrome-grip${c?` capped worded`:``}`,role:`separator`,"aria-orientation":`horizontal`,tabIndex:0,"aria-label":u,title:u,...l,children:c&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(hg,{size:12,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:`shortened · tap for all of it`})]})})]})}var Qw=[`queued`,`blocked`,`starting`,`running`];function $w(e){return Qw.includes(e.state)&&!e.archived}function eT(e){let t=new Map;for(let n of e){if(n.trigger.kind!==`at`||n.target.kind!==`session`||!$w(n))continue;let e=t.get(n.target.sessionId)??{ids:[],nextAt:null};e.ids.push(n.id),n.nextAt!=null&&(e.nextAt=e.nextAt==null?n.nextAt:Math.min(e.nextAt,n.nextAt)),t.set(n.target.sessionId,e)}return t}function tT(e,t){return e.some(e=>t.has(e))}var nT=Cn(null),rT=Cn(``),iT=Cn(Dr()),aT=Cn(Id()),oT=Cn(`home`),sT=Cn([]),cT=Cn(null),lT=Cn(!1),uT=Cn(!1),dT=Cn(null);_t(G.closeCustomH),_t(G.closeBy);var fT=Cn(Dt(G.closeKeepStar,!0)),pT={top:0};function mT(e){return[up(e),e.set]}function hT(e){let{sessions:t,recent:n,closed:r,repos:i,intents:a,outbox:o,nowTick:c}=e,{hiddenRepoPaths:l,cwdInFocus:d,visibleRepos:p,hiddenRepos:m}=e.view,{focusRepo:h,setFocusRepo:g}=e.route,[_,v]=mT(nT),[y,b]=mT(rT),x=y.trim()!==``,[S,C]=mT(iT),[w,T]=mT(aT),[E,D]=mT(oT),[O,k]=mT(sT),[A,j]=mT(cT),[M,ee]=mT(lT),[P,F]=mT(uT),[I,te]=mT(dT),[L,R]=mT(fT),[ne,z]=(0,Z.useState)(null),B=e=>$y(i,e),V=e=>B(e.cwd),H=e=>eb(i,e),re=e=>rb(i,e),ie=e=>ib(i,e),U=e=>ab(i,e),ae=(0,Z.useMemo)(()=>t.filter(e=>!l.has(e.cwd)&&d(e.cwd)),[t,l,h,i]),oe=(0,Z.useMemo)(()=>t.filter(e=>l.has(e.cwd)&&d(e.cwd)),[t,l,h,i]),W=(0,Z.useMemo)(()=>db(ae,w,H),[ae,w,i]);function se(e,t){v(n=>n&&n.status===e&&n.repo===t?null:(q(`action:session.filter.${e}`),{status:e,repo:t}))}let ce=(e,t)=>!!_&&_.status===e&&_.repo===t,le=(0,Z.useMemo)(()=>mb(W,_,(t,n)=>n===`worktrees`?B(t.cwd)?.isPrimary===!1:Kt(t,n,e.backends),H).filter(e=>!x||Mb(y,[e.tabTitle,e.title,e.firstPrompt,e.lastPrompt,e.pinnedPrompt,H(e),tb(i,e),ie(e)])),[W,_,i,y,e.backends]),ue=(0,Z.useMemo)(()=>hb(W,t=>an(t,e.backends),H),[W,i,e.backends]),de=(0,Z.useMemo)(()=>bi(t,`wait`,e.backends,e.view.cwdVisible),[t,e.backends,e.view.cwdVisible]),fe=(0,Z.useMemo)(()=>bi(t,`blocked`,e.backends,e.view.cwdVisible),[t,e.backends,e.view.cwdVisible]),pe=de.shown.length,me=(0,Z.useMemo)(()=>eT(a),[a]),he=(0,Z.useMemo)(()=>{let t=new Map;for(let n of W)an(n,e.backends)===`wait`&&me.has(n.id)&&t.set(H(n),!0);return t},[W,me,i,e.backends]),ge=(0,Z.useMemo)(()=>tT(W.filter(t=>an(t,e.backends)===`wait`).map(e=>e.id),me),[W,me,e.backends]),_e=fe.shown.length,ve=(0,Z.useMemo)(()=>gb(ue,`coding`),[ue]),ye=(0,Z.useMemo)(()=>_b(W,H),[W,i]),be=(0,Z.useMemo)(()=>vb(W,H),[W,i]),xe=(0,Z.useMemo)(()=>[...ye.values()].reduce((e,t)=>e+t,0),[ye]),Se=(0,Z.useMemo)(()=>Er(W,H),[W,i]),Ce=(0,Z.useMemo)(()=>Ko(Se),[Se]),we=(0,Z.useMemo)(()=>W.filter(e=>e.shellList?.length).length,[W]),Te=Br(),Ee=ir(),De=(0,Z.useMemo)(()=>wb(o,a,Te,e=>{let t=B(e);return t?N(t):Fu(e)}),[o,a,i,Te]),Oe=(0,Z.useMemo)(()=>new Map(a.map(e=>[e.id,e])),[a]);function ke(e){C(e),mt(xi,[...e])}function Ae(e){q(`action:repo.collapse`);let t=new Set(S);t.has(e)?t.delete(e):t.add(e),ke(t)}let je=(0,Z.useMemo)(()=>{let e=new Map;for(let t of i)e.set(N(t),f(t));return e},[i]),Me=e=>je.get(e)??e,Ne=e=>i.find(t=>N(t)===e&&t.isPrimary)??null,Pe=e=>p.filter(t=>N(t)===e&&!t.isPrimary),Fe=X(`repoSort`),Ie=(0,Z.useMemo)(()=>Fe===`sessions`?xb(W,H):void 0,[Fe,W,i]),Le=(0,Z.useMemo)(()=>Sb(le,p,!!_||x,H,_?.status===`worktrees`&&_.repo?[_.repo]:x&&!_?p.filter(e=>Mb(y,[N(e),e.displayName,e.branch])).map(e=>N(e)):[],Ie),[le,p,_,i,y,Ie]),Re=Le.length>0&&Le.every(e=>S.has(e.repoName)),ze=Le.every(e=>!S.has(e.repoName)),Be=(0,Z.useRef)(!1);function Ve(e){let n=fb(aT.get(),e,new Set(t.map(e=>e.id)));T(n),mt(on,n)}function He(){T([]),_t(on)}function Ue(e,t){if(e.pointerType===`mouse`&&e.button!==0)return;Be.current=!1;let n=e.clientX,r=e.clientY,i=window.setTimeout(()=>{i=void 0,s(),Be.current=!0,z(t),navigator.vibrate?.(15),q(`action:session.reorder`)},400),a=e=>{Math.hypot(e.clientX-n,e.clientY-r)>10&&o()},o=()=>{i&&clearTimeout(i),s()},s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),window.removeEventListener(`scroll`,o,!0)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),window.addEventListener(`scroll`,o,!0)}(0,Z.useEffect)(()=>{if(!ne)return;let e=e=>{let t=(document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-sid]`))?.getAttribute(`data-sid`),n=t?pb(W,ne,t,H):null;n&&Ve(n)},t=e=>e.preventDefault(),n=()=>z(null);return window.addEventListener(`pointermove`,e),window.addEventListener(`touchmove`,t,{passive:!1}),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`touchmove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n)}},[ne,W]),(0,Z.useEffect)(()=>{E===`external`&&Dn.external().then(k).catch(()=>k([]))},[E,e.conn.status]);let We=(0,Z.useMemo)(()=>O.filter(e=>d(e.cwd)),[O,h,i]);function Ge(e){hl()?g(e):window.open(`${location.pathname}?repo=${encodeURIComponent(e)}`,`_blank`)}function Ke(){g(null)}let qe=vi(a,o,c),Je=qe.horizon,Ye=s(Je),Xe=(0,Z.useMemo)(()=>Vp({cuts:qe,repoOf:e=>{let t=B(e);return t?N(t):Fu(e)||null},now:Date.now()}),[qe,i,c]),Ze=u(Je),Qe=Je.unarmed>0&&Je.unarmed===Je.total,$e=qe.kinds,tt=[$e.rules?`${$e.rules} rule${$e.rules===1?``:`s`}`:``,$e.timed?`${$e.timed} on a clock in a backlog`:``].filter(Boolean).join(` · `),nt=Ye?`${ec.automation.toLowerCase()} · ${tt} — ${Ye}${Je.unarmed&&!Qe?` · ${Je.unarmed} not armed`:``} — tap to see the ${Ze?et[Ze]:``} ones`:`${ec.automation.toLowerCase()} — run a prompt on its own at a time you pick (once, every week, or around a usage window)`,rt=(0,Z.useMemo)(()=>Tb(o,a,{has:e=>Te.has(e)||Ee.has(e)}),[o,a,Te,Ee]),it=rt.length,at=Nu(),ot=oi(Ho(at,ur())),st=new Set(t.map(e=>e.cwd)),ct=new Set(t.map(Mi).filter(Boolean)),lt=e=>{let t=Mi(e);return t?ct.has(t):st.has(e.cwd)},ut=n.filter(e=>!lt(e)&&l.has(e.cwd)&&d(e.cwd));return{statusFilter:_,setStatusFilter:v,toggleStatusFilter:se,statusFilterActive:ce,textQuery:y,setTextQuery:b,textOn:x,collapsedRepos:S,persistCollapsedRepos:ke,toggleRepoCollapsed:Ae,sessionOrder:w,saveSessionOrder:Ve,resetSessionOrder:He,dragSid:ne,dragRef:Be,armRowDrag:Ue,tab:E,setTab:D,repoMenu:A,setRepoMenu:j,navMenu:M,setNavMenu:ee,showHidden:P,setShowHidden:F,closeAllPick:I,setCloseAllPick:te,closeKeepStar:L,setCloseKeepStar:R,repoForCwd:B,sessionRepo:V,sessionRepoName:H,sessionRepoLabel:re,sessionRowBranch:ie,sessionRowTitle:U,visibleSessions:ae,hiddenSessions:oe,sortedSessions:W,shownSessions:le,repoGroups:Le,allReposCollapsed:Re,noRepoCollapsed:ze,primaryRepo:Ne,worktreesOf:Pe,shownOf:Me,attentionByRepo:ue,waitingTotal:pe,repliesBySession:me,waitingRepliesByRepo:he,waitingRepliesTotal:ge,blockedTotal:_e,codingTotal:ve,starredByRepo:ye,starredTotal:xe,flaggedByRepo:Se,flaggedTotal:Ce,sessionNumbers:be,shellsTotal:we,queuedByRepo:De,intentById:Oe,visibleExternal:We,openFocusWindow:Ge,clearFocus:Ke,scheduleWords:Ye,scheduleLead:Ze,scheduleTitle:nt,clocksPerRepo:Xe,activityBadge:it,activityKeys:rt,dl:ot,visibleRecent:n.filter(e=>!lt(e)&&!l.has(e.cwd)&&d(e.cwd)),hiddenRecent:ut,reopenable:r.filter(e=>!lt(e)&&d(e.cwd)),hiddenCount:m.length+oe.length+ut.length}}var gT=16,_T=(e,t)=>e?(0,Q.jsxs)(Q.Fragment,{children:[e.outboxCount>0&&(0,Q.jsxs)(`button`,{className:`row-act count`,title:`${e.outboxCount} new outbox file${e.outboxCount>1?`s`:``} since last opened — open gallery`,onClick:()=>fo(e.id),children:[(0,Q.jsx)(wg,{size:14}),e.outboxCount]}),mi(e)&&(0,Q.jsxs)(`button`,{className:`row-act count`,title:Lp(e),onClick:()=>t(e.id),children:[(0,Q.jsx)(fm,{size:14}),e.changedCount>0&&e.changedCount,ja(e)&&(0,Q.jsx)(`span`,{className:`git-ab`,children:ja(e)})]})]}):null;function vT({p:e,m:t,s:n,repoName:r}){let i=Lg()(n),{backends:a,openGitFor:o}=e,{status:s,liveSend:c}=e.conn,{lastVisitedId:l}=e.route,{attach:u,openReader:d}=e.term,{sessionCan:f}=e.launchCore,{pendingStars:p,toggleStar:m,pendingFollowUps:h,toggleFollowUp:g,closeSession:_}=e.verbs,{dragSid:v,dragRef:y,armRowDrag:b,sessionRowBranch:x,sessionRepoName:S,sessionRepoLabel:C,sessionRowTitle:w,sessionRepo:T,repliesBySession:E,sessionNumbers:D}=t,O=Ii(),k={isOn:e=>t.statusFilterActive(e),toggle:e=>t.toggleStatusFilter(e)},A=C(n),j=(()=>{let e=Fd(n);return!!(e.first||e.now)})(),M=j?``:n.title&&n.title!==A&&n.title!==r?n.title:``;return(0,Q.jsxs)(`div`,{className:`row-wrap${n.id===l?` row-recent`:``}${n.id===v?` row-dragging`:``}`,style:Ka(r),"data-sid":n.id,children:[(0,Q.jsxs)(`button`,{className:`row grow${n.id===v?` dragging`:``}`,"data-nohint":!0,title:`tap to open · press and hold to drag into a new position`,onPointerDown:e=>b(e,n.id),onContextMenu:e=>e.preventDefault(),onClick:()=>{y.current||u(n)},children:[(0,Q.jsxs)(`span`,{className:`row-head`,children:[D.has(n.id)&&(0,Q.jsx)(`span`,{className:`row-num`,title:`open session ${D.get(n.id)} in ${t.shownOf(r)}`,children:D.get(n.id)}),x(n)&&(0,Q.jsx)(pd,{children:x(n)}),se(n)?(0,Q.jsx)(Si,{s:n}):!x(n)&&(0,Q.jsx)(pd,{children:t.shownOf(S(n))}),(0,Q.jsxs)(`span`,{className:`row-meta`,children:[(0,Q.jsx)(nc,{className:`row-launch${$a(a,n.backend)?` row-foreign`:``}`,children:pu(Po(n),$a(a,n.backend),a)}),n.createdAt&&n.running&&(0,Q.jsxs)(nc,{title:`session open for ${ml(n.createdAt)}`,children:[(0,Q.jsx)(Dh,{size:11}),` `,ml(n.createdAt)]})]})]}),(0,Q.jsxs)(`span`,{className:`row-gist`,children:[j?(0,Q.jsx)(ci,{firstPrompt:n.firstPrompt,lastPrompt:n.lastPrompt,pinnedPrompt:n.pinnedPrompt}):M&&(0,Q.jsx)(`span`,{className:`row-summary`,children:M}),n.followUp&&(0,Q.jsx)(kS,{f:n.followUp})]})]}),(0,Q.jsxs)(`div`,{className:`row-acts`,children:[(0,Q.jsx)(`span`,{className:`row-stat`,children:lx(n,k,n.starred&&n.newActivity,a)}),(0,Q.jsxs)(`span`,{className:`row-tags`,children:[n.remoteControlled&&(0,Q.jsxs)(df,{className:`rc-tag`,title:`a desktop is driving this session`,children:[(0,Q.jsx)(bg,{size:12}),` RC`]}),(()=>{let e=E.get(n.id);if(!e)return null;let t=e.ids.length,r=e.nextAt==null?`when its window opens`:it(e.nextAt),i=()=>{q(`action:session.scheduled.open`),Ld(n.cwd,e.ids,`scheduled for ${n.title}`)};return(0,Q.jsxs)(df,{className:`sched tag-filter`,role:`button`,tabIndex:0,title:`${t} prompt${t>1?`s`:``} on a clock for this session — next ${r}; tap to open ${t>1?`them`:`it`}`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),i())},onClick:e=>{e.stopPropagation(),i()},children:[(0,Q.jsx)(Vm,{size:12}),` `,t>1?`${t} · `:``,r]})})(),(0,Q.jsx)(Zc,{s:n}),(0,Q.jsx)(ya,{s:n}),mx(n,()=>Qo(n)),ux(n,O),(0,Q.jsx)(Eu,{s:n}),(0,Q.jsx)(Sf,{sessionId:n.id}),_T(T(n),o)]}),(()=>{let e=_x(n,()=>Ni(n.id)),t=dx(n),r=f(n,`transcript`);return(e||t||r||n.contextSpark)&&(0,Q.jsxs)(`span`,{className:`row-side`,children:[r&&(()=>{let e=hx(n);return(0,Q.jsxs)(`button`,{className:`row-act${e==null?``:` tally`}`,title:`outline — where this session got to, without opening the terminal${gx(e)}`,onClick:()=>d(n),children:[(0,Q.jsx)(am,{size:gT}),e??null]})})(),(e||t)&&(0,Q.jsxs)(`span`,{className:`row-side-top`,children:[t,e]}),n.contextSpark&&(0,Q.jsxs)(`span`,{className:`row-spark tappable`,role:`button`,tabIndex:0,"aria-label":`what this session has cost — open the context graph for ${w(n)}`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Nr(n))},onClick:e=>{e.stopPropagation(),Nr(n)},children:[fx(n),px(n),(0,Q.jsx)(xr,{spark:n.contextSpark,value:!0}),(0,Q.jsx)(_o,{spark:n.contextSpark,warn:i})]})]})})(),(0,Q.jsxs)(`span`,{className:`row-ctl`,children:[(0,Q.jsx)(`button`,{className:`row-act${n.starred?` starred`:``}${n.id in p?` star-pending`:``}`,"data-hint":`session.star`,title:n.id in p?s===`open`?`starred here — the desktop has not confirmed it yet`:`starred here — offline, so it is only on this phone until the link is back`:n.starred?`unstar (prima interest)`:`star — mark as prima interest to come back to`,onClick:()=>m(n.id,!n.starred),children:(0,Q.jsx)(em,{size:gT,fill:n.starred?`currentColor`:`none`})}),(0,Q.jsx)(`button`,{className:`row-act fu-btn${ES(n.followUp)}${n.id in h?` star-pending`:``}`,"data-hint":`session.followup`,"aria-pressed":!!n.followUp,title:DS(n,n.id in h,s===`open`),onClick:()=>g(n.id,!n.followUp),children:(0,Q.jsx)(OS,{on:!!n.followUp,size:gT})}),(0,Q.jsx)(`button`,{className:`row-act`,title:`name this session`,onClick:()=>{lS(n,c)},children:(0,Q.jsx)(qm,{size:gT})}),(0,Q.jsx)(`button`,{className:`row-act danger`,title:n.running?`close`:`remove`,onClick:()=>_(n),children:(0,Q.jsx)(Lh,{size:gT})})]})]})]})}var yT=new Map;function bT({repo:e,onSaved:t}){let[n,r]=(0,Z.useState)(yT.has(e.id)),[i,a]=(0,Z.useState)(()=>yT.get(e.id)??e.displayName??``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),u=e.repoName,d=e.displayName??null,f=t=>{a(t),l(null),t===(d??``)?yT.delete(e.id):yT.set(e.id,t)};async function p(n){q(n?`action:repo.shownas.save`:`action:repo.shownas.clear`);let i=tt(n);if(!i.ok)l(i.error);else{s(!0);try{let n=await Dn.setRepoDisplayName(e.id,i.value);if(!n.ok){l(n.error);return}yT.delete(e.id),a(n.name??``),r(!1),K(n.name?`${u} is shown as “${n.name}” — the folder keeps its name`:`${u} is shown by its folder name again`),t()}catch{l(`The desktop did not answer, so nothing was changed. What you typed is still here.`)}finally{s(!1)}}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{className:`more-act${d?` names`:``}${n?` on`:``}`,"aria-expanded":n,title:d?`shown as “${d}” — change it, or go back to the folder name “${u}”`:`change the name this repo is shown under; the folder “${u}” keeps its name`,onClick:()=>{q(`action:repo.shownas`),r(e=>!e)},children:[(0,Q.jsx)(Ah,{size:16}),d?(0,Q.jsxs)(Q.Fragment,{children:[`shown as `,(0,Q.jsx)(`b`,{children:d})]}):`shown as…`]}),n&&(0,Q.jsxs)(`div`,{className:`shownas`,style:{flex:`0 0 100%`},children:[(0,Q.jsxs)(`div`,{className:`plugin-field`,children:[(0,Q.jsx)(`input`,{type:`text`,value:i,placeholder:u,"aria-label":`name to show for ${u}`,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!o&&p(i)}}),(0,Q.jsx)(Y,{variant:`primary`,onClick:()=>void p(i),children:o?`saving…`:`save`}),d&&(0,Q.jsxs)(Y,{onClick:()=>void p(null),children:[`use “`,u,`”`]})]}),(0,Q.jsxs)(Dc,{children:[`Only what is shown changes, on every device. The folder is still “`,u,`”, and so are the repo’s colour and everything that finds it by name.`]}),c&&(0,Q.jsx)(Dc,{tone:`warn`,children:c})]})]})}function xT({def:e,repo:t}){let n=e.useCount(t);if(!n||!(n.n>0))return null;let r=e.icon;return(0,Q.jsxs)(`button`,{className:`repo-group-stat`,title:n.title,onClick:()=>{q(`action:repo.chip.${e.id}`),e.open(t,n.filter,Yn())},children:[(0,Q.jsx)(r,{size:12}),n.text??`${n.label?`${n.label} `:``}${n.n}`]})}function ST({kind:e,n:t,onClick:n,repo:r,on:i,replies:a,hint:o}){if(t<=0)return null;let s=e===`wait`?pg:ah;return(0,Q.jsxs)(`button`,{className:`${r?e===`wait`?`repo-group-wait`:`repo-group-stat limit`:e===`wait`?`head-wait`:`head-wait limit`}${i?` on`:``}`,"data-hint":o,title:La(e,t,{repo:r,replies:a}),onClick:n,children:[(0,Q.jsx)(s,{size:13}),r?``:` `,t,r&&e===`blocked`?``:` ${Rr[e]}`,a&&(0,Q.jsx)(Vm,{size:11,className:`wait-sched`})]})}function CT(e){let[t,n]=(0,Z.useState)(new Map),[r,i]=(0,Z.useState)(0),a=e.join(`,`);return(0,Z.useEffect)(()=>{if(!e.length)return;let t=new AbortController;n(new Map(e.map(e=>[e,{state:`loading`}])));for(let r of e)Dn.worktreeLeftover(r,t.signal).then(e=>{t.signal.aborted||n(t=>new Map(t).set(r,{state:`ok`,v:e}))},e=>{t.signal.aborted||n(t=>new Map(t).set(r,{state:`error`,error:e instanceof Error?e.message:String(e)}))});return()=>t.abort()},[a,r]),{readings:t,recheck:(0,Z.useCallback)(()=>i(e=>e+1),[])}}var wT=e=>e?.state===`ok`&&e.v.blockers.length===0;async function TT(e,t){let n=0,r=[],i=[];for(let t of e)try{let e=await Dn.removeWorktree(t.id);e.ok?(n++,e.note&&i.push(e.note)):r.push(`${t.branch}: ${e.error??`refused`}`)}catch(e){r.push(`${t.branch}: ${e instanceof Error?e.message:String(e)}`)}let a=n?`Removed ${n} worktree${n===1?``:`s`} and ${n===1?`its branch`:`their branches`}.`:`Nothing removed.`;K([a,...i,...r.length?[`Kept ${r.join(`; `)}`]:[]].join(` `)),t()}function ET({wts:e,readings:t,onChanged:n}){let[r,i]=(0,Z.useState)(!1);if(!e.length)return null;let a=e.length,o=e.filter(e=>wT(t.get(e.id))),s=e.some(e=>t.get(e.id)?.state===`loading`),c=a-o.length;return(0,Q.jsxs)(`div`,{className:`wt-leftover-head`,children:[(0,Q.jsxs)(nc,{as:`div`,children:[`No session is using `,a===1?`this worktree`:`these ${a} worktrees`,`. A worktree is a second checkout of the repo, usually made for an agent; `,a===1?`it`:`they`,` outlived the session that made `,a===1?`it`:`them`,`.`,s?` Checking what is in them…`:o.length===a?` Every commit in ${a===1?`it`:`them`} is already on ${DT(o,t)}, and nothing is uncommitted — removing loses nothing.`:o.length?` ${o.length} hold nothing that is not on ${DT(o,t)}; ${c} hold work, said on ${c===1?`its`:`their`} row.`:` ${a===1?`It holds`:`Each holds`} work that is not anywhere else, said on the row — open it to commit or keep it.`]}),o.length>0&&(r?(0,Q.jsx)(nc,{children:`removing…`}):(0,Q.jsxs)(ss,{className:`key wt-leftover-go`,confirm:`remove ${o.length} for good?`,onConfirm:()=>{q(`action:repo.worktree.removeLeftovers`),i(!0),TT(o,()=>{i(!1),n()})},children:[(0,Q.jsx)(Ch,{size:14}),`remove `,o.length===a?a===1?`it`:`all ${a}`:`the ${o.length} safe`]}))]})}function DT(e,t){for(let n of e){let e=t.get(n.id);if(e?.state===`ok`&&e.v.base)return e.v.base}return`the main branch`}function OT({r:e}){return!e||e.state===`loading`?(0,Q.jsx)(nc,{className:`wt-leftover`,children:`checking what is in it…`}):e.state===`error`?(0,Q.jsxs)(nc,{className:`wt-leftover warn`,children:[(0,Q.jsx)(vh,{size:12}),`could not check it: `,e.error]}):e.v.blockers.length?(0,Q.jsxs)(nc,{className:`wt-leftover warn`,children:[(0,Q.jsx)(vh,{size:12}),`keep: `,e.v.blockers.join(` `)]}):(0,Q.jsxs)(nc,{className:`wt-leftover ok`,children:[(0,Q.jsx)(ng,{size:12}),`nothing only here — `,e.v.ahead?`its ${e.v.ahead} commit${e.v.ahead===1?` is`:`s are`} on ${e.v.base} as cherry-picks`:`all on ${e.v.base}`]})}function kT({t:e,r:t,onChanged:n}){return wT(t)?(0,Q.jsxs)(ss,{className:`more-act`,confirm:`remove for good?`,onConfirm:()=>{q(`action:repo.worktree.remove`),TT([e],n)},children:[(0,Q.jsx)(Ch,{size:16}),`remove worktree`]}):null}var AT=16;function jT({p:e,m:t,repoName:r,sessions:i}){let{intents:a,openGitFor:o}=e,{focusRepo:c,setOverlay:l}=e.route,{toggleHideRepo:u,openingCwds:d}=e.view,{openRepo:f,openShell:p,setBranchPick:m,refreshRepos:h}=e.launchCore,g=!!Yo(e.backends),{enterOldestPending:_,enterLater:v}=e.queue,{primaryRepo:y,worktreesOf:b,attentionByRepo:x,statusFilter:S,textOn:C,collapsedRepos:w,toggleRepoCollapsed:T,openFocusWindow:E,statusFilterActive:D,toggleStatusFilter:O,waitingRepliesByRepo:k,queuedByRepo:A,intentById:j,clocksPerRepo:M,starredByRepo:ee,flaggedByRepo:N,repoMenu:P,setRepoMenu:F,setCloseAllPick:I}=t,te=i.length,L=t.shownOf(r),R=y(r),z=b(r),B=z.length,V=z.filter(e=>!e.ownerSessionId),{readings:H,recheck:re}=CT(V.map(e=>e.id)),ie=()=>{h(),re()},U=x.get(r)??{wait:0,blocked:0,coding:0,done:0,exited:0},ae=te+B===0,[oe,W]=(0,Z.useState)(!1),se=ae?!oe:!S&&!C&&w.has(r),ce=(0,Z.useRef)(null),le=(0,Z.useRef)(null),ue=(0,Z.useRef)(!1);(0,Z.useLayoutEffect)(()=>{if(!ue.current)return;ue.current=!1;let e=ce.current,t=e?.closest(`.list`);if(!e||!t)return;let n=t.getBoundingClientRect().top,r=le.current;if(!se&&r&&xa(`unfoldToEnd`).current){let e=r.getBoundingClientRect().top-n;e>t.clientHeight&&t.scrollTo({top:t.scrollTop+e-t.clientHeight,behavior:`smooth`});return}let i=e.getBoundingClientRect().top-n+t.scrollTop;t.scrollTo({top:i,behavior:`smooth`})},[se]);let de=(0,Q.jsxs)(`div`,{className:`section repo-group${ae?` idle`:``}`,style:Ka(r),children:[(0,Q.jsxs)(`div`,{className:`repo-group-line`,children:[(0,Q.jsxs)(`button`,{className:`repo-group-toggle`,title:ae?`${se?`show`:`hide`} — no session open in ${L}`:se?`show ${te} session${te===1?``:`s`}${B>0?` and ${B} worktree${B===1?``:`s`}`:``}`:`hide ${te} session${te===1?``:`s`}${B>0?` and ${B} worktree${B===1?``:`s`}`:``}`,onClick:()=>{ue.current=!0,ae?(q(`action:repo.collapse`),W(e=>!e)):T(r)},children:[se?(0,Q.jsx)(vg,{size:17}):(0,Q.jsx)(im,{size:17}),(0,Q.jsx)(`span`,{children:L})]}),(0,Q.jsxs)(`span`,{className:`repo-group-acts`,children:[R&&(0,Q.jsxs)(`button`,{className:`focus-btn${R.outboxCount>0?` count`:``}`,title:R.outboxCount>0?`${R.outboxCount} new outbox file${R.outboxCount>1?`s`:``} since last opened — open files`:`files in ${L}`,onClick:()=>{q(`action:repo.files.header`),R.outboxCount>0?fo(R.id):bn(R.id)},children:[(0,Q.jsx)(wg,{size:15}),R.outboxCount>0&&R.outboxCount]}),R&&(0,Q.jsxs)(`button`,{className:`focus-btn${mi(R)?` count`:``}`,title:R.gitFailed?`the last ${R.gitFailed.verb} failed — open git to see why`:R.gitRunning?`${R.gitRunning===`push`?`a push`:R.gitRunning===`check`?`a check`:`a pull`} is running on the desktop — open git to follow it`:Lp(R),onClick:()=>o(R.id),children:[R.gitRunning?(0,Q.jsx)(yg,{size:13,className:`spin`}):(0,Q.jsx)(fm,{size:13}),R.changedCount>0&&R.changedCount,ja(R)&&(0,Q.jsx)(`span`,{className:`git-ab`,children:ja(R)}),Qt(R)&&(0,Q.jsxs)(`span`,{className:`git-ab no-origin`,children:[(0,Q.jsx)(Ym,{size:12}),`no remote`]}),R.gitFailed&&(0,Q.jsxs)(`span`,{className:`git-ab failed`,children:[(0,Q.jsx)(Fh,{size:12}),R.gitFailed.verb,` failed`]})]}),R&&(0,Q.jsx)(MT,{repo:R,repoName:L})]})]}),(0,Q.jsxs)(`span`,{className:`repo-group-pin`,children:[(0,Q.jsx)(`button`,{className:`focus-btn${P===r?` on`:``}`,"aria-label":`more actions`,"aria-expanded":P===r,title:`more actions`,onClick:()=>{q(`action:repo.more`),F(e=>e===r?null:r)},children:(0,Q.jsx)(hm,{size:17})}),te>0&&(0,Q.jsx)(`button`,{className:`focus-btn danger`,title:`close sessions in ${L} — review the ${te} here, cut by state, idle time, or what is still running underneath`,onClick:()=>I(r),children:(0,Q.jsx)(Lh,{size:18})})]}),(0,Q.jsxs)(`span`,{className:`repo-group-stats`,children:[R&&(()=>{let e=d.get(R.worktreePath);return(0,Q.jsxs)(`span`,{className:`repo-start`,children:[(0,Q.jsxs)(`button`,{className:`repo-start-btn${ae&&!se?` lead`:``}`,title:e?`new session in ${L} · ${R.branch}, another one now — ${sb(e)}`:`new session in ${L} · ${R.branch}, opened now`,onClick:()=>{q(`action:repo.new.header`),f(R)},children:[(0,Q.jsx)(Um,{size:15}),`now`]}),(0,Q.jsxs)(`button`,{className:`repo-start-btn`,title:`words for a new session in ${L} — held until the repo is free, or on a clock you pick`,onClick:()=>{q(`action:repo.send`),v(R.worktreePath)},children:[(0,Q.jsx)(Um,{size:15}),`later`]})]})})(),te===0&&R&&xe(R)&&(0,Q.jsx)(`span`,{className:`repo-group-branch`,title:`${dt(n(R))} — nothing running`,children:xe(R)}),B>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat wt${D(`worktrees`,r)?` on`:``}`,title:`${B} open worktree${B>1?`s`:``} in ${L} — tap to show only those`,onClick:()=>O(`worktrees`,r),children:[(0,Q.jsx)(og,{size:13}),B]}),(()=>{let e=R?Vs(R.healthIndex,L,ne(new Date().toISOString().slice(0,10))):null;if(!R||!e)return null;let t=e.arrow===`down`?Jm:e.arrow===`up`?Om:e.arrow===`flat`?dg:null;return(0,Q.jsxs)(`button`,{className:`repo-group-stat health${e.tone?` ${e.tone}`:``}`,title:e.title,onClick:()=>{q(`action:repo.healthindex`),lr(R)},children:[(0,Q.jsx)(ch,{size:13}),e.label,t?(0,Q.jsx)(t,{size:12}):null,e.delta]})})(),R?.setup&&R.setup.issues>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat ${R.setup.ok?`warn`:`bad`}`,title:cb(R.setup),onClick:()=>{q(`action:repo.setup`),ri(R.id,{focus:`findings`})},children:[(0,Q.jsx)(Hm,{size:13}),R.setup.issues]}),(()=>{let e=R&&d.get(R.worktreePath);return e?(0,Q.jsxs)(`button`,{className:`repo-group-stat`,title:`${sb(e)} — open its screen`,onClick:()=>{q(`action:repo.pending.open`),_(R.worktreePath)},children:[(0,Q.jsx)(yg,{size:12,className:`spin`}),ob(e)]}):null})(),(0,Q.jsx)(ST,{kind:`blocked`,n:U.blocked,repo:L,on:D(`blocked`,r),onClick:()=>O(`blocked`,r)}),(0,Q.jsx)(ST,{kind:`wait`,n:U.wait,repo:L,on:D(`wait`,r),replies:!!k.get(r),onClick:()=>O(`wait`,r)}),U.coding>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat coding${D(`coding`,r)?` on`:``}`,title:`${U.coding} session${U.coding>1?`s`:``} in ${L} working — tap to show only those`,onClick:()=>O(`coding`,r),children:[(0,Q.jsx)(yg,{size:13,className:`spin`}),U.coding]}),U.done>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat done${D(`done`,r)?` on`:``}`,title:`${U.done} session${U.done>1?`s`:``} in ${L} idle — turn finished; tap to show only those`,onClick:()=>O(`done`,r),children:[(0,Q.jsx)(rh,{size:13}),U.done]}),U.exited>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat exited${D(`exited`,r)?` on`:``}`,title:`${U.exited} exited session${U.exited>1?`s`:``} in ${L} — tap to show only those`,onClick:()=>O(`exited`,r),children:[(0,Q.jsx)(xh,{size:11}),U.exited]}),(A.get(r)?.length??0)>0&&(()=>{let e=A.get(r)??[],t=e.length,n=new Set(e),i=Date.now(),o=a.filter(e=>n.has(wr(e.id))&&Jc(e,i,j)).length;return(0,Q.jsxs)(`button`,{className:`repo-group-stat queued`,title:`${t} command${t>1?`s`:``} waiting to run in ${L} — on this phone or held by the desktop${o?`; ${o} held by the usage budget`:``}. Tap to show only those.`,onClick:()=>{let n=Eb(e,a);n.kind===`backlog`?(q(`action:repo.queued.backlog`),Ld(n.cwd,n.ids,`the ${t} waiting in ${L}`)):(q(`action:repo.queued.open`),Ki({keys:e,label:`the ${t} waiting in ${L}`}))},children:[(0,Q.jsx)(bm,{size:12}),t,gn(t,o)]})})(),(M.get(r)?.ids.length??0)>0&&(()=>{let e=M.get(r),t=e.ids.length,n=s(e.horizon);return(0,Q.jsxs)(`button`,{className:`repo-group-stat`,title:`${t} thing${t>1?`s`:``} on a clock in ${L}${n?` — ${n}`:``}. Tap to show only those.`,onClick:()=>{q(`action:repo.clocks.open`),Wf(e.ids,nn(L,t),R?.worktreePath)},children:[(0,Q.jsx)(Vm,{size:12}),t]})})(),R&&no().map(e=>(0,Q.jsx)($c,{feature:e.feature,what:`its ${e.def.id} chip`,children:(0,Q.jsx)(xT,{def:e.def,repo:R})},e.key)),(ee.get(r)??0)>0&&(()=>{let e=ee.get(r)??0;return(0,Q.jsxs)(`button`,{className:`repo-group-stat starred${D(`starred`,r)?` on`:``}`,title:`${e} starred session${e>1?`s`:``} in ${L} — tap to show only those`,onClick:()=>O(`starred`,r),children:[(0,Q.jsx)(em,{size:12,fill:`currentColor`}),e]})})(),(()=>{let e=N.get(r);return e?(0,Q.jsxs)(`button`,{className:`repo-group-stat fu-${e.tone}${D(`followup`,r)?` on`:``}`,"data-hint":`session.followup`,title:So(e.n,L),onClick:()=>O(`followup`,r),children:[(0,Q.jsx)(Mh,{size:12,fill:`currentColor`}),e.n]}):null})()]}),P===r&&(0,Q.jsxs)(`div`,{className:`row-more`,children:[R&&g&&(0,Q.jsxs)(`button`,{className:`more-act`,title:`a plain terminal on the desktop in this repo — no agent`,onClick:()=>{F(null),p(R)},children:[(0,Q.jsx)(sm,{size:AT}),`open a shell here`]}),!c&&(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`repo.focus`,onClick:()=>{q(`action:repo.focus`),F(null),E(r)},children:[(0,Q.jsx)(zm,{size:AT}),hl()?`focus this repo`:`focus window`]}),R&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{q(`action:repo.browse`),F(null),Qa(R.id)},children:[(0,Q.jsx)(Kh,{size:AT}),`browse files`]}),R&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{q(`action:repo.backlog`),F(null),Qr(R)},children:[(0,Q.jsx)(_g,{size:AT}),`backlog`]}),R&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{q(`action:repo.assess`),F(null),ui(R)},children:[(0,Q.jsx)(Qh,{size:AT}),`what is left`]}),R&&Qf(R).map(e=>(0,Q.jsx)($c,{feature:e.feature,what:`its ${e.id} action`,children:(0,Q.jsxs)(`button`,{className:`more-act`,title:e.title,onClick:()=>{q(`action:repo.ext.${e.id}`),F(null),e.run()},children:[(0,Q.jsx)(e.icon,{size:AT}),e.label]})},e.key)),R&&(0,Q.jsxs)(`button`,{className:`more-act`,title:ub(R.setup),onClick:()=>{q(`action:repo.setup`),F(null),ri(R.id)},children:[(0,Q.jsx)(Hm,{size:AT}),lb(R.setup)]}),R&&(0,Q.jsxs)(`button`,{className:`more-act`,title:`what this repo downloads to this phone by itself`,onClick:()=>{q(`action:repo.pullrules`),F(null),Es(R.worktreePath)},children:[(0,Q.jsx)(Sm,{size:AT}),`download rules`]}),R&&(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{q(`action:repo.branch`),F(null),m(R),l(`branches`)},children:[(0,Q.jsx)(og,{size:AT}),`branch`]}),R&&(0,Q.jsx)(bT,{repo:R,onSaved:()=>{F(null),h()}}),R&&(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`repo.hide`,onClick:()=>{q(`action:repo.hide`),F(null),u(R.id)},children:[(0,Q.jsx)(Rm,{size:AT}),`hide`]}),R&&(0,Q.jsx)(wd,{repo:R,onOpen:()=>{F(null),lr(R)}}),R&&(0,Q.jsx)(Cs,{onOpen:()=>{q(`action:repo.optins`),F(null),ri(R.id,{region:`optins`})}})]})]}),fe=new Set(i.map(e=>e.id)),pe=e=>z.filter(t=>t.ownerSessionId===e),me=z.filter(e=>!e.ownerSessionId||!fe.has(e.ownerSessionId)),he=e=>(0,Q.jsxs)(`div`,{className:`row-wrap repo-row row-wt${e.ownerSessionId&&fe.has(e.ownerSessionId)?` row-wt-owned`:``}`,style:Ka(r),children:[(0,Q.jsxs)(`div`,{className:`row grow repo-main`,role:`button`,tabIndex:0,onClick:()=>f(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),f(e))},children:[(0,Q.jsx)(pd,{children:(0,Q.jsx)(`span`,{className:`wt-branch`,children:e.branch.replace(/^worktree-/,``)})}),(0,Q.jsxs)(nc,{className:`repo-sub`,children:[(0,Q.jsxs)(`span`,{className:`repo-branch wt-of`,children:[(0,Q.jsx)(og,{size:12}),`worktree of `,(0,Q.jsx)(`b`,{children:L})]}),(()=>{let t=d.get(e.worktreePath);return t?(0,Q.jsxs)(`button`,{className:`row-chip`,title:`${sb(t)} — open its screen`,onClick:t=>{t.stopPropagation(),q(`action:repo.pending.open`),_(e.worktreePath)},children:[(0,Q.jsx)(yg,{size:12,className:`spin`}),ob(t)]}):null})(),e.outboxCount>0&&(0,Q.jsxs)(`button`,{className:`row-chip`,title:`${e.outboxCount} new outbox file${e.outboxCount>1?`s`:``} since last opened — open gallery`,onClick:t=>{t.stopPropagation(),q(`action:repo.inbox`),fo(e.id)},children:[(0,Q.jsx)(wg,{size:12}),e.outboxCount]}),e.gitFailed&&(0,Q.jsxs)(`button`,{className:`row-chip bad`,title:`the last ${e.gitFailed.verb} failed — open git to see why`,onClick:t=>{t.stopPropagation(),q(`action:repo.git`),o(e.id)},children:[(0,Q.jsx)(Fh,{size:12}),e.gitFailed.verb,` failed`]}),mi(e)&&(0,Q.jsxs)(`button`,{className:`row-chip`,title:Lp(e),onClick:t=>{t.stopPropagation(),q(`action:repo.git`),o(e.id)},children:[(0,Q.jsx)(fm,{size:12}),e.changedCount>0&&e.changedCount,ja(e)&&(0,Q.jsx)(`span`,{className:`git-ab`,children:ja(e)})]}),e.setup&&e.setup.issues>0&&(0,Q.jsxs)(`button`,{className:`row-chip ${e.setup.ok?`warn`:`bad`}`,title:cb(e.setup),onClick:t=>{t.stopPropagation(),q(`action:repo.setup`),ri(e.id,{focus:`findings`})},children:[(0,Q.jsx)(Hm,{size:12}),e.setup.issues]})]}),!e.ownerSessionId&&(0,Q.jsx)(OT,{r:H.get(e.id)})]}),(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this worktree`,onClick:()=>bl(e.id),children:(0,Q.jsx)(cm,{size:AT})}),(0,Q.jsx)(`button`,{className:`row-act`,title:`send words to a new session here — works offline`,onClick:()=>{q(`action:repo.send`),v(e.worktreePath)},children:(0,Q.jsx)(sg,{size:AT})}),(0,Q.jsx)(`button`,{className:`row-act${P===e.id?` on`:``}`,"aria-label":`more actions`,"aria-expanded":P===e.id,title:`more actions`,onClick:()=>{q(`action:repo.more`),F(t=>t===e.id?null:e.id)},children:(0,Q.jsx)(hm,{size:AT})}),P===e.id&&(0,Q.jsxs)(`div`,{className:`row-more`,children:[g&&(0,Q.jsxs)(`button`,{className:`more-act`,title:`a plain terminal on the desktop in this worktree — no agent`,onClick:()=>{F(null),p(e)},children:[(0,Q.jsx)(sm,{size:AT}),`open a shell here`]}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{q(`action:repo.build`),F(null),Rn(e)},children:[(0,Q.jsx)(Tm,{size:AT}),`build`]}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{q(`action:repo.capture`),F(null),qf(e)},children:[(0,Q.jsx)(mg,{size:AT}),`capture`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:ub(e.setup),onClick:()=>{q(`action:repo.setup`),F(null),ri(e.id)},children:[(0,Q.jsx)(Hm,{size:AT}),lb(e.setup)]}),(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`repo.hide`,onClick:()=>{q(`action:repo.hide`),F(null),u(e.id)},children:[(0,Q.jsx)(Rm,{size:AT}),`hide`]}),!e.ownerSessionId&&(0,Q.jsx)(kT,{t:e,r:H.get(e.id),onChanged:()=>{F(null),ie()}})]})]},e.id);return(0,Q.jsxs)(`div`,{className:`repo-group-block`,children:[(0,Q.jsx)(`span`,{ref:ce,className:`repo-group-anchor`,"aria-hidden":!0}),de,ae&&!se&&(0,Q.jsx)(`div`,{className:`repo-group-empty`,style:Ka(r),children:R?(0,Q.jsxs)(Q.Fragment,{children:[`No active session — start one with `,(0,Q.jsx)(Um,{size:15,"aria-label":`plus`}),`now under the name above.`]}):`No active session.`}),!se&&(0,Q.jsx)(ET,{wts:V,readings:H,onChanged:ie}),!se&&me.map(he),!se&&i.map(n=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(vT,{p:e,m:t,s:n,repoName:r}),pe(n.id).map(he)]},n.id)),(0,Q.jsx)(`span`,{ref:le,className:`repo-group-anchor`,"aria-hidden":!0})]})}function MT({repo:e,repoName:t}){let n=Zi(e);return(0,Q.jsxs)(`button`,{className:`focus-btn`,title:n?`build “${n.name}” is running on the desktop — open build to follow it`:`build ${t} (run a build command, no tokens)`,onClick:()=>{q(`action:repo.build.header`),Rn(e)},children:[n?(0,Q.jsx)(yg,{size:17,className:`spin`}):(0,Q.jsx)(Tm,{size:17}),e.buildFailed&&(0,Q.jsx)(`span`,{className:`git-ab failed`,title:`build “${e.buildFailed.name}” failed — open build to see why`,children:`failed`})]})}function NT(e){return e.itemLabel||e.tabTitle||j(e.title)||e.title}function PT(e){let t=j(e.title)||e.title;return t&&t!==NT(e)?t:void 0}var FT={hand:`by hand`,fork:`fork`,backlog:`backlog`,schedule:`scheduled`,agent:`agent`,fanout:`fan-out`,resurrect:`reopened after limit`};function IT(e){return e.kind&&e.kind in FT?FT[e.kind]:void 0}function LT(e){return e.closedBy===`auto-done`||e.closedBy===`auto-slot`}function RT(e){switch(e.closedBy){case`you`:return{text:`closed by you`,tone:`quiet`};case`replaced`:return{text:`replaced by a relaunch`,tone:`quiet`};case`auto-done`:return{text:`closed automatically — work finished`,tone:`auto`};case`auto-slot`:return{text:`closed automatically to make room for a waiting item`,tone:`auto`};case`exited`:return typeof e.exitSignal==`number`&&e.exitSignal!==0?{text:`ended on its own (signal ${e.exitSignal})`,tone:`note`}:typeof e.exitCode==`number`&&e.exitCode!==0?{text:`ended on its own (exit ${e.exitCode})`,tone:`note`}:{text:`ended on its own`,tone:`quiet`};case`limit`:return{text:e.resumedAs?`stopped at usage limit — reopened`:`stopped at usage limit`,tone:`note`};default:return}}function zT(e){if(!e.itemState)return;let t=e.itemDetail?`: ${e.itemDetail}`:``;return e.itemState===`canceled`?{text:`item canceled${t}`,tone:`muted`}:e.itemState===`failed`||e.itemOk===!1?{text:`item failed${t}`,tone:`bad`}:{text:`item done${t}`,tone:`ok`}}function BT(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return n%60?`${r}h ${n%60}m`:`${r}h`;let i=Math.floor(r/24);return r%24?`${i}d ${r%24}h`:`${i}d`}function VT(e,t){let n=[];return typeof e.openedAt==`number`&&e.closedAt>=e.openedAt&&n.push(`open ${BT(e.closedAt-e.openedAt)}`),typeof e.lastActiveAt==`number`&&n.push(`last active ${BT(t-e.lastActiveAt)} ago`),typeof e.turns==`number`&&e.turns>0&&n.push(`${e.turns} prompt${e.turns===1?``:`s`} sent from here`),e.model&&n.push(e.model),n}function HT(e,t){return t===`auto`?e.filter(LT):[...e]}function UT(e,t){return`${e} of ${t} shown — closed automatically`}var WT=16;function GT({p:e,m:t}){let{backends:n,openGitFor:r}=e,{send:i,liveSend:a}=e.conn,{setOverlay:o}=e.route,{hiddenRepos:s,toggleHideRepo:c}=e.view,{openCwd:l,openRepo:u,reopenCant:d}=e.launchCore,{attach:p}=e.term,{closeSession:m}=e.verbs,{repoForCwd:h,sessionRepo:g,visibleRecent:_,hiddenRecent:v,hiddenSessions:y,hiddenCount:b,showHidden:x,setShowHidden:S}=t,C=e=>Fi(n,e.launch?.backend),w=e=>C(e)?`starts a new shell in this folder — a shell has no conversation to continue`:tu(!!Mi(e)),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(``),M=k.trim()!==``,ee=t.reopenable,N=M?ee.filter(e=>Mb(k,[e.title,NT(e),PT(e),e.cwd,e.firstPrompt,e.lastPrompt])):ee,P=M?_.filter(e=>Mb(k,[e.title,e.cwd])):_,F=ee.length+_.length,I=N.length+P.length;return(0,Q.jsxs)(Q.Fragment,{children:[F>0&&(0,Q.jsx)(`button`,{className:`section section-head closed-fold`,"aria-expanded":D,title:D?`fold away recently closed and recent sessions`:`show recently closed and recent sessions, with a search`,onClick:()=>O(e=>!e),children:(0,Q.jsxs)(`span`,{children:[D?(0,Q.jsx)(im,{size:WT}):(0,Q.jsx)(vg,{size:WT}),` Closed & recent`,(0,Q.jsxs)(`span`,{className:`section-hint`,children:[` · `,ee.length,` closed · `,_.length,` recent`]})]})}),D&&F>0&&(0,Q.jsxs)(`div`,{className:`section quick-filter`,children:[(0,Q.jsx)(Vh,{size:14,className:`quick-filter-icon`}),(0,Q.jsx)(`input`,{type:`search`,value:k,placeholder:`search closed & recent`,"aria-label":`search recently closed and recent sessions by title, folder and prompts`,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Escape`&&k&&(e.preventDefault(),e.stopPropagation(),A(``))}}),M&&(0,Q.jsxs)(`span`,{className:`quick-filter-n`,children:[I,` of `,F]}),M&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`clear the search`,title:`clear the search — every row again`,onClick:()=>A(``),children:(0,Q.jsx)(Lh,{size:WT})})]}),D&&M&&I===0&&(0,Q.jsxs)(Zd,{children:[`No closed or recent session shows “`,k.trim(),`”.`]}),D&&(()=>{if(!N.length)return null;let e=N.filter(LT).length,s=T===`auto`&&e>0?`auto`:null,c=HT(N,s),u=Date.now();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`section section-head`,children:[(0,Q.jsxs)(`span`,{children:[`Recently closed `,(0,Q.jsx)(`span`,{className:`section-hint`,children:`· tap to reopen (newest first)`})]}),(0,Q.jsxs)(`span`,{className:`head-acts tight`,children:[(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`open the archive`,title:`older conversations — the full archive on disk`,onClick:()=>{q(`overlay:archive`),o(`archive`)},children:(0,Q.jsx)(Zh,{size:WT})}),(0,Q.jsx)(ss,{className:`head-act`,"aria-label":`clear recently-closed list`,title:`clear the recently-closed shortlist (the conversations stay, in the archive)`,confirmTitle:`tap again to clear the shortlist — the conversations stay on disk and remain resumable from the archive`,confirm:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ch,{size:WT}),` clear?`]}),onConfirm:()=>{i({t:`closed.clear`}),K(`shortlist cleared — conversations kept`)},children:(0,Q.jsx)(Ch,{size:WT})})]})]}),e>0&&(0,Q.jsx)(Bc,{className:`annot-tools closed-chips`,keys:[`auto`],bucket:()=>({count:e}),label:()=>`closed automatically`,active:s,onPick:e=>E(e)}),s&&(0,Q.jsx)(Hu,{onClear:()=>E(null),clearLabel:`show all`,children:UT(c.length,N.length)}),c.map(e=>{let i=PT(e),o=IT(e),s=RT(e),c=zT(e),f=VT(e,u),p=e.contextSpark,m=()=>l(e.cwd,j(e.title)||e.title,!0,`continue`,e.launch,Mi(e));return(0,Q.jsxs)(`div`,{className:`row-wrap closed-card${LT(e)?` closed-auto-row`:``}`,style:Ka(t.sessionRepoName(e)),children:[(0,Q.jsxs)(Kl,{as:`button`,kind:`grow`,title:`reopen ${j(e.title)} — ${w(e)}`,onClick:m,children:[(0,Q.jsxs)(`span`,{className:`row-head`,children:[(0,Q.jsxs)(pd,{children:[e.bookmark&&!e.bookmark.note&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`bm-mark`,children:(0,Q.jsx)(Ws,{on:!0,size:12})}),` `]}),NT(e)]}),(0,Q.jsxs)(`span`,{className:`row-meta`,children:[i&&(0,Q.jsx)(nc,{className:`closed-folder`,children:i}),(0,Q.jsx)(nc,{className:`row-launch${$a(n,e.launch?.backend)?` row-foreign`:``}`,children:pu(e.launch??{},$a(n,e.launch?.backend),n)}),o&&(0,Q.jsx)(df,{className:`closed-kind`,children:o}),s&&s.tone!==`auto`&&(0,Q.jsx)(nc,{className:s.tone===`note`?`closed-note`:void 0,children:s.text}),C(e)&&(0,Q.jsx)(nc,{children:`new shell here`})]})]}),(0,Q.jsx)(`span`,{className:`row-stat`,children:(0,Q.jsxs)(df,{className:`closed-stat`,title:`closed ${new Date(e.closedAt).toLocaleString()}`,children:[`closed `,nl(e.closedAt)]})}),(0,Q.jsxs)(`span`,{className:`row-gist`,children:[s?.tone===`auto`&&(0,Q.jsx)(`span`,{className:`closed-line`,children:(0,Q.jsxs)(df,{className:`closed-auto`,children:[(0,Q.jsx)(Im,{size:12}),` `,s.text]})}),c&&(0,Q.jsxs)(nc,{className:`closed-line closed-outcome ${c.tone}`,children:[c.tone===`ok`?(0,Q.jsx)(ng,{size:12}):c.tone===`bad`?(0,Q.jsx)(zh,{size:12}):(0,Q.jsx)(ym,{size:12}),` `,c.text]}),(0,Q.jsx)(ci,{firstPrompt:e.firstPrompt,lastPrompt:e.lastPrompt,className:`closed-gist`}),f.length>0&&(0,Q.jsx)(nc,{className:`closed-line closed-meta`,children:f.join(` · `)}),e.followUp&&(0,Q.jsx)(`span`,{className:`closed-line`,children:(0,Q.jsx)(kS,{f:e.followUp})}),e.bookmark?.note&&(0,Q.jsxs)(`span`,{className:`closed-line bm-mark`,children:[(0,Q.jsx)(Ws,{on:!0,size:12}),` `,e.bookmark.note]}),d(e)]}),p&&(0,Q.jsx)(`span`,{className:`row-side`,children:(0,Q.jsxs)(`span`,{className:`row-spark`,children:[(0,Q.jsx)(xr,{spark:p,value:!0}),(0,Q.jsx)(_o,{spark:p})]})})]}),(0,Q.jsxs)(`div`,{className:`row-acts`,children:[(0,Q.jsx)(`span`,{className:`row-tags`,children:_T(h(e.cwd),r)}),(0,Q.jsxs)(`span`,{className:`row-ctl`,children:[e.followUp&&(0,Q.jsx)(`button`,{className:`row-act fu-btn${ES(e.followUp)}`,"data-hint":`session.followup`,"aria-pressed":!0,title:`Done — clear flag — the conversation stays where it is`,onClick:()=>{q(`action:session.followup.closed`),a({t:`session.followup`,id:e.claudeSessionId??e.id,on:!1},`flag cleared`,`no connection — the desktop didn't get that, the flag is still set`)},children:(0,Q.jsx)(OS,{on:!0,size:WT})}),Yt(n,e.launch?.backend,`resumePick`)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`pick an older conversation in this folder — the binary's own list`,onClick:()=>l(e.cwd,e.title,!0,`pick`,e.launch),children:(0,Q.jsx)(Nh,{size:WT})}),(0,Q.jsx)(`button`,{className:`row-act`,title:`${C(e)?`start a new shell in this folder`:`reopen`} — ${w(e)}`,onClick:m,children:(0,Q.jsx)(Xh,{size:WT})})]})]})]},e.id)})]})})(),D&&P.length>0&&(0,Q.jsxs)(`div`,{className:`section section-head`,children:[(0,Q.jsx)(`span`,{children:`Resume recent`}),(0,Q.jsx)(`span`,{className:`head-acts tight`,children:(0,Q.jsx)(ss,{className:`head-act`,"aria-label":`clear recent list`,title:`clear the recent-sessions list`,confirmTitle:`tap again to clear the recent-sessions list`,confirm:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ch,{size:WT}),` clear?`]}),onConfirm:()=>{i({t:`recent.clear`}),K(`recent cleared`)},children:(0,Q.jsx)(Ch,{size:WT})})})]}),D&&P.map(e=>(0,Q.jsxs)(Kl,{kind:`wrap`,style:Ka(t.sessionRepoName(e)),children:[(0,Q.jsxs)(Kl,{as:`button`,kind:`grow`,title:`${C(e)?`open a new shell in`:`resume`} ${e.title} — ${w(e)}`,onClick:()=>l(e.cwd,e.title,!0,`continue`,e.launch,Mi(e)),children:[(0,Q.jsx)(pd,{children:e.title}),(0,Q.jsxs)(nc,{children:[(0,Q.jsx)(Xh,{size:12}),` `,C(e)?`new shell here`:`resume`]}),d(e)]}),_T(h(e.cwd),r),h(e.cwd)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this repo`,onClick:()=>bl(h(e.cwd).id),children:(0,Q.jsx)(cm,{size:WT})})]},Mi(e)??e.cwd)),b>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{className:`section`,onClick:()=>S(e=>!e),style:{background:`none`,border:0,textAlign:`left`,cursor:`pointer`,width:`100%`},children:[`Hidden (`,b,`) `,x?`▾`:`▸`]}),x&&(0,Q.jsxs)(Q.Fragment,{children:[y.map(e=>(0,Q.jsxs)(Kl,{kind:`wrap`,children:[(0,Q.jsxs)(Kl,{as:`button`,kind:`grow`,onClick:()=>p(e),children:[(0,Q.jsxs)(pd,{children:[e.title,(0,Q.jsxs)(nc,{className:$a(n,e.backend)?`row-foreign`:void 0,children:[` `,pu(e,$a(n,e.backend),n)]})]}),(0,Q.jsx)(Si,{s:e}),lx(e,void 0,void 0,n)]}),_T(g(e),r),g(e)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this session`,onClick:()=>bl(g(e).id),children:(0,Q.jsx)(cm,{size:WT})}),(0,Q.jsx)(`button`,{className:`row-act danger`,title:e.running?`close`:`remove`,onClick:()=>m(e),children:(0,Q.jsx)(Lh,{size:WT})})]},e.id)),v.map(e=>(0,Q.jsxs)(Kl,{kind:`wrap`,children:[(0,Q.jsxs)(Kl,{as:`button`,kind:`grow`,title:`${C(e)?`open a new shell in`:`resume`} ${e.title} — ${w(e)}`,onClick:()=>l(e.cwd,e.title,!0,`continue`,e.launch,Mi(e)),children:[(0,Q.jsx)(pd,{children:e.title}),(0,Q.jsxs)(nc,{children:[(0,Q.jsx)(Xh,{size:12}),` `,C(e)?`new shell here`:`resume`]})]}),_T(h(e.cwd),r),h(e.cwd)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this repo`,onClick:()=>bl(h(e.cwd).id),children:(0,Q.jsx)(cm,{size:WT})})]},Mi(e)??e.cwd)),s.map(e=>(0,Q.jsxs)(`div`,{className:`row-wrap ${e.isPrimary?``:`row-wt`}`,children:[(0,Q.jsxs)(Kl,{as:`button`,kind:`grow`,onClick:()=>u(e),children:[(0,Q.jsx)(pd,{children:e.isPrimary?f(e):(0,Q.jsx)(`span`,{className:`wt-branch`,children:e.branch})}),(e.isPrimary?xe(e):`worktree`)&&(0,Q.jsx)(nc,{children:e.isPrimary?xe(e):`worktree`})]}),(0,Q.jsx)(`button`,{className:`row-act`,title:`show repo`,onClick:()=>c(e.id),children:(0,Q.jsx)(Hh,{size:WT})})]},e.id))]})]})]})}var KT=[],qT=new Set;function JT(e){KT=e;for(let t of qT)t(e)}function YT(){return Dn.plainFolders().then(e=>(JT(e.folders??[]),KT.length)).catch(()=>null)}function XT({refreshRepos:e}){let[t,n]=(0,Z.useState)(KT),[r,i]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>(qT.add(n),()=>{qT.delete(n)}),[]),!t.length)return null;let a=t=>{i(t.path),Dn.initPlainFolder(t.path).then(n=>{n.error?K(`${t.name}: ${n.error}`):(JT(KT.filter(e=>e.path!==t.path)),e(),K(`${t.name} is a git repo now — listed below`))}).catch(()=>K(`${t.name}: the desktop did not answer — nothing changed`)).finally(()=>i(null))};return(0,Q.jsxs)(`div`,{className:`list`,children:[(0,Q.jsxs)(`div`,{className:`section section-head`,children:[(0,Q.jsxs)(`span`,{children:[t.length===1?`1 folder is`:`${t.length} folders are`,` not listed: no git in `,t.length===1?`it`:`them`]}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`dismiss`,title:`dismiss — the next rescan says it again`,onClick:()=>JT([]),children:(0,Q.jsx)(Lh,{size:13})})]}),t.map(e=>(0,Q.jsxs)(Kl,{kind:`wrap`,children:[(0,Q.jsxs)(Kl,{kind:`grow`,children:[(0,Q.jsx)(pd,{className:`mono`,children:e.name}),(0,Q.jsx)(nc,{children:`only folders with git are repos here`})]}),(0,Q.jsxs)(Y,{title:`run git init in ${e.name} — adds a .git folder, no commit, your files stay as they are`,onClick:()=>{r||a(e)},children:[(0,Q.jsx)(Th,{size:14}),` `,r===e.path?`running…`:`git init`]})]},e.path))]})}var ZT=[`wait`,`blocked`,`coding`,`done`,`exited`],QT={coding:`working`,wait:`waiting for your answer`,done:`idle`,blocked:`blocked`,exited:`exited`},$T=[`1h`,`6h`,`1d`,`3d`],eE={"1h":36e5,"6h":216e5,"1d":864e5,"3d":2592e5},tE={"1h":`> 1h`,"6h":`> 6h`,"1d":`> 1d`,"3d":`> 3d`},nE=[`agents`,`shellsLive`,`shellsQuiet`,`nothing`],rE={agents:`agents running`,shellsLive:`shells live`,shellsQuiet:`shells quiet`,nothing:`nothing running`};function iE(e,t,n){let r=!!e.agents?.length,i,a;if(e.shellList){let n=p(e.shellList,t);i=n.working+n.waiting+n.unknown>0,a=!i&&n.quiet>0}else i=!!e.shells,a=!1;return n===`agents`?r:n===`shellsLive`?i:n===`shellsQuiet`?a:!r&&!i&&!a}var aE=[`draft`,`queued`,`none`],oE={draft:`unsent draft on this phone`,queued:`prompts queued for it`,none:`nothing waiting`};function sE(e,t,n){return t.has(e.id)?`draft`:n.some(t=>t.sessionId===e.id&&t.status!==`failed`)?`queued`:`none`}var cE=[`fresh`,`started`],lE={fresh:`never started`,started:`started`},uE={state:new Set,idleOver:new Set,openOver:new Set,under:new Set,stakes:new Set,convo:new Set,repo:new Set};function dE(e,t){return e.size===0||[...e].some(t)}function fE(e,t,n){return dE(t.state,t=>n.statusOf(e)===t)&&dE(t.idleOver,t=>cc(e)>=eE[t])&&dE(t.openOver,t=>n.now-e.createdAt>=eE[t])&&dE(t.under,t=>iE(e,n.now,t))&&dE(t.stakes,t=>sE(e,n.draftIds,n.outbox)===t)&&dE(t.convo,t=>El(e)===t)&&dE(t.repo,t=>n.repoName(e)===t)}function pE(e,t,n){return e.filter(e=>fE(e,t,n))}function mE(e,t){return{...e,[t]:uE[t]}}function hE(e,t,n,r,i,a){let o=mE(t,r),s=e.filter(e=>fE(e,o,n)),c={};for(let e of i)c[e]=s.filter(t=>a(t,e)).length;return c}function gE(e,t,n,r){let i=mE(t,`idleOver`);return{state:hE(e,t,n,`state`,ZT,(e,t)=>n.statusOf(e)===t),idleOver:hE(e,t,n,`idleOver`,$T,(e,t)=>cc(e)>=eE[t]),openOver:hE(e,t,n,`openOver`,$T,(e,t)=>n.now-e.createdAt>=eE[t]),under:hE(e,t,n,`under`,nE,(e,t)=>iE(e,n.now,t)),stakes:hE(e,t,n,`stakes`,aE,(e,t)=>sE(e,n.draftIds,n.outbox)===t),convo:hE(e,t,n,`convo`,cE,(e,t)=>El(e)===t),repo:hE(e,t,n,`repo`,r,(e,t)=>n.repoName(e)===t),idleUnknown:e.filter(e=>fE(e,i,n)&&!mp(e)).length}}function _E(e){return e?`${e} session${e===1?` has`:`s have`} no readable activity record — ${e===1?`its`:`their`} quiet time is measured only since the last desktop restart, so "idle for" may read shorter than it has been. "Open for" is unaffected.`:``}function vE(e){let t=[];return e.state.size&&t.push([...e.state].map(e=>QT[e]).join(` or `)),e.idleOver.size&&t.push(`idle ${[...e.idleOver].map(e=>tE[e]).join(` or `)}`),e.openOver.size&&t.push(`open ${[...e.openOver].map(e=>tE[e]).join(` or `)}`),e.under.size&&t.push([...e.under].map(e=>rE[e]).join(` or `)),e.stakes.size&&t.push([...e.stakes].map(e=>oE[e]).join(` or `)),e.convo.size&&t.push([...e.convo].map(e=>lE[e]).join(` or `)),e.repo.size&&t.push([...e.repo].join(` or `)),t.join(` · `)}function yE(e,t,n){let r=vE(n);return`${e} of ${t} in scope${r?` · ${r}`:``}`}var bE=e=>e.state.size+e.idleOver.size+e.openOver.size+e.under.size+e.stakes.size+e.convo.size+e.repo.size>0;function xE(e,t,n=new Set){return n.has(e)?!t.has(e):t.has(e)}function SE(e,t,n){return e.filter(e=>!xE(e.id,t,n))}function CE(e){return e?`${e} session${e===1?` is`:`s are`} kept open: a timed prompt is aimed at ${e===1?`it`:`each`}. Closed anyway, the desktop reopens that conversation when the prompt's time comes — the shield on the row puts ${e===1?`it`:`one`} back in this close.`:``}function wE(e){return e.reduce((e,t)=>e+(t.shellList?.length??0),0)}function TE(e,t){return e.filter(e=>t.statusOf(e)===`wait`).length}function EE(e,t){return e?t>0?`close ${e} · stops ${t} background shell${t===1?``:`s`}`:`close ${e}`:``}function DE(e,t,n,r){let i=`archived ${e} session${e===1?``:`s`}${r?` in ${r}`:``}`,a=[t>0?`stopping ${t} background shell${t===1?``:`s`}`:``,typeof n==`string`?n?`kept ${n}`:``:n>0?`kept ${n} starred`:``].filter(Boolean).join(`, `);return`${i}${a?`, ${a}`:``} — the conversation${e===1?` is`:`s are`} kept: reopen under "Recently closed" or Archive`}var OE=16;function kE({label:e,options:t,counts:n,active:r,labels:i,onToggle:a,hintId:o}){let s=t.filter(e=>n[e]>0||r.has(e)),c=t.filter(e=>!(n[e]>0||r.has(e)));return(0,Q.jsxs)(`div`,{className:`close-facet`,"data-hint":o,children:[(0,Q.jsx)(`span`,{className:`close-facet-label`,children:e}),(0,Q.jsxs)(`div`,{className:`close-facet-body`,children:[s.length>0&&(0,Q.jsx)(`div`,{className:`fchips wrap`,children:s.map(e=>(0,Q.jsx)(ll,{on:r.has(e),title:`${i[e]} — ${n[e]} session${n[e]===1?``:`s`}`,onClick:()=>a(e),children:Ed(i[e],{count:n[e]})},e))}),c.length>0&&(0,Q.jsx)(`div`,{className:`close-facet-none`,children:`none: ${c.map(e=>i[e]).join(`, `)}`})]})]})}function AE(e){let t=e.indexOf(` — `);if(t<0)return[e.replace(/\.$/,``),``];let n=e.slice(t+3);return[e.slice(0,t),n.charAt(0).toUpperCase()+n.slice(1)]}function jE(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function ME({s:e,repoLabel:t,kept:n,onToggleKeep:r,statusOf:i,now:a,timedAt:o,backends:s}){let c=i(e)===`wait`;return(0,Q.jsxs)(Kl,{kind:`wrap`,children:[(0,Q.jsxs)(Kl,{kind:`grow`,style:{cursor:`default`},children:[(0,Q.jsx)(Wn,{s:e,repoLabel:t,backends:s}),e.shellList?.length?(0,Q.jsxs)(nc,{children:[(0,Q.jsx)(Fm,{size:11}),` `,E(p(e.shellList,a)),` — will stop`]}):null,o&&(0,Q.jsxs)(nc,{children:[(0,Q.jsx)(Dh,{size:11}),` a prompt is timed into it · `,o,n?` — kept open`:` — its conversation is reopened then`]}),c&&(0,Q.jsxs)(nc,{className:`warn`,children:[(0,Q.jsx)(pg,{size:11}),` waiting on a box — closing answers nothing, it just ends the process`]})]}),(0,Q.jsx)(`button`,{className:`row-act${n?` on`:``}`,title:n?`kept — tap to put it back in this close`:`keep — leave this one open`,onClick:r,children:(0,Q.jsx)(lh,{size:OE})})]})}function NE({p:e,m:t}){let{send:n}=e.conn,{closeAllPick:r,setCloseAllPick:i,closeKeepStar:a,setCloseKeepStar:o,visibleSessions:s,sessionRepoName:c,shownOf:l}=t,u=r!==null;Hc(u,()=>i(null));let[d,f]=(0,Z.useState)(uE),[p,m]=(0,Z.useState)(new Set),{items:h}=os();if((0,Z.useEffect)(()=>{u||(f(uE),m(new Set))},[u]),!u)return null;let g=r===`*`?void 0:r,_=Date.now(),v=Ob(s,g,a,c),y=Ab(s,g,a,c),b=kb(s,g,c),x=b.n,S=jb(b),C={now:_,repoName:c,statusOf:t=>an(t,e.backends),draftIds:Ha(),outbox:e.outbox},w=g?[]:[...new Set(v.map(c))].sort(),T=gE(v,d,C,w),E=pE(v,d,C),D=new Map;for(let e of h)e.status===`queued`&&e.at&&e.targetSessionId&&!D.has(e.targetSessionId)&&D.set(e.targetSessionId,e.at.nextAt==null?`when its rule comes round`:Dp(e.at.nextAt));let O=new Set(D.keys()),k=SE(E,p,O),A=CE(E.filter(e=>O.has(e.id)&&xE(e.id,p,O)).length),j=wE(k),M=TE(k,C),ee=EE(k.length,j),[N,P]=AE(_E(T.idleUnknown));function F(e,t){f(n=>({...n,[e]:t}))}function I(){f(uE)}function te(e){m(t=>jE(t,e))}function L(){if(k.length){q(`action:${g?`repo`:`session`}.close.facets`);for(let e of k)us(e.id),n({t:`session.remove`,id:e.id});i(null),K(DE(k.length,j,y>0?S:``,g&&l(g)))}}return(0,Q.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:30,background:`var(--bg)`,display:`flex`,flexDirection:`column`},children:(0,Q.jsx)(ku,{title:g?`Close sessions in ${l(g)}?`:`Close sessions?`,icon:(0,Q.jsx)(Lh,{size:OE}),onClose:()=>i(null),footer:(0,Q.jsxs)(Q.Fragment,{children:[ee?(0,Q.jsxs)(ss,{className:`key danger`,confirm:`tap again to ${ee}`,title:ee,confirmTitle:`tap again to ${ee}`,onConfirm:L,children:[(0,Q.jsx)(Lh,{size:OE}),` `,ee]}):(0,Q.jsx)(Dc,{children:v.length===0?y>0?`Nothing left to close — every session here is starred or flagged. "Close them too" below puts ${y===1?`it`:`them`} back in reach.`:`Nothing here to close.`:`Nothing in the cut, or every matching row is kept — nothing to send.`}),(0,Q.jsx)(Dc,{children:`Conversations are kept — reopen under "Recently closed" or Archive.`})]}),children:(0,Q.jsxs)(`div`,{className:`sheet-body`,children:[x>0&&(0,Q.jsx)(`div`,{className:`section`,children:(0,Q.jsx)(`div`,{style:{padding:`10px 12px 0`},children:(0,Q.jsx)(Fs,{label:`what happens to the starred and flagged sessions`,value:a?`keep`:`close`,options:[{key:`keep`,label:`keep ${S}`,title:`leave the ${S} session(s) alone — out of every count and cut below`},{key:`close`,label:`close them too`,title:`treat the ${S} session(s) like any other`}],onChange:e=>o(e===`keep`)})})}),bE(d)&&(0,Q.jsxs)(`div`,{className:`filter-bar`,children:[(0,Q.jsx)(`span`,{className:`filter-bar-txt`,children:yE(E.length,v.length,d)}),(0,Q.jsxs)(`button`,{className:`filter-bar-clear`,onClick:I,children:[(0,Q.jsx)(Lh,{size:13}),` clear`]})]}),(0,Q.jsxs)(`div`,{className:`close-facets`,children:[(0,Q.jsx)(kE,{label:`State`,options:ZT,counts:T.state,active:d.state,labels:QT,onToggle:e=>F(`state`,jE(d.state,e))}),(0,Q.jsx)(kE,{label:`Idle for`,options:$T,counts:T.idleOver,active:d.idleOver,labels:tE,onToggle:e=>F(`idleOver`,jE(d.idleOver,e)),hintId:`session.close.stale`}),N&&(0,Q.jsxs)(Dc,{children:[N,`.`,` `,P&&(0,Q.jsx)(Ft,{of:`the idle-for reading`,label:`what does that change?`,children:P})]}),(0,Q.jsx)(kE,{label:`Open for`,options:$T,counts:T.openOver,active:d.openOver,labels:tE,onToggle:e=>F(`openOver`,jE(d.openOver,e))}),(0,Q.jsx)(kE,{label:`Underneath`,options:nE,counts:T.under,active:d.under,labels:rE,onToggle:e=>F(`under`,jE(d.under,e))}),(0,Q.jsx)(kE,{label:`Words at stake`,options:aE,counts:T.stakes,active:d.stakes,labels:oE,onToggle:e=>F(`stakes`,jE(d.stakes,e))}),(0,Q.jsx)(kE,{label:`Conversation`,options:cE,counts:T.convo,active:d.convo,labels:lE,onToggle:e=>F(`convo`,jE(d.convo,e))}),!g&&w.length>1&&(0,Q.jsx)(kE,{label:`Repo`,options:w,counts:T.repo,active:d.repo,labels:Object.fromEntries(w.map(e=>[e,l(e)])),onToggle:e=>F(`repo`,jE(d.repo,e))})]}),A&&(0,Q.jsx)(Dc,{children:A}),(0,Q.jsx)(`div`,{className:`section section-head close-cut`,children:(0,Q.jsxs)(`span`,{children:[`The cut`,M>0?` · ${M} waiting on a box`:``]})}),E.length===0?(0,Q.jsx)(Zd,{children:`Nothing here matches every facet ticked above.`}):E.map(t=>(0,Q.jsx)(ME,{backends:e.backends,s:t,repoLabel:g?void 0:l(c(t)),kept:xE(t.id,p,O),onToggleKeep:()=>te(t.id),statusOf:C.statusOf,now:_,timedAt:D.get(t.id)},t.id))]})})})}var PE=16,FE=6e4;function IE(e){let t=hT(e),{sessions:n,recent:r,repos:i,reposAt:a,reposFailAt:o,launch:s}=e,c=Cb(gi({rows:i,readAt:a})),{status:l,connVisible:u}=e.conn,{tailscaleIp:d}=e.conn.info,{focusRepo:f,setOverlay:p,lastVisitedId:m}=e.route,{openCwd:h,refreshRepos:g}=e.launchCore,{clearExited:_}=e.verbs,{tab:v,setTab:y,navMenu:b,setNavMenu:x,dl:S,activityBadge:C,activityKeys:w,visibleSessions:T,visibleExternal:E,clearFocus:D,repoGroups:O,sessionOrder:k,resetSessionOrder:j,waitingTotal:M,waitingRepliesTotal:ee,blockedTotal:N,codingTotal:P,starredTotal:F,flaggedTotal:I,shellsTotal:te,statusFilter:L,setStatusFilter:R,statusFilterActive:ne,toggleStatusFilter:z,shownSessions:B,sortedSessions:V,textQuery:H,setTextQuery:re,textOn:ie,noRepoCollapsed:U,allReposCollapsed:ae,persistCollapsedRepos:oe,scheduleWords:W,scheduleLead:se,scheduleTitle:ce,setCloseAllPick:le,repoForCwd:ue}=t,de=ep(),fe=Uu(),pe=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let e=pe.current;if(!e||(e.scrollTop=pT.top,!m))return;let t=e.querySelector(`[data-sid="${CSS.escape(m)}"]`);if(!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();(r.top<n.top||r.bottom>n.bottom)&&t.scrollIntoView({block:`center`})},[]),(0,Q.jsxs)(`div`,{className:`screen`,children:[(0,Q.jsxs)(Zw,{off:b,children:[(0,Q.jsxs)(`header`,{className:`topbar`,children:[f?(0,Q.jsxs)(`div`,{className:`brand brand-focus`,style:Ka(f),children:[(0,Q.jsx)(qw,{size:32,label:``}),(0,Q.jsx)(`span`,{children:t.shownOf(f)}),(0,Q.jsx)(`button`,{className:`focus-clear`,title:`exit repo focus — show all repos`,onClick:D,children:(0,Q.jsx)(Lh,{size:14})})]}):(0,Q.jsx)(`div`,{className:`brand`,children:(0,Q.jsx)(qw,{size:40})}),s.permissionMode&&Yy.has(s.permissionMode)&&(0,Q.jsxs)(Y,{variant:`danger`,title:`New sessions launch with --permission-mode ${s.permissionMode}: every tool call runs without asking. Tap to change it.`,onClick:()=>p(`settings`),children:[(0,Q.jsx)(gh,{size:PE}),` no approvals`]}),(0,Q.jsx)(Ac,{compact:!0}),(0,Q.jsxs)(Y,{className:`nav-key${b?` on`:``}`,"data-nohint":!0,"aria-label":`menu`,"aria-expanded":b,title:`menu — new, pad, activity, search, files, downloads, archive, logs, local/external${v===`external`?`
|
|
170
|
-
showing: external processes`:``}`,onClick:()=>{q(`action:nav.menu`),x(e=>!e)},children:[(0,Q.jsx)(kh,{size:PE}),v===`external`&&(0,Q.jsxs)(`span`,{className:`nav-tab`,children:[(0,Q.jsx)(sm,{size:12}),` external`]}),S.active>0&&(0,Q.jsxs)(`span`,{className:`nav-dl${S.stuck?` warn`:``}`,children:[(0,Q.jsx)(Sm,{size:11}),` `,S.pct,`%`]}),(0,Q.jsx)(vS,{base:C})]}),b&&(0,Q.jsxs)(`div`,{className:`row-more nav-more`,children:[hl()&&(0,Q.jsx)(ql,{size:PE,onOpen:()=>x(!1)}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{x(!1),p(`new`)},children:[(0,Q.jsx)(Um,{size:PE}),`new`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`prompt pad — write a thought now, decide where it goes later`,onClick:()=>{x(!1),p(`pad`)},children:[(0,Q.jsx)(vm,{size:PE}),`pad`]}),(0,Q.jsxs)(`button`,{className:`more-act`,"data-hint":`activity.open`,title:`activity — every prompt, sweep, build, schedule and download you posted, with what became of it. Select rows here to deal with many at once.`,onClick:()=>{q(`overlay:activity`),x(!1),Ki(w.length?{keys:w,label:`the ${w.length} ${w.length===1?`row`:`rows`} still open`}:null)},children:[(0,Q.jsx)(lm,{size:PE}),`activity`,C>0&&(0,Q.jsx)(`span`,{className:`mic-badge`,children:C})]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`search words across all sessions`,onClick:()=>{x(!1),_u(null)},children:[(0,Q.jsx)(Vh,{size:PE}),`search`]}),(0,Q.jsxs)(`button`,{className:`more-act`,onClick:()=>{x(!1),p(`gallery`)},children:[(0,Q.jsx)(wg,{size:PE}),`files`]}),(0,Q.jsxs)(`button`,{className:`more-act${S.active>0?` has-bar`:``}`,title:S.active>0?`downloads — ${S.active} in flight, ${S.pct}% of the bytes here${S.stuck?` (something is stopped)`:``}`:`downloads — files fetched to this phone, and what each repo fetches on its own`,onClick:()=>{q(`overlay:pull`),x(!1),p(`pull`)},children:[(0,Q.jsx)(Sm,{size:PE}),`downloads`,S.active>0?` ${S.active} · ${S.pct}%`:S.onPhone>0?` ${S.onPhone}`:``,S.active>0&&(0,Q.jsx)(`span`,{className:`more-dl-bar${S.stuck?` warn`:``}`,style:{width:`${S.pct}%`}})]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`archive — every conversation this repo ever had, resumable`,onClick:()=>{q(`overlay:archive`),x(!1),p(`archive`)},children:[(0,Q.jsx)(Zh,{size:PE}),`archive`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`decision log — usage-limit auto-continues and what plugins suggested or answered`,onClick:()=>{x(!1),Nf(null)},children:[(0,Q.jsx)(tg,{size:PE}),`decisions`]}),(0,Q.jsxs)(`button`,{className:`more-act`,title:`sent commands — everything this app typed into a session, including what it decided by itself`,onClick:()=>{q(`overlay:sentlog`),x(!1),cs(null)},children:[(0,Q.jsx)(Sh,{size:PE}),`sent`]}),(0,Q.jsxs)(`button`,{className:`more-act${v===`home`?` on`:``}`,title:`sessions this app started`,onClick:()=>{x(!1),y(`home`)},children:[(0,Q.jsx)(_g,{size:PE}),`local `,T.length?`(${T.length})`:``]}),(0,Q.jsxs)(`button`,{className:`more-act${v===`external`?` on`:``}`,title:"`claude` processes running outside this app — resumable from here",onClick:()=>{x(!1),y(`external`)},children:[(0,Q.jsx)(sm,{size:PE}),`external `,E.length?`(${E.length})`:``]}),(0,Q.jsx)(pS,{size:PE,onOpen:()=>x(!1)})]}),de.kind===`windows`?(0,Q.jsx)(sS,{sessions:n}):(0,Q.jsxs)(Y,{className:`usage-key ${de.kind===`usd`&&de.chip.hot?`danger`:``}`,"aria-label":de.kind===`usd`?de.chip.text:`token statistics`,title:`${de.kind===`usd`?de.chip.title:`Spend on this desktop`}\ntap for the token history`,onClick:()=>{q(`overlay:tokens`),p(`tokens`)},children:[(0,Q.jsx)(Bh,{size:PE}),de.kind===`usd`&&(0,Q.jsx)(`span`,{className:de.chip.hot?`usage-hot`:``,children:de.chip.text})]}),(0,Q.jsx)(bs,{}),(0,Q.jsx)(gS,{size:PE}),(0,Q.jsx)(_a,{size:PE}),(0,Q.jsx)(Y,{className:fe===`insecure`?`danger`:``,"aria-label":`settings`,title:`settings — notifications, launch defaults, plugins, tools`,onClick:()=>p(`settings`),children:(0,Q.jsx)(Oh,{size:PE})}),(0,Q.jsx)(wf,{}),(0,Q.jsx)(nd,{})]}),e.banners]}),v===`home`&&(0,Q.jsxs)(`div`,{className:`list`,ref:pe,onScroll:e=>{pT.top=e.currentTarget.scrollTop},children:[n.length===0&&r.length===0&&i.length===0&&l!==`open`&&u&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`offline-card`,children:[(0,Q.jsxs)(`div`,{className:`offline-card-head`,children:[(0,Q.jsx)(Ym,{size:18}),` Can’t reach the host and nothing is cached yet`]}),(0,Q.jsx)(`div`,{className:`offline-card-body`,children:`The launcher fills in when the tunnel is back — sessions, repos and recent conversations all come from the desktop.`}),(0,Q.jsxs)(`ul`,{className:`offline-card-hints`,children:[(0,Q.jsx)(`li`,{children:`Is Tailscale connected on this phone?`}),(0,Q.jsxs)(`li`,{children:[`Is the desktop awake, with the `,A.name,` daemon running?`]}),d&&(0,Q.jsxs)(`li`,{children:[`Last known host address: `,(0,Q.jsx)(`span`,{className:`mono`,children:d})]})]})]}),[0,1,2].map(e=>(0,Q.jsxs)(`div`,{className:`row-wrap skel-row`,"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{className:`skel-bar skel-title`}),(0,Q.jsx)(`span`,{className:`skel-bar skel-sub`})]},e))]}),(0,Q.jsx)(Mr,{}),(0,Q.jsx)(ol,{repos:i.length,demo:vt(),onDemo:()=>wt(`first-look`)}),O.length>0&&(0,Q.jsxs)(`div`,{className:`section section-head launcher-head`,children:[(0,Q.jsxs)(`span`,{children:[`Sessions & repos `,(0,Q.jsxs)(`span`,{className:`section-hint`,children:[`· `,T.length,` live in `,O.length,` repo`,O.length>1?`s`:``,k.length?` · custom order`:``,a&&o>a&&Date.now()-a>FE?(0,Q.jsxs)(Q.Fragment,{children:[` — repos as of `,nl(a),`, the host hasn’t answered since`]}):(0,Q.jsx)(Q.Fragment,{children:` — hold a row to drag`})]})]}),(0,Q.jsxs)(`span`,{className:`head-acts tight`,children:[(0,Q.jsx)(ST,{kind:`wait`,n:M,replies:!!ee,onClick:()=>{q(`overlay:questions`),p(`questions`)}}),(0,Q.jsx)(ST,{kind:`blocked`,n:N,hint:`limit.open`,onClick:()=>{q(`overlay:limits`),p(`limits`)}}),P>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat coding${ne(`coding`)?` on`:``}`,title:`${P} session${P>1?`s`:``} working — tap to show only those`,onClick:()=>z(`coding`),children:[(0,Q.jsx)(yg,{size:13,className:`spin`}),P]}),F>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat starred${ne(`starred`)?` on`:``}`,title:`${F} starred session${F>1?`s`:``} — tap to show only those`,onClick:()=>z(`starred`),children:[(0,Q.jsx)(em,{size:13,fill:`currentColor`}),F]}),I&&(0,Q.jsxs)(`button`,{className:`repo-group-stat fu-${I.tone}${ne(`followup`)?` on`:``}`,"data-hint":`session.followup`,title:So(I.n),onClick:()=>z(`followup`),children:[(0,Q.jsx)(Mh,{size:13,fill:`currentColor`}),I.n]}),te>0&&(0,Q.jsxs)(`button`,{className:`repo-group-stat coding${ne(`shells`)?` on`:``}`,title:`${te} session${te>1?`s`:``} running background shells — tap to show only those`,onClick:()=>z(`shells`),children:[(0,Q.jsx)(Fm,{size:13}),te]}),k.length>0&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`reset order`,title:`reset order — drop the custom order and go back to creation order`,onClick:()=>{q(`action:session.order.reset`),j(),K(`order reset to oldest-first`)},children:(0,Q.jsx)(dm,{size:PE})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`expand all repo groups`,title:U?`expand all — every repo group is already open`:`expand all — every repo group opens`,onClick:()=>{q(`action:repo.expand.all`),oe(new Set)},children:(0,Q.jsx)(yh,{size:PE})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`collapse all repo groups`,title:ae?`collapse all — every repo group is already folded`:`collapse all — headers stay, session and worktree rows hide`,onClick:()=>{q(`action:repo.collapse.all`),oe(new Set(O.map(e=>e.repoName)))},children:(0,Q.jsx)(xg,{size:PE})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`fan out`,title:`fan out — run one prompt in several repos at once (a fresh session each)`,onClick:()=>{q(`overlay:fanout`),p(`fanout`)},children:(0,Q.jsx)(jm,{size:PE})}),(0,Q.jsxs)(`button`,{className:`head-act${W?` head-act-wide`:``}`,"aria-label":ec.automation.toLowerCase(),title:ce,onClick:()=>{q(`overlay:schedule`),kp(W?se:null)},children:[(0,Q.jsx)(Vm,{size:PE}),W&&(0,Q.jsx)(`span`,{className:`head-act-n`,children:W})]}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`sync repos`,title:`sync repos — pull, push or sync every repo at once`,onClick:()=>{q(`overlay:reposync`),p(`reposync`)},children:(0,Q.jsx)(Eh,{size:PE})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`rescan repos`,title:`rescan the host root for repos and worktrees`,onClick:()=>{g(),YT().then(e=>K(e?`repos rescanned — ${e} folder${e===1?``:`s`} without git, see above the list`:`repos rescanned`))},children:(0,Q.jsx)(Xh,{size:PE})}),T.some(e=>!e.running&&!Up(e))&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`clear exited sessions`,title:`clear exited — drop the sessions that have already ended`,onClick:_,children:(0,Q.jsx)(Km,{size:PE})}),T.length>0&&(0,Q.jsx)(`button`,{className:`head-act danger`,"data-hint":`session.close.all`,"aria-label":`close sessions`,title:`close sessions — review the ${T.length} listed, cut by state, idle time, what is still running underneath, or a repo`,onClick:()=>le(`*`),children:(0,Q.jsx)(Lh,{size:PE})})]})]}),(O.length>0||ie)&&(0,Q.jsxs)(`div`,{className:`section quick-filter`,children:[(0,Q.jsx)(Vh,{size:14,className:`quick-filter-icon`}),(0,Q.jsx)(`input`,{type:`search`,value:H,placeholder:`filter sessions & repos`,"aria-label":`filter sessions and repos by the text on their rows`,onChange:e=>re(e.target.value),onKeyDown:e=>{e.key===`Escape`&&H&&(e.preventDefault(),e.stopPropagation(),re(``))}}),ie&&(0,Q.jsxs)(`span`,{className:`quick-filter-n`,children:[B.length,` of `,V.length]}),ie&&(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`clear the filter`,title:`clear the filter — every row again`,onClick:()=>re(``),children:(0,Q.jsx)(Lh,{size:PE})}),(0,Q.jsx)(`button`,{className:`head-act`,"aria-label":`search what sessions said`,title:`search what the sessions SAID — every transcript, on the desktop`,onClick:()=>{q(`action:launcher.search`),_u(null)},children:(0,Q.jsx)(tg,{size:PE})})]}),L&&(0,Q.jsxs)(`div`,{className:`section filter-bar`,children:[(0,Q.jsxs)(`span`,{className:`filter-bar-txt`,children:[`showing `,lo[L.status],L.repo?` in ${L.repo}`:``,L.status===`worktrees`&&L.repo?(0,Q.jsxs)(Q.Fragment,{children:[` · `,t.worktreesOf(L.repo).length,` worktree`,t.worktreesOf(L.repo).length===1?``:`s`,`, `,B.length,` of `,V.length,` sessions`]}):(0,Q.jsxs)(Q.Fragment,{children:[` · `,B.length,` of `,V.length]}),B.length===0&&L.status!==`worktrees`&&(L.status===`starred`?` — nothing is starred any more`:L.status===`followup`?` — nothing is flagged any more`:L.status===`shells`?` — no session is running one any more`:` — nothing is in that state any more`)]}),(0,Q.jsxs)(`button`,{className:`filter-bar-clear`,title:`clear the filter — show every live session again`,onClick:()=>R(null),children:[(0,Q.jsx)(Lh,{size:13}),` clear`]})]}),(0,Q.jsx)(XT,{refreshRepos:g}),O.map(({repoName:n,sessions:r})=>(0,Q.jsx)(jT,{p:e,m:t,repoName:n,sessions:r},`g:${n}`)),c&&(0,Q.jsx)(Zd,{children:c}),ie&&O.length===0&&(0,Q.jsxs)(Zd,{children:[`No session or repo shows “`,H.trim(),`”. The search at the end of the filter looks through what sessions said.`]}),(0,Q.jsx)(GT,{p:e,m:t})]}),v===`external`&&(0,Q.jsxs)(`div`,{className:`list`,children:[(0,Q.jsxs)(`div`,{className:`section section-head`,children:[(0,Q.jsx)(`span`,{children:`External claude processes`}),(0,Q.jsxs)(`button`,{className:`head-act`,title:`back to the sessions this app started`,onClick:()=>y(`home`),children:[(0,Q.jsx)(_g,{size:13}),` local`]})]}),E.length===0&&(0,Q.jsxs)(Zd,{children:["No `claude` running outside ",A.name,`. Started one in a terminal? It shows here.`]}),E.map(e=>(0,Q.jsxs)(Kl,{kind:`wrap`,children:[(0,Q.jsxs)(Kl,{as:`button`,kind:`grow`,onClick:()=>h(e.cwd,Fu(e.cwd),!0),children:[(0,Q.jsx)(pd,{className:`mono`,children:Fu(e.cwd)}),(0,Q.jsxs)(nc,{children:[`pid `,e.pid,` · `,(0,Q.jsx)(wh,{size:12}),` resume here`]})]}),ue(e.cwd)&&(0,Q.jsx)(`button`,{className:`row-act`,title:`send image to this repo`,onClick:()=>bl(ue(e.cwd).id),children:(0,Q.jsx)(cm,{size:PE})})]},e.pid)),(0,Q.jsxs)(Dc,{children:[`Can't attach to another terminal's TTY directly — "resume here" opens a session here in that directory with `,(0,Q.jsx)(`span`,{className:`mono`,children:`--continue`}),`.`]})]}),(0,Q.jsx)(NE,{p:e,m:t}),(0,Q.jsx)(Ax,{}),(0,Q.jsx)(ni,{})]})}function LE(e,t){if(!(e>0))return`ignore`;if(t&&String(t.tagName??``).toUpperCase()===`TEXTAREA`){let e=typeof t.className==`string`?t.className.split(/\s+/):[];if(e.includes(`pipe`)||e.includes(`xterm-helper-textarea`))return`ignore`}return`back`}function RE(e,t,n){let r=r=>{r.key!==`Escape`||r.isComposing||LE(t(),r.target)===`back`&&e.setTimeout(()=>{!r.defaultPrevented&&t()>0&&n()},0)};return e.addEventListener(`keydown`,r),()=>e.removeEventListener(`keydown`,r)}var zE=`data-layout`,BE=Cn(`phone`);function VE(e,t){let n=()=>{let n=e?.matches?`wide`:`phone`;BE.set(n);try{t?.setAttribute(zE,n)}catch{}};return n(),e?e.addEventListener?(e.addEventListener(`change`,n),()=>e.removeEventListener?.(`change`,n)):(e.addListener?.(n),()=>e.removeListener?.(n)):()=>{}}function HE(){return up(BE)}function UE(){return HE()===`wide`}if(typeof window<`u`&&typeof document<`u`){let e=null;try{e=window.matchMedia?.(`(min-width: 1024px)`)??null}catch{e=null}VE(e,document.documentElement)}function WE(e,t){if(!Number.isFinite(e))return 320;let n=Number.isFinite(t)?t-600:760;return Math.round(Math.min(Math.max(240,Math.min(760,n)),Math.max(240,e)))}var GE=`--ws-side-w`;function KE(e){let t=WE(e,window.innerWidth);return document.documentElement.style.setProperty(GE,`${t}px`),t}function qE(){let e=(0,Z.useRef)(320),t=(0,Z.useRef)(null),n=n=>{e.current=n,t.current?.setAttribute(`aria-valuenow`,String(n))};(0,Z.useEffect)(()=>(n(KE(pt(G.wideSideW,320))),()=>{document.documentElement.style.removeProperty(GE)}),[]);let r=e=>{e===320?_t(G.wideSideW):Tt(G.wideSideW,String(e))};return(0,Q.jsx)(`div`,{ref:t,className:`ws-side-grip`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Sidebar width: drag, or arrow keys; double-click resets`,title:`Drag to resize · double-click for the default width`,"aria-valuenow":320,tabIndex:0,onPointerDown:t=>{if(t.button!==0)return;t.preventDefault();let i=t.currentTarget;i.setPointerCapture(t.pointerId);let a=t.clientX,o=e.current;document.documentElement.classList.add(`ws-resizing`);let s=e=>n(KE(o+e.clientX-a)),c=()=>{i.removeEventListener(`pointermove`,s),i.removeEventListener(`pointerup`,c),i.removeEventListener(`pointercancel`,c),document.documentElement.classList.remove(`ws-resizing`),r(e.current)};i.addEventListener(`pointermove`,s),i.addEventListener(`pointerup`,c),i.addEventListener(`pointercancel`,c)},onKeyDown:t=>{let i=t.key===`ArrowLeft`?-1:+(t.key===`ArrowRight`);if(!i)return;t.preventDefault();let a=KE(e.current+i*16*(t.shiftKey?5:1));n(a),r(a)},onDoubleClick:()=>{let e=KE(320);n(e),r(e)}})}var JE={beside:{VAR:`--ws-beside-w`,key:G.wideBesideW,cls:`ws-beside-grip`,label:`Annotator width`},panel:{VAR:`--ws-panel-w`,key:G.widePanelW,cls:`ws-panel-grip`,label:`Panel width`}},YE=440,XE=360,ZE=24;function QE(){return document.querySelector(`#root > .ws-side`)?.getBoundingClientRect().width??320}function $E(e){let t=Math.max(YE,window.innerWidth-QE()-XE);return Math.round(Math.min(t,Math.max(YE,e)))}function eD(e){return e?.parentElement?.getBoundingClientRect().width??YE}function tD({of:e=`beside`}){let t=(0,Z.useRef)(null),{VAR:n,key:r,cls:i,label:a}=JE[e],o=e=>{let t=$E(e);return document.documentElement.style.setProperty(n,`${t}px`),t};return(0,Z.useEffect)(()=>{let e=pt(r,0);return e&&o(e),()=>{document.documentElement.style.removeProperty(n)}},[e]),(0,Q.jsx)(`div`,{ref:t,className:i,role:`separator`,"aria-orientation":`vertical`,"aria-label":`${a}: drag, or arrow keys; double-click resets`,title:`Drag to resize · double-click for the default width`,tabIndex:0,onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId);let n=e.clientX,i=eD(t),a=i;document.documentElement.classList.add(`ws-resizing`);let s=e=>{a=o(i-(e.clientX-n))},c=()=>{t.removeEventListener(`pointermove`,s),t.removeEventListener(`pointerup`,c),t.removeEventListener(`pointercancel`,c),document.documentElement.classList.remove(`ws-resizing`),Tt(r,String(a))};t.addEventListener(`pointermove`,s),t.addEventListener(`pointerup`,c),t.addEventListener(`pointercancel`,c)},onKeyDown:e=>{let n=e.key===`ArrowLeft`?1:e.key===`ArrowRight`?-1:0;n&&(e.preventDefault(),Tt(r,String(o(eD(t.current)+n*ZE*(e.shiftKey?5:1)))))},onDoubleClick:()=>{document.documentElement.style.removeProperty(n),_t(r)}})}function nD({sheet:e,overlay:t,launcher:n,session:r}){let i=UE(),a=e||null,o=Xd()&&t===`image`&&!!a&&!!r,s=uf()&&o;rD(o,s);let c=i&&!!a&&!dl(t);return iD(i&&!!a&&!o,c?t:null),i?o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`aside`,{className:`ws-side`,children:[n,(0,Q.jsx)(qE,{})]}),r,(0,Q.jsxs)(`div`,{className:`ws-beside${s?` full`:``}`,children:[a,s?null:(0,Q.jsx)(tD,{})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`aside`,{className:`ws-side`,children:[n,(0,Q.jsx)(qE,{})]}),(c?null:a)??r??(0,Q.jsx)(`div`,{className:`screen ws-empty`,children:(0,Q.jsx)(Zd,{children:`Pick a session in the list, or start one.`})}),c?(0,Q.jsxs)(`div`,{className:`ws-panel`,children:[a,(0,Q.jsx)(tD,{of:`panel`})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[null,a??r??n,null]})}function rD(e,t){(0,Z.useEffect)(()=>{e||tc.set(!1)},[e]),(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),tc.set(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function iD(e,t){(0,Z.useEffect)(()=>e?RE(window,()=>Jl.depth,()=>history.back()):void 0,[e]);let n=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=document.activeElement;if(!t){let t=n.current;n.current=null,t?.isConnected&&(!e||e===document.body)&&t.focus();return}e?.matches?.(`.compose textarea`)&&(n.current=e);let r=document.querySelector(`#root > .ws-panel`);r&&!r.contains(e)&&r.querySelector(`.back`)?.focus()},[t])}var aD=120;function oD(){(0,Z.useEffect)(()=>{let e=window.visualViewport,t=document.documentElement,n=0,r=()=>{t.style.removeProperty(`--app-h`),t.style.removeProperty(`--app-top`)},i=()=>{e?document.visibilityState!==`hidden`&&(e.height>=aD?(t.style.setProperty(`--app-h`,`${e.height}px`),t.style.setProperty(`--app-top`,`${Math.max(0,e.offsetTop)}px`)):r()):r()},a=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(i)},o=()=>{document.visibilityState===`visible`&&(a(),setTimeout(()=>{let e=document.getElementById(`root`);e&&e.getBoundingClientRect().height<aD&&r()},60))};return a(),e?.addEventListener(`resize`,a),e?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a),window.addEventListener(`orientationchange`,o),window.addEventListener(`pageshow`,o),window.addEventListener(`focus`,o),document.addEventListener(`visibilitychange`,o),document.addEventListener(`resume`,o),()=>{cancelAnimationFrame(n),e?.removeEventListener(`resize`,a),e?.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,a),window.removeEventListener(`orientationchange`,o),window.removeEventListener(`pageshow`,o),window.removeEventListener(`focus`,o),document.removeEventListener(`visibilitychange`,o),document.removeEventListener(`resume`,o)}},[])}function sD(){let e=Kv(),{connRef:t,status:n,send:r,liveSend:i,liveSendAll:a,liveAsk:o,reconnectAsk:s,setReconnectAsk:c}=e,{httpsUrl:l,root:u}=e.info,d=ra(),f=X(`autoSend`),p=X(`serialSessions`),m=X(`confirmQueue`),{sessionsRaw:h,setSessions:g,recent:_,setRecent:v,closed:y,setClosed:b,repos:x,setRepos:S,reposAt:C,setReposAt:w,reposFailAt:T,setReposFailAt:E,intents:D,setIntents:O,backends:k,setBackends:A,update:j,setUpdate:M,meter:ee,setMeter:N,updateResultSeenRef:P}=Tx(),F=gy(e,()=>Me.current),{pendingStars:I,pendingFollowUps:te,closeSession:L}=F,R=(0,Z.useMemo)(()=>vu(vu(h,I,sa),te,In),[h,I,te]),{initRoute:ne,activeId:z,setActiveId:B,overlay:V,setOverlay:H,closeSheet:re,overlayRef:ie,focusRepo:U,setFocusRepo:ae}=Xv(),oe=my({conn:e,activeId:z,setActiveId:B,setOverlay:H,sessions:R,getActive:()=>_t,noteVisited:e=>Ve(e),onExit:()=>He.flushOutbox()});function W(e){Re.current=!1,oe.focus(e)}let{termRef:se,geomRef:ce,buffers:le,exitedRef:ue,readMode:de,readModeRef:fe,setView:pe,fireReader:me,setOutlineJump:he,attach:ge}=oe,_e=xv(),{compose:ve,setCompose:ye,composeNow:be,composeRef:xe,pushHistory:Se,insertCompose:Ce,composeFocused:we,setComposeFocused:Te}=_e,Ee=X(`enterSends`),De=X(`cliMode`);ia(ne,!!ne.file&&Gn(ne.file.relPath));let Oe=Fa(),ke=Nu(),Ae=Br(),je=ir(),Me=Ip(R),Ne=Ip(x),Pe=Ro()?.repoId??null,Fe=os();uo(),tx({connRef:t,setLaunch:e=>bt(e),setHiddenRepoIds:e=>Jt(e)}),Ps(z);let Ie=pn(),Le=Ga(),Re=(0,Z.useRef)(!1),ze=(0,Z.useRef)(null),[Be,Ve]=(0,Z.useState)(null),He=F_({conn:e,sessions:R,backends:k,repos:x,activeId:z,setActiveId:B,setLastVisitedId:e=>Ve(e),overlayRef:ie,setOverlay:H,wantNavRef:Re,buffers:le,readModeRef:fe,exitedRef:ue,composeTextRef:be,setCompose:ye,pushHistory:Se,openSend:e=>Ft(e),sendTargetFor:(e,t)=>zt(e,t),repoForCwd:e=>an(e),focusSession:e=>W(e)}),Ue=He.entries,{outboxRef:We,writeOutbox:Ge,flushOutbox:Ke,idleReason:qe,goneLanes:Je,submitInput:Ye,queueOp:Xe,queueBacklog:Ze,queueImageUpload:Qe,pendingSession:$e,answerPrompt:et,holdQueueRef:tt,laneLabel:nt,sendQueuedNow:rt,toggleHoldQueued:it,toggleSerialQueued:at,removeQueued:ot,editQueued:st,retargetQueued:ct,restoreQueued:lt,retryFailedQueued:ut,moveQueued:dt,addPromptToQueuedCreate:ft,scheduleQueueRows:pt,dropScheduleQueue:mt,repoIdOfEntry:ht}=He,{allBufsRef:gt}=He.uploads,_t=(0,Z.useMemo)(()=>R.find(e=>e.id===z)??$e,[R,z,$e]),vt=!!$e&&_t?.id===$e.id,G=K_({backends:k,setOverlay:H,geomRef:ce,queue:He,setRepos:S,setReposAt:w,setReposFailAt:E,root:u,repos:x,active:_t,openingCwds:()=>en,repoForCwd:e=>an(e)}),{launch:yt,setLaunch:bt,setLaunchOpt:xt,pickBackend:St,wireLaunch:Ct,sessionCan:wt,sessionCant:Tt,refreshRepos:Et,openRepo:Dt,openCwd:Ot,startSessionWithPrompt:kt,relaunch:At}=G,jt=de&&!vt&&Yt(k,_t?hc(_t):void 0,`transcript`)&&!(_t?.cliSetup&&_t.running),Mt=iv({connRef:t,liveSend:i,liveSendAll:a,queue:He,sessions:R,getVisibleRepos:()=>Zt,intents:D,usage:Ie,launch:yt,wireLaunch:Ct,geomRef:ce,repoForCwd:e=>an(e),startSessionWithPrompt:kt,setOverlay:H,attach:ge}),{sendSeed:Nt,sendSeedRef:Pt,openSend:Ft,seedFromIntent:It,seedFromSchedule:Rt,sendTargetFor:zt,renderRetime:Bt}=Mt,Vt=Sv(_e,{conn:e,active:_t,pending:vt,activeId:z,sessions:R,readerShown:jt,enterSends:Ee,cliModeOn:De,setCliModeOn:e=>J(`cliMode`,e),showCli:()=>pe(!1),queue:He,sender:Mt,repoForCwd:e=>an(e),leave:()=>B(null),cliInstalled:j?.current,relaunch:At}),{cliMode:Ht,voice:Ut}=Vt,Wt=Lw({activeId:z,active:_t,composeFocused:we,setComposeFocused:Te,composeRef:xe,cliMode:Ht}),Gt=(0,Z.useMemo)(()=>_t?$y(x,_t.cwd):null,[_t,x]),Kt=Gt?.id??null,qt=Ag(Kt,de),{setHiddenRepoIds:Jt,toggleHideRepo:Xt,visibleRepos:Zt,hiddenRepos:Qt,hiddenRepoPaths:$t,openingCwds:en,cwdInFocus:tn,cwdVisible:nn,visibleBacklogItems:rn}=nx({repos:x,focusRepo:U,outbox:Ue,bl:Fe}),an=e=>$y(x,e),on=e=>$y(x,e.cwd),sn=e=>eb(x,e),cn=e=>ab(x,e);(0,Z.useEffect)(()=>{Yu(U&&nb(x,U))},[U,x]),oD();let[ln,un]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=setInterval(()=>{document.hidden||un(e=>e+1)},3e4);return()=>clearInterval(e)},[]),(0,Z.useEffect)(()=>{V&&q(`overlay:${V}`)},[V]);let fn=e=>rx(e,{setOverlay:H,activeRepoId:Kt,active:_t,readMode:de,fireReader:me,send:r,geomRef:ce,submitInput:Ye,openCompanionShell:G.openCompanionShell});zy({conn:e,term:oe,verbs:F,q:He,focusSession:W},{connRef:t,setBackends:A,setSessions:g,setRecent:v,setClosed:b,setUpdate:M,setMeter:N,setIntents:O,updateResultSeenRef:P,wantNavRef:Re}),sx({status:n,refreshRepos:Et,activeId:z,active:_t,wantNavRef:Re,firedIdRef:ze,bl:Fe,sessions:R,attach:ge,repos:x,overlay:V}),Rg(_t);let{installEvt:mn,canInstall:hn,setCanInstall:gn,installed:_n}=cx();(0,Z.useEffect)(()=>{Bn()},[]),yx({sessions:R,sessionRepoName:sn,activeId:z,repos:x,attach:ge,closeSession:L,backends:k}),(0,Z.useEffect)(()=>{n===`open`&&(_t&&V!==`settings`||r({t:`usage.refresh`}))},[V,_t,n]),Cx({reposRef:Ne,initRoute:ne,sessions:R,attach:ge,setOverlay:H});function vn(e){qp(e,()=>H(`git`))}if(wx({outbox:Ue,activityFiled:Ae,activityConfirmedDone:je,allBufsRef:gt}),ho({conn:{get status(){return t.current.status},send:r,trySend:e=>t.current.trySend(e),liveSend:i,liveSendAll:a,liveAsk:o,info:e.info},queue:{queueOp:Xe,submitInput:Ye,mintAckId:Bd,entries:He.entries,repoIdOf:ht,drop:e=>Ge(We.current.filter(t=>t.ackId!==e)),blocked:He.blocked,goneLanes:Je,laneLabel:nt,answerPrompt:et,queueBacklog:Ze,flush:Ke,idleReason:qe,serial:{on:p,set:e=>J(`serialSessions`,e)},verbs:{sendQueuedNow:rt,toggleHoldQueued:it,toggleSerialQueued:at,removeQueued:ot,editQueued:st,retargetQueued:ct,restoreQueued:lt,retryFailedQueued:ut,moveQueued:dt,addPromptToQueuedCreate:ft,scheduleQueueRows:pt,dropScheduleQueue:mt},uploads:He.uploads,queueImageUpload:Qe},nav:{overlay:V,open:H,close:re,attach:ge,openRepo:Dt,openSend:Ft,startSessionWithPrompt:kt,openBacklogCut:Ld,openScheduleCut:Wf,closeSession:L,openPlugin:e=>dn(e),openRepoHealth:lr,openSetup:ri,openContext:Zn,followFire:e=>{Re.current=!0,ze.current=e},openPadAt:Pi,sendSeeded:()=>Pt.current!=null,openActivity:Ki,openGit:vn,openReader:oe.openReader,openCapture:qf,openBuild:Rn},launch:{setOpt:xt,wire:Ct,openCwd:Ot,relaunch:At,focusShell:G.focusShell,shellCant:G.shellCant,openCompanionShell:G.openCompanionShell},term:{snapshot:oe.snapshot,geom:()=>ce.current},compose:{draft:ve,insert:Ce,seedDraft:Vt.seedDraft,typeOn:Vt.typeOn,send:Vt.sendNow,pushHistory:Se,removePadNotes:Ms,loadSheetDraft:pi,seedSheetDraft:Gc,appendSheetDraft:va,gridText:()=>se.current?.getText()??``},world:{sessions:R,repos:x,reposAt:C,visibleRepos:Zt,active:_t,activeRepo:Gt,backends:k,recent:_,closed:y,intents:D,launches:He.launches,budget:He.budget,billing:Le,meter:ee,usage:Ie,get usageReadings(){return sc()},get tokensOpenOn(){return pp()},clearTokensOn:Vf,launch:yt,update:j,sessionRepo:on,sessionRowTitle:cn,sessionCan:wt,sessionCant:Tt,repoForCwd:an,refreshRepos:Et,schedules:Oe,pending:vt,backlog:Fe.items,backlogAuto:Fe.auto,cwdVisible:nn},files:{downloadArtifact:Np,openArtifact:e=>mc(e),viewImage:hu,attachForInbox:Td,annotate:Ou,openSweep:Kn,editBacklogImage:Vu,annotateUrl:Ff,attachFiles:Hs,browseTo:bp,openFileFrom:(e,t)=>mc(e,t)},send:{renderRetime:Bt,seedFromSchedule:Rt,seedFromIntent:It,targetFor:zt},say:{toast:K,track:q,confirm:Lt}}),(0,Z.useEffect)(()=>Ev(),[]),d)return(0,Q.jsx)(Mn,{reconnect:()=>t.current.reconnect(),unlockSeal:cf});let yn=Wt.drawnSheet(ex({overlay:V,setOverlay:H,closeSheet:re,connRef:t,status:n,setReconnectAsk:c,submitInput:Ye,holdQueueRef:tt,flushOutbox:Ke,removeQueued:ot,pendingSession:$e,insertCompose:Ce,setOutlineJump:he,setView:pe,active:_t,sessions:R,visibleRepos:Zt,outbox:Ue,usage:Ie,intents:D,launchCore:G,sessionCant:Tt,pickBackend:St,refreshRepos:Et,sendCore:Mt,sendSeed:Nt,voice:Ut,installed:_n,canInstall:hn,installEvt:mn,setCanInstall:gn,gitRepoId:Pe,activeRepoId:Kt,repos:x,reposAt:C,backends:k}));return(0,Q.jsx)(nD,{sheet:yn,overlay:V,session:_t?(0,Q.jsx)(Iw,{active:_t,pending:vt,conn:e,term:oe,q:He,compose:Vt,launch:G,chrome:Wt,backends:k,sessions:R,update:j,readerShown:jt,activeRepo:Gt,transportKnown:qt,visibleBacklogItems:rn,intents:D,verbs:F,repoForCwd:an,sessionRepoName:sn,setActiveId:B,setOverlay:H,runToolbar:fn}):null,launcher:(0,Q.jsx)(IE,{sessions:R,recent:_,closed:y,repos:x,reposAt:C,reposFailAt:T,backends:k,intents:D,outbox:Ue,nowTick:ln,launch:yt,conn:e,route:{focusRepo:U,setFocusRepo:ae,setOverlay:H,lastVisitedId:Be},view:{visibleRepos:Zt,hiddenRepos:Qt,hiddenRepoPaths:$t,cwdInFocus:tn,cwdVisible:nn,toggleHideRepo:Xt,openingCwds:en},launchCore:G,term:oe,queue:He,openSend:Ft,verbs:F,openGitFor:vn,banners:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y_,{q:He,status:n,reconnectAsk:s,setReconnectAsk:c,autoSend:f,confirmQueue:m,pullRecords:ke,setOverlay:H}),(0,Q.jsx)(qc,{httpsUrl:l}),(0,Q.jsx)(bf,{onOpen:()=>H(`phonesetup`)}),(0,Q.jsx)(ka,{update:j,liveAsk:o,liveSend:i}),(0,Q.jsx)(Qu,{})]})})})}var cD=`.bl-modal-backdrop, [role=dialog][aria-modal=true], [data-primary-key]`;function lD(e){return e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&!e.isComposing}function uD(e){let t=e.querySelectorAll(cD);return t[t.length-1]?.querySelector(`button.send:not(:disabled)`)??null}function dD(e){let t=(e??``).replace(/\s+/g,` `).trim();return t&&t.length<=24?`press “${t}”`:`press the dialog's button`}function fD(e=window){let t=go({id:`primaryKey`,mods:[`ctrl`,`meta`],key:`Enter`,what:()=>dD(uD(e.document)?.textContent),when:()=>uD(e.document)!=null}),n=t=>{if(!lD(t))return;let n=uD(e.document);n&&(t.preventDefault(),t.stopPropagation(),n.click())};return e.addEventListener(`keydown`,n,!0),()=>{t(),e.removeEventListener(`keydown`,n,!0)}}function pD(e,t){return t||!e||!e.matches(`textarea[data-compose]:not(.pipe)`)?!1:(e.value??``).trim()!==``}function mD(e=document){return go({id:`composeSend`,mods:[`ctrl`,`meta`],key:`Enter`,what:()=>`send`,when:()=>pD(e.activeElement,uD(e)!=null)})}var hD=[{ms:3e5,label:`5m`},{ms:36e5,label:`1h`},{ms:144e5,label:`4h`},{ms:864e5,label:`1d`}],gD=hD.reduce((e,t)=>Math.max(e,t.ms),0);function _D(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let{id:n,until:r}=t;return typeof n!=`string`||!n||typeof r!=`number`||!Number.isFinite(r)?null:{id:n,until:r}}catch{return null}}function vD(e,t,n){return{id:e,until:t+n}}function yD(e,t,n){return!e||!t||e.id!==t?!1:n<e.until&&e.until-n<=gD}function bD(e){return`Hidden for ${e<36e5?`${Math.round(e/6e4)} min`:e<864e5?`${Math.round(e/36e5)} hours`:`${Math.round(e/864e5)} day${e>=1728e5?`s`:``}`} — it still applies on its own once you put the phone down.`}var xD=null;function SD(){let[e,t]=(0,Z.useState)(()=>hf.get()),[,n]=(0,Z.useState)(0),[r,i]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>hf.subscribe(t),[]),!Uc()||e.phase!==`staged`||!e.stagedId||xD===e.stagedId||yD(_D(Et(G.webUpdateSnooze)),e.stagedId,Date.now()))return null;let a=e.stagedId;return(0,Q.jsxs)(`div`,{className:`staged-bar`,role:`status`,children:[(0,Q.jsx)(Jh,{size:15}),(0,Q.jsx)(`span`,{className:`staged-bar-text`,children:r?`Hide this for how long?`:`A newer build is ready and verified on this phone.`}),!r&&(0,Q.jsx)(Y,{className:`staged-bar-go`,title:`restart into the new build — anything half-written in a box is lost`,onClick:()=>{q(`action:update.applyNow`),hf.applyNow()},children:`Restart into it`}),(0,Q.jsx)(`button`,{className:`staged-bar-later`,"aria-label":r?`keep showing it`:`hide for a while`,"aria-expanded":r,title:r?`keep showing it`:`hide for a while — pick how long; the build still applies on its own once you put the phone down`,onClick:()=>i(e=>!e),children:(0,Q.jsx)(Dh,{size:14})}),r&&hD.map(e=>(0,Q.jsx)(Y,{className:`staged-bar-span`,title:`hide the bar for ${e.label}, across reloads — the build still applies on its own once you put the phone down`,onClick:()=>{q(`action:update.snooze`),mt(G.webUpdateSnooze,vD(a,Date.now(),e.ms)),K(bD(e.ms)),i(!1),n(e=>e+1)},children:e.label},e.ms)),(0,Q.jsx)(`button`,{className:`staged-bar-x`,"aria-label":`not now`,title:`not now — it applies on its own once you put the phone down`,onClick:()=>{xD=a,n(e=>e+1)},children:(0,Q.jsx)(Lh,{size:14})})]})}var CD=6e4;function wD({onUnlocked:e}){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>(vo.start(),vo.subscribe(n)),[]);let l=async()=>{let t=await rc.state();t?(o(`ok`),i(t.checkedAt),t.unlockedUntil&&t.unlockedUntil>Date.now()?e(t.unlockedUntil):(vo.sync(t.items),vo.pump())):o(`unreachable`)};(0,Z.useEffect)(()=>{l();let e=setInterval(()=>{document.visibilityState===`visible`&&l()},CD),t=()=>{document.visibilityState===`visible`&&l()};return document.addEventListener(`visibilitychange`,t),()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,t)}},[]);let u=qs(t);return(0,Q.jsx)(`div`,{className:`auth-gate passive-screen`,children:(0,Q.jsxs)(`div`,{className:`auth-card`,children:[(0,Q.jsxs)(`div`,{className:`auth-title`,children:[(0,Q.jsx)(Tg,{size:16,style:{verticalAlign:`-3px`}}),` Apps`]}),u.length===0&&(0,Q.jsx)(`div`,{className:`set-note`,children:`No new app builds right now. New ones download here by themselves.`}),u.map(e=>(0,Q.jsxs)(`div`,{className:`passive-row`,children:[(0,Q.jsx)(`div`,{className:`passive-name`,children:e.item.name}),(0,Q.jsxs)(`div`,{className:`set-note`,children:[e.item.repoName,` · `,Ll(e)]})]},e.item.id)),(0,Q.jsxs)(`div`,{className:`passive-foot`,children:[(0,Q.jsx)(`span`,{className:`set-note`,children:a===`unreachable`?`Desktop not reachable${r?` — last check ${Dp(r)}`:``}`:r?`Last check ${Dp(r)}`:`Checking…`}),(0,Q.jsxs)(`button`,{className:`link-btn`,title:`check the desktop for new builds now`,onClick:()=>{l(),K(`checking for new builds`)},children:[(0,Q.jsx)(Xh,{size:12}),` check now`]})]}),!s&&(0,Q.jsxs)(`button`,{className:`link-btn passive-unlock`,title:`unlock the full app with the PIN`,onClick:()=>c(!0),children:[(0,Q.jsx)(gg,{size:12}),` Unlock`]}),s&&(0,Q.jsx)(TD,{onCancel:()=>c(!1),onUnlocked:e})]})})}function TD({onCancel:e,onUnlocked:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{c.current?.focus()},[]);let l=async()=>{a(!0),s(null);let e=null;try{e=await rc.unlock(n)}catch{e=null}a(!1),e?e.ok?t(e.unlockedUntil):(r(``),s(e.message||de(e.error))):s(`The desktop did not answer. Try again when it is reachable.`)};return(0,Q.jsxs)(`form`,{className:`passive-pin`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,Q.jsx)(`input`,{ref:c,className:`auth-input`,type:`password`,inputMode:`numeric`,autoComplete:`off`,placeholder:`PIN`,value:n,onChange:e=>r(e.target.value.replace(/\D/g,``).slice(0,12)),"aria-label":`unlock PIN`}),(0,Q.jsx)(Y,{variant:`primary`,type:`submit`,title:`unlock for 30 minutes`,children:i?`checking…`:`unlock`}),(0,Q.jsx)(Y,{type:`button`,onClick:e,children:`not now`}),o&&(0,Q.jsx)(`div`,{className:`set-note`,style:{color:`var(--dead)`},children:o})]})}function ED({until:e}){let[t,n]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let t=setTimeout(()=>window.location.reload(),ad(e));return()=>clearTimeout(t)},[e]);let r=Ke(e);if(!r)return null;let i=async()=>{n(!0);try{await rc.lock()}catch{}window.location.reload()};return(0,Q.jsxs)(`div`,{className:`passive-bar`,role:`status`,children:[(0,Q.jsx)(Sg,{size:13}),` `,r,` ·`,` `,(0,Q.jsx)(`button`,{className:`link-btn`,title:`back to the passive screen now`,onClick:()=>void i(),children:t?`locking…`:`Lock now`})]})}var DD=22,OD=36;function kD(){let e=vt(),t=Ad(),n=t===`static`?OD:DD;if((0,Z.useEffect)(()=>{if(e)return document.documentElement.style.setProperty(`--ui-demo-h`,`${n}px`),()=>{document.documentElement.style.removeProperty(`--ui-demo-h`)}},[e,n]),!e)return null;let r=t===`shell`&&!Gr();return(0,Q.jsxs)(`div`,{className:t===`static`?`demo-line static`:`demo-line`,role:`status`,style:{height:n},children:[(0,Q.jsx)(Yh,{size:12}),(0,Q.jsx)(`span`,{className:`demo-line-text`,children:t===`static`?(0,Q.jsxs)(Q.Fragment,{children:[`Demo — nothing runs on a computer. To use `,A.name,` for real, open it from your own desktop host.`]}):`Demo — nothing runs on a computer`}),(0,Q.jsxs)(Y,{className:`demo-line-go`,onClick:$o,children:[(0,Q.jsx)(Cg,{size:11}),` More to try`]}),t!==`static`&&(0,Q.jsx)(Y,{className:`demo-line-go`,onClick:ds,children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(tm,{size:11}),` Connect a real desktop`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(jh,{size:11}),` Leave the demo`]})})]})}var AD=3e5;Gy(),bu(location,Date.now()),Kc(),tr();try{xt()}catch(e){St(null,`The demo could not start: ${String(e?.message??e)}`)}Dl(),ao(),vf(uu),gs(),qa(),Ss(),xl(),Mp(),zr(),ii();for(let e of[P(`installLog`),...I(`installLog`)])_t(e);al(),fD(),Mu(),mD(),br();function jD(){let[e,t]=(0,Z.useState)(()=>!Iu()),n=wc(),[r,i]=(0,Z.useState)(null);(0,Z.useEffect)(()=>e?Os(i):void 0,[e]);let[a,o]=(0,Z.useState)(()=>Iu()?Ku(Hd(),null):`full`),s=(0,Z.useRef)(a===`full`),[c,l]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(e)return;let t=!0;return rc.status().then(e=>{if(!t||!e)return;tf(e);let n=Ku(Hd(),e);l(n===`full`&&e.scope===`passive`&&e.unlockedUntil?e.unlockedUntil:null),n===`passive`&&s.current?window.location.reload():o(n)}),()=>{t=!1}},[e]),(0,Z.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(`app:host-setup`,e),()=>window.removeEventListener(`app:host-setup`,e)},[]),(0,Z.useEffect)(()=>{if(!Uc())return;hf.markHealthy().then(()=>hf.check());let e=setInterval(()=>{document.visibilityState===`visible`&&hf.check()},AD),t=Date.now(),n=()=>{document.visibilityState===`visible`&&(Date.now()-t<6e4||(t=Date.now(),hf.check()))};document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n);let r=()=>{t=Date.now(),hf.check()};window.addEventListener(Xr,r);let i=hf.watchAutoApply();return()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n),window.removeEventListener(Xr,r),i()}},[]);let u=yt();return u?(0,Q.jsx)(`div`,{className:`auth-gate`,children:(0,Q.jsxs)(`div`,{className:`auth-card`,children:[(0,Q.jsxs)(`div`,{className:`auth-title`,children:[(0,Q.jsx)(Yh,{size:16,style:{verticalAlign:`-3px`}}),` Demo not available`]}),(0,Q.jsx)(`div`,{className:`set-note`,children:u}),(0,Q.jsx)(`div`,{className:`set-row demo-problem`,children:(0,Q.jsx)(Y,{variant:`primary`,onClick:ds,children:`Leave the demo`})})]})}):e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gu,{}),Iu()&&(0,Q.jsx)(Ul,{}),(0,Q.jsx)(Lf,{mode:`first`,pair:r,pairFromLink:!!r,onDone:()=>t(!Iu()),onCancel:Iu()?()=>t(!1):void 0})]}):a===`passive`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gu,{}),(0,Q.jsx)(SD,{}),(0,Q.jsx)(wD,{onUnlocked:e=>{l(e),s.current=!0,o(`full`)}})]}):n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gu,{}),(0,Q.jsx)($s,{})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(sD,{}),(0,Q.jsx)(MD,{}),(0,Q.jsx)(Ks,{}),(0,Q.jsx)(Il,{}),(0,Q.jsx)(Vd,{}),(0,Q.jsx)(Ef,{}),(0,Q.jsx)(Gu,{}),(0,Q.jsx)(mf,{}),(0,Q.jsx)(As,{}),(0,Q.jsx)(md,{}),(0,Q.jsx)(Oo,{}),(0,Q.jsx)(gd,{}),(0,Q.jsx)(SD,{}),(0,Q.jsx)(Rt,{}),(0,Q.jsx)(kD,{}),c&&(0,Q.jsx)(ED,{until:c}),(0,Q.jsx)(Ul,{})]})}function MD(){return(0,Z.useEffect)(()=>{try{tp(Uv())}catch{}try{ji(Uv())}catch{}try{tn(Uv(),Ut)}catch{}try{Vc(Uv())}catch{}},[]),null}if(Bl(),dd(),Ls().finally(()=>(0,Og.createRoot)(document.getElementById(`root`)).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(Wy,{children:(0,Q.jsx)(jD,{})})}))),`serviceWorker`in navigator&&!hl()){let e=!!navigator.serviceWorker.controller,t=!1,n=()=>{t||(t=!0,window.location.reload())};navigator.serviceWorker.addEventListener(`controllerchange`,()=>{!t&&e&&(document.visibilityState===`hidden`?n():document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&n()}))}),window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).then(e=>e.update().catch(()=>{})).catch(()=>{})})}
|