feat: support arbitrary ANTHROPIC_DEFAULT_*_MODEL env keys#380
Open
sylzd wants to merge 1 commit into
Open
Conversation
Dynamically discover model env vars instead of hardcoding 4 known keys, so users can configure additional tiers (e.g. ANTHROPIC_DEFAULT_MIMO_MODEL) and have them appear in the UI automatically. - Add collectModelEnvKeys() to scan env for matching pattern - Update getModelsFromEnvironment/getCustomModelIds/getCurrentModel to use it - Update computeEnvHash in main.ts for session invalidation - Add 14 new test cases covering dynamic key discovery Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
ANTHROPIC_DEFAULT_*_MODELenvironment variable instead of hardcoding only 4 known keysANTHROPIC_DEFAULT_MIMO_MODEL) in their env vars will now see them in the model selector automaticallycomputeEnvHash()updated to include dynamic model keys so session invalidation triggers correctlyChanges
src/utils/env.ts: Replace hardcodedCUSTOM_MODEL_ENV_KEYSwithcollectModelEnvKeys()that scans env vars via regex patternANTHROPIC_DEFAULT_(\w+)_MODEL. UpdatedgetModelsFromEnvironment(),getCustomModelIds(), andgetCurrentModelFromEnvironment()to use it.src/main.ts:computeEnvHash()now usescollectModelEnvKeys()so adding/removing a custom model env var triggers session refresh.tests/unit/utils/env.test.ts: 14 new test cases covering dynamic key discovery, mixed known+dynamic keys, priority ordering, and fallback behavior.Test plan
npm run test -- --selectProjects unit --testPathPatterns env.test— all 154 tests pass (14 new)npx tsc --noEmit— no type errorsnpx eslint— 0 errors, 0 warningsANTHROPIC_DEFAULT_MIMO_MODEL=xiaomi/mimo-v2-proin env vars, confirm it appears in model selector dropdown🤖 Generated with Claude Code