fix(send-to-workflow): strip file extension before searching relative paths

Backend _relative_path_matches_tokens() removes extensions from paths
before matching (commit 43f6bfab). This fix ensures frontend also
removes extensions from search terms to avoid matching failures.

Fixes issue where send model to workflow would receive absolute
paths instead of relative paths because the API returned empty
results when searching with file extension.
This commit is contained in:
Will Miao
2026-03-09 15:49:37 +08:00
parent cda271890a
commit 97979d9e7c

View File

@@ -483,8 +483,12 @@ async function ensureRelativeModelPath(modelPath, collectionType) {
return modelPath;
}
// Remove model file extension (.safetensors, .ckpt, .pt, .bin) for cleaner matching
// Backend removes extensions from paths before matching, so search term should not include extension
const searchTerm = fileName.replace(/\.(safetensors|ckpt|pt|bin)$/i, '');
try {
const response = await fetch(`/api/lm/${collectionType}/relative-paths?search=${encodeURIComponent(fileName)}&limit=10`);
const response = await fetch(`/api/lm/${collectionType}/relative-paths?search=${encodeURIComponent(searchTerm)}&limit=10`);
if (!response.ok) {
return modelPath;
}