Skip to content

fix(tui): defer --model validation until providers load#23271

Open
kagura-agent wants to merge 2 commits intoanomalyco:devfrom
kagura-agent:fix/tui-model-validation-timing
Open

fix(tui): defer --model validation until providers load#23271
kagura-agent wants to merge 2 commits intoanomalyco:devfrom
kagura-agent:fix/tui-model-validation-timing

Conversation

@kagura-agent
Copy link
Copy Markdown

@kagura-agent kagura-agent commented Apr 18, 2026

Issue for this PR

Closes #23270

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes --model flag being rejected at TUI startup because model validation runs before provider metadata loads.

Two problems:

  1. Race condition: app.tsx onMount calls model.set()isModelValid() checks sync.data.provider which is still empty → shows "not valid" toast for a valid model.

  2. Priority override: Even when validation passes, the agent's configured model overwrites the CLI selection because the agent-change createEffect fires after mount.

Fix: Replace the eager onMount validation with a reactive cliOverride signal in local.tsx that 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.tsx bootstrap (async provider fetch) → local.tsx model resolution (createEffect reactivity on sync.data.provider) → app.tsx mount lifecycle. Confirmed SolidJS createEffect re-evaluates when provider data arrives, and cliOverride correctly participates in getFirstValidModel priority chain.

Screenshots / recordings

N/A (logic-only change, no UI changes)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

TUI validates --model before providers load, causing false 'Model ... is not valid'

1 participant