diff --git a/src/Explorer/QueryCopilot/V2/Bubbles/Output/OutputBubble.tsx b/src/Explorer/QueryCopilot/V2/Bubbles/Output/OutputBubble.tsx index d4ca08310..c009a5f0b 100644 --- a/src/Explorer/QueryCopilot/V2/Bubbles/Output/OutputBubble.tsx +++ b/src/Explorer/QueryCopilot/V2/Bubbles/Output/OutputBubble.tsx @@ -2,18 +2,31 @@ import { Stack, Text } from "@fluentui/react"; import { EditorReact } from "Explorer/Controls/Editor/EditorReact"; import { CopilotMessage } from "Explorer/QueryCopilot/Shared/QueryCopilotInterfaces"; import { OutputBubbleButtons } from "Explorer/QueryCopilot/V2/Bubbles/Output/Buttons/OutputBubbleButtons"; +import { userContext } from "UserContext"; import React, { useState } from "react"; export const OutputBubble = ({ copilotMessage }: { copilotMessage: CopilotMessage }): JSX.Element => { const [windowHeight, setWindowHeight] = useState(); + const textHeightWithPadding = 16; const calculateQueryWindowHeight = (): string => { - const calculatedHeight = document.getElementById("outputBubble")?.clientHeight * (3 / 5); - return `${calculatedHeight}px`; + const outputWidth = document.getElementById("outputBubble")?.clientWidth; + const responseLength = copilotMessage.sqlQuery.length; + + if (outputWidth > responseLength) { + return `${textHeightWithPadding * 3}px`; + } else { + const neededLines = Math.ceil(responseLength / outputWidth); + return `${neededLines * textHeightWithPadding}px`; + } }; React.useEffect(() => { - setWindowHeight(calculateQueryWindowHeight()); + if (userContext.features.copilotChatFixedMonacoEditorHeight) { + setWindowHeight(`${textHeightWithPadding * 5}px`); + } else { + setWindowHeight(calculateQueryWindowHeight()); + } }, []); return ( diff --git a/src/Platform/Hosted/extractFeatures.ts b/src/Platform/Hosted/extractFeatures.ts index 57656b14d..d4d33775f 100644 --- a/src/Platform/Hosted/extractFeatures.ts +++ b/src/Platform/Hosted/extractFeatures.ts @@ -40,6 +40,7 @@ export type Features = { readonly copilotVersion?: string; readonly disableCopilotPhoenixGateaway: boolean; readonly enableCopilotFullSchema: boolean; + readonly copilotChatFixedMonacoEditorHeight: boolean; // can be set via both flight and feature flag autoscaleDefault: boolean; @@ -112,6 +113,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear copilotVersion: get("copilotversion") ?? "v1.0", disableCopilotPhoenixGateaway: "true" === get("disablecopilotphoenixgateaway"), enableCopilotFullSchema: "true" === get("enablecopilotfullschema", "true"), + copilotChatFixedMonacoEditorHeight: "true" === get("copilotchatfixedmonacoeditorheight"), }; }