taskchef 8.4.1 → 8.4.2

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskchef",
3
- "version": "8.4.1",
3
+ "version": "8.4.2",
4
4
  "description": "Dispatch work from a data-only workspace to visible Codex project tasks.",
5
5
  "author": {
6
6
  "name": "Favo Yang",
package/README.md CHANGED
@@ -17,6 +17,7 @@ request -> recorded TaskChef task -> Codex executor -> request/result turn timel
17
17
  | Install, configure, dispatch, inspect, and recover | This README |
18
18
  | Follow the normative agent contract and MCP interfaces | [Specification](docs/spec.md) |
19
19
  | Understand dashboard start, upgrade, and shutdown | [Dashboard lifecycle](docs/dashboard-lifecycle.md) |
20
+ | Build or change dashboard pages consistently | [Dashboard UI baseline](docs/dashboard-ui.md) |
20
21
  | Understand implementation flows and trust boundaries | [Workflows](docs/workflows.md) |
21
22
  | Compare TaskChef with FirstMate | [FirstMate comparison research](docs/firstmate-taskchef-comparison.md) |
22
23
  | Review deferred ideas | [Backlog](BACKLOG.md) |
@@ -0,0 +1,25 @@
1
+ # Dashboard UI baseline
2
+
3
+ Board and List are the visual baseline for dashboard pages. New pages should
4
+ inherit the Mantine theme in `src/dashboard/react/App.tsx` and the shared CSS
5
+ properties in `src/dashboard/react/styles.css` before adding page-specific
6
+ rules.
7
+
8
+ - Use `--taskchef-page-max-width`, `--taskchef-page-gutter`, and the
9
+ `.taskchef-main` shell for the outer page. Use `.taskchef-content` for
10
+ readable single-column content; Board may use the full shell width for its
11
+ horizontal lanes.
12
+ - Use Mantine `h5`, `sm`, and `xs` sizes for section headings, body text, and
13
+ supporting text. Reserve larger headings for views that establish a distinct
14
+ document hierarchy.
15
+ - Selects inherit the compact `xs` dashboard size from the shared Mantine
16
+ theme. New pages get the same 30 px control height and 12 px control text
17
+ without page-specific selectors. Keep short, related selects in one compact
18
+ row when they remain readable at narrow widths; give the field with longer
19
+ values the larger share of the row.
20
+ - Use `.taskchef-section`, `p="sm"`, and `gap="sm"` for bordered page sections.
21
+ Keep intentional Board and List differences, such as lane width and card
22
+ excerpts, in their existing component classes.
23
+
24
+ Check a dashboard page at desktop and narrow widths. Confirm keyboard focus,
25
+ control operation, reachable overflow, and a clean browser console.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskchef",
3
- "version": "8.4.1",
3
+ "version": "8.4.2",
4
4
  "description": "A non-blocking interactive dispatcher for visible Codex tasks.",
5
5
  "license": "MIT",
6
6
  "author": "Favo Yang",
@@ -26,6 +26,7 @@
26
26
  "docs/spec.md",
27
27
  "docs/workflows.md",
28
28
  "docs/dashboard-lifecycle.md",
29
+ "docs/dashboard-ui.md",
29
30
  "docs/firstmate-taskchef-comparison.md",
30
31
  "docs/images/dashboard-identity.jpg",
31
32
  "docs/images/ccusage-token-consumption.png",
@@ -190,5 +190,5 @@ ${f?`${d("light")}{${f}}`:""}`}function Xs({theme:n,color:l,colorScheme:r,name:o
190
190
  *
191
191
  * This source code is licensed under the MIT license.
192
192
  * See the LICENSE file in the root directory of this source tree.
193
- */const HN=[["path",{d:"M7 3.34a10 10 0 1 1 -4.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 4.995 -8.336z",key:"svg-0"}]],UN=Nt("filled","circle-filled","CircleFilled",HN);function VN({onConnection:n,onError:l,onSnapshot:r}){const o=new EventSource("/api/events");return o.addEventListener("open",()=>n(!0)),o.addEventListener("error",()=>n(!1)),o.addEventListener("snapshot",s=>{n(!0),r(JSON.parse(s.data))}),o.addEventListener("dashboard-error",s=>{const c=JSON.parse(s.data);l(c.message??"The task log is temporarily unavailable.")}),o}async function ji(n,l){const r=await fetch(n,l),o=await r.json().catch(()=>({}));if(!r.ok)throw Object.assign(new Error(o.message??"Request failed."),{payload:o});return o}async function YN(){return(await ji("/api/health")).taskchefVersion}async function qN(n,l,r){return ji(`/api/settings/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({schemaVersion:1,model:l,effort:r})})}async function GN(n){return(await ji(`/api/tasks/${encodeURIComponent(n)}`)).task}async function XN(n){return(await ji(`/api/tasks/${encodeURIComponent(n)}/open-codex`,{method:"POST"})).message??null}async function IN(n,l,r){const o=new AbortController,s=window.setTimeout(()=>o.abort(),1e4);try{return{ok:!0,task:(await ji(`/api/tasks/${encodeURIComponent(n.id)}/manual-transition`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({schemaVersion:1,actionId:r,expected:{status:n.status,turnRef:n.turnRef,threadId:n.threadId,updatedAt:n.updatedAt},targetStatus:l}),signal:o.signal})).task}}catch(c){const f=c.payload;return{ok:!1,code:(f==null?void 0:f.code)??(o.signal.aborted?"request_timeout":"network_error"),message:(f==null?void 0:f.message)??(o.signal.aborted?"Task state change timed out. Try again.":"Task state changes are temporarily unavailable. Try again."),task:(f==null?void 0:f.task)??null}}finally{window.clearTimeout(s)}}const ZN={low:"Light",medium:"Medium",high:"High",xhigh:"Extra High",ultra:"Ultra"};function QN(){const[n,l]=x.useState([]),[r,o]=x.useState(null),[s,c]=x.useState(null),[f,d]=x.useState(!0),[p,h]=x.useState(null),[b,y]=x.useState(null),[g,w]=x.useState(0);x.useEffect(()=>{const C=new AbortController;return d(!0),c(null),fetch("/api/settings",{signal:C.signal}).then(async A=>{if(!A.ok)throw new Error("Settings preview could not be loaded.");const _=await A.json();l(_.profiles),o(_.usageProvider??null)}).catch(A=>{C.signal.aborted||c(A.message)}).finally(()=>{C.signal.aborted||d(!1)}),()=>C.abort()},[g]),x.useEffect(()=>{if(y(null),!p)return;const C=window.setTimeout(()=>y(p),400);return()=>window.clearTimeout(C)},[p]);const R=n.find(C=>C.id==="personal"),T=async(C,A,_)=>{h(C.role),c(null),l(N=>N.map(j=>j.id!=="personal"?j:{...j,roles:j.roles.map($=>$.role===C.role?{...$,model:A,effort:_}:$)}));try{const N=await qN(C.role,A,_);l([N.profile])}catch(N){l(j=>j.map($=>$.id!=="personal"?$:{...$,roles:$.roles.map(L=>L.role===C.role?C:L)})),c(N instanceof Error?N.message:"Model role could not be saved.")}finally{h(null)}};return v.jsxs(Vt,{gap:"md","aria-label":"Model settings",children:[v.jsxs(yt,{justify:"space-between",children:[v.jsx(Ut,{order:2,size:"h3",children:"Model roles"}),v.jsx(pl,{"aria-label":"Refresh","aria-busy":f,"aria-disabled":f||p!==null,className:"taskchef-icon-button",color:"gray",variant:"subtle",size:"lg",onClick:()=>{f||p||(d(!0),w(C=>C+1))},children:v.jsx(ON,{className:f?"taskchef-refresh-spinning":void 0,size:18,stroke:1.8})})]}),v.jsx(Ee,{c:"dimmed",size:"sm",children:"Your models for orchestration, planning, implementation, and review."}),s&&v.jsx(Dn,{color:"red",role:"alert",children:s}),R&&v.jsxs(v.Fragment,{children:[R.problems.map(C=>v.jsx(Dn,{color:"yellow",children:C},C)),R.roles.map(C=>{var A,_;return v.jsx(ln,{withBorder:!0,p:"md",children:v.jsxs(Vt,{gap:"xs",children:[v.jsxs(yt,{justify:"space-between",children:[v.jsx(Ut,{order:3,size:"h4",tt:"capitalize",children:C.role}),v.jsx(Ai,{color:["invalid","unavailable"].includes(C.status)?"red":C.status==="missing"?"gray":"teal",children:C.status})]}),v.jsxs(Bp,{cols:{base:1,sm:2},children:[v.jsx(Jo,{label:"Model","aria-label":`${C.role} model`,"aria-busy":f||p!==null,data:R.modelOptions??[],value:typeof C.model=="string"?C.model:null,readOnly:f||p!==null,allowDeselect:!1,searchable:!0,onChange:N=>{var L;if(f||p||!N)return;const j=(L=R.modelOptions)==null?void 0:L.find(D=>D.value===N),$=typeof C.effort=="string"&&(j!=null&&j.efforts.includes(C.effort))?C.effort:j==null?void 0:j.efforts.find(D=>D!=="max");$&&T(C,N,$)}}),v.jsx(Jo,{label:"Reasoning effort","aria-label":`${C.role} reasoning effort`,"aria-busy":f||p!==null,data:[...(((_=(A=R.modelOptions)==null?void 0:A.find(N=>N.value===C.model))==null?void 0:_.efforts)??[]).filter(N=>N!=="max").map(N=>({value:N,label:ZN[N]??N})),...C.effort==="max"?[{value:"max",label:"Max (current setting)",disabled:!0}]:[]],value:typeof C.effort=="string"?C.effort:null,disabled:typeof C.model!="string",readOnly:f||p!==null,allowDeselect:!1,onChange:N=>{!f&&!p&&N&&N!=="max"&&typeof C.model=="string"&&T(C,C.model,N)}})]}),v.jsxs(Ee,{size:"sm",style:{overflowWrap:"anywhere"},children:["Source: ",C.displaySource??C.source??"No role file"]}),b===C.role&&v.jsx(Ee,{c:"dimmed",size:"sm",role:"status",children:"Saving…"}),C.problems.map(N=>v.jsx(Dn,{color:"red",children:N},N))]})},C.role)})]}),r&&v.jsx(ln,{withBorder:!0,p:"md",children:v.jsxs(Vt,{gap:"xs",children:[v.jsx(Ut,{order:3,size:"h4",children:"Usage provider"}),v.jsxs(Ee,{children:[r.provider,r.version?` ${r.version}`:" version unavailable"]}),v.jsx(Ee,{c:"dimmed",size:"sm",children:"Version pinned by TaskChef for token and cost estimates."})]})})]})}const KN=50,FN="Turn interrupted before a terminal report.",FS=[{value:"",label:"All"},{value:"working",label:"Working"},{value:"needs input",label:"Needs input"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}],PN=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,JN=new Map([["created","Task created"],["task_started","Task started"],["follow_up_started","Follow-up started"],["completed","Task completed"],["needs_input","Task needs input"],["failed","Task failed"],["manual_completed","Task manually completed"],["manual_failed","Task manually failed"],["archive_succeeded","Chat archived"],["archive_failed","Chat archive failed"],["unresolved","Task updated"]]),WN=new Map([["24h",1440*60*1e3],["7d",10080*60*1e3],["all",null]]);function e_(n){return Date.parse(n.meaningfulUpdatedAt??n.updatedAt??n.createdAt)}function PS(n){return n.status===null?"unresolved":n.status.replaceAll("_"," ")}function t_(n){return typeof n.threadId=="string"&&PN.test(n.threadId)}function n_(n){return{status:n.status,turnRef:n.turnRef,threadId:n.threadId,updatedAt:n.updatedAt}}function l_(n,l){return!!l&&n.status===l.status&&n.turnRef===l.turnRef&&n.threadId===l.threadId&&n.updatedAt===l.updatedAt}function kb({requestTask:n,expected:l,responseTask:r,selectedTask:o}){const s=(o==null?void 0:o.id)===n.id?o:n;return l_(s,l)?r??s:s}function JS(n){var s;const l=n.latestTurn??null,r=(l==null?void 0:l.result)??null,o=(l==null?void 0:l.requestSummary)??(l?"Request not recorded by this TaskChef version.":n.title);return{turnRef:(l==null?void 0:l.turnRef)??(l==null?void 0:l.turnId)??n.turnRef??n.turnId??null,turnId:(l==null?void 0:l.turnId)??n.turnId??null,startedAt:(l==null?void 0:l.startedAt)??n.updatedAt??n.createdAt??null,requestSummary:o,resultStatus:(r==null?void 0:r.status)??(n.status==="working"?"working":n.status),resultSummary:(r==null?void 0:r.summary)??(n.status==="working"?"In progress":((s=n.lastResult)==null?void 0:s.summary)??n.summary??"No result reported."),resultUpdatedAt:(r==null?void 0:r.updatedAt)??null}}function a_(n){var r;const l=n.result??null;return{status:(l==null?void 0:l.status)??"working",summary:(l==null?void 0:l.summary)??"In progress",updatedAt:(l==null?void 0:l.updatedAt)??n.startedAt,...((r=n.provenance)==null?void 0:r.kind)==="dashboard_manual"?{sourceLabel:"Manual dashboard change"}:{}}}function o_(n,l=[]){if(Array.isArray(n.turns))return n.turns;if(!n.latestTurn)return l;const r=[...l],o=r.length-1,s=n.latestTurn.turnRef??n.latestTurn.turnId,c=o>=0?r[o].turnRef??r[o].turnId:null,f=o>=0&&c===null&&s!==null&&r[o].turnId==null&&n.latestTurn.turnId==null&&JSON.stringify({...r[o],turnRef:null})===JSON.stringify({...n.latestTurn,turnRef:null});return o>=0&&(c===s||f)?r[o]=n.latestTurn:(n.schemaVersion>=8&&o>=0&&r[o].result===null&&(r[o]={...r[o],result:{status:"interrupted",summary:FN,updatedAt:n.latestTurn.startedAt}}),r.push(n.latestTurn)),r}function lu(n){return JN.get(n.event)??"Task updated"}function r_(n,l,r=Date.now()){const o=WN.get(l);if(o===null)return!0;if(o===void 0)return!1;const s=e_(n);return Number.isFinite(s)&&s>=r-o}function gm(n,{project:l="",status:r="",date:o="all",now:s=Date.now()}={}){return n.filter(c=>(!l||c.project.name===l)&&(!r||PS(c)===r)&&r_(c,o,s))}function i_(n,{project:l="",date:r="all",now:o=Date.now()}={}){const s=gm(n,{project:l,date:r,now:o});return Object.fromEntries(FS.map(({value:c})=>[c,c?s.filter(f=>PS(f)===c).length:s.length]))}function s_(n){return JSON.stringify([n.id,n.turnRef??n.turnId??null,n.turnId??null,n.status??"unresolved"])}function c_(n,l){try{const r=JSON.parse(n),o=JSON.parse(l);return Array.isArray(r)&&Array.isArray(o)&&r.length===o.length&&r[1]===null&&o[1]!==null&&r[2]===null&&o[2]===null&&r[3]!=="working"&&r.every((s,c)=>c===1||s===o[c])}catch{return!1}}function u_(n){var l,r;return n.status==="working"?n.lastResult?"follow_up_started":"task_started":((r=(l=n.latestTurn)==null?void 0:l.provenance)==null?void 0:r.kind)==="dashboard_manual"?`manual_${n.status}`:n.status??"unresolved"}function WS(n,l){return JSON.stringify(l==="created"?[n.id,null,l,n.createdAt??null]:[n.id,n.turnRef??n.turnId??null,l])}function f_(n,l){var r,o,s;return l==="created"?n.createdAt??n.updatedAt??null:((r=n.lastResult)==null?void 0:r.status)===n.status&&(((o=n.lastResult)==null?void 0:o.turnRef)??((s=n.lastResult)==null?void 0:s.turnId))===(n.turnRef??n.turnId)?n.lastResult.updatedAt:n.updatedAt??n.createdAt??null}function d_(n,l){var r,o,s;return["completed","needs_input","failed","manual_completed","manual_failed"].includes(l)?((r=n.lastResult)==null?void 0:r.status)===n.status&&(((o=n.lastResult)==null?void 0:o.turnRef)??((s=n.lastResult)==null?void 0:s.turnId))===(n.turnRef??n.turnId)?n.lastResult.summary:n.summary??null:null}function Yo(n,l=u_(n)){const r=l==="created";return Object.freeze({id:WS(n,l),taskId:n.id,title:n.title,status:r?"working":n.status,event:l,turnRef:r?null:n.turnRef??n.turnId??null,turnId:r?null:n.turnId??null,timestamp:f_(n,l),summary:d_(n,l)})}function Js(n){var o;const l=n.lastResult;if(!l)return null;const r=((o=l.provenance)==null?void 0:o.kind)==="dashboard_manual"?`manual_${l.status}`:l.status;return Object.freeze({id:WS({...n,turnRef:l.turnRef??l.turnId,turnId:l.turnId},r),taskId:n.id,title:n.title,status:l.status,event:r,turnRef:l.turnRef??l.turnId??null,turnId:l.turnId??null,timestamp:l.updatedAt,summary:l.summary})}function m_(n,l){return`${l?"Open current task details":"Show task availability"} for ${n.title}: ${lu(n)}`}function p_(n){return`Dismiss ${lu(n)} notification for ${n.title}`}function Bb(n,l){return n.filter(({id:r})=>r!==l)}function h_({initialized:n,notifications:l,seenIds:r=new Set,signatures:o},s){const c=new Map(o);for(const p of s)c.set(p.id,s_(p));const f=new Set(r);if(!n){for(const p of s){f.add(Yo(p,"created").id);const h=Js(p);h&&f.add(h.id),f.add(Yo(p).id)}return{additions:[],notifications:l,seenIds:f,signatures:c}}const d=[];for(const p of s){const h=[];if(o.has(p.id)){if(o.get(p.id)!==c.get(p.id)&&!c_(o.get(p.id),c.get(p.id))){h.push(Yo(p));const y=Js(p);y&&h.push(y)}}else{const y=Js(p);(p.turnRef||p.turnId||p.status!=="working"||y)&&(h.push(Yo(p)),y&&h.push(y)),h.push(Yo(p,"created"))}for(const y of h)f.has(y.id)||d.push(y),f.add(y.id);const b=Js(p);b&&f.add(b.id),f.add(Yo(p).id)}return{additions:d,notifications:[...d,...l].slice(0,KN),seenIds:f,signatures:c}}function g_(n,l,r){const o=n.notifications.filter(({id:s})=>s!==l.id);return r?{...n,detailTaskId:l.taskId,detailOpened:!0,highlightTurnRef:l.turnRef??l.turnId,notifications:o,refreshGeneration:n.refreshGeneration+1}:{...n,notifications:o}}function Hb(n){return{...n,notifications:[]}}function Ub(n,l){const r=Array.isArray(n.turns)&&Array.isArray(n.results),o=!Array.isArray(l.turns)&&!Array.isArray(l.results);return{...n,...l,...r&&o?{results:n.results,turns:n.turns,usage:n.usage}:{}}}function Ws(n){var l,r,o,s,c,f,d;return JSON.stringify([((l=n==null?void 0:n.usage)==null?void 0:l.generationTurnRef)??null,((r=n==null?void 0:n.usage)==null?void 0:r.status)??null,((o=n==null?void 0:n.usage)==null?void 0:o.updatedAt)??null,((c=(s=n==null?void 0:n.usage)==null?void 0:s.task)==null?void 0:c.totalTokens)??null,((d=(f=n==null?void 0:n.usage)==null?void 0:f.task)==null?void 0:d.estimatedCostUsd)??null])}const v_=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?(Z|[+-]\d{2}:\d{2})$/;function ex(n,l){const r=Vb(n),o=Vb(l);if(r===null||o===null)return null;const s=o-r;return s>=0?s:null}function tx(n){var r;const l=ex(n.startedAt,(r=n.result)==null?void 0:r.updatedAt);return l===0?null:l}function y_(n){const l=n.filter(s=>s.result!==null),r=l.map(tx).filter(s=>s!==null),o=r.length===0?l.length===0?0:null:r.reduce((s,c)=>s+c,0);return Object.freeze({terminalTurns:l.length,validTurns:r.length,totalMilliseconds:o===null||Number.isSafeInteger(o)?o:null})}function Vb(n){if(typeof n!="string")return null;const l=n.match(v_);if(!l)return null;const[,r,o,s,c,f,d,,p]=l,h=Number(r),b=Number(o),y=Number(s),g=Number(c),w=Number(f),R=Number(d),T=p==="Z"?0:Number(p.slice(1,3)),C=p==="Z"?0:Number(p.slice(4,6)),_=[31,h%4===0&&(h%100!==0||h%400===0)?29:28,31,30,31,30,31,31,30,31,30,31];if(b<1||b>12||y<1||y>_[b-1]||g>23||w>59||R>59||T>23||C>59)return null;const N=Date.parse(n);return Number.isFinite(N)?N:null}const vm=1e3,ym=60*vm,bm=60*ym,b_=24*bm,xn="n/a";function nx(n){if(!Number.isFinite(n)||n<0)return null;if(n>0&&n<vm)return"<1s";const l=Math.floor(n/vm);if(n<ym)return`${l}s`;if(n<bm)return`${Math.floor(l/60)}m ${l%60}s`;const r=Math.floor(n/ym);if(n<b_)return`${Math.floor(r/60)}h ${r%60}m`;const o=Math.floor(n/bm);return`${Math.floor(o/24)}d ${o%24}h`}function lx(n){const l=n.turns===void 0?n.reportedWork:y_(n.turns??[]);if(l===void 0)return{accessibleLabel:"Reported work unavailable because terminal turn history is not available.",kind:"unavailable",title:"Reported wall-clock elapsed time requires the terminal turn history from the task detail projection.",value:xn};if(l.terminalTurns===0)return{accessibleLabel:"Reported work not yet reported. Unfinished turns are excluded.",kind:"not-reported",title:"Reported wall-clock elapsed time is added only after a turn reaches a terminal state.",value:xn};if(l.validTurns===0)return{accessibleLabel:"Reported work unavailable because completed turn timestamps are missing or invalid.",kind:"unavailable",title:"Reported wall-clock elapsed time is unavailable because no terminal turn has a valid start and end timestamp.",value:xn};const r=l.totalMilliseconds===null?null:nx(l.totalMilliseconds);if(r===null)return{accessibleLabel:"Reported work unavailable because the duration total is outside the supported range.",kind:"unavailable",title:"Reported wall-clock elapsed time is unavailable because the duration total is outside the supported range.",value:xn};const o=l.terminalTurns-l.validTurns,s=o>0?` ${o} terminal ${o===1?"turn was":"turns were"} unavailable and excluded.`:"";return{accessibleLabel:`Reported work ${r}. This is reported wall-clock elapsed time.${s}`,kind:"available",title:`Sum of valid terminal-turn wall-clock elapsed times; unfinished turns and idle gaps are excluded.${s}`,value:r}}function S_(n,l=Date.now()){const r=n.result===null,o=r?ex(n.startedAt,new Date(l).toISOString()):tx(n),s=r?"Elapsed so far":"Elapsed",c=o===null?xn:nx(o)??xn;return{accessibleLabel:`${s} ${o===null?"unavailable":c}. ${r?"Current":"Completed"} turn reported wall-clock elapsed time.`,kind:o===null?"unavailable":"available",label:s,title:o===null?"Reported wall-clock elapsed time is unavailable because the turn timestamps are missing, invalid, or reversed.":`Reported wall-clock elapsed time from startedAt ${r?"to the current time":"to result.updatedAt"}.`,value:c}}function au(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2,notation:"compact"}).format(n)}function pi(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2}).format(n)}function Wo(n,l){return typeof n!="number"||!Number.isFinite(n)?"—":new Intl.NumberFormat(l,{currency:"USD",currencyDisplay:"narrowSymbol",maximumFractionDigits:2,minimumFractionDigits:2,style:"currency"}).format(n)}function ax(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2,minimumFractionDigits:2}).format(n)}function ox(n){var s;const l=n.usage,r=n.turnRef??((s=n.latestTurn)==null?void 0:s.turnRef)??null,o=(l==null?void 0:l.generationTurnRef)!=null&&r!=null&&l.generationTurnRef!==r;return n.status==="working"?l!=null&&l.task?Kd(l.task,!0):{kind:"pending",label:"Token usage pending"}:(l==null?void 0:l.status)==="calculating"||o?l.task?Kd(l.task,!0):{kind:"calculating",label:"Calculating token usage"}:(l==null?void 0:l.status)==="available"&&l.task?Kd(l.task,!1):!l&&n.threadId&&["completed","failed","needs_input"].includes(n.status??"")?{kind:"calculating",label:"Calculating token usage"}:{kind:"unavailable",label:(l==null?void 0:l.reason)??"Token usage unavailable"}}function Kd(n,l){const r=au(n.totalTokens),o=n.estimatedCostUsd==null?"Estimated cost n/a":`Estimated cost ${Wo(n.estimatedCostUsd)}`;return{kind:"ready",knownSoFar:l,label:`${r} tokens · ${o}${l?" · known so far":""}`,usage:n}}function x_(n,l){var s,c;if(l.result===null)return{kind:"pending",label:"Turn usage pending"};const r=l.turnRef??l.turnId,o=r?(c=(s=n.usage)==null?void 0:s.turns)==null?void 0:c[r]:null;if((o==null?void 0:o.status)==="calculating")return{kind:"calculating",label:"Calculating turn usage"};if((o==null?void 0:o.status)==="available"&&typeof o.totalTokens=="number"){const f=pi(o.totalTokens),d=o.estimatedCostUsd==null?"Estimated cost n/a":`Estimated cost ${Wo(o.estimatedCostUsd)}`;return{kind:"ready",label:`${f} tokens · ${d}`}}return{kind:"unavailable",label:(o==null?void 0:o.reason)??"Turn usage unavailable"}}function w_(n,l){var c,f;const r=x_(n,l);if(r.kind==="ready"){const d=l.turnRef??l.turnId,p=d?(f=(c=n.usage)==null?void 0:c.turns)==null?void 0:f[d]:null,h=typeof(p==null?void 0:p.totalTokens)=="number"?pi(p.totalTokens):xn,b=typeof(p==null?void 0:p.totalTokens)=="number"?au(p.totalTokens):xn,y=p==null?void 0:p.estimatedCostUsd,g=typeof y=="number"&&Number.isFinite(y),w=g?ax(y):xn;return{animated:!1,cost:{accessibleLabel:`Estimated cost ${g?Wo(y).toLowerCase():"unavailable"}`,value:w},kind:r.kind,note:null,title:r.label,tokens:{accessibleLabel:`${h} tokens`,value:b}}}const o=r.kind==="pending"?"Pending":r.kind==="calculating"?"Calculating":xn,s=r.kind==="unavailable"?"unavailable":o.toLowerCase();return{animated:r.kind==="pending"||r.kind==="calculating",cost:{accessibleLabel:`Estimated cost ${s}${r.kind==="unavailable"?`: ${r.label}`:""}`,value:o},kind:r.kind,note:r.kind==="unavailable"&&r.label!=="Turn usage unavailable"?r.label:null,title:r.label,tokens:{accessibleLabel:`Tokens ${s}${r.kind==="unavailable"?`: ${r.label}`:""}`,value:o}}}function C_(n){var l,r;return n.status!=="working"&&(((l=n.usage)==null?void 0:l.status)==="calculating"||Object.values(((r=n.usage)==null?void 0:r.turns)??{}).some(o=>o.status==="calculating"))}function T_(n){var R;const l=ox(n);if(l.kind==="pending"||l.kind==="calculating"){const T=l.kind==="pending"?"Pending":"Calculating";return{cost:{accessibleLabel:`Estimated cost ${T.toLowerCase()}`,animated:!0,title:l.label,value:T},kind:l.kind,tokens:{accessibleLabel:`Tokens ${T.toLowerCase()}`,animated:!0,title:l.label,value:T}}}if(l.kind==="unavailable"){const T=l.label==="Token usage unavailable"?"":`: ${l.label}`;return{cost:{accessibleLabel:`Estimated cost unavailable${T}`,animated:!1,title:l.label,value:xn},kind:"unavailable",tokens:{accessibleLabel:`Token usage unavailable${T}`,animated:!1,title:l.label,value:`${xn} tokens`}}}const r=au(l.usage.totalTokens),o=pi(l.usage.totalTokens),s=l.usage.estimatedCostUsd,c=typeof s=="number"&&Number.isFinite(s),f=c?Wo(s):null,d=c?ax(s):null,p=l.knownSoFar?" · Updating…":"",h=l.knownSoFar?"; updating":"",b=c?p:"",y=c?h:"",g=l.usage.sourceUpdatedAt??l.usage.sampledAt??((R=n.usage)==null?void 0:R.updatedAt)??null,w=g&&!Number.isNaN(Date.parse(g))?` Cached usage updated ${new Date(g).toLocaleString()}.`:"";return{cost:{accessibleLabel:`Estimated cost ${f??"unavailable"}${y}.${w}`,animated:l.knownSoFar&&c,title:`${f===null?"Estimated cost unavailable":`Unrounded estimate: $${l.usage.estimatedCostUsd}`}${b}.${w}`,value:d??xn},kind:"ready",tokens:{accessibleLabel:`${o} tokens${h}.${w}`,animated:l.knownSoFar,title:`${o} tokens${p}.${w}`,value:`${r} tokens`}}}function R_(n){return n==="completed"?"teal":n==="needs_input"?"yellow":n==="failed"?"red":n==="working"?"blue":"gray"}function E_(n){return n===null?"Unresolved":n.replaceAll("_"," ")}const Fd=30,ai=6e4,pc=60*ai,Ga=24*pc;function rx(n){if(typeof n!="string"||n.trim()==="")return null;const l=Date.parse(n);return Number.isFinite(l)?{date:new Date(l),iso:new Date(l).toISOString(),milliseconds:l}:null}function Sm(n,{locale:l,timeZone:r}={}){const o=rx(n);return o?new Intl.DateTimeFormat(l,{dateStyle:"medium",timeStyle:"short",timeZone:r}).format(o.date):"—"}function A_(n,l){const r=Math.floor(n/pc),o=r===1?"1 hour":`${r} hours`;return l==="future"?`in ${o}`:`${o} ago`}function hc(n,{now:l=Date.now(),locale:r,timeZone:o}={}){const s=rx(n);if(!s)return"—";const c=l-s.milliseconds,f=c<0,d=Math.abs(c);if(d<ai)return"just now";if(d<2*ai)return f?"in 1 minute":"1 minute ago";if(d<pc){const b=f?Math.ceil(d/ai):Math.floor(d/ai);return f?`in ${b} minutes`:`${b} minutes ago`}if(d<2*pc)return f?"in 1 hour":"1 hour ago";if(d<Ga)return A_(d,f?"future":"past");if(d<2*Ga)return f?"in 1 day":"1 day ago";if(d<Fd*Ga){const b=f?Math.ceil(d/Ga):Math.floor(d/Ga);return f?`in ${b} days`:`${b} days ago`}const p=f?Math.ceil(d/(Fd*Ga)):Math.floor(d/(Fd*Ga)),h=p===1?"1 month":`${p} months`;return f?`in ${h}`:`${h} ago`}function ou({status:n}){return v.jsx(Ai,{className:"taskchef-status-badge",color:R_(n),size:"sm",variant:"light",children:E_(n)})}function Yb({notifications:n,announcements:l=n,onClear:r,onDismiss:o,onOpen:s,tasks:c,withinPortal:f=!0}){if(n.length===0)return null;const d=v.jsxs(v.Fragment,{children:[v.jsxs(ln,{"aria-label":"Task notifications",className:"taskchef-notifications",p:"sm",radius:"md",role:"region",shadow:"xl",withBorder:!0,children:[v.jsxs(yt,{justify:"space-between",mb:"xs",children:[v.jsxs(yt,{gap:6,children:[v.jsx(vN,{"aria-hidden":!0,size:16}),v.jsx(Ee,{fw:700,size:"sm",children:"Updates"})]}),v.jsx(Zn,{onClick:r,size:"compact-xs",variant:"subtle",children:"Clear all"})]}),v.jsx(Xn.Autosize,{className:"taskchef-notification-scroll",mah:"min(55vh, 520px)",type:"auto",children:v.jsx(Vt,{className:"taskchef-notification-list",gap:6,children:n.map(p=>{const h=c.some(w=>w.id===p.taskId),b=`notification-${Math.abs(__(p.id))}`,y=`${b}-summary`,g=`${b}-metadata`;return v.jsx(ln,{className:"taskchef-notification",p:"xs",radius:"sm",children:v.jsxs(yt,{align:"flex-start",gap:"xs",wrap:"nowrap",children:[v.jsxs("button",{"aria-describedby":[p.summary?y:null,g].filter(Boolean).join(" "),"aria-label":m_(p,h),className:"taskchef-notification-open",onClick:()=>s(p),type:"button",children:[v.jsxs(yt,{gap:"xs",justify:"space-between",wrap:"nowrap",children:[v.jsx(Ee,{fw:700,size:"sm",children:lu(p)}),v.jsx(ou,{status:p.status})]}),v.jsx(Ee,{lineClamp:1,size:"sm",children:p.title}),p.summary&&v.jsx(Ee,{className:"taskchef-preserve-lines",id:y,lineClamp:3,size:"xs",children:p.summary}),v.jsxs(Ee,{c:"dimmed",id:g,size:"xs",children:[v.jsx($n,{label:Sm(p.timestamp),children:v.jsx("span",{children:hc(p.timestamp)})}),h?"":" · Task no longer available"]})]}),v.jsx($n,{label:"Dismiss notification",children:v.jsx(pl,{"aria-label":p_(p),color:"gray",onClick:()=>o(p),size:"compact-sm",variant:"subtle",children:v.jsx(KS,{"aria-hidden":!0,size:14})})})]})},p.id)})})})]}),v.jsx(fe,{"aria-atomic":"true","aria-live":"polite",className:"taskchef-visually-hidden",role:"status",children:l.map(N_).join(" ")})]});return f?v.jsx(lp,{children:d}):d}function N_(n){return[lu(n),n.title,n.summary,n.turnRef?`Turn ref ${n.turnRef}`:null,hc(n.timestamp)].filter(Boolean).map(l=>String(l).replace(/[.\s]+$/,"")).join(". ")+"."}function __(n){let l=0;for(const r of n)l=(l<<5)-l+r.charCodeAt(0)|0;return l}const j_=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]+$/,M_=/https?:\/\/(?:www\.)?github\.com\/([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))\/([A-Za-z0-9._-]+)\/(issues|pull)\/([1-9]\d*)(?![A-Za-z0-9_])|([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))\/([A-Za-z0-9._-]+)#([1-9]\d*)(?![A-Za-z0-9_])|#([1-9]\d*)(?![A-Za-z0-9_])|https?:\/\/(?:www\.)?github\.com\/([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))\/([A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9_-])?)\/?(?=$|[\s#),.;:!?'"\]}>])/gi,O_=/https?:\/\/[^\s<>"'`]+/gi;function Qo(n){return!(n!=null&&n.owner)||!(n!=null&&n.repository)?null:`${n.owner.toLowerCase()}/${n.repository.toLowerCase()}`}function ix(n){const l=new Map;for(const r of n){const o=Qo(r);if(!o)continue;const s=r.repository.toLowerCase(),c=l.get(s)??new Set;c.add(o),l.set(s,c)}return new Set([...l].filter(([,r])=>r.size>1).map(([r])=>r))}function xm(n,l){return l.has(n.repository.toLowerCase())?`${n.owner}/${n.repository}`:n.repository}function sx(n,{related:l=!1}={}){const r=ix(n);let o=null;return n.map(s=>{if(s.provider!=="github"&&!s.owner)return s.label??s.text;const c=Qo(s),f=xm(s,r);if(s.type==="repository")return f;if(l){const d=c===o?`#${s.number}`:`${f} #${s.number}`;return o=c,d}return s.type==="pull"?`${f} PR #${s.number}`:s.type==="issue"?`${f} Issue #${s.number}`:`${f} #${s.number}`})}function z_(n,l){const r=String(n.number??""),o=String(l.number??"");return r.length-o.length||r.localeCompare(o)}function D_(n){const l=new Map,r=new Set,o=new Set,s=new Set;for(const f of n??[]){const d=Qo(f),p=f.number?`${d}#${f.number}`:null;if(f.type==="repository"||!d||r.has(f.label)||s.has(f.url)||p&&o.has(p))continue;r.add(f.label),s.add(f.url),p&&o.add(p);const h=l.get(d)??[];h.push(f),l.set(d,h)}const c=ix(n??[]);return[...l.values()].map(f=>[...f].sort(z_)).sort((f,d)=>{const p=xm(f[0],c),h=xm(d[0],c);return p.localeCompare(h,void 0,{sensitivity:"base"})||Qo(f[0]).localeCompare(Qo(d[0]))})}function cx(n){const l=Qo(n);return l?n.type==="repository"?l:n.type==="pull"?`${l} PR #${n.number}`:n.type==="issue"?`${l} Issue #${n.number}`:`${l} #${n.number}`:n.label??n.text}function ux(n,l){return`${n.toLowerCase()}/${l.toLowerCase()}`}function fx(n){return n!=="."&&n!==".."}function dx(n){if(typeof n!="string")return null;let l=n.trim();const r=l.match(/^https?:\/\/(?:www\.)?github\.com\/([^/?#]+)\/([^/?#]+?)(?:\.git)?\/?$/i);if(r&&(l=`${r[1]}/${r[2]}`),!j_.test(l))return null;const[o,s]=l.split("/");return fx(s)?ux(o,s):null}function $_(n){var s;const l=String(n??""),r=mx(l),o=[];for(const c of l.matchAll(M_)){const f=c.index,d=f>0?l[f-1]:"";let p=null;const h=r.find(C=>f>=C.start&&f<C.end);if(h){const C=!!(c[1]||c[9]);let A=null;try{A=new URL(h.text).hostname.toLowerCase()}catch{}if(!(C&&f===h.start&&(A==="github.com"||A==="www.github.com"))||!px(h.text))continue;p={end:h.end,suffix:h.text.slice(c[0].length),text:h.text}}if(c[8]&&/[\w&#/]/.test(d)||(c[5]||c[1]||c[9])&&/[\w/]/.test(d))continue;let b=c[1]??c[5]??c[9]??null,y=c[2]??c[6]??c[10]??null;c[9]&&(y=y.replace(/\.git$/i,""));const g=c[4]??c[7]??c[8]??null,w=(s=c[3])==null?void 0:s.toLowerCase(),R=c[9]?"repository":w==="pull"?"pull":w==="issues"?"issue":"generic",T=!!(b&&y);if(T){if(!fx(y))continue;[b,y]=ux(b,y).split("/")}o.push({end:(p==null?void 0:p.end)??f+c[0].length,explicit:T,number:g,owner:b,repository:y,start:f,text:(p==null?void 0:p.text)??c[0],type:R,urlSuffix:(p==null?void 0:p.suffix)??""})}return o}function L_(n){const l=new Set(n.filter(({explicit:r})=>r).map(({owner:r,repository:o})=>`${r}/${o}`));return l.size===1?[...l][0]:null}function k_(n){const l=new Set((n??[]).map(dx).filter(Boolean));return l.size===1?[...l][0]:null}function B_(n,l){const r=n.explicit?`${n.owner}/${n.repository}`:l;if(!r)return null;const[o,s]=r.split("/");if(n.type==="repository")return{kind:"link",label:`${o}/${s}`,number:null,owner:o,provider:"github",repository:s,text:n.text,type:n.type,url:`https://github.com/${o}/${s}${n.urlSuffix}`};const c=n.type==="pull"?"pull":"issues";return{kind:"link",label:`${o}/${s}#${n.number}`,number:n.number,owner:o,provider:"github",repository:s,text:n.text,type:n.type,url:`https://github.com/${o}/${s}/${c}/${n.number}${n.urlSuffix}`}}function H_(n){let l=n,r;do{r=l,l=l.replace(/[.,;:!?]+$/u,"");for(const[o,s]of[["(",")"],["[","]"],["{","}"]])for(;l.endsWith(s);){const c=[...l].filter(d=>d===o).length;if([...l].filter(d=>d===s).length<=c)break;l=l.slice(0,-1)}}while(l!==r);return l}function mx(n){const l=[];for(const r of String(n??"").matchAll(O_)){const o=H_(r[0]);o&&l.push({end:r.index+o.length,start:r.index,text:o})}return l}function U_(n){const l=n.slice(n.indexOf("//")+2).split(/[?#]/u,1)[0],r=l.indexOf("/");return r<0?!1:l.slice(r).split("/").some(o=>{try{const s=decodeURIComponent(o);return s==="."||s===".."}catch{return!0}})}function px(n){try{const l=new URL(n);return!l.hostname||l.username||l.password||n.includes("\\")||U_(n)?null:l.href}catch{return null}}function V_(n){const l=[];for(const r of mx(n)){const o=px(r.text);o&&l.push({end:r.end,kind:"link",label:r.text,provider:"web",start:r.start,text:r.text,type:"url",url:o})}return l}function Y_(n,{projectRepositories:l=[],taskRepository:r=null}={}){const o=String(n??""),s=$_(o),f=L_(s)??dx(r)??k_(l),d=[];let p=0;for(const h of s){h.start>p&&d.push({kind:"text",text:o.slice(p,h.start)});const b=B_(h,f);b?d.push(b):d.push({kind:"ambiguous",reason:`GitHub reference ${h.text} is not linked because the repository is ambiguous.`,text:h.text}),p=h.end}return p<o.length&&d.push({kind:"text",text:o.slice(p)}),d}function q_(n,l={}){const r=String(n??""),o=Y_(r,l),s=[];let c=0;for(const h of o){const b=r.indexOf(h.text,c);b<0||(h.kind!=="text"&&s.push({end:b+h.text.length,segment:h,start:b}),c=b+h.text.length)}const f=V_(r).filter(h=>!s.some(({end:b,start:y})=>h.start<b&&h.end>y));if(f.length===0)return o;s.push(...f.map(h=>({end:h.end,segment:h,start:h.start}))),s.sort((h,b)=>h.start-b.start);const d=[];let p=0;for(const h of s)h.start<p||(h.start>p&&d.push({kind:"text",text:r.slice(p,h.start)}),d.push(h.segment),p=h.end);return p<r.length&&d.push({kind:"text",text:r.slice(p)}),d}function hx({task:n}){const l=n.relatedGitHubLinks??[];if(l.length===0&&!n.relatedGitHubLinksTruncated)return null;const r=D_(l),o=sx(r.flat(),{related:!0});let s=0;return v.jsxs(fe,{"aria-label":`Related GitHub links for ${n.title}`,className:"taskchef-github-groups",component:"nav",children:[r.map(c=>v.jsx(yt,{className:"taskchef-github-group",gap:5,wrap:"wrap",children:c.map(f=>{const d=o[s];s+=1;const p=f.type==="pull"?", GitHub pull request":f.type==="issue"?", GitHub issue":" on GitHub";return v.jsx(Bc,{"aria-label":`${cx(f)}${p} (opens in a new tab)`,className:"taskchef-github-link",href:f.url,rel:"noopener noreferrer",size:"xs",target:"_blank",children:d},f.url)})},`${c[0].owner}/${c[0].repository}`)),n.relatedGitHubLinksTruncated&&v.jsx(Ee,{c:"dimmed",size:"xs",children:"More links in task history"})]})}function hi({task:n,text:l}){const r=q_(l,{projectRepositories:n.project.githubRepos,taskRepository:n.relatedGitHubRepository}),o=r.filter(f=>f.kind==="link"),s=sx(o);let c=0;return r.map((f,d)=>{if(f.kind==="text")return f.text;if(f.kind==="ambiguous")return v.jsx("span",{"aria-label":f.reason,className:"taskchef-github-reference-ambiguous",tabIndex:0,title:f.reason,children:f.text},`${d}:${f.text}`);const p=s[c];c+=1;const h=f.type==="pull"?", GitHub pull request":f.type==="issue"?", GitHub issue":f.owner?" on GitHub":"";return v.jsx(Bc,{"aria-label":`${cx(f)}${h} (opens in a new tab)`,className:"taskchef-github-link",href:f.url,rel:"noopener noreferrer",target:"_blank",children:p},`${d}:${f.url}`)})}function ru({children:n,className:l="",...r}){return v.jsx("span",{className:`taskchef-shimmer ${l}`.trim(),"data-animation":"text-shimmer",...r,children:n})}const gx=x.createContext(null);function G_({children:n,now:l}){return v.jsx(gx,{value:l,children:n})}function gi({icon:n,label:l,value:r}){const[o,s]=x.useState(!1);x.useContext(gx);const c=o?Sm(r):hc(r),f=Sm(r),d=f==="—",p=d?"Updated time unavailable":o?hc(r):f;return v.jsx($n,{events:{focus:!0,hover:!0,touch:!1},label:p,children:v.jsxs(Ul,{"aria-label":d?`${l}: unavailable.`:`${l}: ${c}. ${o?"Show relative time":"Show exact time"}`,className:"taskchef-time",disabled:d,onClick:()=>s(h=>!h),children:[n??v.jsx(CN,{"aria-hidden":!0,size:12}),v.jsx("bdi",{className:"taskchef-time-label",children:c})]})})}function vx({children:n,variant:l}){return v.jsx(fe,{className:`taskchef-stats taskchef-${l}-stats`,component:"div",children:n})}function va({children:n,usageState:l}){return v.jsx(fe,{className:"taskchef-stat","data-usage-state":l,children:n})}function Ko({accessibleLabel:n,animated:l=!1,icon:r,title:o,value:s}){return v.jsx($n,{events:{focus:!0,hover:!0,touch:!1},label:o,multiline:!0,children:v.jsxs(Ee,{"aria-label":n,className:"taskchef-stat-content",component:"span",size:"xs",tabIndex:0,children:[r,v.jsx("bdi",{children:l?v.jsx(ru,{children:s}):s})]})})}function X_({task:n}){const l=lx(n),r=T_(n);return v.jsxs(vx,{variant:"card",children:[v.jsx(va,{children:v.jsx(gi,{icon:v.jsx(IS,{"aria-hidden":!0,size:14}),label:`Updated time for ${n.title}`,value:n.meaningfulUpdatedAt??n.updatedAt})}),v.jsx(va,{children:v.jsx(Ko,{accessibleLabel:l.accessibleLabel,icon:v.jsx(ZS,{"aria-hidden":!0,size:14}),title:"Duration",value:l.value})}),v.jsxs(va,{usageState:r.kind,children:[v.jsx(Ko,{accessibleLabel:r.tokens.accessibleLabel,animated:r.tokens.animated,icon:v.jsx(QS,{"aria-hidden":!0,size:14}),title:"Tokens",value:r.tokens.value}),v.jsxs(Ee,{className:"taskchef-visually-hidden",component:"span",role:"status",children:[r.tokens.accessibleLabel,"; ",r.cost.accessibleLabel]})]}),v.jsx(va,{usageState:r.kind,children:v.jsx(Ko,{accessibleLabel:r.cost.accessibleLabel,animated:r.cost.animated,icon:v.jsx(XS,{"aria-hidden":!0,size:14}),title:"Estimated cost",value:r.cost.value})})]})}function I_({onOpenCodex:n,onOpenDetail:l,task:r}){const o=JS(r);return v.jsx(ln,{className:"taskchef-task-row",component:"article",pb:8,pt:"md",px:"sm",radius:"md",withBorder:!0,children:v.jsxs(Vt,{className:"taskchef-task-main",gap:"sm",children:[v.jsxs(fe,{children:[v.jsxs(fe,{className:"taskchef-card-heading",children:[v.jsx(Ut,{order:3,size:"h5",children:v.jsx("button",{className:"taskchef-title-button",onClick:()=>l(r),type:"button",children:r.title})}),v.jsx(Vt,{align:"flex-end",className:"taskchef-card-metadata",gap:4,children:v.jsx(ou,{status:r.status})})]}),v.jsx(Ee,{c:"dimmed",mt:2,size:"xs",children:r.project.name})]}),v.jsxs(fe,{className:"taskchef-summary-grid",children:[v.jsx(Ee,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Request"}),v.jsx(Ee,{className:"taskchef-preserve-lines",lineClamp:3,size:"sm",children:v.jsx(hi,{task:r,text:o.requestSummary})}),v.jsx(Ee,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Result"}),v.jsx(Ee,{className:"taskchef-preserve-lines",lineClamp:3,size:"sm",children:o.resultStatus==="working"?v.jsx(ru,{children:o.resultSummary}):v.jsx(hi,{task:r,text:o.resultSummary})})]}),v.jsx(hx,{task:r}),v.jsxs(fe,{className:"taskchef-list-card-footer",children:[v.jsx(X_,{task:r}),v.jsx("button",{"aria-label":`Open chat for ${r.title}`,className:"taskchef-board-chat",onClick:()=>n(r),title:"Open chat",type:"button",children:v.jsx(Hp,{"aria-hidden":!0,size:19,stroke:1.6})})]})]})})}const Z_=[{status:"working",label:"Working"},{status:"needs_input",label:"Needs input"},{status:"completed",label:"Completed"},{status:"failed",label:"Failed"},{status:null,label:"Unresolved"}],Q_=new Set(["working","needs_input","completed","failed"]);function qb(n){return Q_.has(n.status)?n.status:null}function K_({completedLimit:n,onMoreCompleted:l,onOpenCodex:r,onOpenDetail:o,tasks:s}){const c=x.useRef(null),f=x.useRef(null),d=x.useRef(!1);function p(g){if(g.pointerType!=="mouse"||g.button!==0||!g.isPrimary||g.target.closest("button, a, input, textarea, select, [contenteditable], .taskchef-board-card, h1, h2, h3, p, span"))return;const R=c.current;!R||R.scrollWidth<=R.clientWidth||(f.current={pointerId:g.pointerId,startX:g.clientX,scrollLeft:R.scrollLeft,moved:!1},R.setPointerCapture(g.pointerId))}function h(g){const w=f.current,R=c.current;if(!w||!R||w.pointerId!==g.pointerId)return;const T=g.clientX-w.startX;!w.moved&&Math.abs(T)<6||(w.moved||(w.moved=!0,R.classList.add("taskchef-board-dragging")),g.preventDefault(),R.scrollLeft=w.scrollLeft-T)}function b(g){const w=f.current,R=c.current;!w||!R||w.pointerId!==g.pointerId||(f.current=null,R.classList.remove("taskchef-board-dragging"),R.hasPointerCapture(g.pointerId)&&R.releasePointerCapture(g.pointerId),w.moved&&(d.current=!0,window.setTimeout(()=>{d.current=!1},0)))}const y=Z_.filter(g=>g.status!==null||s.some(w=>qb(w)===null));return v.jsx(fe,{"aria-label":"Task board",className:"taskchef-board",component:"section",onClickCapture:g=>{d.current&&(g.preventDefault(),g.stopPropagation(),d.current=!1)},onPointerCancel:b,onPointerDown:p,onPointerMove:h,onPointerUp:b,ref:c,tabIndex:0,children:y.map(({status:g,label:w})=>{const R=s.filter(C=>qb(C)===g),T=g==="completed"?R.slice(0,n):R;return v.jsxs(fe,{"aria-label":`${w}, ${R.length} tasks`,className:"taskchef-board-lane",component:"section",children:[v.jsxs(fe,{className:"taskchef-board-lane-heading",children:[v.jsx(Ut,{order:2,size:"h5",children:w}),v.jsx(Ee,{"aria-label":`${R.length} tasks`,c:"dimmed",size:"sm",children:R.length})]}),v.jsxs(Vt,{gap:"sm",children:[T.map(C=>v.jsx(F_,{onOpenCodex:r,onOpenDetail:o,task:C},C.id)),R.length===0&&v.jsx(Ee,{c:"dimmed",className:"taskchef-board-empty",size:"sm",children:"No tasks"}),g==="completed"&&R.length>T.length&&v.jsxs(Zn,{className:"taskchef-board-more",onClick:l,size:"compact-sm",variant:"subtle",children:["Show ",Math.min(5,R.length-T.length)," more · ",T.length," of ",R.length]})]})]},w)})})}function F_({task:n,onOpenCodex:l,onOpenDetail:r}){const o=JS(n),s=n.status==="working"?o.requestSummary:o.resultSummary,c=t_(n);return v.jsxs(ln,{className:"taskchef-board-card",component:"article",px:"sm",pt:"sm",pb:6,withBorder:!0,children:[v.jsx(Ut,{className:"taskchef-board-title",order:3,size:"h5",children:v.jsx("button",{className:"taskchef-title-button",onClick:()=>r(n),type:"button",children:n.title})}),v.jsx(Ee,{className:"taskchef-board-project",size:"xs",children:n.project.name}),v.jsx(Ee,{className:"taskchef-board-excerpt taskchef-preserve-lines",size:"sm",children:v.jsx(hi,{task:n,text:s})}),v.jsxs(fe,{className:"taskchef-board-card-footer",children:[v.jsx(gi,{label:"Updated time",value:n.meaningfulUpdatedAt??n.updatedAt}),c?v.jsx("button",{"aria-label":`Open chat for ${n.title}`,className:"taskchef-board-chat",onClick:()=>l(n),title:"Open chat",type:"button",children:v.jsx(Hp,{"aria-hidden":!0,size:19,stroke:1.6})}):n.status==="working"?v.jsx(Ee,{c:"dimmed",className:"taskchef-board-link-pending",size:"xs",children:"Chat link pending"}):null]})]})}function P_({highlightTurnRef:n,task:l}){const r=o_(l,[]);return r!=null&&r.length?v.jsx(Vt,{gap:"sm",children:[...r].reverse().map((o,s)=>{const c=a_(o),f=o.turnRef??o.turnId??`turn-${s}`,d=f===n,p=w_(l,o);return v.jsx(ln,{className:`taskchef-turn${d?" taskchef-turn-highlighted":""}`,"data-turn-ref":f,p:"sm",radius:"md",tabIndex:d?-1:void 0,withBorder:!0,children:v.jsxs(Vt,{gap:7,children:[v.jsxs(fe,{className:"taskchef-turn-heading",children:[v.jsx(Ee,{c:"dimmed",size:"xs",children:c.sourceLabel}),v.jsx(ou,{status:c.status})]}),v.jsxs(fe,{children:[v.jsx(Ee,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Request"}),v.jsx(Ee,{className:"taskchef-preserve-lines",size:"sm",children:v.jsx(hi,{task:l,text:o.requestSummary??"Request not recorded."})})]}),v.jsxs(fe,{children:[v.jsx(Ee,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Result"}),v.jsx(Ee,{className:"taskchef-preserve-lines",size:"sm",children:c.status==="working"?v.jsx(ru,{children:c.summary}):v.jsx(hi,{task:l,text:c.summary})})]}),v.jsxs(vx,{variant:"turn",children:[v.jsx(va,{children:v.jsx(gi,{icon:v.jsx(IS,{"aria-hidden":!0,size:14}),label:"Turn update time",value:c.updatedAt})}),v.jsx(va,{children:v.jsx(J_,{turn:o})}),v.jsx(va,{usageState:p.kind,children:v.jsx(Ko,{accessibleLabel:p.tokens.accessibleLabel,animated:p.animated,icon:v.jsx(QS,{"aria-hidden":!0,size:14}),title:"Tokens",value:p.tokens.value})}),v.jsx(va,{usageState:p.kind,children:v.jsx(Ko,{accessibleLabel:p.cost.accessibleLabel,animated:p.animated,icon:v.jsx(XS,{"aria-hidden":!0,size:14}),title:"Estimated cost",value:p.cost.value})})]}),p.note&&v.jsx(Ee,{c:"dimmed",size:"xs",children:p.note})]})},f)})}):v.jsx(Ee,{c:"dimmed",size:"sm",children:"No turn history has been recorded."})}function J_({turn:n}){const l=W_(n.result===null),r=S_(n,l);return v.jsx(Ko,{accessibleLabel:r.accessibleLabel,icon:v.jsx(ZS,{"aria-hidden":!0,size:14}),title:"Duration",value:r.value})}function W_(n){const[l,r]=x.useState(()=>Date.now());return x.useEffect(()=>{if(!n)return;r(Date.now());const o=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(o)},[n]),l}function ej({loading:n,onClick:l,taskTitle:r}){return v.jsx(Zn,{"aria-label":`Open chat for ${r}`,className:"taskchef-open-chat",leftSection:v.jsx(Hp,{"aria-hidden":!0,size:15,stroke:1.6}),loading:n,onClick:l,size:"compact-sm",variant:"default",children:"Open chat"})}function tj({task:n}){const l=ox(n),r=lx(n),o=l.kind==="ready"?l:null,s=Object.keys((o==null?void 0:o.usage.models)??{}).join(", "),c=o==null?void 0:o.usage.estimatedCostUsd,f=typeof c=="number"&&Number.isFinite(c),d=l.kind==="pending"?"Pending":l.kind==="calculating"?"Calculating":"n/a",p=l.kind==="unavailable"?"unavailable":d.toLowerCase(),h=[{accessibleValue:o?`${pi(o.usage.totalTokens)} tokens`:l.label,animated:l.kind==="pending"||l.kind==="calculating"||(o==null?void 0:o.knownSoFar),label:"Tokens",title:o?`${pi(o.usage.totalTokens)} tokens`:l.label,value:o?au(o.usage.totalTokens):d},{accessibleValue:o?o.usage.estimatedCostUsd==null?"Estimated cost unavailable":`Estimated cost ${Wo(o.usage.estimatedCostUsd)}`:`Estimated cost ${p}${l.kind==="unavailable"?`: ${l.label}`:""}`,animated:l.kind==="pending"||l.kind==="calculating"||(o==null?void 0:o.knownSoFar)&&f,label:"Estimated cost",title:(o==null?void 0:o.usage.estimatedCostUsd)==null?"Estimated cost unavailable":`Unrounded estimate: $${o.usage.estimatedCostUsd}`,value:o?o.usage.estimatedCostUsd==null?"n/a":Wo(o.usage.estimatedCostUsd):d},{accessibleValue:r.accessibleLabel,label:"Duration",title:r.title,value:r.value},{accessibleValue:s||"Models unavailable",label:"Models",title:s||"Models unavailable",value:s||"n/a"}];return v.jsxs(fe,{"aria-live":"polite",children:[v.jsx(fe,{className:"taskchef-metrics",children:h.map(({accessibleValue:b,animated:y,label:g,title:w,value:R})=>v.jsxs(ln,{className:"taskchef-metric",p:"sm",radius:"md",withBorder:!0,children:[v.jsx(Ee,{c:"dimmed",size:"xs",children:g}),v.jsx(Ee,{"aria-label":b,className:"taskchef-metric-value",fw:650,size:"sm",title:w,children:y?v.jsx(ru,{children:R}):R})]},g))}),l.kind==="unavailable"&&l.label!=="Token usage unavailable"&&v.jsx(Ee,{c:"dimmed",mt:"xs",size:"xs",children:l.label})]})}function nj({busy:n,error:l,highlightTurnRef:r,onClose:o,onCopy:s,onOpenCodex:c,onTransition:f,opened:d,task:p,notifications:h,notice:b}){var C;const y=Nm("(max-width: 48em)"),[g,w]=x.useState(null);if(x.useEffect(()=>{d||w(null)},[d]),x.useEffect(()=>{d&&r&&requestAnimationFrame(()=>{var A;(A=document.querySelector(`[data-turn-ref="${CSS.escape(r)}"]`))==null||A.focus()})},[r,d,(C=p==null?void 0:p.turns)==null?void 0:C.length,p==null?void 0:p.updatedAt]),x.useEffect(()=>{g&&(!p||!Gb(p).includes(g))&&w(null)},[g,p==null?void 0:p.status]),!p)return null;const R=Gb(p),T=v.jsxs(Vt,{gap:"lg",children:[h,v.jsxs(fe,{children:[v.jsxs(yt,{align:"flex-start",gap:"sm",justify:"space-between",wrap:"nowrap",children:[v.jsxs(fe,{children:[v.jsx(Ee,{c:"teal",fw:700,size:"xs",tt:"uppercase",children:p.project.name}),v.jsx(Ut,{id:"task-detail-title",order:2,size:"h3",tabIndex:-1,children:p.title})]}),v.jsx(ou,{status:p.status})]}),v.jsxs(yt,{gap:"xs",mt:"md",children:[v.jsx(ej,{loading:n,onClick:c,taskTitle:p.title}),v.jsxs(bt,{position:"bottom-start",shadow:"md",withinPortal:!0,zIndex:360,children:[v.jsx(bt.Target,{children:v.jsx($n,{label:"More task actions",children:v.jsx(pl,{"aria-label":"More task actions",className:"taskchef-detail-more",disabled:n,variant:"default",children:v.jsx(EN,{"aria-hidden":!0,size:17})})})}),v.jsxs(bt.Dropdown,{children:[v.jsx(bt.Item,{leftSection:v.jsx(xN,{size:14}),onClick:s,children:"Copy Task ID"}),R.includes("completed")&&v.jsx(bt.Item,{leftSection:v.jsx(bN,{size:14}),onClick:()=>w("completed"),children:"Mark completed"}),R.includes("failed")&&v.jsx(bt.Item,{color:"red",leftSection:v.jsx(KS,{size:14}),onClick:()=>w("failed"),children:"Mark failed"})]})]})]}),v.jsx(fe,{mt:"sm",children:v.jsx(hx,{task:p})})]}),g&&v.jsx(lj,{busy:n,onCancel:()=>w(null),onTransition:f,status:g},g),b&&v.jsx(Dn,{color:"teal",role:"status",children:b}),l&&v.jsx(Dn,{color:"red",role:"alert",children:l}),v.jsxs("section",{"aria-labelledby":"usage-heading",children:[v.jsx(Ut,{id:"usage-heading",mb:"xs",order:3,size:"h5",children:"Usage"}),v.jsx(tj,{task:p})]}),v.jsx(Yc,{}),v.jsxs("section",{"aria-labelledby":"activity-heading",children:[v.jsx(Ut,{id:"activity-heading",mb:"sm",order:3,size:"h5",children:"Activity timeline"}),v.jsx(P_,{highlightTurnRef:r,task:p})]}),v.jsxs("section",{"aria-labelledby":"instruction-heading",children:[v.jsx(Ut,{id:"instruction-heading",mb:"xs",order:3,size:"h5",children:"Original instruction"}),v.jsx(fe,{className:"taskchef-code-panel",component:"pre",children:p.instruction})]}),v.jsxs("section",{"aria-labelledby":"metadata-heading",children:[v.jsx(Ut,{id:"metadata-heading",mb:"xs",order:3,size:"h5",children:"Metadata"}),v.jsxs("dl",{className:"taskchef-metadata",children:[v.jsx("dt",{children:"Task ID"}),v.jsx("dd",{children:p.id}),v.jsx("dt",{children:"Thread ID"}),v.jsx("dd",{children:p.threadId??"—"}),v.jsx("dt",{children:"Current turn ref"}),v.jsx("dd",{children:p.turnRef??"—"}),v.jsx("dt",{children:"Project path"}),v.jsx("dd",{children:p.project.path}),v.jsx("dt",{children:"Created"}),v.jsx("dd",{children:v.jsx(gi,{label:"Created time",value:p.createdAt})}),v.jsx("dt",{children:"Updated"}),v.jsx("dd",{children:v.jsx(gi,{label:"Updated time",value:p.meaningfulUpdatedAt??p.updatedAt})}),v.jsx("dt",{children:"Updated by"}),v.jsx("dd",{children:p.updatedBy??"—"})]})]})]});return y?v.jsx(Fn,{closeOnClickOutside:!n,closeOnEscape:!n,onClose:o,opened:d,overlayProps:{backgroundOpacity:.55,blur:2},position:"bottom",scrollAreaComponent:Xn.Autosize,size:"92%",title:v.jsx("span",{className:"taskchef-visually-hidden",children:"Task details"}),trapFocus:!0,zIndex:300,children:T}):v.jsx(Jn,{"aria-labelledby":"task-detail-title",closeOnClickOutside:!n,closeOnEscape:!n,onClose:o,opened:d,overlayProps:{backgroundOpacity:.55,blur:2},scrollAreaComponent:Xn.Autosize,size:"min(820px, calc(100vw - 32px))",title:v.jsx("span",{className:"taskchef-visually-hidden",children:"Task details"}),trapFocus:!0,zIndex:300,children:T})}function Gb(n){return n.status==="completed"?["failed"]:n.status==="failed"?["completed"]:n.status==="working"||n.status==="needs_input"?["completed","failed"]:[]}function lj({busy:n,onCancel:l,onTransition:r,status:o}){const s=x.useRef(crypto.randomUUID());return v.jsxs(Dn,{color:o==="failed"?"red":"teal",role:"alert",title:`Mark task ${o}?`,children:[v.jsx(Ee,{mb:"sm",size:"sm",children:"This interrupts active work and appends an audited manual dashboard turn."}),v.jsxs(yt,{gap:"xs",children:[v.jsx(Zn,{color:o==="failed"?"red":"teal",loading:n,onClick:async()=>{const c=await r(o,s.current);c.ok?(l(),requestAnimationFrame(()=>{var f;return(f=document.getElementById("task-detail-title"))==null?void 0:f.focus()})):c.rotateActionId&&(s.current=crypto.randomUUID())},size:"compact-sm",children:"Confirm"}),v.jsx(Zn,{disabled:n,onClick:l,size:"compact-sm",variant:"default",children:"Cancel"})]})]})}const aj={primaryColor:"teal",colors:{teal:["#e6fcf5","#c3fae8","#96f2d7","#63e6be","#38d9a9","#20c997","#087f5b","#067052","#055e46","#044d39"]},defaultRadius:"md",fontFamily:"Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif",headings:{fontFamily:"inherit",fontWeight:"680"},components:{Button:{defaultProps:{radius:"md"}},Paper:{defaultProps:{radius:"md"}}}};var Ib;const Xb=(Ib=document.querySelector('meta[name="taskchef-style-nonce"]'))==null?void 0:Ib.content,yx="taskchef.dashboard.view";function oj(){try{return window.localStorage.getItem(yx)==="board"?"board":"list"}catch{return"list"}}function rj({totalCount:n,visibleCount:l}){return v.jsxs(Ee,{"aria-live":"polite",className:"taskchef-results-summary",id:"task-results-summary",children:["Tasks: ",l," of ",n]})}function ij({connect:n=!0,initialFilters:l={},initialTasks:r=[]}){const[o,s]=x.useState(()=>window.location.hash==="#settings");x.useEffect(()=>{const se=()=>s(window.location.hash==="#settings");return window.addEventListener("hashchange",se),()=>window.removeEventListener("hashchange",se)},[]);const[c,f]=x.useState(r),[d,p]=x.useState(),[h,b]=x.useState(!1),[y,g]=x.useState(null),[w,R]=x.useState(null),[T,C]=x.useState(l.project??""),[A,_]=x.useState(l.status??""),[N,j]=x.useState("all"),[$,L]=x.useState(oj),[D,H]=x.useState(5),[J,oe]=x.useState(()=>Date.now()),[te,ne]=x.useState(null),[K,q]=x.useState(!1),[ue,O]=x.useState(!1),[B,U]=x.useState(null),[F,W]=x.useState(null),[M,V]=x.useState(null),[P,ae]=x.useState({initialized:r.length>0,announcements:[],notifications:[],seenIds:new Set,signatures:new Map}),ie=(te==null?void 0:te.id)??null,de=x.useRef(ie);de.current=ie;const ge=x.useRef(0),pe=x.useRef(null),he=x.useRef(Ws(null)),Me=x.useCallback(se=>{f(se.tasks),p(se.projectIndex),ae(ze=>{const Ue=h_(ze,se.tasks);return{initialized:!0,announcements:Ue.additions,notifications:Ue.notifications,seenIds:Ue.seenIds,signatures:Ue.signatures}}),g(se.healthy===!1?"The task log is temporarily unavailable. Showing the last valid snapshot.":null);const He=de.current;if(He){const ze=se.tasks.find(Ue=>Ue.id===He);ze&&ne(Ue=>Ue?Ub(Ue,ze):ze)}},[]);x.useEffect(()=>{const se=window.setInterval(()=>oe(Date.now()),3e4);return()=>window.clearInterval(se)},[]),x.useEffect(()=>{if(!n)return;YN().then(R).catch(()=>R(null));const se=VN({onConnection:b,onError:g,onSnapshot:Me});return()=>se.close()},[Me,n]);const ye=x.useCallback(async(se,He=null)=>{const ze=++ge.current;pe.current=se.updatedAt,he.current=Ws(se),ne(Ue=>(Ue==null?void 0:Ue.id)===se.id?Ub(Ue,se):se),q(!0),V(He),U(null),W(null);try{for(let Ue=0;Ue<=40;Ue+=1){if(ze!==ge.current)return;const Te=await GN(se.id);if(ze!==ge.current||(pe.current=Te.updatedAt,he.current=Ws(Te),ne(Te),!C_(Te)||Ue===40))return;await new Promise(Qt=>window.setTimeout(Qt,1500))}}catch{ze===ge.current&&U("Task activity is temporarily unavailable. Showing the latest list snapshot.")}},[]),we=c.find(se=>se.id===ie)??null,Se=Ws(we);x.useEffect(()=>{!K||!ie||!n||we&&(we.updatedAt===pe.current&&Se===he.current||ye(we,M))},[we==null?void 0:we.updatedAt,Se]);const Oe=x.useMemo(()=>[{label:"All projects",value:""},...[...new Set(c.map(se=>se.project.name))].sort().map(se=>({label:se,value:se}))],[c]),We=x.useMemo(()=>gm(c,{project:T,status:A,date:N,now:J}),[c,T,A,N,J]),rt=x.useMemo(()=>gm(c,{project:T,date:N,now:J}),[c,T,N,J]),ut=$==="board",_t=x.useMemo(()=>i_(c,{project:T,date:N,now:J}),[c,T,N,J]),It=FS.map(({label:se,value:He})=>({label:_t[He]>0?`${se} ${_t[He]}`:se,value:He}));function Zt(se){if(!(se!=="board"&&se!=="list")){L(se);try{window.localStorage.setItem(yx,se)}catch{}}}async function Lt(se){O(!0);try{const He=await XN(se.id);He&&g(He)}catch{g("Codex could not be opened. Open the project and select the recorded task instead.")}finally{O(!1)}}async function Ct(se,He){if(!te)return{ok:!1};const ze=te,Ue=n_(ze);O(!0),U(null);const Te=await IN(ze,se,He);return O(!1),Te.task&&(ne(Qt=>kb({requestTask:ze,expected:Ue,responseTask:Te.task,selectedTask:Qt})),f(Qt=>Qt.map(un=>un.id===ze.id?kb({requestTask:ze,expected:Ue,responseTask:Te.task,selectedTask:un}):un))),Te.ok&&Te.task?(V(Te.task.turnRef??Te.task.turnId),{ok:!0}):(U(Te.message??"Task state could not be changed."),{ok:!1,rotateActionId:Te.code==="stale_task"})}function kt(se){const He=c.find(Ue=>Ue.id===se.taskId),ze=g_({detailTaskId:ie,detailOpened:K,highlightTurnRef:M,notifications:P.notifications,refreshGeneration:ge.current},se,!!He);if(ae(Ue=>({...Ue,notifications:ze.notifications})),!He){g("This task is no longer present in the current snapshot.");return}ye(He,ze.highlightTurnRef)}return v.jsx(d0,{defaultColorScheme:"auto",getStyleNonce:Xb?()=>Xb:void 0,theme:aj,children:v.jsxs(G_,{now:J,children:[v.jsxs(In,{className:"taskchef-shell",padding:0,children:[v.jsx(fe,{className:"taskchef-header-shell",component:"header",children:v.jsx(di,{className:`taskchef-header${ut?" taskchef-header-board":""}`,size:"100%",children:v.jsxs(yt,{className:"taskchef-header-layout",justify:"space-between",wrap:"nowrap",children:[v.jsxs(yt,{className:"taskchef-header-copy",gap:"xs",wrap:"nowrap",children:[v.jsx(cj,{}),v.jsxs(Ut,{className:"taskchef-brand-title",order:1,children:[v.jsx("span",{children:"TaskChef Dashboard"}),w&&v.jsxs("span",{className:"taskchef-version",children:["v",w]})]})]}),v.jsxs(yt,{className:"taskchef-header-actions",gap:2,justify:"flex-end",wrap:"nowrap",children:[v.jsx($n,{label:"Settings",children:v.jsx(pl,{className:"taskchef-icon-button",component:"a",href:"#settings","aria-label":"Settings","aria-current":o?"page":void 0,variant:"subtle",color:"gray",size:"lg",children:v.jsx(DN,{size:18,stroke:1.8})})}),v.jsx(sj,{}),v.jsxs(yt,{"aria-live":"polite",className:"taskchef-connection",gap:7,role:"status",wrap:"nowrap",children:[v.jsx(UN,{"aria-hidden":!0,color:h?"var(--mantine-color-teal-6)":"var(--mantine-color-yellow-6)",size:9}),v.jsx(Ee,{c:"dimmed",size:"xs",children:h?"Live":n?"Connecting…":"Fixture preview"})]})]})]})})}),v.jsx(In.Main,{children:v.jsxs(di,{className:`taskchef-main${ut?" taskchef-main-board":""}`,pb:80,size:"100%",children:[(d==null?void 0:d.status)==="unavailable"&&v.jsx(Dn,{color:"yellow",icon:v.jsx(Qd,{size:18}),mb:"md",title:"Project index unavailable",children:"Task history is still visible. Verify the index and inspect backups before making project changes."}),(d==null?void 0:d.status)==="available"&&d.missingProjects.length>0&&v.jsx(Dn,{color:"yellow",icon:v.jsx(Qd,{size:18}),mb:"md",title:"Historical projects are missing from the current index",children:d.missingProjects.map(se=>v.jsxs(Ee,{size:"sm",children:[se.snapshotNames.join(", "),": ",se.taskCount," task(s). Run ",v.jsx("code",{children:"taskchef backup list --json"})," and preview any restore; the dashboard never restores automatically."]},se.path))}),o?v.jsxs(Vt,{gap:"md",children:[v.jsx(Zn,{component:"a",href:"#",variant:"subtle",size:"sm",leftSection:v.jsx(pN,{size:16}),style:{alignSelf:"flex-start"},children:"Back to tasks"}),v.jsx(QN,{})]}):v.jsxs(v.Fragment,{children:[v.jsx(ln,{className:"taskchef-toolbar",radius:0,children:v.jsxs(Vt,{gap:"sm",children:[v.jsx(yt,{className:"taskchef-toolbar-view",children:v.jsx(mi,{"aria-label":"View",data:[{label:"Board",value:"board"},{label:"List",value:"list"}],onChange:Zt,size:"xs",value:$,withItemsBorders:!1})}),v.jsxs(yt,{className:"taskchef-toolbar-filters",gap:"sm",wrap:"nowrap",children:[v.jsx(Jo,{"aria-label":"Project",data:Oe,onChange:se=>{C(se??""),H(5)},size:"xs",value:T}),v.jsx(Jo,{"aria-label":"Updated",data:[{label:"Latest 24 hours",value:"24h"},{label:"Latest 7 days",value:"7d"},{label:"All time",value:"all"}],onChange:se=>{j(se??"all"),H(5)},size:"xs",value:N})]}),!ut&&v.jsx(fe,{className:"taskchef-toolbar-status",children:v.jsx(mi,{"aria-label":"Status",data:It,onChange:_,size:"xs",value:A,withItemsBorders:!1})})]})}),!ut&&v.jsx(rj,{totalCount:c.length,visibleCount:We.length}),y&&v.jsx(Dn,{color:"yellow",icon:v.jsx(Qd,{"aria-hidden":!0,size:17}),mt:"md",role:"status",children:v.jsxs(yt,{gap:"sm",justify:"space-between",wrap:"nowrap",children:[v.jsx(Ee,{size:"sm",children:y}),v.jsx(Pa,{"aria-label":"Dismiss dashboard message",onClick:()=>g(null),size:"sm"})]})}),ut?v.jsx(K_,{completedLimit:D,onMoreCompleted:()=>H(se=>se+5),onOpenCodex:Lt,onOpenDetail:se=>void ye(se),tasks:rt}):v.jsxs(Vt,{"aria-describedby":"task-results-summary","aria-label":"Tasks",className:"taskchef-list",component:"section",gap:"sm",mt:"xs",children:[We.map(se=>v.jsx(I_,{onOpenCodex:Lt,onOpenDetail:He=>void ye(He),task:se},se.id)),We.length===0&&v.jsxs(ln,{className:"taskchef-empty",p:48,ta:"center",withBorder:!0,children:[v.jsx(Ut,{order:2,size:"h4",children:"No tasks match these filters"}),v.jsx(Ee,{c:"dimmed",mt:4,size:"sm",children:"Choose a different project, update window, or status."})]})]})]})]})})]}),v.jsx(nj,{busy:ue,error:B,highlightTurnRef:M,onClose:()=>{ue||(ge.current+=1,q(!1),V(null))},onCopy:()=>{te&&(W(null),navigator.clipboard.writeText(te.id).then(()=>W("Task ID copied."),()=>W("Clipboard access is unavailable. Copy the Task ID from metadata.")))},onOpenCodex:()=>te&&void Lt(te),onTransition:Ct,opened:K,task:te,notice:F,notifications:K?v.jsx(Yb,{announcements:P.announcements,notifications:P.notifications,onClear:()=>ae(se=>({...se,notifications:Hb({detailTaskId:ie,detailOpened:K,highlightTurnRef:M,notifications:se.notifications,refreshGeneration:ge.current}).notifications})),onDismiss:se=>ae(He=>({...He,notifications:Bb(He.notifications,se.id)})),onOpen:kt,tasks:c,withinPortal:!1}):null}),!K&&v.jsx(Yb,{announcements:P.announcements,notifications:P.notifications,onClear:()=>ae(se=>({...se,notifications:Hb({detailTaskId:ie,detailOpened:K,highlightTurnRef:M,notifications:se.notifications,refreshGeneration:ge.current}).notifications})),onDismiss:se=>ae(He=>({...He,notifications:Bb(He.notifications,se.id)})),onOpen:kt,tasks:c})]})})}function sj(){const{setColorScheme:n}=r0(),l=i0("light"),r=l==="dark"?"light":"dark";return v.jsx($n,{label:`Use ${r} theme`,children:v.jsx(pl,{"aria-label":`Use ${r} theme`,className:"taskchef-icon-button",color:"gray",onClick:()=>n(r),size:"lg",variant:"subtle",children:l==="dark"?v.jsx(kN,{"aria-hidden":!0,size:18,stroke:1.8}):v.jsx(jN,{"aria-hidden":!0,size:18,stroke:1.8})})})}function cj(){const n=i0("light");return v.jsx("img",{alt:"","aria-hidden":!0,className:"taskchef-brand-icon",height:"28",src:n==="dark"?"/assets/taskchef-dark.svg":"/assets/taskchef.svg",width:"28"})}V2.createRoot(document.getElementById("root")).render(v.jsx(x.StrictMode,{children:v.jsx(ij,{})}));
193
+ */const HN=[["path",{d:"M7 3.34a10 10 0 1 1 -4.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 4.995 -8.336z",key:"svg-0"}]],UN=Nt("filled","circle-filled","CircleFilled",HN);function VN({onConnection:n,onError:l,onSnapshot:r}){const o=new EventSource("/api/events");return o.addEventListener("open",()=>n(!0)),o.addEventListener("error",()=>n(!1)),o.addEventListener("snapshot",s=>{n(!0),r(JSON.parse(s.data))}),o.addEventListener("dashboard-error",s=>{const c=JSON.parse(s.data);l(c.message??"The task log is temporarily unavailable.")}),o}async function ji(n,l){const r=await fetch(n,l),o=await r.json().catch(()=>({}));if(!r.ok)throw Object.assign(new Error(o.message??"Request failed."),{payload:o});return o}async function YN(){return(await ji("/api/health")).taskchefVersion}async function qN(n,l,r){return ji(`/api/settings/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({schemaVersion:1,model:l,effort:r})})}async function GN(n){return(await ji(`/api/tasks/${encodeURIComponent(n)}`)).task}async function XN(n){return(await ji(`/api/tasks/${encodeURIComponent(n)}/open-codex`,{method:"POST"})).message??null}async function IN(n,l,r){const o=new AbortController,s=window.setTimeout(()=>o.abort(),1e4);try{return{ok:!0,task:(await ji(`/api/tasks/${encodeURIComponent(n.id)}/manual-transition`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({schemaVersion:1,actionId:r,expected:{status:n.status,turnRef:n.turnRef,threadId:n.threadId,updatedAt:n.updatedAt},targetStatus:l}),signal:o.signal})).task}}catch(c){const f=c.payload;return{ok:!1,code:(f==null?void 0:f.code)??(o.signal.aborted?"request_timeout":"network_error"),message:(f==null?void 0:f.message)??(o.signal.aborted?"Task state change timed out. Try again.":"Task state changes are temporarily unavailable. Try again."),task:(f==null?void 0:f.task)??null}}finally{window.clearTimeout(s)}}const ZN={low:"Light",medium:"Medium",high:"High",xhigh:"Extra High",ultra:"Ultra"};function QN(){const[n,l]=x.useState([]),[r,o]=x.useState(null),[s,c]=x.useState(null),[f,d]=x.useState(!0),[p,h]=x.useState(null),[b,y]=x.useState(null),[g,w]=x.useState(0);x.useEffect(()=>{const C=new AbortController;return d(!0),c(null),fetch("/api/settings",{signal:C.signal}).then(async A=>{if(!A.ok)throw new Error("Settings preview could not be loaded.");const _=await A.json();l(_.profiles),o(_.usageProvider??null)}).catch(A=>{C.signal.aborted||c(A.message)}).finally(()=>{C.signal.aborted||d(!1)}),()=>C.abort()},[g]),x.useEffect(()=>{if(y(null),!p)return;const C=window.setTimeout(()=>y(p),400);return()=>window.clearTimeout(C)},[p]);const R=n.find(C=>C.id==="personal"),T=async(C,A,_)=>{h(C.role),c(null),l(N=>N.map(j=>j.id!=="personal"?j:{...j,roles:j.roles.map($=>$.role===C.role?{...$,model:A,effort:_}:$)}));try{const N=await qN(C.role,A,_);l([N.profile])}catch(N){l(j=>j.map($=>$.id!=="personal"?$:{...$,roles:$.roles.map(L=>L.role===C.role?C:L)})),c(N instanceof Error?N.message:"Model role could not be saved.")}finally{h(null)}};return v.jsxs(Vt,{className:"taskchef-settings",gap:"sm","aria-label":"Model settings",children:[v.jsxs(yt,{justify:"space-between",children:[v.jsx(Ut,{order:2,size:"h5",children:"Model roles"}),v.jsx(pl,{"aria-label":"Refresh","aria-busy":f,"aria-disabled":f||p!==null,className:"taskchef-icon-button",color:"gray",variant:"subtle",size:"lg",onClick:()=>{f||p||(d(!0),w(C=>C+1))},children:v.jsx(ON,{className:f?"taskchef-refresh-spinning":void 0,size:18,stroke:1.8})})]}),v.jsx(Ee,{c:"dimmed",size:"sm",children:"Your models for orchestration, planning, implementation, and review."}),s&&v.jsx(Dn,{color:"red",role:"alert",children:s}),R&&v.jsxs(v.Fragment,{children:[R.problems.map(C=>v.jsx(Dn,{color:"yellow",children:C},C)),R.roles.map(C=>{var A,_;return v.jsx(ln,{className:"taskchef-section",withBorder:!0,p:"sm",children:v.jsxs(Vt,{gap:"xs",children:[v.jsxs(yt,{justify:"space-between",children:[v.jsx(Ut,{order:3,size:"h5",tt:"capitalize",children:C.role}),v.jsx(Ai,{color:["invalid","unavailable"].includes(C.status)?"red":C.status==="missing"?"gray":"teal",children:C.status})]}),v.jsxs(Bp,{className:"taskchef-settings-fields",cols:2,children:[v.jsx(Jo,{label:"Model","aria-label":`${C.role} model`,"aria-busy":f||p!==null,data:R.modelOptions??[],value:typeof C.model=="string"?C.model:null,readOnly:f||p!==null,allowDeselect:!1,searchable:!0,onChange:N=>{var L;if(f||p||!N)return;const j=(L=R.modelOptions)==null?void 0:L.find(D=>D.value===N),$=typeof C.effort=="string"&&(j!=null&&j.efforts.includes(C.effort))?C.effort:j==null?void 0:j.efforts.find(D=>D!=="max");$&&T(C,N,$)}}),v.jsx(Jo,{label:"Reasoning effort","aria-label":`${C.role} reasoning effort`,"aria-busy":f||p!==null,data:[...(((_=(A=R.modelOptions)==null?void 0:A.find(N=>N.value===C.model))==null?void 0:_.efforts)??[]).filter(N=>N!=="max").map(N=>({value:N,label:ZN[N]??N})),...C.effort==="max"?[{value:"max",label:"Max (current setting)",disabled:!0}]:[]],value:typeof C.effort=="string"?C.effort:null,disabled:typeof C.model!="string",readOnly:f||p!==null,allowDeselect:!1,onChange:N=>{!f&&!p&&N&&N!=="max"&&typeof C.model=="string"&&T(C,C.model,N)}})]}),v.jsxs(Ee,{size:"sm",style:{overflowWrap:"anywhere"},children:["Source: ",C.displaySource??C.source??"No role file"]}),b===C.role&&v.jsx(Ee,{c:"dimmed",size:"sm",role:"status",children:"Saving…"}),C.problems.map(N=>v.jsx(Dn,{color:"red",children:N},N))]})},C.role)})]}),r&&v.jsx(ln,{className:"taskchef-section",withBorder:!0,p:"sm",children:v.jsxs(Vt,{gap:"xs",children:[v.jsx(Ut,{order:3,size:"h5",children:"Usage provider"}),v.jsxs(Ee,{size:"sm",children:[r.provider,r.version?` ${r.version}`:" version unavailable"]}),v.jsx(Ee,{c:"dimmed",size:"sm",children:"Version pinned by TaskChef for token and cost estimates."})]})})]})}const KN=50,FN="Turn interrupted before a terminal report.",FS=[{value:"",label:"All"},{value:"working",label:"Working"},{value:"needs input",label:"Needs input"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}],PN=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,JN=new Map([["created","Task created"],["task_started","Task started"],["follow_up_started","Follow-up started"],["completed","Task completed"],["needs_input","Task needs input"],["failed","Task failed"],["manual_completed","Task manually completed"],["manual_failed","Task manually failed"],["archive_succeeded","Chat archived"],["archive_failed","Chat archive failed"],["unresolved","Task updated"]]),WN=new Map([["24h",1440*60*1e3],["7d",10080*60*1e3],["all",null]]);function e_(n){return Date.parse(n.meaningfulUpdatedAt??n.updatedAt??n.createdAt)}function PS(n){return n.status===null?"unresolved":n.status.replaceAll("_"," ")}function t_(n){return typeof n.threadId=="string"&&PN.test(n.threadId)}function n_(n){return{status:n.status,turnRef:n.turnRef,threadId:n.threadId,updatedAt:n.updatedAt}}function l_(n,l){return!!l&&n.status===l.status&&n.turnRef===l.turnRef&&n.threadId===l.threadId&&n.updatedAt===l.updatedAt}function kb({requestTask:n,expected:l,responseTask:r,selectedTask:o}){const s=(o==null?void 0:o.id)===n.id?o:n;return l_(s,l)?r??s:s}function JS(n){var s;const l=n.latestTurn??null,r=(l==null?void 0:l.result)??null,o=(l==null?void 0:l.requestSummary)??(l?"Request not recorded by this TaskChef version.":n.title);return{turnRef:(l==null?void 0:l.turnRef)??(l==null?void 0:l.turnId)??n.turnRef??n.turnId??null,turnId:(l==null?void 0:l.turnId)??n.turnId??null,startedAt:(l==null?void 0:l.startedAt)??n.updatedAt??n.createdAt??null,requestSummary:o,resultStatus:(r==null?void 0:r.status)??(n.status==="working"?"working":n.status),resultSummary:(r==null?void 0:r.summary)??(n.status==="working"?"In progress":((s=n.lastResult)==null?void 0:s.summary)??n.summary??"No result reported."),resultUpdatedAt:(r==null?void 0:r.updatedAt)??null}}function a_(n){var r;const l=n.result??null;return{status:(l==null?void 0:l.status)??"working",summary:(l==null?void 0:l.summary)??"In progress",updatedAt:(l==null?void 0:l.updatedAt)??n.startedAt,...((r=n.provenance)==null?void 0:r.kind)==="dashboard_manual"?{sourceLabel:"Manual dashboard change"}:{}}}function o_(n,l=[]){if(Array.isArray(n.turns))return n.turns;if(!n.latestTurn)return l;const r=[...l],o=r.length-1,s=n.latestTurn.turnRef??n.latestTurn.turnId,c=o>=0?r[o].turnRef??r[o].turnId:null,f=o>=0&&c===null&&s!==null&&r[o].turnId==null&&n.latestTurn.turnId==null&&JSON.stringify({...r[o],turnRef:null})===JSON.stringify({...n.latestTurn,turnRef:null});return o>=0&&(c===s||f)?r[o]=n.latestTurn:(n.schemaVersion>=8&&o>=0&&r[o].result===null&&(r[o]={...r[o],result:{status:"interrupted",summary:FN,updatedAt:n.latestTurn.startedAt}}),r.push(n.latestTurn)),r}function lu(n){return JN.get(n.event)??"Task updated"}function r_(n,l,r=Date.now()){const o=WN.get(l);if(o===null)return!0;if(o===void 0)return!1;const s=e_(n);return Number.isFinite(s)&&s>=r-o}function gm(n,{project:l="",status:r="",date:o="all",now:s=Date.now()}={}){return n.filter(c=>(!l||c.project.name===l)&&(!r||PS(c)===r)&&r_(c,o,s))}function i_(n,{project:l="",date:r="all",now:o=Date.now()}={}){const s=gm(n,{project:l,date:r,now:o});return Object.fromEntries(FS.map(({value:c})=>[c,c?s.filter(f=>PS(f)===c).length:s.length]))}function s_(n){return JSON.stringify([n.id,n.turnRef??n.turnId??null,n.turnId??null,n.status??"unresolved"])}function c_(n,l){try{const r=JSON.parse(n),o=JSON.parse(l);return Array.isArray(r)&&Array.isArray(o)&&r.length===o.length&&r[1]===null&&o[1]!==null&&r[2]===null&&o[2]===null&&r[3]!=="working"&&r.every((s,c)=>c===1||s===o[c])}catch{return!1}}function u_(n){var l,r;return n.status==="working"?n.lastResult?"follow_up_started":"task_started":((r=(l=n.latestTurn)==null?void 0:l.provenance)==null?void 0:r.kind)==="dashboard_manual"?`manual_${n.status}`:n.status??"unresolved"}function WS(n,l){return JSON.stringify(l==="created"?[n.id,null,l,n.createdAt??null]:[n.id,n.turnRef??n.turnId??null,l])}function f_(n,l){var r,o,s;return l==="created"?n.createdAt??n.updatedAt??null:((r=n.lastResult)==null?void 0:r.status)===n.status&&(((o=n.lastResult)==null?void 0:o.turnRef)??((s=n.lastResult)==null?void 0:s.turnId))===(n.turnRef??n.turnId)?n.lastResult.updatedAt:n.updatedAt??n.createdAt??null}function d_(n,l){var r,o,s;return["completed","needs_input","failed","manual_completed","manual_failed"].includes(l)?((r=n.lastResult)==null?void 0:r.status)===n.status&&(((o=n.lastResult)==null?void 0:o.turnRef)??((s=n.lastResult)==null?void 0:s.turnId))===(n.turnRef??n.turnId)?n.lastResult.summary:n.summary??null:null}function Yo(n,l=u_(n)){const r=l==="created";return Object.freeze({id:WS(n,l),taskId:n.id,title:n.title,status:r?"working":n.status,event:l,turnRef:r?null:n.turnRef??n.turnId??null,turnId:r?null:n.turnId??null,timestamp:f_(n,l),summary:d_(n,l)})}function Js(n){var o;const l=n.lastResult;if(!l)return null;const r=((o=l.provenance)==null?void 0:o.kind)==="dashboard_manual"?`manual_${l.status}`:l.status;return Object.freeze({id:WS({...n,turnRef:l.turnRef??l.turnId,turnId:l.turnId},r),taskId:n.id,title:n.title,status:l.status,event:r,turnRef:l.turnRef??l.turnId??null,turnId:l.turnId??null,timestamp:l.updatedAt,summary:l.summary})}function m_(n,l){return`${l?"Open current task details":"Show task availability"} for ${n.title}: ${lu(n)}`}function p_(n){return`Dismiss ${lu(n)} notification for ${n.title}`}function Bb(n,l){return n.filter(({id:r})=>r!==l)}function h_({initialized:n,notifications:l,seenIds:r=new Set,signatures:o},s){const c=new Map(o);for(const p of s)c.set(p.id,s_(p));const f=new Set(r);if(!n){for(const p of s){f.add(Yo(p,"created").id);const h=Js(p);h&&f.add(h.id),f.add(Yo(p).id)}return{additions:[],notifications:l,seenIds:f,signatures:c}}const d=[];for(const p of s){const h=[];if(o.has(p.id)){if(o.get(p.id)!==c.get(p.id)&&!c_(o.get(p.id),c.get(p.id))){h.push(Yo(p));const y=Js(p);y&&h.push(y)}}else{const y=Js(p);(p.turnRef||p.turnId||p.status!=="working"||y)&&(h.push(Yo(p)),y&&h.push(y)),h.push(Yo(p,"created"))}for(const y of h)f.has(y.id)||d.push(y),f.add(y.id);const b=Js(p);b&&f.add(b.id),f.add(Yo(p).id)}return{additions:d,notifications:[...d,...l].slice(0,KN),seenIds:f,signatures:c}}function g_(n,l,r){const o=n.notifications.filter(({id:s})=>s!==l.id);return r?{...n,detailTaskId:l.taskId,detailOpened:!0,highlightTurnRef:l.turnRef??l.turnId,notifications:o,refreshGeneration:n.refreshGeneration+1}:{...n,notifications:o}}function Hb(n){return{...n,notifications:[]}}function Ub(n,l){const r=Array.isArray(n.turns)&&Array.isArray(n.results),o=!Array.isArray(l.turns)&&!Array.isArray(l.results);return{...n,...l,...r&&o?{results:n.results,turns:n.turns,usage:n.usage}:{}}}function Ws(n){var l,r,o,s,c,f,d;return JSON.stringify([((l=n==null?void 0:n.usage)==null?void 0:l.generationTurnRef)??null,((r=n==null?void 0:n.usage)==null?void 0:r.status)??null,((o=n==null?void 0:n.usage)==null?void 0:o.updatedAt)??null,((c=(s=n==null?void 0:n.usage)==null?void 0:s.task)==null?void 0:c.totalTokens)??null,((d=(f=n==null?void 0:n.usage)==null?void 0:f.task)==null?void 0:d.estimatedCostUsd)??null])}const v_=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?(Z|[+-]\d{2}:\d{2})$/;function ex(n,l){const r=Vb(n),o=Vb(l);if(r===null||o===null)return null;const s=o-r;return s>=0?s:null}function tx(n){var r;const l=ex(n.startedAt,(r=n.result)==null?void 0:r.updatedAt);return l===0?null:l}function y_(n){const l=n.filter(s=>s.result!==null),r=l.map(tx).filter(s=>s!==null),o=r.length===0?l.length===0?0:null:r.reduce((s,c)=>s+c,0);return Object.freeze({terminalTurns:l.length,validTurns:r.length,totalMilliseconds:o===null||Number.isSafeInteger(o)?o:null})}function Vb(n){if(typeof n!="string")return null;const l=n.match(v_);if(!l)return null;const[,r,o,s,c,f,d,,p]=l,h=Number(r),b=Number(o),y=Number(s),g=Number(c),w=Number(f),R=Number(d),T=p==="Z"?0:Number(p.slice(1,3)),C=p==="Z"?0:Number(p.slice(4,6)),_=[31,h%4===0&&(h%100!==0||h%400===0)?29:28,31,30,31,30,31,31,30,31,30,31];if(b<1||b>12||y<1||y>_[b-1]||g>23||w>59||R>59||T>23||C>59)return null;const N=Date.parse(n);return Number.isFinite(N)?N:null}const vm=1e3,ym=60*vm,bm=60*ym,b_=24*bm,xn="n/a";function nx(n){if(!Number.isFinite(n)||n<0)return null;if(n>0&&n<vm)return"<1s";const l=Math.floor(n/vm);if(n<ym)return`${l}s`;if(n<bm)return`${Math.floor(l/60)}m ${l%60}s`;const r=Math.floor(n/ym);if(n<b_)return`${Math.floor(r/60)}h ${r%60}m`;const o=Math.floor(n/bm);return`${Math.floor(o/24)}d ${o%24}h`}function lx(n){const l=n.turns===void 0?n.reportedWork:y_(n.turns??[]);if(l===void 0)return{accessibleLabel:"Reported work unavailable because terminal turn history is not available.",kind:"unavailable",title:"Reported wall-clock elapsed time requires the terminal turn history from the task detail projection.",value:xn};if(l.terminalTurns===0)return{accessibleLabel:"Reported work not yet reported. Unfinished turns are excluded.",kind:"not-reported",title:"Reported wall-clock elapsed time is added only after a turn reaches a terminal state.",value:xn};if(l.validTurns===0)return{accessibleLabel:"Reported work unavailable because completed turn timestamps are missing or invalid.",kind:"unavailable",title:"Reported wall-clock elapsed time is unavailable because no terminal turn has a valid start and end timestamp.",value:xn};const r=l.totalMilliseconds===null?null:nx(l.totalMilliseconds);if(r===null)return{accessibleLabel:"Reported work unavailable because the duration total is outside the supported range.",kind:"unavailable",title:"Reported wall-clock elapsed time is unavailable because the duration total is outside the supported range.",value:xn};const o=l.terminalTurns-l.validTurns,s=o>0?` ${o} terminal ${o===1?"turn was":"turns were"} unavailable and excluded.`:"";return{accessibleLabel:`Reported work ${r}. This is reported wall-clock elapsed time.${s}`,kind:"available",title:`Sum of valid terminal-turn wall-clock elapsed times; unfinished turns and idle gaps are excluded.${s}`,value:r}}function S_(n,l=Date.now()){const r=n.result===null,o=r?ex(n.startedAt,new Date(l).toISOString()):tx(n),s=r?"Elapsed so far":"Elapsed",c=o===null?xn:nx(o)??xn;return{accessibleLabel:`${s} ${o===null?"unavailable":c}. ${r?"Current":"Completed"} turn reported wall-clock elapsed time.`,kind:o===null?"unavailable":"available",label:s,title:o===null?"Reported wall-clock elapsed time is unavailable because the turn timestamps are missing, invalid, or reversed.":`Reported wall-clock elapsed time from startedAt ${r?"to the current time":"to result.updatedAt"}.`,value:c}}function au(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2,notation:"compact"}).format(n)}function pi(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2}).format(n)}function Wo(n,l){return typeof n!="number"||!Number.isFinite(n)?"—":new Intl.NumberFormat(l,{currency:"USD",currencyDisplay:"narrowSymbol",maximumFractionDigits:2,minimumFractionDigits:2,style:"currency"}).format(n)}function ax(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2,minimumFractionDigits:2}).format(n)}function ox(n){var s;const l=n.usage,r=n.turnRef??((s=n.latestTurn)==null?void 0:s.turnRef)??null,o=(l==null?void 0:l.generationTurnRef)!=null&&r!=null&&l.generationTurnRef!==r;return n.status==="working"?l!=null&&l.task?Kd(l.task,!0):{kind:"pending",label:"Token usage pending"}:(l==null?void 0:l.status)==="calculating"||o?l.task?Kd(l.task,!0):{kind:"calculating",label:"Calculating token usage"}:(l==null?void 0:l.status)==="available"&&l.task?Kd(l.task,!1):!l&&n.threadId&&["completed","failed","needs_input"].includes(n.status??"")?{kind:"calculating",label:"Calculating token usage"}:{kind:"unavailable",label:(l==null?void 0:l.reason)??"Token usage unavailable"}}function Kd(n,l){const r=au(n.totalTokens),o=n.estimatedCostUsd==null?"Estimated cost n/a":`Estimated cost ${Wo(n.estimatedCostUsd)}`;return{kind:"ready",knownSoFar:l,label:`${r} tokens · ${o}${l?" · known so far":""}`,usage:n}}function x_(n,l){var s,c;if(l.result===null)return{kind:"pending",label:"Turn usage pending"};const r=l.turnRef??l.turnId,o=r?(c=(s=n.usage)==null?void 0:s.turns)==null?void 0:c[r]:null;if((o==null?void 0:o.status)==="calculating")return{kind:"calculating",label:"Calculating turn usage"};if((o==null?void 0:o.status)==="available"&&typeof o.totalTokens=="number"){const f=pi(o.totalTokens),d=o.estimatedCostUsd==null?"Estimated cost n/a":`Estimated cost ${Wo(o.estimatedCostUsd)}`;return{kind:"ready",label:`${f} tokens · ${d}`}}return{kind:"unavailable",label:(o==null?void 0:o.reason)??"Turn usage unavailable"}}function w_(n,l){var c,f;const r=x_(n,l);if(r.kind==="ready"){const d=l.turnRef??l.turnId,p=d?(f=(c=n.usage)==null?void 0:c.turns)==null?void 0:f[d]:null,h=typeof(p==null?void 0:p.totalTokens)=="number"?pi(p.totalTokens):xn,b=typeof(p==null?void 0:p.totalTokens)=="number"?au(p.totalTokens):xn,y=p==null?void 0:p.estimatedCostUsd,g=typeof y=="number"&&Number.isFinite(y),w=g?ax(y):xn;return{animated:!1,cost:{accessibleLabel:`Estimated cost ${g?Wo(y).toLowerCase():"unavailable"}`,value:w},kind:r.kind,note:null,title:r.label,tokens:{accessibleLabel:`${h} tokens`,value:b}}}const o=r.kind==="pending"?"Pending":r.kind==="calculating"?"Calculating":xn,s=r.kind==="unavailable"?"unavailable":o.toLowerCase();return{animated:r.kind==="pending"||r.kind==="calculating",cost:{accessibleLabel:`Estimated cost ${s}${r.kind==="unavailable"?`: ${r.label}`:""}`,value:o},kind:r.kind,note:r.kind==="unavailable"&&r.label!=="Turn usage unavailable"?r.label:null,title:r.label,tokens:{accessibleLabel:`Tokens ${s}${r.kind==="unavailable"?`: ${r.label}`:""}`,value:o}}}function C_(n){var l,r;return n.status!=="working"&&(((l=n.usage)==null?void 0:l.status)==="calculating"||Object.values(((r=n.usage)==null?void 0:r.turns)??{}).some(o=>o.status==="calculating"))}function T_(n){var R;const l=ox(n);if(l.kind==="pending"||l.kind==="calculating"){const T=l.kind==="pending"?"Pending":"Calculating";return{cost:{accessibleLabel:`Estimated cost ${T.toLowerCase()}`,animated:!0,title:l.label,value:T},kind:l.kind,tokens:{accessibleLabel:`Tokens ${T.toLowerCase()}`,animated:!0,title:l.label,value:T}}}if(l.kind==="unavailable"){const T=l.label==="Token usage unavailable"?"":`: ${l.label}`;return{cost:{accessibleLabel:`Estimated cost unavailable${T}`,animated:!1,title:l.label,value:xn},kind:"unavailable",tokens:{accessibleLabel:`Token usage unavailable${T}`,animated:!1,title:l.label,value:`${xn} tokens`}}}const r=au(l.usage.totalTokens),o=pi(l.usage.totalTokens),s=l.usage.estimatedCostUsd,c=typeof s=="number"&&Number.isFinite(s),f=c?Wo(s):null,d=c?ax(s):null,p=l.knownSoFar?" · Updating…":"",h=l.knownSoFar?"; updating":"",b=c?p:"",y=c?h:"",g=l.usage.sourceUpdatedAt??l.usage.sampledAt??((R=n.usage)==null?void 0:R.updatedAt)??null,w=g&&!Number.isNaN(Date.parse(g))?` Cached usage updated ${new Date(g).toLocaleString()}.`:"";return{cost:{accessibleLabel:`Estimated cost ${f??"unavailable"}${y}.${w}`,animated:l.knownSoFar&&c,title:`${f===null?"Estimated cost unavailable":`Unrounded estimate: $${l.usage.estimatedCostUsd}`}${b}.${w}`,value:d??xn},kind:"ready",tokens:{accessibleLabel:`${o} tokens${h}.${w}`,animated:l.knownSoFar,title:`${o} tokens${p}.${w}`,value:`${r} tokens`}}}function R_(n){return n==="completed"?"teal":n==="needs_input"?"yellow":n==="failed"?"red":n==="working"?"blue":"gray"}function E_(n){return n===null?"Unresolved":n.replaceAll("_"," ")}const Fd=30,ai=6e4,pc=60*ai,Ga=24*pc;function rx(n){if(typeof n!="string"||n.trim()==="")return null;const l=Date.parse(n);return Number.isFinite(l)?{date:new Date(l),iso:new Date(l).toISOString(),milliseconds:l}:null}function Sm(n,{locale:l,timeZone:r}={}){const o=rx(n);return o?new Intl.DateTimeFormat(l,{dateStyle:"medium",timeStyle:"short",timeZone:r}).format(o.date):"—"}function A_(n,l){const r=Math.floor(n/pc),o=r===1?"1 hour":`${r} hours`;return l==="future"?`in ${o}`:`${o} ago`}function hc(n,{now:l=Date.now(),locale:r,timeZone:o}={}){const s=rx(n);if(!s)return"—";const c=l-s.milliseconds,f=c<0,d=Math.abs(c);if(d<ai)return"just now";if(d<2*ai)return f?"in 1 minute":"1 minute ago";if(d<pc){const b=f?Math.ceil(d/ai):Math.floor(d/ai);return f?`in ${b} minutes`:`${b} minutes ago`}if(d<2*pc)return f?"in 1 hour":"1 hour ago";if(d<Ga)return A_(d,f?"future":"past");if(d<2*Ga)return f?"in 1 day":"1 day ago";if(d<Fd*Ga){const b=f?Math.ceil(d/Ga):Math.floor(d/Ga);return f?`in ${b} days`:`${b} days ago`}const p=f?Math.ceil(d/(Fd*Ga)):Math.floor(d/(Fd*Ga)),h=p===1?"1 month":`${p} months`;return f?`in ${h}`:`${h} ago`}function ou({status:n}){return v.jsx(Ai,{className:"taskchef-status-badge",color:R_(n),size:"sm",variant:"light",children:E_(n)})}function Yb({notifications:n,announcements:l=n,onClear:r,onDismiss:o,onOpen:s,tasks:c,withinPortal:f=!0}){if(n.length===0)return null;const d=v.jsxs(v.Fragment,{children:[v.jsxs(ln,{"aria-label":"Task notifications",className:"taskchef-notifications",p:"sm",radius:"md",role:"region",shadow:"xl",withBorder:!0,children:[v.jsxs(yt,{justify:"space-between",mb:"xs",children:[v.jsxs(yt,{gap:6,children:[v.jsx(vN,{"aria-hidden":!0,size:16}),v.jsx(Ee,{fw:700,size:"sm",children:"Updates"})]}),v.jsx(Zn,{onClick:r,size:"compact-xs",variant:"subtle",children:"Clear all"})]}),v.jsx(Xn.Autosize,{className:"taskchef-notification-scroll",mah:"min(55vh, 520px)",type:"auto",children:v.jsx(Vt,{className:"taskchef-notification-list",gap:6,children:n.map(p=>{const h=c.some(w=>w.id===p.taskId),b=`notification-${Math.abs(__(p.id))}`,y=`${b}-summary`,g=`${b}-metadata`;return v.jsx(ln,{className:"taskchef-notification",p:"xs",radius:"sm",children:v.jsxs(yt,{align:"flex-start",gap:"xs",wrap:"nowrap",children:[v.jsxs("button",{"aria-describedby":[p.summary?y:null,g].filter(Boolean).join(" "),"aria-label":m_(p,h),className:"taskchef-notification-open",onClick:()=>s(p),type:"button",children:[v.jsxs(yt,{gap:"xs",justify:"space-between",wrap:"nowrap",children:[v.jsx(Ee,{fw:700,size:"sm",children:lu(p)}),v.jsx(ou,{status:p.status})]}),v.jsx(Ee,{lineClamp:1,size:"sm",children:p.title}),p.summary&&v.jsx(Ee,{className:"taskchef-preserve-lines",id:y,lineClamp:3,size:"xs",children:p.summary}),v.jsxs(Ee,{c:"dimmed",id:g,size:"xs",children:[v.jsx($n,{label:Sm(p.timestamp),children:v.jsx("span",{children:hc(p.timestamp)})}),h?"":" · Task no longer available"]})]}),v.jsx($n,{label:"Dismiss notification",children:v.jsx(pl,{"aria-label":p_(p),color:"gray",onClick:()=>o(p),size:"compact-sm",variant:"subtle",children:v.jsx(KS,{"aria-hidden":!0,size:14})})})]})},p.id)})})})]}),v.jsx(fe,{"aria-atomic":"true","aria-live":"polite",className:"taskchef-visually-hidden",role:"status",children:l.map(N_).join(" ")})]});return f?v.jsx(lp,{children:d}):d}function N_(n){return[lu(n),n.title,n.summary,n.turnRef?`Turn ref ${n.turnRef}`:null,hc(n.timestamp)].filter(Boolean).map(l=>String(l).replace(/[.\s]+$/,"")).join(". ")+"."}function __(n){let l=0;for(const r of n)l=(l<<5)-l+r.charCodeAt(0)|0;return l}const j_=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]+$/,M_=/https?:\/\/(?:www\.)?github\.com\/([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))\/([A-Za-z0-9._-]+)\/(issues|pull)\/([1-9]\d*)(?![A-Za-z0-9_])|([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))\/([A-Za-z0-9._-]+)#([1-9]\d*)(?![A-Za-z0-9_])|#([1-9]\d*)(?![A-Za-z0-9_])|https?:\/\/(?:www\.)?github\.com\/([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))\/([A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9_-])?)\/?(?=$|[\s#),.;:!?'"\]}>])/gi,O_=/https?:\/\/[^\s<>"'`]+/gi;function Qo(n){return!(n!=null&&n.owner)||!(n!=null&&n.repository)?null:`${n.owner.toLowerCase()}/${n.repository.toLowerCase()}`}function ix(n){const l=new Map;for(const r of n){const o=Qo(r);if(!o)continue;const s=r.repository.toLowerCase(),c=l.get(s)??new Set;c.add(o),l.set(s,c)}return new Set([...l].filter(([,r])=>r.size>1).map(([r])=>r))}function xm(n,l){return l.has(n.repository.toLowerCase())?`${n.owner}/${n.repository}`:n.repository}function sx(n,{related:l=!1}={}){const r=ix(n);let o=null;return n.map(s=>{if(s.provider!=="github"&&!s.owner)return s.label??s.text;const c=Qo(s),f=xm(s,r);if(s.type==="repository")return f;if(l){const d=c===o?`#${s.number}`:`${f} #${s.number}`;return o=c,d}return s.type==="pull"?`${f} PR #${s.number}`:s.type==="issue"?`${f} Issue #${s.number}`:`${f} #${s.number}`})}function z_(n,l){const r=String(n.number??""),o=String(l.number??"");return r.length-o.length||r.localeCompare(o)}function D_(n){const l=new Map,r=new Set,o=new Set,s=new Set;for(const f of n??[]){const d=Qo(f),p=f.number?`${d}#${f.number}`:null;if(f.type==="repository"||!d||r.has(f.label)||s.has(f.url)||p&&o.has(p))continue;r.add(f.label),s.add(f.url),p&&o.add(p);const h=l.get(d)??[];h.push(f),l.set(d,h)}const c=ix(n??[]);return[...l.values()].map(f=>[...f].sort(z_)).sort((f,d)=>{const p=xm(f[0],c),h=xm(d[0],c);return p.localeCompare(h,void 0,{sensitivity:"base"})||Qo(f[0]).localeCompare(Qo(d[0]))})}function cx(n){const l=Qo(n);return l?n.type==="repository"?l:n.type==="pull"?`${l} PR #${n.number}`:n.type==="issue"?`${l} Issue #${n.number}`:`${l} #${n.number}`:n.label??n.text}function ux(n,l){return`${n.toLowerCase()}/${l.toLowerCase()}`}function fx(n){return n!=="."&&n!==".."}function dx(n){if(typeof n!="string")return null;let l=n.trim();const r=l.match(/^https?:\/\/(?:www\.)?github\.com\/([^/?#]+)\/([^/?#]+?)(?:\.git)?\/?$/i);if(r&&(l=`${r[1]}/${r[2]}`),!j_.test(l))return null;const[o,s]=l.split("/");return fx(s)?ux(o,s):null}function $_(n){var s;const l=String(n??""),r=mx(l),o=[];for(const c of l.matchAll(M_)){const f=c.index,d=f>0?l[f-1]:"";let p=null;const h=r.find(C=>f>=C.start&&f<C.end);if(h){const C=!!(c[1]||c[9]);let A=null;try{A=new URL(h.text).hostname.toLowerCase()}catch{}if(!(C&&f===h.start&&(A==="github.com"||A==="www.github.com"))||!px(h.text))continue;p={end:h.end,suffix:h.text.slice(c[0].length),text:h.text}}if(c[8]&&/[\w&#/]/.test(d)||(c[5]||c[1]||c[9])&&/[\w/]/.test(d))continue;let b=c[1]??c[5]??c[9]??null,y=c[2]??c[6]??c[10]??null;c[9]&&(y=y.replace(/\.git$/i,""));const g=c[4]??c[7]??c[8]??null,w=(s=c[3])==null?void 0:s.toLowerCase(),R=c[9]?"repository":w==="pull"?"pull":w==="issues"?"issue":"generic",T=!!(b&&y);if(T){if(!fx(y))continue;[b,y]=ux(b,y).split("/")}o.push({end:(p==null?void 0:p.end)??f+c[0].length,explicit:T,number:g,owner:b,repository:y,start:f,text:(p==null?void 0:p.text)??c[0],type:R,urlSuffix:(p==null?void 0:p.suffix)??""})}return o}function L_(n){const l=new Set(n.filter(({explicit:r})=>r).map(({owner:r,repository:o})=>`${r}/${o}`));return l.size===1?[...l][0]:null}function k_(n){const l=new Set((n??[]).map(dx).filter(Boolean));return l.size===1?[...l][0]:null}function B_(n,l){const r=n.explicit?`${n.owner}/${n.repository}`:l;if(!r)return null;const[o,s]=r.split("/");if(n.type==="repository")return{kind:"link",label:`${o}/${s}`,number:null,owner:o,provider:"github",repository:s,text:n.text,type:n.type,url:`https://github.com/${o}/${s}${n.urlSuffix}`};const c=n.type==="pull"?"pull":"issues";return{kind:"link",label:`${o}/${s}#${n.number}`,number:n.number,owner:o,provider:"github",repository:s,text:n.text,type:n.type,url:`https://github.com/${o}/${s}/${c}/${n.number}${n.urlSuffix}`}}function H_(n){let l=n,r;do{r=l,l=l.replace(/[.,;:!?]+$/u,"");for(const[o,s]of[["(",")"],["[","]"],["{","}"]])for(;l.endsWith(s);){const c=[...l].filter(d=>d===o).length;if([...l].filter(d=>d===s).length<=c)break;l=l.slice(0,-1)}}while(l!==r);return l}function mx(n){const l=[];for(const r of String(n??"").matchAll(O_)){const o=H_(r[0]);o&&l.push({end:r.index+o.length,start:r.index,text:o})}return l}function U_(n){const l=n.slice(n.indexOf("//")+2).split(/[?#]/u,1)[0],r=l.indexOf("/");return r<0?!1:l.slice(r).split("/").some(o=>{try{const s=decodeURIComponent(o);return s==="."||s===".."}catch{return!0}})}function px(n){try{const l=new URL(n);return!l.hostname||l.username||l.password||n.includes("\\")||U_(n)?null:l.href}catch{return null}}function V_(n){const l=[];for(const r of mx(n)){const o=px(r.text);o&&l.push({end:r.end,kind:"link",label:r.text,provider:"web",start:r.start,text:r.text,type:"url",url:o})}return l}function Y_(n,{projectRepositories:l=[],taskRepository:r=null}={}){const o=String(n??""),s=$_(o),f=L_(s)??dx(r)??k_(l),d=[];let p=0;for(const h of s){h.start>p&&d.push({kind:"text",text:o.slice(p,h.start)});const b=B_(h,f);b?d.push(b):d.push({kind:"ambiguous",reason:`GitHub reference ${h.text} is not linked because the repository is ambiguous.`,text:h.text}),p=h.end}return p<o.length&&d.push({kind:"text",text:o.slice(p)}),d}function q_(n,l={}){const r=String(n??""),o=Y_(r,l),s=[];let c=0;for(const h of o){const b=r.indexOf(h.text,c);b<0||(h.kind!=="text"&&s.push({end:b+h.text.length,segment:h,start:b}),c=b+h.text.length)}const f=V_(r).filter(h=>!s.some(({end:b,start:y})=>h.start<b&&h.end>y));if(f.length===0)return o;s.push(...f.map(h=>({end:h.end,segment:h,start:h.start}))),s.sort((h,b)=>h.start-b.start);const d=[];let p=0;for(const h of s)h.start<p||(h.start>p&&d.push({kind:"text",text:r.slice(p,h.start)}),d.push(h.segment),p=h.end);return p<r.length&&d.push({kind:"text",text:r.slice(p)}),d}function hx({task:n}){const l=n.relatedGitHubLinks??[];if(l.length===0&&!n.relatedGitHubLinksTruncated)return null;const r=D_(l),o=sx(r.flat(),{related:!0});let s=0;return v.jsxs(fe,{"aria-label":`Related GitHub links for ${n.title}`,className:"taskchef-github-groups",component:"nav",children:[r.map(c=>v.jsx(yt,{className:"taskchef-github-group",gap:5,wrap:"wrap",children:c.map(f=>{const d=o[s];s+=1;const p=f.type==="pull"?", GitHub pull request":f.type==="issue"?", GitHub issue":" on GitHub";return v.jsx(Bc,{"aria-label":`${cx(f)}${p} (opens in a new tab)`,className:"taskchef-github-link",href:f.url,rel:"noopener noreferrer",size:"xs",target:"_blank",children:d},f.url)})},`${c[0].owner}/${c[0].repository}`)),n.relatedGitHubLinksTruncated&&v.jsx(Ee,{c:"dimmed",size:"xs",children:"More links in task history"})]})}function hi({task:n,text:l}){const r=q_(l,{projectRepositories:n.project.githubRepos,taskRepository:n.relatedGitHubRepository}),o=r.filter(f=>f.kind==="link"),s=sx(o);let c=0;return r.map((f,d)=>{if(f.kind==="text")return f.text;if(f.kind==="ambiguous")return v.jsx("span",{"aria-label":f.reason,className:"taskchef-github-reference-ambiguous",tabIndex:0,title:f.reason,children:f.text},`${d}:${f.text}`);const p=s[c];c+=1;const h=f.type==="pull"?", GitHub pull request":f.type==="issue"?", GitHub issue":f.owner?" on GitHub":"";return v.jsx(Bc,{"aria-label":`${cx(f)}${h} (opens in a new tab)`,className:"taskchef-github-link",href:f.url,rel:"noopener noreferrer",target:"_blank",children:p},`${d}:${f.url}`)})}function ru({children:n,className:l="",...r}){return v.jsx("span",{className:`taskchef-shimmer ${l}`.trim(),"data-animation":"text-shimmer",...r,children:n})}const gx=x.createContext(null);function G_({children:n,now:l}){return v.jsx(gx,{value:l,children:n})}function gi({icon:n,label:l,value:r}){const[o,s]=x.useState(!1);x.useContext(gx);const c=o?Sm(r):hc(r),f=Sm(r),d=f==="—",p=d?"Updated time unavailable":o?hc(r):f;return v.jsx($n,{events:{focus:!0,hover:!0,touch:!1},label:p,children:v.jsxs(Ul,{"aria-label":d?`${l}: unavailable.`:`${l}: ${c}. ${o?"Show relative time":"Show exact time"}`,className:"taskchef-time",disabled:d,onClick:()=>s(h=>!h),children:[n??v.jsx(CN,{"aria-hidden":!0,size:12}),v.jsx("bdi",{className:"taskchef-time-label",children:c})]})})}function vx({children:n,variant:l}){return v.jsx(fe,{className:`taskchef-stats taskchef-${l}-stats`,component:"div",children:n})}function va({children:n,usageState:l}){return v.jsx(fe,{className:"taskchef-stat","data-usage-state":l,children:n})}function Ko({accessibleLabel:n,animated:l=!1,icon:r,title:o,value:s}){return v.jsx($n,{events:{focus:!0,hover:!0,touch:!1},label:o,multiline:!0,children:v.jsxs(Ee,{"aria-label":n,className:"taskchef-stat-content",component:"span",size:"xs",tabIndex:0,children:[r,v.jsx("bdi",{children:l?v.jsx(ru,{children:s}):s})]})})}function X_({task:n}){const l=lx(n),r=T_(n);return v.jsxs(vx,{variant:"card",children:[v.jsx(va,{children:v.jsx(gi,{icon:v.jsx(IS,{"aria-hidden":!0,size:14}),label:`Updated time for ${n.title}`,value:n.meaningfulUpdatedAt??n.updatedAt})}),v.jsx(va,{children:v.jsx(Ko,{accessibleLabel:l.accessibleLabel,icon:v.jsx(ZS,{"aria-hidden":!0,size:14}),title:"Duration",value:l.value})}),v.jsxs(va,{usageState:r.kind,children:[v.jsx(Ko,{accessibleLabel:r.tokens.accessibleLabel,animated:r.tokens.animated,icon:v.jsx(QS,{"aria-hidden":!0,size:14}),title:"Tokens",value:r.tokens.value}),v.jsxs(Ee,{className:"taskchef-visually-hidden",component:"span",role:"status",children:[r.tokens.accessibleLabel,"; ",r.cost.accessibleLabel]})]}),v.jsx(va,{usageState:r.kind,children:v.jsx(Ko,{accessibleLabel:r.cost.accessibleLabel,animated:r.cost.animated,icon:v.jsx(XS,{"aria-hidden":!0,size:14}),title:"Estimated cost",value:r.cost.value})})]})}function I_({onOpenCodex:n,onOpenDetail:l,task:r}){const o=JS(r);return v.jsx(ln,{className:"taskchef-task-row",component:"article",pb:8,pt:"md",px:"sm",radius:"md",withBorder:!0,children:v.jsxs(Vt,{className:"taskchef-task-main",gap:"sm",children:[v.jsxs(fe,{children:[v.jsxs(fe,{className:"taskchef-card-heading",children:[v.jsx(Ut,{order:3,size:"h5",children:v.jsx("button",{className:"taskchef-title-button",onClick:()=>l(r),type:"button",children:r.title})}),v.jsx(Vt,{align:"flex-end",className:"taskchef-card-metadata",gap:4,children:v.jsx(ou,{status:r.status})})]}),v.jsx(Ee,{c:"dimmed",mt:2,size:"xs",children:r.project.name})]}),v.jsxs(fe,{className:"taskchef-summary-grid",children:[v.jsx(Ee,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Request"}),v.jsx(Ee,{className:"taskchef-preserve-lines",lineClamp:3,size:"sm",children:v.jsx(hi,{task:r,text:o.requestSummary})}),v.jsx(Ee,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Result"}),v.jsx(Ee,{className:"taskchef-preserve-lines",lineClamp:3,size:"sm",children:o.resultStatus==="working"?v.jsx(ru,{children:o.resultSummary}):v.jsx(hi,{task:r,text:o.resultSummary})})]}),v.jsx(hx,{task:r}),v.jsxs(fe,{className:"taskchef-list-card-footer",children:[v.jsx(X_,{task:r}),v.jsx("button",{"aria-label":`Open chat for ${r.title}`,className:"taskchef-board-chat",onClick:()=>n(r),title:"Open chat",type:"button",children:v.jsx(Hp,{"aria-hidden":!0,size:19,stroke:1.6})})]})]})})}const Z_=[{status:"working",label:"Working"},{status:"needs_input",label:"Needs input"},{status:"completed",label:"Completed"},{status:"failed",label:"Failed"},{status:null,label:"Unresolved"}],Q_=new Set(["working","needs_input","completed","failed"]);function qb(n){return Q_.has(n.status)?n.status:null}function K_({completedLimit:n,onMoreCompleted:l,onOpenCodex:r,onOpenDetail:o,tasks:s}){const c=x.useRef(null),f=x.useRef(null),d=x.useRef(!1);function p(g){if(g.pointerType!=="mouse"||g.button!==0||!g.isPrimary||g.target.closest("button, a, input, textarea, select, [contenteditable], .taskchef-board-card, h1, h2, h3, p, span"))return;const R=c.current;!R||R.scrollWidth<=R.clientWidth||(f.current={pointerId:g.pointerId,startX:g.clientX,scrollLeft:R.scrollLeft,moved:!1},R.setPointerCapture(g.pointerId))}function h(g){const w=f.current,R=c.current;if(!w||!R||w.pointerId!==g.pointerId)return;const T=g.clientX-w.startX;!w.moved&&Math.abs(T)<6||(w.moved||(w.moved=!0,R.classList.add("taskchef-board-dragging")),g.preventDefault(),R.scrollLeft=w.scrollLeft-T)}function b(g){const w=f.current,R=c.current;!w||!R||w.pointerId!==g.pointerId||(f.current=null,R.classList.remove("taskchef-board-dragging"),R.hasPointerCapture(g.pointerId)&&R.releasePointerCapture(g.pointerId),w.moved&&(d.current=!0,window.setTimeout(()=>{d.current=!1},0)))}const y=Z_.filter(g=>g.status!==null||s.some(w=>qb(w)===null));return v.jsx(fe,{"aria-label":"Task board",className:"taskchef-board",component:"section",onClickCapture:g=>{d.current&&(g.preventDefault(),g.stopPropagation(),d.current=!1)},onPointerCancel:b,onPointerDown:p,onPointerMove:h,onPointerUp:b,ref:c,tabIndex:0,children:y.map(({status:g,label:w})=>{const R=s.filter(C=>qb(C)===g),T=g==="completed"?R.slice(0,n):R;return v.jsxs(fe,{"aria-label":`${w}, ${R.length} tasks`,className:"taskchef-board-lane",component:"section",children:[v.jsxs(fe,{className:"taskchef-board-lane-heading",children:[v.jsx(Ut,{order:2,size:"h5",children:w}),v.jsx(Ee,{"aria-label":`${R.length} tasks`,c:"dimmed",size:"sm",children:R.length})]}),v.jsxs(Vt,{gap:"sm",children:[T.map(C=>v.jsx(F_,{onOpenCodex:r,onOpenDetail:o,task:C},C.id)),R.length===0&&v.jsx(Ee,{c:"dimmed",className:"taskchef-board-empty",size:"sm",children:"No tasks"}),g==="completed"&&R.length>T.length&&v.jsxs(Zn,{className:"taskchef-board-more",onClick:l,size:"compact-sm",variant:"subtle",children:["Show ",Math.min(5,R.length-T.length)," more · ",T.length," of ",R.length]})]})]},w)})})}function F_({task:n,onOpenCodex:l,onOpenDetail:r}){const o=JS(n),s=n.status==="working"?o.requestSummary:o.resultSummary,c=t_(n);return v.jsxs(ln,{className:"taskchef-board-card",component:"article",px:"sm",pt:"sm",pb:6,withBorder:!0,children:[v.jsx(Ut,{className:"taskchef-board-title",order:3,size:"h5",children:v.jsx("button",{className:"taskchef-title-button",onClick:()=>r(n),type:"button",children:n.title})}),v.jsx(Ee,{className:"taskchef-board-project",size:"xs",children:n.project.name}),v.jsx(Ee,{className:"taskchef-board-excerpt taskchef-preserve-lines",size:"sm",children:v.jsx(hi,{task:n,text:s})}),v.jsxs(fe,{className:"taskchef-board-card-footer",children:[v.jsx(gi,{label:"Updated time",value:n.meaningfulUpdatedAt??n.updatedAt}),c?v.jsx("button",{"aria-label":`Open chat for ${n.title}`,className:"taskchef-board-chat",onClick:()=>l(n),title:"Open chat",type:"button",children:v.jsx(Hp,{"aria-hidden":!0,size:19,stroke:1.6})}):n.status==="working"?v.jsx(Ee,{c:"dimmed",className:"taskchef-board-link-pending",size:"xs",children:"Chat link pending"}):null]})]})}function P_({highlightTurnRef:n,task:l}){const r=o_(l,[]);return r!=null&&r.length?v.jsx(Vt,{gap:"sm",children:[...r].reverse().map((o,s)=>{const c=a_(o),f=o.turnRef??o.turnId??`turn-${s}`,d=f===n,p=w_(l,o);return v.jsx(ln,{className:`taskchef-turn${d?" taskchef-turn-highlighted":""}`,"data-turn-ref":f,p:"sm",radius:"md",tabIndex:d?-1:void 0,withBorder:!0,children:v.jsxs(Vt,{gap:7,children:[v.jsxs(fe,{className:"taskchef-turn-heading",children:[v.jsx(Ee,{c:"dimmed",size:"xs",children:c.sourceLabel}),v.jsx(ou,{status:c.status})]}),v.jsxs(fe,{children:[v.jsx(Ee,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Request"}),v.jsx(Ee,{className:"taskchef-preserve-lines",size:"sm",children:v.jsx(hi,{task:l,text:o.requestSummary??"Request not recorded."})})]}),v.jsxs(fe,{children:[v.jsx(Ee,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Result"}),v.jsx(Ee,{className:"taskchef-preserve-lines",size:"sm",children:c.status==="working"?v.jsx(ru,{children:c.summary}):v.jsx(hi,{task:l,text:c.summary})})]}),v.jsxs(vx,{variant:"turn",children:[v.jsx(va,{children:v.jsx(gi,{icon:v.jsx(IS,{"aria-hidden":!0,size:14}),label:"Turn update time",value:c.updatedAt})}),v.jsx(va,{children:v.jsx(J_,{turn:o})}),v.jsx(va,{usageState:p.kind,children:v.jsx(Ko,{accessibleLabel:p.tokens.accessibleLabel,animated:p.animated,icon:v.jsx(QS,{"aria-hidden":!0,size:14}),title:"Tokens",value:p.tokens.value})}),v.jsx(va,{usageState:p.kind,children:v.jsx(Ko,{accessibleLabel:p.cost.accessibleLabel,animated:p.animated,icon:v.jsx(XS,{"aria-hidden":!0,size:14}),title:"Estimated cost",value:p.cost.value})})]}),p.note&&v.jsx(Ee,{c:"dimmed",size:"xs",children:p.note})]})},f)})}):v.jsx(Ee,{c:"dimmed",size:"sm",children:"No turn history has been recorded."})}function J_({turn:n}){const l=W_(n.result===null),r=S_(n,l);return v.jsx(Ko,{accessibleLabel:r.accessibleLabel,icon:v.jsx(ZS,{"aria-hidden":!0,size:14}),title:"Duration",value:r.value})}function W_(n){const[l,r]=x.useState(()=>Date.now());return x.useEffect(()=>{if(!n)return;r(Date.now());const o=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(o)},[n]),l}function ej({loading:n,onClick:l,taskTitle:r}){return v.jsx(Zn,{"aria-label":`Open chat for ${r}`,className:"taskchef-open-chat",leftSection:v.jsx(Hp,{"aria-hidden":!0,size:15,stroke:1.6}),loading:n,onClick:l,size:"compact-sm",variant:"default",children:"Open chat"})}function tj({task:n}){const l=ox(n),r=lx(n),o=l.kind==="ready"?l:null,s=Object.keys((o==null?void 0:o.usage.models)??{}).join(", "),c=o==null?void 0:o.usage.estimatedCostUsd,f=typeof c=="number"&&Number.isFinite(c),d=l.kind==="pending"?"Pending":l.kind==="calculating"?"Calculating":"n/a",p=l.kind==="unavailable"?"unavailable":d.toLowerCase(),h=[{accessibleValue:o?`${pi(o.usage.totalTokens)} tokens`:l.label,animated:l.kind==="pending"||l.kind==="calculating"||(o==null?void 0:o.knownSoFar),label:"Tokens",title:o?`${pi(o.usage.totalTokens)} tokens`:l.label,value:o?au(o.usage.totalTokens):d},{accessibleValue:o?o.usage.estimatedCostUsd==null?"Estimated cost unavailable":`Estimated cost ${Wo(o.usage.estimatedCostUsd)}`:`Estimated cost ${p}${l.kind==="unavailable"?`: ${l.label}`:""}`,animated:l.kind==="pending"||l.kind==="calculating"||(o==null?void 0:o.knownSoFar)&&f,label:"Estimated cost",title:(o==null?void 0:o.usage.estimatedCostUsd)==null?"Estimated cost unavailable":`Unrounded estimate: $${o.usage.estimatedCostUsd}`,value:o?o.usage.estimatedCostUsd==null?"n/a":Wo(o.usage.estimatedCostUsd):d},{accessibleValue:r.accessibleLabel,label:"Duration",title:r.title,value:r.value},{accessibleValue:s||"Models unavailable",label:"Models",title:s||"Models unavailable",value:s||"n/a"}];return v.jsxs(fe,{"aria-live":"polite",children:[v.jsx(fe,{className:"taskchef-metrics",children:h.map(({accessibleValue:b,animated:y,label:g,title:w,value:R})=>v.jsxs(ln,{className:"taskchef-metric",p:"sm",radius:"md",withBorder:!0,children:[v.jsx(Ee,{c:"dimmed",size:"xs",children:g}),v.jsx(Ee,{"aria-label":b,className:"taskchef-metric-value",fw:650,size:"sm",title:w,children:y?v.jsx(ru,{children:R}):R})]},g))}),l.kind==="unavailable"&&l.label!=="Token usage unavailable"&&v.jsx(Ee,{c:"dimmed",mt:"xs",size:"xs",children:l.label})]})}function nj({busy:n,error:l,highlightTurnRef:r,onClose:o,onCopy:s,onOpenCodex:c,onTransition:f,opened:d,task:p,notifications:h,notice:b}){var C;const y=Nm("(max-width: 48em)"),[g,w]=x.useState(null);if(x.useEffect(()=>{d||w(null)},[d]),x.useEffect(()=>{d&&r&&requestAnimationFrame(()=>{var A;(A=document.querySelector(`[data-turn-ref="${CSS.escape(r)}"]`))==null||A.focus()})},[r,d,(C=p==null?void 0:p.turns)==null?void 0:C.length,p==null?void 0:p.updatedAt]),x.useEffect(()=>{g&&(!p||!Gb(p).includes(g))&&w(null)},[g,p==null?void 0:p.status]),!p)return null;const R=Gb(p),T=v.jsxs(Vt,{gap:"lg",children:[h,v.jsxs(fe,{children:[v.jsxs(yt,{align:"flex-start",gap:"sm",justify:"space-between",wrap:"nowrap",children:[v.jsxs(fe,{children:[v.jsx(Ee,{c:"teal",fw:700,size:"xs",tt:"uppercase",children:p.project.name}),v.jsx(Ut,{id:"task-detail-title",order:2,size:"h3",tabIndex:-1,children:p.title})]}),v.jsx(ou,{status:p.status})]}),v.jsxs(yt,{gap:"xs",mt:"md",children:[v.jsx(ej,{loading:n,onClick:c,taskTitle:p.title}),v.jsxs(bt,{position:"bottom-start",shadow:"md",withinPortal:!0,zIndex:360,children:[v.jsx(bt.Target,{children:v.jsx($n,{label:"More task actions",children:v.jsx(pl,{"aria-label":"More task actions",className:"taskchef-detail-more",disabled:n,variant:"default",children:v.jsx(EN,{"aria-hidden":!0,size:17})})})}),v.jsxs(bt.Dropdown,{children:[v.jsx(bt.Item,{leftSection:v.jsx(xN,{size:14}),onClick:s,children:"Copy Task ID"}),R.includes("completed")&&v.jsx(bt.Item,{leftSection:v.jsx(bN,{size:14}),onClick:()=>w("completed"),children:"Mark completed"}),R.includes("failed")&&v.jsx(bt.Item,{color:"red",leftSection:v.jsx(KS,{size:14}),onClick:()=>w("failed"),children:"Mark failed"})]})]})]}),v.jsx(fe,{mt:"sm",children:v.jsx(hx,{task:p})})]}),g&&v.jsx(lj,{busy:n,onCancel:()=>w(null),onTransition:f,status:g},g),b&&v.jsx(Dn,{color:"teal",role:"status",children:b}),l&&v.jsx(Dn,{color:"red",role:"alert",children:l}),v.jsxs("section",{"aria-labelledby":"usage-heading",children:[v.jsx(Ut,{id:"usage-heading",mb:"xs",order:3,size:"h5",children:"Usage"}),v.jsx(tj,{task:p})]}),v.jsx(Yc,{}),v.jsxs("section",{"aria-labelledby":"activity-heading",children:[v.jsx(Ut,{id:"activity-heading",mb:"sm",order:3,size:"h5",children:"Activity timeline"}),v.jsx(P_,{highlightTurnRef:r,task:p})]}),v.jsxs("section",{"aria-labelledby":"instruction-heading",children:[v.jsx(Ut,{id:"instruction-heading",mb:"xs",order:3,size:"h5",children:"Original instruction"}),v.jsx(fe,{className:"taskchef-code-panel",component:"pre",children:p.instruction})]}),v.jsxs("section",{"aria-labelledby":"metadata-heading",children:[v.jsx(Ut,{id:"metadata-heading",mb:"xs",order:3,size:"h5",children:"Metadata"}),v.jsxs("dl",{className:"taskchef-metadata",children:[v.jsx("dt",{children:"Task ID"}),v.jsx("dd",{children:p.id}),v.jsx("dt",{children:"Thread ID"}),v.jsx("dd",{children:p.threadId??"—"}),v.jsx("dt",{children:"Current turn ref"}),v.jsx("dd",{children:p.turnRef??"—"}),v.jsx("dt",{children:"Project path"}),v.jsx("dd",{children:p.project.path}),v.jsx("dt",{children:"Created"}),v.jsx("dd",{children:v.jsx(gi,{label:"Created time",value:p.createdAt})}),v.jsx("dt",{children:"Updated"}),v.jsx("dd",{children:v.jsx(gi,{label:"Updated time",value:p.meaningfulUpdatedAt??p.updatedAt})}),v.jsx("dt",{children:"Updated by"}),v.jsx("dd",{children:p.updatedBy??"—"})]})]})]});return y?v.jsx(Fn,{closeOnClickOutside:!n,closeOnEscape:!n,onClose:o,opened:d,overlayProps:{backgroundOpacity:.55,blur:2},position:"bottom",scrollAreaComponent:Xn.Autosize,size:"92%",title:v.jsx("span",{className:"taskchef-visually-hidden",children:"Task details"}),trapFocus:!0,zIndex:300,children:T}):v.jsx(Jn,{"aria-labelledby":"task-detail-title",closeOnClickOutside:!n,closeOnEscape:!n,onClose:o,opened:d,overlayProps:{backgroundOpacity:.55,blur:2},scrollAreaComponent:Xn.Autosize,size:"min(820px, calc(100vw - 32px))",title:v.jsx("span",{className:"taskchef-visually-hidden",children:"Task details"}),trapFocus:!0,zIndex:300,children:T})}function Gb(n){return n.status==="completed"?["failed"]:n.status==="failed"?["completed"]:n.status==="working"||n.status==="needs_input"?["completed","failed"]:[]}function lj({busy:n,onCancel:l,onTransition:r,status:o}){const s=x.useRef(crypto.randomUUID());return v.jsxs(Dn,{color:o==="failed"?"red":"teal",role:"alert",title:`Mark task ${o}?`,children:[v.jsx(Ee,{mb:"sm",size:"sm",children:"This interrupts active work and appends an audited manual dashboard turn."}),v.jsxs(yt,{gap:"xs",children:[v.jsx(Zn,{color:o==="failed"?"red":"teal",loading:n,onClick:async()=>{const c=await r(o,s.current);c.ok?(l(),requestAnimationFrame(()=>{var f;return(f=document.getElementById("task-detail-title"))==null?void 0:f.focus()})):c.rotateActionId&&(s.current=crypto.randomUUID())},size:"compact-sm",children:"Confirm"}),v.jsx(Zn,{disabled:n,onClick:l,size:"compact-sm",variant:"default",children:"Cancel"})]})]})}const aj={primaryColor:"teal",colors:{teal:["#e6fcf5","#c3fae8","#96f2d7","#63e6be","#38d9a9","#20c997","#087f5b","#067052","#055e46","#044d39"]},defaultRadius:"md",fontFamily:"Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif",headings:{fontFamily:"inherit",fontWeight:"680"},components:{Button:{defaultProps:{radius:"md"}},Paper:{defaultProps:{radius:"md"}},Select:{defaultProps:{size:"xs"}}}};var Ib;const Xb=(Ib=document.querySelector('meta[name="taskchef-style-nonce"]'))==null?void 0:Ib.content,yx="taskchef.dashboard.view";function oj(){try{return window.localStorage.getItem(yx)==="board"?"board":"list"}catch{return"list"}}function rj({totalCount:n,visibleCount:l}){return v.jsxs(Ee,{"aria-live":"polite",className:"taskchef-results-summary taskchef-content",id:"task-results-summary",children:["Tasks: ",l," of ",n]})}function ij({connect:n=!0,initialFilters:l={},initialTasks:r=[]}){const[o,s]=x.useState(()=>window.location.hash==="#settings");x.useEffect(()=>{const se=()=>s(window.location.hash==="#settings");return window.addEventListener("hashchange",se),()=>window.removeEventListener("hashchange",se)},[]);const[c,f]=x.useState(r),[d,p]=x.useState(),[h,b]=x.useState(!1),[y,g]=x.useState(null),[w,R]=x.useState(null),[T,C]=x.useState(l.project??""),[A,_]=x.useState(l.status??""),[N,j]=x.useState("all"),[$,L]=x.useState(oj),[D,H]=x.useState(5),[J,oe]=x.useState(()=>Date.now()),[te,ne]=x.useState(null),[K,q]=x.useState(!1),[ue,O]=x.useState(!1),[B,U]=x.useState(null),[F,W]=x.useState(null),[M,V]=x.useState(null),[P,ae]=x.useState({initialized:r.length>0,announcements:[],notifications:[],seenIds:new Set,signatures:new Map}),ie=(te==null?void 0:te.id)??null,de=x.useRef(ie);de.current=ie;const ge=x.useRef(0),pe=x.useRef(null),he=x.useRef(Ws(null)),Me=x.useCallback(se=>{f(se.tasks),p(se.projectIndex),ae(ze=>{const Ue=h_(ze,se.tasks);return{initialized:!0,announcements:Ue.additions,notifications:Ue.notifications,seenIds:Ue.seenIds,signatures:Ue.signatures}}),g(se.healthy===!1?"The task log is temporarily unavailable. Showing the last valid snapshot.":null);const He=de.current;if(He){const ze=se.tasks.find(Ue=>Ue.id===He);ze&&ne(Ue=>Ue?Ub(Ue,ze):ze)}},[]);x.useEffect(()=>{const se=window.setInterval(()=>oe(Date.now()),3e4);return()=>window.clearInterval(se)},[]),x.useEffect(()=>{if(!n)return;YN().then(R).catch(()=>R(null));const se=VN({onConnection:b,onError:g,onSnapshot:Me});return()=>se.close()},[Me,n]);const ye=x.useCallback(async(se,He=null)=>{const ze=++ge.current;pe.current=se.updatedAt,he.current=Ws(se),ne(Ue=>(Ue==null?void 0:Ue.id)===se.id?Ub(Ue,se):se),q(!0),V(He),U(null),W(null);try{for(let Ue=0;Ue<=40;Ue+=1){if(ze!==ge.current)return;const Te=await GN(se.id);if(ze!==ge.current||(pe.current=Te.updatedAt,he.current=Ws(Te),ne(Te),!C_(Te)||Ue===40))return;await new Promise(Qt=>window.setTimeout(Qt,1500))}}catch{ze===ge.current&&U("Task activity is temporarily unavailable. Showing the latest list snapshot.")}},[]),we=c.find(se=>se.id===ie)??null,Se=Ws(we);x.useEffect(()=>{!K||!ie||!n||we&&(we.updatedAt===pe.current&&Se===he.current||ye(we,M))},[we==null?void 0:we.updatedAt,Se]);const Oe=x.useMemo(()=>[{label:"All projects",value:""},...[...new Set(c.map(se=>se.project.name))].sort().map(se=>({label:se,value:se}))],[c]),We=x.useMemo(()=>gm(c,{project:T,status:A,date:N,now:J}),[c,T,A,N,J]),rt=x.useMemo(()=>gm(c,{project:T,date:N,now:J}),[c,T,N,J]),ut=$==="board",_t=x.useMemo(()=>i_(c,{project:T,date:N,now:J}),[c,T,N,J]),It=FS.map(({label:se,value:He})=>({label:_t[He]>0?`${se} ${_t[He]}`:se,value:He}));function Zt(se){if(!(se!=="board"&&se!=="list")){L(se);try{window.localStorage.setItem(yx,se)}catch{}}}async function Lt(se){O(!0);try{const He=await XN(se.id);He&&g(He)}catch{g("Codex could not be opened. Open the project and select the recorded task instead.")}finally{O(!1)}}async function Ct(se,He){if(!te)return{ok:!1};const ze=te,Ue=n_(ze);O(!0),U(null);const Te=await IN(ze,se,He);return O(!1),Te.task&&(ne(Qt=>kb({requestTask:ze,expected:Ue,responseTask:Te.task,selectedTask:Qt})),f(Qt=>Qt.map(un=>un.id===ze.id?kb({requestTask:ze,expected:Ue,responseTask:Te.task,selectedTask:un}):un))),Te.ok&&Te.task?(V(Te.task.turnRef??Te.task.turnId),{ok:!0}):(U(Te.message??"Task state could not be changed."),{ok:!1,rotateActionId:Te.code==="stale_task"})}function kt(se){const He=c.find(Ue=>Ue.id===se.taskId),ze=g_({detailTaskId:ie,detailOpened:K,highlightTurnRef:M,notifications:P.notifications,refreshGeneration:ge.current},se,!!He);if(ae(Ue=>({...Ue,notifications:ze.notifications})),!He){g("This task is no longer present in the current snapshot.");return}ye(He,ze.highlightTurnRef)}return v.jsx(d0,{defaultColorScheme:"auto",getStyleNonce:Xb?()=>Xb:void 0,theme:aj,children:v.jsxs(G_,{now:J,children:[v.jsxs(In,{className:"taskchef-shell",padding:0,children:[v.jsx(fe,{className:"taskchef-header-shell",component:"header",children:v.jsx(di,{className:`taskchef-header${ut?" taskchef-header-board":""}`,size:"100%",children:v.jsxs(yt,{className:"taskchef-header-layout",justify:"space-between",wrap:"nowrap",children:[v.jsxs(yt,{className:"taskchef-header-copy",gap:"xs",wrap:"nowrap",children:[v.jsx(cj,{}),v.jsxs(Ut,{className:"taskchef-brand-title",order:1,children:[v.jsx("span",{children:"TaskChef Dashboard"}),w&&v.jsxs("span",{className:"taskchef-version",children:["v",w]})]})]}),v.jsxs(yt,{className:"taskchef-header-actions",gap:2,justify:"flex-end",wrap:"nowrap",children:[v.jsx($n,{label:"Settings",children:v.jsx(pl,{className:"taskchef-icon-button",component:"a",href:"#settings","aria-label":"Settings","aria-current":o?"page":void 0,variant:"subtle",color:"gray",size:"lg",children:v.jsx(DN,{size:18,stroke:1.8})})}),v.jsx(sj,{}),v.jsxs(yt,{"aria-live":"polite",className:"taskchef-connection",gap:7,role:"status",wrap:"nowrap",children:[v.jsx(UN,{"aria-hidden":!0,color:h?"var(--mantine-color-teal-6)":"var(--mantine-color-yellow-6)",size:9}),v.jsx(Ee,{c:"dimmed",size:"xs",children:h?"Live":n?"Connecting…":"Fixture preview"})]})]})]})})}),v.jsx(In.Main,{children:v.jsxs(di,{className:`taskchef-main${ut?" taskchef-main-board":""}`,pb:80,size:"100%",children:[(d==null?void 0:d.status)==="unavailable"&&v.jsx(Dn,{color:"yellow",icon:v.jsx(Qd,{size:18}),mb:"md",title:"Project index unavailable",children:"Task history is still visible. Verify the index and inspect backups before making project changes."}),(d==null?void 0:d.status)==="available"&&d.missingProjects.length>0&&v.jsx(Dn,{color:"yellow",icon:v.jsx(Qd,{size:18}),mb:"md",title:"Historical projects are missing from the current index",children:d.missingProjects.map(se=>v.jsxs(Ee,{size:"sm",children:[se.snapshotNames.join(", "),": ",se.taskCount," task(s). Run ",v.jsx("code",{children:"taskchef backup list --json"})," and preview any restore; the dashboard never restores automatically."]},se.path))}),o?v.jsxs(Vt,{className:"taskchef-settings-page taskchef-content",gap:"sm",children:[v.jsx(Zn,{component:"a",href:"#",variant:"subtle",size:"xs",leftSection:v.jsx(pN,{size:14}),style:{alignSelf:"flex-start"},children:"Back to tasks"}),v.jsx(QN,{})]}):v.jsxs(v.Fragment,{children:[v.jsx(ln,{className:"taskchef-toolbar",radius:0,children:v.jsxs(Vt,{gap:"sm",children:[v.jsx(yt,{className:"taskchef-toolbar-view",children:v.jsx(mi,{"aria-label":"View",data:[{label:"Board",value:"board"},{label:"List",value:"list"}],onChange:Zt,size:"xs",value:$,withItemsBorders:!1})}),v.jsxs(yt,{className:"taskchef-toolbar-filters",gap:"sm",wrap:"nowrap",children:[v.jsx(Jo,{"aria-label":"Project",data:Oe,onChange:se=>{C(se??""),H(5)},value:T}),v.jsx(Jo,{"aria-label":"Updated",data:[{label:"Latest 24 hours",value:"24h"},{label:"Latest 7 days",value:"7d"},{label:"All time",value:"all"}],onChange:se=>{j(se??"all"),H(5)},value:N})]}),!ut&&v.jsx(fe,{className:"taskchef-toolbar-status",children:v.jsx(mi,{"aria-label":"Status",data:It,onChange:_,size:"xs",value:A,withItemsBorders:!1})})]})}),!ut&&v.jsx(rj,{totalCount:c.length,visibleCount:We.length}),y&&v.jsx(Dn,{color:"yellow",icon:v.jsx(Qd,{"aria-hidden":!0,size:17}),mt:"md",role:"status",children:v.jsxs(yt,{gap:"sm",justify:"space-between",wrap:"nowrap",children:[v.jsx(Ee,{size:"sm",children:y}),v.jsx(Pa,{"aria-label":"Dismiss dashboard message",onClick:()=>g(null),size:"sm"})]})}),ut?v.jsx(K_,{completedLimit:D,onMoreCompleted:()=>H(se=>se+5),onOpenCodex:Lt,onOpenDetail:se=>void ye(se),tasks:rt}):v.jsxs(Vt,{"aria-describedby":"task-results-summary","aria-label":"Tasks",className:"taskchef-list taskchef-content",component:"section",gap:"sm",mt:"xs",children:[We.map(se=>v.jsx(I_,{onOpenCodex:Lt,onOpenDetail:He=>void ye(He),task:se},se.id)),We.length===0&&v.jsxs(ln,{className:"taskchef-empty",p:48,ta:"center",withBorder:!0,children:[v.jsx(Ut,{order:2,size:"h4",children:"No tasks match these filters"}),v.jsx(Ee,{c:"dimmed",mt:4,size:"sm",children:"Choose a different project, update window, or status."})]})]})]})]})})]}),v.jsx(nj,{busy:ue,error:B,highlightTurnRef:M,onClose:()=>{ue||(ge.current+=1,q(!1),V(null))},onCopy:()=>{te&&(W(null),navigator.clipboard.writeText(te.id).then(()=>W("Task ID copied."),()=>W("Clipboard access is unavailable. Copy the Task ID from metadata.")))},onOpenCodex:()=>te&&void Lt(te),onTransition:Ct,opened:K,task:te,notice:F,notifications:K?v.jsx(Yb,{announcements:P.announcements,notifications:P.notifications,onClear:()=>ae(se=>({...se,notifications:Hb({detailTaskId:ie,detailOpened:K,highlightTurnRef:M,notifications:se.notifications,refreshGeneration:ge.current}).notifications})),onDismiss:se=>ae(He=>({...He,notifications:Bb(He.notifications,se.id)})),onOpen:kt,tasks:c,withinPortal:!1}):null}),!K&&v.jsx(Yb,{announcements:P.announcements,notifications:P.notifications,onClear:()=>ae(se=>({...se,notifications:Hb({detailTaskId:ie,detailOpened:K,highlightTurnRef:M,notifications:se.notifications,refreshGeneration:ge.current}).notifications})),onDismiss:se=>ae(He=>({...He,notifications:Bb(He.notifications,se.id)})),onOpen:kt,tasks:c})]})})}function sj(){const{setColorScheme:n}=r0(),l=i0("light"),r=l==="dark"?"light":"dark";return v.jsx($n,{label:`Use ${r} theme`,children:v.jsx(pl,{"aria-label":`Use ${r} theme`,className:"taskchef-icon-button",color:"gray",onClick:()=>n(r),size:"lg",variant:"subtle",children:l==="dark"?v.jsx(kN,{"aria-hidden":!0,size:18,stroke:1.8}):v.jsx(jN,{"aria-hidden":!0,size:18,stroke:1.8})})})}function cj(){const n=i0("light");return v.jsx("img",{alt:"","aria-hidden":!0,className:"taskchef-brand-icon",height:"28",src:n==="dark"?"/assets/taskchef-dark.svg":"/assets/taskchef.svg",width:"28"})}V2.createRoot(document.getElementById("root")).render(v.jsx(x.StrictMode,{children:v.jsx(ij,{})}));
194
194
  //# sourceMappingURL=app.js.map