feat: 脚本程序区分启动器模式和直接启动模式#59
Conversation
- 将脚本进程名配置迁移为候选进程列表 - 运行器区分直接启动和启动器启动场景 - 进程匹配统一规范化名称并避免匹配启动前已有进程
- 新增启动进阶折叠区和启动器模式开关 - 支持填写多个启动后实际运行的候选程序 - 将启动器模式校验错误定位到进阶区域
- 移除多余的 QDialog 枚举判断 - 直接使用弹窗 exec 结果判断是否保存备注
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough此 PR 引入启动器模式:增加进程名规范化工具、将脚本进程名改为多值并扩展配置与迁移逻辑,升级 ProcessManager 支持多目标查找/排除快照,新增多值设置卡与交互改进,并将功能整合到脚本运行器与脚本编辑界面。 ChangesLauncher Mode & Multi-Process Configuration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 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.
Inline comments:
In
`@src/one_dragon_qt/widgets/setting_card/multi_value_display_combo_box_setting_card.py`:
- Around line 254-276: setValue currently rebuilds rows but doesn't propagate
the new value back to the adapter or emit the value_changed signal when called
with emit_signal=True (used by _on_preset_changed → setValue), so fix setValue
to, after rebuilding rows and refreshing layout (after _refresh_layout() /
setContent()), call the adapter's set_value with the current value
(adapter.set_value(self.getValue())) and then emit the value_changed signal
(value_changed.emit(...)) only when emit_signal is True; keep the existing
_block_signals behavior when emit_signal is False so no signals are emitted in
that case.
In `@src/script_chainer/config/script_config.py`:
- Line 4: Replace cross-platform PurePath usage with PureWindowsPath when
extracting a Windows-style launcher filename: import PureWindowsPath (instead of
PurePath) at the top, then update the two extraction sites — the
_infer_launcher_mode() method and the launch_program_name property — to
construct a PureWindowsPath from the stored launcher path and use its .name to
get the filename; keep Path for filesystem operations if used elsewhere but
ensure the filename extraction specifically uses PureWindowsPath to avoid
platform-dependent parsing.
- Around line 104-106: _infer_launcher_mode currently returns
bool(data.get('launcher_mode')) which treats any non-empty string (e.g. "false"
or "0") as True; change it to explicitly parse the value: read val =
data.get('launcher_mode'), if isinstance(val, bool) return val, if
isinstance(val, (int, float)) return bool(val), if isinstance(val, str) compare
val.lower().strip() against accepted true tokens ("true","1","yes","y","on") and
false tokens ("false","0","no","n","off") and return the corresponding boolean,
otherwise fall back to the original inference logic using script_process_names.
Ensure this logic is implemented in the _infer_launcher_mode function.
In `@src/script_chainer/gui/page/script_edit_interface.py`:
- Around line 373-381: The code currently only sets
self.script_process_name_opt.set_error_message(invalid_message) for the specific
launcher-mode messages but does not clear that control when other validation
errors occur; update the non-launcher error branch to clear the process-name
error state by calling self.script_process_name_opt.set_error_message(None) (or
the widget’s clear error method) before setting and showing self.error_label and
returning False, keeping existing use of
self.launch_advanced_group.setExpand(True) in the launcher-specific branch
unchanged.
- Around line 329-339: _sync_launch_advanced_summary currently calls
get_config_value() which parses the whole form (and can raise when unrelated
fields like timeout are invalid); change it to read only the specific UI
controls that affect the summary instead of calling get_config_value(): directly
query the launcher mode control and the process name input (the widgets that
populate config.launcher_mode and config.script_process_display_name) and then
set the summary via self.launch_advanced_group.card.setContent(summary); this
avoids parsing unrelated fields and prevents exceptions from breaking the Qt
slot.
In `@src/script_chainer/win_exe/script_runner.py`:
- Around line 369-390: The current launcher-mode branch switches to a global
name check (is_process_existed(script_config.script_process_name)), which can
misidentify other same-named processes; instead keep using the ProcessManager
instance to verify the actual target PID. Replace the launcher_mode branch so
that when script_config.launcher_mode is true you call pm.is_running() (the same
check used in the non-launcher branch) to set script_current_existed, rather
than is_process_existed(...); preserve the rest of the script_ever_existed /
script_closed / script_hint_printed logic and ensure pm is the same
ProcessManager used during startup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 93dd4089-43ca-48d5-afa5-db798d40c788
📒 Files selected for processing (10)
src/one_dragon_qt/view/setting/setting_push_interface.pysrc/one_dragon_qt/widgets/setting_card/expand_setting_card_group.pysrc/one_dragon_qt/widgets/setting_card/multi_value_display_combo_box_setting_card.pysrc/one_dragon_qt/widgets/setting_card/value_display_editable_combo_box_setting_card.pysrc/script_chainer/config/script_config.pysrc/script_chainer/gui/page/script_edit_interface.pysrc/script_chainer/gui/page/script_setting_cards.pysrc/script_chainer/services/process_manager.pysrc/script_chainer/utils/process_name_utils.pysrc/script_chainer/win_exe/script_runner.py
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/script_chainer/win_exe/script_runner.py (1)
88-99: 💤 Low value
PurePath在 Windows 专用模块中可接受,但建议保持一致性。Line 94 使用
PurePath(script_path).name提取启动器文件名。由于此文件位于win_exe目录,仅在 Windows 上运行,PurePath会正确解析 Windows 路径。但为了与
script_config.py中的修复保持一致(已改用PureWindowsPath),建议统一使用PureWindowsPath。可选:保持与 script_config.py 一致
-from pathlib import Path, PurePath +from pathlib import Path, PureWindowsPath def _get_target_process_infos(script_path: str, configured_process_name: list[str]) -> list[ProcessInfo]: - launcher_name = PurePath(script_path).name + launcher_name = PureWindowsPath(script_path).name🤖 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/script_chainer/win_exe/script_runner.py` around lines 88 - 99, The function _get_target_process_infos uses PurePath to extract the launcher_name from script_path; to keep Windows-specific path handling consistent with script_config.py, replace PurePath with PureWindowsPath: import PureWindowsPath from pathlib and compute launcher_name = PureWindowsPath(script_path).name so Windows paths are parsed correctly in the win_exe module.
🤖 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/script_chainer/win_exe/script_runner.py`:
- Around line 88-99: The function _get_target_process_infos uses PurePath to
extract the launcher_name from script_path; to keep Windows-specific path
handling consistent with script_config.py, replace PurePath with
PureWindowsPath: import PureWindowsPath from pathlib and compute launcher_name =
PureWindowsPath(script_path).name so Windows paths are parsed correctly in the
win_exe module.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2a7efc59-c0d6-409b-be1d-17ad135922f1
📒 Files selected for processing (5)
src/one_dragon_qt/widgets/setting_card/multi_value_display_combo_box_setting_card.pysrc/script_chainer/config/script_config.pysrc/script_chainer/context/script_chainer_context.pysrc/script_chainer/gui/page/script_edit_interface.pysrc/script_chainer/win_exe/script_runner.py
Summary by CodeRabbit
New Features
Bug Fixes
Improvements