Skip to content

cli: sync input filters with the URL in dev/serve - #3338

Closed
wiwimaster wants to merge 1 commit into
evidence-dev:mainfrom
wiwimaster:cli-filters-url-sync
Closed

wiwimaster wants to merge 1 commit into
evidence-dev:mainfrom
wiwimaster:cli-filters-url-sync

Conversation

@wiwimaster

Copy link
Copy Markdown
Contributor

Problem

The Filter class supports reading an input's initial value from the page URL and writing user choices back (documented in core/src/FILTER_SYSTEM.md; the Preview context is listed as "reads: yes, writes: yes"). The CLI renderer never wired that up: CLIPageWrapper creates the page filters context without url/updateUrl deps, so in evidence dev and evidence serve

  • ?category=Electronics in the address bar is ignored, and
  • selecting a value does not update the URL.

For self-hosters this means table drill-throughs (a link column pointing at /detail?id=…) land on the detail page without a selection, and filtered views cannot be shared by URL.

Change

  • CLIPageWrapper.svelte: pass url (window.location.href on the client) and updateUrl (history.replaceState) to createPageFiltersContext, the same pattern the published/preview routes use.
  • process.ts: accept the request url as an option and hand it to the server-side Filters, so SSR renders the same state the client restores from the URL.
  • Both +page.server.ts loads pass their request url through.

18 insertions, no new dependencies.

Verification

Against a project with a BigQuery direct connector, running the CLI from source (bun cli/cli/index.ts --project … dev):

  • opening /detail?post_id=395196 pre-selects that option in the {% dropdown id="post_id" %} and the page queries render for it;
  • choosing another option rewrites the query string to ?post_id=9;
  • pnpm --filter @evidence/cli check passes; CLI unit tests: 18 files, 340 tests passed.

🤖 Generated with Claude Code

The Filter class already supports reading an input's initial value from
the page URL and writing user choices back (see core/src/FILTER_SYSTEM.md,
'Preview' context). The CLI renderer never wired that up:
CLIPageWrapper created the page filters context without url/updateUrl
deps, so `?category=Electronics` was ignored in `evidence dev` and
`evidence serve`, and choosing a value did not update the address bar.
Drill-through links from a table (`link` column pointing at
`/detail?id=…`) therefore landed on the detail page without a selection,
and filtered views could not be shared by URL when self-hosting.

- CLIPageWrapper: pass `url` (window.location on the client) and
  `updateUrl` (history.replaceState) to createPageFiltersContext, the
  same pattern the published/preview routes use.
- process(): accept the request URL as an option and hand it to the
  server-side Filters, so SSR renders the state the client restores.
- Both page.server loads pass their request `url` through.

Verified against a BigQuery project: opening `/page?filter_id=value`
pre-selects the dropdown, selecting an option rewrites the query string,
`pnpm --filter @evidence/cli check` and the CLI unit tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 21, 2026

Copy link
Copy Markdown

@wiwimaster is attempting to deploy a commit to the Evidence Team on Vercel.

A member of the Team first needs to authorize it.

@hughess

hughess commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

@wiwimaster this should be solved in 0.10.0 - let me know if that's working for you!

Closing this PR for now, but feel free to reopen if it's not working for you

@hughess hughess closed this Sep 26, 2026
@wiwimaster

Copy link
Copy Markdown
Contributor Author

Thanks @hughess, confirmed: with evidencedev/serve:0.10.1 a link like /detail?post_id=… now pre-selects the dropdown, and table row links from our scoreboard land on the right detail page. We're running 0.10.1 in production now. Happy to leave this closed.

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.

2 participants