700 lines
20 KiB
TypeScript
Raw Normal View History

"use client";
2024-04-06 19:03:04 -04:00
import { useEffect, useRef, useState } from "react";
import monaco from "monaco-editor";
import Editor, { BeforeMount, OnMount } from "@monaco-editor/react";
import { io } from "socket.io-client";
import { toast } from "sonner";
import { useClerk } from "@clerk/nextjs";
2024-05-03 13:53:21 -07:00
import * as Y from "yjs";
import LiveblocksProvider from "@liveblocks/yjs";
import { MonacoBinding } from "y-monaco";
import { Awareness } from "y-protocols/awareness";
import { TypedLiveblocksProvider, useRoom } from "@/liveblocks.config";
2024-04-06 19:03:04 -04:00
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable";
2024-05-08 23:52:08 -07:00
import { FileJson, Loader2, TerminalSquare } from "lucide-react";
import Tab from "../ui/tab";
import Sidebar from "./sidebar";
import GenerateInput from "./generate";
2024-05-08 23:52:08 -07:00
import { Sandbox, User, TFile, TFolder, TTab } from "@/lib/types";
import { processFileType, validateName } from "@/lib/utils";
import { Cursors } from "./live/cursors";
import { Terminal } from "@xterm/xterm";
2024-05-07 21:19:32 -07:00
import DisableAccessModal from "./live/disableModal";
import Loading from "./loading";
2024-05-08 23:52:08 -07:00
import PreviewWindow from "./preview";
import Terminals from "./terminals";
2024-04-28 20:06:47 -04:00
2024-04-26 22:34:56 -04:00
export default function CodeEditor({
2024-05-01 01:53:49 -04:00
userData,
2024-05-05 00:06:10 -07:00
sandboxData,
2024-05-08 23:52:08 -07:00
}: // isSharedUser,
{
userData: User;
sandboxData: Sandbox;
isSharedUser: boolean;
2024-04-26 22:34:56 -04:00
}) {
2024-05-08 23:52:08 -07:00
const socket = io(
`http://localhost:4000?userId=${userData.id}&sandboxId=${sandboxData.id}`
);
const [files, setFiles] = useState<(TFolder | TFile)[]>([]);
const [tabs, setTabs] = useState<TTab[]>([]);
const [editorLanguage, setEditorLanguage] = useState("plaintext");
const [activeFileId, setActiveFileId] = useState<string>("");
2024-05-06 23:34:45 -07:00
const [activeFileContent, setActiveFileContent] = useState("");
const [cursorLine, setCursorLine] = useState(0);
2024-05-02 17:38:37 -07:00
const [generate, setGenerate] = useState<{
show: boolean;
id: string;
line: number;
widget: monaco.editor.IContentWidget | undefined;
pref: monaco.editor.ContentWidgetPositionPreference[];
width: number;
}>({ show: false, line: 0, id: "", widget: undefined, pref: [], width: 0 });
2024-05-02 15:25:24 -07:00
const [decorations, setDecorations] = useState<{
options: monaco.editor.IModelDeltaDecoration[];
instance: monaco.editor.IEditorDecorationsCollection | undefined;
}>({ options: [], instance: undefined });
const [terminals, setTerminals] = useState<
{
id: string;
terminal: Terminal | null;
}[]
>([]);
2024-05-06 23:34:45 -07:00
const [activeTerminalId, setActiveTerminalId] = useState("");
const [creatingTerminal, setCreatingTerminal] = useState(false);
2024-05-08 01:04:03 -07:00
const [closingTerminal, setClosingTerminal] = useState("");
const [provider, setProvider] = useState<TypedLiveblocksProvider>();
const [ai, setAi] = useState(false);
2024-05-07 21:19:32 -07:00
const [disableAccess, setDisableAccess] = useState({
isDisabled: false,
message: "",
});
const isOwner = sandboxData.userId === userData.id;
const clerk = useClerk();
const room = useRoom();
2024-05-06 23:34:45 -07:00
const activeTerminal = terminals.find((t) => t.id === activeTerminalId);
2024-04-28 20:06:47 -04:00
const [editorRef, setEditorRef] =
useState<monaco.editor.IStandaloneCodeEditor>();
const editorContainerRef = useRef<HTMLDivElement>(null);
const monacoRef = useRef<typeof monaco | null>(null);
const generateRef = useRef<HTMLDivElement>(null);
const generateWidgetRef = useRef<HTMLDivElement>(null);
2024-05-02 00:00:35 -07:00
2024-05-08 23:52:08 -07:00
// Resize observer tracks editor width for generate widget
const resizeObserver = new ResizeObserver((entries) => {
for (const entry of entries) {
const { width } = entry.contentRect;
setGenerate((prev) => {
return { ...prev, width };
});
}
});
// Pre-mount editor keybindings
2024-05-02 00:00:35 -07:00
const handleEditorWillMount: BeforeMount = (monaco) => {
monaco.editor.addKeybindingRules([
{
keybinding: monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyG,
command: "null",
},
]);
};
2024-04-06 19:03:04 -04:00
2024-05-08 23:52:08 -07:00
// Post-mount editor keybindings and actions
2024-04-27 00:20:17 -04:00
const handleEditorMount: OnMount = (editor, monaco) => {
setEditorRef(editor);
monacoRef.current = monaco;
2024-05-02 00:00:35 -07:00
editor.onDidChangeCursorPosition((e) => {
const { column, lineNumber } = e.position;
if (lineNumber === cursorLine) return;
setCursorLine(lineNumber);
2024-05-02 15:25:24 -07:00
const model = editor.getModel();
const endColumn = model?.getLineContent(lineNumber).length || 0;
2024-05-02 15:25:24 -07:00
setDecorations((prev) => {
return {
...prev,
options: [
{
range: new monaco.Range(
lineNumber,
column,
lineNumber,
endColumn
),
options: {
afterContentClassName: "inline-decoration",
},
},
],
};
});
});
2024-05-02 00:00:35 -07:00
2024-05-02 17:38:37 -07:00
editor.onDidBlurEditorText((e) => {
setDecorations((prev) => {
return {
...prev,
options: [],
};
});
});
2024-05-02 17:38:37 -07:00
2024-05-02 00:00:35 -07:00
editor.addAction({
id: "generate",
label: "Generate",
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyG],
precondition:
"editorTextFocus && !suggestWidgetVisible && !renameInputVisible && !inSnippetMode && !quickFixWidgetVisible",
2024-05-02 15:25:24 -07:00
run: () => {
setGenerate((prev) => {
2024-05-02 17:38:37 -07:00
return {
...prev,
show: !prev.show,
pref: [monaco.editor.ContentWidgetPositionPreference.BELOW],
};
});
2024-05-02 15:25:24 -07:00
},
});
};
2024-04-06 19:03:04 -04:00
2024-05-08 23:52:08 -07:00
// Generate widget effect
2024-05-02 00:00:35 -07:00
useEffect(() => {
2024-05-04 01:50:33 -07:00
if (!ai) {
setGenerate((prev) => {
return {
...prev,
show: false,
};
});
return;
2024-05-04 01:50:33 -07:00
}
2024-05-02 15:25:24 -07:00
if (generate.show) {
editorRef?.changeViewZones(function (changeAccessor) {
if (!generateRef.current) return;
2024-05-02 00:00:35 -07:00
const id = changeAccessor.addZone({
afterLineNumber: cursorLine,
heightInLines: 3,
domNode: generateRef.current,
});
2024-05-02 15:25:24 -07:00
setGenerate((prev) => {
return { ...prev, id, line: cursorLine };
});
});
2024-05-02 17:38:37 -07:00
if (!generateWidgetRef.current) return;
const widgetElement = generateWidgetRef.current;
2024-05-02 17:38:37 -07:00
const contentWidget = {
getDomNode: () => {
return widgetElement;
2024-05-02 17:38:37 -07:00
},
getId: () => {
return "generate.widget";
2024-05-02 17:38:37 -07:00
},
getPosition: () => {
return {
position: {
lineNumber: cursorLine,
column: 1,
},
preference: generate.pref,
};
2024-05-02 17:38:37 -07:00
},
};
2024-05-02 17:38:37 -07:00
setGenerate((prev) => {
return { ...prev, widget: contentWidget };
});
editorRef?.addContentWidget(contentWidget);
2024-05-02 17:38:37 -07:00
if (generateRef.current && generateWidgetRef.current) {
editorRef?.applyFontInfo(generateRef.current);
editorRef?.applyFontInfo(generateWidgetRef.current);
2024-05-02 17:38:37 -07:00
}
2024-05-02 00:00:35 -07:00
} else {
editorRef?.changeViewZones(function (changeAccessor) {
changeAccessor.removeZone(generate.id);
2024-05-02 15:25:24 -07:00
setGenerate((prev) => {
return { ...prev, id: "" };
});
});
2024-05-02 17:38:37 -07:00
if (!generate.widget) return;
editorRef?.removeContentWidget(generate.widget);
2024-05-02 17:38:37 -07:00
setGenerate((prev) => {
return {
...prev,
widget: undefined,
};
});
2024-05-02 15:25:24 -07:00
}
}, [generate.show]);
2024-05-02 15:25:24 -07:00
2024-05-08 23:52:08 -07:00
// Decorations effect for generate widget tips
2024-05-02 15:25:24 -07:00
useEffect(() => {
2024-05-02 17:38:37 -07:00
if (decorations.options.length === 0) {
decorations.instance?.clear();
2024-05-02 17:38:37 -07:00
}
2024-05-02 15:25:24 -07:00
if (!ai) return;
2024-05-04 01:50:33 -07:00
2024-05-02 15:25:24 -07:00
if (decorations.instance) {
decorations.instance.set(decorations.options);
2024-05-02 15:25:24 -07:00
} else {
const instance = editorRef?.createDecorationsCollection();
instance?.set(decorations.options);
2024-05-02 15:25:24 -07:00
setDecorations((prev) => {
return {
...prev,
instance,
};
});
2024-05-02 00:00:35 -07:00
}
}, [decorations.options]);
2024-04-26 22:34:56 -04:00
2024-05-08 23:52:08 -07:00
// Save file keybinding logic effect
2024-04-27 16:41:25 -04:00
useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === "s" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
2024-04-27 16:41:25 -04:00
setTabs((prev) =>
prev.map((tab) =>
tab.id === activeFileId ? { ...tab, saved: true } : tab
2024-04-27 16:41:25 -04:00
)
);
2024-04-27 16:41:25 -04:00
socket.emit("saveFile", activeFileId, editorRef?.getValue());
2024-04-27 16:41:25 -04:00
}
};
document.addEventListener("keydown", down);
2024-04-27 16:41:25 -04:00
return () => {
document.removeEventListener("keydown", down);
};
}, [tabs, activeFileId]);
2024-04-27 16:41:25 -04:00
2024-05-08 23:52:08 -07:00
// Liveblocks live collaboration setup effect
useEffect(() => {
const tab = tabs.find((t) => t.id === activeFileId);
const model = editorRef?.getModel();
if (!editorRef || !tab || !model) return;
const yDoc = new Y.Doc();
const yText = yDoc.getText(tab.id);
const yProvider: any = new LiveblocksProvider(room, yDoc);
const onSync = (isSynced: boolean) => {
if (isSynced) {
const text = yText.toString();
if (text === "") {
if (activeFileContent) {
yText.insert(0, activeFileContent);
} else {
setTimeout(() => {
yText.insert(0, editorRef.getValue());
}, 0);
}
}
}
};
yProvider.on("sync", onSync);
setProvider(yProvider);
const binding = new MonacoBinding(
yText,
model,
new Set([editorRef]),
yProvider.awareness as Awareness
);
return () => {
yDoc.destroy();
yProvider.destroy();
binding.destroy();
yProvider.off("sync", onSync);
};
}, [editorRef, room, activeFileContent]);
2024-05-03 13:53:21 -07:00
2024-05-08 23:52:08 -07:00
// Connection/disconnection effect + resizeobserver
2024-04-26 22:34:56 -04:00
useEffect(() => {
socket.connect();
2024-04-26 22:34:56 -04:00
2024-05-02 17:38:37 -07:00
if (editorContainerRef.current) {
resizeObserver.observe(editorContainerRef.current);
2024-05-02 17:38:37 -07:00
}
2024-04-26 22:34:56 -04:00
return () => {
socket.disconnect();
resizeObserver.disconnect();
};
}, []);
2024-04-26 22:34:56 -04:00
2024-05-08 23:52:08 -07:00
// Socket event listener effect
2024-04-26 22:34:56 -04:00
useEffect(() => {
2024-05-08 23:52:08 -07:00
const onConnect = () => {};
2024-04-28 20:06:47 -04:00
const onDisconnect = () => {
2024-05-07 23:52:14 -07:00
setTerminals([]);
};
2024-04-28 20:06:47 -04:00
const onLoadedEvent = (files: (TFolder | TFile)[]) => {
setFiles(files);
};
2024-04-26 22:34:56 -04:00
2024-05-05 14:33:09 -07:00
const onRateLimit = (message: string) => {
toast.error(message);
};
2024-04-28 20:06:47 -04:00
const onTerminalResponse = (response: { id: string; data: string }) => {
2024-05-08 01:04:03 -07:00
const term = terminals.find((t) => t.id === response.id);
if (term && term.terminal) {
term.terminal.write(response.data);
}
};
const onDisableAccess = (message: string) => {
setDisableAccess({
isDisabled: true,
message,
});
};
socket.on("connect", onConnect);
socket.on("disconnect", onDisconnect);
socket.on("loaded", onLoadedEvent);
socket.on("rateLimit", onRateLimit);
socket.on("terminalResponse", onTerminalResponse);
socket.on("disableAccess", onDisableAccess);
2024-04-26 22:34:56 -04:00
return () => {
socket.off("connect", onConnect);
socket.off("disconnect", onDisconnect);
socket.off("loaded", onLoadedEvent);
socket.off("rateLimit", onRateLimit);
socket.off("terminalResponse", onTerminalResponse);
socket.off("disableAccess", onDisableAccess);
};
2024-05-08 01:04:03 -07:00
// }, []);
}, [terminals]);
2024-04-26 22:34:56 -04:00
2024-05-08 23:52:08 -07:00
// Helper functions for tabs:
2024-05-08 23:52:08 -07:00
// Select file and load content
2024-04-27 11:08:19 -04:00
const selectFile = (tab: TTab) => {
if (tab.id === activeFileId) return;
const exists = tabs.find((t) => t.id === tab.id);
2024-05-05 12:55:34 -07:00
2024-04-26 00:10:53 -04:00
setTabs((prev) => {
if (exists) {
setActiveFileId(exists.id);
return prev;
2024-04-26 00:10:53 -04:00
}
return [...prev, tab];
});
2024-05-04 01:18:06 -07:00
2024-04-27 00:20:17 -04:00
socket.emit("getFile", tab.id, (response: string) => {
setActiveFileContent(response);
});
setEditorLanguage(processFileType(tab.name));
setActiveFileId(tab.id);
};
2024-04-26 00:10:53 -04:00
2024-05-08 23:52:08 -07:00
// Close tab and remove from tabs
2024-04-26 00:10:53 -04:00
const closeTab = (tab: TFile) => {
const numTabs = tabs.length;
const index = tabs.findIndex((t) => t.id === tab.id);
2024-04-30 01:56:43 -04:00
if (index === -1) return;
2024-04-30 01:56:43 -04:00
2024-04-27 00:20:17 -04:00
const nextId =
activeFileId === tab.id
2024-04-27 00:20:17 -04:00
? numTabs === 1
? null
: index < numTabs - 1
? tabs[index + 1].id
: tabs[index - 1].id
: activeFileId;
2024-04-27 00:20:17 -04:00
setTabs((prev) => prev.filter((t) => t.id !== tab.id));
2024-05-04 01:18:06 -07:00
if (!nextId) {
setActiveFileId("");
2024-05-04 01:18:06 -07:00
} else {
const nextTab = tabs.find((t) => t.id === nextId);
2024-05-04 01:18:06 -07:00
if (nextTab) {
selectFile(nextTab);
2024-05-04 01:18:06 -07:00
}
}
};
2024-04-26 00:10:53 -04:00
2024-04-27 14:23:09 -04:00
const handleRename = (
id: string,
newName: string,
oldName: string,
type: "file" | "folder"
) => {
const valid = validateName(newName, oldName, type);
2024-05-05 12:55:34 -07:00
if (!valid.status) {
if (valid.message) toast.error("Invalid file name.");
return false;
2024-04-30 01:56:43 -04:00
}
2024-04-27 14:23:09 -04:00
socket.emit("renameFile", id, newName);
2024-04-27 11:08:19 -04:00
setTabs((prev) =>
prev.map((tab) => (tab.id === id ? { ...tab, name: newName } : tab))
);
2024-04-27 14:23:09 -04:00
return true;
};
2024-04-27 11:08:19 -04:00
2024-04-30 01:56:43 -04:00
const handleDeleteFile = (file: TFile) => {
socket.emit("deleteFile", file.id, (response: (TFolder | TFile)[]) => {
setFiles(response);
});
closeTab(file);
};
2024-04-30 01:56:43 -04:00
const handleDeleteFolder = (folder: TFolder) => {
// socket.emit("deleteFolder", folder.id, (response: (TFolder | TFile)[]) => {
// setFiles(response)
// })
};
2024-04-30 01:56:43 -04:00
2024-05-08 23:52:08 -07:00
// On disabled access for shared users, show un-interactable loading placeholder + info modal
if (disableAccess.isDisabled)
2024-05-07 21:19:32 -07:00
return (
<>
<DisableAccessModal
message={disableAccess.message}
open={disableAccess.isDisabled}
setOpen={() => {}}
/>
<Loading />
</>
);
2024-04-06 19:03:04 -04:00
return (
<>
2024-05-08 23:52:08 -07:00
{/* Copilot DOM elements */}
2024-05-02 17:38:37 -07:00
<div ref={generateRef} />
<div className="z-50 p-1" ref={generateWidgetRef}>
2024-05-04 01:50:33 -07:00
{generate.show && ai ? (
2024-05-02 17:38:37 -07:00
<GenerateInput
user={userData}
2024-05-03 00:52:01 -07:00
socket={socket}
2024-05-02 17:38:37 -07:00
width={generate.width - 90}
2024-05-03 00:52:01 -07:00
data={{
fileName: tabs.find((t) => t.id === activeFileId)?.name ?? "",
code: editorRef?.getValue() ?? "",
2024-05-03 00:52:01 -07:00
line: generate.line,
}}
editor={{
language: editorLanguage,
}}
2024-05-02 17:38:37 -07:00
onExpand={() => {
editorRef?.changeViewZones(function (changeAccessor) {
changeAccessor.removeZone(generate.id);
2024-05-02 17:38:37 -07:00
if (!generateRef.current) return;
2024-05-02 17:38:37 -07:00
const id = changeAccessor.addZone({
afterLineNumber: cursorLine,
heightInLines: 12,
domNode: generateRef.current,
});
2024-05-02 17:38:37 -07:00
setGenerate((prev) => {
return { ...prev, id };
});
});
2024-05-02 17:38:37 -07:00
}}
2024-05-02 18:05:18 -07:00
onAccept={(code: string) => {
const line = generate.line;
2024-05-02 18:05:18 -07:00
setGenerate((prev) => {
return {
...prev,
show: !prev.show,
};
});
const file = editorRef?.getValue();
const lines = file?.split("\n") || [];
lines.splice(line - 1, 0, code);
const updatedFile = lines.join("\n");
editorRef?.setValue(updatedFile);
2024-05-02 18:05:18 -07:00
}}
2024-05-02 17:38:37 -07:00
/>
) : null}
2024-05-02 00:00:35 -07:00
</div>
2024-05-02 17:38:37 -07:00
2024-05-08 23:52:08 -07:00
{/* Main editor components */}
2024-04-27 14:23:09 -04:00
<Sidebar
files={files}
selectFile={selectFile}
handleRename={handleRename}
2024-04-30 01:56:43 -04:00
handleDeleteFile={handleDeleteFile}
handleDeleteFolder={handleDeleteFolder}
2024-04-29 00:50:25 -04:00
socket={socket}
addNew={(name, type) => {
if (type === "file") {
setFiles((prev) => [
...prev,
2024-05-05 00:06:10 -07:00
{ id: `projects/${sandboxData.id}/${name}`, name, type: "file" },
]);
2024-04-29 00:50:25 -04:00
} else {
console.log("adding folder");
2024-04-29 00:50:25 -04:00
// setFiles(prev => [...prev, { id, name, type: "folder", children: [] }])
}
}}
2024-05-08 23:52:08 -07:00
// AI Copilot Toggle
2024-05-04 01:50:33 -07:00
ai={ai}
setAi={setAi}
2024-04-27 14:23:09 -04:00
/>
2024-05-08 23:52:08 -07:00
{/* Shadcn resizeable panels: https://ui.shadcn.com/docs/components/resizable */}
2024-04-06 19:03:04 -04:00
<ResizablePanelGroup direction="horizontal">
<ResizablePanel
className="p-2 flex flex-col"
maxSize={75}
minSize={30}
defaultSize={60}
>
2024-05-07 00:16:02 -07:00
<div className="h-10 w-full flex gap-2 overflow-auto tab-scroll">
2024-05-08 23:52:08 -07:00
{/* File tabs */}
2024-04-26 00:10:53 -04:00
{tabs.map((tab) => (
<Tab
key={tab.id}
2024-04-27 11:08:19 -04:00
saved={tab.saved}
selected={activeFileId === tab.id}
2024-05-04 01:18:06 -07:00
onClick={(e) => {
selectFile(tab);
2024-04-27 00:20:17 -04:00
}}
2024-04-26 00:10:53 -04:00
onClose={() => closeTab(tab)}
>
{tab.name}
</Tab>
))}
2024-04-06 19:03:04 -04:00
</div>
2024-05-08 23:52:08 -07:00
{/* Monaco editor */}
2024-05-02 17:38:37 -07:00
<div
ref={editorContainerRef}
2024-05-03 14:27:45 -07:00
className="grow w-full overflow-hidden rounded-md relative"
2024-05-02 17:38:37 -07:00
>
{!activeFileId ? (
2024-04-26 00:10:53 -04:00
<>
2024-05-05 14:33:09 -07:00
<div className="w-full h-full flex items-center justify-center text-xl font-medium text-muted-foreground/50 select-none">
2024-04-27 11:08:19 -04:00
<FileJson className="w-6 h-6 mr-3" />
2024-04-26 00:10:53 -04:00
No file selected.
</div>
</>
2024-05-08 23:52:08 -07:00
) : // Note clerk.loaded is required here due to a bug: https://github.com/clerk/javascript/issues/1643
clerk.loaded ? (
2024-05-03 14:27:45 -07:00
<>
{provider ? <Cursors yProvider={provider} /> : null}
<Editor
height="100%"
language={editorLanguage}
beforeMount={handleEditorWillMount}
onMount={handleEditorMount}
onChange={(value) => {
if (value === activeFileContent) {
setTabs((prev) =>
prev.map((tab) =>
tab.id === activeFileId
? { ...tab, saved: true }
: tab
)
);
} else {
setTabs((prev) =>
prev.map((tab) =>
tab.id === activeFileId
? { ...tab, saved: false }
: tab
)
);
}
2024-05-03 14:27:45 -07:00
}}
options={{
minimap: {
enabled: false,
},
padding: {
bottom: 4,
top: 4,
},
scrollBeyondLastLine: false,
fixedOverflowWidgets: true,
fontFamily: "var(--font-geist-mono)",
}}
theme="vs-dark"
2024-05-06 23:34:45 -07:00
value={activeFileContent}
2024-05-03 14:27:45 -07:00
/>
</>
2024-05-05 14:33:09 -07:00
) : (
<div className="w-full h-full flex items-center justify-center text-xl font-medium text-muted-foreground/50 select-none">
<Loader2 className="animate-spin w-6 h-6 mr-3" />
Waiting for Clerk to load...
</div>
)}
2024-04-06 19:03:04 -04:00
</div>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={40}>
<ResizablePanelGroup direction="vertical">
<ResizablePanel
defaultSize={50}
minSize={20}
className="p-2 flex flex-col"
>
2024-05-08 23:52:08 -07:00
<PreviewWindow />
2024-04-06 19:03:04 -04:00
</ResizablePanel>
<ResizableHandle />
<ResizablePanel
defaultSize={50}
minSize={20}
className="p-2 flex flex-col"
>
2024-05-05 14:33:09 -07:00
{isOwner ? (
2024-05-08 23:52:08 -07:00
<Terminals
terminals={terminals}
setTerminals={setTerminals}
activeTerminalId={activeTerminalId}
setActiveTerminalId={setActiveTerminalId}
socket={socket}
activeTerminal={activeTerminal}
creatingTerminal={creatingTerminal}
setCreatingTerminal={setCreatingTerminal}
closingTerminal={closingTerminal}
setClosingTerminal={setClosingTerminal}
/>
2024-05-05 14:33:09 -07:00
) : (
<div className="w-full h-full flex items-center justify-center text-lg font-medium text-muted-foreground/50 select-none">
<TerminalSquare className="w-4 h-4 mr-2" />
No terminal access.
</div>
)}
2024-04-06 19:03:04 -04:00
</ResizablePanel>
</ResizablePanelGroup>
</ResizablePanel>
</ResizablePanelGroup>
</>
);
2024-04-06 19:03:04 -04:00
}