Skip to content

Studio: disclose required assets before media downloads - #12387

Merged
danielhanchen merged 12 commits into
unslothai:mainfrom
Imagineer99:fix/additional-assets-disclosure
Oct 1, 2026
Merged

danielhanchen merged 12 commits into
unslothai:mainfrom
Imagineer99:fix/additional-assets-disclosure

Conversation

@Imagineer99

@Imagineer99 Imagineer99 commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Problem

A media GGUF download advertises only the checkpoint size, then loading can silently download several more GB of required files. Expanding a local quant can also change its displayed size after dependency metadata arrives. After accepting the new asset flow, the Hub must keep showing progress for the complete operation.

Changes

  • Check missing files before starting a supported media download and show a breakdown with an explicit option to include required files or download only the model. Reuse files already present according to the backend plan.
  • Prefetch dependency metadata for the selected model, reuse a short-lived plan, and keep the same dialog mounted while checking to avoid the loading-to-choice flicker.
  • Queue checkpoints before assets, display waiting entries in the download panel, and retain aggregate Hub progress until the accepted operation finishes. Download completion does not load or switch models.
  • The Images, Video and Audio pages keep their existing staged loads: picker rows already show the model plus required-files size (Studio: count companion assets in the Hub download size of image and video GGUFs #12370), and the Downloads panel lists the required assets with cancel. A failed plan still falls back to the load's own download, so cached models load offline.

Validation

  • 216 focused frontend tests pass, including model-only selection, unknown-size assets, checkpoint-first ordering, asset labels, download-panel visibility, and existing audio/video download-plan coverage.
  • Application and test TypeScript checks passed (npm run typecheck).
  • Frontend production build and Windows release executable build passed.
  • Exercised real frontend components against a simulated backend: model-first transfer, visible queued assets, progression to assets, cancellation clearing the remaining queue, and model-only completion without loading.
  • Installed the build locally; the user tested the general desktop flow and confirmed it appears correct.

Draft scope / follow-ups

This uses the existing image/video and native-audio planners; it is not universal dependency handling for chat/vision GGUFs or training. The repository-only audio planner is deliberately not used for Hub GGUF selections. Some local pipeline load paths remain unchanged. Backend dependency selection, shared-asset deletion, and memory requirements are unchanged.

Queued asset rows still identify their source repository as “Required assets”; clearer component labels are a possible follow-up. Mock pages, local fixtures, screenshots, packaging work, and desktop binaries are excluded from this PR.

Before / after

Model Hub, unsloth/Qwen-Image-2512-GGUF (BF16), clicking Download. BEFORE (merge base a76ac47c8): the 41 GB transfer starts at once. AFTER (1e5fcaa49): the disclosure dialog shows 40.9 GB model files plus 4.9 GB required files (decoder and configuration 253.8 MB, text encoder 4.7 GB), 45.8 GB in total, and Cancel starts nothing.

Hub Download before and after

Resolve conflicts with unslothai#12370: keep main's combined model plus required
assets size in the Hub and pickers, route the GGUF card's disclosure
through mediaPage, and drop the picker-only missing-assets status.
The backend contract is that a load falls back to its own inline download
when the plan is unavailable (offline, older backend, Hub hiccup). Refusing
the load there blocked already-downloaded image, video and TTS models
offline. Download-only picks still report the failure.
… plan fallback

Use calc(...*var(--ui-space-scale,1)) for the dialog's fixed lengths, update the
video plan-bypass test to the pipeline-only predicate, and add source tests that
keep the offline plan-failure fallback on the images, video and audio pages.
@danielhanchen
danielhanchen marked this pull request as ready for review October 1, 2026 09:28
@danielhanchen
danielhanchen self-requested a review as a code owner October 1, 2026 09:28
@danielhanchen danielhanchen reopened this Oct 1, 2026
Resolve conflicts with unslothai#10150: keep its load snapshot (family override)
passed to the non-hub load, with this PR's pipeline-only bypass.
@shimmyshimmer

shimmyshimmer commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Review record for #12387, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#314.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 9ab72eef7 (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] on studio/frontend/src/features/hub/catalog/use-required-assets-download.tsx (on the mirror)

@@ -0,0 +1,167 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { useCallback, useEffect, useRef, useState } from "react";
+import {
+  getDiffusionDownloadPlan,
+  type DiffusionDownloadPlan,
+} from "@/features/images/api";
+import { getVideoDownloadPlan } from "@/features/video/api";
+import { getAudioDownloadPlan } from "@/features/audio/api";
+import { toast } from "@/lib/toast";
+import { useInventoryVersion } from "../stores/inventory-events";
+import { useHfTokenStore } from "../stores/hf-token-store";
+import {
+  additionalAssetDownloads,
+  selectDownloadEntries,
+} from "../download-manager/required-assets";
+import { RequiredAssetsDownloadDialog } from "../download-manager/required-assets-dialog";
+import { enqueueHubDownload } from "../download-manager/use-hub-download-queue";
+import type { StagedDownloadEntry } from "../download-manager/use-staged-download";
+export type AssetRuntime = "images" | "video" | "audio";
+
+export function useRequiredAssetsDownload({
+  repoId,
+  filename,
+  runtime,
+  modelLabel,
+}: {
+  repoId: string;
+  filename?: string;
+  runtime?: AssetRuntime;
+  modelLabel?: string;
+}) {
+  const token = useHfTokenStore((s) => s.token);
+  const [checking, setChecking] = useState(false);
+  const [pending, setPending] = useState<StagedDownloadEntry[] | null>(null);
+  const inventoryVersion = useInventoryVersion();
+  const sequence = useRef(0);
+  const starting = useRef(false);
+  const fetchPlan = useCallback(async () => {
+    const body = {
+      model_path: repoId,
+      gguf_filename: filename,
+      model_kind: filename ? ("gguf" as const) : ("pipeline" as const),
+      hf_token: token || undefined,
+    };
+    const result =
+      runtime === "audio"
+        ? await getAudioDownloadPlan(repoId, token || undefined)
+        : runtime === "video"
+          ? await getVideoDownloadPlan(body)
+          : await getDiffusionDownloadPlan(body);
+    const resultPlan: DiffusionDownloadPlan = result;
+    if (resultPlan.plan_failed)
+      throw new Error(
+        "Required file information is incomplete. Please try again.",
+      );
+    if (resultPlan.incompatible_reason)
+      throw new Error(resultPlan.incompatible_reason);
+    return resultPlan;
+  }, [repoId, filename, token, runtime]);
+  const cached = useRef<{
+    fetch: typeof fetchPlan;
+    inventory: number;
+    expires: number;
+    promise: ReturnType<typeof fetchPlan>;
+  } | null>(null);
+  const resolvePlan = useCallback(() => {
+    const previous = cached.current;
+    if (
+      previous &&
+      previous.fetch === fetchPlan &&
+      previous.inventory === inventoryVersion &&
+      previous.expires > Date.now()
+    )
+      return previous.promise;
+    const record = {
+      fetch: fetchPlan,
+      inventory: inventoryVersion,
+      expires: Date.now() + 30_000,
+      promise: fetchPlan(),
+    };
+    cached.current = record;
+    void record.promise.catch(() => {
+      if (cached.current === record) cached.current = null;
+    });
+    return record.promise;
+  }, [fetchPlan, inventoryVersion]);
+  useEffect(() => {
+    if (!runtime) return;
+    const timer = window.setTimeout(() => {
+      void resolvePlan().catch(() => {});
+    }, 200);
+    return () => window.clearTimeout(timer);
+  }, [resolvePlan, runtime]);
+  useEffect(() => {
+    ++sequence.current;
+    setPending(null);
+    setChecking(false);
+    starting.current = false;
+    return () => {
+      ++sequence.current;
+    };
+  }, [fetchPlan, runtime]);
+  const request = async (fallback: () => void) => {
+    if (!runtime) {
+      fallback();
+      return;
+    }
+    if (starting.current) return;
+    starting.current = true;
+    setChecking(true);
+    const id = ++sequence.current;
+    try {
+      const p = await resolvePlan();
+      if (sequence.current !== id) return;
+      const entries = p.entries.map((e) => ({
+        repoId: e.repo_id,
+        files: e.files,
+        bytes: e.bytes,
+        ggufFilename: e.gguf_filename,
+        checkpoint:
+          e.checkpoint ??
+          (filename ? e.files.includes(filename) : e.repo_id === repoId),

P2 Badge Do not infer checkpoint roles from repository identity

When an older backend omits the optional checkpoint field, this fallback misclassifies gated pipeline models: the planner stages the selected checkpoint from an ungated mirror, so e.repo_id !== repoId even though the entry is the model itself. The dialog consequently presents the whole model as “required files,” and choosing model-only filters out every entry and starts no download. Treat a plan without explicit checkpoint roles as unsupported and fall back to the ordinary download rather than inferring the role from repository equality.

Useful? React with 👍 / 👎.

Rejected on the mirror

Reply from danielhanchen:

Not changing this. Studio's frontend is built and served by its own backend, so this bundle never meets a planner that omits checkpoint; the fallback mirrors the same expression the Images and Video pages already use on main for that hypothetical. Every current planner sets checkpoint explicitly, including the ungated-mirror case.

chatgpt-codex-connector[bot] on studio/frontend/src/features/hub/download-manager/use-hub-download-queue.ts (on the mirror)

@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { checkpointFirst } from "./required-assets";
+import { useEffect, useRef } from "react";
+import { create } from "zustand";
+import {
+  AUTH_SESSION_CLEARED_EVENT,
+  AUTH_SESSION_STORED_EVENT,
+} from "@/features/auth";
+import { useDownloadManagerStore } from "./download-manager-controller";
+import { toast } from "@/lib/toast";
+import {
+  useStagedDownload,
+  type StagedDownloadEntry,
+} from "./use-staged-download";
+export type Plan = {
+  id: number;
+  origin?: { repoId: string; filename?: string };
+  entries: StagedDownloadEntry[];
+  remaining: StagedDownloadEntry[];
+};
+let nextId = 0;
+export const useHubQueue = create<{ plans: Plan[] }>(() => ({ plans: [] }));

P2 Badge Persist the multi-entry Hub queue across reloads

When a user accepts a model plus required assets and reloads or restarts Studio while the first entry is downloading, this in-memory store is recreated with plans: []. The download manager separately persists and re-adopts only the currently active job, so every later entry in remaining is forgotten; after the checkpoint finishes, the accepted required assets are never started. Persist the plan/remaining entries or reconstruct them when adopting the scoped job so long-running multi-entry downloads survive reloads.

Useful? React with 👍 / 👎.

Rejected on the mirror

Reply from danielhanchen:

Not changing this (same as the earlier reload item). The staged-download queue the media pages use on main is in-memory too; nothing is lost, the file in flight completes, and Run re-plans from the cache-aware planner, which lists exactly the remaining files. Persisting queued plans is a follow-up, not a correctness bug.

Verdict

The round did not reach a clean review on the mirror before it closed.

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 1, 2026
Read confirmAssets through a ref so stage keeps its empty dependency list,
which the staged-download contracts in test_model_picker_contracts.py pin.
…irmed

Confirming the missing-files dialog on a load pick now stages the files and
loads the model, as before this change, instead of leaving the user to pick
it again. The "will not load" note stays on the Hub download dialog only.
The image cancel/retry Playwright test accepts the disclosure and asserts it
appeared.
pre-commit-ci Bot and others added 2 commits October 1, 2026 14:18
Asking inside the shared staged-download queue raised the modal whenever a
queued plan reached the front, minutes after the pick, and stalled the
Images download queue (playwright_image_download_queue.py). The media pages
already show the full model plus required-files size on each picker row and
list required assets in the Downloads panel with cancel, so they go back to
main's staging and the dialog stays on the Hub Download button, the path
that started a GGUF without its required files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants