Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ All notable changes to this project will be documented in this file.
## [Unreleased]

### Changed / 变更
- “+ 应用”改为先添加空白步骤并聚焦路径输入框,不再强制打开文件对话框。路径区用更明确的提示、占位符和「查找」在前的按钮顺序强调按名称查找;在路径框按 Enter 也会触发查找,但输入过程中不会自动改写路径。保存、试运行和导出仍要求填写有效绝对路径。
- Professional 工作台不再提供“+ 等待”按钮。等待步骤仍可加载、编辑和运行;步骤之间的间隔请使用各步骤的“后续延迟(秒)”。
- 从 Professional 导出的独立启动器在执行命令步骤时会弹出可交互的控制台窗口(`CREATE_NEW_CONSOLE` 并继承标准输入输出),便于查看输出和交互。编辑器内试运行仍将输出捕获到日志面板。短命令结束时控制台可能很快关闭。

### Fixed / 修复
- `tools/check_app_paths_smoke.py` 在干净工作树(没有 gitignored 的 `data/app_templates.json`)上也能运行,并继续证明测试不会改写源码树中的数据文件。
- 导入 `shared.platform.shortcuts` 不再连带加载 `shared.models`,恢复快捷键策略的隔离约定。`shared.basic_policy` 改为在需要时再导入 Plan。
- 当日志抽屉被拖到最小高度时,“运行与输出日志”标题不再与状态文本重叠,“恢复高度”按钮保持完整可见且可点击。最小高度以标题行为准,不再被日志正文的最小高度挤扁。
- 网址若未写 scheme(例如 `www.baidu.com`),会在输入、保存、预检、试运行和导出时统一补上 `https://`。已显式写出的 scheme(包括 http、https 以及其他 scheme)不会被改写。Basic 仍拒绝非 HTTP/HTTPS。
- 修复 Professional“执行命令”多行输入框在获得焦点时出现模糊/双层蓝框的问题(去掉 QTextEdit 原生边框,只保留样式表描边)。
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ LaunchFlow 有意保持小而通用的步骤模型。Professional / 当前默认

Command 在后台以无控制台窗口方式运行,界面仍会保留原始诊断信息。若 Windows 返回 `9009`,日志会在保留退出码和 stderr 的同时提示“未找到可执行命令,请检查程序是否安装或是否加入 PATH。”;找不到目标文件或权限不足时也会显示对应的友好说明。原始 `command`、`returncode`、`stdout`、`stderr` 不会被隐藏。

Application 步骤用于启动外部程序,本身不等待外部程序退出;后续延迟用于给应用留出启动时间。URL 使用系统默认浏览器。Wait 是流程中的显式暂停。若一个步骤失败,日志会明确标识失败位置,方便在编辑器中返回该步骤修正参数。
Application 步骤用于启动外部程序,本身不等待外部程序退出;后续延迟用于给应用留出启动时间。添加应用步骤后,可以输入程序名(例如 steam)再点击「查找」或在路径框按 Enter,不必先在磁盘里逐层选择;也可以浏览或直接填写绝对路径。查找只会检索本机常用位置,不会扫描整个磁盘。URL 使用系统默认浏览器。Wait 是流程中的显式暂停。若一个步骤失败,日志会明确标识失败位置,方便在编辑器中返回该步骤修正参数。

## 🗂️ 方案、最近记录与备份

Expand Down Expand Up @@ -135,7 +135,7 @@ Application 步骤用于启动外部程序,本身不等待外部程序退出
1. 把 `LaunchFlow.exe` 放入普通用户可写目录并启动。
2. 如授权页出现,复制离线请求码并交给许可管理员签发。
3. 导入收到的 `.lic` 文件,完成本机校验。
4. 新建方案,依次添加步骤并填写参数。
4. 新建方案,依次添加步骤并填写参数。添加应用时,可按名称查找、浏览或填写路径。
5. 先试运行,确认日志无未解决错误。
6. 保存方案;需要交付时再执行导出。

Expand Down
4 changes: 2 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Select Run or press `Ctrl+R` to execute the plan from top to bottom. The log dra

Command steps run in the background without opening a console window, but the original diagnostic information is retained. When Windows returns `9009`, LaunchFlow keeps the return code and stderr and also explains that the executable command could not be found and that installation or PATH should be checked. Missing target files and insufficient permission receive similarly direct explanations. The raw `command`, `returncode`, `stdout`, and `stderr` remain available rather than being replaced by the friendly message.

An Application step launches an external process and continues without waiting for that process to exit; its post-launch delay can provide startup time. URL uses the system default browser. Wait is an explicit pause within the plan. When a step fails, the log identifies the failing position so the user can return to that card and correct its settings.
An Application step launches an external process and continues without waiting for that process to exit; its post-launch delay can provide startup time. After you add an Application step, type a program name such as steam and click Find or press Enter in the path field; you do not have to walk the filesystem first. You can still browse or paste an absolute path. Find searches common local locations only and does not scan the whole disk. URL uses the system default browser. Wait is an explicit pause within the plan. When a step fails, the log identifies the failing position so the user can return to that card and correct its settings.

## 🗂️ Plans, Recent Files, and Backups

Expand Down Expand Up @@ -135,7 +135,7 @@ A normal packaged workflow is:
1. Place `LaunchFlow.exe` in an ordinary user-writable directory and start it.
2. If activation is requested, copy the offline request code and send it to the license administrator.
3. Import the returned `.lic` file to complete local verification.
4. Create a plan, add steps in order, and fill in their parameters.
4. Create a plan, add steps in order, and fill in their parameters. When adding an Application step, you can look it up by name, browse, or type a path.
5. Test-run the plan and resolve any remaining log errors.
6. Save the plan, and export it only when a separate launcher is needed.

Expand Down
16 changes: 14 additions & 2 deletions editor/edition_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@
PROFESSIONAL_EMPTY_STEPS_HINT = "请先在左侧点击“+ 应用 / + 网页 / + 命令”来添加步骤。步骤之间的间隔请使用“后续延迟”。"
BASIC_EMPTY_STEPS_HINT = "请先在左侧点击“+ 应用 / + 网页”来添加步骤。"

PROFESSIONAL_APP_PATH_PLACEHOLDER = "输入绝对路径,或浏览 / 按名称查找 .exe / .bat / .cmd / .ps1"
BASIC_APP_PATH_PLACEHOLDER = "输入绝对路径,或浏览 / 按名称查找本地 .exe / .lnk"
PROFESSIONAL_APP_PATH_PLACEHOLDER = "输入程序名后点击查找,例如 steam"
BASIC_APP_PATH_PLACEHOLDER = "输入程序名后点击查找,例如 steam"
PROFESSIONAL_APP_PATH_HINT = (
"输入程序名后点击「查找」,例如 steam。查找只会检索本机常用位置,不会扫描整个磁盘。"
"也可以「浏览」或直接填写绝对路径(.exe / .bat / .cmd / .ps1 / .lnk)。"
)
BASIC_APP_PATH_HINT = (
"输入程序名后点击「查找」,例如 steam。查找只会检索本机常用位置,不会扫描整个磁盘。"
"也可以「浏览」或直接填写本地 .exe / .lnk 路径。"
)

PROFESSIONAL_LOG_HINT = "后台 Command 的标准输出、错误和退出码集中显示在这里。"
BASIC_LOG_HINT = "应用和网页步骤的运行结果会显示在这里。"
Expand Down Expand Up @@ -80,6 +88,10 @@ def application_path_placeholder() -> str:
return BASIC_APP_PATH_PLACEHOLDER if is_basic_edition_active() else PROFESSIONAL_APP_PATH_PLACEHOLDER


def application_path_hint() -> str:
return BASIC_APP_PATH_HINT if is_basic_edition_active() else PROFESSIONAL_APP_PATH_HINT


def application_lookup_suffixes() -> tuple[str, ...]:
"""Return the path suffixes keyword lookup may store for this edition."""

Expand Down
4 changes: 4 additions & 0 deletions editor/services/plan_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ def create_app_step(self, app_name: str, app_path: str) -> AppStep:
working_dir="",
delay_after=1.0,
)
# A blank path is a legitimate in-editor draft. Completeness is still
# enforced when the plan is saved, trial-run, or exported.
if not str(app_path or "").strip():
return step
enforce_basic_policy_on_ingress(Plan(plan_name="app-step", steps=[step]))
return step

Expand Down
54 changes: 30 additions & 24 deletions editor/ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
from editor.edition_ui import (
application_file_dialog_filter,
application_lookup_suffixes,
application_path_hint,
application_path_placeholder,
brand_title,
empty_steps_hint,
Expand Down Expand Up @@ -2349,6 +2350,7 @@ def _apply_edition_presentation(self) -> None:
self.brand_title_label.setText(brand_title())
self.empty_steps_subtitle.setText(empty_steps_hint())
self.app_path_in.setPlaceholderText(application_path_placeholder())
self.app_path_hint.setText(application_path_hint())
self.log_hint.setText(log_hint_text())

def _build_menu_bar(self) -> QMenuBar:
Expand Down Expand Up @@ -2444,20 +2446,30 @@ def _build_property_editors(self) -> None:
self.btn_find_app_path = QPushButton("查找")
self.btn_browse_app_path.setObjectName("AppPathBrowseButton")
self.btn_find_app_path.setObjectName("AppPathFindButton")
self.btn_browse_app_path.setToolTip("打开文件对话框,选择要启动的程序")
self.btn_find_app_path.setToolTip("根据输入的关键词在本机查找程序,例如 steam")
self.btn_browse_app_path.setToolTip("打开文件对话框,选择要启动的程序。如果更熟悉程序名称,请改用查找。")
self.btn_find_app_path.setToolTip("按输入的名称在本机查找程序,例如 steam。不会扫描整个磁盘。也可在路径框中按 Enter。")
self.application_lookup = lookup_windows_application
path_row = QWidget()
path_layout = QHBoxLayout(path_row)
path_layout.setContentsMargins(0, 0, 0, 0)
path_layout.setSpacing(8)
path_layout.addWidget(self.app_path_in, 1)
path_layout.addWidget(self.btn_browse_app_path)
path_layout.addWidget(self.btn_find_app_path)
path_layout.addWidget(self.btn_browse_app_path)
self.app_path_hint = self._make_label(application_path_hint(), "panel_hint")
self.app_path_hint.setObjectName("AppPathHint")
self.app_path_hint.setWordWrap(True)
path_column = QWidget()
path_column_layout = QVBoxLayout(path_column)
path_column_layout.setContentsMargins(0, 0, 0, 0)
path_column_layout.setSpacing(6)
path_column_layout.addWidget(path_row)
path_column_layout.addWidget(self.app_path_hint)
app_form.addRow("步骤名称", self.app_name_in)
app_form.addRow("程序路径", path_row)
app_form.addRow("程序路径或名称", path_column)
self.btn_browse_app_path.clicked.connect(self._on_browse_app_path)
self.btn_find_app_path.clicked.connect(self._on_find_app_path)
self.app_path_in.returnPressed.connect(self._on_find_app_path)
app_form.addRow("启动参数", self.app_args_in)
app_form.addRow("后续延迟(秒)", self.app_delay_in)
self.editor_stack.addWidget(self.page_app)
Expand Down Expand Up @@ -2746,7 +2758,7 @@ def _configure_tooltips(self) -> None:
self.btn_delete_step.setToolTip(
self._shortcut_tooltip("删除当前选中步骤", self.action_delete_step)
)
self.btn_add_app.setToolTip("添加一个应用启动步骤")
self.btn_add_app.setToolTip("添加一个应用步骤。添加后可按名称查找、浏览或填写路径,不必先在磁盘里逐层选择。")
self.btn_add_url.setToolTip("添加一个网页打开步骤")
self.btn_add_cmd.setToolTip("添加一个后台命令步骤,输出显示在日志区")
self.btn_add_wait.setToolTip("等待步骤仍可加载和运行,请使用各步骤的后续延迟。")
Expand Down Expand Up @@ -3602,21 +3614,16 @@ def _commit_before_editor_boundary(self, title: str) -> bool:

# ---------------- add step ----------------
def _on_add_app_step(self) -> None:
"""
通过文件选择框添加一个应用步骤。
"""Add a blank Application step so the user can find, browse, or type a path.

说明:
- Professional 支持 exe / bat / cmd / ps1 / lnk 等常见启动入口;
- Basic 只提供本地 .exe / .lnk 选择;
- 选择成功后会立即将步骤加入当前方案并刷新界面。
The add button no longer opens a file dialog first. Completeness is
still enforced on save, trial-run, and export. Browse remains available
in the inspector after the draft step is created.
"""
file_path = self._choose_application_file(start_dir="")
if not file_path:
return
if not self._commit_before_editor_boundary("无法新增步骤"):
return

new_step = self.plan_service.create_app_step(Path(file_path).stem, file_path)
new_step = self.plan_service.create_app_step("新应用", "")
self.current_plan.steps.append(new_step)
self.current_editor_index = None
self._refresh_flow_list()
Expand Down Expand Up @@ -3733,15 +3740,14 @@ def _select_new_step(self, index: int) -> None:
self.flow_list.scrollToItem(item)

step = self.current_plan.steps[index]
editor = (
self.app_name_in
if isinstance(step, AppStep)
else self.url_name_in
if isinstance(step, UrlStep)
else self.cmd_name_in
if isinstance(step, CommandStep)
else self.wait_name_in
)
if isinstance(step, AppStep):
editor = self.app_path_in
elif isinstance(step, UrlStep):
editor = self.url_name_in
elif isinstance(step, CommandStep):
editor = self.cmd_name_in
else:
editor = self.wait_name_in
editor.setFocus()
editor.selectAll()

Expand Down
16 changes: 12 additions & 4 deletions shared/basic_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
import re
from dataclasses import dataclass
from enum import Enum
from typing import Any, Callable, Iterable, Mapping, Protocol, runtime_checkable
from typing import TYPE_CHECKING, Any, Callable, Iterable, Mapping, Protocol, runtime_checkable
from urllib.parse import urlparse

from shared.url_normalization import normalize_missing_url_scheme

from shared.models import Plan
if TYPE_CHECKING:
from shared.models import Plan


BASIC_FIXED_DELAY_SECONDS = 1.0
Expand Down Expand Up @@ -191,6 +192,13 @@ class BasicPolicyDependencies:
shortcut_resolver: ShortcutResolver | ShortcutResolverCallable | None = None


def _is_plan(value: object) -> bool:
# Import Plan only when a caller actually needs to distinguish a Plan object.
from shared.models import Plan

return isinstance(value, Plan)


def validate_basic_plan_document(
document: Any,
*,
Expand All @@ -211,7 +219,7 @@ def validate_basic_plan_document(
drive_classifier=drive_classifier,
shortcut_resolver=shortcut_resolver,
)
if isinstance(document, Plan):
if _is_plan(document):
return validate_basic_plan(
document,
filesystem=deps.filesystem,
Expand All @@ -236,7 +244,7 @@ def validate_basic_plan(
use validate_basic_plan_document() first.
"""

if not isinstance(plan, Plan):
if not _is_plan(plan):
return BasicPolicyResult(
False,
(
Expand Down
13 changes: 12 additions & 1 deletion tools/check_app_paths_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ def main() -> None:
temp_root.mkdir(parents=True)
alternate_cwd.mkdir()

protected_source_files = [PROJECT_ROOT / "data" / "app_templates.json", PROJECT_ROOT / "data" / "settings.json"]
tracked_settings = PROJECT_ROOT / "data" / "settings.json"
gitignored_templates = PROJECT_ROOT / "data" / "app_templates.json"
if not tracked_settings.is_file():
raise AssertionError(f"missing tracked source file: {tracked_settings}")
templates_existed = gitignored_templates.is_file()
protected_source_files = [tracked_settings]
if templates_existed:
protected_source_files.append(gitignored_templates)
before_hashes = {path: _sha256(path) for path in protected_source_files}
old_override = os.environ.get(APP_DATA_ENV)
old_cwd = Path.cwd()
Expand Down Expand Up @@ -111,6 +118,10 @@ def main() -> None:
after_hashes = {path: _sha256(path) for path in protected_source_files}
if before_hashes != after_hashes:
raise AssertionError("read-only source data changed")
if not templates_existed and gitignored_templates.exists():
raise AssertionError(
"clean-tree smoke created gitignored data/app_templates.json in the source tree"
)
finally:
reset_app_logger_for_tests()
sys.executable = old_executable
Expand Down
Loading
Loading