Skip to content

fix: clear stale console output during code execution#41

Open
Sarthak-madan334 wants to merge 1 commit into
Rishabhworkspace:mainfrom
Sarthak-madan334:fix-console-output
Open

fix: clear stale console output during code execution#41
Sarthak-madan334 wants to merge 1 commit into
Rishabhworkspace:mainfrom
Sarthak-madan334:fix-console-output

Conversation

@Sarthak-madan334

@Sarthak-madan334 Sarthak-madan334 commented Jun 13, 2026

Copy link
Copy Markdown

Closes #17
Changes
Clears previous execution output when Run Code is clicked.
Shows a Running... indicator inside the console panel.
Adds a Clear button to manually clear console output.
Auto-scrolls the console panel when new results arrive.
Testing
Verified old output is cleared immediately on re-run.
Verified Running... indicator appears during execution.
Verified Clear button resets console output.
Verified console scroll behavior on new output.

Summary by CodeRabbit

  • New Features

    • Added a "Clear" button to reset console output
  • Bug Fixes

    • Console now auto-scrolls to display the latest execution results
    • Improved execution status messaging with clearer feedback states
    • Console output properly clears before each new code execution

@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

@Sarthak-madan334 is attempting to deploy a commit to the rishabhjtripathi2903-3434's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

ProblemWorkspace refactors its console to support user-initiated clearing via a new handler and automatically scroll output to the bottom. The run flow now clears prior output state before execution, and console rendering depends on execution status rather than result placeholders.

Changes

Console Clearing and Auto-Scroll

Layer / File(s) Summary
Console ref, auto-scroll, and clear handler
app/src/sections/ProblemWorkspace.tsx
consoleRef is created and attached to the console output div; an effect scrolls to bottom whenever executionResult changes; handleClearConsole resets both executionResult and isExecuting; the run flow clears prior output by setting executionResult to null before marking execution in progress.
Console UI with clear button and rendering refactor
app/src/sections/ProblemWorkspace.tsx
Trash2 icon is imported; console header now includes a "Clear" button; console body rendering is refactored to show "Running..." based on isExecuting, a default "Execute code…" message when idle with no result, and the error message when executionResult.error is present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 A console that clears without a trace,
Auto-scrolls with elegant grace,
The Trash2 icon stands so proud,
Clearing output from the crowd,
State reset bright, execution true!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title directly describes the main change: clearing stale console output during code execution, which is the primary objective and aligns with the file changes in ProblemWorkspace.tsx.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@app/src/sections/ProblemWorkspace.tsx`:
- Around line 96-99: The handleClearConsole currently calls
setIsExecuting(false) which incorrectly clears the active execution flag and can
allow a new run while one is still in flight; update handleClearConsole to only
clear the visible console state by removing the call to setIsExecuting(false)
(leave setExecutionResult(null) intact) so that the running state managed by
isExecuting and the execution logic (the run/execute handler) remains
authoritative and prevents overlapping requests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dbaee72b-76e2-4caa-bb93-94445e615288

📥 Commits

Reviewing files that changed from the base of the PR and between 209465d and b2d3afd.

📒 Files selected for processing (1)
  • app/src/sections/ProblemWorkspace.tsx

Comment on lines +96 to +99
const handleClearConsole = () => {
setExecutionResult(null);
setIsExecuting(false);
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Clearing console should not reset active execution state

Line 98 forces isExecuting to false even if a run is still in flight. That can re-enable “Run Code” early and allow overlapping execute requests with stale/out-of-order output.

Suggested fix
 const handleClearConsole = () => {
-  setExecutionResult(null);
-  setIsExecuting(false);
+  // Clear visible output only; do not mutate in-flight execution state.
+  setExecutionResult(null);
 };
 <button
   onClick={handleClearConsole}
+  disabled={isExecuting}
   className="flex items-center gap-1 text-xs text-white/50 hover:text-white transition-colors"
   title="Clear console output"
 >
🤖 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 `@app/src/sections/ProblemWorkspace.tsx` around lines 96 - 99, The
handleClearConsole currently calls setIsExecuting(false) which incorrectly
clears the active execution flag and can allow a new run while one is still in
flight; update handleClearConsole to only clear the visible console state by
removing the call to setIsExecuting(false) (leave setExecutionResult(null)
intact) so that the running state managed by isExecuting and the execution logic
(the run/execute handler) remains authoritative and prevents overlapping
requests.

@Rishabhworkspace

Copy link
Copy Markdown
Owner

@Sarthak-madan334 include which issues is this pr closing

@Sarthak-madan334

Copy link
Copy Markdown
Author

@Rishabhworkspace I've updated the PR description to include the linked issue ("Closes #17").

@Rishabhworkspace Rishabhworkspace added bug Something isn't working good first issue Good for newcomers SSoC26 Easy labels Jun 18, 2026
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
algo-forge-2-0 Error Error Jun 18, 2026 4:43am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Easy good first issue Good for newcomers SSoC26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem Workspace Console Shows Stale Output During New Execution

2 participants