Skip to content
Merged
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
12 changes: 10 additions & 2 deletions site/src/components/ai-elements/response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ const createComponents = (
};
};

// Precompute component maps for both themes at module scope so
// every Response instance shares the same stable references.
// This prevents Streamdown from discarding its cached render
// tree on each parent re-render.
const componentsByTheme: Record<FileViewerThemeType, Components> = {
light: createComponents("light", fileViewerTheme.light),
dark: createComponents("dark", fileViewerTheme.dark),
};

export const Response = ({
className,
children,
Expand All @@ -241,8 +250,7 @@ export const Response = ({
const theme = useTheme();
const fileViewerThemeType: FileViewerThemeType =
theme.palette.mode === "dark" ? "dark" : "light";
const viewerTheme = fileViewerTheme[fileViewerThemeType];
const components = createComponents(fileViewerThemeType, viewerTheme);
const components = componentsByTheme[fileViewerThemeType];

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ const mockTextAttachmentFetch = () => {
const defaultArgs: Omit<
React.ComponentProps<typeof ConversationTimeline>,
"parsedMessages"
> = {};
> = {
subagentTitles: new Map(),
};

const meta: Meta<typeof ConversationTimeline> = {
title: "pages/AgentsPage/AgentDetail/ConversationTimeline",
Expand Down
Loading
Loading