Repository navigation
fix(web): Cursor threads keep a stored model the catalog doesn't list #24872
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
Merged
juliusmarminge
merged 11 commits into
pingdotgg:main
from
only21mil:fix/i16526-composer-shows-cursor-auto-for-a-thread
Nov 12, 2026
+239
−7
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a39a262
fix(web): Cursor threads keep a stored model the catalog does not list
only21mil d76690b
fix(web): re-picking a Cursor thread's unavailable model keeps it
only21mil d6b446e
fix(web): re-picking a Cursor thread's unavailable model keeps its op…
only21mil 5273207
test(web): wait for the draft store in the composer selection browser…
only21mil db66b19
test(web): assert the composer's effective model and options after th…
only21mil db1b23f
Merge upstream main into fix/i16526-composer-shows-cursor-auto-for-a-…
only21mil 61fb130
fix(web): re-picking a model whose save failed saves it again
only21mil e24345a
test(web): drop the plan mode input main removed from the Cursor send…
only21mil 18a772d
Merge branch 'main' into fix/i16526-composer-shows-cursor-auto-for-a-…
only21mil b193bc2
Merge remote-tracking branch 'origin/main' into fix/i16526-composer-s…
juliusmarminge dbd1682
test(web): reset the model-save mock in every composer selection test
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
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
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
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
177 changes: 177 additions & 0 deletions
177
apps/web/src/components/chat/useComposerSelection.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,177 @@ | ||
| import { scopeThreadRef } from "@t3tools/client-runtime/environment"; | ||
| import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime"; | ||
| import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell"; | ||
| import { | ||
| EnvironmentId, | ||
| ProviderDriverKind, | ||
| ProviderInstanceId, | ||
| ThreadId, | ||
| type ServerProvider, | ||
| } from "@t3tools/contracts"; | ||
| import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings"; | ||
| import { createModelSelection } from "@t3tools/shared/model"; | ||
| import * as Cause from "effect/Cause"; | ||
| import { AsyncResult, Atom } from "effect/reactivity"; | ||
| import { expect, it, vi } from "vite-plus/test"; | ||
| import { page } from "vite-plus/test/browser"; | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| setModelSelection: null as ((value: unknown) => Promise<AtomCommandResult<void, unknown>>) | null, | ||
| })); | ||
|
|
||
| vi.mock(import("../../state/use-orchestration-command"), async (importOriginal) => ({ | ||
| ...(await importOriginal()), | ||
| useOrchestrationCommand: (() => (value: unknown) => mocks.setModelSelection?.(value)) as never, | ||
| })); | ||
|
|
||
| vi.mock(import("../../state/threads"), async (original) => { | ||
| const actual = await original(); | ||
| return { | ||
| ...actual, | ||
| environmentThreadShells: { | ||
| ...actual.environmentThreadShells, | ||
| threadShellAtom: ((ref: { threadId: string }) => shellAtom(ref.threadId)) as never, | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| import { render } from "../../../test/render"; | ||
| import { deriveEffectiveComposerModelState, useComposerDraftStore } from "../../composerDraftStore"; | ||
| import { AppAtomRegistryProvider, appAtomRegistry } from "../../rpc/atomRegistry"; | ||
| import { useComposerSelection } from "./useComposerSelection"; | ||
|
|
||
| // Kept alive so a shell set before the hook mounts is still there when it saves a pick. | ||
| const shellAtom = Atom.family((_threadId: string) => Atom.make<unknown>(null).pipe(Atom.keepAlive)); | ||
|
|
||
| function setup() { | ||
| const setModelSelection = vi.fn<(value: unknown) => Promise<AtomCommandResult<void, unknown>>>(); | ||
| mocks.setModelSelection = setModelSelection; | ||
| return { setModelSelection }; | ||
| } | ||
|
|
||
| const environmentId = EnvironmentId.make("environment-local"); | ||
| const cursor = ProviderInstanceId.make("cursor"); | ||
| const stored = createModelSelection(cursor, "claude-opus-5-5", [{ id: "effort", value: "medium" }]); | ||
|
|
||
| const providers: ReadonlyArray<ServerProvider> = [ | ||
| { | ||
| instanceId: cursor, | ||
| driver: ProviderDriverKind.make("cursor"), | ||
| enabled: true, | ||
| installed: true, | ||
| version: null, | ||
| status: "ready", | ||
| auth: { status: "authenticated" }, | ||
| checkedAt: "2026-01-01T00:00:00.000Z", | ||
| models: [{ slug: "auto-smart", name: "Auto", isCustom: false, capabilities: {} }], | ||
| slashCommands: [], | ||
| skills: [], | ||
| }, | ||
| ]; | ||
|
|
||
| // The hook reads only the thread's identity and stored selection. | ||
| function cursorThread(id: string) { | ||
| return { environmentId, id: ThreadId.make(id), modelSelection: stored } as EnvironmentThreadShell; | ||
| } | ||
|
|
||
| function Picker(props: { | ||
| thread: EnvironmentThreadShell; | ||
| runtime: Parameters<typeof useComposerSelection>[0]["activeRuntime"]; | ||
| model?: string; | ||
| }) { | ||
| const { onProviderModelSelectStable } = useComposerSelection({ | ||
| environmentId, | ||
| composerDraftTarget: scopeThreadRef(environmentId, props.thread.id), | ||
| draftThread: null, | ||
| activeThread: props.thread, | ||
| activeRuntime: props.runtime, | ||
| activeProjectSettings: { settings: { newWorktreesStartFromOrigin: false } }, | ||
| settings: DEFAULT_UNIFIED_SETTINGS, | ||
| providerStatuses: providers, | ||
| lockedProvider: null, | ||
| supportsProviderSwitchingViaHandoff: true, | ||
| multipleModelSelections: null, | ||
| runtimeMode: "full-access", | ||
| isLocalDraftThread: false, | ||
| canOverrideServerThreadEnvMode: false, | ||
| setPendingServerThreadEnvModeEntry: () => {}, | ||
| setPendingServerThreadStartFromOriginByThreadId: () => {}, | ||
| scheduleComposerFocus: () => {}, | ||
| }); | ||
| return ( | ||
| <button | ||
| type="button" | ||
| onClick={() => onProviderModelSelectStable(cursor, props.model ?? stored.model)} | ||
| > | ||
| Pick the model | ||
| </button> | ||
| ); | ||
| } | ||
|
|
||
| it("keeps a Cursor thread's stored model and options when the user re-picks its unavailable row", async () => { | ||
| setup(); | ||
| const thread = cursorThread("thread-cursor"); | ||
| await using _screen = await render(<Picker thread={thread} runtime={null} />); | ||
| await page.getByRole("button", { name: "Pick the model" }).click(); | ||
|
|
||
| await vi.waitFor(() => { | ||
| const draft = useComposerDraftStore | ||
| .getState() | ||
| .getComposerDraft(scopeThreadRef(environmentId, thread.id)); | ||
| expect(draft?.modelSelectionByProvider[cursor] ?? thread.modelSelection).toEqual(stored); | ||
| }); | ||
| }); | ||
|
|
||
| it("switches back to the thread's stored model while the session runs on another instance", async () => { | ||
| setup(); | ||
| const thread = cursorThread("thread-cursor-handoff"); | ||
| const runtime = { providerInstanceId: ProviderInstanceId.make("codex") } as Parameters< | ||
| typeof useComposerSelection | ||
| >[0]["activeRuntime"]; | ||
| await using _screen = await render(<Picker thread={thread} runtime={runtime} />); | ||
| await page.getByRole("button", { name: "Pick the model" }).click(); | ||
|
|
||
| await vi.waitFor(() => { | ||
| const draft = useComposerDraftStore | ||
| .getState() | ||
| .getComposerDraft(scopeThreadRef(environmentId, thread.id)); | ||
| expect(draft?.activeProvider).toBe(cursor); | ||
| expect( | ||
| deriveEffectiveComposerModelState({ | ||
| draft, | ||
| providers, | ||
| selectedProvider: ProviderDriverKind.make("cursor"), | ||
| selectedInstanceId: cursor, | ||
| threadModelSelection: thread.modelSelection, | ||
| projectModelSelection: null, | ||
| settings: DEFAULT_UNIFIED_SETTINGS, | ||
| }), | ||
| ).toEqual({ selectedModel: stored.model, modelOptions: { [cursor]: stored.options } }); | ||
| }); | ||
| }); | ||
|
|
||
| it("saves a re-picked model again when its first save failed", async () => { | ||
| const { setModelSelection } = setup(); | ||
| setModelSelection | ||
| .mockResolvedValueOnce(AsyncResult.failure(Cause.fail(new Error("offline")))) | ||
| .mockResolvedValue(AsyncResult.success(undefined)); | ||
| const thread = cursorThread("thread-cursor-retry"); | ||
| appAtomRegistry.set(shellAtom(thread.id), thread); | ||
| await using _screen = await render( | ||
| <AppAtomRegistryProvider> | ||
| <Picker thread={thread} runtime={null} model="auto-smart" /> | ||
| </AppAtomRegistryProvider>, | ||
| ); | ||
| const pick = page.getByRole("button", { name: "Pick the model" }); | ||
| await pick.click(); | ||
| await vi.waitFor(() => expect(setModelSelection).toHaveBeenCalledTimes(1)); | ||
| await pick.click(); | ||
|
|
||
| const autoSave = expect.objectContaining({ | ||
| input: { | ||
| threadId: thread.id, | ||
| modelSelection: expect.objectContaining({ instanceId: cursor, model: "auto-smart" }), | ||
| }, | ||
| }); | ||
| await vi.waitFor(() => expect(setModelSelection.mock.calls).toEqual([[autoSave], [autoSave]])); | ||
| }); |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.