Repository navigation
fix: find config without HOME and match variant models in the fallback chain - #42
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.
azumag
left a comment
There was a problem hiding this comment.
差分を確認しました。Windows で HOME が無い場合の os.homedir() fallback と、reasoning-effort variant を同一モデルの provider fallback にだけ引き継ぐ変更は問題の境界に合っています。追加テストも HOME/XDG 未設定、同一モデルへの variant 継承、異モデルへ継承しないケースを直接カバーしています。CI の action_required は jobs=0 でコード/テスト failure ではなく、fork PR の Actions 実行承認待ちと判断します。必須修正なしです。
|
追レビューで1点見つけました(PRは既にmerge済みなので follow-up 推奨です)。
具体的には、fallback中にユーザーが 今回必要なのは「設定された fallback chain と runtime model の照合では variant を無視する」ことなので、matcherを分けるのが安全だと思います。
回帰テストとして「fallback後、 Windows の |
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.