Repository navigation
fix(web): default model row shows Mixed when environments resolve the automatic default differently #28017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
fix(web): default model row shows Mixed when environments resolve the automatic default differently #28017
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f98ccd5
test(web): reproduce automatic default model not shown as mixed (#27997)
juliusmarminge 87f51cd
fix(web): automatic default model shows as mixed when environments re…
juliusmarminge cf6f636
fix(web): compare effective default models when deciding the row is m…
juliusmarminge 6f90719
fix(web): resolve each environment's default against client settings …
juliusmarminge d31f3a1
Merge origin/main into fix/issue-27997
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
183 changes: 183 additions & 0 deletions
183
apps/web/src/components/settings/ProjectDefaultsSettings.browser.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| import { RegistryContext } from "@effect/atom-react"; | ||
| import { | ||
| DEFAULT_SERVER_SETTINGS, | ||
| EnvironmentId, | ||
| ProviderDriverKind, | ||
| ProviderInstanceId, | ||
| type ServerProvider, | ||
| } from "@t3tools/contracts"; | ||
| import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings"; | ||
| import { describe, expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| import { render } from "../../../test/render"; | ||
|
|
||
| vi.mock(import("~/state/environments"), async (original) => ({ | ||
| ...(await original()), | ||
| useEnvironments: (() => ({ environments: fixture.environments })) as never, | ||
| useEnvironmentProviders: () => fixture.providersByEnvironment, | ||
| usePrimaryEnvironmentId: () => primaryId, | ||
| })); | ||
| // Every environment grants settings writes, so the row's controls are live. | ||
| vi.mock(import("~/state/session"), async (original) => ({ | ||
| ...(await original()), | ||
| useEnvironmentScope: () => true, | ||
| useEnvironmentsWithScope: (environments) => | ||
| new Set(environments.map(({ environmentId }) => environmentId)), | ||
| })); | ||
| vi.mock(import("~/state/entities"), async (original) => ({ | ||
| ...(await original()), | ||
| useProjects: () => [], | ||
| useThreadShells: () => [], | ||
| })); | ||
|
|
||
| import { appAtomRegistry } from "../../rpc/atomRegistry"; | ||
| import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings"; | ||
| import { SettingsScopeProvider } from "./SettingsScopeContext"; | ||
|
|
||
| const primaryId = EnvironmentId.make("primary"); | ||
| const remoteId = EnvironmentId.make("remote"); | ||
|
|
||
| function provider(driver: string, enabled: boolean, slugs: readonly string[]): ServerProvider { | ||
| return { | ||
| instanceId: ProviderInstanceId.make(driver), | ||
| driver: ProviderDriverKind.make(driver), | ||
| enabled, | ||
| installed: true, | ||
| version: null, | ||
| status: "ready", | ||
| auth: { status: "authenticated" }, | ||
| checkedAt: "2026-01-01T00:00:00.000Z", | ||
| models: slugs.map((slug, index) => ({ | ||
| slug, | ||
| name: slug, | ||
| isCustom: false, | ||
| isDefault: index === 0, | ||
| capabilities: { | ||
| optionDescriptors: [ | ||
| { | ||
| id: "effort", | ||
| label: "Effort", | ||
| type: "select", | ||
| options: [ | ||
| { id: "medium", label: "Medium", isDefault: true }, | ||
| { id: "high", label: "High" }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| })), | ||
| slashCommands: [], | ||
| skills: [], | ||
| }; | ||
| } | ||
|
|
||
| interface EnvironmentFixture { | ||
| readonly providers: readonly ServerProvider[]; | ||
| readonly hiddenClaudeModels?: readonly string[]; | ||
| } | ||
|
|
||
| const fixture = { | ||
| environments: [] as unknown[], | ||
| providersByEnvironment: new Map<EnvironmentId, readonly ServerProvider[]>(), | ||
| }; | ||
|
|
||
| // Both environments choose their default model automatically. | ||
| function setup(primary: EnvironmentFixture, remote: EnvironmentFixture) { | ||
| const byId = new Map([ | ||
| [primaryId, primary], | ||
| [remoteId, remote], | ||
| ]); | ||
| fixture.environments = [...byId].map(([environmentId, { hiddenClaudeModels }]) => ({ | ||
| environmentId, | ||
| label: environmentId, | ||
| connection: { phase: "connected" }, | ||
| serverConfig: { | ||
| keybindings: DEFAULT_RESOLVED_KEYBINDINGS, | ||
| settings: { | ||
| ...DEFAULT_SERVER_SETTINGS, | ||
| defaultModelSelection: null, | ||
| providerModelPreferences: hiddenClaudeModels | ||
| ? { claudeAgent: { hiddenModels: [...hiddenClaudeModels], modelOrder: [] } } | ||
| : null, | ||
| }, | ||
| environment: { platform: { machine: "server" } }, | ||
| }, | ||
| })); | ||
| fixture.providersByEnvironment = new Map( | ||
| [...byId].map(([environmentId, { providers }]) => [environmentId, providers]), | ||
| ); | ||
| } | ||
|
|
||
| async function renderModelRow() { | ||
| await using stack = new AsyncDisposableStack(); | ||
| const screen = stack.use( | ||
| await render( | ||
| <RegistryContext.Provider value={appAtomRegistry}> | ||
| <SettingsScopeProvider search={{}} onChange={() => {}}> | ||
| <ProjectDefaultsSettings category="general" /> | ||
| </SettingsScopeProvider> | ||
| </RegistryContext.Provider>, | ||
| ), | ||
| ); | ||
| await expect.element(screen.getByRole("heading", { name: "Model" })).toBeVisible(); | ||
| stack.move(); | ||
| return screen; | ||
| } | ||
|
|
||
| describe("ProjectDefaultsSettings", () => { | ||
| it("shows the automatic default model as mixed when environments resolve it differently", async () => { | ||
| // Primary alone resolves to Codex at Medium effort; remote can only resolve to Claude. | ||
| setup( | ||
| { providers: [provider("codex", true, ["gpt-6"]), provider("claudeAgent", true, ["opus"])] }, | ||
| { providers: [provider("codex", false, ["gpt-6"]), provider("claudeAgent", true, ["opus"])] }, | ||
| ); | ||
| await using screen = await renderModelRow(); | ||
|
|
||
| expect( | ||
| screen.getByRole("button", { name: "Mixed" }).query(), | ||
| "model picker labelled Mixed", | ||
| ).not.toBeNull(); | ||
| expect( | ||
| screen.getByRole("button", { name: "Medium" }).query(), | ||
| "effort picker for primary's model", | ||
| ).toBeNull(); | ||
| }); | ||
|
|
||
| it("keeps the shared automatic default editable when environments resolve it alike", async () => { | ||
| // Different catalogs whose defaults are hidden still land on the same visible model. | ||
| setup( | ||
| { | ||
| providers: [provider("claudeAgent", true, ["opus-old", "sonnet"])], | ||
| hiddenClaudeModels: ["opus-old"], | ||
| }, | ||
| { | ||
| providers: [provider("claudeAgent", true, ["opus-new", "sonnet"])], | ||
| hiddenClaudeModels: ["opus-new"], | ||
| }, | ||
| ); | ||
| await using screen = await renderModelRow(); | ||
|
|
||
| expect(screen.getByRole("button", { name: "Mixed" }).query(), "Mixed label").toBeNull(); | ||
| expect( | ||
| screen.getByRole("button", { name: "Medium" }).query(), | ||
| "effort picker for the shared model", | ||
| ).not.toBeNull(); | ||
| }); | ||
|
|
||
| it("resolves each environment against its own model preferences", async () => { | ||
| // Only primary hides Opus, so remote's automatic default stays Opus. | ||
| setup( | ||
| { | ||
| providers: [provider("claudeAgent", true, ["opus", "sonnet"])], | ||
| hiddenClaudeModels: ["opus"], | ||
| }, | ||
| { providers: [provider("claudeAgent", true, ["opus", "sonnet"])] }, | ||
| ); | ||
| await using screen = await renderModelRow(); | ||
|
|
||
| expect( | ||
| screen.getByRole("button", { name: "Mixed" }).query(), | ||
| "model picker labelled Mixed", | ||
| ).not.toBeNull(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
sed -n '45,205p' apps/web/src/components/settings/ProjectDefaultsSettings.tsx cat apps/web/src/components/settings/useScopedModelAvailability.tsRepository: pingdotgg/t3code
Length of output: 8957
Use the all-target availability guard in
mixedModel.resolvedDefaultscompares onlyinstanceIdandmodel, so it can treat selections with different drivers as equal. The same selection can then remain editable whileuseScopedModelDisabledReasonrejects it. That guard also detects disabled, unavailable, or missing model options.Include the guard result for the representative
selection. It skips targets whose providers have not loaded, so those targets are not treated as mismatches.Suggested fix