Skip to content
Merged
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
5 changes: 2 additions & 3 deletions client/src/components/Chat/Input/ChatForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useAtom } from 'jotai';
import { useRecoilValue } from 'recoil';
import { useWatch } from 'react-hook-form';
import { useNavigate } from 'react-router-dom';
import { showStopButtonByIndex } from '@librechat/chat/react';
import { useSteering, showStopButtonByIndex } from '@librechat/chat/react';
import {
composerSurfaceClasses,
composerSurfaceShadow,
Expand All @@ -18,9 +18,9 @@ import {
isAssistantsEndpoint,
} from 'librechat-data-provider';
import type { TChatProject, TMessage, TConversation } from 'librechat-data-provider';
import type { QueuedMessageContext } from '@librechat/chat';
import type { SetterOrUpdater } from 'recoil';
import type { ExtendedFile, FileSetter, ConvoGenerator, TAskFunction } from '~/common';
import type { QueuedMessageContext } from '~/hooks/Chat/useSteering';
import {
cn,
getModelSpec,
Expand Down Expand Up @@ -70,7 +70,6 @@ import useHasAccess from '~/hooks/Roles/useHasAccess';
import useDictation from '~/hooks/Input/useDictation';
import { useGetStartupConfig } from '~/data-provider';
import CodeWorkspaceMenu from './CodeWorkspaceMenu';
import useSteering from '~/hooks/Chat/useSteering';
import CodeApprovalMenu from './CodeApprovalMenu';
import TextareaHeader from './TextareaHeader';
import PromptsCommand from './PromptsCommand';
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Chat/Input/Composer/Queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import {
TriangleAlert,
MessageSquarePlus,
} from 'lucide-react';
import type { SteeringControls } from '@librechat/chat/react';
import type { MenuItemProps } from '@librechat/client';
import type { RestoreToComposer } from '~/Providers/ComposerRestoreContext';
import type { SteeringControls } from '~/hooks/Chat/useSteering';
import type { QueuedMessage } from '~/hooks/Chat/queue';
import { useQueuedTurnPortal } from '~/components/Chat/Steering/QueuedTurnPortal';
import EscalateNowButton from '~/components/Chat/Input/EscalateNowButton';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
resetSteerFamilies,
resetQueueFamilies,
} from '@librechat/chat/react';
import type { SteeringControls } from '~/hooks/Chat/useSteering';
import type { SteeringControls } from '@librechat/chat/react';
import type { QueuedMessage } from '~/hooks/Chat/queue';
import {
QueuedTurnPortalProvider,
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Chat/Input/DuringRunSendButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React, { forwardRef, useMemo, useRef } from 'react';
import { useWatch } from 'react-hook-form';
import { Zap, Clock, ZapOff } from 'lucide-react';
import { composerSubmitClasses, SendActions, SendIcon } from '@librechat/client';
import type { SteeringControls } from '@librechat/chat/react';
import type { SendAction } from '@librechat/client';
import type { Control } from 'react-hook-form';
import type { ComposerKeyContext, KeyChordSource } from '~/utils/shortcuts';
import type { SteeringControls } from '~/hooks/Chat/useSteering';
import { isMacPlatform, resolveComposerKeyDown } from '~/utils/shortcuts';
import useComposerBindings from '~/hooks/Input/useComposerBindings';
import { useLocalize } from '~/hooks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { RecoilRoot } from 'recoil';
import { useForm } from 'react-hook-form';
import { render, screen, fireEvent } from '@testing-library/react';
import type { SteeringControls } from '~/hooks/Chat/useSteering';
import type { SteeringControls } from '@librechat/chat/react';
import type { ShortcutOverride } from '~/store/misc';
import DuringRunSendButton from '../DuringRunSendButton';
import store from '~/store';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { memo, useMemo, useRef, useState } from 'react';
import { hasLiveRunPause } from '@librechat/chat';
import { Clock, TextQuote, X } from 'lucide-react';
import { useQueryClient } from '@tanstack/react-query';
import { Button, TooltipAnchor } from '@librechat/client';
import { QueryKeys, type TMessage } from 'librechat-data-provider';
import {
useSteerCancel,
useSteerMoveToQueue,
useSteerRehome,
useSteerEscalate,
} from '@librechat/chat/react';
import type { SteerReceiptState } from '~/components/Chat/Steering/Receipt';
import useSteerCancel, { useSteerMoveToQueue, useSteerRehome } from '~/hooks/Chat/useSteerCancel';
import { getMessageRowWidthClass } from '~/components/Chat/Messages/ui/MessageRow';
import EscalateNowButton from '~/components/Chat/Input/EscalateNowButton';
import { useMessagePartsHost } from '~/Providers/MessagePartsHostContext';
import useSteerEscalate from '~/hooks/Chat/useSteerEscalate';
import useSteerRecovery from '~/hooks/Chat/useSteerRecovery';
import { hasLiveRunPause } from '~/hooks/Chat/useSteering';
import { useGetMessagesByConvoId } from '~/data-provider';
import { cn, isLegacyDeliveryUncertain } from '~/utils';
import { useLatestMessage } from '~/hooks/Messages';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { RecoilRoot } from 'recoil';
import { MemoryRouter } from 'react-router-dom';
import { hasLiveRunPause } from '@librechat/chat';
import { Provider as JotaiProvider, createStore } from 'jotai';
import { pendingSteersByConvoId } from '@librechat/chat/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
Expand All @@ -9,7 +10,6 @@ import { render, screen, fireEvent, waitFor, act } from '@testing-library/react'
import type { Agents, TConversation, TMessage } from 'librechat-data-provider';
import type { PendingSteer } from '~/hooks/Chat/queue';
import { siblingIdxFamily, siblingKey } from '~/components/Chat/Messages/Thread/state';
import { hasLiveRunPause } from '~/hooks/Chat/useSteering';
import { applyPendingAction } from '~/utils/approval';
import PendingSteers from '../PendingSteers';
import store from '~/store';
Expand All @@ -30,19 +30,15 @@ jest.mock('~/hooks', () => ({
useLocalize: () => (key: string) => key,
}));

jest.mock('~/hooks/Chat/useSteerEscalate', () => ({
__esModule: true,
default: () => mockEscalate,
}));

jest.mock('~/hooks/Chat/useSteerRecovery', () => ({
__esModule: true,
default: () => ({ retry: mockRetry, sendAsNew: mockSendAsNew }),
}));

jest.mock('~/hooks/Chat/useSteerCancel', () => ({
__esModule: true,
default: () => jest.fn(),
jest.mock('@librechat/chat/react', () => ({
...jest.requireActual('@librechat/chat/react'),
useSteerEscalate: () => mockEscalate,
useSteerCancel: () => jest.fn(),
useSteerMoveToQueue: () => mockMoveToQueue,
useSteerRehome: () => mockRehome,
}));
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/Chat/__tests__/abort.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ jest.mock('~/hooks/useNewConvo', () => ({
default: () => ({ newConversation: jest.fn() }),
}));

jest.mock('~/hooks/Chat/useSteerConvert', () => ({
__esModule: true,
default: () => mockConvertSteersToQueued,
jest.mock('@librechat/chat/react', () => ({
...jest.requireActual('@librechat/chat/react'),
useSteerConvert: () => mockConvertSteersToQueued,
}));

const INDEX = 0;
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/Chat/__tests__/contract.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jest.mock('~/hooks/useNewConvo', () => ({
default: () => ({ newConversation: jest.fn() }),
}));

jest.mock('~/hooks/Chat/useSteerConvert', () => ({
__esModule: true,
default: () => jest.fn(),
jest.mock('@librechat/chat/react', () => ({
...jest.requireActual('@librechat/chat/react'),
useSteerConvert: () => jest.fn(),
}));

function createWrapper(
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/Chat/__tests__/feedback.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jest.mock('~/hooks/useNewConvo', () => ({
default: () => ({ newConversation: jest.fn() }),
}));

jest.mock('~/hooks/Chat/useSteerConvert', () => ({
__esModule: true,
default: () => jest.fn(),
jest.mock('@librechat/chat/react', () => ({
...jest.requireActual('@librechat/chat/react'),
useSteerConvert: () => jest.fn(),
}));

function renderChatHelpers() {
Expand Down
8 changes: 4 additions & 4 deletions client/src/hooks/Chat/__tests__/transport.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import { Tools, QueryKeys, ContentTypes, EModelEndpoint, request } from 'librech
import {
activeGenerationCreatedAtByConvoId,
activeGenerationProtocolVersionByConvoId,
queuedMessagesByConvoId,
pendingSteersByConvoId,
resetSteerFamilies,
submissionByIndex,
clearSubmissions,
resetQueueFamilies,
useSteerReclaim,
useSteerEscalate,
useSteering,
} from '@librechat/chat/react';
import type {
TEnqueueAgentQueuedTurnRequest,
Expand All @@ -29,14 +33,10 @@ import type { PendingSteer } from '~/hooks/Chat/queue';
import { ChatTransportContext } from '~/Providers/ChatTransportContext';
import { ChatContext, useChatContext } from '~/Providers/ChatContext';
import { startupConfigKey } from '~/data-provider/Endpoints/queries';
import { useSteerReclaim } from '~/hooks/Chat/useSteerCancel';
import { queuedMessagesByConvoId } from '~/hooks/Chat/queue';
import useSteerEscalate from '~/hooks/Chat/useSteerEscalate';
import useResumableSSE from '~/hooks/SSE/useResumableSSE';
import useResumeOnLoad from '~/hooks/SSE/useResumeOnLoad';
import useChatHelpers from '~/hooks/Chat/useChatHelpers';
import { resumeRequestsAtom } from '~/hooks/Chat/resume';
import useSteering from '~/hooks/Chat/useSteering';
import { useChat } from '~/hooks/Chat/facade';
import useSSE from '~/hooks/SSE/useSSE';
import store from '~/store';
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/Chat/__tests__/useSteerCancel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
ComposerRestoreProvider,
useComposerRestoreHost,
} from '~/Providers/ComposerRestoreContext';
import useSteerCancel, { useSteerMoveToQueue } from '../useSteerCancel';
import '~/Providers/SteerHostContext';
import { queuedMessagesByConvoId } from '~/hooks/Chat/queue';
import '~/Providers/SteerHostContext';
import { useSteerCancel, useSteerMoveToQueue } from '@librechat/chat/react';

const mockCancelAsync = jest.fn();

Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/Chat/__tests__/useSteerConvert.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
} from '@librechat/chat/react';
import { recoveryDispositionsFamily } from '~/components/Chat/Steering/recovery';
import { queuedMessagesByConvoId } from '~/hooks/Chat/queue';
import useSteerConvert from '../useSteerConvert';
import '~/Providers/SteerHostContext';
import { useSteerConvert } from '@librechat/chat/react';

const mockFetchStreamStatus = jest.fn();
let mockFileMap: Record<string, { llmDeliveryPath: 'text' }> = {};
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/Chat/__tests__/useSteerEscalate.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
} from '@librechat/chat/react';
import type { PendingSteer } from '~/hooks/Chat/queue';
import { ChatSettingsContext, defaultChatSettings } from '~/Providers/ChatSettingsContext';
import useSteerEscalate from '../useSteerEscalate';
import '~/Providers/SteerHostContext';
import { useSteerEscalate } from '@librechat/chat/react';

const mockArmMutateAsync = jest.fn();
const mockShowToast = jest.fn();
Expand Down
6 changes: 5 additions & 1 deletion client/src/hooks/Chat/__tests__/useSteering.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
pendingManualSkillsByConvoId,
pendingReasoningOverrideFamily,
} from '~/components/Chat/Input/Composer/state';
import useSteering, { hasLiveRunPause, mergeQueuedTurnFileMetadata } from '../useSteering';
import { clearAllDrafts, getPendingDraftId, getNewConversationDraftId } from '~/utils';
import { recoveryDispositionsFamily } from '~/components/Chat/Steering/recovery';
import useUpdateFiles from '~/hooks/Files/useUpdateFiles';
Expand All @@ -55,6 +54,11 @@ import { applyPendingAction } from '~/utils/approval';
import English from '~/locales/en/translation.json';
import useQueueDrain from '../useQueueDrain';
import '~/Providers/SteerHostContext';
import { useSteering } from '@librechat/chat/react';
import {
hasLiveRunPause,
hydrateFileDeliveryMetadata as mergeQueuedTurnFileMetadata,
} from '@librechat/chat';

const CONVO_ID = 'convo-steer-ui';
const UUID_V4_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
Expand Down
2 changes: 0 additions & 2 deletions client/src/hooks/Chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ export { default as useIdChangeEffect } from './useIdChangeEffect';
export { default as useFocusChatEffect } from './useFocusChatEffect';
export { default as useQueueDrain } from './useQueueDrain';
export { default as useQueuedTurnReveal } from './useQueuedTurnReveal';
export { default as useSteering } from './useSteering';
export { default as useSteerConvert } from './useSteerConvert';
2 changes: 1 addition & 1 deletion client/src/hooks/Chat/useChatHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
abortScrollFamily,
submissionByIndex,
useClearSubmissions,
useSteerConvert,
} from '@librechat/chat/react';
import type { TMessage } from 'librechat-data-provider';
import type { ChatContract } from './contract';
Expand All @@ -23,7 +24,6 @@ import { useAbortStreamMutation, supportsGenerationProtocolV2 } from '~/data-pro
import { siblingIdxFamily, siblingKey } from '~/components/Chat/Messages/Thread/state';
import { useChatSettings } from '~/Providers/ChatSettingsContext';
import useChatFunctions from '~/hooks/Chat/useChatFunctions';
import useSteerConvert from '~/hooks/Chat/useSteerConvert';
import { resolveAbortSteerTarget } from '~/utils';
import useNewConvo from '~/hooks/useNewConvo';
import { getMessageCacheIds } from './cache';
Expand Down
11 changes: 4 additions & 7 deletions client/src/hooks/Chat/useSteerRecovery.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import { useCallback } from 'react';
import { useStore } from 'jotai';
import { getSteerErrorCode, isDefiniteSteerRejection } from '@librechat/chat';
import {
useSteerRehome,
useSteerConvert,
isSubmittingFamily,
pendingSteersByConvoId,
resolveAcknowledgedSteer,
pendingSteerCancelClientIdsFamily,
} from '@librechat/chat/react';
import type { PendingSteer } from '~/hooks/Chat/queue';
import {
getSteerErrorCode,
isDefiniteSteerRejection,
resolveAcknowledgedSteer,
} from '~/hooks/Chat/useSteering';
import { useSteerMessageMutation, useCancelSteerMutation } from '~/data-provider';
import { useComposerRestoreHost } from '~/Providers/ComposerRestoreContext';
import { carriedSteerContext, isLegacyDeliveryUncertain } from '~/utils';
import { useChatSettings } from '~/Providers/ChatSettingsContext';
import { useSteerRehome } from '~/hooks/Chat/useSteerCancel';
import useSteerConvert from '~/hooks/Chat/useSteerConvert';

/**
* Retry or re-route a pending steer from OUTSIDE the composer. The thread's
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/Input/useComposerRestore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRef, useEffect, useCallback } from 'react';
import { useStore } from 'jotai';
import type { QueuedMessageContext } from '@librechat/chat';
import type { TMessage } from 'librechat-data-provider';
import type { QueuedMessageContext } from '~/hooks/Chat/useSteering';
import type { ExtendedFile, FileSetter } from '~/common';
import type { useChatFormContext } from '~/Providers';
import {
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/SSE/__tests__/useResumableSSE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ jest.mock('~/data-provider', () => ({
postGenerationRequest: (...args: unknown[]) => mockPostGenerationRequest(...args),
}));

jest.mock('~/hooks/Chat/useSteerConvert', () => ({
__esModule: true,
default: () => mockConvertSteersToQueued,
jest.mock('@librechat/chat/react', () => ({
...jest.requireActual('@librechat/chat/react'),
useSteerConvert: () => mockConvertSteersToQueued,
}));

/** The steer-chip/queue writers are swapped for stable named spies, so these tests
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/SSE/steer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useMemo, useRef } from 'react';
import { useStore } from 'jotai';
import { useSteerConvert } from '@librechat/chat/react';
import {
pendingSteersByConvoId,
appliedSteerIdsByConvoId,
Expand Down Expand Up @@ -27,7 +28,6 @@ import {
} from '~/utils';
import { pendingQuotesByConvoId } from '~/components/Chat/Input/Composer/state';
import { queuedMessagesByConvoId } from '~/hooks/Chat/queue';
import useSteerConvert from '~/hooks/Chat/useSteerConvert';
import { useFileMapContext } from '~/Providers';

/**
Expand Down
6 changes: 4 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"librechat-data-provider": "*",
"lucide": "^0.528.0",
"lucide-react": "^0.528.0",
"react": "^18.2.0 || ^19.1.0"
"react": "^18.2.0 || ^19.1.0",
"uuid": "^11.1.1"
},
"dependencies": {
"sse.js": "^2.8.0"
Expand All @@ -88,6 +89,7 @@
"react-dom": "^18.2.0",
"rimraf": "^6.1.3",
"tsdown": "0.22.2",
"typescript": "^5.9.3"
"typescript": "^5.9.3",
"uuid": "^11.1.1"
}
}
Loading
Loading