Skip to content

Conversation

@swarna1101
Copy link
Collaborator

@swarna1101 swarna1101 commented Jan 16, 2026

Summary by CodeRabbit

  • New Features

    • Network health dashboard: text-based overview showing status and metrics for proxies and nodes (CPU, memory, disk, availability), printed to stdout.
    • Supports local and remote monitoring modes with configurable endpoints and optional proxy/node base settings.
  • Chores

    • Dashboard binary is built, cleaned, ignored, and included in standard build targets so it's produced with other client artifacts.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Adds a text-based network dashboard tool and integrates it into the Makefile/build (new dashboard binary and dashboard target); introduces a Go CLI at tools/network-dashboard/main.go that fetches proxy/node health/state/countries and prints a formatted dashboard; updates .gitignore and clean/phony targets.

Changes

Cohort / File(s) Summary
Build integration
Makefile
Add DASHBOARD_BINARY variable and $(DASHBOARD_BINARY) target; include dashboard binary in build and clean; add dashboard phony target with mode/parsing logic; update PHONY list. Review Makefile target logic and argument handling.
Dashboard CLI
tools/network-dashboard/main.go
Add new CLI program implementing types (NodeHealth, NodeState, ProxyHealth, NodeCountries, NodeInfo, ProxyInfo), HTTP fetch helpers, fetchers for /health, /state, /countries, flag parsing (-proxies, -nodes, -proxy-base, -node-base, -local), and text renderer. Inspect HTTP timeouts, error propagation into item fields, and output formatting.
Ignore artifacts
.gitignore
Ignore tools/network-dashboard/network-dashboard binary. Verify ignore path matches produced artifact location.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI/Main
    participant Parser as Flag Parser
    participant ProxyFetcher as Proxy Fetcher
    participant NodeFetcher as Node Fetcher
    participant ProxyEndpoint as Proxy REST Endpoint
    participant NodeEndpoint as Node REST Endpoint
    participant Renderer as Dashboard Renderer
    participant Stdout as Output

    CLI->>Parser: Parse flags (-local, -proxy-base, -node-base, -proxies, -nodes)
    Parser-->>CLI: Assembled proxy & node URLs
    CLI->>ProxyFetcher: For each proxy URL, fetch /health
    ProxyFetcher->>ProxyEndpoint: GET /health
    ProxyEndpoint-->>ProxyFetcher: ProxyHealth JSON or error
    ProxyFetcher-->>CLI: ProxyInfo (populated or error)
    CLI->>NodeFetcher: For each node URL, fetch /health and /state
    NodeFetcher->>NodeEndpoint: GET /health and GET /state
    NodeEndpoint-->>NodeFetcher: NodeHealth & NodeState JSON or error
    NodeFetcher-->>CLI: NodeInfo (populated or error)
    alt Proxies Available
        CLI->>NodeFetcher: Request /countries from proxies to enrich nodes
        NodeFetcher->>ProxyEndpoint: GET /countries
        ProxyEndpoint-->>NodeFetcher: NodeCountries JSON or error
        NodeFetcher-->>CLI: Country data
    end
    CLI->>Renderer: Provide collected ProxyInfo and NodeInfo
    Renderer->>Stdout: Write formatted text dashboard
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I'm a rabbit with a dashboard bright,
Hopping through nodes by lantern light,
Proxies and health in tidy rows,
I fetch, I print—see how it glows! 🐇📡

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat: add network health dashboard' directly and clearly summarizes the main change: introducing a new network health dashboard feature across multiple files (Makefile, main.go, .gitignore).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/network-dashboard

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


Comment @coderabbitai help to get the list of available commands and usage tips.

@swarna1101
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 Fix all issues with AI agents
In `@Makefile`:
- Line 15: The .PHONY line currently lists $(P2P_CLIENT), $(PROXY_CLIENT),
$(KEYGEN_BINARY), and $(DASHBOARD_BINARY) which are actual binary output files
and should not be phony; remove those variables from the .PHONY declaration and
only keep truly phony targets (e.g., setup-scripts) so Make can use
timestamp-based rebuild logic for the binaries (look for the .PHONY declaration
and the variables P2P_CLIENT, PROXY_CLIENT, KEYGEN_BINARY, DASHBOARD_BINARY to
update).
- Around line 125-142: The dashboard target currently exits with code 1 on
invalid mode or missing proxy/node URLs but prints nothing; update the dashboard
recipe to emit clear stderr messages before exiting: when mode is neither
empty/"local" nor "remote" print an "invalid mode" error referencing mode, and
in the "remote" branch when args is empty print a descriptive error that
proxy-base/node-base are required (use the existing variables mode, proxy_base,
node_base, args and the $(DASHBOARD_BINARY) invocation), then exit with code 1
as before.

In `@tools/network-dashboard/main.go`:
- Around line 250-255: The port arrays used when *proxyBase and *nodeBase are
non-empty do not match the flag help text: update the ports slices so proxy
ports append :8081 and :8082 (instead of only :8080) and node ports append
:9091,:9092,:9093,:9094 (instead of a single :8081), then build URLs and call
fetchProxyInfo/fetchNodeInfo as before; specifically modify the ports variable
in the proxy block (where proxies = append(proxies, fetchProxyInfo(...))) and
the ports variable in the node block (where nodes = append(nodes,
fetchNodeInfo(...))) to match the documented port lists.
- Around line 241-282: The current loops call fetchProxyInfo and fetchNodeInfo
sequentially causing slow startup; change to concurrent fetching by launching
goroutines that call fetchProxyInfo/fetchNodeInfo, use a sync.WaitGroup to wait
for all goroutines, and send results into buffered channels (one for proxies,
one for nodes) sized to the number of endpoints, then close channels and drain
them into the proxies and nodes slices; apply this pattern in the blocks that
build proxies (the branches using local, proxyBase, proxyURLs) and nodes
(nodeBase, nodeURLs) and ensure you trim/skip empty URLs and preserve any naming
logic (fmt.Sprintf("proxy-%d", ...), fmt.Sprintf("p2pnode-%d", ...)).
- Around line 241-249: The local slices named proxyURLs and nodeURLs in main
shadow the flag pointer variables of the same names; rename the local slice
variables (for example to proxyAddrs or proxyURLsLocal and nodeAddrs or
nodeURLsLocal) and update their for-loops that call fetchProxyInfo and
fetchNodeInfo to use the new names so you no longer shadow the flag pointer
variables.
- Around line 221-226: Remove the custom min function implementation (func
min(a, b int) int) and replace its usages with the Go 1.21 builtin min; locate
the custom function named "min" and any call sites (e.g., the call that
currently invokes min) and update them to use the builtin min(a, b) instead,
then delete the redundant function definition to avoid shadowing the standard
builtin.
📜 Review details

Configuration used: Repository: getoptimum/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da89587 and 3d1135a.

⛔ Files ignored due to path filters (2)
  • .gitignore is excluded by !.gitignore and included by **.gitignore
  • tools/network-dashboard/go.mod is excluded by none and included by none
📒 Files selected for processing (2)
  • Makefile
  • tools/network-dashboard/main.go
🧰 Additional context used
📓 Path-based instructions (3)
**/*

⚙️ CodeRabbit configuration file

**/*: When you find the same underlying issue in multiple locations (same pattern, same fix):

  • Do NOT post separate comments for each occurrence.
  • Post a single primary comment on the first occurrence.
  • In that comment, include a short list of “Also at: file:line” references
    for the other locations (e.g. 'Also at: foo.go:42, bar.go:17').
    Prioritize signal over volume: one strong comment that references multiple
    locations is preferred over many near-identical comments.

Files:

  • Makefile
  • tools/network-dashboard/main.go
Makefile*

⚙️ CodeRabbit configuration file

  • Provide phony targets; stable reproducible builds; avoid environment-specific paths.

Files:

  • Makefile
**/*.go

📄 CodeRabbit inference engine (Custom checks)

**/*.go: Watch for goroutine leaks, unbounded channels, and racy access; ensure contexts are plumbed and respected
If code changes affect Go packages, verify that tests cover changed logic; flag risky changes lacking tests

Files:

  • tools/network-dashboard/main.go

⚙️ CodeRabbit configuration file

Review Go code for: idiomatic patterns, error handling (check all errors), concurrency safety (context propagation, goroutine cleanup), test coverage for changed logic, exported API stability, memory efficiency (avoid unnecessary allocations), and prefer standard library over third-party when reasonable.

Files:

  • tools/network-dashboard/main.go
🪛 checkmake (0.2.2)
Makefile

[warning] 125-125: Target body for "dashboard" exceeds allowed length of 5 (17).

(maxbodylength)


[warning] 152-152: Missing required phony target "all"

(minphony)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test Docker Setup
🔇 Additional comments (7)
Makefile (3)

28-30: LGTM!

Build target is correctly structured, consistent with other binary targets in the Makefile.


48-48: LGTM!

Dashboard binary correctly added to the build target dependencies.


145-145: LGTM!

Clean target properly updated to remove the new dashboard binary.

tools/network-dashboard/main.go (4)

65-83: LGTM!

fetchJSON correctly uses a timeout, checks HTTP status, and handles errors. The 5-second timeout is reasonable for a CLI dashboard tool.


14-63: LGTM!

Type definitions are clean with appropriate JSON tags. Using pointers for Health and State in NodeInfo/ProxyInfo correctly signals optional data.


120-219: LGTM!

printDashboard handles nil/unavailable cases gracefully and produces well-formatted output. The peer truncation logic (showing first 5 with a "...and N more" message) is a nice touch.


284-288: LGTM!

Good input validation with clear error message and usage hint when no endpoints are configured.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@tools/network-dashboard/main.go`:
- Around line 206-208: The loop over the map countryCount is non-deterministic;
to make output stable, collect the map keys into a slice (e.g., countries), sort
them with sort.Strings, and then iterate over the sorted slice to print
fmt.Printf("%s: %d node(s)\n", country, countryCount[country]); update the
for-range block that currently iterates directly over countryCount to use this
sorted-key approach and import "sort" if not already present.
- Around line 248-249: The loop is appending each proxy twice by calling proxies
= append(proxies, fetchProxyInfo(fmt.Sprintf("proxy-%d", i+1), url)) two times;
fix it by removing the duplicate append so each iteration only calls
fetchProxyInfo once (update the code that populates the proxies slice where
fetchProxyInfo and fmt.Sprintf("proxy-%d", i+1) are used to ensure a single
append per proxy).
- Around line 59-61: fetchJSON currently creates a new http.Client per call
which prevents connection reuse; refactor to use a shared client by moving the
client creation out of fetchJSON (either declare a package-level variable like
var httpClient = &http.Client{Timeout: 5 * time.Second} or accept an
*http.Client parameter) and update fetchJSON to use that shared client
(referencing fetchJSON and the http.Client instance) so requests can reuse
connections and improve performance.
♻️ Duplicate comments (3)
tools/network-dashboard/main.go (3)

215-220: Remove redundant min function—Go 1.21 builtin exists.

This was flagged in a previous review. The custom implementation shadows the builtin and should be deleted.


236-243: Variable shadowing issue remains unaddressed.

Local slices proxyURLs and nodeURLs shadow the flag pointer variables declared at lines 224-225. Rename to localProxyURLs/localNodeURLs as suggested in the previous review.


244-267: Port configuration still inconsistent with flag documentation.

Previously flagged: -proxy-base help says :8081,:8082 but code uses :8080. -node-base help says :9091,:9092,:9093,:9094 but code uses :8081. Either fix the ports or update the documentation.

📜 Review details

Configuration used: Repository: getoptimum/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d1135a and 583cb91.

📒 Files selected for processing (1)
  • tools/network-dashboard/main.go
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (Custom checks)

**/*.go: Watch for goroutine leaks, unbounded channels, and racy access; ensure contexts are plumbed and respected
If code changes affect Go packages, verify that tests cover changed logic; flag risky changes lacking tests

Files:

  • tools/network-dashboard/main.go

⚙️ CodeRabbit configuration file

Review Go code for: idiomatic patterns, error handling (check all errors), concurrency safety (context propagation, goroutine cleanup), test coverage for changed logic, exported API stability, memory efficiency (avoid unnecessary allocations), and prefer standard library over third-party when reasonable.

Files:

  • tools/network-dashboard/main.go
**/*

⚙️ CodeRabbit configuration file

**/*: When you find the same underlying issue in multiple locations (same pattern, same fix):

  • Do NOT post separate comments for each occurrence.
  • Post a single primary comment on the first occurrence.
  • In that comment, include a short list of “Also at: file:line” references
    for the other locations (e.g. 'Also at: foo.go:42, bar.go:17').
    Prioritize signal over volume: one strong comment that references multiple
    locations is preferred over many near-identical comments.

Files:

  • tools/network-dashboard/main.go
🔇 Additional comments (3)
tools/network-dashboard/main.go (3)

1-57: LGTM on imports and type definitions.

Clean structure using only standard library. The types are well-organized with appropriate JSON tags for serialization.


79-112: LGTM on fetch functions.

Error handling is correct—Available remains false on failure, and errors are captured for display. The two-step fetch in fetchNodeInfo appropriately short-circuits on first failure.


285-291: LGTM on optional country enrichment.

Using only the first available proxy for node countries is a reasonable simplification. Silent error handling is acceptable here since this data is supplementary.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@tools/network-dashboard/main.go`:
- Around line 292-298: The code only attempts node-countries lookup using
proxies[0] which skips country data if that proxy is down; update the logic
around nodeCountries, proxies and fetchJSON to iterate over the proxies slice,
pick the first proxy with Available==true, and attempt
fetchJSON(proxy.URL+"/api/v1/node-countries", nc) until a fetch succeeds (set
nodeCountries = nc) or all available proxies fail; ensure you reference the
proxies slice, the Available field, the fetchJSON function and the nodeCountries
variable when making the change so the first healthy proxy that returns valid
JSON is used.
- Around line 216-301: Add unit tests covering fetchJSON, fetchNodeInfo,
fetchProxyInfo, and printDashboard: create table-driven tests that use httptest
servers to return valid JSON, malformed JSON, HTTP errors, and delayed responses
to simulate timeouts (for fetchJSON and the fetch* functions), assert returned
structs and error handling, and verify that fetchProxyInfo/fetchNodeInfo
correctly set fields like URL and Available; for printDashboard, capture
stdout/stderr using a bytes.Buffer and assert output contains expected headers,
node/proxy entries, and handles empty nodeCountries or empty node/proxy slices.
Use subtests for each edge case and ensure tests cleanly shut down servers and
restore any global state/timeouts.
♻️ Duplicate comments (2)
tools/network-dashboard/main.go (2)

203-209: Make country output deterministic.

Map iteration order is non-deterministic; sort keys before printing for stable output.


229-283: Avoid sequential network fetches for proxies and nodes.

Current loops block per endpoint; concurrent fetches would reduce total wait time.

📜 Review details

Configuration used: Repository: getoptimum/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 583cb91 and b5488e7.

⛔ Files ignored due to path filters (3)
  • grpc_p2p_client/go.mod is excluded by none and included by none
  • grpc_proxy_client/go.mod is excluded by none and included by none
  • keygen/go.mod is excluded by none and included by none
📒 Files selected for processing (1)
  • tools/network-dashboard/main.go
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (Custom checks)

**/*.go: Watch for goroutine leaks, unbounded channels, and racy access; ensure contexts are plumbed and respected
If code changes affect Go packages, verify that tests cover changed logic; flag risky changes lacking tests

Files:

  • tools/network-dashboard/main.go

⚙️ CodeRabbit configuration file

Review Go code for: idiomatic patterns, error handling (check all errors), concurrency safety (context propagation, goroutine cleanup), test coverage for changed logic, exported API stability, memory efficiency (avoid unnecessary allocations), and prefer standard library over third-party when reasonable.

Files:

  • tools/network-dashboard/main.go
**/*

⚙️ CodeRabbit configuration file

**/*: When you find the same underlying issue in multiple locations (same pattern, same fix):

  • Do NOT post separate comments for each occurrence.
  • Post a single primary comment on the first occurrence.
  • In that comment, include a short list of “Also at: file:line” references
    for the other locations (e.g. 'Also at: foo.go:42, bar.go:17').
    Prioritize signal over volume: one strong comment that references multiple
    locations is preferred over many near-identical comments.

Files:

  • tools/network-dashboard/main.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test Docker Setup

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@swarna1101 swarna1101 linked an issue Jan 20, 2026 that may be closed by this pull request
hpsing
hpsing previously approved these changes Jan 30, 2026
@swarna1101 swarna1101 merged commit d360fbe into main Jan 30, 2026
6 checks passed
@swarna1101 swarna1101 deleted the feature/network-dashboard branch January 30, 2026 12:18
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.

Network health dashboard script (CLI tool)

3 participants