taskchef 7.25.0 → 7.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/docs/dashboard-lifecycle.md +3 -2
- package/package.json +1 -1
- package/src/dashboard/dist/app.js +1 -1
- package/src/dashboard/dist/app.js.map +1 -1
- package/src/dashboard/react/components/TaskUsageSummary.test.tsx +16 -0
- package/src/dashboard/react/presentation.ts +4 -3
- package/src/dashboard.js +1 -0
|
@@ -29,8 +29,9 @@ those benefits without retaining the obsolete per-transport ownership.
|
|
|
29
29
|
|
|
30
30
|
The detail view distinguishes an active turn whose final usage is pending from
|
|
31
31
|
a terminal turn whose usage is being calculated. Available usage keeps both
|
|
32
|
-
the token total and API-equivalent USD estimate
|
|
33
|
-
|
|
32
|
+
the token total and API-equivalent USD estimate. Task cards keep the latest
|
|
33
|
+
cumulative value visible during a newer active turn and label it as updating;
|
|
34
|
+
pending is reserved for tasks that do not have a usage snapshot yet.
|
|
34
35
|
|
|
35
36
|

|
|
36
37
|
|
package/package.json
CHANGED
|
@@ -160,5 +160,5 @@ ${f?`${m("light")}{${f}}`:""}`}function js({theme:n,color:l,colorScheme:r,name:o
|
|
|
160
160
|
*
|
|
161
161
|
* This source code is licensed under the MIT license.
|
|
162
162
|
* See the LICENSE file in the root directory of this source tree.
|
|
163
|
-
*/const J3=[["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"}]],P3=An("filled","circle-filled","CircleFilled",J3),W3=50,e_="Turn interrupted before a terminal report.",AS=[{value:"",label:"All"},{value:"working",label:"Working"},{value:"needs input",label:"Needs input"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}],t_=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"]]),n_=new Map([["24h",1440*60*1e3],["7d",10080*60*1e3],["all",null]]);function l_(n){return Date.parse(n.meaningfulUpdatedAt??n.updatedAt??n.createdAt)}function _S(n){return n.status===null?"unresolved":n.status.replaceAll("_"," ")}function a_(n){return{status:n.status,turnRef:n.turnRef,threadId:n.threadId,updatedAt:n.updatedAt}}function o_(n,l){return!!l&&n.status===l.status&&n.turnRef===l.turnRef&&n.threadId===l.threadId&&n.updatedAt===l.updatedAt}function Sb({requestTask:n,expected:l,responseTask:r,selectedTask:o}){const s=(o==null?void 0:o.id)===n.id?o:n;return o_(s,l)?r??s:s}function r_(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 i_(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 s_(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,u=o>=0?r[o].turnRef??r[o].turnId:null,f=o>=0&&u===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&&(u===s||f)?r[o]=n.latestTurn:(n.schemaVersion>=8&&o>=0&&r[o].result===null&&(r[o]={...r[o],result:{status:"interrupted",summary:e_,updatedAt:n.latestTurn.startedAt}}),r.push(n.latestTurn)),r}function Qc(n){return t_.get(n.event)??"Task updated"}function c_(n,l,r=Date.now()){const o=n_.get(l);if(o===null)return!0;if(o===void 0)return!1;const s=l_(n);return Number.isFinite(s)&&s>=r-o}function NS(n,{project:l="",status:r="",date:o="all",now:s=Date.now()}={}){return n.filter(u=>(!l||u.project.name===l)&&(!r||_S(u)===r)&&c_(u,o,s))}function u_(n,{project:l="",date:r="all",now:o=Date.now()}={}){const s=NS(n,{project:l,date:r,now:o});return Object.fromEntries(AS.map(({value:u})=>[u,u?s.filter(f=>_S(f)===u).length:s.length]))}function f_(n){return JSON.stringify([n.id,n.turnRef??n.turnId??null,n.turnId??null,n.status??"unresolved"])}function d_(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,u)=>u===1||s===o[u])}catch{return!1}}function m_(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 MS(n,l){return JSON.stringify(l==="created"?[n.id,null,l,n.createdAt??null]:[n.id,n.turnRef??n.turnId??null,l])}function p_(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 h_(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 Ho(n,l=m_(n)){const r=l==="created";return Object.freeze({id:MS(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:p_(n,l),summary:h_(n,l)})}function ks(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:MS({...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 g_(n,l){return`${l?"Open current task details":"Show task availability"} for ${n.title}: ${Qc(n)}`}function v_(n){return`Dismiss ${Qc(n)} notification for ${n.title}`}function xb(n,l){return n.filter(({id:r})=>r!==l)}function y_({initialized:n,notifications:l,seenIds:r=new Set,signatures:o},s){const u=new Map(o);for(const p of s)u.set(p.id,f_(p));const f=new Set(r);if(!n){for(const p of s){f.add(Ho(p,"created").id);const h=ks(p);h&&f.add(h.id),f.add(Ho(p).id)}return{additions:[],notifications:l,seenIds:f,signatures:u}}const m=[];for(const p of s){const h=[];if(o.has(p.id)){if(o.get(p.id)!==u.get(p.id)&&!d_(o.get(p.id),u.get(p.id))){h.push(Ho(p));const v=ks(p);v&&h.push(v)}}else{const v=ks(p);(p.turnRef||p.turnId||p.status!=="working"||v)&&(h.push(Ho(p)),v&&h.push(v)),h.push(Ho(p,"created"))}for(const v of h)f.has(v.id)||m.push(v),f.add(v.id);const S=ks(p);S&&f.add(S.id),f.add(Ho(p).id)}return{additions:m,notifications:[...m,...l].slice(0,W3),seenIds:f,signatures:u}}function b_({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 u=JSON.parse(s.data);l(u.message??"The task log is temporarily unavailable.")}),o}async function Kc(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 S_(){return(await Kc("/api/health")).taskchefVersion}async function x_(n){return(await Kc(`/api/tasks/${encodeURIComponent(n)}`)).task}async function w_(n){return(await Kc(`/api/tasks/${encodeURIComponent(n)}/open-codex`,{method:"POST"})).message??null}async function C_(n,l,r){const o=new AbortController,s=window.setTimeout(()=>o.abort(),1e4);try{return{ok:!0,task:(await Kc(`/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(u){const f=u.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)}}function T_(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 wb(n){return{...n,notifications:[]}}function Cb(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 Ys(n){var l,r,o,s,u,f,m;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,((u=(s=n==null?void 0:n.usage)==null?void 0:s.task)==null?void 0:u.totalTokens)??null,((m=(f=n==null?void 0:n.usage)==null?void 0:f.task)==null?void 0:m.estimatedCostUsd)??null])}function Sp(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2,notation:"compact"}).format(n)}function lc(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2}).format(n)}function Io(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 OS(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?Tb(l.task,!0):{kind:"pending",label:"Token usage pending"}:(l==null?void 0:l.status)==="calculating"||o?{kind:"calculating",label:"Calculating token usage"}:(l==null?void 0:l.status)==="available"&&l.task?Tb(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 Tb(n,l){const r=Sp(n.totalTokens),o=n.estimatedCostUsd==null?"Estimated cost unavailable":`Estimated cost ${Io(n.estimatedCostUsd)}`;return{kind:"ready",knownSoFar:l,label:`${r} tokens · ${o}${l?" · known so far":""}`,usage:n}}function R_(n,l){var s,u;if(l.result===null)return{kind:"pending",label:"Turn usage pending"};const r=l.turnRef??l.turnId,o=r?(u=(s=n.usage)==null?void 0:s.turns)==null?void 0:u[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=lc(o.totalTokens),m=o.estimatedCostUsd==null?"Estimated cost unavailable":`Estimated cost ${Io(o.estimatedCostUsd)}`;return{kind:"ready",label:`${f} tokens · ${m}`}}return{kind:"unavailable",label:(o==null?void 0:o.reason)??"Turn usage unavailable"}}function E_(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 A_(n){var p;const l=OS(n);if(l.kind==="pending"||l.kind==="calculating")return{accessibleLabel:l.label,kind:l.kind,label:l.label,title:l.label};if(l.kind==="unavailable")return{accessibleLabel:`Token usage unavailable${l.label==="Token usage unavailable"?"":`: ${l.label}`}`,kind:"unavailable",label:"Token usage unavailable",title:l.label};const r=Sp(l.usage.totalTokens),o=lc(l.usage.totalTokens),s=l.usage.estimatedCostUsd==null?"cost unavailable":`est. ${Io(l.usage.estimatedCostUsd)}`,u=l.knownSoFar?" · known so far":"",f=l.usage.sourceUpdatedAt??l.usage.sampledAt??((p=n.usage)==null?void 0:p.updatedAt)??null,m=f&&!Number.isNaN(Date.parse(f))?` Cached usage updated ${new Date(f).toLocaleString()}.`:"";return{accessibleLabel:`${o} tokens; ${l.usage.estimatedCostUsd==null?"estimated cost unavailable":`estimated cost ${Io(l.usage.estimatedCostUsd)}`}${l.knownSoFar?"; known so far":""}.${m}`,kind:"ready",label:`${r} tokens · ${s}${u}`,title:`${o} tokens · ${l.usage.estimatedCostUsd==null?"estimated cost unavailable":`unrounded estimate $${l.usage.estimatedCostUsd}`}${l.knownSoFar?" · known so far":""}.${m}`}}function __(n){return n==="completed"?"teal":n==="needs_input"?"yellow":n==="failed"?"red":n==="working"?"blue":"gray"}function N_(n){return n===null?"Unresolved":n.replaceAll("_"," ")}const M_=30,Yo=6e4,oi=60*Yo,Jr=24*oi;function zS(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 O_(n,{locale:l,timeZone:r}={}){const o=zS(n);return o?new Intl.DateTimeFormat(l,{dateStyle:"medium",timeStyle:"short",timeZone:r}).format(o.date):"—"}function z_(n,l){const r=Math.floor(n/oi),o=Math.floor(n%oi/Yo),s=r===1?"1 hour":`${r} hours`,u=r<6&&o>0?` ${o} minutes`:"";return l==="future"?`in ${s}${u}`:`${s}${u} ago`}function xp(n,{now:l=Date.now(),locale:r,timeZone:o}={}){const s=zS(n);if(!s)return"—";const u=l-s.milliseconds,f=u<0,m=Math.abs(u);if(m<Yo)return"just now";if(m<2*Yo)return f?"in 1 minute":"1 minute ago";if(m<oi){const p=f?Math.ceil(m/Yo):Math.floor(m/Yo);return f?`in ${p} minutes`:`${p} minutes ago`}if(m<2*oi)return f?"in 1 hour":"1 hour ago";if(m<Jr)return z_(m,f?"future":"past");if(m<2*Jr)return f?"in 1 day":"1 day ago";if(m<M_*Jr){const p=f?Math.ceil(m/Jr):Math.floor(m/Jr);return f?`in ${p} days`:`${p} days ago`}return new Intl.DateTimeFormat(r,{dateStyle:"medium",timeZone:o}).format(s.date)}function Fc({status:n}){return y.jsx(Nc,{className:"taskchef-status-badge",color:__(n),size:"sm",variant:"light",children:N_(n)})}function Rb({notifications:n,announcements:l=n,onClear:r,onDismiss:o,onOpen:s,tasks:u,withinPortal:f=!0}){if(n.length===0)return null;const m=y.jsxs(y.Fragment,{children:[y.jsxs(Rn,{"aria-label":"Task notifications",className:"taskchef-notifications",p:"sm",radius:"md",role:"region",shadow:"xl",withBorder:!0,children:[y.jsxs(Ct,{justify:"space-between",mb:"xs",children:[y.jsxs(Ct,{gap:6,children:[y.jsx(D3,{"aria-hidden":!0,size:16}),y.jsx(De,{fw:700,size:"sm",children:"Updates"})]}),y.jsx(ll,{onClick:r,size:"compact-xs",variant:"subtle",children:"Clear all"})]}),y.jsx(Bn.Autosize,{className:"taskchef-notification-scroll",mah:"min(55vh, 520px)",type:"auto",children:y.jsx(Tn,{className:"taskchef-notification-list",gap:6,children:n.map(p=>{const h=u.some(w=>w.id===p.taskId),S=`notification-${Math.abs(D_(p.id))}`,v=`${S}-summary`,g=`${S}-metadata`;return y.jsx(Rn,{className:"taskchef-notification",p:"xs",radius:"sm",children:y.jsxs(Ct,{align:"flex-start",gap:"xs",wrap:"nowrap",children:[y.jsxs("button",{"aria-describedby":[p.summary?v:null,g].filter(Boolean).join(" "),"aria-label":g_(p,h),className:"taskchef-notification-open",onClick:()=>s(p),type:"button",children:[y.jsxs(Ct,{gap:"xs",justify:"space-between",wrap:"nowrap",children:[y.jsx(De,{fw:700,size:"sm",children:Qc(p)}),y.jsx(Fc,{status:p.status})]}),y.jsx(De,{lineClamp:1,size:"sm",children:p.title}),p.summary&&y.jsx(De,{className:"taskchef-preserve-lines",id:v,lineClamp:3,size:"xs",children:p.summary}),y.jsxs(De,{c:"dimmed",id:g,size:"xs",children:[xp(p.timestamp),h?"":" · Task no longer available"]})]}),y.jsx(Ll,{label:"Dismiss notification",children:y.jsx(ya,{"aria-label":v_(p),color:"gray",onClick:()=>o(p),size:"compact-sm",variant:"subtle",children:y.jsx(ES,{"aria-hidden":!0,size:14})})})]})},p.id)})})})]}),y.jsx(fe,{"aria-atomic":"true","aria-live":"polite",className:"taskchef-visually-hidden",role:"status",children:l.map(j_).join(" ")})]});return f?y.jsx(Um,{children:m}):m}function j_(n){return[Qc(n),n.title,n.summary,n.turnRef?`Turn ref ${n.turnRef}`:null,xp(n.timestamp)].filter(Boolean).map(l=>String(l).replace(/[.\s]+$/,"")).join(". ")+"."}function D_(n){let l=0;for(const r of n)l=(l<<5)-l+r.charCodeAt(0)|0;return l}const $_=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]+$/,L_=/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,B_=/https?:\/\/[^\s<>"'`]+/gi;function Jc(n){return!(n!=null&&n.owner)||!(n!=null&&n.repository)?null:`${n.owner.toLowerCase()}/${n.repository.toLowerCase()}`}function H_(n){const l=new Map;for(const r of n){const o=Jc(r);if(!o)continue;const s=r.repository.toLowerCase(),u=l.get(s)??new Set;u.add(o),l.set(s,u)}return new Set([...l].filter(([,r])=>r.size>1).map(([r])=>r))}function U_(n,l){return l.has(n.repository.toLowerCase())?`${n.owner}/${n.repository}`:n.repository}function jS(n,{related:l=!1}={}){const r=H_(n);let o=null;return n.map(s=>{if(s.provider!=="github"&&!s.owner)return s.label??s.text;const u=Jc(s),f=U_(s,r);if(s.type==="repository")return f;if(l){const m=u===o?`#${s.number}`:`${f} #${s.number}`;return o=u,m}return s.type==="pull"?`${f} PR #${s.number}`:s.type==="issue"?`${f} Issue #${s.number}`:`${f} #${s.number}`})}function k_(n,l){const r=String(n.number??""),o=String(l.number??"");return r.length-o.length||r.localeCompare(o)}function Y_(n){const l=new Map,r=new Set,o=new Set,s=new Set;for(const u of n??[]){const f=Jc(u),m=u.number?`${f}#${u.number}`:null;if(u.type==="repository"||!f||r.has(u.label)||s.has(u.url)||m&&o.has(m))continue;r.add(u.label),s.add(u.url),m&&o.add(m);const p=l.get(f)??[];p.push(u),l.set(f,p)}return[...l.values()].map(u=>[...u].sort(k_))}function DS(n){const l=Jc(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 $S(n,l){return`${n.toLowerCase()}/${l.toLowerCase()}`}function LS(n){return n!=="."&&n!==".."}function BS(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]}`),!$_.test(l))return null;const[o,s]=l.split("/");return LS(s)?$S(o,s):null}function q_(n){var s;const l=String(n??""),r=HS(l),o=[];for(const u of l.matchAll(L_)){const f=u.index,m=f>0?l[f-1]:"";let p=null;const h=r.find(T=>f>=T.start&&f<T.end);if(h){const T=!!(u[1]||u[9]);let A=null;try{A=new URL(h.text).hostname.toLowerCase()}catch{}if(!(T&&f===h.start&&(A==="github.com"||A==="www.github.com"))||!US(h.text))continue;p={end:h.end,suffix:h.text.slice(u[0].length),text:h.text}}if(u[8]&&/[\w&#/]/.test(m)||(u[5]||u[1]||u[9])&&/[\w/]/.test(m))continue;let S=u[1]??u[5]??u[9]??null,v=u[2]??u[6]??u[10]??null;u[9]&&(v=v.replace(/\.git$/i,""));const g=u[4]??u[7]??u[8]??null,w=(s=u[3])==null?void 0:s.toLowerCase(),E=u[9]?"repository":w==="pull"?"pull":w==="issues"?"issue":"generic",C=!!(S&&v);if(C){if(!LS(v))continue;[S,v]=$S(S,v).split("/")}o.push({end:(p==null?void 0:p.end)??f+u[0].length,explicit:C,number:g,owner:S,repository:v,start:f,text:(p==null?void 0:p.text)??u[0],type:E,urlSuffix:(p==null?void 0:p.suffix)??""})}return o}function V_(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 G_(n){const l=new Set((n??[]).map(BS).filter(Boolean));return l.size===1?[...l][0]:null}function X_(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 u=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}/${u}/${n.number}${n.urlSuffix}`}}function I_(n){let l=n,r;do{r=l,l=l.replace(/[.,;:!?]+$/u,"");for(const[o,s]of[["(",")"],["[","]"],["{","}"]])for(;l.endsWith(s);){const u=[...l].filter(m=>m===o).length;if([...l].filter(m=>m===s).length<=u)break;l=l.slice(0,-1)}}while(l!==r);return l}function HS(n){const l=[];for(const r of String(n??"").matchAll(B_)){const o=I_(r[0]);o&&l.push({end:r.index+o.length,start:r.index,text:o})}return l}function Z_(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 US(n){try{const l=new URL(n);return!l.hostname||l.username||l.password||n.includes("\\")||Z_(n)?null:l.href}catch{return null}}function Q_(n){const l=[];for(const r of HS(n)){const o=US(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 K_(n,{projectRepositories:l=[],taskRepository:r=null}={}){const o=String(n??""),s=q_(o),f=V_(s)??BS(r)??G_(l),m=[];let p=0;for(const h of s){h.start>p&&m.push({kind:"text",text:o.slice(p,h.start)});const S=X_(h,f);S?m.push(S):m.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&&m.push({kind:"text",text:o.slice(p)}),m}function F_(n,l={}){const r=String(n??""),o=K_(r,l),s=[];let u=0;for(const h of o){const S=r.indexOf(h.text,u);S<0||(h.kind!=="text"&&s.push({end:S+h.text.length,segment:h,start:S}),u=S+h.text.length)}const f=Q_(r).filter(h=>!s.some(({end:S,start:v})=>h.start<S&&h.end>v));if(f.length===0)return o;s.push(...f.map(h=>({end:h.end,segment:h,start:h.start}))),s.sort((h,S)=>h.start-S.start);const m=[];let p=0;for(const h of s)h.start<p||(h.start>p&&m.push({kind:"text",text:r.slice(p,h.start)}),m.push(h.segment),p=h.end);return p<r.length&&m.push({kind:"text",text:r.slice(p)}),m}function kS({task:n}){const l=n.relatedGitHubLinks??[];if(l.length===0&&!n.relatedGitHubLinksTruncated)return null;const r=Y_(l),o=jS(r.flat(),{related:!0});let s=0;return y.jsxs(fe,{"aria-label":`Related GitHub links for ${n.title}`,className:"taskchef-github-groups",component:"nav",children:[r.map(u=>y.jsx(Ct,{className:"taskchef-github-group",gap:5,wrap:"wrap",children:u.map(f=>{const m=o[s];s+=1;const p=f.type==="pull"?", GitHub pull request":f.type==="issue"?", GitHub issue":" on GitHub";return y.jsx(Ac,{"aria-label":`${DS(f)}${p} (opens in a new tab)`,className:"taskchef-github-link",href:f.url,rel:"noopener noreferrer",size:"xs",target:"_blank",children:m},f.url)})},`${u[0].owner}/${u[0].repository}`)),n.relatedGitHubLinksTruncated&&y.jsx(De,{c:"dimmed",size:"xs",children:"More links in task history"})]})}function ac({task:n,text:l}){const r=F_(l,{projectRepositories:n.project.githubRepos,taskRepository:n.relatedGitHubRepository}),o=r.filter(f=>f.kind==="link"),s=jS(o);let u=0;return r.map((f,m)=>{if(f.kind==="text")return f.text;if(f.kind==="ambiguous")return y.jsx("span",{"aria-label":f.reason,className:"taskchef-github-reference-ambiguous",tabIndex:0,title:f.reason,children:f.text},`${m}:${f.text}`);const p=s[u];u+=1;const h=f.type==="pull"?", GitHub pull request":f.type==="issue"?", GitHub issue":f.owner?" on GitHub":"";return y.jsx(Ac,{"aria-label":`${DS(f)}${h} (opens in a new tab)`,className:"taskchef-github-link",href:f.url,rel:"noopener noreferrer",target:"_blank",children:p},`${m}:${f.url}`)})}const YS=x.createContext(null);function J_({children:n,now:l}){return y.jsx(YS,{value:l,children:n})}function oc({label:n,value:l}){const[r,o]=x.useState(!1);x.useContext(YS);const s=r?O_(l):xp(l);return y.jsx(Ll,{label:r?"Show relative time":"Show exact time",children:y.jsxs(zl,{"aria-label":`${n}: ${s}. ${r?"Show relative time":"Show exact time"}`,className:"taskchef-time",onClick:()=>o(u=>!u),children:[y.jsx(k3,{"aria-hidden":!0,size:12}),y.jsx("span",{className:"taskchef-time-label",children:s})]})})}function ri({children:n,className:l="",...r}){return y.jsx("span",{className:`taskchef-shimmer ${l}`.trim(),"data-animation":"text-shimmer",...r,children:n})}function P_({task:n}){const l=A_(n),r=l.kind==="pending"||l.kind==="calculating"?y.jsx(ri,{children:l.label}):l.label;return y.jsx(De,{"aria-label":l.accessibleLabel,"aria-live":"polite",c:"dimmed",className:"taskchef-task-usage","data-usage-state":l.kind,size:"xs",title:l.title,children:r})}function W_({onOpenCodex:n,onOpenDetail:l,task:r}){const o=r_(r);return y.jsx(Rn,{className:"taskchef-task-row",component:"article",p:"md",radius:"md",withBorder:!0,children:y.jsxs(Tn,{className:"taskchef-task-main",gap:"sm",children:[y.jsxs(fe,{children:[y.jsxs(fe,{className:"taskchef-card-heading",children:[y.jsx(zn,{order:3,size:"h5",children:y.jsx("button",{className:"taskchef-title-button",onClick:()=>l(r),type:"button",children:r.title})}),y.jsxs(Tn,{align:"flex-end",className:"taskchef-card-metadata",gap:4,children:[y.jsx(Fc,{status:r.status}),y.jsx(P_,{task:r})]})]}),y.jsx(De,{c:"dimmed",mt:2,size:"xs",children:r.project.name})]}),y.jsxs(fe,{className:"taskchef-summary-grid",children:[y.jsx(De,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Request"}),y.jsx(De,{className:"taskchef-preserve-lines",lineClamp:3,size:"sm",children:y.jsx(ac,{task:r,text:o.requestSummary})}),y.jsx(De,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Result"}),y.jsx(De,{className:"taskchef-preserve-lines",lineClamp:3,size:"sm",children:o.resultStatus==="working"?y.jsx(ri,{children:o.resultSummary}):y.jsx(ac,{task:r,text:o.resultSummary})})]}),y.jsx(kS,{task:r}),y.jsxs(Ct,{className:"taskchef-card-footer",gap:"md",justify:"space-between",children:[y.jsx(oc,{label:`Updated time for ${r.title}`,value:r.meaningfulUpdatedAt??r.updatedAt}),y.jsx(ll,{"aria-label":`Open chat for ${r.title}`,leftSection:y.jsx(RS,{"aria-hidden":!0,size:15}),onClick:()=>n(r),size:"compact-sm",variant:"default",children:"Open chat"})]})]})})}function eN({highlightTurnRef:n,task:l}){const r=s_(l,[]);return r!=null&&r.length?y.jsx(Tn,{gap:"sm",children:[...r].reverse().map((o,s)=>{const u=i_(o),f=o.turnRef??o.turnId??`turn-${s}`,m=f===n,p=R_(l,o);return y.jsx(Rn,{className:`taskchef-turn${m?" taskchef-turn-highlighted":""}`,"data-turn-ref":f,p:"sm",radius:"md",tabIndex:m?-1:void 0,withBorder:!0,children:y.jsxs(Tn,{gap:7,children:[y.jsxs(fe,{className:"taskchef-turn-heading",children:[y.jsx(Fc,{status:u.status}),y.jsx(oc,{label:"Turn update time",value:u.updatedAt})]}),u.sourceLabel&&y.jsx(De,{c:"dimmed",size:"xs",children:u.sourceLabel}),y.jsxs(fe,{children:[y.jsx(De,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Request"}),y.jsx(De,{className:"taskchef-preserve-lines",size:"sm",children:y.jsx(ac,{task:l,text:o.requestSummary??"Request not recorded."})})]}),y.jsxs(fe,{children:[y.jsx(De,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Result"}),y.jsx(De,{className:"taskchef-preserve-lines",size:"sm",children:u.status==="working"?y.jsx(ri,{children:u.summary}):y.jsx(ac,{task:l,text:u.summary})})]}),y.jsx(De,{c:"dimmed",className:p.kind==="calculating"||p.kind==="pending"?"taskchef-turn-usage":void 0,size:"xs",children:p.kind==="calculating"||p.kind==="pending"?y.jsx(ri,{children:p.label}):p.label}),y.jsxs(De,{c:"dimmed",className:"taskchef-mono",size:"xs",children:["Turn ref: ",f??"—"]})]})},f)})}):y.jsx(De,{c:"dimmed",size:"sm",children:"No turn history has been recorded."})}function tN({task:n}){const l=OS(n);if(l.kind==="pending"||l.kind==="calculating")return y.jsx(Rn,{"aria-live":"polite",className:"taskchef-subtle-panel",p:"sm",radius:"md",children:y.jsxs(Ct,{gap:"xs",children:[y.jsx(q3,{"aria-hidden":!0,size:16}),y.jsx(De,{size:"sm",children:y.jsx(ri,{children:l.label})})]})});if(l.kind==="unavailable")return y.jsx(De,{"aria-live":"polite",c:"dimmed",size:"sm",children:l.label});const r=l.usage.cachedInputTokens??0,o=l.usage.inputTokens??0,s=o+r>0?`${Math.round(r/(o+r)*100)}%`:"—",u=[{accessibleValue:`${lc(l.usage.totalTokens)} tokens`,label:l.knownSoFar?"Tokens · known so far":"Tokens",title:`${lc(l.usage.totalTokens)} tokens`,value:Sp(l.usage.totalTokens)},{accessibleValue:l.usage.estimatedCostUsd==null?"Estimated cost unavailable":`Estimated cost ${Io(l.usage.estimatedCostUsd)}`,label:"Estimated cost",title:l.usage.estimatedCostUsd==null?void 0:`Unrounded estimate: $${l.usage.estimatedCostUsd}`,value:Io(l.usage.estimatedCostUsd)},{label:"Model",value:Object.keys(l.usage.models??{}).join(", ")||"—"},{label:"Cache ratio",value:s}];return y.jsx(fe,{"aria-live":"polite",className:"taskchef-metrics",children:u.map(({accessibleValue:f,label:m,title:p,value:h})=>y.jsxs(Rn,{className:"taskchef-metric",p:"sm",radius:"md",withBorder:!0,children:[y.jsx(De,{c:"dimmed",size:"xs",children:m}),y.jsx(De,{"aria-label":f,className:"taskchef-metric-value",fw:650,size:"sm",title:p,children:h})]},m))})}function nN({busy:n,error:l,highlightTurnRef:r,onClose:o,onCopy:s,onOpenCodex:u,onTransition:f,opened:m,task:p,notifications:h,notice:S}){var T;const v=um("(max-width: 48em)"),[g,w]=x.useState(null);if(x.useEffect(()=>{m||w(null)},[m]),x.useEffect(()=>{m&&r&&requestAnimationFrame(()=>{var A;(A=document.querySelector(`[data-turn-ref="${CSS.escape(r)}"]`))==null||A.focus()})},[r,m,(T=p==null?void 0:p.turns)==null?void 0:T.length,p==null?void 0:p.updatedAt]),x.useEffect(()=>{g&&(!p||!Eb(p).includes(g))&&w(null)},[g,p==null?void 0:p.status]),!p)return null;const E=Eb(p),C=y.jsxs(Tn,{gap:"lg",children:[h,y.jsxs(fe,{children:[y.jsxs(Ct,{align:"flex-start",gap:"sm",justify:"space-between",wrap:"nowrap",children:[y.jsxs(fe,{children:[y.jsx(De,{c:"teal",fw:700,size:"xs",tt:"uppercase",children:p.project.name}),y.jsx(zn,{id:"task-detail-title",order:2,size:"h3",tabIndex:-1,children:p.title})]}),y.jsx(Fc,{status:p.status})]}),y.jsxs(Ct,{gap:"xs",mt:"md",children:[y.jsx(ll,{leftSection:y.jsx(RS,{"aria-hidden":!0,size:15}),loading:n,onClick:u,size:"compact-sm",children:"Open chat"}),y.jsxs(pt,{position:"bottom-start",shadow:"md",withinPortal:!0,zIndex:360,children:[y.jsx(pt.Target,{children:y.jsx(Ll,{label:"More task actions",children:y.jsx(ya,{"aria-label":"More task actions",disabled:n,variant:"default",children:y.jsx(G3,{"aria-hidden":!0,size:17})})})}),y.jsxs(pt.Dropdown,{children:[y.jsx(pt.Item,{leftSection:y.jsx(H3,{size:14}),onClick:s,children:"Copy Task ID"}),E.includes("completed")&&y.jsx(pt.Item,{leftSection:y.jsx(L3,{size:14}),onClick:()=>w("completed"),children:"Mark completed"}),E.includes("failed")&&y.jsx(pt.Item,{color:"red",leftSection:y.jsx(ES,{size:14}),onClick:()=>w("failed"),children:"Mark failed"})]})]})]}),y.jsx(fe,{mt:"sm",children:y.jsx(kS,{task:p})})]}),g&&y.jsx(lN,{busy:n,onCancel:()=>w(null),onTransition:f,status:g},g),S&&y.jsx(Xa,{color:"teal",role:"status",children:S}),l&&y.jsx(Xa,{color:"red",role:"alert",children:l}),y.jsxs("section",{"aria-labelledby":"usage-heading",children:[y.jsx(zn,{id:"usage-heading",mb:"xs",order:3,size:"h5",children:"Usage"}),y.jsx(tN,{task:p})]}),y.jsx(zc,{}),y.jsxs("section",{"aria-labelledby":"activity-heading",children:[y.jsx(zn,{id:"activity-heading",mb:"sm",order:3,size:"h5",children:"Activity timeline"}),y.jsx(eN,{highlightTurnRef:r,task:p})]}),y.jsxs("section",{"aria-labelledby":"instruction-heading",children:[y.jsx(zn,{id:"instruction-heading",mb:"xs",order:3,size:"h5",children:"Original instruction"}),y.jsx(fe,{className:"taskchef-code-panel",component:"pre",children:p.instruction})]}),y.jsxs("section",{"aria-labelledby":"metadata-heading",children:[y.jsx(zn,{id:"metadata-heading",mb:"xs",order:3,size:"h5",children:"Metadata"}),y.jsxs("dl",{className:"taskchef-metadata",children:[y.jsx("dt",{children:"Task ID"}),y.jsx("dd",{children:p.id}),y.jsx("dt",{children:"Thread ID"}),y.jsx("dd",{children:p.threadId??"—"}),y.jsx("dt",{children:"Current turn ref"}),y.jsx("dd",{children:p.turnRef??"—"}),y.jsx("dt",{children:"Project path"}),y.jsx("dd",{children:p.project.path}),y.jsx("dt",{children:"Created"}),y.jsx("dd",{children:y.jsx(oc,{label:"Created time",value:p.createdAt})}),y.jsx("dt",{children:"Updated"}),y.jsx("dd",{children:y.jsx(oc,{label:"Updated time",value:p.meaningfulUpdatedAt??p.updatedAt})}),y.jsx("dt",{children:"Updated by"}),y.jsx("dd",{children:p.updatedBy??"—"})]})]})]});return v?y.jsx(Yn,{closeOnClickOutside:!n,closeOnEscape:!n,onClose:o,opened:m,overlayProps:{backgroundOpacity:.55,blur:2},position:"bottom",scrollAreaComponent:Bn.Autosize,size:"92%",title:y.jsx("span",{className:"taskchef-visually-hidden",children:"Task details"}),trapFocus:!0,zIndex:300,children:C}):y.jsx(Vn,{"aria-labelledby":"task-detail-title",closeOnClickOutside:!n,closeOnEscape:!n,onClose:o,opened:m,overlayProps:{backgroundOpacity:.55,blur:2},scrollAreaComponent:Bn.Autosize,size:"min(820px, calc(100vw - 32px))",title:y.jsx("span",{className:"taskchef-visually-hidden",children:"Task details"}),trapFocus:!0,zIndex:300,children:C})}function Eb(n){return n.status==="completed"?["failed"]:n.status==="failed"?["completed"]:n.status==="working"||n.status==="needs_input"?["completed","failed"]:[]}function lN({busy:n,onCancel:l,onTransition:r,status:o}){const s=x.useRef(crypto.randomUUID());return y.jsxs(Xa,{color:o==="failed"?"red":"teal",role:"alert",title:`Mark task ${o}?`,children:[y.jsx(De,{mb:"sm",size:"sm",children:"This interrupts active work and appends an audited manual dashboard turn."}),y.jsxs(Ct,{gap:"xs",children:[y.jsx(ll,{color:o==="failed"?"red":"teal",loading:n,onClick:async()=>{const u=await r(o,s.current);u.ok?(l(),requestAnimationFrame(()=>{var f;return(f=document.getElementById("task-detail-title"))==null?void 0:f.focus()})):u.rotateActionId&&(s.current=crypto.randomUUID())},size:"compact-sm",children:"Confirm"}),y.jsx(ll,{disabled:n,onClick:l,size:"compact-sm",variant:"default",children:"Cancel"})]})]})}const aN={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 _b;const Ab=(_b=document.querySelector('meta[name="taskchef-style-nonce"]'))==null?void 0:_b.content;function oN({connect:n=!0,initialTasks:l=[]}){const[r,o]=x.useState(l),[s,u]=x.useState(!1),[f,m]=x.useState(null),[p,h]=x.useState(null),[S,v]=x.useState(""),[g,w]=x.useState(""),[E,C]=x.useState("all"),[T,A]=x.useState(()=>Date.now()),[_,N]=x.useState(null),[z,B]=x.useState(!1),[L,D]=x.useState(!1),[k,ee]=x.useState(null),[ae,le]=x.useState(null),[te,J]=x.useState(null),[V,se]=x.useState({initialized:l.length>0,announcements:[],notifications:[],seenIds:new Set,signatures:new Map}),O=(_==null?void 0:_.id)??null,H=x.useRef(O);H.current=O;const U=x.useRef(0),K=x.useRef(null),P=x.useRef(Ys(null)),M=x.useCallback(ue=>{o(ue.tasks),se(xe=>{const Te=y_(xe,ue.tasks);return{initialized:!0,announcements:Te.additions,notifications:Te.notifications,seenIds:Te.seenIds,signatures:Te.signatures}}),m(ue.healthy===!1?"The task log is temporarily unavailable. Showing the last valid snapshot.":null);const me=H.current;if(me){const xe=ue.tasks.find(Te=>Te.id===me);xe&&N(Te=>Te?Cb(Te,xe):xe)}},[]);x.useEffect(()=>{const ue=window.setInterval(()=>A(Date.now()),3e4);return()=>window.clearInterval(ue)},[]),x.useEffect(()=>{if(!n)return;S_().then(h).catch(()=>h(null));const ue=b_({onConnection:u,onError:m,onSnapshot:M});return()=>ue.close()},[M,n]);const Y=x.useCallback(async(ue,me=null)=>{const xe=++U.current;K.current=ue.updatedAt,P.current=Ys(ue),N(Te=>(Te==null?void 0:Te.id)===ue.id?Cb(Te,ue):ue),B(!0),J(me),ee(null),le(null);try{for(let Te=0;Te<=40;Te+=1){if(xe!==U.current)return;const $e=await x_(ue.id);if(xe!==U.current||(K.current=$e.updatedAt,P.current=Ys($e),N($e),!E_($e)||Te===40))return;await new Promise(it=>window.setTimeout(it,1500))}}catch{xe===U.current&&ee("Task activity is temporarily unavailable. Showing the latest list snapshot.")}},[]),F=r.find(ue=>ue.id===O)??null,re=Ys(F);x.useEffect(()=>{!z||!O||!n||F&&(F.updatedAt===K.current&&re===P.current||Y(F,te))},[F==null?void 0:F.updatedAt,re]);const ie=x.useMemo(()=>[{label:"All projects",value:""},...[...new Set(r.map(ue=>ue.project.name))].sort().map(ue=>({label:ue,value:ue}))],[r]),de=x.useMemo(()=>NS(r,{project:S,status:g,date:E,now:T}),[r,S,g,E,T]),ye=x.useMemo(()=>u_(r,{project:S,date:E,now:T}),[r,S,E,T]),ge=AS.map(({label:ue,value:me})=>({label:ye[me]>0?`${ue} ${ye[me]}`:ue,value:me}));async function he(ue){D(!0);try{const me=await w_(ue.id);me&&m(me)}catch{m("Codex could not be opened. Open the project and select the recorded task instead.")}finally{D(!1)}}async function Me(ue,me){if(!_)return{ok:!1};const xe=_,Te=a_(xe);D(!0),ee(null);const $e=await C_(xe,ue,me);return D(!1),$e.task&&(N(it=>Sb({requestTask:xe,expected:Te,responseTask:$e.task,selectedTask:it})),o(it=>it.map(bt=>bt.id===xe.id?Sb({requestTask:xe,expected:Te,responseTask:$e.task,selectedTask:bt}):bt))),$e.ok&&$e.task?(J($e.task.turnRef??$e.task.turnId),{ok:!0}):(ee($e.message??"Task state could not be changed."),{ok:!1,rotateActionId:$e.code==="stale_task"})}function Se(ue){const me=r.find(Te=>Te.id===ue.taskId),xe=T_({detailTaskId:O,detailOpened:z,highlightTurnRef:te,notifications:V.notifications,refreshGeneration:U.current},ue,!!me);if(se(Te=>({...Te,notifications:xe.notifications})),!me){m("This task is no longer present in the current snapshot.");return}Y(me,xe.highlightTurnRef)}return y.jsx(Qb,{defaultColorScheme:"auto",getStyleNonce:Ab?()=>Ab:void 0,theme:aN,children:y.jsxs(J_,{now:T,children:[y.jsxs(Hn,{className:"taskchef-shell",padding:0,children:[y.jsx(ai,{className:"taskchef-header",component:"header",size:1080,children:y.jsxs(Ct,{className:"taskchef-header-layout",align:"stretch",justify:"space-between",wrap:"nowrap",children:[y.jsxs(fe,{className:"taskchef-header-copy",children:[y.jsxs(De,{c:"var(--taskchef-accent)",fw:750,size:"xs",tt:"uppercase",children:["TaskChef ",p&&y.jsxs("span",{className:"taskchef-version",children:["v",p]})]}),y.jsxs(Ct,{gap:"sm",mt:5,wrap:"nowrap",children:[y.jsx(iN,{}),y.jsx(zn,{order:1,size:"h2",children:"Dashboard"})]})]}),y.jsxs(Tn,{align:"flex-end",className:"taskchef-header-actions",gap:0,justify:"space-between",children:[y.jsxs(Ct,{"aria-live":"polite",className:"taskchef-connection",gap:7,role:"status",wrap:"nowrap",children:[y.jsx(P3,{"aria-hidden":!0,color:s?"var(--mantine-color-teal-6)":"var(--mantine-color-yellow-6)",size:9}),y.jsx(De,{c:"dimmed",size:"xs",children:s?"Live":n?"Connecting…":"Fixture preview"})]}),y.jsx(rN,{})]})]})}),y.jsx(Hn.Main,{children:y.jsxs(ai,{className:"taskchef-main",pb:80,size:1080,children:[y.jsx(Rn,{className:"taskchef-toolbar",p:"sm",radius:"md",withBorder:!0,children:y.jsxs(Tn,{gap:"sm",children:[y.jsxs(Ct,{align:"end",gap:"sm",children:[y.jsx(nc,{"aria-label":"Project",data:ie,label:"Project",onChange:ue=>v(ue??""),size:"sm",value:S}),y.jsx(nc,{"aria-label":"Updated",data:[{label:"Latest 24 hours",value:"24h"},{label:"Latest 7 days",value:"7d"},{label:"All time",value:"all"}],label:"Updated",onChange:ue=>C(ue??"all"),size:"sm",value:E}),y.jsxs(fe,{className:"taskchef-task-count-field",children:[y.jsx(De,{className:"taskchef-filter-label",mb:3,children:"Tasks"}),y.jsxs(De,{className:"taskchef-count-value",size:"sm",children:[de.length," of ",r.length]})]})]}),y.jsxs(fe,{children:[y.jsx(De,{className:"taskchef-filter-label",mb:5,children:"Status"}),y.jsx(Zc,{"aria-label":"Status",data:ge,fullWidth:!0,onChange:w,size:"xs",value:g})]})]})}),f&&y.jsx(Xa,{color:"yellow",icon:y.jsx(z3,{"aria-hidden":!0,size:17}),mt:"md",role:"status",children:y.jsxs(Ct,{gap:"sm",justify:"space-between",wrap:"nowrap",children:[y.jsx(De,{size:"sm",children:f}),y.jsx(Za,{"aria-label":"Dismiss dashboard message",onClick:()=>m(null),size:"sm"})]})}),y.jsxs(Tn,{"aria-label":"Tasks",component:"section",gap:"sm",mt:"md",children:[de.map(ue=>y.jsx(W_,{onOpenCodex:he,onOpenDetail:me=>void Y(me),task:ue},ue.id)),de.length===0&&y.jsxs(Rn,{className:"taskchef-empty",p:48,ta:"center",withBorder:!0,children:[y.jsx(zn,{order:2,size:"h4",children:"No tasks match these filters"}),y.jsx(De,{c:"dimmed",mt:4,size:"sm",children:"Choose a different project, date, or status."})]})]})]})})]}),y.jsx(nN,{busy:L,error:k,highlightTurnRef:te,onClose:()=>{L||(U.current+=1,B(!1),J(null))},onCopy:()=>{_&&(le(null),navigator.clipboard.writeText(_.id).then(()=>le("Task ID copied."),()=>le("Clipboard access is unavailable. Copy the Task ID from metadata.")))},onOpenCodex:()=>_&&void he(_),onTransition:Me,opened:z,task:_,notice:ae,notifications:z?y.jsx(Rb,{announcements:V.announcements,notifications:V.notifications,onClear:()=>se(ue=>({...ue,notifications:wb({detailTaskId:O,detailOpened:z,highlightTurnRef:te,notifications:ue.notifications,refreshGeneration:U.current}).notifications})),onDismiss:ue=>se(me=>({...me,notifications:xb(me.notifications,ue.id)})),onOpen:Se,tasks:r,withinPortal:!1}):null}),!z&&y.jsx(Rb,{announcements:V.announcements,notifications:V.notifications,onClear:()=>se(ue=>({...ue,notifications:wb({detailTaskId:O,detailOpened:z,highlightTurnRef:te,notifications:ue.notifications,refreshGeneration:U.current}).notifications})),onDismiss:ue=>se(me=>({...me,notifications:xb(me.notifications,ue.id)})),onOpen:Se,tasks:r})]})})}function rN(){const{setColorScheme:n}=qb(),l=Vb("light"),r=l==="dark"?"light":"dark";return y.jsx(Ll,{label:`Use ${r} theme`,children:y.jsx(ya,{"aria-label":`Use ${r} theme`,color:"gray",onClick:()=>n(r),size:"lg",variant:"subtle",children:l==="dark"?y.jsx(K3,{"aria-hidden":!0,size:18}):y.jsx(Z3,{"aria-hidden":!0,size:18})})})}function iN(){const n=Vb("light");return y.jsx("img",{alt:"","aria-hidden":!0,className:"taskchef-brand-icon",height:"42",src:n==="dark"?"/assets/taskchef-dark.svg":"/assets/taskchef.svg",width:"42"})}u2.createRoot(document.getElementById("root")).render(y.jsx(x.StrictMode,{children:y.jsx(oN,{})}));
|
|
163
|
+
*/const J3=[["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"}]],P3=An("filled","circle-filled","CircleFilled",J3),W3=50,e_="Turn interrupted before a terminal report.",AS=[{value:"",label:"All"},{value:"working",label:"Working"},{value:"needs input",label:"Needs input"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}],t_=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"]]),n_=new Map([["24h",1440*60*1e3],["7d",10080*60*1e3],["all",null]]);function l_(n){return Date.parse(n.meaningfulUpdatedAt??n.updatedAt??n.createdAt)}function _S(n){return n.status===null?"unresolved":n.status.replaceAll("_"," ")}function a_(n){return{status:n.status,turnRef:n.turnRef,threadId:n.threadId,updatedAt:n.updatedAt}}function o_(n,l){return!!l&&n.status===l.status&&n.turnRef===l.turnRef&&n.threadId===l.threadId&&n.updatedAt===l.updatedAt}function Sb({requestTask:n,expected:l,responseTask:r,selectedTask:o}){const s=(o==null?void 0:o.id)===n.id?o:n;return o_(s,l)?r??s:s}function r_(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 i_(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 s_(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,u=o>=0?r[o].turnRef??r[o].turnId:null,f=o>=0&&u===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&&(u===s||f)?r[o]=n.latestTurn:(n.schemaVersion>=8&&o>=0&&r[o].result===null&&(r[o]={...r[o],result:{status:"interrupted",summary:e_,updatedAt:n.latestTurn.startedAt}}),r.push(n.latestTurn)),r}function Qc(n){return t_.get(n.event)??"Task updated"}function c_(n,l,r=Date.now()){const o=n_.get(l);if(o===null)return!0;if(o===void 0)return!1;const s=l_(n);return Number.isFinite(s)&&s>=r-o}function NS(n,{project:l="",status:r="",date:o="all",now:s=Date.now()}={}){return n.filter(u=>(!l||u.project.name===l)&&(!r||_S(u)===r)&&c_(u,o,s))}function u_(n,{project:l="",date:r="all",now:o=Date.now()}={}){const s=NS(n,{project:l,date:r,now:o});return Object.fromEntries(AS.map(({value:u})=>[u,u?s.filter(f=>_S(f)===u).length:s.length]))}function f_(n){return JSON.stringify([n.id,n.turnRef??n.turnId??null,n.turnId??null,n.status??"unresolved"])}function d_(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,u)=>u===1||s===o[u])}catch{return!1}}function m_(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 MS(n,l){return JSON.stringify(l==="created"?[n.id,null,l,n.createdAt??null]:[n.id,n.turnRef??n.turnId??null,l])}function p_(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 h_(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 Ho(n,l=m_(n)){const r=l==="created";return Object.freeze({id:MS(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:p_(n,l),summary:h_(n,l)})}function ks(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:MS({...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 g_(n,l){return`${l?"Open current task details":"Show task availability"} for ${n.title}: ${Qc(n)}`}function v_(n){return`Dismiss ${Qc(n)} notification for ${n.title}`}function xb(n,l){return n.filter(({id:r})=>r!==l)}function y_({initialized:n,notifications:l,seenIds:r=new Set,signatures:o},s){const u=new Map(o);for(const p of s)u.set(p.id,f_(p));const f=new Set(r);if(!n){for(const p of s){f.add(Ho(p,"created").id);const h=ks(p);h&&f.add(h.id),f.add(Ho(p).id)}return{additions:[],notifications:l,seenIds:f,signatures:u}}const m=[];for(const p of s){const h=[];if(o.has(p.id)){if(o.get(p.id)!==u.get(p.id)&&!d_(o.get(p.id),u.get(p.id))){h.push(Ho(p));const v=ks(p);v&&h.push(v)}}else{const v=ks(p);(p.turnRef||p.turnId||p.status!=="working"||v)&&(h.push(Ho(p)),v&&h.push(v)),h.push(Ho(p,"created"))}for(const v of h)f.has(v.id)||m.push(v),f.add(v.id);const S=ks(p);S&&f.add(S.id),f.add(Ho(p).id)}return{additions:m,notifications:[...m,...l].slice(0,W3),seenIds:f,signatures:u}}function b_({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 u=JSON.parse(s.data);l(u.message??"The task log is temporarily unavailable.")}),o}async function Kc(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 S_(){return(await Kc("/api/health")).taskchefVersion}async function x_(n){return(await Kc(`/api/tasks/${encodeURIComponent(n)}`)).task}async function w_(n){return(await Kc(`/api/tasks/${encodeURIComponent(n)}/open-codex`,{method:"POST"})).message??null}async function C_(n,l,r){const o=new AbortController,s=window.setTimeout(()=>o.abort(),1e4);try{return{ok:!0,task:(await Kc(`/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(u){const f=u.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)}}function T_(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 wb(n){return{...n,notifications:[]}}function Cb(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 Ys(n){var l,r,o,s,u,f,m;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,((u=(s=n==null?void 0:n.usage)==null?void 0:s.task)==null?void 0:u.totalTokens)??null,((m=(f=n==null?void 0:n.usage)==null?void 0:f.task)==null?void 0:m.estimatedCostUsd)??null])}function Sp(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2,notation:"compact"}).format(n)}function lc(n,l){return new Intl.NumberFormat(l,{maximumFractionDigits:2}).format(n)}function Io(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 OS(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?Tb(l.task,!0):{kind:"pending",label:"Token usage pending"}:(l==null?void 0:l.status)==="calculating"||o?{kind:"calculating",label:"Calculating token usage"}:(l==null?void 0:l.status)==="available"&&l.task?Tb(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 Tb(n,l){const r=Sp(n.totalTokens),o=n.estimatedCostUsd==null?"Estimated cost unavailable":`Estimated cost ${Io(n.estimatedCostUsd)}`;return{kind:"ready",knownSoFar:l,label:`${r} tokens · ${o}${l?" · known so far":""}`,usage:n}}function R_(n,l){var s,u;if(l.result===null)return{kind:"pending",label:"Turn usage pending"};const r=l.turnRef??l.turnId,o=r?(u=(s=n.usage)==null?void 0:s.turns)==null?void 0:u[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=lc(o.totalTokens),m=o.estimatedCostUsd==null?"Estimated cost unavailable":`Estimated cost ${Io(o.estimatedCostUsd)}`;return{kind:"ready",label:`${f} tokens · ${m}`}}return{kind:"unavailable",label:(o==null?void 0:o.reason)??"Turn usage unavailable"}}function E_(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 A_(n){var h;const l=OS(n);if(l.kind==="pending"||l.kind==="calculating")return{accessibleLabel:l.label,kind:l.kind,label:l.label,title:l.label};if(l.kind==="unavailable")return{accessibleLabel:`Token usage unavailable${l.label==="Token usage unavailable"?"":`: ${l.label}`}`,kind:"unavailable",label:"Token usage unavailable",title:l.label};const r=Sp(l.usage.totalTokens),o=lc(l.usage.totalTokens),s=l.usage.estimatedCostUsd==null?"cost unavailable":`est. ${Io(l.usage.estimatedCostUsd)}`,u=l.knownSoFar?" · Updating…":"",f=l.knownSoFar?"; updating":"",m=l.usage.sourceUpdatedAt??l.usage.sampledAt??((h=n.usage)==null?void 0:h.updatedAt)??null,p=m&&!Number.isNaN(Date.parse(m))?` Cached usage updated ${new Date(m).toLocaleString()}.`:"";return{accessibleLabel:`${o} tokens; ${l.usage.estimatedCostUsd==null?"estimated cost unavailable":`estimated cost ${Io(l.usage.estimatedCostUsd)}`}${f}.${p}`,kind:"ready",label:`${r} tokens · ${s}${u}`,title:`${o} tokens · ${l.usage.estimatedCostUsd==null?"estimated cost unavailable":`unrounded estimate $${l.usage.estimatedCostUsd}`}${u}.${p}`}}function __(n){return n==="completed"?"teal":n==="needs_input"?"yellow":n==="failed"?"red":n==="working"?"blue":"gray"}function N_(n){return n===null?"Unresolved":n.replaceAll("_"," ")}const M_=30,Yo=6e4,oi=60*Yo,Jr=24*oi;function zS(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 O_(n,{locale:l,timeZone:r}={}){const o=zS(n);return o?new Intl.DateTimeFormat(l,{dateStyle:"medium",timeStyle:"short",timeZone:r}).format(o.date):"—"}function z_(n,l){const r=Math.floor(n/oi),o=Math.floor(n%oi/Yo),s=r===1?"1 hour":`${r} hours`,u=r<6&&o>0?` ${o} minutes`:"";return l==="future"?`in ${s}${u}`:`${s}${u} ago`}function xp(n,{now:l=Date.now(),locale:r,timeZone:o}={}){const s=zS(n);if(!s)return"—";const u=l-s.milliseconds,f=u<0,m=Math.abs(u);if(m<Yo)return"just now";if(m<2*Yo)return f?"in 1 minute":"1 minute ago";if(m<oi){const p=f?Math.ceil(m/Yo):Math.floor(m/Yo);return f?`in ${p} minutes`:`${p} minutes ago`}if(m<2*oi)return f?"in 1 hour":"1 hour ago";if(m<Jr)return z_(m,f?"future":"past");if(m<2*Jr)return f?"in 1 day":"1 day ago";if(m<M_*Jr){const p=f?Math.ceil(m/Jr):Math.floor(m/Jr);return f?`in ${p} days`:`${p} days ago`}return new Intl.DateTimeFormat(r,{dateStyle:"medium",timeZone:o}).format(s.date)}function Fc({status:n}){return y.jsx(Nc,{className:"taskchef-status-badge",color:__(n),size:"sm",variant:"light",children:N_(n)})}function Rb({notifications:n,announcements:l=n,onClear:r,onDismiss:o,onOpen:s,tasks:u,withinPortal:f=!0}){if(n.length===0)return null;const m=y.jsxs(y.Fragment,{children:[y.jsxs(Rn,{"aria-label":"Task notifications",className:"taskchef-notifications",p:"sm",radius:"md",role:"region",shadow:"xl",withBorder:!0,children:[y.jsxs(Ct,{justify:"space-between",mb:"xs",children:[y.jsxs(Ct,{gap:6,children:[y.jsx(D3,{"aria-hidden":!0,size:16}),y.jsx(De,{fw:700,size:"sm",children:"Updates"})]}),y.jsx(ll,{onClick:r,size:"compact-xs",variant:"subtle",children:"Clear all"})]}),y.jsx(Bn.Autosize,{className:"taskchef-notification-scroll",mah:"min(55vh, 520px)",type:"auto",children:y.jsx(Tn,{className:"taskchef-notification-list",gap:6,children:n.map(p=>{const h=u.some(w=>w.id===p.taskId),S=`notification-${Math.abs(D_(p.id))}`,v=`${S}-summary`,g=`${S}-metadata`;return y.jsx(Rn,{className:"taskchef-notification",p:"xs",radius:"sm",children:y.jsxs(Ct,{align:"flex-start",gap:"xs",wrap:"nowrap",children:[y.jsxs("button",{"aria-describedby":[p.summary?v:null,g].filter(Boolean).join(" "),"aria-label":g_(p,h),className:"taskchef-notification-open",onClick:()=>s(p),type:"button",children:[y.jsxs(Ct,{gap:"xs",justify:"space-between",wrap:"nowrap",children:[y.jsx(De,{fw:700,size:"sm",children:Qc(p)}),y.jsx(Fc,{status:p.status})]}),y.jsx(De,{lineClamp:1,size:"sm",children:p.title}),p.summary&&y.jsx(De,{className:"taskchef-preserve-lines",id:v,lineClamp:3,size:"xs",children:p.summary}),y.jsxs(De,{c:"dimmed",id:g,size:"xs",children:[xp(p.timestamp),h?"":" · Task no longer available"]})]}),y.jsx(Ll,{label:"Dismiss notification",children:y.jsx(ya,{"aria-label":v_(p),color:"gray",onClick:()=>o(p),size:"compact-sm",variant:"subtle",children:y.jsx(ES,{"aria-hidden":!0,size:14})})})]})},p.id)})})})]}),y.jsx(fe,{"aria-atomic":"true","aria-live":"polite",className:"taskchef-visually-hidden",role:"status",children:l.map(j_).join(" ")})]});return f?y.jsx(Um,{children:m}):m}function j_(n){return[Qc(n),n.title,n.summary,n.turnRef?`Turn ref ${n.turnRef}`:null,xp(n.timestamp)].filter(Boolean).map(l=>String(l).replace(/[.\s]+$/,"")).join(". ")+"."}function D_(n){let l=0;for(const r of n)l=(l<<5)-l+r.charCodeAt(0)|0;return l}const $_=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]+$/,L_=/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,B_=/https?:\/\/[^\s<>"'`]+/gi;function Jc(n){return!(n!=null&&n.owner)||!(n!=null&&n.repository)?null:`${n.owner.toLowerCase()}/${n.repository.toLowerCase()}`}function H_(n){const l=new Map;for(const r of n){const o=Jc(r);if(!o)continue;const s=r.repository.toLowerCase(),u=l.get(s)??new Set;u.add(o),l.set(s,u)}return new Set([...l].filter(([,r])=>r.size>1).map(([r])=>r))}function U_(n,l){return l.has(n.repository.toLowerCase())?`${n.owner}/${n.repository}`:n.repository}function jS(n,{related:l=!1}={}){const r=H_(n);let o=null;return n.map(s=>{if(s.provider!=="github"&&!s.owner)return s.label??s.text;const u=Jc(s),f=U_(s,r);if(s.type==="repository")return f;if(l){const m=u===o?`#${s.number}`:`${f} #${s.number}`;return o=u,m}return s.type==="pull"?`${f} PR #${s.number}`:s.type==="issue"?`${f} Issue #${s.number}`:`${f} #${s.number}`})}function k_(n,l){const r=String(n.number??""),o=String(l.number??"");return r.length-o.length||r.localeCompare(o)}function Y_(n){const l=new Map,r=new Set,o=new Set,s=new Set;for(const u of n??[]){const f=Jc(u),m=u.number?`${f}#${u.number}`:null;if(u.type==="repository"||!f||r.has(u.label)||s.has(u.url)||m&&o.has(m))continue;r.add(u.label),s.add(u.url),m&&o.add(m);const p=l.get(f)??[];p.push(u),l.set(f,p)}return[...l.values()].map(u=>[...u].sort(k_))}function DS(n){const l=Jc(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 $S(n,l){return`${n.toLowerCase()}/${l.toLowerCase()}`}function LS(n){return n!=="."&&n!==".."}function BS(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]}`),!$_.test(l))return null;const[o,s]=l.split("/");return LS(s)?$S(o,s):null}function q_(n){var s;const l=String(n??""),r=HS(l),o=[];for(const u of l.matchAll(L_)){const f=u.index,m=f>0?l[f-1]:"";let p=null;const h=r.find(T=>f>=T.start&&f<T.end);if(h){const T=!!(u[1]||u[9]);let A=null;try{A=new URL(h.text).hostname.toLowerCase()}catch{}if(!(T&&f===h.start&&(A==="github.com"||A==="www.github.com"))||!US(h.text))continue;p={end:h.end,suffix:h.text.slice(u[0].length),text:h.text}}if(u[8]&&/[\w&#/]/.test(m)||(u[5]||u[1]||u[9])&&/[\w/]/.test(m))continue;let S=u[1]??u[5]??u[9]??null,v=u[2]??u[6]??u[10]??null;u[9]&&(v=v.replace(/\.git$/i,""));const g=u[4]??u[7]??u[8]??null,w=(s=u[3])==null?void 0:s.toLowerCase(),E=u[9]?"repository":w==="pull"?"pull":w==="issues"?"issue":"generic",C=!!(S&&v);if(C){if(!LS(v))continue;[S,v]=$S(S,v).split("/")}o.push({end:(p==null?void 0:p.end)??f+u[0].length,explicit:C,number:g,owner:S,repository:v,start:f,text:(p==null?void 0:p.text)??u[0],type:E,urlSuffix:(p==null?void 0:p.suffix)??""})}return o}function V_(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 G_(n){const l=new Set((n??[]).map(BS).filter(Boolean));return l.size===1?[...l][0]:null}function X_(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 u=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}/${u}/${n.number}${n.urlSuffix}`}}function I_(n){let l=n,r;do{r=l,l=l.replace(/[.,;:!?]+$/u,"");for(const[o,s]of[["(",")"],["[","]"],["{","}"]])for(;l.endsWith(s);){const u=[...l].filter(m=>m===o).length;if([...l].filter(m=>m===s).length<=u)break;l=l.slice(0,-1)}}while(l!==r);return l}function HS(n){const l=[];for(const r of String(n??"").matchAll(B_)){const o=I_(r[0]);o&&l.push({end:r.index+o.length,start:r.index,text:o})}return l}function Z_(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 US(n){try{const l=new URL(n);return!l.hostname||l.username||l.password||n.includes("\\")||Z_(n)?null:l.href}catch{return null}}function Q_(n){const l=[];for(const r of HS(n)){const o=US(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 K_(n,{projectRepositories:l=[],taskRepository:r=null}={}){const o=String(n??""),s=q_(o),f=V_(s)??BS(r)??G_(l),m=[];let p=0;for(const h of s){h.start>p&&m.push({kind:"text",text:o.slice(p,h.start)});const S=X_(h,f);S?m.push(S):m.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&&m.push({kind:"text",text:o.slice(p)}),m}function F_(n,l={}){const r=String(n??""),o=K_(r,l),s=[];let u=0;for(const h of o){const S=r.indexOf(h.text,u);S<0||(h.kind!=="text"&&s.push({end:S+h.text.length,segment:h,start:S}),u=S+h.text.length)}const f=Q_(r).filter(h=>!s.some(({end:S,start:v})=>h.start<S&&h.end>v));if(f.length===0)return o;s.push(...f.map(h=>({end:h.end,segment:h,start:h.start}))),s.sort((h,S)=>h.start-S.start);const m=[];let p=0;for(const h of s)h.start<p||(h.start>p&&m.push({kind:"text",text:r.slice(p,h.start)}),m.push(h.segment),p=h.end);return p<r.length&&m.push({kind:"text",text:r.slice(p)}),m}function kS({task:n}){const l=n.relatedGitHubLinks??[];if(l.length===0&&!n.relatedGitHubLinksTruncated)return null;const r=Y_(l),o=jS(r.flat(),{related:!0});let s=0;return y.jsxs(fe,{"aria-label":`Related GitHub links for ${n.title}`,className:"taskchef-github-groups",component:"nav",children:[r.map(u=>y.jsx(Ct,{className:"taskchef-github-group",gap:5,wrap:"wrap",children:u.map(f=>{const m=o[s];s+=1;const p=f.type==="pull"?", GitHub pull request":f.type==="issue"?", GitHub issue":" on GitHub";return y.jsx(Ac,{"aria-label":`${DS(f)}${p} (opens in a new tab)`,className:"taskchef-github-link",href:f.url,rel:"noopener noreferrer",size:"xs",target:"_blank",children:m},f.url)})},`${u[0].owner}/${u[0].repository}`)),n.relatedGitHubLinksTruncated&&y.jsx(De,{c:"dimmed",size:"xs",children:"More links in task history"})]})}function ac({task:n,text:l}){const r=F_(l,{projectRepositories:n.project.githubRepos,taskRepository:n.relatedGitHubRepository}),o=r.filter(f=>f.kind==="link"),s=jS(o);let u=0;return r.map((f,m)=>{if(f.kind==="text")return f.text;if(f.kind==="ambiguous")return y.jsx("span",{"aria-label":f.reason,className:"taskchef-github-reference-ambiguous",tabIndex:0,title:f.reason,children:f.text},`${m}:${f.text}`);const p=s[u];u+=1;const h=f.type==="pull"?", GitHub pull request":f.type==="issue"?", GitHub issue":f.owner?" on GitHub":"";return y.jsx(Ac,{"aria-label":`${DS(f)}${h} (opens in a new tab)`,className:"taskchef-github-link",href:f.url,rel:"noopener noreferrer",target:"_blank",children:p},`${m}:${f.url}`)})}const YS=x.createContext(null);function J_({children:n,now:l}){return y.jsx(YS,{value:l,children:n})}function oc({label:n,value:l}){const[r,o]=x.useState(!1);x.useContext(YS);const s=r?O_(l):xp(l);return y.jsx(Ll,{label:r?"Show relative time":"Show exact time",children:y.jsxs(zl,{"aria-label":`${n}: ${s}. ${r?"Show relative time":"Show exact time"}`,className:"taskchef-time",onClick:()=>o(u=>!u),children:[y.jsx(k3,{"aria-hidden":!0,size:12}),y.jsx("span",{className:"taskchef-time-label",children:s})]})})}function ri({children:n,className:l="",...r}){return y.jsx("span",{className:`taskchef-shimmer ${l}`.trim(),"data-animation":"text-shimmer",...r,children:n})}function P_({task:n}){const l=A_(n),r=l.kind==="pending"||l.kind==="calculating"?y.jsx(ri,{children:l.label}):l.label;return y.jsx(De,{"aria-label":l.accessibleLabel,"aria-live":"polite",c:"dimmed",className:"taskchef-task-usage","data-usage-state":l.kind,size:"xs",title:l.title,children:r})}function W_({onOpenCodex:n,onOpenDetail:l,task:r}){const o=r_(r);return y.jsx(Rn,{className:"taskchef-task-row",component:"article",p:"md",radius:"md",withBorder:!0,children:y.jsxs(Tn,{className:"taskchef-task-main",gap:"sm",children:[y.jsxs(fe,{children:[y.jsxs(fe,{className:"taskchef-card-heading",children:[y.jsx(zn,{order:3,size:"h5",children:y.jsx("button",{className:"taskchef-title-button",onClick:()=>l(r),type:"button",children:r.title})}),y.jsxs(Tn,{align:"flex-end",className:"taskchef-card-metadata",gap:4,children:[y.jsx(Fc,{status:r.status}),y.jsx(P_,{task:r})]})]}),y.jsx(De,{c:"dimmed",mt:2,size:"xs",children:r.project.name})]}),y.jsxs(fe,{className:"taskchef-summary-grid",children:[y.jsx(De,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Request"}),y.jsx(De,{className:"taskchef-preserve-lines",lineClamp:3,size:"sm",children:y.jsx(ac,{task:r,text:o.requestSummary})}),y.jsx(De,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Result"}),y.jsx(De,{className:"taskchef-preserve-lines",lineClamp:3,size:"sm",children:o.resultStatus==="working"?y.jsx(ri,{children:o.resultSummary}):y.jsx(ac,{task:r,text:o.resultSummary})})]}),y.jsx(kS,{task:r}),y.jsxs(Ct,{className:"taskchef-card-footer",gap:"md",justify:"space-between",children:[y.jsx(oc,{label:`Updated time for ${r.title}`,value:r.meaningfulUpdatedAt??r.updatedAt}),y.jsx(ll,{"aria-label":`Open chat for ${r.title}`,leftSection:y.jsx(RS,{"aria-hidden":!0,size:15}),onClick:()=>n(r),size:"compact-sm",variant:"default",children:"Open chat"})]})]})})}function eN({highlightTurnRef:n,task:l}){const r=s_(l,[]);return r!=null&&r.length?y.jsx(Tn,{gap:"sm",children:[...r].reverse().map((o,s)=>{const u=i_(o),f=o.turnRef??o.turnId??`turn-${s}`,m=f===n,p=R_(l,o);return y.jsx(Rn,{className:`taskchef-turn${m?" taskchef-turn-highlighted":""}`,"data-turn-ref":f,p:"sm",radius:"md",tabIndex:m?-1:void 0,withBorder:!0,children:y.jsxs(Tn,{gap:7,children:[y.jsxs(fe,{className:"taskchef-turn-heading",children:[y.jsx(Fc,{status:u.status}),y.jsx(oc,{label:"Turn update time",value:u.updatedAt})]}),u.sourceLabel&&y.jsx(De,{c:"dimmed",size:"xs",children:u.sourceLabel}),y.jsxs(fe,{children:[y.jsx(De,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Request"}),y.jsx(De,{className:"taskchef-preserve-lines",size:"sm",children:y.jsx(ac,{task:l,text:o.requestSummary??"Request not recorded."})})]}),y.jsxs(fe,{children:[y.jsx(De,{c:"dimmed",className:"taskchef-field-label",size:"xs",children:"Result"}),y.jsx(De,{className:"taskchef-preserve-lines",size:"sm",children:u.status==="working"?y.jsx(ri,{children:u.summary}):y.jsx(ac,{task:l,text:u.summary})})]}),y.jsx(De,{c:"dimmed",className:p.kind==="calculating"||p.kind==="pending"?"taskchef-turn-usage":void 0,size:"xs",children:p.kind==="calculating"||p.kind==="pending"?y.jsx(ri,{children:p.label}):p.label}),y.jsxs(De,{c:"dimmed",className:"taskchef-mono",size:"xs",children:["Turn ref: ",f??"—"]})]})},f)})}):y.jsx(De,{c:"dimmed",size:"sm",children:"No turn history has been recorded."})}function tN({task:n}){const l=OS(n);if(l.kind==="pending"||l.kind==="calculating")return y.jsx(Rn,{"aria-live":"polite",className:"taskchef-subtle-panel",p:"sm",radius:"md",children:y.jsxs(Ct,{gap:"xs",children:[y.jsx(q3,{"aria-hidden":!0,size:16}),y.jsx(De,{size:"sm",children:y.jsx(ri,{children:l.label})})]})});if(l.kind==="unavailable")return y.jsx(De,{"aria-live":"polite",c:"dimmed",size:"sm",children:l.label});const r=l.usage.cachedInputTokens??0,o=l.usage.inputTokens??0,s=o+r>0?`${Math.round(r/(o+r)*100)}%`:"—",u=[{accessibleValue:`${lc(l.usage.totalTokens)} tokens`,label:l.knownSoFar?"Tokens · known so far":"Tokens",title:`${lc(l.usage.totalTokens)} tokens`,value:Sp(l.usage.totalTokens)},{accessibleValue:l.usage.estimatedCostUsd==null?"Estimated cost unavailable":`Estimated cost ${Io(l.usage.estimatedCostUsd)}`,label:"Estimated cost",title:l.usage.estimatedCostUsd==null?void 0:`Unrounded estimate: $${l.usage.estimatedCostUsd}`,value:Io(l.usage.estimatedCostUsd)},{label:"Model",value:Object.keys(l.usage.models??{}).join(", ")||"—"},{label:"Cache ratio",value:s}];return y.jsx(fe,{"aria-live":"polite",className:"taskchef-metrics",children:u.map(({accessibleValue:f,label:m,title:p,value:h})=>y.jsxs(Rn,{className:"taskchef-metric",p:"sm",radius:"md",withBorder:!0,children:[y.jsx(De,{c:"dimmed",size:"xs",children:m}),y.jsx(De,{"aria-label":f,className:"taskchef-metric-value",fw:650,size:"sm",title:p,children:h})]},m))})}function nN({busy:n,error:l,highlightTurnRef:r,onClose:o,onCopy:s,onOpenCodex:u,onTransition:f,opened:m,task:p,notifications:h,notice:S}){var T;const v=um("(max-width: 48em)"),[g,w]=x.useState(null);if(x.useEffect(()=>{m||w(null)},[m]),x.useEffect(()=>{m&&r&&requestAnimationFrame(()=>{var A;(A=document.querySelector(`[data-turn-ref="${CSS.escape(r)}"]`))==null||A.focus()})},[r,m,(T=p==null?void 0:p.turns)==null?void 0:T.length,p==null?void 0:p.updatedAt]),x.useEffect(()=>{g&&(!p||!Eb(p).includes(g))&&w(null)},[g,p==null?void 0:p.status]),!p)return null;const E=Eb(p),C=y.jsxs(Tn,{gap:"lg",children:[h,y.jsxs(fe,{children:[y.jsxs(Ct,{align:"flex-start",gap:"sm",justify:"space-between",wrap:"nowrap",children:[y.jsxs(fe,{children:[y.jsx(De,{c:"teal",fw:700,size:"xs",tt:"uppercase",children:p.project.name}),y.jsx(zn,{id:"task-detail-title",order:2,size:"h3",tabIndex:-1,children:p.title})]}),y.jsx(Fc,{status:p.status})]}),y.jsxs(Ct,{gap:"xs",mt:"md",children:[y.jsx(ll,{leftSection:y.jsx(RS,{"aria-hidden":!0,size:15}),loading:n,onClick:u,size:"compact-sm",children:"Open chat"}),y.jsxs(pt,{position:"bottom-start",shadow:"md",withinPortal:!0,zIndex:360,children:[y.jsx(pt.Target,{children:y.jsx(Ll,{label:"More task actions",children:y.jsx(ya,{"aria-label":"More task actions",disabled:n,variant:"default",children:y.jsx(G3,{"aria-hidden":!0,size:17})})})}),y.jsxs(pt.Dropdown,{children:[y.jsx(pt.Item,{leftSection:y.jsx(H3,{size:14}),onClick:s,children:"Copy Task ID"}),E.includes("completed")&&y.jsx(pt.Item,{leftSection:y.jsx(L3,{size:14}),onClick:()=>w("completed"),children:"Mark completed"}),E.includes("failed")&&y.jsx(pt.Item,{color:"red",leftSection:y.jsx(ES,{size:14}),onClick:()=>w("failed"),children:"Mark failed"})]})]})]}),y.jsx(fe,{mt:"sm",children:y.jsx(kS,{task:p})})]}),g&&y.jsx(lN,{busy:n,onCancel:()=>w(null),onTransition:f,status:g},g),S&&y.jsx(Xa,{color:"teal",role:"status",children:S}),l&&y.jsx(Xa,{color:"red",role:"alert",children:l}),y.jsxs("section",{"aria-labelledby":"usage-heading",children:[y.jsx(zn,{id:"usage-heading",mb:"xs",order:3,size:"h5",children:"Usage"}),y.jsx(tN,{task:p})]}),y.jsx(zc,{}),y.jsxs("section",{"aria-labelledby":"activity-heading",children:[y.jsx(zn,{id:"activity-heading",mb:"sm",order:3,size:"h5",children:"Activity timeline"}),y.jsx(eN,{highlightTurnRef:r,task:p})]}),y.jsxs("section",{"aria-labelledby":"instruction-heading",children:[y.jsx(zn,{id:"instruction-heading",mb:"xs",order:3,size:"h5",children:"Original instruction"}),y.jsx(fe,{className:"taskchef-code-panel",component:"pre",children:p.instruction})]}),y.jsxs("section",{"aria-labelledby":"metadata-heading",children:[y.jsx(zn,{id:"metadata-heading",mb:"xs",order:3,size:"h5",children:"Metadata"}),y.jsxs("dl",{className:"taskchef-metadata",children:[y.jsx("dt",{children:"Task ID"}),y.jsx("dd",{children:p.id}),y.jsx("dt",{children:"Thread ID"}),y.jsx("dd",{children:p.threadId??"—"}),y.jsx("dt",{children:"Current turn ref"}),y.jsx("dd",{children:p.turnRef??"—"}),y.jsx("dt",{children:"Project path"}),y.jsx("dd",{children:p.project.path}),y.jsx("dt",{children:"Created"}),y.jsx("dd",{children:y.jsx(oc,{label:"Created time",value:p.createdAt})}),y.jsx("dt",{children:"Updated"}),y.jsx("dd",{children:y.jsx(oc,{label:"Updated time",value:p.meaningfulUpdatedAt??p.updatedAt})}),y.jsx("dt",{children:"Updated by"}),y.jsx("dd",{children:p.updatedBy??"—"})]})]})]});return v?y.jsx(Yn,{closeOnClickOutside:!n,closeOnEscape:!n,onClose:o,opened:m,overlayProps:{backgroundOpacity:.55,blur:2},position:"bottom",scrollAreaComponent:Bn.Autosize,size:"92%",title:y.jsx("span",{className:"taskchef-visually-hidden",children:"Task details"}),trapFocus:!0,zIndex:300,children:C}):y.jsx(Vn,{"aria-labelledby":"task-detail-title",closeOnClickOutside:!n,closeOnEscape:!n,onClose:o,opened:m,overlayProps:{backgroundOpacity:.55,blur:2},scrollAreaComponent:Bn.Autosize,size:"min(820px, calc(100vw - 32px))",title:y.jsx("span",{className:"taskchef-visually-hidden",children:"Task details"}),trapFocus:!0,zIndex:300,children:C})}function Eb(n){return n.status==="completed"?["failed"]:n.status==="failed"?["completed"]:n.status==="working"||n.status==="needs_input"?["completed","failed"]:[]}function lN({busy:n,onCancel:l,onTransition:r,status:o}){const s=x.useRef(crypto.randomUUID());return y.jsxs(Xa,{color:o==="failed"?"red":"teal",role:"alert",title:`Mark task ${o}?`,children:[y.jsx(De,{mb:"sm",size:"sm",children:"This interrupts active work and appends an audited manual dashboard turn."}),y.jsxs(Ct,{gap:"xs",children:[y.jsx(ll,{color:o==="failed"?"red":"teal",loading:n,onClick:async()=>{const u=await r(o,s.current);u.ok?(l(),requestAnimationFrame(()=>{var f;return(f=document.getElementById("task-detail-title"))==null?void 0:f.focus()})):u.rotateActionId&&(s.current=crypto.randomUUID())},size:"compact-sm",children:"Confirm"}),y.jsx(ll,{disabled:n,onClick:l,size:"compact-sm",variant:"default",children:"Cancel"})]})]})}const aN={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 _b;const Ab=(_b=document.querySelector('meta[name="taskchef-style-nonce"]'))==null?void 0:_b.content;function oN({connect:n=!0,initialTasks:l=[]}){const[r,o]=x.useState(l),[s,u]=x.useState(!1),[f,m]=x.useState(null),[p,h]=x.useState(null),[S,v]=x.useState(""),[g,w]=x.useState(""),[E,C]=x.useState("all"),[T,A]=x.useState(()=>Date.now()),[_,N]=x.useState(null),[z,B]=x.useState(!1),[L,D]=x.useState(!1),[k,ee]=x.useState(null),[ae,le]=x.useState(null),[te,J]=x.useState(null),[V,se]=x.useState({initialized:l.length>0,announcements:[],notifications:[],seenIds:new Set,signatures:new Map}),O=(_==null?void 0:_.id)??null,H=x.useRef(O);H.current=O;const U=x.useRef(0),K=x.useRef(null),P=x.useRef(Ys(null)),M=x.useCallback(ue=>{o(ue.tasks),se(xe=>{const Te=y_(xe,ue.tasks);return{initialized:!0,announcements:Te.additions,notifications:Te.notifications,seenIds:Te.seenIds,signatures:Te.signatures}}),m(ue.healthy===!1?"The task log is temporarily unavailable. Showing the last valid snapshot.":null);const me=H.current;if(me){const xe=ue.tasks.find(Te=>Te.id===me);xe&&N(Te=>Te?Cb(Te,xe):xe)}},[]);x.useEffect(()=>{const ue=window.setInterval(()=>A(Date.now()),3e4);return()=>window.clearInterval(ue)},[]),x.useEffect(()=>{if(!n)return;S_().then(h).catch(()=>h(null));const ue=b_({onConnection:u,onError:m,onSnapshot:M});return()=>ue.close()},[M,n]);const Y=x.useCallback(async(ue,me=null)=>{const xe=++U.current;K.current=ue.updatedAt,P.current=Ys(ue),N(Te=>(Te==null?void 0:Te.id)===ue.id?Cb(Te,ue):ue),B(!0),J(me),ee(null),le(null);try{for(let Te=0;Te<=40;Te+=1){if(xe!==U.current)return;const $e=await x_(ue.id);if(xe!==U.current||(K.current=$e.updatedAt,P.current=Ys($e),N($e),!E_($e)||Te===40))return;await new Promise(it=>window.setTimeout(it,1500))}}catch{xe===U.current&&ee("Task activity is temporarily unavailable. Showing the latest list snapshot.")}},[]),F=r.find(ue=>ue.id===O)??null,re=Ys(F);x.useEffect(()=>{!z||!O||!n||F&&(F.updatedAt===K.current&&re===P.current||Y(F,te))},[F==null?void 0:F.updatedAt,re]);const ie=x.useMemo(()=>[{label:"All projects",value:""},...[...new Set(r.map(ue=>ue.project.name))].sort().map(ue=>({label:ue,value:ue}))],[r]),de=x.useMemo(()=>NS(r,{project:S,status:g,date:E,now:T}),[r,S,g,E,T]),ye=x.useMemo(()=>u_(r,{project:S,date:E,now:T}),[r,S,E,T]),ge=AS.map(({label:ue,value:me})=>({label:ye[me]>0?`${ue} ${ye[me]}`:ue,value:me}));async function he(ue){D(!0);try{const me=await w_(ue.id);me&&m(me)}catch{m("Codex could not be opened. Open the project and select the recorded task instead.")}finally{D(!1)}}async function Me(ue,me){if(!_)return{ok:!1};const xe=_,Te=a_(xe);D(!0),ee(null);const $e=await C_(xe,ue,me);return D(!1),$e.task&&(N(it=>Sb({requestTask:xe,expected:Te,responseTask:$e.task,selectedTask:it})),o(it=>it.map(bt=>bt.id===xe.id?Sb({requestTask:xe,expected:Te,responseTask:$e.task,selectedTask:bt}):bt))),$e.ok&&$e.task?(J($e.task.turnRef??$e.task.turnId),{ok:!0}):(ee($e.message??"Task state could not be changed."),{ok:!1,rotateActionId:$e.code==="stale_task"})}function Se(ue){const me=r.find(Te=>Te.id===ue.taskId),xe=T_({detailTaskId:O,detailOpened:z,highlightTurnRef:te,notifications:V.notifications,refreshGeneration:U.current},ue,!!me);if(se(Te=>({...Te,notifications:xe.notifications})),!me){m("This task is no longer present in the current snapshot.");return}Y(me,xe.highlightTurnRef)}return y.jsx(Qb,{defaultColorScheme:"auto",getStyleNonce:Ab?()=>Ab:void 0,theme:aN,children:y.jsxs(J_,{now:T,children:[y.jsxs(Hn,{className:"taskchef-shell",padding:0,children:[y.jsx(ai,{className:"taskchef-header",component:"header",size:1080,children:y.jsxs(Ct,{className:"taskchef-header-layout",align:"stretch",justify:"space-between",wrap:"nowrap",children:[y.jsxs(fe,{className:"taskchef-header-copy",children:[y.jsxs(De,{c:"var(--taskchef-accent)",fw:750,size:"xs",tt:"uppercase",children:["TaskChef ",p&&y.jsxs("span",{className:"taskchef-version",children:["v",p]})]}),y.jsxs(Ct,{gap:"sm",mt:5,wrap:"nowrap",children:[y.jsx(iN,{}),y.jsx(zn,{order:1,size:"h2",children:"Dashboard"})]})]}),y.jsxs(Tn,{align:"flex-end",className:"taskchef-header-actions",gap:0,justify:"space-between",children:[y.jsxs(Ct,{"aria-live":"polite",className:"taskchef-connection",gap:7,role:"status",wrap:"nowrap",children:[y.jsx(P3,{"aria-hidden":!0,color:s?"var(--mantine-color-teal-6)":"var(--mantine-color-yellow-6)",size:9}),y.jsx(De,{c:"dimmed",size:"xs",children:s?"Live":n?"Connecting…":"Fixture preview"})]}),y.jsx(rN,{})]})]})}),y.jsx(Hn.Main,{children:y.jsxs(ai,{className:"taskchef-main",pb:80,size:1080,children:[y.jsx(Rn,{className:"taskchef-toolbar",p:"sm",radius:"md",withBorder:!0,children:y.jsxs(Tn,{gap:"sm",children:[y.jsxs(Ct,{align:"end",gap:"sm",children:[y.jsx(nc,{"aria-label":"Project",data:ie,label:"Project",onChange:ue=>v(ue??""),size:"sm",value:S}),y.jsx(nc,{"aria-label":"Updated",data:[{label:"Latest 24 hours",value:"24h"},{label:"Latest 7 days",value:"7d"},{label:"All time",value:"all"}],label:"Updated",onChange:ue=>C(ue??"all"),size:"sm",value:E}),y.jsxs(fe,{className:"taskchef-task-count-field",children:[y.jsx(De,{className:"taskchef-filter-label",mb:3,children:"Tasks"}),y.jsxs(De,{className:"taskchef-count-value",size:"sm",children:[de.length," of ",r.length]})]})]}),y.jsxs(fe,{children:[y.jsx(De,{className:"taskchef-filter-label",mb:5,children:"Status"}),y.jsx(Zc,{"aria-label":"Status",data:ge,fullWidth:!0,onChange:w,size:"xs",value:g})]})]})}),f&&y.jsx(Xa,{color:"yellow",icon:y.jsx(z3,{"aria-hidden":!0,size:17}),mt:"md",role:"status",children:y.jsxs(Ct,{gap:"sm",justify:"space-between",wrap:"nowrap",children:[y.jsx(De,{size:"sm",children:f}),y.jsx(Za,{"aria-label":"Dismiss dashboard message",onClick:()=>m(null),size:"sm"})]})}),y.jsxs(Tn,{"aria-label":"Tasks",component:"section",gap:"sm",mt:"md",children:[de.map(ue=>y.jsx(W_,{onOpenCodex:he,onOpenDetail:me=>void Y(me),task:ue},ue.id)),de.length===0&&y.jsxs(Rn,{className:"taskchef-empty",p:48,ta:"center",withBorder:!0,children:[y.jsx(zn,{order:2,size:"h4",children:"No tasks match these filters"}),y.jsx(De,{c:"dimmed",mt:4,size:"sm",children:"Choose a different project, date, or status."})]})]})]})})]}),y.jsx(nN,{busy:L,error:k,highlightTurnRef:te,onClose:()=>{L||(U.current+=1,B(!1),J(null))},onCopy:()=>{_&&(le(null),navigator.clipboard.writeText(_.id).then(()=>le("Task ID copied."),()=>le("Clipboard access is unavailable. Copy the Task ID from metadata.")))},onOpenCodex:()=>_&&void he(_),onTransition:Me,opened:z,task:_,notice:ae,notifications:z?y.jsx(Rb,{announcements:V.announcements,notifications:V.notifications,onClear:()=>se(ue=>({...ue,notifications:wb({detailTaskId:O,detailOpened:z,highlightTurnRef:te,notifications:ue.notifications,refreshGeneration:U.current}).notifications})),onDismiss:ue=>se(me=>({...me,notifications:xb(me.notifications,ue.id)})),onOpen:Se,tasks:r,withinPortal:!1}):null}),!z&&y.jsx(Rb,{announcements:V.announcements,notifications:V.notifications,onClear:()=>se(ue=>({...ue,notifications:wb({detailTaskId:O,detailOpened:z,highlightTurnRef:te,notifications:ue.notifications,refreshGeneration:U.current}).notifications})),onDismiss:ue=>se(me=>({...me,notifications:xb(me.notifications,ue.id)})),onOpen:Se,tasks:r})]})})}function rN(){const{setColorScheme:n}=qb(),l=Vb("light"),r=l==="dark"?"light":"dark";return y.jsx(Ll,{label:`Use ${r} theme`,children:y.jsx(ya,{"aria-label":`Use ${r} theme`,color:"gray",onClick:()=>n(r),size:"lg",variant:"subtle",children:l==="dark"?y.jsx(K3,{"aria-hidden":!0,size:18}):y.jsx(Z3,{"aria-hidden":!0,size:18})})})}function iN(){const n=Vb("light");return y.jsx("img",{alt:"","aria-hidden":!0,className:"taskchef-brand-icon",height:"42",src:n==="dark"?"/assets/taskchef-dark.svg":"/assets/taskchef.svg",width:"42"})}u2.createRoot(document.getElementById("root")).render(y.jsx(x.StrictMode,{children:y.jsx(oN,{})}));
|
|
164
164
|
//# sourceMappingURL=app.js.map
|