Skip to content

fix(packets): updatePacketsUrl drops ?obs= and ?viewPath= on load and on filter changes #147

Description

@dborup

Summary

updatePacketsUrl() in public/packets.js rebuilds the hash from buildPacketsQuery(), which only writes filter params. Every call therefore drops packet-detail params it does not own, obs (selected observation) and viewPath (shareable View Path modal), from #/packets/<hash>?obs=…&viewPath=1. The pane keeps showing the selected observation, but the address bar no longer describes it, so a second refresh or a link copied from the address bar loses it.

#132 stopped the type menu from doing this (it now only refreshes the Clear button via updateClearFiltersVisibility()), but the other call sites remain. Found by the independent re-review of #132.

Where it happens (master 5f493f1d)

  • Cold load: init() calls updatePacketsUrl() to show the Clear button when the page loads with URL filters (around line 1984). Opening #/packets/<hash>?obs=123 directly rewrites it to #/packets/<hash> immediately; ?obs was already parsed (around line 1102), so the first render is right, but the URL is not.
  • Observer menu and the other filter handlers (region/area onChange, hash/node/channel/filter inputs, time window, sort; around lines 1681–2269).
  • viewPath is fork-specific (?viewPath=1, around line 1134); obs also exists upstream (reported there as Kpa-clawbot/CoreScope#2091).

Proposed fix

Make updatePacketsUrl() preserve the detail params it does not own when it rebuilds the query, e.g. read obs and viewPath from the current hash and re-append them after buildPacketsQuery(...). One place, fixes every caller, including init().

Keep buildPacketsQuery() itself filter-only (it is also used for API/other URLs). Consider whether viewPath should survive filter changes or be consumed once (it opens a modal on load); decide and test explicitly.

Acceptance criteria

  • Cold load of #/packets/<hash>?obs=123 and …?obs=123&viewPath=1 keeps those params in the address bar.
  • Changing observer, region/area, hash/node/channel/filter, time window or sort keeps obs (and viewPath per the decision above) while updating the filter params.
  • Clear Filters behaves as today (fix(packets): Clear Filters must reset observer and type selection state #121/fix(packets): empty observer/type selections on Clear Filters #132): filter params removed, detail subpath and params per the same rule.
  • Regression tests start from a detail URL with ?obs= (unit + a Playwright check at desktop width); the existing Clear Filters tests keep passing.
  • No change to buildPacketsQuery()'s output for callers that use it outside the hash.

Non-goals

No redesign of the filter bar or URL scheme; no deploy.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions