Ignore workspace settings for untrusted folders (#6606)

This commit is contained in:
shrutip90
2025-08-19 21:20:41 -07:00
committed by GitHub
parent 179f1414da
commit d250293c2e
16 changed files with 386 additions and 122 deletions

View File

@@ -4,7 +4,14 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { useCallback, useEffect, useMemo, useState, useRef } from 'react';
import {
useCallback,
useEffect,
useMemo,
useState,
useRef,
useContext,
} from 'react';
import {
Box,
DOMElement,
@@ -41,7 +48,7 @@ import { ShellConfirmationDialog } from './components/ShellConfirmationDialog.js
import { RadioButtonSelect } from './components/shared/RadioButtonSelect.js';
import { Colors } from './colors.js';
import { loadHierarchicalGeminiMemory } from '../config/config.js';
import { LoadedSettings, SettingScope } from '../config/settings.js';
import { SettingScope } from '../config/settings.js';
import { Tips } from './components/Tips.js';
import { ConsolePatcher } from './utils/ConsolePatcher.js';
import { registerCleanup } from '../utils/cleanup.js';
@@ -100,6 +107,7 @@ import { useSettingsCommand } from './hooks/useSettingsCommand.js';
import { SettingsDialog } from './components/SettingsDialog.js';
import { setUpdateHandler } from '../utils/handleAutoUpdate.js';
import { appEvents, AppEvent } from '../utils/events.js';
import { SettingsContext } from './contexts/SettingsContext.js';
import { isNarrowWidth } from './utils/isNarrowWidth.js';
const CTRL_EXIT_PROMPT_DURATION_MS = 1000;
@@ -108,20 +116,26 @@ const MAX_DISPLAYED_QUEUED_MESSAGES = 3;
interface AppProps {
config: Config;
settings: LoadedSettings;
startupWarnings?: string[];
version: string;
}
export const AppWrapper = (props: AppProps) => {
const kittyProtocolStatus = useKittyKeyboardProtocol();
const settingsContext = useContext(SettingsContext);
if (!settingsContext) {
// This should not happen as AppWrapper is always rendered within the provider.
throw new Error('SettingsContext is not available');
}
const { settings } = settingsContext;
return (
<KeypressProvider
kittyProtocolEnabled={kittyProtocolStatus.enabled}
config={props.config}
>
<SessionStatsProvider>
<VimModeProvider settings={props.settings}>
<VimModeProvider settings={settings}>
<App {...props} />
</VimModeProvider>
</SessionStatsProvider>
@@ -129,13 +143,19 @@ export const AppWrapper = (props: AppProps) => {
);
};
const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
const App = ({ config, startupWarnings = [], version }: AppProps) => {
const isFocused = useFocus();
useBracketedPaste();
const [updateInfo, setUpdateInfo] = useState<UpdateObject | null>(null);
const { stdout } = useStdout();
const nightly = version.includes('nightly');
const { history, addItem, clearItems, loadHistory } = useHistory();
const settingsContext = useContext(SettingsContext);
if (!settingsContext) {
// This should not happen as App is always rendered within the provider.
throw new Error('SettingsContext is not available');
}
const { settings } = settingsContext;
const [idePromptAnswered, setIdePromptAnswered] = useState(false);
const currentIDE = config.getIdeClient().getCurrentIde();
@@ -262,7 +282,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
openThemeDialog,
handleThemeSelect,
handleThemeHighlight,
} = useThemeCommand(settings, setThemeError, addItem);
} = useThemeCommand(setThemeError, addItem);
const { isSettingsDialogOpen, openSettingsDialog, closeSettingsDialog } =
useSettingsCommand();
@@ -308,7 +328,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
openEditorDialog,
handleEditorSelect,
exitEditorDialog,
} = useEditorSettings(settings, setEditorError, addItem);
} = useEditorSettings(setEditorError, addItem);
const toggleCorgiMode = useCallback(() => {
setCorgiMode((prev) => !prev);