@rizom/brain 0.2.0-alpha.867 → 0.2.0-alpha.868
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/dist/brain.js +4 -4
- package/dist/chunks/{app-y0wryc02.js → app-esb1afkk.js} +2 -2
- package/dist/chunks/{index-04sg3s72.js → index-f6mq05th.js} +3 -3
- package/dist/chunks/{index-04sg3s72.js.map → index-f6mq05th.js.map} +1 -1
- package/dist/chunks/{index-ryvvrpek.js → index-n569mach.js} +2 -2
- package/dist/chunks/{package-6eq3kjmw.js → package-hdjj3mg3.js} +3 -3
- package/dist/chunks/{package-6eq3kjmw.js.map → package-hdjj3mg3.js.map} +1 -1
- package/dist/model.js +4 -4
- package/dist/model.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/ui/{studio-app-djzsg9kt.js → studio-app-wgdxs5zd.js} +1 -1
- package/dist/ui/studio-asset-manifest.json +5 -5
- package/dist/ui/studio-chunks/studio-chat-workspace-5kxn0f0c.js +3 -0
- package/dist/ui/studio-chunks/{studio-chat-workspace-vbgtq56y.js.map → studio-chat-workspace-5kxn0f0c.js.map} +3 -3
- package/package.json +1 -1
- package/dist/ui/studio-chunks/studio-chat-workspace-vbgtq56y.js +0 -3
- /package/dist/chunks/{app-y0wryc02.js.map → app-esb1afkk.js.map} +0 -0
- /package/dist/chunks/{index-ryvvrpek.js.map → index-n569mach.js.map} +0 -0
- /package/dist/ui/{studio-app-djzsg9kt.js.map → studio-app-wgdxs5zd.js.map} +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{A as st,B as Je,Ba as ct,C as ze,aa as it,ba as at,ca as ne,da as ue,ea as rt,fa as lt}from"./main-6d8fnk33.js";import{Ea as n,Fa as i,Ga as Le,Ha as q,Ia as ut,Ja as mt,Ka as ft,La as ht,Ma as pt,Na as vt,Oa as _,Pa as gt,Qa as yt}from"./main-wv4cygtj.js";import{Mb as Ve,_a as et,bb as Ke,gc as dt,hb as Oe,kb as de,mb as Fe}from"./main-yfr70kka.js";import"./main-eakaz9w9.js";import{Gc as X}from"./main-a91pxdfw.js";import{Nc as H,Pc as D,Qc as Ee,Rc as Ge,Uc as Be,Vc as He,Xc as qe,de as z,kd as tt,ld as nt,wd as Ae,xd as Ne,zd as xe}from"./main-2dnw093e.js";import{Pf as ot}from"./main-4qxa4jpx.js";import{Qf as L}from"./main-2vaawyz9.js";import{wg as w}from"./main-s8r820px.js";var Q=w(L(),1);var O=w(H(),1),qt={stopped:"Stopped",disconnected:"Connection lost",failed:"Response failed"};function ke(e){let{interrupted:t}=e;return O.jsxDEV("section",{className:i("studio-chat-interruption",n.empty),role:t.kind==="stopped"?"status":"alert","aria-atomic":"true",children:[O.jsxDEV("strong",{children:qt[t.kind]},void 0,!1,void 0,this),O.jsxDEV("p",{children:"Any received text is kept here. Stopping the response does not undo completed actions; the server may still be working."},void 0,!1,void 0,this),t.detail&&O.jsxDEV("p",{children:t.detail},void 0,!1,void 0,this),t.retry&&O.jsxDEV(O.Fragment,{children:[O.jsxDEV("p",{children:"Sending again may repeat completed actions. Review the request before sending."},void 0,!1,void 0,this),O.jsxDEV(D,{type:"button",variant:"ghost",disabled:e.restoreBlocked||e.draftPending,onClick:()=>{if(!t.retry||e.draftPending)return;e.onRestore(t.retry)},children:"Review retry in composer"},void 0,!1,void 0,this),e.draftPending&&O.jsxDEV("p",{children:"Your composer draft is unchanged. Send or clear it before restoring this request."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Z=w(L(),1);var N=w(H(),1);function we(e){return N.jsxDEV("aside",{className:i("studio-chat-context",n.contextBody),tabIndex:0,"aria-label":"Conversation sources and attachments",children:N.jsxDEV("div",{className:i("studio-chat-context-list",n.cards),children:[e.session?.contextHandoff?N.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[N.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Linked context"},void 0,!1,void 0,this),N.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,z.section),children:e.session.contextHandoff.titleSeed},void 0,!1,void 0,this),N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[e.session.contextHandoff.sourceId," ·"," ",e.session.contextHandoff.itemId]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null,e.cards.length===0&&e.progress.length===0?N.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"No sources or attachments in this conversation yet."},void 0,!1,void 0,this):null,e.cards.map((t,o)=>N.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[N.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:t.kind==="sources"?"Sources":"Artifact"},void 0,!1,void 0,this),N.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,z.section),children:t.kind==="sources"?t.title??`${t.sources.length} consulted`:t.kind==="attachment"?t.title:"Conversation context"},void 0,!1,void 0,this),t.kind==="sources"?N.jsxDEV(N.Fragment,{children:[N.jsxDEV("ul",{children:t.sources.slice(0,5).map((s)=>N.jsxDEV("li",{children:s.title??s.source},s.id,!1,void 0,this))},void 0,!1,void 0,this),t.sources.length>5?N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[t.sources.length-5," more sources in the conversation."]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this):t.kind==="attachment"&&t.description?N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.description},void 0,!1,void 0,this):null]},`${t.kind}-${t.id}-${o}`,!0,void 0,this)),e.progress.map((t,o)=>N.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[N.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Durable job"},void 0,!1,void 0,this),N.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,z.section),children:t.operationTarget??t.operationType},void 0,!1,void 0,this),N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.message??t.status},void 0,!1,void 0,this)]},`${t.type}-${o}`,!0,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Ot=86400000;function Ie(e,t){return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(e)}function Lt(e,t){return Math.round((Date.parse(t)-Date.parse(e))/Ot)}function De(e,t,o){let s=Lt(Ie(e,o),Ie(t,o));if(s<=0)return"Today";if(s===1)return"Yesterday";if(s<7)return"This week";return"Earlier"}function Re(e,t,o){let s=[...e].sort((r,a)=>a.lastActiveAt.localeCompare(r.lastActiveAt));return["Today","Yesterday","This week","Earlier"].map((r)=>({label:r,sessions:s.filter((a)=>De(Date.parse(a.lastActiveAt),t,o)===r)})).filter((r)=>r.sessions.length>0)}function le(e){let t=e.contextHandoff;if(t?.sourceId!==Ne)return null;let o=xe(t.itemId);return o?{...o,title:t.titleSeed}:null}function Te(e,t,o){let s=le(e);if(s)return{kind:"entry",text:s.title};let r=Date.parse(e.lastActiveAt);if(Number.isNaN(r))return{kind:"time",text:""};let a=Math.floor((t-r)/60000),l=De(r,t,o);if(l==="Today"){if(a<1)return{kind:"time",text:"Just now"};if(a<60)return{kind:"time",text:`${a} ${a===1?"minute":"minutes"} ago`};let f=Math.floor(a/60);return{kind:"time",text:`${f} ${f===1?"hour":"hours"} ago`}}if(l==="Yesterday")return{kind:"time",text:"Yesterday"};if(l==="This week")return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:o}).format(r)};return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"short",timeZone:o}).format(r)}}var P=w(L(),1);var A=w(H(),1);function Pe(e){let[t,o]=P.useState(!1),[s,r]=P.useState(e.title),[a,l]=P.useState(!1),[f,d]=P.useState(null),m=P.useRef(!1),p=P.useRef(!1),b=P.useRef(null);P.useEffect(()=>{if(t)b.current?.focus()},[t]);let g=P.useRef(null);P.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);let I=()=>{o(!1),d(null),requestAnimationFrame(()=>g.current?.querySelector("button")?.focus())},y=async()=>{if(p.current||!s.trim())return;p.current=!0,l(!0),d(null);try{if(await e.onRename(s.trim()),m.current)I()}catch(c){if(m.current)d(Ae(c,"Rename failed. Your proposed title is kept.")||"Rename failed. Your proposed title is kept.")}finally{if(p.current=!1,m.current)l(!1)}};return A.jsxDEV(A.Fragment,{children:[A.jsxDEV("span",{ref:g,children:A.jsxDEV(D,{type:"button",variant:"ghost","aria-expanded":t,disabled:t,onClick:()=>{r(e.title),o(!0)},children:"Rename"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t&&A.jsxDEV("form",{className:i("studio-chat-rename",n.sessionControls),onSubmit:(c)=>{c.preventDefault(),y()},children:[A.jsxDEV("label",{children:["Conversation title",A.jsxDEV(Ee,{ref:b,xstyle:n.sessionFilterSelect,value:s,onChange:(c)=>r(c.target.value),required:!0,maxLength:48,disabled:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A.jsxDEV("div",{className:i("",n.actions),children:[A.jsxDEV(D,{type:"submit",disabled:a||!s.trim(),children:a?"Renaming…":"Save title"},void 0,!1,void 0,this),A.jsxDEV(D,{type:"button",variant:"ghost",disabled:a,onClick:I,children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&A.jsxDEV("p",{role:"alert",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var u=w(H(),1);function Ue(e){let{currentSession:t,archivedSession:o,setConversationsOpen:s,detailsOpen:r,setDetailsOpen:a,renameCurrent:l}=e.sessions,f=Z.useRef(null),d=t?le(t):null,m=d?.title??t?.contextHandoff?.titleSeed??void 0,p=d?e.entryHref(d.entityType,d.entityId):void 0,b=t?.title??(e.sessionId?"Conversation":"New conversation"),g=(c)=>p!==void 0?u.jsxDEV("a",{href:p,className:i("studio-chat-open-entry",n.openEntry,c&&n.openEntryIcon),"aria-label":c?"Open entry":void 0,onClick:(S)=>{if(!Oe(S))return;S.preventDefault(),e.onOpenEntry(p)},children:c?u.jsxDEV("span",{"aria-hidden":"true",children:"↗"},void 0,!1,void 0,this):"Open entry ↗"},void 0,!1,void 0,this):null,I=u.jsxDEV(D,{type:"button",variant:"ghost",xstyle:n.toolbarButton,"aria-label":"Conversation details and options","aria-haspopup":"dialog","aria-expanded":r,onClick:()=>a(!0),children:"•••"},void 0,!1,void 0,this),[y]=Z.useState(()=>Symbol("chat thread"));return X(y,e.phoneShown?{title:b,back:{label:"Conversations",onBack:()=>s(!0)},action:u.jsxDEV(u.Fragment,{children:[g(!0),I]},void 0,!0,void 0,this)}:null),u.jsxDEV(u.Fragment,{children:[u.jsxDEV("header",{className:i("studio-chat-thread-head",n.threadHead,n.phoneGoneFlex),children:[u.jsxDEV("h1",{className:i("studio-chat-session-heading",n.title),title:t?.title,children:b},void 0,!1,void 0,this),m&&u.jsxDEV("span",{className:i("studio-chat-about",n.about),"data-studio-chat-about":"",children:["About: ",m]},void 0,!0,void 0,this),u.jsxDEV("div",{className:i("studio-chat-head-actions",n.toolbar),children:[g(!1),u.jsxDEV("span",{ref:f,children:I},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV(Be,{open:r,onOpenChange:(c)=>{if(a(c),!c)e.deletion.cancelDelete()},children:u.jsxDEV(He,{"aria-describedby":void 0,onCloseAutoFocus:(c)=>{c.preventDefault(),([...document.querySelectorAll('[aria-label="Conversation details and options"]')].find((k)=>k.offsetParent!==null)??f.current?.querySelector("button"))?.focus()},children:[u.jsxDEV(qe,{children:"Conversation details"},void 0,!1,void 0,this),u.jsxDEV("div",{className:i("studio-chat-details",n.details),children:[u.jsxDEV("p",{children:t?.title??"New conversation"},void 0,!1,void 0,this),u.jsxDEV("div",{className:i("studio-chat-session-actions",n.actions),children:[t&&u.jsxDEV(Pe,{title:t.title,onRename:l},t.id,!1,void 0,this),o&&u.jsxDEV("p",{role:"status",children:"Archived conversation. New messages here remain archived."},void 0,!1,void 0,this),e.sessionId&&!o?u.jsxDEV(D,{className:"studio-chat-header-action",variant:"ghost",type:"button",onClick:e.onArchive,disabled:e.archiveBlocked,title:e.draftPending?"Send or clear the draft before archiving":void 0,children:e.archiving?"Archiving…":"Archive"},void 0,!1,void 0,this):null,e.sessionId&&(e.deletion.confirming?u.jsxDEV("section",{role:"group","aria-label":"Confirm conversation deletion",children:[u.jsxDEV("p",{children:"Delete this conversation permanently? This cannot be undone."},void 0,!1,void 0,this),u.jsxDEV("p",{children:"Deleting history does not undo completed actions or guarantee that remote work has stopped."},void 0,!1,void 0,this),e.deletion.deleteError&&u.jsxDEV("p",{role:"alert",children:e.deletion.deleteError},void 0,!1,void 0,this),u.jsxDEV(D,{type:"button",variant:"ghost",autoFocus:!0,"aria-label":"Cancel conversation deletion",disabled:e.deletion.deleting,onClick:e.deletion.cancelDelete,children:"Cancel"},void 0,!1,void 0,this),u.jsxDEV(D,{type:"button",variant:"ghost","aria-label":"Permanently delete conversation",disabled:e.archiveBlocked,onClick:()=>void e.deletion.confirmDelete(),children:e.deletion.deleting?"Deleting…":"Delete permanently"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):u.jsxDEV(D,{type:"button",variant:"ghost","aria-label":"Delete conversation",disabled:e.archiveBlocked,title:e.draftPending?"Send or clear the draft before deleting":void 0,onClick:e.deletion.requestDelete,children:"Delete conversation"},void 0,!1,void 0,this))]},void 0,!0,void 0,this),u.jsxDEV("details",{children:[u.jsxDEV("summary",{children:"Sources and attachments"},void 0,!1,void 0,this),u.jsxDEV(we,{cards:e.contextCards,progress:e.progress,session:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV("details",{children:[u.jsxDEV("summary",{children:"File types and limits"},void 0,!1,void 0,this),u.jsxDEV("p",{id:"studio-chat-upload-guidance",children:Le},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var U=w(L(),1);var Ut=250;function Me(e){let{chatClient:t,queryClient:o,sessionId:s,studioBasePath:r,navigate:a}=e,[l,f]=U.useState(s===null),[d,m]=U.useState(!1),[p,b]=U.useState(""),[g,I]=U.useState({query:"",archived:!1,offset:0});U.useEffect(()=>{let E=window.setTimeout(()=>I((T)=>T.query===p.trim()?T:{...T,query:p.trim(),offset:0}),Ut);return()=>window.clearTimeout(E)},[p]);let y=Ke({queryKey:[...q.sessions,g],queryFn:()=>t.listSessions(g)}),c=y.data??[],S=c.find((E)=>E.id===s)??o.getQueriesData({queryKey:q.sessions}).flatMap(([,E])=>E??[]).find((E)=>E.id===s),k=U.useCallback(()=>{m(!1)},[]),x=U.useCallback((E,T=!1)=>{a(Fe(r,E),{preserveWork:T}),f(!1),k()},[a,r,k]),R=async(E)=>{if(!S)return;let T=await t.renameSession(S.id,E);if(!T.renamed)throw Error("The conversation could not be renamed.");o.setQueriesData({queryKey:q.sessions},(V)=>V?.map((W)=>W.id===S.id?{...W,title:T.title}:W)),o.invalidateQueries({queryKey:q.sessions})};return{sessions:c,currentSession:S,archivedSession:S?.archived===!0,sessionControls:{search:p,view:g,error:y.error?"Sessions could not be loaded.":null,onRetry:()=>{y.refetch()},onSearch:b,onView:I},sessionsLoading:y.isPending,navigateToSession:x,conversationsOpen:l,setConversationsOpen:f,detailsOpen:d,setDetailsOpen:m,closeDisclosures:k,renameCurrent:R}}var K=w(L(),1);function Qe(e){let{chatClient:t,draftKey:o,currentDraftKey:s,setUploads:r}=e,[a,l]=K.useState(!1),[f,d]=K.useState([]),m=K.useRef(null),p=K.useCallback(async(y)=>{if(m.current||y.length===0)return;let c=Symbol();if(m.current=c,l(!0),d((S)=>[...S.filter((k)=>!y.some((x)=>x.id===k.id)),...y.map((k)=>({id:k.id,file:k.file,status:"uploading"}))]),await Promise.all(y.map(async(S)=>{try{let k=await t.upload(S.file,S.file.name);if(m.current!==c||s.current!==o)return;r((x)=>[...x,k]),d((x)=>x.filter((R)=>R.id!==S.id))}catch(k){if(m.current!==c||s.current!==o)return;d((x)=>x.map((R)=>R.id===S.id?{...R,status:"failed",error:_(k,"Upload failed")}:R))}})),m.current===c)m.current=null,l(!1)},[t,o,s,r]),b=K.useCallback(async(y)=>{let c=Array.from(y.target.files??[]);y.target.value="",await p(c.map((S)=>({id:crypto.randomUUID(),file:S,status:"uploading"})))},[p]),g=K.useCallback((y)=>{d((c)=>c.filter((S)=>S.id!==y))},[]),I=K.useCallback(()=>{m.current=null,l(!1),d([])},[]);return{uploading:a,uploadAttempts:f,runUploads:p,uploadFiles:b,dismissAttempt:g,reset:I}}var j=w(L(),1);function We(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,setError:m,navigateToSession:p}=e,[b,g]=j.useState(!1),I=j.useCallback(async()=>{if(!s||f)return;d(!0),g(!0);try{if(await t.archiveSession(s),await o.invalidateQueries({queryKey:q.sessions}),l.current&&a.current===r)p(void 0,!0)}catch(c){if(l.current&&a.current===r)m(_(c,"Conversation could not be archived"))}finally{if(l.current&&a.current===r)d(!1),g(!1)}},[t,o,s,r,a,l,f,d,m,p]),y=j.useCallback(()=>g(!1),[]);return{archiving:b,archiveCurrent:I,reset:y}}var M=w(L(),1);function $e(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,navigateToSession:m}=e,[p,b]=M.useState(null),[g,I]=M.useState(!1),[y,c]=M.useState(null),S=M.useRef(0),k=M.useRef(!1),x=p===r,R=M.useCallback(()=>{S.current++,k.current=!1,b(null),I(!1),c(null)},[]);return{confirming:x,deleting:g,deleteError:y,requestDelete:()=>{if(!s||f||k.current)return;c(null),b(r)},cancelDelete:()=>{if(!k.current)b(null)},confirmDelete:async()=>{if(!s||!x||f||k.current)return;let W=S.current,B=()=>l.current&&a.current===r&&S.current===W;k.current=!0,I(!0),d(!0),c(null);try{if(!(await t.deleteSession(s)).deleted)throw Error("Deletion was not acknowledged");if(await o.cancelQueries({queryKey:q.messages(s)}),o.removeQueries({queryKey:q.messages(s)}),o.setQueriesData({queryKey:q.sessions},(G)=>G?.filter((J)=>J.id!==s)),o.invalidateQueries({queryKey:q.sessions}),B())b(null),m(void 0,!0)}catch{if(B())c("Deletion could not be confirmed. The conversation may already be deleted. Check history before trying again.")}finally{if(B())k.current=!1,I(!1),d(!1)}},reset:R}}var ee=w(L(),1);function _e(e){let{chatClient:t,handoff:o,sessionId:s,apiPath:r,draftStore:a,draftKey:l,currentDraftKey:f,mountedRef:d,setDraft:m,setError:p,navigateToSession:b}=e,g=ee.useRef(null);ee.useEffect(()=>{if(!o||s)return;let I=`${o.sourceId}\x00${o.itemId}`;if(g.current===I)return;g.current=I,m(o.prompt),p(null);let y=()=>d.current===!0&&f.current===l&&g.current===I;t.openContextSession({version:1,sourceId:o.sourceId,itemId:o.itemId,titleSeed:o.label}).then(({conversationId:c})=>{if(!y())return;a.adopt(l,Ve(r,c)),b(c,!0)}).catch((c)=>{if(!y())return;g.current=null,p(_(c,"Context could not be attached"))})},[t,o,s,r,a,l,f,d,m,p,b])}var te=w(L(),1);function Ye(e){let{question:t,sessionId:o,setDraft:s}=e,r=te.useRef(null);te.useEffect(()=>{if(!t||o)return;if(r.current===t)return;r.current=t,s(t)},[t,o,s])}var ce=w(L(),1);function je(e){let{onChange:t,draft:o,uploadCount:s,uploadAttemptCount:r,sending:a,uploading:l}=e;ce.useEffect(()=>{t?.({hasDraft:Boolean(o||s||r),busy:a||l})},[o,s,r,a,l,t]),ce.useEffect(()=>()=>t?.({hasDraft:!1,busy:!1}),[t])}var Xe=w(L(),1);var C=w(H(),1);function Ze(e){let t=Date.now(),o=e.sessions.length>0||e.search!==""||e.view.query!==""||e.view.archived||e.view.offset>0,s=C.jsxDEV(D,{className:"studio-chat-new",type:"button",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this),[r]=Xe.useState(()=>Symbol("conversations"));return X(r,e.phoneHidden===!0?null:{title:"Conversations",action:s}),C.jsxDEV("aside",{className:i("studio-chat-session-picker",n.conversations,e.phoneHidden===!0&&n.conversationsHidden),"aria-label":"Conversations",children:[C.jsxDEV("div",{className:i("studio-chat-session-controls",n.sessionControls),children:[C.jsxDEV("div",{className:i("",n.railHead,n.phoneGoneFlex),children:[C.jsxDEV("h2",{className:i("",n.railTitle),children:"Conversations"},void 0,!1,void 0,this),C.jsxDEV(D,{className:"studio-chat-new",type:"button",variant:"secondary",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&C.jsxDEV(Je,{label:"Conversation search and filters",searchLabel:"Search conversations",search:e.search,onSearch:e.onSearch,filterLabel:"Filter",filterCount:e.view.archived?1:0,filtered:Boolean(e.view.query)||e.view.archived,onClear:()=>{e.onSearch(""),e.onView({...e.view,query:"",archived:!1,offset:0})},children:C.jsxDEV(Ge,{"aria-label":"Show conversations",value:e.view.archived?"archived":"active",onChange:(a)=>e.onView({...e.view,archived:a.target.value==="archived",offset:0}),children:[C.jsxDEV("option",{value:"active",children:"Active conversations"},void 0,!1,void 0,this),C.jsxDEV("option",{value:"archived",children:"Archived conversations"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),e.error&&C.jsxDEV("p",{role:"alert",children:[e.error," ",C.jsxDEV(D,{type:"button",variant:"ghost",onClick:e.onRetry,children:"Retry sessions"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),C.jsxDEV("div",{className:i("studio-chat-session-list",n.sessionList),children:[e.loading?C.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:"Loading conversations…"},void 0,!1,void 0,this):null,!e.loading&&!e.error&&e.sessions.length===0?C.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:e.view.query?"No conversations match this search.":e.view.offset>0?"No more conversations.":e.view.archived?"No archived conversations.":"No conversations yet."},void 0,!1,void 0,this):null,Re(e.sessions,t).map((a)=>C.jsxDEV("section",{"aria-label":a.label,children:[C.jsxDEV("h3",{className:i("",n.dayLabel),children:a.label},void 0,!1,void 0,this),a.sessions.map((l)=>{let f=l.id===e.activeSessionId,d=Te(l,t);return C.jsxDEV("button",{className:i("studio-chat-session",n.session,f&&n.activeSession),"data-active":f?"true":"false","aria-current":f?"true":void 0,type:"button",onClick:()=>e.onSelect(l.id),children:[C.jsxDEV("strong",{className:i("studio-chat-session-title",n.sessionTitle),children:l.title},void 0,!1,void 0,this),C.jsxDEV("small",{className:i("studio-chat-session-note",n.sessionNote),"data-note":d.kind,children:d.kind==="entry"?C.jsxDEV(C.Fragment,{children:[C.jsxDEV("span",{"aria-hidden":"true",className:i("",n.brainMark)},void 0,!1,void 0,this),d.text]},void 0,!0,void 0,this):C.jsxDEV("time",{dateTime:l.lastActiveAt,title:l.lastActiveAt,children:d.text},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},l.id,!0,void 0,this)})]},a.label,!0,void 0,this)),(e.view.offset>0||e.sessions.length>=25)&&C.jsxDEV(ze,{label:"Conversation pages",offset:e.view.offset,count:e.sessions.length,loading:e.loading,hasNext:e.sessions.length>=25,onPrevious:()=>e.onView({...e.view,offset:Math.max(0,e.view.offset-25)}),onNext:()=>e.onView({...e.view,offset:e.view.offset+25})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var h=w(H(),1);function Kt(e,t,o){return`${e==="/"?"":e.replace(/\/+$/,"")}/entities/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}function io(e){let t=et(),o=tt(),s=Q.useMemo(()=>ot({apiPath:e.apiPath,fetch:o}),[e.apiPath,o]),{draftStore:r,draftKey:a,currentDraftKey:l,draft:f,uploads:d,setDraft:m,setUploads:p}=vt({draftStore:e.draftStore,apiPath:e.apiPath,sessionId:e.sessionId}),{uploading:b,uploadAttempts:g,runUploads:I,uploadFiles:y,dismissAttempt:c,reset:S}=Qe({chatClient:s,draftKey:a,currentDraftKey:l,setUploads:p}),k=at(),x=Me({chatClient:s,queryClient:t,sessionId:e.sessionId,studioBasePath:e.studioBasePath,navigate:e.navigate}),{navigateToSession:R,closeDisclosures:E}=x,T=Q.useRef(!1),V=Q.useRef(null),{pendingMessages:W,stream:B,sending:F,error:G,interrupted:J,setSending:me,setError:fe,submitPrompt:Ct,respondToApproval:he,runSuggestedAction:St,hasActiveStream:bt,stopActiveStream:kt,abortActiveStream:pe,reset:wt}=gt({chatClient:s,queryClient:t,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,adoptedSessionRef:V,uploads:d,uploading:b,uploadAttemptCount:g.length,navigateToSession:R});_e({chatClient:s,handoff:e.handoff,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,setDraft:m,setError:fe,navigateToSession:R}),Ye({question:e.question,sessionId:e.sessionId,setDraft:m});let ve=Boolean(f)||d.length>0,ge=ve||g.length>0,oe=F||b||ge,{archiving:ye,archiveCurrent:It,reset:Nt}=We({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,setError:fe,navigateToSession:R}),se=$e({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,navigateToSession:R});Q.useEffect(()=>(T.current=!0,()=>{T.current=!1,pe()}),[pe]),je({onChange:e.onNavigationStateChange,draft:f,uploadCount:d.length,uploadAttemptCount:g.length,sending:F,uploading:b});let{visibleMessages:Y,contextCards:xt,historyFailed:ie,historyOpening:ae,historyReading:Dt,hasStoredHistory:Rt,retryHistory:Tt}=yt({chatClient:s,sessionId:e.sessionId,sending:F,pendingMessages:W,stream:B}),{ref:Ce,onScroll:Et,awayFromLatest:At,jumpToLatest:Pt}=nt({resetKey:e.sessionId,contentKey:`${Y.length}:${B?.text.length??-1}`});Q.useEffect(()=>{if(E(),e.sessionId&&V.current===e.sessionId){V.current=null;return}wt(),S(),Nt(),se.reset()},[e.sessionId]);let Bt=(v)=>{v.preventDefault(),Ct(f)},Se=ct(e.workspaces),be=!ie&&(!e.sessionId||!ae)&&Y.length===0?mt({types:e.types.map((v)=>v.entityType),workspaces:e.workspaces.map((v)=>v.id)}):[];return h.jsxDEV(dt,{value:(v)=>e.navigate(v),children:h.jsxDEV("div",{className:i("studio",st.frame,n.root,it.space),"data-view":"chat","data-studio-shell":"",children:[h.jsxDEV(lt,{contextLabel:"Chat",navigation:{types:e.types,workspaces:e.workspaces,activeEntityType:null,activeWorkspaceId:de,workspaceBadges:Se,selectEntityType:e.selectEntityType,selectWorkspace:e.selectWorkspace}},void 0,!1,void 0,this),h.jsxDEV("div",{className:ue("studio-chat-shell",n.shell,ne.shell,k&&ne.shellCollapsed),children:[h.jsxDEV("aside",{className:ue("rail studio-chat-studio-rail",ne.rail),children:h.jsxDEV(rt,{renderMode:"desktop",types:e.types,active:null,onSelect:e.selectEntityType,workspaces:e.workspaces,activeWorkspace:de,workspaceBadges:Se,onSelectWorkspace:e.selectWorkspace},void 0,!1,void 0,this)},void 0,!1,void 0,this),h.jsxDEV("main",{className:i("studio-chat-workspace",n.frame),children:h.jsxDEV("div",{className:i("studio-chat-room",n.room),children:[h.jsxDEV(Ze,{...x.sessionControls,activeSessionId:e.sessionId,loading:x.sessionsLoading,sessions:x.sessions,onNew:()=>R(),onSelect:R,phoneHidden:!x.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("section",{className:i("studio-chat-thread",n.thread,x.conversationsOpen&&n.threadHidden),"aria-label":"Conversation",children:[h.jsxDEV(Ue,{sessionId:e.sessionId,sessions:x,archiving:ye,archiveBlocked:oe,draftPending:ge,onArchive:()=>void It(),deletion:se,contextCards:xt,progress:B?.progress??[],entryHref:(v,re)=>Kt(e.studioBasePath,v,re),onOpenEntry:(v)=>e.navigate(v),phoneShown:!x.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("div",{ref:Ce,tabIndex:0,role:"region","aria-label":"Conversation messages",onScroll:Et,className:i("studio-chat-thread-scroll",n.threadScroll),children:h.jsxDEV("div",{className:i("studio-chat-manuscript",n.manuscript),children:[ie&&h.jsxDEV("section",{role:"alert",children:[h.jsxDEV("p",{children:[Rt?"Showing previously loaded messages. ":"","Conversation could not be loaded."]},void 0,!0,void 0,this),h.jsxDEV(D,{type:"button",variant:"ghost",disabled:Dt,onClick:Tt,children:"Retry conversation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ae&&e.sessionId&&Y.length===0?h.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"Opening conversation…"},void 0,!1,void 0,this):null,!ie&&(!e.sessionId||!ae)&&Y.length===0?h.jsxDEV(ft,{},void 0,!1,void 0,this):null,Y.map((v)=>h.jsxDEV(ht,{message:v,client:s,disabled:F,speaker:"Your brain",reading:"manuscript",onAction:St,onApproval:he},v.id,!1,void 0,this)),B?.approvals.map((v)=>h.jsxDEV(pt,{approval:v,disabled:F,onDecision:he},v.approvalId,!1,void 0,this)),B&&B.progress.length>0&&h.jsxDEV("details",{className:i("studio-chat-progress",n.card),children:[h.jsxDEV("summary",{children:["Activity · ",B.progress.length," updates"]},void 0,!0,void 0,this),h.jsxDEV("pre",{className:i("",n.source),children:JSON.stringify(B.progress,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F?h.jsxDEV("p",{className:i("studio-chat-stream-status",n.empty),role:"status",children:"Responding…"},void 0,!1,void 0,this):null,J&&h.jsxDEV(ke,{interrupted:J,draftPending:ve,restoreBlocked:F||b,onRestore:(v)=>{m(v.text),p([...v.uploads]),Ce.current?.closest(".studio-chat-thread")?.querySelector("textarea")?.focus()}},void 0,!1,void 0,this),G?h.jsxDEV("p",{className:i("studio-chat-error",n.empty,n.error),role:"alert",children:G},void 0,!1,void 0,this):null,h.jsxDEV("div",{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),h.jsxDEV(ut,{above:be.length>0?h.jsxDEV("div",{"data-studio-chat-starters":"",className:i("studio-chat-starters",n.starters),"aria-label":"Ways to start",children:be.map((v)=>h.jsxDEV("button",{type:"button",className:i("",n.starter),onClick:()=>m(v),children:v},v,!1,void 0,this))},void 0,!1,void 0,this):void 0,onJumpToLatest:At?Pt:void 0,draft:f,sending:F,uploading:b,uploads:d,uploadAttempts:g,onRetryUpload:(v)=>void I([v]),onDismissUpload:c,onDraft:m,locked:ye||se.deleting,onRemoveUpload:(v)=>p((re)=>re.filter((Ht)=>Ht.id!==v)),onFiles:y,onSubmit:Bt,onStop:bt()?kt:void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}export{io as StudioChatWorkspace};
|
|
2
|
-
|
|
3
|
-
//# debugId=021F11D0CF72740A64756E2164756E21
|
|
File without changes
|
|
File without changes
|
|
File without changes
|