Skip to content

Commit 58e764c

Browse files
authored
fix(copilot): fix code block overflow (#861)
* Fix codeblock overflow * Increase max panel width * Lint
1 parent dc5cccd commit 58e764c

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/copilot-message.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ const SmoothStreamingText = memo(
145145
}, [content, isStreaming])
146146

147147
return (
148-
<div className='relative' style={{ minHeight: '1.25rem' }}>
149-
<div className='space-y-4 break-words font-geist-sans text-[#0D0D0D] text-base leading-relaxed dark:text-gray-100'>
148+
<div className='relative max-w-full overflow-hidden' style={{ minHeight: '1.25rem' }}>
149+
<div className='max-w-full space-y-4 break-words font-geist-sans text-[#0D0D0D] text-base leading-relaxed dark:text-gray-100'>
150150
<ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
151151
{displayedContent}
152152
</ReactMarkdown>
@@ -374,7 +374,7 @@ const CopilotMessage: FC<CopilotMessageProps> = memo(
374374
}
375375

376376
return (
377-
<div className='my-6 rounded-md bg-gray-900 text-sm dark:bg-black'>
377+
<div className='my-6 w-0 min-w-full rounded-md bg-gray-900 text-sm dark:bg-black'>
378378
<div className='flex items-center justify-between border-gray-700 border-b px-4 py-1.5 dark:border-gray-800'>
379379
<span className='font-geist-sans text-gray-400 text-xs'>{language}</span>
380380
<Button
@@ -390,9 +390,11 @@ const CopilotMessage: FC<CopilotMessageProps> = memo(
390390
<Copy className='h-3 w-3 text-gray-400' />
391391
</Button>
392392
</div>
393-
<pre className='overflow-x-auto p-4 font-mono text-gray-100 text-sm leading-relaxed'>
394-
{codeContent}
395-
</pre>
393+
<div className='overflow-x-auto'>
394+
<pre className='whitespace-pre p-4 font-mono text-gray-100 text-sm leading-relaxed'>
395+
{codeContent}
396+
</pre>
397+
</div>
396398
</div>
397399
)
398400
},
@@ -440,7 +442,7 @@ const CopilotMessage: FC<CopilotMessageProps> = memo(
440442

441443
// Tables
442444
table: ({ children }: React.TableHTMLAttributes<HTMLTableElement>) => (
443-
<div className='my-4 w-full overflow-x-auto'>
445+
<div className='my-4 max-w-full overflow-x-auto'>
444446
<table className='min-w-full table-auto border border-gray-300 font-geist-sans text-sm dark:border-gray-700'>
445447
{children}
446448
</table>
@@ -500,7 +502,7 @@ const CopilotMessage: FC<CopilotMessageProps> = memo(
500502
return (
501503
<div
502504
key={`text-${index}-${block.timestamp || index}`}
503-
className='w-full transition-opacity duration-200 ease-in-out'
505+
className='w-full max-w-full overflow-hidden transition-opacity duration-200 ease-in-out'
504506
style={{
505507
opacity: cleanBlockContent.length > 0 ? 1 : 0.7,
506508
transform: shouldUseSmoothing ? 'translateY(0)' : undefined,
@@ -516,7 +518,7 @@ const CopilotMessage: FC<CopilotMessageProps> = memo(
516518
markdownComponents={markdownComponents}
517519
/>
518520
) : (
519-
<div className='space-y-4 break-words font-geist-sans text-[#0D0D0D] text-base leading-relaxed dark:text-gray-100'>
521+
<div className='max-w-full space-y-4 break-words font-geist-sans text-[#0D0D0D] text-base leading-relaxed dark:text-gray-100'>
520522
<ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
521523
{cleanBlockContent}
522524
</ReactMarkdown>
@@ -600,8 +602,8 @@ const CopilotMessage: FC<CopilotMessageProps> = memo(
600602

601603
if (isAssistant) {
602604
return (
603-
<div className='w-full py-2 pl-[2px]'>
604-
<div className='space-y-2 transition-all duration-200 ease-in-out'>
605+
<div className='w-full max-w-full overflow-hidden py-2 pl-[2px]'>
606+
<div className='max-w-full space-y-2 transition-all duration-200 ease-in-out'>
605607
{/* Content blocks in chronological order */}
606608
{memoizedContentBlocks}
607609

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/copilot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export const Copilot = forwardRef<CopilotRef, CopilotProps>(({ panelWidth }, ref
208208
className='flex-1 overflow-hidden'
209209
hideScrollbar={true}
210210
>
211-
<div className='space-y-1'>
211+
<div className='w-full max-w-full space-y-1 overflow-hidden'>
212212
{messages.length === 0 ? (
213213
<div className='flex h-full items-center justify-center p-4'>
214214
<CopilotWelcome onQuestionClick={handleSubmit} mode={mode} />

apps/sim/stores/panel/store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export const usePanelStore = create<PanelStore>()(
1919
},
2020

2121
setPanelWidth: (width: number) => {
22-
// Ensure minimum width of 308px and maximum of 500px
23-
const clampedWidth = Math.max(308, Math.min(500, width))
22+
// Ensure minimum width of 308px and maximum of 800px
23+
const clampedWidth = Math.max(308, Math.min(800, width))
2424
set({ panelWidth: clampedWidth })
2525
},
2626
}),

0 commit comments

Comments
 (0)