feat(app): add model-switching to btw_app()#196
Draft
gadenbuie wants to merge 12 commits into
Draft
Conversation
… improve UI integration
Previously, btw_status_bar_ui() made a live API call to fetch available models during UI construction, blocking rendering on slow or unavailable networks. Now the select input is seeded with just the current model, and an observe() in the server populates the full list after the session starts.
Replaces individual per-counter reset messages with a single btw_reset_status message. The JS handler resets all status-countup elements matching the module namespace to zero and clears all state classes (btw-status-unknown, btw-status-recalculating), fixing a bug where clearing chat would display $0.00 for providers with unknown pricing.
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
Adds a
model_choicesparameter tobtw_app()that lets users switch between AI providers and models from within the app's status bar.The new parameter accepts four values:
"auto"(default) — uses models frombtw.mdif the app was launched with one, otherwise falls back to the provider's model list"btw_md"— shows the namedcliententries from thebtw.mdconfig as model choices, enabling switching between providers mid-conversation"provider"— fetches available models from the active provider's API (previous behavior)"none"— no model selector shownWhen switching between providers (
"btw_md"mode), the server creates a new client from the target config, transfers the system prompt, tools, and conversation history, and replaces any<thinking>content blocks that are incompatible across providers. A toast notification confirms the switch.Provider model choices are populated asynchronously after session start to avoid a startup race condition. The status bar's token and cost counters reset when the chat is cleared, and the provider badge appearance was polished.
Verification