Skip to content

Conversation

@Incharajayaram
Copy link
Contributor

@Incharajayaram Incharajayaram commented Oct 29, 2025

Resolves #153

PR Fixes:

This pull request introduces several new features and improvements to the Custom Code Editor, primarily focused on adding support for
user input (stdin) and enhancing the user experience.

New Features & Improvements:

  • User Input (stdin) Support:

    • An "Input" text area has been added to the UI, allowing users to provide standard input to their programs before execution.
    • The code submission logic has been updated to send the provided stdin to the Judge0 API, enabling the execution of interactive
      programs (e.g., using input() in Python).
  • Improved Error Reporting:

    • The output display logic has been enhanced to show stderr and compile_output alongside stdout. This ensures that users will
      always see error messages, even if their program has produced some standard output, making it easier to debug code.
  • Enhanced Input UI:

    • A placeholder text ("Provide all program input here before running") has been added to the "Input" box to make the
      non-interactive workflow clearer to the user.
    • The placeholder has been styled to be non-intrusive (greyish-white) and to disappear as soon as the user clicks inside the input
      box, improving the user experience.
  • Bug Fixes:

    • Resolved several ESLint issues related to unused variables, quotes, and indentation that arose during development.

Checklist before requesting a review

  • I have pull latest changes from main branch
  • I have tested the changes locally
  • I have run npm run lint:fix locally
  • I have performed a self-review of my code
  • I assure there is no similar/duplicate pull request regarding same issue

@vercel
Copy link

vercel bot commented Oct 29, 2025

Someone is attempting to deploy a commit to the Dhanush Nehru's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Incharajayaram
Copy link
Contributor Author

@DhanushNehru please review this PR

@vercel
Copy link

vercel bot commented Oct 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
custom-code-editor Ready Ready Preview Comment Oct 30, 2025 2:53pm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds stdin input support and code persistence to the online code editor. It introduces an input panel alongside the output panel, allowing users to provide program input before running their code. Additionally, code is now automatically saved to and restored from localStorage per language.

  • Added stdin support with a new input text area for providing program input
  • Implemented localStorage-based code persistence per language
  • Enhanced output handling to show stdout, stderr, and compilation errors together

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

NAME: selectedLanguage.NAME,
});
setCode(selectedLanguage.HELLO_WORLD);
const savedCode = localStorage.getItem(`code-${currentLanguage}`);
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The localStorage key uses currentLanguage but should use selectedLanguage.DEFAULT_LANGUAGE instead. At this point in the useEffect, currentLanguage still holds the previous language value (the dependency that triggered the effect), not the new language being switched to. This will cause the wrong saved code to be loaded when switching languages.

Copilot uses AI. Check for mistakes.
Comment on lines 181 to 183
if (code) {
localStorage.setItem(`code-${currentLanguage}`, code);
}
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The useEffect saves code to localStorage on every keystroke in the editor. This could cause performance issues with frequent writes. Consider debouncing this save operation (e.g., using a debounce hook or setTimeout) to reduce the number of localStorage writes while typing.

Suggested change
if (code) {
localStorage.setItem(`code-${currentLanguage}`, code);
}
if (!code) return;
const handler = setTimeout(() => {
localStorage.setItem(`code-${currentLanguage}`, code);
}, 500); // 500ms debounce
return () => clearTimeout(handler);

Copilot uses AI. Check for mistakes.
Comment on lines 258 to 270
const newOutput = [];
if (data.stdout) {
newOutput.push(...decodeFormat(data.stdout));
}
if (data.stderr) {
newOutput.push(...decodeFormat(data.stderr));
enqueueSnackbar("Error in code", { variant: "error" });
}
setOutput(decodeFormat(data.stdout));
if (data.compile_output) {
newOutput.push(...decodeFormat(data.compile_output));
enqueueSnackbar("Compilation error", { variant: "error" });
}
setOutput(newOutput);
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

When both stderr and compile_output are present, two separate error snackbars will be shown, which could be confusing to users. Consider combining the error messages or showing only the most relevant error snackbar to improve the user experience.

Copilot uses AI. Check for mistakes.
@DhanushNehru DhanushNehru merged commit d72e801 into DhanushNehru:main Oct 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code Editor Does Not Support User Input in Console

2 participants