Skip to content

fix(renderer): Settings active card no longer misrepresents model when not in fetched list (#136)#166

Merged
hqhq1025 merged 1 commit intomainfrom
worktree-agent-a3271760
Apr 23, 2026
Merged

fix(renderer): Settings active card no longer misrepresents model when not in fetched list (#136)#166
hqhq1025 merged 1 commit intomainfrom
worktree-agent-a3271760

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Summary

Fixes #136. Related: #124, #134.

The active-provider card in Settings was displaying the wrong model whenever config.modelPrimary was not in the list returned by the provider's /models endpoint. The native <select value={config.modelPrimary}> silently fell back to rendering options[0] — so the card visually claimed the active model was, say, claude-3-5-haiku-20241022, while:

  • the top-bar ModelSwitcher correctly read config.modelPrimary (e.g. opus-4-7)
  • the main process snapped requests to the canonical cfg.activeModel (also opus-4-7)

Pure UI inconsistency, but seriously misleading when debugging 4xx failures ("I thought I was using opus-4-7 but the card says haiku — am I?"), which is exactly the debugging loop #124/#134 are stuck in.

Fix

RowModelSelector now injects the active model id at the top of the options list with an (active, not in provider list) hint whenever it's missing from the fetched list. The dropdown always matches reality, and users can spot at a glance that their configured model is not one the provider's /models returned — a useful diagnostic signal.

Extracted the option-building logic into a pure computeModelOptions helper and covered it with deterministic unit tests (loading / empty / active-in-list / active-not-in-list / inactive-row).

Files

  • apps/desktop/src/renderer/src/components/Settings.tsx — inject pinned active option, exported helper
  • apps/desktop/src/renderer/src/components/Settings.test.ts — 5 new tests for computeModelOptions
  • packages/i18n/src/locales/{en,zh-CN}.json — new settings.providers.activeNotInList key

PRINCIPLES §5b

  • Compatibility: green — pure UI fix, no schema / IPC / storage changes
  • Upgradeability: green — no new abstractions, helper is trivially inlinable later
  • No bloat: green — net +41 lines in Settings.tsx, +1 i18n key per locale
  • Elegance: green — helper is pure and framework-free; dropdown tells the truth regardless of what the provider returns

Test plan

  • pnpm --filter @open-codesign/desktop vitest: 875/875 pass (includes 5 new)
  • pnpm typecheck: 10/10 pass
  • pnpm lint (biome): clean
  • Manual: activate a custom OpenAI-compatible provider whose /models hides your configured model id; open Settings; confirm the card's <select> shows the active id with the hint, top-bar and card agree
  • Manual: repro bug(desktop): top bar active model can disagree with Settings current provider model #136's original case (Anthropic + opus-4-7 with a list that only returns haiku/sonnet) and verify card no longer lies

@github-actions github-actions Bot added docs Documentation area:desktop apps/desktop (Electron shell, renderer) labels Apr 22, 2026
…n not in fetched list (#136)

When the provider /models endpoint returns a list that does not contain
the currently-active model id, the native <select> silently fell back to
rendering options[0] and the card claimed that was the active model.
The top-bar ModelSwitcher and the actual request kept using the real
config.modelPrimary, so this was a pure UI lie but it seriously misled
users debugging 4xx failures (related: #124, #134).

Pin the active model id at the top of the dropdown with an
`(active, not in provider list)` hint whenever it is missing from the
fetched list. The select now always reflects reality and surfaces the
"your configured model isn't one the provider advertised" signal.

Extracted the option-building logic as `computeModelOptions` for
deterministic unit coverage.

Signed-off-by: hqhq1025 <1506751656@qq.com>
@hqhq1025 hqhq1025 force-pushed the worktree-agent-a3271760 branch from 5aefb3a to 0a67959 Compare April 22, 2026 14:24
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • None.

Summary

  • Review mode: initial
  • No issues found on added/modified lines in this diff.
  • Residual risk/testing gap: coverage added for computeModelOptions pure logic, but no UI-level interaction test confirms the Settings <select> renders the pinned active option in the DOM when the fetched model list excludes the active model.

Testing

  • Not run (automation)

open-codesign Bot

@hqhq1025 hqhq1025 merged commit 5d22e60 into main Apr 23, 2026
7 checks passed
@hqhq1025 hqhq1025 deleted the worktree-agent-a3271760 branch April 23, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:desktop apps/desktop (Electron shell, renderer) docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(desktop): top bar active model can disagree with Settings current provider model

1 participant