Skip to content

Commit 97c6911

Browse files
committed
hotfix to stop the loader from always spinning on code blocks
1 parent f651e78 commit 97c6911

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface StepContainerPreToolbarProps {
5252
codeBlockContent: string;
5353
language: string | null;
5454
relativeFilepath?: string;
55-
isGeneratingCodeBlock: boolean;
55+
isFinalCodeblock: boolean;
5656
codeBlockIndex: number; // To track which codeblock we are applying
5757
codeBlockStreamId: string;
5858
range?: string;
@@ -65,7 +65,7 @@ export function StepContainerPreToolbar({
6565
codeBlockContent,
6666
language,
6767
relativeFilepath,
68-
isGeneratingCodeBlock,
68+
isFinalCodeblock,
6969
codeBlockIndex,
7070
codeBlockStreamId,
7171
range,
@@ -115,6 +115,9 @@ export function StepContainerPreToolbar({
115115
const hasFileExtension =
116116
relativeFilepath && /\.[0-9a-z]+$/i.test(relativeFilepath);
117117

118+
const isStreaming = useAppSelector((store) => store.session.isStreaming);
119+
const isGeneratingCodeBlock = isFinalCodeblock && isStreaming;
120+
118121
// If we are creating a file, we already render that in the button
119122
// so we don't want to dispaly it twice here
120123
const displayFilepath = relativeFilepath ?? appliedFileUri;

gui/src/components/StyledMarkdownPreview/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
310310

311311
const language = getLanguageFromClassName(className);
312312

313+
const isFinalCodeblock =
314+
preChildProps["data-islastcodeblock"] && isLastItemRef.current;
315+
313316
const isGeneratingCodeBlock =
314317
preChildProps["data-islastcodeblock"] &&
315318
isLastItemRef.current &&
@@ -331,7 +334,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
331334
codeBlockIndex={codeBlockIndex}
332335
language={language}
333336
relativeFilepath={relativeFilePath}
334-
isGeneratingCodeBlock={isGeneratingCodeBlock}
337+
isFinalCodeblock={isFinalCodeblock}
335338
range={range}
336339
codeBlockStreamId={
337340
codeblockState.current[codeBlockIndex].streamId
@@ -381,7 +384,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
381384
const codeWrapState = uiConfig?.codeWrap ? "pre-wrap" : "pre";
382385
return (
383386
<StyledMarkdown
384-
contentEditable='false'
387+
contentEditable="false"
385388
fontSize={getFontSize()}
386389
whiteSpace={codeWrapState}
387390
bgColor={props.useParentBackgroundColor ? "" : vscBackground}

0 commit comments

Comments
 (0)