Fix Chat Page Refreshing Before Saving Chat #399
+124
−45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
aiState.done
is called beforeonSetAIState
onSetAIState
callback is removed and instead anaiStateDone
wrapper aroundaiState.done
is called in place ofaiState.done
. This wrapper function waits until the chat is saved to the db before marking the aiState updates as done.chat.tsx
, theuseEffect
hook for refreshing the router contains an additional check to refresh the router if the chat contains 3 messages and the last message is a tool call. The existing check only checked for 2 messages, meaning the router was not refreshed if the first user message in a chat resulted in a tool call response.Purchase
componentstatus
now defaults torequires_action
, instead ofexpired
, with auseEffect
hook added to check and update the purchase status based on the relevant tool call message and any related system messages.toolCallId
is passed as a prop toPurchase
. This is used to find the relevant tool call in theaiState.messages
.purchased
, then the purchase is marked as completed.createdAt
property is added to theMessage
interface. If the tool call message was created more than 30 seconds ago, the checkout is marked as expired. While the status remains in arequires_action
state, an interval is set to check every 5 seconds whether the status should beexpired
.