Summary
Two closely related defects in the local-environment import wizard (Settings → 导入本机环境, added by issue #31 / PR #34) on Windows, both still present on the latest upstream/main (3a802ae, tag v0.2.4-dev.109):
- Importing a local source/version directory "always succeeds" but creates nothing — no instance is made and no failure message or reason is ever shown.
C:\Users\yuki\.dsh is shown as "已登记 / registered", but it can never be discovered in instance management.
Problem 1: importing a local source dir silently creates no instance
Looking at src-tauri/src/scan.rs (import_scanned, lines 362–456):
- The
input.versions loop only pushes a DshVersion record into the config (lines 369–386). Instances are created exclusively from (home, profile) pairs in the homes loop below. So adding a local source checkout / npm tree in the wizard and clicking 导入所选 registers a version, but never creates an instance. The frontend then always shows a success toast 已导入 {instances_added} 个实例 where instances_added is 0 (ImportScanDialog.vue lines 106–114), and the instance list does not change — with zero explanation that a version alone is not an instance.
- Failure paths are silent:
if !path.is_dir() { continue; } for versions (line 371) and if !path.is_dir() && home.wsl.is_none() { continue; } for homes (line 390) skip entries without recording any per-item error. ImportReport only has counters (homes_added / versions_added / instances_added / skipped_known), so a completely failed import still reports success.
- New instances always get
version_id: cfg.versions.first().map(|v| v.id.clone()).unwrap_or_default() (lines 438–442) — the first configured version, not the one the user picked. If no version exists yet (user only checked profiles), version_id becomes "", and the instance is only discovered to be unlaunchable at launch time via resolve_instance_paths → "版本不存在" (commands.rs line 891). No validation at import time.
Problem 2: auto-registered ~/.dsh can never become a visible instance
ensure_user_dsh_home (src-tauri/src/config.rs lines 300–319) auto-registers %USERPROFILE%\.dsh as a HOME record (id: "home-user-dsh", name "用户默认 (~/.dsh)") on every config load, but never creates instances for its profiles.
- In
ImportScanDialog.vue the checkboxes of home.already_known homes are :disabled="home.already_known" (line 157) and excluded from default selection (if (home.already_known) continue, line 45). Because ~/.dsh is auto-registered, it is always already_known, so its profiles can never be imported as instances through the wizard — nothing to click, no message.
- The instance management page only renders
store.instances; since no instance references home-user-dsh, the home never appears there. Net effect: the launcher says the home is "registered", but there is no in-app path from that fact to an importable instance (the only workaround is hand-creating an instance elsewhere).
Repro (Windows)
- Have an existing
C:\Users\yuki\.dsh (auto-registered at launcher startup).
- Settings → 导入本机环境 → scan: the home appears with the "已登记" tag and all profile checkboxes disabled.
- Add a local DSH version directory (source checkout or npm tree), click 导入所选 → success toast with
0 instances; the 实例管理 list is unchanged; no error or reason anywhere.
Expected behavior
- Importing a version directory should either create an instance bound to it, or clearly state that a version alone is not an instance; per-item failures/skips should be reported instead of a blanket success toast.
- Already-registered homes should remain importable (don't disable their profiles), or the instances/home pages should surface homes that exist but have no instance.
version_id for imported instances should reference the version the user actually chose (and be validated), not cfg.versions.first().
Environment
- dsh-launcher
upstream/main 3a802ae (v0.2.4-dev.109)
- Windows 11, DSH_HOME
C:\Users\yuki\.dsh
Summary
Two closely related defects in the local-environment import wizard (Settings → 导入本机环境, added by issue #31 / PR #34) on Windows, both still present on the latest
upstream/main(3a802ae, tagv0.2.4-dev.109):C:\Users\yuki\.dshis shown as "已登记 / registered", but it can never be discovered in instance management.Problem 1: importing a local source dir silently creates no instance
Looking at
src-tauri/src/scan.rs(import_scanned, lines 362–456):input.versionsloop only pushes aDshVersionrecord into the config (lines 369–386). Instances are created exclusively from(home, profile)pairs in the homes loop below. So adding a local source checkout / npm tree in the wizard and clicking 导入所选 registers a version, but never creates an instance. The frontend then always shows a success toast已导入 {instances_added} 个实例whereinstances_addedis0(ImportScanDialog.vuelines 106–114), and the instance list does not change — with zero explanation that a version alone is not an instance.if !path.is_dir() { continue; }for versions (line 371) andif !path.is_dir() && home.wsl.is_none() { continue; }for homes (line 390) skip entries without recording any per-item error.ImportReportonly has counters (homes_added/versions_added/instances_added/skipped_known), so a completely failed import still reports success.version_id: cfg.versions.first().map(|v| v.id.clone()).unwrap_or_default()(lines 438–442) — the first configured version, not the one the user picked. If no version exists yet (user only checked profiles),version_idbecomes"", and the instance is only discovered to be unlaunchable at launch time viaresolve_instance_paths→ "版本不存在" (commands.rsline 891). No validation at import time.Problem 2: auto-registered
~/.dshcan never become a visible instanceensure_user_dsh_home(src-tauri/src/config.rslines 300–319) auto-registers%USERPROFILE%\.dshas a HOME record (id: "home-user-dsh", name "用户默认 (~/.dsh)") on every config load, but never creates instances for its profiles.ImportScanDialog.vuethe checkboxes ofhome.already_knownhomes are:disabled="home.already_known"(line 157) and excluded from default selection (if (home.already_known) continue, line 45). Because~/.dshis auto-registered, it is alwaysalready_known, so its profiles can never be imported as instances through the wizard — nothing to click, no message.store.instances; since no instance referenceshome-user-dsh, the home never appears there. Net effect: the launcher says the home is "registered", but there is no in-app path from that fact to an importable instance (the only workaround is hand-creating an instance elsewhere).Repro (Windows)
C:\Users\yuki\.dsh(auto-registered at launcher startup).0instances; the 实例管理 list is unchanged; no error or reason anywhere.Expected behavior
version_idfor imported instances should reference the version the user actually chose (and be validated), notcfg.versions.first().Environment
upstream/main3a802ae(v0.2.4-dev.109)C:\Users\yuki\.dsh