refactor: Imports to Prevent Circular Type Refs (#8423)

This commit is contained in:
Danny Avila 2025-07-12 11:37:07 -04:00 committed by GitHub
parent f1b29ffb45
commit 170cc340d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 201 additions and 196 deletions

View file

@ -1,7 +1,7 @@
import { Spinner } from '~/components/svg';
import { useLocalize } from '~/hooks';
import VersionItem from './VersionItem';
import { VersionContext } from './VersionPanel';
import type { VersionContext } from './types';
type VersionContentProps = {
selectedAgentId: string;

View file

@ -1,5 +1,5 @@
import { useLocalize } from '~/hooks';
import { VersionRecord } from './VersionPanel';
import type { VersionRecord } from './types';
type VersionItemProps = {
version: VersionRecord;

View file

@ -1,44 +1,13 @@
import { ChevronLeft } from 'lucide-react';
import { useCallback, useMemo } from 'react';
import { useGetAgentByIdQuery, useRevertAgentVersionMutation } from '~/data-provider';
import type { Agent } from 'librechat-data-provider';
import type { AgentWithVersions, VersionContext } from './types';
import { isActiveVersion } from './isActiveVersion';
import { useAgentPanelContext } from '~/Providers';
import { useLocalize, useToast } from '~/hooks';
import VersionContent from './VersionContent';
import { Panel } from '~/common';
export type VersionRecord = Record<string, any>;
export type AgentState = {
name: string | null;
description: string | null;
instructions: string | null;
artifacts?: string | null;
capabilities?: string[];
tools?: string[];
} | null;
export type VersionWithId = {
id: number;
originalIndex: number;
version: VersionRecord;
isActive: boolean;
};
export type VersionContext = {
versions: VersionRecord[];
versionIds: VersionWithId[];
currentAgent: AgentState;
selectedAgentId: string;
activeVersion: VersionRecord | null;
};
export interface AgentWithVersions extends Agent {
capabilities?: string[];
versions?: Array<VersionRecord>;
}
export default function VersionPanel() {
const localize = useLocalize();
const { showToast } = useToast();

View file

@ -1,4 +1,4 @@
import { AgentState, VersionRecord } from './VersionPanel';
import type { AgentState, VersionRecord } from './types';
export const isActiveVersion = (
version: VersionRecord,

View file

@ -0,0 +1,35 @@
export type VersionRecord = Record<string, any>;
export type AgentState = {
name: string | null;
description: string | null;
instructions: string | null;
artifacts?: string | null;
capabilities?: string[];
tools?: string[];
} | null;
export type VersionWithId = {
id: number;
originalIndex: number;
version: VersionRecord;
isActive: boolean;
};
export type VersionContext = {
versions: VersionRecord[];
versionIds: VersionWithId[];
currentAgent: AgentState;
selectedAgentId: string;
activeVersion: VersionRecord | null;
};
export interface AgentWithVersions {
name: string;
description: string | null;
instructions: string | null;
artifacts?: string | null;
capabilities?: string[];
tools?: string[];
versions?: Array<VersionRecord>;
}