Skip to content

Commit

Permalink
Add 2 lines in InputSettings.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
AtlantisPleb committed Aug 27, 2024
1 parent 70b3e41 commit 4d9e04e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions components/input/InputSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function InputSettings({ className, ...props }: React.ComponentProps<'div
const setModel = useModelStore((state) => state.setModel)
const tools = useToolStore((state) => state.tools)
const setTools = useToolStore((state) => state.setTools)
const getSelectedTools = useToolStore((state) => state.getSelectedTools)
const balance = useBalanceStore((state) => state.balance)
const { user, isLoaded, isSignedIn } = useUser()
const [isGitHubConnected, setIsGitHubConnected] = useState(false)
Expand Down Expand Up @@ -60,10 +61,11 @@ export function InputSettings({ className, ...props }: React.ComponentProps<'div

const handleToolChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, checked } = e.target
const selectedTools = getSelectedTools()
if (checked) {
setTools([...tools, name])
setTools([...selectedTools, name])
} else {
setTools(tools.filter((tool) => tool !== name))
setTools(selectedTools.filter((tool) => tool !== name))
}
}

Expand Down Expand Up @@ -151,7 +153,7 @@ export function InputSettings({ className, ...props }: React.ComponentProps<'div
<Popover.Trigger asChild>
<button className={buttonClasses}>
<Wrench className="mr-1" size={14} />
{tools.length}
{getSelectedTools().length}
</button>
</Popover.Trigger>
<Popover.Portal>
Expand All @@ -167,7 +169,7 @@ export function InputSettings({ className, ...props }: React.ComponentProps<'div
type="checkbox"
id={tool}
name={tool}
checked={tools.includes(tool)}
checked={getSelectedTools().includes(tool)}
onChange={handleToolChange}
className="mr-2"
/>
Expand Down

0 comments on commit 4d9e04e

Please sign in to comment.