diff --git a/web/src/app/admin/assistants/AssistantEditor.tsx b/web/src/app/admin/assistants/AssistantEditor.tsx index 22bd532f5b82..e4673cba559a 100644 --- a/web/src/app/admin/assistants/AssistantEditor.tsx +++ b/web/src/app/admin/assistants/AssistantEditor.tsx @@ -61,10 +61,10 @@ import { debounce } from "lodash"; import { FullLLMProvider } from "../configuration/llm/interfaces"; import StarterMessagesList from "./StarterMessageList"; -import { Switch } from "@/components/ui/switch"; +import { Switch, SwitchField } from "@/components/ui/switch"; import { generateIdenticon } from "@/components/assistants/AssistantIcon"; import { BackButton } from "@/components/BackButton"; -import { Checkbox } from "@/components/ui/checkbox"; +import { Checkbox, CheckboxField } from "@/components/ui/checkbox"; import { AdvancedOptionsToggle } from "@/components/AdvancedOptionsToggle"; import { MinimalUserSnapshot } from "@/lib/types"; import { useUserGroups } from "@/lib/hooks"; @@ -144,8 +144,6 @@ export function AssistantEditor({ "#6FFFFF", ]; - const [showSearchTool, setShowSearchTool] = useState(false); - const [showAdvancedOptions, setShowAdvancedOptions] = useState(false); // state to persist across formik reformatting @@ -786,15 +784,9 @@ export function AssistantEditor({ : "" }`} > - { - setShowSearchTool(checked); setFieldValue("num_chunks", null); toggleToolInValues(searchTool.id); }} @@ -828,7 +820,7 @@ export function AssistantEditor({ )} {ccPairs.length > 0 && searchTool && - showSearchTool && + values.enabled_tools_map[searchTool.id] && !(user?.role != "admin" && documentSets.length === 0) && (
@@ -916,14 +908,10 @@ export function AssistantEditor({ - { if ( currentLLMSupportsImageOutput && @@ -979,6 +967,7 @@ export function AssistantEditor({ onCheckedChange={() => { toggleToolInValues(internetSearchTool.id); }} + name={`enabled_tools_map.${internetSearchTool.id}`} />
@@ -1071,9 +1060,9 @@ export function AssistantEditor({
- { setFieldValue("is_public", checked); if (checked) { diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index 1da9551d5d80..a3ad5097d064 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -2063,6 +2063,7 @@ export function ChatPage({ {retrievalEnabled && documentSidebarToggled && settings?.isMobile && (
setDocumentSidebarToggled(false)} title="Sources" > @@ -2346,9 +2347,10 @@ export function ChatPage({ (settings?.enterpriseSettings ?.two_lines_for_chat_header ? "pt-20 " - : "pt-8") + - (hasPerformedInitialScroll ? "" : "invisible") + : "pt-8 ") } + // NOTE: temporarily removing this to fix the scroll bug + // (hasPerformedInitialScroll ? "" : "invisible") > {(messageHistory.length < BUFFER_COUNT ? messageHistory diff --git a/web/src/components/Modal.tsx b/web/src/components/Modal.tsx index b4c298ff2cd6..cd6ad6e92e04 100644 --- a/web/src/components/Modal.tsx +++ b/web/src/components/Modal.tsx @@ -22,6 +22,7 @@ interface ModalProps { noScroll?: boolean; heightOverride?: string; removeBottomPadding?: boolean; + removePadding?: boolean; } export function Modal({ @@ -39,6 +40,7 @@ export function Modal({ noScroll, heightOverride, removeBottomPadding, + removePadding, }: ModalProps) { const modalRef = useRef(null); const [isMounted, setIsMounted] = useState(false); @@ -114,7 +116,7 @@ export function Modal({ {icon && icon({ size: 30 })}
- {!hideDividerForTitle && } + {!hideDividerForTitle && } )}
diff --git a/web/src/components/ui/checkbox.tsx b/web/src/components/ui/checkbox.tsx index ddfb542a5e03..82fa21a799d2 100644 --- a/web/src/components/ui/checkbox.tsx +++ b/web/src/components/ui/checkbox.tsx @@ -3,15 +3,19 @@ import * as React from "react"; import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; import { Check } from "lucide-react"; +import { useField } from "formik"; import { cn } from "@/lib/utils"; -const Checkbox = React.forwardRef< +interface BaseCheckboxProps + extends React.ComponentPropsWithoutRef { + size?: "sm" | "md" | "lg"; +} + +export const Checkbox = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef & { - size?: "sm" | "md" | "lg"; - } ->(({ className, size = "md", type = "button", ...props }, ref) => { + BaseCheckboxProps +>(({ className, size = "md", ...props }, ref) => { const sizeClasses = { sm: "h-3 w-3", md: "h-4 w-4", @@ -21,22 +25,44 @@ const Checkbox = React.forwardRef< return ( - + ); }); -Checkbox.displayName = CheckboxPrimitive.Root.displayName; -export { Checkbox }; +Checkbox.displayName = "Checkbox"; + +interface CheckboxFieldProps extends Omit { + name: string; +} + +export const CheckboxField: React.FC = ({ + name, + ...props +}) => { + const [field, , helpers] = useField({ name, type: "checkbox" }); + + return ( + { + helpers.setValue(Boolean(checked)); + }} + {...props} + /> + ); +}; diff --git a/web/src/components/ui/switch.tsx b/web/src/components/ui/switch.tsx index cd7e133903a2..36c3cee7ba36 100644 --- a/web/src/components/ui/switch.tsx +++ b/web/src/components/ui/switch.tsx @@ -2,15 +2,19 @@ import * as React from "react"; import * as SwitchPrimitives from "@radix-ui/react-switch"; +import { useField } from "formik"; import { cn } from "@/lib/utils"; -const Switch = React.forwardRef< +interface BaseSwitchProps + extends React.ComponentPropsWithoutRef { + circleClassName?: string; + size?: "sm" | "md" | "lg"; +} + +export const Switch = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef & { - circleClassName?: string; - size?: "sm" | "md" | "lg"; - } + BaseSwitchProps >(({ circleClassName, className, size = "md", ...props }, ref) => { const sizeClasses = { sm: "h-4 w-8", @@ -32,17 +36,24 @@ const Switch = React.forwardRef< return ( ); }); -Switch.displayName = SwitchPrimitives.Root.displayName; -export { Switch }; +Switch.displayName = "Switch"; + +interface SwitchFieldProps extends Omit { + name: string; +} + +export const SwitchField: React.FC = ({ + name, + onCheckedChange, + ...props +}) => { + const [field, , helpers] = useField({ name, type: "checkbox" }); + + return ( + { + helpers.setValue(Boolean(checked)); + onCheckedChange?.(checked); + }} + {...props} + /> + ); +};