+
{/* Add context tab button */}
-
@@ -143,20 +145,23 @@ export default function ContextTabs({
{previewTab && (
{previewTab.type === "image" ? (
-
- ) : previewTab.lineRange && (
- <>
-
- Lines {previewTab.lineRange.start}-{previewTab.lineRange.end}
-
-
- {previewTab.content}
-
- >
+ ) : (
+ previewTab.lineRange && (
+ <>
+
+ Lines {previewTab.lineRange.start}-
+ {previewTab.lineRange.end}
+
+
+ {previewTab.content}
+
+ >
+ )
)}
{/* Render file context tab */}
{previewTab.type === "file" && (
@@ -169,4 +174,4 @@ export default function ContextTabs({
)
-}
\ No newline at end of file
+}
diff --git a/frontend/components/editor/AIChat/index.tsx b/frontend/components/editor/AIChat/index.tsx
index 444e576..664928f 100644
--- a/frontend/components/editor/AIChat/index.tsx
+++ b/frontend/components/editor/AIChat/index.tsx
@@ -1,14 +1,14 @@
+import { useSocket } from "@/context/SocketContext"
+import { TFile } from "@/lib/types"
import { X } from "lucide-react"
+import { nanoid } from "nanoid"
import { useEffect, useRef, useState } from "react"
import LoadingDots from "../../ui/LoadingDots"
import ChatInput from "./ChatInput"
import ChatMessage from "./ChatMessage"
import ContextTabs from "./ContextTabs"
import { handleSend, handleStopGeneration } from "./lib/chatUtils"
-import { nanoid } from 'nanoid'
-import { TFile } from "@/lib/types"
-import { useSocket } from "@/context/SocketContext"
-import { Message, ContextTab, AIChatProps } from './types'
+import { AIChatProps, ContextTab, Message } from "./types"
export default function AIChat({
activeFileContent,
@@ -56,47 +56,54 @@ export default function AIChat({
}
// Add context tab to context tabs
- const addContextTab = (type: string, name: string, content: string, lineRange?: { start: number; end: number }) => {
+ const addContextTab = (
+ type: string,
+ name: string,
+ content: string,
+ lineRange?: { start: number; end: number }
+ ) => {
const newTab = {
id: nanoid(),
type: type as "file" | "code" | "image",
name,
content,
- lineRange
+ lineRange,
}
- setContextTabs(prev => [...prev, newTab])
+ setContextTabs((prev) => [...prev, newTab])
}
// Remove context tab from context tabs
const removeContextTab = (id: string) => {
- setContextTabs(prev => prev.filter(tab => tab.id !== id))
+ setContextTabs((prev) => prev.filter((tab) => tab.id !== id))
}
// Add file to context tabs
const handleAddFile = (tab: ContextTab) => {
- setContextTabs(prev => [...prev, tab])
+ setContextTabs((prev) => [...prev, tab])
}
// Format code content to remove starting and ending code block markers if they exist
const formatCodeContent = (content: string) => {
- return content.replace(/^```[\w-]*\n/, '').replace(/\n```$/, '')
+ return content.replace(/^```[\w-]*\n/, "").replace(/\n```$/, "")
}
// Get combined context from context tabs
const getCombinedContext = () => {
- if (contextTabs.length === 0) return ''
-
- return contextTabs.map(tab => {
- if (tab.type === 'file') {
- const fileExt = tab.name.split('.').pop() || 'txt'
- const cleanContent = formatCodeContent(tab.content)
- return `File ${tab.name}:\n\`\`\`${fileExt}\n${cleanContent}\n\`\`\``
- } else if (tab.type === 'code') {
- const cleanContent = formatCodeContent(tab.content)
- return `Code from ${tab.name}:\n\`\`\`typescript\n${cleanContent}\n\`\`\``
- }
- return `${tab.name}:\n${tab.content}`
- }).join('\n\n')
+ if (contextTabs.length === 0) return ""
+
+ return contextTabs
+ .map((tab) => {
+ if (tab.type === "file") {
+ const fileExt = tab.name.split(".").pop() || "txt"
+ const cleanContent = formatCodeContent(tab.content)
+ return `File ${tab.name}:\n\`\`\`${fileExt}\n${cleanContent}\n\`\`\``
+ } else if (tab.type === "code") {
+ const cleanContent = formatCodeContent(tab.content)
+ return `Code from ${tab.name}:\n\`\`\`typescript\n${cleanContent}\n\`\`\``
+ }
+ return `${tab.name}:\n${tab.content}`
+ })
+ .join("\n\n")
}
// Handle sending message with context
@@ -120,9 +127,9 @@ export default function AIChat({
// Set context for the chat
const setContext = (
- context: string | null,
- name: string,
- range?: { start: number, end: number }
+ context: string | null,
+ name: string,
+ range?: { start: number; end: number }
) => {
if (!context) {
setContextTabs([])
@@ -130,7 +137,7 @@ export default function AIChat({
}
// Always add a new tab instead of updating existing ones
- addContextTab('code', name, context, range)
+ addContextTab("code", name, context, range)
}
return (
@@ -156,7 +163,7 @@ export default function AIChat({
className="flex-grow overflow-y-auto p-4 space-y-4"
>
{messages.map((message, messageIndex) => (
- // Render chat message component for each message
+ // Render chat message component for each message
{
socket?.emit("getFile", { fileId: file.id }, (response: string) => {
- const fileExt = file.name.split('.').pop() || 'txt'
+ const fileExt = file.name.split(".").pop() || "txt"
const formattedContent = `\`\`\`${fileExt}\n${response}\n\`\`\``
- addContextTab('file', file.name, formattedContent)
+ addContextTab("file", file.name, formattedContent)
if (textareaRef.current) {
textareaRef.current.focus()
}
@@ -210,9 +217,9 @@ export default function AIChat({
}}
lastCopiedRangeRef={lastCopiedRangeRef}
activeFileName={activeFileName}
- contextTabs={contextTabs.map(tab => ({
+ contextTabs={contextTabs.map((tab) => ({
...tab,
- title: tab.id
+ title: tab.id,
}))}
onRemoveTab={removeContextTab}
/>
diff --git a/frontend/components/editor/AIChat/lib/chatUtils.ts b/frontend/components/editor/AIChat/lib/chatUtils.ts
index d02c91e..950096f 100644
--- a/frontend/components/editor/AIChat/lib/chatUtils.ts
+++ b/frontend/components/editor/AIChat/lib/chatUtils.ts
@@ -1,6 +1,6 @@
import React from "react"
-// Stringify content for chat message component
+// Stringify content for chat message component
export const stringifyContent = (
content: any,
seen = new WeakSet()
@@ -66,19 +66,19 @@ export const stringifyContent = (
return String(content)
}
-// Copy to clipboard for chat message component
+// Copy to clipboard for chat message component
export const copyToClipboard = (
text: string,
setCopiedText: (text: string | null) => void
) => {
- // Copy text to clipboard for chat message component
+ // Copy text to clipboard for chat message component
navigator.clipboard.writeText(text).then(() => {
setCopiedText(text)
setTimeout(() => setCopiedText(null), 2000)
})
}
-// Handle send for chat message component
+// Handle send for chat message component
export const handleSend = async (
input: string,
context: string | null,
@@ -92,24 +92,26 @@ export const handleSend = async (
activeFileContent: string
) => {
// Return if input is empty and context is null
- if (input.trim() === "" && !context) return
+ if (input.trim() === "" && !context) return
- // Get timestamp for chat message component
- const timestamp = new Date().toLocaleTimeString('en-US', {
- hour12: true,
- hour: '2-digit',
- minute: '2-digit'
- }).replace(/(\d{2}):(\d{2})/, '$1:$2')
+ // Get timestamp for chat message component
+ const timestamp = new Date()
+ .toLocaleTimeString("en-US", {
+ hour12: true,
+ hour: "2-digit",
+ minute: "2-digit",
+ })
+ .replace(/(\d{2}):(\d{2})/, "$1:$2")
- // Create user message for chat message component
+ // Create user message for chat message component
const userMessage = {
role: "user" as const,
content: input,
context: context || undefined,
- timestamp: timestamp
+ timestamp: timestamp,
}
- // Update messages for chat message component
+ // Update messages for chat message component
const updatedMessages = [...messages, userMessage]
setMessages(updatedMessages)
setInput("")
@@ -120,13 +122,13 @@ export const handleSend = async (
abortControllerRef.current = new AbortController()
try {
- // Create anthropic messages for chat message component
+ // Create anthropic messages for chat message component
const anthropicMessages = updatedMessages.map((msg) => ({
role: msg.role === "user" ? "human" : "assistant",
content: msg.content,
}))
- // Fetch AI response for chat message component
+ // Fetch AI response for chat message component
const response = await fetch(
`${process.env.NEXT_PUBLIC_AI_WORKER_URL}/api`,
{
@@ -148,19 +150,19 @@ export const handleSend = async (
throw new Error("Failed to get AI response")
}
- // Get reader for chat message component
+ // Get reader for chat message component
const reader = response.body?.getReader()
const decoder = new TextDecoder()
const assistantMessage = { role: "assistant" as const, content: "" }
setMessages([...updatedMessages, assistantMessage])
setIsLoading(false)
- // Initialize buffer for chat message component
+ // Initialize buffer for chat message component
let buffer = ""
const updateInterval = 100
let lastUpdateTime = Date.now()
- // Read response from reader for chat message component
+ // Read response from reader for chat message component
if (reader) {
while (true) {
const { done, value } = await reader.read()
@@ -179,7 +181,7 @@ export const handleSend = async (
}
}
- // Update messages for chat message component
+ // Update messages for chat message component
setMessages((prev) => {
const updatedMessages = [...prev]
const lastMessage = updatedMessages[updatedMessages.length - 1]
@@ -188,7 +190,7 @@ export const handleSend = async (
})
}
} catch (error: any) {
- // Handle abort error for chat message component
+ // Handle abort error for chat message component
if (error.name === "AbortError") {
console.log("Generation aborted")
} else {
@@ -206,7 +208,7 @@ export const handleSend = async (
}
}
-// Handle stop generation for chat message component
+// Handle stop generation for chat message component
export const handleStopGeneration = (
abortControllerRef: React.MutableRefObject
) => {
@@ -215,21 +217,21 @@ export const handleStopGeneration = (
}
}
-// Check if text looks like code for chat message component
+// Check if text looks like code for chat message component
export const looksLikeCode = (text: string): boolean => {
const codeIndicators = [
- /^import\s+/m, // import statements
- /^function\s+/m, // function declarations
- /^class\s+/m, // class declarations
- /^const\s+/m, // const declarations
- /^let\s+/m, // let declarations
- /^var\s+/m, // var declarations
- /[{}\[\]();]/, // common code syntax
- /^\s*\/\//m, // comments
- /^\s*\/\*/m, // multi-line comments
- /=>/, // arrow functions
- /^export\s+/m, // export statements
- ];
+ /^import\s+/m, // import statements
+ /^function\s+/m, // function declarations
+ /^class\s+/m, // class declarations
+ /^const\s+/m, // const declarations
+ /^let\s+/m, // let declarations
+ /^var\s+/m, // var declarations
+ /[{}\[\]();]/, // common code syntax
+ /^\s*\/\//m, // comments
+ /^\s*\/\*/m, // multi-line comments
+ /=>/, // arrow functions
+ /^export\s+/m, // export statements
+ ]
- return codeIndicators.some(pattern => pattern.test(text));
-};
+ return codeIndicators.some((pattern) => pattern.test(text))
+}
diff --git a/frontend/components/editor/AIChat/lib/ignored-paths.ts b/frontend/components/editor/AIChat/lib/ignored-paths.ts
index 75d8f2b..0e6da33 100644
--- a/frontend/components/editor/AIChat/lib/ignored-paths.ts
+++ b/frontend/components/editor/AIChat/lib/ignored-paths.ts
@@ -1,102 +1,102 @@
-// Ignore certain folders and files from the file tree
+// Ignore certain folders and files from the file tree
export const ignoredFolders = [
- // Package managers
- 'node_modules',
- 'venv',
- '.env',
- 'env',
- '.venv',
- 'virtualenv',
- 'pip-wheel-metadata',
-
- // Build outputs
- '.next',
- 'dist',
- 'build',
- 'out',
- '__pycache__',
- '.webpack',
- '.serverless',
- 'storybook-static',
-
- // Version control
- '.git',
- '.svn',
- '.hg', // Mercurial
-
- // Cache and temp files
- '.cache',
- 'coverage',
- 'tmp',
- '.temp',
- '.npm',
- '.pnpm',
- '.yarn',
- '.eslintcache',
- '.stylelintcache',
-
- // IDE specific
- '.idea',
- '.vscode',
- '.vs',
- '.sublime',
-
- // Framework specific
- '.streamlit',
- '.next',
- 'static',
- '.pytest_cache',
- '.nuxt',
- '.docusaurus',
- '.remix',
- '.parcel-cache',
- 'public/build', // Remix/Rails
- '.turbo', // Turborepo
-
- // Logs
- 'logs',
- '*.log',
- 'npm-debug.log*',
- 'yarn-debug.log*',
- 'yarn-error.log*',
- 'pnpm-debug.log*',
- ] as const;
-
- export const ignoredFiles = [
- '.DS_Store',
- '.env.local',
- '.env.development',
- '.env.production',
- '.env.test',
- '.env*.local',
- '.gitignore',
- '.npmrc',
- '.yarnrc',
- '.editorconfig',
- '.prettierrc',
- '.eslintrc',
- '.browserslistrc',
- 'tsconfig.tsbuildinfo',
- '*.pyc',
- '*.pyo',
- '*.pyd',
- '*.so',
- '*.dll',
- '*.dylib',
- '*.class',
- '*.exe',
- 'package-lock.json',
- 'yarn.lock',
- 'pnpm-lock.yaml',
- 'composer.lock',
- 'poetry.lock',
- 'Gemfile.lock',
- '*.min.js',
- '*.min.css',
- '*.map',
- '*.chunk.*',
- '*.hot-update.*',
- '.vercel',
- '.netlify'
- ] as const;
\ No newline at end of file
+ // Package managers
+ "node_modules",
+ "venv",
+ ".env",
+ "env",
+ ".venv",
+ "virtualenv",
+ "pip-wheel-metadata",
+
+ // Build outputs
+ ".next",
+ "dist",
+ "build",
+ "out",
+ "__pycache__",
+ ".webpack",
+ ".serverless",
+ "storybook-static",
+
+ // Version control
+ ".git",
+ ".svn",
+ ".hg", // Mercurial
+
+ // Cache and temp files
+ ".cache",
+ "coverage",
+ "tmp",
+ ".temp",
+ ".npm",
+ ".pnpm",
+ ".yarn",
+ ".eslintcache",
+ ".stylelintcache",
+
+ // IDE specific
+ ".idea",
+ ".vscode",
+ ".vs",
+ ".sublime",
+
+ // Framework specific
+ ".streamlit",
+ ".next",
+ "static",
+ ".pytest_cache",
+ ".nuxt",
+ ".docusaurus",
+ ".remix",
+ ".parcel-cache",
+ "public/build", // Remix/Rails
+ ".turbo", // Turborepo
+
+ // Logs
+ "logs",
+ "*.log",
+ "npm-debug.log*",
+ "yarn-debug.log*",
+ "yarn-error.log*",
+ "pnpm-debug.log*",
+] as const
+
+export const ignoredFiles = [
+ ".DS_Store",
+ ".env.local",
+ ".env.development",
+ ".env.production",
+ ".env.test",
+ ".env*.local",
+ ".gitignore",
+ ".npmrc",
+ ".yarnrc",
+ ".editorconfig",
+ ".prettierrc",
+ ".eslintrc",
+ ".browserslistrc",
+ "tsconfig.tsbuildinfo",
+ "*.pyc",
+ "*.pyo",
+ "*.pyd",
+ "*.so",
+ "*.dll",
+ "*.dylib",
+ "*.class",
+ "*.exe",
+ "package-lock.json",
+ "yarn.lock",
+ "pnpm-lock.yaml",
+ "composer.lock",
+ "poetry.lock",
+ "Gemfile.lock",
+ "*.min.js",
+ "*.min.css",
+ "*.map",
+ "*.chunk.*",
+ "*.hot-update.*",
+ ".vercel",
+ ".netlify",
+] as const
diff --git a/frontend/components/editor/AIChat/lib/markdownComponents.tsx b/frontend/components/editor/AIChat/lib/markdownComponents.tsx
index 03009ae..c5cbbf3 100644
--- a/frontend/components/editor/AIChat/lib/markdownComponents.tsx
+++ b/frontend/components/editor/AIChat/lib/markdownComponents.tsx
@@ -1,21 +1,26 @@
+import { CornerUpLeft } from "lucide-react"
import { Components } from "react-markdown"
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"
import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism"
import { Button } from "../../../ui/button"
-import { CornerUpLeft } from "lucide-react"
import { stringifyContent } from "./chatUtils"
-// Create markdown components for chat message component
+// Create markdown components for chat message component
export const createMarkdownComponents = (
renderCopyButton: (text: any) => JSX.Element,
renderMarkdownElement: (props: any) => JSX.Element,
askAboutCode: (code: any) => void
): Components => ({
- code: ({ node, className, children, ...props }: {
- node?: import('hast').Element,
- className?: string,
- children?: React.ReactNode,
- [key: string]: any,
+ code: ({
+ node,
+ className,
+ children,
+ ...props
+ }: {
+ node?: import("hast").Element
+ className?: string
+ children?: React.ReactNode
+ [key: string]: any
}) => {
const match = /language-(\w+)/.exec(className || "")
@@ -55,25 +60,30 @@ export const createMarkdownComponents = (
) : (
-
{children}
+
+ {children}
+
)
},
- // Render markdown elements
- p: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
- h1: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
- h2: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
- h3: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
- h4: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
- h5: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
- h6: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
+ // Render markdown elements
+ p: ({ node, children, ...props }) =>
+ renderMarkdownElement({ node, children, ...props }),
+ h1: ({ node, children, ...props }) =>
+ renderMarkdownElement({ node, children, ...props }),
+ h2: ({ node, children, ...props }) =>
+ renderMarkdownElement({ node, children, ...props }),
+ h3: ({ node, children, ...props }) =>
+ renderMarkdownElement({ node, children, ...props }),
+ h4: ({ node, children, ...props }) =>
+ renderMarkdownElement({ node, children, ...props }),
+ h5: ({ node, children, ...props }) =>
+ renderMarkdownElement({ node, children, ...props }),
+ h6: ({ node, children, ...props }) =>
+ renderMarkdownElement({ node, children, ...props }),
ul: (props) => (
-
+
),
ol: (props) => (
-
- {props.children}
-
+
{props.children}
),
})
diff --git a/frontend/components/editor/AIChat/types/index.ts b/frontend/components/editor/AIChat/types/index.ts
index 40978b8..bc69ac7 100644
--- a/frontend/components/editor/AIChat/types/index.ts
+++ b/frontend/components/editor/AIChat/types/index.ts
@@ -1,28 +1,28 @@
-import * as monaco from 'monaco-editor'
import { TFile, TFolder } from "@/lib/types"
-import { Socket } from 'socket.io-client';
+import * as monaco from "monaco-editor"
+import { Socket } from "socket.io-client"
// Allowed file types for context tabs
export const ALLOWED_FILE_TYPES = {
// Text files
- 'text/plain': true,
- 'text/markdown': true,
- 'text/csv': true,
+ "text/plain": true,
+ "text/markdown": true,
+ "text/csv": true,
// Code files
- 'application/json': true,
- 'text/javascript': true,
- 'text/typescript': true,
- 'text/html': true,
- 'text/css': true,
+ "application/json": true,
+ "text/javascript": true,
+ "text/typescript": true,
+ "text/html": true,
+ "text/css": true,
// Documents
- 'application/pdf': true,
+ "application/pdf": true,
// Images
- 'image/jpeg': true,
- 'image/png': true,
- 'image/gif': true,
- 'image/webp': true,
- 'image/svg+xml': true,
-} as const;
+ "image/jpeg": true,
+ "image/png": true,
+ "image/gif": true,
+ "image/webp": true,
+ "image/svg+xml": true,
+} as const
// Message interface
export interface Message {
@@ -45,8 +45,13 @@ export interface AIChatProps {
activeFileContent: string
activeFileName: string
onClose: () => void
- editorRef: React.MutableRefObject
- lastCopiedRangeRef: React.MutableRefObject<{ startLine: number; endLine: number } | null>
+ editorRef: React.MutableRefObject<
+ monaco.editor.IStandaloneCodeEditor | undefined
+ >
+ lastCopiedRangeRef: React.MutableRefObject<{
+ startLine: number
+ endLine: number
+ } | null>
files: (TFile | TFolder)[]
}
@@ -58,11 +63,27 @@ export interface ChatInputProps {
handleSend: (useFullContext?: boolean) => void
handleStopGeneration: () => void
onImageUpload: (file: File) => void
- addContextTab: (type: string, title: string, content: string, lineRange?: { start: number, end: number }) => void
+ addContextTab: (
+ type: string,
+ title: string,
+ content: string,
+ lineRange?: { start: number; end: number }
+ ) => void
activeFileName?: string
- editorRef: React.MutableRefObject
- lastCopiedRangeRef: React.MutableRefObject<{ startLine: number; endLine: number } | null>
- contextTabs: { id: string; type: string; title: string; content: string; lineRange?: { start: number; end: number } }[]
+ editorRef: React.MutableRefObject<
+ monaco.editor.IStandaloneCodeEditor | undefined
+ >
+ lastCopiedRangeRef: React.MutableRefObject<{
+ startLine: number
+ endLine: number
+ } | null>
+ contextTabs: {
+ id: string
+ type: string
+ title: string
+ content: string
+ lineRange?: { start: number; end: number }
+ }[]
onRemoveTab: (id: string) => void
textareaRef: React.RefObject
}
@@ -74,7 +95,11 @@ export interface MessageProps {
content: string
context?: string
}
- setContext: (context: string | null, name: string, range?: { start: number, end: number }) => void
+ setContext: (
+ context: string | null,
+ name: string,
+ range?: { start: number; end: number }
+ ) => void
setIsContextExpanded: (isExpanded: boolean) => void
socket: Socket | null
}
diff --git a/frontend/components/editor/generate.tsx b/frontend/components/editor/generate.tsx
index 0b5ff39..6062e07 100644
--- a/frontend/components/editor/generate.tsx
+++ b/frontend/components/editor/generate.tsx
@@ -72,7 +72,7 @@ export default function GenerateInput({
fileName: data.fileName,
code: data.code,
line: data.line,
- instructions: regenerate ? currentPrompt : input
+ instructions: regenerate ? currentPrompt : input,
},
(res: { response: string; success: boolean }) => {
console.log("Generated code", res.response, res.success)
diff --git a/frontend/components/editor/index.tsx b/frontend/components/editor/index.tsx
index a516114..bf7e5ec 100644
--- a/frontend/components/editor/index.tsx
+++ b/frontend/components/editor/index.tsx
@@ -173,7 +173,10 @@ export default function CodeEditor({
const previewWindowRef = useRef<{ refreshIframe: () => void }>(null)
// Ref to store the last copied range in the editor to be used in the AIChat component
- const lastCopiedRangeRef = useRef<{ startLine: number; endLine: number } | null>(null);
+ const lastCopiedRangeRef = useRef<{
+ startLine: number
+ endLine: number
+ } | null>(null)
const debouncedSetIsSelected = useRef(
debounce((value: boolean) => {
@@ -260,14 +263,14 @@ export default function CodeEditor({
// Store the last copied range in the editor to be used in the AIChat component
editor.onDidChangeCursorSelection((e) => {
- const selection = editor.getSelection();
+ const selection = editor.getSelection()
if (selection) {
lastCopiedRangeRef.current = {
startLine: selection.startLineNumber,
- endLine: selection.endLineNumber
- };
+ endLine: selection.endLineNumber,
+ }
}
- });
+ })
}
// Call the function with your file structure
@@ -658,7 +661,7 @@ export default function CodeEditor({
// Socket event listener effect
useEffect(() => {
- const onConnect = () => { }
+ const onConnect = () => {}
const onDisconnect = () => {
setTerminals([])
@@ -786,8 +789,8 @@ export default function CodeEditor({
? numTabs === 1
? null
: index < numTabs - 1
- ? tabs[index + 1].id
- : tabs[index - 1].id
+ ? tabs[index + 1].id
+ : tabs[index - 1].id
: activeFileId
setTabs((prev) => prev.filter((t) => t.id !== id))
@@ -853,9 +856,13 @@ export default function CodeEditor({
}
const handleDeleteFile = (file: TFile) => {
- socket?.emit("deleteFile", { fileId: file.id }, (response: (TFolder | TFile)[]) => {
- setFiles(response)
- })
+ socket?.emit(
+ "deleteFile",
+ { fileId: file.id },
+ (response: (TFolder | TFile)[]) => {
+ setFiles(response)
+ }
+ )
closeTab(file.id)
}
@@ -867,10 +874,14 @@ export default function CodeEditor({
closeTabs(response)
)
- socket?.emit("deleteFolder", { folderId: folder.id }, (response: (TFolder | TFile)[]) => {
- setFiles(response)
- setDeletingFolderId("")
- })
+ socket?.emit(
+ "deleteFolder",
+ { folderId: folder.id },
+ (response: (TFolder | TFile)[]) => {
+ setFiles(response)
+ setDeletingFolderId("")
+ }
+ )
}
const togglePreviewPanel = () => {
@@ -911,7 +922,7 @@ export default function CodeEditor({
{ }}
+ setOpen={() => {}}
/>
>
@@ -953,8 +964,8 @@ export default function CodeEditor({
code:
(isSelected && editorRef?.getSelection()
? editorRef
- ?.getModel()
- ?.getValueInRange(editorRef?.getSelection()!)
+ ?.getModel()
+ ?.getValueInRange(editorRef?.getSelection()!)
: editorRef?.getValue()) ?? "",
line: generate.line,
}}
@@ -1086,62 +1097,62 @@ export default function CodeEditor({
>
) : // Note clerk.loaded is required here due to a bug: https://github.com/clerk/javascript/issues/1643
- clerk.loaded ? (
- <>
- {provider && userInfo ? (
-