fix(commands): propagate command-group renames and aliases to sub-commands - #9371
Open
he-yufeng wants to merge 1 commit into
Open
fix(commands): propagate command-group renames and aliases to sub-commands#9371he-yufeng wants to merge 1 commit into
he-yufeng wants to merge 1 commit into
Conversation
…mands Sub-filters snapshot parent_command_names at registration and cache their complete names, so renaming a group left children matching only the old prefix (and the same for alias changes). Refresh the snapshots and clear the caches recursively after the group fragment or aliases are updated.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
问题
#9366:WebUI 里重命名指令组(或给它加别名)后,子指令只认旧前缀,新前缀无响应。
根因是两处快照不同步:子指令注册时把指令组当时的
get_complete_command_names()快照进parent_command_names(star_handler.py),而重命名只更新了指令组自身的group_name并清了它自己的_cmpl_cmd_names缓存(command_management.py 的_set_filter_fragment),子指令的快照和缓存都没动,于是get_complete_command_names()继续返回旧前缀组合。修法
_refresh_sub_command_names:指令组的 fragment 或别名更新后,递归刷新子过滤器的parent_command_names快照并清掉_cmpl_cmd_names缓存,嵌套指令组同样处理。_apply_config_to_runtime里,只要filter_ref是CommandGroupFilter就在 fragment/别名应用后调用它,rename 和 alter alias 两条路都覆盖到。测试
4 个新测试(tests/test_command_management.py):扁平组重命名、嵌套组重命名、经
_apply_config_to_runtime的 rename 传播、别名传播。全部通过;tests/test_conversation_commands.py 回归也通过。Fixes #9366
Summary by Sourcery
Ensure command group renames and aliases are propagated to sub-commands so they match updated prefixes.
New Features:
Enhancements:
Tests: