fix(engine): don't send the first message before the real default loads - #103
Closed
Its-My-Work wants to merge 1 commit into
Closed
Its-My-Work wants to merge 1 commit into
Its-My-Work wants to merge 1 commit into
Conversation
_globalDefaultEngine starts hardcoded 'api' and only becomes the actual configured default once checkVersion()'s /api/version fetch resolves and calls resolveEngineForView(). A message sent before that fetch landed — in practice, the very first message on a freshly loaded page — went out with curEngine still on that placeholder 'api'. The server bakes whatever `engine` arrives into the session's run_engine permanently (server.js ~11914), so this silently and irreversibly routed that chat's billing through the API key instead of the user's actually configured Subscription default, for the life of the chat. Capture checkVersion()'s promise as _versionCheckDone and await it at the top of send() — a no-op once already resolved, so this costs nothing beyond the first message of a session. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011E2bJQ2sL9LgEWosjvydTR
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_globalDefaultEnginestarts hardcoded'api'and only becomes the actual configured default oncecheckVersion()'s/api/versionfetch resolves and callsresolveEngineForView(). A message sent before that fetch lands — in practice, the very first message on a freshly loaded page — went out withcurEnginestill on that placeholder'api'.The server bakes whatever
enginearrives into the session'srun_enginepermanently (server.js~line 11914), so this silently and irreversibly routed that chat's billing through the API key instead of the user's actually-configured Subscription default, for the life of the chat.Fix
Capture
checkVersion()'s promise as_versionCheckDoneandawaitit at the top ofsend()— a no-op once already resolved, so this costs nothing beyond the first message of a session.Verified
run_engine='api'explicitly set even though the configured default was'subscription'— neverNULL(which would mean "inherit the default").Test plan
🤖 Generated with Claude Code
https://claude.ai/code/session_011E2bJQ2sL9LgEWosjvydTR