don't collapse code blocks in chat mode

This commit is contained in:
Nate 2025-07-04 22:50:08 -07:00
parent 76d73dbb91
commit 923b7e79d3
4 changed files with 17 additions and 2 deletions

View file

@ -5,15 +5,22 @@ 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 <div className={className}>{children}</div>;
}
return (
<div className={`relative ${className}`}>
<div className={`overflow-hidden ${isExpanded ? "" : maxHeight}`}>

View file

@ -33,6 +33,7 @@ export interface StepContainerPreToolbarProps {
children: any;
expanded?: boolean;
disableManualApply?: boolean;
collapsible?: boolean;
}
export function StepContainerPreToolbar({
@ -48,6 +49,7 @@ export function StepContainerPreToolbar({
children,
expanded,
disableManualApply,
collapsible,
}: StepContainerPreToolbarProps) {
const ideMessenger = useContext(IdeMessengerContext);
const history = useAppSelector((state) => state.session.history);
@ -299,8 +301,11 @@ export function StepContainerPreToolbar({
{renderActionButtons()}
</div>
</div>
{isExpanded && <CollapsibleContainer>{children}</CollapsibleContainer>}
{isExpanded && (
<CollapsibleContainer collapsible={collapsible}>
{children}
</CollapsibleContainer>
)}
</div>
);
}

View file

@ -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}
>
<SyntaxHighlightedPre {...preProps} />
</StepContainerPreToolbar>

View file

@ -24,6 +24,7 @@ export function EditFile(props: EditToolCallProps) {
source={src}
toolCallId={props.toolCallId}
itemIndex={props.historyIndex}
collapsible={true}
/>
);
}