Skip to content

feat:补全只写了任务名字的预设 - #17

Open
duorua wants to merge 1 commit into
MaaXYZ:mainfrom
duorua:patch-3
Open

duorua wants to merge 1 commit into
MaaXYZ:mainfrom
duorua:patch-3

Conversation

@duorua

@duorua duorua commented Sep 22, 2026 •

Copy link
Copy Markdown

方便编辑的时候查看

Sourcery 摘要

增强功能:

  • 通过继承并处理仅指定任务名称的预设任务所配置的选项来完善这些任务,使其在编辑预设时可用。
Original summary in English

Summary by Sourcery

Enhancements:

  • Complete preset tasks that specify only a task name by inheriting and processing the task’s configured options, making them available when editing presets.

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

你好——我发现了 1 个问题

给 AI Agent 的提示
请处理本次代码审查中的评论:

## 单独评论

### 评论 1
<location path="CLI/interactor.cpp" line_range="2617-2620" />
<code_context>
         config_task.name = preset_task.name
-
+        
+        if (preset_task.option.empty() && !data_iter->option.empty()) {
+            std::string preset_task_display = get_display_name(data_iter->name, data_iter->label);
+            for (const auto& option_name : data_iter->option) {
+                if (!process_option(option_name, preset_task_display, config_task.option, /*auto_accept_default=*/true)) {
+                    LogWarn << "Failed to process option for preset task" << VAR(preset_task.name) << VAR(option_name);
+                }
</code_context>
<issue_to_address>
**问题 (bug_risk):** 应用仅包含任务名称的预设时,对于没有有效 `default_case` 的任何 Select 或 Switch 选项,仍会进入交互式输入,因为 `auto_accept_default=true` 只有在存在默认值时才会跳过输入。因此,`apply_preset()` 会消耗用户输入或阻塞,而不是以非交互方式完成任务。

**触发条件:** 仅包含名称的预设引用了一个任务,而该任务的 Select 或 Switch 选项没有有效的默认情况时。

**建议修复:** 为自动完成定义确定性的回退方案,或者在没有可用默认值时返回失败/跳过该选项,而不是调用交互式输入路径。
</issue_to_address>

Sourcery 对开源项目免费——如果您喜欢我们的审查,请考虑分享 ✨
Original comment in English

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="CLI/interactor.cpp" line_range="2617-2620" />
<code_context>
         config_task.name = preset_task.name;
-
+        
+        if (preset_task.option.empty() && !data_iter->option.empty()) {
+            std::string preset_task_display = get_display_name(data_iter->name, data_iter->label);
+            for (const auto& option_name : data_iter->option) {
+                if (!process_option(option_name, preset_task_display, config_task.option, /*auto_accept_default=*/true)) {
+                    LogWarn << "Failed to process option for preset task" << VAR(preset_task.name) << VAR(option_name);
+                }
</code_context>
<issue_to_address>
**issue (bug_risk):** Applying a preset that contains only a task name still enters interactive input for any Select or Switch option without a valid `default_case`, because `auto_accept_default=true` only bypasses input when a default exists. `apply_preset()` therefore consumes user input or blocks instead of completing the task non-interactively.

**Triggers:** When a name-only preset references a task whose Select or Switch option has no valid default case.

**Suggested fix:** Define a deterministic fallback for auto-completion, or return a failure/skip the option when no default is available instead of calling the interactive input path.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread CLI/interactor.cpp
Comment on lines +2617 to +2620
if (preset_task.option.empty() && !data_iter->option.empty()) {
std::string preset_task_display = get_display_name(data_iter->name, data_iter->label);
for (const auto& option_name : data_iter->option) {
if (!process_option(option_name, preset_task_display, config_task.option, /*auto_accept_default=*/true)) {

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.

问题 (bug_risk): 应用仅包含任务名称的预设时,对于没有有效 default_case 的任何 Select 或 Switch 选项,仍会进入交互式输入,因为 auto_accept_default=true 只有在存在默认值时才会跳过输入。因此,apply_preset() 会消耗用户输入或阻塞,而不是以非交互方式完成任务。

触发条件: 仅包含名称的预设引用了一个任务,而该任务的 Select 或 Switch 选项没有有效的默认情况时。

建议修复: 为自动完成定义确定性的回退方案,或者在没有可用默认值时返回失败/跳过该选项,而不是调用交互式输入路径。

Original comment in English

issue (bug_risk): Applying a preset that contains only a task name still enters interactive input for any Select or Switch option without a valid default_case, because auto_accept_default=true only bypasses input when a default exists. apply_preset() therefore consumes user input or blocks instead of completing the task non-interactively.

Triggers: When a name-only preset references a task whose Select or Switch option has no valid default case.

Suggested fix: Define a deterministic fallback for auto-completion, or return a failure/skip the option when no default is available instead of calling the interactive input path.

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.

1 participant