From cb971955ae847e3dd2590e59981f5e945308a37f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 26 Sep 2025 18:42:41 -0500 Subject: [PATCH] Improve terminal UX --- src/components/Shakespeare/PreviewPane.tsx | 16 ++-- src/components/Terminal.tsx | 87 +++++----------------- 2 files changed, 25 insertions(+), 78 deletions(-) diff --git a/src/components/Shakespeare/PreviewPane.tsx b/src/components/Shakespeare/PreviewPane.tsx index 53da503c..9286dbd0 100644 --- a/src/components/Shakespeare/PreviewPane.tsx +++ b/src/components/Shakespeare/PreviewPane.tsx @@ -750,26 +750,25 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o variant="outline" size="sm" onClick={() => setMobileCodeView('terminal')} - className="absolute bottom-4 right-4 h-10 w-10 p-0 rounded-full shadow-lg bg-background border-2" + className="absolute bottom-4 right-4 h-12 w-12 p-0 rounded-full shadow-lg bg-background border-2" > - + ) : mobileCodeView === 'terminal' ? ( <> -
+
-

- Terminal -

-
@@ -845,7 +844,6 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o > -
)} {/* Code view header without back button for non-previewable projects */} diff --git a/src/components/Terminal.tsx b/src/components/Terminal.tsx index 366f4d52..6325ad3f 100644 --- a/src/components/Terminal.tsx +++ b/src/components/Terminal.tsx @@ -1,7 +1,7 @@ import { useState, useRef, useEffect, useCallback } from 'react'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Button } from '@/components/ui/button'; -import { X, Copy, Trash2 } from 'lucide-react'; +import { Copy } from 'lucide-react'; import { cn } from '@/lib/utils'; import { ShellTool } from '@/lib/tools/ShellTool'; import { useFS } from '@/hooks/useFS'; @@ -9,7 +9,6 @@ import { useGit } from '@/hooks/useGit'; interface TerminalProps { projectId: string; - onClose?: () => void; className?: string; } @@ -20,13 +19,12 @@ interface TerminalLine { timestamp: Date; } -export function Terminal({ projectId, onClose, className }: TerminalProps) { +export function Terminal({ projectId, className }: TerminalProps) { const [lines, setLines] = useState([]); const [currentInput, setCurrentInput] = useState(''); const [isExecuting, setIsExecuting] = useState(false); const [commandHistory, setCommandHistory] = useState([]); const [historyIndex, setHistoryIndex] = useState(-1); - const [currentWorkingDirectory, setCurrentWorkingDirectory] = useState(`/projects/${projectId}`); const inputRef = useRef(null); const scrollRef = useRef(null); @@ -43,7 +41,7 @@ export function Terminal({ projectId, onClose, className }: TerminalProps) { setLines([{ id: Date.now().toString(), type: 'output', - content: `Welcome to Shakespeare Terminal\nProject: ${projectId}\nType 'help' to see available commands.`, + content: `Welcome to Shakespeare Terminal\nType 'help' to see available commands.`, timestamp: new Date() }]); }, [projectId, fs, git]); @@ -89,25 +87,23 @@ export function Terminal({ projectId, onClose, className }: TerminalProps) { setHistoryIndex(-1); // Add input line - addLine('input', `$ ${command}`); + addLine('input', command); setIsExecuting(true); try { // Handle special help command - if (command.trim().toLowerCase() === 'help') { + if (command.trim() === 'help') { const availableCommands = shellToolRef.current.getAvailableCommands(); const helpText = `Available commands:\n\n${availableCommands.map(cmd => `${cmd.name.padEnd(12)} - ${cmd.description}` ).join('\n')}\n\nUse 'which ' for more details about a specific command.`; addLine('output', helpText); + } else if (command.trim() === 'clear') { + setLines([]); } else { const result = await shellToolRef.current.execute({ command }); - // Update current working directory - const newCwd = shellToolRef.current.getCurrentWorkingDirectory(); - setCurrentWorkingDirectory(newCwd); - // Add output if (result && result.trim()) { addLine('output', result); @@ -162,15 +158,6 @@ export function Terminal({ projectId, onClose, className }: TerminalProps) { } }, []); - const clearTerminal = useCallback(() => { - setLines([]); - }, []); - - const getPrompt = () => { - const relativePath = currentWorkingDirectory.replace(`/projects/${projectId}`, '') || '/'; - return `${projectId}:${relativePath}$`; - }; - // Focus input when clicking anywhere in the terminal const handleTerminalClick = useCallback(() => { if (inputRef.current) { @@ -179,39 +166,7 @@ export function Terminal({ projectId, onClose, className }: TerminalProps) { }, []); return ( -
- {/* Terminal Header */} -
-
-
-
-
-
-
- Terminal - {projectId} -
-
- - {onClose && ( - - )} -
-
- +
{/* Terminal Content */}
@@ -221,12 +176,17 @@ export function Terminal({ projectId, onClose, className }: TerminalProps) { key={line.id} className={cn( "group relative", - line.type === 'input' && "text-blue-400", + line.type === 'input' && "text-white", line.type === 'error' && "text-red-400", - line.type === 'output' && "text-green-400" + line.type === 'output' && "text-slate-300" )} > -
+                
+                  {line.type === 'input' ? (
+                    
+                      ${' '}
+                    
+                  ) : null}
                   {line.content}
                 
))} - {isExecuting && ( -
- Executing... -
- )} {/* Current Command Input - inline with content */} {!isExecuting && (
- + $
@@ -262,17 +217,11 @@ export function Terminal({ projectId, onClose, className }: TerminalProps) { onChange={(e) => setCurrentInput(e.target.value)} onKeyDown={handleKeyDown} disabled={isExecuting} - className="w-full bg-transparent border-none outline-none text-green-400 font-mono text-xs placeholder-gray-500 caret-green-400" + className="w-full bg-transparent border-none outline-none text-white font-mono placeholder-gray-500 caret-white leading-relaxedFP" placeholder="" autoComplete="off" spellCheck="false" /> - {/* Blinking cursor when input is empty */} - {!currentInput && ( - - _ - - )}
)}