meshy-node 0.10.8 → 0.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dashboard/assets/DashboardPage-Dr7Q3ARl.js +191 -0
- package/dashboard/assets/{DashboardShared-BfK1KyJO.js → DashboardShared-DihTM-xx.js} +4 -4
- package/dashboard/assets/{DiffTab-BPQY3AYd.js → DiffTab-BuC8qgFb.js} +2 -2
- package/dashboard/assets/{FilesTab-91w4HaID.js → FilesTab-jvuvGCqQ.js} +2 -2
- package/dashboard/assets/{MarkdownPreviewFrame-C56qjNyn.js → MarkdownPreviewFrame-CwXixe62.js} +1 -1
- package/dashboard/assets/{PreviewTab-DQ4yhJji.js → PreviewTab-oRD3Wntx.js} +5 -5
- package/dashboard/assets/SharedConversationPage-Psgl27Kx.js +2 -0
- package/dashboard/assets/{file-DQcCuz7j.js → file-CoTh89vx.js} +1 -1
- package/dashboard/assets/{index-BvnWYZW6.js → index-BBHpcOD3.js} +26 -26
- package/dashboard/assets/index-CE-vUwSy.css +1 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +898 -777
- package/package.json +1 -1
- package/runtime-metadata.json +4 -4
- package/dashboard/assets/DashboardPage-BA5_31Nu.js +0 -181
- package/dashboard/assets/SharedConversationPage-hiwRfWZA.js +0 -2
- package/dashboard/assets/index-By1kKB26.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as be,j as m,G as Ml,aq as Fl,d as $e,H as Ol,J as Rl,ar as Bl,Z as $l,
|
|
1
|
+
import{c as be,j as m,G as Ml,aq as Fl,d as $e,H as Ol,J as Rl,ar as Bl,Z as $l,bU as Kr,T as Zr,o as _t,bV as Ul,bW as Hl,bX as ql,bY as ei,r as fe,B as At,C as He,X as ti,V as Vl,y as Wl,L as Gl,M as ni}from"./index-BBHpcOD3.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -78,7 +78,7 @@ import{c as be,j as m,G as Ml,aq as Fl,d as $e,H as Ol,J as Rl,ar as Bl,Z as $l,
|
|
|
78
78
|
`):""}function gh(e){const t=e.message;return typeof t=="object"&&t!==null&&Array.isArray(t.content)?t.content:Array.isArray(e.content)?e.content:[]}function kl(e){return e.flatMap(t=>gh(t).flatMap(n=>{if(n.type==="thinking"){const r=String(n.thinking??"").trim();return r?[{title:"Thinking",preview:ve(r,112),block:n,kind:"thinking",status:"success"}]:[]}if(n.type==="tool_use")return[{title:`Tool: ${String(n.name??"tool")}`,preview:ml(n.input),block:n,kind:"tool_use",status:"success"}];if(n.type==="tool_result"){const r=ve(qn(n),112);return r?[{title:"Result",preview:r,block:n,kind:"tool_result",status:gl(n)}]:[]}return[]}))}function xh(e){return kl(e).length>0}function yh({events:e,...t}){const[n,r]=fe.useState(!1),[i,l]=fe.useState(tt),o=kl(e);if(o.length===0)return null;const s=o.slice(0,i),a=o.length-s.length;function u(){r(f=>{const c=!f;return c&&l(tt),c})}return m.jsxs("div",{className:"animate-agent-activity group/activity overflow-hidden py-0.5 text-muted-foreground","data-agent-activity-page-size":tt,children:[m.jsxs("button",{type:"button",onClick:u,"aria-expanded":n,className:"flex w-full items-start gap-1.5 rounded-sm px-1 py-1 text-left transition-colors hover:bg-muted/18",children:[m.jsx("div",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground/55 transition-colors group-hover/activity:text-muted-foreground/80",children:m.jsx(bn,{className:"h-3 w-3"})}),m.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[m.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[m.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[0.18em] text-muted-foreground/80",children:"Agent activity"}),m.jsxs("span",{className:"font-mono text-[9px] leading-4 text-muted-foreground/55",children:[o.length," ",o.length===1?"item":"items"]})]}),m.jsx("div",{className:"divide-y divide-dashed divide-border/18",children:o.slice(0,4).map((f,c)=>m.jsxs("div",{className:"grid gap-1 py-0.5 text-[9px] leading-3 sm:grid-cols-[0.875rem_4.75rem_minmax(0,1fr)]",children:[m.jsx($n,{status:f.status}),m.jsx("span",{className:"truncate font-medium text-muted-foreground/75",children:f.title}),m.jsx("span",{className:"truncate font-mono text-muted-foreground/60",children:f.preview})]},`${f.kind}-${c}`))})]}),m.jsx(dl,{expanded:n})]}),n&&m.jsxs("div",{className:"animate-agent-activity-expand divide-y divide-dashed divide-border/18 px-3 pb-1 pt-0.5",children:[s.map((f,c)=>{const h=`${f.kind}-${c}`;return f.kind==="thinking"?m.jsx("div",{className:"py-0.5",children:m.jsx(xl,{text:String(f.block.thinking??""),status:f.status})},h):f.kind==="tool_use"?m.jsx("div",{className:"py-0.5",children:m.jsx(yl,{block:f.block,status:f.status,...t})},h):m.jsx("div",{className:"py-0.5",children:m.jsx(Hn,{block:f.block,status:f.status,...t})},h)}),a>0&&m.jsxs("button",{type:"button",onClick:()=>l(f=>f+tt),className:"ml-5 inline-flex rounded-sm px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground/62 transition-colors hover:bg-muted/20 hover:text-muted-foreground",children:["Load more ",Math.min(a,tt)]})]})]})}function kh(e){return Array.isArray(e)?e.map(t=>{if(typeof t!="object"||t===null)return null;const n=t,r=typeof n.content=="string"?n.content:"";if(!r)return null;const i=typeof n.activeForm=="string"?n.activeForm:r,l=typeof n.status=="string"?n.status:"pending";return{content:r,activeForm:i,status:l==="completed"||l==="in_progress"?l:"pending"}}).filter(t=>t!==null):[]}function bh({todos:e,status:t="success"}){const n=e.filter(l=>l.status==="completed").length,r=e.length,i=e.find(l=>l.status==="in_progress");return m.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/18 bg-muted/16 shadow-none",children:[m.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/18 px-2 py-1",children:[m.jsx($n,{status:t}),m.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-border/20 bg-background/36 text-muted-foreground/72",children:m.jsx(eo,{className:"h-3 w-3"})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/78",children:"Todos"}),m.jsx("div",{className:"mt-0.5 truncate text-[9px] leading-3 text-muted-foreground/78",children:i?i.activeForm:r===0?"No items":n===r?"All complete":"Up next"})]}),m.jsxs("div",{className:"shrink-0 rounded-sm border border-border/20 bg-background/36 px-1.5 py-0.5 font-mono text-[8px] tracking-wide text-muted-foreground/72",children:[n,"/",r]})]}),m.jsx("ul",{className:"divide-y divide-border/18",children:e.map((l,o)=>m.jsxs("li",{className:"flex items-start gap-1.5 px-2 py-1",children:[m.jsx(wh,{status:l.status}),m.jsx("span",{className:l.status==="completed"?"text-[11px] leading-4 text-muted-foreground line-through decoration-muted-foreground/60":l.status==="in_progress"?"text-[11px] font-medium leading-4 text-foreground":"text-[11px] leading-4 text-foreground/85",children:l.status==="in_progress"?l.activeForm:l.content})]},`${o}-${l.content}`))})]})}function wh({status:e}){return e==="completed"?m.jsx("span",{className:"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full bg-emerald-500/15 text-emerald-500 dark:text-emerald-400",children:m.jsx(He,{className:"h-2.5 w-2.5"})}):e==="in_progress"?m.jsx("span",{className:"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center text-primary",children:m.jsx(Gl,{className:"h-3 w-3 animate-spin"})}):m.jsx("span",{className:"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center text-muted-foreground/60",children:m.jsx(ri,{className:"h-2.5 w-2.5"})})}const Vn=/^[A-Za-z]:[\\/]/,bl=/^[A-Za-z][A-Za-z\d+.-]*:/,wl=/^\/(?:api|preview|preview-open|shared|tasks)(?:\/|$)/;function Sh(e){const t=Wn(e);if(!t||t.startsWith("#")||wl.test(t)||bl.test(t)&&!t.toLowerCase().startsWith("file:")&&!Vn.test(t))return!1;const n=Yn(ke(Xn(Jn(Gn(t)))));return!n||Qn(Ot(n))?!1:Kn(n)}function Ch(e,t,n={}){const r=Wn(e);if(!r||r.startsWith("#")||wl.test(r)||bl.test(r)&&!r.toLowerCase().startsWith("file:")&&!Vn.test(r))return null;const i=vh(r,t,n);if(!i)return null;const l=Sl(i,t);return!l||l==="."?null:Kn(l)?l:null}function Sl(e,t){let n=Wn(e);if(!n)return null;n=Gn(n),n=Jn(n),n=Xn(n),n=ke(n),n=Yn(n);const r=t?Pt(ke(t)):null;if(vl(n)){if(!r)return null;const i=Pt(n);if(i===r)return".";if(!i.startsWith(`${r}/`))return null;n=i.slice(r.length+1)}return n=Ot(n),Qn(n)?null:n||"."}function Cl(e){const t=Ot(ke(e)),n=t.lastIndexOf("/");return n<=0?".":t.slice(0,n)}function hm(e,t,n,r=new Set){const i=[],l=(o,s)=>{for(const a of o){const u=a.type==="directory"&&n.has(a.path);i.push({entry:a,depth:s,expanded:u,loading:a.type==="directory"&&r.has(a.path)}),u&&l(t[a.path]??[],s+1)}};return l(e,0),i}function mm(e){const t=Cl(e);if(t===".")return[];const n=t.split("/").filter(Boolean);return n.map((r,i)=>n.slice(0,i+1).join("/"))}function dm(e){const t=Ot(ke(e));return!t||t==="."?0:Math.max(0,t.split("/").filter(Boolean).length-1)}function gm(e,t){const n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(r=>{const i=`${r.name} ${r.path}`.toLowerCase();return n.every(l=>i.includes(l))})}function Wn(e){const t=e?.trim()??"";if(!t)return"";try{return decodeURIComponent(t)}catch{return t}}function Gn(e){if(!e.toLowerCase().startsWith("file:"))return e;try{return new URL(e).pathname}catch{return e.replace(/^file:\/\//i,"")}}function Jn(e){const t=e.indexOf("#"),n=e.indexOf("?"),r=[t,n].filter(i=>i>=0).sort((i,l)=>i-l)[0];return r===void 0?e:e.slice(0,r)}function Xn(e){const t=e.match(/^(.*):\d+(?::\d+)?$/);return t?.[1]&&Kn(t[1])?t[1]:e}function ke(e){return e.replace(/\\/g,"/")}function Pt(e){return e.replace(/\/+$/,"")}function Yn(e){return e.replace(/^\/([A-Za-z]:\/)/,"$1")}function Ot(e){let t=e;for(;t.startsWith("./");)t=t.slice(2);return t}function Qn(e){return e.split("/").includes("..")}function vl(e){return e.startsWith("/")||Vn.test(e)}function Kn(e){const t=ke(e);if(!t||t==="."||Qn(t))return!1;const n=t.split("/").pop()??t;return n.startsWith(".")||/\.[A-Za-z0-9][A-Za-z0-9_-]*$/.test(n)?!0:t.split("/").some(r=>r.startsWith(".")&&r.length>1)}function vh(e,t,n){const r=Yn(ke(Xn(Jn(Gn(e))))),i=t?Pt(ke(t)):null;if(n.allowRootRelative&&r.startsWith("/")){const s=Pt(r);if(!(i?s===i||s.startsWith(`${i}/`):!1))return r.replace(/^\/+/,"")}if(vl(r))return e;const l=Sl(n.baseFilePath,t);if(!l||l===".")return e;const o=Cl(l);return o==="."?e:Ah(`${o}/${r}`)}function Ah(e){const t=[];for(const n of ke(e).split("/"))if(!(!n||n===".")){if(n===".."){if(t.length===0)return null;t.pop();continue}t.push(n)}return t.join("/")||"."}const Ct="/goal",Eh="Goal",Th="Set a goal that Codex will keep working towards";function jh(e,t){if(e!=="codex")return{isGoal:!1,prompt:t,commandPrompt:t};const n=t.trimStart();if(!n.startsWith(Ct))return{isGoal:!1,prompt:t,commandPrompt:t};const r=n.charAt(Ct.length);return r&&!/\s/.test(r)?{isGoal:!1,prompt:t,commandPrompt:t}:{isGoal:!0,prompt:n.slice(Ct.length).trimStart(),commandPrompt:n}}function xm(e,t){if(e!=="codex")return null;const n=t.trimStart();if(!n.startsWith("/"))return null;const r=n.slice(1).toLowerCase();return/\s/.test(r)||!"goal".startsWith(r)?null:{label:Eh,description:Th,value:Ct+" "}}function Ih(e){let t=!1;return e.map(n=>{if(t||n.type!=="text")return n;const r=jh("codex",n.text);return r.isGoal?(t=!0,{...n,text:r.prompt}):n}).filter(n=>n.type!=="text"||n.text.trim().length>0)}function ym(e){return e?.agent==="codex"&&e.payload.goal===!0}function Nh(e){return/^(https?:\/\/|mailto:|tel:)/i.test(e?.trim()??"")}function Ph(e){const t=typeof window>"u"?void 0:window,n=t?.__TAURI__?.core?.invoke;if(typeof n=="function")return i=>n("plugin:opener|open_url",{url:i,with:void 0});const r=t?.__TAURI__?.opener?.openUrl;return typeof r=="function"?r:null}function Qr(e,t){const n=Ph(),r=t?.trim();!n||!Nh(r)||(e.preventDefault(),Promise.resolve(n(r)).catch(()=>{window.open(r,"_blank","noopener,noreferrer")}))}function km({event:e,agent:t,subItems:n=[],questionBypassEnabled:r=!1,onQuestionBypassChange:i,onSubmitQuestionResponse:l,questionResponseDisabled:o=!1,taskRootPath:s,onOpenFilePath:a,sentAsGoal:u=!1}){const f=e.type,c=wn(e),h=ft(e);if(c)return m.jsx(lt,{agent:t,children:m.jsx(mh,{payload:c,onSubmit:l,disabled:o})});if(h)return m.jsx(lt,{agent:t,children:m.jsx(ut,{payload:h,bypassEnabled:r,onBypassChange:i,onSubmit:l,disabled:o})});if(f==="user"){if(e.isMeta===!0||e.isSidechain===!0)return null;const p=_h(e),d=p.filter(y=>y.type==="tool_result");if(d.length>0&&p.every(y=>y.type==="tool_result"))return m.jsx(lt,{agent:t,children:d.map((y,A)=>m.jsx(Hn,{block:y,questionBypassEnabled:r,onQuestionBypassChange:i,onSubmitQuestionResponse:l,questionResponseDisabled:o},A))});const k=qe(e);if(!k)return null;const w=u?Ih(k):k;return m.jsx(Oh,{content:w,sentAsGoal:u,taskRootPath:s,onOpenFilePath:a})}return f==="assistant"?m.jsx(Rh,{event:e,agent:t,subItems:n,questionBypassEnabled:r,onQuestionBypassChange:i,onSubmitQuestionResponse:l,questionResponseDisabled:o,taskRootPath:s,onOpenFilePath:a}):null}function _h(e){const n=e.message?.content;if(Array.isArray(n))return n.filter(i=>typeof i=="object"&&i!==null);const r=e.content;return Array.isArray(r)?r.filter(i=>typeof i=="object"&&i!==null):[]}function nn(e){const t=e.replace(/\r\n/g,`
|
|
79
79
|
`).split(`
|
|
80
80
|
`);for(;t.length>0&&t[0]?.trim()==="";)t.shift();return t.join(`
|
|
81
|
-
`)}function zh(e){if(typeof e=="number"&&Number.isFinite(e))return Number.isNaN(new Date(e).getTime())?null:{raw:String(e),time:e};if(typeof e=="string"&&e.trim().length>0){const t=Date.parse(e);return Number.isNaN(t)?null:{raw:e,time:t}}return null}function Lh(e){const t=new Date(e.time),n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),s=String(t.getSeconds()).padStart(2,"0");return`${n}-${r}-${i} ${l}:${o}:${s}`}function Al({text:e,tone:t="default",size:n="default",className:r="",taskRootPath:i,onOpenFilePath:l}){const o=t==="inverted",s=n==="compact"?"text-[10px] leading-4":"text-[11px] leading-[17px]",a=o?"underline decoration-current/45 underline-offset-2 hover:decoration-current":"underline decoration-current/35 underline-offset-2 hover:decoration-current",u=o?"rounded-sm bg-black/15 px-1 py-0.5 font-mono text-[10px] text-primary-foreground":"rounded-sm bg-muted/80 px-1 py-0.5 font-mono text-[10px] text-foreground",f=o?"overflow-x-auto rounded-md border border-primary-foreground/12 bg-black/15 px-3 py-2 font-mono text-[10px] leading-4 text-primary-foreground":"overflow-x-auto rounded-md border border-border/45 bg-muted/50 px-3 py-2 font-mono text-[10px] leading-4 text-foreground",c=o?"w-full border-collapse text-left text-[11px] text-primary-foreground":"w-full border-collapse text-left text-[11px] text-foreground",h=o?"border border-primary-foreground/20 px-2 py-1 align-top":"border border-border/60 px-2 py-1 align-top",p=o?"border-l-2 border-primary-foreground/30 pl-3 italic text-primary-foreground/90":"border-l-2 border-border pl-3 italic text-muted-foreground";return m.jsx("div",{className:[`max-w-none break-words ${s} [overflow-wrap:anywhere] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>*+*]:mt-2 [&_li>p]:my-0`,r].filter(Boolean).join(" "),children:m.jsx(Qc,{remarkPlugins:[hh,uf],components:{a:({node:d,href:k,...w})=>{const y=l?Ch(k,i):null,A=l&&!y&&!i&&Sh(k)?k?.trim()??null:null,v=y??A;return v?m.jsx("a",{...w,href:k,"data-task-file-link":v,"data-task-file-link-unresolved":y?void 0:"true",className:a,onClick:_=>{_.preventDefault(),l?.(v)}}):m.jsx("a",{...w,href:k,target:"_blank",rel:"noreferrer noopener",className:a,onClick:_=>Qr(_,k)})},blockquote:({node:d,...k})=>m.jsx("blockquote",{...k,className:p}),code:({node:d,className:k,children:w,...y})=>k?m.jsx("code",{...y,className:k,children:w}):m.jsx("code",{...y,className:u,children:w}),h1:({node:d,...k})=>m.jsx("h1",{...k,className:"text-[14px] font-semibold leading-5"}),h2:({node:d,...k})=>m.jsx("h2",{...k,className:"text-[13px] font-semibold leading-5"}),h3:({node:d,...k})=>m.jsx("h3",{...k,className:"text-[12px] font-semibold leading-5"}),h4:({node:d,...k})=>m.jsx("h4",{...k,className:"text-[11px] font-semibold leading-4"}),hr:({node:d,...k})=>m.jsx("hr",{...k,className:o?"border-primary-foreground/20":"border-border"}),img:({node:d,alt:k,src:w})=>w?m.jsx("a",{href:w,target:"_blank",rel:"noreferrer noopener",className:a,onClick:y=>Qr(y,w),children:k?.trim()||w}):m.jsx("span",{children:k?.trim()||"Image"}),ol:({node:d,...k})=>m.jsx("ol",{...k,className:"list-decimal space-y-0.5 pl-5"}),p:({node:d,...k})=>m.jsx("p",{...k,className:"my-0"}),pre:({node:d,...k})=>m.jsx("pre",{...k,className:f}),table:({node:d,...k})=>m.jsx("table",{...k,className:c}),td:({node:d,...k})=>m.jsx("td",{...k,className:h}),th:({node:d,...k})=>m.jsx("th",{...k,className:`${h} font-semibold`}),ul:({node:d,...k})=>m.jsx("ul",{...k,className:"list-disc space-y-0.5 pl-5"})},children:e})})}function El({text:e,className:t=""}){const[n,r]=fe.useState(!1);if(!e)return null;const i=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}};return m.jsx("button",{type:"button",onClick:i,"aria-label":n?"Copied":"Copy message",className:`flex h-
|
|
81
|
+
`)}function zh(e){if(typeof e=="number"&&Number.isFinite(e))return Number.isNaN(new Date(e).getTime())?null:{raw:String(e),time:e};if(typeof e=="string"&&e.trim().length>0){const t=Date.parse(e);return Number.isNaN(t)?null:{raw:e,time:t}}return null}function Lh(e){const t=new Date(e.time),n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),s=String(t.getSeconds()).padStart(2,"0");return`${n}-${r}-${i} ${l}:${o}:${s}`}function Al({text:e,tone:t="default",size:n="default",className:r="",taskRootPath:i,onOpenFilePath:l}){const o=t==="inverted",s=n==="compact"?"text-[10px] leading-4":"text-[11px] leading-[17px]",a=o?"underline decoration-current/45 underline-offset-2 hover:decoration-current":"underline decoration-current/35 underline-offset-2 hover:decoration-current",u=o?"rounded-sm bg-black/15 px-1 py-0.5 font-mono text-[10px] text-primary-foreground":"rounded-sm bg-muted/80 px-1 py-0.5 font-mono text-[10px] text-foreground",f=o?"overflow-x-auto rounded-md border border-primary-foreground/12 bg-black/15 px-3 py-2 font-mono text-[10px] leading-4 text-primary-foreground":"overflow-x-auto rounded-md border border-border/45 bg-muted/50 px-3 py-2 font-mono text-[10px] leading-4 text-foreground",c=o?"w-full border-collapse text-left text-[11px] text-primary-foreground":"w-full border-collapse text-left text-[11px] text-foreground",h=o?"border border-primary-foreground/20 px-2 py-1 align-top":"border border-border/60 px-2 py-1 align-top",p=o?"border-l-2 border-primary-foreground/30 pl-3 italic text-primary-foreground/90":"border-l-2 border-border pl-3 italic text-muted-foreground";return m.jsx("div",{className:[`max-w-none break-words ${s} [overflow-wrap:anywhere] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>*+*]:mt-2 [&_li>p]:my-0`,r].filter(Boolean).join(" "),children:m.jsx(Qc,{remarkPlugins:[hh,uf],components:{a:({node:d,href:k,...w})=>{const y=l?Ch(k,i):null,A=l&&!y&&!i&&Sh(k)?k?.trim()??null:null,v=y??A;return v?m.jsx("a",{...w,href:k,"data-task-file-link":v,"data-task-file-link-unresolved":y?void 0:"true",className:a,onClick:_=>{_.preventDefault(),l?.(v)}}):m.jsx("a",{...w,href:k,target:"_blank",rel:"noreferrer noopener",className:a,onClick:_=>Qr(_,k)})},blockquote:({node:d,...k})=>m.jsx("blockquote",{...k,className:p}),code:({node:d,className:k,children:w,...y})=>k?m.jsx("code",{...y,className:k,children:w}):m.jsx("code",{...y,className:u,children:w}),h1:({node:d,...k})=>m.jsx("h1",{...k,className:"text-[14px] font-semibold leading-5"}),h2:({node:d,...k})=>m.jsx("h2",{...k,className:"text-[13px] font-semibold leading-5"}),h3:({node:d,...k})=>m.jsx("h3",{...k,className:"text-[12px] font-semibold leading-5"}),h4:({node:d,...k})=>m.jsx("h4",{...k,className:"text-[11px] font-semibold leading-4"}),hr:({node:d,...k})=>m.jsx("hr",{...k,className:o?"border-primary-foreground/20":"border-border"}),img:({node:d,alt:k,src:w})=>w?m.jsx("a",{href:w,target:"_blank",rel:"noreferrer noopener",className:a,onClick:y=>Qr(y,w),children:k?.trim()||w}):m.jsx("span",{children:k?.trim()||"Image"}),ol:({node:d,...k})=>m.jsx("ol",{...k,className:"list-decimal space-y-0.5 pl-5"}),p:({node:d,...k})=>m.jsx("p",{...k,className:"my-0"}),pre:({node:d,...k})=>m.jsx("pre",{...k,className:f}),table:({node:d,...k})=>m.jsx("table",{...k,className:c}),td:({node:d,...k})=>m.jsx("td",{...k,className:h}),th:({node:d,...k})=>m.jsx("th",{...k,className:`${h} font-semibold`}),ul:({node:d,...k})=>m.jsx("ul",{...k,className:"list-disc space-y-0.5 pl-5"})},children:e})})}function El({text:e,className:t=""}){const[n,r]=fe.useState(!1);if(!e)return null;const i=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}};return m.jsx("button",{type:"button",onClick:i,"aria-label":n?"Copied":"Copy message",className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground/60 opacity-0 transition hover:bg-muted/50 hover:text-foreground group-hover/msg:opacity-100 focus-visible:opacity-100 ${t}`,children:n?m.jsx(He,{className:"h-3 w-3 text-emerald-500"}):m.jsx(ni,{className:"h-3 w-3"})})}async function Dh(e){let n=await(await fetch(e)).blob();n.type!=="image/png"&&(n=await Mh(n)),await navigator.clipboard.write([new ClipboardItem({[n.type]:n})])}async function Mh(e){const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const r=n.getContext("2d");if(!r)throw new Error("canvas 2d context unavailable");return r.drawImage(t,0,0),await new Promise((i,l)=>{n.toBlob(o=>o?i(o):l(new Error("toBlob failed")),"image/png")})}function Fh({dataUrl:e,className:t=""}){const[n,r]=fe.useState(!1),i=async l=>{l.stopPropagation();try{await Dh(e),r(!0),setTimeout(()=>r(!1),1500)}catch(o){console.error("copy image failed",o)}};return m.jsx("button",{type:"button",onClick:i,"aria-label":n?"Copied":"Copy image",className:`flex h-6 w-6 items-center justify-center rounded-sm border border-border/60 bg-background/86 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-all hover:-translate-y-px hover:text-foreground group-hover/msg:opacity-100 focus-visible:opacity-100 ${t}`,children:n?m.jsx(He,{className:"h-3 w-3 text-emerald-500"}):m.jsx(ni,{className:"h-3 w-3"})})}function Oh({content:e,sentAsGoal:t=!1,taskRootPath:n,onOpenFilePath:r}){const i=ho(e),l=e.filter(o=>o.type==="image");return m.jsx("div",{className:"animate-message-send flex w-full max-w-full min-w-0 justify-end",children:m.jsxs("div",{className:"group/msg relative flex min-w-0 max-w-[88%] items-start gap-2",children:[m.jsx(El,{text:i,className:"absolute -left-8 top-5"}),m.jsxs("div",{className:"flex min-w-0 max-w-full flex-col items-end gap-0.5",children:[m.jsxs("div",{className:"flex max-w-full items-center justify-end gap-1.5 pr-0.5",children:[m.jsx("span",{className:"shrink-0 text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/72",children:"You"}),t&&m.jsxs("span",{"data-message-goal-label":"true",title:"Sent as Codex goal",className:"inline-flex h-4 max-w-full items-center gap-1 rounded-sm border border-border/45 bg-background/85 px-1.5 text-[9px] font-medium leading-3 tracking-normal text-muted-foreground shadow-none",children:[m.jsx(oo,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":"true"}),m.jsx("span",{className:"truncate",children:"Sent as goal"})]})]}),m.jsxs("div",{className:"max-w-full space-y-1 overflow-hidden rounded-lg rounded-br-md bg-primary px-3 py-2 text-[10px] leading-4 text-primary-foreground shadow-[0_16px_52px_-38px_hsl(var(--primary)/0.9)]",children:[i&&m.jsx(Al,{text:i,tone:"inverted",size:"compact",taskRootPath:n,onOpenFilePath:r}),l.length>0&&m.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:l.map((o,s)=>{const a=ii(o);return m.jsxs("div",{className:"relative",children:[m.jsx(Fo,{image:o,alt:o.filename??`attachment ${s+1}`,thumbnailClassName:"w-full border border-primary-foreground/15",imageClassName:"max-h-72 w-full"}),m.jsx(Fh,{dataUrl:a,className:"absolute right-2 top-2"})]},`${o.filename??"image"}-${s}`)})})]})]}),m.jsx("div",{className:"mt-4 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm bg-primary/8 text-primary",children:m.jsx(ao,{className:"h-3.5 w-3.5"})})]})})}function lt({agent:e,children:t,timestamp:n}){const r=e?ai(e):"Agent",i=zh(n);return m.jsx("div",{className:"animate-message-receive flex w-full max-w-full min-w-0 justify-start",children:m.jsxs("div",{className:"flex w-full min-w-0 max-w-[92%] items-start gap-2",children:[m.jsx("div",{className:"mt-4 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm bg-muted/45 text-muted-foreground/82",children:m.jsx(oi,{agent:e??"",className:"h-3.5 w-3.5"})}),m.jsxs("div",{className:"min-w-0 max-w-full flex-1 space-y-1",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/72","data-agent-speaker-label":r,children:r}),i&&m.jsx("span",{className:"shrink-0 rounded-sm bg-muted/18 px-1 py-0.5 text-[8px] font-mono font-medium leading-3 tabular-nums text-muted-foreground/54","data-agent-message-timestamp":i.raw,children:Lh(i)})]}),t]})]})})}function Rh({event:e,agent:t,subItems:n=[],questionBypassEnabled:r,onQuestionBypassChange:i,onSubmitQuestionResponse:l,questionResponseDisabled:o,taskRootPath:s,onOpenFilePath:a}){const u=e.message;if(!u)return null;const f=ft(u);if(f)return m.jsx(lt,{agent:t,children:m.jsx(ut,{payload:f,bypassEnabled:r,onBypassChange:i,onSubmit:l,disabled:o})});const c=u.content;if(!c||!Array.isArray(c))return null;const h=new Set,p=c.filter(I=>I.type==="text"||I.type==="commentary").map(I=>({...I,text:nn(String(I.text??"")),questionPayload:pt(nn(String(I.text??"")))})).filter(I=>I.text.length>0||I.questionPayload),d=c.filter(I=>I.type==="thinking").map(I=>nn(String(I.thinking??""))).filter(Boolean).join(`
|
|
82
82
|
|
|
83
|
-
`),k=c.filter(I=>I.type==="tool_use"),w=c.filter(I=>I.type==="tool_result"),y=typeof e.timestamp=="string"||typeof e.timestamp=="number"?e.timestamp:void 0,A=p.length>0,_=[...A&&(d.length>0||k.length>0||w.length>0)?[{type:"assistant",...y!==void 0?{timestamp:y}:{},message:{content:[...d.length>0?[{type:"thinking",thinking:d}]:[],...k,...w]}}]:[],...n],D=xh(_);return p.length>0||d.length>0||k.length>0||w.length>0||D?m.jsxs(lt,{agent:t,timestamp:y,children:[p.map((I,O)=>{if(I.questionPayload){const B=Ve(I.questionPayload);return h.has(B)?null:(h.add(B),m.jsx(ut,{payload:I.questionPayload,bypassEnabled:r,onBypassChange:i,onSubmit:l,disabled:o},O))}return m.
|
|
84
|
-
`):""}function Uh(e){return ft(e)?!0:e.type==="tool_result"&&pt($h(e))!==null}function Hh(e){const t=Bh(e);return t.length===0||t.some(Uh)?!1:e.type==="assistant"?t.every(n=>n.type==="thinking"||n.type==="tool_use"||n.type==="tool_result"):e.type==="user"?t.every(n=>n.type==="tool_result"):!1}function bm(e){const t=[];let n=[];const r=()=>{if(n.length===0)return;const i=typeof n[0]?.timestamp=="string"?n[0].timestamp:void 0;t.push({event:{type:"assistant",message:{role:"assistant",content:[]},...i?{timestamp:i}:{}},subItems:n}),n=[]};for(const i of e){if(Hh(i)){n.push(i);continue}r(),t.push({event:i,subItems:[]})}return r(),t}function wm({label:e,value:t}){return m.jsxs("div",{className:"min-w-[4.75rem] flex-1 rounded-sm bg-muted/45 px-2 py-1.5 shadow-none",children:[m.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),m.jsx("div",{className:"mt-0.5 text-[11px] font-semibold leading-4 tracking-tight text-foreground",children:t})]})}function Sm({label:e}){return m.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function Cm({label:e,value:t,mono:n,action:r}){return m.jsxs("div",{className:"grid grid-cols-[3.75rem,minmax(0,1fr)] items-start gap-1.5",children:[m.jsx("span",{className:"pt-px text-[8px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:e}),m.jsxs("div",{className:"flex min-w-0 items-start gap-1",children:[m.jsx("span",{className:$e("min-w-0 flex-1 break-all text-[9px] leading-[0.95rem] text-foreground",n&&"font-mono"),children:t}),r]})]})}function vm({label:e,value:t,mono:n}){return m.jsxs("div",{className:"rounded-sm bg-muted/45 px-2 py-1.5 shadow-none",children:[m.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),m.jsx("div",{className:$e("mt-0.5 text-[9px] font-medium leading-[0.95rem] text-foreground",n&&"font-mono"),children:t})]})}export{
|
|
83
|
+
`),k=c.filter(I=>I.type==="tool_use"),w=c.filter(I=>I.type==="tool_result"),y=typeof e.timestamp=="string"||typeof e.timestamp=="number"?e.timestamp:void 0,A=p.length>0,_=[...A&&(d.length>0||k.length>0||w.length>0)?[{type:"assistant",...y!==void 0?{timestamp:y}:{},message:{content:[...d.length>0?[{type:"thinking",thinking:d}]:[],...k,...w]}}]:[],...n],D=xh(_);return p.length>0||d.length>0||k.length>0||w.length>0||D?m.jsxs(lt,{agent:t,timestamp:y,children:[p.map((I,O)=>{if(I.questionPayload){const B=Ve(I.questionPayload);return h.has(B)?null:(h.add(B),m.jsx(ut,{payload:I.questionPayload,bypassEnabled:r,onBypassChange:i,onSubmit:l,disabled:o},O))}return m.jsx("div",{className:"group/msg max-w-full overflow-hidden rounded-lg rounded-bl-md bg-card/72 px-3 py-2 text-[11px] leading-[17px] text-foreground shadow-[0_14px_48px_-42px_rgba(15,23,42,0.65)] backdrop-blur-sm dark:bg-card/68 dark:shadow-[0_14px_48px_-42px_rgba(0,0,0,0.9)]",children:m.jsxs("div",{className:"flex items-start gap-1",children:[m.jsx(Al,{text:I.text,className:"min-w-0",taskRootPath:s,onOpenFilePath:a}),m.jsx(El,{text:I.text,className:"mt-px"})]})},O)}),D&&m.jsx(yh,{events:_,questionBypassEnabled:r,onQuestionBypassChange:i,onSubmitQuestionResponse:l,questionResponseDisabled:o}),d.length>0&&!A&&m.jsx(xl,{text:d}),!A&&k.map((I,O)=>m.jsx(yl,{block:I,renderedQuestionSignatures:h,questionBypassEnabled:r,onQuestionBypassChange:i,onSubmitQuestionResponse:l,questionResponseDisabled:o},O)),!A&&w.map((I,O)=>m.jsx(Hn,{block:I,renderedQuestionSignatures:h,questionBypassEnabled:r,onQuestionBypassChange:i,onSubmitQuestionResponse:l,questionResponseDisabled:o},O))]}):null}function vt(e){return typeof e=="object"&&e!==null}function Bh(e){const t=e.message;return vt(t)&&Array.isArray(t.content)?t.content.filter(vt):Array.isArray(e.content)?e.content.filter(vt):[]}function $h(e){const t=e.content;return typeof t=="string"?t:Array.isArray(t)?t.filter(vt).map(n=>String(n.text??"")).join(`
|
|
84
|
+
`):""}function Uh(e){return ft(e)?!0:e.type==="tool_result"&&pt($h(e))!==null}function Hh(e){const t=Bh(e);return t.length===0||t.some(Uh)?!1:e.type==="assistant"?t.every(n=>n.type==="thinking"||n.type==="tool_use"||n.type==="tool_result"):e.type==="user"?t.every(n=>n.type==="tool_result"):!1}function bm(e){const t=[];let n=[];const r=()=>{if(n.length===0)return;const i=typeof n[0]?.timestamp=="string"?n[0].timestamp:void 0;t.push({event:{type:"assistant",message:{role:"assistant",content:[]},...i?{timestamp:i}:{}},subItems:n}),n=[]};for(const i of e){if(Hh(i)){n.push(i);continue}r(),t.push({event:i,subItems:[]})}return r(),t}function wm({label:e,value:t}){return m.jsxs("div",{className:"min-w-[4.75rem] flex-1 rounded-sm bg-muted/45 px-2 py-1.5 shadow-none",children:[m.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),m.jsx("div",{className:"mt-0.5 text-[11px] font-semibold leading-4 tracking-tight text-foreground",children:t})]})}function Sm({label:e}){return m.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function Cm({label:e,value:t,mono:n,action:r}){return m.jsxs("div",{className:"grid grid-cols-[3.75rem,minmax(0,1fr)] items-start gap-1.5",children:[m.jsx("span",{className:"pt-px text-[8px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:e}),m.jsxs("div",{className:"flex min-w-0 items-start gap-1",children:[m.jsx("span",{className:$e("min-w-0 flex-1 break-all text-[9px] leading-[0.95rem] text-foreground",n&&"font-mono"),children:t}),r]})]})}function vm({label:e,value:t,mono:n}){return m.jsxs("div",{className:"rounded-sm bg-muted/45 px-2 py-1.5 shadow-none",children:[m.jsx("div",{className:"text-[8px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),m.jsx("div",{className:$e("mt-0.5 text-[9px] font-medium leading-[0.95rem] text-foreground",n&&"font-mono"),children:t})]})}export{gi as $,oi as A,wt as B,km as C,wm as D,tm as E,Sl as F,Cl as G,mm as H,Fo as I,hm as J,dm as K,eo as L,vm as M,gm as N,Ch as O,Zo as P,pm as Q,fm as R,an as S,oo as T,ns as U,vn as V,cm as W,$o as X,rs as Y,An as Z,Mn as _,ai as a,It as a0,cs as a1,Qc as a2,hh as a3,Vh as b,xm as c,om as d,Jh as e,am as f,im as g,um as h,rm as i,lm as j,sm as k,ym as l,bm as m,Yh as n,Sm as o,jh as p,qe as q,Xh as r,Cm as s,Kh as t,em as u,Qh as v,Zh as w,nm as x,Wh as y,Gh as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as _,j as n,d as j,r as l,
|
|
1
|
+
import{c as _,j as n,d as j,r as l,c2 as K,bZ as Q,y as B,n as V,a1 as X,l as Y}from"./index-BBHpcOD3.js";import{A as ee,G as ne}from"./DashboardPage-Dr7Q3ARl.js";import{F as te}from"./file-CoTh89vx.js";import"./DashboardShared-DihTM-xx.js";import"./MarkdownPreviewFrame-CwXixe62.js";import"./PreviewTab-oRD3Wntx.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -20,4 +20,4 @@ import{c as _,j as n,d as j,r as l,b_ as Q,bV as X,y as V,n as B,a1 as Y,l as Z}
|
|
|
20
20
|
`).split(`
|
|
21
21
|
`);return r.length>0&&r[r.length-1]===""&&r.pop(),r}function G(e){if(!e)return[];const r=[];let t=null;for(const i of e.split(`
|
|
22
22
|
`)){const s=i.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(s){t={index:r.length,header:i,oldStart:Number(s[1]??0),newStart:Number(s[2]??0),lines:[]},r.push(t);continue}if(!t||i.startsWith("\\ No newline"))continue;const d=i.charAt(0);d===" "?t.lines.push({kind:"context",content:i.slice(1)}):d==="+"?t.lines.push({kind:"added",content:i.slice(1)}):d==="-"&&t.lines.push({kind:"removed",content:i.slice(1)})}return r}function ge(e,r){const t=Math.max(e.length,r.length),i=[];for(let s=0;s<t;s+=1){const d=s<e.length,c=s<r.length,o=e[s]??"",a=r[s]??"";i.push({oldLineNumber:d?s+1:null,newLineNumber:c?s+1:null,oldContent:o,newContent:a,kind:d&&c?o===a?"context":"changed":d?"removed":"added"})}return i}function be(e){const r=e.find(d=>d.startsWith("+++ "))?.slice(4).trim();if(r&&r!=="/dev/null")return I(r);const t=e.find(d=>d.startsWith("--- "))?.slice(4).trim();if(t&&t!=="/dev/null")return I(t);const i=e.find(d=>d.startsWith("diff --git "));if(!i)return null;const s=i.match(/^diff --git a\/(.+?) b\/(.+)$/);return s?I(s[2]||s[1]||""):null}function I(e){return e.replace(/^[ab]\//,"")}function Ne({item:e,viewMode:r}){return e.binary?n.jsx(k,{tone:"muted",children:"Binary file changed."}):typeof e.oldContent=="string"||typeof e.newContent=="string"?n.jsx(F,{oldContent:e.oldContent??"",newContent:e.newContent??"",patch:e.patch,oldTitle:e.oldExists===!1?"Missing base":"Base",newTitle:e.newExists===!1?"Deleted":"Current",oldTruncated:e.oldTruncated,newTruncated:e.newTruncated,viewMode:r}):n.jsx(Ce,{patch:e.patch??""})}function ke({loading:e,error:r,content:t,viewMode:i}){if(e)return n.jsx(k,{tone:"muted",children:"Loading file content..."});if(r)return n.jsx(k,{tone:"destructive",children:r});if(!t)return n.jsx(k,{tone:"muted",children:"Select an untracked file to preview its content."});if(t.kind==="image"){const s=t.content?`data:${t.mimeType};base64,${t.content}`:t.downloadUrl;return s?n.jsx("div",{className:"flex min-h-[18rem] items-center justify-center rounded-sm bg-background/55 p-3",children:n.jsx("img",{src:s,alt:t.path,className:"max-h-full max-w-full rounded-sm object-contain shadow-[0_24px_90px_-52px_rgba(0,0,0,0.65)]"})}):n.jsx(k,{tone:"muted",children:"Image preview is not available."})}if(t.kind==="pdf"&&t.downloadUrl)return n.jsx("div",{className:"h-full min-h-[22rem] overflow-hidden rounded-sm bg-background/55",children:n.jsx("iframe",{src:t.downloadUrl,title:t.path,className:"h-full w-full border-0"})});if(t.kind==="json"){let s=t.content;try{s=JSON.stringify(JSON.parse(t.content),null,2)}catch{}return n.jsx(F,{oldContent:"",newContent:s,addedOnly:!0,newTitle:"Untracked",newTruncated:t.truncated,viewMode:i})}return t.kind==="markdown"||t.kind==="text"||t.kind==="html"?n.jsx(F,{oldContent:"",newContent:t.content,addedOnly:!0,newTitle:"Untracked",newTruncated:t.truncated,viewMode:i}):n.jsx(k,{tone:"muted",children:"This file cannot be previewed inline."})}function F({oldContent:e,newContent:r,patch:t,oldTitle:i="Base",newTitle:s="Current",oldTruncated:d=!1,newTruncated:c=!1,addedOnly:o=!1,viewMode:a}){const m=l.useMemo(()=>o?he(r):xe({oldContent:e,newContent:r,patch:t}),[o,r,e,t]);return n.jsxs("div",{className:"overflow-hidden rounded-sm bg-background/55",children:[n.jsx("div",{className:"overflow-x-auto",children:a==="inline"?n.jsx(we,{rows:m,oldTitle:i,newTitle:s}):n.jsx(je,{rows:m,oldTitle:i,newTitle:s})}),(d||c)&&n.jsx("div",{className:"bg-muted/30 px-2.5 py-1.5 text-[10px] text-muted-foreground",children:"Content truncated. Open the Files tab to inspect the full artifact."})]})}function je({rows:e,oldTitle:r,newTitle:t}){return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid min-w-[52rem] grid-cols-[3rem_minmax(16rem,1fr)_3rem_minmax(16rem,1fr)] bg-muted/30 font-mono text-[10px] leading-4",children:[n.jsx("span",{className:"border-r border-border/50 px-2 py-1.5 text-right text-muted-foreground/60",children:"#"}),n.jsx("span",{className:"border-r border-border/60 px-2 py-1.5 font-medium text-foreground",children:r}),n.jsx("span",{className:"border-r border-border/50 px-2 py-1.5 text-right text-muted-foreground/60",children:"#"}),n.jsx("span",{className:"px-2 py-1.5 font-medium text-foreground",children:t})]}),n.jsx("div",{className:"font-mono text-[10px] leading-4",children:e.length>0?e.map((i,s)=>n.jsx(ve,{row:i},`${s}:${i.oldLineNumber??"x"}:${i.newLineNumber??"x"}`)):n.jsx("div",{className:"min-w-[52rem] px-2.5 py-2 text-[10px] text-muted-foreground",children:"No text content."})})]})}function we({rows:e,oldTitle:r,newTitle:t}){const i=l.useMemo(()=>pe(e),[e]);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid min-w-[42rem] grid-cols-[3rem_3rem_minmax(0,1fr)] bg-muted/30 font-mono text-[10px] leading-4",children:[n.jsx("span",{className:"border-r border-border/50 px-2 py-1.5 text-right text-muted-foreground/60",children:"old"}),n.jsx("span",{className:"border-r border-border/50 px-2 py-1.5 text-right text-muted-foreground/60",children:"new"}),n.jsxs("span",{className:"px-2 py-1.5 font-medium text-foreground",children:[r," / ",t]})]}),n.jsx("div",{className:"font-mono text-[10px] leading-4",children:i.length>0?i.map((s,d)=>n.jsx(ye,{row:s},`${d}:${s.oldLineNumber??"x"}:${s.newLineNumber??"x"}:${s.prefix}`)):n.jsx("div",{className:"min-w-[42rem] px-2.5 py-2 text-[10px] text-muted-foreground",children:"No text content."})})]})}function ve({row:e}){return n.jsxs("div",{"data-diff-hunk-index":e.hunkIndex,className:"grid min-w-[52rem] grid-cols-[3rem_minmax(16rem,1fr)_3rem_minmax(16rem,1fr)] border-b border-border/25 last:border-b-0",children:[n.jsx("span",{className:j("select-none border-r border-border/40 px-2 py-px text-right text-muted-foreground/55",P(e)),children:e.oldLineNumber??""}),n.jsx("span",{className:j("whitespace-pre-wrap break-all border-r border-border/60 px-2 py-px text-foreground",P(e)),children:e.oldContent||" "}),n.jsx("span",{className:j("select-none border-r border-border/40 px-2 py-px text-right text-muted-foreground/55",O(e)),children:e.newLineNumber??""}),n.jsx("span",{className:j("whitespace-pre-wrap break-all px-2 py-px text-foreground",O(e)),children:e.newContent||" "})]})}function ye({row:e}){return n.jsxs("div",{"data-diff-hunk-index":e.hunkIndex,className:j("grid min-w-[42rem] grid-cols-[3rem_3rem_minmax(0,1fr)] border-b border-border/25 last:border-b-0",Le(e)),children:[n.jsx("span",{className:"select-none border-r border-border/40 px-2 py-px text-right text-muted-foreground/55",children:e.oldLineNumber??""}),n.jsx("span",{className:"select-none border-r border-border/40 px-2 py-px text-right text-muted-foreground/55",children:e.newLineNumber??""}),n.jsxs("span",{className:"whitespace-pre-wrap break-all px-2 py-px text-foreground",children:[n.jsx("span",{className:"mr-2 inline-block w-2 select-none text-muted-foreground/60",children:e.prefix}),e.content||" "]})]})}function Ce({patch:e}){const r=e.split(`
|
|
23
|
-
`);let t=-1;return n.jsxs("div",{className:"rounded-sm bg-background/55",children:[n.jsxs("div",{className:"px-2.5 py-1.5",children:[n.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"Patch"}),n.jsxs("div",{className:"mt-0.5 text-[9px] text-muted-foreground",children:[r.length," lines"]})]}),n.jsx("div",{className:"font-mono text-[10px] leading-4",children:r.map((i,s)=>{const d=i.startsWith("@@");return d&&(t+=1),n.jsxs("div",{"data-diff-hunk-index":d?t:void 0,className:j("grid grid-cols-[36px_minmax(0,1fr)] gap-2 px-2.5 py-px",Se(i)),children:[n.jsx("span",{className:"select-none text-right text-muted-foreground/55",children:s+1}),n.jsx("span",{className:"whitespace-pre-wrap break-all text-foreground",children:i||" "})]},`${s}-${i}`)})})]})}function k({children:e,tone:r}){return n.jsx("div",{className:j("flex h-full min-h-[10rem] items-center justify-center rounded-sm text-[10px]",r==="muted"?"text-muted-foreground":"text-destructive"),children:e})}function P(e){return e.kind==="removed"||e.kind==="changed"?"bg-destructive/10":e.kind==="added"?"bg-muted/25 text-muted-foreground":""}function O(e){return e.kind==="added"||e.kind==="changed"?"bg-emerald-500/10":e.kind==="removed"?"bg-muted/25 text-muted-foreground":""}function Le(e){return e.kind==="added"?"bg-emerald-500/10":e.kind==="removed"?"bg-destructive/10":""}function Se(e){return e.startsWith("@@")?"bg-sky-500/10":e.startsWith("+")&&!e.startsWith("+++")?"bg-emerald-500/10":e.startsWith("-")&&!e.startsWith("---")?"bg-destructive/10":e.startsWith("diff ")||e.startsWith("index ")||e.startsWith("---")||e.startsWith("+++")?"bg-muted/45":""}function De({activeHunkIndex:e,hunkCount:r,onPrevious:t,onNext:i}){const s=r>0,d=s?Math.min(Math.max(e,0),r-1):0,c=!s||d<=0,o=!s||d>=r-1,a=s?`${d+1}/${r}`:"0/0",m=f=>j("flex h-6 w-6 items-center justify-center rounded-sm text-muted-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",f?"cursor-not-allowed opacity-40":"hover:bg-background/55 hover:text-foreground");return n.jsxs("div",{className:"flex shrink-0 items-center gap-1 rounded-sm bg-muted/40 p-0.5",role:"group","aria-label":"Diff hunk navigation",children:[n.jsx("button",{type:"button","aria-label":"Previous diff hunk",title:"Previous diff hunk",disabled:c,onClick:t,className:m(c),children:n.jsx(ee,{className:"h-3 w-3"})}),n.jsx("span",{className:"min-w-[2.25rem] text-center font-mono text-[10px] leading-5 text-muted-foreground",children:a}),n.jsx("button",{type:"button","aria-label":"Next diff hunk",title:"Next diff hunk",disabled:o,onClick:i,className:m(o),children:n.jsx(se,{className:"h-3 w-3"})})]})}const Me={staged:"Staged",unstaged:"Unstaged",untracked:"Untracked"};function Pe({taskId:e}){const[r,t]=l.useState(null),[i,s]=l.useState(!0),[d,c]=l.useState(null),[o,a]=l.useState(null),[m,f]=l.useState(null),[g,w]=l.useState(!1),[b,x]=l.useState(null),[N,D]=l.useState("split"),[M,h]=l.useState(0),C=l.useRef(null),S=l.useCallback(async()=>{s(!0),c(null),t(null);try{const u=await Q(e);t(u)}catch(u){c(u instanceof Error?u.message:"Failed to load diff")}finally{s(!1)}},[e]);l.useEffect(()=>{S()},[S]);const R=l.useMemo(()=>A(r?.files,r?.staged,"staged"),[r?.files,r?.staged]),H=l.useMemo(()=>A(r?.files,r?.unstaged,"unstaged"),[r?.files,r?.unstaged]),W=l.useMemo(()=>fe(r?.untrackedFiles??[]),[r?.untrackedFiles]),T=l.useMemo(()=>[{section:"staged",items:R},{section:"unstaged",items:H},{section:"untracked",items:W}],[R,H,W]),L=l.useMemo(()=>T.flatMap(u=>u.items),[T]),J=l.useMemo(()=>T.filter(u=>u.items.length>0),[T]),p=l.useMemo(()=>L.find(u=>u.id===o)??L[0]??null,[L,o]),y=l.useMemo(()=>me(p?.patch),[p?.patch]),U=l.useCallback(u=>{const v=()=>{C.current?.querySelector(`[data-diff-hunk-index="${u}"]`)?.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})};if(typeof window>"u"){v();return}window.requestAnimationFrame(v)},[]);l.useEffect(()=>{(!o||!L.some(u=>u.id===o))&&a(L[0]?.id??null)},[L,o]),l.useEffect(()=>{h(0)},[p?.id]),l.useEffect(()=>{if(y.length===0){h(0);return}h(u=>Math.min(u,y.length-1))},[y.length]),l.useEffect(()=>{y.length!==0&&U(M)},[M,N,U,y.length,p?.id]);const z=l.useCallback(()=>{h(u=>Math.max(0,u-1))},[]),K=l.useCallback(()=>{h(u=>Math.min(y.length-1,u+1))},[y.length]);return l.useEffect(()=>{if(f(null),x(null),w(!1),!p||p.section!=="untracked")return;if(p.path.endsWith("/")){x("This untracked path is a directory. Open the Files tab to inspect its contents.");return}let u=!1;return w(!0),X(e,p.path).then(v=>{u||f(v)}).catch(v=>{u||x(v instanceof Error?v.message:"Failed to load file content")}).finally(()=>{u||w(!1)}),()=>{u=!0}},[p,e]),i?n.jsx(k,{tone:"muted",children:"Loading diff..."}):d?n.jsx(k,{tone:"destructive",children:d}):r?.available?L.length>0?n.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[16rem_minmax(0,1fr)] lg:pl-5",children:[n.jsxs("aside",{className:"flex min-h-0 flex-col bg-card/25 lg:border-r lg:border-border/50",children:[n.jsx("div",{className:"shrink-0 bg-card/20 px-2.5 py-1.5",children:n.jsx("div",{className:"flex items-start justify-between gap-1.5",children:n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-semibold text-foreground",children:[n.jsx(ne,{className:"h-3 w-3 text-muted-foreground"}),n.jsx("span",{className:"truncate",children:r.branch??"detached HEAD"})]}),r.repoRoot&&n.jsx("div",{className:"mt-1 truncate font-mono text-[10px] leading-4 text-muted-foreground",children:r.repoRoot})]})})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1",children:n.jsx("div",{className:"space-y-1",children:J.map(({section:u,items:v})=>n.jsx(Te,{section:u,items:v,selectedId:p?.id??null,onSelect:a},u))})})]}),n.jsx("section",{className:"min-h-0 flex flex-col bg-card/15",children:p?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 px-2.5 py-1.5",children:n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsx("div",{className:"min-w-0 break-all font-mono text-[9px] text-muted-foreground",children:p.path}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n.jsx(De,{activeHunkIndex:M,hunkCount:y.length,onPrevious:z,onNext:K}),n.jsx($e,{mode:N,onModeChange:D})]})]})}),n.jsx("div",{ref:C,className:"min-h-0 flex-1 overflow-auto px-1.5 pb-1.5 pt-1",children:p.section==="untracked"?n.jsx(ke,{loading:g,error:b,content:m,viewMode:N}):n.jsx(Ne,{item:p,viewMode:N})})]}):n.jsx(k,{tone:"muted",children:"Select a file to inspect."})})]}):n.jsx(k,{tone:"muted",children:"Working tree is clean."}):n.jsx(k,{tone:"muted",children:"Task working directory is not inside a Git repository."})}function Te({section:e,items:r,selectedId:t,onSelect:i}){const s=l.useMemo(()=>ce(r),[r]),d=l.useMemo(()=>r.find(m=>m.id===t)??null,[r,t]),c=l.useMemo(()=>new Set(d?ue(d.path):[]),[d]),[o,a]=l.useState(!0);return r.length===0?null:n.jsxs("section",{className:"rounded-sm bg-background/35",children:[n.jsxs("button",{type:"button",onClick:()=>a(m=>!m),"aria-expanded":o,className:j("flex w-full items-center justify-between gap-1.5 px-2 py-1 text-left transition-colors hover:bg-background/55"),children:[n.jsxs("div",{className:"flex items-center gap-1",children:[o?n.jsx(V,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):n.jsx(B,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"text-[10px] font-medium text-foreground",children:Me[e]})]}),n.jsx(Y,{variant:"outline",className:"rounded-sm border-transparent bg-muted/45 px-1.5 py-0 text-[9px]",children:r.length})]}),o&&n.jsx("div",{className:"p-1",children:s.length>0?n.jsx("div",{className:"space-y-0.5",children:s.map(m=>n.jsx(q,{node:m,depth:0,selectedId:t,expandedAncestorPaths:c,onSelect:i},`${e}:${m.path}`))}):null})]})}function $e({mode:e,onModeChange:r}){const t=i=>j("flex items-center gap-1 rounded-sm px-2 py-0.5 text-[10px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",i?"bg-primary/10 font-medium text-primary":"text-muted-foreground hover:bg-background/45 hover:text-foreground");return n.jsxs("div",{className:"flex shrink-0 items-center gap-1 rounded-sm bg-muted/40 p-0.5",role:"group","aria-label":"Diff view mode",children:[n.jsxs("button",{type:"button","aria-pressed":e==="split",title:"Split diff",onClick:()=>r("split"),className:t(e==="split"),children:[n.jsx(oe,{className:"h-3 w-3"}),n.jsx("span",{children:"Split"})]}),n.jsxs("button",{type:"button","aria-pressed":e==="inline",title:"Inline diff",onClick:()=>r("inline"),className:t(e==="inline"),children:[n.jsx(ae,{className:"h-3 w-3"}),n.jsx("span",{children:"Inline"})]})]})}function q({node:e,depth:r,selectedId:t,expandedAncestorPaths:i,onSelect:s}){return e.type==="folder"?n.jsx(Ie,{node:e,depth:r,selectedId:t,expandedAncestorPaths:i,onSelect:s}):n.jsxs("button",{type:"button",onClick:()=>{e.item&&s(e.item.id)},className:j("flex w-full cursor-pointer items-center gap-1 rounded-sm px-1 py-0.5 text-left transition-colors",e.item?.id===t?"bg-primary/10 text-foreground":"text-foreground/90 hover:bg-background/55"),style:{paddingLeft:`${r*10+5}px`},children:[n.jsx(te,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"truncate text-[10px] leading-4",children:e.name})]})}function Ie({node:e,depth:r,selectedId:t,expandedAncestorPaths:i,onSelect:s}){const[d,c]=l.useState(!0);return l.useEffect(()=>{i.has(e.path)&&c(!0)},[i,e.path]),n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>c(o=>!o),"aria-expanded":d,className:"flex w-full cursor-pointer select-none items-center gap-1 rounded-sm px-1 py-0.5 text-left text-[10px] leading-4 text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",style:{paddingLeft:`${r*10+5}px`},children:[d?n.jsx(V,{className:"h-3 w-3 shrink-0"}):n.jsx(B,{className:"h-3 w-3 shrink-0"}),n.jsx(Z,{className:"h-3 w-3 shrink-0"}),n.jsx("span",{className:"truncate",children:e.name})]}),d&&n.jsx("div",{className:"space-y-0.5",children:(e.children??[]).map(o=>n.jsx(q,{node:o,depth:r+1,selectedId:t,expandedAncestorPaths:i,onSelect:s},o.path))})]})}export{Pe as DiffTab};
|
|
23
|
+
`);let t=-1;return n.jsxs("div",{className:"rounded-sm bg-background/55",children:[n.jsxs("div",{className:"px-2.5 py-1.5",children:[n.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"Patch"}),n.jsxs("div",{className:"mt-0.5 text-[9px] text-muted-foreground",children:[r.length," lines"]})]}),n.jsx("div",{className:"font-mono text-[10px] leading-4",children:r.map((i,s)=>{const d=i.startsWith("@@");return d&&(t+=1),n.jsxs("div",{"data-diff-hunk-index":d?t:void 0,className:j("grid grid-cols-[36px_minmax(0,1fr)] gap-2 px-2.5 py-px",Se(i)),children:[n.jsx("span",{className:"select-none text-right text-muted-foreground/55",children:s+1}),n.jsx("span",{className:"whitespace-pre-wrap break-all text-foreground",children:i||" "})]},`${s}-${i}`)})})]})}function k({children:e,tone:r}){return n.jsx("div",{className:j("flex h-full min-h-[10rem] items-center justify-center rounded-sm text-[10px]",r==="muted"?"text-muted-foreground":"text-destructive"),children:e})}function P(e){return e.kind==="removed"||e.kind==="changed"?"bg-destructive/10":e.kind==="added"?"bg-muted/25 text-muted-foreground":""}function O(e){return e.kind==="added"||e.kind==="changed"?"bg-emerald-500/10":e.kind==="removed"?"bg-muted/25 text-muted-foreground":""}function Le(e){return e.kind==="added"?"bg-emerald-500/10":e.kind==="removed"?"bg-destructive/10":""}function Se(e){return e.startsWith("@@")?"bg-sky-500/10":e.startsWith("+")&&!e.startsWith("+++")?"bg-emerald-500/10":e.startsWith("-")&&!e.startsWith("---")?"bg-destructive/10":e.startsWith("diff ")||e.startsWith("index ")||e.startsWith("---")||e.startsWith("+++")?"bg-muted/45":""}function De({activeHunkIndex:e,hunkCount:r,onPrevious:t,onNext:i}){const s=r>0,d=s?Math.min(Math.max(e,0),r-1):0,c=!s||d<=0,o=!s||d>=r-1,a=s?`${d+1}/${r}`:"0/0",m=f=>j("flex h-6 w-6 items-center justify-center rounded-sm text-muted-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",f?"cursor-not-allowed opacity-40":"hover:bg-background/55 hover:text-foreground");return n.jsxs("div",{className:"flex shrink-0 items-center gap-1 rounded-sm bg-muted/40 p-0.5",role:"group","aria-label":"Diff hunk navigation",children:[n.jsx("button",{type:"button","aria-label":"Previous diff hunk",title:"Previous diff hunk",disabled:c,onClick:t,className:m(c),children:n.jsx(ee,{className:"h-3 w-3"})}),n.jsx("span",{className:"min-w-[2.25rem] text-center font-mono text-[10px] leading-5 text-muted-foreground",children:a}),n.jsx("button",{type:"button","aria-label":"Next diff hunk",title:"Next diff hunk",disabled:o,onClick:i,className:m(o),children:n.jsx(se,{className:"h-3 w-3"})})]})}const Me={staged:"Staged",unstaged:"Unstaged",untracked:"Untracked"};function Pe({taskId:e}){const[r,t]=l.useState(null),[i,s]=l.useState(!0),[d,c]=l.useState(null),[o,a]=l.useState(null),[m,f]=l.useState(null),[g,w]=l.useState(!1),[b,x]=l.useState(null),[N,D]=l.useState("split"),[M,h]=l.useState(0),C=l.useRef(null),S=l.useCallback(async()=>{s(!0),c(null),t(null);try{const u=await K(e);t(u)}catch(u){c(u instanceof Error?u.message:"Failed to load diff")}finally{s(!1)}},[e]);l.useEffect(()=>{S()},[S]);const R=l.useMemo(()=>A(r?.files,r?.staged,"staged"),[r?.files,r?.staged]),H=l.useMemo(()=>A(r?.files,r?.unstaged,"unstaged"),[r?.files,r?.unstaged]),W=l.useMemo(()=>fe(r?.untrackedFiles??[]),[r?.untrackedFiles]),T=l.useMemo(()=>[{section:"staged",items:R},{section:"unstaged",items:H},{section:"untracked",items:W}],[R,H,W]),L=l.useMemo(()=>T.flatMap(u=>u.items),[T]),J=l.useMemo(()=>T.filter(u=>u.items.length>0),[T]),p=l.useMemo(()=>L.find(u=>u.id===o)??L[0]??null,[L,o]),y=l.useMemo(()=>me(p?.patch),[p?.patch]),U=l.useCallback(u=>{const v=()=>{C.current?.querySelector(`[data-diff-hunk-index="${u}"]`)?.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})};if(typeof window>"u"){v();return}window.requestAnimationFrame(v)},[]);l.useEffect(()=>{(!o||!L.some(u=>u.id===o))&&a(L[0]?.id??null)},[L,o]),l.useEffect(()=>{h(0)},[p?.id]),l.useEffect(()=>{if(y.length===0){h(0);return}h(u=>Math.min(u,y.length-1))},[y.length]),l.useEffect(()=>{y.length!==0&&U(M)},[M,N,U,y.length,p?.id]);const z=l.useCallback(()=>{h(u=>Math.max(0,u-1))},[]),Z=l.useCallback(()=>{h(u=>Math.min(y.length-1,u+1))},[y.length]);return l.useEffect(()=>{if(f(null),x(null),w(!1),!p||p.section!=="untracked")return;if(p.path.endsWith("/")){x("This untracked path is a directory. Open the Files tab to inspect its contents.");return}let u=!1;return w(!0),Q(e,p.path).then(v=>{u||f(v)}).catch(v=>{u||x(v instanceof Error?v.message:"Failed to load file content")}).finally(()=>{u||w(!1)}),()=>{u=!0}},[p,e]),i?n.jsx(k,{tone:"muted",children:"Loading diff..."}):d?n.jsx(k,{tone:"destructive",children:d}):r?.available?L.length>0?n.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[16rem_minmax(0,1fr)] lg:pl-5",children:[n.jsxs("aside",{className:"flex min-h-0 flex-col bg-card/25 lg:border-r lg:border-border/50",children:[n.jsx("div",{className:"shrink-0 bg-card/20 px-2.5 py-1.5",children:n.jsx("div",{className:"flex items-start justify-between gap-1.5",children:n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-semibold text-foreground",children:[n.jsx(ne,{className:"h-3 w-3 text-muted-foreground"}),n.jsx("span",{className:"truncate",children:r.branch??"detached HEAD"})]}),r.repoRoot&&n.jsx("div",{className:"mt-1 truncate font-mono text-[10px] leading-4 text-muted-foreground",children:r.repoRoot})]})})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1",children:n.jsx("div",{className:"space-y-1",children:J.map(({section:u,items:v})=>n.jsx(Te,{section:u,items:v,selectedId:p?.id??null,onSelect:a},u))})})]}),n.jsx("section",{className:"min-h-0 flex flex-col bg-card/15",children:p?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 px-2.5 py-1.5",children:n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsx("div",{className:"min-w-0 break-all font-mono text-[9px] text-muted-foreground",children:p.path}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n.jsx(De,{activeHunkIndex:M,hunkCount:y.length,onPrevious:z,onNext:Z}),n.jsx($e,{mode:N,onModeChange:D})]})]})}),n.jsx("div",{ref:C,className:"min-h-0 flex-1 overflow-auto px-1.5 pb-1.5 pt-1",children:p.section==="untracked"?n.jsx(ke,{loading:g,error:b,content:m,viewMode:N}):n.jsx(Ne,{item:p,viewMode:N})})]}):n.jsx(k,{tone:"muted",children:"Select a file to inspect."})})]}):n.jsx(k,{tone:"muted",children:"Working tree is clean."}):n.jsx(k,{tone:"muted",children:"Task working directory is not inside a Git repository."})}function Te({section:e,items:r,selectedId:t,onSelect:i}){const s=l.useMemo(()=>ce(r),[r]),d=l.useMemo(()=>r.find(m=>m.id===t)??null,[r,t]),c=l.useMemo(()=>new Set(d?ue(d.path):[]),[d]),[o,a]=l.useState(!0);return r.length===0?null:n.jsxs("section",{className:"rounded-sm bg-background/35",children:[n.jsxs("button",{type:"button",onClick:()=>a(m=>!m),"aria-expanded":o,className:j("flex w-full items-center justify-between gap-1.5 px-2 py-1 text-left transition-colors hover:bg-background/55"),children:[n.jsxs("div",{className:"flex items-center gap-1",children:[o?n.jsx(B,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):n.jsx(V,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"text-[10px] font-medium text-foreground",children:Me[e]})]}),n.jsx(X,{variant:"outline",className:"rounded-sm border-transparent bg-muted/45 px-1.5 py-0 text-[9px]",children:r.length})]}),o&&n.jsx("div",{className:"p-1",children:s.length>0?n.jsx("div",{className:"space-y-0.5",children:s.map(m=>n.jsx(q,{node:m,depth:0,selectedId:t,expandedAncestorPaths:c,onSelect:i},`${e}:${m.path}`))}):null})]})}function $e({mode:e,onModeChange:r}){const t=i=>j("flex items-center gap-1 rounded-sm px-2 py-0.5 text-[10px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",i?"bg-primary/10 font-medium text-primary":"text-muted-foreground hover:bg-background/45 hover:text-foreground");return n.jsxs("div",{className:"flex shrink-0 items-center gap-1 rounded-sm bg-muted/40 p-0.5",role:"group","aria-label":"Diff view mode",children:[n.jsxs("button",{type:"button","aria-pressed":e==="split",title:"Split diff",onClick:()=>r("split"),className:t(e==="split"),children:[n.jsx(oe,{className:"h-3 w-3"}),n.jsx("span",{children:"Split"})]}),n.jsxs("button",{type:"button","aria-pressed":e==="inline",title:"Inline diff",onClick:()=>r("inline"),className:t(e==="inline"),children:[n.jsx(ae,{className:"h-3 w-3"}),n.jsx("span",{children:"Inline"})]})]})}function q({node:e,depth:r,selectedId:t,expandedAncestorPaths:i,onSelect:s}){return e.type==="folder"?n.jsx(Ie,{node:e,depth:r,selectedId:t,expandedAncestorPaths:i,onSelect:s}):n.jsxs("button",{type:"button",onClick:()=>{e.item&&s(e.item.id)},className:j("flex w-full cursor-pointer items-center gap-1 rounded-sm px-1 py-0.5 text-left transition-colors",e.item?.id===t?"bg-primary/10 text-foreground":"text-foreground/90 hover:bg-background/55"),style:{paddingLeft:`${r*10+5}px`},children:[n.jsx(te,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"truncate text-[10px] leading-4",children:e.name})]})}function Ie({node:e,depth:r,selectedId:t,expandedAncestorPaths:i,onSelect:s}){const[d,c]=l.useState(!0);return l.useEffect(()=>{i.has(e.path)&&c(!0)},[i,e.path]),n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>c(o=>!o),"aria-expanded":d,className:"flex w-full cursor-pointer select-none items-center gap-1 rounded-sm px-1 py-0.5 text-left text-[10px] leading-4 text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",style:{paddingLeft:`${r*10+5}px`},children:[d?n.jsx(B,{className:"h-3 w-3 shrink-0"}):n.jsx(V,{className:"h-3 w-3 shrink-0"}),n.jsx(Y,{className:"h-3 w-3 shrink-0"}),n.jsx("span",{className:"truncate",children:e.name})]}),d&&n.jsx("div",{className:"space-y-0.5",children:(e.children??[]).map(o=>n.jsx(q,{node:o,depth:r+1,selectedId:t,expandedAncestorPaths:i,onSelect:s},o.path))})]})}export{Pe as DiffTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as fe,r as i,
|
|
1
|
+
import{c as fe,r as i,bZ as je,b_ as ke,b$ as Ne,j as t,l as oe,B as P,x as le,X as Se,n as Ce,d as x,t as Fe}from"./index-BBHpcOD3.js";import{E as Ee,M as Pe,L as De}from"./MarkdownPreviewFrame-CwXixe62.js";import{F as L,G as Te,H as _e,J as Oe,K as ze,N as Re,O as $e}from"./DashboardShared-DihTM-xx.js";import{F as Ae}from"./file-CoTh89vx.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,4 +8,4 @@ import{c as fe,r as i,bV as je,bW as ke,bX as Ne,j as t,l as oe,B as P,x as le,X
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Le=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Me=fe("download",Le),Ue="save_dashboard_download";function me(e=xe()){const n=e?.__TAURI__?.core?.invoke;return typeof n=="function"?n:null}function He(e){const d=(e.trim().replace(/\\/g,"/").split("/").filter(Boolean).pop()??"").replace(/[<>:"/\\|?*\x00-\x1f]/g,"_").replace(/^[ .]+|[ .]+$/g,"");return d.length>0?d:"download"}async function Ke({href:e,filePath:n,currentWindow:o=xe(),fetchImpl:d=fetch}){const c=me(o);if(!c)return!1;const l=await d(e,{cache:"no-store"});if(!l.ok)throw new Error(`Failed to download file (${l.status})`);const M=await l.blob(),k=await Xe(M),N=await c(Ue,{fileName:He(n),contentBase64:k});return!Je(N)||N.saved!==!1}async function Xe(e){const n=new Uint8Array(await e.arrayBuffer()),o=[],d=32768;for(let c=0;c<n.length;c+=d){const l=n.subarray(c,c+d);o.push(String.fromCharCode(...l))}return btoa(o.join(""))}function xe(){return typeof window>"u"?null:window}function Je(e){return!!(e&&typeof e=="object"&&"saved"in e)}const Qe={getOutput:Ne,getOutputTree:ke,getOutputContent:je},ce=120,Ve=1200;function at({taskId:e,api:n=Qe,requestedFilePath:o=null,requestedFileRequestId:d=0,onPreviewFile:c}){const[l,M]=i.useState(null),[k,N]=i.useState([]),[S,Z]=i.useState({}),[C,D]=i.useState(new Set),[U,H]=i.useState(new Set),[g,T]=i.useState("."),[h,E]=i.useState(null),[ge,v]=i.useState(!1),[y,b]=i.useState(""),[q,_]=i.useState([]),[ee,O]=i.useState(!1),[te,z]=i.useState(null),[K,R]=i.useState(!0),[re,f]=i.useState(null),ae=i.useRef(null),X=i.useRef(null),m=l?.summary?.rootPath??l?.effectiveProjectPath??null,J=y.trim(),w=J.length>0,p=ge||y.length>0,se=i.useCallback(async()=>{f(null),R(!0),T("."),N([]),Z({}),D(new Set),H(new Set),E(null),v(!1),b(""),_([]),z(null),X.current=null;try{const a=await n.getOutput(e);if(M(a),!a.available){R(!1);return}const r=await n.getOutputTree(e,".");N(r.entries),R(!1)}catch(a){f(a instanceof Error?a.message:"Failed to load output"),R(!1)}},[n,e]);i.useEffect(()=>{se()},[se]);const $=i.useCallback(async a=>{const r=L(a,m);if(!r)return f("Invalid directory path"),[];if(S[r])return S[r];f(null),H(s=>new Set(s).add(r));try{const s=await n.getOutputTree(e,r);return Z(u=>({...u,[r]:s.entries})),s.entries}catch(s){return f(s instanceof Error?s.message:"Failed to load directory"),[]}finally{H(s=>{const u=new Set(s);return u.delete(r),u})}},[n,S,m,e]),A=i.useCallback(async a=>{const r=a.filter(s=>s!==".");if(r.length!==0){D(s=>{const u=new Set(s);for(const F of r)u.add(F);return u});for(const s of r)await $(s)}},[$]),Q=i.useCallback(async a=>{const r=L(a,m);if(!r){f("Invalid directory path");return}v(!1),b(""),T(r),E(null),r!=="."&&await A(Ye(r))},[A,m]),ve=i.useCallback(async a=>{const r=L(a,m);if(!r){f("Invalid directory path");return}if(T(r),E(null),C.has(r)){D(s=>{const u=new Set(s);return u.delete(r),u});return}D(s=>new Set(s).add(r)),await $(r)},[C,$,m]),B=i.useCallback(async a=>{const r=L(a,m);if(!r){f("Invalid file path");return}f(null);try{const s=Te(r);v(!1),b(""),await A(_e(r));const u=await n.getOutputContent(e,r);T(s),E(u)}catch(s){f(s instanceof Error?s.message:"Failed to load file")}},[n,A,m,e]),be=i.useCallback(()=>{if(g===".")return;const a=g.split("/");a.pop();const r=a.length===0?".":a.join("/");Q(r)},[g,Q]);i.useEffect(()=>{if(!o||!l?.available||K)return;const a=`${d}:${o}`;X.current!==a&&(X.current=a,b(""),B(o))},[K,B,l?.available,o,d]),i.useEffect(()=>{p&&ae.current?.focus()},[p]),i.useEffect(()=>{if(!w||!l?.available){O(!1),_([]),z(null);return}let a=!1;async function r(){O(!0),z(null);const s=["."],u=new Set,F=[];let ie=0;try{for(;s.length>0&&ie<Ve&&F.length<ce;){const j=s.shift()??".";if(u.has(j))continue;u.add(j);const W=await n.getOutputTree(e,j);if(a)return;ie+=W.entries.length,F.push(...Re(W.entries,J));for(const G of W.entries)G.type==="directory"&&!u.has(G.path)&&s.push(G.path)}a||(_(F.slice(0,ce)),O(!1))}catch(j){a||(_([]),z(j instanceof Error?j.message:"Failed to search files"),O(!1))}}return r(),()=>{a=!0}},[n,J,l?.available,w,e]);const we=i.useMemo(()=>Oe(k,S,C,U),[S,k,C,U]),V=w?q.map(a=>({entry:a,depth:ze(a.path),expanded:a.type==="directory"&&C.has(a.path),loading:a.type==="directory"&&U.has(a.path)})):we;if(K)return t.jsx(I,{tone:"muted",children:"Loading files..."});if(re)return t.jsx(I,{tone:"destructive",children:re});if(!l?.available)return t.jsx(I,{tone:"muted",children:"Task output is not available yet. The task may not have started."});const ne=(l.summary?.htmlEntries.length??0)+(l.summary?.markdownEntries?.length??0),ye=w?`${q.length}${ee?"+":""} matches`:`${l.summary?.fileCount??k.length} files`;return t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[16rem_minmax(0,1fr)] lg:pl-5",children:[t.jsxs("aside",{className:x("flex min-h-0 flex-col bg-card/25 lg:border-r lg:border-border/50",h&&"hidden lg:flex"),children:[t.jsxs("div",{className:"shrink-0 bg-card/20 px-2 py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-primary",children:t.jsx(oe,{className:"h-3.5 w-3.5"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-[12px] font-semibold leading-4 text-foreground",children:l.summary?.rootName??"Artifacts"}),t.jsxs("div",{className:"text-[10px] leading-4 text-muted-foreground",children:[ye,ne>0&&` · ${ne} previews`]})]}),t.jsx(P,{type:"button",variant:p?"secondary":"ghost",size:"icon","aria-expanded":p,"aria-label":p&&y.length===0?"Hide file search":"Search files",title:p&&y.length===0?"Hide file search":"Search files",className:"h-6 w-6 shrink-0 rounded-sm",onClick:()=>{p&&y.length===0?v(!1):v(!0)},children:t.jsx(le,{className:"h-3.5 w-3.5"})})]}),t.jsxs("div",{className:"mt-1 flex min-h-5 items-center gap-1 rounded-sm bg-muted/35 px-1.5 py-0",children:[g!=="."&&t.jsx(P,{variant:"ghost",size:"icon",className:"h-5 w-5 rounded-sm",onClick:be,children:t.jsx(de,{className:"h-3 w-3"})}),t.jsx("span",{className:"truncate font-mono text-[10px] leading-4 text-muted-foreground",children:g==="."?l.summary?.rootPath??l.summary?.rootName??"/":g})]}),p&&t.jsxs("div",{className:"mt-1 flex items-center gap-1 rounded-sm bg-muted/35 px-1.5 py-0",children:[t.jsx(le,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),t.jsx("input",{ref:ae,value:y,onChange:a=>b(a.target.value),onKeyDown:a=>{a.key==="Escape"&&(b(""),v(!1))},placeholder:"Search files and folders",className:"h-5 min-w-0 flex-1 bg-transparent text-[10px] leading-4 text-foreground outline-none placeholder:text-muted-foreground/70"}),t.jsx("button",{type:"button",onClick:()=>{b(""),v(!1)},className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted/70 hover:text-foreground","aria-label":"Close file search",children:t.jsx(Se,{className:"h-3 w-3"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1",children:ee&&V.length===0?t.jsx("div",{className:"flex h-full items-center justify-center rounded-sm border border-dashed border-border/70 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:"Searching files..."}):te?t.jsx("div",{className:"flex h-full items-center justify-center rounded-sm border border-dashed border-destructive/35 bg-destructive/10 px-3 text-center text-[11px] text-destructive",children:te}):V.length>0?t.jsx("div",{className:"space-y-0",children:V.map(a=>{const r=a.entry,s=h?.path===r.path||!h&&r.type==="directory"&&g===r.path;return t.jsxs("button",{type:"button","aria-current":s?"page":void 0,style:{"--tree-depth":a.depth,paddingLeft:`${4+a.depth*11}px`},onClick:()=>{r.type==="directory"?w?Q(r.path):ve(r.path):B(r.path)},className:x("animate-task-row-reveal group relative flex min-h-5 w-full items-center gap-1 rounded-sm py-0 text-left transition-all duration-150",s?'bg-primary/10 text-foreground before:absolute before:left-0 before:top-1/2 before:h-1/2 before:w-[2px] before:-translate-y-1/2 before:rounded-full before:bg-primary before:content-[""]':"text-foreground hover:bg-muted/40"),children:[r.type==="directory"?t.jsx(Ce,{className:x("h-3 w-3 shrink-0 text-muted-foreground transition-transform",s&&"text-primary",a.expanded&&"rotate-90")}):t.jsx("span",{className:"h-3 w-3 shrink-0"}),r.type==="directory"?t.jsx(oe,{className:x("h-3 w-3 shrink-0 text-muted-foreground group-hover:text-foreground",s&&"text-primary")}):t.jsx(Ae,{className:x("h-3 w-3 shrink-0 text-muted-foreground group-hover:text-foreground",s&&"text-primary")}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-medium leading-4",children:w?r.path:r.name}),t.jsx("span",{className:x("max-w-[5.75rem] shrink-0 truncate text-right text-[9px] leading-4",s?"text-primary/75":"text-muted-foreground"),children:a.loading?"loading":Ie(r)})]},r.path)})}):t.jsx("div",{className:"flex h-full items-center justify-center rounded-sm border border-dashed border-border/70 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:w?"No matching files or folders":"Empty directory"})})]}),t.jsx("section",{className:x("min-h-0 flex flex-col bg-card/15",!h&&"hidden lg:flex"),children:h?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"shrink-0 px-3 py-1.5",children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx(P,{variant:"ghost",size:"icon","aria-label":"Back to file list",title:"Back to file list",className:"h-6 w-6 shrink-0 rounded-sm text-muted-foreground hover:bg-muted/55 hover:text-foreground",onClick:()=>E(null),children:t.jsx(de,{className:"h-3 w-3"})}),t.jsx("div",{className:"min-w-0 truncate font-mono text-[10px] leading-5 text-muted-foreground",children:h.path})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[c&&Ge(h)&&t.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Preview file",title:"Preview file",className:"h-6 w-6 shrink-0 rounded-sm text-primary hover:bg-primary/10 hover:text-primary",onClick:()=>c(h.path),children:t.jsx(Fe,{className:"h-3.5 w-3.5"})}),h.downloadUrl&&t.jsx(Y,{href:h.downloadUrl,filePath:h.path,iconOnly:!0})]})]})}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-2.5 pb-2.5 pt-1",children:t.jsx(We,{content:h,rootPath:m,onOpenFile:B})})]}):t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:t.jsxs("div",{className:"max-w-md rounded-lg border border-border/60 bg-background/55 px-4 py-4 text-center",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:"Select a file to inspect"}),t.jsx("p",{className:"mt-1 text-[11px] leading-5 text-muted-foreground",children:"Preview source files, generated assets, or exported documents from this task."})]})})})]})}function We({content:e,rootPath:n,onOpenFile:o}){const d=e.downloadUrl;if(e.truncated&&!e.content)return t.jsx(pe,{title:"File is too large to preview inline",description:e.path,action:d?t.jsx(Y,{href:d,filePath:e.path}):void 0});if(e.kind==="image"){const c=e.content?`data:${e.mimeType};base64,${e.content}`:d;return c?t.jsx("div",{className:"flex h-full min-h-[16rem] items-center justify-center rounded-sm bg-background/55 p-3",children:t.jsx("img",{src:c,alt:e.path,className:"max-h-full max-w-full rounded-sm object-contain shadow-[0_24px_90px_-52px_rgba(0,0,0,0.65)]"})}):t.jsx(he,{content:e})}if(e.kind==="pdf"&&d)return t.jsx("div",{className:"h-full min-h-[20rem] overflow-hidden rounded-sm bg-background/55",children:t.jsx("iframe",{src:d,title:e.path,className:"h-full w-full border-0"})});if(e.kind==="json"){let c=e.content;try{c=JSON.stringify(JSON.parse(e.content),null,2)}catch{}return t.jsx(ue,{content:c,truncated:e.truncated})}return e.kind==="markdown"?t.jsx(Pe,{content:e.content,truncated:e.truncated,resolveFileLink:c=>$e(c,n,{allowRootRelative:!0,baseFilePath:e.path}),onOpenFileLink:o}):e.kind==="text"||e.kind==="html"?t.jsx(ue,{content:e.content,truncated:e.truncated}):t.jsx(he,{content:e})}function ue({content:e,truncated:n}){return t.jsxs("div",{className:"rounded-sm bg-background/55",children:[t.jsx(De,{content:e}),n&&t.jsx("div",{className:"bg-muted/30 px-3 py-1.5 text-[10px] text-muted-foreground",children:"Content truncated. Download the file to inspect the full artifact."})]})}function he({content:e}){return t.jsx(pe,{title:`${e.kind} file`,description:e.path,action:e.downloadUrl?t.jsx(Y,{href:e.downloadUrl,filePath:e.path}):void 0})}function Ge(e){return e.kind==="html"||e.kind==="markdown"}function Y({href:e,filePath:n,iconOnly:o=!1}){const d=i.useCallback(c=>{me()&&(c.preventDefault(),Ke({href:e,filePath:n}).catch(l=>{Ee.error(l instanceof Error?l.message:"Failed to save file")}))},[n,e]);return t.jsx(P,{asChild:!0,variant:"ghost",size:o?"icon":"sm",className:x("rounded-sm text-primary shadow-none hover:bg-primary/10 hover:text-primary",o?"h-6 w-6 shrink-0 bg-transparent":"h-7 bg-primary/10 px-2.5 text-[11px] hover:bg-primary/15"),children:t.jsxs("a",{href:e,download:!0,"aria-label":o?"Download file":void 0,title:o?"Download file":void 0,onClick:d,children:[t.jsx(Me,{className:"h-3.5 w-3.5"}),!o&&"Download"]})})}function pe({title:e,description:n,action:o}){return t.jsx("div",{className:"flex h-full min-h-[14rem] items-center justify-center rounded-sm bg-background/35 p-4 text-center",children:t.jsxs("div",{className:"max-w-sm",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:e}),t.jsx("div",{className:"mt-1 break-all font-mono text-[10px] text-muted-foreground",children:n}),o&&t.jsx("div",{className:"mt-2.5 flex justify-center",children:o})]})})}function I({children:e,tone:n}){return t.jsx("div",{className:x("flex h-48 items-center justify-center text-[12px]",n==="muted"?"text-muted-foreground":"text-destructive"),children:e})}function Ie(e){return e.type==="directory"?"dir":e.size===void 0?e.kind??"file":`${e.kind??"file"} · ${Ze(e.size)}`}function Ye(e){if(e===".")return[];const n=e.split("/").filter(Boolean);return n.map((o,d)=>n.slice(0,d+1).join("/"))}function Ze(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}export{at as FilesTab};
|
|
11
|
+
*/const Le=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Me=fe("download",Le),Ue="save_dashboard_download";function me(e=xe()){const n=e?.__TAURI__?.core?.invoke;return typeof n=="function"?n:null}function He(e){const d=(e.trim().replace(/\\/g,"/").split("/").filter(Boolean).pop()??"").replace(/[<>:"/\\|?*\x00-\x1f]/g,"_").replace(/^[ .]+|[ .]+$/g,"");return d.length>0?d:"download"}async function Ke({href:e,filePath:n,currentWindow:o=xe(),fetchImpl:d=fetch}){const c=me(o);if(!c)return!1;const l=await d(e,{cache:"no-store"});if(!l.ok)throw new Error(`Failed to download file (${l.status})`);const M=await l.blob(),k=await Je(M),N=await c(Ue,{fileName:He(n),contentBase64:k});return!Qe(N)||N.saved!==!1}async function Je(e){const n=new Uint8Array(await e.arrayBuffer()),o=[],d=32768;for(let c=0;c<n.length;c+=d){const l=n.subarray(c,c+d);o.push(String.fromCharCode(...l))}return btoa(o.join(""))}function xe(){return typeof window>"u"?null:window}function Qe(e){return!!(e&&typeof e=="object"&&"saved"in e)}const Xe={getOutput:Ne,getOutputTree:ke,getOutputContent:je},ce=120,Ve=1200;function at({taskId:e,api:n=Xe,requestedFilePath:o=null,requestedFileRequestId:d=0,onPreviewFile:c}){const[l,M]=i.useState(null),[k,N]=i.useState([]),[S,Y]=i.useState({}),[C,D]=i.useState(new Set),[U,H]=i.useState(new Set),[g,T]=i.useState("."),[h,F]=i.useState(null),[ge,v]=i.useState(!1),[y,b]=i.useState(""),[q,_]=i.useState([]),[ee,O]=i.useState(!1),[te,z]=i.useState(null),[K,R]=i.useState(!0),[re,f]=i.useState(null),ae=i.useRef(null),J=i.useRef(null),m=l?.summary?.rootPath??l?.effectiveProjectPath??null,Q=y.trim(),w=Q.length>0,p=ge||y.length>0,se=i.useCallback(async()=>{f(null),R(!0),T("."),N([]),Y({}),D(new Set),H(new Set),F(null),v(!1),b(""),_([]),z(null),J.current=null;try{const a=await n.getOutput(e);if(M(a),!a.available){R(!1);return}const r=await n.getOutputTree(e,".");N(r.entries),R(!1)}catch(a){f(a instanceof Error?a.message:"Failed to load output"),R(!1)}},[n,e]);i.useEffect(()=>{se()},[se]);const $=i.useCallback(async a=>{const r=L(a,m);if(!r)return f("Invalid directory path"),[];if(S[r])return S[r];f(null),H(s=>new Set(s).add(r));try{const s=await n.getOutputTree(e,r);return Y(u=>({...u,[r]:s.entries})),s.entries}catch(s){return f(s instanceof Error?s.message:"Failed to load directory"),[]}finally{H(s=>{const u=new Set(s);return u.delete(r),u})}},[n,S,m,e]),A=i.useCallback(async a=>{const r=a.filter(s=>s!==".");if(r.length!==0){D(s=>{const u=new Set(s);for(const E of r)u.add(E);return u});for(const s of r)await $(s)}},[$]),X=i.useCallback(async a=>{const r=L(a,m);if(!r){f("Invalid directory path");return}v(!1),b(""),T(r),F(null),r!=="."&&await A(Ie(r))},[A,m]),ve=i.useCallback(async a=>{const r=L(a,m);if(!r){f("Invalid directory path");return}if(T(r),F(null),C.has(r)){D(s=>{const u=new Set(s);return u.delete(r),u});return}D(s=>new Set(s).add(r)),await $(r)},[C,$,m]),B=i.useCallback(async a=>{const r=L(a,m);if(!r){f("Invalid file path");return}f(null);try{const s=Te(r);v(!1),b(""),await A(_e(r));const u=await n.getOutputContent(e,r);T(s),F(u)}catch(s){f(s instanceof Error?s.message:"Failed to load file")}},[n,A,m,e]),be=i.useCallback(()=>{if(g===".")return;const a=g.split("/");a.pop();const r=a.length===0?".":a.join("/");X(r)},[g,X]);i.useEffect(()=>{if(!o||!l?.available||K)return;const a=`${d}:${o}`;J.current!==a&&(J.current=a,b(""),B(o))},[K,B,l?.available,o,d]),i.useEffect(()=>{p&&ae.current?.focus()},[p]),i.useEffect(()=>{if(!w||!l?.available){O(!1),_([]),z(null);return}let a=!1;async function r(){O(!0),z(null);const s=["."],u=new Set,E=[];let ie=0;try{for(;s.length>0&&ie<Ve&&E.length<ce;){const j=s.shift()??".";if(u.has(j))continue;u.add(j);const W=await n.getOutputTree(e,j);if(a)return;ie+=W.entries.length,E.push(...Re(W.entries,Q));for(const G of W.entries)G.type==="directory"&&!u.has(G.path)&&s.push(G.path)}a||(_(E.slice(0,ce)),O(!1))}catch(j){a||(_([]),z(j instanceof Error?j.message:"Failed to search files"),O(!1))}}return r(),()=>{a=!0}},[n,Q,l?.available,w,e]);const we=i.useMemo(()=>Oe(k,S,C,U),[S,k,C,U]),V=w?q.map(a=>({entry:a,depth:ze(a.path),expanded:a.type==="directory"&&C.has(a.path),loading:a.type==="directory"&&U.has(a.path)})):we;if(K)return t.jsx(Z,{tone:"muted",children:"Loading files..."});if(re)return t.jsx(Z,{tone:"destructive",children:re});if(!l?.available)return t.jsx(Z,{tone:"muted",children:"Task output is not available yet. The task may not have started."});const ne=(l.summary?.htmlEntries.length??0)+(l.summary?.markdownEntries?.length??0),ye=w?`${q.length}${ee?"+":""} matches`:`${l.summary?.fileCount??k.length} files`;return t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[16rem_minmax(0,1fr)] lg:pl-5",children:[t.jsxs("aside",{className:x("flex min-h-0 flex-col bg-card/25 lg:border-r lg:border-border/50",h&&"hidden lg:flex"),children:[t.jsxs("div",{className:"shrink-0 bg-card/20 px-2 py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-primary",children:t.jsx(oe,{className:"h-3.5 w-3.5"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-[12px] font-semibold leading-4 text-foreground",children:l.summary?.rootName??"Artifacts"}),t.jsxs("div",{className:"text-[10px] leading-4 text-muted-foreground",children:[ye,ne>0&&` · ${ne} previews`]})]}),t.jsx(P,{type:"button",variant:p?"secondary":"ghost",size:"icon","aria-expanded":p,"aria-label":p&&y.length===0?"Hide file search":"Search files",title:p&&y.length===0?"Hide file search":"Search files",className:"h-6 w-6 shrink-0 rounded-sm",onClick:()=>{p&&y.length===0?v(!1):v(!0)},children:t.jsx(le,{className:"h-3.5 w-3.5"})})]}),t.jsxs("div",{className:"mt-1 flex min-h-5 items-center gap-1 rounded-sm bg-muted/35 px-1.5 py-0",children:[g!=="."&&t.jsx(P,{variant:"ghost",size:"icon",className:"h-5 w-5 rounded-sm",onClick:be,children:t.jsx(de,{className:"h-3 w-3"})}),t.jsx("span",{className:"truncate font-mono text-[10px] leading-4 text-muted-foreground",children:g==="."?l.summary?.rootPath??l.summary?.rootName??"/":g})]}),p&&t.jsxs("div",{className:"mt-1 flex items-center gap-1 rounded-sm bg-muted/35 px-1.5 py-0",children:[t.jsx(le,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),t.jsx("input",{ref:ae,value:y,onChange:a=>b(a.target.value),onKeyDown:a=>{a.key==="Escape"&&(b(""),v(!1))},placeholder:"Search files and folders",className:"h-5 min-w-0 flex-1 bg-transparent text-[10px] leading-4 text-foreground outline-none placeholder:text-muted-foreground/70"}),t.jsx("button",{type:"button",onClick:()=>{b(""),v(!1)},className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted/70 hover:text-foreground","aria-label":"Close file search",children:t.jsx(Se,{className:"h-3 w-3"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1",children:ee&&V.length===0?t.jsx("div",{className:"flex h-full items-center justify-center rounded-sm border border-dashed border-border/70 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:"Searching files..."}):te?t.jsx("div",{className:"flex h-full items-center justify-center rounded-sm border border-dashed border-destructive/35 bg-destructive/10 px-3 text-center text-[11px] text-destructive",children:te}):V.length>0?t.jsx("div",{className:"space-y-0",children:V.map(a=>{const r=a.entry,s=h?.path===r.path||!h&&r.type==="directory"&&g===r.path;return t.jsxs("button",{type:"button","aria-current":s?"page":void 0,style:{"--tree-depth":a.depth,paddingLeft:`${4+a.depth*11}px`},onClick:()=>{r.type==="directory"?w?X(r.path):ve(r.path):B(r.path)},className:x("animate-task-row-reveal group relative flex min-h-5 w-full items-center gap-1 rounded-sm py-0 text-left transition-all duration-150",s?'bg-primary/10 text-foreground before:absolute before:left-0 before:top-1/2 before:h-1/2 before:w-[2px] before:-translate-y-1/2 before:rounded-full before:bg-primary before:content-[""]':"text-foreground hover:bg-muted/40"),children:[r.type==="directory"?t.jsx(Ce,{className:x("h-3 w-3 shrink-0 text-muted-foreground transition-transform",s&&"text-primary",a.expanded&&"rotate-90")}):t.jsx("span",{className:"h-3 w-3 shrink-0"}),r.type==="directory"?t.jsx(oe,{className:x("h-3 w-3 shrink-0 text-muted-foreground group-hover:text-foreground",s&&"text-primary")}):t.jsx(Ae,{className:x("h-3 w-3 shrink-0 text-muted-foreground group-hover:text-foreground",s&&"text-primary")}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-medium leading-4",children:w?r.path:r.name}),t.jsx("span",{className:x("max-w-[5.75rem] shrink-0 truncate text-right text-[9px] leading-4",s?"text-primary/75":"text-muted-foreground"),children:a.loading?"loading":Ze(r)})]},r.path)})}):t.jsx("div",{className:"flex h-full items-center justify-center rounded-sm border border-dashed border-border/70 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:w?"No matching files or folders":"Empty directory"})})]}),t.jsx("section",{className:x("min-h-0 flex flex-col bg-card/15",!h&&"hidden lg:flex"),children:h?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"shrink-0 px-3 py-1.5",children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx(P,{variant:"ghost",size:"icon","aria-label":"Back to file list",title:"Back to file list",className:"h-6 w-6 shrink-0 rounded-sm text-muted-foreground hover:bg-muted/55 hover:text-foreground",onClick:()=>F(null),children:t.jsx(de,{className:"h-3 w-3"})}),t.jsx("div",{className:"min-w-0 truncate font-mono text-[10px] leading-5 text-muted-foreground",children:h.path})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[c&&Ge(h)&&t.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Preview file",title:"Preview file",className:"h-6 w-6 shrink-0 rounded-sm text-primary hover:bg-primary/10 hover:text-primary",onClick:()=>c(h.path),children:t.jsx(Ee,{className:"h-3.5 w-3.5"})}),h.downloadUrl&&t.jsx(I,{href:h.downloadUrl,filePath:h.path,iconOnly:!0})]})]})}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-2.5 pb-2.5 pt-1",children:t.jsx(We,{content:h,rootPath:m,onOpenFile:B})})]}):t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:t.jsxs("div",{className:"max-w-md rounded-lg border border-border/60 bg-background/55 px-4 py-4 text-center",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:"Select a file to inspect"}),t.jsx("p",{className:"mt-1 text-[11px] leading-5 text-muted-foreground",children:"Preview source files, generated assets, or exported documents from this task."})]})})})]})}function We({content:e,rootPath:n,onOpenFile:o}){const d=e.downloadUrl;if(e.truncated&&!e.content)return t.jsx(pe,{title:"File is too large to preview inline",description:e.path,action:d?t.jsx(I,{href:d,filePath:e.path}):void 0});if(e.kind==="image"){const c=e.content?`data:${e.mimeType};base64,${e.content}`:d;return c?t.jsx("div",{className:"flex h-full min-h-[16rem] items-center justify-center rounded-sm bg-background/55 p-3",children:t.jsx("img",{src:c,alt:e.path,className:"max-h-full max-w-full rounded-sm object-contain shadow-[0_24px_90px_-52px_rgba(0,0,0,0.65)]"})}):t.jsx(he,{content:e})}if(e.kind==="pdf"&&d)return t.jsx("div",{className:"h-full min-h-[20rem] overflow-hidden rounded-sm bg-background/55",children:t.jsx("iframe",{src:d,title:e.path,className:"h-full w-full border-0"})});if(e.kind==="json"){let c=e.content;try{c=JSON.stringify(JSON.parse(e.content),null,2)}catch{}return t.jsx(ue,{content:c,truncated:e.truncated})}return e.kind==="markdown"?t.jsx(Pe,{content:e.content,truncated:e.truncated,resolveFileLink:c=>$e(c,n,{allowRootRelative:!0,baseFilePath:e.path}),onOpenFileLink:o}):e.kind==="text"||e.kind==="html"?t.jsx(ue,{content:e.content,truncated:e.truncated}):t.jsx(he,{content:e})}function ue({content:e,truncated:n}){return t.jsxs("div",{className:"rounded-sm bg-background/55",children:[t.jsx(De,{content:e}),n&&t.jsx("div",{className:"bg-muted/30 px-3 py-1.5 text-[10px] text-muted-foreground",children:"Content truncated. Download the file to inspect the full artifact."})]})}function he({content:e}){return t.jsx(pe,{title:`${e.kind} file`,description:e.path,action:e.downloadUrl?t.jsx(I,{href:e.downloadUrl,filePath:e.path}):void 0})}function Ge(e){return e.kind==="html"||e.kind==="markdown"}function I({href:e,filePath:n,iconOnly:o=!1}){const d=i.useCallback(c=>{me()&&(c.preventDefault(),Ke({href:e,filePath:n}).catch(l=>{Fe.error(l instanceof Error?l.message:"Failed to save file")}))},[n,e]);return t.jsx(P,{asChild:!0,variant:"ghost",size:o?"icon":"sm",className:x("rounded-sm text-primary shadow-none hover:bg-primary/10 hover:text-primary",o?"h-6 w-6 shrink-0 bg-transparent":"h-7 bg-primary/10 px-2.5 text-[11px] hover:bg-primary/15"),children:t.jsxs("a",{href:e,download:!0,"aria-label":o?"Download file":void 0,title:o?"Download file":void 0,onClick:d,children:[t.jsx(Me,{className:"h-3.5 w-3.5"}),!o&&"Download"]})})}function pe({title:e,description:n,action:o}){return t.jsx("div",{className:"flex h-full min-h-[14rem] items-center justify-center rounded-sm bg-background/35 p-4 text-center",children:t.jsxs("div",{className:"max-w-sm",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:e}),t.jsx("div",{className:"mt-1 break-all font-mono text-[10px] text-muted-foreground",children:n}),o&&t.jsx("div",{className:"mt-2.5 flex justify-center",children:o})]})})}function Z({children:e,tone:n}){return t.jsx("div",{className:x("flex h-48 items-center justify-center text-[12px]",n==="muted"?"text-muted-foreground":"text-destructive"),children:e})}function Ze(e){return e.type==="directory"?"dir":e.size===void 0?e.kind??"file":`${e.kind??"file"} · ${Ye(e.size)}`}function Ie(e){if(e===".")return[];const n=e.split("/").filter(Boolean);return n.map((o,d)=>n.slice(0,d+1).join("/"))}function Ye(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}export{at as FilesTab};
|
package/dashboard/assets/{MarkdownPreviewFrame-C56qjNyn.js → MarkdownPreviewFrame-CwXixe62.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as st,r as Xt,j as C,d as z}from"./index-
|
|
1
|
+
import{c as st,r as Xt,j as C,d as z}from"./index-BBHpcOD3.js";import{P as Re,Q as ye,R as He,S as Fe,U as he,V as ae,W as Ne,X as Kt,Y as Vt,Z as w,_ as zt,$ as rt,a0 as pe,a1 as jt,a2 as Jt,a3 as $t}from"./DashboardShared-DihTM-xx.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as $,j as e,I as le,B as f,as as L,aD as q,r as i,c0 as oe,b$ as ce,aI as O,G as de,H as ue,J as me,c1 as xe,y as fe,C as he}from"./index-BBHpcOD3.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const pe=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ve
|
|
6
|
+
*/const pe=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ve=$("maximize-2",pe);/**
|
|
7
7
|
* @license lucide-react v1.7.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const we=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],be
|
|
11
|
+
*/const we=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],be=$("minimize-2",we);/**
|
|
12
12
|
* @license lucide-react v1.7.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const ge=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],je
|
|
16
|
+
*/const ge=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],je=$("play",ge);/**
|
|
17
17
|
* @license lucide-react v1.7.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Ne=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],ke=z("settings-2",Ne),F="8314",ye={getOutput:ce,createPreviewSession:oe};function Se({taskId:s,api:t=ye,allowPortPreview:a=!1,requestedEntryPath:l=null,requestedEntryRequestId:b=0}){const[o,g]=i.useState(null),[n,c]=i.useState(null),[u,m]=i.useState(null),[j,y]=i.useState(F),[h,S]=i.useState(!1),[C,N]=i.useState(!0),[E,p]=i.useState(null),[ne,R]=i.useState(!1),[B,x]=i.useState(!1),A=i.useRef(null),K=i.useCallback(async()=>{N(!0),p(null),g(null),c(null),m(null),x(!1),A.current=null;try{const r=await t.getOutput(s);g(r),N(!1)}catch(r){p(r instanceof Error?r.message:"Failed to load output"),N(!1)}},[t,s]);i.useEffect(()=>{K()},[K]);const v=i.useCallback(async r=>{p(null);try{const d=await t.createPreviewSession(s,r?.path?{path:r.path}:void 0);c(d),S(!1),x(!1),r&&m(r),O("preview.created",{result:"success",previewType:r?.kind??"file"})}catch(d){p(d instanceof Error?d.message:"Failed to create preview session"),O("preview.failed",{result:"failed",previewType:r?.kind??"file"})}},[t,s]),P=i.useCallback(async r=>{const d=r??Number.parseInt(j.trim()||F,10);if(!Number.isInteger(d)||d<1||d>65535){p("Enter a port between 1 and 65535");return}p(null);try{const _=await t.createPreviewSession(s,{port:d});c(_),m(null),y(String(d)),S(!0),x(!1),O("preview.created",{result:"success",previewType:"service-port"})}catch(_){p(_ instanceof Error?_.message:"Failed to create preview session"),O("preview.failed",{result:"failed",previewType:"service-port"})}},[t,j,s]),w=i.useMemo(()=>Z(o),[o]),D=i.useMemo(()=>ee(w,l),[w,l]);i.useEffect(()=>{if(!l||!o?.available||C||h)return;const r=`${b}:${l}`;if(A.current!==r){if(A.current=r,!D){c(null),m(null),p("File is not available for preview");return}c(null),v(D)}},[C,o?.available,D,l,b,h,v]),i.useEffect(()=>{if(h||l||!o?.available||w.length===0||n&&n.kind!=="service")return;const r=u??w[0];r&&v(r)},[u,o,w,l,h,n,v]);const k=i.useCallback(()=>{if(n?.kind==="service"&&typeof n.port=="number"){P(n.port);return}c(null);const r=u??Z(o)[0];r&&v(r)},[u,o,n,P,v]);if(i.useEffect(()=>{if(!n)return;const r=n.expiresAt-Date.now()-5e3;if(r<=0){k();return}const d=window.setTimeout(k,r);return()=>window.clearTimeout(d)},[k,n]),C)return e.jsx(T,{children:"Loading preview..."});const M=a&&h;if(E&&n&&!M)return e.jsx(T,{children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"text-[11px] text-destructive",children:E}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(f,{variant:"outline",size:"sm",onClick:k,className:"rounded-sm",children:[e.jsx(L,{className:"h-3.5 w-3.5"}),"Retry"]})})]})});const G=!!o?.available;if(!G&&!a)return e.jsx(T,{children:"Task output is not available yet."});if(!n)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-1.5",children:e.jsx(U,{session:null,serviceModeOpen:M,allowPortPreview:a,servicePort:j,previewEntries:w,activeEntry:u,filesMenuOpen:B,onRefresh:k,onFullscreen:()=>R(!0),onServiceModeToggle:()=>{x(!1),S(r=>!r)},onServicePortChange:y,onServiceStart:()=>{P()},onFileMenuToggle:()=>x(r=>!r),onEntrySelect:r=>{x(!1),v(r)}})}),M?e.jsx(H,{serviceSession:null,error:E}):e.jsx(T,{children:E?e.jsx("span",{className:"text-[11px] text-destructive",children:E}):G?w.length>0?"Starting preview session...":"No HTML or Markdown files were found in this task output.":"Task output is not available yet."})]});const J=te(n),ie=$(n),W=se(n),X=re(n),I=n.kind==="service"?n:null,ae=M?I:n,Y=e.jsx("iframe",{src:W,className:"h-full w-full border-0",sandbox:X,title:"Task Preview"});return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-1.5",children:e.jsx(U,{session:ae,serviceModeOpen:M,allowPortPreview:a,servicePort:j,previewEntries:w,activeEntry:u,filesMenuOpen:B,onRefresh:k,onFullscreen:()=>R(!0),onServiceModeToggle:()=>{x(!1),S(r=>!r)},onServicePortChange:y,onServiceStart:()=>{P()},onFileMenuToggle:()=>x(r=>!r),onEntrySelect:r=>{x(!1),v(r)}})}),M?e.jsx(H,{serviceSession:I,error:E,children:I?Y:null}):e.jsx("div",{className:"min-h-0 flex-1 p-2",children:e.jsx("div",{className:"h-full overflow-hidden rounded-sm border border-border/60 bg-white shadow-none",children:Y})}),e.jsx(de,{open:ne,onOpenChange:R,children:e.jsxs(ue,{className:"flex h-[95vh] max-w-[95vw] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs(me,{className:"sr-only",children:["Preview: ",J]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-[12px] font-semibold text-foreground",children:J}),e.jsx("span",{className:"text-xs text-muted-foreground",children:V(n.expiresAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:k,title:"Refresh",children:e.jsx(L,{className:"h-3.5 w-3.5"})}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:ie,target:"_blank",rel:"noopener noreferrer",children:e.jsx(q,{className:"h-3.5 w-3.5"})})}),e.jsx(xe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"h-6 rounded-sm px-2 text-[11px]",title:"Exit fullscreen",children:[e.jsx(be,{className:"h-3.5 w-3.5"}),"Exit fullscreen"]})})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx("iframe",{src:W,className:"h-full w-full border-0",sandbox:X,title:"Task Preview Fullscreen"})})]})})]})}function Z(s){const t=s?.summary?.htmlEntries??[],a=s?.summary?.markdownEntries??[];return[...t.map(l=>({...l,kind:"html"})),...a.map(l=>({...l,kind:"markdown"}))]}function ee(s,t){if(!t)return null;const a=s.find(l=>l.path===t);return a||(/\.html?$/i.test(t)?{kind:"html",path:t,label:t}:/\.mdx?$/i.test(t)?{kind:"markdown",path:t,label:t}:null)}function Ee({entries:s,activeEntry:t,open:a,onToggle:l,onEntrySelect:b}){const o=s[0];if(!o)return null;const g=t??o,n=Q(g);return e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-expanded":a,"aria-haspopup":"menu","aria-label":"Preview files",onClick:l,className:"flex h-6 max-w-[min(24rem,calc(100vw-7rem))] items-center gap-1.5 rounded-sm px-1.5 text-left text-[12px] font-semibold text-foreground transition-colors hover:bg-background/70",children:[e.jsx("span",{className:"truncate",children:g.label}),e.jsx(fe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),a&&e.jsx("div",{role:"menu","aria-label":"Preview files",className:"absolute left-0 top-full z-30 mt-1 max-h-64 min-w-[14rem] max-w-[min(28rem,calc(100vw-4rem))] overflow-y-auto rounded-sm border border-border/70 bg-popover/95 p-1 text-popover-foreground shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:s.map(c=>{const u=Q(c),m=u===n;return e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":m,onClick:()=>b(c),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1 text-left text-[11px] leading-4 text-foreground transition-colors hover:bg-accent/75 hover:text-accent-foreground",children:[e.jsx("span",{className:"w-3.5 shrink-0 text-primary",children:m?e.jsx(he,{className:"h-3.5 w-3.5"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:c.label})]},u)})})]})}function Q(s){return`${s.kind}:${s.path}`}function U({session:s,serviceModeOpen:t,allowPortPreview:a,servicePort:l,previewEntries:b=[],activeEntry:o=null,filesMenuOpen:g=!1,onRefresh:n,onFullscreen:c,onServiceModeToggle:u,onServicePortChange:m,onServiceStart:j,onFileMenuToggle:y,onEntrySelect:h}){const S=s?$(s):null,C=!t&&b.length>0&&y&&h;return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:t&&m&&j?e.jsxs("form",{className:"flex min-w-0 items-center gap-1.5",onSubmit:N=>{N.preventDefault(),j()},children:[e.jsx("span",{className:"shrink-0 text-[12px] font-semibold text-foreground",children:"Preview service"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:["Port",e.jsx(le,{type:"text",min:1,max:65535,inputMode:"numeric",value:l??"",onChange:N=>m(N.target.value),placeholder:F,"aria-label":"Service preview port",className:"h-6 w-20 rounded-sm border-0 bg-muted/55 px-2 text-[11px] shadow-none focus:bg-muted/55 focus:outline-none focus-visible:border-0 focus-visible:bg-muted/55 focus-visible:ring-0 focus-visible:ring-offset-0"})]}),e.jsxs(f,{type:"submit",variant:"ghost",size:"sm",className:"h-6 rounded-sm border-0 bg-primary/10 px-2 text-[11px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Preview"]}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:V(s.expiresAt)})]}):e.jsxs(e.Fragment,{children:[C?e.jsx(Ee,{entries:b,activeEntry:o,open:g,onToggle:y,onEntrySelect:h}):e.jsx("span",{className:"truncate text-[12px] font-semibold text-foreground",children:s?te(s):"Preview"}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:V(s.expiresAt)})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:n,title:"Refresh",children:e.jsx(L,{className:"h-3.5 w-3.5"})}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:S??s.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(q,{className:"h-3.5 w-3.5"})})}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:c,title:"Fullscreen",children:e.jsx(ve,{className:"h-3.5 w-3.5"})})]}),a&&e.jsxs(f,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:u,className:"h-6 shrink-0 rounded-sm px-2 text-[11px]",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"Advanced"]})]})]})}function H({serviceSession:s,error:t,children:a}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-xs text-destructive",children:t}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:s&&a?e.jsx("div",{className:"h-full overflow-hidden rounded-sm border border-border/60 bg-white shadow-none",children:a}):e.jsx(T,{children:"No service preview running."})})]})}function $(s){return s.openUrl??s.previewUrl}function se(s){return s.kind==="service"?$(s):s.previewUrl}function re(s){return s.kind==="service"?void 0:"allow-scripts allow-same-origin"}function te(s){if(s.kind==="service"&&typeof s.port=="number"){const t=s.entryPath?`/${s.entryPath.replace(/^\/+/,"")}`:"";return`127.0.0.1:${s.port}${t}`}return s.entryPath}function T({children:s}){return e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:s})}function V(s){const t=Math.max(0,Math.round((s-Date.now())/1e3));if(t<60)return`${t}s`;const a=Math.floor(t/60),l=t%60;return`${a}m ${l}s`}const Ce=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_SERVICE_PREVIEW_PORT:F,PreviewHeader:U,PreviewServicePanel:H,PreviewTab:Se,getPreviewIframeSandbox:re,getPreviewIframeSrc:se,getPreviewOpenUrl:$,resolveRequestedPreviewEntry:ee},Symbol.toStringTag,{value:"Module"}));export{F as D,je as P,re as a,se as b,Ce as c,$ as g};
|
|
21
|
+
*/const Ne=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],ke=$("settings-2",Ne),F="8314",ye={getOutput:ce,createPreviewSession:oe};function Se({taskId:s,api:t=ye,allowPortPreview:a=!1,requestedEntryPath:l=null,requestedEntryRequestId:b=0}){const[o,g]=i.useState(null),[n,c]=i.useState(null),[u,m]=i.useState(null),[j,y]=i.useState(F),[h,S]=i.useState(!1),[C,N]=i.useState(!0),[E,p]=i.useState(null),[ne,R]=i.useState(!1),[B,x]=i.useState(!1),D=i.useRef(null),K=i.useCallback(async()=>{N(!0),p(null),g(null),c(null),m(null),x(!1),D.current=null;try{const r=await t.getOutput(s);g(r),N(!1)}catch(r){p(r instanceof Error?r.message:"Failed to load output"),N(!1)}},[t,s]);i.useEffect(()=>{K()},[K]);const v=i.useCallback(async r=>{p(null);try{const d=await t.createPreviewSession(s,r?.path?{path:r.path}:void 0);c(d),S(!1),x(!1),r&&m(r),O("preview.created",{result:"success",previewType:r?.kind??"file"})}catch(d){p(d instanceof Error?d.message:"Failed to create preview session"),O("preview.failed",{result:"failed",previewType:r?.kind??"file"})}},[t,s]),P=i.useCallback(async r=>{const d=r??Number.parseInt(j.trim()||F,10);if(!Number.isInteger(d)||d<1||d>65535){p("Enter a port between 1 and 65535");return}p(null);try{const _=await t.createPreviewSession(s,{port:d});c(_),m(null),y(String(d)),S(!0),x(!1),O("preview.created",{result:"success",previewType:"service-port"})}catch(_){p(_ instanceof Error?_.message:"Failed to create preview session"),O("preview.failed",{result:"failed",previewType:"service-port"})}},[t,j,s]),w=i.useMemo(()=>Y(o),[o]),A=i.useMemo(()=>ee(w,l),[w,l]);i.useEffect(()=>{if(!l||!o?.available||C||h)return;const r=`${b}:${l}`;if(D.current!==r){if(D.current=r,!A){c(null),m(null),p("File is not available for preview");return}c(null),v(A)}},[C,o?.available,A,l,b,h,v]),i.useEffect(()=>{if(h||l||!o?.available||w.length===0||n&&n.kind!=="service")return;const r=u??w[0];r&&v(r)},[u,o,w,l,h,n,v]);const k=i.useCallback(()=>{if(n?.kind==="service"&&typeof n.port=="number"){P(n.port);return}c(null);const r=u??Y(o)[0];r&&v(r)},[u,o,n,P,v]);if(i.useEffect(()=>{if(!n)return;const r=n.expiresAt-Date.now()-5e3;if(r<=0){k();return}const d=window.setTimeout(k,r);return()=>window.clearTimeout(d)},[k,n]),C)return e.jsx(T,{children:"Loading preview..."});const M=a&&h;if(E&&n&&!M)return e.jsx(T,{children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"text-[11px] text-destructive",children:E}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(f,{variant:"outline",size:"sm",onClick:k,className:"rounded-sm",children:[e.jsx(L,{className:"h-3.5 w-3.5"}),"Retry"]})})]})});const G=!!o?.available;if(!G&&!a)return e.jsx(T,{children:"Task output is not available yet."});if(!n)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-1.5",children:e.jsx(U,{session:null,serviceModeOpen:M,allowPortPreview:a,servicePort:j,previewEntries:w,activeEntry:u,filesMenuOpen:B,onRefresh:k,onFullscreen:()=>R(!0),onServiceModeToggle:()=>{x(!1),S(r=>!r)},onServicePortChange:y,onServiceStart:()=>{P()},onFileMenuToggle:()=>x(r=>!r),onEntrySelect:r=>{x(!1),v(r)}})}),M?e.jsx(H,{serviceSession:null,error:E}):e.jsx(T,{children:E?e.jsx("span",{className:"text-[11px] text-destructive",children:E}):G?w.length>0?"Starting preview session...":"No HTML or Markdown files were found in this task output.":"Task output is not available yet."})]});const J=te(n),ie=z(n),W=se(n),Q=re(n),I=n.kind==="service"?n:null,ae=M?I:n,X=e.jsx("iframe",{src:W,className:"h-full w-full border-0",sandbox:Q,title:"Task Preview"});return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-1.5",children:e.jsx(U,{session:ae,serviceModeOpen:M,allowPortPreview:a,servicePort:j,previewEntries:w,activeEntry:u,filesMenuOpen:B,onRefresh:k,onFullscreen:()=>R(!0),onServiceModeToggle:()=>{x(!1),S(r=>!r)},onServicePortChange:y,onServiceStart:()=>{P()},onFileMenuToggle:()=>x(r=>!r),onEntrySelect:r=>{x(!1),v(r)}})}),M?e.jsx(H,{serviceSession:I,error:E,children:I?X:null}):e.jsx("div",{className:"min-h-0 flex-1 p-2",children:e.jsx("div",{className:"h-full overflow-hidden rounded-sm border border-border/60 bg-white shadow-none",children:X})}),e.jsx(de,{open:ne,onOpenChange:R,children:e.jsxs(ue,{className:"flex h-[95vh] max-w-[95vw] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs(me,{className:"sr-only",children:["Preview: ",J]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-[12px] font-semibold text-foreground",children:J}),e.jsx("span",{className:"text-xs text-muted-foreground",children:V(n.expiresAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:k,title:"Refresh",children:e.jsx(L,{className:"h-3.5 w-3.5"})}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:ie,target:"_blank",rel:"noopener noreferrer",children:e.jsx(q,{className:"h-3.5 w-3.5"})})}),e.jsx(xe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"h-6 rounded-sm px-2 text-[11px]",title:"Exit fullscreen",children:[e.jsx(be,{className:"h-3.5 w-3.5"}),"Exit fullscreen"]})})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx("iframe",{src:W,className:"h-full w-full border-0",sandbox:Q,title:"Task Preview Fullscreen"})})]})})]})}function Y(s){const t=s?.summary?.htmlEntries??[],a=s?.summary?.markdownEntries??[];return[...t.map(l=>({...l,kind:"html"})),...a.map(l=>({...l,kind:"markdown"}))]}function ee(s,t){if(!t)return null;const a=s.find(l=>l.path===t);return a||(/\.html?$/i.test(t)?{kind:"html",path:t,label:t}:/\.mdx?$/i.test(t)?{kind:"markdown",path:t,label:t}:null)}function Ee({entries:s,activeEntry:t,open:a,onToggle:l,onEntrySelect:b}){const o=s[0];if(!o)return null;const g=t??o,n=Z(g);return e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-expanded":a,"aria-haspopup":"menu","aria-label":"Preview files",onClick:l,className:"flex h-6 max-w-[min(24rem,calc(100vw-7rem))] items-center gap-1.5 rounded-sm px-1.5 text-left text-[12px] font-semibold text-foreground transition-colors hover:bg-background/70",children:[e.jsx("span",{className:"truncate",children:g.label}),e.jsx(fe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),a&&e.jsx("div",{role:"menu","aria-label":"Preview files",className:"absolute left-0 top-full z-30 mt-1 max-h-64 min-w-[14rem] max-w-[min(28rem,calc(100vw-4rem))] overflow-y-auto rounded-sm border border-border/70 bg-popover/95 p-1 text-popover-foreground shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:s.map(c=>{const u=Z(c),m=u===n;return e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":m,onClick:()=>b(c),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1 text-left text-[11px] leading-4 text-foreground transition-colors hover:bg-accent/75 hover:text-accent-foreground",children:[e.jsx("span",{className:"w-3.5 shrink-0 text-primary",children:m?e.jsx(he,{className:"h-3.5 w-3.5"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:c.label})]},u)})})]})}function Z(s){return`${s.kind}:${s.path}`}function U({session:s,serviceModeOpen:t,allowPortPreview:a,servicePort:l,previewEntries:b=[],activeEntry:o=null,filesMenuOpen:g=!1,onRefresh:n,onFullscreen:c,onServiceModeToggle:u,onServicePortChange:m,onServiceStart:j,onFileMenuToggle:y,onEntrySelect:h}){const S=s?z(s):null,C=!t&&b.length>0&&y&&h;return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:t&&m&&j?e.jsxs("form",{className:"flex min-w-0 items-center gap-1.5",onSubmit:N=>{N.preventDefault(),j()},children:[e.jsx("span",{className:"shrink-0 text-[12px] font-semibold text-foreground",children:"Preview service"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:["Port",e.jsx(le,{type:"text",min:1,max:65535,inputMode:"numeric",value:l??"",onChange:N=>m(N.target.value),placeholder:F,"aria-label":"Service preview port",className:"h-6 w-20 rounded-sm border-0 bg-muted/55 px-2 text-[11px] shadow-none focus:bg-muted/55 focus:outline-none focus-visible:border-0 focus-visible:bg-muted/55 focus-visible:ring-0 focus-visible:ring-offset-0"})]}),e.jsxs(f,{type:"submit",variant:"ghost",size:"sm",className:"h-6 rounded-sm border-0 bg-primary/10 px-2 text-[11px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Preview"]}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:V(s.expiresAt)})]}):e.jsxs(e.Fragment,{children:[C?e.jsx(Ee,{entries:b,activeEntry:o,open:g,onToggle:y,onEntrySelect:h}):e.jsx("span",{className:"truncate text-[12px] font-semibold text-foreground",children:s?te(s):"Preview"}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:V(s.expiresAt)})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:n,title:"Refresh",children:e.jsx(L,{className:"h-3.5 w-3.5"})}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:S??s.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(q,{className:"h-3.5 w-3.5"})})}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:c,title:"Fullscreen",children:e.jsx(ve,{className:"h-3.5 w-3.5"})})]}),a&&e.jsxs(f,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:u,className:"h-6 shrink-0 rounded-sm px-2 text-[11px]",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"Advanced"]})]})]})}function H({serviceSession:s,error:t,children:a}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-xs text-destructive",children:t}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:s&&a?e.jsx("div",{className:"h-full overflow-hidden rounded-sm border border-border/60 bg-white shadow-none",children:a}):e.jsx(T,{children:"No service preview running."})})]})}function z(s){return s.openUrl??s.previewUrl}function se(s){return s.kind==="service"?z(s):s.previewUrl}function re(s){return s.kind==="service"?void 0:"allow-scripts allow-same-origin"}function te(s){if(s.kind==="service"&&typeof s.port=="number"){const t=s.entryPath?`/${s.entryPath.replace(/^\/+/,"")}`:"";return`127.0.0.1:${s.port}${t}`}return s.entryPath}function T({children:s}){return e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:s})}function V(s){const t=Math.max(0,Math.round((s-Date.now())/1e3));if(t<60)return`${t}s`;const a=Math.floor(t/60),l=t%60;return`${a}m ${l}s`}const Ce=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_SERVICE_PREVIEW_PORT:F,PreviewHeader:U,PreviewServicePanel:H,PreviewTab:Se,getPreviewIframeSandbox:re,getPreviewIframeSrc:se,getPreviewOpenUrl:z,resolveRequestedPreviewEntry:ee},Symbol.toStringTag,{value:"Module"}));export{F as D,je as P,re as a,se as b,Ce as c,z as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-jvuvGCqQ.js","assets/index-BBHpcOD3.js","assets/index-CE-vUwSy.css","assets/MarkdownPreviewFrame-CwXixe62.js","assets/DashboardShared-DihTM-xx.js","assets/file-CoTh89vx.js","assets/PreviewTab-oRD3Wntx.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{bo as S,r,j as e,L as T,R as C,bN as P,a0 as E,a2 as M,ah as O,bO as I,bP as _,bQ as y,bR as F,bS as L,ac as N,bT as q}from"./index-BBHpcOD3.js";import{B as A,E as R,y as z,x as B,m as D,C as G,o as w,v as U}from"./DashboardShared-DihTM-xx.js";const V=r.lazy(async()=>({default:(await N(()=>import("./FilesTab-jvuvGCqQ.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),W=r.lazy(async()=>({default:(await N(()=>import("./PreviewTab-oRD3Wntx.js").then(a=>a.c),__vite__mapDeps([6,1,2]))).PreviewTab})),H={getOutput:y,getOutputTree:_,getOutputContent:I},Q={getOutput:y,createPreviewSession:(t,a)=>q(t,typeof a=="string"?a:a?.path)};function X(){const{shareId:t}=S(),[a,d]=r.useState(null),[c,s]=r.useState([]),[u,m]=r.useState(!0),[b,l]=r.useState(null),x=r.useRef(null);return r.useEffect(()=>{if(!t){d(null),s([]),l("Shared conversation not found"),m(!1);return}let i=!1;x.current=t,m(!0),l(null);const h=async o=>{try{const[p,f]=await Promise.all([F(t),L(t)]);if(i||x.current!==t)return;d(p),s(n=>o?f.logs:U(n,f.logs)),l(null)}catch(p){if(i||x.current!==t)return;o&&(d(null),s([]),l(p instanceof Error?p.message:"Failed to load shared conversation"))}finally{!i&&x.current===t&&o&&m(!1)}};h(!0);const g=window.setInterval(()=>{h(!1)},2500);return()=>{i=!0,window.clearInterval(g)}},[t]),e.jsx(Z,{conversation:a,logs:c,loading:u,error:b})}function Z({conversation:t,logs:a,loading:d,error:c}){const[s,u]=r.useState("transcript"),[m,b]=r.useState(null),[l,x]=r.useState(!1),i=r.useMemo(()=>{if(!t)return null;const n=A(t.payload.initialMessage);return n.length>0&&R(a,n)?null:n.length>0?z(n,new Date(t.createdAt).toISOString()):null},[t,a]),h=r.useMemo(()=>B([...i?[i]:[],...a]),[i,a]),g=r.useMemo(()=>D(h),[h]),o=t?.scope==="filesPreview",p=r.useCallback(n=>{o&&(b(v=>({path:n,requestId:(v?.requestId??0)+1})),u("files"))},[o]);r.useEffect(()=>{b(null)},[t?.shareId]);const f=e.jsx("section",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain scroll-pb-16 bg-gradient-to-b from-background/15 via-transparent to-background/35 px-4 py-4 sm:px-6",children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-4 pb-16",children:[d&&e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-border/60 bg-background/60 px-3 py-2 text-[11px] text-muted-foreground",children:[e.jsx(T,{className:"h-4 w-4 animate-spin"}),"Loading shared conversation..."]}),!d&&c&&e.jsxs("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-4 text-center text-destructive",children:[e.jsx("div",{className:"text-[12px] font-semibold",children:"Shared conversation unavailable"}),e.jsx("div",{className:"mt-1 text-[11px]",children:c})]}),!d&&!c&&h.length===0&&e.jsxs("div",{className:"rounded-sm border border-dashed border-border/70 bg-background/35 px-3 py-4 text-center",children:[e.jsx(C,{className:"mx-auto h-5 w-5 text-muted-foreground"}),e.jsx("div",{className:"mt-2 text-[12px] font-medium text-foreground",children:"No transcript output yet"})]}),!d&&!c&&g.map(({event:n,subItems:v},k)=>e.jsx(G,{event:n,agent:t?.agent,subItems:v,onOpenFilePath:p,questionResponseDisabled:!0},`shared-${k}`))]})});return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background text-foreground",children:[e.jsx("div",{className:"mesh-grid pointer-events-none absolute inset-0"}),e.jsxs("div",{className:"relative z-10 flex h-full min-h-0 gap-2 px-2 py-2 sm:px-3",children:[e.jsxs("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle hidden w-64 shrink-0 flex-col overflow-hidden rounded-sm px-3 py-3 lg:flex xl:w-72",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-sm border border-border/70 bg-foreground text-[11px] font-semibold tracking-[0.24em] text-background shadow-none",children:"M"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:"Meshy Workspace"}),e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Shared view"})]})]}),e.jsx("div",{className:"mt-4 text-[10px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Shared conversation"}),t&&e.jsxs("div",{className:"mt-2 space-y-2.5",children:[e.jsx("h1",{className:"max-h-24 overflow-hidden break-words text-[13px] font-semibold leading-5 text-foreground [overflow-wrap:anywhere]",title:t.title,children:t.title}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(P,{status:t.status}),e.jsx(E,{priority:t.priority})]}),e.jsxs("div",{className:"space-y-1 text-[11px] text-muted-foreground",children:[e.jsxs("div",{children:["updated ",M(t.updatedAt)]}),e.jsx("div",{className:"font-mono",children:t.id.slice(0,8)})]})]}),e.jsxs("div",{className:"mt-auto space-y-2 pt-6",children:[l&&e.jsx("div",{className:"rounded-sm border border-border/70 bg-background/80 p-2.5 font-mono text-[11px] text-foreground shadow-none",children:"npx -y meshy-node@latest start"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:"https://github.com/gim-home/meshy",target:"_blank",rel:"noreferrer","aria-label":"Open Meshy on GitHub",className:"inline-flex h-8 w-8 items-center justify-center rounded-sm border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx($,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",onClick:()=>x(n=>!n),"aria-expanded":l,className:"inline-flex h-8 items-center gap-1.5 rounded-sm border border-border/70 bg-background/70 px-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(O,{className:"h-4 w-4"}),"Try it"]})]})]})]}),e.jsxs("main",{className:"dashboard-panel animate-panel-settle flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-sm",children:[e.jsxs("header",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-2 sm:px-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-sm border border-border/70 bg-foreground text-[11px] font-semibold tracking-[0.24em] text-background lg:hidden",children:"M"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.28em] text-muted-foreground",children:"Meshy Workspace"}),e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:t?.title??"Shared conversation"})]})]}),o&&e.jsxs("div",{className:"mt-3 inline-flex h-7 rounded-sm border border-border/55 bg-background/35 p-0.5 text-muted-foreground",children:[e.jsx("button",{type:"button",onClick:()=>u("transcript"),"aria-current":s==="transcript"?"page":void 0,className:j(s==="transcript"),children:"Transcript"}),e.jsx("button",{type:"button",onClick:()=>u("files"),"aria-current":s==="files"?"page":void 0,className:j(s==="files"),children:"Files"}),e.jsx("button",{type:"button",onClick:()=>u("preview"),"aria-current":s==="preview"?"page":void 0,className:j(s==="preview"),children:"Preview"})]})]}),o&&t?e.jsxs(e.Fragment,{children:[s==="transcript"&&f,s==="files"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(r.Suspense,{fallback:e.jsx(w,{label:"Loading files..."}),children:e.jsx(V,{taskId:t.shareId,api:H,requestedFilePath:m?.path??null,requestedFileRequestId:m?.requestId??0})})}),s==="preview"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(r.Suspense,{fallback:e.jsx(w,{label:"Loading preview..."}),children:e.jsx(W,{taskId:t.shareId,api:Q,allowPortPreview:!1})})})]}):f]})]})]})}function j(t){return t?"inline-flex h-full items-center justify-center whitespace-nowrap rounded-sm border border-primary/30 bg-primary/10 px-2.5 text-[11px] font-medium text-primary shadow-none":"inline-flex h-full items-center justify-center whitespace-nowrap rounded-sm border border-transparent px-2.5 text-[11px] font-medium transition-colors hover:bg-muted/35 hover:text-foreground"}function $({className:t}){return e.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.58 2 12.23c0 4.51 2.87 8.34 6.84 9.7.5.1.68-.22.68-.49 0-.24-.01-.88-.01-1.73-2.78.62-3.37-1.37-3.37-1.37-.45-1.18-1.11-1.49-1.11-1.49-.91-.64.07-.63.07-.63 1 .07 1.53 1.06 1.53 1.06.89 1.56 2.34 1.11 2.91.85.09-.66.35-1.11.63-1.37-2.22-.26-4.55-1.14-4.55-5.05 0-1.12.39-2.03 1.03-2.75-.1-.26-.45-1.31.1-2.71 0 0 .84-.27 2.75 1.05A9.3 9.3 0 0 1 12 6.96c.85 0 1.71.12 2.51.34 1.91-1.32 2.75-1.05 2.75-1.05.55 1.4.2 2.45.1 2.71.64.72 1.03 1.63 1.03 2.75 0 3.92-2.34 4.79-4.57 5.05.36.32.68.94.68 1.9 0 1.37-.01 2.47-.01 2.81 0 .27.18.59.69.49A10.05 10.05 0 0 0 22 12.23C22 6.58 17.52 2 12 2Z"})})}export{X as SharedConversationPage,Z as SharedConversationView};
|