import React from "react";
import { useState, useEffect } from "react";
import { X } from "lucide-react";
const Panel = ({
height,
terminalOutput = [],
isRunning = false,
waitingForInput = false,
activeRunningFile = null,
initialTab = "terminal",
onClose,
userInput = "",
onUserInputChange,
onInputSubmit
}) => {
const [activeTab, setActiveTab] = useState(initialTab);
// Set active tab when initialTab changes
useEffect(() => {
setActiveTab(initialTab);
}, [initialTab]);
const renderTerminal = () => {
return (
{terminalOutput.length > 0 ? (
// Render output from EditorArea when available
<>
{terminalOutput.map((line, index) => (
{line.type === 'command' ? $ : ''}
{line.type === 'input' ? [Input] : ''}
{line.type === 'prompt' ? > : ''}
{line.content}
))}
{waitingForInput && (
Input Required:
Press Enter to submit input
)}
>
) : (
// Default terminal content when no output
<>
$ npm start
Starting the development server...
Compiled successfully!
You can now view vscode-clone in the browser.
Local: http://localhost:3000
On Your Network: http://192.168.1.5:3000
$
>
)}
);
};
const renderProblems = () => {
return (
No problems have been detected in the workspace.
);
};
const renderOutput = () => {
return (
[Extension Host] Extension host started.
[Language Server] Language server started.
{activeRunningFile && (
[Running] {activeRunningFile}
)}
);
};
const getTabContent = () => {
switch (activeTab) {
case "terminal":
return renderTerminal();
case "problems":
return renderProblems();
case "output":
return renderOutput();
default:
return Unknown tab
;
}
};
return (
setActiveTab("problems")}
>
Problems
setActiveTab("output")}>
Output
setActiveTab("terminal")}
>
Terminal
{/* Add close button */}
{getTabContent()}
);
};
export default Panel;