meshy-node 0.8.10 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dashboard/assets/DashboardPage-CKkLv8I1.js +149 -0
- package/dashboard/assets/{DashboardShared-Dp0Fy_Ow.js → DashboardShared-BvjPqceV.js} +33 -33
- package/dashboard/assets/DiffTab-BEsNBvvh.js +18 -0
- package/dashboard/assets/FilesTab-Cg5PBMv6.js +11 -0
- package/dashboard/assets/MarkdownPreviewFrame-B58EGPZX.js +12 -0
- package/dashboard/assets/{PreviewTab-_L379b0E.js → PreviewTab-CoN0CJR0.js} +2 -2
- package/dashboard/assets/{SharedConversationPage-Bq1VobyA.js → SharedConversationPage-aj_wfoD8.js} +3 -3
- package/dashboard/assets/{file-BDgANqYE.js → file-BDYM9RQo.js} +1 -1
- package/dashboard/assets/{index-D9o9Minz.js → index-AgRF0fhH.js} +2 -2
- package/dashboard/assets/index-BYWN4SLt.css +1 -0
- package/dashboard/assets/{play-CdDHr-lN.js → play-nM4_YhiZ.js} +1 -1
- package/dashboard/index.html +2 -2
- package/main.cjs +553 -412
- package/package.json +1 -1
- package/runtime-metadata.json +4 -4
- package/dashboard/assets/DashboardPage-CirLzrD2.js +0 -144
- package/dashboard/assets/DiffTab-CFH_P3BV.js +0 -4
- package/dashboard/assets/FilesTab-BCCKrMjo.js +0 -11
- package/dashboard/assets/MarkdownPreviewFrame-CQs46DMm.js +0 -12
- package/dashboard/assets/index-BtsHIDyN.css +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{c as W,j as n,b as k,r as c,bE as A,by as B,v as U,k as I,R as V,i as G}from"./index-AgRF0fhH.js";import{G as H}from"./DashboardPage-CKkLv8I1.js";import{F as J}from"./file-BDYM9RQo.js";import"./DashboardShared-BvjPqceV.js";import"./play-nM4_YhiZ.js";import"./MarkdownPreviewFrame-B58EGPZX.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const z=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],q=W("columns-2",z);/**
|
|
7
|
+
* @license lucide-react v1.7.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const K=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],Q=W("rows-3",K);function X(e,t){if(!(e!=null&&e.trim()))return[];const r=e.split(`
|
|
12
|
+
`),i=[];let s=[];const d=()=>{if(s.length===0)return;const a=s.join(`
|
|
13
|
+
`).trim();if(!a){s=[];return}const o=oe(s);if(!o){s=[];return}i.push({id:`${t}:${o}`,path:o,section:t,patch:a}),s=[]};for(const a of r)a.startsWith("diff --git ")&&s.length>0&&d(),s.push(a);return d(),i}function F(e,t,r){const i=(e==null?void 0:e.filter(s=>s.section===r))??[];return i.length===0?X(t,r):i.map(s=>({id:`${r}:${s.path}`,path:s.path,section:r,status:s.status,patch:s.patch,oldExists:s.oldExists,newExists:s.newExists,oldContent:s.oldContent,newContent:s.newContent,oldTruncated:s.oldTruncated,newTruncated:s.newTruncated,binary:s.binary}))}function Y(e){const t=[];for(const r of[...e].sort((i,s)=>i.path.localeCompare(s.path))){const i=r.path.split("/").filter(Boolean);let s=t,d="";i.forEach((a,o)=>{d=d?`${d}/${a}`:a;const l=o===i.length-1;let m=s.find(u=>u.name===a);m||(m=l?{type:"file",name:a,path:d,item:r}:{type:"folder",name:a,path:d,children:[]},s.push(m)),l||(m.children??(m.children=[]),s=m.children)})}return t}function Z(e){const t=[];let r="";for(const i of e.split("/").filter(Boolean).slice(0,-1))r=r?`${r}/${i}`:i,t.push(r);return t}function ee(e){return e.filter(t=>t&&!t.endsWith("/")).map(t=>({id:`untracked:${t}`,path:t,section:"untracked"}))}function te({oldContent:e,newContent:t,patch:r}){const i=D(e),s=D(t),d=se(r);if(d.length===0)return ie(i,s);const a=[];let o=1,l=1;const m=(u,h)=>{const f=Math.min(u,i.length+1),v=Math.min(h,s.length+1);for(;o<f||l<v;){const p=o<f&&o<=i.length,y=l<v&&l<=s.length;a.push({oldLineNumber:p?o:null,newLineNumber:y?l:null,oldContent:p?i[o-1]??"":"",newContent:y?s[l-1]??"":"",kind:p&&y?"context":p?"removed":"added"}),o<f&&(o+=1),l<v&&(l+=1)}o<u&&(o=u),l<h&&(l=h)};for(const u of d){m(u.oldStart>0?u.oldStart:o,u.newStart>0?u.newStart:l);let h=0;for(;h<u.lines.length;){const f=u.lines[h];if(!f)break;if(f.kind==="context"){a.push({oldLineNumber:o,newLineNumber:l,oldContent:i[o-1]??f.content,newContent:s[l-1]??f.content,kind:"context"}),o+=1,l+=1,h+=1;continue}const v=[],p=[];for(;h<u.lines.length;){const g=u.lines[h];if(!g||g.kind==="context")break;g.kind==="removed"?(v.push({lineNumber:o,content:i[o-1]??g.content}),o+=1):(p.push({lineNumber:l,content:s[l-1]??g.content}),l+=1),h+=1}const y=Math.max(v.length,p.length);for(let g=0;g<y;g+=1){const N=v[g],w=p[g];a.push({oldLineNumber:(N==null?void 0:N.lineNumber)??null,newLineNumber:(w==null?void 0:w.lineNumber)??null,oldContent:(N==null?void 0:N.content)??"",newContent:(w==null?void 0:w.content)??"",kind:N&&w?"changed":N?"removed":"added"})}}}for(;o<=i.length||l<=s.length;){const u=o<=i.length,h=l<=s.length;a.push({oldLineNumber:u?o:null,newLineNumber:h?l:null,oldContent:u?i[o-1]??"":"",newContent:h?s[l-1]??"":"",kind:u&&h?"context":u?"removed":"added"}),u&&(o+=1),h&&(l+=1)}return a}function ne(e){return D(e).map((t,r)=>({oldLineNumber:null,newLineNumber:r+1,oldContent:"",newContent:t,kind:"added"}))}function re(e){const t=[];for(const r of e){if(r.kind==="context"){t.push({oldLineNumber:r.oldLineNumber,newLineNumber:r.newLineNumber,content:r.newContent||r.oldContent,kind:"context",prefix:" "});continue}if(r.kind==="changed"){t.push({oldLineNumber:r.oldLineNumber,newLineNumber:null,content:r.oldContent,kind:"removed",prefix:"-"}),t.push({oldLineNumber:null,newLineNumber:r.newLineNumber,content:r.newContent,kind:"added",prefix:"+"});continue}if(r.kind==="removed"){t.push({oldLineNumber:r.oldLineNumber,newLineNumber:null,content:r.oldContent,kind:"removed",prefix:"-"});continue}t.push({oldLineNumber:null,newLineNumber:r.newLineNumber,content:r.newContent,kind:"added",prefix:"+"})}return t}function D(e){if(!e)return[];const t=e.replace(/\r\n/g,`
|
|
14
|
+
`).replace(/\r/g,`
|
|
15
|
+
`).split(`
|
|
16
|
+
`);return t.length>0&&t[t.length-1]===""&&t.pop(),t}function se(e){if(!e)return[];const t=[];let r=null;for(const i of e.split(`
|
|
17
|
+
`)){const s=i.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(s){r={oldStart:Number(s[1]??0),newStart:Number(s[2]??0),lines:[]},t.push(r);continue}if(!r||i.startsWith("\\ No newline"))continue;const d=i.charAt(0);d===" "?r.lines.push({kind:"context",content:i.slice(1)}):d==="+"?r.lines.push({kind:"added",content:i.slice(1)}):d==="-"&&r.lines.push({kind:"removed",content:i.slice(1)})}return t}function ie(e,t){const r=Math.max(e.length,t.length),i=[];for(let s=0;s<r;s+=1){const d=s<e.length,a=s<t.length,o=e[s]??"",l=t[s]??"";i.push({oldLineNumber:d?s+1:null,newLineNumber:a?s+1:null,oldContent:o,newContent:l,kind:d&&a?o===l?"context":"changed":d?"removed":"added"})}return i}function oe(e){var d,a;const t=(d=e.find(o=>o.startsWith("+++ ")))==null?void 0:d.slice(4).trim();if(t&&t!=="/dev/null")return T(t);const r=(a=e.find(o=>o.startsWith("--- ")))==null?void 0:a.slice(4).trim();if(r&&r!=="/dev/null")return T(r);const i=e.find(o=>o.startsWith("diff --git "));if(!i)return null;const s=i.match(/^diff --git a\/(.+?) b\/(.+)$/);return s?T(s[2]||s[1]||""):null}function T(e){return e.replace(/^[ab]\//,"")}function de({item:e,viewMode:t}){return e.binary?n.jsx(j,{tone:"muted",children:"Binary file changed."}):typeof e.oldContent=="string"||typeof e.newContent=="string"?n.jsx(M,{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:t}):n.jsx(xe,{patch:e.patch??""})}function le({loading:e,error:t,content:r,viewMode:i}){if(e)return n.jsx(j,{tone:"muted",children:"Loading file content..."});if(t)return n.jsx(j,{tone:"destructive",children:t});if(!r)return n.jsx(j,{tone:"muted",children:"Select an untracked file to preview its content."});if(r.kind==="image"){const s=r.content?`data:${r.mimeType};base64,${r.content}`:r.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:r.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(j,{tone:"muted",children:"Image preview is not available."})}if(r.kind==="pdf"&&r.downloadUrl)return n.jsx("div",{className:"h-full min-h-[22rem] overflow-hidden rounded-sm bg-background/55",children:n.jsx("iframe",{src:r.downloadUrl,title:r.path,className:"h-full w-full border-0"})});if(r.kind==="json"){let s=r.content;try{s=JSON.stringify(JSON.parse(r.content),null,2)}catch{}return n.jsx(M,{oldContent:"",newContent:s,addedOnly:!0,newTitle:"Untracked",newTruncated:r.truncated,viewMode:i})}return r.kind==="markdown"||r.kind==="text"||r.kind==="html"?n.jsx(M,{oldContent:"",newContent:r.content,addedOnly:!0,newTitle:"Untracked",newTruncated:r.truncated,viewMode:i}):n.jsx(j,{tone:"muted",children:"This file cannot be previewed inline."})}function M({oldContent:e,newContent:t,patch:r,oldTitle:i="Base",newTitle:s="Current",oldTruncated:d=!1,newTruncated:a=!1,addedOnly:o=!1,viewMode:l}){const m=c.useMemo(()=>o?ne(t):te({oldContent:e,newContent:t,patch:r}),[o,t,e,r]);return n.jsxs("div",{className:"overflow-hidden rounded-sm bg-background/55",children:[n.jsx("div",{className:"overflow-x-auto",children:l==="inline"?n.jsx(ce,{rows:m,oldTitle:i,newTitle:s}):n.jsx(ae,{rows:m,oldTitle:i,newTitle:s})}),(d||a)&&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 ae({rows:e,oldTitle:t,newTitle:r}){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:t}),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:r})]}),n.jsx("div",{className:"font-mono text-[10px] leading-4",children:e.length>0?e.map((i,s)=>n.jsx(ue,{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 ce({rows:e,oldTitle:t,newTitle:r}){const i=c.useMemo(()=>re(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:[t," / ",r]})]}),n.jsx("div",{className:"font-mono text-[10px] leading-4",children:i.length>0?i.map((s,d)=>n.jsx(me,{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 ue({row:e}){return n.jsxs("div",{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:k("select-none border-r border-border/40 px-2 py-px text-right text-muted-foreground/55",_(e)),children:e.oldLineNumber??""}),n.jsx("span",{className:k("whitespace-pre-wrap break-all border-r border-border/60 px-2 py-px text-foreground",_(e)),children:e.oldContent||" "}),n.jsx("span",{className:k("select-none border-r border-border/40 px-2 py-px text-right text-muted-foreground/55",R(e)),children:e.newLineNumber??""}),n.jsx("span",{className:k("whitespace-pre-wrap break-all px-2 py-px text-foreground",R(e)),children:e.newContent||" "})]})}function me({row:e}){return n.jsxs("div",{className:k("grid min-w-[42rem] grid-cols-[3rem_3rem_minmax(0,1fr)] border-b border-border/25 last:border-b-0",he(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 xe({patch:e}){const t=e.split(`
|
|
18
|
+
`);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:[t.length," lines"]})]}),n.jsx("div",{className:"font-mono text-[10px] leading-4",children:t.map((r,i)=>n.jsxs("div",{className:k("grid grid-cols-[36px_minmax(0,1fr)] gap-2 px-2.5 py-px",fe(r)),children:[n.jsx("span",{className:"select-none text-right text-muted-foreground/55",children:i+1}),n.jsx("span",{className:"whitespace-pre-wrap break-all text-foreground",children:r||" "})]},`${i}-${r}`))})]})}function j({children:e,tone:t}){return n.jsx("div",{className:k("flex h-full min-h-[10rem] items-center justify-center rounded-sm text-[10px]",t==="muted"?"text-muted-foreground":"text-destructive"),children:e})}function _(e){return e.kind==="removed"||e.kind==="changed"?"bg-destructive/10":e.kind==="added"?"bg-muted/25 text-muted-foreground":""}function R(e){return e.kind==="added"||e.kind==="changed"?"bg-emerald-500/10":e.kind==="removed"?"bg-muted/25 text-muted-foreground":""}function he(e){return e.kind==="added"?"bg-emerald-500/10":e.kind==="removed"?"bg-destructive/10":""}function fe(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":""}const pe={staged:"Staged",unstaged:"Unstaged",untracked:"Untracked"};function Se({taskId:e}){const[t,r]=c.useState(null),[i,s]=c.useState(!0),[d,a]=c.useState(null),[o,l]=c.useState(null),[m,u]=c.useState(null),[h,f]=c.useState(!1),[v,p]=c.useState(null),[y,g]=c.useState("split"),N=c.useCallback(async()=>{s(!0),a(null),r(null);try{const x=await A(e);r(x)}catch(x){a(x instanceof Error?x.message:"Failed to load diff")}finally{s(!1)}},[e]);c.useEffect(()=>{N()},[N]);const w=c.useMemo(()=>F(t==null?void 0:t.files,t==null?void 0:t.staged,"staged"),[t==null?void 0:t.files,t==null?void 0:t.staged]),$=c.useMemo(()=>F(t==null?void 0:t.files,t==null?void 0:t.unstaged,"unstaged"),[t==null?void 0:t.files,t==null?void 0:t.unstaged]),E=c.useMemo(()=>ee((t==null?void 0:t.untrackedFiles)??[]),[t==null?void 0:t.untrackedFiles]),S=c.useMemo(()=>[{section:"staged",items:w},{section:"unstaged",items:$},{section:"untracked",items:E}],[w,$,E]),L=c.useMemo(()=>S.flatMap(x=>x.items),[S]),P=c.useMemo(()=>S.filter(x=>x.items.length>0),[S]),b=c.useMemo(()=>L.find(x=>x.id===o)??L[0]??null,[L,o]);return c.useEffect(()=>{var x;(!o||!L.some(C=>C.id===o))&&l(((x=L[0])==null?void 0:x.id)??null)},[L,o]),c.useEffect(()=>{if(u(null),p(null),f(!1),!b||b.section!=="untracked")return;if(b.path.endsWith("/")){p("This untracked path is a directory. Open the Files tab to inspect its contents.");return}let x=!1;return f(!0),B(e,b.path).then(C=>{x||u(C)}).catch(C=>{x||p(C instanceof Error?C.message:"Failed to load file content")}).finally(()=>{x||f(!1)}),()=>{x=!0}},[b,e]),i?n.jsx(j,{tone:"muted",children:"Loading diff..."}):d?n.jsx(j,{tone:"destructive",children:d}):t!=null&&t.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(H,{className:"h-3 w-3 text-muted-foreground"}),n.jsx("span",{className:"truncate",children:t.branch??"detached HEAD"})]}),t.repoRoot&&n.jsx("div",{className:"mt-1 truncate font-mono text-[10px] leading-4 text-muted-foreground",children:t.repoRoot})]})})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1",children:n.jsx("div",{className:"space-y-1",children:P.map(({section:x,items:C})=>n.jsx(ge,{section:x,items:C,selectedId:(b==null?void 0:b.id)??null,onSelect:l},x))})})]}),n.jsx("section",{className:"min-h-0 flex flex-col bg-card/15",children:b?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:b.path}),n.jsx(be,{mode:y,onModeChange:g})]})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-1.5 pb-1.5 pt-1",children:b.section==="untracked"?n.jsx(le,{loading:h,error:v,content:m,viewMode:y}):n.jsx(de,{item:b,viewMode:y})})]}):n.jsx(j,{tone:"muted",children:"Select a file to inspect."})})]}):n.jsx(j,{tone:"muted",children:"Working tree is clean."}):n.jsx(j,{tone:"muted",children:"Task working directory is not inside a Git repository."})}function ge({section:e,items:t,selectedId:r,onSelect:i}){const s=c.useMemo(()=>Y(t),[t]),d=c.useMemo(()=>t.find(m=>m.id===r)??null,[t,r]),a=c.useMemo(()=>new Set(d?Z(d.path):[]),[d]),[o,l]=c.useState(!0);return t.length===0?null:n.jsxs("section",{className:"rounded-sm bg-background/35",children:[n.jsxs("button",{type:"button",onClick:()=>l(m=>!m),"aria-expanded":o,className:k("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(U,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):n.jsx(I,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"text-[10px] font-medium text-foreground",children:pe[e]})]}),n.jsx(V,{variant:"outline",className:"rounded-sm border-transparent bg-muted/45 px-1.5 py-0 text-[9px]",children:t.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(O,{node:m,depth:0,selectedId:r,expandedAncestorPaths:a,onSelect:i},`${e}:${m.path}`))}):null})]})}function be({mode:e,onModeChange:t}){const r=i=>k("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:()=>t("split"),className:r(e==="split"),children:[n.jsx(q,{className:"h-3 w-3"}),n.jsx("span",{children:"Split"})]}),n.jsxs("button",{type:"button","aria-pressed":e==="inline",title:"Inline diff",onClick:()=>t("inline"),className:r(e==="inline"),children:[n.jsx(Q,{className:"h-3 w-3"}),n.jsx("span",{children:"Inline"})]})]})}function O({node:e,depth:t,selectedId:r,expandedAncestorPaths:i,onSelect:s}){var d;return e.type==="folder"?n.jsx(Ne,{node:e,depth:t,selectedId:r,expandedAncestorPaths:i,onSelect:s}):n.jsxs("button",{type:"button",onClick:()=>{e.item&&s(e.item.id)},className:k("flex w-full cursor-pointer items-center gap-1 rounded-sm px-1 py-0.5 text-left transition-colors",((d=e.item)==null?void 0:d.id)===r?"bg-primary/10 text-foreground":"text-foreground/90 hover:bg-background/55"),style:{paddingLeft:`${t*10+5}px`},children:[n.jsx(J,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"truncate text-[10px] leading-4",children:e.name})]})}function Ne({node:e,depth:t,selectedId:r,expandedAncestorPaths:i,onSelect:s}){const[d,a]=c.useState(!0);return c.useEffect(()=>{i.has(e.path)&&a(!0)},[i,e.path]),n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>a(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:`${t*10+5}px`},children:[d?n.jsx(U,{className:"h-3 w-3 shrink-0"}):n.jsx(I,{className:"h-3 w-3 shrink-0"}),n.jsx(G,{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(O,{node:o,depth:t+1,selectedId:r,expandedAncestorPaths:i,onSelect:s},o.path))})]})}export{Se as DiffTab};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{c as ye,r as o,by as De,bz as Pe,bA as Te,j as t,i as me,B as L,u as xe,X as _e,k as Oe,b as x,t as ze}from"./index-AgRF0fhH.js";import{M as Re,L as $e}from"./MarkdownPreviewFrame-B58EGPZX.js";import{w as B,x as Ae,y as Be,z as Le,B as Me,E as Ue,F as He}from"./DashboardShared-BvjPqceV.js";import{F as Ke}from"./file-BDYM9RQo.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Qe=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],pe=ye("arrow-left",Qe);/**
|
|
7
|
+
* @license lucide-react v1.7.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Xe=[["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"}]],Je=ye("download",Xe),Ve="save_dashboard_download";function we(e=je()){var l,d;const i=(d=(l=e==null?void 0:e.__TAURI__)==null?void 0:l.core)==null?void 0:d.invoke;return typeof i=="function"?i:null}function Ge(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 Ie({href:e,filePath:i,currentWindow:l=je(),fetchImpl:d=fetch}){const s=we(l);if(!s)return!1;const h=await d(e,{cache:"no-store"});if(!h.ok)throw new Error(`Failed to download file (${h.status})`);const N=await h.blob(),F=await Ye(N),p=await s(Ve,{fileName:Ge(i),contentBase64:F});return!Ze(p)||p.saved!==!1}async function Ye(e){const i=new Uint8Array(await e.arrayBuffer()),l=[],d=32768;for(let s=0;s<i.length;s+=d){const h=i.subarray(s,s+d);l.push(String.fromCharCode(...h))}return btoa(l.join(""))}function je(){return typeof window>"u"?null:window}function Ze(e){return!!(e&&typeof e=="object"&&"saved"in e)}const qe={getOutput:Te,getOutputTree:Pe,getOutputContent:De},ge=120,We=1200;function lt({taskId:e,api:i=qe,requestedFilePath:l=null,requestedFileRequestId:d=0}){var ne,ie,oe,le,de,ce,ue,he;const[s,h]=o.useState(null),[N,F]=o.useState([]),[p,Z]=o.useState({}),[S,D]=o.useState(new Set),[M,U]=o.useState(new Set),[b,P]=o.useState("."),[u,C]=o.useState(null),[Ne,v]=o.useState(!1),[j,y]=o.useState(""),[q,T]=o.useState([]),[W,_]=o.useState(!1),[ee,O]=o.useState(null),[H,z]=o.useState(!0),[te,f]=o.useState(null),re=o.useRef(null),K=o.useRef(null),m=((ne=s==null?void 0:s.summary)==null?void 0:ne.rootPath)??(s==null?void 0:s.effectiveProjectPath)??null,Q=j.trim(),w=Q.length>0,g=Ne||j.length>0,ae=o.useCallback(async()=>{f(null),z(!0),P("."),F([]),Z({}),D(new Set),U(new Set),C(null),v(!1),y(""),T([]),O(null),K.current=null;try{const a=await i.getOutput(e);if(h(a),!a.available){z(!1);return}const r=await i.getOutputTree(e,".");F(r.entries),z(!1)}catch(a){f(a instanceof Error?a.message:"Failed to load output"),z(!1)}},[i,e]);o.useEffect(()=>{ae()},[ae]);const R=o.useCallback(async a=>{const r=B(a,m);if(!r)return f("Invalid directory path"),[];if(p[r])return p[r];f(null),U(n=>new Set(n).add(r));try{const n=await i.getOutputTree(e,r);return Z(c=>({...c,[r]:n.entries})),n.entries}catch(n){return f(n instanceof Error?n.message:"Failed to load directory"),[]}finally{U(n=>{const c=new Set(n);return c.delete(r),c})}},[i,p,m,e]),$=o.useCallback(async a=>{const r=a.filter(n=>n!==".");if(r.length!==0){D(n=>{const c=new Set(n);for(const E of r)c.add(E);return c});for(const n of r)await R(n)}},[R]),X=o.useCallback(async a=>{const r=B(a,m);if(!r){f("Invalid directory path");return}v(!1),y(""),P(r),C(null),r!=="."&&await $(rt(r))},[$,m]),Se=o.useCallback(async a=>{const r=B(a,m);if(!r){f("Invalid directory path");return}if(P(r),C(null),S.has(r)){D(n=>{const c=new Set(n);return c.delete(r),c});return}D(n=>new Set(n).add(r)),await R(r)},[S,R,m]),A=o.useCallback(async a=>{const r=B(a,m);if(!r){f("Invalid file path");return}f(null);try{const n=Ae(r);v(!1),y(""),await $(Be(r));const c=await i.getOutputContent(e,r);P(n),C(c)}catch(n){f(n instanceof Error?n.message:"Failed to load file")}},[i,$,m,e]),Ce=o.useCallback(()=>{if(b===".")return;const a=b.split("/");a.pop();const r=a.length===0?".":a.join("/");X(r)},[b,X]);o.useEffect(()=>{if(!l||!(s!=null&&s.available)||H)return;const a=`${d}:${l}`;K.current!==a&&(K.current=a,y(""),A(l))},[H,A,s==null?void 0:s.available,l,d]),o.useEffect(()=>{var a;g&&((a=re.current)==null||a.focus())},[g]),o.useEffect(()=>{if(!w||!(s!=null&&s.available)){_(!1),T([]),O(null);return}let a=!1;async function r(){_(!0),O(null);const n=["."],c=new Set,E=[];let fe=0;try{for(;n.length>0&&fe<We&&E.length<ge;){const k=n.shift()??".";if(c.has(k))continue;c.add(k);const V=await i.getOutputTree(e,k);if(a)return;fe+=V.entries.length,E.push(...Ue(V.entries,Q));for(const G of V.entries)G.type==="directory"&&!c.has(G.path)&&n.push(G.path)}a||(T(E.slice(0,ge)),_(!1))}catch(k){a||(T([]),O(k instanceof Error?k.message:"Failed to search files"),_(!1))}}return r(),()=>{a=!0}},[i,Q,s==null?void 0:s.available,w,e]);const Ee=o.useMemo(()=>Le(N,p,S,M),[p,N,S,M]),J=w?q.map(a=>({entry:a,depth:Me(a.path),expanded:a.type==="directory"&&S.has(a.path),loading:a.type==="directory"&&M.has(a.path)})):Ee;if(H)return t.jsx(I,{tone:"muted",children:"Loading files..."});if(te)return t.jsx(I,{tone:"destructive",children:te});if(!(s!=null&&s.available))return t.jsx(I,{tone:"muted",children:"Task output is not available yet. The task may not have started."});const se=(((ie=s.summary)==null?void 0:ie.htmlEntries.length)??0)+(((le=(oe=s.summary)==null?void 0:oe.markdownEntries)==null?void 0:le.length)??0),Fe=w?`${q.length}${W?"+":""} matches`:`${((de=s.summary)==null?void 0:de.fileCount)??N.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",u&&"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(me,{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:((ce=s.summary)==null?void 0:ce.rootName)??"Artifacts"}),t.jsxs("div",{className:"text-[10px] leading-4 text-muted-foreground",children:[Fe,se>0&&` · ${se} previews`]})]}),t.jsx(L,{type:"button",variant:g?"secondary":"ghost",size:"icon","aria-expanded":g,"aria-label":g&&j.length===0?"Hide file search":"Search files",title:g&&j.length===0?"Hide file search":"Search files",className:"h-6 w-6 shrink-0 rounded-sm",onClick:()=>{g&&j.length===0?v(!1):v(!0)},children:t.jsx(xe,{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:[b!=="."&&t.jsx(L,{variant:"ghost",size:"icon",className:"h-5 w-5 rounded-sm",onClick:Ce,children:t.jsx(pe,{className:"h-3 w-3"})}),t.jsx("span",{className:"truncate font-mono text-[10px] leading-4 text-muted-foreground",children:b==="."?((ue=s.summary)==null?void 0:ue.rootPath)??((he=s.summary)==null?void 0:he.rootName)??"/":b})]}),g&&t.jsxs("div",{className:"mt-1 flex items-center gap-1 rounded-sm bg-muted/35 px-1.5 py-0",children:[t.jsx(xe,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),t.jsx("input",{ref:re,value:j,onChange:a=>y(a.target.value),onKeyDown:a=>{a.key==="Escape"&&(y(""),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:()=>{y(""),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(_e,{className:"h-3 w-3"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1",children:W&&J.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..."}):ee?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:ee}):J.length>0?t.jsx("div",{className:"space-y-0",children:J.map(a=>{const r=a.entry,n=(u==null?void 0:u.path)===r.path||!u&&r.type==="directory"&&b===r.path;return t.jsxs("button",{type:"button","aria-current":n?"page":void 0,style:{"--tree-depth":a.depth,paddingLeft:`${4+a.depth*11}px`},onClick:()=>{r.type==="directory"?w?X(r.path):Se(r.path):A(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",n?'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(Oe,{className:x("h-3 w-3 shrink-0 text-muted-foreground transition-transform",n&&"text-primary",a.expanded&&"rotate-90")}):t.jsx("span",{className:"h-3 w-3 shrink-0"}),r.type==="directory"?t.jsx(me,{className:x("h-3 w-3 shrink-0 text-muted-foreground group-hover:text-foreground",n&&"text-primary")}):t.jsx(Ke,{className:x("h-3 w-3 shrink-0 text-muted-foreground group-hover:text-foreground",n&&"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",n?"text-primary/75":"text-muted-foreground"),children:a.loading?"loading":tt(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",!u&&"hidden lg:flex"),children:u?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(L,{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:()=>C(null),children:t.jsx(pe,{className:"h-3 w-3"})}),t.jsx("div",{className:"min-w-0 truncate font-mono text-[10px] leading-5 text-muted-foreground",children:u.path})]}),u.downloadUrl&&t.jsx(Y,{href:u.downloadUrl,filePath:u.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(et,{content:u,rootPath:m,onOpenFile:A})})]}):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 et({content:e,rootPath:i,onOpenFile:l}){const d=e.downloadUrl;if(e.truncated&&!e.content)return t.jsx(ke,{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 s=e.content?`data:${e.mimeType};base64,${e.content}`:d;return s?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:s,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(ve,{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 s=e.content;try{s=JSON.stringify(JSON.parse(e.content),null,2)}catch{}return t.jsx(be,{content:s,truncated:e.truncated})}return e.kind==="markdown"?t.jsx(Re,{content:e.content,truncated:e.truncated,resolveFileLink:s=>He(s,i,{allowRootRelative:!0,baseFilePath:e.path}),onOpenFileLink:l}):e.kind==="text"||e.kind==="html"?t.jsx(be,{content:e.content,truncated:e.truncated}):t.jsx(ve,{content:e})}function be({content:e,truncated:i}){return t.jsxs("div",{className:"rounded-sm bg-background/55",children:[t.jsx($e,{content:e}),i&&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 ve({content:e}){return t.jsx(ke,{title:`${e.kind} file`,description:e.path,action:e.downloadUrl?t.jsx(Y,{href:e.downloadUrl,filePath:e.path}):void 0})}function Y({href:e,filePath:i,iconOnly:l=!1}){const d=o.useCallback(s=>{we()&&(s.preventDefault(),Ie({href:e,filePath:i}).catch(h=>{ze.error(h instanceof Error?h.message:"Failed to save file")}))},[i,e]);return t.jsx(L,{asChild:!0,variant:"ghost",size:l?"icon":"sm",className:x("rounded-sm text-primary shadow-none hover:bg-primary/10 hover:text-primary",l?"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":l?"Download file":void 0,title:l?"Download file":void 0,onClick:d,children:[t.jsx(Je,{className:"h-3.5 w-3.5"}),!l&&"Download"]})})}function ke({title:e,description:i,action:l}){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:i}),l&&t.jsx("div",{className:"mt-2.5 flex justify-center",children:l})]})})}function I({children:e,tone:i}){return t.jsx("div",{className:x("flex h-48 items-center justify-center text-[12px]",i==="muted"?"text-muted-foreground":"text-destructive"),children:e})}function tt(e){return e.type==="directory"?"dir":e.size===void 0?e.kind??"file":`${e.kind??"file"} · ${at(e.size)}`}function rt(e){if(e===".")return[];const i=e.split("/").filter(Boolean);return i.map((l,d)=>i.slice(0,d+1).join("/"))}function at(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}export{lt as FilesTab};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{c as p,r as h,j as e,b as s}from"./index-AgRF0fhH.js";import{G as f}from"./DashboardShared-BvjPqceV.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const b=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],y=p("code",b);/**
|
|
7
|
+
* @license lucide-react v1.7.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const j=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],w=p("eye",j);function M({content:r,truncated:n=!1,className:a,previewClassName:d,rawClassName:c,resolveFileLink:t,onOpenFileLink:o}){const[l,u]=h.useState(!1);return e.jsxs("div",{className:s("rounded-sm bg-background/55",a),children:[e.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-end bg-background/85 px-2 py-1 backdrop-blur supports-[backdrop-filter]:bg-background/70",children:e.jsxs("div",{className:"flex items-center gap-1 rounded-sm bg-muted/40 p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>u(!1),className:s("flex items-center gap-1 rounded-sm px-2 py-0.5 text-[10px] transition-colors",l?"text-muted-foreground hover:bg-background/45 hover:text-foreground":"bg-primary/10 font-medium text-primary"),children:[e.jsx(w,{className:"h-3 w-3"}),"Preview"]}),e.jsxs("button",{type:"button",onClick:()=>u(!0),className:s("flex items-center gap-1 rounded-sm px-2 py-0.5 text-[10px] transition-colors",l?"bg-primary/10 font-medium text-primary":"text-muted-foreground hover:bg-background/45 hover:text-foreground"),children:[e.jsx(y,{className:"h-3 w-3"}),"Raw"]})]})}),l?e.jsx(N,{content:r,className:c}):e.jsx("div",{className:s("prose prose-sm dark:prose-invert max-w-none px-4 py-3 text-foreground",d),children:e.jsx(f,{components:{a:({node:k,href:x,...i})=>{const m=o?(t==null?void 0:t(x))??null:null;return m?e.jsx("a",{...i,href:x,"data-task-file-link":m,onClick:g=>{g.preventDefault(),o==null||o(m)}}):e.jsx("a",{...i,href:x})}},children:r})}),n&&e.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 N({content:r,className:n}){const a=r.length===0?[""]:r.split(`
|
|
12
|
+
`),d=`${Math.max(2,String(a.length).length)+1}ch`;return e.jsx("div",{className:s("overflow-x-auto font-mono text-[11px] leading-5 text-foreground",n),children:e.jsx("div",{className:"min-w-full",children:a.map((c,t)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:"sticky left-0 shrink-0 select-none border-r border-border/40 bg-background/95 px-2 py-0 text-right tabular-nums text-muted-foreground/55",style:{width:d},children:t+1}),e.jsx("span",{className:"whitespace-pre-wrap break-all px-3 py-0",children:c||" "})]},t))})})}export{N as L,M};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as _,j as e,I as X,B as v,
|
|
1
|
+
import{c as _,j as e,I as X,B as v,bB as O,an as V,r as i,bC as Y,bA as Z,z as ee,A as se,E as re,bD as te,v as ne,C as ae}from"./index-AgRF0fhH.js";import{P as ie}from"./play-nM4_YhiZ.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,4 +13,4 @@ import{c as _,j as e,I as X,B as v,a$ as O,am as V,r as i,bB as Y,bA as Z,z as e
|
|
|
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 xe=[["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"}]],me=_("settings-2",xe),ue={getOutput:Z,createPreviewSession:Y};function we({taskId:s,api:n=ue,allowPortPreview:l=!0}){const[a,d]=i.useState(null),[t,m]=i.useState(null),[x,u]=i.useState(null),[h,f]=i.useState(""),[g,j]=i.useState(!1),[P,S]=i.useState(!0),[w,o]=i.useState(null),[K,T]=i.useState(!1),[$,p]=i.useState(!1),A=i.useCallback(async()=>{S(!0),o(null),d(null),m(null),u(null),p(!1);try{const r=await n.getOutput(s);d(r),S(!1)}catch(r){o(r instanceof Error?r.message:"Failed to load output"),S(!1)}},[n,s]);i.useEffect(()=>{A()},[A]);const N=i.useCallback(async r=>{o(null);try{const c=await n.createPreviewSession(s,r!=null&&r.path?{path:r.path}:void 0);m(c),j(!1),p(!1),r&&u(r)}catch(c){o(c instanceof Error?c.message:"Failed to create preview session")}},[n,s]),C=i.useCallback(async r=>{const c=r??Number.parseInt(h,10);if(!Number.isInteger(c)||c<1||c>65535){o("Enter a port between 1 and 65535");return}o(null);try{const M=await n.createPreviewSession(s,{port:c});m(M),u(null),f(String(c)),j(!0),p(!1)}catch(M){o(M instanceof Error?M.message:"Failed to create preview session")}},[n,h,s]),k=i.useMemo(()=>I(a),[a]);i.useEffect(()=>{if(g||!(a!=null&&a.available)||k.length===0||t&&t.kind!=="service")return;const r=x??k[0];r&&N(r)},[x,a,k,g,t,N]);const b=i.useCallback(()=>{if((t==null?void 0:t.kind)==="service"&&typeof t.port=="number"){C(t.port);return}m(null);const r=x??I(a)[0];r&&N(r)},[x,a,t,C,N]);if(i.useEffect(()=>{if(!t)return;const r=t.expiresAt-Date.now()-5e3;if(r<=0){b();return}const c=window.setTimeout(b,r);return()=>window.clearTimeout(c)},[b,t]),P)return e.jsx(E,{children:"Loading preview..."});const y=l&&g;if(w&&t&&!y)return e.jsx(E,{children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"text-sm text-destructive",children:w}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(v,{variant:"outline",size:"sm",onClick:b,className:"rounded-full",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),"Retry"]})})]})});const D=!!(a!=null&&a.available);if(!D&&!l)return e.jsx(E,{children:"Task output is not available yet."});if(!t)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(B,{session:null,serviceModeOpen:y,allowPortPreview:l,servicePort:h,previewEntries:k,activeEntry:x,filesMenuOpen:$,onRefresh:b,onFullscreen:()=>T(!0),onServiceModeToggle:()=>{p(!1),j(r=>!r)},onServicePortChange:f,onServiceStart:()=>void C(),onFileMenuToggle:()=>p(r=>!r),onEntrySelect:r=>{p(!1),N(r)}})}),y?e.jsx(q,{serviceSession:null,error:w}):e.jsx(E,{children:w?e.jsx("span",{className:"text-sm text-destructive",children:w}):D?k.length>0?"Starting preview session...":"No HTML or Markdown files were found in this task output.":"Task output is not available yet."})]});const R=J(t),Q=G(t),U=fe(t),z=t.kind==="service"?t:null,W=y?z:t,L=e.jsx("iframe",{src:t.previewUrl,className:"h-full w-full border-0",sandbox:U,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(B,{session:W,serviceModeOpen:y,allowPortPreview:l,servicePort:h,previewEntries:k,activeEntry:x,filesMenuOpen:$,onRefresh:b,onFullscreen:()=>T(!0),onServiceModeToggle:()=>{p(!1),j(r=>!r)},onServicePortChange:f,onServiceStart:()=>void C(),onFileMenuToggle:()=>p(r=>!r),onEntrySelect:r=>{p(!1),N(r)}})}),y?e.jsx(q,{serviceSession:z,error:w,children:z?L:null}):e.jsx("div",{className:"min-h-0 flex-1 p-2",children:e.jsx("div",{className:"h-full overflow-hidden rounded-2xl border border-border/60 bg-white shadow-sm",children:L})}),e.jsx(ee,{open:K,onOpenChange:T,children:e.jsxs(se,{className:"flex h-[95vh] max-w-[95vw] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs(re,{className:"sr-only",children:["Preview: ",R]}),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:R}),e.jsx("span",{className:"text-xs text-muted-foreground",children:F(t.expiresAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",onClick:b,title:"Refresh",children:e.jsx(O,{className:"h-3.5 w-3.5"})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:Q,target:"_blank",rel:"noopener noreferrer",children:e.jsx(V,{className:"h-3.5 w-3.5"})})}),e.jsx(te,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:"h-6 rounded-md px-2 text-[11px]",title:"Exit fullscreen",children:[e.jsx(de,{className:"h-3.5 w-3.5"}),"Exit fullscreen"]})})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx("iframe",{src:t.previewUrl,className:"h-full w-full border-0",sandbox:U,title:"Task Preview Fullscreen"})})]})})]})}function I(s){var a,d;const n=((a=s==null?void 0:s.summary)==null?void 0:a.htmlEntries)??[],l=((d=s==null?void 0:s.summary)==null?void 0:d.markdownEntries)??[];return[...n.map(t=>({...t,kind:"html"})),...l.map(t=>({...t,kind:"markdown"}))]}function he({entries:s,activeEntry:n,open:l,onToggle:a,onEntrySelect:d}){const t=s[0];if(!t)return null;const m=n??t,x=H(m);return e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-expanded":l,"aria-haspopup":"menu","aria-label":"Preview files",onClick:a,className:"flex h-6 max-w-[min(24rem,calc(100vw-7rem))] items-center gap-1.5 rounded-md px-1.5 text-left text-[12px] font-semibold text-foreground transition-colors hover:bg-background/70",children:[e.jsx("span",{className:"truncate",children:m.label}),e.jsx(ne,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),l&&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-lg border border-border/70 bg-popover/95 p-1 text-popover-foreground shadow-[0_20px_70px_-36px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:s.map(u=>{const h=H(u),f=h===x;return e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":f,onClick:()=>d(u),className:"flex w-full items-center gap-2 rounded-md 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:f?e.jsx(ae,{className:"h-3.5 w-3.5"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:u.label})]},h)})})]})}function H(s){return`${s.kind}:${s.path}`}function B({session:s,serviceModeOpen:n,allowPortPreview:l,servicePort:a,previewEntries:d=[],activeEntry:t=null,filesMenuOpen:m=!1,onRefresh:x,onFullscreen:u,onServiceModeToggle:h,onServicePortChange:f,onServiceStart:g,onFileMenuToggle:j,onEntrySelect:P}){const S=s?G(s):null,w=!n&&d.length>0&&j&&P;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:n&&f&&g?e.jsxs("form",{className:"flex min-w-0 items-center gap-1.5",onSubmit:o=>{o.preventDefault(),g()},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(X,{type:"number",min:1,max:65535,inputMode:"numeric",value:a??"",onChange:o=>f(o.target.value),placeholder:"12345","aria-label":"Service preview port",className:"h-6 w-20 rounded-md px-2 text-[11px]"})]}),e.jsxs(v,{type:"submit",variant:"outline",size:"sm",className:"h-6 rounded-md px-2 text-[11px]",children:[e.jsx(ie,{className:"h-3.5 w-3.5"}),"Run"]}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:F(s.expiresAt)})]}):e.jsxs(e.Fragment,{children:[w?e.jsx(he,{entries:d,activeEntry:t,open:m,onToggle:j,onEntrySelect:P}):e.jsx("span",{className:"truncate text-[12px] font-semibold text-foreground",children:s?J(s):"Preview"}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:F(s.expiresAt)})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",onClick:x,title:"Refresh",children:e.jsx(O,{className:"h-3.5 w-3.5"})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:S??s.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(V,{className:"h-3.5 w-3.5"})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",onClick:u,title:"Fullscreen",children:e.jsx(ce,{className:"h-3.5 w-3.5"})})]}),l&&e.jsxs(v,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:h,className:"h-6 shrink-0 rounded-md px-2 text-[11px]",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),"Advanced"]})]})]})}function q({serviceSession:s,error:n,children:l}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[n&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-xs text-destructive",children:n}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:s&&l?e.jsx("div",{className:"h-full overflow-hidden rounded-2xl border border-border/60 bg-white shadow-sm",children:l}):e.jsx(E,{children:"No service preview running."})})]})}function G(s){return s.openUrl??s.previewUrl}function fe(s){return s.kind==="service"?void 0:"allow-scripts allow-same-origin"}function J(s){if(s.kind==="service"&&typeof s.port=="number"){const n=s.entryPath?`/${s.entryPath.replace(/^\/+/,"")}`:"";return`127.0.0.1:${s.port}${n}`}return s.entryPath}function E({children:s}){return e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:s})}function F(s){const n=Math.max(0,Math.round((s-Date.now())/1e3));if(n<60)return`${n}s`;const l=Math.floor(n/60),a=n%60;return`${l}m ${a}s`}export{B as PreviewHeader,q as PreviewServicePanel,we as PreviewTab,fe as getPreviewIframeSandbox,G as getPreviewOpenUrl};
|
|
16
|
+
*/const xe=[["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"}]],me=_("settings-2",xe),ue={getOutput:Z,createPreviewSession:Y};function we({taskId:s,api:n=ue,allowPortPreview:l=!0}){const[a,d]=i.useState(null),[t,m]=i.useState(null),[x,u]=i.useState(null),[h,f]=i.useState(""),[g,b]=i.useState(!1),[P,S]=i.useState(!0),[w,o]=i.useState(null),[K,T]=i.useState(!1),[A,p]=i.useState(!1),$=i.useCallback(async()=>{S(!0),o(null),d(null),m(null),u(null),p(!1);try{const r=await n.getOutput(s);d(r),S(!1)}catch(r){o(r instanceof Error?r.message:"Failed to load output"),S(!1)}},[n,s]);i.useEffect(()=>{$()},[$]);const N=i.useCallback(async r=>{o(null);try{const c=await n.createPreviewSession(s,r!=null&&r.path?{path:r.path}:void 0);m(c),b(!1),p(!1),r&&u(r)}catch(c){o(c instanceof Error?c.message:"Failed to create preview session")}},[n,s]),C=i.useCallback(async r=>{const c=r??Number.parseInt(h,10);if(!Number.isInteger(c)||c<1||c>65535){o("Enter a port between 1 and 65535");return}o(null);try{const M=await n.createPreviewSession(s,{port:c});m(M),u(null),f(String(c)),b(!0),p(!1)}catch(M){o(M instanceof Error?M.message:"Failed to create preview session")}},[n,h,s]),k=i.useMemo(()=>I(a),[a]);i.useEffect(()=>{if(g||!(a!=null&&a.available)||k.length===0||t&&t.kind!=="service")return;const r=x??k[0];r&&N(r)},[x,a,k,g,t,N]);const j=i.useCallback(()=>{if((t==null?void 0:t.kind)==="service"&&typeof t.port=="number"){C(t.port);return}m(null);const r=x??I(a)[0];r&&N(r)},[x,a,t,C,N]);if(i.useEffect(()=>{if(!t)return;const r=t.expiresAt-Date.now()-5e3;if(r<=0){j();return}const c=window.setTimeout(j,r);return()=>window.clearTimeout(c)},[j,t]),P)return e.jsx(E,{children:"Loading preview..."});const y=l&&g;if(w&&t&&!y)return e.jsx(E,{children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"text-sm text-destructive",children:w}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(v,{variant:"outline",size:"sm",onClick:j,className:"rounded-full",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),"Retry"]})})]})});const D=!!(a!=null&&a.available);if(!D&&!l)return e.jsx(E,{children:"Task output is not available yet."});if(!t)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(B,{session:null,serviceModeOpen:y,allowPortPreview:l,servicePort:h,previewEntries:k,activeEntry:x,filesMenuOpen:A,onRefresh:j,onFullscreen:()=>T(!0),onServiceModeToggle:()=>{p(!1),b(r=>!r)},onServicePortChange:f,onServiceStart:()=>void C(),onFileMenuToggle:()=>p(r=>!r),onEntrySelect:r=>{p(!1),N(r)}})}),y?e.jsx(q,{serviceSession:null,error:w}):e.jsx(E,{children:w?e.jsx("span",{className:"text-sm text-destructive",children:w}):D?k.length>0?"Starting preview session...":"No HTML or Markdown files were found in this task output.":"Task output is not available yet."})]});const R=J(t),Q=G(t),U=fe(t),z=t.kind==="service"?t:null,W=y?z:t,L=e.jsx("iframe",{src:t.previewUrl,className:"h-full w-full border-0",sandbox:U,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(B,{session:W,serviceModeOpen:y,allowPortPreview:l,servicePort:h,previewEntries:k,activeEntry:x,filesMenuOpen:A,onRefresh:j,onFullscreen:()=>T(!0),onServiceModeToggle:()=>{p(!1),b(r=>!r)},onServicePortChange:f,onServiceStart:()=>void C(),onFileMenuToggle:()=>p(r=>!r),onEntrySelect:r=>{p(!1),N(r)}})}),y?e.jsx(q,{serviceSession:z,error:w,children:z?L:null}):e.jsx("div",{className:"min-h-0 flex-1 p-2",children:e.jsx("div",{className:"h-full overflow-hidden rounded-2xl border border-border/60 bg-white shadow-sm",children:L})}),e.jsx(ee,{open:K,onOpenChange:T,children:e.jsxs(se,{className:"flex h-[95vh] max-w-[95vw] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs(re,{className:"sr-only",children:["Preview: ",R]}),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:R}),e.jsx("span",{className:"text-xs text-muted-foreground",children:F(t.expiresAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",onClick:j,title:"Refresh",children:e.jsx(O,{className:"h-3.5 w-3.5"})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:Q,target:"_blank",rel:"noopener noreferrer",children:e.jsx(V,{className:"h-3.5 w-3.5"})})}),e.jsx(te,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:"h-6 rounded-md px-2 text-[11px]",title:"Exit fullscreen",children:[e.jsx(de,{className:"h-3.5 w-3.5"}),"Exit fullscreen"]})})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx("iframe",{src:t.previewUrl,className:"h-full w-full border-0",sandbox:U,title:"Task Preview Fullscreen"})})]})})]})}function I(s){var a,d;const n=((a=s==null?void 0:s.summary)==null?void 0:a.htmlEntries)??[],l=((d=s==null?void 0:s.summary)==null?void 0:d.markdownEntries)??[];return[...n.map(t=>({...t,kind:"html"})),...l.map(t=>({...t,kind:"markdown"}))]}function he({entries:s,activeEntry:n,open:l,onToggle:a,onEntrySelect:d}){const t=s[0];if(!t)return null;const m=n??t,x=H(m);return e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-expanded":l,"aria-haspopup":"menu","aria-label":"Preview files",onClick:a,className:"flex h-6 max-w-[min(24rem,calc(100vw-7rem))] items-center gap-1.5 rounded-md px-1.5 text-left text-[12px] font-semibold text-foreground transition-colors hover:bg-background/70",children:[e.jsx("span",{className:"truncate",children:m.label}),e.jsx(ne,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),l&&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-lg border border-border/70 bg-popover/95 p-1 text-popover-foreground shadow-[0_20px_70px_-36px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:s.map(u=>{const h=H(u),f=h===x;return e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":f,onClick:()=>d(u),className:"flex w-full items-center gap-2 rounded-md 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:f?e.jsx(ae,{className:"h-3.5 w-3.5"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:u.label})]},h)})})]})}function H(s){return`${s.kind}:${s.path}`}function B({session:s,serviceModeOpen:n,allowPortPreview:l,servicePort:a,previewEntries:d=[],activeEntry:t=null,filesMenuOpen:m=!1,onRefresh:x,onFullscreen:u,onServiceModeToggle:h,onServicePortChange:f,onServiceStart:g,onFileMenuToggle:b,onEntrySelect:P}){const S=s?G(s):null,w=!n&&d.length>0&&b&&P;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:n&&f&&g?e.jsxs("form",{className:"flex min-w-0 items-center gap-1.5",onSubmit:o=>{o.preventDefault(),g()},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(X,{type:"number",min:1,max:65535,inputMode:"numeric",value:a??"",onChange:o=>f(o.target.value),placeholder:"12345","aria-label":"Service preview port",className:"h-6 w-20 rounded-md px-2 text-[11px]"})]}),e.jsxs(v,{type:"submit",variant:"outline",size:"sm",className:"h-6 rounded-md px-2 text-[11px]",children:[e.jsx(ie,{className:"h-3.5 w-3.5"}),"Run"]}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:F(s.expiresAt)})]}):e.jsxs(e.Fragment,{children:[w?e.jsx(he,{entries:d,activeEntry:t,open:m,onToggle:b,onEntrySelect:P}):e.jsx("span",{className:"truncate text-[12px] font-semibold text-foreground",children:s?J(s):"Preview"}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:F(s.expiresAt)})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",onClick:x,title:"Refresh",children:e.jsx(O,{className:"h-3.5 w-3.5"})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:S??s.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(V,{className:"h-3.5 w-3.5"})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-md",onClick:u,title:"Fullscreen",children:e.jsx(ce,{className:"h-3.5 w-3.5"})})]}),l&&e.jsxs(v,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:h,className:"h-6 shrink-0 rounded-md px-2 text-[11px]",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),"Advanced"]})]})]})}function q({serviceSession:s,error:n,children:l}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[n&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-xs text-destructive",children:n}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:s&&l?e.jsx("div",{className:"h-full overflow-hidden rounded-2xl border border-border/60 bg-white shadow-sm",children:l}):e.jsx(E,{children:"No service preview running."})})]})}function G(s){return s.openUrl??s.previewUrl}function fe(s){return s.kind==="service"?void 0:"allow-scripts allow-same-origin"}function J(s){if(s.kind==="service"&&typeof s.port=="number"){const n=s.entryPath?`/${s.entryPath.replace(/^\/+/,"")}`:"";return`127.0.0.1:${s.port}${n}`}return s.entryPath}function E({children:s}){return e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:s})}function F(s){const n=Math.max(0,Math.round((s-Date.now())/1e3));if(n<60)return`${n}s`;const l=Math.floor(n/60),a=n%60;return`${l}m ${a}s`}export{B as PreviewHeader,q as PreviewServicePanel,we as PreviewTab,fe as getPreviewIframeSandbox,G as getPreviewOpenUrl};
|
package/dashboard/assets/{SharedConversationPage-Bq1VobyA.js → SharedConversationPage-aj_wfoD8.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-
|
|
2
|
-
import{c as N,b2 as k,r as s,j as e,bo as S,P as T,U as C,a8 as M,bp as P,bq as _,br as j,bs as E,bt as L,a3 as w,bu as A}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-Cg5PBMv6.js","assets/index-AgRF0fhH.js","assets/index-BYWN4SLt.css","assets/MarkdownPreviewFrame-B58EGPZX.js","assets/DashboardShared-BvjPqceV.js","assets/file-BDYM9RQo.js","assets/PreviewTab-CoN0CJR0.js","assets/play-nM4_YhiZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as N,b2 as k,r as s,j as e,bo as S,P as T,U as C,a8 as M,bp as P,bq as _,br as j,bs as E,bt as L,a3 as w,bu as A}from"./index-AgRF0fhH.js";import{u as I,v as O,q as z,p as F,h as R,L as q,C as D,T as v,m as U}from"./DashboardShared-BvjPqceV.js";/**
|
|
3
3
|
* @license lucide-react v1.7.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const V=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],B=N("message-square-text",V),G=s.lazy(async()=>({default:(await w(()=>import("./FilesTab-
|
|
7
|
+
*/const V=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],B=N("message-square-text",V),G=s.lazy(async()=>({default:(await w(()=>import("./FilesTab-Cg5PBMv6.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),H=s.lazy(async()=>({default:(await w(()=>import("./PreviewTab-CoN0CJR0.js"),__vite__mapDeps([6,1,2,7]))).PreviewTab})),W={getOutput:j,getOutputTree:_,getOutputContent:P},Z={getOutput:j,createPreviewSession:(t,r)=>A(t,typeof r=="string"?r:r==null?void 0:r.path)};function X(){const{shareId:t}=k(),[r,d]=s.useState(null),[o,n]=s.useState([]),[x,c]=s.useState(!0),[g,i]=s.useState(null),l=s.useRef(null);return s.useEffect(()=>{if(!t){d(null),n([]),i("Shared conversation not found"),c(!1);return}let u=!1;l.current=t,c(!0),i(null);const h=async a=>{try{const[m,f]=await Promise.all([E(t),L(t)]);if(u||l.current!==t)return;d(m),n(y=>a?f.logs:U(y,f.logs)),i(null)}catch(m){if(u||l.current!==t)return;a&&(d(null),n([]),i(m instanceof Error?m.message:"Failed to load shared conversation"))}finally{!u&&l.current===t&&a&&c(!1)}};h(!0);const p=window.setInterval(()=>{h(!1)},2500);return()=>{u=!0,window.clearInterval(p)}},[t]),e.jsx($,{conversation:r,logs:o,loading:x,error:g})}function $({conversation:t,logs:r,loading:d,error:o}){const[n,x]=s.useState("transcript"),[c,g]=s.useState(!1),i=s.useMemo(()=>{if(!t)return null;const a=I(t.payload.initialMessage);return a.length>0&&O(r,a)?null:a.length>0?z(a,new Date(t.createdAt).toISOString()):null},[t,r]),l=s.useMemo(()=>F([...i?[i]:[],...r]),[i,r]),u=s.useMemo(()=>R(l),[l]),h=(t==null?void 0:t.scope)==="filesPreview",p=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-3 rounded-lg border border-border/60 bg-background/60 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx(q,{className:"h-4 w-4 animate-spin"}),"Loading shared conversation..."]}),!d&&o&&e.jsxs("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-5 py-8 text-center text-destructive",children:[e.jsx("div",{className:"text-base font-semibold",children:"Shared conversation unavailable"}),e.jsx("div",{className:"mt-2 text-sm",children:o})]}),!d&&!o&&l.length===0&&e.jsxs("div",{className:"rounded-lg border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx(B,{className:"mx-auto h-6 w-6 text-muted-foreground"}),e.jsx("div",{className:"mt-3 text-sm font-medium text-foreground",children:"No transcript output yet"})]}),!d&&!o&&u.map(({event:a,subItems:m},f)=>e.jsx(D,{event:a,agent:t==null?void 0:t.agent,subItems:m,questionResponseDisabled:!0},`shared-${f}`))]})});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-3 px-3 py-3 sm:px-5 lg:px-6",children:[e.jsxs("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle hidden w-64 shrink-0 flex-col overflow-hidden rounded-xl px-4 py-5 lg:flex xl:w-72",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-border/70 bg-foreground text-xs font-semibold tracking-[0.24em] text-background shadow-sm",children:"M"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm 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-7 text-[11px] font-medium uppercase tracking-[0.28em] text-muted-foreground",children:"Shared conversation"}),t&&e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("h1",{className:"max-h-28 overflow-hidden break-words text-base 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(S,{status:t.status}),e.jsx(T,{priority:t.priority})]}),e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[e.jsxs("div",{children:["updated ",C(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:[c&&e.jsx("div",{className:"rounded-xl border border-border/70 bg-background/80 p-3 font-mono text-[11px] text-foreground shadow-sm",children:"npx -y meshy-node@latest start"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:"https://github.com/ai-microsoft/meshy",target:"_blank",rel:"noreferrer","aria-label":"Open Meshy on GitHub",className:"inline-flex h-9 w-9 items-center justify-center rounded-sm border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(J,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",onClick:()=>g(a=>!a),"aria-expanded":c,className:"inline-flex h-9 items-center gap-2 rounded-sm border border-border/70 bg-background/70 px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(M,{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-xl",children:[e.jsxs("header",{className:"shrink-0 border-b border-border/55 bg-card/28 px-4 py-3 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-sm border border-border/70 bg-foreground text-xs 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-base font-semibold text-foreground",children:(t==null?void 0:t.title)??"Shared conversation"})]})]}),h&&e.jsxs("div",{className:"mt-3 inline-flex h-auto rounded-sm bg-muted/70 p-0.5 text-muted-foreground",children:[e.jsx("button",{type:"button",onClick:()=>x("transcript"),className:b(n==="transcript"),children:"Transcript"}),e.jsx("button",{type:"button",onClick:()=>x("files"),className:b(n==="files"),children:"Files"}),e.jsx("button",{type:"button",onClick:()=>x("preview"),className:b(n==="preview"),children:"Preview"})]})]}),h&&t?e.jsxs(e.Fragment,{children:[n==="transcript"&&p,n==="files"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(v,{label:"Loading files..."}),children:e.jsx(G,{taskId:t.shareId,api:W})})}),n==="preview"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(v,{label:"Loading preview..."}),children:e.jsx(H,{taskId:t.shareId,api:Z,allowPortPreview:!1})})})]}):p]})]})]})}function b(t){return t?"inline-flex items-center justify-center whitespace-nowrap rounded-sm bg-background px-2.5 py-0.5 text-[11px] font-medium text-foreground shadow-sm":"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-2.5 py-0.5 text-[11px] font-medium transition-colors hover:text-foreground"}function J({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,$ as SharedConversationView};
|