Wizzas commited on
Commit
13af0e1
·
verified ·
1 Parent(s): 4946331

Clarify workspace context and preserve controls during polling

Browse files
frontend/dist/assets/TeamWorkspace-Bj0Iv4wc.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{c as v,r as n,a as he,b as u,s as fe,R as e,L as Ee,S as ye,A as ve,d as we,e as ge,w as z,p as se,f as be}from"./index-DCyhJBD5.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 Se=v("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 V=v("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 ke=v("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 Ne=v("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 _e=v("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 Ce=v("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 Re=v("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 Ae=v("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 Me({onOpenInspection:G}){var re;const d=n.useRef(0),K=n.useRef(null),k=n.useRef(0),U=n.useRef(null),D=n.useRef(0),[R,le]=n.useState({state:"refreshing"}),[o,Y]=n.useState(null),[c,O]=n.useState(null),[N,T]=n.useState([]),[_,ce]=n.useState({}),[A,oe]=n.useState(""),[Z,J]=n.useState(""),[m,Q]=n.useState(!1),[X,S]=n.useState(""),[w,ie]=n.useState(!1),[s,h]=n.useState(null),[de,x]=n.useState([]),[I,M]=n.useState([]),[j,$]=n.useState(""),[me,ee]=n.useState(!1),[te,ae]=n.useState(""),[ue,F]=n.useState(!1);n.useEffect(()=>{U.current=s},[s]);const H=he();async function p(t){Q(!0),S("");try{await t()}catch(a){S(a.message||"Team request failed.")}finally{Q(!1)}}async function q(){var ne;const t=++k.current,a=d.current,r=(ne=U.current)==null?void 0:ne.id,{client:i,staff:f}=await be();let l=i.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);l=w?l.not("archived_at","is",null):l.is("archived_at",null);const[{data:g,error:E},{data:L,error:y},W]=await Promise.all([l,i.from("staff_members").select("*"),r?i.from("staff_notes").select("*").eq("inspection_id",r).order("created_at"):{data:[]}]);if(E)throw E;if(y)throw y;if(W.error)throw W.error;if(t===k.current&&(O(f),S(""),T(g||[]),ce(Object.fromEntries((L||[]).map(b=>[b.user_id,b.display_name]))),r&&a===d.current)){const b=(g||[]).find(P=>P.id===r);if(!b)d.current++,h(null),x([]),M([]);else if(h(b),M(W.data||[]),Date.now()-D.current>480*1e3){const P=await Promise.all([b.image_path,b.heatmap_path].map(C=>i.storage.from("team-inspections").createSignedUrl(C,900)));if(t===k.current&&a===d.current){if(P.some(C=>C.error))throw new Error("Shared image links could not refresh.");x(P.map(C=>C.data.signedUrl)),D.current=Date.now()}}}}n.useEffect(()=>{if(!H)return;let t=!1,a;return u().then(async r=>{a=r.auth.onAuthStateChange((f,l)=>{var g;if(!t){const E=((g=l==null?void 0:l.user)==null?void 0:g.id)||null;K.current!==E&&(d.current++,k.current++,h(null),T([]),x([]),M([]),O(null),K.current=E),Y((l==null?void 0:l.user)||null),f==="PASSWORD_RECOVERY"&&ee(!0)}}).data.subscription;const{data:i}=await r.auth.getUser();t||Y(i.user)}).catch(r=>{t||S(r.message)}),()=>{t=!0,d.current++,a==null||a.unsubscribe()}},[H]),n.useEffect(()=>{if(!o)return;const t=fe(q,{onState:a=>{le(a),a.error&&S(a.error)}});return()=>{t.stop(),k.current++}},[o==null?void 0:o.id,w]);async function B(t){const a=++d.current;await p(async()=>{const r=await u(),i=r.storage.from("team-inspections"),[{data:f,error:l},{data:g,error:E}]=await Promise.all([r.from("shared_inspections").select("*").eq("id",t.id).single(),r.from("staff_notes").select("*").eq("inspection_id",t.id).order("created_at")]);if(l)throw l;if(E)throw E;const L=await Promise.all([f.image_path,f.heatmap_path].map(y=>i.createSignedUrl(y,900)));if(L.some(y=>y.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");a===d.current&&(U.current=f,D.current=Date.now(),h(f),x(L.map(y=>y.data.signedUrl)),M(g||[]))})}async function pe(){await p(async()=>{const t=await u(),a=N.filter(r=>r.owner_id===o.id).map(r=>r.id);if(a.length){const{error:r}=await t.rpc("archive_team_inspections",{p_ids:a});if(r)throw r}d.current++,h(null),F(!1),await q(),z()})}return H?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(Ae,{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(V,{size:13})," SUPABASE")),X&&e.createElement("div",{className:"error",role:"alert"},X),o?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(ye,{size:18}),e.createElement("strong",null,(c==null?void 0:c.display_name)||o.email),e.createElement("span",{className:"subtle-tag"},(c==null?void 0:c.role)||"CHECKING MEMBERSHIP")),e.createElement("button",{className:"secondary",disabled:m,onClick:()=>p(q)},e.createElement(Ce,{size:16})," Refresh"),e.createElement("button",{className:"secondary",onClick:()=>p(async()=>{await(await u()).auth.signOut(),T([]),h(null),O(null)})},e.createElement(_e,{size:16})," Sign out")),me&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),p(async()=>{const a=await u(),{error:r}=await a.auth.updateUser({password:te});if(r)throw r;ae(""),ee(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:te,onChange:t=>ae(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:m},"Save password")),e.createElement("div",{className:"team-toolbar"},e.createElement("span",{role:"status"},"Team Workspace · latest ",N.length," shared records · ",R.state==="synced"?"synchronized at "+new Date(R.at).toLocaleTimeString():R.state==="offline"?"offline; data may be stale":R.state==="stale"?"synchronization failed; data may be stale":"refreshing…"," · polls every 15 seconds"),(c==null?void 0:c.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{ie(!w),h(null)}},e.createElement(Se,{size:16}),w?"Active history":"Developer recovery"),!w&&e.createElement("button",{className:"secondary danger",disabled:m||!N.some(t=>t.owner_id===o.id),onClick:()=>F(!0)},e.createElement(ve,{size:16})," Archive my visible history")),ue&&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:m,onClick:pe},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>F(!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,N.map(t=>{var a;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 "+((a=t.payload.verdict)==null?void 0:a.toLowerCase())},t.payload.verdict)),e.createElement("td",null,_[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:()=>B(t)},"Review"),w&&(c==null?void 0:c.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:m,onClick:()=>p(async()=>{const r=await u(),{error:i}=await r.rpc("restore_team_inspections",{p_ids:[t.id]});if(i)throw i;await q(),z()})},"Restore")))}))),!N.length&&e.createElement("div",{className:"empty"},e.createElement(V,{size:30}),e.createElement("p",null,w?"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(),p(async()=>{const a=await u(),{error:r}=await a.auth.signInWithPassword({email:A,password:Z});if(r)throw r;J("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:A,onChange:t=>oe(t.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:Z,onChange:t=>J(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:m},m?e.createElement(Ee,{className:"spin",size:17}):e.createElement(Ne,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!A||m,onClick:()=>p(async()=>{const t=await u(),{error:a}=await t.auth.resetPasswordForEmail(A,{redirectTo:location.origin+location.pathname});if(a)throw a;S("Password reset requested. Check your email.")})},"Reset password"),e.createElement("p",{className:"caption"},"Accounts must be invited and approved by your workspace developer. Signing up alone does not grant staff access."))),o&&s&&e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Shared inspection · ",s.id.slice(0,8)),e.createElement("p",null,"Saved snapshot from ",_[s.owner_id]||"a colleague",". This page does not run a new prediction.")),e.createElement("div",{className:"button-row"},G&&!s.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>G(s)},"Open inspection & assistant"),e.createElement("button",{className:"text-button",onClick:()=>{d.current++,h(null)}},"Close"))),e.createElement("div",{className:"shared-images"},de.map((t,a)=>e.createElement("img",{key:t,src:t,alt:a?"Saved anomaly heatmap":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED MEASUREMENTS"),e.createElement("span",null,s.payload.verdict," · score ",Number(s.payload.score).toFixed(5)," · threshold ",Number(s.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Recorded evidence"),(re=s.conversation)!=null&&re.length?s.conversation.map((t,a)=>e.createElement("p",{className:"cloud-message",key:a},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."),!s.archived_at&&e.createElement(we,{key:s.id+String(I.length),current:I.map(t=>se(t,_)).filter(Boolean).at(-1),disabled:m,onSave:async t=>{const a=await u(),{error:r}=await a.from("staff_notes").insert({inspection_id:s.id,author_id:o.id,body:ge(t.status,t.decision,t.note)});if(r)throw r;await B(s),z()}}),e.createElement("h3",{className:"section-gap"},"Staff review notes"),I.filter(t=>!se(t,_)).map(t=>e.createElement("div",{className:"cloud-message",key:t.id},e.createElement("strong",null,_[t.author_id]||"Staff member"),e.createElement("p",null,t.body),e.createElement("small",null,new Date(t.created_at).toLocaleString()))),!s.archived_at&&e.createElement("form",{className:"question-form",onSubmit:t=>{t.preventDefault(),p(async()=>{const a=await u(),{error:r}=await a.from("staff_notes").insert({inspection_id:s.id,author_id:o.id,body:j.trim()});if(r)throw r;$(""),await B(s),z()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a review note for your colleagues…",value:j,onChange:t=>$(t.target.value)}),e.createElement("button",{className:"primary",disabled:m||!j.trim()},e.createElement(Re,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(V,{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,a,r])=>e.createElement("div",{key:t},e.createElement("b",null,t),e.createElement("h3",null,a),e.createElement("p",null,r)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Open Supabase ",e.createElement(ke,{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{Me as default};
frontend/dist/assets/index-DCyhJBD5.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-Bi4p7Ozq.js"></script>
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-DCyhJBD5.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.css">
3
  </head><body><div id="root"></div></body></html>