Repository navigation
Fix crash when a scrolled crafting job plan with collapsed rows refreshes - #243
Merged
Merged
Conversation
…shes When the live crafting job plan was refreshed, the scroll position of the previous view was applied before its collapsed elements were hidden again. The first row was therefore calculated for the fully expanded list, and could point past the end of the visible list, which crashed the client with an IllegalArgumentException from List#subList while rendering. Below that point, the plan jumped to the wrong rows on every refresh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeSuG89xJRXxfor1cEVHSW
rubensworks
force-pushed
the
claude/inspiring-fermat-vvaq8d
branch
from
November 16, 2026 15:30
cd69862 to
93e20e9
Compare
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.
Alternative to #242, targeting the lowest maintained branch so it can be upmerged.
Cause
The live crafting job plan (
ContainerScreenTerminalCraftingJobsPlan) rebuilds itsGuiCraftingPlanon every server update (every second by default) and callsinheritVisualizationStateon it. That method applied the previous scroll position before re-hiding the previously collapsed elements:scrollTo(f)setsfirstRow = round(f * (allElements - visibleRows)).refreshList()shrinks the list.WidgetScrollBar#setTotalRowsdoes not re-run the scroll callback, sofirstRowkeeps the value computed for the full list.If
firstRowends up past the end of the visible list,getVisibleElements()crashes the client withIllegalArgumentException: fromIndex(x) > toIndex(y). Below that threshold there is no crash, but the plan jumps to the wrong (partly empty) rows on every refresh.The trigger is collapsing rows and then scrolling. A plan that shrinks while scrolled does not cause this, as #242 suggests, because the new view's scrollbar is sized to the new plan.
Fix
Restore the collapsed state and refresh the visible list first, then apply the scroll position.
#242 also changes
ContainerScreenTerminalCraftingJobs#getVisiblePlans()andContainerScreenTerminalStorageCraftingOptionAmount#drawOutputSlots(). Neither can hit this exception, so this PR leaves them alone:mouseScrolledhandler, sofirstRowis always 0 there. Wheel, drag and click on the scrollbar all leave it at 0, confirmed in a dev client. That is a separate bug: jobs after the 10th can't be reached.Testing
master-26-lts(same code) in a dev client driven by clientdevbridge. I used a running job with 54 plan rows, collapsed one branch (37 visible rows), scrolled to the bottom and waited for the next plan update. The client crashed withfromIndex(44) > toIndex(37)inGuiCraftingPlan.getVisibleElements, where 44 = 54 - 10. With this change, the same steps keep showing the same rows across updates, with no crash../gradlew buildpasses on this branch. There are no game tests on 1.20.🤖 Generated with Claude Code
https://claude.ai/code/session_01UeSuG89xJRXxfor1cEVHSW