Skip to content

feat(crafting-menu): add reactive state saving and restoring#198

Open
zndxcvbn wants to merge 2 commits into
mainfrom
fix-save-indices
Open

feat(crafting-menu): add reactive state saving and restoring#198
zndxcvbn wants to merge 2 commits into
mainfrom
fix-save-indices

Conversation

@zndxcvbn

@zndxcvbn zndxcvbn commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Resolve #197.

This PR addresses an issue in the CraftingMenu where the menu state was not being preserved. The InventoryMenu utilizes a dedicated game-provided delegate for saving its state; however, the CraftingMenu is unique and lacks this delegate.
Consequently, a polling-based state-saving model has been implemented to work around difficulties in intercepting the CraftingMenu exit event. Since the Esc and Tab keys trigger prematurely, it is impossible to employ the standard state-saving model via a direct call to saveIndices(); as a result, attempts to intercept these specific key presses simply fail.

Summary by CodeRabbit

  • New Features
    • Crafting menu state is now persisted. Your previously selected categories and items, scroll positions, and column layouts are automatically saved and restored when you reopen the menu. This enhancement ensures you can seamlessly resume your crafting activities from where you left off, eliminating the need to re-navigate through menus.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

CraftingMenu now persists the user's crafting list navigation state (selected category and item, scroll position, active column sorting index and state) by storing indices via SKSE during menu updates and restoring them on initialization via onUnsuspend callbacks. Persistence is driven by a debounced save mechanism triggered each frame.

Changes

Crafting Menu Navigation State Persistence

Layer / File(s) Summary
Navigation state tracking, restoration, and persistence
source/actionscript/CraftingMenu/CraftingMenu.as
Instance variables store category index, item index, scroll position, column index, and column state. RestoreIndices() loads saved state from SKSE and restores it via onUnsuspend callbacks after Initialize() completes. saveIndices(abForceSave) validates state and debounces persistence (300ms). onEnterFrame() calls saveIndices(false) every frame to drive debounced saves to SKSE.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code changes implement state persistence for CraftingMenu by tracking indices and scroll positions, then restoring them on menu resume, directly addressing the requirement to persist sorting options when enchanting.
Out of Scope Changes check ✅ Passed All changes are narrowly focused on adding state-saving functionality to CraftingMenu. No unrelated modifications to other components or functionality are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding reactive state saving and restoring to the crafting menu to persist navigation state.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@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 `@source/actionscript/CraftingMenu/CraftingMenu.as`:
- Around line 557-606: The function saveIndices currently only writes on a
trailing debounce and can miss the final state; modify the change-detection
branch inside saveIndices (the if that compares this._lastCatIdx/... to
catIdx/itemIdx/...) to perform an immediate write using
skse.StoreIndices(this._subtypeName, [...]) when a change is detected (build the
same array of catIdx, itemIdx, scrollPos, colIdx, colState), update this._last*
fields and set this._pendingSave = false and this._indicesChangedTime =
getTimer() so the state is saved immediately while retaining or removing the
trailing debounce logic as desired; ensure abForceSave branch still calls
skse.StoreIndices when true.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 44d1da52-b001-4d60-bbb3-e2d7b0d53d9d

📥 Commits

Reviewing files that changed from the base of the PR and between 3d537a3 and d3b22d8.

📒 Files selected for processing (1)
  • source/actionscript/CraftingMenu/CraftingMenu.as

Comment thread source/actionscript/CraftingMenu/CraftingMenu.as
@zndxcvbn zndxcvbn changed the title fix(crafting-menu): save menu state feat(crafting-menu): add state saving and restoring via SKSE hooks May 14, 2026
@zndxcvbn zndxcvbn changed the title feat(crafting-menu): add state saving and restoring via SKSE hooks feat(crafting-menu): add reactive state saving and restoring May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sorting options do not persist when enchanting

1 participant