fix(tui): defer --model validation until providers load#23271
Open
kagura-agent wants to merge 2 commits intoanomalyco:devfrom
Open
fix(tui): defer --model validation until providers load#23271kagura-agent wants to merge 2 commits intoanomalyco:devfrom
kagura-agent wants to merge 2 commits intoanomalyco:devfrom
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #23270
Type of change
What does this PR do?
Fixes
--modelflag being rejected at TUI startup because model validation runs before provider metadata loads.Two problems:
Race condition:
app.tsxonMountcallsmodel.set()→isModelValid()checkssync.data.providerwhich is still empty → shows "not valid" toast for a valid model.Priority override: Even when validation passes, the agent's configured model overwrites the CLI selection because the agent-change
createEffectfires after mount.Fix: Replace the eager
onMountvalidation with a reactivecliOverridesignal inlocal.tsxthat resolves once providers load and takes highest priority in the model resolution chain. The agent-change effect skips auto-override when a CLI override is active.How did you verify your code works?
Traced the full execution path:
sync.tsxbootstrap (async provider fetch) →local.tsxmodel resolution (createEffectreactivity onsync.data.provider) →app.tsxmount lifecycle. Confirmed SolidJScreateEffectre-evaluates when provider data arrives, andcliOverridecorrectly participates ingetFirstValidModelpriority chain.Screenshots / recordings
N/A (logic-only change, no UI changes)
Checklist