Remove max requests per task settings option

This commit is contained in:
Saoud Rizwan
2024-09-01 01:41:43 -04:00
parent fdcec81814
commit ba4caf4f00
11 changed files with 6 additions and 147 deletions

View File

@@ -57,13 +57,6 @@ const ChatRow: React.FC<ChatRowProps> = ({
)
switch (type) {
case "request_limit_reached":
return [
<span
className="codicon codicon-error"
style={{ color: errorColor, marginBottom: "-1.5px" }}></span>,
<span style={{ color: errorColor, fontWeight: "bold" }}>Max Requests Reached</span>,
]
case "error":
return [
<span
@@ -410,16 +403,6 @@ const ChatRow: React.FC<ChatRowProps> = ({
switch (message.ask) {
case "tool":
return renderTool(message, headerStyle)
case "request_limit_reached":
return (
<>
<div style={headerStyle}>
{icon}
{title}
</div>
<p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}>{message.text}</p>
</>
)
case "command":
const splitMessage = (text: string) => {
const outputIndex = text.indexOf(COMMAND_OUTPUT_STRING)

View File

@@ -95,13 +95,6 @@ const ChatView = ({
switch (lastMessage.type) {
case "ask":
switch (lastMessage.ask) {
case "request_limit_reached":
setTextAreaDisabled(true)
setClaudeAsk("request_limit_reached")
setEnableButtons(true)
setPrimaryButtonText("Proceed")
setSecondaryButtonText("Start New Task")
break
case "api_req_failed":
setTextAreaDisabled(true)
setClaudeAsk("api_req_failed")
@@ -257,7 +250,6 @@ const ChatView = ({
*/
const handlePrimaryButtonClick = () => {
switch (claudeAsk) {
case "request_limit_reached":
case "api_req_failed":
case "command":
case "command_output":
@@ -280,7 +272,6 @@ const ChatView = ({
const handleSecondaryButtonClick = () => {
switch (claudeAsk) {
case "request_limit_reached":
case "api_req_failed":
startNewTask()
break

View File

@@ -2,12 +2,11 @@ import {
VSCodeButton,
VSCodeCheckbox,
VSCodeLink,
VSCodeTextArea,
VSCodeTextField,
VSCodeTextArea
} from "@vscode/webview-ui-toolkit/react"
import { useEffect, useState } from "react"
import { useExtensionState } from "../context/ExtensionStateContext"
import { validateApiConfiguration, validateMaxRequestsPerTask } from "../utils/validate"
import { validateApiConfiguration } from "../utils/validate"
import { vscode } from "../utils/vscode"
import ApiOptions from "./ApiOptions"
@@ -21,28 +20,20 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
const {
apiConfiguration,
version,
maxRequestsPerTask,
customInstructions,
setCustomInstructions,
alwaysAllowReadOnly,
setAlwaysAllowReadOnly,
} = useExtensionState()
const [apiErrorMessage, setApiErrorMessage] = useState<string | undefined>(undefined)
const [maxRequestsErrorMessage, setMaxRequestsErrorMessage] = useState<string | undefined>(undefined)
const [maxRequestsPerTaskString, setMaxRequestsPerTaskString] = useState<string>(
maxRequestsPerTask?.toString() || ""
)
const handleSubmit = () => {
const apiValidationResult = validateApiConfiguration(apiConfiguration)
const maxRequestsValidationResult = validateMaxRequestsPerTask(maxRequestsPerTaskString)
setApiErrorMessage(apiValidationResult)
setMaxRequestsErrorMessage(maxRequestsValidationResult)
if (!apiValidationResult && !maxRequestsValidationResult) {
if (!apiValidationResult) {
vscode.postMessage({ type: "apiConfiguration", apiConfiguration })
vscode.postMessage({ type: "maxRequestsPerTask", text: maxRequestsPerTaskString })
vscode.postMessage({ type: "customInstructions", text: customInstructions })
vscode.postMessage({ type: "alwaysAllowReadOnly", bool: alwaysAllowReadOnly })
onDone()
@@ -53,10 +44,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
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.
@@ -141,35 +128,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
</p>
</div>
<div>
<VSCodeTextField
value={maxRequestsPerTaskString}
style={{ width: "100%" }}
placeholder="20"
onInput={(e: any) => setMaxRequestsPerTaskString(e.target?.value ?? "")}>
<span style={{ fontWeight: "500" }}>Maximum # Requests Per Task</span>
</VSCodeTextField>
<p
style={{
fontSize: "12px",
marginTop: "5px",
color: "var(--vscode-descriptionForeground)",
}}>
If Claude Dev reaches this limit, it will pause and ask for your permission before making
additional requests.
</p>
{maxRequestsErrorMessage && (
<p
style={{
fontSize: "12px",
marginTop: "5px",
color: "var(--vscode-errorForeground)",
}}>
{maxRequestsErrorMessage}
</p>
)}
</div>
{IS_DEV && (
<>
<div style={{ marginTop: "10px", marginBottom: "4px" }}>Debug</div>

View File

@@ -8,7 +8,6 @@ interface ExtensionStateContextType extends ExtensionState {
didHydrateState: boolean
showWelcome: boolean
setApiConfiguration: (config: ApiConfiguration) => void
setMaxRequestsPerTask: (value?: number) => void
setCustomInstructions: (value?: string) => void
setAlwaysAllowReadOnly: (value: boolean) => void
setShowAnnouncement: (value: boolean) => void
@@ -52,7 +51,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
didHydrateState,
showWelcome,
setApiConfiguration: (value) => setState((prevState) => ({ ...prevState, apiConfiguration: value })),
setMaxRequestsPerTask: (value) => setState((prevState) => ({ ...prevState, maxRequestsPerTask: value })),
setCustomInstructions: (value) => setState((prevState) => ({ ...prevState, customInstructions: value })),
setAlwaysAllowReadOnly: (value) => setState((prevState) => ({ ...prevState, alwaysAllowReadOnly: value })),
setShowAnnouncement: (value) => setState((prevState) => ({ ...prevState, shouldShowAnnouncement: value })),

View File

@@ -204,12 +204,6 @@ export const mockMessages: ClaudeMessage[] = [
say: "text",
text: "Great! The tests for the TodoList component have passed. All functionalities, including the new delete feature, are working as expected.",
},
{
ts: Date.now() - 2200000,
type: "ask",
ask: "request_limit_reached",
text: "You've reached the maximum number of requests for this task. Would you like to continue or start a new task?",
},
{
ts: Date.now() - 2100000,
type: "say",

View File

@@ -26,14 +26,4 @@ export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): s
}
}
return undefined
}
export function validateMaxRequestsPerTask(maxRequestsPerTask?: string): string | undefined {
if (maxRequestsPerTask && maxRequestsPerTask.trim()) {
const num = Number(maxRequestsPerTask)
if (isNaN(num) || num < 3 || num > 100) {
return "Maximum requests must be between 3 and 100"
}
}
return undefined
}
}