mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 18:00:15 +01:00
21 lines
759 B
TypeScript
21 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,
|
||
|
|
});
|