1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4236,4844],{43100:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/migration",function(){return s(87261)}])},87261:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>z});var a=s(37876),n=s(14232),r=s(38203),i=s(79984),o=s(30207),l=s(17210),c=s(61150),d=s(498),x=s(86739),m=s(3609),u=s(79516),g=s(1312),h=s(11713);let p=(0,h.A)("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),b=(0,h.A)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var j=s(77328),v=s.n(j);let y=e=>{let{children:t}=e,[s,r]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{let e=e=>{console.log("â Global error caught: ".concat(e.message)),r(!1)};return window.addEventListener("error",e),window.addEventListener("unhandledrejection",e),()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",e)}},[]),s)?(0,a.jsx)("div",{children:"Something went wrong, but we're handling it gracefully."}):t},f=()=>{let{user:e,isLoaded:t}=(0,i.Jd)(),[s,h]=(0,n.useState)([]),[j,y]=(0,n.useState)(!0),[f,z]=(0,n.useState)(null),[k,N]=(0,n.useState)({summaryStatus:"all",sortBy:"updatedAt",sortOrder:"desc"}),[w,S]=(0,n.useState)(""),[D,C]=(0,n.useState)({page:1,limit:5,total:0,totalPages:0}),[_,A]=(0,n.useState)(new Set),[I,E]=(0,n.useState)(!1),[P,M]=(0,n.useState)({total:0,hasSummaryId:0,noSummaryId:0,migrationCompleted:0});(0,n.useEffect)(()=>{t&&O()},[t,k,D.page,w]);let O=async()=>{try{let e;y(!0);let t=new URLSearchParams({page:D.page,limit:1e3,sortBy:k.sortBy,sortOrder:k.sortOrder,..."all"!==k.summaryStatus&&{summaryStatus:k.summaryStatus},...w&&{search:w}}),s=await fetch("/api/migration/conversations?".concat(t));try{e=await s.json()}catch(e){console.log("â Failed to parse conversations response: ".concat(e.message));return}if(!s.ok){console.log("â Failed to fetch conversations (".concat(s.status,"): ").concat(e.error||"Unknown error"));return}h(e.conversations||[]),C(t=>{var s,a;return{...t,total:(null===(s=e.pagination)||void 0===s?void 0:s.total)||0,totalPages:(null===(a=e.pagination)||void 0===a?void 0:a.totalPages)||0}}),M(e.stats||{total:0,hasSummaryId:0,noSummaryId:0,migrationCompleted:0})}catch(e){console.log("â Error fetching conversations: ".concat(e.message))}finally{y(!1)}},F=e=>{let t=!!e.summaryId;return e.migrationCompleted?{status:"completed",label:"Migration Completed",icon:d.A,colorClass:"text-green-600 dark:text-green-400",bgClass:"bg-green-50 dark:bg-green-900/20"}:t?{status:"has_summary_id",label:"Has Summary ID",icon:x.A,colorClass:"text-blue-600 dark:text-blue-400",bgClass:"bg-blue-50 dark:bg-blue-900/20"}:{status:"none",label:"No Summary ID",icon:m.A,colorClass:"text-red-600 dark:text-red-400",bgClass:"bg-red-50 dark:bg-red-900/20"}},R=e=>{let t=new Set(_);t.has(e)?t.delete(e):t.add(e),A(t)},T=async()=>{if(0!==_.size){console.log("\uD83D\uDE80 Starting migration for ".concat(_.size," selected conversations")),E(!0);try{let e,t=await fetch("/api/migration/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversationIds:Array.from(_)})});try{e=await t.json()}catch(e){console.log("â Failed to parse response: ".concat(e.message));return}if(!t.ok){console.log("â API Error (".concat(t.status,"): ").concat(e.error||"Unknown error")),e.error&&console.log("\uD83D\uDCCB Error details: ".concat(JSON.stringify(e,null,2)));return}if(console.log("\n\uD83C\uDFAF Frontend Migration Results Summary:"),e&&e.results&&Array.isArray(e.results)){let t=e.results.filter(e=>e.status&&e.status.includes("completed")).length,s=e.results.filter(e=>"pending_generation"===e.status).length,a=e.results.filter(e=>e.status&&e.status.includes("error")).length,n=e.results.filter(e=>"skipped"===e.status).length;t>0&&console.log("â
".concat(t," conversations completed migration")),s>0&&console.log("â³ ".concat(s," conversations still generating summaries")),a>0&&console.log("â ".concat(a," conversations had errors")),n>0&&console.log("âï¸ ".concat(n," conversations skipped (already completed)")),console.log("\uD83D\uDCCA Total processed: ".concat(e.processedCount||0," conversations"))}try{console.log("\uD83D\uDD04 Refreshing conversation list..."),await O(),console.log("â
Conversation list refreshed successfully")}catch(e){console.log("â ï¸ Warning: Failed to refresh conversation list: ".concat(e.message))}
1A(new Set)}catch(e){console.log("â Frontend error during migration: ".concat(e.message)),console.log("\uD83D\uDD0D Error stack: ".concat(e.stack))}finally{E(!1)}}},L=async e=>{console.log("\uD83D\uDE80 Starting migration for specific conversation: ".concat(e)),E(!0);try{let t,s=await fetch("/api/migration/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversationIds:[e]})});try{t=await s.json()}catch(e){console.log("â Failed to parse response: ".concat(e.message));return}if(!s.ok){console.log("â API Error (".concat(s.status,"): ").concat(t.error||"Unknown error")),t.error&&console.log("\uD83D\uDCCB Error details: ".concat(JSON.stringify(t,null,2)));return}if(console.log("\n\uD83C\uDFAF Individual Migration Results:"),t&&t.results&&Array.isArray(t.results)&&t.results[0]){let e=t.results[0];e.status&&e.status.includes("completed")?console.log("â
Migration completed successfully"):"pending_generation"===e.status?console.log("â³ Summary still generating, run again later"):e.status&&e.status.includes("error")?console.log("â Migration had an error: ".concat(e.message||"Unknown error")):"skipped"===e.status&&console.log("âï¸ Migration skipped (already completed)")}console.log("\uD83D\uDCCA Migration completed for conversation");try{console.log("\uD83D\uDD04 Refreshing conversation list..."),await O(),console.log("â
Conversation list refreshed successfully")}catch(e){console.log("â ï¸ Warning: Failed to refresh conversation list: ".concat(e.message))}}catch(e){console.log("â Frontend error during individual migration: ".concat(e.message)),console.log("\uD83D\uDD0D Error stack: ".concat(e.stack))}finally{E(!1)}};return t?j?(0,a.jsxs)(o.A,{children:[(0,a.jsx)(l.A,{}),(0,a.jsx)("div",{className:"flex-1 p-6",children:(0,a.jsx)("div",{className:"animate-pulse",children:"Loading conversations..."})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(v(),{children:[(0,a.jsx)("title",{children:"Migration Dashboard - Summary Management"}),(0,a.jsx)("meta",{name:"description",content:"Manage conversation summaries and migration status"})]}),(0,a.jsxs)(o.A,{children:[(0,a.jsx)(l.A,{}),(0,a.jsx)("div",{className:"flex-1 p-6 overflow-auto",children:(0,a.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold text-zinc-900 dark:text-zinc-100 mb-2",children:"Migration Dashboard"}),(0,a.jsx)("p",{className:"text-zinc-600 dark:text-zinc-400",children:"Manage conversation summaries and track migration status to the new summary system"}),(0,a.jsx)("div",{className:"mt-2 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:(0,a.jsxs)("p",{className:"text-blue-700 dark:text-blue-300 text-sm",children:[(0,a.jsx)("strong",{children:"Admin View:"})," Showing incomplete migrations from all users with 4+ messages (completed migrations are hidden)"]})})]}),(0,a.jsxs)("div",{className:"bg-white dark:bg-zinc-800 rounded-lg border border-zinc-200 dark:border-zinc-700 p-6 mb-6",children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-4 items-center justify-between mb-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-4 items-center",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(u.A,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-zinc-400",size:16}),(0,a.jsx)("input",{type:"text",value:w,onChange:e=>S(e.target.value),placeholder:"Search conversations...",className:"pl-10 pr-4 py-2 border border-zinc-300 dark:border-zinc-600 rounded-md bg-white dark:bg-zinc-700 text-zinc-900 dark:text-zinc-100 w-64"})]}),(0,a.jsxs)("select",{value:k.summaryStatus,onChange:e=>N(t=>({...t,summaryStatus:e.target.value})),className:"px-3 py-2 border border-zinc-300 dark:border-zinc-600 rounded-md bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100",children:[(0,a.jsx)("option",{value:"all",children:"All Pending"}),(0,a.jsx)("option",{value:"none",children:"Need Summary"}),(0,a.jsx)("option",{value:"has_summary_id",children:"Ready to Migrate"})]}),(0,a.jsxs)("select",{value:"".concat(k.sortBy,"_").concat(k.sortOrder),onChange:e=>{let[t,s]=e.target.value.split("_");N(e=>({...e,sortBy:t,sortOrder:s}))},className:"px-3 py-2 border border-zinc-300 dark:border-zinc-600 rounded-md bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100",children:[(0,a.jsx)("option",{value:"updatedAt_desc",children:"Recent First"}),(0,a.jsx)("option",{value:"updatedAt_asc",children:"Oldest First"}),(0,a.jsx)("option",{value:"title_asc",children:"Title A-Z"}),(0,a.jsx)("option",{value:"title_desc",children:"Title Z-A"})]})]}),(0,a.jsxs)(c.A,{onClick:O,disabled:j,className:"flex items-center gap-2",children:[(0,a.jsx)(g.A,{size:16}),"Refresh"]})]}),(0,a.jsx)(r.If,{condition:_.size>0,children:(0,a.jsx)(r.al,{children:(0,a.jsxs)("div",{className:"flex items-center gap-4 p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800",children:[(0,a.jsxs)("span",{className:"text-blue-700 dark:text-blue-300 font-medium",children:[_.size," conversation",1!==_.size?"s":""," selected"]}),(0,a.jsx)("div",{className:"flex gap-2",children:(0,a.jsxs)(c.A,{variation:"primary",onClick:e=>{try{e.preventDefault(),e.stopPropagation(),T()}catch(e){console.log("â Click handler error: ".concat(e.message))}},disabled:I,className:"flex items-center gap-2",children:[(0,a.jsx)(p,{size:16}),(0,a.jsxs)(r.If,{condition:I,children:[(0,a.jsx)(r.al,{children:"Running..."}),(0,a.jsx)(r._I,{children:"Run"})]})]})})]})})})]}),(0,a.jsx)(r.If,{condition:f,children:(0,a.jsx)(r.al,{children:(0,a.jsxs)("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-6",children:["Error: ",f]})})}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-6",children:[(0,a.jsxs)("div",{className:"bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-4",children:[(0,a.jsx)("div",{className:"text-2xl font-bold text-zinc-900 dark:text-zinc-100",children:(null==P?void 0:P.total)||0}),(0,a.jsx)("div",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Pending Migrations"})]}),(0,a.jsxs)("div",{className:"bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-4",children:[(0,a.jsx)("div",{className:"text-2xl font-bold text-blue-600 dar
1k:text-blue-400",children:(null==P?void 0:P.hasSummaryId)||0}),(0,a.jsx)("div",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Ready to Migrate"})]}),(0,a.jsxs)("div",{className:"bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg p-4",children:[(0,a.jsx)("div",{className:"text-2xl font-bold text-orange-600 dark:text-orange-400",children:(null==P?void 0:P.noSummaryId)||0}),(0,a.jsx)("div",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Need Summary"})]})]}),(0,a.jsxs)("div",{className:"bg-white dark:bg-zinc-800 rounded-lg border border-zinc-200 dark:border-zinc-700 overflow-hidden",children:[(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full",children:[(0,a.jsx)("thead",{className:"bg-zinc-50 dark:bg-zinc-900 border-b border-zinc-200 dark:border-zinc-700",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-3 text-left",children:(0,a.jsx)("input",{type:"checkbox",checked:s.length>0&&_.size===s.length,onChange:()=>{_.size===s.length?A(new Set):A(new Set(s.map(e=>e._id)))},className:"rounded border-zinc-300 dark:border-zinc-600"})}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-sm font-semibold text-zinc-900 dark:text-zinc-100",children:"Conversation"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-sm font-semibold text-zinc-900 dark:text-zinc-100",children:"Messages"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-sm font-semibold text-zinc-900 dark:text-zinc-100",children:"Summary Status"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-sm font-semibold text-zinc-900 dark:text-zinc-100",children:"Summary ID"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-sm font-semibold text-zinc-900 dark:text-zinc-100",children:"Actions"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-zinc-200 dark:divide-zinc-700",children:(0,a.jsxs)(r.If,{condition:0===s.length,children:[(0,a.jsx)(r.al,{children:(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"6",className:"px-4 py-8 text-center text-zinc-500 dark:text-zinc-400",children:"No conversations found"})})}),(0,a.jsx)(r._I,{children:s.map(e=>{let t=F(e),s=t.icon;return(0,a.jsxs)("tr",{className:"hover:bg-zinc-50 dark:hover:bg-zinc-700/50",children:[(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsx)("input",{type:"checkbox",checked:_.has(e._id),onChange:()=>R(e._id),className:"rounded border-zinc-300 dark:border-zinc-600"})}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"font-medium text-zinc-900 dark:text-zinc-100 truncate max-w-xs",children:e.title}),(0,a.jsxs)("div",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:["ID: ",e._id]})]})}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("span",{className:"font-medium text-zinc-900 dark:text-zinc-100",children:e.messageCount||0}),(0,a.jsx)("div",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"messages"})]})}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsxs)("span",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-medium ".concat(t.bgClass," ").concat(t.colorClass),children:[(0,a.jsx)(s,{size:12}),t.label]})}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsxs)(r.If,{condition:e.summaryId,children:[(0,a.jsx)(r.al,{children:(0,a.jsx)("code",{className:"text-xs bg-zinc-100 dark:bg-zinc-700 px-2 py-1 rounded",children:e.summaryId})}),(0,a.jsx)(r._I,{children:(0,a.jsx)("span",{className:"text-zinc-400 dark:text-zinc-500 text-sm",children:"None"})})]})}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.A,{tiny:!0,tooltip:"View Conversation",onClick:t=>{t.preventDefault(),t.stopPropagation(),window.open("/conversation/".concat(e._id),"_blank")},children:(0,a.jsx)(b,{size:12})}),(0,a.jsx)(r.If,{condition:!e.migrationCompleted,children:(0,a.jsx)(r.al,{children:(0,a.jsx)(c.A,{tiny:!0,variation:"primary",tooltip:"Run Migration Process",onClick:async t=>{try{t.preventDefault(),t.stopPropagation(),await L(e._id)}catch(e){console.log("â Individual click handler error: ".concat(e.message))}},children:(0,a.jsx)(p,{size:12})})})})]})})]},e._id)})})]})})]})}),(0,a.jsx)(r.If,{condition:D.totalPages>1,children:(0,a.jsx)(r.al,{children:(0,a.jsxs)("div",{className:"px-4 py-3 border-t border-zinc-200 dark:border-zinc-700 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:["Showing ",(D.page-1)*D.limit+1," to ",Math.min(D.page*D.limit,D.total)," of ",D.total," conversations"]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(c.A,{onClick:()=>C(e=>({...e,page:e.page-1})),disabled:D.page<=1,className:"text-sm",children:"Previous"}),(0,a.jsxs)("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:["Page ",D.page," of ",D.totalPages]}),(0,a.jsx)(c.A,{onClick:()=>C(e=>({...e,page:e.page+1})),disabled:D.page>=D.totalPages,className:"text-sm",children:"Next"})]})]})})})]})]})})]})]}):(0,a.jsx)("div",{children:"Loading..."})},z=()=>(0,a.jsx)(y,{children:(0,a.jsx)(f,{})})}},e=>{var t=t=>e(e.s=t);e.O(0,[347,1327,8230,3474,3005,3,5979,6658,9591,636,6593,8792],()=>t(43100)),_N_E=e.O()}]);
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.