@testver/testver 1.4.2 → 1.5.0
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/LICENSE +88 -69
- package/README.md +6 -2
- package/bin/testver.js +9 -1
- package/dist/index.js +52650 -35771
- package/package.json +179 -178
- package/src/ui/static/agents/antigravity.svg +76 -0
- package/src/ui/static/agents/codex.svg +3 -0
- package/src/ui/static/agents/gemini.svg +1 -0
- package/src/ui/static/agents/opencode.svg +4 -0
- package/src/ui/static/agents/vscode.svg +17 -0
- package/src/ui/static/assets/AIPanel-RWO8Cd9w.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-DnreS585.js +40 -0
- package/src/ui/static/assets/AIStreamUI-C1gHJtlF.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-C8bWUelu.js} +5 -5
- package/src/ui/static/assets/APITestingPage-DwL67hqL.js +19 -0
- package/src/ui/static/assets/AboutPage-CynLB95E.js +1 -0
- package/src/ui/static/assets/AccessTokensTab-BdevOmpE.js +1 -0
- package/src/ui/static/assets/AdvancedPage-BeM7aB8b.js +3 -0
- package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-C5ddYfRk.js} +1 -1
- package/src/ui/static/assets/AuditLogPage-DYcUdJoj.js +1 -0
- package/src/ui/static/assets/ChangesSummary-BjNMwGIZ.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-BQOEtv-R.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-D_N9188T.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-8bDSphY1.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-C7_JADb7.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-B22yRPyV.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-Arv4Ac-b.js} +72 -72
- package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-BShNSbLf.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-xrS_AnfS.js} +1 -1
- package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-Bcr9T1jW.js} +18 -18
- package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-DXL2Sv40.js} +12 -12
- package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-BcjzRd7T.js} +36 -36
- package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DNYU9Ce0.js} +1 -1
- package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BKlWqjgN.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-1LlyEDEe.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-Dyy_iHl9.js} +1 -1
- package/src/ui/static/assets/MobileRunPicker-Cf5rm469.js +1 -0
- package/src/ui/static/assets/MobileRunTarget-C4M4YJJh.js +6 -0
- package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-BKVbxFZK.js} +1 -1
- package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Bi-28tJi.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-BtO3iSJ4.js +1 -0
- package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BgZ4VDC-.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-BVGbmVP7.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-dzPInzgb.js} +1 -1
- package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-LOf1PXlb.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-Ce4OI8lf.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-DFxCQ8cY.js} +48 -48
- package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DD-uj8gk.js} +115 -115
- package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-DDwFB4tA.js} +1 -1
- package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CkIpY3v3.js} +1 -1
- package/src/ui/static/assets/ScriptMappingPage-DQQoR6sR.js +1 -0
- package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-CenIxD7b.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-DAV_0y0m.js} +83 -83
- package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-CqSLFKT1.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BvqC9oKw.js} +14 -14
- package/src/ui/static/assets/TestExplorerPage-Bdnll77k.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-CCNE688A.js} +10 -10
- package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-T6D25i6-.js} +5 -5
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CoDk5eAS.js} +1 -1
- package/src/ui/static/assets/TestverMcpPage-Dte0qSXp.js +34 -0
- package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-BNroxCoo.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-BU4MuDJZ.js} +10 -10
- package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BP5k7AqE.js} +83 -83
- package/src/ui/static/assets/clipboard-BIEd7Ccc.js +1 -0
- package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-BPORgy-e.js} +1 -1
- package/src/ui/static/assets/index-BlA8ntjb.js +47 -0
- package/src/ui/static/assets/index-Co4_SlGD.css +1 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-B9ZRW6ts.js} +1 -1
- package/src/ui/static/assets/runSelected-BoPm1sz-.js +1 -0
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-B4Otsv-N.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector--JZhbYrT.js} +1 -1
- package/src/ui/static/assets/{useOwnership-U0AfKBRo.js → useOwnership-BhPOiYzy.js} +1 -1
- package/src/ui/static/assets/useSuites-GN_K2mHc.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-BGhkGHKy.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-DX5ES6x8.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-ommXjx0q.js} +2 -2
- package/src/ui/static/assets/useTestResults-DWjvm8gm.js +1 -0
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-Cm92aSc5.js} +1426 -1421
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +479 -479
- package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
- package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
- package/src/ui/static/assets/AboutPage-CjEqKB-q.js +0 -1
- package/src/ui/static/assets/AdvancedPage-4kAcpE8Y.js +0 -3
- package/src/ui/static/assets/AuditLogPage-BQjOzQje.js +0 -1
- package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
- package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
- package/src/ui/static/assets/MobileRunPicker-0h-N2c6d.js +0 -1
- package/src/ui/static/assets/MobileRunTarget-Bo_xekig.js +0 -6
- package/src/ui/static/assets/PipelinesPanel-PmmPu8pj.js +0 -1
- package/src/ui/static/assets/ScriptMappingPage-7vHuvhQw.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-gYLhCD4d.js +0 -7
- package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
- package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +0 -1
- package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
- package/src/ui/static/assets/useTestResults-D5EwGIX9.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
var sr=Object.defineProperty;var ar=(s,i,o)=>i in s?sr(s,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[i]=o;var Ws=(s,i,o)=>ar(s,typeof i!="symbol"?i+"":i,o);import{u as ss,r as n,j as e,n as na,L as kt,b as rr}from"./vendor-react-CTbHBddL.js";import{b as ia,N as nr,O as ir,h as or,P as lr,Q as dr,S as Js,T as Gs,U as cr,V as Ks,W as xr,X as ur,j as mr,Y as pr,Z as oa,_ as hr,$ as fr,a0 as gr,a1 as as,a2 as br,x as yr,a3 as vr,a4 as kr,a5 as jr,a6 as wr,a7 as Nr,a8 as Sr,a9 as Cr,aa as Vs,ab as $r,ac as Ar,ad as Ir,ae as Jt,af as Tr,ag as Rr,ah as zr,ai as Er,aj as Mr,ak as Dr,al as Pr,am as Lr,an as Or}from"./index-BYVxKLrT.js";import{u as qr}from"./RemoteFileStrip-WuRKtx_h.js";import{G as Fr,K as rs,J as ns,a6 as is,C as Br,O as la,y as ze,ag as Ye,bc as Hr,Z as da,bd as Yt,r as Be,_ as os,a0 as jt,l as wt,b9 as Ur,at as _r,X as Ie,ah as ca,be as Wr,bf as Jr,g as Re,a5 as Nt,bg as yt,aL as xa,b as Gr,bh as Kr,bi as Vr,bj as ua,B as ma,v as pa,b4 as Qr,a_ as Yr,aJ as Xr,bk as Zr,T as en,bl as Gt,bm as Xt,h as Qs,a7 as Kt,b8 as tn,bn as sn,bo as an,bp as rn,b6 as nn,b7 as on,bq as ln,aE as dn,u as cn,al as Ys,t as ha,ap as Zt,aC as xn}from"./vendor-icons-BKPiFyYV.js";import{S as un,L as mn}from"./SearchableDevicePicker-BYxYJNWl.js";import{C as fa}from"./ConfirmDialog-t7mpeeSN.js";import{s as ga}from"./visibleInterval-BKsLfJZ3.js";import{t as pn,f as hn}from"./formatTestName-BKd2Uqhs.js";import{u as fn}from"./useTestExplorer-DT8frjCK.js";import{u as gn}from"./useFeatureFlags-DNkIctil.js";import{u as bn,e as yn,A as es,C as vn,S as kn,c as jn,s as wn}from"./AIStreamUI-C3D989_6.js";import{a as ba,u as ls,c as ya}from"./vendor-query-BrzmPFT3.js";import{R as Nn}from"./ReportCard-G52Q6-2i.js";import{L as Sn,a as Cn,A as Xs,P as $n,b as An,T as In,C as Tn}from"./ChangesSummary-CY_Vb27i.js";import{H as Rn,P as Zs}from"./hiddenLlmProviders-CdhhNa5G.js";import{T as zn}from"./TestverCreditsRing-DpMzl3h7.js";import{D as En}from"./DiffViewer-BIU09a_i.js";import{F as va}from"./index-DpQhqcHv.js";import{u as ka}from"./useChartTheme-BFz2QcND.js";import"./formatDate-T65-Y6Mi.js";import"./KpiTile-inmeEsy3.js";import"./vendor-charts-DWFQlmCz.js";import"./useTabParam-ChbOedP1.js";import"./MediaModal-C5n6sHYi.js";function Mn({texts:s,enabled:i}){const o=ss(),{toast:h}=ia(),d=nr(),m=ir(),{check:b,byPath:j}=qr(),[f,$]=n.useState(null);if(!i||!b||j.size===0)return null;const k=s.join(`
|
|
2
|
-
`);let y=null;for(const A of j.keys()){const I=A.split("/").pop()??A;if(k.includes(A)||I.length>3&&k.includes(I)){y=A;break}}if(!y)return null;const w=`${b.upstreamSha}:${y}`;if(f===w)return null;const g=j.get(y),l=or(b),S=b.dirtyFiles.includes(b.projectPrefix+y),c=b.verdict==="uncommitted_overlap"||b.verdict==="will_conflict";return e.jsx("div",{className:"flex-shrink-0 px-6 pt-2 pb-1 bg-white dark:bg-white/[0.02]",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-md border border-amber-500/30 bg-amber-500/5 dark:bg-amber-500/10",role:"status",children:[e.jsx(Fr,{size:14,className:"text-amber-600 dark:text-amber-400 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 text-xs text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"font-mono font-semibold",children:y})," changed on ",l,g.author?e.jsxs(e.Fragment,{children:[" ",lr(g.timestamp)," (",g.author,": “",g.message,"”)"]}):null,".",S?" You also have uncommitted edits in it.":""," Your copy is behind — pull first so the assistant doesn't work on old code?"]}),c||S?e.jsx("button",{onClick:()=>o("/git"),className:"px-2.5 py-1 rounded-md text-[11px] font-medium bg-amber-500/20 hover:bg-amber-500/30 text-amber-700 dark:text-amber-300 border border-amber-500/40 transition-colors whitespace-nowrap",children:"Open Git"}):e.jsx("button",{disabled:m,onClick:()=>d.mutate(void 0,{onSuccess:A=>{var I;if(A.conflicts&&((I=A.conflictedPaths)!=null&&I.length)){o("/git");return}h("success",`Pulled from ${l}`)},onError:A=>h("error",`Pull failed: ${A.message}`)}),className:"px-2.5 py-1 rounded-md text-[11px] font-medium bg-amber-500/20 hover:bg-amber-500/30 text-amber-700 dark:text-amber-300 border border-amber-500/40 transition-colors whitespace-nowrap disabled:opacity-50",children:"Pull now"}),e.jsx("button",{onClick:()=>o("/git?incoming=1"),className:"px-2.5 py-1 rounded-md text-[11px] font-medium text-amber-700 dark:text-amber-300 hover:bg-amber-500/10 transition-colors whitespace-nowrap",children:"View the change"}),e.jsx("button",{onClick:()=>$(w),className:"px-2.5 py-1 rounded-md text-[11px] text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 transition-colors whitespace-nowrap",children:"Continue anyway"})]})})})}const oe=[{value:"web",label:"Web",description:"Tests, page objects, locators, fixes",Icon:rs,colorClass:"text-blue-500 dark:text-blue-400"},{value:"mobile",label:"Mobile",description:"iOS / Android via Appium — local or cloud devices",Icon:ns,colorClass:"text-indigo-500 dark:text-indigo-400"},{value:"api",label:"API",description:"Endpoints, schemas, collections, chains",Icon:is,colorClass:"text-purple-500 dark:text-purple-400"},{value:"reporting",label:"Reporting",description:"Analytics, charts, summaries, exports",Icon:Br,colorClass:"text-emerald-500 dark:text-emerald-400"},{value:"ask",label:"Ask",description:"What the app you are testing does, from what we know",Icon:la,colorClass:"text-cyan-500 dark:text-cyan-400"}];function Dn({value:s,onChange:i,disabled:o,availableModes:h}){const[d,m]=n.useState(!1),[b,j]=n.useState(!1),f=n.useRef(null),$=n.useRef(null),k=h?oe.filter(l=>h.includes(l.value)):oe,y=oe.find(l=>l.value===s)??k[0]??oe[0],w=y.Icon;n.useEffect(()=>{if(!d)return;const l=c=>{var A,I;(A=$.current)!=null&&A.contains(c.target)||(I=f.current)!=null&&I.contains(c.target)||m(!1)},S=c=>{var A;c.key==="Escape"&&(m(!1),(A=f.current)==null||A.focus())};return document.addEventListener("mousedown",l),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",S)}},[d]);const g=()=>{if(!o){if(f.current){const l=f.current.getBoundingClientRect(),S=56*k.length+16,c=window.innerHeight-l.bottom;j(c<S+8)}m(l=>!l)}};return e.jsxs("div",{className:"relative inline-block",children:[e.jsxs("button",{ref:f,type:"button",onClick:g,disabled:o,title:`Mode: ${y.label}`,"aria-haspopup":"listbox","aria-expanded":d,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(w,{size:13,className:y.colorClass}),e.jsx("span",{children:y.label}),e.jsx(ze,{size:10,className:`flex-shrink-0 transition-transform ${d?"rotate-180":""}`})]}),d&&e.jsx("div",{ref:$,role:"listbox","aria-label":"Chat mode",className:`absolute z-50 ${b?"bottom-full mb-1":"top-full mt-1"} left-0
|
|
3
|
-
w-60 rounded-xl border border-white/10 bg-surface-1 shadow-xl py-1 overflow-hidden`,children:k.map(l=>{const S=l.Icon,c=l.value===s;return e.jsxs("button",{type:"button",role:"option","aria-selected":c,onClick:()=>{i(l.value),m(!1)},className:`w-full flex items-start gap-2 px-3 py-2 text-left text-xs transition-colors
|
|
4
|
-
${c?"bg-brand-500/10 text-brand-300":"text-gray-400 hover:bg-brand-500/10 hover:text-gray-200"}`,children:[e.jsx(S,{size:13,className:`${l.colorClass} flex-shrink-0 mt-0.5`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium",children:l.label}),c&&e.jsx(Ye,{size:12,className:"text-brand-400"})]}),e.jsx("div",{className:"text-[10px] opacity-70 leading-snug",children:l.description})]})]},l.value)})})]})}function Pn({mode:s,className:i=""}){const o=oe.find(d=>d.value===s)??oe[0],h=o.Icon;return e.jsx("span",{className:`inline-flex items-center justify-center ${i}`,title:`${o.label} mode`,"aria-label":`${o.label} mode`,children:e.jsx(h,{size:13,className:o.colorClass})})}const Vt=[{value:"manual",label:"Manual",description:"Ask before each action that changes something",Icon:Hr,colorClass:"text-gray-400"},{value:"auto",label:"Auto",description:"Approve actions automatically for this chat — deleting files, sending email and logins still ask",Icon:da,colorClass:"text-amber-500 dark:text-amber-400"}];function Ln({value:s,onChange:i,disabled:o}){const[h,d]=n.useState(!1),[m,b]=n.useState(!1),j=n.useRef(null),f=n.useRef(null),$=Vt.find(w=>w.value===s)??Vt[0],k=$.Icon;n.useEffect(()=>{if(!h)return;const w=g=>{var l,S;(l=f.current)!=null&&l.contains(g.target)||(S=j.current)!=null&&S.contains(g.target)||d(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[h]);const y=()=>{if(!o){if(j.current){const w=j.current.getBoundingClientRect();b(window.innerHeight-w.bottom<140)}d(w=>!w)}};return e.jsxs("div",{className:"relative inline-block",children:[e.jsxs("button",{ref:j,type:"button",onClick:y,disabled:o,title:s==="auto"?"Permissions: Auto — actions are approved without asking (deleting files, sending email and logins still ask)":"Permissions: Manual — asks before each action","aria-label":`Permissions: ${$.label}`,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors disabled:opacity-50 disabled:cursor-not-allowed
|
|
5
|
-
${s==="auto"?"text-amber-600 dark:text-amber-300 bg-amber-500/10 hover:bg-amber-500/15":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,children:[e.jsx(k,{size:13,className:$.colorClass}),e.jsx("span",{children:$.label}),e.jsx(ze,{size:10,className:`flex-shrink-0 transition-transform ${h?"rotate-180":""}`})]}),h&&e.jsx("div",{ref:f,role:"listbox","aria-label":"Tool permissions",className:`absolute z-50 ${m?"bottom-full mb-1":"top-full mt-1"} left-0
|
|
6
|
-
w-64 rounded-xl border border-white/10 bg-surface-1 shadow-xl py-1 overflow-hidden`,children:Vt.map(w=>{const g=w.Icon,l=w.value===s;return e.jsxs("button",{type:"button",role:"option","aria-selected":l,onClick:()=>{i(w.value),d(!1)},className:`w-full flex items-start gap-2 px-3 py-2 text-left text-xs transition-colors
|
|
7
|
-
${l?"bg-brand-500/10 text-brand-300":"text-gray-400 hover:bg-brand-500/10 hover:text-gray-200"}`,children:[e.jsx(g,{size:13,className:`${w.colorClass} flex-shrink-0 mt-0.5`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium",children:w.label}),l&&e.jsx(Ye,{size:12,className:"text-brand-400"})]}),e.jsx("div",{className:"text-[10px] opacity-70 leading-snug",children:w.description})]})]},w.value)})})]})}const ds=[".pdf",".docx",".xlsx",".csv",".txt",".md",".html",".htm",".xml",".json",".yaml",".yml",".toml",".ini",".cfg",".properties",".env.example",".har",".proto",".graphql",".gql",".wsdl",".xsd",".js",".mjs",".cjs",".ts",".jsx",".tsx",".py",".java",".kt",".cs",".rb",".go",".rs",".feature",".gherkin",".robot",".sh",".bat",".css",".scss"],cs="PDF, Word (.docx), Excel, CSV, text and config files, and code or test files",On=[".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".tif",".tiff",".heic",".doc",".xls",".ppt",".pptx",".odt",".rtf",".epub",".zip",".gz",".tgz",".tar",".7z",".mp3",".mp4",".wav",".mov",".webm",".ogg",".m4a",".bin",".dat",".parquet",".avro",".pem",".crt",".cer",".der",".key",".p12",".pfx",".jks"],qn={".doc":"legacy Word format cannot be read — save it as .docx",".xls":"legacy Excel 97–2003 format cannot be read — save it as .xlsx",".ppt":"PowerPoint is not supported — export the slides to PDF",".pptx":"PowerPoint is not supported — export the slides to PDF",".png":"images cannot be read by the assistant yet — paste the text, or describe what the image shows",".jpg":"images cannot be read by the assistant yet — paste the text, or describe what the image shows",".jpeg":"images cannot be read by the assistant yet — paste the text, or describe what the image shows",".gif":"images cannot be read by the assistant yet",".webp":"images cannot be read by the assistant yet",".svg":"images cannot be read by the assistant yet",".bmp":"images cannot be read by the assistant yet",".zip":"archives are not supported — upload the files inside it",".apk":"app builds are uploaded in the Mobile session bar or Settings → General → App Builds, not into the chat",".ipa":"app builds are uploaded in the Mobile session bar or Settings → General → App Builds, not into the chat"};function Fn(s,i=ds){const o=s.toLowerCase();return i.some(h=>o.endsWith(h))}function Bn(s,i=cs){const o=s.toLowerCase(),h=o.lastIndexOf("."),d=h>=0?o.slice(h):"",m=d&&qn[d];return m?`${s}: ${m}.`:`${s}: ${d?`${d} files are`:"files without an extension are"} not supported. Supported: ${i}.`}function Hn(s,i,o){const h=(i==null?void 0:i.extensions)??[...ds,...o??[]],d=(i==null?void 0:i.summary)??cs,m=(i==null?void 0:i.maxBytes)??20*1024*1024,b=[],j=[];for(const f of s)Fn(f.name,h)?f.size>m?j.push(`${f.name}: larger than ${Math.round(m/1024/1024)} MB.`):b.push(f):j.push(Bn(f.name,d));return{accepted:b,rejected:j}}function Un({onSessionChange:s}){const{toast:i}=ia(),[o,h]=n.useState([]),[d,m]=n.useState("browserstack"),[b,j]=n.useState([]),[f,$]=n.useState([]),[k,y]=n.useState(""),[w,g]=n.useState(""),[l,S]=n.useState(null),[c,A]=n.useState(!1),[I,R]=n.useState(null),[L,v]=n.useState(null),[F,_]=n.useState(!1),[ee,re]=n.useState(null),[Y,B]=n.useState(!1),je=n.useRef(null),[te,Ee]=n.useState(null),X=n.useRef(null);X.current=l;const se=n.useRef(!1);se.current=c;const Z=n.useRef(s);Z.current=s;const V=n.useCallback(p=>{var C,z;((p==null?void 0:p.sessionId)??null)!==(((C=X.current)==null?void 0:C.sessionId)??null)&&(X.current=p,S(p),v(null),(z=Z.current)==null||z.call(Z,p))},[]);n.useEffect(()=>{let p=!1;const z=ga(async()=>{try{const O=await Gs();if(p||se.current||(Ee(O.session?O.context??null:null),!O.session&&O.starting))return;V(O.session??null)}catch{}},5e3);return()=>{p=!0,z()}},[V]);const K=na();n.useEffect(()=>{if(K!=null&&K.subscribe)return K.subscribe(p=>{if(!se.current){if(p.type==="mobile-session-started"){const C=p.session;C&&!C.external&&V(C)}else if(p.type==="mobile-session-closed"){V(null);const C=p.reason;C&&i("info",C)}}})},[K,V,i]),n.useEffect(()=>{(async()=>{try{const[p,C,z]=await Promise.all([dr(),Js(),Gs().catch(()=>({session:null}))]);h(p.providers),$(C.apps),z.session&&(S(z.session),s==null||s(z.session));const O=p.providers.find(P=>P.hasCredentials&&P.enabled);O&&m(O.id)}catch(p){R(p.message)}})()},[]);const ve=n.useCallback(async p=>{_(!0),R(null);try{const z=[...(await cr(p)).devices].sort((P,le)=>P.realMobile!==le.realMobile?P.realMobile?-1:1:P.name.localeCompare(le.name));j(z);const O=z.filter(P=>!P.unavailableReason);if(!k||!z.some(P=>P.id===k)){const P=O.find(le=>le.realMobile&&/iphone 15/i.test(le.name))||O.find(le=>le.realMobile&&/pixel/i.test(le.name))||O[0];y((P==null?void 0:P.id)??"")}}catch(C){R(C.message),j([])}finally{_(!1)}},[k]);n.useEffect(()=>{const p=o.find(C=>C.id===d);p!=null&&p.hasCredentials?ve(d):j([])},[d,o,ve]);const ae=async p=>{A(!0),R(null),re(0);const C=(p.size/1024/1024).toFixed(1);v(`Uploading ${p.name} (${C} MB)…`);try{const z=await ur(p,void 0,P=>re(P)),O=await Js();$(O.apps),g(z.id),v(`Added ${p.name}.`)}catch(z){R(z.message),v(null),console.error("[MobileDeviceBar] upload failed:",z)}finally{A(!1),re(null)}},E=async()=>{R(null);const p=b.find(C=>C.id===k);if(!p){R("Pick a device first.");return}if(!w){R("Pick or upload an app first.");return}A(!0),v(d==="local-appium"?"Starting local device session — this may take a moment.":"Starting cloud session — this can take 30–60 s on first launch.");try{l&&(await Ks().catch(()=>{}),S(null),s==null||s(null));const C=await xr({provider:d,deviceKey:p.rawDeviceKey,osVersion:p.os,platform:p.platform,appId:w,sessionName:"Testver AI Assistant"});S(C.session),s==null||s(C.session),v(`Session started on ${p.name} (${p.os}).`)}catch(C){R(C.message),v(null)}finally{A(!1)}},fe=async()=>{A(!0);try{await Ks(),S(null),s==null||s(null),v("Session ended.")}catch(p){R(p.message)}finally{A(!1)}},J=o.find(p=>p.id===d),T=!(J!=null&&J.hasCredentials);b.find(p=>p.id===k);const H=f.find(p=>p.id===w);n.useMemo(()=>{const p={};for(const C of b){const z=C.manufacturer||(C.platform==="ios"?"Apple":"Other");p[z]||(p[z]=[]),p[z].push(C)}return p},[b]);const ne=!!l||c;return e.jsxs("div",{className:"bg-white dark:bg-white/[0.03] border border-gray-200 dark:border-white/10 rounded-2xl mb-2",children:[e.jsxs("div",{className:"px-3 py-2 flex flex-wrap items-center gap-2 text-xs",children:[e.jsx(ns,{size:13,className:"text-indigo-500 dark:text-indigo-400"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-400 font-medium mr-1",children:"Mobile session"}),!l&&e.jsxs(e.Fragment,{children:[e.jsx(ea,{label:(J==null?void 0:J.displayName)||d,disabled:ne,widthClass:"w-40",children:o.map(p=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>m(p.id),className:`w-full flex items-center justify-between px-3 py-1.5 text-left text-xs hover:bg-gray-50 dark:hover:bg-white/5 ${p.id===d?"text-indigo-600 dark:text-indigo-300 bg-indigo-50/50 dark:bg-transparent":"text-gray-700 dark:text-gray-300"}`,children:[e.jsx("span",{children:p.displayName}),e.jsx("span",{className:`text-[10px] ${p.hasCredentials?"text-emerald-600 dark:text-emerald-400":"text-gray-400 dark:text-gray-500"}`,children:p.hasCredentials?"ready":"no creds"})]})},p.id))}),e.jsx("div",{className:"w-48 min-w-0 flex-shrink-0",children:e.jsx(un,{devices:b,selectedId:k,onSelect:p=>y(p.id),loading:F,disabled:ne||T,onRefresh:()=>void ve(d),placeholder:T?"(add creds in Connectors)":"Pick device",emptyText:d==="local-appium"?mn:void 0,variant:"compact"})}),e.jsxs(ea,{label:H?H.label||H.filename:"Pick app",disabled:ne,widthClass:"w-48",children:[e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[f.length===0&&e.jsx("li",{className:"px-3 py-2 text-xs text-gray-500",children:"No apps yet — upload an .apk or .ipa."}),f.map(p=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>g(p.id),className:`w-full flex items-center justify-between px-3 py-1.5 text-left text-xs hover:bg-gray-50 dark:hover:bg-white/5 ${p.id===w?"text-indigo-600 dark:text-indigo-300 bg-indigo-50/50 dark:bg-transparent":"text-gray-700 dark:text-gray-300"}`,children:[e.jsx("span",{className:"truncate max-w-[200px]",children:p.label||p.filename}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:[p.kind," · ",(p.size/1024/1024).toFixed(1)," MB"]})]})},p.id))]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-white/10 px-2 py-1",children:e.jsxs("button",{type:"button",onClick:p=>{var C;p.stopPropagation(),(C=je.current)==null||C.click()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1 text-[11px] text-indigo-600 hover:text-indigo-700 dark:text-indigo-300 dark:hover:text-indigo-200",children:[e.jsx(Yt,{size:11})," ",e.jsx("span",{title:"Android: .apk or .aab · real iPhone / iPad: .ipa · iOS simulator: the .app zipped",children:"Upload app build"})]})})]})]}),l&&L&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-emerald-600 dark:text-emerald-400",children:[e.jsx(Be,{size:11}),L]}),e.jsx("div",{className:"flex-1"}),l?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-emerald-600 dark:text-emerald-400 font-medium",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse"}),"Live · ",l.device]}),te&&te!=="NATIVE_APP"&&e.jsx("span",{title:`Automation context: ${te} — the AI is interacting with web content inside the app`,className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/10 border border-amber-500/30 text-amber-700 dark:text-amber-300 max-w-[10rem] truncate",children:te}),l.liveViewUrl&&e.jsxs("a",{href:l.liveViewUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-indigo-600 hover:text-indigo-700 dark:text-indigo-300 dark:hover:text-indigo-200",children:["View ",e.jsx(os,{size:10})]}),e.jsx("button",{type:"button",disabled:c,onClick:()=>B(!0),className:"h-8 px-3 text-xs rounded-lg border border-red-200 dark:border-red-500/30 text-red-600 dark:text-red-300 bg-white dark:bg-transparent hover:bg-red-50 dark:hover:bg-red-500/10 disabled:opacity-40 transition-colors",children:c?"Ending…":"End session"}),e.jsx(fa,{open:Y,title:"End mobile session?",description:`This disconnects "${l.device}" and closes the Appium session — the AI Assistant can no longer see or interact with the device, and any in-progress action on it stops. `+(l.providerId==="local-appium"?"Starting again boots a fresh session on the device.":"Starting again boots a fresh cloud session, which takes a moment and consumes provider device minutes."),confirmLabel:"End session",cancelLabel:"Keep session",onConfirm:()=>{B(!1),fe()},onCancel:()=>B(!1)})]}):e.jsx("button",{type:"button",disabled:c||T||!k||!w,onClick:E,title:k?w?void 0:"Pick an app first":"Pick a device first",className:"h-8 px-3 text-xs rounded-lg bg-indigo-600 hover:bg-indigo-500 text-white font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:c?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(jt,{size:11,className:"animate-spin"})," Starting…"]}):"Start session"})]}),(I||L&&!l)&&e.jsxs("div",{className:`px-3 pb-2 text-[11px] flex items-center gap-1.5 ${I?"text-red-600 dark:text-red-300":"text-gray-600 dark:text-gray-400"}`,children:[I?e.jsx(wt,{size:11}):e.jsx(Be,{size:11}),e.jsxs("span",{children:[I||L,ee!==null&&e.jsxs("span",{className:"ml-2 text-indigo-600 dark:text-indigo-300",children:[Math.round(ee*100),"%"]})]})]}),ee!==null&&e.jsx("div",{className:"h-0.5 bg-gray-100 dark:bg-white/[0.04] rounded-b-2xl overflow-hidden",children:e.jsx("div",{className:"h-full bg-indigo-500 dark:bg-indigo-400 transition-[width] duration-200",style:{width:`${Math.round(ee*100)}%`}})}),e.jsx("input",{ref:je,type:"file",accept:".apk,.aab,.ipa,.zip,application/vnd.android.package-archive,application/zip,application/octet-stream",hidden:!0,onChange:p=>{var z;const C=(z=p.target.files)==null?void 0:z[0];C&&ae(C),p.target.value=""}})]})}function ea({label:s,children:i,disabled:o,wide:h,widthClass:d}){const[m,b]=n.useState(!1),[j,f]=n.useState(!1),$=n.useRef(null),k=n.useRef(null);n.useEffect(()=>{if(!m)return;const w=g=>{var l;(l=$.current)!=null&&l.contains(g.target)||b(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[m]);const y=()=>{if(!o){if(!m&&k.current){const w=k.current.getBoundingClientRect(),g=320,l=window.innerHeight-w.bottom,S=w.top;f(l<g+16&&S>l)}b(w=>!w)}};return e.jsxs("div",{className:`relative ${d?`${d} min-w-0 flex-shrink-0`:""}`,ref:$,children:[e.jsxs("button",{ref:k,type:"button",disabled:o,onClick:y,className:`h-8 flex items-center gap-1.5 px-2.5 rounded-lg border border-gray-200 dark:border-white/10
|
|
8
|
-
bg-white dark:bg-white/[0.04] hover:border-gray-300 dark:hover:border-white/20
|
|
9
|
-
text-gray-800 dark:text-gray-200 text-xs transition-colors
|
|
10
|
-
${d?"w-full min-w-0 justify-between":""}
|
|
11
|
-
${o?"opacity-50 cursor-not-allowed":""}`,title:s,children:[e.jsx("span",{className:`truncate min-w-0 ${d?"flex-1":"max-w-[220px]"}`,children:s}),e.jsx(ze,{size:11,className:`text-gray-500 transition-transform flex-shrink-0 ${m?"rotate-180":""}`})]}),m&&e.jsx("div",{onClick:()=>b(!1),className:`absolute z-50 left-0 ${h?"w-[320px]":"w-[240px]"} rounded-lg border border-gray-200 dark:border-white/10
|
|
12
|
-
bg-white dark:bg-surface-1 shadow-xl overflow-hidden ${j?"bottom-full mb-1":"top-full mt-1"}`,children:e.jsx("ul",{children:i})})]})}function _n(){const[s,i]=n.useState(null),[o,h]=n.useState(),d=ss();if(n.useEffect(()=>{const b=async()=>{var j;try{const f=mr(),$=await fetch("/api/local-browser/status",{headers:f?{Authorization:`Bearer ${f}`}:{}});if(!$.ok){i(!1);return}const k=await $.json();i(!!k.connected),h((j=k==null?void 0:k.client)==null?void 0:j.machine)}catch{i(!1)}};return b(),ga(b,5e3)},[]),s===null)return null;const m=()=>d("/connectors");return s?e.jsxs("button",{onClick:m,className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-[10px] font-medium text-emerald-300 bg-emerald-500/10 border border-emerald-500/20 hover:bg-emerald-500/20 transition-colors",title:o?`Browser actions run on ${o}`:"Browser actions run on your machine",children:[e.jsx(Ur,{className:"w-3 h-3"}),"Local",o?` (${o.slice(0,18)})`:""]}):e.jsxs("button",{onClick:m,className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-[10px] font-medium text-gray-400 bg-surface-2/40 border border-white/5 hover:bg-surface-2/70 hover:text-gray-200 transition-colors",title:"Browser actions run on the server. Click to set up a local connector.",children:[e.jsx(_r,{className:"w-3 h-3"}),"Server"]})}function Qt(s){if(!s)return"";const i=Math.floor((Date.now()-s)/864e5);if(i<=0)return"today";if(i===1)return"yesterday";if(i<30)return`${i} days ago`;const o=Math.floor(i/30);return o===1?"a month ago":`${o} months ago`}function Ve({dot:s,label:i,count:o,detail:h,empty:d}){return e.jsxs("div",{className:`rounded-xl border px-3 py-2.5 ${d?"border-black/5 dark:border-white/5 bg-transparent":"border-black/[0.06] dark:border-white/[0.07] bg-white dark:bg-surface-1"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${d?"bg-gray-400/40":s}`}),e.jsx("span",{className:`text-[12.5px] font-semibold ${d?"text-gray-400 dark:text-gray-600":"text-gray-800 dark:text-gray-200"}`,children:i}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:`text-[11px] ${d?"text-gray-400 dark:text-gray-600":"text-gray-500 dark:text-gray-400"}`,children:o})]}),h&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-gray-500 dark:text-gray-500",children:h})]})}function Wn(){const s=ba(),{data:i}=ls({queryKey:["ask-feedback-summary"],queryFn:()=>oa(),staleTime:3e4}),o=ya({mutationFn:m=>hr(m),onSuccess:()=>s.invalidateQueries({queryKey:["ask-feedback-summary"]})});if(!i||i.misses.length===0&&i.unhelpful.length===0)return null;const h=i.misses.slice(0,5),d=i.unhelpful.slice(0,3);return e.jsxs("div",{"data-testid":"ask-gaps",children:[e.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] uppercase text-gray-500 dark:text-gray-500",children:"What Ask couldn't answer"}),h.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"text-[11.5px] text-gray-500 dark:text-gray-400",children:"Searches that found nothing"}),e.jsx("ul",{className:"mt-1 flex flex-col gap-1",children:h.map(m=>e.jsxs("li",{className:"group flex items-center gap-2 text-[12px] text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",title:m.query,children:m.query}),m.count>1&&e.jsxs("span",{className:"text-[11px] tabular-nums text-gray-500",children:[m.count,"×"]}),e.jsx("button",{type:"button",onClick:()=>o.mutate(m.query),title:"Dismiss — it has been filled, or was not a real gap","aria-label":`Dismiss "${m.query}"`,className:"opacity-0 group-hover:opacity-100 focus:opacity-100 p-0.5 rounded text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",children:e.jsx(Ie,{size:11})})]},m.query))})]}),d.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"text-[11.5px] text-gray-500 dark:text-gray-400",children:["Answers marked not helpful",i.down>d.length?` (${i.down})`:""]}),e.jsx("ul",{className:"mt-1 flex flex-col gap-1.5",children:d.map(m=>e.jsxs("li",{className:"text-[12px] leading-snug text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"block truncate",title:m.question,children:m.question||"An answer"}),m.note&&e.jsxs("span",{className:"block text-[11.5px] text-gray-500 dark:text-gray-400 line-clamp-2",title:m.note,children:["“",m.note,"”"]})]},m.id))})]}),e.jsxs("div",{className:"mt-2 text-[11px] leading-relaxed text-gray-500 dark:text-gray-500",children:["An exploration run that reaches these areas, or a ",e.jsx(kt,{to:"/sources",className:"text-cyan-700 dark:text-cyan-300 underline underline-offset-2",children:"document"})," that covers them, fills the gap."]})]})}function Jn(){var b,j,f;const[s,i]=n.useState(null),[o,h]=n.useState(!1);if(n.useEffect(()=>{let $=!0;return pr().then(k=>{$&&i(k)}).catch(()=>{$&&h(!0)}),()=>{$=!1}},[]),o)return e.jsxs("div",{className:"w-[300px] flex-shrink-0 border-l border-black/[0.06] dark:border-white/[0.07] px-5 py-6",children:[e.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] uppercase text-gray-500 dark:text-gray-500",children:"What I know from"}),e.jsx("div",{className:"mt-1 text-[12px] text-amber-600 dark:text-amber-400",role:"status",children:"Could not read what is recorded right now. Ask still works; reopen this mode to try again."})]});const d=s?s.observed.pages+s.observed.notes+s.observed.findings:0,m=!!s&&s.tiersWithContent===0&&!((b=s.automation)!=null&&b.tests);return e.jsxs("div",{className:"w-[300px] flex-shrink-0 border-l border-black/[0.06] dark:border-white/[0.07] px-5 py-6 flex flex-col gap-4 overflow-y-auto",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] uppercase text-gray-500 dark:text-gray-500",children:"What I know from"}),e.jsx("div",{className:"mt-1 text-[12px] text-gray-500 dark:text-gray-400",children:s?m?"Nothing recorded yet":`${s.tiersWithContent+((j=s.automation)!=null&&j.tests?1:0)} of ${(s.reported?4:3)+(s.automation?1:0)} kinds of record${s.observed.latestAt?` · newest ${Qt(s.observed.latestAt)}`:""}`:"Reading…"})]}),s&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ve,{dot:"bg-emerald-400",label:"Exploration",count:d?s.observed.pages?`${s.observed.pages} page${s.observed.pages===1?"":"s"}`:`${d} record${d===1?"":"s"}`:"none",empty:!d,detail:s.observed.latestRunId?`${s.observed.runs>1?`${s.observed.runs} runs · latest `:"run "}${s.observed.latestRunId} · ${Qt(s.observed.latestAt)}${(f=s.observed.roles)!=null&&f.length?` · ${s.observed.roles.join(", ")}`:""}`:"No run has walked this app"}),s.reported&&e.jsx(Ve,{dot:"bg-rose-400",label:"Defects",count:s.reported.open+s.reported.resolved?`${s.reported.open} open`:"none",empty:!(s.reported.open+s.reported.resolved),detail:s.reported.open+s.reported.resolved?`${s.reported.resolved} fixed · rejected ones are left out`:"No defects logged"}),e.jsx(Ve,{dot:"bg-blue-400",label:"Test management",count:s.asserted.cases?`${s.asserted.cases} case${s.asserted.cases===1?"":"s"}`:"none",empty:!s.asserted.cases,detail:s.asserted.cases?`${s.asserted.automated} automated · ${s.asserted.cases-s.asserted.automated} manual`:"No test cases recorded"}),s.automation&&e.jsx(Ve,{dot:"bg-violet-400",label:"Automated tests",count:s.automation.tests?`${s.automation.tests} test${s.automation.tests===1?"":"s"}`:"none",empty:!s.automation.tests,detail:s.automation.tests?`${s.automation.failing} failing · ${s.automation.neverRun} never run${s.automation.latestAt?` · last run ${Qt(s.automation.latestAt)}`:""}`:"No test files in this repository"}),e.jsx(Ve,{dot:"bg-amber-400",label:"Documents",count:s.stated.sources?`${s.stated.sources} document${s.stated.sources===1?"":"s"}`:"none",empty:!s.stated.sources&&!s.stated.requirements,detail:s.stated.titles.length?s.stated.titles.join(", "):s.stated.requirements?`${s.stated.requirements} requirements`:"No PRD or flow doc registered"})]}),e.jsx(Wn,{}),m?e.jsx("div",{className:"rounded-xl border border-cyan-500/20 bg-cyan-500/[0.05] px-3 py-2.5",children:e.jsxs("div",{className:"text-[11.5px] leading-relaxed text-gray-600 dark:text-gray-400",children:["Ask has nothing to answer from. Run ",e.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:"Explore & Automate"})," in Web mode, or ",e.jsx(kt,{to:"/sources",className:"font-medium text-cyan-700 dark:text-cyan-300 underline underline-offset-2",children:"add a PRD or flow document"}),", and this fills in."]})}):e.jsx("div",{className:"rounded-xl border border-cyan-500/20 bg-cyan-500/[0.05] px-3 py-2.5",children:e.jsx("div",{className:"text-[11.5px] leading-relaxed text-gray-600 dark:text-gray-400",children:"Ask reads only what is already recorded. It never opens the app."})})]})}function Gn({feedback:s,answer:i}){var g;const o=ba(),{data:h}=ls({queryKey:["ask-rating",s.answerId],queryFn:()=>oa([s.answerId]),staleTime:1/0}),d=(g=h==null?void 0:h.ratings)==null?void 0:g[s.answerId],[m,b]=n.useState(!1),[j,f]=n.useState(""),[$,k]=n.useState(!1),y=ya({mutationFn:l=>fr({answerId:s.answerId,sessionId:s.sessionId,question:s.question,answer:wn(i).slice(0,400),rating:l.rating,note:l.note}),onSuccess:l=>{o.setQueryData(["ask-rating",s.answerId],S=>({...S??{},ratings:{...(S==null?void 0:S.ratings)??{},[s.answerId]:l.rating}})),o.invalidateQueries({queryKey:["ask-feedback-summary"]}),k(!0),setTimeout(()=>k(!1),2e3)}}),w=l=>`inline-flex items-center rounded-md p-1 transition-colors ${l?"text-cyan-700 dark:text-cyan-400 bg-cyan-500/10":"text-gray-500 hover:text-gray-800 hover:bg-black/[0.04] dark:hover:text-gray-200 dark:hover:bg-white/[0.05]"}`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Helpful answer",title:"Helpful","aria-pressed":d==="up","data-testid":"ask-rate-up",disabled:y.isPending,onClick:()=>{b(!1),y.mutate({rating:"up"})},className:w(d==="up"),children:e.jsx(Wr,{size:12})}),e.jsx("button",{type:"button","aria-label":"Not helpful",title:"Not helpful — tell us what was wrong","aria-pressed":d==="down","data-testid":"ask-rate-down",disabled:y.isPending,onClick:()=>b(l=>!l),className:w(d==="down"||m),children:e.jsx(Jr,{size:12})}),$&&e.jsx("span",{className:"text-[11px] text-gray-500",role:"status",children:"Thanks"}),m&&e.jsxs("form",{className:"basis-full mt-1.5 flex flex-wrap items-start gap-2",onSubmit:l=>{l.preventDefault(),y.mutate({rating:"down",note:j}),b(!1),f("")},children:[e.jsx("textarea",{autoFocus:!0,value:j,onChange:l=>f(l.target.value),rows:2,maxLength:600,placeholder:"What was wrong or missing? (optional)","aria-label":"What was wrong or missing",className:"flex-1 min-w-[16rem] rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-2.5 py-1.5 text-[12px] text-gray-800 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-cyan-400/40"}),e.jsx("button",{type:"submit",disabled:y.isPending,"data-testid":"ask-rate-send",className:"rounded-md bg-cyan-600 hover:bg-cyan-700 px-2.5 py-1.5 text-[12px] font-medium text-white disabled:opacity-60",children:"Send"})]})]})}function Kn(s){return s.replace(/\[\[(?:[^\]]|\](?!\]))*$/,"").trimEnd()}function Vn({text:s,feedback:i}){const o=bn(Kn(s)),h=yn(o),[d,m]=n.useState(!1),b=async()=>{try{await navigator.clipboard.writeText(jn(o)),m(!0),setTimeout(()=>m(!1),1500)}catch{}},j=e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>void b(),"aria-label":"Copy answer with its sources",title:"Copy answer with its sources",className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] text-gray-500 hover:text-gray-800 hover:bg-black/[0.04] dark:hover:text-gray-200 dark:hover:bg-white/[0.05] transition-colors",children:[d?e.jsx(Ye,{size:12}):e.jsx(ca,{size:12}),d?"Copied":"Copy"]}),i&&e.jsx(Gn,{feedback:i,answer:o})]});return h.length===0?e.jsxs(e.Fragment,{children:[e.jsx(es,{text:o}),j]}):e.jsxs(vn,{citations:h,children:[e.jsx(es,{text:o}),e.jsx(kn,{citations:h}),j]})}function Qn({result:s}){var h,d,m,b;const[i,o]=n.useState(()=>s.spec&&!s.saved?{state:"ready",spec:s.spec}:{state:"loading"});return n.useEffect(()=>{let j=!1;return(async()=>{var $;try{const k=await gr(s.id);j||o({state:"ready",spec:k.spec,saved:k});return}catch{}if(s.saved){j||o({state:"error",message:"This saved report is no longer available."});return}if(s.spec)return;const f=s.specUrl||(($=s.urls)==null?void 0:$.json);if(!f){j||o({state:"error",message:"This dashboard has no data file."});return}try{const k=await fetch(as(f),{cache:"no-store"});if(!k.ok)throw new Error(k.status===404?"The dashboard file is no longer on disk.":`HTTP ${k.status}`);const y=await k.json();j||o({state:"ready",spec:y})}catch(k){j||o({state:"error",message:k instanceof Error?k.message:String(k)})}})(),()=>{j=!0}},[s.id,s.saved,s.spec,s.specUrl,(h=s.urls)==null?void 0:h.json]),i.state==="loading"?e.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-white/10 px-5 py-6 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(jt,{size:14,className:"animate-spin"})," Loading dashboard",s.title?` “${s.title}”`:"","…"]}):i.state==="error"?e.jsxs("div",{className:"rounded-2xl border border-rose-500/30 bg-rose-500/5 px-5 py-4 flex items-start gap-2 text-xs text-gray-700 dark:text-gray-300",children:[e.jsx(wt,{size:14,className:"text-rose-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium",children:["Dashboard",s.title?` “${s.title}”`:""," could not be shown"]}),e.jsx("div",{className:"text-gray-500 dark:text-gray-400 mt-0.5",children:i.message})]})]}):e.jsx(Nn,{spec:i.spec,urls:s.urls,savedId:(d=i.saved)==null?void 0:d.id,initialShareToken:(m=i.saved)==null?void 0:m.shareToken,initialShareExpiresAt:(b=i.saved)==null?void 0:b.shareExpiresAt})}function Yn({url:s,filename:i,height:o=520}){var b;const h=as(s),d=(i||((b=s.split("/").pop())==null?void 0:b.split("?")[0])||"document.pdf").replace(/^\d{10,}-/,""),m=h+(h.includes("#")?"":"#toolbar=0&view=FitH");return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-100 dark:border-white/5",children:[e.jsx(Re,{size:14,className:"text-rose-500 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-gray-700 dark:text-gray-300 font-medium truncate flex-1",children:d}),e.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",title:"Open in new tab",className:"p-1 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:e.jsx(os,{size:13})}),e.jsx("a",{href:h,download:d,title:"Download",className:"p-1 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:e.jsx(Nt,{size:13})})]}),e.jsx("iframe",{src:m,title:d,className:"w-full bg-gray-50 dark:bg-black/30",style:{height:o}})]})}const Xn={docx:{Icon:Re,iconCls:"text-sky-500",label:"Word document"},doc:{Icon:Re,iconCls:"text-sky-500",label:"Word document"},xlsx:{Icon:yt,iconCls:"text-emerald-500",label:"Excel workbook"},xls:{Icon:yt,iconCls:"text-emerald-500",label:"Excel workbook"},csv:{Icon:yt,iconCls:"text-emerald-500",label:"CSV file"}};function Zn({url:s,filename:i,size:o}){var f;const h=as(s),d=(i||((f=s.split("/").pop())==null?void 0:f.split("?")[0])||"document").replace(/^\d{10,}-/,""),m=(d.split(".").pop()||"").toLowerCase(),b=Xn[m]||{Icon:xa,iconCls:"text-gray-500",label:"Document"},{Icon:j}=b;return e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-100 dark:bg-white/[0.05] border border-gray-200 dark:border-white/5 flex items-center justify-center flex-shrink-0",children:e.jsx(j,{size:18,className:b.iconCls})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate",title:d,children:d}),e.jsxs("div",{className:"text-[11px] text-gray-500 flex items-center gap-1.5",children:[e.jsx("span",{children:b.label}),m&&e.jsx("span",{className:"uppercase px-1 py-px rounded border border-gray-200 dark:border-white/10 text-[9px] font-semibold tracking-wide",children:m}),o&&e.jsxs("span",{children:["· ",o]})]})]}),e.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",title:"Open in new tab",className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors flex-shrink-0",children:e.jsx(os,{size:14})}),e.jsxs("a",{href:h,download:d,title:"Download",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-white bg-brand-600 hover:bg-brand-500 transition-colors flex-shrink-0",children:[e.jsx(Nt,{size:13})," Download"]})]})})}class ta extends n.Component{constructor(){super(...arguments);Ws(this,"state",{error:null})}static getDerivedStateFromError(o){return{error:o}}componentDidCatch(o,h){console.error("[testver] render error contained:",o,h.componentStack)}render(){return this.state.error?this.props.fallback(this.state.error):this.props.children}}const Te=5,ei=[{id:"all",label:"All"},{id:"requirement",label:"Requirements"},{id:"nlp",label:"Notes"},{id:"jira",label:"JIRA"},{id:"document",label:"Other Sources"}],ti={requirement:"Requirement",nlp:"Note",jira:"JIRA",document:"Other source"};function ts({type:s,size:i=13,className:o=""}){const h=s==="requirement"?Gr:s==="nlp"?Kr:s==="jira"?Vr:ua;return e.jsx(h,{size:i,className:`flex-shrink-0 ${o}`})}function Qe(s){return s.type==="jira"&&s.jiraKey&&!s.title.toUpperCase().startsWith(s.jiraKey)?`${s.jiraKey}: ${s.title}`:s.title}const si=/\.(png|jpe?g|gif|webp|bmp|svg|tiff?|heic)$/i;function ja(s){return!s.repoPath&&s.textChars===0&&(!s.hasFile||si.test(s.fileName||""))}function wa(s){if(s.repoPath)return`project file · ${s.repoPath}`;if(ja(s))return s.fileName?`image · ${s.fileName}`:"no text";if(s.textChars>0){const i=s.textChars/1024;return`${i<1?"< 1":i<10?i.toFixed(1):Math.round(i)} KB text`}return s.hasFile?s.fileName?`file · ${s.fileName}`:"file":"no text"}function Na(s=!1,i=!0){return ls({queryKey:["source-summaries",s],queryFn:()=>br({includeArchived:s}),enabled:i,staleTime:3e4})}function Sa(s,i){const o=i.trim().toLowerCase();return o?s.filter(h=>h.title.toLowerCase().includes(o)||(h.jiraKey||"").toLowerCase().includes(o)||(h.fileName||"").toLowerCase().includes(o)||h.id.toLowerCase().includes(o)):s}function ai({open:s,onClose:i,selected:o,onAdd:h,askMode:d}){const[m,b]=n.useState("all"),[j,f]=n.useState(""),[$,k]=n.useState(!1),[y,w]=n.useState(new Map),{data:g,isLoading:l,error:S}=Na($,s);n.useEffect(()=>{s&&(w(new Map(o.map(v=>[v.id,v]))),f(""))},[s]),n.useEffect(()=>{if(!s)return;const v=F=>{F.key==="Escape"&&i()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s,i]);const c=(g==null?void 0:g.sources)??[],A=n.useMemo(()=>{const v={all:c.length};for(const F of c)v[F.type]=(v[F.type]??0)+1;return v},[c]),I=n.useMemo(()=>Sa(m==="all"?c:c.filter(v=>v.type===m),j),[c,m,j]);if(!s)return null;const R=y.size>=Te,L=v=>w(F=>{const _=new Map(F);return _.has(v.id)?_.delete(v.id):_.size<Te&&_.set(v.id,{id:v.id,title:v.title,type:v.type,jiraKey:v.jiraKey}),_});return rr.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-4","data-testid":"source-picker",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":d?"Answer from Sources":"Add from Sources",className:"relative w-full max-w-2xl max-h-[80vh] flex flex-col rounded-2xl border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start gap-3 px-5 pt-4 pb-3 border-b border-gray-200 dark:border-white/5",children:[e.jsx("span",{className:"mt-0.5 rounded-lg bg-brand-500/10 p-2 text-brand-500 dark:text-brand-300",children:e.jsx(ma,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:d?"Answer from Sources":"Add from Sources"}),e.jsx("p",{className:"text-[13px] text-gray-500 dark:text-gray-400",children:d?"The answer will come only from the sources you pick, with citations.":"The AI reads the picked sources with your message. Long documents: it gets the beginning and outline, and searches the rest."})]}),e.jsx("button",{type:"button",onClick:i,className:"p-1 rounded-md text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",title:"Close",children:e.jsx(Ie,{size:16})})]}),e.jsxs("div",{className:"px-5 pt-3 space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ei.map(v=>e.jsxs("button",{type:"button",onClick:()=>b(v.id),className:`px-2.5 py-1 rounded-lg text-[13px] transition-colors ${m===v.id?"bg-brand-500/15 text-brand-700 dark:text-brand-200 font-medium":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-white/5"}`,children:[v.label,A[v.id]?e.jsx("span",{className:"ml-1 text-gray-400",children:A[v.id]}):null]},v.id))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(pa,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{autoFocus:!0,value:j,onChange:v=>f(v.target.value),placeholder:"Search by title, JIRA key or file name",className:"w-full pl-8 pr-3 py-2 text-sm rounded-lg bg-gray-50 dark:bg-surface-2 border border-gray-200 dark:border-white/10 text-gray-800 dark:text-gray-100 placeholder-gray-400 focus:outline-none focus:border-brand-500/50"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[13px] text-gray-600 dark:text-gray-400 cursor-pointer select-none whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:v=>k(v.target.checked),className:"accent-brand-500"}),"Show archived"]})]})]}),e.jsx("div",{className:"flex-1 min-h-[180px] overflow-y-auto px-3 py-2",children:l?e.jsx("p",{className:"px-2 py-6 text-center text-sm text-gray-500",children:"Loading sources…"}):S?e.jsxs("p",{className:"px-2 py-6 text-center text-sm text-red-500",children:["Could not load sources: ",S.message]}):c.length===0?e.jsxs("div",{className:"px-2 py-8 text-center text-sm text-gray-500 space-y-1",children:[e.jsx("p",{children:"No sources yet."}),e.jsxs("p",{children:["Add requirements, notes, JIRA stories or documents on the ",e.jsx(kt,{to:"/sources",onClick:i,className:"text-brand-500 hover:underline",children:"Sources"})," screen."]})]}):I.length===0?e.jsxs("p",{className:"px-2 py-6 text-center text-sm text-gray-500",children:["No sources match “",j,"”."]}):I.map(v=>{const F=y.has(v.id),_=ja(v);return e.jsxs("button",{type:"button",onClick:()=>L(v),disabled:!F&&R,"data-testid":`source-row-${v.id}`,className:`w-full flex items-center gap-3 px-2.5 py-2 rounded-lg text-left transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${F?"bg-brand-500/10":"hover:bg-gray-100 dark:hover:bg-white/[0.04]"}`,children:[e.jsx("span",{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border ${F?"bg-brand-500 border-brand-500 text-white":"border-gray-300 dark:border-white/20"}`,children:F&&e.jsx(Ye,{size:11,strokeWidth:3})}),e.jsx(ts,{type:v.type,size:15,className:"text-gray-500 dark:text-gray-400"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm text-gray-800 dark:text-gray-100",children:Qe(v)}),e.jsxs("span",{className:"block truncate text-xs text-gray-500",children:[ti[v.type]," · ",wa(v)," · updated ",new Date(v.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),v.status!=="active"?` · ${v.status}`:""]})]}),_&&e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-amber-600 dark:text-amber-400 flex-shrink-0",title:"No readable text — the AI will be told it cannot see this one",children:[e.jsx(Re,{size:11})," no readable text"]})]},v.id)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-3 border-t border-gray-200 dark:border-white/5",children:[e.jsxs("span",{className:"text-[13px] text-gray-500",children:[y.size," of ",Te," selected",R?" — the most one message can carry":""]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:i,className:"px-3.5 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>{h([...y.values()]),i()},disabled:y.size===0&&o.length===0,className:"px-4 py-2 text-sm font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"source-picker-add",children:[o.length>0?"Update":"Add",y.size>0?` ${y.size}`:""]})]})]})]})]}),document.body)}function ri(){const s=new Date().getHours();return s>=5&&s<12?"Good morning":s>=12&&s<18?"Good afternoon":"Good evening"}function ni({onControlsReady:s,hideFloatingControls:i}){var Bs,Hs,Us,_s;const{subscribe:o,send:h}=na(),[d,m]=n.useState([]),[b,j]=n.useState(null),[f,$]=n.useState(!1),k=yr(),[y,w]=n.useState(()=>{try{const t=localStorage.getItem("testver-ai-chat-mode");if(t==="web"||t==="api"||t==="mobile"||t==="reporting"||t==="ask")return t}catch{}return"web"}),g=y==="ask",l=(()=>{const t=[];return k.showsWeb&&t.push("web"),k.showsMobile&&t.push("mobile"),t.push("api","reporting","ask"),t})();n.useEffect(()=>{k.isLoading||l.includes(y)||w(l[0]??"web")},[k.mode,k.isLoading]),n.useEffect(()=>{try{localStorage.setItem("testver-ai-chat-mode",y)}catch{}},[y]);const S=n.useRef(null),c=n.useRef(null),[A,I]=n.useState(0);n.useEffect(()=>{try{const r=localStorage.getItem("testver-ai-initial-prompt");r&&(S.current=r,localStorage.removeItem("testver-ai-initial-prompt"));const a=localStorage.getItem("testver-ai-attached-test");a&&(c.current=JSON.parse(a),localStorage.removeItem("testver-ai-attached-test"))}catch{}const t=r=>{const a=r.detail||{};typeof a.prompt=="string"&&a.prompt&&(S.current=a.prompt),a.attachedTest&&a.attachedTest.file&&a.attachedTest.name&&(c.current=a.attachedTest),(a.mode==="web"||a.mode==="api"||a.mode==="mobile"||a.mode==="reporting"||a.mode==="ask")&&w(a.mode),I(x=>x+1)};return window.addEventListener("testver-ai-handoff",t),()=>window.removeEventListener("testver-ai-handoff",t)},[]);const[R,L]=n.useState(null),v=n.useRef(""),F=n.useRef(null),[_,ee]=n.useState("all"),[re,Y]=n.useState(null),[B,je]=n.useState(""),[te,Ee]=n.useState(""),[X,se]=n.useState(null),[Z,V]=n.useState(null),[K,ve]=n.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem("testver-ai-pinned-sessions")||"[]"))}catch{return new Set}}),[ae,E]=n.useState([]),[fe,J]=n.useState(""),T=n.useRef(async()=>{}),H=n.useCallback(()=>{T.current("Continue")},[]),{data:ne}=vr(kr()),[p,C]=n.useState(null),[z,O]=n.useState(!1),[P,le]=n.useState(""),[xs,Xe]=n.useState(0),xe=y==="web"||y==="mobile"||y==="api"||y==="reporting",{data:Ze}=fn(),{mcpEnabled:et,uploads:us,apiUploads:Ca}=gn(),we=y==="api"?Ca??us:us,St=n.useMemo(()=>{const t=[];for(const r of(Ze==null?void 0:Ze.suites)||[])for(const a of r.tests)t.push({name:a.name,file:r.file,framework:r.framework,line:a.line,endLine:a.endLine,lastStatus:a.lastStatus,runCount:a.runCount,passCount:a.passCount,tags:a.tags});return t},[Ze]),Me=n.useMemo(()=>{if(!z)return[];const t=P.toLowerCase();return(t?St.filter(a=>pn(a.name,t)||a.file.toLowerCase().includes(t)):St).slice(0,50)},[z,P,St]),$a=(t,r)=>{const a=t.slice(0,r).match(/(?:^|\s)@([\w./:\- ]*)$/);return a?a[1]:null},ms=t=>{C(t),O(!1),le(""),J(r=>r.replace(/(?:^|\s)@([\w./:\- ]*)$/,"").replace(/\s+$/,"")),setTimeout(()=>{var r;return(r=pe.current)==null?void 0:r.focus()},0)};n.useEffect(()=>{xe||(C(null),O(!1))},[xe]),n.useEffect(()=>{g&&(it([]),Ce(!1),Oe([]))},[g]);const tt=y!=="reporting",He=y==="reporting",[de,Ue]=n.useState([]),[Aa,st]=n.useState(!1),[Ia,_e]=n.useState(!1),[We,Ne]=n.useState(!1),[Ct,ps]=n.useState(""),[$t,at]=n.useState(0),{data:De}=Na(!1,We),Se=n.useMemo(()=>{if(!We)return[];const t=new Set(de.map(r=>r.id));return Sa((De==null?void 0:De.sources)??[],Ct).filter(r=>!t.has(r.id)).slice(0,30)},[We,Ct,De,de]),hs=We&&(Se.length>0||Ct===""&&!!De&&De.sources.length===0),fs=/(?:^|\s)#([\w\-.: ]{0,40})$/,Ta=(t,r)=>{const a=t.slice(0,r).match(fs);return a?a[1]:null};n.useEffect(()=>{tt||(Ue([]),Ne(!1),_e(!1),st(!1))},[tt]);const gs=t=>{Ue(r=>r.some(a=>a.id===t.id)||r.length>=Te?r:[...r,t]),Ne(!1),ps(""),J(r=>r.replace(fs,"").replace(/\s+$/,"")),setTimeout(()=>{var r;return(r=pe.current)==null?void 0:r.focus()},0)},[rt,Ra]=n.useState([]),bs=ss(),[At,za]=n.useState([]),[nt,it]=n.useState([]),[ue,Ea]=n.useState(()=>{try{return JSON.parse(localStorage.getItem("testver-ai-mcp")||"[]")}catch{return[]}}),[ot,Ce]=n.useState(!1),[It,ys]=n.useState(""),[Tt,lt]=n.useState(0),[Ma,Rt]=n.useState(!1);n.useEffect(()=>{jr().then(t=>{Ra(t.skills);const r=new Set(t.skills.filter(a=>a.enabled).map(a=>a.slug));it(a=>a.filter(x=>r.has(x)))}).catch(()=>{}),zt()},[]),n.useEffect(()=>{try{localStorage.removeItem("testver-ai-skills")}catch{}},[]),n.useEffect(()=>{try{localStorage.setItem("testver-ai-mcp",JSON.stringify(ue))}catch{}},[ue]);const $e=n.useMemo(()=>{if(!ot||g)return[];const t=It.toLowerCase(),r=rt.filter(x=>x.enabled);return(t?r.filter(x=>{var u;return x.name.toLowerCase().includes(t)||x.slug.toLowerCase().includes(t)||((u=x.tags)==null?void 0:u.some(N=>N.toLowerCase().includes(t)))}):r).slice(0,50)},[ot,It,rt,g]),vs=/(?:^|\s)\/([\w-]*)$/,[Da,Pa]=n.useState(!1),La=(t,r)=>{if(g)return null;const a=t.slice(0,r).match(vs);return a?a[1]:null},ks=ot&&(Da||$e.length>0),js=t=>it(r=>r.includes(t)?r.filter(a=>a!==t):[...r,t]),zt=n.useCallback(()=>{wr().then(t=>za((t.servers||[]).filter(r=>r.enabled))).catch(()=>{})},[]),ws=t=>Ea(r=>r.includes(t)?r.filter(a=>a!==t):(Mr(t).catch(()=>{}).finally(()=>zt()),[...r,t])),Ns=t=>{js(t.slug),Ce(!1),ys(""),J(r=>r.replace(vs,"").replace(/\s+$/,"")),setTimeout(()=>{var r;return(r=pe.current)==null?void 0:r.focus()},0)},Ss=t=>{var r;return((r=rt.find(a=>a.slug===t))==null?void 0:r.name)||t},Oa=t=>{var r;return((r=At.find(a=>a.id===t))==null?void 0:r.name)||t};n.useEffect(()=>{c.current&&(C(c.current),c.current=null),S.current&&(J(S.current),S.current=null,requestAnimationFrame(()=>{const t=pe.current;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)}))},[A]);const[U,Pe]=n.useState(!1),[gi,Cs]=n.useState(null),Ae=n.useRef(null),Je=t=>{Ae.current=t,Cs(t)},Le=n.useRef([]),[Et,Oe]=n.useState([]),[qa,$s]=n.useState(!1),[As,Mt]=n.useState(!1),Dt=n.useRef(null),Q=n.useRef(""),G=n.useRef(null),Is=n.useRef(0),[dt,Pt]=n.useState("manual"),Lt=n.useRef("manual");Lt.current=dt;const[ge,be]=n.useState(null),me=n.useRef([]),Ot=n.useRef(!1),qt=n.useRef(!1),[bi,yi]=n.useState(null),[Ts,Fa]=n.useState([]),[ct,Rs]=n.useState(""),[qe,zs]=n.useState(""),[Ft,Bt]=n.useState(!1);n.useEffect(()=>{Nr().then(t=>{const r=[],a=t.effectiveProvider||t.defaultProvider;for(const[u,N]of Object.entries(t.providers)){if(Rn.has(u)||!N.hasApiKey&&!N.isLocal)continue;if(u==="testver"){r.push({provider:u,models:[""]});continue}const D=N.models,M=Array.isArray(D)&&D.length>0?D:[N.model].filter(Boolean);M.length>0&&r.push({provider:u,models:M})}Fa(r);const x=t.providers[a];x&&(zs(a),Rs(a==="testver"?"":x.activeModel||x.model||""))}).catch(t=>{console.warn("[ChatPanel] Failed to load LLM config:",t)})},[]);const xt=n.useRef(null),pe=n.useRef(null),Ba=n.useRef(0),ut=n.useRef(null),{user:Fe}=Sr(),Ha=(Fe==null?void 0:Fe.displayName)||(Fe==null?void 0:Fe.username)||"";ut.current=b;const Ua=ae.some(t=>t.kind==="user"||t.kind==="text"||t.kind==="loading"),Ht=n.useCallback(()=>$(t=>!t),[]),mt=n.useCallback(()=>{U||(Cr().catch(()=>{}),j(null),Le.current=[],Oe([]),E([]),me.current=[],be(null),L(null),Pt("manual"),ht())},[U]),_a=n.useCallback(t=>{Pt(t),Lt.current=t,b&&(Vs(b,t).catch(()=>{}),m(a=>a.map(x=>x.id===b?{...x,permissionMode:t}:x)));const r=Ae.current;r&&$r(r,t).catch(()=>{}),t==="auto"&&(me.current=me.current.filter(a=>!a.autoEligible),ge!=null&&ge.autoEligible&&be(me.current.shift()||null))},[b,ge]),pt=n.useCallback(t=>{w(t),L(null),b&&(Ar(b,t).catch(()=>{}),m(r=>r.map(a=>a.id===b?{...a,mode:t}:a)))},[b]);n.useEffect(()=>{s==null||s({toggleSidebar:Ht,newChat:mt,sidebarOpen:f})},[s,Ht,mt,f]),n.useEffect(()=>{ht()},[]);const ht=async()=>{try{const t=await Ir();m(t.sessions)}catch{}},Wa=async t=>{if(!U)try{const r=await Lr(t);j(t),qt.current=!0,me.current=[],be(null),L(null),w(r.mode??"web"),Pt(r.permissionMode==="auto"?"auto":"manual");const a=[];for(const x of r.messages)a.push({role:x.role,content:x.content});if(Le.current=a,Array.isArray(r.fullTimeline)&&r.fullTimeline.length>0){const x=r.fullTimeline.map(u=>{const N=u.id||`restored-${Date.now()}-${Math.random()}`;return u.kind==="user"?{kind:"user",id:N,text:u.text||"",mode:u.mode}:u.kind==="system"?{kind:"system",id:N,text:u.text||""}:u.kind==="text"?{kind:"text",id:N,text:u.text||"",done:!0}:u.kind==="error"?{kind:"error",id:N,text:u.text||""}:u.kind==="tool"?{kind:"tool",id:N,phase:u.phase||"complete",toolName:u.toolName||"",args:u.args||"",result:u.result,fullResult:u.fullResult,error:u.error,startedAt:u.startedAt,endedAt:u.endedAt}:u.kind==="diff"?{kind:"diff",id:N,filePath:u.filePath||"",diffType:u.diffType||"modified",diff:u.diff||"",linesAdded:u.linesAdded||0,linesRemoved:u.linesRemoved||0,via:u.via,unavailable:u.unavailable,netNoChange:u.netNoChange,omitted:u.omitted}:{kind:"system",id:N,text:""}});E(x)}else{const x=[];for(const u of r.messages){const N=`restored-${Date.now()}-${Math.random()}`;u.role==="user"?x.push({kind:"user",id:N,text:u.content}):x.push({kind:"text",id:N,text:u.content,done:!0})}E(x)}Oe([]),$(!1),setTimeout(()=>{qt.current=!1},0)}catch(r){E(a=>[...a,{kind:"error",id:`err-${Date.now()}`,text:`Failed to load session: ${r}`}])}},Ja=(t,r)=>{const a=d.find(x=>x.id===t);V({id:t,title:(a==null?void 0:a.title)||"this chat"})},Ga=async()=>{if(!Z)return;const t=Z.id;V(null);try{await Or(t),m(r=>r.filter(a=>a.id!==t)),b===t&&mt()}catch{}},Ka=(t,r,a)=>{Y(t),je(r)},Es=async t=>{if(t.stopPropagation(),!re||!B.trim()){Y(null);return}try{await Pr(re,B.trim()),m(r=>r.map(a=>a.id===re?{...a,title:B.trim()}:a))}catch{}Y(null)};n.useEffect(()=>{if(!X)return;const t=()=>se(null);return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[X]);const Va=n.useCallback(t=>{ve(r=>{const a=new Set(r);return a.has(t)?a.delete(t):a.add(t),localStorage.setItem("testver-ai-pinned-sessions",JSON.stringify([...a])),a})},[]),Ms=n.useMemo(()=>{const t=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=r-864e5,x=r-7*864e5;let u=d.filter(q=>q.messageCount>0||q.id===b);if(_!=="all"&&(u=u.filter(q=>(q.mode??"web")===_)),te){const q=te.toLowerCase();u=u.filter(he=>he.title.toLowerCase().includes(q))}const N=u.filter(q=>K.has(q.id)),D=u.filter(q=>!K.has(q.id)),M=[];N.length>0&&M.push({label:"📌 Pinned",items:N});const W=D.filter(q=>new Date(q.updatedAt||q.createdAt).getTime()>=r),ie=D.filter(q=>{const he=new Date(q.updatedAt||q.createdAt).getTime();return he>=a&&he<r}),ke=D.filter(q=>{const he=new Date(q.updatedAt||q.createdAt).getTime();return he>=x&&he<a}),Ke=D.filter(q=>new Date(q.updatedAt||q.createdAt).getTime()<x);return W.length>0&&M.push({label:"Today",items:W}),ie.length>0&&M.push({label:"Yesterday",items:ie}),ke.length>0&&M.push({label:"This Week",items:ke}),Ke.length>0&&M.push({label:"Older",items:Ke}),M},[d,K,te,_,b]),Ut=n.useCallback(t=>{E(r=>r.filter(a=>!(a.kind==="loading"&&a.id===`loading-${t}`)))},[]),Ge=n.useRef(null),ft=n.useCallback(()=>{const t=Ge.current;t&&(t.raf!=null&&cancelAnimationFrame(t.raf),t.timer!=null&&clearTimeout(t.timer),Ge.current=null)},[]),ye=n.useCallback(()=>{ft();const t=G.current,r=Q.current;t&&E(a=>{const x=a.findIndex(u=>u.id===t);if(x>=0){const u=[...a];return u[x]={...u[x],kind:"text",text:r},u}return a})},[ft]),Ds=n.useCallback(()=>{if(Ge.current)return;const t=()=>{Ge.current=null,ye()};Ge.current=typeof document<"u"&&document.hidden?{timer:setTimeout(t,100)}:{raf:requestAnimationFrame(t)}},[ye]);n.useEffect(()=>ft,[ft]);const Ps=n.useCallback(t=>{const r=t.requestId;if(t.type==="chat-mode-suggestion"){const a=t;typeof a.suggestedMode=="string"&&typeof a.currentMode=="string"&&a.suggestedMode!==a.currentMode&&L({suggested:a.suggestedMode,reason:a.reason||`Message looks like a ${a.suggestedMode} request`});return}if(t.type==="client-id"&&!t.resumed&&Ae.current){const a=Ae.current;ye(),Q.current="",G.current=null,E(x=>[...x.filter(u=>!(u.kind==="notice"&&u.tone==="retrying")&&!(u.kind==="loading"&&u.id.includes(a))),{kind:"error",id:`err-offline-${Date.now()}`,resumable:!0,text:"This page lost track of the reply in progress — it was offline for more than 5 minutes, or the Testver server restarted. What the task already did (file changes included) is saved — press Continue to pick up from there."}]),Pe(!1),Je(null),be(null),me.current=[];return}if(t.type==="replay-incomplete"&&Ae.current){E(a=>[...a,{kind:"system",id:`replay-gap-${Date.now()}`,text:"Reconnected — part of the reply sent while this page was offline could not be shown."}]);return}if(!(!r||!r.startsWith("chat-"))){if(Ut(r),t.type==="ai-fix-notice"){const a=t,x=`notice-${r}`,u=a.kind==="ai-recovered"?{kind:"notice",id:x,tone:"recovered",text:"Reconnected to the AI service — carrying on."}:{kind:"notice",id:x,tone:"retrying",text:a.message||"Lost the connection to the AI service — retrying",retryAt:typeof a.retryInMs=="number"?Date.now()+a.retryInMs:void 0,attempt:typeof a.attempt=="number"?a.attempt:void 0};E(N=>{const D=N.findIndex(W=>W.id===x);if(D<0)return[...N,u];const M=[...N];return M[D]=u,M}),G.current&&(ye(),Q.current="",G.current=null);return}if(t.type==="ai-mcp-notice"){const a=t.text;a&&E(x=>[...x,{kind:"system",id:`mcp-notice-${r}-${Date.now()}`,text:a}]);return}if(t.type==="ai-fix-stream"){const a=t.content;if(!G.current){const x=`text-${r}-${++Is.current}`;Q.current="",G.current=x,E(u=>[...u,{kind:"text",id:x,text:""}])}Q.current+=a,Ds();return}if(t.type==="ai-fix-tool"){const a=t.phase,x=t.toolName,u=t.args;if(a==="start"){if(G.current){Q.current&&ye();const D=G.current;E(M=>{const W=M.findIndex(ie=>ie.id===D);if(W>=0){const ie=[...M],ke=ie[W];return ke.kind==="text"&&(ie[W]={...ke,done:!0}),ie}return M}),Q.current="",G.current=null}const N=`tool-${x}-${Date.now()}-${Math.random()}`;E(D=>[...D,{kind:"tool",id:N,phase:"start",toolName:x,args:u,startedAt:Date.now()}])}else E(N=>{const D=[...N];for(let M=D.length-1;M>=0;M--){const W=D[M];if(W.kind==="tool"&&W.toolName===x&&W.phase==="start"){D[M]={...W,phase:a,result:t.result,fullResult:t.fullResult,error:t.error,endedAt:Date.now()};break}}return D});return}if(t.type==="ai-fix-file-diff"){E(a=>[...a,{kind:"diff",id:`diff-${Date.now()}-${Math.random()}`,filePath:t.filePath,diffType:t.diffType,diff:t.diff,linesAdded:t.linesAdded,linesRemoved:t.linesRemoved,via:t.via==="detected"?"detected":void 0,unavailable:t.unavailable,netNoChange:t.netNoChange===!0||void 0}]);return}if(t.type==="ai-fix-file-changes-omitted"){E(a=>[...a,{kind:"diff",id:`diff-omitted-${Date.now()}`,filePath:"",diffType:"modified",diff:"",linesAdded:0,linesRemoved:0,via:"detected",omitted:{count:Number(t.count)||0,examples:Array.isArray(t.examples)?t.examples:[]}}]);return}if(t.type==="ai-fix-permission"){const a={permissionId:t.permissionId,toolName:t.toolName,args:t.args,fullPath:t.fullPath||void 0,prompt:t.prompt||void 0,confirmLabel:t.confirmLabel||void 0,allowRemember:t.allowRemember,autoEligible:t.autoEligible===!0};if(a.autoEligible&&Lt.current==="auto")return;be(x=>x?(me.current.push(a),x):a);return}if(t.type==="ai-fix-done"){ye();const a=Q.current||"";if(a){Le.current.push({role:"assistant",content:a});const x=ut.current;x&&(Jt(x,"assistant",a).catch(()=>{}),ht())}G.current&&(E(x=>{const u=x.findIndex(N=>N.id===G.current);if(u>=0){const N=[...x],D=N[u];return D.kind==="text"&&(N[u]={...D,done:!0}),N}return x}),Q.current="",G.current=null),Pe(!1),Je(null),be(null);return}if(t.type==="ai-fix-error"){ye();const a=t.resumable===!0;if(a&&Q.current){Le.current.push({role:"assistant",content:Q.current});const x=ut.current;x&&Jt(x,"assistant",Q.current).catch(()=>{})}Q.current="",G.current=null,E(x=>[...x.filter(u=>!(u.kind==="notice"&&u.id===`notice-${r}`&&u.tone==="retrying")),{kind:"error",id:`err-${Date.now()}`,text:t.message,...a?{resumable:!0}:{}}]),Pe(!1),Je(null),be(null);return}}},[Ut,ye,Ds]);n.useEffect(()=>o(Ps),[o,Ps]);const gt=n.useRef(!0),Ls=n.useRef(0);n.useEffect(()=>{xt.current&>.current&&(xt.current.scrollTop=xt.current.scrollHeight)},[ae,ge]),n.useEffect(()=>{if(U||!Ot.current||qt.current)return;const t=ut.current;if(!t)return;Ot.current=!1;const r=ae.map(a=>{if(a.kind==="text")return{kind:"text",id:a.id,text:a.text,done:a.done};if(a.kind==="user")return{kind:"user",id:a.id,text:a.text,mode:a.mode};if(a.kind==="system")return{kind:"system",id:a.id,text:a.text};if(a.kind==="error")return{kind:"error",id:a.id,text:a.text};if(a.kind==="tool"){const x=a;return{kind:"tool",id:a.id,phase:x.phase,toolName:x.toolName,args:x.args,result:x.result,fullResult:x.fullResult,error:x.error,startedAt:x.startedAt,endedAt:x.endedAt}}if(a.kind==="diff"){const x=a;return{kind:"diff",id:a.id,filePath:x.filePath,diffType:x.diffType,diff:x.diff,linesAdded:x.linesAdded,linesRemoved:x.linesRemoved,via:x.via,unavailable:x.unavailable,netNoChange:x.netNoChange,omitted:x.omitted}}return null}).filter(Boolean);Tr(t,r).catch(()=>{})},[U,ae]);const _t=async t=>{if(!t.trim()||U)return;const r=`chat-${Date.now()}-${++Ba.current}`;v.current=t,Q.current="",G.current=null,Is.current=0;let a=b;if(!a){a=`session-${Date.now()}`;try{await Rr(a,"New Chat",y),dt==="auto"&&await Vs(a,"auto")}catch{}j(a)}L(null);const x=xe?p:null,u=x?`"${x.name}" `:"",N=[...nt],D=N.length>0?`
|
|
13
|
-
📚 Skills used: ${N.map(Ss).join(", ")}`:"",M=tt?[...de]:[],W=M.length>0?`
|
|
14
|
-
🗂 ${g?"Answer from":"Sources"}: ${M.map(ce=>`${Qe(ce)} (${ce.id})`).join(", ")}`:"",ie=u+t+D+W,ke=g?[]:Et,Ke=ke.map(ce=>ce.originalName),q=Ke.length>0?`${ie}
|
|
15
|
-
📎 ${Ke.join(", ")}`:ie;Le.current.push({role:"user",content:t+W}),Jt(a,"user",ie).catch(()=>{}).finally(()=>{ht()}),E(ce=>[...ce,{kind:"user",id:`user-${r}`,text:q,mode:y},{kind:"loading",id:`loading-${r}`}]),J(""),gt.current=!0,C(null),O(!1),it([]),Ce(!1),g||Ue([]),Ne(!1),pe.current&&(pe.current.style.height="auto"),Pe(!0),Ot.current=!0,Je(r);const he=ke.map(ce=>ce.id);Oe([]);try{const bt=Le.current.slice(-20).slice(0,-1);await zr({requestId:r,message:t,history:bt.length>0?bt:void 0,uploadedFileIds:he.length>0?he:void 0,model:ct||void 0,provider:qe||void 0,mode:y,attachedTest:x||void 0,skillSlugs:N.length>0?N:void 0,mcpServerIds:!g&&et&&ue.length>0?ue:void 0,permissionMode:dt,sourceIds:M.length>0?M.map(tr=>tr.id):void 0})}catch(ce){Ut(r),E(bt=>[...bt,{kind:"error",id:`err-${Date.now()}`,text:`Failed to send: ${ce}`}]),Pe(!1),Je(null)}};T.current=_t;const Os=()=>_t(fe.trim()),Qa=t=>{const r=v.current;U&&Fs(),r&&(F.current={text:r,mode:t}),pt(t)};n.useEffect(()=>{const t=F.current;!t||U||y!==t.mode||(F.current=null,_t(t.text))},[y,U]);const Ya=t=>{if(We&&Se.length>0){if(t.key==="ArrowDown"){t.preventDefault(),at(r=>Math.min(r+1,Se.length-1));return}if(t.key==="ArrowUp"){t.preventDefault(),at(r=>Math.max(r-1,0));return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),gs(Se[$t]||Se[0]);return}if(t.key==="Escape"){t.preventDefault(),Ne(!1);return}}if(hs&&t.key==="Escape"){t.preventDefault(),Ne(!1);return}if(xe&&z&&Me.length>0){if(t.key==="ArrowDown"){t.preventDefault(),Xe(r=>Math.min(r+1,Me.length-1));return}if(t.key==="ArrowUp"){t.preventDefault(),Xe(r=>Math.max(r-1,0));return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),ms(Me[xs]||Me[0]);return}if(t.key==="Escape"){t.preventDefault(),O(!1);return}}if(ot&&$e.length>0){if(t.key==="ArrowDown"){t.preventDefault(),lt(r=>Math.min(r+1,$e.length-1));return}if(t.key==="ArrowUp"){t.preventDefault(),lt(r=>Math.max(r-1,0));return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),Ns($e[Tt]||$e[0]);return}}if(ks&&t.key==="Escape"){t.preventDefault(),Ce(!1);return}t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),Os())},qs=async t=>{const{accepted:r,rejected:a}=Hn(Array.from(t),we,y==="api"?On:void 0);a.length>0&&E(u=>[...u,{kind:"error",id:`upload-rej-${Date.now()}`,text:a.length===1?`Not uploaded — ${a[0]}`:`Not uploaded:
|
|
16
|
-
${a.map(N=>`• ${N}`).join(`
|
|
17
|
-
`)}`}]);const x=r;if(x.length!==0){$s(!0);try{const u=await Er(x,y);Oe(N=>[...N,...u.files])}catch(u){E(N=>[...N,{kind:"error",id:`upload-err-${Date.now()}`,text:`Upload failed: ${u}`}])}finally{$s(!1)}}},Xa=t=>{t.preventDefault(),t.stopPropagation(),Mt(!0)},Za=t=>{t.preventDefault(),t.stopPropagation(),Mt(!1)},er=t=>{t.preventDefault(),t.stopPropagation(),Mt(!1),t.dataTransfer.files.length>0&&qs(t.dataTransfer.files)},Fs=()=>{const t=Ae.current;if(t){if(Ae.current=null,Cs(null),be(null),me.current=[],G.current){ye();const r=G.current;E(a=>{const x=a.findIndex(u=>u.id===r);if(x>=0){const u=[...a],N=u[x];return N.kind==="text"&&(u[x]={...N,done:!0}),u}return a}),Q.current="",G.current=null}Pe(!1),E(r=>[...r,{kind:"system",id:`stopped-${Date.now()}`,text:"Generation stopped by user"}]),Dr({requestId:t}).catch(()=>{})}},Wt=(t,r=!1)=>{if(!ge)return;h({type:"ai-fix-permission-response",permissionId:ge.permissionId,granted:t,remember:t&&r});const a=me.current.shift()||null;be(a)};return e.jsx(Sn,{children:e.jsx(Cn,{children:e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[!i&&e.jsxs("div",{className:"absolute top-3 right-3 z-10 flex flex-col items-center gap-1.5",children:[e.jsx("button",{onClick:mt,disabled:U,className:"p-1.5 rounded-lg transition-all shadow-lg backdrop-blur-sm bg-brand-600 hover:bg-brand-500 text-white opacity-70 hover:opacity-100 disabled:opacity-30",title:"New Session",children:e.jsx(Qr,{size:14})}),e.jsx("button",{onClick:Ht,className:`p-1.5 rounded-lg transition-all shadow-lg backdrop-blur-sm opacity-70 hover:opacity-100 ${f?"bg-brand-500/20 text-brand-400 border border-brand-500/30":"bg-surface-2/80 text-gray-400 hover:text-gray-200 hover:bg-surface-2 border border-white/10"}`,title:f?"Hide History":"Show History",children:e.jsx(Yr,{size:14})})]}),Ua?e.jsxs("div",{ref:xt,onScroll:t=>{const r=t.currentTarget;r.scrollHeight-r.scrollTop-r.clientHeight<120?gt.current=!0:r.scrollTop<Ls.current-2&&(gt.current=!1),Ls.current=r.scrollTop},className:"flex-1 overflow-y-auto px-12 py-4 space-y-3 bg-white dark:bg-white/[0.02]",children:[e.jsx(oi,{timeline:ae,isStreaming:U,currentMode:y,activeSessionId:b,onContinue:H}),g&&U&&!ci(ae)&&e.jsxs("div",{className:"flex items-center gap-3 text-[13px] text-gray-500 dark:text-gray-400",role:"status",children:[e.jsx(Xs,{size:6}),"Getting app knowledge from the available sources…"]})]}):e.jsx(fi,{displayName:Ha,availableModes:l,currentMode:y,onPickMode:t=>{pt(t),requestAnimationFrame(()=>{var r;return(r=pe.current)==null?void 0:r.focus()})},onPrefillPrompt:t=>{J(t),requestAnimationFrame(()=>{const r=pe.current;r&&(r.focus(),r.style.height="auto",r.style.height=`${r.scrollHeight}px`)})},isStreaming:U}),ge&&e.jsx("div",{className:"flex-shrink-0 px-6 pt-3 pb-2 bg-white dark:bg-white/[0.02]",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx($n,{pending:ge,queuedCount:me.current.length,onAllow:()=>Wt(!0,!1),onAlwaysAllow:()=>Wt(!0,!0),onDeny:()=>Wt(!1,!1)})})}),R&&e.jsx("div",{className:"flex-shrink-0 px-6 pt-2 pb-1 bg-white dark:bg-white/[0.02]",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-md border border-amber-500/30 bg-amber-500/5 dark:bg-amber-500/10",children:[(()=>{const t=oe.find(a=>a.value===R.suggested),r=t==null?void 0:t.Icon;return r?e.jsx(r,{size:14,className:t.colorClass+" flex-shrink-0"}):null})(),e.jsxs("div",{className:"flex-1 text-xs text-gray-700 dark:text-gray-300",children:["This looks like a ",e.jsx("span",{className:"font-semibold",children:(Bs=oe.find(t=>t.value===R.suggested))==null?void 0:Bs.label})," request.",U?" Stop this answer and ask again there?":" Switch modes?"]}),v.current&&e.jsxs("button",{onClick:()=>Qa(R.suggested),className:"px-2.5 py-1 rounded-md text-[11px] font-medium bg-amber-500/20 hover:bg-amber-500/30 text-amber-700 dark:text-amber-300 border border-amber-500/40 transition-colors",children:["Ask again in ",(Hs=oe.find(t=>t.value===R.suggested))==null?void 0:Hs.label]}),!U&&e.jsxs("button",{onClick:()=>pt(R.suggested),className:"px-2.5 py-1 rounded-md text-[11px] font-medium text-amber-700 dark:text-amber-300 hover:bg-amber-500/10 transition-colors",children:["Switch to ",(Us=oe.find(t=>t.value===R.suggested))==null?void 0:Us.label]}),e.jsxs("button",{onClick:()=>L(null),className:"px-2.5 py-1 rounded-md text-[11px] text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 transition-colors",title:"Dismiss",children:["Keep ",(_s=oe.find(t=>t.value===y))==null?void 0:_s.label]})]})})}),e.jsx("input",{ref:Dt,type:"file",multiple:!0,className:"hidden",accept:(we==null?void 0:we.accept)??ds.join(","),onChange:t=>{t.target.files&&qs(t.target.files),t.target.value=""}}),e.jsx(Mn,{enabled:(ne==null?void 0:ne.settings.tellAI)!==!1,texts:[fe,...ae.slice(-20).map(t=>t.kind==="user"||t.kind==="text"?t.text:t.kind==="tool"?t.args:t.kind==="diff"?t.filePath:"")]}),e.jsx("div",{className:`px-6 pb-3 flex-shrink-0 transition-colors ${As?"bg-brand-500/5":"bg-white dark:bg-white/[0.02]"}`,onDragOver:g?void 0:Xa,onDragLeave:g?void 0:Za,onDrop:g?void 0:er,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[As&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 mb-2 rounded-xl border-2 border-dashed border-brand-500/40 bg-brand-500/5",children:[e.jsx(Yt,{size:16,className:"text-brand-400"}),e.jsx("span",{className:"text-sm text-brand-300 font-medium",children:"Drop files here to upload"})]}),U&&!g&&e.jsx("div",{className:"flex items-center pl-1 pb-3",children:e.jsx(Xs,{})}),y==="mobile"&&e.jsx(Un,{}),e.jsxs("div",{className:"relative bg-white dark:bg-white/[0.03] border border-gray-200 dark:border-white/10 rounded-2xl focus-within:border-brand-500/40 transition-colors",children:[hs&&e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 max-h-64 overflow-y-auto rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-xl py-1","data-testid":"source-hash-menu",children:[e.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-500 flex items-center gap-1.5",children:[e.jsx(Xr,{size:11})," ",g?"Answer from a source":"Add a source",de.length>=Te&&e.jsxs("span",{className:"normal-case font-normal text-amber-600 dark:text-amber-400",children:["— ",Te," is the most per message"]})]}),Se.length===0&&e.jsxs("div",{className:"px-3 py-2.5 text-[11px] text-gray-500 dark:text-gray-400 leading-relaxed",children:["No sources yet. Add requirements, notes, JIRA stories or documents on the"," ",e.jsx(kt,{to:"/sources",className:"font-medium text-emerald-600 dark:text-emerald-400 hover:underline",children:"Sources"})," screen."]}),Se.map((t,r)=>e.jsxs("button",{type:"button",onMouseEnter:()=>at(r),onClick:()=>gs(t),disabled:de.length>=Te,className:`w-full flex items-center gap-2 px-3 py-2 text-left text-xs transition-colors disabled:opacity-40 ${r===$t?"bg-emerald-500/10 text-emerald-700 dark:text-emerald-200":"text-gray-600 dark:text-gray-300 hover:bg-black/5 dark:hover:bg-white/5"}`,children:[e.jsx(ts,{type:t.type,size:13,className:"text-emerald-600 dark:text-emerald-400"}),e.jsx("span",{className:`truncate font-medium ${r===$t?"":"text-gray-900 dark:text-gray-100"}`,children:Qe(t)}),e.jsx("span",{className:"ml-auto flex-shrink-0 text-[10px] text-gray-500 dark:text-gray-400",children:wa(t)})]},t.id))]}),xe&&z&&Me.length>0&&e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 max-h-64 overflow-y-auto rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-xl py-1",children:[e.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-500 flex items-center gap-1.5",children:[e.jsx(Zr,{size:11})," Attach a test"]}),Me.map((t,r)=>e.jsxs("button",{type:"button",onMouseEnter:()=>Xe(r),onClick:()=>ms(t),className:`w-full flex items-center gap-2 px-3 py-2 text-left text-xs transition-colors ${r===xs?"bg-brand-500/15 text-brand-200":"text-gray-600 dark:text-gray-300 hover:bg-black/5 dark:hover:bg-white/5"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${t.lastStatus==="passed"?"bg-emerald-400":t.lastStatus==="failed"?"bg-red-400":"bg-gray-500"}`}),e.jsx(en,{size:13,className:"text-gray-500 flex-shrink-0"}),e.jsx("span",{className:"font-medium truncate flex-1",title:t.name,children:hn(t.name)}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate max-w-[150px]",children:t.file.split(/[/\\]/).pop()})]},`${t.file}::${t.name}`))]}),ks&&e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 max-h-64 overflow-y-auto rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-xl py-1",children:[e.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-500 flex items-center gap-1.5",children:[e.jsx(Gt,{size:11})," Add a skill"]}),$e.length===0&&e.jsx("div",{className:"px-3 py-2.5 text-[11px] text-gray-500 dark:text-gray-400 leading-relaxed",children:rt.filter(t=>t.enabled).length===0?e.jsxs(e.Fragment,{children:["No skills enabled yet. Enable them in ",e.jsx("span",{className:"font-medium text-violet-600 dark:text-violet-300",children:"Settings → Skills"}),", or create a new one."]}):e.jsxs(e.Fragment,{children:["No skills match “",It,"”."]})}),$e.map((t,r)=>{const a=nt.includes(t.slug);return e.jsxs("button",{type:"button",onMouseEnter:()=>lt(r),onClick:()=>Ns(t),title:t.description||t.name,className:`w-full flex items-center gap-2 px-3 py-2 text-left text-xs transition-colors ${r===Tt?"bg-violet-500/10 dark:bg-violet-500/15 text-violet-700 dark:text-violet-200":"text-gray-600 dark:text-gray-300 hover:bg-black/5 dark:hover:bg-white/5"}`,children:[e.jsx(Gt,{size:13,className:"text-violet-500 flex-shrink-0"}),e.jsx("span",{className:`font-medium flex-shrink-0 max-w-[45%] truncate ${r===Tt?"":"text-gray-900 dark:text-gray-100"}`,children:t.name}),t.description&&e.jsx("span",{className:"flex-1 min-w-0 truncate text-gray-500 dark:text-gray-400 font-normal",children:t.description}),e.jsxs("span",{className:"flex-shrink-0 flex items-center justify-end gap-1.5 w-[74px] ml-auto",children:[e.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:t.source==="user"?"Custom":"Built-in"}),a?e.jsx(Xt,{size:12,className:"text-violet-500 flex-shrink-0"}):e.jsx("span",{className:"w-3 flex-shrink-0"})]})]},t.slug)}),e.jsx("div",{className:"border-t border-gray-200 dark:border-white/10 mt-1 pt-1",children:e.jsxs("button",{type:"button",onClick:()=>{Ce(!1),bs("/settings?tab=skills")},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] text-gray-500 hover:text-violet-600 dark:hover:text-violet-300 hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:[e.jsx(Qs,{size:12,className:"flex-shrink-0"}),e.jsx("span",{children:"Manage skills…"})]})})]}),(xe&&p||nt.length>0||!g&&et&&ue.length>0||de.length>0)&&e.jsxs("div",{className:"px-4 pt-3 flex items-center gap-1.5 flex-wrap",children:[de.map(t=>e.jsxs("span",{"data-testid":`source-chip-${t.id}`,className:"inline-flex items-center gap-1 pl-1.5 pr-1 py-1 rounded-md bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 text-xs font-medium",title:g?`Answer only from this source (${t.id})`:`Source ${t.id} — the AI reads it with this message`,children:[e.jsx(ts,{type:t.type,size:11}),e.jsx("span",{className:"truncate max-w-[200px]",children:Qe(t)}),e.jsx("button",{onClick:()=>Ue(r=>r.filter(a=>a.id!==t.id)),className:"opacity-60 hover:opacity-100 hover:text-red-400",title:"Remove","aria-label":`Remove ${Qe(t)}`,children:e.jsx(Ie,{size:10})})]},t.id)),g&&de.length>0&&e.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400","data-testid":"ask-sources-sticky",children:["Answering only from ",de.length===1?"this source":"these sources"," until you remove ",de.length===1?"it":"them"]}),xe&&p&&e.jsxs("span",{className:"inline-flex items-center gap-1 pl-2 pr-1.5 py-1 rounded-md bg-blue-500/15 text-blue-600 dark:text-blue-300 text-xs font-semibold max-w-full",title:`${p.name} — ${p.file}`,children:[e.jsx("span",{className:"opacity-70",children:"@"}),e.jsx("span",{className:"truncate max-w-[220px]",children:p.name}),e.jsx("button",{onClick:()=>C(null),className:"ml-0.5 opacity-60 hover:opacity-100 hover:text-red-400",title:"Remove",children:e.jsx(Ie,{size:11})})]}),nt.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 pl-1.5 pr-1 py-1 rounded-md bg-violet-500/15 text-violet-700 dark:text-violet-300 text-xs font-medium",title:"Agent Skill",children:[e.jsx(Gt,{size:11}),e.jsx("span",{className:"truncate max-w-[160px]",children:Ss(t)}),e.jsx("button",{onClick:()=>js(t),className:"opacity-60 hover:opacity-100 hover:text-red-400",title:"Remove",children:e.jsx(Ie,{size:10})})]},t)),!g&&et&&ue.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 pl-1.5 pr-1 py-1 rounded-md bg-cyan-500/15 text-cyan-700 dark:text-cyan-300 text-xs font-medium",title:"MCP server",children:[e.jsx(Kt,{size:11}),e.jsx("span",{className:"truncate max-w-[160px]",children:Oa(t)}),e.jsx("button",{onClick:()=>ws(t),className:"opacity-60 hover:opacity-100 hover:text-red-400",title:"Remove",children:e.jsx(Ie,{size:10})})]},t))]}),e.jsx("textarea",{ref:pe,value:fe,onChange:t=>{J(t.target.value);const r=t.target.selectionStart??t.target.value.length;if(xe){const N=$a(t.target.value,r);N!==null?(O(!0),le(N),Xe(0)):O(!1)}const a=tt?Ta(t.target.value,r):null;a!==null?(Ne(!0),ps(a),at(0)):Ne(!1);const x=La(t.target.value,r);x!==null?(Ce(!0),ys(x),lt(0),Pa(/^\/[\w-]*$/.test(t.target.value.slice(0,r)))):Ce(!1);const u=t.target;u.style.height="auto",u.style.height=`${u.scrollHeight}px`},onKeyDown:Ya,placeholder:g?"Ask about this application… (# answer from a source)":He?"Ask for a report, chart or dashboard… (@ a test · / add a skill)":xe?"Ask anything… (@ attach a test · # add a source · / add a skill)":"Ask anything… (# add a source · / add a skill)",rows:1,disabled:U,className:"w-full bg-transparent px-4 pt-3 pb-2 text-sm text-gray-800 dark:text-gray-200 outline-none placeholder-gray-400 dark:placeholder-gray-600 resize-none disabled:opacity-40 overflow-y-auto",style:{minHeight:"38px",maxHeight:"240px"}}),xe&&p&&!fe.trim()&&e.jsx("div",{className:"px-4 pb-2 flex items-center gap-1.5 flex-wrap",children:[["Analyze","Analyze this test for quality, flakiness and missing assertions, and suggest improvements."],["Fix last failure","Investigate why this test last failed and fix it. Run it to verify."],["Strengthen assertions","Review and strengthen the assertions in this test without changing its intent."],["Refactor","Refactor this test for readability and reuse, preserving behaviour. Run it to verify."],["Update selectors","Review and update the locators/selectors in this test to be more robust."]].map(([t,r])=>e.jsx("button",{onClick:()=>{J(r),setTimeout(()=>{var a;return(a=pe.current)==null?void 0:a.focus()},0)},className:"px-2 py-1 rounded-md text-[10px] font-medium bg-black/5 dark:bg-white/5 text-gray-600 dark:text-gray-400 hover:text-brand-400 hover:bg-brand-500/10 transition-colors",children:t},t))}),!g&&Et.length>0&&e.jsx("div",{className:"px-4 pb-2 flex items-center gap-1.5 flex-wrap",children:Et.map(t=>e.jsxs("div",{title:t.savedPath?`Saved in the project as ${t.savedPath}`:t.originalName,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-brand-500/10 border border-brand-500/20 text-[10px] text-brand-300",children:[e.jsx(mi,{type:t.type,isImage:t.isImage}),e.jsx("span",{className:"truncate max-w-[120px]",children:t.originalName}),e.jsx("span",{className:"text-gray-600",children:hi(t.size)}),e.jsx("button",{onClick:()=>Oe(r=>r.filter(a=>a.id!==t.id)),className:"text-gray-500 hover:text-red-400",children:e.jsx(Ie,{size:10})})]},t.id))}),e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-t border-white/[0.05]",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>{var t;return g?st(!0):He?(t=Dt.current)==null?void 0:t.click():_e(r=>!r)},disabled:U||qa,className:"p-1.5 rounded-lg text-gray-500 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors disabled:opacity-30",title:g?"Answer from Sources":He?"Upload a results file to report on (JUnit XML, CSV, JSON …)":"Attach files or Sources","aria-haspopup":g?"dialog":He?void 0:"menu","data-testid":"attach-button",children:e.jsx(ua,{size:15})}),Ia&&!g&&!He&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>_e(!1)}),e.jsxs("div",{role:"menu",className:"absolute bottom-full left-0 mb-2 z-50 w-72 rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-xl py-1","data-testid":"attach-menu",children:[e.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{var t;_e(!1),(t=Dt.current)==null||t.click()},className:"w-full flex items-start gap-2.5 px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/5",children:[e.jsx(Yt,{size:15,className:"mt-0.5 text-cyan-500 flex-shrink-0"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm text-gray-800 dark:text-gray-100",children:"Upload from computer"}),e.jsx("span",{className:"block text-[11px] text-gray-500 truncate",children:(we==null?void 0:we.summary)??cs})]})]}),e.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{_e(!1),st(!0)},className:"w-full flex items-start gap-2.5 px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/5",children:[e.jsx(ma,{size:15,className:"mt-0.5 text-emerald-500 flex-shrink-0"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm text-gray-800 dark:text-gray-100",children:"Add from Sources"}),e.jsx("span",{className:"block text-[11px] text-gray-500",children:"Requirements, Notes, JIRA and Other Sources · or type #"})]})]})]})]})]}),e.jsx(ai,{open:Aa,onClose:()=>st(!1),selected:de,onAdd:Ue,askMode:g}),e.jsx(Dn,{value:y,onChange:pt,disabled:U,availableModes:l}),!g&&e.jsx(Ln,{value:dt,onChange:_a}),!g&&et&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>Rt(t=>{const r=!t;return r&&zt(),r}),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${ue.length>0?"text-cyan-500 dark:text-cyan-300 bg-cyan-500/10":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,title:"Connect MCP servers",children:[e.jsx(Kt,{size:13}),e.jsxs("span",{children:["MCP",ue.length>0?` (${ue.length})`:""]})]}),Ma&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Rt(!1)}),e.jsxs("div",{className:"absolute bottom-full left-0 mb-1 z-50 w-60 max-h-64 overflow-y-auto rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-xl py-1",children:[e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:"MCP servers"}),At.length===0&&e.jsxs("div",{className:"px-3 py-2.5 text-[11px] text-gray-500 dark:text-gray-400 leading-relaxed",children:["No MCP servers enabled yet. Enable them in ",e.jsx("span",{className:"font-medium text-cyan-600 dark:text-cyan-300",children:"Settings → MCPs"})," to use them here."]}),At.map(t=>{const r=ue.includes(t.id),a=t.status==="connected"?"bg-green-500":t.status==="connecting"?"bg-amber-400 animate-pulse":t.status==="error"?"bg-red-500":"bg-gray-400 dark:bg-gray-600",x=t.status==="connected"?`${t.toolCount} tools`:t.status==="connecting"?"connecting…":t.status==="error"?"error":"not connected";return e.jsxs("button",{onClick:()=>ws(t.id),title:t.status==="error"&&t.lastError?t.lastError:`${t.name} — ${x}`,className:`w-full flex items-center gap-2 px-3 py-2 text-left text-xs transition-colors ${r?"bg-cyan-500/10 text-cyan-700 dark:text-cyan-300":"text-gray-600 dark:text-gray-300 hover:bg-black/5 dark:hover:bg-white/5"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${a}`}),e.jsx(Kt,{size:12,className:"flex-shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:t.name}),e.jsx("span",{className:`text-[9px] ${t.status==="error"?"text-red-500":"text-gray-500"}`,children:x}),r&&e.jsx(Xt,{size:12,className:"text-cyan-500 flex-shrink-0"})]},t.id)}),e.jsx("div",{className:"border-t border-gray-200 dark:border-white/10 mt-1 pt-1",children:e.jsxs("button",{onClick:()=>{Rt(!1),bs("/settings?tab=mcp")},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-[11px] text-gray-500 hover:text-cyan-600 dark:hover:text-cyan-300 hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:[e.jsx(Qs,{size:12,className:"flex-shrink-0"}),e.jsx("span",{children:"Manage servers…"})]})})]})]})]}),!g&&e.jsx(_n,{}),e.jsx("div",{className:"flex-1"}),qe==="testver"&&e.jsx(zn,{refreshSignal:U}),Ts.length>0&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>Bt(!Ft),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-mono text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors max-w-[200px]",title:"Switch model",children:[e.jsx(Zs,{provider:qe,size:13}),e.jsx("span",{className:"truncate",children:qe==="testver"?"Testver":ct||"Model"}),e.jsx(ze,{size:10,className:`flex-shrink-0 transition-transform ${Ft?"rotate-180":""}`})]}),Ft&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Bt(!1)}),e.jsx("div",{className:"absolute bottom-full right-0 mb-1 w-64 bg-surface-1 border border-white/10 rounded-xl shadow-xl z-50 py-1 max-h-72 overflow-y-auto",children:Ts.map(t=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[10px] text-gray-600 uppercase tracking-wider font-semibold border-b border-white/5",children:[e.jsx(Zs,{provider:t.provider,size:14}),t.provider]}),t.models.map(r=>e.jsxs("button",{onClick:()=>{zs(t.provider),Rs(r),Bt(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-left text-sm font-mono transition-colors ${r===ct&&t.provider===qe?"bg-brand-500/10 text-brand-300":"text-gray-400 hover:bg-brand-500/10 hover:text-gray-200"}`,children:[r===ct&&t.provider===qe&&e.jsx(Be,{size:12,className:"text-brand-400 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:t.provider==="testver"?"Testver — managed model":r})]},`${t.provider}-${r}`))]},t.provider))})]})]}),U?e.jsx("button",{onClick:Fs,title:"Stop generation",className:"flex items-center justify-center w-7 h-7 rounded-full bg-gray-400 hover:bg-gray-500 transition-colors",children:e.jsx(tn,{size:11,className:"fill-gray-900 text-gray-900",strokeWidth:0})}):e.jsx("button",{onClick:Os,disabled:!fe.trim(),className:"p-1.5 rounded-lg text-gray-500 hover:text-brand-400 hover:bg-brand-500/10 transition-colors disabled:opacity-30 disabled:hover:text-gray-500 disabled:hover:bg-transparent",title:"Send message",children:e.jsx(is,{size:15})})]})]})]})})]}),g&&!f&&e.jsx(Jn,{}),e.jsxs("div",{className:`flex-shrink-0 border-l border-white/5 bg-surface-1 transition-all duration-200 flex flex-col ${f?"w-72":"w-0"} overflow-hidden`,children:[e.jsx("div",{className:"px-3 py-2.5 flex-shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx(pa,{size:12,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-600"}),e.jsx("input",{value:te,onChange:t=>Ee(t.target.value),placeholder:"Search sessions...",className:"w-full bg-surface-2 border border-white/5 rounded-lg pl-7 pr-2 py-1.5 text-xs text-gray-300 placeholder:text-gray-600 focus:outline-none focus:ring-1 focus:ring-brand-500/50"})]})}),e.jsx("div",{className:"px-3 pb-2 flex flex-wrap items-center gap-1 flex-shrink-0",children:["all",...l].map(t=>{const r=t==="all"?null:oe.find(x=>x.value===t),a=_===t;return e.jsxs("button",{onClick:()=>ee(t),className:`flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-medium transition-colors ${a?"bg-brand-500/15 text-brand-300":"bg-transparent text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,children:[r&&e.jsx(r.Icon,{size:10,className:a?"":r.colorClass}),t==="all"?"All":r==null?void 0:r.label]},t)})}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Ms.length===0&&e.jsx("div",{className:"text-center py-8 text-sm text-gray-600",children:te?"No matching sessions":"No session history yet"}),Ms.map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 pt-3 pb-1",children:e.jsx("span",{className:"text-sm font-semibold uppercase tracking-wider text-gray-600",children:t.label})}),t.items.map(r=>e.jsxs("div",{onClick:()=>Wa(r.id),className:`group relative flex items-center px-3 py-2 mx-1.5 rounded-lg cursor-pointer transition-colors ${b===r.id?"bg-brand-500/10 text-gray-200":"hover:bg-white/5 text-gray-400"}`,children:[e.jsx("div",{className:"flex-1 min-w-0",children:re===r.id?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:B,onChange:a=>je(a.target.value),onClick:a=>a.stopPropagation(),onKeyDown:a=>{a.key==="Enter"&&Es(a),a.key==="Escape"&&Y(null)},className:"flex-1 bg-surface-2 border border-white/10 rounded px-2 py-1 text-sm text-gray-200 outline-none focus:border-brand-500/50 min-w-0",autoFocus:!0}),e.jsx("button",{onClick:Es,className:"p-0.5 text-emerald-400",children:e.jsx(Ye,{size:12})})]}):e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(Pn,{mode:r.mode??"web",className:"flex-shrink-0"}),r.permissionMode==="auto"&&e.jsx("span",{title:"Auto permissions — actions approved without asking","aria-label":"Auto permissions",className:"flex-shrink-0 inline-flex",children:e.jsx(da,{size:11,className:"text-amber-500 dark:text-amber-400"})}),e.jsx("div",{className:`text-sm truncate flex-1 min-w-0 ${b===r.id?"font-medium":""}`,children:r.title})]})}),re!==r.id&&e.jsx("div",{className:`absolute right-1.5 top-1/2 -translate-y-1/2 transition-opacity ${X===r.id?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:a=>a.stopPropagation(),onMouseEnter:a=>a.stopPropagation(),children:e.jsx("button",{"data-menu-id":r.id,onClick:a=>{a.stopPropagation(),a.preventDefault(),se(X===r.id?null:r.id)},className:"p-1 rounded-lg text-gray-500 hover:text-gray-300 bg-surface-1 hover:bg-surface-2 border border-white/10 transition-colors",children:e.jsx(sn,{size:14})})})]},r.id))]},t.label))]})]}),X&&(()=>{const t=document.querySelector(`[data-menu-id="${X}"]`),r=t==null?void 0:t.getBoundingClientRect();if(!r)return null;const a=d.find(W=>W.id===X);if(!a)return null;const x=130,u=4,M=window.innerHeight-r.bottom<x+u?{bottom:window.innerHeight-r.top+u,right:window.innerWidth-r.right}:{top:r.bottom+u,right:window.innerWidth-r.right};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[200]",onClick:()=>se(null)}),e.jsxs("div",{className:"fixed z-[201] rounded-lg py-1 min-w-[140px] bg-surface-1 border border-white/10 shadow-[0_2px_8px_rgba(0,0,0,0.4)]",style:M,children:[e.jsxs("button",{onClick:()=>{Va(a.id),se(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-300 hover:bg-white/10 transition-colors",children:[K.has(a.id)?e.jsx(an,{size:14}):e.jsx(rn,{size:14}),K.has(a.id)?"Unpin":"Pin to Top"]}),e.jsxs("button",{onClick:()=>{Ka(a.id,a.title),se(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-300 hover:bg-white/10 transition-colors",children:[e.jsx(nn,{size:14})," Rename"]}),e.jsx("div",{className:"my-1 border-t border-white/10"}),e.jsxs("button",{onClick:()=>{Ja(a.id),se(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-400 hover:bg-red-500/10 transition-colors",children:[e.jsx(on,{size:12})," Delete"]})]})]})})(),e.jsx(fa,{open:!!Z,title:"Delete chat?",description:`Are you sure you want to delete "${(Z==null?void 0:Z.title)||"this chat"}"? This will permanently remove the conversation, all messages, and the full timeline history. This action cannot be undone.`,confirmLabel:"Delete",onCancel:()=>V(null),onConfirm:Ga})]})})})}function sa({what:s,error:i}){return e.jsxs("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/5 px-4 py-3 text-xs text-gray-700 dark:text-gray-300",children:["This ",s," could not be displayed: ",e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:i.message})]})}function ii(s){if(s.kind!=="tool"||s.phase!=="complete")return!1;const i=s.fullResult||s.result||"";if(s.toolName==="generate_dashboard"||s.toolName==="get_report")try{const o=JSON.parse(i);return(o==null?void 0:o.marker)==="TESTVER_DASHBOARD_SPEC"&&typeof o.id=="string"}catch{return!1}if(s.toolName==="build_report"||s.toolName==="generate_document")try{const o=JSON.parse(i);return!!(o!=null&&o.success&&(o!=null&&o.downloadUrl))}catch{return!1}return["api_request","api_send_collection_request","api_run_chain"].includes(s.toolName)?/^HTTP \d{3}/.test(i)||/^--- Request ---/.test(i)||s.toolName==="api_run_chain"&&i.startsWith("Chain:"):!1}const oi=n.memo(function({timeline:i,isStreaming:o,currentMode:h,activeSessionId:d,onContinue:m}){var j;const b=(j=i[i.length-1])==null?void 0:j.id;return e.jsx(e.Fragment,{children:li(i).map((f,$,k)=>{var g;const y=(((g=f[0])==null?void 0:g.kind)==="user"?f[0].mode:void 0)??h,w=!(o&&$===k.length-1);return y==="ask"?di(f).map(l=>{var S;return e.jsx(aa,{entry:l,askMode:!0,askFeedback:l.kind==="text"&&w&&d?{answerId:`${d}:${l.id}`,sessionId:d,question:((S=f[0])==null?void 0:S.kind)==="user"?f[0].text:void 0}:void 0},l.id)}):An(f,{toolOf:l=>l.kind==="tool"?l:null,diffOf:l=>l.kind==="diff"?l:null,isStandalone:ii,isTurnStart:l=>l.kind==="user",isInvisible:l=>l.kind==="text"&&!l.text.trim(),streaming:o}).map(l=>l.kind==="group"?e.jsx(In,{group:l,className:"!-mt-1.5 !-mb-2.5"},l.id):l.kind==="changes"?e.jsx(Tn,{item:l},l.id):e.jsx(aa,{entry:l.entry,onContinue:l.entry.kind==="error"&&l.entry.resumable&&!o&&l.entry.id===b?m:void 0},l.entry.id))})})});function li(s){const i=[];for(const o of s)o.kind==="user"||i.length===0?i.push([o]):i[i.length-1].push(o);return i}function di(s){let i=-1;s.forEach((h,d)=>{h.kind==="tool"&&(i=d)});const o=[];for(const[h,d]of s.entries()){if(d.kind==="tool"||d.kind==="loading"||d.kind==="text"&&h<i)continue;const m=o[o.length-1];if(d.kind==="text"&&(m==null?void 0:m.kind)==="text"){o[o.length-1]={...m,text:`${m.text.trimEnd()}
|
|
18
|
-
|
|
19
|
-
${d.text.trimStart()}`,done:d.done};continue}o.push(d)}return o}function ci(s){for(let i=s.length-1;i>=0;i--){const o=s[i];if(o.kind==="user"||o.kind==="tool")return!1;if(o.kind==="text"&&o.text.trim())return!0}return!1}function xi({entry:s}){const[i,o]=n.useState(()=>Date.now());if(n.useEffect(()=>{if(s.tone!=="retrying"||!s.retryAt)return;const d=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(d)},[s.tone,s.retryAt]),s.tone==="recovered")return e.jsxs("div",{className:"flex items-center gap-2 px-4 text-[12px] text-emerald-600 dark:text-emerald-400",role:"status",children:[e.jsx(Be,{size:13,className:"flex-shrink-0"}),s.text]});const h=s.retryAt?Math.max(0,Math.ceil((s.retryAt-i)/1e3)):0;return e.jsxs("div",{className:"flex items-center gap-2 px-4 text-[12px] text-amber-600 dark:text-amber-400",role:"status",children:[e.jsx(jt,{size:13,className:"flex-shrink-0 animate-spin"}),e.jsxs("span",{children:[s.text,h>0?` in ${h}s`:" now","…",s.attempt&&s.attempt>1?e.jsxs("span",{className:"opacity-70",children:[" (attempt ",s.attempt,")"]}):null,e.jsx("span",{className:"opacity-70",children:" Check your internet connection if this keeps happening."})]})]})}const aa=n.memo(ui,(s,i)=>{var o,h,d,m,b,j;return s.entry===i.entry&&s.askMode===i.askMode&&s.onContinue===i.onContinue&&((o=s.askFeedback)==null?void 0:o.answerId)===((h=i.askFeedback)==null?void 0:h.answerId)&&((d=s.askFeedback)==null?void 0:d.sessionId)===((m=i.askFeedback)==null?void 0:m.sessionId)&&((b=s.askFeedback)==null?void 0:b.question)===((j=i.askFeedback)==null?void 0:j.question)});function ui({entry:s,askMode:i,askFeedback:o,onContinue:h}){var j;const[d,m]=n.useState(!1),{monacoTheme:b}=ka();if(s.kind==="user")return e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[75%] rounded-2xl rounded-tr-md px-4 py-2.5 bg-brand-600/90 text-white text-[13px] leading-relaxed shadow-sm whitespace-pre-wrap break-words",children:s.text})});if(s.kind==="system")return e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-white/[0.03] border border-white/5",children:[e.jsx(wt,{size:11,className:"text-gray-500"}),e.jsx("span",{className:"text-[11px] text-gray-500",children:s.text})]})});if(s.kind==="text"){const f=s.text.trimEnd();return f?e.jsx("div",{className:"flex items-start",children:e.jsx("div",{className:"text-gray-200 px-4 py-2.5 min-w-0 max-w-[85%] overflow-hidden",children:i?e.jsx(Vn,{text:f,feedback:o}):e.jsx(es,{text:f})})}):null}if(s.kind==="tool"){const f=s.result||s.error||s.args,$=["api_request","api_send_collection_request","api_run_chain"].includes(s.toolName),k=s.fullResult||s.result||"",y=$&&k&&(/^HTTP \d{3}/.test(k)||/^--- Request ---/.test(k)),w=s.toolName==="api_run_chain"&&k&&k.startsWith("Chain:");if((s.toolName==="generate_dashboard"||s.toolName==="get_report")&&s.phase==="complete"){const g=s.fullResult||s.result||"";try{const l=JSON.parse(g);if((l==null?void 0:l.marker)==="TESTVER_DASHBOARD_SPEC"&&typeof l.id=="string")return e.jsx("div",{className:"my-2",children:e.jsx(ta,{fallback:S=>e.jsx(sa,{what:"dashboard",error:S}),children:e.jsx(Qn,{result:l})})},s.id)}catch{}}if((s.toolName==="build_report"||s.toolName==="generate_document")&&s.phase==="complete"){const g=s.fullResult||s.result||"";try{const l=JSON.parse(g);if(l!=null&&l.success&&(l!=null&&l.downloadUrl)){const S=/\.pdf(?:$|\?)/i.test(l.downloadUrl),c=typeof l.displayName=="string"?l.displayName:l.filename;return e.jsx("div",{className:"my-2",children:e.jsx(ta,{fallback:A=>e.jsx(sa,{what:"document",error:A}),children:S?e.jsx(Yn,{url:l.downloadUrl,filename:c}):e.jsx(Zn,{url:l.downloadUrl,filename:c,size:typeof l.size=="string"?l.size:void 0})})},s.id)}}catch{}}if(y&&s.phase==="complete"){const g=k.split(`
|
|
20
|
-
`);let l="",S="",c="",A="";const I=g.indexOf("--- Request ---");if(I>=0&&g[I+1]){const H=g[I+1].match(/^(\w+)\s+(.+)$/);H&&(l=H[1].toUpperCase(),S=H[2])}const R=g.find(T=>T.startsWith("Name: "));R&&(c=R.replace("Name: ",""));const L=g.find(T=>T.startsWith("Resolved URL: ")),v=L?L.replace("Resolved URL: ",""):"",F=g.indexOf("--- Request Body ---"),_=g.findIndex(T=>/^HTTP \d{3}/.test(T)),ee=F>=0&&_>F?g.slice(F+1,_).join(`
|
|
21
|
-
`).trim():"",Y=(g.find(T=>/^HTTP \d{3}/.test(T))||"").match(/^HTTP (\d{3}) (.+)$/),B=Y?parseInt(Y[1]):0,je=Y?Y[2]:"",te=g.find(T=>T.startsWith("Duration:"))||"",Ee=te.match(/Duration: (\d+)ms/),X=te.match(/Size: (.+?)$/),se=Ee?Ee[1]:"",Z=X?X[1]:"",V=g.find(T=>T.startsWith("Validations:")),K=g.indexOf("--- Body ---"),ve=g.indexOf("--- Headers ---"),ae=K>=0?g.slice(K+1).join(`
|
|
22
|
-
`).trim():"",E=ve>=0&&K>=0?g.slice(ve+1,K-1).join(`
|
|
23
|
-
`).trim():"";if(!l&&s.args)try{const T=JSON.parse(s.args);l=(T.method||"").toUpperCase(),S=S||T.url||"",T.collection&&(A=T.request?`${T.collection} / ${T.request}`:T.collection)}catch{}const fe=B>=200&&B<300?"bg-emerald-500/15 text-emerald-400 border-emerald-500/30":B>=300&&B<400?"bg-amber-500/15 text-amber-400 border-amber-500/30":B>=400&&B<500?"bg-orange-500/15 text-orange-400 border-orange-500/30":"bg-red-500/15 text-red-400 border-red-500/30",J={GET:"text-emerald-400 bg-emerald-500/15",POST:"text-blue-400 bg-blue-500/15",PUT:"text-amber-400 bg-amber-500/15",PATCH:"text-brand-400 bg-brand-500/15",DELETE:"text-red-400 bg-red-500/15"};return e.jsx("div",{className:"my-2",children:e.jsxs("div",{className:"rounded-2xl border border-white/10 bg-surface-1 overflow-hidden max-w-[650px] shadow-sm",children:[e.jsxs("div",{className:"px-4 py-2.5 bg-surface-2/50 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rs,{size:14,className:"text-gray-500 flex-shrink-0"}),l&&e.jsx("span",{className:`px-2 py-0.5 rounded-md text-xs font-bold ${J[l]||"text-gray-400 bg-gray-500/15"}`,children:l}),e.jsx("span",{className:"text-sm font-mono text-gray-300 truncate",children:S||s.toolName})]}),(c||A)&&e.jsxs("div",{className:"flex items-center gap-2 mt-1 ml-6",children:[c&&e.jsx("span",{className:"text-xs text-gray-400",children:c}),A&&e.jsx("span",{className:"text-xs text-gray-600",children:A})]}),v&&e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 ml-6",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Resolved:"}),e.jsx("span",{className:"text-xs font-mono break-all",style:{color:"#d39034cc"},children:v})]})]}),ee&&e.jsxs("div",{className:"border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5",children:[e.jsx("span",{className:"text-xs text-gray-500 font-medium",children:"Request Body"}),e.jsx(vt,{text:ee})]}),e.jsx("div",{className:"max-h-[150px] overflow-auto",children:(()=>{let T=!1,H=ee;try{H=JSON.stringify(JSON.parse(ee),null,2),T=!0}catch{}return T?e.jsx("pre",{className:"px-4 pb-2 text-xs font-mono text-orange-700 dark:text-orange-300/70 whitespace-pre-wrap break-words",children:H}):e.jsx("pre",{className:"px-4 pb-2 text-xs font-mono text-gray-400 whitespace-pre-wrap break-words",children:H})})()})]}),e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-white/5",children:[e.jsx("span",{className:"text-xs text-gray-500 font-medium uppercase",children:"Response"}),e.jsxs("span",{className:`px-2.5 py-0.5 rounded-lg text-sm font-bold border ${fe}`,children:[B," ",je]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto text-xs text-gray-500",children:[se&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cn,{size:12,className:"text-gray-600"})," ",se,"ms"]}),Z&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ys,{size:12,className:"text-gray-600"})," ",Z]})]})]}),V&&e.jsx("div",{className:`px-4 py-1.5 text-xs font-medium border-b border-white/5 ${V.includes("0/")?"text-red-400 bg-red-500/5":V.startsWith("Validations: "+((j=V.split("/")[1])==null?void 0:j.split(" ")[0]))?"text-emerald-400 bg-emerald-500/5":"text-cyan-400 bg-cyan-500/5"}`,children:V}),E&&e.jsxs("div",{className:"border-b border-white/5",children:[e.jsxs("button",{onClick:()=>m(!d),className:"w-full flex items-center gap-1.5 px-4 py-2 text-xs text-gray-500 hover:text-gray-300 hover:bg-white/[0.02] transition-colors",children:[d?e.jsx(ze,{size:11}):e.jsx(ha,{size:11}),e.jsx("span",{className:"font-medium",children:"Headers"}),e.jsxs("span",{className:"text-gray-600",children:["(",E.split(`
|
|
24
|
-
`).length,")"]})]}),d&&e.jsx("div",{className:"px-4 pb-2 space-y-0.5",children:E.split(`
|
|
25
|
-
`).filter(T=>T.includes(":")).map((T,H)=>{const ne=T.indexOf(":"),p=T.slice(0,ne).trim(),C=T.slice(ne+1).trim();return e.jsxs("div",{className:"flex gap-2 text-xs font-mono",children:[e.jsxs("span",{className:"text-gray-900 dark:text-gray-300 font-semibold flex-shrink-0",children:[p,":"]}),e.jsx("span",{className:"text-gray-400 break-all",children:C})]},H)})})]}),ae&&(()=>{let T=!1,H=ae;try{H=JSON.stringify(JSON.parse(ae),null,2),T=!0}catch{}const ne=H.split(`
|
|
26
|
-
`).length,p=Math.min(Math.max(ne*20,60),300),C=()=>{const z=new Blob([H],{type:"application/json"}),O=URL.createObjectURL(z),P=document.createElement("a");P.href=O,P.download=`response-${Date.now()}.json`,document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(O)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 border-b border-white/[0.03]",children:[e.jsx("span",{className:"text-xs text-gray-500 font-medium",children:"Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(vt,{text:H}),e.jsxs("button",{onClick:C,className:"flex items-center gap-1 px-2 py-0.5 rounded text-xs text-gray-600 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors",title:"Download as JSON",children:[e.jsx(Nt,{size:12})," Download"]})]})]}),T?e.jsx("div",{style:{height:`${p}px`},children:e.jsx(va,{value:H,language:"json",theme:b,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineHeight:20,scrollBeyondLastLine:!1,wordWrap:"on",padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:6,horizontalScrollbarSize:6},lineNumbers:"off",folding:!0,bracketPairColorization:{enabled:!0},renderLineHighlight:"none",automaticLayout:!0}})}):e.jsx("div",{className:"max-h-[280px] overflow-auto",children:e.jsx("pre",{className:"px-4 py-2.5 text-sm font-mono text-gray-300 whitespace-pre-wrap break-words leading-relaxed",children:H})})]})})()]})})}return w&&s.phase==="complete"?e.jsx(pi,{result:k}):e.jsxs("div",{className:"my-0.5",children:[e.jsxs("button",{onClick:()=>f&&m(!d),className:`flex items-center gap-2 px-4 py-1.5 rounded-lg transition-colors text-left ${f?"hover:bg-white/[0.03] cursor-pointer":"cursor-default"}`,children:[s.phase==="start"&&e.jsx(jt,{size:11,className:"text-blue-400 animate-spin flex-shrink-0"}),s.phase==="complete"&&e.jsx(Be,{size:11,className:"text-emerald-400 flex-shrink-0"}),s.phase==="error"&&e.jsx(Zt,{size:11,className:"text-red-400 flex-shrink-0"}),s.phase==="denied"&&e.jsx(xn,{size:11,className:"text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-mono text-gray-500",children:s.toolName}),s.phase==="start"&&e.jsx("span",{className:"text-[10px] text-gray-600 truncate max-w-[250px]",children:s.args}),s.phase==="error"&&s.error&&e.jsx("span",{className:"text-[10px] text-red-400 truncate max-w-[200px]",children:s.error}),f&&s.phase!=="start"&&e.jsx(ze,{size:10,className:`text-gray-600 transition-transform ${d?"rotate-180":""}`})]}),d&&f&&e.jsxs("div",{className:"mt-1 max-h-[200px] overflow-auto rounded-lg bg-black/30 border border-white/5 p-2.5",children:[s.args&&e.jsx("div",{className:"text-[10px] font-mono text-gray-500 mb-1 break-all",children:s.args}),s.result&&e.jsx("div",{className:"text-[10px] font-mono text-gray-400 break-all whitespace-pre-wrap",children:s.result.slice(0,2e3)}),s.error&&e.jsx("div",{className:"text-[10px] font-mono text-red-400 break-all",children:s.error})]})]})}return s.kind==="diff"?e.jsx("div",{className:"my-1",children:e.jsx(En,{diffs:[{filePath:s.filePath,diffType:s.diffType,diff:s.diff,linesAdded:s.linesAdded,linesRemoved:s.linesRemoved,timestamp:Date.now()}]})}):s.kind==="error"?e.jsx("div",{className:"flex items-start",children:e.jsxs("div",{className:"flex items-start gap-2 bg-red-500/10 border border-red-500/20 rounded-2xl rounded-tl-md px-4 py-2.5 text-[13px] text-red-300 shadow-sm",children:[e.jsx(Zt,{size:13,className:"text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("span",{children:[s.text,h&&e.jsxs("button",{onClick:h,className:"mt-2 flex items-center gap-1 px-3 py-1 rounded-lg text-xs font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:["Continue ",e.jsx(Ys,{size:12})]})]})]})}):s.kind==="notice"?e.jsx(xi,{entry:s}):s.kind==="loading"?e.jsx("div",{className:"flex items-start",children:e.jsx("div",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400/60 animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400/60 animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400/60 animate-bounce",style:{animationDelay:"300ms"}})]})})}):null}function mi({type:s,isImage:i}){return i?e.jsx(dn,{size:10,className:"text-purple-400"}):s==="pdf"?e.jsx(Re,{size:10,className:"text-red-400"}):s==="word"?e.jsx(Re,{size:10,className:"text-blue-400"}):s==="excel"||s==="csv"?e.jsx(yt,{size:10,className:"text-emerald-400"}):s==="code"?e.jsx(Re,{size:10,className:"text-amber-400"}):e.jsx(xa,{size:10,className:"text-gray-400"})}function pi({result:s}){const[i,o]=n.useState(new Set),{monacoTheme:h}=ka(),d=s.split(`
|
|
27
|
-
`),m=d.find(c=>c.startsWith("Chain:"))||"Chain Run",b=d.filter(c=>/^(?:\S{1,3}\s+)?Step \d+:/.test(c)),j=d.find(c=>c.startsWith("Result:"))||"",f=/Result: (\d+)\/(\d+)/.exec(j),$=!!f&&f[1]===f[2]&&Number(f[2])>0,k=d.indexOf("--- CHAIN_DETAILS_JSON ---");let y=[];if(k>=0&&d[k+1])try{y=JSON.parse(d[k+1])}catch{}const w=c=>{o(A=>{const I=new Set(A);return I.has(c)?I.delete(c):I.add(c),I})},g={GET:"text-emerald-400",POST:"text-blue-400",PUT:"text-amber-400",PATCH:"text-brand-400",DELETE:"text-red-400"},l={GET:"bg-emerald-500/15",POST:"bg-blue-500/15",PUT:"bg-amber-500/15",PATCH:"bg-brand-500/15",DELETE:"bg-red-500/15"},S=y.length>0?y:b.map((c,A)=>{const I=c.match(/Step (\d+): (\w+) (.+?) → (\d{3}) (.+?) \((\d+)ms[^)]*\)/),R=c.startsWith("✅")?!0:c.startsWith("❌")?!1:void 0;return I?{step:parseInt(I[1]),method:I[2],url:I[3],status:parseInt(I[4]),statusText:I[5],duration:parseInt(I[6]),name:"",resolvedUrl:"",requestBody:"",responseBody:"",headers:{},error:"",extractedVars:{},validations:[],size:0,passed:R}:null}).filter(Boolean);return e.jsx("div",{className:"ml-10 my-2",children:e.jsxs("div",{className:"rounded-2xl border border-white/10 bg-surface-1 overflow-hidden max-w-[700px] shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 bg-surface-2/50 border-b border-white/5",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${$?"bg-emerald-500/15":"bg-orange-500/15"}`,children:$?e.jsx(Be,{size:16,className:"text-emerald-400"}):e.jsx(wt,{size:16,className:"text-orange-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-gray-200",children:m}),e.jsx("div",{className:`text-xs font-medium ${$?"text-emerald-400":"text-orange-400"}`,children:j})]})]}),e.jsx("div",{className:"divide-y divide-white/[0.03]",children:S.map(c=>{const A=typeof c.passed=="boolean"?c.passed:c.status>=200&&c.status<400,I=i.has(c.step),R=c.responseBody||c.requestBody||Object.keys(c.headers||{}).length>0;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>R&&w(c.step),className:`w-full flex items-center gap-2 px-3 py-2.5 text-left transition-colors hover:bg-brand-500/5 ${R?"cursor-pointer":"cursor-default"} ${I?"bg-brand-500/5":""}`,children:[R&&(I?e.jsx(ze,{size:11,className:"text-gray-600 flex-shrink-0"}):e.jsx(ha,{size:11,className:"text-gray-600 flex-shrink-0"})),!R&&e.jsx("span",{className:"w-3"}),e.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0 text-[10px] font-bold ${A?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:c.step}),e.jsx("span",{className:`text-xs font-bold w-12 flex-shrink-0 ${g[c.method]||"text-gray-400"}`,children:c.method}),e.jsx("span",{className:"text-xs font-mono text-gray-400 truncate flex-1",children:c.url}),c.skipped?e.jsx("span",{className:"text-xs text-gray-500",children:"skipped"}):e.jsx("span",{className:`text-xs font-bold ${A?"text-emerald-400":"text-red-400"}`,children:c.status}),e.jsxs("span",{className:"text-xs text-gray-600 w-14 text-right",children:[c.skipped?"":`${c.duration}ms`,c.attempts>1?` ×${c.attempts}`:""]})]}),I&&R&&e.jsxs("div",{className:"mx-3 mb-3 rounded-xl border border-white/5 bg-black/10 overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 bg-surface-2/30 border-b border-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold ${l[c.method]||"bg-gray-500/15"} ${g[c.method]||"text-gray-400"}`,children:c.method}),e.jsx("span",{className:"text-xs font-mono text-gray-300 truncate",children:c.url})]}),c.name&&e.jsx("div",{className:"text-[11px] text-gray-500 mt-0.5 ml-1",children:c.name}),c.resolvedUrl&&e.jsxs("div",{className:"text-[11px] mt-0.5 ml-1",children:[e.jsx("span",{className:"text-gray-600",children:"Resolved: "}),e.jsx("span",{style:{color:"#d39034cc"},children:c.resolvedUrl})]})]}),c.requestBody&&e.jsxs("div",{className:"border-b border-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[e.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:"Request Body"}),e.jsx(vt,{text:c.requestBody})]}),e.jsx("pre",{className:"px-3 pb-2 text-xs font-mono text-orange-700 dark:text-orange-300/70 whitespace-pre-wrap break-words max-h-[120px] overflow-auto",children:(()=>{try{return JSON.stringify(JSON.parse(c.requestBody),null,2)}catch{return c.requestBody}})()})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-white/[0.03]",children:[e.jsx("span",{className:"text-[11px] text-gray-500",children:"Response"}),e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[11px] font-bold ${A?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:[c.status," ",c.statusText]}),e.jsxs("span",{className:"text-[11px] text-gray-600 ml-auto",children:[c.duration,"ms · ",c.size>0?c.size<1024?`${c.size}B`:`${(c.size/1024).toFixed(1)}KB`:"",c.attempts>1?` · ${c.attempts} attempts`:""]})]}),Array.isArray(c.failures)&&c.failures.length>0&&e.jsx("div",{className:"px-3 py-1.5 border-b border-white/[0.03] space-y-0.5",children:c.failures.map((L,v)=>e.jsxs("div",{className:"flex gap-1.5 text-[11px] text-red-400",children:[e.jsx(Zt,{size:11,className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words",children:L})]},v))}),Object.keys(c.headers||{}).length>0&&e.jsxs("details",{className:"border-b border-white/[0.03]",children:[e.jsxs("summary",{className:"px-3 py-1.5 text-[11px] text-gray-500 cursor-pointer hover:text-gray-300",children:["Headers (",Object.keys(c.headers).length,")"]}),e.jsx("div",{className:"px-3 pb-2 space-y-0.5",children:Object.entries(c.headers).map(([L,v])=>e.jsxs("div",{className:"flex gap-2 text-[11px] font-mono",children:[e.jsxs("span",{className:"text-gray-900 dark:text-gray-300 font-semibold flex-shrink-0",children:[L,":"]}),e.jsx("span",{className:"text-gray-400 break-all",children:String(v)})]},L))})]}),c.responseBody&&(()=>{let L=!1,v=c.responseBody;try{v=JSON.stringify(JSON.parse(c.responseBody),null,2),L=!0}catch{}const F=v.split(`
|
|
28
|
-
`).length,_=Math.min(Math.max(F*18,50),200),ee=()=>{const re=new Blob([v],{type:"application/json"}),Y=URL.createObjectURL(re),B=document.createElement("a");B.href=Y,B.download=`step-${c.step}-response-${Date.now()}.json`,document.body.appendChild(B),B.click(),document.body.removeChild(B),URL.revokeObjectURL(Y)};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[e.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:"Response Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(vt,{text:v}),e.jsxs("button",{onClick:ee,className:"flex items-center gap-1 px-2 py-0.5 rounded text-xs text-gray-600 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors",title:"Download as JSON",children:[e.jsx(Nt,{size:11})," Download"]})]})]}),L?e.jsx("div",{style:{height:`${_}px`},children:e.jsx(va,{value:v,language:"json",theme:h,options:{readOnly:!0,minimap:{enabled:!1},fontSize:12,lineHeight:18,scrollBeyondLastLine:!1,wordWrap:"on",padding:{top:4,bottom:4},scrollbar:{verticalScrollbarSize:5,horizontalScrollbarSize:5},lineNumbers:"off",folding:!0,bracketPairColorization:{enabled:!0},renderLineHighlight:"none",automaticLayout:!0}})}):e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("pre",{className:"px-3 pb-2 text-xs font-mono text-gray-300 whitespace-pre-wrap break-words",children:v})})]})})(),Object.keys(c.extractedVars||{}).length>0&&e.jsxs("div",{className:"px-3 py-1.5 bg-cyan-500/5 border-t border-white/[0.03]",children:[e.jsx("span",{className:"text-[11px] text-cyan-400 font-medium",children:"Extracted Variables: "}),e.jsx("span",{className:"text-[11px] font-mono text-cyan-300",children:JSON.stringify(c.extractedVars)})]}),c.error&&e.jsx("div",{className:"px-3 py-1.5 bg-red-500/5 border-t border-white/[0.03] text-[11px] text-red-400",children:c.error})]})]},c.step)})})]})})}function vt({text:s}){const[i,o]=n.useState(!1);return e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(s).catch(()=>{}),o(!0),setTimeout(()=>o(!1),1500)},className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs transition-colors ${i?"text-emerald-400 bg-emerald-500/10":"text-gray-600 hover:text-cyan-400 hover:bg-cyan-500/10"}`,title:i?"Copied!":"Copy response",children:i?e.jsxs(e.Fragment,{children:[e.jsx(Xt,{size:12})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ca,{size:12})," Copy"]})})}function hi(s){return s<1024?`${s}B`:s<1024*1024?`${Math.round(s/1024)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}const ra=[{id:"web",label:"Web",icon:rs,iconColor:"text-blue-600 dark:text-sky-400",iconBg:"bg-blue-50 dark:bg-sky-500/10",capabilities:["generate","run","fix"],chipClass:"text-blue-700 bg-blue-50 dark:text-blue-300 dark:bg-blue-500/15",description:"Design, build and maintain browser test automation — scripts, page objects, locators and fixes.",examples:["Generate a Playwright login test for /login","Stabilize the flaky selector in checkout.spec","Refactor the LoginPage page object"]},{id:"mobile",label:"Mobile",icon:ns,iconColor:"text-indigo-600 dark:text-indigo-400",iconBg:"bg-indigo-50 dark:bg-indigo-500/10",capabilities:["record","generate","run","fix"],chipClass:"text-indigo-700 bg-indigo-50 dark:text-indigo-300 dark:bg-indigo-500/15",description:"Build and maintain native iOS and Android tests via Appium, on local or cloud devices.",examples:["Generate an Appium login test for the app","Tap through onboarding and create a test","Fix the broken accessibility-id locator"]},{id:"api",label:"API",icon:is,iconColor:"text-purple-600 dark:text-purple-400",iconBg:"bg-purple-50 dark:bg-purple-500/10",capabilities:["import spec","chain","assert"],chipClass:"text-purple-700 bg-purple-50 dark:text-purple-300 dark:bg-purple-500/15",description:"Generate, validate and chain API tests — endpoints, schemas, collections.",examples:["Generate a contract test for POST /users","Build an auth + CRUD test chain","Validate the response JSON schema"]},{id:"reporting",label:"Reporting",icon:ln,iconColor:"text-emerald-600 dark:text-emerald-400",iconBg:"bg-emerald-50 dark:bg-emerald-500/10",capabilities:["analyse","dashboards","PDF · Excel","share · schedule · email"],chipClass:"text-emerald-700 bg-emerald-50 dark:text-emerald-300 dark:bg-emerald-500/15",description:"Analyse runs and results, then build dashboards and documents — save, share, schedule or email them.",examples:["Summarize the last failure","Show the top 5 flaky tests this week as a chart","Build a pass-rate dashboard for the last 30 days"]},{id:"ask",label:"Ask",icon:la,iconColor:"text-cyan-600 dark:text-cyan-400",iconBg:"bg-cyan-50 dark:bg-cyan-500/10",capabilities:["read-only","cites sources"],chipClass:"text-cyan-700 bg-white border border-cyan-200 dark:text-cyan-300 dark:bg-cyan-500/10 dark:border-cyan-500/25",description:"What the app you are testing does — answered from explorations, test cases and documents.",examples:["How do notification preferences work?","Which roles can reach user administration?","What does the checkout flow do after payment?"]}];function fi({displayName:s,currentMode:i,onPickMode:o,onPrefillPrompt:h,isStreaming:d,availableModes:m}){const b=n.useMemo(()=>ri(),[]),j=n.useMemo(()=>m?ra.filter(f=>m.includes(f.id)):ra,[m]);return e.jsx("div",{className:"flex-1 overflow-y-auto bg-white dark:bg-white/[0.02]",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-14",children:[e.jsxs("div",{className:"text-center mb-12 opacity-0 animate-rise-in",style:{animationDelay:"0ms"},children:[e.jsxs("h1",{className:"text-3xl font-semibold tracking-tight",children:[e.jsxs("span",{className:"text-gray-900 dark:text-gray-100",children:[b,", "]}),e.jsx("span",{className:"bg-gradient-to-r from-brand-500 to-cyan-500 bg-clip-text text-transparent",children:s||"there"})]}),e.jsx("p",{className:"mt-2 text-sm text-gray-500 dark:text-gray-400",children:"What would you like to work on today?"})]}),e.jsx("div",{className:"rounded-2xl overflow-hidden opacity-0 animate-rise-in",style:{animationDelay:"120ms"},children:j.map((f,$)=>{const k=f.icon,y=f.id===i;return e.jsxs("button",{type:"button",onClick:()=>o(f.id),disabled:d,"aria-current":y?"true":void 0,className:`w-full text-left flex items-center gap-4 px-5 py-4 transition-colors
|
|
29
|
-
disabled:opacity-60 disabled:cursor-not-allowed
|
|
30
|
-
${$>0?"border-t border-gray-100 dark:border-white/5":""}
|
|
31
|
-
${y?f.iconBg:"bg-transparent hover:bg-gray-50 dark:hover:bg-white/[0.04]"}`,children:[e.jsx("span",{className:`flex-shrink-0 w-10 h-10 rounded-xl flex items-center justify-center
|
|
32
|
-
${y?"bg-white dark:bg-white/10":f.iconBg}`,children:e.jsx(k,{size:18,className:f.iconColor})}),e.jsx("span",{className:"w-24 flex-shrink-0 flex items-center gap-2",children:e.jsx("span",{className:"text-[16px] font-semibold text-gray-900 dark:text-gray-100",children:f.label})}),e.jsx("span",{className:"flex-1 min-w-0 text-[13.5px] leading-snug text-gray-500 dark:text-gray-400",children:f.description}),e.jsx("span",{className:"flex-shrink-0 hidden sm:flex flex-wrap justify-end items-center gap-1.5 max-w-[17rem]",children:f.capabilities.map(w=>e.jsx("span",{className:`text-[11.5px] px-2 py-0.5 rounded-full whitespace-nowrap ${f.chipClass}`,children:w},w))})]},f.id)})})]})})}function Wi(){return e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden h-full",children:e.jsx(ni,{})})}export{Wi as AIPanel};
|