LocalAI/pkg/model
Ettore Di Giacinto 3280b9a287
Some checks failed
Security Scan / tests (push) Has been cancelled
fix(distributed): per-replica backend logs (store aggregation + UI)
The multi-replica refactor (PR #9583) changed the worker's process key
from `modelID` to `modelID#replicaIndex`, but the BackendLogStore kept
the bare-modelID lookup. Result: every distributed deployment lost
backend logs in the Nodes UI — single-replica too, since even the
default capacity of 1 produces a `#0` suffix.

Two changes wired together:

* pkg/model: BackendLogStore.GetLines/Subscribe now treat a modelID
  without `#` as a model prefix and merge across all `modelID#N` replica
  buffers (timestamp-sorted for GetLines; fan-in for Subscribe). Calls
  with a full `modelID#N` key resolve exactly. ListModels strips
  replica suffixes and deduplicates so the listing surfaces one entry
  per loaded model.

* react-ui: per-replica log streams as the default. Loaded Models
  table disambiguates each row with a `rep N` pill (only when the node
  hosts >1 replica of a model). Each row's "View logs" link routes to
  the per-replica process key so operators see only that replica's
  output. The logs page renders the replica context as a chip in the
  title and surfaces a segmented control — `Replica 0 / 1 / … / All
  merged` — when the model has multiple replicas; the merged segment
  uses the bare-modelID URL (delegating to the store's prefix
  aggregation) for the side-by-side comparison case. Single-replica
  deployments see no extra UI.

Tests added first (TDD): the regression set in
backend_log_store_test.go reproduces the bug at the exact failure
point — GetLines/ListModels/Subscribe assertions all fail against the
broken code, all pass against the fix. TestSubscribe_PerReplicaFilter
pins the exact-key path so a future change can't silently break it.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: claude-code:opus-4-7 [Edit] [Skill:critique] [Skill:audit] [Skill:polish] [Skill:distill]
2026-04-27 20:55:24 +00:00
..
backend_log_store.go fix(distributed): per-replica backend logs (store aggregation + UI) 2026-04-27 20:55:24 +00:00
backend_log_store_test.go fix(distributed): per-replica backend logs (store aggregation + UI) 2026-04-27 20:55:24 +00:00
connection_errors.go fix(nodes): better detection if nodes goes down or model is not available (#9274) 2026-04-08 12:11:02 +02:00
connection_evicting_client.go feat: wire transcription for llama.cpp, add streaming support (#9353) 2026-04-14 16:13:40 +02:00
filters.go fix: make sure to close on errors (#7521) 2025-12-11 14:03:20 +01:00
initializers.go feat(backends): add ik-llama-cpp (#9326) 2026-04-12 13:51:28 +02:00
loader.go fix(model-loader): also skip .ckpt, .zip, and .tag files when scanning models 2026-04-26 19:37:53 +00:00
loader_options.go feat: refactor build process, drop embedded backends (#5875) 2025-07-22 16:31:04 +02:00
loader_test.go fix(nodes): better detection if nodes goes down or model is not available (#9274) 2026-04-08 12:11:02 +02:00
model.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00
model_suite_test.go tests: add template tests (#2063) 2024-04-18 10:57:24 +02:00
process.go feat: Log backend exit code (#9581) 2026-04-27 14:19:18 +02:00
store.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00
store_test.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00
watchdog.go feat: allow to pin models and skip from reaping (#9309) 2026-04-11 08:38:17 +02:00
watchdog_options.go feat: disable force eviction (#7725) 2025-12-25 14:26:18 +01:00
watchdog_options_test.go chore: fixup tests with defaults from constants 2025-12-16 21:26:55 +00:00
watchdog_test.go feat: allow to pin models and skip from reaping (#9309) 2026-04-11 08:38:17 +02:00