codesesh 0.7.0 → 0.7.1

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.
@@ -79,7 +79,7 @@ import {
79
79
  syncSessionSearchIndexChanges,
80
80
  upsertBookmark,
81
81
  withEstimatedSessionCost
82
- } from "./chunk-JTHZVP6G.js";
82
+ } from "./chunk-7GQEIPVK.js";
83
83
  export {
84
84
  BaseAgent,
85
85
  BookmarkStorageUnavailableError,
@@ -161,4 +161,4 @@ export {
161
161
  upsertBookmark,
162
162
  withEstimatedSessionCost
163
163
  };
164
- //# sourceMappingURL=dist-FQAQSHHO.js.map
164
+ //# sourceMappingURL=dist-L4XKQDGX.js.map
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  searchFileActivitySessions,
30
30
  searchSessions,
31
31
  upsertBookmark
32
- } from "./chunk-JTHZVP6G.js";
32
+ } from "./chunk-7GQEIPVK.js";
33
33
 
34
34
  // src/index.ts
35
35
  import { defineCommand, runMain } from "citty";
@@ -2480,7 +2480,7 @@ var main = defineCommand({
2480
2480
  log_path: appLogger.getLogPath()
2481
2481
  });
2482
2482
  if (clearCache) {
2483
- const { clearCache: clear } = await import("./dist-FQAQSHHO.js");
2483
+ const { clearCache: clear } = await import("./dist-L4XKQDGX.js");
2484
2484
  clear();
2485
2485
  appLogger.info("cache.clear");
2486
2486
  console.log("Cache cleared.");
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createRegisteredAgents
4
- } from "./chunk-JTHZVP6G.js";
4
+ } from "./chunk-7GQEIPVK.js";
5
5
 
6
6
  // src/scan-refresh-worker.ts
7
7
  import { parentPort, workerData } from "worker_threads";
@@ -6,7 +6,7 @@ import {
6
6
  saveCachedSessions,
7
7
  syncSessionSearchIndex,
8
8
  syncSessionSearchIndexChanges
9
- } from "./chunk-JTHZVP6G.js";
9
+ } from "./chunk-7GQEIPVK.js";
10
10
 
11
11
  // src/search-index-worker.ts
12
12
  import { parentPort, workerData } from "worker_threads";
@@ -3,7 +3,7 @@ import {
3
3
  classifySessionTags,
4
4
  createRegisteredAgents,
5
5
  getSmartTagSourceTimestamp
6
- } from "./chunk-JTHZVP6G.js";
6
+ } from "./chunk-7GQEIPVK.js";
7
7
 
8
8
  // src/smart-tag-worker.ts
9
9
  import { parentPort, workerData } from "worker_threads";
@@ -105,4 +105,4 @@ ${n.map(([e,n])=>{let r=n.theme?.[t]??n.color;return r?` --color-${e}: ${r};`:n
105
105
  [data-type='item'][data-item-type='file'] [data-truncate-marker] {
106
106
  display: none;
107
107
  }
108
- `;function Ba(e){return e.replaceAll(`/`,`∕`).trim()||`(untitled)`}function Va(e){return e.replace(/\/+$/,``).split(`/`).at(-1)?.trim()||`(unknown)`}function Ha(e){let t=e.project_identity;if(t)return{key:`${t.kind}:${t.key}`,label:t.displayName||Va(e.directory)};let n=Va(e.directory);return{key:n===`(unknown)`?`__unknown__`:`path:${e.directory||n}`,label:n}}function Ua(e){return e.time_updated??e.time_created}function Wa(e,t,n){let r=e.get(t.path)??2**53-1,i=e.get(n.path)??2**53-1;return r===i?t.path.localeCompare(n.path):r-i}function Ga(e){let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Set,c=[],l=new Map;for(let t of e){let{key:e,label:n}=Ha(t),r=l.get(e);r?r.sessions.push(t):l.set(e,{label:n,sessions:[t]})}let u=[...l.entries()].sort(([,e],[,t])=>{if(e.label===`(unknown)`)return 1;if(t.label===`(unknown)`)return-1;let n=Math.max(...e.sessions.map(Ua));return Math.max(...t.sessions.map(Ua))-n}),d=0,f=new Set;for(let[,e]of u){let l=Ba(e.label),u=`${l}/`,p=2;for(;f.has(u);)u=`${l} (${p})/`,p+=1;f.add(u);let m=u.slice(0,-1),h=new Map;t.set(u,d),t.set(m,d),d+=1,a.set(u,`${e.sessions.length}`),a.set(m,`${e.sessions.length}`);for(let t of e.sessions)h.set(t.title,(h.get(t.title)??0)+1);for(let a of e.sessions){let e=(h.get(a.title)??0)>1?`${Ba(a.title)} #${a.id.slice(0,8)}`:Ba(a.title),l=`${u}${e}`,f=2;for(;s.has(l);)l=`${u}${e} (${f})`,f+=1;s.add(l),c.push(l),t.set(l,d),d+=1,n.set(a.id,l),r.set(a.id,u),i.set(l,a.id),o.set(l,a)}}return{paths:c,sortOrderByPath:t,pathBySessionId:n,groupPathBySessionId:r,sessionIdByPath:i,groupCountByPath:a,sessionByPath:o}}function Ka({sessions:e,activeSessionId:t,selectedSessionId:n,onSelectSession:r,bookmarkedSessionIds:a,onToggleBookmark:s}){let c=(0,j.useMemo)(()=>Ga(e),[e]),l=(0,j.useRef)(c.sortOrderByPath),u=(0,j.useRef)(c.sessionIdByPath),d=(0,j.useRef)(c.groupCountByPath),f=(0,j.useRef)(c.sessionByPath),p=(0,j.useRef)(a),m=(0,j.useRef)(r),h=(0,j.useRef)(s),g={"--trees-bg-override":`transparent`,"--trees-border-color-override":`var(--console-border)`,"--trees-fg-override":`var(--console-text)`,"--trees-fg-muted-override":`var(--console-muted)`,"--trees-font-family-override":`"JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace`,"--trees-font-size-override":`12px`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`8px`,"--trees-selected-bg-override":`var(--console-surface-muted)`},{model:_}=o({flattenEmptyDirectories:!1,initialExpansion:`closed`,paths:c.paths,sort:(e,t)=>Wa(l.current,e,t),density:`compact`,unsafeCSS:za,onSelectionChange(e){let t=u.current.get(e[0]??``);t&&m.current(t)},renderRowDecoration({item:e}){let t=f.current.get(e.path);if(t){let e=p.current.has(t.id);return{text:e?`★`:`☆`,title:e?`Remove bookmark`:`Add bookmark`}}return d.current.get(e.path)?{text:d.current.get(e.path),title:`Sessions`}:null}});(0,j.useEffect)(()=>{l.current=c.sortOrderByPath,u.current=c.sessionIdByPath,d.current=c.groupCountByPath,f.current=c.sessionByPath,_.resetPaths(c.paths)},[_,c]),(0,j.useEffect)(()=>{m.current=r},[r]),(0,j.useEffect)(()=>{p.current=a,_.resetPaths(c.paths)},[a,_,c.paths]),(0,j.useEffect)(()=>{h.current=s},[s]);function ee(e){let t=e.nativeEvent.composedPath(),n=t.find(e=>e instanceof HTMLElement&&e.parentElement?.getAttribute(`data-item-section`)===`decoration`),r=t.find(e=>e instanceof HTMLElement&&e.getAttribute(`data-type`)===`item`),i=r?f.current.get(r.getAttribute(`data-item-path`)??``):null;!n||!i||(e.preventDefault(),e.stopPropagation(),h.current(i))}return(0,j.useEffect)(()=>{let e=c.pathBySessionId.get(t??``),r=c.pathBySessionId.get(n??``)??e,i=n??t??``,a=c.groupPathBySessionId.get(i);if(e&&_.getItem(e)?.select(),r&&t){let e=a?_.getItem(a):null;e&&`expand`in e&&e.expand(),_.focusPath(r);return}a&&_.focusPath(a)},[t,_,c,n]),(0,F.jsx)(`div`,{className:`session-tree h-[min(560px,calc(100vh-410px))] min-h-56 overflow-hidden`,style:g,onClickCapture:ee,children:(0,F.jsx)(i,{model:_,style:{height:`100%`},"aria-label":`Sessions`})})}function qa(e,t){return(t.time_updated??t.time_created)-(e.time_updated??e.time_created)}function Ja(e){return e.slug.split(`/`)[0]?.toLowerCase()||`unknown`}function Ya(e,t){return`${e.toLowerCase()}/${t}`}function Xa(e,t){return`${e}\0${t.toLowerCase()}`}function Za(e,t,n){let r=e.get(t);if(r){r.push(n);return}e.set(t,[n])}function Qa(e,t){let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c=new Map,l=new Map,u=[],d=new Set(t.map(e=>e.name.toLowerCase()));for(let e of d)r.set(e,[]),s.set(e,[]);for(let t of e){let e=Ja(t),r={...t,agentKey:e,sessionSlug:t.id,fullPath:t.slug};u.push(r);let i=Ya(e,t.id);n.has(i)||n.set(i,t),d.has(e)&&s.get(e).push(r);let a=t.project_identity;if(!a?.key)continue;Za(c,Hi(a),r);let o=l.get(a.key);o?o.count+=1:l.set(a.key,{key:a.key,label:a.displayName||t.directory,count:1})}let f=e.toSorted(qa);for(let e of f){let t=Ja(e);d.has(t)&&r.get(t).push(e);let n=e.project_identity;if(!n?.key)continue;let s=Hi(n);Za(i,s,e),Za(a,Xa(s,t),e),Za(o,n.key,e)}return{byRouteKey:n,byAgent:r,byProjectIdentityKey:i,byProjectAgentKey:a,byProjectKey:o,byLandingAgent:s,byLandingProjectIdentityKey:c,landingSessions:u,sessionsByActivity:f,projectOptions:[...l.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)}}function $a(e){let t=new Map,n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r];t.has(i.id)||(t.set(i.id,i),n.set(i.id,r))}return{byId:t,indexById:n}}function eo(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?n.split(`/`).map(e=>e.trim()).filter(Boolean):[];if(r.length===0)return{mode:`root`,activeAgentKey:null,activeSessionSlug:null};if(r[0]?.toLowerCase()===`projects`){if(r.length===1)return{mode:`projects`,activeAgentKey:null,activeSessionSlug:null};if(r.length===3)try{let e=decodeURIComponent(r[1]);return Vi(e)?{mode:`project`,activeAgentKey:null,activeSessionSlug:null,activeProjectKind:e,activeProjectKey:Ui(r[2])}:{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}catch{return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}if(r.length===1){let e=r[0].toLowerCase();return t.has(e)?{mode:`agent`,activeAgentKey:e,activeSessionSlug:null}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}if(r.length===2){let e=r[0].toLowerCase(),n=r[1];return t.has(e)&&n?{mode:`session`,activeAgentKey:e,activeSessionSlug:n}:t.has(e)?{mode:`missingSession`,activeAgentKey:e,activeSessionSlug:n,attemptedSessionSlug:n}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}function to(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function no(e){if(!e)return null;let{from:t,to:n,days:r}=e.window;if(t==null)return`All time`;let i=to(t),a=to(n??Date.now());return r?`Last ${r}d · ${i} → ${a}`:`${i} → ${a}`}function ro(e,t,n){return t?e?`Searching for "${e}"`:`Loading recent sessions`:e?`${n} matches for "${e}"`:`${n} recent sessions`}function io(e){if(!e?.active)return null;let t=e.completedAgents.length,n=e.totalAgents,r=e.scanningAgents[0],i=r?e.agentStatuses[r]:null,a=i?.total&&i.processed!=null?` · ${i.processed}/${i.total}`:``,o=n>0?r?` · ${r}${a} · ${t}/${n} agents ready`:` · ${t}/${n} agents ready`:``;return e.phase===`initializing`?`First-run setup: indexing all local sessions${o}. Your selected time window appears after this finishes.`:e.phase===`indexing`?`Preparing local session index`:n>0?r?`Checking for new or changed sessions · ${r}${a} · ${t}/${n} agents ready`:`Checking for new or changed sessions · ${t}/${n} agents ready`:`Checking for new or changed sessions`}function ao(e,t){let n=e?.agentStatuses[t];return!n||n.status===`complete`?null:n.total&&n.processed!=null?`${n.processed}/${n.total}`:n.status===`scanning`?`Scanning`:`Pending`}function oo(e,t,n){let r=e?.agentStatuses[t];return r?.status===`complete`&&r.sessions!=null?r.sessions:n}function so(e){return{kind:e.identityKind,key:e.identityKey}}function co(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function lo(e,t){return(t.time_updated??t.time_created)-(e.time_updated??e.time_created)}function uo(e,t){if(!t.changedSessionHeads||!t.removedSessionRefs)return null;let n=new Map(e.map(e=>[Ya(Ja(e),e.id),e]));for(let{agentName:e,sessionId:r}of t.removedSessionRefs)n.delete(Ya(e,r));for(let{agentName:e,session:r}of t.changedSessionHeads)n.set(Ya(e,r.id),r);return[...n.values()].sort(lo)}function fo(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#39;`).replaceAll(`&lt;mark&gt;`,`<mark>`).replaceAll(`&lt;/mark&gt;`,`</mark>`)}var po=`codesesh.shortcuts-hint-dismissed`,mo=[`bugfix`,`refactoring`,`feature-dev`,`testing`,`docs`,`git-ops`,`build-deploy`,`exploration`,`planning`],ho=[`apply_patch`,`bash`,`read`,`edit`,`grep`],go=[{kind:`read`,label:`Read`},{kind:`edit`,label:`Edit`},{kind:`write`,label:`Write`},{kind:`delete`,label:`Delete`}],_o=[{id:`paid`,label:`Cost > $0`,costMin:1e-6},{id:`one_plus`,label:`Cost >= $1`,costMin:1},{id:`ten_plus`,label:`Cost >= $10`,costMin:10}],vo={recent:`Recent`,title:`Title`,user_message:`User message`,assistant_reply:`Assistant reply`,tool_output:`Tool output`,file_path:`File path`},yo=[{title:`Navigation`,items:[{keys:`j / k`,description:`Move through sessions or search results`},{keys:`Enter`,description:`Open the current selection`},{keys:`g / G`,description:`Jump to the first or last item`}]},{title:`Search`,items:[{keys:`Cmd/Ctrl K`,description:`Open global search`},{keys:`/`,description:`Focus the search box`},{keys:`Esc`,description:`Exit search or close the current detail view`}]},{title:`Groups`,items:[{keys:`g / G`,description:`Jump to the first or last session`},{keys:`?`,description:`Open this shortcuts panel`}]}];function bo(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function xo({value:e,onChange:t,projectsDisabled:n=!1}){return(0,F.jsx)(`div`,{role:`radiogroup`,"aria-label":`Browse by`,className:`grid gap-1.5`,children:[{value:`projects`,label:`Projects`},{value:`agents`,label:`Agents`}].map(r=>{let i=e===r.value,a=r.value===`projects`&&n;return(0,F.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,disabled:a,onClick:()=>t(r.value),className:`console-mono flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left text-xs transition-colors ${a?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-45`:i?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,title:a?`Project grouping is available after the current scan finishes`:void 0,children:[(0,F.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center rounded-full border ${i?`border-[var(--console-accent)]`:`border-[var(--console-border-strong)]`}`,children:i?(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--console-accent)]`}):null}),(0,F.jsx)(`span`,{children:r.label})]},r.value)})})}function So({sessions:e,activeSessionId:t,selectedSessionId:n,bookmarkedSessionIds:r,onSelectSession:i,onToggleBookmark:a}){return(0,F.jsx)(`div`,{className:`console-scrollbar h-[min(560px,calc(100vh-410px))] min-h-56 overflow-y-auto`,children:(0,F.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let o=Ja(e),s=M.agents[o],c=t===e.id,l=n===e.id;return(0,F.jsx)(`li`,{children:(0,F.jsxs)(`div`,{className:`flex items-start gap-1 rounded-sm border px-2 py-1.5 transition-colors ${c||l?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`min-w-0 flex-1 text-left`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[s?.icon?(0,F.jsx)(`img`,{src:s.icon,alt:s.name,className:`size-3.5 shrink-0 object-contain`}):null,(0,F.jsx)(`span`,{className:`console-mono line-clamp-1 text-xs text-[var(--console-text)]`,children:e.title})]}),(0,F.jsx)(`span`,{className:`console-mono mt-0.5 block truncate text-[10px] text-[var(--console-muted)]`,children:co(e.time_updated??e.time_created)})]}),(0,F.jsx)(vi,{active:r.has(e.id),onToggle:()=>a(e)})]})},e.slug)})})})}function Co(){let e=m(),[t,n]=(0,j.useState)([]),[r,i]=(0,j.useState)([]),[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)(!0),[l,u]=(0,j.useState)(null),[p,h]=(0,j.useState)(null),[g,_]=(0,j.useState)(!1),[ee,te]=(0,j.useState)(null),[ne,v]=(0,j.useState)(null),[y,re]=(0,j.useState)(null),[b,ie]=(0,j.useState)([]),[x,ae]=(0,j.useState)(`agents`),[oe,S]=(0,j.useState)(null),[se,ce]=(0,j.useState)(null),[le,ue]=(0,j.useState)(!1),[de,fe]=(0,j.useState)(null),[C,pe]=(0,j.useState)(void 0),[w,me]=(0,j.useState)(null),[T,he]=(0,j.useState)(``),[E,ge]=(0,j.useState)(``),[_e,ve]=(0,j.useState)(!1),[D,ye]=(0,j.useState)({}),[O,be]=(0,j.useState)([]),[xe,Se]=(0,j.useState)(!1),[k,Ce]=(0,j.useState)(null),[we,A]=(0,j.useState)(null),[Te,Ee]=(0,j.useState)(0),[De,Oe]=(0,j.useState)(!1),[ke,Ae]=(0,j.useState)(!0),je=(0,j.useRef)(null),Me=(0,j.useRef)(new Map);(0,j.useEffect)(()=>{let e=new AbortController,t=performance.now();return N(`app.load.start`,{path:window.location.pathname}),(async()=>{try{let e=await Ne();me(e);let[r,a,s,c,l,u]=await Promise.all([Fe(),Le({from:e.window.from,to:e.window.to}),ze(e.window).catch(e=>(console.error(`Failed to load dashboard:`,e),null)),Ie().catch(e=>(console.error(`Failed to load projects:`,e),{projects:[]})),Ve(),Pe().catch(e=>(console.error(`Failed to load scan status:`,e),null))]);n(r),i(a.sessions),ie(c.projects),o(l.bookmarks),u&&Ce(u),s&&re(s),N(`app.load.done`,{duration_ms:Math.round(performance.now()-t),agents:r.length,sessions:a.sessions.length,projects:c.projects.length,dashboard:!!s})}catch(e){console.error(`Failed to load data:`,e),N(`app.load.error`,{duration_ms:Math.round(performance.now()-t),error:e instanceof Error?e.message:String(e)}),u(`Failed to load data. Is the CLI server running?`)}finally{c(!1)}})(),()=>e.abort()},[]);let P=f(),Ke=(0,j.useMemo)(()=>new Set(t.map(e=>e.name.toLowerCase())),[t]),qe=(0,j.useMemo)(()=>new Map(t.map(e=>[e.name.toLowerCase(),e.displayName])),[t]),I=_e,L=(0,j.useMemo)(()=>eo(P.pathname,Ke),[P.pathname,Ke]);(0,j.useEffect)(()=>{N(`route.change`,{path:P.pathname,mode:L.mode,agent:L.activeAgentKey,session:L.activeSessionSlug})},[P.pathname,L.mode,L.activeAgentKey,L.activeSessionSlug]),(0,j.useEffect)(()=>{if(L.mode===`projects`||L.mode===`project`){ae(`projects`),L.mode===`project`&&S({kind:L.activeProjectKind,key:L.activeProjectKey});return}(L.mode===`agent`||L.mode===`missingAgent`)&&ae(`agents`)},[L]);let Ye=I?E:typeof P.state==`object`&&P.state!==null&&`searchQuery`in P.state&&typeof P.state.searchQuery==`string`?P.state.searchQuery:``,R=(0,j.useMemo)(()=>Qa(r,t),[r,t]);(0,j.useEffect)(()=>{let e=!1;return o(t=>{let n=zi(t,r);return n===t?t:(Ue(n.map(({bookmarked_at:e,...t})=>t)).catch(t=>{e||console.error(`Failed to sync bookmark snapshots:`,t)}),n)}),()=>{e=!0}},[r]),(0,j.useEffect)(()=>{let e=!1;return(async()=>{let t=Ii();if(t.length!==0)try{let n=await Ue(t.map(({bookmarked_at:e,...t})=>t));if(e)return;o(n.bookmarks),Li()}catch(t){e||console.error(`Failed to migrate legacy bookmarks:`,t)}})(),()=>{e=!0}},[]);let z=(0,j.useMemo)(()=>new Set(a.map(e=>Pi(e.agentKey,e.sessionId))),[a]);function Xe(e,t){return z.has(Pi(e,t))}function B(e){let t=Pi(e.agentKey,e.sessionId),n=z.has(t),r=a;o(n?r.filter(e=>Pi(e.agentKey,e.sessionId)!==t):[...r,e].toSorted((e,t)=>{let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n})),N(n?`bookmark.delete`:`bookmark.add`,{agent:e.agentKey,session:e.sessionId}),(n?We(e.agentKey,e.sessionId):He({agentKey:e.agentKey,sessionId:e.sessionId,fullPath:e.fullPath,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats})).catch(e=>{console.error(`Failed to toggle bookmark:`,e),o(r)})}function V(e,t){B(Fi(e,t))}let H=L.activeAgentKey,Ze=L.mode===`project`?L.activeProjectKind:null,Qe=L.mode===`project`?L.activeProjectKey:null,$e=(0,j.useMemo)(()=>Ze&&Qe?{kind:Ze,key:Qe}:null,[Ze,Qe]),et=$e?Hi($e):null,tt=(0,j.useMemo)(()=>L.mode===`session`?R.byRouteKey.get(Ya(L.activeAgentKey,L.activeSessionSlug))??null:null,[R,L]),nt=(L.mode===`session`&&p?.id===L.activeSessionSlug?p:null)?.project_identity??tt?.project_identity??null,rt=x===`projects`?$e??(L.mode===`session`?nt:oe):null,it=rt?Hi(rt):null,at=(0,j.useMemo)(()=>H?R.byAgent.get(H)??[]:[],[H,R]),ot=(0,j.useMemo)(()=>it?C?R.byProjectAgentKey.get(Xa(it,C))??[]:R.byProjectIdentityKey.get(it)??[]:[],[C,it,R]),U=x===`projects`?ot:at,st=(0,j.useMemo)(()=>$a(U),[U]),W=(0,j.useMemo)(()=>U.length===0?new Set:new Set(U.filter(e=>z.has(Pi(Ja(e),e.id))).map(e=>e.id)),[z,U]),ct=(0,j.useMemo)(()=>a.toSorted((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created)),[a]),lt=(0,j.useMemo)(()=>{let e=_o.find(e=>e.id===D.costRange);return{agent:D.agent,projectKey:D.projectKey,tag:D.tag,tool:D.tool,fileKind:D.fileKind,costMin:e?.costMin}},[D]),ut=E.trim().length>0||!!(D.tool||D.fileKind),dt=io(k),ft=k?.active===!0,pt=(0,j.useMemo)(()=>{let e=_o.find(e=>e.id===D.costRange),t=D.agent?R.byAgent.get(D.agent)??[]:null,n=D.projectKey?R.byProjectKey.get(D.projectKey)??[]:null,r=t&&n?t.length<=n.length?t:n:t??n??R.sessionsByActivity,i=[];for(let t of r)if(!(D.agent&&Ja(t)!==D.agent)&&!(D.projectKey&&t.project_identity?.key!==D.projectKey)&&!(D.tag&&!t.smart_tags?.includes(D.tag))&&!(e&&t.stats.total_cost<e.costMin)&&(i.push({agentName:Ja(t),session:t,snippet:`Recent session · ${t.directory}`,matchType:`recent`}),i.length>=50))break;return i},[D,R]),mt=L.mode===`session`?`${L.activeAgentKey}/${L.activeSessionSlug}`:``,ht=(0,j.useEffectEvent)(async e=>{try{let t=!!(e.changedSessionHeads&&e.removedSessionRefs);t&&i(t=>uo(t,e)??t);let[r,a,o,s,c,l]=await Promise.all([Fe(),t?Promise.resolve(null):Le({from:w?.window.from,to:w?.window.to}),ze(w?.window).catch(e=>(console.error(`Failed to refresh dashboard:`,e),null)),Ie().catch(e=>(console.error(`Failed to refresh projects:`,e),{projects:[]})),L.mode===`project`?ze(w?.window,{projectKind:L.activeProjectKind,projectKey:L.activeProjectKey,agent:C}).catch(e=>(console.error(`Failed to refresh project dashboard:`,e),null)):Promise.resolve(null),I&&ut?Be(E,lt).catch(e=>(console.error(`Failed to refresh search results:`,e),{results:[]})):Promise.resolve(null)]);if(n(r),a&&i(a.sessions),ie(s.projects),o&&re(o),c&&ce(c),l&&be(l.results),L.mode===`session`)try{h(await Re(L.activeAgentKey,L.activeSessionSlug)),te(null)}catch{h(null),te(`Session not found`)}e.newSessions>0&&v(`发现 ${e.newSessions} 个新会话,列表已自动刷新`)}catch(e){console.error(`Failed to sync live session update:`,e)}});(0,j.useEffect)(()=>{if(!I){be([]),Se(!1);return}if(!ut){be(pt),Se(!1);return}let e=!1;Se(!0);let t=performance.now();return N(`search.start`,{query_length:E.length}),Be(E,lt).then(n=>{e||(be(n.results),N(`search.done`,{duration_ms:Math.round(performance.now()-t),results:n.results.length}))}).catch(n=>{e||(console.error(`Failed to load search results:`,n),N(`search.error`,{duration_ms:Math.round(performance.now()-t),error:n instanceof Error?n.message:String(n)}),be([]))}).finally(()=>{e||Se(!1)}),()=>{e=!0}},[E,I,pt,lt,ut]),(0,j.useEffect)(()=>{if(L.mode!==`session`){h(null),te(null);return}let e=new AbortController;_(!0),te(null);let t=performance.now();return N(`session.open.start`,{agent:L.activeAgentKey,session:L.activeSessionSlug}),(async()=>{try{let e=await Re(L.activeAgentKey,L.activeSessionSlug);h(e),N(`session.open.done`,{agent:L.activeAgentKey,session:L.activeSessionSlug,duration_ms:Math.round(performance.now()-t),messages:e.messages.length})}catch(e){N(`session.open.error`,{agent:L.activeAgentKey,session:L.activeSessionSlug,duration_ms:Math.round(performance.now()-t),error:e instanceof Error?e.message:String(e)}),te(`Session not found`),h(null)}finally{_(!1)}})(),()=>e.abort()},[mt,L.activeAgentKey,L.activeSessionSlug,L.mode]),(0,j.useEffect)(()=>{et&&pe(void 0)},[et]),(0,j.useEffect)(()=>{if(!Qe||!w){ce(null),fe(null),ue(!1);return}let e=!1;return ue(!0),fe(null),ze(w.window,{projectKind:Ze??void 0,projectKey:Qe,agent:C}).then(t=>{e||ce(t)}).catch(t=>{e||(console.error(`Failed to load project dashboard:`,t),ce(null),fe(`Failed to load project dashboard`))}).finally(()=>{e||ue(!1)}),()=>{e=!0}},[Ze,Qe,w,C]),(0,j.useEffect)(()=>Ge(e=>{ht(e)},e=>{Ce(e)}),[]),(0,j.useEffect)(()=>{if(!ne)return;let e=window.setTimeout(()=>{v(null)},3500);return()=>{window.clearTimeout(e)}},[ne]),(0,j.useEffect)(()=>{try{Ae(window.localStorage.getItem(po)===`1`)}catch{Ae(!0)}},[]),(0,j.useEffect)(()=>{if(I){Ee(e=>O.length===0?0:Math.min(e,O.length-1));return}if(L.mode===`session`){A(L.activeSessionSlug);return}if(L.mode===`agent`){A(null);return}A(null)},[I,O.length,L.mode,L.activeSessionSlug,U]),(0,j.useEffect)(()=>{if(!I)return;let e=O[Te];if(!e)return;let t=`${e.agentName}/${e.session.id}`;Me.current.get(t)?.scrollIntoView({block:`nearest`})},[I,O,Te]);let gt=R.landingSessions,_t=(0,j.useMemo)(()=>et?R.byLandingProjectIdentityKey.get(et)??[]:[],[et,R]),vt=(0,j.useMemo)(()=>t.filter(e=>e.count>0).map(e=>({key:e.name.toLowerCase(),name:e.displayName,icon:e.icon,count:e.count})),[t]),G=(0,j.useMemo)(()=>t.find(e=>e.name.toLowerCase()===H)??null,[H,t]),yt=(0,j.useMemo)(()=>b.find(e=>et===Hi(so(e)))??null,[et,b]),bt=(0,j.useMemo)(()=>b.find(e=>it===Hi(so(e)))??null,[b,it]),xt=R.projectOptions,St=(0,j.useMemo)(()=>{if(!ut)return xt;let e=new Map,t=xe?[]:O;for(let n of t){let t=n.session.project_identity;if(!t?.key)continue;let r=e.get(t.key);r?r.count+=1:e.set(t.key,{key:t.key,label:t.displayName||n.session.directory,count:1,showCount:!1})}if(D.projectKey&&!e.has(D.projectKey)){let t=xt.find(e=>e.key===D.projectKey);t&&e.set(t.key,{...t,count:0,showCount:!1})}return[...e.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)},[xt,D.projectKey,xe,O,ut]),K=`CodeSesh`,q=`Select an agent to browse sessions`;if(L.mode===`root`&&(K=I?`Search`:`Dashboard`,q=I?ro(E,xe,O.length):y?`${y.totals.sessions.toLocaleString(`en-US`)} total sessions across ${y.perAgent.length} agents`:`Aggregated view across all agents`),L.mode===`projects`&&(K=`Projects`,q=`${b.length.toLocaleString(`en-US`)} projects across ${r.length.toLocaleString(`en-US`)} sessions`),L.mode===`project`&&(K=yt?.displayName??`Project`,q=yt?`${yt.sessionCount.toLocaleString(`en-US`)} sessions · ${yt.agentStats.length} agents`:L.activeProjectKey),L.mode===`agent`&&H&&(K=G?.displayName??H,q=`${U.length} sessions`),L.mode===`session`){if(ee)K=`Session Not Found`,q=`Requested /${H}/${L.activeSessionSlug}`;else if(p){K=p.title||`Conversation`;let e=p.time_updated??p.time_created;q=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{children:[`ID: #`,p.id.slice(0,8)]}),(0,F.jsx)(`span`,{children:`·`}),(0,F.jsxs)(`span`,{children:[`Updated `,co(e)]}),(0,F.jsx)(Je,{tags:p.smart_tags,limit:9,className:`inline-flex`})]})}}L.mode===`missingAgent`&&(K=`Agent Not Found`,q=`Requested /${L.attemptedKey}`),L.mode===`missingSession`&&(K=`Session Not Found`,q=`Session not found in /${H}`),I&&(K=`Search`,q=ro(E,xe,O.length));let Ct=(0,j.useMemo)(()=>{if(I)return[{label:`Search`}];let e={label:`Dashboard`,to:x===`agents`&&L.mode===`root`||x===`projects`&&L.mode===`projects`?void 0:x===`projects`?`/projects`:`/`};if(L.mode===`root`)return[{label:`Dashboard`}];let t={label:`Projects`,to:L.mode===`project`?`/projects`:void 0};if(L.mode===`projects`)return[e,{label:`Projects`}];if(L.mode===`project`)return[e,t,{label:yt?.displayName??L.activeProjectKey}];if(L.mode===`session`&&x===`projects`&&rt)return[e,{label:`Projects`,to:`/projects`},{label:bt?.displayName??rt.key,to:Wi(rt)},{label:p?.title||L.activeSessionSlug||`Conversation`}];if(L.mode===`missingAgent`)return[e,{label:L.attemptedKey}];let n=G?.displayName??H??`Unknown Agent`,r={label:n,to:L.mode===`session`?`/${H}`:void 0};return L.mode===`agent`?[e,{label:n}]:L.mode===`missingSession`?[e,r,{label:L.attemptedSessionSlug}]:L.mode===`session`?[e,r,{label:p?.title||L.activeSessionSlug||`Conversation`}]:[e,{label:`Invalid Route`}]},[G,H,yt,x,I,bt,rt,p?.title,L]),wt;wt=s?(0,F.jsx)(_i,{}):I?(0,F.jsx)(wo,{query:E,loading:xe,results:O,agentNameMap:qe,agents:t,projects:St,filters:D,onChangeFilters:ye,onOpenResult:()=>{ve(!1),ge(``)},selectedIndex:Te,registerResultRef:(e,t)=>{t?Me.current.set(e,t):Me.current.delete(e)}}):l?(0,F.jsx)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6 text-sm text-[var(--console-error)]`,children:l}):L.mode===`root`?y?(0,F.jsx)(va,{data:y,projects:b,bookmarkedSessions:ct,isBookmarked:Xe,onToggleBookmark:(e,t)=>{if(`agentName`in e){V(e,t??e.agentName.toLowerCase());return}B(e)}}):(0,F.jsx)(ki,{type:`global`,sessions:gt,agentItems:vt,isBookmarked:Xe,onToggleBookmark:e=>V(e,e.agentKey)}):L.mode===`projects`?(0,F.jsx)(Da,{projects:b}):L.mode===`project`?(0,F.jsx)(ja,{project:yt,projectKey:L.activeProjectKey,dashboard:se,loading:le,error:de,sessions:_t,activeAgent:C,onChangeAgent:pe,isBookmarked:Xe,onToggleSessionBookmark:V}):L.mode===`agent`&&H?(0,F.jsx)(ki,{type:`agent`,sessions:R.byLandingAgent.get(H)??[],agentItems:vt,activeAgentKey:H,isBookmarked:Xe,onToggleBookmark:e=>V(e,e.agentKey)}):L.mode===`session`?g?(0,F.jsx)(_i,{}):ee||!p?(0,F.jsx)(ki,{type:`missing-session`,sessions:R.byLandingAgent.get(L.activeAgentKey)??[],agentItems:vt,activeAgentKey:L.activeAgentKey,attemptedSessionSlug:L.activeSessionSlug,isBookmarked:Xe,onToggleBookmark:e=>V(e,e.agentKey)}):(0,F.jsx)(ti,{session:p,highlightQuery:Ye}):L.mode===`missingAgent`?(0,F.jsx)(ki,{type:`missing-agent`,sessions:gt,agentItems:vt,attemptedAgentKey:L.attemptedKey,isBookmarked:Xe,onToggleBookmark:e=>V(e,e.agentKey)}):(0,F.jsx)(`div`,{className:`text-sm text-[var(--console-muted)]`,children:`Invalid route.`});function Tt(){ge(T.trim()),ve(!0),Ee(0)}function J(){Ae(!0);try{window.localStorage.setItem(po,`1`)}catch{}}function Et(t){if(!(t===`projects`&&ft)){if(ae(t),A(null),t===`projects`){let t=nt??(L.mode===`session`?null:oe);e(t?Wi(t):`/projects`);return}e(`/`)}}let Dt=(0,j.useEffectEvent)(t=>{let n=t.key;if((t.metaKey||t.ctrlKey)&&n.toLowerCase()===`k`){t.preventDefault(),ve(!0),Ee(0),window.setTimeout(()=>{je.current?.focus(),je.current?.select()},0);return}if(t.defaultPrevented||t.metaKey||t.ctrlKey||t.altKey||t.isComposing)return;let r=t.target,i=bo(r);if(De){n===`Escape`&&(t.preventDefault(),Oe(!1));return}if(i){n===`Escape`&&(t.preventDefault(),r instanceof HTMLElement&&r.blur());return}if(n===`?`){t.preventDefault(),Oe(!0),J();return}if(n===`/`){t.preventDefault(),J(),ve(!0),je.current?.focus(),je.current?.select();return}if(n===`Escape`){if(t.preventDefault(),I){ve(!1),ge(``),he(``);return}if(L.mode===`session`&&L.activeAgentKey){if(x===`projects`&&rt){e(Wi(rt));return}e(`/${L.activeAgentKey}`)}return}if(I){if(O.length===0)return;if(n===`j`){t.preventDefault(),J(),Ee(e=>Math.min(e+1,O.length-1));return}if(n===`k`){t.preventDefault(),J(),Ee(e=>Math.max(e-1,0));return}if(n===`g`){t.preventDefault(),J(),Ee(0);return}if(n===`G`){t.preventDefault(),J(),Ee(O.length-1);return}if(n===`Enter`){let n=O[Te];if(!n)return;t.preventDefault(),J(),ve(!1),ge(``),e(`/${n.agentName.toLowerCase()}/${n.session.id}`,{state:{searchQuery:E}})}return}if(x===`agents`&&!H||U.length===0)return;let a=e=>{J();let t=we==null?-1:st.indexById.get(we)??-1,n=t>=0?t:e>=0?-1:U.length;A(U[Math.max(0,Math.min(n+e,U.length-1))]?.id??null)};if(n===`j`){t.preventDefault(),a(1);return}if(n===`k`){t.preventDefault(),a(-1);return}if(n===`g`){t.preventDefault(),J(),A(U[0]?.id??null);return}if(n===`G`){t.preventDefault(),J(),A(U.at(-1)?.id??null);return}if(n===`Enter`){let n=we==null?null:st.byId.get(we);if(!n)return;t.preventDefault(),J(),e(x===`projects`?`/${n.slug}`:`/${H}/${n.id}`)}});return(0,j.useEffect)(()=>(window.addEventListener(`keydown`,Dt),()=>window.removeEventListener(`keydown`,Dt)),[]),(0,F.jsxs)(`div`,{className:`console-ui flex h-screen flex-col overflow-hidden bg-[var(--console-bg)] text-[var(--console-text)]`,children:[(0,F.jsx)(`header`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/85 backdrop-blur-sm`,children:(0,F.jsxs)(`div`,{className:`grid min-h-14 grid-cols-[auto_1fr] items-center gap-3 px-4 py-2 sm:grid-cols-[auto_1fr_auto] sm:py-0`,children:[(0,F.jsxs)(d,{to:`/`,className:`flex items-center gap-2 text-[var(--console-text)]`,children:[(0,F.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`CodeSesh`,className:`h-6 w-6 rounded-sm`}),(0,F.jsx)(`span`,{className:`console-mono text-sm font-semibold uppercase tracking-[0.05em]`,children:`CodeSesh`})]}),(0,F.jsxs)(`form`,{className:`order-3 col-span-2 flex w-full items-center justify-center gap-2 sm:order-none sm:col-span-1 sm:mx-auto sm:max-w-[560px]`,onSubmit:e=>{e.preventDefault(),Tt()},children:[(0,F.jsx)(`label`,{className:`flex min-w-0 flex-1 items-center rounded-sm border border-[var(--console-border)] bg-white px-2 py-1`,children:(0,F.jsx)(`input`,{ref:je,value:T,onChange:e=>he(e.target.value),placeholder:`Search sessions /`,className:`console-mono w-full min-w-0 bg-transparent text-xs text-[var(--console-text)] outline-none placeholder:text-[var(--console-muted)]`})}),(0,F.jsx)(`button`,{type:`submit`,className:`console-mono rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] px-3 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Search`})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{Oe(!0),J()},className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-[var(--console-surface-muted)]`,title:`Show keyboard shortcuts`,children:[`?`,(0,F.jsx)(`span`,{className:`hidden sm:inline`,children:` Shortcuts`})]}),no(w)?(0,F.jsx)(`span`,{className:`console-mono hidden rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] md:inline-flex`,title:`Time window applied to agent counts, dashboard, and session list`,children:no(w)}):null,(0,F.jsxs)(`span`,{className:`console-mono hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-muted)] sm:inline-flex`,children:[`v`,`0.7.0`]})]})]})}),(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,F.jsx)(`aside`,{className:`hidden w-64 shrink-0 flex-col border-r border-[var(--console-border)] bg-[var(--console-sidebar-bg)] lg:flex`,children:(0,F.jsxs)(`div`,{className:`console-scrollbar flex-1 space-y-8 overflow-y-auto px-4 py-6`,children:[(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BROWSE BY`}),(0,F.jsx)(xo,{value:x,onChange:Et,projectsDisabled:ft})]}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`NAVIGATION`}),(0,F.jsxs)(`ul`,{className:`space-y-1 ${x===`projects`?`console-scrollbar max-h-[min(280px,calc(100vh-440px))] overflow-y-auto pr-1`:``}`,children:[(0,F.jsx)(`li`,{children:(0,F.jsxs)(d,{to:x===`projects`?`/projects`:`/`,className:`flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${x===`agents`&&L.mode===`root`||x===`projects`&&L.mode===`projects`?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,F.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`Dashboard`,className:`size-3.5 rounded-[2px]`}),(0,F.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:`Dashboard`})]})}),x===`agents`?t.map(e=>{let t=e.name.toLowerCase(),n=t===H,r=M.agents[t],i=ao(k,e.name),a=ft&&i!==null,o=`ml-4 flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${a?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-50`:n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,s=(0,F.jsxs)(F.Fragment,{children:[r?.icon&&(0,F.jsx)(`img`,{src:r.icon,alt:e.displayName,className:`size-3.5 object-contain`}),(0,F.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:e.displayName}),(0,F.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:i??oo(k,e.name,e.count)})]});return(0,F.jsxs)(`li`,{children:[a?(0,F.jsx)(`span`,{className:o,title:`Available after this agent scan completes`,children:s}):(0,F.jsx)(d,{to:`/${t}`,className:o,children:s}),i?(0,F.jsx)(`span`,{className:`ml-4 mt-1 block h-1 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,children:(0,F.jsx)(`span`,{className:`block h-full bg-[var(--console-accent)]`,style:{width:`${k?.agentStatuses[e.name]?.total?Math.round((k.agentStatuses[e.name]?.processed??0)/k.agentStatuses[e.name].total*100):8}%`}})}):null]},e.name)}):b.map(e=>{let t=so(e),n=it===Hi(t);return(0,F.jsx)(`li`,{children:(0,F.jsxs)(d,{to:Wi(t),onClick:()=>S(t),className:`ml-4 flex min-w-0 items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,F.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs`,children:e.displayName}),(0,F.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.sessionCount})]})},`${e.identityKind}:${e.identityKey}`)}),x===`agents`&&t.length===0&&!s?(0,F.jsx)(`li`,{children:(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:k?.active?`Scanning agents...`:`No agents found`})}):null,x===`projects`&&b.length===0&&!s?(0,F.jsx)(`li`,{children:(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:k?.active?`Scanning projects...`:`No projects found`})}):null]})]}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BOOKMARKS`}),ct.length===0?(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No bookmarks yet`}):(0,F.jsx)(`ul`,{className:`space-y-1`,children:ct.map(e=>{let t=L.mode===`session`&&L.activeAgentKey===e.agentKey&&L.activeSessionSlug===e.sessionId,n=M.agents[e.agentKey];return(0,F.jsx)(`li`,{children:(0,F.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border px-2 py-1.5 transition-colors ${t?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,F.jsxs)(d,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,F.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`span`,{className:`console-mono line-clamp-1 block text-xs`,children:e.title}),(0,F.jsx)(`span`,{className:`console-mono mt-0.5 line-clamp-1 block text-[10px] text-[var(--console-muted)]`,children:n?.name??e.agentKey})]})]}),(0,F.jsx)(vi,{active:!0,onToggle:()=>B(e)})]})},Pi(e.agentKey,e.sessionId))})})]}),(0,F.jsxs)(`section`,{children:[(0,F.jsxs)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:[`SESSIONS`,U.length>0?(0,F.jsx)(`span`,{className:`ml-2 text-[10px] font-normal text-[var(--console-muted)]`,children:`Navigate j k · Open Enter`}):null]}),x===`agents`&&!H?(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select an agent`}):x===`projects`&&!it?(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select a project`}):U.length===0?(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:k?.active?`Scanning sessions...`:`No sessions yet`}):x===`projects`?(0,F.jsx)(So,{sessions:U,activeSessionId:L.mode===`session`?L.activeSessionSlug:null,selectedSessionId:we,bookmarkedSessionIds:W,onSelectSession:t=>{A(t.id),e(`/${t.slug}`)},onToggleBookmark:e=>V(e,Ja(e))}):(0,F.jsx)(Ka,{sessions:U,activeSessionId:L.mode===`session`?L.activeSessionSlug:null,selectedSessionId:we,onSelectSession:t=>{A(t);let n=st.byId.get(t);n&&e(`/${n.slug}`)},bookmarkedSessionIds:W,onToggleBookmark:e=>V(e,Ja(e))})]})]})}),(0,F.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,F.jsx)(`section`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/70 px-4 py-4 backdrop-blur-sm md:px-8`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`console-mono mb-2 flex flex-wrap items-center gap-1 text-[11px] text-[var(--console-muted)]`,children:Ct.map((e,t)=>(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.to?(0,F.jsx)(d,{to:e.to,className:`transition-colors hover:text-[var(--console-text)]`,children:e.label}):(0,F.jsx)(`span`,{className:`text-[var(--console-text)]`,children:e.label}),t<Ct.length-1?(0,F.jsx)(`span`,{children:`/`}):null]},`${e.label}-${t}`))}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] font-bold uppercase text-[var(--console-muted)]`,children:L.mode===`session`?`Session`:L.mode===`root`?`Dashboard`:L.mode===`projects`?`Projects`:L.mode===`project`?`Project`:`Landing`}),(0,F.jsx)(`h1`,{className:`console-mono text-xl font-semibold tracking-tight text-[var(--console-text)]`,children:K})]}),(0,F.jsx)(`div`,{className:`console-mono mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-[var(--console-muted)]`,children:q}),(0,F.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[ke?null:(0,F.jsxs)(`div`,{className:`console-mono inline-flex items-center gap-2 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:[(0,F.jsx)(`span`,{children:`Keyboard navigation available`}),(0,F.jsx)(`span`,{className:`rounded-sm border border-[var(--console-border)] bg-white px-1`,children:`?`}),(0,F.jsx)(`button`,{type:`button`,onClick:J,className:`text-[var(--console-muted)] transition-colors hover:text-[var(--console-text)]`,"aria-label":`Dismiss keyboard shortcuts hint`,children:`×`})]}),!I&&L.mode===`session`?(0,F.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:`Esc back`}):null,!I&&L.mode===`session`&&p?(0,F.jsx)(Ra,{agentName:L.activeAgentKey,sessionId:p.id,directory:p.directory}):null]}),ne?(0,F.jsx)(`p`,{className:`console-mono mt-2 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:ne}):null,dt&&L.mode===`root`?(0,F.jsx)(`p`,{className:`console-mono mt-2 inline-flex max-w-4xl rounded-sm border border-[var(--console-warning-border)] bg-[var(--console-warning-bg)] px-2 py-1 text-[11px] leading-relaxed text-[var(--console-warning)]`,children:dt}):null]})}),(0,F.jsx)(`section`,{className:`console-scrollbar bg-grid min-h-0 flex-1 overflow-y-auto px-4 py-6 md:px-8`,children:(0,F.jsx)(Ma,{children:wt})})]})]}),De?(0,F.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/35 px-4`,onClick:()=>Oe(!1),children:(0,F.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Keyboard shortcuts`,className:`w-full max-w-2xl rounded-sm border border-[var(--console-border-strong)] bg-white p-5 shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`Keyboard Shortcuts`}),(0,F.jsx)(`h2`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:`Navigate without leaving the keyboard`})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>Oe(!1),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Esc`})]}),(0,F.jsx)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-3`,children:yo.map(e=>(0,F.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-4`,children:[(0,F.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:e.title}),(0,F.jsx)(`div`,{className:`mt-3 space-y-3`,children:e.items.map(e=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-text)]`,children:e.keys}),(0,F.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-[var(--console-muted)]`,children:e.description})]},e.keys))})]},e.title))})]})}):null]})}function wo({query:e,loading:t,results:n,agentNameMap:r,agents:i,projects:a,filters:o,onChangeFilters:s,onOpenResult:c,selectedIndex:l,registerResultRef:u}){let f=(0,F.jsx)(To,{agents:i,projects:a,filters:o,onChangeFilters:s});return t?(0,F.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,(0,F.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:4}).map((e,t)=>(0,F.jsxs)(`div`,{className:`animate-pulse rounded-sm border border-[var(--console-border)] bg-white/80 p-4`,children:[(0,F.jsx)(`div`,{className:`h-3 w-32 rounded bg-[var(--console-surface-muted)]`}),(0,F.jsx)(`div`,{className:`mt-3 h-4 w-2/3 rounded bg-[var(--console-surface-muted)]`}),(0,F.jsx)(`div`,{className:`mt-2 h-3 w-full rounded bg-[var(--console-surface-muted)]`}),(0,F.jsx)(`div`,{className:`mt-1 h-3 w-5/6 rounded bg-[var(--console-surface-muted)]`})]},t))})]}):n.length===0?(0,F.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,(0,F.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/80 p-6`,children:[(0,F.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:e?`No matches`:`No recent sessions`}),e?(0,F.jsxs)(`p`,{className:`console-mono mt-2 text-xs text-[var(--console-muted)]`,children:[`Query: `,e]}):null]})]}):(0,F.jsxs)(`div`,{className:`grid gap-3`,children:[f,(0,F.jsx)(`div`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Navigate j k · Open Enter · Exit Esc`}),n.map((t,n)=>{let i=t.agentName.toLowerCase(),a=r.get(i)??t.agentName,o=`${t.agentName}/${t.session.id}`;return(0,F.jsxs)(d,{ref:e=>u(o,e),to:`/${i}/${t.session.id}`,state:{searchQuery:e},onClick:c,className:`rounded-sm border bg-white/85 p-4 transition-colors hover:border-[var(--console-border-strong)] hover:bg-white ${n===l?`border-[var(--console-border-strong)]`:`border-[var(--console-border)]`}`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:a}),(0,F.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:vo[t.matchType]}),(0,F.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:t.session.directory})]}),(0,F.jsx)(`h2`,{className:`console-mono mt-3 text-sm font-semibold text-[var(--console-text)]`,children:t.session.title}),(0,F.jsx)(Je,{tags:t.session.smart_tags,className:`mt-2`}),(0,F.jsx)(`p`,{className:`console-mono mt-2 text-xs leading-6 text-[var(--console-muted)] [&_mark]:bg-[var(--console-accent)] [&_mark]:px-0.5 [&_mark]:text-white`,dangerouslySetInnerHTML:{__html:fo(t.snippet||t.session.title)}})]},o)})]})}function To({agents:e,projects:t,filters:n,onChangeFilters:r}){let i=Object.values(n).some(Boolean),a=(e,t)=>{r(n=>({...n,[e]:n[e]===t?void 0:t}))};return(0,F.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/85 p-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Scope`}),(0,F.jsx)(Eo,{active:!n.projectKey,label:`All`,onClick:()=>r(e=>({...e,projectKey:void 0}))}),t.map(e=>(0,F.jsx)(Eo,{active:n.projectKey===e.key,label:e.showCount===!1?e.label:`${e.label} · ${e.count}`,onClick:()=>a(`projectKey`,e.key)},e.key))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Agent`}),(0,F.jsx)(Eo,{active:!n.agent,label:`All Agents`,onClick:()=>r(e=>({...e,agent:void 0}))}),e.map(e=>(0,F.jsx)(Eo,{active:n.agent===e.name,label:e.displayName,onClick:()=>a(`agent`,e.name)},e.name))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Tag`}),mo.map(e=>(0,F.jsx)(Eo,{active:n.tag===e,label:Ke[e],onClick:()=>a(`tag`,e)},e))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Signal`}),ho.map(e=>(0,F.jsx)(Eo,{active:n.tool===e,label:`tool:${e}`,onClick:()=>a(`tool`,e)},e))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`File Activity`}),go.map(e=>(0,F.jsx)(Eo,{active:n.fileKind===e.kind,label:e.label,onClick:()=>a(`fileKind`,e.kind)},e.kind))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Cost Range`}),(0,F.jsx)(Eo,{active:!n.costRange,label:`Any Cost`,onClick:()=>r(e=>({...e,costRange:void 0}))}),_o.map(e=>(0,F.jsx)(Eo,{active:n.costRange===e.id,label:e.label,onClick:()=>a(`costRange`,e.id)},e.id)),i?(0,F.jsx)(`button`,{type:`button`,onClick:()=>r({}),className:`console-mono ml-auto rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[10px] text-[var(--console-muted)] transition-colors hover:bg-white`,children:`Clear`}):null]})]})}function Eo({active:e,label:t,onClick:n}){return(0,F.jsx)(`button`,{type:`button`,onClick:n,className:`console-mono rounded-sm border px-2 py-1 text-[10px] transition-colors ${e?`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-white`}`,children:t})}Me.createRoot(document.getElementById(`root`)).render((0,F.jsx)(j.StrictMode,{children:(0,F.jsx)(ie,{children:(0,F.jsx)(Co,{})})}));
108
+ `;function Ba(e){return e.replaceAll(`/`,`∕`).trim()||`(untitled)`}function Va(e){return e.replace(/\/+$/,``).split(`/`).at(-1)?.trim()||`(unknown)`}function Ha(e){let t=e.project_identity;if(t)return{key:`${t.kind}:${t.key}`,label:t.displayName||Va(e.directory)};let n=Va(e.directory);return{key:n===`(unknown)`?`__unknown__`:`path:${e.directory||n}`,label:n}}function Ua(e){return e.time_updated??e.time_created}function Wa(e,t,n){let r=e.get(t.path)??2**53-1,i=e.get(n.path)??2**53-1;return r===i?t.path.localeCompare(n.path):r-i}function Ga(e){let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Set,c=[],l=new Map;for(let t of e){let{key:e,label:n}=Ha(t),r=l.get(e);r?r.sessions.push(t):l.set(e,{label:n,sessions:[t]})}let u=[...l.entries()].sort(([,e],[,t])=>{if(e.label===`(unknown)`)return 1;if(t.label===`(unknown)`)return-1;let n=Math.max(...e.sessions.map(Ua));return Math.max(...t.sessions.map(Ua))-n}),d=0,f=new Set;for(let[,e]of u){let l=Ba(e.label),u=`${l}/`,p=2;for(;f.has(u);)u=`${l} (${p})/`,p+=1;f.add(u);let m=u.slice(0,-1),h=new Map;t.set(u,d),t.set(m,d),d+=1,a.set(u,`${e.sessions.length}`),a.set(m,`${e.sessions.length}`);for(let t of e.sessions)h.set(t.title,(h.get(t.title)??0)+1);for(let a of e.sessions){let e=(h.get(a.title)??0)>1?`${Ba(a.title)} #${a.id.slice(0,8)}`:Ba(a.title),l=`${u}${e}`,f=2;for(;s.has(l);)l=`${u}${e} (${f})`,f+=1;s.add(l),c.push(l),t.set(l,d),d+=1,n.set(a.id,l),r.set(a.id,u),i.set(l,a.id),o.set(l,a)}}return{paths:c,sortOrderByPath:t,pathBySessionId:n,groupPathBySessionId:r,sessionIdByPath:i,groupCountByPath:a,sessionByPath:o}}function Ka({sessions:e,activeSessionId:t,selectedSessionId:n,onSelectSession:r,bookmarkedSessionIds:a,onToggleBookmark:s}){let c=(0,j.useMemo)(()=>Ga(e),[e]),l=(0,j.useRef)(c.sortOrderByPath),u=(0,j.useRef)(c.sessionIdByPath),d=(0,j.useRef)(c.groupCountByPath),f=(0,j.useRef)(c.sessionByPath),p=(0,j.useRef)(a),m=(0,j.useRef)(r),h=(0,j.useRef)(s),g={"--trees-bg-override":`transparent`,"--trees-border-color-override":`var(--console-border)`,"--trees-fg-override":`var(--console-text)`,"--trees-fg-muted-override":`var(--console-muted)`,"--trees-font-family-override":`"JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace`,"--trees-font-size-override":`12px`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`8px`,"--trees-selected-bg-override":`var(--console-surface-muted)`},{model:_}=o({flattenEmptyDirectories:!1,initialExpansion:`closed`,paths:c.paths,sort:(e,t)=>Wa(l.current,e,t),density:`compact`,unsafeCSS:za,onSelectionChange(e){let t=u.current.get(e[0]??``);t&&m.current(t)},renderRowDecoration({item:e}){let t=f.current.get(e.path);if(t){let e=p.current.has(t.id);return{text:e?`★`:`☆`,title:e?`Remove bookmark`:`Add bookmark`}}return d.current.get(e.path)?{text:d.current.get(e.path),title:`Sessions`}:null}});(0,j.useEffect)(()=>{l.current=c.sortOrderByPath,u.current=c.sessionIdByPath,d.current=c.groupCountByPath,f.current=c.sessionByPath,_.resetPaths(c.paths)},[_,c]),(0,j.useEffect)(()=>{m.current=r},[r]),(0,j.useEffect)(()=>{p.current=a,_.resetPaths(c.paths)},[a,_,c.paths]),(0,j.useEffect)(()=>{h.current=s},[s]);function ee(e){let t=e.nativeEvent.composedPath(),n=t.find(e=>e instanceof HTMLElement&&e.parentElement?.getAttribute(`data-item-section`)===`decoration`),r=t.find(e=>e instanceof HTMLElement&&e.getAttribute(`data-type`)===`item`),i=r?f.current.get(r.getAttribute(`data-item-path`)??``):null;!n||!i||(e.preventDefault(),e.stopPropagation(),h.current(i))}return(0,j.useEffect)(()=>{let e=c.pathBySessionId.get(t??``),r=c.pathBySessionId.get(n??``)??e,i=n??t??``,a=c.groupPathBySessionId.get(i);if(e&&_.getItem(e)?.select(),r&&t){let e=a?_.getItem(a):null;e&&`expand`in e&&e.expand(),_.focusPath(r);return}a&&_.focusPath(a)},[t,_,c,n]),(0,F.jsx)(`div`,{className:`session-tree h-[min(560px,calc(100vh-410px))] min-h-56 overflow-hidden`,style:g,onClickCapture:ee,children:(0,F.jsx)(i,{model:_,style:{height:`100%`},"aria-label":`Sessions`})})}function qa(e,t){return(t.time_updated??t.time_created)-(e.time_updated??e.time_created)}function Ja(e){return e.slug.split(`/`)[0]?.toLowerCase()||`unknown`}function Ya(e,t){return`${e.toLowerCase()}/${t}`}function Xa(e,t){return`${e}\0${t.toLowerCase()}`}function Za(e,t,n){let r=e.get(t);if(r){r.push(n);return}e.set(t,[n])}function Qa(e,t){let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c=new Map,l=new Map,u=[],d=new Set(t.map(e=>e.name.toLowerCase()));for(let e of d)r.set(e,[]),s.set(e,[]);for(let t of e){let e=Ja(t),r={...t,agentKey:e,sessionSlug:t.id,fullPath:t.slug};u.push(r);let i=Ya(e,t.id);n.has(i)||n.set(i,t),d.has(e)&&s.get(e).push(r);let a=t.project_identity;if(!a?.key)continue;Za(c,Hi(a),r);let o=l.get(a.key);o?o.count+=1:l.set(a.key,{key:a.key,label:a.displayName||t.directory,count:1})}let f=e.toSorted(qa);for(let e of f){let t=Ja(e);d.has(t)&&r.get(t).push(e);let n=e.project_identity;if(!n?.key)continue;let s=Hi(n);Za(i,s,e),Za(a,Xa(s,t),e),Za(o,n.key,e)}return{byRouteKey:n,byAgent:r,byProjectIdentityKey:i,byProjectAgentKey:a,byProjectKey:o,byLandingAgent:s,byLandingProjectIdentityKey:c,landingSessions:u,sessionsByActivity:f,projectOptions:[...l.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)}}function $a(e){let t=new Map,n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r];t.has(i.id)||(t.set(i.id,i),n.set(i.id,r))}return{byId:t,indexById:n}}function eo(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?n.split(`/`).map(e=>e.trim()).filter(Boolean):[];if(r.length===0)return{mode:`root`,activeAgentKey:null,activeSessionSlug:null};if(r[0]?.toLowerCase()===`projects`){if(r.length===1)return{mode:`projects`,activeAgentKey:null,activeSessionSlug:null};if(r.length===3)try{let e=decodeURIComponent(r[1]);return Vi(e)?{mode:`project`,activeAgentKey:null,activeSessionSlug:null,activeProjectKind:e,activeProjectKey:Ui(r[2])}:{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}catch{return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}if(r.length===1){let e=r[0].toLowerCase();return t.has(e)?{mode:`agent`,activeAgentKey:e,activeSessionSlug:null}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}if(r.length===2){let e=r[0].toLowerCase(),n=r[1];return t.has(e)&&n?{mode:`session`,activeAgentKey:e,activeSessionSlug:n}:t.has(e)?{mode:`missingSession`,activeAgentKey:e,activeSessionSlug:n,attemptedSessionSlug:n}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}function to(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function no(e){if(!e)return null;let{from:t,to:n,days:r}=e.window;if(t==null)return`All time`;let i=to(t),a=to(n??Date.now());return r?`Last ${r}d · ${i} → ${a}`:`${i} → ${a}`}function ro(e,t,n){return t?e?`Searching for "${e}"`:`Loading recent sessions`:e?`${n} matches for "${e}"`:`${n} recent sessions`}function io(e){if(!e?.active)return null;let t=e.completedAgents.length,n=e.totalAgents,r=e.scanningAgents[0],i=r?e.agentStatuses[r]:null,a=i?.total&&i.processed!=null?` · ${i.processed}/${i.total}`:``,o=n>0?r?` · ${r}${a} · ${t}/${n} agents ready`:` · ${t}/${n} agents ready`:``;return e.phase===`initializing`?`First-run setup: indexing all local sessions${o}. Your selected time window appears after this finishes.`:e.phase===`indexing`?`Preparing local session index`:n>0?r?`Checking for new or changed sessions · ${r}${a} · ${t}/${n} agents ready`:`Checking for new or changed sessions · ${t}/${n} agents ready`:`Checking for new or changed sessions`}function ao(e,t){let n=e?.agentStatuses[t];return!n||n.status===`complete`?null:n.total&&n.processed!=null?`${n.processed}/${n.total}`:n.status===`scanning`?`Scanning`:`Pending`}function oo(e,t,n){let r=e?.agentStatuses[t];return r?.status===`complete`&&r.sessions!=null?r.sessions:n}function so(e){return{kind:e.identityKind,key:e.identityKey}}function co(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function lo(e,t){return(t.time_updated??t.time_created)-(e.time_updated??e.time_created)}function uo(e,t){if(!t.changedSessionHeads||!t.removedSessionRefs)return null;let n=new Map(e.map(e=>[Ya(Ja(e),e.id),e]));for(let{agentName:e,sessionId:r}of t.removedSessionRefs)n.delete(Ya(e,r));for(let{agentName:e,session:r}of t.changedSessionHeads)n.set(Ya(e,r.id),r);return[...n.values()].sort(lo)}function fo(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#39;`).replaceAll(`&lt;mark&gt;`,`<mark>`).replaceAll(`&lt;/mark&gt;`,`</mark>`)}var po=`codesesh.shortcuts-hint-dismissed`,mo=[`bugfix`,`refactoring`,`feature-dev`,`testing`,`docs`,`git-ops`,`build-deploy`,`exploration`,`planning`],ho=[`apply_patch`,`bash`,`read`,`edit`,`grep`],go=[{kind:`read`,label:`Read`},{kind:`edit`,label:`Edit`},{kind:`write`,label:`Write`},{kind:`delete`,label:`Delete`}],_o=[{id:`paid`,label:`Cost > $0`,costMin:1e-6},{id:`one_plus`,label:`Cost >= $1`,costMin:1},{id:`ten_plus`,label:`Cost >= $10`,costMin:10}],vo={recent:`Recent`,title:`Title`,user_message:`User message`,assistant_reply:`Assistant reply`,tool_output:`Tool output`,file_path:`File path`},yo=[{title:`Navigation`,items:[{keys:`j / k`,description:`Move through sessions or search results`},{keys:`Enter`,description:`Open the current selection`},{keys:`g / G`,description:`Jump to the first or last item`}]},{title:`Search`,items:[{keys:`Cmd/Ctrl K`,description:`Open global search`},{keys:`/`,description:`Focus the search box`},{keys:`Esc`,description:`Exit search or close the current detail view`}]},{title:`Groups`,items:[{keys:`g / G`,description:`Jump to the first or last session`},{keys:`?`,description:`Open this shortcuts panel`}]}];function bo(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function xo({value:e,onChange:t,projectsDisabled:n=!1}){return(0,F.jsx)(`div`,{role:`radiogroup`,"aria-label":`Browse by`,className:`grid gap-1.5`,children:[{value:`projects`,label:`Projects`},{value:`agents`,label:`Agents`}].map(r=>{let i=e===r.value,a=r.value===`projects`&&n;return(0,F.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,disabled:a,onClick:()=>t(r.value),className:`console-mono flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left text-xs transition-colors ${a?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-45`:i?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,title:a?`Project grouping is available after the current scan finishes`:void 0,children:[(0,F.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center rounded-full border ${i?`border-[var(--console-accent)]`:`border-[var(--console-border-strong)]`}`,children:i?(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--console-accent)]`}):null}),(0,F.jsx)(`span`,{children:r.label})]},r.value)})})}function So({sessions:e,activeSessionId:t,selectedSessionId:n,bookmarkedSessionIds:r,onSelectSession:i,onToggleBookmark:a}){return(0,F.jsx)(`div`,{className:`console-scrollbar h-[min(560px,calc(100vh-410px))] min-h-56 overflow-y-auto`,children:(0,F.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let o=Ja(e),s=M.agents[o],c=t===e.id,l=n===e.id;return(0,F.jsx)(`li`,{children:(0,F.jsxs)(`div`,{className:`flex items-start gap-1 rounded-sm border px-2 py-1.5 transition-colors ${c||l?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`min-w-0 flex-1 text-left`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[s?.icon?(0,F.jsx)(`img`,{src:s.icon,alt:s.name,className:`size-3.5 shrink-0 object-contain`}):null,(0,F.jsx)(`span`,{className:`console-mono line-clamp-1 text-xs text-[var(--console-text)]`,children:e.title})]}),(0,F.jsx)(`span`,{className:`console-mono mt-0.5 block truncate text-[10px] text-[var(--console-muted)]`,children:co(e.time_updated??e.time_created)})]}),(0,F.jsx)(vi,{active:r.has(e.id),onToggle:()=>a(e)})]})},e.slug)})})})}function Co(){let e=m(),[t,n]=(0,j.useState)([]),[r,i]=(0,j.useState)([]),[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)(!0),[l,u]=(0,j.useState)(null),[p,h]=(0,j.useState)(null),[g,_]=(0,j.useState)(!1),[ee,te]=(0,j.useState)(null),[ne,v]=(0,j.useState)(null),[y,re]=(0,j.useState)(null),[b,ie]=(0,j.useState)([]),[x,ae]=(0,j.useState)(`agents`),[oe,S]=(0,j.useState)(null),[se,ce]=(0,j.useState)(null),[le,ue]=(0,j.useState)(!1),[de,fe]=(0,j.useState)(null),[C,pe]=(0,j.useState)(void 0),[w,me]=(0,j.useState)(null),[T,he]=(0,j.useState)(``),[E,ge]=(0,j.useState)(``),[_e,ve]=(0,j.useState)(!1),[D,ye]=(0,j.useState)({}),[O,be]=(0,j.useState)([]),[xe,Se]=(0,j.useState)(!1),[k,Ce]=(0,j.useState)(null),[we,A]=(0,j.useState)(null),[Te,Ee]=(0,j.useState)(0),[De,Oe]=(0,j.useState)(!1),[ke,Ae]=(0,j.useState)(!0),je=(0,j.useRef)(null),Me=(0,j.useRef)(new Map);(0,j.useEffect)(()=>{let e=new AbortController,t=performance.now();return N(`app.load.start`,{path:window.location.pathname}),(async()=>{try{let e=await Ne();me(e);let[r,a,s,c,l,u]=await Promise.all([Fe(),Le({from:e.window.from,to:e.window.to}),ze(e.window).catch(e=>(console.error(`Failed to load dashboard:`,e),null)),Ie().catch(e=>(console.error(`Failed to load projects:`,e),{projects:[]})),Ve(),Pe().catch(e=>(console.error(`Failed to load scan status:`,e),null))]);n(r),i(a.sessions),ie(c.projects),o(l.bookmarks),u&&Ce(u),s&&re(s),N(`app.load.done`,{duration_ms:Math.round(performance.now()-t),agents:r.length,sessions:a.sessions.length,projects:c.projects.length,dashboard:!!s})}catch(e){console.error(`Failed to load data:`,e),N(`app.load.error`,{duration_ms:Math.round(performance.now()-t),error:e instanceof Error?e.message:String(e)}),u(`Failed to load data. Is the CLI server running?`)}finally{c(!1)}})(),()=>e.abort()},[]);let P=f(),Ke=(0,j.useMemo)(()=>new Set(t.map(e=>e.name.toLowerCase())),[t]),qe=(0,j.useMemo)(()=>new Map(t.map(e=>[e.name.toLowerCase(),e.displayName])),[t]),I=_e,L=(0,j.useMemo)(()=>eo(P.pathname,Ke),[P.pathname,Ke]);(0,j.useEffect)(()=>{N(`route.change`,{path:P.pathname,mode:L.mode,agent:L.activeAgentKey,session:L.activeSessionSlug})},[P.pathname,L.mode,L.activeAgentKey,L.activeSessionSlug]),(0,j.useEffect)(()=>{if(L.mode===`projects`||L.mode===`project`){ae(`projects`),L.mode===`project`&&S({kind:L.activeProjectKind,key:L.activeProjectKey});return}(L.mode===`agent`||L.mode===`missingAgent`)&&ae(`agents`)},[L]);let Ye=I?E:typeof P.state==`object`&&P.state!==null&&`searchQuery`in P.state&&typeof P.state.searchQuery==`string`?P.state.searchQuery:``,R=(0,j.useMemo)(()=>Qa(r,t),[r,t]);(0,j.useEffect)(()=>{let e=!1;return o(t=>{let n=zi(t,r);return n===t?t:(Ue(n.map(({bookmarked_at:e,...t})=>t)).catch(t=>{e||console.error(`Failed to sync bookmark snapshots:`,t)}),n)}),()=>{e=!0}},[r]),(0,j.useEffect)(()=>{let e=!1;return(async()=>{let t=Ii();if(t.length!==0)try{let n=await Ue(t.map(({bookmarked_at:e,...t})=>t));if(e)return;o(n.bookmarks),Li()}catch(t){e||console.error(`Failed to migrate legacy bookmarks:`,t)}})(),()=>{e=!0}},[]);let z=(0,j.useMemo)(()=>new Set(a.map(e=>Pi(e.agentKey,e.sessionId))),[a]);function Xe(e,t){return z.has(Pi(e,t))}function B(e){let t=Pi(e.agentKey,e.sessionId),n=z.has(t),r=a;o(n?r.filter(e=>Pi(e.agentKey,e.sessionId)!==t):[...r,e].toSorted((e,t)=>{let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n})),N(n?`bookmark.delete`:`bookmark.add`,{agent:e.agentKey,session:e.sessionId}),(n?We(e.agentKey,e.sessionId):He({agentKey:e.agentKey,sessionId:e.sessionId,fullPath:e.fullPath,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats})).catch(e=>{console.error(`Failed to toggle bookmark:`,e),o(r)})}function V(e,t){B(Fi(e,t))}let H=L.activeAgentKey,Ze=L.mode===`project`?L.activeProjectKind:null,Qe=L.mode===`project`?L.activeProjectKey:null,$e=(0,j.useMemo)(()=>Ze&&Qe?{kind:Ze,key:Qe}:null,[Ze,Qe]),et=$e?Hi($e):null,tt=(0,j.useMemo)(()=>L.mode===`session`?R.byRouteKey.get(Ya(L.activeAgentKey,L.activeSessionSlug))??null:null,[R,L]),nt=(L.mode===`session`&&p?.id===L.activeSessionSlug?p:null)?.project_identity??tt?.project_identity??null,rt=x===`projects`?$e??(L.mode===`session`?nt:oe):null,it=rt?Hi(rt):null,at=(0,j.useMemo)(()=>H?R.byAgent.get(H)??[]:[],[H,R]),ot=(0,j.useMemo)(()=>it?C?R.byProjectAgentKey.get(Xa(it,C))??[]:R.byProjectIdentityKey.get(it)??[]:[],[C,it,R]),U=x===`projects`?ot:at,st=(0,j.useMemo)(()=>$a(U),[U]),W=(0,j.useMemo)(()=>U.length===0?new Set:new Set(U.filter(e=>z.has(Pi(Ja(e),e.id))).map(e=>e.id)),[z,U]),ct=(0,j.useMemo)(()=>a.toSorted((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created)),[a]),lt=(0,j.useMemo)(()=>{let e=_o.find(e=>e.id===D.costRange);return{agent:D.agent,projectKey:D.projectKey,tag:D.tag,tool:D.tool,fileKind:D.fileKind,costMin:e?.costMin}},[D]),ut=E.trim().length>0||!!(D.tool||D.fileKind),dt=io(k),ft=k?.active===!0,pt=(0,j.useMemo)(()=>{let e=_o.find(e=>e.id===D.costRange),t=D.agent?R.byAgent.get(D.agent)??[]:null,n=D.projectKey?R.byProjectKey.get(D.projectKey)??[]:null,r=t&&n?t.length<=n.length?t:n:t??n??R.sessionsByActivity,i=[];for(let t of r)if(!(D.agent&&Ja(t)!==D.agent)&&!(D.projectKey&&t.project_identity?.key!==D.projectKey)&&!(D.tag&&!t.smart_tags?.includes(D.tag))&&!(e&&t.stats.total_cost<e.costMin)&&(i.push({agentName:Ja(t),session:t,snippet:`Recent session · ${t.directory}`,matchType:`recent`}),i.length>=50))break;return i},[D,R]),mt=L.mode===`session`?`${L.activeAgentKey}/${L.activeSessionSlug}`:``,ht=(0,j.useEffectEvent)(async e=>{try{let t=!!(e.changedSessionHeads&&e.removedSessionRefs);t&&i(t=>uo(t,e)??t);let[r,a,o,s,c,l]=await Promise.all([Fe(),t?Promise.resolve(null):Le({from:w?.window.from,to:w?.window.to}),ze(w?.window).catch(e=>(console.error(`Failed to refresh dashboard:`,e),null)),Ie().catch(e=>(console.error(`Failed to refresh projects:`,e),{projects:[]})),L.mode===`project`?ze(w?.window,{projectKind:L.activeProjectKind,projectKey:L.activeProjectKey,agent:C}).catch(e=>(console.error(`Failed to refresh project dashboard:`,e),null)):Promise.resolve(null),I&&ut?Be(E,lt).catch(e=>(console.error(`Failed to refresh search results:`,e),{results:[]})):Promise.resolve(null)]);if(n(r),a&&i(a.sessions),ie(s.projects),o&&re(o),c&&ce(c),l&&be(l.results),L.mode===`session`)try{h(await Re(L.activeAgentKey,L.activeSessionSlug)),te(null)}catch{h(null),te(`Session not found`)}e.newSessions>0&&v(`发现 ${e.newSessions} 个新会话,列表已自动刷新`)}catch(e){console.error(`Failed to sync live session update:`,e)}});(0,j.useEffect)(()=>{if(!I){be([]),Se(!1);return}if(!ut){be(pt),Se(!1);return}let e=!1;Se(!0);let t=performance.now();return N(`search.start`,{query_length:E.length}),Be(E,lt).then(n=>{e||(be(n.results),N(`search.done`,{duration_ms:Math.round(performance.now()-t),results:n.results.length}))}).catch(n=>{e||(console.error(`Failed to load search results:`,n),N(`search.error`,{duration_ms:Math.round(performance.now()-t),error:n instanceof Error?n.message:String(n)}),be([]))}).finally(()=>{e||Se(!1)}),()=>{e=!0}},[E,I,pt,lt,ut]),(0,j.useEffect)(()=>{if(L.mode!==`session`){h(null),te(null);return}let e=new AbortController;_(!0),te(null);let t=performance.now();return N(`session.open.start`,{agent:L.activeAgentKey,session:L.activeSessionSlug}),(async()=>{try{let e=await Re(L.activeAgentKey,L.activeSessionSlug);h(e),N(`session.open.done`,{agent:L.activeAgentKey,session:L.activeSessionSlug,duration_ms:Math.round(performance.now()-t),messages:e.messages.length})}catch(e){N(`session.open.error`,{agent:L.activeAgentKey,session:L.activeSessionSlug,duration_ms:Math.round(performance.now()-t),error:e instanceof Error?e.message:String(e)}),te(`Session not found`),h(null)}finally{_(!1)}})(),()=>e.abort()},[mt,L.activeAgentKey,L.activeSessionSlug,L.mode]),(0,j.useEffect)(()=>{et&&pe(void 0)},[et]),(0,j.useEffect)(()=>{if(!Qe||!w){ce(null),fe(null),ue(!1);return}let e=!1;return ue(!0),fe(null),ze(w.window,{projectKind:Ze??void 0,projectKey:Qe,agent:C}).then(t=>{e||ce(t)}).catch(t=>{e||(console.error(`Failed to load project dashboard:`,t),ce(null),fe(`Failed to load project dashboard`))}).finally(()=>{e||ue(!1)}),()=>{e=!0}},[Ze,Qe,w,C]),(0,j.useEffect)(()=>Ge(e=>{ht(e)},e=>{Ce(e)}),[]),(0,j.useEffect)(()=>{if(!ne)return;let e=window.setTimeout(()=>{v(null)},3500);return()=>{window.clearTimeout(e)}},[ne]),(0,j.useEffect)(()=>{try{Ae(window.localStorage.getItem(po)===`1`)}catch{Ae(!0)}},[]),(0,j.useEffect)(()=>{if(I){Ee(e=>O.length===0?0:Math.min(e,O.length-1));return}if(L.mode===`session`){A(L.activeSessionSlug);return}if(L.mode===`agent`){A(null);return}A(null)},[I,O.length,L.mode,L.activeSessionSlug,U]),(0,j.useEffect)(()=>{if(!I)return;let e=O[Te];if(!e)return;let t=`${e.agentName}/${e.session.id}`;Me.current.get(t)?.scrollIntoView({block:`nearest`})},[I,O,Te]);let gt=R.landingSessions,_t=(0,j.useMemo)(()=>et?R.byLandingProjectIdentityKey.get(et)??[]:[],[et,R]),vt=(0,j.useMemo)(()=>t.filter(e=>e.count>0).map(e=>({key:e.name.toLowerCase(),name:e.displayName,icon:e.icon,count:e.count})),[t]),G=(0,j.useMemo)(()=>t.find(e=>e.name.toLowerCase()===H)??null,[H,t]),yt=(0,j.useMemo)(()=>b.find(e=>et===Hi(so(e)))??null,[et,b]),bt=(0,j.useMemo)(()=>b.find(e=>it===Hi(so(e)))??null,[b,it]),xt=R.projectOptions,St=(0,j.useMemo)(()=>{if(!ut)return xt;let e=new Map,t=xe?[]:O;for(let n of t){let t=n.session.project_identity;if(!t?.key)continue;let r=e.get(t.key);r?r.count+=1:e.set(t.key,{key:t.key,label:t.displayName||n.session.directory,count:1,showCount:!1})}if(D.projectKey&&!e.has(D.projectKey)){let t=xt.find(e=>e.key===D.projectKey);t&&e.set(t.key,{...t,count:0,showCount:!1})}return[...e.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)},[xt,D.projectKey,xe,O,ut]),K=`CodeSesh`,q=`Select an agent to browse sessions`;if(L.mode===`root`&&(K=I?`Search`:`Dashboard`,q=I?ro(E,xe,O.length):y?`${y.totals.sessions.toLocaleString(`en-US`)} total sessions across ${y.perAgent.length} agents`:`Aggregated view across all agents`),L.mode===`projects`&&(K=`Projects`,q=`${b.length.toLocaleString(`en-US`)} projects across ${r.length.toLocaleString(`en-US`)} sessions`),L.mode===`project`&&(K=yt?.displayName??`Project`,q=yt?`${yt.sessionCount.toLocaleString(`en-US`)} sessions · ${yt.agentStats.length} agents`:L.activeProjectKey),L.mode===`agent`&&H&&(K=G?.displayName??H,q=`${U.length} sessions`),L.mode===`session`){if(ee)K=`Session Not Found`,q=`Requested /${H}/${L.activeSessionSlug}`;else if(p){K=p.title||`Conversation`;let e=p.time_updated??p.time_created;q=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{children:[`ID: #`,p.id.slice(0,8)]}),(0,F.jsx)(`span`,{children:`·`}),(0,F.jsxs)(`span`,{children:[`Updated `,co(e)]}),(0,F.jsx)(Je,{tags:p.smart_tags,limit:9,className:`inline-flex`})]})}}L.mode===`missingAgent`&&(K=`Agent Not Found`,q=`Requested /${L.attemptedKey}`),L.mode===`missingSession`&&(K=`Session Not Found`,q=`Session not found in /${H}`),I&&(K=`Search`,q=ro(E,xe,O.length));let Ct=(0,j.useMemo)(()=>{if(I)return[{label:`Search`}];let e={label:`Dashboard`,to:x===`agents`&&L.mode===`root`||x===`projects`&&L.mode===`projects`?void 0:x===`projects`?`/projects`:`/`};if(L.mode===`root`)return[{label:`Dashboard`}];let t={label:`Projects`,to:L.mode===`project`?`/projects`:void 0};if(L.mode===`projects`)return[e,{label:`Projects`}];if(L.mode===`project`)return[e,t,{label:yt?.displayName??L.activeProjectKey}];if(L.mode===`session`&&x===`projects`&&rt)return[e,{label:`Projects`,to:`/projects`},{label:bt?.displayName??rt.key,to:Wi(rt)},{label:p?.title||L.activeSessionSlug||`Conversation`}];if(L.mode===`missingAgent`)return[e,{label:L.attemptedKey}];let n=G?.displayName??H??`Unknown Agent`,r={label:n,to:L.mode===`session`?`/${H}`:void 0};return L.mode===`agent`?[e,{label:n}]:L.mode===`missingSession`?[e,r,{label:L.attemptedSessionSlug}]:L.mode===`session`?[e,r,{label:p?.title||L.activeSessionSlug||`Conversation`}]:[e,{label:`Invalid Route`}]},[G,H,yt,x,I,bt,rt,p?.title,L]),wt;wt=s?(0,F.jsx)(_i,{}):I?(0,F.jsx)(wo,{query:E,loading:xe,results:O,agentNameMap:qe,agents:t,projects:St,filters:D,onChangeFilters:ye,onOpenResult:()=>{ve(!1),ge(``)},selectedIndex:Te,registerResultRef:(e,t)=>{t?Me.current.set(e,t):Me.current.delete(e)}}):l?(0,F.jsx)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6 text-sm text-[var(--console-error)]`,children:l}):L.mode===`root`?y?(0,F.jsx)(va,{data:y,projects:b,bookmarkedSessions:ct,isBookmarked:Xe,onToggleBookmark:(e,t)=>{if(`agentName`in e){V(e,t??e.agentName.toLowerCase());return}B(e)}}):(0,F.jsx)(ki,{type:`global`,sessions:gt,agentItems:vt,isBookmarked:Xe,onToggleBookmark:e=>V(e,e.agentKey)}):L.mode===`projects`?(0,F.jsx)(Da,{projects:b}):L.mode===`project`?(0,F.jsx)(ja,{project:yt,projectKey:L.activeProjectKey,dashboard:se,loading:le,error:de,sessions:_t,activeAgent:C,onChangeAgent:pe,isBookmarked:Xe,onToggleSessionBookmark:V}):L.mode===`agent`&&H?(0,F.jsx)(ki,{type:`agent`,sessions:R.byLandingAgent.get(H)??[],agentItems:vt,activeAgentKey:H,isBookmarked:Xe,onToggleBookmark:e=>V(e,e.agentKey)}):L.mode===`session`?g?(0,F.jsx)(_i,{}):ee||!p?(0,F.jsx)(ki,{type:`missing-session`,sessions:R.byLandingAgent.get(L.activeAgentKey)??[],agentItems:vt,activeAgentKey:L.activeAgentKey,attemptedSessionSlug:L.activeSessionSlug,isBookmarked:Xe,onToggleBookmark:e=>V(e,e.agentKey)}):(0,F.jsx)(ti,{session:p,highlightQuery:Ye}):L.mode===`missingAgent`?(0,F.jsx)(ki,{type:`missing-agent`,sessions:gt,agentItems:vt,attemptedAgentKey:L.attemptedKey,isBookmarked:Xe,onToggleBookmark:e=>V(e,e.agentKey)}):(0,F.jsx)(`div`,{className:`text-sm text-[var(--console-muted)]`,children:`Invalid route.`});function Tt(){ge(T.trim()),ve(!0),Ee(0)}function J(){Ae(!0);try{window.localStorage.setItem(po,`1`)}catch{}}function Et(t){if(!(t===`projects`&&ft)){if(ae(t),A(null),t===`projects`){let t=nt??(L.mode===`session`?null:oe);e(t?Wi(t):`/projects`);return}e(`/`)}}let Dt=(0,j.useEffectEvent)(t=>{let n=t.key;if((t.metaKey||t.ctrlKey)&&n.toLowerCase()===`k`){t.preventDefault(),ve(!0),Ee(0),window.setTimeout(()=>{je.current?.focus(),je.current?.select()},0);return}if(t.defaultPrevented||t.metaKey||t.ctrlKey||t.altKey||t.isComposing)return;let r=t.target,i=bo(r);if(De){n===`Escape`&&(t.preventDefault(),Oe(!1));return}if(i){n===`Escape`&&(t.preventDefault(),r instanceof HTMLElement&&r.blur());return}if(n===`?`){t.preventDefault(),Oe(!0),J();return}if(n===`/`){t.preventDefault(),J(),ve(!0),je.current?.focus(),je.current?.select();return}if(n===`Escape`){if(t.preventDefault(),I){ve(!1),ge(``),he(``);return}if(L.mode===`session`&&L.activeAgentKey){if(x===`projects`&&rt){e(Wi(rt));return}e(`/${L.activeAgentKey}`)}return}if(I){if(O.length===0)return;if(n===`j`){t.preventDefault(),J(),Ee(e=>Math.min(e+1,O.length-1));return}if(n===`k`){t.preventDefault(),J(),Ee(e=>Math.max(e-1,0));return}if(n===`g`){t.preventDefault(),J(),Ee(0);return}if(n===`G`){t.preventDefault(),J(),Ee(O.length-1);return}if(n===`Enter`){let n=O[Te];if(!n)return;t.preventDefault(),J(),ve(!1),ge(``),e(`/${n.agentName.toLowerCase()}/${n.session.id}`,{state:{searchQuery:E}})}return}if(x===`agents`&&!H||U.length===0)return;let a=e=>{J();let t=we==null?-1:st.indexById.get(we)??-1,n=t>=0?t:e>=0?-1:U.length;A(U[Math.max(0,Math.min(n+e,U.length-1))]?.id??null)};if(n===`j`){t.preventDefault(),a(1);return}if(n===`k`){t.preventDefault(),a(-1);return}if(n===`g`){t.preventDefault(),J(),A(U[0]?.id??null);return}if(n===`G`){t.preventDefault(),J(),A(U.at(-1)?.id??null);return}if(n===`Enter`){let n=we==null?null:st.byId.get(we);if(!n)return;t.preventDefault(),J(),e(x===`projects`?`/${n.slug}`:`/${H}/${n.id}`)}});return(0,j.useEffect)(()=>(window.addEventListener(`keydown`,Dt),()=>window.removeEventListener(`keydown`,Dt)),[]),(0,F.jsxs)(`div`,{className:`console-ui flex h-screen flex-col overflow-hidden bg-[var(--console-bg)] text-[var(--console-text)]`,children:[(0,F.jsx)(`header`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/85 backdrop-blur-sm`,children:(0,F.jsxs)(`div`,{className:`grid min-h-14 grid-cols-[auto_1fr] items-center gap-3 px-4 py-2 sm:grid-cols-[auto_1fr_auto] sm:py-0`,children:[(0,F.jsxs)(d,{to:`/`,className:`flex items-center gap-2 text-[var(--console-text)]`,children:[(0,F.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`CodeSesh`,className:`h-6 w-6 rounded-sm`}),(0,F.jsx)(`span`,{className:`console-mono text-sm font-semibold uppercase tracking-[0.05em]`,children:`CodeSesh`})]}),(0,F.jsxs)(`form`,{className:`order-3 col-span-2 flex w-full items-center justify-center gap-2 sm:order-none sm:col-span-1 sm:mx-auto sm:max-w-[560px]`,onSubmit:e=>{e.preventDefault(),Tt()},children:[(0,F.jsx)(`label`,{className:`flex min-w-0 flex-1 items-center rounded-sm border border-[var(--console-border)] bg-white px-2 py-1`,children:(0,F.jsx)(`input`,{ref:je,value:T,onChange:e=>he(e.target.value),placeholder:`Search sessions /`,className:`console-mono w-full min-w-0 bg-transparent text-xs text-[var(--console-text)] outline-none placeholder:text-[var(--console-muted)]`})}),(0,F.jsx)(`button`,{type:`submit`,className:`console-mono rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] px-3 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Search`})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{Oe(!0),J()},className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-[var(--console-surface-muted)]`,title:`Show keyboard shortcuts`,children:[`?`,(0,F.jsx)(`span`,{className:`hidden sm:inline`,children:` Shortcuts`})]}),no(w)?(0,F.jsx)(`span`,{className:`console-mono hidden rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] md:inline-flex`,title:`Time window applied to agent counts, dashboard, and session list`,children:no(w)}):null,(0,F.jsxs)(`span`,{className:`console-mono hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-muted)] sm:inline-flex`,children:[`v`,`0.7.1`]})]})]})}),(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,F.jsx)(`aside`,{className:`hidden w-64 shrink-0 flex-col border-r border-[var(--console-border)] bg-[var(--console-sidebar-bg)] lg:flex`,children:(0,F.jsxs)(`div`,{className:`console-scrollbar flex-1 space-y-8 overflow-y-auto px-4 py-6`,children:[(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BROWSE BY`}),(0,F.jsx)(xo,{value:x,onChange:Et,projectsDisabled:ft})]}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`NAVIGATION`}),(0,F.jsxs)(`ul`,{className:`space-y-1 ${x===`projects`?`console-scrollbar max-h-[min(280px,calc(100vh-440px))] overflow-y-auto pr-1`:``}`,children:[(0,F.jsx)(`li`,{children:(0,F.jsxs)(d,{to:x===`projects`?`/projects`:`/`,className:`flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${x===`agents`&&L.mode===`root`||x===`projects`&&L.mode===`projects`?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,F.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`Dashboard`,className:`size-3.5 rounded-[2px]`}),(0,F.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:`Dashboard`})]})}),x===`agents`?t.map(e=>{let t=e.name.toLowerCase(),n=t===H,r=M.agents[t],i=ao(k,e.name),a=ft&&i!==null,o=`ml-4 flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${a?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-50`:n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,s=(0,F.jsxs)(F.Fragment,{children:[r?.icon&&(0,F.jsx)(`img`,{src:r.icon,alt:e.displayName,className:`size-3.5 object-contain`}),(0,F.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:e.displayName}),(0,F.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:i??oo(k,e.name,e.count)})]});return(0,F.jsxs)(`li`,{children:[a?(0,F.jsx)(`span`,{className:o,title:`Available after this agent scan completes`,children:s}):(0,F.jsx)(d,{to:`/${t}`,className:o,children:s}),i?(0,F.jsx)(`span`,{className:`ml-4 mt-1 block h-1 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,children:(0,F.jsx)(`span`,{className:`block h-full bg-[var(--console-accent)]`,style:{width:`${k?.agentStatuses[e.name]?.total?Math.round((k.agentStatuses[e.name]?.processed??0)/k.agentStatuses[e.name].total*100):8}%`}})}):null]},e.name)}):b.map(e=>{let t=so(e),n=it===Hi(t);return(0,F.jsx)(`li`,{children:(0,F.jsxs)(d,{to:Wi(t),onClick:()=>S(t),className:`ml-4 flex min-w-0 items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,F.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs`,children:e.displayName}),(0,F.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.sessionCount})]})},`${e.identityKind}:${e.identityKey}`)}),x===`agents`&&t.length===0&&!s?(0,F.jsx)(`li`,{children:(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:k?.active?`Scanning agents...`:`No agents found`})}):null,x===`projects`&&b.length===0&&!s?(0,F.jsx)(`li`,{children:(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:k?.active?`Scanning projects...`:`No projects found`})}):null]})]}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BOOKMARKS`}),ct.length===0?(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No bookmarks yet`}):(0,F.jsx)(`ul`,{className:`space-y-1`,children:ct.map(e=>{let t=L.mode===`session`&&L.activeAgentKey===e.agentKey&&L.activeSessionSlug===e.sessionId,n=M.agents[e.agentKey];return(0,F.jsx)(`li`,{children:(0,F.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border px-2 py-1.5 transition-colors ${t?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,F.jsxs)(d,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,F.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`span`,{className:`console-mono line-clamp-1 block text-xs`,children:e.title}),(0,F.jsx)(`span`,{className:`console-mono mt-0.5 line-clamp-1 block text-[10px] text-[var(--console-muted)]`,children:n?.name??e.agentKey})]})]}),(0,F.jsx)(vi,{active:!0,onToggle:()=>B(e)})]})},Pi(e.agentKey,e.sessionId))})})]}),(0,F.jsxs)(`section`,{children:[(0,F.jsxs)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:[`SESSIONS`,U.length>0?(0,F.jsx)(`span`,{className:`ml-2 text-[10px] font-normal text-[var(--console-muted)]`,children:`Navigate j k · Open Enter`}):null]}),x===`agents`&&!H?(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select an agent`}):x===`projects`&&!it?(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select a project`}):U.length===0?(0,F.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:k?.active?`Scanning sessions...`:`No sessions yet`}):x===`projects`?(0,F.jsx)(So,{sessions:U,activeSessionId:L.mode===`session`?L.activeSessionSlug:null,selectedSessionId:we,bookmarkedSessionIds:W,onSelectSession:t=>{A(t.id),e(`/${t.slug}`)},onToggleBookmark:e=>V(e,Ja(e))}):(0,F.jsx)(Ka,{sessions:U,activeSessionId:L.mode===`session`?L.activeSessionSlug:null,selectedSessionId:we,onSelectSession:t=>{A(t);let n=st.byId.get(t);n&&e(`/${n.slug}`)},bookmarkedSessionIds:W,onToggleBookmark:e=>V(e,Ja(e))})]})]})}),(0,F.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,F.jsx)(`section`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/70 px-4 py-4 backdrop-blur-sm md:px-8`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`console-mono mb-2 flex flex-wrap items-center gap-1 text-[11px] text-[var(--console-muted)]`,children:Ct.map((e,t)=>(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.to?(0,F.jsx)(d,{to:e.to,className:`transition-colors hover:text-[var(--console-text)]`,children:e.label}):(0,F.jsx)(`span`,{className:`text-[var(--console-text)]`,children:e.label}),t<Ct.length-1?(0,F.jsx)(`span`,{children:`/`}):null]},`${e.label}-${t}`))}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] font-bold uppercase text-[var(--console-muted)]`,children:L.mode===`session`?`Session`:L.mode===`root`?`Dashboard`:L.mode===`projects`?`Projects`:L.mode===`project`?`Project`:`Landing`}),(0,F.jsx)(`h1`,{className:`console-mono text-xl font-semibold tracking-tight text-[var(--console-text)]`,children:K})]}),(0,F.jsx)(`div`,{className:`console-mono mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-[var(--console-muted)]`,children:q}),(0,F.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[ke?null:(0,F.jsxs)(`div`,{className:`console-mono inline-flex items-center gap-2 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:[(0,F.jsx)(`span`,{children:`Keyboard navigation available`}),(0,F.jsx)(`span`,{className:`rounded-sm border border-[var(--console-border)] bg-white px-1`,children:`?`}),(0,F.jsx)(`button`,{type:`button`,onClick:J,className:`text-[var(--console-muted)] transition-colors hover:text-[var(--console-text)]`,"aria-label":`Dismiss keyboard shortcuts hint`,children:`×`})]}),!I&&L.mode===`session`?(0,F.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:`Esc back`}):null,!I&&L.mode===`session`&&p?(0,F.jsx)(Ra,{agentName:L.activeAgentKey,sessionId:p.id,directory:p.directory}):null]}),ne?(0,F.jsx)(`p`,{className:`console-mono mt-2 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:ne}):null,dt&&L.mode===`root`?(0,F.jsx)(`p`,{className:`console-mono mt-2 inline-flex max-w-4xl rounded-sm border border-[var(--console-warning-border)] bg-[var(--console-warning-bg)] px-2 py-1 text-[11px] leading-relaxed text-[var(--console-warning)]`,children:dt}):null]})}),(0,F.jsx)(`section`,{className:`console-scrollbar bg-grid min-h-0 flex-1 overflow-y-auto px-4 py-6 md:px-8`,children:(0,F.jsx)(Ma,{children:wt})})]})]}),De?(0,F.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/35 px-4`,onClick:()=>Oe(!1),children:(0,F.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Keyboard shortcuts`,className:`w-full max-w-2xl rounded-sm border border-[var(--console-border-strong)] bg-white p-5 shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`Keyboard Shortcuts`}),(0,F.jsx)(`h2`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:`Navigate without leaving the keyboard`})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>Oe(!1),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Esc`})]}),(0,F.jsx)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-3`,children:yo.map(e=>(0,F.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-4`,children:[(0,F.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:e.title}),(0,F.jsx)(`div`,{className:`mt-3 space-y-3`,children:e.items.map(e=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-text)]`,children:e.keys}),(0,F.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-[var(--console-muted)]`,children:e.description})]},e.keys))})]},e.title))})]})}):null]})}function wo({query:e,loading:t,results:n,agentNameMap:r,agents:i,projects:a,filters:o,onChangeFilters:s,onOpenResult:c,selectedIndex:l,registerResultRef:u}){let f=(0,F.jsx)(To,{agents:i,projects:a,filters:o,onChangeFilters:s});return t?(0,F.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,(0,F.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:4}).map((e,t)=>(0,F.jsxs)(`div`,{className:`animate-pulse rounded-sm border border-[var(--console-border)] bg-white/80 p-4`,children:[(0,F.jsx)(`div`,{className:`h-3 w-32 rounded bg-[var(--console-surface-muted)]`}),(0,F.jsx)(`div`,{className:`mt-3 h-4 w-2/3 rounded bg-[var(--console-surface-muted)]`}),(0,F.jsx)(`div`,{className:`mt-2 h-3 w-full rounded bg-[var(--console-surface-muted)]`}),(0,F.jsx)(`div`,{className:`mt-1 h-3 w-5/6 rounded bg-[var(--console-surface-muted)]`})]},t))})]}):n.length===0?(0,F.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,(0,F.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/80 p-6`,children:[(0,F.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:e?`No matches`:`No recent sessions`}),e?(0,F.jsxs)(`p`,{className:`console-mono mt-2 text-xs text-[var(--console-muted)]`,children:[`Query: `,e]}):null]})]}):(0,F.jsxs)(`div`,{className:`grid gap-3`,children:[f,(0,F.jsx)(`div`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Navigate j k · Open Enter · Exit Esc`}),n.map((t,n)=>{let i=t.agentName.toLowerCase(),a=r.get(i)??t.agentName,o=`${t.agentName}/${t.session.id}`;return(0,F.jsxs)(d,{ref:e=>u(o,e),to:`/${i}/${t.session.id}`,state:{searchQuery:e},onClick:c,className:`rounded-sm border bg-white/85 p-4 transition-colors hover:border-[var(--console-border-strong)] hover:bg-white ${n===l?`border-[var(--console-border-strong)]`:`border-[var(--console-border)]`}`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:a}),(0,F.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:vo[t.matchType]}),(0,F.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:t.session.directory})]}),(0,F.jsx)(`h2`,{className:`console-mono mt-3 text-sm font-semibold text-[var(--console-text)]`,children:t.session.title}),(0,F.jsx)(Je,{tags:t.session.smart_tags,className:`mt-2`}),(0,F.jsx)(`p`,{className:`console-mono mt-2 text-xs leading-6 text-[var(--console-muted)] [&_mark]:bg-[var(--console-accent)] [&_mark]:px-0.5 [&_mark]:text-white`,dangerouslySetInnerHTML:{__html:fo(t.snippet||t.session.title)}})]},o)})]})}function To({agents:e,projects:t,filters:n,onChangeFilters:r}){let i=Object.values(n).some(Boolean),a=(e,t)=>{r(n=>({...n,[e]:n[e]===t?void 0:t}))};return(0,F.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/85 p-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Scope`}),(0,F.jsx)(Eo,{active:!n.projectKey,label:`All`,onClick:()=>r(e=>({...e,projectKey:void 0}))}),t.map(e=>(0,F.jsx)(Eo,{active:n.projectKey===e.key,label:e.showCount===!1?e.label:`${e.label} · ${e.count}`,onClick:()=>a(`projectKey`,e.key)},e.key))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Agent`}),(0,F.jsx)(Eo,{active:!n.agent,label:`All Agents`,onClick:()=>r(e=>({...e,agent:void 0}))}),e.map(e=>(0,F.jsx)(Eo,{active:n.agent===e.name,label:e.displayName,onClick:()=>a(`agent`,e.name)},e.name))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Tag`}),mo.map(e=>(0,F.jsx)(Eo,{active:n.tag===e,label:Ke[e],onClick:()=>a(`tag`,e)},e))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Signal`}),ho.map(e=>(0,F.jsx)(Eo,{active:n.tool===e,label:`tool:${e}`,onClick:()=>a(`tool`,e)},e))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`File Activity`}),go.map(e=>(0,F.jsx)(Eo,{active:n.fileKind===e.kind,label:e.label,onClick:()=>a(`fileKind`,e.kind)},e.kind))]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Cost Range`}),(0,F.jsx)(Eo,{active:!n.costRange,label:`Any Cost`,onClick:()=>r(e=>({...e,costRange:void 0}))}),_o.map(e=>(0,F.jsx)(Eo,{active:n.costRange===e.id,label:e.label,onClick:()=>a(`costRange`,e.id)},e.id)),i?(0,F.jsx)(`button`,{type:`button`,onClick:()=>r({}),className:`console-mono ml-auto rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[10px] text-[var(--console-muted)] transition-colors hover:bg-white`,children:`Clear`}):null]})]})}function Eo({active:e,label:t,onClick:n}){return(0,F.jsx)(`button`,{type:`button`,onClick:n,className:`console-mono rounded-sm border px-2 py-1 text-[10px] transition-colors ${e?`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-white`}`,children:t})}Me.createRoot(document.getElementById(`root`)).render((0,F.jsx)(j.StrictMode,{children:(0,F.jsx)(ie,{children:(0,F.jsx)(Co,{})})}));
@@ -158,7 +158,7 @@
158
158
  }
159
159
  }
160
160
  </style>
161
- <script type="module" crossorigin src="/assets/index-Dy__ZJD8.js"></script>
161
+ <script type="module" crossorigin src="/assets/index-LM0Z2sjk.js"></script>
162
162
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-Dw2cE7zH.js">
163
163
  <link rel="modulepreload" crossorigin href="/assets/markdown-CnUlvKkZ.js">
164
164
  <link rel="modulepreload" crossorigin href="/assets/react-DT3QPCDf.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codesesh",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "One place to see every AI coding session you've ever had. Unify Claude Code, Cursor, Kimi, Codex, and OpenCode sessions in a single, beautiful Web UI.",
5
5
  "keywords": [
6
6
  "ai",