Fix: Military regiment notes not updated on regeneration with new era/year#1329
Merged
Conversation
✅ Deploy Preview for afmg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix military notes not updating on regiment or era data change
Fix: Military regiment notes not updated on regeneration with new era/year
Feb 19, 2026
Azgaar
reviewed
Feb 19, 2026
Azgaar
reviewed
Feb 19, 2026
Azgaar
requested changes
Feb 19, 2026
… notes in one pass Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where military regiment notes retained stale era/year information after changing Options and regenerating military forces. The issue occurred because generateNote() always appended new notes without removing prior entries, and notes.find() would return the first (stale) match.
Changes:
- Modified
generate()to remove all existing regiment notes upfront before regeneration - Updated
generateNote()to support updating existing notes in-place (though this becomes dead code given the upfront removal)
Owner
|
@copilot, please update the version. |
Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Contributor
Author
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.
Regiment notes retained stale era/year text after changing Options and recalculating military, because
generateNote()always appended tonotes[]without removing the prior entry — andnotes.find()returns the first match.Description
Changes in
public/modules/military-generator.js:generateNote(): If a note with the matching ID already exists, update it in-place (nameandlegendfields). Only push a new entry when no existing note is found. The update-in-place path is intentionally kept sincegenerateNoteis also called from outside this module.generate(): Before regenerating regiments for any state, remove all existing regiment notes in a single upfront pass (notes whose ID starts with"regiment"). This is simpler and more correct than removing per-state, since all regiments are always fully regenerated together.Type of change
Versioning
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.