Merge branch 'refs/heads/main' into production

This commit is contained in:
James Murdza 2024-09-06 18:15:25 -07:00
commit 3fcfe5a3dc
3 changed files with 5 additions and 36 deletions

View File

@ -177,7 +177,7 @@ io.on("connection", async (socket) => {
};
const sandboxFiles = await getSandboxFiles(data.sandboxId);
sandboxFiles.fileData.forEach(async (file) => {
const promises = sandboxFiles.fileData.map(async (file) => {
const filePath = path.join(dirName, file.id);
try {
await containers[data.sandboxId].files.makeDir(
@ -188,6 +188,8 @@ io.on("connection", async (socket) => {
}
await containers[data.sandboxId].files.write(filePath, file.data);
});
await Promise.all(promises);
fixPermissions();
socket.emit("loaded", sandboxFiles.files);

View File

@ -78,7 +78,6 @@ export default function CodeEditor({
useState<monaco.editor.IStandaloneCodeEditor>()
// AI Copilot state
const [ai, setAi] = useState(false)
const [generate, setGenerate] = useState<{
show: boolean
id: string
@ -260,15 +259,6 @@ export default function CodeEditor({
}, [editorRef])
// Generate widget effect
useEffect(() => {
if (!ai) {
setGenerate((prev) => {
return {
...prev,
show: false,
}
})
return
}
if (generate.show) {
setShowSuggestion(false)
editorRef?.changeViewZones(function (changeAccessor) {
@ -387,8 +377,6 @@ export default function CodeEditor({
decorations.instance?.clear()
}
if (!ai) return
const model = editorRef?.getModel()
const line = model?.getLineContent(cursorLine)
@ -745,7 +733,7 @@ export default function CodeEditor({
<div ref={generateRef} />
<div ref={suggestionRef} className="absolute">
<AnimatePresence>
{isSelected && ai && showSuggestion && (
{isSelected && showSuggestion && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
@ -761,7 +749,7 @@ export default function CodeEditor({
</AnimatePresence>
</div>
<div className="z-50 p-1" ref={generateWidgetRef}>
{generate.show && ai ? (
{generate.show ? (
<GenerateInput
user={userData}
socket={socket!}
@ -857,9 +845,6 @@ export default function CodeEditor({
setFiles={setFiles}
addNew={(name, type) => addNew(name, type, setFiles, sandboxData)}
deletingFolderId={deletingFolderId}
// AI Copilot Toggle
ai={ai}
setAi={setAi}
/>
{/* Shadcn resizeable panels: https://ui.shadcn.com/docs/components/resizable */}

View File

@ -32,8 +32,6 @@ export default function Sidebar({
socket,
setFiles,
addNew,
ai,
setAi,
deletingFolderId,
}: {
sandboxData: Sandbox;
@ -50,8 +48,6 @@ export default function Sidebar({
socket: Socket;
setFiles: (files: (TFile | TFolder)[]) => void;
addNew: (name: string, type: "file" | "folder") => void;
ai: boolean;
setAi: React.Dispatch<React.SetStateAction<boolean>>;
deletingFolderId: string;
}) {
const ref = useRef(null); // drop target
@ -186,20 +182,6 @@ export default function Sidebar({
</div>
</div>
<div className="w-full space-y-4">
<div className="flex items-center justify-between w-full">
<div className="flex items-center">
<Sparkles
className={`h-4 w-4 mr-2 ${
ai ? "text-indigo-500" : "text-muted-foreground"
}`}
/>
Copilot{" "}
<span className="font-mono text-muted-foreground inline-block ml-1.5 text-xs leading-none border border-b-2 border-muted-foreground py-1 px-1.5 rounded-md">
G
</span>
</div>
<Switch checked={ai} onCheckedChange={setAi} />
</div>
{/* <Button className="w-full">
<MonitorPlay className="w-4 h-4 mr-2" /> Run
</Button> */}