perf: optimize agent stream view rendering
- Separate streaming item from FlatList data array to prevent full re-diffs on every streaming chunk - Memoize renderStreamItem with useCallback - Memoize AgentThoughtMessage component with React.memo The main fix is rendering the streaming message in ListHeaderComponent instead of prepending it to the data array, which was causing the entire list to re-diff on every character streamed.
This commit is contained in:
@@ -963,7 +963,7 @@ const agentThoughtStylesheet = StyleSheet.create((theme) => ({
|
||||
},
|
||||
}));
|
||||
|
||||
export function AgentThoughtMessage({ message, status = "ready" }: AgentThoughtMessageProps) {
|
||||
export const AgentThoughtMessage = memo(function AgentThoughtMessage({ message, status = "ready" }: AgentThoughtMessageProps) {
|
||||
const { theme } = useUnistyles();
|
||||
const [isExpanded, setIsExpanded] = useState(false);
|
||||
const markdownContent = useMemo(() => message?.trim() ?? "", [message]);
|
||||
@@ -1102,7 +1102,7 @@ export function AgentThoughtMessage({ message, status = "ready" }: AgentThoughtM
|
||||
isLoading={status !== "ready"}
|
||||
/>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
interface ToolCallProps {
|
||||
toolName: string;
|
||||
|
||||
Reference in New Issue
Block a user