Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions client/src/Providers/ChatHostContext.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { useMemo } from 'react';
import { useSetAtom } from 'jotai';
import { Constants, QueryKeys } from 'librechat-data-provider';
import { hashQueryKey, useQueryClient } from '@tanstack/react-query';
import type { ChatHost, ChatMessageCache, ChatMessagesQuery } from '@librechat/chat/react';
import type { TMessage, TAgentQueuedTurnReceipt } from 'librechat-data-provider';
import type { QueryClient, QueryCacheNotifyEvent } from '@tanstack/react-query';
import { useLatestMessage, useLatestMessageId } from '~/hooks/Messages/useLatestMessage';
import { siblingIdxFamily, siblingKey } from '~/components/Chat/Messages/Thread/state';
import { useAbortStreamMutation, useGetMessagesByConvoId } from '~/data-provider';
import { agentQueuedTurnsQueryKey } from '~/data-provider/SSE/queuedTurns';
import { useChatSettings } from '~/Providers/ChatSettingsContext';
import { getMappingOptions } from '~/hooks/Chat/outcomes';
import useTurnServices from '~/hooks/Chat/services';
import useNewConvo from '~/hooks/useNewConvo';

Expand Down Expand Up @@ -113,15 +109,11 @@ export const appChatHost: ChatHost = {
usePaneConversation: (index) => useChatSettings().usePaneConversationState(index),
useNewConversation: (index) => useNewConvo(index).newConversation,
useTurnServices,
useLatestMessage: (index, key) => useLatestMessage(index, key),
useLatestMessageId: (index, key) => useLatestMessageId(index, key),
useSetSiblingIdx: (parentMessageId) => useSetAtom(siblingIdxFamily(siblingKey(parentMessageId))),
/** `mutateAsync` is bound once per observer; the mutation result object is fresh every
* render and would defeat the contract's memo. */
useAbortStream: () => useAbortStreamMutation().mutateAsync,
useMessageCache,
useFeedbackEnabled: () => useChatSettings().config.feedbackEnabled,
getMappingOptions,
useMessages,
};

Expand Down
8 changes: 4 additions & 4 deletions client/src/Providers/SteerHostContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCallback, useMemo } from 'react';
import { useParams } from 'react-router-dom';
import { QueryKeys } from 'librechat-data-provider';
import { useToastContext } from '@librechat/client';
import { useQueryClient } from '@tanstack/react-query';
Expand All @@ -24,7 +25,6 @@ import { agentQueuedTurnsQueryKey } from '~/data-provider/SSE/queuedTurns';
import useCodeApprovalMode from '~/hooks/Agents/useCodeApprovalMode';
import { streamStatusQueryKey } from '~/data-provider/SSE/queries';
import { useChatSettings } from '~/Providers/ChatSettingsContext';
import { useLatestMessage } from '~/hooks/Messages';
import { useSetFilesToDelete } from '~/hooks/Files';
import { useFileMapContext } from '~/Providers';
import useLocalize from '~/hooks/useLocalize';
Expand Down Expand Up @@ -113,9 +113,9 @@ export const appSteerHost: SteerHost = {
useAgentQueuedTurns(conversationId, enabled, clientRequestIds, reconcileUntil, expectsReceipts)
.data,
useFetchStreamStatus: () => fetchStreamStatus,
useLatestMessage: (index, conversationId) => useLatestMessage(index, conversationId),
useCodeApprovalMode: (conversation, addedConversation, codeEnvironmentMode) =>
useCodeApprovalMode(conversation, addedConversation, codeEnvironmentMode).selected,
useRouteConversationId: () => useParams().conversationId,
useCodeApprovalInputs: (conversation, addedConversation) =>
useCodeApprovalMode(conversation, addedConversation).readInputs(),
useLocalize,
useNotify,
useFileMap: useFileMapContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jest.mock('~/hooks/Agents/useCodeApprovalMode', () => ({
available: true,
modes: ['ask', 'acceptEdits'],
selected: 'ask',
readInputs: () => ({ conversation: null, reachable: { agents: [], complete: true } }),
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ jest.mock('~/hooks', () => ({
useLocalize: () => (key: string) => key,
}));

jest.mock('~/hooks/Chat/outcomes', () => ({
getMappingOptions: () => ({}),
}));

jest.mock('~/Providers', () => {
const Passthrough = ({ children }: { children: React.ReactNode }) => <>{children}</>;
const Context = { Provider: Passthrough };
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/Chat/__tests__/facade.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { getMappingOptions } from '@librechat/chat';
import { act, render, renderHook } from '@testing-library/react';
import { QueryKeys, Constants, ContentTypes } from 'librechat-data-provider';
import { useChat, ChatContext, useChatActions, resumeRequestsAtom } from '@librechat/chat/react';
Expand All @@ -8,7 +9,6 @@ import type { ChatContract } from '../contract';
import type { JotaiStore } from 'test/harness';
import { createMessageCache } from '~/Providers/ChatHostContext';
import { IsolatedAtomStore } from 'test/harness';
import { getMappingOptions } from '../outcomes';

const userMessage: TMessage = {
messageId: 'user-1',
Expand Down
Loading