HERMES-GIELIE/static
Nathan Esquenazi c71439d8ab fix: model picker correctly updates on profile switch without flicker or raw injection
Root cause: three interacting bugs caused the model picker to show the wrong
model or flicker after a profile switch.

Bug 1 — syncTopbar() fought switchToProfile().
After switchToProfile() set the picker to the profile's model, syncTopbar()
was called (via renderSessionList -> loadSession, then explicitly at the end)
and overwrote it with S.session.model -- the old session's model.
Fix: added S._pendingProfileModel flag. switchToProfile() sets it;
syncTopbar() checks it first, applies the override, then clears it.
S.session.model is also updated to the resolved value so subsequent
syncTopbar() calls are consistent.

Bug 2 — Raw option injected at top of list for mismatched model IDs.
Profile configs store model IDs like 'claude-sonnet-4-6' (hermes-agent
format: hyphens, no namespace prefix) but the dropdown has
'anthropic/claude-sonnet-4.6' (OpenRouter format: dots, with prefix).
The old code did sel.value = id, found no match, then injected a new
<option> at the top of the list -- creating a lowercase duplicate that
didn't match any real provider group entry.
Fix: _findModelInDropdown() normalises both sides (strip prefix, hyphens->dots,
lowercase) and finds the best matching existing option. No new options are ever
injected for profile switching.

Bug 3 — populateModelDropdown() injected raw option on cold load.
Same issue: if default_model from /api/models didn't exactly match a dropdown
value, an extra option was added. Fixed by using _applyModelToDropdown()
which only selects existing options.

New helpers in ui.js:
  _findModelInDropdown(modelId, sel) -- smart fuzzy match, returns matched value
  _applyModelToDropdown(modelId, sel) -- sets picker, returns resolved value

Tests: 426 passed, 0 failed.
2026-04-03 20:10:47 +00:00
..
boot.js feat: multi-profile support -- create, switch, delete profiles from web UI (Issue #28) 2026-04-03 10:50:21 -07:00
commands.js feat: Sprint 17 -- workspace breadcrumbs, slash commands, send key setting 2026-04-03 04:13:38 -07:00
index.html fix: workspace updates on profile switch; remove redundant topbar workspace chip 2026-04-03 19:38:33 +00:00
messages.js feat: polish send button — hidden until content, icon-circle, pop-in animation 2026-04-03 07:20:16 -07:00
panels.js fix: model picker correctly updates on profile switch without flicker or raw injection 2026-04-03 20:10:47 +00:00
sessions.js fix: legacy sessions (profile=null) leak into all profiles' session lists 2026-04-03 19:50:08 +00:00
style.css fix: profile default workspace reads terminal.cwd; dropdown opens upward 2026-04-03 19:47:38 +00:00
ui.js fix: model picker correctly updates on profile switch without flicker or raw injection 2026-04-03 20:10:47 +00:00
workspace.js fix: profile switch fails with 'does not exist' when server starts on non-default profile 2026-04-03 19:29:24 +00:00