Skip to content

Add network output highlighting (Generic, Cisco IOS, Junos, Huawei VRP) - #1345

Open
carlosjaribeiro wants to merge 2 commits into
mfat:devfrom
carlosjaribeiro:submit/highlight-base
Open

carlosjaribeiro wants to merge 2 commits into
mfat:devfrom
carlosjaribeiro:submit/highlight-base

Conversation

@carlosjaribeiro

Copy link
Copy Markdown

Summary

Adds opt-in, colour-only highlighting of network-device output in the terminal (IPs, prefixes, MACs, VLANs, interfaces, link state, error lines), as discussed in #1265. Built-in profiles: Generic, Cisco IOS, Junos and Huawei VRP.

  • It sits on the daemon-fed terminal output path, in front of the terminal widget, so it works with every terminal backend. It only adds SGR foreground colours; the visible text and the bytes the terminal sees are otherwise unchanged.
  • Remote styling is respected: highlighting is suspended while the remote application sets foreground/background colour, reverse or concealed text, or while the alternate screen is active (vim, less, htop). Incomplete escape sequences split across chunks are carried over, and the parser state is reset on reconnect.
  • Disabled by default. Settings → Terminal → Highlighting has an on/off switch and a profile selector; changes apply to new output without reopening the tab. Both settings are in the settings search index.
  • Docs: docs/highlighting.md, linked from docs/README.md.
  • Translations: the new msgids are added to the eight catalogs and the .mo files are regenerated with msgfmt --check, as docs/development/localization.md describes (new entries are untranslated).

Closes #1265

Design notes

  • The implementation lives in one self-contained module (terminal_highlight.py, pure Python, no gi import) plus a small hook in terminal.py. The hook is a no-op when the feature is off.
  • Rules are plain regexes compiled per profile.
  • Colours use the 16-colour palette, so they follow the active terminal theme.

API and architecture

  • Not applicable: this change does not affect the frontend-neutral API or core/frontend ownership boundary (terminal colouring is frontend rendering; only terminal.* default settings are added)
  • Public DTOs or client methods were updated
  • Capabilities were updated and only implemented support is advertised
  • Events and structured errors were updated
  • State, ordering, threading, cancellation, and security semantics were reviewed
  • Contract tests were updated
  • API documentation was updated
  • docs/api/CHANGELOG.md was updated
  • Compatibility and protocol-version impact were reviewed
  • Generated API artifacts and the public-surface snapshot were deliberately refreshed

No API artifacts change; scripts/generate_api_artifacts.py --check confirms they are current.

Testing

  • ruff check src/ tests/ scripts/generate_api_artifacts.py (Ruff 0.15.17): passed
  • python scripts/generate_api_artifacts.py --check: passed
  • pytest -q tests/api tests/architecture tests/test_terminal_highlight.py: 1,197 passed
  • pytest -ra (full suite): 9,847 passed, 131 skipped, 6 xfailed, 1 xpassed, 5 failed. Pristine upstream/dev has the same five failures here (unavailable msgfmt, libvterm ABI guard, inode-replacement and daemon-socket race checks).
  • The PO/MO consistency block from .github/workflows/lint.yml: passed for all eight catalogs.
  • Manual: I have used this highlighting on Windows 11 in SSH sessions to a real Cisco IOS switch (show running-config, show logging), and opened the Preferences controls under WSLg. That was done with a downstream build that contains this code plus additional profiles, not with this exact branch alone.

Not run: opt-in integration, GUI, E2E, stress and property suites; the Windows and macOS CI jobs; real-GTK tests. The Junos and Huawei VRP profiles are built from vendor documentation and sample output and have not been checked against real devices. Not tested on macOS.

Known limitations

  • Matching is heuristic, so false positives and misses are possible.
  • A token split across two output chunks is only coloured from the chunk boundary onward.
  • Colours depend on the terminal theme.
  • The new Preferences rows are covered at the component level, not by an end-to-end GTK test.

If you would like a different scope, settings layout or profile set, I am happy to adjust.

This branch has not been deployed

No deployments
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