Skip to content

CSE Machine : Stepper full screen NOT working FIX#3900

Open
Akshay-2007-1 wants to merge 4 commits into
source-academy:masterfrom
Akshay-2007-1:stepper-full-screen
Open

CSE Machine : Stepper full screen NOT working FIX#3900
Akshay-2007-1 wants to merge 4 commits into
source-academy:masterfrom
Akshay-2007-1:stepper-full-screen

Conversation

@Akshay-2007-1
Copy link
Copy Markdown
Contributor

Description

Closes #3820. The stepper now works as intended!

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Test using the given code at #3820.

function new_stream(a, b) { 
return pair(a, () => stream_map(x => -x, new_stream(-b, a + 2))); 
} 
const st2 = new_stream(1, 2); 
eval_stream(st2, 4);

Checklist

  • I have tested this code
  • I have updated the documentation

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@Akshay-2007-1
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

Walkthrough

SideContentCseMachineBase adds a sliderKey state field that increments when the fullscreen mode changes or the CSE update completes. The Blueprint Slider receives this key so it remounts and re-measures when needed, fixing unresponsive stepper controls in fullscreen mode.

Changes

Slider Remounting Fix for Fullscreen CSE Machine

Layer / File(s) Summary
Slider remounting via sliderKey state tracking
src/commons/sideContent/content/SideContentCseMachine.tsx
Component state adds a sliderKey field initialized to 0. A fullscreenchange event listener and CSE update completion logic both increment sliderKey via requestAnimationFrame callbacks. The Slider element uses key={sliderKey} to trigger React remounting on state changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A slider once stuck in fullscreen's embrace,
Now bounces and measures with newfound grace,
A key and a remount, so clever and bright,
The stepper controls dance left, dance right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'CSE Machine : Stepper full screen NOT working FIX' directly addresses the main issue being fixed, which is the stepper not working in full-screen mode.
Description check ✅ Passed The PR description includes issue reference, change type, test instructions, and checklist completion as specified in the template.
Linked Issues check ✅ Passed The code changes directly address issue #3820 by adding slider remount logic on fullscreen transitions to restore stepper functionality in full-screen mode.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the fullscreen stepper bug in SideContentCseMachine.tsx with no unrelated modifications present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

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.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 `@src/commons/sideContent/content/SideContentCseMachine.tsx`:
- Around line 188-196: The nested requestAnimationFrame in
handleFullscreenChange (and the other similar double-rAF call sites that set
sliderKey) can fire after unmount and call setState; fix by adding a helper
(e.g., scheduleDoubleRaf or scheduleRaf) that calls requestAnimationFrame twice,
stores the returned rAF ids in an array on the instance, and returns a cancel
token; call this helper from handleFullscreenChange and the other call site(s)
instead of raw rAFs, implement componentWillUnmount to iterate stored ids and
cancelAnimationFrame for each (and clear the array), and ensure any canceled
scheduled callbacks do not call setState after unmount.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c88eaa04-6a53-464f-ae51-575d4743d4d3

📥 Commits

Reviewing files that changed from the base of the PR and between 9bf4bac and 6e022ca.

📒 Files selected for processing (1)
  • src/commons/sideContent/content/SideContentCseMachine.tsx

Comment on lines +188 to +196
private handleFullscreenChange = () => {
// Double rAF ensures the browser has completed layout after the fullscreen
// transition before Blueprint Slider remounts and measures its track width.
requestAnimationFrame(() => {
requestAnimationFrame(() => {
this.setState(prev => ({ sliderKey: prev.sliderKey + 1 }));
});
});
};
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 | 🟡 Minor | ⚡ Quick win

Cancel queued remount callbacks on unmount.

The nested requestAnimationFrame callbacks can still run after unmount and call setState. Track rAF ids and cancel them in componentWillUnmount (and reuse one helper for both call sites).

Proposed fix
 class SideContentCseMachineBase extends Component<CseMachineProps, State> {
+  private sliderRemountRaf1: number | null = null;
+  private sliderRemountRaf2: number | null = null;
+
+  private scheduleSliderRemount = () => {
+    this.sliderRemountRaf1 = requestAnimationFrame(() => {
+      this.sliderRemountRaf2 = requestAnimationFrame(() => {
+        this.setState(prev => ({ sliderKey: prev.sliderKey + 1 }));
+      });
+    });
+  };

   private handleFullscreenChange = () => {
-    // Double rAF ensures the browser has completed layout after the fullscreen
-    // transition before Blueprint Slider remounts and measures its track width.
-    requestAnimationFrame(() => {
-      requestAnimationFrame(() => {
-        this.setState(prev => ({ sliderKey: prev.sliderKey + 1 }));
-      });
-    });
+    // Double rAF ensures layout settles before Slider remount/re-measure.
+    this.scheduleSliderRemount();
   };

   componentWillUnmount() {
     this.handleResize.cancel();
     window.removeEventListener('resize', this.handleResize);
     document.removeEventListener('fullscreenchange', this.handleFullscreenChange);
+    if (this.sliderRemountRaf1 !== null) cancelAnimationFrame(this.sliderRemountRaf1);
+    if (this.sliderRemountRaf2 !== null) cancelAnimationFrame(this.sliderRemountRaf2);
     if (!this.isJava()) {
       CseMachine.resetArrowOriginFilters();
     }
   }

   componentDidUpdate(prevProps: {
@@
-      requestAnimationFrame(() => {
-        requestAnimationFrame(() => {
-          this.setState(prev => ({ sliderKey: prev.sliderKey + 1 }));
-        });
-      });
+      this.scheduleSliderRemount();
     }
   }

Also applies to: 205-209, 236-242

🤖 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/commons/sideContent/content/SideContentCseMachine.tsx` around lines 188 -
196, The nested requestAnimationFrame in handleFullscreenChange (and the other
similar double-rAF call sites that set sliderKey) can fire after unmount and
call setState; fix by adding a helper (e.g., scheduleDoubleRaf or scheduleRaf)
that calls requestAnimationFrame twice, stores the returned rAF ids in an array
on the instance, and returns a cancel token; call this helper from
handleFullscreenChange and the other call site(s) instead of raw rAFs, implement
componentWillUnmount to iterate stored ids and cancelAnimationFrame for each
(and clear the array), and ensure any canceled scheduled callbacks do not call
setState after unmount.

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

CSE Machine: Stepper not working in full screen

1 participant