React context/provider managing chat sidebar state (sources, memories) with open/close/toggle logic and hooks for consumption in workspace chat UI.
// Source: https://github.com/Mintplex-Labs/anything-llm | License: MIT | Copyright Mintplex Labs Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { createContext, useContext, useState } from "react";
const ChatSidebarContext = createContext();
export function ChatSidebarProvider({ children }) {
const [activeSidebar, setActiveSidebar] = useState(null);
const [sidebarData, setSidebarData] = useState(null);
function openSidebar(type, data = null) {
setActiveSidebar(type);
setSidebarData(data);
}
function closeSidebar() {
setActiveSidebar(null);
setSidebarData(null);
}
function toggleSidebar(type, data = null) {
if (activeSidebar === type) closeSidebar();
else openSidebar(type, data);
}
return (
<ChatSidebarContext
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key