Skip to content

feat: 内置app添加优先级排列 - #2520

Merged
ShadowLemoon merged 2 commits into
mainfrom
feat/builtin-app-priority
Jul 24, 2026
Merged

feat: 内置app添加优先级排列#2520
ShadowLemoon merged 2 commits into
mainfrom
feat/builtin-app-priority

Conversation

@ShadowLemoon

@ShadowLemoon ShadowLemoon commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • 新功能
    • 默认应用组现可按应用优先级自动排序(优先级数值越小越靠前;相同则按应用标识排序)。
    • 运行应用或调整顺序后,应用组的保存行为更符合当前显示与点击位置。
  • 改进
    • 各应用已补齐优先级配置,用于参与默认组排序。
    • 新增用于检查应用优先级与输出排序结果的开发入口。
  • 文档
    • 补充了默认应用组初始化、保存时机与排序语义的说明。

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

新增应用 PRIORITY 配置及默认组排序规则,并扩展应用组配置以区分暂态条目与已持久化顺序。新增优先级扫描工具,同时补充相关开发文档。

Changes

应用优先级配置与默认组排序

Layer / File(s) Summary
优先级配置与工厂解析
src/zzz_od/application/*/*_const.py, src/one_dragon/base/operation/application/application_factory.py
多个应用新增 PRIORITY 数值;ApplicationFactory 读取并校验其为非 bool 的整数。
默认组排序规则
src/one_dragon/base/operation/application/application_factory_manager.py, docs/develop/one_dragon/modules/application_plugin_system.md
默认组工厂按优先级和 app_id 排序;文档说明排序规则及其对用户保存顺序的适用范围。
暂态应用持久化
src/one_dragon/base/operation/application/application_group_config.py, src/one_dragon_qt/view/one_dragon/one_dragon_run_interface.py, docs/develop/one_dragon/modules/application.md
应用组配置记录持久化状态;启用、排序或运行应用时将相关条目纳入保存顺序。
优先级扫描工具
src/zzz_od/application/devtools/application_priority_scanner.py
新增基于 AST 的内置及插件应用扫描器,校验常量并输出按优先级排序的结果及错误状态。

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AppConstants
  participant ApplicationFactory
  participant ApplicationFactoryManager
  participant ApplicationGroupConfig
  AppConstants->>ApplicationFactory: 提供 PRIORITY
  ApplicationFactory->>ApplicationFactory: 校验并保存 priority
  ApplicationFactoryManager->>ApplicationFactoryManager: 发现并排序默认组工厂
  ApplicationGroupConfig->>ApplicationGroupConfig: 管理暂态与已持久化条目
  ApplicationGroupConfig->>ApplicationGroupConfig: 保存用户应用顺序
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次变更:为内置应用新增优先级字段并引入默认排序逻辑。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/builtin-app-priority

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.

@ShadowLemoon
ShadowLemoon force-pushed the feat/builtin-app-priority branch 2 times, most recently from c336f6f to 135d6b2 Compare July 23, 2026 08:56
@ShadowLemoon
ShadowLemoon force-pushed the feat/builtin-app-priority branch from 135d6b2 to 63c0892 Compare July 23, 2026 08:57

@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.

🧹 Nitpick comments (1)
src/one_dragon/base/operation/application/application_group_config.py (1)

58-66: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

save_app_list 依赖跨多方法维护的隐式不变量,建议加固或补充测试。

zip(active_indices, persisted_apps, strict=True) 要求 _all_appsapp_list 中已持久化条目严格一一对应(无重复 app_id)。该不变量目前由 update_full_app_list/_persist_app_item/remove_app 等多处方法共同维护,一旦未来改动(包括未修改的 move_up_app/move_top_app)打破它,会直接抛出未捕获的 ValueError,导致保存流程崩溃而非优雅降级。

建议为该不变量补充单测覆盖(尤其覆盖 set_app_order/persist_app/remove_app/move_up_app 的交互),或将长度不匹配场景改为记录警告并跳过本次排序同步,而非直接崩溃。

🛡️ 降级处理示例(避免硬崩溃)
-        for idx, item in zip(active_indices, persisted_apps, strict=True):
-            self._all_apps[idx] = item
+        if len(active_indices) == len(persisted_apps):
+            for idx, item in zip(active_indices, persisted_apps):
+                self._all_apps[idx] = item
+        else:
+            # 不变量被打破,跳过本次排序同步,避免崩溃;建议同时记录日志便于排查
+            pass
🤖 Prompt for 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.

In `@src/one_dragon/base/operation/application/application_group_config.py` around
lines 58 - 66, Harden save_app_list so inconsistent persisted entries or
duplicate app_id values cannot raise an uncaught ValueError from zip(...,
strict=True). Validate that active_indices and persisted_apps represent the same
unique set before updating _all_apps; when they do not, log a warning and skip
synchronization. Add focused tests covering set_app_order, persist_app,
remove_app, and move_up_app interactions while preserving normal ordering
behavior.
🤖 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.

Nitpick comments:
In `@src/one_dragon/base/operation/application/application_group_config.py`:
- Around line 58-66: Harden save_app_list so inconsistent persisted entries or
duplicate app_id values cannot raise an uncaught ValueError from zip(...,
strict=True). Validate that active_indices and persisted_apps represent the same
unique set before updating _all_apps; when they do not, log a warning and skip
synchronization. Add focused tests covering set_app_order, persist_app,
remove_app, and move_up_app interactions while preserving normal ordering
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e7e7f79-1849-462f-aa96-a60dd67cba6d

📥 Commits

Reviewing files that changed from the base of the PR and between 1020579 and 63c0892.

📒 Files selected for processing (29)
  • docs/develop/one_dragon/modules/application.md
  • docs/develop/one_dragon/modules/application_plugin_system.md
  • src/one_dragon/base/operation/application/application_factory.py
  • src/one_dragon/base/operation/application/application_factory_manager.py
  • src/one_dragon/base/operation/application/application_group_config.py
  • src/one_dragon_qt/view/one_dragon/one_dragon_run_interface.py
  • src/zzz_od/application/charge_plan/charge_plan_const.py
  • src/zzz_od/application/city_fund/city_fund_const.py
  • src/zzz_od/application/coffee/coffee_app_const.py
  • src/zzz_od/application/daily_signin/daily_signin_const.py
  • src/zzz_od/application/devtools/application_priority_scanner.py
  • src/zzz_od/application/drive_disc_dismantle/drive_disc_dismantle_const.py
  • src/zzz_od/application/email_app/email_app_const.py
  • src/zzz_od/application/engagement_reward/engagement_reward_const.py
  • src/zzz_od/application/hollow_zero/lost_void/lost_void_const.py
  • src/zzz_od/application/hollow_zero/withered_domain/withered_domain_const.py
  • src/zzz_od/application/hou_hou_bakery/hou_hou_bakery_const.py
  • src/zzz_od/application/intel_board/intel_board_const.py
  • src/zzz_od/application/life_on_line/life_on_line_const.py
  • src/zzz_od/application/notify/notify_const.py
  • src/zzz_od/application/notorious_hunt/notorious_hunt_const.py
  • src/zzz_od/application/random_play/random_play_const.py
  • src/zzz_od/application/redemption_code/redemption_code_const.py
  • src/zzz_od/application/ridu_weekly/ridu_weekly_const.py
  • src/zzz_od/application/scratch_card/scratch_card_const.py
  • src/zzz_od/application/shiyu_defense/shiyu_defense_const.py
  • src/zzz_od/application/suibian_temple/suibian_temple_const.py
  • src/zzz_od/application/trigrams_collection/trigrams_collection_const.py
  • src/zzz_od/application/world_patrol/world_patrol_const.py
🚧 Files skipped from review as they are similar to previous changes (21)
  • src/zzz_od/application/intel_board/intel_board_const.py
  • src/zzz_od/application/notorious_hunt/notorious_hunt_const.py
  • src/zzz_od/application/city_fund/city_fund_const.py
  • src/zzz_od/application/suibian_temple/suibian_temple_const.py
  • src/zzz_od/application/drive_disc_dismantle/drive_disc_dismantle_const.py
  • src/zzz_od/application/world_patrol/world_patrol_const.py
  • src/zzz_od/application/hollow_zero/lost_void/lost_void_const.py
  • src/zzz_od/application/life_on_line/life_on_line_const.py
  • src/zzz_od/application/random_play/random_play_const.py
  • src/zzz_od/application/scratch_card/scratch_card_const.py
  • src/zzz_od/application/redemption_code/redemption_code_const.py
  • src/zzz_od/application/charge_plan/charge_plan_const.py
  • src/zzz_od/application/notify/notify_const.py
  • src/zzz_od/application/hou_hou_bakery/hou_hou_bakery_const.py
  • src/one_dragon/base/operation/application/application_factory_manager.py
  • src/zzz_od/application/trigrams_collection/trigrams_collection_const.py
  • src/zzz_od/application/email_app/email_app_const.py
  • docs/develop/one_dragon/modules/application_plugin_system.md
  • src/zzz_od/application/coffee/coffee_app_const.py
  • src/zzz_od/application/ridu_weekly/ridu_weekly_const.py
  • src/zzz_od/application/engagement_reward/engagement_reward_const.py

@ShadowLemoon
ShadowLemoon merged commit 4258d4b into main Jul 24, 2026
9 checks passed
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 27, 2026
@ShadowLemoon
ShadowLemoon deleted the feat/builtin-app-priority branch July 29, 2026 03:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant