Hi all!
Im doing the following to clean the (previous) state, before triggering a new run:
setState((prev) => ({ ...prev!, generated_report: "" }))
await new Promise((resolve) => setTimeout(resolve, 100))
run(() => new TextMessage({
role: MessageRole.User,
content: 'Generate the report!',
}))
If i take out the 100ms wait, then the run() method runs concurrently as the cleaning setState, and flickering ocurrs.
How does one elegantly wait for the state to be cleaned up, in this case, the generated_report state variable, before calling run()?