Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/pages/EditorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const WelcomeText = styled("span")(({ theme }) => ({
fontWeight: "bold",
}));

const decodeFormat = (data) => {
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name decodeFormat is ambiguous. Consider renaming it to decodeBase64Output or parseBase64Response to clearly indicate it decodes base64-encoded data and formats it as an array of lines.

Suggested change
const decodeFormat = (data) => {
const decodeBase64Output = (data) => {

Copilot uses AI. Check for mistakes.

return data ? atob(data).split("\n") : [];
}

function EditorComponent() {
const [code, setCode] = useState(null);
const [output, setOutput] = useState([]);
Expand Down Expand Up @@ -192,12 +196,14 @@ function EditorComponent() {
.then((data) => {
if (!data.stdout) {
enqueueSnackbar("Please check the code", { variant: "error" });
setOutput(data.message);
if (data.stderr) {
setOutput(decodeFormat(data.stderr));
} else if (data.compile_output) {
setOutput(decodeFormat(data.compile_output));
Comment on lines +200 to +202
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider combining both error conditions to avoid duplication. You could use setOutput(decodeFormat(data.stderr || data.compile_output)) since both handle error scenarios similarly.

Suggested change
setOutput(decodeFormat(data.stderr));
} else if (data.compile_output) {
setOutput(decodeFormat(data.compile_output));
setOutput(decodeFormat(data.stderr || data.compile_output));

Copilot uses AI. Check for mistakes.

}
return;
}
const decodedOutput = atob(data.stdout);
const formattedData = decodedOutput.split("\n");
setOutput(formattedData);
setOutput(decodeFormat(data.stdout));
})
.catch((error) => {
enqueueSnackbar("Error retrieving output: " + error.message, {
Expand Down