From 7fd52ff6c335ffbfd35dd9d91dc783a7788c5e6e Mon Sep 17 00:00:00 2001 From: adarshramiyer Date: Wed, 2 Jul 2025 19:49:48 -0700 Subject: [PATCH] updated logToolUsage to use core "devdata/log" message --- .../components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx | 6 +++++- gui/src/hooks/ParallelListeners.tsx | 2 +- gui/src/redux/thunks/callCurrentTool.ts | 4 ++-- gui/src/redux/util/index.ts | 5 +++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gui/src/components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx b/gui/src/components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx index 510366448..466887a3e 100644 --- a/gui/src/components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx +++ b/gui/src/components/mainInput/Lump/LumpToolbar/LumpToolbar.tsx @@ -1,9 +1,11 @@ -import { useEffect } from "react"; +import { useContext, useEffect } from "react"; import { useSelector } from "react-redux"; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; import { selectCurrentToolCall } from "../../../../redux/selectors/selectCurrentToolCall"; import { cancelToolCall } from "../../../../redux/slices/sessionSlice"; import { callCurrentTool } from "../../../../redux/thunks/callCurrentTool"; +import { logToolUsage } from "../../../../redux/util"; import { isJetBrains } from "../../../../util"; import { BlockSettingsTopToolbar } from "./BlockSettingsTopToolbar"; import { EditOutcomeToolbar } from "./EditOutcomeToolbar"; @@ -50,6 +52,8 @@ export function LumpToolbar() { } else if ((jetbrains ? altKey : metaKey) && event.key === "Backspace") { event.preventDefault(); event.stopPropagation(); + const ideMessenger = useContext(IdeMessengerContext); + logToolUsage(toolCallState, false, true, ideMessenger); void dispatch( cancelToolCall({ toolCallId: toolCallState.toolCallId, diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index 891bc88c9..14faa8631 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -264,7 +264,7 @@ function ParallelListeners() { state.toolCallId!, ); if (toolCallState) { - logToolUsage(toolCallState, true, true); + logToolUsage(toolCallState, true, true, ideMessenger); } void dispatch(exitEdit({})); } diff --git a/gui/src/redux/thunks/callCurrentTool.ts b/gui/src/redux/thunks/callCurrentTool.ts index 2110e93b6..cedebe4f9 100644 --- a/gui/src/redux/thunks/callCurrentTool.ts +++ b/gui/src/redux/thunks/callCurrentTool.ts @@ -123,14 +123,14 @@ export const callCurrentTool = createAsyncThunk( if (streamResponse) { if (errorMessage) { - logToolUsage(toolCallState, false, false, output); + logToolUsage(toolCallState, false, false, extra.ideMessenger, output); dispatch( errorToolCall({ toolCallId, }), ); } else { - logToolUsage(toolCallState, true, true, output); + logToolUsage(toolCallState, true, true, extra.ideMessenger, output); dispatch( acceptToolCall({ toolCallId, diff --git a/gui/src/redux/util/index.ts b/gui/src/redux/util/index.ts index 3e2d9a6ef..83c8394c7 100644 --- a/gui/src/redux/util/index.ts +++ b/gui/src/redux/util/index.ts @@ -1,5 +1,5 @@ import { ContextItem, ToolCallState } from "core"; -import { DataLogger } from "core/data/log"; +import { IIdeMessenger } from "../../context/IdeMessenger"; import { ChatHistoryItemWithMessageId } from "../slices/sessionSlice"; import { RootState } from "../store"; @@ -33,9 +33,10 @@ export function logToolUsage( toolCallState: ToolCallState, accepted: boolean, success: boolean, + messenger: IIdeMessenger, finalOutput?: ContextItem[], ) { - void DataLogger.getInstance().logDevData({ + messenger.post("devdata/log", { name: "toolUsage", data: { toolCallId: toolCallState.toolCallId,