import { VSCodeButton, VSCodeLink, VSCodeTextArea, VSCodeTextField } from "@vscode/webview-ui-toolkit/react" import React, { useEffect, useState } from "react" import { ApiConfiguration } from "../../../src/shared/api" import { validateApiConfiguration, validateMaxRequestsPerTask } from "../utils/validate" import { vscode } from "../utils/vscode" import ApiOptions from "./ApiOptions" type SettingsViewProps = { version: string apiConfiguration?: ApiConfiguration setApiConfiguration: React.Dispatch> maxRequestsPerTask: string setMaxRequestsPerTask: React.Dispatch> customInstructions: string setCustomInstructions: React.Dispatch> onDone: () => void } const SettingsView = ({ version, apiConfiguration, setApiConfiguration, maxRequestsPerTask, setMaxRequestsPerTask, customInstructions, setCustomInstructions, onDone, }: SettingsViewProps) => { const [apiErrorMessage, setApiErrorMessage] = useState(undefined) const [maxRequestsErrorMessage, setMaxRequestsErrorMessage] = useState(undefined) const handleSubmit = () => { const apiValidationResult = validateApiConfiguration(apiConfiguration) const maxRequestsValidationResult = validateMaxRequestsPerTask(maxRequestsPerTask) setApiErrorMessage(apiValidationResult) setMaxRequestsErrorMessage(maxRequestsValidationResult) if (!apiValidationResult && !maxRequestsValidationResult) { vscode.postMessage({ type: "apiConfiguration", apiConfiguration }) vscode.postMessage({ type: "maxRequestsPerTask", text: maxRequestsPerTask }) vscode.postMessage({ type: "customInstructions", text: customInstructions }) onDone() } } useEffect(() => { setApiErrorMessage(undefined) }, [apiConfiguration]) useEffect(() => { setMaxRequestsErrorMessage(undefined) }, [maxRequestsPerTask]) // 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 */ return (

Settings

Done
{apiErrorMessage && (

{apiErrorMessage}

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

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

setMaxRequestsPerTask(e.target?.value)}> Maximum # Requests Per Task

If Claude Dev reaches this limit, it will pause and ask for your permission before making additional requests.

{maxRequestsErrorMessage && (

{maxRequestsErrorMessage}

)}

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

v{version}

) } export default SettingsView