@codeyam/codeyam-cli 0.1.0-bleeding-edge.8afd3ee → 0.1.0-staging.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/analyzer-template/.build-info.json +7 -7
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +107 -51
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +183 -36
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +0 -34
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/index.ts +0 -2
- package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getNextRoutePath.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getNextRoutePath.js +2 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getNextRoutePath.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getNextRoutePath.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getNextRoutePath.js +2 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getNextRoutePath.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/frameworks/getNextRoutePath.ts +2 -6
- package/analyzer-template/project/writeUniversalMocks.ts +2 -6
- package/background/src/lib/virtualized/project/writeUniversalMocks.js +2 -3
- package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +3 -4
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +5 -25
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/fileWatcher.js +5 -75
- package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +2 -3
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +0 -13
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +35 -15
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-GqWwt5wG.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-B0oiPem-.js → InteractivePreview-Dh-FldQK.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-p0fuyqGQ.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-BKKG1s2B.js → LogViewer-Dp6DC845.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DU_jxCPD.js → SafeScreenshot-xwuhwsZH.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioPreview-Bl2IRh55.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DmjXUj6m.js → ScenarioViewer-M2QuSHKC.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/_index-CAVtep9Q.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CLmzsLsT.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/chart-column-B2I7jQx2.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-alert-GwwOAbhw.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{components-Dj-Ggnl2.js → components-CAx5ONX_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CgyOwWip.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BbR3FwNc.js → dev.empty-DGy3zrli.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BHiWkb_W.js → entity._sha._-1Z6D0fLM.js} +7 -7
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-L7M9Vr5z.js → entity._sha_.create-scenario-ChAdTrrU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-C9w-q7P3.js → entity._sha_.edit._scenarioId-D9L7267w.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entityVersioning-Bk_YB1jM.js → entityVersioning-DO2gCvXv.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CdGoUs8A.js → entry.client-C6FRgjPr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-C3-cQjgv.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-Dp4EB9nv.js +12 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-Da3jt49-.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-DN7Vr40D.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-172a4629.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-COyVTsPq.js +16 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-CvyP_1Lo.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{settings-NU_ZquhK.js → settings-Hbf8b7J_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-MZc4XdmE.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-BMBi0VzO.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-Lumm1t01.js → useLastLogLine-BBlyqxij.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useToast-C_VxoXTh.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/zap-B4gsLUZQ.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/{index-DHr4rT4u.js → index-eAULANMV.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-lutv16q5.js +161 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/codeyam-setup-skill.md +18 -24
- package/package.json +1 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +107 -51
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +1 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +183 -36
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +0 -28
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/index.js +0 -2
- package/packages/analyze/src/lib/asts/sourceFiles/index.js.map +1 -1
- package/packages/utils/src/lib/frameworks/getNextRoutePath.js +2 -3
- package/packages/utils/src/lib/frameworks/getNextRoutePath.js.map +1 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +0 -238
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getDeclaredEntityNode.ts +0 -25
- package/codeyam-cli/scripts/apply-setup.js +0 -288
- package/codeyam-cli/scripts/apply-setup.js.map +0 -1
- package/codeyam-cli/scripts/extract-setup.js +0 -130
- package/codeyam-cli/scripts/extract-setup.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-rqv54FUY.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DqXXjAJ7.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioPreview-5DY-YIxu.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/_index-DvSrcxsk.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CsaMd9mb.js +0 -10
- package/codeyam-cli/src/webserver/build/client/assets/chart-column-VXBS6qOn.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/circle-alert-n5GUC2AS.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/clock-DKqtX8js.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/file-text-B6Er7j5k.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-KcDVw1FY.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-B9uZ8eSJ.js +0 -12
- package/codeyam-cli/src/webserver/build/client/assets/globals-B0f88RTV.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-v3c6DFp4.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-fca08d7e.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-Cf8VBqIb.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-DA14wXpu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-COJUrwGu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CNaMJ-nR.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useToast-BRShB17p.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/zap-BvukH0eN.js +0 -1
- package/codeyam-cli/src/webserver/build/client/favicon.svg +0 -13
- package/codeyam-cli/src/webserver/build/server/assets/server-build-Bi1mj14J.js +0 -166
- package/codeyam-cli/src/webserver/public/favicon.svg +0 -13
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +0 -191
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +0 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getDeclaredEntityNode.js +0 -16
- package/packages/analyze/src/lib/asts/sourceFiles/getDeclaredEntityNode.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{r as o,j as e,b as Z,L as ee}from"./components-
|
|
1
|
+
import{r as o,j as e,b as Z,L as ee}from"./components-CAx5ONX_.js";import{a as se,I as te}from"./InteractivePreview-Dh-FldQK.js";import{L as re}from"./LogViewer-Dp6DC845.js";import{S as ae}from"./SafeScreenshot-xwuhwsZH.js";import{u as ne}from"./useLastLogLine-BBlyqxij.js";function ie({presets:r,customSizes:x,currentWidth:l,currentHeight:n,scale:b,onSizeChange:v,onSaveCustomSize:u,onRemoveCustomSize:t,className:c=""}){const[a,d]=o.useState(!1),[m,I]=o.useState(String(l)),[k,N]=o.useState(String(n)),[h,p]=o.useState(!1),[f,y]=o.useState(!1),S=o.useRef(null);o.useEffect(()=>{h||I(String(l))},[l,h]),o.useEffect(()=>{f||N(String(n))},[n,f]),o.useEffect(()=>{const s=w=>{S.current&&!S.current.contains(w.target)&&d(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const P=o.useMemo(()=>{const s=r.find(g=>g.width===l&&g.height===n);if(s)return s.name;const w=x.find(g=>g.width===l&&g.height===n);return w?w.name:"Custom"},[r,x,l,n]),A=P==="Custom",M=s=>{v(s.width,s.height),d(!1)},E=s=>{const w=s.target.value;I(w);const g=parseInt(w,10);!isNaN(g)&&g>0&&v(g,n)},D=s=>{const w=s.target.value;N(w);const g=parseInt(w,10);!isNaN(g)&&g>0&&v(l,g)},B=()=>{p(!1);const s=parseInt(m,10);(isNaN(s)||s<=0)&&I(String(l))},C=()=>{y(!1);const s=parseInt(k,10);(isNaN(s)||s<=0)&&N(String(n))},$=s=>{(s.key==="Enter"||s.key==="Escape")&&s.target.blur()};return e.jsxs("div",{className:`flex items-center gap-3 ${c}`,children:[e.jsxs("div",{className:"relative",ref:S,children:[e.jsxs("button",{onClick:()=>d(!a),className:"flex items-center gap-2 px-3 py-1.5 bg-white border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-[#005c75] focus:ring-offset-1 min-w-[120px] justify-between",children:[e.jsx("span",{children:P}),e.jsx("svg",{className:`w-4 h-4 transition-transform ${a?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),a&&e.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-full bg-white border border-gray-200 rounded-md shadow-lg z-50",children:e.jsxs("div",{className:"py-1",children:[r.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-1 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"Presets"}),r.map(s=>e.jsxs("button",{onClick:()=>M(s),className:`w-full text-left px-3 py-2 text-sm hover:bg-gray-100 flex justify-between items-center gap-4 whitespace-nowrap ${P===s.name?"bg-[#f0f7f9] text-[#005c75]":"text-gray-700"}`,children:[e.jsx("span",{children:s.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:[s.width," x ",s.height]})]},s.name))]}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-gray-100 my-1"}),e.jsx("div",{className:"px-3 py-1 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"Custom"}),[...x].sort((s,w)=>s.width-w.width).map(s=>e.jsxs("div",{className:`flex items-center gap-1 hover:bg-gray-100 ${P===s.name?"bg-[#f0f7f9] text-[#005c75]":"text-gray-700"}`,children:[e.jsxs("button",{onClick:()=>M(s),className:"flex-1 text-left px-3 py-2 text-sm flex justify-between items-center gap-4 whitespace-nowrap cursor-pointer",children:[e.jsx("span",{children:s.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:[s.width," x ",s.height]})]}),t&&e.jsx("button",{onClick:w=>{w.stopPropagation(),P===s.name&&r.length>0&&v(r[0].width,r[0].height),t(s.name)},className:"p-1.5 mr-1 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded cursor-pointer transition-colors",title:"Remove custom size",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},s.name))]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"text",value:m,onChange:E,onFocus:()=>p(!0),onBlur:B,onKeyDown:$,className:"w-16 px-2 py-1 text-right border border-gray-300 rounded-l-md text-sm focus:outline-none focus:ring-2 focus:ring-[#005c75] focus:border-[#005c75]"}),e.jsx("span",{className:"px-2 py-1 bg-gray-100 border border-l-0 border-gray-300 rounded-r-md text-gray-500 text-sm",children:"px"})]}),e.jsx("span",{className:"text-gray-400 mx-1",children:"×"}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"text",value:k,onChange:D,onFocus:()=>y(!0),onBlur:C,onKeyDown:$,className:"w-16 px-2 py-1 text-right border border-gray-300 rounded-l-md text-sm focus:outline-none focus:ring-2 focus:ring-[#005c75] focus:border-[#005c75]"}),e.jsx("span",{className:"px-2 py-1 bg-gray-100 border border-l-0 border-gray-300 rounded-r-md text-gray-500 text-sm",children:"px"})]}),b!==void 0&&b<1&&e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(",Math.round(b*100),"%)"]})]}),A&&e.jsx("button",{onClick:u,className:"px-3 py-1.5 bg-[#005c75] text-white text-sm font-medium rounded-md hover:bg-[#004a5c] focus:outline-none focus:ring-2 focus:ring-[#005c75] focus:ring-offset-1 transition-colors",children:"Save Custom Size"})]})}function oe({scenario:r,analysis:x,entity:l}){const n=r.metadata?.executionResult||null,b=r.metadata?.data?.argumentsData||[],v=u=>{if(!u)return"No execution results available yet. Run the function to capture side effects including console output, file operations, and API calls.";const t=[],c=u.sideEffects?.consoleOutput||[];c.length>0&&(t.push(`Console Output: ${c.length} log ${c.length===1?"entry":"entries"} captured`),c.forEach(m=>{t.push(` [${m.level.toUpperCase()}] ${m.args.join(" ")}`)}));const a=u.sideEffects?.fileWrites||[];a.length>0&&(t.push(`
|
|
2
2
|
File System Operations: ${a.length} ${a.length===1?"operation":"operations"} detected`),a.forEach(m=>{t.push(` ${m.operation}: ${m.path}${m.size?` (${m.size} bytes)`:""}`)}));const d=u.sideEffects?.apiCalls||[];return d.length>0&&(t.push(`
|
|
3
3
|
API Calls: ${d.length} ${d.length===1?"call":"calls"} made`),d.forEach(m=>{t.push(` ${m.method} ${m.url}${m.status?` → ${m.status}`:""}${m.duration?` (${m.duration}ms)`:""}`)})),u.error&&t.push(`
|
|
4
4
|
Error: ${u.error.name||"Error"}: ${u.error.message}`),t.length===0?"No side effects detected. The function executed without console output, file operations, or API calls.":t.join(`
|
|
5
|
-
`)};return e.jsxs("div",{className:"flex w-full h-full gap-0",children:[e.jsxs("div",{className:"flex-1 border border-gray-200 bg-white rounded flex flex-col",children:[e.jsx("div",{className:"px-4 pt-3.5 pb-2.5",children:e.jsx("h3",{className:"text-[9px] font-semibold text-[#005c75] uppercase tracking-wide text-center m-0",children:"Input Data"})}),e.jsx("div",{className:"flex-1 overflow-auto px-4 pb-0",children:e.jsx("pre",{className:"text-xs font-mono text-gray-800 whitespace-pre-wrap break-words m-0",children:JSON.stringify(b,null,2)})})]}),e.jsxs("div",{className:"flex-1 border border-gray-200 bg-white rounded flex flex-col ml-[-1px]",children:[e.jsx("div",{className:"px-4 pt-3.5 pb-2.5",children:e.jsx("h3",{className:"text-[9px] font-semibold text-[#005c75] uppercase tracking-wide text-center m-0",children:"Returned Data"})}),e.jsx("div",{className:"flex-1 overflow-auto px-4 pb-0",children:n?e.jsx("pre",{className:"text-xs font-mono text-gray-800 whitespace-pre-wrap break-words m-0",children:n.returnValue!==void 0?JSON.stringify(n.returnValue,null,2):"undefined"}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:"No execution results yet"})})]}),e.jsxs("div",{className:"flex-1 border border-gray-200 bg-white rounded flex flex-col ml-[-1px]",children:[e.jsx("div",{className:"px-4 pt-3.5 pb-2.5",children:e.jsx("h3",{className:"text-[9px] font-semibold text-[#005c75] uppercase tracking-wide text-center m-0",children:"Side Effects"})}),e.jsx("div",{className:"flex-1 overflow-auto px-4 pb-4",children:e.jsx("p",{className:"text-sm text-gray-700 leading-[22px] m-0 whitespace-pre-wrap",children:v(n)})})]})]})}const W=10,le=1024;function ce({currentViewportWidth:r,currentPresetName:x,onDevicePresetClick:l,devicePresets:n}){const[b,v]=o.useState(null),u=o.useRef(null),t=o.useMemo(()=>[...n].sort((h,p)=>h.width-p.width),[n]),{fittingPresets:c,overflowPresets:a}=o.useMemo(()=>{const h=[],p=[];for(const f of t)f.width<=le?h.push(f):p.push(f);return p.sort((f,y)=>y.width-f.width),{fittingPresets:h,overflowPresets:p}},[t]),d=o.useCallback(h=>{if(!u.current)return null;const p=u.current.getBoundingClientRect(),f=h-p.left,y=p.width,S=y/2,A=(c.length>0?c[c.length-1].width:0)/2,M=S-A,E=S+A,D=a.length>0?(a.length-1)*W:0;if(a.length>0){if(f<M){if(f<=D){const C=Math.min(Math.floor(f/W),a.length-1);return a[C]}return a[a.length-1]}if(f>E){const C=y-f;if(C<=D){const $=Math.min(Math.floor(C/W),a.length-1);return a[$]}return a[a.length-1]}}const B=Math.abs(f-S);for(let C=c.length-1;C>=0;C--){const $=c[C],s=c[C-1],w=$.width/2,g=s?s.width/2:0;if(B<=w&&B>=g)return $}return c[0]||a[a.length-1]||null},[c,a]),m=o.useCallback(h=>{const p=d(h.clientX);v(p)},[d]),I=o.useCallback(()=>{v(null)},[]),k=o.useCallback(h=>{const p=d(h.clientX);p&&l(p)},[d,l]),N=b||{name:x,width:r};return e.jsxs("div",{ref:u,className:"relative h-6 bg-[#f6f9fc] shrink-0 overflow-hidden cursor-pointer",onMouseMove:m,onMouseLeave:I,onClick:k,children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx("div",{className:"h-full transition-all duration-100 bg-[rgba(0,92,117,0.15)]",style:{width:`${r}px`}})}),e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:c.map(h=>{const p=h.width===r,f=b?.name===h.name,y=h.width/2;return e.jsxs("div",{children:[e.jsx("div",{className:"absolute top-0 bottom-0",style:{left:`calc(50% - ${y}px)`},children:e.jsx("div",{className:`w-0.5 h-full transition-colors duration-75 ${p||f?"bg-[#005c75]":"bg-[rgba(0,92,117,0.25)]"}`})}),e.jsx("div",{className:"absolute top-0 bottom-0",style:{left:`calc(50% + ${y}px)`},children:e.jsx("div",{className:`w-0.5 h-full transition-colors duration-75 ${p||f?"bg-[#005c75]":"bg-[rgba(0,92,117,0.25)]"}`})})]},h.name)})}),e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:a.map((h,p)=>{const f=p*W,y=h.width===r,S=b?.name===h.name;return e.jsxs("div",{children:[e.jsx("div",{className:"absolute top-0 bottom-0",style:{left:`${f}px`},children:e.jsx("div",{className:`w-0.5 h-full transition-colors duration-75 ${y||S?"bg-[#005c75]":"bg-[rgba(0,92,117,0.25)]"}`})}),e.jsx("div",{className:"absolute top-0 bottom-0",style:{right:`${f}px`},children:e.jsx("div",{className:`w-0.5 h-full transition-colors duration-75 ${y||S?"bg-[#005c75]":"bg-[rgba(0,92,117,0.25)]"}`})})]},h.name)})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsxs("div",{className:`text-[10px] px-2 py-0.5 rounded shadow-sm whitespace-nowrap transition-colors ${b?"bg-[#005c75] text-white":"bg-white/90 text-[#005c75] border border-[rgba(0,92,117,0.25)]"}`,children:[N.name," - ",N.width,"px"]})})]})}function de({width:r,height:x,onSave:l,onCancel:n}){const[b,v]=o.useState(""),[u,t]=o.useState(""),c=()=>{const d=b.trim();if(!d){t("Please enter a name for this custom size");return}l(d)},a=d=>{d.key==="Enter"&&b.trim()&&c(),d.key==="Escape"&&n()};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-white rounded-lg max-w-md w-full p-6 shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Save Custom Size"}),e.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"mb-6 p-4 bg-gray-50 rounded-lg border border-gray-200",children:[e.jsx("div",{className:"text-sm text-gray-500 mb-1",children:"Dimensions"}),e.jsxs("div",{className:"text-lg font-medium text-gray-900",children:[r,"px × ",x,"px"]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"custom-size-name",className:"block text-sm font-medium text-gray-700 mb-2",children:"Name"}),e.jsx("input",{id:"custom-size-name",type:"text",value:b,onChange:d=>{v(d.target.value),t("")},onKeyDown:a,placeholder:"e.g., iPhone 15 Pro",className:`w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-[#005c75] focus:border-[#005c75] ${u?"border-red-300":"border-gray-300"}`,autoFocus:!0}),u&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:u})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:n,className:"px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-gray-300 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:c,disabled:!b.trim(),className:"px-4 py-2 bg-[#005c75] text-white text-sm font-medium rounded-md hover:bg-[#004a5c] focus:outline-none focus:ring-2 focus:ring-[#005c75] focus:ring-offset-1 transition-colors disabled:bg-gray-300 disabled:cursor-not-allowed",children:"Save"})]})]})})}function xe(r){const[x,l]=o.useState([]),n=r?`codeyam-custom-sizes-${r}`:null;o.useEffect(()=>{if(!n||typeof window>"u"){l([]);return}try{const t=localStorage.getItem(n);if(t){const c=JSON.parse(t);Array.isArray(c)&&l(c)}}catch(t){console.error("[useCustomSizes] Failed to load custom sizes:",t),l([])}},[n]);const b=o.useCallback(t=>{if(!(!n||typeof window>"u"))try{localStorage.setItem(n,JSON.stringify(t))}catch(c){console.error("[useCustomSizes] Failed to save custom sizes:",c)}},[n]),v=o.useCallback((t,c,a)=>{l(d=>{const m=d.findIndex(N=>N.name===t),I={name:t,width:c,height:a};let k;return m>=0?(k=[...d],k[m]=I):k=[...d,I],b(k),k})},[b]),u=o.useCallback(t=>{l(c=>{const a=c.filter(d=>d.name!==t);return b(a),a})},[b]);return{customSizes:x,addCustomSize:v,removeCustomSize:u}}const X=1440,_=[{name:"Mobile",width:375,height:667},{name:"Tablet",width:768,height:1024},{name:"Laptop",width:1024,height:768},{name:"Desktop",width:1440,height:900}];function ge({selectedScenario:r,analysis:x,entity:l,viewMode:n,cacheBuster:b,hasScenarios:v,isAnalyzing:u=!1,projectSlug:t,hasAnApiKey:c=!0}){const a=Z(),[d,m]=o.useState(!1),[I,k]=o.useState(!1),[N,h]=o.useState({name:"Desktop",width:X,height:900}),[p,f]=o.useState(X),[y,S]=o.useState(1),{customSizes:P,addCustomSize:A,removeCustomSize:M}=xe(t),E=o.useMemo(()=>[..._,...P],[P]),D=(i,j)=>{f(i);const O=E.find(z=>z.width===i&&z.height===j);h({name:O?.name||"Custom",width:i,height:j})},B=i=>{f(i.width),h({name:i.name,width:i.width,height:i.height})},C=i=>{A(i,N.width,N.height??900),k(!1),h(j=>({...j,name:i}))},$=(i,j)=>{f(i);const O=E.find(z=>z.width===i&&z.height===j);h(z=>({name:O?.name||"Custom",width:i,height:z.height}))},s=r?.metadata?.screenshotPaths?.[0],w=o.useMemo(()=>!r||!x?.status?.scenarios?null:x.status.scenarios.find(i=>i.name===r.name),[r,x?.status?.scenarios]),g=o.useMemo(()=>{const i=[];if(x?.status?.errors&&x.status.errors.length>0)for(const j of x.status.errors)i.push({source:`${j.phase} phase`,message:j.message,stack:j.stack});if(x?.status?.steps)for(const j of x.status.steps)j.error&&i.push({source:j.name,message:j.error,stack:j.errorStack});return i},[x?.status?.errors,x?.status?.steps]),L=w?.error||(r?.metadata?.error?"Error during capture":null),V=w?.errorStack,{interactiveServerUrl:K,isStarting:H,isLoading:J,showIframe:U,iframeKey:G,onIframeLoad:q}=se({analysisId:x?.id,scenarioId:r?.id,scenarioName:r?.name,projectSlug:t,enabled:n==="interactive"}),T=o.useMemo(()=>K||null,[K]),R=!u&&v&&r&&!r.metadata?.screenshotPaths?.[0]&&x?.status?.scenarios?.some(i=>i.name===r.name&&i.screenshotStartedAt&&!i.screenshotFinishedAt),{lastLine:F}=ne(t,u||n==="interactive"||R||!1);if(!r)return!v&&l?u?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-12 text-center bg-[#f6f9fc]",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 max-w-2xl",children:[e.jsx("div",{className:"w-12 h-12 mb-2",children:e.jsx("svg",{className:"animate-spin",viewBox:"0 0 50 50",children:e.jsx("circle",{cx:"25",cy:"25",r:"20",fill:"none",stroke:"#005c75",strokeWidth:"4",strokeDasharray:"31.4 31.4",strokeLinecap:"round"})})}),e.jsx("h2",{className:"text-2xl font-semibold text-[#005c75] leading-[30px] m-0 font-['IBM_Plex_Sans']",children:R?"Capturing screenshots...":"Analyzing..."}),e.jsx("p",{className:"text-xs text-[#8e8e8e] text-center leading-5 m-0 font-['IBM_Plex_Mono']",children:"This may take a few minutes."}),F&&e.jsx("p",{className:"text-xs font-mono text-[#005c75] text-center leading-5 m-0 max-w-xl",children:F}),t&&e.jsx("button",{onClick:()=>m(!0),className:"w-[148px] px-2.5 py-[5px] bg-[#005c75] text-white border-none rounded-sm text-xs font-medium cursor-pointer transition-colors hover:bg-[#004a5c] font-['IBM_Plex_Sans']",children:"View full logs"})]})}):g.length>0?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 bg-[#f6f9fc] overflow-auto",children:e.jsxs("div",{className:"bg-red-50 border-2 border-red-300 rounded-lg p-8 w-full max-w-4xl",children:[e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("span",{className:"text-red-500 text-4xl shrink-0",children:"⚠️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xl font-semibold text-red-800 m-0 mb-3",children:"Analysis Failed"}),e.jsx("p",{className:"text-sm text-red-700 m-0 mb-4",children:g.length===1?"An error occurred during analysis. No scenarios were generated.":`${g.length} errors occurred during analysis. No scenarios were generated.`}),g.map((i,j)=>e.jsxs("div",{className:"bg-white border border-red-200 rounded p-4 mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-xs font-semibold text-red-800 m-0 mb-2 uppercase tracking-wide",children:i.source}),e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("p",{className:"text-sm text-red-900 m-0 font-mono whitespace-pre-wrap wrap-break-word",children:i.message})}),i.stack&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-xs text-red-700 cursor-pointer hover:text-red-900 font-semibold",children:"View stack trace"}),e.jsx("div",{className:"mt-2 bg-red-50 border border-red-200 rounded p-3 max-h-[200px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-red-900 font-mono whitespace-pre-wrap wrap-break-word m-0",children:i.stack})})]})]},j))]})]}),l.filePath&&e.jsx("div",{className:"flex justify-center mt-4",children:e.jsx("button",{onClick:()=>{a.submit({entitySha:l.sha,filePath:l.filePath},{method:"post",action:"/api/analyze"})},disabled:a.state!=="idle",className:"h-[42px] px-6 py-2 bg-[#005c75] text-white border-none rounded-lg text-sm font-medium cursor-pointer transition-all hover:bg-[#004a5e] disabled:bg-gray-400 disabled:cursor-not-allowed",children:a.state!=="idle"?"Retrying...":"Retry Analysis"})})]})}):e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center bg-[#f6f9fc]",children:e.jsxs("div",{className:"max-w-[600px]",children:[e.jsx("h2",{className:"text-[28px] font-semibold text-[#343434] mb-4 m-0 leading-10",children:"No simulations yet"}),e.jsx("p",{className:"text-base font-normal text-[#3e3e3e] mb-8 leading-6 m-0",children:"Analyze the code to create simulations and create test scenarios automatically."}),l.filePath&&e.jsx("button",{onClick:()=>{a.submit({entitySha:l.sha,filePath:l.filePath},{method:"post",action:"/api/analyze"})},disabled:a.state!=="idle",className:"h-[54px] w-[183px] px-2.5 py-[5px] bg-[#005c75] text-white border-none rounded-lg text-base font-medium cursor-pointer transition-all hover:bg-[#004a5e] disabled:bg-gray-400 disabled:cursor-not-allowed",children:a.state!=="idle"?"Analyzing...":"Analyze"})]})}):e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center",children:e.jsx("p",{className:"text-base text-gray-500 m-0",children:"Select a scenario to view its screenshot"})});const Y=n==="screenshot"&&(s||L)||n==="interactive"&&(T||H)||n==="data",Q=(u||R)&&!s&&!L&&n==="screenshot";return e.jsxs(e.Fragment,{children:[e.jsx("main",{className:"flex-1 bg-[#f9f9f9] overflow-auto flex flex-col min-w-0",children:Q?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center bg-linear-to-br from-blue-50 to-indigo-50",children:e.jsxs("div",{className:"max-w-2xl w-full bg-white rounded-t-2xl shadow-xl p-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-24 h-24 bg-blue-100 rounded-full mb-6",children:e.jsx("span",{className:"text-5xl animate-spin",children:"⚙️"})}),e.jsx("h2",{className:"text-3xl font-bold text-gray-900 mb-4 m-0",children:R?`Capturing ${l?.name}`:`Analyzing ${l?.name}`}),e.jsx("p",{className:"text-base text-gray-600 leading-relaxed m-0 mb-2",children:R?`Taking screenshots for ${x?.scenarios?.length||0} scenario${x?.scenarios?.length!==1?"s":""}...`:`Generating simulations and scenarios for this ${l?.entityType} entity...`}),r&&e.jsxs("p",{className:"text-sm text-blue-600 font-semibold m-0",children:["Currently processing: ",r.name]})]}),F&&e.jsx("div",{className:"bg-[#f6f9fc] border-2 border-[#e1e1e1] rounded-lg p-6 mb-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-xl shrink-0",children:"📝"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-700 uppercase tracking-wide mb-2 m-0",children:"Current Progress"}),e.jsx("p",{className:"text-sm text-gray-900 font-mono wrap-break-word m-0",title:F,children:F})]})]})}),t&&e.jsx("button",{onClick:()=>m(!0),className:"px-6 py-3 bg-[#005c75] text-white border-none rounded-lg text-base font-semibold cursor-pointer transition-all hover:bg-[#004a5e] hover:shadow-lg",children:"📋 View Full Logs"}),e.jsx("p",{className:"text-xs text-gray-500 mt-8 m-0",children:"Screenshots will appear here as they are captured. This may take a few minutes."})]})}):Y?e.jsxs(e.Fragment,{children:[L&&!s&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 mx-5 mt-4 p-4 rounded-r max-h-[400px] overflow-auto",role:"alert",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 text-xl shrink-0","aria-hidden":"true",children:"⚠️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-red-800 m-0 mb-2",children:"Capture Error"}),e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("p",{className:"text-sm text-red-700 m-0 mb-2 font-mono whitespace-pre-wrap wrap-break-word",children:L})}),V&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-xs text-red-600 cursor-pointer hover:text-red-800 font-medium",children:"View stack trace"}),e.jsx("div",{className:"mt-2 p-3 bg-red-100 rounded max-h-[300px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-red-900 font-mono whitespace-pre-wrap wrap-break-word m-0",children:V})})]})]})]})}),n==="interactive"?e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[T&&e.jsx("div",{className:"bg-gray-50 border-b border-gray-200 px-6 py-3 shrink-0 flex justify-center",children:e.jsx(ie,{presets:[..._],customSizes:P,currentWidth:N.width,currentHeight:N.height??900,scale:y,onSizeChange:D,onSaveCustomSize:()=>k(!0),onRemoveCustomSize:M})}),T&&e.jsx("div",{className:"bg-[#f6f9fc] border-b border-[rgba(0,92,117,0.25)] flex justify-center",children:e.jsx("div",{style:{maxWidth:`${_[_.length-1].width}px`,width:"100%"},children:e.jsx(ce,{currentViewportWidth:p,currentPresetName:N.name,onDevicePresetClick:B,devicePresets:E})})}),e.jsx(te,{scenarioId:r.id,scenarioName:r.name,iframeUrl:T,isStarting:H,isLoading:J,showIframe:U,iframeKey:G,onIframeLoad:q,onScaleChange:S,onDimensionChange:$,projectSlug:t,defaultWidth:N.width,defaultHeight:N.height})]}):n==="data"?e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(oe,{scenario:r,analysis:x,entity:l})}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsx("div",{className:"flex-1 p-6 flex items-center justify-center",children:e.jsx("div",{className:"transition-all duration-300",style:{maxWidth:`${p}px`},children:(s||!L)&&e.jsx(ae,{screenshotPath:s,cacheBuster:b,alt:r.name,className:"w-full rounded-lg shadow-[0_10px_25px_rgba(0,0,0,0.1)] bg-white"})})})})]}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 overflow-auto w-full",children:u&&!s?e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"bg-blue-50 border-2 border-blue-200 rounded-lg p-8",children:e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("span",{className:"animate-spin text-4xl shrink-0",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-xl font-semibold text-blue-900 m-0 mb-3",children:"Capturing Screenshot"}),e.jsxs("p",{className:"text-sm text-blue-800 m-0 mb-4",children:["Analysis is in progress for"," ",e.jsx("strong",{children:r.name}),". The screenshot will appear here once capture is complete."]}),F&&e.jsxs("div",{className:"bg-white border border-blue-200 rounded p-4 mt-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-blue-800 m-0 mb-2 uppercase tracking-wide",children:"Current Progress"}),e.jsx("p",{className:"text-sm text-blue-900 m-0 font-mono wrap-break-word",children:F})]}),t&&e.jsx("button",{onClick:()=>m(!0),className:"mt-4 px-4 py-2 bg-[#005c75] text-white border-none rounded-md text-sm font-semibold cursor-pointer transition-colors hover:bg-[#004a5e]",children:"📋 View Full Logs"})]})]})})}):L?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center overflow-auto gap-6",children:[!c&&e.jsx("div",{className:"bg-blue-50 border-2 border-blue-300 rounded-lg p-8",children:e.jsxs("div",{className:"flex-1 flex flex-col gap-4 items-center justify-center",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"text-blue-600 text-2xl shrink-0",children:"🔑"}),e.jsx("h3",{className:"text-xl font-semibold text-blue-900 m-0 mb-3",children:"Improve Analysis Quality with an API Key"})]}),e.jsxs("div",{className:"bg-white border border-blue-200 rounded p-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-blue-900 m-0 mb-2 uppercase tracking-wide",children:"CodeYam requires an AI API key for reliable analysis."}),e.jsxs("ul",{className:"text-sm text-blue-800 m-0 space-y-1 pl-5 list-disc",children:[e.jsx("li",{children:"You can use API keys for a variety of models"}),e.jsx("li",{children:"Faster analysis processing"}),e.jsx("li",{children:"Better handling of complex code structures"}),e.jsx("li",{children:"Improved scenario generation quality"})]})]}),e.jsx(ee,{to:"/settings",className:"inline-block px-4 py-2 bg-blue-600 text-white border-none rounded-md text-sm font-semibold cursor-pointer transition-colors hover:bg-blue-700",children:"🔐 Configure API Keys"})]})}),e.jsx("div",{className:"bg-red-50 border-2 border-red-300 rounded-lg p-8 w-full max-w-4xl my-auto",children:e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("span",{className:"text-red-500 text-4xl shrink-0",children:"⚠️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xl font-semibold text-red-800 m-0 mb-3",children:"Capture Failed"}),e.jsx("p",{className:"text-sm text-red-700 m-0 mb-4",children:"An error occurred while capturing this scenario. No screenshot is available."}),e.jsxs("div",{className:"bg-white border border-red-200 rounded p-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-red-800 m-0 mb-2 uppercase tracking-wide",children:"Error Message"}),e.jsx("div",{className:"max-h-[300px] overflow-auto",children:e.jsx("p",{className:"text-sm text-red-900 m-0 font-mono whitespace-pre-wrap wrap-break-word",children:L})})]}),V&&e.jsxs("details",{className:"mt-4",children:[e.jsx("summary",{className:"text-sm text-red-700 cursor-pointer hover:text-red-900 font-semibold",children:"📋 View full stack trace"}),e.jsx("div",{className:"mt-3 bg-white border border-red-200 rounded p-4 max-h-[400px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-red-900 font-mono whitespace-pre-wrap wrap-break-word m-0",children:V})})]})]})]})})]}):g.length>0?e.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-auto",children:e.jsx("div",{className:"bg-red-50 border-2 border-red-300 rounded-lg p-8 w-full max-w-4xl my-auto",children:e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("span",{className:"text-red-500 text-4xl shrink-0",children:"⚠️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xl font-semibold text-red-800 m-0 mb-3",children:"Analysis Error"}),e.jsx("p",{className:"text-sm text-red-700 m-0 mb-4",children:g.length===1?"An error occurred during analysis. Screenshot capture was not completed.":`${g.length} errors occurred during analysis. Screenshot capture was not completed.`}),g.map((i,j)=>e.jsxs("div",{className:"bg-white border border-red-200 rounded p-4 mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-xs font-semibold text-red-800 m-0 mb-2 uppercase tracking-wide",children:i.source}),e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("p",{className:"text-sm text-red-900 m-0 font-mono whitespace-pre-wrap wrap-break-word",children:i.message})}),i.stack&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-xs text-red-700 cursor-pointer hover:text-red-900 font-semibold",children:"View stack trace"}),e.jsx("div",{className:"mt-2 bg-red-50 border border-red-200 rounded p-3 max-h-[200px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-red-900 font-mono whitespace-pre-wrap wrap-break-word m-0",children:i.stack})})]})]},j))]})]})})}):e.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[e.jsx("span",{className:"text-6xl text-gray-300",children:"📷"}),e.jsx("p",{className:"text-lg text-gray-500 m-0",children:"No screenshot available for this scenario"}),e.jsx("p",{className:"text-sm text-gray-400 m-0",children:"Try recapturing or debugging this scenario"})]})})})}),d&&t&&e.jsx(re,{projectSlug:t,onClose:()=>m(!1)}),I&&e.jsx(de,{width:N.width,height:N.height??900,onSave:C,onCancel:()=>k(!1)})]})}export{ge as S};
|
|
5
|
+
`)};return e.jsxs("div",{className:"flex w-full h-full gap-0",children:[e.jsxs("div",{className:"flex-1 border border-gray-200 bg-white rounded flex flex-col",children:[e.jsx("div",{className:"px-4 pt-3.5 pb-2.5",children:e.jsx("h3",{className:"text-[9px] font-semibold text-[#005c75] uppercase tracking-wide text-center m-0",children:"Input Data"})}),e.jsx("div",{className:"flex-1 overflow-auto px-4 pb-0",children:e.jsx("pre",{className:"text-xs font-mono text-gray-800 whitespace-pre-wrap break-words m-0",children:JSON.stringify(b,null,2)})})]}),e.jsxs("div",{className:"flex-1 border border-gray-200 bg-white rounded flex flex-col ml-[-1px]",children:[e.jsx("div",{className:"px-4 pt-3.5 pb-2.5",children:e.jsx("h3",{className:"text-[9px] font-semibold text-[#005c75] uppercase tracking-wide text-center m-0",children:"Returned Data"})}),e.jsx("div",{className:"flex-1 overflow-auto px-4 pb-0",children:n?e.jsx("pre",{className:"text-xs font-mono text-gray-800 whitespace-pre-wrap break-words m-0",children:n.returnValue!==void 0?JSON.stringify(n.returnValue,null,2):"undefined"}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:"No execution results yet"})})]}),e.jsxs("div",{className:"flex-1 border border-gray-200 bg-white rounded flex flex-col ml-[-1px]",children:[e.jsx("div",{className:"px-4 pt-3.5 pb-2.5",children:e.jsx("h3",{className:"text-[9px] font-semibold text-[#005c75] uppercase tracking-wide text-center m-0",children:"Side Effects"})}),e.jsx("div",{className:"flex-1 overflow-auto px-4 pb-4",children:e.jsx("p",{className:"text-sm text-gray-700 leading-[22px] m-0 whitespace-pre-wrap",children:v(n)})})]})]})}const W=10,le=1024;function ce({currentViewportWidth:r,currentPresetName:x,onDevicePresetClick:l,devicePresets:n}){const[b,v]=o.useState(null),u=o.useRef(null),t=o.useMemo(()=>[...n].sort((h,p)=>h.width-p.width),[n]),{fittingPresets:c,overflowPresets:a}=o.useMemo(()=>{const h=[],p=[];for(const f of t)f.width<=le?h.push(f):p.push(f);return p.sort((f,y)=>y.width-f.width),{fittingPresets:h,overflowPresets:p}},[t]),d=o.useCallback(h=>{if(!u.current)return null;const p=u.current.getBoundingClientRect(),f=h-p.left,y=p.width,S=y/2,A=(c.length>0?c[c.length-1].width:0)/2,M=S-A,E=S+A,D=a.length>0?(a.length-1)*W:0;if(a.length>0){if(f<M){if(f<=D){const C=Math.min(Math.floor(f/W),a.length-1);return a[C]}return a[a.length-1]}if(f>E){const C=y-f;if(C<=D){const $=Math.min(Math.floor(C/W),a.length-1);return a[$]}return a[a.length-1]}}const B=Math.abs(f-S);for(let C=c.length-1;C>=0;C--){const $=c[C],s=c[C-1],w=$.width/2,g=s?s.width/2:0;if(B<=w&&B>=g)return $}return c[0]||a[a.length-1]||null},[c,a]),m=o.useCallback(h=>{const p=d(h.clientX);v(p)},[d]),I=o.useCallback(()=>{v(null)},[]),k=o.useCallback(h=>{const p=d(h.clientX);p&&l(p)},[d,l]),N=b||{name:x,width:r};return e.jsxs("div",{ref:u,className:"relative h-6 bg-[#f6f9fc] shrink-0 overflow-hidden cursor-pointer",onMouseMove:m,onMouseLeave:I,onClick:k,children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx("div",{className:"h-full transition-all duration-100 bg-[rgba(0,92,117,0.15)]",style:{width:`${r}px`}})}),e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:c.map(h=>{const p=h.width===r,f=b?.name===h.name,y=h.width/2;return e.jsxs("div",{children:[e.jsx("div",{className:"absolute top-0 bottom-0",style:{left:`calc(50% - ${y}px)`},children:e.jsx("div",{className:`w-0.5 h-full transition-colors duration-75 ${p||f?"bg-[#005c75]":"bg-[rgba(0,92,117,0.25)]"}`})}),e.jsx("div",{className:"absolute top-0 bottom-0",style:{left:`calc(50% + ${y}px)`},children:e.jsx("div",{className:`w-0.5 h-full transition-colors duration-75 ${p||f?"bg-[#005c75]":"bg-[rgba(0,92,117,0.25)]"}`})})]},h.name)})}),e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:a.map((h,p)=>{const f=p*W,y=h.width===r,S=b?.name===h.name;return e.jsxs("div",{children:[e.jsx("div",{className:"absolute top-0 bottom-0",style:{left:`${f}px`},children:e.jsx("div",{className:`w-0.5 h-full transition-colors duration-75 ${y||S?"bg-[#005c75]":"bg-[rgba(0,92,117,0.25)]"}`})}),e.jsx("div",{className:"absolute top-0 bottom-0",style:{right:`${f}px`},children:e.jsx("div",{className:`w-0.5 h-full transition-colors duration-75 ${y||S?"bg-[#005c75]":"bg-[rgba(0,92,117,0.25)]"}`})})]},h.name)})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsxs("div",{className:`text-[10px] px-2 py-0.5 rounded shadow-sm whitespace-nowrap transition-colors ${b?"bg-[#005c75] text-white":"bg-white/90 text-[#005c75] border border-[rgba(0,92,117,0.25)]"}`,children:[N.name," - ",N.width,"px"]})})]})}function de({width:r,height:x,onSave:l,onCancel:n}){const[b,v]=o.useState(""),[u,t]=o.useState(""),c=()=>{const d=b.trim();if(!d){t("Please enter a name for this custom size");return}l(d)},a=d=>{d.key==="Enter"&&b.trim()&&c(),d.key==="Escape"&&n()};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-white rounded-lg max-w-md w-full p-6 shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Save Custom Size"}),e.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"mb-6 p-4 bg-gray-50 rounded-lg border border-gray-200",children:[e.jsx("div",{className:"text-sm text-gray-500 mb-1",children:"Dimensions"}),e.jsxs("div",{className:"text-lg font-medium text-gray-900",children:[r,"px × ",x,"px"]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"custom-size-name",className:"block text-sm font-medium text-gray-700 mb-2",children:"Name"}),e.jsx("input",{id:"custom-size-name",type:"text",value:b,onChange:d=>{v(d.target.value),t("")},onKeyDown:a,placeholder:"e.g., iPhone 15 Pro",className:`w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-[#005c75] focus:border-[#005c75] ${u?"border-red-300":"border-gray-300"}`,autoFocus:!0}),u&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:u})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:n,className:"px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-gray-300 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:c,disabled:!b.trim(),className:"px-4 py-2 bg-[#005c75] text-white text-sm font-medium rounded-md hover:bg-[#004a5c] focus:outline-none focus:ring-2 focus:ring-[#005c75] focus:ring-offset-1 transition-colors disabled:bg-gray-300 disabled:cursor-not-allowed",children:"Save"})]})]})})}function xe(r){const[x,l]=o.useState([]),n=r?`codeyam-custom-sizes-${r}`:null;o.useEffect(()=>{if(!n||typeof window>"u"){l([]);return}try{const t=localStorage.getItem(n);if(t){const c=JSON.parse(t);Array.isArray(c)&&l(c)}}catch(t){console.error("[useCustomSizes] Failed to load custom sizes:",t),l([])}},[n]);const b=o.useCallback(t=>{if(!(!n||typeof window>"u"))try{localStorage.setItem(n,JSON.stringify(t))}catch(c){console.error("[useCustomSizes] Failed to save custom sizes:",c)}},[n]),v=o.useCallback((t,c,a)=>{l(d=>{const m=d.findIndex(N=>N.name===t),I={name:t,width:c,height:a};let k;return m>=0?(k=[...d],k[m]=I):k=[...d,I],b(k),k})},[b]),u=o.useCallback(t=>{l(c=>{const a=c.filter(d=>d.name!==t);return b(a),a})},[b]);return{customSizes:x,addCustomSize:v,removeCustomSize:u}}const X=1440,_=[{name:"Mobile",width:375,height:667},{name:"Tablet",width:768,height:1024},{name:"Laptop",width:1024,height:768},{name:"Desktop",width:1440,height:900}];function ge({selectedScenario:r,analysis:x,entity:l,viewMode:n,cacheBuster:b,hasScenarios:v,isAnalyzing:u=!1,projectSlug:t,hasAnApiKey:c=!0}){const a=Z(),[d,m]=o.useState(!1),[I,k]=o.useState(!1),[N,h]=o.useState({name:"Desktop",width:X,height:900}),[p,f]=o.useState(X),[y,S]=o.useState(1),{customSizes:P,addCustomSize:A,removeCustomSize:M}=xe(t),E=o.useMemo(()=>[..._,...P],[P]),D=(i,j)=>{f(i);const O=E.find(z=>z.width===i&&z.height===j);h({name:O?.name||"Custom",width:i,height:j})},B=i=>{f(i.width),h({name:i.name,width:i.width,height:i.height})},C=i=>{A(i,N.width,N.height??900),k(!1),h(j=>({...j,name:i}))},$=(i,j)=>{f(i);const O=E.find(z=>z.width===i&&z.height===j);h(z=>({name:O?.name||"Custom",width:i,height:z.height}))},s=r?.metadata?.screenshotPaths?.[0],w=o.useMemo(()=>!r||!x?.status?.scenarios?null:x.status.scenarios.find(i=>i.name===r.name),[r,x?.status?.scenarios]),g=o.useMemo(()=>{const i=[];if(x?.status?.errors&&x.status.errors.length>0)for(const j of x.status.errors)i.push({source:`${j.phase} phase`,message:j.message,stack:j.stack});if(x?.status?.steps)for(const j of x.status.steps)j.error&&i.push({source:j.name,message:j.error,stack:j.errorStack});return i},[x?.status?.errors,x?.status?.steps]),L=w?.error||(r?.metadata?.error?"Error during capture":null),V=w?.errorStack,{interactiveServerUrl:K,isStarting:H,isLoading:J,showIframe:U,iframeKey:G,onIframeLoad:q}=se({analysisId:x?.id,scenarioId:r?.id,scenarioName:r?.name,projectSlug:t,enabled:n==="interactive"}),T=o.useMemo(()=>K||null,[K]),R=!u&&v&&r&&!r.metadata?.screenshotPaths?.[0]&&x?.status?.scenarios?.some(i=>i.name===r.name&&i.screenshotStartedAt&&!i.screenshotFinishedAt),{lastLine:F}=ne(t,u||n==="interactive"||R||!1);if(!r)return!v&&l?u?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-12 text-center bg-[#f6f9fc]",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 max-w-2xl",children:[e.jsx("div",{className:"w-12 h-12 mb-2",children:e.jsx("svg",{className:"animate-spin",viewBox:"0 0 50 50",children:e.jsx("circle",{cx:"25",cy:"25",r:"20",fill:"none",stroke:"#005c75",strokeWidth:"4",strokeDasharray:"31.4 31.4",strokeLinecap:"round"})})}),e.jsx("h2",{className:"text-2xl font-semibold text-[#005c75] leading-[30px] m-0 font-['IBM_Plex_Sans']",children:R?"Capturing screenshots...":"Analyzing..."}),e.jsx("p",{className:"text-xs text-[#8e8e8e] text-center leading-5 m-0 font-['IBM_Plex_Mono']",children:"This may take a few minutes."}),F&&e.jsx("p",{className:"text-xs font-mono text-[#005c75] text-center leading-5 m-0 max-w-xl",children:F}),t&&e.jsx("button",{onClick:()=>m(!0),className:"w-[148px] px-2.5 py-[5px] bg-[#005c75] text-white border-none rounded-sm text-xs font-medium cursor-pointer transition-colors hover:bg-[#004a5c] font-['IBM_Plex_Sans']",children:"View full logs"})]})}):g.length>0?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 bg-[#f6f9fc] overflow-auto",children:e.jsxs("div",{className:"bg-red-50 border-2 border-red-300 rounded-lg p-8 w-full max-w-4xl",children:[e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("span",{className:"text-red-500 text-4xl shrink-0",children:"⚠️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xl font-semibold text-red-800 m-0 mb-3",children:"Analysis Failed"}),e.jsx("p",{className:"text-sm text-red-700 m-0 mb-4",children:g.length===1?"An error occurred during analysis. No scenarios were generated.":`${g.length} errors occurred during analysis. No scenarios were generated.`}),g.map((i,j)=>e.jsxs("div",{className:"bg-white border border-red-200 rounded p-4 mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-xs font-semibold text-red-800 m-0 mb-2 uppercase tracking-wide",children:i.source}),e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("p",{className:"text-sm text-red-900 m-0 font-mono whitespace-pre-wrap wrap-break-word",children:i.message})}),i.stack&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-xs text-red-700 cursor-pointer hover:text-red-900 font-semibold",children:"View stack trace"}),e.jsx("div",{className:"mt-2 bg-red-50 border border-red-200 rounded p-3 max-h-[200px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-red-900 font-mono whitespace-pre-wrap wrap-break-word m-0",children:i.stack})})]})]},j))]})]}),l.filePath&&e.jsx("div",{className:"flex justify-center mt-4",children:e.jsx("button",{onClick:()=>{a.submit({entitySha:l.sha,filePath:l.filePath},{method:"post",action:"/api/analyze"})},disabled:a.state!=="idle",className:"h-[42px] px-6 py-2 bg-[#005c75] text-white border-none rounded-lg text-sm font-medium cursor-pointer transition-all hover:bg-[#004a5e] disabled:bg-gray-400 disabled:cursor-not-allowed",children:a.state!=="idle"?"Retrying...":"Retry Analysis"})})]})}):e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center bg-[#f6f9fc]",children:e.jsxs("div",{className:"max-w-[600px]",children:[e.jsx("h2",{className:"text-[28px] font-semibold text-[#343434] mb-4 m-0 leading-10",children:"No simulations yet"}),e.jsx("p",{className:"text-base font-normal text-[#3e3e3e] mb-8 leading-6 m-0",children:"Analyze the code to create simulations and create test scenarios automatically."}),l.filePath&&e.jsx("button",{onClick:()=>{a.submit({entitySha:l.sha,filePath:l.filePath},{method:"post",action:"/api/analyze"})},disabled:a.state!=="idle",className:"h-[54px] w-[183px] px-2.5 py-[5px] bg-[#005c75] text-white border-none rounded-lg text-base font-medium cursor-pointer transition-all hover:bg-[#004a5e] disabled:bg-gray-400 disabled:cursor-not-allowed",children:a.state!=="idle"?"Analyzing...":"Analyze"})]})}):e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center",children:e.jsx("p",{className:"text-base text-gray-500 m-0",children:"Select a scenario to view its screenshot"})});const Y=n==="screenshot"&&(s||L)||n==="interactive"&&(T||H)||n==="data",Q=(u||R)&&!s&&!L&&n==="screenshot";return e.jsxs(e.Fragment,{children:[e.jsx("main",{className:"flex-1 bg-[#f9f9f9] overflow-auto flex flex-col min-w-0",children:Q?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center bg-linear-to-br from-blue-50 to-indigo-50",children:e.jsxs("div",{className:"max-w-2xl w-full bg-white rounded-2xl shadow-xl p-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-24 h-24 bg-blue-100 rounded-full mb-6",children:e.jsx("span",{className:"text-5xl animate-spin",children:"⚙️"})}),e.jsx("h2",{className:"text-3xl font-bold text-gray-900 mb-4 m-0",children:R?`Capturing ${l?.name}`:`Analyzing ${l?.name}`}),e.jsx("p",{className:"text-base text-gray-600 leading-relaxed m-0 mb-2",children:R?`Taking screenshots for ${x?.scenarios?.length||0} scenario${x?.scenarios?.length!==1?"s":""}...`:`Generating simulations and scenarios for this ${l?.entityType} entity...`}),r&&e.jsxs("p",{className:"text-sm text-blue-600 font-semibold m-0",children:["Currently processing: ",r.name]})]}),F&&e.jsx("div",{className:"bg-[#f6f9fc] border-2 border-[#e1e1e1] rounded-lg p-6 mb-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-xl shrink-0",children:"📝"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-700 uppercase tracking-wide mb-2 m-0",children:"Current Progress"}),e.jsx("p",{className:"text-sm text-gray-900 font-mono wrap-break-word m-0",title:F,children:F})]})]})}),t&&e.jsx("button",{onClick:()=>m(!0),className:"px-6 py-3 bg-[#005c75] text-white border-none rounded-lg text-base font-semibold cursor-pointer transition-all hover:bg-[#004a5e] hover:shadow-lg",children:"📋 View Full Logs"}),e.jsx("p",{className:"text-xs text-gray-500 mt-8 m-0",children:"Screenshots will appear here as they are captured. This may take a few minutes."})]})}):Y?e.jsxs(e.Fragment,{children:[L&&!s&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 mx-5 mt-4 p-4 rounded-r max-h-[400px] overflow-auto",role:"alert",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 text-xl shrink-0","aria-hidden":"true",children:"⚠️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-red-800 m-0 mb-2",children:"Capture Error"}),e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("p",{className:"text-sm text-red-700 m-0 mb-2 font-mono whitespace-pre-wrap wrap-break-word",children:L})}),V&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-xs text-red-600 cursor-pointer hover:text-red-800 font-medium",children:"View stack trace"}),e.jsx("div",{className:"mt-2 p-3 bg-red-100 rounded max-h-[300px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-red-900 font-mono whitespace-pre-wrap wrap-break-word m-0",children:V})})]})]})]})}),n==="interactive"?e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[T&&e.jsx("div",{className:"bg-gray-50 border-b border-gray-200 px-6 py-3 shrink-0 flex justify-center",children:e.jsx(ie,{presets:[..._],customSizes:P,currentWidth:N.width,currentHeight:N.height??900,scale:y,onSizeChange:D,onSaveCustomSize:()=>k(!0),onRemoveCustomSize:M})}),T&&e.jsx("div",{className:"bg-[#f6f9fc] border-b border-[rgba(0,92,117,0.25)] flex justify-center",children:e.jsx("div",{style:{maxWidth:`${_[_.length-1].width}px`,width:"100%"},children:e.jsx(ce,{currentViewportWidth:p,currentPresetName:N.name,onDevicePresetClick:B,devicePresets:E})})}),e.jsx(te,{scenarioId:r.id,scenarioName:r.name,iframeUrl:T,isStarting:H,isLoading:J,showIframe:U,iframeKey:G,onIframeLoad:q,onScaleChange:S,onDimensionChange:$,projectSlug:t,defaultWidth:N.width,defaultHeight:N.height})]}):n==="data"?e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(oe,{scenario:r,analysis:x,entity:l})}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsx("div",{className:"flex-1 p-6 flex items-center justify-center",children:e.jsx("div",{className:"transition-all duration-300",style:{maxWidth:`${p}px`},children:(s||!L)&&e.jsx(ae,{screenshotPath:s,cacheBuster:b,alt:r.name,className:"w-full rounded-lg shadow-[0_10px_25px_rgba(0,0,0,0.1)] bg-white"})})})})]}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 overflow-auto w-full",children:u&&!s?e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"bg-blue-50 border-2 border-blue-200 rounded-lg p-8",children:e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("span",{className:"animate-spin text-4xl shrink-0",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-xl font-semibold text-blue-900 m-0 mb-3",children:"Capturing Screenshot"}),e.jsxs("p",{className:"text-sm text-blue-800 m-0 mb-4",children:["Analysis is in progress for"," ",e.jsx("strong",{children:r.name}),". The screenshot will appear here once capture is complete."]}),F&&e.jsxs("div",{className:"bg-white border border-blue-200 rounded p-4 mt-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-blue-800 m-0 mb-2 uppercase tracking-wide",children:"Current Progress"}),e.jsx("p",{className:"text-sm text-blue-900 m-0 font-mono wrap-break-word",children:F})]}),t&&e.jsx("button",{onClick:()=>m(!0),className:"mt-4 px-4 py-2 bg-[#005c75] text-white border-none rounded-md text-sm font-semibold cursor-pointer transition-colors hover:bg-[#004a5e]",children:"📋 View Full Logs"})]})]})})}):L?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center overflow-auto gap-6",children:[!c&&e.jsx("div",{className:"bg-blue-50 border-2 border-blue-300 rounded-lg p-8",children:e.jsxs("div",{className:"flex-1 flex flex-col gap-4 items-center justify-center",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"text-blue-600 text-2xl shrink-0",children:"🔑"}),e.jsx("h3",{className:"text-xl font-semibold text-blue-900 m-0 mb-3",children:"Improve Analysis Quality with an API Key"})]}),e.jsxs("div",{className:"bg-white border border-blue-200 rounded p-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-blue-900 m-0 mb-2 uppercase tracking-wide",children:"CodeYam requires an AI API key for reliable analysis."}),e.jsxs("ul",{className:"text-sm text-blue-800 m-0 space-y-1 pl-5 list-disc",children:[e.jsx("li",{children:"You can use API keys for a variety of models"}),e.jsx("li",{children:"Faster analysis processing"}),e.jsx("li",{children:"Better handling of complex code structures"}),e.jsx("li",{children:"Improved scenario generation quality"})]})]}),e.jsx(ee,{to:"/settings",className:"inline-block px-4 py-2 bg-blue-600 text-white border-none rounded-md text-sm font-semibold cursor-pointer transition-colors hover:bg-blue-700",children:"🔐 Configure API Keys"})]})}),e.jsx("div",{className:"bg-red-50 border-2 border-red-300 rounded-lg p-8 w-full max-w-4xl my-auto",children:e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("span",{className:"text-red-500 text-4xl shrink-0",children:"⚠️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xl font-semibold text-red-800 m-0 mb-3",children:"Capture Failed"}),e.jsx("p",{className:"text-sm text-red-700 m-0 mb-4",children:"An error occurred while capturing this scenario. No screenshot is available."}),e.jsxs("div",{className:"bg-white border border-red-200 rounded p-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-red-800 m-0 mb-2 uppercase tracking-wide",children:"Error Message"}),e.jsx("div",{className:"max-h-[300px] overflow-auto",children:e.jsx("p",{className:"text-sm text-red-900 m-0 font-mono whitespace-pre-wrap wrap-break-word",children:L})})]}),V&&e.jsxs("details",{className:"mt-4",children:[e.jsx("summary",{className:"text-sm text-red-700 cursor-pointer hover:text-red-900 font-semibold",children:"📋 View full stack trace"}),e.jsx("div",{className:"mt-3 bg-white border border-red-200 rounded p-4 max-h-[400px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-red-900 font-mono whitespace-pre-wrap wrap-break-word m-0",children:V})})]})]})]})})]}):g.length>0?e.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-auto",children:e.jsx("div",{className:"bg-red-50 border-2 border-red-300 rounded-lg p-8 w-full max-w-4xl my-auto",children:e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsx("span",{className:"text-red-500 text-4xl shrink-0",children:"⚠️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-xl font-semibold text-red-800 m-0 mb-3",children:"Analysis Error"}),e.jsx("p",{className:"text-sm text-red-700 m-0 mb-4",children:g.length===1?"An error occurred during analysis. Screenshot capture was not completed.":`${g.length} errors occurred during analysis. Screenshot capture was not completed.`}),g.map((i,j)=>e.jsxs("div",{className:"bg-white border border-red-200 rounded p-4 mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-xs font-semibold text-red-800 m-0 mb-2 uppercase tracking-wide",children:i.source}),e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("p",{className:"text-sm text-red-900 m-0 font-mono whitespace-pre-wrap wrap-break-word",children:i.message})}),i.stack&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-xs text-red-700 cursor-pointer hover:text-red-900 font-semibold",children:"View stack trace"}),e.jsx("div",{className:"mt-2 bg-red-50 border border-red-200 rounded p-3 max-h-[200px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-red-900 font-mono whitespace-pre-wrap wrap-break-word m-0",children:i.stack})})]})]},j))]})]})})}):e.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[e.jsx("span",{className:"text-6xl text-gray-300",children:"📷"}),e.jsx("p",{className:"text-lg text-gray-500 m-0",children:"No screenshot available for this scenario"}),e.jsx("p",{className:"text-sm text-gray-400 m-0",children:"Try recapturing or debugging this scenario"})]})})})}),d&&t&&e.jsx(re,{projectSlug:t,onClose:()=>m(!1)}),I&&e.jsx(de,{width:N.width,height:N.height??900,onSave:C,onCancel:()=>k(!1)})]})}export{ge as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as J,b as K,d as ee,r as d,j as e,L as m}from"./components-CAx5ONX_.js";import{u as se}from"./useLastLogLine-BBlyqxij.js";import{u as te,C as le}from"./useToast-C_VxoXTh.js";import{L as ne}from"./LogViewer-Dp6DC845.js";import{I as b,C as V,E as ae}from"./EntityTypeIcon-GqWwt5wG.js";import{S as H}from"./SafeScreenshot-xwuhwsZH.js";import{c as re}from"./createLucideIcon-CgyOwWip.js";import{S as ie}from"./settings-MZc4XdmE.js";import{Z as oe}from"./zap-B4gsLUZQ.js";import{L as w}from"./loader-circle-DN7Vr40D.js";import"./chart-column-B2I7jQx2.js";const ce=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],de=re("folder-open",ce),Ne=()=>[{title:"Dashboard - CodeYam"},{name:"description",content:"CodeYam project dashboard"}];function we(){const{stats:j,uncommittedFiles:g,uncommittedEntitiesList:C,recentSimulations:h,visualEntitiesForSimulation:y,projectSlug:v,queueState:F,currentCommit:_}=J(),i=K(),W=ee(),{showToast:x}=te(),[I,P]=d.useState(new Set),[o,T]=d.useState(null),[R,A]=d.useState(!1),[L,k]=d.useState(!1),{lastLine:S,isCompleted:z,resetLogs:Z}=se(v,!!o),{simulatingEntity:f,scenarios:N,scenarioStatuses:U,allScenariosCaptured:E}=d.useMemo(()=>{const s={simulatingEntity:null,scenarios:[],scenarioStatuses:[],allScenariosCaptured:!1};if(!o)return s;const t=y?.find(r=>r.sha===o);if(!t)return s;const l=t.analyses?.[0],a=l?.scenarios||[],n=l?.status?.scenarios||[],u=n.filter(r=>r.screenshotFinishedAt).length,p=a.length>0&&u===a.length;return{simulatingEntity:t,scenarios:a,scenarioStatuses:n,allScenariosCaptured:p}},[o,y]);d.useEffect(()=>{(z||E)&&T(null)},[z,E]);const q=_?.metadata?.currentRun,$=new Set(q?.currentEntityShas||[]),M=new Set(F.jobs.flatMap(s=>s.entityShas||[])),B=new Set(F.currentlyExecuting?.entityShas||[]),D=C.filter(s=>s.entityType==="visual"||s.entityType==="library"),c=D.filter(s=>!$.has(s.sha)&&!M.has(s.sha)&&!B.has(s.sha)),Q=()=>{if(c.length===0){x("All entities are already queued or analyzing","info",3e3);return}console.log("Analyzing uncommitted entities not yet queued:",c.length),console.log("Entity SHAs:",c.map(s=>s.sha)),k(!0),x(`Starting analysis for ${c.length} entities...`,"info",3e3),i.submit({entityShas:c.map(s=>s.sha).join(",")},{method:"post",action:"/api/analyze"})};d.useEffect(()=>{if(i.state==="idle"&&i.data){const s=i.data;s.success?(console.log("[Analyze All] Success:",s.message),x(`Analysis started for ${s.entityCount} entities in ${s.fileCount} files. Watch the logs for progress.`,"success",6e3),k(!1)):s.error&&(console.error("[Analyze All] Error:",s.error),x(`Error: ${s.error}`,"error",8e3),k(!1))}},[i.state,i.data,x]);const Y=(s,t)=>{console.log("Simulating entity:",s);const l=y?.find(a=>a.sha===s);T(s),Z(),x(`Starting analysis for ${l?.name||"entity"}...`,"info",3e3),i.submit({entitySha:s,filePath:t},{method:"post",action:"/api/analyze"})},O=s=>{P(t=>{const l=new Set(t);return l.has(s)?l.delete(s):l.add(s),l})},G=d.useMemo(()=>{const s=new Map;return h.forEach(t=>{const l=t.entitySha;s.has(l)||s.set(l,[]),s.get(l).push(t)}),Array.from(s.entries()).map(([t,l])=>({entitySha:t,entityName:l[0].entityName,scenarios:l}))},[h]),X=[{label:"Total Entities",value:j.totalEntities,iconType:"folder",link:"/files",color:"#F59E0B"},{label:"Analyzed Entities",value:j.entitiesWithAnalyses,iconType:"check",link:"/recent",color:"#10B981"},{label:"Visual Components",value:j.visualEntities,iconType:"image",link:"/files?entityType=visual",color:"#8B5CF6"},{label:"Library Functions",value:j.libraryEntities,iconType:"code-xml",link:"/files?entityType=library",color:"#0DBFE9"}];return e.jsx("div",{className:"bg-cygray-10 min-h-screen",children:e.jsxs("div",{className:"py-6 px-12",children:[e.jsxs("header",{className:"mb-8 flex justify-between items-center",children:[e.jsx("div",{children:e.jsx("h1",{className:"text-3xl font-bold text-gray-900 m-0 mb-2",children:"CodeYam"})}),W.state==="loading"&&e.jsx("div",{className:"text-blue-600 text-sm font-medium animate-pulse",children:"🔄 Updating..."})]}),e.jsx("div",{className:"flex items-center justify-between gap-3",children:X.map((s,t)=>e.jsx(m,{to:s.link,className:"flex-1 bg-white rounded-xl border border-gray-200 overflow-hidden flex transition-all hover:shadow-lg hover:-translate-y-0.5 no-underline",style:{borderLeft:`4px solid ${s.color}`},children:e.jsxs("div",{className:"px-6 py-4 flex flex-col gap-3 flex-1",children:[e.jsxs("div",{className:"flex md:justify-between md:items-start md:flex-row flex-col",children:[e.jsx("div",{className:"text-xs text-gray-700 font-medium",children:s.label}),e.jsx("div",{className:"text-xs font-medium transition-colors flex items-center gap-1 hidden md:flex",style:{color:s.color},children:"View All →"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"rounded-lg p-2 leading-none flex-shrink-0",style:{backgroundColor:`${s.color}15`},children:[s.iconType==="folder"&&e.jsx(de,{size:20,style:{color:s.color}}),s.iconType==="check"&&e.jsx(le,{size:20,style:{color:s.color}}),s.iconType==="image"&&e.jsx(b,{size:20,style:{color:s.color}}),s.iconType==="gear"&&e.jsx(ie,{size:20,style:{color:s.color}}),s.iconType==="code-xml"&&e.jsx(V,{size:20,style:{color:s.color}})]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900 leading-none",children:s.value})]}),e.jsx("div",{className:"text-xs font-medium transition-colors flex items-center gap-1 md:hidden",style:{color:s.color},children:"View All →"})]})]})},t))}),e.jsxs("div",{className:"mt-12 grid gap-8 items-start",style:{gridTemplateColumns:"repeat(auto-fit, minmax(500px, 1fr))"},children:[e.jsxs("section",{id:"uncommitted",className:"bg-white border border-gray-200 rounded-xl p-6",children:[e.jsxs("div",{className:"flex justify-between items-start mb-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[22px] font-semibold text-gray-900 m-0 mb-1",children:"Uncommitted Changes"}),e.jsx("p",{className:"text-sm text-gray-500 m-0",children:g.length>0?`${g.length} file${g.length!==1?"s":""} with ${C.length} uncommitted entit${C.length!==1?"ies":"y"}`:"No uncommitted changes detected"})]}),D.length>0&&e.jsx("button",{onClick:Q,disabled:i.state!=="idle"||L||c.length===0,className:"px-5 py-2.5 text-white border-none rounded-lg text-sm font-semibold cursor-pointer transition-all hover:-translate-y-px disabled:bg-gray-400 disabled:cursor-not-allowed disabled:translate-y-0",style:{backgroundColor:"#005C75"},onMouseEnter:s=>s.currentTarget.style.backgroundColor="#004560",onMouseLeave:s=>s.currentTarget.style.backgroundColor="#005C75",children:i.state!=="idle"||L?"Starting analysis...":c.length===0?"All Queued":`Analyze All (${c.length})`})]}),g.length>0?e.jsx("div",{className:"flex flex-col gap-3",children:g.map(([s,t])=>{const l=I.has(s),a=t.editedEntities||[];return e.jsxs("div",{className:"bg-white border border-gray-200 border-l-4 rounded-lg overflow-hidden",style:{borderLeftColor:"#306AFF"},children:[e.jsx("div",{className:"p-4 cursor-pointer select-none transition-colors hover:bg-gray-50",onClick:()=>O(s),role:"button",tabIndex:0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-gray-500 text-xs w-4 shrink-0",children:l?"▼":"▶"}),e.jsxs("svg",{width:"16",height:"20",viewBox:"0 0 12 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"shrink-0",children:[e.jsxs("g",{clipPath:"url(#clip0_784_10666)",children:[e.jsx("path",{d:"M0 2.55857C0 1.14551 1.14551 0 2.55857 0H8.73194L12 3.3616V13.4414C12 14.8545 10.8545 16 9.44143 16H2.55857C1.14551 16 0 14.8545 0 13.4414V2.55857Z",fill:"#DDDDFE"}),e.jsx("path",{d:"M8.72656 3.3307H11.9906L8.72656 0V3.3307Z",fill:"#306AFF"}),e.jsx("line",{x1:"1.8125",y1:"5.94825",x2:"10.0235",y2:"5.94825",stroke:"#306AFF",strokeWidth:"1.27929"}),e.jsx("line",{x1:"1.8125",y1:"8.82715",x2:"6.01207",y2:"8.82715",stroke:"#306AFF",strokeWidth:"1.27929"}),e.jsx("line",{x1:"1.8125",y1:"11.7061",x2:"10.0235",y2:"11.7061",stroke:"#306AFF",strokeWidth:"1.27929"})]}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0_784_10666",children:e.jsx("rect",{width:"12",height:"16",fill:"white"})})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-normal text-gray-900 text-sm block truncate",children:s}),e.jsxs("span",{className:"text-xs text-gray-500",children:[a.length," entit",a.length!==1?"ies":"y"]})]})]})}),l&&e.jsx("div",{className:"border-t border-gray-200 bg-gray-50 p-3 flex flex-col gap-2",children:a.length>0?a.map(n=>{const u=$.has(n.sha),p=M.has(n.sha)||B.has(n.sha);return e.jsxs(m,{to:`/entity/${n.sha}`,className:"flex items-center gap-4 p-4 bg-white border border-gray-200 rounded-lg no-underline transition-all hover:shadow-md hover:-translate-y-0.5",style:{borderColor:"inherit"},onMouseEnter:r=>r.currentTarget.style.borderColor="#005C75",onMouseLeave:r=>r.currentTarget.style.borderColor="inherit",children:[e.jsxs("div",{className:"shrink-0 rounded-lg p-1.5 flex items-center justify-center",style:{backgroundColor:n.entityType==="visual"?"#8B5CF615":n.entityType==="library"?"#6366F1":"#EC4899"},children:[n.entityType==="visual"&&e.jsx(b,{size:16,style:{color:"#8B5CF6"}}),n.entityType==="library"&&e.jsx(V,{size:16,className:"text-white"}),n.entityType==="other"&&e.jsx(oe,{size:16,className:"text-white"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("div",{className:"font-semibold text-gray-900 text-sm",children:n.name}),n.entityType==="visual"&&e.jsx("div",{className:"px-2 py-0.5 rounded-sm text-[10px] uppercase font-bold",style:{backgroundColor:"#8B5CF60D",color:"#8B5CF6"},children:"Visual"}),n.entityType==="library"&&e.jsx("div",{className:"px-2 py-0.5 rounded-sm text-[10px] uppercase font-bold",style:{backgroundColor:"#6366F10D",color:"#6366F1"},children:"Library"}),n.entityType==="other"&&e.jsx("div",{className:"px-2 py-0.5 rounded-sm text-[10px] uppercase font-bold",style:{backgroundColor:"#EC48990D",color:"#EC4899"},children:"Other"})]}),n.description&&e.jsx("div",{className:"text-sm text-gray-500 mt-1 overflow-hidden text-ellipsis whitespace-nowrap",children:n.description})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[u&&e.jsxs("div",{className:"px-2 py-1 bg-pink-100 rounded text-xs text-pink-700 font-semibold flex items-center gap-1.5",children:[e.jsx(w,{size:14,className:"animate-spin"}),"Analyzing..."]}),!u&&p&&e.jsx("div",{className:"px-2 py-1 bg-purple-50 border border-purple-300 rounded text-xs text-purple-700 font-semibold",children:"⏳ Queued"}),!u&&!p&&e.jsx("button",{onClick:r=>{r.preventDefault(),r.stopPropagation(),x(`Starting analysis for ${n.name}...`,"info",3e3),i.submit({entityShas:n.sha},{method:"post",action:"/api/analyze"})},disabled:i.state!=="idle",className:"px-3 py-1.5 text-white border-none rounded text-xs font-medium cursor-pointer transition-all disabled:bg-gray-400 disabled:cursor-not-allowed",style:{backgroundColor:"#005C75"},onMouseEnter:r=>r.currentTarget.style.backgroundColor="#004560",onMouseLeave:r=>r.currentTarget.style.backgroundColor="#005C75",children:"Analyze"})]})]},n.sha)}):e.jsx("div",{className:"text-sm text-gray-500 italic p-2",children:"No entity changes detected in this file"})})]},s)})}):e.jsxs("div",{className:"py-12 px-6 text-center flex flex-col items-center bg-gray-50 rounded-lg min-h-[200px] justify-center",children:[e.jsxs("svg",{width:"52",height:"68",viewBox:"0 0 26 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"mb-4 opacity-40",children:[e.jsxs("g",{clipPath:"url(#clip0_784_10631)",children:[e.jsx("path",{d:"M0 2.55857C0 1.14551 1.14551 0 2.55857 0H18.9423L26.0318 7.14651V31.4562C26.0318 32.8693 24.8863 34.0148 23.4732 34.0148H2.55857C1.14551 34.0148 0 32.8693 0 31.4562V2.55857Z",fill:"#D9D9D9"}),e.jsx("path",{d:"M18.9453 7.08081H26.0261L18.9453 0V7.08081Z",fill:"#646464"}),e.jsx("line",{x1:"3.92188",y1:"13.3633",x2:"21.7341",y2:"13.3633",stroke:"#646464",strokeWidth:"1.27929"}),e.jsx("line",{x1:"3.92188",y1:"19.4863",x2:"13.0321",y2:"19.4863",stroke:"#646464",strokeWidth:"1.27929"}),e.jsx("line",{x1:"3.92188",y1:"25.6016",x2:"21.7341",y2:"25.6016",stroke:"#646464",strokeWidth:"1.27929"})]}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0_784_10631",children:e.jsx("rect",{width:"26",height:"34",fill:"white"})})})]}),e.jsx("p",{className:"text-sm font-medium text-gray-400 m-0 mb-2",children:"No Uncommitted Changes."})]})]}),e.jsxs("section",{className:"bg-white border border-gray-200 rounded-xl p-6",children:[e.jsx("div",{className:"flex justify-between items-start mb-5",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-[22px] font-semibold text-gray-900 m-0 mb-1",children:"Recent Simulations"}),e.jsx("p",{className:"text-sm text-gray-500 m-0",children:h.length>0?`Latest ${h.length} captured screenshot${h.length!==1?"s":""}`:"No simulations captured yet"})]})}),h.length>0&&!o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-6 mb-5",children:G.map(s=>e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("div",{className:"shrink-0 rounded-lg p-1.5 flex items-center justify-center bg-purple-100",children:e.jsx(b,{size:16,style:{color:"#8B5CF6"}})}),e.jsx(m,{to:`/entity/${s.entitySha}`,className:"text-sm font-semibold text-gray-900 no-underline hover:text-gray-700 transition-colors",children:s.entityName})]}),e.jsx("div",{className:"grid grid-cols-4 gap-3",children:s.scenarios.map((t,l)=>e.jsx(m,{to:t.scenarioId?`/entity/${t.entitySha}/scenarios/${t.scenarioId}`:`/entity/${t.entitySha}`,className:"aspect-4/3 border border-gray-200 rounded-lg overflow-hidden bg-gray-50 transition-all flex items-center justify-center hover:scale-105",onMouseEnter:a=>{a.currentTarget.style.borderColor="#005C75",a.currentTarget.style.boxShadow="0 4px 12px rgba(0, 92, 117, 0.2)"},onMouseLeave:a=>{a.currentTarget.style.borderColor="#E5E7EB",a.currentTarget.style.boxShadow="none"},title:`${t.scenarioName}`,children:e.jsx(H,{screenshotPath:t.screenshotPath,alt:t.scenarioName,className:"max-w-full max-h-full object-contain object-center"})},l))})]},s.entitySha))}),e.jsx(m,{to:"/recent",className:"block text-center p-3 rounded-lg no-underline font-semibold text-sm transition-all",style:{color:"#005C75",backgroundColor:"#F6F9FC"},onMouseEnter:s=>s.currentTarget.style.backgroundColor="#EEF4F8",onMouseLeave:s=>s.currentTarget.style.backgroundColor="#F6F9FC",children:"View All Recent Simulations →"})]}):o?e.jsxs("div",{className:"p-0 bg-white rounded-lg flex flex-col gap-0",children:[f&&e.jsx("div",{className:"p-4 rounded-t-lg",style:{backgroundColor:"#F0F5F8",borderBottom:"2px solid #005C75"},children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[32px] leading-none",children:e.jsx(ae,{type:"visual"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-base font-bold mb-1",style:{color:"#005C75"},children:["Generating Simulations for ",f.name]}),e.jsx("div",{className:"text-[13px] text-gray-500 font-mono overflow-hidden text-ellipsis whitespace-nowrap",children:f.filePath})]})]})}),E?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600 font-medium p-4 bg-emerald-50",children:[e.jsx("span",{className:"text-lg",children:"✅"}),e.jsxs("span",{children:["Complete (",N.length," scenario",N.length!==1?"s":"",")"]})]}):S?e.jsxs("div",{className:"flex items-center justify-between gap-1.5 text-sm font-medium p-4 bg-gray-50",style:{color:"#005C75"},children:[e.jsx(w,{size:18,className:"animate-spin shrink-0"}),e.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-xs",title:S,children:S}),v&&e.jsx("button",{onClick:()=>A(!0),className:"px-2 py-1.5 bg-gray-500 text-white border-none rounded-md text-[13px] font-medium cursor-pointer transition-all whitespace-nowrap self-start hover:bg-gray-600 hover:-translate-y-px",title:"View analysis logs",children:"📋 Logs"})]}):i.state!=="idle"?e.jsxs("div",{className:"flex items-center justify-between gap-1.5 text-sm font-medium p-4 bg-gray-50",style:{color:"#005C75"},children:[e.jsx(w,{size:18,className:"animate-spin shrink-0"}),e.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:"Initializing analysis..."})]}):e.jsxs("div",{className:"flex items-center justify-between gap-1.5 text-sm font-medium p-4 bg-gray-50",style:{color:"#005C75"},children:[e.jsx(w,{size:18,className:"animate-spin shrink-0"}),e.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:"Starting analysis..."})]}),N.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap p-4 bg-white border-t border-gray-200",children:N.slice(0,8).map((s,t)=>{const l=s.metadata?.screenshotPaths?.[0],a=U.find(p=>p.name===s.name),n=a?.screenshotStartedAt&&!a?.screenshotFinishedAt;return l?e.jsx(m,{to:`/entity/${o}`,className:"w-20 h-15 border-2 border-gray-200 rounded overflow-hidden bg-gray-50 cursor-pointer transition-all flex items-center justify-center no-underline hover:border-blue-600 hover:scale-105 hover:shadow-md",children:e.jsx(H,{screenshotPath:l,alt:s.name,title:s.name,className:"max-w-full max-h-full object-contain object-center"})},t):e.jsx("div",{className:"w-20 h-15 border-2 border-dashed border-gray-300 rounded bg-gray-50 flex items-center justify-center text-2xl",title:`Capturing ${s.name}...`,children:e.jsx("span",{className:n?"animate-spin":"text-gray-400",children:n?"⏳":"⏹️"})},t)})})]}):e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:"py-12 px-6 text-center bg-gray-50 rounded-lg w-full flex flex-col items-center justify-center min-h-[200px]",children:[e.jsx("div",{className:"mb-4 bg-[#efefef] rounded-lg p-3",children:e.jsx(b,{size:28,style:{color:"#999999"},strokeWidth:1.5})}),e.jsx("p",{className:"text-gray-700 m-0 font-semibold",children:"Start by analyzing your first component below."})]}),(y?.length??0)>0?e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-col gap-3 mt-6 w-full",children:(o&&f?[f]:y||[]).map(s=>e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-white border border-gray-200 rounded-lg transition-colors",style:{borderLeft:"4px solid #8B5CF6"},onMouseEnter:t=>{t.currentTarget.style.backgroundColor="#F9FAFB"},onMouseLeave:t=>{t.currentTarget.style.backgroundColor="white"},children:[e.jsxs(m,{to:`/entity/${s.sha}`,className:"flex items-center gap-4 flex-1 min-w-0 no-underline",children:[e.jsx("div",{className:"shrink-0 rounded-lg p-1.5 flex items-center justify-center bg-purple-100",children:e.jsx(b,{size:16,style:{color:"#8B5CF6"}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-gray-900 text-sm mb-1",children:s.name}),e.jsx("div",{className:"text-xs text-gray-500 font-mono overflow-hidden text-ellipsis whitespace-nowrap",children:s.filePath})]})]}),e.jsx("button",{onClick:()=>Y(s.sha,s.filePath||""),disabled:i.state!=="idle"||o!==null,className:"px-4 py-2 text-white border-none rounded text-sm font-medium cursor-pointer transition-all whitespace-nowrap shrink-0 disabled:bg-gray-400 disabled:cursor-not-allowed disabled:translate-y-0",style:{backgroundColor:"#005C75"},onMouseEnter:t=>t.currentTarget.style.backgroundColor="#004560",onMouseLeave:t=>t.currentTarget.style.backgroundColor="#005C75",title:o?"Please wait for current analysis to complete":"Analyze this entity",children:"Analyze"})]})},s.sha))})}):e.jsx("p",{className:"text-base text-gray-600 m-0 mb-6 leading-relaxed mt-6",children:"Run analysis on your visual components to create simulations and capture screenshots"})]})]})]}),R&&v&&e.jsx(ne,{projectSlug:v,onClose:()=>A(!1)})]})})}export{we as default,Ne as meta};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{b as E,j as e,L as g,u as M,e as z,r as k,d as L}from"./components-CAx5ONX_.js";import{L as q}from"./LogViewer-Dp6DC845.js";import{u as D}from"./useLastLogLine-BBlyqxij.js";import{S,C as K}from"./ScenarioPreview-Bl2IRh55.js";import{c as T}from"./createLucideIcon-CgyOwWip.js";import{C as F}from"./chart-column-B2I7jQx2.js";import{C as I}from"./circle-alert-GwwOAbhw.js";import"./SafeScreenshot-xwuhwsZH.js";import"./LibraryFunctionPreview-p0fuyqGQ.js";const B=[["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}]],H=T("cog",B);const _=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Q=T("list-todo",_);const J=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],$=T("pause",J);function V(s){const t=Date.now(),o=new Date(s).getTime(),i=t-o,r=Math.floor(i/6e4),a=Math.floor(r/60);return r<1?"just now":r<60?`${r}m ago`:a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function O({state:s,currentRun:t}){E();const o=t?.currentEntityShas&&t.currentEntityShas.length>0;return!s.currentlyExecuting&&(!s.jobs||s.jobs.length===0)?null:e.jsxs("div",{className:"bg-white border-2 border-blue-500 rounded-xl shadow-lg p-5 mb-6",children:[s.currentlyExecuting&&!o&&e.jsxs("div",{className:"mb-4 bg-blue-50 border-2 border-blue-400 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xl animate-spin",children:"⚙️"}),e.jsx("span",{className:"text-sm font-bold text-blue-900",children:"Starting analysis..."})]}),e.jsxs("p",{className:"text-xs text-blue-700 mb-2",children:["Booting analyzer for ",s.currentlyExecuting.entities?.length||s.currentlyExecuting.entityShas?.length||1," ",(s.currentlyExecuting.entities?.length||s.currentlyExecuting.entityShas?.length)===1?"entity":"entities"]}),s.currentlyExecuting.entities&&s.currentlyExecuting.entities.length>0&&e.jsxs("div",{className:"space-y-1 mt-2 max-h-[100px] overflow-y-auto bg-white rounded-md p-2 border border-blue-200",children:[s.currentlyExecuting.entities.slice(0,3).map(i=>e.jsxs(g,{to:`/entity/${i.sha}`,className:"block text-xs text-blue-600 hover:text-blue-800 hover:underline font-medium truncate",title:`${i.name} - ${i.filePath}`,children:["📄 ",i.name,e.jsxs("span",{className:"text-gray-400 ml-1",children:["(",i.filePath,")"]})]},i.sha)),s.currentlyExecuting.entities.length>3&&e.jsxs("div",{className:"text-xs text-blue-600 italic",children:["+",s.currentlyExecuting.entities.length-3," more entities"]})]}),e.jsx("p",{className:"text-xs text-blue-600 mt-2",children:"This may take 2-3 minutes for environment setup"})]}),s.jobs.length>0&&e.jsxs("div",{className:"space-y-2",children:[s.jobs.slice(0,5).map((i,r)=>{i.entities?.length||i.entityShas?.length,i.filePaths?.length,i.entityNames?.[0];const a=i.entities&&i.entities.length>0;return e.jsx("div",{className:"flex items-start gap-3",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-sm font-semibold text-gray-700",children:["Job ",r+1]}),e.jsx("span",{className:"text-xs text-gray-400",children:"•"}),e.jsx("span",{className:"text-xs text-gray-500",children:V(i.queuedAt)})]}),a&&e.jsxs("div",{className:"space-y-1 mt-2 max-h-[120px] overflow-y-auto bg-white rounded-md p-2 border border-gray-200",children:[i.entities.slice(0,5).map(n=>e.jsxs(g,{to:`/entity/${n.sha}`,className:"block text-xs text-blue-600 hover:text-blue-800 hover:underline font-medium truncate",title:`${n.name} - ${n.filePath}`,children:["📄 ",n.name,e.jsxs("span",{className:"text-gray-400 ml-1",children:["(",n.filePath,")"]})]},n.sha)),i.entities.length>5&&e.jsxs("div",{className:"text-xs text-gray-500 italic",children:["+",i.entities.length-5," more entities"]})]}),i.type==="recapture"&&i.scenarioId&&e.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:["Scenario: ",i.scenarioId]})]})},i.id)}),s.jobs.length>5&&e.jsxs("div",{className:"text-xs text-gray-500 text-center py-2",children:["+",s.jobs.length-5," more jobs in queue"]})]})]})}function R({activeTab:s,hasCurrentActivity:t,queuedCount:o,historicCount:i}){const r=[{id:"current",label:"Current Activity",hasContent:t,count:null},{id:"queued",label:"Queued Activity",hasContent:o>0,count:o},{id:"historic",label:"Historic Activity",hasContent:i>0,count:i}];return e.jsx("div",{className:"border-b border-gray-200 mb-6",children:e.jsx("nav",{className:"flex gap-8",children:r.map(a=>{const n=s===a.id;return e.jsx(g,{to:a.id==="current"?"/activity":`/activity/${a.id}`,className:`
|
|
2
|
+
relative pb-4 px-2 text-sm font-medium transition-colors
|
|
3
|
+
${n?"border-b-2":"text-gray-500 hover:text-gray-700"}
|
|
4
|
+
`,style:n?{color:"#005C75",borderColor:"#005C75"}:{},children:e.jsxs("span",{className:"flex items-center gap-2",children:[a.label,a.count!==null&&a.count>0&&e.jsx("span",{className:`
|
|
5
|
+
inline-flex items-center justify-center px-2 py-0.5 text-xs font-semibold rounded-full
|
|
6
|
+
${n?"":"bg-gray-200 text-gray-700"}
|
|
7
|
+
`,style:n?{backgroundColor:"#e8f1f5",color:"#005C75"}:{},children:a.count}),a.count===null&&a.hasContent&&e.jsx("span",{className:`
|
|
8
|
+
inline-block w-2 h-2 rounded-full
|
|
9
|
+
${n?"":"bg-gray-400"}
|
|
10
|
+
`,style:n?{backgroundColor:"#005C75"}:{}})]})},a.id)})})})}function U(s){const t=new Date(s),i=Math.floor((new Date().getTime()-t.getTime())/1e3);if(i<60)return"just now";const r=Math.floor(i/60);if(r<60)return`${r}m ago`;const a=Math.floor(r/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function W({currentlyExecuting:s,currentRun:t,state:o,projectSlug:i,commitSha:r,onShowLogs:a,recentCompletedRuns:n,totalCompletedRuns:N}){const[h,A]=k.useState({}),[u,f]=k.useState({isKilling:!1,current:0,total:0}),C=L(),w=!!s,p=s?.entities||[],x=!!t?.analysisCompletedAt,j=w,{lastLine:v}=D(i,j);return k.useEffect(()=>{if(!t)return;const l=[t.analyzerPid,t.capturePid].filter(c=>!!c);if(l.length===0)return;const m=async()=>{try{const d=await(await fetch(`/api/process-status?pids=${l.join(",")}`)).json();if(d.processes){const b={};d.processes.forEach(P=>{b[P.pid]={isRunning:P.isRunning,processName:P.processName}}),A(b)}}catch(c){console.error("Failed to fetch process statuses:",c)}};m();const y=setInterval(()=>void m(),5e3);return()=>clearInterval(y)},[t?.analyzerPid,t?.capturePid]),j?e.jsxs("div",{className:"bg-white rounded-xl shadow-lg p-6",style:{borderWidth:"2px",borderColor:"#005C75"},children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 bg-gray-100 rounded-full animate-spin",children:e.jsx(H,{size:24,className:"text-gray-700"})}),e.jsx("h3",{className:"text-xl font-bold text-gray-900",children:x?"Capture in Progress":"Analysis in Progress"})]}),e.jsx("button",{onClick:a,className:"px-4 py-2 text-white rounded-md text-sm font-semibold transition-colors",style:{backgroundColor:"#005C75"},onMouseEnter:l=>l.currentTarget.style.backgroundColor="#003d52",onMouseLeave:l=>l.currentTarget.style.backgroundColor="#005C75",children:"View Logs"})]}),x&&(t?.readyToBeCaptured??0)>0&&e.jsxs("div",{className:"rounded-md p-4 mb-4",style:{backgroundColor:"#f0f5f8",borderColor:"#b3d9e8",borderWidth:"1px"},children:[e.jsx("p",{className:"text-sm font-semibold mb-1",style:{color:"#00263d"},children:"Capture Progress:"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("p",{className:"text-sm",style:{color:"#004560"},children:[t?.capturesCompleted??0," of"," ",t?.readyToBeCaptured??0," entities captured"]}),e.jsx("div",{className:"flex-1 rounded-full h-2",style:{backgroundColor:"#b3d9e8"},children:e.jsx("div",{className:"h-2 rounded-full transition-all duration-300",style:{backgroundColor:"#005C75",width:`${(t?.capturesCompleted??0)/(t?.readyToBeCaptured??1)*100}%`}})})]})]}),p&&p.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("p",{className:"text-sm font-semibold text-gray-700 mb-2",children:[x?"Capturing":"Analyzing"," ",p.length," ",p.length===1?"Entity":"Entities",":"]}),e.jsx("div",{className:"space-y-3",children:p.map(l=>{const m=l.analyses?.[0],y=m?.scenarios||[],c=m?.status;return e.jsxs("div",{className:"bg-gray-50 rounded-md p-3",children:[e.jsxs(g,{to:`/entity/${l.sha}`,className:"block text-sm hover:underline font-medium truncate mb-2",title:`${l.name} - ${l.filePath}`,style:{color:"#005C75"},onMouseEnter:d=>d.currentTarget.style.color="#003d52",onMouseLeave:d=>d.currentTarget.style.color="#005C75",children:["📄 ",l.name,e.jsxs("span",{className:"text-gray-500 ml-2 text-xs",children:["(",l.filePath,")"]})]}),y.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap",children:y.slice(0,5).map((d,b)=>d.id?e.jsx(S,{scenario:d,entity:{sha:l.sha,entityType:l.entityType},analysisStatus:c,queueState:o,processIsRunning:j,size:"small"},b):null)})]},l.sha)})})]}),v&&e.jsxs("div",{className:"flex flex-col gap-2 mb-4",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-700",children:"Current Step:"}),e.jsx("p",{className:"text-sm text-gray-600 font-mono",children:v})]}),(t?.analyzerPid||t?.capturePid)&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-700",children:"Running Processes:"}),e.jsxs("div",{className:"flex items-center justify-between bg-gray-50 rounded-md p-3",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[t.analyzerPid&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-mono bg-gray-200 px-2 py-1 rounded",children:["Analyzer: ",t.analyzerPid]}),h[t.analyzerPid]&&e.jsx("span",{className:`text-xs px-2 py-1 rounded ${h[t.analyzerPid].isRunning?"bg-green-100 text-green-700":"bg-red-100 text-red-700"}`,children:h[t.analyzerPid].isRunning?"Running":"Stopped"})]}),t.capturePid&&e.jsxs(e.Fragment,{children:[t.analyzerPid&&e.jsx("span",{className:"text-gray-400",children:"|"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-mono bg-gray-200 px-2 py-1 rounded",children:["Capture: ",t.capturePid]}),h[t.capturePid]&&e.jsx("span",{className:`text-xs px-2 py-1 rounded ${h[t.capturePid].isRunning?"bg-green-100 text-green-700":"bg-red-100 text-red-700"}`,children:h[t.capturePid].isRunning?"Running":"Stopped"})]})]})]}),(h[t.analyzerPid]?.isRunning||h[t.capturePid]?.isRunning)&&e.jsxs("div",{className:"flex items-center gap-3",children:[u.isKilling&&e.jsxs("span",{className:"text-xs text-gray-600 font-medium",children:["Killing process ",u.current," of"," ",u.total,"..."]}),e.jsx("button",{onClick:()=>{const l=[t.analyzerPid,t.capturePid].filter(c=>!!c&&h[c]?.isRunning);if(l.length===0)return;const m=l.join(", ");if(!confirm(`Are you sure you want to kill all running processes (${m})?`))return;f({isKilling:!0,current:1,total:l.length}),(async()=>{for(let c=0;c<l.length;c++){const d=l[c];try{await fetch("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:d,commitSha:r||""})})}catch(b){console.error(`Failed to kill process ${d}:`,b)}c<l.length-1&&f({isKilling:!0,current:c+2,total:l.length})}f({isKilling:!1,current:0,total:0}),C.revalidate()})()},disabled:u.isKilling,className:"px-3 py-1 bg-red-600 text-white rounded-md text-xs font-semibold hover:bg-red-700 transition-colors whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed",children:u.isKilling?"Killing...":"Kill All Processes"})]})]})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 rounded-xl p-12 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"p-2 bg-gray-200 rounded-lg",children:e.jsx($,{size:24,className:"text-gray-600",fill:"currentColor"})})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-700 mb-2",children:"No Current Activity"}),e.jsxs("p",{className:"text-gray-500",children:["There are no analyses currently running. Trigger an analysis from the"," ",e.jsx(g,{to:"/git",className:"text-[#005C75] underline hover:text-[#004a5e]",children:"Git"})," ","or"," ",e.jsx(g,{to:"/files",className:"text-[#005C75] underline hover:text-[#004a5e]",children:"Files"})," ","page."]})]}),n&&n.length>0&&e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Recent Completed Analyses"}),e.jsx("div",{className:"space-y-3",children:n.map(l=>{const m=l.analysisCompletedAt||l.archivedAt||l.createdAt,y=l.entities&&l.entities.length>0;return e.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-xl",children:"✅"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:"Completed"}),e.jsx("span",{className:"text-xs text-gray-400",children:"•"}),e.jsx("span",{className:"text-xs text-gray-500",children:m?U(m):"Unknown"})]}),y&&e.jsxs("div",{className:"ml-7 space-y-1",children:[l.entities.slice(0,3).map(c=>e.jsxs(g,{to:`/entity/${c.sha}`,className:"block text-sm hover:underline truncate",title:`${c.name} - ${c.filePath}`,style:{color:"#005C75"},onMouseEnter:d=>d.currentTarget.style.color="#003d52",onMouseLeave:d=>d.currentTarget.style.color="#005C75",children:["📄 ",c.name,e.jsxs("span",{className:"text-gray-400 ml-1 text-xs",children:["(",c.filePath,")"]})]},c.sha)),l.entities.length>3&&e.jsxs("div",{className:"text-xs text-gray-500 italic",children:["+",l.entities.length-3," more entities"]})]})]},l.id)})}),N>3&&e.jsx("div",{className:"mt-4 text-center",children:e.jsx(g,{to:"/activity/historic",className:"text-sm font-medium",style:{color:"#005C75"},onMouseEnter:l=>l.currentTarget.style.color="#003d52",onMouseLeave:l=>l.currentTarget.style.color="#005C75",children:"View All Historic Activity →"})})]})]})}function G({queueJobs:s,state:t,currentRun:o}){return!s||s.length===0?e.jsxs("div",{className:"bg-gray-50 rounded-xl p-12 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"p-3 bg-gray-200 rounded-lg",children:e.jsx(Q,{size:32,className:"text-gray-600",fill:"currentColor"})})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-700 mb-2",children:"No Queued Jobs"}),e.jsx("p",{className:"text-gray-500",children:"Analysis jobs will appear here when they are queued but not yet started."})]}):e.jsx("div",{children:e.jsx(O,{state:t,currentRun:o})})}function X({historicalRuns:s,totalHistoricalRuns:t,currentPage:o,totalPages:i,tab:r}){return t===0?e.jsxs("div",{className:"bg-gray-50 rounded-xl p-12 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"p-3 bg-gray-200 rounded-lg",children:e.jsx(F,{size:32,className:"text-gray-600",fill:"currentColor"})})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-700 mb-2",children:"No Historic Activity"}),e.jsx("p",{className:"text-gray-500",children:"Completed analyses will appear here for historical reference."})]}):e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-6",children:[e.jsx("div",{className:"space-y-3",children:s.map(a=>{const n=!!a.failedAt,N=a.readyToBeCaptured,h=a.capturesCompleted??0,A=N===void 0?!0:N===0||h>=N,u=!n&&!!a.analysisCompletedAt&&A,f=a.createdAt?new Date(a.createdAt):null,C=a.failedAt?new Date(a.failedAt):a.analysisCompletedAt?new Date(a.analysisCompletedAt):null,w=f&&C?(C.getTime()-f.getTime())/1e3:null,p=a.entities&&a.entities.length>0;return e.jsx("div",{className:`border rounded-lg p-4 ${n?"bg-red-50 border-red-200":u?"bg-green-50 border-green-200":"bg-gray-50 border-gray-200"}`,children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n?e.jsx(I,{size:20,className:"text-red-500"}):u?e.jsx(K,{size:20,className:"text-green-500"}):e.jsx($,{size:20,className:"text-gray-400"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:n?"Failed":u?"Completed":"Incomplete"}),e.jsx("span",{className:"text-xs text-gray-400",children:"•"}),e.jsx("span",{className:"text-xs text-gray-500",children:a.archivedAt?new Date(a.archivedAt).toLocaleString():a.createdAt?new Date(a.createdAt).toLocaleString():"Unknown"})]}),p&&e.jsxs("div",{className:"ml-7 mt-2 space-y-2 max-h-[300px] overflow-y-auto bg-white rounded-md p-2 border border-gray-200",children:[a.entities.slice(0,5).map(x=>{const j=x.analyses?.[0],v=j?.scenarios||[];return e.jsxs("div",{className:"pb-2 border-b last:border-b-0 border-gray-100",children:[e.jsxs(g,{to:`/entity/${x.sha}`,className:"block text-xs hover:underline font-medium truncate mb-1",title:`${x.name} - ${x.filePath}`,style:{color:"#005C75"},onMouseEnter:l=>l.currentTarget.style.color="#003d52",onMouseLeave:l=>l.currentTarget.style.color="#005C75",children:["📄 ",x.name,e.jsxs("span",{className:"text-gray-400 ml-1",children:["(",x.filePath,")"]})]}),v.length>0&&e.jsx("div",{className:"flex gap-1.5 flex-wrap mt-1.5",children:v.slice(0,5).map((l,m)=>l.id?e.jsx(S,{scenario:l,entity:{sha:x.sha,entityType:x.entityType},analysisStatus:j?.status,queueState:void 0,processIsRunning:!1,size:"small"},m):null)})]},x.sha)}),a.entities.length>5&&e.jsxs("div",{className:"text-xs text-gray-500 italic pt-1",children:["+",a.entities.length-5," more entities"]})]}),a.failureReason&&e.jsx("p",{className:"text-xs text-red-600 mt-2 font-mono ml-7",children:a.failureReason})]}),w!==null&&e.jsxs("div",{className:"text-xs text-gray-500",children:[w.toFixed(1),"s"]})]})},a.id)})}),i>1&&e.jsxs("div",{className:"mt-6 flex items-center justify-between border-t border-gray-200 pt-4",children:[e.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",(o-1)*20+1," -"," ",Math.min(o*20,t)," of"," ",t," runs"]}),e.jsxs("div",{className:"flex gap-2",children:[o>1&&e.jsx(g,{to:`/activity/${r}?page=${o-1}`,className:"px-3 py-1 bg-gray-100 text-gray-700 rounded-md text-sm font-medium hover:bg-gray-200 transition-colors",children:"Previous"}),o<i&&e.jsx(g,{to:`/activity/${r}?page=${o+1}`,className:"px-3 py-1 bg-gray-100 text-gray-700 rounded-md text-sm font-medium hover:bg-gray-200 transition-colors",children:"Next"})]})]})]})}function ne(){const s=M(),t=z(),[o,i]=k.useState(!1),r=t.tab||"current";return e.jsxs("div",{className:"px-36 py-12",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Activity"}),e.jsx("p",{className:"text-gray-600",children:"View queued, current, and historical analysis activity"})]}),e.jsx(R,{activeTab:r,hasCurrentActivity:s.hasCurrentActivity,queuedCount:s.queuedCount,historicCount:s.totalHistoricalRuns}),r==="current"&&e.jsx(W,{currentlyExecuting:s.currentlyExecuting,currentRun:s.currentRun,state:s.state,projectSlug:s.projectSlug,commitSha:s.commitSha,onShowLogs:()=>i(!0),recentCompletedRuns:s.recentCompletedRuns,totalCompletedRuns:s.totalCompletedRuns}),r==="queued"&&e.jsx(G,{queueJobs:s.queueJobs,state:s.state,currentRun:s.currentRun}),r==="historic"&&e.jsx(X,{historicalRuns:s.historicalRuns,totalHistoricalRuns:s.totalHistoricalRuns,currentPage:s.currentPage,totalPages:s.totalPages,tab:r}),o&&s.projectSlug&&e.jsx(q,{projectSlug:s.projectSlug,onClose:()=>i(!1)})]})}export{ne as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as t}from"./createLucideIcon-CgyOwWip.js";const a=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],o=t("chart-column",a);export{o as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./createLucideIcon-CgyOwWip.js";const c=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],y=e("circle-alert",c);export{y as C};
|
|
@@ -37,4 +37,4 @@ ${N.map((Re,we)=>`import * as route${we} from ${JSON.stringify(i.routes[Re.route
|
|
|
37
37
|
${S?`window.__remixManifest = ${JSON.stringify(Jy(i,p),null,2)};`:""}
|
|
38
38
|
window.__remixRouteModules = {${N.map((Re,we)=>`${JSON.stringify(Re.route.id)}:route${we}`).join(",")}};
|
|
39
39
|
|
|
40
|
-
import(${JSON.stringify(i.entry.module)});`:" ";return w.createElement(w.Fragment,null,w.createElement("script",rt({},r,{suppressHydrationWarning:!0,dangerouslySetInnerHTML:id(Y),type:void 0})),w.createElement("script",rt({},r,{suppressHydrationWarning:!0,dangerouslySetInnerHTML:id(ue),type:"module",async:!0})))},[]);if(!v&&typeof __remixContext=="object"&&__remixContext.a)for(let J=0;J<__remixContext.a;J++)j.push(w.createElement(sd,{key:J,scriptProps:r,serializeData:Q,serializeError:z}));let B=N.map(J=>{let P=i.routes[J.route.id];return(P.imports||[]).concat([P.module])}).flat(1),Z=ko?[]:i.entry.imports.concat(B);return ko?null:w.createElement(w.Fragment,null,S?null:w.createElement("link",{rel:"modulepreload",href:i.url,crossOrigin:r.crossOrigin}),w.createElement("link",{rel:"modulepreload",href:i.entry.module,crossOrigin:r.crossOrigin}),og(Z).map(J=>w.createElement("link",{key:J,rel:"modulepreload",href:J,crossOrigin:r.crossOrigin})),K,j)}function sd({dataKey:r,deferredData:i,routeId:o,scriptProps:s,serializeData:c,serializeError:d}){return typeof document>"u"&&i&&r&&o&&_n(i.pendingKeys.includes(r),`Deferred data for route ${o} with key ${r} was not pending but tried to render a script for it.`),w.createElement(w.Suspense,{fallback:typeof document>"u"&&i&&r&&o?null:w.createElement("script",rt({},s,{async:!0,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:" "}}))},typeof document>"u"&&i&&r&&o?w.createElement(rg,{resolve:i.data[r],errorElement:w.createElement(ig,{dataKey:r,routeId:o,scriptProps:s,serializeError:d}),children:h=>w.createElement("script",rt({},s,{async:!0,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:c(o,r,h)}}))}):w.createElement("script",rt({},s,{async:!0,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:" "}})))}function ig({dataKey:r,routeId:i,scriptProps:o,serializeError:s}){let c=sv();return w.createElement("script",rt({},o,{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:s(i,r,c)}}))}function og(r){return[...new Set(r)]}function Pg(){return ov()}function Lg(){return av()}function Tg(r={}){return Kv(r)}const Dg=(()=>null);function lh(...r){return i=>{r.forEach(o=>{typeof o=="function"?o(i):o!=null&&(o.current=i)})}}export{iv as A,wg as B,_g as C,Dg as D,Er as E,Uu as F,ug as G,$p as H,fd as I,Vp as J,ag as K,qy as L,Cg as M,pg as O,nh as R,lg as S,rt as _,Ld as a,Tg as b,Lg as c,hg as d,
|
|
40
|
+
import(${JSON.stringify(i.entry.module)});`:" ";return w.createElement(w.Fragment,null,w.createElement("script",rt({},r,{suppressHydrationWarning:!0,dangerouslySetInnerHTML:id(Y),type:void 0})),w.createElement("script",rt({},r,{suppressHydrationWarning:!0,dangerouslySetInnerHTML:id(ue),type:"module",async:!0})))},[]);if(!v&&typeof __remixContext=="object"&&__remixContext.a)for(let J=0;J<__remixContext.a;J++)j.push(w.createElement(sd,{key:J,scriptProps:r,serializeData:Q,serializeError:z}));let B=N.map(J=>{let P=i.routes[J.route.id];return(P.imports||[]).concat([P.module])}).flat(1),Z=ko?[]:i.entry.imports.concat(B);return ko?null:w.createElement(w.Fragment,null,S?null:w.createElement("link",{rel:"modulepreload",href:i.url,crossOrigin:r.crossOrigin}),w.createElement("link",{rel:"modulepreload",href:i.entry.module,crossOrigin:r.crossOrigin}),og(Z).map(J=>w.createElement("link",{key:J,rel:"modulepreload",href:J,crossOrigin:r.crossOrigin})),K,j)}function sd({dataKey:r,deferredData:i,routeId:o,scriptProps:s,serializeData:c,serializeError:d}){return typeof document>"u"&&i&&r&&o&&_n(i.pendingKeys.includes(r),`Deferred data for route ${o} with key ${r} was not pending but tried to render a script for it.`),w.createElement(w.Suspense,{fallback:typeof document>"u"&&i&&r&&o?null:w.createElement("script",rt({},s,{async:!0,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:" "}}))},typeof document>"u"&&i&&r&&o?w.createElement(rg,{resolve:i.data[r],errorElement:w.createElement(ig,{dataKey:r,routeId:o,scriptProps:s,serializeError:d}),children:h=>w.createElement("script",rt({},s,{async:!0,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:c(o,r,h)}}))}):w.createElement("script",rt({},s,{async:!0,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:" "}})))}function ig({dataKey:r,routeId:i,scriptProps:o,serializeError:s}){let c=sv();return w.createElement("script",rt({},o,{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:s(i,r,c)}}))}function og(r){return[...new Set(r)]}function Pg(){return ov()}function Lg(){return av()}function Tg(r={}){return Kv(r)}const Dg=(()=>null);function lh(...r){return i=>{r.forEach(o=>{typeof o=="function"?o(i):o!=null&&(o.current=i)})}}export{iv as A,wg as B,_g as C,Dg as D,Er as E,Uu as F,ug as G,$p as H,fd as I,Vp as J,ag as K,qy as L,Cg as M,pg as O,nh as R,lg as S,rt as _,Ld as a,Tg as b,Lg as c,hg as d,dg as e,gg as f,Iy as g,Zu as h,_n as i,sg as j,fg as k,kg as l,Rn as m,Sg as n,cg as o,xg as p,Rg as q,w as r,Ky as s,Eg as t,Pg as u,yg as v,mg as w,Yp as x,rl as y,dn as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as s}from"./components-CAx5ONX_.js";const C=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),w=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,r,o)=>o?o.toUpperCase():r.toLowerCase()),i=t=>{const e=w(t);return e.charAt(0).toUpperCase()+e.slice(1)},l=(...t)=>t.filter((e,r,o)=>!!e&&e.trim()!==""&&o.indexOf(e)===r).join(" ").trim(),f=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var h={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const g=s.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:n="",children:a,iconNode:u,...c},p)=>s.createElement("svg",{ref:p,...h,width:e,height:e,stroke:t,strokeWidth:o?Number(r)*24/Number(e):r,className:l("lucide",n),...!a&&!f(c)&&{"aria-hidden":"true"},...c},[...u.map(([m,d])=>s.createElement(m,d)),...Array.isArray(a)?a:[a]]));const b=(t,e)=>{const r=s.forwardRef(({className:o,...n},a)=>s.createElement(g,{ref:a,iconNode:e,className:l(`lucide-${C(i(t))}`,`lucide-${t}`,o),...n}));return r.displayName=i(t),r};export{b as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t,j as e}from"./components-
|
|
1
|
+
import{b as t,j as e}from"./components-CAx5ONX_.js";import{S as n}from"./ScenarioViewer-M2QuSHKC.js";import{W as r}from"./InteractivePreview-Dh-FldQK.js";import"./LogViewer-Dp6DC845.js";import"./SafeScreenshot-xwuhwsZH.js";import"./useLastLogLine-BBlyqxij.js";const d=()=>[{title:"Empty State - CodeYam"},{name:"description",content:"Simulations empty state development view"}];function m(){t();const s={sha:"mock-sha",name:"Dashboard",filePath:"codeyam-cli/src/webserver/app/routes/_index.tsx",entityType:"visual"};return e.jsx(r,{children:e.jsxs("div",{className:"h-screen bg-[#f9f9f9] flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-white border-b border-gray-200 shrink-0 relative h-[54px]",children:e.jsxs("div",{className:"flex items-center h-full px-6 gap-6",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M13 8.5H4M4 8.5L8.5 4M4 8.5L8.5 13",stroke:"#005c75",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("h1",{className:"text-lg font-semibold text-black m-0 leading-[26px] shrink-0",children:"Dashboard"}),e.jsx("span",{className:"text-xs text-[#626262] font-mono whitespace-nowrap overflow-hidden text-ellipsis min-w-0",children:"codeyam-cli/src/webserver/app/routes/_index.tsx"})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-[15px] py-0 h-[26px] bg-[#efefef] border border-[#e1e1e1] rounded",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-[#626262]"}),e.jsx("span",{className:"text-xs font-semibold text-[#626262]",children:"Not analyzed"})]}),e.jsx("button",{className:"px-[15px] py-0 h-[26px] bg-[#005c75] text-white rounded text-xs font-semibold border-none cursor-pointer hover:bg-[#004a5e] transition-colors",children:"Analyze"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-[#626262] ml-auto",children:[e.jsx("span",{className:"leading-[22px]",children:"Next Entity"}),e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",className:"shrink-0",children:e.jsx("path",{d:"M4 8.5H13M13 8.5L8.5 4M13 8.5L8.5 13",stroke:"#005c75",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}),e.jsx("div",{className:"bg-[#efefef] border-b border-[#efefef] shrink-0",children:e.jsxs("div",{className:"flex items-center gap-3 h-11 px-[15px]",children:[e.jsxs("div",{className:"px-4 flex items-center justify-center gap-3 shrink-0 text-sm rounded bg-[#343434] text-[#efefef] font-semibold h-8",children:["Scenarios",e.jsx("span",{className:"px-2 py-0.5 rounded-[9px] text-xs font-semibold bg-[#cbf3fa] text-[#005c75] min-w-[25px] text-center",children:"0"})]}),e.jsxs("div",{className:"px-4 flex items-center justify-center gap-3 shrink-0 text-sm rounded-[9px] text-[#3e3e3e] font-normal",children:["Related Entities",e.jsx("span",{className:"px-2 py-0.5 rounded-[9px] text-xs font-semibold bg-[#e1e1e1] text-[#3e3e3e] min-w-[25px] text-center",children:"5"})]}),e.jsx("div",{className:"px-4 shrink-0 text-sm text-[#3e3e3e] font-normal",children:"Code"}),e.jsx("div",{className:"px-4 shrink-0 text-sm text-[#3e3e3e] font-normal",children:"Data Structure"}),e.jsx("div",{className:"px-4 shrink-0 text-sm text-[#3e3e3e] font-normal",children:"History"})]})}),e.jsxs("div",{className:"flex flex-1 gap-0 min-h-0",children:[e.jsx("div",{className:"w-[165px] bg-[#e1e1e1] border-r border-[#c7c7c7] flex items-center justify-center shrink-0",children:e.jsx("span",{className:"text-xs font-medium text-[#8e8e8e] leading-5",children:"No Scenarios"})}),e.jsx(n,{selectedScenario:null,analysis:void 0,entity:s,viewMode:"screenshot",cacheBuster:Date.now(),hasScenarios:!1,isAnalyzing:!1,projectSlug:null,hasAnApiKey:!0})]})]})})}export{m as default,d as meta};
|