feat(sidebar): scan a single folder from the folder context menu (#1108)

The Refresh menu can scope a scan to one model root, but the folder a user is
looking at lives in the sidebar's unified tree, which merges every root into one
relative-path namespace. "Scan this folder" therefore addresses the folder, not a
root: the backend walks that relative path under every root that holds it, which
is also what makes the action safe while another drive is switched off.

Backend:
* GET /scan accepts `folder=<rel>` (alone or with `roots=`), rejected together
  with full_rebuild=true like the roots parameter. Validation reuses
  normalize_relative_folder(), extracted to module scope from ModelMoveService so
  the folder operations and the scan endpoint reject the same input (absolute
  paths, drive letters, `..` climbing) instead of each carrying its own copy.
* The reconcile summary carries `scope_label` (the folder) for a folder scope, so
  the result toast names the folder the user clicked instead of the roots it
  happens to live under; the completed WS payload carries it too.
* `folder` is a scope prefix exactly like a root: only that subtree is re-read or
  pruned, and an unreachable root keeps the entries that fall inside it.

Frontend:
* The sidebar folder context menu gains "Scan this folder" above "Check for
  updates in this folder" (they share the refresh divider); the entry is gated by
  the same supportsFolderManagement flag as the other folder operations.
* SidebarManager.scanFolder() resolves the node through the existing
  _resolveFolderCandidates() before doing anything: a folder no root holds any
  more explains itself ("no longer exists on disk") instead of scanning nothing,
  and an unresolvable multi-root node is refused rather than guessed.
* PageControls.refreshModels() and BaseModelApi.refreshModels() forward the folder
  scope, and _showRefreshSummary() prefers scope_label over the walked roots.

Verified live on the three-root sandbox with one drive switched off:
GET /scan?folder=pack000 walks drive-G and drive-Y, reports scope_label=pack000,
keeps drive-Z's 6 entries under that folder (kept_unreachable=6) and leaves all
420 models cached. 3704 passed, 7 skipped; frontend 1495 passed (150 files); vue
widgets 96 passed. The 2 new sidebar keys are [TODO: Translate] placeholders
pending the feature owner's go-ahead.
This commit is contained in:
Will Miao
2026-10-07 15:15:35 +08:00
parent bd184559bf
commit 12930ce78c
23 changed files with 465 additions and 55 deletions
+4
View File
@@ -1482,6 +1482,10 @@
"success": "{count} Update(s) für {type}s in diesem Ordner gefunden",
"none": "Alle {type}s in diesem Ordner sind aktuell",
"error": "Fehler beim Prüfen des Ordners auf {type}-Updates: {message}"
},
"scanFolder": "[TODO: Translate] Scan this folder",
"scanFolderResult": {
"missing": "[TODO: Translate] This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {
+4
View File
@@ -1482,6 +1482,10 @@
"success": "Found {count} update(s) for {type}s in this folder",
"none": "All {type}s in this folder are up to date",
"error": "Failed to check folder for {type} updates: {message}"
},
"scanFolder": "Scan this folder",
"scanFolderResult": {
"missing": "This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {
+4
View File
@@ -1482,6 +1482,10 @@
"success": "Se encontraron {count} actualización(es) para {type}s en esta carpeta",
"none": "Todos los {type}s en esta carpeta están actualizados",
"error": "Error al buscar actualizaciones de {type} en la carpeta: {message}"
},
"scanFolder": "[TODO: Translate] Scan this folder",
"scanFolderResult": {
"missing": "[TODO: Translate] This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {
+4
View File
@@ -1482,6 +1482,10 @@
"success": "{count} mise(s) à jour trouvée(s) pour les {type}s dans ce dossier",
"none": "Tous les {type}s dans ce dossier sont à jour",
"error": "Échec de la vérification des mises à jour {type} dans ce dossier : {message}"
},
"scanFolder": "[TODO: Translate] Scan this folder",
"scanFolderResult": {
"missing": "[TODO: Translate] This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {
+4
View File
@@ -1482,6 +1482,10 @@
"success": "נמצאו {count} עדכון/ים עבור {type}s בתיקייה זו",
"none": "כל ה-{type}s בתיקייה זו מעודכנים",
"error": "נכשל בבדיקת עדכוני {type} בתיקייה: {message}"
},
"scanFolder": "[TODO: Translate] Scan this folder",
"scanFolderResult": {
"missing": "[TODO: Translate] This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {
+4
View File
@@ -1482,6 +1482,10 @@
"success": "このフォルダの{type}sに{count}件のアップデートが見つかりました",
"none": "このフォルダのすべての{type}sは最新です",
"error": "フォルダの{type}アップデート確認に失敗しました: {message}"
},
"scanFolder": "[TODO: Translate] Scan this folder",
"scanFolderResult": {
"missing": "[TODO: Translate] This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {
+4
View File
@@ -1482,6 +1482,10 @@
"success": "이 폴더에서 {type}s에 대한 {count}개 업데이트를 찾았습니다",
"none": "이 폴더의 모든 {type}s가 최신 상태입니다",
"error": "폴더의 {type} 업데이트 확인 실패: {message}"
},
"scanFolder": "[TODO: Translate] Scan this folder",
"scanFolderResult": {
"missing": "[TODO: Translate] This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {
+4
View File
@@ -1482,6 +1482,10 @@
"success": "Найдено {count} обновление(й) для {type}s в этой папке",
"none": "Все {type}s в этой папке актуальны",
"error": "Не удалось проверить папку на наличие обновлений {type}: {message}"
},
"scanFolder": "[TODO: Translate] Scan this folder",
"scanFolderResult": {
"missing": "[TODO: Translate] This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {
+4
View File
@@ -1482,6 +1482,10 @@
"success": "在此文件夹中找到 {count} 个{type}更新",
"none": "此文件夹中的所有{type}都是最新版本",
"error": "检查文件夹{type}更新失败: {message}"
},
"scanFolder": "[TODO: Translate] Scan this folder",
"scanFolderResult": {
"missing": "[TODO: Translate] This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {
+4
View File
@@ -1482,6 +1482,10 @@
"success": "在此資料夾中找到 {count} 個{type}更新",
"none": "此資料夾中的所有{type}都是最新版本",
"error": "檢查資料夾{type}更新失敗: {message}"
},
"scanFolder": "[TODO: Translate] Scan this folder",
"scanFolderResult": {
"missing": "[TODO: Translate] This folder no longer exists on disk. Refresh the sidebar and try again."
}
},
"statistics": {