fix(scan): report per-item import outcomes and bind preferred version (#39) - #40
Open
yukitakasama wants to merge 1 commit into
Open
fix(scan): report per-item import outcomes and bind preferred version (#39)#40yukitakasama wants to merge 1 commit into
yukitakasama wants to merge 1 commit into
Conversation
Issue dsh-plugins#39 (scan/import wizard defects): - ImportReport gains a per-item items breakdown (kind/name/status/reason) so failures are never silent anymore: missing dirs, already-known entries and unbound versions are each reported instead of a bare continue. - The wizard now passes preferredVersionDir (the first version the user added); newly created instances bind to it. When the picked version is not in the config, instances are skipped with a failed item instead of silently binding the wrong (first) version. Without any version the instance is still created, marked with a warning reason. - ImportScanDialog: already_known homes are no longer disabled (problem 2) and their web/tui profiles are default-selected again; the import summary renders the per-item list (added/skipped/failed + reason) and the version rows get a remove button; the toast switches to a warning when any item failed. - Instances.vue: registered homes that have no instances are surfaced above the table with a link to the import wizard. - i18n: zh-CN / en-US updated with the new importScan / instances keys.
Contributor
请求修改(request changes)方向与 issue #39 的两个缺陷都对得上,后端 阻塞项:浏览器预览(mock)下导入直接报错
const result = await api.importScanned({...})
const failed = result.items.filter((i) => i.status === 'failed').length // ImportScanDialog.vue:135但本 PR 没有改动 case 'import_scanned':
return { homes_added: 1, versions_added: 0, instances_added: 2, skipped_known: 0 } as T后果: 最小修复:mock 的 非阻塞建议
验证情况
修好阻塞项(补 mock |
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.
TL;DR (EN)
Fixes the two defects from issue #39 in the scan/import wizard (Settings → 导入本机环境, added by #31 / #34): importing a local version/source directory never created an instance and silently reported success, and the auto-registered
~/.dshhome (idhome-user-dsh) could never be turned into instances because its profiles were disabled. This PR makes every import outcome explicit (per-item added / skipped / failed + reason), re-enables profiles of already-known homes, and binds new instances to the version the user actually picked instead of blindly using the first one.改动内容
后端(
src-tauri/src/scan.rs)ImportReport新增逐项明细items: Vec<ImportItem>(kind: home|version|instance、name、status: added|skipped|failed、reason),保留原有四计数字段兼容旧前端;失败不再静默continuefailed+ 原因「目录不存在」skipped+ 原因(幂等行为保留,仍计入skipped_known)added(版本本身不是实例;前端会明确提示)ImportScannedInput新增可选preferred_version_dir(issue Scan/import wizard: importing a local source dir silently creates no instance, and the auto-registered ~/.dsh home can never be discovered in instance management #39 R3):实例创建时优先绑定用户所选版本目录(前端传第一个添加的版本);指定但未在 config 中 → 该实例failed并跳过创建,不再静默绑定错误版本;未指定时回落第一个已知版本;无任何版本时实例仍创建但附带警告原因「未绑定版本,请在实例编辑器中指定」apply_import(&mut Config, &ImportScannedInput) -> ImportReport,命令层import_scanned仅做 clone / 调用 /save_state,便于单元测试前端
components/ImportScanDialog.vuealready_knownhome 的 profile 禁用(issue Scan/import wizard: importing a local source dir silently creates no instance, and the auto-registered ~/.dsh home can never be discovered in instance management #39 问题 2:~/.dsh等已登记 HOME 的 profile 可正常勾选导入),默认选中也覆盖已登记 home 的 web/tui profile(幂等,重复导入跳过)failed项时改Message.warning(含失败计数),不再无条件成功preferredVersionDir(用户添加的第一个版本目录)views/Instances.vue:表格上方新增「已登记但无实例的 HOME」提示条(列出 home 名 + 跳转设置页导入向导的入口),问题 2 的「在实例管理中不可见」有了明确出口api/types.ts:ImportItem、ImportReport.items、ImportScannedInput.preferredVersionDir类型同步locales/zh-CN.json/en-US.json:新增importScan.itemAdded/itemSkipped/itemFailed/versionNotInstance/doneWithFailures/removeVersion与instances.homesWithoutInstances*,两语言键集同步测试(
scan.rs#[cfg(test)])import_versions_only_never_creates_instances_and_reports_items:仅导入版本 → 0 实例,逐项added(回归问题 1)import_missing_dirs_fail_per_item_instead_of_silently_skipping:不存在的版本/HOME 目录 →failed+ 原因import_creates_instances_and_binds_preferred_version:home+profile → 实例绑定preferred_version_dir对应版本import_preferred_version_missing_fails_instances:所选版本不可用 → 实例failed、不创建(回归 R3)import_is_idempotent_and_counts_skips:重复导入不产生重复实例,skipped_known计数正确import_without_any_version_creates_instance_with_warning:无版本时实例创建 + 警告原因验证
cargo test --workspace --locked(Windows cargo 1.97.0):118 passed / 0 failed(含上述 6 个新增用例)cargo clippy --workspace --all-targets --locked -D warnings:0 警告cargo fmt --check:通过pnpm build(vue-tsc + vite):通过Notes