DefectRAG phase 5: incremental real-model application migration
Browse files
frontend/dist/assets/TeamWorkspace-Dcbl6qUO.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import{c as ae,p as Ee,r,s as we,a as x,R as e,w as ue,b as Se,d as _e,e as Ne,f as Ce,g as ke,v as Re,h as Ae,i as qe,L as De,S as xe,A as Le,j as Pe,k as Oe,l as ye,m as Me}from"./index-J0gQheIb.js";/**
|
| 2 |
+
* @license lucide-react v0.468.0 - ISC
|
| 3 |
+
*
|
| 4 |
+
* This source code is licensed under the ISC license.
|
| 5 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 6 |
+
*/const Ie=ae("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
|
| 7 |
+
* @license lucide-react v0.468.0 - ISC
|
| 8 |
+
*
|
| 9 |
+
* This source code is licensed under the ISC license.
|
| 10 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 11 |
+
*/const he=ae("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
|
| 12 |
+
* @license lucide-react v0.468.0 - ISC
|
| 13 |
+
*
|
| 14 |
+
* This source code is licensed under the ISC license.
|
| 15 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 16 |
+
*/const Ue=ae("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
| 17 |
+
* @license lucide-react v0.468.0 - ISC
|
| 18 |
+
*
|
| 19 |
+
* This source code is licensed under the ISC license.
|
| 20 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 21 |
+
*/const Fe=ae("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
|
| 22 |
+
* @license lucide-react v0.468.0 - ISC
|
| 23 |
+
*
|
| 24 |
+
* This source code is licensed under the ISC license.
|
| 25 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 26 |
+
*/const Te=ae("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
| 27 |
+
* @license lucide-react v0.468.0 - ISC
|
| 28 |
+
*
|
| 29 |
+
* This source code is licensed under the ISC license.
|
| 30 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 31 |
+
*/const je=ae("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
|
| 32 |
+
* @license lucide-react v0.468.0 - ISC
|
| 33 |
+
*
|
| 34 |
+
* This source code is licensed under the ISC license.
|
| 35 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 36 |
+
*/const ze=ae("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
|
| 37 |
+
* @license lucide-react v0.468.0 - ISC
|
| 38 |
+
*
|
| 39 |
+
* This source code is licensed under the ISC license.
|
| 40 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 41 |
+
*/const He=ae("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function ge(u){return{Open:["Open","Assigned","Cancelled"],Assigned:["Assigned","In Progress","Cancelled"],"In Progress":["In Progress","Resolved","Cancelled"],Resolved:["Resolved","Closed","In Progress","Cancelled"],Closed:[],Cancelled:[]}[u]||[]}function Be(u){const b=u.filter(i=>Ee(i)).sort((i,y)=>String(i.created_at).localeCompare(String(y.created_at))||i.id.localeCompare(y.id)).at(-1),s=b&&Ee(b);return(s==null?void 0:s.status)==="Reviewed"&&s.decision==="Reject"?b:null}function We(u,d=Date.now()){const b=u.filter(i=>!["Closed","Cancelled"].includes(i.state)),s=u.filter(i=>["Resolved","Closed"].includes(i.state)).map(i=>Date.parse(i.resolved_at)-Date.parse(i.created_at)).filter(i=>Number.isFinite(i)&&i>=0);return{open:b.filter(i=>i.state!=="Resolved").length,resolved:u.filter(i=>["Resolved","Closed"].includes(i.state)).length,overdue:b.filter(i=>i.state!=="Resolved"&&Date.parse(i.due_at)<d).length,averageResolutionHours:s.length?s.reduce((i,y)=>i+y,0)/s.length/36e5:null}}async function be(u,d,b){const{data:s,error:i}=await u.rpc(d,b);if(i)throw i;return s}function Ge({user:u,inspection:d,notes:b=[],onEvidence:s}){const i=r.useRef(0),[y,O]=r.useState([]),[T,p]=r.useState([]),[k,E]=r.useState(""),[H,w]=r.useState([]),[B,R]=r.useState([]),[j,A]=r.useState(""),[W,re]=r.useState(!1),[Y,S]=r.useState(""),[Z,M]=r.useState(""),[h,I]=r.useState(""),[de,m]=r.useState("Normal"),[q,z]=r.useState(""),[U,_]=r.useState(!1),[v,J]=r.useState(""),[X,n]=r.useState(""),[f,ne]=r.useState(0),[G,N]=r.useState(""),[L,le]=r.useState(""),[me,V]=r.useState(""),o=y.find(a=>a.id===k),C=Be(b),F=We(y);async function K(){const a=++i.current,t=await x(),l=await t.rpc("defectrag_ca_staff");if(a!==i.current)return;if(l.error||l.data!==!0)throw O([]),w([]),R([]),new Error("Approved staff with verified TOTP MFA are required for corrective actions.");const c=await Promise.all([t.from("corrective_actions").select("*").order("created_at",{ascending:!1}).limit(500),t.from("staff_members").select("user_id,display_name,revoked_at").is("revoked_at",null)]);if(a===i.current){if(c.some(g=>g.error))throw O([]),w([]),R([]),c.find(g=>g.error).error;O(c[0].data||[]),p(c[1].data||[]),A(""),ne(g=>g+1)}}r.useEffect(()=>{const a=we(K,{onState:t=>{t.error&&(A(t.error),O([]),w([]),R([]))}});return()=>{a.stop(),i.current++}},[u.id]),r.useEffect(()=>{const a=()=>{i.current++,O([]),p([]),w([]),R([]),K().catch(t=>A(t.message))};return window.addEventListener("defectrag-auth-change",a),()=>window.removeEventListener("defectrag-auth-change",a)},[u.id]),r.useEffect(()=>{_(!1),S("")},[d==null?void 0:d.id,C==null?void 0:C.id]),r.useEffect(()=>{n(""),J((o==null?void 0:o.state)||""),N((o==null?void 0:o.owner_id)||""),le((o==null?void 0:o.supervisor_id)||""),V("")},[o==null?void 0:o.id,o==null?void 0:o.version]),r.useEffect(()=>{let a=!0;if(w([]),R([]),!!o)return x().then(t=>Promise.all([t.from("corrective_action_history").select("*").eq("case_id",o.id).order("version"),t.from("corrective_action_events").select("id,case_id,version,kind,status,attempts,last_error,created_at").eq("case_id",o.id).order("created_at",{ascending:!1})])).then(t=>{if(a){if(t.some(l=>l.error))throw t.find(l=>l.error).error;w(t[0].data||[]),R(t[1].data||[])}}).catch(t=>{a&&A(t.message)}),()=>{a=!1}},[o==null?void 0:o.id,o==null?void 0:o.version,f]);async function pe(a){if(!W){re(!0),A("");try{await a(),await K(),ue()}catch(t){A(t.message||"Corrective action request failed.")}finally{re(!1)}}}const Q=a=>{var t;return((t=T.find(l=>l.user_id===a))==null?void 0:t.display_name)||"Former / unavailable staff"};return e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Corrective Actions"),e.createElement("p",null,"Human-confirmed defects, accountable ownership and traceable resolution.")),e.createElement("button",{className:"secondary",disabled:W,onClick:()=>pe(K)},"Refresh cases")),j&&e.createElement("div",{className:"error",role:"alert"},j),e.createElement("p",{className:"caption"},"Showing up to 500 accessible cases. Open: ",F.open," · Resolved / closed: ",F.resolved," · Overdue: ",F.overdue," · Average resolution: ",F.averageResolutionHours===null?"No resolved cases":F.averageResolutionHours.toFixed(1)+" hours",". Automation delivery is tracked separately from case status."),d&&!d.archived_at&&e.createElement(e.Fragment,null,e.createElement("h3",null,"Create from inspection ",d.id.slice(0,8)),C?e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),pe(async()=>{const t=await x(),l=await be(t,"defectrag_create_corrective_action",{p_inspection:d.id,p_review:C.id,p_confirmed:U,p_owner:Z,p_supervisor:h,p_priority:de,p_description:Y,p_due:new Date(q).toISOString()});E(l),S(""),_(!1)})}},e.createElement("label",{className:"field"},"Confirmed defect description",e.createElement("textarea",{required:!0,minLength:10,maxLength:2e3,value:Y,onChange:a=>S(a.target.value)})),e.createElement("label",{className:"field"},"Assigned owner",e.createElement("select",{required:!0,value:Z,onChange:a=>M(a.target.value)},e.createElement("option",{value:""},"Choose active staff"),T.map(a=>e.createElement("option",{key:a.user_id,value:a.user_id},a.display_name)))),e.createElement("label",{className:"field"},"Escalation supervisor",e.createElement("select",{required:!0,value:h,onChange:a=>I(a.target.value)},e.createElement("option",{value:""},"Choose active staff"),T.map(a=>e.createElement("option",{key:a.user_id,value:a.user_id},a.display_name)))),e.createElement("label",{className:"field"},"Priority",e.createElement("select",{value:de,onChange:a=>m(a.target.value)},["Low","Normal","High","Critical"].map(a=>e.createElement("option",{key:a},a)))),e.createElement("label",{className:"field"},"Due date (local time)",e.createElement("input",{type:"datetime-local",required:!0,value:q,onChange:a=>z(a.target.value)})),e.createElement("label",null,e.createElement("input",{type:"checkbox",checked:U,onChange:a=>_(a.target.checked)})," A human review confirms a defect requiring corrective action. An AI anomaly score alone is insufficient."),e.createElement("button",{className:"primary",disabled:W||!U},"Create corrective action")):e.createElement("p",{className:"note"},"Record a completed human review with a Reject disposition first. Creating a case also requires separate explicit defect confirmation.")),!d&&e.createElement("p",{className:"caption"},"Select a shared inspection and complete its human review to create a case."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Case"),e.createElement("th",null,"Status"),e.createElement("th",null,"Owner"),e.createElement("th",null,"Priority"),e.createElement("th",null,"Due"),e.createElement("th",null))),e.createElement("tbody",null,y.map(a=>e.createElement("tr",{key:a.id},e.createElement("td",null,a.id.slice(0,8)),e.createElement("td",null,a.state,!["Resolved","Closed","Cancelled"].includes(a.state)&&Date.parse(a.due_at)<Date.now()?" · Overdue":""),e.createElement("td",null,Q(a.owner_id)),e.createElement("td",null,a.priority),e.createElement("td",null,new Date(a.due_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>E(a.id)},"Details")))))),!y.length&&e.createElement("p",{className:"caption"},"No accessible corrective actions.")),o&&e.createElement("div",{className:"cloud-message"},e.createElement("div",{className:"section-title"},e.createElement("h3",null,"Case ",o.id.slice(0,8)," · ",o.state),e.createElement("button",{className:"text-button",onClick:()=>E("")},"Close details")),e.createElement("p",null,o.description),e.createElement("p",null,"Supervisor: ",Q(o.supervisor_id)," · Confirmed by: ",Q(o.confirmed_by)),e.createElement("button",{className:"secondary",onClick:()=>s(o.inspection_id)},"Review linked inspection and private evidence"),ge(o.state).length>0&&e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),pe(async()=>{const t=await x();await be(t,"defectrag_update_corrective_action",{p_id:o.id,p_version:o.version,p_state:v,p_note:X,p_owner:G,p_supervisor:L,p_due:me?new Date(me).toISOString():null}),n("")})}},e.createElement("label",{className:"field"},"Next state",e.createElement("select",{value:v,onChange:a=>J(a.target.value)},ge(o.state).map(a=>e.createElement("option",{key:a},a)))),e.createElement("label",{className:"field"},"Owner",e.createElement("select",{required:!0,value:G,onChange:a=>N(a.target.value)},e.createElement("option",{value:""},"Choose active staff"),T.map(a=>e.createElement("option",{key:a.user_id,value:a.user_id},a.display_name)))),e.createElement("label",{className:"field"},"Supervisor",e.createElement("select",{required:!0,value:L,onChange:a=>le(a.target.value)},e.createElement("option",{value:""},"Choose active staff"),T.map(a=>e.createElement("option",{key:a.user_id,value:a.user_id},a.display_name)))),e.createElement("label",{className:"field"},"Change due date (optional)",e.createElement("input",{type:"datetime-local",value:me,onChange:a=>V(a.target.value)})),e.createElement("label",{className:"field"},"Progress / resolution note",e.createElement("textarea",{required:!0,minLength:3,maxLength:2e3,value:X,onChange:a=>n(a.target.value)})),e.createElement("button",{className:"primary",disabled:W||!v},"Save auditable update")),e.createElement("h3",null,"Status history"),H.map(a=>e.createElement("p",{key:a.id},e.createElement("strong",null,a.state)," · ",Q(a.actor_id)," · ",new Date(a.created_at).toLocaleString(),e.createElement("br",null),a.note,a.snapshot&&e.createElement("small",null,e.createElement("br",null),"Owner: ",Q(a.snapshot.owner_id)," · Supervisor: ",Q(a.snapshot.supervisor_id)," · Due: ",new Date(a.snapshot.due_at).toLocaleString()))),e.createElement("h3",null,"Automation delivery"),e.createElement("p",{className:"caption"},"Queued does not mean sent. Dead / ambiguous deliveries need developer reconciliation; cases remain saved even when n8n is offline."),B.map(a=>e.createElement("p",{key:a.id},a.kind," · ",a.status," · attempts ",a.attempts,a.last_error?" · "+a.last_error:""))))}function Ve({client:u,user:d,onChange:b}){var X;const[s,i]=r.useState(null),[y,O]=r.useState([]),[T,p]=r.useState([]),[k,E]=r.useState(null),[H,w]=r.useState(""),[B,R]=r.useState(""),[j,A]=r.useState(""),[W,re]=r.useState(""),[Y,S]=r.useState(""),[Z,M]=r.useState(""),[h,I]=r.useState(!1),[de,m]=r.useState([]),[q,z]=r.useState([]),U=((X=window.DEFECTRAG_PUBLIC_CONFIG)==null?void 0:X.registrationEnabled)===!0;async function _(){if(!d){i(null),m([]),z([]);return}const n=await Se(u);i(n);const{data:f,error:ne}=await u.auth.mfa.listFactors();if(ne)throw ne;const G=(f.totp||[]).filter(N=>N.status==="verified");if(O(G),p((f.all||[]).filter(N=>N.factor_type==="totp"&&N.status==="unverified")),R(N=>{var L;return G.some(le=>le.id===N)?N:((L=G[0])==null?void 0:L.id)||""}),n.role==="developer"&&n.approved&&n.aal2){const[N,L]=await Promise.all([u.rpc("defectrag_access_directory"),u.rpc("defectrag_notification_status")]);if(N.error)throw N.error;if(L.error)throw L.error;m(N.data||[]),z(L.data||[])}else m([]),z([])}async function v(n){I(!0),M("");try{await n()}catch(f){M(f.message||"Security request failed.")}finally{I(!1)}}r.useEffect(()=>{let n=!0;return E(null),w(""),m([]),z([]),u&&d?_().catch(f=>{n&&M(f.message)}):i(null),()=>{n=!1}},[u,d==null?void 0:d.id]);async function J(){await Re(u,(k==null?void 0:k.id)||B,H),w(""),E(null),await _(),b(),M("Authenticator verified. Account approval still controls staff access.")}return e.createElement("div",{className:"section-gap"},e.createElement("h3",null,"Account access & security"),Z&&e.createElement("p",{className:"note",role:"status"},Z),d?e.createElement(e.Fragment,null,e.createElement("p",null,"Access: ",e.createElement("strong",null,s!=null&&s.revoked?"revoked":s!=null&&s.approved?"approved":(s==null?void 0:s.request_status)||"not requested")," · Authenticator: ",e.createElement("strong",null,s!=null&&s.aal2?"verified session":"session not verified")),e.createElement("button",{className:"secondary",disabled:h,onClick:()=>v(_)},"Refresh account status"),s&&!s.approved&&!s.revoked&&!s.request_status&&e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),v(async()=>{await Ne(u,j),await _(),M("Access request saved. Staff data remains unavailable until developer approval."),b()})}},e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:j,maxLength:80,onChange:n=>A(n.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:h||!s.registration_enabled||!s.email_verified},"Request staff access")),e.createElement("p",{className:"caption"},"Enrollment does not grant membership. Keep the authenticator available before mandatory MFA is enabled. Lost-factor recovery requires the workspace administrator; password reset does not remove MFA."),!k&&!y.length&&!T.length&&e.createElement("button",{className:"secondary",disabled:h,onClick:()=>v(async()=>E(await Ce(u)))},"Set up authenticator"),!k&&T.map(n=>e.createElement("p",{key:n.id,className:"caption"},"An unfinished enrollment exists. ",e.createElement("button",{className:"text-button",disabled:h,onClick:()=>v(async()=>{const{error:f}=await u.auth.mfa.unenroll({factorId:n.id});if(f)throw f;await _()})},"Cancel unfinished setup"))),k&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("p",null,"Scan this QR code in an authenticator. Keep it private and verify a code to finish enrollment."),e.createElement("img",{src:k.totp.qr_code,width:"200",height:"200",alt:"Private authenticator enrollment QR code"}),e.createElement("button",{className:"text-button",disabled:h,onClick:()=>v(async()=>{const{error:n}=await u.auth.mfa.unenroll({factorId:k.id});if(n)throw n;E(null),w("")})},"Cancel unfinished enrollment"))),(k||y.length>0)&&e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),v(J)}},!k&&e.createElement("label",{className:"field"},"Authenticator",e.createElement("select",{value:B,onChange:n=>R(n.target.value)},y.map(n=>e.createElement("option",{key:n.id,value:n.id},n.friendly_name||"Authenticator")))),e.createElement("label",{className:"field"},"Six-digit code",e.createElement("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,value:H,onChange:n=>w(n.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:h},"Verify authenticator")),(s==null?void 0:s.role)==="developer"&&s.approved&&s.aal2&&e.createElement(e.Fragment,null,e.createElement("h3",{className:"section-gap"},"Staff access management"),e.createElement("p",null,"Only pending requests can be approved or rejected. Revocation retains inspection history and blocks new protected operations."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Account"),e.createElement("th",null,"Status"),e.createElement("th",null,"Role"),e.createElement("th",null,"Action"))),e.createElement("tbody",null,de.map(n=>e.createElement("tr",{key:n.user_id},e.createElement("td",null,n.display_name,e.createElement("br",null),e.createElement("small",null,n.email)),e.createElement("td",null,n.status),e.createElement("td",null,n.role||"applicant"),e.createElement("td",null,n.user_id!==d.id&&(n.status==="pending"?["approve","reject"]:n.status==="approved"?["revoke"]:[]).map(f=>e.createElement("button",{key:f,className:"text-button",disabled:h,onClick:()=>{window.confirm(`${f[0].toUpperCase()+f.slice(1)} access for ${n.display_name}?`)&&v(async()=>{await ke(u,n,f),await _(),b(),M("Access decision saved. Notification delivery is tracked separately.")})}},f)))))))),e.createElement("h3",{className:"section-gap"},"Notification delivery"),e.createElement("p",{className:"caption"},"Queued messages wait while the notification service is offline. Sent means the mail provider accepted the message, not proof of inbox delivery."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Event"),e.createElement("th",null,"Delivery"),e.createElement("th",null,"Attempts"),e.createElement("th",null))),e.createElement("tbody",null,q.map(n=>e.createElement("tr",{key:n.id},e.createElement("td",null,n.kind),e.createElement("td",null,n.status),e.createElement("td",null,n.attempts),e.createElement("td",null,n.status==="dead"&&e.createElement("button",{className:"text-button",disabled:h,onClick:()=>v(async()=>{const{error:f}=await u.rpc("defectrag_retry_notification",{p_id:n.id});if(f)throw f;await _()})},"Retry delivery"))))))))):U?e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),v(async()=>{await _e(u,{email:W,password:Y,displayName:j,redirectTo:location.origin+location.pathname}),S(""),M("If registration is available, check the email for confirmation. Sign in afterward and submit the staff access request. Registration does not grant staff access.")})}},e.createElement("p",null,"Register an account to request staff access. Public Demo Mode does not require registration."),e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:j,onChange:n=>A(n.target.value),maxLength:80,autoComplete:"name",required:!0})),e.createElement("label",{className:"field"},"Email",e.createElement("input",{type:"email",value:W,onChange:n=>re(n.target.value),autoComplete:"email",required:!0})),e.createElement("label",{className:"field"},"New password",e.createElement("input",{type:"password",minLength:12,value:Y,onChange:n=>S(n.target.value),autoComplete:"new-password",required:!0})),e.createElement("button",{className:"secondary",disabled:h||!u},"Register account")):e.createElement("p",{className:"caption"},"Self-registration is not enabled. Existing approved accounts can sign in below. Public Demo Mode remains accessible."))}function Qe({onOpenInspection:u}){var Q,a;const d=r.useRef(0),b=r.useRef(null),s=r.useRef(0),i=r.useRef(null),y=r.useRef(0),[O,T]=r.useState({state:"refreshing"}),[p,k]=r.useState(null),[E,H]=r.useState(null),[w,B]=r.useState([]),[R,j]=r.useState({}),[A,W]=r.useState(""),[re,Y]=r.useState(""),[S,Z]=r.useState(!1),[M,h]=r.useState(""),[I,de]=r.useState(!1),[m,q]=r.useState(null),[z,U]=r.useState([]),[_,v]=r.useState([]),[J,X]=r.useState(""),[n,f]=r.useState(!1),[ne,G]=r.useState(""),[N,L]=r.useState(!1),[le,me]=r.useState(null),V=Ae();r.useEffect(()=>()=>{z.filter(t=>t.startsWith("blob:")).forEach(t=>URL.revokeObjectURL(t))},[z]),r.useEffect(()=>{i.current=m},[m]);const o=qe();async function C(t){Z(!0),h("");try{await t()}catch(l){h(l.message||"Team request failed.")}finally{Z(!1)}}async function F(){var ve;const t=++s.current,l=d.current,c=(ve=i.current)==null?void 0:ve.id,{client:g,staff:$}=await Me();let D=g.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);D=I?D.not("archived_at","is",null):D.is("archived_at",null);const[{data:se,error:ee},{data:ce,error:fe},P]=await Promise.all([D,g.from("staff_members").select("*"),c?g.from("staff_notes").select("*").eq("inspection_id",c).order("created_at"):{data:[]}]);if(ee)throw ee;if(fe)throw fe;if(P.error)throw P.error;if(t===s.current&&(H($),h(""),B(se||[]),j(Object.fromEntries((ce||[]).map(te=>[te.user_id,te.display_name]))),c&&l===d.current)){const te=(se||[]).find(ie=>ie.id===c);if(!te)d.current++,q(null),U([]),v([]);else if(q(te),v(P.data||[]),Date.now()-y.current>480*1e3)if(V){const ie=await ye(g,te);t===s.current&&l===d.current?(U(ie),y.current=Date.now()):ie.forEach(oe=>URL.revokeObjectURL(oe))}else{const ie=await Promise.all([te.image_path,te.heatmap_path].map(oe=>g.storage.from("team-inspections").createSignedUrl(oe,900)));if(t===s.current&&l===d.current){if(ie.some(oe=>oe.error))throw new Error("Shared image links could not refresh.");U(ie.map(oe=>oe.data.signedUrl)),y.current=Date.now()}}}}r.useEffect(()=>{if(!o)return;let t=!1,l;return x().then(async c=>{!t&&V&&me(c),l=c.auth.onAuthStateChange(($,D)=>{var se;if(!t){const ee=((se=D==null?void 0:D.user)==null?void 0:se.id)||null;b.current!==ee&&(d.current++,s.current++,q(null),B([]),U([]),v([]),H(null),b.current=ee),k((D==null?void 0:D.user)||null),$==="PASSWORD_RECOVERY"&&f(!0)}}).data.subscription;const{data:g}=await c.auth.getUser();t||k(g.user)}).catch(c=>{t||h(c.message)}),()=>{t=!0,d.current++,l==null||l.unsubscribe()}},[o]),r.useEffect(()=>{if(!p)return;const t=we(F,{onState:l=>{T(l),l.error&&(h(l.error),V&&(d.current++,B([]),j({}),q(null),U([]),v([]),H(null)))}});return()=>{t.stop(),s.current++}},[p==null?void 0:p.id,I]);async function K(t){const l=++d.current;await C(async()=>{const c=await x(),g=c.storage.from("team-inspections"),[{data:$,error:D},{data:se,error:ee}]=await Promise.all([c.from("shared_inspections").select("*").eq("id",t.id).single(),c.from("staff_notes").select("*").eq("inspection_id",t.id).order("created_at")]);if(D)throw D;if(ee)throw ee;const ce=V?await ye(c,$):null,fe=ce?ce.map(P=>({data:{signedUrl:P}})):await Promise.all([$.image_path,$.heatmap_path].map(P=>g.createSignedUrl(P,900)));if(fe.some(P=>P.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");if(l!==d.current){ce==null||ce.forEach(P=>URL.revokeObjectURL(P));return}i.current=$,y.current=Date.now(),q($),U(fe.map(P=>P.data.signedUrl)),v(se||[])})}async function pe(){await C(async()=>{const t=await x(),l=w.filter(c=>c.owner_id===p.id).map(c=>c.id);if(l.length){const{error:c}=await t.rpc("archive_team_inspections",{p_ids:l});if(c)throw c}d.current++,q(null),L(!1),await F(),ue()})}return o?e.createElement(e.Fragment,null,e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,e.createElement(He,{size:21})," Staff workspace"),e.createElement("p",null,"Signed-in staff share saved inspections and review notes. Live AI runs on the connected inspection backend.")),e.createElement("span",{className:"subtle-tag"},e.createElement(he,{size:13})," SUPABASE")),M&&e.createElement("div",{className:"error",role:"alert"},M),V&&le&&e.createElement(Ve,{key:(p==null?void 0:p.id)||"anonymous",client:le,user:p,onChange:()=>{ue(),p&&C(F)}}),p?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(xe,{size:18}),e.createElement("strong",null,(E==null?void 0:E.display_name)||p.email),e.createElement("span",{className:"subtle-tag"},(E==null?void 0:E.role)||"CHECKING MEMBERSHIP")),e.createElement("button",{className:"secondary",disabled:S,onClick:()=>C(F)},e.createElement(je,{size:16})," Refresh"),e.createElement("button",{className:"secondary",onClick:()=>C(async()=>{await(await x()).auth.signOut(),B([]),q(null),H(null)})},e.createElement(Te,{size:16})," Sign out")),n&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),C(async()=>{const l=await x(),{error:c}=await l.auth.updateUser({password:ne});if(c)throw c;G(""),f(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:ne,onChange:t=>G(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:S},"Save password")),e.createElement("div",{className:"team-toolbar"},e.createElement("span",{role:"status"},"Team Workspace · latest ",w.length," shared records · ",O.state==="synced"?"synchronized at "+new Date(O.at).toLocaleTimeString():O.state==="offline"?"offline; data may be stale":O.state==="stale"?"synchronization failed; data may be stale":"refreshing…"," · polls every 15 seconds"),(E==null?void 0:E.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{de(!I),q(null)}},e.createElement(Ie,{size:16}),I?"Active history":"Developer recovery"),!I&&e.createElement("button",{className:"secondary danger",disabled:S||!w.some(t=>t.owner_id===p.id),onClick:()=>L(!0)},e.createElement(Le,{size:16})," Archive my visible history")),N&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("strong",null,"Archive your visible records?"),e.createElement("p",null,"They will leave the shared active history. Original files and conversations remain recoverable by a developer. Other staff members’ records will stay active."),e.createElement("div",{className:"button-row"},e.createElement("button",{className:"primary",disabled:S,onClick:pe},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>L(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Inspection"),e.createElement("th",null,"Product"),e.createElement("th",null,"Result"),e.createElement("th",null,"Shared by"),e.createElement("th",null,"Saved"),e.createElement("th",null))),e.createElement("tbody",null,w.map(t=>{var l;return e.createElement("tr",{key:t.id},e.createElement("td",null,e.createElement("strong",null,t.id.slice(0,8))),e.createElement("td",null,t.payload.category),e.createElement("td",null,e.createElement("span",{className:"badge "+((l=t.payload.verdict)==null?void 0:l.toLowerCase())},t.payload.verdict)),e.createElement("td",null,R[t.owner_id]||"Staff member"),e.createElement("td",null,new Date(t.created_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>K(t)},"Review"),I&&(E==null?void 0:E.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:S,onClick:()=>C(async()=>{const c=await x(),{error:g}=await c.rpc("restore_team_inspections",{p_ids:[t.id]});if(g)throw g;await F(),ue()})},"Restore")))}))),!w.length&&e.createElement("div",{className:"empty"},e.createElement(he,{size:30}),e.createElement("p",null,I?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with staff.")))):e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),C(async()=>{const l=await x(),{error:c}=await l.auth.signInWithPassword({email:A,password:re});if(c)throw c;Y("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:A,onChange:t=>W(t.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:re,onChange:t=>Y(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:S},S?e.createElement(De,{className:"spin",size:17}):e.createElement(Fe,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!A||S,onClick:()=>C(async()=>{const t=await x(),{error:l}=await t.auth.resetPasswordForEmail(A,{redirectTo:location.origin+location.pathname});if(l)throw l;h("Password reset requested. Check your email.")})},"Reset password"),e.createElement("p",{className:"caption"},V?"Registration alone does not grant staff access. Approved staff complete any required authenticator verification.":"Accounts must be invited and approved by your workspace developer. Signing up alone does not grant staff access."))),p&&m&&e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Shared inspection · ",m.id.slice(0,8)),e.createElement("p",null,"Saved snapshot from ",R[m.owner_id]||"a colleague",". This page does not run a new prediction.")),e.createElement("div",{className:"button-row"},u&&!m.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>u(m)},"Open inspection & assistant"),e.createElement("button",{className:"text-button",onClick:()=>{d.current++,q(null)}},"Close"))),e.createElement("div",{className:"shared-images"},z.map((t,l)=>e.createElement("img",{key:t,src:t,alt:l?"Saved anomaly heatmap":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED MEASUREMENTS"),e.createElement("span",null,m.payload.verdict," · score ",Number(m.payload.score).toFixed(5)," · threshold ",Number(m.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Recorded evidence"),(Q=m.conversation)!=null&&Q.length?m.conversation.map((t,l)=>e.createElement("p",{className:"cloud-message",key:l},e.createElement("strong",null,t.role==="user"?"Inspector":"Evidence Assistant",": "),t.question||t.answer)):e.createElement("p",{className:"caption"},"No conversation was included when this inspection was shared."),!m.archived_at&&e.createElement(Pe,{key:m.id+String(_.length),current:_.map(t=>Ee(t,R)).filter(Boolean).at(-1),disabled:S,onSave:async t=>{const l=await x(),{error:c}=await l.from("staff_notes").insert({inspection_id:m.id,author_id:p.id,body:Oe(t.status,t.decision,t.note)});if(c)throw c;await K(m),ue()}}),e.createElement("h3",{className:"section-gap"},"Staff review notes"),_.filter(t=>!Ee(t,R)).map(t=>e.createElement("div",{className:"cloud-message",key:t.id},e.createElement("strong",null,R[t.author_id]||"Staff member"),e.createElement("p",null,t.body),e.createElement("small",null,new Date(t.created_at).toLocaleString()))),!m.archived_at&&e.createElement("form",{className:"question-form",onSubmit:t=>{t.preventDefault(),C(async()=>{const l=await x(),{error:c}=await l.from("staff_notes").insert({inspection_id:m.id,author_id:p.id,body:J.trim()});if(c)throw c;X(""),await K(m),ue()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a review note for your colleagues…",value:J,onChange:t=>X(t.target.value)}),e.createElement("button",{className:"primary",disabled:S||!J.trim()},e.createElement(ze,{size:16})," Add note"))),p&&E&&((a=window.DEFECTRAG_PUBLIC_CONFIG)==null?void 0:a.correctiveActionsEnabled)===!0&&e.createElement(Ge,{key:p.id,user:p,inspection:m,notes:_,onEvidence:t=>K({id:t})})):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(he,{size:32})),e.createElement("span",{className:"eyebrow"},"TEAM WORKSPACE"),e.createElement("h2",null,"One shared view of inspection."),e.createElement("p",null,"The staff workspace is ready to connect to your own Supabase project. No cloud project or account has been created for you."),e.createElement("div",{className:"setup-grid"},[["01","Create a free project","Use your Supabase account and select an eligible Free plan."],["02","Set up staff access","Run the supplied schema, add your developer account and invite colleagues."],["03","Connect this dashboard","Add the project URL and publishable key to config.js, then reload."]].map(([t,l,c])=>e.createElement("div",{key:t},e.createElement("b",null,t),e.createElement("h3",null,l),e.createElement("p",null,c)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Open Supabase ",e.createElement(Ue,{size:16})),e.createElement("p",{className:"caption"},"Setup files: deployment/SUPABASE_SETUP.md and deployment/supabase.sql. Never place a service-role key in the browser. Local inspection works without cloud setup."))}export{Qe as default};
|
frontend/dist/assets/index-J0gQheIb.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/dist/index.html
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#132e32"/><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-
|
| 2 |
<link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.css">
|
| 3 |
</head><body><div id="root"></div></body></html>
|
|
|
|
| 1 |
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#132e32"/><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-J0gQheIb.js"></script>
|
| 2 |
<link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.css">
|
| 3 |
</head><body><div id="root"></div></body></html>
|