mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 09:50:15 +01:00
* 👻 refactor: MCP Select State with Jotai Atoms
* refactor: Implement timestamp management for ChatArea localStorage entries
* refactor: Integrate MCP Server Manager into BadgeRow context and components to avoid double-calling within BadgeRow
* refactor: add try/catch
* chore: remove comment
20 lines
759 B
TypeScript
20 lines
759 B
TypeScript
import { atomFamily, atomWithStorage } from 'jotai/utils';
|
|
import { Constants, LocalStorageKeys } from 'librechat-data-provider';
|
|
|
|
/**
|
|
* Creates a storage atom for MCP values per conversation
|
|
* Uses atomFamily to create unique atoms for each conversation ID
|
|
*/
|
|
export const mcpValuesAtomFamily = atomFamily((conversationId: string | null) => {
|
|
const key = conversationId ?? Constants.NEW_CONVO;
|
|
const storageKey = `${LocalStorageKeys.LAST_MCP_}${key}`;
|
|
|
|
return atomWithStorage<string[]>(storageKey, [], undefined, { getOnInit: true });
|
|
});
|
|
|
|
/**
|
|
* Global storage atom for MCP pinned state (shared across all conversations)
|
|
*/
|
|
export const mcpPinnedAtom = atomWithStorage<boolean>(LocalStorageKeys.PIN_MCP_, true, undefined, {
|
|
getOnInit: true,
|
|
});
|