Skip to content

feat: add Ollama model management widget#15

Open
Alarisco wants to merge 89 commits into
HANCORE-linux:mainfrom
Alarisco:feat/ollama-widget
Open

feat: add Ollama model management widget#15
Alarisco wants to merge 89 commits into
HANCORE-linux:mainfrom
Alarisco:feat/ollama-widget

Conversation

@Alarisco

@Alarisco Alarisco commented Jul 12, 2026

Copy link
Copy Markdown

Summary

Adds an optional, default-off Ollama widget for monitoring GPU utilization and managing local models from the Quickshell bar.

This supersedes #14 and is based on current main.

Features

  • GPU utilization widget with compact mode and sparkline history
  • Installed/loaded model overview with VRAM and runtime details
  • Exclusive load, eject, delete confirmation, and model pull controls
  • Runtime Keep Alive and context-length configuration
  • Direct Ollama HTTP API integration without Ollama CLI or shell-evaluated model input
  • Streaming pull parsing with readable per-layer size/rate/ETA feedback
  • Explicit cancellation while streaming and bounded 180-second post-stream reconciliation
  • Short, stable completion/error results after finalization

Lifecycle And Performance

  • Ollama remains disabled by default and produces no Ollama API polling or visible UI
  • Version and model data refresh on panel open, operations, manual/IPC refresh, and reconciliation, not periodically while closed
  • GPU provider detection is lifecycle-aware
  • AMD uses a readable amdgpu gpu_busy_percent source without recurring child processes
  • NVIDIA uses a persistent nvidia-smi sampler with separate open/closed cadences
  • Unsupported or failed GPU sources settle at N/A until an explicit retry lifecycle

Reliability And UI

  • Structurally validates /api/tags and /api/ps before replacing model state
  • Keeps endpoint-specific connection/error state and rejects stale responses
  • Separates bar-origin and panel-origin tooltip geometry
  • Uses explicit labeled delete confirmation with deterministic cancellation
  • Keeps icon bounds, hover contrast, configuration alignment, infinity sizing, and Custom input geometry stable
  • Splits panel sections, runtime configuration, model operations, pull lifecycle, and GPU sampling into focused components
  • Keeps all smoke roots under tests/; no test-only ShellRoot is shipped in versions/V1

Bar Integration

  • Uses the existing slot delegate and persisted ordering as group G16
  • Supports split groups, drag/drop, compact mode, and per-monitor popup anchoring
  • Participates in narrow-stage reduction
  • Preserves legacy bar-order/split caches and appends Ollama fields without moving existing cache fields

Testing

  • QtTest: 109 passed, 0 failed
  • Native Quickshell data, model-operation, and panel component tests
  • Pull, lifecycle, GPU, and wiring integration suites
  • Arch, Theme, and Shell updater regression suites
  • qmllint and git diff --check
  • Isolated active AMD runtime smoke: enable, open, refresh, close, and original-bar restoration

Notes

NVIDIA behavior was validated only with deterministic fixtures. No NVIDIA GPU was available on the contributor's test machine, so working and broken NVIDIA behavior could not be tested on real hardware.

Alarisco added 30 commits July 11, 2026 19:57
Slow polling to 15s when panel is closed (reduced CPU/memory load), restore 2s
when panel is open for responsive GPU and loaded-model updates. Follows
the same adaptive pattern already used by the AI usage timer.
Alarisco added 28 commits July 14, 2026 10:07
@Alarisco

Copy link
Copy Markdown
Author

@HANCORE-linux The requested correctness, payload, maintainability, polling/GPU, UI, and performance follow-up is now implemented. The branch has been updated through 6bee654.

Correctness

  • Tooltip placement: 3090a6e separates bar-position-aware placement from panel-anchor placement. Geometry coverage includes top/bottom bars and panel anchors at multiple screen sizes/edges in tst_TooltipPosition.qml.
  • Pull reconciliation: 558f775, 2d54e30, and 144da9e use a documented time-based backoff with a 180-second deadline. State remains Finalizing... until the exact model is present. Cancel is available only during streaming; late responses are rejected and final results are published atomically. The integration suite exercises delayed visibility, timeout, cancellation, close/reopen, and retry.
  • /api/tags validation: b1e8719 requires models to be an array and every entry to expose a non-empty name. Wrong schemas and missing names preserve prior state, clear the endpoint connection flag, and expose an error.
  • Current-layer feedback: f61af62 labels digest-specific transfer feedback as Current layer; multi-digest tests verify that all per-layer fields reset together.

Payload And Maintainability

  • 1bb6f12, 3f0c592, 922fe5c, 17e3970, and d6bdfc7 keep canonical smoke fixtures under tests/ and guard against test roots entering the production payload.
  • 8af533a splits the panel into focused header, summary, models, pull, and configuration sections.
  • 7cc1a18, f755f7a, and 37ac762 split runtime configuration, model operations, and pull lifecycle from the shared data coordinator.
  • 69156a0 moves provider-aware GPU sampling into OllamaGpuSampler.qml.

Polling And GPU

  • ebf1842 removes periodic API polling while the panel is closed; refreshes now come from explicit lifecycle events.
  • 5d62324 cancels queued refreshes after close.
  • 69156a0 detects and retains the selected GPU provider and uses a persistent NVIDIA sampler instead of spawning nvidia-smi every two seconds.
  • a233d05 retains only readable AMD DRM utilization sources.
  • Unsupported/failed providers settle at stable N/A and retry only on an explicit lifecycle event.

UI

  • bd7ef25 and 7e1c736 align and exercise the actual production controls: delete glyph bounds/contrast, labeled confirmation, icon tooltips, configuration heading/gear sizing, infinity optical sizing, centered Custom input, hover/selected/disabled behavior, and no layout shifts.

Final Verification

  • QtTest: 109 passed, 0 failed
  • Native OllamaData component: PASS
  • Pull integration: PASS
  • Lifecycle integration: PASS
  • GPU integration: PASS
  • Theme/wiring regression: PASS
  • Arch/Theme/Shell updater regressions: PASS
  • qmllint: PASS
  • performance harness self-test: PASS
  • git diff --check: PASS
  • isolated active AMD IPC smoke: enable/open/refresh/close and original-bar restoration: PASS

AMD A/B Evidence

The report and all raw artifacts are committed under docs/performance/pr15-ollama-amd/. The final run used current main 5fde51e and PR 3b08d8a, with 30-second warm-ups and 120/120/120/60-second windows.

Scenario CPU boundaries Own p50 Own p95 Own whole PSS delta Ollama API starts nvidia-smi starts
Main 121 5.0000% 9.0000% 5.4750% +13,540 KiB 0 0
PR disabled 121 5.0505% 7.0000% 5.6329% -943 KiB 0 0
PR enabled, closed 121 6.0000% 8.0000% 6.1912% +15,737 KiB 0 0
PR enabled, open 61 6.0000% 8.0000% 6.1323% +4,639 KiB 0 0

PR-disabled own CPU was +0.1579 percentage point versus main, which crosses the requested 0.10 pp review flag. Main and enabled-closed PSS boundary growth crossed the requested review levels, while disabled PSS decreased; the report retains these as noisy boundary flags rather than presenting them as leak proof. Live-descendant CPU lower bounds, reaped-child CPU, calibrated process attribution, and QSG logs are included in the raw evidence.

The real host is an RX 6700 XT using readable amdgpu sysfs. No recurring GPU child process or Ollama API polling was observed in the measured idle windows, and the harness restored the widget cache byte-for-byte and reported zero surviving owned processes.

NVIDIA behavior was validated only with deterministic fixtures. No NVIDIA GPU was available on the benchmark machine, so working and broken NVIDIA behavior could not be tested on real hardware.

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