Elffuss BraidHub

kikocis/continue public

Merge pull request #6467 from continuedev/nate/diff-ui-edit

don't expand edit tool codeblocks by default
Changeset401f69e2e4c47d28495c1eb3a4d832695387efbca0f4ff12e3181c75f362e65d
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-07-05 10:30 -07:00
CommitterGitHub <noreply@github.com> · 2025-07-05 10:30 -07:00
Parents4073142854bc, 757036cb67e5

Browse the files at this changeset

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 @@
1313 import Spinner from "../../gui/Spinner";
1414 import { isTerminalCodeBlock } from "../utils";
1515 import { ApplyActions } from "./ApplyActions";
16+import { CollapsibleContainer } from "./CollapsibleContainer";
1617 import { CopyButton } from "./CopyButton";
1718 import { CreateFileButton } from "./CreateFileButton";
1819 import { FileInfo } from "./FileInfo";
@@ -32,6 +33,7 @@
3233 children: any;
3334 expanded?: boolean;
3435 disableManualApply?: boolean;
36+ collapsible?: boolean;
3537 }
3638
3739 export function StepContainerPreToolbar({
@@ -47,6 +49,7 @@
4749 children,
4850 expanded,
4951 disableManualApply,
52+ collapsible,
5053 }: StepContainerPreToolbarProps) {
5154 const ideMessenger = useContext(IdeMessengerContext);
5255 const history = useAppSelector((state) => state.session.history);
@@ -298,9 +301,10 @@
298301 {renderActionButtons()}
299302 </div>
300303 </div>
301-
302304 {isExpanded && (
303- <div className="overflow-hidden overflow-y-auto">{children}</div>
305+ <CollapsibleContainer collapsible={collapsible}>
306+ {children}
307+ </CollapsibleContainer>
304308 )}
305309 </div>
306310 );
modified gui/src/components/StyledMarkdownPreview/index.tsx +2 −0
@@ -127,6 +127,7 @@
127127 disableManualApply?: boolean;
128128 toolCallId?: string;
129129 expandCodeblocks?: boolean;
130+ collapsible?: boolean;
130131 }
131132
132133 const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-";
@@ -305,6 +306,7 @@
305306 forceToolCallId={props.toolCallId}
306307 expanded={props.expandCodeblocks}
307308 disableManualApply={props.disableManualApply}
309+ collapsible={props.collapsible}
308310 >
309311 <SyntaxHighlightedPre {...preProps} />
310312 </StepContainerPreToolbar>
modified gui/src/pages/gui/ToolCallDiv/EditFile.tsx +2 −1
@@ -18,12 +18,13 @@
1818
1919 return (
2020 <StyledMarkdownPreview
21- expandCodeblocks={props.expandCodeblocks ?? false}
21+ expandCodeblocks={false}
2222 isRenderingInStepContainer
2323 disableManualApply
2424 source={src}
2525 toolCallId={props.toolCallId}
2626 itemIndex={props.historyIndex}
27+ collapsible={true}
2728 />
2829 );
2930 }