fix(logviewer): preserve URL lineNumber range across mount#9524
Merged
Conversation
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>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Archaeopteryx
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A shared logviewer URL like
?lineNumber=17657-19403had 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.jsxhad a mount-time effect that firedonHighlightChange(highlight)whilehighlightwas still its initialnullfromuseLogViewer— so the parent'swriteLineNumberParam(null)cleared the URL param before any of the URL-preservation logic could run.App.jsxonly readurlLN[0]forinitialLineand initializedhighlighttonull, dropping the range end on load.ClassicLogViewer.jsx'sinitialLineeffect always calledsetHighlight([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 theinitialLineeffect so it no longer overrides the range.Test plan
LogviewerUrlPreservation_test.jsxloads?lineNumber=17657-19403, mocks the log + an error, and assertswindow.location.searchstill contains the range after both fetches settle. A second test scans everyhistory.pushStatecall and verifies none of them clobber the range.useLogViewer_test.jscovers theinitialHighlightseed./logviewer?...&lineNumber=A-Band confirm both the URL and the highlighted range survive the load./logviewer?...(no lineNumber) and confirm the first error line is still auto-selected.