import React from "react"; import { useTranslation } from "react-i18next"; import { useScrollToBottom } from "#/hooks/use-scroll-to-bottom"; import { JupyterCell } from "./jupyter-cell"; import { ScrollToBottomButton } from "#/components/shared/buttons/scroll-to-bottom-button"; import { RUNTIME_INACTIVE_STATES } from "#/types/agent-state"; import { I18nKey } from "#/i18n/declaration"; import JupyterLargeIcon from "#/icons/jupyter-large.svg?react"; import { WaitingForRuntimeMessage } from "../chat/waiting-for-runtime-message"; import { useAgentState } from "#/hooks/use-agent-state"; import { useJupyterStore } from "#/state/jupyter-store"; interface JupyterEditorProps { maxWidth: number; } export function JupyterEditor({ maxWidth }: JupyterEditorProps) { const { curAgentState } = useAgentState(); const cells = useJupyterStore((state) => state.cells); const jupyterRef = React.useRef(null); const { t } = useTranslation(); const isRuntimeInactive = RUNTIME_INACTIVE_STATES.includes(curAgentState); const { hitBottom, scrollDomToBottom, onChatBodyScroll } = useScrollToBottom(jupyterRef); return ( <> {isRuntimeInactive && } {!isRuntimeInactive && cells.length > 0 && (
onChatBodyScroll(e.currentTarget)} > {cells.map((cell, index) => ( ))}
{!hitBottom && (
)}
)} {!isRuntimeInactive && cells.length === 0 && (
{t(I18nKey.COMMON$JUPYTER_EMPTY_MESSAGE)}
)} ); }