Repository navigation
fix: find config without HOME and match variant models in the fallback chain - #42
Open
madsiberian wants to merge 1 commit into
Open
madsiberian wants to merge 1 commit into
madsiberian wants to merge 1 commit into
Conversation
…k chain Two fixes that together make the v2 fallback work for Z.AI coding-plan users on Windows. - loadConfig used process.env.HOME || "", which on Windows (where HOME is usually unset) resolves the home-based config paths against the process cwd instead of the user profile, so the plugin silently finds no config and registers nothing. Fall back to os.homedir(). - sameModel compared the reasoning-effort variant, so a session on glm-5.3#high never matched a variant-less chain entry and the fallback never engaged. Ignore the variant when matching, and carry it onto same-model fallbacks (glm-5.3#high -> zai/glm-5.3#high) so effort is preserved across providers; different-model tiers (e.g. a flash model) keep their default effort.
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.
Problem
Two independent bugs kept the v2 fallback from working for Z.AI coding-plan users on Windows:
Config never found on Windows.
loadConfigusedprocess.env.HOME || "". On WindowsHOMEis normally unset, so the home-based search paths resolved against the process cwd instead of the user profile. The plugin silently found no config,fallbackModelsstayed empty, andsetupregistered nothing.Variant models never matched the chain.
sameModelcompared the reasoning-effort variant, so a session onglm-5.3#high(configured viareasoningEffort: "high") never matched a variant-less chain entry. Theretryhook fired and detection passed (HTTP 429), buthandles(model)returned false, so no fallback ever engaged.Changes
src/utils/config.ts: fall back toos.homedir()whenHOMEis unset.v2.ts: ignore the variant when matching (sameModel), and carry the failed model's variant onto same-model fallbacks (chainFor) soglm-5.3#high -> zai/glm-5.3#highpreserves effort; different-model tiers (e.g. a flash model) keep their default effort.Testing
loadConfigfalls back toos.homedir()whenHOME/XDG_CONFIG_HOMEare unset.vitest run: 734 passed (the 2 failures are pre-existingsymlinkSyncEPERM tests that need admin/Developer Mode on Windows — unrelated).npm run typecheckandnpm run buildpass.Note
errorPatterns.customis parsed byvalidateConfigbut never wired into the v2 detection path (the v2 entrypoint matches against a fixed pattern list). That's a separate gap left untouched here; flagging it in case you want a follow-up.