feat: MAC-stable device identity + label as primary display name - #115
Merged
Merged
Conversation
Backend: - upsert_device() now matches by MAC first; if MAC seen at a new IP, updates ip_address while preserving label/trusted/device_type - Adds ix_devices_mac_address index (model + idempotent migration) - RiskOut gains label: str | None populated from r.device.label - device_appeared event detail now includes 'label' (parity with device_disappeared which already had it) - 3 new tests: create new, MAC-first IP update, no-MAC IP fallback Frontend: - Risk interface gains label: string | null - RisksPage: risk cards + device filter use label ?? hostname ?? ip - DeviceDetailPage: page title uses label ?? hostname ?? ip_address; subtitle shows the next level down (hostname or IP as context) Closes #111 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two-part change: devices now keep their identity (and user data) when their DHCP lease changes; labels are used as the primary display name everywhere.
A — MAC-stable identity (backend)
upsert_device()lookup ordermac_addressprovided, find existing device by MACip_addressin-place, preservinglabel,trusted,device_typeIndex
ix_devices_mac_addressadded to model + idempotentCREATE INDEX IF NOT EXISTSin_migrate_schemaRiskOutlabel: str | None— populated fromr.device.labelscan_runner.pydevice_appeareddetail JSON now includes"label"(parity withdevice_disappeared)Tests (3 new)
B — Label as primary display name (frontend)
Display priority everywhere:
label ?? hostname ?? ip_addresshostname || iplabel ?? hostname ?? ipip (hostname)label ?? ip (hostname)label ?? hostname ?? ipTesting
Closes #111