fix(copilot): preserve legacy autopilot mode alias

This commit is contained in:
Mohamed Boudra
2026-05-12 17:34:09 +07:00
parent d198c68b9e
commit 985ad52cce
2 changed files with 35 additions and 1 deletions

View File

@@ -943,6 +943,36 @@ describe("ACPAgentSession Zed parity", () => {
expect(events.some((event) => event.type === "permission_requested")).toBe(false);
});
test("accepts Copilot's legacy autopilot mode ID as Allow All", async () => {
const setSessionConfigOption = vi.fn(async () => ({
configOptions: [
copilotModeConfigOption("https://agentclientprotocol.com/protocol/session-modes#agent"),
copilotAllowAllConfigOption("on"),
],
}));
const setSessionMode = vi.fn(async () => undefined);
const session = createCopilotSessionWithConfig();
prepareConfiguredOverrideSession(session, {
currentMode: "https://agentclientprotocol.com/protocol/session-modes#agent",
availableModes: COPILOT_MODES,
configOptions: [
copilotModeConfigOption("https://agentclientprotocol.com/protocol/session-modes#agent"),
copilotAllowAllConfigOption("off"),
],
connection: { setSessionConfigOption, setSessionMode },
});
await session.setMode("https://agentclientprotocol.com/protocol/session-modes#autopilot");
expect(setSessionConfigOption).toHaveBeenCalledWith({
sessionId: "session-1",
configId: "allow_all",
value: "on",
});
expect(setSessionMode).not.toHaveBeenCalled();
await expect(session.getCurrentMode()).resolves.toBe(COPILOT_ALLOW_ALL_MODE_ID);
});
test("switching Copilot away from Allow All turns allow_all off before setting the ACP mode", async () => {
const setSessionConfigOption = vi.fn(async (input: { value: string }) => ({
configOptions: [

View File

@@ -214,7 +214,11 @@ export function transformCopilotModeId(modeId: string): string | null {
export async function writeCopilotProviderMode(
context: ACPProviderModeWriterContext,
): Promise<ACPProviderModeWriteResult> {
if (context.requestedModeId !== COPILOT_ALLOW_ALL_MODE_ID) {
// COMPAT(copilotAutopilotMode): added in v0.1.75, remove after 2026-11-12 once old clients no longer send Copilot's old ACP autopilot mode ID.
const requestsAllowAll =
context.requestedModeId === COPILOT_ALLOW_ALL_MODE_ID ||
context.requestedModeId === COPILOT_AUTOPILOT_MODE_ID;
if (!requestsAllowAll) {
return { handled: false };
}
const response = await context.connection.setSessionConfigOption({