diff --git a/src/__fixtures__/confirmation.ts b/src/__fixtures__/confirmation.ts new file mode 100644 index 00000000..0c3edc01 --- /dev/null +++ b/src/__fixtures__/confirmation.ts @@ -0,0 +1,52 @@ +import { ToolConfirmationPauseReason } from "../services/refact"; + +export const CONFIRMATIONAL_PAUSE_REASONS_WITH_PATH: ToolConfirmationPauseReason[] = + [ + { + command: "SELECT *", + rule: "*", + type: "confirmation", + tool_call_id: "1", + integr_config_path: + "\\\\?\\d:\\work\\refact.ai\\refact-lsp\\.refact\\integrations\\postgres.yaml", + }, + ]; +export const CONFIRMATIONAL_PAUSE_REASONS: ToolConfirmationPauseReason[] = [ + { + command: "patch", + rule: "default", + type: "confirmation", + tool_call_id: "1", + integr_config_path: null, + }, +]; + +export const DENIAL_PAUSE_REASONS_WITH_PATH: ToolConfirmationPauseReason[] = [ + { + command: "SELECT *", + rule: "*", + type: "denial", + tool_call_id: "1", + integr_config_path: + "\\\\?\\d:\\work\\refact.ai\\refact-lsp\\.refact\\integrations\\postgres.yaml", + }, +]; + +export const MIXED_PAUSE_REASONS: ToolConfirmationPauseReason[] = [ + { + command: "SELECT *", + rule: "*", + type: "denial", + tool_call_id: "1", + integr_config_path: + "\\\\?\\d:\\work\\refact.ai\\refact-lsp\\.refact\\integrations\\postgres.yaml", + }, + { + command: "DROP *", + rule: "*", + type: "confirmation", + tool_call_id: "1", + integr_config_path: + "\\\\?\\d:\\work\\refact.ai\\refact-lsp\\.refact\\integrations\\postgres.yaml", + }, +]; diff --git a/src/components/ChatContent/ChatContent.tsx b/src/components/ChatContent/ChatContent.tsx index 7e786037..a6c825ec 100644 --- a/src/components/ChatContent/ChatContent.tsx +++ b/src/components/ChatContent/ChatContent.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useRef } from "react"; +import React, { useCallback, useMemo, useRef } from "react"; import { ChatMessages, isChatContextFileMessage, @@ -18,6 +18,7 @@ import { PlainText } from "./PlainText"; import { useAppDispatch } from "../../hooks"; import { useAppSelector } from "../../hooks"; import { + selectIntegration, selectIsStreaming, selectIsWaiting, selectMessages, @@ -49,6 +50,7 @@ export const ChatContent: React.FC = ({ const isWaiting = useAppSelector(selectIsWaiting); const [sendTelemetryEvent] = telemetryApi.useLazySendTelemetryChatEventQuery(); + const integrationMeta = useAppSelector(selectIntegration); const { handleScroll, @@ -93,6 +95,10 @@ export const ChatContent: React.FC = ({ }); }, [onStopStreaming, sendTelemetryEvent]); + const shouldConfigButtonBeVisible = useMemo(() => { + return isConfig && !integrationMeta?.path?.includes("project_summary"); + }, [isConfig, integrationMeta?.path]); + return ( = ({ Stop )} - {isConfig && ( + {shouldConfigButtonBeVisible && (