Skip to content

Select an endpoint in the collection you clicked it in - #85

Merged
MathiasWP merged 1 commit into
mainfrom
fiber-selection-collision
Aug 24, 2026
Merged

Select an endpoint in the collection you clicked it in#85
MathiasWP merged 1 commit into
mainfrom
fiber-selection-collision

Conversation

@MathiasWP

Copy link
Copy Markdown
Owner

Two collections describing the same API — staging and production — give every loaded endpoint the same id. That isn't an accident: a loaded id is endpointKey, "GET /users", and it carries no section because it's the identity a saved body and a refresh have to agree on. Putting the section into it would orphan every overlay entry on disk.

Selection was keyed on that id alone, which made three symptoms of one bug:

  • Both rows highlighted, in staging and production at once.
  • The pane resolved to the wrong onefindRequest returned whichever collection sorted first, whatever you clicked.
  • The second was unopenable. Clicking it set an id the store already held, so nothing changed and the row was inert.

Fix

Selection carries selectedSectionId alongside the id, and the sidebar's highlight compares both.

findRequest takes the section as a preference, not a filter: a history entry recorded before this existed names no section, and answering nothing for it would lose the request it points at — so the search still falls back to the first match, exactly as it did.

Every site that writes a selection now sets both, including the removal paths (deleting a collection clears the selection by section rather than by an id the collection next door may also hold).

On the test

It asserts the highlight count as well as the resolution, and that mattered: the first version passed against the broken build. The base-URL chip is driven by selected, which the store fix alone repairs — the duplicated highlight needed its own assertion. Reverting isSelected now fails it with Expected: 1, Received: 2.

Known, not fixed here

Response history is still bucketed by request id, so the same endpoint in staging and production shares one history — a production response can appear under staging. Same root cause. Re-keying orphans entries already on disk, so it wants its own change that records the section going forward and falls back for older entries, rather than a silent loss.

Testing

pnpm check (0 errors), pnpm test:e2e (323 passed, 1 new).

Two collections describing the same API — staging and production — give
every loaded endpoint the same id. That is not an accident: a loaded id is
`endpointKey`, `"GET /users"`, and it carries no section because it is the
identity a saved body and a refresh have to agree on. Putting the section in
it would orphan every overlay entry on disk.

Selection was keyed on that id alone, so all three of these were the same
bug: both rows highlighted, `findRequest` answered with whichever collection
sorted first regardless of which you clicked, and the second one could not
be opened at all — the click set an id the store already held, so nothing
changed and the row was inert.

So the selection carries `selectedSectionId` alongside the id, and the
sidebar's highlight compares both. `findRequest` takes the section as a
*preference* rather than a filter: a history entry recorded before this
existed names no section, and answering nothing for it would lose the
request it points at, so the search still falls back to the first match.

The regression test asserts the highlight count as well as the resolution.
Without it the test passed against the broken build — the base-URL chip is
driven by `selected`, which the store fix alone repairs, and the duplicated
highlight needs its own assertion to be caught. Reverting `isSelected` now
fails it with "Expected: 1, Received: 2".

Response history is still bucketed by request id, so staging and production
share one history for the same endpoint. Same root cause, not fixed here:
re-keying it would orphan entries already written, and that wants its own
change with a fallback rather than a silent loss.
@MathiasWP
MathiasWP merged commit ba28ebb into main Aug 24, 2026
4 checks passed
@MathiasWP
MathiasWP deleted the fiber-selection-collision branch August 24, 2026 15:30
@github-actions github-actions Bot mentioned this pull request Aug 24, 2026
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.

1 participant