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: Replace Sandpack Code Editor with Monaco for Artifact Editing (#12109)
Danny Avila771227ecf91d
diff --git a/client/package.json b/client/package.jsonindex 0f7ffed04c..31e75c4702 100644--- a/client/package.json+++ b/client/package.json@@ -38,6 +38,7 @@"@librechat/client": "*","@marsidev/react-turnstile": "^1.1.0","@mcp-ui/client": "^5.7.0",+ "@monaco-editor/react": "^4.7.0","@radix-ui/react-accordion": "^1.1.2","@radix-ui/react-alert-dialog": "1.0.2","@radix-ui/react-checkbox": "^1.0.3",@@ -146,6 +147,7 @@"jest": "^30.2.0","jest-canvas-mock": "^2.5.2","jest-environment-jsdom": "^30.2.0",+ "monaco-editor": "^0.55.0","jest-file-loader": "^1.0.3","jest-junit": "^16.0.0","postcss": "^8.4.31",diff --git a/client/src/components/Artifacts/ArtifactCodeEditor.tsx b/client/src/components/Artifacts/ArtifactCodeEditor.tsxindex 4ab2b182b8..ddf8dc84fa 100644--- a/client/src/components/Artifacts/ArtifactCodeEditor.tsx+++ b/client/src/components/Artifacts/ArtifactCodeEditor.tsx@@ -1,206 +1,326 @@-import React, { useMemo, useState, useEffect, useRef, memo } from 'react';+import React, { useMemo, useState, useEffect, useRef, useCallback } from 'react';import debounce from 'lodash/debounce';-import { KeyBinding } from '@codemirror/view';-import { autocompletion, completionKeymap } from '@codemirror/autocomplete';-import {- useSandpack,- SandpackCodeEditor,- SandpackProvider as StyledProvider,-} from '@codesandbox/sandpack-react';-import type { SandpackProviderProps } from '@codesandbox/sandpack-react/unstyled';-import type { SandpackBundlerFile } from '@codesandbox/sandpack-client';-import type { CodeEditorRef } from '@codesandbox/sandpack-react';-import type { ArtifactFiles, Artifact } from '~/common';-import { useEditArtifact, useGetStartupConfig } from '~/data-provider';+import MonacoEditor from '@monaco-editor/react';+import type { Monaco } from '@monaco-editor/react';+import type { editor } from 'monaco-editor';+import type { Artifact } from '~/common';import { useMutationState, useCodeState } from '~/Providers/EditorContext';import { useArtifactsContext } from '~/Providers';-import { sharedFiles, sharedOptions } from '~/utils/artifacts';--const CodeEditor = memo(- ({- fileKey,- readOnly,- artifact,- editorRef,- }: {- fileKey: string;- readOnly?: boolean;- artifact: Artifact;- editorRef: React.MutableRefObject<CodeEditorRef>;- }) => {- const { sandpack } = useSandpack();- const [currentUpdate, setCurrentUpdate] = useState<string | null>(null);- const { isMutating, setIsMutating } = useMutationState();- const { setCurrentCode } = useCodeState();- const editArtifact = useEditArtifact({- onMutate: (vars) => {- setIsMutating(true);- setCurrentUpdate(vars.updated);- },- onSuccess: () => {- setIsMutating(false);- setCurrentUpdate(null);- },- onError: () => {- setIsMutating(false);- },- });-- /**- * Create stable debounced mutation that doesn't depend on changing callbacks- * Use refs to always access the latest values without recreating the debounce- */- const artifactRef = useRef(artifact);- const isMutatingRef = useRef(isMutating);- const currentUpdateRef = useRef(currentUpdate);- const editArtifactRef = useRef(editArtifact);- const setCurrentCodeRef = useRef(setCurrentCode);-- useEffect(() => {- artifactRef.current = artifact;- }, [artifact]);-- useEffect(() => {- isMutatingRef.current = isMutating;- }, [isMutating]);-- useEffect(() => {- currentUpdateRef.current = currentUpdate;- }, [currentUpdate]);-- useEffect(() => {- editArtifactRef.current = editArtifact;- }, [editArtifact]);-- useEffect(() => {- setCurrentCodeRef.current = setCurrentCode;- }, [setCurrentCode]);-- /**- * Create debounced mutation once - never recreate it- * All values are accessed via refs so they're always current- */- const debouncedMutation = useMemo(- () =>- debounce((code: string) => {- if (readOnly) {- return;- }- if (isMutatingRef.current) {- return;- }- if (artifactRef.current.index == null) {- return;- }-- const artifact = artifactRef.current;- const artifactIndex = artifact.index;- const isNotOriginal =- code && artifact.content != null && code.trim() !== artifact.content.trim();- const isNotRepeated =- currentUpdateRef.current == null- ? true- : code != null && code.trim() !== currentUpdateRef.current.trim();-- if (artifact.content && isNotOriginal && isNotRepeated && artifactIndex != null) {- setCurrentCodeRef.current(code);- editArtifactRef.current.mutate({- index: artifactIndex,- messageId: artifact.messageId ?? '',- original: artifact.content,- updated: code,- });- }- }, 500),- [readOnly],- );-- /**- * Listen to Sandpack file changes and trigger debounced mutation- */- useEffect(() => {- const currentCode = (sandpack.files['/' + fileKey] as SandpackBundlerFile | undefined)?.code;- if (currentCode) {- debouncedMutation(currentCode);- }- }, [sandpack.files, fileKey, debouncedMutation]);-- /**- * Cleanup: cancel pending mutations when component unmounts or artifact changes- */- useEffect(() => {- return () => {- debouncedMutation.cancel();- };- }, [artifact.id, debouncedMutation]);-- return (- <SandpackCodeEditor- ref={editorRef}- showTabs={false}- showRunButton={false}- showLineNumbers={true}- showInlineErrors={true}- readOnly={readOnly === true}- extensions={[autocompletion()]}- extensionsKeymap={Array.from<KeyBinding>(completionKeymap)}- className="hljs language-javascript bg-black"- />- );- },-);--export const ArtifactCodeEditor = function ({- files,- fileKey,- template,+import { useEditArtifact } from '~/data-provider';++const LANG_MAP: Record<string, string> = {+ javascript: 'javascript',+ typescript: 'typescript',+ python: 'python',+ css: 'css',+ json: 'json',+ markdown: 'markdown',+ html: 'html',+ xml: 'xml',+ sql: 'sql',+ yaml: 'yaml',+ shell: 'shell',+ bash: 'shell',+ tsx: 'typescript',+ jsx: 'javascript',+ c: 'c',+ cpp: 'cpp',+ java: 'java',+ go: 'go',+ rust: 'rust',+ kotlin: 'kotlin',+ swift: 'swift',+ php: 'php',+ ruby: 'ruby',+ r: 'r',+ lua: 'lua',+ scala: 'scala',+ perl: 'perl',+};++const TYPE_MAP: Record<string, string> = {+ 'text/html': 'html',+ 'application/vnd.code-html': 'html',+ 'application/vnd.react': 'typescript',+ 'application/vnd.ant.react': 'typescript',+ 'text/markdown': 'markdown',+ 'text/md': 'markdown',+ 'text/plain': 'plaintext',+ 'application/vnd.mermaid': 'markdown',+};++function getMonacoLanguage(type?: string, language?: string): string {+ if (language && LANG_MAP[language]) {+ return LANG_MAP[language];+ }+ return TYPE_MAP[type ?? ''] ?? 'plaintext';+}++export const ArtifactCodeEditor = function ArtifactCodeEditor({artifact,- editorRef,- sharedProps,+ monacoRef,readOnly: externalReadOnly,}: {- fileKey: string;artifact: Artifact;- files: ArtifactFiles;- template: SandpackProviderProps['template'];- sharedProps: Partial<SandpackProviderProps>;- editorRef: React.MutableRefObject<CodeEditorRef>;+ monacoRef: React.MutableRefObject<editor.IStandaloneCodeEditor | null>;readOnly?: boolean;}) {- const { data: config } = useGetStartupConfig();const { isSubmitting } = useArtifactsContext();- const options: typeof sharedOptions = useMemo(() => {- if (!config) {- return sharedOptions;+ const readOnly = (externalReadOnly ?? false) || isSubmitting;+ const { setCurrentCode } = useCodeState();+ const [currentUpdate, setCurrentUpdate] = useState<string | null>(null);+ const { isMutating, setIsMutating } = useMutationState();+ const editArtifact = useEditArtifact({+ onMutate: (vars) => {+ setIsMutating(true);+ setCurrentUpdate(vars.updated);+ },+ onSuccess: () => {+ setIsMutating(false);+ setCurrentUpdate(null);+ },+ onError: () => {+ setIsMutating(false);+ },+ });++ const artifactRef = useRef(artifact);+ const isMutatingRef = useRef(isMutating);+ const currentUpdateRef = useRef(currentUpdate);+ const editArtifactRef = useRef(editArtifact);+ const setCurrentCodeRef = useRef(setCurrentCode);+ const prevContentRef = useRef(artifact.content ?? '');+ const prevArtifactId = useRef(artifact.id);+ const prevReadOnly = useRef(readOnly);++ artifactRef.current = artifact;+ isMutatingRef.current = isMutating;+ currentUpdateRef.current = currentUpdate;+ editArtifactRef.current = editArtifact;+ setCurrentCodeRef.current = setCurrentCode;++ const debouncedMutation = useMemo(+ () =>+ debounce((code: string) => {+ if (readOnly || isMutatingRef.current || artifactRef.current.index == null) {+ return;+ }+ const art = artifactRef.current;+ const isNotOriginal = art.content != null && code.trim() !== art.content.trim();+ const isNotRepeated =+ currentUpdateRef.current == null ? true : code.trim() !== currentUpdateRef.current.trim();++ if (art.content != null && isNotOriginal && isNotRepeated && art.index != null) {+ setCurrentCodeRef.current(code);+ editArtifactRef.current.mutate({+ index: art.index,+ messageId: art.messageId ?? '',+ original: art.content,+ updated: code,+ });+ }+ }, 500),+ [readOnly],+ );++ useEffect(() => {+ return () => debouncedMutation.cancel();+ }, [artifact.id, debouncedMutation]);++ /**+ * Streaming: use model.applyEdits() to append new content.+ * Unlike setValue/pushEditOperations, applyEdits preserves existing+ * tokens so syntax highlighting doesn't flash during updates.+ */+ useEffect(() => {+ const ed = monacoRef.current;+ if (!ed || !readOnly) {+ return;}- return {- ...sharedOptions,- activeFile: '/' + fileKey,- bundlerURL: template === 'static' ? config.staticBundlerURL : config.bundlerURL,- };- }, [config, template, fileKey]);- const initialReadOnly = (externalReadOnly ?? false) || (isSubmitting ?? false);- const [readOnly, setReadOnly] = useState(initialReadOnly);+ const newContent = artifact.content ?? '';+ const prev = prevContentRef.current;++ if (newContent === prev) {+ return;+ }++ const model = ed.getModel();+ if (!model) {+ return;+ }++ if (newContent.startsWith(prev) && prev.length > 0) {+ const appended = newContent.slice(prev.length);+ const endPos = model.getPositionAt(model.getValueLength());+ model.applyEdits([+ {+ range: {+ startLineNumber: endPos.lineNumber,+ startColumn: endPos.column,+ endLineNumber: endPos.lineNumber,+ endColumn: endPos.column,+ },+ text: appended,+ },+ ]);+ } else {+ model.setValue(newContent);+ }++ prevContentRef.current = newContent;+ ed.revealLine(model.getLineCount());+ }, [artifact.content, readOnly, monacoRef]);+useEffect(() => {- setReadOnly((externalReadOnly ?? false) || (isSubmitting ?? false));- }, [isSubmitting, externalReadOnly]);+ if (artifact.id === prevArtifactId.current) {+ return;+ }+ prevArtifactId.current = artifact.id;+ prevContentRef.current = artifact.content ?? '';+ const ed = monacoRef.current;+ if (ed && artifact.content != null) {+ ed.getModel()?.setValue(artifact.content);+ }+ }, [artifact.id, artifact.content, monacoRef]);++ useEffect(() => {+ if (prevReadOnly.current && !readOnly && artifact.content != null) {+ const ed = monacoRef.current;+ if (ed) {+ ed.getModel()?.setValue(artifact.content);+ prevContentRef.current = artifact.content;+ }+ }+ prevReadOnly.current = readOnly;+ }, [readOnly, artifact.content, monacoRef]);++ const handleChange = useCallback(+ (value: string | undefined) => {+ if (value === undefined || readOnly) {+ return;+ }+ prevContentRef.current = value;+ setCurrentCode(value);+ if (value.length > 0) {+ debouncedMutation(value);+ }+ },+ [readOnly, debouncedMutation, setCurrentCode],+ );- if (Object.keys(files).length === 0) {+ /**+ * Disable all validation — this is an artifact viewer/editor, not an IDE.+ * Note: these are global Monaco settings that affect all editor instances on the page.+ * The `as unknown` cast is required because monaco-editor v0.55 types `.languages.typescript`+ * as `{ deprecated: true }` while the runtime API is fully functional.+ */+ const handleBeforeMount = useCallback((monaco: Monaco) => {+ const { typescriptDefaults, javascriptDefaults, JsxEmit } = monaco.languages+ .typescript as unknown as {+ typescriptDefaults: {+ setDiagnosticsOptions: (o: {+ noSemanticValidation: boolean;+ noSyntaxValidation: boolean;+ }) => void;+ setCompilerOptions: (o: {+ allowNonTsExtensions: boolean;+ allowJs: boolean;+ jsx: number;+ }) => void;+ };+ javascriptDefaults: {+ setDiagnosticsOptions: (o: {+ noSemanticValidation: boolean;+ noSyntaxValidation: boolean;+ }) => void;+ setCompilerOptions: (o: {+ allowNonTsExtensions: boolean;+ allowJs: boolean;+ jsx: number;+ }) => void;+ };+ JsxEmit: { React: number };+ };+ const diagnosticsOff = { noSemanticValidation: true, noSyntaxValidation: true };+ const compilerBase = { allowNonTsExtensions: true, allowJs: true, jsx: JsxEmit.React };+ typescriptDefaults.setDiagnosticsOptions(diagnosticsOff);+ javascriptDefaults.setDiagnosticsOptions(diagnosticsOff);+ typescriptDefaults.setCompilerOptions(compilerBase);+ javascriptDefaults.setCompilerOptions(compilerBase);+ }, []);++ const handleMount = useCallback(+ (ed: editor.IStandaloneCodeEditor) => {+ monacoRef.current = ed;+ prevContentRef.current = ed.getModel()?.getValue() ?? artifact.content ?? '';+ if (readOnly) {+ const model = ed.getModel();+ if (model) {+ ed.revealLine(model.getLineCount());+ }+ }+ },+ // eslint-disable-next-line react-hooks/exhaustive-deps+ [monacoRef],+ );++ const language = getMonacoLanguage(artifact.type, artifact.language);++ const editorOptions = useMemo<editor.IStandaloneEditorConstructionOptions>(+ () => ({+ readOnly,+ minimap: { enabled: false },+ lineNumbers: 'on',+ scrollBeyondLastLine: false,+ fontSize: 13,+ tabSize: 2,+ wordWrap: 'on',+ automaticLayout: true,+ padding: { top: 8 },+ renderLineHighlight: readOnly ? 'none' : 'line',+ cursorStyle: readOnly ? 'underline-thin' : 'line',+ scrollbar: {+ vertical: 'visible',+ horizontal: 'auto',+ verticalScrollbarSize: 8,+ horizontalScrollbarSize: 8,+ useShadows: false,+ alwaysConsumeMouseWheel: false,+ },+ overviewRulerLanes: 0,+ hideCursorInOverviewRuler: true,+ overviewRulerBorder: false,+ folding: false,+ glyphMargin: false,+ colorDecorators: !readOnly,+ occurrencesHighlight: readOnly ? 'off' : 'singleFile',+ selectionHighlight: !readOnly,+ renderValidationDecorations: readOnly ? 'off' : 'editable',+ quickSuggestions: !readOnly,+ suggestOnTriggerCharacters: !readOnly,+ parameterHints: { enabled: !readOnly },+ hover: { enabled: !readOnly },+ matchBrackets: readOnly ? 'never' : 'always',+ }),+ [readOnly],+ );++ if (!artifact.content) {return null;}return (- <StyledProvider- theme="dark"- files={{- ...files,- ...sharedFiles,- }}- options={options}- {...sharedProps}- template={template}- >- <CodeEditor fileKey={fileKey} artifact={artifact} editorRef={editorRef} readOnly={readOnly} />- </StyledProvider>+ <div className="h-full w-full bg-[#1e1e1e]">+ <MonacoEditor+ height="100%"+ language={language}+ theme="vs-dark"+ defaultValue={artifact.content}+ onChange={handleChange}+ beforeMount={handleBeforeMount}+ onMount={handleMount}+ options={editorOptions}+ />+ </div>);};diff --git a/client/src/components/Artifacts/ArtifactTabs.tsx b/client/src/components/Artifacts/ArtifactTabs.tsxindex 8e2a92eb9c..32332215f0 100644--- a/client/src/components/Artifacts/ArtifactTabs.tsx+++ b/client/src/components/Artifacts/ArtifactTabs.tsx@@ -1,30 +1,26 @@import { useRef, useEffect } from 'react';import * as Tabs from '@radix-ui/react-tabs';import type { SandpackPreviewRef } from '@codesandbox/sandpack-react/unstyled';-import type { CodeEditorRef } from '@codesandbox/sandpack-react';+import type { editor } from 'monaco-editor';import type { Artifact } from '~/common';import { useCodeState } from '~/Providers/EditorContext';-import { useArtifactsContext } from '~/Providers';import useArtifactProps from '~/hooks/Artifacts/useArtifactProps';-import { useAutoScroll } from '~/hooks/Artifacts/useAutoScroll';import { ArtifactCodeEditor } from './ArtifactCodeEditor';import { useGetStartupConfig } from '~/data-provider';import { ArtifactPreview } from './ArtifactPreview';export default function ArtifactTabs({artifact,- editorRef,previewRef,isSharedConvo,}: {artifact: Artifact;- editorRef: React.MutableRefObject<CodeEditorRef>;previewRef: React.MutableRefObject<SandpackPreviewRef>;isSharedConvo?: boolean;}) {- const { isSubmitting } = useArtifactsContext();const { currentCode, setCurrentCode } = useCodeState();const { data: startupConfig } = useGetStartupConfig();+ const monacoRef = useRef<editor.IStandaloneCodeEditor | null>(null);const lastIdRef = useRef<string | null>(null);useEffect(() => {@@ -34,33 +30,24 @@ export default function ArtifactTabs({lastIdRef.current = artifact.id;}, [setCurrentCode, artifact.id]);- const content = artifact.content ?? '';- const contentRef = useRef<HTMLDivElement>(null);- useAutoScroll({ ref: contentRef, content, isSubmitting });-const { files, fileKey, template, sharedProps } = useArtifactProps({ artifact });return (<div className="flex h-full w-full flex-col"><Tabs.Content- ref={contentRef}value="code"id="artifacts-code"className="h-full w-full flex-grow overflow-auto"tabIndex={-1}>- <ArtifactCodeEditor- files={files}- fileKey={fileKey}- template={template}- artifact={artifact}- editorRef={editorRef}- sharedProps={sharedProps}- readOnly={isSharedConvo}- />+ <ArtifactCodeEditor artifact={artifact} monacoRef={monacoRef} readOnly={isSharedConvo} /></Tabs.Content>- <Tabs.Content value="preview" className="h-full w-full flex-grow overflow-auto" tabIndex={-1}>+ <Tabs.Content+ value="preview"+ className="h-full w-full flex-grow overflow-hidden"+ tabIndex={-1}+ ><ArtifactPreviewfiles={files}fileKey={fileKey}diff --git a/client/src/components/Artifacts/Artifacts.tsx b/client/src/components/Artifacts/Artifacts.tsxindex 5b433cf0f6..74b2e20180 100644--- a/client/src/components/Artifacts/Artifacts.tsx+++ b/client/src/components/Artifacts/Artifacts.tsx@@ -3,7 +3,7 @@ import * as Tabs from '@radix-ui/react-tabs';import { Code, Play, RefreshCw, X } from 'lucide-react';import { useSetRecoilState, useResetRecoilState } from 'recoil';import { Button, Spinner, useMediaQuery, Radio } from '@librechat/client';-import type { SandpackPreviewRef, CodeEditorRef } from '@codesandbox/sandpack-react';+import type { SandpackPreviewRef } from '@codesandbox/sandpack-react';import { useShareContext, useMutationState } from '~/Providers';import useArtifacts from '~/hooks/Artifacts/useArtifacts';import DownloadArtifact from './DownloadArtifact';@@ -22,7 +22,6 @@ export default function Artifacts() {const { isMutating } = useMutationState();const { isSharedConvo } = useShareContext();const isMobile = useMediaQuery('(max-width: 868px)');- const editorRef = useRef<CodeEditorRef>();const previewRef = useRef<SandpackPreviewRef>();const [isVisible, setIsVisible] = useState(false);const [isClosing, setIsClosing] = useState(false);@@ -297,7 +296,6 @@ export default function Artifacts() {<div className="absolute inset-0 flex flex-col"><ArtifactTabsartifact={currentArtifact}- editorRef={editorRef as React.MutableRefObject<CodeEditorRef>}previewRef={previewRef as React.MutableRefObject<SandpackPreviewRef>}isSharedConvo={isSharedConvo}/>diff --git a/client/src/components/Artifacts/Code.tsx b/client/src/components/Artifacts/Code.tsxindex 6894ce775b..001b010908 100644--- a/client/src/components/Artifacts/Code.tsx+++ b/client/src/components/Artifacts/Code.tsx@@ -1,11 +1,8 @@-import React, { memo, useEffect, useRef, useState } from 'react';+import React, { memo, useState } from 'react';import copy from 'copy-to-clipboard';-import rehypeKatex from 'rehype-katex';-import ReactMarkdown from 'react-markdown';import { Button } from '@librechat/client';-import rehypeHighlight from 'rehype-highlight';import { Copy, CircleCheckBig } from 'lucide-react';-import { handleDoubleClick, langSubset } from '~/utils';+import { handleDoubleClick } from '~/utils';import { useLocalize } from '~/hooks';type TCodeProps = {@@ -29,74 +26,6 @@ export const code: React.ElementType = memo(({ inline, className, children }: TCreturn <code className={`hljs language-${lang} !whitespace-pre`}>{children}</code>;});-export const CodeMarkdown = memo(- ({ content = '', isSubmitting }: { content: string; isSubmitting: boolean }) => {- const scrollRef = useRef<HTMLDivElement>(null);- const [userScrolled, setUserScrolled] = useState(false);- const currentContent = content;- const rehypePlugins = [- [rehypeKatex],- [- rehypeHighlight,- {- detect: true,- ignoreMissing: true,- subset: langSubset,- },- ],- ];-- useEffect(() => {- const scrollContainer = scrollRef.current;- if (!scrollContainer) {- return;- }-- const handleScroll = () => {- const { scrollTop, scrollHeight, clientHeight } = scrollContainer;- const isNearBottom = scrollHeight - scrollTop - clientHeight < 50;-- if (!isNearBottom) {- setUserScrolled(true);- } else {- setUserScrolled(false);- }- };-- scrollContainer.addEventListener('scroll', handleScroll);-- return () => {- scrollContainer.removeEventListener('scroll', handleScroll);- };- }, []);-- useEffect(() => {- const scrollContainer = scrollRef.current;- if (!scrollContainer || !isSubmitting || userScrolled) {- return;- }-- scrollContainer.scrollTop = scrollContainer.scrollHeight;- }, [content, isSubmitting, userScrolled]);-- return (- <div ref={scrollRef} className="max-h-full overflow-y-auto">- <ReactMarkdown- /* @ts-ignore */- rehypePlugins={rehypePlugins}- components={- { code } as {- [key: string]: React.ElementType;- }- }- >- {currentContent}- </ReactMarkdown>- </div>- );- },-);-export const CopyCodeButton: React.FC<{ content: string }> = ({ content }) => {const localize = useLocalize();const [isCopied, setIsCopied] = useState(false);diff --git a/client/src/hooks/Artifacts/useAutoScroll.ts b/client/src/hooks/Artifacts/useAutoScroll.tsdeleted file mode 100644index 1ddb9feb98..0000000000--- a/client/src/hooks/Artifacts/useAutoScroll.ts+++ /dev/null@@ -1,47 +0,0 @@-// hooks/useAutoScroll.ts-import { useEffect, useState } from 'react';--interface UseAutoScrollProps {- ref: React.RefObject<HTMLElement>;- content: string;- isSubmitting: boolean;-}--export const useAutoScroll = ({ ref, content, isSubmitting }: UseAutoScrollProps) => {- const [userScrolled, setUserScrolled] = useState(false);-- useEffect(() => {- const scrollContainer = ref.current;- if (!scrollContainer) {- return;- }-- const handleScroll = () => {- const { scrollTop, scrollHeight, clientHeight } = scrollContainer;- const isNearBottom = scrollHeight - scrollTop - clientHeight < 50;-- if (!isNearBottom) {- setUserScrolled(true);- } else {- setUserScrolled(false);- }- };-- scrollContainer.addEventListener('scroll', handleScroll);-- return () => {- scrollContainer.removeEventListener('scroll', handleScroll);- };- }, [ref]);-- useEffect(() => {- const scrollContainer = ref.current;- if (!scrollContainer || !isSubmitting || userScrolled) {- return;- }-- scrollContainer.scrollTop = scrollContainer.scrollHeight;- }, [content, isSubmitting, userScrolled, ref]);-- return { userScrolled };-};diff --git a/client/src/mobile.css b/client/src/mobile.cssindex 20eeb5d1da..0d31b41134 100644--- a/client/src/mobile.css+++ b/client/src/mobile.css@@ -349,26 +349,6 @@animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;}-div[role="tabpanel"][data-state="active"][data-orientation="horizontal"][aria-labelledby^="radix-"][id^="radix-"][id$="-content-preview"] {- scrollbar-gutter: stable !important;- background-color: rgba(205, 205, 205, 0.66) !important;-}--div[role="tabpanel"][data-state="active"][data-orientation="horizontal"][aria-labelledby^="radix-"][id^="radix-"][id$="-content-preview"]::-webkit-scrollbar {- width: 12px !important;-}--div[role="tabpanel"][data-state="active"][data-orientation="horizontal"][aria-labelledby^="radix-"][id^="radix-"][id$="-content-preview"]::-webkit-scrollbar-thumb {- background-color: rgba(56, 56, 56) !important;- border-radius: 6px !important;- border: 2px solid transparent !important;- background-clip: padding-box !important;-}--div[role="tabpanel"][data-state="active"][data-orientation="horizontal"][aria-labelledby^="radix-"][id^="radix-"][id$="-content-preview"]::-webkit-scrollbar-track {- background-color: transparent !important;-}-.cm-content:focus {outline: none !important;}diff --git a/client/src/utils/artifacts.ts b/client/src/utils/artifacts.tsindex a1caf8c07e..13f3a23b47 100644--- a/client/src/utils/artifacts.ts+++ b/client/src/utils/artifacts.ts@@ -7,6 +7,7 @@ import type {const artifactFilename = {'application/vnd.react': 'App.tsx',+ 'application/vnd.ant.react': 'App.tsx','text/html': 'index.html','application/vnd.code-html': 'index.html',// mermaid and markdown types are handled separately in useArtifactProps.ts@@ -28,6 +29,7 @@ const artifactTemplate: Record<> = {'text/html': 'static','application/vnd.react': 'react-ts',+ 'application/vnd.ant.react': 'react-ts','application/vnd.mermaid': 'react-ts','application/vnd.code-html': 'static','text/markdown': 'react-ts',@@ -119,6 +121,7 @@ const dependenciesMap: Record<> = {'application/vnd.mermaid': mermaidDependencies,'application/vnd.react': standardDependencies,+ 'application/vnd.ant.react': standardDependencies,'text/html': standardDependencies,'application/vnd.code-html': standardDependencies,'text/markdown': markdownDependencies,diff --git a/package-lock.json b/package-lock.jsonindex 6be9adfa61..e634f9f053 100644--- a/package-lock.json+++ b/package-lock.json@@ -389,6 +389,7 @@"@librechat/client": "*","@marsidev/react-turnstile": "^1.1.0","@mcp-ui/client": "^5.7.0",+ "@monaco-editor/react": "^4.7.0","@radix-ui/react-accordion": "^1.1.2","@radix-ui/react-alert-dialog": "1.0.2","@radix-ui/react-checkbox": "^1.0.3",@@ -12437,6 +12438,29 @@"url": "https://github.com/sponsors/panva"}},+ "node_modules/@monaco-editor/loader": {+ "version": "1.7.0",+ "resolved": "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.7.0.tgz",+ "integrity": "sha512-gIwR1HrJrrx+vfyOhYmCZ0/JcWqG5kbfG7+d3f/C1LXk2EvzAbHSg3MQ5lO2sMlo9izoAZ04shohfKLVT6crVA==",+ "license": "MIT",+ "dependencies": {+ "state-local": "^1.0.6"+ }+ },+ "node_modules/@monaco-editor/react": {+ "version": "4.7.0",+ "resolved": "https://registry.npmjs.org/@monaco-editor/react/-/react-4.7.0.tgz",+ "integrity": "sha512-cyzXQCtO47ydzxpQtCGSQGOC8Gk3ZUeBXFAxD+CWXYFo5OqZyZUonFl0DwUlTyAfRHntBfw2p3w4s9R6oe1eCA==",+ "license": "MIT",+ "dependencies": {+ "@monaco-editor/loader": "^1.5.0"+ },+ "peerDependencies": {+ "monaco-editor": ">= 0.25.0 < 1",+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"+ }+ },"node_modules/@mongodb-js/saslprep": {"version": "1.3.1","resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.3.1.tgz",@@ -34283,6 +34307,40 @@"node": "*"}},+ "node_modules/monaco-editor": {+ "version": "0.55.1",+ "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.55.1.tgz",+ "integrity": "sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==",+ "license": "MIT",+ "peer": true,+ "dependencies": {+ "dompurify": "3.2.7",+ "marked": "14.0.0"+ }+ },+ "node_modules/monaco-editor/node_modules/dompurify": {+ "version": "3.2.7",+ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.7.tgz",+ "integrity": "sha512-WhL/YuveyGXJaerVlMYGWhvQswa7myDG17P7Vu65EWC05o8vfeNbvNf4d/BOvH99+ZW+LlQsc1GDKMa1vNK6dw==",+ "license": "(MPL-2.0 OR Apache-2.0)",+ "peer": true,+ "optionalDependencies": {+ "@types/trusted-types": "^2.0.7"+ }+ },+ "node_modules/monaco-editor/node_modules/marked": {+ "version": "14.0.0",+ "resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz",+ "integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==",+ "license": "MIT",+ "peer": true,+ "bin": {+ "marked": "bin/marked.js"+ },+ "engines": {+ "node": ">= 18"+ }+ },"node_modules/mongodb": {"version": "6.14.2","resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.14.2.tgz",@@ -40426,6 +40484,12 @@"resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz","integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A=="},+ "node_modules/state-local": {+ "version": "1.0.7",+ "resolved": "https://registry.npmjs.org/state-local/-/state-local-1.0.7.tgz",+ "integrity": "sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==",+ "license": "MIT"+ },"node_modules/static-browser-server": {"version": "1.0.3","resolved": "https://registry.npmjs.org/static-browser-server/-/static-browser-server-1.0.3.tgz",