agents icon indicating copy to clipboard operation
agents copied to clipboard

Feature request: Conditional agent connection in react

Open dnyg opened this issue 4 months ago • 3 comments

When using the useAgent hook in react it would be useful to be able to provide a enabled?: boolean parameter as part of the agent options (much like React Query does) where the websocket connection is only started once the enabled parameter returns true.

dnyg avatar Oct 02 '25 09:10 dnyg

You can pass startClosed: true, to useAgent, and then call agent.reconnect() when needed, will that work?

threepointone avatar Oct 03 '25 12:10 threepointone

You can pass startClosed: true, to useAgent, and then call agent.reconnect() when needed, will that work?

It is not as elegant as the enabled? hook known from react query, because I still have to write the useEffect then to trigger the reconnect. But it absolutely does solve the problem I have 🔥

Thank you very much 🙏

(I'll refrain from closing this issue in case it is feedback you want to work with. If you don't feel like it's worthwhile, feel free to close the issue 🙌 )

dnyg avatar Oct 03 '25 13:10 dnyg

yeah maybe we want to implement enabled anyway (upstream in partysocket). let's leave this open for a while.

threepointone avatar Oct 03 '25 14:10 threepointone