fix(vscode): restore permission auto-accept replies

Route live VS Code permission requests directly to directory-scoped permission replies instead of blocking on the refresh-only state preflight.

When auto-accept is enabled after prompts are already visible, reply to the authoritative local requests first, then reconcile and deduplicate the server pending list. Keep state verification for reconnect and refresh flows so stale resolved requests are not resurrected.

Add regression coverage for live events, existing prompts, directory routing, retry behavior, stale reconciliation, and network failures.
This commit is contained in:
Bohdan Triapitsyn
2026-08-01 03:14:59 +03:00
parent 4f63dbf96c
commit f1e8e03c31
7 changed files with 161 additions and 25 deletions
+5 -4
View File
@@ -1183,12 +1183,13 @@ class OpencodeService {
async fetchPermission(
sessionID: string,
requestID: string,
directory?: string,
): Promise<FetchPermissionResult> {
try {
// The V2 path is session-scoped and does not require a `directory`
// parameter. The client-scoped directory (set via setDirectory) is
// honored by the underlying SDK client when the call is routed.
const response = await this.client.v2.session.permission.get({
// The V2 endpoint does not accept a directory parameter. Callers that
// reconcile a known project must therefore select its scoped SDK client.
const client = directory ? this.getScopedSdkClient(directory) : this.client;
const response = await client.v2.session.permission.get({
sessionID,
requestID,
});