import { VSCodeButton, VSCodeCheckbox, VSCodeLink, VSCodeTextArea } from "@vscode/webview-ui-toolkit/react" import { memo, useEffect, useState } from "react" import { useExtensionState } from "../context/ExtensionStateContext" import { validateApiConfiguration } from "../utils/validate" import { vscode } from "../utils/vscode" import ApiOptions from "./ApiOptions" const IS_DEV = false // FIXME: use flags when packaging type SettingsViewProps = { onDone: () => void } const SettingsView = ({ onDone }: SettingsViewProps) => { const { apiConfiguration, version, customInstructions, setCustomInstructions, alwaysAllowReadOnly, setAlwaysAllowReadOnly, } = useExtensionState() const [apiErrorMessage, setApiErrorMessage] = useState(undefined) const handleSubmit = () => { const apiValidationResult = validateApiConfiguration(apiConfiguration) setApiErrorMessage(apiValidationResult) if (!apiValidationResult) { vscode.postMessage({ type: "apiConfiguration", apiConfiguration }) vscode.postMessage({ type: "customInstructions", text: customInstructions }) vscode.postMessage({ type: "alwaysAllowReadOnly", bool: alwaysAllowReadOnly }) onDone() } } useEffect(() => { setApiErrorMessage(undefined) }, [apiConfiguration]) // validate as soon as the component is mounted /* useEffect will use stale values of variables if they are not included in the dependency array. so trying to use useEffect with a dependency array of only one value for example will use any other variables' old values. In most cases you don't want this, and should opt to use react-use hooks. useEffect(() => { // uses someVar and anotherVar // eslint-disable-next-line react-hooks/exhaustive-deps }, [someVar]) If we only want to run code once on mount we can use react-use's useEffectOnce or useMount */ const handleResetState = () => { vscode.postMessage({ type: "resetState" }) } return (

Settings

Done
setCustomInstructions(e.target?.value ?? "")}> Custom Instructions

These instructions are added to the end of the system prompt sent with every request.

setAlwaysAllowReadOnly(e.target.checked)}> Always allow read-only operations

When enabled, Claude will automatically read files and view directories without requiring you to click the Allow button.

{IS_DEV && ( <>
Debug
Reset State

This will reset all global state and secret storage in the extension.

)}

If you have any questions or feedback, feel free to open an issue at{" "} https://github.com/saoudrizwan/claude-dev

v{version}

) } export default memo(SettingsView)