@wrongstack/webui 0.317.2 → 0.318.0
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-xv5VajRi.js → AgentRosterView-C46rL23K.js} +1 -1
- package/dist/assets/{AnalyticsDashboard-D7D5_bvf.js → AnalyticsDashboard-B8r_8kNv.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-Cpg91ZrC.js → AudienceMemoryPanel-Ciybycpn.js} +1 -1
- package/dist/assets/{ChangesView-4CP-bLYD.js → ChangesView-BREfCsEq.js} +1 -1
- package/dist/assets/{ChimeraReviewsView-DZjw-bOC.js → ChimeraReviewsView-aSYmQ8tC.js} +1 -1
- package/dist/assets/{ChronicleDashboard-BnNxX8Hc.js → ChronicleDashboard-bo2jv52s.js} +1 -1
- package/dist/assets/{CodeEditor-FNYzhDcO.js → CodeEditor-C_KzNkIb.js} +1 -1
- package/dist/assets/{CronJobsPanel-BXqObet6.js → CronJobsPanel-D-43oYQ-.js} +1 -1
- package/dist/assets/{DebugDashboard-Hwt0OxYX.js → DebugDashboard-DNDadwro.js} +1 -1
- package/dist/assets/{DesignGalleryView-Ce2H_zeu.js → DesignGalleryView-B9ZMJPOQ.js} +1 -1
- package/dist/assets/{GoalView-DlS73sGV.js → GoalView-BkoCNN8l.js} +1 -1
- package/dist/assets/{KanbanView-Cd77gXMT.js → KanbanView-nql6LkaS.js} +1 -1
- package/dist/assets/{MailboxDetailView-B4hFbVk5.js → MailboxDetailView-CdHRfnNq.js} +1 -1
- package/dist/assets/{MemoryDrawer-CnpnSW42.js → MemoryDrawer-CfukdhlF.js} +1 -1
- package/dist/assets/{MemoryManager-DqJfeD_d.js → MemoryManager-BD_VnFAu.js} +1 -1
- package/dist/assets/{ModelPicker-R1UwpDyl.js → ModelPicker-C3r7IFfh.js} +1 -1
- package/dist/assets/{OfficeMapPanel-zAuziIkn.js → OfficeMapPanel-B47jfEHf.js} +1 -1
- package/dist/assets/{ProcessMonitor-Baj9b1_B.js → ProcessMonitor-CvHdN8Bn.js} +1 -1
- package/dist/assets/{RequirementIntakeView-B5JjTm9k.js → RequirementIntakeView-CFgVx_0T.js} +1 -1
- package/dist/assets/{SageTabs-Co-5UcaG.js → SageTabs-BRJG0fhZ.js} +2 -2
- package/dist/assets/{SddHub-DYAjEaqD.js → SddHub-Br1vyCgq.js} +1 -1
- package/dist/assets/{SessionInspectView-DVeF-pUQ.js → SessionInspectView-BSRjWErA.js} +1 -1
- package/dist/assets/{SessionList-BvVLmIsL.js → SessionList-BkaI91oW.js} +1 -1
- package/dist/assets/{SessionsDashboard-wPcCBDIK.js → SessionsDashboard-BEQs4Div.js} +1 -1
- package/dist/assets/{SetupScreen-uhBHDZqD.js → SetupScreen-zY4541lT.js} +1 -1
- package/dist/assets/{SkillDetailView-DPqT3npD.js → SkillDetailView-DqxkOnb8.js} +1 -1
- package/dist/assets/{SpecsView-BEITfh6o.js → SpecsView-COS0-sxq.js} +1 -1
- package/dist/assets/{TechStackView-DLEi7aSX.js → TechStackView-Dr8vI0hK.js} +1 -1
- package/dist/assets/{index-b_i-YcNT.js → index-DbprKWmG.js} +5 -5
- package/dist/assets/{useWebSocket-B4er0zlV.js → useWebSocket-VIItbvVK.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/index.js +3 -1
- package/dist/stores/file-store.d.ts +9 -0
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./ws-client-D-d32pHb.js";import{$t as n,Kr as r,Oi as i,Ut as a,Vr as o,Wi as s,da as c,ft as ee,gn as te,kt as l,mi as u,oo as d,qa as f,sn as ne,to as p,ut as m,vr as h,wa as g,xa as _,xn as re}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{t as v}from"./utils-DQ9Exx8j.js";import{b as ie,x as ae}from"./index-b_i-YcNT.js";var y=e(d(),1),b=m();function oe({status:e}){let{t}=p();return(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-primary/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,title:e.chronicleDirectory,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:t(`activity:chroniclePipelineStrip.chronicleOwnership`)}),(0,b.jsxs)(`span`,{children:[`collect `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,b.jsxs)(`span`,{children:[`process `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,b.jsxs)(`span`,{children:[`serve `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,b.jsxs)(`span`,{children:[`PID `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,b.jsxs)(`span`,{children:[`watcher`,` `,(0,b.jsx)(`b`,{className:v(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,b.jsxs)(`span`,{children:[`store `,(0,b.jsx)(`b`,{className:`text-foreground`,children:x(e.pipeline.storage)})]}),e.mode===`inline`&&(0,b.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:t(`activity:chroniclePipelineStrip.inlineFallback`)})]})}function x(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var S=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],C=864e5;function w(){return{limit:300,order:`desc`,from:new Date(Date.now()-C).toISOString()}}var se=[{id:`all`,labelKey:`activity:chronicle.signalAllSignals`,icon:(0,b.jsx)(f,{})},{id:`llm`,labelKey:`activity:chronicle.signalLlm`,icon:(0,b.jsx)(_,{})},{id:`agents`,labelKey:`activity:chronicle.signalAgents`,icon:(0,b.jsx)(g,{})},{id:`tools`,labelKey:`activity:chronicle.signalTools`,icon:(0,b.jsx)(a,{})},{id:`files`,labelKey:`activity:chronicle.signalFiles`,icon:(0,b.jsx)(u,{})},{id:`failures`,labelKey:`activity:chronicle.signalFailures`,icon:(0,b.jsx)(l,{})}];function T(){let{t:e}=p(),n=t(),[i,o]=(0,y.useState)([]),[c,l]=(0,y.useState)(null),[d,f]=(0,y.useState)({}),[m,x]=(0,y.useState)(w()),[C,T]=(0,y.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[E,O]=(0,y.useState)(`all`),[N,F]=(0,y.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,pe]=(0,y.useState)(D),[L,R]=(0,y.useState)(!0),[z,B]=(0,y.useState)(null),[me,V]=(0,y.useState)(null),[H,he]=(0,y.useState)([]),[U,ge]=(0,y.useState)([]),[W,_e]=(0,y.useState)(null),G=(0,y.useRef)(m);G.current=m;let K=(0,y.useCallback)(e=>{if(!n.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),x(e),f({}),n.send({type:`chronicle.query`,payload:{query:e}}),n.supportsCapability(`chronicle.facets`))n.send({type:`chronicle.facets`,payload:{fields:[...S],query:e,limit:12}});else for(let t of S)n.send({type:`chronicle.facet`,payload:{field:t,query:e,limit:12}})},[n]),q=(0,y.useCallback)(()=>{n.supportsCapability(`chronicle.metrics`)&&(n.send({type:`chronicle.metrics`,payload:{view:`providers`}}),n.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[n]),J=(0,y.useCallback)(()=>{n.supportsCapability(`chronicle.status`)&&n.send({type:`chronicle.status`})},[n]);(0,y.useEffect)(()=>{let e=n.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(o(e.payload.events),F(e.payload),pe(e.payload.summary??D),R(!1))}),t=n.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&f(t=>({...t,[e.payload.field]:e.payload.values}))}),r=n.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&f(e.payload.values)}),i=n.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),a=n.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&V(e.payload)}),s=n.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?he(e.payload.data):e.payload.view===`tasks`&&ge(e.payload.data))}),c=n.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&_e(e.payload)});return K(G.current),q(),J(),()=>{e(),t(),r(),i(),a(),s(),c()}},[n,K,q,J]);let Y=(0,y.useMemo)(()=>i.filter(e=>ue(e,E)),[i,E]),X=ae(Y,25,E),Z=(0,y.useMemo)(()=>{let e=i.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let t=t=>e[t]?.last;return{eventLoop:{utilization:t(`eventLoop.utilization`),delayP95Ms:t(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:t(`memory.heapUsedBytes`)},chronicle:{pendingEvents:t(`chronicle.pendingEvents`),rejectedEvents:t(`chronicle.rejectedEvents`)}}},[i]),Q=(0,y.useMemo)(()=>{let e={};for(let t of U)e[t.status]=(e[t.status]??0)+1;let t=(e.completed??0)+(e.merged??0)+(e.failed??0)+(e.conflict??0),n=(e.completed??0)+(e.merged??0),r=[...U].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:U.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[U]),$=()=>K({...w(),...C.text?{text:C.text}:{},...C.path?{path:C.path}:{},...C.providerId?{providerId:C.providerId}:{},...C.modelId?{modelId:C.modelId}:{},...C.sessionId?{sessionId:C.sessionId}:{}}),ve=()=>{T({text:``,path:``,providerId:``,modelId:``,sessionId:``}),O(`all`),K(w())},ye=e=>{l(e),V(null),n.supportsCapability(`chronicle.graph`)&&n.send({type:`chronicle.graph`,payload:{seed:{eventId:e.eventId},hops:2,maxNodes:250}})};return(0,b.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,b.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,b.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(_,{className:`h-5 w-5 text-primary`}),(0,b.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e(`activity:chronicle.codingIntelligence`)}),(0,b.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:e(`activity:chronicle.chronicle`)})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:chronicle.llmAgentToolAndFileEvidence`)})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,b.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{K(m),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:e(`activity:chronicle.refreshEvidence`),children:(0,b.jsx)(re,{className:v(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,b.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,b.jsx)(j,{icon:(0,b.jsx)(_,{}),label:e(`activity:chronicle.llmRequests`),value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,b.jsx)(j,{icon:(0,b.jsx)(g,{}),label:e(`activity:chronicle.agentWork`),value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,b.jsx)(j,{icon:(0,b.jsx)(a,{}),label:e(`activity:chronicle.toolCalls`),value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,b.jsx)(j,{icon:(0,b.jsx)(u,{}),label:e(`activity:chronicle.fileEvidence`),value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,b.jsx)(j,{icon:(0,b.jsx)(te,{}),label:e(`activity:chronicle.retries`),value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,b.jsx)(j,{icon:(0,b.jsx)(s,{}),label:e(`activity:chronicle.providerP95`),value:k(I.providerP95DurationMs),detail:`${k(I.providerAvgDurationMs)} average · all matches`})]}),(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:e(`activity:chronicle.tokenEconomics`)}),(0,b.jsxs)(`span`,{children:[e(`activity:chronicle.freshInput`),` `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`output `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[e(`activity:chronicle.cacheRead`),` `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`cache write`,` `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[e(`activity:chronicle.cacheHit`),` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[le(I).toFixed(1),`%`]})]}),(0,b.jsxs)(`span`,{children:[e(`activity:chronicle.estimatedCost`),` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),H.length>0&&(0,b.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.14] px-4 py-1.5`,children:[(0,b.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:chronicle.modelReliability`)}),H.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${e.day} · ${e.attempts} attempts · avg ${k(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,b.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,b.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,b.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.10] px-4 py-1.5`,children:[(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(h,{className:`h-3 w-3`}),e(`activity:chronicle.taskOutcomes`)]}),(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${Q.total} tasks tracked · ${Q.terminal} finished`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,b.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,b.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,b.jsx)(`b`,{className:v(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,b.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>K({limit:300,order:`desc`,taskId:e.taskId}),className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-[9px] hover:border-primary/50`,title:`${e.taskId}${e.boardId?` · board ${e.boardId}`:``}${e.sessionId?` · ${e.sessionId}`:``} · ${e.filesTouched} files${e.retries?` · ${e.retries} retries`:``}${e.verificationFailures?` · ${e.verificationFailures} verify-fails`:``}`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,e.status===`completed`||e.status===`merged`?`bg-success`:e.status===`failed`||e.status===`conflict`?`bg-destructive`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:k(e.durationMs)}),e.filesTouched>0&&(0,b.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,b.jsx)(u,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,b.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,b.jsx)(A,{icon:(0,b.jsx)(ne,{}),placeholder:e(`activity:chronicle.searchEventEvidence`),value:C.text,onChange:e=>T(t=>({...t,text:e})),onEnter:$}),(0,b.jsx)(A,{placeholder:e(`activity:chronicle.fileOrDirectory`),value:C.path,onChange:e=>T(t=>({...t,path:e})),onEnter:$}),(0,b.jsx)(A,{placeholder:e(`activity:chronicle.provider`),value:C.providerId,onChange:e=>T(t=>({...t,providerId:e})),onEnter:$}),(0,b.jsx)(A,{placeholder:e(`activity:chronicle.model`),value:C.modelId,onChange:e=>T(t=>({...t,modelId:e})),onEnter:$}),(0,b.jsx)(A,{placeholder:e(`activity:chronicle.session`),value:C.sessionId,onChange:e=>T(t=>({...t,sessionId:e})),onEnter:$}),(0,b.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,b.jsx)(r,{className:`mr-1 inline h-3 w-3`}),e(`activity:chronicle.apply`)]}),(0,b.jsx)(`button`,{type:`button`,onClick:ve,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:e(`activity:chronicle.clear`)})]})]})}),(0,b.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[se.map(t=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>O(t.id),className:v(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,E===t.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[t.icon,e(t.labelKey),(0,b.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:ce(I,t.id,N.total)})]},t.id)),(0,b.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,b.jsxs)(`span`,{children:[N.total.toLocaleString(),` matched`]}),(0,b.jsxs)(`span`,{children:[N.sourceFiles,` journal files`]}),N.invalidLines>0&&(0,b.jsxs)(`span`,{className:`text-warning`,children:[N.invalidLines,` invalid lines`]})]})]}),W&&(0,b.jsx)(oe,{status:W}),Z&&(0,b.jsx)(M,{health:Z}),(0,b.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,b.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,b.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(d[e]??[]).slice(0,4).map(t=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>K({...m,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,b.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(`span`,{children:e(`activity:chronicle.time`)}),(0,b.jsx)(`span`,{children:e(`activity:chronicle.signal`)}),(0,b.jsx)(`span`,{children:e(`activity:chronicle.outcome`)}),(0,b.jsx)(`span`,{children:e(`activity:chronicle.modelAgent`)}),(0,b.jsx)(`span`,{children:e(`activity:chronicle.resource`)}),(0,b.jsx)(`span`,{})]}),(0,b.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,b.jsx)(P,{text:z}):!L&&Y.length===0?(0,b.jsx)(P,{text:`No coding evidence matches these filters.`}):(0,b.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,b.jsx)(de,{event:e,active:c?.eventId===e.eventId,onClick:()=>ye(e)},e.eventId))})}),(0,b.jsx)(ie,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),c&&(0,b.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,b.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-xs font-semibold`,children:e(`activity:chronicle.evidenceLineage`)}),(0,b.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,c.sequence,` · `,c.eventId]})]}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded p-1 hover:bg-muted`,children:(0,b.jsx)(ee,{className:`h-4 w-4`})})]}),(0,b.jsx)(fe,{event:c,graph:me})]})]})}var E={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},D={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...E},failuresByFamily:{...E}};function ce(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function le(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function ue(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function O(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function k(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function A({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,b.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,b.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,b.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function j({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,b.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,b.jsx)(`div`,{className:v(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,b.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function M({health:e}){let{t}=p();return(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:t(`activity:chronicle.collectorHealthy`)}),(0,b.jsxs)(`span`,{children:[`ELU`,` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`span`,{children:[`p95 `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,b.jsxs)(`span`,{children:[`heap`,` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,b.jsxs)(`span`,{children:[`queue `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,b.jsxs)(`span`,{children:[`dropped`,` `,(0,b.jsx)(`b`,{className:v((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function de({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,b.jsxs)(`button`,{type:`button`,onClick:n,className:v(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,b.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,b.jsx)(`span`,{className:v(`w-fit rounded px-1.5 py-0.5 text-[9px]`,F(e.outcome)),children:e.outcome??`unknown`}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,b.jsx)(c,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function fe({event:e,graph:t}){let{t:r}=p(),a=(0,y.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,b.jsxs)(`div`,{className:`p-4`,children:[(0,b.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,b.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,b.jsx)(`span`,{children:O(Number(e.durationNs??0))})]})]}),(0,b.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,b.jsx)(N,{icon:(0,b.jsx)(n,{}),label:r(`activity:chronicle.evidenceHash`),value:e.hash.slice(0,16)}),(0,b.jsx)(N,{icon:(0,b.jsx)(i,{}),label:r(`activity:chronicle.sequence`),value:String(e.sequence)})]}),t&&(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(o,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,b.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,b.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,b.jsx)(`span`,{className:v(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,b.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,b.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:r(`activity:chronicle.lineageTruncatedAtSafetyLimit`)})]}),a.map(([e,t])=>t&&(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,b.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function N({icon:e,label:t,value:n}){return(0,b.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,b.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function P({text:e}){return(0,b.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function F(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{T as ChronicleDashboard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./ws-client-D-d32pHb.js";import{$t as n,Kr as r,Oi as i,Ut as a,Vr as o,Wi as s,da as c,ft as ee,gn as te,kt as l,mi as u,oo as d,qa as f,sn as ne,to as p,ut as m,vr as h,wa as g,xa as _,xn as re}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{t as v}from"./utils-DQ9Exx8j.js";import{b as ie,x as ae}from"./index-DbprKWmG.js";var y=e(d(),1),b=m();function oe({status:e}){let{t}=p();return(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-primary/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,title:e.chronicleDirectory,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:t(`activity:chroniclePipelineStrip.chronicleOwnership`)}),(0,b.jsxs)(`span`,{children:[`collect `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,b.jsxs)(`span`,{children:[`process `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,b.jsxs)(`span`,{children:[`serve `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,b.jsxs)(`span`,{children:[`PID `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,b.jsxs)(`span`,{children:[`watcher`,` `,(0,b.jsx)(`b`,{className:v(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,b.jsxs)(`span`,{children:[`store `,(0,b.jsx)(`b`,{className:`text-foreground`,children:x(e.pipeline.storage)})]}),e.mode===`inline`&&(0,b.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:t(`activity:chroniclePipelineStrip.inlineFallback`)})]})}function x(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var S=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],C=864e5;function w(){return{limit:300,order:`desc`,from:new Date(Date.now()-C).toISOString()}}var se=[{id:`all`,labelKey:`activity:chronicle.signalAllSignals`,icon:(0,b.jsx)(f,{})},{id:`llm`,labelKey:`activity:chronicle.signalLlm`,icon:(0,b.jsx)(_,{})},{id:`agents`,labelKey:`activity:chronicle.signalAgents`,icon:(0,b.jsx)(g,{})},{id:`tools`,labelKey:`activity:chronicle.signalTools`,icon:(0,b.jsx)(a,{})},{id:`files`,labelKey:`activity:chronicle.signalFiles`,icon:(0,b.jsx)(u,{})},{id:`failures`,labelKey:`activity:chronicle.signalFailures`,icon:(0,b.jsx)(l,{})}];function T(){let{t:e}=p(),n=t(),[i,o]=(0,y.useState)([]),[c,l]=(0,y.useState)(null),[d,f]=(0,y.useState)({}),[m,x]=(0,y.useState)(w()),[C,T]=(0,y.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[E,O]=(0,y.useState)(`all`),[N,F]=(0,y.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,pe]=(0,y.useState)(D),[L,R]=(0,y.useState)(!0),[z,B]=(0,y.useState)(null),[me,V]=(0,y.useState)(null),[H,he]=(0,y.useState)([]),[U,ge]=(0,y.useState)([]),[W,_e]=(0,y.useState)(null),G=(0,y.useRef)(m);G.current=m;let K=(0,y.useCallback)(e=>{if(!n.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),x(e),f({}),n.send({type:`chronicle.query`,payload:{query:e}}),n.supportsCapability(`chronicle.facets`))n.send({type:`chronicle.facets`,payload:{fields:[...S],query:e,limit:12}});else for(let t of S)n.send({type:`chronicle.facet`,payload:{field:t,query:e,limit:12}})},[n]),q=(0,y.useCallback)(()=>{n.supportsCapability(`chronicle.metrics`)&&(n.send({type:`chronicle.metrics`,payload:{view:`providers`}}),n.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[n]),J=(0,y.useCallback)(()=>{n.supportsCapability(`chronicle.status`)&&n.send({type:`chronicle.status`})},[n]);(0,y.useEffect)(()=>{let e=n.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(o(e.payload.events),F(e.payload),pe(e.payload.summary??D),R(!1))}),t=n.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&f(t=>({...t,[e.payload.field]:e.payload.values}))}),r=n.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&f(e.payload.values)}),i=n.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),a=n.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&V(e.payload)}),s=n.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?he(e.payload.data):e.payload.view===`tasks`&&ge(e.payload.data))}),c=n.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&_e(e.payload)});return K(G.current),q(),J(),()=>{e(),t(),r(),i(),a(),s(),c()}},[n,K,q,J]);let Y=(0,y.useMemo)(()=>i.filter(e=>ue(e,E)),[i,E]),X=ae(Y,25,E),Z=(0,y.useMemo)(()=>{let e=i.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let t=t=>e[t]?.last;return{eventLoop:{utilization:t(`eventLoop.utilization`),delayP95Ms:t(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:t(`memory.heapUsedBytes`)},chronicle:{pendingEvents:t(`chronicle.pendingEvents`),rejectedEvents:t(`chronicle.rejectedEvents`)}}},[i]),Q=(0,y.useMemo)(()=>{let e={};for(let t of U)e[t.status]=(e[t.status]??0)+1;let t=(e.completed??0)+(e.merged??0)+(e.failed??0)+(e.conflict??0),n=(e.completed??0)+(e.merged??0),r=[...U].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:U.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[U]),$=()=>K({...w(),...C.text?{text:C.text}:{},...C.path?{path:C.path}:{},...C.providerId?{providerId:C.providerId}:{},...C.modelId?{modelId:C.modelId}:{},...C.sessionId?{sessionId:C.sessionId}:{}}),ve=()=>{T({text:``,path:``,providerId:``,modelId:``,sessionId:``}),O(`all`),K(w())},ye=e=>{l(e),V(null),n.supportsCapability(`chronicle.graph`)&&n.send({type:`chronicle.graph`,payload:{seed:{eventId:e.eventId},hops:2,maxNodes:250}})};return(0,b.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,b.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,b.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(_,{className:`h-5 w-5 text-primary`}),(0,b.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e(`activity:chronicle.codingIntelligence`)}),(0,b.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:e(`activity:chronicle.chronicle`)})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:chronicle.llmAgentToolAndFileEvidence`)})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,b.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{K(m),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:e(`activity:chronicle.refreshEvidence`),children:(0,b.jsx)(re,{className:v(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,b.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,b.jsx)(j,{icon:(0,b.jsx)(_,{}),label:e(`activity:chronicle.llmRequests`),value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,b.jsx)(j,{icon:(0,b.jsx)(g,{}),label:e(`activity:chronicle.agentWork`),value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,b.jsx)(j,{icon:(0,b.jsx)(a,{}),label:e(`activity:chronicle.toolCalls`),value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,b.jsx)(j,{icon:(0,b.jsx)(u,{}),label:e(`activity:chronicle.fileEvidence`),value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,b.jsx)(j,{icon:(0,b.jsx)(te,{}),label:e(`activity:chronicle.retries`),value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,b.jsx)(j,{icon:(0,b.jsx)(s,{}),label:e(`activity:chronicle.providerP95`),value:k(I.providerP95DurationMs),detail:`${k(I.providerAvgDurationMs)} average · all matches`})]}),(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:e(`activity:chronicle.tokenEconomics`)}),(0,b.jsxs)(`span`,{children:[e(`activity:chronicle.freshInput`),` `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`output `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[e(`activity:chronicle.cacheRead`),` `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`cache write`,` `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[e(`activity:chronicle.cacheHit`),` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[le(I).toFixed(1),`%`]})]}),(0,b.jsxs)(`span`,{children:[e(`activity:chronicle.estimatedCost`),` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),H.length>0&&(0,b.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.14] px-4 py-1.5`,children:[(0,b.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:chronicle.modelReliability`)}),H.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${e.day} · ${e.attempts} attempts · avg ${k(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,b.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,b.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,b.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.10] px-4 py-1.5`,children:[(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(h,{className:`h-3 w-3`}),e(`activity:chronicle.taskOutcomes`)]}),(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${Q.total} tasks tracked · ${Q.terminal} finished`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,b.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,b.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,b.jsx)(`b`,{className:v(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,b.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>K({limit:300,order:`desc`,taskId:e.taskId}),className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-[9px] hover:border-primary/50`,title:`${e.taskId}${e.boardId?` · board ${e.boardId}`:``}${e.sessionId?` · ${e.sessionId}`:``} · ${e.filesTouched} files${e.retries?` · ${e.retries} retries`:``}${e.verificationFailures?` · ${e.verificationFailures} verify-fails`:``}`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,e.status===`completed`||e.status===`merged`?`bg-success`:e.status===`failed`||e.status===`conflict`?`bg-destructive`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:k(e.durationMs)}),e.filesTouched>0&&(0,b.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,b.jsx)(u,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,b.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,b.jsx)(A,{icon:(0,b.jsx)(ne,{}),placeholder:e(`activity:chronicle.searchEventEvidence`),value:C.text,onChange:e=>T(t=>({...t,text:e})),onEnter:$}),(0,b.jsx)(A,{placeholder:e(`activity:chronicle.fileOrDirectory`),value:C.path,onChange:e=>T(t=>({...t,path:e})),onEnter:$}),(0,b.jsx)(A,{placeholder:e(`activity:chronicle.provider`),value:C.providerId,onChange:e=>T(t=>({...t,providerId:e})),onEnter:$}),(0,b.jsx)(A,{placeholder:e(`activity:chronicle.model`),value:C.modelId,onChange:e=>T(t=>({...t,modelId:e})),onEnter:$}),(0,b.jsx)(A,{placeholder:e(`activity:chronicle.session`),value:C.sessionId,onChange:e=>T(t=>({...t,sessionId:e})),onEnter:$}),(0,b.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,b.jsx)(r,{className:`mr-1 inline h-3 w-3`}),e(`activity:chronicle.apply`)]}),(0,b.jsx)(`button`,{type:`button`,onClick:ve,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:e(`activity:chronicle.clear`)})]})]})}),(0,b.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[se.map(t=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>O(t.id),className:v(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,E===t.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[t.icon,e(t.labelKey),(0,b.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:ce(I,t.id,N.total)})]},t.id)),(0,b.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,b.jsxs)(`span`,{children:[N.total.toLocaleString(),` matched`]}),(0,b.jsxs)(`span`,{children:[N.sourceFiles,` journal files`]}),N.invalidLines>0&&(0,b.jsxs)(`span`,{className:`text-warning`,children:[N.invalidLines,` invalid lines`]})]})]}),W&&(0,b.jsx)(oe,{status:W}),Z&&(0,b.jsx)(M,{health:Z}),(0,b.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,b.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,b.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(d[e]??[]).slice(0,4).map(t=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>K({...m,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,b.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(`span`,{children:e(`activity:chronicle.time`)}),(0,b.jsx)(`span`,{children:e(`activity:chronicle.signal`)}),(0,b.jsx)(`span`,{children:e(`activity:chronicle.outcome`)}),(0,b.jsx)(`span`,{children:e(`activity:chronicle.modelAgent`)}),(0,b.jsx)(`span`,{children:e(`activity:chronicle.resource`)}),(0,b.jsx)(`span`,{})]}),(0,b.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,b.jsx)(P,{text:z}):!L&&Y.length===0?(0,b.jsx)(P,{text:`No coding evidence matches these filters.`}):(0,b.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,b.jsx)(de,{event:e,active:c?.eventId===e.eventId,onClick:()=>ye(e)},e.eventId))})}),(0,b.jsx)(ie,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),c&&(0,b.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,b.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-xs font-semibold`,children:e(`activity:chronicle.evidenceLineage`)}),(0,b.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,c.sequence,` · `,c.eventId]})]}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded p-1 hover:bg-muted`,children:(0,b.jsx)(ee,{className:`h-4 w-4`})})]}),(0,b.jsx)(fe,{event:c,graph:me})]})]})}var E={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},D={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...E},failuresByFamily:{...E}};function ce(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function le(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function ue(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function O(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function k(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function A({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,b.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,b.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,b.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function j({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,b.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,b.jsx)(`div`,{className:v(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,b.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function M({health:e}){let{t}=p();return(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:t(`activity:chronicle.collectorHealthy`)}),(0,b.jsxs)(`span`,{children:[`ELU`,` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`span`,{children:[`p95 `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,b.jsxs)(`span`,{children:[`heap`,` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,b.jsxs)(`span`,{children:[`queue `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,b.jsxs)(`span`,{children:[`dropped`,` `,(0,b.jsx)(`b`,{className:v((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function de({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,b.jsxs)(`button`,{type:`button`,onClick:n,className:v(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,b.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,b.jsx)(`span`,{className:v(`w-fit rounded px-1.5 py-0.5 text-[9px]`,F(e.outcome)),children:e.outcome??`unknown`}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,b.jsx)(c,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function fe({event:e,graph:t}){let{t:r}=p(),a=(0,y.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,b.jsxs)(`div`,{className:`p-4`,children:[(0,b.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,b.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,b.jsx)(`span`,{children:O(Number(e.durationNs??0))})]})]}),(0,b.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,b.jsx)(N,{icon:(0,b.jsx)(n,{}),label:r(`activity:chronicle.evidenceHash`),value:e.hash.slice(0,16)}),(0,b.jsx)(N,{icon:(0,b.jsx)(i,{}),label:r(`activity:chronicle.sequence`),value:String(e.sequence)})]}),t&&(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(o,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,b.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,b.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,b.jsx)(`span`,{className:v(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,b.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,b.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:r(`activity:chronicle.lineageTruncatedAtSafetyLimit`)})]}),a.map(([e,t])=>t&&(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,b.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function N({icon:e,label:t,value:n}){return(0,b.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,b.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function P({text:e}){return(0,b.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function F(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{T as ChronicleDashboard};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Q as n,t as r}from"./ws-client-D-d32pHb.js";import{Ji as i,Ni as a,Pt as o,Ut as s,Vr as c,ar as l,bt as u,en as d,fa as f,fi as p,fr as m,ft as h,gi as g,hi as _,ii as v,la as y,on as b,oo as x,pa as S,pr as C,qa as ee,r as w,ra as T,to as E,ut as D,wa as O,xa as k,xn as A}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{a as j,i as M,n as N,o as P,r as te,t as F}from"./monaco-BCqJp2xW.js";import{t as I}from"./utils-DQ9Exx8j.js";import{i as L}from"./codemap-activity-store-Br4b57a0.js";import{d as R,g as z,o as ne,v as B}from"./stores-CNuMLG8X.js";import{o as V}from"./view-navigation-DPOY0lyt.js";import{O as re,_ as ie,k as H}from"./index-b_i-YcNT.js";import{t as U}from"./empty-state-DBQN80mK.js";import{t as W}from"./monaco-theme-CR1QvFi2.js";import{t as ae}from"./MemoryDrawer-CnpnSW42.js";var G={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,css:`css`,html:`html`,svg:`xml`,md:`markdown`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sh:`shell`,bash:`shell`,ps1:`powershell`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sql:`sql`,xml:`xml`},K=Array.from(new Set(Object.values(G))).filter(e=>e!==`plaintext`),q=12e3,J=4e3,oe=5e3,se=1e4;function ce(e){return G[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function le(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function ue(e,t){return e.triggerCharacter?!0:t.length>=3}function de(e,t){return e.triggerCharacter===`.`||!e.triggerCharacter&&/^(findBy|findAllBy|create|update|delete|remove|get[A-Z_]|set[A-Z_]|use[A-Z_])/.test(t)}function fe(e){return[e.filePath,e.language,e.lineNumber,e.column,e.versionId??``,e.triggerCharacter??``,e.linePrefix.slice(-160),e.suffix.slice(0,160)].join(`\0`)}var Y=e(x(),1),X=D();function pe(e){let t=new Set,n=new Set,r=new Set,i=new Set,a=new Set,o,s;for(let c of e)c.sessionId&&t.add(c.sessionId),c.taskId&&n.add(c.taskId),c.boardId&&r.add(c.boardId),c.toolName&&i.add(c.toolName),c.modelId&&a.add(c.modelId),(!o||c.occurredAt<o)&&(o=c.occurredAt),(!s||c.occurredAt>s)&&(s=c.occurredAt);return{mutations:e.length,sessions:t.size,tasks:n.size,boards:r.size,tools:[...i],models:[...a],firstAt:o,lastAt:s}}var me=150,he=224,ge=38,_e=/(write|edit|update|create|delete|rename|modified|changed)/i;function ve(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Z(e,t){let n=ve(e),r=ve(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ye(e,t=Date.now()){let n=e.filter(e=>t-e.at<=18e5),r=n.filter(e=>_e.test(e.action)),i=new Set(n.map(e=>e.sessionId).filter(Boolean)).size,a=new Set(n.map(e=>e.actor).filter(Boolean)).size,o=new Set(n.map(e=>e.taskId).filter(Boolean)).size;return{level:r.length>=8||r.length>=4&&a>=3?`churn`:r.length>0?`active`:`quiet`,mutationCount:r.length,sessionCount:i,actorCount:a,taskCount:o}}function Q(e){return typeof e==`string`&&e.length>0?e:void 0}function be(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function xe(e){let t=e.attributes??{},n=Q(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:be(e),action:n,actor:r??i??Q(t.actor)??`external`,source:Q(t.source)??e.tags?.collector??`chronicle`,summary:[e.eventType,i&&a?`${i}/${a}`:i,e.outcome].filter(Boolean).join(` · `),sessionId:e.scope.sessionId,agentId:r,taskId:e.scope.taskId??Q(t.taskId),boardId:Q(t.boardId)??e.scope.boardId,tool:Q(t.toolName),status:e.outcome,raw:e}}function Se(e){return{id:e.id??`${e.filePath}:${e.timestamp}:${e.type}`,at:e.timestamp,action:e.type,actor:e.agentName??e.agent??e.agentId??`external`,source:e.source??`live`,summary:e.summary,sessionId:e.sessionId,agentId:e.agentId,tool:e.toolName,status:e.status,raw:e}}function Ce(e){let t=new Set;return e.sort((e,t)=>t.at-e.at).filter(e=>{let n=`${e.id}:${e.at}`;return!t.has(n)&&(t.add(n),!0)})}function we(e){return e?e.split(/\r?\n/).length:0}function Te(e){return new TextEncoder().encode(e).length}function Ee(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function De(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function Oe(e,t){let n=H(e,t);return n?{added:n.filter(e=>e.kind===`add`).length,removed:n.filter(e=>e.kind===`del`).length,large:!1}:{added:0,removed:0,large:!0}}function ke({file:e}){let{t:n}=E(),[i,a]=(0,Y.useState)(!0),[o,l]=(0,Y.useState)(he),[u,d]=(0,Y.useState)(`overview`),[m,h]=(0,Y.useState)([]),[v,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(!1),[w,D]=(0,Y.useState)(null),[O,j]=(0,Y.useState)(null),M=(0,Y.useRef)(null),N=t(e=>e.wsUrl),P=L(e=>e.history),te=L(e=>e.activeOperations),F=R(e=>e.activeBoard),z=ne(e=>e.snapshot),B=(0,Y.useMemo)(()=>r(N),[N]),V=(0,Y.useCallback)(()=>{D(null),S(!0),typeof B.getGitDiff==`function`&&B.getGitDiff(e.path);let t=typeof B.supportsCapability==`function`?B.supportsCapability.bind(B):null;t?.(`chronicle.query`)?B.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):S(!1),t?.(`chronicle.metrics`)&&B.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[B,e.path]);(0,Y.useEffect)(()=>{h([]),b([]),j(null);let t=B.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Z(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(h(n),S(!1))}),n=B.on(`chronicle.metrics_result`,t=>{t.type===`chronicle.metrics_result`&&t.payload.view===`files`&&b(t.payload.data.filter(t=>Z(t.path,e.path)))}),r=B.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(D(e.payload.message),S(!1))}),i=B.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Z(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){j({text:e.savedContent,available:!1,error:n.error});return}j({text:n.oldText??``,available:!0})});return V(),()=>{t(),n(),r(),i()}},[B,e.path,e.savedContent,V]),(0,Y.useEffect)(()=>{let e=e=>{if(!M.current)return;let t=M.current.startY-e.clientY,n=Math.max(me,Math.floor(window.innerHeight*.62));l(Math.min(n,Math.max(me,M.current.startHeight+t)))},t=()=>{M.current=null,document.body.style.cursor=``,document.body.style.userSelect=``};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]);let ie=(0,Y.useMemo)(()=>{let t=[];for(let[n,r]of P)Z(n,e.path)&&t.push(...r);for(let n of te.values())t.push(...n.filter(t=>Z(t.filePath,e.path)));return t},[te,e.path,P]),H=(0,Y.useMemo)(()=>Ce([...ie.map(Se),...m.map(xe)]),[m,ie]),U=(0,Y.useMemo)(()=>ye(H),[H]),W=(0,Y.useMemo)(()=>pe(v),[v]),G=O?.text??e.savedContent,K=(0,Y.useMemo)(()=>Oe(G,e.content),[G,e.content]),q=(0,Y.useMemo)(()=>[...new Set(H.map(e=>e.sessionId).filter(e=>!!e))],[H]),J=(0,Y.useMemo)(()=>[...new Set(H.map(e=>e.actor).filter(Boolean))],[H]),oe=(0,Y.useMemo)(()=>[...new Set(H.map(e=>e.taskId).filter(e=>!!e))],[H]),se=(0,Y.useCallback)(e=>{let t=F?.tasks.find(t=>t.id===e),n=z?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[F,z]),ce=e=>{i||a(!0),M.current={startY:e.clientY,startHeight:i?o:me},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},le=[{id:`overview`,label:n(`activity:fileActivity.overview`),icon:(0,X.jsx)(ee,{})},{id:`changes`,label:n(`activity:fileActivity.changes`),icon:(0,X.jsx)(p,{})},{id:`skeleton`,label:`Skeleton`,icon:(0,X.jsx)(_,{})},{id:`context`,label:n(`activity:fileActivity.context`),icon:(0,X.jsx)(C,{})},{id:`logs`,label:n(`activity:fileActivity.logs`),icon:(0,X.jsx)(s,{})},{id:`memory`,label:n(`activity:fileActivity.memory`),icon:(0,X.jsx)(k,{})}];return(0,X.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:i?o:ge},"data-testid":`file-activity-drawer`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":n(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:ce,onDoubleClick:()=>{a(!0),l(he)},title:n(`activity:fileActivity.resizeHint`),children:(0,X.jsx)(`span`,{className:`absolute left-1/2 top-0.5 h-1 w-10 -translate-x-1/2 rounded-full bg-border transition-colors group-hover:bg-primary/60`})}),(0,X.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":i,children:[(0,X.jsx)(g,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,X.jsx)(`span`,{className:`truncate`,children:n(`activity:fileActivity.title`)}),i?(0,X.jsx)(f,{className:`h-3 w-3`}):(0,X.jsx)(y,{className:`h-3 w-3`})]}),(0,X.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,X.jsx)(Ae,{label:`${we(e.content)} ${n(`activity:fileActivity.lines`)}`}),(0,X.jsx)(Ae,{label:Ee(Te(e.content))}),!K.large&&(K.added>0||K.removed>0)&&(0,X.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,K.added]}),(0,X.jsxs)(`span`,{className:`text-destructive`,children:[`−`,K.removed]})]}),(0,X.jsxs)(`span`,{className:I(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,U.level===`churn`&&`bg-destructive/10 text-destructive`,U.level===`active`&&`bg-warning/10 text-warning`,U.level===`quiet`&&`bg-success/10 text-success`),children:[(0,X.jsx)(T,{className:`h-2.5 w-2.5`}),n(`activity:fileActivity.level.${U.level}`)]}),(0,X.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:n(`activity:fileActivity.evidenceCount`,{count:H.length})}),i&&(0,X.jsx)(`button`,{type:`button`,onClick:V,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:n(`activity:fileActivity.refresh`),children:(0,X.jsx)(A,{className:I(`h-3.5 w-3.5`,x&&`animate-spin`)})})]}),i&&(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[le.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),className:I(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,u===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),w&&(0,X.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:w})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[u===`overview`&&(0,X.jsx)(je,{analysis:U,lifetime:W,records:H,sessions:q,agents:J,tasks:oe,taskLabel:se}),u===`changes`&&(0,X.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,X.jsx)(c,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:O?.available?n(`activity:fileActivity.gitToBuffer`):n(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,X.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:n(`activity:fileActivity.unsaved`)}),O?.error&&(0,X.jsx)(`span`,{className:`truncate text-warning`,children:O.error})]}),(0,X.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,X.jsx)(re,{oldText:G,newText:e.content,caption:e.path,fill:!0})})]}),u===`skeleton`&&(0,X.jsx)(Re,{file:e}),u===`context`&&(0,X.jsx)(Ne,{sessions:q,agents:J,tasks:oe,records:H,taskLabel:se,boardTitle:F?.title??z?.title}),u===`logs`&&(0,X.jsx)(Fe,{records:H,loading:x}),u===`memory`&&(0,X.jsx)(`div`,{className:`h-full min-h-[120px]`,children:(0,X.jsx)(ae,{filePath:e.path,open:!0,onClose:()=>d(`overview`)})})]})]})]})}function Ae({label:e}){return(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function je({analysis:e,lifetime:t,records:n,sessions:r,agents:i,tasks:a,taskLabel:o}){let{t:s}=E(),c=[{label:s(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,X.jsx)(p,{})},{label:s(`activity:fileActivity.sessions`),value:r.length,icon:(0,X.jsx)(u,{})},{label:s(`activity:fileActivity.actors`),value:i.length,icon:(0,X.jsx)(O,{})},{label:s(`activity:fileActivity.linkedWork`),value:a.length,icon:(0,X.jsx)(C,{})}];return(0,X.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 gap-2 p-2 lg:grid-cols-[minmax(360px,.9fr)_minmax(420px,1.35fr)]`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:c.map(e=>(0,X.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,X.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,X.jsx)(Me,{lifetime:t}),(0,X.jsxs)(`div`,{className:I(`flex items-start gap-2 rounded-md border px-2.5 py-2 text-[10px]`,e.level===`churn`?`border-destructive/25 bg-destructive/[0.055]`:`border-border/70 bg-background/45`),children:[(0,X.jsx)(d,{className:I(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-semibold`,children:s(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:s(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),a.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[s(`activity:fileActivity.workLinks`),`:`]}),a.slice(0,4).map(e=>(0,X.jsx)(`span`,{className:`max-w-[180px] truncate rounded border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-primary`,title:e,children:o(e)},e))]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,X.jsx)(`div`,{className:`border-b border-border/60 px-2.5 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:s(`activity:fileActivity.recentActivity`)}),(0,X.jsx)(`div`,{className:`divide-y divide-border/40`,children:n.length===0?(0,X.jsx)(Le,{text:s(`activity:fileActivity.noEvidence`)}):n.slice(0,5).map(e=>(0,X.jsx)(Ie,{record:e},`${e.id}:${e.at}`))})]})]})}function Me({lifetime:e}){let{t}=E(),n=[{value:e.mutations,label:t(`activity:fileActivity.lifetimeChanges`)},{value:e.sessions,label:t(`activity:fileActivity.lifetimeSessions`)},{value:e.tasks,label:t(`activity:fileActivity.lifetimeTasks`)},{value:e.boards,label:t(`activity:fileActivity.lifetimeBoards`)}],r=e.firstAt?new Date(e.firstAt).toLocaleDateString():void 0;return(0,X.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-primary [&>svg]:h-3 [&>svg]:w-3`,children:[(0,X.jsx)(g,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,X.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:[n.map(e=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,X.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,X.jsx)(`div`,{className:`mt-1 truncate font-mono text-[8px] text-muted-foreground`,title:e.tools.join(`, `),children:t(`activity:fileActivity.lifetimeTools`,{tools:e.tools.slice(0,6).join(`, `)})})]})}function Ne({sessions:e,agents:t,tasks:n,records:r,taskLabel:i,boardTitle:a}){let{t:o}=E();return(0,X.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 divide-y divide-border/50 md:grid-cols-3 md:divide-x md:divide-y-0`,children:[(0,X.jsx)($,{icon:(0,X.jsx)(u,{}),title:o(`activity:fileActivity.sessions`),empty:o(`activity:fileActivity.noSessions`),children:e.map(e=>(0,X.jsx)(Pe,{title:De(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${o(`activity:fileActivity.events`)}`,raw:e},e))}),(0,X.jsx)($,{icon:(0,X.jsx)(O,{}),title:o(`activity:fileActivity.actors`),empty:o(`activity:fileActivity.noActors`),children:t.map(e=>(0,X.jsx)(Pe,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${o(`activity:fileActivity.events`)}`},e))}),(0,X.jsx)($,{icon:(0,X.jsx)(C,{}),title:o(`activity:fileActivity.workLinks`),empty:o(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,X.jsx)(Pe,{title:i(e),subtitle:a??o(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function $({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,X.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,X.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e,t]}),(0,X.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,X.jsx)(Le,{text:n})})]})}function Pe({title:e,subtitle:t,raw:n}){return(0,X.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,X.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function Fe({records:e,loading:t}){let{t:n}=E();return t&&e.length===0?(0,X.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,X.jsx)(Le,{text:n(`activity:fileActivity.noEvidence`)}):(0,X.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,X.jsx)(Ie,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Ie({record:e,raw:t=!1}){let n=new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),r=(0,X.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,X.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:n}),(0,X.jsx)(`span`,{className:I(`w-fit rounded px-1.5 py-0.5 font-mono`,_e.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,X.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,X.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,X.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,X.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:r}),(0,X.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto rounded border border-border/60 bg-background/60 p-2 font-mono text-[8px] leading-relaxed text-muted-foreground`,children:JSON.stringify(e.raw,null,2)})]}):(0,X.jsx)(`div`,{className:`px-2.5 py-1.5`,children:r})}function Le({text:e}){return(0,X.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}function Re({file:e}){let i=t(e=>e.wsUrl),o=n(e=>e.jumpToLine),s=(0,Y.useMemo)(()=>r(i),[i]),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(!0),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(!1),[C,ee]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(!0),E=(0,Y.useCallback)(()=>{g(!0),y(null),s.send({type:`files.skeleton`,payload:{filePath:e.path,content:e.content,options:{collapseImports:C,includeDocs:w}}})},[s,e.path,e.content,C,w]);(0,Y.useEffect)(()=>{let t=s.on(`files.skeleton_result`,t=>{if(t.type===`files.skeleton_result`&&t.payload.filePath===e.path){if(g(!1),t.payload.error){y(t.payload.error);return}l(t.payload.skeleton),t.payload.stats&&d(t.payload.stats),t.payload.lang&&p(t.payload.lang)}});return E(),()=>{t()}},[s,e.path,E]);let D=async()=>{if(c)try{await navigator.clipboard.writeText(c),x(!0),setTimeout(()=>x(!1),2e3)}catch{}},O=(e,t)=>{let n=e.match(/(?:\/\*\s*L(\d+)(?:-L\d+)?\s*\*\/|#\s*L(\d+)(?:-L\d+)?)/),r=n?parseInt(n[1]||n[2]||`0`,10):null;return r&&r>0?(0,X.jsxs)(`div`,{className:`group flex items-center justify-between gap-2 rounded px-1.5 py-0.5 hover:bg-primary/10 transition-colors`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o(r),className:`shrink-0 cursor-pointer rounded bg-primary/20 px-1.5 py-0.5 font-mono text-[9px] font-semibold text-primary opacity-75 group-hover:opacity-100 hover:bg-primary hover:text-primary-foreground transition-all`,title:`Jump to line ${r} in editor`,children:[`Jump to L`,r,` →`]})]},t):(0,X.jsx)(`div`,{className:`px-1.5 py-0.5 whitespace-pre`,children:e},t)};return(0,X.jsxs)(`div`,{className:`flex h-full min-h-[140px] flex-col p-2`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2 border-b border-border/50 pb-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-0.5 font-mono text-[10px] font-semibold uppercase text-primary`,children:[(0,X.jsx)(_,{className:`h-3 w-3`}),f||`AST`]}),u&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 font-mono text-[10px] font-medium text-success`,children:[`-`,u.tokenSavingsPercent,`% Tokens`]}),(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[u.originalLines,` → `,u.skeletonLines,` lines`]}),(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,u.symbolCount,` symbols)`]})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[(0,X.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>ee(e.target.checked),className:`rounded border-border`}),(0,X.jsx)(`span`,{children:`Collapse imports`})]}),(0,X.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),className:`rounded border-border`}),(0,X.jsx)(`span`,{children:`Include docs`})]}),(0,X.jsx)(`button`,{type:`button`,onClick:E,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Refresh Skeleton`,children:(0,X.jsx)(A,{className:I(`h-3.5 w-3.5`,h&&`animate-spin`)})}),(0,X.jsxs)(`button`,{type:`button`,onClick:D,disabled:!c,className:`inline-flex items-center gap-1 rounded bg-secondary px-2 py-1 text-[10px] font-medium text-secondary-foreground hover:bg-secondary/80 disabled:opacity-50`,children:[b?(0,X.jsx)(S,{className:`h-3 w-3 text-success`}):(0,X.jsx)(a,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:b?`Copied`:`Copy`})]})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded border border-border/60 bg-muted/20 p-2 font-mono text-[11px] leading-relaxed`,children:h&&!c?(0,X.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,X.jsx)(m,{className:`mr-2 h-4 w-4 animate-spin text-primary`}),(0,X.jsx)(`span`,{children:`Extracting AST Skeleton…`})]}):v?(0,X.jsx)(`div`,{className:`p-4 text-warning`,children:v}):(0,X.jsx)(`div`,{className:`font-mono select-text`,children:c.split(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Q as n,t as r}from"./ws-client-D-d32pHb.js";import{Ji as i,Ni as a,Pt as o,Ut as s,Vr as c,ar as l,bt as u,en as d,fa as f,fi as p,fr as m,ft as h,gi as g,hi as _,ii as v,la as y,on as b,oo as x,pa as S,pr as C,qa as ee,r as w,ra as T,to as E,ut as D,wa as O,xa as k,xn as A}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{a as j,i as M,n as N,o as P,r as te,t as F}from"./monaco-BCqJp2xW.js";import{t as I}from"./utils-DQ9Exx8j.js";import{i as L}from"./codemap-activity-store-Br4b57a0.js";import{d as R,g as z,o as ne,v as B}from"./stores-CNuMLG8X.js";import{o as V}from"./view-navigation-DPOY0lyt.js";import{O as re,_ as ie,k as H}from"./index-DbprKWmG.js";import{t as U}from"./empty-state-DBQN80mK.js";import{t as W}from"./monaco-theme-CR1QvFi2.js";import{t as ae}from"./MemoryDrawer-CfukdhlF.js";var G={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,css:`css`,html:`html`,svg:`xml`,md:`markdown`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sh:`shell`,bash:`shell`,ps1:`powershell`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sql:`sql`,xml:`xml`},K=Array.from(new Set(Object.values(G))).filter(e=>e!==`plaintext`),q=12e3,J=4e3,oe=5e3,se=1e4;function ce(e){return G[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function le(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function ue(e,t){return e.triggerCharacter?!0:t.length>=3}function de(e,t){return e.triggerCharacter===`.`||!e.triggerCharacter&&/^(findBy|findAllBy|create|update|delete|remove|get[A-Z_]|set[A-Z_]|use[A-Z_])/.test(t)}function fe(e){return[e.filePath,e.language,e.lineNumber,e.column,e.versionId??``,e.triggerCharacter??``,e.linePrefix.slice(-160),e.suffix.slice(0,160)].join(`\0`)}var Y=e(x(),1),X=D();function pe(e){let t=new Set,n=new Set,r=new Set,i=new Set,a=new Set,o,s;for(let c of e)c.sessionId&&t.add(c.sessionId),c.taskId&&n.add(c.taskId),c.boardId&&r.add(c.boardId),c.toolName&&i.add(c.toolName),c.modelId&&a.add(c.modelId),(!o||c.occurredAt<o)&&(o=c.occurredAt),(!s||c.occurredAt>s)&&(s=c.occurredAt);return{mutations:e.length,sessions:t.size,tasks:n.size,boards:r.size,tools:[...i],models:[...a],firstAt:o,lastAt:s}}var me=150,he=224,ge=38,_e=/(write|edit|update|create|delete|rename|modified|changed)/i;function ve(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Z(e,t){let n=ve(e),r=ve(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ye(e,t=Date.now()){let n=e.filter(e=>t-e.at<=18e5),r=n.filter(e=>_e.test(e.action)),i=new Set(n.map(e=>e.sessionId).filter(Boolean)).size,a=new Set(n.map(e=>e.actor).filter(Boolean)).size,o=new Set(n.map(e=>e.taskId).filter(Boolean)).size;return{level:r.length>=8||r.length>=4&&a>=3?`churn`:r.length>0?`active`:`quiet`,mutationCount:r.length,sessionCount:i,actorCount:a,taskCount:o}}function Q(e){return typeof e==`string`&&e.length>0?e:void 0}function be(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function xe(e){let t=e.attributes??{},n=Q(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:be(e),action:n,actor:r??i??Q(t.actor)??`external`,source:Q(t.source)??e.tags?.collector??`chronicle`,summary:[e.eventType,i&&a?`${i}/${a}`:i,e.outcome].filter(Boolean).join(` · `),sessionId:e.scope.sessionId,agentId:r,taskId:e.scope.taskId??Q(t.taskId),boardId:Q(t.boardId)??e.scope.boardId,tool:Q(t.toolName),status:e.outcome,raw:e}}function Se(e){return{id:e.id??`${e.filePath}:${e.timestamp}:${e.type}`,at:e.timestamp,action:e.type,actor:e.agentName??e.agent??e.agentId??`external`,source:e.source??`live`,summary:e.summary,sessionId:e.sessionId,agentId:e.agentId,tool:e.toolName,status:e.status,raw:e}}function Ce(e){let t=new Set;return e.sort((e,t)=>t.at-e.at).filter(e=>{let n=`${e.id}:${e.at}`;return!t.has(n)&&(t.add(n),!0)})}function we(e){return e?e.split(/\r?\n/).length:0}function Te(e){return new TextEncoder().encode(e).length}function Ee(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function De(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function Oe(e,t){let n=H(e,t);return n?{added:n.filter(e=>e.kind===`add`).length,removed:n.filter(e=>e.kind===`del`).length,large:!1}:{added:0,removed:0,large:!0}}function ke({file:e}){let{t:n}=E(),[i,a]=(0,Y.useState)(!0),[o,l]=(0,Y.useState)(he),[u,d]=(0,Y.useState)(`overview`),[m,h]=(0,Y.useState)([]),[v,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(!1),[w,D]=(0,Y.useState)(null),[O,j]=(0,Y.useState)(null),M=(0,Y.useRef)(null),N=t(e=>e.wsUrl),P=L(e=>e.history),te=L(e=>e.activeOperations),F=R(e=>e.activeBoard),z=ne(e=>e.snapshot),B=(0,Y.useMemo)(()=>r(N),[N]),V=(0,Y.useCallback)(()=>{D(null),S(!0),typeof B.getGitDiff==`function`&&B.getGitDiff(e.path);let t=typeof B.supportsCapability==`function`?B.supportsCapability.bind(B):null;t?.(`chronicle.query`)?B.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):S(!1),t?.(`chronicle.metrics`)&&B.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[B,e.path]);(0,Y.useEffect)(()=>{h([]),b([]),j(null);let t=B.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Z(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(h(n),S(!1))}),n=B.on(`chronicle.metrics_result`,t=>{t.type===`chronicle.metrics_result`&&t.payload.view===`files`&&b(t.payload.data.filter(t=>Z(t.path,e.path)))}),r=B.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(D(e.payload.message),S(!1))}),i=B.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Z(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){j({text:e.savedContent,available:!1,error:n.error});return}j({text:n.oldText??``,available:!0})});return V(),()=>{t(),n(),r(),i()}},[B,e.path,e.savedContent,V]),(0,Y.useEffect)(()=>{let e=e=>{if(!M.current)return;let t=M.current.startY-e.clientY,n=Math.max(me,Math.floor(window.innerHeight*.62));l(Math.min(n,Math.max(me,M.current.startHeight+t)))},t=()=>{M.current=null,document.body.style.cursor=``,document.body.style.userSelect=``};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]);let ie=(0,Y.useMemo)(()=>{let t=[];for(let[n,r]of P)Z(n,e.path)&&t.push(...r);for(let n of te.values())t.push(...n.filter(t=>Z(t.filePath,e.path)));return t},[te,e.path,P]),H=(0,Y.useMemo)(()=>Ce([...ie.map(Se),...m.map(xe)]),[m,ie]),U=(0,Y.useMemo)(()=>ye(H),[H]),W=(0,Y.useMemo)(()=>pe(v),[v]),G=O?.text??e.savedContent,K=(0,Y.useMemo)(()=>Oe(G,e.content),[G,e.content]),q=(0,Y.useMemo)(()=>[...new Set(H.map(e=>e.sessionId).filter(e=>!!e))],[H]),J=(0,Y.useMemo)(()=>[...new Set(H.map(e=>e.actor).filter(Boolean))],[H]),oe=(0,Y.useMemo)(()=>[...new Set(H.map(e=>e.taskId).filter(e=>!!e))],[H]),se=(0,Y.useCallback)(e=>{let t=F?.tasks.find(t=>t.id===e),n=z?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[F,z]),ce=e=>{i||a(!0),M.current={startY:e.clientY,startHeight:i?o:me},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},le=[{id:`overview`,label:n(`activity:fileActivity.overview`),icon:(0,X.jsx)(ee,{})},{id:`changes`,label:n(`activity:fileActivity.changes`),icon:(0,X.jsx)(p,{})},{id:`skeleton`,label:`Skeleton`,icon:(0,X.jsx)(_,{})},{id:`context`,label:n(`activity:fileActivity.context`),icon:(0,X.jsx)(C,{})},{id:`logs`,label:n(`activity:fileActivity.logs`),icon:(0,X.jsx)(s,{})},{id:`memory`,label:n(`activity:fileActivity.memory`),icon:(0,X.jsx)(k,{})}];return(0,X.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:i?o:ge},"data-testid":`file-activity-drawer`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":n(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:ce,onDoubleClick:()=>{a(!0),l(he)},title:n(`activity:fileActivity.resizeHint`),children:(0,X.jsx)(`span`,{className:`absolute left-1/2 top-0.5 h-1 w-10 -translate-x-1/2 rounded-full bg-border transition-colors group-hover:bg-primary/60`})}),(0,X.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":i,children:[(0,X.jsx)(g,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,X.jsx)(`span`,{className:`truncate`,children:n(`activity:fileActivity.title`)}),i?(0,X.jsx)(f,{className:`h-3 w-3`}):(0,X.jsx)(y,{className:`h-3 w-3`})]}),(0,X.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,X.jsx)(Ae,{label:`${we(e.content)} ${n(`activity:fileActivity.lines`)}`}),(0,X.jsx)(Ae,{label:Ee(Te(e.content))}),!K.large&&(K.added>0||K.removed>0)&&(0,X.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,K.added]}),(0,X.jsxs)(`span`,{className:`text-destructive`,children:[`−`,K.removed]})]}),(0,X.jsxs)(`span`,{className:I(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,U.level===`churn`&&`bg-destructive/10 text-destructive`,U.level===`active`&&`bg-warning/10 text-warning`,U.level===`quiet`&&`bg-success/10 text-success`),children:[(0,X.jsx)(T,{className:`h-2.5 w-2.5`}),n(`activity:fileActivity.level.${U.level}`)]}),(0,X.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:n(`activity:fileActivity.evidenceCount`,{count:H.length})}),i&&(0,X.jsx)(`button`,{type:`button`,onClick:V,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:n(`activity:fileActivity.refresh`),children:(0,X.jsx)(A,{className:I(`h-3.5 w-3.5`,x&&`animate-spin`)})})]}),i&&(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[le.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),className:I(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,u===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),w&&(0,X.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:w})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[u===`overview`&&(0,X.jsx)(je,{analysis:U,lifetime:W,records:H,sessions:q,agents:J,tasks:oe,taskLabel:se}),u===`changes`&&(0,X.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,X.jsx)(c,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:O?.available?n(`activity:fileActivity.gitToBuffer`):n(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,X.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:n(`activity:fileActivity.unsaved`)}),O?.error&&(0,X.jsx)(`span`,{className:`truncate text-warning`,children:O.error})]}),(0,X.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,X.jsx)(re,{oldText:G,newText:e.content,caption:e.path,fill:!0})})]}),u===`skeleton`&&(0,X.jsx)(Re,{file:e}),u===`context`&&(0,X.jsx)(Ne,{sessions:q,agents:J,tasks:oe,records:H,taskLabel:se,boardTitle:F?.title??z?.title}),u===`logs`&&(0,X.jsx)(Fe,{records:H,loading:x}),u===`memory`&&(0,X.jsx)(`div`,{className:`h-full min-h-[120px]`,children:(0,X.jsx)(ae,{filePath:e.path,open:!0,onClose:()=>d(`overview`)})})]})]})]})}function Ae({label:e}){return(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function je({analysis:e,lifetime:t,records:n,sessions:r,agents:i,tasks:a,taskLabel:o}){let{t:s}=E(),c=[{label:s(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,X.jsx)(p,{})},{label:s(`activity:fileActivity.sessions`),value:r.length,icon:(0,X.jsx)(u,{})},{label:s(`activity:fileActivity.actors`),value:i.length,icon:(0,X.jsx)(O,{})},{label:s(`activity:fileActivity.linkedWork`),value:a.length,icon:(0,X.jsx)(C,{})}];return(0,X.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 gap-2 p-2 lg:grid-cols-[minmax(360px,.9fr)_minmax(420px,1.35fr)]`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:c.map(e=>(0,X.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,X.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,X.jsx)(Me,{lifetime:t}),(0,X.jsxs)(`div`,{className:I(`flex items-start gap-2 rounded-md border px-2.5 py-2 text-[10px]`,e.level===`churn`?`border-destructive/25 bg-destructive/[0.055]`:`border-border/70 bg-background/45`),children:[(0,X.jsx)(d,{className:I(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-semibold`,children:s(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:s(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),a.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[s(`activity:fileActivity.workLinks`),`:`]}),a.slice(0,4).map(e=>(0,X.jsx)(`span`,{className:`max-w-[180px] truncate rounded border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-primary`,title:e,children:o(e)},e))]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,X.jsx)(`div`,{className:`border-b border-border/60 px-2.5 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:s(`activity:fileActivity.recentActivity`)}),(0,X.jsx)(`div`,{className:`divide-y divide-border/40`,children:n.length===0?(0,X.jsx)(Le,{text:s(`activity:fileActivity.noEvidence`)}):n.slice(0,5).map(e=>(0,X.jsx)(Ie,{record:e},`${e.id}:${e.at}`))})]})]})}function Me({lifetime:e}){let{t}=E(),n=[{value:e.mutations,label:t(`activity:fileActivity.lifetimeChanges`)},{value:e.sessions,label:t(`activity:fileActivity.lifetimeSessions`)},{value:e.tasks,label:t(`activity:fileActivity.lifetimeTasks`)},{value:e.boards,label:t(`activity:fileActivity.lifetimeBoards`)}],r=e.firstAt?new Date(e.firstAt).toLocaleDateString():void 0;return(0,X.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-primary [&>svg]:h-3 [&>svg]:w-3`,children:[(0,X.jsx)(g,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,X.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:[n.map(e=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,X.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,X.jsx)(`div`,{className:`mt-1 truncate font-mono text-[8px] text-muted-foreground`,title:e.tools.join(`, `),children:t(`activity:fileActivity.lifetimeTools`,{tools:e.tools.slice(0,6).join(`, `)})})]})}function Ne({sessions:e,agents:t,tasks:n,records:r,taskLabel:i,boardTitle:a}){let{t:o}=E();return(0,X.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 divide-y divide-border/50 md:grid-cols-3 md:divide-x md:divide-y-0`,children:[(0,X.jsx)($,{icon:(0,X.jsx)(u,{}),title:o(`activity:fileActivity.sessions`),empty:o(`activity:fileActivity.noSessions`),children:e.map(e=>(0,X.jsx)(Pe,{title:De(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${o(`activity:fileActivity.events`)}`,raw:e},e))}),(0,X.jsx)($,{icon:(0,X.jsx)(O,{}),title:o(`activity:fileActivity.actors`),empty:o(`activity:fileActivity.noActors`),children:t.map(e=>(0,X.jsx)(Pe,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${o(`activity:fileActivity.events`)}`},e))}),(0,X.jsx)($,{icon:(0,X.jsx)(C,{}),title:o(`activity:fileActivity.workLinks`),empty:o(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,X.jsx)(Pe,{title:i(e),subtitle:a??o(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function $({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,X.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,X.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e,t]}),(0,X.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,X.jsx)(Le,{text:n})})]})}function Pe({title:e,subtitle:t,raw:n}){return(0,X.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,X.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function Fe({records:e,loading:t}){let{t:n}=E();return t&&e.length===0?(0,X.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,X.jsx)(Le,{text:n(`activity:fileActivity.noEvidence`)}):(0,X.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,X.jsx)(Ie,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Ie({record:e,raw:t=!1}){let n=new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),r=(0,X.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,X.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:n}),(0,X.jsx)(`span`,{className:I(`w-fit rounded px-1.5 py-0.5 font-mono`,_e.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,X.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,X.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,X.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,X.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:r}),(0,X.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto rounded border border-border/60 bg-background/60 p-2 font-mono text-[8px] leading-relaxed text-muted-foreground`,children:JSON.stringify(e.raw,null,2)})]}):(0,X.jsx)(`div`,{className:`px-2.5 py-1.5`,children:r})}function Le({text:e}){return(0,X.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}function Re({file:e}){let i=t(e=>e.wsUrl),o=n(e=>e.jumpToLine),s=(0,Y.useMemo)(()=>r(i),[i]),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(!0),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(!1),[C,ee]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(!0),E=(0,Y.useCallback)(()=>{g(!0),y(null),s.send({type:`files.skeleton`,payload:{filePath:e.path,content:e.content,options:{collapseImports:C,includeDocs:w}}})},[s,e.path,e.content,C,w]);(0,Y.useEffect)(()=>{let t=s.on(`files.skeleton_result`,t=>{if(t.type===`files.skeleton_result`&&t.payload.filePath===e.path){if(g(!1),t.payload.error){y(t.payload.error);return}l(t.payload.skeleton),t.payload.stats&&d(t.payload.stats),t.payload.lang&&p(t.payload.lang)}});return E(),()=>{t()}},[s,e.path,E]);let D=async()=>{if(c)try{await navigator.clipboard.writeText(c),x(!0),setTimeout(()=>x(!1),2e3)}catch{}},O=(e,t)=>{let n=e.match(/(?:\/\*\s*L(\d+)(?:-L\d+)?\s*\*\/|#\s*L(\d+)(?:-L\d+)?)/),r=n?parseInt(n[1]||n[2]||`0`,10):null;return r&&r>0?(0,X.jsxs)(`div`,{className:`group flex items-center justify-between gap-2 rounded px-1.5 py-0.5 hover:bg-primary/10 transition-colors`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o(r),className:`shrink-0 cursor-pointer rounded bg-primary/20 px-1.5 py-0.5 font-mono text-[9px] font-semibold text-primary opacity-75 group-hover:opacity-100 hover:bg-primary hover:text-primary-foreground transition-all`,title:`Jump to line ${r} in editor`,children:[`Jump to L`,r,` →`]})]},t):(0,X.jsx)(`div`,{className:`px-1.5 py-0.5 whitespace-pre`,children:e},t)};return(0,X.jsxs)(`div`,{className:`flex h-full min-h-[140px] flex-col p-2`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2 border-b border-border/50 pb-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-0.5 font-mono text-[10px] font-semibold uppercase text-primary`,children:[(0,X.jsx)(_,{className:`h-3 w-3`}),f||`AST`]}),u&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 font-mono text-[10px] font-medium text-success`,children:[`-`,u.tokenSavingsPercent,`% Tokens`]}),(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[u.originalLines,` → `,u.skeletonLines,` lines`]}),(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,u.symbolCount,` symbols)`]})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[(0,X.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>ee(e.target.checked),className:`rounded border-border`}),(0,X.jsx)(`span`,{children:`Collapse imports`})]}),(0,X.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),className:`rounded border-border`}),(0,X.jsx)(`span`,{children:`Include docs`})]}),(0,X.jsx)(`button`,{type:`button`,onClick:E,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Refresh Skeleton`,children:(0,X.jsx)(A,{className:I(`h-3.5 w-3.5`,h&&`animate-spin`)})}),(0,X.jsxs)(`button`,{type:`button`,onClick:D,disabled:!c,className:`inline-flex items-center gap-1 rounded bg-secondary px-2 py-1 text-[10px] font-medium text-secondary-foreground hover:bg-secondary/80 disabled:opacity-50`,children:[b?(0,X.jsx)(S,{className:`h-3 w-3 text-success`}):(0,X.jsx)(a,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:b?`Copied`:`Copy`})]})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded border border-border/60 bg-muted/20 p-2 font-mono text-[11px] leading-relaxed`,children:h&&!c?(0,X.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,X.jsx)(m,{className:`mr-2 h-4 w-4 animate-spin text-primary`}),(0,X.jsx)(`span`,{children:`Extracting AST Skeleton…`})]}):v?(0,X.jsx)(`div`,{className:`p-4 text-warning`,children:v}):(0,X.jsx)(`div`,{className:`font-mono select-text`,children:c.split(`
|
|
2
2
|
`).map((e,t)=>O(e,t))})})]})}N.config({monaco:F});function ze(e){switch(e){case`method`:return P.CompletionItemKind.Method;case`function`:return P.CompletionItemKind.Function;case`constructor`:return P.CompletionItemKind.Constructor;case`field`:return P.CompletionItemKind.Field;case`variable`:return P.CompletionItemKind.Variable;case`class`:return P.CompletionItemKind.Class;case`interface`:return P.CompletionItemKind.Interface;case`module`:return P.CompletionItemKind.Module;case`property`:return P.CompletionItemKind.Property;case`unit`:return P.CompletionItemKind.Unit;case`value`:return P.CompletionItemKind.Value;case`enum`:return P.CompletionItemKind.Enum;case`keyword`:return P.CompletionItemKind.Keyword;case`snippet`:return P.CompletionItemKind.Snippet;case`file`:return P.CompletionItemKind.File;case`reference`:return P.CompletionItemKind.Reference;default:return P.CompletionItemKind.Text}}function Be(){let e=n(e=>e.openFiles),t=n(e=>e.activeFilePath),r=n(e=>e.setActiveFile),a=n(e=>e.closeFile);return e.length===0?null:(0,X.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let n=e.path===t,o=e.path.split(`/`).pop()??e.path;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),a(e.path))},className:I(`group flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r whitespace-nowrap min-w-0 max-w-[180px] transition-colors`,n?`bg-background border-t-2 border-t-primary text-foreground -mb-px`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),title:e.path,children:[e.dirty&&(0,X.jsx)(i,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:o}),(0,X.jsx)(h,{className:I(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,n&&`opacity-100`),onClick:t=>{t.stopPropagation(),a(e.path)}})]},e.path)})})}function Ve(){let{t:e}=E(),i=n(e=>e.openFiles),a=n(e=>e.activeFilePath),s=n(e=>e.updateContent),{theme:u}=ie(),d=(0,Y.useRef)(null),f=(0,Y.useRef)(a),p=(0,Y.useRef)(new Map),m=(0,Y.useMemo)(()=>i.find(e=>e.path===a)??null,[i,a]),h=a?ce(a):`plaintext`,g=W(),[_,y]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)({line:1,col:1}),[C,ee]=(0,Y.useState)(!1),[T,D]=(0,Y.useState)(!1),O=z(e=>e.info?.branch);(0,Y.useEffect)(()=>{f.current=a},[a]),(0,Y.useEffect)(()=>{let e=W();j.setTheme(e)},[u]);let k=n(e=>e.targetLine),A=n(e=>e.clearTargetLine);(0,Y.useEffect)(()=>{k&&d.current&&(d.current.revealLineInCenter(k.line),d.current.setPosition({lineNumber:k.line,column:k.col??1}),d.current.focus(),A())},[k,A]),(0,Y.useEffect)(()=>{let e=K.map(e=>P.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,n,i,a)=>{let o=f.current;if(!o)return{suggestions:[]};let s=e.getOffsetAt(n),c=e.getValue(),l=c.slice(Math.max(0,s-q),s),u=c.slice(s,s+J),d=e.getLineContent(n.lineNumber).slice(0,Math.max(0,n.column-1)),m=le(d),h={triggerCharacter:i.triggerCharacter,triggerKind:i.triggerKind};if(!ue(h,m))return{suggestions:[]};let g=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,_=e.getWordUntilPosition(n),v={startLineNumber:n.lineNumber,endLineNumber:n.lineNumber,startColumn:_.startColumn,endColumn:n.column},y=r(t.getState().wsUrl),b=e=>e.map((e,t)=>({label:e.label,kind:ze(e.kind),insertText:e.insertText,detail:e.detail??(e.source?`WrongStack ${e.source}`:void 0),documentation:e.documentation,sortText:e.sortText??`${String(t).padStart(3,`0`)}-${e.label}`,range:v,insertTextRules:e.kind===`snippet`?P.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),x=fe({filePath:o,language:e.getLanguageId(),lineNumber:n.lineNumber,column:n.column,versionId:e.getVersionId(),triggerCharacter:i.triggerCharacter,linePrefix:d,suffix:u}),S=p.current.get(x);return S&&S.expiresAt>Date.now()?{suggestions:b(S.items)}:await new Promise(t=>{let r=!1,s=()=>{},d=null,f,_=e=>{r||(r=!0,s(),f!==void 0&&window.clearTimeout(f),d?.dispose(),t({suggestions:e}))};s=y.on(`completion.result`,e=>{let t=e;t.payload.requestId===g&&(p.current.set(x,{expiresAt:Date.now()+se,items:t.payload.items}),_(b(t.payload.items)))}),f=window.setTimeout(()=>_([]),oe),d=a.onCancellationRequested(()=>_([])),y.requestCompletion({requestId:g,filePath:o,language:e.getLanguageId(),lineNumber:n.lineNumber,column:n.column,content:c.length<=5e5?c:void 0,prefix:l,suffix:u,triggerCharacter:i.triggerCharacter,triggerKind:i.triggerKind,allowLlm:de(h,m)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let N=(0,Y.useCallback)(()=>{let e=d.current;if(!e)return null;let t=e.getSelection();if(!t||t.isEmpty())return null;let n=e.getModel();if(!n)return null;let r=n.getValueInRange(t);return r.trim()?{content:r,startLine:t.startLineNumber,endLine:t.endLineNumber}:null},[]),F=(0,Y.useCallback)(()=>{V(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),L=(0,Y.useCallback)(()=>{let e=f.current;if(!e)return;let t=N();t&&(B.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),F())},[N,F]),R=(0,Y.useCallback)(()=>{let e=f.current;e&&(B.getState().addRef({kind:`file`,path:e}),F())},[F]),ne=(0,Y.useCallback)(t=>{d.current=t,j.setTheme(W()),t.onDidChangeCursorSelection?.(()=>{let e=t.getSelection();y(!!e&&!e.isEmpty())}),t.onDidChangeCursorPosition?.(e=>{e?.position&&S({line:e.position.lineNumber,col:e.position.column})}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[M.CtrlCmd|M.Shift|te.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?L():R()}})},[L,R]),re=(0,Y.useCallback)(e=>{a&&e!==void 0&&s(a,e)},[a,s]);return(0,Y.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.metaKey,r=e.target?.tagName?.toLowerCase()===`textarea`||e.target?.closest(`.monaco-editor`)!==null;!t||!r||(e.key.toLowerCase()===`s`&&(e.preventDefault(),window.dispatchEvent(new CustomEvent(`wrongstack:save-file`,{detail:{filePath:a}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),a&&n.getState().closeFile(a)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),i.length===0?(0,X.jsx)(U,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,X.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,X.jsx)(Be,{}),(0,X.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(_||m)&&(0,X.jsxs)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-popover/95 backdrop-blur shadow-md p-1`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ee(e=>!e),className:I(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] transition-colors`,C?`bg-primary/20 text-primary font-medium`:`text-muted-foreground hover:text-foreground hover:bg-accent`),title:C?`Disable word wrap`:`Enable word wrap`,children:[(0,X.jsx)(o,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:`Wrap`})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>D(e=>!e),className:I(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] transition-colors`,T?`bg-primary/20 text-primary font-medium`:`text-muted-foreground hover:text-foreground hover:bg-accent`),title:T?`Hide minimap`:`Show minimap`,children:[(0,X.jsx)(l,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:`Map`})]}),(0,X.jsx)(`div`,{className:`h-3.5 w-px bg-border/80 mx-0.5`}),(0,X.jsxs)(`button`,{type:`button`,onClick:_?L:R,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-foreground hover:bg-accent transition-colors`,title:e(_?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[_?(0,X.jsx)(b,{className:`h-3 w-3`}):(0,X.jsx)(v,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:e(_?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})]}),m?(0,X.jsx)(w,{language:h,value:m.content,onChange:re,theme:g,onMount:ne,loading:(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:T},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:C?`on`:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},m.path):(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),m&&(0,X.jsxs)(`div`,{className:`flex h-6 shrink-0 items-center justify-between border-t border-border/70 bg-muted/30 px-3 text-[11px] text-muted-foreground font-mono select-none`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[O&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-foreground/80 font-medium`,children:[(0,X.jsx)(c,{className:`h-3 w-3 text-primary shrink-0`}),(0,X.jsx)(`span`,{className:`truncate max-w-[140px]`,children:O})]}),(0,X.jsx)(`span`,{className:`truncate max-w-[320px] text-muted-foreground`,children:m.path})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,X.jsxs)(`span`,{children:[`Ln `,x.line,`, Col `,x.col]}),(0,X.jsx)(`span`,{children:`UTF-8`}),(0,X.jsx)(`span`,{className:`uppercase text-[10px] font-semibold text-primary`,children:h})]})]}),m&&(0,X.jsx)(ke,{file:m})]})}export{Ve as CodeEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ui as t,ea as n,hn as r,oo as i,ta as a,to as o,ut as s}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{y as c}from"./stores-CNuMLG8X.js";import{a as l,n as u,o as d,r as f,t as p}from"./dialog-BTHxOi5z.js";import{D as m,u as h}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ui as t,ea as n,hn as r,oo as i,ta as a,to as o,ut as s}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{y as c}from"./stores-CNuMLG8X.js";import{a as l,n as u,o as d,r as f,t as p}from"./dialog-BTHxOi5z.js";import{D as m,u as h}from"./index-DbprKWmG.js";var g=e(i(),1),_=s();function v(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:e<36e5?`${(e/6e4).toFixed(1)}m`:`${(e/36e5).toFixed(1)}h`}function y(e){if(!e)return`—`;let t=new Date(e),n=Date.now(),r=t.getTime()-n,i=Math.abs(r);if(i<6e4)return r>=0?`<1m`:`<1m ago`;if(i<36e5){let e=Math.round(i/6e4);return r>=0?`${e}m`:`${e}m ago`}if(i<864e5){let e=Math.round(i/36e5);return r>=0?`${e}h`:`${e}h ago`}return t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function b({enabled:e,overdue:r}){let{t:i}=o();return e?r?(0,_.jsxs)(h,{variant:`destructive`,className:`gap-1`,children:[(0,_.jsx)(t,{className:`h-3 w-3`}),i(`activity:cronJobs.statusOverdue`)]}):(0,_.jsxs)(h,{variant:`outline`,className:`gap-1 border-success/30 bg-success/10 text-success`,children:[(0,_.jsx)(n,{className:`h-3 w-3`}),i(`activity:cronJobs.statusActive`)]}):(0,_.jsxs)(h,{variant:`secondary`,className:`gap-1`,children:[(0,_.jsx)(a,{className:`h-3 w-3`}),i(`activity:cronJobs.statusDisabled`)]})}function x({open:e,onClose:n}){let{t:i}=o(),a=c(e=>e.snapshot),s=c(e=>e.lastFiredAt);c(e=>e.revision);let h=a?.jobs??[],x=a?.count??0,S=a?.maxConcurrent??0,C=h.filter(e=>e.overdue).length,w=h.filter(e=>e.enabled).length,T=h.reduce((e,t)=>e+t.runCount,0),E=(0,g.useCallback)(e=>{e||n()},[n]);return(0,_.jsx)(p,{open:e,onOpenChange:E,children:(0,_.jsxs)(u,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,_.jsxs)(l,{children:[(0,_.jsxs)(d,{className:`flex items-center gap-2`,children:[(0,_.jsx)(r,{className:`h-5 w-5`}),i(`activity:cronJobs.heading`)]}),(0,_.jsx)(f,{children:i(`activity:cronJobs.subtitle`)})]}),x>0&&(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-sm text-muted-foreground border-b border-border/70 pb-3`,children:[(0,_.jsx)(`span`,{className:`font-medium text-foreground`,children:i(`activity:cronJobs.jobCount`,{count:x})}),(0,_.jsx)(`span`,{className:`text-success`,children:i(`activity:cronJobs.enabledCount`,{count:w})}),C>0&&(0,_.jsx)(`span`,{className:`text-destructive`,children:i(`activity:cronJobs.overdueCount`,{count:C})}),(0,_.jsx)(`span`,{children:i(`activity:cronJobs.totalRuns`,{count:T})}),(0,_.jsx)(`span`,{className:`text-muted-foreground/60`,children:i(`activity:cronJobs.maxConcurrent`,{count:S})})]}),x===0&&(0,_.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-12 text-muted-foreground`,children:[(0,_.jsx)(t,{className:`h-8 w-8 opacity-40`}),(0,_.jsx)(`p`,{className:`text-sm`,children:i(`activity:cronJobs.emptyTitle`)}),(0,_.jsxs)(`p`,{className:`text-xs`,children:[i(`activity:cronJobs.emptyUse`),` `,(0,_.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`cron_schedule`}),` `,i(`activity:cronJobs.emptyToAdd`)]})]}),x>0&&(0,_.jsx)(m,{className:`flex-1 -mx-6 px-6`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-border/50 text-left text-xs text-muted-foreground`,children:[(0,_.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:i(`activity:cronJobs.thStatus`)}),(0,_.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:i(`activity:cronJobs.thName`)}),(0,_.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:i(`activity:cronJobs.thInterval`)}),(0,_.jsx)(`th`,{className:`pb-2 pr-3 font-medium text-right`,children:i(`activity:cronJobs.thRuns`)}),(0,_.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:i(`activity:cronJobs.thNextRun`)}),(0,_.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:i(`activity:cronJobs.thLastRun`)}),(0,_.jsx)(`th`,{className:`pb-2 font-medium`,children:i(`activity:cronJobs.thAction`)})]})}),(0,_.jsx)(`tbody`,{children:h.map(e=>(0,_.jsxs)(`tr`,{className:`border-b border-border/30 last:border-0`,children:[(0,_.jsx)(`td`,{className:`py-2.5 pr-3`,children:(0,_.jsx)(b,{enabled:e.enabled,overdue:e.overdue})}),(0,_.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs font-medium max-w-[160px] truncate`,title:e.name,children:e.name}),(0,_.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.intervalMs)}),(0,_.jsxs)(`td`,{className:`py-2.5 pr-3 text-right font-mono text-xs tabular-nums`,children:[e.runCount,s[e.name]&&(0,_.jsx)(`span`,{className:`ml-1 text-success`,title:i(`activity:cronJobs.lastFiredAtTitle`,{time:s[e.name]}),children:`●`})]}),(0,_.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:y(e.nextRun)}),(0,_.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:y(e.lastRun)}),(0,_.jsx)(`td`,{className:`py-2.5 font-mono text-xs max-w-[200px] truncate text-muted-foreground`,title:e.action,children:e.action})]},e.name))})]})}),x>0&&(0,_.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-3 border-t border-border/70`,children:[i(`activity:cronJobs.footerUse`),` `,(0,_.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px]`,children:`cron_schedule`}),` `,i(`activity:cronJobs.footerToAdd`),(0,_.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px] ml-1`,children:`cron_cancel`}),` `,i(`activity:cronJobs.footerToRemove`)]})]})})}export{x as CronJobsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{At as t,Gr as n,Ui as r,an as i,di as a,ga as o,io as s,oa as c,oo as l,qa as u,to as d,ut as f,vi as p,xn as m}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{d as h}from"./index-b_i-YcNT.js";var g=e(l(),1),_=f();function v({title:e,value:n,subtitle:r,icon:i,color:a=`text-primary`,trend:o}){let{t:s}=d();return(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium`,children:e}),(0,_.jsx)(`p`,{className:`mt-1 truncate text-xl font-semibold tabular-nums sm:text-2xl ${a}`,children:n}),r&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:r})]}),(0,_.jsx)(`div`,{className:`shrink-0 rounded-lg bg-muted/70 p-2 ${a}`,children:(0,_.jsx)(i,{className:`w-5 h-5`})})]}),o&&(0,_.jsxs)(`div`,{className:`mt-2 flex items-center gap-1`,children:[o===`up`&&(0,_.jsx)(t,{className:`w-3 h-3 text-success`}),o===`down`&&(0,_.jsx)(t,{className:`w-3 h-3 rotate-180 text-destructive`}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s(o===`up`?`activity:debug.trendUp`:o===`down`?`activity:debug.trendDown`:`activity:debug.trendStable`)})]})]})}function y(){let{t:e}=d(),[l,f]=(0,g.useState)({fileWatcher:null,system:null,lastUpdated:null,error:null}),[y,C]=(0,g.useState)(!0),[w,T]=(0,g.useState)(2e3),E=(0,g.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch(`/debug/watcher-metrics`),fetch(`/debug/system`,{cache:`no-store`})]),n=null,r=e.headers.get(`content-type`)??``;if(e.ok&&r.includes(`application/json`)&&(n=await e.json()),!t.ok)throw Error(`System metrics request failed (${t.status})`);let i=await t.json();f({fileWatcher:n,system:i,lastUpdated:new Date,error:null})}catch(e){f(t=>({...t,error:e instanceof Error?e.message:s.t(`activity:debug.fetchFailed`)}))}finally{C(!1)}},[]);return(0,g.useEffect)(()=>{E();let e=setInterval(E,w);return()=>clearInterval(e)},[E,w]),(0,_.jsx)(`div`,{ref:h(`debug`),className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,_.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-col gap-5`,children:[(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold sm:text-xl`,children:[(0,_.jsx)(o,{className:`h-5 w-5 text-primary`}),e(`activity:debug.heading`)]}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e(`activity:debug.subtitle`)})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,_.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,_.jsx)(m,{className:`w-4 h-4 text-muted-foreground`}),(0,_.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e(`activity:debug.refreshLabel`)}),(0,_.jsxs)(`select`,{value:w,onChange:e=>T(Number(e.target.value)),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm`,children:[(0,_.jsx)(`option`,{value:1e3,children:`1s`}),(0,_.jsx)(`option`,{value:2e3,children:`2s`}),(0,_.jsx)(`option`,{value:5e3,children:`5s`}),(0,_.jsx)(`option`,{value:1e4,children:`10s`})]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{C(!0),E()},disabled:y,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground shadow-sm shadow-primary/15 hover:bg-primary/90 disabled:opacity-50`,children:[(0,_.jsx)(m,{className:`w-4 h-4 ${y?`animate-spin`:``}`}),e(`common:action.refresh`)]})]})]})}),l.lastUpdated&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-card/55 px-3 py-2 text-sm text-muted-foreground`,children:[(0,_.jsx)(r,{className:`w-4 h-4`}),e(`activity:debug.lastUpdated`,{time:l.lastUpdated.toLocaleTimeString()})]}),l.error&&(0,_.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-destructive/25 bg-destructive/10 p-4 text-destructive`,children:[(0,_.jsx)(c,{className:`w-5 h-5 flex-shrink-0`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`font-medium`,children:e(`activity:debug.fetchFailed`)}),(0,_.jsx)(`p`,{className:`text-sm opacity-80`,children:l.error})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(p,{className:`h-4 w-4 text-primary`}),e(`activity:debug.fileWatcher`)]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.watcherStatus`),value:l.fileWatcher?.watcherActive?e(`activity:debug.running`):e(`activity:debug.stopped`),icon:i,color:l.fileWatcher?.watcherActive?`text-success`:`text-destructive`}),(0,_.jsx)(v,{title:e(`activity:debug.activeProjects`),value:l.fileWatcher?.activeProjects??0,subtitle:e(`activity:debug.projectsWatched`),icon:a,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.fileChanges`),value:l.fileWatcher?.fileChangesDetected??0,subtitle:e(`activity:debug.totalDetected`),icon:u,color:`text-primary`,trend:`neutral`}),(0,_.jsx)(v,{title:e(`activity:debug.filesProcessed`),value:l.fileWatcher?.filesProcessed??0,subtitle:e(`activity:debug.afterHash`),icon:n,color:`text-success`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mt-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.broadcastsSent`),value:l.fileWatcher?.broadcastsSent??0,subtitle:e(`activity:debug.toClients`),icon:t,color:`text-success`}),(0,_.jsx)(v,{title:e(`activity:debug.debounceResets`),value:l.fileWatcher?.debounceResets??0,subtitle:e(`activity:debug.rapidWrites`),icon:m,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.avgDebounce`),value:`${(l.fileWatcher?.averageDebounceDelayMs??0).toFixed(1)}ms`,subtitle:e(`activity:debug.actualDelay`),icon:r,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.totalDelay`),value:`${(l.fileWatcher?.totalDebounceDelayMs??0).toFixed(0)}ms`,subtitle:e(`activity:debug.sumDelays`),icon:o,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(n,{className:`h-4 w-4 text-primary`}),e(`activity:debugDash.webuiServerProcess`)]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:e(`activity:debugDash.processRamRss`),value:b(l.system?.memoryUsage?.rss??0),subtitle:l.system?`PID ${l.system.pid}`:void 0,icon:i,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapUsed`),value:b(l.system?.memoryUsage?.heapUsed??0),subtitle:e(`activity:debug.jsHeap`),icon:o,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapTotal`),value:b(l.system?.memoryUsage?.heapTotal??0),subtitle:e(`activity:debug.totalHeap`),icon:o,color:`text-success`}),(0,_.jsx)(v,{title:e(`activity:debugDash.v8HeapLimit`),value:b(l.system?.heapLimit??0),subtitle:e(`activity:debugDash.oldSpaceCeiling`),icon:n,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debugDash.serverUptime`),value:S(l.system?.uptime??0),subtitle:e(`activity:debugDash.sinceProcessStart`),icon:r,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(u,{className:`h-4 w-4 text-primary`}),e(`activity:debugDash.liveWrongstackProcesses`)]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[980px] text-left text-xs`,children:[(0,_.jsx)(`thead`,{className:`border-b border-border/70 bg-muted/35 text-muted-foreground`,children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.surface`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.memory`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.growthSignal`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.workload`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.hqOfflineQueue`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.resourcesHotspot`)})]})}),(0,_.jsxs)(`tbody`,{children:[(l.system?.processes??[]).map(e=>{let t=[e.workload.messages===void 0?void 0:`${e.workload.messages} msgs`,e.workload.messageEstimatedTokens===void 0?void 0:`${e.workload.messageEstimatedTokens.toLocaleString()} ctx tokens`,e.workload.historyEntries===void 0?void 0:`${e.workload.historyMountedEntries??0}/${e.workload.historyEntries} history mounted`,e.workload.appRenders===void 0?void 0:`${e.workload.appRenders} renders`,e.workload.metricsDroppedObservations?`${e.workload.metricsDroppedObservations} metric drops`:void 0,e.workload.kanbanSyncActive?`kanban sync active`:void 0,e.workload.kanbanSyncPendingBoards?`${e.workload.kanbanSyncPendingBoards} kanban pending`:void 0,e.workload.kanbanSyncFullRescanPending?`kanban full rescan pending`:void 0,e.workload.kanbanSyncRemoteApplyQueued?`${e.workload.kanbanSyncPendingRemoteBoards??0} remote boards queued`:void 0,e.workload.kanbanSyncCoalescedRefreshes?`${e.workload.kanbanSyncCoalescedRefreshes} kanban coalesced`:void 0,e.workload.kanbanSupervisorSnapshots?`${e.workload.kanbanSupervisorSnapshots} supervised boards`:void 0,e.workload.kanbanSupervisorScheduledBoards?`${e.workload.kanbanSupervisorScheduledBoards} supervisor schedules`:void 0].filter(Boolean).join(` · `);return(0,_.jsxs)(`tr`,{className:`border-b border-border/50 align-top last:border-b-0`,children:[(0,_.jsxs)(`td`,{className:`px-3 py-3`,children:[(0,_.jsx)(`div`,{className:`font-medium text-foreground`,children:e.surface}),(0,_.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`PID `,e.pid]}),(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()})]}),(0,_.jsxs)(`td`,{className:`px-3 py-3 tabular-nums`,children:[(0,_.jsxs)(`div`,{children:[`RSS `,b(e.memory.rss)]}),(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`heap `,b(e.memory.heapUsed),e.memory.retainedHeapUsed===void 0?``:` · retained ${b(e.memory.retainedHeapUsed)}`]}),e.memory.nativeResidual===void 0?null:(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`native `,b(e.memory.nativeResidual)]}),e.memory.external===void 0?null:(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`external `,b(e.memory.external),e.memory.arrayBuffers===void 0?``:` · buffers ${b(e.memory.arrayBuffers)}`]})]}),(0,_.jsxs)(`td`,{className:`px-3 py-3 tabular-nums`,children:[(0,_.jsx)(`div`,{className:e.signal===`stable`?`text-success`:e.signal?`text-warning`:`text-muted-foreground`,children:e.signal??`sampling`}),(0,_.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`heap `,x(e.heapGrowthBytesPerHour)]}),(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`RSS `,x(e.rssGrowthBytesPerHour)]})]}),(0,_.jsx)(`td`,{className:`px-3 py-3 text-muted-foreground`,children:t||`—`}),(0,_.jsx)(`td`,{className:`px-3 py-3 tabular-nums`,children:e.hqQueue?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{children:[e.hqQueue.entries,` frames ·`,` `,b(e.hqQueue.bytes),` /`,` `,b(e.hqQueue.maxBytes)]}),(0,_.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[e.hqQueue.coalescedFrames,` coalesced ·`,` `,e.hqQueue.droppedFrames,` dropped`]}),e.hqSnapshot?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`snapshot`,` `,e.hqSnapshot.inFlight?`in-flight`:e.hqSnapshot.pending?`pending`:e.hqSnapshot.timerScheduled?`scheduled`:`idle`]}),(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`events`,` `,e.hqSnapshot.eventInFlight?`in-flight`:`idle`,` ·`,` `,e.hqSnapshot.pendingEvents,` pending ·`,` `,e.hqSnapshot.coalescedEvents,` coalesced ·`,` `,e.hqSnapshot.droppedEvents,` dropped`]})]}):null]}):(0,_.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,_.jsxs)(`td`,{className:`max-w-[360px] px-3 py-3 text-muted-foreground`,children:[(0,_.jsxs)(`div`,{children:[e.resources.active??0,` active`,e.resources.types?` · ${e.resources.types}`:``]}),e.profileTopStack?(0,_.jsxs)(`div`,{className:`mt-1 truncate`,title:e.profileTopStack,children:[e.profileTopStackBytes===void 0?``:`${b(e.profileTopStackBytes)} · `,e.profileTopStack]}):null]})]},e.pid)}),(l.system?.processes?.length??0)===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{className:`px-3 py-5 text-muted-foreground`,colSpan:6,children:e(`activity:debugDash.waitingForHeapFlightRecorderSamples`)})}):null]})]})})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(i,{className:`h-4 w-4 text-primary`}),e(`activity:debugDash.codebaseIndexServer`)]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:e(`activity:debugDash.connection`),value:l.system?.codebaseIndexServer?.health?.status??l.system?.codebaseIndexServer?.status??`unknown`,subtitle:l.system?.codebaseIndexServer?.pid?`PID ${l.system.codebaseIndexServer.pid} · RTT ${l.system.codebaseIndexServer.health?.latencyMs??`—`}ms`:`No connected project server`,icon:u,color:l.system?.codebaseIndexServer?.health?.status===`healthy`?`text-success`:l.system?.codebaseIndexServer?.status===`unresponsive`||l.system?.codebaseIndexServer?.status===`error`?`text-destructive`:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debugDash.indexRamRss`),value:b(l.system?.codebaseIndexServer?.health?.server?.memory.rss??0),subtitle:`Heap ${b(l.system?.codebaseIndexServer?.health?.server?.memory.heapUsed??0)} / ${b(l.system?.codebaseIndexServer?.health?.server?.memory.heapTotal??0)}`,icon:o,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debugDash.indexWorkload`),value:`${l.system?.codebaseIndexServer?.health?.server?.activeRequests??0} requests`,subtitle:`${l.system?.codebaseIndexServer?.health?.server?.activeWrites??0} writes · ${l.system?.codebaseIndexServer?.health?.server?.queuedWrites??0} queued`,icon:n,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debugDash.indexWatcher`),value:l.system?.codebaseIndexServer?.health?.server?.watchingExternal?`Active`:`Off`,subtitle:`${l.system?.codebaseIndexServer?.health?.server?.watchingClients??0} owners · ${l.system?.codebaseIndexServer?.health?.server?.pendingExternalFiles??0} pending`,icon:p,color:l.system?.codebaseIndexServer?.health?.server?.watchingExternal?`text-success`:`text-muted-foreground`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(u,{className:`h-4 w-4 text-primary`}),e(`activity:debug.rawData`)]}),(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsx)(`pre`,{className:`overflow-x-auto text-xs font-mono text-muted-foreground`,children:JSON.stringify({fileWatcher:l.fileWatcher,serverPid:l.system?.pid,serverMemory:l.system?.memoryUsage,serverHeapLimit:l.system?.heapLimit,serverUptime:l.system?.uptime,processes:l.system?.processes,codebaseIndexServer:l.system?.codebaseIndexServer},null,2)})})]})]})})}function b(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${(e/t**r).toFixed(1)} ${n[r]}`}function x(e){return e===void 0?`—`:`${e>0?`+`:e<0?`−`:``}${b(Math.abs(e))}/h`}function S(e){return e<60?`${e.toFixed(0)}s`:e<3600?`${(e/60).toFixed(1)}m`:`${(e/3600).toFixed(1)}h`}export{y as DebugDashboard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{At as t,Gr as n,Ui as r,an as i,di as a,ga as o,io as s,oa as c,oo as l,qa as u,to as d,ut as f,vi as p,xn as m}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{d as h}from"./index-DbprKWmG.js";var g=e(l(),1),_=f();function v({title:e,value:n,subtitle:r,icon:i,color:a=`text-primary`,trend:o}){let{t:s}=d();return(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium`,children:e}),(0,_.jsx)(`p`,{className:`mt-1 truncate text-xl font-semibold tabular-nums sm:text-2xl ${a}`,children:n}),r&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:r})]}),(0,_.jsx)(`div`,{className:`shrink-0 rounded-lg bg-muted/70 p-2 ${a}`,children:(0,_.jsx)(i,{className:`w-5 h-5`})})]}),o&&(0,_.jsxs)(`div`,{className:`mt-2 flex items-center gap-1`,children:[o===`up`&&(0,_.jsx)(t,{className:`w-3 h-3 text-success`}),o===`down`&&(0,_.jsx)(t,{className:`w-3 h-3 rotate-180 text-destructive`}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s(o===`up`?`activity:debug.trendUp`:o===`down`?`activity:debug.trendDown`:`activity:debug.trendStable`)})]})]})}function y(){let{t:e}=d(),[l,f]=(0,g.useState)({fileWatcher:null,system:null,lastUpdated:null,error:null}),[y,C]=(0,g.useState)(!0),[w,T]=(0,g.useState)(2e3),E=(0,g.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch(`/debug/watcher-metrics`),fetch(`/debug/system`,{cache:`no-store`})]),n=null,r=e.headers.get(`content-type`)??``;if(e.ok&&r.includes(`application/json`)&&(n=await e.json()),!t.ok)throw Error(`System metrics request failed (${t.status})`);let i=await t.json();f({fileWatcher:n,system:i,lastUpdated:new Date,error:null})}catch(e){f(t=>({...t,error:e instanceof Error?e.message:s.t(`activity:debug.fetchFailed`)}))}finally{C(!1)}},[]);return(0,g.useEffect)(()=>{E();let e=setInterval(E,w);return()=>clearInterval(e)},[E,w]),(0,_.jsx)(`div`,{ref:h(`debug`),className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,_.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-col gap-5`,children:[(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold sm:text-xl`,children:[(0,_.jsx)(o,{className:`h-5 w-5 text-primary`}),e(`activity:debug.heading`)]}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e(`activity:debug.subtitle`)})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,_.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,_.jsx)(m,{className:`w-4 h-4 text-muted-foreground`}),(0,_.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e(`activity:debug.refreshLabel`)}),(0,_.jsxs)(`select`,{value:w,onChange:e=>T(Number(e.target.value)),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm`,children:[(0,_.jsx)(`option`,{value:1e3,children:`1s`}),(0,_.jsx)(`option`,{value:2e3,children:`2s`}),(0,_.jsx)(`option`,{value:5e3,children:`5s`}),(0,_.jsx)(`option`,{value:1e4,children:`10s`})]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{C(!0),E()},disabled:y,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground shadow-sm shadow-primary/15 hover:bg-primary/90 disabled:opacity-50`,children:[(0,_.jsx)(m,{className:`w-4 h-4 ${y?`animate-spin`:``}`}),e(`common:action.refresh`)]})]})]})}),l.lastUpdated&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-card/55 px-3 py-2 text-sm text-muted-foreground`,children:[(0,_.jsx)(r,{className:`w-4 h-4`}),e(`activity:debug.lastUpdated`,{time:l.lastUpdated.toLocaleTimeString()})]}),l.error&&(0,_.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-destructive/25 bg-destructive/10 p-4 text-destructive`,children:[(0,_.jsx)(c,{className:`w-5 h-5 flex-shrink-0`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`font-medium`,children:e(`activity:debug.fetchFailed`)}),(0,_.jsx)(`p`,{className:`text-sm opacity-80`,children:l.error})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(p,{className:`h-4 w-4 text-primary`}),e(`activity:debug.fileWatcher`)]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.watcherStatus`),value:l.fileWatcher?.watcherActive?e(`activity:debug.running`):e(`activity:debug.stopped`),icon:i,color:l.fileWatcher?.watcherActive?`text-success`:`text-destructive`}),(0,_.jsx)(v,{title:e(`activity:debug.activeProjects`),value:l.fileWatcher?.activeProjects??0,subtitle:e(`activity:debug.projectsWatched`),icon:a,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.fileChanges`),value:l.fileWatcher?.fileChangesDetected??0,subtitle:e(`activity:debug.totalDetected`),icon:u,color:`text-primary`,trend:`neutral`}),(0,_.jsx)(v,{title:e(`activity:debug.filesProcessed`),value:l.fileWatcher?.filesProcessed??0,subtitle:e(`activity:debug.afterHash`),icon:n,color:`text-success`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mt-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.broadcastsSent`),value:l.fileWatcher?.broadcastsSent??0,subtitle:e(`activity:debug.toClients`),icon:t,color:`text-success`}),(0,_.jsx)(v,{title:e(`activity:debug.debounceResets`),value:l.fileWatcher?.debounceResets??0,subtitle:e(`activity:debug.rapidWrites`),icon:m,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.avgDebounce`),value:`${(l.fileWatcher?.averageDebounceDelayMs??0).toFixed(1)}ms`,subtitle:e(`activity:debug.actualDelay`),icon:r,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.totalDelay`),value:`${(l.fileWatcher?.totalDebounceDelayMs??0).toFixed(0)}ms`,subtitle:e(`activity:debug.sumDelays`),icon:o,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(n,{className:`h-4 w-4 text-primary`}),e(`activity:debugDash.webuiServerProcess`)]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:e(`activity:debugDash.processRamRss`),value:b(l.system?.memoryUsage?.rss??0),subtitle:l.system?`PID ${l.system.pid}`:void 0,icon:i,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapUsed`),value:b(l.system?.memoryUsage?.heapUsed??0),subtitle:e(`activity:debug.jsHeap`),icon:o,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapTotal`),value:b(l.system?.memoryUsage?.heapTotal??0),subtitle:e(`activity:debug.totalHeap`),icon:o,color:`text-success`}),(0,_.jsx)(v,{title:e(`activity:debugDash.v8HeapLimit`),value:b(l.system?.heapLimit??0),subtitle:e(`activity:debugDash.oldSpaceCeiling`),icon:n,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debugDash.serverUptime`),value:S(l.system?.uptime??0),subtitle:e(`activity:debugDash.sinceProcessStart`),icon:r,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(u,{className:`h-4 w-4 text-primary`}),e(`activity:debugDash.liveWrongstackProcesses`)]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[980px] text-left text-xs`,children:[(0,_.jsx)(`thead`,{className:`border-b border-border/70 bg-muted/35 text-muted-foreground`,children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.surface`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.memory`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.growthSignal`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.workload`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.hqOfflineQueue`)}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`activity:debugDash.resourcesHotspot`)})]})}),(0,_.jsxs)(`tbody`,{children:[(l.system?.processes??[]).map(e=>{let t=[e.workload.messages===void 0?void 0:`${e.workload.messages} msgs`,e.workload.messageEstimatedTokens===void 0?void 0:`${e.workload.messageEstimatedTokens.toLocaleString()} ctx tokens`,e.workload.historyEntries===void 0?void 0:`${e.workload.historyMountedEntries??0}/${e.workload.historyEntries} history mounted`,e.workload.appRenders===void 0?void 0:`${e.workload.appRenders} renders`,e.workload.metricsDroppedObservations?`${e.workload.metricsDroppedObservations} metric drops`:void 0,e.workload.kanbanSyncActive?`kanban sync active`:void 0,e.workload.kanbanSyncPendingBoards?`${e.workload.kanbanSyncPendingBoards} kanban pending`:void 0,e.workload.kanbanSyncFullRescanPending?`kanban full rescan pending`:void 0,e.workload.kanbanSyncRemoteApplyQueued?`${e.workload.kanbanSyncPendingRemoteBoards??0} remote boards queued`:void 0,e.workload.kanbanSyncCoalescedRefreshes?`${e.workload.kanbanSyncCoalescedRefreshes} kanban coalesced`:void 0,e.workload.kanbanSupervisorSnapshots?`${e.workload.kanbanSupervisorSnapshots} supervised boards`:void 0,e.workload.kanbanSupervisorScheduledBoards?`${e.workload.kanbanSupervisorScheduledBoards} supervisor schedules`:void 0].filter(Boolean).join(` · `);return(0,_.jsxs)(`tr`,{className:`border-b border-border/50 align-top last:border-b-0`,children:[(0,_.jsxs)(`td`,{className:`px-3 py-3`,children:[(0,_.jsx)(`div`,{className:`font-medium text-foreground`,children:e.surface}),(0,_.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`PID `,e.pid]}),(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()})]}),(0,_.jsxs)(`td`,{className:`px-3 py-3 tabular-nums`,children:[(0,_.jsxs)(`div`,{children:[`RSS `,b(e.memory.rss)]}),(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`heap `,b(e.memory.heapUsed),e.memory.retainedHeapUsed===void 0?``:` · retained ${b(e.memory.retainedHeapUsed)}`]}),e.memory.nativeResidual===void 0?null:(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`native `,b(e.memory.nativeResidual)]}),e.memory.external===void 0?null:(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`external `,b(e.memory.external),e.memory.arrayBuffers===void 0?``:` · buffers ${b(e.memory.arrayBuffers)}`]})]}),(0,_.jsxs)(`td`,{className:`px-3 py-3 tabular-nums`,children:[(0,_.jsx)(`div`,{className:e.signal===`stable`?`text-success`:e.signal?`text-warning`:`text-muted-foreground`,children:e.signal??`sampling`}),(0,_.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`heap `,x(e.heapGrowthBytesPerHour)]}),(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`RSS `,x(e.rssGrowthBytesPerHour)]})]}),(0,_.jsx)(`td`,{className:`px-3 py-3 text-muted-foreground`,children:t||`—`}),(0,_.jsx)(`td`,{className:`px-3 py-3 tabular-nums`,children:e.hqQueue?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{children:[e.hqQueue.entries,` frames ·`,` `,b(e.hqQueue.bytes),` /`,` `,b(e.hqQueue.maxBytes)]}),(0,_.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[e.hqQueue.coalescedFrames,` coalesced ·`,` `,e.hqQueue.droppedFrames,` dropped`]}),e.hqSnapshot?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`snapshot`,` `,e.hqSnapshot.inFlight?`in-flight`:e.hqSnapshot.pending?`pending`:e.hqSnapshot.timerScheduled?`scheduled`:`idle`]}),(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`events`,` `,e.hqSnapshot.eventInFlight?`in-flight`:`idle`,` ·`,` `,e.hqSnapshot.pendingEvents,` pending ·`,` `,e.hqSnapshot.coalescedEvents,` coalesced ·`,` `,e.hqSnapshot.droppedEvents,` dropped`]})]}):null]}):(0,_.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,_.jsxs)(`td`,{className:`max-w-[360px] px-3 py-3 text-muted-foreground`,children:[(0,_.jsxs)(`div`,{children:[e.resources.active??0,` active`,e.resources.types?` · ${e.resources.types}`:``]}),e.profileTopStack?(0,_.jsxs)(`div`,{className:`mt-1 truncate`,title:e.profileTopStack,children:[e.profileTopStackBytes===void 0?``:`${b(e.profileTopStackBytes)} · `,e.profileTopStack]}):null]})]},e.pid)}),(l.system?.processes?.length??0)===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{className:`px-3 py-5 text-muted-foreground`,colSpan:6,children:e(`activity:debugDash.waitingForHeapFlightRecorderSamples`)})}):null]})]})})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(i,{className:`h-4 w-4 text-primary`}),e(`activity:debugDash.codebaseIndexServer`)]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:e(`activity:debugDash.connection`),value:l.system?.codebaseIndexServer?.health?.status??l.system?.codebaseIndexServer?.status??`unknown`,subtitle:l.system?.codebaseIndexServer?.pid?`PID ${l.system.codebaseIndexServer.pid} · RTT ${l.system.codebaseIndexServer.health?.latencyMs??`—`}ms`:`No connected project server`,icon:u,color:l.system?.codebaseIndexServer?.health?.status===`healthy`?`text-success`:l.system?.codebaseIndexServer?.status===`unresponsive`||l.system?.codebaseIndexServer?.status===`error`?`text-destructive`:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debugDash.indexRamRss`),value:b(l.system?.codebaseIndexServer?.health?.server?.memory.rss??0),subtitle:`Heap ${b(l.system?.codebaseIndexServer?.health?.server?.memory.heapUsed??0)} / ${b(l.system?.codebaseIndexServer?.health?.server?.memory.heapTotal??0)}`,icon:o,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debugDash.indexWorkload`),value:`${l.system?.codebaseIndexServer?.health?.server?.activeRequests??0} requests`,subtitle:`${l.system?.codebaseIndexServer?.health?.server?.activeWrites??0} writes · ${l.system?.codebaseIndexServer?.health?.server?.queuedWrites??0} queued`,icon:n,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debugDash.indexWatcher`),value:l.system?.codebaseIndexServer?.health?.server?.watchingExternal?`Active`:`Off`,subtitle:`${l.system?.codebaseIndexServer?.health?.server?.watchingClients??0} owners · ${l.system?.codebaseIndexServer?.health?.server?.pendingExternalFiles??0} pending`,icon:p,color:l.system?.codebaseIndexServer?.health?.server?.watchingExternal?`text-success`:`text-muted-foreground`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(u,{className:`h-4 w-4 text-primary`}),e(`activity:debug.rawData`)]}),(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsx)(`pre`,{className:`overflow-x-auto text-xs font-mono text-muted-foreground`,children:JSON.stringify({fileWatcher:l.fileWatcher,serverPid:l.system?.pid,serverMemory:l.system?.memoryUsage,serverHeapLimit:l.system?.heapLimit,serverUptime:l.system?.uptime,processes:l.system?.processes,codebaseIndexServer:l.system?.codebaseIndexServer},null,2)})})]})]})})}function b(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${(e/t**r).toFixed(1)} ${n[r]}`}function x(e){return e===void 0?`—`:`${e>0?`+`:e<0?`−`:``}${b(Math.abs(e))}/h`}function S(e){return e<60?`${e.toFixed(0)}s`:e<3600?`${(e/60).toFixed(1)}m`:`${(e/3600).toFixed(1)}h`}export{y as DebugDashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_t as t}from"./ws-client-D-d32pHb.js";import{$t as n,Bn as r,Ei as i,ft as a,io as o,oo as s,pa as c,sn as l,to as u,ut as d}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{t as f}from"./useWebSocket-B4er0zlV.js";import{t as p}from"./utils-DQ9Exx8j.js";import{o as m}from"./view-navigation-DPOY0lyt.js";import{d as h}from"./index-b_i-YcNT.js";var g=e(s(),1);function _(e,t,n){return e<t?t:e>n?n:e}function v(e){let t=/^oklch\(\s*([^)]+)\)$/i.exec(e.trim());if(!t?.[1])return null;let n=(t[1].split(`/`)[0]??``).trim().split(/\s+/);if(n.length<3||!n[0]||!n[1]||!n[2])return null;let r=n[0].endsWith(`%`)?Number.parseFloat(n[0])/100:Number.parseFloat(n[0]),i=n[1].endsWith(`%`)?Number.parseFloat(n[1])/100*.4:Number.parseFloat(n[1]),a=Number.parseFloat(n[2].replace(/deg$/i,``));return[r,i,a].every(Number.isFinite)?[_(r,0,1),Math.max(0,i),a]:null}function y(e){return _(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055,0,1)}function b(e){return Math.round(e*255).toString(16).padStart(2,`0`)}function x(e){let t=v(e);if(!t)return null;let[n,r,i]=t,a=i*Math.PI/180,o=r*Math.cos(a),s=r*Math.sin(a),c=n+.3963377774*o+.2158037573*s,l=n-.1055613458*o-.0638541728*s,u=n-.0894841775*o-1.291485548*s,d=c**3,f=l**3,p=u**3,m=4.0767416621*d-3.3077115913*f+.2309699292*p,h=-1.2684380046*d+2.6097574011*f-.3413193965*p,g=-.0041960863*d-.7034186147*f+1.707614701*p;return`#${b(y(m))}${b(y(h))}${b(y(g))}`}function S(e){let t=e.trim(),n=x(t);if(n)return n.toLowerCase();let r=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(t);if(r?.[1])return`#${r[1].toLowerCase()}`;let i=/^#([0-9a-f]{3})$/i.exec(t);return i?.[1]?`#${i[1].split(``).map(e=>e+e).join(``).toLowerCase()}`:null}var C=d(),w=[`web`,`react-native`,`flutter`,`swiftui`,`compose`],T=[`primary`,`accent`,`bg`,`surface`,`fg`,`border`];function E(e,t,n){let r={...e};for(let[e,i]of Object.entries(t))e.startsWith(`light.`)?n===`light`&&(r[e.slice(6)]=i):e.startsWith(`dark.`)?n===`dark`&&(r[e.slice(5)]=i):r[e]=i;return r}function D({t:e,label:t}){let{t:n}=u(),r=e.bg??`#fff`,i=e.surface??r,a=e.fg??`#111`,o=e.muted??a,s=e.primary??`#3b82f6`,c=e.accent??s,l=e.border??o,d=e[`radius-md`]??e.radius??`0.5rem`,f=e[`font-sans`]??e.fontSans??`system-ui, sans-serif`,p=e[`font-display`]??e.fontDisplay??f,m=e[`shadow-2`]??(e.shadow&&e.shadow!==`none`?e.shadow:void 0);return(0,C.jsxs)(`div`,{style:{background:r,color:a,fontFamily:f},className:`flex min-w-0 flex-col gap-2 overflow-hidden p-3`,children:[(0,C.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide`,style:{color:o},children:t}),(0,C.jsxs)(`div`,{style:{background:i,border:`1px solid ${l}`,borderRadius:d,boxShadow:m},className:`flex min-w-0 flex-col gap-2 p-3`,children:[(0,C.jsx)(`div`,{style:{fontFamily:p},className:`text-base font-bold leading-tight`,children:n(`activity:designStudio.aaHeading`)}),(0,C.jsx)(`div`,{className:`text-[11px] leading-snug`,style:{color:o},children:n(`activity:designStudio.theQuickBrownFoxJumpsOver`)}),(0,C.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5`,children:[(0,C.jsx)(`span`,{style:{background:s,color:r,borderRadius:d},className:`shrink-0 px-2.5 py-1 text-[10px] font-semibold`,children:n(`activity:designStudio.primary`)}),(0,C.jsx)(`span`,{style:{border:`1px solid ${l}`,color:a,borderRadius:d},className:`shrink-0 px-2 py-1 text-[10px]`,children:n(`activity:designStudio.ghost`)}),(0,C.jsx)(`span`,{style:{background:c,color:r,borderRadius:`999px`},className:`ml-auto shrink-0 px-2 py-0.5 text-[9px] font-semibold`,children:n(`activity:designStudio.badge`)})]}),(0,C.jsx)(`div`,{style:{border:`1px solid ${l}`,borderRadius:d,color:o},className:`text-[10px] px-2 py-1.5 mt-1`,children:n(`activity:designStudio.inputField`)})]})]})}function O({kit:e,overrides:t,onSet:n}){let[r,i]=(0,g.useState)(`light`),{t:a}=u(),o=E(r===`light`?e.light:e.dark,t,r);return(0,C.jsxs)(`div`,{className:`mt-1 rounded-lg border border-border/60 p-2 bg-muted/30`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,C.jsx)(`span`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:a(`activity:design.colors`)}),(0,C.jsx)(`div`,{className:`ml-auto inline-flex rounded border border-border/60 overflow-hidden`,children:[`light`,`dark`].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:p(`text-[10px] px-1.5 py-0.5`,r===e?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e},e))})]}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>o[e]).map(e=>{let t=S(o[e]??``)??`#000000`;return(0,C.jsxs)(`label`,{className:`flex min-w-[2rem] flex-col items-center gap-0.5`,title:`${e}: ${o[e]}`,children:[(0,C.jsx)(`input`,{type:`color`,value:t,onChange:t=>n(`${r}.${e}`,t.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border border-border/60 p-0`}),(0,C.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:e})]},e)})})]})}function k({onTune:e}){let{t}=u(),[n,r]=(0,g.useState)(``),i=({label:t,knob:n,values:r})=>(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`w-16 shrink-0 text-[9px] uppercase text-muted-foreground`,children:t}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(t=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>e({[n]:t}),className:`rounded border border-border/60 px-1.5 py-0.5 text-[10px] hover:bg-primary hover:text-primary-foreground`,children:t},t))})]});return(0,C.jsxs)(`div`,{className:`mt-1 flex flex-col gap-1.5 rounded-lg border border-border/60 bg-muted/30 p-2`,children:[(0,C.jsx)(`span`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:t(`activity:designStudio.tune`)}),(0,C.jsx)(i,{label:t(`activity:designStudio.radius`),knob:`radius`,values:[`none`,`sm`,`md`,`lg`,`xl`,`full`]}),(0,C.jsx)(i,{label:t(`activity:designStudio.density`),knob:`density`,values:[`compact`,`cozy`,`comfortable`]}),(0,C.jsx)(i,{label:t(`activity:designStudio.motion`),knob:`motion`,values:[`snappy`,`smooth`,`none`]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`w-16 shrink-0 text-[9px] uppercase text-muted-foreground`,children:t(`activity:designStudio.font`)}),(0,C.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:t=>{t.key===`Enter`&&n.trim()&&e({font:n.trim()})},placeholder:t(`activity:designStudio.spaceGrotesk`),className:`h-6 min-w-0 flex-1 rounded border border-border/60 bg-background/70 px-1.5 text-[10px]`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>n.trim()&&e({font:n.trim()}),className:`rounded border border-border/60 px-1.5 py-0.5 text-[10px] hover:bg-muted`,children:t(`activity:designStudio.set`)})]})]})}function A({className:e}){let{client:s}=f(),d=t(),{t:_}=u(),[v,y]=(0,g.useState)([]),[b,x]=(0,g.useState)(null),[S,T]=(0,g.useState)({}),[A,j]=(0,g.useState)(`web`),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!s)return;let e=e=>{let t=e.payload?.sessionId;return typeof t!=`string`||t.length===0?d!==null:t!==d},t=t=>{if(e(t))return;let n=t.payload;y(n?.kits??[]),x(n?.activeKit??null),T(n?.overrides??{})},n=t=>{if(e(t))return;let n=t.payload;n?.ok&&n.kit&&(x(n.kit),T(n.overrides??{}))},r=t=>{if(e(t))return;let n=t.payload;n?.ok&&n.overrides&&T(n.overrides)},i=t=>{if(e(t))return;let n=t.payload;n?.ok&&n.overrides?(T(n.overrides),F(`Tuned`)):n?.error&&F(`Tune failed: ${n.error}`)},a=t=>{if(e(t))return;let n=t.payload;n?.ok&&n.kit&&(x(n.kit),T(n.overrides??{}),F(`Swapped to ${n.kit}`))},c=t=>{if(e(t))return;let n=t.payload;F(n?.ok?o.t(`activity:design.wrote`,{path:n.path}):o.t(`activity:design.materializeFailed`,{error:n?.error??`error`}))},l=t=>{if(e(t))return;let n=t.payload;if(!n?.ok){F(o.t(`activity:design.verifyError`,{error:n?.error??`error`}));return}let r=Math.round((n.score??1)*100);F(n.violationCount?o.t(`activity:design.verifyOffPalette`,{pct:r,count:n.violationCount,files:n.filesScanned}):o.t(`activity:design.verifyClean`,{files:n.filesScanned}))};return s.on(`design.list`,t),s.on(`design.use`,n),s.on(`design.set`,r),s.on(`design.tune`,i),s.on(`design.swap`,a),s.on(`design.materialize`,c),s.on(`design.verify`,l),s.send({type:`design.list`,payload:s.withSession({})}),()=>{s.off(`design.list`,t),s.off(`design.use`,n),s.off(`design.set`,r),s.off(`design.tune`,i),s.off(`design.swap`,a),s.off(`design.materialize`,c),s.off(`design.verify`,l)}},[s,d]);let I=(0,g.useCallback)(e=>s?.send({type:`design.use`,payload:s.withSession({kit:e,stack:A})}),[s,A]),L=(0,g.useCallback)((e,t)=>{T(n=>({...n,[e]:t})),s?.send({type:`design.set`,payload:s.withSession({overrides:{[e]:t}})})},[s]),R=(0,g.useCallback)(e=>s?.send({type:`design.tune`,payload:s.withSession({tune:e})}),[s]),z=(0,g.useCallback)(()=>{F(o.t(`activity:design.writing`)),s?.send({type:`design.materialize`,payload:s.withSession({stack:A})})},[s,A]),B=(0,g.useCallback)(()=>{F(o.t(`activity:design.scanning`)),s?.send({type:`design.verify`,payload:s.withSession({})})},[s]),V=(0,g.useMemo)(()=>{let e=M.trim().toLowerCase();return[...e?v.filter(t=>t.id.includes(e)||t.name.toLowerCase().includes(e)||t.aesthetic.toLowerCase().includes(e)||t.tags.some(t=>t.includes(e))):v].sort((e,t)=>e.name.localeCompare(t.name))},[v,M]);return(0,C.jsxs)(`div`,{className:p(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)]`,e),children:[(0,C.jsx)(`div`,{className:`border-b border-border/60 p-3`,children:(0,C.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-3 shadow-sm`,children:(0,C.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center`,children:[(0,C.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,C.jsx)(r,{className:`h-4 w-4`})}),(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`h2`,{className:`truncate text-sm font-semibold`,children:_(`activity:design.heading`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(`activity:design.kitsCount`,{count:V.length})})]})]}),(0,C.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2 sm:flex-row sm:items-center lg:justify-end`,children:[(0,C.jsxs)(`label`,{className:`relative min-w-0 flex-1 sm:max-w-xs`,children:[(0,C.jsx)(l,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/70`}),(0,C.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),placeholder:_(`activity:design.searchPlaceholder`),className:`h-9 w-full rounded-md border border-border/70 bg-background/70 pl-8 pr-3 text-sm shadow-sm outline-none transition focus:border-primary/40 focus:ring-2 focus:ring-ring/30`})]}),(0,C.jsx)(`select`,{value:A,onChange:e=>j(e.target.value),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm shadow-sm`,title:_(`activity:design.stackTitle`),children:w.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))}),P&&(0,C.jsx)(`span`,{className:`min-w-0 truncate rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[11px] text-muted-foreground sm:max-w-56`,children:P}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>m(`chat`),className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,title:_(`common:action.close`),children:(0,C.jsx)(a,{className:`h-4 w-4`})})]})]})})}),(0,C.jsx)(`div`,{ref:h(`design-gallery`),className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3 sm:p-4`,children:V.length===0?(0,C.jsxs)(`div`,{className:`ws-surface mx-auto mt-8 flex max-w-md flex-col items-center gap-3 rounded-xl p-6 text-center text-muted-foreground`,children:[(0,C.jsx)(r,{className:`h-8 w-8 text-primary/60`}),(0,C.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:_(`activity:design.kitsCount`,{count:0})}),(0,C.jsx)(`p`,{className:`text-xs`,children:_(`activity:design.searchPlaceholder`)})]}):(0,C.jsx)(`div`,{className:`grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(min(100%,20rem),1fr))]`,children:V.map(e=>{let t=b===e.id,r=t?S:{};return(0,C.jsxs)(`div`,{className:p(`flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card/75 shadow-sm`,t?`border-primary/60 ring-1 ring-primary/30`:`border-border/70`),children:[(0,C.jsxs)(`div`,{className:`grid min-h-[12rem] grid-cols-1 sm:grid-cols-2`,children:[(0,C.jsx)(D,{t:E(e.light,r,`light`),label:_(`activity:designStudio.light`)}),(0,C.jsx)(D,{t:E(e.dark,r,`dark`),label:_(`activity:designStudio.dark`)})]}),(0,C.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 border-t border-border/60 bg-card p-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:e.name}),(0,C.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e.id}),t&&(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-semibold uppercase text-primary ml-auto`,children:[(0,C.jsx)(c,{className:`w-3 h-3`}),` `,_(`activity:design.active`)]})]}),(0,C.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug`,children:e.aesthetic}),(0,C.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>I(e.id),className:p(`rounded-md px-2.5 py-1 text-[11px] font-medium transition`,t?`bg-primary/10 text-primary`:`bg-primary text-primary-foreground hover:opacity-90`),children:_(t?`activity:design.reapply`:`activity:design.use`)}),t&&(0,C.jsxs)(`button`,{type:`button`,onClick:z,className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium hover:bg-muted`,title:_(`activity:design.materializeTitle`,{stack:A}),children:[(0,C.jsx)(i,{className:`w-3 h-3`}),` `,_(`activity:design.materialize`)]}),t&&(0,C.jsxs)(`button`,{type:`button`,onClick:B,className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium hover:bg-muted`,title:_(`activity:design.verifyTitle`),children:[(0,C.jsx)(n,{className:`w-3 h-3`}),` `,_(`activity:design.verify`)]}),(0,C.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[10px] text-muted-foreground`,children:e.bestFor})]}),t&&(0,C.jsx)(O,{kit:e,overrides:r,onSet:L}),t&&(0,C.jsx)(k,{onTune:R})]})]},e.id)})})})]})}export{A as DesignGalleryView};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_t as t}from"./ws-client-D-d32pHb.js";import{$t as n,Bn as r,Ei as i,ft as a,io as o,oo as s,pa as c,sn as l,to as u,ut as d}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{t as f}from"./useWebSocket-VIItbvVK.js";import{t as p}from"./utils-DQ9Exx8j.js";import{o as m}from"./view-navigation-DPOY0lyt.js";import{d as h}from"./index-DbprKWmG.js";var g=e(s(),1);function _(e,t,n){return e<t?t:e>n?n:e}function v(e){let t=/^oklch\(\s*([^)]+)\)$/i.exec(e.trim());if(!t?.[1])return null;let n=(t[1].split(`/`)[0]??``).trim().split(/\s+/);if(n.length<3||!n[0]||!n[1]||!n[2])return null;let r=n[0].endsWith(`%`)?Number.parseFloat(n[0])/100:Number.parseFloat(n[0]),i=n[1].endsWith(`%`)?Number.parseFloat(n[1])/100*.4:Number.parseFloat(n[1]),a=Number.parseFloat(n[2].replace(/deg$/i,``));return[r,i,a].every(Number.isFinite)?[_(r,0,1),Math.max(0,i),a]:null}function y(e){return _(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055,0,1)}function b(e){return Math.round(e*255).toString(16).padStart(2,`0`)}function x(e){let t=v(e);if(!t)return null;let[n,r,i]=t,a=i*Math.PI/180,o=r*Math.cos(a),s=r*Math.sin(a),c=n+.3963377774*o+.2158037573*s,l=n-.1055613458*o-.0638541728*s,u=n-.0894841775*o-1.291485548*s,d=c**3,f=l**3,p=u**3,m=4.0767416621*d-3.3077115913*f+.2309699292*p,h=-1.2684380046*d+2.6097574011*f-.3413193965*p,g=-.0041960863*d-.7034186147*f+1.707614701*p;return`#${b(y(m))}${b(y(h))}${b(y(g))}`}function S(e){let t=e.trim(),n=x(t);if(n)return n.toLowerCase();let r=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(t);if(r?.[1])return`#${r[1].toLowerCase()}`;let i=/^#([0-9a-f]{3})$/i.exec(t);return i?.[1]?`#${i[1].split(``).map(e=>e+e).join(``).toLowerCase()}`:null}var C=d(),w=[`web`,`react-native`,`flutter`,`swiftui`,`compose`],T=[`primary`,`accent`,`bg`,`surface`,`fg`,`border`];function E(e,t,n){let r={...e};for(let[e,i]of Object.entries(t))e.startsWith(`light.`)?n===`light`&&(r[e.slice(6)]=i):e.startsWith(`dark.`)?n===`dark`&&(r[e.slice(5)]=i):r[e]=i;return r}function D({t:e,label:t}){let{t:n}=u(),r=e.bg??`#fff`,i=e.surface??r,a=e.fg??`#111`,o=e.muted??a,s=e.primary??`#3b82f6`,c=e.accent??s,l=e.border??o,d=e[`radius-md`]??e.radius??`0.5rem`,f=e[`font-sans`]??e.fontSans??`system-ui, sans-serif`,p=e[`font-display`]??e.fontDisplay??f,m=e[`shadow-2`]??(e.shadow&&e.shadow!==`none`?e.shadow:void 0);return(0,C.jsxs)(`div`,{style:{background:r,color:a,fontFamily:f},className:`flex min-w-0 flex-col gap-2 overflow-hidden p-3`,children:[(0,C.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide`,style:{color:o},children:t}),(0,C.jsxs)(`div`,{style:{background:i,border:`1px solid ${l}`,borderRadius:d,boxShadow:m},className:`flex min-w-0 flex-col gap-2 p-3`,children:[(0,C.jsx)(`div`,{style:{fontFamily:p},className:`text-base font-bold leading-tight`,children:n(`activity:designStudio.aaHeading`)}),(0,C.jsx)(`div`,{className:`text-[11px] leading-snug`,style:{color:o},children:n(`activity:designStudio.theQuickBrownFoxJumpsOver`)}),(0,C.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5`,children:[(0,C.jsx)(`span`,{style:{background:s,color:r,borderRadius:d},className:`shrink-0 px-2.5 py-1 text-[10px] font-semibold`,children:n(`activity:designStudio.primary`)}),(0,C.jsx)(`span`,{style:{border:`1px solid ${l}`,color:a,borderRadius:d},className:`shrink-0 px-2 py-1 text-[10px]`,children:n(`activity:designStudio.ghost`)}),(0,C.jsx)(`span`,{style:{background:c,color:r,borderRadius:`999px`},className:`ml-auto shrink-0 px-2 py-0.5 text-[9px] font-semibold`,children:n(`activity:designStudio.badge`)})]}),(0,C.jsx)(`div`,{style:{border:`1px solid ${l}`,borderRadius:d,color:o},className:`text-[10px] px-2 py-1.5 mt-1`,children:n(`activity:designStudio.inputField`)})]})]})}function O({kit:e,overrides:t,onSet:n}){let[r,i]=(0,g.useState)(`light`),{t:a}=u(),o=E(r===`light`?e.light:e.dark,t,r);return(0,C.jsxs)(`div`,{className:`mt-1 rounded-lg border border-border/60 p-2 bg-muted/30`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,C.jsx)(`span`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:a(`activity:design.colors`)}),(0,C.jsx)(`div`,{className:`ml-auto inline-flex rounded border border-border/60 overflow-hidden`,children:[`light`,`dark`].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:p(`text-[10px] px-1.5 py-0.5`,r===e?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e},e))})]}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>o[e]).map(e=>{let t=S(o[e]??``)??`#000000`;return(0,C.jsxs)(`label`,{className:`flex min-w-[2rem] flex-col items-center gap-0.5`,title:`${e}: ${o[e]}`,children:[(0,C.jsx)(`input`,{type:`color`,value:t,onChange:t=>n(`${r}.${e}`,t.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border border-border/60 p-0`}),(0,C.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:e})]},e)})})]})}function k({onTune:e}){let{t}=u(),[n,r]=(0,g.useState)(``),i=({label:t,knob:n,values:r})=>(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`w-16 shrink-0 text-[9px] uppercase text-muted-foreground`,children:t}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(t=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>e({[n]:t}),className:`rounded border border-border/60 px-1.5 py-0.5 text-[10px] hover:bg-primary hover:text-primary-foreground`,children:t},t))})]});return(0,C.jsxs)(`div`,{className:`mt-1 flex flex-col gap-1.5 rounded-lg border border-border/60 bg-muted/30 p-2`,children:[(0,C.jsx)(`span`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:t(`activity:designStudio.tune`)}),(0,C.jsx)(i,{label:t(`activity:designStudio.radius`),knob:`radius`,values:[`none`,`sm`,`md`,`lg`,`xl`,`full`]}),(0,C.jsx)(i,{label:t(`activity:designStudio.density`),knob:`density`,values:[`compact`,`cozy`,`comfortable`]}),(0,C.jsx)(i,{label:t(`activity:designStudio.motion`),knob:`motion`,values:[`snappy`,`smooth`,`none`]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`w-16 shrink-0 text-[9px] uppercase text-muted-foreground`,children:t(`activity:designStudio.font`)}),(0,C.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:t=>{t.key===`Enter`&&n.trim()&&e({font:n.trim()})},placeholder:t(`activity:designStudio.spaceGrotesk`),className:`h-6 min-w-0 flex-1 rounded border border-border/60 bg-background/70 px-1.5 text-[10px]`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>n.trim()&&e({font:n.trim()}),className:`rounded border border-border/60 px-1.5 py-0.5 text-[10px] hover:bg-muted`,children:t(`activity:designStudio.set`)})]})]})}function A({className:e}){let{client:s}=f(),d=t(),{t:_}=u(),[v,y]=(0,g.useState)([]),[b,x]=(0,g.useState)(null),[S,T]=(0,g.useState)({}),[A,j]=(0,g.useState)(`web`),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!s)return;let e=e=>{let t=e.payload?.sessionId;return typeof t!=`string`||t.length===0?d!==null:t!==d},t=t=>{if(e(t))return;let n=t.payload;y(n?.kits??[]),x(n?.activeKit??null),T(n?.overrides??{})},n=t=>{if(e(t))return;let n=t.payload;n?.ok&&n.kit&&(x(n.kit),T(n.overrides??{}))},r=t=>{if(e(t))return;let n=t.payload;n?.ok&&n.overrides&&T(n.overrides)},i=t=>{if(e(t))return;let n=t.payload;n?.ok&&n.overrides?(T(n.overrides),F(`Tuned`)):n?.error&&F(`Tune failed: ${n.error}`)},a=t=>{if(e(t))return;let n=t.payload;n?.ok&&n.kit&&(x(n.kit),T(n.overrides??{}),F(`Swapped to ${n.kit}`))},c=t=>{if(e(t))return;let n=t.payload;F(n?.ok?o.t(`activity:design.wrote`,{path:n.path}):o.t(`activity:design.materializeFailed`,{error:n?.error??`error`}))},l=t=>{if(e(t))return;let n=t.payload;if(!n?.ok){F(o.t(`activity:design.verifyError`,{error:n?.error??`error`}));return}let r=Math.round((n.score??1)*100);F(n.violationCount?o.t(`activity:design.verifyOffPalette`,{pct:r,count:n.violationCount,files:n.filesScanned}):o.t(`activity:design.verifyClean`,{files:n.filesScanned}))};return s.on(`design.list`,t),s.on(`design.use`,n),s.on(`design.set`,r),s.on(`design.tune`,i),s.on(`design.swap`,a),s.on(`design.materialize`,c),s.on(`design.verify`,l),s.send({type:`design.list`,payload:s.withSession({})}),()=>{s.off(`design.list`,t),s.off(`design.use`,n),s.off(`design.set`,r),s.off(`design.tune`,i),s.off(`design.swap`,a),s.off(`design.materialize`,c),s.off(`design.verify`,l)}},[s,d]);let I=(0,g.useCallback)(e=>s?.send({type:`design.use`,payload:s.withSession({kit:e,stack:A})}),[s,A]),L=(0,g.useCallback)((e,t)=>{T(n=>({...n,[e]:t})),s?.send({type:`design.set`,payload:s.withSession({overrides:{[e]:t}})})},[s]),R=(0,g.useCallback)(e=>s?.send({type:`design.tune`,payload:s.withSession({tune:e})}),[s]),z=(0,g.useCallback)(()=>{F(o.t(`activity:design.writing`)),s?.send({type:`design.materialize`,payload:s.withSession({stack:A})})},[s,A]),B=(0,g.useCallback)(()=>{F(o.t(`activity:design.scanning`)),s?.send({type:`design.verify`,payload:s.withSession({})})},[s]),V=(0,g.useMemo)(()=>{let e=M.trim().toLowerCase();return[...e?v.filter(t=>t.id.includes(e)||t.name.toLowerCase().includes(e)||t.aesthetic.toLowerCase().includes(e)||t.tags.some(t=>t.includes(e))):v].sort((e,t)=>e.name.localeCompare(t.name))},[v,M]);return(0,C.jsxs)(`div`,{className:p(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)]`,e),children:[(0,C.jsx)(`div`,{className:`border-b border-border/60 p-3`,children:(0,C.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-3 shadow-sm`,children:(0,C.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center`,children:[(0,C.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,C.jsx)(r,{className:`h-4 w-4`})}),(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`h2`,{className:`truncate text-sm font-semibold`,children:_(`activity:design.heading`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(`activity:design.kitsCount`,{count:V.length})})]})]}),(0,C.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2 sm:flex-row sm:items-center lg:justify-end`,children:[(0,C.jsxs)(`label`,{className:`relative min-w-0 flex-1 sm:max-w-xs`,children:[(0,C.jsx)(l,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/70`}),(0,C.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),placeholder:_(`activity:design.searchPlaceholder`),className:`h-9 w-full rounded-md border border-border/70 bg-background/70 pl-8 pr-3 text-sm shadow-sm outline-none transition focus:border-primary/40 focus:ring-2 focus:ring-ring/30`})]}),(0,C.jsx)(`select`,{value:A,onChange:e=>j(e.target.value),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm shadow-sm`,title:_(`activity:design.stackTitle`),children:w.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))}),P&&(0,C.jsx)(`span`,{className:`min-w-0 truncate rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[11px] text-muted-foreground sm:max-w-56`,children:P}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>m(`chat`),className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,title:_(`common:action.close`),children:(0,C.jsx)(a,{className:`h-4 w-4`})})]})]})})}),(0,C.jsx)(`div`,{ref:h(`design-gallery`),className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3 sm:p-4`,children:V.length===0?(0,C.jsxs)(`div`,{className:`ws-surface mx-auto mt-8 flex max-w-md flex-col items-center gap-3 rounded-xl p-6 text-center text-muted-foreground`,children:[(0,C.jsx)(r,{className:`h-8 w-8 text-primary/60`}),(0,C.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:_(`activity:design.kitsCount`,{count:0})}),(0,C.jsx)(`p`,{className:`text-xs`,children:_(`activity:design.searchPlaceholder`)})]}):(0,C.jsx)(`div`,{className:`grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(min(100%,20rem),1fr))]`,children:V.map(e=>{let t=b===e.id,r=t?S:{};return(0,C.jsxs)(`div`,{className:p(`flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card/75 shadow-sm`,t?`border-primary/60 ring-1 ring-primary/30`:`border-border/70`),children:[(0,C.jsxs)(`div`,{className:`grid min-h-[12rem] grid-cols-1 sm:grid-cols-2`,children:[(0,C.jsx)(D,{t:E(e.light,r,`light`),label:_(`activity:designStudio.light`)}),(0,C.jsx)(D,{t:E(e.dark,r,`dark`),label:_(`activity:designStudio.dark`)})]}),(0,C.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 border-t border-border/60 bg-card p-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:e.name}),(0,C.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e.id}),t&&(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-semibold uppercase text-primary ml-auto`,children:[(0,C.jsx)(c,{className:`w-3 h-3`}),` `,_(`activity:design.active`)]})]}),(0,C.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug`,children:e.aesthetic}),(0,C.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>I(e.id),className:p(`rounded-md px-2.5 py-1 text-[11px] font-medium transition`,t?`bg-primary/10 text-primary`:`bg-primary text-primary-foreground hover:opacity-90`),children:_(t?`activity:design.reapply`:`activity:design.use`)}),t&&(0,C.jsxs)(`button`,{type:`button`,onClick:z,className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium hover:bg-muted`,title:_(`activity:design.materializeTitle`,{stack:A}),children:[(0,C.jsx)(i,{className:`w-3 h-3`}),` `,_(`activity:design.materialize`)]}),t&&(0,C.jsxs)(`button`,{type:`button`,onClick:B,className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium hover:bg-muted`,title:_(`activity:design.verifyTitle`),children:[(0,C.jsx)(n,{className:`w-3 h-3`}),` `,_(`activity:design.verify`)]}),(0,C.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[10px] text-muted-foreground`,children:e.bestFor})]}),t&&(0,C.jsx)(O,{kit:e,overrides:r,onSet:L}),t&&(0,C.jsx)(k,{onTune:R})]})]},e.id)})})})]})}export{A as DesignGalleryView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Dn as t,Dt as n,Ht as r,Ji as i,Li as a,Nn as o,On as s,Ui as c,Yi as l,dt as u,fr as d,ft as f,gn as p,ia as m,io as h,oo as g,pn as _,to as v,ut as y,vn as b,wr as x,wt as S}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{t as C}from"./useWebSocket-B4er0zlV.js";import{t as w}from"./utils-DQ9Exx8j.js";import{t as T}from"./chat-store-DIcs826A.js";import{h as E,m as D,t as O}from"./stores-CNuMLG8X.js";import{o as k}from"./view-navigation-DPOY0lyt.js";import{t as A}from"./button-DNyYztcH.js";import{a as j}from"./ConfirmModal-gukSikBD.js";import{n as M,r as ee,t as te}from"./index-b_i-YcNT.js";var N=e(g(),1),P=y(),F={pending:{icon:(0,P.jsx)(i,{className:`w-4 h-4`}),color:`text-muted-foreground`},in_progress:{icon:(0,P.jsx)(c,{className:`w-4 h-4 animate-spin`}),color:`text-primary`},blocked:{icon:(0,P.jsx)(o,{className:`w-4 h-4`}),color:`text-warning`},failed:{icon:(0,P.jsx)(l,{className:`w-4 h-4`}),color:`text-destructive`},review:{icon:(0,P.jsx)(p,{className:`w-4 h-4`}),color:`text-info`},completed:{icon:(0,P.jsx)(m,{className:`w-4 h-4`}),color:`text-success`}},I={critical:`bg-destructive/15 text-destructive`,high:`bg-warning/15 text-warning`,medium:`bg-info/15 text-info`,low:`bg-muted text-muted-foreground`},L={feature:`bg-success/15 text-success`,bugfix:`bg-destructive/15 text-destructive`,refactor:`bg-primary/15 text-primary`,docs:`bg-info/15 text-info`,test:`bg-primary/15 text-primary`,chore:`bg-muted text-muted-foreground`};function R(e){if(!e)return``;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60),r=t%60;return r>0?`${n}h ${r}m`:`${n}h`}function z({task:e,onStatusChange:t,onRetry:n,agents:r,onAssign:i,compact:a,className:o}){let{t:s}=v(),l=F[e.status],[u,d]=(0,N.useState)(!1),f=e.status===`in_progress`;return(0,P.jsxs)(`div`,{className:w(`w-full text-left rounded-lg border p-3 transition-all hover:shadow-sm`,f?`border-primary/40 bg-primary/5`:e.status===`completed`?`border-success/35 bg-success/6`:e.status===`failed`?`border-destructive/40 bg-destructive/5`:`border-border bg-card`,o),children:[(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,P.jsx)(`span`,{className:w(`mt-0.5`,l.color),role:`img`,"aria-label":f?s(`common:status.inProgress`):void 0,children:l.icon}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,P.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,I[e.priority]),children:e.priority}),(0,P.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,L[e.type]),children:e.type})]}),e.description&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 line-clamp-2`,children:e.description})]})]}),e.assignee&&(0,P.jsxs)(`div`,{className:w(`mt-2 inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium`,f?`bg-primary/15 text-primary`:`bg-muted text-muted-foreground`),children:[f&&(0,P.jsx)(c,{className:`w-3 h-3 animate-spin`,"aria-label":s(`common:status.working`)}),(0,P.jsx)(`span`,{children:e.assignee})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 mt-2 text-xs text-muted-foreground`,children:[e.estimateHours?(0,P.jsxs)(`span`,{children:[`~`,e.estimateHours,`h`]}):null,e.actualHours?(0,P.jsxs)(`span`,{children:[`• `,e.actualHours,`h`]}):null,e.startedAt?(0,P.jsxs)(`span`,{children:[`• `,R(Date.now()-e.startedAt)]}):null]}),e.tags.length>0&&(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.tags.map(e=>(0,P.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))}),!a&&(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 mt-2`,children:[t&&e.status!==`in_progress`&&e.status!==`completed`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`in_progress`),className:`px-2 py-0.5 text-[10px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,children:s(`activity:task.start`)}),t&&e.status===`in_progress`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`completed`),className:`px-2 py-0.5 text-[10px] rounded bg-success/15 text-success hover:bg-success/25 transition-colors`,children:s(`activity:task.complete`)}),n&&(e.status===`failed`||e.status===`completed`)&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,children:[(0,P.jsx)(p,{className:`w-3 h-3`}),` `,s(`activity:task.retry`)]}),i&&r&&r.length>0&&(u?(0,P.jsxs)(`select`,{defaultValue:e.assignee??``,onChange:t=>{i(e.id,t.target.value),d(!1)},onBlur:()=>d(!1),className:`px-1 py-0.5 text-[10px] rounded border border-border bg-card`,children:[(0,P.jsx)(`option`,{value:``,children:s(`activity:task.unassigned`)}),r.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]}):(0,P.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,title:s(`activity:task.assignTitle`),children:[(0,P.jsx)(S,{className:`w-3 h-3`}),` `,s(`activity:task.assign`)]}))]})]})}var B=[{key:`pending`,match:[`pending`,`blocked`]},{key:`in_progress`,match:[`in_progress`]},{key:`review`,match:[`review`]},{key:`failed`,match:[`failed`]},{key:`completed`,match:[`completed`]}],V={pending:`bg-muted text-muted-foreground`,ready:`bg-info/15 text-info`,running:`bg-primary/15 text-primary`,paused:`bg-warning/15 text-warning`,completed:`bg-success/15 text-success`,failed:`bg-destructive/15 text-destructive`,skipped:`bg-muted text-muted-foreground`};function ne(){let{client:e}=C(),{t}=v(),n=D(e=>e.phases),r=D(e=>e.multiBoard),[i,o]=(0,N.useState)(`phase`),[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(0),p=Math.min(d,Math.max(0,n.length-1)),m=r?n[p]:void 0,h=(0,N.useMemo)(()=>n.flatMap(e=>(e.tasks??[]).map(t=>({...t,phaseId:e.id}))),[n]),g=(0,N.useMemo)(()=>[...new Set(h.map(e=>e.assignee).filter(e=>!!e))],[h]),y=(0,N.useCallback)(t=>e?.send?.(t),[e]),b=(0,N.useCallback)((e,t)=>y({type:`goal.taskStatus`,payload:{taskId:e,status:t}}),[y]),x=(0,N.useCallback)(e=>y({type:`goal.retryTask`,payload:{taskId:e}}),[y]),S=(0,N.useCallback)((e,t)=>y({type:`goal.assignTask`,payload:{taskId:e,agentName:t||void 0}}),[y]),T=(0,N.useCallback)(e=>{j({title:t(`activity:board.newTaskTitle`),placeholder:t(`activity:board.newTaskPlaceholder`),confirmLabel:t(`activity:board.addTask`)}).then(t=>{t&&y({type:`goal.addTask`,payload:{phaseId:e,title:t}})})},[y]),E=(0,N.useCallback)(e=>{s&&y({type:`goal.moveTask`,payload:{taskId:s,toPhaseId:e}}),c(null),u(null)},[s,y]),O=(0,N.useCallback)(e=>{s&&y({type:`goal.taskStatus`,payload:{taskId:s,status:e}}),c(null),u(null)},[s,y]),k={onStatusChange:b,onRetry:x,agents:g,onAssign:S};function A(e){return{draggable:!0,onDragStart:t=>{c(e),t.dataTransfer.effectAllowed=`move`},onDragEnd:()=>{c(null),u(null)}}}function M(e,t){return{onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,l!==e&&u(e)},onDragLeave:()=>u(t=>t===e?null:t),onDrop:e=>{e.preventDefault(),t()},"data-hover":l===e||void 0}}return n.length===0?(0,P.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 items-center justify-center text-muted-foreground`,children:(0,P.jsx)(`p`,{className:`text-sm`,children:t(`activity:board.empty`)})}):(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2`,children:[(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:board.summary`,{phases:n.length,tasks:h.length})}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>o(`phase`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,i===`phase`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,P.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.phases`)]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>o(`status`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,i===`status`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,P.jsx)(_,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.statusTab`)]})]})]}),r&&m?(0,P.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,P.jsx)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-b border-border px-3 py-1.5`,children:n.map((e,t)=>(0,P.jsxs)(`button`,{type:`button`,onClick:()=>f(t),className:w(`shrink-0 rounded-t px-3 py-1.5 text-xs font-medium transition-colors`,t===p?`border-primary/40 bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,P.jsx)(`span`,{className:`truncate`,children:e.name}),(0,P.jsxs)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount]})]},e.id))}),(0,P.jsx)(W,{phase:m,allTasks:h,layout:i,dragId:s,hoverKey:l,callbacks:k,draggable:A,dropZone:M,dropToPhase:E,dropToStatus:O,onAddTask:T})]}):(0,P.jsx)(U,{phases:n,allTasks:h,layout:i,dragId:s,hoverKey:l,callbacks:k,draggable:A,dropZone:M,dropToPhase:E,dropToStatus:O,onAddTask:T})]})}function H({phase:e,phaseTasks:n,callbacks:r,draggable:i,dropZone:a,dropToPhase:o,onAddTask:s,dragId:c,hoverKey:l}){let{t:u}=v();return(0,P.jsxs)(`div`,{...a(`phase:${e.id}`,()=>o(e.id)),className:w(`flex min-h-0 w-80 shrink-0 flex-col rounded-lg border bg-muted/30 transition-colors`,l===`phase:${e.id}`?`border-primary/60 bg-primary/5`:`border-border`),children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.name}),(0,P.jsx)(`span`,{className:w(`rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,V[e.status]),children:e.status})]}),(0,P.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount,` · `,e.progressPercent,`%`]})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),title:u(`activity:board.addTask`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,P.jsx)(t,{className:`h-4 w-4`})})]}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-2`,children:n.length===0?(0,P.jsx)(`p`,{className:`px-1 py-4 text-center text-[11px] text-muted-foreground`,children:u(`activity:board.dropHere`)}):n.map(e=>(0,P.jsx)(`div`,{...i(e.id),className:w(c===e.id&&`opacity-50`),children:(0,P.jsx)(z,{task:e,...r})},e.id))})]})}function U({phases:e,allTasks:t,layout:n,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,dropToStatus:l,onAddTask:u}){return(0,P.jsx)(P.Fragment,{children:n===`phase`?(0,P.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:e.map(e=>{let n=t.filter(t=>t.phaseId===e.id);return(0,P.jsx)(H,{phase:e,phaseTasks:n,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:u,dragId:r,hoverKey:i},e.id)})}):(0,P.jsx)(G,{phases:e,allTasks:t,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToStatus:l})})}function W({phase:e,allTasks:t,layout:n,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,dropToStatus:l,onAddTask:u}){let d=t.filter(t=>t.phaseId===e.id),{t:f}=v();return n===`phase`?(0,P.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:(0,P.jsx)(H,{phase:e,phaseTasks:d,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:u,dragId:r,hoverKey:i})}):(0,P.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain p-3`,children:(0,P.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${B.length}, minmax(0, 1fr))`},children:[(0,P.jsx)(`div`,{}),B.map(e=>(0,P.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:f(`activity:board.status.${e.key}`)},e.key)),(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,P.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,V[e.status]),children:e.status})]})}),B.map(t=>{let n=d.filter(e=>t.match.includes(e.status)),c=`cell:${e.id}:${t.key}`;return(0,P.jsx)(`div`,{...s(c,()=>l(t.key)),className:w(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,i===c?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:n.map(e=>(0,P.jsx)(`div`,{...o(e.id),className:w(r===e.id&&`opacity-50`),children:(0,P.jsx)(z,{task:e,compact:!0,...a})},e.id))},t.key)})]},e.id)]})})}function G({phases:e,allTasks:t,dragId:n,hoverKey:r,callbacks:i,draggable:a,dropZone:o,dropToStatus:s}){let{t:c}=v();return(0,P.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${B.length}, minmax(0, 1fr))`},children:[(0,P.jsx)(`div`,{}),B.map(e=>(0,P.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:c(`activity:board.status.${e.key}`)},e.key)),e.map(e=>(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,P.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,V[e.status]),children:e.status})]})}),B.map(c=>{let l=t.filter(t=>t.phaseId===e.id&&c.match.includes(t.status)),u=`cell:${e.id}:${c.key}`;return(0,P.jsx)(`div`,{...o(u,()=>s(c.key)),className:w(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,r===u?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:l.map(e=>(0,P.jsx)(`div`,{...a(e.id),className:w(n===e.id&&`opacity-50`),children:(0,P.jsx)(z,{task:e,compact:!0,...i})},e.id))},c.key)})]},e.id))]})}function K({children:e}){return(0,P.jsx)(P.Fragment,{children:e})}function q({onClose:e}){let{client:i}=C(),{t:a}=v(),c=D(e=>e.phases),l=D(e=>e.overallPercent),p=D(e=>e.autonomous),m=D(e=>e.title),g=D(e=>e.goal),_=D(e=>e.status),y=D(e=>e.lastError),S=D(e=>e.graphs);(0,N.useEffect)(()=>{i?.send?.({type:`goal.list`}),i?.send?.({type:`goal.state`})},[i]);let j=O(e=>e.worktrees),F=O(e=>e.baseBranch),[I,L]=(0,N.useState)(``),[R,z]=(0,N.useState)(null),[B,V]=(0,N.useState)(!1),[H,U]=(0,N.useState)(!0),[W,G]=(0,N.useState)(!1),[K,q]=(0,N.useState)(!1),[J,re]=(0,N.useState)(!1),Y=E(e=>e.result),X=E(e=>e.loading),Z=(0,N.useRef)(null);(0,N.useEffect)(()=>{if(Z.current&&clearTimeout(Z.current),!I.trim()){E.getState().clear();return}return Z.current=setTimeout(()=>{E.getState().setLoading();let e=E.getState().nextSeq();i?.send?.({type:`goal.assess`,payload:{goal:I,seq:e}})},800),()=>{Z.current&&clearTimeout(Z.current)}},[I,i]),(0,N.useEffect)(()=>{!I.trim()&&!R&&E.getState().clear()},[I,R]);let Q=c.length>0,ie=R!=null&&!Q;(0,N.useEffect)(()=>{Q&&z(null)},[Q]);let ae=(0,N.useCallback)(()=>{let e=I.trim();if(!e||R!=null)return;let t=T.getState();t.addMessage({role:`user`,content:e}),t.addMessage({role:`assistant`,content:h.t(`activity:goalRun.planningAck`)}),z(e),L(``),i?.send?.({type:`goal.start`,payload:{title:e,autonomous:!0,worktrees:H,multiBoard:W,verifyTasks:K,chimeraReview:J}}),k(`chat`)},[I,R,i,H]),oe=(0,N.useCallback)(()=>{i?.send?.({type:`goal.stop`,payload:{}}),z(null)},[i]),se=(0,N.useCallback)(()=>{i?.send?.({type:`goal.toggleAutonomous`,payload:{}})},[i]),ce=(0,N.useCallback)(()=>{i?.send?.(_===`paused`?{type:`goal.resume`,payload:{}}:{type:`goal.pause`,payload:{}})},[i,_]),le=(0,N.useCallback)(()=>{i?.send?.({type:`goal.stop`,payload:{}})},[i]),ue=(0,N.useCallback)(()=>{i?.send?.({type:`goal.clear`,payload:{}}),D.getState().clear(),z(null),L(``)},[i]),[de,$]=(0,N.useState)(!1),fe=(0,N.useCallback)(()=>{i?.send?.({type:`goal.revert`,payload:{}}),$(!1)},[i]),pe=_===`running`||_===`paused`,me=_===`stopped`||_===`completed`||_===`failed`,he=(0,N.useCallback)(e=>{e&&i?.send?.({type:`goal.load`,payload:{graphId:e}})},[i]);return(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,P.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-2 border-b bg-card px-4 py-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(x,{className:`h-5 w-5 text-muted-foreground`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold`,children:Q&&m||`Goal`}),Q&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`activity:goalRun.summary`,{count:c.length,pct:l})})]}),Q&&(0,P.jsx)(`span`,{className:w(`rounded border px-2 py-0.5 text-[11px] font-medium capitalize`,_===`failed`?`border-destructive/40 bg-destructive/10 text-destructive`:_===`paused`||_===`stopped`?`border-warning/40 bg-warning/10 text-warning`:_===`completed`?`border-success/40 bg-success/10 text-success`:`border-primary/30 bg-primary/10 text-primary`),title:y??void 0,children:_})]}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[S.length>0&&(0,P.jsxs)(`select`,{value:Q?S.find(e=>e.title===m)?.id??``:``,onChange:e=>he(e.target.value),title:a(`activity:goalRun.switchBoard`),className:`min-w-0 flex-1 rounded border border-border bg-card px-2 py-1 text-xs text-foreground sm:w-72 sm:flex-none`,children:[(0,P.jsx)(`option`,{value:``,disabled:!0,children:a(`activity:goalRun.boardsCount`,{count:S.length})}),S.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.status]},e.id))]}),Q&&(0,P.jsxs)(`button`,{type:`button`,onClick:se,title:a(`activity:goalRun.toggleAutonomousTitle`),className:w(`inline-flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors`,p?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[(0,P.jsx)(u,{className:`h-3.5 w-3.5`}),` `,a(p?`activity:goalRun.autonomous`:`activity:goalRun.manual`)]}),pe&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:ce,title:a(_===`paused`?`activity:goalRun.resumeTitle`:`activity:goalRun.pauseTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[_===`paused`?(0,P.jsx)(s,{className:`h-3.5 w-3.5`}):(0,P.jsx)(o,{className:`h-3.5 w-3.5`}),a(_===`paused`?`activity:goalRun.resume`:`activity:goalRun.pause`)]}),(0,P.jsxs)(`button`,{type:`button`,onClick:le,title:a(`activity:goalRun.stopTitle`),className:`inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/20`,children:[(0,P.jsx)(r,{className:`h-3.5 w-3.5 fill-current`}),` `,a(`activity:goalRun.stop`)]})]}),Q&&me&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:ue,title:a(`activity:goalRun.newTitle`),className:`inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/10 px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-primary/20`,children:[(0,P.jsx)(t,{className:`h-3.5 w-3.5`}),` `,a(`activity:goalRun.newLabel`)]}),de?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-warning/40 bg-warning/10 px-1.5 py-0.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-warning`,children:a(`activity:goalRun.revertConfirm`)}),(0,P.jsx)(`button`,{type:`button`,onClick:fe,className:`rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-destructive hover:bg-destructive/25`,children:a(`common:action.yes`)}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>$(!1),className:`rounded px-1.5 py-0.5 text-muted-foreground hover:text-foreground`,children:a(`common:action.no`)})]}):(0,P.jsxs)(`button`,{type:`button`,onClick:()=>$(!0),title:a(`activity:goalRun.revertTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,P.jsx)(n,{className:`h-3.5 w-3.5`}),` `,a(`activity:goalRun.revert`)]})]}),(0,P.jsx)(A,{variant:`ghost`,size:`icon`,onClick:e,children:(0,P.jsx)(f,{className:`h-4 w-4`})})]})]}),Q&&g&&(0,P.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 bg-muted/20 px-4 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,P.jsx)(b,{className:`h-3 w-3`}),` `,a(`activity:goalRun.goal`)]}),(0,P.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:g})]}),Q?(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,P.jsx)(ne,{})}):ie?(0,P.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`max-w-lg w-full space-y-5 text-center`,children:[(0,P.jsx)(d,{className:`h-10 w-10 mx-auto animate-spin text-primary/70`}),(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsx)(`h2`,{className:`text-xl font-semibold`,children:a(`activity:goalRun.planning`)}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`activity:goalRun.planningBody`)})]}),(0,P.jsxs)(`div`,{className:`rounded-lg border border-border bg-card px-4 py-3 text-left`,children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,P.jsx)(b,{className:`h-3 w-3`}),` `,a(`activity:goalRun.goal`)]}),(0,P.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:R})]}),(0,P.jsxs)(A,{variant:`outline`,onClick:oe,className:`gap-2`,children:[(0,P.jsx)(r,{className:`h-4 w-4 fill-current`}),` `,a(`common:action.cancel`)]})]})}):(0,P.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`max-w-lg w-full space-y-6`,children:[(0,P.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,P.jsx)(b,{className:`h-10 w-10 mx-auto text-primary/60`}),(0,P.jsx)(`h2`,{className:`text-xl font-semibold`,children:a(`activity:goalRun.startHeading`)}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`activity:goalRun.startBody`)})]}),(0,P.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:a(`activity:goalRun.startPlaceholder`),rows:5,className:`w-full rounded-lg border border-border bg-card px-4 py-3 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-primary/30 placeholder:text-muted-foreground/70`,onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),ae())}}),X&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(d,{className:`h-3 w-3 animate-spin`}),a(`activity:goalRun.assess.analyzing`)]}),!X&&Y&&!Y.parseFailed&&(0,P.jsxs)(`div`,{className:w(`rounded-lg border px-3 py-2 text-xs space-y-1.5`,Y.realistic?`border-success/40 bg-success/10`:`border-warning/40 bg-warning/10`),children:[(0,P.jsx)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:Y.realistic?(0,P.jsx)(`span`,{className:`text-success`,children:a(`activity:goalRun.assess.realistic`)}):(0,P.jsx)(`span`,{className:`text-warning`,children:a(`activity:goalRun.assess.durationConcern`)})}),Y.durationClaimed&&(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:a(`activity:goalRun.assess.durationClaimed`,{duration:Y.durationClaimed})}),(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:Y.explanation}),Y.recommendedDuration&&(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:a(`activity:goalRun.assess.recommendation`,{duration:Y.recommendedDuration})}),Y.concerns.length>0&&(0,P.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,P.jsx)(`p`,{className:`font-medium text-foreground/80`,children:a(`activity:goalRun.assess.concerns`)}),(0,P.jsx)(`ul`,{className:`list-disc pl-4 space-y-0.5 text-muted-foreground`,children:Y.concerns.map((e,t)=>(0,P.jsx)(`li`,{children:e},t))})]})]}),!X&&Y?.parseFailed&&(0,P.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:a(`activity:goalRun.assess.analysisFailed`)}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>U(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.isolateLabel`)]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3 text-xs text-muted-foreground`,children:[(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:W,onChange:e=>G(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.multiBoardLabel`)]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:K,onChange:e=>q(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.verifyTasksLabel`)]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:J,onChange:e=>re(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.chimeraReviewLabel`)]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!X&&Y&&!Y.realistic&&!Y.parseFailed&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>E.getState().clear(),className:`shrink-0 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:a(`activity:goalRun.assess.overrideTitle`),children:a(`activity:goalRun.assess.override`)}),(0,P.jsxs)(A,{onClick:ae,disabled:!I.trim()||R!=null||X||!X&&Y!=null&&!Y.parseFailed&&!Y.realistic,className:`flex-1 gap-2`,title:I.trim()&&!X&&Y&&!Y.parseFailed&&!Y.realistic?a(`activity:goalRun.assess.disableTitle`):``,children:[(0,P.jsx)(s,{className:`h-4 w-4`}),a(`activity:goalRun.startButton`)]})]}),(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground text-center`,children:[a(`activity:goalRun.ctrlHint`),` ·`,` `,a(H?`activity:goalRun.isolateOn`:`activity:goalRun.isolateOff`)]})]})}),j.length>0&&(0,P.jsxs)(`div`,{className:`border-t bg-card/50 shrink-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 pt-2 text-xs`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>V(!1),className:w(`rounded px-2 py-0.5 border transition-colors`,B?`border-border text-muted-foreground hover:text-foreground`:`bg-primary/10 border-primary/30 text-primary`),children:a(`activity:goalRun.lanes`)}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>V(!0),className:w(`rounded px-2 py-0.5 border transition-colors`,B?`bg-primary/10 border-primary/30 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:a(`activity:goalRun.graph`)})]}),(0,P.jsxs)(`div`,{className:`space-y-2 px-4 pb-3`,children:[(0,P.jsx)(te,{}),B?(0,P.jsx)(ee,{worktrees:j,baseBranch:F}):(0,P.jsx)(M,{worktrees:j,baseBranch:F})]})]})]})}export{q as GoalView};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Dn as t,Dt as n,Ht as r,Ji as i,Li as a,Nn as o,On as s,Ui as c,Yi as l,dt as u,fr as d,ft as f,gn as p,ia as m,io as h,oo as g,pn as _,to as v,ut as y,vn as b,wr as x,wt as S}from"./vendor-enc0q-Va.js";import"./i18n-Cv65b1SP.js";import{t as C}from"./useWebSocket-VIItbvVK.js";import{t as w}from"./utils-DQ9Exx8j.js";import{t as T}from"./chat-store-DIcs826A.js";import{h as E,m as D,t as O}from"./stores-CNuMLG8X.js";import{o as k}from"./view-navigation-DPOY0lyt.js";import{t as A}from"./button-DNyYztcH.js";import{a as j}from"./ConfirmModal-gukSikBD.js";import{n as M,r as ee,t as te}from"./index-DbprKWmG.js";var N=e(g(),1),P=y(),F={pending:{icon:(0,P.jsx)(i,{className:`w-4 h-4`}),color:`text-muted-foreground`},in_progress:{icon:(0,P.jsx)(c,{className:`w-4 h-4 animate-spin`}),color:`text-primary`},blocked:{icon:(0,P.jsx)(o,{className:`w-4 h-4`}),color:`text-warning`},failed:{icon:(0,P.jsx)(l,{className:`w-4 h-4`}),color:`text-destructive`},review:{icon:(0,P.jsx)(p,{className:`w-4 h-4`}),color:`text-info`},completed:{icon:(0,P.jsx)(m,{className:`w-4 h-4`}),color:`text-success`}},I={critical:`bg-destructive/15 text-destructive`,high:`bg-warning/15 text-warning`,medium:`bg-info/15 text-info`,low:`bg-muted text-muted-foreground`},L={feature:`bg-success/15 text-success`,bugfix:`bg-destructive/15 text-destructive`,refactor:`bg-primary/15 text-primary`,docs:`bg-info/15 text-info`,test:`bg-primary/15 text-primary`,chore:`bg-muted text-muted-foreground`};function R(e){if(!e)return``;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60),r=t%60;return r>0?`${n}h ${r}m`:`${n}h`}function z({task:e,onStatusChange:t,onRetry:n,agents:r,onAssign:i,compact:a,className:o}){let{t:s}=v(),l=F[e.status],[u,d]=(0,N.useState)(!1),f=e.status===`in_progress`;return(0,P.jsxs)(`div`,{className:w(`w-full text-left rounded-lg border p-3 transition-all hover:shadow-sm`,f?`border-primary/40 bg-primary/5`:e.status===`completed`?`border-success/35 bg-success/6`:e.status===`failed`?`border-destructive/40 bg-destructive/5`:`border-border bg-card`,o),children:[(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,P.jsx)(`span`,{className:w(`mt-0.5`,l.color),role:`img`,"aria-label":f?s(`common:status.inProgress`):void 0,children:l.icon}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,P.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,I[e.priority]),children:e.priority}),(0,P.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,L[e.type]),children:e.type})]}),e.description&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 line-clamp-2`,children:e.description})]})]}),e.assignee&&(0,P.jsxs)(`div`,{className:w(`mt-2 inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium`,f?`bg-primary/15 text-primary`:`bg-muted text-muted-foreground`),children:[f&&(0,P.jsx)(c,{className:`w-3 h-3 animate-spin`,"aria-label":s(`common:status.working`)}),(0,P.jsx)(`span`,{children:e.assignee})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 mt-2 text-xs text-muted-foreground`,children:[e.estimateHours?(0,P.jsxs)(`span`,{children:[`~`,e.estimateHours,`h`]}):null,e.actualHours?(0,P.jsxs)(`span`,{children:[`• `,e.actualHours,`h`]}):null,e.startedAt?(0,P.jsxs)(`span`,{children:[`• `,R(Date.now()-e.startedAt)]}):null]}),e.tags.length>0&&(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.tags.map(e=>(0,P.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))}),!a&&(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 mt-2`,children:[t&&e.status!==`in_progress`&&e.status!==`completed`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`in_progress`),className:`px-2 py-0.5 text-[10px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,children:s(`activity:task.start`)}),t&&e.status===`in_progress`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`completed`),className:`px-2 py-0.5 text-[10px] rounded bg-success/15 text-success hover:bg-success/25 transition-colors`,children:s(`activity:task.complete`)}),n&&(e.status===`failed`||e.status===`completed`)&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,children:[(0,P.jsx)(p,{className:`w-3 h-3`}),` `,s(`activity:task.retry`)]}),i&&r&&r.length>0&&(u?(0,P.jsxs)(`select`,{defaultValue:e.assignee??``,onChange:t=>{i(e.id,t.target.value),d(!1)},onBlur:()=>d(!1),className:`px-1 py-0.5 text-[10px] rounded border border-border bg-card`,children:[(0,P.jsx)(`option`,{value:``,children:s(`activity:task.unassigned`)}),r.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]}):(0,P.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,title:s(`activity:task.assignTitle`),children:[(0,P.jsx)(S,{className:`w-3 h-3`}),` `,s(`activity:task.assign`)]}))]})]})}var B=[{key:`pending`,match:[`pending`,`blocked`]},{key:`in_progress`,match:[`in_progress`]},{key:`review`,match:[`review`]},{key:`failed`,match:[`failed`]},{key:`completed`,match:[`completed`]}],V={pending:`bg-muted text-muted-foreground`,ready:`bg-info/15 text-info`,running:`bg-primary/15 text-primary`,paused:`bg-warning/15 text-warning`,completed:`bg-success/15 text-success`,failed:`bg-destructive/15 text-destructive`,skipped:`bg-muted text-muted-foreground`};function ne(){let{client:e}=C(),{t}=v(),n=D(e=>e.phases),r=D(e=>e.multiBoard),[i,o]=(0,N.useState)(`phase`),[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(0),p=Math.min(d,Math.max(0,n.length-1)),m=r?n[p]:void 0,h=(0,N.useMemo)(()=>n.flatMap(e=>(e.tasks??[]).map(t=>({...t,phaseId:e.id}))),[n]),g=(0,N.useMemo)(()=>[...new Set(h.map(e=>e.assignee).filter(e=>!!e))],[h]),y=(0,N.useCallback)(t=>e?.send?.(t),[e]),b=(0,N.useCallback)((e,t)=>y({type:`goal.taskStatus`,payload:{taskId:e,status:t}}),[y]),x=(0,N.useCallback)(e=>y({type:`goal.retryTask`,payload:{taskId:e}}),[y]),S=(0,N.useCallback)((e,t)=>y({type:`goal.assignTask`,payload:{taskId:e,agentName:t||void 0}}),[y]),T=(0,N.useCallback)(e=>{j({title:t(`activity:board.newTaskTitle`),placeholder:t(`activity:board.newTaskPlaceholder`),confirmLabel:t(`activity:board.addTask`)}).then(t=>{t&&y({type:`goal.addTask`,payload:{phaseId:e,title:t}})})},[y]),E=(0,N.useCallback)(e=>{s&&y({type:`goal.moveTask`,payload:{taskId:s,toPhaseId:e}}),c(null),u(null)},[s,y]),O=(0,N.useCallback)(e=>{s&&y({type:`goal.taskStatus`,payload:{taskId:s,status:e}}),c(null),u(null)},[s,y]),k={onStatusChange:b,onRetry:x,agents:g,onAssign:S};function A(e){return{draggable:!0,onDragStart:t=>{c(e),t.dataTransfer.effectAllowed=`move`},onDragEnd:()=>{c(null),u(null)}}}function M(e,t){return{onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,l!==e&&u(e)},onDragLeave:()=>u(t=>t===e?null:t),onDrop:e=>{e.preventDefault(),t()},"data-hover":l===e||void 0}}return n.length===0?(0,P.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 items-center justify-center text-muted-foreground`,children:(0,P.jsx)(`p`,{className:`text-sm`,children:t(`activity:board.empty`)})}):(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2`,children:[(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:board.summary`,{phases:n.length,tasks:h.length})}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>o(`phase`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,i===`phase`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,P.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.phases`)]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>o(`status`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,i===`status`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,P.jsx)(_,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.statusTab`)]})]})]}),r&&m?(0,P.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,P.jsx)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-b border-border px-3 py-1.5`,children:n.map((e,t)=>(0,P.jsxs)(`button`,{type:`button`,onClick:()=>f(t),className:w(`shrink-0 rounded-t px-3 py-1.5 text-xs font-medium transition-colors`,t===p?`border-primary/40 bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,P.jsx)(`span`,{className:`truncate`,children:e.name}),(0,P.jsxs)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount]})]},e.id))}),(0,P.jsx)(W,{phase:m,allTasks:h,layout:i,dragId:s,hoverKey:l,callbacks:k,draggable:A,dropZone:M,dropToPhase:E,dropToStatus:O,onAddTask:T})]}):(0,P.jsx)(U,{phases:n,allTasks:h,layout:i,dragId:s,hoverKey:l,callbacks:k,draggable:A,dropZone:M,dropToPhase:E,dropToStatus:O,onAddTask:T})]})}function H({phase:e,phaseTasks:n,callbacks:r,draggable:i,dropZone:a,dropToPhase:o,onAddTask:s,dragId:c,hoverKey:l}){let{t:u}=v();return(0,P.jsxs)(`div`,{...a(`phase:${e.id}`,()=>o(e.id)),className:w(`flex min-h-0 w-80 shrink-0 flex-col rounded-lg border bg-muted/30 transition-colors`,l===`phase:${e.id}`?`border-primary/60 bg-primary/5`:`border-border`),children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.name}),(0,P.jsx)(`span`,{className:w(`rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,V[e.status]),children:e.status})]}),(0,P.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount,` · `,e.progressPercent,`%`]})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),title:u(`activity:board.addTask`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,P.jsx)(t,{className:`h-4 w-4`})})]}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-2`,children:n.length===0?(0,P.jsx)(`p`,{className:`px-1 py-4 text-center text-[11px] text-muted-foreground`,children:u(`activity:board.dropHere`)}):n.map(e=>(0,P.jsx)(`div`,{...i(e.id),className:w(c===e.id&&`opacity-50`),children:(0,P.jsx)(z,{task:e,...r})},e.id))})]})}function U({phases:e,allTasks:t,layout:n,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,dropToStatus:l,onAddTask:u}){return(0,P.jsx)(P.Fragment,{children:n===`phase`?(0,P.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:e.map(e=>{let n=t.filter(t=>t.phaseId===e.id);return(0,P.jsx)(H,{phase:e,phaseTasks:n,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:u,dragId:r,hoverKey:i},e.id)})}):(0,P.jsx)(G,{phases:e,allTasks:t,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToStatus:l})})}function W({phase:e,allTasks:t,layout:n,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,dropToStatus:l,onAddTask:u}){let d=t.filter(t=>t.phaseId===e.id),{t:f}=v();return n===`phase`?(0,P.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:(0,P.jsx)(H,{phase:e,phaseTasks:d,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:u,dragId:r,hoverKey:i})}):(0,P.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain p-3`,children:(0,P.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${B.length}, minmax(0, 1fr))`},children:[(0,P.jsx)(`div`,{}),B.map(e=>(0,P.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:f(`activity:board.status.${e.key}`)},e.key)),(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,P.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,V[e.status]),children:e.status})]})}),B.map(t=>{let n=d.filter(e=>t.match.includes(e.status)),c=`cell:${e.id}:${t.key}`;return(0,P.jsx)(`div`,{...s(c,()=>l(t.key)),className:w(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,i===c?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:n.map(e=>(0,P.jsx)(`div`,{...o(e.id),className:w(r===e.id&&`opacity-50`),children:(0,P.jsx)(z,{task:e,compact:!0,...a})},e.id))},t.key)})]},e.id)]})})}function G({phases:e,allTasks:t,dragId:n,hoverKey:r,callbacks:i,draggable:a,dropZone:o,dropToStatus:s}){let{t:c}=v();return(0,P.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${B.length}, minmax(0, 1fr))`},children:[(0,P.jsx)(`div`,{}),B.map(e=>(0,P.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:c(`activity:board.status.${e.key}`)},e.key)),e.map(e=>(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,P.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,V[e.status]),children:e.status})]})}),B.map(c=>{let l=t.filter(t=>t.phaseId===e.id&&c.match.includes(t.status)),u=`cell:${e.id}:${c.key}`;return(0,P.jsx)(`div`,{...o(u,()=>s(c.key)),className:w(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,r===u?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:l.map(e=>(0,P.jsx)(`div`,{...a(e.id),className:w(n===e.id&&`opacity-50`),children:(0,P.jsx)(z,{task:e,compact:!0,...i})},e.id))},c.key)})]},e.id))]})}function K({children:e}){return(0,P.jsx)(P.Fragment,{children:e})}function q({onClose:e}){let{client:i}=C(),{t:a}=v(),c=D(e=>e.phases),l=D(e=>e.overallPercent),p=D(e=>e.autonomous),m=D(e=>e.title),g=D(e=>e.goal),_=D(e=>e.status),y=D(e=>e.lastError),S=D(e=>e.graphs);(0,N.useEffect)(()=>{i?.send?.({type:`goal.list`}),i?.send?.({type:`goal.state`})},[i]);let j=O(e=>e.worktrees),F=O(e=>e.baseBranch),[I,L]=(0,N.useState)(``),[R,z]=(0,N.useState)(null),[B,V]=(0,N.useState)(!1),[H,U]=(0,N.useState)(!0),[W,G]=(0,N.useState)(!1),[K,q]=(0,N.useState)(!1),[J,re]=(0,N.useState)(!1),Y=E(e=>e.result),X=E(e=>e.loading),Z=(0,N.useRef)(null);(0,N.useEffect)(()=>{if(Z.current&&clearTimeout(Z.current),!I.trim()){E.getState().clear();return}return Z.current=setTimeout(()=>{E.getState().setLoading();let e=E.getState().nextSeq();i?.send?.({type:`goal.assess`,payload:{goal:I,seq:e}})},800),()=>{Z.current&&clearTimeout(Z.current)}},[I,i]),(0,N.useEffect)(()=>{!I.trim()&&!R&&E.getState().clear()},[I,R]);let Q=c.length>0,ie=R!=null&&!Q;(0,N.useEffect)(()=>{Q&&z(null)},[Q]);let ae=(0,N.useCallback)(()=>{let e=I.trim();if(!e||R!=null)return;let t=T.getState();t.addMessage({role:`user`,content:e}),t.addMessage({role:`assistant`,content:h.t(`activity:goalRun.planningAck`)}),z(e),L(``),i?.send?.({type:`goal.start`,payload:{title:e,autonomous:!0,worktrees:H,multiBoard:W,verifyTasks:K,chimeraReview:J}}),k(`chat`)},[I,R,i,H]),oe=(0,N.useCallback)(()=>{i?.send?.({type:`goal.stop`,payload:{}}),z(null)},[i]),se=(0,N.useCallback)(()=>{i?.send?.({type:`goal.toggleAutonomous`,payload:{}})},[i]),ce=(0,N.useCallback)(()=>{i?.send?.(_===`paused`?{type:`goal.resume`,payload:{}}:{type:`goal.pause`,payload:{}})},[i,_]),le=(0,N.useCallback)(()=>{i?.send?.({type:`goal.stop`,payload:{}})},[i]),ue=(0,N.useCallback)(()=>{i?.send?.({type:`goal.clear`,payload:{}}),D.getState().clear(),z(null),L(``)},[i]),[de,$]=(0,N.useState)(!1),fe=(0,N.useCallback)(()=>{i?.send?.({type:`goal.revert`,payload:{}}),$(!1)},[i]),pe=_===`running`||_===`paused`,me=_===`stopped`||_===`completed`||_===`failed`,he=(0,N.useCallback)(e=>{e&&i?.send?.({type:`goal.load`,payload:{graphId:e}})},[i]);return(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,P.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-2 border-b bg-card px-4 py-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(x,{className:`h-5 w-5 text-muted-foreground`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold`,children:Q&&m||`Goal`}),Q&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`activity:goalRun.summary`,{count:c.length,pct:l})})]}),Q&&(0,P.jsx)(`span`,{className:w(`rounded border px-2 py-0.5 text-[11px] font-medium capitalize`,_===`failed`?`border-destructive/40 bg-destructive/10 text-destructive`:_===`paused`||_===`stopped`?`border-warning/40 bg-warning/10 text-warning`:_===`completed`?`border-success/40 bg-success/10 text-success`:`border-primary/30 bg-primary/10 text-primary`),title:y??void 0,children:_})]}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[S.length>0&&(0,P.jsxs)(`select`,{value:Q?S.find(e=>e.title===m)?.id??``:``,onChange:e=>he(e.target.value),title:a(`activity:goalRun.switchBoard`),className:`min-w-0 flex-1 rounded border border-border bg-card px-2 py-1 text-xs text-foreground sm:w-72 sm:flex-none`,children:[(0,P.jsx)(`option`,{value:``,disabled:!0,children:a(`activity:goalRun.boardsCount`,{count:S.length})}),S.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.status]},e.id))]}),Q&&(0,P.jsxs)(`button`,{type:`button`,onClick:se,title:a(`activity:goalRun.toggleAutonomousTitle`),className:w(`inline-flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors`,p?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[(0,P.jsx)(u,{className:`h-3.5 w-3.5`}),` `,a(p?`activity:goalRun.autonomous`:`activity:goalRun.manual`)]}),pe&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:ce,title:a(_===`paused`?`activity:goalRun.resumeTitle`:`activity:goalRun.pauseTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[_===`paused`?(0,P.jsx)(s,{className:`h-3.5 w-3.5`}):(0,P.jsx)(o,{className:`h-3.5 w-3.5`}),a(_===`paused`?`activity:goalRun.resume`:`activity:goalRun.pause`)]}),(0,P.jsxs)(`button`,{type:`button`,onClick:le,title:a(`activity:goalRun.stopTitle`),className:`inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/20`,children:[(0,P.jsx)(r,{className:`h-3.5 w-3.5 fill-current`}),` `,a(`activity:goalRun.stop`)]})]}),Q&&me&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:ue,title:a(`activity:goalRun.newTitle`),className:`inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/10 px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-primary/20`,children:[(0,P.jsx)(t,{className:`h-3.5 w-3.5`}),` `,a(`activity:goalRun.newLabel`)]}),de?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-warning/40 bg-warning/10 px-1.5 py-0.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-warning`,children:a(`activity:goalRun.revertConfirm`)}),(0,P.jsx)(`button`,{type:`button`,onClick:fe,className:`rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-destructive hover:bg-destructive/25`,children:a(`common:action.yes`)}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>$(!1),className:`rounded px-1.5 py-0.5 text-muted-foreground hover:text-foreground`,children:a(`common:action.no`)})]}):(0,P.jsxs)(`button`,{type:`button`,onClick:()=>$(!0),title:a(`activity:goalRun.revertTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,P.jsx)(n,{className:`h-3.5 w-3.5`}),` `,a(`activity:goalRun.revert`)]})]}),(0,P.jsx)(A,{variant:`ghost`,size:`icon`,onClick:e,children:(0,P.jsx)(f,{className:`h-4 w-4`})})]})]}),Q&&g&&(0,P.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 bg-muted/20 px-4 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,P.jsx)(b,{className:`h-3 w-3`}),` `,a(`activity:goalRun.goal`)]}),(0,P.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:g})]}),Q?(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,P.jsx)(ne,{})}):ie?(0,P.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`max-w-lg w-full space-y-5 text-center`,children:[(0,P.jsx)(d,{className:`h-10 w-10 mx-auto animate-spin text-primary/70`}),(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsx)(`h2`,{className:`text-xl font-semibold`,children:a(`activity:goalRun.planning`)}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`activity:goalRun.planningBody`)})]}),(0,P.jsxs)(`div`,{className:`rounded-lg border border-border bg-card px-4 py-3 text-left`,children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,P.jsx)(b,{className:`h-3 w-3`}),` `,a(`activity:goalRun.goal`)]}),(0,P.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:R})]}),(0,P.jsxs)(A,{variant:`outline`,onClick:oe,className:`gap-2`,children:[(0,P.jsx)(r,{className:`h-4 w-4 fill-current`}),` `,a(`common:action.cancel`)]})]})}):(0,P.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`max-w-lg w-full space-y-6`,children:[(0,P.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,P.jsx)(b,{className:`h-10 w-10 mx-auto text-primary/60`}),(0,P.jsx)(`h2`,{className:`text-xl font-semibold`,children:a(`activity:goalRun.startHeading`)}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`activity:goalRun.startBody`)})]}),(0,P.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:a(`activity:goalRun.startPlaceholder`),rows:5,className:`w-full rounded-lg border border-border bg-card px-4 py-3 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-primary/30 placeholder:text-muted-foreground/70`,onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),ae())}}),X&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(d,{className:`h-3 w-3 animate-spin`}),a(`activity:goalRun.assess.analyzing`)]}),!X&&Y&&!Y.parseFailed&&(0,P.jsxs)(`div`,{className:w(`rounded-lg border px-3 py-2 text-xs space-y-1.5`,Y.realistic?`border-success/40 bg-success/10`:`border-warning/40 bg-warning/10`),children:[(0,P.jsx)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:Y.realistic?(0,P.jsx)(`span`,{className:`text-success`,children:a(`activity:goalRun.assess.realistic`)}):(0,P.jsx)(`span`,{className:`text-warning`,children:a(`activity:goalRun.assess.durationConcern`)})}),Y.durationClaimed&&(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:a(`activity:goalRun.assess.durationClaimed`,{duration:Y.durationClaimed})}),(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:Y.explanation}),Y.recommendedDuration&&(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:a(`activity:goalRun.assess.recommendation`,{duration:Y.recommendedDuration})}),Y.concerns.length>0&&(0,P.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,P.jsx)(`p`,{className:`font-medium text-foreground/80`,children:a(`activity:goalRun.assess.concerns`)}),(0,P.jsx)(`ul`,{className:`list-disc pl-4 space-y-0.5 text-muted-foreground`,children:Y.concerns.map((e,t)=>(0,P.jsx)(`li`,{children:e},t))})]})]}),!X&&Y?.parseFailed&&(0,P.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:a(`activity:goalRun.assess.analysisFailed`)}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>U(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.isolateLabel`)]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3 text-xs text-muted-foreground`,children:[(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:W,onChange:e=>G(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.multiBoardLabel`)]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:K,onChange:e=>q(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.verifyTasksLabel`)]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:J,onChange:e=>re(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.chimeraReviewLabel`)]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!X&&Y&&!Y.realistic&&!Y.parseFailed&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>E.getState().clear(),className:`shrink-0 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:a(`activity:goalRun.assess.overrideTitle`),children:a(`activity:goalRun.assess.override`)}),(0,P.jsxs)(A,{onClick:ae,disabled:!I.trim()||R!=null||X||!X&&Y!=null&&!Y.parseFailed&&!Y.realistic,className:`flex-1 gap-2`,title:I.trim()&&!X&&Y&&!Y.parseFailed&&!Y.realistic?a(`activity:goalRun.assess.disableTitle`):``,children:[(0,P.jsx)(s,{className:`h-4 w-4`}),a(`activity:goalRun.startButton`)]})]}),(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground text-center`,children:[a(`activity:goalRun.ctrlHint`),` ·`,` `,a(H?`activity:goalRun.isolateOn`:`activity:goalRun.isolateOff`)]})]})}),j.length>0&&(0,P.jsxs)(`div`,{className:`border-t bg-card/50 shrink-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 pt-2 text-xs`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>V(!1),className:w(`rounded px-2 py-0.5 border transition-colors`,B?`border-border text-muted-foreground hover:text-foreground`:`bg-primary/10 border-primary/30 text-primary`),children:a(`activity:goalRun.lanes`)}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>V(!0),className:w(`rounded px-2 py-0.5 border transition-colors`,B?`bg-primary/10 border-primary/30 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:a(`activity:goalRun.graph`)})]}),(0,P.jsxs)(`div`,{className:`space-y-2 px-4 pb-3`,children:[(0,P.jsx)(te,{}),B?(0,P.jsx)(ee,{worktrees:j,baseBranch:F}):(0,P.jsx)(M,{worktrees:j,baseBranch:F})]})]})]})}export{q as GoalView};
|