Add Phoenix LiveDashboard on a separate port#4119
Conversation
Serve the dashboard on a dedicated Bandit instance configured via ELECTRIC_LIVE_DASHBOARD_PORT to avoid interfering with the existing Plug-based HTTP API. When the env var is unset the dashboard is not started. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
They tend to not load at all and the graph layout is barely informative
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 673bd848d0
ℹ️ 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".
Claude Code ReviewSummaryThis PR adds an opt-in Phoenix LiveDashboard on a dedicated Bandit instance. Good progress since the first review — most issues were addressed. Two concerns remain: the default all-interfaces bind address and a config-access pattern inconsistency. What's Working Well
Issues FoundCritical (Must Fix)None remaining. Important (Should Fix)1. Dashboard still binds to File: dashboard_ip =
if env!("ELECTRIC_LISTEN_ON_IPV6", :boolean, false),
do: {0, 0, 0, 0, 0, 0, 0, 0},
else: {0, 0, 0, 0}With zero authentication, binding to all interfaces is the most common way operators accidentally expose this endpoint. Container port-forwarding, misconfigured firewall rules, and cloud security group defaults can all leave this reachable from the public internet. Suggested fix — default to localhost; let operators opt in to a wider bind if needed: dashboard_ip =
case env!("ELECTRIC_LIVE_DASHBOARD_IP", :string, "127.0.0.1") do
"::0" -> {0, 0, 0, 0, 0, 0, 0, 0}
"0.0.0.0" -> {0, 0, 0, 0}
_ -> {127, 0, 0, 1}
endOr, simpler — just use 2. Inconsistent config access pattern File: # New code (line 57):
live_dashboard_endpoint(Application.get_env(:electric, :live_dashboard_port))
# Established pattern one line above (line 56):
prometheus_endpoint(Electric.Config.get_env(:prometheus_port))This was raised in the first review and hasn't been addressed. live_dashboard_endpoint(Electric.Config.get_env(:live_dashboard_port))Suggestions (Nice to Have)Session invalidation on restart — worth a comment File: secret_key_base: Base.encode64(:crypto.strong_rand_bytes(48)),This is the right default for a dev tool, but operators running Electric behind a load balancer with multiple instances will find that dashboard sessions are invalidated across restarts and not portable between nodes. A short comment here would help: # Random per-startup key: sessions don't survive restarts and aren't
# shared across nodes. Acceptable for a dev/ops tool; if you need
# stable sessions, replace with an operator-supplied env var.
secret_key_base: Base.encode64(:crypto.strong_rand_bytes(48)),Issue ConformanceNo linked issue — unchanged from previous review. The PR description is clear and the README section adequately documents the feature for operators. Previous Review Status
The one remaining Important issue (default bind address) and the unaddressed config pattern inconsistency are both straightforward to fix. Otherwise this is close to merge-ready. Review iteration: 2 | 2026-04-13 |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
- Respect ELECTRIC_LISTEN_ON_IPV6 when binding the dashboard socket - Make FaviconController a proper Phoenix controller - Add unauthenticated-endpoint warnings in moduledoc, config, and README Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
magnetised
left a comment
There was a problem hiding this comment.
Looks good, this will be very useful so thanks for adding. I don't like all the new top-level modules, especially for an optional component, could we move under the Electric.LiveDashboard namespace?
Addresses review feedback to avoid polluting the top-level namespace with an optional component. Also uses Electric.Config.get_env for consistency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@magnetised Good suggestions! Thanks for taking the time to propose code changes. All have been accepted. |
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Summary
ELECTRIC_LIVE_DASHBOARD_PORTTest plan
ELECTRIC_LIVE_DASHBOARD_PORT=4000and verify dashboard loads athttp://localhost:4000ELECTRIC_PORTis unaffected🤖 Generated with Claude Code