Repository navigation
fix: trigger re-render when agent node changes - #4620
nytheradev wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@aartisonigra is attempting to deploy a commit to the CopilotKit Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi maintainers, I’ve synced the branch with the latest upstream changes. The fix ensures proper re-rendering when the agent node changes by using useState along with useRef. Could you please review this PR? Also, some Vercel checks are awaiting authorization. Thank you! |
|
Thanks for this, and sorry it sat. I've verified the fix and it's correct: Two small things and I think this is ready: 1. Missing trailing newline — this fails the The whole fix: return nodeName;
-}
\ No newline at end of file
+}2. A small test would be welcome if you're up for it — there's no test file for this hook yet, and the behavior is observable through One thing on our side, not yours: this means every |
|
Closing this as superseded — but the diagnosis here was right, it was first, and I handled the follow-through badly. You found it correctly: What happened next is on me. I confirmed your fix in August, asked for two cosmetic changes, and then six days later landed the same change myself in #6520 ( For completeness on why it can't be merged as-is now, independent of the above: Sorry for the eight-month gap and for not crediting you when it landed. The instinct you showed here — reading a hook and noticing the ref/render mismatch rather than working around the symptom — is the useful kind, and I'd be glad to see more from you. If you want something current with a clearer runway, say so and I'll point you at one. |
I fixed an issue in useAgentNodeName where the hook was only updating a useRef, which did not trigger React re-renders when the agent node changed. This could result in stale or undefined values being accessed during runtime.
To resolve this, I introduced useState alongside useRef so that updates to the node name properly trigger re-renders while still maintaining a reference for internal consistency.
The nodeName is now updated through a shared updateNodeName function used across all event handlers (onStepStartedEvent, onRunStartedEvent, onRunFinishedEvent, and onRunErrorEvent), ensuring consistent state updates across the agent lifecycle.
This change improves reliability and ensures UI always reflects the latest agent node state.