PageSourceSearch

https://markwise.app/js/ChatHistoryPage-Dlztu6U6.js

js markwise.app collected 2026-09-24 13:44:25 UTC 7,047 bytes, 1 lines download raw bytes

1import{a as T}from"./rolldown-runtime-M0oDzQ_3.js";import{c as S,d as A,l as M,u as E}from"./mw-events-DL4GPaTJ.js";import{a as L,o as H}from"./animation-vendor-BTgXq0V2.js";import{_ as I}from"./dashboard-provider-EkyrAMoA.js";import{o as F}from"./utils-BebnwCks.js";import{u as q}from"./chunk-EVOBXE3Y-B2g1H80g.js";import{n as O}from"./dist-CK74me5t.js";import{C as N,N as Y,Q as C,cn as z,h as P}from"./lucide-react-B5Mqw2VM.js";import{w as R}from"./copilot-utils-DpOGymRv.js";import{E as B,T as X,Xt as v,_ as $,b as G,g as Q,h as U,m as V,p as J,v as K,x as W,y as Z}from"./index-Cs8jPAIC.js";var m=T(H(),1),e=L(),ue=()=>{const a=q(),{hasAccess:n}=I(),{data:o,isLoading:u,isError:x,refetch:p}=X(1,50),s=(0,m.useMemo)(()=>o?.conversations??[],[o]),h=B(),[i,d]=(0,m.useState)(""),[l,c]=(0,m.useState)(null),b=(0,m.useRef)(!1);(0,m.useEffect)(()=>{n||a("/",{replace:!0})},[n,a]),(0,m.useEffect)(()=>{!n||b.current||o&&(b.current=!0,A({conversation_count:s.length}))},[n,o,s.length]),(0,m.useEffect)(()=>{const t=i.trim();if(!t)return;const r=setTimeout(()=>{const g=s.filter(f=>f.title.toLowerCase().includes(t.toLowerCase())).length;E({query_length:t.length,result_count:g})},500);return()=>clearTimeout(r)},[i,s]);const D=()=>{if(!l)return;const t=s.find(r=>r.id===l);h.mutate(l,{onSuccess:()=>{S({conversation_id:l,message_count:j(t)}),c(null)},onError:()=>{O.error("Failed to delete conversation. Please try again."),c(null)}})},k=t=>{const r=Math.max(0,Math.floor((Date.now()-new Date(t.updated_at).getTime())/864e5));M({conversation_id:t.id,age_days:r,message_count:j(t)}),a(`/chat/${t.id}`)},w=i.trim()?s.filter(t=>t.title.toLowerCase().includes(i.trim().toLowerCase())):s,_=ee(w);return(0,e.jsxs)("div",{className:"mx-auto max-w-3xl px-4 pt-4 pb-24 md:pb-8",children:[(0,e.jsxs)("div",{className:"mb-5 flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-foreground text-lg font-bold tracking-tight",children:"Conversations"}),s.length>0&&(0,e.jsxs)("p",{className:"text-muted-foreground text-xs",children:[s.length," total"]})]}),(0,e.jsxs)(v,{variant:"outline",size:"sm",onClick:()=>a("/"),children:[(0,e.jsx)(N,{className:"mr-1.5 h-3.5 w-3.5"}),"New chat"]})]}),s.length>3&&(0,e.jsx)("div",{className:"mb-4",children:(0,e.jsxs)("div",{className:"bg-muted/50 flex items-center gap-2 rounded-xl px-3 py-2.5",children:[(0,e.jsx)(Y,{className:"text-muted-foreground h-4 w-4 shrink-0"}),(0,e.jsx)("input",{value:i,onChange:t=>d(t.target.value),placeholder:"Search conversations...",className:"text-foreground placeholder:text-muted-foreground w-full bg-transparent text-sm outline-none"}),i&&(0,e.jsx)("button",{onClick:()=>d(""),className:"text-muted-foreground hover:text-foreground",children:(0,e.jsx)(z,{className:"h-3.5 w-3.5"})})]})}),u||x?(0,e.jsx)(J,{isLoading:u,isError:x,onRetry:()=>p()}):s.length===0?(0,e.jsxs)("div",{className:"py-16 text-center",children:[(0,e.jsx)(C,{className:"text-muted-foreground/60 mx-auto mb-3 h-10 w-10"}),(0,e.jsx)("p",{className:"text-foreground mb-1 text-sm font-semibold",children:"No conversations yet"}),(0,e.jsx)("p",{className:"text-muted-foreground mb-4 text-xs",children:"Your past conversations will appear here"}),(0,e.jsxs)(v,{size:"sm",onClick:()=>a("/"),children:[(0,e.jsx)(N,{className:"mr-1.5 h-3.5 w-3.5"}),"Start a conversation"]})]}):w.length===0?(0,e.jsxs)("div",{className:"py-12 text-center",children:[(0,e.jsxs)("p",{className:"text-muted-foreground mb-2 text-sm",children:['No results for "',i,'"']}),(0,e.jsx)(v,{variant:"ghost",size:"sm",onClick:()=>d(""),children:"Clear search"})]}):(0,e.jsx)("div",{className:"space-y-5",children:_.map(t=>(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-muted-foreground mb-2 px-1 text-[10px] font-semibold tracking-wider uppercase",children:t.label}),(0,e.jsx)("div",{className:"bg-card divide-border/40 divide-y rounded-xl border",children:t.items.map(r=>{const g=R(r.messages?.[0]?.content??"").slice(0,80),f=j(r),y=r.attached_items?.length??0;return(0,e.jsxs)("div",{className:"group mwds-row-hover flex items-start first:rounded-t-xl last:rounded-b-xl",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>k(r),className:"focus-visible:ring-primary flex min-w-0 flex-1 items-start gap-3 rounded-l-xl px-4 py-3 text-left focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none",children:[(0,e.jsx)("div",{className:"bg-muted text-muted-foreground mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg",children:(0,e.jsx)(C,{className:"h-3.5 w-3.5"})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,e.jsx)("p",{className:"text-foreground truncate text-sm font-semibold",children:r.title}),(0,e.jsx)("span",{className:"text-muted-foreground shrink-0 text-[10px]",children:te(r.updated_at)})]}),g&&(0,e.jsx)("p",{className:"text-muted-foreground mt-0.5 truncate text-xs",children:g}),(0,e.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[f>0&&(0,e.jsx)("span",{className:"text-muted-foreground text-[10px]",children:F(f,"message")}),y>0&&(0,e.jsxs)("span",{className:"text-muted-foreground text-[10px]",children:[y," attached"]})]})]})]}),(0,e.jsx)("button",{type:"button",onClick:()=>c(r.id),className:"text-muted-foreground hover:text-destructive focus-visible:ring-destructive mt-1.5 mr-2 flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center rounded-lg opacity-60 transition-all hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100","aria-label":`Delete conversation: ${r.title||"Untitled chat"}`,children:(0,e.jsx)(P,{className:"h-3.5 w-3.5"})})]},r.id)})})]},t.label))}),(0,e.jsx)(V,{open:!!l,onOpenChange:t=>!t&&c(null),children:(0,e.jsxs)($,{children:[(0,e.jsxs)(G,{children:[(0,e.jsx)(W,{children:"Delete conversation?"}),(0,e.jsx)(K,{children:"This conversation will be permanently deleted. This action cannot be undone."})]}),(0,e.jsxs)(Z,{children:[(0,e.jsx)(Q,{children:"Cancel"}),(0,e.jsx)(U,{onClick:D,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})};function ee(a){const n=[],o=new Date,u=new Date(o.getFullYear(),o.getMonth(),o.getDate()),x=new Date(u.getTime()-864e5),p=new Date(u.getTime()-7*864e5),s=[],h=[],i=[],d=[];for(const l of a){const c=new Date(l.updated_at);c>=u?s.push(l):c>=x?h.push(l):c>=p?i.push(l):d.push(l)}return s.length&&n.push({label:"Today",items:s}),h.length&&n.push({label:"Yesterday",items:h}),i.length&&n.push({label:"This week",items:i}),d.length&&n.push({label:"Older",items:d}),n}function j(a){return a?.message_count??a?.messages?.length??0}function te(a){const n=new Date(a),o=new Date;return n>=new Date(o.getFullYear(),o.getMonth(),o.getDate())?n.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}export{ue 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.