Skip to content

Per-route selector in the route string: '/pricing @section.cta' - #91

Merged
tmashara merged 2 commits into
mainfrom
claude/issue-26-route-selector
Oct 29, 2026
Merged

tmashara merged 2 commits into
mainfrom
claude/issue-26-route-selector

Conversation

@tmashara

Copy link
Copy Markdown
Owner

What

A route string can carry its own selector: whitespace, then @, after the path. This adds no new flag.

renderdiff L R /a /b '/pricing @section.light-blue-footer-container' --selector .try-metabase-footer
'/pricing @section.cta'                # both sides /pricing, both shot at section.cta
'/pricing @.plans-v2::/plans @.plans'  # pair, one selector per side
'/pricing @.new::/pricing @.old'       # same path, different markup per side

Why

#26: you can now compare several components, plus whole pages, in one run without a config file. The first command above does the issue's four runs in one.

Syntax

  • The pair split (::/) runs first. Then each side splits at its first \s+@, so a selector may contain @, ::, >> or spaces, e.g. '/c @[href="mailto:[email protected]"]'.
  • The space is required, so /@user stays a path. Raw whitespace can't appear in a URL path or query, so every route that works today keeps its meaning: /@me, /npm/@scope/pkg, [email protected] and /@u@host. Sitemap and probe paths come from URL, which percent-encodes whitespace, so they can't hit the separator either.
  • One quoted shell argument.
  • These exit 2:
    • A selector on one side of a pair only: '/a::/b @.x' gives give a selector on both sides or neither.
    • An empty selector: '/a @' gives has an empty selector.

Precedence

A selector written in the route beats --selector / --left/right-selector, which beat a config route object's selector. The second half is unchanged. Config strings get the syntax for free, and since a string with @ is new syntax, this precedence breaks nothing that exists.

GitHub Action limitation

The Action's routes input splits on whitespace, so it can't carry this syntax. docs/github-action.md now says per-route selectors go in the config. I left the optional action.yml guard (reject a token starting with @) out. Add it if someone hits this.

How tested

  • Five new dry-run tests in tests/unit/cli-args.test.ts:
    • precedence over --selector
    • per-side pair
    • /@me and [email protected] stay plain, and a selector with @ is kept whole
    • the two exit-2 errors
  • All five fail without the src/config.ts change and pass with it.
  • typecheck, lint, format:check, npm test (340) and npm run test:visual (347) all pass, after rebasing on 0.10.0.

Docs: README, docs/scoping.md, docs/github-action.md, skills/renderdiff/{SKILL,reference}.md, and --help.

Fixes #26

🤖 Generated with Claude Code

tmashara and others added 2 commits October 29, 2026 20:17
A route string's side may end in whitespace + @selector; a pair takes one per
side. The required whitespace keeps /@user, /npm/@scope/pkg and ?e=a@b plain
paths. A selector in the route beats --selector, which still replaces a config
route object's selector.

Fixes #26

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tmashara
tmashara merged commit f7e59a6 into main Oct 29, 2026
3 checks passed
@tmashara
tmashara deleted the claude/issue-26-route-selector branch October 29, 2026 19:32
This was referenced Oct 29, 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.

Per-route selector on the CLI

1 participant