Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: make the partial download affordance tell the truth (#8982)
Michael Han7b58b5622843
diff --git a/studio/backend/hub/schemas/datasets.py b/studio/backend/hub/schemas/datasets.pyindex f4aa269f825..c72623d97e2 100644--- a/studio/backend/hub/schemas/datasets.py+++ b/studio/backend/hub/schemas/datasets.py@@ -99,6 +99,7 @@ class CachedDatasetItem(BaseModel):processed_cache: bool = Falsepartial: bool = Falsepartial_transport: Optional[str] = None+ partial_resumable: bool = Falseclass CachedDatasetsResponse(BaseModel):diff --git a/studio/backend/hub/schemas/downloads.py b/studio/backend/hub/schemas/downloads.pyindex dd8d0430cd3..9397bdc9196 100644--- a/studio/backend/hub/schemas/downloads.py+++ b/studio/backend/hub/schemas/downloads.py@@ -135,6 +135,9 @@ class TransportCapabilities(BaseModel):xet: TransportCapabilityauto_resolves_to: Literal["xet", "http"] = "xet"auto_reason: Optional[str] = None+ # False when the installed huggingface_hub refetches an interrupted file from zero, so no+ # transport can offer a byte-resume and the UI must not label one.+ partials_resumable: bool = Trueclass TransportStatusResponse(BaseModel):diff --git a/studio/backend/hub/schemas/inventory.py b/studio/backend/hub/schemas/inventory.pyindex 1f56c11d6c7..2210398b666 100644--- a/studio/backend/hub/schemas/inventory.py+++ b/studio/backend/hub/schemas/inventory.py@@ -45,8 +45,15 @@ class GgufVariantDetail(BaseModel):None,description = ('Transport recorded for the partial state ("http" or '- '"xet"), or null if not partial / unknown. Frontend uses '- "this to pick Resume (http) vs Redownload (xet) labels."+ '"xet"), or null if not partial / unknown.'+ ),+ )+ partial_resumable: bool = Field(+ False,+ description = (+ "Whether THIS partial can be continued byte for byte, which is what picks "+ "Resume over Continue. False for a Xet partial, and for an HTTP one no "+ "installed writer can reopen."),)dependency_key: Optional[str] = Field(@@ -177,6 +184,10 @@ class LocalModelInfo(BaseModel):'"xet"), or null if not partial / unknown.'),)+ partial_resumable: bool = Field(+ False,+ description = "Whether THIS partial can be continued byte for byte.",+ )class LocalModelListResponse(BaseModel):@@ -210,6 +221,7 @@ class CachedRepoBase(BaseModel):last_modified: Optional[float] = Nonepartial: bool = Falsepartial_transport: Optional[str] = None+ partial_resumable: bool = Falseinventory_id: Optional[str] = Noneload_id: Optional[str] = Nonemodel_format: ModelFormat = "unknown"diff --git a/studio/backend/hub/services/datasets/cache_inventory.py b/studio/backend/hub/services/datasets/cache_inventory.pyindex 9097ce98f1d..a4a8fb3b74c 100644--- a/studio/backend/hub/services/datasets/cache_inventory.py+++ b/studio/backend/hub/services/datasets/cache_inventory.py@@ -309,6 +309,15 @@ def _scan_hub_dataset_cache_dirs() -> list[dict]:if snapshot_partialelse None),+ "partial_resumable": (+ hf_cache_scan.partial_resume_available(+ "dataset",+ repo_id,+ repo_cache_dir = entry,+ )+ if snapshot_partial+ else False+ ),}if _prefer_dataset_cache_row(row, existing):seen_lower[key] = row@@ -461,6 +470,15 @@ def _scan_hf_dataset_caches() -> list[dict]:if snapshot_partialelse None),+ "partial_resumable": (+ hf_cache_scan.partial_resume_available(+ "dataset",+ repo_info.repo_id,+ repo_cache_dir = cache_dir,+ )+ if snapshot_partial+ else False+ ),}if _prefer_dataset_cache_row(row, existing):seen_lower[key] = row@@ -481,6 +499,8 @@ def _scan_hf_dataset_caches() -> list[dict]:and row.get("partial_transport")):existing["partial_transport"] = row["partial_transport"]+ # The resume verdict belongs to the transport it was measured against.+ existing["partial_resumable"] = bool(row.get("partial_resumable"))for row in _scan_processed_dataset_caches():key = row["repo_id"].lower()existing = seen_lower.get(key)@@ -496,6 +516,7 @@ def _scan_hf_dataset_caches() -> list[dict]:if existing.get("partial") and not row.get("partial"):existing["partial"] = Falseexisting["partial_transport"] = None+ existing["partial_resumable"] = Falsefor row in _scan_app_processed_dataset_caches():key = row["repo_id"].lower()existing = seen_lower.get(key)diff --git a/studio/backend/hub/services/models/cache_inventory.py b/studio/backend/hub/services/models/cache_inventory.pyindex 72acc2e2c6d..119ff55e3a9 100644--- a/studio/backend/hub/services/models/cache_inventory.py+++ b/studio/backend/hub/services/models/cache_inventory.py@@ -566,6 +566,7 @@ def _scan_cached_gguf(# GGUF row-level transport is ambiguous (variants may differ);# per-variant detail lives on GgufVariantDetail."partial_transport": None,+ "partial_resumable": False,}last_modified = max(last_modified, (existing or {}).get("last_modified", 0.0))if last_modified > 0:@@ -1068,6 +1069,15 @@ def _scan_cached_models(if download_partialelse None),+ "partial_resumable": (+ hf_cache_scan.partial_resume_available(+ "model",+ repo_id,+ repo_cache_dir = repo_path,+ )+ if download_partial+ else False+ ),# Diffusion repos with no pipeline index load only via from_single_file, so the task pickers must not offer them as# pipeline loads. Without this the picker's single_file gate sees undefined on every hub-sourced row. Read from the# row's snapshot: the manifest a sibling revision carries is not the one this row's load_id opens.diff --git a/studio/backend/hub/services/models/common.py b/studio/backend/hub/services/models/common.pyindex b4b32e8b292..68c6ac9d0c9 100644--- a/studio/backend/hub/services/models/common.py+++ b/studio/backend/hub/services/models/common.py@@ -424,6 +424,7 @@ def _apply_format_aware_partial(snapshot_partial: bool,gguf_partial: bool,snapshot_partial_transport: Optional[str] = None,+ snapshot_partial_resumable: bool = False,) -> List[LocalModelInfo]:"""Rewrite each row's partial flag with format-aware predicates so a hybrid (gguf + safetensors) repo's broken format doesn't taint the clean one; capabilities are recomputed from the new flag."""rewritten: List[LocalModelInfo] = []@@ -440,6 +441,9 @@ def _apply_format_aware_partial(update = {"partial": True,"partial_transport": partial_transport,+ "partial_resumable": (+ partial_transport is not None and snapshot_partial_resumable+ ),"capabilities": _capabilities_for_format(row.model_format,row.source,diff --git a/studio/backend/hub/services/models/gguf_variants.py b/studio/backend/hub/services/models/gguf_variants.pyindex bd87ebdd954..6a5e6b75821 100644--- a/studio/backend/hub/services/models/gguf_variants.py+++ b/studio/backend/hub/services/models/gguf_variants.py@@ -400,6 +400,19 @@ def _partial_transport_for_variant()+def _partial_resumable_for_variant(+ repo_id: str,+ variant: str,+ repo_cache_dir: Optional[Path] = None,+) -> bool:+ return hf_cache_scan.partial_resume_available(+ "model",+ repo_id,+ variant,+ repo_cache_dir,+ )++def _local_main_gguf_blobs_by_quant(repo_id: str, repo_cache_dir: Optional[Path] = None) -> dict[str, dict[str, set[str]]]:@@ -1036,6 +1049,11 @@ async def get_gguf_variants_answer(v.quant,repo_cache_dir,),+ partial_resumable = _partial_resumable_for_variant(+ response_repo_id,+ v.quant,+ repo_cache_dir,+ ),dependency_key = _variant_dependency_key(response_repo_id, v.filename),)for v in variants@@ -1065,6 +1083,9 @@ async def get_gguf_variants_answer(partial_transport = _partial_transport_for_variant(repo_id, v.quant, repo_cache_dir),+ partial_resumable = _partial_resumable_for_variant(+ repo_id, v.quant, repo_cache_dir+ ),dependency_key = _variant_dependency_key(repo_id, v.filename),)for v in state[0]@@ -1474,6 +1495,9 @@ async def get_gguf_variants_answer(),partial = is_partial,partial_transport = (partial_quant_transports.get(v.quant) if is_partial else None),+ partial_resumable = (+ is_partial and _partial_resumable_for_variant(repo_id, v.quant, repo_cache_dir)+ ),dependency_key = _variant_dependency_key(repo_id, v.filename),)diff --git a/studio/backend/hub/services/models/local_inventory.py b/studio/backend/hub/services/models/local_inventory.pyindex b3d1c67fed1..10747cbe601 100644--- a/studio/backend/hub/services/models/local_inventory.py+++ b/studio/backend/hub/services/models/local_inventory.py@@ -362,6 +362,11 @@ def _scan_hf_cache(if snapshot_partialelse None)+ snapshot_partial_resumable = snapshot_partial and hf_cache_scan.partial_resume_available(+ "model",+ model_id,+ repo_cache_dir = repo_dir,+ )resolved = hf_cache_scan.resolve_hf_cache_realpath(repo_dir)scan_path = Path(resolved) if resolved else repo_dirload_path = repo_dir if active_cache else scan_path@@ -435,6 +440,7 @@ def _scan_hf_cache(snapshot_partial = snapshot_partial,gguf_partial = gguf_partial,snapshot_partial_transport = snapshot_partial_transport,+ snapshot_partial_resumable = snapshot_partial_resumable,)found.extend(rows)return founddiff --git a/studio/backend/hub/tests/test_dataset_services.py b/studio/backend/hub/tests/test_dataset_services.pyindex 1362871eb90..816748a0cdb 100644--- a/studio/backend/hub/tests/test_dataset_services.py+++ b/studio/backend/hub/tests/test_dataset_services.py@@ -143,6 +143,7 @@ def test_dataset_cache_scan_attaches_app_bytes_without_replacing_raw_path(monkey"cache_path": "/cache/hub/datasets--Org--Data","partial": False,"partial_transport": None,+ "partial_resumable": False,"processed_cache": True,"app_processed_cache": True,}diff --git a/studio/backend/hub/tests/test_unresumable_partial_purge.py b/studio/backend/hub/tests/test_unresumable_partial_purge.pyindex 13cab815235..fba304ee937 100644--- a/studio/backend/hub/tests/test_unresumable_partial_purge.py+++ b/studio/backend/hub/tests/test_unresumable_partial_purge.py@@ -165,8 +165,12 @@ def test_a_peer_being_written_is_still_protected(monkeypatch, blobs):def test_transport_status_does_not_promise_a_resume_it_cannot_keep(monkeypatch, blobs):- """``resumable`` drives a dialog offering to keep existing progress."""- monkeypatch.setattr(download_registry, "read_active_transport_marker", lambda *_a, **_k: "http")+ """``resumable`` drives a dialog offering to keep existing progress.++ The marker is written rather than stubbed: the verdict reads each cache entry's own+ marker, since one repo can own several and only the one beside a partial vouches for it.+ """+ download_registry._write_marker(blobs.parent, download_registry.TRANSPORT_HTTP)(blobs / _NONCE_PARTIAL).write_bytes(b"x" * 25)monkeypatch.setattr(download_registry, "partial_is_resumable", lambda _name: True)diff --git a/studio/backend/hub/utils/download_manifest.py b/studio/backend/hub/utils/download_manifest.pyindex a0df9a73a45..18e1eefc64b 100644--- a/studio/backend/hub/utils/download_manifest.py+++ b/studio/backend/hub/utils/download_manifest.py@@ -901,8 +901,8 @@ def write_cancel_marker("""Record that this triple was cancelled. Idempotent across repeated cancels.``transport`` ("http"/"xet") is surfaced via partial_transport on- inventory rows so the UI labels HTTP retries as continuable and XET- retries as full redownloads. None is accepted for forward-compat.+ inventory rows so the UI only offers a byte-resume for an HTTP partial.+ None is accepted for forward-compat."""recorded_hub_cache = _canonical_hub_cache(hub_cache)path = marker_path(diff --git a/studio/backend/hub/utils/download_registry.py b/studio/backend/hub/utils/download_registry.pyindex 147226c4e9f..3b1c140b8db 100644--- a/studio/backend/hub/utils/download_registry.py+++ b/studio/backend/hub/utils/download_registry.py@@ -73,6 +73,7 @@ from hub.utils.hf_cache_state import (VALID_TRANSPORTS,VALID_TRANSPORT_MODES,has_active_incomplete_blobs,+ hf_partials_are_resumable,iter_repo_cache_dirs,iter_active_repo_cache_dirs,repo_cache_dir_name,@@ -101,6 +102,9 @@ class DownloadTransportCapabilities:# "Auto (HTTP -- Xet stalled twice on this machine)" instead of just "Auto".auto_resolves_to: str = TRANSPORT_XETauto_reason: Optional[str] = None+ # Whether an interrupted HTTP transfer leaves bytes the next attempt can append to. False on+ # huggingface_hub >= 1.18, so the UI stops offering a byte-resume no writer can honour.+ partials_resumable: bool = Truedef get_download_transport_capabilities(*, probe: bool = False) -> DownloadTransportCapabilities:@@ -156,6 +160,7 @@ def get_download_transport_capabilities(*, probe: bool = False) -> DownloadTrans),auto_resolves_to = auto_transport,auto_reason = auto_reason,+ partials_resumable = hf_partials_are_resumable(),)@@ -1005,6 +1010,8 @@ def is_resumable_partial(repo_type: str,repo_id: str,variant: Optional[str] = None,+ *,+ root: Optional[Path] = None,) -> bool:"""True only when a partial exists AND something can still resume from it.@@ -1012,10 +1019,78 @@ def is_resumable_partial(from scratch, so the marker has to say HTTP. And an HTTP partial is only resumable while awriter that reopens it is installed; the UI turns this flag into "Resume with HTTP to keepthe progress you already have", which must not be promised for bytes about to be swept.++ Decided per cache entry, the way :func:`prepare_cache_for_transport` decides what to purge,+ because one repo can own several active directories at once (a case-sensitive filesystem+ holds ``models--Org--Model`` beside ``models--org--model``). A marker only vouches for+ partials sitting beside it.++ Within an entry the split matters too: main blobs answer to the variant marker, while a+ shared companion (mmproj, MTP drafter) answers to ``.transport.companion``. With a+ ``variant`` the manifest says which hashes are which; a blob in neither set, and a variant+ with no manifest, back nothing rather than an unscoped yes.++ ``root`` is the hub cache the row being judged was found in. A row can come from a+ remembered, legacy or custom cache, and that root holds both its own partials and its own+ manifest scope (state is keyed by a per-cache digest), so leaving it out asked the ACTIVE+ root about a directory it does not contain. ``None`` keeps the active root, for callers+ that have no particular row in hand."""- if read_active_transport_marker(repo_type, repo_id, variant) != TRANSPORT_HTTP:- return False- return bool(incomplete_blob_hashes(repo_type, repo_id, active_only = True, resumable_only = True))+ main, companion = (+ _manifest_hash_split(repo_type, repo_id, variant, root = root) if variant else (set(), set())+ )+ for entry in iter_active_repo_cache_dirs(repo_type, repo_id, root = root):+ resumable = _resumable_blob_hashes(entry)+ if not resumable:+ continue+ if _read_marker(entry, variant) == TRANSPORT_HTTP and (variant is None or resumable & main):+ return True+ if (+ variant is not None+ and resumable & companion+ and _read_companion_marker(entry) == TRANSPORT_HTTP+ ):+ return True+ return False+++def _resumable_blob_hashes(entry: Path) -> set[str]:+ """Blob hashes whose partial sits in THIS entry and can still be appended to."""+ out: set[str] = set()+ try:+ for blob in (entry / "blobs").iterdir():+ if not blob.is_file():+ continue+ blob_hash = incomplete_blob_hash(blob.name)+ if blob_hash is not None and partial_is_resumable(blob.name):+ out.add(blob_hash)+ except OSError:+ return out+ return out+++def _manifest_hash_split(+ repo_type: str,+ repo_id: str,+ variant: Optional[str],+ *,+ root: Optional[Path] = None,+) -> tuple[set[str], set[str]]:+ """``(main, companion)`` blob hashes from the variant's manifest, split the way the worker+ splits them when it asks for a purge. Empty pair when either step cannot answer, which+ reads as "no resume to promise"."""+ from hub.utils import download_manifest++ manifest = download_manifest.read_manifest(repo_type, repo_id, variant, hub_cache = root)+ if manifest is None or not manifest.expected_files or not variant:+ return set(), set()+ try:+ from hub.utils.gguf_plan import plan_from_expected_files+ plan = plan_from_expected_files(variant, manifest.expected_files)+ except Exception as exc: # noqa: BLE001 - an unsplittable manifest promises nothing+ logger.debug("Could not split manifest hashes for %s [%s]: %s", repo_id, variant, exc)+ return set(), set()+ return set(plan.main_hashes), set(plan.companion_hashes)def incomplete_blob_hashes(diff --git a/studio/backend/hub/utils/inventory_scan.py b/studio/backend/hub/utils/inventory_scan.pyindex 92e1d8bc9db..8fa12ee0f55 100644--- a/studio/backend/hub/utils/inventory_scan.py+++ b/studio/backend/hub/utils/inventory_scan.py@@ -1989,3 +1989,32 @@ def partial_transport_for(hub_cache = hub_cache,)return manifest.transport if manifest is not None else None+++def partial_resume_available(+ repo_type: RepoType,+ repo_id: str,+ variant: Optional[str] = None,+ repo_cache_dir: Optional[Path] = None,+) -> bool:+ """Whether THIS partial can be picked up byte for byte, rather than whether some partial+ somewhere could be.++ Both verdicts have to agree: the transport this row reports, and the registry's per-file+ check, which rejects a 1.18+ nonce partial nothing will reopen. The installed+ huggingface_hub cannot answer it alone, since a cache shared with a newer environment+ holds partials this one can never continue.+ """+ from hub.utils import download_registry++ if partial_transport_for(repo_type, repo_id, variant, repo_cache_dir) != "http":+ return False+ # Same root the transport was read from. A row can be displayed from a remembered, legacy+ # or custom cache, and both halves have to answer about THAT directory: the active root+ # neither holds its partials nor shares its manifest scope.+ return download_registry.is_resumable_partial(+ repo_type,+ repo_id,+ variant,+ root = _hub_cache_for_repo_dir(repo_cache_dir),+ )diff --git a/studio/backend/tests/test_hub_download_transport_auto.py b/studio/backend/tests/test_hub_download_transport_auto.pyindex 4dd04caf0d6..841fa23636d 100644--- a/studio/backend/tests/test_hub_download_transport_auto.py+++ b/studio/backend/tests/test_hub_download_transport_auto.py@@ -86,6 +86,15 @@ def test_auto_reports_http_when_hf_xet_is_missing(monkeypatch):assert "hf_xet" in reason+def test_capabilities_carry_the_partial_resume_verdict(monkeypatch):+ """The card labels a partial from this. huggingface_hub >= 1.18 refetches an interrupted file+ from zero, so a byte-resume must not be offered there."""+ monkeypatch.setattr(download_registry, "hf_partials_are_resumable", lambda: False)+ assert download_registry.get_download_transport_capabilities().partials_resumable is False+ monkeypatch.setattr(download_registry, "hf_partials_are_resumable", lambda: True)+ assert download_registry.get_download_transport_capabilities().partials_resumable is True++def test_auto_is_not_a_real_transport():""" "auto" is a request preference: the .transport marker must keep naming the writer thatproduced a partial, or a resume picks the wrong strategy."""diff --git a/studio/backend/tests/test_partial_resume_verdict.py b/studio/backend/tests/test_partial_resume_verdict.pynew file mode 100644index 00000000000..18b5476e5c4--- /dev/null+++ b/studio/backend/tests/test_partial_resume_verdict.py@@ -0,0 +1,301 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""A row may only offer Resume for a partial that can actually be reopened.++The installed huggingface_hub cannot answer this alone. A cache shared with a newer+environment holds ``<etag>.<nonce>.incomplete`` files that even a resuming writer will not+reopen, and this repo's own pins produce exactly that mix: Python 3.10+ takes hub >= 1.23,+older takes 0.36.2, one cache between them. Deriving the answer from transport plus installed+version promised a resume there and then purged the bytes.+"""++from __future__ import annotations++import sys+from pathlib import Path++import pytest++_BACKEND_DIR = str(Path(__file__).resolve().parent.parent)+if _BACKEND_DIR not in sys.path:+ sys.path.insert(0, _BACKEND_DIR)++from hub.utils import download_manifest, download_registry, hf_cache_state, state_dir+from hub.utils.download_manifest import ExpectedFile+from hub.utils.inventory_scan import partial_resume_available+++BLOB = "a" * 64+LEGACY_PARTIAL = f"{BLOB}{hf_cache_state.INCOMPLETE_SUFFIX}"+NONCE_PARTIAL = f"{BLOB}.deadbeef{hf_cache_state.INCOMPLETE_SUFFIX}"+++def cache(monkeypatch, tmp_path):+ """A repo cache with a legacy huggingface_hub installed, so only the per-file check can+ reject a partial."""+ root = tmp_path / "hub"+ entry = root / "models--Org--Model"+ (entry / "blobs").mkdir(parents = True)+ monkeypatch.setenv("HF_HUB_CACHE", str(root))+ monkeypatch.setattr(state_dir, "cache_root", lambda: tmp_path / "state")+ for module in (download_registry, hf_cache_state):+ monkeypatch.setattr(module, "hf_cache_root", lambda **_kw: root, raising = False)+ monkeypatch.setattr(hf_cache_state, "hf_cache_roots", lambda *_a, **_k: [root])+ monkeypatch.setattr(hf_cache_state, "hf_partials_are_resumable", lambda: True)+ return entry+++def _record(transport: str, entry: Path):+ """What a worker leaves behind: the manifest the row reads, and the marker naming the+ writer that produced the partial."""+ download_manifest.write_manifest(+ "model",+ "Org/Model",+ "Q4_K_M",+ [ExpectedFile(path = "model-Q4_K_M.gguf", size = 4096, sha256 = BLOB)],+ transport,+ )+ download_registry._write_marker(entry, transport, "Q4_K_M")+++def _partial(entry: Path, name: str):+ (entry / "blobs" / name).write_bytes(b"x" * 128)+++def test_a_reopenable_http_partial_can_be_resumed(cache):+ _record("http", cache)+ _partial(cache, LEGACY_PARTIAL)+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is True+++def test_a_nonce_partial_cannot_be_resumed_by_any_writer(cache):+ """The bug: hub <= 1.17 is installed and the marker says HTTP, so a version-only check+ said Resume. This file was written by a 1.18+ client and will be purged, not continued."""+ _record("http", cache)+ _partial(cache, NONCE_PARTIAL)+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++def test_a_xet_partial_is_never_resumable(cache):+ _record("xet", cache)+ _partial(cache, LEGACY_PARTIAL)+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++def test_a_row_with_no_partial_left_has_nothing_to_resume(cache):+ _record("http", cache)+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++def test_a_writer_that_cannot_reopen_anything_never_promises_a_resume(cache, monkeypatch):+ """The ordinary install: hub >= 1.18 refetches from zero, so even a legacy-named+ survivor is litter."""+ monkeypatch.setattr(hf_cache_state, "hf_partials_are_resumable", lambda: False)+ _record("http", cache)+ _partial(cache, LEGACY_PARTIAL)+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++def test_an_unmarked_partial_is_not_resumable(cache):+ """No manifest and no marker: nothing attributes the partial to a writer that resumes."""+ _partial(cache, LEGACY_PARTIAL)+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++def test_a_siblings_resumable_partial_does_not_speak_for_this_one(cache):+ """Two quants of one repo: this one's partial is nonce-named and doomed, the sibling's is+ reopenable. The blob scan behind is_resumable_partial is repo-wide, so the sibling's bytes+ must not answer for this row."""+ _record("http", cache)+ _partial(cache, NONCE_PARTIAL)+ sibling = "b" * 64+ download_manifest.write_manifest(+ "model",+ "Org/Model",+ "Q8_0",+ [ExpectedFile(path = "model-Q8_0.gguf", size = 4096, sha256 = sibling)],+ "http",+ )+ download_registry._write_marker(cache, "http", "Q8_0")+ _partial(cache, f"{sibling}{hf_cache_state.INCOMPLETE_SUFFIX}")++ assert partial_resume_available("model", "Org/Model", "Q8_0") is True+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++COMPANION = "c" * 64+++def _record_with_companion(transport: str, entry: Path):+ """A vision quant: its own shard plus the shared mmproj, which every sibling downloads."""+ download_manifest.write_manifest(+ "model",+ "Org/Model",+ "Q4_K_M",+ [+ ExpectedFile(path = "model-Q4_K_M.gguf", size = 4096, sha256 = BLOB),+ ExpectedFile(path = "mmproj-F16.gguf", size = 2048, sha256 = COMPANION),+ ],+ transport,+ )+ download_registry._write_marker(entry, transport, "Q4_K_M")+++def test_a_companion_partial_from_another_transport_is_not_a_resume(cache):+ """The companion is governed by .transport.companion, not by this variant's marker.+ prepare_cache_for_transport purges it on an HTTP run, so it cannot back a Resume."""+ _record_with_companion("http", cache)+ download_registry._write_companion_marker(cache, "xet")+ _partial(cache, f"{COMPANION}{hf_cache_state.INCOMPLETE_SUFFIX}")+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++def test_a_companion_partial_written_by_http_still_resumes(cache):+ _record_with_companion("http", cache)+ download_registry._write_companion_marker(cache, "http")+ _partial(cache, f"{COMPANION}{hf_cache_state.INCOMPLETE_SUFFIX}")+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is True+++def test_an_unmarked_companion_partial_is_not_a_resume(cache):+ _record_with_companion("http", cache)+ _partial(cache, f"{COMPANION}{hf_cache_state.INCOMPLETE_SUFFIX}")+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++def test_the_variants_own_partial_still_decides_for_the_variant(cache):+ """A companion marker disagreeing says nothing about the main shard, which this+ variant's own marker vouches for."""+ _record_with_companion("http", cache)+ download_registry._write_companion_marker(cache, "xet")+ _partial(cache, LEGACY_PARTIAL)+ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is True+++# --------------------------------------------------------------------------------------------+# One repo can own several active cache directories at once: a case-sensitive filesystem holds+# models--Org--Model beside models--org--model, and every one of them matches. The blob scan+# unions them while a marker read answers from whichever comes first, so a verdict built from+# the two separately can pair a partial in one directory with a marker from another.+# prepare_cache_for_transport judges each directory on its own, so the pairing has to as well.+# --------------------------------------------------------------------------------------------+++def split_cache(monkeypatch, tmp_path):+ """Two active entries for one repo. The names are stand-ins so the test also runs on a+ case-insensitive filesystem, where the real pair cannot coexist."""+ root = tmp_path / "hub"+ first = root / "models--Org--Model"+ second = root / "models--Org--Model.case-variant"+ for entry in (first, second):+ (entry / "blobs").mkdir(parents = True)+ monkeypatch.setenv("HF_HUB_CACHE", str(root))+ monkeypatch.setattr(state_dir, "cache_root", lambda: tmp_path / "state")+ monkeypatch.setattr(+ download_registry, "iter_active_repo_cache_dirs", lambda *_a, **_k: iter((first, second))+ )+ monkeypatch.setattr(hf_cache_state, "hf_partials_are_resumable", lambda: True)+ return first, second+++def test_a_marker_does_not_vouch_for_another_directorys_companion(split_cache):+ first, second = split_cache+ _record_with_companion("http", first)+ download_registry._write_companion_marker(first, "http")+ # The partial lives next door, under a Xet companion marker that will purge it.+ download_registry._write_marker(second, "http", "Q4_K_M")+ download_registry._write_companion_marker(second, "xet")+ _partial(second, f"{COMPANION}{hf_cache_state.INCOMPLETE_SUFFIX}")++ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++def test_a_marker_does_not_vouch_for_another_directorys_main_partial(split_cache):+ first, second = split_cache+ _record("http", first)+ # Same repo, other directory, written by Xet: its own marker is what decides.+ download_registry._write_marker(second, "xet", "Q4_K_M")+ _partial(second, LEGACY_PARTIAL)++ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is False+++def test_a_partial_and_its_own_directorys_marker_still_resume(split_cache):+ first, second = split_cache+ _record("http", first)+ download_registry._write_marker(second, "http", "Q4_K_M")+ _partial(second, LEGACY_PARTIAL)++ assert partial_resume_available("model", "Org/Model", "Q4_K_M") is True+++# --------------------------------------------------------------------------------------------+# A row is not always displayed from the active cache. local_inventory enumerates remembered+# ("previous HF cache") and custom roots too, and hands each row's own directory down. That+# root holds its own partials and its own manifest scope (state_dir keys manifests by a+# per-cache digest), so the resume verdict has to be asked of it and not of the active root.+# --------------------------------------------------------------------------------------------+++def two_roots(monkeypatch, tmp_path):+ """The active hub cache plus a remembered one, both holding the same repo."""+ active = tmp_path / "hub"+ previous = tmp_path / "old" / "hub"+ for root in (active, previous):+ (root / "models--Org--Model" / "blobs").mkdir(parents = True)+ monkeypatch.setenv("HF_HUB_CACHE", str(active))+ monkeypatch.setattr(state_dir, "cache_root", lambda: tmp_path / "state")+ monkeypatch.setattr(hf_cache_state, "hf_partials_are_resumable", lambda: True)+ for module in (download_registry, hf_cache_state):+ monkeypatch.setattr(+ module,+ "hf_cache_root",+ lambda root = None, **_kw: Path(root) if root is not None else active,+ raising = False,+ )+ monkeypatch.setattr(hf_cache_state, "hf_cache_roots", lambda *_a, **_k: [active, previous])+ return active / "models--Org--Model", previous / "models--Org--Model"+++def _record_in(+ entry: Path,+ transport: str,+ variant,+ blob: str = BLOB,+):+ download_manifest.write_manifest(+ "model",+ "Org/Model",+ variant,+ [ExpectedFile(path = f"model-{variant or 'main'}.gguf", size = 4096, sha256 = blob)],+ transport,+ hub_cache = entry.parent,+ )+ download_registry._write_marker(entry, transport, variant)+++def test_another_roots_partial_does_not_vouch_for_this_row(two_roots):+ """The displayed row lives in the remembered cache and its partial is nonce-named, so+ nothing can reopen it. The active root's legacy partial for the same repo must not be+ what turns this row into "Resume with HTTP to keep the progress you already have"."""+ active, previous = two_roots+ _record_in(active, "http", None)+ _partial(active, LEGACY_PARTIAL)+ _record_in(previous, "http", None)+ _partial(previous, NONCE_PARTIAL)++ assert partial_resume_available("model", "Org/Model", None, previous) is False+++def test_a_remembered_roots_own_partial_still_resumes(two_roots):+ """And the other direction: the row's bytes are reopenable and its manifest lives in that+ root's scope, so the verdict may not be lost just because the active root is empty."""+ active, previous = two_roots+ _record_in(previous, "http", "Q4_K_M")+ _partial(previous, LEGACY_PARTIAL)++ assert partial_resume_available("model", "Org/Model", "Q4_K_M", previous) is Truediff --git a/studio/frontend/src/features/hub/catalog/dataset-download-section.tsx b/studio/frontend/src/features/hub/catalog/dataset-download-section.tsxindex 45988e05e4c..f3268aabda9 100644--- a/studio/frontend/src/features/hub/catalog/dataset-download-section.tsx+++ b/studio/frontend/src/features/hub/catalog/dataset-download-section.tsx@@ -6,7 +6,7 @@ import {TooltipContent,TooltipTrigger,} from "@/components/ui/tooltip";-import { useRepoDownload } from "../download-manager";+import { useHttpPartialsResumable, useRepoDownload } from "../download-manager";import { deleteCachedDataset } from "../inventory";import { cn } from "@/lib/utils";import { TrainIcon } from "../components/train-icon";@@ -33,6 +33,7 @@ export function DatasetDownloadSection({isDownloaded,isPartial = false,partialTransport = null,+ partialResumable = false,cachePath,knownBytes,onTrain,@@ -42,6 +43,7 @@ export function DatasetDownloadSection({isDownloaded: boolean;isPartial?: boolean;partialTransport?: string | null;+ partialResumable?: boolean;cachePath?: string | null;knownBytes?: number | null;onTrain?: () => void;@@ -86,6 +88,7 @@ export function DatasetDownloadSection({const downloading = progress !== null;const canDelete =(isDownloaded || isPartial) && !downloading && !cancelling && !deleting;+ const partialsResumable = useHttpPartialsResumable();const downloadAction = useDownloadCardState({job,variant: null,@@ -96,6 +99,8 @@ export function DatasetDownloadSection({disabled: cancelling || deleting,isPartial,partialTransport,+ partialResumable,+ partialsResumable,});return (@@ -136,7 +141,8 @@ export function DatasetDownloadSection({</span></TooltipTrigger><TooltipContent side="top" sideOffset={4}>- Partial download. Click to continue.+ {/* The badge is a status dot, not a control. */}+ {downloadAction.partialHint}</TooltipContent></Tooltip>)}@@ -178,7 +184,7 @@ export function DatasetDownloadSection({cancelling={downloadAction.cancelling}loading={downloadAction.starting}isPartial={downloadAction.isPartial}- partialTransport={downloadAction.partialTransport}+ partialResumable={downloadAction.partialResumable}stopMode={downloadAction.stopMode}progressPercent={downloadAction.progressPercent}disabled={downloadAction.disabled}diff --git a/studio/frontend/src/features/hub/catalog/download-card.tsx b/studio/frontend/src/features/hub/catalog/download-card.tsxindex 8f38f8d3e1c..1a7f317f5d2 100644--- a/studio/frontend/src/features/hub/catalog/download-card.tsx+++ b/studio/frontend/src/features/hub/catalog/download-card.tsx@@ -233,7 +233,7 @@ export function DownloadActionButton({cancelling,loading = false,isPartial = false,- partialTransport = null,+ partialResumable = false,stopMode = "cancel",progressPercent = null,disabled,@@ -244,7 +244,8 @@ export function DownloadActionButton({cancelling: boolean;loading?: boolean;isPartial?: boolean;- partialTransport?: string | null;+ /** This row's partial can be continued byte for byte (backend verdict). */+ partialResumable?: boolean;/** What stopping the running job costs; see downloadStopMode. */stopMode?: DownloadStopMode;progressPercent?: number | null;@@ -285,7 +286,7 @@ export function DownloadActionButton({) : (<><HugeiconsIcon icon={Download01Icon} strokeWidth={1.75} />- {downloadActionLabel(isPartial, partialTransport)}+ {downloadActionLabel(isPartial, partialResumable)}</>)}</button>diff --git a/studio/frontend/src/features/hub/catalog/download-section.tsx b/studio/frontend/src/features/hub/catalog/download-section.tsxindex c3d3e6b5380..b9b523bfca3 100644--- a/studio/frontend/src/features/hub/catalog/download-section.tsx+++ b/studio/frontend/src/features/hub/catalog/download-section.tsx@@ -11,6 +11,7 @@ export function DownloadSection({isDownloaded,isPartial = false,partialTransport = null,+ partialResumable = false,modelFormat,canRun = true,isActive,@@ -34,6 +35,7 @@ export function DownloadSection({isDownloaded: boolean;isPartial?: boolean;partialTransport?: string | null;+ partialResumable?: boolean;modelFormat?: ModelInventoryFormat | null;canRun?: boolean;isActive: boolean;@@ -79,6 +81,7 @@ export function DownloadSection({isDownloaded={isDownloaded}isPartial={isPartial}partialTransport={partialTransport}+ partialResumable={partialResumable}modelFormat={modelFormat}canRun={canRun}isActive={isActive}diff --git a/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx b/studio/frontend/src/features/hub/catalog/gguf-download-card.tsxindex d872047764c..714079e4ec0 100644--- a/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx+++ b/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx@@ -51,6 +51,7 @@ import {import {downloadManager,useDownloadManagerStore,+ useHttpPartialsResumable,useRepoDownload,} from "../download-manager";import { useOnlineStatus } from "../hooks/use-online-status";@@ -507,9 +508,11 @@ const GgufVariantMenuRow = memo(function GgufVariantMenuRow({</span></TooltipTrigger><TooltipContent side="top" sideOffset={4}>+ {/* Selecting a row only selects it; the card's button starts the+ transfer, so do not promise otherwise. */}{liveActive? "Download is running. Select it to view progress."- : "Partial download. Select it to continue."}+ : "Partial download. Select it, then use the button on the card to finish it."}</TooltipContent></Tooltip>)}@@ -574,6 +577,7 @@ export function GgufDownloadCard({}) {const hfToken = useHfTokenStore((s) => s.token);const online = useOnlineStatus();+ const partialsResumable = useHttpPartialsResumable();const localVariantPath = cachePath?.trim() || null;const { variants, loading, error, refreshError, refresh } =useGgufVariantFetchState({@@ -779,6 +783,8 @@ export function GgufDownloadCard({: ctaDisabled && !selectedIsActive,isPartial: Boolean(selected?.partial),partialTransport: selected?.partial_transport ?? null,+ partialResumable: selected?.partial_resumable === true,+ partialsResumable,});const selectedLabel = selected ? ggufVariantDisplayLabel(selected) : null;const deleteTargetVariant =@@ -980,9 +986,11 @@ export function GgufDownloadCard({</span></TooltipTrigger><TooltipContent side="top" sideOffset={4}>+ {/* The badge rides inside the quant trigger, so clicking+ it opens the menu. Name the button that acts. */}{selectedLiveActive- ? "Download is running. Click to cancel."- : "Partial download. Click to continue."}+ ? "Download is running. Use the button on the right to stop it."+ : downloadAction.partialHint}</TooltipContent></Tooltip>)}diff --git a/studio/frontend/src/features/hub/catalog/gguf-status-cards.tsx b/studio/frontend/src/features/hub/catalog/gguf-status-cards.tsxindex 9c7e9937cd7..753b799cded 100644--- a/studio/frontend/src/features/hub/catalog/gguf-status-cards.tsx+++ b/studio/frontend/src/features/hub/catalog/gguf-status-cards.tsx@@ -3,7 +3,11 @@import { Spinner } from "@/components/ui/spinner";import { cn } from "@/lib/utils";-import type { DownloadJob, DownloadJobProgress } from "../download-manager";+import {+ type DownloadJob,+ type DownloadJobProgress,+ useHttpPartialsResumable,+} from "../download-manager";import { DotTag } from "./dot-tag";import {CardDivider,@@ -88,6 +92,7 @@ export function GgufDownloadingFallbackCard({progress: DownloadJobProgress;cancelling: boolean;}) {+ const partialsResumable = useHttpPartialsResumable();return (<div className="flex w-full flex-col gap-2"><DownloadCard job={job} progress={progress}>@@ -102,7 +107,12 @@ export function GgufDownloadingFallbackCard({downloadingcancelling={cancelling}progressPercent={Math.round(Math.min(progress.fraction, 1) * 100)}- stopMode={downloadStopMode(job.transport, null, job.cancelTransport)}+ stopMode={downloadStopMode(+ job.transport,+ null,+ job.cancelTransport,+ partialsResumable,+ )}disabled={cancelling}onClick={() => void job.cancelDownload(progress.variant)}/>diff --git a/studio/frontend/src/features/hub/catalog/model-inspector.tsx b/studio/frontend/src/features/hub/catalog/model-inspector.tsxindex c7593119827..0f8bc69a2d6 100644--- a/studio/frontend/src/features/hub/catalog/model-inspector.tsx+++ b/studio/frontend/src/features/hub/catalog/model-inspector.tsx@@ -678,6 +678,7 @@ export const ModelInspector = memo(function ModelInspector({isDownloaded={model.isDownloaded}isPartial={model.isPartial ?? false}partialTransport={model.partialTransport ?? null}+ partialResumable={model.partialResumable === true}cachePath={model.path}knownBytes={model.cachedBytes}onTrain={onTrain}@@ -744,6 +745,7 @@ export const ModelInspector = memo(function ModelInspector({isDownloaded={model.isDownloaded}isPartial={model.isPartial ?? false}partialTransport={model.partialTransport ?? null}+ partialResumable={model.partialResumable === true}modelFormat={model.modelFormat}canRun={canRunModel}isActive={isActive}diff --git a/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsx b/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsxindex bc58fe5afdf..b404d867721 100644--- a/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsx+++ b/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsx@@ -387,7 +387,7 @@ export function buildRowStatusTooltip({lines.push(<TooltipLegendRow key="partial" toneClass="bg-status-warning">Partial download of <span className="font-medium">{partialRepoId}</span>- . Click Resume to continue.+ . Open it to finish the download.</TooltipLegendRow>,);} else if (isAvailableOnDevice) {diff --git a/studio/frontend/src/features/hub/catalog/safetensors-download-card.tsx b/studio/frontend/src/features/hub/catalog/safetensors-download-card.tsxindex 4b79a37c967..2e709478b8d 100644--- a/studio/frontend/src/features/hub/catalog/safetensors-download-card.tsx+++ b/studio/frontend/src/features/hub/catalog/safetensors-download-card.tsx@@ -16,7 +16,7 @@ import {import { HugeiconsIcon } from "@hugeicons/react";import { useEffect, useState } from "react";import { TrainIcon } from "../components/train-icon";-import { useRepoDownload } from "../download-manager";+import { useHttpPartialsResumable, useRepoDownload } from "../download-manager";import { useOnlineStatus } from "../hooks/use-online-status";import { deleteCachedModel } from "../inventory";import type { ModelInventoryFormat } from "../inventory";@@ -58,6 +58,7 @@ export function SafetensorsDownloadCard({isDownloaded,isPartial = false,partialTransport = null,+ partialResumable = false,modelFormat,canRun = true,isActive,@@ -73,6 +74,7 @@ export function SafetensorsDownloadCard({isDownloaded: boolean;isPartial?: boolean;partialTransport?: string | null;+ partialResumable?: boolean;modelFormat?: ModelInventoryFormat | null;canRun?: boolean;isActive: boolean;@@ -153,6 +155,7 @@ export function SafetensorsDownloadCard({}, [repoId, hfToken, sizeKey, setJobExpectedBytes, knownBytes, online]);const downloading = progress !== null && progress.variant === null;+ const partialsResumable = useHttpPartialsResumable();const downloadAction = useDownloadCardState({job,variant: null,@@ -161,6 +164,8 @@ export function SafetensorsDownloadCard({disabled: isLoadingThisModel || cancelling || repoPeerActive,isPartial,partialTransport,+ partialResumable,+ partialsResumable,});const showActionPair = isDownloaded && !downloading && (canRun || !!onTrain);const showUnavailableAction =@@ -227,7 +232,8 @@ export function SafetensorsDownloadCard({</span></TooltipTrigger><TooltipContent side="top" sideOffset={4}>- Partial download. Click to continue.+ {/* The badge is a status dot, not a control. */}+ {downloadAction.partialHint}</TooltipContent></Tooltip>)}@@ -336,7 +342,7 @@ export function SafetensorsDownloadCard({cancelling={downloadAction.cancelling}loading={isLoadingThisModel || downloadAction.starting}isPartial={downloadAction.isPartial}- partialTransport={downloadAction.partialTransport}+ partialResumable={downloadAction.partialResumable}stopMode={downloadAction.stopMode}progressPercent={downloadAction.progressPercent}disabled={downloadAction.disabled}diff --git a/studio/frontend/src/features/hub/catalog/use-download-card-state.ts b/studio/frontend/src/features/hub/catalog/use-download-card-state.tsindex cdabdb6940e..5be9dc29491 100644--- a/studio/frontend/src/features/hub/catalog/use-download-card-state.ts+++ b/studio/frontend/src/features/hub/catalog/use-download-card-state.ts@@ -5,15 +5,33 @@ import type { DownloadJob } from "../download-manager";import { useCallback, useEffect, useRef, useState } from "react";import type { DownloadStopMode } from "./download-cancel-indicator";-export function partialResumeLabel(transport: string | null | undefined): string {- if (transport === "xet") return "Redownload";- if (transport === "http") return "Continue";- return "Retry";+/** What the button on a partial row does. Never "Redownload": whichever+ * transport wrote the partial, files already on disk are kept and only the+ * interrupted one is fetched again.+ *+ * `partialResumable` is the backend's verdict on THIS partial, not on the+ * installed writer: a cache shared with a newer environment holds partials that+ * even a resuming huggingface_hub will not reopen. */+export function partialResumeLabel(partialResumable = false): string {+ return partialResumable ? "Resume" : "Continue";+}++/** Tooltip for a "Partial" badge. The badge is not a control, so it names the+ * button that is, and says what continuing actually costs.+ *+ * The restart leads, because the unit is the FILE: a sharded repo keeps the+ * shards it finished, but a one-file quant has nothing to keep and fetches+ * every byte again. Leading with what survives reads as a promise the+ * single-file case cannot honour. */+export function partialDownloadHint(partialResumable = false): string {+ const label = partialResumeLabel(partialResumable);+ return partialResumable+ ? `Partial download. Click ${label} to pick up where it stopped.`+ : `Partial download. Click ${label} to finish it. The interrupted file starts over; other files already on disk are kept.`;}-/** Stopping an HTTP download leaves a partial to continue from, so it is a- * pause. Xet has to start over, so it is a cancel. Unknown assumes the costlier- * one rather than promising a resume that may not exist.+/** Stopping a download that can be resumed is a pause; anything else is a+ * cancel, since the interrupted file has to start over.** Reads the running job's transport, not the partial's: a fresh HTTP download* has no partial yet, and a restarted conflict switches transport, so the@@ -22,12 +40,15 @@ export function downloadStopMode(activeTransport: string | null | undefined,partialTransport?: string | null,cancelTransport?: string | null,+ partialsResumable = false,): DownloadStopMode {// The cancel marker wins where there is one: a Xet run that fell back to// HTTP still cancels into a restart-only partial, so Pause would promise a// resume the marker does not allow.const transport = cancelTransport ?? activeTransport ?? partialTransport;- return transport === "http" ? "pause" : "cancel";+ // Capability, not a row verdict: the partial being written right now is this+ // machine's own, so the installed writer decides whether stopping keeps it.+ return transport === "http" && partialsResumable ? "pause" : "cancel";}export function downloadActionAriaLabel(@@ -42,9 +63,9 @@ export function downloadActionAriaLabel(export function downloadActionLabel(isPartial: boolean,- partialTransport: string | null | undefined,+ partialResumable = false,): string {- return isPartial ? partialResumeLabel(partialTransport) : "Download";+ return isPartial ? partialResumeLabel(partialResumable) : "Download";}export function useDownloadCardState({@@ -56,6 +77,8 @@ export function useDownloadCardState({disabled,isPartial = false,partialTransport = null,+ partialResumable = false,+ partialsResumable = false,}: {job: DownloadJob;variant: string | null;@@ -65,6 +88,10 @@ export function useDownloadCardState({disabled: boolean;isPartial?: boolean;partialTransport?: string | null;+ /** This row's partial can be continued byte for byte (backend verdict). */+ partialResumable?: boolean;+ /** Whether the installed writer resumes at all, for the running job's stop control. */+ partialsResumable?: boolean;}) {const [starting, setStarting] = useState(false);const mountedRef = useRef(true);@@ -107,6 +134,7 @@ export function useDownloadCardState({job.transport,partialTransport,job.cancelTransport,+ partialsResumable,);return {downloading,@@ -114,11 +142,13 @@ export function useDownloadCardState({starting,isPartial,partialTransport,+ partialResumable,progressPercent,stopMode,disabled: effectiveDisabled,ariaLabel: downloadActionAriaLabel(downloading, cancelling, stopMode),- downloadLabel: downloadActionLabel(isPartial, partialTransport),+ downloadLabel: downloadActionLabel(isPartial, partialResumable),+ partialHint: partialDownloadHint(partialResumable),onClick,};}diff --git a/studio/frontend/src/features/hub/download-manager/index.ts b/studio/frontend/src/features/hub/download-manager/index.tsindex ab92ee275af..9068ba89e35 100644--- a/studio/frontend/src/features/hub/download-manager/index.ts+++ b/studio/frontend/src/features/hub/download-manager/index.ts@@ -52,6 +52,7 @@ export { scopedVariant } from "./download-manager-types";export {getTransportMode,useDownloadTransportCapabilities,+ useHttpPartialsResumable,useTransportMode,} from "./transport-preference";export type { TransportConflictInfo } from "./types";diff --git a/studio/frontend/src/features/hub/download-manager/transport-capabilities.ts b/studio/frontend/src/features/hub/download-manager/transport-capabilities.tsindex 1d484fcf2be..0f890a20955 100644--- a/studio/frontend/src/features/hub/download-manager/transport-capabilities.ts+++ b/studio/frontend/src/features/hub/download-manager/transport-capabilities.ts@@ -17,6 +17,9 @@ export interface DownloadTransportCapabilities {// machine's RAM, hf_xet build, and recent Xet failures.auto_resolves_to?: "xet" | "http";auto_reason?: string | null;+ // Whether an interrupted HTTP transfer leaves bytes the next attempt can append to. Server-side+ // because only the backend knows which huggingface_hub writer is installed.+ partials_resumable?: boolean;}export const DOWNLOAD_TRANSPORT_CAPABILITIES_FALLBACK: DownloadTransportCapabilities = {@@ -28,6 +31,9 @@ export const DOWNLOAD_TRANSPORT_CAPABILITIES_FALLBACK: DownloadTransportCapabili// Unknown backend state: stay on Xet, the download-time ladder still falls back to HTTP.auto_resolves_to: "xet",auto_reason: null,+ // Unverified means "do not promise a resume". Continuing a partial is honest either way; only+ // the byte-resume wording would be a lie.+ partials_resumable: false,};export function normalizeDownloadTransportCapability(value: unknown,@@ -62,6 +68,7 @@ export function normalizeDownloadTransportCapabilities(xet?: unknown;auto_resolves_to?: unknown;auto_reason?: unknown;+ partials_resumable?: unknown;};return {http: normalizeDownloadTransportCapability(candidate.http, {@@ -80,5 +87,7 @@ export function normalizeDownloadTransportCapabilities(: DOWNLOAD_TRANSPORT_CAPABILITIES_FALLBACK.auto_resolves_to,auto_reason:typeof candidate.auto_reason === "string" ? candidate.auto_reason : null,+ // Anything but an explicit true (older backend, junk value) stays false.+ partials_resumable: candidate.partials_resumable === true,};}diff --git a/studio/frontend/src/features/hub/download-manager/transport-preference.ts b/studio/frontend/src/features/hub/download-manager/transport-preference.tsindex 3d9c0d54cd7..624c6df72fe 100644--- a/studio/frontend/src/features/hub/download-manager/transport-preference.ts+++ b/studio/frontend/src/features/hub/download-manager/transport-preference.ts@@ -81,6 +81,14 @@ export function useTransportMode(): [return [mode, set];}+/** Whether an interrupted HTTP transfer leaves resumable bytes on this backend.+ * False until the capabilities land, so a card never flashes a resume promise+ * it may have to take back. */+export function useHttpPartialsResumable(): boolean {+ const { capabilities } = useDownloadTransportCapabilities();+ return capabilities?.partials_resumable === true;+}+export function useDownloadTransportCapabilities(): TransportCapabilitiesState {const [state, setState] = useState<TransportCapabilitiesState>({capabilities: null,diff --git a/studio/frontend/src/features/hub/hooks/use-selected-model-view.ts b/studio/frontend/src/features/hub/hooks/use-selected-model-view.tsindex 287cdc5c940..5b9c582f1d1 100644--- a/studio/frontend/src/features/hub/hooks/use-selected-model-view.ts+++ b/studio/frontend/src/features/hub/hooks/use-selected-model-view.ts@@ -138,6 +138,7 @@ export function useSelectedModelView({isDownloaded: !selectedLocalRow.partial,isPartial: selectedLocalRow.partial ?? false,partialTransport: selectedLocalRow.partialTransport ?? null,+ partialResumable: selectedLocalRow.partialResumable === true,runtimeCapabilities: selectedLocalRow.capabilities,capabilities: selectedDiscoverRow.capabilities,license: detectLicense(selectedDiscoverRow.result.tags),@@ -212,6 +213,8 @@ export function useSelectedModelView({selectedCachedRow?.partialTransport ??selectedLocalRow?.partialTransport ??null,+ partialResumable:+ (selectedCachedRow ?? selectedLocalRow)?.partialResumable === true,runtimeCapabilities:selectedCachedRow?.capabilities ?? selectedLocalRow?.capabilities,capabilities: selectedDiscoverRow.capabilities,@@ -281,6 +284,7 @@ export function useSelectedModelView({isDownloaded: !selectedCachedRow.partial,isPartial: selectedCachedRow.partial ?? false,partialTransport: selectedCachedRow.partialTransport ?? null,+ partialResumable: selectedCachedRow.partialResumable === true,runtimeCapabilities: selectedCachedRow.capabilities,capabilities: detectViewCapabilities(mergedTags,@@ -347,7 +351,7 @@ export function useSelectedModelView({title: selectedLocalRow.title,summary: selectedHfResult? buildSummary(selectedHfResult)- : "Partial download. Resume to finish or delete to free space.",+ : "Partial download. Finish it from the card below, or delete it to free space.",sourceLabel: "Hub cache",path: selectedLocalRow.path,isLocal: false,@@ -357,6 +361,7 @@ export function useSelectedModelView({isDownloaded: false,isPartial: true,partialTransport: selectedLocalRow.partialTransport ?? null,+ partialResumable: selectedLocalRow.partialResumable === true,runtimeCapabilities: selectedLocalRow.capabilities,capabilities: detectViewCapabilities(mergedTags,diff --git a/studio/frontend/src/features/hub/inventory/api.ts b/studio/frontend/src/features/hub/inventory/api.tsindex a86579e9b52..b23ffd835f1 100644--- a/studio/frontend/src/features/hub/inventory/api.ts+++ b/studio/frontend/src/features/hub/inventory/api.ts@@ -51,6 +51,8 @@ export interface CachedGgufRepo {last_modified?: number | null;partial?: boolean;partial_transport?: string | null;+ /** This partial can be continued byte for byte. */+ partial_resumable?: boolean;pipeline_tag?: string | null;task?: string | null;tags?: string[];@@ -70,6 +72,8 @@ export interface CachedModelRepo {last_modified?: number | null;partial?: boolean;partial_transport?: string | null;+ /** This partial can be continued byte for byte. */+ partial_resumable?: boolean;pipeline_tag?: string | null;task?: string | null;tags?: string[];@@ -98,6 +102,8 @@ export interface LocalModelInfo {updated_at?: number | null;partial?: boolean;partial_transport?: string | null;+ /** This partial can be continued byte for byte. */+ partial_resumable?: boolean;pipeline_tag?: string | null;task?: string | null;tags?: string[];@@ -120,6 +126,8 @@ export interface CachedDatasetRepo {load_cache_path?: string;partial?: boolean;partial_transport?: string | null;+ /** This partial can be continued byte for byte. */+ partial_resumable?: boolean;}export type LocalDatasetInfo = {@@ -158,6 +166,8 @@ export interface GgufVariantDetail {update_available?: boolean;partial?: boolean;partial_transport?: string | null;+ /** This partial can be continued byte for byte. */+ partial_resumable?: boolean;/** Variants sharing this key share one companion download footprint, so a* footprint resolved for one of them is correct for all of them. */dependency_key?: string | null;diff --git a/studio/frontend/src/features/hub/inventory/types.ts b/studio/frontend/src/features/hub/inventory/types.tsindex 22c6f93a8a0..eaf5e776276 100644--- a/studio/frontend/src/features/hub/inventory/types.ts+++ b/studio/frontend/src/features/hub/inventory/types.ts@@ -51,6 +51,8 @@ export interface CachedInventoryRow {lastModified?: number | null;partial?: boolean;partialTransport?: string | null;+ /** This partial can be continued byte for byte. */+ partialResumable?: boolean;/** A download manifest or cancel marker exists for some quant; moves on a sibling cancel, which changes neither bytes nor mtime. */hasVariantState?: boolean;pipelineTag?: string | null;@@ -95,6 +97,8 @@ export interface LocalInventoryRow {updatedAt: number | null;partial?: boolean;partialTransport?: string | null;+ /** This partial can be continued byte for byte. */+ partialResumable?: boolean;activeCache?: boolean | null;pipelineTag?: string | null;tags?: string[];diff --git a/studio/frontend/src/features/hub/inventory/view-models.ts b/studio/frontend/src/features/hub/inventory/view-models.tsindex 37a9830c1cf..22b1cbcfd6e 100644--- a/studio/frontend/src/features/hub/inventory/view-models.ts+++ b/studio/frontend/src/features/hub/inventory/view-models.ts@@ -167,6 +167,7 @@ export function buildCachedInventoryRow(load_cache_path?: string;partial?: boolean;partial_transport?: string | null;+ partial_resumable?: boolean;has_variant_state?: boolean;pipeline_tag?: string | null;task?: string | null;@@ -230,6 +231,7 @@ export function buildCachedInventoryRow(: null,partial: row.partial ?? false,partialTransport: row.partial_transport ?? null,+ partialResumable: row.partial_resumable === true,hasVariantState: row.has_variant_state ?? false,pipelineTag: row.pipeline_tag ?? null,task: row.task ?? null,@@ -311,6 +313,7 @@ export function buildLocalInventoryRows(updatedAt: normalizeTimestamp(model.updated_at),partial: model.partial ?? false,partialTransport: model.partial_transport ?? null,+ partialResumable: model.partial_resumable === true,activeCache: model.active_cache ?? null,pipelineTag: model.pipeline_tag ?? null,task: model.task ?? null,diff --git a/studio/frontend/src/features/hub/types.ts b/studio/frontend/src/features/hub/types.tsindex 73173bf6247..64e160e8a12 100644--- a/studio/frontend/src/features/hub/types.ts+++ b/studio/frontend/src/features/hub/types.ts@@ -81,6 +81,7 @@ export interface SelectedModelView {isDownloaded: boolean;isPartial?: boolean;partialTransport?: string | null;+ partialResumable?: boolean;runtimeCapabilities?: ModelInventoryCapabilities;capabilities: Capability[];license: string | null;diff --git a/studio/frontend/tests/download-stop-mode.test.ts b/studio/frontend/tests/download-stop-mode.test.tsindex 47356625e26..b4a15fda855 100644--- a/studio/frontend/tests/download-stop-mode.test.ts+++ b/studio/frontend/tests/download-stop-mode.test.ts@@ -9,29 +9,37 @@ import {downloadStopMode,} from "../src/features/hub/catalog/use-download-card-state.ts";+// The 4th argument is the backend's "an interrupted file leaves resumable bytes" verdict.+// huggingface_hub >= 1.18 refetches from zero, so Pause has to be earned, not assumed.+const RESUMABLE = true;+test("an HTTP download pauses, because its partial can be continued", () => {- assert.equal(downloadStopMode("http"), "pause");+ assert.equal(downloadStopMode("http", null, null, RESUMABLE), "pause");+});++test("an HTTP download cancels when nothing can reopen its partial", () => {+ assert.equal(downloadStopMode("http"), "cancel");});test("a Xet download cancels, because it has to start over", () => {- assert.equal(downloadStopMode("xet"), "cancel");+ assert.equal(downloadStopMode("xet", null, null, RESUMABLE), "cancel");});test("a fresh HTTP download reads its own transport, not the absent partial", () => {- assert.equal(downloadStopMode("http", null), "pause");+ assert.equal(downloadStopMode("http", null, null, RESUMABLE), "pause");});test("a restarted conflict follows the new transport, not the old partial", () => {- assert.equal(downloadStopMode("xet", "http"), "cancel");- assert.equal(downloadStopMode("http", "xet"), "pause");+ assert.equal(downloadStopMode("xet", "http", null, RESUMABLE), "cancel");+ assert.equal(downloadStopMode("http", "xet", null, RESUMABLE), "pause");});test("an adopted job with no known transport falls back to the partial", () => {- assert.equal(downloadStopMode(null, "http"), "pause");+ assert.equal(downloadStopMode(null, "http", null, RESUMABLE), "pause");});test("an unknown transport cancels, never promising a resume", () => {- assert.equal(downloadStopMode(null), "cancel");+ assert.equal(downloadStopMode(null, null, null, RESUMABLE), "cancel");assert.equal(downloadStopMode(undefined, undefined), "cancel");});@@ -48,15 +56,15 @@ test("the accessible label matches what the button does", () => {test("a Xet run that fell back to HTTP still cancels, not pauses", () => {// The retry reclaims the job as HTTP but keeps the Xet cancel marker, so// stopping it leaves a partial that has to start over.- assert.equal(downloadStopMode("http", null, "xet"), "cancel");+ assert.equal(downloadStopMode("http", null, "xet", RESUMABLE), "cancel");});test("an HTTP job whose marker is also HTTP still pauses", () => {- assert.equal(downloadStopMode("http", null, "http"), "pause");+ assert.equal(downloadStopMode("http", null, "http", RESUMABLE), "pause");});test("no marker leaves the live transport in charge", () => {- assert.equal(downloadStopMode("http", null, null), "pause");- assert.equal(downloadStopMode("http", null, undefined), "pause");- assert.equal(downloadStopMode("xet", "http", null), "cancel");+ assert.equal(downloadStopMode("http", null, null, RESUMABLE), "pause");+ assert.equal(downloadStopMode("http", null, undefined, RESUMABLE), "pause");+ assert.equal(downloadStopMode("xet", "http", null, RESUMABLE), "cancel");});diff --git a/studio/frontend/tests/partial-download-affordance.test.ts b/studio/frontend/tests/partial-download-affordance.test.tsnew file mode 100644index 00000000000..8c3457891de--- /dev/null+++ b/studio/frontend/tests/partial-download-affordance.test.ts@@ -0,0 +1,63 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// The "Partial" badge used to say "Click to continue" while being a status dot with no handler,+// and the button beside it said "Redownload" for a Xet partial even though completed shards are+// kept. Both read as a 56 GB refetch nobody asked for (issue #8927).+//+// The resume wording is driven by the backend's verdict on THIS partial, never by the installed+// huggingface_hub alone: a cache shared with a newer environment holds nonce-named partials that+// even a resuming writer will not reopen.++import assert from "node:assert/strict";+import test from "node:test";++import {+ downloadActionLabel,+ partialDownloadHint,+ partialResumeLabel,+} from "../src/features/hub/catalog/use-download-card-state.ts";++const RESUMABLE = true;++test("a partial the backend cannot resume is continued, never redownloaded", () => {+ // "Redownload" priced the whole repo. The transfer skips every completed file.+ assert.equal(partialResumeLabel(false), "Continue");+});++test("a resumable partial says so", () => {+ assert.equal(partialResumeLabel(RESUMABLE), "Resume");+});++test("an unstated verdict never promises a resume", () => {+ assert.equal(partialResumeLabel(), "Continue");+ assert.equal(partialResumeLabel(undefined), "Continue");+});++test("a repo with no partial is still a plain download", () => {+ assert.equal(downloadActionLabel(false, RESUMABLE), "Download");+ assert.equal(downloadActionLabel(true, RESUMABLE), "Resume");+ assert.equal(downloadActionLabel(true, false), "Continue");+});++test("the badge tooltip names the button, since the badge is not one", () => {+ for (const hint of [partialDownloadHint(RESUMABLE), partialDownloadHint(false)]) {+ assert.match(hint, /^Partial download\. Click (Continue|Resume) /);+ }+});++test("a restart-only partial leads with the file that starts over", () => {+ // A one-file quant has nothing to keep, so "files are kept" must not come first.+ const hint = partialDownloadHint(false);+ assert.match(hint, /Click Continue/);+ assert.match(+ hint,+ /The interrupted file starts over; other files already on disk are kept\.$/,+ );+});++test("a resumable partial promises the bytes on disk, and nothing more", () => {+ const hint = partialDownloadHint(RESUMABLE);+ assert.match(hint, /Click Resume/);+ assert.match(hint, /pick up where it stopped/);+});diff --git a/studio/frontend/tests/transport-capabilities.test.ts b/studio/frontend/tests/transport-capabilities.test.tsindex c6f9fb9d65b..f05a3cdbef2 100644--- a/studio/frontend/tests/transport-capabilities.test.ts+++ b/studio/frontend/tests/transport-capabilities.test.ts@@ -38,6 +38,28 @@ test("a backend with no auto fields still resolves to xet", () => {assert.equal(caps.auto_reason, null);});+test("the resumability verdict survives normalization", () => {+ const caps = normalizeDownloadTransportCapabilities({+ http: { available: true, reason: null },+ xet: { available: true, reason: null },+ partials_resumable: true,+ });++ assert.equal(caps.partials_resumable, true);+});++test("an unverified backend never claims a partial is resumable", () => {+ // Older backend, or junk: continuing a partial is honest either way, a byte-resume is not.+ for (const value of [{}, { partials_resumable: "yes" }]) {+ const caps = normalizeDownloadTransportCapabilities({+ http: { available: true, reason: null },+ xet: { available: true, reason: null },+ ...value,+ });+ assert.equal(caps.partials_resumable, false);+ }+});+test("a junk auto verdict is not trusted", () => {const caps = normalizeDownloadTransportCapabilities({http: { available: true, reason: null },