-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix(ui) reduce redundant rerenders #3593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -582,8 +582,7 @@ export function useChat( | |
| readArgs?.path as string | undefined, | ||
| tc.result.output | ||
| ) | ||
| if (resource) { | ||
| addResource(resource) | ||
| if (resource && addResource(resource)) { | ||
| onResourceEventRef.current?.() | ||
| } | ||
| } | ||
|
|
@@ -594,12 +593,23 @@ export function useChat( | |
| case 'resource_added': { | ||
| const resource = parsed.resource | ||
| if (resource?.type && resource?.id) { | ||
| addResource(resource) | ||
| const wasAdded = addResource(resource) | ||
| invalidateResourceQueries(queryClient, workspaceId, resource.type, resource.id) | ||
|
|
||
| onResourceEventRef.current?.() | ||
| if (!wasAdded) { | ||
| if (activeResourceIdRef.current !== resource.id) { | ||
| setActiveResourceId(resource.id) | ||
| onResourceEventRef.current?.() | ||
| } | ||
| } else { | ||
| onResourceEventRef.current?.() | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Panel won't re-expand for active-but-collapsed resource When Before this PR, If the intent is only to avoid the rerender (not the expand), consider still firing the event when the panel is collapsed: (Note: this would require threading |
||
|
|
||
| if (resource.type === 'workflow') { | ||
| if (ensureWorkflowInRegistry(resource.id, resource.title, workspaceId)) { | ||
| if ( | ||
| wasAdded && | ||
| ensureWorkflowInRegistry(resource.id, resource.title, workspaceId) | ||
| ) { | ||
|
cursor[bot] marked this conversation as resolved.
Outdated
|
||
| useWorkflowRegistry.getState().setActiveWorkflow(resource.id) | ||
| } else { | ||
| useWorkflowRegistry.getState().loadWorkflowState(resource.id) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.