Skip to content

device: unify identifier matching; case-insensitive names everywhere - #95

Merged
moskovich merged 1 commit into
mainfrom
device-name-matching
Jul 25, 2026
Merged

device: unify identifier matching; case-insensitive names everywhere#95
moskovich merged 1 commit into
mainfrom
device-name-matching

Conversation

@moskovich

Copy link
Copy Markdown
Contributor

What

Follow-up to #94, addressing two inconsistencies in how device identifiers are matched, plus a contributor-facing install note.

  1. One matcher, four surfaces. The name-or-host matching logic was duplicated across device remove (inline), device default, and device rename. It's now a single findConfiguredDeviceIndex() in device-lookup.ts, also used by runtime -d resolution (resolveConfiguredDevice).
  2. Case-insensitive everywhere. Management commands matched names case-insensitively but -d was exact-match — play -d Kitchen failed against a device named kitchen while device remove Kitchen worked. -d now matches case-insensitively and accepts a host URL (so unnamed legacy entries are targetable), the same rules as the management commands.
  3. Close the duplicate-name gap in add. The duplicate-name guard in device add was case-sensitive, so an update could save Kitchen alongside kitchen — making one unreachable by name under case-insensitive lookup. The guard now compares case-insensitively; a case-only rename of the same row is still allowed.
  4. README: documents the npm 12 --allow-git workaround for npm ci (git-URL dependency on @feralfile/source-resolver; npm 12 defaults allow-git=none).

Behavior change

resolveConfiguredDevice previously did exact-match lookups; the test pinning that (multi-device.test.ts) treated a config holding both Kitchen and kitchen as disambiguatable. Such configs can no longer be created (the add/rename guards reject them); for legacy configs that still contain case-duplicates, lookups deterministically resolve to the first row. The avahi-parse test header's case-preservation rationale is updated accordingly (names still round-trip verbatim as display labels).

Testing

  • New CLI integration test for the case-insensitive duplicate guard in add (conflict rejected, same-row case rename allowed).
  • New resolveConfiguredDevice cases: case-insensitive name, host-URL targeting, legacy case-duplicate first-match.
  • Full npm run check green: 444 tests, format, lint, copy lint.

… everywhere

Extract the name-or-host matcher duplicated across device remove,
device default, and device rename into findConfiguredDeviceIndex
(device-lookup.ts), and use it for runtime -d resolution too. -d now
matches names case-insensitively and accepts a host URL, the same rules
as the management commands; previously -d Kitchen failed against a
device named kitchen while device remove Kitchen worked.

Close the remaining gap in device add: the duplicate-name guard was
case-sensitive, so an update could save Kitchen alongside kitchen and
make one unreachable by name. The guard now compares case-insensitively;
a case-only rename of the same row is still allowed.

Also document the npm 12 allow-git install workaround in the README
dev section.
@moskovich
moskovich merged commit 8357125 into main Jul 25, 2026
6 checks 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