Handle unset agent slug, name. E.g when chat with user created agents

This commit is contained in:
Debanjum
2025-06-09 17:55:07 -07:00
parent 5dd8a9cb24
commit bd928b9f3c

View File

@@ -317,7 +317,7 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) {
const [inputTools, setInputTools] = useState<string[] | undefined>();
const [outputModes, setOutputModes] = useState<string[] | undefined>();
const [hasModified, setHasModified] = useState<boolean>(false);
const [isDefaultAgent, setIsDefaultAgent] = useState<boolean>(!agentData || agentData?.slug.toLowerCase() === "khoj");
const [isDefaultAgent, setIsDefaultAgent] = useState<boolean>(!agentData || agentData?.slug?.toLowerCase() === "khoj");
const [displayInputTools, setDisplayInputTools] = useState<string[] | undefined>();
const [displayOutputModes, setDisplayOutputModes] = useState<string[] | undefined>();
@@ -338,11 +338,11 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) {
setDisplayOutputModes(agentConfigurationOptions?.output_modes ? Object.keys(agentConfigurationOptions.output_modes) : []);
}
if (agentData.name.toLowerCase() === "khoj" || agentData.is_hidden === true) {
if (agentData.name?.toLowerCase() === "khoj" || agentData.is_hidden === true) {
setIsEditable(true);
}
if (agentData.slug.toLowerCase() === "khoj") {
if (agentData.slug?.toLowerCase() === "khoj") {
setSelectedModel(undefined);
setCustomPrompt(undefined);
setIsDefaultAgent(true);