Java Lab2: fix reset bug#73330
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Java Lab (Lab2) regression where running a mini-app level could reset the editor to the initially loaded server sources due to referential changes in labConfig / initialSources. The fix stabilizes derived config objects and ensures useSource detects meaningful initialSources changes by value rather than reference.
Changes:
- Update
useSourceto compareinitialSourcesvia deep equality instead of reference equality to avoid unintended resets. - Memoize/stabilize derived Java Lab
labConfigso downstreaminitialSourcesWithLabConfigdoesn’t churn on deep-equal inputs. - Add a unit test guarding against resets when
initialSourceschanges by reference but not by value.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/test/unit/codebridge/hooks/useSourceTest.tsx | Adds coverage to ensure deep-equal initialSources does not trigger a reset. |
| apps/src/javalab/lab2/Javalab2View.tsx | Stabilizes derived labConfig to prevent unnecessary initialSourcesWithLabConfig object churn. |
| apps/src/codebridge/hooks/useSource.ts | Switches reset detection from reference equality to deep equality for initialSources. |
fisher-alice
approved these changes
Jun 18, 2026
fisher-alice
left a comment
Contributor
There was a problem hiding this comment.
Nice - appreciate that you included why you stuck with the reference quality check in description (e.g., teacher viewing code case) - makes sense!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found that on Java Lab levels with mini apps, the code was getting reset to the initially loaded sources on run. This was because the labConfig was getting re-created and passed to
useSource, which is doing a reference equality check to determine if the initial sources had changed. This PR memoizes the labConfig to avoid sending a different object. At first I also updated the reference check to an equality check, but I think it could cause a regression in the teacher viewing student code case. In that case, if the student's code was the same as the teacher's initial sources, and the teacher had made a change, the student's code would not load. Therefore we need to keep the reference equality check.Before
Neighborhood (bug present)
Screen.Recording.2026-06-17.at.3.26.11.PM.mov
Console (bug not present)
Screen.Recording.2026-06-17.at.3.26.38.PM.mov
After
Neighborhood (fixed)
Screen.Recording.2026-06-17.at.3.27.18.PM.mov
Console (bug still not present)
Screen.Recording.2026-06-17.at.3.27.49.PM.mov
Testing story
Tested locally