perf(webui): virtualize the log viewer row list (#185)

The logs page rendered every filtered row, so a full 2000-line view mounted
~10k DOM nodes and cost ~66ms of layout per commit. Switch to a virtualized
list (@tanstack/react-virtual) that mounts only the visible window plus a small
overscan — a few dozen nodes regardless of how many lines the view holds.

Rows are dynamically measured (measureElement) so wrap mode's variable-height
lines need no fixed row-height assumption; the size cache is keyed by row id so
the maxLines front-drop doesn't mis-attribute heights across the index shift.
The column header moved just outside the scroll viewport so the virtual list is
the sole scroll content (no sticky-offset math). Auto-scroll now follows the
tail via scrollToIndex with a next-frame re-pin (freshly-appended rows carry the
size estimate until measured, which otherwise left wrap-mode tails short), and
re-runs on filter/level/wrap/maxLines changes, not just new logs. ScrollArea
gained an optional viewportRef so the virtualizer can drive off the real Radix
scroll element. The per-row entrance fade is dropped (rows mount/unmount on
scroll); divide-y became a per-row border.
This commit is contained in:
DrSmoothl committed 2026-07-07 22:07:02 +08:00
1 parent 8fbcbd29ff
commit 4802dfe7aa
4 files changed
+126 -30

No files matched your search

+59 -2
View File
@@ -379,6 +379,9 @@ importers:
'@tanstack/react-router':
specifier: ^1.169.2
version: 1.169.2([email protected]([email protected]))([email protected])
'@tanstack/react-virtual':
specifier: ^3.14.5
version: 3.14.5([email protected]([email protected]))([email protected])
class-variance-authority:
specifier: ^0.7.1
version: 0.7.1
@@ -1720,6 +1723,12 @@ packages:
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
'@tanstack/[email protected]':
resolution: {integrity: sha512-4EKRXh7zBLkbKbFmG3AUVkircuHd+7OdT1pocJSepxtfBd3qnrJgJ5rtPkRYyo9fmyVb2+pI2xPy5oYvMLQy6A==}
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
'@tanstack/[email protected]':
resolution: {integrity: sha512-5sm0DJF1A7Mz+9gy4Gz/lLovNailK3yot4vYvz9MkBUPw26uLnhQiR8hSCYxucjE0wD6Mdlc5l+Z0/XTlZ7xHw==}
engines: {node: '>=20.19'}
@@ -1727,6 +1736,9 @@ packages:
'@tanstack/[email protected]':
resolution: {integrity: sha512-8reSzl/qGWGGVKhBoxXPMWzATSbZLZFWhwBAFO9NAyp0TxzfBP0mIrGb8CP8KrQTmvzXlR/vFPPUrHTLBGyFyw==}
'@tanstack/[email protected]':
resolution: {integrity: sha512-8Np/TFELpI0ySuJoVmjvOrQYXH/8sTX0Biv9szhFhY39xOdAAY+smrMxjxOum/ux3eM8MUJQsEJ0/R0UpvC8dw==}
'@tybys/[email protected]':
resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==}
@@ -4308,6 +4320,12 @@ snapshots:
react-dom: 19.2.5([email protected])
use-sync-external-store: 1.6.0([email protected])
'@tanstack/[email protected]([email protected]([email protected]))([email protected])':
dependencies:
'@tanstack/virtual-core': 3.17.3
react: 19.2.5
react-dom: 19.2.5([email protected])
'@tanstack/[email protected]':
dependencies:
'@tanstack/history': 1.161.6
@@ -4317,6 +4335,8 @@ snapshots:
'@tanstack/[email protected]': {}
'@tanstack/[email protected]': {}
'@tybys/[email protected]':
dependencies:
tslib: 2.8.1
@@ -4476,7 +4496,7 @@ snapshots:
magicast: 0.5.3
obug: 2.1.1
tinyrainbow: 3.1.0
vitest: 4.1.4(@types/node@24.12.2)(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/node@24.12.2)([email protected])([email protected])([email protected])([email protected]))
vitest: 4.1.4(@types/node@25.6.0)(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/node@25.6.0)([email protected])([email protected])([email protected])([email protected]))
transitivePeerDependencies:
- supports-color
@@ -4492,7 +4512,7 @@ snapshots:
obug: 2.1.1
std-env: 4.1.0
tinyrainbow: 3.1.0
vitest: 4.1.4(@types/node@24.12.2)(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/node@24.12.2)([email protected])([email protected])([email protected])([email protected]))
vitest: 4.1.4(@types/node@25.6.0)(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/node@25.6.0)([email protected])([email protected])([email protected])([email protected]))
'@vitest/[email protected]':
dependencies:
@@ -4511,6 +4531,14 @@ snapshots:
optionalDependencies:
vite: 8.1.0(@types/[email protected])([email protected])([email protected])([email protected])([email protected])
'@vitest/[email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))':
dependencies:
'@vitest/spy': 4.1.4
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
vite: 8.1.0(@types/[email protected])([email protected])([email protected])([email protected])([email protected])
'@vitest/[email protected]':
dependencies:
tinyrainbow: 3.1.0
@@ -5813,6 +5841,35 @@ snapshots:
transitivePeerDependencies:
- msw
[email protected](@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])):
dependencies:
'@vitest/expect': 4.1.4
'@vitest/mocker': 4.1.4([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))
'@vitest/pretty-format': 4.1.4
'@vitest/runner': 4.1.4
'@vitest/snapshot': 4.1.4
'@vitest/spy': 4.1.4
'@vitest/utils': 4.1.4
es-module-lexer: 2.0.0
expect-type: 1.3.0
magic-string: 0.30.21
obug: 2.1.1
pathe: 2.0.3
picomatch: 4.0.4
std-env: 4.1.0
tinybench: 2.9.0
tinyexec: 1.1.1
tinyglobby: 0.2.16
tinyrainbow: 3.1.0
vite: 8.1.0(@types/[email protected])([email protected])([email protected])([email protected])([email protected])
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 25.6.0
'@vitest/coverage-istanbul': 4.1.4([email protected])
'@vitest/coverage-v8': 4.1.4([email protected])
transitivePeerDependencies:
- msw
[email protected]:
dependencies:
'@types/fs-extra': 11.0.4