Stabilize chat transport auth for hosted sandboxes#1591
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Caution Review failedPull request was closed or merged during review WalkthroughThis pull request refactors the chat session authentication and transport configuration system. The changes replace static auth header handling with dynamic transport-based configuration, introduce a transport configuration reference that holds session-specific data, and update the mocking infrastructure across tests to simulate transport behavior more realistically. The module exports transition from Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
useChatSessionon a single long-lived AI SDK transport and move mutable chat request config behind a refauthFetchso hosted sandbox chat uses request-time bearer resolution and guest-token retryTesting
Note
Medium Risk
Changes how chat requests are authenticated and routed by moving transport config to request-time refs and switching transport fetch to
authFetch, which could affect authorization headers and chat session resets in hosted/non-hosted flows.Overview
Stabilizes
useChatSessionby creating a single long-livedDefaultChatTransportand moving mutable request config (model, prompt, temperature, selected servers, hosted tokens, tool-approval flag) behind refs so it’s read at send-time instead of via render closures.Routes chat transport requests through
authFetchand changes header behavior: hosted chat relies onauthFetchfor request-time bearer/guest-token retry, while non-hosted chat only attaches an explicitAuthorizationheader for the MCPJam-provided model path (dropping the previous merged session header approach).Updates hook tests to simulate AI SDK transport latching and assert correct request bodies/headers for hosted sandboxes, minimal mode, and forked session behavior.
Written by Cursor Bugbot for commit ec9a1fb. This will update automatically on new commits. Configure here.