Skip to content

Prettify llama.cpp OCR settings + wire up llama.cpp hashes#11053

Merged
niksedk merged 2 commits into
mainfrom
llama-cpp-ocr-settings-prettify-and-hash-checks
May 19, 2026
Merged

Prettify llama.cpp OCR settings + wire up llama.cpp hashes#11053
niksedk merged 2 commits into
mainfrom
llama-cpp-ocr-settings-prettify-and-hash-checks

Conversation

@niksedk
Copy link
Copy Markdown
Member

@niksedk niksedk commented May 19, 2026

Summary

  • Redesigned LlamaCppOcrSettingsWindow — header (title + subtitle), bordered details panel, more vertical spacing (RowSpacing = 12), and a wider Timeout NumericUpDown (100 → 140). Matches the Chatterbox TTS settings layout.
  • Added an "Engine" status row to the new details panel — colored dot (Ellipse) + bold label bound to EngineBrush / EngineLabel, mirroring ChatterboxTtsSettingsWindow.MakeStatusPanel.
  • Wired up the previously-unused LlamaCpp.* hashes in DownloadHashManager:
    • LlamaCppDownloadService.DownloadEngine now calls a new VerifyArchive after download — compares the downloaded bytes against DownloadHashManager.GetLatestKnownHash(ResolveLlamaCppKey(variant)) and throws IOException on mismatch, so the caller's IsFaulted branch surfaces "Download failed" instead of silently unpacking a truncated or tampered file. Mirrors Qwen3TtsCppDownloadService.VerifyArchive.
    • New LlamaCppServerManager.GetEngineUpdateStatus() SHA-256s the installed llama-server binary on disk and calls DownloadHashManager.GetStatus(ResolveLlamaCppExecutableKey(), hash). No sidecar needed because LlamaCpp.{Os}Executable keys already track hashes of the unpacked binary per OS/arch.
  • The OCR settings dot now shows three states: grey "Not installed", green "Installed (latest)" / "Installed (unknown version)", amber "Update available". Unknown installs (sideloaded / custom build / future untracked version) deliberately fall back to green so users don't get false-positive update prompts.

Test plan

  • Open OCR window → select llama.cpp → click Settings cog → verify the new window layout matches Chatterbox TTS settings styling
  • Verify the Engine row shows green "Installed (latest)" when running pinned b9174
  • Verify amber "Update available" when an older known build (e.g. b9145 from the executable hash list) is on disk
  • Verify grey "Not installed" when llama-server is absent
  • Trigger a llama.cpp download and verify the integrity check passes; manually corrupt the stream to confirm IOException is raised
  • Confirm Timeout numeric up-down and Prompt multi-line text box still bind/save correctly

🤖 Generated with Claude Code

- Redesigned LlamaCppOcrSettingsWindow with header, bordered
  details panel, more vertical spacing, and a wider Timeout
  numeric input. Matches the Chatterbox TTS settings layout.
- Added an "Engine" status row showing a green/amber/grey dot
  + label, mirroring how Chatterbox shows install state.
- Wired up the previously-unused LlamaCpp.* hashes in
  DownloadHashManager: LlamaCppDownloadService.DownloadEngine
  now verifies the downloaded archive's SHA-256 and throws on
  mismatch, and LlamaCppServerManager.GetEngineUpdateStatus()
  hashes the installed llama-server binary against the
  per-OS executable key so the OCR settings dot can show
  "Update available" when a new build is pinned.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the llama.cpp OCR settings experience and strengthens llama.cpp engine integrity/version reporting by wiring DownloadHashManager hashes into the download and “installed status” flows.

Changes:

  • Redesignes LlamaCppOcrSettingsWindow layout to match the Chatterbox TTS settings styling and adds an “Engine” status row (dot + label).
  • Adds archive integrity verification to LlamaCppDownloadService.DownloadEngine() using known SHA-256 hashes.
  • Adds LlamaCppServerManager.GetEngineUpdateStatus() and initializes the OCR settings view model on dialog open to display installed/update status.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ui/Logic/LlamaCpp/LlamaCppServerManager.cs Adds executable hashing-based update status lookup for installed llama-server.
src/ui/Logic/Download/LlamaCppDownloadService.cs Verifies downloaded engine archive SHA-256 against DownloadHashManager and fails on mismatch.
src/ui/Features/Ocr/OcrViewModel.cs Ensures the llama.cpp OCR settings VM is initialized when opening the dialog.
src/ui/Features/Ocr/LlamaCppOcrSettingsWindow.cs Rebuilds the settings window layout and adds the engine status row UI.
src/ui/Features/Ocr/LlamaCppOcrSettingsViewModel.cs Adds engine status label/brush state and refresh logic based on installed/update status.

Comment on lines +43 to +64
IsEngineInstalled = LlamaCppServerManager.IsEngineInstalled();
if (!IsEngineInstalled)
{
EngineLabel = "Not installed";
EngineBrush = new SolidColorBrush(Color.FromRgb(0x9E, 0x9E, 0x9E)); // grey
return;
}

switch (LlamaCppServerManager.GetEngineUpdateStatus())
{
case DownloadHashManager.UpdateStatus.UpToDate:
EngineLabel = "Installed (latest)";
EngineBrush = new SolidColorBrush(Color.FromRgb(0x4C, 0xAF, 0x50)); // green
break;
case DownloadHashManager.UpdateStatus.UpdateAvailable:
EngineLabel = "Update available";
EngineBrush = new SolidColorBrush(Color.FromRgb(0xFF, 0x98, 0x00)); // amber
break;
default:
EngineLabel = "Installed (unknown version)";
EngineBrush = new SolidColorBrush(Color.FromRgb(0x4C, 0xAF, 0x50)); // green
break;
Comment on lines +135 to +156
private static StackPanel BuildHeader()
{
var title = new TextBlock
{
Text = "llama.cpp OCR",
FontSize = 18,
FontWeight = FontWeight.SemiBold,
};
var subtitle = new TextBlock
{
Text = "Local llama.cpp server (multimodal model) used for OCR.",
FontSize = 12,
Opacity = 0.75,
Margin = new Thickness(0, 2, 0, 0),
};
return new StackPanel
{
Orientation = Orientation.Vertical,
Spacing = 0,
Children = { title, subtitle },
};
}
Switch hard-coded "Not installed" / "Installed (latest)" /
"Update available" / "Installed (unknown version)" strings to
Se.Language.General.{NotInstalled, UpToDate, UpdateAvailable,
UnknownNoInstallRecord}, matching the Qwen3/Kokoro/STT
engine-settings pattern. Align the dot colors with the same
convention: red when missing, green up-to-date, amber update
available, grey for an unknown installed build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@niksedk niksedk merged commit 5a3f6fc into main May 19, 2026
1 of 3 checks passed
@niksedk niksedk deleted the llama-cpp-ocr-settings-prettify-and-hash-checks branch May 19, 2026 20:28
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.

2 participants