@wrongstack/webui 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AgentRosterView-CtUX-VHJ.js +12 -0
- package/dist/assets/{AnalyticsDashboard-tA_UUQWD.js → AnalyticsDashboard-fPe6DYsh.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-DNopUX7m.js → AudienceMemoryPanel-i53Y5nRR.js} +1 -1
- package/dist/assets/{ChangesView-Cij-BSUX.js → ChangesView-CFOQZBoO.js} +1 -1
- package/dist/assets/{ChimeraReviewsView-1TlYFUrk.js → ChimeraReviewsView-BQe81cSZ.js} +1 -1
- package/dist/assets/{ChronicleDashboard-mZgdM2It.js → ChronicleDashboard-Dc2rEfEh.js} +1 -1
- package/dist/assets/{CodeEditor-CXf7lq5W.js → CodeEditor-DhA63AyO.js} +2 -2
- package/dist/assets/{CodeMap-CoQQ76zV.js → CodeMap-6sHlGgjj.js} +1 -1
- package/dist/assets/{CronJobsPanel-CL4m2QgQ.js → CronJobsPanel-C30TtTM7.js} +1 -1
- package/dist/assets/{DeadCodeScanPanel-DxCRT8rV.js → DeadCodeScanPanel-j3n15R1p.js} +1 -1
- package/dist/assets/{DebugDashboard-CMbbIq8d.js → DebugDashboard-jJxP9Qek.js} +1 -1
- package/dist/assets/{DesignGalleryView-CcX5u8rA.js → DesignGalleryView-tw6AdJGD.js} +1 -1
- package/dist/assets/{GoalView-CVjWpHkb.js → GoalView-DsGdbElx.js} +1 -1
- package/dist/assets/{KanbanView-DQmHGtH3.js → KanbanView-B8USJasA.js} +1 -1
- package/dist/assets/{MailboxDetailView-CfJjqySh.js → MailboxDetailView-jsHPTvQO.js} +1 -1
- package/dist/assets/{MemoryDrawer-C72rzAy0.js → MemoryDrawer-BdcWptmP.js} +1 -1
- package/dist/assets/{MemoryManager-DOZYeDYO.js → MemoryManager-Cawc6tAj.js} +1 -1
- package/dist/assets/{ProcessMonitor-C7h419Eb.js → ProcessMonitor-Bvgcuk_7.js} +1 -1
- package/dist/assets/{PromptJournalView-UkyefQGK.js → PromptJournalView-BUgpBI3V.js} +1 -1
- package/dist/assets/{ProviderTestView-B74V32hh.js → ProviderTestView-CztiodHF.js} +1 -1
- package/dist/assets/{QueuePanel-CW3iERCF.js → QueuePanel-BQQfIbGH.js} +1 -1
- package/dist/assets/{RefreshDebugView-CDfO7Uid.js → RefreshDebugView-CCk1X8Hz.js} +1 -1
- package/dist/assets/{RepositoryHistoryView-DnJ5jcgB.js → RepositoryHistoryView-BFiEVjF-.js} +1 -1
- package/dist/assets/{RequirementIntakeView-CSTVrB4Y.js → RequirementIntakeView-ByVm-u0p.js} +1 -1
- package/dist/assets/{SageTabs-DMFqP3JS.js → SageTabs-BnjtZSVk.js} +2 -2
- package/dist/assets/{SddFlowGraph-hmWEIf45.js → SddFlowGraph-CZQxxeJv.js} +1 -1
- package/dist/assets/SddHub-CimqjJhd.js +2 -0
- package/dist/assets/{SessionInspectView-DA0kAM4e.js → SessionInspectView-DnzU3hjG.js} +1 -1
- package/dist/assets/{SessionList-17tCMc4D.js → SessionList-DBcHNwcc.js} +1 -1
- package/dist/assets/{SessionsDashboard-CvrLsLGL.js → SessionsDashboard-DofL975M.js} +1 -1
- package/dist/assets/{SetupScreen-BHcAa0VI.js → SetupScreen-DQAqt8Dn.js} +1 -1
- package/dist/assets/{SkillDetailView-BODqDrPU.js → SkillDetailView-BcG2XIwr.js} +2 -2
- package/dist/assets/{TechStackView-DjP_PhtH.js → TechStackView-Ce3WNG85.js} +1 -1
- package/dist/assets/{TerminalPanel-perOinUJ.js → TerminalPanel-B3SOIzJY.js} +1 -1
- package/dist/assets/{activity-DThW4oMo.js → activity-BGw29FDK.js} +1 -1
- package/dist/assets/{activity-DZ2z6LSR.js → activity-CbWiifO9.js} +1 -1
- package/dist/assets/{activity-oY2h83Fp.js → activity-D8n7MaKo.js} +1 -1
- package/dist/assets/{activity-EReqzYpW.js → activity-DYH5K2cA.js} +1 -1
- package/dist/assets/{activity-CHP09wRx.js → activity-DdvIZYux.js} +1 -1
- package/dist/assets/{activity-DDfoWJrR.js → activity-S9f20P0d.js} +1 -1
- package/dist/assets/{activity-BKJV5XjX.js → activity-pDZp_UqI.js} +1 -1
- package/dist/assets/{button-CN_h6kNT.js → button-h7DHXgna.js} +1 -1
- package/dist/assets/{chat-store-BVz6zQLP.js → chat-store-DpI9nO_z.js} +1 -1
- package/dist/assets/{codemap-activity-store-RqE4L9Os.js → codemap-activity-store-5hcdmofR.js} +1 -1
- package/dist/assets/config-store-D7yrCV2X.js +22 -0
- package/dist/assets/{dialog-DNsBc-EF.js → dialog-CTmNJKRN.js} +1 -1
- package/dist/assets/{empty-state-BFPCt03_.js → empty-state-Dl66htl_.js} +1 -1
- package/dist/assets/{i18n-BwptPW9U.js → i18n-B_njdXiH.js} +2 -2
- package/dist/assets/index-CfREDCPe.js +170 -0
- package/dist/assets/{input-BnTFqRjn.js → input-DAvKojvP.js} +1 -1
- package/dist/assets/{mailbox-store-CV5--Nmh.js → mailbox-store-5Dizermg.js} +1 -1
- package/dist/assets/{markdown-BzOXYqOo.js → markdown-CXRzjX3p.js} +1 -1
- package/dist/assets/{monaco-COtIgMfE.js → monaco-CbI7qrVD.js} +1 -1
- package/dist/assets/{monaco-theme-ruX2YdTu.js → monaco-theme-Dr3-rSid.js} +1 -1
- package/dist/assets/{roster-ws-Cx9Bzoh0.js → roster-ws-CSbZSs3G.js} +1 -1
- package/dist/assets/{shared-h0I65HLY.js → shared-BirfDJmq.js} +1 -1
- package/dist/assets/{stores-Bt7wAdGA.js → stores-COxKgvNx.js} +1 -1
- package/dist/assets/{ui-store-CMdVzHOn.js → ui-store-BROszDxo.js} +1 -1
- package/dist/assets/{utils-sO9lidp6.js → utils-DQbrPaAM.js} +1 -1
- package/dist/assets/{vector-memory-panel-BtQElVO4.js → vector-memory-panel-fEdfCaDJ.js} +1 -1
- package/dist/assets/vendor-BO-lHyIr.js +116 -0
- package/dist/assets/{view-navigation-BDsXeQ5i.js → view-navigation-CVnKqjL2.js} +1 -1
- package/dist/assets/{vite-preload-Czpn1I53.js → vite-preload-BZ1Pz5am.js} +1 -1
- package/dist/components/ChatInput/subagent-model-picker-dialog.d.ts +43 -0
- package/dist/components/SettingsPanel/SubagentModelsSection.d.ts +6 -9
- package/dist/hooks/ws-handlers/session-execution-handlers.d.ts +10 -0
- package/dist/index.html +16 -16
- package/dist/index.js +10429 -9956
- package/dist/types/runtime.d.ts +25 -0
- package/dist/types/server-message.d.ts +2 -2
- package/package.json +26 -26
- package/dist/assets/AgentRosterView-C2PmzJWn.js +0 -12
- package/dist/assets/SddHub-BedY4SV-.js +0 -2
- package/dist/assets/config-store-CZdk-vPj.js +0 -22
- package/dist/assets/index-BYBlSXtn.js +0 -170
- package/dist/assets/vendor-Cvuk-OYN.js +0 -125
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-CZdk-vPj.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{J as i,Jn as a,La as o,Mi as s,Ot as c,Vr as l,Xi as u,br as d,dn as f,dt as p,ni as m,rn as h,ti as g}from"./vendor-Cvuk-OYN.js";import"./i18n-BwptPW9U.js";import{t as _}from"./utils-sO9lidp6.js";import{t as v}from"./button-CN_h6kNT.js";import{T as y,w as b}from"./index-BYBlSXtn.js";import{g as x,h as S,l as C,r as w,v as T}from"./shared-h0I65HLY.js";var E=e(n(),1);function D(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}var O={filePath:``,primaryMatches:[],symbolMatches:[],relatedMatches:[],totalCount:0,activeCount:0,supersededCount:0,reviewPendingCount:0};function k(e){let{filePath:n,lineStart:r,lineEnd:i,limit:a=50,showSuperseded:o=!0,showDeleted:s=!1,autoFetch:c=!0,sendOptions:l}=e,u=l?JSON.stringify(l):``,[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(null),_=(0,E.useRef)(0),v=(0,E.useRef)(null),y=(0,E.useRef)(l);y.current=l;let b=(0,E.useCallback)(()=>{if(!n){f(null),g(null),m(!1);return}let e=++_.current;m(!0),g(null);let c=t();if(!c){g(`WebSocket client unavailable`),m(!1);return}v.current?.(),v.current=null;let l=n,u=c.on(`memory.sage.forFile`,t=>{if(e!==_.current)return;let n=t.payload.response;n&&D(n.filePath)!==D(l)||(t.payload.error?(g(t.payload.error),f(null)):(f(n??O),g(null)),m(!1))});v.current=u;let d={filePath:n,limit:a,showSuperseded:o,showDeleted:s,...r===void 0?{}:{lineStart:r},...i===void 0?{}:{lineEnd:i}};try{c.findMemoriesForFile(d,y.current??void 0)}catch(t){u(),v.current===u&&(v.current=null),e===_.current&&(g(t instanceof Error?t.message:String(t)),m(!1))}},[n,r,i,a,o,s]);(0,E.useEffect)(()=>{if(c)return b(),()=>{_.current++,v.current?.(),v.current=null}},[c,b,u]);let x=(0,E.useCallback)(()=>{b()},[b]);return(0,E.useEffect)(()=>()=>{v.current?.(),v.current=null},[]),{data:d,loading:p,error:h,refetch:x}}var A=r();function j(e){return e>=.9?`bg-success/15 border-success/40`:e>=.7?`bg-info/15 border-info/40`:e>=.4?`bg-warning/10 border-warning/30`:`bg-muted/30 border-border/40`}function M(e){switch(e){case`scope_file`:return`scope: file`;case`scope_symbol`:return`scope: symbol`;case`anchor_file`:return`anchor: file`;case`anchor_symbol`:return`anchor: symbol`;case`anchor_directory`:return`anchor: directory`;case`mention`:return`text mention`}}function N({match:e,cursorBoosted:t,onShowMemory:n,onAcceptDeletion:r,onKeep:s,onUpdate:l,onMarkPermanent:m,onRecover:y,pendingAction:b}){let{t:E}=o(),D=e.memory.status===`deleted`,O=e.memory.status===`superseded`,k=e.pendingReview,N=b!==void 0,P=t===!0;return(0,A.jsxs)(`article`,{className:_(`group relative rounded-md border px-3 py-2 text-sm transition-colors`,j(e.matchStrength),P&&`ring-1 ring-primary/40 ring-offset-0`,D&&`opacity-70`),"data-match-via":e.matchedVia,"data-memory-id":e.memory.id,children:[(0,A.jsx)(`header`,{className:`flex items-start justify-between gap-2`,children:(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide`,children:[(0,A.jsx)(`span`,{className:_(`font-mono`,S(e.memory.kind)),children:w[e.memory.kind]??e.memory.kind}),(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,A.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:M(e.matchedVia)}),P&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-primary/15 px-1 py-0.5 font-mono text-primary`,title:E(`activity:memoryManager.anchorCursorHint`),children:[(0,A.jsx)(f,{className:`size-2.5`}),` `,E(`activity:memoryManager.cursorLabel`)]}),k&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-warning/15 px-1 py-0.5 font-mono text-warning`,title:E(`activity:memoryManager.hygieneReviewTitle`,{reason:k.reason,days:k.ageDays}),children:[(0,A.jsx)(p,{className:`size-2.5`}),` `,E(`activity:memoryManager.reviewLabel`)]}),D&&(0,A.jsx)(`span`,{className:`font-mono text-destructive`,children:E(`activity:memoryManager.statusDeleted`)}),O&&!D&&(0,A.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:E(`activity:memoryManager.statusSuperseded`)})]}),(0,A.jsx)(`p`,{className:`mt-1 text-foreground/90`,children:x(e.memory.text,200)}),(0,A.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(C,{status:e.memory.status}),(0,A.jsx)(`span`,{children:E(`activity:memoryManager.updatedSuffix`,{date:T(e.memory.updatedAt)})})]})]})}),(0,A.jsxs)(`footer`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[D&&y&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>y(e.memory.id),className:`h-7 gap-1 border-primary/40 px-2 text-[11px] text-primary hover:bg-primary/10`,title:E(`activity:memoryManager.restoreTitle`),children:[(0,A.jsx)(h,{className:`size-3`}),` `,E(`activity:memoryManager.actionRecover`)]}),O&&e.supersededByActiveId&&n&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>n(e.supersededByActiveId),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.supersededJumpTitle`),children:[(0,A.jsx)(d,{className:`size-3`}),` `,E(`activity:memoryManager.actionGoToActive`)]}),k&&(r||s||l||m)&&(0,A.jsxs)(A.Fragment,{children:[k.suggestedAction===`delete`&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`destructive`,disabled:N,onClick:()=>r?.(k.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.acceptSuggestionTitle`),children:[(0,A.jsx)(u,{className:`size-3`}),` `,E(`activity:memoryManager.actionAcceptDeletion`)]}),(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>s?.(k.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.rejectSuggestionTitle`),children:[(0,A.jsx)(i,{className:`size-3`}),` `,E(`activity:memoryManager.actionKeep`)]}),(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>l?.(e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.updateTitle`),children:[(0,A.jsx)(c,{className:`size-3`}),` `,E(`activity:memoryManager.actionUpdate`)]}),m&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>m(e.memory.id),className:`h-7 gap-1 border-warning/40 px-2 text-[11px] text-warning hover:bg-warning/10`,title:E(`activity:memoryManager.promoteTitle`),children:[(0,A.jsx)(f,{className:`size-3`}),` `,E(`activity:memoryManager.actionMarkPermanent`)]})]}),n&&!D&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`ghost`,disabled:N,onClick:()=>n(e.memory.id),className:`h-7 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,title:E(`activity:memoryManager.openRecordTitle`),children:[(0,A.jsx)(g,{className:`size-3`}),` `,E(`activity:memoryManager.actionShowFull`)]}),b&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(a,{className:`size-3 animate-spin`}),` `,b]})]})]})}function P({icon:e,title:t,count:n,matches:r,cursorBoosted:i=!1,...a}){let{t:s}=o(),c=y(r,10);return r.length===0?null:(0,A.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(e,{className:`size-3`}),(0,A.jsx)(`span`,{children:t}),(0,A.jsxs)(`span`,{className:`font-mono`,children:[`(`,n,`)`]}),i&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 font-mono text-[9px] text-primary`,children:[(0,A.jsx)(f,{className:`size-2.5`}),` `,s(`activity:memoryManager.cursorBoostTitle`)]})]}),(0,A.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:c.pageItems.map(e=>(0,A.jsx)(N,{match:e,cursorBoosted:i&&(e.matchedVia===`anchor_symbol`||e.matchedVia===`scope_symbol`),pendingAction:a.pendingActionById.get(e.memory.id),...a},e.memory.id))}),(0,A.jsx)(b,{page:c.page,pageSize:c.pageSize,totalItems:c.totalItems,onPageChange:c.setPage,compact:!0,itemLabel:s(`activity:memoryManager.itemLabel`)})]})}function F({filePath:e,lineStart:t,lineEnd:n,open:r,onClose:i,onShowMemory:a,onAcceptDeletion:c,onKeep:u,onUpdate:d,onMarkPermanent:y,onRecover:b}){let{t:x}=o(),[S,C]=(0,E.useState)(!1),[w,T]=(0,E.useState)(new Map),D={accepting:x(`activity:memoryManager.pendingAccepting`),keeping:x(`activity:memoryManager.pendingKeeping`),updating:x(`activity:memoryManager.pendingUpdating`),marking:x(`activity:memoryManager.pendingMarking`),recovering:x(`activity:memoryManager.pendingRecovering`)},{data:O,loading:j,error:M,refetch:N}=k({filePath:e,lineStart:t,lineEnd:n,showDeleted:S,autoFetch:r}),F=t!==void 0&&n!==void 0,L=(0,E.useCallback)(async(e,t,n)=>{if(n){T(n=>new Map(n).set(e,t));try{await n(e)}finally{T(t=>{let n=new Map(t);return n.delete(e),n})}}},[]);if((0,E.useEffect)(()=>{C(!1)},[e]),!r)return null;let R=O,z=R?.totalCount??0;return(0,A.jsxs)(`aside`,{className:`flex h-full min-h-0 w-full flex-col border-l border-border/70 bg-card/15`,"aria-label":x(`activity:memoryManager.fileDrawerAria`),"data-file-path":e??``,children:[(0,A.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(l,{className:`size-3`}),(0,A.jsx)(`span`,{className:`truncate font-mono`,title:e??``,children:e??x(`activity:memoryManager.noFile`)})]}),(0,A.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`font-mono`,children:x(`activity:memoryManager.memoriesCount`,{count:z})}),R&&R.reviewPendingCount>0&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 font-mono text-warning`,children:[(0,A.jsx)(p,{className:`size-3`}),x(`activity:memoryManager.pendingReviewCount`,{count:R.reviewPendingCount})]}),R&&R.supersededCount>0&&(0,A.jsx)(`span`,{className:`font-mono`,children:x(`activity:memoryManager.supersededCount`,{count:R.supersededCount})})]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,A.jsx)(v,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>N(),disabled:j||!e,className:`h-7 w-7 p-0`,"aria-label":x(`common:action.refresh`),title:x(`activity:memoryManager.requeryTitle`),children:(0,A.jsx)(h,{className:_(`size-3.5`,j&&`animate-spin`)})}),(0,A.jsx)(v,{type:`button`,size:`sm`,variant:`ghost`,onClick:i,className:`h-7 w-7 p-0`,"aria-label":x(`activity:memoryManager.closeDrawerAria`),title:x(`activity:memoryManager.closeDrawerTitle`),children:(0,A.jsx)(s,{className:`size-3.5`})})]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/40 bg-background/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked),className:`size-3 accent-primary`,disabled:!e,"data-testid":`memory-drawer-show-deleted`}),S?(0,A.jsx)(g,{className:`size-3`}):(0,A.jsx)(m,{className:`size-3`}),(0,A.jsx)(`span`,{children:x(`activity:memoryManager.showRecoverable`)})]}),F&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[10px] text-primary`,children:[(0,A.jsx)(f,{className:`size-3`}),` `,x(`activity:memoryManager.linesRange`,{start:t,end:n})]})]}),(0,A.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-3 py-3`,children:e?j&&!R?(0,A.jsx)(I,{loading:!0,message:x(`activity:memoryManager.loadingMemories`)}):M?(0,A.jsx)(I,{tone:`error`,message:x(`activity:memoryManager.errorPrefix`,{message:M})}):!R||z===0?(0,A.jsx)(I,{message:x(`activity:memoryManager.emptyNoMemories`,{file:e})}):(0,A.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,A.jsx)(P,{icon:f,title:x(`activity:memoryManager.cursorBoostTitle`),count:R.symbolMatches.length,cursorBoosted:F,matches:R.symbolMatches,pendingActionById:w,onShowMemory:a,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>c?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>u?.(e,t)),onUpdate:e=>L(e,D.updating,()=>d?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))}),(0,A.jsx)(P,{icon:l,title:x(`activity:memoryManager.fileScopedTitle`),count:R.primaryMatches.length,matches:R.primaryMatches,pendingActionById:w,onShowMemory:a,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>c?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>u?.(e,t)),onUpdate:e=>L(e,D.updating,()=>d?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))}),(0,A.jsx)(P,{icon:g,title:x(`activity:memoryManager.mentionedInTitle`),count:R.relatedMatches.length,matches:R.relatedMatches,pendingActionById:w,onShowMemory:a,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>c?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>u?.(e,t)),onUpdate:e=>L(e,D.updating,()=>d?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))})]}):(0,A.jsx)(I,{message:x(`activity:memoryManager.emptyOpenFile`)})})]})}function I({message:e,loading:t=!1,tone:n=`default`}){return(0,A.jsxs)(`div`,{className:_(`flex min-h-[120px] flex-col items-center justify-center gap-2 rounded-md border border-dashed border-border/60 px-4 py-6 text-center text-[11px]`,n===`error`?`text-destructive`:`text-muted-foreground`),children:[t&&(0,A.jsx)(a,{className:`size-4 animate-spin`}),(0,A.jsx)(`p`,{children:e})]})}export{F as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-D7yrCV2X.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{J as i,Jn as a,La as o,Mi as s,Ot as c,Vr as l,Xi as u,br as d,dt as f,fn as p,ni as m,rn as h,ti as g}from"./vendor-BO-lHyIr.js";import"./i18n-B_njdXiH.js";import{t as _}from"./utils-DQbrPaAM.js";import{t as v}from"./button-h7DHXgna.js";import{T as y,w as b}from"./index-CfREDCPe.js";import{g as x,h as S,l as C,r as w,v as T}from"./shared-BirfDJmq.js";var E=e(n(),1);function D(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}var O={filePath:``,primaryMatches:[],symbolMatches:[],relatedMatches:[],totalCount:0,activeCount:0,supersededCount:0,reviewPendingCount:0};function k(e){let{filePath:n,lineStart:r,lineEnd:i,limit:a=50,showSuperseded:o=!0,showDeleted:s=!1,autoFetch:c=!0,sendOptions:l}=e,u=l?JSON.stringify(l):``,[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(null),_=(0,E.useRef)(0),v=(0,E.useRef)(null),y=(0,E.useRef)(l);y.current=l;let b=(0,E.useCallback)(()=>{if(!n){f(null),g(null),m(!1);return}let e=++_.current;m(!0),g(null);let c=t();if(!c){g(`WebSocket client unavailable`),m(!1);return}v.current?.(),v.current=null;let l=n,u=c.on(`memory.sage.forFile`,t=>{if(e!==_.current)return;let n=t.payload.response;n&&D(n.filePath)!==D(l)||(t.payload.error?(g(t.payload.error),f(null)):(f(n??O),g(null)),m(!1))});v.current=u;let d={filePath:n,limit:a,showSuperseded:o,showDeleted:s,...r===void 0?{}:{lineStart:r},...i===void 0?{}:{lineEnd:i}};try{c.findMemoriesForFile(d,y.current??void 0)}catch(t){u(),v.current===u&&(v.current=null),e===_.current&&(g(t instanceof Error?t.message:String(t)),m(!1))}},[n,r,i,a,o,s]);(0,E.useEffect)(()=>{if(c)return b(),()=>{_.current++,v.current?.(),v.current=null}},[c,b,u]);let x=(0,E.useCallback)(()=>{b()},[b]);return(0,E.useEffect)(()=>()=>{v.current?.(),v.current=null},[]),{data:d,loading:p,error:h,refetch:x}}var A=r();function j(e){return e>=.9?`bg-success/15 border-success/40`:e>=.7?`bg-info/15 border-info/40`:e>=.4?`bg-warning/10 border-warning/30`:`bg-muted/30 border-border/40`}function M(e){switch(e){case`scope_file`:return`scope: file`;case`scope_symbol`:return`scope: symbol`;case`anchor_file`:return`anchor: file`;case`anchor_symbol`:return`anchor: symbol`;case`anchor_directory`:return`anchor: directory`;case`mention`:return`text mention`}}function N({match:e,cursorBoosted:t,onShowMemory:n,onAcceptDeletion:r,onKeep:s,onUpdate:l,onMarkPermanent:m,onRecover:y,pendingAction:b}){let{t:E}=o(),D=e.memory.status===`deleted`,O=e.memory.status===`superseded`,k=e.pendingReview,N=b!==void 0,P=t===!0;return(0,A.jsxs)(`article`,{className:_(`group relative rounded-md border px-3 py-2 text-sm transition-colors`,j(e.matchStrength),P&&`ring-1 ring-primary/40 ring-offset-0`,D&&`opacity-70`),"data-match-via":e.matchedVia,"data-memory-id":e.memory.id,children:[(0,A.jsx)(`header`,{className:`flex items-start justify-between gap-2`,children:(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide`,children:[(0,A.jsx)(`span`,{className:_(`font-mono`,S(e.memory.kind)),children:w[e.memory.kind]??e.memory.kind}),(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,A.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:M(e.matchedVia)}),P&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-primary/15 px-1 py-0.5 font-mono text-primary`,title:E(`activity:memoryManager.anchorCursorHint`),children:[(0,A.jsx)(p,{className:`size-2.5`}),` `,E(`activity:memoryManager.cursorLabel`)]}),k&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-warning/15 px-1 py-0.5 font-mono text-warning`,title:E(`activity:memoryManager.hygieneReviewTitle`,{reason:k.reason,days:k.ageDays}),children:[(0,A.jsx)(f,{className:`size-2.5`}),` `,E(`activity:memoryManager.reviewLabel`)]}),D&&(0,A.jsx)(`span`,{className:`font-mono text-destructive`,children:E(`activity:memoryManager.statusDeleted`)}),O&&!D&&(0,A.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:E(`activity:memoryManager.statusSuperseded`)})]}),(0,A.jsx)(`p`,{className:`mt-1 text-foreground/90`,children:x(e.memory.text,200)}),(0,A.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(C,{status:e.memory.status}),(0,A.jsx)(`span`,{children:E(`activity:memoryManager.updatedSuffix`,{date:T(e.memory.updatedAt)})})]})]})}),(0,A.jsxs)(`footer`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[D&&y&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>y(e.memory.id),className:`h-7 gap-1 border-primary/40 px-2 text-[11px] text-primary hover:bg-primary/10`,title:E(`activity:memoryManager.restoreTitle`),children:[(0,A.jsx)(h,{className:`size-3`}),` `,E(`activity:memoryManager.actionRecover`)]}),O&&e.supersededByActiveId&&n&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>n(e.supersededByActiveId),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.supersededJumpTitle`),children:[(0,A.jsx)(d,{className:`size-3`}),` `,E(`activity:memoryManager.actionGoToActive`)]}),k&&(r||s||l||m)&&(0,A.jsxs)(A.Fragment,{children:[k.suggestedAction===`delete`&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`destructive`,disabled:N,onClick:()=>r?.(k.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.acceptSuggestionTitle`),children:[(0,A.jsx)(u,{className:`size-3`}),` `,E(`activity:memoryManager.actionAcceptDeletion`)]}),(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>s?.(k.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.rejectSuggestionTitle`),children:[(0,A.jsx)(i,{className:`size-3`}),` `,E(`activity:memoryManager.actionKeep`)]}),(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>l?.(e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.updateTitle`),children:[(0,A.jsx)(c,{className:`size-3`}),` `,E(`activity:memoryManager.actionUpdate`)]}),m&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>m(e.memory.id),className:`h-7 gap-1 border-warning/40 px-2 text-[11px] text-warning hover:bg-warning/10`,title:E(`activity:memoryManager.promoteTitle`),children:[(0,A.jsx)(p,{className:`size-3`}),` `,E(`activity:memoryManager.actionMarkPermanent`)]})]}),n&&!D&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`ghost`,disabled:N,onClick:()=>n(e.memory.id),className:`h-7 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,title:E(`activity:memoryManager.openRecordTitle`),children:[(0,A.jsx)(g,{className:`size-3`}),` `,E(`activity:memoryManager.actionShowFull`)]}),b&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(a,{className:`size-3 animate-spin`}),` `,b]})]})]})}function P({icon:e,title:t,count:n,matches:r,cursorBoosted:i=!1,...a}){let{t:s}=o(),c=y(r,10);return r.length===0?null:(0,A.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(e,{className:`size-3`}),(0,A.jsx)(`span`,{children:t}),(0,A.jsxs)(`span`,{className:`font-mono`,children:[`(`,n,`)`]}),i&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 font-mono text-[9px] text-primary`,children:[(0,A.jsx)(p,{className:`size-2.5`}),` `,s(`activity:memoryManager.cursorBoostTitle`)]})]}),(0,A.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:c.pageItems.map(e=>(0,A.jsx)(N,{match:e,cursorBoosted:i&&(e.matchedVia===`anchor_symbol`||e.matchedVia===`scope_symbol`),pendingAction:a.pendingActionById.get(e.memory.id),...a},e.memory.id))}),(0,A.jsx)(b,{page:c.page,pageSize:c.pageSize,totalItems:c.totalItems,onPageChange:c.setPage,compact:!0,itemLabel:s(`activity:memoryManager.itemLabel`)})]})}function F({filePath:e,lineStart:t,lineEnd:n,open:r,onClose:i,onShowMemory:a,onAcceptDeletion:c,onKeep:u,onUpdate:d,onMarkPermanent:y,onRecover:b}){let{t:x}=o(),[S,C]=(0,E.useState)(!1),[w,T]=(0,E.useState)(new Map),D={accepting:x(`activity:memoryManager.pendingAccepting`),keeping:x(`activity:memoryManager.pendingKeeping`),updating:x(`activity:memoryManager.pendingUpdating`),marking:x(`activity:memoryManager.pendingMarking`),recovering:x(`activity:memoryManager.pendingRecovering`)},{data:O,loading:j,error:M,refetch:N}=k({filePath:e,lineStart:t,lineEnd:n,showDeleted:S,autoFetch:r}),F=t!==void 0&&n!==void 0,L=(0,E.useCallback)(async(e,t,n)=>{if(n){T(n=>new Map(n).set(e,t));try{await n(e)}finally{T(t=>{let n=new Map(t);return n.delete(e),n})}}},[]);if((0,E.useEffect)(()=>{C(!1)},[e]),!r)return null;let R=O,z=R?.totalCount??0;return(0,A.jsxs)(`aside`,{className:`flex h-full min-h-0 w-full flex-col border-l border-border/70 bg-card/15`,"aria-label":x(`activity:memoryManager.fileDrawerAria`),"data-file-path":e??``,children:[(0,A.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(l,{className:`size-3`}),(0,A.jsx)(`span`,{className:`truncate font-mono`,title:e??``,children:e??x(`activity:memoryManager.noFile`)})]}),(0,A.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`font-mono`,children:x(`activity:memoryManager.memoriesCount`,{count:z})}),R&&R.reviewPendingCount>0&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 font-mono text-warning`,children:[(0,A.jsx)(f,{className:`size-3`}),x(`activity:memoryManager.pendingReviewCount`,{count:R.reviewPendingCount})]}),R&&R.supersededCount>0&&(0,A.jsx)(`span`,{className:`font-mono`,children:x(`activity:memoryManager.supersededCount`,{count:R.supersededCount})})]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,A.jsx)(v,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>N(),disabled:j||!e,className:`h-7 w-7 p-0`,"aria-label":x(`common:action.refresh`),title:x(`activity:memoryManager.requeryTitle`),children:(0,A.jsx)(h,{className:_(`size-3.5`,j&&`animate-spin`)})}),(0,A.jsx)(v,{type:`button`,size:`sm`,variant:`ghost`,onClick:i,className:`h-7 w-7 p-0`,"aria-label":x(`activity:memoryManager.closeDrawerAria`),title:x(`activity:memoryManager.closeDrawerTitle`),children:(0,A.jsx)(s,{className:`size-3.5`})})]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/40 bg-background/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked),className:`size-3 accent-primary`,disabled:!e,"data-testid":`memory-drawer-show-deleted`}),S?(0,A.jsx)(g,{className:`size-3`}):(0,A.jsx)(m,{className:`size-3`}),(0,A.jsx)(`span`,{children:x(`activity:memoryManager.showRecoverable`)})]}),F&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[10px] text-primary`,children:[(0,A.jsx)(p,{className:`size-3`}),` `,x(`activity:memoryManager.linesRange`,{start:t,end:n})]})]}),(0,A.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-3 py-3`,children:e?j&&!R?(0,A.jsx)(I,{loading:!0,message:x(`activity:memoryManager.loadingMemories`)}):M?(0,A.jsx)(I,{tone:`error`,message:x(`activity:memoryManager.errorPrefix`,{message:M})}):!R||z===0?(0,A.jsx)(I,{message:x(`activity:memoryManager.emptyNoMemories`,{file:e})}):(0,A.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,A.jsx)(P,{icon:p,title:x(`activity:memoryManager.cursorBoostTitle`),count:R.symbolMatches.length,cursorBoosted:F,matches:R.symbolMatches,pendingActionById:w,onShowMemory:a,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>c?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>u?.(e,t)),onUpdate:e=>L(e,D.updating,()=>d?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))}),(0,A.jsx)(P,{icon:l,title:x(`activity:memoryManager.fileScopedTitle`),count:R.primaryMatches.length,matches:R.primaryMatches,pendingActionById:w,onShowMemory:a,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>c?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>u?.(e,t)),onUpdate:e=>L(e,D.updating,()=>d?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))}),(0,A.jsx)(P,{icon:g,title:x(`activity:memoryManager.mentionedInTitle`),count:R.relatedMatches.length,matches:R.relatedMatches,pendingActionById:w,onShowMemory:a,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>c?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>u?.(e,t)),onUpdate:e=>L(e,D.updating,()=>d?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))})]}):(0,A.jsx)(I,{message:x(`activity:memoryManager.emptyOpenFile`)})})]})}function I({message:e,loading:t=!1,tone:n=`default`}){return(0,A.jsxs)(`div`,{className:_(`flex min-h-[120px] flex-col items-center justify-center gap-2 rounded-md border border-dashed border-border/60 px-4 py-6 text-center text-[11px]`,n===`error`?`text-destructive`:`text-muted-foreground`),children:[t&&(0,A.jsx)(a,{className:`size-4 animate-spin`}),(0,A.jsx)(`p`,{children:e})]})}export{F as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./config-store-CZdk-vPj.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Ar as i,Bi as a,Ca as o,En as s,Ft as c,J as l,Jn as u,Jt as d,La as f,Oi as p,Ot as m,Qr as h,Tt as g,Ut as _,Xi as v,Yi as ee,_n as y,da as b,di as x,dt as S,gr as C,ia as w,ka as T,ln as E,mt as D,n as O,pn as te,qi as k,ra as ne,ri as re,rn as A,tr as ie,vn as ae,wr as oe,yt as se}from"./vendor-Cvuk-OYN.js";import"./i18n-BwptPW9U.js";import{a as j,h as M,n as ce,r as N,t as le,u as ue}from"./xyflow-BqDBClm9.js";import{t as P}from"./utils-sO9lidp6.js";import{n as de}from"./ui-store-CMdVzHOn.js";import"./stores-Bt7wAdGA.js";import{a as F,i as fe,n as pe,o as I,r as L,t as R}from"./dialog-DNsBc-EF.js";import{t as z}from"./button-CN_h6kNT.js";import{t as B}from"./input-BnTFqRjn.js";import{I as me,v as he}from"./index-BYBlSXtn.js";import{t as V}from"./roster-ws-Cx9Bzoh0.js";import{_ as ge,a as _e,b as ve,c as ye,d as be,f as xe,g as H,h as Se,i as Ce,l as we,m as U,n as Te,o as Ee,p as De,r as Oe,s as ke,t as Ae,u as je,v as Me,y as W}from"./shared-h0I65HLY.js";import{t as Ne}from"./MemoryDrawer-C72rzAy0.js";var G=r();function Pe({busyAction:e,deletingId:t,memory:n,onCancel:r,onConfirm:i,onOpenChange:a}){let{t:o}=f();return(0,G.jsx)(R,{open:!!t,onOpenChange:a,children:(0,G.jsxs)(pe,{className:`max-w-md`,children:[(0,G.jsxs)(F,{children:[(0,G.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(D,{className:`size-4`})}),(0,G.jsx)(I,{children:o(`activity:memoryManager.deleteTitle`)}),(0,G.jsx)(L,{className:`leading-6`,children:o(`activity:deleteMemoryDialog.sageWillMarkTheRecordDeleted`)})]}),(0,G.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:H(n?.text??``,180)}),(0,G.jsxs)(fe,{children:[(0,G.jsx)(z,{variant:`outline`,onClick:r,disabled:e===`delete`,children:o(`common:action.cancel`)}),(0,G.jsxs)(z,{variant:`destructive`,onClick:i,disabled:e===`delete`,children:[e===`delete`?(0,G.jsx)(u,{className:`size-4 animate-spin`}):(0,G.jsx)(D,{className:`size-4`}),o(e===`delete`?`activity:memoryManager.deletingLabel`:`activity:memoryManager.actionDeleteMemory`)]})]})]})})}var K=e(n(),1),Fe=212,Ie=188;function Le(e){return e.length>14?`${e.slice(0,11)}…`:e}function Re(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function ze(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.role??e.type}function q(e){return e===`active`?`border-success/45 bg-success/10 text-success`:e===`stale`?`border-warning/45 bg-warning/10 text-warning`:e===`contradicted`?`border-destructive/45 bg-destructive/10 text-destructive`:e===`superseded`?`border-warning/35 bg-warning/5 text-warning`:`border-border bg-muted/55 text-muted-foreground`}function J({data:e}){let{entry:t,center:n}=e;return(0,G.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:Fe},title:t.text,children:[(0,G.jsx)(j,{type:`target`,position:M.Top,className:`!border-background !bg-muted-foreground`}),(0,G.jsx)(j,{type:`source`,position:M.Bottom,className:`!border-background !bg-primary`}),(0,G.jsx)(j,{type:`source`,position:M.Right,className:`!border-background !bg-primary`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${q(t.status)}`,children:t.status}),(0,G.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:Le(t.id)})]}),(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Re(t.text)}),(0,G.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function Be({data:e}){return(0,G.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Ie},title:e.label,children:[(0,G.jsx)(j,{type:`target`,position:M.Left,className:`!border-background !bg-info`}),(0,G.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,G.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var Y={memoryNode:J,anchorNode:Be};function Ve(e,t){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:t(`activity:memoryManager.memoryUnavailable`),importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function X({nodes:e,edges:t,className:n}){return(0,G.jsx)(`div`,{className:P(`w-full`,n),children:(0,G.jsxs)(ue,{nodes:e,edges:t,nodeTypes:Y,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,G.jsx)(le,{variant:ce.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,G.jsx)(N,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function He({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let{t:a}=f(),[o,s]=(0,K.useState)(!1),c=`mem:${e.id}`,l=(0,K.useMemo)(()=>n.filter(e=>e.from===c&&e.to.startsWith(`mem:`)||e.to===c&&e.from.startsWith(`mem:`)).slice(0,24),[c,n]),{nodes:u,edges:d}=(0,K.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-Fe/2,y:120},data:{entry:e,center:!0}});let o=[...e.supersededBy?[{id:e.supersededBy,relation:`superseded by`}]:[],...(e.supersedes??[]).map(e=>({id:e,relation:`supersedes`})),...(e.contradicts??[]).map(e=>({id:e,relation:`contradicts`}))];for(let e of l){let t=(e.from===c?e.to:e.from).slice(4);o.some(n=>n.id===t&&n.relation===e.relation)||o.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let s=320-(o.length-1)*220/2;return o.forEach((t,o)=>{let c=i.get(t.id)??Ve(t.id,a),l=t.relation===`superseded by`,u=l?0:280+Math.floor(o/3)*130,d=l?320-Fe/2:s+o*220-Fe/2;n.push({id:`memory:${t.id}:${o}`,type:`memoryNode`,position:{x:d,y:u},data:{entry:c,center:!1}});let f=t.relation===`contradicts`,p=l?`memory:${t.id}:${o}`:e.id,m=l?e.id:`memory:${t.id}:${o}`;r.push({id:`relation:${t.relation}:${t.id}:${o}`,source:p,target:m,type:`smoothstep`,animated:!f,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:f?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...f?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:f?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:9,fontWeight:700},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.9}})}),e.anchors.forEach((t,i)=>{let a=`anchor:${i}`;n.push({id:a,type:`anchorNode`,position:{x:540,y:120+(i-(e.anchors.length-1)/2)*66},data:{anchor:t,label:ze(t)}}),r.push({id:`anchor-edge:${i}`,source:e.id,target:a,type:`smoothstep`,style:{stroke:`hsl(var(--info))`,strokeWidth:1.3}})}),{nodes:n,edges:r}},[t,e,c,l]);return u.length<=1&&!r&&!i?null:(0,G.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":a(`activity:memoryManager.graphAria`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeading`)}),u.length>1&&(0,G.jsxs)(z,{variant:`ghost`,size:`sm`,onClick:()=>s(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":a(`activity:memoryManager.graphFullscreenAria`),children:[(0,G.jsx)(re,{className:`size-3`}),a(`activity:memoryManager.graphOpenFullscreen`)]})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?a(`activity:memoryManager.loadingGraph`):a(`activity:memoryManager.graphStats`,{nodes:u.length,edges:d.length})})]}),i&&(0,G.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),u.length>1&&(0,G.jsx)(X,{nodes:u,edges:d,className:`h-[320px]`}),l.some(e=>e.evidence?.length)&&(0,G.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:l.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===c?e.to:e.from).slice(4);return(0,G.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,Le(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),o&&(0,G.jsx)(R,{open:o,onOpenChange:s,children:(0,G.jsxs)(pe,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeadingFull`,{id:e.id})}),(0,G.jsx)(z,{variant:`ghost`,size:`sm`,onClick:()=>s(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:a(`common:action.close`)})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,G.jsx)(X,{nodes:u,edges:d,className:`h-[65vh]`})})]})})]})}function Ue({memory:e,allMemories:t,relatedMemories:n,graphEdges:r,graphLoading:i,graphError:a,onClose:s,onOpenMemory:c,onEdit:l,onDelete:u,onTagSelect:d,onNotice:m}){let{t:h}=f();return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:s,"aria-label":h(`activity:memoryManager.backToList`),children:(0,G.jsx)(o,{className:`size-4`})}),(0,G.jsx)(`span`,{className:P(`text-[10px] font-bold uppercase tracking-[0.14em]`,Se(e.kind)),children:Oe[e.kind]??e.kind}),(0,G.jsx)(we,{status:e.status}),(0,G.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:De(e.audience),children:[(0,G.jsx)(w,{className:`size-3`}),De(e.audience)]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,"aria-label":h(`activity:memoryManager.copyId`),title:h(`activity:memoryManager.copyId`),onClick:()=>{navigator.clipboard?.writeText(e.id),m(h(`activity:memoryManager.copiedNotice`))},children:(0,G.jsx)(p,{className:`size-4`})}),(0,G.jsxs)(z,{variant:`outline`,size:`sm`,onClick:()=>l(e.id),disabled:e.status===`deleted`,children:[(0,G.jsx)(te,{className:`size-3.5`}),` `,h(`common:action.edit`)]}),(0,G.jsxs)(z,{variant:`destructive`,size:`sm`,onClick:u,disabled:e.status===`deleted`,children:[(0,G.jsx)(D,{className:`size-3.5`}),` `,h(`common:action.delete`)]})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,G.jsx)(We,{memory:e}),(0,G.jsx)(Z,{memory:e}),e.tags.length>0&&(0,G.jsx)(Ge,{tags:e.tags,onTagSelect:d}),e.anchors.length>0&&(0,G.jsx)(Q,{anchors:e.anchors}),n.length>0&&(0,G.jsx)(Ke,{relatedMemories:n,allMemories:t,onOpenMemory:c}),(0,G.jsx)(He,{centerMemory:e,allMemories:t,graphEdges:r,loading:i,error:a}),(0,G.jsx)(qe,{memory:e}),e.status===`deleted`&&(0,G.jsx)($,{contextPolicy:e.contextPolicy})]})})]})}function We({memory:e}){let{t}=f();return(0,G.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,G.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,G.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,G.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,G.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,G.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:t(`activity:memoryManager.revisionSuffix`,{n:e.revision})})]})]})}function Z({memory:e}){let{t}=f(),n=[[t(`activity:memoryManager.editorImportance`),e.importance,c],[t(`activity:memoryManager.editorConfidence`),e.confidence,a],[t(`activity:memoryManager.editorFreshness`),e.freshness,A]];return(0,G.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:n.map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(n,{className:`size-3.5 text-info`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,G.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,G.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function Ge({tags:e,onTagSelect:t}){let{t:n}=f();return(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(se,{className:`size-3.5 text-info`}),` `,n(`activity:memoryManager.tagsLabel`)]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function Q({anchors:e}){let{t}=f();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(h,{className:`size-3.5 text-info`}),` `,t(`activity:memoryManager.editorAnchors`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,G.jsx)(g,{className:`size-3.5`}):(0,G.jsx)(h,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,G.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??e.role??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol??e.role}:${t}`))})]})}function Ke({relatedMemories:e,allMemories:t,onOpenMemory:n}){let{t:r}=f();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(oe,{className:`size-3.5 text-info`}),` `,r(`activity:memoryManager.memoryRelationships`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let i=t.find(t=>t.id===e.id);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,disabled:!i,onClick:()=>i&&n(i.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,G.jsx)(`span`,{className:P(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:i?H(i.text,95):r(`activity:memoryManager.referencedUnavailable`)}),(0,G.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),i&&(0,G.jsx)(k,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function qe({memory:e}){let{t}=f(),n=[[t(`activity:memoryManager.metaCreated`),U(e.createdAt),b],[t(`activity:memoryManager.metaUpdated`),U(e.updatedAt),A],[t(`activity:memoryManager.metaLastAccessed`),U(e.lastAccessedAt),s],[t(`activity:memoryManager.metaLastVerified`),U(e.lastVerifiedAt),c]];return(0,G.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:n.map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,G.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,G.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function $({contextPolicy:e}){let{t}=f();return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,G.jsx)(T,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-bold text-foreground`,children:t(`activity:memoryManager.deletedMemory`)}),(0,G.jsx)(`p`,{className:`mt-1 leading-5`,children:t(e===`never`?`activity:memoryManager.deletedNeverPolicy`:`activity:memoryManager.deletedEligiblePolicy`)})]})]})}function Je({currentFilePath:e,knownFilePaths:t,drawerActive:n,onFilePathChange:r,onToggleDrawer:i}){let{t:a}=f();return(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/60 bg-card/30 px-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:a(`activity:memoryManager.fileDrawerLabel`)}),(0,G.jsx)(`input`,{type:`text`,list:`memory-drawer-file-list`,value:e??``,onChange:e=>{r(e.target.value.trim()||null)},placeholder:a(`activity:memoryManager.selectFilePlaceholder`),className:`min-w-0 max-w-[260px] flex-1 truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":a(`activity:memoryManager.fileForDrawerAria`),"data-testid":`memory-drawer-file-select`}),(0,G.jsx)(`datalist`,{id:`memory-drawer-file-list`,children:[...t].sort().map(e=>(0,G.jsx)(`option`,{value:e},e))}),(0,G.jsxs)(z,{type:`button`,size:`sm`,variant:n?`default`:`outline`,onClick:i,disabled:!e,className:`h-7 shrink-0 gap-1 px-2 text-[11px]`,"aria-pressed":n,title:a(n?`activity:memoryManager.hideFileDrawer`:`activity:memoryManager.showFileDrawer`),children:[n?(0,G.jsx)(ae,{className:`size-3`}):(0,G.jsx)(y,{className:`size-3`}),a(n?`activity:memoryManager.hideDrawer`:`activity:memoryManager.showDrawer`)]})]})}function Ye({mode:e,draft:t,busy:n,error:r,onChange:i,onCancel:a,onSubmit:o}){let{t:s}=f(),c=(0,K.useRef)(null),[p,h]=(0,K.useState)([]);(0,K.useEffect)(()=>{c.current?.focus();let e=new AbortController;return V(`agent-roster.list`,{},e.signal).then(e=>{let t=e.roles;Array.isArray(t)&&h(t.filter(e=>typeof e==`string`))}).catch(()=>void 0),()=>e.abort()},[]);let g=(e,n)=>{i({...t,[e]:n})},_=()=>{g(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,G.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),o()},"aria-busy":n,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,G.jsx)(m,{className:`size-4`}):(0,G.jsx)(te,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-bold`,children:s(e===`create`?`activity:memoryManager.captureMemory`:`activity:memoryManager.editMemory`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:s(e===`create`?`activity:memoryManager.editorCreateHint`:`activity:memoryManager.editorEditHint`)})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,disabled:n,children:[(0,G.jsx)(l,{className:`size-3.5`}),` `,s(`common:action.cancel`)]}),(0,G.jsxs)(z,{type:`submit`,size:`sm`,disabled:n||!t.text.trim(),children:[n?(0,G.jsx)(u,{className:`size-3.5 animate-spin`}):e===`create`?(0,G.jsx)(E,{className:`size-3.5`}):(0,G.jsx)(d,{className:`size-3.5`}),s(n?`common:action.saving`:e===`create`?`activity:memoryManager.createMemory`:`activity:memoryManager.saveChanges`)]})]})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[r&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,G.jsx)(S,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsx)(`span`,{children:r})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:s(`activity:memoryManager.editorKnowledge`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:s(`activity:memEditor.writeTheDurableFactOrDecision`)})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:s(`activity:memoryManager.editorCharCount`,{count:t.text.length})})]}),(0,G.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:s(`activity:memoryManager.editorContentLabel`)}),(0,G.jsx)(`textarea`,{ref:c,id:`memory-text`,value:t.text,onChange:e=>g(`text`,e.target.value),rows:7,required:!0,placeholder:s(`activity:memoryManager.editorContentPlaceholder`),className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorKind`)}),(0,G.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>g(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Ce.map(e=>(0,G.jsx)(`option`,{value:e,children:Oe[e]},e))})]}),e===`create`?(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorScope`)}),(0,G.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>g(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:_e.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}):(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorLifecycleStatus`)}),(0,G.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>g(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Te.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:P(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,G.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(B,{id:`memory-tags`,value:t.tags,onChange:e=>g(`tags`,e.target.value),placeholder:s(`activity:memEditor.architectureWebuiWorkflow`),className:`h-10 bg-background`})]})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,G.jsx)(ye,{id:`memory-importance`,label:s(`activity:memoryManager.editorImportance`),value:t.importance,onChange:e=>g(`importance`,e)}),(0,G.jsx)(ye,{id:`memory-confidence`,label:s(`activity:memoryManager.editorConfidence`),value:t.confidence,onChange:e=>g(`confidence`,e)}),(0,G.jsx)(ye,{id:`memory-freshness`,label:s(`activity:memoryManager.editorFreshness`),value:t.freshness,onChange:e=>g(`freshness`,e)})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:s(`activity:memoryManager.editorAnchors`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:s(`activity:memEditor.bindKnowledgeToFilesSymbolsPackages`)})]}),(0,G.jsxs)(z,{type:`button`,variant:`outline`,size:`sm`,onClick:_,children:[(0,G.jsx)(E,{className:`size-3.5`}),` `,s(`activity:memoryManager.addAnchor`)]})]}),t.anchors.length===0?(0,G.jsxs)(`button`,{type:`button`,onClick:_,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,G.jsx)(ie,{className:`size-4`}),` `,s(`activity:memoryManager.noAnchors`)]}):(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,G.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,G.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:r===`agent`?{type:r,role:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);g(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:Ae.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:P(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,G.jsx)(B,{id:`anchor-value-${n}`,list:e.type===`agent`?`memory-agent-role-options`:void 0,value:je(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?ve(t,e.target.value):t);g(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:e.type===`agent`?`reviewer`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,G.jsx)(B,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);g(`anchors`,r)},placeholder:s(`activity:memoryManager.editorSymbolPlaceholder`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>g(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,G.jsx)(D,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))}),(0,G.jsx)(`datalist`,{id:`memory-agent-role-options`,children:p.map(e=>(0,G.jsx)(`option`,{value:e},e))})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:s(`activity:memoryManager.editorRelationships`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.editorRelationshipsHint`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorSupersedes`)}),(0,G.jsx)(B,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>g(`supersedes`,e.target.value),placeholder:s(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorContradicts`)}),(0,G.jsx)(B,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>g(`contradicts`,e.target.value),placeholder:s(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memEditor.audienceOptional`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:s(`activity:memEditor.targetThisMemoryToSpecificAgent`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memEditor.roles`)}),(0,G.jsx)(B,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>g(`audienceRoles`,e.target.value),placeholder:s(`activity:memEditor.reviewerRefactorPlanner`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorTaskTypes`)}),(0,G.jsx)(B,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>g(`audienceTaskTypes`,e.target.value),placeholder:s(`activity:memEditor.reviewRefactorBugfix`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memEditor.modes`)}),(0,G.jsx)(B,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>g(`audienceModes`,e.target.value),placeholder:s(`activity:memEditor.teachCodeReview`),className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function Xe({searchQuery:e,statusFilter:t,kindFilter:n,audienceOnly:r,tagFilter:a,hasFilters:o,allTags:s,stats:c,onSearchChange:u,onStatusFilterChange:d,onKindFilterChange:p,onToggleAudienceOnly:m,onTagFilterChange:h,onClearFilters:g}){let{t:v}=f(),[y,b]=(0,K.useState)(!!a),x=y||!!a,S=s.length>0;return(0,G.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(B,{"aria-label":v(`activity:memoryManager.searchAria`),value:e,onChange:e=>u(e.target.value),placeholder:v(`activity:memoryManager.searchPlaceholder`),className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,G.jsx)(`button`,{type:`button`,"aria-label":v(`activity:memoryManager.clearSearchAria`),onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(l,{className:`size-3.5`})})]}),(0,G.jsx)(z,{variant:r?`default`:`ghost`,size:`icon`,onClick:m,"aria-label":v(`activity:memoryManager.audienceFilterAria`),title:v(`activity:memoryManager.audienceFilterTitle`),className:`shrink-0`,children:(0,G.jsx)(w,{className:`size-4`})}),o&&(0,G.jsx)(z,{variant:`ghost`,size:`icon`,onClick:g,"aria-label":v(`activity:memoryManager.clearFiltersAria`),title:v(`activity:memoryManager.clearFiltersTitle`),children:(0,G.jsx)(i,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:v(`activity:memoryManager.filterByStatus`)}),(0,G.jsxs)(`select`,{id:`memory-status-filter`,value:t,onChange:e=>d(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:v(`activity:memoryManager.allStatuses`)}),Ee.map(e=>(0,G.jsxs)(`option`,{value:e,children:[e,` · `,c?.byStatus[e]??0]},e))]}),(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:v(`activity:memoryManager.filterByKind`)}),(0,G.jsxs)(`select`,{id:`memory-kind-filter`,value:n,onChange:e=>p(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:v(`activity:memoryManager.allKinds`)}),Ce.map(e=>(0,G.jsxs)(`option`,{value:e,children:[Oe[e],` · `,c?.byKind[e]??0]},e))]})]}),S&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{a||b(e=>!e)},"aria-expanded":x,"aria-controls":`memory-tags-panel`,disabled:!!a,className:P(`flex items-center gap-1.5 px-1 py-0.5 text-[10px] uppercase tracking-wide transition-colors`,x?`text-foreground`:`text-muted-foreground hover:text-foreground`,!!a&&`cursor-default`),title:a?`Active filter: ${a} (click the chip to clear)`:x?`Hide tag filters`:`Show tag filters (${s.length})`,children:[(0,G.jsx)(ee,{className:P(`size-3 transition-transform`,!x&&`-rotate-90`)}),(0,G.jsx)(se,{className:`size-3`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:v(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:s.length})]}),a&&(0,G.jsx)(`span`,{role:`status`,"aria-label":`Active tag filter: ${a}`,className:`border border-info/55 bg-info/10 px-1 font-mono text-[9px] uppercase text-info`,children:a})]}),S&&x&&(0,G.jsxs)(`fieldset`,{id:`memory-tags-panel`,className:`min-w-0 border-0 p-0`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:v(`activity:memoryManager.popularTags`)}),(0,G.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:s.slice(0,18).map(([e,t])=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":a===e,onClick:()=>h(a===e?null:e),className:P(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,a===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,G.jsx)(se,{className:`size-2.5`}),` `,e,(0,G.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}var Ze=100;function Qe({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let{t:s}=f(),c=n.length>Ze,l=O({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:c});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{children:s(`activity:memoryManager.memoryCountSummary`,{shown:n.length,total:t.length})}),(0,G.jsx)(`span`,{className:`font-mono uppercase`,children:s(`activity:memoryManager.updatedSortLabel`)})]}),(0,G.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":s(`activity:memoryManager.listAria`),children:n.length===0?(0,G.jsx)($e,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):c?(0,G.jsx)(`div`,{style:{height:`${l.getTotalSize()}px`,width:`100%`,position:`relative`},children:l.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,G.jsx)(`div`,{"data-index":e.index,ref:l.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,G.jsx)(et,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,G.jsx)(et,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function $e({hasMemories:e,onOpenCreate:t,onClearFilters:n}){let{t:r}=f();return(0,G.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,G.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,G.jsx)(x,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:r(e?`activity:memoryManager.noMatching`:`activity:memoryManager.buildGraph`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:r(e?`activity:memoryManager.emptyFiltered`:`activity:memoryManager.emptyCapture`)}),(0,G.jsxs)(z,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,G.jsx)(i,{className:`size-3.5`}):(0,G.jsx)(E,{className:`size-3.5`}),r(e?`activity:memoryManager.clearFilters`:`activity:memoryManager.createFirst`)]})]})}function et({memory:e,isSelected:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:P(`group relative block w-full border-b border-border/55 px-3 py-3 text-left transition-[background-color,border-color] hover:bg-info/5`,t&&`bg-info/8`),children:[t&&(0,G.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:P(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,Se(e.kind)),children:Oe[e.kind]??e.kind}),(0,G.jsx)(we,{status:e.status}),(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,G.jsx)(`p`,{className:P(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:H(e.text)}),(0,G.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,G.jsx)(w,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,G.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,G.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,G.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:Me(e.updatedAt)}),(0,G.jsx)(k,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function tt({onCapture:e}){let{t}=f();return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,G.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,G.jsx)(w,{className:`size-8`}),(0,G.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,G.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:t(`activity:memoryManager.emptyTitle`)}),(0,G.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:t(`activity:memoryManager.emptyBody`)}),(0,G.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(v,{className:`mx-auto size-4 text-success`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyVerifiedAnchors`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(w,{className:`mx-auto size-4 text-info`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyTypedRelations`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(E,{className:`mx-auto size-4 text-warning`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyAgentRecall`)})]})]}),(0,G.jsxs)(z,{onClick:e,children:[(0,G.jsx)(E,{className:`size-4`}),` `,t(`activity:memoryManager.captureButton`)]})]})}function nt({wsConnected:e,refreshing:t,onRefresh:n,onCreate:r}){let{t:i}=f(),a=de(e=>e.setCurrentView);return(0,G.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,G.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,onClick:()=>a(`chat`),"aria-label":i(`activity:memoryManager.backToChat`),title:i(`activity:memoryManager.backToChat`),children:(0,G.jsx)(o,{className:`size-4`})}),(0,G.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,G.jsx)(w,{className:`size-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:i(`activity:memoryManager.sageHeading`)}),(0,G.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:i(`activity:memoryManager.projectKnowledge`)})]}),(0,G.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:i(`activity:memoryManager.sageSubtitle`)})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:P(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,e?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,G.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,i(e?`activity:memoryManager.liveStore`:`activity:memoryManager.reconnecting`)]}),(0,G.jsxs)(z,{variant:`outline`,size:`sm`,onClick:n,disabled:t,"aria-label":i(`activity:memoryManager.refreshAria`),children:[(0,G.jsx)(A,{className:P(`size-3.5`,t&&`animate-spin`)}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:i(`common:action.refresh`)})]}),(0,G.jsxs)(z,{size:`sm`,onClick:r,children:[(0,G.jsx)(E,{className:`size-3.5`}),` `,i(`activity:memoryManager.newMemory`)]})]})]})]})}function rt({stats:e,memories:t,filteredCount:n,allTagsCount:r}){let{t:i}=f(),a=t.filter(e=>e.audience).length,o=new Set;if(a>0){for(let e of t)if(e.audience){for(let t of e.audience.roles??[])o.add(t);for(let t of e.audience.taskTypes??[])o.add(t);for(let t of e.audience.modes??[])o.add(t)}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,G.jsx)(ke,{label:i(`activity:memoryManager.tabMemories`),value:e?.total??t.length,hint:`${n} visible`}),(0,G.jsx)(ke,{label:i(`activity:memoryManager.tabActive`),value:e?.byStatus.active??t.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,G.jsx)(ke,{label:i(`activity:memoryManager.tabNeedsReview`),value:(e?.byStatus.stale??0)+(e?.byStatus.contradicted??0),hint:i(`activity:memoryManager.staleConflicts`),tone:`warning`}),(0,G.jsx)(`div`,{className:`hidden sm:block`,children:(0,G.jsx)(ke,{label:i(`activity:memoryManager.tabGraphEdges`),value:e?.edges??0,hint:`${r} tags`,tone:`info`})})]}),a>0&&(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,G.jsx)(w,{className:`size-3.5 text-primary`}),(0,G.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[a,` audience-scoped memory`,a===1?``:`ies`]}),o.size>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...o].sort().join(`, `),`)`]})]})]})}function it({query:e,channel:t,hits:n,loading:r,error:i,onOpenMemory:a,onClear:o}){let{t:s}=f();return e?(0,G.jsxs)(`section`,{"aria-label":s(`activity:memoryManager.searchBreakdownAria`),className:`border-b border-border/60 bg-card/35`,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-border/55 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(m,{className:`size-3 text-info`}),(0,G.jsx)(`span`,{className:`font-mono uppercase tracking-[0.1em]`,children:s(`activity:memoryManager.searchBreakdownTitle`,{query:e})}),t===`breakdown`&&(0,G.jsx)(`span`,{className:`border border-info/40 bg-info/8 px-1.5 py-0.5 font-mono text-[9px] uppercase text-info`,children:s(`activity:memoryManager.searchBreakdownDual`)}),t===`lexical`&&(0,G.jsx)(`span`,{className:`border border-border/60 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownLexicalOnly`)})]}),(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`font-mono text-[10px] uppercase text-muted-foreground hover:text-foreground`,children:s(`common:action.close`)})]}),r&&(0,G.jsx)(`p`,{className:`px-3 py-3 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownLoading`)}),i&&(0,G.jsx)(`p`,{className:`border-t border-border/55 px-3 py-2 text-[10px] text-destructive`,role:`alert`,children:i}),!r&&!i&&n.length===0&&(0,G.jsx)(`p`,{className:`px-3 py-3 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownEmpty`)}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:n.map(e=>(0,G.jsx)(at,{hit:e,onOpenMemory:a},e.memory.id))})]}):null}function at({hit:e,onOpenMemory:t}){let{t:n}=f(),r=ot(e.lexicalScore),i=ot(e.vectorScore),a=ot(e.finalScore),{accent:o,label:s}=st(e.source);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e.memory.id),className:`group flex w-full min-w-0 items-start gap-3 px-3 py-2.5 text-left hover:bg-info/5`,children:[(0,G.jsx)(`span`,{className:P(`flex size-7 shrink-0 items-center justify-center border font-mono text-[9px] uppercase`,o),title:n(`activity:memoryManager.searchBreakdownSourceLabel`,{source:s}),children:e.source===`vector`?(0,G.jsx)(m,{className:`size-3.5`}):e.source===`both`?(0,G.jsx)(ne,{className:`size-3.5`}):(0,G.jsx)(C,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`line-clamp-2 text-[11px] leading-5 text-foreground/90`,children:e.memory.text}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`L`}),(0,G.jsx)(`span`,{className:`tabular-nums text-foreground/80`,children:r})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`V`}),(0,G.jsx)(`span`,{className:P(`tabular-nums`,e.vectorScore===null?`text-muted-foreground/50`:`text-foreground/80`),children:i})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`RRF`}),(0,G.jsx)(`span`,{className:`tabular-nums font-bold text-foreground`,children:a})]}),(0,G.jsx)(`span`,{className:`ml-auto uppercase text-[9px]`,children:s})]})]})]})})}function ot(e){return e===null?`—`:`${Math.round(e*100)}%`}function st(e){switch(e){case`vector`:return{accent:`border-accent/40 bg-accent/10 text-accent`,label:`vector`};case`both`:return{accent:`border-info/40 bg-info/10 text-info`,label:`both`};default:return{accent:`border-border/60 bg-background text-muted-foreground`,label:`lexical`}}}function ct({listCandidates:e,resolveCandidate:t,onOpenMemory:n,client:r,active:i}){let{t:a}=f(),[o,s]=(0,K.useState)([]),[c,d]=(0,K.useState)(!1),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(null),[_,ee]=(0,K.useState)(!1),[y,b]=(0,K.useState)(()=>new Set),x=(0,K.useRef)(0),C=(0,K.useCallback)(()=>{let t=++x.current;d(!0),m(null);let n=r.on(`memory.sage.listCandidates`,e=>{if(t===x.current){if(n(),e.payload.error)m(String(e.payload.error)),s([]);else{let t=(Array.isArray(e.payload.candidates)?e.payload.candidates:[]).filter(e=>e.status===`pending`);s(t),b(e=>{let n=new Set;for(let r of e)t.some(e=>e.id===r)&&n.add(r);return n})}d(!1)}}),i=setTimeout(()=>{t===x.current&&(n(),d(!1),m(a(`activity:memoryManager.reviewLoadTimeout`)))},15e3);return e({includeResolved:!1},{echoToChat:!1}),()=>{clearTimeout(i),n()}},[r,e,a]);(0,K.useEffect)(()=>{if(i)return C()},[i,C]);let w=(0,K.useCallback)((e,n)=>new Promise(i=>{let a=r.on(`memory.sage.candidateResolve`,e=>{a();let t=e.payload.error;i(!t)});t({candidateId:e,action:n,reason:n===`reject`?`Rejected via Memory Review tab`:void 0},{echoToChat:!1}),setTimeout(()=>{a(),i(!1)},15e3)}),[r,t]),T=(0,K.useCallback)(async(e,t)=>{g(e),await w(e,t),g(null),C()},[C,w]),E=(0,K.useCallback)(async e=>{let t=[...y];if(t.length!==0){ee(!0);for(let n of t)await w(n,e);ee(!1),b(new Set),C()}},[C,w,y]),D=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},O=()=>{b(new Set(o.map(e=>e.id)))},te=()=>b(new Set);if(c&&o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 p-6 text-sm text-muted-foreground`,children:[(0,G.jsx)(u,{className:`size-4 animate-spin`}),a(`activity:memoryManager.reviewLoading`)]});if(p&&o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(S,{className:`size-5 text-warning`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,onClick:()=>C(),children:[(0,G.jsx)(A,{className:`size-3.5`}),` `,a(`common:action.retry`)]})]});if(o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center`,children:[(0,G.jsx)(v,{className:`size-6 text-success`}),(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:a(`activity:memoryManager.reviewEmptyTitle`)}),(0,G.jsx)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:a(`activity:memoryManager.reviewEmptyHint`)}),(0,G.jsxs)(z,{size:`sm`,variant:`ghost`,onClick:()=>C(),children:[(0,G.jsx)(A,{className:`size-3.5`}),` `,a(`common:action.refresh`)]})]});let k=y.size,ne=k===o.length&&o.length>0;return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:a(`activity:memoryManager.reviewPendingCount`,{count:o.length})}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(z,{size:`sm`,variant:`ghost`,className:`h-7 text-[11px]`,onClick:ne?te:O,children:a(ne?`activity:memoryManager.reviewClearSelection`:`activity:memoryManager.reviewSelectAll`)}),(0,G.jsxs)(z,{size:`sm`,className:`h-7`,disabled:k===0||_,onClick:()=>void E(`accept`),children:[_?(0,G.jsx)(u,{className:`size-3 animate-spin`}):(0,G.jsx)(v,{className:`size-3`}),a(`activity:memoryManager.reviewBulkAccept`),k>0?` (${k})`:``]}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,className:`h-7`,disabled:k===0||_,onClick:()=>void E(`reject`),children:[(0,G.jsx)(l,{className:`size-3`}),a(`activity:memoryManager.reviewBulkKeep`),k>0?` (${k})`:``]}),(0,G.jsx)(z,{size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>C(),disabled:c,children:(0,G.jsx)(A,{className:P(`size-3.5`,c&&`animate-spin`)})})]})]}),(0,G.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:o.map(e=>{let t=e.targetMemoryId??e.memoryId,r=e.reviewReason??e.reason??``,i=h===e.id||_,o=y.has(e.id);return(0,G.jsx)(`li`,{className:P(`rounded-md border bg-card/60 p-3 text-sm shadow-sm`,o?`border-primary/50 ring-1 ring-primary/20`:`border-border/70`),children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-3.5 accent-primary`,checked:o,disabled:_,onChange:()=>D(e.id),"aria-label":a(`activity:memoryManager.reviewSelectOne`)}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`font-mono text-warning`,children:e.suggestedAction??`review`}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{children:Me(e.createdAt)}),e.tags?.includes(`triage`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{className:`text-info`,children:`triage`})]})]}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-snug text-foreground`,children:H(e.text,220)}),r?(0,G.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r}):null,t?(0,G.jsxs)(`button`,{type:`button`,className:`mt-1 font-mono text-[10px] text-primary hover:underline`,onClick:()=>n?.(t),children:[t.slice(0,16),`…`]}):null,(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,G.jsxs)(z,{size:`sm`,className:`h-7`,disabled:i,onClick:()=>void T(e.id,`accept`),children:[h===e.id?(0,G.jsx)(u,{className:`size-3 animate-spin`}):(0,G.jsx)(v,{className:`size-3`}),a(`activity:memoryManager.actionAcceptDeletion`)]}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,className:`h-7`,disabled:i,onClick:()=>void T(e.id,`reject`),children:[(0,G.jsx)(l,{className:`size-3`}),a(`activity:memoryManager.actionKeep`)]})]})]})]})},e.id)})})]})}function lt(e,t){let n=t.searchQuery.trim().toLowerCase();return e.filter(e=>{if(t.statusFilter!==`all`&&e.status!==t.statusFilter||t.kindFilter!==`all`&&e.kind!==t.kindFilter||t.tagFilter&&!e.tags.includes(t.tagFilter)||t.audienceOnly&&!e.audience)return!1;if(!n)return!0;let r=e.anchors.map(e=>[e.path,e.symbol,e.command,e.role].filter(Boolean).join(` `)).join(` `),i=e.audience?[e.audience.roles?.join(` `)??``,e.audience.taskTypes?.join(` `)??``,e.audience.modes?.join(` `)??``].join(` `):``;return[e.id,e.text,e.summary??``,e.kind,e.scope,e.tags.join(` `),r,i].join(` `).toLowerCase().includes(n)})}function ut(e){let t=new Map;for(let n of e)for(let e of n.tags)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function dt(e){if(!e)return[];let t=[];e.supersededBy&&t.push({relation:`Superseded by`,id:e.supersededBy});for(let n of e.supersedes??[])t.push({relation:`Supersedes`,id:n});for(let n of e.contradicts??[])t.push({relation:`Contradicts`,id:n});return t}var ft=100;function pt(){let{t:e}=f(),{client:n,listSageMemoriesPage:r,listMemoryCandidates:i,rememberSage:a,updateSage:o,deleteSage:s,getSageGraph:c,recoverSage:l,resolveMemoryCandidate:u,searchSageBreakdown:d}=me(),p=t(e=>e.wsConnected),[m,h]=(0,K.useState)([]),[g,_]=(0,K.useState)(null),[v,ee]=(0,K.useState)(!0),[y,b]=(0,K.useState)(!1),[x,S]=(0,K.useState)(null),[C,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(null),[D,O]=(0,K.useState)(null),[te,k]=(0,K.useState)([]),[ne,re]=(0,K.useState)([]),[A,ie]=(0,K.useState)(null),[ae,oe]=(0,K.useState)(!1),[se,j]=(0,K.useState)(!1),[M,ce]=(0,K.useState)(!1),[N,le]=(0,K.useState)(xe),[ue,P]=(0,K.useState)(xe),[de,F]=(0,K.useState)(null),[fe,pe]=(0,K.useState)(null),[I,L]=(0,K.useState)({hits:[],channel:void 0,loading:!1,error:null}),[R,z]=(0,K.useState)(``),[B,he]=(0,K.useState)(`all`),[V,_e]=(0,K.useState)(`all`),[ve,ye]=(0,K.useState)(!1),[H,Se]=(0,K.useState)(null),[Ce,we]=(0,K.useState)(`active`),U=Ce===`deleted`,Te=Ce===`review`,[Ee,De]=(0,K.useState)(null),[Oe,ke]=(0,K.useState)(!1),[Ae,je]=(0,K.useState)(!1),[Me,Ne]=(0,K.useState)({}),[G,Pe]=(0,K.useState)(!1),[Fe,Ie]=(0,K.useState)(null),Le=(0,K.useRef)(!1),Re=(0,K.useRef)([]),ze=(0,K.useRef)(0),q=(0,K.useRef)(null),J=(0,K.useRef)(!0),Be=(0,K.useRef)(0),Y=(0,K.useRef)(0),Ve=(0,K.useRef)(null),X=(0,K.useRef)(null),He=(0,K.useMemo)(()=>{let e=new Set;for(let t of m)for(let n of t.anchors??[])n.type===`file`&&n.path&&e.add(n.path);return e},[m]),Ue=(0,K.useMemo)(()=>JSON.stringify(N)!==JSON.stringify(ue),[ue,N]),We=(0,K.useCallback)(e=>m.find(t=>t.id===e)??I.hits.find(t=>t.memory.id===e)?.memory??ne.find(t=>t.id===e)??null,[ne,m,I.hits]),Z=(0,K.useMemo)(()=>D===null?null:We(D),[We,D]),Ge=(0,K.useCallback)(e=>{let t=e!==null,i=++Be.current;Ve.current?.(),S(null),t?je(!0):(b(!0),Le.current||ee(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),Ve.current===c&&(Ve.current=null))};a=n.on(`memory.sage.listPage`,e=>{if(i!==Be.current||!J.current){c();return}if(c(),e.payload.error)S(e.payload.error);else{let n=e.payload.memories??[];h(e=>t?[...e,...n]:n),De(e.payload.nextCursor??null),ke(!!e.payload.nextCursor);let r=e.payload.statusCounts??{};Ne(r);let i=Object.values(r).reduce((e,t)=>e+t,0);e.payload.stats?_(e.payload.stats):_(e=>({total:i,byStatus:r,byKind:e?.byKind??{},edges:e?.edges??0})),Le.current=!0,t||O(e=>e&&(n.some(t=>t.id===e)||Re.current.some(t=>t.memory.id===e))?e:null)}ee(!1),b(!1),je(!1)}),o=setTimeout(()=>{i===Be.current&&J.current&&(c(),S(`The memory store did not respond. Check the WebSocket connection and try again.`),ee(!1),b(!1),je(!1))},2e4),Ve.current=c,r({limit:ft,...U?{statuses:[`deleted`]}:{},...e?{cursor:e}:{},...R.trim()?{query:R.trim()}:{},...V===`all`?{}:{kind:V}},{echoToChat:!1})},[n,V,r,R,U]),Q=(0,K.useCallback)(()=>{De(null),ke(!1),Ge(null)},[Ge]),Ke=(0,K.useCallback)(()=>{!Ae&&Ee&&Ge(Ee)},[Ge,Ae,Ee]);(0,K.useEffect)(()=>(J.current=!0,Q(),()=>{J.current=!1,Be.current+=1,Y.current+=1,Ve.current?.(),X.current?.(),q.current?.()}),[Q]),(0,K.useEffect)(()=>{let e=R.trim();if(q.current?.(),e.length===0){L({hits:[],channel:void 0,loading:!1,error:null});return}let t=++ze.current;L(e=>({...e,loading:!0,error:null}));let r=()=>{},i=()=>{q.current===i&&(q.current=null),r()};q.current=i,r=n.on(`memory.sage.searchBreakdown`,e=>{if(t!==ze.current||!J.current){i();return}if(i(),e.payload.error){L({hits:[],channel:void 0,loading:!1,error:e.payload.error});return}L({hits:e.payload.hits??[],channel:e.payload.source,loading:!1,error:null})}),d({query:e,limit:20})},[R,n,d]),(0,K.useEffect)(()=>{Re.current=I.hits},[I.hits]),(0,K.useEffect)(()=>{if(k([]),re([]),ie(null),!D){oe(!1);return}let e=D;oe(!0);let t=null,r=n.on(`memory.sage.graph`,n=>{n.payload.query===e&&(t!==null&&clearTimeout(t),k(n.payload.edges??[]),re(n.payload.memories??[]),ie(n.payload.error??null),oe(!1))});return t=setTimeout(()=>{ie(`Relationship graph did not respond in time.`),oe(!1)},15e3),c(e,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{t!==null&&clearTimeout(t),r()}},[n,c,D]);let qe=(0,K.useRef)(p);(0,K.useEffect)(()=>{p&&!qe.current&&Le.current&&Q(),qe.current=p},[Q,p]),(0,K.useEffect)(()=>{if(!T)return;let e=setTimeout(()=>E(null),4e3);return()=>clearTimeout(e)},[T]);let $=(0,K.useCallback)(()=>!Ue||!se&&!M||window.confirm(`Discard the unsaved memory changes?`),[M,Ue,se]),Je=(0,K.useCallback)(()=>{if(!$())return;let e=xe();le(e),P(e),ce(!0),j(!1),O(null),w(null)},[$]),Ye=(0,K.useCallback)(e=>{$()&&(O(e),ce(!1),j(!1),w(null))},[$]),Xe=(0,K.useCallback)(e=>{let t=e===void 0?Z:We(e);if(!t||t.status===`deleted`)return;e!==void 0&&O(e);let n=be(t);le(n),P(n),j(!0),ce(!1),w(null)},[We,Z]),Ze=(0,K.useCallback)(()=>{$()&&(j(!1),ce(!1),w(null))},[$]),Qe=(0,K.useCallback)((t,r,i)=>{if(!N.text.trim()){w(`Memory content is required.`);return}let a=++Y.current;X.current?.(),F(i),w(null),E(null);let o=()=>{},s=null,c=!1,l=()=>{c||(c=!0,s!==null&&clearTimeout(s),o(),X.current===l&&(X.current=null))},u=t=>{if(a!==Y.current||!J.current){l();return}if(l(),F(null),t.payload.error||!t.payload.memory){w(t.payload.error??`The server returned no memory record.`);return}let n=t.payload.memory;h(e=>{let t=e.filter(e=>e.id!==n.id);return[n,...t]}),O(n.id),ce(!1),j(!1),E(e(i===`create`?`activity:memoryManager.memoryCaptured`:`activity:memoryManager.memoryUpdated`)),Q()};o=t===`memory.sage.remember`?n.on(`memory.sage.remember`,u):n.on(`memory.sage.update`,u),s=setTimeout(()=>{a===Y.current&&J.current&&(l(),F(null),w(e(`activity:memoryManager.mutationTimeout`,{verb:e(i===`create`?`activity:memoryManager.createAction`:`common:action.save`)})))},2e4),X.current=l,r()},[n,N.text,Q,e]),$e=(0,K.useCallback)(()=>{Qe(`memory.sage.remember`,()=>a({text:N.text.trim(),kind:N.kind,scope:N.scope,tags:W(N.tags),importance:N.importance,confidence:N.confidence,freshness:N.freshness,anchors:ge(N.anchors),...W(N.audienceRoles).length||W(N.audienceTaskTypes).length||W(N.audienceModes).length?{audience:{roles:W(N.audienceRoles),taskTypes:W(N.audienceTaskTypes),modes:W(N.audienceModes)}}:{},supersedes:W(N.supersedes),contradicts:W(N.contradicts)},{echoToChat:!1}),`create`)},[N,a,Qe]),et=(0,K.useCallback)(()=>{Z&&Qe(`memory.sage.update`,()=>o(Z.id,{text:N.text.trim(),kind:N.kind,status:N.status,tags:W(N.tags),importance:N.importance,confidence:N.confidence,freshness:N.freshness,anchors:ge(N.anchors),...W(N.audienceRoles).length||W(N.audienceTaskTypes).length||W(N.audienceModes).length?{audience:{roles:W(N.audienceRoles),taskTypes:W(N.audienceTaskTypes),modes:W(N.audienceModes)}}:{},supersedes:W(N.supersedes),contradicts:W(N.contradicts)},{echoToChat:!1}),`update`)},[N,Qe,Z,o]),tt=(0,K.useCallback)(()=>{if(!fe)return;let e=++Y.current;X.current?.(),F(`delete`),w(null);let t=()=>{},r=null,i=!1,a=()=>{i||(i=!0,r!==null&&clearTimeout(r),t(),X.current===a&&(X.current=null))};t=n.on(`memory.sage.delete`,t=>{if(e!==Y.current||!J.current){a();return}if(a(),F(null),!t.payload.success){w(t.payload.message||`Delete failed.`);return}pe(null),O(null),j(!1),E(`Memory deleted and relationship edges cleaned up.`),Q()}),r=setTimeout(()=>{e===Y.current&&J.current&&(a(),F(null),w(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=a,s(fe,`Deleted from the WebUI Memory Manager.`)},[n,s,fe,Q]),nt=(0,K.useCallback)((e,t,r)=>{let i=++Y.current;X.current?.(),w(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))};a=n.on(e,e=>{if(i!==Y.current||!J.current){c();return}c(),r(e.payload)}),o=setTimeout(()=>{i===Y.current&&J.current&&(c(),w(`The memory store did not respond. Check the WebSocket connection and try again.`))},2e4),X.current=c,t()},[n]),rt=(0,K.useMemo)(()=>lt(m,{searchQuery:R,statusFilter:B,kindFilter:V,tagFilter:H,audienceOnly:ve}),[ve,V,m,R,B,H]),it=(0,K.useMemo)(()=>ut(m),[m]),at=(0,K.useMemo)(()=>dt(Z),[Z]),ot=(0,K.useCallback)(()=>{z(``),he(`all`),_e(`all`),ye(!1),Se(null)},[]);return{client:n,wsConnected:p,memories:m,stats:g,initialLoading:v,refreshing:y,loadError:x,mutationError:C,setMutationError:w,notice:T,setNotice:E,selectedId:D,setSelectedId:O,selectedMemory:Z,graphEdges:te,graphMemories:ne,graphError:A,graphLoading:ae,editing:se,creating:M,draft:N,setDraft:le,busyAction:de,deletingId:fe,setDeletingId:pe,searchQuery:R,setSearchQuery:z,searchBreakdown:I,clearSearchBreakdown:()=>{ze.current+=1,q.current?.(),L({hits:[],channel:void 0,loading:!1,error:null})},statusFilter:B,setStatusFilter:he,kindFilter:V,setKindFilter:_e,audienceOnly:ve,setAudienceOnly:ye,tagFilter:H,setTagFilter:Se,libraryView:Ce,setLibraryView:we,showDeleted:U,showReview:Te,hasMore:Oe,loadingMore:Ae,statusCounts:Me,drawerOpen:G,setDrawerOpen:Pe,currentFilePath:Fe,setCurrentFilePath:Ie,knownFilePaths:He,filteredMemories:rt,allTags:it,relatedMemories:at,hasFilters:!!(R||B!==`all`||V!==`all`||H||ve),detailOpen:M||!!Z,drawerActive:G&&!!Fe,loadMemories:Q,loadMore:Ke,openCreate:Je,openMemory:Ye,openEdit:Xe,cancelEditor:Ze,submitCreate:$e,submitUpdate:et,confirmDelete:tt,sendWithAck:nt,clearFilters:ot,resolveMemoryCandidate:u,updateSage:o,recoverSage:l,listMemoryCandidates:i}}function mt(){let{t:e}=f(),t=de(e=>e.setCurrentView),n=he(`memory`),r=pt();return r.initialLoading&&r.memories.length===0?(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,G.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,G.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,G.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,G.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,G.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,G.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,G.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:e(`activity:memoryManager.loadingSageContent`)})]}):r.loadError&&r.memories.length===0?(0,G.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,G.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,G.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(S,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:e(`activity:memoryManager.storeUnavailable`)}),(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:r.loadError}),(0,G.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,G.jsxs)(z,{onClick:r.loadMemories,children:[(0,G.jsx)(A,{className:`size-4`}),` `,e(`common:action.retry`)]}),(0,G.jsxs)(z,{variant:`outline`,onClick:()=>t(`chat`),children:[(0,G.jsx)(o,{className:`size-4`}),` `,e(`activity:memoryManager.backToChat`)]})]})]})}):(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,G.jsx)(nt,{wsConnected:r.wsConnected,refreshing:r.refreshing,onRefresh:r.loadMemories,onCreate:r.openCreate}),(0,G.jsx)(rt,{stats:r.stats,memories:r.memories,filteredCount:r.filteredMemories.length,allTagsCount:r.allTags.length}),(r.notice||r.loadError||r.mutationError)&&(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[r.notice&&(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,G.jsx)(v,{className:`size-3.5`}),` `,r.notice]}),r.loadError&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,G.jsx)(S,{className:`size-3.5`}),` `,r.loadError,` Existing content remains available.`]}),r.mutationError&&!r.editing&&!r.creating&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,G.jsx)(S,{className:`size-3.5`}),` `,r.mutationError]})]}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsxs)(`section`,{className:P(`min-h-0 border-r border-border/70 bg-card/25`,r.detailOpen?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":e(`activity:memoryManager.libraryAria`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":e(`activity:memoryManager.viewAria`),children:[(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.libraryView===`active`,onClick:()=>r.setLibraryView(`active`),className:P(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.libraryView===`active`?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabActive`)}),(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.showReview,onClick:()=>r.setLibraryView(`review`),className:P(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.showReview?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabReview`)}),(0,G.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.showDeleted,onClick:()=>r.setLibraryView(`deleted`),className:P(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.showDeleted?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[e(`activity:memoryManager.tabDeleted`),typeof r.statusCounts.deleted==`number`?` (${r.statusCounts.deleted})`:``]})]}),r.showReview?(0,G.jsx)(ct,{active:r.showReview,client:r.client,listCandidates:r.listMemoryCandidates,resolveCandidate:r.resolveMemoryCandidate,onOpenMemory:r.openMemory}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Xe,{searchQuery:r.searchQuery,statusFilter:r.statusFilter,kindFilter:r.kindFilter,audienceOnly:r.audienceOnly,tagFilter:r.tagFilter,hasFilters:r.hasFilters,allTags:r.allTags,stats:r.stats,onSearchChange:r.setSearchQuery,onStatusFilterChange:r.setStatusFilter,onKindFilterChange:r.setKindFilter,onToggleAudienceOnly:()=>r.setAudienceOnly(e=>!e),onTagFilterChange:r.setTagFilter,onClearFilters:r.clearFilters}),(0,G.jsx)(Qe,{memoryListRef:n,memories:r.memories,filteredMemories:r.filteredMemories,selectedId:r.selectedId,onSelectMemory:r.openMemory,onOpenCreate:r.openCreate,onClearFilters:r.clearFilters}),r.searchQuery.trim().length>0&&(0,G.jsx)(it,{query:r.searchQuery.trim(),channel:r.searchBreakdown.channel,hits:r.searchBreakdown.hits,loading:r.searchBreakdown.loading,error:r.searchBreakdown.error,onOpenMemory:r.openMemory,onClear:r.clearSearchBreakdown}),r.hasMore?(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,G.jsx)(z,{type:`button`,variant:`outline`,size:`sm`,onClick:r.loadMore,disabled:r.loadingMore,className:`h-7 w-full text-[11px]`,children:r.loadingMore?e(`common:action.loading`):`Load more (${r.memories.length} loaded)`})}):null]})]}),(0,G.jsxs)(`section`,{className:P(`min-h-0 bg-background`,r.detailOpen?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":e(`activity:memoryManager.detailAria`),children:[r.memories.some(e=>(e.anchors??[]).some(e=>e.type===`file`&&e.path))&&(0,G.jsx)(Je,{currentFilePath:r.currentFilePath,knownFilePaths:r.knownFilePaths,drawerActive:r.drawerActive,onFilePathChange:e=>{e&&r.knownFilePaths.has(e)?(r.setCurrentFilePath(e),r.setDrawerOpen(!0)):e?r.setCurrentFilePath(e):r.setCurrentFilePath(null)},onToggleDrawer:()=>{r.currentFilePath&&r.setDrawerOpen(e=>!e)}}),r.creating?(0,G.jsx)(Ye,{mode:`create`,draft:r.draft,busy:r.busyAction===`create`,error:r.mutationError,onChange:r.setDraft,onCancel:r.cancelEditor,onSubmit:r.submitCreate}):r.selectedMemory?r.editing?(0,G.jsx)(Ye,{mode:`edit`,draft:r.draft,busy:r.busyAction===`update`,error:r.mutationError,onChange:r.setDraft,onCancel:r.cancelEditor,onSubmit:r.submitUpdate}):r.drawerActive?(0,G.jsx)(Ne,{filePath:r.currentFilePath,open:r.drawerActive,onClose:()=>r.setDrawerOpen(!1),onShowMemory:e=>r.setSelectedId(e),onAcceptDeletion:(e,t)=>{r.sendWithAck(`memory.sage.candidateResolve`,()=>r.resolveMemoryCandidate({candidateId:e,action:`accept`}),n=>{if(n.error){r.setMutationError(n.error);return}r.setNotice(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),r.loadMemories()})},onKeep:(e,t)=>{r.sendWithAck(`memory.sage.candidateResolve`,()=>r.resolveMemoryCandidate({candidateId:e,action:`reject`}),n=>{if(n.error){r.setMutationError(n.error);return}r.setNotice(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`),r.loadMemories()})},onUpdate:e=>{r.openEdit(e)},onMarkPermanent:e=>{r.sendWithAck(`memory.sage.update`,()=>r.updateSage(e,{persistence:`permanent`}),t=>{if(t.error||!t.memory){r.setMutationError(t.error??`The server returned no memory record.`);return}r.setNotice(`Memory ${e.slice(0,12)}… promoted to permanent.`),r.loadMemories()})},onRecover:e=>{r.sendWithAck(`memory.sage.recover`,()=>r.recoverSage({id:e,reason:`recovered via file drawer`}),t=>{if(t.error){r.setMutationError(t.error);return}r.setNotice(`Recovered ${e.slice(0,12)}…`),r.loadMemories()})}}):(0,G.jsx)(Ue,{memory:r.selectedMemory,allMemories:[...r.memories,...r.graphMemories],relatedMemories:r.relatedMemories,graphEdges:r.graphEdges,graphLoading:r.graphLoading,graphError:r.graphError,onClose:()=>r.setSelectedId(null),onOpenMemory:r.openMemory,onEdit:r.openEdit,onDelete:()=>r.setDeletingId(r.selectedMemory.id),onTagSelect:e=>{r.setTagFilter(e),r.setSelectedId(null)},onNotice:r.setNotice}):(0,G.jsx)(tt,{onCapture:r.openCreate})]})]}),(0,G.jsx)(Pe,{busyAction:r.busyAction,deletingId:r.deletingId,memory:r.selectedMemory,onCancel:()=>r.setDeletingId(null),onConfirm:r.confirmDelete,onOpenChange:e=>{!e&&r.busyAction!==`delete`&&r.setDeletingId(null)}})]})}export{mt as MemoryManager};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./config-store-D7yrCV2X.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Ar as i,Bi as a,Ca as o,En as s,Ft as c,J as l,Jn as u,Jt as d,La as f,Oi as p,Ot as m,Qr as h,Tt as g,Ut as _,Xi as v,Yi as ee,_n as y,da as b,di as x,dt as S,gr as C,ia as w,ka as T,ln as E,mt as D,n as O,pn as te,qi as k,ra as ne,ri as re,rn as A,tr as ie,vn as ae,wr as oe,yt as se}from"./vendor-BO-lHyIr.js";import"./i18n-B_njdXiH.js";import{a as j,h as M,n as ce,r as N,t as le,u as ue}from"./xyflow-BqDBClm9.js";import{t as P}from"./utils-DQbrPaAM.js";import{n as de}from"./ui-store-BROszDxo.js";import"./stores-COxKgvNx.js";import{a as F,i as fe,n as pe,o as I,r as L,t as R}from"./dialog-CTmNJKRN.js";import{t as z}from"./button-h7DHXgna.js";import{t as B}from"./input-DAvKojvP.js";import{I as me,v as he}from"./index-CfREDCPe.js";import{t as V}from"./roster-ws-CSbZSs3G.js";import{_ as ge,a as _e,b as ve,c as ye,d as be,f as xe,g as H,h as Se,i as Ce,l as we,m as U,n as Te,o as Ee,p as De,r as Oe,s as ke,t as Ae,u as je,v as Me,y as W}from"./shared-BirfDJmq.js";import{t as Ne}from"./MemoryDrawer-BdcWptmP.js";var G=r();function Pe({busyAction:e,deletingId:t,memory:n,onCancel:r,onConfirm:i,onOpenChange:a}){let{t:o}=f();return(0,G.jsx)(R,{open:!!t,onOpenChange:a,children:(0,G.jsxs)(pe,{className:`max-w-md`,children:[(0,G.jsxs)(F,{children:[(0,G.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(D,{className:`size-4`})}),(0,G.jsx)(I,{children:o(`activity:memoryManager.deleteTitle`)}),(0,G.jsx)(L,{className:`leading-6`,children:o(`activity:deleteMemoryDialog.sageWillMarkTheRecordDeleted`)})]}),(0,G.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:H(n?.text??``,180)}),(0,G.jsxs)(fe,{children:[(0,G.jsx)(z,{variant:`outline`,onClick:r,disabled:e===`delete`,children:o(`common:action.cancel`)}),(0,G.jsxs)(z,{variant:`destructive`,onClick:i,disabled:e===`delete`,children:[e===`delete`?(0,G.jsx)(u,{className:`size-4 animate-spin`}):(0,G.jsx)(D,{className:`size-4`}),o(e===`delete`?`activity:memoryManager.deletingLabel`:`activity:memoryManager.actionDeleteMemory`)]})]})]})})}var K=e(n(),1),Fe=212,Ie=188;function Le(e){return e.length>14?`${e.slice(0,11)}…`:e}function Re(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function ze(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.role??e.type}function q(e){return e===`active`?`border-success/45 bg-success/10 text-success`:e===`stale`?`border-warning/45 bg-warning/10 text-warning`:e===`contradicted`?`border-destructive/45 bg-destructive/10 text-destructive`:e===`superseded`?`border-warning/35 bg-warning/5 text-warning`:`border-border bg-muted/55 text-muted-foreground`}function J({data:e}){let{entry:t,center:n}=e;return(0,G.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:Fe},title:t.text,children:[(0,G.jsx)(j,{type:`target`,position:M.Top,className:`!border-background !bg-muted-foreground`}),(0,G.jsx)(j,{type:`source`,position:M.Bottom,className:`!border-background !bg-primary`}),(0,G.jsx)(j,{type:`source`,position:M.Right,className:`!border-background !bg-primary`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${q(t.status)}`,children:t.status}),(0,G.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:Le(t.id)})]}),(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Re(t.text)}),(0,G.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function Be({data:e}){return(0,G.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Ie},title:e.label,children:[(0,G.jsx)(j,{type:`target`,position:M.Left,className:`!border-background !bg-info`}),(0,G.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,G.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var Y={memoryNode:J,anchorNode:Be};function Ve(e,t){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:t(`activity:memoryManager.memoryUnavailable`),importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function X({nodes:e,edges:t,className:n}){return(0,G.jsx)(`div`,{className:P(`w-full`,n),children:(0,G.jsxs)(ue,{nodes:e,edges:t,nodeTypes:Y,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,G.jsx)(le,{variant:ce.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,G.jsx)(N,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function He({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let{t:a}=f(),[o,s]=(0,K.useState)(!1),c=`mem:${e.id}`,l=(0,K.useMemo)(()=>n.filter(e=>e.from===c&&e.to.startsWith(`mem:`)||e.to===c&&e.from.startsWith(`mem:`)).slice(0,24),[c,n]),{nodes:u,edges:d}=(0,K.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-Fe/2,y:120},data:{entry:e,center:!0}});let o=[...e.supersededBy?[{id:e.supersededBy,relation:`superseded by`}]:[],...(e.supersedes??[]).map(e=>({id:e,relation:`supersedes`})),...(e.contradicts??[]).map(e=>({id:e,relation:`contradicts`}))];for(let e of l){let t=(e.from===c?e.to:e.from).slice(4);o.some(n=>n.id===t&&n.relation===e.relation)||o.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let s=320-(o.length-1)*220/2;return o.forEach((t,o)=>{let c=i.get(t.id)??Ve(t.id,a),l=t.relation===`superseded by`,u=l?0:280+Math.floor(o/3)*130,d=l?320-Fe/2:s+o*220-Fe/2;n.push({id:`memory:${t.id}:${o}`,type:`memoryNode`,position:{x:d,y:u},data:{entry:c,center:!1}});let f=t.relation===`contradicts`,p=l?`memory:${t.id}:${o}`:e.id,m=l?e.id:`memory:${t.id}:${o}`;r.push({id:`relation:${t.relation}:${t.id}:${o}`,source:p,target:m,type:`smoothstep`,animated:!f,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:f?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...f?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:f?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:9,fontWeight:700},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.9}})}),e.anchors.forEach((t,i)=>{let a=`anchor:${i}`;n.push({id:a,type:`anchorNode`,position:{x:540,y:120+(i-(e.anchors.length-1)/2)*66},data:{anchor:t,label:ze(t)}}),r.push({id:`anchor-edge:${i}`,source:e.id,target:a,type:`smoothstep`,style:{stroke:`hsl(var(--info))`,strokeWidth:1.3}})}),{nodes:n,edges:r}},[t,e,c,l]);return u.length<=1&&!r&&!i?null:(0,G.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":a(`activity:memoryManager.graphAria`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeading`)}),u.length>1&&(0,G.jsxs)(z,{variant:`ghost`,size:`sm`,onClick:()=>s(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":a(`activity:memoryManager.graphFullscreenAria`),children:[(0,G.jsx)(re,{className:`size-3`}),a(`activity:memoryManager.graphOpenFullscreen`)]})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?a(`activity:memoryManager.loadingGraph`):a(`activity:memoryManager.graphStats`,{nodes:u.length,edges:d.length})})]}),i&&(0,G.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),u.length>1&&(0,G.jsx)(X,{nodes:u,edges:d,className:`h-[320px]`}),l.some(e=>e.evidence?.length)&&(0,G.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:l.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===c?e.to:e.from).slice(4);return(0,G.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,Le(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),o&&(0,G.jsx)(R,{open:o,onOpenChange:s,children:(0,G.jsxs)(pe,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeadingFull`,{id:e.id})}),(0,G.jsx)(z,{variant:`ghost`,size:`sm`,onClick:()=>s(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:a(`common:action.close`)})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,G.jsx)(X,{nodes:u,edges:d,className:`h-[65vh]`})})]})})]})}function Ue({memory:e,allMemories:t,relatedMemories:n,graphEdges:r,graphLoading:i,graphError:a,onClose:s,onOpenMemory:c,onEdit:l,onDelete:u,onTagSelect:d,onNotice:m}){let{t:h}=f();return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:s,"aria-label":h(`activity:memoryManager.backToList`),children:(0,G.jsx)(o,{className:`size-4`})}),(0,G.jsx)(`span`,{className:P(`text-[10px] font-bold uppercase tracking-[0.14em]`,Se(e.kind)),children:Oe[e.kind]??e.kind}),(0,G.jsx)(we,{status:e.status}),(0,G.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:De(e.audience),children:[(0,G.jsx)(w,{className:`size-3`}),De(e.audience)]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,"aria-label":h(`activity:memoryManager.copyId`),title:h(`activity:memoryManager.copyId`),onClick:()=>{navigator.clipboard?.writeText(e.id),m(h(`activity:memoryManager.copiedNotice`))},children:(0,G.jsx)(p,{className:`size-4`})}),(0,G.jsxs)(z,{variant:`outline`,size:`sm`,onClick:()=>l(e.id),disabled:e.status===`deleted`,children:[(0,G.jsx)(te,{className:`size-3.5`}),` `,h(`common:action.edit`)]}),(0,G.jsxs)(z,{variant:`destructive`,size:`sm`,onClick:u,disabled:e.status===`deleted`,children:[(0,G.jsx)(D,{className:`size-3.5`}),` `,h(`common:action.delete`)]})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,G.jsx)(We,{memory:e}),(0,G.jsx)(Z,{memory:e}),e.tags.length>0&&(0,G.jsx)(Ge,{tags:e.tags,onTagSelect:d}),e.anchors.length>0&&(0,G.jsx)(Q,{anchors:e.anchors}),n.length>0&&(0,G.jsx)(Ke,{relatedMemories:n,allMemories:t,onOpenMemory:c}),(0,G.jsx)(He,{centerMemory:e,allMemories:t,graphEdges:r,loading:i,error:a}),(0,G.jsx)(qe,{memory:e}),e.status===`deleted`&&(0,G.jsx)($,{contextPolicy:e.contextPolicy})]})})]})}function We({memory:e}){let{t}=f();return(0,G.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,G.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,G.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,G.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,G.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,G.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:t(`activity:memoryManager.revisionSuffix`,{n:e.revision})})]})]})}function Z({memory:e}){let{t}=f(),n=[[t(`activity:memoryManager.editorImportance`),e.importance,c],[t(`activity:memoryManager.editorConfidence`),e.confidence,a],[t(`activity:memoryManager.editorFreshness`),e.freshness,A]];return(0,G.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:n.map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(n,{className:`size-3.5 text-info`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,G.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,G.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function Ge({tags:e,onTagSelect:t}){let{t:n}=f();return(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(se,{className:`size-3.5 text-info`}),` `,n(`activity:memoryManager.tagsLabel`)]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function Q({anchors:e}){let{t}=f();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(h,{className:`size-3.5 text-info`}),` `,t(`activity:memoryManager.editorAnchors`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,G.jsx)(g,{className:`size-3.5`}):(0,G.jsx)(h,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,G.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??e.role??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol??e.role}:${t}`))})]})}function Ke({relatedMemories:e,allMemories:t,onOpenMemory:n}){let{t:r}=f();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(oe,{className:`size-3.5 text-info`}),` `,r(`activity:memoryManager.memoryRelationships`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let i=t.find(t=>t.id===e.id);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,disabled:!i,onClick:()=>i&&n(i.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,G.jsx)(`span`,{className:P(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:i?H(i.text,95):r(`activity:memoryManager.referencedUnavailable`)}),(0,G.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),i&&(0,G.jsx)(k,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function qe({memory:e}){let{t}=f(),n=[[t(`activity:memoryManager.metaCreated`),U(e.createdAt),b],[t(`activity:memoryManager.metaUpdated`),U(e.updatedAt),A],[t(`activity:memoryManager.metaLastAccessed`),U(e.lastAccessedAt),s],[t(`activity:memoryManager.metaLastVerified`),U(e.lastVerifiedAt),c]];return(0,G.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:n.map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,G.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,G.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function $({contextPolicy:e}){let{t}=f();return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,G.jsx)(T,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-bold text-foreground`,children:t(`activity:memoryManager.deletedMemory`)}),(0,G.jsx)(`p`,{className:`mt-1 leading-5`,children:t(e===`never`?`activity:memoryManager.deletedNeverPolicy`:`activity:memoryManager.deletedEligiblePolicy`)})]})]})}function Je({currentFilePath:e,knownFilePaths:t,drawerActive:n,onFilePathChange:r,onToggleDrawer:i}){let{t:a}=f();return(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/60 bg-card/30 px-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:a(`activity:memoryManager.fileDrawerLabel`)}),(0,G.jsx)(`input`,{type:`text`,list:`memory-drawer-file-list`,value:e??``,onChange:e=>{r(e.target.value.trim()||null)},placeholder:a(`activity:memoryManager.selectFilePlaceholder`),className:`min-w-0 max-w-[260px] flex-1 truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":a(`activity:memoryManager.fileForDrawerAria`),"data-testid":`memory-drawer-file-select`}),(0,G.jsx)(`datalist`,{id:`memory-drawer-file-list`,children:[...t].sort().map(e=>(0,G.jsx)(`option`,{value:e},e))}),(0,G.jsxs)(z,{type:`button`,size:`sm`,variant:n?`default`:`outline`,onClick:i,disabled:!e,className:`h-7 shrink-0 gap-1 px-2 text-[11px]`,"aria-pressed":n,title:a(n?`activity:memoryManager.hideFileDrawer`:`activity:memoryManager.showFileDrawer`),children:[n?(0,G.jsx)(ae,{className:`size-3`}):(0,G.jsx)(y,{className:`size-3`}),a(n?`activity:memoryManager.hideDrawer`:`activity:memoryManager.showDrawer`)]})]})}function Ye({mode:e,draft:t,busy:n,error:r,onChange:i,onCancel:a,onSubmit:o}){let{t:s}=f(),c=(0,K.useRef)(null),[p,h]=(0,K.useState)([]);(0,K.useEffect)(()=>{c.current?.focus();let e=new AbortController;return V(`agent-roster.list`,{},e.signal).then(e=>{let t=e.roles;Array.isArray(t)&&h(t.filter(e=>typeof e==`string`))}).catch(()=>void 0),()=>e.abort()},[]);let g=(e,n)=>{i({...t,[e]:n})},_=()=>{g(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,G.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),o()},"aria-busy":n,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,G.jsx)(m,{className:`size-4`}):(0,G.jsx)(te,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-bold`,children:s(e===`create`?`activity:memoryManager.captureMemory`:`activity:memoryManager.editMemory`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:s(e===`create`?`activity:memoryManager.editorCreateHint`:`activity:memoryManager.editorEditHint`)})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,disabled:n,children:[(0,G.jsx)(l,{className:`size-3.5`}),` `,s(`common:action.cancel`)]}),(0,G.jsxs)(z,{type:`submit`,size:`sm`,disabled:n||!t.text.trim(),children:[n?(0,G.jsx)(u,{className:`size-3.5 animate-spin`}):e===`create`?(0,G.jsx)(E,{className:`size-3.5`}):(0,G.jsx)(d,{className:`size-3.5`}),s(n?`common:action.saving`:e===`create`?`activity:memoryManager.createMemory`:`activity:memoryManager.saveChanges`)]})]})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[r&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,G.jsx)(S,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsx)(`span`,{children:r})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:s(`activity:memoryManager.editorKnowledge`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:s(`activity:memEditor.writeTheDurableFactOrDecision`)})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:s(`activity:memoryManager.editorCharCount`,{count:t.text.length})})]}),(0,G.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:s(`activity:memoryManager.editorContentLabel`)}),(0,G.jsx)(`textarea`,{ref:c,id:`memory-text`,value:t.text,onChange:e=>g(`text`,e.target.value),rows:7,required:!0,placeholder:s(`activity:memoryManager.editorContentPlaceholder`),className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorKind`)}),(0,G.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>g(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Ce.map(e=>(0,G.jsx)(`option`,{value:e,children:Oe[e]},e))})]}),e===`create`?(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorScope`)}),(0,G.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>g(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:_e.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}):(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorLifecycleStatus`)}),(0,G.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>g(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Te.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:P(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,G.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(B,{id:`memory-tags`,value:t.tags,onChange:e=>g(`tags`,e.target.value),placeholder:s(`activity:memEditor.architectureWebuiWorkflow`),className:`h-10 bg-background`})]})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,G.jsx)(ye,{id:`memory-importance`,label:s(`activity:memoryManager.editorImportance`),value:t.importance,onChange:e=>g(`importance`,e)}),(0,G.jsx)(ye,{id:`memory-confidence`,label:s(`activity:memoryManager.editorConfidence`),value:t.confidence,onChange:e=>g(`confidence`,e)}),(0,G.jsx)(ye,{id:`memory-freshness`,label:s(`activity:memoryManager.editorFreshness`),value:t.freshness,onChange:e=>g(`freshness`,e)})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:s(`activity:memoryManager.editorAnchors`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:s(`activity:memEditor.bindKnowledgeToFilesSymbolsPackages`)})]}),(0,G.jsxs)(z,{type:`button`,variant:`outline`,size:`sm`,onClick:_,children:[(0,G.jsx)(E,{className:`size-3.5`}),` `,s(`activity:memoryManager.addAnchor`)]})]}),t.anchors.length===0?(0,G.jsxs)(`button`,{type:`button`,onClick:_,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,G.jsx)(ie,{className:`size-4`}),` `,s(`activity:memoryManager.noAnchors`)]}):(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,G.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,G.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:r===`agent`?{type:r,role:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);g(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:Ae.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:P(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,G.jsx)(B,{id:`anchor-value-${n}`,list:e.type===`agent`?`memory-agent-role-options`:void 0,value:je(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?ve(t,e.target.value):t);g(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:e.type===`agent`?`reviewer`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,G.jsx)(B,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);g(`anchors`,r)},placeholder:s(`activity:memoryManager.editorSymbolPlaceholder`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>g(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,G.jsx)(D,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))}),(0,G.jsx)(`datalist`,{id:`memory-agent-role-options`,children:p.map(e=>(0,G.jsx)(`option`,{value:e},e))})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:s(`activity:memoryManager.editorRelationships`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.editorRelationshipsHint`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorSupersedes`)}),(0,G.jsx)(B,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>g(`supersedes`,e.target.value),placeholder:s(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorContradicts`)}),(0,G.jsx)(B,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>g(`contradicts`,e.target.value),placeholder:s(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memEditor.audienceOptional`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:s(`activity:memEditor.targetThisMemoryToSpecificAgent`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memEditor.roles`)}),(0,G.jsx)(B,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>g(`audienceRoles`,e.target.value),placeholder:s(`activity:memEditor.reviewerRefactorPlanner`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memoryManager.editorTaskTypes`)}),(0,G.jsx)(B,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>g(`audienceTaskTypes`,e.target.value),placeholder:s(`activity:memEditor.reviewRefactorBugfix`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s(`activity:memEditor.modes`)}),(0,G.jsx)(B,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>g(`audienceModes`,e.target.value),placeholder:s(`activity:memEditor.teachCodeReview`),className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function Xe({searchQuery:e,statusFilter:t,kindFilter:n,audienceOnly:r,tagFilter:a,hasFilters:o,allTags:s,stats:c,onSearchChange:u,onStatusFilterChange:d,onKindFilterChange:p,onToggleAudienceOnly:m,onTagFilterChange:h,onClearFilters:g}){let{t:v}=f(),[y,b]=(0,K.useState)(!!a),x=y||!!a,S=s.length>0;return(0,G.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(B,{"aria-label":v(`activity:memoryManager.searchAria`),value:e,onChange:e=>u(e.target.value),placeholder:v(`activity:memoryManager.searchPlaceholder`),className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,G.jsx)(`button`,{type:`button`,"aria-label":v(`activity:memoryManager.clearSearchAria`),onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(l,{className:`size-3.5`})})]}),(0,G.jsx)(z,{variant:r?`default`:`ghost`,size:`icon`,onClick:m,"aria-label":v(`activity:memoryManager.audienceFilterAria`),title:v(`activity:memoryManager.audienceFilterTitle`),className:`shrink-0`,children:(0,G.jsx)(w,{className:`size-4`})}),o&&(0,G.jsx)(z,{variant:`ghost`,size:`icon`,onClick:g,"aria-label":v(`activity:memoryManager.clearFiltersAria`),title:v(`activity:memoryManager.clearFiltersTitle`),children:(0,G.jsx)(i,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:v(`activity:memoryManager.filterByStatus`)}),(0,G.jsxs)(`select`,{id:`memory-status-filter`,value:t,onChange:e=>d(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:v(`activity:memoryManager.allStatuses`)}),Ee.map(e=>(0,G.jsxs)(`option`,{value:e,children:[e,` · `,c?.byStatus[e]??0]},e))]}),(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:v(`activity:memoryManager.filterByKind`)}),(0,G.jsxs)(`select`,{id:`memory-kind-filter`,value:n,onChange:e=>p(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:v(`activity:memoryManager.allKinds`)}),Ce.map(e=>(0,G.jsxs)(`option`,{value:e,children:[Oe[e],` · `,c?.byKind[e]??0]},e))]})]}),S&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{a||b(e=>!e)},"aria-expanded":x,"aria-controls":`memory-tags-panel`,disabled:!!a,className:P(`flex items-center gap-1.5 px-1 py-0.5 text-[10px] uppercase tracking-wide transition-colors`,x?`text-foreground`:`text-muted-foreground hover:text-foreground`,!!a&&`cursor-default`),title:a?`Active filter: ${a} (click the chip to clear)`:x?`Hide tag filters`:`Show tag filters (${s.length})`,children:[(0,G.jsx)(ee,{className:P(`size-3 transition-transform`,!x&&`-rotate-90`)}),(0,G.jsx)(se,{className:`size-3`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:v(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:s.length})]}),a&&(0,G.jsx)(`span`,{role:`status`,"aria-label":`Active tag filter: ${a}`,className:`border border-info/55 bg-info/10 px-1 font-mono text-[9px] uppercase text-info`,children:a})]}),S&&x&&(0,G.jsxs)(`fieldset`,{id:`memory-tags-panel`,className:`min-w-0 border-0 p-0`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:v(`activity:memoryManager.popularTags`)}),(0,G.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:s.slice(0,18).map(([e,t])=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":a===e,onClick:()=>h(a===e?null:e),className:P(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,a===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,G.jsx)(se,{className:`size-2.5`}),` `,e,(0,G.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}var Ze=100;function Qe({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let{t:s}=f(),c=n.length>Ze,l=O({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:c});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{children:s(`activity:memoryManager.memoryCountSummary`,{shown:n.length,total:t.length})}),(0,G.jsx)(`span`,{className:`font-mono uppercase`,children:s(`activity:memoryManager.updatedSortLabel`)})]}),(0,G.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":s(`activity:memoryManager.listAria`),children:n.length===0?(0,G.jsx)($e,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):c?(0,G.jsx)(`div`,{style:{height:`${l.getTotalSize()}px`,width:`100%`,position:`relative`},children:l.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,G.jsx)(`div`,{"data-index":e.index,ref:l.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,G.jsx)(et,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,G.jsx)(et,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function $e({hasMemories:e,onOpenCreate:t,onClearFilters:n}){let{t:r}=f();return(0,G.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,G.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,G.jsx)(x,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:r(e?`activity:memoryManager.noMatching`:`activity:memoryManager.buildGraph`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:r(e?`activity:memoryManager.emptyFiltered`:`activity:memoryManager.emptyCapture`)}),(0,G.jsxs)(z,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,G.jsx)(i,{className:`size-3.5`}):(0,G.jsx)(E,{className:`size-3.5`}),r(e?`activity:memoryManager.clearFilters`:`activity:memoryManager.createFirst`)]})]})}function et({memory:e,isSelected:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:P(`group relative block w-full border-b border-border/55 px-3 py-3 text-left transition-[background-color,border-color] hover:bg-info/5`,t&&`bg-info/8`),children:[t&&(0,G.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:P(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,Se(e.kind)),children:Oe[e.kind]??e.kind}),(0,G.jsx)(we,{status:e.status}),(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,G.jsx)(`p`,{className:P(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:H(e.text)}),(0,G.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,G.jsx)(w,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,G.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,G.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,G.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:Me(e.updatedAt)}),(0,G.jsx)(k,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function tt({onCapture:e}){let{t}=f();return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,G.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,G.jsx)(w,{className:`size-8`}),(0,G.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,G.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:t(`activity:memoryManager.emptyTitle`)}),(0,G.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:t(`activity:memoryManager.emptyBody`)}),(0,G.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(v,{className:`mx-auto size-4 text-success`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyVerifiedAnchors`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(w,{className:`mx-auto size-4 text-info`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyTypedRelations`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(E,{className:`mx-auto size-4 text-warning`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyAgentRecall`)})]})]}),(0,G.jsxs)(z,{onClick:e,children:[(0,G.jsx)(E,{className:`size-4`}),` `,t(`activity:memoryManager.captureButton`)]})]})}function nt({wsConnected:e,refreshing:t,onRefresh:n,onCreate:r}){let{t:i}=f(),a=de(e=>e.setCurrentView);return(0,G.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,G.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,onClick:()=>a(`chat`),"aria-label":i(`activity:memoryManager.backToChat`),title:i(`activity:memoryManager.backToChat`),children:(0,G.jsx)(o,{className:`size-4`})}),(0,G.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,G.jsx)(w,{className:`size-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:i(`activity:memoryManager.sageHeading`)}),(0,G.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:i(`activity:memoryManager.projectKnowledge`)})]}),(0,G.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:i(`activity:memoryManager.sageSubtitle`)})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:P(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,e?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,G.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,i(e?`activity:memoryManager.liveStore`:`activity:memoryManager.reconnecting`)]}),(0,G.jsxs)(z,{variant:`outline`,size:`sm`,onClick:n,disabled:t,"aria-label":i(`activity:memoryManager.refreshAria`),children:[(0,G.jsx)(A,{className:P(`size-3.5`,t&&`animate-spin`)}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:i(`common:action.refresh`)})]}),(0,G.jsxs)(z,{size:`sm`,onClick:r,children:[(0,G.jsx)(E,{className:`size-3.5`}),` `,i(`activity:memoryManager.newMemory`)]})]})]})]})}function rt({stats:e,memories:t,filteredCount:n,allTagsCount:r}){let{t:i}=f(),a=t.filter(e=>e.audience).length,o=new Set;if(a>0){for(let e of t)if(e.audience){for(let t of e.audience.roles??[])o.add(t);for(let t of e.audience.taskTypes??[])o.add(t);for(let t of e.audience.modes??[])o.add(t)}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,G.jsx)(ke,{label:i(`activity:memoryManager.tabMemories`),value:e?.total??t.length,hint:`${n} visible`}),(0,G.jsx)(ke,{label:i(`activity:memoryManager.tabActive`),value:e?.byStatus.active??t.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,G.jsx)(ke,{label:i(`activity:memoryManager.tabNeedsReview`),value:(e?.byStatus.stale??0)+(e?.byStatus.contradicted??0),hint:i(`activity:memoryManager.staleConflicts`),tone:`warning`}),(0,G.jsx)(`div`,{className:`hidden sm:block`,children:(0,G.jsx)(ke,{label:i(`activity:memoryManager.tabGraphEdges`),value:e?.edges??0,hint:`${r} tags`,tone:`info`})})]}),a>0&&(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,G.jsx)(w,{className:`size-3.5 text-primary`}),(0,G.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[a,` audience-scoped memory`,a===1?``:`ies`]}),o.size>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...o].sort().join(`, `),`)`]})]})]})}function it({query:e,channel:t,hits:n,loading:r,error:i,onOpenMemory:a,onClear:o}){let{t:s}=f();return e?(0,G.jsxs)(`section`,{"aria-label":s(`activity:memoryManager.searchBreakdownAria`),className:`border-b border-border/60 bg-card/35`,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-border/55 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(m,{className:`size-3 text-info`}),(0,G.jsx)(`span`,{className:`font-mono uppercase tracking-[0.1em]`,children:s(`activity:memoryManager.searchBreakdownTitle`,{query:e})}),t===`breakdown`&&(0,G.jsx)(`span`,{className:`border border-info/40 bg-info/8 px-1.5 py-0.5 font-mono text-[9px] uppercase text-info`,children:s(`activity:memoryManager.searchBreakdownDual`)}),t===`lexical`&&(0,G.jsx)(`span`,{className:`border border-border/60 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownLexicalOnly`)})]}),(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`font-mono text-[10px] uppercase text-muted-foreground hover:text-foreground`,children:s(`common:action.close`)})]}),r&&(0,G.jsx)(`p`,{className:`px-3 py-3 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownLoading`)}),i&&(0,G.jsx)(`p`,{className:`border-t border-border/55 px-3 py-2 text-[10px] text-destructive`,role:`alert`,children:i}),!r&&!i&&n.length===0&&(0,G.jsx)(`p`,{className:`px-3 py-3 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownEmpty`)}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:n.map(e=>(0,G.jsx)(at,{hit:e,onOpenMemory:a},e.memory.id))})]}):null}function at({hit:e,onOpenMemory:t}){let{t:n}=f(),r=ot(e.lexicalScore),i=ot(e.vectorScore),a=ot(e.finalScore),{accent:o,label:s}=st(e.source);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e.memory.id),className:`group flex w-full min-w-0 items-start gap-3 px-3 py-2.5 text-left hover:bg-info/5`,children:[(0,G.jsx)(`span`,{className:P(`flex size-7 shrink-0 items-center justify-center border font-mono text-[9px] uppercase`,o),title:n(`activity:memoryManager.searchBreakdownSourceLabel`,{source:s}),children:e.source===`vector`?(0,G.jsx)(m,{className:`size-3.5`}):e.source===`both`?(0,G.jsx)(ne,{className:`size-3.5`}):(0,G.jsx)(C,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`line-clamp-2 text-[11px] leading-5 text-foreground/90`,children:e.memory.text}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`L`}),(0,G.jsx)(`span`,{className:`tabular-nums text-foreground/80`,children:r})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`V`}),(0,G.jsx)(`span`,{className:P(`tabular-nums`,e.vectorScore===null?`text-muted-foreground/50`:`text-foreground/80`),children:i})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`RRF`}),(0,G.jsx)(`span`,{className:`tabular-nums font-bold text-foreground`,children:a})]}),(0,G.jsx)(`span`,{className:`ml-auto uppercase text-[9px]`,children:s})]})]})]})})}function ot(e){return e===null?`—`:`${Math.round(e*100)}%`}function st(e){switch(e){case`vector`:return{accent:`border-accent/40 bg-accent/10 text-accent`,label:`vector`};case`both`:return{accent:`border-info/40 bg-info/10 text-info`,label:`both`};default:return{accent:`border-border/60 bg-background text-muted-foreground`,label:`lexical`}}}function ct({listCandidates:e,resolveCandidate:t,onOpenMemory:n,client:r,active:i}){let{t:a}=f(),[o,s]=(0,K.useState)([]),[c,d]=(0,K.useState)(!1),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(null),[_,ee]=(0,K.useState)(!1),[y,b]=(0,K.useState)(()=>new Set),x=(0,K.useRef)(0),C=(0,K.useCallback)(()=>{let t=++x.current;d(!0),m(null);let n=r.on(`memory.sage.listCandidates`,e=>{if(t===x.current){if(n(),e.payload.error)m(String(e.payload.error)),s([]);else{let t=(Array.isArray(e.payload.candidates)?e.payload.candidates:[]).filter(e=>e.status===`pending`);s(t),b(e=>{let n=new Set;for(let r of e)t.some(e=>e.id===r)&&n.add(r);return n})}d(!1)}}),i=setTimeout(()=>{t===x.current&&(n(),d(!1),m(a(`activity:memoryManager.reviewLoadTimeout`)))},15e3);return e({includeResolved:!1},{echoToChat:!1}),()=>{clearTimeout(i),n()}},[r,e,a]);(0,K.useEffect)(()=>{if(i)return C()},[i,C]);let w=(0,K.useCallback)((e,n)=>new Promise(i=>{let a=r.on(`memory.sage.candidateResolve`,e=>{a();let t=e.payload.error;i(!t)});t({candidateId:e,action:n,reason:n===`reject`?`Rejected via Memory Review tab`:void 0},{echoToChat:!1}),setTimeout(()=>{a(),i(!1)},15e3)}),[r,t]),T=(0,K.useCallback)(async(e,t)=>{g(e),await w(e,t),g(null),C()},[C,w]),E=(0,K.useCallback)(async e=>{let t=[...y];if(t.length!==0){ee(!0);for(let n of t)await w(n,e);ee(!1),b(new Set),C()}},[C,w,y]),D=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},O=()=>{b(new Set(o.map(e=>e.id)))},te=()=>b(new Set);if(c&&o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 p-6 text-sm text-muted-foreground`,children:[(0,G.jsx)(u,{className:`size-4 animate-spin`}),a(`activity:memoryManager.reviewLoading`)]});if(p&&o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(S,{className:`size-5 text-warning`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,onClick:()=>C(),children:[(0,G.jsx)(A,{className:`size-3.5`}),` `,a(`common:action.retry`)]})]});if(o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center`,children:[(0,G.jsx)(v,{className:`size-6 text-success`}),(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:a(`activity:memoryManager.reviewEmptyTitle`)}),(0,G.jsx)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:a(`activity:memoryManager.reviewEmptyHint`)}),(0,G.jsxs)(z,{size:`sm`,variant:`ghost`,onClick:()=>C(),children:[(0,G.jsx)(A,{className:`size-3.5`}),` `,a(`common:action.refresh`)]})]});let k=y.size,ne=k===o.length&&o.length>0;return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:a(`activity:memoryManager.reviewPendingCount`,{count:o.length})}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(z,{size:`sm`,variant:`ghost`,className:`h-7 text-[11px]`,onClick:ne?te:O,children:a(ne?`activity:memoryManager.reviewClearSelection`:`activity:memoryManager.reviewSelectAll`)}),(0,G.jsxs)(z,{size:`sm`,className:`h-7`,disabled:k===0||_,onClick:()=>void E(`accept`),children:[_?(0,G.jsx)(u,{className:`size-3 animate-spin`}):(0,G.jsx)(v,{className:`size-3`}),a(`activity:memoryManager.reviewBulkAccept`),k>0?` (${k})`:``]}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,className:`h-7`,disabled:k===0||_,onClick:()=>void E(`reject`),children:[(0,G.jsx)(l,{className:`size-3`}),a(`activity:memoryManager.reviewBulkKeep`),k>0?` (${k})`:``]}),(0,G.jsx)(z,{size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>C(),disabled:c,children:(0,G.jsx)(A,{className:P(`size-3.5`,c&&`animate-spin`)})})]})]}),(0,G.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:o.map(e=>{let t=e.targetMemoryId??e.memoryId,r=e.reviewReason??e.reason??``,i=h===e.id||_,o=y.has(e.id);return(0,G.jsx)(`li`,{className:P(`rounded-md border bg-card/60 p-3 text-sm shadow-sm`,o?`border-primary/50 ring-1 ring-primary/20`:`border-border/70`),children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-3.5 accent-primary`,checked:o,disabled:_,onChange:()=>D(e.id),"aria-label":a(`activity:memoryManager.reviewSelectOne`)}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`font-mono text-warning`,children:e.suggestedAction??`review`}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{children:Me(e.createdAt)}),e.tags?.includes(`triage`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{className:`text-info`,children:`triage`})]})]}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-snug text-foreground`,children:H(e.text,220)}),r?(0,G.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r}):null,t?(0,G.jsxs)(`button`,{type:`button`,className:`mt-1 font-mono text-[10px] text-primary hover:underline`,onClick:()=>n?.(t),children:[t.slice(0,16),`…`]}):null,(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,G.jsxs)(z,{size:`sm`,className:`h-7`,disabled:i,onClick:()=>void T(e.id,`accept`),children:[h===e.id?(0,G.jsx)(u,{className:`size-3 animate-spin`}):(0,G.jsx)(v,{className:`size-3`}),a(`activity:memoryManager.actionAcceptDeletion`)]}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,className:`h-7`,disabled:i,onClick:()=>void T(e.id,`reject`),children:[(0,G.jsx)(l,{className:`size-3`}),a(`activity:memoryManager.actionKeep`)]})]})]})]})},e.id)})})]})}function lt(e,t){let n=t.searchQuery.trim().toLowerCase();return e.filter(e=>{if(t.statusFilter!==`all`&&e.status!==t.statusFilter||t.kindFilter!==`all`&&e.kind!==t.kindFilter||t.tagFilter&&!e.tags.includes(t.tagFilter)||t.audienceOnly&&!e.audience)return!1;if(!n)return!0;let r=e.anchors.map(e=>[e.path,e.symbol,e.command,e.role].filter(Boolean).join(` `)).join(` `),i=e.audience?[e.audience.roles?.join(` `)??``,e.audience.taskTypes?.join(` `)??``,e.audience.modes?.join(` `)??``].join(` `):``;return[e.id,e.text,e.summary??``,e.kind,e.scope,e.tags.join(` `),r,i].join(` `).toLowerCase().includes(n)})}function ut(e){let t=new Map;for(let n of e)for(let e of n.tags)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function dt(e){if(!e)return[];let t=[];e.supersededBy&&t.push({relation:`Superseded by`,id:e.supersededBy});for(let n of e.supersedes??[])t.push({relation:`Supersedes`,id:n});for(let n of e.contradicts??[])t.push({relation:`Contradicts`,id:n});return t}var ft=100;function pt(){let{t:e}=f(),{client:n,listSageMemoriesPage:r,listMemoryCandidates:i,rememberSage:a,updateSage:o,deleteSage:s,getSageGraph:c,recoverSage:l,resolveMemoryCandidate:u,searchSageBreakdown:d}=me(),p=t(e=>e.wsConnected),[m,h]=(0,K.useState)([]),[g,_]=(0,K.useState)(null),[v,ee]=(0,K.useState)(!0),[y,b]=(0,K.useState)(!1),[x,S]=(0,K.useState)(null),[C,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(null),[D,O]=(0,K.useState)(null),[te,k]=(0,K.useState)([]),[ne,re]=(0,K.useState)([]),[A,ie]=(0,K.useState)(null),[ae,oe]=(0,K.useState)(!1),[se,j]=(0,K.useState)(!1),[M,ce]=(0,K.useState)(!1),[N,le]=(0,K.useState)(xe),[ue,P]=(0,K.useState)(xe),[de,F]=(0,K.useState)(null),[fe,pe]=(0,K.useState)(null),[I,L]=(0,K.useState)({hits:[],channel:void 0,loading:!1,error:null}),[R,z]=(0,K.useState)(``),[B,he]=(0,K.useState)(`all`),[V,_e]=(0,K.useState)(`all`),[ve,ye]=(0,K.useState)(!1),[H,Se]=(0,K.useState)(null),[Ce,we]=(0,K.useState)(`active`),U=Ce===`deleted`,Te=Ce===`review`,[Ee,De]=(0,K.useState)(null),[Oe,ke]=(0,K.useState)(!1),[Ae,je]=(0,K.useState)(!1),[Me,Ne]=(0,K.useState)({}),[G,Pe]=(0,K.useState)(!1),[Fe,Ie]=(0,K.useState)(null),Le=(0,K.useRef)(!1),Re=(0,K.useRef)([]),ze=(0,K.useRef)(0),q=(0,K.useRef)(null),J=(0,K.useRef)(!0),Be=(0,K.useRef)(0),Y=(0,K.useRef)(0),Ve=(0,K.useRef)(null),X=(0,K.useRef)(null),He=(0,K.useMemo)(()=>{let e=new Set;for(let t of m)for(let n of t.anchors??[])n.type===`file`&&n.path&&e.add(n.path);return e},[m]),Ue=(0,K.useMemo)(()=>JSON.stringify(N)!==JSON.stringify(ue),[ue,N]),We=(0,K.useCallback)(e=>m.find(t=>t.id===e)??I.hits.find(t=>t.memory.id===e)?.memory??ne.find(t=>t.id===e)??null,[ne,m,I.hits]),Z=(0,K.useMemo)(()=>D===null?null:We(D),[We,D]),Ge=(0,K.useCallback)(e=>{let t=e!==null,i=++Be.current;Ve.current?.(),S(null),t?je(!0):(b(!0),Le.current||ee(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),Ve.current===c&&(Ve.current=null))};a=n.on(`memory.sage.listPage`,e=>{if(i!==Be.current||!J.current){c();return}if(c(),e.payload.error)S(e.payload.error);else{let n=e.payload.memories??[];h(e=>t?[...e,...n]:n),De(e.payload.nextCursor??null),ke(!!e.payload.nextCursor);let r=e.payload.statusCounts??{};Ne(r);let i=Object.values(r).reduce((e,t)=>e+t,0);e.payload.stats?_(e.payload.stats):_(e=>({total:i,byStatus:r,byKind:e?.byKind??{},edges:e?.edges??0})),Le.current=!0,t||O(e=>e&&(n.some(t=>t.id===e)||Re.current.some(t=>t.memory.id===e))?e:null)}ee(!1),b(!1),je(!1)}),o=setTimeout(()=>{i===Be.current&&J.current&&(c(),S(`The memory store did not respond. Check the WebSocket connection and try again.`),ee(!1),b(!1),je(!1))},2e4),Ve.current=c,r({limit:ft,...U?{statuses:[`deleted`]}:{},...e?{cursor:e}:{},...R.trim()?{query:R.trim()}:{},...V===`all`?{}:{kind:V}},{echoToChat:!1})},[n,V,r,R,U]),Q=(0,K.useCallback)(()=>{De(null),ke(!1),Ge(null)},[Ge]),Ke=(0,K.useCallback)(()=>{!Ae&&Ee&&Ge(Ee)},[Ge,Ae,Ee]);(0,K.useEffect)(()=>(J.current=!0,Q(),()=>{J.current=!1,Be.current+=1,Y.current+=1,Ve.current?.(),X.current?.(),q.current?.()}),[Q]),(0,K.useEffect)(()=>{let e=R.trim();if(q.current?.(),e.length===0){L({hits:[],channel:void 0,loading:!1,error:null});return}let t=++ze.current;L(e=>({...e,loading:!0,error:null}));let r=()=>{},i=()=>{q.current===i&&(q.current=null),r()};q.current=i,r=n.on(`memory.sage.searchBreakdown`,e=>{if(t!==ze.current||!J.current){i();return}if(i(),e.payload.error){L({hits:[],channel:void 0,loading:!1,error:e.payload.error});return}L({hits:e.payload.hits??[],channel:e.payload.source,loading:!1,error:null})}),d({query:e,limit:20})},[R,n,d]),(0,K.useEffect)(()=>{Re.current=I.hits},[I.hits]),(0,K.useEffect)(()=>{if(k([]),re([]),ie(null),!D){oe(!1);return}let e=D;oe(!0);let t=null,r=n.on(`memory.sage.graph`,n=>{n.payload.query===e&&(t!==null&&clearTimeout(t),k(n.payload.edges??[]),re(n.payload.memories??[]),ie(n.payload.error??null),oe(!1))});return t=setTimeout(()=>{ie(`Relationship graph did not respond in time.`),oe(!1)},15e3),c(e,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{t!==null&&clearTimeout(t),r()}},[n,c,D]);let qe=(0,K.useRef)(p);(0,K.useEffect)(()=>{p&&!qe.current&&Le.current&&Q(),qe.current=p},[Q,p]),(0,K.useEffect)(()=>{if(!T)return;let e=setTimeout(()=>E(null),4e3);return()=>clearTimeout(e)},[T]);let $=(0,K.useCallback)(()=>!Ue||!se&&!M||window.confirm(`Discard the unsaved memory changes?`),[M,Ue,se]),Je=(0,K.useCallback)(()=>{if(!$())return;let e=xe();le(e),P(e),ce(!0),j(!1),O(null),w(null)},[$]),Ye=(0,K.useCallback)(e=>{$()&&(O(e),ce(!1),j(!1),w(null))},[$]),Xe=(0,K.useCallback)(e=>{let t=e===void 0?Z:We(e);if(!t||t.status===`deleted`)return;e!==void 0&&O(e);let n=be(t);le(n),P(n),j(!0),ce(!1),w(null)},[We,Z]),Ze=(0,K.useCallback)(()=>{$()&&(j(!1),ce(!1),w(null))},[$]),Qe=(0,K.useCallback)((t,r,i)=>{if(!N.text.trim()){w(`Memory content is required.`);return}let a=++Y.current;X.current?.(),F(i),w(null),E(null);let o=()=>{},s=null,c=!1,l=()=>{c||(c=!0,s!==null&&clearTimeout(s),o(),X.current===l&&(X.current=null))},u=t=>{if(a!==Y.current||!J.current){l();return}if(l(),F(null),t.payload.error||!t.payload.memory){w(t.payload.error??`The server returned no memory record.`);return}let n=t.payload.memory;h(e=>{let t=e.filter(e=>e.id!==n.id);return[n,...t]}),O(n.id),ce(!1),j(!1),E(e(i===`create`?`activity:memoryManager.memoryCaptured`:`activity:memoryManager.memoryUpdated`)),Q()};o=t===`memory.sage.remember`?n.on(`memory.sage.remember`,u):n.on(`memory.sage.update`,u),s=setTimeout(()=>{a===Y.current&&J.current&&(l(),F(null),w(e(`activity:memoryManager.mutationTimeout`,{verb:e(i===`create`?`activity:memoryManager.createAction`:`common:action.save`)})))},2e4),X.current=l,r()},[n,N.text,Q,e]),$e=(0,K.useCallback)(()=>{Qe(`memory.sage.remember`,()=>a({text:N.text.trim(),kind:N.kind,scope:N.scope,tags:W(N.tags),importance:N.importance,confidence:N.confidence,freshness:N.freshness,anchors:ge(N.anchors),...W(N.audienceRoles).length||W(N.audienceTaskTypes).length||W(N.audienceModes).length?{audience:{roles:W(N.audienceRoles),taskTypes:W(N.audienceTaskTypes),modes:W(N.audienceModes)}}:{},supersedes:W(N.supersedes),contradicts:W(N.contradicts)},{echoToChat:!1}),`create`)},[N,a,Qe]),et=(0,K.useCallback)(()=>{Z&&Qe(`memory.sage.update`,()=>o(Z.id,{text:N.text.trim(),kind:N.kind,status:N.status,tags:W(N.tags),importance:N.importance,confidence:N.confidence,freshness:N.freshness,anchors:ge(N.anchors),...W(N.audienceRoles).length||W(N.audienceTaskTypes).length||W(N.audienceModes).length?{audience:{roles:W(N.audienceRoles),taskTypes:W(N.audienceTaskTypes),modes:W(N.audienceModes)}}:{},supersedes:W(N.supersedes),contradicts:W(N.contradicts)},{echoToChat:!1}),`update`)},[N,Qe,Z,o]),tt=(0,K.useCallback)(()=>{if(!fe)return;let e=++Y.current;X.current?.(),F(`delete`),w(null);let t=()=>{},r=null,i=!1,a=()=>{i||(i=!0,r!==null&&clearTimeout(r),t(),X.current===a&&(X.current=null))};t=n.on(`memory.sage.delete`,t=>{if(e!==Y.current||!J.current){a();return}if(a(),F(null),!t.payload.success){w(t.payload.message||`Delete failed.`);return}pe(null),O(null),j(!1),E(`Memory deleted and relationship edges cleaned up.`),Q()}),r=setTimeout(()=>{e===Y.current&&J.current&&(a(),F(null),w(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=a,s(fe,`Deleted from the WebUI Memory Manager.`)},[n,s,fe,Q]),nt=(0,K.useCallback)((e,t,r)=>{let i=++Y.current;X.current?.(),w(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))};a=n.on(e,e=>{if(i!==Y.current||!J.current){c();return}c(),r(e.payload)}),o=setTimeout(()=>{i===Y.current&&J.current&&(c(),w(`The memory store did not respond. Check the WebSocket connection and try again.`))},2e4),X.current=c,t()},[n]),rt=(0,K.useMemo)(()=>lt(m,{searchQuery:R,statusFilter:B,kindFilter:V,tagFilter:H,audienceOnly:ve}),[ve,V,m,R,B,H]),it=(0,K.useMemo)(()=>ut(m),[m]),at=(0,K.useMemo)(()=>dt(Z),[Z]),ot=(0,K.useCallback)(()=>{z(``),he(`all`),_e(`all`),ye(!1),Se(null)},[]);return{client:n,wsConnected:p,memories:m,stats:g,initialLoading:v,refreshing:y,loadError:x,mutationError:C,setMutationError:w,notice:T,setNotice:E,selectedId:D,setSelectedId:O,selectedMemory:Z,graphEdges:te,graphMemories:ne,graphError:A,graphLoading:ae,editing:se,creating:M,draft:N,setDraft:le,busyAction:de,deletingId:fe,setDeletingId:pe,searchQuery:R,setSearchQuery:z,searchBreakdown:I,clearSearchBreakdown:()=>{ze.current+=1,q.current?.(),L({hits:[],channel:void 0,loading:!1,error:null})},statusFilter:B,setStatusFilter:he,kindFilter:V,setKindFilter:_e,audienceOnly:ve,setAudienceOnly:ye,tagFilter:H,setTagFilter:Se,libraryView:Ce,setLibraryView:we,showDeleted:U,showReview:Te,hasMore:Oe,loadingMore:Ae,statusCounts:Me,drawerOpen:G,setDrawerOpen:Pe,currentFilePath:Fe,setCurrentFilePath:Ie,knownFilePaths:He,filteredMemories:rt,allTags:it,relatedMemories:at,hasFilters:!!(R||B!==`all`||V!==`all`||H||ve),detailOpen:M||!!Z,drawerActive:G&&!!Fe,loadMemories:Q,loadMore:Ke,openCreate:Je,openMemory:Ye,openEdit:Xe,cancelEditor:Ze,submitCreate:$e,submitUpdate:et,confirmDelete:tt,sendWithAck:nt,clearFilters:ot,resolveMemoryCandidate:u,updateSage:o,recoverSage:l,listMemoryCandidates:i}}function mt(){let{t:e}=f(),t=de(e=>e.setCurrentView),n=he(`memory`),r=pt();return r.initialLoading&&r.memories.length===0?(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,G.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,G.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,G.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,G.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,G.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,G.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,G.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:e(`activity:memoryManager.loadingSageContent`)})]}):r.loadError&&r.memories.length===0?(0,G.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,G.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,G.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(S,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:e(`activity:memoryManager.storeUnavailable`)}),(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:r.loadError}),(0,G.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,G.jsxs)(z,{onClick:r.loadMemories,children:[(0,G.jsx)(A,{className:`size-4`}),` `,e(`common:action.retry`)]}),(0,G.jsxs)(z,{variant:`outline`,onClick:()=>t(`chat`),children:[(0,G.jsx)(o,{className:`size-4`}),` `,e(`activity:memoryManager.backToChat`)]})]})]})}):(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,G.jsx)(nt,{wsConnected:r.wsConnected,refreshing:r.refreshing,onRefresh:r.loadMemories,onCreate:r.openCreate}),(0,G.jsx)(rt,{stats:r.stats,memories:r.memories,filteredCount:r.filteredMemories.length,allTagsCount:r.allTags.length}),(r.notice||r.loadError||r.mutationError)&&(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[r.notice&&(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,G.jsx)(v,{className:`size-3.5`}),` `,r.notice]}),r.loadError&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,G.jsx)(S,{className:`size-3.5`}),` `,r.loadError,` Existing content remains available.`]}),r.mutationError&&!r.editing&&!r.creating&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,G.jsx)(S,{className:`size-3.5`}),` `,r.mutationError]})]}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsxs)(`section`,{className:P(`min-h-0 border-r border-border/70 bg-card/25`,r.detailOpen?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":e(`activity:memoryManager.libraryAria`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":e(`activity:memoryManager.viewAria`),children:[(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.libraryView===`active`,onClick:()=>r.setLibraryView(`active`),className:P(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.libraryView===`active`?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabActive`)}),(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.showReview,onClick:()=>r.setLibraryView(`review`),className:P(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.showReview?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabReview`)}),(0,G.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.showDeleted,onClick:()=>r.setLibraryView(`deleted`),className:P(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.showDeleted?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[e(`activity:memoryManager.tabDeleted`),typeof r.statusCounts.deleted==`number`?` (${r.statusCounts.deleted})`:``]})]}),r.showReview?(0,G.jsx)(ct,{active:r.showReview,client:r.client,listCandidates:r.listMemoryCandidates,resolveCandidate:r.resolveMemoryCandidate,onOpenMemory:r.openMemory}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Xe,{searchQuery:r.searchQuery,statusFilter:r.statusFilter,kindFilter:r.kindFilter,audienceOnly:r.audienceOnly,tagFilter:r.tagFilter,hasFilters:r.hasFilters,allTags:r.allTags,stats:r.stats,onSearchChange:r.setSearchQuery,onStatusFilterChange:r.setStatusFilter,onKindFilterChange:r.setKindFilter,onToggleAudienceOnly:()=>r.setAudienceOnly(e=>!e),onTagFilterChange:r.setTagFilter,onClearFilters:r.clearFilters}),(0,G.jsx)(Qe,{memoryListRef:n,memories:r.memories,filteredMemories:r.filteredMemories,selectedId:r.selectedId,onSelectMemory:r.openMemory,onOpenCreate:r.openCreate,onClearFilters:r.clearFilters}),r.searchQuery.trim().length>0&&(0,G.jsx)(it,{query:r.searchQuery.trim(),channel:r.searchBreakdown.channel,hits:r.searchBreakdown.hits,loading:r.searchBreakdown.loading,error:r.searchBreakdown.error,onOpenMemory:r.openMemory,onClear:r.clearSearchBreakdown}),r.hasMore?(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,G.jsx)(z,{type:`button`,variant:`outline`,size:`sm`,onClick:r.loadMore,disabled:r.loadingMore,className:`h-7 w-full text-[11px]`,children:r.loadingMore?e(`common:action.loading`):`Load more (${r.memories.length} loaded)`})}):null]})]}),(0,G.jsxs)(`section`,{className:P(`min-h-0 bg-background`,r.detailOpen?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":e(`activity:memoryManager.detailAria`),children:[r.memories.some(e=>(e.anchors??[]).some(e=>e.type===`file`&&e.path))&&(0,G.jsx)(Je,{currentFilePath:r.currentFilePath,knownFilePaths:r.knownFilePaths,drawerActive:r.drawerActive,onFilePathChange:e=>{e&&r.knownFilePaths.has(e)?(r.setCurrentFilePath(e),r.setDrawerOpen(!0)):e?r.setCurrentFilePath(e):r.setCurrentFilePath(null)},onToggleDrawer:()=>{r.currentFilePath&&r.setDrawerOpen(e=>!e)}}),r.creating?(0,G.jsx)(Ye,{mode:`create`,draft:r.draft,busy:r.busyAction===`create`,error:r.mutationError,onChange:r.setDraft,onCancel:r.cancelEditor,onSubmit:r.submitCreate}):r.selectedMemory?r.editing?(0,G.jsx)(Ye,{mode:`edit`,draft:r.draft,busy:r.busyAction===`update`,error:r.mutationError,onChange:r.setDraft,onCancel:r.cancelEditor,onSubmit:r.submitUpdate}):r.drawerActive?(0,G.jsx)(Ne,{filePath:r.currentFilePath,open:r.drawerActive,onClose:()=>r.setDrawerOpen(!1),onShowMemory:e=>r.setSelectedId(e),onAcceptDeletion:(e,t)=>{r.sendWithAck(`memory.sage.candidateResolve`,()=>r.resolveMemoryCandidate({candidateId:e,action:`accept`}),n=>{if(n.error){r.setMutationError(n.error);return}r.setNotice(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),r.loadMemories()})},onKeep:(e,t)=>{r.sendWithAck(`memory.sage.candidateResolve`,()=>r.resolveMemoryCandidate({candidateId:e,action:`reject`}),n=>{if(n.error){r.setMutationError(n.error);return}r.setNotice(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`),r.loadMemories()})},onUpdate:e=>{r.openEdit(e)},onMarkPermanent:e=>{r.sendWithAck(`memory.sage.update`,()=>r.updateSage(e,{persistence:`permanent`}),t=>{if(t.error||!t.memory){r.setMutationError(t.error??`The server returned no memory record.`);return}r.setNotice(`Memory ${e.slice(0,12)}… promoted to permanent.`),r.loadMemories()})},onRecover:e=>{r.sendWithAck(`memory.sage.recover`,()=>r.recoverSage({id:e,reason:`recovered via file drawer`}),t=>{if(t.error){r.setMutationError(t.error);return}r.setNotice(`Recovered ${e.slice(0,12)}…`),r.loadMemories()})}}):(0,G.jsx)(Ue,{memory:r.selectedMemory,allMemories:[...r.memories,...r.graphMemories],relatedMemories:r.relatedMemories,graphEdges:r.graphEdges,graphLoading:r.graphLoading,graphError:r.graphError,onClose:()=>r.setSelectedId(null),onOpenMemory:r.openMemory,onEdit:r.openEdit,onDelete:()=>r.setDeletingId(r.selectedMemory.id),onTagSelect:e=>{r.setTagFilter(e),r.setSelectedId(null)},onNotice:r.setNotice}):(0,G.jsx)(tt,{onCapture:r.openCreate})]})]}),(0,G.jsx)(Pe,{busyAction:r.busyAction,deletingId:r.deletingId,memory:r.selectedMemory,onCancel:()=>r.setDeletingId(null),onConfirm:r.confirmDelete,onOpenChange:e=>{!e&&r.busyAction!==`delete`&&r.setDeletingId(null)}})]})}export{mt as MemoryManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{U as t,mt as n,t as r}from"./config-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{U as t,mt as n,t as r}from"./config-store-D7yrCV2X.js";import{i,t as a}from"./react-core-wiHys0m2.js";import{La as o,_t as s,jt as c,wt as l}from"./vendor-BO-lHyIr.js";import"./i18n-B_njdXiH.js";import{t as u}from"./utils-DQbrPaAM.js";import"./stores-COxKgvNx.js";import{n as d,o as f,r as p,t as m}from"./dialog-CTmNJKRN.js";import{I as h}from"./index-CfREDCPe.js";var g=e(i(),1),_=a();function v({open:e,onClose:i,className:a}){let{t:v}=o(),[y,b]=(0,g.useState)([]),x=n(),S=h(),C=r(e=>e.wsConnected),w=(0,g.useRef)(null),T=(0,g.useRef)(null);(0,g.useEffect)(()=>{if(!e||!C||!S.client?.isConnected)return;b([]);let n=()=>{let e=S.client.withSession?.({})??(x?{sessionId:x}:{});S.client.send?.({type:`process.list`,payload:e})};return n(),w.current=S.client.on?.(`process.list`,e=>{let n=e?.payload;n?.processes&&t(n.sessionId,x)&&b(n.processes)})??null,T.current=setInterval(n,3e3),()=>{w.current?.(),T.current&&clearInterval(T.current)}},[e,C,S.client,x]);let E=y.filter(e=>e.status===`running`),D=(0,g.useCallback)(e=>{if(e.background&&!window.confirm(v(`activity:process.confirmKillBackground`,{pid:e.pid,defaultValue:`Terminate detached background process ${e.pid}?`})))return;let t=S.client.withSession?.({pid:e.pid})??{pid:e.pid};S.client.send?.({type:`process.kill`,payload:t})},[v,S.client]),O=(0,g.useCallback)(()=>{if(!window.confirm(v(`activity:process.confirmKillAll`,{count:E.length,defaultValue:`Terminate all ${E.length} running processes?`})))return;let e=S.client.withSession?.({})??(x?{sessionId:x}:{});S.client.send?.({type:`process.killAll`,payload:e})},[E.length,v,S.client,x]);return(0,_.jsx)(m,{open:e,onOpenChange:e=>{e||i()},children:(0,_.jsxs)(d,{className:u(`max-w-lg gap-0 p-0 overflow-hidden flex flex-col max-h-[75dvh] pt-[10dvh]`,a),showCloseButton:!1,children:[(0,_.jsx)(f,{className:`sr-only`,children:v(`activity:process.heading`)}),(0,_.jsx)(p,{className:`sr-only`,children:v(`activity:process.subtitle`,{active:E.length,total:y.length})}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b shrink-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,_.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-warning/10 text-warning`,children:(0,_.jsx)(s,{className:`h-4 w-4`})}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-sm font-semibold`,children:v(`activity:process.heading`)}),(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:v(`activity:process.subtitle`,{active:E.length,total:y.length})})]})]}),(0,_.jsx)(`div`,{className:`flex items-center gap-1`,children:E.length>0&&(0,_.jsxs)(`button`,{type:`button`,onClick:O,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,children:[(0,_.jsx)(l,{className:`h-3 w-3 fill-current`}),v(`activity:process.killAll`)]})})]}),(0,_.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:y.length===0?(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,_.jsx)(s,{className:`h-10 w-10 opacity-15`}),(0,_.jsx)(`p`,{className:`text-sm font-medium`,children:v(`activity:process.emptyTitle`)}),(0,_.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:v(`activity:process.emptyBody`)})]}):(0,_.jsx)(`div`,{className:`divide-y`,children:y.map(e=>{let t=e.status===`running`?Math.floor((Date.now()-e.startedAt)/1e3):null,n=t?t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`:null,r=e.protected===!0,i=e.background===!0;return(0,_.jsxs)(`div`,{className:u(`flex items-center justify-between px-4 py-3 text-xs transition-colors`,e.status===`running`?`bg-background hover:bg-muted/30`:`bg-muted/20 text-muted-foreground`),children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,_.jsx)(`span`,{className:u(`led shrink-0`,e.status===`running`?r?`text-info`:`text-success led-pulse`:`text-muted-foreground`)}),(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:v(`activity:process.pidLabel`,{pid:e.pid})}),(0,_.jsx)(`span`,{className:`font-medium truncate`,children:e.tool}),r&&(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] bg-info/10 text-info font-medium shrink-0`,title:v(`activity:process.protectedTitle`),children:[(0,_.jsx)(c,{className:`h-2.5 w-2.5`}),v(`activity:process.protected`)]}),i&&(0,_.jsx)(`span`,{className:`inline-flex items-center px-1 py-0.5 rounded text-[9px] bg-success/10 text-success font-medium shrink-0`,title:v(`activity:process.backgroundTitle`),children:v(`activity:process.background`)})]}),(0,_.jsx)(`code`,{className:`text-[10px] text-muted-foreground/70 truncate block mt-0.5 font-mono`,children:e.command})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 ml-3`,children:[n&&(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:n}),e.status===`running`&&!r&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>D(e),className:`p-1.5 rounded-md hover:bg-destructive/10 hover:text-destructive transition-colors`,title:v(`activity:process.killTitle`,{pid:e.pid}),children:(0,_.jsx)(l,{className:`h-3.5 w-3.5 fill-current`})})]})]},e.pid)})})})]})})}export{v as ProcessMonitor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-D7yrCV2X.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Gt as i,La as a,Vr as o,Yi as s,dt as c,qi as l,rn as u}from"./vendor-BO-lHyIr.js";import"./i18n-B_njdXiH.js";import{t as d}from"./utils-DQbrPaAM.js";var f=e(n(),1),p=r(),m=200,h=new Set([`raw_user`,`refined_user`]),g=[`raw_user`,`refined_user`];function _(e,t){return e(`activity:promptJournal.cat.${t}`,t)}function v(){let{t:e}=a(),n=t(),[r,s]=(0,f.useState)([]),[l,v]=(0,f.useState)(!0),[b,x]=(0,f.useState)(null),[S,C]=(0,f.useState)(!0),[w,T]=(0,f.useState)({category:``,session:``,limit:m}),[E,D]=(0,f.useState)(new Set),O=(0,f.useCallback)(()=>{if(!n.isConnected){C(!1);return}C(!0),x(null),n.send({type:`prompts.journal`,payload:{filter:{...w.category?{category:w.category}:{},limit:w.limit}}})},[n,w.category,w.limit]);(0,f.useEffect)(()=>{let e=e=>{let t=e.payload;v(t.enabled);let n=(t.entries??[]).filter(e=>h.has(e.category));s(n),x(t.error??null),C(!1)};return n.on(`prompts.journal`,e),O(),()=>n.off(`prompts.journal`,e)},[n,O]);let k=(0,f.useMemo)(()=>{let e=w.session.trim().toLowerCase(),t=r.filter(t=>!e||t.sessionId.toLowerCase().includes(e)),n=new Map;for(let e of[...t].reverse()){let t=e.timestamp.slice(0,10),r=n.get(t)??[];r.push(e),n.set(t,r)}return[...n.entries()]},[r,w.session]),A=(0,f.useMemo)(()=>{let e=0;for(let t of r)e+=t.metadata.tokenEstimate??0;return{count:r.length,tokens:e}},[r]),j=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=(0,f.useMemo)(()=>g.filter(e=>r.some(t=>t.category===e)),[r]);return(0,p.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto`,children:[(0,p.jsxs)(`div`,{className:`border-b border-border/70 px-4 py-3 sm:px-6`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(i,{className:`h-5 w-5 text-primary`}),(0,p.jsx)(`h1`,{className:`text-base font-semibold`,children:e(`activity:promptJournal.title`)})]}),(0,p.jsxs)(`button`,{type:`button`,onClick:O,disabled:S,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50`,children:[(0,p.jsx)(u,{className:d(`h-3.5 w-3.5`,S&&`animate-spin`)}),e(`activity:promptJournal.refresh`)]})]}),(0,p.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:promptJournal.subtitle`)}),l&&A.count>0&&(0,p.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.statEntries`,{count:A.count})}),(0,p.jsx)(`span`,{children:e(`activity:promptJournal.statTokens`,{count:A.tokens.toLocaleString()})})]})]}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 px-4 py-2 sm:px-6`,children:[(0,p.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.filterCategory`)}),(0,p.jsxs)(`select`,{value:w.category,onChange:e=>T(t=>({...t,category:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`,children:[(0,p.jsx)(`option`,{value:``,children:e(`activity:promptJournal.filterAll`)}),M.map(t=>(0,p.jsx)(`option`,{value:t,children:_(e,t)},t))]})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.filterSession`)}),(0,p.jsx)(`input`,{type:`text`,value:w.session,onChange:e=>T(t=>({...t,session:e.target.value})),placeholder:`sess_…`,className:`w-40 rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.filterLimit`)}),(0,p.jsxs)(`select`,{value:w.limit,onChange:e=>T(t=>({...t,limit:Number(e.target.value)})),className:`rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`,children:[(0,p.jsx)(`option`,{value:50,children:`50`}),(0,p.jsx)(`option`,{value:200,children:`200`}),(0,p.jsx)(`option`,{value:1e3,children:`1000`})]})]})]}),(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 px-4 py-3 sm:px-6`,children:[S&&(0,p.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:e(`activity:promptJournal.loading`)}),!S&&b&&(0,p.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-destructive`,children:[(0,p.jsx)(c,{className:`h-4 w-4`}),b]}),!S&&!b&&!l&&(0,p.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:e(`activity:promptJournal.disabled`)}),!S&&!b&&l&&k.length===0&&(0,p.jsxs)(`div`,{className:`py-10 text-center`,children:[(0,p.jsx)(o,{className:`mx-auto h-8 w-8 text-muted-foreground/50`}),(0,p.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e(`activity:promptJournal.emptyTitle`)}),(0,p.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:promptJournal.emptyHint`)})]}),!S&&!b&&l&&k.length>0&&(0,p.jsx)(`div`,{className:`space-y-5`,children:k.map(([e,t])=>(0,p.jsxs)(`section`,{children:[(0,p.jsxs)(`h2`,{className:`sticky top-0 z-10 border-b border-border/60 bg-background/90 py-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground backdrop-blur`,children:[e,(0,p.jsx)(`span`,{className:`ml-2 font-normal normal-case text-muted-foreground/60`,children:t.length})]}),(0,p.jsx)(`ul`,{className:`mt-2 space-y-2`,children:t.map(e=>(0,p.jsx)(y,{entry:e,expanded:E.has(e.id),onToggle:()=>j(e.id)},e.id))})]},e))})]})]})}function y({entry:e,expanded:t,onToggle:n}){let{t:r}=a(),i=e.timestamp.slice(11,19),o=e.metadata,c=e.content.trim().slice(0,240),u=e.rawContent!==void 0&&e.rawContent!==e.content;return(0,p.jsxs)(`li`,{className:`rounded-lg border border-border/70 bg-card/60`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left hover:bg-accent/40`,children:[t?(0,p.jsx)(s,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}):(0,p.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[(0,p.jsx)(`span`,{className:`tabular text-muted-foreground`,children:i}),(0,p.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 font-medium text-primary`,children:_(r,e.category)}),(0,p.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:e.role}),(0,p.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.sessionId})]}),!t&&c&&(0,p.jsx)(`div`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap break-words text-xs text-foreground/80`,children:c})]}),(0,p.jsxs)(`span`,{className:`shrink-0 text-[11px] tabular text-muted-foreground`,children:[`~`,o.tokenEstimate,` `,r(`activity:promptJournal.tokens`)]})]}),t&&(0,p.jsxs)(`div`,{className:`border-t border-border/60 px-3 py-2 pl-9`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:promptJournal.refinedBody`)}),(0,p.jsx)(`pre`,{className:`mt-1 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/50 p-2 text-xs text-foreground`,children:e.content}),u&&(0,p.jsxs)(`div`,{className:`mt-2`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:promptJournal.rawInput`)}),(0,p.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/30 p-2 text-xs text-muted-foreground`,children:e.rawContent})]})]})]})}export{v as PromptJournalView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./config-store-CZdk-vPj.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Ca as i,Ct as a,Jn as o,Mi as ee,Pi as s,Qt as c,Rr as l,Ut as te,Vi as ne,ha as u,lr as re,qi as d,un as f,zt as ie}from"./vendor-Cvuk-OYN.js";import{n as ae}from"./i18n-BwptPW9U.js";import{t as p}from"./utils-sO9lidp6.js";import{o as oe,r as se}from"./view-navigation-BDsXeQ5i.js";import"./stores-Bt7wAdGA.js";import{a as ce,i as m,n as h,o as g,r as le,t as ue}from"./dialog-DNsBc-EF.js";import{t as _}from"./button-CN_h6kNT.js";import{t as de}from"./input-BnTFqRjn.js";import{C as v,I as y,S as b}from"./index-BYBlSXtn.js";var x=e(n(),1),S=r();function C(e){return e?Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e):`—`}function fe(e){return{authentication:`Authentication failed`,quota_exhausted:`Plan / credits exhausted`,rate_limited:`Rate limited`,model_unavailable:`Model unavailable`,context_limit:`Context limit exceeded`,token_limit:`Output-token limit rejected`,timeout:`Timed out`,network:`Network error`,overloaded:`Provider overloaded`,server_error:`Provider server error`,invalid_request:`Invalid request`,cancelled:`Cancelled`,unknown:`Unknown failure`}[e]??e}function w(e,t,n,r){let i=e.trim().toLowerCase(),a=t.trim().toLowerCase(),o=n.trim().toLowerCase();return i===`${a}/${o}`||i===`${a} ${o}`||a===r.trim().toLowerCase()&&i===o}function T(){let e=y(),n=e.client,r=t(e=>e.provider),T=ae(),[E,D]=(0,x.useState)(`provider`),[O,pe]=(0,x.useState)([]),[k,me]=(0,x.useState)(``),[A,j]=(0,x.useState)([]),[M,N]=(0,x.useState)(new Set),[P,F]=(0,x.useState)(``),[I,L]=(0,x.useState)(!1),[R,z]=(0,x.useState)(!1),[B,he]=(0,x.useState)(``),[V,H]=(0,x.useState)(``),[U,W]=(0,x.useState)(``),[G,K]=(0,x.useState)([]),[q,J]=(0,x.useState)(``),[Y,X]=(0,x.useState)([]);(0,x.useEffect)(()=>{if(!n)return;let e=n.on(`providers.saved`,e=>{e.type===`providers.saved`&&pe(e.payload.providers)}),t=n.on(`provider.models`,e=>{if(e.type!==`provider.models`||e.payload.provider!==k)return;let t=e.payload.models;j(t),N(new Set(t.filter(e=>!b(k,e.id,T.disabledModels)).map(e=>e.id))),L(!1)}),r=n.on(`provider.test.started`,e=>{e.type===`provider.test.started`&&e.payload.requestId===B&&z(!0)}),i=n.on(`provider.test.result`,e=>{e.type!==`provider.test.result`||e.payload.requestId!==B&&e.payload.requestId!==V||K(t=>{let n=t.findIndex(t=>t.modelId===e.payload.modelId);return n<0?[...t,e.payload]:t.map((t,r)=>r===n?e.payload:t)})}),a=n.on(`provider.test.complete`,e=>{e.type===`provider.test.complete`&&(e.payload.requestId===B&&(z(!1),J(e.payload.error??``)),e.payload.requestId===V&&(H(``),W(``)))});return n.send({type:`providers.saved`}),()=>{e(),t(),r(),i(),a()}},[n,T.disabledModels,k,B,V]);let ge=(0,x.useMemo)(()=>{let e=P.trim().toLowerCase();return e?A.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e)):A},[A,P]),Z=G.length,_e=G.filter(e=>e.status===`passed`).length,Q=G.filter(e=>e.status===`failed`).length,$=G.filter(e=>e.status===`failed`&&!b(k,e.modelId,T.disabledModels)),ve=()=>{k&&(L(!0),j([]),N(new Set),D(`models`),n?.send({type:`provider.models`,payload:{providerId:k,includeDisabled:!0}}))},ye=()=>{if(!n||M.size===0)return;let e=crypto.randomUUID();he(e),K([]),J(``),z(!0),D(`results`),n.send({type:`provider.test.run`,payload:{requestId:e,providerId:k,modelIds:[...M],timeoutMs:45e3,maxTokens:32}})},be=()=>{B&&n?.send({type:`provider.test.cancel`,payload:{requestId:B}})},xe=e=>{if(!n||R||U)return;let t=crypto.randomUUID();H(t),W(e),n.send({type:`provider.test.run`,payload:{requestId:t,providerId:k,modelIds:[e],timeoutMs:45e3,maxTokens:32}})},Se=t=>{let n=`${k}/${t}`,r=v(k,t,T.favoriteModels)?T.favoriteModels.filter(e=>!v(k,t,[e])):[...T.favoriteModels,n];T.set({favoriteModels:r}),e.updatePrefs({favoriteModels:r})},Ce=t=>{let n=T.disabledModels.filter(e=>!w(e,k,t,r));T.set({disabledModels:n}),e.updatePrefs({disabledModels:n})};return(0,S.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,S.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-border/70 px-4 py-3 sm:px-6`,children:[(0,S.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-primary/10 text-primary`,children:(0,S.jsx)(l,{className:`h-5 w-5`})}),(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`h1`,{className:`text-base font-semibold`,children:`Provider Test`}),(0,S.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:`Test every selected model with the saved account and its real provider adapter.`})]}),(0,S.jsxs)(_,{variant:`ghost`,size:`sm`,onClick:()=>se(`settings`),children:[(0,S.jsx)(ie,{className:`mr-1.5 h-4 w-4`}),` Settings`]}),(0,S.jsx)(_,{variant:`ghost`,size:`icon`,onClick:()=>oe(`chat`),"aria-label":`Close`,children:(0,S.jsx)(i,{className:`h-4 w-4`})})]}),(0,S.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,S.jsxs)(`div`,{className:`mx-auto max-w-7xl space-y-5 p-4 sm:p-6`,children:[(0,S.jsx)(`div`,{className:`grid grid-cols-3 gap-2 text-xs`,children:[`provider`,`models`,`results`].map((e,t)=>(0,S.jsxs)(`div`,{className:p(`rounded-lg border px-3 py-2`,E===e?`border-primary/50 bg-primary/10 text-primary`:`text-muted-foreground`),children:[t+1,`.`,` `,e===`provider`?`Account`:e===`models`?`Models`:`Results`]},e))}),E===`provider`&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Choose a provider or subscription`}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Only saved accounts are shown. Credentials remain on the server.`})]}),O.length===0?(0,S.jsx)(`div`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:`No saved provider accounts. Add one in Settings first.`}):(0,S.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:O.map(e=>{let t=e.apiKeys.find(e=>e.isActive);return(0,S.jsxs)(`button`,{type:`button`,onClick:()=>me(e.id),className:p(`rounded-xl border p-4 text-left transition-colors hover:bg-accent/50`,k===e.id&&`border-primary bg-primary/5 ring-1 ring-primary/30`),children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`font-medium`,children:e.id}),(0,S.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.type&&e.type!==e.id?`${e.type} · ${e.family??`auto`}`:e.family??e.type??`auto-detect`})]}),(0,S.jsx)(re,{className:`h-4 w-4 text-muted-foreground`})]}),(0,S.jsx)(`div`,{className:`mt-3 text-xs text-muted-foreground`,children:t?`${t.label} · ${t.maskedKey}`:`${e.apiKeys.length} saved credential(s)`})]},e.id)})}),(0,S.jsx)(`div`,{className:`flex justify-end`,children:(0,S.jsxs)(_,{disabled:!k,onClick:ve,children:[`Next `,(0,S.jsx)(d,{className:`ml-1.5 h-4 w-4`})]})})]}),E===`models`&&(0,S.jsxs)(`section`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Choose models`}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:k})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>N(new Set(A.filter(e=>!b(k,e.id,T.disabledModels)).map(e=>e.id))),children:`Select all`}),(0,S.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>N(new Set(A.map(e=>e.id))),children:`With disabled models`}),(0,S.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>N(new Set),children:`Clear`})]})]}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(te,{className:`absolute left-3 top-2.5 h-4 w-4 text-muted-foreground`}),(0,S.jsx)(de,{value:P,onChange:e=>F(e.target.value),className:`pl-9`,placeholder:`Filter models…`})]}),I?(0,S.jsx)(`div`,{className:`flex justify-center p-12`,children:(0,S.jsx)(o,{className:`h-6 w-6 animate-spin`})}):(0,S.jsx)(`div`,{className:`overflow-hidden rounded-xl border`,children:ge.map(e=>(0,S.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 border-b p-3 last:border-b-0 hover:bg-accent/40`,children:[(0,S.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-4 w-4 accent-primary`,checked:M.has(e.id),onChange:()=>N(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-mono text-sm`,children:e.id}),b(k,e.id,T.disabledModels)&&(0,S.jsx)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium text-destructive`,children:`Disabled`})]}),e.description&&(0,S.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-muted-foreground`,children:e.description})]}),(0,S.jsxs)(`div`,{className:`shrink-0 text-right text-xs text-muted-foreground`,children:[(0,S.jsxs)(`div`,{children:[`ctx `,C(e.contextWindow)]}),(0,S.jsxs)(`div`,{children:[`out `,C(e.maxOutput)]})]})]},e.id))}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(_,{variant:`ghost`,onClick:()=>D(`provider`),children:[(0,S.jsx)(i,{className:`mr-1.5 h-4 w-4`}),` Back`]}),(0,S.jsxs)(_,{disabled:M.size===0||I,onClick:ye,children:[(0,S.jsx)(f,{className:`mr-1.5 h-4 w-4`}),` Test `,M.size,` model(s)`]})]})]}),E===`results`&&(0,S.jsxs)(`section`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Test results`}),(0,S.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[k,` · `,Z,`/`,M.size,` completed`]})]}),(0,S.jsx)(`div`,{className:`flex gap-2`,children:R?(0,S.jsxs)(_,{variant:`destructive`,size:`sm`,onClick:be,children:[(0,S.jsx)(s,{className:`mr-1.5 h-4 w-4`}),` Stop`]}):(0,S.jsxs)(S.Fragment,{children:[$.length>1&&(0,S.jsxs)(_,{variant:`destructive`,size:`sm`,onClick:()=>X($),children:[(0,S.jsx)(u,{className:`mr-1.5 h-4 w-4`}),` Disable all failed (`,$.length,`)`]}),(0,S.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>D(`models`),children:[(0,S.jsx)(c,{className:`mr-1.5 h-4 w-4`}),` Test again`]})]})})]}),(0,S.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,S.jsxs)(`div`,{className:`rounded-xl border p-4`,children:[(0,S.jsx)(`div`,{className:`text-2xl font-semibold`,children:Z}),(0,S.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Completed`})]}),(0,S.jsxs)(`div`,{className:`rounded-xl border border-success/30 bg-success/5 p-4`,children:[(0,S.jsx)(`div`,{className:`text-2xl font-semibold text-success`,children:_e}),(0,S.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Working`})]}),(0,S.jsxs)(`div`,{className:`rounded-xl border border-destructive/30 bg-destructive/5 p-4`,children:[(0,S.jsx)(`div`,{className:`text-2xl font-semibold text-destructive`,children:Q}),(0,S.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Failed`})]})]}),q&&(0,S.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive`,children:q}),(0,S.jsx)(`div`,{className:`overflow-x-auto rounded-xl border`,children:(0,S.jsxs)(`table`,{className:`w-full min-w-[900px] text-left text-sm`,children:[(0,S.jsx)(`thead`,{className:`bg-muted/50 text-xs text-muted-foreground`,children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`p-3`,children:`Model`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Family / wire`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Catalog limits / cost`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Latency`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Usage`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Detail`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Actions`})]})}),(0,S.jsxs)(`tbody`,{children:[G.map(e=>(0,S.jsxs)(`tr`,{className:`border-t align-top`,children:[(0,S.jsx)(`td`,{className:`p-3 font-mono text-xs`,children:e.modelId}),(0,S.jsx)(`td`,{className:`p-3`,children:e.status===`passed`?(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-success`,children:[(0,S.jsx)(ne,{className:`h-4 w-4`}),` Working`]}):e.status===`cancelled`?(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Cancelled`}):(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive`,children:[(0,S.jsx)(ee,{className:`h-4 w-4`}),` Failed`]})}),(0,S.jsxs)(`td`,{className:`p-3 text-xs`,children:[(0,S.jsx)(`div`,{children:e.family??`—`}),(0,S.jsx)(`div`,{className:`text-muted-foreground`,children:e.wire??`—`})]}),(0,S.jsxs)(`td`,{className:`p-3 text-xs`,children:[(0,S.jsxs)(`div`,{children:[`ctx `,C(e.maxContext)]}),(0,S.jsxs)(`div`,{children:[`out `,C(e.maxOutput)]}),(e.inputCost!==void 0||e.outputCost!==void 0)&&(0,S.jsxs)(`div`,{className:`text-muted-foreground`,children:[`$`,e.inputCost??`—`,` / $`,e.outputCost??`—`]})]}),(0,S.jsxs)(`td`,{className:`p-3 tabular-nums`,children:[e.latencyMs,` ms`]}),(0,S.jsx)(`td`,{className:`p-3 text-xs tabular-nums`,children:e.usage?`in ${e.usage.input} / out ${e.usage.output}`:`—`}),(0,S.jsxs)(`td`,{className:`max-w-sm p-3 text-xs`,children:[(0,S.jsx)(`div`,{className:e.status===`failed`?`font-medium text-destructive`:``,children:e.status===`passed`?e.stopReason:fe(e.diagnosis)}),e.error&&(0,S.jsxs)(`div`,{className:`mt-1 break-words text-muted-foreground`,children:[e.httpStatus?`HTTP ${e.httpStatus} · `:``,e.error]})]}),(0,S.jsx)(`td`,{className:`p-3`,children:(0,S.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.status===`failed`&&(0,S.jsxs)(_,{variant:`outline`,size:`sm`,disabled:R||!!U,onClick:()=>xe(e.modelId),children:[U===e.modelId?(0,S.jsx)(o,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,S.jsx)(c,{className:`mr-1.5 h-3.5 w-3.5`}),`Retry`]}),e.status===`passed`?(0,S.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>Se(e.modelId),children:[(0,S.jsx)(a,{className:p(`mr-1.5 h-3.5 w-3.5`,v(k,e.modelId,T.favoriteModels)&&`fill-current text-warning`)}),v(k,e.modelId,T.favoriteModels)?`Unfavorite`:`Favorite`]}):e.status===`failed`?b(k,e.modelId,T.disabledModels)?(0,S.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>Ce(e.modelId),children:`Enable`}):(0,S.jsxs)(_,{variant:`destructive`,size:`sm`,onClick:()=>X([e]),children:[(0,S.jsx)(u,{className:`mr-1.5 h-3.5 w-3.5`}),` Disable`]}):null]})})]},e.modelId)),R&&Z<M.size&&(0,S.jsx)(`tr`,{className:`border-t`,children:(0,S.jsxs)(`td`,{colSpan:8,className:`p-4 text-center text-sm text-muted-foreground`,children:[(0,S.jsx)(o,{className:`mr-2 inline h-4 w-4 animate-spin`}),`Testing next model…`]})})]})]})})]})]})}),(0,S.jsx)(ue,{open:Y.length>0,onOpenChange:e=>!e&&X([]),children:(0,S.jsxs)(h,{children:[(0,S.jsxs)(ce,{children:[(0,S.jsx)(g,{children:Y.length>1?`Disable ${Y.length} failed models?`:`Disable this model?`}),(0,S.jsxs)(le,{children:[Y.length>0?`${Y.map(e=>`${k}/${e.modelId}`).join(`, `)} will be hidden from model pickers and removed from favorites, the explicit fallback chain, and every fallback profile.`:``,Y.some(e=>k===r&&e.modelId===t.getState().model)?` It is currently active and will remain active until you switch models.`:``]})]}),(0,S.jsxs)(m,{children:[(0,S.jsx)(_,{variant:`outline`,onClick:()=>X([]),children:`Cancel`}),(0,S.jsx)(_,{variant:`destructive`,onClick:()=>{if(Y.length===0)return;let t=new Set(Y.map(e=>e.modelId)),n=[...T.disabledModels];for(let e of t)b(k,e,n)||n.push(`${k}/${e}`);let i=e=>![...t].some(t=>w(e,k,t,r)),a={disabledModels:n,favoriteModels:T.favoriteModels.filter(i),fallbackModels:T.fallbackModels.filter(i),fallbackProfiles:Object.fromEntries(Object.entries(T.fallbackProfiles).map(([e,t])=>[e,t.filter(i)]))};T.set(a),e.updatePrefs(a),N(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n}),X([])},children:`Disable model`})]})]})})]})}export{T as ProviderTestView};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./config-store-D7yrCV2X.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Ca as i,Ct as a,Jn as o,Mi as ee,Pi as s,Qt as c,Rr as l,Ut as te,Vi as ne,ha as u,lr as re,qi as d,un as f,zt as ie}from"./vendor-BO-lHyIr.js";import{n as ae}from"./i18n-B_njdXiH.js";import{t as p}from"./utils-DQbrPaAM.js";import{o as oe,r as se}from"./view-navigation-CVnKqjL2.js";import"./stores-COxKgvNx.js";import{a as ce,i as m,n as h,o as g,r as le,t as ue}from"./dialog-CTmNJKRN.js";import{t as _}from"./button-h7DHXgna.js";import{t as de}from"./input-DAvKojvP.js";import{C as v,I as y,S as b}from"./index-CfREDCPe.js";var x=e(n(),1),S=r();function C(e){return e?Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e):`—`}function fe(e){return{authentication:`Authentication failed`,quota_exhausted:`Plan / credits exhausted`,rate_limited:`Rate limited`,model_unavailable:`Model unavailable`,context_limit:`Context limit exceeded`,token_limit:`Output-token limit rejected`,timeout:`Timed out`,network:`Network error`,overloaded:`Provider overloaded`,server_error:`Provider server error`,invalid_request:`Invalid request`,cancelled:`Cancelled`,unknown:`Unknown failure`}[e]??e}function w(e,t,n,r){let i=e.trim().toLowerCase(),a=t.trim().toLowerCase(),o=n.trim().toLowerCase();return i===`${a}/${o}`||i===`${a} ${o}`||a===r.trim().toLowerCase()&&i===o}function T(){let e=y(),n=e.client,r=t(e=>e.provider),T=ae(),[E,D]=(0,x.useState)(`provider`),[O,pe]=(0,x.useState)([]),[k,me]=(0,x.useState)(``),[A,j]=(0,x.useState)([]),[M,N]=(0,x.useState)(new Set),[P,F]=(0,x.useState)(``),[I,L]=(0,x.useState)(!1),[R,z]=(0,x.useState)(!1),[B,he]=(0,x.useState)(``),[V,H]=(0,x.useState)(``),[U,W]=(0,x.useState)(``),[G,K]=(0,x.useState)([]),[q,J]=(0,x.useState)(``),[Y,X]=(0,x.useState)([]);(0,x.useEffect)(()=>{if(!n)return;let e=n.on(`providers.saved`,e=>{e.type===`providers.saved`&&pe(e.payload.providers)}),t=n.on(`provider.models`,e=>{if(e.type!==`provider.models`||e.payload.provider!==k)return;let t=e.payload.models;j(t),N(new Set(t.filter(e=>!b(k,e.id,T.disabledModels)).map(e=>e.id))),L(!1)}),r=n.on(`provider.test.started`,e=>{e.type===`provider.test.started`&&e.payload.requestId===B&&z(!0)}),i=n.on(`provider.test.result`,e=>{e.type!==`provider.test.result`||e.payload.requestId!==B&&e.payload.requestId!==V||K(t=>{let n=t.findIndex(t=>t.modelId===e.payload.modelId);return n<0?[...t,e.payload]:t.map((t,r)=>r===n?e.payload:t)})}),a=n.on(`provider.test.complete`,e=>{e.type===`provider.test.complete`&&(e.payload.requestId===B&&(z(!1),J(e.payload.error??``)),e.payload.requestId===V&&(H(``),W(``)))});return n.send({type:`providers.saved`}),()=>{e(),t(),r(),i(),a()}},[n,T.disabledModels,k,B,V]);let ge=(0,x.useMemo)(()=>{let e=P.trim().toLowerCase();return e?A.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e)):A},[A,P]),Z=G.length,_e=G.filter(e=>e.status===`passed`).length,Q=G.filter(e=>e.status===`failed`).length,$=G.filter(e=>e.status===`failed`&&!b(k,e.modelId,T.disabledModels)),ve=()=>{k&&(L(!0),j([]),N(new Set),D(`models`),n?.send({type:`provider.models`,payload:{providerId:k,includeDisabled:!0}}))},ye=()=>{if(!n||M.size===0)return;let e=crypto.randomUUID();he(e),K([]),J(``),z(!0),D(`results`),n.send({type:`provider.test.run`,payload:{requestId:e,providerId:k,modelIds:[...M],timeoutMs:45e3,maxTokens:32}})},be=()=>{B&&n?.send({type:`provider.test.cancel`,payload:{requestId:B}})},xe=e=>{if(!n||R||U)return;let t=crypto.randomUUID();H(t),W(e),n.send({type:`provider.test.run`,payload:{requestId:t,providerId:k,modelIds:[e],timeoutMs:45e3,maxTokens:32}})},Se=t=>{let n=`${k}/${t}`,r=v(k,t,T.favoriteModels)?T.favoriteModels.filter(e=>!v(k,t,[e])):[...T.favoriteModels,n];T.set({favoriteModels:r}),e.updatePrefs({favoriteModels:r})},Ce=t=>{let n=T.disabledModels.filter(e=>!w(e,k,t,r));T.set({disabledModels:n}),e.updatePrefs({disabledModels:n})};return(0,S.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,S.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-border/70 px-4 py-3 sm:px-6`,children:[(0,S.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-primary/10 text-primary`,children:(0,S.jsx)(l,{className:`h-5 w-5`})}),(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`h1`,{className:`text-base font-semibold`,children:`Provider Test`}),(0,S.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:`Test every selected model with the saved account and its real provider adapter.`})]}),(0,S.jsxs)(_,{variant:`ghost`,size:`sm`,onClick:()=>se(`settings`),children:[(0,S.jsx)(ie,{className:`mr-1.5 h-4 w-4`}),` Settings`]}),(0,S.jsx)(_,{variant:`ghost`,size:`icon`,onClick:()=>oe(`chat`),"aria-label":`Close`,children:(0,S.jsx)(i,{className:`h-4 w-4`})})]}),(0,S.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,S.jsxs)(`div`,{className:`mx-auto max-w-7xl space-y-5 p-4 sm:p-6`,children:[(0,S.jsx)(`div`,{className:`grid grid-cols-3 gap-2 text-xs`,children:[`provider`,`models`,`results`].map((e,t)=>(0,S.jsxs)(`div`,{className:p(`rounded-lg border px-3 py-2`,E===e?`border-primary/50 bg-primary/10 text-primary`:`text-muted-foreground`),children:[t+1,`.`,` `,e===`provider`?`Account`:e===`models`?`Models`:`Results`]},e))}),E===`provider`&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Choose a provider or subscription`}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Only saved accounts are shown. Credentials remain on the server.`})]}),O.length===0?(0,S.jsx)(`div`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:`No saved provider accounts. Add one in Settings first.`}):(0,S.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:O.map(e=>{let t=e.apiKeys.find(e=>e.isActive);return(0,S.jsxs)(`button`,{type:`button`,onClick:()=>me(e.id),className:p(`rounded-xl border p-4 text-left transition-colors hover:bg-accent/50`,k===e.id&&`border-primary bg-primary/5 ring-1 ring-primary/30`),children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`font-medium`,children:e.id}),(0,S.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.type&&e.type!==e.id?`${e.type} · ${e.family??`auto`}`:e.family??e.type??`auto-detect`})]}),(0,S.jsx)(re,{className:`h-4 w-4 text-muted-foreground`})]}),(0,S.jsx)(`div`,{className:`mt-3 text-xs text-muted-foreground`,children:t?`${t.label} · ${t.maskedKey}`:`${e.apiKeys.length} saved credential(s)`})]},e.id)})}),(0,S.jsx)(`div`,{className:`flex justify-end`,children:(0,S.jsxs)(_,{disabled:!k,onClick:ve,children:[`Next `,(0,S.jsx)(d,{className:`ml-1.5 h-4 w-4`})]})})]}),E===`models`&&(0,S.jsxs)(`section`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Choose models`}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:k})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>N(new Set(A.filter(e=>!b(k,e.id,T.disabledModels)).map(e=>e.id))),children:`Select all`}),(0,S.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>N(new Set(A.map(e=>e.id))),children:`With disabled models`}),(0,S.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>N(new Set),children:`Clear`})]})]}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(te,{className:`absolute left-3 top-2.5 h-4 w-4 text-muted-foreground`}),(0,S.jsx)(de,{value:P,onChange:e=>F(e.target.value),className:`pl-9`,placeholder:`Filter models…`})]}),I?(0,S.jsx)(`div`,{className:`flex justify-center p-12`,children:(0,S.jsx)(o,{className:`h-6 w-6 animate-spin`})}):(0,S.jsx)(`div`,{className:`overflow-hidden rounded-xl border`,children:ge.map(e=>(0,S.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 border-b p-3 last:border-b-0 hover:bg-accent/40`,children:[(0,S.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-4 w-4 accent-primary`,checked:M.has(e.id),onChange:()=>N(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-mono text-sm`,children:e.id}),b(k,e.id,T.disabledModels)&&(0,S.jsx)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium text-destructive`,children:`Disabled`})]}),e.description&&(0,S.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-muted-foreground`,children:e.description})]}),(0,S.jsxs)(`div`,{className:`shrink-0 text-right text-xs text-muted-foreground`,children:[(0,S.jsxs)(`div`,{children:[`ctx `,C(e.contextWindow)]}),(0,S.jsxs)(`div`,{children:[`out `,C(e.maxOutput)]})]})]},e.id))}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(_,{variant:`ghost`,onClick:()=>D(`provider`),children:[(0,S.jsx)(i,{className:`mr-1.5 h-4 w-4`}),` Back`]}),(0,S.jsxs)(_,{disabled:M.size===0||I,onClick:ye,children:[(0,S.jsx)(f,{className:`mr-1.5 h-4 w-4`}),` Test `,M.size,` model(s)`]})]})]}),E===`results`&&(0,S.jsxs)(`section`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Test results`}),(0,S.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[k,` · `,Z,`/`,M.size,` completed`]})]}),(0,S.jsx)(`div`,{className:`flex gap-2`,children:R?(0,S.jsxs)(_,{variant:`destructive`,size:`sm`,onClick:be,children:[(0,S.jsx)(s,{className:`mr-1.5 h-4 w-4`}),` Stop`]}):(0,S.jsxs)(S.Fragment,{children:[$.length>1&&(0,S.jsxs)(_,{variant:`destructive`,size:`sm`,onClick:()=>X($),children:[(0,S.jsx)(u,{className:`mr-1.5 h-4 w-4`}),` Disable all failed (`,$.length,`)`]}),(0,S.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>D(`models`),children:[(0,S.jsx)(c,{className:`mr-1.5 h-4 w-4`}),` Test again`]})]})})]}),(0,S.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,S.jsxs)(`div`,{className:`rounded-xl border p-4`,children:[(0,S.jsx)(`div`,{className:`text-2xl font-semibold`,children:Z}),(0,S.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Completed`})]}),(0,S.jsxs)(`div`,{className:`rounded-xl border border-success/30 bg-success/5 p-4`,children:[(0,S.jsx)(`div`,{className:`text-2xl font-semibold text-success`,children:_e}),(0,S.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Working`})]}),(0,S.jsxs)(`div`,{className:`rounded-xl border border-destructive/30 bg-destructive/5 p-4`,children:[(0,S.jsx)(`div`,{className:`text-2xl font-semibold text-destructive`,children:Q}),(0,S.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Failed`})]})]}),q&&(0,S.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive`,children:q}),(0,S.jsx)(`div`,{className:`overflow-x-auto rounded-xl border`,children:(0,S.jsxs)(`table`,{className:`w-full min-w-[900px] text-left text-sm`,children:[(0,S.jsx)(`thead`,{className:`bg-muted/50 text-xs text-muted-foreground`,children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`p-3`,children:`Model`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Family / wire`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Catalog limits / cost`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Latency`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Usage`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Detail`}),(0,S.jsx)(`th`,{className:`p-3`,children:`Actions`})]})}),(0,S.jsxs)(`tbody`,{children:[G.map(e=>(0,S.jsxs)(`tr`,{className:`border-t align-top`,children:[(0,S.jsx)(`td`,{className:`p-3 font-mono text-xs`,children:e.modelId}),(0,S.jsx)(`td`,{className:`p-3`,children:e.status===`passed`?(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-success`,children:[(0,S.jsx)(ne,{className:`h-4 w-4`}),` Working`]}):e.status===`cancelled`?(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Cancelled`}):(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive`,children:[(0,S.jsx)(ee,{className:`h-4 w-4`}),` Failed`]})}),(0,S.jsxs)(`td`,{className:`p-3 text-xs`,children:[(0,S.jsx)(`div`,{children:e.family??`—`}),(0,S.jsx)(`div`,{className:`text-muted-foreground`,children:e.wire??`—`})]}),(0,S.jsxs)(`td`,{className:`p-3 text-xs`,children:[(0,S.jsxs)(`div`,{children:[`ctx `,C(e.maxContext)]}),(0,S.jsxs)(`div`,{children:[`out `,C(e.maxOutput)]}),(e.inputCost!==void 0||e.outputCost!==void 0)&&(0,S.jsxs)(`div`,{className:`text-muted-foreground`,children:[`$`,e.inputCost??`—`,` / $`,e.outputCost??`—`]})]}),(0,S.jsxs)(`td`,{className:`p-3 tabular-nums`,children:[e.latencyMs,` ms`]}),(0,S.jsx)(`td`,{className:`p-3 text-xs tabular-nums`,children:e.usage?`in ${e.usage.input} / out ${e.usage.output}`:`—`}),(0,S.jsxs)(`td`,{className:`max-w-sm p-3 text-xs`,children:[(0,S.jsx)(`div`,{className:e.status===`failed`?`font-medium text-destructive`:``,children:e.status===`passed`?e.stopReason:fe(e.diagnosis)}),e.error&&(0,S.jsxs)(`div`,{className:`mt-1 break-words text-muted-foreground`,children:[e.httpStatus?`HTTP ${e.httpStatus} · `:``,e.error]})]}),(0,S.jsx)(`td`,{className:`p-3`,children:(0,S.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.status===`failed`&&(0,S.jsxs)(_,{variant:`outline`,size:`sm`,disabled:R||!!U,onClick:()=>xe(e.modelId),children:[U===e.modelId?(0,S.jsx)(o,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,S.jsx)(c,{className:`mr-1.5 h-3.5 w-3.5`}),`Retry`]}),e.status===`passed`?(0,S.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>Se(e.modelId),children:[(0,S.jsx)(a,{className:p(`mr-1.5 h-3.5 w-3.5`,v(k,e.modelId,T.favoriteModels)&&`fill-current text-warning`)}),v(k,e.modelId,T.favoriteModels)?`Unfavorite`:`Favorite`]}):e.status===`failed`?b(k,e.modelId,T.disabledModels)?(0,S.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>Ce(e.modelId),children:`Enable`}):(0,S.jsxs)(_,{variant:`destructive`,size:`sm`,onClick:()=>X([e]),children:[(0,S.jsx)(u,{className:`mr-1.5 h-3.5 w-3.5`}),` Disable`]}):null]})})]},e.modelId)),R&&Z<M.size&&(0,S.jsx)(`tr`,{className:`border-t`,children:(0,S.jsxs)(`td`,{colSpan:8,className:`p-4 text-center text-sm text-muted-foreground`,children:[(0,S.jsx)(o,{className:`mr-2 inline h-4 w-4 animate-spin`}),`Testing next model…`]})})]})]})})]})]})}),(0,S.jsx)(ue,{open:Y.length>0,onOpenChange:e=>!e&&X([]),children:(0,S.jsxs)(h,{children:[(0,S.jsxs)(ce,{children:[(0,S.jsx)(g,{children:Y.length>1?`Disable ${Y.length} failed models?`:`Disable this model?`}),(0,S.jsxs)(le,{children:[Y.length>0?`${Y.map(e=>`${k}/${e.modelId}`).join(`, `)} will be hidden from model pickers and removed from favorites, the explicit fallback chain, and every fallback profile.`:``,Y.some(e=>k===r&&e.modelId===t.getState().model)?` It is currently active and will remain active until you switch models.`:``]})]}),(0,S.jsxs)(m,{children:[(0,S.jsx)(_,{variant:`outline`,onClick:()=>X([]),children:`Cancel`}),(0,S.jsx)(_,{variant:`destructive`,onClick:()=>{if(Y.length===0)return;let t=new Set(Y.map(e=>e.modelId)),n=[...T.disabledModels];for(let e of t)b(k,e,n)||n.push(`${k}/${e}`);let i=e=>![...t].some(t=>w(e,k,t,r)),a={disabledModels:n,favoriteModels:T.favoriteModels.filter(i),fallbackModels:T.fallbackModels.filter(i),fallbackProfiles:Object.fromEntries(Object.entries(T.fallbackProfiles).map(([e,t])=>[e,t.filter(i)]))};T.set(a),e.updatePrefs(a),N(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n}),X([])},children:`Disable model`})]})]})})]})}export{T as ProviderTestView};
|