| import { QueryClient } from "@tanstack/react-query"; |
| import type { ActionEvent } from "#/types/agent-server/core/events/action-event"; |
| import { useModelStore } from "#/stores/model-store"; |
| import { stripWorkspacePrefix } from "./path-utils"; |
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export const handleActionEventCacheInvalidation = ( |
| event: ActionEvent, |
| conversationId: string, |
| queryClient: QueryClient, |
| ) => { |
| const { action } = event; |
|
|
| |
| if ( |
| action.kind === "StrReplaceEditorAction" || |
| action.kind === "FileEditorAction" || |
| action.kind === "ExecuteBashAction" |
| ) { |
| queryClient.invalidateQueries( |
| { |
| queryKey: ["file_changes", conversationId], |
| }, |
| { cancelRefetch: false }, |
| ); |
| } |
|
|
| |
| if ( |
| (action.kind === "StrReplaceEditorAction" || |
| action.kind === "FileEditorAction") && |
| action.path |
| ) { |
| const strippedPath = stripWorkspacePrefix(action.path); |
| queryClient.invalidateQueries({ |
| queryKey: ["file_diff", conversationId, strippedPath], |
| }); |
| } |
|
|
| |
| |
| |
| |
| if (event.tool_name === "SwitchLLMTool") { |
| queryClient.invalidateQueries({ |
| queryKey: ["user", "conversation", conversationId], |
| }); |
| useModelStore.getState().clearActiveProfile(conversationId); |
| } |
| }; |
|
|