-
Notifications
You must be signed in to change notification settings - Fork 25
fix: make threadId optional in sendThreadMessage #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes improve backwards compatibility by making threadId
optional. However, there is a potential inconsistency in the defaulting logic between the default parameter and the destructuring assignment that could lead to unexpected behavior.
Summary of changes
Summary of Changes
- Made
threadId
optional in theTamboThreadContextProps
interface and in thesendThreadMessage
function. - Updated the default behavior so that if
threadId
is undefined in the options object, it now defaults tocurrentThread.id
during destructuring. - Adjusted the dependency array of the
useCallback
hook to usecurrentThread.id
instead of the wholecurrentThread
object.
streamResponse?: boolean; | ||
contextKey?: string; | ||
} = { threadId: PLACEHOLDER_THREAD.id }, | ||
): Promise<TamboThreadMessage> => { | ||
const { threadId, streamResponse } = options; | ||
const { threadId = currentThread.id, streamResponse } = options; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default assignment for threadId
is handled in two places: the default parameter ({ threadId: PLACEHOLDER_THREAD.id }
) and the destructuring default (threadId = currentThread.id
). This may lead to inconsistent behavior when a caller explicitly passes an empty object versus when the parameter is omitted. Ensure that this discrepancy is intentional for backwards compatibility and consider unifying the defaults to avoid potential confusion.
Suggestion
Consider using a unified default value for threadId
across both the default parameter and the destructuring. For example, change the default parameter to use currentThread.id
:
} = { threadId: currentTh
AB49
read.id },
Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion.
fixes some backwards compatibility with 0.19