Feat/vehicle tag registry - #210
Merged
Merged
Conversation
The '175tbi' and '2.0gme' tags gate real behavior (the WOT quick-filter's per-ECU channel set, the acceleration Registry's extra run curves) but were hard-coded independently in math-definitions.ts and acceleration.service.ts, so a typo in either failed silently. Add src/app/core/vehicle-tags.ts as the single registry of tags the app branches on, distinct from the free-form labels users attach for filtering. autoEnableSignalsByTag is now keyed by VehicleTag, so a bad key fails the build, and both call sites match through fileHasVehicleTag(). That also normalizes the comparison (trim/lowercase/collapse whitespace, matching the signal-name lookups), so a log tagged externally as '2.0GME' -- tags seeded from Drive appProperties are never normalized on the way in -- now matches where it previously did not. Also fix the one-directional tag sync: DriveService.addTag wrote the Drive entry and appProperties only, never AppStateService.files or IndexedDB, so tagging an already-loaded log from the Drive panel left the loaded copy untagged until a reload -- silently keeping the default channel sets. addTag now emits DRIVE_TAG_ADDED once the write lands and AppStateService applies it to any loaded file of that name. The handler deliberately does not re-emit FILE_TAG_ADDED, which is what keeps the chart->Drive->state round trip from echoing.
Both tag entry points were a bare window.prompt, so a near-miss like '2.0 gme' was accepted, stored, synced to Drive and permanent -- while silently changing which channel sets the log gets. Nothing anywhere could remove a tag, which was survivable while tags were decoration and is not now that they gate behavior. Replace both prompts with an inline TagInput component: a native datalist of the tags already in use (DriveService.knownTags -- the listing's tags, the loaded files' tags, and the registered vehicle tags), Enter/Escape handling, and a preview of the spelling that will actually be stored. Normalization moves into the services so no caller has to remember it: canonicalTag() normalizes and snaps a variant of a registered vehicle tag onto its registered spelling, and AppStateService.addFileTag/DriveService .addTag both run through it. normalizeTag() also drops commas, which used to split one tag into two on the next Drive load since appProperties stores them comma-joined. Add the removal path as the mirror of the add path: removeFileTag/removeTag, FILE_TAG_REMOVED/DRIVE_TAG_REMOVED to sync the two sides, and an x on every pill in both views. Removal matches the stored spelling exactly rather than canonicalizing, since a tag seeded from Drive was never normalized on the way in. Clearing the last tag sends appProperties.tags = null so the key is deleted rather than left as an empty string. knownTags is deliberately separate from availableTags: the filter dropdown stays listing-derived, since offering a tag no listed file carries would just empty the list. Also dedupes the two byte-identical copies of legacy's _getTagStyle into tags.util.ts.
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.
No description provided.