Skip to content

feat: GGUF model manager with download, verification, and lifecycle - #1027

Merged
malibio merged 1 commit into
mainfrom
feature/issue-1000-model-manager
Apr 3, 2026
Merged

malibio merged 1 commit into
mainfrom
feature/issue-1000-model-manager

Conversation

@malibio

@malibio malibio commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Implements GgufModelManager for GGUF model discovery and lifecycle
  • HTTP range-request resume for download, SHA256 verification
  • RAM-based model recommendation (>16GB → 8B, ≤16GB → 3B)
  • State machine: NotDownloaded → Downloading → Verifying → Ready → Loaded → Error

Closes #1000

…loses #1000)

Implements GgufModelManager for GGUF model discovery, download with
HTTP range-request resume, SHA256 verification, and lifecycle state
tracking. Auto-selects model based on system RAM.

Co-Authored-By: Claude <[email protected]>
@malibio
malibio force-pushed the feature/issue-1000-model-manager branch from 11614e9 to 225571b Compare April 3, 2026 22:57
@malibio
malibio merged commit ac0d4e9 into main Apr 3, 2026
@malibio
malibio deleted the feature/issue-1000-model-manager branch April 3, 2026 22:57
@malibio

malibio commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator Author

Post-Merge Code Review: PR #1027 (GGUF model manager with download, verification, and lifecycle)

Verdict: Has a critical issue that needs immediate follow-up.

Findings

[Critical/Blocker] Merge conflict markers were present in the diff

The PR diff contained unresolved merge conflict markers in packages/desktop-app/src-tauri/Cargo.toml:

<<<<<<< HEAD
which = "7"

[target.'cfg(unix)'.dependencies]
libc = "0.2"
=======
sysinfo = "0.33"
sha2 = "0.10"
reqwest = { version = "0.12", features = ["stream"] }
>>>>>>> 11614e9a

Verified: The actual merged file on main has this resolved correctly -- all dependencies are present and the conflict markers are gone. So the merge was handled properly, but the diff displayed by GitHub still shows the conflict. No action needed -- this was a display artifact; the actual code is correct.

[Improvement] SHA-256 resume verification gap

File: packages/desktop-app/src-tauri/src/local_agent/model_manager.rs

When resuming a download via HTTP Range requests, the SHA-256 hash is computed only on the final file after the full download completes. This is correct. However, if the server returns a 200 OK (full file) instead of 206 Partial Content in response to a Range request (which some CDNs/proxies do), the resumed data will be appended to the existing partial file, resulting in a corrupted file. The SHA-256 check will catch this, but the user will see a "verification failed" error without understanding why.

Fix: When the response status is 200 OK (not 206 Partial Content) and resume_offset > 0, truncate the partial file back to 0 before writing. This handles the case where the server doesn't support range requests.

Priority: Medium -- HuggingFace supports range requests, but it's a correctness issue for robustness.

[Improvement] speed_bps: 0 placeholder in download progress

File: packages/desktop-app/src-tauri/src/local_agent/model_manager.rs (line ~1179 in the diff)

The DownloadEvent always reports speed_bps: 0 with a TODO comment. This means the UI cannot display download speed. Low priority since the UI is using mock data currently, but should be implemented when wiring the real backend.

Notes

  • Solid state machine: NotDownloaded -> Downloading -> Verifying -> Ready -> Loaded, with proper transitions and guards.
  • Cancellation via CancellationToken is well-implemented with proper cleanup of partial files.
  • Disk space check before download prevents failed writes.
  • System RAM detection for model recommendation is a good UX touch.
  • Cannot delete a loaded model -- correct safety guard.
  • 16 tests covering catalog, state transitions, load/unload, delete, and SHA-256 verification.
  • Streaming SHA-256 computation (64KB chunks) is memory-efficient for multi-GB model files.

Follow-up needed: Handle HTTP 200 response on range-request resume (truncate partial file).

malibio added a commit that referenced this pull request Jun 22, 2026
…loses #1000) (#1027)

Implements GgufModelManager for GGUF model discovery, download with
HTTP range-request resume, SHA256 verification, and lifecycle state
tracking. Auto-selects model based on system RAM.

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GGUF Model Manager with download, verification, and lifecycle

1 participant