Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🚰 refactor: Move the Queue Drain, Reveal and Recovery Hooks into the Chat Package (#17170)
Marco Beretta255acf3812ef
diff --git a/client/src/Providers/SteerHostContext.tsx b/client/src/Providers/SteerHostContext.tsxindex bbec8d83f1..9a05b601c1 100644--- a/client/src/Providers/SteerHostContext.tsx+++ b/client/src/Providers/SteerHostContext.tsx@@ -1,12 +1,15 @@-import { useCallback } from 'react';+import { useCallback, useMemo } from 'react';+import { QueryKeys } from 'librechat-data-provider';import { useToastContext } from '@librechat/client';+import { useQueryClient } from '@tanstack/react-query';import type {SteerHost,SteerSettings,SteerNotification,SteerRequestCallbacks,} from '@librechat/chat/react';-import type { ChatTransportError } from '@librechat/chat';+import type { ChatTransportError, StreamStatusResponse } from '@librechat/chat';+import type { TAgentQueuedTurnReceipt } from 'librechat-data-provider';import {fetchStreamStatus,useAgentQueuedTurns,@@ -17,7 +20,9 @@ import {useCancelAgentQueuedTurnMutation,useEnqueueAgentQueuedTurnMutation,} from '~/data-provider';+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';@@ -41,6 +46,35 @@ function useEnqueueQueuedTurn(): ReturnType<SteerHost['useEnqueueQueuedTurn']> {return useCallback((input, callbacks) => mutate(input, settleWith(callbacks)), [mutate]);}+/** Observes the receipts and stream status the app's queries cache for a conversation, without+ * registering a competing query function. */+function useQueuedTurnCache(conversationId: string): ReturnType<SteerHost['useQueuedTurnCache']> {+ const queryClient = useQueryClient();+ return useMemo(+ () => ({+ read: () => ({+ receipts: queryClient.getQueryData<TAgentQueuedTurnReceipt[]>(+ agentQueuedTurnsQueryKey(conversationId),+ ),+ status: queryClient.getQueryData<StreamStatusResponse>(+ streamStatusQueryKey(conversationId),+ ),+ }),+ subscribe: (notify: () => void) =>+ queryClient.getQueryCache().subscribe((event) => {+ const key = event?.query.queryKey;+ if (+ key?.[1] === conversationId &&+ (key[0] === QueryKeys.agentQueuedTurns || key[0] === 'streamStatus')+ ) {+ notify();+ }+ }),+ }),+ [queryClient, conversationId],+ );+}+function useNotify(): (notification: SteerNotification) => void {const { showToast } = useToastContext();return showToast;@@ -52,13 +86,15 @@ function useClearFilesToDelete(): () => void {}function useSettings(): SteerSettings {- const { config, duringRunDefaultAction, setDuringRunDefaultAction } = useChatSettings();+ const { config, duringRunDefaultAction, setDuringRunDefaultAction, getPaneConversations } =+ useChatSettings();return {duringRunDefaultAction,setDuringRunDefaultAction,queuedSendLockTimeoutMs: config.queuedSendLockTimeoutMs,queuedTurnReconciliationTimeoutMs: config.queuedTurnReconciliationTimeoutMs,steerArmConfirmationTimeoutMs: config.steerArmConfirmationTimeoutMs,+ getPaneConversations,};}@@ -66,11 +102,13 @@ function useSettings(): SteerSettings {* queries, toasts, translations, file map and chat settings. */export const appSteerHost: SteerHost = {useSteerMessage,+ useSteerMessageAsync: () => useSteerMessageMutation().mutateAsync,useCancelSteer: () => useCancelSteerMutation().mutateAsync,useArmSteer: () => useArmSteerMutation().mutateAsync,useMarkFilesUsage: () => useMarkFilesUsageMutation().mutate,useEnqueueQueuedTurn,useCancelQueuedTurn: () => useCancelAgentQueuedTurnMutation().mutateAsync,+ useQueuedTurnCache,useQueuedTurns: (conversationId, enabled, clientRequestIds, reconcileUntil, expectsReceipts) =>useAgentQueuedTurns(conversationId, enabled, clientRequestIds, reconcileUntil, expectsReceipts).data,diff --git a/client/src/Providers/__tests__/SteerHostContext.spec.tsx b/client/src/Providers/__tests__/SteerHostContext.spec.tsxnew file mode 100644index 0000000000..11b45c0ca8--- /dev/null+++ b/client/src/Providers/__tests__/SteerHostContext.spec.tsx@@ -0,0 +1,84 @@+import React from 'react';+import { act, renderHook } from '@testing-library/react';+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import type { TAgentQueuedTurnReceipt } from 'librechat-data-provider';+import type { StreamStatusResponse } from '@librechat/chat';+import { agentQueuedTurnsQueryKey } from '~/data-provider/SSE/queuedTurns';+import { streamStatusQueryKey } from '~/data-provider/SSE/queries';+import { appSteerHost } from '../SteerHostContext';++const CONVO_ID = 'convo-cache';++const receipt = { clientRequestId: 'request-1', status: 'queued' } as TAgentQueuedTurnReceipt;+const status: StreamStatusResponse = { active: false, status: 'complete', createdAt: 10 };++function renderCache(queryClient: QueryClient, conversationId = CONVO_ID) {+ const wrapper = ({ children }: { children: React.ReactNode }) => (+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>+ );+ return renderHook(({ id }) => appSteerHost.useQueuedTurnCache(id), {+ wrapper,+ initialProps: { id: conversationId },+ });+}++describe('appSteerHost.useQueuedTurnCache', () => {+ it('reads the receipts and stream status cached for the conversation', () => {+ const queryClient = new QueryClient();+ queryClient.setQueryData(agentQueuedTurnsQueryKey(CONVO_ID), [receipt]);+ queryClient.setQueryData(streamStatusQueryKey(CONVO_ID), status);+ queryClient.setQueryData(streamStatusQueryKey('other'), { active: true });++ const { result } = renderCache(queryClient);++ expect(result.current.read()).toEqual({ receipts: [receipt], status });+ });++ it('reads nothing for a conversation the caches do not hold', () => {+ const { result } = renderCache(new QueryClient());+ expect(result.current.read()).toEqual({ receipts: undefined, status: undefined });+ });++ it('notifies only for the receipts and status of its own conversation', () => {+ const queryClient = new QueryClient();+ const { result } = renderCache(queryClient);+ const notify = jest.fn();+ const unsubscribe = result.current.subscribe(notify);++ act(() => {+ queryClient.setQueryData(['messages', CONVO_ID], []);+ queryClient.setQueryData(agentQueuedTurnsQueryKey('other'), [receipt]);+ });+ expect(notify).not.toHaveBeenCalled();++ act(() => {+ queryClient.setQueryData(agentQueuedTurnsQueryKey(CONVO_ID), [receipt]);+ });+ const afterReceipts = notify.mock.calls.length;+ expect(afterReceipts).toBeGreaterThan(0);++ act(() => {+ queryClient.setQueryData(streamStatusQueryKey(CONVO_ID), status);+ });+ expect(notify.mock.calls.length).toBeGreaterThan(afterReceipts);++ unsubscribe();+ const settled = notify.mock.calls.length;+ act(() => {+ queryClient.setQueryData(streamStatusQueryKey(CONVO_ID), { ...status, createdAt: 20 });+ });+ expect(notify).toHaveBeenCalledTimes(settled);+ });++ it('keeps its functions while the conversation does, and replaces them when it changes', () => {+ const { result, rerender } = renderCache(new QueryClient());+ const first = result.current;++ rerender({ id: CONVO_ID });+ expect(result.current.read).toBe(first.read);+ expect(result.current.subscribe).toBe(first.subscribe);++ rerender({ id: 'other' });+ expect(result.current.subscribe).not.toBe(first.subscribe);+ });+});diff --git a/client/src/components/Chat/ChatView.tsx b/client/src/components/Chat/ChatView.tsxindex f680255f50..bddfae5c0c 100644--- a/client/src/components/Chat/ChatView.tsx+++ b/client/src/components/Chat/ChatView.tsx@@ -5,7 +5,13 @@ import { useForm } from 'react-hook-form';import { Spinner } from '@librechat/client';import { useParams } from 'react-router-dom';import { Constants, buildTree } from 'librechat-data-provider';-import { useIsSubmitting, submissionByIndex, ComposerRestoreProvider } from '@librechat/chat/react';+import {+ useQueueDrain,+ submissionByIndex,+ useIsSubmitting,+ useQueuedTurnReveal,+ ComposerRestoreProvider,+} from '@librechat/chat/react';import type { TChatProject } from 'librechat-data-provider';import type { ChatFormValues } from '~/common';import {@@ -14,8 +20,6 @@ import {useResumeOnLoad,useAdaptiveSSE,useChatHelpers,- useQueueDrain,- useQueuedTurnReveal,useLocalize,} from '~/hooks';import { ChatContext, AddedChatContext, ChatFormProvider, useFileMapContext } from '~/Providers';diff --git a/client/src/components/Chat/Messages/Content/Parts/PendingSteers.tsx b/client/src/components/Chat/Messages/Content/Parts/PendingSteers.tsxindex 16b0e64645..81e7f9bc41 100644--- a/client/src/components/Chat/Messages/Content/Parts/PendingSteers.tsx+++ b/client/src/components/Chat/Messages/Content/Parts/PendingSteers.tsx@@ -9,12 +9,12 @@ import {useSteerMoveToQueue,useSteerRehome,useSteerEscalate,+ useSteerRecovery,} from '@librechat/chat/react';import type { SteerReceiptState } from '~/components/Chat/Steering/Receipt';import { getMessageRowWidthClass } from '~/components/Chat/Messages/ui/MessageRow';import EscalateNowButton from '~/components/Chat/Input/EscalateNowButton';import { useMessagePartsHost } from '~/Providers/MessagePartsHostContext';-import useSteerRecovery from '~/hooks/Chat/useSteerRecovery';import { useGetMessagesByConvoId } from '~/data-provider';import { cn, isLegacyDeliveryUncertain } from '~/utils';import { useLatestMessage } from '~/hooks/Messages';diff --git a/client/src/components/Chat/Messages/Content/Parts/__tests__/PendingSteers.test.tsx b/client/src/components/Chat/Messages/Content/Parts/__tests__/PendingSteers.test.tsxindex fae6b488d6..bd9471981c 100644--- a/client/src/components/Chat/Messages/Content/Parts/__tests__/PendingSteers.test.tsx+++ b/client/src/components/Chat/Messages/Content/Parts/__tests__/PendingSteers.test.tsx@@ -30,17 +30,13 @@ jest.mock('~/hooks', () => ({useLocalize: () => (key: string) => key,}));-jest.mock('~/hooks/Chat/useSteerRecovery', () => ({- __esModule: true,- default: () => ({ retry: mockRetry, sendAsNew: mockSendAsNew }),-}));-jest.mock('@librechat/chat/react', () => ({...jest.requireActual('@librechat/chat/react'),useSteerEscalate: () => mockEscalate,useSteerCancel: () => jest.fn(),useSteerMoveToQueue: () => mockMoveToQueue,useSteerRehome: () => mockRehome,+ useSteerRecovery: () => ({ retry: mockRetry, sendAsNew: mockSendAsNew }),}));jest.mock('~/Providers', () => ({diff --git a/client/src/components/Chat/Messages/PendingTurn.tsx b/client/src/components/Chat/Messages/PendingTurn.tsxindex 44b28ce039..42dabec9c3 100644--- a/client/src/components/Chat/Messages/PendingTurn.tsx+++ b/client/src/components/Chat/Messages/PendingTurn.tsx@@ -1,11 +1,14 @@import { useCallback, useEffect, useMemo, useRef } from 'react';import { useAtomValue } from 'jotai';import { useRecoilValue } from 'recoil';-import { revealedQueuedTurnFamily } from '@librechat/chat/react';+import {+ hasRevealSuccessor,+ buildRevealedMessage,+ revealedQueuedTurnFamily,+} from '@librechat/chat/react';import type { TMessage } from 'librechat-data-provider';import type { RefObject } from 'react';import type { TMessageIcon } from '~/common';-import { buildRevealedMessage, hasRevealSuccessor } from '~/hooks/Chat/useQueuedTurnReveal';import { useQueuedTurnPortal } from '~/components/Chat/Steering/QueuedTurnPortal';import { getHeaderPrefixForScreenReader, getMessageAriaLabel } from '~/utils';import { messageFooterClasses } from '~/components/Chat/Messages/styles';diff --git a/client/src/components/Chat/__tests__/ChatView.spec.tsx b/client/src/components/Chat/__tests__/ChatView.spec.tsxindex d755712a44..834a47de33 100644--- a/client/src/components/Chat/__tests__/ChatView.spec.tsx+++ b/client/src/components/Chat/__tests__/ChatView.spec.tsx@@ -30,14 +30,18 @@ jest.mock('~/data-provider', () => ({* helper surface so the suite can inject matching vs stale IDs without standing* up SSE, message trees, or full ChatRoute synchronization.*/+jest.mock('@librechat/chat/react', () => ({+ ...jest.requireActual('@librechat/chat/react'),+ useQueueDrain: jest.fn(),+ useQueuedTurnReveal: jest.fn(),+}));+jest.mock('~/hooks', () => ({useLocalize: () => (key: string) => (key === 'com_ui_new_chat' ? 'New chat' : key),useChatHelpers: () => ({ conversation: mockConversation() }),useAddedResponse: () => ({}),useAdaptiveSSE: jest.fn(),useResumeOnLoad: jest.fn(),- useQueueDrain: jest.fn(),- useQueuedTurnReveal: jest.fn(),useScrollbarGutterSeed: jest.fn(),}));diff --git a/client/src/components/Chat/__tests__/ChatView.subagent.spec.tsx b/client/src/components/Chat/__tests__/ChatView.subagent.spec.tsxindex e1df77ddc3..5b16b6e1d9 100644--- a/client/src/components/Chat/__tests__/ChatView.subagent.spec.tsx+++ b/client/src/components/Chat/__tests__/ChatView.subagent.spec.tsx@@ -27,12 +27,16 @@ jest.mock('librechat-data-provider', () => ({buildTree: ({ messages }: { messages: unknown[] }) => messages,}));+jest.mock('@librechat/chat/react', () => ({+ ...jest.requireActual('@librechat/chat/react'),+ useQueueDrain: jest.fn(),+ useQueuedTurnReveal: jest.fn(),+}));+jest.mock('~/hooks', () => ({useAddedResponse: () => ({}),useResumeOnLoad: jest.fn(),useAdaptiveSSE: jest.fn(),- useQueueDrain: jest.fn(),- useQueuedTurnReveal: jest.fn(),useScrollbarGutterSeed: jest.fn(),useLocalize: () => (key: string) => key,useChatHelpers: () => ({diff --git a/client/src/hooks/Chat/__tests__/useQueueDrain.spec.tsx b/client/src/hooks/Chat/__tests__/useQueueDrain.spec.tsxindex 0b1963014a..bee73b396b 100644--- a/client/src/hooks/Chat/__tests__/useQueueDrain.spec.tsx+++ b/client/src/hooks/Chat/__tests__/useQueueDrain.spec.tsx@@ -4,8 +4,8 @@ import { getDefaultStore, useAtomValue, useSetAtom } from 'jotai';import { act, renderHook, waitFor } from '@testing-library/react';import { Constants, ReasoningEffort } from 'librechat-data-provider';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';-import { isSubmittingFamily, resetSubmitting } from '@librechat/chat/react';import { revealedQueuedTurnFamily, resetSteerFamilies } from '@librechat/chat/react';+import { useQueueDrain, isSubmittingFamily, resetSubmitting } from '@librechat/chat/react';import {claimQueuedIntent,releaseQueuedIntent,@@ -28,7 +28,6 @@ import type {SettledQueuedTurnReceipt,} from '@librechat/chat';import { SteerHostTestProvider } from 'test/steerHost';-import useQueueDrain from '../useQueueDrain';const mockMarkFilesUsage = jest.fn();jest.mock('~/data-provider', () => ({diff --git a/client/src/hooks/Chat/__tests__/useQueuedTurnReveal.spec.tsx b/client/src/hooks/Chat/__tests__/useQueuedTurnReveal.spec.tsxindex 6308864589..d0e8d8c9a6 100644--- a/client/src/hooks/Chat/__tests__/useQueuedTurnReveal.spec.tsx+++ b/client/src/hooks/Chat/__tests__/useQueuedTurnReveal.spec.tsx@@ -1,25 +1,25 @@import React from 'react';import { RecoilRoot } from 'recoil';import { QueryKeys } from 'librechat-data-provider';+import { selectQueuedTurnReveal } from '@librechat/chat';import { isSubmittingFamily } from '@librechat/chat/react';import { act, renderHook, waitFor } from '@testing-library/react';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { Provider as JotaiProvider, createStore, useSetAtom } from 'jotai';import {+ hasRevealSuccessor,+ useQueuedTurnReveal,+ shouldRollbackReveal,+ buildRevealedMessage,revealedQueuedTurnFamily,activeGenerationCreatedAtByConvoId,} from '@librechat/chat/react';import type { TMessage, TAgentQueuedTurnReceipt } from 'librechat-data-provider';import type { RevealedQueuedTurn } from '@librechat/chat/react';import type { QueuedMessage, RunEnd } from '@librechat/chat';-import useQueuedTurnReveal, {- buildRevealedMessage,- hasRevealSuccessor,- selectQueuedTurnReveal,- shouldRollbackReveal,-} from '../useQueuedTurnReveal';import { agentQueuedTurnsQueryKey } from '~/data-provider/SSE/queuedTurns';import { streamStatusQueryKey } from '~/data-provider/SSE/queries';+import { SteerHostTestProvider } from 'test/steerHost';const CONVO_ID = 'convo-reveal';const RESPONSE_ID = 'response-1';@@ -198,8 +198,10 @@ describe('useQueuedTurnReveal', () => {<QueryClientProvider client={queryClient}><RecoilRoot><JotaiProvider store={jotaiStore}>- <StateProbe />- {children}+ <SteerHostTestProvider>+ <StateProbe />+ {children}+ </SteerHostTestProvider></JotaiProvider></RecoilRoot></QueryClientProvider>diff --git a/client/src/hooks/Chat/__tests__/useSteerRecovery.spec.tsx b/client/src/hooks/Chat/__tests__/useSteerRecovery.spec.tsxindex c798d2ade5..2ea6ddc82f 100644--- a/client/src/hooks/Chat/__tests__/useSteerRecovery.spec.tsx+++ b/client/src/hooks/Chat/__tests__/useSteerRecovery.spec.tsx@@ -1,10 +1,11 @@import React from 'react';import { act, render, renderHook } from '@testing-library/react';import { getDefaultStore, useAtomValue, useSetAtom } from 'jotai';-import { isSubmittingFamily, resetSubmitting } from '@librechat/chat/react';+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { RecoilRoot, useSetRecoilState, type MutableSnapshot } from 'recoil';import { queuedMessagesByConvoId, resetQueueFamilies } from '@librechat/chat/react';import { ComposerRestoreProvider, useComposerRestoreHost } from '@librechat/chat/react';+import { useSteerRecovery, isSubmittingFamily, resetSubmitting } from '@librechat/chat/react';import {pendingSteerCancelClientIdsFamily,acceptedSteerClientIdsByConvoId,@@ -17,14 +18,21 @@ import type { RewakeDrain } from '@librechat/chat/react';import { ChatSettingsContext, defaultChatSettings } from '~/Providers/ChatSettingsContext';import { usePaneConversations } from '~/routes/ChatSettings';import { SteerHostTestProvider } from 'test/steerHost';-import useSteerRecovery from '../useSteerRecovery';import store from '~/store';const mockMutateAsync = jest.fn();const mockCancelSteer = jest.fn();+/** Whether the steer mutation runs on React Query itself rather than a bare `mutateAsync`+ * stub, for a case that depends on what the library does with a request that outlives its+ * component. */+let mockRealSteerMutation = false;jest.mock('~/data-provider', () => ({- useSteerMessageMutation: () => ({ mutateAsync: mockMutateAsync }),+ useSteerMessageMutation: () => {+ const { useMutation } = jest.requireActual('@tanstack/react-query');+ const mutation = useMutation({ mutationFn: (request: unknown) => mockMutateAsync(request) });+ return mockRealSteerMutation ? mutation : { mutateAsync: mockMutateAsync };+ },useCancelSteerMutation: () => ({ mutateAsync: mockCancelSteer }),}));@@ -34,6 +42,8 @@ const flush = () => act(async () => undefined);const CONVO_ID = 'convo-steer-recovery';+const queryClient = new QueryClient({ defaultOptions: { mutations: { retry: false } } });+/** The hook resolves "is the run over" from the conversation's own submitting* state, not from its own unmount, so every case has to place the* conversation in the store the way `ChatView` does. */@@ -66,20 +76,22 @@ function PaneSettings({ children }: { children: React.ReactNode }) {function setup(initialize?: (snapshot: MutableSnapshot) => void, rewake?: RewakeDrain) {const wrapper = ({ children }: { children: React.ReactNode }) => (- <RecoilRoot- initializeState={(snapshot) => {- seedRun(snapshot, true);- initialize?.(snapshot);- }}- >- <SteerHostTestProvider>- <PaneSettings>- <ComposerRestoreProvider>- {rewake ? <RewakePublisher rewake={rewake}>{children}</RewakePublisher> : children}- </ComposerRestoreProvider>- </PaneSettings>- </SteerHostTestProvider>- </RecoilRoot>+ <QueryClientProvider client={queryClient}>+ <RecoilRoot+ initializeState={(snapshot) => {+ seedRun(snapshot, true);+ initialize?.(snapshot);+ }}+ >+ <SteerHostTestProvider>+ <PaneSettings>+ <ComposerRestoreProvider>+ {rewake ? <RewakePublisher rewake={rewake}>{children}</RewakePublisher> : children}+ </ComposerRestoreProvider>+ </PaneSettings>+ </SteerHostTestProvider>+ </RecoilRoot>+ </QueryClientProvider>);return renderHook(() => ({@@ -99,6 +111,7 @@ beforeEach(() => {});afterEach(() => {+ mockRealSteerMutation = false;resetSubmitting(getDefaultStore());});@@ -169,6 +182,28 @@ describe('useSteerRecovery', () => {]);});+ it('settles a retry whose row unmounted before the server answered', async () => {+ mockRealSteerMutation = true;+ let answer: (result: unknown) => void = () => undefined;+ mockMutateAsync.mockReturnValue(new Promise((resolve) => (answer = resolve)));+ const { result, unmount } = setup(() => {+ getDefaultStore().set(pendingSteersByConvoId(CONVO_ID), [+ { steerId: 'local-1', text: 'redo this', status: 'failed', createdAt: 5 },+ ]);+ });+ act(() => {+ result.current.recovery.retry('local-1');+ });+ unmount();++ answer({ steerId: 'srv-9', status: 'queued', position: 1, conversationId: CONVO_ID });+ await flush();++ expect(getDefaultStore().get(pendingSteersByConvoId(CONVO_ID))).toEqual([+ expect.objectContaining({ steerId: 'srv-9', text: 'redo this', status: 'pending' }),+ ]);+ });+it('clears delivery uncertainty after an idempotent retry succeeds', async () => {mockMutateAsync.mockResolvedValue({steerId: 'srv-safe',@@ -285,27 +320,29 @@ describe('useSteerRecovery', () => {}render(<ComposerRestoreProvider>- <RecoilRoot- initializeState={(snapshot) => {- seedRun(snapshot, true);- getDefaultStore().set(pendingSteersByConvoId(CONVO_ID), [- {- steerId: 'local-race',- text: 'changed my mind',- status: 'failed',- createdAt: 4,- },- ]);- }}- >- <SteerHostTestProvider>- <PaneSettings>- <RewakePublisher rewake={rewake}>- <Tree />- </RewakePublisher>- </PaneSettings>- </SteerHostTestProvider>- </RecoilRoot>+ <QueryClientProvider client={queryClient}>+ <RecoilRoot+ initializeState={(snapshot) => {+ seedRun(snapshot, true);+ getDefaultStore().set(pendingSteersByConvoId(CONVO_ID), [+ {+ steerId: 'local-race',+ text: 'changed my mind',+ status: 'failed',+ createdAt: 4,+ },+ ]);+ }}+ >+ <SteerHostTestProvider>+ <PaneSettings>+ <RewakePublisher rewake={rewake}>+ <Tree />+ </RewakePublisher>+ </PaneSettings>+ </SteerHostTestProvider>+ </RecoilRoot>+ </QueryClientProvider></ComposerRestoreProvider>,);act(() => {@@ -391,25 +428,27 @@ describe('useSteerRecovery', () => {};render(<ComposerRestoreProvider>- <RecoilRoot- initializeState={(snapshot) => {- seedRun(snapshot, true);- getDefaultStore().set(pendingSteersByConvoId(CONVO_ID), [- {- steerId: 'local-vanish',- text: 'do not lose me',- status: 'failed',- createdAt: 4,- },- ]);- }}- >- <SteerHostTestProvider>- <PaneSettings>- <Tree />- </PaneSettings>- </SteerHostTestProvider>- </RecoilRoot>+ <QueryClientProvider client={queryClient}>+ <RecoilRoot+ initializeState={(snapshot) => {+ seedRun(snapshot, true);+ getDefaultStore().set(pendingSteersByConvoId(CONVO_ID), [+ {+ steerId: 'local-vanish',+ text: 'do not lose me',+ status: 'failed',+ createdAt: 4,+ },+ ]);+ }}+ >+ <SteerHostTestProvider>+ <PaneSettings>+ <Tree />+ </PaneSettings>+ </SteerHostTestProvider>+ </RecoilRoot>+ </QueryClientProvider></ComposerRestoreProvider>,);act(() => {@@ -559,21 +598,23 @@ describe('useSteerRecovery', () => {return null;};const Tree = ({ live }: { live: boolean }) => (- <RecoilRoot- initializeState={(snapshot) => {- seedRun(snapshot, true);- getDefaultStore().set(pendingSteersByConvoId(CONVO_ID), [- { steerId: 'local-late', text: 'landed too late', status: 'failed', createdAt: 3 },- ]);- }}- >- <SteerHostTestProvider>- <PaneSettings>- <Observer />- {live && <Recovery />}- </PaneSettings>- </SteerHostTestProvider>- </RecoilRoot>+ <QueryClientProvider client={queryClient}>+ <RecoilRoot+ initializeState={(snapshot) => {+ seedRun(snapshot, true);+ getDefaultStore().set(pendingSteersByConvoId(CONVO_ID), [+ { steerId: 'local-late', text: 'landed too late', status: 'failed', createdAt: 3 },+ ]);+ }}+ >+ <SteerHostTestProvider>+ <PaneSettings>+ <Observer />+ {live && <Recovery />}+ </PaneSettings>+ </SteerHostTestProvider>+ </RecoilRoot>+ </QueryClientProvider>);const { rerender } = render(<Tree live={true} />);@@ -630,20 +671,22 @@ describe('useSteerRecovery', () => {};render(- <RecoilRoot- initializeState={(snapshot) => {- seedRun(snapshot, true);- getDefaultStore().set(pendingSteersByConvoId(CONVO_ID), [- { steerId: 'local-nav', text: 'still running', status: 'failed', createdAt: 2 },- ]);- }}- >- <SteerHostTestProvider>- <PaneSettings>- <Tree />- </PaneSettings>- </SteerHostTestProvider>- </RecoilRoot>,+ <QueryClientProvider client={queryClient}>+ <RecoilRoot+ initializeState={(snapshot) => {+ seedRun(snapshot, true);+ getDefaultStore().set(pendingSteersByConvoId(CONVO_ID), [+ { steerId: 'local-nav', text: 'still running', status: 'failed', createdAt: 2 },+ ]);+ }}+ >+ <SteerHostTestProvider>+ <PaneSettings>+ <Tree />+ </PaneSettings>+ </SteerHostTestProvider>+ </RecoilRoot>+ </QueryClientProvider>,);act(() => {diff --git a/client/src/hooks/Chat/__tests__/useSteering.spec.tsx b/client/src/hooks/Chat/__tests__/useSteering.spec.tsxindex bb74a090e3..b7619b67fe 100644--- a/client/src/hooks/Chat/__tests__/useSteering.spec.tsx+++ b/client/src/hooks/Chat/__tests__/useSteering.spec.tsx@@ -3,7 +3,7 @@ import { useSteering } from '@librechat/chat/react';import { RecoilRoot, type MutableSnapshot } from 'recoil';import { claimQueuedIntent, releaseQueuedIntent } from '@librechat/chat';import { act, render, renderHook, waitFor } from '@testing-library/react';-import { isSubmittingFamily, resetSubmitting } from '@librechat/chat/react';+import { useQueueDrain, isSubmittingFamily, resetSubmitting } from '@librechat/chat/react';import {getDefaultStore,Provider as JotaiProvider,@@ -58,7 +58,6 @@ import { duringRunActionAtom } from '~/store/duringRun';import { SteerHostTestProvider } from 'test/steerHost';import { applyPendingAction } from '~/utils/approval';import English from '~/locales/en/translation.json';-import useQueueDrain from '../useQueueDrain';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;diff --git a/client/src/hooks/Chat/index.ts b/client/src/hooks/Chat/index.tsindex 136e6e1cfb..838a4afcd7 100644--- a/client/src/hooks/Chat/index.ts+++ b/client/src/hooks/Chat/index.ts@@ -4,5 +4,3 @@ export { default as useTokenUsage } from './useTokenUsage';export { default as useChatFunctions } from './useChatFunctions';export { default as useIdChangeEffect } from './useIdChangeEffect';export { default as useFocusChatEffect } from './useFocusChatEffect';-export { default as useQueueDrain } from './useQueueDrain';-export { default as useQueuedTurnReveal } from './useQueuedTurnReveal';diff --git a/packages/chat/src/core/steer/types.ts b/packages/chat/src/core/steer/types.tsindex 2a4a70ef33..d5e10ed7ea 100644--- a/packages/chat/src/core/steer/types.ts+++ b/packages/chat/src/core/steer/types.ts@@ -118,6 +118,24 @@ export type QueuedMessageOrigin = {afterIds: string[];};+/** The host's `ask`, as the drain calls it to send one queued message as a new turn. The+ * overrides carry everything the message was queued with, so `ask` does not take what the+ * composer has staged for the user's next message instead. Returns `false` when it refused+ * without sending, which puts the message back in the queue. */+export type QueuedTurnAsk = (+ props: { text: string; overrideUserMessageId?: string },+ options: {+ overrideFiles: NonNullable<QueuedMessage['files']>;+ overrideQuotes: string[];+ overrideManualSkills: string[];+ overrideReasoning: QueuedMessage['reasoningOverride'] | null;+ overrideClientRequestId?: string;+ overrideRecoverySteerId?: string;+ overrideExpectedPredecessorCreatedAt?: number;+ overrideQueuedMessageOrigin?: QueuedMessageOrigin;+ },+) => false | void;+export type SettledQueuedTurnReceipt = {clientRequestId: string;status: 'admitted' | 'admitted_pending_boundary' | 'indeterminate' | 'cancelled' | 'dead';diff --git a/packages/chat/src/react.ts b/packages/chat/src/react.tsindex 296e0f347f..696138e30a 100644--- a/packages/chat/src/react.ts+++ b/packages/chat/src/react.ts@@ -69,7 +69,10 @@ export {export { SteerHostProvider, useSteerHost } from './react/steer/host';export type {SteerHost,+ SteerPane,SteerSettings,+ QueuedTurnCache,+ QueuedTurnSnapshot,SteerMessageKey,SteerNotification,SteerRequestCallbacks,@@ -95,3 +98,12 @@ export type { ConvertibleSteer, SteerConvertOptions } from './react/steering/useexport { default as useSteerEscalate } from './react/steering/useSteerEscalate';export type { EscalateTarget } from './react/steering/useSteerEscalate';export { resolveAcknowledgedSteer } from './react/steering/chips';+export { default as useQueueDrain } from './react/steering/useQueueDrain';+export { default as useSteerRecovery } from './react/steering/useSteerRecovery';+export type { SteerRecoveryActions } from './react/steering/useSteerRecovery';+export {+ default as useQueuedTurnReveal,+ hasRevealSuccessor,+ shouldRollbackReveal,+ buildRevealedMessage,+} from './react/steering/useQueuedTurnReveal';diff --git a/packages/chat/src/react/steer/__tests__/host.spec.tsx b/packages/chat/src/react/steer/__tests__/host.spec.tsxindex d759a55fa8..fcfda4f692 100644--- a/packages/chat/src/react/steer/__tests__/host.spec.tsx+++ b/packages/chat/src/react/steer/__tests__/host.spec.tsx@@ -8,6 +8,12 @@ import { SteerHostProvider, useSteerHost } from '../host';const createHost = (label: string): SteerHost => ({useSteerMessage: () => () => undefined,+ useSteerMessageAsync: () => async () => ({+ status: 'queued',+ steerId: 'steer-1',+ position: 0,+ conversationId: 'convo-1',+ }),useCancelSteer: () => async () => ({ removed: true }),useArmSteer: () => async () => ({ armed: true }),useMarkFilesUsage: () => () => undefined,@@ -16,6 +22,7 @@ const createHost = (label: string): SteerHost => ({throw new Error('not queued');},useQueuedTurns: () => undefined,+ useQueuedTurnCache: () => ({ read: () => ({}), subscribe: () => () => undefined }),useFetchStreamStatus: () => async () => ({ active: false }),useLatestMessage: () => null,useCodeApprovalMode: () => undefined,@@ -23,7 +30,11 @@ const createHost = (label: string): SteerHost => ({useNotify: () => () => undefined,useFileMap: () => undefined,useClearFilesToDelete: () => () => undefined,- useSettings: () => ({ duringRunDefaultAction: 'steer', setDuringRunDefaultAction: () => {} }),+ useSettings: () => ({+ duringRunDefaultAction: 'steer',+ setDuringRunDefaultAction: () => {},+ getPaneConversations: () => [],+ }),});const translate = (host: SteerHost) => host.useLocalize()('com_ui_steer_cancel_failed');diff --git a/packages/chat/src/react/steer/host.tsx b/packages/chat/src/react/steer/host.tsxindex 316b9b04db..811226f13a 100644--- a/packages/chat/src/react/steer/host.tsx+++ b/packages/chat/src/react/steer/host.tsx@@ -18,6 +18,7 @@ import type {ChatTransportError,ChatCancelSteerResult,} from '../../core/types';+import type { StreamStatusResponse } from '../../core/resumable/host';import type { FileDeliveryMetadataMap } from '../../core/files';/** Callbacks of a fire-and-forget request, called once it settles. */@@ -41,6 +42,13 @@ export type SteerMessageKey =| 'com_ui_steer_paused_queued'| 'com_ui_steer_preempt_unsupported';+/** One mounted chat pane and the conversation it shows. */+export type SteerPane = {+ /** The pane key, as the app keys its panes (`0` for the main chat). */+ index: string | number;+ conversationId: string | null;+};+/** The app-global preferences and deployment limits the steer hooks read. */export type SteerSettings = {duringRunDefaultAction: DuringRunAction;@@ -48,6 +56,22 @@ export type SteerSettings = {queuedSendLockTimeoutMs?: number;queuedTurnReconciliationTimeoutMs?: number;steerArmConfirmationTimeoutMs?: number;+ /** The conversation each mounted chat pane shows, read when called rather than at render:+ * steer recovery asks whether any pane holding a conversation is still running. */+ getPaneConversations: () => ReadonlyArray<SteerPane>;+};++/** What the host's caches already hold about a conversation's queued-turn handoff. */+export type QueuedTurnSnapshot = {+ receipts?: TAgentQueuedTurnReceipt[];+ status?: StreamStatusResponse;+};++/** Reads the cached handoff of one conversation without fetching it, and subscribes to changes+ * of it. Both functions keep their identity while the conversation does. */+export type QueuedTurnCache = {+ read: () => QueuedTurnSnapshot;+ subscribe: (notify: () => void) => () => void;};/**@@ -61,6 +85,9 @@ export interface SteerHost {request: ChatSteerRequest,callbacks?: SteerRequestCallbacks<ChatSteerResult>,) => void;+ /** Posts a steer and settles with the server's answer even after the caller unmounts, which a+ * retry from the thread needs: its row unmounts when the user navigates away mid-request. */+ useSteerMessageAsync(): (request: ChatSteerRequest) => Promise<ChatSteerResult>;/** Withdraws a steer that has not been injected yet. */useCancelSteer(): (request: ChatSteerTarget & { clientSteerId?: string },@@ -87,6 +114,9 @@ export interface SteerHost {reconcileUntil: number | undefined,expectsReceipts: boolean,): TAgentQueuedTurnReceipt[] | undefined;+ /** The queued-turn receipts and stream status the host has cached for a conversation, observed+ * without registering a competing fetcher. */+ useQueuedTurnCache(conversationId: string): QueuedTurnCache;/** Reads a conversation's generation state, including steers it could not deliver. */useFetchStreamStatus(): (conversationId: string) => Promise<ChatStreamStatus>;/** The latest message of the pane, on the branch on screen. */diff --git a/client/src/hooks/Chat/useQueueDrain.ts b/packages/chat/src/react/steering/useQueueDrain.tssimilarity index 95%rename from client/src/hooks/Chat/useQueueDrain.tsrename to packages/chat/src/react/steering/useQueueDrain.tsindex ed48077c27..65c039e5a8 100644--- a/client/src/hooks/Chat/useQueueDrain.ts+++ b/packages/chat/src/react/steering/useQueueDrain.ts@@ -1,19 +1,20 @@import { useRef, useEffect, useMemo, useCallback } from 'react';import { useAtomValue, useStore } from 'jotai';-import { recoveryDisposition, canRestoreRecovery } from '@librechat/chat';-import { revealedQueuedTurnFamily, useIsSubmitting } from '@librechat/chat/react';import { Constants, DEFAULT_QUEUED_SEND_LOCK_TIMEOUT_MS } from 'librechat-data-provider';-import { acquireQueueSendLock, releaseQueueSendLock, hasQueuedIntent } from '@librechat/chat';-import {- settledQueuedTurnReceiptsByConvoId,- pendingQueuedTurnEnqueueIdsByConvoId,- pendingRunEndByConvoId,- queuedMessagesByConvoId,- drainAfterAbortByIndex,- runEndByIndex,- recoveryDispositionsFamily,-} from '@librechat/chat/react';+import type {+ QueueSendLock,+ QueuedTurnAsk,+ QueuedMessage,+ QueuedMessageOrigin,+ RunEnd,+} from '../../core';import {+ mergeQueuedMessages,+ recoveryDisposition,+ canRestoreRecovery,+ acquireQueueSendLock,+ releaseQueueSendLock,+ hasQueuedIntent,parkRunEnd,batchFileIds,pickDrainable,@@ -24,12 +25,19 @@ import {selectQueuedTurnReveal,consumeAdmittedBoundary,QUEUE_USAGE_RENEW_INTERVAL_MS,-} from '@librechat/chat';-import type { QueueSendLock, QueuedMessage, QueuedMessageOrigin, RunEnd } from '@librechat/chat';-import type { TAskFunction } from '~/common';-import { useChatSettings } from '~/Providers/ChatSettingsContext';-import { useMarkFilesUsageMutation } from '~/data-provider';-import { mergeQueuedMessages } from '~/utils/queue';+} from '../../core';+import {+ settledQueuedTurnReceiptsByConvoId,+ pendingQueuedTurnEnqueueIdsByConvoId,+ pendingRunEndByConvoId,+ queuedMessagesByConvoId,+ drainAfterAbortByIndex,+ runEndByIndex,+} from '../steer/queue';+import { recoveryDispositionsFamily } from '../steer/recovery';+import { revealedQueuedTurnFamily } from '../steer/atoms';+import { useIsSubmitting } from '../submission';+import { useSteerHost } from '../steer/host';/*** Auto-sends queued follow-up messages when a run finishes.@@ -49,9 +57,9 @@ import { mergeQueuedMessages } from '~/utils/queue';export default function useQueueDrain(index: string | number,activeConversationId: string | undefined,- ask: TAskFunction,+ ask: QueuedTurnAsk,revealQueuedTurn?: (item: QueuedMessage, end: RunEnd) => void,-) {+): void {const jotaiStore = useStore();const runEnd = useAtomValue(runEndByIndex(index));const parkedRunEnd = useAtomValue(@@ -63,9 +71,10 @@ export default function useQueueDrain(const sendLockKey = String(index);const sendLockRef = useRef<QueueSendLock | null>(null);const revealLockRef = useRef(false);- const { mutate: markFilesUsage } = useMarkFilesUsageMutation();- const { config } = useChatSettings();- const sendLockTimeoutMs = config.queuedSendLockTimeoutMs ?? DEFAULT_QUEUED_SEND_LOCK_TIMEOUT_MS;+ const host = useSteerHost();+ const markFilesUsage = host.useMarkFilesUsage();+ const { queuedSendLockTimeoutMs } = host.useSettings();+ const sendLockTimeoutMs = queuedSendLockTimeoutMs ?? DEFAULT_QUEUED_SEND_LOCK_TIMEOUT_MS;const ownQueue = useAtomValue(queuedMessagesByConvoId(activeConversationId ?? Constants.NEW_CONVO),);diff --git a/client/src/hooks/Chat/useQueuedTurnReveal.ts b/packages/chat/src/react/steering/useQueuedTurnReveal.tssimilarity index 81%rename from client/src/hooks/Chat/useQueuedTurnReveal.tsrename to packages/chat/src/react/steering/useQueuedTurnReveal.tsindex cb9ffcd6fa..d7575fd617 100644--- a/client/src/hooks/Chat/useQueuedTurnReveal.ts+++ b/packages/chat/src/react/steering/useQueuedTurnReveal.ts@@ -1,22 +1,12 @@import { useCallback, useEffect, useSyncExternalStore } from 'react';import { useStore, useAtomValue } from 'jotai';-import { QueryKeys } from 'librechat-data-provider';-import { useQueryClient } from '@tanstack/react-query';-import { isAdmissibleQueuedTurn } from '@librechat/chat';-import {- revealedQueuedTurnFamily,- activeGenerationCreatedAtByConvoId,- useIsSubmitting,- isSubmittingFamily,-} from '@librechat/chat/react';import type { TMessage, TAgentQueuedTurnReceipt } from 'librechat-data-provider';-import type { RevealedQueuedTurn } from '@librechat/chat/react';-import type { QueuedMessage, RunEnd } from '@librechat/chat';-import type { StreamStatusResponse } from '~/data-provider/SSE/queries';-import { agentQueuedTurnsQueryKey } from '~/data-provider/SSE/queuedTurns';-import { streamStatusQueryKey } from '~/data-provider/SSE/queries';--export { selectQueuedTurnReveal } from '@librechat/chat';+import type { RevealedQueuedTurn } from '../steer/atoms';+import type { QueuedMessage, RunEnd } from '../../core';+import { revealedQueuedTurnFamily, activeGenerationCreatedAtByConvoId } from '../steer/atoms';+import { useIsSubmitting, isSubmittingFamily } from '../submission';+import { isAdmissibleQueuedTurn } from '../../core';+import { useSteerHost } from '../steer/host';/** The thread has moved past the response the reveal follows: the admitted* turn, or any other turn, now parents on it. */@@ -65,19 +55,14 @@ export default function useQueuedTurnReveal(index: string | number = 0,): (item: QueuedMessage, end: RunEnd) => void {const jotaiStore = useStore();- const queryClient = useQueryClient();const revealKey = conversationId ?? '';+ const { read: readCache, subscribe } = useSteerHost().useQueuedTurnCache(revealKey);const reveal = useAtomValue(revealedQueuedTurnFamily(revealKey));const isSubmitting = useIsSubmitting(index);const activeEpoch = useAtomValue(activeGenerationCreatedAtByConvoId(revealKey));const readHandoff = useCallback((intent: RevealedQueuedTurn) => {- const receipts = queryClient.getQueryData<TAgentQueuedTurnReceipt[]>(- agentQueuedTurnsQueryKey(revealKey),- );- const status = queryClient.getQueryData<StreamStatusResponse>(- streamStatusQueryKey(revealKey),- );+ const { receipts, status } = readCache();const submitting = jotaiStore.get(isSubmittingFamily(index));let generationCreatedAt = intent.generationCreatedAt;let waiting = false;@@ -110,20 +95,7 @@ export default function useQueuedTurnReveal(status.createdAt > generationCreatedAt))),};},- [queryClient, jotaiStore, index, revealKey, activeEpoch],- );- const subscribe = useCallback(- (notify: () => void) =>- queryClient.getQueryCache().subscribe((event) => {- const key = event?.query.queryKey;- if (- key?.[1] === revealKey &&- (key[0] === QueryKeys.agentQueuedTurns || key[0] === 'streamStatus')- ) {- notify();- }- }),- [queryClient, revealKey],+ [readCache, jotaiStore, index, activeEpoch],);/** Only ownership facts trigger a render, not every receipt poll. Remember* an admitted successor's effective boundary even after its receipt leavesdiff --git a/client/src/hooks/Chat/useSteerRecovery.ts b/packages/chat/src/react/steering/useSteerRecovery.tssimilarity index 92%rename from client/src/hooks/Chat/useSteerRecovery.tsrename to packages/chat/src/react/steering/useSteerRecovery.tsindex 82ba229fe2..fdd41e1618 100644--- a/client/src/hooks/Chat/useSteerRecovery.ts+++ b/packages/chat/src/react/steering/useSteerRecovery.ts@@ -1,33 +1,42 @@import { useCallback } from 'react';import { useStore } from 'jotai';-import { useComposerRestoreHost } from '@librechat/chat/react';-import { getSteerErrorCode, isDefiniteSteerRejection } from '@librechat/chat';+import type { PendingSteer } from '../../core';import {- useSteerRehome,- useSteerConvert,- isSubmittingFamily,- pendingSteersByConvoId,- resolveAcknowledgedSteer,- pendingSteerCancelClientIdsFamily,-} from '@librechat/chat/react';-import type { PendingSteer } from '@librechat/chat';-import { useSteerMessageMutation, useCancelSteerMutation } from '~/data-provider';-import { carriedSteerContext, isLegacyDeliveryUncertain } from '~/utils';-import { useChatSettings } from '~/Providers/ChatSettingsContext';+ getSteerErrorCode,+ carriedSteerContext,+ isDefiniteSteerRejection,+ isLegacyDeliveryUncertain,+} from '../../core';+import { pendingSteersByConvoId, pendingSteerCancelClientIdsFamily } from '../steer/atoms';+import { useComposerRestoreHost } from '../steer/restore';+import { isSubmittingFamily } from '../submission';+import { resolveAcknowledgedSteer } from './chips';+import { useSteerRehome } from './useSteerCancel';+import useSteerConvert from './useSteerConvert';+import { useSteerHost } from '../steer/host';/*** Retry or re-route a pending steer from OUTSIDE the composer. The thread's* pending block needs these actions without dragging the whole* `SteeringControls` object through the message tree.*/-export default function useSteerRecovery(conversationId: string) {- const { mutateAsync: steerMessage } = useSteerMessageMutation();- const { mutateAsync: cancelSteer } = useCancelSteerMutation();+/** The actions a failed or uncertain steer row offers. */+export type SteerRecoveryActions = {+ /** Resend the steer into the run it was written for. */+ retry: (steerId: string) => void;+ /** Move a failed steer into the queue: it sends when the reply finishes. */+ sendAsNew: (steerId: string) => void;+};++export default function useSteerRecovery(conversationId: string): SteerRecoveryActions {+ const host = useSteerHost();+ const steerMessage = host.useSteerMessageAsync();+ const cancelSteer = host.useCancelSteer();const convertSteersToQueued = useSteerConvert();const rehomeSteer = useSteerRehome(conversationId);const { rewakeDrain } = useComposerRestoreHost();const jotaiStore = useStore();- const { getPaneConversations } = useChatSettings();+ const { getPaneConversations } = host.useSettings();/** Whether the run this steer belongs to has finished, read live at ack time.* Unmounting is not the same signal: `PendingSteers` also unmounts when the