Skip to content

fix(logviewer): preserve URL lineNumber range across mount#9524

Merged
Archaeopteryx merged 2 commits into
masterfrom
camd/logviewer-url-param-load
May 18, 2026
Merged

fix(logviewer): preserve URL lineNumber range across mount#9524
Archaeopteryx merged 2 commits into
masterfrom
camd/logviewer-url-param-load

Conversation

@camd
Copy link
Copy Markdown
Collaborator

@camd camd commented May 17, 2026

Summary

A shared logviewer URL like ?lineNumber=17657-19403 had its range stripped within milliseconds of page load, so the UI ended up selecting either the first error line (~17547) or just the range start (17657) — the range end was always lost.

Three interacting issues:

  • ClassicLogViewer.jsx had a mount-time effect that fired onHighlightChange(highlight) while highlight was still its initial null from useLogViewer — so the parent's writeLineNumberParam(null) cleared the URL param before any of the URL-preservation logic could run.
  • App.jsx only read urlLN[0] for initialLine and initialized highlight to null, dropping the range end on load.
  • ClassicLogViewer.jsx's initialLine effect always called setHighlight([initialLine]) once the log finished fetching, which would clobber any restored range with a single line.

The fix snapshots the full URL range at mount, plumbs it through as initialHighlight (App → ClassicLogViewer → useLogViewer), and skips the mount run of the initialLine effect so it no longer overrides the range.

Test plan

  • New regression test LogviewerUrlPreservation_test.jsx loads ?lineNumber=17657-19403, mocks the log + an error, and asserts window.location.search still contains the range after both fetches settle. A second test scans every history.pushState call and verifies none of them clobber the range.
  • New unit test in useLogViewer_test.js covers the initialHighlight seed.
  • All 1007 frontend tests still pass; biome lint clean on changed files.
  • Manual: open /logviewer?...&lineNumber=A-B and confirm both the URL and the highlighted range survive the load.
  • Manual: click and shift-click in the log, confirm the URL still updates with the single/range selection.
  • Manual: open /logviewer?... (no lineNumber) and confirm the first error line is still auto-selected.

A shared URL like ?lineNumber=START-END would have its range stripped
within milliseconds of page load: useLogViewer initialized highlight to
null, so ClassicLogViewer's mount-time onHighlightChange(null) cleared
the URL param. Subsequent effects then re-wrote it with either the first
error line or just the range start.

Read the full range out of the URL at mount in App.jsx, pass it down as
initialHighlight, and seed useLogViewer's highlight state with it. Skip
the mount run of ClassicLogViewer's initialLine effect so it no longer
overrides the URL range with [initialLine].

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@camd camd self-assigned this May 17, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.83%. Comparing base (3519a51) to head (17e4cd8).

Files with missing lines Patch % Lines
ui/logviewer/ClassicLogViewer.jsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9524      +/-   ##
==========================================
+ Coverage   82.75%   82.83%   +0.07%     
==========================================
  Files         604      604              
  Lines       34973    34977       +4     
  Branches     3261     3269       +8     
==========================================
+ Hits        28943    28972      +29     
- Misses       5661     5851     +190     
+ Partials      369      154     -215     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Archaeopteryx Archaeopteryx merged commit 01d4fcd into master May 18, 2026
7 checks passed
@Archaeopteryx Archaeopteryx deleted the camd/logviewer-url-param-load branch May 18, 2026 15:52
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.

3 participants