Show toast when enabling auto-approve on non-settings UI

This commit is contained in:
Will Chen
2025-04-18 13:49:06 -07:00
parent 5e95ae3686
commit a4629e7698
3 changed files with 16 additions and 6 deletions

View File

@@ -1,17 +1,25 @@
import { useSettings } from "@/hooks/useSettings";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
import { showInfo } from "@/lib/toast";
export function AutoApproveSwitch() {
export function AutoApproveSwitch({
showToast = true,
}: {
showToast?: boolean;
}) {
const { settings, updateSettings } = useSettings();
return (
<div className="flex items-center space-x-2">
<Switch
id="auto-approve"
checked={settings?.autoApproveChanges}
onCheckedChange={() =>
updateSettings({ autoApproveChanges: !settings?.autoApproveChanges })
}
onCheckedChange={() => {
updateSettings({ autoApproveChanges: !settings?.autoApproveChanges });
if (!settings?.autoApproveChanges && showToast) {
showInfo("You can disable auto-approve in the Settings.");
}
}}
/>
<Label htmlFor="auto-approve">Auto-approve</Label>
</div>

View File

@@ -323,7 +323,9 @@ function ChatInputActions({
}: ChatInputActionsProps) {
const [autoApprove, setAutoApprove] = useState(false);
const [isDetailsVisible, setIsDetailsVisible] = useState(false);
if (proposal.type === "tip-proposal") {
return <div>Tip proposal</div>;
}
if (proposal.type === "action-proposal") {
return <ActionProposalActions proposal={proposal}></ActionProposalActions>;
}