#11806: fix(ui): agent model dropdown not reflecting actual primary model
app: web-ui
stale
Cluster:
Model Management Enhancements
## Summary
- Fix Lit rendering race condition where `<select .value=...>` fires before dynamically generated `<option>` children are in the DOM, causing the model dropdown to always show the first option instead of the configured primary model
- Use `?selected` on individual `<option>` elements instead, matching the pattern already used in `sessions.ts` and `usage.ts`
- Add test coverage for the agents model dropdown (`agents.test.ts`)
## Test plan
- [x] All 4 new tests in `agents.test.ts` pass (configured primary selected, agent-specific override, inherit-default fallback, unlisted model shown as "Current")
- [x] Full UI test suite passes (167/168 — 1 pre-existing failure in `navigation.browser.test.ts` unrelated to this change)
- [x] Manual: open Agents page, confirm dropdown reflects actual primary model, not first option
https://github.com/user-attachments/assets/24a4ed86-f239-4a07-bb22-95cf22c63807
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the Agents “Primary model” dropdown rendering to avoid a Lit timing issue where setting `<select .value=…>` can run before dynamically generated `<option>` elements exist. It does this by moving selection logic onto each `<option>` via `?selected`, and adds a new `agents.test.ts` file with coverage for selecting the configured default, agent overrides, inheritance behavior, and handling an unlisted “current” model.
The change is localized to the Agents view (`ui/src/ui/views/agents.ts`) and its new view-level tests (`ui/src/ui/views/agents.test.ts`).
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge after fixing a correctness issue in the “Inherit default” selection logic.
- The core fix (moving selection to `?selected` on `<option>`) aligns with existing patterns and should address the reported Lit rendering race. However, the new logic makes the empty-value “Inherit default” option effectively unselectable/never-selected because `effectivePrimary` is always populated when a default exists, which changes UX semantics for non-default agents. Tests also appear a bit brittle in how they locate the dropdown.
- ui/src/ui/views/agents.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#21293: fix(ui): use live() directive for agent Primary model select to fix...
by soohanpark · 2026-02-19
83.4%
#20712: fix(subagents): prioritize agent runtime default model over global ...
by sourcesavant · 2026-02-19
80.0%
#20968: fix(ui): enable save button when editing default agent models
by Gitjay11 · 2026-02-19
79.5%
#15142: fix(ui): fallbacks input always empty even when config has models (...
by yinghaosang · 2026-02-13
78.1%
#22977: fix(ui): resolve agent names from config in session dropdown
by NikhilGaddam · 2026-02-21
77.4%
#9583: fix(models): allow models in agents.defaults.models even if not in ...
by hotzen100 · 2026-02-05
76.5%
#16838: fix: include configured fallbacks in model allowlist
by taw0002 · 2026-02-15
76.2%
#21088: fix: sessions_sspawn model override ignored for sub-agents
by Slats24 · 2026-02-19
76.1%
#21791: feat(TUI): show main agent model in status footer
by chansuke · 2026-02-20
76.1%
#11349: fix(agents): do not filter fallback models by models allowlist
by liuxiaopai-ai · 2026-02-07
76.0%