fix: missing-dep [add] button respects MOD_ID_ALIASES on build mismatch
When user is on B42 and a mod requires the B41 mod_id (e.g. truemusic_mixtape_megapack require=truemusic), the canonical wsid (2613146550, B41-only) is rightly filtered out by the build guard — but we were silently dropping the suggestion. Now we fall back to MOD_ID_ALIASES: truemusic → TrueMoozic, suggest wsid 3632610172. - _lookup_wsids_for_missing returns Dict[str, Tuple[wsid, suggested_mod_id]] - build_warnings unpacks tuple, label clarifies rename when alias used - adapters.build_response signature updated for new shape
This commit is contained in:
@@ -84,17 +84,20 @@ def _resolve_satisfied_via_alias(input_modids: Set[str]) -> Set[str]:
|
||||
|
||||
def build_warnings(
|
||||
mlos_warnings: Dict[str, Any],
|
||||
wsid_lookup: Dict[str, str] | None = None,
|
||||
wsid_lookup: Dict[str, Tuple[str, str]] | None = None,
|
||||
source_wsids: Dict[str, str] | None = None,
|
||||
input_modids: Set[str] | None = None,
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Translate mlos_sort warnings to the SORTOF_DATA WARNINGS shape.
|
||||
|
||||
wsid_lookup: optional {mod_id -> workshop_id} map of *deps* we already
|
||||
have cached. When provided, each 'missing' warning is augmented with
|
||||
`actions: [{type: "add-wsid", wsid, label}]` so the frontend can render
|
||||
a click-to-add button. Unknown deps fall back to a Steam Workshop search
|
||||
link the user follows manually.
|
||||
wsid_lookup: optional {missing_mod_id -> (workshop_id, suggested_mod_id)}
|
||||
map produced by app._lookup_wsids_for_missing. The `suggested_mod_id`
|
||||
differs from the missing mod_id when a MOD_ID_ALIASES alternative was
|
||||
used because the canonical mod_id's only cached wsid is wrong-build
|
||||
(e.g. user on B42 needs `truemusic` → suggest `TrueMoozic`'s wsid).
|
||||
When provided, each 'missing' warning is augmented with `actions:
|
||||
[{type: "add-wsid", wsid, modId, label}]`. Unknown deps fall back to a
|
||||
Steam Workshop search link the user follows manually.
|
||||
|
||||
source_wsids: optional {mod_id -> workshop_id} map of *every cached mod
|
||||
in the current sort*. Used to attach the source mod's wsid onto
|
||||
@@ -120,13 +123,19 @@ def build_warnings(
|
||||
continue
|
||||
actions: List[Dict[str, str]] = []
|
||||
for dep in deps:
|
||||
wsid = lookup.get(dep)
|
||||
if wsid:
|
||||
entry = lookup.get(dep)
|
||||
if entry:
|
||||
wsid, suggested = entry
|
||||
# If MOD_ID_ALIASES rewrote the suggestion (B42 user needing
|
||||
# B41 mod_id `truemusic` gets `TrueMoozic` instead), surface
|
||||
# both names so the user understands what's being added.
|
||||
label = (f"add {suggested}" if suggested == dep
|
||||
else f"add {suggested} (renamed from {dep})")
|
||||
actions.append({
|
||||
"type": "add-wsid",
|
||||
"wsid": wsid,
|
||||
"modId": dep,
|
||||
"label": f"add {dep}",
|
||||
"modId": suggested,
|
||||
"label": label,
|
||||
})
|
||||
else:
|
||||
# No cache hit -> link to Steam Workshop search so the user
|
||||
@@ -558,7 +567,7 @@ def build_response(
|
||||
mods: List[ModInfo],
|
||||
sort_result: Dict[str, Any],
|
||||
status: str,
|
||||
wsid_lookup: Dict[str, str] | None = None,
|
||||
wsid_lookup: Dict[str, Tuple[str, str]] | None = None,
|
||||
pz_build: str = "B42",
|
||||
is_resort: bool = False,
|
||||
selected_modids: Optional[Set[str]] = None,
|
||||
|
||||
Reference in New Issue
Block a user