Skip to content

fix(ui): keep trace expansion stable during refresh - #11278

Open
localai-org-maint-bot wants to merge 2 commits into
masterfrom
bot/issue-11277-trace-selection
Open

fix(ui): keep trace expansion stable during refresh#11278
localai-org-maint-bot wants to merge 2 commits into
masterfrom
bot/issue-11277-trace-selection

Conversation

@localai-org-maint-bot

Copy link
Copy Markdown
Collaborator

Description

This PR fixes #11277.

The Traces page stored its expanded row by array index and also keyed React fragments by that index. When the five-second poll prepended a new trace, the same index referred to a different record, so the open detail panel moved. This change tracks expansion and reconciliation by stable trace ID instead.

A focused Playwright regression prepends a trace during manual refresh and asserts that the original trace remains expanded.

Notes for Reviewers

Validation performed:

  • npx eslint src/pages/Traces.jsx e2e/traces-pagination.spec.js (0 errors; 11 pre-existing warnings in Traces.jsx)
  • npm run lint:inline-styles (624, at baseline)
  • npm run build
  • PW_WORKERS=1 npx playwright test e2e/traces-pagination.spec.js --list (4 tests discovered)
  • git diff --check

Browser execution could not run on this NixOS host: the cached Playwright Chromium requires libglib-2.0.so.0, and no system Chromium or Nix development shell is available in this cron environment. CI should execute the regression in the repository-supported browser environment.

Signed commits

  • Yes, I signed my commits.
  • Documentation updated (docs/content/) for user-facing changes, or not applicable

mudler added 2 commits August 1, 2026 16:06
Track expanded traces by their stable IDs instead of table indexes so polling cannot move an open detail panel to a newly inserted row. Use the same IDs for React keys and cover the prepend-on-refresh case in Playwright.

Fixes #11277

Assisted-by: Codex:gpt-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Keep ID-based expansion stable across refreshes while falling back to the row index for backend trace summaries that do not carry an ID.

Assisted-by: Codex:gpt-5 [systematic-debugging]
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@localai-org-maint-bot

Copy link
Copy Markdown
Collaborator Author

Review pass. The fix is right and both tables are converted symmetrically, which is the sibling path that usually gets missed. Two small things.

Nit that matters: ?? cannot do what the second commit intends.

trace.id ?? i only falls back when id is null or undefined. Both trace types declare ID string \json:"id"`with noomitempty (core/trace/backend_trace.go:62, core/http/middleware/trace.go:46), and SummarizeBackendTrace` preserves it, so the key is never absent, only ever empty.

Concrete failure: if any trace carries id: "" (a legacy persisted trace deserialized through core/trace/tracepersist, or a failed ID generation), every such row shares the key "". Clicking one expands all of them and React sees duplicate keys. The second commit was written to guard exactly this case and picked the operator that cannot. || fixes it.

Worth a rebase check before merge. The flat diff no longer applies (git apply --check fails at Traces.jsx:648); GitHub's three-way merge still succeeds, but the file changed twice since this opened: 9f62401fc (#11368, in-flight API requests) and 799cc9f21 (#11560, bound global admission and running backend traces). Those add status === 'running' rows that appear and disappear on every poll, so the prepend scenario this fixes is now much more frequent. The fix is more valuable than when it was written; the merged result just wants an eyeball against the new rendering block.

Undescribed but correct: toggleSort now also clears detail, which it did not before. That is an incidental fix (a stale detail could render against a re-sorted row) worth a line in the commit message.

Note DCO: no Signed-off-by on the commits.

@mudler
mudler force-pushed the bot/issue-11277-trace-selection branch from 70f1eb3 to 781b4b4 Compare September 3, 2026 20:35
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.

WebU(traces): Traces keep on scrolling after opening

2 participants