diff --git a/bun.lock b/bun.lock index ed26a7444f..74d2e726bf 100644 --- a/bun.lock +++ b/bun.lock @@ -455,6 +455,7 @@ "@types/jest": "^29.5.2", "@types/react": "^18.2.11", "babel-plugin-replace-ts-export-assignment": "^0.0.2", + "framer-motion": "^12.40.0", "i18next": "^24.2.2", "jest": "^30.2.0", "jest-environment-jsdom": "^30.2.0", @@ -470,6 +471,8 @@ "micromark-extension-gfm": "^3.0.0", "micromark-extension-math": "^3.1.0", "react": "^18.2.0", + "react-dnd": "^16.0.1", + "react-dnd-html5-backend": "^16.0.1", "react-dom": "^18.2.0", "react-i18next": "^15.4.0", "rimraf": "^6.1.3", @@ -481,6 +484,7 @@ "@ariakit/react": "^0.4.29", "@librechat/client": "*", "@radix-ui/react-dialog": "^1.1.23", + "framer-motion": "^12.40.0", "jotai": "^2.12.5", "librechat-data-provider": "*", "lucide": "^0.528.0", @@ -493,6 +497,8 @@ "micromark-extension-gfm": "^3.0.0", "micromark-extension-math": "^3.1.0", "react": "^18.2.0 || ^19.1.0", + "react-dnd": "^16.0.1", + "react-dnd-html5-backend": "^16.0.1", "react-dom": "^18.2.0 || ^19.1.0", "uuid": "^11.1.1", }, diff --git a/client/src/components/Chat/Input/Composer/Queue.tsx b/client/src/components/Chat/Input/Composer/Queue.tsx index 143164a80f..2b243a77b2 100644 --- a/client/src/components/Chat/Input/Composer/Queue.tsx +++ b/client/src/components/Chat/Input/Composer/Queue.tsx @@ -1,850 +1 @@ -import { memo, useId, useRef, useMemo, useState, useCallback } from 'react'; -import { useAtomValue } from 'jotai'; -import { createPortal } from 'react-dom'; -import * as Ariakit from '@ariakit/react'; -import { useDrag, useDrop } from 'react-dnd'; -import { queuedMessagesByConvoId } from '@librechat/chat/react'; -import { AnimatePresence, motion, useReducedMotion } from 'framer-motion'; -import { useQueuedTurnPortal, EscalateNowButton } from '@librechat/chat/components'; -import { claimQueuedIntent, releaseQueuedIntent, hasQueuedIntent } from '@librechat/chat'; -import { - escalatingSteerFamily, - revealedQueuedTurnFamily, - pendingSteersByConvoId, -} from '@librechat/chat/react'; -import { - Button, - IconButton, - TooltipAnchor, - DropdownPopup, - useMediaQuery, - useToastContext, -} from '@librechat/client'; -import { - Clock, - Trash2, - Pencil, - Ellipsis, - TextQuote, - CirclePlay, - CirclePause, - GripVertical, - TriangleAlert, - MessageSquarePlus, -} from 'lucide-react'; -import type { RestoreToComposer } from '@librechat/chat/react'; -import type { SteeringControls } from '@librechat/chat/react'; -import type { MenuItemProps } from '@librechat/client'; -import type { QueuedMessage } from '@librechat/chat'; -import { useLocalize } from '~/hooks'; -import { cn } from '~/utils'; - -const DRAG_TYPE = 'queued-message'; - -/** One timing for a row entering or leaving the rail, so a message that sends reads as - * the rail closing up behind it rather than a row vanishing. */ -const ROW_TRANSITION = { - height: { duration: 0.26, ease: [0.4, 0, 0.2, 1] }, - opacity: { duration: 0.16, ease: 'easeOut' }, -} as const; - -interface DragItem { - id: string; - index: number; - /** The order the drag started from, so abandoning it puts things back. */ - order: string[]; - /** Avoid repeating the same refusal while the pointer remains over a blocked row. */ - blockedTarget?: number; -} - -interface QueueProps { - steering: SteeringControls; - conversationId: string; - onRestoreToComposer: RestoreToComposer; - /** Whether the composer would take this conversation's words right now. */ - canRestoreToComposer: (conversationId: string) => boolean; - /** Owned by the composer host: opens a fresh chat that starts with these words. */ - onStartNewChat: (text: string) => void; -} - -interface QueueRowProps { - message: QueuedMessage; - index: number; - total: number; - /** Every queued id in order, captured when a drag starts so abandoning it - * can put the queue back the way it was. */ - order: string[]; - /** A server-owned row is a durable ordering boundary. */ - serverOwnedIds: ReadonlySet; - steering: SteeringControls; - conversationId: string; - /** One interrupt at a time: an arm is already unresolved somewhere. */ - interruptPending: boolean; - /** Owned by the rail, so the keys are stated once rather than once per row, - * and scoped to THIS rail, so a split view has one hint per pane. */ - reorderHintId: string; - onRestoreToComposer: RestoreToComposer; - canRestoreToComposer: (conversationId: string) => boolean; - onStartNewChat: (text: string) => void; - /** The server has revealed this row as the next user turn; only removal remains meaningful. */ - revealed?: boolean; - /** The matching user turn owns this row's actions when its bubble is visible. */ - portalElement?: HTMLSpanElement; - onAnnounce: (message: string) => void; -} - -function QueuedIcon({ warning, hint }: { warning: boolean; hint?: string }) { - if (warning) { - return