Skip to content

Commit 0250648

Browse files
authored
promptUrlHandler: Simplify the confirmation dialog (microsoft#254077)
promptUrlHandler: Simplify the confirmation dilaog
1 parent c809b74 commit 0250648

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

src/vs/workbench/contrib/chat/browser/promptSyntax/promptUrlHandler.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { PromptsType } from '../../common/promptSyntax/promptTypes.js';
2121
import { ILogService } from '../../../../../platform/log/common/log.js';
2222
import { localize } from '../../../../../nls.js';
2323
import { IDialogService } from '../../../../../platform/dialogs/common/dialogs.js';
24-
import { IStorageService, StorageScope, StorageTarget } from '../../../../../platform/storage/common/storage.js';
2524
import { Schemas } from '../../../../../base/common/network.js';
2625
import { MarkdownString } from '../../../../../base/common/htmlContent.js';
2726
import { IHostService } from '../../../../services/host/browser/host.js';
@@ -33,8 +32,6 @@ export class PromptUrlHandler extends Disposable implements IWorkbenchContributi
3332

3433
static readonly ID = 'workbench.contrib.promptUrlHandler';
3534

36-
static readonly CONFIRM_INSTALL_STORAGE_KEY = 'security.promptForPromptProtocolHandling';
37-
3835
constructor(
3936
@IURLService urlService: IURLService,
4037
@INotificationService private readonly notificationService: INotificationService,
@@ -44,7 +41,7 @@ export class PromptUrlHandler extends Disposable implements IWorkbenchContributi
4441
@IOpenerService private readonly openerService: IOpenerService,
4542
@ILogService private readonly logService: ILogService,
4643
@IDialogService private readonly dialogService: IDialogService,
47-
@IStorageService private readonly storageService: IStorageService,
44+
4845
@IHostService private readonly hostService: IHostService,
4946
) {
5047
super();
@@ -120,51 +117,40 @@ export class PromptUrlHandler extends Disposable implements IWorkbenchContributi
120117
}
121118

122119
private async shouldBlockInstall(promptType: PromptsType, url: URI): Promise<boolean> {
123-
const location = url.with({ path: url.path.substring(0, url.path.indexOf('/', 1) + 1), query: undefined, fragment: undefined }).toString();
124-
const key = PromptUrlHandler.CONFIRM_INSTALL_STORAGE_KEY + '-' + location;
125-
126-
if (this.storageService.getBoolean(key, StorageScope.APPLICATION, false)) {
127-
return false;
128-
}
129-
130120
let uriLabel = url.toString();
131121
if (uriLabel.length > 50) {
132122
uriLabel = `${uriLabel.substring(0, 35)}...${uriLabel.substring(uriLabel.length - 15)}`;
133123
}
134124

135125
const detail = new MarkdownString('', { supportHtml: true });
136126
detail.appendMarkdown(localize('confirmOpenDetail2', "This will access {0}.\n\n", `[${uriLabel}](${url.toString()})`));
137-
detail.appendMarkdown(localize('confirmOpenDetail3', "If you did not initiate this request, it may represent an attempted attack on your system. Unless you took an explicit action to initiate this request, you should press 'Cancel'"));
127+
detail.appendMarkdown(localize('confirmOpenDetail3', "If you did not initiate this request, it may represent an attempted attack on your system. Unless you took an explicit action to initiate this request, you should press 'No'"));
138128

139129
let message: string;
140130
switch (promptType) {
141131
case PromptsType.prompt:
142132
message = localize('confirmInstallPrompt', "An external application wants to create a prompt file with content from a URL. Do you want to continue by selecting a destination folder and name?");
143133
break;
144134
case PromptsType.instructions:
145-
message = localize('confirmInstallInstructions', "An external application wants to create an instructions file with content from a URL.");
135+
message = localize('confirmInstallInstructions', "An external application wants to create an instructions file with content from a URL. Do you want to continue by selecting a destination folder and name?");
146136
break;
147137
default:
148-
message = localize('confirmInstallMode', "An external application wants to create a chat mode with content from a URL.");
138+
message = localize('confirmInstallMode', "An external application wants to create a chat mode with content from a URL. Do you want to continue by selecting a destination folder and name?");
149139
break;
150140
}
151141

152-
const { confirmed, checkboxChecked } = await this.dialogService.confirm({
142+
const { confirmed } = await this.dialogService.confirm({
153143
type: 'warning',
154144
primaryButton: localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes"),
155145
cancelButton: localize('noButton', "No"),
156146
message,
157-
checkbox: { label: localize('confirmOpenDoNotAskAgain', "Allow creating a prompt file without asking from '{0}'", location) },
158147
custom: {
159148
markdownDetails: [{
160149
markdown: detail
161150
}]
162151
}
163152
});
164153

165-
if (checkboxChecked) {
166-
this.storageService.store(key, true, StorageScope.APPLICATION, StorageTarget.MACHINE);
167-
}
168154
return !confirmed;
169155

170156
}

0 commit comments

Comments
 (0)