Skip to content

Commit 5a569e3

Browse files
authored
Merge pull request microsoft#286218 from microsoft/connor4312/286107
chat: fix URL approval settings merge
1 parent b095009 commit 5a569e3

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

src/vs/workbench/contrib/chat/common/tools/builtinTools/chatUrlFetchingConfirmation.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,27 @@ export class ChatUrlFetchingConfirmationContribution implements ILanguageModelTo
236236
private async _approvePattern(pattern: string, approveRequest: boolean, approveResponse: boolean): Promise<void> {
237237
const approvedUrls = { ...this._getApprovedUrls() };
238238

239+
// Merge with existing settings for this pattern
240+
const existingSettings = approvedUrls[pattern];
241+
let existingRequest = false;
242+
let existingResponse = false;
243+
if (typeof existingSettings === 'boolean') {
244+
existingRequest = existingSettings;
245+
existingResponse = existingSettings;
246+
} else if (existingSettings) {
247+
existingRequest = existingSettings.approveRequest ?? false;
248+
existingResponse = existingSettings.approveResponse ?? false;
249+
}
250+
251+
const mergedRequest = approveRequest || existingRequest;
252+
const mergedResponse = approveResponse || existingResponse;
253+
239254
// Create the approval settings
240255
let value: boolean | IUrlApprovalSettings;
241-
if (approveRequest === approveResponse) {
242-
value = approveRequest;
256+
if (mergedRequest === mergedResponse) {
257+
value = mergedRequest;
243258
} else {
244-
value = { approveRequest, approveResponse };
259+
value = { approveRequest: mergedRequest, approveResponse: mergedResponse };
245260
}
246261

247262
approvedUrls[pattern] = value;

0 commit comments

Comments
 (0)