TamboHack: Streaming status tracking for nested objects/arrays
Problem:
The current implementation of useTamboStreamStatus (see here ) only supports flat object structures for tracking streaming status. When working with components that have nested properties, developers cannot track the streaming status of individual nested fields, limiting the granularity of loading states and user experience optimizations.
Additionally, when streaming an array field, we often only want to display the items that have completed streaming, but the sdk currently doesn't provide an easy way to access these items.
We should enable tracking of the status of fields nested within props objects, and the status of each element in an array prop.
Proposed Solution:
- Update useTamboStreamStatus and the usePropsStreamingStatus used within it so the object returned contains a nested 'status' field for each nested object, so the final object might look like:
{
propStatus: {
user: {
// Status for the 'user' object itself
isPending: false,
isStreaming: true,
isSuccess: false,
error: undefined,
// Nested properties
name: {
isPending: false,
isStreaming: true, // Currently streaming
isSuccess: false,
error: undefined
},
email: {
isPending: true, // Hasn't started yet
isStreaming: false,
isSuccess: false,
error: undefined
}
}
}
}- Update the same functions so that the status of any array fields contains extra fields that hold the list of completedItems and streamingItems
Acceptance Criteria:
When I have const { propStatus } = useTamboStreamStatus(); in a component that has a prop with nested objects, the propStatus contains the status of the nested objects, which I can access using: propStatus["parent"]["child"].isStreaming for example.
When I have const { propStatus } = useTamboStreamStatus(); in a component that has a prop which is an array, the propStatus contains the the list of completedItems and the list of streaming items, which I can access using: propStatus["arrayField"].completedItemsfor example.
Tests to cover nested object and array scenarios
Documentation about streaming status is updated to include description and examples of nested object and array scenarios
Source: tambo-ai/tambo