Changesets · Branches · Tags · Compare
| Changeset | 401f69e2e4c47d28495c1eb3a4d832695387efbca0f4ff12e3181c75f362e65d |
|---|---|
| Author | Nate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-07-05 10:30 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-07-05 10:30 -07:00 |
| Parents | 4073142854bc, 757036cb67e5 |
4 files changed
added gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/CollapsibleContainer.tsx +55 −0
| @@ -0,0 +1,55 @@ | ||
| 1 | +import { ChevronDownIcon } from "@heroicons/react/24/outline"; | |
| 2 | +import { useState } from "react"; | |
| 3 | + | |
| 4 | +interface CollapsibleContainerProps { | |
| 5 | + children: React.ReactNode; | |
| 6 | + maxHeight?: string; | |
| 7 | + className?: string; | |
| 8 | + collapsible?: boolean; | |
| 9 | +} | |
| 10 | + | |
| 11 | +export function CollapsibleContainer({ | |
| 12 | + children, | |
| 13 | + maxHeight = "max-h-40", | |
| 14 | + className = "", | |
| 15 | + collapsible = false, | |
| 16 | +}: CollapsibleContainerProps) { | |
| 17 | + const [isExpanded, setIsExpanded] = useState(false); | |
| 18 | + | |
| 19 | + // If not collapsible, just render children without any collapsible behavior | |
| 20 | + if (!collapsible) { | |
| 21 | + return <div className={className}>{children}</div>; | |
| 22 | + } | |
| 23 | + | |
| 24 | + return ( | |
| 25 | + <div className={`relative ${className}`}> | |
| 26 | + <div className={`overflow-hidden ${isExpanded ? "" : maxHeight}`}> | |
| 27 | + {children} | |
| 28 | + </div> | |
| 29 | + | |
| 30 | + {!isExpanded && ( | |
| 31 | + <div className="from-editor absolute bottom-0 left-0 right-0 h-12 bg-gradient-to-t to-transparent"> | |
| 32 | + <div | |
| 33 | + onClick={() => setIsExpanded(true)} | |
| 34 | + className="group flex h-full cursor-pointer items-end justify-center pb-2" | |
| 35 | + > | |
| 36 | + <span title="Expand to show full content"> | |
| 37 | + <ChevronDownIcon className="text-lightgray group-hover:text-foreground h-4 w-4" /> | |
| 38 | + </span> | |
| 39 | + </div> | |
| 40 | + </div> | |
| 41 | + )} | |
| 42 | + | |
| 43 | + {isExpanded && ( | |
| 44 | + <div | |
| 45 | + onClick={() => setIsExpanded(false)} | |
| 46 | + className="group mt-2 flex cursor-pointer justify-center" | |
| 47 | + > | |
| 48 | + <span title="Collapse to compact view"> | |
| 49 | + <ChevronDownIcon className="text-lightgray group-hover:text-foreground h-4 w-4 rotate-180" /> | |
| 50 | + </span> | |
| 51 | + </div> | |
| 52 | + )} | |
| 53 | + </div> | |
| 54 | + ); | |
| 55 | +} |
modified gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx +6 −2
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | import Spinner from "../../gui/Spinner"; |
| 14 | 14 | import { isTerminalCodeBlock } from "../utils"; |
| 15 | 15 | import { ApplyActions } from "./ApplyActions"; |
| 16 | +import { CollapsibleContainer } from "./CollapsibleContainer"; | |
| 16 | 17 | import { CopyButton } from "./CopyButton"; |
| 17 | 18 | import { CreateFileButton } from "./CreateFileButton"; |
| 18 | 19 | import { FileInfo } from "./FileInfo"; |
| @@ -32,6 +33,7 @@ | ||
| 32 | 33 | children: any; |
| 33 | 34 | expanded?: boolean; |
| 34 | 35 | disableManualApply?: boolean; |
| 36 | + collapsible?: boolean; | |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | export function StepContainerPreToolbar({ |
| @@ -47,6 +49,7 @@ | ||
| 47 | 49 | children, |
| 48 | 50 | expanded, |
| 49 | 51 | disableManualApply, |
| 52 | + collapsible, | |
| 50 | 53 | }: StepContainerPreToolbarProps) { |
| 51 | 54 | const ideMessenger = useContext(IdeMessengerContext); |
| 52 | 55 | const history = useAppSelector((state) => state.session.history); |
| @@ -298,9 +301,10 @@ | ||
| 298 | 301 | {renderActionButtons()} |
| 299 | 302 | </div> |
| 300 | 303 | </div> |
| 301 | - | |
| 302 | 304 | {isExpanded && ( |
| 303 | - <div className="overflow-hidden overflow-y-auto">{children}</div> | |
| 305 | + <CollapsibleContainer collapsible={collapsible}> | |
| 306 | + {children} | |
| 307 | + </CollapsibleContainer> | |
| 304 | 308 | )} |
| 305 | 309 | </div> |
| 306 | 310 | ); |
modified gui/src/components/StyledMarkdownPreview/index.tsx +2 −0
| @@ -127,6 +127,7 @@ | ||
| 127 | 127 | disableManualApply?: boolean; |
| 128 | 128 | toolCallId?: string; |
| 129 | 129 | expandCodeblocks?: boolean; |
| 130 | + collapsible?: boolean; | |
| 130 | 131 | } |
| 131 | 132 | |
| 132 | 133 | const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-"; |
| @@ -305,6 +306,7 @@ | ||
| 305 | 306 | forceToolCallId={props.toolCallId} |
| 306 | 307 | expanded={props.expandCodeblocks} |
| 307 | 308 | disableManualApply={props.disableManualApply} |
| 309 | + collapsible={props.collapsible} | |
| 308 | 310 | > |
| 309 | 311 | <SyntaxHighlightedPre {...preProps} /> |
| 310 | 312 | </StepContainerPreToolbar> |
modified gui/src/pages/gui/ToolCallDiv/EditFile.tsx +2 −1
| @@ -18,12 +18,13 @@ | ||
| 18 | 18 | |
| 19 | 19 | return ( |
| 20 | 20 | <StyledMarkdownPreview |
| 21 | - expandCodeblocks={props.expandCodeblocks ?? false} | |
| 21 | + expandCodeblocks={false} | |
| 22 | 22 | isRenderingInStepContainer |
| 23 | 23 | disableManualApply |
| 24 | 24 | source={src} |
| 25 | 25 | toolCallId={props.toolCallId} |
| 26 | 26 | itemIndex={props.historyIndex} |
| 27 | + collapsible={true} | |
| 27 | 28 | /> |
| 28 | 29 | ); |
| 29 | 30 | } |