Skip to content

fix(zcode): keep selected default model in personalModelIds - #751

Merged
lzt404 merged 1 commit into
router-for-me:devfrom
wenbaolu6666-design:WenPaul/fix-zcode-repair-default-model
Dec 4, 2026
Merged

lzt404 merged 1 commit into
router-for-me:devfrom
wenbaolu6666-design:WenPaul/fix-zcode-repair-default-model

Conversation

@wenbaolu6666-design

Copy link
Copy Markdown
Contributor

Summary

Fixes ZCode integration remaining stuck in Needs Repair (needs-update) even after clicking Repair / Update Configuration when the selected default model is not already present in personalModelIds.

Root Cause

  • ZCode builds a standard-personal provider's active model list from personalModelIds, and inspect_zcode_agent_config requires defaultModelSelection.modelId to be contained in personalModelIds.
  • Previously, build_zcode_agent_config pruned personalModelIds against the live catalog without ever adding the selected default model, while still writing that model to defaultModelSelection. If the user previously hid models in ZCode Model Catalog Settings (or the previous default model disappeared from /v1/models), clicking Repair wrote a config that immediately failed inspect_zcode_agent_config again.
  • In addition, resolving selection_model against ordered (which always inserts model) prevented falling back to available_models[0] when model was no longer in available_models, and unchecking the active default model in save_zcode_editor left defaultModelSelection pointing at a disabled model.

Changes

  • src-tauri/crates/ecpa-agents/src/configuration.rs (build_zcode_agent_config):
    • Resolve selection_model against available_models first so removed models properly fall back to available_models[0] (or keep model when available_models is empty).
    • Keep existing pruning/order-preservation behavior (never re-adding other hidden models), while ensuring the selected default model is present in personalModelIds and modelOrder.
  • src-tauri/crates/ecpa-agents/src/zcode.rs (save_zcode_editor):
    • When the currently active cpa-gui default model is disabled in ZCode Model Catalog Settings while other models remain enabled, update defaultModelSelection to the first remaining enabled model (respecting modelOrder).
  • src-tauri/crates/ecpa-agents/src/tests/agent_configuration.rs:
    • Updated zcode_preserves_catalog_visibility_and_model_order to verify both hidden-model preservation when updating with an enabled default model and inclusion of the selected default model when repairing/applying.
    • Added regression tests zcode_repair_includes_selected_default_model_in_personal_model_ids and zcode_catalog_editor_updates_default_model_when_disabling_active_model.

Verification

  • Cloud unit tests (cargo test --manifest-path src-tauri/Cargo.toml -p ecpa-agents zcode): all 29 ZCode tests covering this change passed, including both new regression tests and zcode_agent_config_falls_back_to_an_available_default_model.
  • Built Windows amd64 test package (v0.3.130-test.zcode-repair.1) and verified live against ZCode 4.1.2.11125: clicking Repair immediately transitioned ZCode from Needs Repair to Configured, kept existing glm-5.3-flash, added only qwenwork/flash to personalModelIds, and left all other hidden models untouched.

@lzt404
lzt404 merged commit 2592639 into router-for-me:dev Dec 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants