Skip to content

fix: reset model picker on session switch#1779

Closed
Michaelyklam wants to merge 1 commit into
nesquena:masterfrom
Michaelyklam:fix/issue-1771-session-model-sync
Closed

fix: reset model picker on session switch#1779
Michaelyklam wants to merge 1 commit into
nesquena:masterfrom
Michaelyklam:fix/issue-1771-session-model-sync

Conversation

@Michaelyklam
Copy link
Copy Markdown
Contributor

@Michaelyklam Michaelyklam commented May 7, 2026

Thinking Path

  • Hermes WebUI routes the next chat turn from the composer model picker.
  • Session switches already call syncTopbar() to restore per-session model metadata.
  • Missing, unknown, or stale session model metadata could leave the hidden select and visible picker on the previously viewed chat's model.
  • The safe behavior is to apply the session model when present, otherwise reset to the configured default (then first available option only as a last resort) before the user sends.

What Changed

  • Added a session-model fallback path in static/ui.js that treats missing/unknown/stale session model metadata as needing an explicit reset instead of keeping the previous selection.
  • Prefer the configured default model/provider when available, with the first available dropdown option retained only as a final fallback.
  • Refresh the visible composer model dropdown/chip when the hidden select changes, including when the picker is already open.
  • Added Node-backed frontend regression coverage for switching from an expensive model chat to a missing-model chat, unknown model metadata, and visible dropdown rerendering.
  • Updated existing stale-model source tests to expect the configured-default fallback helper.

Why It Matters

  • Fixes a surprising and potentially expensive model-routing bug: opening another chat no longer silently keeps the last chat's model in the composer.
  • Preserves explicit per-session model/provider metadata while making missing or stale metadata safe.

Fixes #1771

Verification

  • RED check on origin/master: copied the new regression test into a clean origin/master worktree and confirmed 3 failures where the select stayed on @expensive:gpt-5.5 instead of the safe default.
  • /home/michael/.hermes/hermes-agent/venv/bin/python -m pytest tests/test_issue1771_session_model_switch_sync.py -q → 3 passed.
  • /home/michael/.hermes/hermes-agent/venv/bin/python -m pytest tests/test_issue1771_session_model_switch_sync.py tests/test_provider_mismatch.py tests/test_session_metadata_fast_path.py -q → 68 passed.
  • git diff --check → passed.
  • Isolated browser QA on a temporary local server: synthetic session A used @expensive:gpt-5.5; switching to session B with missing model metadata immediately changed the visible composer model picker to GPT-4o mini before sending.
  • Full-suite attempt with config isolation: env -u HERMES_CONFIG_PATH -u HERMES_WEBUI_HOST /home/michael/.hermes/hermes-agent/venv/bin/python -m pytest tests/ -q reached 4501 passed / 4 skipped / 3 xfailed but failed after the test HTTP server on port 26676 stopped responding, causing 189 connection-refused/remote-disconnected failures across unrelated endpoint tests. No issue bug(model): switching chats does not switch the active model — silent fall-through to dropdown's last value can route messages to wrong (potentially expensive) model #1771 targeted tests failed.

Evidence / UI media

Model picker reset after switching to missing-model session

Risks / Follow-ups

  • The fallback correction is persisted back to the session when model metadata is missing or stale, matching the existing stale-model correction pattern.
  • If a live provider model catalog fetch is still pending, the existing deferral guard is preserved so the UI does not corrupt a session before live models arrive.

Model Used

  • OpenAI Codex gpt-5.5 via Hermes Agent.
  • Tool use: git/GitHub CLI, pytest, browser QA, screenshot capture.

@Michaelyklam Michaelyklam force-pushed the fix/issue-1771-session-model-sync branch from ba33778 to 6ff1ac6 Compare May 7, 2026 02:48
@Michaelyklam Michaelyklam changed the title fix: restore safe session model on chat switch fix: reset model picker on session switch May 7, 2026
nesquena-hermes added a commit that referenced this pull request May 7, 2026
pull Bot pushed a commit to soitun/hermes-webui that referenced this pull request May 7, 2026
pull Bot pushed a commit to soitun/hermes-webui that referenced this pull request May 7, 2026
…1778, nesquena#1779)

Constituent PRs:
- nesquena#1768 (@franksong2702) serialize Anthropic env fallback reads. Closes nesquena#1736.
- nesquena#1778 (@Michaelyklam) preserve CLI session tool metadata. Closes nesquena#1772.
- nesquena#1779 (@Michaelyklam) reset model picker on session switch. Closes nesquena#1771.
  AUTO-FIX: Opus stage-310 caught a regression in the new !hasSessionModel
  branch — it dropped the deferModelCorrection guard that the parallel
  else-branch keeps. Fired spurious /api/session/update POSTs against
  imported/read-only CLI sessions whose model field reads 'unknown' (the
  exact surface nesquena#1778 introduces in this same release). Wrapped the new
  branch's _persistSessionModelCorrection call + state mutation in
  if(!deferModelCorrection). Added test_sync_topbar_does_not_persist_correction_while_model_resolution_deferred
  regression test covering both empty and 'unknown' fast-path interaction.

Tests: 4694 → 4702 collected (+8). 4695 passed, 4 skipped, 3 xpassed,
0 failed in 141.29s.

Pre-release verification:
- All 3 PRs CI-green individually.
- node -c clean on static/ui.js.
- 11/11 browser API endpoints PASS.
- Pre-stamp re-fetch: all PR heads match local rebases.
- Opus advisor: SHIP nesquena#1768 + nesquena#1778, nesquena#1779 SHOULD-FIX before merge — auto-fix
  applied at stage with regression test, re-verified clean.

Closes nesquena#1736, nesquena#1771, nesquena#1772.
@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Thanks @Michaelyklam — this shipped in v0.51.16 (commit 697a7a1) as part of a 3-PR full-sweep batch. Stage rebased your branch onto current master, ran the full pre-release gate (4695 pytest, browser tests, Opus advisor verdict), and merged via release PR #1781.

A small auto-fix was applied at stage time per the Opus stage-310 SHOULD-FIX: the new !hasSessionModel branch was missing the deferModelCorrection guard that the parallel else-branch keeps. Without that guard, every fast-path session view of an empty/unknown-model session would have fired a spurious /api/session/update POST that races _resolveSessionModelForDisplaySoon — and would have silently written to imported/read-only CLI sessions whose model field reads "unknown" (the exact surface PR #1778 introduces in this same release). Wrapped the new branch's _persistSessionModelCorrection call + state mutation in if(!deferModelCorrection) mirroring the else-branch. Added test_sync_topbar_does_not_persist_correction_while_model_resolution_deferred regression test covering both empty and "unknown" fast-path interaction with _modelResolutionDeferred=true.

GitHub didn't auto-close because the merge commit only references the squash-merged stage branch, not your fork's commit directly — closing manually for hygiene.

Live now on existing installs after git pull + restart.

Release notes: https://github.com/nesquena/hermes-webui/releases/tag/v0.51.16

Du7chManiac pushed a commit to TheCouchCoder-com/hermes-webui that referenced this pull request May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants