Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

fix: ensure latest toolbar state is used when sending enabled toolkits to chat API#8

Merged
alt-glitch merged 1 commit into
mainfrom
sid/fix-toolkit-enabling
Jun 6, 2025
Merged

fix: ensure latest toolbar state is used when sending enabled toolkits to chat API#8
alt-glitch merged 1 commit into
mainfrom
sid/fix-toolkit-enabling

Conversation

@alt-glitch

Copy link
Copy Markdown
Contributor

Summary

This PR fixes a UX bug where enabled toolkits weren't being sent to the chat API when a user enabled and connected tools after the chat component was already mounted.

Problem

  • When a user logged in, opened the toolbar, enabled a tool and connected to it, then started chatting, the chat component wasn't updating with the enabled toolkits
  • The LLM wasn't receiving the toolkits in the chat route because the experimental_prepareRequestBody function was capturing the initial toolbar state via closure

Solution

  • Use useRef to maintain a reference to the latest toolbar state
  • Update the experimental_prepareRequestBody callback to always use the current state from the ref instead of the potentially stale closure value
  • This ensures that even if tools are enabled/connected after the chat component mounts, they will be included in the request

Test plan

  1. Login to the application
  2. Navigate to a chat
  3. Open the toolbar (⌘T)
  4. Enable a tool and connect to it
  5. Send a message in the chat
  6. Verify that the enabled toolkit is sent to the API (can be verified in network tab or server logs)

🤖 Generated with Claude Code

…s to chat API

Use useRef to capture the current toolbar state in experimental_prepareRequestBody callback to fix issue where enabled toolkits weren't sent when tools were connected after chat component mount

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 6, 2025

Copy link
Copy Markdown

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

Name Status Preview Comments Updated (UTC)
chat 🔄 Building (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 4:23am

@alt-glitch
alt-glitch merged commit db14b50 into main Jun 6, 2025
2 of 4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant