fix(copilot): preserve legacy autopilot mode alias
This commit is contained in:
@@ -943,6 +943,36 @@ describe("ACPAgentSession Zed parity", () => {
|
|||||||
expect(events.some((event) => event.type === "permission_requested")).toBe(false);
|
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 () => {
|
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 }) => ({
|
const setSessionConfigOption = vi.fn(async (input: { value: string }) => ({
|
||||||
configOptions: [
|
configOptions: [
|
||||||
|
|||||||
@@ -214,7 +214,11 @@ export function transformCopilotModeId(modeId: string): string | null {
|
|||||||
export async function writeCopilotProviderMode(
|
export async function writeCopilotProviderMode(
|
||||||
context: ACPProviderModeWriterContext,
|
context: ACPProviderModeWriterContext,
|
||||||
): Promise<ACPProviderModeWriteResult> {
|
): 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 };
|
return { handled: false };
|
||||||
}
|
}
|
||||||
const response = await context.connection.setSessionConfigOption({
|
const response = await context.connection.setSessionConfigOption({
|
||||||
|
|||||||
Reference in New Issue
Block a user