Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions components/task-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ export function TaskForm({
maxSandboxDuration = 300,
}: TaskFormProps) {
const [prompt, setPrompt] = useAtom(taskPromptAtom)
const [savedAgent, setSavedAgent] = useAtom(lastSelectedAgentAtom)
const [selectedAgent, setSelectedAgent] = useState(savedAgent || 'claude')
const [selectedAgent, setSelectedAgent] = useAtom(lastSelectedAgentAtom)
const [isAgentInitialized, setIsAgentInitialized] = useState(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isAgentInitialized state variable is created and set but never used anywhere in the component.

View Details
📝 Patch Details
diff --git a/components/task-form.tsx b/components/task-form.tsx
index 2bf77ef..9280459 100644
--- a/components/task-form.tsx
+++ b/components/task-form.tsx
@@ -161,7 +161,6 @@ export function TaskForm({
 }: TaskFormProps) {
   const [prompt, setPrompt] = useAtom(taskPromptAtom)
   const [selectedAgent, setSelectedAgent] = useAtom(lastSelectedAgentAtom)
-  const [isAgentInitialized, setIsAgentInitialized] = useState(false)
   const [selectedModel, setSelectedModel] = useState<string>(DEFAULT_MODELS.claude)
   const [selectedModels, setSelectedModels] = useState<string[]>([])
   const [repos, setRepos] = useAtom(githubReposAtomFamily(selectedOwner))
@@ -235,7 +234,6 @@ export function TaskForm({
           setSelectedModel(urlModel)
         }
       }
-      setIsAgentInitialized(true)
     } else {
       // Wait a tick for localStorage to be read by Jotai
       const timeoutId = setTimeout(() => {
@@ -243,7 +241,6 @@ export function TaskForm({
           // Only set default if still no agent after localStorage load
           setSelectedAgent('claude')
         }
-        setIsAgentInitialized(true)
       }, 0)
 
       return () => clearTimeout(timeoutId)

Analysis

Dead code: Unused isAgentInitialized state variable in TaskForm component

What fails: The isAgentInitialized state variable (line 164) is declared with useState(false) but is never read anywhere in the component. It is set to true in two places (lines 238 and 246 in the mount effect) but never referenced in conditional rendering or any other logic.

How to reproduce:

# Run TypeScript compiler with noUnusedLocals flag
pnpm exec tsc --noEmit --noUnusedLocals

Result: TypeScript reports:

components/task-form.tsx(164,10): error TS6133: 'isAgentInitialized' is declared but its value is never read.

Expected: TypeScript compilation should succeed with no unused variable errors. State variables should either be used for their intended purpose or removed entirely.

Fix: Removed the unused state variable declaration and all calls to its setter function (setIsAgentInitialized). The variable appeared to have been intended for gating renders during initialization but was never implemented, leaving it as pure dead code.

const [selectedModel, setSelectedModel] = useState<string>(DEFAULT_MODELS.claude)
const [selectedModels, setSelectedModels] = useState<string[]>([])
const [repos, setRepos] = useAtom(githubReposAtomFamily(selectedOwner))
Expand Down Expand Up @@ -235,11 +235,18 @@ export function TaskForm({
setSelectedModel(urlModel)
}
}
} else if (savedAgent) {
// Fall back to saved agent from Jotai atom
if (CODING_AGENTS.some((agent) => agent.value === savedAgent && !('isDivider' in agent && agent.isDivider))) {
setSelectedAgent(savedAgent)
}
setIsAgentInitialized(true)
} else {
// Wait a tick for localStorage to be read by Jotai
const timeoutId = setTimeout(() => {
if (!selectedAgent) {
// Only set default if still no agent after localStorage load
setSelectedAgent('claude')
}
setIsAgentInitialized(true)
}, 0)

return () => clearTimeout(timeoutId)
}

// Options are now initialized from server props, no need to load from cookies
Expand All @@ -252,7 +259,7 @@ export function TaskForm({
}, [])

// Get saved model atom for current agent
const savedModelAtom = lastSelectedModelAtomFamily(selectedAgent)
const savedModelAtom = lastSelectedModelAtomFamily(selectedAgent || 'claude')
const savedModel = useAtomValue(savedModelAtom)
const setSavedModel = useSetAtom(savedModelAtom)

Expand Down Expand Up @@ -326,7 +333,7 @@ export function TaskForm({
onSubmit({
prompt: prompt.trim(),
repoUrl: '',
selectedAgent,
selectedAgent: selectedAgent || 'claude',
selectedModel,
selectedModels: selectedAgent === 'multi-agent' ? selectedModels : undefined,
installDependencies,
Expand All @@ -340,7 +347,7 @@ export function TaskForm({
// Skip this check if we don't have repo data (likely not signed in) or if multi-agent mode
const selectedRepoData = repos?.find((repo) => repo.name === selectedRepo)

if (selectedRepoData && selectedAgent !== 'multi-agent') {
if (selectedRepoData && selectedAgent && selectedAgent !== 'multi-agent') {
try {
const response = await fetch(`/api/api-keys/check?agent=${selectedAgent}&model=${selectedModel}`)
const data = await response.json()
Expand Down Expand Up @@ -370,7 +377,7 @@ export function TaskForm({
onSubmit({
prompt: prompt.trim(),
repoUrl: selectedRepoData?.clone_url || '',
selectedAgent,
selectedAgent: selectedAgent || 'claude',
selectedModel,
selectedModels: selectedAgent === 'multi-agent' ? selectedModels : undefined,
installDependencies,
Expand Down Expand Up @@ -430,11 +437,9 @@ export function TaskForm({
<div className="flex items-center gap-2 flex-1 min-w-0">
{/* Agent Selection - Icon only on mobile, minimal width */}
<Select
value={selectedAgent}
value={selectedAgent || 'claude'}
onValueChange={(value) => {
setSelectedAgent(value)
// Save to Jotai atom immediately
setSavedAgent(value)
}}
disabled={isSubmitting}
>
Expand Down Expand Up @@ -520,7 +525,6 @@ export function TaskForm({
value={selectedModel}
onValueChange={(value) => {
setSelectedModel(value)
// Save to Jotai atom immediately
setSavedModel(value)
}}
disabled={isSubmitting}
Expand Down
Loading