8000 fix: make threadId optional in sendThreadMessage by alecf · Pull Request #292 · tambo-ai/tambo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 1 commit into from
Apr 7, 2025

Conversation

alecf
Copy link
Contributor
@alecf alecf commented Apr 7, 2025

fixes some backwards compatibility with 0.19

@charliecreates charliecreates bot requested a review from CharlieHelps April 7, 2025 15:47
Copy link
vercel bot commented Apr 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
showcase ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 7, 2025 3:48pm

Copy link
@charliecreates charliecreates bot left a 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 the TamboThreadContextProps interface and in the sendThreadMessage function.
  • Updated the default behavior so that if threadId is undefined in the options object, it now defaults to currentThread.id during destructuring.
  • Adjusted the dependency array of the useCallback hook to use currentThread.id instead of the whole currentThread object.

streamResponse?: boolean;
contextKey?: string;
} = { threadId: PLACEHOLDER_THREAD.id },
): Promise<TamboThreadMessage> => {
const { threadId, streamResponse } = options;
const { threadId = currentThread.id, streamResponse } = options;
Copy link

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.

@charliecreates charliecreates bot removed the request for review from CharlieHelps April 7, 2025 15:49
@alecf alecf merged commit e043f35 into main Apr 7, 2025
6 checks passed
@alecf alecf deleted the alecf/thread-current-thread branch April 7, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0