diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/CollapsibleContainer.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/CollapsibleContainer.tsx new file mode 100644 index 000000000..464c4b4cf --- /dev/null +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/CollapsibleContainer.tsx @@ -0,0 +1,55 @@ +import { ChevronDownIcon } from "@heroicons/react/24/outline"; +import { useState } from "react"; + +interface CollapsibleContainerProps { + children: React.ReactNode; + maxHeight?: string; + className?: string; + collapsible?: boolean; +} + +export function CollapsibleContainer({ + children, + maxHeight = "max-h-40", + className = "", + collapsible = false, +}: CollapsibleContainerProps) { + const [isExpanded, setIsExpanded] = useState(false); + + // If not collapsible, just render children without any collapsible behavior + if (!collapsible) { + return
{children}
; + } + + return ( +
+
+ {children} +
+ + {!isExpanded && ( +
+
setIsExpanded(true)} + className="group flex h-full cursor-pointer items-end justify-center pb-2" + > + + + +
+
+ )} + + {isExpanded && ( +
setIsExpanded(false)} + className="group mt-2 flex cursor-pointer justify-center" + > + + + +
+ )} +
+ ); +} diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx index 8ece216bb..1d252dbdb 100644 --- a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx @@ -13,6 +13,7 @@ import { getFontSize } from "../../../util"; import Spinner from "../../gui/Spinner"; import { isTerminalCodeBlock } from "../utils"; import { ApplyActions } from "./ApplyActions"; +import { CollapsibleContainer } from "./CollapsibleContainer"; import { CopyButton } from "./CopyButton"; import { CreateFileButton } from "./CreateFileButton"; import { FileInfo } from "./FileInfo"; @@ -32,6 +33,7 @@ export interface StepContainerPreToolbarProps { children: any; expanded?: boolean; disableManualApply?: boolean; + collapsible?: boolean; } export function StepContainerPreToolbar({ @@ -47,6 +49,7 @@ export function StepContainerPreToolbar({ children, expanded, disableManualApply, + collapsible, }: StepContainerPreToolbarProps) { const ideMessenger = useContext(IdeMessengerContext); const history = useAppSelector((state) => state.session.history); @@ -298,9 +301,10 @@ export function StepContainerPreToolbar({ {renderActionButtons()} - {isExpanded && ( -
{children}
+ + {children} + )} ); diff --git a/gui/src/components/StyledMarkdownPreview/index.tsx b/gui/src/components/StyledMarkdownPreview/index.tsx index 0f2d1af0d..b01e49256 100644 --- a/gui/src/components/StyledMarkdownPreview/index.tsx +++ b/gui/src/components/StyledMarkdownPreview/index.tsx @@ -127,6 +127,7 @@ interface StyledMarkdownPreviewProps { disableManualApply?: boolean; toolCallId?: string; expandCodeblocks?: boolean; + collapsible?: boolean; } const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-"; @@ -305,6 +306,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( forceToolCallId={props.toolCallId} expanded={props.expandCodeblocks} disableManualApply={props.disableManualApply} + collapsible={props.collapsible} > diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx index 77fd2757f..27b093799 100644 --- a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx @@ -18,12 +18,13 @@ export function EditFile(props: EditToolCallProps) { return ( ); }