Skip to content

feat(console/list-pages): persist selected item id in URL#18

Merged
vaderyang merged 1 commit into
mainfrom
feat/selected-id-in-url
May 19, 2026
Merged

feat(console/list-pages): persist selected item id in URL#18
vaderyang merged 1 commit into
mainfrom
feat/selected-id-in-url

Conversation

@vaderyang
Copy link
Copy Markdown
Collaborator

Summary

Agent Turns, LLM Calls, and HTTP Exchanges keep the slide-over detail's open id in React state, so copying the URL or hitting refresh drops the selection and reopens the list with no panel. Every other filter on those pages already round-trips through the URL via `useSearchParamState`; this is the one holdout.

Move the selected id onto a `?selected=` query param backed by the same hook. Now:

  • Copy URL lands a recipient on the same row with the panel open.
  • Refresh / back-forward restores the panel.
  • Close panel removes the param (empty string is the default → the hook drops the key).

Implementation detail

LLM Calls and HTTP Exchanges also tracked `selectedIndex` (for the panel's prev/next buttons). That state was redundant — the index is now derived from `items.findIndex(i => i.id === selectedId)`. One source of truth (the URL); prev/next still works as long as the selected id is on the current page.

If the URL points to an id that isn't on the visible page (e.g. someone pasted a link with a different filter or stale time range), the prev/next buttons naturally disable (`index = -1`) but the detail still loads — the panel queries by id rather than indexing into the list.

Verification

  • `bun test` — 97 pass
  • `npm run build` — green
  • Deployed to wuneng (new bundle index-_yoJkBO2.js); panel opens / closes / survives refresh on all three pages

Test plan

  • Open a row in Agent Turns → URL gains `?selected=<turn_id>`
  • Copy URL into a new tab → list opens with that row's detail panel
  • Refresh while the panel is open → panel stays open on the same row
  • Close the panel → `selected` param disappears from the URL
  • Same flow on LLM Calls and HTTP Exchanges
  • On LLM Calls, prev/next buttons still work; disable correctly at edges

🤖 Generated with Claude Code

The list pages (Agent Turns, LLM Calls, HTTP Exchanges) all kept the
slide-over detail's open id in React state, so copying the URL or
hitting refresh dropped the selection and reopened the list with no
panel — invisible to anyone trying to bookmark or share a link to a
specific item. Other filters on these pages already round-trip
through the URL via useSearchParamState; the selection was the one
holdout.

Move the selected id onto a `?selected=<id>` query param backed by
the same hook. Effects:

* Open detail → URL gains ?selected=<id>; copy / share lands a
  recipient on the same row with the panel open.
* Refresh / back-forward navigation restores the panel.
* Close panel → param removed (empty string is the default → hook
  drops it from the URL).

LLM Calls and HTTP Exchanges also tracked `selectedIndex` for the
prev/next buttons on their detail panels. The index is now derived
from `items.findIndex(i => i.id === selectedId)` — one source of
truth (the URL) and prev/next continues to work as long as the
selected id is on the current page. If a paste-in id is no longer
on the visible page, the buttons disable naturally (index = -1) but
the detail still loads, since the panel queries by id rather than
indexing into items.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vaderyang vaderyang merged commit f45eadf into main May 19, 2026
1 check passed
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