Treat undefined same as true for isTrustedFolder (#7073)

This commit is contained in:
shrutip90 2025-08-25 19:57:57 -07:00 committed by GitHub
parent b6cca01161
commit 97ce197f38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 5 deletions

View file

@ -136,6 +136,24 @@ describe('ToolConfirmationMessage', () => {
expect(lastFrame()).toContain(alwaysAllowText);
});
it('should show "allow always" when folder trust is undefined', () => {
const mockConfig = {
isTrustedFolder: () => undefined,
getIdeMode: () => false,
} as unknown as Config;
const { lastFrame } = renderWithProviders(
<ToolConfirmationMessage
confirmationDetails={details}
config={mockConfig}
availableTerminalHeight={30}
terminalWidth={80}
/>,
);
expect(lastFrame()).toContain(alwaysAllowText);
});
it('should NOT show "allow always" when folder is untrusted', () => {
const mockConfig = {
isTrustedFolder: () => false,

View file

@ -56,6 +56,8 @@ export const ToolConfirmationMessage: React.FC<
onConfirm(outcome);
};
const isTrustedFolder = config?.isTrustedFolder() !== false;
useKeypress(
(key) => {
if (!isFocused) return;
@ -129,7 +131,7 @@ export const ToolConfirmationMessage: React.FC<
label: 'Yes, allow once',
value: ToolConfirmationOutcome.ProceedOnce,
});
if (config?.isTrustedFolder()) {
if (isTrustedFolder) {
options.push({
label: 'Yes, allow always',
value: ToolConfirmationOutcome.ProceedAlways,
@ -168,7 +170,7 @@ export const ToolConfirmationMessage: React.FC<
label: 'Yes, allow once',
value: ToolConfirmationOutcome.ProceedOnce,
});
if (config?.isTrustedFolder()) {
if (isTrustedFolder) {
options.push({
label: `Yes, allow always ...`,
value: ToolConfirmationOutcome.ProceedAlways,
@ -208,7 +210,7 @@ export const ToolConfirmationMessage: React.FC<
label: 'Yes, allow once',
value: ToolConfirmationOutcome.ProceedOnce,
});
if (config?.isTrustedFolder()) {
if (isTrustedFolder) {
options.push({
label: 'Yes, allow always',
value: ToolConfirmationOutcome.ProceedAlways,
@ -253,7 +255,7 @@ export const ToolConfirmationMessage: React.FC<
label: 'Yes, allow once',
value: ToolConfirmationOutcome.ProceedOnce,
});
if (config?.isTrustedFolder()) {
if (isTrustedFolder) {
options.push({
label: `Yes, always allow tool "${mcpProps.toolName}" from server "${mcpProps.serverName}"`,
value: ToolConfirmationOutcome.ProceedAlwaysTool, // Cast until types are updated