github / github/copilot-cli

Config changes does not work over ACP

未關閉
#3,556 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area:non-interactive area:permissions
主要語言
Shell
星號
11.2k
分支
1.9k
平均合併
14 小時 16 分鐘
30 天內合併 PR
6

描述

### Describe the bug

After starting `copilot --acp`, initializing ACP, and creating a new session with session/new, calling session/set_config_option fails for permission-related config.

Example request:

{
"jsonrpc": "2.0",
"id": 3,
"method": "session/set_config_option",
"params": {
"sessionId": "",
"configId": "allow_all",
"value": "on"
}
}

Response/error:

Failed to set config option 'allow_all' to 'on': Error: Permission service is unavailable for this session.

### Affected version

1.0.54

### Steps to reproduce the behavior

Script to reproduce it:

```
#!/usr/bin/env bash
set -euo pipefail

# Minimal Copilot ACP repro:
# 1. start copilot --acp
# 2. initialize
# 3. create a session
# 4. try to set allow_all=on
#
# Expected failure:
# Failed to set config option 'allow_all' to 'on': Error: Permission service is unavailable for this session.

node <<'NODE'
const { spawn } = require("node:child_process");

const child = spawn(process.env.COPILOT_ACP_COMMAND || "copilot --acp", {
shell: true,
stdio: ["pipe", "pipe", "pipe"],
});

let nextId = 1;
let buffer = "";
const pending = new Map();

child.stderr.on("data", (chunk) => process.stderr.write(chunk));
child.stdout.on("data", (chunk) => {
buffer += chunk.toString();
const lines = buffer.split(/\r?\n/);
buffer = lines.pop() || "";
for (const line of lines) {
if (line.trim() !== "") handleLine(line);
}
});

child.on("exit", (code, signal) => {
for (const { reject } of pending.values()) {
reject(new Error(`copilot exited: code=${code} signal=${signal}`));
}
});

function request(method, params) {
const id = nextId++;
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}\n`);

return new Promise((resolve, reject) => {
pending.set(id, { resolve, reject });
setTimeout(() => reject(new Error(`timeout waiting for ${method}`)), 60000);
});
}

function handleLine(line) {
const message = JSON.parse(line);

if (message.id !== undefined && message.method) {
// This repro does not implement client-side ACP methods.
child.stdin.write(`${JSON.stringify({
jsonrpc: "2.0",
id: message.id,
error: { code: -32601, message: `not implemented: ${message.method}` },
})}\n`);
return;
}

if (message.id === undefined) return;

const waiter = pending.get(message.id);
if (!waiter) return;
pending.delete(message.id);

if (message.error) {
waiter.reject(new Error(message.error.message || JSON.stringify(message.error)));
} else {
waiter.resolve(message.result);
}
}

(async function main() {
await request("initialize", {
protocolVersion: 1,
clientCapabilities: {
fs: { readTextFile: false, writeTextFile: false },
},
});

const session = await request("session/new", {
cwd: process.cwd(),
mcpServers: [],
});

console.log(`sessionId=${session.sessionId}`);
console.log("setting allow_all=on...");

try {
await request("session/set_config_option", {
sessionId: session.sessionId,
configId: "allow_all",
value: "on",
});
console.log("unexpected success");
process.exitCode = 1;
} catch (error) {
console.error(String(error.message || error));
process.exitCode = error.message.includes("Permission service is unavailable")
? 0
: 1;
} finally {
child.kill("SIGTERM");
}
})();
NODE
```

### Expected behavior

It should allow mode to be changed.

### Additional context

This is a separate but related issue with #2942. #2942 is about the model not being able to leave plan mode. This one applies to all configs in general. Thanks!!!

貢獻指南

開啟貢獻指南

研究方向

Start by running the provided Node.js reproduction against `copilot --acp`, then trace the `session/new` and `session/set_config_option` entry points and how the permission service is initialized for ACP sessions. Done means changing `allow_all` to `on` succeeds without the permission-service-unavailable error, while the existing configuration behavior remains intact.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript, node.js, shell
領域
api, cli
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。