Skip to content

fix(react-ui): unify backend-logs entry point for distributed mode#9949

Merged
mudler merged 1 commit into
masterfrom
fix/backend-logs-distributed-mode
May 22, 2026
Merged

fix(react-ui): unify backend-logs entry point for distributed mode#9949
mudler merged 1 commit into
masterfrom
fix/backend-logs-distributed-mode

Conversation

@localai-bot
Copy link
Copy Markdown
Collaborator

Summary

In distributed mode the local `/api/backend-logs` WebSocket has nothing behind it (inference runs on workers), so the "View backend logs" link in Traces dead-ended on `/app/backend-logs/`. Manage worked around it by hiding the action; Traces still rendered the broken link.

This PR makes `/app/backend-logs/:modelId` the single, mode-aware entry point so every view links to the same URL and the destination adapts to the running mode.

  • New `BackendLogsRouter` in `BackendLogs.jsx` probes `useDistributedMode` and forks:
    • standalone: existing local WebSocket view (`BackendLogsDetail`), unchanged.
    • distributed: new `DistributedBackendLogsResolver` fans out to each node via `nodesApi.getModels`, filters by `model_name`, then routes:
      • 0 hits - empty state with a link to the Nodes page.
      • 1 hit - `` to `/app/node-backend-logs//`, preserving the `?from=` deep-link timestamp.
      • N hits - picker listing each hosting worker (node id, replica index, load state) so the operator can choose.
  • Bare `modelId` in the redirect target intentionally aggregates that node's replicas via the worker's `BackendLogStore`, matching the existing per-node link pattern in `Nodes.jsx`.
  • Reverted the per-caller distributed checks now that routing is centralised:
    • `Manage.jsx`: dropped `hidden: distributedMode` on the Backend logs action.
    • `Traces.jsx`: link is unconditional again (no `distributedMode` prop threading).

Any future view that wants to link to backend logs just uses `/app/backend-logs/:modelId` and gets the right behaviour in both modes.

Test plan

  • Standalone mode: open Traces, expand a backend trace - "View backend logs" still streams the local model logs as before. Same for Manage > Actions > Backend logs.
  • Distributed mode, model loaded on exactly one worker: same flow redirects (replace history entry) to `/app/node-backend-logs//` with the `?from=` timestamp preserved so the deep-link scrolls to the right line.
  • Distributed mode, model loaded on multiple workers: picker renders one row per hosting worker (node id, replica index, state); clicking a row opens that worker's logs page.
  • Distributed mode, model not loaded anywhere: empty state appears with a link to the Nodes page.
  • Distributed mode, nodes API partial failure: a single offline worker doesn't hide logs available on its peers (per-node fetch errors are tolerated).

In distributed mode the local /api/backend-logs WebSocket has nothing
behind it (inference runs on workers), so the "View backend logs" link
in Traces (and the action in Manage when previously not hidden) dead-
ended on /app/backend-logs/<modelId>. Manage worked around it by
hiding the action; Traces still rendered the link.

Make /app/backend-logs/:modelId the single, mode-aware entry point.
A new BackendLogsRouter probes useDistributedMode and forks:

  - standalone: existing local WebSocket view (BackendLogsDetail).
  - distributed: DistributedBackendLogsResolver fans out to each node
    via nodesApi.getModels, filters by model_name, and routes:
      * 0 hits   -> empty state with a link to the Nodes page.
      * 1 hit    -> <Navigate replace> to
                    /app/node-backend-logs/<nodeId>/<modelId>,
                    preserving the ?from= deep-link timestamp.
      * N hits   -> picker listing each hosting worker (node id,
                    replica index, load state) so the operator can
                    choose which worker's logs to view.

Bare modelId in the redirect target intentionally aggregates that
node's replicas via the worker's BackendLogStore, matching the
existing per-node link pattern in Nodes.jsx.

Revert the per-caller distributed checks now that routing is
centralised: drop the hidden:distributedMode guard on Manage's
Backend logs action, and remove the prop threading in Traces so the
link is unconditional. Any future view that wants to link to backend
logs uses the same URL and gets correct behaviour in both modes.

Assisted-by: Claude:claude-opus-4-7 [Claude Code]

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler merged commit 834ecc3 into master May 22, 2026
57 checks passed
@mudler mudler deleted the fix/backend-logs-distributed-mode branch May 22, 2026 20:00
@localai-bot localai-bot added the bug Something isn't working label May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants