Skip to content

feat: add opt-in proxychains-style terminal chain visual#7

Merged
P4X-ng merged 5 commits intomainfrom
copilot/review-end-to-end-flow
Mar 20, 2026
Merged

feat: add opt-in proxychains-style terminal chain visual#7
P4X-ng merged 5 commits intomainfrom
copilot/review-end-to-end-flow

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

Adds a terminal-friendly ASCII chain visualization inspired by classic proxychains output. Disabled by default (logging.chain_visual: false) so it doesn't pollute JSON log pipelines.

What it looks like

# Startup — topology only, probes not yet run:
[egressd] |S-chain|-<>-proxy1:3128-<>-proxy2:3128-<>-...

# After hop probes — all healthy:
[egressd] |S-chain|-<>-proxy1:3128-<>-proxy2:3128-<>-OK
[egressd]   hop_0: proxy1:3128                 OK   42ms
[egressd]   hop_1: proxy2:3128                 OK   38ms

# Hop down:
[egressd] |S-chain|-<>-proxy1:3128-XX-proxy2:3128-<>-FAIL
[egressd]   hop_0: proxy1:3128                 OK   42ms
[egressd]   hop_1: proxy2:3128                 FAIL Connection refused

Written to stderr so it stays separate from structured stdout logs.

Changes

  • egressd/supervisor.py

    • _extract_hop_label(hop) — parses host:port from a hop config dict
    • _all_hops_ok(hops, statuses) — shared predicate used in both the visual and hop_health_loop
    • format_chain_visual(cfg, hop_statuses) — pure function returning the ASCII string
    • print_chain_visual(cfg, hop_statuses) — gate on logging.chain_visual, writes to stderr
    • hop_health_loop — calls print_chain_visual on first run and whenever overall-ok state flips
    • main — prints topology visual immediately after config loads (before first probe)
  • egressd/config.json5 / egressd/config.host.example.json5logging.chain_visual: false with comment

  • tests/test_supervisor.py — 9 new tests covering topology-only, all-ok, partial failure, single-hop, empty chain, and print_chain_visual enable/disable

  • README.md — new Chain visual section with example output

Original prompt

This section details on the original issue you should resolve

<issue_title>Human-like review</issue_title>
<issue_description>Hey there @cursoragent if you could please provide a reeview of the end to end flow here, assuming a base ubuntu 24.04 with no special dependencies pre-installed, go through flow from start to end and ensure everything "just works" for the user. Let's also see if we can include a nice little terminal-friendly old-school proxychains visual that the user can turn on if they'd like that shows the whole thing passing through each proxy :).</issue_description>

Comments on the Issue (you are @copilot in this section)

@P4X-ng @cursor

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.


Note

Low Risk
Low risk: adds an opt-in stderr-only chain visualization gated by logging.chain_visual, with limited new logic in the hop health loop and coverage via unit tests.

Overview
Adds an opt-in proxychains-style ASCII chain visualization (logging.chain_visual) that prints the configured hop topology at startup and reprints whenever overall hop health flips, writing to stderr to avoid polluting JSON stdout logs.

Updates sample configs to include chain_visual: false, documents the feature and example output in the README, and adds unit tests covering formatting and the enable/disable behavior.

Written by Cursor Bugbot for commit 9c7d1ae. Configure here.

- Add format_chain_visual() and print_chain_visual() to supervisor.py
- Extract _extract_hop_label() and _all_hops_ok() helpers to avoid duplication
- Call visual at startup (topology) and on hop health state changes in hop_health_loop
- Add logging.chain_visual: false option to both config files
- Add 9 new tests in tests/test_supervisor.py (81 total, all pass)
- Document chain_visual option with example output in README.md

Co-authored-by: P4X-ng <223870169+P4X-ng@users.noreply.github.com>
Copilot AI changed the title [WIP] Review end to end flow for Ubuntu 24.04 feat: add opt-in proxychains-style terminal chain visual Mar 19, 2026
Copilot AI requested a review from P4X-ng March 19, 2026 19:16
@P4X-ng P4X-ng requested a review from Copilot March 20, 2026 07:56
@P4X-ng
Copy link
Contributor

P4X-ng commented Mar 20, 2026

/gemini review

@codex review or bitch about your environment

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a well-implemented and useful feature: an optional, proxychains-style terminal visualization for the hop chain. The changes are comprehensive, including updates to documentation, configuration, core logic, and thorough testing. The code is clean, robust, and the feature is disabled by default to avoid impacting existing log pipelines. I have one minor suggestion to improve the robustness of the visual output formatting.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in, terminal-friendly “proxychains-style” ASCII visualization of the configured proxy chain and hop health, intended to be printed to stderr to avoid polluting structured stdout logs.

Changes:

  • Implemented chain visual formatting + gated stderr printing, and integrated it into startup and hop health monitoring.
  • Added logging.chain_visual: false to example configs (disabled by default).
  • Added unit tests and README documentation for the new visual output.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
egressd/supervisor.py Adds chain visual formatting/printing functions and hooks them into main and hop_health_loop.
egressd/config.json5 Documents and defaults logging.chain_visual to false.
egressd/config.host.example.json5 Documents and defaults logging.chain_visual to false.
tests/test_supervisor.py Adds tests for topology-only and health-status chain visuals, plus stderr gating.
README.md Adds a “Chain visual” section explaining usage and showing example output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +147 to +156
def _capture_stderr(self, fn, *args, **kwargs) -> str:
"""Call *fn* with redirected stderr and return whatever was written."""
buf = io.StringIO()
old_stderr = sys.stderr
try:
sys.stderr = buf
fn(*args, **kwargs)
finally:
sys.stderr = old_stderr
return buf.getvalue()
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_capture_stderr reassigns the global sys.stderr, which can interfere with other tests if the suite is ever run in parallel. Consider using the standard library helper (contextlib.redirect_stderr) for the same behavior with clearer intent, and keep the redirected scope as small as possible.

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ea7ee57be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +518 to +522
if parsed.hostname and parsed.port:
return f"{parsed.hostname}:{parsed.port}"
except (ValueError, AttributeError):
pass
return raw_url

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Sanitize hop labels before falling back to raw URL

_extract_hop_label falls back to raw_url when the parsed URL has no explicit port, so a hop like http://user:pass@proxy will be printed with embedded credentials when chain visual output is enabled. Because preflight allows hop URLs without ports, this path is reachable in production configs and leaks secrets to stderr/log capture. Strip userinfo and derive a default port instead of returning the original URL.

Useful? React with 👍 / 👎.

Comment on lines +603 to +605
current_ok = _all_hops_ok(hops, statuses)
if first_run or current_ok != last_overall_ok:
print_chain_visual(cfg, statuses)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Trigger chain visual on any hop-status change

hop_health_loop only reprints when the aggregate _all_hops_ok(...) boolean flips, so per-hop transitions are suppressed whenever overall state stays unhealthy (for example, one failed hop is replaced by a different failed hop). This leaves operators with stale chain diagnostics despite real hop changes. Track and compare per-hop status (or an ok tuple) rather than a single aggregate flag before deciding to print.

Useful? React with 👍 / 👎.

P4X-ng and others added 3 commits March 20, 2026 05:15
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@P4X-ng P4X-ng marked this pull request as ready for review March 20, 2026 09:16
@P4X-ng P4X-ng merged commit b5e6e20 into main Mar 20, 2026
3 of 5 checks passed
@P4X-ng P4X-ng deleted the copilot/review-end-to-end-flow branch March 20, 2026 09:16
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.

Human-like review

3 participants