Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/CodexAcpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
resolveFastServiceTier,
} from "./FastModeConfig";
import packageJson from "../package.json";
import {isJetBrains2026_1Client} from "./JBUtils";

export interface SessionState {
sessionId: string,
Expand Down Expand Up @@ -90,6 +91,7 @@ export class CodexAcpServer implements acp.Agent {
private readonly defaultAuthRequest: CodexAuthRequest | null;
private readonly getExitCode: () => number | null;
private readonly availableCommands: CodexCommands;
private clientInfo: acp.Implementation | null;

private readonly sessions: Map<string, SessionState>;
private readonly pendingMcpStartupSessions: Map<string, PendingMcpStartupSession>;
Expand All @@ -116,6 +118,7 @@ export class CodexAcpServer implements acp.Agent {
this.codexAcpClient = codexAcpClient;
this.defaultAuthRequest = defaultAuthRequest ?? null;
this.getExitCode = getExitCode ?? (() => null);
this.clientInfo = null;
this.availableCommands = new CodexCommands(
connection,
codexAcpClient,
Expand All @@ -127,6 +130,7 @@ export class CodexAcpServer implements acp.Agent {
_params: acp.InitializeRequest,
): Promise<acp.InitializeResponse> {
logger.log("Initialize request received");
this.clientInfo = _params.clientInfo ?? null;
await this.runWithProcessCheck(() => this.codexAcpClient.initialize(_params));
return {
protocolVersion: acp.PROTOCOL_VERSION,
Expand Down Expand Up @@ -382,7 +386,7 @@ export class CodexAcpServer implements acp.Agent {
return {
models: modelState,
modes: modeState,
configOptions: this.createSessionConfigOptions(this.getSessionState(sessionId)),
...this.createSessionConfigOptionsResponse(this.getSessionState(sessionId)),
};
}

Expand All @@ -398,7 +402,7 @@ export class CodexAcpServer implements acp.Agent {
return {
models: modelState,
modes: modeState,
configOptions: this.createSessionConfigOptions(this.getSessionState(sessionId)),
...this.createSessionConfigOptionsResponse(this.getSessionState(sessionId)),
};
}

Expand Down Expand Up @@ -458,7 +462,7 @@ export class CodexAcpServer implements acp.Agent {
sessionId: sessionId,
models: modelState,
modes: modeState,
configOptions: this.createSessionConfigOptions(this.getSessionState(sessionId)),
...this.createSessionConfigOptionsResponse(this.getSessionState(sessionId)),
};
}

Expand Down Expand Up @@ -567,6 +571,22 @@ export class CodexAcpServer implements acp.Agent {
];
}

private createSessionConfigOptionsResponse(sessionState: SessionState): {
configOptions?: Array<acp.SessionConfigOption>;
} {
if (!this.isSessionConfigEnabled()) {
return {};
}
return {
configOptions: this.createSessionConfigOptions(sessionState),
};
}

private isSessionConfigEnabled(): boolean {
// Temporarily disabled for JB IDEs 2026.1 due to issues in session_config (LLM-28118)
return !isJetBrains2026_1Client(this.clientInfo);
}

private publishAvailableCommandsAsync(sessionId: string) {
void this.availableCommands.publish(sessionId);
}
Expand Down
12 changes: 12 additions & 0 deletions src/JBUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type * as acp from "@agentclientprotocol/sdk";

export function isJetBrains2026_1Client(clientInfo: acp.Implementation | null): boolean {
if (!clientInfo) {
return false;
}

const platform = clientInfo._meta?.["platform"];
const isIntelliJPlatform = platform === "intellij";
const isJetBrainsClient = clientInfo.name.startsWith("JetBrains");
return (isIntelliJPlatform || isJetBrainsClient) && clientInfo.version.startsWith("2026.1");
}
60 changes: 59 additions & 1 deletion src/__tests__/CodexACPAgent/fast-mode-config.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {describe, expect, it, vi} from "vitest";
import * as acp from "@agentclientprotocol/sdk";
import {
createCodexMockTestFixture,
createTestModel,
Expand All @@ -13,7 +14,10 @@ import {
} from "../../FastModeConfig";

describe("Fast mode session config", () => {
async function createSession(currentServiceTier: "fast" | "flex" | null = null) {
async function createSession(
currentServiceTier: "fast" | "flex" | null = null,
clientInfo: acp.Implementation | null = null
) {
const fixture = createCodexMockTestFixture();
const codexAcpAgent = fixture.getCodexAcpAgent();
const codexAcpClient = fixture.getCodexAcpClient();
Expand All @@ -31,6 +35,11 @@ describe("Fast mode session config", () => {
currentServiceTier,
});

await codexAcpAgent.initialize({
protocolVersion: acp.PROTOCOL_VERSION,
clientInfo,
});

const response = await codexAcpAgent.newSession({cwd: "/test/cwd", mcpServers: []});
return {fixture, codexAcpAgent, codexAcpClient, response};
}
Expand Down Expand Up @@ -58,6 +67,55 @@ describe("Fast mode session config", () => {
expect(codexAcpAgent.getSessionState("session-id").fastModeEnabled).toBe(true);
});

it("omits Fast mode config options for JetBrains 2026.1 IntelliJ clients", async () => {
const {response} = await createSession(null, {
name: "JetBrains.WebStorm",
version: "2026.1.1",
title: "WebStorm 2026.1.1",
_meta: {
platform: "intellij",
},
});

expect(response.configOptions).toBeUndefined();
});

it("omits Fast mode config options for JetBrains 2026.1 clients by name", async () => {
const {response} = await createSession(null, {
name: "JetBrains.IDE",
version: "2026.1",
title: "JetBrains IDE",
});

expect(response.configOptions).toBeUndefined();
});

it("keeps Fast mode config options for JetBrains clients outside 2026.1", async () => {
const {response} = await createSession(null, {
name: "JetBrains.WebStorm",
version: "2026.2.0",
title: "WebStorm 2026.2.0",
_meta: {
platform: "intellij",
},
});

expect(response.configOptions).toEqual([createFastModeConfigOption(false)]);
});

it("keeps Fast mode config options for non-JetBrains 2026.1 clients", async () => {
const {response} = await createSession(null, {
name: "VSCode",
version: "2026.1.1",
title: "VS Code",
_meta: {
platform: "vscode",
},
});

expect(response.configOptions).toEqual([createFastModeConfigOption(false)]);
});

it("toggles Fast mode through session config options", async () => {
const {codexAcpAgent} = await createSession();

Expand Down
Loading