This commit is contained in:
Julius Marminge committed 2026-04-17 16:43:47 -07:00
1 parent 8c5fc4e690
commit 74a6a32df7
7 files changed
+22 -343

No files matched your search

@@ -24,14 +24,15 @@ function decodeProviderKind(
providerName: string,
operation: string,
): Effect.Effect<ProviderKind, ProviderSessionDirectoryPersistenceError> {
if (providerName === "codex" || providerName === "claudeAgent" || providerName === "cursor") {
return Effect.succeed(providerName);
}
return Effect.fail(
new ProviderSessionDirectoryPersistenceError({
operation,
detail: `Unknown persisted provider '${providerName}'.`,
}),
return Schema.decodeUnknownEffect(ProviderKind)(providerName).pipe(
Effect.mapError(
(cause) =>
new ProviderSessionDirectoryPersistenceError({
operation,
detail: `Unknown persisted provider '${providerName}'.`,
cause,
}),
),
);
}
+1 -1
View File
@@ -94,7 +94,7 @@ const jsonRpcWireToInbound = SchemaTransformation.transformOrFail({
return Effect.fail(
new SchemaIssue.InvalidValue(Option.some(parsed), {
title: "Unrecognized JSON-RPC inbound message shape",
message: "Unrecognized JSON-RPC inbound message shape",
}),
);
},
-3
View File
@@ -1,3 +0,0 @@
export * from "./AcpErrors.ts";
export * from "./AcpTypes.ts";
export * from "./AcpJsonRpcConnection.ts";
@@ -113,26 +113,7 @@ async function mountMenu(props?: { modelSelection?: ModelSelection; prompt?: str
},
},
]
: provider === "cursor"
? [
{
slug: "gpt-5.3-codex",
name: "Codex 5.3",
isCustom: false,
capabilities: {
reasoningEffortLevels: [
{ value: "low", label: "Low" },
{ value: "medium", label: "Medium", isDefault: true },
{ value: "high", label: "High" },
{ value: "xhigh", label: "Extra high" },
],
supportsFastMode: true,
supportsThinkingToggle: false,
promptInjectedEffortLevels: [],
},
},
]
: [];
: [];
const screen = await render(
<CompactComposerControlsMenu
activePlan={false}
@@ -244,24 +225,6 @@ describe("CompactComposerControlsMenu", () => {
});
});
it("shows Cursor reasoning controls for GPT-5.3 Codex family", async () => {
const mounted = await mountMenu({
modelSelection: { provider: "cursor", model: "gpt-5.3-codex" },
});
try {
await page.getByLabelText("More composer controls").click();
await vi.waitFor(() => {
const text = document.body.textContent ?? "";
expect(text).toContain("Reasoning");
expect(text).toContain("Fast mode");
});
} finally {
await mounted.cleanup();
}
});
it("shows prompt-controlled Ultrathink messaging with disabled effort controls", async () => {
await using _ = await mountMenu({
modelSelection: {
@@ -112,58 +112,6 @@ const TEST_PROVIDERS: ReadonlyArray<ServerProvider> = [
},
],
},
{
provider: "cursor",
enabled: true,
installed: true,
version: "1.0.0",
status: "ready",
authStatus: "authenticated",
checkedAt: new Date().toISOString(),
models: [
{
slug: "composer-2",
name: "Composer 2",
isCustom: false,
capabilities: {
reasoningEffortLevels: [],
supportsFastMode: true,
supportsThinkingToggle: false,
contextWindowOptions: [],
promptInjectedEffortLevels: [],
},
},
{
slug: "gpt-5.3-codex",
name: "Codex 5.3",
isCustom: false,
capabilities: {
reasoningEffortLevels: [
effort("low"),
effort("medium", true),
effort("high"),
effort("xhigh"),
],
supportsFastMode: true,
supportsThinkingToggle: false,
contextWindowOptions: [],
promptInjectedEffortLevels: [],
},
},
{
slug: "claude-opus-4-6",
name: "Claude Opus 4.6",
isCustom: false,
capabilities: {
reasoningEffortLevels: [],
supportsFastMode: false,
supportsThinkingToggle: true,
contextWindowOptions: [],
promptInjectedEffortLevels: [],
},
},
],
},
];
function buildCodexProvider(models: ServerProvider["models"]): ServerProvider {
@@ -192,14 +140,12 @@ async function mountPicker(props: {
document.body.append(host);
const onProviderModelChange = vi.fn();
const providers = props.providers ?? TEST_PROVIDERS;
const modelOptionsByProvider = {
...getCustomModelOptionsByProvider(
DEFAULT_UNIFIED_SETTINGS,
providers,
props.provider,
props.model,
),
};
const modelOptionsByProvider = getCustomModelOptionsByProvider(
DEFAULT_UNIFIED_SETTINGS,
providers,
props.provider,
props.model,
);
const screen = await render(
<ProviderModelPicker
provider={props.provider}
@@ -314,23 +260,6 @@ describe("ProviderModelPicker", () => {
}
});
it("uses canonical Cursor slugs from the server-provided model options", async () => {
const mounted = await mountPicker({
provider: "cursor",
model: "claude-opus-4-6",
lockedProvider: "cursor",
});
try {
await page.getByRole("button").click();
await page.getByRole("menuitemradio", { name: "Codex 5.3" }).click();
expect(mounted.onProviderModelChange).toHaveBeenCalledWith("cursor", "gpt-5.3-codex");
} finally {
await mounted.cleanup();
}
});
it("dispatches the canonical slug when a model is selected", async () => {
const mounted = await mountPicker({
provider: "claudeAgent",
@@ -4,7 +4,6 @@ import {
type ModelSelection,
ClaudeModelOptions,
CodexModelOptions,
CursorModelOptions,
DEFAULT_MODEL_BY_PROVIDER,
DEFAULT_SERVER_SETTINGS,
OpenCodeModelOptions,
@@ -627,212 +626,3 @@ describe("TraitsPicker (Codex)", () => {
});
});
});
// ── Cursor TraitsPicker tests ─────────────────────────────────────────
async function mountCursorPicker(props?: {
model?: string;
options?: CursorModelOptions;
models?: ServerProvider["models"];
}) {
const threadId = ThreadId.makeUnsafe("thread-cursor-traits");
const model = props?.model ?? "gpt-5.4";
const cursorProvider = {
provider: "cursor",
enabled: true,
installed: true,
version: "0.1.0",
status: "ready",
authStatus: "authenticated",
checkedAt: "2026-01-01T00:00:00.000Z",
models: props?.models ?? [
{
slug: "gpt-5.4",
name: "GPT-5.4",
isCustom: false,
capabilities: {
reasoningEffortLevels: [
{ value: "low", label: "Low" },
{ value: "medium", label: "Medium", isDefault: true },
{ value: "high", label: "High" },
{ value: "xhigh", label: "Extra High" },
],
supportsFastMode: true,
supportsThinkingToggle: false,
contextWindowOptions: [
{ value: "272k", label: "272k", isDefault: true },
{ value: "1m", label: "1M" },
],
promptInjectedEffortLevels: [],
},
},
],
} satisfies ServerProvider;
const draftsByThreadId: Record<ThreadId, ComposerThreadDraftState> = {
[threadId]: {
prompt: "",
images: [],
nonPersistedImageIds: [],
persistedAttachments: [],
terminalContexts: [],
modelSelectionByProvider: {
cursor: {
provider: "cursor",
model,
...(props?.options ? { options: props.options } : {}),
},
},
activeProvider: "cursor",
runtimeMode: null,
interactionMode: null,
},
};
useComposerDraftStore.setState({
draftsByThreadId,
draftThreadsByThreadId: {},
projectDraftThreadIdByProjectId: {
[ProjectId.makeUnsafe("project-cursor-traits")]: threadId,
},
});
const host = document.createElement("div");
document.body.append(host);
const screen = await render(
<TraitsPicker
provider="cursor"
models={cursorProvider.models}
threadId={threadId}
model={model}
prompt=""
modelOptions={props?.options}
onPromptChange={() => {}}
/>,
{ container: host },
);
const cleanup = async () => {
await screen.unmount();
host.remove();
};
return {
[Symbol.asyncDispose]: cleanup,
cleanup,
};
}
describe("TraitsPicker (Cursor)", () => {
afterEach(() => {
document.body.innerHTML = "";
localStorage.removeItem(COMPOSER_DRAFT_STORAGE_KEY);
useComposerDraftStore.setState({
draftsByThreadId: {},
draftThreadsByThreadId: {},
projectDraftThreadIdByProjectId: {},
stickyModelSelectionByProvider: {},
});
});
it("shows the selected Cursor context window in the trigger label", async () => {
await using _ = await mountCursorPicker({
options: { contextWindow: "1m" },
});
await vi.waitFor(() => {
expect(document.body.textContent ?? "").toContain("Medium · 1M");
});
});
it("persists Cursor context window changes", async () => {
await using _ = await mountCursorPicker();
await page.getByRole("button").click();
await page.getByRole("menuitemradio", { name: "1M" }).click();
expect(useComposerDraftStore.getState().stickyModelSelectionByProvider.cursor).toMatchObject({
provider: "cursor",
model: "gpt-5.4",
options: {
contextWindow: "1m",
},
});
});
it("does not render for models with no trait capabilities", async () => {
await using _ = await mountCursorPicker({
model: "default",
models: [
{
slug: "default",
name: "Auto",
isCustom: false,
capabilities: {
reasoningEffortLevels: [],
supportsFastMode: false,
supportsThinkingToggle: false,
contextWindowOptions: [],
promptInjectedEffortLevels: [],
},
},
],
});
expect(document.querySelector("button")).toBeNull();
});
it("renders for fast-only Cursor models with a usable label", async () => {
await using _ = await mountCursorPicker({
model: "composer-2",
models: [
{
slug: "composer-2",
name: "Composer 2",
isCustom: false,
capabilities: {
reasoningEffortLevels: [],
supportsFastMode: true,
supportsThinkingToggle: false,
contextWindowOptions: [],
promptInjectedEffortLevels: [],
},
},
],
});
await vi.waitFor(() => {
expect(document.body.textContent ?? "").toContain("Normal");
});
});
it("persists fast-mode changes for fast-only Cursor models", async () => {
await using _ = await mountCursorPicker({
model: "composer-2",
models: [
{
slug: "composer-2",
name: "Composer 2",
isCustom: false,
capabilities: {
reasoningEffortLevels: [],
supportsFastMode: true,
supportsThinkingToggle: false,
contextWindowOptions: [],
promptInjectedEffortLevels: [],
},
},
],
});
await page.getByRole("button").click();
await page.getByRole("menuitemradio", { name: "on" }).click();
expect(useComposerDraftStore.getState().stickyModelSelectionByProvider.cursor).toMatchObject({
provider: "cursor",
model: "composer-2",
options: {
fastMode: true,
},
});
});
});
@@ -123,12 +123,11 @@ function getProviderStateFromCapabilities(
: null;
// Normalize options for dispatch
const normalizedOptions =
provider === "codex"
? normalizeCodexModelOptionsWithCapabilities(caps, providerOptions)
: provider === "cursor"
? normalizeCursorModelOptionsWithCapabilities(caps, providerOptions)
: normalizeClaudeModelOptionsWithCapabilities(caps, providerOptions);
const normalizedOptions = {
codex: normalizeCodexModelOptionsWithCapabilities(caps, providerOptions),
cursor: normalizeCursorModelOptionsWithCapabilities(caps, providerOptions),
claudeAgent: normalizeClaudeModelOptionsWithCapabilities(caps, providerOptions),
}[provider];
// Ultrathink styling (driven by capabilities data, not provider identity)
const ultrathinkActive =