Repository navigation
fix(plugin-subcommands-advanced): sort registered subcommands by name - #257
Merged
Merged
Conversation
Registered subcommands followed store load order, which changes between starts. http-framework then updated the parent command on every restart. Iterate them sorted by name when wiring and in the register hooks.
|
Architecture Data flow Review ✨ Nothing flagged · reviewed Tip The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change 🪧 More tips
Thanks for using PR Lens! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out on X, Bluesky, Mastodon, Reddit or LinkedIn |
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the full single-commit diff for stable ordering of registered subcommands.
sortedRegistryEntrieshelper: a non-mutating, locale-independent (code unit) sort of a registry's entries. It usestoSorted, which the repo already uses and which fits the ES2023 lib and Node>=20.wireParentSubcommandsandRegisterSubcommandsHooks: direct subcommands, groups, and the subcommands inside each group are now iterated sorted. Subcommands the parent declares itself are replayed first, so they still come before the registered ones.- Tests: children loaded forward and backward must yield identical, sorted options for direct, grouped, and builder-hook paths, with the native subcommand still first.
- Changeset: patch bump for
@wolfstar/plugin-subcommands-advanced.
claude-sonnet-5-5 | 𝕏
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.

🔗 Linked issue
Resolves #256
🧭 Context
Registered subcommands were added to their parent in the order the stores loaded the pieces. That order changes between starts, so the same build could deploy
/reportsasunblock, block, historyonce andhistory, block, unblockthe next time.@wolfstar/http-framework6.4.0 compares deployed and loaded commands by option position, so withregister: 'on-start'every parent with modular subcommands was updated on each restart even when nothing had changed.📚 Description
Registered subcommands, groups, and the subcommands inside each group are now iterated sorted by name, in
wireParentSubcommandsand in bothRegisterSubcommandsHooksmethods. Subcommands the parent declares itself are replayed from its snapshot first, so they still come before the registered ones. Names are compared by code unit instead oflocaleCompare, so the result does not depend on the machine's locale.I followed the Pullfrog plan on the issue. Checked against the code: the three iteration sites and the
lookupEntryloops (search by method name only, left alone) match what it describes.The first start after upgrading may update those commands once; after that the order is stable. A
positionoption for a custom order is not part of this change.Key changes
sortedRegistryEntrieshelper (@internal) insrc/lib/utils/functions.ts.wireParentSubcommandsandRegisterSubcommandsHooks.subcommands/groupsuse it.@wolfstar/plugin-subcommands-advanced.Verification:
pnpm build,pnpm typecheckandpnpm test(125 files, 1845 tests) pass;oxlintreports nothing on the changed files.pnpm lintas a whole fails itsoxfmt --checkhere only because this Windows checkout has CRLF line endings; the changed files were formatted withoxfmt --write.Type of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.