@wrongstack/webui 0.298.0 → 0.298.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentRosterView-C8j2NuD1.js → AgentRosterView-C26RCdot.js} +4 -4
- package/dist/assets/{AnalyticsDashboard-D2_HYmYw.js → AnalyticsDashboard-CEjjV3bX.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-SzXptIQj.js → AudienceMemoryPanel-CnfZC8x0.js} +2 -2
- package/dist/assets/{ChangesView-D31wr7_h.js → ChangesView-D0BiTbs8.js} +1 -1
- package/dist/assets/ChronicleDashboard-BZ4XOcvf.js +1 -0
- package/dist/assets/CodeEditor-BlqaT56D.js +1 -0
- package/dist/assets/CodeMap-Bj5tjjW5.js +1 -0
- package/dist/assets/{CronJobsPanel-C9shS0P2.js → CronJobsPanel-F6nhZtfg.js} +1 -1
- package/dist/assets/{DeadCodeScanPanel-CHud_Ugp.js → DeadCodeScanPanel-C9sLNUUc.js} +1 -1
- package/dist/assets/{DebugDashboard-DmqpGXnx.js → DebugDashboard-D8BLcLjI.js} +1 -1
- package/dist/assets/{DesignGalleryView-CnAHpKa1.js → DesignGalleryView-B8mE5nGy.js} +1 -1
- package/dist/assets/GoalView-DIx7Zr4a.js +1 -0
- package/dist/assets/KanbanView-DshzDwq1.js +3 -0
- package/dist/assets/{MailboxDetailView-CQtHeWVs.js → MailboxDetailView-BJXpXjtm.js} +1 -1
- package/dist/assets/MemoryManager-B-S5oREO.js +1 -0
- package/dist/assets/{ModelPicker-Dt0wCi90.js → ModelPicker-CNHhT2SO.js} +1 -1
- package/dist/assets/OfficeMapPanel-CBN9uG80.js +4 -0
- package/dist/assets/{ProcessMonitor-Dq760Vqm.js → ProcessMonitor-Cc8LsfTh.js} +1 -1
- package/dist/assets/{QueuePanel-ZcJliKcY.js → QueuePanel-B0NXFwEt.js} +1 -1
- package/dist/assets/{RefreshDebugView-SivBV0LN.js → RefreshDebugView-DLst_piS.js} +1 -1
- package/dist/assets/{SageTabs-CGrc4PuM.js → SageTabs-NwMcr4Pq.js} +2 -2
- package/dist/assets/SddHub-CpRHXmjm.js +2 -0
- package/dist/assets/SessionsDashboard-C5dXb0iJ.js +1 -0
- package/dist/assets/SetupScreen-B81fcNgP.js +1 -0
- package/dist/assets/SkillDetailView-BTvgE_MD.js +3 -0
- package/dist/assets/{SpecsView-CzYtHNbj.js → SpecsView-DhuaZcOl.js} +1 -1
- package/dist/assets/TechStackView-BXmfl2qY.js +1 -0
- package/dist/assets/{TerminalPanel-BRSYloOD.js → TerminalPanel-DjruTcb6.js} +1 -1
- package/dist/assets/{Toaster-Bd6ckyrP.js → Toaster-BmyghnqJ.js} +1 -1
- package/dist/assets/{button-Clh96jMK.js → button-BMECp1cg.js} +1 -1
- package/dist/assets/{chat-Du7n7HZ7.js → chat-CRmMDzCb.js} +1 -1
- package/dist/assets/{chat-VkTBQmmx.js → chat-CwnuX7tG.js} +1 -1
- package/dist/assets/{chat-BJzPxfyr.js → chat-DLn1hY01.js} +1 -1
- package/dist/assets/{chat-IRKmQ6we.js → chat-DSEq1Bdz.js} +1 -1
- package/dist/assets/{chat-C7ybebfi.js → chat-DxLD17ER.js} +1 -1
- package/dist/assets/{chat-BRBVFl4h.js → chat-DzPxYALH.js} +1 -1
- package/dist/assets/{chat-Bkom8vQo.js → chat-OunddzYy.js} +1 -1
- package/dist/assets/{chat-store-CWhuSNod.js → chat-store-B2CjP2Zl.js} +2 -2
- package/dist/assets/{codemap-activity-store-C1XWbXeZ.js → codemap-activity-store-Cz0_AHqt.js} +1 -1
- package/dist/assets/codemap-index-store-B-XLZpJu.js +1 -0
- package/dist/assets/{dialog-DYJUM0p1.js → dialog-BJef9ZZo.js} +1 -1
- package/dist/assets/{empty-state-BV-Y8c35.js → empty-state-BGzRrNXI.js} +1 -1
- package/dist/assets/{i18n-DOuSY1L8.js → i18n-2wGPPdl_.js} +2 -2
- package/dist/assets/index-DeA8UyiB.css +1 -0
- package/dist/assets/index-x6-rLl5H.js +132 -0
- package/dist/assets/{input-CW-Yw2Wu.js → input-Bd10nfMj.js} +1 -1
- package/dist/assets/{mailbox-store-_8voaug1.js → mailbox-store-D3omLzBk.js} +1 -1
- package/dist/assets/progress-ring-BEULkQ1r.js +1 -0
- package/dist/assets/{roster-ws-q8Cp6us7.js → roster-ws-BmV_3U6w.js} +1 -1
- package/dist/assets/{session-store-D4JWBP5w.js → session-store-ZMNU48xK.js} +1 -1
- package/dist/assets/{settings-B9EPDhAL.js → settings-BF0lRxlj.js} +1 -1
- package/dist/assets/{settings-DWIDXI2K.js → settings-CP6cwqHD.js} +1 -1
- package/dist/assets/{settings-tyKsHhya.js → settings-D0rWEhMg.js} +1 -1
- package/dist/assets/{settings-r_KOGrbF.js → settings-DFCaP02p.js} +1 -1
- package/dist/assets/{settings-BoXoFVdx.js → settings-DHix1ZPL.js} +1 -1
- package/dist/assets/{settings-BBNOO9wC.js → settings-eEzjNzsC.js} +1 -1
- package/dist/assets/{settings-CkXKHC77.js → settings-kp_aIgcX.js} +1 -1
- package/dist/assets/{shared-DidGznBo.js → shared-CrX8iE-U.js} +1 -1
- package/dist/assets/{stores-CpZiOiOP.js → stores-DyQOSkkD.js} +2 -2
- package/dist/assets/ui-store-di6oY7cy.js +1 -0
- package/dist/assets/{useWebSocket-BTXT0rOW.js → useWebSocket-BVFPigcY.js} +16 -16
- package/dist/assets/{utils-DxDx8yib.js → utils-CwJvjOcH.js} +1 -1
- package/dist/assets/{vendor-BTDGplXK.js → vendor-BTTkQ9Tn.js} +27 -27
- package/dist/assets/{view-navigation-BRtuAwZo.js → view-navigation-BMRzqGbq.js} +1 -1
- package/dist/assets/ws-client-B0-KwuTK.js +1 -0
- package/dist/components/MemoryManager/MemoryInjectorPanel.d.ts +19 -0
- package/dist/components/SettingsPanel/PluginToggleList.d.ts +11 -1
- package/dist/hooks/ws-handlers/misc-handlers.d.ts +1 -0
- package/dist/index.html +22 -22
- package/dist/index.js +7803 -7535
- package/dist/lib/sage-block.d.ts +18 -23
- package/dist/stores/local-prefs.d.ts +2 -2
- package/dist/stores/types.d.ts +2 -1
- package/dist/types/server-message.d.ts +11 -0
- package/package.json +10 -9
- package/dist/assets/ChronicleDashboard-B7P4f1hr.js +0 -1
- package/dist/assets/CodeEditor-BRDwx8Y-.js +0 -1
- package/dist/assets/CodeMap-uabWaeJH.js +0 -1
- package/dist/assets/GoalView-DaptZIKr.js +0 -1
- package/dist/assets/KanbanView-DA5Ulb8C.js +0 -3
- package/dist/assets/MemoryManager-BWuSS0Pg.js +0 -1
- package/dist/assets/OfficeMapPanel-CUNRI3X7.js +0 -4
- package/dist/assets/SddHub-oU47Hv8Y.js +0 -2
- package/dist/assets/SessionsDashboard-Dp-Mr844.js +0 -1
- package/dist/assets/SetupScreen-BWA_dTU0.js +0 -1
- package/dist/assets/SkillDetailView-DmRgd_uu.js +0 -3
- package/dist/assets/TechStackView-p9PKj9pQ.js +0 -1
- package/dist/assets/codemap-index-store-DDT3gP6t.js +0 -1
- package/dist/assets/index-C09Opuro.css +0 -1
- package/dist/assets/index-DxZTscTk.js +0 -132
- package/dist/assets/progress-ring-DPV94fM-.js +0 -1
- package/dist/assets/ui-store-C-oyG_br.js +0 -1
- package/dist/assets/ws-client-DqIqzkfU.js +0 -1
- package/dist/components/MemoryManager/MemoryInjectorTrace.d.ts +0 -3
- package/dist/components/SageMemoryCard.d.ts +0 -19
package/dist/lib/sage-block.d.ts
CHANGED
|
@@ -1,42 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* sage-block —
|
|
2
|
+
* sage-block — WebUI view over the canonical SAGE suffix splitter.
|
|
3
3
|
*
|
|
4
4
|
* The SAGE Memory Injector middleware (`packages/sage/src/middleware/tool-call-memory.ts`)
|
|
5
5
|
* appends a `--- SAGE: ... ---` block to `payload.result.content` after the
|
|
6
|
-
* normal tool output
|
|
7
|
-
*
|
|
8
|
-
* `ToolResult` renderer wants to surface that block as a separate bordered
|
|
9
|
-
* card instead of letting it leak into the body — this helper does the split.
|
|
6
|
+
* normal tool output. The WebUI `ToolResult` renderer surfaces that block as a
|
|
7
|
+
* separate bordered card instead of letting it leak into the body.
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* ALL parsing logic (headings, memory-line regexes, block walk, truncation
|
|
10
|
+
* recovery) lives in ONE place: `@wrongstack/core/utils/sage-output-block`
|
|
11
|
+
* (`packages/core/src/utils/sage-output-block.ts`). This module is a thin
|
|
12
|
+
* adapter that keeps the historical `SageSplit` / `extractSageBlock` surface
|
|
13
|
+
* (with `cleanOutput`) so existing WebUI consumers don't churn. The TUI
|
|
14
|
+
* (`packages/tui/src/components/history/sage-output-format.ts`) delegates to
|
|
15
|
+
* the same canonical module — see `verify-sage-all-tools.test.ts` and
|
|
16
|
+
* `tests/lib/sage-block.test.ts` for the behavioral lock.
|
|
15
17
|
*/
|
|
18
|
+
import { SAGE_INJECTOR_HEADINGS, type SageOutputSplit } from '@wrongstack/core/utils/sage-output-block';
|
|
19
|
+
export { SAGE_INJECTOR_HEADINGS };
|
|
16
20
|
export interface SageSplit {
|
|
17
21
|
/** Tool result text with the SAGE block removed (trailing whitespace trimmed). */
|
|
18
22
|
cleanOutput: string;
|
|
19
23
|
/**
|
|
20
24
|
* Extracted SAGE block lines including the `--- SAGE:` header. Empty when
|
|
21
|
-
* the input contains no terminal SAGE suffix.
|
|
22
|
-
* lines are excluded so the rendered card doesn't show empty rows.
|
|
25
|
+
* the input contains no terminal SAGE suffix.
|
|
23
26
|
*/
|
|
24
27
|
sageLines: string[];
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
* Find the last SAGE-injector suffix in `output` and split it away from the
|
|
28
|
-
* normal tool text. Behaviour
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* accidentally steals the real trailing block.
|
|
32
|
-
* - Every non-blank line after the header must match the memory-line regex;
|
|
33
|
-
* otherwise the candidate is rejected (defensive against tools that emit
|
|
34
|
-
* a `--- SAGE: ...` shaped header as legitimate output).
|
|
35
|
-
* - Trailing blank/whitespace-only lines after the memory block are tolerated
|
|
36
|
-
* (the injector + downstream serializers sometimes append them) but
|
|
37
|
-
* excluded from `sageLines`.
|
|
38
|
-
* - Real (non-blank) content after the SAGE block disqualifies the candidate
|
|
39
|
-
* — the SAGE header is then treated as ordinary tool output.
|
|
31
|
+
* normal tool text. Behaviour is the canonical `splitSageOutputBlock` from
|
|
32
|
+
* `@wrongstack/core/utils/sage-output-block` (property names preserved for
|
|
33
|
+
* WebUI callers).
|
|
40
34
|
*/
|
|
41
35
|
export declare function extractSageBlock(output: string): SageSplit;
|
|
36
|
+
export type { SageOutputSplit };
|
|
42
37
|
//# sourceMappingURL=sage-block.d.ts.map
|
|
@@ -98,8 +98,8 @@ export interface LocalPrefs {
|
|
|
98
98
|
groupToolCalls: boolean;
|
|
99
99
|
/** Show model reasoning/thinking blocks inline in the chat */
|
|
100
100
|
showModelReasoning: boolean;
|
|
101
|
-
/**
|
|
102
|
-
showAgentSwarmPanel:
|
|
101
|
+
/** Agent swarm panel placement: bottom, sidebar, or off */
|
|
102
|
+
showAgentSwarmPanel: 'bottom' | 'sidebar' | 'off';
|
|
103
103
|
/** Allow tools to access paths outside the project root (inverse of fsAccess). */
|
|
104
104
|
allowOutsideProjectRoot: boolean;
|
|
105
105
|
reasoningMode: 'auto' | 'on' | 'off';
|
package/dist/stores/types.d.ts
CHANGED
|
@@ -37,7 +37,8 @@ export interface ChatMessage {
|
|
|
37
37
|
/**
|
|
38
38
|
* SAGE Memory Injector block for this tool call — header line plus one line
|
|
39
39
|
* per injected memory — delivered as a dedicated `tool.executed.sage` field
|
|
40
|
-
* instead of being buried in `toolResult`. Rendered by
|
|
40
|
+
* instead of being buried in `toolResult`. Rendered as a compact badge by
|
|
41
|
+
* `ToolResult`; full details in the `MemoryInjectorPanel` side drawer.
|
|
41
42
|
*
|
|
42
43
|
* Absent on replayed messages, where the block is still inline in the
|
|
43
44
|
* persisted tool_result content; `extractSageBlock` recovers it there.
|
|
@@ -224,6 +224,17 @@ export type WSServerMessage = WSSessionStart | WSSessionEnd | WSTextDelta | WSTh
|
|
|
224
224
|
payload: {
|
|
225
225
|
sessions: unknown[];
|
|
226
226
|
};
|
|
227
|
+
} | {
|
|
228
|
+
type: 'chimera.report_available';
|
|
229
|
+
payload: {
|
|
230
|
+
reportId: string;
|
|
231
|
+
sessionId: string;
|
|
232
|
+
message: string;
|
|
233
|
+
fileCount: number;
|
|
234
|
+
findingCount: number;
|
|
235
|
+
hasActionableFindings: boolean;
|
|
236
|
+
messageId?: string | undefined;
|
|
237
|
+
};
|
|
227
238
|
} | {
|
|
228
239
|
type: 'mailbox.event';
|
|
229
240
|
payload: Record<string, unknown> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrongstack/webui",
|
|
3
|
-
"version": "0.298.
|
|
3
|
+
"version": "0.298.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Browser-based WebUI for WrongStack — React + Vite frontend. The WebSocket backend lives in the separate @wrongstack/webui-server package (extracted in PR #018b to remove the CLI -> @wrongstack/webui/server cross-package edge).",
|
|
6
6
|
"keywords": [
|
|
@@ -76,21 +76,22 @@
|
|
|
76
76
|
"tailwind-merge": "^3.6.0",
|
|
77
77
|
"virtua": "^0.49.3",
|
|
78
78
|
"zustand": "^5.0.14",
|
|
79
|
-
"@wrongstack/
|
|
80
|
-
"@wrongstack/
|
|
81
|
-
"@wrongstack/
|
|
82
|
-
"@wrongstack/tools": "0.298.
|
|
83
|
-
"@wrongstack/
|
|
79
|
+
"@wrongstack/kanban": "0.298.1",
|
|
80
|
+
"@wrongstack/core": "0.298.1",
|
|
81
|
+
"@wrongstack/webui-server": "0.298.1",
|
|
82
|
+
"@wrongstack/tools": "0.298.1",
|
|
83
|
+
"@wrongstack/plugins": "0.298.1",
|
|
84
|
+
"@wrongstack/providers": "0.298.1"
|
|
84
85
|
},
|
|
85
86
|
"optionalDependencies": {
|
|
86
87
|
"node-pty": "1.2.0-beta.14"
|
|
87
88
|
},
|
|
88
89
|
"devDependencies": {
|
|
89
|
-
"@playwright/test": "^1.62.
|
|
90
|
+
"@playwright/test": "^1.62.1",
|
|
90
91
|
"@tailwindcss/vite": "^4.3.3",
|
|
91
92
|
"@testing-library/dom": "^10.4.1",
|
|
92
93
|
"@testing-library/react": "^16.3.2",
|
|
93
|
-
"@types/node": "^26.1.
|
|
94
|
+
"@types/node": "^26.1.2",
|
|
94
95
|
"@types/qrcode": "^1.5.6",
|
|
95
96
|
"@types/react": "^19.2.17",
|
|
96
97
|
"@types/react-dom": "^19.2.3",
|
|
@@ -102,7 +103,7 @@
|
|
|
102
103
|
"typescript": "^7.0.2",
|
|
103
104
|
"vite": "^8.1.5",
|
|
104
105
|
"vitest": "^4.1.10",
|
|
105
|
-
"@wrongstack/sdd": "0.298.
|
|
106
|
+
"@wrongstack/sdd": "0.298.1"
|
|
106
107
|
},
|
|
107
108
|
"scripts": {
|
|
108
109
|
"dev": "vite",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ca as t,Pi as n,Sr as r,Vt as i,Wi as a,Wr as o,Xn as s,Yt as c,et as l,fa as u,hi as ee,jt as d,ni as f,nn as te,nt as ne,on as p,qi as m,vr as h,vt as g}from"./vendor-BTDGplXK.js";import{t as re}from"./ws-client-DqIqzkfU.js";import{t as _}from"./utils-DxDx8yib.js";import{C as ie,S as v}from"./index-DxZTscTk.js";var y=e(t(),1),b=l();function ae({status:e}){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:`Chronicle ownership`}),(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:_(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:`INLINE FALLBACK`})]})}function x(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var S=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],C=1440*60*1e3;function w(){return{limit:300,order:`desc`,from:new Date(Date.now()-C).toISOString()}}var T=[{id:`all`,label:`All signals`,icon:(0,b.jsx)(u,{})},{id:`llm`,label:`LLM`,icon:(0,b.jsx)(a,{})},{id:`agents`,label:`Agents`,icon:(0,b.jsx)(m,{})},{id:`tools`,label:`Tools`,icon:(0,b.jsx)(d,{})},{id:`files`,label:`Files`,icon:(0,b.jsx)(o,{})},{id:`failures`,label:`Failures`,icon:(0,b.jsx)(g,{})}];function E(){let e=re(),[t,n]=(0,y.useState)([]),[i,l]=(0,y.useState)(null),[u,f]=(0,y.useState)({}),[h,g]=(0,y.useState)(w()),[x,C]=(0,y.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[E,D]=(0,y.useState)(`all`),[A,P]=(0,y.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,de]=(0,y.useState)(O),[L,R]=(0,y.useState)(!0),[z,B]=(0,y.useState)(null),[V,H]=(0,y.useState)(null),[U,fe]=(0,y.useState)([]),[W,pe]=(0,y.useState)([]),[G,me]=(0,y.useState)(null),K=(0,y.useCallback)(t=>{if(!e.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),g(t),f({}),e.send({type:`chronicle.query`,payload:{query:t}}),e.supportsCapability(`chronicle.facets`))e.send({type:`chronicle.facets`,payload:{fields:[...S],query:t,limit:12}});else for(let n of S)e.send({type:`chronicle.facet`,payload:{field:n,query:t,limit:12}})},[e]),q=(0,y.useCallback)(()=>{e.supportsCapability(`chronicle.metrics`)&&(e.send({type:`chronicle.metrics`,payload:{view:`providers`}}),e.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[e]),J=(0,y.useCallback)(()=>{e.supportsCapability(`chronicle.status`)&&e.send({type:`chronicle.status`})},[e]);(0,y.useEffect)(()=>{let t=e.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(n(e.payload.events),P(e.payload),de(e.payload.summary??O),R(!1))}),r=e.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&f(t=>({...t,[e.payload.field]:e.payload.values}))}),i=e.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&f(e.payload.values)}),a=e.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),o=e.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&H(e.payload)}),s=e.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?fe(e.payload.data):e.payload.view===`tasks`&&pe(e.payload.data))}),c=e.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&me(e.payload)});return K(w()),q(),J(),()=>{t(),r(),i(),a(),o(),s(),c()}},[e,K,q,J]);let Y=(0,y.useMemo)(()=>t.filter(e=>k(e,E)),[t,E]),X=ie(Y,25,E),Z=(0,y.useMemo)(()=>{let e=t.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let n=t=>e[t]?.last;return{eventLoop:{utilization:n(`eventLoop.utilization`),delayP95Ms:n(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:n(`memory.heapUsedBytes`)},chronicle:{pendingEvents:n(`chronicle.pendingEvents`),rejectedEvents:n(`chronicle.rejectedEvents`)}}},[t]),Q=(0,y.useMemo)(()=>{let e={};for(let t of W)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=[...W].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:W.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[W]),$=()=>K({...w(),...x.text?{text:x.text}:{},...x.path?{path:x.path}:{},...x.providerId?{providerId:x.providerId}:{},...x.modelId?{modelId:x.modelId}:{},...x.sessionId?{sessionId:x.sessionId}:{}}),he=()=>{C({text:``,path:``,providerId:``,modelId:``,sessionId:``}),D(`all`),K(w())},ge=t=>{l(t),H(null),e.supportsCapability(`chronicle.graph`)&&e.send({type:`chronicle.graph`,payload:{seed:{eventId:t.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)(a,{className:`h-5 w-5 text-primary`}),(0,b.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Coding Intelligence`}),(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:`CHRONICLE`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`LLM, agent, tool and file evidence — connected from decision to code change.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:_(`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(h),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:`Refresh evidence`,children:(0,b.jsx)(p,{className:_(`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)(N,{icon:(0,b.jsx)(a,{}),label:`LLM requests`,value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,b.jsx)(N,{icon:(0,b.jsx)(m,{}),label:`Agent work`,value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,b.jsx)(N,{icon:(0,b.jsx)(d,{}),label:`Tool calls`,value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,b.jsx)(N,{icon:(0,b.jsx)(o,{}),label:`File evidence`,value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,b.jsx)(N,{icon:(0,b.jsx)(te,{}),label:`Retries`,value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,b.jsx)(N,{icon:(0,b.jsx)(ee,{}),label:`Provider p95`,value:j(I.providerP95DurationMs),detail:`${j(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:`Token economics`}),(0,b.jsxs)(`span`,{children:[`fresh input `,(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:[`cache read `,(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:[`cache hit `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[se(I).toFixed(1),`%`]})]}),(0,b.jsxs)(`span`,{children:[`estimated cost `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),U.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:`Model reliability`}),U.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 ${j(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,b.jsx)(`span`,{className:_(`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)(s,{className:`h-3 w-3`}),`Task outcomes`]}),(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:_(`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:_(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:_(`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:j(e.durationMs)}),e.filesTouched>0&&(0,b.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,b.jsx)(o,{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)(M,{icon:(0,b.jsx)(c,{}),placeholder:`Search event evidence`,value:x.text,onChange:e=>C(t=>({...t,text:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`File or directory`,value:x.path,onChange:e=>C(t=>({...t,path:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`Provider`,value:x.providerId,onChange:e=>C(t=>({...t,providerId:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`Model`,value:x.modelId,onChange:e=>C(t=>({...t,modelId:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`Session`,value:x.sessionId,onChange:e=>C(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`}),`Apply`]}),(0,b.jsx)(`button`,{type:`button`,onClick:he,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:`Clear`})]})]})}),(0,b.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[T.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>D(e.id),className:_(`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===e.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.icon,e.label,(0,b.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:oe(I,e.id,A.total)})]},e.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:[A.total.toLocaleString(),` matched`]}),(0,b.jsxs)(`span`,{children:[A.sourceFiles,` journal files`]}),A.invalidLines>0&&(0,b.jsxs)(`span`,{className:`text-warning`,children:[A.invalidLines,` invalid lines`]})]})]}),G&&(0,b.jsx)(ae,{status:G}),Z&&(0,b.jsx)(ce,{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`,``)}),(u[e]??[]).slice(0,4).map(t=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>K({...h,[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:`Time`}),(0,b.jsx)(`span`,{children:`Signal`}),(0,b.jsx)(`span`,{children:`Outcome`}),(0,b.jsx)(`span`,{children:`Model / agent`}),(0,b.jsx)(`span`,{children:`Resource`}),(0,b.jsx)(`span`,{})]}),(0,b.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,b.jsx)(F,{text:z}):!L&&Y.length===0?(0,b.jsx)(F,{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)(le,{event:e,active:i?.eventId===e.eventId,onClick:()=>ge(e)},e.eventId))})}),(0,b.jsx)(v,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),i&&(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:`Evidence & lineage`}),(0,b.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,i.sequence,` · `,i.eventId]})]}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded p-1 hover:bg-muted`,children:(0,b.jsx)(ne,{className:`h-4 w-4`})})]}),(0,b.jsx)(ue,{event:i,graph:V})]})]})}var D={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},O={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:{...D},failuresByFamily:{...D}};function oe(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 se(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function k(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 A(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 j(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function M({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 N({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:_(`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 ce({health:e}){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:`Collector healthy`}),(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:_((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function le({event:e,active:t,onClick:r}){let i=e.occurredAt??e.observedAt,a=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,o=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,b.jsxs)(`button`,{type:`button`,onClick:r,className:_(`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(i).toLocaleTimeString()}),(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(`span`,{className:_(`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:_(`w-fit rounded px-1.5 py-0.5 text-[9px]`,I(e.outcome)),children:e.outcome??`unknown`}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:o}),(0,b.jsx)(n,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function ue({event:e,graph:t}){let n=(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:_(`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:A(Number(e.durationNs??0))})]})]}),(0,b.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,b.jsx)(P,{icon:(0,b.jsx)(i,{}),label:`Evidence hash`,value:e.hash.slice(0,16)}),(0,b.jsx)(P,{icon:(0,b.jsx)(f,{}),label:`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)(h,{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:_(`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:`Lineage truncated at safety limit.`})]}),n.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 P({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 F({text:e}){return(0,b.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function I(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{E as ChronicleDashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ca as t,Di as n,Gn as r,Gr as i,Ht as a,Ii as o,Jt as s,Ni as c,Pr as l,Vr as u,Wn as d,et as f,fa as p,jt as m,lt as h,nt as g,on as _,qi as v,va as y,vr as b,y as x,yi as S}from"./vendor-BTDGplXK.js";import"./i18n-DOuSY1L8.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./monaco-BLUV5g0U.js";import{t as ee}from"./ws-client-DqIqzkfU.js";import{t as k}from"./utils-DxDx8yib.js";import{i as te}from"./codemap-activity-store-C1XWbXeZ.js";import{D as A,M as ne,k as j,o as re,u as ie}from"./stores-CpZiOiOP.js";import{o as M}from"./view-navigation-BRtuAwZo.js";import{A as N,b as ae,x as P}from"./index-DxZTscTk.js";import{t as F}from"./empty-state-BV-Y8c35.js";import{t as I}from"./monaco-theme-DSeCDzQy.js";var L={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`},R=Array.from(new Set(Object.values(L))).filter(e=>e!==`plaintext`),z=12e3,B=4e3,oe=5e3,V=1e4;function H(e){return L[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function U(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function W(e,t){return e.triggerCharacter?!0:t.length>=3}function G(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 K(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 q=e(t(),1),J=f();function se(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 Y=150,ce=224,le=38,X=/(write|edit|update|create|delete|rename|modified|changed)/i;function Z(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Q(e,t){let n=Z(e),r=Z(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ue(e,t=Date.now()){let n=e.filter(e=>t-e.at<=30*6e4),r=n.filter(e=>X.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 $(e){return typeof e==`string`&&e.length>0?e:void 0}function de(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function fe(e){let t=e.attributes??{},n=$(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:de(e),action:n,actor:r??i??$(t.actor)??`external`,source:$(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??$(t.taskId),boardId:$(t.boardId)??e.scope.boardId,tool:$(t.toolName),status:e.outcome,raw:e}}function pe(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 me(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)?!1:(t.add(n),!0)})}function he(e){return e?e.split(/\r?\n/).length:0}function ge(e){return new TextEncoder().encode(e).length}function _e(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ve(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function ye(e,t){let n=P(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 be({file:e}){let{t}=y(),[a,s]=(0,q.useState)(!0),[l,d]=(0,q.useState)(ce),[f,h]=(0,q.useState)(`overview`),[g,v]=(0,q.useState)([]),[x,S]=(0,q.useState)([]),[C,w]=(0,q.useState)(!1),[T,E]=(0,q.useState)(null),[D,O]=(0,q.useState)(null),A=(0,q.useRef)(null),j=ne(e=>e.wsUrl),M=te(e=>e.history),N=te(e=>e.activeOperations),P=ie(e=>e.activeBoard),F=re(e=>e.snapshot),I=(0,q.useMemo)(()=>ee(j),[j]),L=(0,q.useCallback)(()=>{E(null),w(!0),typeof I.getGitDiff==`function`&&I.getGitDiff(e.path);let t=typeof I.supportsCapability==`function`?I.supportsCapability.bind(I):null;t?.(`chronicle.query`)?I.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):w(!1),t?.(`chronicle.metrics`)&&I.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[I,e.path]);(0,q.useEffect)(()=>{v([]),S([]),O(null);let t=I.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Q(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(v(n),w(!1))}),n=I.on(`chronicle.metrics_result`,t=>{t.type!==`chronicle.metrics_result`||t.payload.view!==`files`||S(t.payload.data.filter(t=>Q(t.path,e.path)))}),r=I.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(E(e.payload.message),w(!1))}),i=I.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Q(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){O({text:e.savedContent,available:!1,error:n.error});return}O({text:n.oldText??``,available:!0})});return L(),()=>{t(),n(),r(),i()}},[I,e.path,e.savedContent,L]),(0,q.useEffect)(()=>{let e=e=>{if(!A.current)return;let t=A.current.startY-e.clientY,n=Math.max(Y,Math.floor(window.innerHeight*.62));d(Math.min(n,Math.max(Y,A.current.startHeight+t)))},t=()=>{A.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 R=(0,q.useMemo)(()=>{let t=[];for(let[n,r]of M)Q(n,e.path)&&t.push(...r);for(let n of N.values())t.push(...n.filter(t=>Q(t.filePath,e.path)));return t},[N,e.path,M]),z=(0,q.useMemo)(()=>me([...R.map(pe),...g.map(fe)]),[g,R]),B=(0,q.useMemo)(()=>ue(z),[z]),oe=(0,q.useMemo)(()=>se(x),[x]),V=D?.text??e.savedContent,H=(0,q.useMemo)(()=>ye(V,e.content),[V,e.content]),U=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.sessionId).filter(e=>!!e))],[z]),W=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.actor).filter(Boolean))],[z]),G=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.taskId).filter(e=>!!e))],[z]),K=(0,q.useCallback)(e=>{let t=P?.tasks.find(t=>t.id===e),n=F?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[P,F]),X=e=>{a||s(!0),A.current={startY:e.clientY,startHeight:a?l:Y},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},Z=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,J.jsx)(p,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,J.jsx)(u,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,J.jsx)(r,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,J.jsx)(m,{})}];return(0,J.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:a?l:le},"data-testid":`file-activity-drawer`,children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":t(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:X,onDoubleClick:()=>{s(!0),d(ce)},title:t(`activity:fileActivity.resizeHint`),children:(0,J.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,J.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>s(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":a,children:[(0,J.jsx)(i,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,J.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),a?(0,J.jsx)(o,{className:`h-3 w-3`}):(0,J.jsx)(c,{className:`h-3 w-3`})]}),(0,J.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,J.jsx)(xe,{label:`${he(e.content)} ${t(`activity:fileActivity.lines`)}`}),(0,J.jsx)(xe,{label:_e(ge(e.content))}),!H.large&&(H.added>0||H.removed>0)&&(0,J.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,J.jsxs)(`span`,{className:`text-success`,children:[`+`,H.added]}),(0,J.jsxs)(`span`,{className:`text-destructive`,children:[`−`,H.removed]})]}),(0,J.jsxs)(`span`,{className:k(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,B.level===`churn`&&`bg-destructive/10 text-destructive`,B.level===`active`&&`bg-warning/10 text-warning`,B.level===`quiet`&&`bg-success/10 text-success`),children:[(0,J.jsx)(n,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${B.level}`)]}),(0,J.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:z.length})}),a&&(0,J.jsx)(`button`,{type:`button`,onClick:L,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,J.jsx)(_,{className:k(`h-3.5 w-3.5`,C&&`animate-spin`)})})]}),a&&(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[Z.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>h(e.id),className:k(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,f===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),T&&(0,J.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:T})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[f===`overview`&&(0,J.jsx)(Se,{analysis:B,lifetime:oe,records:z,sessions:U,agents:W,tasks:G,taskLabel:K}),f===`changes`&&(0,J.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,J.jsx)(b,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:D?.available?t(`activity:fileActivity.gitToBuffer`):t(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,J.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t(`activity:fileActivity.unsaved`)}),D?.error&&(0,J.jsx)(`span`,{className:`truncate text-warning`,children:D.error})]}),(0,J.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,J.jsx)(ae,{oldText:V,newText:e.content,caption:e.path,fill:!0})})]}),f===`context`&&(0,J.jsx)(we,{sessions:U,agents:W,tasks:G,records:z,taskLabel:K,boardTitle:P?.title??F?.title}),f===`logs`&&(0,J.jsx)(De,{records:z,loading:C})]})]})]})}function xe({label:e}){return(0,J.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Se({analysis:e,lifetime:t,records:n,sessions:i,agents:o,tasks:s,taskLabel:c}){let{t:l}=y();return(0,J.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,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[{label:l(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,J.jsx)(u,{})},{label:l(`activity:fileActivity.sessions`),value:i.length,icon:(0,J.jsx)(h,{})},{label:l(`activity:fileActivity.actors`),value:o.length,icon:(0,J.jsx)(v,{})},{label:l(`activity:fileActivity.linkedWork`),value:s.length,icon:(0,J.jsx)(r,{})}].map(e=>(0,J.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,J.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,J.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,J.jsx)(Ce,{lifetime:t}),(0,J.jsxs)(`div`,{className:k(`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,J.jsx)(a,{className:k(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-semibold`,children:l(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,J.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:l(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),s.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`activity:fileActivity.workLinks`),`:`]}),s.slice(0,4).map(e=>(0,J.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:c(e)},e))]})]}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,J.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:l(`activity:fileActivity.recentActivity`)}),(0,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:n.length===0?(0,J.jsx)(ke,{text:l(`activity:fileActivity.noEvidence`)}):n.slice(0,5).map(e=>(0,J.jsx)(Oe,{record:e},`${e.id}:${e.at}`))})]})]})}function Ce({lifetime:e}){let{t}=y(),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,J.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,J.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,J.jsx)(i,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,J.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,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,J.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,J.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 we({sessions:e,agents:t,tasks:n,records:i,taskLabel:a,boardTitle:o}){let{t:s}=y();return(0,J.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,J.jsx)(Te,{icon:(0,J.jsx)(h,{}),title:s(`activity:fileActivity.sessions`),empty:s(`activity:fileActivity.noSessions`),children:e.map(e=>(0,J.jsx)(Ee,{title:ve(e),subtitle:`${i.filter(t=>t.sessionId===e).length} ${s(`activity:fileActivity.events`)}`,raw:e},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(v,{}),title:s(`activity:fileActivity.actors`),empty:s(`activity:fileActivity.noActors`),children:t.map(e=>(0,J.jsx)(Ee,{title:e,subtitle:`${i.filter(t=>t.actor===e).length} ${s(`activity:fileActivity.events`)}`},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(r,{}),title:s(`activity:fileActivity.workLinks`),empty:s(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,J.jsx)(Ee,{title:a(e),subtitle:o??s(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Te({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,J.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,J.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,J.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,J.jsx)(ke,{text:n})})]})}function Ee({title:e,subtitle:t,raw:n}){return(0,J.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,J.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,J.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function De({records:e,loading:t}){let{t:n}=y();return t&&e.length===0?(0,J.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,J.jsx)(ke,{text:n(`activity:fileActivity.noEvidence`)}):(0,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,J.jsx)(Oe,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Oe({record:e,raw:t=!1}){let n=(0,J.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,J.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,J.jsx)(`span`,{className:k(`w-fit rounded px-1.5 py-0.5 font-mono`,X.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,J.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,J.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,J.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,J.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:n}),(0,J.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,J.jsx)(`div`,{className:`px-2.5 py-1.5`,children:n})}function ke({text:e}){return(0,J.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}T.config({monaco:O});function Ae(e){switch(e){case`method`:return E.CompletionItemKind.Method;case`function`:return E.CompletionItemKind.Function;case`constructor`:return E.CompletionItemKind.Constructor;case`field`:return E.CompletionItemKind.Field;case`variable`:return E.CompletionItemKind.Variable;case`class`:return E.CompletionItemKind.Class;case`interface`:return E.CompletionItemKind.Interface;case`module`:return E.CompletionItemKind.Module;case`property`:return E.CompletionItemKind.Property;case`unit`:return E.CompletionItemKind.Unit;case`value`:return E.CompletionItemKind.Value;case`enum`:return E.CompletionItemKind.Enum;case`keyword`:return E.CompletionItemKind.Keyword;case`snippet`:return E.CompletionItemKind.Snippet;case`file`:return E.CompletionItemKind.File;case`reference`:return E.CompletionItemKind.Reference;default:return E.CompletionItemKind.Text}}function je(){let e=A(e=>e.openFiles),t=A(e=>e.activeFilePath),n=A(e=>e.setActiveFile),r=A(e=>e.closeFile);return e.length===0?null:(0,J.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let i=e.path===t,a=e.path.split(`/`).pop()??e.path;return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),r(e.path))},className:k(`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`,i?`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,J.jsx)(S,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:a}),(0,J.jsx)(g,{className:k(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,i&&`opacity-100`),onClick:t=>{t.stopPropagation(),r(e.path)}})]},e.path)})})}function Me(){let{t:e}=y(),t=A(e=>e.openFiles),n=A(e=>e.activeFilePath),r=A(e=>e.updateContent),{theme:i}=N(),a=(0,q.useRef)(null),o=(0,q.useRef)(n),c=(0,q.useRef)(new Map),u=(0,q.useMemo)(()=>t.find(e=>e.path===n)??null,[t,n]),d=n?H(n):`plaintext`,f=I(),[p,m]=(0,q.useState)(!1);(0,q.useEffect)(()=>{o.current=n},[n]),(0,q.useEffect)(()=>{let e=I();C.setTheme(e)},[i]),(0,q.useEffect)(()=>{let e=R.map(e=>E.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=o.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),s=e.getValue(),l=s.slice(Math.max(0,a-z),a),u=s.slice(a,a+B),d=e.getLineContent(t.lineNumber).slice(0,Math.max(0,t.column-1)),f=U(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!W(p,f))return{suggestions:[]};let m=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,h=e.getWordUntilPosition(t),g={startLineNumber:t.lineNumber,endLineNumber:t.lineNumber,startColumn:h.startColumn,endColumn:t.column},_=ee(ne.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:Ae(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:g,insertTextRules:e.kind===`snippet`?E.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),y=K({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=c.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let o=!1,d=()=>{},h=null,g,b=e=>{o||(o=!0,d(),g!==void 0&&window.clearTimeout(g),h?.dispose(),a({suggestions:e}))};d=_.on(`completion.result`,e=>{let t=e;t.payload.requestId===m&&(c.current.set(y,{expiresAt:Date.now()+V,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),oe),h=r.onCancellationRequested(()=>b([])),_.requestCompletion({requestId:m,filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,content:s.length<=5e5?s:void 0,prefix:l,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:G(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let h=(0,q.useCallback)(()=>{let e=a.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},[]),g=(0,q.useCallback)(()=>{M(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),_=(0,q.useCallback)(()=>{let e=o.current;if(!e)return;let t=h();t&&(j.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),g())},[h,g]),v=(0,q.useCallback)(()=>{let e=o.current;e&&(j.getState().addRef({kind:`file`,path:e}),g())},[g]),b=(0,q.useCallback)(t=>{a.current=t,C.setTheme(I()),t.onDidChangeCursorSelection(()=>{let e=t.getSelection();m(!!e&&!e.isEmpty())}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[w.CtrlCmd|w.Shift|D.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?_():v()}})},[_,v]),S=(0,q.useCallback)(e=>{n&&e!==void 0&&r(n,e)},[n,r]);return(0,q.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:n}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),n&&A.getState().closeFile(n)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),t.length===0?(0,J.jsx)(F,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,J.jsx)(je,{}),(0,J.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(p||u)&&(0,J.jsx)(`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,J.jsxs)(`button`,{type:`button`,onClick:p?_:v,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(p?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[p?(0,J.jsx)(s,{className:`h-3 w-3`}):(0,J.jsx)(l,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e(p?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,J.jsx)(x,{language:d,value:u.content,onChange:S,theme:f,onMount:b,loading:(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:!1},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},u.path):(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),u&&(0,J.jsx)(be,{file:u})]})}export{Me as CodeEditor};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ca as t,En as n,Ii as r,Ki as i,Or as a,Pi as o,Tn as s,Tr as c,Ur as l,Vt as u,Wn as d,Yr as f,Yt as p,_ as m,_n as h,a as g,aa as _,c as ee,et as v,f as y,fa as b,fn as x,g as te,h as ne,ha as re,i as ie,m as ae,n as oe,nr as S,nt as C,p as se,r as w,s as ce,sn as T,u as le,ur as ue,vr as E,wn as de,wt as fe}from"./vendor-BTDGplXK.js";import{t as D}from"./utils-DxDx8yib.js";import{i as pe,r as me,t as he}from"./codemap-activity-store-C1XWbXeZ.js";import{t as ge}from"./codemap-index-store-DDT3gP6t.js";var O=e(t(),1),k=4096,A=new Map;function j(e){let t=A.get(e);if(t!==void 0)return t;let n=e.replace(/\\/g,`/`).replace(/^\.\//,``).toLocaleLowerCase();for(;A.size>=k;){let e=A.keys().next().value;if(e===void 0)break;A.delete(e)}return A.set(e,n),n}function M(e){return e.level===`packages`?`packages`:e.level===`files`?`files:${e.package}`:`symbols:${e.file}`}function _e(e){return e.level===`packages`?`/api/codemap/packages`:e.level===`files`?`/api/codemap/files?package=${encodeURIComponent(e.package)}`:`/api/codemap/symbols?file=${encodeURIComponent(e.file)}`}function ve(e,t,n){let r=new Map(e.nodes.map(e=>[e.id,e])),i=[];for(let a of e.edges){let e=n===`incoming`?a.target===t?a.source:void 0:a.source===t?a.target:void 0;if(!e)continue;let o=r.get(e);o&&i.push({node:o,edge:a})}return i.sort((e,t)=>t.edge.weight-e.edge.weight||e.node.label.localeCompare(t.node.label))}function ye(e,t){let n=new Set([t]);for(let r of e.edges)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}function N(e,t){let n=new Map(e.nodes.map(e=>[e.id,0]));for(let r of e.edges)!t.has(r.source)||!t.has(r.target)||(n.set(r.source,(n.get(r.source)??0)+r.weight),r.target!==r.source&&n.set(r.target,(n.get(r.target)??0)+r.weight));return n}function be(e){let t=new Set(e.nodes.map(e=>e.id)),n=N(e,t),r=new Map(e.nodes.map(e=>[e.id,0])),i=new Map;for(let n of e.edges){if(!t.has(n.source)||!t.has(n.target)||n.source===n.target)continue;r.set(n.target,(r.get(n.target)??0)+1);let e=i.get(n.source)??[];e.push(n.target),i.set(n.source,e)}let a=new Map,o=e.nodes.filter(e=>(r.get(e.id)??0)===0).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0)).map(e=>e.id);o.length===0&&e.nodes[0]&&o.push(e.nodes[0].id);for(let e of o)a.set(e,0);let s=new Set,c=0;for(;c<o.length;){let e=o[c++];if(!s.has(e)){s.add(e);for(let t of i.get(e)??[])a.set(t,Math.max(a.get(t)??0,Math.min((a.get(e)??0)+1,7))),r.set(t,(r.get(t)??1)-1),(r.get(t)??0)<=0&&o.push(t)}}let l=e.nodes.filter(e=>!a.has(e.id)).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0));l.forEach((e,t)=>{a.set(e.id,t%Math.min(4,Math.max(1,l.length)))});let u=new Map;for(let t of e.nodes){let e=a.get(t.id)??0,n=u.get(e)??[];n.push(t),u.set(e,n)}for(let e of u.values())e.sort((e,t)=>Number(e.external)-Number(t.external)||(n.get(t.id)??0)-(n.get(e.id)??0)||e.label.localeCompare(t.label));let d=Math.max(1,...[...u.values()].map(e=>e.length))*160,f=[];for(let[e,t]of[...u.entries()].sort(([e],[t])=>e-t)){let n=(d-t.length*160)/2;t.forEach((t,r)=>{f.push({node:t,position:{x:e*386,y:n+r*160}})})}return f}function P(e,t){if(e.nodes.length===0)return[];let n=N(e,new Set(e.nodes.map(e=>e.id))),r=e.nodes.find(e=>e.id===t)??[...e.nodes].sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0))[0],i=ye(e,r.id);i.delete(r.id);let a=e.nodes.filter(e=>i.has(e.id)),o=e.nodes.filter(e=>e.id!==r.id&&!i.has(e.id)),s=[{node:r,position:{x:0,y:0}}],c=(e,t,n)=>{e.forEach((r,i)=>{let a=n+Math.PI*2*i/Math.max(1,e.length);s.push({node:r,position:{x:Math.cos(a)*t,y:Math.sin(a)*t}})})};c(a,Math.max(330,a.length*34),-Math.PI/2);for(let e=0;e<o.length;e+=18)c(o.slice(e,e+18),620+Math.floor(e/18)*280,-Math.PI/2+.12);return s}function xe(e,t,n){return t===`orbit`?P(e,n):be(e)}function Se(e,t,n){if(e.length<=n)return e;let r=t?e.filter(e=>e.source===t||e.target===t):[],i=e.filter(e=>!t||e.source!==t&&e.target!==t).sort((e,t)=>t.weight-e.weight||e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),a=Math.max(0,n-r.length);return[...r,...i.slice(0,a)]}function Ce(e,t,n){if(n===`all`)return e;let r=e.nodes;if(e.nodes.length>96){let n=new Map(e.nodes.map(e=>[e.id,e])),i=new Map;for(let t of e.edges)i.set(t.source,(i.get(t.source)??0)+t.weight),i.set(t.target,(i.get(t.target)??0)+t.weight);let a=[...e.nodes].sort((e,t)=>(i.get(t.id)??0)-(i.get(e.id)??0)||e.label.localeCompare(t.label)),o=new Set,s=e=>{n.has(e)&&o.size<96&&o.add(e)};if(t&&n.has(t)){s(t);let n=e.edges.filter(e=>e.source===t||e.target===t).sort((e,t)=>t.weight-e.weight);for(let e of n)s(e.source),s(e.target);let r=new Set(o),i=e.edges.filter(e=>r.has(e.source)||r.has(e.target)).sort((e,t)=>t.weight-e.weight);for(let e of i)s(e.source),s(e.target)}else{let e=a.filter(e=>!e.external).slice(0,72),t=a.filter(e=>e.external).slice(0,24);for(let n of[...e,...t])s(n.id)}for(let e of a)s(e.id);r=e.nodes.filter(e=>o.has(e.id))}let i=new Set(r.map(e=>e.id)),a=e.edges.filter(e=>i.has(e.source)&&i.has(e.target));return{nodes:r,edges:Se(a,t,180)}}function F(e){let t=(e.file??e.label).replace(/\\/g,`/`),n=e.package??``,r=n.startsWith(`@wrongstack/`)?`/packages/${n.slice(12)}/`:n.startsWith(`app:`)?`/apps/${n.slice(4)}/`:void 0;if(r){let e=t.indexOf(r);if(e>=0)return t.slice(e+r.length)}let i=t.lastIndexOf(`/src/`);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}var we=new WeakMap;function Te(e){let t=we.get(e);if(t)return t;let n={name:``,path:``,directories:[],files:[]};for(let t of e.filter(e=>e.kind===`file`&&!e.external)){let e=F(t).split(`/`).filter(Boolean),r=e.pop()??t.label,i=n;for(let t of e){let e=i.path?`${i.path}/${t}`:t,n=i.directories.find(e=>e.name===t);n||(n={name:t,path:e,directories:[],files:[]},i.directories.push(n)),i=n}i.files.push({...t,label:r})}let r=e=>{e.directories.sort((e,t)=>e.name.localeCompare(t.name)),e.files.sort((e,t)=>e.label.localeCompare(t.label)),e.directories.forEach(r)};return r(n),we.set(e,n),n}function Ee(e){let t=2166136261,n=e=>{for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(let t of e.nodes)n(t.id);for(let r of e.edges)n(r.source),n(r.target),n(r.refType),t^=r.weight|0,t=Math.imul(t,16777619);return`${e.nodes.length}:${e.edges.length}:${t>>>0}`}function De(e,t,n,r){for(e.has(t)&&e.delete(t),e.set(t,n);e.size>r;){let t=e.keys().next().value;if(t===void 0)break;e.delete(t)}}function Oe(e,t){if(!e||!t)return!1;let n=j(e),r=j(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ke(e){let t=j(e),n=t.match(/\/packages\/([^/]+)\//);if(n?.[1])return`@wrongstack/${n[1]}`;let r=t.match(/\/apps\/([^/]+)\//);return r?.[1]?`app:${r[1]}`:`(root)`}function Ae(e,t){return t.kind===`package`?ke(e.filePath)===(t.package??t.label):Oe(e.filePath,t.file)?t.kind!==`symbol`||e.symbol?.id===t.id:!1}function je(e){let t=new Map;for(let n of e){let e=j(n.filePath),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function Me(e,t){let n=new Map;if(t.length===0||e.length===0)return n;let r=je(t),i=new Map;for(let a of e){let e;if(a.kind===`package`){let n=a.package??a.label,r=i.get(n);r||(r=t.filter(e=>ke(e.filePath)===n),i.set(n,r)),e=r}else if(a.file){let t=j(a.file),n=r.get(t);if(!n){n=[];for(let[e,i]of r)(e.endsWith(`/${t}`)||t.endsWith(`/${e}`))&&n.push(...i)}e=a.kind===`symbol`?n.filter(e=>e.symbol?.id===a.id):n}else e=[];e.length>0&&n.set(a.id,e)}return n}function Ne(e){if(e.length===0)return``;let t=`${e.length}`;for(let n=0;n<e.length;n++){let r=e[n];t+=`|${r.id??``}:${r.toolUseId??``}:${r.filePath}:${r.type}:${r.status??``}:${r.symbol?.id??``}:${r.timestamp}`}return t}function Pe(e,t){let n=t.filter(t=>t.kind===`symbol`&&!t.external&&Oe(t.file,e.filePath));if(n.length===0)return;if(e.line)return[...n].sort((e,t)=>(t.line??0)-(e.line??0)).find(t=>(t.line??0)<=e.line)??n[0];let r=e.summary.toLocaleLowerCase();return n.find(e=>e.label.length>2&&(r.includes(e.label.toLocaleLowerCase())||!!(e.signature&&r.includes(e.signature.toLocaleLowerCase()))))}var I=v();function Fe({historyFile:e,fileHistory:t,onClose:n}){return(0,I.jsxs)(`div`,{className:`absolute right-0 top-0 z-50 flex h-full w-[390px] max-w-[90%] flex-col border-l bg-card shadow-2xl`,children:[(0,I.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b px-4`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(b,{className:`h-4 w-4 shrink-0 text-warning`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[11px] font-semibold`,title:e,children:e})]}),(0,I.jsx)(`button`,{type:`button`,onClick:n,className:`flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,"aria-label":`Close activity`,children:(0,I.jsx)(C,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:t.length===0?(0,I.jsx)(`p`,{className:`py-12 text-center text-[10px] text-muted-foreground`,children:`No activity recorded for this file yet.`}):t.map((e,t)=>(0,I.jsxs)(`div`,{className:`mb-1 flex items-start gap-2 border p-2 text-[10px]`,children:[(0,I.jsx)(`span`,{className:D(`border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/40 text-destructive`:e.type===`read`?`border-info/40 text-info`:`border-warning/40 text-warning`),children:e.type}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(e.timestamp).toLocaleTimeString()}),e.toolName&&(0,I.jsxs)(`div`,{className:`mt-1`,children:[`via `,e.toolName]}),e.agent&&(0,I.jsx)(`div`,{className:`text-muted-foreground`,children:e.agent}),e.summary&&(0,I.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:e.summary}),e.change&&(0,I.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,I.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,I.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.change.before&&(0,I.jsx)(`span`,{className:`ml-1 truncate text-destructive/80`,title:e.change.before,children:e.change.before}),e.change.after&&(0,I.jsxs)(`span`,{className:`truncate text-success/80`,title:e.change.after,children:[`→ `,e.change.after]})]}),(0,I.jsxs)(`div`,{className:`mt-1 flex gap-2 font-mono text-[8px] uppercase text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:e.status??`observed`}),(0,I.jsx)(`span`,{children:e.source??`legacy`}),e.durationMs!==void 0&&(0,I.jsxs)(`span`,{children:[e.durationMs,`ms`]}),e.watcherConfirmed&&(0,I.jsx)(`span`,{className:`text-success`,children:`fs verified`})]})]})]},`${e.timestamp}-${t}`))}),(0,I.jsxs)(`div`,{className:`border-t px-4 py-2 font-mono text-[9px] text-muted-foreground`,children:[t.length,` events · newest first`]})]})}var L={package:{icon:de,accent:`border-l-primary`,iconStyle:`bg-primary/12 text-primary`},file:{icon:l,accent:`border-l-info`,iconStyle:`bg-info/12 text-info`},symbol:{icon:i,accent:`border-l-success`,iconStyle:`bg-success/12 text-success`}},Ie={call:`hsl(var(--primary))`,import:`hsl(var(--info))`,type_ref:`hsl(var(--success))`,inherit:`hsl(var(--warning))`,implement:`hsl(var(--destructive))`},Le={read:`ring-2 ring-info/60 shadow-info/20`,write:`ring-2 ring-warning/70 shadow-warning/30`,edit:`ring-2 ring-warning/80 shadow-warning/40`,delete:`ring-2 ring-destructive/70 shadow-destructive/30`,search:`ring-2 ring-primary/55 shadow-primary/20`,memory:`ring-2 ring-success/60 shadow-success/30`,index:`ring-2 ring-info/50 shadow-info/20`,execute:`ring-2 ring-primary/55 shadow-primary/25`},Re=[`bg-primary text-primary-foreground`,`bg-info text-info-foreground`,`bg-success text-success-foreground`,`bg-warning text-warning-foreground`,`bg-destructive text-destructive-foreground`];function ze(e){let t=e.trim().split(/[\s:_-]+/).filter(Boolean);return(t.length>1?`${t[0]?.[0]??``}${t[1]?.[0]??``}`:e.slice(0,2)).toLocaleUpperCase()}function R(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return Re[Math.abs(t)%Re.length]??Re[0]}function Be(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return`hsl(${Math.abs(t)%360} 82% 58%)`}function z(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/packages/`),r=t.lastIndexOf(`/apps/`),i=Math.max(n,r);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}function B(e){return[e.symbol?.name,e.line?`L${e.line}`:void 0].filter(Boolean).join(` · `)}function Ve({data:e}){let{graphNode:t,selected:n,dimmed:r,incoming:i,outgoing:a,isActive:o,activityType:s,activeOperations:c}=e,l=L[t.kind],u=l.icon,d=t.kind!==`symbol`,p=t.kind===`symbol`?`${t.symbolKind??`symbol`}${t.line?` · L${t.line}`:``}`:t.kind===`file`?F(t):`${t.fileCount??0} files · ${t.symbolCount??0} symbols`;return(0,I.jsxs)(`div`,{className:D(`group relative w-[236px] border border-l-[3px] bg-card text-card-foreground shadow-[0_8px_24px_hsl(var(--shadow-color)/0.08)] transition-[opacity,box-shadow,border-color,background-color]`,l.accent,n&&`border-primary bg-primary/5 shadow-[0_0_0_2px_hsl(var(--primary)/0.18),0_16px_36px_hsl(var(--shadow-color)/0.18)]`,t.external&&`border-dashed bg-muted/75`,r&&`opacity-25 grayscale`,o&&s&&Le[s]),children:[c.length>0&&(0,I.jsxs)(`div`,{className:`absolute -top-5 left-2 z-20 flex max-w-[210px] items-center gap-1`,children:[c.slice(0,4).map(e=>{let t=e.agentName??e.agent??`External`,n=`${e.sessionId??`none`}:${e.agentId??t}`;return(0,I.jsxs)(`span`,{className:D(`flex h-6 items-center gap-1 border-2 border-background px-1.5 font-mono text-[8px] font-bold shadow-md`,R(n)),title:`${t} · ${e.type} ${B(e)}`,children:[(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-current`}),ze(t),e.symbol&&(0,I.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.symbol.name})]},e.id??`${n}:${e.filePath}`)}),c.length>4&&(0,I.jsxs)(`span`,{className:`border bg-card px-1 font-mono text-[8px] shadow`,children:[`+`,c.length-4]})]}),(0,I.jsx)(ce,{type:`target`,position:m.Left,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`}),(0,I.jsxs)(`button`,{type:`button`,className:`block w-full text-left`,onClick:n=>{if(n.shiftKey&&t.file){e.onShowHistory(t.file);return}e.onSelect(t)},onDoubleClick:()=>d&&e.onOpen(t),"aria-label":`${t.kind} ${t.label}`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3 p-3 pr-10`,children:[(0,I.jsx)(`span`,{className:D(`flex h-8 w-8 shrink-0 items-center justify-center border`,l.iconStyle),children:(0,I.jsx)(u,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:t.kind}),t.external&&(0,I.jsx)(`span`,{className:`border border-border px-1 py-0.5 text-[8px] text-warning`,children:`external`}),t.lang&&(0,I.jsx)(`span`,{className:`ml-auto font-mono normal-case tracking-normal`,children:t.lang})]}),(0,I.jsx)(`div`,{className:`truncate font-mono text-[13px] font-semibold`,title:t.label,children:t.label}),(0,I.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,title:p,children:p})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 border-t bg-muted/30 px-3 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,I.jsxs)(`span`,{title:`Incoming relationships`,children:[`← `,i]}),(0,I.jsxs)(`span`,{title:`Outgoing relationships`,children:[`→ `,a]}),t.symbolCount!==void 0&&t.kind===`file`&&(0,I.jsxs)(`span`,{className:`ml-auto`,children:[t.symbolCount,` sym`]}),o&&(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-bold text-warning`,children:[(0,I.jsx)(T,{className:`h-2.5 w-2.5 animate-pulse`}),` LIVE`]})]})]}),d&&(0,I.jsx)(`button`,{type:`button`,className:`absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center border border-transparent text-muted-foreground opacity-0 transition hover:border-border hover:bg-muted hover:text-foreground group-hover:opacity-100 focus:opacity-100`,onClick:()=>e.onOpen(t),title:t.kind===`package`?`Open file map`:`Open symbol map`,"aria-label":`Open ${t.label} map`,children:(0,I.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(ce,{type:`source`,position:m.Right,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`})]})}function He(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function V(e,t){return e.graphNode===t.graphNode&&e.selected===t.selected&&e.dimmed===t.dimmed&&e.incoming===t.incoming&&e.outgoing===t.outgoing&&e.isActive===t.isActive&&e.activityType===t.activityType&&e.onSelect===t.onSelect&&e.onOpen===t.onOpen&&e.onShowHistory===t.onShowHistory&&He(e.activeOperations,t.activeOperations)}var Ue={codemap:(0,O.memo)(Ve,(e,t)=>V(e.data,t.data))},We={nodes:[],edges:[]};function Ge({loading:e,error:t,graph:r,canvasNodeCount:i,flowNodes:a,flowEdges:o,onNodesChange:s,onEdgesChange:c,agentTrailCount:l}){return(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/75 backdrop-blur-sm`,children:[(0,I.jsx)(d,{className:`h-7 w-7 animate-spin text-primary`}),(0,I.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Mapping relationships`})]}),t&&!e&&(0,I.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,I.jsx)(n,{className:`h-10 w-10 text-destructive`}),(0,I.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:t}),(0,I.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`The map needs a codebase index. Run`,` `,(0,I.jsx)(`code`,{className:`border bg-muted px-1.5 py-0.5`,children:`codebase-index`}),` once, then reopen this view.`]})]}),!e&&!t&&r.nodes.length===0&&(0,I.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,I.jsx)(n,{className:`h-8 w-8 opacity-40`}),(0,I.jsx)(`p`,{className:`text-xs`,children:`No indexed nodes at this level.`})]}),!e&&!t&&r.nodes.length>1&&r.edges.length===0&&(0,I.jsxs)(`div`,{className:`pointer-events-none absolute left-1/2 top-14 z-10 -translate-x-1/2 border border-warning/40 bg-warning/10 px-3 py-2 text-center shadow backdrop-blur`,children:[(0,I.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-wider text-warning`,children:`No resolved relations in this scope`}),(0,I.jsx)(`div`,{className:`mt-0.5 text-[8px] text-muted-foreground`,children:`The upgraded index will rebuild and resolve call/import/type links automatically.`})]}),!t&&r.nodes.length>0&&(0,I.jsxs)(y,{nodes:a,edges:o,onNodesChange:s,onEdgesChange:c,nodeTypes:Ue,nodesConnectable:!1,nodesDraggable:!1,edgesFocusable:!1,elementsSelectable:!1,onlyRenderVisibleElements:!0,minZoom:.08,maxZoom:2.2,proOptions:{hideAttribution:!0},children:[(0,I.jsx)(w,{variant:ie.Dots,gap:i>60?32:22,size:1,color:`hsl(var(--muted-foreground))`,className:`!opacity-25`}),(0,I.jsx)(g,{position:`bottom-left`,showInteractive:!1,className:`!border !border-border !bg-card !shadow-md [&>button]:!border-border [&>button]:!bg-card [&>button]:!fill-foreground`}),i<=48&&(0,I.jsx)(ee,{position:`bottom-right`,pannable:!0,zoomable:!0,className:`!h-[112px] !w-[180px] !border !border-border !bg-card !shadow-md`,maskColor:`hsl(var(--background) / 0.72)`,nodeColor:e=>{let t=e.data?.graphNode.kind;return t===`package`?`hsl(var(--primary))`:t===`file`?`hsl(var(--info))`:`hsl(var(--success))`}})]}),(0,I.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-3 border bg-card/90 px-3 py-1.5 font-mono text-[8px] text-muted-foreground shadow backdrop-blur`,children:[Object.entries(Ie).map(([e,t])=>(0,I.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`h-0.5 w-3`,style:{backgroundColor:t}}),e.replace(`_`,` `)]},e)),(0,I.jsxs)(`span`,{className:`flex items-center gap-1 text-primary`,"data-testid":`agent-trail-count`,children:[(0,I.jsx)(`span`,{className:`w-4 border-t-2 border-dashed border-primary`}),`agent trail`,l>0?` ×${l}`:``]})]})]})}function Ke({layout:e,canvasMode:t,edgeFilter:n,canvasNodeCount:r,graphNodeCount:i,onLayoutChange:a,onCanvasModeChange:o,onEdgeFilterChange:c}){return(0,I.jsxs)(`div`,{className:`pointer-events-none absolute left-3 right-3 top-3 z-10 flex items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,I.jsxs)(`button`,{type:`button`,className:D(`flex h-8 items-center gap-1.5 border-r px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`layers`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>a(`layers`),children:[(0,I.jsx)(S,{className:`h-3 w-3`}),` Layers`]}),(0,I.jsxs)(`button`,{type:`button`,className:D(`flex h-8 items-center gap-1.5 px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`orbit`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>a(`orbit`),children:[(0,I.jsx)(s,{className:`h-3 w-3`}),` Relations`]})]}),(0,I.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,I.jsxs)(`button`,{type:`button`,className:D(`h-8 border-r px-2.5 font-mono text-[9px] font-bold`,t===`smart`?`bg-success text-success-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>o(`smart`),title:`Keep the full tree, show the strongest relations and selected neighbourhood`,children:[`SMART `,r,`/`,i]}),(0,I.jsx)(`button`,{type:`button`,className:D(`h-8 px-2.5 font-mono text-[9px] font-bold`,t===`all`?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>o(`all`),title:`Render every node and relation in this scope`,children:`ALL`})]}),(0,I.jsx)(`div`,{className:`pointer-events-auto ml-auto flex max-w-[60%] overflow-x-auto border bg-card/95 shadow-md backdrop-blur`,children:[`all`,`import`,`call`,`type_ref`,`inherit`,`implement`].map(e=>(0,I.jsx)(`button`,{type:`button`,className:D(`h-8 whitespace-nowrap border-r px-2.5 font-mono text-[9px] last:border-r-0`,n===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>c(e),children:e===`all`?`ALL LINKS`:e.replace(`_`,` `).toUpperCase()},e))})]})}function qe({scope:e,graph:t,agentPresences:r,edgeWeight:i,connectedNodeCount:a,navigate:s}){return(0,I.jsxs)(`header`,{className:`flex h-[62px] shrink-0 items-center gap-4 border-b bg-card px-4`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-[220px] items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center border border-primary bg-primary/10 text-primary`,children:(0,I.jsx)(n,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`font-display text-sm font-semibold tracking-tight`,children:`Code Atlas`}),(0,I.jsx)(`p`,{className:`text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Architecture intelligence`})]})]}),(0,I.jsxs)(`nav`,{className:`flex min-w-0 flex-1 items-center gap-1 font-mono text-[10px]`,"aria-label":`Code map breadcrumb`,children:[e.level!==`packages`&&(0,I.jsx)(`button`,{type:`button`,className:`mr-1 flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,onClick:()=>{e.level===`symbols`?s({level:`files`,package:e.package??`(root)`}):s({level:`packages`})},"aria-label":`Back`,children:(0,I.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,I.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-1.5 py-1 text-muted-foreground hover:text-foreground`,onClick:()=>s({level:`packages`}),children:[(0,I.jsx)(ue,{className:`h-3 w-3`}),` workspace`]}),e.level!==`packages`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{className:`h-3 w-3 text-muted-foreground`}),(0,I.jsx)(`button`,{type:`button`,className:`max-w-[220px] truncate px-1.5 py-1 hover:text-primary`,onClick:()=>s({level:`files`,package:e.package??`(root)`}),children:e.package??`(root)`})]}),e.level===`symbols`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{className:`h-3 w-3 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`truncate px-1.5 py-1 text-primary`,children:F({id:``,label:e.file,kind:`file`,file:e.file,package:e.package})})]})]}),(0,I.jsxs)(`div`,{className:`hidden items-center gap-5 xl:flex`,children:[(0,I.jsxs)(`div`,{className:D(`flex h-8 items-center gap-2 border px-2.5`,r.length>0?`border-success/50 bg-success/10 text-success`:`text-muted-foreground`),children:[(0,I.jsx)(T,{className:D(`h-3 w-3`,r.length>0&&`animate-pulse`)}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`font-mono text-[10px] font-bold`,children:[r.length,` LIVE`]}),(0,I.jsx)(`div`,{className:`text-[7px] uppercase tracking-wider`,children:`agents`})]})]}),(0,I.jsxs)(`div`,{className:`text-right`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:t.nodes.length}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`nodes`})]}),(0,I.jsxs)(`div`,{className:`text-right`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:t.edges.length}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`links`})]}),(0,I.jsxs)(`div`,{className:`text-right`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:i}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`references`})]}),(0,I.jsxs)(`div`,{className:`text-right`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:a}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`connected`})]})]})]})}function H({activity:e}){return(0,I.jsx)(`span`,{className:D(`shrink-0 border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/50 bg-destructive/10 text-destructive`:e.type===`read`?`border-info/50 bg-info/10 text-info`:e.type===`search`||e.type===`index`?`border-primary/50 bg-primary/10 text-primary`:`border-warning/50 bg-warning/10 text-warning`),children:e.filePath.startsWith(`(tool:`)?e.toolName:e.type})}function U({activity:e,onLocate:t,showAgent:n=!1}){let r=e.agentName??e.agent??`External process`,i=`${e.sessionId??`none`}:${e.agentId??r}`;return(0,I.jsxs)(`button`,{type:`button`,className:`group flex w-full items-start gap-2 border-b px-3 py-2 text-left last:border-b-0 hover:bg-muted/70`,onClick:()=>!e.filePath.startsWith(`(`)&&t(e),title:`Locate ${e.filePath}`,children:[n&&(0,I.jsx)(`span`,{className:D(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center font-mono text-[8px] font-black`,R(i)),children:ze(r)}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(H,{activity:e}),n&&(0,I.jsx)(`span`,{className:`truncate text-[9px] font-semibold`,children:r}),e.status===`active`&&(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[8px] font-bold text-success`,children:[(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-success`}),` LIVE`]}),e.watcherConfirmed&&(0,I.jsx)(u,{className:`ml-auto h-3 w-3 text-success`,"aria-label":`Filesystem confirmed`}),e.attribution===`correlated`&&!e.watcherConfirmed&&(0,I.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-warning`,title:`Correlated from the only active tool`,children:`~ correlated`}),e.attribution===`external`&&(0,I.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-destructive`,children:`external`})]}),(0,I.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] font-semibold`,title:e.filePath,children:z(e.filePath)}),(e.symbol||e.line)&&(0,I.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 truncate font-mono text-[8px] text-success`,children:[(0,I.jsx)(fe,{className:`h-2.5 w-2.5 shrink-0`}),e.symbol?.name??`line ${e.line}`,e.symbol?.kind&&(0,I.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.symbol.kind]})]}),e.change&&(0,I.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,I.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,I.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.durationMs!==void 0&&(0,I.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.summary&&e.summary!==e.toolName&&(0,I.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[8px] leading-3 text-muted-foreground`,children:e.summary})]}),!e.filePath.startsWith(`(`)&&(0,I.jsx)(f,{className:`mt-1 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function Je({presences:e,onLocate:t}){return e.length===0?null:(0,I.jsxs)(`section`,{className:`pointer-events-auto absolute left-3 top-14 z-20 w-[304px] border bg-card/95 shadow-xl backdrop-blur`,children:[(0,I.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,I.jsx)(T,{className:`h-3.5 w-3.5 animate-pulse text-success`}),(0,I.jsx)(`h2`,{className:`text-[9px] font-black uppercase tracking-[0.18em]`,children:`Live agent operations`}),(0,I.jsxs)(`span`,{className:`ml-auto bg-success px-1.5 py-0.5 font-mono text-[8px] font-bold text-success-foreground`,children:[e.length,` ONLINE`]})]}),(0,I.jsx)(`div`,{className:`max-h-[330px] overflow-y-auto`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/35 px-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:D(`flex h-6 w-6 items-center justify-center font-mono text-[8px] font-black`,R(e.key)),children:ze(e.agentName)}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`truncate text-[9px] font-bold`,children:e.agentName}),(0,I.jsxs)(`div`,{className:`truncate font-mono text-[7px] text-muted-foreground`,children:[`session `,e.sessionId.slice(0,12),` · agent `,e.agentId.slice(0,12)]})]}),(0,I.jsxs)(`span`,{className:`font-mono text-[8px] text-success`,children:[e.operations.length,` op`]})]}),e.operations.map(e=>(0,I.jsx)(U,{activity:e,onLocate:t},e.id??`${e.toolUseId}:${e.filePath}`))]},e.key))})]})}function Ye({paused:e,followLive:t,agentFilter:n,agents:r,onTogglePaused:i,onToggleFollow:a,onAgentFilter:o}){return(0,I.jsxs)(`div`,{className:`pointer-events-auto absolute right-3 top-14 z-20 flex h-9 items-center border bg-card/95 shadow-lg backdrop-blur`,children:[(0,I.jsxs)(`button`,{type:`button`,className:D(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:a,title:`Automatically enter the file/function used by the newest visible agent`,children:[(0,I.jsx)(fe,{className:`h-3 w-3`}),` Follow`]}),(0,I.jsxs)(`button`,{type:`button`,className:D(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,e?`bg-warning text-warning-foreground`:`text-success hover:bg-success/10`),onClick:i,title:e?`Resume the live telemetry stream`:`Freeze the current telemetry frame`,children:[e?(0,I.jsx)(x,{className:`h-3 w-3`}):(0,I.jsx)(h,{className:`h-3 w-3`}),e?`Resume`:`Live`]}),(0,I.jsxs)(`label`,{className:`flex h-full items-center gap-1.5 px-2 text-[8px] uppercase text-muted-foreground`,children:[`Agent`,(0,I.jsxs)(`select`,{"aria-label":`Filter CodeMap by agent and session`,className:`h-6 max-w-[170px] border bg-background px-1.5 font-mono text-[8px] text-foreground outline-none focus:border-primary`,value:n,onChange:e=>o(e.target.value),children:[(0,I.jsx)(`option`,{value:`all`,children:`ALL AGENTS`}),r.map(e=>(0,I.jsxs)(`option`,{value:e.key,children:[e.agentName,` · `,e.sessionId.slice(0,10)]},e.key))]})]})]})}function Xe({activeOperations:e,recentActivities:t,activityTotalCount:n,onLocate:r}){return(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[e.length>0&&(0,I.jsxs)(`section`,{className:`border-b`,children:[(0,I.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b bg-success/5 px-3`,children:[(0,I.jsx)(T,{className:`h-3 w-3 animate-pulse text-success`}),(0,I.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Active now`}),(0,I.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:e.length})]}),e.map(e=>(0,I.jsx)(U,{activity:e,onLocate:r,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,I.jsx)(b,{className:`h-3 w-3 text-muted-foreground`}),(0,I.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Event stream`}),(0,I.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] text-muted-foreground`,children:[n,` total`]})]}),t.length>0?t.map((e,t)=>(0,I.jsx)(U,{activity:e,onLocate:r,showAgent:!0},e.id??`${e.timestamp}:${t}`)):(0,I.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-7 py-16 text-center`,children:[(0,I.jsx)(`span`,{className:`mb-4 flex h-12 w-12 items-center justify-center border bg-muted text-muted-foreground`,children:(0,I.jsx)(E,{className:`h-5 w-5`})}),(0,I.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Select a node or wait for an agent`}),(0,I.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-muted-foreground`,children:`Relations appear on selection. Tool calls and external filesystem touches stream here live.`})]})]})]})}function Ze({node:e,incomingCount:t,outgoingCount:n,onOpenNode:r,onOpenActivity:i}){let a=L[e.kind].icon;return(0,I.jsxs)(`div`,{className:`border-b bg-muted/25 p-3`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:D(`flex h-8 w-8 items-center justify-center border`,L[e.kind].iconStyle),children:(0,I.jsx)(a,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`text-[8px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[e.external?`external `:``,e.kind]}),(0,I.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold`,title:e.label,children:e.label})]})]}),(0,I.jsx)(`div`,{className:`break-all font-mono text-[9px] leading-relaxed text-muted-foreground`,children:e.file?F(e):e.package}),e.signature&&(0,I.jsx)(`pre`,{className:`mt-3 overflow-x-auto border bg-background p-2 font-mono text-[9px] leading-relaxed text-foreground`,children:e.signature}),(0,I.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 border`,children:[(0,I.jsx)(W,{value:t,label:`incoming`,className:`border-r text-info`}),(0,I.jsx)(W,{value:n,label:`outgoing`,className:`border-r text-primary`}),(0,I.jsx)(W,{value:e.symbolCount??e.fileCount??e.line??`—`,label:e.kind===`package`?`files`:e.kind===`file`?`symbols`:`line`})]}),(0,I.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[e.kind!==`symbol`&&(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 flex-1 items-center justify-center gap-1.5 border bg-foreground text-[9px] font-semibold uppercase tracking-wider text-background hover:opacity-90`,onClick:()=>r(e),children:[(0,I.jsx)(f,{className:`h-3 w-3`}),` Open `,e.kind===`package`?`files`:`symbols`]}),e.file&&(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center justify-center gap-1.5 border px-2 text-[9px] uppercase text-muted-foreground hover:bg-muted`,onClick:()=>i(e.file),children:[(0,I.jsx)(b,{className:`h-3 w-3`}),` Activity`]})]})]})}function W({value:e,label:t,className:n}){return(0,I.jsxs)(`div`,{className:D(`p-2 text-center`,n),children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:e}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:t})]})}function Qe(e){let{title:t,subtitle:n,items:i,graph:a,selectedId:s,expanded:c,onToggle:l,onSelect:u}=e;return(0,I.jsxs)(`section`,{className:`border-b py-3`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-end justify-between px-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.16em]`,children:t}),(0,I.jsx)(`p`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:n})]}),(0,I.jsx)(`span`,{className:`border bg-muted px-1.5 py-0.5 font-mono text-[9px]`,children:i.length})]}),i.length===0?(0,I.jsx)(`p`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:`No relationships in this view.`}):i.map(e=>{let n=`${t}:${e.node.id}`,i=c.has(n),d=[...ve(a,e.node.id,`incoming`),...ve(a,e.node.id,`outgoing`)].filter((e,t,n)=>e.node.id!==s&&n.findIndex(t=>t.node.id===e.node.id)===t).slice(0,8);return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`group flex min-h-9 items-center gap-1 px-2 hover:bg-muted/70`,children:[(0,I.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>d.length>0&&l(n),"aria-label":`${i?`Collapse`:`Expand`} relation ${e.node.label}`,children:d.length>0?i?(0,I.jsx)(r,{className:`h-3 w-3`}):(0,I.jsx)(o,{className:`h-3 w-3`}):(0,I.jsx)(`span`,{className:`h-px w-2 bg-border`})}),(0,I.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 py-1 text-left`,onClick:()=>u(e.node),children:[(0,I.jsx)(`span`,{className:`block truncate font-mono text-[10px] font-semibold`,title:e.node.label,children:e.node.label}),(0,I.jsx)(`span`,{className:`block truncate text-[9px] text-muted-foreground`,children:e.node.package??e.node.symbolKind??e.node.kind})]}),(0,I.jsx)(`span`,{className:`border px-1 py-0.5 font-mono text-[8px] text-muted-foreground`,children:e.edge.refType}),(0,I.jsxs)(`span`,{className:`w-5 text-right font-mono text-[9px] text-muted-foreground`,children:[`×`,e.edge.weight]})]}),i&&d.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`relative flex h-7 w-full items-center gap-2 border-l border-border pl-11 pr-3 text-left text-[9px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:()=>u(e.node),children:[(0,I.jsx)(`span`,{className:`absolute left-7 top-1/2 h-px w-3 bg-border`}),(0,I.jsx)(E,{className:`h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate font-mono`,children:e.node.label}),(0,I.jsx)(`span`,{className:`ml-auto font-mono opacity-70`,children:e.edge.refType})]},`${n}:${e.node.id}`))]},n)})]})}function $e({selectedNode:e,incoming:t,outgoing:n,filteredGraph:r,expandedRelations:i,activeOperations:a,recentActivities:o,activityTotalCount:s,selectedActivities:c,onClearSelection:l,onOpenNode:u,onOpenActivity:d,onLocateActivity:f,onToggleRelation:p,onSelectNode:m}){return(0,I.jsxs)(`aside`,{className:`flex w-[326px] shrink-0 flex-col border-l bg-card/80`,children:[(0,I.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b px-3`,children:[(0,I.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Relation inspector`}),e&&(0,I.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:l,"aria-label":`Clear selection`,children:(0,I.jsx)(C,{className:`h-3.5 w-3.5`})})]}),e?(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,I.jsx)(Ze,{node:e,incomingCount:t.length,outgoingCount:n.length,onOpenNode:u,onOpenActivity:d}),c.length>0&&(0,I.jsxs)(`section`,{className:`border-b bg-success/5 py-2`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 px-3`,children:[(0,I.jsx)(T,{className:`h-3 w-3 animate-pulse text-success`}),(0,I.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Agents on this node`}),(0,I.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:c.length})]}),c.map(e=>(0,I.jsx)(U,{activity:e,onLocate:f,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,I.jsx)(Qe,{title:`Incoming`,subtitle:`Who depends on this`,items:t,graph:r,selectedId:e.id,expanded:i,onToggle:p,onSelect:m}),(0,I.jsx)(Qe,{title:`Outgoing`,subtitle:`What this depends on`,items:n,graph:r,selectedId:e.id,expanded:i,onToggle:p,onSelect:m})]}):(0,I.jsx)(Xe,{activeOperations:a,recentActivities:o,activityTotalCount:s,onLocate:f})]})}function et({node:e,onSelect:t,virtual:n}){let r=L[e.kind].icon;return(0,I.jsxs)(`button`,{type:`button`,"data-index":n?.index,ref:n?e=>n.measureElement(e):void 0,className:D(`min-h-8 items-center gap-2 px-3 py-1 text-left hover:bg-muted`,n?`absolute left-0 flex w-full`:`flex w-full`),style:n?{transform:`translateY(${n.start}px)`}:void 0,onClick:()=>t(e),children:[(0,I.jsx)(r,{className:D(`h-3.5 w-3.5 shrink-0`,e.kind===`package`?`text-primary`:e.kind===`file`?`text-info`:`text-success`)}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate font-mono text-[10px]`,children:e.label}),(0,I.jsx)(`span`,{className:`block truncate text-[8px] text-muted-foreground`,children:e.file??e.package??e.symbolKind})]}),(0,I.jsx)(`span`,{className:`text-[8px] uppercase text-muted-foreground`,children:e.kind.slice(0,3)})]},e.id)}var G=80,tt=40;function K(e,t){if(!e||t.size===0)return!1;let n=j(e);if(t.has(n))return!0;for(let e of t)if(e.endsWith(`/${n}`)||n.endsWith(`/${e}`))return!0;return!1}var nt=(0,O.memo)(function e(t){let{directory:n,packageName:s,depth:u,expandedDirectories:p,expandedFiles:m,loadingBranches:h,graphForFile:g,onToggleDirectory:_,onToggleFile:ee,onSelectFile:v,onOpenFile:y,onSelectSymbol:b,selectedId:x,activeFileNorms:te,activeSymbolIds:ne,revealAllKeys:re,onRevealAll:ie}=t,ae=`files:${s}:${n.path||`.`}`,oe=re.has(ae)?n.files:n.files.slice(0,G),S=n.files.length-oe.length;return(0,I.jsxs)(I.Fragment,{children:[n.directories.map(n=>{let i=`${s}:${n.path}`,l=p.has(i);return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:8+u*12},onClick:()=>_(i),children:[l?(0,I.jsx)(r,{className:`h-3 w-3`}):(0,I.jsx)(o,{className:`h-3 w-3`}),l?(0,I.jsx)(a,{className:`h-3.5 w-3.5 text-warning`}):(0,I.jsx)(c,{className:`h-3.5 w-3.5 text-warning`}),(0,I.jsx)(`span`,{className:`truncate`,children:n.name})]}),l&&(0,I.jsx)(e,{...t,directory:n,depth:u+1})]},i)}),oe.map(e=>{let t=m.has(e.file??e.id),n=M({level:`symbols`,file:e.file??e.label}),a=(e.file?g(e.file):void 0)?.nodes.filter(t=>t.kind===`symbol`&&t.file===e.file&&!t.external)??[],s=`symbols:${e.file??e.id}`,c=re.has(s)?a:a.slice(0,tt),p=a.length-c.length,_=K(e.file,te);return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:D(`group flex h-7 items-center pr-1 text-[11px] hover:bg-muted`,x===e.id&&`bg-primary/10 text-primary`),style:{paddingLeft:8+u*12},children:[(0,I.jsx)(`button`,{type:`button`,className:`flex h-6 w-4 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>ee(e),"aria-label":`${t?`Collapse`:`Expand`} ${e.label}`,children:h.has(n)?(0,I.jsx)(d,{className:`h-3 w-3 animate-spin`}):t?(0,I.jsx)(r,{className:`h-3 w-3`}):(0,I.jsx)(o,{className:`h-3 w-3`})}),(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>v(e),onDoubleClick:()=>y(e),children:[(0,I.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 text-info`}),_&&(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 animate-pulse bg-success`,title:`Live operation`}),(0,I.jsx)(`span`,{className:`truncate font-mono`,title:e.file,children:e.label}),(0,I.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.symbolCount??0})]}),(0,I.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>y(e),title:`Open symbol map`,"aria-label":`Open ${e.label} map`,children:(0,I.jsx)(f,{className:`h-3 w-3`})})]}),t&&c.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:D(`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[10px] hover:bg-muted`,x===e.id?`bg-primary/10 text-primary`:`text-muted-foreground`),style:{paddingLeft:38+u*12},onClick:()=>b(e),children:[(0,I.jsx)(i,{className:`h-3 w-3 shrink-0 text-success`}),ne.has(e.id)&&(0,I.jsx)(T,{className:`h-3 w-3 shrink-0 animate-pulse text-success`}),(0,I.jsx)(`span`,{className:`truncate font-mono`,children:e.label}),e.line&&(0,I.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] opacity-60`,children:[`:`,e.line]})]},e.id)),t&&p>0&&(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:38+u*12},onClick:()=>ie(s),children:[`Show `,p,` more symbols`]})]},e.id)}),S>0&&(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:8+u*12},onClick:()=>ie(ae),children:[`Show `,S,` more files`]})]})});function rt({rootGraph:e,search:t,searchInput:n,searchResults:i,virtualizeSearch:a,searchVirtualizer:s,treeScrollRef:c,selectedId:l,expandedPackages:u,expandedDirectories:m,expandedFiles:h,loadingBranches:g,activeFileNorms:_,activeSymbolIds:ee,revealAllKeys:v,packageGraph:y,graphForFile:b,navigate:x,togglePackage:te,toggleDirectory:ne,toggleFile:re,revealAllTree:ie,selectFileFromTree:ae,selectSymbolFromTree:oe,selectSearchResult:S,handleOpenNode:se,onSearchInputChange:w,onSearchChange:ce}){return(0,I.jsxs)(`aside`,{className:`flex w-[286px] shrink-0 flex-col border-r bg-card/70`,children:[(0,I.jsxs)(`div`,{className:`border-b p-3`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,I.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Code tree`}),(0,I.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[e.nodes.length,` roots`]})]}),(0,I.jsxs)(`label`,{className:`flex h-8 items-center gap-2 border bg-background px-2 focus-within:border-primary`,children:[(0,I.jsx)(p,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,I.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent font-mono text-[10px] outline-none placeholder:text-muted-foreground`,value:n,onChange:e=>w(e.target.value),placeholder:`Find package, file, symbol…`}),n&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>{w(``),ce(``)},"aria-label":`Clear search`,children:(0,I.jsx)(C,{className:`h-3 w-3 text-muted-foreground`})})]})]}),(0,I.jsx)(`div`,{ref:c,className:`min-h-0 flex-1 overflow-y-auto py-2`,children:t.trim()?(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`px-3 pb-2 text-[9px] text-muted-foreground`,children:[i.length,` loaded-map results`]}),i.length===0?(0,I.jsxs)(`p`,{className:`px-3 py-8 text-center text-[10px] text-muted-foreground`,children:[`No match in loaded branches.`,(0,I.jsx)(`br`,{}),`Expand a package to search its files.`]}):a?(0,I.jsx)(`div`,{style:{height:`${s.getTotalSize()}px`,width:`100%`,position:`relative`},children:s.getVirtualItems().map(e=>{let t=i[e.index];return t?(0,I.jsx)(et,{node:t,onSelect:S,virtual:{index:e.index,start:e.start,measureElement:s.measureElement}},t.id):null})}):i.map(e=>(0,I.jsx)(et,{node:e,onSelect:S},e.id))]}):e.nodes.map(e=>{let t=e.package??e.label,n=u.has(t),i=M({level:`files`,package:t}),a=y(t),s=a?Te(a.nodes):void 0;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:D(`group flex h-8 items-center px-2 hover:bg-muted`,l===e.id&&`bg-primary/10 text-primary`),children:[(0,I.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 items-center justify-center text-muted-foreground`,onClick:()=>te(e),"aria-label":`${n?`Collapse`:`Expand`} ${t}`,children:g.has(i)?(0,I.jsx)(d,{className:`h-3 w-3 animate-spin`}):n?(0,I.jsx)(r,{className:`h-3 w-3`}):(0,I.jsx)(o,{className:`h-3 w-3`})}),(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>x({level:`packages`},e.id),onDoubleClick:()=>x({level:`files`,package:t}),children:[(0,I.jsx)(de,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold`,children:e.label}),(0,I.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.fileCount??0})]}),(0,I.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>x({level:`files`,package:t}),title:`Open file map`,"aria-label":`Open ${t} map`,children:(0,I.jsx)(f,{className:`h-3 w-3`})})]}),n&&s&&(0,I.jsx)(nt,{directory:s,packageName:t,depth:1,expandedDirectories:m,expandedFiles:h,loadingBranches:g,graphForFile:b,onToggleDirectory:ne,onToggleFile:re,onSelectFile:ae,onOpenFile:se,onSelectSymbol:oe,selectedId:l,activeFileNorms:_,activeSymbolIds:ee,revealAllKeys:v,onRevealAll:ie})]},e.id)})}),(0,I.jsxs)(`div`,{className:`border-t px-3 py-2 text-[9px] leading-relaxed text-muted-foreground`,children:[`Click to focus · double-click to enter`,(0,I.jsx)(`br`,{}),`Branches stay open while the map changes`]})]})}function it(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a?a.type===t.type&&a.position.x===t.position.x&&a.position.y===t.position.y&&V(a.data,t.data)?(e[i]!==a&&(r=!0),a):(r=!0,{...a,...t,measured:a.measured}):(r=!0,t)});return r?i:e}function q(e){return e.data?.renderKey}function at(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a&&q(a)===q(t)?(e[i]!==a&&(r=!0),a):(r=!0,t)});return r?i:e}function ot(){let[e,t]=(0,O.useState)({level:`packages`}),n=M(e),[r,i]=(0,O.useState)(We),[a,o]=(0,O.useState)(!0),[s,c]=(0,O.useState)(null),[l,u]=(0,O.useState)(null),[d,f]=(0,O.useState)(`layers`),[p,m]=(0,O.useState)(`smart`),[h,g]=(0,O.useState)(`all`),[_,ee]=(0,O.useState)(``),[v,y]=(0,O.useState)(``),[b,x]=(0,O.useState)(new Set),[ie,S]=(0,O.useState)(new Set),[C,w]=(0,O.useState)(new Set),[ce,T]=(0,O.useState)(new Set),[le,ue]=(0,O.useState)(new Set),[E,de]=(0,O.useState)(new Set),[fe,D]=(0,O.useState)(0),[k,A]=(0,O.useState)(null),[N,be]=(0,O.useState)(!1),[P,Se]=(0,O.useState)(`all`),[F,we]=(0,O.useState)(null),[je,L]=(0,O.useState)(null),[Le,Re]=(0,O.useState)(0),R=(0,O.useRef)(new Map),z=(0,O.useRef)(null),B=(0,O.useRef)(null),Ve=(0,O.useRef)(``),He=(0,O.useRef)(``),V=(0,O.useRef)(null),Ue=(0,O.useRef)(new Set),{history:H,pulses:U,activeOperationsMap:Xe,activityTotalCount:Ze,resolveActivitySymbol:W,getActivityForFile:Qe,sweepActivity:et}=pe(re(e=>({history:e.history,pulses:e.pulses,activeOperationsMap:e.activeOperations,activityTotalCount:e.totalCount,resolveActivitySymbol:e.resolveActivitySymbol,getActivityForFile:e.getActivityForFile,sweepActivity:e._sweep}))),G=(0,O.useMemo)(()=>[...Xe.values()].flat(),[Xe]),tt=(0,O.useMemo)(()=>[...U.keys()].map(e=>H.get(e)?.[0]).filter(e=>!!e),[H,U]),K=(0,O.useMemo)(()=>{let e=[];for(let t of H.values())e.push(...t.slice(0,16));return e.sort((e,t)=>t.timestamp-e.timestamp).slice(0,16)},[H]),nt=(0,O.useMemo)(()=>me([...G,...K]),[G,K]),q=(0,O.useMemo)(()=>{let e=F??G;return P===`all`?e:e.filter(e=>he(e)===P)},[G,P,F]),ot=(0,O.useMemo)(()=>{let e=je??K;return P===`all`?e:e.filter(e=>he(e)===P)},[P,je,K]),J=(0,O.useDeferredValue)(q),st=(0,O.useDeferredValue)(ot),ct=(0,O.useDeferredValue)(tt),lt=(0,O.useMemo)(()=>me(q),[q]),[ut,dt,ft]=ae([]),[pt,mt,ht]=se([]),{fitView:gt}=ne(),Y=(0,O.useCallback)(async(e,t=!1)=>{let n=M(e),r=R.current.get(n);if(r&&!t)return De(R.current,n,r,48),r;let i=await fetch(_e(e));if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();return De(R.current,n,a,48),D(e=>e+1),a},[]);(0,O.useEffect)(()=>{let e=window.setTimeout(()=>y(_),150);return()=>window.clearTimeout(e)},[_]);let _t=ge(e=>e.generation),vt=(0,O.useRef)(0),yt=(0,O.useRef)(null);(0,O.useEffect)(()=>{let t=!1,n=_t>vt.current;return n&&(vt.current=_t,R.current.clear(),D(e=>e+1),x(new Set),S(new Set),w(new Set),ue(new Set)),o(!0),c(null),Y(e,n).then(e=>{if(!t){if(i(e),!n){let t=z.current;z.current=null,u(t&&e.nodes.some(e=>e.id===t)?t:null)}o(!1)}}).catch(e=>{t||(c(e instanceof Error?e.message:String(e)),i(We),o(!1))}),()=>{t=!0}},[n,Y,_t,e]);let X=(0,O.useCallback)((e,r)=>{if(z.current=r??null,M(e)===n){u(r??null),z.current=null;return}t(e)},[n]),bt=(0,O.useCallback)(async e=>{let t=M(e);if(!(R.current.has(t)||E.has(t))){de(e=>new Set(e).add(t));try{await Y(e)}finally{de(e=>{let n=new Set(e);return n.delete(t),n})}}},[Y,E]);(0,O.useEffect)(()=>{let e=!1,t=0;for(let n of G){if(t>=2)break;if(n.symbol||!n.toolUseId||n.filePath.startsWith(`(`))continue;let r=n.filePath;Ue.current.has(r)||(Ue.current.add(r),t+=1,Y({level:`symbols`,file:r}).then(t=>{if(e)return;let i=Pe(n,t.nodes);i&&W(n.toolUseId,r,{id:i.id,name:i.label,...i.symbolKind?{kind:i.symbolKind}:{},...i.line?{line:i.line}:{}})}).catch(()=>void 0).finally(()=>{Ue.current.delete(r)}))}return()=>{e=!0}},[G,Y,W]);let Z=(0,O.useMemo)(()=>({nodes:r.nodes,edges:h===`all`?r.edges:r.edges.filter(e=>e.refType===h)}),[r,h]),Q=r.nodes.find(e=>e.id===l),$=(0,O.useMemo)(()=>Ce(Z,l,p),[p,Z,l]),xt=(0,O.useMemo)(()=>l?ye(Z,l):new Set,[Z,l]),{incomingCounts:St,outgoingCounts:Ct}=(0,O.useMemo)(()=>{let e=new Map,t=new Map;for(let n of Z.edges)t.set(n.source,(t.get(n.source)??0)+1),e.set(n.target,(e.get(n.target)??0)+1);return{incomingCounts:e,outgoingCounts:t}},[Z]),wt=d===`orbit`?l??void 0:void 0,Tt=(0,O.useMemo)(()=>xe($,d,wt),[$,d,wt]),Et=(0,O.useMemo)(()=>[n,d,d===`orbit`?l??``:``,Ee($)].join(``),[$,n,d,l]),Dt=(0,O.useCallback)(e=>{u(e.id),T(new Set)},[]),Ot=(0,O.useCallback)(e=>{e.kind===`package`&&X({level:`files`,package:e.package??e.label}),e.kind===`file`&&e.file&&X({level:`symbols`,file:e.file,package:e.package})},[X]),kt=(0,O.useMemo)(()=>[Ne(J),Ne(ct),Ne(st)].join(``),[J,ct,st]),At=(0,O.useMemo)(()=>{let e=new Set;for(let t of q)e.add(j(t.filePath));return e},[q]),jt=(0,O.useMemo)(()=>{let e=new Set;for(let t of q)t.symbol?.id&&e.add(t.symbol.id);return e},[q]);(0,O.useEffect)(()=>{let e=()=>{let e=Tt.map(({node:e})=>e),t=Me(e,J),n=Me(e,ct),r=new Set(t.keys()),i=Tt.map(({node:e,position:r})=>{let i=t.get(e.id)??[],a=i[0]??n.get(e.id)?.[0];return{id:e.id,type:`codemap`,position:r,data:{graphNode:e,selected:e.id===l,dimmed:!!l&&!xt.has(e.id),incoming:St.get(e.id)??0,outgoing:Ct.get(e.id)??0,isActive:!!a,...a?{activityType:a.type}:{},activeOperations:i,onSelect:Dt,onOpen:Ot,onShowHistory:A}}});dt(e=>it(e,i));let a=6,o=$.edges.map((e,t)=>{let n=!!l&&(e.source===l||e.target===l),i=r.has(e.source)||r.has(e.target),o=i&&(n||a>0);o&&--a;let s=Ie[e.refType]??`hsl(var(--muted-foreground))`,c=n||i?`smoothstep`:`default`;return{id:`edge:${e.source}:${e.target}:${t}`,source:e.source,target:e.target,type:c,animated:o,label:n?`${e.refType}${e.weight>1?` ×${e.weight}`:``}`:void 0,markerEnd:{type:te.ArrowClosed,color:s,width:14,height:14},style:{stroke:s,strokeWidth:i?Math.min(2.5+Math.log2(e.weight+1)*.65,5):n?Math.min(1.25+Math.log2(e.weight+1)*.65,4):1,opacity:i?1:l?n?.88:.08:.52},labelStyle:{fontSize:9,fontFamily:`var(--font-mono)`,fill:`hsl(var(--muted-foreground))`},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.92},labelBgPadding:[4,2],zIndex:i?4:n?2:0,data:{renderKey:`${e.refType}:${e.weight}:${l?n?`focused`:`dimmed`:`idle`}:${i?`live`:`still`}:${o?`anim`:`still`}:${c}`}}}),s=new Map,c=new Set(J.map(he));for(let e of[...st].sort((e,t)=>e.timestamp-t.timestamp)){let t=he(e),n=s.get(t);n?n.push(e):s.set(t,[e])}let u=[...s.entries()].map(([e,t])=>({agentKey:e,activities:t,live:c.has(e),latest:t[t.length-1]?.timestamp??0})).sort((e,t)=>Number(t.live)-Number(e.live)||t.latest-e.latest).slice(0,4),d=[];for(let{agentKey:e,activities:t,live:n}of u){let r=t.slice(-7).map(e=>({activity:e,node:$.nodes.find(t=>Ae(e,t))})).filter(e=>!!e.node).filter((e,t,n)=>t===0||e.node.id!==n[t-1]?.node.id),i=Be(e);for(let t=1;t<r.length;t++){let o=r[t-1],s=r[t],c=n&&a>0;c&&--a,d.push({id:`trail:${e}:${o.activity.timestamp}:${s.activity.timestamp}`,source:o.node.id,target:s.node.id,type:`smoothstep`,animated:c,label:t===r.length-1?`${ze(s.activity.agentName??s.activity.agent??`agent`)} TRAIL`:void 0,markerEnd:{type:te.ArrowClosed,color:i,width:13,height:13},style:{stroke:i,strokeWidth:2.5,strokeDasharray:`7 5`,opacity:.9},labelStyle:{fontSize:8,fontWeight:700,fill:i},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.94},labelBgPadding:[4,2],zIndex:6,data:{renderKey:`${i}:${t===r.length-1?`label`:`plain`}:${n?`live`:`still`}:${c?`anim`:`still`}`}})}}Re(d.length),mt(e=>at(e,[...o,...d]))},t=Et,n=He.current!==t;He.current=t,V.current!==null&&(window.clearTimeout(V.current),V.current=null),n?e():V.current=window.setTimeout(()=>{V.current=null,e()},120);let r;return Ve.current!==Et&&(r=window.setTimeout(()=>{Ve.current=Et;let e=$.nodes.length>48?0:240;gt({padding:.2,duration:e,maxZoom:1.25})},20)),()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null),r!==void 0&&window.clearTimeout(r)}},[kt,$,l,J,st,ct,Et,xt,gt,Ot,Dt,St,Ct,Tt,mt,dt]),(0,O.useEffect)(()=>{let e=window.setInterval(()=>{et()},2e3);return()=>window.clearInterval(e)},[et]);let Mt=R.current.get(`packages`)??(e.level===`packages`?r:We),Nt=(0,O.useCallback)(e=>R.current.get(M({level:`files`,package:e})),[fe]),Pt=(0,O.useCallback)(e=>R.current.get(M({level:`symbols`,file:e})),[fe]),Ft=(0,O.useCallback)(e=>{let t=e.filePath,n=ke(e.filePath),r=`file:${e.filePath}`;for(let i of R.current.values()){let a=i.nodes.find(t=>t.kind===`file`&&!t.external&&Oe(t.file,e.filePath));if(a){t=a.file??t,n=a.package??n,r=a.id;break}}if(e.symbol){X({level:`symbols`,file:t,package:n},e.symbol.id);return}X({level:`files`,package:n},r)},[X]);(0,O.useEffect)(()=>{if(!N||F)return;let e=[...q].filter(e=>!e.filePath.startsWith(`(`)).sort((e,t)=>t.timestamp-e.timestamp)[0];if(!e)return;let t=`${e.id??e.toolUseId}:${e.filePath}:${e.symbol?.id??`file`}`;B.current!==t&&(B.current=t,Ft(e))},[q,N,Ft,F]);let It=(0,O.useCallback)(()=>{if(F){we(null),L(null);return}we([...G]),L([...K])},[G,F,K]),Lt=(0,O.useCallback)(e=>{let t=e.package??e.label,n=!b.has(t);x(e=>{let r=new Set(e);return n?r.add(t):r.delete(t),r}),n&&bt({level:`files`,package:t}).then(()=>{let e=R.current.get(M({level:`files`,package:t})),n=e?Te(e.nodes):void 0;n?.directories.length===1&&n.directories[0]&&S(e=>new Set(e).add(`${t}:${n.directories[0].path}`))}).catch(()=>void 0)},[bt,b]),Rt=(0,O.useCallback)(e=>{if(!e.file)return;let t=!C.has(e.file);w(n=>{let r=new Set(n);return t?r.add(e.file):r.delete(e.file),r}),t&&bt({level:`symbols`,file:e.file,package:e.package}).catch(()=>void 0)},[bt,C]),zt=(0,O.useCallback)(e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Bt=(0,O.useCallback)(e=>{ue(t=>new Set(t).add(e))},[]),Vt=(0,O.useCallback)(e=>{X({level:`files`,package:e.package??`(root)`},e.id)},[X]),Ht=(0,O.useCallback)(e=>{e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),Ut=(0,O.useMemo)(()=>{let e=v.trim().toLocaleLowerCase();if(!e)return[];let t=new Map;for(let n of R.current.values())for(let r of n.nodes)`${r.label} ${r.file??``} ${r.signature??``} ${r.package??``}`.toLocaleLowerCase().includes(e)&&t.set(r.id,r);return[...t.values()].sort((e,t)=>e.kind.localeCompare(t.kind)||e.label.localeCompare(t.label)).slice(0,80)},[v,fe]),Wt=Ut.length>40,Gt=oe({count:Ut.length,getScrollElement:()=>yt.current,estimateSize:()=>40,overscan:8,enabled:Wt}),Kt=(0,O.useCallback)(e=>{e.kind===`package`?X({level:`packages`},e.id):e.kind===`file`?X({level:`files`,package:e.package??`(root)`},e.id):e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),{incoming:qt,outgoing:Jt}=(0,O.useMemo)(()=>({incoming:Q?ve(Z,Q.id,`incoming`):[],outgoing:Q?ve(Z,Q.id,`outgoing`):[]}),[Z,Q]),{edgeWeight:Yt,connectedNodeCount:Xt}=(0,O.useMemo)(()=>{let e=0,t=new Set;for(let n of Z.edges)e+=n.weight,t.add(n.source),t.add(n.target);return{edgeWeight:e,connectedNodeCount:t.size}},[Z]),Zt=Q?q.filter(e=>Ae(e,Q)):[],Qt=k?Qe(k):[];return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,I.jsx)(qe,{scope:e,graph:r,agentPresences:lt,edgeWeight:Yt,connectedNodeCount:Xt,navigate:X}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,I.jsx)(rt,{rootGraph:Mt,search:v,searchInput:_,searchResults:Ut,virtualizeSearch:Wt,searchVirtualizer:Gt,treeScrollRef:yt,selectedId:l,expandedPackages:b,expandedDirectories:ie,expandedFiles:C,loadingBranches:E,activeFileNorms:At,activeSymbolIds:jt,revealAllKeys:le,packageGraph:Nt,graphForFile:Pt,navigate:X,togglePackage:Lt,toggleDirectory:zt,toggleFile:Rt,revealAllTree:Bt,selectFileFromTree:Vt,selectSymbolFromTree:Ht,selectSearchResult:Kt,handleOpenNode:Ot,onSearchInputChange:ee,onSearchChange:y}),(0,I.jsxs)(`main`,{className:`relative min-w-0 flex-1 bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/0.055),transparent_38%)]`,children:[(0,I.jsx)(Ke,{layout:d,canvasMode:p,edgeFilter:h,canvasNodeCount:$.nodes.length,graphNodeCount:r.nodes.length,onLayoutChange:f,onCanvasModeChange:m,onEdgeFilterChange:g}),(0,I.jsx)(Je,{presences:lt,onLocate:Ft}),(0,I.jsx)(Ye,{paused:F!==null,followLive:N,agentFilter:P,agents:nt,onTogglePaused:It,onToggleFollow:()=>{B.current=null,be(e=>!e)},onAgentFilter:e=>{B.current=null,Se(e)}}),(0,I.jsx)(Ge,{loading:a,error:s,graph:r,canvasNodeCount:$.nodes.length,flowNodes:ut,flowEdges:pt,onNodesChange:ft,onEdgesChange:ht,agentTrailCount:Le})]}),(0,I.jsx)($e,{selectedNode:Q,incoming:qt,outgoing:Jt,filteredGraph:Z,expandedRelations:ce,activeOperations:q,recentActivities:ot,activityTotalCount:Ze,selectedActivities:Zt,onClearSelection:()=>u(null),onOpenNode:Ot,onOpenActivity:A,onLocateActivity:Ft,onToggleRelation:e=>T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelectNode:Dt})]}),k&&(0,I.jsx)(Fe,{historyFile:k,fileHistory:Qt,onClose:()=>A(null)})]})}function J(){return(0,I.jsx)(le,{children:(0,I.jsx)(ot,{})})}export{J as CodeMap};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CWhuSNod.js";import{$t as n,At as r,Ca as i,Oi as a,Wn as o,_n as s,bi as c,dn as l,et as u,fn as d,gt as f,li as p,mi as m,nn as h,nr as g,nt as _,pt as v,rn as y,tt as ee,va as b,xa as x,yi as S}from"./vendor-BTDGplXK.js";import"./i18n-DOuSY1L8.js";import{t as C}from"./useWebSocket-BTXT0rOW.js";import{t as w}from"./utils-DxDx8yib.js";import{m as T,p as E,t as D}from"./stores-CpZiOiOP.js";import{o as O}from"./view-navigation-BRtuAwZo.js";import{t as k}from"./button-Clh96jMK.js";import{h as A,m as te,p as ne,y as j}from"./index-DxZTscTk.js";var M=e(i(),1),N=u(),P={pending:{icon:(0,N.jsx)(S,{className:`w-4 h-4`}),color:`text-muted-foreground`,label:`Pending`},in_progress:{icon:(0,N.jsx)(m,{className:`w-4 h-4 animate-spin`}),color:`text-primary`,label:`In Progress`},blocked:{icon:(0,N.jsx)(s,{className:`w-4 h-4`}),color:`text-warning`,label:`Blocked`},failed:{icon:(0,N.jsx)(c,{className:`w-4 h-4`}),color:`text-destructive`,label:`Failed`},review:{icon:(0,N.jsx)(h,{className:`w-4 h-4`}),color:`text-info`,label:`Review`},completed:{icon:(0,N.jsx)(a,{className:`w-4 h-4`}),color:`text-success`,label:`Done`}},F={critical:`bg-destructive/15 text-destructive`,high:`bg-warning/15 text-warning`,medium:`bg-info/15 text-info`,low:`bg-muted text-muted-foreground`},I={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 L(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 R({task:e,onStatusChange:t,onRetry:n,agents:r,onAssign:i,compact:a,className:o}){let{t:s}=b(),c=P[e.status],[l,u]=(0,M.useState)(!1),d=e.status===`in_progress`;return(0,N.jsxs)(`div`,{className:w(`w-full text-left rounded-lg border p-3 transition-all hover:shadow-sm`,d?`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,N.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,N.jsx)(`span`,{className:w(`mt-0.5`,c.color),role:`img`,"aria-label":d?s(`common:status.inProgress`):void 0,children:c.icon}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,N.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,N.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,F[e.priority]),children:e.priority}),(0,N.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,I[e.type]),children:e.type})]}),e.description&&(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 line-clamp-2`,children:e.description})]})]}),e.assignee&&(0,N.jsxs)(`div`,{className:w(`mt-2 inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium`,d?`bg-primary/15 text-primary`:`bg-muted text-muted-foreground`),children:[d&&(0,N.jsx)(m,{className:`w-3 h-3 animate-spin`,"aria-label":s(`common:status.working`)}),(0,N.jsx)(`span`,{children:e.assignee})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 mt-2 text-xs text-muted-foreground`,children:[e.estimateHours?(0,N.jsxs)(`span`,{children:[`~`,e.estimateHours,`h`]}):null,e.actualHours?(0,N.jsxs)(`span`,{children:[`• `,e.actualHours,`h`]}):null,e.startedAt?(0,N.jsxs)(`span`,{children:[`• `,L(Date.now()-e.startedAt)]}):null]}),e.tags.length>0&&(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.tags.map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))}),!a&&(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 mt-2`,children:[t&&e.status!==`in_progress`&&e.status!==`completed`&&(0,N.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,N.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,N.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,N.jsx)(h,{className:`w-3 h-3`}),` `,s(`activity:task.retry`)]}),i&&r&&r.length>0&&(l?(0,N.jsxs)(`select`,{defaultValue:e.assignee??``,onChange:t=>{i(e.id,t.target.value),u(!1)},onBlur:()=>u(!1),className:`px-1 py-0.5 text-[10px] rounded border border-border bg-card`,children:[(0,N.jsx)(`option`,{value:``,children:s(`activity:task.unassigned`)}),r.map(e=>(0,N.jsx)(`option`,{value:e,children:e},e))]}):(0,N.jsxs)(`button`,{type:`button`,onClick:()=>u(!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,N.jsx)(v,{className:`w-3 h-3`}),` `,s(`activity:task.assign`)]}))]})]})}var z=[{key:`pending`,label:`Pending`,match:[`pending`,`blocked`]},{key:`in_progress`,label:`In Progress`,match:[`in_progress`]},{key:`review`,label:`Review`,match:[`review`]},{key:`failed`,label:`Failed`,match:[`failed`]},{key:`completed`,label:`Done`,match:[`completed`]}],B={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 re(){let{client:e}=C(),{t}=b(),r=E(e=>e.phases),i=E(e=>e.multiBoard),[a,o]=(0,M.useState)(`phase`),[s,c]=(0,M.useState)(null),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(0),m=Math.min(d,Math.max(0,r.length-1)),h=i?r[m]:void 0,g=(0,M.useMemo)(()=>r.flatMap(e=>(e.tasks??[]).map(t=>({...t,phaseId:e.id}))),[r]),_=(0,M.useMemo)(()=>[...new Set(g.map(e=>e.assignee).filter(e=>!!e))],[g]),v=(0,M.useCallback)(t=>e?.send?.(t),[e]),y=(0,M.useCallback)((e,t)=>v({type:`goal.taskStatus`,payload:{taskId:e,status:t}}),[v]),ee=(0,M.useCallback)(e=>v({type:`goal.retryTask`,payload:{taskId:e}}),[v]),x=(0,M.useCallback)((e,t)=>v({type:`goal.assignTask`,payload:{taskId:e,agentName:t||void 0}}),[v]),S=(0,M.useCallback)(e=>{j({title:t(`activity:board.newTaskTitle`),placeholder:t(`activity:board.newTaskPlaceholder`),confirmLabel:t(`activity:board.addTask`)}).then(t=>{t&&v({type:`goal.addTask`,payload:{phaseId:e,title:t}})})},[v]),T=(0,M.useCallback)(e=>{s&&v({type:`goal.moveTask`,payload:{taskId:s,toPhaseId:e}}),c(null),u(null)},[s,v]),D=(0,M.useCallback)(e=>{s&&v({type:`goal.taskStatus`,payload:{taskId:s,status:e}}),c(null),u(null)},[s,v]),O={onStatusChange:y,onRetry:ee,agents:_,onAssign:x};function k(e){return{draggable:!0,onDragStart:t=>{c(e),t.dataTransfer.effectAllowed=`move`},onDragEnd:()=>{c(null),u(null)}}}function A(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 r.length===0?(0,N.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 items-center justify-center text-muted-foreground`,children:(0,N.jsx)(`p`,{className:`text-sm`,children:t(`activity:board.empty`)})}):(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2`,children:[(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:board.summary`,{phases:r.length,tasks:g.length})}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>o(`phase`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,a===`phase`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,N.jsx)(p,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.phases`)]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>o(`status`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,a===`status`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,N.jsx)(n,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.statusTab`)]})]})]}),i&&h?(0,N.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,N.jsx)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-b border-border px-3 py-1.5`,children:r.map((e,t)=>(0,N.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===m?`border-primary/40 bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,N.jsx)(`span`,{className:`truncate`,children:e.name}),(0,N.jsxs)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount]})]},e.id))}),(0,N.jsx)(U,{phase:h,allTasks:g,layout:a,dragId:s,hoverKey:l,callbacks:O,draggable:k,dropZone:A,dropToPhase:T,dropToStatus:D,onAddTask:S})]}):(0,N.jsx)(H,{phases:r,allTasks:g,layout:a,dragId:s,hoverKey:l,callbacks:O,draggable:k,dropZone:A,dropToPhase:T,dropToStatus:D,onAddTask:S})]})}function V({phase:e,phaseTasks:t,callbacks:n,draggable:r,dropZone:i,dropToPhase:a,onAddTask:o,dragId:s,hoverKey:c}){let{t:u}=b();return(0,N.jsxs)(`div`,{...i(`phase:${e.id}`,()=>a(e.id)),className:w(`flex min-h-0 w-80 shrink-0 flex-col rounded-lg border bg-muted/30 transition-colors`,c===`phase:${e.id}`?`border-primary/60 bg-primary/5`:`border-border`),children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.name}),(0,N.jsx)(`span`,{className:w(`rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,B[e.status]),children:e.status})]}),(0,N.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount,` · `,e.progressPercent,`%`]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),title:u(`activity:board.addTask`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,N.jsx)(l,{className:`h-4 w-4`})})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-2`,children:t.length===0?(0,N.jsx)(`p`,{className:`px-1 py-4 text-center text-[11px] text-muted-foreground`,children:u(`activity:board.dropHere`)}):t.map(e=>(0,N.jsx)(`div`,{...r(e.id),className:w(s===e.id&&`opacity-50`),children:(0,N.jsx)(R,{task:e,...n})},e.id))})]})}function H({phases:e,allTasks:t,layout:n,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,dropToStatus:l,onAddTask:u}){return(0,N.jsx)(N.Fragment,{children:n===`phase`?(0,N.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:e.map(e=>(0,N.jsx)(V,{phase:e,phaseTasks:t.filter(t=>t.phaseId===e.id),callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:u,dragId:r,hoverKey:i},e.id))}):(0,N.jsx)(W,{phases:e,allTasks:t,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToStatus:l})})}function U({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}=b();return n===`phase`?(0,N.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:(0,N.jsx)(V,{phase:e,phaseTasks:d,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:u,dragId:r,hoverKey:i})}):(0,N.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain p-3`,children:(0,N.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${z.length}, minmax(0, 1fr))`},children:[(0,N.jsx)(`div`,{}),z.map(e=>(0,N.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,N.jsxs)(G,{children:[(0,N.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,N.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,B[e.status]),children:e.status})]})}),z.map(t=>{let n=d.filter(e=>t.match.includes(e.status)),c=`cell:${e.id}:${t.key}`;return(0,N.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,N.jsx)(`div`,{...o(e.id),className:w(r===e.id&&`opacity-50`),children:(0,N.jsx)(R,{task:e,compact:!0,...a})},e.id))},t.key)})]},e.id)]})})}function W({phases:e,allTasks:t,dragId:n,hoverKey:r,callbacks:i,draggable:a,dropZone:o,dropToStatus:s}){let{t:c}=b();return(0,N.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${z.length}, minmax(0, 1fr))`},children:[(0,N.jsx)(`div`,{}),z.map(e=>(0,N.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,N.jsxs)(G,{children:[(0,N.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,N.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,B[e.status]),children:e.status})]})}),z.map(c=>{let l=t.filter(t=>t.phaseId===e.id&&c.match.includes(t.status)),u=`cell:${e.id}:${c.key}`;return(0,N.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,N.jsx)(`div`,{...a(e.id),className:w(n===e.id&&`opacity-50`),children:(0,N.jsx)(R,{task:e,compact:!0,...i})},e.id))},c.key)})]},e.id))]})}function G({children:e}){return(0,N.jsx)(N.Fragment,{children:e})}function K({onClose:e}){let{client:n}=C(),{t:i}=b(),a=E(e=>e.phases),c=E(e=>e.overallPercent),u=E(e=>e.autonomous),p=E(e=>e.title),m=E(e=>e.goal),h=E(e=>e.status),v=E(e=>e.lastError),S=E(e=>e.graphs);(0,M.useEffect)(()=>{n?.send?.({type:`goal.list`}),n?.send?.({type:`goal.state`})},[n]);let j=D(e=>e.worktrees),P=D(e=>e.baseBranch),[F,I]=(0,M.useState)(``),[L,R]=(0,M.useState)(null),[z,B]=(0,M.useState)(!1),[V,H]=(0,M.useState)(!0),[U,W]=(0,M.useState)(!1),[G,K]=(0,M.useState)(!1),[q,ie]=(0,M.useState)(!1),J=T(e=>e.result),Y=T(e=>e.loading),X=(0,M.useRef)(null);(0,M.useEffect)(()=>{if(X.current&&clearTimeout(X.current),!F.trim()){T.getState().clear();return}return X.current=setTimeout(()=>{T.getState().setLoading();let e=T.getState().nextSeq();n?.send?.({type:`goal.assess`,payload:{goal:F,seq:e}})},800),()=>{X.current&&clearTimeout(X.current)}},[F,n]),(0,M.useEffect)(()=>{!F.trim()&&!L&&T.getState().clear()},[F,L]);let Z=a.length>0,ae=L!=null&&!Z;(0,M.useEffect)(()=>{Z&&R(null)},[Z]);let Q=(0,M.useCallback)(()=>{let e=F.trim();if(!e||L!=null)return;let r=t.getState();r.addMessage({role:`user`,content:e}),r.addMessage({role:`assistant`,content:x.t(`activity:goalRun.planningAck`)}),R(e),I(``),n?.send?.({type:`goal.start`,payload:{title:e,autonomous:!0,worktrees:V,multiBoard:U,verifyTasks:G,chimeraReview:q}}),O(`chat`)},[F,L,n,V]),oe=(0,M.useCallback)(()=>{n?.send?.({type:`goal.stop`,payload:{}}),R(null)},[n]),se=(0,M.useCallback)(()=>{n?.send?.({type:`goal.toggleAutonomous`,payload:{}})},[n]),ce=(0,M.useCallback)(()=>{n?.send?.(h===`paused`?{type:`goal.resume`,payload:{}}:{type:`goal.pause`,payload:{}})},[n,h]),le=(0,M.useCallback)(()=>{n?.send?.({type:`goal.stop`,payload:{}})},[n]),ue=(0,M.useCallback)(()=>{n?.send?.({type:`goal.clear`,payload:{}}),E.getState().clear(),R(null),I(``)},[n]),[de,$]=(0,M.useState)(!1),fe=(0,M.useCallback)(()=>{n?.send?.({type:`goal.revert`,payload:{}}),$(!1)},[n]),pe=h===`running`||h===`paused`,me=h===`stopped`||h===`completed`||h===`failed`,he=(0,M.useCallback)(e=>{e&&n?.send?.({type:`goal.load`,payload:{graphId:e}})},[n]);return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,N.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,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(g,{className:`h-5 w-5 text-muted-foreground`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-lg font-semibold`,children:Z&&p||`Goal`}),Z&&(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`activity:goalRun.summary`,{count:a.length,pct:c})})]}),Z&&(0,N.jsx)(`span`,{className:w(`rounded border px-2 py-0.5 text-[11px] font-medium capitalize`,h===`failed`?`border-destructive/40 bg-destructive/10 text-destructive`:h===`paused`||h===`stopped`?`border-warning/40 bg-warning/10 text-warning`:h===`completed`?`border-success/40 bg-success/10 text-success`:`border-primary/30 bg-primary/10 text-primary`),title:v??void 0,children:h})]}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[S.length>0&&(0,N.jsxs)(`select`,{value:Z?S.find(e=>e.title===p)?.id??``:``,onChange:e=>he(e.target.value),title:i(`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,N.jsx)(`option`,{value:``,disabled:!0,children:i(`activity:goalRun.boardsCount`,{count:S.length})}),S.map(e=>(0,N.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.status]},e.id))]}),Z&&(0,N.jsxs)(`button`,{type:`button`,onClick:se,title:i(`activity:goalRun.toggleAutonomousTitle`),className:w(`inline-flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors`,u?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[(0,N.jsx)(ee,{className:`h-3.5 w-3.5`}),` `,i(u?`activity:goalRun.autonomous`:`activity:goalRun.manual`)]}),pe&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`button`,{type:`button`,onClick:ce,title:i(h===`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:[h===`paused`?(0,N.jsx)(d,{className:`h-3.5 w-3.5`}):(0,N.jsx)(s,{className:`h-3.5 w-3.5`}),i(h===`paused`?`activity:goalRun.resume`:`activity:goalRun.pause`)]}),(0,N.jsxs)(`button`,{type:`button`,onClick:le,title:i(`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,N.jsx)(r,{className:`h-3.5 w-3.5 fill-current`}),` `,i(`activity:goalRun.stop`)]})]}),Z&&me&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`button`,{type:`button`,onClick:ue,title:i(`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,N.jsx)(l,{className:`h-3.5 w-3.5`}),` `,i(`activity:goalRun.newLabel`)]}),de?(0,N.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,N.jsx)(`span`,{className:`text-warning`,children:i(`activity:goalRun.revertConfirm`)}),(0,N.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:i(`common:action.yes`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>$(!1),className:`rounded px-1.5 py-0.5 text-muted-foreground hover:text-foreground`,children:i(`common:action.no`)})]}):(0,N.jsxs)(`button`,{type:`button`,onClick:()=>$(!0),title:i(`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,N.jsx)(f,{className:`h-3.5 w-3.5`}),` `,i(`activity:goalRun.revert`)]})]}),(0,N.jsx)(k,{variant:`ghost`,size:`icon`,onClick:e,children:(0,N.jsx)(_,{className:`h-4 w-4`})})]})]}),Z&&m&&(0,N.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 bg-muted/20 px-4 py-2.5`,children:[(0,N.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,N.jsx)(y,{className:`h-3 w-3`}),` `,i(`activity:goalRun.goal`)]}),(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:m})]}),Z?(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,N.jsx)(re,{})}):ae?(0,N.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,N.jsxs)(`div`,{className:`max-w-lg w-full space-y-5 text-center`,children:[(0,N.jsx)(o,{className:`h-10 w-10 mx-auto animate-spin text-primary/70`}),(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`h2`,{className:`text-xl font-semibold`,children:i(`activity:goalRun.planning`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`activity:goalRun.planningBody`)})]}),(0,N.jsxs)(`div`,{className:`rounded-lg border border-border bg-card px-4 py-3 text-left`,children:[(0,N.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,N.jsx)(y,{className:`h-3 w-3`}),` `,i(`activity:goalRun.goal`)]}),(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:L})]}),(0,N.jsxs)(k,{variant:`outline`,onClick:oe,className:`gap-2`,children:[(0,N.jsx)(r,{className:`h-4 w-4 fill-current`}),` `,i(`common:action.cancel`)]})]})}):(0,N.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,N.jsxs)(`div`,{className:`max-w-lg w-full space-y-6`,children:[(0,N.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,N.jsx)(y,{className:`h-10 w-10 mx-auto text-primary/60`}),(0,N.jsx)(`h2`,{className:`text-xl font-semibold`,children:i(`activity:goalRun.startHeading`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`activity:goalRun.startBody`)})]}),(0,N.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:i(`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(),Q())}}),Y&&(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,N.jsx)(o,{className:`h-3 w-3 animate-spin`}),i(`activity:goalRun.assess.analyzing`)]}),!Y&&J&&!J.parseFailed&&(0,N.jsxs)(`div`,{className:w(`rounded-lg border px-3 py-2 text-xs space-y-1.5`,J.realistic?`border-success/40 bg-success/10`:`border-warning/40 bg-warning/10`),children:[(0,N.jsx)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:J.realistic?(0,N.jsx)(`span`,{className:`text-success`,children:i(`activity:goalRun.assess.realistic`)}):(0,N.jsx)(`span`,{className:`text-warning`,children:i(`activity:goalRun.assess.durationConcern`)})}),J.durationClaimed&&(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:i(`activity:goalRun.assess.durationClaimed`,{duration:J.durationClaimed})}),(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:J.explanation}),J.recommendedDuration&&(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:i(`activity:goalRun.assess.recommendation`,{duration:J.recommendedDuration})}),J.concerns.length>0&&(0,N.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,N.jsx)(`p`,{className:`font-medium text-foreground/80`,children:i(`activity:goalRun.assess.concerns`)}),(0,N.jsx)(`ul`,{className:`list-disc pl-4 space-y-0.5 text-muted-foreground`,children:J.concerns.map((e,t)=>(0,N.jsx)(`li`,{children:e},t))})]})]}),!Y&&J?.parseFailed&&(0,N.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:i(`activity:goalRun.assess.analysisFailed`)}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:V,onChange:e=>H(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),i(`activity:goalRun.isolateLabel`)]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3 text-xs text-muted-foreground`,children:[(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:U,onChange:e=>W(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),i(`activity:goalRun.multiBoardLabel`)]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:G,onChange:e=>K(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),i(`activity:goalRun.verifyTasksLabel`)]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:q,onChange:e=>ie(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),i(`activity:goalRun.chimeraReviewLabel`)]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!Y&&J&&!J.realistic&&!J.parseFailed&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>T.getState().clear(),className:`shrink-0 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:i(`activity:goalRun.assess.overrideTitle`),children:i(`activity:goalRun.assess.override`)}),(0,N.jsxs)(k,{onClick:Q,disabled:!F.trim()||L!=null||Y||!Y&&J!=null&&!J.parseFailed&&!J.realistic,className:`flex-1 gap-2`,title:F.trim()&&!Y&&J&&!J.parseFailed&&!J.realistic?i(`activity:goalRun.assess.disableTitle`):``,children:[(0,N.jsx)(d,{className:`h-4 w-4`}),i(`activity:goalRun.startButton`)]})]}),(0,N.jsxs)(`p`,{className:`text-xs text-muted-foreground text-center`,children:[i(`activity:goalRun.ctrlHint`),` ·`,` `,i(V?`activity:goalRun.isolateOn`:`activity:goalRun.isolateOff`)]})]})}),j.length>0&&(0,N.jsxs)(`div`,{className:`border-t bg-card/50 shrink-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 pt-2 text-xs`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>B(!1),className:w(`rounded px-2 py-0.5 border transition-colors`,z?`border-border text-muted-foreground hover:text-foreground`:`bg-primary/10 border-primary/30 text-primary`),children:i(`activity:goalRun.lanes`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:w(`rounded px-2 py-0.5 border transition-colors`,z?`bg-primary/10 border-primary/30 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:i(`activity:goalRun.graph`)})]}),(0,N.jsxs)(`div`,{className:`space-y-2 px-4 pb-3`,children:[(0,N.jsx)(ne,{}),z?(0,N.jsx)(A,{worktrees:j,baseBranch:P}):(0,N.jsx)(te,{worktrees:j,baseBranch:P})]})]})]})}export{K as GoalView};
|