feat: remove the ai toggle switch

This commit is contained in:
James Murdza 2024-09-06 18:14:54 -07:00
parent 4ebd6dea96
commit 06118e98e9
2 changed files with 2 additions and 35 deletions

View File

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

View File

@ -32,8 +32,6 @@ export default function Sidebar({
socket, socket,
setFiles, setFiles,
addNew, addNew,
ai,
setAi,
deletingFolderId, deletingFolderId,
}: { }: {
sandboxData: Sandbox; sandboxData: Sandbox;
@ -50,8 +48,6 @@ export default function Sidebar({
socket: Socket; socket: Socket;
setFiles: (files: (TFile | TFolder)[]) => void; setFiles: (files: (TFile | TFolder)[]) => void;
addNew: (name: string, type: "file" | "folder") => void; addNew: (name: string, type: "file" | "folder") => void;
ai: boolean;
setAi: React.Dispatch<React.SetStateAction<boolean>>;
deletingFolderId: string; deletingFolderId: string;
}) { }) {
const ref = useRef(null); // drop target const ref = useRef(null); // drop target
@ -186,20 +182,6 @@ export default function Sidebar({
</div> </div>
</div> </div>
<div className="w-full space-y-4"> <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"> {/* <Button className="w-full">
<MonitorPlay className="w-4 h-4 mr-2" /> Run <MonitorPlay className="w-4 h-4 mr-2" /> Run
</Button> */} </Button> */}