Fix #958: highlight IPv6 + allow editing built-in keyword rules#962
Merged
Conversation
Two changes addressing both halves of #958: 1. IPv6 highlighting The built-in 'URL, IP & MAC' rule only shipped URL, IPv4 and MAC patterns, so compressed IPv6 addresses such as 2001:11:22:33::5 or fe80::d2dd:bff:fe79:f2bb were never highlighted. Add an IPv6 regex covering full and compressed forms (including ::1 and leading-/trailing- :: variants) and merge it into the same 'ip-mac' rule's patterns. The normalizer's existing "fill missing defaults" path means existing users pick this up on next start with no migration step. 2. Editable built-in rules Add an optional `customized` flag to KeywordHighlightRule. When false / absent, normalize re-syncs the rule's label/patterns with the shipped defaults (so future default-pattern upgrades reach users automatically). When true, normalize keeps the user's label/patterns/color/enabled verbatim, allowing built-ins like 'ip-mac' to be tailored. SettingsTerminalTab: - Pencil icon now appears on built-ins too. Editing one routes through the same dialog and flips `customized` on save. - The pattern field becomes a Textarea so multi-pattern built-ins (e.g. 'error' ships seven spellings) can all be edited in one go. - A per-rule "↺" reset icon appears on customized built-ins and restores the shipped label/patterns while preserving the user's color/enabled. - The footer's "Reset to default colors" button is broadened into "Reset built-ins to defaults", restoring every built-in to shipped label/patterns/color and clearing `customized`. Tests: New domain/keywordHighlight.test.ts (6 tests) covers IPv6 matches for both #958 examples plus loopback and full-form, IPv4/MAC still match, normalize migrates legacy non-customized 'ip-mac' to include IPv6, normalize preserves customized patterns, and normalize keeps user custom rules verbatim. Full suite: 808/0/3. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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
Closes both halves of #958 in a single PR:
2001:11:22:33::5andfe80::d2dd:bff:fe79:f2bb) were never highlighted.Changes
1. IPv6 regex
Added
IPV6_HIGHLIGHT_PATTERNin domain/models.ts and merged it into the existing'ip-mac'default rule's patterns array (per the issue follow-up: "fold it into the existing rule"). Covers:2001:0db8:85a3:0000:0000:8a2e:0370:73342001:11:22:33::5(issue example 1)fe80::d2dd:bff:fe79:f2bb(issue example 2)::1::at the head / middle / tailOut of scope for this first pass (intentionally omitted, can become a follow-up issue): zone IDs (
%eth0suffix) and IPv4-mapped (::ffff:192.0.2.1). The carve-out is documented in the constant's comment.No migration step needed for existing users: the existing "fill in missing default rules" logic in
normalizeKeywordHighlightRules, combined with thecustomizedchange below, automatically refreshes the patterns of anyip-macrule the user has not customized.2. Editable built-in rules
Added an optional
customized?: booleantoKeywordHighlightRule:customizedunset / false (the default state): normalize overwrites with the latest default patterns/label (while preserving the user's color/enabled). This means any future pattern upgrade we ship (like IPv6 in this PR) automatically reaches every user who hasn't customized.customizedset to true: normalize keeps the user's label/patterns/color/enabled exactly as saved.Corresponding UI changes in SettingsTerminalTab.tsx:
AddCustomRuleDialog.InputtoTextarea, one regex per line. Built-ins like'error'(which ships seven patterns) can now be viewed and edited in one go.customizedto true.Tests
New
domain/keywordHighlight.test.ts— 6 tests:ip-macrule (without IPv6) up to the new defaultscustomized: truenpx tsc --noEmitis clean on the changed files (other pre-existing repo-wide TS errors are unrelated to this PR).Test plan
2001:11:22:33::5andfe80::d2dd:bff:fe79:f2bb, confirm both are highlighted🤖 Generated with Claude Code