Fixed : Reset Code Button - #172
Conversation
|
@Eashan-H is attempting to deploy a commit to the aviralsaxena16's projects Team on Vercel. A member of the Team first needs to authorize it. |
🎉 Thanks for Your Contribution to CanonForces!
|
WalkthroughCodeEditor component now accepts an optional ChangesCode editor reset callback wiring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/pages/questions/[id].tsx (1)
120-123: ⚡ Quick winClear stale output/submission state when resetting code.
After reset, previous run/submission results remain visible, which can make reset look partial. Consider resetting those panes in the same handler.
Suggested patch
const handleResetCode = () => { setCodeValue(CODE_SNIPPETS[language as keyof typeof CODE_SNIPPETS]); + setOutput(null); + setSubmissionResult(null); toast.success('Code reset to default') }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/pages/questions/`[id].tsx around lines 120 - 123, The handleResetCode handler only resets code and shows a toast but leaves prior run/submission state visible; update handleResetCode to also clear any related UI state (e.g. output pane, run/submission results, running flags) by calling the relevant setters used in this component (for example, setOutput, setSubmission, setRunResults, setIsRunning or whatever your state variables are named) immediately after setCodeValue(CODE_SNIPPETS[language as keyof typeof CODE_SNIPPETS]) so the UI fully returns to its initial state when toast.success('Code reset to default') is shown.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/pages/questions/`[id].tsx:
- Around line 120-123: The handleResetCode handler only resets code and shows a
toast but leaves prior run/submission state visible; update handleResetCode to
also clear any related UI state (e.g. output pane, run/submission results,
running flags) by calling the relevant setters used in this component (for
example, setOutput, setSubmission, setRunResults, setIsRunning or whatever your
state variables are named) immediately after setCodeValue(CODE_SNIPPETS[language
as keyof typeof CODE_SNIPPETS]) so the UI fully returns to its initial state
when toast.success('Code reset to default') is shown.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f85c19f2-b81d-422a-9ea1-bd7777dd9d98
📒 Files selected for processing (2)
src/common/components/CodeEditor/CodeEditor.tsxsrc/pages/questions/[id].tsx
Related Issue
Changes Introduced
Why This Change?
🖼️ Screenshots / Loom Video (if applicable)
|

Summary by CodeRabbit