Skip to content

Commit

Permalink
Small change to terminal init logic
Browse files Browse the repository at this point in the history
  • Loading branch information
akhatua2 committed Nov 22, 2024
1 parent e0d8b66 commit 7a4897f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ export const Terminal: React.FC<TerminalProps> = ({ externalMessages, socket })
const [input, setInput] = useState('');
const [isInitialized, setIsInitialized] = useState(false);
const historyRef = useRef<HTMLDivElement>(null);
const initializedRef = useRef(false);

// Initialize terminal on mount
useEffect(() => {
if (!isInitialized) {
// Send initial commands to get user, hostname, and current path
if (!initializedRef.current) {
socket.emit('terminal_command', 'whoami && hostname && pwd');
setIsInitialized(true);
initializedRef.current = true;
}
}, [isInitialized, socket]);
}, [socket]);

// Auto-scroll to bottom when history updates
useEffect(() => {
Expand Down

0 comments on commit 7a4897f

Please sign in to comment.