Skip to content

feat(ai): add hardware selection - #217

Merged
scotej merged 30 commits into
mainfrom
feat/211-ai-hardware-selection
Aug 11, 2026
Merged

feat(ai): add hardware selection#217
scotej merged 30 commits into
mainfrom
feat/211-ai-hardware-selection

Conversation

@scotej

@scotej scotej commented Aug 10, 2026

Copy link
Copy Markdown
Owner

What changed and why

Adds an explicit Settings → AI hardware selector for Automatic, CPU, and each accelerator reported by the local llama.cpp engine, closing #211. The selection is persisted locally, applied to both live inference and benchmarks, and preserved across sidecar crash respawns. Windows now ships the pinned b9095 Vulkan engine so NVIDIA, AMD, Intel, and external GPUs use one cross-vendor backend; CPU remains an explicit --device none fallback. Benchmark fingerprints include the hardware choice so CPU timings are never reused after switching to a GPU/eGPU. The managed-engine package identity is also revisioned so a pre-#211 CPU-only Windows cache cannot be reused as a recovery fallback. Hardware discovery is bounded, cached for the app process, and invalidated after engine reinstall so a wedged GPU driver cannot hang Settings or cause repeated probe processes.

Manual test

This connector environment does not expose the repository's Windows desktop-control MCP, so I did not claim a machine-walked UI smoke test. The changed settings surface is covered by the existing Storybook build/a11y gate and the native paths are compiled/tested on the repository's macOS, Linux, and Windows CI runners.

  • npm run tauri dev launched and the changed surface behaves as described — not run in this environment
  • Checked in both themes and at reduced-motion — not run in this environment

Compatibility surfaces

  • SQLite schema / src-tauri/src/db/migrations/ — untouched
  • Peer wire format (trystero payloads, session/pomodoro/AI-alert messages) — untouched
  • Identity derivation (BIP39 → ed25519/x25519, pair links, contact links) — untouched
  • Persisted settings shape / store keys — additive ai-hardware.json / selection; missing or invalid data defaults to auto, so existing installs remain valid
  • Updater manifest or release artifact names — unchanged; only the bundled Windows llama.cpp backend payload changes from CPU to Vulkan

Gates

GitHub Actions is the authoritative execution environment for this PR. Final head 3bb7ffc passed the complete pre-merge matrix, CodeQL, and preview installer builds for both macOS and Windows.

  • npm run build && npm run lint && npm run test
  • npm run check-tokens && npm run check-strings && npm run check-contrast
  • npm run check-migrations && npm run check-stories
  • npm run build-storybook && npm run check-a11y
  • cd src-tauri && cargo fmt --check && cargo clippy && cargo test — macOS, Linux, and Windows
  • cd src-tauri && cargo deny check — supply chain

CI-only checks also passed: workflow lint, dependency review, typos, version lockstep, PR title, CodeQL, the aggregate pre-merge gate, and macOS/Windows preview installer builds.

Merge style

  • Squash
  • Merge commit

Summary by CodeRabbit

  • New Features
    • Added AI compute-device selection for automatic, CPU-only, or specific accelerator hardware.
    • Added hardware detection and device details in AI settings.
    • Preserved the selected device when restarting the AI engine.
    • Added device-aware benchmark compatibility and result tracking.
  • Bug Fixes
    • Improved Windows builds and downloads with Vulkan support, while retaining CPU fallback behavior.
    • Added safer fallback handling when hardware detection or configuration fails.
  • Documentation
    • Updated Windows build requirements and Vulkan archive instructions.

Copilot AI lite review requested due to automatic review settings August 10, 2026 23:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds persisted AI compute-device selection for automatic, CPU, or explicit devices. It discovers available accelerators, applies selections to sidecar launches, includes hardware in benchmark fingerprints, and switches Windows llama.cpp packaging to Vulkan.

Changes

GPU compute-device selection

Layer / File(s) Summary
Selection persistence and fingerprints
src/features/ai/computeDevice.ts, src/features/ai/benchmark.ts, src/features/ai/index.ts, tests/unit/ai-compute-device.test.ts
The frontend validates and persists compute-device selections. Benchmark fingerprints now include the selected device. Tests cover validation, persistence defaults, and fingerprint generation.
Device discovery and engine information
src-tauri/src/commands/compute_device.rs, src-tauri/src/commands/engine.rs, src-tauri/src/commands/mod.rs, src/features/ai/engine.ts
The backend resolves revisioned engine runtimes, probes llama-server --list-devices, filters device output, and returns devices and discovery errors through asynchronous engine information.
AI settings integration
src/features/settings/categories/AiCategory.tsx
The settings UI hydrates, displays, validates, and persists compute-device choices. Controls are disabled during active engine operations.
Sidecar device propagation
src-tauri/src/commands/sidecar.rs
Sidecar startup and respawn paths preserve the selected device and derive GPU-layer and --device arguments.
Windows Vulkan engine packaging
scripts/build-llama-server.sh, scripts/fetch-llama-server.sh
Windows builds enable Vulkan and use the Vulkan llama.cpp archive with updated documentation and checksums.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AISettings
  participant computeDevice
  participant engine_info
  participant llama_server
  AISettings->>computeDevice: hydrate selected device
  computeDevice-->>AISettings: cached or persisted selection
  AISettings->>engine_info: request engine information
  engine_info->>llama_server: invoke --list-devices
  llama_server-->>engine_info: device output
  engine_info-->>AISettings: devices and device_error
  AISettings->>computeDevice: persist changed selection
Loading

Possibly related PRs

  • scotej/studyvis#88: Extends related engine and sidecar changes with Vulkan-aware device discovery and propagation.
  • scotej/studyvis#45: Modifies sidecar lifecycle and respawn behavior in the same module.
  • scotej/studyvis#163: Modifies AI benchmark behavior and inference fingerprint handling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding AI hardware selection.
Description check ✅ Passed The description covers the change, testing limits, compatibility surfaces, gates, and merge style in the required template.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/211-ai-hardware-selection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@scotej
scotej merged commit 322fd70 into main Aug 11, 2026
20 checks passed
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