@testver/testver 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/bin/testver.js +1 -1
- package/dist/index.js +1943 -1190
- package/package.json +2 -1
- package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
- package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-Cg21-P1W.js → AITestGenPage-CHaHfmu4.js} +5 -5
- package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
- package/src/ui/static/assets/{AboutPage-yJLCr2_q.js → AboutPage-CDa24SCJ.js} +1 -1
- package/src/ui/static/assets/AdvancedPage-BqXP0FLg.js +3 -0
- package/src/ui/static/assets/{AnalyticsPage-gTPFsiLZ.js → AnalyticsPage-Lm8noJqC.js} +1 -1
- package/src/ui/static/assets/{AuditLogPage-DE45E_PV.js → AuditLogPage-BvldSIik.js} +1 -1
- package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-DgU6ZYBO.js → CodeMapPage-uEjuo3fk.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-DNU3qoAP.js → ConfirmDialog-DtotgVmI.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-BpTjgcdV.js → CoveragePage-jNkQJA1P.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-DsnX-vRr.js → CronBuilder-D2fERHt9.js} +1 -1
- package/src/ui/static/assets/Dashboard-BaIj_IdQ.js +1 -0
- package/src/ui/static/assets/{DefectsPage-BtMNbq6Z.js → DefectsPage-DH0njYFG.js} +3 -3
- package/src/ui/static/assets/{EmptyState-BH_aDO0P.js → EmptyState-utxlJ0fu.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Ce_MxnM1.js → ExportButton-ouKqn9CU.js} +1 -1
- package/src/ui/static/assets/{FileViewer-iYL0lxyY.js → FileViewer-mU3JloJ6.js} +5 -5
- package/src/ui/static/assets/{GitPage-CQqV8JBC.js → GitPage-TrX-RqNC.js} +5 -5
- package/src/ui/static/assets/{ImportExportPage-DXk7Koaq.js → ImportExportPage-CIhK_raX.js} +1 -1
- package/src/ui/static/assets/{JiraPushDialog-CqftoLh8.js → JiraPushDialog-DgEZS-0u.js} +1 -1
- package/src/ui/static/assets/KpiTile-BHLE3HVj.js +1 -0
- package/src/ui/static/assets/{LiveExecutionView-BD0wE8sz.js → LiveExecutionView-CaIf7Jux.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-DiSINwmh.js → MediaModal-DNM45Uz2.js} +1 -1
- package/src/ui/static/assets/{MobileRunPicker-BNs2lZFf.js → MobileRunPicker-DFKm6_nU.js} +1 -1
- package/src/ui/static/assets/{MobileRunTarget-D2Nqcj10.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
- package/src/ui/static/assets/{ModuleExplorer-BmkoQrHb.js → ModuleExplorer-rni7JbsL.js} +1 -1
- package/src/ui/static/assets/{OutputPage-Dcsr7cmr.js → OutputPage-Cn2WCpJ6.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-D6zWcLtD.js +1 -0
- package/src/ui/static/assets/{ProfilePage-ByshrcwC.js → ProfilePage-BKNdkSnx.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-B9B___ij.js → ProjectExplorer-5e7J8t-o.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-DbPnaZ-v.js → RemoteFileStrip-C1S2aclP.js} +1 -1
- package/src/ui/static/assets/ReportCard-D4EElEe9.js +2 -0
- package/src/ui/static/assets/ReportFullView-2w2ysKRg.js +1 -0
- package/src/ui/static/assets/ReportsPage-9Fx-IEwV.js +48 -0
- package/src/ui/static/assets/ResultsPage-DPkfGh-K.js +115 -0
- package/src/ui/static/assets/RunState-CRuS_bC2.js +1 -0
- package/src/ui/static/assets/{RunTargets-C7Vqd4TU.js → RunTargets-CPKBrefj.js} +1 -1
- package/src/ui/static/assets/{ScriptMappingPage-BrANeHv0.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
- package/src/ui/static/assets/{SearchableDevicePicker-CFJ_DUAA.js → SearchableDevicePicker-DubIldKj.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-BwOiebKG.js → SettingsPage-BuZrrlW2.js} +1 -1
- package/src/ui/static/assets/SharedReportView-ig5hECRk.js +1 -0
- package/src/ui/static/assets/{SourcesPage-C_QVQwiA.js → SourcesPage-BPkqRqkC.js} +1 -1
- package/src/ui/static/assets/TestExplorerPage-C_jl93GR.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-Ch4PthuU.js → TestManagementPage-DJiWpCne.js} +1 -1
- package/src/ui/static/assets/TestPlansPage-G1lvK1C0.js +5 -0
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-CUsMGEe3.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
- package/src/ui/static/assets/{UncommittedDiffViewer-B5HSURk8.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-BjY3ftxf.js → UserManagementPage-gDGhaHE4.js} +3 -3
- package/src/ui/static/assets/{WorkflowsPage-BUu-LjZ8.js → WorkflowsPage-BACdnU-1.js} +17 -17
- package/src/ui/static/assets/{hiddenLlmProviders-setxgY_B.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
- package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/index-aInN0yoR.css +1 -0
- package/src/ui/static/assets/reportMeta-3kxT7BIT.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-DqhngqgG.js → useFeatureFlags-DrhvBp0C.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-TM1Rfj1s.js → useJiraConnector-Dwj69Rfh.js} +1 -1
- package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
- package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-HqvURJAc.js → useTestExplorer-CUqC18DV.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-CL7-zz0Q.js → useTestLifecycle-C2S_vaX2.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-ZTA1_VUm.js → useTestManagement-DW6AW2mt.js} +2 -2
- package/src/ui/static/assets/useTestResults-yjH1aUy-.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-B0wLOBoh.js → vendor-icons-D_Dmmj8d.js} +277 -282
- 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 +5 -5
- package/src/ui/static/assets/AIPanel-D09Ni3a4.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +0 -40
- package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +0 -19
- package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +0 -3
- package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +0 -2
- package/src/ui/static/assets/Dashboard-DRWbVyTb.js +0 -1
- package/src/ui/static/assets/DiffViewer-DPglzjPH.js +0 -2
- package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +0 -1
- package/src/ui/static/assets/ReportCard-BbNfk85h.js +0 -2
- package/src/ui/static/assets/ReportFullView-Cg1rggho.js +0 -1
- package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +0 -48
- package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +0 -115
- package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +0 -7
- package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +0 -5
- package/src/ui/static/assets/index-B0klHYbO.css +0 -1
- package/src/ui/static/assets/index-DtBWNlVD.js +0 -47
- package/src/ui/static/assets/useOwnership-eW6Egd7X.js +0 -1
- package/src/ui/static/assets/useSuites-CvtMGakZ.js +0 -1
- package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testver/testver",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "AI-powered interactive CLI for test automation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"dist/wdio-bootstrap/",
|
|
20
20
|
"dist/wdio-json-reporter/",
|
|
21
21
|
"dist/py-agent/",
|
|
22
|
+
"!**/__pycache__",
|
|
22
23
|
"dist/java-agent/",
|
|
23
24
|
"dist/dotnet-agent/",
|
|
24
25
|
"dist/vendor/",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var Va=Object.defineProperty;var Qa=(s,n,l)=>n in s?Va(s,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[n]=l;var Sr=(s,n,l)=>Qa(s,typeof n!="symbol"?n+"":n,l);import{u as Ft,r as i,j as e,n as Ur,L as fe,d as Ya}from"./vendor-react-DOVfxdUy.js";import{b as Hr,N as Xa,O as Za,h as en,P as tn,Q as sn,S as Cr,T as $r,U as rn,V as Ir,W as an,X as nn,j as on,Y as ln,Z as Wr,_ as dn,$ as Kr,a0 as Jr,a1 as cn,a2 as un,a3 as xn,a4 as mn,a5 as pn,a6 as As,a7 as hn,a8 as fn,x as gn,a9 as bn,aa as yn,ab as kn,ac as vn,ad as jn,ae as wn,af as Nn,ag as Ar,ah as Sn,ai as Cn,aj as $n,ak as In,al as hs,am as fs,an as An,ao as Rr,ap as Tr,aq as Rn,ar as Tn,as as qn,at as En,au as Mn,av as Pn,aw as zn}from"./index-D6sQYc_0.js";import{u as Dn}from"./RemoteFileStrip-C1S2aclP.js";import{G as Ln,K as Rs,J as Ts,a6 as qs,b as On,O as Gr,y as Se,ag as dt,bc as _n,Z as Vr,bd as js,r as Qe,_ as Es,a0 as Bt,a as Ut,b9 as Fn,at as Bn,X as Ie,e as qr,az as Un,a_ as Qr,v as Ms,t as Lt,F as Hn,a1 as Wn,ah as Yr,be as Kn,bf as Jn,i as Oe,a5 as Ht,bg as Dt,aL as Xr,d as Gn,bh as Vn,bi as Qn,bj as Zr,B as ea,b4 as Yn,aJ as Xn,bk as Zn,T as ei,bl as gs,bm as ws,j as Er,a7 as bs,b8 as ti,bn as si,bo as ri,bp as ai,b6 as ni,b7 as ii,bq as oi,aE as li,u as di,al as Mr,ap as Ns,aC as ci}from"./vendor-icons-D_Dmmj8d.js";import{S as ui,L as xi}from"./SearchableDevicePicker-DubIldKj.js";import{C as ta}from"./ConfirmDialog-DtotgVmI.js";import{s as sa}from"./visibleInterval-BKsLfJZ3.js";import{t as mi,f as pi}from"./formatTestName-BKd2Uqhs.js";import{u as hi}from"./useTestExplorer-CUqC18DV.js";import{u as fi}from"./useFeatureFlags-DrhvBp0C.js";import{u as gi,e as bi,A as Ss,C as yi,S as ki,c as vi,s as ji}from"./AIStreamUI-p_sMTEDQ.js";import{a as Ps,u as _e,c as ra,e as aa}from"./vendor-query-DkZSMtfn.js";import{R as wi}from"./ReportCard-D4EElEe9.js";import{L as Ni,a as Si,A as Pr,P as Ci,b as $i,T as Ii,C as Ai,D as Ri}from"./ChangesSummary-Cu0_4Ucf.js";import{H as Ti,P as zr}from"./hiddenLlmProviders-DzwaR-b9.js";import{T as qi}from"./TestverCreditsRing-CEBSy3w3.js";import{F as na}from"./index-DLmlY2Ol.js";import{u as ia}from"./useChartTheme-CTIe6M63.js";import"./formatDate-T65-Y6Mi.js";import"./KpiTile-BHLE3HVj.js";import"./vendor-charts-By5uZ93z.js";import"./useTabParam-CyYAP90W.js";import"./MediaModal-DNM45Uz2.js";function Ei({texts:s,enabled:n}){const l=Ft(),{toast:x}=Hr(),o=Xa(),m=Za(),{check:j,byPath:k}=Dn(),[g,S]=i.useState(null);if(!n||!j||k.size===0)return null;const p=s.join(`
|
|
2
|
+
`);let N=null;for(const I of k.keys()){const R=I.split("/").pop()??I;if(p.includes(I)||R.length>3&&p.includes(R)){N=I;break}}if(!N)return null;const C=`${j.upstreamSha}:${N}`;if(g===C)return null;const v=k.get(N),c=en(j),y=j.dirtyFiles.includes(j.projectPrefix+N),h=j.verdict==="uncommitted_overlap"||j.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(Ln,{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:N})," changed on ",c,v.author?e.jsxs(e.Fragment,{children:[" ",tn(v.timestamp)," (",v.author,": “",v.message,"”)"]}):null,".",y?" You also have uncommitted edits in it.":""," Your copy is behind — pull first so the assistant doesn't work on old code?"]}),h||y?e.jsx("button",{onClick:()=>l("/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:()=>o.mutate(void 0,{onSuccess:I=>{var R;if(I.conflicts&&((R=I.conflictedPaths)!=null&&R.length)){l("/git");return}x("success",`Pulled from ${c}`)},onError:I=>x("error",`Pull failed: ${I.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:()=>l("/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:()=>S(C),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 de=[{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:Ts,colorClass:"text-indigo-500 dark:text-indigo-400"},{value:"api",label:"API",description:"Endpoints, schemas, collections, chains",Icon:qs,colorClass:"text-purple-500 dark:text-purple-400"},{value:"reporting",label:"Reporting",description:"Analytics, charts, summaries, exports",Icon:On,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:Gr,colorClass:"text-cyan-500 dark:text-cyan-400"}];function Mi({value:s,onChange:n,disabled:l,availableModes:x}){const[o,m]=i.useState(!1),[j,k]=i.useState(!1),g=i.useRef(null),S=i.useRef(null),p=x?de.filter(c=>x.includes(c.value)):de,N=de.find(c=>c.value===s)??p[0]??de[0],C=N.Icon;i.useEffect(()=>{if(!o)return;const c=h=>{var I,R;(I=S.current)!=null&&I.contains(h.target)||(R=g.current)!=null&&R.contains(h.target)||m(!1)},y=h=>{var I;h.key==="Escape"&&(m(!1),(I=g.current)==null||I.focus())};return document.addEventListener("mousedown",c),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",y)}},[o]);const v=()=>{if(!l){if(g.current){const c=g.current.getBoundingClientRect(),y=56*p.length+16,h=window.innerHeight-c.bottom;k(h<y+8)}m(c=>!c)}};return e.jsxs("div",{className:"relative inline-block",children:[e.jsxs("button",{ref:g,type:"button",onClick:v,disabled:l,title:`Mode: ${N.label}`,"aria-haspopup":"listbox","aria-expanded":o,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(C,{size:13,className:N.colorClass}),e.jsx("span",{children:N.label}),e.jsx(Se,{size:10,className:`flex-shrink-0 transition-transform ${o?"rotate-180":""}`})]}),o&&e.jsx("div",{ref:S,role:"listbox","aria-label":"Chat mode",className:`absolute z-50 ${j?"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:p.map(c=>{const y=c.Icon,h=c.value===s;return e.jsxs("button",{type:"button",role:"option","aria-selected":h,onClick:()=>{n(c.value),m(!1)},className:`w-full flex items-start gap-2 px-3 py-2 text-left text-xs transition-colors
|
|
4
|
+
${h?"bg-brand-500/10 text-brand-300":"text-gray-400 hover:bg-brand-500/10 hover:text-gray-200"}`,children:[e.jsx(y,{size:13,className:`${c.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:c.label}),h&&e.jsx(dt,{size:12,className:"text-brand-400"})]}),e.jsx("div",{className:"text-[10px] opacity-70 leading-snug",children:c.description})]})]},c.value)})})]})}function Pi({mode:s,className:n=""}){const l=de.find(o=>o.value===s)??de[0],x=l.Icon;return e.jsx("span",{className:`inline-flex items-center justify-center ${n}`,title:`${l.label} mode`,"aria-label":`${l.label} mode`,children:e.jsx(x,{size:13,className:l.colorClass})})}const ys=[{value:"manual",label:"Manual",description:"Ask before each action that changes something",Icon:_n,colorClass:"text-gray-400"},{value:"auto",label:"Auto",description:"Approve actions automatically for this chat — deleting files, sending email and logins still ask",Icon:Vr,colorClass:"text-amber-500 dark:text-amber-400"}];function zi({value:s,onChange:n,disabled:l}){const[x,o]=i.useState(!1),[m,j]=i.useState(!1),k=i.useRef(null),g=i.useRef(null),S=ys.find(C=>C.value===s)??ys[0],p=S.Icon;i.useEffect(()=>{if(!x)return;const C=v=>{var c,y;(c=g.current)!=null&&c.contains(v.target)||(y=k.current)!=null&&y.contains(v.target)||o(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[x]);const N=()=>{if(!l){if(k.current){const C=k.current.getBoundingClientRect();j(window.innerHeight-C.bottom<140)}o(C=>!C)}};return e.jsxs("div",{className:"relative inline-block",children:[e.jsxs("button",{ref:k,type:"button",onClick:N,disabled:l,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: ${S.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(p,{size:13,className:S.colorClass}),e.jsx("span",{children:S.label}),e.jsx(Se,{size:10,className:`flex-shrink-0 transition-transform ${x?"rotate-180":""}`})]}),x&&e.jsx("div",{ref:g,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:ys.map(C=>{const v=C.Icon,c=C.value===s;return e.jsxs("button",{type:"button",role:"option","aria-selected":c,onClick:()=>{n(C.value),o(!1)},className:`w-full flex items-start gap-2 px-3 py-2 text-left text-xs transition-colors
|
|
7
|
+
${c?"bg-brand-500/10 text-brand-300":"text-gray-400 hover:bg-brand-500/10 hover:text-gray-200"}`,children:[e.jsx(v,{size:13,className:`${C.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:C.label}),c&&e.jsx(dt,{size:12,className:"text-brand-400"})]}),e.jsx("div",{className:"text-[10px] opacity-70 leading-snug",children:C.description})]})]},C.value)})})]})}const zs=[".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"],Ds="PDF, Word (.docx), Excel, CSV, text and config files, and code or test files",Di=[".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"],Li={".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 Oi(s,n=zs){const l=s.toLowerCase();return n.some(x=>l.endsWith(x))}function _i(s,n=Ds){const l=s.toLowerCase(),x=l.lastIndexOf("."),o=x>=0?l.slice(x):"",m=o&&Li[o];return m?`${s}: ${m}.`:`${s}: ${o?`${o} files are`:"files without an extension are"} not supported. Supported: ${n}.`}function Fi(s,n,l){const x=(n==null?void 0:n.extensions)??[...zs,...l??[]],o=(n==null?void 0:n.summary)??Ds,m=(n==null?void 0:n.maxBytes)??20*1024*1024,j=[],k=[];for(const g of s)Oi(g.name,x)?g.size>m?k.push(`${g.name}: larger than ${Math.round(m/1024/1024)} MB.`):j.push(g):k.push(_i(g.name,o));return{accepted:j,rejected:k}}function Bi({onSessionChange:s}){const{toast:n}=Hr(),[l,x]=i.useState([]),[o,m]=i.useState("browserstack"),[j,k]=i.useState([]),[g,S]=i.useState([]),[p,N]=i.useState(""),[C,v]=i.useState(""),[c,y]=i.useState(null),[h,I]=i.useState(!1),[R,D]=i.useState(null),[F,w]=i.useState(null),[O,G]=i.useState(!1),[ne,ie]=i.useState(null),[Y,b]=i.useState(!1),M=i.useRef(null),[E,re]=i.useState(null),X=i.useRef(null);X.current=c;const W=i.useRef(!1);W.current=h;const P=i.useRef(s);P.current=s;const Z=i.useCallback(f=>{var q,_;((f==null?void 0:f.sessionId)??null)!==(((q=X.current)==null?void 0:q.sessionId)??null)&&(X.current=f,y(f),w(null),(_=P.current)==null||_.call(P,f))},[]);i.useEffect(()=>{let f=!1;const _=sa(async()=>{try{const U=await $r();if(f||W.current||(re(U.session?U.context??null:null),!U.session&&U.starting))return;Z(U.session??null)}catch{}},5e3);return()=>{f=!0,_()}},[Z]);const ee=Ur();i.useEffect(()=>{if(ee!=null&&ee.subscribe)return ee.subscribe(f=>{if(!W.current){if(f.type==="mobile-session-started"){const q=f.session;q&&!q.external&&Z(q)}else if(f.type==="mobile-session-closed"){Z(null);const q=f.reason;q&&n("info",q)}}})},[ee,Z,n]),i.useEffect(()=>{(async()=>{try{const[f,q,_]=await Promise.all([sn(),Cr(),$r().catch(()=>({session:null}))]);x(f.providers),S(q.apps),_.session&&(y(_.session),s==null||s(_.session));const U=f.providers.find(z=>z.hasCredentials&&z.enabled);U&&m(U.id)}catch(f){D(f.message)}})()},[]);const ce=i.useCallback(async f=>{G(!0),D(null);try{const _=[...(await rn(f)).devices].sort((z,ue)=>z.realMobile!==ue.realMobile?z.realMobile?-1:1:z.name.localeCompare(ue.name));k(_);const U=_.filter(z=>!z.unavailableReason);if(!p||!_.some(z=>z.id===p)){const z=U.find(ue=>ue.realMobile&&/iphone 15/i.test(ue.name))||U.find(ue=>ue.realMobile&&/pixel/i.test(ue.name))||U[0];N((z==null?void 0:z.id)??"")}}catch(q){D(q.message),k([])}finally{G(!1)}},[p]);i.useEffect(()=>{const f=l.find(q=>q.id===o);f!=null&&f.hasCredentials?ce(o):k([])},[o,l,ce]);const te=async f=>{I(!0),D(null),ie(0);const q=(f.size/1024/1024).toFixed(1);w(`Uploading ${f.name} (${q} MB)…`);try{const _=await nn(f,void 0,z=>ie(z)),U=await Cr();S(U.apps),v(_.id),w(`Added ${f.name}.`)}catch(_){D(_.message),w(null),console.error("[MobileDeviceBar] upload failed:",_)}finally{I(!1),ie(null)}},J=async()=>{D(null);const f=j.find(q=>q.id===p);if(!f){D("Pick a device first.");return}if(!C){D("Pick or upload an app first.");return}I(!0),w(o==="local-appium"?"Starting local device session — this may take a moment.":"Starting cloud session — this can take 30–60 s on first launch.");try{c&&(await Ir().catch(()=>{}),y(null),s==null||s(null));const q=await an({provider:o,deviceKey:f.rawDeviceKey,osVersion:f.os,platform:f.platform,appId:C,sessionName:"Testver AI Assistant"});y(q.session),s==null||s(q.session),w(`Session started on ${f.name} (${f.os}).`)}catch(q){D(q.message),w(null)}finally{I(!1)}},ge=async()=>{I(!0);try{await Ir(),y(null),s==null||s(null),w("Session ended.")}catch(f){D(f.message)}finally{I(!1)}},oe=l.find(f=>f.id===o),T=!(oe!=null&&oe.hasCredentials);j.find(f=>f.id===p);const K=g.find(f=>f.id===C);i.useMemo(()=>{const f={};for(const q of j){const _=q.manufacturer||(q.platform==="ios"?"Apple":"Other");f[_]||(f[_]=[]),f[_].push(q)}return f},[j]);const V=!!c||h;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(Ts,{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"}),!c&&e.jsxs(e.Fragment,{children:[e.jsx(Dr,{label:(oe==null?void 0:oe.displayName)||o,disabled:V,widthClass:"w-40",children:l.map(f=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>m(f.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 ${f.id===o?"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:f.displayName}),e.jsx("span",{className:`text-[10px] ${f.hasCredentials?"text-emerald-600 dark:text-emerald-400":"text-gray-400 dark:text-gray-500"}`,children:f.hasCredentials?"ready":"no creds"})]})},f.id))}),e.jsx("div",{className:"w-48 min-w-0 flex-shrink-0",children:e.jsx(ui,{devices:j,selectedId:p,onSelect:f=>N(f.id),loading:O,disabled:V||T,onRefresh:()=>void ce(o),placeholder:T?"(add creds in Connectors)":"Pick device",emptyText:o==="local-appium"?xi:void 0,variant:"compact"})}),e.jsxs(Dr,{label:K?K.label||K.filename:"Pick app",disabled:V,widthClass:"w-48",children:[e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[g.length===0&&e.jsx("li",{className:"px-3 py-2 text-xs text-gray-500",children:"No apps yet — upload an .apk or .ipa."}),g.map(f=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>v(f.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 ${f.id===C?"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:f.label||f.filename}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:[f.kind," · ",(f.size/1024/1024).toFixed(1)," MB"]})]})},f.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:f=>{var q;f.stopPropagation(),(q=M.current)==null||q.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(js,{size:11})," ",e.jsx("span",{title:"Android: .apk or .aab · real iPhone / iPad: .ipa · iOS simulator: the .app zipped",children:"Upload app build"})]})})]})]}),c&&F&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-emerald-600 dark:text-emerald-400",children:[e.jsx(Qe,{size:11}),F]}),e.jsx("div",{className:"flex-1"}),c?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 · ",c.device]}),E&&E!=="NATIVE_APP"&&e.jsx("span",{title:`Automation context: ${E} — 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:E}),c.liveViewUrl&&e.jsxs("a",{href:c.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(Es,{size:10})]}),e.jsx("button",{type:"button",disabled:h,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:h?"Ending…":"End session"}),e.jsx(ta,{open:Y,title:"End mobile session?",description:`This disconnects "${c.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. `+(c.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),ge()},onCancel:()=>b(!1)})]}):e.jsx("button",{type:"button",disabled:h||T||!p||!C,onClick:J,title:p?C?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:h?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Bt,{size:11,className:"animate-spin"})," Starting…"]}):"Start session"})]}),(R||F&&!c)&&e.jsxs("div",{className:`px-3 pb-2 text-[11px] flex items-center gap-1.5 ${R?"text-red-600 dark:text-red-300":"text-gray-600 dark:text-gray-400"}`,children:[R?e.jsx(Ut,{size:11}):e.jsx(Qe,{size:11}),e.jsxs("span",{children:[R||F,ne!==null&&e.jsxs("span",{className:"ml-2 text-indigo-600 dark:text-indigo-300",children:[Math.round(ne*100),"%"]})]})]}),ne!==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(ne*100)}%`}})}),e.jsx("input",{ref:M,type:"file",accept:".apk,.aab,.ipa,.zip,application/vnd.android.package-archive,application/zip,application/octet-stream",hidden:!0,onChange:f=>{var _;const q=(_=f.target.files)==null?void 0:_[0];q&&te(q),f.target.value=""}})]})}function Dr({label:s,children:n,disabled:l,wide:x,widthClass:o}){const[m,j]=i.useState(!1),[k,g]=i.useState(!1),S=i.useRef(null),p=i.useRef(null);i.useEffect(()=>{if(!m)return;const C=v=>{var c;(c=S.current)!=null&&c.contains(v.target)||j(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[m]);const N=()=>{if(!l){if(!m&&p.current){const C=p.current.getBoundingClientRect(),v=320,c=window.innerHeight-C.bottom,y=C.top;g(c<v+16&&y>c)}j(C=>!C)}};return e.jsxs("div",{className:`relative ${o?`${o} min-w-0 flex-shrink-0`:""}`,ref:S,children:[e.jsxs("button",{ref:p,type:"button",disabled:l,onClick:N,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
|
+
${o?"w-full min-w-0 justify-between":""}
|
|
11
|
+
${l?"opacity-50 cursor-not-allowed":""}`,title:s,children:[e.jsx("span",{className:`truncate min-w-0 ${o?"flex-1":"max-w-[220px]"}`,children:s}),e.jsx(Se,{size:11,className:`text-gray-500 transition-transform flex-shrink-0 ${m?"rotate-180":""}`})]}),m&&e.jsx("div",{onClick:()=>j(!1),className:`absolute z-50 left-0 ${x?"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 ${k?"bottom-full mb-1":"top-full mt-1"}`,children:e.jsx("ul",{children:n})})]})}function Ui(){const[s,n]=i.useState(null),[l,x]=i.useState(),o=Ft();if(i.useEffect(()=>{const j=async()=>{var k;try{const g=on(),S=await fetch("/api/local-browser/status",{headers:g?{Authorization:`Bearer ${g}`}:{}});if(!S.ok){n(!1);return}const p=await S.json();n(!!p.connected),x((k=p==null?void 0:p.client)==null?void 0:k.machine)}catch{n(!1)}};return j(),sa(j,5e3)},[]),s===null)return null;const m=()=>o("/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:l?`Browser actions run on ${l}`:"Browser actions run on your machine",children:[e.jsx(Fn,{className:"w-3 h-3"}),"Local",l?` (${l.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(Bn,{className:"w-3 h-3"}),"Server"]})}function ks(s){if(!s)return"";const n=Math.floor((Date.now()-s)/864e5);if(n<=0)return"today";if(n===1)return"yesterday";if(n<30)return`${n} days ago`;const l=Math.floor(n/30);return l===1?"a month ago":`${l} months ago`}function nt({dot:s,label:n,count:l,detail:x,empty:o}){return e.jsxs("div",{className:`rounded-xl border px-3 py-2.5 ${o?"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 ${o?"bg-gray-400/40":s}`}),e.jsx("span",{className:`text-[12.5px] font-semibold ${o?"text-gray-400 dark:text-gray-600":"text-gray-800 dark:text-gray-200"}`,children:n}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:`text-[11px] ${o?"text-gray-400 dark:text-gray-600":"text-gray-500 dark:text-gray-400"}`,children:l})]}),x&&e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-gray-500 dark:text-gray-500",children:x})]})}function Hi(){const s=Ps(),{data:n}=_e({queryKey:["ask-feedback-summary"],queryFn:()=>Wr(),staleTime:3e4}),l=ra({mutationFn:m=>dn(m),onSuccess:()=>s.invalidateQueries({queryKey:["ask-feedback-summary"]})});if(!n||n.misses.length===0&&n.unhelpful.length===0)return null;const x=n.misses.slice(0,5),o=n.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"}),x.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:x.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:()=>l.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))})]}),o.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",n.down>o.length?` (${n.down})`:""]}),e.jsx("ul",{className:"mt-1 flex flex-col gap-1.5",children:o.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(fe,{to:"/sources",className:"text-cyan-700 dark:text-cyan-300 underline underline-offset-2",children:"document"})," that covers them, fills the gap."]})]})}function Wi(){var j,k,g;const[s,n]=i.useState(null),[l,x]=i.useState(!1);if(i.useEffect(()=>{let S=!0;return ln().then(p=>{S&&n(p)}).catch(()=>{S&&x(!0)}),()=>{S=!1}},[]),l)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 o=s?s.observed.pages+s.observed.notes+s.observed.findings:0,m=!!s&&s.tiersWithContent===0&&!((j=s.automation)!=null&&j.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+((k=s.automation)!=null&&k.tests?1:0)} of ${(s.reported?4:3)+(s.automation?1:0)} kinds of record${s.observed.latestAt?` · newest ${ks(s.observed.latestAt)}`:""}`:"Reading…"})]}),s&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(nt,{dot:"bg-emerald-400",label:"Exploration",count:o?s.observed.pages?`${s.observed.pages} page${s.observed.pages===1?"":"s"}`:`${o} record${o===1?"":"s"}`:"none",empty:!o,detail:s.observed.latestRunId?`${s.observed.runs>1?`${s.observed.runs} runs · latest `:"run "}${s.observed.latestRunId} · ${ks(s.observed.latestAt)}${(g=s.observed.roles)!=null&&g.length?` · ${s.observed.roles.join(", ")}`:""}`:"No run has walked this app"}),s.reported&&e.jsx(nt,{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(nt,{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(nt,{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 ${ks(s.automation.latestAt)}`:""}`:"No test files in this repository"}),e.jsx(nt,{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(Hi,{}),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(fe,{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."})})]})}const Ki=s=>{try{const n=JSON.parse(s);if(!n||typeof n!="object"||Array.isArray(n))return{};const l={};for(const[x,o]of Object.entries(n))typeof o=="string"&&o&&(l[x]=o);return l}catch{return{}}},Ji=s=>{var n;if(!(!s||!/^Imported\b/.test(s.trim())))return(n=/"([^"]+)"/.exec(s))==null?void 0:n[1]};function Ls(s,n,l){var m,j;if(!s.startsWith("api_")||l&&/^Error\b/.test(l.trim()))return null;const x=Ki(n),o=x.collection;switch(s){case"api_create_collection":return x.name?{kind:"saved",collection:x.name,action:"Created collection"}:null;case"api_import_spec":{const k=Ji(l)??x.collection_name;return k?{kind:"saved",collection:k,action:"Imported into"}:null}case"api_save_request":return o?{kind:"saved",collection:o,folder:x.folder,request:x.name,method:(m=x.method)==null?void 0:m.toUpperCase(),action:"Saved request"}:null;case"api_create_folder":return o?{kind:"saved",collection:o,folder:x.name,action:"Created folder"}:null;case"api_set_environment":return o?{kind:"saved",collection:o,environment:x.environment_name,action:"Saved environment"}:null;case"api_add_validation":return o?{kind:"saved",collection:o,request:x.request,action:"Added validations to"}:null;case"api_set_request_options":return o?{kind:"saved",collection:o,request:x.request,action:"Updated request options of"}:null;case"api_set_collection_settings":return o?{kind:"saved",collection:o,action:"Updated settings of"}:null;case"api_list_collections":return{kind:"read",action:"Listed collections"};case"api_get_collection":return o?{kind:"read",collection:o,action:"Read"}:null;case"api_get_environments":return o?{kind:"read",collection:o,action:"Read environments of"}:null;case"api_get_history":return o?{kind:"read",collection:o,action:"Read call history of"}:{kind:"read",action:"Read call history"};case"api_get_request":return o?{kind:"read",collection:o,request:x.request,action:"Read"}:null;case"api_send_collection_request":return o?{kind:"read",collection:o,request:x.request,environment:x.environment,action:"Sent"}:null;case"api_run_chain":return o?{kind:"read",collection:o,folder:x.folder,environment:x.environment,action:"Ran chain"}:null;case"api_run_data_driven":return o?{kind:"read",collection:o,folder:x.folder,request:x.request,environment:x.environment,action:"Ran data-driven"}:null;case"api_request":return{kind:"oneoff",method:(j=x.method)==null?void 0:j.toUpperCase(),url:x.url,action:"One-off request"};default:return null}}function Gi(s){const n=[];return s.collection&&n.push(s.collection),s.folder&&n.push(s.folder),s.request&&n.push(s.method?`${s.method} ${s.request}`:s.request),s.environment&&!s.request&&!s.folder&&n.push(`environment ${s.environment}`),n}function Wt(s){const n=new URLSearchParams;s.collection&&n.set("collection",s.collection),s.folder&&n.set("folder",s.folder),s.request&&n.set("request",s.request);const l=n.toString();return`/api-testing${l?`?${l}`:""}`}const vs=(s,n)=>!!s&&!!n&&s.toLowerCase()===n.toLowerCase(),Vi=/^(\{\{[^}]+\}\}|\{[^}]+\}|:[A-Za-z_]\w*)$/,Ot=s=>s.split(/[?#]/)[0].split("/").filter(Boolean).map(n=>n.toLowerCase()),Cs=s=>{try{const n=new URL(s);return{host:n.host.toLowerCase(),path:Ot(n.pathname)}}catch{return s.startsWith("/")?{path:Ot(s)}:null}},Qi=(s,n)=>{const l=/^\{\{\s*([\w.-]+)\s*\}\}/.exec(s);if(l){const o=Ot(s.slice(l[0].length)),m=[{path:o}];for(const j of n.get(l[1])??[]){const k=Cs(j);k&&m.push({host:k.host,path:[...k.path,...o]})}return m}const x=Cs(s);return x?[x]:[{path:Ot(s.replace(/^[a-z]+:\/\/[^/]+/i,""))}]};function oa(s,n,l){if(!s||!n)return null;const x=Cs(n);if(!x)return null;let o=null;for(const m of l){const j=new Map,k=(S,p)=>{p&&j.set(S,[...j.get(S)??[],p])};k("baseUrl",m.baseUrl);for(const S of m.environments??[])for(const p of S.variables)p.enabled!==!1&&k(p.key,p.value);const g=[...m.requests.map(S=>({r:S,folder:void 0})),...m.folders.flatMap(S=>S.requests.map(p=>({r:p,folder:S.name})))];for(const{r:S,folder:p}of g)if(S.method.toUpperCase()===s.toUpperCase())for(const N of Qi(S.url,j)){if(N.path.length!==x.path.length)continue;let C=0,v=!0;N.path.forEach((h,I)=>{h===x.path[I]?C++:Vi.test(h)||(v=!1)});const c=!!N.host&&!!x.host&&N.host===x.host;if(!v||x.path.length>0&&C===0||x.path.length===0&&!c)continue;const y=C*2+(c?1:0);(!o||y>o.score)&&(o={m:{collection:m.name,folder:p,request:S.name,method:S.method.toUpperCase()},score:y})}}return(o==null?void 0:o.m)??null}function it(s,n){return s.some(l=>l.kind!=="saved"||!(vs(l.collection,n.collectionName)||l.collection===n.collectionId)?!1:n.requestId||n.requestName?!!l.request&&(vs(l.request,n.requestName)||l.request===n.requestId):n.folderName?vs(l.folder,n.folderName):!0)}const Yi={GET:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",POST:"bg-orange-500/10 text-orange-700 dark:text-orange-300",PUT:"bg-sky-500/10 text-sky-700 dark:text-sky-300",PATCH:"bg-violet-500/10 text-violet-700 dark:text-violet-300",DELETE:"bg-red-500/10 text-red-700 dark:text-red-300"};function la({method:s}){return e.jsx("span",{className:`inline-block min-w-[40px] text-center rounded px-1 py-px font-mono text-[10px] font-bold flex-shrink-0 ${Yi[s]??"bg-gray-500/10 text-gray-600 dark:text-gray-300"}`,children:s})}const da=s=>{const n=Math.max(0,(Date.now()-Date.parse(s))/1e3);return n<60?"just now":n<3600?`${Math.floor(n/60)} min`:n<86400?`${Math.floor(n/3600)} h`:`${Math.floor(n/86400)} d`},ca=s=>s>=200&&s<300?"text-emerald-600 dark:text-emerald-400":s>=400||s===0?"text-red-600 dark:text-red-400":"text-amber-600 dark:text-amber-400",Xi=s=>{try{return localStorage.getItem(`testver-active-env-${s}`)}catch{return null}};function Zi({info:s}){const n=(s==null?void 0:s.file)??".testver/api-collections.json";let l;switch(s==null?void 0:s.git){case"tracked":l=s.uncommitted?e.jsxs(e.Fragment,{children:["In Git — this file has changes not committed yet. ",e.jsx(fe,{to:"/git",className:"text-sky-700 dark:text-sky-300 hover:underline",children:"Commit them"})," to share (turn on “Include .testver changes”)."]}):e.jsx(e.Fragment,{children:"In Git — your team gets it when they pull."});break;case"untracked":l=e.jsxs(e.Fragment,{children:["Only on this computer — not in Git yet. To share it, ",e.jsx(fe,{to:"/git",className:"text-sky-700 dark:text-sky-300 hover:underline",children:"commit it"})," with “Include .testver changes” on."]});break;case"ignored":l=e.jsxs(e.Fragment,{children:["Only on this computer — your ",e.jsx("span",{className:"font-mono",children:".gitignore"})," leaves it out of Git."]});break;case"no-repo":l=e.jsx(e.Fragment,{children:"On this computer, in the project folder."});break;default:l=e.jsx(e.Fragment,{children:"In the project folder."})}return e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.03] px-3 py-2.5 flex flex-col gap-1","data-testid":"api-storage",children:[e.jsxs("span",{className:"text-[12px] font-semibold text-gray-700 dark:text-gray-300 flex items-center gap-1.5",children:[e.jsx(Wn,{size:12,"aria-hidden":!0})," Stored in your project"]}),e.jsx("span",{className:"font-mono text-[12px] text-gray-900 dark:text-gray-100 break-all",children:n}),e.jsx("span",{className:"text-[12px] leading-snug text-gray-600 dark:text-gray-400",children:l})]})}function Lr({req:s,collection:n,folderName:l,changed:x,last:o}){return e.jsxs(fe,{to:Wt({collection:n.id,folder:l,request:s.id}),title:`${s.method} ${s.url}`,className:`flex items-center gap-2 rounded-md pl-8 pr-2 py-1 text-[13px] text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/[0.04] ${x?"bg-sky-500/[0.07]":""}`,children:[e.jsx(la,{method:s.method}),e.jsx("span",{className:"truncate min-w-0",children:s.name}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 flex-shrink-0",children:[x&&e.jsx("span",{className:"rounded-full bg-sky-500/15 px-1.5 py-px text-[10px] font-semibold text-sky-700 dark:text-sky-300",children:"changed"}),o&&e.jsx("span",{className:`font-mono text-[11px] font-semibold ${ca(o.response.status)}`,title:`Last call ${da(o.timestamp)} ago`,children:o.response.status})]})]})}function eo({touched:s,refreshKey:n,onClose:l}){var Y;const x=Ft(),o=Ps(),[m,j]=i.useState("collections"),[k,g]=i.useState(""),[S,p]=i.useState({}),{data:N}=_e({queryKey:["api-collections"],queryFn:Kr,staleTime:5e3}),C=i.useMemo(()=>((N==null?void 0:N.collections)??[]).map(b=>b.id),[N]),c=aa({queries:C.map(b=>({queryKey:["api-collection",b],queryFn:()=>Jr(b),staleTime:5e3}))}).map(b=>b.data).filter(b=>!!b),{data:y}=_e({queryKey:["api-history",50],queryFn:()=>cn(50),staleTime:5e3}),{data:h}=_e({queryKey:["api-storage"],queryFn:un,staleTime:15e3});i.useEffect(()=>{n!==0&&(o.invalidateQueries({queryKey:["api-collections"]}),o.invalidateQueries({queryKey:["api-collection"]}),o.invalidateQueries({queryKey:["api-history"]}),o.invalidateQueries({queryKey:["api-storage"]}))},[n,o]);const I=i.useMemo(()=>{var M;const b=new Map;for(const E of(y==null?void 0:y.history)??[])(M=E.request)!=null&&M.id&&!b.has(E.request.id)&&b.set(E.request.id,E);return b},[y]),R=c.reduce((b,M)=>b+M.requests.length+M.folders.reduce((E,re)=>E+re.requests.length,0),0),D=c.reduce((b,M)=>b+M.environments.length,0),F=(y==null?void 0:y.count)??((Y=y==null?void 0:y.history)==null?void 0:Y.length)??0,w=k.trim().toLowerCase(),O=b=>!w||b.name.toLowerCase().includes(w)||b.url.toLowerCase().includes(w)||b.method.toLowerCase()===w,G=(b,M)=>S[b]??M,ne=(b,M)=>p(E=>({...E,[b]:!(E[b]??M)})),ie=[{id:"collections",label:"Collections",count:R,Icon:qr},{id:"environments",label:"Environments",count:D,Icon:Un},{id:"history",label:"History",count:F,Icon:Qr}];return e.jsxs("aside",{"aria-label":"API Collections","data-testid":"api-collections-panel",className:"w-[340px] flex-shrink-0 border-l border-black/[0.06] dark:border-white/[0.07] flex flex-col min-h-0 bg-white/40 dark:bg-transparent",children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex flex-col gap-3 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{size:16,className:"text-gray-700 dark:text-gray-300","aria-hidden":!0}),e.jsx("h2",{className:"text-[15px] font-semibold text-gray-900 dark:text-gray-100",children:"API Collections"}),e.jsx("button",{onClick:l,"aria-label":"Hide API Collections",title:"Hide",className:"ml-auto p-1.5 rounded-md text-gray-500 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-white/5",children:e.jsx(Ie,{size:15})})]}),e.jsx(Zi,{info:h}),e.jsx("div",{role:"tablist","aria-label":"API Collections",className:"flex gap-3 border-b border-gray-200 dark:border-white/10","data-testid":"api-panel-tabs",children:ie.map(b=>{const M=m===b.id;return e.jsxs("button",{role:"tab","aria-selected":M,onClick:()=>j(b.id),className:`flex h-9 flex-shrink-0 items-center gap-1.5 whitespace-nowrap border-b-2 px-0.5 text-[13px] transition-colors ${M?"border-gray-900 dark:border-gray-100 font-semibold text-gray-900 dark:text-gray-100":"border-transparent font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[b.label,e.jsx("span",{className:`min-w-[20px] rounded-full px-1.5 py-px text-center text-[11px] font-semibold tabular-nums ${M?"bg-brand-600 text-white dark:bg-white dark:text-gray-900":"bg-gray-200 text-gray-700 dark:bg-white/10 dark:text-gray-300"}`,children:b.count})]},b.id)})})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-3 pb-3",children:[m==="collections"&&e.jsxs("div",{className:"flex flex-col gap-2",role:"tabpanel","aria-label":"Collections",children:[c.length>0&&e.jsxs("label",{className:"relative block",children:[e.jsx("span",{className:"sr-only",children:"Filter requests"}),e.jsx(Ms,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400","aria-hidden":!0}),e.jsx("input",{value:k,onChange:b=>g(b.target.value),placeholder:`Filter ${R} request${R===1?"":"s"}…`,className:"w-full rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] pl-8 pr-3 py-1.5 text-[13px] text-gray-900 dark:text-gray-100 outline-none focus:border-gray-400 dark:focus:border-white/30"})]}),N&&c.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 dark:border-white/10 px-3 py-6 text-center text-[13px] text-gray-500 dark:text-gray-400",children:"No collections yet. Ask the AI to import a spec (OpenAPI, Postman or HAR) or to save a request — it lands here."}),e.jsx("div",{className:"flex flex-col",children:c.map(b=>{const M=it(s,{collectionId:b.id,collectionName:b.name}),E=b.id,re=G(E,M||c.length===1||!!w),X=b.requests.length+b.folders.reduce((P,Z)=>P+Z.requests.length,0),W=b.requests.filter(O);return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("button",{onClick:()=>ne(E,M||c.length===1||!!w),"aria-expanded":re,className:"flex items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-[13px] font-semibold text-gray-900 dark:text-gray-100 hover:bg-gray-100 dark:hover:bg-white/[0.04]",children:[re?e.jsx(Se,{size:14,"aria-hidden":!0}):e.jsx(Lt,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"truncate",children:b.name}),M&&e.jsx("span",{className:"rounded-full bg-sky-500/15 px-1.5 py-px text-[10px] font-semibold text-sky-700 dark:text-sky-300",children:"updated"}),e.jsx("span",{className:"ml-auto text-[12px] font-medium text-gray-500 dark:text-gray-400 tabular-nums",children:X})]}),re&&e.jsxs("div",{className:"flex flex-col",children:[b.folders.map(P=>{const Z=P.requests.filter(O);if(w&&Z.length===0)return null;const ee=`${b.id}/${P.id}`,ce=it(s,{collectionId:b.id,collectionName:b.name,folderName:P.name})||P.requests.some(J=>it(s,{collectionId:b.id,collectionName:b.name,requestId:J.id,requestName:J.name})),te=G(ee,ce||!!w);return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("button",{onClick:()=>ne(ee,ce||!!w),"aria-expanded":te,className:"flex items-center gap-1.5 rounded-md pl-5 pr-2 py-1 text-left text-[13px] text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/[0.04]",children:[te?e.jsx(Se,{size:13,"aria-hidden":!0}):e.jsx(Lt,{size:13,"aria-hidden":!0}),e.jsx(Hn,{size:13,className:"text-gray-400","aria-hidden":!0}),e.jsx("span",{className:`truncate ${te?"font-medium":""}`,children:P.name}),e.jsx("span",{className:"ml-auto text-[12px] text-gray-500 dark:text-gray-400 tabular-nums",children:P.requests.length})]}),te&&Z.map(J=>e.jsx(Lr,{req:J,collection:b,folderName:P.name,last:I.get(J.id),changed:it(s,{collectionId:b.id,collectionName:b.name,requestId:J.id,requestName:J.name})},J.id))]},P.id)}),W.map(P=>e.jsx(Lr,{req:P,collection:b,last:I.get(P.id),changed:it(s,{collectionId:b.id,collectionName:b.name,requestId:P.id,requestName:P.name})},P.id)),X===0&&e.jsx("div",{className:"pl-8 py-1 text-[12px] text-gray-500 dark:text-gray-400",children:"No requests yet"})]})]},b.id)})})]}),m==="environments"&&e.jsxs("div",{className:"flex flex-col gap-3",role:"tabpanel","aria-label":"Environments",children:[D===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 dark:border-white/10 px-3 py-6 text-center text-[13px] text-gray-500 dark:text-gray-400",children:"No environments yet. Ask the AI to add one (for example “add a Staging environment with baseUrl …”)."}),c.filter(b=>b.environments.length>0).map(b=>{const M=Xi(b.id);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"px-1 text-[11px] font-semibold uppercase tracking-[0.06em] text-gray-500 dark:text-gray-400",children:b.name}),b.environments.map(E=>{const re=E.variables.find(W=>W.enabled&&/^base_?url$/i.test(W.key)&&!W.secret),X=M?M===E.id:!1;return e.jsxs("div",{className:`rounded-lg border px-3 py-2 flex flex-col gap-1 ${X?"border-gray-400 dark:border-white/30":"border-gray-200 dark:border-white/10"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${X?"bg-emerald-500":"bg-gray-300 dark:bg-white/20"}`,"aria-hidden":!0}),e.jsx("strong",{className:"text-gray-900 dark:text-gray-100",children:E.name}),X&&e.jsx("span",{className:"text-[11px] font-semibold text-emerald-700 dark:text-emerald-300",children:"active in the workspace"}),e.jsxs("span",{className:"ml-auto text-[12px] text-gray-500 dark:text-gray-400",children:[E.variables.length," variable",E.variables.length===1?"":"s"]})]}),re&&e.jsxs("span",{className:"font-mono text-[12px] text-gray-600 dark:text-gray-400 truncate",title:re.value,children:[re.key," = ",re.value]}),E.variables.some(W=>W.secret)&&e.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:(()=>{const W=E.variables.filter(P=>P.secret).length;return`${W} secret value${W===1?"":"s"} hidden`})()})]},E.id)})]},b.id)}),c.some(b=>b.baseUrl)&&e.jsxs("p",{className:"px-1 text-[12px] text-gray-500 dark:text-gray-400 leading-snug",children:["Requests use a collection’s base URL unless an environment sets ",e.jsx("span",{className:"font-mono",children:"baseUrl"}),"."]})]}),m==="history"&&e.jsxs("div",{className:"flex flex-col",role:"tabpanel","aria-label":"History",children:[((y==null?void 0:y.history)??[]).length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 dark:border-white/10 px-3 py-6 text-center text-[13px] text-gray-500 dark:text-gray-400",children:"No calls yet. Requests sent from a collection — by the AI or in the workspace — are listed here."}),((y==null?void 0:y.history)??[]).slice(0,30).map(b=>{const M=c.find(E=>E.id===b.collectionId);return e.jsxs(fe,{to:M?Wt({collection:M.id,request:b.request.id}):"/api-testing",className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/[0.04]",title:b.request.url,children:[e.jsx(la,{method:b.request.method}),e.jsx("span",{className:"truncate min-w-0",children:b.request.name||b.request.url}),e.jsx("span",{className:`ml-auto font-mono text-[11px] font-semibold flex-shrink-0 ${ca(b.response.status)}`,children:b.response.status||"ERR"}),e.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400 tabular-nums flex-shrink-0 w-[52px] text-right",children:da(b.timestamp)})]},b.id)})]})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-black/[0.06] dark:border-white/[0.07] flex gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>x("/api-testing"),className:"flex-1 inline-flex items-center justify-center rounded-lg bg-brand-600 hover:bg-brand-700 text-white text-[13px] font-medium h-9","data-testid":"api-open-workspace",children:"Open workspace"}),e.jsx("button",{onClick:()=>x("/api-testing?import=1"),className:"inline-flex items-center justify-center rounded-lg border border-gray-200 dark:border-white/10 px-3 h-9 text-[13px] font-medium text-gray-800 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-white/5",children:"Import"}),e.jsx("button",{onClick:()=>{xn()},disabled:c.length===0,className:"inline-flex items-center justify-center rounded-lg border border-gray-200 dark:border-white/10 px-3 h-9 text-[13px] font-medium text-gray-800 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-white/5 disabled:opacity-40",children:"Export"})]})]})}const ua={saved:{text:"Saved to",cls:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"},read:{text:"From",cls:"bg-sky-500/10 text-sky-700 dark:text-sky-300"},match:{text:"Saved in",cls:"bg-sky-500/10 text-sky-700 dark:text-sky-300"},oneoff:{text:"Not saved",cls:"bg-gray-500/10 text-gray-600 dark:text-gray-300"}};function xa(s){const{data:n}=_e({queryKey:["api-collections"],queryFn:Kr,staleTime:5e3,enabled:s}),l=s?((n==null?void 0:n.collections)??[]).map(o=>o.id):[];return aa({queries:l.map(o=>({queryKey:["api-collection",o],queryFn:()=>Jr(o),staleTime:5e3}))}).map(o=>o.data).filter(o=>!!o)}function to(s,n,l){const x=Ls(s,n,l),o=xa((x==null?void 0:x.kind)==="oneoff");if(!x)return null;if(x.kind!=="oneoff")return{loc:x,tag:x.kind};const m=oa(x.method,x.url,o);return m?{loc:{...x,kind:"read",...m},tag:"match"}:{loc:x,tag:"oneoff"}}function $s({toolName:s,args:n,result:l,variant:x="bar"}){const o=to(s,n,l);if(!o)return null;const{loc:m}=o,j=ua[o.tag],k=Gi(m),g=o.tag==="oneoff",S=o.tag==="match",p=g?"a one-off request — ask the AI to save it to a collection to keep it":k.length?k.join(" › "):"API Collections",N=g?null:Wt(m),C="sent straight to its URL, not from the collection";return x==="chip"?e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0 text-[12px] text-gray-500 dark:text-gray-400","data-testid":"api-where",children:[e.jsx("span",{className:`rounded-full px-1.5 py-px text-[10.5px] font-semibold flex-shrink-0 ${j.cls}`,children:j.text}),e.jsx("span",{className:"truncate",title:S?`${p} (${C})`:p,children:p}),N&&e.jsx(fe,{to:N,onClick:v=>v.stopPropagation(),className:"flex-shrink-0 font-semibold text-sky-700 dark:text-sky-300 hover:underline",children:"Open"})]}):e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-white/5 bg-surface-2/40 px-4 py-2 text-[12.5px] text-gray-500 dark:text-gray-400","data-testid":"api-where",children:[e.jsx("span",{className:`rounded-full px-2 py-px text-[11px] font-semibold ${j.cls}`,children:j.text}),g?e.jsx("span",{children:p}):k.map((v,c)=>e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[c>0&&e.jsx("span",{"aria-hidden":!0,className:"text-gray-400",children:"›"}),e.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200 truncate",children:v})]},c)),S&&e.jsxs("span",{children:["· ",C]}),m.environment&&(m.request||m.folder)&&e.jsxs("span",{children:["· env ",m.environment]}),N&&e.jsx(fe,{to:N,className:"ml-auto font-semibold text-sky-700 dark:text-sky-300 hover:underline",children:"Open"})]})}function so({tools:s}){const l=s.filter(p=>p.toolName.startsWith("api_")&&p.phase==="complete").map(p=>Ls(p.toolName,p.args,p.fullResult||p.result)).filter(p=>!!p),x=xa(l.some(p=>p.kind==="oneoff")),o=l.map(p=>{if(p.kind!=="oneoff")return p;const N=oa(p.method,p.url,x);return N?{...p,kind:"read",...N}:null}).filter(p=>!!p);if(o.length===0)return null;const m=o.filter(p=>p.kind==="saved"),j=m.length?m:o,k=[...new Set(j.map(p=>p.collection).filter(p=>!!p))];if(k.length===0)return null;const g=ua[m.length?"saved":"read"],S=k.length===1?k[0]:`${k.length} collections`;return e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0 text-[12px] text-gray-500 dark:text-gray-400","data-testid":"api-where-summary",children:[e.jsx("span",{className:`rounded-full px-1.5 py-px text-[10.5px] font-semibold flex-shrink-0 ${g.cls}`,children:g.text}),e.jsx("span",{className:"truncate",title:k.join(", "),children:S}),k.length===1&&e.jsx(fe,{to:Wt({collection:k[0]}),onClick:p=>p.stopPropagation(),className:"flex-shrink-0 font-semibold text-sky-700 dark:text-sky-300 hover:underline",children:"Open"})]})}function ro({feedback:s,answer:n}){var v;const l=Ps(),{data:x}=_e({queryKey:["ask-rating",s.answerId],queryFn:()=>Wr([s.answerId]),staleTime:1/0}),o=(v=x==null?void 0:x.ratings)==null?void 0:v[s.answerId],[m,j]=i.useState(!1),[k,g]=i.useState(""),[S,p]=i.useState(!1),N=ra({mutationFn:c=>mn({answerId:s.answerId,sessionId:s.sessionId,question:s.question,answer:ji(n).slice(0,400),rating:c.rating,note:c.note}),onSuccess:c=>{l.setQueryData(["ask-rating",s.answerId],y=>({...y??{},ratings:{...(y==null?void 0:y.ratings)??{},[s.answerId]:c.rating}})),l.invalidateQueries({queryKey:["ask-feedback-summary"]}),p(!0),setTimeout(()=>p(!1),2e3)}}),C=c=>`inline-flex items-center rounded-md p-1 transition-colors ${c?"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":o==="up","data-testid":"ask-rate-up",disabled:N.isPending,onClick:()=>{j(!1),N.mutate({rating:"up"})},className:C(o==="up"),children:e.jsx(Kn,{size:12})}),e.jsx("button",{type:"button","aria-label":"Not helpful",title:"Not helpful — tell us what was wrong","aria-pressed":o==="down","data-testid":"ask-rate-down",disabled:N.isPending,onClick:()=>j(c=>!c),className:C(o==="down"||m),children:e.jsx(Jn,{size:12})}),S&&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:c=>{c.preventDefault(),N.mutate({rating:"down",note:k}),j(!1),g("")},children:[e.jsx("textarea",{autoFocus:!0,value:k,onChange:c=>g(c.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:N.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 ao(s){return s.replace(/\[\[(?:[^\]]|\](?!\]))*$/,"").trimEnd()}function no({text:s,feedback:n}){const l=gi(ao(s)),x=bi(l),[o,m]=i.useState(!1),j=async()=>{try{await navigator.clipboard.writeText(vi(l)),m(!0),setTimeout(()=>m(!1),1500)}catch{}},k=e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>void j(),"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:[o?e.jsx(dt,{size:12}):e.jsx(Yr,{size:12}),o?"Copied":"Copy"]}),n&&e.jsx(ro,{feedback:n,answer:l})]});return x.length===0?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{text:l}),k]}):e.jsxs(yi,{citations:x,children:[e.jsx(Ss,{text:l}),e.jsx(ki,{citations:x}),k]})}function io({result:s}){var x,o,m,j;const[n,l]=i.useState(()=>s.spec&&!s.saved?{state:"ready",spec:s.spec}:{state:"loading"});return i.useEffect(()=>{let k=!1;return(async()=>{var S;try{const p=await pn(s.id);k||l({state:"ready",spec:p.spec,saved:p});return}catch{}if(s.saved){k||l({state:"error",message:"This saved report is no longer available."});return}if(s.spec)return;const g=s.specUrl||((S=s.urls)==null?void 0:S.json);if(!g){k||l({state:"error",message:"This dashboard has no data file."});return}try{const p=await fetch(As(g),{cache:"no-store"});if(!p.ok)throw new Error(p.status===404?"The dashboard file is no longer on disk.":`HTTP ${p.status}`);const N=await p.json();k||l({state:"ready",spec:N})}catch(p){k||l({state:"error",message:p instanceof Error?p.message:String(p)})}})(),()=>{k=!0}},[s.id,s.saved,s.spec,s.specUrl,(x=s.urls)==null?void 0:x.json]),n.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(Bt,{size:14,className:"animate-spin"})," Loading dashboard",s.title?` “${s.title}”`:"","…"]}):n.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(Ut,{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:n.message})]})]}):e.jsx(wi,{spec:n.spec,urls:s.urls,savedId:(o=n.saved)==null?void 0:o.id,initialShareToken:(m=n.saved)==null?void 0:m.shareToken,initialShareExpiresAt:(j=n.saved)==null?void 0:j.shareExpiresAt})}function oo({url:s,filename:n,height:l=520}){var j;const x=As(s),o=(n||((j=s.split("/").pop())==null?void 0:j.split("?")[0])||"document.pdf").replace(/^\d{10,}-/,""),m=x+(x.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(Oe,{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:o}),e.jsx("a",{href:x,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(Es,{size:13})}),e.jsx("a",{href:x,download:o,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(Ht,{size:13})})]}),e.jsx("iframe",{src:m,title:o,className:"w-full bg-gray-50 dark:bg-black/30",style:{height:l}})]})}const lo={docx:{Icon:Oe,iconCls:"text-sky-500",label:"Word document"},doc:{Icon:Oe,iconCls:"text-sky-500",label:"Word document"},xlsx:{Icon:Dt,iconCls:"text-emerald-500",label:"Excel workbook"},xls:{Icon:Dt,iconCls:"text-emerald-500",label:"Excel workbook"},csv:{Icon:Dt,iconCls:"text-emerald-500",label:"CSV file"}};function co({url:s,filename:n,size:l}){var g;const x=As(s),o=(n||((g=s.split("/").pop())==null?void 0:g.split("?")[0])||"document").replace(/^\d{10,}-/,""),m=(o.split(".").pop()||"").toLowerCase(),j=lo[m]||{Icon:Xr,iconCls:"text-gray-500",label:"Document"},{Icon:k}=j;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(k,{size:18,className:j.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:o,children:o}),e.jsxs("div",{className:"text-[11px] text-gray-500 flex items-center gap-1.5",children:[e.jsx("span",{children:j.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}),l&&e.jsxs("span",{children:["· ",l]})]})]}),e.jsx("a",{href:x,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(Es,{size:14})}),e.jsxs("a",{href:x,download:o,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(Ht,{size:13})," Download"]})]})})}class Or extends i.Component{constructor(){super(...arguments);Sr(this,"state",{error:null})}static getDerivedStateFromError(l){return{error:l}}componentDidCatch(l,x){console.error("[testver] render error contained:",l,x.componentStack)}render(){return this.state.error?this.props.fallback(this.state.error):this.props.children}}const Le=5,uo=[{id:"all",label:"All"},{id:"requirement",label:"Requirements"},{id:"nlp",label:"Notes"},{id:"jira",label:"JIRA"},{id:"document",label:"Other Sources"}],xo={requirement:"Requirement",nlp:"Note",jira:"JIRA",document:"Other source"};function Is({type:s,size:n=13,className:l=""}){const x=s==="requirement"?Gn:s==="nlp"?Vn:s==="jira"?Qn:Zr;return e.jsx(x,{size:n,className:`flex-shrink-0 ${l}`})}function lt(s){return s.type==="jira"&&s.jiraKey&&!s.title.toUpperCase().startsWith(s.jiraKey)?`${s.jiraKey}: ${s.title}`:s.title}const mo=/\.(png|jpe?g|gif|webp|bmp|svg|tiff?|heic)$/i;function ma(s){return!s.repoPath&&s.textChars===0&&(!s.hasFile||mo.test(s.fileName||""))}function pa(s){if(s.repoPath)return`project file · ${s.repoPath}`;if(ma(s))return s.fileName?`image · ${s.fileName}`:"no text";if(s.textChars>0){const n=s.textChars/1024;return`${n<1?"< 1":n<10?n.toFixed(1):Math.round(n)} KB text`}return s.hasFile?s.fileName?`file · ${s.fileName}`:"file":"no text"}function ha(s=!1,n=!0){return _e({queryKey:["source-summaries",s],queryFn:()=>hn({includeArchived:s}),enabled:n,staleTime:3e4})}function fa(s,n){const l=n.trim().toLowerCase();return l?s.filter(x=>x.title.toLowerCase().includes(l)||(x.jiraKey||"").toLowerCase().includes(l)||(x.fileName||"").toLowerCase().includes(l)||x.id.toLowerCase().includes(l)):s}function po({open:s,onClose:n,selected:l,onAdd:x,askMode:o}){const[m,j]=i.useState("all"),[k,g]=i.useState(""),[S,p]=i.useState(!1),[N,C]=i.useState(new Map),{data:v,isLoading:c,error:y}=ha(S,s);i.useEffect(()=>{s&&(C(new Map(l.map(w=>[w.id,w]))),g(""))},[s]),i.useEffect(()=>{if(!s)return;const w=O=>{O.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[s,n]);const h=(v==null?void 0:v.sources)??[],I=i.useMemo(()=>{const w={all:h.length};for(const O of h)w[O.type]=(w[O.type]??0)+1;return w},[h]),R=i.useMemo(()=>fa(m==="all"?h:h.filter(w=>w.type===m),k),[h,m,k]);if(!s)return null;const D=N.size>=Le,F=w=>C(O=>{const G=new Map(O);return G.has(w.id)?G.delete(w.id):G.size<Le&&G.set(w.id,{id:w.id,title:w.title,type:w.type,jiraKey:w.jiraKey}),G});return Ya.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:n}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":o?"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(ea,{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:o?"Answer from Sources":"Add from Sources"}),e.jsx("p",{className:"text-[13px] text-gray-500 dark:text-gray-400",children:o?"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:n,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:uo.map(w=>e.jsxs("button",{type:"button",onClick:()=>j(w.id),className:`px-2.5 py-1 rounded-lg text-[13px] transition-colors ${m===w.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:[w.label,I[w.id]?e.jsx("span",{className:"ml-1 text-gray-400",children:I[w.id]}):null]},w.id))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ms,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{autoFocus:!0,value:k,onChange:w=>g(w.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:S,onChange:w=>p(w.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:c?e.jsx("p",{className:"px-2 py-6 text-center text-sm text-gray-500",children:"Loading sources…"}):y?e.jsxs("p",{className:"px-2 py-6 text-center text-sm text-red-500",children:["Could not load sources: ",y.message]}):h.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(fe,{to:"/sources",onClick:n,className:"text-brand-500 hover:underline",children:"Sources"})," screen."]})]}):R.length===0?e.jsxs("p",{className:"px-2 py-6 text-center text-sm text-gray-500",children:["No sources match “",k,"”."]}):R.map(w=>{const O=N.has(w.id),G=ma(w);return e.jsxs("button",{type:"button",onClick:()=>F(w),disabled:!O&&D,"data-testid":`source-row-${w.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 ${O?"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 ${O?"bg-brand-500 border-brand-500 text-white":"border-gray-300 dark:border-white/20"}`,children:O&&e.jsx(dt,{size:11,strokeWidth:3})}),e.jsx(Is,{type:w.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:lt(w)}),e.jsxs("span",{className:"block truncate text-xs text-gray-500",children:[xo[w.type]," · ",pa(w)," · updated ",new Date(w.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),w.status!=="active"?` · ${w.status}`:""]})]}),G&&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(Oe,{size:11})," no readable text"]})]},w.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:[N.size," of ",Le," selected",D?" — the most one message can carry":""]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:n,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:()=>{x([...N.values()]),n()},disabled:N.size===0&&l.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:[l.length>0?"Update":"Add",N.size>0?` ${N.size}`:""]})]})]})]})]}),document.body)}function ho(){const s=new Date().getHours();return s>=5&&s<12?"Good morning":s>=12&&s<18?"Good afternoon":"Good evening"}function fo({run:s}){const n=s.waitingForApproval;return e.jsxs("span",{className:`flex-shrink-0 inline-flex items-center gap-1 rounded-full px-1.5 py-px text-[10px] font-semibold ${n?"bg-amber-500/15 text-amber-700 dark:text-amber-300":"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300"}`,title:n?"This task is waiting for your approval":"This task is running","data-testid":"history-running-pill",children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full motion-safe:animate-pulse ${n?"bg-amber-400":"bg-emerald-400"}`}),n?"Needs approval":"Running"]})}const ga="testver.ai.seenRuns";function ba(){try{const s=JSON.parse(sessionStorage.getItem(ga)||"[]");return Array.isArray(s)?s.filter(n=>typeof n=="string"):[]}catch{return[]}}function ot(s){try{const n=[s,...ba().filter(l=>l!==s)].slice(0,30);sessionStorage.setItem(ga,JSON.stringify(n))}catch{}}function go({onControlsReady:s,hideFloatingControls:n}){var vr,jr,wr,Nr;const{subscribe:l,send:x,adoptClientId:o}=Ur(),m=fn(),[j,k]=i.useState([]),[g,S]=i.useState(null),[p,N]=i.useState(!1),C=gn(),[v,c]=i.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"}),y=v==="ask",h=v==="api",[I,R]=i.useState(()=>{try{return localStorage.getItem("testver:api-panel")!=="closed"}catch{return!0}}),D=t=>{R(t);try{localStorage.setItem("testver:api-panel",t?"open":"closed")}catch{}},F=(()=>{const t=[];return C.showsWeb&&t.push("web"),C.showsMobile&&t.push("mobile"),t.push("api","reporting","ask"),t})();i.useEffect(()=>{C.isLoading||F.includes(v)||c(F[0]??"web")},[C.mode,C.isLoading]),i.useEffect(()=>{try{localStorage.setItem("testver-ai-chat-mode",v)}catch{}},[v]);const w=i.useRef(null),O=i.useRef(null),[G,ne]=i.useState(0);i.useEffect(()=>{try{const r=localStorage.getItem("testver-ai-initial-prompt");r&&(w.current=r,localStorage.removeItem("testver-ai-initial-prompt"));const a=localStorage.getItem("testver-ai-attached-test");a&&(O.current=JSON.parse(a),localStorage.removeItem("testver-ai-attached-test"))}catch{}const t=r=>{const a=r.detail||{};typeof a.prompt=="string"&&a.prompt&&(w.current=a.prompt),a.attachedTest&&a.attachedTest.file&&a.attachedTest.name&&(O.current=a.attachedTest),(a.mode==="web"||a.mode==="api"||a.mode==="mobile"||a.mode==="reporting"||a.mode==="ask")&&c(a.mode),ne(d=>d+1)};return window.addEventListener("testver-ai-handoff",t),()=>window.removeEventListener("testver-ai-handoff",t)},[]);const[ie,Y]=i.useState(null),b=i.useRef(""),M=i.useRef(null),[E,re]=i.useState("all"),[X,W]=i.useState(null),[P,Z]=i.useState(""),[ee,ce]=i.useState(""),[te,J]=i.useState(null),[ge,oe]=i.useState(null),[T,K]=i.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem("testver-ai-pinned-sessions")||"[]"))}catch{return new Set}}),[V,f]=i.useState([]),q=i.useMemo(()=>{const t=[];for(const r of V){if(r.kind!=="tool"||r.phase!=="complete"||!r.toolName.startsWith("api_"))continue;const a=Ls(r.toolName,r.args,r.fullResult||r.result);a&&t.push(a)}return t},[V]),_=i.useMemo(()=>V.filter(t=>t.kind==="tool"&&t.phase==="complete"&&t.toolName.startsWith("api_")).length,[V]),[U,z]=i.useState(""),ue=i.useRef(async()=>{}),ya=i.useCallback(()=>{ue.current("Continue")},[]),{data:Kt}=bn(yn()),[Ae,Ye]=i.useState(null),[ct,Fe]=i.useState(!1),[Os,_s]=i.useState(""),[Fs,ut]=i.useState(0),be=v==="web"||v==="mobile"||v==="api"||v==="reporting",{data:xt}=hi(),{mcpEnabled:mt,uploads:Bs,apiUploads:ka}=fi(),Re=v==="api"?ka??Bs:Bs,Jt=i.useMemo(()=>{const t=[];for(const r of(xt==null?void 0:xt.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},[xt]),Be=i.useMemo(()=>{if(!ct)return[];const t=Os.toLowerCase();return(t?Jt.filter(a=>mi(a.name,t)||a.file.toLowerCase().includes(t)):Jt).slice(0,50)},[ct,Os,Jt]),va=(t,r)=>{const a=t.slice(0,r).match(/(?:^|\s)@([\w./:\- ]*)$/);return a?a[1]:null},Us=t=>{Ye(t),Fe(!1),_s(""),z(r=>r.replace(/(?:^|\s)@([\w./:\- ]*)$/,"").replace(/\s+$/,"")),setTimeout(()=>{var r;return(r=ve.current)==null?void 0:r.focus()},0)};i.useEffect(()=>{be||(Ye(null),Fe(!1))},[be]),i.useEffect(()=>{y&&(yt([]),Ee(!1),Ke([]))},[y]);const pt=v!=="reporting",Xe=v==="reporting",[xe,Ze]=i.useState([]),[ja,ht]=i.useState(!1),[wa,et]=i.useState(!1),[tt,Te]=i.useState(!1),[Gt,Hs]=i.useState(""),[Vt,ft]=i.useState(0),{data:Ue}=ha(!1,tt),qe=i.useMemo(()=>{if(!tt)return[];const t=new Set(xe.map(r=>r.id));return fa((Ue==null?void 0:Ue.sources)??[],Gt).filter(r=>!t.has(r.id)).slice(0,30)},[tt,Gt,Ue,xe]),Ws=tt&&(qe.length>0||Gt===""&&!!Ue&&Ue.sources.length===0),Ks=/(?:^|\s)#([\w\-.: ]{0,40})$/,Na=(t,r)=>{const a=t.slice(0,r).match(Ks);return a?a[1]:null};i.useEffect(()=>{pt||(Ze([]),Te(!1),et(!1),ht(!1))},[pt]);const Js=t=>{Ze(r=>r.some(a=>a.id===t.id)||r.length>=Le?r:[...r,t]),Te(!1),Hs(""),z(r=>r.replace(Ks,"").replace(/\s+$/,"")),setTimeout(()=>{var r;return(r=ve.current)==null?void 0:r.focus()},0)},[gt,Sa]=i.useState([]),Gs=Ft(),[Qt,Ca]=i.useState([]),[bt,yt]=i.useState([]),[ye,$a]=i.useState(()=>{try{return JSON.parse(localStorage.getItem("testver-ai-mcp")||"[]")}catch{return[]}}),[kt,Ee]=i.useState(!1),[Yt,Vs]=i.useState(""),[Xt,vt]=i.useState(0),[Ia,Zt]=i.useState(!1);i.useEffect(()=>{kn().then(t=>{Sa(t.skills);const r=new Set(t.skills.filter(a=>a.enabled).map(a=>a.slug));yt(a=>a.filter(d=>r.has(d)))}).catch(()=>{}),es()},[]),i.useEffect(()=>{try{localStorage.removeItem("testver-ai-skills")}catch{}},[]),i.useEffect(()=>{try{localStorage.setItem("testver-ai-mcp",JSON.stringify(ye))}catch{}},[ye]);const Me=i.useMemo(()=>{if(!kt||y)return[];const t=Yt.toLowerCase(),r=gt.filter(d=>d.enabled);return(t?r.filter(d=>{var u;return d.name.toLowerCase().includes(t)||d.slug.toLowerCase().includes(t)||((u=d.tags)==null?void 0:u.some($=>$.toLowerCase().includes(t)))}):r).slice(0,50)},[kt,Yt,gt,y]),Qs=/(?:^|\s)\/([\w-]*)$/,[Aa,Ra]=i.useState(!1),Ta=(t,r)=>{if(y)return null;const a=t.slice(0,r).match(Qs);return a?a[1]:null},Ys=kt&&(Aa||Me.length>0),Xs=t=>yt(r=>r.includes(t)?r.filter(a=>a!==t):[...r,t]),es=i.useCallback(()=>{vn().then(t=>Ca((t.servers||[]).filter(r=>r.enabled))).catch(()=>{})},[]),Zs=t=>$a(r=>r.includes(t)?r.filter(a=>a!==t):(En(t).catch(()=>{}).finally(()=>es()),[...r,t])),er=t=>{Xs(t.slug),Ee(!1),Vs(""),z(r=>r.replace(Qs,"").replace(/\s+$/,"")),setTimeout(()=>{var r;return(r=ve.current)==null?void 0:r.focus()},0)},tr=t=>{var r;return((r=gt.find(a=>a.slug===t))==null?void 0:r.name)||t},qa=t=>{var r;return((r=Qt.find(a=>a.id===t))==null?void 0:r.name)||t};i.useEffect(()=>{O.current&&(Ye(O.current),O.current=null),w.current&&(z(w.current),w.current=null,requestAnimationFrame(()=>{const t=ve.current;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)}))},[G]);const[H,Ce]=i.useState(!1),[To,sr]=i.useState(null),me=i.useRef(null),Pe=t=>{me.current=t,sr(t)},He=i.useRef(null),ze=i.useRef(null),jt=i.useRef(null),wt=i.useRef(null),De=()=>{wt.current&&clearInterval(wt.current),wt.current=null};i.useEffect(()=>De,[]);const We=i.useRef([]),[ts,Ke]=i.useState([]),[Ea,rr]=i.useState(!1),[ar,ss]=i.useState(!1),rs=i.useRef(null),ae=i.useRef(""),Q=i.useRef(null),as=i.useRef(0),[Nt,ns]=i.useState("manual"),is=i.useRef("manual");is.current=Nt;const[Ne,ke]=i.useState(null),pe=i.useRef([]),St=i.useRef(!1),Ct=i.useRef(!1),[qo,Eo]=i.useState(null),[nr,Ma]=i.useState([]),[$t,ir]=i.useState(""),[Je,or]=i.useState(""),[os,ls]=i.useState(!1);i.useEffect(()=>{jn().then(t=>{const r=[],a=t.effectiveProvider||t.defaultProvider;for(const[u,$]of Object.entries(t.providers)){if(Ti.has(u)||!$.hasApiKey&&!$.isLocal)continue;if(u==="testver"){r.push({provider:u,models:[""]});continue}const A=$.models,L=Array.isArray(A)&&A.length>0?A:[$.model].filter(Boolean);L.length>0&&r.push({provider:u,models:L})}Ma(r);const d=t.providers[a];d&&(or(a),ir(a==="testver"?"":d.activeModel||d.model||""))}).catch(t=>{console.warn("[ChatPanel] Failed to load LLM config:",t)})},[]);const It=i.useRef(null),ve=i.useRef(null),Pa=i.useRef(0),st=i.useRef(null),{user:Ge}=wn(),za=(Ge==null?void 0:Ge.displayName)||(Ge==null?void 0:Ge.username)||"";st.current=g;const ds=V.some(t=>t.kind==="user"||t.kind==="text"||t.kind==="loading"),cs=i.useCallback(()=>N(t=>!t),[]),At=i.useCallback(()=>{H||(Nn().catch(()=>{}),S(null),We.current=[],Ke([]),f([]),pe.current=[],ke(null),Y(null),ns("manual"),Tt())},[H]),Da=i.useCallback(t=>{ns(t),is.current=t,g&&(Ar(g,t).catch(()=>{}),k(a=>a.map(d=>d.id===g?{...d,permissionMode:t}:d)));const r=me.current;r&&Sn(r,t).catch(()=>{}),t==="auto"&&(pe.current=pe.current.filter(a=>!a.autoEligible),Ne!=null&&Ne.autoEligible&&ke(pe.current.shift()||null))},[g,Ne]),Rt=i.useCallback(t=>{c(t),Y(null),g&&(Cn(g,t).catch(()=>{}),k(r=>r.map(a=>a.id===g?{...a,mode:t}:a)))},[g]);i.useEffect(()=>{s==null||s({toggleSidebar:cs,newChat:At,sidebarOpen:p})},[s,cs,At,p]),i.useEffect(()=>{Tt()},[]);const Tt=async()=>{try{const t=await $n();k(t.sessions)}catch{}},La=async t=>{if(H)return;const r=m.running.find(a=>a.sessionId===t);if(r){cr(r);return}try{const a=await Tr(t);lr(a);const d=a.pendingRun;if(d){const u=[];for(const $ of d.events)try{u.push(JSON.parse($))}catch{}dr(a.id,d.requestId,d.userText,u,{truncated:d.truncated,mode:a.mode})}}catch(a){f(d=>[...d,{kind:"error",id:`err-${Date.now()}`,text:`Failed to load session: ${a}`}])}},lr=t=>{const r=t.id;{S(r),Ct.current=!0,pe.current=[],ke(null),Y(null),c(t.mode??"web"),ns(t.permissionMode==="auto"?"auto":"manual");const a=[];for(const d of t.messages)a.push({role:d.role,content:d.content});if(We.current=a,Array.isArray(t.fullTimeline)&&t.fullTimeline.length>0){const d=t.fullTimeline.map(u=>{const $=u.id||`restored-${Date.now()}-${Math.random()}`;return u.kind==="user"?{kind:"user",id:$,text:u.text||"",mode:u.mode}:u.kind==="system"?{kind:"system",id:$,text:u.text||""}:u.kind==="text"?{kind:"text",id:$,text:u.text||"",done:!0}:u.kind==="error"?{kind:"error",id:$,text:u.text||""}:u.kind==="tool"?{kind:"tool",id:$,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:$,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:$,text:""}});f(d)}else{const d=[];for(const u of t.messages){const $=`restored-${Date.now()}-${Math.random()}`;u.role==="user"?d.push({kind:"user",id:$,text:u.content}):d.push({kind:"text",id:$,text:u.content,done:!0})}f(d)}Ke([]),N(!1),setTimeout(()=>{Ct.current=!1},0)}},dr=(t,r,a,d,u)=>{Ct.current=!1,st.current=t,ae.current="",Q.current=null,as.current=0,f(A=>[...A,...a&&!A.some(L=>L.id===`user-${r}`)&&!(A.length>0&&A[A.length-1].kind==="user"&&A[A.length-1].text===a)?[{kind:"user",id:`user-${r}`,text:a,mode:u.mode}]:[],...u.truncated?[{kind:"system",id:`run-trunc-${r}`,text:"The earliest steps of this task are too long to show here."}]:[],{kind:"loading",id:`loading-${r}`}]),Ce(!0),St.current=!0,jt.current=r,Pe(r),He.current={requestId:r,lastSeq:0};const $=new Set(u.pendingPermissionIds??[]);for(const A of d)A.type==="ai-fix-permission"&&!$.has(String(A.permissionId))||Ve(A)},qt=i.useRef(null),cr=async t=>{var r;if(!(!t.sessionId||qt.current===t.requestId||me.current===t.requestId)){qt.current=t.requestId;try{let a=t.clientId===Rr();!a&&t.status==="running"&&t.clientId&&!t.tabOpen&&o&&(a=await o(t.clientId)===t.clientId),ze.current={requestId:t.requestId,queue:[]};const[d,u]=await Promise.all([Tr(t.sessionId),fs(t.requestId)]);if(De(),lr(d),u.run.status!=="running"&&!d.pendingRun){ze.current=null,ot(t.requestId);return}dr(d.id,t.requestId,u.run.userText,u.events,{pendingPermissionIds:u.pendingPermissionIds,truncated:u.truncated,mode:d.mode});const $=((r=ze.current)==null?void 0:r.queue)??[];ze.current=null;for(const A of $)Ve(A);!a&&u.run.status==="running"&&(f(A=>[...A,{kind:"system",id:`other-tab-${t.requestId}`,text:"This task belongs to another open Testver tab: its steps appear here a moment after they happen there. Stop and approvals work from here too."}]),fr(t.requestId))}catch(a){ze.current=null,f(d=>[...d,{kind:"error",id:`err-${Date.now()}`,text:`Could not open the running task: ${a}`}])}finally{qt.current=null}}},ur=i.useRef(new Set);i.useEffect(()=>{if(H||ze.current||qt.current||ds)return;const t=Rr(),r=ba(),a=m.runs.find(d=>In(d)&&!!d.sessionId&&!ur.current.has(d.requestId)&&!r.includes(d.requestId)&&(d.status==="running"?d.clientId===t||!d.tabOpen:d.clientId===t));a&&(ur.current.add(a.requestId),cr(a))},[m.runs,H,ds]);const Oa=(t,r)=>{const a=j.find(d=>d.id===t);oe({id:t,title:(a==null?void 0:a.title)||"this chat"})},_a=async()=>{if(!ge)return;const t=ge.id;oe(null);try{await zn(t),k(r=>r.filter(a=>a.id!==t)),g===t&&At()}catch{}},Fa=(t,r,a)=>{W(t),Z(r)},xr=async t=>{if(t.stopPropagation(),!X||!P.trim()){W(null);return}try{await Pn(X,P.trim()),k(r=>r.map(a=>a.id===X?{...a,title:P.trim()}:a))}catch{}W(null)};i.useEffect(()=>{if(!te)return;const t=()=>J(null);return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[te]);const Ba=i.useCallback(t=>{K(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})},[]),mr=i.useMemo(()=>{const t=new Map;for(const r of m.running)r.sessionId&&t.set(r.sessionId,r);return t},[m.running]),pr=i.useMemo(()=>{const t=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=r-864e5,d=r-7*864e5;let u=j.filter(B=>B.messageCount>0||B.id===g);if(E!=="all"&&(u=u.filter(B=>(B.mode??"web")===E)),ee){const B=ee.toLowerCase();u=u.filter(we=>we.title.toLowerCase().includes(B))}const $=u.filter(B=>T.has(B.id)),A=u.filter(B=>!T.has(B.id)),L=[];$.length>0&&L.push({label:"📌 Pinned",items:$});const se=A.filter(B=>new Date(B.updatedAt||B.createdAt).getTime()>=r),le=A.filter(B=>{const we=new Date(B.updatedAt||B.createdAt).getTime();return we>=a&&we<r}),$e=A.filter(B=>{const we=new Date(B.updatedAt||B.createdAt).getTime();return we>=d&&we<a}),at=A.filter(B=>new Date(B.updatedAt||B.createdAt).getTime()<d);return se.length>0&&L.push({label:"Today",items:se}),le.length>0&&L.push({label:"Yesterday",items:le}),$e.length>0&&L.push({label:"This Week",items:$e}),at.length>0&&L.push({label:"Older",items:at}),L},[j,T,ee,E,g]),us=i.useCallback(t=>{f(r=>r.filter(a=>!(a.kind==="loading"&&a.id===`loading-${t}`)))},[]),rt=i.useRef(null),Et=i.useCallback(()=>{const t=rt.current;t&&(t.raf!=null&&cancelAnimationFrame(t.raf),t.timer!=null&&clearTimeout(t.timer),rt.current=null)},[]),je=i.useCallback(()=>{Et();const t=Q.current,r=ae.current;t&&f(a=>{const d=a.findIndex(u=>u.id===t);if(d>=0){const u=[...a];return u[d]={...u[d],kind:"text",text:r},u}return a})},[Et]),hr=i.useCallback(()=>{if(rt.current)return;const t=()=>{rt.current=null,je()};rt.current=typeof document<"u"&&document.hidden?{timer:setTimeout(t,100)}:{raf:requestAnimationFrame(t)}},[je]);i.useEffect(()=>Et,[Et]);const Mt=i.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&&Y({suggested:a.suggestedMode,reason:a.reason||`Message looks like a ${a.suggestedMode} request`});return}if(t.type==="client-id"&&!t.resumed&&me.current){const a=me.current;je(),ae.current="",Q.current=null,f(d=>[...d.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."}]),Ce(!1),Pe(null),ke(null),pe.current=[];return}if(t.type==="replay-incomplete"&&me.current){f(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(us(r),t.type==="ai-fix-stopped"){je();const a=Q.current;a&&f(d=>d.map(u=>u.id===a&&u.kind==="text"?{...u,done:!0}:u)),ae.current="",Q.current=null,f(d=>[...d,{kind:"system",id:`stopped-${r}`,text:"Generation stopped by user"}]),ot(r),Ce(!1),Pe(null),ke(null),pe.current=[];return}if(t.type==="ai-fix-notice"){const a=t,d=`notice-${r}`,u=a.kind==="ai-recovered"?{kind:"notice",id:d,tone:"recovered",text:"Reconnected to the AI service — carrying on."}:{kind:"notice",id:d,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};f($=>{const A=$.findIndex(se=>se.id===d);if(A<0)return[...$,u];const L=[...$];return L[A]=u,L}),Q.current&&(je(),ae.current="",Q.current=null);return}if(t.type==="ai-mcp-notice"){const a=t.text;a&&f(d=>[...d,{kind:"system",id:`mcp-notice-${r}-${Date.now()}`,text:a}]);return}if(t.type==="ai-fix-stream"){const a=t.content;if(!Q.current){const d=`text-${r}-${++as.current}`;ae.current="",Q.current=d,f(u=>[...u,{kind:"text",id:d,text:""}])}ae.current+=a,hr();return}if(t.type==="ai-fix-tool"){const a=t.phase,d=t.toolName,u=t.args;if(a==="start"){if(Q.current){ae.current&&je();const A=Q.current;f(L=>{const se=L.findIndex(le=>le.id===A);if(se>=0){const le=[...L],$e=le[se];return $e.kind==="text"&&(le[se]={...$e,done:!0}),le}return L}),ae.current="",Q.current=null}const $=`tool-${d}-${Date.now()}-${Math.random()}`;f(A=>[...A,{kind:"tool",id:$,phase:"start",toolName:d,args:u,startedAt:Date.now()}])}else f($=>{const A=[...$];for(let L=A.length-1;L>=0;L--){const se=A[L];if(se.kind==="tool"&&se.toolName===d&&se.phase==="start"){A[L]={...se,phase:a,result:t.result,fullResult:t.fullResult,error:t.error,endedAt:Date.now()};break}}return A});return}if(t.type==="ai-fix-file-diff"){f(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"){f(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&&is.current==="auto")return;ke(d=>d?(pe.current.push(a),d):a);return}if(t.type==="ai-fix-done"){je();const a=ae.current||"";if(a){We.current.push({role:"assistant",content:a});const d=st.current;d&&(hs(d,"assistant",a,r).catch(()=>{}),Tt())}Q.current&&(f(d=>{const u=d.findIndex($=>$.id===Q.current);if(u>=0){const $=[...d],A=$[u];return A.kind==="text"&&($[u]={...A,done:!0}),$}return d}),ae.current="",Q.current=null),ot(r),Ce(!1),Pe(null),ke(null);return}if(t.type==="ai-fix-error"){je();const a=t.resumable===!0;if(a&&ae.current){We.current.push({role:"assistant",content:ae.current});const d=st.current;d&&hs(d,"assistant",ae.current,r).catch(()=>{})}ae.current="",Q.current=null,f(d=>[...d.filter(u=>!(u.kind==="notice"&&u.id===`notice-${r}`&&u.tone==="retrying")),{kind:"error",id:`err-${Date.now()}`,text:t.message,...a?{resumable:!0}:{}}]),ot(r),Ce(!1),Pe(null),ke(null);return}}},[us,je,hr]),fr=t=>{De(),wt.current=setInterval(()=>{const r=He.current;if(me.current!==t||!r||r.requestId!==t){De();return}fs(t,r.lastSeq).then(a=>{const d=new Set(a.pendingPermissionIds);for(const u of a.events)u.type==="ai-fix-permission"&&!d.has(String(u.permissionId))||xs.current(u);a.run.status!=="running"&&De()}).catch(()=>De())},2e3)},Ve=i.useCallback(t=>{const r=t.requestId,a=t.runSeq;if(r&&typeof a=="number"){const d=He.current;if(d&&d.requestId===r){if(a<=d.lastSeq)return;d.lastSeq=a}else He.current={requestId:r,lastSeq:a}}Mt(t)},[Mt]),xs=i.useRef(Ve);xs.current=Ve,i.useEffect(()=>l(t=>{if(t.type==="client-id"&&!t.resumed&&me.current){const a=me.current,d=He.current;fs(a,d&&d.requestId===a?d.lastSeq:0).then(u=>{const $=new Set(u.pendingPermissionIds);for(const A of u.events)A.type==="ai-fix-permission"&&!$.has(String(A.permissionId))||xs.current(A);u.run.status==="running"&&fr(a)}).catch(()=>Mt(t));return}const r=ze.current;if(r&&t.requestId===r.requestId){r.queue.push(t);return}Ve(t)}),[l,Ve,Mt]);const Pt=i.useRef(!0),gr=i.useRef(0);i.useEffect(()=>{It.current&&Pt.current&&(It.current.scrollTop=It.current.scrollHeight)},[V,Ne]),i.useEffect(()=>{if(H||!St.current||Ct.current)return;const t=st.current;if(!t)return;St.current=!1;const r=V.map(d=>{if(d.kind==="text")return{kind:"text",id:d.id,text:d.text,done:d.done};if(d.kind==="user")return{kind:"user",id:d.id,text:d.text,mode:d.mode};if(d.kind==="system")return{kind:"system",id:d.id,text:d.text};if(d.kind==="error")return{kind:"error",id:d.id,text:d.text};if(d.kind==="tool"){const u=d;return{kind:"tool",id:d.id,phase:u.phase,toolName:u.toolName,args:u.args,result:u.result,fullResult:u.fullResult,error:u.error,startedAt:u.startedAt,endedAt:u.endedAt}}if(d.kind==="diff"){const u=d;return{kind:"diff",id:d.id,filePath:u.filePath,diffType:u.diffType,diff:u.diff,linesAdded:u.linesAdded,linesRemoved:u.linesRemoved,via:u.via,unavailable:u.unavailable,netNoChange:u.netNoChange,omitted:u.omitted}}return null}).filter(Boolean),a=jt.current||void 0;jt.current=null,An(t,r,a).catch(()=>{})},[H,V]);const ms=async t=>{if(!t.trim()||H)return;const r=`chat-${Date.now()}-${++Pa.current}`;b.current=t,ae.current="",Q.current=null,as.current=0;let a=g;if(!a){a=`session-${Date.now()}`;try{await Rn(a,"New Chat",v),Nt==="auto"&&await Ar(a,"auto")}catch{}S(a)}Y(null);const d=be?Ae:null,u=d?`"${d.name}" `:"",$=[...bt],A=$.length>0?`
|
|
13
|
+
📚 Skills used: ${$.map(tr).join(", ")}`:"",L=pt?[...xe]:[],se=L.length>0?`
|
|
14
|
+
🗂 ${y?"Answer from":"Sources"}: ${L.map(he=>`${lt(he)} (${he.id})`).join(", ")}`:"",le=u+t+A+se,$e=y?[]:ts,at=$e.map(he=>he.originalName),B=at.length>0?`${le}
|
|
15
|
+
📎 ${at.join(", ")}`:le;We.current.push({role:"user",content:t+se}),hs(a,"user",le).catch(()=>{}).finally(()=>{Tt()}),f(he=>[...he,{kind:"user",id:`user-${r}`,text:B,mode:v},{kind:"loading",id:`loading-${r}`}]),z(""),Pt.current=!0,Ye(null),Fe(!1),yt([]),Ee(!1),y||Ze([]),Te(!1),ve.current&&(ve.current.style.height="auto"),Ce(!0),St.current=!0,jt.current=r,He.current={requestId:r,lastSeq:0},Pe(r);const we=$e.map(he=>he.id);Ke([]);try{const zt=We.current.slice(-20).slice(0,-1);await Tn({requestId:r,message:t,history:zt.length>0?zt:void 0,uploadedFileIds:we.length>0?we:void 0,model:$t||void 0,provider:Je||void 0,mode:v,attachedTest:d||void 0,skillSlugs:$.length>0?$:void 0,mcpServerIds:!y&&mt&&ye.length>0?ye:void 0,permissionMode:Nt,sourceIds:L.length>0?L.map(Ga=>Ga.id):void 0,sessionId:a,displayText:B})}catch(he){us(r),f(zt=>[...zt,{kind:"error",id:`err-${Date.now()}`,text:`Failed to send: ${he}`}]),Ce(!1),Pe(null)}};ue.current=ms;const br=()=>ms(U.trim()),Ua=t=>{const r=b.current;H&&kr(),r&&(M.current={text:r,mode:t}),Rt(t)};i.useEffect(()=>{const t=M.current;!t||H||v!==t.mode||(M.current=null,ms(t.text))},[v,H]);const Ha=t=>{if(tt&&qe.length>0){if(t.key==="ArrowDown"){t.preventDefault(),ft(r=>Math.min(r+1,qe.length-1));return}if(t.key==="ArrowUp"){t.preventDefault(),ft(r=>Math.max(r-1,0));return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),Js(qe[Vt]||qe[0]);return}if(t.key==="Escape"){t.preventDefault(),Te(!1);return}}if(Ws&&t.key==="Escape"){t.preventDefault(),Te(!1);return}if(be&&ct&&Be.length>0){if(t.key==="ArrowDown"){t.preventDefault(),ut(r=>Math.min(r+1,Be.length-1));return}if(t.key==="ArrowUp"){t.preventDefault(),ut(r=>Math.max(r-1,0));return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),Us(Be[Fs]||Be[0]);return}if(t.key==="Escape"){t.preventDefault(),Fe(!1);return}}if(kt&&Me.length>0){if(t.key==="ArrowDown"){t.preventDefault(),vt(r=>Math.min(r+1,Me.length-1));return}if(t.key==="ArrowUp"){t.preventDefault(),vt(r=>Math.max(r-1,0));return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),er(Me[Xt]||Me[0]);return}}if(Ys&&t.key==="Escape"){t.preventDefault(),Ee(!1);return}t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),br())},yr=async t=>{const{accepted:r,rejected:a}=Fi(Array.from(t),Re,v==="api"?Di:void 0);a.length>0&&f(u=>[...u,{kind:"error",id:`upload-rej-${Date.now()}`,text:a.length===1?`Not uploaded — ${a[0]}`:`Not uploaded:
|
|
16
|
+
${a.map($=>`• ${$}`).join(`
|
|
17
|
+
`)}`}]);const d=r;if(d.length!==0){rr(!0);try{const u=await qn(d,v);Ke($=>[...$,...u.files])}catch(u){f($=>[...$,{kind:"error",id:`upload-err-${Date.now()}`,text:`Upload failed: ${u}`}])}finally{rr(!1)}}},Wa=t=>{t.preventDefault(),t.stopPropagation(),ss(!0)},Ka=t=>{t.preventDefault(),t.stopPropagation(),ss(!1)},Ja=t=>{t.preventDefault(),t.stopPropagation(),ss(!1),t.dataTransfer.files.length>0&&yr(t.dataTransfer.files)},kr=()=>{const t=me.current;if(t){if(me.current=null,sr(null),ke(null),pe.current=[],Q.current){je();const r=Q.current;f(a=>{const d=a.findIndex(u=>u.id===r);if(d>=0){const u=[...a],$=u[d];return $.kind==="text"&&(u[d]={...$,done:!0}),u}return a}),ae.current="",Q.current=null}Ce(!1),De(),ot(t),f(r=>[...r,{kind:"system",id:`stopped-${Date.now()}`,text:"Generation stopped by user"}]),Mn({requestId:t}).catch(()=>{})}},ps=(t,r=!1)=>{if(!Ne)return;x({type:"ai-fix-permission-response",permissionId:Ne.permissionId,granted:t,remember:t&&r});const a=pe.current.shift()||null;ke(a)};return e.jsx(Ni,{children:e.jsx(Si,{children:e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[!n&&e.jsxs("div",{className:"absolute top-3 right-3 z-10 flex flex-col items-center gap-1.5",children:[e.jsx("button",{onClick:At,disabled:H,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(Yn,{size:14})}),e.jsx("button",{onClick:cs,className:`p-1.5 rounded-lg transition-all shadow-lg backdrop-blur-sm opacity-70 hover:opacity-100 ${p?"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:p?"Hide History":"Show History",children:e.jsx(Qr,{size:14})})]}),ds?e.jsxs("div",{ref:It,onScroll:t=>{const r=t.currentTarget;r.scrollHeight-r.scrollTop-r.clientHeight<120?Pt.current=!0:r.scrollTop<gr.current-2&&(Pt.current=!1),gr.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(vo,{timeline:V,isStreaming:H,currentMode:v,activeSessionId:g,onContinue:ya}),y&&H&&!No(V)&&e.jsxs("div",{className:"flex items-center gap-3 text-[13px] text-gray-500 dark:text-gray-400",role:"status",children:[e.jsx(Pr,{size:6}),"Getting app knowledge from the available sources…"]})]}):e.jsx(Ro,{displayName:za,availableModes:F,currentMode:v,onPickMode:t=>{Rt(t),requestAnimationFrame(()=>{var r;return(r=ve.current)==null?void 0:r.focus()})},onPrefillPrompt:t=>{z(t),requestAnimationFrame(()=>{const r=ve.current;r&&(r.focus(),r.style.height="auto",r.style.height=`${r.scrollHeight}px`)})},isStreaming:H}),Ne&&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(Ci,{pending:Ne,queuedCount:pe.current.length,onAllow:()=>ps(!0,!1),onAlwaysAllow:()=>ps(!0,!0),onDeny:()=>ps(!1,!1)})})}),ie&&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=de.find(a=>a.value===ie.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:(vr=de.find(t=>t.value===ie.suggested))==null?void 0:vr.label})," request.",H?" Stop this answer and ask again there?":" Switch modes?"]}),b.current&&e.jsxs("button",{onClick:()=>Ua(ie.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 ",(jr=de.find(t=>t.value===ie.suggested))==null?void 0:jr.label]}),!H&&e.jsxs("button",{onClick:()=>Rt(ie.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 ",(wr=de.find(t=>t.value===ie.suggested))==null?void 0:wr.label]}),e.jsxs("button",{onClick:()=>Y(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 ",(Nr=de.find(t=>t.value===v))==null?void 0:Nr.label]})]})})}),e.jsx("input",{ref:rs,type:"file",multiple:!0,className:"hidden",accept:(Re==null?void 0:Re.accept)??zs.join(","),onChange:t=>{t.target.files&&yr(t.target.files),t.target.value=""}}),e.jsx(Ei,{enabled:(Kt==null?void 0:Kt.settings.tellAI)!==!1,texts:[U,...V.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 ${ar?"bg-brand-500/5":"bg-white dark:bg-white/[0.02]"}`,onDragOver:y?void 0:Wa,onDragLeave:y?void 0:Ka,onDrop:y?void 0:Ja,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[ar&&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(js,{size:16,className:"text-brand-400"}),e.jsx("span",{className:"text-sm text-brand-300 font-medium",children:"Drop files here to upload"})]}),H&&!y&&e.jsx("div",{className:"flex items-center pl-1 pb-3",children:e.jsx(Pr,{})}),v==="mobile"&&e.jsx(Bi,{}),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:[Ws&&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(Xn,{size:11})," ",y?"Answer from a source":"Add a source",xe.length>=Le&&e.jsxs("span",{className:"normal-case font-normal text-amber-600 dark:text-amber-400",children:["— ",Le," is the most per message"]})]}),qe.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(fe,{to:"/sources",className:"font-medium text-emerald-600 dark:text-emerald-400 hover:underline",children:"Sources"})," screen."]}),qe.map((t,r)=>e.jsxs("button",{type:"button",onMouseEnter:()=>ft(r),onClick:()=>Js(t),disabled:xe.length>=Le,className:`w-full flex items-center gap-2 px-3 py-2 text-left text-xs transition-colors disabled:opacity-40 ${r===Vt?"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(Is,{type:t.type,size:13,className:"text-emerald-600 dark:text-emerald-400"}),e.jsx("span",{className:`truncate font-medium ${r===Vt?"":"text-gray-900 dark:text-gray-100"}`,children:lt(t)}),e.jsx("span",{className:"ml-auto flex-shrink-0 text-[10px] text-gray-500 dark:text-gray-400",children:pa(t)})]},t.id))]}),be&&ct&&Be.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(Zn,{size:11})," Attach a test"]}),Be.map((t,r)=>e.jsxs("button",{type:"button",onMouseEnter:()=>ut(r),onClick:()=>Us(t),className:`w-full flex items-center gap-2 px-3 py-2 text-left text-xs transition-colors ${r===Fs?"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(ei,{size:13,className:"text-gray-500 flex-shrink-0"}),e.jsx("span",{className:"font-medium truncate flex-1",title:t.name,children:pi(t.name)}),e.jsx("span",{className:"text-[10px] text-gray-500 truncate max-w-[150px]",children:t.file.split(/[/\\]/).pop()})]},`${t.file}::${t.name}`))]}),Ys&&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(gs,{size:11})," Add a skill"]}),Me.length===0&&e.jsx("div",{className:"px-3 py-2.5 text-[11px] text-gray-500 dark:text-gray-400 leading-relaxed",children:gt.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 “",Yt,"”."]})}),Me.map((t,r)=>{const a=bt.includes(t.slug);return e.jsxs("button",{type:"button",onMouseEnter:()=>vt(r),onClick:()=>er(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===Xt?"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(gs,{size:13,className:"text-violet-500 flex-shrink-0"}),e.jsx("span",{className:`font-medium flex-shrink-0 max-w-[45%] truncate ${r===Xt?"":"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(ws,{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:()=>{Ee(!1),Gs("/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(Er,{size:12,className:"flex-shrink-0"}),e.jsx("span",{children:"Manage skills…"})]})})]}),(be&&Ae||bt.length>0||!y&&mt&&ye.length>0||xe.length>0)&&e.jsxs("div",{className:"px-4 pt-3 flex items-center gap-1.5 flex-wrap",children:[xe.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:y?`Answer only from this source (${t.id})`:`Source ${t.id} — the AI reads it with this message`,children:[e.jsx(Is,{type:t.type,size:11}),e.jsx("span",{className:"truncate max-w-[200px]",children:lt(t)}),e.jsx("button",{onClick:()=>Ze(r=>r.filter(a=>a.id!==t.id)),className:"opacity-60 hover:opacity-100 hover:text-red-400",title:"Remove","aria-label":`Remove ${lt(t)}`,children:e.jsx(Ie,{size:10})})]},t.id)),y&&xe.length>0&&e.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400","data-testid":"ask-sources-sticky",children:["Answering only from ",xe.length===1?"this source":"these sources"," until you remove ",xe.length===1?"it":"them"]}),be&&Ae&&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:`${Ae.name} — ${Ae.file}`,children:[e.jsx("span",{className:"opacity-70",children:"@"}),e.jsx("span",{className:"truncate max-w-[220px]",children:Ae.name}),e.jsx("button",{onClick:()=>Ye(null),className:"ml-0.5 opacity-60 hover:opacity-100 hover:text-red-400",title:"Remove",children:e.jsx(Ie,{size:11})})]}),bt.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(gs,{size:11}),e.jsx("span",{className:"truncate max-w-[160px]",children:tr(t)}),e.jsx("button",{onClick:()=>Xs(t),className:"opacity-60 hover:opacity-100 hover:text-red-400",title:"Remove",children:e.jsx(Ie,{size:10})})]},t)),!y&&mt&&ye.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(bs,{size:11}),e.jsx("span",{className:"truncate max-w-[160px]",children:qa(t)}),e.jsx("button",{onClick:()=>Zs(t),className:"opacity-60 hover:opacity-100 hover:text-red-400",title:"Remove",children:e.jsx(Ie,{size:10})})]},t))]}),e.jsx("textarea",{ref:ve,value:U,onChange:t=>{z(t.target.value);const r=t.target.selectionStart??t.target.value.length;if(be){const $=va(t.target.value,r);$!==null?(Fe(!0),_s($),ut(0)):Fe(!1)}const a=pt?Na(t.target.value,r):null;a!==null?(Te(!0),Hs(a),ft(0)):Te(!1);const d=Ta(t.target.value,r);d!==null?(Ee(!0),Vs(d),vt(0),Ra(/^\/[\w-]*$/.test(t.target.value.slice(0,r)))):Ee(!1);const u=t.target;u.style.height="auto",u.style.height=`${u.scrollHeight}px`},onKeyDown:Ha,placeholder:y?"Ask about this application… (# answer from a source)":Xe?"Ask for a report, chart or dashboard… (@ a test · / add a skill)":be?"Ask anything… (@ attach a test · # add a source · / add a skill)":"Ask anything… (# add a source · / add a skill)",rows:1,disabled:H,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"}}),be&&Ae&&!U.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:()=>{z(r),setTimeout(()=>{var a;return(a=ve.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))}),!y&&ts.length>0&&e.jsx("div",{className:"px-4 pb-2 flex items-center gap-1.5 flex-wrap",children:ts.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($o,{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:Ao(t.size)}),e.jsx("button",{onClick:()=>Ke(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 y?ht(!0):Xe?(t=rs.current)==null?void 0:t.click():et(r=>!r)},disabled:H||Ea,className:"p-1.5 rounded-lg text-gray-500 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors disabled:opacity-30",title:y?"Answer from Sources":Xe?"Upload a results file to report on (JUnit XML, CSV, JSON …)":"Attach files or Sources","aria-haspopup":y?"dialog":Xe?void 0:"menu","data-testid":"attach-button",children:e.jsx(Zr,{size:15})}),wa&&!y&&!Xe&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>et(!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;et(!1),(t=rs.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(js,{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:(Re==null?void 0:Re.summary)??Ds})]})]}),e.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{et(!1),ht(!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(ea,{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(po,{open:ja,onClose:()=>ht(!1),selected:xe,onAdd:Ze,askMode:y}),e.jsx(Mi,{value:v,onChange:Rt,disabled:H,availableModes:F}),!y&&e.jsx(zi,{value:Nt,onChange:Da}),!y&&mt&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>Zt(t=>{const r=!t;return r&&es(),r}),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${ye.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(bs,{size:13}),e.jsxs("span",{children:["MCP",ye.length>0?` (${ye.length})`:""]})]}),Ia&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Zt(!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"}),Qt.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."]}),Qt.map(t=>{const r=ye.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",d=t.status==="connected"?`${t.toolCount} tools`:t.status==="connecting"?"connecting…":t.status==="error"?"error":"not connected";return e.jsxs("button",{onClick:()=>Zs(t.id),title:t.status==="error"&&t.lastError?t.lastError:`${t.name} — ${d}`,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(bs,{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:d}),r&&e.jsx(ws,{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:()=>{Zt(!1),Gs("/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(Er,{size:12,className:"flex-shrink-0"}),e.jsx("span",{children:"Manage servers…"})]})})]})]})]}),!y&&e.jsx(Ui,{}),e.jsx("div",{className:"flex-1"}),Je==="testver"&&e.jsx(qi,{refreshSignal:H}),nr.length>0&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>ls(!os),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(zr,{provider:Je,size:13}),e.jsx("span",{className:"truncate",children:Je==="testver"?"Testver":$t||"Model"}),e.jsx(Se,{size:10,className:`flex-shrink-0 transition-transform ${os?"rotate-180":""}`})]}),os&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ls(!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:nr.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(zr,{provider:t.provider,size:14}),t.provider]}),t.models.map(r=>e.jsxs("button",{onClick:()=>{or(t.provider),ir(r),ls(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-left text-sm font-mono transition-colors ${r===$t&&t.provider===Je?"bg-brand-500/10 text-brand-300":"text-gray-400 hover:bg-brand-500/10 hover:text-gray-200"}`,children:[r===$t&&t.provider===Je&&e.jsx(Qe,{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))})]})]}),H?e.jsx("button",{onClick:kr,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(ti,{size:11,className:"fill-gray-900 text-gray-900",strokeWidth:0})}):e.jsx("button",{onClick:br,disabled:!U.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(qs,{size:15})})]})]})]})})]}),y&&!p&&e.jsx(Wi,{}),h&&!p&&(I?e.jsx(eo,{touched:q,refreshKey:_,onClose:()=>D(!1)}):e.jsx("button",{onClick:()=>D(!0),className:"flex-shrink-0 w-9 border-l border-black/[0.06] dark:border-white/[0.07] flex items-start justify-center pt-4 text-gray-500 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-100/60 dark:hover:bg-white/[0.03]","aria-label":"Show API Collections",title:"Show API Collections","data-testid":"api-panel-reopen",children:e.jsx("span",{className:"text-[12px] font-semibold tracking-wide [writing-mode:vertical-rl] rotate-180",children:"API Collections"})})),e.jsxs("div",{className:`flex-shrink-0 border-l border-white/5 bg-surface-1 transition-all duration-200 flex flex-col ${p?"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(Ms,{size:12,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-600"}),e.jsx("input",{value:ee,onChange:t=>ce(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",...F].map(t=>{const r=t==="all"?null:de.find(d=>d.value===t),a=E===t;return e.jsxs("button",{onClick:()=>re(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:[pr.length===0&&e.jsx("div",{className:"text-center py-8 text-sm text-gray-600",children:ee?"No matching sessions":"No session history yet"}),pr.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:()=>La(r.id),className:`group relative flex items-center px-3 py-2 mx-1.5 rounded-lg cursor-pointer transition-colors ${g===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:X===r.id?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:P,onChange:a=>Z(a.target.value),onClick:a=>a.stopPropagation(),onKeyDown:a=>{a.key==="Enter"&&xr(a),a.key==="Escape"&&W(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:xr,className:"p-0.5 text-emerald-400",children:e.jsx(dt,{size:12})})]}):e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(Pi,{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(Vr,{size:11,className:"text-amber-500 dark:text-amber-400"})}),e.jsx("div",{className:`text-sm truncate flex-1 min-w-0 ${g===r.id?"font-medium":""}`,children:r.title}),mr.has(r.id)&&e.jsx(fo,{run:mr.get(r.id)})]})}),X!==r.id&&e.jsx("div",{className:`absolute right-1.5 top-1/2 -translate-y-1/2 transition-opacity ${te===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(),J(te===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(si,{size:14})})})]},r.id))]},t.label))]})]}),te&&(()=>{const t=document.querySelector(`[data-menu-id="${te}"]`),r=t==null?void 0:t.getBoundingClientRect();if(!r)return null;const a=j.find(se=>se.id===te);if(!a)return null;const d=130,u=4,L=window.innerHeight-r.bottom<d+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:()=>J(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:L,children:[e.jsxs("button",{onClick:()=>{Ba(a.id),J(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:[T.has(a.id)?e.jsx(ri,{size:14}):e.jsx(ai,{size:14}),T.has(a.id)?"Unpin":"Pin to Top"]}),e.jsxs("button",{onClick:()=>{Fa(a.id,a.title),J(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(ni,{size:14})," Rename"]}),e.jsx("div",{className:"my-1 border-t border-white/10"}),e.jsxs("button",{onClick:()=>{Oa(a.id),J(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(ii,{size:12})," Delete"]})]})]})})(),e.jsx(ta,{open:!!ge,title:"Delete chat?",description:`Are you sure you want to delete "${(ge==null?void 0:ge.title)||"this chat"}"? This will permanently remove the conversation, all messages, and the full timeline history. This action cannot be undone.`,confirmLabel:"Delete",onCancel:()=>oe(null),onConfirm:_a})]})})})}function _r({what:s,error:n}){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:n.message})]})}const bo=s=>s.toolName.startsWith("api_")?e.jsx($s,{toolName:s.toolName,args:s.args,result:s.fullResult||s.result,variant:"chip"}):null,yo=s=>s.some(n=>n.toolName.startsWith("api_"))?e.jsx(so,{tools:s}):null;function ko(s){if(s.kind!=="tool"||s.phase!=="complete")return!1;const n=s.fullResult||s.result||"";if(s.toolName==="generate_dashboard"||s.toolName==="get_report")try{const l=JSON.parse(n);return(l==null?void 0:l.marker)==="TESTVER_DASHBOARD_SPEC"&&typeof l.id=="string"}catch{return!1}if(s.toolName==="build_report"||s.toolName==="generate_document")try{const l=JSON.parse(n);return!!(l!=null&&l.success&&(l!=null&&l.downloadUrl))}catch{return!1}return["api_request","api_send_collection_request","api_run_chain"].includes(s.toolName)?/^HTTP \d{3}/.test(n)||/^--- Request ---/.test(n)||s.toolName==="api_run_chain"&&n.startsWith("Chain:"):!1}const vo=i.memo(function({timeline:n,isStreaming:l,currentMode:x,activeSessionId:o,onContinue:m}){var k;const j=(k=n[n.length-1])==null?void 0:k.id;return e.jsx(e.Fragment,{children:jo(n).map((g,S,p)=>{var v;const N=(((v=g[0])==null?void 0:v.kind)==="user"?g[0].mode:void 0)??x,C=!(l&&S===p.length-1);return N==="ask"?wo(g).map(c=>{var y;return e.jsx(Fr,{entry:c,askMode:!0,askFeedback:c.kind==="text"&&C&&o?{answerId:`${o}:${c.id}`,sessionId:o,question:((y=g[0])==null?void 0:y.kind)==="user"?g[0].text:void 0}:void 0},c.id)}):$i(g,{toolOf:c=>c.kind==="tool"?c:null,diffOf:c=>c.kind==="diff"?c:null,isStandalone:ko,isTurnStart:c=>c.kind==="user",isInvisible:c=>c.kind==="text"&&!c.text.trim(),streaming:l}).map(c=>c.kind==="group"?e.jsx(Ii,{group:c,className:"!-mt-1.5 !-mb-2.5",trail:bo,summary:yo},c.id):c.kind==="changes"?e.jsx(Ai,{item:c},c.id):e.jsx(Fr,{entry:c.entry,onContinue:c.entry.kind==="error"&&c.entry.resumable&&!l&&c.entry.id===j?m:void 0},c.entry.id))})})});function jo(s){const n=[];for(const l of s)l.kind==="user"||n.length===0?n.push([l]):n[n.length-1].push(l);return n}function wo(s){let n=-1;s.forEach((x,o)=>{x.kind==="tool"&&(n=o)});const l=[];for(const[x,o]of s.entries()){if(o.kind==="tool"||o.kind==="loading"||o.kind==="text"&&x<n)continue;const m=l[l.length-1];if(o.kind==="text"&&(m==null?void 0:m.kind)==="text"){l[l.length-1]={...m,text:`${m.text.trimEnd()}
|
|
18
|
+
|
|
19
|
+
${o.text.trimStart()}`,done:o.done};continue}l.push(o)}return l}function No(s){for(let n=s.length-1;n>=0;n--){const l=s[n];if(l.kind==="user"||l.kind==="tool")return!1;if(l.kind==="text"&&l.text.trim())return!0}return!1}function So({entry:s}){const[n,l]=i.useState(()=>Date.now());if(i.useEffect(()=>{if(s.tone!=="retrying"||!s.retryAt)return;const o=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(o)},[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(Qe,{size:13,className:"flex-shrink-0"}),s.text]});const x=s.retryAt?Math.max(0,Math.ceil((s.retryAt-n)/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(Bt,{size:13,className:"flex-shrink-0 animate-spin"}),e.jsxs("span",{children:[s.text,x>0?` in ${x}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 Fr=i.memo(Co,(s,n)=>{var l,x,o,m,j,k;return s.entry===n.entry&&s.askMode===n.askMode&&s.onContinue===n.onContinue&&((l=s.askFeedback)==null?void 0:l.answerId)===((x=n.askFeedback)==null?void 0:x.answerId)&&((o=s.askFeedback)==null?void 0:o.sessionId)===((m=n.askFeedback)==null?void 0:m.sessionId)&&((j=s.askFeedback)==null?void 0:j.question)===((k=n.askFeedback)==null?void 0:k.question)});function Co({entry:s,askMode:n,askFeedback:l,onContinue:x}){var k;const[o,m]=i.useState(!1),{monacoTheme:j}=ia();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(Ut,{size:11,className:"text-gray-500"}),e.jsx("span",{className:"text-[11px] text-gray-500",children:s.text})]})});if(s.kind==="text"){const g=s.text.trimEnd();return g?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:n?e.jsx(no,{text:g,feedback:l}):e.jsx(Ss,{text:g})})}):null}if(s.kind==="tool"){const g=s.result||s.error||s.args,S=["api_request","api_send_collection_request","api_run_chain"].includes(s.toolName),p=s.fullResult||s.result||"",N=S&&p&&(/^HTTP \d{3}/.test(p)||/^--- Request ---/.test(p)),C=s.toolName==="api_run_chain"&&p&&p.startsWith("Chain:");if((s.toolName==="generate_dashboard"||s.toolName==="get_report")&&s.phase==="complete"){const v=s.fullResult||s.result||"";try{const c=JSON.parse(v);if((c==null?void 0:c.marker)==="TESTVER_DASHBOARD_SPEC"&&typeof c.id=="string")return e.jsx("div",{className:"my-2",children:e.jsx(Or,{fallback:y=>e.jsx(_r,{what:"dashboard",error:y}),children:e.jsx(io,{result:c})})},s.id)}catch{}}if((s.toolName==="build_report"||s.toolName==="generate_document")&&s.phase==="complete"){const v=s.fullResult||s.result||"";try{const c=JSON.parse(v);if(c!=null&&c.success&&(c!=null&&c.downloadUrl)){const y=/\.pdf(?:$|\?)/i.test(c.downloadUrl),h=typeof c.displayName=="string"?c.displayName:c.filename;return e.jsx("div",{className:"my-2",children:e.jsx(Or,{fallback:I=>e.jsx(_r,{what:"document",error:I}),children:y?e.jsx(oo,{url:c.downloadUrl,filename:h}):e.jsx(co,{url:c.downloadUrl,filename:h,size:typeof c.size=="string"?c.size:void 0})})},s.id)}}catch{}}if(N&&s.phase==="complete"){const v=p.split(`
|
|
20
|
+
`);let c="",y="",h="",I="";const R=v.indexOf("--- Request ---");if(R>=0&&v[R+1]){const K=v[R+1].match(/^(\w+)\s+(.+)$/);K&&(c=K[1].toUpperCase(),y=K[2])}const D=v.find(T=>T.startsWith("Name: "));D&&(h=D.replace("Name: ",""));const F=v.find(T=>T.startsWith("Resolved URL: ")),w=F?F.replace("Resolved URL: ",""):"",O=v.indexOf("--- Request Body ---"),G=v.findIndex(T=>/^HTTP \d{3}/.test(T)),ne=O>=0&&G>O?v.slice(O+1,G).join(`
|
|
21
|
+
`).trim():"",Y=(v.find(T=>/^HTTP \d{3}/.test(T))||"").match(/^HTTP (\d{3}) (.+)$/),b=Y?parseInt(Y[1]):0,M=Y?Y[2]:"",E=v.find(T=>T.startsWith("Duration:"))||"",re=E.match(/Duration: (\d+)ms/),X=E.match(/Size: (.+?)$/),W=re?re[1]:"",P=X?X[1]:"",Z=v.find(T=>T.startsWith("Validations:")),ee=v.indexOf("--- Body ---"),ce=v.indexOf("--- Headers ---"),te=ee>=0?v.slice(ee+1).join(`
|
|
22
|
+
`).trim():"",J=ce>=0&&ee>=0?v.slice(ce+1,ee-1).join(`
|
|
23
|
+
`).trim():"";if(!c&&s.args)try{const T=JSON.parse(s.args);c=(T.method||"").toUpperCase(),y=y||T.url||"",T.collection&&(I=T.request?`${T.collection} / ${T.request}`:T.collection)}catch{}const ge=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",oe={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"}),c&&e.jsx("span",{className:`px-2 py-0.5 rounded-md text-xs font-bold ${oe[c]||"text-gray-400 bg-gray-500/15"}`,children:c}),e.jsx("span",{className:"text-sm font-mono text-gray-300 truncate",children:y||s.toolName})]}),(h||I)&&e.jsxs("div",{className:"flex items-center gap-2 mt-1 ml-6",children:[h&&e.jsx("span",{className:"text-xs text-gray-400",children:h}),I&&e.jsx("span",{className:"text-xs text-gray-600",children:I})]}),w&&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:w})]})]}),ne&&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(_t,{text:ne})]}),e.jsx("div",{className:"max-h-[150px] overflow-auto",children:(()=>{let T=!1,K=ne;try{K=JSON.stringify(JSON.parse(ne),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:K}):e.jsx("pre",{className:"px-4 pb-2 text-xs font-mono text-gray-400 whitespace-pre-wrap break-words",children:K})})()})]}),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 ${ge}`,children:[b," ",M]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto text-xs text-gray-500",children:[W&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(di,{size:12,className:"text-gray-600"})," ",W,"ms"]}),P&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Mr,{size:12,className:"text-gray-600"})," ",P]})]})]}),Z&&e.jsx("div",{className:`px-4 py-1.5 text-xs font-medium border-b border-white/5 ${Z.includes("0/")?"text-red-400 bg-red-500/5":Z.startsWith("Validations: "+((k=Z.split("/")[1])==null?void 0:k.split(" ")[0]))?"text-emerald-400 bg-emerald-500/5":"text-cyan-400 bg-cyan-500/5"}`,children:Z}),J&&e.jsxs("div",{className:"border-b border-white/5",children:[e.jsxs("button",{onClick:()=>m(!o),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:[o?e.jsx(Se,{size:11}):e.jsx(Lt,{size:11}),e.jsx("span",{className:"font-medium",children:"Headers"}),e.jsxs("span",{className:"text-gray-600",children:["(",J.split(`
|
|
24
|
+
`).length,")"]})]}),o&&e.jsx("div",{className:"px-4 pb-2 space-y-0.5",children:J.split(`
|
|
25
|
+
`).filter(T=>T.includes(":")).map((T,K)=>{const V=T.indexOf(":"),f=T.slice(0,V).trim(),q=T.slice(V+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:[f,":"]}),e.jsx("span",{className:"text-gray-400 break-all",children:q})]},K)})})]}),te&&(()=>{let T=!1,K=te;try{K=JSON.stringify(JSON.parse(te),null,2),T=!0}catch{}const V=K.split(`
|
|
26
|
+
`).length,f=Math.min(Math.max(V*20,60),300),q=()=>{const _=new Blob([K],{type:"application/json"}),U=URL.createObjectURL(_),z=document.createElement("a");z.href=U,z.download=`response-${Date.now()}.json`,document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(U)};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(_t,{text:K}),e.jsxs("button",{onClick:q,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(Ht,{size:12})," Download"]})]})]}),T?e.jsx("div",{style:{height:`${f}px`},children:e.jsx(na,{value:K,language:"json",theme:j,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:K})})]})})(),e.jsx($s,{toolName:s.toolName,args:s.args,result:p})]})})}return C&&s.phase==="complete"?e.jsxs("div",{children:[e.jsx(Io,{result:p}),e.jsx("div",{className:"-mt-1 mb-2 max-w-[650px] rounded-b-xl overflow-hidden",children:e.jsx($s,{toolName:s.toolName,args:s.args,result:p})})]}):e.jsxs("div",{className:"my-0.5",children:[e.jsxs("button",{onClick:()=>g&&m(!o),className:`flex items-center gap-2 px-4 py-1.5 rounded-lg transition-colors text-left ${g?"hover:bg-white/[0.03] cursor-pointer":"cursor-default"}`,children:[s.phase==="start"&&e.jsx(Bt,{size:11,className:"text-blue-400 animate-spin flex-shrink-0"}),s.phase==="complete"&&e.jsx(Qe,{size:11,className:"text-emerald-400 flex-shrink-0"}),s.phase==="error"&&e.jsx(Ns,{size:11,className:"text-red-400 flex-shrink-0"}),s.phase==="denied"&&e.jsx(ci,{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}),g&&s.phase!=="start"&&e.jsx(Se,{size:10,className:`text-gray-600 transition-transform ${o?"rotate-180":""}`})]}),o&&g&&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(Ri,{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(Ns,{size:13,className:"text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("span",{children:[s.text,x&&e.jsxs("button",{onClick:x,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(Mr,{size:12})]})]})]})}):s.kind==="notice"?e.jsx(So,{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 $o({type:s,isImage:n}){return n?e.jsx(li,{size:10,className:"text-purple-400"}):s==="pdf"?e.jsx(Oe,{size:10,className:"text-red-400"}):s==="word"?e.jsx(Oe,{size:10,className:"text-blue-400"}):s==="excel"||s==="csv"?e.jsx(Dt,{size:10,className:"text-emerald-400"}):s==="code"?e.jsx(Oe,{size:10,className:"text-amber-400"}):e.jsx(Xr,{size:10,className:"text-gray-400"})}function Io({result:s}){const[n,l]=i.useState(new Set),{monacoTheme:x}=ia(),o=s.split(`
|
|
27
|
+
`),m=o.find(h=>h.startsWith("Chain:"))||"Chain Run",j=o.filter(h=>/^(?:\S{1,3}\s+)?Step \d+:/.test(h)),k=o.find(h=>h.startsWith("Result:"))||"",g=/Result: (\d+)\/(\d+)/.exec(k),S=!!g&&g[1]===g[2]&&Number(g[2])>0,p=o.indexOf("--- CHAIN_DETAILS_JSON ---");let N=[];if(p>=0&&o[p+1])try{N=JSON.parse(o[p+1])}catch{}const C=h=>{l(I=>{const R=new Set(I);return R.has(h)?R.delete(h):R.add(h),R})},v={GET:"text-emerald-400",POST:"text-blue-400",PUT:"text-amber-400",PATCH:"text-brand-400",DELETE:"text-red-400"},c={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"},y=N.length>0?N:j.map((h,I)=>{const R=h.match(/Step (\d+): (\w+) (.+?) → (\d{3}) (.+?) \((\d+)ms[^)]*\)/),D=h.startsWith("✅")?!0:h.startsWith("❌")?!1:void 0;return R?{step:parseInt(R[1]),method:R[2],url:R[3],status:parseInt(R[4]),statusText:R[5],duration:parseInt(R[6]),name:"",resolvedUrl:"",requestBody:"",responseBody:"",headers:{},error:"",extractedVars:{},validations:[],size:0,passed:D}: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 ${S?"bg-emerald-500/15":"bg-orange-500/15"}`,children:S?e.jsx(Qe,{size:16,className:"text-emerald-400"}):e.jsx(Ut,{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 ${S?"text-emerald-400":"text-orange-400"}`,children:k})]})]}),e.jsx("div",{className:"divide-y divide-white/[0.03]",children:y.map(h=>{const I=typeof h.passed=="boolean"?h.passed:h.status>=200&&h.status<400,R=n.has(h.step),D=h.responseBody||h.requestBody||Object.keys(h.headers||{}).length>0;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>D&&C(h.step),className:`w-full flex items-center gap-2 px-3 py-2.5 text-left transition-colors hover:bg-brand-500/5 ${D?"cursor-pointer":"cursor-default"} ${R?"bg-brand-500/5":""}`,children:[D&&(R?e.jsx(Se,{size:11,className:"text-gray-600 flex-shrink-0"}):e.jsx(Lt,{size:11,className:"text-gray-600 flex-shrink-0"})),!D&&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 ${I?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:h.step}),e.jsx("span",{className:`text-xs font-bold w-12 flex-shrink-0 ${v[h.method]||"text-gray-400"}`,children:h.method}),e.jsx("span",{className:"text-xs font-mono text-gray-400 truncate flex-1",children:h.url}),h.skipped?e.jsx("span",{className:"text-xs text-gray-500",children:"skipped"}):e.jsx("span",{className:`text-xs font-bold ${I?"text-emerald-400":"text-red-400"}`,children:h.status}),e.jsxs("span",{className:"text-xs text-gray-600 w-14 text-right",children:[h.skipped?"":`${h.duration}ms`,h.attempts>1?` ×${h.attempts}`:""]})]}),R&&D&&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 ${c[h.method]||"bg-gray-500/15"} ${v[h.method]||"text-gray-400"}`,children:h.method}),e.jsx("span",{className:"text-xs font-mono text-gray-300 truncate",children:h.url})]}),h.name&&e.jsx("div",{className:"text-[11px] text-gray-500 mt-0.5 ml-1",children:h.name}),h.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:h.resolvedUrl})]})]}),h.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(_t,{text:h.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(h.requestBody),null,2)}catch{return h.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 ${I?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:[h.status," ",h.statusText]}),e.jsxs("span",{className:"text-[11px] text-gray-600 ml-auto",children:[h.duration,"ms · ",h.size>0?h.size<1024?`${h.size}B`:`${(h.size/1024).toFixed(1)}KB`:"",h.attempts>1?` · ${h.attempts} attempts`:""]})]}),Array.isArray(h.failures)&&h.failures.length>0&&e.jsx("div",{className:"px-3 py-1.5 border-b border-white/[0.03] space-y-0.5",children:h.failures.map((F,w)=>e.jsxs("div",{className:"flex gap-1.5 text-[11px] text-red-400",children:[e.jsx(Ns,{size:11,className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words",children:F})]},w))}),Object.keys(h.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(h.headers).length,")"]}),e.jsx("div",{className:"px-3 pb-2 space-y-0.5",children:Object.entries(h.headers).map(([F,w])=>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:[F,":"]}),e.jsx("span",{className:"text-gray-400 break-all",children:String(w)})]},F))})]}),h.responseBody&&(()=>{let F=!1,w=h.responseBody;try{w=JSON.stringify(JSON.parse(h.responseBody),null,2),F=!0}catch{}const O=w.split(`
|
|
28
|
+
`).length,G=Math.min(Math.max(O*18,50),200),ne=()=>{const ie=new Blob([w],{type:"application/json"}),Y=URL.createObjectURL(ie),b=document.createElement("a");b.href=Y,b.download=`step-${h.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(_t,{text:w}),e.jsxs("button",{onClick:ne,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(Ht,{size:11})," Download"]})]})]}),F?e.jsx("div",{style:{height:`${G}px`},children:e.jsx(na,{value:w,language:"json",theme:x,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:w})})]})})(),Object.keys(h.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(h.extractedVars)})]}),h.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:h.error})]})]},h.step)})})]})})}function _t({text:s}){const[n,l]=i.useState(!1);return e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(s).catch(()=>{}),l(!0),setTimeout(()=>l(!1),1500)},className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs transition-colors ${n?"text-emerald-400 bg-emerald-500/10":"text-gray-600 hover:text-cyan-400 hover:bg-cyan-500/10"}`,title:n?"Copied!":"Copy response",children:n?e.jsxs(e.Fragment,{children:[e.jsx(ws,{size:12})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Yr,{size:12})," Copy"]})})}function Ao(s){return s<1024?`${s}B`:s<1024*1024?`${Math.round(s/1024)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}const Br=[{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:Ts,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:qs,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:oi,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:Gr,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 Ro({displayName:s,currentMode:n,onPickMode:l,onPrefillPrompt:x,isStreaming:o,availableModes:m}){const j=i.useMemo(()=>ho(),[]),k=i.useMemo(()=>m?Br.filter(g=>m.includes(g.id)):Br,[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:[j,", "]}),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:k.map((g,S)=>{const p=g.icon,N=g.id===n;return e.jsxs("button",{type:"button",onClick:()=>l(g.id),disabled:o,"aria-current":N?"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
|
+
${S>0?"border-t border-gray-100 dark:border-white/5":""}
|
|
31
|
+
${N?g.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
|
+
${N?"bg-white dark:bg-white/10":g.iconBg}`,children:e.jsx(p,{size:18,className:g.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:g.label})}),e.jsx("span",{className:"flex-1 min-w-0 text-[13.5px] leading-snug text-gray-500 dark:text-gray-400",children:g.description}),e.jsx("span",{className:"flex-shrink-0 hidden sm:flex flex-wrap justify-end items-center gap-1.5 max-w-[17rem]",children:g.capabilities.map(C=>e.jsx("span",{className:`text-[11.5px] px-2 py-0.5 rounded-full whitespace-nowrap ${g.chipClass}`,children:C},C))})]},g.id)})})]})})}function al(){return e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden h-full",children:e.jsx(go,{})})}export{al as AIPanel};
|