teamtrail 0.29.2-next.42 → 0.29.3-next.43
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.
|
@@ -142,14 +142,14 @@ ${s.briefText}`)},4e3,a=>s.stale[a.id]??[]);return i.jsxs("div",{className:"kn-p
|
|
|
142
142
|
`),trailing:dn(e.now-t.since),onOpen:e.onOpen,actions:i.jsx($1,{title:t.title,canDismiss:fj(t),onSnooze:e.onSnooze,onDismiss:e.onDismiss}),below:i.jsx(k1,{item:t})})}function A1(e){const t=[];for(const s of e){const o=t.at(-1);(o==null?void 0:o.key)===s.batchKey?o.items.push(s):t.push({key:s.batchKey,kind:s.kind,mapId:s.mapId,items:[s]})}return t}const I1={question:"inbox-list",approval:"inbox-list approvals"};function M1(e){const{batch:t}=e,s=t.items.length>1,o=t.kind==="question"?"answer together":"review together",a=[`${t.items.length} ${x1[t.kind]}`,e.trail,o].filter(Boolean);return i.jsxs("div",{className:`att-batch ${s?"many":""}`,children:[s&&i.jsx("span",{className:"batch-head t-label",children:a.join(" · ")}),i.jsx("ul",{className:`att-list ${I1[t.kind]??""}`,children:e.children})]})}function R1(e,t){e.ticketId?t.openTicket(e.mapId,e.ticketId):t.selectTrail(e.mapId)}function Ig(e,t){switch(e.kind){case"question":return t.openQuestion(e.ref);case"approval":case"blocked":case"policy":case"flag":case"stalled":case"hitl-ready":case"overlap":case"integration":case"model":case"tracker-settings":return R1(e,t);case"knowledge":return t.openKnowledge();case"brief":return t.openBrief(e.mapId);case"reroute":case"reroute-suggested":return t.openReroute(e);case"guide":case"guide-checks":return t.openGuides();case"delivery":return t.openConnector(e.ref);case"trust":return t.openApprovals();default:return e.kind}}function L1(e){const t=Yt(1e3),{view:s}=e;if(!s.items.length)return i.jsx(Qn,{title:"Nothing waiting on you",hint:s.hidden?`${s.hidden} snoozed or set aside. They come back when the snooze ends.`:"When an agent needs your call, it lands here, most important first."});const o=Object.keys(e.snaps).length>1,a=h=>o&&h!==e.currentMapId,c=new Set(s.interrupting),d=h=>{var m;return(m=e.pending.find(p=>p.id===h))==null?void 0:m.sessionId};return i.jsx("div",{className:"attention-queue",children:A1(s.items).map(h=>{var m;return i.jsx(M1,{batch:h,trail:a(h.mapId)?(m=e.snaps[h.mapId])==null?void 0:m.map.title:void 0,children:h.items.map(p=>i.jsx(E1,{item:p,snap:e.snaps[p.mapId],otherTrail:a(p.mapId)&&h.items.length<2,selected:p.kind==="question"&&d(p.ref)===e.selected,interrupting:c.has(p.id),now:t,onOpen:()=>Ig(p,e.handlers),onSnooze:v=>e.onSnooze(p.id,v),onDismiss:()=>e.onDismiss(p.id)},p.id))},h.key)})})}const Nm={label:"Focus for 1 hour",change:{kind:"for",minutes:60}};function O1(e){switch(e.kind){case"manual":case"hours":return[{label:"End focus now",change:{kind:"end"},primary:!0}];case"paused":return[{label:"Resume quiet hours",change:{kind:"resume"},primary:!0},Nm];case"off":return[{...Nm,primary:!0},{label:"Focus for 3 hours",change:{kind:"for",minutes:180}}];default:return e}}const bm=e=>ua(e).slice(0,5),P1=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function _1(e){const t=`${e.items.length} waiting on you`;return e.heldBack===0?`Nothing held back · ${t}`:`${P1(e.heldBack,"item")} would interrupt you · ${t}`}function $c(e){const t=e.prefs.focus;return t?`Quiet hours ${t.from}–${t.to}`:"No quiet hours set"}const Cm=e=>`Items scoring ${e.policy.value.interrupt} or more interrupt you · ${e.items.length} waiting on you`;function D1(e){const t=e.focus;switch(t.kind){case"manual":case"hours":{const s=bm(t.until),o=t.kind==="manual"?"Switched on here":$c(e);return{word:"on",until:s,on:!0,title:`Focus is on until ${s}`,reason:o,detail:_1(e)}}case"paused":{const s=bm(t.until),o=`Quiet hours paused until ${s}`;return{word:"paused",until:s,on:!1,title:o,reason:$c(e),detail:Cm(e)}}case"off":return{word:"off",until:"",on:!1,title:"Focus is off",reason:$c(e),detail:Cm(e)};default:return t}}const z1="Focus holds back interruptions: no browser notifications or Slack messages, even for urgent items. Nothing is answered or dropped: everything still waits in Waiting on you and the Slack digest. Quiet hours turn it on every day; you can also focus for a while or end it early. This stays on this machine.";function B1(e){const{view:t}=e,s=D1(t),o=t.focus.kind,a=i.jsxs("span",{className:Ge("focus-state",`focus-${o}`),children:[i.jsx("i",{className:"focus-dot","aria-hidden":"true"}),i.jsxs("span",{className:"focus-label",children:["Focus",i.jsxs("span",{className:"focus-word",children:[" ",s.word]})]}),s.until&&i.jsxs("span",{className:"focus-until",children:[i.jsx("span",{className:"sep",children:" · "}),i.jsx("span",{className:"focus-until-word",children:"until "}),s.until]})]});return i.jsx(Ng,{className:"focus-menu",label:a,role:"dialog",tip:s.title,ariaLabel:s.title,children:c=>i.jsxs("div",{className:"focus-panel","aria-label":"Focus",children:[i.jsxs("div",{className:"focus-panel-head",children:[i.jsx("span",{className:"t-row-title",children:s.title}),i.jsx(ni,{text:z1})]}),i.jsx(V,{parts:[s.reason]}),i.jsx(V,{className:"focus-held",parts:[s.detail]}),i.jsxs("div",{className:"focus-panel-actions",children:[O1(t.focus).map(d=>i.jsx(P,{size:"sm",variant:d.primary?"primary":"default",onClick:()=>{c(),e.onChange(d.change)},children:d.label},d.label)),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>{c(),e.onSettings()},children:"Quiet hours"})]})]})})}function F1(e){const{view:t}=e,s=t.interrupting.length;return i.jsxs("span",{className:"attention-head",children:[i.jsx(B1,{view:t,onChange:e.onFocus,onSettings:e.onSettings}),s>0&&i.jsxs("span",{className:"waiting-chip interrupting",title:`${s} need you now`,children:[i.jsx(ii,{variant:"alert",size:14}),i.jsx("b",{children:s}),i.jsx("span",{className:"wl",children:" need you now"})]})]})}const Mg=`${je()}/attention`,U1=250;async function $m(e,t,s){var c;const o=await fetch(`${Mg}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(((c=a.errors)==null?void 0:c.join("; "))??a.error??`HTTP ${o.status}`);return a}function Rg(e){const[t,s]=y.useState(),[o,a]=y.useState(),[c]=y.useState(ei),d=y.useCallback(()=>{const m=c.start();fetch(Mg).then(p=>p.ok?p.json():void 0).then(p=>p&&m()&&s(p)).catch(()=>{})},[c]);y.useEffect(()=>ti("attention",m=>{c.pushed(),s(JSON.parse(m))}),[c]),y.useEffect(()=>fs(d),[d]),y.useEffect(()=>{const m=setTimeout(d,U1);return()=>clearTimeout(m)},[d,e]);const h=(m,p)=>void $m(m,"POST",p).then(()=>(a(void 0),d()),v=>a(v.message));return{view:t,error:o,snooze:(m,p)=>h("/snooze",{id:m,minutes:p}),dismiss:m=>h("/dismiss",{id:m}),savePrefs:m=>$m("/prefs","PUT",m).then(()=>(a(void 0),d(),!0),p=>(a(p.message),!1))}}function W1(e){return e.prefs.channel!=="browser"?!1:typeof Notification<"u"&&Notification.permission==="granted"}function H1(e){const t=new Notification(`${te.name} · needs you`,{body:e.title,tag:e.id});t.onclick=()=>{window.focus(),t.close()}}function K1(e){const t=y.useRef();y.useEffect(()=>{if(!e)return;const s=new Set(e.interrupting),o=t.current;if(t.current=s,!(!o||!W1(e)))for(const a of e.items)s.has(a.id)&&!o.has(a.id)&&H1(a)},[e])}function V1(e){const t=Yt(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list approvals",children:e.items.map(s=>{var c;const o=s.kind!=="approve",a=s.mapId!==e.currentMapId?(c=e.snaps[s.mapId])==null?void 0:c.map.title:void 0;return i.jsx(Ce,{as:"li",edge:o?"attention":"neutral",title:`${o?"Decide":"Approve"}: ${s.title}`,context:i.jsx(V,{parts:[o?"Held":"Verified",{text:s.ticketKey,code:!0},a]}),detail:s.reason,detailText:s.reason,trailing:dn(t-s.at),onOpen:()=>e.onOpen(s.mapId,s.ticketId)},`${s.mapId}/${s.ticketId}`)})}):null}function Tm({activity:e}){const t=Yt(1e3),s=gx(e);return i.jsxs("div",{className:"hitl-readout",children:[i.jsx(on,{layout:"inline",label:"Oldest",value:s.oldestAt?Qt(t-s.oldestAt):"—",urgent:!!s.oldestAt&&t-s.oldestAt>6e4,title:"Oldest open question"}),i.jsx(on,{layout:"inline",label:"Avg wait",value:s.avgWaitMs!==void 0?Qt(s.avgWaitMs):"—",title:`Average wait over ${s.answered} answered questions`}),i.jsx(on,{layout:"inline",label:"Answered",value:s.answered})]})}function G1(e){const t=Yt(1e3);return e.items.length?i.jsx("ul",{className:"inbox-list",children:e.items.map(s=>{const o=e.snaps[s.mapId],a=o==null?void 0:o.tickets.find(h=>h.id===s.ticketId),c=s.mapId!==e.currentMapId?o==null?void 0:o.map.title:void 0,d=s.text.split(`
|
|
143
143
|
`)[0];return i.jsx(Ce,{as:"li",className:s.sessionId===e.selected?"sel":void 0,edge:s.urgency==="blocking"?"urgent":"neutral",selected:s.sessionId===e.selected,title:d,titleText:s.text,context:i.jsx(V,{parts:[s.urgency==="blocking"&&{text:"Blocking",urgent:!0},`${s.agent} asks`,a&&{text:a.key,code:!0},a==null?void 0:a.title,c]}),trailing:dn(t-s.at),onOpen:()=>e.onOpen(s.sessionId,s.ticketId)},s.id)})}):i.jsx(Qn,{title:"Nothing waiting on you",hint:"When an agent needs your call, its question lands here."})}const q1={pass:"Passed",fail:"Failed",error:"Could not run",interrupted:"Interrupted"},ir={off:"Off",checks:"Checks","checks+review":"Checks + review","checks+review+human":"Checks + review + you"},Lg={off:"The agent saying “done” closes the ticket right away.",checks:"Your checks (tests, lint, typecheck…) run in the repo first. A failure goes back to the agent with the output.","checks+review":"After the checks pass, a different agent reviews the change. It is never the agent that did the work.","checks+review+human":"After checks and review, you approve it in the inbox before the ticket closes."},Q1=e=>e.exitCode===0&&!e.timedOut&&!e.error;async function Em(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`HTTP ${e.status}`);return t}const Eo=`${je()}/verification`,ur={ticket:(e,t)=>fetch(`${Eo}/ticket?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`).then(s=>s.ok?s.json():void 0,()=>{}),inbox:()=>fetch(`${Eo}/inbox`).then(e=>e.ok?e.json().then(t=>t.items):[],()=>[]),log:e=>fetch(`${Eo}/log?path=${encodeURIComponent(e)}`).then(t=>Em(t)),act:e=>fetch(`${Eo}/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>Em(t))};function Y1(e){const[t,s]=y.useState([]),o=Object.values(e).map(c=>c.tickets.map(d=>`${d.id}:${d.state}:${d.status??""}`).join()).join("|"),{reload:a}=pt({version:o,load:ur.inbox,show:s});return y.useEffect(()=>Ys.onEvidence(a),[a]),t}function J1(e,t){return{...e,items:e.items.filter(s=>!(s.kind==="brief"&&s.mapId===t))}}function X1(e){var h;const t=[...e.activity.pending].sort((m,p)=>m.at-p.at),s=Y1(e.snaps),o=(h=e.attention)==null?void 0:h.view,a=o&&e.briefShown?J1(o,e.currentMapId):o,c=a?a.items.length:t.length+s.length,d=i.jsx(Et,{hot:c>0,title:i.jsxs(i.Fragment,{children:[c>0&&i.jsx(ii,{variant:"alert",size:12}),"Waiting on you"]}),count:i.jsx(ds,{n:c,urgent:c>0,pop:!0},c)});return a&&e.attention&&e.handlers?i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(Tm,{activity:e.activity}),i.jsx(L1,{view:a,snaps:e.snaps,pending:e.activity.pending,currentMapId:e.currentMapId,selected:e.sessionId,handlers:e.handlers,onSnooze:e.attention.snooze,onDismiss:e.attention.dismiss})]}):i.jsxs("div",{className:"inbox-part",children:[d,i.jsx(Tm,{activity:e.activity}),i.jsx(V1,{items:s,snaps:e.snaps,currentMapId:e.currentMapId,onOpen:e.onOpenTicket}),(t.length>0||!s.length)&&i.jsx(G1,{items:t,snaps:e.snaps,currentMapId:e.currentMapId,selected:e.sessionId,onOpen:e.onOpenQuestion})]})}function Z1(e){const[t,s]=y.useState("list"),[o,a]=y.useState();y.useEffect(()=>{e.convRequest&&s("conv")},[e.convRequest]);const c=(v,k)=>{e.onOpen(v,k),s("conv")},d=v=>{const k=e.activity.pending.find(x=>x.id===v);k&&(a(k.id),c(k.sessionId,k.ticketId))},h=i.jsx(X1,{activity:e.activity,snaps:e.snaps,currentMapId:e.currentMapId,sessionId:e.sessionId,attention:e.attention,handlers:e.handlers&&{...e.handlers,openQuestion:d},briefShown:!!e.above,onOpenQuestion:c,onOpenTicket:e.onOpenTicket}),m=i.jsx(h1,{activity:e.activity,snaps:e.snaps,sessionId:e.sessionId,questionId:o,onAnswer:e.onAnswer,onBack:e.layout==="stack"?()=>s("list"):void 0});if(e.layout==="stack")return i.jsx(ze,{className:"zone inbox stack",children:t==="conv"&&e.sessionId?m:i.jsxs("div",{className:"stack-scroll",children:[e.above,h,e.below]})});const p=!!e.activity.sessions.find(v=>v.id===e.sessionId);return i.jsxs(ze,{className:`zone inbox split ${p?"has-conv":""}`,style:{gridArea:"inbox"},children:[i.jsx(Et,{className:"zone-title",icon:"mailbox",title:"Communication",info:"Where your agents reach you: everything waiting on you, ranked with the reasons why, the conversation with the agent that asked, and the tickets coming up next."}),e.above,h,p&&m,e.below]})}function eb(e){var h;const{snap:t}=e,s=t?Xs(t.tickets,t.map.mode):new Map,o={claimed:0,frontier:1},a=((t==null?void 0:t.tickets)??[]).filter(m=>o[s.get(m.id)]!==void 0).sort((m,p)=>o[s.get(m.id)]-o[s.get(p.id)]),c=new Set(e.sessions.filter(xg).map(m=>m.ticketId)),d=((h=e.selection)==null?void 0:h.kind)==="ticket"?e.selection.id:void 0;return i.jsxs("div",{className:"upnext",children:[i.jsx(Et,{title:"Up next",count:i.jsx("span",{className:"n mono-label",children:a.length})}),!t&&i.jsx(Ae,{children:"Ready tickets show here"}),t&&!a.length&&i.jsx(Ae,{children:"Nothing ready"}),t&&a.length>0&&i.jsx("ul",{className:"ticket-list",children:a.map(m=>{const v={state:s.get(m.id),waiting:c.has(m.id),assignee:m.assignee,hitl:or(m)==="hitl"},k=tb(v);return i.jsx("li",{className:`${d===m.id?"sel":""} st-${nb(v)}`,children:i.jsxs("button",{onClick:()=>e.onSelect({kind:"ticket",id:m.id}),children:[i.jsx("i",{className:"dot"}),i.jsx("span",{className:"key t-code",children:m.key}),i.jsx("span",{className:"ttl t-body",children:m.title}),i.jsx("span",{className:"st-text t-meta",children:k})]})},m.id)})})]})}function tb(e){if(e.waiting)return"waiting on you";if(e.state==="claimed")return e.assignee??"claimed";const t=hg[e.state].toLowerCase();return e.hitl?`${t}, needs you`:t}function nb(e){return e.waiting?"waiting":e.state==="frontier"&&e.hitl?"attention":e.state}function sb(e){const{api:t,nav:s}=e;return i.jsx(Z1,{activity:t.activity,snaps:t.allSnaps,currentMapId:t.mapId,sessionId:t.chatSession,layout:e.bp==="mobile"?"stack":"split",convRequest:s.convRequest,onOpen:s.openChat,onAnswer:t.actions.answer,onOpenTicket:s.openTicket,attention:e.attn.attention,handlers:e.attn.handlers,below:i.jsx(eb,{snap:t.snap,sessions:e.scoped.sessions,selection:t.selection,onSelect:s.select}),above:e.above})}function Ko({command:e,label:t="Copy"}){const[s,o]=y.useState(!1);return i.jsxs("span",{className:"agent-cmd",children:[i.jsx("code",{children:e}),i.jsx("button",{type:"button",className:"btn sm","data-tip":"Copy, then paste it in Claude Code or Codex",onClick:()=>void navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)}),children:s?"Copied":t})]})}const Ao=[{text:"Agents pick up ready work from their chat",command:"/scout resume"},{text:"Answer what is waiting on you from the chat",command:"/scout inbox"},{text:"Ask Scout where the trail stands",command:"/scout status"},{text:"Start the next trail from your agent",command:'/scout new "your idea"'},{text:"Click a ticket to zoom in. Scroll or pinch to zoom, drag to pan, Fit to see it all"}],ib=9e3;function rb(){const[e,t]=y.useState(0),[s,o]=y.useState(!1);y.useEffect(()=>{if(s)return;const c=setInterval(()=>t(d=>(d+1)%Ao.length),ib);return()=>clearInterval(c)},[s]);const a=Ao[e];return i.jsxs("div",{className:"command-bar real",children:[i.jsx(jg,{name:"map"}),i.jsx(Ve,{as:"h2",className:"zone-title-label",children:"Trail map"}),i.jsx(ni,{text:"Every decision ticket in this trail and what blocks what. Click a ticket to see it in Trail step. The strip below sums up progress."}),i.jsxs("div",{className:"hint",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>o(!0),onBlur:()=>o(!1),children:[i.jsx("span",{className:"dim",children:a.text}),a.command&&i.jsx(Ko,{command:a.command})]},e),i.jsxs("button",{type:"button",className:"link hint-next","data-tip":"Next hint","aria-label":"Next hint",onClick:()=>t(c=>(c+1)%Ao.length),children:[e+1,"/",Ao.length," ›"]})]})}function ob(e){const t=[{v:"plan+execute",title:"Plan + execute"},{v:"plan-only",title:"Plan only"}];return i.jsx("div",{className:"choice-row",children:t.map(s=>i.jsx(mt,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}function ab({onClose:e,tracker:t,onCreate:s}){const[o,a]=y.useState(),[c,d]=y.useState(!1),[h,m]=y.useState(),[p,v]=y.useState(""),[k,x]=y.useState(""),[S,C]=y.useState(""),[j,I]=y.useState(""),b=[p.trim(),k.trim(),S.trim()].filter(Boolean).join(". ").replace(/"/g,"'");return y.useEffect(()=>{const R=O=>O.key==="Escape"&&e();return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[e]),i.jsx("div",{className:"scrim",onClick:e,children:i.jsxs(ze,{as:"div",className:"dialog",onClick:R=>R.stopPropagation(),children:[i.jsx("header",{children:i.jsx("h2",{className:"t-heading caps",children:"New trail"})}),i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:p,onChange:R=>v(R.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Destination",children:i.jsx("textarea",{rows:3,value:k,onChange:R=>x(R.target.value),placeholder:"What is true when this trail is done?"})}),i.jsx(Ze,{label:"Notes",children:i.jsx("textarea",{rows:2,value:S,onChange:R=>C(R.target.value)})}),i.jsx(Ze,{label:"Assumptions (optional, one per line)",children:i.jsx("textarea",{className:"new-trail-assumptions",rows:2,value:j,onChange:R=>I(R.target.value),placeholder:"What the plan takes for granted, e.g. The v2 API supports batch writes"})}),i.jsxs("div",{className:"agent-draft",children:[i.jsxs("span",{className:"dim",children:["Paste this in Claude Code or Codex. Scout frames the trail with you there, then charts it here in ",t,"."]}),i.jsx(Ko,{command:`/scout new "${b||"your idea"}"`,label:"Copy command"})]}),o?i.jsxs("div",{className:"agent-draft created",children:[i.jsxs("span",{children:["Trail ",o," is on the map, starting with discovery. To get it moving, run this in Claude Code or Codex:"]}),i.jsx(Ko,{command:"/scout resume",label:"Copy command"})]}):h&&i.jsx("p",{className:"vf-err",children:h}),i.jsxs("footer",{children:[i.jsx(P,{variant:"ghost",onClick:e,children:"Close"}),!o&&i.jsx(P,{variant:"primary",disabled:c||!p.trim()||!k.trim(),"data-tip":"Put the trail on the map now; any agent picks it up with /scout resume",onClick:()=>{d(!0);const R=j.split(`
|
|
144
144
|
`).map(O=>O.trim());s({title:p.trim(),destination:k.trim(),notes:S.trim(),assumptions:R.filter(Boolean)}).then(O=>a(O.key)).catch(O=>m(O.message)).finally(()=>d(!1))},children:"Create trail"})]})]})})}const Am=["Ready when you are","What's the next big idea?","I keep the party on the trail","Describe it, I frame it"],lb=5e3;function cb(){const e=$u(),[t,s]=y.useState(0),[o,a]=y.useState(!0);return y.useEffect(()=>{if(o)return;const c=setTimeout(()=>{s(d=>(d+1)%Am.length),a(!0)},lb);return()=>clearTimeout(c)},[o]),i.jsxs("div",{className:"floating-scout","aria-hidden":"true",children:[i.jsx(ca,{variant:e?"night":"crt",size:3,framed:!1,speaking:o?Am[t]:void 0,onSpeakEnd:()=>a(!1),className:"fm-avatar"}),i.jsx("span",{className:"fm-shadow"})]})}function ub(e){return i.jsx(ab,{onClose:e.onClose,tracker:e.rt.adapter.label,onCreate:async t=>{const s=await mS(e.rt.adapter,t);return e.onCreated(s.id),s}})}const db={gh:"your gh login",GITHUB_TOKEN:"GITHUB_TOKEN",GH_TOKEN:"GH_TOKEN",stored:"a saved token","signed-in":"your GitHub sign-in",LINEAR_API_KEY:"LINEAR_API_KEY"},Iu=e=>db[e];function Mu(e){var t;return((t=e.account)==null?void 0:t.kind)==="user"?e.account.login:void 0}const Tc=e=>!!e.auth&&!!Mu(e);function Og(e,t){const s=Mu(e);return!e.auth||!s?void 0:`Will use ${t||"the repo you pick"} as ${s} (${Iu(e.auth)})`}function hb(e){if(!e.repo)return;const t=Mu(e),s=t?` as ${t}`:"",o=e.auth?`, using ${Iu(e.auth)}`:"";return`Connected to ${e.repo}${s}${o}`}function fb(e,t){if(!e.pushedAt)return;const s=Math.floor((t-Date.parse(e.pushedAt))/864e5);return s<1?"Pushed today":s<60?`Pushed ${s}d ago`:`Pushed ${Math.floor(s/30)}mo ago`}function mb(e){const{gh:t}=e;if(!t.auth)return null;const s=Og(t,e.repo);return i.jsxs("div",{className:"gh-identity",children:[s&&i.jsx("span",{className:"t-body",children:s}),i.jsxs("span",{className:"gh-identity-actions",children:[i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another token"}),t.auth==="signed-in"&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onSignOut,title:"Forgets the token on this machine. To revoke it, remove Teamtrail under GitHub → Settings → Applications.",children:"Sign out"})]})]})}const pb=/^[\w.-]+\/[\w.-]+$/;function gb(e){const t=e.query.trim().toLowerCase(),o=!!e.detected&&e.repos.every(m=>m.fullName!==e.detected)?[{fullName:e.detected,private:!1},...e.repos]:e.repos,a=[...o.filter(m=>m.fullName===e.detected),...o.filter(m=>m.fullName!==e.detected)],c=t?a.filter(m=>m.fullName.toLowerCase().includes(t)):a,h=pb.test(e.query.trim())&&c.every(m=>m.fullName.toLowerCase()!==t)?e.query.trim():void 0;return{shown:c.slice(0,e.limit),matches:c.length,typed:h}}function Im(e){const{repo:t,listed:s}=e,o=t.private?"Private":"Public";return i.jsx(Ce,{as:"li",className:"repo-row",selected:e.selected,title:i.jsx("span",{className:"t-code",children:t.fullName}),context:i.jsx(V,{parts:[e.detected&&{text:"This project's repo",strong:!0},s&&o,s&&fb(t,e.now),!s&&"Checked when you connect"]}),onOpen:e.onPick})}const vb=40;function Mm(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),a=y.useMemo(()=>new Set(e.repos.map(v=>v.fullName)),[e.repos]),{shown:c,matches:d,typed:h}=gb({repos:e.repos,detected:e.detected,query:t,limit:vb}),m=d>c.length?`${d-c.length} more: type to narrow`:"",p=e.truncated?`Your ${e.repos.length} most recently pushed repos`:"";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:t,placeholder:"Search your repos, or type owner/name",spellCheck:!1,"aria-label":"Search repositories",onChange:v=>s(v.target.value)})]}),i.jsxs("ul",{className:"repo-list","aria-label":"Repositories",children:[h&&i.jsx(Im,{repo:{fullName:h,private:!1},detected:h===e.detected,listed:!1,selected:h===e.value,now:o,onPick:()=>e.onChange(h)}),c.map(v=>i.jsx(Im,{repo:v,detected:v.fullName===e.detected,listed:a.has(v.fullName),selected:v.fullName===e.value,now:o,onPick:()=>e.onChange(v.fullName)},v.fullName))]}),i.jsx(V,{parts:[!d&&!h&&"No repo matches",m,p]})]})}function kb(e){const{list:t}=e;if(!t)return i.jsx(si,{label:"Loading your repos…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Mm,{repos:t.repos,truncated:t.truncated,detected:t.detectedRepo??e.detected,value:e.value,onChange:e.onChange});case"no-token":return i.jsx(V,{parts:["No GitHub token found"]});case"error":return i.jsxs(i.Fragment,{children:[i.jsx(Cu,{what:"Couldn't list your repos",reason:t.error,onRetry:e.onRetry}),i.jsx(Mm,{repos:[],truncated:!1,detected:e.detected,value:e.value,onChange:e.onChange})]});default:return t}}const yb={stored:"Saved token",gh:"gh CLI",GITHUB_TOKEN:"$GITHUB_TOKEN",GH_TOKEN:"$GH_TOKEN","signed-in":"Signed in with GitHub",LINEAR_API_KEY:"$LINEAR_API_KEY"},Zi=e=>e==="github"||e==="linear";function Pg(e){const[t,s]=y.useState(!e.source);return e.source&&!t?i.jsxs("div",{className:"ts-auth",children:[i.jsx("span",{className:"mono-label",children:e.label}),i.jsx("span",{className:"pill on",children:yb[e.source]}),i.jsx("button",{type:"button",className:"btn ghost sm",onClick:()=>s(!0),children:"Use another"})]}):i.jsxs("label",{className:"field",children:[i.jsxs("span",{className:"ts-label",children:[e.label,e.link&&i.jsx("a",{href:e.link.href,target:"_blank",rel:"noreferrer",children:e.link.text})]}),i.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:e.value,placeholder:e.placeholder,onChange:o=>e.onChange(o.target.value)})]})}function wb(e){const[t,s]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.code).then(()=>s(!0),()=>{}))};return i.jsxs("div",{className:"gh-device",children:[i.jsx("span",{className:"t-label",children:"Enter this code on GitHub"}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("code",{className:"gh-device-code t-code","aria-label":"Your code",children:e.code}),i.jsx(P,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("div",{className:"gh-device-row",children:[i.jsx("a",{className:"btn primary",href:Zs(e.href),target:"_blank",rel:"noreferrer",onClick:o,children:"Open GitHub"}),i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onCancel,children:"Cancel"})]}),i.jsx(si,{label:"Waiting for you to approve on GitHub…"})]})}function xb(e){switch(e.kind){case"code":return{kind:"code",userCode:e.userCode,verificationUri:e.verificationUri,interval:e.interval,asked:0};case"unavailable":return{kind:"ended",reason:"Sign in with GitHub isn’t set up in this build"};case"error":return{kind:"ended",reason:e.error};default:return e}}function jb(e,t){switch(t.kind){case"waiting":return{...e,interval:t.interval,asked:e.asked+1};case"signed-in":return{kind:"idle"};case"expired":return{kind:"ended",reason:"The code expired before it was approved"};case"denied":return{kind:"ended",reason:"The sign-in was declined on GitHub"};case"none":return{kind:"ended",reason:"The sign-in was stopped"};case"error":return{kind:"ended",reason:t.error};default:return t}}const zt=Hj(je());function er(e,t){e({tracker:t});const s=new URL(location.href);s.searchParams.delete("tracker"),location.href=s.toString()}function Sb(e){const[t,s]=y.useState({kind:"idle"}),o=y.useRef(e);o.current=e;const a=t.kind==="code";return y.useEffect(()=>{if(t.kind!=="code")return;let c=!0;const d=setTimeout(()=>void zt.githubSignIn.poll().then(async h=>{c&&(h.kind==="signed-in"&&await o.current(),c&&s(jb(t,h)))},h=>c&&s({kind:"ended",reason:h.message})),Math.max(t.interval,1)*1e3);return()=>{c=!1,clearTimeout(d)}},[t]),y.useEffect(()=>{if(a)return()=>void zt.githubSignIn.cancel().catch(()=>{})},[a]),{state:t,start(){s({kind:"starting"}),zt.githubSignIn.start().then(c=>s(xb(c)),c=>s({kind:"ended",reason:c.message}))},cancel(){s({kind:"idle"})}}}function Nb(e){const{state:t,start:s,cancel:o}=Sb(e.onSignedIn);switch(t.kind){case"idle":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(P,{variant:"primary",onClick:s,children:"Sign in with GitHub"}),i.jsx(V,{parts:["No gh login or token needed","the token stays on this machine"]}),i.jsx(V,{parts:["GitHub asks for access to your repos: it has no narrower scope for issues in private repos"]})]});case"starting":return i.jsx(si,{label:"Asking GitHub for a code…"});case"code":return i.jsx(wb,{code:t.userCode,href:t.verificationUri,onCancel:o});case"ended":return i.jsxs("div",{className:"gh-sign-in",children:[i.jsx(P,{onClick:s,children:"Try again"}),i.jsx(V,{parts:["Didn't sign in",t.reason]})]});default:return t}}function bb(e){var d,h;const{gh:t}=e,s=t.auth&&((d=t.account)==null?void 0:d.kind)==="unknown"?`Found ${Iu(t.auth)}, but GitHub didn't accept it`:"",o=((h=t.account)==null?void 0:h.kind)==="unknown"?t.account.error:"",a=t.auth==="GITHUB_TOKEN"||t.auth==="GH_TOKEN",c=t.signIn.available&&!a;return i.jsxs(i.Fragment,{children:[s&&i.jsx(V,{parts:[s,o]}),c&&i.jsx(Nb,{onSignedIn:e.onSignedIn}),c&&i.jsx("span",{className:"t-label gh-or",children:"Or paste a token"}),i.jsx(Pg,{source:null,value:e.token,onChange:e.onToken,label:"Token",placeholder:"ghp_… or github_pat_…",link:{href:"https://github.com/settings/personal-access-tokens/new",text:"New token"}}),i.jsxs("span",{className:"t-meta",children:["Or run ",i.jsx("code",{className:"t-code",children:"gh auth login"})," in a terminal; this finds it in a few seconds."]}),i.jsxs("label",{className:"field",children:["Repository",i.jsx("input",{value:e.repo,placeholder:"owner/name",spellCheck:!1,onChange:m=>e.onRepo(m.target.value.trim())})]})]})}function _g({r:e}){var o,a;if(!e)return null;if(!e.ok)return i.jsxs("div",{className:"test-line alert",children:["✕ ",e.error]});const t=(o=e.rate)!=null&&o.limit?`${(a=e.rate.remaining)==null?void 0:a.toLocaleString()}/${e.rate.limit.toLocaleString()} req`:"";let s="";return e.canWrite===!1?s="read-only":e.canWrite&&(s="read/write"),i.jsxs("div",{className:"test-line ok",children:["✓ ",[e.account,e.target,s,t].filter(Boolean).join(" · ")]})}function Ru(e){const[t,s]=y.useState(),[o,a]=y.useState(0);y.useEffect(()=>{if(s(void 0),!e.enabled)return;let d=!0;return e.load().then(h=>d&&s(h),h=>d&&s(e.failed(h.message))),()=>{d=!1}},[e.enabled,e.key,o]);const c=y.useCallback(()=>a(d=>d+1),[]);return{value:t,retry:c}}function Cb(e){const{value:t,retry:s}=Ru({enabled:e.enabled,key:e.auth??"",load:()=>zt.githubRepos(),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function Dg(e){const t=e.s.github,s=Tc(t),[o,a]=y.useState(!s),[c,d]=y.useState(t.repo??t.detectedRepo??""),[h,m]=y.useState(""),[p,v]=y.useState(),[k,x]=y.useState(!1),{list:S,retry:C}=Cb({enabled:!o,auth:t.auth});y.useEffect(()=>{s&&!h&&a(!1)},[s]);const j=async()=>{x(!0),v(void 0);try{await zt.connect({active:"github",github:{repo:c,token:o?h:void 0}}),e.onConnected()}catch(U){v({ok:!1,error:U.message}),x(!1)}},I=async()=>{const U=await e.reload();U&&Tc(U.github)&&a(!1)},b=async()=>{await zt.githubSignIn.signOut().catch(()=>{});const U=await e.reload();a(!U||!Tc(U.github))},O=!!c&&!(!o&&!S)&&(!o||!!h||s);return i.jsxs("div",{className:"card inset tracker-setup",children:[o?i.jsx(bb,{gh:t,token:h,onToken:m,repo:c,onRepo:d,onSignedIn:I}):i.jsxs(i.Fragment,{children:[i.jsx(mb,{gh:t,repo:c,onUseAnother:()=>a(!0),onSignOut:()=>void b()}),i.jsx(kb,{list:S,detected:t.detectedRepo,value:c,onChange:d,onRetry:C})]}),i.jsx(_g,{r:p}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:k||!O,onClick:()=>void j(),children:k?"Connecting…":"Connect"})})]})}function $b(e){return e.line?i.jsxs("div",{className:"gh-identity",children:[i.jsxs("div",{className:"ln-who",children:[i.jsx("span",{className:"t-body",children:e.line}),e.email&&i.jsx(V,{parts:[e.email]})]}),e.onUseAnother&&i.jsx("button",{type:"button",className:"btn ghost sm",onClick:e.onUseAnother,children:"Use another key"})]}):null}const Tb={LINEAR_API_KEY:"LINEAR_API_KEY",stored:"a saved key"},Lu=e=>Tb[e]??e;function ya(e){return(e==null?void 0:e.kind)==="user"?e:void 0}const Eb=e=>!!e.auth&&!!ya(e.viewer);function zg(e,t){if(e)return t?`${e} / ${t}`:e}function Bg(e){const t=ya(e.viewer);if(!t)return;const s=zg(e.team,e.project)??"the team you pick",o=e.source?` (${Lu(e.source)})`:"";return`Will use ${s} in ${t.orgName} as ${t.name}${o}`}function Ab(e){const t=zg(e.teamName??e.teamKey,e.projectName);if(!e.teamId||!t)return;const s=ya(e.viewer),o=e.orgName??(s==null?void 0:s.orgName),a=o?` in ${o}`:"",c=s?` as ${s.name}`:"",d=e.auth?`, using ${Lu(e.auth)}`:"";return`Connected to ${t}${a}${c}${d}`}function Ib(e,t){if(!e.activeAt)return"No issues yet";const s=Math.floor((t-Date.parse(e.activeAt))/864e5);return s<1?"Active today":s<60?`Active ${s}d ago`:`Active ${Math.floor(s/30)}mo ago`}function Mb(e){var a,c;const{ln:t}=e,s=t.auth&&((a=t.viewer)==null?void 0:a.kind)==="unknown"?`Found ${Lu(t.auth)}, but Linear didn't accept it`:"",o=((c=t.viewer)==null?void 0:c.kind)==="unknown"?t.viewer.error:"";return i.jsxs(i.Fragment,{children:[s&&i.jsx(V,{parts:[s,o]}),i.jsx(Pg,{source:null,value:e.apiKey,onChange:e.onKey,label:"API key",placeholder:"lin_api_…",link:{href:"https://linear.app/settings/account/security",text:"New key"}}),i.jsxs("span",{className:"t-meta",children:["Or set ",i.jsx("code",{className:"t-code",children:"LINEAR_API_KEY"})," before starting Teamtrail."]})]})}function Rb(e){const{list:t}=e;if(!t)return i.jsx(si,{label:"Loading projects…"});if(t.kind==="error")return i.jsx(Cu,{what:"Couldn't list the team's projects",reason:t.error,onRetry:e.onRetry});if(t.kind!=="ok"||!t.projects.length)return null;const s=[{value:"",label:"All projects"},...t.projects.map(o=>({value:o.id,label:o.state?`${o.name} · ${o.state}`:o.name}))];return i.jsxs("label",{className:"field",children:["Project (optional)",i.jsx(dt,{"aria-label":"Project",value:e.value,onChange:e.onChange,options:s})]})}function Lb(e){const t=e.query.trim().toLowerCase(),s=t?e.teams.filter(o=>o.key.toLowerCase().includes(t)||o.name.toLowerCase().includes(t)):e.teams;return{shown:s.slice(0,e.limit),matches:s.length}}function Ob(e,t){return t&&e.some(s=>s.id===t)?t:e.length===1?e[0].id:void 0}function Pb(e){const{team:t}=e;return i.jsx(Ce,{as:"li",className:"repo-row team-row",selected:e.selected,title:t.name,context:i.jsx(V,{parts:[{text:t.key,code:!0},Ib(t,e.now)]}),onOpen:e.onPick})}const _b=40;function Db(e){const[t,s]=y.useState(""),o=y.useMemo(()=>Date.now(),[]),{shown:a,matches:c}=Lb({teams:e.teams,query:t,limit:_b}),d=c>a.length?`${c-a.length} more: type to narrow`:"",h=e.truncated?`The first ${e.teams.length} teams`:"",m=e.value?"":"Pick the team your trails go in";return i.jsxs("div",{className:"repo-picker",children:[i.jsxs("label",{className:"field",children:["Team",i.jsx("input",{value:t,placeholder:"Search your teams by key or name",spellCheck:!1,"aria-label":"Search teams",onChange:p=>s(p.target.value)})]}),i.jsx("ul",{className:"repo-list","aria-label":"Teams",children:a.map(p=>i.jsx(Pb,{team:p,selected:p.id===e.value,now:o,onPick:()=>e.onChange(p.id)},p.id))}),i.jsx(V,{parts:[!c&&"No team matches",m,d,h]})]})}function zb(e){const{list:t}=e;if(!t)return i.jsx(si,{label:"Loading teams…",rows:3,className:"picker-loading"});switch(t.kind){case"ok":return i.jsx(Db,{teams:t.teams,truncated:t.truncated,value:e.value,onChange:e.onChange});case"no-key":return i.jsx(V,{parts:["Paste a Linear API key to list your teams"]});case"error":return i.jsx(Cu,{what:"Couldn't list your teams",reason:t.error,onRetry:e.onRetry});default:return t}}function Bb(e,t){const[s,o]=y.useState(e);return y.useEffect(()=>{const a=setTimeout(()=>o(e),t);return()=>clearTimeout(a)},[e,t]),s}function Fb(e){const{value:t,retry:s}=Ru({enabled:e.enabled&&!!e.teamId,key:`${e.teamId}
|
|
145
|
-
${e.apiKey??""}`,load:()=>zt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function Ub(e){const{value:t,retry:s}=Ru({enabled:e.enabled,key:e.apiKey??"",load:()=>zt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function Wb(e){const t=Bb(e.apiKey.trim(),400),s=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,a=Ub({enabled:o,apiKey:s}),c=Fb({teamId:e.teamId,apiKey:s,enabled:o}),d=a.list,h=c.list,m=(d==null?void 0:d.kind)==="ok"?d.teams:[],p=o&&!d,v=o&&!!e.teamId&&!h;return{enabled:o,list:d,teams:m,projects:h,loading:p||v,retryTeams:a.retry,retryProjects:c.retry}}function Fg(e){var oe;const t=e.s.linear,s=Eb(t),[o,a]=y.useState(!s),[c,d]=y.useState(""),[h,m]=y.useState(t.teamId??""),[p,v]=y.useState(t.projectId??""),[k,x]=y.useState(),[S,C]=y.useState(!1),{enabled:j,list:I,teams:b,projects:R,loading:O,retryTeams:U,retryProjects:X}=Wb({ln:t,paste:o,apiKey:c,teamId:h});y.useEffect(()=>{s&&!c&&a(!1)},[s]),y.useEffect(()=>{(I==null?void 0:I.kind)==="ok"&&m(Ob(I.teams,t.teamId)??"")},[I]);const Q=b.find(D=>D.id===h),W=(R==null?void 0:R.kind)==="ok"?R.projects.find(D=>D.id===p):void 0,ie=(I==null?void 0:I.kind)==="ok"?I.viewer:t.viewer,G=o?null:t.auth,ve=Bg({viewer:ie,team:Q==null?void 0:Q.name,project:W==null?void 0:W.name,source:G}),Pe=async()=>{if(Q){C(!0),x(void 0);try{await zt.connect({active:"linear",linear:{teamId:Q.id,teamKey:Q.key,teamName:Q.name,projectId:W==null?void 0:W.id,projectName:W==null?void 0:W.name,apiKey:o?c.trim():void 0}}),e.onConnected()}catch(D){x({ok:!1,error:D.message}),C(!1)}}},$e=D=>{m(D),v("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(Mb,{ln:t,apiKey:c,onKey:d}),i.jsx($b,{line:ve,email:(oe=ya(ie))==null?void 0:oe.email,onUseAnother:o?void 0:()=>a(!0)}),j&&i.jsx(zb,{list:I,value:h,onChange:$e,onRetry:U}),Q&&i.jsx(Rb,{list:R,value:p,onChange:v,onRetry:X}),i.jsx(_g,{r:k}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:S||O||!Q,onClick:()=>void Pe(),children:S?"Connecting…":"Connect"})})]})}function Hb(e){return i.jsxs("div",{className:"c-actions",children:[e.canSwitch&&i.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&i.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function Kb(e){return["Anything this account writes counts as you, including agents signed in as you",`${e==="github"?"people with write access":"members (not guests)"} can claim, move and close tickets; their decisions show under their name`,"settings they change wait for you in the queue, to accept or keep stricter"]}function Vb(e){const{id:t,active:s,s:o}=e,a=Zi(t),c=s&&o?Gb(t,o):void 0;return c&&a?i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"c-who",parts:[c]}),i.jsx(V,{className:"c-trust",parts:Kb(t)})]}):c?i.jsx(V,{className:"c-who",parts:[c]}):s&&(t==="markdown"||a)?i.jsx("div",{className:"c-loc",children:e.location}):a&&e.configured&&o?i.jsx("div",{className:"c-loc",children:qb(t,o)}):null}function Gb(e,t){if(e==="github")return hb(t.github);if(e==="linear")return Ab(t.linear)}function qb(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function Qb({status:e}){var c,d;if(!e)return null;const t=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",s=e.queued?` · ${e.queued} queued`:"",[o,a]=Yb(e,s);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:a}),t&&i.jsx("span",{className:"rate",children:t})]})}function Yb(e,t){switch(e.state){case"online":return["ok",`Online · synced ${dg(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${cr(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function Jb(e){const{id:t,active:s,configured:o,s:a}=e,c=Zi(t),d=!c||!!a,h=["card connector",s?"active":"",d?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:h.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),s&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(Vb,{id:t,active:s,configured:o,location:e.location,s:a}),c&&s&&i.jsx(Qb,{status:a==null?void 0:a[t].status}),i.jsx(Hb,{canSwitch:!s&&(!c||o),remote:c,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function Ug(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>zt.get().then(a=>(s(a),a),()=>(s(null),void 0)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,s,o]}function Xb(e){const[t,,s]=Ug(5e3),[o,a]=y.useState(null),c=async h=>{t&&(h==="markdown"||Zi(h))&&await zt.connect({active:h==="markdown"?"markdown":h,...h==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...h==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),er(e.update,h)},d=y.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:Kj.map(h=>{const m=h.id;return i.jsx(Jb,{id:m,name:h.name,active:m===e.activeTracker,configured:Zi(m)&&d[m],open:o===m,location:e.location,s:t,onSwitch:()=>void c(m),onToggle:()=>Zi(m)&&a(o===m?null:m)},h.id)})}),t&&o==="github"&&i.jsx(Dg,{s:t,reload:s,onConnected:()=>er(e.update,"github")}),t&&o==="linear"&&i.jsx(Fg,{s:t,onConnected:()=>er(e.update,"linear")})]})}function Zb(e,t){const s=e==null?void 0:e.github,o=e==null?void 0:e.linear,a=s&&t!=="github"?Og(s,s.repo??s.detectedRepo):void 0,c=o&&t!=="linear"?Bg({viewer:o.viewer,team:o.teamName,project:o.projectName,source:o.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:a??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:c??"Trails and tickets in your Linear team"}]}function Ie(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Ve,{as:"h4",children:e.title}),e.children]})}function Wg(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:t.map(s=>i.jsx(mt,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}const eC={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function tC(e){var I;const{prefs:t,update:s}=e,[o,,a]=Ug(5e3),[c,d]=y.useState(!1),h=(I=o==null?void 0:o.pending)==null?void 0:I.target.split(":")[0],[m,p]=y.useState(!1);y.useEffect(()=>{h&&!m&&t.tracker!==h&&s({tracker:h})},[h,m,t.tracker,s]);const v=Zb(o??void 0,t.tracker),k=t.tracker==="github"||t.tracker==="linear",x=k&&(o==null?void 0:o.active)===t.tracker,S=k&&!x,C=b=>{s({onboarded:!0}),er(s,b)},j=async()=>{d(!0);const b=o&&!o.pending;t.tracker==="markdown"&&b&&await zt.connect({active:"markdown"}).catch(()=>{}),s({onboarded:!0}),t.tracker!==e.activeTracker&&er(s,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(ze,{as:"div",className:"dialog onboarding",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(va,{className:"onb-title"})}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(rN,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(Ie,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:v.map(b=>i.jsx(mt,{on:t.tracker===b.id,title:b.title,sub:b.sub,onClick:()=>(p(!0),s({tracker:b.id}))},b.id))}),(o==null?void 0:o.pending)&&i.jsxs("p",{className:"t-meta onb-repo-tracker",children:["This repo keeps its trails in ",o.pending.label,". Connect it here, or keep local files on this machine; the team's choice in the repo isn't changed either way."]}),o===void 0&&k&&i.jsx(si,{label:eC[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!x&&i.jsx(Dg,{s:o,reload:a,onConnected:()=>C("github")}),o&&t.tracker==="linear"&&!x&&i.jsx(Fg,{s:o,onConnected:()=>C("linear")})]}),i.jsx(Ie,{title:"HITL transcript",children:i.jsx(Wg,{value:t.hitlTranscript,onChange:b=>s({hitlTranscript:b})})}),i.jsx("footer",{children:i.jsx(P,{variant:"primary",disabled:c||S,onClick:()=>void j(),children:"Get started"})})]})})}const rr=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"approvals",title:"Approvals"},{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"remote-agents",title:"Remote agents"},{id:"policy",title:"Risk policy"},{id:"guides",title:"Guides"},{id:"labels",title:"Labels"}]},{id:"alerts",label:"Attention & alerts",intro:"What interrupts you, where questions reach you, and what Scout tells you when you come back.",sections:[{id:"attention",title:"Attention"},{id:"slack",title:"Slack"},{id:"trip-report",title:"Trip report"}]},{id:"you",label:"You",intro:"How the Lookout looks and reads for you, and the browsers and devices signed in to it.",sections:[{id:"appearance",title:"Appearance"},{id:"transcript",title:"HITL transcript"},{id:"agent",title:"Agent"},{id:"devices",title:"Browsers & devices"}]},{id:"projects",label:"All projects",intro:"Every repo this Lookout knows, so you can switch between them from the header.",sections:[{id:"projects",title:"Projects"}]},{id:"about",label:"About",intro:"What Teamtrail is, and what changed in each release.",sections:[{id:"changelog",title:"Changelog"}]}];function Hg(e){if(e===null)return null;const t=rr.find(a=>a.id===e);if(t)return{group:t.id};const s=rr.find(a=>a.sections.some(c=>c.id===e));if(!s)return{};const o=s.sections.find(a=>a.id===e);return{group:s.id,section:o==null?void 0:o.id}}function nC(){return i.jsxs("p",{className:"sp-elsewhere t-meta",role:"note",children:["You're looking at this Lookout from another device. You can read, answer and approve from here. What changes what runs on the machine ",te.name," runs on, or whom it trusts, is set there: the approvals of what the repo asks it to trust, the tracker connection, Slack, the risk policy, verification levels, workspaces, guides, remote agents, your attention settings and the projects list. Paths on that machine and its tracker account are not shown here."]})}const Rm={from:"18:00",to:"09:00"};function sC(e){const t=e.focus!==void 0,s=e.focus??Rm;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(P,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:Rm),children:t?"On":"Off"}),t&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:s.from,onChange:o=>o.target.value&&e.onChange({...s,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:s.to,onChange:o=>o.target.value&&e.onChange({...s,to:o.target.value})})]})]})}const iC=[{value:"browser",label:"Browser notification"},{value:"slack-dm",label:"Slack DM"},{value:"slack-channel",label:"Slack channel"},{value:"none",label:"Nothing, I check the queue"}];function rC(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function oC(){const{view:e,error:t,savePrefs:s}=Rg(0);if(!e)return null;const o=e.policy.value,a=`${te.dataDir}/attention.json`,c=h=>void s({...e.prefs,...h}),d=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(Ie,{title:"Attention",children:[i.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",o.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),i.jsx(dt,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:iC,onChange:h=>{h==="browser"&&rC(),c({channel:h})}})]}),e.prefs.channel==="browser"&&d&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(sC,{focus:e.prefs.focus,onChange:h=>c({focus:h})}),i.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),e.policy.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(h=>i.jsxs("li",{children:[a,": ",h]},h))}),i.jsx(V,{className:"set-hint",parts:[e.policy.exists?{text:a,code:!0}:"Team defaults",`interrupt at ${o.interrupt}`,o.digestMinutes?`Slack digest every ${o.digestMinutes} min`:"Slack digest off"]}),t&&i.jsx("span",{className:"vf-err",children:t})]})}const aC=[5,15,30,60];function lC(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(mt,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),aC.map(s=>i.jsx(mt,{on:t.enabled&&t.awayMinutes===s,title:`Away ${s} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:s})},s))]})}const cC={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function Qe(e){const t=e.storage&&cC[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&i.jsx(V,{className:"sp-where",parts:[t]})]})}function uC(e){const[t]=Au();return t?i.jsx(Ie,{title:"Slack",children:i.jsx(s1,{focus:e.focus})}):null}function dC({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"attention",storage:"repo",children:i.jsx(oC,{})}),i.jsx(Qe,{id:"slack",storage:"machine",children:i.jsx(uC,{focus:t.section==="slack"})}),i.jsx(Qe,{id:"trip-report",storage:"browser",children:i.jsx(Ie,{title:"Trip report",children:i.jsx(lC,{value:e.prefs.briefing,onChange:s=>e.update({briefing:s})})})})]})}const hC=[{version:"0.17.0",date:"2026-11-03",items:["Discovery brief: new missions start with an agent mapping the existing system (files, conventions, data and API impact, risks, assumptions, product context). Implementation tickets wait until you accept the brief or ask for changes, from the banner over the map or the card in Communication","Create mission: start a mission from the New mission dialog without a terminal; any agent picks it up with /milo resume","Knowledge: what agents need to know about your codebase and product (architecture, conventions, gotchas, dead ends, business rules, personas, UX principles, pricing). Agents propose, you confirm, keep as an assumption or retire. Confirmed entries reach agents with every claim, picked for the ticket with the reason, and the inspector shows what an agent gets","Knowledge about specific files is flagged for re-confirmation when those files change","Save decisions, cancelled tickets (as dead ends) and brief sections as knowledge in one click; seed it from a document with miloops knowledge import <file.md>"]},{version:"0.16.0",date:"2026-11-03",items:["Mission report (Mission plan → Report): tickets done, mission and median ticket lead time, your interventions, rework, review results and cost per verified ticket. Hover any number to see how it is computed; export it as markdown","Agents report the same numbers in one line from the status tool","Agents use missions for big work only, and decide routine calls themselves, keeping each one as a decision record you can review or reverse; they ask you when the call changes product behaviour, data, security, billing, a public API or the schema","Decisions: filter by who made the call, agents on their own or people. The briefing now counts only the calls agents made themselves, not your answers they recorded"]},{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},{version:"0.10.0",date:"2026-10-31",items:["MCP server in the miloops package: `claude mcp add miloops -- npx -y miloops-cli mcp`, or the same for Codex","Connected agents start and resume missions, claim ready tickets, report steps, tokens and spend, close tickets and record decisions, live in the command center","Agent questions land in Waiting on you and the agent waits for your answer; answer in the command center or in the agent chat","/milo new, resume, status and inbox commands for Claude Code (and as a Codex prompt); `miloops connect claude|codex` sets them up","The command center follows a mission an agent just charted; sessions of agents that quit show as disconnected"]},{version:"0.9.0",date:"2026-10-31",items:["While you were away: MILO briefs you when you open the app or come back after being away: tickets done, now blocked, decisions waiting on you, agent decisions, spend and tokens since, active sessions","Briefing shows on return after 15 minutes hidden or idle; change the threshold or turn it off in Settings; reopen it from the header","Last seen per mission and usage over time are kept locally, so the briefing survives a reload","Mission title shows in full at laptop width; header readouts collapse to glyph and count","Prototype reviews link a real preview build and ask about the spike results"]},{version:"0.8.0",date:"2026-10-31",items:["Decisions: every decision across missions, newest first, with question, decision, alternatives, rationale, who decided and the full transcript","Filter decisions by mission, source, who decided and status; search; export to markdown","Supersede a decision; the chain stays visible on every record and in the mission","Decision records stored as markdown next to each mission and served by the local API with a live event stream","Resolve form: rationale and alternatives considered"]},{version:"0.7.0",date:"2026-10-31",items:["New type: Chakra Petch, Share Tech Mono and Barlow","Calmer palette; bright colour only for warnings and waiting on you","MILO mark, also used for status, action and alert glyphs","Dot-matrix signals for new decision requests and mission launches","Separate type voices for operators and agents","One-command install: npm i -g miloops-cli, then miloops in any repo","Packages renamed to @miloops-hq/core and @miloops-hq/command-center"]},{version:"0.6.0",date:"2026-10-31",items:["Named MILOOPS; MILO speaks for the platform in the activity log and onboarding","Tracker sync status, last-write latency and event pulse","Inbox: oldest question age and average wait","Critical path, decided per hour with burndown, type mix","Per-session tokens and cost, mission totals, claims per agent"]},{version:"0.5.0",date:"2026-10-31",items:["Status counters and resolution bar on the map","Current step tracker with step pipeline","Sessions with live timers","Activity log with time and source columns","Out-of-scope quarantine zone on the map"]},{version:"0.4.0",date:"2026-10-31",items:["Missions: switcher with progress and waiting count, New mission in the switcher","Inbox collects questions from every mission","Elapsed time and progress per mission","Responsive layout with progressive disclosure (wide, laptop, phone)","Map graph pans and zooms by drag, pinch and wheel","Changelog"]},{version:"0.3.0",date:"2026-10-31",items:["Fixed-zone layout","Plan + execute and plan-only mission modes","Execute tickets"]},{version:"0.2.0",date:"2026-10-31",items:["Local markdown tracker (default)","Onboarding","HITL transcript: summary or full","Settings with tracker connectors"]},{version:"0.1.0",date:"2026-10-31",items:["Live map graph","HITL vs AFK tickets","In-window HITL conversations","Demo tracker with simulated sessions"]}],fC=[{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],mC=[{version:"0.29.2",date:"2026-11-12",items:["The Activity log reads in one style: a coloured bar marks what needs you (red), what went well (green) and what is held up (amber), and Slack answers show who gave them"]},{version:"0.29.1",date:"2026-11-12",items:["Scout says in Slack that it needs Teamtrail running on your computer, and how to start it, when it can’t reach yours","Ask Scout in your own words: “@Scout what’s in my inbox?” or “status of Slack live test” work, in a channel or a DM"]},{version:"0.29.0",date:"2026-11-12",items:["Ask Scout in Slack: @Scout inbox or @Scout status in a channel answers only you, or DM Scout; if you added Scout before, Settings asks you to reconnect once","A question your agent waits on gets its own Slack message with answer buttons, even right after it asked another one","Scout can be installed straight from Slack (scout.teamtrail.app/install-slack); each person then connects in Settings → Slack"]},{version:"0.28.0",date:"2026-11-12",items:["Scout is now one Slack app: Settings → Slack → Add Scout to Slack, no app to create and no tokens to paste","You confirm which Slack account becomes Scout’s owner before it connects; if you made your own Slack app before, add Scout again","High-risk calls are answered in the Lookout only, and so is approving an agent’s request to change your settings: Slack shows Open in Lookout, and Decline still works there"]},{version:"0.27.3",date:"2026-11-11",items:["On Linux, the Lookout sees every change an agent makes to a ticket again, not only the first: a claimed ticket no longer stays in the queue as waiting"]},{version:"0.27.2",date:"2026-11-11",items:["Settings, briefs, criteria, guides, reroutes and the other panels stay current through reconnects, and a GitHub or Linear map updates live again"]},{version:"0.27.1",date:"2026-11-11",items:["The map and the queue no longer miss a change made while the Lookout was loading or reconnecting"]},{version:"0.27.0",date:"2026-11-11",items:["Teamtrail opens your browser ready to sign in with one click; `teamtrail pair` does the same for another tab"]},{version:"0.26.2",date:"2026-11-11",items:["The Lookout shows the new teamtrail. wordmark"]},{version:"0.26.1",date:"2026-11-11",items:["A refreshed logo: the trail’s destination is larger, and there are light and dark versions that follow your theme"]},{version:"0.26.0",date:"2026-11-11",items:["The Lookout asks you to sign in: open the link `teamtrail` prints, and pair your phone with a QR code (again after each restart)","Your answers count only when you give them in the Lookout or Slack, and skipping discovery or changing a trail’s mode or destination waits for your Approve","Check commands, briefs, criteria and other trusted settings run only once you approve them on this machine, in Settings → Approvals","Changes made to trail files outside Teamtrail have no effect until you accept them"]},{version:"0.25.0",date:"2026-11-10",items:["Agents on other machines or in cloud sandboxes can join your trails: `teamtrail mcp --http` serves the same tools over HTTP","One token per remote agent, created and revoked in Settings → Remote agents; without a token nothing is reachable","`teamtrail connect claude|codex --url` points an agent at a remote Teamtrail"]},{version:"0.24.2",date:"2026-11-10",items:["A ticket’s description no longer repeats which trail it is part of"]},{version:"0.24.1",date:"2026-11-10",items:["Buttons in the same row are always the same size"]},{version:"0.24.0",date:"2026-11-10",items:["Focus in the header: see at a glance whether it is on, and start or end it in one click","Sign in with GitHub, and pick your repo or Linear team from a searchable list","Write your own guides with `teamtrail guides new`, approve them in Settings and share them with the catalog","Settings is its own page, and the trail map has a cleaner, flatter look","Smaller polish: one colour for work in progress everywhere, a calmer first run and clearer Slack setup"]},{version:"0.23.0",date:"2026-11-08",items:["Match work to models: switch it on for a trail in Settings and each agent gets the tickets that fit the model it runs on, research on fast models and junctions on the strongest. You set the tier per ticket type; Teamtrail never switches a model, and a ticket no connected agent is strong enough for waits in your queue","Guides: a ticket can ask for a reviewer, QA, security, docs or architect, and the agent that claims it gets that guide’s instructions and a checklist it must answer before the work counts as done. Pick a trail’s team and each ticket’s guide in the Lookout, and add more guides from a moderated catalog in Settings → Guides. A guide can add checks but never remove one, its commands only run after you approve them, and a guide file edited after you approved it is switched off until you look at it again","Records has a new Trail stats view: delivery across every trail, by vendor, agent and ticket type, with plain observations from your own numbers. Teamtrail doesn't route work from them","MILOOPS is now Teamtrail. Missions are trails, the command center is the Lookout, MILO is Scout, and `/milo` is `/scout`","More room for the map: the summary of counts now slides up from a tab when you want it","A new day and night look, starting in night, with an Appearance setting to switch to day or follow your system","The map is now a landscape: tickets are trail signs, the trail shows what is walked and what is ahead, and an X marks the destination","A new greeting when you start `teamtrail` in a terminal","A new logo, a t whose stem runs along a trail to a node, and a new look for Scout: the original CRT head with ear cups and a baseball cap, with a lamp on the cap at night. No more pixel art, and new fonts too","All projects: every repo you supervise in one view, with one list of what needs you across them and what changed while you were away. Answer an agent's question in any repo from there, and switch projects from the header. Agents add their repo when they connect (`--no-register` opts out), or add one with `teamtrail projects add`"]},{version:"0.22.0",date:"2026-11-05",items:["A calmer, clearer command center: every list now reads the same way, what it is first, then one quiet line of context, and details when you want them","Red now only means something needs you now; other states show as a thin edge instead of colored text everywhere","The open question in a conversation can no longer be hidden by its suggested answers, and the phone header no longer runs off the side"]},{version:"0.21.0",date:"2026-11-05",items:["New plans can now edit a ticket, remove a dependency and reopen finished work, instead of working around it","Slack digests follow the team's digest setting (digestMinutes in attention.json); 0 turns them off, and everything still waits in Waiting on you","Remove a finished task's workspace from Settings → Workspaces or the ticket; the branch stays, and MILOOPS asks before discarding uncommitted changes"]},{version:"0.20.0",date:"2026-11-04",items:["Separate workspaces: switch on Settings → Workspaces and each ticket an agent claims gets its own copy of the repo on its own branch, so agents working at the same time don’t step on each other. When the work is done you get the branch to review; MILOOPS never merges or pushes for you","Warnings before a clash: agents say which files they expect to change. When two of them plan to change the same files, the second one is warned, and you see it in Waiting on you; open it to release either claim","When two agents’ branches did change the same files, Waiting on you suggests a ticket to bring the work together. One click adds it, waiting on both tickets, with the files listed","The ticket inspector shows which files an agent expects to change and the branch it works on","Fix: an execute ticket marked as needing you keeps that mark when saved to local files, GitHub Issues or Linear"]},{version:"0.19.0",date:"2026-11-04",items:["Risk policy: you decide what always needs you, such as database changes, logins and permissions, billing, deleting data or new dependencies (Settings → Risk policy). Agents can no longer make those calls on their own; they ask you. Their other decisions are labelled by risk in the briefing, and work that touched risky files without asking comes to you to check","One ranked list of everything that needs you in Waiting on you: questions, approvals, blocked work, briefs, knowledge and new plans, most important first, each with the reason (for example “blocks 3 tickets” or “claude-02 is waiting”). Related items are grouped so you answer them together; snooze what can wait","Fewer interruptions: agents say how urgent a question is, and only urgent items notify you (browser or Slack). Focus for an hour from the header, set quiet hours in Settings → Attention, and the rest waits in the list and the digest","Plans that adapt: missions list the assumptions they rely on, starting with the ones in the discovery brief. When an agent finds one is wrong, it shows the evidence and proposes a new plan; the tickets it would change are paused, the map previews the change, and nothing happens until you approve","Challenge the destination: an agent can tell you the work already exists, the mission targets the wrong problem, or it should be rescoped, with evidence and a suggested new goal","Assumptions on the Plan tab (confirm the ones you know are true) and an assumptions field when you create a mission","Fix: when an agent asks two questions at once, your answer goes to the one you opened; the inbox stats line no longer gets covered by the list"]},{version:"0.18.0",date:"2026-11-04",items:["Acceptance criteria: agents write down what done means before they start (required on missions with a discovery brief). When they finish, each point needs proof: one of your checks, a named test, the pull request, or your sign-off","Work whose criteria lack proof goes back with the reason; points only you can confirm come to your inbox to sign off","Business rules from your project knowledge are suggested as criteria, and the ticket shows any rule no criterion covers yet. Confirm a ticket’s criteria in the inspector","Cross-vendor review: when Claude and Codex agents both run, each reviews the other’s work first","Fix: answers from the command center could hang when too many live updates were open; all updates now share one connection"]},...hC];function pC(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(va,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:te.category}),i.jsx("p",{className:"onb-tagline",children:te.tagline}),i.jsx(V,{parts:[te.assistant.name]})]}),i.jsx(Ie,{title:"Next",children:fC.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})]},e.area))}),mC.map(e=>i.jsx(Ie,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}function Kg(){const[e,t]=y.useState();return y.useEffect(()=>{fetch(`${je()}/machine`).then(s=>s.ok?s.json():void 0).then(s=>t(s==null?void 0:s.local),()=>t(void 0))},[]),e}const Lm={checks:"Completions run these commands on this machine",catalogs:"Guides can then be searched for and added from these addresses",policy:"Agents may then decide these alone",brief:"Implementation tickets of the trail open up",criteria:"These criteria define done for the ticket",knowledge:"Agents get it as trusted context with their claims",level:"Completions on it are checked this much",type:"The trail's level applies to a ticket by its type",state:"Accepting signs it as yours on this machine: gates then read the file as it is",discovery:"Agents may claim its implementation tickets without a discovery brief, and criteria are no longer required"},Om={checks:"Approval covers these commands, not what they run: npm run check runs package.json scripts, and an agent can edit those.",catalogs:"Approval covers where guides come from, not the guides: each one is still shown whole and approved on its own."};function Vg(e){return e.kind==="state"?gC(e):e.committed===!1?"Not committed, so shown whole":e.standing==="elsewhere"?"Came with the repo, never approved on this machine":"Changed since you approved it here"}function gC(e){const t="Changed by a teammate or an agent outside Teamtrail";return e.standing==="elsewhere"?`${t}, or came with the repo · never signed on this machine`:e.committed===!1?`${t} · not committed`:t}const vC="Until you decide, Teamtrail uses the values it signed: a changed ticket is held for you, and a decision nobody signed here does not count. Accept signs the change as yours on this machine; Revert writes the signed values back into the file.";function kC(e){return`${e} committed ${e===1?"thing":"things"} in this repo say they were approved, or record a trail's state, but nothing on this machine signed them: a fresh clone, a teammate's push, or an upgrade from before they were kept per machine. Look them over, then approve them in one step. After that, only what Teamtrail writes here, and what you approve one at a time, counts.`}const yC=["Kept in your config folder, never in the repo","A repo moved to another folder is asked again","This stops an agent that can only write files in the repo, and a teammate's push. An agent that can read your home folder can read the key, and any local agent can answer questions with answer_question","An agent whose sandbox can write your config folder can approve for itself (teamtrail approve --hash, or approvals.json); where the sandbox blocks that folder, Teamtrail fails closed","A trail's state (ticket types, states, claims, blockers, levels, the trail's mode, decisions, assumptions) counts only as Teamtrail wrote it here, so a teammate's push shows as changed outside Teamtrail until you accept it on this machine. An agent that can write your config folder can forge that record too"];function wC(e){const{queue:t}=e;return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:`${t.writes} tracker writes queued before the upgrade`,context:i.jsx(V,{parts:[`For ${t.targets.join(", ")}`]}),below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.labels.join(`
|
|
146
|
-
`)}),i.jsx("p",{className:"ap-note t-meta",children:"An older version kept this queue in the repo, where anyone who could write it could add to it. Send them only if you recognise them; nothing is sent until you do."}),e.local&&i.jsxs("div",{className:"ap-actions",children:[i.jsx(P,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:"Send them"}),i.jsx(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:"Discard"})]})]})})}function
|
|
147
|
-
`)}),e.local&&!s&&i.jsxs("div",{className:"ap-below ap-actions",children:[i.jsx(P,{size:"sm",disabled:e.busy,onClick:e.onAccept,children:"Accept this change"}),c!=="none"&&i.jsx(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>c==="delete"?o(!0):e.onRevert(),children:c==="delete"?"Delete…":"Revert"})]}),e.local&&s&&i.jsx(
|
|
145
|
+
${e.apiKey??""}`,load:()=>zt.linearProjects(e.teamId,e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function Ub(e){const{value:t,retry:s}=Ru({enabled:e.enabled,key:e.apiKey??"",load:()=>zt.linearTeams(e.apiKey),failed:o=>({kind:"error",error:o})});return{list:t,retry:s}}function Wb(e){const t=Bb(e.apiKey.trim(),400),s=e.paste&&t?t:void 0,o=e.paste?!!t:!!e.ln.auth,a=Ub({enabled:o,apiKey:s}),c=Fb({teamId:e.teamId,apiKey:s,enabled:o}),d=a.list,h=c.list,m=(d==null?void 0:d.kind)==="ok"?d.teams:[],p=o&&!d,v=o&&!!e.teamId&&!h;return{enabled:o,list:d,teams:m,projects:h,loading:p||v,retryTeams:a.retry,retryProjects:c.retry}}function Fg(e){var oe;const t=e.s.linear,s=Eb(t),[o,a]=y.useState(!s),[c,d]=y.useState(""),[h,m]=y.useState(t.teamId??""),[p,v]=y.useState(t.projectId??""),[k,x]=y.useState(),[S,C]=y.useState(!1),{enabled:j,list:I,teams:b,projects:R,loading:O,retryTeams:U,retryProjects:X}=Wb({ln:t,paste:o,apiKey:c,teamId:h});y.useEffect(()=>{s&&!c&&a(!1)},[s]),y.useEffect(()=>{(I==null?void 0:I.kind)==="ok"&&m(Ob(I.teams,t.teamId)??"")},[I]);const Q=b.find(D=>D.id===h),W=(R==null?void 0:R.kind)==="ok"?R.projects.find(D=>D.id===p):void 0,ie=(I==null?void 0:I.kind)==="ok"?I.viewer:t.viewer,G=o?null:t.auth,ve=Bg({viewer:ie,team:Q==null?void 0:Q.name,project:W==null?void 0:W.name,source:G}),Pe=async()=>{if(Q){C(!0),x(void 0);try{await zt.connect({active:"linear",linear:{teamId:Q.id,teamKey:Q.key,teamName:Q.name,projectId:W==null?void 0:W.id,projectName:W==null?void 0:W.name,apiKey:o?c.trim():void 0}}),e.onConnected()}catch(D){x({ok:!1,error:D.message}),C(!1)}}},$e=D=>{m(D),v("")};return i.jsxs("div",{className:"card inset tracker-setup linear-setup",children:[o&&i.jsx(Mb,{ln:t,apiKey:c,onKey:d}),i.jsx($b,{line:ve,email:(oe=ya(ie))==null?void 0:oe.email,onUseAnother:o?void 0:()=>a(!0)}),j&&i.jsx(zb,{list:I,value:h,onChange:$e,onRetry:U}),Q&&i.jsx(Rb,{list:R,value:p,onChange:v,onRetry:X}),i.jsx(_g,{r:k}),i.jsx("footer",{children:i.jsx("button",{type:"button",className:"btn primary",disabled:S||O||!Q,onClick:()=>void Pe(),children:S?"Connecting…":"Connect"})})]})}function Hb(e){return i.jsxs("div",{className:"c-actions",children:[e.canSwitch&&i.jsx("button",{className:"btn sm",disabled:!e.usable,onClick:e.onSwitch,children:"Switch"}),e.remote&&i.jsx("button",{className:`btn sm ${e.open?"on":""}`,disabled:!e.usable,onClick:e.onToggle,children:e.configured?"Edit":"Connect"})]})}function Kb(e){return["Anything this account writes counts as you, including agents signed in as you",`${e==="github"?"people with write access":"members (not guests)"} can claim, move and close tickets; their decisions show under their name`,"settings they change wait for you in the queue, to accept or keep stricter"]}function Vb(e){const{id:t,active:s,s:o}=e,a=Zi(t),c=s&&o?Gb(t,o):void 0;return c&&a?i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"c-who",parts:[c]}),i.jsx(V,{className:"c-trust",parts:Kb(t)})]}):c?i.jsx(V,{className:"c-who",parts:[c]}):s&&(t==="markdown"||a)?i.jsx("div",{className:"c-loc",children:e.location}):a&&e.configured&&o?i.jsx("div",{className:"c-loc",children:qb(t,o)}):null}function Gb(e,t){if(e==="github")return hb(t.github);if(e==="linear")return Ab(t.linear)}function qb(e,t){return e==="github"?t.github.repo:[t.linear.teamKey,t.linear.projectName].filter(Boolean).join(" · ")}function Qb({status:e}){var c,d;if(!e)return null;const t=(c=e.rate)!=null&&c.limit?`${((d=e.rate.remaining)==null?void 0:d.toLocaleString())??"?"}/${e.rate.limit.toLocaleString()} req`:"",s=e.queued?` · ${e.queued} queued`:"",[o,a]=Yb(e,s);return i.jsxs("div",{className:`sync-line ${o}`,title:e.error,children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:a}),t&&i.jsx("span",{className:"rate",children:t})]})}function Yb(e,t){switch(e.state){case"online":return["ok",`Online · synced ${dg(e.lastSyncAt)}${t}`];case"offline":return["warn",`Offline${t}`];case"rate-limited":return["warn",`Rate limited · resumes ${cr(e.resetAt)}${t}`];case"auth-error":return["alert",`Credentials rejected${t}`];default:return["",`Connecting${t}`]}}function Jb(e){const{id:t,active:s,configured:o,s:a}=e,c=Zi(t),d=!c||!!a,h=["card connector",s?"active":"",d?"":"disabled",e.open?"open":""];return i.jsxs("div",{className:h.join(" "),children:[i.jsxs("div",{className:"card-row",children:[i.jsx("b",{className:"choice-title t-row-title",children:e.name}),s&&i.jsx("span",{className:"pill on",children:"Active"})]}),i.jsx(Vb,{id:t,active:s,configured:o,location:e.location,s:a}),c&&s&&i.jsx(Qb,{status:a==null?void 0:a[t].status}),i.jsx(Hb,{canSwitch:!s&&(!c||o),remote:c,usable:d,configured:o,open:e.open,onSwitch:e.onSwitch,onToggle:e.onToggle})]})}function Ug(e=0){const[t,s]=y.useState(),o=y.useCallback(()=>zt.get().then(a=>(s(a),a),()=>(s(null),void 0)),[]);return y.useEffect(()=>{if(o(),!e)return;const a=setInterval(()=>void o(),e);return()=>clearInterval(a)},[o,e]),[t,s,o]}function Xb(e){const[t,,s]=Ug(5e3),[o,a]=y.useState(null),c=async h=>{t&&(h==="markdown"||Zi(h))&&await zt.connect({active:h==="markdown"?"markdown":h,...h==="github"&&t.github.repo?{github:{repo:t.github.repo}}:{},...h==="linear"&&t.linear.teamId?{linear:{teamId:t.linear.teamId,teamKey:t.linear.teamKey,teamName:t.linear.teamName,projectId:t.linear.projectId,projectName:t.linear.projectName}}:{}}).catch(()=>{}),er(e.update,h)},d=y.useMemo(()=>({github:!!(t!=null&&t.github.repo),linear:!!(t!=null&&t.linear.teamId)}),[t]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"connectors",children:Kj.map(h=>{const m=h.id;return i.jsx(Jb,{id:m,name:h.name,active:m===e.activeTracker,configured:Zi(m)&&d[m],open:o===m,location:e.location,s:t,onSwitch:()=>void c(m),onToggle:()=>Zi(m)&&a(o===m?null:m)},h.id)})}),t&&o==="github"&&i.jsx(Dg,{s:t,reload:s,onConnected:()=>er(e.update,"github")}),t&&o==="linear"&&i.jsx(Fg,{s:t,onConnected:()=>er(e.update,"linear")})]})}function Zb(e,t){const s=e==null?void 0:e.github,o=e==null?void 0:e.linear,a=s&&t!=="github"?Og(s,s.repo??s.detectedRepo):void 0,c=o&&t!=="linear"?Bg({viewer:o.viewer,team:o.teamName,project:o.projectName,source:o.auth}):void 0;return[{id:"markdown",title:"Local markdown",sub:"Files in .teamtrail/ in this repo"},{id:"github",title:"GitHub Issues",sub:a??"Trails as labelled issues in your repo"},{id:"linear",title:"Linear",sub:c??"Trails and tickets in your Linear team"}]}function Ie(e){return i.jsxs("section",{className:"set-sec",children:[i.jsx(Ve,{as:"h4",children:e.title}),e.children]})}function Wg(e){const t=[{v:"summary",title:"Summary"},{v:"full",title:"Full transcript"}];return i.jsx("div",{className:"choice-row",children:t.map(s=>i.jsx(mt,{on:e.value===s.v,title:s.title,onClick:()=>e.onChange(s.v)},s.v))})}const eC={github:"Checking for a GitHub login…",linear:"Checking for a Linear key…"};function tC(e){var I;const{prefs:t,update:s}=e,[o,,a]=Ug(5e3),[c,d]=y.useState(!1),h=(I=o==null?void 0:o.pending)==null?void 0:I.target.split(":")[0],[m,p]=y.useState(!1);y.useEffect(()=>{h&&!m&&t.tracker!==h&&s({tracker:h})},[h,m,t.tracker,s]);const v=Zb(o??void 0,t.tracker),k=t.tracker==="github"||t.tracker==="linear",x=k&&(o==null?void 0:o.active)===t.tracker,S=k&&!x,C=b=>{s({onboarded:!0}),er(s,b)},j=async()=>{d(!0);const b=o&&!o.pending;t.tracker==="markdown"&&b&&await zt.connect({active:"markdown"}).catch(()=>{}),s({onboarded:!0}),t.tracker!==e.activeTracker&&er(s,t.tracker)};return i.jsx("div",{className:"scrim",children:i.jsxs(ze,{as:"div",className:"dialog onboarding",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(va,{className:"onb-title"})}),i.jsxs("h2",{className:"onb-question t-heading",children:[i.jsx(rN,{className:"voice-badge",size:22}),"Where should your trails live?"]}),i.jsxs(Ie,{title:"Tracker",children:[i.jsx("div",{className:"choice-row",children:v.map(b=>i.jsx(mt,{on:t.tracker===b.id,title:b.title,sub:b.sub,onClick:()=>(p(!0),s({tracker:b.id}))},b.id))}),(o==null?void 0:o.pending)&&i.jsxs("p",{className:"t-meta onb-repo-tracker",children:["This repo keeps its trails in ",o.pending.label,". Connect it here, or keep local files on this machine; the team's choice in the repo isn't changed either way."]}),o===void 0&&k&&i.jsx(si,{label:eC[t.tracker]??"Checking…"}),o&&t.tracker==="github"&&!x&&i.jsx(Dg,{s:o,reload:a,onConnected:()=>C("github")}),o&&t.tracker==="linear"&&!x&&i.jsx(Fg,{s:o,onConnected:()=>C("linear")})]}),i.jsx(Ie,{title:"HITL transcript",children:i.jsx(Wg,{value:t.hitlTranscript,onChange:b=>s({hitlTranscript:b})})}),i.jsx("footer",{children:i.jsx(P,{variant:"primary",disabled:c||S,onClick:()=>void j(),children:"Get started"})})]})})}const rr=[{id:"trail",label:"This trail",intro:"How agents work on the trail on screen: its mode, the checks that prove work done, models and guides.",sections:[{id:"mode",title:"Trail mode"},{id:"verification",title:"Verification"},{id:"models",title:"Model matching"},{id:"team",title:"Team"}]},{id:"project",label:"Project",intro:"Where this repo keeps its trails, and the rules every agent working in it follows.",sections:[{id:"approvals",title:"Approvals"},{id:"tracker",title:"Tracker"},{id:"workspaces",title:"Workspaces"},{id:"remote-agents",title:"Remote agents"},{id:"policy",title:"Risk policy"},{id:"guides",title:"Guides"},{id:"labels",title:"Labels"}]},{id:"alerts",label:"Attention & alerts",intro:"What interrupts you, where questions reach you, and what Scout tells you when you come back.",sections:[{id:"attention",title:"Attention"},{id:"slack",title:"Slack"},{id:"trip-report",title:"Trip report"}]},{id:"you",label:"You",intro:"How the Lookout looks and reads for you, and the browsers and devices signed in to it.",sections:[{id:"appearance",title:"Appearance"},{id:"transcript",title:"HITL transcript"},{id:"agent",title:"Agent"},{id:"devices",title:"Browsers & devices"}]},{id:"projects",label:"All projects",intro:"Every repo this Lookout knows, so you can switch between them from the header.",sections:[{id:"projects",title:"Projects"}]},{id:"about",label:"About",intro:"What Teamtrail is, and what changed in each release.",sections:[{id:"changelog",title:"Changelog"}]}];function Hg(e){if(e===null)return null;const t=rr.find(a=>a.id===e);if(t)return{group:t.id};const s=rr.find(a=>a.sections.some(c=>c.id===e));if(!s)return{};const o=s.sections.find(a=>a.id===e);return{group:s.id,section:o==null?void 0:o.id}}function nC(){return i.jsxs("p",{className:"sp-elsewhere t-meta",role:"note",children:["You're looking at this Lookout from another device. You can read, answer and approve from here. What changes what runs on the machine ",te.name," runs on, or whom it trusts, is set there: the approvals of what the repo asks it to trust, the tracker connection, Slack, the risk policy, verification levels, workspaces, guides, remote agents, your attention settings and the projects list. Paths on that machine and its tracker account are not shown here."]})}const Rm={from:"18:00",to:"09:00"};function sC(e){const t=e.focus!==void 0,s=e.focus??Rm;return i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Quiet hours"}),i.jsx(P,{size:"sm",on:t,"aria-pressed":t,onClick:()=>e.onChange(t?void 0:Rm),children:t?"On":"Off"}),t&&i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"time","aria-label":"Quiet from",value:s.from,onChange:o=>o.target.value&&e.onChange({...s,from:o.target.value})}),i.jsx("span",{className:"t-meta",children:"to"}),i.jsx("input",{type:"time","aria-label":"Quiet until",value:s.to,onChange:o=>o.target.value&&e.onChange({...s,to:o.target.value})})]})]})}const iC=[{value:"browser",label:"Browser notification"},{value:"slack-dm",label:"Slack DM"},{value:"slack-channel",label:"Slack channel"},{value:"none",label:"Nothing, I check the queue"}];function rC(){typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function oC(){const{view:e,error:t,savePrefs:s}=Rg(0);if(!e)return null;const o=e.policy.value,a=`${te.dataDir}/attention.json`,c=h=>void s({...e.prefs,...h}),d=typeof Notification<"u"&&Notification.permission==="denied";return i.jsxs(Ie,{title:"Attention",children:[i.jsxs("p",{className:"vf-intro",children:["Everything that needs you is ranked in Waiting on you. Only items scoring ",o.interrupt," or more interrupt you; the rest wait in the queue, and Slack gets them in a digest."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Interrupt me by"}),i.jsx(dt,{compact:!0,"aria-label":"Interrupt me by",value:e.prefs.channel,options:iC,onChange:h=>{h==="browser"&&rC(),c({channel:h})}})]}),e.prefs.channel==="browser"&&d&&i.jsx("span",{className:"vf-err",children:"The browser blocks notifications for this page. Allow them in its site settings."}),i.jsx(sC,{focus:e.prefs.focus,onChange:h=>c({focus:h})}),i.jsx("span",{className:"set-hint t-meta",children:"Your channel and quiet hours stay on this machine."}),e.policy.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.policy.errors.map(h=>i.jsxs("li",{children:[a,": ",h]},h))}),i.jsx(V,{className:"set-hint",parts:[e.policy.exists?{text:a,code:!0}:"Team defaults",`interrupt at ${o.interrupt}`,o.digestMinutes?`Slack digest every ${o.digestMinutes} min`:"Slack digest off"]}),t&&i.jsx("span",{className:"vf-err",children:t})]})}const aC=[5,15,30,60];function lC(e){const{value:t}=e;return i.jsxs("div",{className:"choice-row compact",children:[i.jsx(mt,{on:!t.enabled,title:"Off",onClick:()=>e.onChange({...t,enabled:!1})}),aC.map(s=>i.jsx(mt,{on:t.enabled&&t.awayMinutes===s,title:`Away ${s} min`,onClick:()=>e.onChange({enabled:!0,awayMinutes:s})},s))]})}const cC={repo:"Committed to the repo",machine:"Only on this machine",browser:"Only in this browser"};function Qe(e){const t=e.storage&&cC[e.storage];return i.jsxs("div",{className:"sp-slot",id:`settings-${e.id}`,children:[e.children,t&&i.jsx(V,{className:"sp-where",parts:[t]})]})}function uC(e){const[t]=Au();return t?i.jsx(Ie,{title:"Slack",children:i.jsx(s1,{focus:e.focus})}):null}function dC({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"attention",storage:"repo",children:i.jsx(oC,{})}),i.jsx(Qe,{id:"slack",storage:"machine",children:i.jsx(uC,{focus:t.section==="slack"})}),i.jsx(Qe,{id:"trip-report",storage:"browser",children:i.jsx(Ie,{title:"Trip report",children:i.jsx(lC,{value:e.prefs.briefing,onChange:s=>e.update({briefing:s})})})})]})}const hC=[{version:"0.6.0",date:"2026-10-31",items:["Named MILOOPS; MILO speaks for the platform in the activity log and onboarding","Tracker sync status, last-write latency and event pulse","Inbox: oldest question age and average wait","Critical path, decided per hour with burndown, type mix","Per-session tokens and cost, mission totals, claims per agent"]},{version:"0.5.0",date:"2026-10-31",items:["Status counters and resolution bar on the map","Current step tracker with step pipeline","Sessions with live timers","Activity log with time and source columns","Out-of-scope quarantine zone on the map"]},{version:"0.4.0",date:"2026-10-31",items:["Missions: switcher with progress and waiting count, New mission in the switcher","Inbox collects questions from every mission","Elapsed time and progress per mission","Responsive layout with progressive disclosure (wide, laptop, phone)","Map graph pans and zooms by drag, pinch and wheel","Changelog"]},{version:"0.3.0",date:"2026-10-31",items:["Fixed-zone layout","Plan + execute and plan-only mission modes","Execute tickets"]},{version:"0.2.0",date:"2026-10-31",items:["Local markdown tracker (default)","Onboarding","HITL transcript: summary or full","Settings with tracker connectors"]},{version:"0.1.0",date:"2026-10-31",items:["Live map graph","HITL vs AFK tickets","In-window HITL conversations","Demo tracker with simulated sessions"]}],fC=[{version:"0.18.0",date:"2026-11-04",items:["Acceptance criteria: agents write down what done means before they start (required on missions with a discovery brief). When they finish, each point needs proof: one of your checks, a named test, the pull request, or your sign-off","Work whose criteria lack proof goes back with the reason; points only you can confirm come to your inbox to sign off","Business rules from your project knowledge are suggested as criteria, and the ticket shows any rule no criterion covers yet. Confirm a ticket’s criteria in the inspector","Cross-vendor review: when Claude and Codex agents both run, each reviews the other’s work first","Fix: answers from the command center could hang when too many live updates were open; all updates now share one connection"]},{version:"0.17.0",date:"2026-11-03",items:["Discovery brief: new missions start with an agent mapping the existing system (files, conventions, data and API impact, risks, assumptions, product context). Implementation tickets wait until you accept the brief or ask for changes, from the banner over the map or the card in Communication","Create mission: start a mission from the New mission dialog without a terminal; any agent picks it up with /milo resume","Knowledge: what agents need to know about your codebase and product (architecture, conventions, gotchas, dead ends, business rules, personas, UX principles, pricing). Agents propose, you confirm, keep as an assumption or retire. Confirmed entries reach agents with every claim, picked for the ticket with the reason, and the inspector shows what an agent gets","Knowledge about specific files is flagged for re-confirmation when those files change","Save decisions, cancelled tickets (as dead ends) and brief sections as knowledge in one click; seed it from a document with miloops knowledge import <file.md>"]},{version:"0.16.0",date:"2026-11-03",items:["Mission report (Mission plan → Report): tickets done, mission and median ticket lead time, your interventions, rework, review results and cost per verified ticket. Hover any number to see how it is computed; export it as markdown","Agents report the same numbers in one line from the status tool","Agents use missions for big work only, and decide routine calls themselves, keeping each one as a decision record you can review or reverse; they ask you when the call changes product behaviour, data, security, billing, a public API or the schema","Decisions: filter by who made the call, agents on their own or people. The briefing now counts only the calls agents made themselves, not your answers they recorded"]},{version:"0.15.0",date:"2026-10-31",items:["Verification in the ticket inspector: the level that applies and where it comes from, every attempt newest first with the git evidence (base → head, files changed, flags), its checks, exit codes, durations and the failing output, and the full log on demand","Verifying, Rework and Blocked on the map, in the legend and as status counters on missions that verify completions","Operator calls on a verifying or blocked ticket: Approve, Re-run checks, Send to rework with a note, Accept anyway and Unblock. Overrides need a reason, and each call is kept as a verdict next to the attempts and in the mission history. Approve asks for a re-run when the code changed since the checks passed","Set the verification level of a mission (Settings → Verification) or of one ticket (inspector). Only you can change it; agents cannot","The inspector updates live while checks run","Independent review: at Checks + review, a passing completion gets a review ticket that another agent takes and answers with PASS, FAIL (with findings) or NEEDS_HUMAN. The agent that did the work is never given its own review","Waiting on you lists reviewed work to approve (Checks + review + you) and held tickets, and Slack posts them with Approve and Rework… buttons","Agents can name their pull request in `report_completion` (`pr`); PR and CI tracking then follows that PR first"]},{version:"0.14.0",date:"2026-10-31",items:["Ticket lifecycle in plain words: Ready, Backlog, Working, Done and Cancelled (with Verifying, Rework and Blocked to come with verification)","Every claim, release, return to queue, resolution and rule-out goes through one lifecycle engine that records who, why and when in `.miloops/.events/<mission>.jsonl` (local history, never committed)","Settings → Verification shows the checks in `.miloops/verification.json`: argv commands with timeouts, run without a shell, secrets kept out of their environment. Read-only","Completion is a claim: on missions started with `verification.json` present, an execute or task ticket is only done once its checks pass. A failed check sends it back for Rework with the failing output (agents see it in close_ticket, next_ticket and claim_ticket, and rework comes first in the queue); after 3 failed attempts, or when the checks cannot run, it waits on you as Blocked","New MCP tools `report_completion` and `verification_status`; missions started before verification, and research, grilling and prototype tickets, close exactly as before","Git evidence, no GitHub needed: each claim records HEAD and the uncommitted state, and each completion lists the files changed since then. It flags no changes, overlap with another active ticket, a branch switch or reset, and edits to `verification.json` (which send the ticket to you as Blocked). A pass on code that changed while its checks ran is re-run","Pull request and CI evidence: with `verification.json` and a GitHub token (Settings, `GITHUB_TOKEN` or `gh auth login`), the command center finds each ticket’s PR (its branch `miloops-<mission>-<ticket>`, a `miloops:<mission>#<ticket>` line in the PR body, or a link you set) and flags mismatches: done with the PR still open, PR merged while the ticket is in progress, PR closed unmerged, required checks failing or unknown, PR head not the verified commit. Flags never change a ticket. A CI chip in the header shows sync health and never shows synced after a failed sync"]},{version:"0.13.0",date:"2026-10-31",items:["Crash recovery for claims: an agent’s claim is a lease (15 min by default) that every tool call renews, including waits on your answer","When an agent crashes or goes silent, its ticket goes back to the queue on its own, and the activity log says so; the next agent picks it up from next_ticket or claim_ticket","The returned ticket keeps a handoff comment with the previous agent’s progress notes and decisions, so the next agent resumes instead of starting over","Stalled state on the map, in sessions and in the ticket inspector when a lease is about to run out, with a Release to queue action","Works with GitHub and Linear: the return is an ordinary comment + unassign, queued in the offline outbox like any other write","Set the lease with `miloops mcp --lease-minutes <n>` or `MILOOPS_LEASE_MINUTES`"]},{version:"0.12.0",date:"2026-10-31",items:["Slack: your own MILO app, created from a manifest and connected from your machine over Socket Mode in five guided steps (Settings → Slack or `miloops connect slack`)","Tokens stay in your local credential store next to the GitHub and Linear ones; nothing passes through MILOOPS servers","Agent questions arrive as a Slack DM with answer buttons and a Reply… box; answering there resolves the item in Waiting on you, and answering in the command center closes the DM","Save as decision on any message, or `/milo decide`: the form is prefilled with a summary of the thread, and the decision is recorded with a permalink, resolving the related ticket by default","`/milo status` and `/milo inbox` for the mission at a glance; DMs when a ticket is blocked or a mission is done","Allowed users, notification target and events in Settings → Slack","Slack setup without Paste clicks: press ⌘V / Ctrl+V anywhere, or in Chrome just come back to the tab after copying; pasting the app token opens the install page; MILO recognises you by your git email, so there is nothing to claim in Slack"]},{version:"0.11.0",date:"2026-10-31",items:["GitHub Issues tracker: missions are labelled issues, tickets are sub-issues, blocking uses native issue dependencies",'Linear tracker: missions are labelled issues in a team (optionally one project), tickets are sub-issues, blocking uses "blocks" relations',"Two-way sync: tickets, status, claims, comments, blockers and decisions written from MILOOPS land in the tracker; changes made there show up within seconds","Decisions are posted as comments on their ticket and listed in the mission","Connect from Settings with Test connection; GitHub reuses your gh login or GITHUB_TOKEN, Linear takes a personal API key","Tokens stay on your machine: kept by the local server, never sent to the browser or anywhere else","Offline and rate limits: changes queue and send in order when the tracker answers again; the connector shows status, queue and remaining requests","Connected agents (MCP) work on the active tracker: with GitHub or Linear connected, their missions, claims and decisions land there, and their sessions show live in the command center"]},{version:"0.10.0",date:"2026-10-31",items:["MCP server in the miloops package: `claude mcp add miloops -- npx -y miloops-cli mcp`, or the same for Codex","Connected agents start and resume missions, claim ready tickets, report steps, tokens and spend, close tickets and record decisions, live in the command center","Agent questions land in Waiting on you and the agent waits for your answer; answer in the command center or in the agent chat","/milo new, resume, status and inbox commands for Claude Code (and as a Codex prompt); `miloops connect claude|codex` sets them up","The command center follows a mission an agent just charted; sessions of agents that quit show as disconnected"]},{version:"0.9.0",date:"2026-10-31",items:["While you were away: MILO briefs you when you open the app or come back after being away: tickets done, now blocked, decisions waiting on you, agent decisions, spend and tokens since, active sessions","Briefing shows on return after 15 minutes hidden or idle; change the threshold or turn it off in Settings; reopen it from the header","Last seen per mission and usage over time are kept locally, so the briefing survives a reload","Mission title shows in full at laptop width; header readouts collapse to glyph and count","Prototype reviews link a real preview build and ask about the spike results"]},{version:"0.8.0",date:"2026-10-31",items:["Decisions: every decision across missions, newest first, with question, decision, alternatives, rationale, who decided and the full transcript","Filter decisions by mission, source, who decided and status; search; export to markdown","Supersede a decision; the chain stays visible on every record and in the mission","Decision records stored as markdown next to each mission and served by the local API with a live event stream","Resolve form: rationale and alternatives considered"]},{version:"0.7.0",date:"2026-10-31",items:["New type: Chakra Petch, Share Tech Mono and Barlow","Calmer palette; bright colour only for warnings and waiting on you","MILO mark, also used for status, action and alert glyphs","Dot-matrix signals for new decision requests and mission launches","Separate type voices for operators and agents","One-command install: npm i -g miloops-cli, then miloops in any repo","Packages renamed to @miloops-hq/core and @miloops-hq/command-center"]},...hC],mC=[{area:"Teamtrail Cloud",items:["Agents that run in the cloud, steered from the same Lookout"]}],pC=[{version:"0.29.3",date:"2026-11-12",items:["@Scout inbox and status in a channel now show up right away, seen only by you"]},{version:"0.29.2",date:"2026-11-12",items:["The Activity log reads in one style: a coloured bar marks what needs you (red), what went well (green) and what is held up (amber), and Slack answers show who gave them"]},{version:"0.29.1",date:"2026-11-12",items:["Scout says in Slack that it needs Teamtrail running on your computer, and how to start it, when it can’t reach yours","Ask Scout in your own words: “@Scout what’s in my inbox?” or “status of Slack live test” work, in a channel or a DM"]},{version:"0.29.0",date:"2026-11-12",items:["Ask Scout in Slack: @Scout inbox or @Scout status in a channel answers only you, or DM Scout; if you added Scout before, Settings asks you to reconnect once","A question your agent waits on gets its own Slack message with answer buttons, even right after it asked another one","Scout can be installed straight from Slack (scout.teamtrail.app/install-slack); each person then connects in Settings → Slack"]},{version:"0.28.0",date:"2026-11-12",items:["Scout is now one Slack app: Settings → Slack → Add Scout to Slack, no app to create and no tokens to paste","You confirm which Slack account becomes Scout’s owner before it connects; if you made your own Slack app before, add Scout again","High-risk calls are answered in the Lookout only, and so is approving an agent’s request to change your settings: Slack shows Open in Lookout, and Decline still works there"]},{version:"0.27.3",date:"2026-11-11",items:["On Linux, the Lookout sees every change an agent makes to a ticket again, not only the first: a claimed ticket no longer stays in the queue as waiting"]},{version:"0.27.2",date:"2026-11-11",items:["Settings, briefs, criteria, guides, reroutes and the other panels stay current through reconnects, and a GitHub or Linear map updates live again"]},{version:"0.27.1",date:"2026-11-11",items:["The map and the queue no longer miss a change made while the Lookout was loading or reconnecting"]},{version:"0.27.0",date:"2026-11-11",items:["Teamtrail opens your browser ready to sign in with one click; `teamtrail pair` does the same for another tab"]},{version:"0.26.2",date:"2026-11-11",items:["The Lookout shows the new teamtrail. wordmark"]},{version:"0.26.1",date:"2026-11-11",items:["A refreshed logo: the trail’s destination is larger, and there are light and dark versions that follow your theme"]},{version:"0.26.0",date:"2026-11-11",items:["The Lookout asks you to sign in: open the link `teamtrail` prints, and pair your phone with a QR code (again after each restart)","Your answers count only when you give them in the Lookout or Slack, and skipping discovery or changing a trail’s mode or destination waits for your Approve","Check commands, briefs, criteria and other trusted settings run only once you approve them on this machine, in Settings → Approvals","Changes made to trail files outside Teamtrail have no effect until you accept them"]},{version:"0.25.0",date:"2026-11-10",items:["Agents on other machines or in cloud sandboxes can join your trails: `teamtrail mcp --http` serves the same tools over HTTP","One token per remote agent, created and revoked in Settings → Remote agents; without a token nothing is reachable","`teamtrail connect claude|codex --url` points an agent at a remote Teamtrail"]},{version:"0.24.2",date:"2026-11-10",items:["A ticket’s description no longer repeats which trail it is part of"]},{version:"0.24.1",date:"2026-11-10",items:["Buttons in the same row are always the same size"]},{version:"0.24.0",date:"2026-11-10",items:["Focus in the header: see at a glance whether it is on, and start or end it in one click","Sign in with GitHub, and pick your repo or Linear team from a searchable list","Write your own guides with `teamtrail guides new`, approve them in Settings and share them with the catalog","Settings is its own page, and the trail map has a cleaner, flatter look","Smaller polish: one colour for work in progress everywhere, a calmer first run and clearer Slack setup"]},{version:"0.23.0",date:"2026-11-08",items:["Match work to models: switch it on for a trail in Settings and each agent gets the tickets that fit the model it runs on, research on fast models and junctions on the strongest. You set the tier per ticket type; Teamtrail never switches a model, and a ticket no connected agent is strong enough for waits in your queue","Guides: a ticket can ask for a reviewer, QA, security, docs or architect, and the agent that claims it gets that guide’s instructions and a checklist it must answer before the work counts as done. Pick a trail’s team and each ticket’s guide in the Lookout, and add more guides from a moderated catalog in Settings → Guides. A guide can add checks but never remove one, its commands only run after you approve them, and a guide file edited after you approved it is switched off until you look at it again","Records has a new Trail stats view: delivery across every trail, by vendor, agent and ticket type, with plain observations from your own numbers. Teamtrail doesn't route work from them","MILOOPS is now Teamtrail. Missions are trails, the command center is the Lookout, MILO is Scout, and `/milo` is `/scout`","More room for the map: the summary of counts now slides up from a tab when you want it","A new day and night look, starting in night, with an Appearance setting to switch to day or follow your system","The map is now a landscape: tickets are trail signs, the trail shows what is walked and what is ahead, and an X marks the destination","A new greeting when you start `teamtrail` in a terminal","A new logo, a t whose stem runs along a trail to a node, and a new look for Scout: the original CRT head with ear cups and a baseball cap, with a lamp on the cap at night. No more pixel art, and new fonts too","All projects: every repo you supervise in one view, with one list of what needs you across them and what changed while you were away. Answer an agent's question in any repo from there, and switch projects from the header. Agents add their repo when they connect (`--no-register` opts out), or add one with `teamtrail projects add`"]},{version:"0.22.0",date:"2026-11-05",items:["A calmer, clearer command center: every list now reads the same way, what it is first, then one quiet line of context, and details when you want them","Red now only means something needs you now; other states show as a thin edge instead of colored text everywhere","The open question in a conversation can no longer be hidden by its suggested answers, and the phone header no longer runs off the side"]},{version:"0.21.0",date:"2026-11-05",items:["New plans can now edit a ticket, remove a dependency and reopen finished work, instead of working around it","Slack digests follow the team's digest setting (digestMinutes in attention.json); 0 turns them off, and everything still waits in Waiting on you","Remove a finished task's workspace from Settings → Workspaces or the ticket; the branch stays, and MILOOPS asks before discarding uncommitted changes"]},{version:"0.20.0",date:"2026-11-04",items:["Separate workspaces: switch on Settings → Workspaces and each ticket an agent claims gets its own copy of the repo on its own branch, so agents working at the same time don’t step on each other. When the work is done you get the branch to review; MILOOPS never merges or pushes for you","Warnings before a clash: agents say which files they expect to change. When two of them plan to change the same files, the second one is warned, and you see it in Waiting on you; open it to release either claim","When two agents’ branches did change the same files, Waiting on you suggests a ticket to bring the work together. One click adds it, waiting on both tickets, with the files listed","The ticket inspector shows which files an agent expects to change and the branch it works on","Fix: an execute ticket marked as needing you keeps that mark when saved to local files, GitHub Issues or Linear"]},{version:"0.19.0",date:"2026-11-04",items:["Risk policy: you decide what always needs you, such as database changes, logins and permissions, billing, deleting data or new dependencies (Settings → Risk policy). Agents can no longer make those calls on their own; they ask you. Their other decisions are labelled by risk in the briefing, and work that touched risky files without asking comes to you to check","One ranked list of everything that needs you in Waiting on you: questions, approvals, blocked work, briefs, knowledge and new plans, most important first, each with the reason (for example “blocks 3 tickets” or “claude-02 is waiting”). Related items are grouped so you answer them together; snooze what can wait","Fewer interruptions: agents say how urgent a question is, and only urgent items notify you (browser or Slack). Focus for an hour from the header, set quiet hours in Settings → Attention, and the rest waits in the list and the digest","Plans that adapt: missions list the assumptions they rely on, starting with the ones in the discovery brief. When an agent finds one is wrong, it shows the evidence and proposes a new plan; the tickets it would change are paused, the map previews the change, and nothing happens until you approve","Challenge the destination: an agent can tell you the work already exists, the mission targets the wrong problem, or it should be rescoped, with evidence and a suggested new goal","Assumptions on the Plan tab (confirm the ones you know are true) and an assumptions field when you create a mission","Fix: when an agent asks two questions at once, your answer goes to the one you opened; the inbox stats line no longer gets covered by the list"]},...fC];function gC(){return i.jsxs("div",{className:"changelog",children:[i.jsxs("div",{className:"about",children:[i.jsx(va,{className:"about-name"}),i.jsx("span",{className:"mono-label",children:te.category}),i.jsx("p",{className:"onb-tagline",children:te.tagline}),i.jsx(V,{parts:[te.assistant.name]})]}),i.jsx(Ie,{title:"Next",children:mC.map(e=>i.jsxs("div",{className:"cl-row",children:[i.jsx("span",{className:"mono-label",children:e.area}),i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})]},e.area))}),pC.map(e=>i.jsx(Ie,{title:`${e.version} · ${e.date}`,children:i.jsx("ul",{children:e.items.map(t=>i.jsx("li",{children:t},t))})},e.version))]})}function Kg(){const[e,t]=y.useState();return y.useEffect(()=>{fetch(`${je()}/machine`).then(s=>s.ok?s.json():void 0).then(s=>t(s==null?void 0:s.local),()=>t(void 0))},[]),e}const Lm={checks:"Completions run these commands on this machine",catalogs:"Guides can then be searched for and added from these addresses",policy:"Agents may then decide these alone",brief:"Implementation tickets of the trail open up",criteria:"These criteria define done for the ticket",knowledge:"Agents get it as trusted context with their claims",level:"Completions on it are checked this much",type:"The trail's level applies to a ticket by its type",state:"Accepting signs it as yours on this machine: gates then read the file as it is",discovery:"Agents may claim its implementation tickets without a discovery brief, and criteria are no longer required"},Om={checks:"Approval covers these commands, not what they run: npm run check runs package.json scripts, and an agent can edit those.",catalogs:"Approval covers where guides come from, not the guides: each one is still shown whole and approved on its own."};function Vg(e){return e.kind==="state"?vC(e):e.committed===!1?"Not committed, so shown whole":e.standing==="elsewhere"?"Came with the repo, never approved on this machine":"Changed since you approved it here"}function vC(e){const t="Changed by a teammate or an agent outside Teamtrail";return e.standing==="elsewhere"?`${t}, or came with the repo · never signed on this machine`:e.committed===!1?`${t} · not committed`:t}const kC="Until you decide, Teamtrail uses the values it signed: a changed ticket is held for you, and a decision nobody signed here does not count. Accept signs the change as yours on this machine; Revert writes the signed values back into the file.";function yC(e){return`${e} committed ${e===1?"thing":"things"} in this repo say they were approved, or record a trail's state, but nothing on this machine signed them: a fresh clone, a teammate's push, or an upgrade from before they were kept per machine. Look them over, then approve them in one step. After that, only what Teamtrail writes here, and what you approve one at a time, counts.`}const wC=["Kept in your config folder, never in the repo","A repo moved to another folder is asked again","This stops an agent that can only write files in the repo, and a teammate's push. An agent that can read your home folder can read the key, and any local agent can answer questions with answer_question","An agent whose sandbox can write your config folder can approve for itself (teamtrail approve --hash, or approvals.json); where the sandbox blocks that folder, Teamtrail fails closed","A trail's state (ticket types, states, claims, blockers, levels, the trail's mode, decisions, assumptions) counts only as Teamtrail wrote it here, so a teammate's push shows as changed outside Teamtrail until you accept it on this machine. An agent that can write your config folder can forge that record too"];function xC(e){const{queue:t}=e;return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:`${t.writes} tracker writes queued before the upgrade`,context:i.jsx(V,{parts:[`For ${t.targets.join(", ")}`]}),below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.labels.join(`
|
|
146
|
+
`)}),i.jsx("p",{className:"ap-note t-meta",children:"An older version kept this queue in the repo, where anyone who could write it could add to it. Send them only if you recognise them; nothing is sent until you do."}),e.local&&i.jsxs("div",{className:"ap-actions",children:[i.jsx(P,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:"Send them"}),i.jsx(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:"Discard"})]})]})})}function jC(e){return i.jsxs("div",{className:"ap-below",children:[i.jsxs("p",{className:"t-meta",children:["Delete ",e.files.join(", "),"? Nobody signed them on this machine; git still has them."]}),i.jsxs("div",{className:"ap-actions",children:[i.jsxs(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onDelete,children:["Delete ",e.files.length===1?"it":`all ${e.files.length}`]}),i.jsx(P,{size:"sm",disabled:e.busy,onClick:e.onCancel,children:"Keep"})]})]})}const SC=e=>e.files??(e.file?[e.file]:[]);function NC(e){const{item:t}=e,[s,o]=y.useState(!1),a=SC(t),c=t.revert??"restore";return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[Vg(t)]}),detail:a.join(", ")||void 0,detailText:a.join(", ")||void 0,below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:t.lines.join(`
|
|
147
|
+
`)}),e.local&&!s&&i.jsxs("div",{className:"ap-below ap-actions",children:[i.jsx(P,{size:"sm",disabled:e.busy,onClick:e.onAccept,children:"Accept this change"}),c!=="none"&&i.jsx(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>c==="delete"?o(!0):e.onRevert(),children:c==="delete"?"Delete…":"Revert"})]}),e.local&&s&&i.jsx(jC,{files:a,busy:e.busy,onDelete:()=>(o(!1),e.onRevert(a)),onCancel:()=>o(!1)})]})})}function bC(e){const{tracker:t}=e;return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:`trackers.json now points at ${t.label}`,context:i.jsx(V,{parts:["Nothing is read from or sent there yet"]}),detail:`This machine keeps using ${t.approved}`,below:e.local&&i.jsxs("div",{className:"ap-below ap-actions",children:[i.jsxs(P,{size:"sm",disabled:e.busy,onClick:()=>e.onDecide(!0),children:["Use ",t.label]}),i.jsxs(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onDecide(!1),children:["Keep ",t.approved]})]})})}function CC(e){const{item:t}=e,s=t.committed===!1,o=t.kind==="catalogs"?[...t.lines,""]:[],a=s?[...o,...t.content.split(`
|
|
148
148
|
`)]:t.lines;return i.jsx(Ce,{as:"li",className:"ap-row",edge:"attention",title:t.title,context:i.jsx(V,{parts:[Vg(t)]}),detail:Lm[t.kind],detailText:Lm[t.kind],below:i.jsxs("div",{className:"ap-below",children:[i.jsx("pre",{className:"ap-lines t-code",children:a.join(`
|
|
149
|
-
`)}),Om[t.kind]&&i.jsx("p",{className:"ap-note t-meta",children:Om[t.kind]}),t.warnings.length>0&&i.jsx("ul",{className:"ap-warnings t-meta",children:t.warnings.map(c=>i.jsxs("li",{children:["Worth a look: ",c]},c))}),e.local&&i.jsx(P,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function Pm(e,t){const s=await fetch(`${je()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await s.json().catch(()=>({}));if(!s.ok)throw new Error(o.error??`Request failed (${s.status})`);return o}const Ec=async e=>e.ok?await e.json():void 0;async function _m(){var p;const[e,t,s]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(v=>fetch(`${je()}${v}`))),o=await Ec(e);if(!o)return null;const{items:a}=o,c=(p=await Ec(t))==null?void 0:p.pending,d=await Ec(s),h=o.firstRun===!0,m=o.stateFirstRun===!0;return{items:a,firstRun:h,stateFirstRun:m,...c?{tracker:c}:{},...d!=null&&d.writes?{oldQueue:d}:{}}}const CC=(e,t)=>{var s,o,a,c;return JSON.stringify([e.items.map(d=>d.hash),(s=e.tracker)==null?void 0:s.target,(o=e.oldQueue)==null?void 0:o.writes])===JSON.stringify([t.items.map(d=>d.hash),(a=t.tracker)==null?void 0:a.target,(c=t.oldQueue)==null?void 0:c.writes])};function $C(e){var s,o;const t=[(s=e.changed)!=null&&s.length?`${e.changed.length} changed while you looked, so they wait; look again`:"",(o=e.refused)!=null&&o.length?`${e.refused.length} not committed, so they need their own look`:""].filter(Boolean);return t.length?`${t.join(". ")}.`:void 0}function TC(){const[e,t]=y.useState(),[s,o]=y.useState(!1),a=y.useRef();y.useEffect(()=>void(a.current=e),[e]);const c=y.useRef(0),[d]=y.useState(ei),h=y.useRef(0),m=y.useCallback(()=>{h.current++;const S=d.start(),C=j=>{S()&&(a.current=j,t(j),o(!1))};return _m().then(C,()=>C(null))},[d]),p=y.useCallback(async()=>{if(c.current)return;const S=h.current,C=await _m().catch(()=>null),j=a.current;h.current!==S||j===void 0||(!C||!j||!CC(C,j))&&o(!0)},[]);y.useEffect(()=>void m(),[m]),y.useEffect(()=>Su(S=>void(S.startsWith(".")||p())),[p]),y.useEffect(()=>fs(()=>void p()),[p]);const v=y.useCallback(async S=>{c.current++;try{const C=await S();return await m(),C}finally{c.current--}},[m]),k=y.useCallback(async S=>$C(await v(()=>Pm("/trust/approve",{items:S.map(C=>({key:C.key,hash:C.hash}))}))),[v]),x=y.useCallback(async(S,C)=>{await v(()=>Pm(S,C))},[v]);return{view:e,changed:s,load:m,approve:k,act:x}}function EC(){const{view:e,changed:t,load:s,approve:o,act:a}=TC(),c=Kg()!==!1,[d,h]=y.useState(!1),[m,p]=y.useState();if(!e)return null;const v=b=>{h(!0),p(void 0),b.then(R=>(h(!1),p(R??void 0)),R=>(h(!1),p(R.message)))},{items:k,tracker:x,oldQueue:S}=e,C=b=>!b.alone&&(b.kind==="state"?e.stateFirstRun&&b.standing==="elsewhere":e.firstRun),j=k.filter(b=>b.committed!==!1&&C(b)),I=k.length+(x?1:0)+(S?1:0);return i.jsxs(Ie,{title:"Approvals",children:[i.jsxs("p",{className:"vf-intro",children:["Some files in the repo tell ",te.name," what to trust: the commands checks run, where trails are kept, what needs you, how much each trail is checked, and briefs, criteria and knowledge marked accepted. Agents can edit those files and teammates push them, so nothing in them takes effect on this machine until you approve it here, exactly as it is. The same goes for a trail's state: a ticket closed, retyped, claimed or unblocked, a level or mode changed, or a decision written by editing files instead of through ",te.name," shows here as changed outside ",te.name,", and counts only once you accept it."]}),t&&i.jsxs("div",{className:"sync-line alert ap-changed",role:"status",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"Files changed while you were here. What's below is what you saw."}),i.jsx(P,{size:"sm",onClick:s,children:"Review again"})]}),I===0&&i.jsx("p",{className:"ap-none t-meta",children:"Nothing waiting. Everything the repo asks for is approved here."}),j.length>1&&i.jsx("p",{className:"ap-adopt",children:kC(j.length)}),k.some(b=>b.kind==="state")&&i.jsx("p",{className:"ap-note t-meta",children:vC}),I>0&&i.jsxs("ul",{className:"ap-list",children:[x&&i.jsx(NC,{tracker:x,busy:d,local:c,onDecide:b=>v(a("/trackers/approval",{use:b,target:x.target}))}),S&&i.jsx(wC,{queue:S,busy:d,local:c,onDecide:b=>v(a("/trackers/legacy-outbox",{action:b?"send":"discard",writes:S.writes}))}),k.map(b=>b.kind==="state"?i.jsx(SC,{item:b,busy:d,local:c,onAccept:()=>v(o([b])),onRevert:R=>v(a("/trust/revert",{key:b.key,hash:b.hash,remove:R}))},b.key):i.jsx(bC,{item:b,busy:d,local:c,onApprove:()=>v(o([b]))},b.key))]}),c&&j.length>1&&i.jsxs(P,{disabled:d||t,onClick:()=>v(o(j)),children:["Approve all ",j.length," committed"]}),!c&&I>0&&i.jsxs("p",{className:"t-meta",children:["Approve these on the machine ",te.name," runs on."]}),m&&i.jsx("span",{className:"vf-err",children:m}),i.jsx(V,{className:"set-hint",parts:yC})]})}function Gg(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const qg=`${te.apiPrefix}`;async function Qg(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const Vo=async e=>Qg(await fetch(`${qg}${e}`)),Yg=async(e,t)=>Qg(await fetch(`${qg}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let Jg;const Lo=new Set;let Vn;function Zc(e){Jg=e;for(const t of Lo)t()}function Xg(e){Vn==null||Vn.pushed(),Zc(e)}const AC=()=>Jg;function IC(e){return Lo.add(e),Vn??(Vn=Cg({load:()=>Vo("/guides"),show:Zc,failed:()=>Zc(null),changed:t=>t.includes("guides")})),()=>{Lo.delete(e),!Lo.size&&(Vn==null||Vn.stop(),Vn=void 0)}}function jn(){const e=y.useSyncExternalStore(IC,AC),t=y.useCallback(async(o,a)=>{try{Xg(await Yg(o,a));return}catch(c){return c.message}},[]),s=y.useCallback(o=>o?e==null?void 0:e.guides.find(a=>a.id===o):void 0,[e]);return{view:e,act:t,find:s}}function MC(e){var h;const{view:t,find:s}=jn(),o=s(e.id),a=t!=null&&(o==null?void 0:o.status)!=="active",c=((h=o==null?void 0:o.guide)==null?void 0:h.name)??e.id,d=a?`${c}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${c}`;return i.jsx("span",{className:Ge("guide-chip",a&&"off"),"data-guide-id":e.id,title:d,children:c})}const RC={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},LC={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},eu=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function OC(e){return eu(e)?{text:LC[e.status],strong:e.status==="active"}:e.status==="active"?void 0:RC[e.status]}function Go(e){try{return new URL(e).host}catch{return e}}function PC(e){var s;if(e.origin==="builtin")return"Built in";const t=(s=e.lock)==null?void 0:s.source;return!t||t==="local"?e.overridesBuiltin?"Local, replaces the built-in":"Local":`From ${Go(t.registry)}`}const Ou=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),Dm=3;function _C(e,t){return e.length<=Math.max(t,Dm+1)?e:`${e.slice(0,Math.max(t-1,Dm)).trimEnd()}…`}function Zg(e){return e===qj?"Verified":`Verified by ${Go(e)}'s catalog`}function ev(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Zg(t),strong:!0}:"Not reviewed"}function DC(e){var c,d;const t=(c=e.lock)==null?void 0:c.review;if(!t||e.status!=="active")return;if(!t.verified)return"Not reviewed";const s=t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0,o=(d=e.lock)==null?void 0:d.source;return{text:o&&o!=="local"?Zg(o.registry):"Verified",strong:!0,tip:s}}var zC=pp();function tv(e){return R0(e.spec)?i.jsxs("span",{className:"guide-unknown",children:[i.jsx("span",{className:"t-body",children:"Unknown program: Teamtrail can't tell what this runs. Approve it only if you know what it does."}),i.jsxs(P,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!0),children:["I know what it runs: approve check ",e.name]})]}):i.jsxs(P,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!1),children:["Approve check ",e.name]})}function BC(e){var x;const{preview:t}=e,{act:s,find:o}=jn(),[a,c]=y.useState({kind:"ready"}),[d,h]=y.useState(),m=t.entry.id,p=async()=>{h(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(m,t.entry.sha256)).pendingChecks})}catch(S){h(S.message),c({kind:"ready"})}};if(t.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",te.name,": already available to every trail, nothing to add."]});if(a.kind!=="added"){const S=e.installed===t.entry.version,C=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!t.ok&&i.jsx("span",{className:"t-meta",children:"The lint found errors, so this guide can't be added."}),i.jsx(P,{variant:"primary",disabled:!t.ok||S||a.kind==="adding",onClick:()=>void p(),children:S?"Added":C}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const v=((x=o(m))==null?void 0:x.pendingChecks)??a.pending,k=async(S,C)=>h(await s("/guides/checks/approve",{id:m,name:S,acknowledged:C}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:v.length?`Added ${m} ${t.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${m} ${t.entry.version}. Agents get its instructions on tickets that ask for ${m}.`}),v.map(S=>{var C,j,I;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[S,": ",Ou(((j=(C=t.guide)==null?void 0:C.proposedChecks[S])==null?void 0:j.run)??[])]}),i.jsx(tv,{name:S,spec:((I=t.guide)==null?void 0:I.proposedChecks[S])??{run:[]},onApprove:(b,R)=>void k(b,R)})]},S)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function FC(e){const t=i.jsx("p",{className:"t-meta",children:"The lint looks for common problems; it isn't a review. Read the guide before you approve it."});return e.findings.length?i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((s,o)=>i.jsxs("li",{className:`sev-${s.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",s.line]})," ",s.message," ",i.jsxs("span",{className:"t-meta",children:["(",s.rule,")"]})]},o))}),t]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-meta",children:"The lint found none of the problems it looks for."}),t]})}function nv(e){var o,a;const{p:t}=e,s=Object.entries(((o=t.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Lint"}),i.jsx(FC,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(c=>i.jsx("li",{children:c},c))}),s.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),s.map(([c,d])=>i.jsxs("code",{className:"t-code guide-check",children:[c,": ",Ou(d.run),d.cwd&&` (in ${d.cwd})`]},c)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((a=t.guide)==null?void 0:a.instructions)??t.text})]})}function UC(e){const t=Zs(e.repo);if(!t)return null;const s=encodeURIComponent(`Report: ${e.id} ${e.version}`),o=`${t.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${s}`;return i.jsx("a",{className:"report-link t-meta",href:o,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function WC(e){const t=e.entry,[s,o]=y.useState(),[a,c]=y.useState();return y.useEffect(()=>{e.preview(t.id).then(o,d=>c(d.message))},[t.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:t.name??t.id}),i.jsx(V,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,ev(t,e.catalogUrl),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10)]},`${d.version}-${d.commit}`))}),a&&i.jsx("span",{className:"vf-err",children:a}),s&&i.jsx(nv,{p:s}),s&&i.jsx(UC,{repo:s.repo,id:t.id,version:t.version}),s&&i.jsx(BC,{preview:s,installed:e.installed,add:e.add})]})}function HC(e){const t=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:i.jsx(Ce,{title:t.name??t.id,context:i.jsx(V,{parts:[{text:t.id,code:!0},t.version,t.author,ev(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const zm=e=>e?`registry=${encodeURIComponent(e)}`:"";function KC(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{let h=!0;return s(void 0),a(void 0),Vo(`/guides/catalog?${zm(e)}`).then(m=>h&&s(m),m=>h&&a(m.message)),()=>{h=!1}},[e]);const c=y.useCallback(h=>Vo(`/guides/catalog/preview?${zm(e)}&id=${encodeURIComponent(h)}`),[e]),d=y.useCallback(async(h,m)=>{const p=await Yg("/guides/catalog/add",{registry:e,id:h,sha256:m});return Xg(p),p.installed},[e]);return{index:t,error:o,preview:c,add:d}}function VC(e){var j,I;const[t,s]=y.useState(((j=e.registries[0])==null?void 0:j.name)??""),o=KC(t||void 0),{find:a}=jn(),[c,d]=y.useState(""),[h,m]=y.useState(!0),[p,v]=y.useState(),k=o.index?L0({guides:o.index.guides},{query:c,verifiedOnly:h}):[],x=(I=o.index)==null?void 0:I.guides.find(b=>b.id===p),S=b=>{var R,O,U;return((R=a(b))==null?void 0:R.origin)==="local"?(U=(O=a(b))==null?void 0:O.guide)==null?void 0:U.version:void 0},C=e.registries.find(b=>b.name===t);return zC.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:b=>{b.stopPropagation(),e.onClose()},children:i.jsxs(ze,{as:"div",className:"dialog catalog-dialog",onClick:b=>b.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(dt,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map(b=>({value:b.name,label:`${b.name} · ${Go(b.url)}`,hint:b.url})),onChange:s}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),C&&e.registries.length===1&&i.jsx(V,{parts:[`Catalog ${C.name}`,{text:Go(C.url),code:!0}]}),x?i.jsx(WC,{entry:x,catalogUrl:(C==null?void 0:C.url)??"",installed:S(x.id),preview:o.preview,add:o.add,onBack:()=>v(void 0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog-filters",children:[i.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:c,onChange:b=>d(b.target.value)}),i.jsx(P,{size:"sm",on:h,"aria-pressed":h,onClick:()=>m(b=>!b),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Ae,{children:"Reading the catalog…"}),o.index&&!k.length&&i.jsx(Ae,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:k.map(b=>i.jsx(HC,{entry:b,catalogUrl:(C==null?void 0:C.url)??"",installed:S(b.id),onOpen:()=>v(b.id)},b.id))})]})]})}),document.body)}function GC(e){const t=e.r.guide;if(!t)return null;const s=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!s.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),s.map(([a,c])=>{const d=e.r.pendingChecks.includes(a);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[a,": ",Ou(c.run)]}),d&&o&&i.jsx(tv,{name:a,spec:c,busy:e.busy,onApprove:e.onApprove}),d&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&i.jsx("span",{className:"t-meta",children:"approved"})]},a)})]})}function qC(e){const{r:t}=e;if(!t.guide||!t.sha256)return null;const s=t.sha256;return i.jsxs("div",{className:"guide-review",children:[i.jsx(nv,{p:{findings:t.findings,guide:t.guide}}),i.jsx(P,{size:"sm","aria-label":`Approve guide ${t.id}`,disabled:e.busy,onClick:()=>e.onApprove(s),children:"Approve"})]})}const QC="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function YC(e){var t,s;return e.override?QC:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((s=e.guide)==null?void 0:s.summary)}function sv(e){const{r:t}=e,s=t.id,o=t.override??t,a=(o.status==="unapproved"||o.status==="tampered")&&!!o.guide,c=t.status!=="active"||t.pendingChecks.length>0||a,d=t.guide?`${t.guide.name} ${t.guide.version}`:s;return i.jsx("li",{className:"guide-row","data-guide-id":s,children:i.jsx(Ce,{edge:c?"attention":"neutral",title:d,context:i.jsx(V,{parts:[{text:s,code:!0},PC(t),DC(t),OC(t),t.guide&&JC(t.guide.checklist.length)]}),detail:YC(t),actions:t.origin==="local"&&i.jsxs(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:s}),children:["Remove guide ",s]}),below:i.jsxs(i.Fragment,{children:[a&&i.jsx(qC,{r:o,busy:e.busy,onApprove:h=>e.onAct("/guides/approve",{id:s,sha256:h})}),i.jsx(GC,{r:t,busy:e.busy,onApprove:(h,m)=>e.onAct("/guides/checks/approve",{id:s,name:h,acknowledged:m})})]})})})}const JC=e=>e===1?"1 checklist item":`${e} checklist items`;function XC(e){return i.jsxs(Ie,{title:"Write your own",children:[i.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",i.jsxs("code",{className:"t-code",children:[te.slug," guides new <id>"]}),". It starts from a template in ",i.jsxs("code",{className:"t-code",children:[te.dataDir,"/guides/"]})," that passes the lint. Fill in the instructions and checklist, then approve it here: agents can only use it once you have, and again after every edit."]}),e.guides.length>0?i.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>i.jsx(sv,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ae,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[te.slug," guides lint"]})," and"," ",i.jsx("a",{href:Qj,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function ZC(e){const{view:t,act:s}=jn(),[o,a]=y.useState(),[c,d]=y.useState(!1),[h,m]=y.useState(!1),p=y.useRef(null);if(y.useEffect(()=>{var x;e.focus&&t&&((x=p.current)==null||x.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const v=x=>(S,C)=>{d(!0),s(S,C).then(j=>{a(j?{own:x,message:j}:void 0),d(!1)})},k=x=>o&&o.own===x?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:p,children:[i.jsxs(Ie,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:t.guides.filter(x=>!eu(x)).map(x=>i.jsx(sv,{r:x,busy:c,onAct:v(!1)},x.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(P,{size:"sm",onClick:()=>m(!0),children:"Browse guides"}),i.jsx(V,{parts:[{text:`${te.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.configErrors.map(x=>i.jsx("li",{children:x},x))}),k(!1)&&i.jsx("span",{className:"vf-err",children:k(!1)})]}),i.jsx(XC,{guides:t.guides.filter(eu),busy:c,onAct:v(!0),error:k(!0)}),h&&i.jsx(VC,{registries:t.registries,onClose:()=>m(!1)})]})}function e$(e){const{view:t,act:s}=jn(),[o,a]=y.useState();if(!t)return null;const c=e.map.guides??[],d=t.guides.filter(m=>m.status==="active"&&m.guide),h=m=>{const p=c.includes(m)?c.filter(v=>v!==m):[...c,m];a(void 0),s("/guides/team",{mapId:e.map.id,guides:p}).then(a)};return i.jsxs(Ie,{title:`Team of ${e.map.key}`,children:[i.jsx("p",{className:"vf-intro",children:"The guides this trail works with. With Reviewer on the team, review tickets come with the reviewer's instructions and checklist."}),i.jsx("div",{className:"team-guides",children:d.map(m=>{const p=c.includes(m.id);return i.jsx(P,{size:"sm",on:p,"aria-pressed":p,title:m.guide.summary,onClick:()=>h(m.id),children:m.guide.name},m.id)})}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function t$(e,t){const[s,o]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return pt({view:a,load:()=>Vo(a),show:c=>o(c.checklist),failed:()=>o(null),changed:c=>c.endsWith("checklist.json")}),s}function n$(e){const t=t$(e.mapId,e.ticketId);if(!t)return null;const s=t.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(V,{parts:[`${t.guide.id} ${t.guide.version} checklist`,t.by,cr(t.at),s?`${s} not done`:"all done"]}),i.jsx(Gg,{answers:t.answers})]})}const Bm="";function s$(e){const{view:t,act:s}=jn(),[o,a]=y.useState();if(!t)return null;const c=e.ticket,d=t.guides.filter(p=>{var v;return p.status==="active"&&((v=p.guide)==null?void 0:v.handles.types.includes(c.type))}),h=[{value:Bm,label:"No guide"},...d.map(p=>({value:p.id,label:p.guide.name,hint:p.guide.summary}))];c.guide&&!d.some(p=>p.id===c.guide)&&h.push({value:c.guide,label:c.guide});const m=p=>{a(void 0),s("/guides/ticket",{mapId:e.mapId,ticketId:c.id,guide:p||null}).then(a)};return i.jsxs("span",{className:"guide-picker",children:[i.jsx(dt,{compact:!0,"aria-label":"Ticket guide",value:c.guide??Bm,options:h,onChange:m}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function i$(e){const{view:t,find:s}=jn();if(!t)return null;const o=s(e.id);if((o==null?void 0:o.status)==="active")return null;const a=o?o.reason??o.status:"it is not installed";return i.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",a,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function r$(e){const{view:t}=jn(),s=e.ticket;return!t||s.state!=="open"&&!s.guide?null:i.jsxs("section",{className:"ticket-guide d-section",children:[i.jsxs("span",{className:"guide-head",children:[i.jsx("span",{className:"t-label",children:"Guide"}),s.state==="open"?i.jsx(s$,{mapId:e.mapId,ticket:s}):s.guide&&i.jsx(MC,{id:s.guide})]}),s.guide&&i.jsx(i$,{id:s.guide}),i.jsx(n$,{mapId:e.mapId,ticketId:s.id})]})}function o$(e){var m;const{view:t,find:s}=jn();if(!e)return;const o=s(e),a=t!=null&&(o==null?void 0:o.status)!=="active",c=((m=o==null?void 0:o.guide)==null?void 0:m.name)??e,d=o!=null&&o.guide?`${c} ${o.guide.version}`:c,h=a?`Guide ${d}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:c,tip:h,off:a}}const iv="0.29.2-next.42",tu="<endpoint>",Pu=vp(iv,["mcp","--http"]);function a$(e,t){const s=vp(iv,["connect",e,"--url"]),o=t===tu?t:gp(t);return`read -rs ${te.tokenEnv} && export ${te.tokenEnv}
|
|
150
|
-
${s} ${o}`}function l$(e){return e.kind==="lookout"?["the Lookout","this machine only"]:["for remote agents",e.network?"open to your network":"this machine only, until a tunnel or proxy shares it"]}function c$({endpoints:e}){const t=e.some(s=>s.kind==="standalone");return i.jsxs("ul",{className:"ra-endpoints",children:[e.map(s=>i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:[{text:s.url,code:!0},...l$(s)]})},s.url)),!t&&i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:["For agents on other machines, start their server",{text:Pu,code:!0}]})})]})}function u$(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[c,d]=y.useState(),h=async m=>{if(!m.trim()||o)return;a(!0);const p=await e.onCreate(m).catch(v=>v.message);a(!1),d(p),p||s("")};return i.jsxs("div",{className:"ra-new",children:[i.jsx(ga,{value:t,onValueChange:s,onSubmit:h,action:"Create token",actionDisabled:o||!t.trim(),placeholder:"Name the agent, e.g. cloud sandbox 1","aria-label":"Agent name",maxLength:60}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function d$(){return i.jsx(Ie,{title:"Remote agents",children:i.jsxs("p",{className:"vf-intro",children:["Tokens for remote agents are created and revoked on the machine ",te.name," runs on. Open the Lookout there to manage them."]})})}function h$(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[c,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(m=>m.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"Its sessions end now."}),i.jsxs(P,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(P,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function f$(e){if(!e.tokens.length)return null;const t=Date.now();return i.jsx("ul",{className:"ra-list",children:e.tokens.map(s=>i.jsx(Ce,{as:"li",className:"ra-row",title:s.name,titleText:s.name,context:i.jsx(V,{parts:[`Created ${Ho(s.createdAt,t)}`,s.lastUsedAt?`Last used ${Ho(s.lastUsedAt,t)}`:"Never used"]}),below:i.jsx(h$,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function Ac(e){const[t,s]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.value).then(()=>{s(!0),setTimeout(()=>s(!1),1500)},()=>s(!1)))};return i.jsxs("div",{className:"ra-copy",children:[i.jsx("code",{className:"ra-copy-value t-code","aria-label":e.label,children:e.value}),i.jsx(P,{size:"sm",className:"ra-copy-btn",onClick:o,children:t?"Copied":e.copyLabel??"Copy"})]})}const m$=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function p$(e){const[t,s]=y.useState("claude");return i.jsxs("div",{className:"ra-reveal",role:"status",children:[i.jsxs("p",{className:"ra-reveal-title t-row-title",children:["Token for ",e.created.name]}),i.jsxs("p",{className:"t-body ra-note",children:["Copy it now. ",te.name," keeps only a fingerprint, so it can't show it again."]}),i.jsx(Ac,{label:"Token",value:e.created.token,copyLabel:"Copy token"}),!e.endpoint&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"ra-reveal-head",children:i.jsx(Ve,{children:"Start the server for remote agents"})}),i.jsx(Ac,{label:"Start command",value:Pu,copyLabel:"Copy command"})]}),i.jsxs("div",{className:"ra-reveal-head",children:[i.jsx(Ve,{children:"Run on the agent's machine"}),i.jsx("span",{className:"ra-clients",children:m$.map(o=>i.jsx(P,{size:"sm",on:t===o.id,"aria-pressed":t===o.id,onClick:()=>s(o.id),children:o.label},o.id))})]}),i.jsx(Ac,{label:"Connect command",value:a$(t,e.endpoint??tu),copyLabel:"Copy command"}),i.jsxs("p",{className:"t-meta ra-note",children:["The first line waits for the token: paste it and press Enter. It isn't shown, and it stays out of your shell history."," ",e.endpoint?"From another machine, use the address that machine reaches this one by.":`Put the address the server prints in place of ${tu}.`,t==="codex"&&` Start Codex from the same shell: it reads $${te.tokenEnv} each time.`]}),i.jsx("span",{children:i.jsx(P,{variant:"primary",size:"sm",onClick:e.onDone,children:"I've copied it"})})]})}const rv=`${je()}/remote-agents`;async function Fm(e,t){const s=await fetch(`${rv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json()}}async function g$(){const e=await fetch(rv);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function v$(){const[e,t]=y.useState(),[s,o]=y.useState(),{pushed:a}=pt({load:g$,show:t,failed:()=>t(null),events:{"remote-agents":()=>!0}}),c=y.useCallback(m=>{a(),t({tokens:m.tokens,endpoints:m.endpoints})},[a]),d=y.useCallback(async m=>{const{ok:p,reply:v}=await Fm("/tokens",{name:m});if(!p||!v.token||!v.created)return v.error??"The token could not be created.";c(v),o({token:v.token,name:v.created.name})},[c]),h=y.useCallback(async m=>{const{ok:p,reply:v}=await Fm("/tokens/revoke",{id:m});return v.tokens&&c(v),p?void 0:v.error??"The token could not be revoked."},[c]);return{view:e,created:s,dismissCreated:()=>o(void 0),create:d,revoke:h}}function k$(){var d;const{view:e,created:t,dismissCreated:s,create:o,revoke:a}=v$();if(!e)return null;if(e==="elsewhere")return i.jsx(d$,{});const c=(d=e.endpoints.find(h=>h.kind==="standalone"))==null?void 0:d.url;return i.jsxs(Ie,{title:"Remote agents",children:[i.jsx("p",{className:"vf-intro",children:"Agents on another machine or in a cloud sandbox can work this repo's trails too. They connect over HTTP with a token and share the tickets, claims and inbox of the agents here. One token per agent; revoke it and that agent is out within about a second."}),i.jsx(c$,{endpoints:e.endpoints}),t&&i.jsx(p$,{created:t,endpoint:c,onDone:s}),i.jsx(f$,{tokens:e.tokens,onRevoke:a}),e.tokens.length===0&&i.jsx("p",{className:"t-meta ra-note",children:"No tokens, so the endpoint is closed: every request is refused."}),i.jsx(u$,{onCreate:o}),i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"Before you open it to other machines."})," The connection is plain HTTP. Run ",i.jsx("code",{children:Pu}),", which serves the agent tools and nothing else, and put that port behind HTTPS with a reverse proxy or a tunnel. The Lookout's own port is not for sharing: its agent endpoint answers this machine only. A token only ever opens the agent tools, never the Lookout, which signs in browsers, not agents."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What a remote agent can't do."})," Speak for you: it can't answer a question, skip discovery, change the trail's mode or destination, or close a ticket that needs you before you've answered here or in Slack. And its files aren't on this machine, so it gets no worktree, and on trails with verification its finished work comes to you to review instead of running the checks here."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"How far to trust one."})," The risk policy only sees what an agent declares: a call is held for you when the agent names a high-risk category or touches files your path rules cover. An agent that declares nothing isn't caught. Give an agent you don't fully trust only trails with verification on, where its finished work comes to you."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it does as you."})," With GitHub Issues or Linear as the tracker, everything a remote agent writes (tickets, comments, closing) goes to the tracker with your credentials, like the agents here."]})]})]})}const Um={schema:"Database schema","breaking-api":"Breaking API changes","auth-permissions":"Auth and permissions",billing:"Billing","data-deletion":"Deleting data","product-behaviour":"Product behaviour",dependencies:"Dependencies"},y$={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},w$=e=>e[0].toUpperCase()+e.slice(1),nu=Dp.map(e=>({value:e,label:w$(e),hint:y$[e]}));function x$(e){const[t,s]=y.useState(""),[o,a]=y.useState("high"),{rules:c,onChange:d}=e,h=()=>{const m=t.trim();!m||c.some(p=>p.glob===m)||(d([...c,{glob:m,level:o}]),s(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),c.map((m,p)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:m.glob}),i.jsx(dt,{compact:!0,"aria-label":`${m.glob} risk`,value:m.level,options:nu,onChange:v=>d(c.map((k,x)=>x===p?{...k,level:v}:k))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${m.glob}`,onClick:()=>d(c.filter((v,k)=>k!==p)),children:"×"})]},m.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:m=>s(m.target.value),onKeyDown:m=>m.key==="Enter"&&h()}),i.jsx(dt,{compact:!0,"aria-label":"New pattern risk",value:o,options:nu,onChange:a}),i.jsx(P,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const ov=`${je()}/policy`;async function j$(){const e=await fetch(ov);return e.ok?await e.json():null}function S$(){const[e,t]=y.useState(),{pushed:s}=pt({load:j$,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),o=y.useCallback(async a=>{const c=await fetch(ov,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;s(),t(d)},[s]);return{view:e,save:o}}function N$(){const{view:e,save:t}=S$(),[s,o]=y.useState();if(!e)return null;const a=`${te.dataDir}/policy.json`,c=d=>{o(void 0),t(d).then(o,h=>o(h.message))};return i.jsxs(Ie,{title:"Risk policy",children:[i.jsx("p",{className:"vf-intro",children:"What agents may decide on their own. High: they must ask you. Medium: they decide, follow your conventions and record it for you to review. Low: they just decide."}),i.jsx("div",{className:"risk-grid",children:_p.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:Um[d]}),i.jsx(dt,{compact:!0,"aria-label":`${Um[d]} risk`,value:e.policy.categories[d],options:nu,onChange:h=>c({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(x$,{rules:e.policy.paths,onChange:d=>c({...e.policy,paths:d})}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[a," has errors, so the defaults apply until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>i.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",a,", so your team shares it."]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const su=`${je()}/workspaces`;async function b$(){const e=await fetch(su);return e.ok?await e.json():null}function av(){const[e,t]=y.useState(),{pushed:s}=pt({load:b$,show:t,failed:()=>t(null),changed:d=>d.endsWith("workspaces.json")||d.includes("workspaces/")||d.includes("leases/")}),o=y.useCallback(d=>{s(),t(d)},[s]),a=y.useCallback(async d=>{const h=await fetch(su,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),m=await h.json();if(!h.ok)return m.error??`Saving failed (${h.status})`;o(m)},[o]),c=y.useCallback(async(d,h,m=!1)=>{const p=await fetch(`${su}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,ticketId:h,force:m})}),v=await p.json();return p.ok?(o(v),{}):{error:v.error??`Removing failed (${p.status})`,dirty:v.dirty??!1}},[o]);return{view:e,save:a,remove:c}}function lv(e){const[t,s]=y.useState(!1),[o,a]=y.useState(),[c,d]=y.useState(!1),h=async m=>{d(!0),a(void 0);const p=await e.onRemove(m).catch(v=>({error:v.message,dirty:!1}));d(!1),s(!!p.dirty&&!m),p.dirty||a(p.error)};return t?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(P,{size:"sm",disabled:c,onClick:()=>h(!0),children:"Remove anyway"}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(P,{size:"sm",disabled:c,onClick:()=>h(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function C$(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(t=>i.jsx(Ce,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:i.jsx(V,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:i.jsx(lv,{onRemove:s=>e.onRemove(t.mapId,t.ticketId,s)})},`${t.mapId}/${t.ticketId}`))}):null}function $$(e){const{view:t,remove:s}=av(),o=t==null?void 0:t.workspaces.find(a=>a.mapId===e.mapId&&a.ticketId===e.ticketId);return!o||o.active?null:i.jsxs("section",{className:"ticket-workspace d-section",children:[i.jsx("span",{className:"t-label",children:"Workspace"}),i.jsxs("p",{className:"t-meta",children:["Branch ",i.jsx("code",{className:"t-code",children:o.branch})," in"," ",i.jsx("code",{className:"t-code",title:o.path,children:o.path})]}),i.jsx(lv,{label:"Remove workspace",onRemove:a=>s(e.mapId,e.ticketId,a)})]})}function T$(){const{view:e,save:t,remove:s}=av(),[o,a]=y.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{a(void 0),t({...e.settings,worktrees:!c}).then(a,h=>a(h.message))};return i.jsxs(Ie,{title:"Workspaces",children:[i.jsxs("p",{className:"vf-intro",children:["Give each agent its own copy of the repo for every ticket it claims, on its own branch, so agents working at the same time don't step on each other. You review and merge the branches; ",te.name," never merges or pushes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),i.jsx(P,{size:"sm",on:c,"aria-pressed":c,className:"worktrees-toggle",onClick:d,children:c?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${te.dataDir}/workspaces.json`,code:!0},Wm(e.workspaces.filter(h=>h.active).length,"active"),Wm(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx(C$,{rows:e.workspaces,onRemove:s}),e.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.errors.map(h=>i.jsx("li",{children:h},h))}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Wm=(e,t)=>`${e} ${t}`;function E$({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"approvals",storage:"machine",children:i.jsx(EC,{})}),i.jsx(Qe,{id:"tracker",children:i.jsx(Ie,{title:"Tracker",children:i.jsx(Xb,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(Qe,{id:"workspaces",storage:"repo",children:i.jsx(T$,{})}),i.jsx(Qe,{id:"remote-agents",storage:"machine",children:i.jsx(k$,{})}),i.jsx(Qe,{id:"policy",storage:"repo",children:i.jsx(N$,{})}),i.jsx(Qe,{id:"guides",storage:"repo",children:i.jsx(ZC,{focus:t.section==="guides"})}),i.jsx(Qe,{id:"labels",children:i.jsx(Ie,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:lu}),i.jsxs("code",{children:[te.labelPrefix,":<type>"]}),i.jsx("code",{children:cu}),i.jsx("code",{children:uu})]})})})]})}const iu=`${te.apiPrefix}/projects`;async function Io(e,t,s){const o=await fetch(`${iu}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(a.error??`HTTP ${o.status}`);return a}const Js={url:iu,add:e=>Io("","POST",{path:e}),remove:e=>Io(`/${e}`,"DELETE"),setAutoRegister:e=>Io("/settings","PUT",{autoRegister:e}),answer:(e,t)=>Io(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${iu}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function cv(e){const[t,s]=y.useState(""),[o,a]=y.useState(),c=d=>{d.trim()&&(a(void 0),Js.add(d.trim()).then(()=>(s(""),e.onAdded()),h=>a(h.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(ga,{value:t,onValueChange:s,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${te.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Fs=(e,t)=>e>0&&`${e} ${t}`;function A$(e){var s;const t=((s=e.briefing)==null?void 0:s.projects)??[];return!e.briefing||!t.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(Et,{title:"While you were away",count:t.length,info:`What changed in each project since ${dn(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:t.map(({projectId:o,project:a,briefing:c})=>i.jsx(Ce,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:a,context:i.jsx(V,{parts:[Fs(c.totals.done,"done"),Fs(c.trails.reduce((d,h)=>d+h.opened.length,0),"new tickets"),Fs(c.totals.agentDecisions,"agent decisions"),Fs(c.totals.waiting,"waiting on you"),Fs(c.totals.ruledOut,"ruled out"),Fs(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function I$(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[c,d]=y.useState(),h=m=>{!m.trim()||o||(a(!0),d(void 0),e.onAnswer(m.trim()).then(()=>s(""),p=>d(p.message)).finally(()=>a(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(ga,{value:t,onValueChange:s,onSubmit:h,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function M$(e){const{item:t}=e,s=Ag(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:Tg[t.kind],a=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(Ce,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:Eg(t,t.interrupting),title:t.title.split(`
|
|
149
|
+
`)}),Om[t.kind]&&i.jsx("p",{className:"ap-note t-meta",children:Om[t.kind]}),t.warnings.length>0&&i.jsx("ul",{className:"ap-warnings t-meta",children:t.warnings.map(c=>i.jsxs("li",{children:["Worth a look: ",c]},c))}),e.local&&i.jsx(P,{size:"sm",disabled:e.busy,onClick:e.onApprove,children:"Approve"})]})})}async function Pm(e,t){const s=await fetch(`${je()}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await s.json().catch(()=>({}));if(!s.ok)throw new Error(o.error??`Request failed (${s.status})`);return o}const Ec=async e=>e.ok?await e.json():void 0;async function _m(){var p;const[e,t,s]=await Promise.all(["/trust","/trackers","/trackers/legacy-outbox"].map(v=>fetch(`${je()}${v}`))),o=await Ec(e);if(!o)return null;const{items:a}=o,c=(p=await Ec(t))==null?void 0:p.pending,d=await Ec(s),h=o.firstRun===!0,m=o.stateFirstRun===!0;return{items:a,firstRun:h,stateFirstRun:m,...c?{tracker:c}:{},...d!=null&&d.writes?{oldQueue:d}:{}}}const $C=(e,t)=>{var s,o,a,c;return JSON.stringify([e.items.map(d=>d.hash),(s=e.tracker)==null?void 0:s.target,(o=e.oldQueue)==null?void 0:o.writes])===JSON.stringify([t.items.map(d=>d.hash),(a=t.tracker)==null?void 0:a.target,(c=t.oldQueue)==null?void 0:c.writes])};function TC(e){var s,o;const t=[(s=e.changed)!=null&&s.length?`${e.changed.length} changed while you looked, so they wait; look again`:"",(o=e.refused)!=null&&o.length?`${e.refused.length} not committed, so they need their own look`:""].filter(Boolean);return t.length?`${t.join(". ")}.`:void 0}function EC(){const[e,t]=y.useState(),[s,o]=y.useState(!1),a=y.useRef();y.useEffect(()=>void(a.current=e),[e]);const c=y.useRef(0),[d]=y.useState(ei),h=y.useRef(0),m=y.useCallback(()=>{h.current++;const S=d.start(),C=j=>{S()&&(a.current=j,t(j),o(!1))};return _m().then(C,()=>C(null))},[d]),p=y.useCallback(async()=>{if(c.current)return;const S=h.current,C=await _m().catch(()=>null),j=a.current;h.current!==S||j===void 0||(!C||!j||!$C(C,j))&&o(!0)},[]);y.useEffect(()=>void m(),[m]),y.useEffect(()=>Su(S=>void(S.startsWith(".")||p())),[p]),y.useEffect(()=>fs(()=>void p()),[p]);const v=y.useCallback(async S=>{c.current++;try{const C=await S();return await m(),C}finally{c.current--}},[m]),k=y.useCallback(async S=>TC(await v(()=>Pm("/trust/approve",{items:S.map(C=>({key:C.key,hash:C.hash}))}))),[v]),x=y.useCallback(async(S,C)=>{await v(()=>Pm(S,C))},[v]);return{view:e,changed:s,load:m,approve:k,act:x}}function AC(){const{view:e,changed:t,load:s,approve:o,act:a}=EC(),c=Kg()!==!1,[d,h]=y.useState(!1),[m,p]=y.useState();if(!e)return null;const v=b=>{h(!0),p(void 0),b.then(R=>(h(!1),p(R??void 0)),R=>(h(!1),p(R.message)))},{items:k,tracker:x,oldQueue:S}=e,C=b=>!b.alone&&(b.kind==="state"?e.stateFirstRun&&b.standing==="elsewhere":e.firstRun),j=k.filter(b=>b.committed!==!1&&C(b)),I=k.length+(x?1:0)+(S?1:0);return i.jsxs(Ie,{title:"Approvals",children:[i.jsxs("p",{className:"vf-intro",children:["Some files in the repo tell ",te.name," what to trust: the commands checks run, where trails are kept, what needs you, how much each trail is checked, and briefs, criteria and knowledge marked accepted. Agents can edit those files and teammates push them, so nothing in them takes effect on this machine until you approve it here, exactly as it is. The same goes for a trail's state: a ticket closed, retyped, claimed or unblocked, a level or mode changed, or a decision written by editing files instead of through ",te.name," shows here as changed outside ",te.name,", and counts only once you accept it."]}),t&&i.jsxs("div",{className:"sync-line alert ap-changed",role:"status",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"Files changed while you were here. What's below is what you saw."}),i.jsx(P,{size:"sm",onClick:s,children:"Review again"})]}),I===0&&i.jsx("p",{className:"ap-none t-meta",children:"Nothing waiting. Everything the repo asks for is approved here."}),j.length>1&&i.jsx("p",{className:"ap-adopt",children:yC(j.length)}),k.some(b=>b.kind==="state")&&i.jsx("p",{className:"ap-note t-meta",children:kC}),I>0&&i.jsxs("ul",{className:"ap-list",children:[x&&i.jsx(bC,{tracker:x,busy:d,local:c,onDecide:b=>v(a("/trackers/approval",{use:b,target:x.target}))}),S&&i.jsx(xC,{queue:S,busy:d,local:c,onDecide:b=>v(a("/trackers/legacy-outbox",{action:b?"send":"discard",writes:S.writes}))}),k.map(b=>b.kind==="state"?i.jsx(NC,{item:b,busy:d,local:c,onAccept:()=>v(o([b])),onRevert:R=>v(a("/trust/revert",{key:b.key,hash:b.hash,remove:R}))},b.key):i.jsx(CC,{item:b,busy:d,local:c,onApprove:()=>v(o([b]))},b.key))]}),c&&j.length>1&&i.jsxs(P,{disabled:d||t,onClick:()=>v(o(j)),children:["Approve all ",j.length," committed"]}),!c&&I>0&&i.jsxs("p",{className:"t-meta",children:["Approve these on the machine ",te.name," runs on."]}),m&&i.jsx("span",{className:"vf-err",children:m}),i.jsx(V,{className:"set-hint",parts:wC})]})}function Gg(e){return i.jsx("ul",{className:"checklist-answers",children:e.answers.map(t=>i.jsxs("li",{className:t.done?"done":"not-done",children:[i.jsx("span",{className:"mark","aria-label":t.done?"Done":"Not done",children:t.done?"✓":"–"}),i.jsx("span",{className:"t-body",children:t.item}),t.note&&i.jsx("span",{className:"t-meta note",children:t.note})]},t.item))})}const qg=`${te.apiPrefix}`;async function Qg(e){const t=await e.json().catch(()=>({}));if(!e.ok)throw new Error(t.error??`Request failed (${e.status})`);return t}const Vo=async e=>Qg(await fetch(`${qg}${e}`)),Yg=async(e,t)=>Qg(await fetch(`${qg}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}));let Jg;const Lo=new Set;let Vn;function Zc(e){Jg=e;for(const t of Lo)t()}function Xg(e){Vn==null||Vn.pushed(),Zc(e)}const IC=()=>Jg;function MC(e){return Lo.add(e),Vn??(Vn=Cg({load:()=>Vo("/guides"),show:Zc,failed:()=>Zc(null),changed:t=>t.includes("guides")})),()=>{Lo.delete(e),!Lo.size&&(Vn==null||Vn.stop(),Vn=void 0)}}function jn(){const e=y.useSyncExternalStore(MC,IC),t=y.useCallback(async(o,a)=>{try{Xg(await Yg(o,a));return}catch(c){return c.message}},[]),s=y.useCallback(o=>o?e==null?void 0:e.guides.find(a=>a.id===o):void 0,[e]);return{view:e,act:t,find:s}}function RC(e){var h;const{view:t,find:s}=jn(),o=s(e.id),a=t!=null&&(o==null?void 0:o.status)!=="active",c=((h=o==null?void 0:o.guide)==null?void 0:h.name)??e.id,d=a?`${c}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${c}`;return i.jsx("span",{className:Ge("guide-chip",a&&"off"),"data-guide-id":e.id,title:d,children:c})}const LC={active:"Active",unapproved:"New, waiting for your approval",tampered:"Changed since you approved it",invalid:"Can't be used"},OC={active:"Approved",unapproved:"Not approved yet",tampered:"Changed since you approved it",invalid:"Can't be used"},eu=e=>{var t;return e.origin==="local"&&(!((t=e.lock)!=null&&t.source)||e.lock.source==="local")};function PC(e){return eu(e)?{text:OC[e.status],strong:e.status==="active"}:e.status==="active"?void 0:LC[e.status]}function Go(e){try{return new URL(e).host}catch{return e}}function _C(e){var s;if(e.origin==="builtin")return"Built in";const t=(s=e.lock)==null?void 0:s.source;return!t||t==="local"?e.overridesBuiltin?"Local, replaces the built-in":"Local":`From ${Go(t.registry)}`}const Ou=e=>e.map(t=>/\s/.test(t)?JSON.stringify(t):t).join(" "),Dm=3;function DC(e,t){return e.length<=Math.max(t,Dm+1)?e:`${e.slice(0,Math.max(t-1,Dm)).trimEnd()}…`}function Zg(e){return e===qj?"Verified":`Verified by ${Go(e)}'s catalog`}function ev(e,t){return e.builtin?{text:"Built in",strong:!0}:e.verified?{text:Zg(t),strong:!0}:"Not reviewed"}function zC(e){var c,d;const t=(c=e.lock)==null?void 0:c.review;if(!t||e.status!=="active")return;if(!t.verified)return"Not reviewed";const s=t.reviewedBy.length>0?`Reviewed by ${t.reviewedBy.join(", ")}`:void 0,o=(d=e.lock)==null?void 0:d.source;return{text:o&&o!=="local"?Zg(o.registry):"Verified",strong:!0,tip:s}}var BC=pp();function tv(e){return R0(e.spec)?i.jsxs("span",{className:"guide-unknown",children:[i.jsx("span",{className:"t-body",children:"Unknown program: Teamtrail can't tell what this runs. Approve it only if you know what it does."}),i.jsxs(P,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!0),children:["I know what it runs: approve check ",e.name]})]}):i.jsxs(P,{size:"sm",disabled:e.busy,onClick:()=>e.onApprove(e.name,!1),children:["Approve check ",e.name]})}function FC(e){var x;const{preview:t}=e,{act:s,find:o}=jn(),[a,c]=y.useState({kind:"ready"}),[d,h]=y.useState(),m=t.entry.id,p=async()=>{h(void 0),c({kind:"adding"});try{c({kind:"added",pending:(await e.add(m,t.entry.sha256)).pendingChecks})}catch(S){h(S.message),c({kind:"ready"})}};if(t.entry.builtin)return i.jsxs("span",{className:"t-meta",children:["Built into ",te.name,": already available to every trail, nothing to add."]});if(a.kind!=="added"){const S=e.installed===t.entry.version,C=e.installed?"Update guide":"Add guide";return i.jsxs("div",{className:"add-guide",children:[!t.ok&&i.jsx("span",{className:"t-meta",children:"The lint found errors, so this guide can't be added."}),i.jsx(P,{variant:"primary",disabled:!t.ok||S||a.kind==="adding",onClick:()=>void p(),children:S?"Added":C}),d&&i.jsx("span",{className:"vf-err",children:d})]})}const v=((x=o(m))==null?void 0:x.pendingChecks)??a.pending,k=async(S,C)=>h(await s("/guides/checks/approve",{id:m,name:S,acknowledged:C}));return i.jsxs("div",{className:"add-guide",children:[i.jsx("p",{className:"t-body",children:v.length?`Added ${m} ${t.entry.version}. Approve each command it proposes; none runs until you do.`:`Added ${m} ${t.entry.version}. Agents get its instructions on tickets that ask for ${m}.`}),v.map(S=>{var C,j,I;return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[S,": ",Ou(((j=(C=t.guide)==null?void 0:C.proposedChecks[S])==null?void 0:j.run)??[])]}),i.jsx(tv,{name:S,spec:((I=t.guide)==null?void 0:I.proposedChecks[S])??{run:[]},onApprove:(b,R)=>void k(b,R)})]},S)}),d&&i.jsx("span",{className:"vf-err",children:d})]})}function UC(e){const t=i.jsx("p",{className:"t-meta",children:"The lint looks for common problems; it isn't a review. Read the guide before you approve it."});return e.findings.length?i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"vf-findings guide-findings",children:e.findings.map((s,o)=>i.jsxs("li",{className:`sev-${s.level}`,children:[i.jsxs("code",{className:"t-code",children:["line ",s.line]})," ",s.message," ",i.jsxs("span",{className:"t-meta",children:["(",s.rule,")"]})]},o))}),t]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-meta",children:"The lint found none of the problems it looks for."}),t]})}function nv(e){var o,a;const{p:t}=e,s=Object.entries(((o=t.guide)==null?void 0:o.proposedChecks)??{});return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"t-label",children:"Lint"}),i.jsx(UC,{findings:t.findings}),t.guide&&t.guide.checklist.length>0&&i.jsx("span",{className:"t-label",children:"Checklist"}),t.guide&&i.jsx("ul",{className:"catalog-checklist t-body",children:t.guide.checklist.map(c=>i.jsx("li",{children:c},c))}),s.length>0&&i.jsx("span",{className:"t-label",children:"Commands it proposes"}),s.map(([c,d])=>i.jsxs("code",{className:"t-code guide-check",children:[c,": ",Ou(d.run),d.cwd&&` (in ${d.cwd})`]},c)),i.jsx("span",{className:"t-label",children:"Instructions"}),i.jsx("pre",{className:"guide-preview",children:((a=t.guide)==null?void 0:a.instructions)??t.text})]})}function WC(e){const t=Zs(e.repo);if(!t)return null;const s=encodeURIComponent(`Report: ${e.id} ${e.version}`),o=`${t.replace(/\/+$/,"")}/issues/new?template=report-guide.yml&title=${s}`;return i.jsx("a",{className:"report-link t-meta",href:o,target:"_blank",rel:"noreferrer",children:"Report this guide"})}function HC(e){const t=e.entry,[s,o]=y.useState(),[a,c]=y.useState();return y.useEffect(()=>{e.preview(t.id).then(o,d=>c(d.message))},[t.id]),i.jsxs("div",{className:"catalog-entry",children:[i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onBack,children:"← All guides"}),i.jsx("h3",{className:"t-title",children:t.name??t.id}),i.jsx(V,{parts:[{text:t.id,code:!0},t.version,`by ${t.author}`,ev(t,e.catalogUrl),t.reviewedBy.length>0&&`reviewed by ${t.reviewedBy.join(", ")}`]}),i.jsx("p",{className:"t-body",children:t.summary}),t.history.length>0&&i.jsx("ul",{className:"catalog-history",children:t.history.map(d=>i.jsxs("li",{className:"t-meta",children:[d.version," · ",i.jsx("code",{className:"t-code",children:d.commit.slice(0,8)})," · ",d.at.slice(0,10)]},`${d.version}-${d.commit}`))}),a&&i.jsx("span",{className:"vf-err",children:a}),s&&i.jsx(nv,{p:s}),s&&i.jsx(WC,{repo:s.repo,id:t.id,version:t.version}),s&&i.jsx(FC,{preview:s,installed:e.installed,add:e.add})]})}function KC(e){const t=e.entry;return i.jsx("li",{className:"catalog-row","data-guide-id":t.id,children:i.jsx(Ce,{title:t.name??t.id,context:i.jsx(V,{parts:[{text:t.id,code:!0},t.version,t.author,ev(t,e.catalogUrl),t.reported&&"Reported"]}),detail:t.summary,trailing:e.installed&&`installed ${e.installed}`,onOpen:e.onOpen})})}const zm=e=>e?`registry=${encodeURIComponent(e)}`:"";function VC(e){const[t,s]=y.useState(),[o,a]=y.useState();y.useEffect(()=>{let h=!0;return s(void 0),a(void 0),Vo(`/guides/catalog?${zm(e)}`).then(m=>h&&s(m),m=>h&&a(m.message)),()=>{h=!1}},[e]);const c=y.useCallback(h=>Vo(`/guides/catalog/preview?${zm(e)}&id=${encodeURIComponent(h)}`),[e]),d=y.useCallback(async(h,m)=>{const p=await Yg("/guides/catalog/add",{registry:e,id:h,sha256:m});return Xg(p),p.installed},[e]);return{index:t,error:o,preview:c,add:d}}function GC(e){var j,I;const[t,s]=y.useState(((j=e.registries[0])==null?void 0:j.name)??""),o=VC(t||void 0),{find:a}=jn(),[c,d]=y.useState(""),[h,m]=y.useState(!0),[p,v]=y.useState(),k=o.index?L0({guides:o.index.guides},{query:c,verifiedOnly:h}):[],x=(I=o.index)==null?void 0:I.guides.find(b=>b.id===p),S=b=>{var R,O,U;return((R=a(b))==null?void 0:R.origin)==="local"?(U=(O=a(b))==null?void 0:O.guide)==null?void 0:U.version:void 0},C=e.registries.find(b=>b.name===t);return BC.createPortal(i.jsx("div",{className:"scrim catalog-scrim",onClick:b=>{b.stopPropagation(),e.onClose()},children:i.jsxs(ze,{as:"div",className:"dialog catalog-dialog",onClick:b=>b.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h3",{className:"t-title",children:"Guide catalog"}),e.registries.length>1&&i.jsx(dt,{compact:!0,"aria-label":"Catalog",value:t,options:e.registries.map(b=>({value:b.name,label:`${b.name} · ${Go(b.url)}`,hint:b.url})),onChange:s}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]}),C&&e.registries.length===1&&i.jsx(V,{parts:[`Catalog ${C.name}`,{text:Go(C.url),code:!0}]}),x?i.jsx(HC,{entry:x,catalogUrl:(C==null?void 0:C.url)??"",installed:S(x.id),preview:o.preview,add:o.add,onBack:()=>v(void 0)}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog-filters",children:[i.jsx("input",{className:"catalog-search",placeholder:"Search guides","aria-label":"Search guides",value:c,onChange:b=>d(b.target.value)}),i.jsx(P,{size:"sm",on:h,"aria-pressed":h,onClick:()=>m(b=>!b),children:"Verified only"})]}),o.error&&i.jsx("span",{className:"vf-err",children:o.error}),!o.index&&!o.error&&i.jsx(Ae,{children:"Reading the catalog…"}),o.index&&!k.length&&i.jsx(Ae,{children:"No guides match."}),i.jsx("ul",{className:"catalog-list",children:k.map(b=>i.jsx(KC,{entry:b,catalogUrl:(C==null?void 0:C.url)??"",installed:S(b.id),onOpen:()=>v(b.id)},b.id))})]})]})}),document.body)}function qC(e){const t=e.r.guide;if(!t)return null;const s=Object.entries(t.proposedChecks);if(!t.requiresChecks.length&&!s.length)return null;const o=e.r.status==="active";return i.jsxs("div",{className:"guide-checks",children:[t.requiresChecks.length>0&&i.jsxs("span",{className:"t-meta",children:["Adds checks ",i.jsx("code",{className:"t-code",children:t.requiresChecks.join(", ")})," to its tickets"]}),s.map(([a,c])=>{const d=e.r.pendingChecks.includes(a);return i.jsxs("span",{className:"guide-check",children:[i.jsxs("code",{className:"t-code",children:[a,": ",Ou(c.run)]}),d&&o&&i.jsx(tv,{name:a,spec:c,busy:e.busy,onApprove:e.onApprove}),d&&!o&&i.jsx("span",{className:"t-meta",children:"approve the guide first"}),!d&&i.jsx("span",{className:"t-meta",children:"approved"})]},a)})]})}function QC(e){const{r:t}=e;if(!t.guide||!t.sha256)return null;const s=t.sha256;return i.jsxs("div",{className:"guide-review",children:[i.jsx(nv,{p:{findings:t.findings,guide:t.guide}}),i.jsx(P,{size:"sm","aria-label":`Approve guide ${t.id}`,disabled:e.busy,onClick:()=>e.onApprove(s),children:"Approve"})]})}const YC="A file in guides/ replaces this built-in once you approve it; until then the built-in is used";function JC(e){var t,s;return e.override?YC:e.status==="unapproved"?(t=e.guide)==null?void 0:t.summary:e.reason??((s=e.guide)==null?void 0:s.summary)}function sv(e){const{r:t}=e,s=t.id,o=t.override??t,a=(o.status==="unapproved"||o.status==="tampered")&&!!o.guide,c=t.status!=="active"||t.pendingChecks.length>0||a,d=t.guide?`${t.guide.name} ${t.guide.version}`:s;return i.jsx("li",{className:"guide-row","data-guide-id":s,children:i.jsx(Ce,{edge:c?"attention":"neutral",title:d,context:i.jsx(V,{parts:[{text:s,code:!0},_C(t),zC(t),PC(t),t.guide&&XC(t.guide.checklist.length)]}),detail:JC(t),actions:t.origin==="local"&&i.jsxs(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:()=>e.onAct("/guides/remove",{id:s}),children:["Remove guide ",s]}),below:i.jsxs(i.Fragment,{children:[a&&i.jsx(QC,{r:o,busy:e.busy,onApprove:h=>e.onAct("/guides/approve",{id:s,sha256:h})}),i.jsx(qC,{r:t,busy:e.busy,onApprove:(h,m)=>e.onAct("/guides/checks/approve",{id:s,name:h,acknowledged:m})})]})})})}const XC=e=>e===1?"1 checklist item":`${e} checklist items`;function ZC(e){return i.jsxs(Ie,{title:"Write your own",children:[i.jsxs("p",{className:"vf-intro",children:["Write a guide for your team in your repo with ",i.jsxs("code",{className:"t-code",children:[te.slug," guides new <id>"]}),". It starts from a template in ",i.jsxs("code",{className:"t-code",children:[te.dataDir,"/guides/"]})," that passes the lint. Fill in the instructions and checklist, then approve it here: agents can only use it once you have, and again after every edit."]}),e.guides.length>0?i.jsx("ul",{className:"guides-list own-guides",children:e.guides.map(t=>i.jsx(sv,{r:t,busy:e.busy,onAct:e.onAct},t.id))}):i.jsx(Ae,{children:"No guides of your own yet."}),e.error&&i.jsx("span",{className:"vf-err",children:e.error}),i.jsxs("p",{className:"t-meta guides-share",children:["Useful beyond your team? Check it with ",i.jsxs("code",{className:"t-code",children:[te.slug," guides lint"]})," and"," ",i.jsx("a",{href:Qj,target:"_blank",rel:"noreferrer",children:"share it in the public catalog"}),"."]})]})}function e$(e){const{view:t,act:s}=jn(),[o,a]=y.useState(),[c,d]=y.useState(!1),[h,m]=y.useState(!1),p=y.useRef(null);if(y.useEffect(()=>{var x;e.focus&&t&&((x=p.current)==null||x.scrollIntoView({block:"start"}))},[e.focus,!!t]),!t)return null;const v=x=>(S,C)=>{d(!0),s(S,C).then(j=>{a(j?{own:x,message:j}:void 0),d(!1)})},k=x=>o&&o.own===x?o.message:void 0;return i.jsxs("div",{className:"guides-section",ref:p,children:[i.jsxs(Ie,{title:"Guides",children:[i.jsx("p",{className:"vf-intro",children:"Guides give an agent instructions and a checklist for the tickets that ask for them. A guide can add checks, never remove them, and its commands only run once you approve them."}),i.jsx("ul",{className:"guides-list",children:t.guides.filter(x=>!eu(x)).map(x=>i.jsx(sv,{r:x,busy:c,onAct:v(!1)},x.id))}),i.jsxs("div",{className:"guides-foot",children:[i.jsx(P,{size:"sm",onClick:()=>m(!0),children:"Browse guides"}),i.jsx(V,{parts:[{text:`${te.dataDir}/guides/`,code:!0},{text:"guides.lock.json",code:!0}]})]}),t.configErrors.length>0&&i.jsx("ul",{className:"vf-errors",children:t.configErrors.map(x=>i.jsx("li",{children:x},x))}),k(!1)&&i.jsx("span",{className:"vf-err",children:k(!1)})]}),i.jsx(ZC,{guides:t.guides.filter(eu),busy:c,onAct:v(!0),error:k(!0)}),h&&i.jsx(GC,{registries:t.registries,onClose:()=>m(!1)})]})}function t$(e){const{view:t,act:s}=jn(),[o,a]=y.useState();if(!t)return null;const c=e.map.guides??[],d=t.guides.filter(m=>m.status==="active"&&m.guide),h=m=>{const p=c.includes(m)?c.filter(v=>v!==m):[...c,m];a(void 0),s("/guides/team",{mapId:e.map.id,guides:p}).then(a)};return i.jsxs(Ie,{title:`Team of ${e.map.key}`,children:[i.jsx("p",{className:"vf-intro",children:"The guides this trail works with. With Reviewer on the team, review tickets come with the reviewer's instructions and checklist."}),i.jsx("div",{className:"team-guides",children:d.map(m=>{const p=c.includes(m.id);return i.jsx(P,{size:"sm",on:p,"aria-pressed":p,title:m.guide.summary,onClick:()=>h(m.id),children:m.guide.name},m.id)})}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function n$(e,t){const[s,o]=y.useState(),a=`/guides/checklist?mapId=${encodeURIComponent(e)}&ticketId=${encodeURIComponent(t)}`;return pt({view:a,load:()=>Vo(a),show:c=>o(c.checklist),failed:()=>o(null),changed:c=>c.endsWith("checklist.json")}),s}function s$(e){const t=n$(e.mapId,e.ticketId);if(!t)return null;const s=t.answers.filter(o=>!o.done).length;return i.jsxs("div",{className:"checklist-panel",children:[i.jsx(V,{parts:[`${t.guide.id} ${t.guide.version} checklist`,t.by,cr(t.at),s?`${s} not done`:"all done"]}),i.jsx(Gg,{answers:t.answers})]})}const Bm="";function i$(e){const{view:t,act:s}=jn(),[o,a]=y.useState();if(!t)return null;const c=e.ticket,d=t.guides.filter(p=>{var v;return p.status==="active"&&((v=p.guide)==null?void 0:v.handles.types.includes(c.type))}),h=[{value:Bm,label:"No guide"},...d.map(p=>({value:p.id,label:p.guide.name,hint:p.guide.summary}))];c.guide&&!d.some(p=>p.id===c.guide)&&h.push({value:c.guide,label:c.guide});const m=p=>{a(void 0),s("/guides/ticket",{mapId:e.mapId,ticketId:c.id,guide:p||null}).then(a)};return i.jsxs("span",{className:"guide-picker",children:[i.jsx(dt,{compact:!0,"aria-label":"Ticket guide",value:c.guide??Bm,options:h,onChange:m}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function r$(e){const{view:t,find:s}=jn();if(!t)return null;const o=s(e.id);if((o==null?void 0:o.status)==="active")return null;const a=o?o.reason??o.status:"it is not installed";return i.jsxs("p",{className:"guide-warning t-meta",children:["Guide ",e.id," can't be used: ",a,". Claims get no guide instructions until you approve it in Settings → Guides."]})}function o$(e){const{view:t}=jn(),s=e.ticket;return!t||s.state!=="open"&&!s.guide?null:i.jsxs("section",{className:"ticket-guide d-section",children:[i.jsxs("span",{className:"guide-head",children:[i.jsx("span",{className:"t-label",children:"Guide"}),s.state==="open"?i.jsx(i$,{mapId:e.mapId,ticket:s}):s.guide&&i.jsx(RC,{id:s.guide})]}),s.guide&&i.jsx(r$,{id:s.guide}),i.jsx(s$,{mapId:e.mapId,ticketId:s.id})]})}function a$(e){var m;const{view:t,find:s}=jn();if(!e)return;const o=s(e),a=t!=null&&(o==null?void 0:o.status)!=="active",c=((m=o==null?void 0:o.guide)==null?void 0:m.name)??e,d=o!=null&&o.guide?`${c} ${o.guide.version}`:c,h=a?`Guide ${d}: ${(o==null?void 0:o.reason)??"not installed"}`:`Guide: ${d}`;return{id:e,name:c,tip:h,off:a}}const iv="0.29.3-next.43",tu="<endpoint>",Pu=vp(iv,["mcp","--http"]);function l$(e,t){const s=vp(iv,["connect",e,"--url"]),o=t===tu?t:gp(t);return`read -rs ${te.tokenEnv} && export ${te.tokenEnv}
|
|
150
|
+
${s} ${o}`}function c$(e){return e.kind==="lookout"?["the Lookout","this machine only"]:["for remote agents",e.network?"open to your network":"this machine only, until a tunnel or proxy shares it"]}function u$({endpoints:e}){const t=e.some(s=>s.kind==="standalone");return i.jsxs("ul",{className:"ra-endpoints",children:[e.map(s=>i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:[{text:s.url,code:!0},...c$(s)]})},s.url)),!t&&i.jsx("li",{children:i.jsx(V,{className:"set-hint",parts:["For agents on other machines, start their server",{text:Pu,code:!0}]})})]})}function d$(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[c,d]=y.useState(),h=async m=>{if(!m.trim()||o)return;a(!0);const p=await e.onCreate(m).catch(v=>v.message);a(!1),d(p),p||s("")};return i.jsxs("div",{className:"ra-new",children:[i.jsx(ga,{value:t,onValueChange:s,onSubmit:h,action:"Create token",actionDisabled:o||!t.trim(),placeholder:"Name the agent, e.g. cloud sandbox 1","aria-label":"Agent name",maxLength:60}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function h$(){return i.jsx(Ie,{title:"Remote agents",children:i.jsxs("p",{className:"vf-intro",children:["Tokens for remote agents are created and revoked on the machine ",te.name," runs on. Open the Lookout there to manage them."]})})}function f$(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[c,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(m=>m.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"Its sessions end now."}),i.jsxs(P,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(P,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function m$(e){if(!e.tokens.length)return null;const t=Date.now();return i.jsx("ul",{className:"ra-list",children:e.tokens.map(s=>i.jsx(Ce,{as:"li",className:"ra-row",title:s.name,titleText:s.name,context:i.jsx(V,{parts:[`Created ${Ho(s.createdAt,t)}`,s.lastUsedAt?`Last used ${Ho(s.lastUsedAt,t)}`:"Never used"]}),below:i.jsx(f$,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function Ac(e){const[t,s]=y.useState(!1),o=()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(e.value).then(()=>{s(!0),setTimeout(()=>s(!1),1500)},()=>s(!1)))};return i.jsxs("div",{className:"ra-copy",children:[i.jsx("code",{className:"ra-copy-value t-code","aria-label":e.label,children:e.value}),i.jsx(P,{size:"sm",className:"ra-copy-btn",onClick:o,children:t?"Copied":e.copyLabel??"Copy"})]})}const p$=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex"}];function g$(e){const[t,s]=y.useState("claude");return i.jsxs("div",{className:"ra-reveal",role:"status",children:[i.jsxs("p",{className:"ra-reveal-title t-row-title",children:["Token for ",e.created.name]}),i.jsxs("p",{className:"t-body ra-note",children:["Copy it now. ",te.name," keeps only a fingerprint, so it can't show it again."]}),i.jsx(Ac,{label:"Token",value:e.created.token,copyLabel:"Copy token"}),!e.endpoint&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"ra-reveal-head",children:i.jsx(Ve,{children:"Start the server for remote agents"})}),i.jsx(Ac,{label:"Start command",value:Pu,copyLabel:"Copy command"})]}),i.jsxs("div",{className:"ra-reveal-head",children:[i.jsx(Ve,{children:"Run on the agent's machine"}),i.jsx("span",{className:"ra-clients",children:p$.map(o=>i.jsx(P,{size:"sm",on:t===o.id,"aria-pressed":t===o.id,onClick:()=>s(o.id),children:o.label},o.id))})]}),i.jsx(Ac,{label:"Connect command",value:l$(t,e.endpoint??tu),copyLabel:"Copy command"}),i.jsxs("p",{className:"t-meta ra-note",children:["The first line waits for the token: paste it and press Enter. It isn't shown, and it stays out of your shell history."," ",e.endpoint?"From another machine, use the address that machine reaches this one by.":`Put the address the server prints in place of ${tu}.`,t==="codex"&&` Start Codex from the same shell: it reads $${te.tokenEnv} each time.`]}),i.jsx("span",{children:i.jsx(P,{variant:"primary",size:"sm",onClick:e.onDone,children:"I've copied it"})})]})}const rv=`${je()}/remote-agents`;async function Fm(e,t){const s=await fetch(`${rv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json()}}async function v$(){const e=await fetch(rv);return e.ok?await e.json():(await e.json().catch(()=>({}))).elsewhere?"elsewhere":null}function k$(){const[e,t]=y.useState(),[s,o]=y.useState(),{pushed:a}=pt({load:v$,show:t,failed:()=>t(null),events:{"remote-agents":()=>!0}}),c=y.useCallback(m=>{a(),t({tokens:m.tokens,endpoints:m.endpoints})},[a]),d=y.useCallback(async m=>{const{ok:p,reply:v}=await Fm("/tokens",{name:m});if(!p||!v.token||!v.created)return v.error??"The token could not be created.";c(v),o({token:v.token,name:v.created.name})},[c]),h=y.useCallback(async m=>{const{ok:p,reply:v}=await Fm("/tokens/revoke",{id:m});return v.tokens&&c(v),p?void 0:v.error??"The token could not be revoked."},[c]);return{view:e,created:s,dismissCreated:()=>o(void 0),create:d,revoke:h}}function y$(){var d;const{view:e,created:t,dismissCreated:s,create:o,revoke:a}=k$();if(!e)return null;if(e==="elsewhere")return i.jsx(h$,{});const c=(d=e.endpoints.find(h=>h.kind==="standalone"))==null?void 0:d.url;return i.jsxs(Ie,{title:"Remote agents",children:[i.jsx("p",{className:"vf-intro",children:"Agents on another machine or in a cloud sandbox can work this repo's trails too. They connect over HTTP with a token and share the tickets, claims and inbox of the agents here. One token per agent; revoke it and that agent is out within about a second."}),i.jsx(u$,{endpoints:e.endpoints}),t&&i.jsx(g$,{created:t,endpoint:c,onDone:s}),i.jsx(m$,{tokens:e.tokens,onRevoke:a}),e.tokens.length===0&&i.jsx("p",{className:"t-meta ra-note",children:"No tokens, so the endpoint is closed: every request is refused."}),i.jsx(d$,{onCreate:o}),i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"Before you open it to other machines."})," The connection is plain HTTP. Run ",i.jsx("code",{children:Pu}),", which serves the agent tools and nothing else, and put that port behind HTTPS with a reverse proxy or a tunnel. The Lookout's own port is not for sharing: its agent endpoint answers this machine only. A token only ever opens the agent tools, never the Lookout, which signs in browsers, not agents."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What a remote agent can't do."})," Speak for you: it can't answer a question, skip discovery, change the trail's mode or destination, or close a ticket that needs you before you've answered here or in Slack. And its files aren't on this machine, so it gets no worktree, and on trails with verification its finished work comes to you to review instead of running the checks here."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"How far to trust one."})," The risk policy only sees what an agent declares: a call is held for you when the agent names a high-risk category or touches files your path rules cover. An agent that declares nothing isn't caught. Give an agent you don't fully trust only trails with verification on, where its finished work comes to you."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it does as you."})," With GitHub Issues or Linear as the tracker, everything a remote agent writes (tickets, comments, closing) goes to the tracker with your credentials, like the agents here."]})]})]})}const Um={schema:"Database schema","breaking-api":"Breaking API changes","auth-permissions":"Auth and permissions",billing:"Billing","data-deletion":"Deleting data","product-behaviour":"Product behaviour",dependencies:"Dependencies"},w$={low:"the agent decides",medium:"the agent decides and records it",high:"you decide"},x$=e=>e[0].toUpperCase()+e.slice(1),nu=Dp.map(e=>({value:e,label:x$(e),hint:w$[e]}));function j$(e){const[t,s]=y.useState(""),[o,a]=y.useState("high"),{rules:c,onChange:d}=e,h=()=>{const m=t.trim();!m||c.some(p=>p.glob===m)||(d([...c,{glob:m,level:o}]),s(""))};return i.jsxs("div",{className:"risk-paths",children:[i.jsx("span",{className:"mono-label",children:"Files"}),c.map((m,p)=>i.jsxs("div",{className:"risk-row",children:[i.jsx("code",{children:m.glob}),i.jsx(dt,{compact:!0,"aria-label":`${m.glob} risk`,value:m.level,options:nu,onChange:v=>d(c.map((k,x)=>x===p?{...k,level:v}:k))}),i.jsx("button",{className:"icon-btn","aria-label":`Remove ${m.glob}`,onClick:()=>d(c.filter((v,k)=>k!==p)),children:"×"})]},m.glob)),i.jsxs("div",{className:"risk-row",children:[i.jsx("input",{value:t,placeholder:"src/payments/**","aria-label":"New file pattern",onChange:m=>s(m.target.value),onKeyDown:m=>m.key==="Enter"&&h()}),i.jsx(dt,{compact:!0,"aria-label":"New pattern risk",value:o,options:nu,onChange:a}),i.jsx(P,{onClick:h,disabled:!t.trim(),children:"Add"})]})]})}const ov=`${je()}/policy`;async function S$(){const e=await fetch(ov);return e.ok?await e.json():null}function N$(){const[e,t]=y.useState(),{pushed:s}=pt({load:S$,show:t,failed:()=>t(null),changed:a=>a.endsWith("policy.json")}),o=y.useCallback(async a=>{const c=await fetch(ov,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),d=await c.json();if(!c.ok)return d.error??`Saving failed (${c.status})`;s(),t(d)},[s]);return{view:e,save:o}}function b$(){const{view:e,save:t}=N$(),[s,o]=y.useState();if(!e)return null;const a=`${te.dataDir}/policy.json`,c=d=>{o(void 0),t(d).then(o,h=>o(h.message))};return i.jsxs(Ie,{title:"Risk policy",children:[i.jsx("p",{className:"vf-intro",children:"What agents may decide on their own. High: they must ask you. Medium: they decide, follow your conventions and record it for you to review. Low: they just decide."}),i.jsx("div",{className:"risk-grid",children:_p.map(d=>i.jsxs("label",{className:"risk-row",children:[i.jsx("span",{children:Um[d]}),i.jsx(dt,{compact:!0,"aria-label":`${Um[d]} risk`,value:e.policy.categories[d],options:nu,onChange:h=>c({...e.policy,categories:{...e.policy.categories,[d]:h}})})]},d))}),i.jsx(j$,{rules:e.policy.paths,onChange:d=>c({...e.policy,paths:d})}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[a," has errors, so the defaults apply until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(d=>i.jsx("li",{children:d},d))})]}),e.defaults&&e.errors.length===0&&i.jsxs("span",{className:"set-hint t-meta",children:["Defaults. Changing anything saves ",a,", so your team shares it."]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const su=`${je()}/workspaces`;async function C$(){const e=await fetch(su);return e.ok?await e.json():null}function av(){const[e,t]=y.useState(),{pushed:s}=pt({load:C$,show:t,failed:()=>t(null),changed:d=>d.endsWith("workspaces.json")||d.includes("workspaces/")||d.includes("leases/")}),o=y.useCallback(d=>{s(),t(d)},[s]),a=y.useCallback(async d=>{const h=await fetch(su,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),m=await h.json();if(!h.ok)return m.error??`Saving failed (${h.status})`;o(m)},[o]),c=y.useCallback(async(d,h,m=!1)=>{const p=await fetch(`${su}/remove`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:d,ticketId:h,force:m})}),v=await p.json();return p.ok?(o(v),{}):{error:v.error??`Removing failed (${p.status})`,dirty:v.dirty??!1}},[o]);return{view:e,save:a,remove:c}}function lv(e){const[t,s]=y.useState(!1),[o,a]=y.useState(),[c,d]=y.useState(!1),h=async m=>{d(!0),a(void 0);const p=await e.onRemove(m).catch(v=>({error:v.message,dirty:!1}));d(!1),s(!!p.dirty&&!m),p.dirty||a(p.error)};return t?i.jsxs("span",{className:"ws-remove ask",children:[i.jsx("span",{className:"vf-err",children:"Uncommitted changes in this workspace will be lost."}),i.jsx(P,{size:"sm",disabled:c,onClick:()=>h(!0),children:"Remove anyway"}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ws-remove",children:[i.jsx(P,{size:"sm",disabled:c,onClick:()=>h(!1),children:e.label??"Remove"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}function $$(e){return e.rows.length?i.jsx("ul",{className:"ws-list",children:e.rows.map(t=>i.jsx(Ce,{as:"li",className:`ws-row ${t.active?"active":"finished"}`,title:i.jsx("span",{className:"t-code",children:t.branch}),titleText:t.branch,context:i.jsx(V,{parts:[{text:t.ticketKey,code:!0},t.active?`Active · ${t.agent}`:"Finished"]}),detail:i.jsx("span",{className:"t-code",children:t.path}),detailText:t.path,below:t.active?void 0:i.jsx(lv,{onRemove:s=>e.onRemove(t.mapId,t.ticketId,s)})},`${t.mapId}/${t.ticketId}`))}):null}function T$(e){const{view:t,remove:s}=av(),o=t==null?void 0:t.workspaces.find(a=>a.mapId===e.mapId&&a.ticketId===e.ticketId);return!o||o.active?null:i.jsxs("section",{className:"ticket-workspace d-section",children:[i.jsx("span",{className:"t-label",children:"Workspace"}),i.jsxs("p",{className:"t-meta",children:["Branch ",i.jsx("code",{className:"t-code",children:o.branch})," in"," ",i.jsx("code",{className:"t-code",title:o.path,children:o.path})]}),i.jsx(lv,{label:"Remove workspace",onRemove:a=>s(e.mapId,e.ticketId,a)})]})}function E$(){const{view:e,save:t,remove:s}=av(),[o,a]=y.useState();if(!e)return null;const c=e.settings.worktrees,d=()=>{a(void 0),t({...e.settings,worktrees:!c}).then(a,h=>a(h.message))};return i.jsxs(Ie,{title:"Workspaces",children:[i.jsxs("p",{className:"vf-intro",children:["Give each agent its own copy of the repo for every ticket it claims, on its own branch, so agents working at the same time don't step on each other. You review and merge the branches; ",te.name," never merges or pushes."]}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"A worktree per ticket"}),i.jsx(P,{size:"sm",on:c,"aria-pressed":c,className:"worktrees-toggle",onClick:d,children:c?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${te.dataDir}/workspaces.json`,code:!0},Wm(e.workspaces.filter(h=>h.active).length,"active"),Wm(e.workspaces.filter(h=>!h.active).length,"finished")]}),i.jsx($$,{rows:e.workspaces,onRemove:s}),e.errors.length>0&&i.jsx("ul",{className:"vf-errors",children:e.errors.map(h=>i.jsx("li",{children:h},h))}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Wm=(e,t)=>`${e} ${t}`;function A$({data:e,route:t}){return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"approvals",storage:"machine",children:i.jsx(AC,{})}),i.jsx(Qe,{id:"tracker",children:i.jsx(Ie,{title:"Tracker",children:i.jsx(Xb,{activeTracker:e.activeTracker,location:e.location,update:e.update})})}),i.jsx(Qe,{id:"workspaces",storage:"repo",children:i.jsx(E$,{})}),i.jsx(Qe,{id:"remote-agents",storage:"machine",children:i.jsx(y$,{})}),i.jsx(Qe,{id:"policy",storage:"repo",children:i.jsx(b$,{})}),i.jsx(Qe,{id:"guides",storage:"repo",children:i.jsx(e$,{focus:t.section==="guides"})}),i.jsx(Qe,{id:"labels",children:i.jsx(Ie,{title:"Labels",children:i.jsxs("div",{className:"label-codes",children:[i.jsx("code",{children:lu}),i.jsxs("code",{children:[te.labelPrefix,":<type>"]}),i.jsx("code",{children:cu}),i.jsx("code",{children:uu})]})})})]})}const iu=`${te.apiPrefix}/projects`;async function Io(e,t,s){const o=await fetch(`${iu}${e}`,{method:t,headers:{"Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)}),a=await o.json().catch(()=>({}));if(!o.ok)throw new Error(a.error??`HTTP ${o.status}`);return a}const Js={url:iu,add:e=>Io("","POST",{path:e}),remove:e=>Io(`/${e}`,"DELETE"),setAutoRegister:e=>Io("/settings","PUT",{autoRegister:e}),answer:(e,t)=>Io(`/${e}/answer`,"POST",t),async briefing(e){const t=await fetch(`${iu}/briefing?since=${e}`);return t.ok?await t.json():void 0}};function cv(e){const[t,s]=y.useState(""),[o,a]=y.useState(),c=d=>{d.trim()&&(a(void 0),Js.add(d.trim()).then(()=>(s(""),e.onAdded()),h=>a(h.message)))};return i.jsxs("div",{className:"pj-add",children:[i.jsx(ga,{value:t,onValueChange:s,onSubmit:c,action:"Add project",placeholder:`/path/to/repo (a ${te.dataDir} folder is created if missing)`,"aria-label":"Repo path",className:"t-code"}),o&&i.jsx("span",{className:"vf-err",children:o})]})}const Fs=(e,t)=>e>0&&`${e} ${t}`;function I$(e){var s;const t=((s=e.briefing)==null?void 0:s.projects)??[];return!e.briefing||!t.length?null:i.jsxs("section",{className:"pj-section pj-briefing",children:[i.jsx(Et,{title:"While you were away",count:t.length,info:`What changed in each project since ${dn(e.now-e.briefing.since)} ago`}),i.jsx("ul",{className:"pj-list",children:t.map(({projectId:o,project:a,briefing:c})=>i.jsx(Ce,{as:"li",edge:c.totals.waiting>0?"attention":"neutral",title:a,context:i.jsx(V,{parts:[Fs(c.totals.done,"done"),Fs(c.trails.reduce((d,h)=>d+h.opened.length,0),"new tickets"),Fs(c.totals.agentDecisions,"agent decisions"),Fs(c.totals.waiting,"waiting on you"),Fs(c.totals.ruledOut,"ruled out"),Fs(c.totals.active,"agents active")]}),onOpen:()=>e.onOpen(o)},o))})]})}function M$(e){const[t,s]=y.useState(""),[o,a]=y.useState(!1),[c,d]=y.useState(),h=m=>{!m.trim()||o||(a(!0),d(void 0),e.onAnswer(m.trim()).then(()=>s(""),p=>d(p.message)).finally(()=>a(!1)))};return i.jsxs("div",{className:"pj-answer",children:[i.jsx(ga,{value:t,onValueChange:s,onSubmit:h,action:"Answer",disabled:o,placeholder:"Your answer","aria-label":"Your answer"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}function R$(e){const{item:t}=e,s=Ag(t),o=t.kind==="question"&&t.agent?`${t.agent} asks`:Tg[t.kind],a=t.urgency==="blocking"&&{text:"Blocking",urgent:!0,className:"urgency-tag"};return i.jsx(Ce,{as:"li",className:`att-item pj-item k-${t.kind}`,edge:Eg(t,t.interrupting),title:t.title.split(`
|
|
151
151
|
`)[0],titleText:t.title,context:i.jsx(V,{parts:[a,{text:t.project,strong:!0},o]}),detail:s.length>0&&s.join(" · "),detailText:s.join(`
|
|
152
|
-
`),trailing:dn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(I$,{onAnswer:e.onAnswer})})}function R$(e){const t=e.view.attention,s=o=>{var a;return((a=e.view.projects.find(c=>c.id===o))==null?void 0:a.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(Et,{title:"Needs you",count:t.length,hot:t.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),t.length===0&&i.jsx(Qn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(M$,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&s(o.projectId)?a=>Js.answer(o.projectId,{questionId:o.ref,text:a}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Ic=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function L$(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function O$(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const t=[];e.needsYou&&t.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&t.push(Ic(e.agents,"agent"));const{working:s,verifying:o,rework:a,blocked:c}=e.phases;s&&t.push(`${s} working`),o&&t.push(`${o} verifying`),a&&t.push(`${a} rework`),c&&t.push(`${c} blocked`),e.flags&&t.push(Ic(e.flags,"PR flag")),e.stalled&&t.push(Ic(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=P$(e.tracker);return d&&t.push(d),t}function P$(e){if(e.kind==="github"&&e.repo)return`Issues in ${e.repo}`;if(!(e.kind!=="linear"||!e.team))return e.org?`Linear: ${e.team} in ${e.org}`:`Linear: ${e.team}`}function _$(e){var t;return e.state.kind==="elsewhere"?e.state.url?`Served by another Lookout · ${e.state.url}`:"Served by another Teamtrail on this machine":((t=e.top)==null?void 0:t.title)??e.note??e.path}function qo(e,t,s){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=e.state.url?Zs(e.state.url):void 0;if(!o)return;const a=new URL(o);s&&a.searchParams.set(Gs,s),window.open(a.toString(),"_blank","noopener");return}location.href=fS({id:e.id,home:t,tracker:e.tracker.kind,item:s})}}function uv(e){const{p:t}=e,s=_$(t);return i.jsx(Ce,{as:"li",className:`project-card st-${t.state.kind}`,edge:L$(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(V,{parts:O$(t)}),detail:s,detailText:s,trailing:t.lastActivity?dn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const dv=`${Xo}:projects:seen`,Hm=24*36e5;function D$(e){try{const t=Number(localStorage.getItem(dv));return t>0?t:e-Hm}catch{return e-Hm}}function z$(e){try{localStorage.setItem(dv,String(e))}catch{}}function B$(){const[e,t]=y.useState();return y.useEffect(()=>{const s=Date.now();return Js.briefing(D$(s)).then(t).catch(()=>{}),()=>z$(s)},[]),e}function F$(e){const{view:t,reload:s}=e.projects,o=Yt(15e3),a=B$();if(y.useEffect(()=>{const m=p=>p.key==="Escape"&&e.onClose();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e]),!t)return null;const c=lr()??t.home,d=m=>{const p=t.projects.find(v=>v.id===m);(p==null?void 0:p.id)===c?e.onClose():p&&qo(p,t.home)},h=(m,p)=>{const v=t.projects.find(k=>k.id===m);if(v){if(v.id!==c)return qo(v,t.home,p);e.onClose(),e.onItemHere(p)}};return i.jsxs(ze,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ve,{as:"h2",children:"All projects"}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"pj-body",children:[i.jsx(R$,{view:t,now:o,onOpen:h,onAnswered:s}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Et,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:t.projects.map(m=>i.jsx(uv,{p:m,current:m.id===c,now:o,onOpen:m.state.kind==="missing"?void 0:()=>d(m.id)},m.id))}),i.jsx(cv,{onAdded:s})]}),i.jsx(A$,{briefing:a,now:o,onOpen:d})]})]})}function U$(e){const[t,s]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const h=m=>{var p;(m instanceof KeyboardEvent?m.key==="Escape":!((p=o.current)!=null&&p.contains(m.target)))&&s(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[t]);const{view:a}=e.projects;if(!a||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const c=lr()??a.home,d=a.projects.filter(h=>h.id!==c).reduce((h,m)=>h+m.interrupting,0);return i.jsxs("div",{className:"project-switcher",ref:o,children:[i.jsxs("button",{className:"project-btn repo",onClick:()=>s(h=>!h),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(ds,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{s(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(ds,{n:a.attention.length,urgent:a.attention.some(h=>h.interrupting),hideZero:!0})]}),i.jsx(Ve,{variant:"plain",className:"menu-h",children:"Projects"}),a.projects.map(h=>i.jsxs("button",{role:"menuitem",className:`trail-item ${h.id===c?"on":""} st-${h.state.kind}`,disabled:h.state.kind==="missing",onClick:()=>{s(!1),h.id!==c&&qo(h,a.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:W$(h.state.kind)}),i.jsx(ds,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function W$(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function H$(e){const t=Yt(15e3),{view:s}=e.projects;if(!s||!e.projects.many)return null;const o=lr()??s.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Et,{title:"Projects",count:s.projects.length,right:i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),i.jsx("ul",{className:"pj-list",children:s.projects.filter(a=>a.id!==o).map(a=>i.jsx(uv,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>qo(a,s.home)},a.id))})]})}async function K$(){const e=await fetch(Js.url);return e.ok?await e.json():void 0}function hv(){const[e,t]=y.useState(),{reload:s,pushed:o}=pt({load:K$,show:a=>a&&t(a)});return y.useEffect(()=>ti("projects",a=>{o(),t(JSON.parse(a))}),[o]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:s}}const V$=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function G$(){const{view:e,reload:t}=hv(),[s,o]=y.useState();if(!e)return null;const a=c=>{o(void 0),c.then(t,d=>o(d.message))};return i.jsxs(Ie,{title:"Projects",children:[i.jsx("p",{className:"vf-intro",children:"Supervise several repos from this Lookout: All projects shows what needs you in each of them. The list lives in your config folder on this machine, never in a repo, and agents only ever work in their own repo."}),i.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(c=>i.jsx(Ce,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:i.jsx(V,{parts:V$(c)}),actions:!c.home&&i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>a(Js.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(cv,{onAdded:t}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(P,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>a(Js.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${te.slug} projects add <path>`,code:!0},`--no-register or ${te.noRegisterEnv} opts one agent out`]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const q$=`${te.apiPrefix}/models`;async function Q$(){const e=await fetch(q$);return e.ok?await e.json():null}function _u(){const[e,t]=y.useState();return pt({load:Q$,show:t,failed:()=>t(null),changed:s=>s.endsWith("models.json")||s.endsWith("map.md")||s.includes("/tickets/"),events:{attention:()=>!0}}),e}function Y$({mapId:e,ticketId:t}){const s=_u(),o=s==null?void 0:s.waiting.find(a=>a.mapId===e&&a.ticketId===t);return o?i.jsx(Ce,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(V,{parts:[`Connected agents run ${o.best} at most`]}),detail:`Connect an agent on a ${o.tier} model, or have one claim ${o.ticketKey} by key.`}):null}function J$({view:e}){if(!e)return null;const t=`${te.dataDir}/${e.file}`,s=Object.keys(e.models).length,o=e.agents.map(a=>`${a.agent} ${a.tier}`).join(", ");return i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${s} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(V,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(a=>i.jsx("li",{children:a},a))})]})]})}const fv={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},X$={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},Z$=Po.map(e=>({value:e,label:fv[e],hint:X$[e]}));function eT(e){return i.jsx("div",{className:"tier-grid",children:ea.map(t=>{const s=e.tiers[t],o=hu[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:nr[t]}),i.jsx(dt,{compact:!0,"aria-label":`${nr[t]} tickets' model`,className:`tier-select tier-${t}`,value:s,options:Z$,onChange:a=>e.onChange(t,a)}),i.jsx(V,{className:"tier-hint",parts:[s!==o&&`default ${fv[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const Mo=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function tT({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(t=>i.jsx(Ce,{as:"li",className:"perf-row",title:t.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:ln(t.medianLeadMs)}),context:i.jsx(V,{parts:[`${t.done} of ${Mo(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,Mo(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&Mo(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${Mo(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ae,{children:"No claimed tickets yet"})}function mv(e){const[t,s]=y.useState({}),o=e.map(a=>`${a.map.id}:${a.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return y.useEffect(()=>{let a=!0;return Promise.all(e.map(async c=>{const d=await fetch(`${je()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),h=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,h.entries]})).then(c=>{a&&s(Object.fromEntries(c))}),()=>{a=!1}},[o]),t}const nT=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function sT({api:e,bp:t,onClose:s}){const[o,a]=y.useState("byVendor"),c=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=mv(c),h=e.activity.answered,m=y.useMemo(()=>Vp(c.map(p=>({snap:p,journal:d[p.map.id]??[],answered:h}))),[c,d,h]);return y.useEffect(()=>{const p=v=>v.key==="Escape"&&s();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[s]),i.jsxs(ze,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ve,{as:"h2",children:"Trail stats"}),i.jsx(V,{parts:[`${m.trails} trails`,`${m.tickets} tickets`]}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:s,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"perf-body",children:[i.jsxs("section",{className:"perf-section",children:[i.jsx(Ve,{as:"h3",children:"What stands out"}),i.jsx("p",{className:"perf-note t-meta",children:"From your own numbers, for you to act on or ignore. Teamtrail doesn't route work from these."}),m.recommendations.length?i.jsx("ul",{className:"perf-recs",children:m.recommendations.map(p=>i.jsxs("li",{title:p.because,children:[i.jsx("span",{children:p.text}),i.jsx("span",{className:"t-meta",children:p.because})]},p.id))}):i.jsx(Ae,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),i.jsxs("section",{className:"perf-section",children:[i.jsx("div",{className:"choice-row compact",children:nT.map(p=>i.jsx(mt,{on:o===p.id,title:p.title,onClick:()=>a(p.id)},p.id))}),i.jsx(tT,{rows:m[o]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function iT(e,t){const s=mv(e);return y.useMemo(()=>{var c;const o=Vp(e.map(d=>({snap:d,journal:s[d.map.id]??[],answered:t}))),a={};for(const d of o.byType){if(!d.done)continue;const h=(c=o.recommendations.find(p=>p.id===`speed-${d.key}`))==null?void 0:c.text,m=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${ln(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];a[d.key]=m.filter(Boolean).join(" · ")}return a},[e,s,t])}function rT(e){var d,h;const t=_u(),s=iT(e.snaps,e.answered),o=e.map;if(!o)return null;const a=!!((d=o.modelMatching)!=null&&d.enabled),c=((h=o.modelMatching)==null?void 0:h.tiers)??{};return i.jsxs(Ie,{title:"Model matching",children:[i.jsx("p",{className:"vf-intro",children:"Give each agent the tickets that fit the model it runs on: research to fast models, junctions, prototypes and reviews to the strongest. Teamtrail reads the model from the agent's log and never switches it. An agent can still claim any ticket by name, and tells you when it does."}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",o.key]}),i.jsx(P,{size:"sm",on:a,"aria-pressed":a,className:"model-matching-toggle",onClick:()=>e.onChange({...o.modelMatching,enabled:!a}),children:a?"On":"Off"})]}),a&&i.jsx(eT,{tiers:qy(o),hints:s,onChange:(m,p)=>{const v={...c,[m]:p};p===hu[m]&&delete v[m],e.onChange({enabled:!0,tiers:v})}}),a&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(J$,{view:t})]})}function Xi(e,t){const s=new URL(e);return s.searchParams.delete("settings"),t&&s.searchParams.set("settings",t.section??t.group??""),s.toString()}async function oT(){const e=await fetch(`${je()}/verification/config`);return e.ok?await e.json():null}function aT(){const[e,t]=y.useState();return pt({load:oT,show:t,failed:()=>t(null),changed:s=>s.endsWith("verification.json"),events:{attention:()=>!0}}),e}const Km=`{
|
|
152
|
+
`),trailing:dn(e.now-t.since),onOpen:e.onOpen,below:e.onAnswer&&i.jsx(M$,{onAnswer:e.onAnswer})})}function L$(e){const t=e.view.attention,s=o=>{var a;return((a=e.view.projects.find(c=>c.id===o))==null?void 0:a.state.kind)!=="missing"};return i.jsxs("section",{className:"pj-section pj-attention",children:[i.jsx(Et,{title:"Needs you",count:t.length,hot:t.some(o=>o.interrupting),info:"One queue across projects, ranked the way each project ranks its own. Answer questions here; the agent in that repo gets the answer."}),t.length===0&&i.jsx(Qn,{title:"Nothing needs you",hint:"Agents in every project can keep going."}),i.jsx("ul",{className:"pj-list",children:t.map(o=>i.jsx(R$,{item:o,now:e.now,onOpen:()=>e.onOpen(o.projectId,o.id),onAnswer:o.kind==="question"&&s(o.projectId)?a=>Js.answer(o.projectId,{questionId:o.ref,text:a}).then(e.onAnswered):void 0},`${o.projectId}/${o.id}`))})]})}const Ic=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function O$(e){return e.interrupting>0?"urgent":e.phases.blocked+e.phases.rework+e.flags+e.stalled>0||e.state.kind==="missing"?"attention":"neutral"}function P$(e){if(e.state.kind==="missing")return[{text:"Missing",strong:!0},{text:e.path,code:!0}];const t=[];e.needsYou&&t.push({text:`${e.needsYou} ${e.needsYou===1?"needs":"need"} you`,strong:!0,urgent:e.interrupting>0}),e.agents&&t.push(Ic(e.agents,"agent"));const{working:s,verifying:o,rework:a,blocked:c}=e.phases;s&&t.push(`${s} working`),o&&t.push(`${o} verifying`),a&&t.push(`${a} rework`),c&&t.push(`${c} blocked`),e.flags&&t.push(Ic(e.flags,"PR flag")),e.stalled&&t.push(Ic(e.stalled,"stalled claim")),t.length||t.push(e.trails?"Nothing waiting":"No trails yet");const d=_$(e.tracker);return d&&t.push(d),t}function _$(e){if(e.kind==="github"&&e.repo)return`Issues in ${e.repo}`;if(!(e.kind!=="linear"||!e.team))return e.org?`Linear: ${e.team} in ${e.org}`:`Linear: ${e.team}`}function D$(e){var t;return e.state.kind==="elsewhere"?e.state.url?`Served by another Lookout · ${e.state.url}`:"Served by another Teamtrail on this machine":((t=e.top)==null?void 0:t.title)??e.note??e.path}function qo(e,t,s){if(e.state.kind!=="missing"){if(e.state.kind==="elsewhere"){const o=e.state.url?Zs(e.state.url):void 0;if(!o)return;const a=new URL(o);s&&a.searchParams.set(Gs,s),window.open(a.toString(),"_blank","noopener");return}location.href=fS({id:e.id,home:t,tracker:e.tracker.kind,item:s})}}function uv(e){const{p:t}=e,s=D$(t);return i.jsx(Ce,{as:"li",className:`project-card st-${t.state.kind}`,edge:O$(t),selected:e.current,title:t.name,titleText:t.path,context:i.jsx(V,{parts:P$(t)}),detail:s,detailText:s,trailing:t.lastActivity?dn(e.now-t.lastActivity):void 0,onOpen:e.onOpen})}const dv=`${Xo}:projects:seen`,Hm=24*36e5;function z$(e){try{const t=Number(localStorage.getItem(dv));return t>0?t:e-Hm}catch{return e-Hm}}function B$(e){try{localStorage.setItem(dv,String(e))}catch{}}function F$(){const[e,t]=y.useState();return y.useEffect(()=>{const s=Date.now();return Js.briefing(z$(s)).then(t).catch(()=>{}),()=>B$(s)},[]),e}function U$(e){const{view:t,reload:s}=e.projects,o=Yt(15e3),a=F$();if(y.useEffect(()=>{const m=p=>p.key==="Escape"&&e.onClose();return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e]),!t)return null;const c=lr()??t.home,d=m=>{const p=t.projects.find(v=>v.id===m);(p==null?void 0:p.id)===c?e.onClose():p&&qo(p,t.home)},h=(m,p)=>{const v=t.projects.find(k=>k.id===m);if(v){if(v.id!==c)return qo(v,t.home,p);e.onClose(),e.onItemHere(p)}};return i.jsxs(ze,{className:`zone decisions-view projects-view dv-${e.bp}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ve,{as:"h2",children:"All projects"}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"pj-body",children:[i.jsx(L$,{view:t,now:o,onOpen:h,onAnswered:s}),i.jsxs("section",{className:"pj-section pj-projects",children:[i.jsx(Et,{title:"Projects",count:t.projects.length,info:"Each repo registered on this machine, read from its own files. Nothing leaves your machine."}),i.jsx("ul",{className:"pj-list",children:t.projects.map(m=>i.jsx(uv,{p:m,current:m.id===c,now:o,onOpen:m.state.kind==="missing"?void 0:()=>d(m.id)},m.id))}),i.jsx(cv,{onAdded:s})]}),i.jsx(I$,{briefing:a,now:o,onOpen:d})]})]})}function W$(e){const[t,s]=y.useState(!1),o=y.useRef(null);y.useEffect(()=>{if(!t)return;const h=m=>{var p;(m instanceof KeyboardEvent?m.key==="Escape":!((p=o.current)!=null&&p.contains(m.target)))&&s(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",h)}},[t]);const{view:a}=e.projects;if(!a||!e.projects.many)return i.jsx("span",{className:"repo",children:e.repo});const c=lr()??a.home,d=a.projects.filter(h=>h.id!==c).reduce((h,m)=>h+m.interrupting,0);return i.jsxs("div",{className:"project-switcher",ref:o,children:[i.jsxs("button",{className:"project-btn repo",onClick:()=>s(h=>!h),"aria-haspopup":"menu","aria-expanded":t,"data-tip":"Switch project, or see all of them",children:[i.jsx("span",{className:"project-name",children:e.repo}),d>0&&i.jsx(ds,{n:d,urgent:!0}),i.jsx("span",{className:"caret",children:"▾"})]}),t&&i.jsxs("div",{className:"trail-menu",role:"menu",children:[i.jsxs("button",{role:"menuitem",className:"trail-item all-projects",onClick:()=>{s(!1),e.onOverview()},children:[i.jsx("span",{className:"mi-title",children:"All projects"}),i.jsx(ds,{n:a.attention.length,urgent:a.attention.some(h=>h.interrupting),hideZero:!0})]}),i.jsx(Ve,{variant:"plain",className:"menu-h",children:"Projects"}),a.projects.map(h=>i.jsxs("button",{role:"menuitem",className:`trail-item ${h.id===c?"on":""} st-${h.state.kind}`,disabled:h.state.kind==="missing",onClick:()=>{s(!1),h.id!==c&&qo(h,a.home)},children:[i.jsx("span",{className:"mi-title",children:h.name}),i.jsx("span",{className:"mi-progress",children:H$(h.state.kind)}),i.jsx(ds,{n:h.needsYou,urgent:h.interrupting>0,hideZero:!0})]},h.id))]})]})}function H$(e){return e==="missing"?"missing":e==="elsewhere"?"other Lookout":""}function K$(e){const t=Yt(15e3),{view:s}=e.projects;if(!s||!e.projects.many)return null;const o=lr()??s.home;return i.jsxs("section",{className:"phone-projects",children:[i.jsx(Et,{title:"Projects",count:s.projects.length,right:i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onOverview,children:"All projects"})}),i.jsx("ul",{className:"pj-list",children:s.projects.filter(a=>a.id!==o).map(a=>i.jsx(uv,{p:a,current:!1,now:t,onOpen:a.state.kind==="missing"?void 0:()=>qo(a,s.home)},a.id))})]})}async function V$(){const e=await fetch(Js.url);return e.ok?await e.json():void 0}function hv(){const[e,t]=y.useState(),{reload:s,pushed:o}=pt({load:V$,show:a=>a&&t(a)});return y.useEffect(()=>ti("projects",a=>{o(),t(JSON.parse(a))}),[o]),{view:e,many:((e==null?void 0:e.projects.length)??0)>1,reload:s}}const G$=e=>[e.home&&{text:"This Lookout",strong:!0},e.state.kind==="missing"&&"Missing",{text:e.path,code:!0}];function q$(){const{view:e,reload:t}=hv(),[s,o]=y.useState();if(!e)return null;const a=c=>{o(void 0),c.then(t,d=>o(d.message))};return i.jsxs(Ie,{title:"Projects",children:[i.jsx("p",{className:"vf-intro",children:"Supervise several repos from this Lookout: All projects shows what needs you in each of them. The list lives in your config folder on this machine, never in a repo, and agents only ever work in their own repo."}),i.jsx("ul",{className:"pj-list set-projects",children:e.projects.map(c=>i.jsx(Ce,{as:"li",edge:c.state.kind==="missing"?"attention":"neutral",title:c.name,context:i.jsx(V,{parts:G$(c)}),actions:!c.home&&i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>a(Js.remove(c.id)),children:"Remove"})},c.id))}),i.jsx(cv,{onAdded:t}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsx("span",{className:"set-field-label",children:"Agents add their repo when they connect"}),i.jsx(P,{size:"sm",on:e.autoRegister,"aria-pressed":e.autoRegister,className:"auto-register-toggle",onClick:()=>a(Js.setAutoRegister(!e.autoRegister)),children:e.autoRegister?"On":"Off"})]}),i.jsx(V,{className:"set-hint",parts:[{text:`${te.slug} projects add <path>`,code:!0},`--no-register or ${te.noRegisterEnv} opts one agent out`]}),s&&i.jsx("span",{className:"vf-err",children:s})]})}const Q$=`${te.apiPrefix}/models`;async function Y$(){const e=await fetch(Q$);return e.ok?await e.json():null}function _u(){const[e,t]=y.useState();return pt({load:Y$,show:t,failed:()=>t(null),changed:s=>s.endsWith("models.json")||s.endsWith("map.md")||s.includes("/tickets/"),events:{attention:()=>!0}}),e}function J$({mapId:e,ticketId:t}){const s=_u(),o=s==null?void 0:s.waiting.find(a=>a.mapId===e&&a.ticketId===t);return o?i.jsx(Ce,{className:"model-wait d-section",edge:"attention",title:`Needs a ${o.tier} model`,context:i.jsx(V,{parts:[`Connected agents run ${o.best} at most`]}),detail:`Connect an agent on a ${o.tier} model, or have one claim ${o.ticketKey} by key.`}):null}function X$({view:e}){if(!e)return null;const t=`${te.dataDir}/${e.file}`,s=Object.keys(e.models).length,o=e.agents.map(a=>`${a.agent} ${a.tier}`).join(", ");return i.jsxs(i.Fragment,{children:[i.jsx(V,{className:"set-hint",parts:[{text:t,code:!0},e.exists?`${s} of your own models`:"add new or custom models here","unknown models count as balanced"]}),o&&i.jsx(V,{className:"set-hint models-connected",parts:[`Connected now: ${o}`]}),e.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[t," has errors, so only the built-in models count until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:e.errors.map(a=>i.jsx("li",{children:a},a))})]})]})}const fv={fast:"Fast",balanced:"Balanced",strongest:"Strongest"},Z$={fast:"Haiku, mini and nano models",balanced:"Sonnet, GPT-4 models",strongest:"Opus, GPT-5 and o-series models"},eT=Po.map(e=>({value:e,label:fv[e],hint:Z$[e]}));function tT(e){return i.jsx("div",{className:"tier-grid",children:ea.map(t=>{const s=e.tiers[t],o=hu[t];return i.jsxs("div",{className:"tier-row",children:[i.jsx("span",{children:nr[t]}),i.jsx(dt,{compact:!0,"aria-label":`${nr[t]} tickets' model`,className:`tier-select tier-${t}`,value:s,options:eT,onChange:a=>e.onChange(t,a)}),i.jsx(V,{className:"tier-hint",parts:[s!==o&&`default ${fv[o].toLowerCase()}`,e.hints[t]]})]},t)})})}const Mo=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function nT({rows:e}){return e.length?i.jsx("ul",{className:"perf-rows",children:e.map(t=>i.jsx(Ce,{as:"li",className:"perf-row",title:t.key,trailing:i.jsx("span",{title:"Median time from first claim to done",children:ln(t.medianLeadMs)}),context:i.jsx(V,{parts:[`${t.done} of ${Mo(t.tickets,"ticket")} done`,t.cancelled>0&&`${t.cancelled} cancelled`,Mo(t.reworkCycles,"rework"),`reviews ${t.reviews.passed} passed, ${t.reviews.failed} failed`,t.answers>0&&Mo(t.answers,"question")]}),detail:t.findings.raised>0?`As reviewer: ${t.findings.upheld} of ${Mo(t.findings.raised,"finding")} upheld`:void 0},t.key))}):i.jsx(Ae,{children:"No claimed tickets yet"})}function mv(e){const[t,s]=y.useState({}),o=e.map(a=>`${a.map.id}:${a.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),0)}`).join();return y.useEffect(()=>{let a=!0;return Promise.all(e.map(async c=>{const d=await fetch(`${je()}/journal?mapId=${encodeURIComponent(c.map.id)}`).catch(()=>{}),h=d!=null&&d.ok?await d.json():{entries:[]};return[c.map.id,h.entries]})).then(c=>{a&&s(Object.fromEntries(c))}),()=>{a=!1}},[o]),t}const sT=[{id:"byVendor",title:"By vendor"},{id:"byAgent",title:"By agent"},{id:"byType",title:"By ticket type"}];function iT({api:e,bp:t,onClose:s}){const[o,a]=y.useState("byVendor"),c=y.useMemo(()=>Object.values(e.allSnaps),[e.allSnaps]),d=mv(c),h=e.activity.answered,m=y.useMemo(()=>Vp(c.map(p=>({snap:p,journal:d[p.map.id]??[],answered:h}))),[c,d,h]);return y.useEffect(()=>{const p=v=>v.key==="Escape"&&s();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[s]),i.jsxs(ze,{className:`zone decisions-view perf-view dv-${t}`,children:[i.jsxs("header",{className:"dv-head",children:[i.jsx(Ve,{as:"h2",children:"Trail stats"}),i.jsx(V,{parts:[`${m.trails} trails`,`${m.tickets} tickets`]}),i.jsx("span",{className:"dv-head-right",children:i.jsx("button",{className:"icon-btn",onClick:s,"aria-label":"Close",children:"×"})})]}),i.jsxs("div",{className:"perf-body",children:[i.jsxs("section",{className:"perf-section",children:[i.jsx(Ve,{as:"h3",children:"What stands out"}),i.jsx("p",{className:"perf-note t-meta",children:"From your own numbers, for you to act on or ignore. Teamtrail doesn't route work from these."}),m.recommendations.length?i.jsx("ul",{className:"perf-recs",children:m.recommendations.map(p=>i.jsxs("li",{title:p.because,children:[i.jsx("span",{children:p.text}),i.jsx("span",{className:"t-meta",children:p.because})]},p.id))}):i.jsx(Ae,{children:"Nothing yet. This needs at least 5 results from two vendors to compare."})]}),i.jsxs("section",{className:"perf-section",children:[i.jsx("div",{className:"choice-row compact",children:sT.map(p=>i.jsx(mt,{on:o===p.id,title:p.title,onClick:()=>a(p.id)},p.id))}),i.jsx(nT,{rows:m[o]}),i.jsx("p",{className:"perf-note t-meta",children:"Spend is tracked per trail, so it isn't split by agent here."})]})]})]})}function rT(e,t){const s=mv(e);return y.useMemo(()=>{var c;const o=Vp(e.map(d=>({snap:d,journal:s[d.map.id]??[],answered:t}))),a={};for(const d of o.byType){if(!d.done)continue;const h=(c=o.recommendations.find(p=>p.id===`speed-${d.key}`))==null?void 0:c.text,m=[`Trail stats: ${d.done} done`,d.medianLeadMs!==void 0&&`median ${ln(d.medianLeadMs)}`,d.reworkCycles>0&&`${d.reworkCycles} back to rework`,h];a[d.key]=m.filter(Boolean).join(" · ")}return a},[e,s,t])}function oT(e){var d,h;const t=_u(),s=rT(e.snaps,e.answered),o=e.map;if(!o)return null;const a=!!((d=o.modelMatching)!=null&&d.enabled),c=((h=o.modelMatching)==null?void 0:h.tiers)??{};return i.jsxs(Ie,{title:"Model matching",children:[i.jsx("p",{className:"vf-intro",children:"Give each agent the tickets that fit the model it runs on: research to fast models, junctions, prototypes and reviews to the strongest. Teamtrail reads the model from the agent's log and never switches it. An agent can still claim any ticket by name, and tells you when it does."}),i.jsxs("div",{className:"att-settings-row set-field",children:[i.jsxs("span",{className:"set-field-label",children:["Match work to models on trail ",o.key]}),i.jsx(P,{size:"sm",on:a,"aria-pressed":a,className:"model-matching-toggle",onClick:()=>e.onChange({...o.modelMatching,enabled:!a}),children:a?"On":"Off"})]}),a&&i.jsx(tT,{tiers:qy(o),hints:s,onChange:(m,p)=>{const v={...c,[m]:p};p===hu[m]&&delete v[m],e.onChange({enabled:!0,tiers:v})}}),a&&i.jsx("span",{className:"set-hint t-meta",children:"Changes apply to the next claim; nothing running is interrupted."}),i.jsx(X$,{view:t})]})}function Xi(e,t){const s=new URL(e);return s.searchParams.delete("settings"),t&&s.searchParams.set("settings",t.section??t.group??""),s.toString()}async function aT(){const e=await fetch(`${je()}/verification/config`);return e.ok?await e.json():null}function lT(){const[e,t]=y.useState();return pt({load:aT,show:t,failed:()=>t(null),changed:s=>s.endsWith("verification.json"),events:{attention:()=>!0}}),e}const Km=`{
|
|
153
153
|
"v": 1,
|
|
154
154
|
"checks": {
|
|
155
155
|
"test": { "run": ["npm", "test"] },
|
|
@@ -157,17 +157,17 @@ ${s} ${o}`}function l$(e){return e.kind==="lookout"?["the Lookout","this machine
|
|
|
157
157
|
},
|
|
158
158
|
"run": ["test", "lint"]
|
|
159
159
|
}
|
|
160
|
-
`;function lT({file:e}){const[t,s]=y.useState(!1),o=()=>void navigator.clipboard.writeText(Km).then(()=>{s(!0),setTimeout(()=>s(!1),1500)});return i.jsxs("div",{className:"vf-setup",children:[i.jsx("b",{className:"vf-setup-h",children:"Set up checks"}),i.jsxs("p",{children:["Checks are the commands that prove a ticket is really done, such as your tests and linter. They live in"," ",i.jsx("code",{children:e})," in your repo. Create it with the commands you trust, then commit it:"]}),i.jsxs("div",{className:"vf-snippet",children:[i.jsx("pre",{children:Km}),i.jsx(P,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("p",{className:"dim",children:[i.jsx("code",{children:"run"})," lists the checks that run on every completion. Each ",i.jsx("code",{children:"run"})," command is a list of words, not a shell line. Until the file exists, levels above Off can’t run their checks, so those completions stop and wait for you."]})]})}function cT(e){var p;const t=aT(),[s,o]=y.useState();if(!t)return null;const a=e.map,c=t.config,d=`${te.dataDir}/${t.file}`,h=(a==null?void 0:a.verification)??"off",m=(c??Ap).appliesTo.join(" and ");return i.jsxs(Ie,{title:"Verification",children:[i.jsxs("p",{className:"vf-intro",children:["When an agent says a ticket is done, Teamtrail can check the work before the ticket closes. This applies to"," ",m," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),a&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",a.key]}),i.jsx("div",{className:"choice-row vf-levels",children:du.map(v=>i.jsx(mt,{on:h===v,title:ir[v],sub:Lg[v],onClick:()=>{o(void 0),ur.act({action:"level",mapId:a.id,level:v,by:St}).catch(k=>o(k.message))}},v))}),h!=="off"&&!c&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),s&&i.jsx("span",{className:"vf-err",children:s})]}),t.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[d," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:t.errors.map(v=>i.jsx("li",{children:v},v))})]}),((p=t.approval)==null?void 0:p.waiting)&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Its commands don't run on this machine until you approve them."," ",i.jsx("a",{href:Xi(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),!t.exists&&i.jsx(lT,{file:d}),c&&t.exists&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:d})," · ",c.run.length," checks run on every completion"]})]}),i.jsx(V,{className:"set-hint",parts:[`New trails start at ${ir[c.default]}`,`${c.maxAttempts} attempts before it waits for you`,c.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(c.checks).map(([v,k])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:c.run.includes(v)?v:`${v} (on request)`}),i.jsx("code",{children:k.run.join(" ")}),i.jsxs("span",{className:"dim",children:[k.timeoutSec," s",k.cwd&&k.cwd!=="."?` · in ${k.cwd}`:""]})]},v))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Teamtrail never edits ",d,". Change checks in the repo, then approve them here: an edit by an agent or a teammate runs nothing on this machine until you do."]}),i.jsxs("span",{className:"set-hint t-meta",children:["Checks run on this machine as you, with no sandbox. Teamtrail passes them only the environment variables they need (more go in ",i.jsx("code",{children:"TEAMTRAIL_CHECK_ENV"}),"), but a check can still read your files (~/.aws, ~/.npmrc, ~/.ssh, ~/.kube, ~/.docker, the GitHub CLI's login, Teamtrail's own credentials) and use your SSH agent. That's why a changed check command needs your approval: you approve the command line, so read what it runs."]})]})}function uT({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(Qe,{id:"mode",children:i.jsx(Ie,{title:`Trail ${t.key}`,children:i.jsx(ob,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ae,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(Qe,{id:"verification",storage:"repo",children:i.jsx(cT,{map:t})}),i.jsx(Qe,{id:"models",children:i.jsx(rT,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(Qe,{id:"team",children:i.jsx(e$,{map:t})})]})}const Vm=10,pv=[0,10,16,26,18,24,16,18,22,22,26],gv=[0,1,1,1,2,2,4,4,4,5,5];function vv(e){let t=(16*e+128)*e+64;if(e<2)return t;const s=Math.floor(e/7)+2;return t-=(25*s-10)*s-55,e>=7?t-36:t}const dT=e=>pv[e],hT=e=>gv[e],kv=e=>Math.floor(vv(e)/8)-pv[e]*gv[e],yv=e=>e<10?8:16;function fT(e){if(e===1)return[];const t=Math.floor(e/7)+2,s=e*4+17,o=Math.ceil((e*4+4)/(t*2-2))*2,a=[6];for(let c=s-7;a.length<t;c-=o)a.splice(1,0,c);return a}function ru(e,t){let s=0;for(let o=7;o>=0;o--)s=s<<1^(s>>>7)*285,s^=(t>>>o&1)*e;return s}function mT(e){const t=new Array(e).fill(0);t[e-1]=1;let s=1;for(let o=0;o<e;o++){for(let a=0;a<t.length;a++)t[a]=ru(t[a],s),a+1<t.length&&(t[a]^=t[a+1]);s=ru(s,2)}return t}function pT(e,t){const s=t.map(()=>0);for(const o of e){const a=o^s.shift();s.push(0),t.forEach((c,d)=>s[d]^=ru(c,a))}return s}function gT(e,t){const s=[],o=(d,h)=>{for(let m=h-1;m>=0;m--)s.push(d>>>m&1)};o(4,4),o(e.length,yv(t));for(const d of e)o(d,8);const a=kv(t)*8;o(0,Math.min(4,a-s.length)),o(0,(8-s.length%8)%8);for(let d=236;s.length<a;d^=253)o(d,8);const c=[];for(let d=0;d<s.length;d+=8)c.push(s.slice(d,d+8).reduce((h,m)=>h<<1|m,0));return c}function vT(e,t){const s=gT(e,t),o=hT(t),a=dT(t),c=Math.floor(vv(t)/8),d=o-c%o,h=Math.floor(c/o),m=mT(a),p=[];for(let k=0,x=0;k<o;k++){const S=s.slice(x,x+h-a+(k<d?0:1));x+=S.length;const C=pT(S,m);k<d&&S.push(0),p.push([...S,...C])}const v=[];for(let k=0;k<p[0].length;k++)for(let x=0;x<p.length;x++)(k!==h-a||x>=d)&&v.push(p[x][k]);return v}const kT=[(e,t)=>(e+t)%2===0,(e,t)=>t%2===0,e=>e%3===0,(e,t)=>(e+t)%3===0,(e,t)=>(Math.floor(e/3)+Math.floor(t/2))%2===0,(e,t)=>e*t%2+e*t%3===0,(e,t)=>(e*t%2+e*t%3)%2===0,(e,t)=>((e+t)%2+e*t%3)%2===0];function Mc(e,t){const s=kT[t];for(let o=0;o<e.size;o++)for(let a=0;a<e.size;a++)!e.fixed[o][a]&&s(a,o)&&(e.dark[o][a]=!e.dark[o][a])}function Gm(e){let t=0,s=1;for(let a=1;a<=e.length;a++)a<e.length&&e[a]===e[a-1]?s++:(s>=5&&(t+=s-2),s=1);const o=e.map(a=>a?"1":"0").join("");for(const a of["00001011101","10111010000"])for(let c=o.indexOf(a);c>=0;c=o.indexOf(a,c+1))t+=40;return t}function yT(e){let t=0,s=0;for(let a=0;a<e.size;a++)t+=Gm(e.dark[a]),t+=Gm(e.dark.map(c=>c[a]));for(let a=0;a<e.size;a++)for(let c=0;c<e.size;c++){if(e.dark[a][c]&&s++,c===e.size-1||a===e.size-1)continue;const d=e.dark[a][c];d===e.dark[a][c+1]&&d===e.dark[a+1][c]&&d===e.dark[a+1][c+1]&&(t+=3)}const o=e.size*e.size;return t+Math.floor(Math.abs(s*20-o*10)/o)*10}const rn=(e,t)=>(e>>>t&1)!==0;function Nt(e,t,s,o){e.dark[s][t]=o,e.fixed[s][t]=!0}function Rc(e,t,s){for(let o=-4;o<=4;o++)for(let a=-4;a<=4;a++){const c=t+a,d=s+o,h=Math.max(Math.abs(a),Math.abs(o));c>=0&&c<e.size&&d>=0&&d<e.size&&Nt(e,c,d,h!==2&&h!==4)}}function wT(e,t,s){for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)Nt(e,t+a,s+o,Math.max(Math.abs(a),Math.abs(o))!==1)}function ou(e,t){const s=0|t;let o=s;for(let c=0;c<10;c++)o=o<<1^(o>>>9)*1335;const a=(s<<10|o)^21522;for(let c=0;c<=5;c++)Nt(e,8,c,rn(a,c));Nt(e,8,7,rn(a,6)),Nt(e,8,8,rn(a,7)),Nt(e,7,8,rn(a,8));for(let c=9;c<15;c++)Nt(e,14-c,8,rn(a,c));for(let c=0;c<8;c++)Nt(e,e.size-1-c,8,rn(a,c));for(let c=8;c<15;c++)Nt(e,8,e.size-15+c,rn(a,c));Nt(e,8,e.size-8,!0)}function xT(e,t){if(t<7)return;let s=t;for(let a=0;a<12;a++)s=s<<1^(s>>>11)*7973;const o=t<<12|s;for(let a=0;a<18;a++){const c=e.size-11+a%3,d=Math.floor(a/3);Nt(e,c,d,rn(o,a)),Nt(e,d,c,rn(o,a))}}function jT(e){const t=e*4+17,s=()=>Array.from({length:t},()=>new Array(t).fill(!1)),o={size:t,dark:s(),fixed:s()};for(let d=0;d<t;d++)Nt(o,6,d,d%2===0),Nt(o,d,6,d%2===0);Rc(o,3,3),Rc(o,t-4,3),Rc(o,3,t-4);const a=fT(e),c=a.length-1;for(let d=0;d<=c;d++)for(let h=0;h<=c;h++)d===0&&h===0||d===0&&h===c||d===c&&h===0||wT(o,a[d],a[h]);return ou(o,0),xT(o,e),o}function ST(e){const t=[];for(let s=e-1;s>=1;s-=2){const o=s<=6?s-1:s,a=(o+1&2)===0;for(let c=0;c<e;c++){const d=a?e-1-c:c;t.push([o,d],[o-1,d])}}return t}function NT(e,t){let s=0;for(const[o,a]of ST(e.size))e.fixed[a][o]||s>=t.length*8||(e.dark[a][o]=rn(t[s>>>3],7-(s&7)),s++)}function bT(e){const t=new TextEncoder().encode(e);let s=1;for(;s<=Vm&&4+yv(s)+t.length*8>kv(s)*8;)s++;if(s>Vm)return;const o=jT(s);NT(o,vT(t,s));let a=0,c=1/0;for(let d=0;d<8;d++){Mc(o,d),ou(o,d);const h=yT(o);h<c&&([a,c]=[d,h]),Mc(o,d)}return Mc(o,a),ou(o,a),o.dark}const Lc=4;function CT(e){const t=bT(e.text);if(!t)return null;const s=t.length+Lc*2,o=t.flatMap((a,c)=>a.map((d,h)=>d?`M${h+Lc} ${c+Lc}h1v1h-1z`:"")).join("");return i.jsxs("svg",{className:"si-qr",viewBox:`0 0 ${s} ${s}`,role:"img","aria-label":e.label,shapeRendering:"crispEdges",children:[i.jsx("rect",{width:s,height:s,fill:"#fff"}),i.jsx("path",{d:o,fill:"#000"})]})}function $T(e){const t=Yt(1e3),s=Math.max(0,Math.ceil((e.device.expiresAt-t)/6e4)),o=e.device.links[0];return e.device.expiresAt<=t?i.jsxs("div",{className:"si-code",children:[i.jsx("p",{className:"t-meta",children:"That code expired. Make a new one when the device is ready."}),i.jsx(P,{size:"sm",onClick:e.onDone,children:"Done"})]}):i.jsxs("div",{className:"si-code",children:[o&&i.jsx(CT,{text:o,label:"QR code that pairs another device"}),i.jsxs("div",{className:"si-code-words",children:[i.jsx("span",{className:"si-code-value t-code","aria-label":"Pairing code",children:e.device.code}),i.jsx(V,{parts:["Works once",`expires in ${s} min`]}),i.jsxs("p",{className:"t-meta si-note",children:["Scan it with the device’s camera, or open"," ",o?i.jsx("code",{className:"t-code",children:o.split("#")[0]}):"the Lookout"," there and type the code."]}),i.jsx(P,{size:"sm",onClick:e.onDone,children:"Done"})]})]})}function TT(e){const[t,s]=y.useState();return e.device?i.jsx($T,{device:e.device,onDone:e.onDone}):e.lan.length?i.jsxs("div",{className:"si-pair",children:[i.jsx(P,{onClick:async()=>s(await e.onPair()),children:"Pair a device"}),t&&i.jsx("span",{className:"vf-err",children:t})]}):i.jsxs("p",{className:"t-meta si-note",children:["This Lookout listens on this machine only, so no other device can reach it. To pair a phone or another computer, start it with ",i.jsxs("code",{className:"t-code",children:[te.slug," --host 0.0.0.0"]})," on a network you trust. Another browser on this machine: run ",i.jsxs("code",{className:"t-code",children:[te.slug," pair"]}),"."]})}function ET(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[c,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(m=>m.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"It’s signed out now."}),i.jsxs(P,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(P,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}const AT={machine:"This machine",device:"Another device"};function IT(e){const t=Date.now();return i.jsx("ul",{className:"ra-list si-list",children:e.sessions.map(s=>i.jsx(Ce,{as:"li",className:"ra-row",title:s.current?`${s.name} · this browser`:s.name,titleText:s.name,context:i.jsx(V,{parts:[AT[s.kind],s.via==="opened-page"?`From the page ${te.name} opened`:void 0,s.via==="opened-page"?{text:Yj(s.id),code:!0}:void 0,`Paired ${Ho(s.pairedAt,t)}`,`Last used ${Ho(s.lastUsedAt,t)}`]}),below:s.current?void 0:i.jsx(ET,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function MT(){return i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it stops."})," A program on this machine, or a device on your network, that isn’t a paired browser: an agent with ",i.jsx("code",{children:"curl"})," can’t approve its own work, answer its own questions or change your settings through the Lookout. The session lives only in this page’s own storage and is sent only by this page, never as a cookie, so another server on this machine (an agent’s dev server on another port) gets nothing from your browser; and it goes only to a server that first proves it is this Lookout, so one that takes its port while the Lookout is stopped gets nothing either. A device paired here can read, answer and approve, but never change what runs on this machine or whom it trusts."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it can’t stop."})," A program that can read ",te.name,"’s config folder can make a pairing code, and one that can read your browser’s profile on disk can copy a session. Keep agents out of both:"," ",i.jsxs("code",{children:[te.slug," connect"]})," sets that up for the agents it registers."]})]})}const wv=`${te.apiPrefix}/sign-in`;async function Oc(e,t={}){const s=await fetch(`${wv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json().catch(()=>({}))}}function RT(){const[e,t]=y.useState(),[s,o]=y.useState(),a=y.useCallback(()=>{fetch(`${wv}/sessions`).then(async m=>m.ok?await m.json():(await m.json().catch(()=>({}))).elsewhere?"elsewhere":null).then(t,()=>t(null))},[]);y.useEffect(a,[a]);const c=y.useCallback(async()=>{const{ok:m,reply:p}=await Oc("/codes");if(!m)return p.error??"No code could be made.";o(p)},[]),d=y.useCallback(async m=>{const{ok:p,reply:v}=await Oc("/revoke",{id:m});return a(),p?void 0:v.error??"That browser could not be revoked."},[a]),h=y.useCallback(async()=>{await Oc("/sign-out"),mg(),location.reload()},[]);return{view:e,device:s,closeDevice:()=>(o(void 0),a()),pairDevice:c,revoke:d,signOut:h}}function LT(){const{view:e,device:t,closeDevice:s,pairDevice:o,revoke:a,signOut:c}=RT();if(!e)return null;const d=i.jsx("div",{className:"si-signout",children:i.jsx(P,{size:"sm",variant:"ghost",onClick:c,children:"Sign out of this browser"})});return e==="elsewhere"?i.jsxs(Ie,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"This device is paired with the Lookout. Browsers and devices are paired and revoked on the machine it runs on."}),d]}):i.jsxs(Ie,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"Every browser that opens this Lookout is paired, and stays signed in while it runs (up to 30 days after it was last used). Revoke one and it’s signed out at once. When the Lookout restarts, browsers and devices pair again: the link is in the terminal where it starts."}),i.jsx(IT,{sessions:e.sessions,onRevoke:a}),i.jsx(TT,{lan:e.lan,device:t,onPair:o,onDone:s}),d,i.jsx(MT,{})]})}function OT(){return y.useEffect(()=>{const e=setInterval(()=>void ha().then(t=>t!=="failed"&&location.reload()),3e3);return()=>clearInterval(e)},[]),i.jsx("div",{className:"pair-page",children:i.jsxs(ze,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(va,{className:"onb-title"})}),i.jsxs("h1",{className:"t-heading pair-title",children:[te.name," isn’t running here"]}),i.jsxs("p",{className:"t-body pair-step",children:["Start it with ",i.jsx("code",{className:"t-code",children:te.slug})," on the machine it runs on. This page reconnects once the Lookout answers as itself; until then it sends nothing to this address."]})]})})}async function Du(e){const t=await fetch(`${te.apiPrefix}/pair`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e})}).catch(()=>{});if(!t)return"The Lookout didn’t answer. Try again.";const s=await t.json().catch(()=>({}));if(!t.ok)return s.error??"That code didn’t work. Get a new one.";s.id&&s.session&&s.verifier&&SS({id:s.id,secret:s.session,verifier:s.verifier})}function PT(e){const[t,s]=y.useState(!1),o=async()=>{s(!0);const a=await Du(e.code);if(!a)return location.reload();s(!1),e.onFailed(a)};return i.jsxs("div",{className:"pair-confirm",children:[i.jsxs("p",{className:"t-body pair-step",children:["This link signs this browser in to the Lookout. Use it only if it came to you from"," ",i.jsx("code",{className:"t-code",children:te.slug}),", ",i.jsxs("code",{className:"t-code",children:[te.slug," pair"]})," or Pair a device in the Lookout’s Settings."]}),i.jsx("div",{children:i.jsx(P,{variant:"primary",disabled:t,onClick:o,children:"Sign in this browser"})})]})}function qm(){const[e,t]=y.useState(""),[s,o]=y.useState(!1),[a,c]=y.useState(),d=async()=>{if(!e.trim()||s)return;o(!0);const h=await Du(e);o(!1),c(h),h||location.reload()};return i.jsxs("form",{className:"pair-device",onSubmit:h=>{h.preventDefault(),d()},children:[i.jsxs("p",{className:"t-body pair-step",children:["On a phone or another computer: in the Lookout on the machine ",te.name," runs on, open Settings → You → Browsers & devices → Pair a device. Then type the code here, or scan it with this device’s camera."]}),i.jsxs("div",{className:"pair-code-row",children:[i.jsx("input",{className:"pair-code-input t-code",value:e,onChange:h=>t(h.target.value),placeholder:"ABCD-EFGH","aria-label":"Pairing code",autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,maxLength:20}),i.jsx(P,{type:"submit",variant:"primary",disabled:s||!e.trim(),children:"Pair"})]}),a&&i.jsx("p",{className:"vf-err",role:"alert",children:a})]})}function Qm(){return i.jsxs("p",{className:"t-body pair-step pair-here",children:["On the machine ",te.name," runs on, run ",i.jsxs("code",{className:"t-code",children:[te.slug," pair"]}),": it opens a tab ready to sign in, with one click. Or open the Sign in link ",i.jsx("code",{className:"t-code",children:te.slug})," printed in its terminal."]})}function _T(e){return i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-body pair-step",children:"The Lookout opens only in browsers you’ve paired."}),e.local?i.jsx(Qm,{}):i.jsx(qm,{}),e.local?i.jsx(qm,{}):i.jsx(Qm,{})]})}function DT(e){const[t,s]=y.useState(),[o,a]=y.useState(e.code),[c,d]=y.useState(e.code);e.code!==c&&(d(e.code),a(e.code));const h=m=>(s(m),a(void 0));return i.jsx("div",{className:"pair-page",children:i.jsxs(ze,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(va,{className:"onb-title"})}),i.jsx("h1",{className:"t-heading pair-title",children:"Pair this browser"}),t&&i.jsx("p",{className:"pair-problem t-body",role:"alert",children:t}),o?i.jsx(PT,{code:o,onFailed:h}):i.jsx(_T,{local:e.local})]})})}function Ym(){const e=/(?:^#|&)pair=([A-Za-z0-9_-]{1,64})/.exec(location.hash);if(e)return history.replaceState(null,"",`${location.pathname}${location.search}`),e[1]}async function Jm(){try{const e=await fetch(`${te.apiPrefix}/session`,{cache:"no-store"});if(!e.ok)return{kind:"no-server"};const t=await e.json();return typeof t.signedIn!="boolean"?{kind:"no-server"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function zT(){if(!xu())return Jm();const e=await ha();return e==="proven"?{kind:"signed-in"}:e==="unknown"?Jm():{kind:"not-running"}}function BT(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void zT().then(t),[]),y.useEffect(()=>NS(s=>s==="failed"&&t({kind:"not-running"})),[]),e}function FT({children:e}){const t=BT(),[s,o]=y.useState(Ym);return y.useEffect(()=>{const a=()=>o(c=>Ym()??c);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&s&&Du(s)},[t.kind,s]),t.kind==="checking"?null:t.kind==="signed-out"?i.jsx(DT,{local:t.local,code:s}):t.kind==="not-running"?i.jsx(OT,{}):i.jsx(i.Fragment,{children:e})}const UT=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function WT(e){return i.jsx("div",{className:"choice-row compact",children:UT.map(t=>i.jsx(mt,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function HT({data:e}){const{prefs:t,update:s}=e;return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"appearance",storage:"browser",children:i.jsx(Ie,{title:"Appearance",children:i.jsx(WT,{value:t.theme,onChange:o=>s({theme:o})})})}),i.jsx(Qe,{id:"transcript",storage:"browser",children:i.jsx(Ie,{title:"HITL transcript",children:i.jsx(Wg,{value:t.hitlTranscript,onChange:o=>s({hitlTranscript:o})})})}),i.jsx(Qe,{id:"agent",children:i.jsx(Ie,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:sg.map(o=>i.jsx(mt,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})}),i.jsx(Qe,{id:"devices",storage:"machine",children:i.jsx(LT,{})})]})}function KT(e){const{data:t,route:s}=e;switch(e.group){case"trail":return i.jsx(uT,{data:t});case"project":return i.jsx(E$,{data:t,route:s});case"alerts":return i.jsx(dC,{data:t,route:s});case"you":return i.jsx(HT,{data:t});case"projects":return i.jsx(Qe,{id:"projects",storage:"machine",children:i.jsx(G$,{})});case"about":return i.jsx(Qe,{id:"changelog",children:i.jsx(pC,{})});default:return e.group}}function VT(e){const{group:t,route:s}=e,o=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{var d,h;(d=o.current)==null||d.focus({preventScroll:!0});const c=s.section&&document.getElementById(`settings-${s.section}`);c?c.scrollIntoView({block:"start"}):(h=a.current)==null||h.scrollTo({top:0})},[t.id,s.section]),i.jsx("div",{className:"sp-pane",ref:a,children:i.jsxs("div",{className:"sp-pane-in",children:[i.jsxs("header",{className:"sp-pane-head",children:[i.jsx("h2",{className:"sp-title t-title",ref:o,tabIndex:-1,children:t.label}),i.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),i.jsx(KT,{group:t.id,data:e.data,route:s})]})})}function GT(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:rr.map(t=>{const s=t.id===e.current;return i.jsx(Ce,{as:"li",className:"sp-nav-row",selected:s,current:s?"page":void 0,title:t.label,context:i.jsx(V,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function qT(e,t){return e.group?rr.find(s=>s.id===e.group):t==="mobile"?void 0:rr[0]}const QT={page:"Back to the Lookout",list:"Lookout",group:"Settings"},YT=(e,t)=>e?t?"group":"list":"page";function JT(e){const{bp:t,route:s}=e,o=t==="mobile",a=qT(s,t),c=YT(o,!!a),d=Kg()===!1,h=()=>c==="group"?e.onShow({}):e.onClose();y.useEffect(()=>{const v=k=>{k.key!=="Escape"||k.defaultPrevented||document.querySelector(".scrim")||(c==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[c,e]);const m=v=>e.onShow({group:v}),p=c!=="group"&&i.jsx(GT,{current:a==null?void 0:a.id,onPick:m,drill:o});return i.jsxs(ze,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:h,children:["‹ ",QT[c]]}),c!=="group"&&i.jsx(Ve,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&i.jsx(nC,{}),i.jsxs("div",{className:"sp-body",children:[p,a&&i.jsx(VT,{group:a,data:e.data,route:s})]})]})}function XT(e){var a;const{rt:t,api:s,settings:o}=e;return o.route?i.jsx(JT,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(a=s.snap)==null?void 0:a.map,onMapMode:s.actions.setMode,snaps:Object.values(s.allSnaps),answered:s.activity.answered,onModelMatching:s.actions.setModelMatching}}):null}function ZT(e){return i.jsxs(ze,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(aN,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function xv(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ke,h:Ye}))}function eE(e){const{obstacles:t,from:s,to:o,clear:a}=e,c=t.flatMap(h=>[h.y-28,h.y+h.h+28]).filter(a),d=h=>Math.abs(h-s)+Math.abs(h-o);return c.reduce((h,m)=>d(m)<d(h)?m:h,c[0]??s)}const tE=6;function nE(e){const t=e.filter((a,c)=>c===0||a.x!==e[c-1].x||a.y!==e[c-1].y);let s=`M${t[0].x} ${t[0].y}`;for(let a=1;a<t.length-1;a++){const[c,d,h]=[t[a-1],t[a],t[a+1]],m=Math.min(tE,Xm(c,d)/2,Xm(d,h)/2),p=Zm(d,c,m),v=Zm(d,h,m);s+=`L${p.x} ${p.y}Q${d.x} ${d.y} ${v.x} ${v.y}`}const o=t[t.length-1];return`${s}L${o.x} ${o.y}`}function Xm(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function Zm(e,t,s){return{x:e.x+Math.sign(t.x-e.x)*s,y:e.y+Math.sign(t.y-e.y)*s}}function Qo(e){const t=e.direction==="TB",s=d=>t?{x:d.y,y:d.x}:d,o=s(e.a),a=s(e.b),c=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return nE(sE({a:o,b:a,obstacles:c,gap:e.gap}).map(s))}function sE({a:e,b:t,obstacles:s,gap:o}){const a=s.filter(p=>p.x+p.w>e.x+1&&p.x<t.x-1),c=p=>!a.some(v=>p>v.y-8&&p<v.y+v.h+8),d=Math.min(e.x+o/2,(e.x+t.x)/2),h=Math.max(t.x-o/2,(e.x+t.x)/2);if(c(e.y))return[e,{x:h,y:e.y},{x:h,y:t.y},t];if(c(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const m=eE({obstacles:a,from:e.y,to:t.y,clear:c});return[e,{x:d,y:e.y},{x:d,y:m},{x:h,y:m},{x:h,y:t.y},t]}function iE(e){if(e.direction==="LR"){const s=e.width+96;return{x:s,y:e.graphH/2,right:s+34,bottom:e.height}}const t=e.graphH+76;return{x:e.width/2,y:t,right:e.width,bottom:Math.max(e.height,t+40)}}function rE(e,t){const s=new Set(e.edges.map(c=>c.from)),o=e.nodes.filter(c=>c.state!=="out-of-scope"&&!s.has(c)),a=xv(e.nodes);return o.map(c=>{if(e.direction==="LR"){const m={x:c.x+Ke,y:c.y+Ye/2},p={x:t.x-30,y:t.y};return Qo({direction:"LR",a:m,b:p,obstacles:a,gap:96})}const d={x:c.x+Ke/2,y:c.y+Ye},h={x:t.x,y:t.y-30};return Qo({direction:"TB",a:d,b:h,obstacles:a,gap:48})})}function oE({x:e,y:t,text:s}){const o=s!=null&&s.trim()?`Destination
|
|
160
|
+
`;function cT({file:e}){const[t,s]=y.useState(!1),o=()=>void navigator.clipboard.writeText(Km).then(()=>{s(!0),setTimeout(()=>s(!1),1500)});return i.jsxs("div",{className:"vf-setup",children:[i.jsx("b",{className:"vf-setup-h",children:"Set up checks"}),i.jsxs("p",{children:["Checks are the commands that prove a ticket is really done, such as your tests and linter. They live in"," ",i.jsx("code",{children:e})," in your repo. Create it with the commands you trust, then commit it:"]}),i.jsxs("div",{className:"vf-snippet",children:[i.jsx("pre",{children:Km}),i.jsx(P,{size:"sm",variant:"ghost",onClick:o,children:t?"Copied":"Copy"})]}),i.jsxs("p",{className:"dim",children:[i.jsx("code",{children:"run"})," lists the checks that run on every completion. Each ",i.jsx("code",{children:"run"})," command is a list of words, not a shell line. Until the file exists, levels above Off can’t run their checks, so those completions stop and wait for you."]})]})}function uT(e){var p;const t=lT(),[s,o]=y.useState();if(!t)return null;const a=e.map,c=t.config,d=`${te.dataDir}/${t.file}`,h=(a==null?void 0:a.verification)??"off",m=(c??Ap).appliesTo.join(" and ");return i.jsxs(Ie,{title:"Verification",children:[i.jsxs("p",{className:"vf-intro",children:["When an agent says a ticket is done, Teamtrail can check the work before the ticket closes. This applies to"," ",m," tickets. Research, junction and prototype tickets close as soon as they are answered."]}),a&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"set-field-label",children:["How much checking for trail ",a.key]}),i.jsx("div",{className:"choice-row vf-levels",children:du.map(v=>i.jsx(mt,{on:h===v,title:ir[v],sub:Lg[v],onClick:()=>{o(void 0),ur.act({action:"level",mapId:a.id,level:v,by:St}).catch(k=>o(k.message))}},v))}),h!=="off"&&!c&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{children:"No working checks yet, so completions at this level stop and wait for you."})]}),s&&i.jsx("span",{className:"vf-err",children:s})]}),t.errors.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line alert",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[d," has errors. Completions that need checks wait for you until it is fixed."]})]}),i.jsx("ul",{className:"vf-errors",children:t.errors.map(v=>i.jsx("li",{children:v},v))})]}),((p=t.approval)==null?void 0:p.waiting)&&i.jsxs("div",{className:"sync-line alert",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Its commands don't run on this machine until you approve them."," ",i.jsx("a",{href:Xi(location.href,{group:"project",section:"approvals"}),children:"Review the commands"})]})]}),!t.exists&&i.jsx(cT,{file:d}),c&&t.exists&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sync-line ok",title:t.hash,children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:[i.jsx("span",{className:"t-code",children:d})," · ",c.run.length," checks run on every completion"]})]}),i.jsx(V,{className:"set-hint",parts:[`New trails start at ${ir[c.default]}`,`${c.maxAttempts} attempts before it waits for you`,c.failFast&&"Stops at the first failure"]}),i.jsx("div",{className:"vf-checks",children:Object.entries(c.checks).map(([v,k])=>i.jsxs("div",{className:"vf-check",children:[i.jsx("span",{className:"t-code",children:c.run.includes(v)?v:`${v} (on request)`}),i.jsx("code",{children:k.run.join(" ")}),i.jsxs("span",{className:"dim",children:[k.timeoutSec," s",k.cwd&&k.cwd!=="."?` · in ${k.cwd}`:""]})]},v))})]}),i.jsxs("span",{className:"set-hint t-meta",children:["Teamtrail never edits ",d,". Change checks in the repo, then approve them here: an edit by an agent or a teammate runs nothing on this machine until you do."]}),i.jsxs("span",{className:"set-hint t-meta",children:["Checks run on this machine as you, with no sandbox. Teamtrail passes them only the environment variables they need (more go in ",i.jsx("code",{children:"TEAMTRAIL_CHECK_ENV"}),"), but a check can still read your files (~/.aws, ~/.npmrc, ~/.ssh, ~/.kube, ~/.docker, the GitHub CLI's login, Teamtrail's own credentials) and use your SSH agent. That's why a changed check command needs your approval: you approve the command line, so read what it runs."]})]})}function dT({data:e}){const{map:t}=e;return i.jsxs(i.Fragment,{children:[t?i.jsx(Qe,{id:"mode",children:i.jsx(Ie,{title:`Trail ${t.key}`,children:i.jsx(ob,{value:t.mode,onChange:e.onMapMode})})}):i.jsx(Ae,{children:"Chart or pick a trail to set its mode, model matching and team."}),i.jsx(Qe,{id:"verification",storage:"repo",children:i.jsx(uT,{map:t})}),i.jsx(Qe,{id:"models",children:i.jsx(oT,{map:t,snaps:e.snaps,answered:e.answered,onChange:e.onModelMatching})}),t&&i.jsx(Qe,{id:"team",children:i.jsx(t$,{map:t})})]})}const Vm=10,pv=[0,10,16,26,18,24,16,18,22,22,26],gv=[0,1,1,1,2,2,4,4,4,5,5];function vv(e){let t=(16*e+128)*e+64;if(e<2)return t;const s=Math.floor(e/7)+2;return t-=(25*s-10)*s-55,e>=7?t-36:t}const hT=e=>pv[e],fT=e=>gv[e],kv=e=>Math.floor(vv(e)/8)-pv[e]*gv[e],yv=e=>e<10?8:16;function mT(e){if(e===1)return[];const t=Math.floor(e/7)+2,s=e*4+17,o=Math.ceil((e*4+4)/(t*2-2))*2,a=[6];for(let c=s-7;a.length<t;c-=o)a.splice(1,0,c);return a}function ru(e,t){let s=0;for(let o=7;o>=0;o--)s=s<<1^(s>>>7)*285,s^=(t>>>o&1)*e;return s}function pT(e){const t=new Array(e).fill(0);t[e-1]=1;let s=1;for(let o=0;o<e;o++){for(let a=0;a<t.length;a++)t[a]=ru(t[a],s),a+1<t.length&&(t[a]^=t[a+1]);s=ru(s,2)}return t}function gT(e,t){const s=t.map(()=>0);for(const o of e){const a=o^s.shift();s.push(0),t.forEach((c,d)=>s[d]^=ru(c,a))}return s}function vT(e,t){const s=[],o=(d,h)=>{for(let m=h-1;m>=0;m--)s.push(d>>>m&1)};o(4,4),o(e.length,yv(t));for(const d of e)o(d,8);const a=kv(t)*8;o(0,Math.min(4,a-s.length)),o(0,(8-s.length%8)%8);for(let d=236;s.length<a;d^=253)o(d,8);const c=[];for(let d=0;d<s.length;d+=8)c.push(s.slice(d,d+8).reduce((h,m)=>h<<1|m,0));return c}function kT(e,t){const s=vT(e,t),o=fT(t),a=hT(t),c=Math.floor(vv(t)/8),d=o-c%o,h=Math.floor(c/o),m=pT(a),p=[];for(let k=0,x=0;k<o;k++){const S=s.slice(x,x+h-a+(k<d?0:1));x+=S.length;const C=gT(S,m);k<d&&S.push(0),p.push([...S,...C])}const v=[];for(let k=0;k<p[0].length;k++)for(let x=0;x<p.length;x++)(k!==h-a||x>=d)&&v.push(p[x][k]);return v}const yT=[(e,t)=>(e+t)%2===0,(e,t)=>t%2===0,e=>e%3===0,(e,t)=>(e+t)%3===0,(e,t)=>(Math.floor(e/3)+Math.floor(t/2))%2===0,(e,t)=>e*t%2+e*t%3===0,(e,t)=>(e*t%2+e*t%3)%2===0,(e,t)=>((e+t)%2+e*t%3)%2===0];function Mc(e,t){const s=yT[t];for(let o=0;o<e.size;o++)for(let a=0;a<e.size;a++)!e.fixed[o][a]&&s(a,o)&&(e.dark[o][a]=!e.dark[o][a])}function Gm(e){let t=0,s=1;for(let a=1;a<=e.length;a++)a<e.length&&e[a]===e[a-1]?s++:(s>=5&&(t+=s-2),s=1);const o=e.map(a=>a?"1":"0").join("");for(const a of["00001011101","10111010000"])for(let c=o.indexOf(a);c>=0;c=o.indexOf(a,c+1))t+=40;return t}function wT(e){let t=0,s=0;for(let a=0;a<e.size;a++)t+=Gm(e.dark[a]),t+=Gm(e.dark.map(c=>c[a]));for(let a=0;a<e.size;a++)for(let c=0;c<e.size;c++){if(e.dark[a][c]&&s++,c===e.size-1||a===e.size-1)continue;const d=e.dark[a][c];d===e.dark[a][c+1]&&d===e.dark[a+1][c]&&d===e.dark[a+1][c+1]&&(t+=3)}const o=e.size*e.size;return t+Math.floor(Math.abs(s*20-o*10)/o)*10}const rn=(e,t)=>(e>>>t&1)!==0;function Nt(e,t,s,o){e.dark[s][t]=o,e.fixed[s][t]=!0}function Rc(e,t,s){for(let o=-4;o<=4;o++)for(let a=-4;a<=4;a++){const c=t+a,d=s+o,h=Math.max(Math.abs(a),Math.abs(o));c>=0&&c<e.size&&d>=0&&d<e.size&&Nt(e,c,d,h!==2&&h!==4)}}function xT(e,t,s){for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)Nt(e,t+a,s+o,Math.max(Math.abs(a),Math.abs(o))!==1)}function ou(e,t){const s=0|t;let o=s;for(let c=0;c<10;c++)o=o<<1^(o>>>9)*1335;const a=(s<<10|o)^21522;for(let c=0;c<=5;c++)Nt(e,8,c,rn(a,c));Nt(e,8,7,rn(a,6)),Nt(e,8,8,rn(a,7)),Nt(e,7,8,rn(a,8));for(let c=9;c<15;c++)Nt(e,14-c,8,rn(a,c));for(let c=0;c<8;c++)Nt(e,e.size-1-c,8,rn(a,c));for(let c=8;c<15;c++)Nt(e,8,e.size-15+c,rn(a,c));Nt(e,8,e.size-8,!0)}function jT(e,t){if(t<7)return;let s=t;for(let a=0;a<12;a++)s=s<<1^(s>>>11)*7973;const o=t<<12|s;for(let a=0;a<18;a++){const c=e.size-11+a%3,d=Math.floor(a/3);Nt(e,c,d,rn(o,a)),Nt(e,d,c,rn(o,a))}}function ST(e){const t=e*4+17,s=()=>Array.from({length:t},()=>new Array(t).fill(!1)),o={size:t,dark:s(),fixed:s()};for(let d=0;d<t;d++)Nt(o,6,d,d%2===0),Nt(o,d,6,d%2===0);Rc(o,3,3),Rc(o,t-4,3),Rc(o,3,t-4);const a=mT(e),c=a.length-1;for(let d=0;d<=c;d++)for(let h=0;h<=c;h++)d===0&&h===0||d===0&&h===c||d===c&&h===0||xT(o,a[d],a[h]);return ou(o,0),jT(o,e),o}function NT(e){const t=[];for(let s=e-1;s>=1;s-=2){const o=s<=6?s-1:s,a=(o+1&2)===0;for(let c=0;c<e;c++){const d=a?e-1-c:c;t.push([o,d],[o-1,d])}}return t}function bT(e,t){let s=0;for(const[o,a]of NT(e.size))e.fixed[a][o]||s>=t.length*8||(e.dark[a][o]=rn(t[s>>>3],7-(s&7)),s++)}function CT(e){const t=new TextEncoder().encode(e);let s=1;for(;s<=Vm&&4+yv(s)+t.length*8>kv(s)*8;)s++;if(s>Vm)return;const o=ST(s);bT(o,kT(t,s));let a=0,c=1/0;for(let d=0;d<8;d++){Mc(o,d),ou(o,d);const h=wT(o);h<c&&([a,c]=[d,h]),Mc(o,d)}return Mc(o,a),ou(o,a),o.dark}const Lc=4;function $T(e){const t=CT(e.text);if(!t)return null;const s=t.length+Lc*2,o=t.flatMap((a,c)=>a.map((d,h)=>d?`M${h+Lc} ${c+Lc}h1v1h-1z`:"")).join("");return i.jsxs("svg",{className:"si-qr",viewBox:`0 0 ${s} ${s}`,role:"img","aria-label":e.label,shapeRendering:"crispEdges",children:[i.jsx("rect",{width:s,height:s,fill:"#fff"}),i.jsx("path",{d:o,fill:"#000"})]})}function TT(e){const t=Yt(1e3),s=Math.max(0,Math.ceil((e.device.expiresAt-t)/6e4)),o=e.device.links[0];return e.device.expiresAt<=t?i.jsxs("div",{className:"si-code",children:[i.jsx("p",{className:"t-meta",children:"That code expired. Make a new one when the device is ready."}),i.jsx(P,{size:"sm",onClick:e.onDone,children:"Done"})]}):i.jsxs("div",{className:"si-code",children:[o&&i.jsx($T,{text:o,label:"QR code that pairs another device"}),i.jsxs("div",{className:"si-code-words",children:[i.jsx("span",{className:"si-code-value t-code","aria-label":"Pairing code",children:e.device.code}),i.jsx(V,{parts:["Works once",`expires in ${s} min`]}),i.jsxs("p",{className:"t-meta si-note",children:["Scan it with the device’s camera, or open"," ",o?i.jsx("code",{className:"t-code",children:o.split("#")[0]}):"the Lookout"," there and type the code."]}),i.jsx(P,{size:"sm",onClick:e.onDone,children:"Done"})]})]})}function ET(e){const[t,s]=y.useState();return e.device?i.jsx(TT,{device:e.device,onDone:e.onDone}):e.lan.length?i.jsxs("div",{className:"si-pair",children:[i.jsx(P,{onClick:async()=>s(await e.onPair()),children:"Pair a device"}),t&&i.jsx("span",{className:"vf-err",children:t})]}):i.jsxs("p",{className:"t-meta si-note",children:["This Lookout listens on this machine only, so no other device can reach it. To pair a phone or another computer, start it with ",i.jsxs("code",{className:"t-code",children:[te.slug," --host 0.0.0.0"]})," on a network you trust. Another browser on this machine: run ",i.jsxs("code",{className:"t-code",children:[te.slug," pair"]}),"."]})}function AT(e){const[t,s]=y.useState(!1),[o,a]=y.useState(!1),[c,d]=y.useState(),h=async()=>{a(!0),d(await e.onRevoke().catch(m=>m.message)),a(!1),s(!1)};return t?i.jsxs("span",{className:"ra-revoke ask",children:[i.jsx("span",{className:"t-meta",children:"It’s signed out now."}),i.jsxs(P,{size:"sm",disabled:o,onClick:h,children:["Revoke ",e.name]}),i.jsx(P,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"Keep"})]}):i.jsxs("span",{className:"ra-revoke",children:[i.jsx(P,{size:"sm","aria-label":`Revoke ${e.name}`,onClick:()=>s(!0),children:"Revoke"}),c&&i.jsx("span",{className:"vf-err",children:c})]})}const IT={machine:"This machine",device:"Another device"};function MT(e){const t=Date.now();return i.jsx("ul",{className:"ra-list si-list",children:e.sessions.map(s=>i.jsx(Ce,{as:"li",className:"ra-row",title:s.current?`${s.name} · this browser`:s.name,titleText:s.name,context:i.jsx(V,{parts:[IT[s.kind],s.via==="opened-page"?`From the page ${te.name} opened`:void 0,s.via==="opened-page"?{text:Yj(s.id),code:!0}:void 0,`Paired ${Ho(s.pairedAt,t)}`,`Last used ${Ho(s.lastUsedAt,t)}`]}),below:s.current?void 0:i.jsx(AT,{name:s.name,onRevoke:()=>e.onRevoke(s.id)})},s.id))})}function RT(){return i.jsxs("div",{className:"ra-notes",children:[i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it stops."})," A program on this machine, or a device on your network, that isn’t a paired browser: an agent with ",i.jsx("code",{children:"curl"})," can’t approve its own work, answer its own questions or change your settings through the Lookout. The session lives only in this page’s own storage and is sent only by this page, never as a cookie, so another server on this machine (an agent’s dev server on another port) gets nothing from your browser; and it goes only to a server that first proves it is this Lookout, so one that takes its port while the Lookout is stopped gets nothing either. A device paired here can read, answer and approve, but never change what runs on this machine or whom it trusts."]}),i.jsxs("p",{className:"t-meta ra-note",children:[i.jsx("b",{children:"What it can’t stop."})," A program that can read ",te.name,"’s config folder can make a pairing code, and one that can read your browser’s profile on disk can copy a session. Keep agents out of both:"," ",i.jsxs("code",{children:[te.slug," connect"]})," sets that up for the agents it registers."]})]})}const wv=`${te.apiPrefix}/sign-in`;async function Oc(e,t={}){const s=await fetch(`${wv}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{ok:s.ok,reply:await s.json().catch(()=>({}))}}function LT(){const[e,t]=y.useState(),[s,o]=y.useState(),a=y.useCallback(()=>{fetch(`${wv}/sessions`).then(async m=>m.ok?await m.json():(await m.json().catch(()=>({}))).elsewhere?"elsewhere":null).then(t,()=>t(null))},[]);y.useEffect(a,[a]);const c=y.useCallback(async()=>{const{ok:m,reply:p}=await Oc("/codes");if(!m)return p.error??"No code could be made.";o(p)},[]),d=y.useCallback(async m=>{const{ok:p,reply:v}=await Oc("/revoke",{id:m});return a(),p?void 0:v.error??"That browser could not be revoked."},[a]),h=y.useCallback(async()=>{await Oc("/sign-out"),mg(),location.reload()},[]);return{view:e,device:s,closeDevice:()=>(o(void 0),a()),pairDevice:c,revoke:d,signOut:h}}function OT(){const{view:e,device:t,closeDevice:s,pairDevice:o,revoke:a,signOut:c}=LT();if(!e)return null;const d=i.jsx("div",{className:"si-signout",children:i.jsx(P,{size:"sm",variant:"ghost",onClick:c,children:"Sign out of this browser"})});return e==="elsewhere"?i.jsxs(Ie,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"This device is paired with the Lookout. Browsers and devices are paired and revoked on the machine it runs on."}),d]}):i.jsxs(Ie,{title:"Browsers & devices",children:[i.jsx("p",{className:"vf-intro",children:"Every browser that opens this Lookout is paired, and stays signed in while it runs (up to 30 days after it was last used). Revoke one and it’s signed out at once. When the Lookout restarts, browsers and devices pair again: the link is in the terminal where it starts."}),i.jsx(MT,{sessions:e.sessions,onRevoke:a}),i.jsx(ET,{lan:e.lan,device:t,onPair:o,onDone:s}),d,i.jsx(RT,{})]})}function PT(){return y.useEffect(()=>{const e=setInterval(()=>void ha().then(t=>t!=="failed"&&location.reload()),3e3);return()=>clearInterval(e)},[]),i.jsx("div",{className:"pair-page",children:i.jsxs(ze,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(va,{className:"onb-title"})}),i.jsxs("h1",{className:"t-heading pair-title",children:[te.name," isn’t running here"]}),i.jsxs("p",{className:"t-body pair-step",children:["Start it with ",i.jsx("code",{className:"t-code",children:te.slug})," on the machine it runs on. This page reconnects once the Lookout answers as itself; until then it sends nothing to this address."]})]})})}async function Du(e){const t=await fetch(`${te.apiPrefix}/pair`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e})}).catch(()=>{});if(!t)return"The Lookout didn’t answer. Try again.";const s=await t.json().catch(()=>({}));if(!t.ok)return s.error??"That code didn’t work. Get a new one.";s.id&&s.session&&s.verifier&&SS({id:s.id,secret:s.session,verifier:s.verifier})}function _T(e){const[t,s]=y.useState(!1),o=async()=>{s(!0);const a=await Du(e.code);if(!a)return location.reload();s(!1),e.onFailed(a)};return i.jsxs("div",{className:"pair-confirm",children:[i.jsxs("p",{className:"t-body pair-step",children:["This link signs this browser in to the Lookout. Use it only if it came to you from"," ",i.jsx("code",{className:"t-code",children:te.slug}),", ",i.jsxs("code",{className:"t-code",children:[te.slug," pair"]})," or Pair a device in the Lookout’s Settings."]}),i.jsx("div",{children:i.jsx(P,{variant:"primary",disabled:t,onClick:o,children:"Sign in this browser"})})]})}function qm(){const[e,t]=y.useState(""),[s,o]=y.useState(!1),[a,c]=y.useState(),d=async()=>{if(!e.trim()||s)return;o(!0);const h=await Du(e);o(!1),c(h),h||location.reload()};return i.jsxs("form",{className:"pair-device",onSubmit:h=>{h.preventDefault(),d()},children:[i.jsxs("p",{className:"t-body pair-step",children:["On a phone or another computer: in the Lookout on the machine ",te.name," runs on, open Settings → You → Browsers & devices → Pair a device. Then type the code here, or scan it with this device’s camera."]}),i.jsxs("div",{className:"pair-code-row",children:[i.jsx("input",{className:"pair-code-input t-code",value:e,onChange:h=>t(h.target.value),placeholder:"ABCD-EFGH","aria-label":"Pairing code",autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,maxLength:20}),i.jsx(P,{type:"submit",variant:"primary",disabled:s||!e.trim(),children:"Pair"})]}),a&&i.jsx("p",{className:"vf-err",role:"alert",children:a})]})}function Qm(){return i.jsxs("p",{className:"t-body pair-step pair-here",children:["On the machine ",te.name," runs on, run ",i.jsxs("code",{className:"t-code",children:[te.slug," pair"]}),": it opens a tab ready to sign in, with one click. Or open the Sign in link ",i.jsx("code",{className:"t-code",children:te.slug})," printed in its terminal."]})}function DT(e){return i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"t-body pair-step",children:"The Lookout opens only in browsers you’ve paired."}),e.local?i.jsx(Qm,{}):i.jsx(qm,{}),e.local?i.jsx(qm,{}):i.jsx(Qm,{})]})}function zT(e){const[t,s]=y.useState(),[o,a]=y.useState(e.code),[c,d]=y.useState(e.code);e.code!==c&&(d(e.code),a(e.code));const h=m=>(s(m),a(void 0));return i.jsx("div",{className:"pair-page",children:i.jsxs(ze,{as:"main",className:"pair-card",children:[i.jsx("div",{className:"onb-brand",children:i.jsx(va,{className:"onb-title"})}),i.jsx("h1",{className:"t-heading pair-title",children:"Pair this browser"}),t&&i.jsx("p",{className:"pair-problem t-body",role:"alert",children:t}),o?i.jsx(_T,{code:o,onFailed:h}):i.jsx(DT,{local:e.local})]})})}function Ym(){const e=/(?:^#|&)pair=([A-Za-z0-9_-]{1,64})/.exec(location.hash);if(e)return history.replaceState(null,"",`${location.pathname}${location.search}`),e[1]}async function Jm(){try{const e=await fetch(`${te.apiPrefix}/session`,{cache:"no-store"});if(!e.ok)return{kind:"no-server"};const t=await e.json();return typeof t.signedIn!="boolean"?{kind:"no-server"}:{kind:"signed-out",local:t.local===!0}}catch{return{kind:"no-server"}}}async function BT(){if(!xu())return Jm();const e=await ha();return e==="proven"?{kind:"signed-in"}:e==="unknown"?Jm():{kind:"not-running"}}function FT(){const[e,t]=y.useState({kind:"checking"});return y.useEffect(()=>void BT().then(t),[]),y.useEffect(()=>NS(s=>s==="failed"&&t({kind:"not-running"})),[]),e}function UT({children:e}){const t=FT(),[s,o]=y.useState(Ym);return y.useEffect(()=>{const a=()=>o(c=>Ym()??c);return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),y.useEffect(()=>{t.kind==="signed-in"&&s&&Du(s)},[t.kind,s]),t.kind==="checking"?null:t.kind==="signed-out"?i.jsx(zT,{local:t.local,code:s}):t.kind==="not-running"?i.jsx(PT,{}):i.jsx(i.Fragment,{children:e})}const WT=[{value:"auto",title:"Match my system"},{value:"day",title:"Day"},{value:"night",title:"Night"}];function HT(e){return i.jsx("div",{className:"choice-row compact",children:WT.map(t=>i.jsx(mt,{on:e.value===t.value,title:t.title,onClick:()=>e.onChange(t.value)},t.value))})}function KT({data:e}){const{prefs:t,update:s}=e;return i.jsxs(i.Fragment,{children:[i.jsx(Qe,{id:"appearance",storage:"browser",children:i.jsx(Ie,{title:"Appearance",children:i.jsx(HT,{value:t.theme,onChange:o=>s({theme:o})})})}),i.jsx(Qe,{id:"transcript",storage:"browser",children:i.jsx(Ie,{title:"HITL transcript",children:i.jsx(Wg,{value:t.hitlTranscript,onChange:o=>s({hitlTranscript:o})})})}),i.jsx(Qe,{id:"agent",children:i.jsx(Ie,{title:"Agent",children:i.jsx("div",{className:"choice-row",children:sg.map(o=>i.jsx(mt,{on:o.status==="primary",disabled:o.status!=="primary",title:o.name},o.id))})})}),i.jsx(Qe,{id:"devices",storage:"machine",children:i.jsx(OT,{})})]})}function VT(e){const{data:t,route:s}=e;switch(e.group){case"trail":return i.jsx(dT,{data:t});case"project":return i.jsx(A$,{data:t,route:s});case"alerts":return i.jsx(dC,{data:t,route:s});case"you":return i.jsx(KT,{data:t});case"projects":return i.jsx(Qe,{id:"projects",storage:"machine",children:i.jsx(q$,{})});case"about":return i.jsx(Qe,{id:"changelog",children:i.jsx(gC,{})});default:return e.group}}function GT(e){const{group:t,route:s}=e,o=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{var d,h;(d=o.current)==null||d.focus({preventScroll:!0});const c=s.section&&document.getElementById(`settings-${s.section}`);c?c.scrollIntoView({block:"start"}):(h=a.current)==null||h.scrollTo({top:0})},[t.id,s.section]),i.jsx("div",{className:"sp-pane",ref:a,children:i.jsxs("div",{className:"sp-pane-in",children:[i.jsxs("header",{className:"sp-pane-head",children:[i.jsx("h2",{className:"sp-title t-title",ref:o,tabIndex:-1,children:t.label}),i.jsx("p",{className:"sp-intro t-meta",children:t.intro})]}),i.jsx(VT,{group:t.id,data:e.data,route:s})]})})}function qT(e){return i.jsx("nav",{className:"sp-nav","aria-label":"Settings groups",children:i.jsx("ul",{children:rr.map(t=>{const s=t.id===e.current;return i.jsx(Ce,{as:"li",className:"sp-nav-row",selected:s,current:s?"page":void 0,title:t.label,context:i.jsx(V,{parts:t.sections.map(o=>o.title)}),trailing:e.drill&&"›",onOpen:()=>e.onPick(t.id)},t.id)})})})}function QT(e,t){return e.group?rr.find(s=>s.id===e.group):t==="mobile"?void 0:rr[0]}const YT={page:"Back to the Lookout",list:"Lookout",group:"Settings"},JT=(e,t)=>e?t?"group":"list":"page";function XT(e){const{bp:t,route:s}=e,o=t==="mobile",a=QT(s,t),c=JT(o,!!a),d=Kg()===!1,h=()=>c==="group"?e.onShow({}):e.onClose();y.useEffect(()=>{const v=k=>{k.key!=="Escape"||k.defaultPrevented||document.querySelector(".scrim")||(c==="group"?e.onShow({}):e.onClose())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[c,e]);const m=v=>e.onShow({group:v}),p=c!=="group"&&i.jsx(qT,{current:a==null?void 0:a.id,onPick:m,drill:o});return i.jsxs(ze,{className:`zone decisions-view settings-page sp-${t}`,"aria-label":"Settings",children:[i.jsxs("header",{className:"dv-head",children:[i.jsxs("button",{className:"back",onClick:h,children:["‹ ",YT[c]]}),c!=="group"&&i.jsx(Ve,{as:"h2",children:"Settings"}),!o&&i.jsx("span",{className:"dv-head-right t-meta",children:"Esc"})]}),d&&i.jsx(nC,{}),i.jsxs("div",{className:"sp-body",children:[p,a&&i.jsx(GT,{group:a,data:e.data,route:s})]})]})}function ZT(e){var a;const{rt:t,api:s,settings:o}=e;return o.route?i.jsx(XT,{bp:e.bp,route:o.route,onShow:o.show,onClose:o.close,data:{prefs:e.prefs,update:e.update,activeTracker:t.kind,location:t.adapter.location,map:(a=s.snap)==null?void 0:a.map,onMapMode:s.actions.setMode,snaps:Object.values(s.allSnaps),answered:s.activity.answered,onModelMatching:s.actions.setModelMatching}}):null}function eE(e){return i.jsxs(ze,{className:"zone side",style:{gridArea:"inspector"},children:[i.jsx(aN,{className:"zone-tabs",value:e.tab,onChange:e.onTab,items:[{id:"ticket",label:"Ticket"},{id:"activity",label:"Activity"},{id:"plan",label:"Plan",n:e.unspecified}]}),{ticket:e.ticket,activity:e.activity,plan:e.plan}[e.tab]]})}function xv(e){return e.filter(t=>t.state!=="out-of-scope").map(t=>({x:t.x,y:t.y,w:Ke,h:Ye}))}function tE(e){const{obstacles:t,from:s,to:o,clear:a}=e,c=t.flatMap(h=>[h.y-28,h.y+h.h+28]).filter(a),d=h=>Math.abs(h-s)+Math.abs(h-o);return c.reduce((h,m)=>d(m)<d(h)?m:h,c[0]??s)}const nE=6;function sE(e){const t=e.filter((a,c)=>c===0||a.x!==e[c-1].x||a.y!==e[c-1].y);let s=`M${t[0].x} ${t[0].y}`;for(let a=1;a<t.length-1;a++){const[c,d,h]=[t[a-1],t[a],t[a+1]],m=Math.min(nE,Xm(c,d)/2,Xm(d,h)/2),p=Zm(d,c,m),v=Zm(d,h,m);s+=`L${p.x} ${p.y}Q${d.x} ${d.y} ${v.x} ${v.y}`}const o=t[t.length-1];return`${s}L${o.x} ${o.y}`}function Xm(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function Zm(e,t,s){return{x:e.x+Math.sign(t.x-e.x)*s,y:e.y+Math.sign(t.y-e.y)*s}}function Qo(e){const t=e.direction==="TB",s=d=>t?{x:d.y,y:d.x}:d,o=s(e.a),a=s(e.b),c=e.obstacles.map(d=>t?{x:d.y,y:d.x,w:d.h,h:d.w}:d);return sE(iE({a:o,b:a,obstacles:c,gap:e.gap}).map(s))}function iE({a:e,b:t,obstacles:s,gap:o}){const a=s.filter(p=>p.x+p.w>e.x+1&&p.x<t.x-1),c=p=>!a.some(v=>p>v.y-8&&p<v.y+v.h+8),d=Math.min(e.x+o/2,(e.x+t.x)/2),h=Math.max(t.x-o/2,(e.x+t.x)/2);if(c(e.y))return[e,{x:h,y:e.y},{x:h,y:t.y},t];if(c(t.y))return[e,{x:d,y:e.y},{x:d,y:t.y},t];const m=tE({obstacles:a,from:e.y,to:t.y,clear:c});return[e,{x:d,y:e.y},{x:d,y:m},{x:h,y:m},{x:h,y:t.y},t]}function rE(e){if(e.direction==="LR"){const s=e.width+96;return{x:s,y:e.graphH/2,right:s+34,bottom:e.height}}const t=e.graphH+76;return{x:e.width/2,y:t,right:e.width,bottom:Math.max(e.height,t+40)}}function oE(e,t){const s=new Set(e.edges.map(c=>c.from)),o=e.nodes.filter(c=>c.state!=="out-of-scope"&&!s.has(c)),a=xv(e.nodes);return o.map(c=>{if(e.direction==="LR"){const m={x:c.x+Ke,y:c.y+Ye/2},p={x:t.x-30,y:t.y};return Qo({direction:"LR",a:m,b:p,obstacles:a,gap:96})}const d={x:c.x+Ke/2,y:c.y+Ye},h={x:t.x,y:t.y-30};return Qo({direction:"TB",a:d,b:h,obstacles:a,gap:48})})}function aE({x:e,y:t,text:s}){const o=s!=null&&s.trim()?`Destination
|
|
161
161
|
${s.trim()}`:`Destination
|
|
162
|
-
Where this trail ends`;return i.jsxs("g",{className:"destination",transform:`translate(${e} ${t})`,"aria-label":o,"data-tip":o,tabIndex:0,children:[i.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),i.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),i.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})}function aE({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function lE(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}const Yo=(e,t)=>`${e}>${t}`;function cE(e,t,s=[]){const o=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const d=o.get(c.id);return d?{...d,blockedBy:[...c.blockedBy,...c.removedEdges??[]]}:{id:c.id,key:"+",title:c.title,type:c.type,body:"",state:"open",blockedBy:c.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(t.nodes.flatMap(c=>c.newEdges.map(d=>Yo(d,c.id)))),removedEdges:new Set(t.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>Yo(d,c.id)))),frozen:new Set(s)}}function uE(e,t){const s=mx({...e,tickets:t}),o=new Set;for(let a=1;a<s.length;a++)o.add(Yo(s[a-1].id,s[a].id));return o}const ep={LR:130,TB:68};function dE(e){const{direction:t,from:s,to:o,cards:a}=e;if(t==="LR"){const h={x:s.x+Ke,y:s.y+Ye/2},m={x:o.x,y:o.y+Ye/2};return Qo({direction:t,a:h,b:m,obstacles:a,gap:ep.LR})}const c={x:s.x+Ke/2,y:s.y+Ye},d={x:o.x+Ke/2,y:o.y};return Qo({direction:t,a:c,b:d,obstacles:a,gap:ep.TB})}function hE(e){const{from:t,to:s,direction:o}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return e.critical&&c.push("edge-critical"),e.added&&c.push("edge-added"),e.removed&&c.push("edge-removed"),i.jsx("path",{className:c.join(" "),d:dE({direction:o,from:t,to:s,cards:e.cards})})}function fE(e){const{snap:t,tickets:s,direction:o,preview:a}=e,c=y.useMemo(()=>uE(t,s),[t,s]),d=y.useMemo(()=>xv(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:m})=>{const p=Yo(h.ticket.id,m.ticket.id);return i.jsx(hE,{from:h,to:m,direction:o,cards:d,critical:c.has(p),added:a==null?void 0:a.newEdges.has(p),removed:a==null?void 0:a.removedEdges.has(p)},p)})}const zu=24,mE=13,pE=9.5;function gE(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${zu} ${e.y})`,children:e.chips.map((s,o)=>{const a=s.kind==="guide"?t:void 0;return i.jsxs("g",{className:Ge("card-chip",s.kind,s.kind==="state"&&e.tone,(a==null?void 0:a.off)&&"off"),"data-guide-id":a==null?void 0:a.id,transform:`translate(${s.x} 0)`,children:[a&&i.jsx("title",{children:a.tip}),i.jsx("rect",{width:s.w,height:mE,rx:3}),i.jsx("text",{x:(s.w-s.textW)/2,y:pE,textLength:s.textW,lengthAdjust:"spacingAndGlyphs",children:s.text})]},o)})})}const jv=5,vE={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let Yi;function kE(){if(Yi!==void 0)return Yi;try{Yi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{Yi=null}return Yi}function yE(e,t="sans"){const s=kE();return s?(s.font=vE[t],s.measureText(e).width*1.04):e.length*jv}const tp=4,np=3,wE=6;function xE(e){var k;const t=Ke-zu-8-(e.reserve??0),s=((k=e.state)==null?void 0:k.split(" · "))??[],o=[{kind:"key",text:e.key},{kind:"type",text:e.type},...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...s.map(x=>({kind:"state",text:x})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],a=t-o.length*2*tp-(o.length-1)*np,c=x=>yE(x.text,x.kind==="key"?"mono":"sans"),d=o.filter(x=>x.kind!=="guide").reduce((x,S)=>x+c(S),0),h=Math.max(wE,Math.floor((a-d)/jv)),m=o.map(x=>x.kind==="guide"?{...x,text:_C(x.text,h)}:x),p=Math.min(1,a/m.reduce((x,S)=>x+c(S),0));let v=0;return m.map(x=>{const S=c(x)*p,C={...x,x:v,w:S+2*tp,textW:S};return v+=C.w+np,C})}function jE(e,t,s){const o=e.state==="frontier"||e.state==="rework";if(!(!t||s||e.ticket.assignee||!o))return t}function SE(e){const t=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&t.push("sel"),e.live&&t.push("live"),e.waiting&&t.push("waiting"),e.stalled&&!e.waiting&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),t.join(" ")}function NE({wait:e,session:t}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?i.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const bE={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function CE(e){const t=bE[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function $E({mark:e,frozen:t}){const s=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Ye/2,x2:Ke-8,y2:Ye/2}),s&&i.jsx("text",{className:"reroute-tag",x:Ke-8,y:Ye-7,textAnchor:"end",children:s}),t&&i.jsx("text",{className:"freeze",x:Ke-(s?58:8),y:Ye-7,textAnchor:"end",children:"❄"})]})}function TE(e){const{n:t,session:s}=e,o=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.stalled?{text:`stalled · ${o}`,tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:s&&e.step?{text:`${s.agent} · step ${s.step}/${s.total}`,tone:"agent"}:s?{text:s.agent,tone:"agent"}:t.state==="claimed"?{text:o??"working",tone:"agent"}:{text:gS[t.state],tone:""}}function EE({tone:e,cy:t}){return e==="done"?i.jsx("path",{className:"dot dot-done",d:`M10 ${t}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:t,r:e==="backlog"?3:3.5})}function AE(e,t,s=2){const o=e.split(/\s+/),a=[];let c="";for(const d of o)(c+" "+d).trim().length>t?(a.push(c.trim()),c=d):c+=" "+d;if(a.push(c.trim()),a.length>s){const d=a.slice(0,s);return d[s-1]=d[s-1].slice(0,t-1)+"…",d}return a}const IE=26;function ME({n:e,session:t,stalled:s,flag:o,selected:a,onSelect:c,mark:d,frozen:h,needs:m}){const p=e.ticket,v=AE(p.title,IE),k=or(p)==="hitl",x=!!(t!=null&&t.waitingOn),S=!!d&&d!=="unchanged",C=jE(e,m,!!t),j=o$(p.guide),I=S?void 0:TE({n:e,session:t,waiting:x,stalled:s,wait:C,step:!j}),b=k&&!S&&(p.type==="task"||p.type==="execute"),R=x||!!s||!!C||b&&e.state==="frontier",O=CE({state:e.state,live:!!t,attention:R}),U=nr[p.type],X=(S&&d!=="cancelled"?44:0)+(h?12:0),Q=xE({key:p.key,type:U,guide:j==null?void 0:j.name,state:I==null?void 0:I.text,needsYou:b,reserve:X}),W=v.length>1?19:24;return i.jsxs("g",{className:SE({n:e,tone:O,hitl:k,selected:a,live:!!t,waiting:x,stalled:s,mark:d,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:ie=>{ie.stopPropagation(),c({kind:"ticket",id:p.id})},children:[i.jsx(NE,{wait:C,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ke+7,height:Ye+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ke-1,height:Ye-1,rx:6}),i.jsx(EE,{tone:O,cy:W-4}),v.map((ie,G)=>i.jsx("text",{className:"title",x:zu,y:W+G*14,children:ie},G)),i.jsx(gE,{chips:Q,y:W+v.length*14-8,tone:I==null?void 0:I.tone,guide:j}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ke-2,cy:2,r:4}),i.jsx($E,{mark:d,frozen:h})]})}const sp=.72;function RE(e){const{fit:t,nodes:s,size:o,pad:a}=e;if(t.k>=sp)return t;const c=s.find(h=>h.state==="claimed")??s.find(h=>h.state==="frontier")??s[0];if(!c)return t;const d=sp;return{k:d,x:o.w/2-(c.x+a+Ke/2)*d,y:o.h/2-(c.y+a+Ye/2)*d}}function LE(e){const{y:t,width:s,height:o}=e,a=e.nodes.filter(c=>c.state==="out-of-scope").length;return a?i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:t-30,width:s+40,height:o+18,fill:"url(#hatch-oos)"}),i.jsx("line",{x1:-20,y1:t-30,x2:s+20,y2:t-30}),i.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",a]})]}):null}const st=280,ip=4,OE=220,Us=e=>Math.round(e/ip)*ip;function PE(e){let t=2166136261;for(const s of e)t=Math.imul(t^s.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let s=Math.imul(t^t>>>15,1|t);return s=s+Math.imul(s^s>>>7,61|s)^s,((s^s>>>14)>>>0)/4294967296}}function Pc(e,t,s,o){return Array.from({length:6},()=>{const a=o*(.5+e()*.7),c=o*(.3+e()*.4);return{x:Us(t+(e()-.5)*o*.8-a/2),y:Us(s+(e()-.5)*o*.5-c/2),w:Us(a),h:Us(c)}})}function _E(e){const{width:t,height:s,nodes:o}=e,a=PE(e.seed),c=(x,S)=>x+a()*(S-x),d=(x,S)=>!o.some(C=>x>C.x-52&&x<C.x+Ke+28&&S>C.y-52&&S<C.y+Ye+28),h=(t+st*2)*(s+st*2),m=Array.from({length:Math.round(h/9e4)},()=>Pc(a,c(-st,t+st),c(-st,s+st),c(160,360))).flat(),p=[...Pc(a,t+st*.55,s+st*.55,300),...Pc(a,-st*.5,-st*.45,220)],v=[],k=(x,S,C)=>{v.length<OE&&d(S,C)&&v.push({sprite:x,x:Us(S),y:Us(C)})};for(let x=0;x<Math.round(h/3e4);x++){const S=c(-st,t+st),C=c(-st,s+st),j=3+Math.floor(a()*5);for(let I=0;I<j;I++)k(a()<.65?"pine":"oak",S+c(-70,70),C+c(-44,44))}for(let x=0;x<Math.round(h/45e3);x++)k(a()<.4?"rock":"tuft",c(-st,t+st),c(-st,s+st));return v.sort((x,S)=>x.y-S.y),{grass:m,water:p,items:v}}const Sv={pine:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),i.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),i.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:i.jsx("path",{d:"M4 8Q3 4 1 1M14 8Q14 3 14 0M24 8Q25 4 27 1",fill:"none",stroke:"var(--map-pine2)",strokeWidth:"2.5",strokeLinecap:"round"})};function DE({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:Sv[e]})}const zE=Object.keys(Sv),BE=y.memo(function(t){const{seed:s,width:o,height:a,nodes:c}=t,d=y.useMemo(()=>_E({seed:s,width:o,height:a,nodes:c}),[s,o,a,c]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:zE.map(h=>i.jsx(DE,{name:h},h))}),d.grass.map((h,m)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-grass)"},m)),d.water.map((h,m)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-water)"},m)),i.jsx("rect",{x:-4e3,y:-4e3,width:o+8e3,height:a+8e3,fill:"url(#map-grid)"}),d.items.map((h,m)=>i.jsx("use",{href:`#terrain-${h.sprite}`,x:h.x,y:h.y},m))]})}),FE=380;function UE(e){const{selId:t,size:s}=e,o=y.useRef(e);o.current=e;const a=y.useRef(!0);y.useEffect(()=>{if(a.current){a.current=!1;return}const{nodes:c,pad:d,view:h,setView:m,onFocus:p}=o.current,v=t?c.find(b=>b.ticket.id===t):void 0;if(!v||!s.w)return;p();const k=Math.min(1.4,Math.max(h.k,1.05)),x={k,x:s.w/2-(d+v.x+Ke/2)*k,y:s.h/2-(d+v.y+Ye/2)*k};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(x);const S=h,C=performance.now();let j=0;const I=b=>{const R=Math.min(1,(b-C)/FE),O=1-(1-R)**3;m({k:S.k+(x.k-S.k)*O,x:S.x+(x.x-S.x)*O,y:S.y+(x.y-S.y)*O}),R<1&&(j=requestAnimationFrame(I))};return j=requestAnimationFrame(I),()=>cancelAnimationFrame(j)},[t])}function WE(e,t){const s=y.useRef(t);s.current=t,y.useEffect(()=>{const o=e.current;if(!o)return;const a=p=>{const v=o.getBoundingClientRect();return{x:p.clientX-v.left,y:p.clientY-v.top}},c=p=>{p.preventDefault();const v=p.ctrlKey?.01:.0015;s.current(Math.exp(-p.deltaY*v),a(p))};let d=1;const h=p=>{p.preventDefault(),d=1},m=p=>{p.preventDefault();const v=p;s.current(v.scale/d,a(v)),d=v.scale};return o.addEventListener("wheel",c,{passive:!1}),o.addEventListener("gesturestart",h,{passive:!1}),o.addEventListener("gesturechange",m,{passive:!1}),()=>{o.removeEventListener("wheel",c),o.removeEventListener("gesturestart",h),o.removeEventListener("gesturechange",m)}},[e])}function rp(e,t,s){const o=Math.min(3,Math.max(.2,t));return{k:o,x:s.x-(s.x-e.x)*o/e.k,y:s.y-(s.y-e.y)*o/e.k}}const sn=32,HE=1.8;function KE(e){var oe;const{snap:t,selection:s,onSelect:o,preview:a}=e,c=(a==null?void 0:a.tickets)??t.tickets,d=y.useRef(null),[h,m]=y.useState({w:0,h:0});y.useEffect(()=>{const D=d.current;if(!D)return;const J=new ResizeObserver(([le])=>m({w:le.contentRect.width,h:le.contentRect.height}));return J.observe(D),()=>J.disconnect()},[]);const p=y.useMemo(()=>{const D=Wf(c,"LR",t.map.mode),J=Wf(c,"TB",t.map.mode),le=ee=>Math.min(h.w/(ee.width+sn*2),h.h/(ee.height+sn*2+16));return le(D)*HE>=le(J)?D:J},[c,t.map.mode,h.w,h.h]),v=(D,J)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(h.w/D,h.h/J))),k=y.useMemo(()=>{const D=p.width+sn*2,J=p.height+sn*2+16,ee=p.nodes.some(Y=>Y.state==="out-of-scope")&&h.h?Math.max(0,h.h/v(D,J)-J):0;if(!ee)return{...p,slack:ee};const K=new Map(p.nodes.map(Y=>[Y,{...Y,y:Y.y+(Y.state==="out-of-scope"?ee:ee/2)}]));return{...p,slack:ee,nodes:[...K.values()],edges:p.edges.map(Y=>({from:K.get(Y.from),to:K.get(Y.to)})),quarantineY:p.quarantineY+ee,height:p.height+ee}},[p,h.w,h.h,e.minFit]),x=iE(k),S=x.right+sn*2,C=x.bottom+sn*2+16,j=()=>{const D=v(S,C);return{k:D,x:Math.max(0,(h.w-S*D)/2),y:Math.max(0,(h.h-C*D)/2)}},[I,b]=y.useState({k:1,x:0,y:0}),R=y.useRef(!1);y.useEffect(()=>{R.current=!1},[t.map.id]),y.useEffect(()=>{!R.current&&h.w&&b(RE({fit:j(),nodes:k.nodes,size:h,pad:sn}))},[h.w,h.h,S,C,t.map.id]);const O=y.useRef(new Map),U=y.useRef(null),X=D=>{const J=d.current.getBoundingClientRect();return{x:D.clientX-J.left,y:D.clientY-J.top}},Q=()=>{var ee;const D=[...O.current.values()],J=D.length>1?{x:(D[0].x+D[1].x)/2,y:(D[0].y+D[1].y)/2}:D[0],le=D.length>1?Math.hypot(D[0].x-D[1].x,D[0].y-D[1].y):0;U.current={view:I,dist:le,mid:J,moved:((ee=U.current)==null?void 0:ee.moved)??!1}};WE(d,(D,J)=>{R.current=!0,b(le=>rp(le,le.k*D,J))});const W=Yt(5e3),ie=yu(e.leases,t.map.id),G=Tu(),ve=(oe=_u())==null?void 0:oe.waiting,Pe=new Map(e.sessions.filter(D=>cn(D)&&D.ticketId).map(D=>[D.ticketId,D])),$e=(s==null?void 0:s.kind)==="ticket"?s.id:void 0;return UE({selId:$e,nodes:k.nodes,size:h,pad:sn,view:I,setView:b,onFocus:()=>R.current=!0}),i.jsxs("div",{className:"graph-box",ref:d,onPointerDown:D=>{O.current.set(D.pointerId,X(D)),O.current.size===1&&(U.current=null),Q()},onPointerMove:D=>{var ee;if(!O.current.has(D.pointerId)||!U.current)return;O.current.set(D.pointerId,X(D));const J=U.current,le=[...O.current.values()];if(le.length>1){const K={x:(le[0].x+le[1].x)/2,y:(le[0].y+le[1].y)/2},Y=Math.hypot(le[0].x-le[1].x,le[0].y-le[1].y),B=rp(J.view,J.view.k*Y/(J.dist||Y),J.mid);b({...B,x:B.x+K.x-J.mid.x,y:B.y+K.y-J.mid.y}),J.moved=!0}else{const K=le[0].x-J.mid.x,Y=le[0].y-J.mid.y;if(!J.moved&&Math.hypot(K,Y)<5)return;J.moved||(ee=d.current)==null||ee.setPointerCapture(D.pointerId),J.moved=!0,b({...J.view,x:J.view.x+K,y:J.view.y+Y})}R.current=!0},onPointerUp:D=>{O.current.delete(D.pointerId),O.current.size&&Q()},onPointerCancel:D=>O.current.delete(D.pointerId),onClickCapture:D=>{var J;(J=U.current)!=null&&J.moved&&(D.stopPropagation(),U.current=null)},children:[i.jsxs("svg",{className:"graph",width:h.w,height:h.h,onClick:()=>o(null),children:[i.jsx(lE,{}),i.jsx("g",{transform:`translate(${I.x} ${I.y}) scale(${I.k})`,children:i.jsxs("g",{transform:`translate(${sn} ${sn})`,children:[i.jsx(BE,{seed:t.map.id,width:S,height:C,nodes:k.nodes}),i.jsx(LE,{y:k.quarantineY,width:k.width,height:k.quarantineH,nodes:k.nodes}),i.jsx(fE,{snap:t,tickets:c,direction:k.direction,nodes:k.nodes,edges:k.edges,preview:a}),i.jsx(aE,{trails:rE(k,x)}),k.nodes.length>0&&i.jsx(oE,{x:x.x,y:x.y,text:t.map.sections.destination}),k.nodes.map(D=>{var J;return i.jsx(ME,{n:D,session:Pe.get(D.ticket.id),stalled:!!ie.get(D.ticket.id)&&aa(ie.get(D.ticket.id),W)!=="live",flag:OS(Ys.ticket(G,t.map.id,D.ticket.id)),selected:$e===D.ticket.id,onSelect:o,mark:a==null?void 0:a.marks.get(D.ticket.id),frozen:a==null?void 0:a.frozen.has(D.ticket.id),needs:(J=ve==null?void 0:ve.find(le=>le.mapId===t.map.id&&le.ticketId===D.ticket.id))==null?void 0:J.tier},D.ticket.id)})]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),R.current=!0,b(j())},children:"Fit"})]})}const _c=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],op=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function VE({snap:e,sessions:t}){const s=Mp(e),o=p=>s[p],a=t.filter(xg).length,c=px(e),d=Math.max(1,...c.map(p=>p.open+p.closed)),m=(e.map.verification??"off")!=="off"||op.some(([p])=>o(p))?[..._c.slice(0,2),...op,..._c.slice(2)]:_c;return i.jsxs("div",{className:"status-panel",children:[i.jsxs("div",{className:"sp-col sp-status",children:[i.jsxs("div",{className:"sp-head",children:[i.jsx(Ve,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[s.total," tickets"]})]}),i.jsxs("ul",{children:[m.map(([p,v])=>i.jsxs("li",{className:`st-${p} ${o(p)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:v}),i.jsx("b",{children:o(p)})]},p)),i.jsxs("li",{className:`st-waiting ${a?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:a})]})]})]}),i.jsxs("div",{className:"sp-block sp-col",children:[i.jsx("span",{className:"t-label",children:"Type mix"}),i.jsx("ul",{className:"mix",children:c.map(p=>i.jsxs("li",{title:`${p.type}: ${p.closed} closed, ${p.open} open`,children:[i.jsx("span",{className:"t-meta",children:nr[p.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${p.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${p.open/d*100}%`}})]}),i.jsx("b",{children:p.open+p.closed})]},p.type))})]})]})}function GE(e){const[t,s]=y.useState(!1);return i.jsxs("div",{className:t?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":t,onPointerDown:o=>o.stopPropagation(),onClick:()=>s(!t),children:["Summary ",i.jsx("span",{className:"caret",children:t?"▾":"▴"})]}),i.jsx(VE,{snap:e.snap,sessions:e.sessions})]})}function qE({planOnly:e,verifies:t}){const s=[["frontier","Ready"],["claimed","Working"],...t?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[s.map(([o,a])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),a]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function QE(e){var o,a;const{snap:t,selection:s}=e.api;return i.jsxs(ze,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&i.jsx(rb,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(GE,{snap:t,sessions:e.sessions}),t?i.jsx(KE,{snap:t,sessions:e.sessions,leases:e.api.leases,selection:s,onSelect:e.onSelect,minFit:e.minFit,preview:(a=e.trail)==null?void 0:a.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(cb,{}),i.jsx("h2",{children:"No trail"}),i.jsx("p",{className:"nomap-lede",children:"Describe your idea and create the trail here, or start it in your agent's chat. Scout frames it with you, then your agents get to work."}),i.jsx("div",{className:"actions",children:i.jsx(P,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),i.jsx(Ko,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(qE,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const YE=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function JE(e){const{tab:t,covered:s,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:YE.map(([a,c])=>i.jsxs("button",{className:t===a&&!s?"on":"",onClick:()=>e.onPick(a),children:[c,a==="home"&&o>0&&i.jsx(ds,{n:o,urgent:!0,pop:!0},o)]},a))})}function XE(e){const t={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(ze,{className:"zone",children:e.ticket}),activity:i.jsx(ze,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const ap={settingsPage:!0},lp=()=>Hg(new URLSearchParams(location.search).get("settings")),cp=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function ZE(){const[e,t]=y.useState(lp);y.useEffect(()=>{e&&!cp()&&(history.replaceState(null,"",Xi(location.href,null)),history.pushState(ap,"",Xi(location.href,e)));const c=()=>t(lp());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const s=c=>{const d=Xi(location.href,c);e?history.replaceState(history.state,"",d):history.pushState(ap,"",d),t(c)},o=()=>{e&&(t(null),cp()?history.back():history.replaceState(null,"",Xi(location.href,null)))},a=c=>s(Hg(c??"")??{});return{route:e,open:a,show:s,close:o,toggle:()=>e?o():a()}}function e2(e,t){const{activity:s,selection:o,setSelection:a,actions:c}=e,[d,h]=y.useState("ticket"),[m,p]=y.useState("home"),[v,k]=y.useState(0),[x,S]=y.useState(null),[C,j]=y.useState(!1),I=Q=>{j(!1),S({focus:Q})},b=()=>{S(null),j(Q=>!Q)};y.useEffect(()=>{const Q=s.sessions.find(W=>W.id===e.chatSession);!o&&(Q!=null&&Q.ticketId)&&Q.mapId===e.mapId&&a({kind:"ticket",id:Q.ticketId})},[e.chatSession,e.mapId]);const R=Q=>{a(Q),Q&&(t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket"))},O=(Q,W,ie)=>{ie&&ie!==e.mapId&&c.selectMap(ie),c.openChat(Q);const G=s.sessions.find(ve=>ve.id===Q);W&&(G==null?void 0:G.mapId)===(ie??e.mapId)&&a({kind:"ticket",id:W}),t==="mobile"&&(p("home"),k(ve=>ve+1))};return{sideTab:d,setSideTab:h,phoneTab:m,setPhoneTab:p,convRequest:v,decisionsView:x,setDecisionsView:S,openDecisions:I,statsOpen:C,setStatsOpen:j,toggleStats:b,select:R,openChat:O,showChat:(Q,W,ie)=>{O(Q,W,ie),k(G=>G+1)},openTicket:(Q,W)=>{Q!==e.mapId&&c.selectMap(Q),a({kind:"ticket",id:W}),S(null),t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket")}}}function t2(e,t){y.useEffect(()=>{document.title=`${te.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function n2(e){const[t,s]=y.useState("…");return y.useEffect(()=>{fetch(`${je()}/list`).then(o=>o.json()).then(o=>{var c;const a=o.root.split("/").filter(Boolean);s((c=a[a.length-1])!=null&&c.startsWith(".")?a[a.length-2]??"repo":a[a.length-1]??"repo")}).catch(()=>s("repo"))},[e]),t}function s2(e,t){return y.useMemo(()=>{const s=e.sessions.filter(a=>a.mapId===t),o=new Set(e.sessions.filter(a=>a.mapId!==t).map(a=>a.id));return{...e,sessions:s,feed:e.feed.filter(a=>!a.sessionId||!o.has(a.sessionId))}},[e,t])}function i2({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
|
|
163
|
-
`).map((t,s)=>i.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,a)=>a%2===1?i.jsx("code",{children:o.replace(/`/g,"")},a):o)},s))}):i.jsx(Ae,{children:"Not covered"})}const up=["summary","productContext","existing","conventions","dataModel","api","risks"];function
|
|
164
|
-
`)[0].slice(0,80)}`,body:d[p],kind:p==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},p)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:qi.assumptions}),d.assumptions.length?i.jsx("ul",{className:"item-list",children:d.assumptions.map(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.text}),i.jsx(V,{parts:[{text:p.id,code:!0}]})]},p.id))}):i.jsx(Ae,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:qi.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.openQuestions.map(p=>i.jsx("li",{children:p},p))}):i.jsx(Ae,{children:"None"})]}),m.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",m.map(p=>qi[p].toLowerCase()).join(", "),"."]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:t.note})]})]}),s&&i.jsx(Ze,{label:"What should change?",children:i.jsx("textarea",{rows:3,value:a,onChange:p=>c(p.target.value),autoFocus:!0})}),e.changed&&e.onReviewAgain&&i.jsx(pa,{what:"The brief",onReviewAgain:e.onReviewAgain}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[t.status==="submitted"&&!s&&i.jsxs(i.Fragment,{children:[i.jsx(P,{onClick:()=>o(!0),children:"Request changes"}),i.jsx(P,{variant:"primary",disabled:e.changed,onClick:e.onAccept,children:"Accept brief"})]}),s&&i.jsxs(i.Fragment,{children:[i.jsx(P,{variant:"ghost",onClick:()=>o(!1),children:"Back"}),i.jsx(P,{variant:"primary",disabled:!a.trim(),onClick:()=>e.onRequestChanges(a.trim()),children:"Send to the agent"})]}),i.jsx(P,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function
|
|
165
|
-
`)[0],detailText:e.sections.summary,onOpen:t})})}const
|
|
166
|
-
`):"",banner:c&&i.jsx(c2,{brief:c,onReview:a}),inboxCard:c&&i.jsx(a2,{brief:c,onReview:a}),dialog:c&&s&&i.jsx(r2,{brief:c,error:t.error,changed:d.changed,onReviewAgain:d.reviewAgain,onAccept:()=>void t.accept(d.hash).then(m=>m&&o(!1)),onRequestChanges:m=>void t.requestChanges(m).then(p=>p&&o(!1)),onClose:()=>o(!1)})}}function f2(e){var p;const{reroute:t,onReview:s}=e,o=t.kind==="challenge-destination",a=((p=t.frozen)==null?void 0:p.length)??0,c=o?"wrong mountain?":"proposes a new plan",d=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",h=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",m=`${t.reason.replace(/\.$/,"")}.${d}${h}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:m,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[t.by," ",c]}),i.jsx("span",{className:"t-meta",children:m})]}),i.jsx(ni,{text:"An agent found that an assumption or the plan no longer holds and proposes changes. The map shows them: dashed outlines are tickets it adds, struck ones it cancels, ❄ marks tickets frozen until you approve or reject. Nothing changes until you decide."}),i.jsx(P,{size:"sm",variant:"ghost",className:"reroute-dismiss",onClick:e.onDismiss,children:"Dismiss"}),i.jsx(P,{size:"sm",variant:"primary",onClick:s,children:"Review"})]})}const m2=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function p2(e,t){const s=new Set(m2(t));return e.tickets.filter(o=>s.has(o.id)&&o.updatedAt>t.at).map(o=>({key:o.key,title:o.title,what:g2(o)}))}function g2(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function v2({parts:e}){return i.jsx("dl",{className:"reroute-parts",children:e.map(t=>i.jsxs("div",{children:[i.jsx("dt",{className:"t-label",children:t.label}),i.jsx("dd",{className:"t-body",children:t.text})]},t.label))})}const k2={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},bv="Dismissed by the trail lead. Carry on with the current plan.",y2="Declined by the trail lead.";function w2(e,t){var s,o,a;switch(e.op){case"edit_ticket":return[...(s=e.title)!=null&&s.trim()?[{label:"New title",text:e.title.trim()}]:[],...(o=e.body)!=null&&o.trim()?[{label:"New description (replaces the old one)",text:e.body.trim()}]:[]];case"add_ticket":return[...(a=e.body)!=null&&a.trim()?[{label:"Description",text:e.body.trim()}]:[],{label:"Who decides",text:e.hitl?"You (HITL)":"Agents, without you"}];case"supersede_decision":return[{label:`New answer to ${e.decision}`,text:e.answer},{label:"Rationale",text:e.rationale},{label:"Recorded as",text:`Proposed by ${t}, approved by you; the words stay ${t}'s.`}];default:return[]}}function x2(e,t){var s;switch(e.op){case"add_ticket":{const o=(s=e.blockedBy)!=null&&s.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:t(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:t(e.ticket),detail:j2(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:S2(e,t)};case"supersede_decision":return{verb:"Supersede",text:e.decision,detail:"Replaced by the answer below"};case"update_destination":return{verb:"Destination",text:e.text};case"add_unspecified":return{verb:"Not yet specified",text:e.text};case"add_out_of_scope":return{verb:"Out of scope",text:e.text};case"reopen":return{verb:"Reopen",text:t(e.ticket),detail:`Back in the queue: ${e.reason}`};case"skip_discovery":return{verb:"Skip discovery",text:"Implementation stops waiting for a discovery brief",detail:"The discovery ticket is ruled out"};case"set_mode":return{verb:"Mode",text:e.mode,detail:e.mode==="plan-only"?"Execute tickets wait":"Execute tickets can be worked"};default:return e}}function j2(e){var s,o;return[((s=e.title)==null?void 0:s.trim())&&"New title",((o=e.body)==null?void 0:o.trim())&&"new description"].filter(Boolean).join(" and ").replace(/^new/,"New")}function S2(e,t){var o,a;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(a=e.removeBlockedBy)!=null&&a.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const N2=new Set(["cancel_ticket","update_destination"]);function b2(e){const{change:t,name:s}=e,o=x2(t,s),a=w2(t,e.by);return i.jsx(Ce,{as:"li",className:`reroute-change op-${t.op}`,edge:N2.has(t.op)?"attention":"neutral",title:o.text,titleText:o.text,context:i.jsx(V,{parts:[{text:o.verb,strong:!0}]}),detail:o.detail,detailText:o.detail,below:a.length?i.jsx(v2,{parts:a}):void 0})}function C2(e){const{reason:t,destination:s}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:k2[t]}),s&&i.jsxs("div",{className:"reroute-destination-diff",children:[i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Destination now"}),i.jsx("p",{className:"before",children:s.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:s.after})]})]})]})}function $2(e){return i.jsxs("section",{className:"reroute-drift edge-note edge-attention",children:[i.jsx("h3",{className:"mono-label",children:"Changed since it was proposed"}),i.jsx("ul",{className:"item-list",children:e.changed.map(t=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:t.title}),i.jsx(V,{parts:[{text:t.key,code:!0},t.what]})]},t.key))}),i.jsxs("label",{className:"reroute-seen t-body",children:[i.jsx("input",{type:"checkbox",checked:e.seen,onChange:t=>e.onSeen(t.target.checked)})," I’ve seen what changed: apply the proposal to the trail as it is now"]})]})}function T2(e,t){const s=new Map(e.tickets.map(a=>[a.id,a.key])),o=new Map(t.flatMap(a=>a.op==="add_ticket"?[[a.ref,a.title]]:[]));return a=>{const c=s.get(a);if(c)return c;const d=o.get(a);return d?`new: ${d}`:a}}function E2(e){var R,O;const{reroute:t,snap:s}=e,[o,a]=y.useState(""),[c,d]=y.useState(!1);y.useEffect(()=>{const U=X=>X.key==="Escape"&&e.onClose();return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const h=T2(s,t.changes),m=new Map(s.tickets.map(U=>[U.id,`${U.key} ${U.title}`])),p=U=>m.get(U)??h(U),v=s.map.sections.assumptions??[],k=t.invalidates.map(U=>v.find(X=>X.id===U)??{id:U,text:""}),x=t.status==="pending",S=x?p2(s,t):[],C=!S.length||c,j=t.kind==="challenge-destination",I=t.lane==="setting",b=I?`${t.by} asks to change your setting`:"Reroute proposal";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(ze,{as:"div",className:"dialog reroute-dialog",onClick:U=>U.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:j?"Destination challenged":b}),i.jsx(V,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${dn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[e.replaced&&i.jsxs("p",{className:"reroute-replaced t-meta edge-note edge-attention",children:[t.by," replaced ",e.replaced," with this proposal while you were reading: review it again."]}),j&&i.jsx(C2,{reason:t.destinationReason,destination:(R=t.diff)==null?void 0:R.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:t.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),k.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:k.map(U=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:U.text}),i.jsx(V,{parts:[{text:U.id,code:!0}]})]},U.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map((U,X)=>i.jsx(b2,{change:U,by:t.by,name:p},X))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&i.jsxs("p",{className:"t-meta",children:["It touches ",t.wide.touched," of ",t.wide.open," open tickets, so it freezes none: the current plan stands until you decide."]}),(O=t.frozen)!=null&&O.length?i.jsx("ul",{className:"item-list",children:t.frozen.map(U=>i.jsx("li",{className:"item-text",children:p(U)},U))}):i.jsx(Ae,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),S.length>0&&i.jsx($2,{changed:S,seen:c,onSeen:d}),x&&i.jsx(Ze,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:U=>a(U.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[x&&i.jsxs(i.Fragment,{children:[i.jsx(P,{className:"reroute-dismiss",variant:"ghost","data-tip":"Reject it without a note of your own",onClick:()=>e.onReject(I?y2:bv),children:I?"Decline":"Dismiss"}),i.jsx(P,{className:"reroute-reject",disabled:!o.trim(),onClick:()=>e.onReject(o.trim()),children:"Reject"}),i.jsx(P,{className:"reroute-approve",variant:"primary",disabled:!C,onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(P,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const Cv=`${je()}/reroutes`;async function A2(e){if(!e)return[];const t=await fetch(`${Cv}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function I2(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState([]),[a,c]=y.useState(),{reload:d}=pt({view:t,version:e==null?void 0:e.tickets.reduce((m,p)=>Math.max(m,p.updatedAt),e.map.updatedAt),load:()=>A2(t),show:o,failed:()=>o([]),events:{reroute:m=>(m==null?void 0:m.mapId)===t}}),h=async(m,p,v)=>{var C,j;const k=await fetch(`${Cv}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:p,note:v,hash:(C=s.find(I=>I.id===p))==null?void 0:C.hash})}),x=await k.json().catch(()=>({}));if(k.ok)return c(void 0),d(),!0;const S=(j=x.errors)==null?void 0:j.map(I=>I.message).join("; ");return c([x.error??`HTTP ${k.status}`,S].filter(Boolean).join(": ")),!1};return{reroutes:s,pending:s.find(m=>m.status==="pending"),error:a,clearError:()=>c(void 0),approve:(m,p)=>h("approve",m,p),reject:(m,p)=>h("reject",m,p)}}function M2(e,t){let s=t;for(let o=0;s&&o<e.length;o++){const a=e.find(c=>c.id===s);if((a==null?void 0:a.status)!=="superseded"||!a.supersededBy)break;s=a.supersededBy}return s!==t?{id:s,replaced:t}:{id:t}}function R2(e,t){const s=I2(e),[o,a]=y.useState(),c=M2(s.reroutes,o),d=s.reroutes.find(k=>k.id===c.id),h=d!=null&&d.diff?d:s.pending,m=()=>{a(void 0),s.clearError()},p=k=>k&&m(),v=s.pending;return{banner:v&&i.jsx(f2,{reroute:v,onReview:()=>a(v.id),onDismiss:()=>void s.reject(v.id,bv)}),preview:e&&(h!=null&&h.diff)?cE(e,h.diff,h.frozen):void 0,openReroute:(k,x)=>{k!==(e==null?void 0:e.map.id)&&(t==null||t(k)),a(x)},dialog:e&&d&&i.jsx(E2,{reroute:d,replaced:c.replaced,snap:e,error:s.error,onApprove:k=>void s.approve(d.id,k||void 0).then(p),onReject:k=>void s.reject(d.id,k).then(p),onClose:m},d.id)}}function L2(e,t){const s=h2(e),o=R2(e,t);return{briefText:s.briefText,inboxCard:s.inboxCard,review:s.review,banner:i.jsxs(i.Fragment,{children:[s.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[s.dialog,o.dialog]})}}function O2(){const e=new URL(location.href);e.searchParams.has(Gs)&&(e.searchParams.delete(Gs),history.replaceState(history.state,"",e))}function P2(e,t){return e.kind!=="question"||t.pending.some(s=>s.id===e.ref)}function _2(e){const[t,s]=y.useState(()=>new URLSearchParams(location.search).get(Gs)??void 0),{loaded:o,view:a,activity:c,handlers:d,showChat:h}=e;return y.useEffect(()=>{if(!t||!o||!a)return;const m=a.items.find(v=>v.id===t);if(m&&!P2(m,c)||(s(void 0),O2(),!m))return;Ig(m,{...d,openQuestion:v=>{const k=c.pending.find(x=>x.id===v);k&&h(k.sessionId,k.ticketId)}})},[t,o,a,c,d,h]),{request:y.useCallback(m=>s(m),[])}}function D2(e){const{api:t,nav:s}=e,o=Rg(t.allSnaps);K1(o.view);const a=p=>p&&t.actions.selectMap(p),c={openTicket:s.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:p=>p===t.mapId?e.reviewBrief():a(p),openReroute:e.openReroute??(p=>p.ticketId?s.openTicket(p.mapId,p.ticketId):a(p.mapId)),selectTrail:a,openGuides:e.openGuides,openConnector:e.openConnector,openApprovals:e.openApprovals},d=o.view,h=_2({loaded:t.loaded,view:d,activity:t.activity,handlers:c,showChat:s.showChat}),m=d&&i.jsx(F1,{view:d,onFocus:p=>void o.savePrefs(kj(d.prefs,p,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:c,header:m,link:h}}async function z2(){const e=await fetch(`${je()}/signed-state`);return e.ok?await e.json():null}function B2(){const[e,t]=y.useState();return pt({load:z2,show:t,failed:()=>t(null),changed:s=>s.endsWith("map.md")||s.includes("/tickets/")||s.includes("/decisions/")}),e}const F2={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function U2(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function $v({mapId:e,kind:t,id:s}){const o=B2(),a=d=>d.mapId===e&&d.kind===t&&d.id===s,c=o==null?void 0:o.changes.find(a);return c?i.jsx(Ce,{className:"d-section",edge:"attention",title:"Changed outside Teamtrail",context:i.jsx(V,{parts:[`${U2(c.fields)} · ${F2[t]}`]}),detail:"By a teammate or an agent editing the file. Settings → Approvals shows what changed."}):o!=null&&o.textEdits.some(a)?i.jsx(V,{className:"d-section",parts:["Text edited outside Teamtrail"]}):null}function W2({d:e}){return e.derived?i.jsx(V,{className:"d-section",parts:["Unverified · read from text anyone who can edit the tracker wrote, not a decision Teamtrail recorded"]}):null}function H2(e){const{d:t,snap:s}=e,o=oi(),[a,c]=y.useState(!1),[d,h]=y.useState(""),[m,p]=y.useState("");y.useEffect(()=>{c(!1),h(""),p("")},[t.id,t.mapId]);const v=Yw(e.all.filter(j=>j.mapId===t.mapId),t.id),k=ar(t),x=t.ticketId?s==null?void 0:s.tickets.find(j=>j.id===t.ticketId):void 0,S=Date.now(),C=Zs(t.source.url);return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:t.id}),i.jsx(Yn,{tone:"state",className:`dv-st-${k}`,children:k}),i.jsx(V,{parts:[pS(t.decidedAt),`${dn(S-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsx($v,{mapId:t.mapId,kind:"decision",id:t.id}),i.jsx(W2,{d:t}),i.jsxs("div",{className:"resolution",children:[i.jsx(Jc,{parts:["Decision"]}),i.jsx("p",{children:t.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:s?`${s.map.key} ${s.map.title}`:t.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:t.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(x==null?void 0:x.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:[Gn(t.decidedBy,o),Ep(t)].filter(Boolean).join(", ")}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(j=>j.name??j.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[qn[t.source.kind].label,C&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:C,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!C&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(j=>i.jsx("li",{children:j},j))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.rationale})]}),v.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:v.map(j=>i.jsx("li",{className:`${j.id===t.id?"cur":""} ${j.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(j.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:j.id}),i.jsx("span",{className:"a",children:j.summary}),i.jsx(V,{parts:[Gn(j.decidedBy,o),Qs(j.decidedAt)]})]})},j.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(Eu,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
|
|
167
|
-
|
|
168
|
-
`),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),k==="active"&&!t.postedBy&&i.jsx(P,{on:a,onClick:()=>c(j=>!j),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),a&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),d.trim()&&(e.onSupersede(t,{answer:d.trim(),rationale:m.trim(),alternatives:[t.summary]}),c(!1))},children:[i.jsx(Ze,{label:"New decision",children:i.jsx("textarea",{rows:3,value:d,onChange:j=>h(j.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:m,onChange:j=>p(j.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((j,I)=>i.jsxs("div",{className:`msg from-${j.from} voice-${j.from==="human"?"human":"agent"}`,children:[i.jsx(Jc,{parts:[Gn(j.author,o),ku(j.at)]}),i.jsx("div",{className:"msg-text",children:j.text})]},I))}):i.jsx(Ae,{children:"None recorded"})]})]})}function _t(e){return i.jsx("li",{children:i.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[i.jsx("span",{className:"ttl",children:e.label}),i.jsx("b",{children:e.n})]})})}function K2(e){const{filter:t,set:s,all:o}=e,a=c=>o.filter(c).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(dt,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:c=>s({mapId:c||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(c=>({value:c.map.id,label:`${c.map.key} ${c.map.title}`}))]}),i.jsx(dt,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:c=>s({source:c||void 0}),options:[{value:"",label:"All sources"},...Do.map(c=>({value:c,label:qn[c].label}))]}),i.jsx(dt,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:c=>s({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),i.jsx(dt,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:c=>s({status:c||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):i.jsxs("aside",{className:"dv-filters",children:[i.jsx("h3",{className:"mono-label",children:"Trail"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>s({mapId:void 0})}),e.trails.map(c=>i.jsx(_t,{on:t.mapId===c.map.id,label:`${c.map.key} ${c.map.title}`,n:a(d=>d.mapId===c.map.id),onClick:()=>s({mapId:c.map.id})},c.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.source,label:"All",n:o.length,onClick:()=>s({source:void 0})}),Do.map(c=>i.jsx(_t,{cls:`src-${c}`,on:t.source===c,label:qn[c].label,n:a(d=>d.source.kind===c),onClick:()=>s({source:t.source===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>s({madeBy:void 0})}),i.jsx(_t,{on:t.madeBy==="agent",label:"Agents, on their own",n:a(c=>tr(c)==="agent"),onClick:()=>s({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(_t,{on:t.madeBy==="human",label:"People",n:a(c=>tr(c)==="human"),onClick:()=>s({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>s({decidedBy:void 0})}),e.people.map(c=>i.jsx(_t,{on:t.decidedBy===c,label:c,n:a(d=>d.decidedBy===c),onClick:()=>s({decidedBy:t.decidedBy===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.status,label:"Any",n:o.length,onClick:()=>s({status:void 0})}),i.jsx(_t,{on:t.status==="active",label:"Active",n:a(c=>!c.supersededBy),onClick:()=>s({status:t.status==="active"?void 0:"active"})}),i.jsx(_t,{on:t.status==="superseded",label:"Superseded",n:a(c=>!!c.supersededBy),onClick:()=>s({status:t.status==="superseded"?void 0:"superseded"})})]})]})}function V2(e){if(ar(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function G2(e){const{d:t}=e,s=oi(),o=ar(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:Qs(t.decidedAt)}),i.jsx(Ce,{as:"li",className:`dv-row ${o}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:ku(t.decidedAt),context:i.jsx(V,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,Gn(t.decidedBy,s),Ep(t)??qn[t.source.kind].label,V2(t)]}),detail:t.summary,detailText:t.summary})]})}function q2(e){const{rows:t,current:s}=e;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((o,a)=>{var c;return i.jsx(G2,{d:o,newDay:a===0||Qs(t[a-1].decidedAt)!==Qs(o.decidedAt),trail:(c=e.snaps[o.mapId])==null?void 0:c.map.key,on:(s==null?void 0:s.id)===o.id&&s.mapId===o.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(o.id)},`${o.mapId}:${o.id}`)}):i.jsx(Ae,{children:"No decisions"})})}function Q2({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(on,{layout:"start",label:"Active",value:e.active}),i.jsx(on,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(on,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(on,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(V,{className:"dv-src-mix",parts:Do.filter(t=>e.bySource[t]).map(t=>`${qn[t].label} ${e.bySource[t]}`)})]})}function Y2(e){const{filter:t}=e,o=Object.values(t).filter(Boolean).length-(t.query?1:0),a=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:c=>e.set({query:c.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${a?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}function J2(e){const{api:t,bp:s}=e,o=t.decisions,[a,c]=y.useState({}),[d,h]=y.useState(e.focus),[m,p]=y.useState(!1);y.useEffect(()=>h(e.focus),[e.focus]),y.useEffect(()=>{const R=O=>{O.key==="Escape"&&(s==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[s,d,e]);const v=y.useMemo(()=>wx(o,a),[o,a]),k=y.useMemo(()=>xx(o),[o]),x=o.find(R=>R.id===d&&(!a.mapId||R.mapId===a.mapId))??(s==="mobile"?void 0:v[0]),S=y.useMemo(()=>Object.values(t.allSnaps).sort((R,O)=>O.map.createdAt-R.map.createdAt),[t.allSnaps]),C=y.useMemo(()=>[...new Set(o.map(R=>R.decidedBy))].sort(),[o]),j=R=>c(O=>({...O,...R})),I=()=>{const R=Object.fromEntries(S.map(O=>[O.map.id,{key:O.map.key,title:O.map.title}]));cg(`${te.slug}-decisions-${Qs(Date.now())}.md`,Rx(v,R,{title:`${te.name} decisions`}))},b=s==="mobile"&&!!x;return i.jsxs(ze,{className:`zone decisions-view dv-${s}`,children:[i.jsxs("header",{className:"dv-head",children:[b?i.jsx("button",{className:"back",onClick:()=>h(void 0),children:"‹ Decisions"}):i.jsxs(Ve,{as:"h2",children:["Decisions ",v.length!==o.length&&i.jsx("span",{className:"n",children:`${v.length}/${o.length}`})]}),s!=="mobile"&&i.jsx(Q2,{stats:k}),i.jsxs("span",{className:"dv-head-right",children:[!b&&i.jsx(P,{onClick:I,disabled:!v.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!b&&i.jsx(Y2,{filter:a,set:j,showToggle:s!=="wide",filtersOpen:m,onToggle:()=>p(R=>!R)}),i.jsxs("div",{className:"dv-body",children:[(s==="wide"||m&&!b)&&i.jsx(K2,{filter:a,set:j,all:o,trails:S,people:C,compact:s!=="wide"}),!b&&i.jsx(q2,{rows:v,current:x,snaps:t.allSnaps,showTrail:s==="wide",onSelect:h}),(s!=="mobile"||x)&&i.jsx("div",{className:"dv-detail",children:x?i.jsx(H2,{d:x,all:o,snap:t.allSnaps[x.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ae,{children:"No decision selected"})})]})]})}function X2({api:e,bp:t,nav:s}){return s.statsOpen?i.jsx(sT,{api:e,bp:t,onClose:()=>s.setStatsOpen(!1)}):s.decisionsView?i.jsx(J2,{api:e,bp:t,focus:s.decisionsView.focus,onClose:()=>s.setDecisionsView(null),onOpenTicket:s.openTicket}):null}function Z2(e,t,s){const o=hv(),[a,c]=y.useState(()=>new URLSearchParams(location.search).has("projects")),d=a&&o.many&&i.jsx(F$,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:s});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),c(!0)}}}const eA={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function tA(e){if(e.kind)return eA[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function Tv({activity:e,onTicket:t}){const s=oi(),o=e.feed.slice(-120).reverse();return o.length?i.jsx("div",{className:"log",children:o.map(a=>i.jsxs("div",{className:`log-row src-${a.source.replace(" ","-")} edge-${tA(a)??"none"}`,onClick:()=>a.ticketId&&t(a.ticketId),children:[i.jsx("span",{className:"t t-meta",children:ua(a.at)}),i.jsx("span",{className:"src t-meta",children:Gn(a.agent??a.source,s)}),i.jsxs("span",{className:"msg",title:a.tag?`${a.tag} · ${a.text}`:a.text,children:[a.tag&&i.jsxs("span",{className:"tag t-meta",children:[a.tag," · "]}),a.text]})]},a.id))}):i.jsx(Qn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function dp({lease:e,now:t}){if(!e)return null;const s=aa(e,t);if(s==="live")return null;const o=e.expiresAt-t;return i.jsxs(Yn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",s==="expired"?"returning":Qt(o)]})}function nA({total:e,step:t}){return i.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(s,o)=>i.jsx("i",{className:sA(o+1,t)},o))})}function sA(e,t){return e<t?"done":e===t?"cur":""}function Ev({snap:e,activity:t,leases:s,onSelect:o,onOpenChat:a}){var x;const c=Yt(1e3),d=t.sessions.filter(cn),h=new Set(d.map(S=>S.ticketId)),m=yu(s,e==null?void 0:e.map.id),p=(e==null?void 0:e.tickets.filter(S=>S.state==="open"&&S.assignee&&!h.has(S.id)))??[];if(!d.length&&!p.length)return i.jsx(Ae,{children:"No agent on a ticket"});const v=S=>!!S&&aa(S,c)!=="live",k=!!((x=e==null?void 0:e.map.modelMatching)!=null&&x.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(S=>{const C=e==null?void 0:e.tickets.find(b=>b.id===S.ticketId),j=C?or(C)==="hitl":!1,I=C&&m.get(C.id);return i.jsx(Ce,{as:"li",className:S.waitingOn?"waiting":void 0,edge:iA(S,v(I)),title:aA(C,S.mode)||S.agent,context:i.jsx(V,{parts:[{text:S.agent,strong:!0},k&&rA(S),S.waitingOn?{text:"Waiting on you",urgent:!0}:`${S.mode} · ${S.stepLabel.toLowerCase()}`,j&&!S.waitingOn&&"with you",oA(S)],children:i.jsx(dp,{lease:I,now:c})}),trailing:ug(c-S.startedAt),below:i.jsx(nA,{total:S.total,step:S.step}),onOpen:()=>{C&&o({kind:"ticket",id:C.id}),j&&a(S.id)}},S.id)}),p.map(S=>i.jsx(Ce,{as:"li",className:"claim",edge:v(m.get(S.id))?"attention":"neutral",title:`${S.key} ${S.title}`,context:i.jsx(V,{parts:[{text:S.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(dp,{lease:m.get(S.id),now:c})}),onOpen:()=>o({kind:"ticket",id:S.id})},S.id))]})}function iA(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function rA(e){const t=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:t,className:"session-tier"}}function oA(e){if(e.usage)return`${da(vx(e))} tok · ${qs(e.usage.costUsd)}`}function aA(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function Av({activity:e,snap:t,running:s,usage:o=!0}){const a=Lp(e,t==null?void 0:t.map.id),c=Pp(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(cn).map(m=>m.ticketId)),h=(t==null?void 0:t.tickets.filter(m=>m.state==="open"&&m.assignee&&!d.has(m.id)).length)??0;return i.jsx(Et,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:s+h})]}),right:o?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...c.map(m=>Op[m].text)].join(`
|
|
169
|
-
`),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",da(a.inputTokens+a.outputTokens)," tok · ",qs(a.costUsd)]}):void 0})}function
|
|
170
|
-
${d.briefText}`)}).filter(k=>k.kind==="business-rule").filter(k=>Zx(m,[k.id]).length);return!m.length&&!v.length&&!c?null:i.jsxs("div",{className:"criteria-section d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Agreed before the work starts; each needs evidence before the ticket counts as done",children:["Acceptance criteria · ",m.length,(h==null?void 0:h.confirmed)&&i.jsx("span",{className:"ok-text",children:" · confirmed by you"})]}),m.length>0&&i.jsx("ul",{className:"criteria-list item-list",children:m.map(k=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:k.text}),i.jsx(V,{parts:[{text:k.id,code:!0},k.kind.replace("-"," "),k.source&&`from ${k.source}`]})]},k.id))}),c&&i.jsx(
|
|
171
|
-
${h.text}`:h.text),h=>c(h.message)),children:"Full log ›"}),e.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),a&&i.jsx("span",{className:"vf-err",children:a})]})]})}function
|
|
172
|
-
`),children:[i.jsx("span",{className:"t-code",children:c.kind})," ",c.message]},c.kind)}),t.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:t.changed.map(c=>i.jsxs("li",{children:[i.jsx("code",{children:c.path}),i.jsxs("span",{className:"dim",children:[c.untracked?"new":`+${mp(c.add)} −${mp(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function bA({attempt:e,latest:t}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[i.jsxs("summary",{children:[i.jsx(Yn,{tone:"state",className:`r-${e.result}`,children:q1[e.result]}),i.jsx(V,{parts:[{text:e.id,code:!0},e.agent,cr(e.submittedAt),Qt(e.finishedAt-e.submittedAt)]})]}),i.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&i.jsx("p",{className:"vf-note",children:e.note}),e.criteria&&i.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(s=>i.jsx("li",{className:CA(s),children:s},s))}),i.jsx(NA,{attempt:e}),e.checks.map(s=>i.jsx(jA,{check:s},s.name))]})}function CA(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const $A={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function TA({verdict:e}){const{guide:t,checklist:s}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(V,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":$A[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,t&&`as ${t.id} ${t.version}`,`on ${e.attemptId}`,cr(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,a)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},a))}),s&&s.length>0&&i.jsx(Gg,{answers:s})]})}function EA(e,t,s){const[o,a]=y.useState(),c=`${e}/${t}`;y.useEffect(()=>a(void 0),[c]);const{reload:d}=pt({view:c,version:s,load:()=>ur.ticket(e,t),show:a});return y.useEffect(()=>Ys.onEvidence(d),[d]),{data:o,reload:d}}const Dc={rework:{label:"What to fix",submit:"Send to rework",hint:"Posted on the ticket for the next agent."},accept:{label:"Why accept",submit:"Accept anyway",hint:"Closes the ticket as done despite the checks."},unblock:{label:"Why",submit:"Unblock",hint:"Back to the queue without running checks."}};function AA(e){const[t,s]=y.useState(),[o,a]=y.useState(""),[c,d]=y.useState("rework"),{state:h,submitted:m,running:p,act:v}=e;if(p||h!=="verifying"&&h!=="held")return null;const k=S=>{s(t===S?void 0:S),a("")},x=S=>{S.preventDefault(),!(!t||!o.trim())&&(v({action:t,reason:o.trim(),...t==="unblock"?{to:c}:{}}),s(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[h==="verifying"&&m&&i.jsx(P,{variant:"primary",onClick:()=>void v({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),m&&i.jsx(P,{onClick:()=>void v({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(P,{on:t==="rework",onClick:()=>k("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),h==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(P,{on:t==="accept",onClick:()=>k("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(P,{on:t==="unblock",onClick:()=>k("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:x,children:[i.jsx(Ze,{label:Dc[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:S=>a(S.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ze,{label:"Back to",children:i.jsx(dt,{"aria-label":"Back to",value:c,onChange:d,options:[{value:"rework",label:"Rework",hint:"Keeps the feedback for the next agent."},{value:"ready",label:"Ready",hint:"Back in the queue as a fresh ticket."}]})}),i.jsx("span",{className:"dim vf-hint",children:Dc[t].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>s(void 0),children:"Cancel"}),i.jsx(P,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!o.trim(),children:Dc[t].submit})]})]})]})}const IA={ticket:"set on this ticket",trail:"from the trail",none:"not set"},MA=new Set(["verifying","rework","held"]);function RA(e){const{mapId:t,ticket:s,state:o}=e,{data:a,reload:c}=EA(t,s.id,s.updatedAt),[d,h]=y.useState();if(!a||a.level.level==="off"&&!a.attempts.length&&!MA.has(o))return null;const m=v=>(h(void 0),ur.act({...v,mapId:t,ticketId:s.id,by:St}).then(c,k=>h(k.message))),p=a.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Ve,{as:"h4",children:"Verification"}),i.jsx(V,{parts:[ir[a.level.level],IA[a.level.source]]}),s.state==="open"&&i.jsx(wA,{value:s.verification,inherit:`Trail (${ir[e.trail??"off"]})`,onChange:v=>void m({action:"level",level:v})})]}),p&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",p.id," for ",p.agent," · since ",cr(p.startedAt)]})]}),i.jsx(AA,{state:o,submitted:a.attempts.length>0,running:!!p,act:m}),d&&i.jsx("p",{className:"vf-err",children:d}),a.verdicts.map(v=>i.jsx(TA,{verdict:v},v.id)),a.attempts.map((v,k)=>i.jsx(bA,{attempt:v,latest:k===0},v.id)),!a.attempts.length&&!p&&i.jsx(V,{parts:[`Checks: ${a.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function LA({lease:e,onRelease:t}){const s=Yt(1e3),o=aa(e,s),a=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${a?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${dn(s-e.renewedAt)} ago`]}),!a&&i.jsx(Yn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:OA(o,PA(e.expiresAt-s))}),e.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:e.workspace.branch})," in its own worktree"]}),e.touches&&e.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",e.touches.map((c,d)=>i.jsxs("span",{children:[d>0&&", ",i.jsx("code",{className:"t-code",children:c})]},c))]}),e.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(-3).map((c,d)=>i.jsx("li",{children:c},d))}),i.jsx("div",{className:"actions",children:i.jsx(P,{variant:a?"default":"urgent",onClick:t,children:"Release to queue"})})]})}function OA(e,t){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${t}.`:`Back in the queue after ${t} without activity.`}function PA(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Qt(Math.max(0,e))}function _A({comments:e}){const t=oi();if(!e.length)return null;const s=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",s]}),e.map(o=>i.jsxs("div",{className:"comment",children:[i.jsx(V,{parts:[{text:Gn(o.author,t),strong:!0}]}),i.jsx("div",{className:"c-body",children:o.body.replace(/\*\*/g,"")})]},o.id))]})}function DA({resolution:e,decisions:t,onOpenDecision:s}){const o=oi(),a=t.find(h=>!h.supersededBy)??t[0],c=e.body.startsWith("**Ruled")?"ruled out":"resolution",d=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:Gn(e.author,o),strong:!0},c]}),a&&s&&i.jsxs("button",{className:"link t-meta",onClick:()=>s(a.id),children:[a.id,d," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function zA(e){const{t,state:s,session:o,mine:a,form:c,setForm:d,actions:h,onOpenChat:m}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(P,{variant:o.waitingOn?"urgent":"default",onClick:()=>m(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),s==="frontier"&&i.jsx(P,{onClick:()=>h.claim(t.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(s==="frontier"||s==="claimed"&&a)&&i.jsx(P,{on:c==="resolve",onClick:()=>d(c==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),a&&s==="claimed"&&i.jsx(P,{onClick:()=>h.release(t.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(s==="frontier"||s==="blocked"||s==="parked")&&i.jsx(P,{variant:"danger",on:c==="rule",onClick:()=>d(c==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function BA(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function FA({t:e,state:t,tickets:s}){const o=new Map(s.map(p=>[p.id,p])),a=p=>{var v;return((v=o.get(p))==null?void 0:v.key)??p},c=e.blockedBy.map(p=>{var v;return`${a(p)}${((v=o.get(p))==null?void 0:v.state)==="closed"?" ✓":""}`}).join(", "),d=s.filter(p=>p.blockedBy.includes(e.id)).map(p=>p.key).join(", "),h=[["Type",nr[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",d],["Reviews",e.reviewOf&&a(e.reviewOf)]],m=or(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(Yn,{tone:"state",className:`st-${t}`,children:hg[t]}),i.jsx("span",{className:"d-att t-meta","data-tip":m?"A person takes this one":"An agent takes this alone",children:m?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:h.filter(([,p])=>p).flatMap(([p,v])=>[i.jsx("dt",{className:"t-label",children:p},`${p}-k`),i.jsx("dd",{children:v},`${p}-v`)])})]})}function UA(e){const{snap:t,api:s,form:o,setForm:a}=e,{actions:c}=s,[d,h]=y.useState(""),[m,p]=y.useState(""),[v,k]=y.useState(""),[x,S]=y.useState("Not needed to reach the destination."),C=t.tickets.find(W=>W.id===e.id);if(!C)return i.jsx(Ae,{children:"Ticket not found."});const j=Xs(t.tickets,t.map.mode).get(C.id),I=e.sessions.find(W=>W.ticketId===C.id&&cn(W)),b=C.assignee===St,R=C.state==="open"?yu(s.leases,t.map.id).get(C.id):void 0,O=[...C.comments].reverse().find(W=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(W.body)),U=C.comments.filter(W=>W!==O),X=BA(C.body),Q=s.decisions.filter(W=>W.mapId===t.map.id&&W.ticketId===C.id);return i.jsxs("div",{className:"detail",children:[i.jsx(FA,{t:C,state:j,tickets:t.tickets}),i.jsx($v,{mapId:t.map.id,kind:"ticket",id:C.id}),X&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:X})]}),i.jsx(Y$,{mapId:t.map.id,ticketId:C.id}),i.jsx(gN,{mapId:t.map.id,ticketId:C.id}),i.jsx(r$,{mapId:t.map.id,ticket:C}),i.jsx(yA,{snap:t,t:C}),i.jsx(EN,{snap:t,t:C}),C.closeReason==="not_planned"&&i.jsx(Eu,{label:"Save as dead end",draft:()=>{var W;return{title:`Ruled out: ${C.title}`,body:((W=C.comments.at(-1))==null?void 0:W.body)??C.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${C.key}`]}}}),R&&i.jsx(LA,{lease:R,onRelease:()=>c.releaseLease(C.id)}),!R&&i.jsx($$,{mapId:t.map.id,ticketId:C.id}),i.jsx(RA,{mapId:t.map.id,trail:t.map.verification,ticket:C,state:j}),i.jsx(zA,{t:C,state:j,session:I,mine:b,form:o,setForm:a,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:W=>{W.preventDefault(),d.trim()&&(c.resolve(C.id,d.trim(),{rationale:m.trim(),alternatives:v.split(`
|
|
173
|
-
`).map(ie=>ie.trim()).filter(Boolean)}),a(null),h(""),p(""),k(""))},children:[i.jsx(Ze,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:W=>h(W.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:m,onChange:W=>p(W.target.value)})}),i.jsx(Ze,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:v,onChange:W=>k(W.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:W=>{W.preventDefault(),c.ruleOut({ticketId:C.id},x),a(null)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:x,onChange:W=>S(W.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"danger",children:"Rule out"})]})]}),O&&i.jsx(DA,{resolution:O,decisions:Q,onOpenDecision:e.onOpenDecision}),i.jsx(_A,{comments:U})]})}function WA({snap:e,item:t,api:s}){const o=$p(e.map.mode),[a,c]=y.useState("research"),[d,h]=y.useState(t),[m,p]=y.useState(!1),[v,k]=y.useState([]),[x,S]=y.useState("Not needed to reach the destination.");y.useEffect(()=>h(t),[t]);const C=e.tickets.filter(j=>j.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(Yn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:t}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),s.actions.graduate({unspecified:t,type:a,title:d,blockedBy:v,hitl:m})},children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:d,onChange:j=>h(j.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(j=>i.jsx("button",{type:"button",className:`chip ${a===j?"on":""}`,onClick:()=>c(j),children:j},j)),Vy.includes(a)&&i.jsx("button",{type:"button",className:`chip ${m?"on":""}`,onClick:()=>p(j=>!j),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:C.map(j=>i.jsx("button",{type:"button",className:`chip ${v.includes(j.id)?"on":""}`,onClick:()=>k(I=>I.includes(j.id)?I.filter(b=>b!==j.id):[...I,j.id]),children:j.key},j.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(P,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),s.actions.ruleOut({unspecified:t},x)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:x,onChange:j=>S(j.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(P,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function HA({api:e,sessions:t,bare:s,onOpenChat:o,onOpenDecision:a}){const{snap:c,selection:d,actions:h}=e,[m,p]=y.useState(null),v=KA(d);y.useEffect(()=>p(null),[v]);let k;return c?d?d.kind==="unspecified"?k=i.jsx(WA,{snap:c,item:d.item,api:e}):k=i.jsx(UA,{snap:c,id:d.id,api:e,sessions:t,form:m,setForm:p,onOpenChat:o??h.openChat,onOpenDecision:a}):k=i.jsx(Qn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):k=i.jsx(Qn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(Sg,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: what it is, who has it, what blocks it, and its decision once it's made.",className:"inspector",bare:s,children:k})}function KA(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const VA={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function GA(e){if(e.decidedBy)return e.status==="invalidated"?`invalidated by ${e.decidedBy}`:e.status==="confirmed"?`confirmed by ${e.decidedBy==="trail lead"?"you":e.decidedBy}`:`kept by ${e.decidedBy}`}function qA(e){const{a:t,snap:s}=e,o=t.tickets.flatMap(c=>s.tickets.filter(d=>d.id===c)),a=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return i.jsx(Ce,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:i.jsx(V,{parts:[{text:t.id,code:!0},VA[t.status],GA(t)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(c=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:c.id}),children:c.key},c.id))]})}),detail:a,detailText:a,actions:e.onConfirm&&i.jsx(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function QA(e){const[t,s]=y.useState(),[o,a]=y.useState();return{confirm:async(d,h)=>{a(d);const m=await fetch(`${je()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d,text:h})}).catch(()=>{});if(a(void 0),m!=null&&m.ok)return s(void 0);const p=await(m==null?void 0:m.json().catch(()=>({})));s((p==null?void 0:p.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:t}}function YA({snap:e,onSelect:t}){const{confirm:s,busy:o,error:a}=QA(e.map.id),c=e.map.sections.assumptions??[];return c.length?i.jsxs(i.Fragment,{children:[a&&i.jsx("p",{className:"urgent-text",children:a}),i.jsx("ul",{className:"assumptions row-list",children:c.map(d=>{const h=d.status==="holding"||d.status==="challenged";return i.jsx(qA,{a:d,snap:e,onSelect:t,onConfirm:h?()=>void s(d.id,d.text):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ae,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function JA(e){const[,t,s=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[o=s,...a]=s.split(/\s+[—–]\s+/);return{key:t,title:o,reason:a.join(" — ")||void 0}}function XA(e){const[t,s]=y.useState([]),o=e==null?void 0:e.map.id,a=(e==null?void 0:e.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),e.map.updatedAt))??0;return y.useEffect(()=>{if(!o)return;let c=!0;return fetch(`${je()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&s(d.entries)).catch(()=>c&&s([])),()=>{c=!1}},[o,a]),t}function ZA({snap:e,activity:t,onTicket:s}){const o=XA(e),a=t.usageByMap[e.map.id],c=y.useMemo(()=>Up({snap:e,journal:o,answered:t.answered,usage:a}),[e,o,t.answered,a]),d=c.interventions,h=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",ln(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",ln(c.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${d.total}`,`${d.answers} agent questions you answered + ${d.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${d.reworkRequested} sent work back. Answers count while their sessions are on record.`],["Rework",`${c.rework.cycles}`,`Times work went back to rework, on ${c.rework.tickets} tickets`],["Reviews",`${c.reviews.passed}/${c.reviews.failed}`,`${c.reviews.passed} passed, ${c.reviews.failed} failed, ${c.reviews.needsHuman} needed you`],["Cost / ticket",c.spend.perVerifiedTicketUsd===void 0?"—":qs(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${qs(c.spend.costUsd)} ÷ ${c.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:h.map(([m,p,v])=>i.jsxs("li",{"data-tip":v,children:[i.jsx("span",{className:"mono-label",children:m}),i.jsx("b",{children:p})]},m))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(P,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>cg(`${e.map.key.replace("#","trail-")}-report.md`,Ux(c,e.map.title)),children:"Export markdown"})]}),c.tickets.length?i.jsx("ul",{className:"list report-tickets",children:c.tickets.map(m=>i.jsx("li",{className:`out-${m.outcome}`,children:i.jsxs("button",{onClick:()=>s(m.id),"data-tip":`${m.outcome} · rework ${m.reworks} · reviews ${m.reviews.passed}/${m.reviews.failed} · your calls ${m.operatorActions}`,children:[i.jsx("span",{className:"key",children:m.key}),i.jsx("span",{className:"ttl",children:m.title}),i.jsx("span",{className:"lead",children:m.outcome==="done"?ln(m.leadMs):m.outcome})]})},m.id))}):i.jsx(Ae,{children:"No tickets yet"})]})}function eI({tab:e,snap:t,selection:s,onSelect:o,activity:a}){const c=t.map.sections;switch(e){case"report":return a?i.jsx(ZA,{snap:t,activity:a,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ae,{children:"No activity yet"});case"assumptions":return i.jsx(YA,{snap:t,onSelect:o});case"decisions":return c.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,h)=>i.jsx(Ce,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(V,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):i.jsx(Ae,{children:"None"});case"unspecified":return c.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>i.jsx(Ce,{as:"li",title:d,titleText:d,selected:(s==null?void 0:s.kind)==="unspecified"&&s.item===d,onOpen:()=>o({kind:"unspecified",item:d})},d))}):i.jsx(Ae,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>{const h=JA(d);return i.jsx(Ce,{as:"li",title:h.title,titleText:d,context:i.jsx(V,{parts:[h.key&&{text:h.key,code:!0},h.reason]})},d)})}):i.jsx(Ae,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function tI({snap:e,selection:t,onSelect:s,bare:o,onAudit:a,activity:c}){var k;const[d,h]=y.useState("unspecified"),m=e==null?void 0:e.map.sections,p=[{id:"unspecified",label:"Not yet specified",n:m==null?void 0:m.unspecified.length},{id:"assumptions",label:"Assumptions",n:(k=m==null?void 0:m.assumptions)==null?void 0:k.length},{id:"decisions",label:"Decisions",n:m==null?void 0:m.decisions.length},{id:"oos",label:"Out of scope",n:m==null?void 0:m.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],v=e?i.jsx(eI,{tab:d,snap:e,selection:t,onSelect:s,activity:c}):i.jsx(Qn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(ze,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Et,{className:"zone-title",icon:"flag",title:"Trail plan",info:"The parts of the plan that aren't tickets yet: open questions still to specify, the assumptions the plan relies on, decisions already made, what's ruled out, and notes. Report shows how the trail is going: lead times, your interventions, rework, reviews and cost per verified ticket."}),i.jsxs("div",{className:"sections-tabs",children:[i.jsx(dt,{compact:!0,"aria-label":"Plan section",value:d,onChange:h,options:p.map(x=>({value:x.id,label:x.n===void 0?x.label:`${x.label} · ${x.n}`}))}),d==="decisions"&&a&&i.jsx("button",{className:"link",onClick:a,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:v})]})}function nI(){var le;const e=y.useMemo(()=>HS(WS()),[]),t=sN(e),{snap:s,activity:o,selection:a,actions:c}=t,[d,h]=iN();y.useEffect(()=>wg(d.theme),[d.theme]);const m=ZE(),[p,v]=y.useState(!1),k=n2(e.kind),x=XS(),S=o.pending.length,C=s2(o,t.mapId);t2(S,s==null?void 0:s.map.title);const j=e2(t,x),I=L2(s,c.selectMap),b=PN(I.briefText),R=D2({api:t,nav:j,knowledge:b,reviewBrief:I.review,openReroute:ee=>I.openReroute(ee.mapId,ee.ref),openGuides:()=>m.open("guides"),openConnector:ee=>m.open(ee),openApprovals:()=>m.open("approvals"),openFocusSettings:()=>m.open("attention")}),O=eN(e,t,d.briefing,(le=R.attention.view)==null?void 0:le.items),U=i.jsx(sb,{api:t,nav:j,bp:x,scoped:C,attn:R,above:I.inboxCard}),X=i.jsx(QE,{api:t,sessions:C.sessions,onSelect:j.select,onNewTrail:()=>v(!0),compact:x==="mobile",minFit:x==="mobile"?.7:0,trail:I}),Q=ee=>i.jsx(HA,{api:t,sessions:C.sessions,bare:ee,onOpenChat:K=>j.openChat(K),onOpenDecision:j.openDecisions}),W={activity:C,snap:s,leases:t.leases,onTicket:ee=>j.select({kind:"ticket",id:ee}),onOpenChat:ee=>j.openChat(ee)},ie=ee=>i.jsx(tI,{snap:s,selection:a,onSelect:j.select,bare:ee,onAudit:()=>j.openDecisions(),activity:C}),{projects:G,overview:ve,openOverview:Pe}=Z2(x,j,R.link.request),$e=m.route&&i.jsx(XT,{rt:e,api:t,bp:x,prefs:d,update:h,settings:m}),oe=(j.statsOpen||j.decisionsView)&&i.jsx(X2,{api:t,bp:x,nav:j}),D=$e||ve||oe,J=O.shown&&i.jsx(mN,{brief:O,snaps:t.allSnaps,bp:x,openTicket:j.openTicket,openChat:j.openChat,openDecisions:j.openDecisions,closeDecisions:()=>j.setDecisionsView(null),showPhoneHome:()=>j.setPhoneTab("home")});return i.jsx(bg.Provider,{value:b,children:i.jsxs("div",{className:`app bp-${x}`,children:[i.jsx(o1,{api:t,rt:e,repo:i.jsx(U$,{repo:k,projects:G,onOverview:Pe}),brief:O,attention:R.header,decisionsOpen:!!j.decisionsView,onDecisions:()=>{m.close(),j.decisionsView?j.setDecisionsView(null):j.openDecisions()},onStats:()=>{m.close(),j.toggleStats()},onNewTrail:()=>v(!0),onSettings:m.toggle,onSlack:()=>m.open("slack"),onToggleTheme:ee=>h({theme:ee?"night":"day"})}),x==="wide"&&i.jsxs(i.Fragment,{children:[U,X,Q(!1),i.jsx(dA,{...W}),i.jsx(uA,{...W}),ie(!1),D]}),x==="laptop"&&i.jsxs(i.Fragment,{children:[U,X,i.jsx(ZT,{tab:j.sideTab,onTab:j.setSideTab,unspecified:s==null?void 0:s.map.sections.unspecified.length,ticket:Q(!0),activity:i.jsx(hp,{...W}),plan:ie(!0)}),D]}),x==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(XE,{tab:j.phoneTab,decisions:D,inbox:U,projects:G.many&&i.jsx(H$,{projects:G,onOverview:Pe}),map:X,ticket:Q(!0),activity:i.jsx(hp,{...W}),plan:ie(!0)}),i.jsx(JE,{tab:j.phoneTab,covered:!!D,pending:S,onPick:ee=>{m.close(),j.setPhoneTab(ee),j.setDecisionsView(null)}})]}),J,I.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),p&&i.jsx(ub,{rt:e,onClose:()=>v(!1),onCreated:ee=>c.selectMap(ee)}),!d.onboarded&&i.jsx(tC,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(RN,{})]})})}const sI="X-Teamtrail-Session";function iI(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function rI(e){const t=new URL(iI(e),location.href),s=te.apiPrefix;return t.origin===location.origin&&(t.pathname===s||t.pathname.startsWith(`${s}/`))}function oI(){const e=window.fetch.bind(window);window.fetch=(t,s)=>{const o=bS()?xu():void 0;if(!o||!rI(t))return e(t,s);const a=new Headers((s==null?void 0:s.headers)??(t instanceof Request?t.headers:void 0));return a.set(sI,o.secret),e(t,{...s,headers:a})}}wg(bu().theme);oI();By.createRoot(document.getElementById("root")).render(i.jsxs(FT,{children:[i.jsx(nI,{}),i.jsx(cN,{})]}));
|
|
162
|
+
Where this trail ends`;return i.jsxs("g",{className:"destination",transform:`translate(${e} ${t})`,"aria-label":o,"data-tip":o,tabIndex:0,children:[i.jsx("rect",{className:"x-hit",x:-24,y:-24,width:48,height:48}),i.jsx("path",{className:"x-stroke",d:"M-15 -16 C-9 -10 2 4 16 17"}),i.jsx("path",{className:"x-stroke",d:"M17 -15 C8 -8 -6 5 -16 17"})]})}function lE({trails:e}){return e.map(t=>i.jsx("path",{className:"edge edge-open edge-destination",d:t},t))}function cE(){return i.jsxs("defs",{children:[i.jsx("pattern",{id:"map-grid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:i.jsx("path",{d:"M40 0H0V40",fill:"none",stroke:"var(--map-grid)",strokeWidth:"1"})}),i.jsx("pattern",{id:"hatch-oos",width:"10",height:"10",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"10",stroke:"var(--line2)",strokeWidth:"1"})})]})}const Yo=(e,t)=>`${e}>${t}`;function uE(e,t,s=[]){const o=new Map(e.tickets.map(c=>[c.id,c]));return{tickets:t.nodes.map(c=>{const d=o.get(c.id);return d?{...d,blockedBy:[...c.blockedBy,...c.removedEdges??[]]}:{id:c.id,key:"+",title:c.title,type:c.type,body:"",state:"open",blockedBy:c.blockedBy,comments:[],createdAt:e.map.updatedAt,updatedAt:e.map.updatedAt}}),marks:new Map(t.nodes.map(c=>[c.id,c.mark])),newEdges:new Set(t.nodes.flatMap(c=>c.newEdges.map(d=>Yo(d,c.id)))),removedEdges:new Set(t.nodes.flatMap(c=>(c.removedEdges??[]).map(d=>Yo(d,c.id)))),frozen:new Set(s)}}function dE(e,t){const s=mx({...e,tickets:t}),o=new Set;for(let a=1;a<s.length;a++)o.add(Yo(s[a-1].id,s[a].id));return o}const ep={LR:130,TB:68};function hE(e){const{direction:t,from:s,to:o,cards:a}=e;if(t==="LR"){const h={x:s.x+Ke,y:s.y+Ye/2},m={x:o.x,y:o.y+Ye/2};return Qo({direction:t,a:h,b:m,obstacles:a,gap:ep.LR})}const c={x:s.x+Ke/2,y:s.y+Ye},d={x:o.x+Ke/2,y:o.y};return Qo({direction:t,a:c,b:d,obstacles:a,gap:ep.TB})}function fE(e){const{from:t,to:s,direction:o}=e,c=["edge",t.ticket.state!=="open"?"edge-done":"edge-open"];return e.critical&&c.push("edge-critical"),e.added&&c.push("edge-added"),e.removed&&c.push("edge-removed"),i.jsx("path",{className:c.join(" "),d:hE({direction:o,from:t,to:s,cards:e.cards})})}function mE(e){const{snap:t,tickets:s,direction:o,preview:a}=e,c=y.useMemo(()=>dE(t,s),[t,s]),d=y.useMemo(()=>xv(e.nodes),[e.nodes]);return e.edges.map(({from:h,to:m})=>{const p=Yo(h.ticket.id,m.ticket.id);return i.jsx(fE,{from:h,to:m,direction:o,cards:d,critical:c.has(p),added:a==null?void 0:a.newEdges.has(p),removed:a==null?void 0:a.removedEdges.has(p)},p)})}const zu=24,pE=13,gE=9.5;function vE(e){const t=e.guide;return i.jsx("g",{className:"meta",transform:`translate(${zu} ${e.y})`,children:e.chips.map((s,o)=>{const a=s.kind==="guide"?t:void 0;return i.jsxs("g",{className:Ge("card-chip",s.kind,s.kind==="state"&&e.tone,(a==null?void 0:a.off)&&"off"),"data-guide-id":a==null?void 0:a.id,transform:`translate(${s.x} 0)`,children:[a&&i.jsx("title",{children:a.tip}),i.jsx("rect",{width:s.w,height:pE,rx:3}),i.jsx("text",{x:(s.w-s.textW)/2,y:gE,textLength:s.textW,lengthAdjust:"spacingAndGlyphs",children:s.text})]},o)})})}const jv=5,kE={sans:"9.5px 'Figtree Variable', system-ui, sans-serif",mono:"8.55px 'JetBrains Mono Variable', ui-monospace, monospace"};let Yi;function yE(){if(Yi!==void 0)return Yi;try{Yi=typeof document>"u"?null:document.createElement("canvas").getContext("2d")}catch{Yi=null}return Yi}function wE(e,t="sans"){const s=yE();return s?(s.font=kE[t],s.measureText(e).width*1.04):e.length*jv}const tp=4,np=3,xE=6;function jE(e){var k;const t=Ke-zu-8-(e.reserve??0),s=((k=e.state)==null?void 0:k.split(" · "))??[],o=[{kind:"key",text:e.key},{kind:"type",text:e.type},...e.guide===void 0?[]:[{kind:"guide",text:e.guide}],...s.map(x=>({kind:"state",text:x})),...e.needsYou?[{kind:"needs",text:"needs you"}]:[]],a=t-o.length*2*tp-(o.length-1)*np,c=x=>wE(x.text,x.kind==="key"?"mono":"sans"),d=o.filter(x=>x.kind!=="guide").reduce((x,S)=>x+c(S),0),h=Math.max(xE,Math.floor((a-d)/jv)),m=o.map(x=>x.kind==="guide"?{...x,text:DC(x.text,h)}:x),p=Math.min(1,a/m.reduce((x,S)=>x+c(S),0));let v=0;return m.map(x=>{const S=c(x)*p,C={...x,x:v,w:S+2*tp,textW:S};return v+=C.w+np,C})}function SE(e,t,s){const o=e.state==="frontier"||e.state==="rework";if(!(!t||s||e.ticket.assignee||!o))return t}function NE(e){const t=["node",`st-${e.n.state}`,`tone-${e.tone}`,e.hitl?"hitl":"afk"];return e.selected&&t.push("sel"),e.live&&t.push("live"),e.waiting&&t.push("waiting"),e.stalled&&!e.waiting&&t.push("stalled"),e.mark&&t.push(`mark-${e.mark}`),e.frozen&&t.push("frozen"),t.join(" ")}function bE({wait:e,session:t}){return e?i.jsx("title",{children:`Needs a ${e} model: no connected agent runs one`}):t?i.jsx("title",{children:`${t.agent} · step ${t.step}/${t.total} · ${t.stepLabel.toLowerCase()}`}):null}const CE={claimed:"working",verifying:"working",frontier:"ready",blocked:"backlog",parked:"backlog",decided:"done","out-of-scope":"cancelled",rework:"attention",held:"attention"};function $E(e){const t=CE[e.state];return t==="done"||t==="cancelled"?t:e.attention?"attention":e.live?"working":t}function TE({mark:e,frozen:t}){const s=e&&e!=="unchanged"&&e!=="cancelled"?e:void 0;return i.jsxs(i.Fragment,{children:[e==="cancelled"&&i.jsx("line",{className:"strike",x1:8,y1:Ye/2,x2:Ke-8,y2:Ye/2}),s&&i.jsx("text",{className:"reroute-tag",x:Ke-8,y:Ye-7,textAnchor:"end",children:s}),t&&i.jsx("text",{className:"freeze",x:Ke-(s?58:8),y:Ye-7,textAnchor:"end",children:"❄"})]})}function EE(e){const{n:t,session:s}=e,o=t.ticket.assignee;return e.waiting?{text:"waiting on you",tone:"urgent"}:e.stalled?{text:`stalled · ${o}`,tone:"warn"}:e.wait?{text:`needs ${e.wait}`,tone:"warn"}:s&&e.step?{text:`${s.agent} · step ${s.step}/${s.total}`,tone:"agent"}:s?{text:s.agent,tone:"agent"}:t.state==="claimed"?{text:o??"working",tone:"agent"}:{text:gS[t.state],tone:""}}function AE({tone:e,cy:t}){return e==="done"?i.jsx("path",{className:"dot dot-done",d:`M10 ${t}l2.5 2.5 4.5 -5`}):i.jsx("circle",{className:`dot dot-${e}`,cx:13,cy:t,r:e==="backlog"?3:3.5})}function IE(e,t,s=2){const o=e.split(/\s+/),a=[];let c="";for(const d of o)(c+" "+d).trim().length>t?(a.push(c.trim()),c=d):c+=" "+d;if(a.push(c.trim()),a.length>s){const d=a.slice(0,s);return d[s-1]=d[s-1].slice(0,t-1)+"…",d}return a}const ME=26;function RE({n:e,session:t,stalled:s,flag:o,selected:a,onSelect:c,mark:d,frozen:h,needs:m}){const p=e.ticket,v=IE(p.title,ME),k=or(p)==="hitl",x=!!(t!=null&&t.waitingOn),S=!!d&&d!=="unchanged",C=SE(e,m,!!t),j=a$(p.guide),I=S?void 0:EE({n:e,session:t,waiting:x,stalled:s,wait:C,step:!j}),b=k&&!S&&(p.type==="task"||p.type==="execute"),R=x||!!s||!!C||b&&e.state==="frontier",O=$E({state:e.state,live:!!t,attention:R}),U=nr[p.type],X=(S&&d!=="cancelled"?44:0)+(h?12:0),Q=jE({key:p.key,type:U,guide:j==null?void 0:j.name,state:I==null?void 0:I.text,needsYou:b,reserve:X}),W=v.length>1?19:24;return i.jsxs("g",{className:NE({n:e,tone:O,hitl:k,selected:a,live:!!t,waiting:x,stalled:s,mark:d,frozen:h}),style:{transform:`translate(${e.x}px, ${e.y}px)`},onClick:ie=>{ie.stopPropagation(),c({kind:"ticket",id:p.id})},children:[i.jsx(bE,{wait:C,session:t}),i.jsx("rect",{className:"ring",x:-3.5,y:-3.5,width:Ke+7,height:Ye+7,rx:9}),i.jsx("rect",{className:"card",x:.5,y:.5,width:Ke-1,height:Ye-1,rx:6}),i.jsx(AE,{tone:O,cy:W-4}),v.map((ie,G)=>i.jsx("text",{className:"title",x:zu,y:W+G*14,children:ie},G)),i.jsx(vE,{chips:Q,y:W+v.length*14-8,tone:I==null?void 0:I.tone,guide:j}),o&&i.jsx("circle",{className:`pr-flag-dot ${o}`,cx:Ke-2,cy:2,r:4}),i.jsx(TE,{mark:d,frozen:h})]})}const sp=.72;function LE(e){const{fit:t,nodes:s,size:o,pad:a}=e;if(t.k>=sp)return t;const c=s.find(h=>h.state==="claimed")??s.find(h=>h.state==="frontier")??s[0];if(!c)return t;const d=sp;return{k:d,x:o.w/2-(c.x+a+Ke/2)*d,y:o.h/2-(c.y+a+Ye/2)*d}}function OE(e){const{y:t,width:s,height:o}=e,a=e.nodes.filter(c=>c.state==="out-of-scope").length;return a?i.jsxs("g",{className:"quarantine",children:[i.jsx("rect",{x:-20,y:t-30,width:s+40,height:o+18,fill:"url(#hatch-oos)"}),i.jsx("line",{x1:-20,y1:t-30,x2:s+20,y2:t-30}),i.jsxs("text",{x:-12,y:t-12,children:["Out of scope · ",a]})]}):null}const st=280,ip=4,PE=220,Us=e=>Math.round(e/ip)*ip;function _E(e){let t=2166136261;for(const s of e)t=Math.imul(t^s.charCodeAt(0),16777619);return()=>{t=t+1831565813|0;let s=Math.imul(t^t>>>15,1|t);return s=s+Math.imul(s^s>>>7,61|s)^s,((s^s>>>14)>>>0)/4294967296}}function Pc(e,t,s,o){return Array.from({length:6},()=>{const a=o*(.5+e()*.7),c=o*(.3+e()*.4);return{x:Us(t+(e()-.5)*o*.8-a/2),y:Us(s+(e()-.5)*o*.5-c/2),w:Us(a),h:Us(c)}})}function DE(e){const{width:t,height:s,nodes:o}=e,a=_E(e.seed),c=(x,S)=>x+a()*(S-x),d=(x,S)=>!o.some(C=>x>C.x-52&&x<C.x+Ke+28&&S>C.y-52&&S<C.y+Ye+28),h=(t+st*2)*(s+st*2),m=Array.from({length:Math.round(h/9e4)},()=>Pc(a,c(-st,t+st),c(-st,s+st),c(160,360))).flat(),p=[...Pc(a,t+st*.55,s+st*.55,300),...Pc(a,-st*.5,-st*.45,220)],v=[],k=(x,S,C)=>{v.length<PE&&d(S,C)&&v.push({sprite:x,x:Us(S),y:Us(C)})};for(let x=0;x<Math.round(h/3e4);x++){const S=c(-st,t+st),C=c(-st,s+st),j=3+Math.floor(a()*5);for(let I=0;I<j;I++)k(a()<.65?"pine":"oak",S+c(-70,70),C+c(-44,44))}for(let x=0;x<Math.round(h/45e3);x++)k(a()<.4?"rock":"tuft",c(-st,t+st),c(-st,s+st));return v.sort((x,S)=>x.y-S.y),{grass:m,water:p,items:v}}const Sv={pine:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"30",width:"4",height:"10",fill:"var(--map-trunk)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H0l9-11H5l8-10H9z",fill:"var(--map-pine)"}),i.jsx("path",{d:"M18 0l9 12h-4l8 10h-4l9 11H18z",fill:"var(--map-pine2)"})]}),oak:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"16",y:"24",width:"4",height:"12",fill:"var(--map-trunk)"}),i.jsx("circle",{cx:"18",cy:"14",r:"14",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"10",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"26",cy:"17",r:"8",fill:"var(--map-oak)"}),i.jsx("circle",{cx:"22",cy:"10",r:"6",fill:"var(--map-oak2)"})]}),rock:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M1 16Q2 6 10 3Q18-1 23 6Q28 11 27 16z",fill:"var(--map-rock)"}),i.jsx("path",{d:"M15 16Q15 8 19 4Q25 8 27 16z",fill:"var(--map-rock2)"})]}),tuft:i.jsx("path",{d:"M4 8Q3 4 1 1M14 8Q14 3 14 0M24 8Q25 4 27 1",fill:"none",stroke:"var(--map-pine2)",strokeWidth:"2.5",strokeLinecap:"round"})};function zE({name:e}){return i.jsx("symbol",{id:`terrain-${e}`,overflow:"visible",children:Sv[e]})}const BE=Object.keys(Sv),FE=y.memo(function(t){const{seed:s,width:o,height:a,nodes:c}=t,d=y.useMemo(()=>DE({seed:s,width:o,height:a,nodes:c}),[s,o,a,c]);return i.jsxs("g",{className:"terrain","aria-hidden":"true",children:[i.jsx("defs",{children:BE.map(h=>i.jsx(zE,{name:h},h))}),d.grass.map((h,m)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-grass)"},m)),d.water.map((h,m)=>i.jsx("rect",{x:h.x,y:h.y,width:h.w,height:h.h,fill:"var(--map-water)"},m)),i.jsx("rect",{x:-4e3,y:-4e3,width:o+8e3,height:a+8e3,fill:"url(#map-grid)"}),d.items.map((h,m)=>i.jsx("use",{href:`#terrain-${h.sprite}`,x:h.x,y:h.y},m))]})}),UE=380;function WE(e){const{selId:t,size:s}=e,o=y.useRef(e);o.current=e;const a=y.useRef(!0);y.useEffect(()=>{if(a.current){a.current=!1;return}const{nodes:c,pad:d,view:h,setView:m,onFocus:p}=o.current,v=t?c.find(b=>b.ticket.id===t):void 0;if(!v||!s.w)return;p();const k=Math.min(1.4,Math.max(h.k,1.05)),x={k,x:s.w/2-(d+v.x+Ke/2)*k,y:s.h/2-(d+v.y+Ye/2)*k};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(x);const S=h,C=performance.now();let j=0;const I=b=>{const R=Math.min(1,(b-C)/UE),O=1-(1-R)**3;m({k:S.k+(x.k-S.k)*O,x:S.x+(x.x-S.x)*O,y:S.y+(x.y-S.y)*O}),R<1&&(j=requestAnimationFrame(I))};return j=requestAnimationFrame(I),()=>cancelAnimationFrame(j)},[t])}function HE(e,t){const s=y.useRef(t);s.current=t,y.useEffect(()=>{const o=e.current;if(!o)return;const a=p=>{const v=o.getBoundingClientRect();return{x:p.clientX-v.left,y:p.clientY-v.top}},c=p=>{p.preventDefault();const v=p.ctrlKey?.01:.0015;s.current(Math.exp(-p.deltaY*v),a(p))};let d=1;const h=p=>{p.preventDefault(),d=1},m=p=>{p.preventDefault();const v=p;s.current(v.scale/d,a(v)),d=v.scale};return o.addEventListener("wheel",c,{passive:!1}),o.addEventListener("gesturestart",h,{passive:!1}),o.addEventListener("gesturechange",m,{passive:!1}),()=>{o.removeEventListener("wheel",c),o.removeEventListener("gesturestart",h),o.removeEventListener("gesturechange",m)}},[e])}function rp(e,t,s){const o=Math.min(3,Math.max(.2,t));return{k:o,x:s.x-(s.x-e.x)*o/e.k,y:s.y-(s.y-e.y)*o/e.k}}const sn=32,KE=1.8;function VE(e){var oe;const{snap:t,selection:s,onSelect:o,preview:a}=e,c=(a==null?void 0:a.tickets)??t.tickets,d=y.useRef(null),[h,m]=y.useState({w:0,h:0});y.useEffect(()=>{const D=d.current;if(!D)return;const J=new ResizeObserver(([le])=>m({w:le.contentRect.width,h:le.contentRect.height}));return J.observe(D),()=>J.disconnect()},[]);const p=y.useMemo(()=>{const D=Wf(c,"LR",t.map.mode),J=Wf(c,"TB",t.map.mode),le=ee=>Math.min(h.w/(ee.width+sn*2),h.h/(ee.height+sn*2+16));return le(D)*KE>=le(J)?D:J},[c,t.map.mode,h.w,h.h]),v=(D,J)=>Math.min(1.25,Math.max(e.minFit??0,Math.min(h.w/D,h.h/J))),k=y.useMemo(()=>{const D=p.width+sn*2,J=p.height+sn*2+16,ee=p.nodes.some(Y=>Y.state==="out-of-scope")&&h.h?Math.max(0,h.h/v(D,J)-J):0;if(!ee)return{...p,slack:ee};const K=new Map(p.nodes.map(Y=>[Y,{...Y,y:Y.y+(Y.state==="out-of-scope"?ee:ee/2)}]));return{...p,slack:ee,nodes:[...K.values()],edges:p.edges.map(Y=>({from:K.get(Y.from),to:K.get(Y.to)})),quarantineY:p.quarantineY+ee,height:p.height+ee}},[p,h.w,h.h,e.minFit]),x=rE(k),S=x.right+sn*2,C=x.bottom+sn*2+16,j=()=>{const D=v(S,C);return{k:D,x:Math.max(0,(h.w-S*D)/2),y:Math.max(0,(h.h-C*D)/2)}},[I,b]=y.useState({k:1,x:0,y:0}),R=y.useRef(!1);y.useEffect(()=>{R.current=!1},[t.map.id]),y.useEffect(()=>{!R.current&&h.w&&b(LE({fit:j(),nodes:k.nodes,size:h,pad:sn}))},[h.w,h.h,S,C,t.map.id]);const O=y.useRef(new Map),U=y.useRef(null),X=D=>{const J=d.current.getBoundingClientRect();return{x:D.clientX-J.left,y:D.clientY-J.top}},Q=()=>{var ee;const D=[...O.current.values()],J=D.length>1?{x:(D[0].x+D[1].x)/2,y:(D[0].y+D[1].y)/2}:D[0],le=D.length>1?Math.hypot(D[0].x-D[1].x,D[0].y-D[1].y):0;U.current={view:I,dist:le,mid:J,moved:((ee=U.current)==null?void 0:ee.moved)??!1}};HE(d,(D,J)=>{R.current=!0,b(le=>rp(le,le.k*D,J))});const W=Yt(5e3),ie=yu(e.leases,t.map.id),G=Tu(),ve=(oe=_u())==null?void 0:oe.waiting,Pe=new Map(e.sessions.filter(D=>cn(D)&&D.ticketId).map(D=>[D.ticketId,D])),$e=(s==null?void 0:s.kind)==="ticket"?s.id:void 0;return WE({selId:$e,nodes:k.nodes,size:h,pad:sn,view:I,setView:b,onFocus:()=>R.current=!0}),i.jsxs("div",{className:"graph-box",ref:d,onPointerDown:D=>{O.current.set(D.pointerId,X(D)),O.current.size===1&&(U.current=null),Q()},onPointerMove:D=>{var ee;if(!O.current.has(D.pointerId)||!U.current)return;O.current.set(D.pointerId,X(D));const J=U.current,le=[...O.current.values()];if(le.length>1){const K={x:(le[0].x+le[1].x)/2,y:(le[0].y+le[1].y)/2},Y=Math.hypot(le[0].x-le[1].x,le[0].y-le[1].y),B=rp(J.view,J.view.k*Y/(J.dist||Y),J.mid);b({...B,x:B.x+K.x-J.mid.x,y:B.y+K.y-J.mid.y}),J.moved=!0}else{const K=le[0].x-J.mid.x,Y=le[0].y-J.mid.y;if(!J.moved&&Math.hypot(K,Y)<5)return;J.moved||(ee=d.current)==null||ee.setPointerCapture(D.pointerId),J.moved=!0,b({...J.view,x:J.view.x+K,y:J.view.y+Y})}R.current=!0},onPointerUp:D=>{O.current.delete(D.pointerId),O.current.size&&Q()},onPointerCancel:D=>O.current.delete(D.pointerId),onClickCapture:D=>{var J;(J=U.current)!=null&&J.moved&&(D.stopPropagation(),U.current=null)},children:[i.jsxs("svg",{className:"graph",width:h.w,height:h.h,onClick:()=>o(null),children:[i.jsx(cE,{}),i.jsx("g",{transform:`translate(${I.x} ${I.y}) scale(${I.k})`,children:i.jsxs("g",{transform:`translate(${sn} ${sn})`,children:[i.jsx(FE,{seed:t.map.id,width:S,height:C,nodes:k.nodes}),i.jsx(OE,{y:k.quarantineY,width:k.width,height:k.quarantineH,nodes:k.nodes}),i.jsx(mE,{snap:t,tickets:c,direction:k.direction,nodes:k.nodes,edges:k.edges,preview:a}),i.jsx(lE,{trails:oE(k,x)}),k.nodes.length>0&&i.jsx(aE,{x:x.x,y:x.y,text:t.map.sections.destination}),k.nodes.map(D=>{var J;return i.jsx(RE,{n:D,session:Pe.get(D.ticket.id),stalled:!!ie.get(D.ticket.id)&&aa(ie.get(D.ticket.id),W)!=="live",flag:OS(Ys.ticket(G,t.map.id,D.ticket.id)),selected:$e===D.ticket.id,onSelect:o,mark:a==null?void 0:a.marks.get(D.ticket.id),frozen:a==null?void 0:a.frozen.has(D.ticket.id),needs:(J=ve==null?void 0:ve.find(le=>le.mapId===t.map.id&&le.ticketId===D.ticket.id))==null?void 0:J.tier},D.ticket.id)})]})})]}),i.jsx("button",{className:"btn sm fit-btn","data-tip":"Fit the whole trail in view",onPointerDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),R.current=!0,b(j())},children:"Fit"})]})}const _c=[["decided","Done"],["claimed","Working"],["frontier","Ready"],["blocked","Backlog"],["parked","Parked"],["out-of-scope","Cancelled"]],op=[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]];function GE({snap:e,sessions:t}){const s=Mp(e),o=p=>s[p],a=t.filter(xg).length,c=px(e),d=Math.max(1,...c.map(p=>p.open+p.closed)),m=(e.map.verification??"off")!=="off"||op.some(([p])=>o(p))?[..._c.slice(0,2),...op,..._c.slice(2)]:_c;return i.jsxs("div",{className:"status-panel",children:[i.jsxs("div",{className:"sp-col sp-status",children:[i.jsxs("div",{className:"sp-head",children:[i.jsx(Ve,{as:"h3",children:"Status"}),i.jsxs("span",{className:"t-meta",children:[s.total," tickets"]})]}),i.jsxs("ul",{children:[m.map(([p,v])=>i.jsxs("li",{className:`st-${p} ${o(p)?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:v}),i.jsx("b",{children:o(p)})]},p)),i.jsxs("li",{className:`st-waiting ${a?"":"zero"}`,children:[i.jsx("i",{}),i.jsx("span",{children:"Waiting on you"}),i.jsx("b",{children:a})]})]})]}),i.jsxs("div",{className:"sp-block sp-col",children:[i.jsx("span",{className:"t-label",children:"Type mix"}),i.jsx("ul",{className:"mix",children:c.map(p=>i.jsxs("li",{title:`${p.type}: ${p.closed} closed, ${p.open} open`,children:[i.jsx("span",{className:"t-meta",children:nr[p.type]}),i.jsxs("span",{className:"mix-bar",children:[i.jsx("i",{className:"closed",style:{width:`${p.closed/d*100}%`}}),i.jsx("i",{className:"open",style:{width:`${p.open/d*100}%`}})]}),i.jsx("b",{children:p.open+p.closed})]},p.type))})]})]})}function qE(e){const[t,s]=y.useState(!1);return i.jsxs("div",{className:t?"status-drawer open":"status-drawer",children:[i.jsxs("button",{type:"button",className:"status-toggle","aria-expanded":t,onPointerDown:o=>o.stopPropagation(),onClick:()=>s(!t),children:["Summary ",i.jsx("span",{className:"caret",children:t?"▾":"▴"})]}),i.jsx(GE,{snap:e.snap,sessions:e.sessions})]})}function QE({planOnly:e,verifies:t}){const s=[["frontier","Ready"],["claimed","Working"],...t?[["verifying","Verifying"],["rework","Rework"],["held","Blocked"]]:[],["stalled","Stalled"],["blocked","Backlog"],["decided","Done"],...e?[["parked","Parked"]]:[],["out-of-scope","Cancelled"],["waiting","Waiting on you"]];return i.jsxs("div",{className:"legend",children:[s.map(([o,a])=>i.jsxs("span",{className:`lg st-${o}`,children:[i.jsx("i",{}),a]},o)),i.jsx("span",{className:"lg hitl",children:"● needs human"})]})}function YE(e){var o,a;const{snap:t,selection:s}=e.api;return i.jsxs(ze,{as:"main",className:"zone map-zone",style:{gridArea:"map"},children:[t&&i.jsx(rb,{}),(o=e.trail)==null?void 0:o.banner,i.jsxs("div",{className:"map-area",children:[t&&!e.compact&&i.jsx(qE,{snap:t,sessions:e.sessions}),t?i.jsx(VE,{snap:t,sessions:e.sessions,leases:e.api.leases,selection:s,onSelect:e.onSelect,minFit:e.minFit,preview:(a=e.trail)==null?void 0:a.preview}):i.jsxs("div",{className:"nomap",children:[i.jsx(cb,{}),i.jsx("h2",{children:"No trail"}),i.jsx("p",{className:"nomap-lede",children:"Describe your idea and create the trail here, or start it in your agent's chat. Scout frames it with you, then your agents get to work."}),i.jsx("div",{className:"actions",children:i.jsx(P,{variant:"primary",onClick:e.onNewTrail,"data-tip":"Describe the idea and create the trail",children:"New trail…"})}),i.jsx(Ko,{command:'/scout new "your idea"'})]}),t&&e.compact&&i.jsx(QE,{planOnly:t.map.mode==="plan-only",verifies:(t.map.verification??"off")!=="off"})]})]})}const JE=[["home","Inbox"],["map","Map"],["ticket","Ticket"],["activity","Activity"],["plan","Plan"]];function XE(e){const{tab:t,covered:s,pending:o}=e;return i.jsx("nav",{className:"tabbar",children:JE.map(([a,c])=>i.jsxs("button",{className:t===a&&!s?"on":"",onClick:()=>e.onPick(a),children:[c,a==="home"&&o>0&&i.jsx(ds,{n:o,urgent:!0,pop:!0},o)]},a))})}function ZE(e){const t={home:e.projects?i.jsxs("div",{className:"phone-home",children:[e.projects,e.inbox]}):e.inbox,map:e.map,ticket:i.jsx(ze,{className:"zone",children:e.ticket}),activity:i.jsx(ze,{className:"zone",children:e.activity}),plan:e.plan};return i.jsx("main",{className:"phone-view",children:e.decisions||t[e.tab]})}const ap={settingsPage:!0},lp=()=>Hg(new URLSearchParams(location.search).get("settings")),cp=()=>{var e;return!!((e=history.state)!=null&&e.settingsPage)};function e2(){const[e,t]=y.useState(lp);y.useEffect(()=>{e&&!cp()&&(history.replaceState(null,"",Xi(location.href,null)),history.pushState(ap,"",Xi(location.href,e)));const c=()=>t(lp());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const s=c=>{const d=Xi(location.href,c);e?history.replaceState(history.state,"",d):history.pushState(ap,"",d),t(c)},o=()=>{e&&(t(null),cp()?history.back():history.replaceState(null,"",Xi(location.href,null)))},a=c=>s(Hg(c??"")??{});return{route:e,open:a,show:s,close:o,toggle:()=>e?o():a()}}function t2(e,t){const{activity:s,selection:o,setSelection:a,actions:c}=e,[d,h]=y.useState("ticket"),[m,p]=y.useState("home"),[v,k]=y.useState(0),[x,S]=y.useState(null),[C,j]=y.useState(!1),I=Q=>{j(!1),S({focus:Q})},b=()=>{S(null),j(Q=>!Q)};y.useEffect(()=>{const Q=s.sessions.find(W=>W.id===e.chatSession);!o&&(Q!=null&&Q.ticketId)&&Q.mapId===e.mapId&&a({kind:"ticket",id:Q.ticketId})},[e.chatSession,e.mapId]);const R=Q=>{a(Q),Q&&(t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket"))},O=(Q,W,ie)=>{ie&&ie!==e.mapId&&c.selectMap(ie),c.openChat(Q);const G=s.sessions.find(ve=>ve.id===Q);W&&(G==null?void 0:G.mapId)===(ie??e.mapId)&&a({kind:"ticket",id:W}),t==="mobile"&&(p("home"),k(ve=>ve+1))};return{sideTab:d,setSideTab:h,phoneTab:m,setPhoneTab:p,convRequest:v,decisionsView:x,setDecisionsView:S,openDecisions:I,statsOpen:C,setStatsOpen:j,toggleStats:b,select:R,openChat:O,showChat:(Q,W,ie)=>{O(Q,W,ie),k(G=>G+1)},openTicket:(Q,W)=>{Q!==e.mapId&&c.selectMap(Q),a({kind:"ticket",id:W}),S(null),t==="laptop"&&h("ticket"),t==="mobile"&&p("ticket")}}}function n2(e,t){y.useEffect(()=>{document.title=`${te.name}: ${e?`(${e}) `:""}${t??"No trail"}`},[e,t])}function s2(e){const[t,s]=y.useState("…");return y.useEffect(()=>{fetch(`${je()}/list`).then(o=>o.json()).then(o=>{var c;const a=o.root.split("/").filter(Boolean);s((c=a[a.length-1])!=null&&c.startsWith(".")?a[a.length-2]??"repo":a[a.length-1]??"repo")}).catch(()=>s("repo"))},[e]),t}function i2(e,t){return y.useMemo(()=>{const s=e.sessions.filter(a=>a.mapId===t),o=new Set(e.sessions.filter(a=>a.mapId!==t).map(a=>a.id));return{...e,sessions:s,feed:e.feed.filter(a=>!a.sessionId||!o.has(a.sessionId))}},[e,t])}function r2({text:e}){return e.trim()?i.jsx("div",{className:"brief-prose",children:e.split(`
|
|
163
|
+
`).map((t,s)=>i.jsx("p",{children:t.split(/(`[^`]+`|\/?\b[\w.-]+\/[\w./-]+\b)/g).map((o,a)=>a%2===1?i.jsx("code",{children:o.replace(/`/g,"")},a):o)},s))}):i.jsx(Ae,{children:"Not covered"})}const up=["summary","productContext","existing","conventions","dataModel","api","risks"];function o2(e){const{brief:t}=e,[s,o]=y.useState(!1),[a,c]=y.useState("");y.useEffect(()=>{const p=v=>v.key==="Escape"&&e.onClose();return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[e]);const d=t.sections,h=up.filter(p=>d[p].trim()),m=up.filter(p=>!d[p].trim());return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(ze,{as:"div",className:"dialog brief-dialog",onClick:p=>p.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:"Discovery brief"}),i.jsx("span",{className:"t-meta",children:a2(t)})]}),i.jsxs("div",{className:"brief-body",children:[h.map(p=>i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:qi[p]}),i.jsx(r2,{text:d[p]}),(p==="conventions"||p==="productContext")&&d[p].trim()&&i.jsx(Eu,{draft:()=>({title:`${qi[p]}: ${d[p].split(`
|
|
164
|
+
`)[0].slice(0,80)}`,body:d[p],kind:p==="conventions"?"convention":"business-rule",sources:[`brief:${t.mapId}`]})})]},p)),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:qi.assumptions}),d.assumptions.length?i.jsx("ul",{className:"item-list",children:d.assumptions.map(p=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:p.text}),i.jsx(V,{parts:[{text:p.id,code:!0}]})]},p.id))}):i.jsx(Ae,{children:"None listed"})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:qi.openQuestions}),d.openQuestions.length?i.jsx("ul",{className:"brief-list",children:d.openQuestions.map(p=>i.jsx("li",{children:p},p))}):i.jsx(Ae,{children:"None"})]}),m.length>0&&i.jsxs("p",{className:"t-meta brief-empty",children:["Nothing noted on ",m.map(p=>qi[p].toLowerCase()).join(", "),"."]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your last request"}),i.jsx("p",{children:t.note})]})]}),s&&i.jsx(Ze,{label:"What should change?",children:i.jsx("textarea",{rows:3,value:a,onChange:p=>c(p.target.value),autoFocus:!0})}),e.changed&&e.onReviewAgain&&i.jsx(pa,{what:"The brief",onReviewAgain:e.onReviewAgain}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[t.status==="submitted"&&!s&&i.jsxs(i.Fragment,{children:[i.jsx(P,{onClick:()=>o(!0),children:"Request changes"}),i.jsx(P,{variant:"primary",disabled:e.changed,onClick:e.onAccept,children:"Accept brief"})]}),s&&i.jsxs(i.Fragment,{children:[i.jsx(P,{variant:"ghost",onClick:()=>o(!1),children:"Back"}),i.jsx(P,{variant:"primary",disabled:!a.trim(),onClick:()=>e.onRequestChanges(a.trim()),children:"Send to the agent"})]}),i.jsx(P,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}function a2(e){if(e.status==="draft")return"Not submitted yet";const t=[e.status.replace("-"," ")];return e.author&&t.push(`by ${e.author}`),e.submittedAt&&t.push(`${dn(Date.now()-e.submittedAt)} ago`),t.join(" · ")}function l2({brief:e,onReview:t}){return e.status!=="submitted"?null:i.jsx("div",{className:"brief-card",children:i.jsx(Ce,{edge:"attention",title:"Discovery brief ready for your review",context:i.jsx(V,{parts:["Discovery brief",e.author&&`by ${e.author}`]}),detail:e.sections.summary.split(`
|
|
165
|
+
`)[0],detailText:e.sections.summary,onOpen:t})})}const c2={draft:["Discovery in progress","An agent maps the existing system before anything is built."],submitted:["Discovery brief ready for your review","Implementation starts once you accept it."],"changes-requested":["You asked for changes","Waiting for the revised discovery brief."],accepted:["Discovery brief accepted",""]};function u2({brief:e,onReview:t}){if(e.status==="accepted")return null;const[s,o]=c2[e.status],a=e.status==="submitted"?"edge-attention":"edge-neutral";return i.jsxs("div",{className:`discovery-banner map-banner ${a} st-${e.status}`,role:"status",children:[i.jsxs("span",{className:"mb-text",children:[i.jsx("span",{className:"mb-lead",children:s}),i.jsx("span",{className:"t-meta",children:o})]}),i.jsx(ni,{text:"Before implementation, an agent maps the existing system: the files involved, conventions, data and API impact, risks and assumptions. You accept the brief or ask for changes; task, execute and prototype tickets can't be claimed until you accept it."}),i.jsx(P,{size:"sm",variant:e.status==="submitted"?"primary":"ghost",onClick:t,children:e.status==="submitted"?"Review brief":"Open brief"})]})}const Nv=`${je()}/briefs`;async function d2(e){if(!e)return{brief:null};const t=await fetch(`${Nv}?mapId=${encodeURIComponent(e)}`);return t.ok?await t.json():{brief:null}}function h2(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState(null),[a,c]=y.useState(),[d,h]=y.useState(),{reload:m,pushed:p}=pt({view:t,version:e==null?void 0:e.tickets.reduce((x,S)=>Math.max(x,S.updatedAt),e.map.updatedAt),load:()=>d2(t),show:x=>{o(x.brief),h(x.hash)},failed:()=>o(null),changed:x=>x.startsWith("briefs/")}),v=(x,S,C)=>fetch(`${Nv}/${x}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,note:S,hash:C})}).then(async j=>{const I=await j.json().catch(()=>({}));if(!j.ok||!I.brief)throw new Error(I.error??`HTTP ${j.status}`);c(void 0),p(),o(I.brief)}),k=(x,S,C)=>v(x,S,C).then(()=>!0,j=>(c(j.message),m(),!1));return{brief:s,error:a,hash:d,accept:x=>k("accept",void 0,x),requestChanges:x=>k("request-changes",x)}}function f2(e){const t=h2(e),[s,o]=y.useState(!1),a=()=>o(!0),c=t.brief,d=ka(s?c==null?void 0:c.mapId:void 0,t.hash),h=c==null?void 0:c.sections;return{review:a,briefText:h?[h.existing,h.conventions,h.dataModel,h.api].join(`
|
|
166
|
+
`):"",banner:c&&i.jsx(u2,{brief:c,onReview:a}),inboxCard:c&&i.jsx(l2,{brief:c,onReview:a}),dialog:c&&s&&i.jsx(o2,{brief:c,error:t.error,changed:d.changed,onReviewAgain:d.reviewAgain,onAccept:()=>void t.accept(d.hash).then(m=>m&&o(!1)),onRequestChanges:m=>void t.requestChanges(m).then(p=>p&&o(!1)),onClose:()=>o(!1)})}}function m2(e){var p;const{reroute:t,onReview:s}=e,o=t.kind==="challenge-destination",a=((p=t.frozen)==null?void 0:p.length)??0,c=o?"wrong mountain?":"proposes a new plan",d=a?` ${a} ticket${a===1?" is":"s are"} closed until you decide.`:"",h=t.wide?" It touches most of the open tickets, so nothing is frozen.":"",m=`${t.reason.replace(/\.$/,"")}.${d}${h}`;return i.jsxs("div",{className:"reroute-banner map-banner edge-attention",role:"status",title:m,children:[i.jsxs("span",{className:"mb-text",children:[i.jsxs("span",{className:"mb-lead",children:[t.by," ",c]}),i.jsx("span",{className:"t-meta",children:m})]}),i.jsx(ni,{text:"An agent found that an assumption or the plan no longer holds and proposes changes. The map shows them: dashed outlines are tickets it adds, struck ones it cancels, ❄ marks tickets frozen until you approve or reject. Nothing changes until you decide."}),i.jsx(P,{size:"sm",variant:"ghost",className:"reroute-dismiss",onClick:e.onDismiss,children:"Dismiss"}),i.jsx(P,{size:"sm",variant:"primary",onClick:s,children:"Review"})]})}const p2=e=>e.changes.flatMap(t=>"ticket"in t?[t.ticket]:[]);function g2(e,t){const s=new Set(p2(t));return e.tickets.filter(o=>s.has(o.id)&&o.updatedAt>t.at).map(o=>({key:o.key,title:o.title,what:v2(o)}))}function v2(e){return e.state==="closed"?"closed":e.assignee?`claimed by ${e.assignee}`:"changed"}function k2({parts:e}){return i.jsx("dl",{className:"reroute-parts",children:e.map(t=>i.jsxs("div",{children:[i.jsx("dt",{className:"t-label",children:t.label}),i.jsx("dd",{className:"t-body",children:t.text})]},t.label))})}const y2={"already-exists":"The work already exists","wrong-problem":"The trail targets the wrong problem",rescope:"The trail should be rescoped"},bv="Dismissed by the trail lead. Carry on with the current plan.",w2="Declined by the trail lead.";function x2(e,t){var s,o,a;switch(e.op){case"edit_ticket":return[...(s=e.title)!=null&&s.trim()?[{label:"New title",text:e.title.trim()}]:[],...(o=e.body)!=null&&o.trim()?[{label:"New description (replaces the old one)",text:e.body.trim()}]:[]];case"add_ticket":return[...(a=e.body)!=null&&a.trim()?[{label:"Description",text:e.body.trim()}]:[],{label:"Who decides",text:e.hitl?"You (HITL)":"Agents, without you"}];case"supersede_decision":return[{label:`New answer to ${e.decision}`,text:e.answer},{label:"Rationale",text:e.rationale},{label:"Recorded as",text:`Proposed by ${t}, approved by you; the words stay ${t}'s.`}];default:return[]}}function j2(e,t){var s;switch(e.op){case"add_ticket":{const o=(s=e.blockedBy)!=null&&s.length?`after ${e.blockedBy.map(t).join(", ")}`:void 0;return{verb:"Add",text:e.title,detail:[`new ${e.type} ticket`,o].filter(Boolean).join(" · ")}}case"cancel_ticket":return{verb:"Cancel",text:t(e.ticket),detail:e.reason};case"edit_ticket":return{verb:"Revise",text:t(e.ticket),detail:S2(e)};case"rewire":return{verb:"Rewire",text:t(e.ticket),detail:N2(e,t)};case"supersede_decision":return{verb:"Supersede",text:e.decision,detail:"Replaced by the answer below"};case"update_destination":return{verb:"Destination",text:e.text};case"add_unspecified":return{verb:"Not yet specified",text:e.text};case"add_out_of_scope":return{verb:"Out of scope",text:e.text};case"reopen":return{verb:"Reopen",text:t(e.ticket),detail:`Back in the queue: ${e.reason}`};case"skip_discovery":return{verb:"Skip discovery",text:"Implementation stops waiting for a discovery brief",detail:"The discovery ticket is ruled out"};case"set_mode":return{verb:"Mode",text:e.mode,detail:e.mode==="plan-only"?"Execute tickets wait":"Execute tickets can be worked"};default:return e}}function S2(e){var s,o;return[((s=e.title)==null?void 0:s.trim())&&"New title",((o=e.body)==null?void 0:o.trim())&&"new description"].filter(Boolean).join(" and ").replace(/^new/,"New")}function N2(e,t){var o,a;return[...(o=e.addBlockedBy)!=null&&o.length?[`now also after ${e.addBlockedBy.map(t).join(", ")}`]:[],...(a=e.removeBlockedBy)!=null&&a.length?[`no longer after ${e.removeBlockedBy.map(t).join(", ")}`]:[]].join(" · ")}const b2=new Set(["cancel_ticket","update_destination"]);function C2(e){const{change:t,name:s}=e,o=j2(t,s),a=x2(t,e.by);return i.jsx(Ce,{as:"li",className:`reroute-change op-${t.op}`,edge:b2.has(t.op)?"attention":"neutral",title:o.text,titleText:o.text,context:i.jsx(V,{parts:[{text:o.verb,strong:!0}]}),detail:o.detail,detailText:o.detail,below:a.length?i.jsx(k2,{parts:a}):void 0})}function $2(e){const{reason:t,destination:s}=e;return i.jsxs("section",{className:"reroute-destination",children:[t&&i.jsx("p",{className:"reroute-destination-why",children:y2[t]}),s&&i.jsxs("div",{className:"reroute-destination-diff",children:[i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Destination now"}),i.jsx("p",{className:"before",children:s.before||"—"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"mono-label",children:"Suggested destination"}),i.jsx("p",{className:"after",children:s.after})]})]})]})}function T2(e){return i.jsxs("section",{className:"reroute-drift edge-note edge-attention",children:[i.jsx("h3",{className:"mono-label",children:"Changed since it was proposed"}),i.jsx("ul",{className:"item-list",children:e.changed.map(t=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:t.title}),i.jsx(V,{parts:[{text:t.key,code:!0},t.what]})]},t.key))}),i.jsxs("label",{className:"reroute-seen t-body",children:[i.jsx("input",{type:"checkbox",checked:e.seen,onChange:t=>e.onSeen(t.target.checked)})," I’ve seen what changed: apply the proposal to the trail as it is now"]})]})}function E2(e,t){const s=new Map(e.tickets.map(a=>[a.id,a.key])),o=new Map(t.flatMap(a=>a.op==="add_ticket"?[[a.ref,a.title]]:[]));return a=>{const c=s.get(a);if(c)return c;const d=o.get(a);return d?`new: ${d}`:a}}function A2(e){var R,O;const{reroute:t,snap:s}=e,[o,a]=y.useState(""),[c,d]=y.useState(!1);y.useEffect(()=>{const U=X=>X.key==="Escape"&&e.onClose();return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const h=E2(s,t.changes),m=new Map(s.tickets.map(U=>[U.id,`${U.key} ${U.title}`])),p=U=>m.get(U)??h(U),v=s.map.sections.assumptions??[],k=t.invalidates.map(U=>v.find(X=>X.id===U)??{id:U,text:""}),x=t.status==="pending",S=x?g2(s,t):[],C=!S.length||c,j=t.kind==="challenge-destination",I=t.lane==="setting",b=I?`${t.by} asks to change your setting`:"Reroute proposal";return i.jsx("div",{className:"scrim",onClick:e.onClose,children:i.jsxs(ze,{as:"div",className:"dialog reroute-dialog",onClick:U=>U.stopPropagation(),children:[i.jsxs("header",{children:[i.jsx("h2",{className:"t-heading caps",children:j?"Destination challenged":b}),i.jsx(V,{parts:[{text:t.id,code:!0},t.status,`by ${t.by}`,`${dn(Date.now()-t.at)} ago`]})]}),i.jsxs("div",{className:"reroute-body",children:[e.replaced&&i.jsxs("p",{className:"reroute-replaced t-meta edge-note edge-attention",children:[t.by," replaced ",e.replaced," with this proposal while you were reading: review it again."]}),j&&i.jsx($2,{reason:t.destinationReason,destination:(R=t.diff)==null?void 0:R.destination}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Why"}),i.jsx("p",{children:t.reason})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Evidence"}),i.jsx("p",{className:"reroute-evidence",children:t.evidence})]}),k.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Assumptions it invalidates"}),i.jsx("ul",{className:"item-list",children:k.map(U=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:U.text}),i.jsx(V,{parts:[{text:U.id,code:!0}]})]},U.id))})]}),i.jsxs("section",{children:[i.jsxs("h3",{className:"mono-label",children:["Changes · ",t.changes.length]}),i.jsx("ul",{className:"reroute-changes row-list",children:t.changes.map((U,X)=>i.jsx(C2,{change:U,by:t.by,name:p},X))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Closed until you decide"}),t.wide&&i.jsxs("p",{className:"t-meta",children:["It touches ",t.wide.touched," of ",t.wide.open," open tickets, so it freezes none: the current plan stands until you decide."]}),(O=t.frozen)!=null&&O.length?i.jsx("ul",{className:"item-list",children:t.frozen.map(U=>i.jsx("li",{className:"item-text",children:p(U)},U))}):i.jsx(Ae,{children:"No tickets closed"})]}),t.note&&i.jsxs("section",{children:[i.jsx("h3",{className:"mono-label",children:"Your note"}),i.jsx("p",{children:t.note})]})]}),S.length>0&&i.jsx(T2,{changed:S,seen:c,onSeen:d}),x&&i.jsx(Ze,{label:"Note for the agent (required to reject)",children:i.jsx("textarea",{rows:2,value:o,onChange:U=>a(U.target.value)})}),e.error&&i.jsx("p",{className:"urgent-text",children:e.error}),i.jsxs("div",{className:"actions",children:[x&&i.jsxs(i.Fragment,{children:[i.jsx(P,{className:"reroute-dismiss",variant:"ghost","data-tip":"Reject it without a note of your own",onClick:()=>e.onReject(I?w2:bv),children:I?"Decline":"Dismiss"}),i.jsx(P,{className:"reroute-reject",disabled:!o.trim(),onClick:()=>e.onReject(o.trim()),children:"Reject"}),i.jsx(P,{className:"reroute-approve",variant:"primary",disabled:!C,onClick:()=>e.onApprove(o.trim()),children:"Approve and apply"})]}),i.jsx(P,{variant:"ghost",onClick:e.onClose,children:"Close"})]})]})})}const Cv=`${je()}/reroutes`;async function I2(e){if(!e)return[];const t=await fetch(`${Cv}?map=${encodeURIComponent(e)}`);return t.ok?(await t.json()).reroutes:[]}function M2(e){const t=e==null?void 0:e.map.id,[s,o]=y.useState([]),[a,c]=y.useState(),{reload:d}=pt({view:t,version:e==null?void 0:e.tickets.reduce((m,p)=>Math.max(m,p.updatedAt),e.map.updatedAt),load:()=>I2(t),show:o,failed:()=>o([]),events:{reroute:m=>(m==null?void 0:m.mapId)===t}}),h=async(m,p,v)=>{var C,j;const k=await fetch(`${Cv}/${m}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:t,id:p,note:v,hash:(C=s.find(I=>I.id===p))==null?void 0:C.hash})}),x=await k.json().catch(()=>({}));if(k.ok)return c(void 0),d(),!0;const S=(j=x.errors)==null?void 0:j.map(I=>I.message).join("; ");return c([x.error??`HTTP ${k.status}`,S].filter(Boolean).join(": ")),!1};return{reroutes:s,pending:s.find(m=>m.status==="pending"),error:a,clearError:()=>c(void 0),approve:(m,p)=>h("approve",m,p),reject:(m,p)=>h("reject",m,p)}}function R2(e,t){let s=t;for(let o=0;s&&o<e.length;o++){const a=e.find(c=>c.id===s);if((a==null?void 0:a.status)!=="superseded"||!a.supersededBy)break;s=a.supersededBy}return s!==t?{id:s,replaced:t}:{id:t}}function L2(e,t){const s=M2(e),[o,a]=y.useState(),c=R2(s.reroutes,o),d=s.reroutes.find(k=>k.id===c.id),h=d!=null&&d.diff?d:s.pending,m=()=>{a(void 0),s.clearError()},p=k=>k&&m(),v=s.pending;return{banner:v&&i.jsx(m2,{reroute:v,onReview:()=>a(v.id),onDismiss:()=>void s.reject(v.id,bv)}),preview:e&&(h!=null&&h.diff)?uE(e,h.diff,h.frozen):void 0,openReroute:(k,x)=>{k!==(e==null?void 0:e.map.id)&&(t==null||t(k)),a(x)},dialog:e&&d&&i.jsx(A2,{reroute:d,replaced:c.replaced,snap:e,error:s.error,onApprove:k=>void s.approve(d.id,k||void 0).then(p),onReject:k=>void s.reject(d.id,k).then(p),onClose:m},d.id)}}function O2(e,t){const s=f2(e),o=L2(e,t);return{briefText:s.briefText,inboxCard:s.inboxCard,review:s.review,banner:i.jsxs(i.Fragment,{children:[s.banner,o.banner]}),preview:o.preview,openReroute:o.openReroute,dialog:i.jsxs(i.Fragment,{children:[s.dialog,o.dialog]})}}function P2(){const e=new URL(location.href);e.searchParams.has(Gs)&&(e.searchParams.delete(Gs),history.replaceState(history.state,"",e))}function _2(e,t){return e.kind!=="question"||t.pending.some(s=>s.id===e.ref)}function D2(e){const[t,s]=y.useState(()=>new URLSearchParams(location.search).get(Gs)??void 0),{loaded:o,view:a,activity:c,handlers:d,showChat:h}=e;return y.useEffect(()=>{if(!t||!o||!a)return;const m=a.items.find(v=>v.id===t);if(m&&!_2(m,c)||(s(void 0),P2(),!m))return;Ig(m,{...d,openQuestion:v=>{const k=c.pending.find(x=>x.id===v);k&&h(k.sessionId,k.ticketId)}})},[t,o,a,c,d,h]),{request:y.useCallback(m=>s(m),[])}}function z2(e){const{api:t,nav:s}=e,o=Rg(t.allSnaps);K1(o.view);const a=p=>p&&t.actions.selectMap(p),c={openTicket:s.openTicket,openKnowledge:()=>e.knowledge.setOpen(!0),openBrief:p=>p===t.mapId?e.reviewBrief():a(p),openReroute:e.openReroute??(p=>p.ticketId?s.openTicket(p.mapId,p.ticketId):a(p.mapId)),selectTrail:a,openGuides:e.openGuides,openConnector:e.openConnector,openApprovals:e.openApprovals},d=o.view,h=D2({loaded:t.loaded,view:d,activity:t.activity,handlers:c,showChat:s.showChat}),m=d&&i.jsx(F1,{view:d,onFocus:p=>void o.savePrefs(kj(d.prefs,p,Date.now())),onSettings:e.openFocusSettings});return{attention:o,handlers:c,header:m,link:h}}async function B2(){const e=await fetch(`${je()}/signed-state`);return e.ok?await e.json():null}function F2(){const[e,t]=y.useState();return pt({load:B2,show:t,failed:()=>t(null),changed:s=>s.endsWith("map.md")||s.includes("/tickets/")||s.includes("/decisions/")}),e}const U2={ticket:"held until you accept or revert it",decision:"what you see is what was signed here, until you accept or revert it"};function W2(e){return e[0]==="added"?"added outside Teamtrail":e.map(t=>t==="words"?"its words":t).join(", ")}function $v({mapId:e,kind:t,id:s}){const o=F2(),a=d=>d.mapId===e&&d.kind===t&&d.id===s,c=o==null?void 0:o.changes.find(a);return c?i.jsx(Ce,{className:"d-section",edge:"attention",title:"Changed outside Teamtrail",context:i.jsx(V,{parts:[`${W2(c.fields)} · ${U2[t]}`]}),detail:"By a teammate or an agent editing the file. Settings → Approvals shows what changed."}):o!=null&&o.textEdits.some(a)?i.jsx(V,{className:"d-section",parts:["Text edited outside Teamtrail"]}):null}function H2({d:e}){return e.derived?i.jsx(V,{className:"d-section",parts:["Unverified · read from text anyone who can edit the tracker wrote, not a decision Teamtrail recorded"]}):null}function K2(e){const{d:t,snap:s}=e,o=oi(),[a,c]=y.useState(!1),[d,h]=y.useState(""),[m,p]=y.useState("");y.useEffect(()=>{c(!1),h(""),p("")},[t.id,t.mapId]);const v=Yw(e.all.filter(j=>j.mapId===t.mapId),t.id),k=ar(t),x=t.ticketId?s==null?void 0:s.tickets.find(j=>j.id===t.ticketId):void 0,S=Date.now(),C=Zs(t.source.url);return i.jsxs("div",{className:"detail dv-d",children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key",children:t.id}),i.jsx(Yn,{tone:"state",className:`dv-st-${k}`,children:k}),i.jsx(V,{parts:[pS(t.decidedAt),`${dn(S-t.decidedAt)} ago`]})]}),i.jsx("h3",{className:"t-heading",children:t.question}),i.jsx($v,{mapId:t.mapId,kind:"decision",id:t.id}),i.jsx(H2,{d:t}),i.jsxs("div",{className:"resolution",children:[i.jsx(Jc,{parts:["Decision"]}),i.jsx("p",{children:t.answer})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"Trail"}),i.jsx("dd",{children:s?`${s.map.key} ${s.map.title}`:t.mapId}),i.jsx("dt",{children:"Ticket"}),i.jsx("dd",{children:t.ticketId?i.jsxs("button",{className:"link",onClick:()=>e.onOpenTicket(t.mapId,t.ticketId),children:[t.ticketKey," ",(x==null?void 0:x.title)??""," · open in trail ›"]}):"—"}),i.jsx("dt",{children:"Decided by"}),i.jsx("dd",{children:[Gn(t.decidedBy,o),Ep(t)].filter(Boolean).join(", ")}),t.participants.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Participants"}),i.jsx("dd",{children:t.participants.map(j=>j.name??j.id).join(", ")})]}),i.jsx("dt",{children:"Source"}),i.jsxs("dd",{children:[qn[t.source.kind].label,C&&i.jsxs(i.Fragment,{children:[" · ",i.jsx("a",{href:C,target:"_blank",rel:"noreferrer",children:t.source.label??"link"})]}),!C&&t.source.label&&` · ${t.source.label}`,t.source.ref&&i.jsxs("span",{className:"ref",children:[" ",t.source.ref]})]})]}),t.alternatives.length>0&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Alternatives"}),i.jsx("ul",{className:"dv-alts",children:t.alternatives.map(j=>i.jsx("li",{children:j},j))})]}),t.rationale&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Rationale"}),i.jsx("p",{children:t.rationale})]}),v.length>1&&i.jsxs("div",{className:"dv-sec",children:[i.jsx("h4",{className:"mono-label",children:"Supersession"}),i.jsx("ol",{className:"dv-chain",children:v.map(j=>i.jsx("li",{className:`${j.id===t.id?"cur":""} ${j.supersededBy?"old":"live"}`,children:i.jsxs("button",{onClick:()=>e.onSelect(j.id),children:[i.jsx("i",{}),i.jsx("span",{className:"id",children:j.id}),i.jsx("span",{className:"a",children:j.summary}),i.jsx(V,{parts:[Gn(j.decidedBy,o),Qs(j.decidedAt)]})]})},j.id))})]}),i.jsxs("div",{className:"actions",children:[i.jsx(Eu,{draft:()=>({title:t.summary||t.question,body:[t.answer,t.rationale&&`Why: ${t.rationale}`].filter(Boolean).join(`
|
|
167
|
+
|
|
168
|
+
`),kind:"product-decision",sources:[`decision:${t.id}`,...t.ticketKey?[`ticket:${t.ticketKey}`]:[]]})}),k==="active"&&!t.postedBy&&i.jsx(P,{on:a,onClick:()=>c(j=>!j),"data-tip":"Replace this decision with a new answer. Both stay on record",children:"Supersede…"})]}),a&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),d.trim()&&(e.onSupersede(t,{answer:d.trim(),rationale:m.trim(),alternatives:[t.summary]}),c(!1))},children:[i.jsx(Ze,{label:"New decision",children:i.jsx("textarea",{rows:3,value:d,onChange:j=>h(j.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:m,onChange:j=>p(j.target.value)})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Supersede"})]})]}),i.jsxs("div",{className:"dv-sec",children:[i.jsxs("h4",{className:"mono-label",children:["Transcript ",i.jsx("span",{className:"n",children:t.transcript.length})]}),t.transcript.length?i.jsx("div",{className:"dv-transcript comms-log",children:t.transcript.map((j,I)=>i.jsxs("div",{className:`msg from-${j.from} voice-${j.from==="human"?"human":"agent"}`,children:[i.jsx(Jc,{parts:[Gn(j.author,o),ku(j.at)]}),i.jsx("div",{className:"msg-text",children:j.text})]},I))}):i.jsx(Ae,{children:"None recorded"})]})]})}function _t(e){return i.jsx("li",{children:i.jsxs("button",{className:`dv-opt ${e.on?"on":""} ${e.cls??""}`,onClick:e.onClick,children:[i.jsx("span",{className:"ttl",children:e.label}),i.jsx("b",{children:e.n})]})})}function V2(e){const{filter:t,set:s,all:o}=e,a=c=>o.filter(c).length;return e.compact?i.jsxs("div",{className:"dv-filters compact",children:[i.jsx(dt,{compact:!0,"aria-label":"Trail",value:t.mapId??"",onChange:c=>s({mapId:c||void 0}),options:[{value:"",label:"All trails"},...e.trails.map(c=>({value:c.map.id,label:`${c.map.key} ${c.map.title}`}))]}),i.jsx(dt,{compact:!0,"aria-label":"Source",value:t.source??"",onChange:c=>s({source:c||void 0}),options:[{value:"",label:"All sources"},...Do.map(c=>({value:c,label:qn[c].label}))]}),i.jsx(dt,{compact:!0,"aria-label":"Decided by",value:t.decidedBy??"",onChange:c=>s({decidedBy:c||void 0}),options:[{value:"",label:"Anyone"},...e.people.map(c=>({value:c,label:c}))]}),i.jsx(dt,{compact:!0,"aria-label":"Status",value:t.status??"",onChange:c=>s({status:c||void 0}),options:[{value:"",label:"Any status"},{value:"active",label:"Active"},{value:"superseded",label:"Superseded"}]})]}):i.jsxs("aside",{className:"dv-filters",children:[i.jsx("h3",{className:"mono-label",children:"Trail"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.mapId,label:"All trails",n:o.length,onClick:()=>s({mapId:void 0})}),e.trails.map(c=>i.jsx(_t,{on:t.mapId===c.map.id,label:`${c.map.key} ${c.map.title}`,n:a(d=>d.mapId===c.map.id),onClick:()=>s({mapId:c.map.id})},c.map.id))]}),i.jsx("h3",{className:"mono-label",children:"Source"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.source,label:"All",n:o.length,onClick:()=>s({source:void 0})}),Do.map(c=>i.jsx(_t,{cls:`src-${c}`,on:t.source===c,label:qn[c].label,n:a(d=>d.source.kind===c),onClick:()=>s({source:t.source===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Made by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.madeBy,label:"Anyone",n:o.length,onClick:()=>s({madeBy:void 0})}),i.jsx(_t,{on:t.madeBy==="agent",label:"Agents, on their own",n:a(c=>tr(c)==="agent"),onClick:()=>s({madeBy:t.madeBy==="agent"?void 0:"agent"})}),i.jsx(_t,{on:t.madeBy==="human",label:"People",n:a(c=>tr(c)==="human"),onClick:()=>s({madeBy:t.madeBy==="human"?void 0:"human"})})]}),i.jsx("h3",{className:"mono-label",children:"Decided by"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.decidedBy,label:"Anyone",n:o.length,onClick:()=>s({decidedBy:void 0})}),e.people.map(c=>i.jsx(_t,{on:t.decidedBy===c,label:c,n:a(d=>d.decidedBy===c),onClick:()=>s({decidedBy:t.decidedBy===c?void 0:c})},c))]}),i.jsx("h3",{className:"mono-label",children:"Status"}),i.jsxs("ul",{children:[i.jsx(_t,{on:!t.status,label:"Any",n:o.length,onClick:()=>s({status:void 0})}),i.jsx(_t,{on:t.status==="active",label:"Active",n:a(c=>!c.supersededBy),onClick:()=>s({status:t.status==="active"?void 0:"active"})}),i.jsx(_t,{on:t.status==="superseded",label:"Superseded",n:a(c=>!!c.supersededBy),onClick:()=>s({status:t.status==="superseded"?void 0:"superseded"})})]})]})}function G2(e){if(ar(e)==="superseded")return`Replaced by ${e.supersededBy}`;if(e.supersedes)return`Replaces ${e.supersedes}`}function q2(e){const{d:t}=e,s=oi(),o=ar(t);return i.jsxs(i.Fragment,{children:[e.newDay&&i.jsx("li",{className:"dv-day t-label",children:Qs(t.decidedAt)}),i.jsx(Ce,{as:"li",className:`dv-row ${o}`,selected:e.on,onOpen:e.onClick,title:t.question,titleText:t.question,trailing:ku(t.decidedAt),context:i.jsx(V,{parts:[{text:t.id,code:!0},t.ticketKey&&{text:t.ticketKey,code:!0},e.showTrail&&e.trail,Gn(t.decidedBy,s),Ep(t)??qn[t.source.kind].label,G2(t)]}),detail:t.summary,detailText:t.summary})]})}function Q2(e){const{rows:t,current:s}=e;return i.jsx("ol",{className:"dv-list","aria-label":"Logbook",children:t.length?t.map((o,a)=>{var c;return i.jsx(q2,{d:o,newDay:a===0||Qs(t[a-1].decidedAt)!==Qs(o.decidedAt),trail:(c=e.snaps[o.mapId])==null?void 0:c.map.key,on:(s==null?void 0:s.id)===o.id&&s.mapId===o.mapId,showTrail:e.showTrail,onClick:()=>e.onSelect(o.id)},`${o.mapId}:${o.id}`)}):i.jsx(Ae,{children:"No decisions"})})}function Y2({stats:e}){return i.jsxs("span",{className:"dv-readouts",children:[i.jsx(on,{layout:"start",label:"Active",value:e.active}),i.jsx(on,{layout:"start",label:"Superseded",value:e.superseded}),i.jsx(on,{layout:"start",label:"Last 24h",value:e.last24h}),i.jsx(on,{layout:"start",label:"Human",value:`${e.total?Math.round(e.human/e.total*100):0}%`}),i.jsx(V,{className:"dv-src-mix",parts:Do.filter(t=>e.bySource[t]).map(t=>`${qn[t].label} ${e.bySource[t]}`)})]})}function J2(e){const{filter:t}=e,o=Object.values(t).filter(Boolean).length-(t.query?1:0),a=e.filtersOpen||o>0;return i.jsxs("div",{className:"dv-search",children:[i.jsx("input",{type:"search",placeholder:"Search decisions",value:t.query??"",onChange:c=>e.set({query:c.target.value})}),e.showToggle&&i.jsxs("button",{className:`chip ${a?"on":""}`,onClick:e.onToggle,children:["Filters",o>0?` · ${o}`:""]})]})}function X2(e){const{api:t,bp:s}=e,o=t.decisions,[a,c]=y.useState({}),[d,h]=y.useState(e.focus),[m,p]=y.useState(!1);y.useEffect(()=>h(e.focus),[e.focus]),y.useEffect(()=>{const R=O=>{O.key==="Escape"&&(s==="mobile"&&d?h(void 0):e.onClose())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[s,d,e]);const v=y.useMemo(()=>wx(o,a),[o,a]),k=y.useMemo(()=>xx(o),[o]),x=o.find(R=>R.id===d&&(!a.mapId||R.mapId===a.mapId))??(s==="mobile"?void 0:v[0]),S=y.useMemo(()=>Object.values(t.allSnaps).sort((R,O)=>O.map.createdAt-R.map.createdAt),[t.allSnaps]),C=y.useMemo(()=>[...new Set(o.map(R=>R.decidedBy))].sort(),[o]),j=R=>c(O=>({...O,...R})),I=()=>{const R=Object.fromEntries(S.map(O=>[O.map.id,{key:O.map.key,title:O.map.title}]));cg(`${te.slug}-decisions-${Qs(Date.now())}.md`,Rx(v,R,{title:`${te.name} decisions`}))},b=s==="mobile"&&!!x;return i.jsxs(ze,{className:`zone decisions-view dv-${s}`,children:[i.jsxs("header",{className:"dv-head",children:[b?i.jsx("button",{className:"back",onClick:()=>h(void 0),children:"‹ Decisions"}):i.jsxs(Ve,{as:"h2",children:["Decisions ",v.length!==o.length&&i.jsx("span",{className:"n",children:`${v.length}/${o.length}`})]}),s!=="mobile"&&i.jsx(Y2,{stats:k}),i.jsxs("span",{className:"dv-head-right",children:[!b&&i.jsx(P,{onClick:I,disabled:!v.length,title:"Export the filtered list as markdown",children:"Export .md"}),i.jsx("button",{className:"icon-btn",onClick:e.onClose,"aria-label":"Close",children:"×"})]})]}),!b&&i.jsx(J2,{filter:a,set:j,showToggle:s!=="wide",filtersOpen:m,onToggle:()=>p(R=>!R)}),i.jsxs("div",{className:"dv-body",children:[(s==="wide"||m&&!b)&&i.jsx(V2,{filter:a,set:j,all:o,trails:S,people:C,compact:s!=="wide"}),!b&&i.jsx(Q2,{rows:v,current:x,snaps:t.allSnaps,showTrail:s==="wide",onSelect:h}),(s!=="mobile"||x)&&i.jsx("div",{className:"dv-detail",children:x?i.jsx(K2,{d:x,all:o,snap:t.allSnaps[x.mapId],onSelect:h,onOpenTicket:e.onOpenTicket,onSupersede:t.actions.supersede}):i.jsx(Ae,{children:"No decision selected"})})]})]})}function Z2({api:e,bp:t,nav:s}){return s.statsOpen?i.jsx(iT,{api:e,bp:t,onClose:()=>s.setStatsOpen(!1)}):s.decisionsView?i.jsx(X2,{api:e,bp:t,focus:s.decisionsView.focus,onClose:()=>s.setDecisionsView(null),onOpenTicket:s.openTicket}):null}function eA(e,t,s){const o=hv(),[a,c]=y.useState(()=>new URLSearchParams(location.search).has("projects")),d=a&&o.many&&i.jsx(U$,{projects:o,bp:e,onClose:()=>c(!1),onItemHere:s});return{projects:o,overview:d,openOverview:()=>{t.setDecisionsView(null),t.setStatsOpen(!1),c(!0)}}}const tA={"asks-you":"urgent",answered:"good",launched:"good",done:"good",verified:"good","checks-failed":"attention",stalled:"attention",disconnected:"attention",problem:"attention"};function nA(e){if(e.kind)return tA[e.kind];if(e.signal){if(e.level==="alert")return"urgent";if(e.level==="ok")return"good"}}function Tv({activity:e,onTicket:t}){const s=oi(),o=e.feed.slice(-120).reverse();return o.length?i.jsx("div",{className:"log",children:o.map(a=>i.jsxs("div",{className:`log-row src-${a.source.replace(" ","-")} edge-${nA(a)??"none"}`,onClick:()=>a.ticketId&&t(a.ticketId),children:[i.jsx("span",{className:"t t-meta",children:ua(a.at)}),i.jsx("span",{className:"src t-meta",children:Gn(a.agent??a.source,s)}),i.jsxs("span",{className:"msg",title:a.tag?`${a.tag} · ${a.text}`:a.text,children:[a.tag&&i.jsxs("span",{className:"tag t-meta",children:[a.tag," · "]}),a.text]})]},a.id))}):i.jsx(Qn,{title:"Nothing has happened yet",hint:"Claims, steps, questions and decisions appear here as agents work."})}function dp({lease:e,now:t}){if(!e)return null;const s=aa(e,t);if(s==="live")return null;const o=e.expiresAt-t;return i.jsxs(Yn,{tone:"amber",className:"stalled",title:`No activity from ${e.agent}; the ticket returns to the queue when the lease runs out`,children:["stalled · ",s==="expired"?"returning":Qt(o)]})}function sA({total:e,step:t}){return i.jsx("span",{className:"segs","aria-label":`Step ${t} of ${e}`,children:Array.from({length:e},(s,o)=>i.jsx("i",{className:iA(o+1,t)},o))})}function iA(e,t){return e<t?"done":e===t?"cur":""}function Ev({snap:e,activity:t,leases:s,onSelect:o,onOpenChat:a}){var x;const c=Yt(1e3),d=t.sessions.filter(cn),h=new Set(d.map(S=>S.ticketId)),m=yu(s,e==null?void 0:e.map.id),p=(e==null?void 0:e.tickets.filter(S=>S.state==="open"&&S.assignee&&!h.has(S.id)))??[];if(!d.length&&!p.length)return i.jsx(Ae,{children:"No agent on a ticket"});const v=S=>!!S&&aa(S,c)!=="live",k=!!((x=e==null?void 0:e.map.modelMatching)!=null&&x.enabled);return i.jsxs("ul",{className:"sessions-list",children:[d.map(S=>{const C=e==null?void 0:e.tickets.find(b=>b.id===S.ticketId),j=C?or(C)==="hitl":!1,I=C&&m.get(C.id);return i.jsx(Ce,{as:"li",className:S.waitingOn?"waiting":void 0,edge:rA(S,v(I)),title:lA(C,S.mode)||S.agent,context:i.jsx(V,{parts:[{text:S.agent,strong:!0},k&&oA(S),S.waitingOn?{text:"Waiting on you",urgent:!0}:`${S.mode} · ${S.stepLabel.toLowerCase()}`,j&&!S.waitingOn&&"with you",aA(S)],children:i.jsx(dp,{lease:I,now:c})}),trailing:ug(c-S.startedAt),below:i.jsx(sA,{total:S.total,step:S.step}),onOpen:()=>{C&&o({kind:"ticket",id:C.id}),j&&a(S.id)}},S.id)}),p.map(S=>i.jsx(Ce,{as:"li",className:"claim",edge:v(m.get(S.id))?"attention":"neutral",title:`${S.key} ${S.title}`,context:i.jsx(V,{parts:[{text:S.assignee??"",strong:!0},"claimed, no live session"],children:i.jsx(dp,{lease:m.get(S.id),now:c})}),onOpen:()=>o({kind:"ticket",id:S.id})},S.id))]})}function rA(e,t){return e.waitingOn?"urgent":t?"attention":"neutral"}function oA(e){const t=e.model?`Runs ${e.model}`:"No model reported, so it counts as balanced";return{text:e.tier??"balanced",tip:t,className:"session-tier"}}function aA(e){if(e.usage)return`${da(vx(e))} tok · ${qs(e.usage.costUsd)}`}function lA(e,t){return e?`${e.key} ${e.title}`:t==="chart"?"Charting trail":""}function Av({activity:e,snap:t,running:s,usage:o=!0}){const a=Lp(e,t==null?void 0:t.map.id),c=Pp(e,t==null?void 0:t.map.id),d=new Set(e.sessions.filter(cn).map(m=>m.ticketId)),h=(t==null?void 0:t.tickets.filter(m=>m.state==="open"&&m.assignee&&!d.has(m.id)).length)??0;return i.jsx(Et,{sub:!0,className:"sessions-head",title:i.jsxs(i.Fragment,{children:["Agents on tickets ",i.jsx("span",{className:"n",children:s+h})]}),right:o?i.jsxs("span",{className:"usage",title:["Model usage for this trail, all sessions",...c.map(m=>Op[m].text)].join(`
|
|
169
|
+
`),children:[i.jsx("span",{className:"mono-label",children:"Trail"})," ",da(a.inputTokens+a.outputTokens)," tok · ",qs(a.costUsd)]}):void 0})}function cA(e){const t=[...e.feed].reverse().find(s=>s.level==="step"&&s.sessionId);return t?e.sessions.find(s=>s.id===t.sessionId):void 0}const uA={running:"Working",done:"Done",failed:"Stopped"};function Iv({activity:e,snap:t}){const s=cA(e);if(!s)return i.jsx(Qn,{title:"No agent working yet",hint:"Run /scout resume in Claude Code or Codex. Each step an agent reports shows here."});const o=s.ticketId?t==null?void 0:t.tickets.find(d=>d.id===s.ticketId):void 0,a=sa[s.mode],c=s.waitingOn?"Waiting on you":uA[s.status];return i.jsxs("div",{className:`step-tracker ${s.waitingOn?"waiting":""}`,children:[i.jsxs("div",{className:"st-meta",children:[i.jsx(V,{parts:[{text:s.agent,strong:!0},`${s.mode}, step ${s.step} of ${s.total}`]}),i.jsx("span",{className:`t-label st-status ${s.waitingOn?"urgent":""}`,children:c})]}),i.jsxs("div",{className:"st-big",children:[s.stepLabel,o&&i.jsxs("span",{className:"st-key",children:[" ",o.key]})]}),o&&i.jsx("div",{className:"st-ticket t-meta",children:o.title}),i.jsx("ol",{className:"pipeline",children:a.map((d,h)=>{const m=h+1,p=m<s.step||m===s.step&&s.status==="done";let v="";return p?v="done":m===s.step&&(v="cur"),i.jsxs("li",{className:v,children:[i.jsx("i",{}),i.jsxs("span",{children:[String(m).padStart(2,"0")," ",d]})]},d)})})]})}function hp(e){return i.jsxs("div",{className:"zone-b activity-stack",children:[i.jsx(Iv,{activity:e.activity,snap:e.snap}),i.jsx(Av,{activity:e.activity,snap:e.snap,running:e.activity.sessions.filter(cn).length}),i.jsx(Ev,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:t=>(t==null?void 0:t.kind)==="ticket"&&e.onTicket(t.id),onOpenChat:e.onOpenChat}),i.jsx(Et,{sub:!0,title:"Activity log"}),i.jsx(Tv,{activity:e.activity,onTicket:e.onTicket})]})}function dA(e){return i.jsx(Sg,{area:"log",className:"log-zone",icon:"book",title:"Activity log",info:"Everything that happened in this trail, newest first: claims, steps, questions, decisions and errors.",right:i.jsxs("span",{className:"mono-label dim",children:[e.activity.feed.length," events"]}),children:i.jsx(Tv,{activity:e.activity,onTicket:e.onTicket})})}function hA(e){var o;const t=e.activity.sessions.filter(cn).length,s=!e.activity.sessions.length&&!((o=e.snap)!=null&&o.tickets.some(a=>a.state==="open"&&a.assignee));return i.jsxs(ze,{className:"zone step-zone",style:{gridArea:"step"},children:[i.jsx(Et,{className:"zone-title",icon:"tent",title:"Current trail step",info:"What your agents are doing right now. The top shows the latest step an agent reported; below is every agent holding a ticket."}),i.jsxs("div",{className:"zone-b",children:[i.jsx(Iv,{activity:e.activity,snap:e.snap}),!s&&i.jsxs(i.Fragment,{children:[i.jsx(Av,{activity:e.activity,snap:e.snap,running:t,usage:!1}),i.jsx(Ev,{snap:e.snap,activity:e.activity,leases:e.leases,onSelect:a=>(a==null?void 0:a.kind)==="ticket"&&e.onTicket(a.id),onOpenChat:e.onOpenChat})]})]})]})}function fA(e){const t=ka(e.ticketId,e.hash),[s,o]=y.useState(),a=e.confirmed?"Unconfirm":"Confirm criteria",c=e.confirmed?"Take your confirmation back":"Agree that these criteria define done for this ticket",d=t.changed&&!e.confirmed;return i.jsxs(i.Fragment,{children:[t.changed&&i.jsx(pa,{what:"These criteria",onReviewAgain:t.reviewAgain}),i.jsx(P,{size:"sm",variant:e.confirmed?"ghost":"default",disabled:d,"data-tip":c,onClick:()=>void e.confirm(!e.confirmed,t.hash).then(o),children:a}),s&&i.jsx("p",{className:"vf-err",children:s})]})}function mA(e){const{proposal:t}=e;return i.jsxs("div",{className:"crit-proposal edge-note edge-attention",children:[i.jsxs("p",{className:"t-meta",children:[t.by," proposes new criteria. Yours stay in force until you take these."]}),i.jsx("ul",{className:"item-list",children:t.criteria.map(s=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:s.text}),i.jsx(V,{parts:[{text:s.id,code:!0},s.kind.replace("-"," "),s.source&&`from ${s.source}`]})]},s.id))}),i.jsxs("div",{className:"actions",children:[i.jsx(P,{size:"sm",variant:"ghost",onClick:e.onDismiss,children:"Keep mine"}),i.jsx(P,{size:"sm",disabled:!e.canAccept,onClick:e.onAccept,children:"Take these"})]})]})}function pA(e){const{proposal:t}=e,s=ka(`${t.ticketId}@${t.at}`,t.hash),[o,a]=y.useState(),c=d=>void e.decide(d,s.hash).then(a);return i.jsxs(i.Fragment,{children:[s.changed&&i.jsx(pa,{what:"The proposal",onReviewAgain:s.reviewAgain}),i.jsx(mA,{proposal:t,canAccept:!s.changed,onAccept:()=>c("accept"),onDismiss:()=>c("dismiss")}),o&&i.jsx("p",{className:"vf-err",children:o})]})}async function Mv(e){return e?e.ok?void 0:(await e.json().catch(()=>({}))).error??`HTTP ${e.status}`:"Could not reach the Lookout"}const Rv=`${je()}/criteria`;async function gA(e){if(!e)return[];const t=await fetch(`${Rv}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).tickets:[]}function vA(e){const[t,s]=y.useState([]),{reload:o}=pt({view:e,load:()=>gA(e),show:s,failed:()=>s([]),changed:c=>c.startsWith("criteria/")});return{tickets:t,confirm:c=>fetch(`${Rv}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...c})}).catch(()=>{}).then(async d=>{const h=await Mv(d);return o(),h})}}const Lv=`${je()}/criteria-proposals`;async function kA(e){if(!e)return[];const t=await fetch(`${Lv}?mapId=${encodeURIComponent(e)}`);return t.ok?(await t.json()).proposals:[]}function yA(e){const[t,s]=y.useState([]),{reload:o}=pt({view:e,load:()=>kA(e),show:s,failed:()=>s([]),events:{"criteria-proposals":c=>(c==null?void 0:c.mapId)===e}});return{proposals:t,decide:(c,d)=>fetch(`${Lv}/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,...d})}).catch(()=>{}).then(async h=>{const m=await Mv(h);return o(),m})}}function wA({snap:e,t}){const{tickets:s,confirm:o}=vA(e.map.id),a=yA(e.map.id),c=a.proposals.find(k=>k.ticketId===t.id),d=ri(),h=s.find(k=>k.ticketId===t.id),m=(h==null?void 0:h.criteria)??[],v=qp(d.entries,{trailKey:e.map.key,ticket:{type:t.type,title:t.title,body:t.body},paths:Qp(`${t.body}
|
|
170
|
+
${d.briefText}`)}).filter(k=>k.kind==="business-rule").filter(k=>Zx(m,[k.id]).length);return!m.length&&!v.length&&!c?null:i.jsxs("div",{className:"criteria-section d-section",children:[i.jsxs("span",{className:"t-label","data-tip":"Agreed before the work starts; each needs evidence before the ticket counts as done",children:["Acceptance criteria · ",m.length,(h==null?void 0:h.confirmed)&&i.jsx("span",{className:"ok-text",children:" · confirmed by you"})]}),m.length>0&&i.jsx("ul",{className:"criteria-list item-list",children:m.map(k=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:k.text}),i.jsx(V,{parts:[{text:k.id,code:!0},k.kind.replace("-"," "),k.source&&`from ${k.source}`]})]},k.id))}),c&&i.jsx(pA,{proposal:c,decide:(k,x)=>a.decide(k,{title:e.map.title,ticketId:t.id,hash:x})}),v.length>0&&i.jsxs("div",{className:"crit-uncovered edge-note edge-attention",children:[i.jsx("p",{className:"t-meta",children:"No criterion covers these rules yet:"}),i.jsx("ul",{className:"item-list",children:v.map(k=>i.jsxs("li",{children:[i.jsx("span",{className:"item-text",children:k.title}),i.jsx(V,{parts:[{text:k.id,code:!0},"business rule"]})]},k.id))})]}),m.length>0&&t.state==="open"&&i.jsx(fA,{ticketId:t.id,hash:h==null?void 0:h.hash,confirmed:!!(h!=null&&h.confirmed),confirm:(k,x)=>o({title:e.map.title,ticketId:t.id,ticketKey:t.key,confirmed:k,hash:x})})]})}const Jo="";function xA(e){const t=du.map(o=>({value:o,label:ir[o],hint:Lg[o]})),s=[...jA(e),...t];return i.jsx(dt,{compact:!0,className:"vf-level","aria-label":"Verification level",value:e.value??Jo,options:s,onChange:o=>e.onChange(o===Jo?null:o)})}function jA(e){return e.inherit!==void 0?[{value:Jo,label:e.inherit,hint:"Use the trail’s level for this ticket."}]:e.value===void 0?[{value:Jo,label:"Off (not set)"}]:[]}function SA({check:e}){const t=Q1(e),[s,o]=y.useState(),[a,c]=y.useState(),d=NA(e);return i.jsxs("details",{className:`vf-row ${t?"ok":"bad"}`,open:!t,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"vf-mark",children:t?"✓":"✕"}),i.jsx("span",{className:"t-code vf-name",children:e.name}),i.jsx("span",{className:"t-meta",children:d}),i.jsx("span",{className:"t-meta vf-dur",children:Qt(e.durationMs)})]}),i.jsx("code",{className:"vf-argv",children:e.argv.join(" ")}),e.error&&i.jsx("p",{className:"vf-note",children:e.error}),i.jsx("pre",{className:"vf-tail",children:s??(e.tail||"No output.")}),i.jsxs("div",{className:"vf-log-line",children:[s===void 0&&i.jsx("button",{className:"link",onClick:()=>ur.log(e.log).then(h=>o(h.clipped?`[earlier output not shown]
|
|
171
|
+
${h.text}`:h.text),h=>c(h.message)),children:"Full log ›"}),e.truncated&&i.jsx("span",{className:"dim",children:"log capped at 1 MB"}),a&&i.jsx("span",{className:"vf-err",children:a})]})]})}function NA(e){return e.error?"did not start":e.timedOut?"timed out":`exit ${e.exitCode??e.signal??"?"}`}const fp=e=>(e==null?void 0:e.slice(0,8))??"none",mp=e=>e===null?"·":String(e);function bA({attempt:e}){const t=e.git;if(!t)return null;const{files:s,add:o,del:a}=t.stats;return i.jsxs("div",{className:"vf-git",children:[i.jsx(V,{parts:[t.tree?{text:`${t.base?`${fp(t.base.head)} → `:""}${fp(t.tree.head)}`,code:!0}:"not a git repo",t.tree&&{text:t.tree.branch??"detached HEAD",code:!!t.tree.branch},t.tree&&`${s} file${s===1?"":"s"} +${o} −${a}`]}),t.flags.filter(c=>c.kind!=="no-git").map(c=>{var d;return i.jsxs("p",{className:`vf-flag lv-${c.level}`,title:(d=c.files)==null?void 0:d.join(`
|
|
172
|
+
`),children:[i.jsx("span",{className:"t-code",children:c.kind})," ",c.message]},c.kind)}),t.changed.length>0&&i.jsxs("details",{className:"vf-files",children:[i.jsx("summary",{className:"t-label",children:"Changed files"}),i.jsx("ul",{children:t.changed.map(c=>i.jsxs("li",{children:[i.jsx("code",{children:c.path}),i.jsxs("span",{className:"dim",children:[c.untracked?"new":`+${mp(c.add)} −${mp(c.del)}`,c.dirtyAtClaim?" · dirty at claim":""]})]},c.path))})]})]})}function CA({attempt:e,latest:t}){return i.jsxs("details",{className:`vf-attempt r-${e.result}`,open:t,children:[i.jsxs("summary",{children:[i.jsx(Yn,{tone:"state",className:`r-${e.result}`,children:q1[e.result]}),i.jsx(V,{parts:[{text:e.id,code:!0},e.agent,cr(e.submittedAt),Qt(e.finishedAt-e.submittedAt)]})]}),i.jsx("p",{className:"vf-claim",children:e.summary??e.resolution}),e.note&&i.jsx("p",{className:"vf-note",children:e.note}),e.criteria&&i.jsx("ul",{className:"vf-criteria",children:e.criteria.lines.map(s=>i.jsx("li",{className:$A(s),children:s},s))}),i.jsx(bA,{attempt:e}),e.checks.map(s=>i.jsx(SA,{check:s},s.name))]})}function $A(e){return e.includes(" ✓ ")?"ok":e.includes(" ✗ ")?"bad":e.includes(" ? ")?"claimed":"wait"}const TA={PASS:"Passed",FAIL:"Sent back",NEEDS_HUMAN:"Needs you"};function EA({verdict:e}){const{guide:t,checklist:s}=e;return i.jsxs("div",{className:`vf-verdict v-${e.verdict.toLowerCase()}`,children:[i.jsx(V,{parts:[{text:e.byKind==="trail lead"&&e.verdict==="PASS"?"Approved":TA[e.verdict],strong:!0},{text:e.id,code:!0},e.byKind==="trail lead"?e.by:`review ${e.by}`,e.sessionId&&`session ${e.sessionId.slice(0,8)}`,t&&`as ${t.id} ${t.version}`,`on ${e.attemptId}`,cr(e.at)]}),i.jsx("p",{children:e.summary}),e.findings.length>0&&i.jsx("ul",{className:"vf-findings",children:e.findings.map((o,a)=>i.jsxs("li",{className:`sev-${o.severity}`,children:[o.path&&i.jsx("code",{children:o.line?`${o.path}:${o.line}`:o.path})," ",o.text]},a))}),s&&s.length>0&&i.jsx(Gg,{answers:s})]})}function AA(e,t,s){const[o,a]=y.useState(),c=`${e}/${t}`;y.useEffect(()=>a(void 0),[c]);const{reload:d}=pt({view:c,version:s,load:()=>ur.ticket(e,t),show:a});return y.useEffect(()=>Ys.onEvidence(d),[d]),{data:o,reload:d}}const Dc={rework:{label:"What to fix",submit:"Send to rework",hint:"Posted on the ticket for the next agent."},accept:{label:"Why accept",submit:"Accept anyway",hint:"Closes the ticket as done despite the checks."},unblock:{label:"Why",submit:"Unblock",hint:"Back to the queue without running checks."}};function IA(e){const[t,s]=y.useState(),[o,a]=y.useState(""),[c,d]=y.useState("rework"),{state:h,submitted:m,running:p,act:v}=e;if(p||h!=="verifying"&&h!=="held")return null;const k=S=>{s(t===S?void 0:S),a("")},x=S=>{S.preventDefault(),!(!t||!o.trim())&&(v({action:t,reason:o.trim(),...t==="unblock"?{to:c}:{}}),s(void 0))};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"actions vf-actions",children:[h==="verifying"&&m&&i.jsx(P,{variant:"primary",onClick:()=>void v({action:"approve"}),"data-tip":"Checks passed: approve and close the ticket",children:"Approve"}),m&&i.jsx(P,{onClick:()=>void v({action:"rerun"}),"data-tip":"Run the repo's checks again on the current code",children:"Re-run checks"}),i.jsx(P,{on:t==="rework",onClick:()=>k("rework"),"data-tip":"Send it back to an agent with what to fix",children:"Rework…"}),h==="held"&&i.jsxs(i.Fragment,{children:[i.jsx(P,{on:t==="accept",onClick:()=>k("accept"),"data-tip":"Close it as done despite the failing checks",children:"Accept anyway…"}),i.jsx(P,{on:t==="unblock",onClick:()=>k("unblock"),"data-tip":"Put it back in the queue without running checks",children:"Unblock…"})]})]}),t&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:x,children:[i.jsx(Ze,{label:Dc[t].label,children:i.jsx("textarea",{rows:2,value:o,onChange:S=>a(S.target.value),autoFocus:!0})}),t==="unblock"&&i.jsx(Ze,{label:"Back to",children:i.jsx(dt,{"aria-label":"Back to",value:c,onChange:d,options:[{value:"rework",label:"Rework",hint:"Keeps the feedback for the next agent."},{value:"ready",label:"Ready",hint:"Back in the queue as a fresh ticket."}]})}),i.jsx("span",{className:"dim vf-hint",children:Dc[t].hint}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>s(void 0),children:"Cancel"}),i.jsx(P,{type:"submit",variant:t==="accept"?"danger":"primary",disabled:!o.trim(),children:Dc[t].submit})]})]})]})}const MA={ticket:"set on this ticket",trail:"from the trail",none:"not set"},RA=new Set(["verifying","rework","held"]);function LA(e){const{mapId:t,ticket:s,state:o}=e,{data:a,reload:c}=AA(t,s.id,s.updatedAt),[d,h]=y.useState();if(!a||a.level.level==="off"&&!a.attempts.length&&!RA.has(o))return null;const m=v=>(h(void 0),ur.act({...v,mapId:t,ticketId:s.id,by:St}).then(c,k=>h(k.message))),p=a.running;return i.jsxs("section",{className:"vf-panel",children:[i.jsxs("div",{className:"vf-head",children:[i.jsx(Ve,{as:"h4",children:"Verification"}),i.jsx(V,{parts:[ir[a.level.level],MA[a.level.source]]}),s.state==="open"&&i.jsx(xA,{value:s.verification,inherit:`Trail (${ir[e.trail??"off"]})`,onChange:v=>void m({action:"level",level:v})})]}),p&&i.jsxs("div",{className:"sync-line vf-running",children:[i.jsx("span",{className:"dot"}),i.jsxs("span",{children:["Checking ",p.id," for ",p.agent," · since ",cr(p.startedAt)]})]}),i.jsx(IA,{state:o,submitted:a.attempts.length>0,running:!!p,act:m}),d&&i.jsx("p",{className:"vf-err",children:d}),a.verdicts.map(v=>i.jsx(EA,{verdict:v},v.id)),a.attempts.map((v,k)=>i.jsx(CA,{attempt:v,latest:k===0},v.id)),!a.attempts.length&&!p&&i.jsx(V,{parts:[`Checks: ${a.level.checks.join(", ")||"none"}`,"run when the ticket is submitted"]})]})}function OA({lease:e,onRelease:t}){const s=Yt(1e3),o=aa(e,s),a=o==="live";return i.jsxs("div",{className:`lease lease-${o} edge-note ${a?"":"edge-attention"}`,children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:`Claimed by ${e.agent}`,strong:!0},`active ${dn(s-e.renewedAt)} ago`]}),!a&&i.jsx(Yn,{tone:"amber",children:"Stalled"})]}),i.jsx("p",{className:"t-meta lease-line",children:PA(o,_A(e.expiresAt-s))}),e.workspace&&i.jsxs("p",{className:"t-meta lease-branch",children:["Works on ",i.jsx("code",{className:"t-code",children:e.workspace.branch})," in its own worktree"]}),e.touches&&e.touches.length>0&&i.jsxs("p",{className:"t-meta lease-touches",children:["Expects to change"," ",e.touches.map((c,d)=>i.jsxs("span",{children:[d>0&&", ",i.jsx("code",{className:"t-code",children:c})]},c))]}),e.notes.length>0&&i.jsx("ul",{className:"lease-notes t-meta",children:e.notes.slice(-3).map((c,d)=>i.jsx("li",{children:c},d))}),i.jsx("div",{className:"actions",children:i.jsx(P,{variant:a?"default":"urgent",onClick:t,children:"Release to queue"})})]})}function PA(e,t){return e==="expired"?"Lease expired, going back to the queue":e==="stalled"?`The agent went quiet. Back in the queue in ${t}.`:`Back in the queue after ${t} without activity.`}function _A(e){const t=e/864e5;return t>=2?`${Math.round(t)} days`:Qt(Math.max(0,e))}function DA({comments:e}){const t=oi();if(!e.length)return null;const s=e.length>1?"s":"";return i.jsxs("details",{className:"comments",children:[i.jsxs("summary",{className:"t-label",children:[e.length," other comment",s]}),e.map(o=>i.jsxs("div",{className:"comment",children:[i.jsx(V,{parts:[{text:Gn(o.author,t),strong:!0}]}),i.jsx("div",{className:"c-body",children:o.body.replace(/\*\*/g,"")})]},o.id))]})}function zA({resolution:e,decisions:t,onOpenDecision:s}){const o=oi(),a=t.find(h=>!h.supersededBy)??t[0],c=e.body.startsWith("**Ruled")?"ruled out":"resolution",d=t.length>1?` · ${t.length} in chain`:"";return i.jsxs("div",{className:"resolution edge-note edge-done",children:[i.jsxs("div",{className:"edge-note-head",children:[i.jsx(V,{parts:[{text:Gn(e.author,o),strong:!0},c]}),a&&s&&i.jsxs("button",{className:"link t-meta",onClick:()=>s(a.id),children:[a.id,d," ›"]})]}),i.jsx("p",{children:e.body.replace(/^\*\*[^*]+\*\*\s*/,"")})]})}function BA(e){const{t,state:s,session:o,mine:a,form:c,setForm:d,actions:h,onOpenChat:m}=e;return i.jsxs("div",{className:"actions",children:[o&&i.jsx(P,{variant:o.waitingOn?"urgent":"default",onClick:()=>m(o.id),"data-tip":o.waitingOn?"The agent is waiting for your answer":"Open the conversation with this agent",children:o.waitingOn?"Answer":"Conversation"}),s==="frontier"&&i.jsx(P,{onClick:()=>h.claim(t.id),"data-tip":"Take this ticket yourself, so no agent picks it up",children:"Claim"}),(s==="frontier"||s==="claimed"&&a)&&i.jsx(P,{on:c==="resolve",onClick:()=>d(c==="resolve"?null:"resolve"),"data-tip":"Answer it yourself and close the ticket, with a decision record",children:"Resolve…"}),a&&s==="claimed"&&i.jsx(P,{onClick:()=>h.release(t.id),"data-tip":"Give the ticket back to the queue",children:"Release"}),(s==="frontier"||s==="blocked"||s==="parked")&&i.jsx(P,{variant:"danger",on:c==="rule",onClick:()=>d(c==="rule"?null:"rule"),"data-tip":"Move it out of scope. It's set aside with your reason, not deleted",children:"Rule out…"})]})}function FA(e){return e.replace(/\s*Part of trail \S+\.\s*$/,"").trim()}function UA({t:e,state:t,tickets:s}){const o=new Map(s.map(p=>[p.id,p])),a=p=>{var v;return((v=o.get(p))==null?void 0:v.key)??p},c=e.blockedBy.map(p=>{var v;return`${a(p)}${((v=o.get(p))==null?void 0:v.state)==="closed"?" ✓":""}`}).join(", "),d=s.filter(p=>p.blockedBy.includes(e.id)).map(p=>p.key).join(", "),h=[["Type",nr[e.type]],["Assignee",e.assignee],["Blocked by",c],["Blocks",d],["Reviews",e.reviewOf&&a(e.reviewOf)]],m=or(e)==="hitl";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"d-head",children:[i.jsx("span",{className:"key t-code",children:e.key}),i.jsx(Yn,{tone:"state",className:`st-${t}`,children:hg[t]}),i.jsx("span",{className:"d-att t-meta","data-tip":m?"A person takes this one":"An agent takes this alone",children:m?"Needs a person":"Agent work"})]}),i.jsx("h3",{className:"t-heading",children:e.title}),i.jsx("dl",{className:"facts",children:h.filter(([,p])=>p).flatMap(([p,v])=>[i.jsx("dt",{className:"t-label",children:p},`${p}-k`),i.jsx("dd",{children:v},`${p}-v`)])})]})}function WA(e){const{snap:t,api:s,form:o,setForm:a}=e,{actions:c}=s,[d,h]=y.useState(""),[m,p]=y.useState(""),[v,k]=y.useState(""),[x,S]=y.useState("Not needed to reach the destination."),C=t.tickets.find(W=>W.id===e.id);if(!C)return i.jsx(Ae,{children:"Ticket not found."});const j=Xs(t.tickets,t.map.mode).get(C.id),I=e.sessions.find(W=>W.ticketId===C.id&&cn(W)),b=C.assignee===St,R=C.state==="open"?yu(s.leases,t.map.id).get(C.id):void 0,O=[...C.comments].reverse().find(W=>/^\*\*(Resolution|Ruled out of scope)\*\*/.test(W.body)),U=C.comments.filter(W=>W!==O),X=FA(C.body),Q=s.decisions.filter(W=>W.mapId===t.map.id&&W.ticketId===C.id);return i.jsxs("div",{className:"detail",children:[i.jsx(UA,{t:C,state:j,tickets:t.tickets}),i.jsx($v,{mapId:t.map.id,kind:"ticket",id:C.id}),X&&i.jsxs("section",{className:"d-section ticket-body",children:[i.jsx("span",{className:"t-label",children:"Description"}),i.jsx("p",{className:"body",children:X})]}),i.jsx(J$,{mapId:t.map.id,ticketId:C.id}),i.jsx(gN,{mapId:t.map.id,ticketId:C.id}),i.jsx(o$,{mapId:t.map.id,ticket:C}),i.jsx(wA,{snap:t,t:C}),i.jsx(EN,{snap:t,t:C}),C.closeReason==="not_planned"&&i.jsx(Eu,{label:"Save as dead end",draft:()=>{var W;return{title:`Ruled out: ${C.title}`,body:((W=C.comments.at(-1))==null?void 0:W.body)??C.body,kind:"dead-end",sources:[`trail:${t.map.key}`,`ticket:${C.key}`]}}}),R&&i.jsx(OA,{lease:R,onRelease:()=>c.releaseLease(C.id)}),!R&&i.jsx(T$,{mapId:t.map.id,ticketId:C.id}),i.jsx(LA,{mapId:t.map.id,trail:t.map.verification,ticket:C,state:j}),i.jsx(BA,{t:C,state:j,session:I,mine:b,form:o,setForm:a,actions:c,onOpenChat:e.onOpenChat}),o==="resolve"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:W=>{W.preventDefault(),d.trim()&&(c.resolve(C.id,d.trim(),{rationale:m.trim(),alternatives:v.split(`
|
|
173
|
+
`).map(ie=>ie.trim()).filter(Boolean)}),a(null),h(""),p(""),k(""))},children:[i.jsx(Ze,{label:"Resolution",children:i.jsx("textarea",{rows:3,value:d,onChange:W=>h(W.target.value),autoFocus:!0})}),i.jsx(Ze,{label:"Rationale",children:i.jsx("input",{value:m,onChange:W=>p(W.target.value)})}),i.jsx(Ze,{label:"Alternatives considered",children:i.jsx("textarea",{rows:2,value:v,onChange:W=>k(W.target.value),placeholder:"One per line"})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"primary",disabled:!d.trim(),children:"Resolve"})]})]}),o==="rule"&&i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:W=>{W.preventDefault(),c.ruleOut({ticketId:C.id},x),a(null)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:x,onChange:W=>S(W.target.value),autoFocus:!0})}),i.jsxs("div",{className:"form-actions",children:[i.jsx(P,{variant:"ghost",onClick:()=>a(null),children:"Cancel"}),i.jsx(P,{type:"submit",variant:"danger",children:"Rule out"})]})]}),O&&i.jsx(zA,{resolution:O,decisions:Q,onOpenDecision:e.onOpenDecision}),i.jsx(DA,{comments:U})]})}function HA({snap:e,item:t,api:s}){const o=$p(e.map.mode),[a,c]=y.useState("research"),[d,h]=y.useState(t),[m,p]=y.useState(!1),[v,k]=y.useState([]),[x,S]=y.useState("Not needed to reach the destination.");y.useEffect(()=>h(t),[t]);const C=e.tickets.filter(j=>j.state==="open");return i.jsxs("div",{className:"detail",children:[i.jsx("div",{className:"d-head",children:i.jsx(Yn,{tone:"state",className:"st-unspecified",children:"Not yet specified"})}),i.jsx("h3",{className:"t-heading",children:t}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),s.actions.graduate({unspecified:t,type:a,title:d,blockedBy:v,hitl:m})},children:[i.jsx(Ze,{label:"Title",children:i.jsx("input",{value:d,onChange:j=>h(j.target.value)})}),i.jsxs("div",{className:"chips",children:[o.map(j=>i.jsx("button",{type:"button",className:`chip ${a===j?"on":""}`,onClick:()=>c(j),children:j},j)),Vy.includes(a)&&i.jsx("button",{type:"button",className:`chip ${m?"on":""}`,onClick:()=>p(j=>!j),children:"needs human"})]}),i.jsx("span",{className:"field",children:"Blocked by"}),i.jsx("div",{className:"chips",children:C.map(j=>i.jsx("button",{type:"button",className:`chip ${v.includes(j.id)?"on":""}`,onClick:()=>k(I=>I.includes(j.id)?I.filter(b=>b!==j.id):[...I,j.id]),children:j.key},j.id))}),i.jsx("div",{className:"form-actions",children:i.jsx(P,{type:"submit",variant:"primary",children:"Promote to ticket"})})]}),i.jsxs(un,{as:"form",tone:"inset",className:"inline-form",onSubmit:j=>{j.preventDefault(),s.actions.ruleOut({unspecified:t},x)},children:[i.jsx(Ze,{label:"Reason",children:i.jsx("input",{value:x,onChange:j=>S(j.target.value)})}),i.jsx("div",{className:"form-actions",children:i.jsx(P,{type:"submit",variant:"danger",children:"Rule out"})})]})]})}function KA({api:e,sessions:t,bare:s,onOpenChat:o,onOpenDecision:a}){const{snap:c,selection:d,actions:h}=e,[m,p]=y.useState(null),v=VA(d);y.useEffect(()=>p(null),[v]);let k;return c?d?d.kind==="unspecified"?k=i.jsx(HA,{snap:c,item:d.item,api:e}):k=i.jsx(WA,{snap:c,id:d.id,api:e,sessions:t,form:m,setForm:p,onOpenChat:o??h.openChat,onOpenDecision:a}):k=i.jsx(Qn,{title:"No ticket selected",hint:"Pick a ticket on the map: what it is, who has it, what blocks it, and its decision."}):k=i.jsx(Qn,{title:"No trail yet",hint:"Once there's a trail, pick a ticket on the map to see it here."}),i.jsx(Sg,{area:"inspector",icon:"note",title:"Trail step",info:"The ticket you selected on the map: what it is, who has it, what blocks it, and its decision once it's made.",className:"inspector",bare:s,children:k})}function VA(e){return(e==null?void 0:e.kind)==="ticket"?e.id:(e==null?void 0:e.kind)==="unspecified"?e.item:""}const GA={holding:"Holding",challenged:"Challenged",invalidated:"Invalidated",confirmed:"Confirmed"};function qA(e){if(e.decidedBy)return e.status==="invalidated"?`invalidated by ${e.decidedBy}`:e.status==="confirmed"?`confirmed by ${e.decidedBy==="trail lead"?"you":e.decidedBy}`:`kept by ${e.decidedBy}`}function QA(e){const{a:t,snap:s}=e,o=t.tickets.flatMap(c=>s.tickets.filter(d=>d.id===c)),a=t.challenge&&`${t.challenge.by}: ${t.challenge.evidence}`;return i.jsx(Ce,{as:"li",className:`assumption st-${t.status}`,edge:t.status==="challenged"?"attention":"neutral",title:t.text,titleText:t.text,context:i.jsx(V,{parts:[{text:t.id,code:!0},GA[t.status],qA(t)],children:o.length>0&&i.jsxs("span",{className:"assumption-tickets",children:[i.jsx("span",{className:"sep",children:" · "}),"relied on by",o.map(c=>i.jsx("button",{className:"link t-code",onClick:()=>e.onSelect({kind:"ticket",id:c.id}),children:c.key},c.id))]})}),detail:a,detailText:a,actions:e.onConfirm&&i.jsx(P,{size:"sm",variant:"ghost",disabled:e.busy,onClick:e.onConfirm,children:"Confirm"})})}function YA(e){const[t,s]=y.useState(),[o,a]=y.useState();return{confirm:async(d,h)=>{a(d);const m=await fetch(`${je()}/assumptions/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mapId:e,id:d,text:h})}).catch(()=>{});if(a(void 0),m!=null&&m.ok)return s(void 0);const p=await(m==null?void 0:m.json().catch(()=>({})));s((p==null?void 0:p.error)??"Could not confirm it; is the Lookout connected?")},busy:o,error:t}}function JA({snap:e,onSelect:t}){const{confirm:s,busy:o,error:a}=YA(e.map.id),c=e.map.sections.assumptions??[];return c.length?i.jsxs(i.Fragment,{children:[a&&i.jsx("p",{className:"urgent-text",children:a}),i.jsx("ul",{className:"assumptions row-list",children:c.map(d=>{const h=d.status==="holding"||d.status==="challenged";return i.jsx(QA,{a:d,snap:e,onSelect:t,onConfirm:h?()=>void s(d.id,d.text):void 0,busy:o===d.id},d.id)})})]}):i.jsx(Ae,{children:"None yet. They come from the accepted discovery brief or the trail's start."})}function XA(e){const[,t,s=e]=/^(#\d+)\s+(.+)$/.exec(e)??[],[o=s,...a]=s.split(/\s+[—–]\s+/);return{key:t,title:o,reason:a.join(" — ")||void 0}}function ZA(e){const[t,s]=y.useState([]),o=e==null?void 0:e.map.id,a=(e==null?void 0:e.tickets.reduce((c,d)=>Math.max(c,d.updatedAt),e.map.updatedAt))??0;return y.useEffect(()=>{if(!o)return;let c=!0;return fetch(`${je()}/journal?mapId=${encodeURIComponent(o)}`).then(d=>d.ok?d.json():{entries:[]}).then(d=>c&&s(d.entries)).catch(()=>c&&s([])),()=>{c=!1}},[o,a]),t}function eI({snap:e,activity:t,onTicket:s}){const o=ZA(e),a=t.usageByMap[e.map.id],c=y.useMemo(()=>Up({snap:e,journal:o,answered:t.answered,usage:a}),[e,o,t.answered,a]),d=c.interventions,h=[["Done",`${c.done}`,`${c.done} done · ${c.cancelled} cancelled · ${c.open} open`],["Lead time",ln(c.trailLeadMs),"Trail lead time: from when the trail was charted to its last done ticket"],["Median ticket",ln(c.medianLeadMs),"Median time from a ticket's first claim to done"],["Interventions",`${d.total}`,`${d.answers} agent questions you answered + ${d.operatorActions} lifecycle calls you made (approve, send back, accept, unblock, cancel, release), of which ${d.reworkRequested} sent work back. Answers count while their sessions are on record.`],["Rework",`${c.rework.cycles}`,`Times work went back to rework, on ${c.rework.tickets} tickets`],["Reviews",`${c.reviews.passed}/${c.reviews.failed}`,`${c.reviews.passed} passed, ${c.reviews.failed} failed, ${c.reviews.needsHuman} needed you`],["Cost / ticket",c.spend.perVerifiedTicketUsd===void 0?"—":qs(c.spend.perVerifiedTicketUsd),`Cost per verified ticket: trail spend ${qs(c.spend.costUsd)} ÷ ${c.done} done tickets`]];return i.jsxs("div",{className:"report",children:[i.jsx("ul",{className:"report-stats",children:h.map(([m,p,v])=>i.jsxs("li",{"data-tip":v,children:[i.jsx("span",{className:"mono-label",children:m}),i.jsx("b",{children:p})]},m))}),i.jsxs("div",{className:"report-bar",children:[i.jsx("span",{className:"mono-label",children:"Tickets"}),i.jsx(P,{size:"sm",variant:"ghost","data-tip":"Download this report as markdown",onClick:()=>cg(`${e.map.key.replace("#","trail-")}-report.md`,Ux(c,e.map.title)),children:"Export markdown"})]}),c.tickets.length?i.jsx("ul",{className:"list report-tickets",children:c.tickets.map(m=>i.jsx("li",{className:`out-${m.outcome}`,children:i.jsxs("button",{onClick:()=>s(m.id),"data-tip":`${m.outcome} · rework ${m.reworks} · reviews ${m.reviews.passed}/${m.reviews.failed} · your calls ${m.operatorActions}`,children:[i.jsx("span",{className:"key",children:m.key}),i.jsx("span",{className:"ttl",children:m.title}),i.jsx("span",{className:"lead",children:m.outcome==="done"?ln(m.leadMs):m.outcome})]})},m.id))}):i.jsx(Ae,{children:"No tickets yet"})]})}function tI({tab:e,snap:t,selection:s,onSelect:o,activity:a}){const c=t.map.sections;switch(e){case"report":return a?i.jsx(eI,{snap:t,activity:a,onTicket:d=>o({kind:"ticket",id:d})}):i.jsx(Ae,{children:"No activity yet"});case"assumptions":return i.jsx(JA,{snap:t,onSelect:o});case"decisions":return c.decisions.length?i.jsx("ol",{className:"row-list decisions",children:[...c.decisions].reverse().map((d,h)=>i.jsx(Ce,{as:"li",title:d.text,titleText:d.text,context:d.ticketKey&&i.jsx(V,{parts:[{text:d.ticketKey,code:!0}]}),onOpen:d.ticketId?()=>o({kind:"ticket",id:d.ticketId}):void 0},`${d.ticketKey}-${h}`))}):i.jsx(Ae,{children:"None"});case"unspecified":return c.unspecified.length?i.jsx("ul",{className:"row-list unspecified",children:c.unspecified.map(d=>i.jsx(Ce,{as:"li",title:d,titleText:d,selected:(s==null?void 0:s.kind)==="unspecified"&&s.item===d,onOpen:()=>o({kind:"unspecified",item:d})},d))}):i.jsx(Ae,{children:"None"});case"oos":return c.outOfScope.length?i.jsx("ul",{className:"row-list oos",children:c.outOfScope.map(d=>{const h=XA(d);return i.jsx(Ce,{as:"li",title:h.title,titleText:d,context:i.jsx(V,{parts:[h.key&&{text:h.key,code:!0},h.reason]})},d)})}):i.jsx(Ae,{children:"None"});case"notes":return i.jsx("p",{className:"notes t-body",children:c.notes||"No notes yet."});default:return e}}function nI({snap:e,selection:t,onSelect:s,bare:o,onAudit:a,activity:c}){var k;const[d,h]=y.useState("unspecified"),m=e==null?void 0:e.map.sections,p=[{id:"unspecified",label:"Not yet specified",n:m==null?void 0:m.unspecified.length},{id:"assumptions",label:"Assumptions",n:(k=m==null?void 0:m.assumptions)==null?void 0:k.length},{id:"decisions",label:"Decisions",n:m==null?void 0:m.decisions.length},{id:"oos",label:"Out of scope",n:m==null?void 0:m.outOfScope.length},{id:"notes",label:"Notes"},{id:"report",label:"Report"}],v=e?i.jsx(tI,{tab:d,snap:e,selection:t,onSelect:s,activity:c}):i.jsx(Qn,{title:"No plan yet",hint:"Open questions, decisions, what's ruled out, notes and the trail report collect here."});return i.jsxs(ze,{className:`zone sections ${o?"bare":""}`,style:o?void 0:{gridArea:"plan"},children:[!o&&i.jsx(Et,{className:"zone-title",icon:"flag",title:"Trail plan",info:"The parts of the plan that aren't tickets yet: open questions still to specify, the assumptions the plan relies on, decisions already made, what's ruled out, and notes. Report shows how the trail is going: lead times, your interventions, rework, reviews and cost per verified ticket."}),i.jsxs("div",{className:"sections-tabs",children:[i.jsx(dt,{compact:!0,"aria-label":"Plan section",value:d,onChange:h,options:p.map(x=>({value:x.id,label:x.n===void 0?x.label:`${x.label} · ${x.n}`}))}),d==="decisions"&&a&&i.jsx("button",{className:"link",onClick:a,children:"Audit ›"})]}),i.jsx("div",{className:"zone-b",children:v})]})}function sI(){var le;const e=y.useMemo(()=>HS(WS()),[]),t=sN(e),{snap:s,activity:o,selection:a,actions:c}=t,[d,h]=iN();y.useEffect(()=>wg(d.theme),[d.theme]);const m=e2(),[p,v]=y.useState(!1),k=s2(e.kind),x=XS(),S=o.pending.length,C=i2(o,t.mapId);n2(S,s==null?void 0:s.map.title);const j=t2(t,x),I=O2(s,c.selectMap),b=PN(I.briefText),R=z2({api:t,nav:j,knowledge:b,reviewBrief:I.review,openReroute:ee=>I.openReroute(ee.mapId,ee.ref),openGuides:()=>m.open("guides"),openConnector:ee=>m.open(ee),openApprovals:()=>m.open("approvals"),openFocusSettings:()=>m.open("attention")}),O=eN(e,t,d.briefing,(le=R.attention.view)==null?void 0:le.items),U=i.jsx(sb,{api:t,nav:j,bp:x,scoped:C,attn:R,above:I.inboxCard}),X=i.jsx(YE,{api:t,sessions:C.sessions,onSelect:j.select,onNewTrail:()=>v(!0),compact:x==="mobile",minFit:x==="mobile"?.7:0,trail:I}),Q=ee=>i.jsx(KA,{api:t,sessions:C.sessions,bare:ee,onOpenChat:K=>j.openChat(K),onOpenDecision:j.openDecisions}),W={activity:C,snap:s,leases:t.leases,onTicket:ee=>j.select({kind:"ticket",id:ee}),onOpenChat:ee=>j.openChat(ee)},ie=ee=>i.jsx(nI,{snap:s,selection:a,onSelect:j.select,bare:ee,onAudit:()=>j.openDecisions(),activity:C}),{projects:G,overview:ve,openOverview:Pe}=eA(x,j,R.link.request),$e=m.route&&i.jsx(ZT,{rt:e,api:t,bp:x,prefs:d,update:h,settings:m}),oe=(j.statsOpen||j.decisionsView)&&i.jsx(Z2,{api:t,bp:x,nav:j}),D=$e||ve||oe,J=O.shown&&i.jsx(mN,{brief:O,snaps:t.allSnaps,bp:x,openTicket:j.openTicket,openChat:j.openChat,openDecisions:j.openDecisions,closeDecisions:()=>j.setDecisionsView(null),showPhoneHome:()=>j.setPhoneTab("home")});return i.jsx(bg.Provider,{value:b,children:i.jsxs("div",{className:`app bp-${x}`,children:[i.jsx(o1,{api:t,rt:e,repo:i.jsx(W$,{repo:k,projects:G,onOverview:Pe}),brief:O,attention:R.header,decisionsOpen:!!j.decisionsView,onDecisions:()=>{m.close(),j.decisionsView?j.setDecisionsView(null):j.openDecisions()},onStats:()=>{m.close(),j.toggleStats()},onNewTrail:()=>v(!0),onSettings:m.toggle,onSlack:()=>m.open("slack"),onToggleTheme:ee=>h({theme:ee?"night":"day"})}),x==="wide"&&i.jsxs(i.Fragment,{children:[U,X,Q(!1),i.jsx(hA,{...W}),i.jsx(dA,{...W}),ie(!1),D]}),x==="laptop"&&i.jsxs(i.Fragment,{children:[U,X,i.jsx(eE,{tab:j.sideTab,onTab:j.setSideTab,unspecified:s==null?void 0:s.map.sections.unspecified.length,ticket:Q(!0),activity:i.jsx(hp,{...W}),plan:ie(!0)}),D]}),x==="mobile"&&i.jsxs(i.Fragment,{children:[i.jsx(ZE,{tab:j.phoneTab,decisions:D,inbox:U,projects:G.many&&i.jsx(K$,{projects:G,onOverview:Pe}),map:X,ticket:Q(!0),activity:i.jsx(hp,{...W}),plan:ie(!0)}),i.jsx(XE,{tab:j.phoneTab,covered:!!D,pending:S,onPick:ee=>{m.close(),j.setPhoneTab(ee),j.setDecisionsView(null)}})]}),J,I.dialog,t.error&&i.jsx("div",{className:"error-toast",children:t.error}),p&&i.jsx(ub,{rt:e,onClose:()=>v(!1),onCreated:ee=>c.selectMap(ee)}),!d.onboarded&&i.jsx(tC,{prefs:d,update:h,activeTracker:e.kind}),i.jsx(RN,{})]})})}const iI="X-Teamtrail-Session";function rI(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}function oI(e){const t=new URL(rI(e),location.href),s=te.apiPrefix;return t.origin===location.origin&&(t.pathname===s||t.pathname.startsWith(`${s}/`))}function aI(){const e=window.fetch.bind(window);window.fetch=(t,s)=>{const o=bS()?xu():void 0;if(!o||!oI(t))return e(t,s);const a=new Headers((s==null?void 0:s.headers)??(t instanceof Request?t.headers:void 0));return a.set(iI,o.secret),e(t,{...s,headers:a})}}wg(bu().theme);aI();By.createRoot(document.getElementById("root")).render(i.jsxs(UT,{children:[i.jsx(sI,{}),i.jsx(cN,{})]}));
|