From 581d53a33e6b2bbec9f36d6e8b789f0e8b03bfc1 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Tue, 24 Mar 2026 22:43:55 +0100 Subject: [PATCH] fix: match SET_TRACED_PROCESSORS payload to agent protocol Payload now sends {processors: {id: "BOTH"}} map instead of {routeId, processorIds[]} array. Tracing state keyed by application name (global, not per-route) matching agent behavior. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../pages/ExchangeDetail/ExchangeDetail.tsx | 18 +++++++------- ui/src/stores/tracing-store.ts | 24 +++++++++++-------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/ui/src/pages/ExchangeDetail/ExchangeDetail.tsx b/ui/src/pages/ExchangeDetail/ExchangeDetail.tsx index 3ef7c3b2..81cc7404 100644 --- a/ui/src/pages/ExchangeDetail/ExchangeDetail.tsx +++ b/ui/src/pages/ExchangeDetail/ExchangeDetail.tsx @@ -164,26 +164,26 @@ export default function ExchangeDetail() { const { toast } = useToast() const tracingStore = useTracingStore() const sendCommand = useSendGroupCommand() - const appRoute = detail ? `${detail.applicationName}:${detail.routeId}` : '' + const app = detail?.applicationName ?? '' const handleToggleTracing = useCallback((processorId: string) => { - if (!processorId || !detail?.applicationName || !detail?.routeId) return - const newSet = tracingStore.toggleProcessor(appRoute, processorId) + if (!processorId || !detail?.applicationName) return + const newMap = tracingStore.toggleProcessor(app, processorId) sendCommand.mutate({ group: detail.applicationName, type: 'set-traced-processors', - payload: { routeId: detail.routeId, processorIds: Array.from(newSet) }, + payload: { processors: newMap }, }, { onSuccess: (data) => { - const action = newSet.has(processorId) ? 'enabled' : 'disabled' + const action = processorId in newMap ? 'enabled' : 'disabled' toast({ title: `Tracing ${action}`, description: `${processorId} — sent to ${data?.targetCount ?? 0} agent(s)`, variant: 'success' }) }, onError: () => { - tracingStore.toggleProcessor(appRoute, processorId) + tracingStore.toggleProcessor(app, processorId) toast({ title: 'Command failed', description: 'Could not send tracing command', variant: 'error' }) }, }) - }, [detail, appRoute, tracingStore, sendCommand, toast]) + }, [detail, app, tracingStore, sendCommand, toast]) // Correlation chain const correlatedExchanges = useMemo(() => { @@ -346,7 +346,7 @@ export default function ExchangeDetail() { const pid = processorIds[index] if (!pid || !detail?.applicationName) return [] return [{ - label: tracingStore.isTraced(appRoute, pid) ? 'Disable Tracing' : 'Enable Tracing', + label: tracingStore.isTraced(app, pid) ? 'Disable Tracing' : 'Enable Tracing', onClick: () => handleToggleTracing(pid), disabled: sendCommand.isPending, }] @@ -365,7 +365,7 @@ export default function ExchangeDetail() { const pid = flowProcessorIds[index] if (!pid || !detail?.applicationName) return [] return [{ - label: tracingStore.isTraced(appRoute, pid) ? 'Disable Tracing' : 'Enable Tracing', + label: tracingStore.isTraced(app, pid) ? 'Disable Tracing' : 'Enable Tracing', onClick: () => handleToggleTracing(pid), disabled: sendCommand.isPending, }] diff --git a/ui/src/stores/tracing-store.ts b/ui/src/stores/tracing-store.ts index d0791bbe..c5c8c3be 100644 --- a/ui/src/stores/tracing-store.ts +++ b/ui/src/stores/tracing-store.ts @@ -1,23 +1,27 @@ import { create } from 'zustand' +type CaptureMode = 'NONE' | 'INPUT' | 'OUTPUT' | 'BOTH' + interface TracingState { - tracedProcessors: Record> - isTraced: (appRoute: string, processorId: string) => boolean - toggleProcessor: (appRoute: string, processorId: string) => Set + /** Key: applicationName → { processorId: captureMode } */ + tracedProcessors: Record> + 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 } export const useTracingStore = create((set, get) => ({ tracedProcessors: {}, - isTraced: (appRoute, processorId) => - get().tracedProcessors[appRoute]?.has(processorId) ?? false, + isTraced: (app, processorId) => + processorId in (get().tracedProcessors[app] ?? {}), - toggleProcessor: (appRoute, processorId) => { - const current = new Set(get().tracedProcessors[appRoute] ?? []) - if (current.has(processorId)) current.delete(processorId) - else current.add(processorId) + toggleProcessor: (app, processorId) => { + const current = { ...(get().tracedProcessors[app] ?? {}) } + if (processorId in current) delete current[processorId] + else current[processorId] = 'BOTH' set((state) => ({ - tracedProcessors: { ...state.tracedProcessors, [appRoute]: current }, + tracedProcessors: { ...state.tracedProcessors, [app]: current }, })) return current },