Check folder trust before allowing add directory (#12652)

This commit is contained in:
shrutip90
2025-11-14 19:06:30 -08:00
committed by GitHub
parent d03496b710
commit 9786c4dcff
18 changed files with 1206 additions and 66 deletions

View File

@@ -105,6 +105,8 @@ import { ShellFocusContext } from './contexts/ShellFocusContext.js';
import { useSessionResume } from './hooks/useSessionResume.js';
import { type ExtensionManager } from '../config/extension-manager.js';
import { requestConsentInteractive } from '../config/extensions/consent.js';
import { useIncludeDirsTrust } from './hooks/useIncludeDirsTrust.js';
import { isWorkspaceTrusted } from '../config/trustedFolders.js';
import { disableMouseEvents, enableMouseEvents } from './utils/mouse.js';
import { useAlternateBuffer } from './hooks/useAlternateBuffer.js';
import { useSettings } from './contexts/SettingsContext.js';
@@ -161,6 +163,9 @@ export const AppContainer = (props: AppContainerProps) => {
const [isProcessing, setIsProcessing] = useState<boolean>(false);
const [embeddedShellFocused, setEmbeddedShellFocused] = useState(false);
const [showDebugProfiler, setShowDebugProfiler] = useState(false);
const [customDialog, setCustomDialog] = useState<React.ReactNode | null>(
null,
);
const [copyModeEnabled, setCopyModeEnabled] = useState(false);
const [shellModeActive, setShellModeActive] = useState(false);
@@ -169,7 +174,7 @@ export const AppContainer = (props: AppContainerProps) => {
const [historyRemountKey, setHistoryRemountKey] = useState(0);
const [updateInfo, setUpdateInfo] = useState<UpdateObject | null>(null);
const [isTrustedFolder, setIsTrustedFolder] = useState<boolean | undefined>(
config.isTrustedFolder(),
isWorkspaceTrusted(settings.merged).isTrusted,
);
const [queueErrorMessage, setQueueErrorMessage] = useState<string | null>(
@@ -591,6 +596,7 @@ Logging in with Google... Please restart Gemini CLI to continue.
slashCommandActions,
extensionsUpdateStateInternal,
isConfigInitialized,
setCustomDialog,
);
const performMemoryRefresh = useCallback(async () => {
@@ -908,6 +914,8 @@ Logging in with Google... Please restart Gemini CLI to continue.
} = useIdeTrustListener();
const isInitialMount = useRef(true);
useIncludeDirsTrust(config, isTrustedFolder, historyManager, setCustomDialog);
useEffect(() => {
let timeoutId: NodeJS.Timeout;
@@ -1263,6 +1271,7 @@ Logging in with Google... Please restart Gemini CLI to continue.
isFolderTrustDialogOpen ||
!!shellConfirmationRequest ||
!!confirmationRequest ||
!!customDialog ||
confirmUpdateExtensionRequests.length > 0 ||
!!loopDetectionConfirmationRequest ||
isThemeDialogOpen ||
@@ -1382,6 +1391,7 @@ Logging in with Google... Please restart Gemini CLI to continue.
activePtyId,
embeddedShellFocused,
showDebugProfiler,
customDialog,
copyModeEnabled,
warningMessage,
}),
@@ -1467,6 +1477,7 @@ Logging in with Google... Please restart Gemini CLI to continue.
historyManager,
embeddedShellFocused,
showDebugProfiler,
customDialog,
apiKeyDefaultValue,
authState,
copyModeEnabled,