Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,27 @@ export class ChatUrlFetchingConfirmationContribution implements ILanguageModelTo
private async _approvePattern(pattern: string, approveRequest: boolean, approveResponse: boolean): Promise<void> {
const approvedUrls = { ...this._getApprovedUrls() };

// Merge with existing settings for this pattern
const existingSettings = approvedUrls[pattern];
let existingRequest = false;
let existingResponse = false;
if (typeof existingSettings === 'boolean') {
existingRequest = existingSettings;
existingResponse = existingSettings;
} else if (existingSettings) {
existingRequest = existingSettings.approveRequest ?? false;
existingResponse = existingSettings.approveResponse ?? false;
}

const mergedRequest = approveRequest || existingRequest;
const mergedResponse = approveResponse || existingResponse;

// Create the approval settings
let value: boolean | IUrlApprovalSettings;
if (approveRequest === approveResponse) {
value = approveRequest;
if (mergedRequest === mergedResponse) {
value = mergedRequest;
} else {
value = { approveRequest, approveResponse };
value = { approveRequest: mergedRequest, approveResponse: mergedResponse };
}
Comment on lines +239 to 260
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge logic for URL approval settings should have test coverage. This bug fix addresses a critical issue where sequential approvals would overwrite each other instead of merging. Consider adding tests that verify:

  1. Approving requests then responses results in both being approved
  2. Approving responses then requests results in both being approved
  3. The boolean optimization works (when both are true, stores as true instead of {approveRequest: true, approveResponse: true})
  4. Merging works correctly when starting from a boolean value

Copilot uses AI. Check for mistakes.

approvedUrls[pattern] = value;
Expand Down
Loading