2026-03-24 22:30:26 +01:00
|
|
|
import { create } from 'zustand'
|
|
|
|
|
|
2026-03-24 22:43:55 +01:00
|
|
|
type CaptureMode = 'NONE' | 'INPUT' | 'OUTPUT' | 'BOTH'
|
|
|
|
|
|
2026-03-24 22:30:26 +01:00
|
|
|
interface TracingState {
|
fix: update frontend field names for identity rename (applicationId, instanceId)
The backend identity rename (applicationName → applicationId,
agentId → instanceId) was not reflected in the frontend. This caused
drilldown to fail (detail.applicationName was undefined, disabling
the diagram fetch) and various display issues.
Updated schema.d.ts, ExchangeHeader, ExecutionDiagram, Dashboard,
AgentHealth, AgentInstance, LayoutShell, LogTab, InfoTab, DetailPanel,
ExchangesPage, and tracing-store.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 18:22:16 +02:00
|
|
|
/** Key: applicationId → { processorId: captureMode } */
|
2026-03-24 22:43:55 +01:00
|
|
|
tracedProcessors: Record<string, Record<string, CaptureMode>>
|
|
|
|
|
isTraced: (app: string, processorId: string) => boolean
|
|
|
|
|
/** Toggle processor tracing (BOTH on, remove on off). Returns the full map for the app. */
|
|
|
|
|
toggleProcessor: (app: string, processorId: string) => Record<string, CaptureMode>
|
2026-03-25 07:42:55 +01:00
|
|
|
/** Sync store with server-side config (called when config is fetched). */
|
|
|
|
|
syncFromServer: (app: string, tracedProcessors: Record<string, string>) => void
|
2026-03-24 22:30:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const useTracingStore = create<TracingState>((set, get) => ({
|
|
|
|
|
tracedProcessors: {},
|
|
|
|
|
|
2026-03-24 22:43:55 +01:00
|
|
|
isTraced: (app, processorId) =>
|
|
|
|
|
processorId in (get().tracedProcessors[app] ?? {}),
|
2026-03-24 22:30:26 +01:00
|
|
|
|
2026-03-24 22:43:55 +01:00
|
|
|
toggleProcessor: (app, processorId) => {
|
|
|
|
|
const current = { ...(get().tracedProcessors[app] ?? {}) }
|
|
|
|
|
if (processorId in current) delete current[processorId]
|
|
|
|
|
else current[processorId] = 'BOTH'
|
2026-03-24 22:30:26 +01:00
|
|
|
set((state) => ({
|
2026-03-24 22:43:55 +01:00
|
|
|
tracedProcessors: { ...state.tracedProcessors, [app]: current },
|
2026-03-24 22:30:26 +01:00
|
|
|
}))
|
|
|
|
|
return current
|
|
|
|
|
},
|
2026-03-25 07:42:55 +01:00
|
|
|
|
|
|
|
|
syncFromServer: (app, serverMap) => {
|
|
|
|
|
const mapped: Record<string, CaptureMode> = {}
|
|
|
|
|
for (const [k, v] of Object.entries(serverMap)) {
|
|
|
|
|
mapped[k] = v as CaptureMode
|
|
|
|
|
}
|
|
|
|
|
set((state) => ({
|
|
|
|
|
tracedProcessors: { ...state.tracedProcessors, [app]: mapped },
|
|
|
|
|
}))
|
|
|
|
|
},
|
2026-03-24 22:30:26 +01:00
|
|
|
}))
|