mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-19 06:23:32 +00:00
* refactor: Read the Thread Panel's Jotai State Through the Chat Surface * refactor: Move the Subagent Thread Panel Into @librechat/chat * test: Spec the Subagent Thread Panel Against Fake Hosts * test: Cover the App Subagents Host Adapters the Panel Move Relies On * fix: Style the Moved Subagent Panel With Shared Variants * test: Pin the Shared Variants the Panel Draws Its Picker and Inline Actions With * perf: Keep the Subagent Thread Panel Out of the Boot Bundle
28 lines
1 KiB
TypeScript
28 lines
1 KiB
TypeScript
import { useCallback } from 'react';
|
|
import { useAtom, useAtomValue, useStore } from 'jotai';
|
|
import type { SubagentControlUiState } from './state';
|
|
import type { SubagentPanelState } from './context';
|
|
import {
|
|
subagentControlStateByTask,
|
|
subagentPanelFocusRequest,
|
|
useSubagentProgress,
|
|
} from './state';
|
|
import { useSubagentActivityStream } from './stream';
|
|
|
|
function useControlStateWriter(): (identity: string, state: SubagentControlUiState | null) => void {
|
|
const store = useStore();
|
|
return useCallback(
|
|
(identity: string, state: SubagentControlUiState | null) =>
|
|
store.set(subagentControlStateByTask(identity), state),
|
|
[store],
|
|
);
|
|
}
|
|
|
|
/** The panel state `ChatSurfaceProvider` supplies: the atoms behind `SubagentPanelState`. */
|
|
export const subagentPanelState: SubagentPanelState = {
|
|
useFocusRequest: () => useAtomValue(subagentPanelFocusRequest),
|
|
useProgress: useSubagentProgress,
|
|
useControlState: (identity) => useAtom(subagentControlStateByTask(identity)),
|
|
useControlStateWriter,
|
|
useActivityStream: useSubagentActivityStream,
|
|
};
|