Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,20 @@ export const LongLineFencedBlock: Story = {
},
play: async ({ canvasElement }) => {
// The fenced block renders asynchronously inside the FileViewer
// shadow root, so retry until a horizontally scrollable viewport
// shadow root, so retry until a horizontally scrollable container
// exists, then scroll it so the capture shows the scrolled state.
const viewport = await waitFor(() => {
const found = [
...canvasElement.querySelectorAll<HTMLElement>(
"[data-radix-scroll-area-viewport]",
),
].find((v) => v.scrollWidth > v.clientWidth);
const scroller = await waitFor(() => {
const found = [...canvasElement.querySelectorAll<HTMLElement>("*")].find(
(el) =>
getComputedStyle(el).overflowX === "auto" &&
el.scrollWidth > el.clientWidth,
);
if (!found) {
throw new Error("Expected a horizontally scrollable viewport.");
throw new Error("Expected a horizontally scrollable code block.");
}
return found;
});
viewport.scrollLeft = 200;
scroller.scrollLeft = 200;
},
};

Expand Down
50 changes: 25 additions & 25 deletions site/src/pages/AgentsPage/components/ChatElements/Response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
type UrlTransform,
} from "streamdown";
import { CopyButton } from "#/components/CopyButton/CopyButton";
import { ScrollArea } from "#/components/ScrollArea/ScrollArea";
import { useTheme } from "#/theme/context";
import {
type InlineNode,
Expand Down Expand Up @@ -308,32 +307,33 @@ const createComponents = (
: (lang as SupportedLanguages);
// MermaidDiagram's error fallback strips the margin, border
// and rounding from its direct child, so the frame must stay
// on the outermost element rather than the ScrollArea.
// on the outermost element rather than the scroll container.
const codeBlock = (
<div className="group/code-block relative my-4 overflow-hidden rounded-md border bg-surface-primary">
<ScrollArea
orientation="both"
scrollBarClassName="w-1.5"
horizontalScrollBarClassName="h-1.5"
>
<FileViewer
file={{
name: `block.${viewerLang}`,
lang: viewerLang,
contents: content,
cacheKey: content,
}}
options={{
overflow: "scroll",
themeType: fileViewerThemeType,
disableFileHeader: true,
disableLineNumbers: true,
theme: viewerTheme,
unsafeCSS: markdownFileViewerCSS,
}}
style={markdownFileViewerStyle}
/>
</ScrollArea>
{/* Not ScrollArea: its per-instance <style> makes WebKit restyle the
whole document each time a code block mounts or unmounts. */}
<div className="overflow-auto scrollbar-thin">
{/* Sizes the viewer to its longest line, so long lines scroll. */}
<div className="table min-w-full">
<FileViewer
file={{
name: `block.${viewerLang}`,
lang: viewerLang,
contents: content,
cacheKey: content,
}}
options={{
overflow: "scroll",
themeType: fileViewerThemeType,
disableFileHeader: true,
disableLineNumbers: true,
theme: viewerTheme,
unsafeCSS: markdownFileViewerCSS,
}}
style={markdownFileViewerStyle}
/>
</div>
</div>
<CopyButton
text={content}
label="Copy code"
Expand Down
Loading