forked from sourcegraph/cody
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Cody Chat UI rendering reconciliation (sourcegraph#5850)
Fixes part of https://linear.app/sourcegraph/issue/CODY-3943/optimize-performance-for-large-chat-windows-in-cody It looks like since sourcegraph#5036 we've lost memoization in a few places. As a result, our chat UI doesn't perform well with more than 4-5 messages (depending on how long these chat messages are) This PR tries to improve it by fixing memoization on expensive components (Transcript, HumanMessage, ...etc) | Before | After | | ------- | ------- | | <video src="https://github.com/user-attachments/assets/79e7b93c-ac82-4a8c-9b2e-6c712af3fb2c" /> | <video src="https://github.com/user-attachments/assets/223b3513-0f30-47cc-b24c-c54f4861329c" /> | This PR also fixes a problem with one-box intention detection; previously, it produced a state where we didn't have a follow-up message UI during intent resolution. ## Test plan - Check with the React profile that we don't render components during message response in places where we don't need to re-render anything - Check that intent detection in one-box doesn't produce UI flashes
- Loading branch information
1 parent
198e655
commit daf1cd5
Showing
6 changed files
with
128 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useEffect, useRef } from 'react' | ||
|
||
export function useTracePropsUpdate(props: any) { | ||
const prev = useRef(props) | ||
|
||
useEffect(() => { | ||
const changedProps = Object.entries(props).reduce( | ||
(prop, [k, v]) => { | ||
if (prev.current[k] !== v) { | ||
prop[k] = [prev.current[k], v] | ||
} | ||
return prop | ||
}, | ||
{} as Record<any, any> | ||
) | ||
|
||
if (Object.keys(changedProps).length > 0) { | ||
console.log('Changed props:', changedProps) | ||
} | ||
|
||
prev.current = props | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters