PageSourceSearch

https://solarintelligence.ai/assets/AdminRecentConversationsPage-BvK68dd6.js

js solarintelligence.ai collected 2026-10-05 12:51:07 UTC 16,604 bytes, 1 lines download raw bytes

1import{j as e}from"./state-DKBP_IF5.js";import{A as Y}from"./AdminPageChrome-TdsAIsqV.js";import{r as i,b as Z}from"./react-vendor-Unhn4PzF.js";import{t as C}from"./ui-Dw3dkPmY.js";import{c as ee,d as z,e as $,a as T,X as se,H as te,y as re}from"./index-Br3_ARw7.js";import{A as ae}from"./AdminIncludeAdminsToggle-Dzktzck7.js";import{M as B}from"./message-square-BvcYC84r.js";import{C as ne}from"./chevron-right-BTFtdlbc.js";import{M as E,r as M}from"./markdown-DHncH_pN.js";/* empty css                           */import"./charts-D5dg506X.js";import"./forms-GD8l5aEM.js";window.CESIUM_BASE_URL="/cesium/";const ce=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],le=ee("user-round",ce),ie=137.508;function oe(s){const t=s.replace(/[^0-9a-f]/gi,"").padEnd(12,"0").slice(0,12),r=parseInt(t.slice(0,6),16)||0,n=parseInt(t.slice(6,12),16)||0,a=Math.round(r*ie%360),l=48+n%28,o=n%10;return{hue:a,saturation:l,lightnessShift:o}}function R(s,t=!1){const{hue:r,saturation:n,lightnessShift:a}=oe(s);if(t){const x=16+a*.8,g=13+a*.6;return{bg:`hsl(${r} ${n}% ${x}%)`,color:`hsl(${r} ${Math.min(n+12,85)}% 78%)`,border:`hsl(${r} ${Math.max(n-8,30)}% ${x+10}%)`,messageBg:`hsl(${r} ${n-6}% ${g}%)`,messageBorder:`hsl(${r} ${Math.max(n-10,28)}% ${g+12}%)`}}const l=90+a*.5,o=93+a*.4;return{bg:`hsl(${r} ${n}% ${l}%)`,color:`hsl(${r} ${Math.min(n+8,80)}% 28%)`,border:`hsl(${r} ${Math.max(n-6,35)}% ${l-12}%)`,messageBg:`hsl(${r} ${n-4}% ${o}%)`,messageBorder:`hsl(${r} ${Math.max(n-8,32)}% ${o-10}%)`}}const de=20;function S(s){const t=T[s];return t?.role?t.role:s.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function pe(s,t){const r=T[s];return{name:t??r?.name??S(s),role:r?.role??S(s)}}function h({agentType:s,size:t=28,nameOverride:r,layout:n="inline"}){const{name:a,role:l}=pe(s,r);return e.jsxs("span",{className:`rcp-agent-identity rcp-agent-identity--${n}`,children:[e.jsx(he,{agentType:s,size:t}),e.jsxs("span",{className:"rcp-agent-identity-text",children:[e.jsx("span",{className:"rcp-agent-name",children:a}),e.jsx("span",{className:"rcp-agent-role",children:l})]})]})}function j(s,t=!1){return s?new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",...t?{year:"numeric"}:{},hour:"2-digit",minute:"2-digit"}):"—"}function ue(s){switch(s){case"executed":return"Executed";case"superseded":return"Re-planned";default:return"Awaiting approval"}}function me(s){switch(s){case"accepted":return"User followed handoff";case"opened":return"Opened specialist chat";default:return"No follow-up detected"}}function D(s){switch(s){case"done":return"Ran";case"failed":return"Failed";case"skipped":return"Skipped";case"locked":return"Locked";case"budget_exceeded":return"Budget exceeded";case"truncated":return"Truncated";case"user_disabled":return"Disabled by user";default:return s.replace(/_/g," ")}}function he({agentType:s,size:t=28}){const r=te(s),n=T[s],a=n?.role??S(s);return e.jsxs("span",{className:"rcp-agent-badge",title:a,style:{width:t,height:t},children:[e.jsx("span",{className:"rcp-agent-badge-bg",style:{background:r.soft,borderColor:r.accent}}),n?.name?e.jsx("img",{src:`/agents/${n.name}.svg`,alt:"",style:{filter:r.iconFilter,width:Math.round(t*.58),height:Math.round(t*.58)}}):e.jsx("span",{className:"rcp-agent-fallback",style:{color:r.accent,fontSize:Math.round(t*.38)},children:a.charAt(0)})]})}function F({hash:s,isDark:t}){const r=R(s,t);return e.jsxs("span",{className:"rcp-user-chip",style:{background:r.bg,color:r.color,borderColor:r.border},children:[e.jsx(le,{size:12}),s]})}function U(){return e.jsx("span",{className:"rcp-guest-pill",children:"Guest"})}function xe(s,t){const r=R(s,t);return{background:r.messageBg,borderColor:r.messageBorder,color:r.color}}function ge({step:s}){const[t,r]=i.useState(!1),n=!!(s.response?.trim()||s.error?.trim());return e.jsxs("div",{className:`rcp-step-result-collapsible ${t?"rcp-step-result-collapsible--open":""}`,children:[e.jsxs("button",{type:"button",className:"rcp-step-result-toggle",onClick:()=>n&&r(a=>!a),disabled:!n,"aria-expanded":n?t:void 0,children:[n&&e.jsx(re,{size:16,className:"rcp-step-chevron"}),e.jsx(h,{agentType:s.agent_type||"unknown",size:22}),e.jsxs("div",{className:"rcp-step-result-summary",children:[e.jsx("div",{className:"rcp-step-result-title",children:s.status&&e.jsx("span",{className:`rcp-status-pill rcp-status-pill--exec-${s.status}`,children:D(s.status)})}),s.question&&e.jsx("p",{className:"rcp-step-question",children:s.question})]})]}),n&&e.jsx("div",{className:"rcp-step-result-body",children:e.jsxs("div",{className:"rcp-step-result-body-inner",children:[s.response&&e.jsx("div",{className:"rcp-markdown rcp-markdown--compact",children:e.jsx(E,{remarkPlugins:[M],children:s.response})}),s.error&&e.jsx("p",{className:"rcp-error-text",children:s.error})]})})]})}function je({steps:s}){return s.length?e.jsx("div",{className:"rcp-step-results",children:s.map((t,r)=>e.jsx(ge,{step:t},`${t.agent_type}-${t.step_id??r}`))}):null}function ve({step:s}){const t=s.enabled!==!1,r=s.execution_status;return e.jsxs("li",{className:`rcp-plan-step ${t?"":"rcp-plan-step--disabled"}`,children:[e.jsxs("div",{className:"rcp-plan-step-top",children:[e.jsx(h,{agentType:s.agent_type,size:22}),e.jsxs("div",{className:"rcp-plan-step-badges",children:[e.jsx("span",{className:`rcp-step-flag ${t?"rcp-step-flag--on":"rcp-step-flag--off"}`,children:t?"Proposed":"Proposed off"}),r&&e.jsx("span",{className:`rcp-status-pill rcp-status-pill--exec-${r}`,children:D(r)})]})]}),e.jsx("p",{children:s.question})]})}function fe({item:s,userHash:t,isDark:r}){if(s.kind==="user_query")return e.jsxs("div",{className:"rcp-timeline-event rcp-timeline-event--user",style:xe(t,r),children:[e.jsxs("div",{className:"rcp-timeline-event-head",children:[e.jsx("span",{className:"rcp-timeline-role",children:"User"}),e.jsx("time",{children:j(s.timestamp)})]}),e.jsx("p",{className:"rcp-timeline-text",children:s.text||e.jsx("em",{children:"Empty message"})})]});if(s.kind==="orion_plan"&&s.plan){const a=s.plan;return e.jsxs("div",{className:"rcp-timeline-event rcp-timeline-event--orion-plan",children:[e.jsxs("div",{className:"rcp-timeline-event-head",children:[e.jsx(h,{agentType:"orchestrator",size:24}),e.jsx("span",{className:"rcp-timeline-event-tag",children:a.is_replan?"Re-plan":"Plan"}),e.jsx("span",{className:`rcp-status-pill rcp-status-pill--${a.status}`,children:ue(a.status)}),e.jsx("time",{children:j(s.timestamp)})]}),a.summary&&e.jsx("p",{className:"rcp-timeline-text",children:a.summary}),a.steps.length>0&&e.jsx("ul",{className:"rcp-plan-steps",children:a.steps.map((l,o)=>e.jsx(ve,{step:l},`${l.agent_type}
1-${l.step_id??o}`))}),a.status==="executed"&&e.jsx("p",{className:"rcp-meta-note rcp-meta-note--muted",children:"User toggles at approval are not stored — execution status is inferred from results."}),a.run_count>0&&e.jsxs("p",{className:"rcp-meta-note",children:["Executed ",a.run_count," time",a.run_count===1?"":"s"]})]})}if(s.kind==="orion_referral"&&s.referral){const a=s.referral;return e.jsxs("div",{className:"rcp-timeline-event rcp-timeline-event--orion-referral",children:[e.jsxs("div",{className:"rcp-timeline-event-head",children:[e.jsx(h,{agentType:"orchestrator",size:24}),e.jsx("span",{className:"rcp-timeline-event-tag",children:"Handoff"}),e.jsx("time",{children:j(s.timestamp)})]}),a.text&&e.jsx("p",{className:"rcp-timeline-text",children:a.text}),e.jsx("ul",{className:"rcp-referral-list",children:a.candidates.map(l=>{const o=a.outcomes.find(x=>x.agent_type===l.agent_type);return e.jsxs("li",{children:[e.jsx(h,{agentType:l.agent_type,size:24,nameOverride:l.agent_name}),e.jsxs("div",{className:"rcp-referral-body",children:[(l.locked||l.open_only)&&e.jsxs("div",{className:"rcp-referral-title",children:[l.locked&&e.jsx("span",{className:"rcp-lock-pill",children:"Locked"}),l.open_only&&e.jsx("span",{className:"rcp-lock-pill",children:"Open only"})]}),l.reason&&e.jsx("p",{children:l.reason}),l.prompt&&e.jsxs("p",{className:"rcp-referral-prompt",children:[e.jsx("span",{children:"Suggested prompt"}),l.prompt]}),o&&e.jsxs("p",{className:`rcp-outcome rcp-outcome--${o.status}`,children:[me(o.status),o.matched_at?` · ${j(o.matched_at)}`:""]})]})]},l.agent_type)})})]})}if(s.kind==="orion_synthesis")return e.jsxs("div",{className:"rcp-timeline-event rcp-timeline-event--orion-synthesis",children:[e.jsxs("div",{className:"rcp-timeline-event-head",children:[e.jsx(h,{agentType:"orchestrator",size:24}),e.jsx("span",{className:"rcp-timeline-event-tag",children:"Synthesis"}),e.jsx("time",{children:j(s.timestamp)})]}),s.step_results&&s.step_results.length>0&&e.jsx(je,{steps:s.step_results}),s.text&&e.jsx("div",{className:"rcp-markdown",children:e.jsx(E,{remarkPlugins:[M],children:s.text})})]});const n=s.kind==="orion_direct_response";return e.jsxs("div",{className:`rcp-timeline-event rcp-timeline-event--agent ${n?"rcp-timeline-event--orion":""}`,children:[e.jsxs("div",{className:"rcp-timeline-event-head",children:[e.jsx(h,{agentType:s.agent_type||"unknown",size:24}),n&&e.jsx("span",{className:"rcp-timeline-event-tag",children:"Direct reply"}),e.jsx("time",{children:j(s.timestamp)})]}),s.text&&e.jsx("div",{className:"rcp-markdown",children:e.jsx(E,{remarkPlugins:[M],children:s.text})})]})}function Ne({conversationId:s,summary:t,includeAdmins:r,onClose:n}){const a=z(d=>d.themeMode==="dark"),[l,o]=i.useState(null),[x,g]=i.useState(!0),[N,b]=i.useState(!1),k=i.useRef(null);i.useEffect(()=>{let d=!1;return(async()=>{try{g(!0);const u=await $.getAnalyticsConversationTimeline(s,r);d||o(u.data)}catch(u){console.error("Failed to load conversation timeline:",u),d||C.error("Failed to load conversation history")}finally{d||g(!1)}})(),()=>{d=!0}},[s,r]);const v=i.useCallback(()=>{b(!0),window.setTimeout(n,180)},[n]);i.useEffect(()=>{const d=u=>{u.key==="Escape"&&v()};return document.addEventListener("keydown",d),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=""}},[v]);const m=t.title||`Chat #${t.conversation_id}`;return Z.createPortal(e.jsx("div",{className:`rcp-modal-backdrop ${N?"rcp-modal-backdrop--closing":""}`,onClick:v,role:"presentation",children:e.jsxs("div",{ref:k,className:`rcp-modal ${N?"rcp-modal--closing":""}`,role:"dialog","aria-modal":"true","aria-label":`Conversation ${s}`,onClick:d=>d.stopPropagation(),children:[e.jsxs("header",{className:"rcp-modal-header",children:[e.jsxs("div",{className:"rcp-modal-title-block",children:[e.jsx(h,{agentType:t.agent_type,size:36,layout:"stacked"}),e.jsxs("div",{children:[e.jsx("h3",{children:m}),e.jsx("p",{children:j(t.last_activity_at,!0)})]})]}),e.jsxs("div",{className:"rcp-modal-meta",children:[e.jsx(F,{hash:t.user_hash,isDark:a}),t.is_guest&&e.jsx(U,{}),e.jsx("button",{type:"button",className:"rcp-modal-close",onClick:v,"aria-label":"Close",children:e.jsx(se,{size:18})})]})]}),e.jsx("div",{className:"rcp-modal-body",children:x?e.jsxs("div",{className:"rcp-modal-loading",children:[e.jsx("div",{className:"rcp-spinner"}),e.jsx("span",{children:"Loading conversation…"})]}):l?.timeline?.length?e.jsx("div",{className:"rcp-timeline",children:l.timeline.map(d=>e.jsx(fe,{item:d,userHash:t.user_hash,isDark:a},d.id))}):e.jsx("p",{className:"rcp-empty",children:"No messages in this conversation."})})]})}),document.body)}function ye(){const s=z(c=>c.themeMode==="dark"),[t,r]=i.useState(!1),[n,a]=i.useState([]),[l,o]=i.useState([]),[x,g]=i.useState(!0),[N,b]=i.useState(!1),[k,v]=i.useState(!1),[m,d]=i.useState("all"),[u,O]=i.useState(void 0),[w,G]=i.useState(""),[_,H]=i.useState(""),[I,V]=i.useState(0),[W,K]=i.useState(!1),[Q,P]=i.useState(0),[A,q]=i.useState(null);i.useEffect(()=>{const c=window.setTimeout(()=>H(w.trim()),300);return()=>window.clearTimeout(c)},[w]),i.useEffect(()=>{(async()=>{try{const p=await $.getAnalyticsAgentUsage(90,t);a(p.data.agents)}catch(p){console.error("Failed to load agent usage:",p)}})()},[t]);const L=i.useCallback(async(c,p)=>{try{p?g(!0):b(!0);const f=(await $.getAnalyticsRecentConversations(de,c,m!=="all"?m:void 0,_||void 0,u,t)).data;o(J=>p?f.conversations:[...J,...f.conversations]),V(f.total),K(f.has_more),P(c+f.conversations.length)}catch(y){console.error("Failed to load conversations:",y),C.error("Failed to load recent conversations")}finally{g(!1),b(!1)}},[_,m,u,t]);i.useEffect(()=>{P(0),o([]),L(0,!0)},[L]);const X=async()=>{try{v(!0),await $.exportQueriesCSV(u,m!=="all"?m:void 0,_||void 0,t),C.success("CSV exported successfully")}catch(c){const p=c instanceof Error?c.message:"Failed to export CSV";C.error(p)}finally{v(!1)}};
1return e.jsxs("div",{className:"rcp-panel",children:[e.jsxs("div",{className:"rcp-header",children:[e.jsxs("h3",{className:"chart-title",children:[e.jsx(B,{size:18}),"Recent Conversations",e.jsxs("span",{className:"rcp-count",children:[I," chats"]})]}),e.jsxs("div",{className:"rcp-filters",children:[e.jsxs("select",{className:"rcp-filter-select",value:u??"",onChange:c=>O(c.target.value?Number(c.target.value):void 0),children:[e.jsx("option",{value:"",children:"All Time"}),e.jsx("option",{value:"1",children:"Today"}),e.jsx("option",{value:"7",children:"Last 7 days"}),e.jsx("option",{value:"30",children:"Last 30 days"}),e.jsx("option",{value:"90",children:"Last 90 days"})]}),e.jsxs("select",{className:"rcp-filter-select",value:m,onChange:c=>d(c.target.value),children:[e.jsx("option",{value:"all",children:"All Agents"}),n.map(c=>e.jsxs("option",{value:c.agent,children:[S(c.agent)," (",c.queries,")"]},c.agent))]}),e.jsxs("label",{className:"rcp-search",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}),e.jsx("input",{className:"rcp-search-input",type:"search",placeholder:"Search queries…",value:w,onChange:c=>G(c.target.value)})]}),e.jsx(ae,{checked:t,onChange:r}),e.jsx("button",{type:"button",className:"rcp-export-btn",onClick:X,disabled:k,children:k?"Exporting…":"Export CSV"})]})]}),x?e.jsxs("div",{className:"rcp-loading",children:[e.jsx("div",{className:"rcp-spinner"}),e.jsx("span",{children:"Loading conversations…"})]}):l.length===0?e.jsxs("div",{className:"rcp-empty-state",children:[e.jsx("p",{children:"No conversations found"}),(m!=="all"||_)&&e.jsx("p",{className:"rcp-empty-hint",children:"Try adjusting your filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rcp-list",children:l.map(c=>{const p=R(c.user_hash,s);return e.jsxs("button",{type:"button",className:"rcp-card",onClick:()=>q(c),children:[e.jsxs("div",{className:"rcp-card-top",children:[e.jsx("div",{className:"rcp-card-main",children:e.jsxs("div",{className:"rcp-card-title-row",children:[e.jsxs("div",{className:"rcp-card-title-left",children:[e.jsx(h,{agentType:c.agent_type,size:34,layout:"stacked"}),e.jsxs("div",{className:"rcp-card-inline-meta",children:[e.jsx(F,{hash:c.user_hash,isDark:s}),c.is_guest&&e.jsx(U,{}),e.jsxs("span",{className:"rcp-query-count",children:[c.query_count," question",c.query_count===1?"":"s"]})]})]}),e.jsx("span",{className:"rcp-card-time",children:j(c.last_activity_at)})]})}),e.jsx(ne,{size:18,className:"rcp-card-chevron"})]}),e.jsx("ul",{className:"rcp-query-preview",children:c.user_queries.map((y,f)=>e.jsxs("li",{style:{background:p.messageBg,borderColor:p.messageBorder,color:p.color},children:[e.jsx("span",{className:"rcp-query-index",style:{background:p.bg,color:p.color,border:`1px solid ${p.border}`},children:f+1}),e.jsx("span",{className:"rcp-query-text",children:y.text||e.jsx("em",{children:"Empty query"})})]},y.id))})]},c.conversation_id)})}),W&&e.jsx("div",{className:"rcp-load-more",children:e.jsx("button",{type:"button",className:"rcp-load-more-btn",onClick:()=>L(Q,!1),disabled:N,children:N?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rcp-spinner rcp-spinner--small"}),"Loading…"]}):e.jsxs(e.Fragment,{children:["Load more (",I-l.length," remaining)"]})})})]}),A&&e.jsx(Ne,{conversationId:A.conversation_id,summary:A,includeAdmins:t,onClose:()=>q(null)})]})}function Re(){return e.jsxs("div",{className:"analytics-page",children:[e.jsx(Y,{}),e.jsx("div",{className:"analytics-header",children:e.jsxs("div",{children:[e.jsxs("h1",{children:[e.jsx(B,{size:28,strokeWidth:2}),"Recent Conversations"]}),e.jsx("p",{className:"analytics-subtitle",children:"Grouped chat view with Orion metadata and anonymized user data"})]})}),e.jsx("div",{className:"chart-card analytics-widget-card",children:e.jsx(ye,{})})]})}export{Re as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.