Skip to content

feat(cli): improve init flow with better UX#942

Merged
scarmuega merged 3 commits intomainfrom
feat/improve-init
Mar 12, 2026
Merged

feat(cli): improve init flow with better UX#942
scarmuega merged 3 commits intomainfrom
feat/improve-init

Conversation

@scarmuega
Copy link
Member

@scarmuega scarmuega commented Mar 12, 2026

Summary by CodeRabbit

  • New Features

    • Init banner now shows app version and Git commit SHA and is printed at startup.
    • Setup flow consolidated into a single multi-select for enabling APIs and a streamlined remote-peer selection with presets and custom option.
  • Dependencies

    • Updated interactive prompt library to a newer release.
    • Added a build-time metadata generator to embed Git information into builds.
  • Chores

    • Removed multiple outdated v1 example configuration files.

@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 18926883-ee6b-4e8d-9803-fbb69ab21f12

📥 Commits

Reviewing files that changed from the base of the PR and between 2c28385 and dd029b7.

📒 Files selected for processing (1)
  • src/bin/dolos/init.rs

📝 Walkthrough

Walkthrough

Updates deps (inquire → 0.9.4; adds vergen-gitcl build-dep), adds a build script emitting Git SHA, prints an init banner using VERGEN_GIT_SHA, refactors CLI init to unify API selection and remote-peer presets, and removes multiple example/config files.

Changes

Cohort / File(s) Summary
Dependency Management
Cargo.toml
Bumped inquire 0.7.5 → 0.9.4; added [build-dependencies] vergen-gitcl = "9.1.0".
Build Infrastructure
build.rs, Cargo.toml
Added build.rs using vergen_gitcl::{GitclBuilder, Emitter} to emit Git metadata (e.g., VERGEN_GIT_SHA) at compile time.
Banner Feature
src/bin/dolos/banner.rs, src/bin/dolos/main.rs
Added pub fn print_init_banner() that prints ASCII art plus version and Git SHA (reads VERGEN_GIT_SHA); integrated mod banner into main.
Initialization Refactor
src/bin/dolos/init.rs
Introduced AvailableApi, RemotePeerPreset, RemotePeerChoice, KnownNetwork helper methods, unified API selection via MultiSelect, preset/Other remote-peer flow, and prints banner at startup; replaces per-service prompts with a consolidated flow.
Formatting-only
crates/fjall/src/index/mod.rs
Reflowed arguments in slots_by_tag calls (formatting only).
Examples/Configs Removed
examples/v1/...
alonzo.json, byron.json, conway.json, shelley.json, dolos.toml
Removed multiple static example/configuration files (protocol params, network configs, and Dolos TOML).

Sequence Diagram(s)

mermaid
sequenceDiagram
participant User as User
participant CLI as Dolos CLI
participant Prompts as Prompt Flow
participant Peer as Remote Peer Presets
participant Config as Config Writer

User->>CLI: run init / run
CLI->>Prompts: show MultiSelect & peer choices
Prompts->>Peer: present presets or "Other"
Peer-->>Prompts: selected preset or custom address
Prompts->>Config: generate PeerConfig + enabled APIs
Config-->>CLI: persist config
CLI-->>User: print banner and completion status

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐇 I nibble at the Git SHA bright,
A banner pops to greet the night,
Preset peers hop, choices in store,
APIs gather, ready to roar,
I twitch my nose — deploys take flight!

🚥 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 title 'feat(cli): improve init flow with better UX' is directly related to the main changes in the PR, which focus on enhancing the CLI initialization flow with improved user experience features like API selection prompts, peer address helpers, and banner display.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/improve-init
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/bin/dolos/init.rs (1)

350-381: ⚠️ Potential issue | 🟠 Major

Don't enable every listener by default.

These defaults turn "accept the defaults" into "bind several APIs on all interfaces" because the corresponding apply_serve_* helpers use wildcard listen addresses. That's a meaningful security posture change for an init flow. Default them to off, or at least to loopback, and let the multi-select opt users in explicitly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/bin/dolos/init.rs` around lines 350 - 381, The init code currently
enables multiple listeners by default via apply_serve_grpc(Some(true)),
apply_serve_minibf(Some(true)), apply_serve_minikupo(Some(true)),
apply_serve_trp(Some(true)) and (on unix) apply_serve_ouroboros(Some(true)),
which causes wildcard binds; change these defaults to not enable listeners by
default—either remove those Some(true) calls or pass Some(false) for each of
apply_serve_grpc, apply_serve_minibf, apply_serve_minikupo, apply_serve_trp and
apply_serve_ouroboros (or adjust the helpers to default to loopback instead of
wildcard) so the init flow does not bind public interfaces unless the user
explicitly opt-ins.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@build.rs`:
- Around line 8-9: The current code passes PathBuf::from(".git") directly to
emit_git_rerun_hints which breaks for worktrees where .git is a file; update the
logic that builds git_dir (and the call sites around emit_git_rerun_hints) to
detect if .git is a file, read its contents (e.g. "gitdir: /actual/path"),
resolve that target to the real git directory, and then call
emit_git_rerun_hints with the resolved path so the function emits rerun hints
against the actual HEAD/ref files (adjust the same pattern used in the block
around lines 31-46 where HEAD/ref paths are emitted).

In `@src/bin/dolos/init.rs`:
- Around line 243-280: The API picker and defaults expose Minibf/Minikupo/TRP
even when those features are not compiled; update AvailableApi, its Display
impl, and the VARIANTS const as well as ConfigEditor::default() to use the same
feature gates as the actual service modules (e.g. add #[cfg(feature = "minibf")]
/ #[cfg(feature = "minikupo")] / #[cfg(feature = "trp")] around the enum
variants, their Display arms, and entries in VARIANTS, and wrap any
default-enabled selections in ConfigEditor::default() with the same
#[cfg(feature = "...")] so the binary only advertises and persists services that
are actually compiled in.
- Around line 573-617: In prompt_remote_peer, preserve the existing custom relay
by pre-filling the Text prompt when matching RemotePeerChoice::Other: use the
local variable current as the default for the Text prompt (the same way the
unknown-network branch does) so editing an existing custom peer doesn't force
retyping; update the RemotePeerChoice::Other branch inside the match in function
prompt_remote_peer to provide .with_default(current) (or equivalent) to the
Text::new prompt before calling .prompt().

---

Outside diff comments:
In `@src/bin/dolos/init.rs`:
- Around line 350-381: The init code currently enables multiple listeners by
default via apply_serve_grpc(Some(true)), apply_serve_minibf(Some(true)),
apply_serve_minikupo(Some(true)), apply_serve_trp(Some(true)) and (on unix)
apply_serve_ouroboros(Some(true)), which causes wildcard binds; change these
defaults to not enable listeners by default—either remove those Some(true) calls
or pass Some(false) for each of apply_serve_grpc, apply_serve_minibf,
apply_serve_minikupo, apply_serve_trp and apply_serve_ouroboros (or adjust the
helpers to default to loopback instead of wildcard) so the init flow does not
bind public interfaces unless the user explicitly opt-ins.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b5d2a809-e32d-49e2-a2bf-37983075ae8d

📥 Commits

Reviewing files that changed from the base of the PR and between 515ce72 and 40fd36e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • Cargo.toml
  • build.rs
  • crates/fjall/src/index/mod.rs
  • examples/v1/alonzo.json
  • examples/v1/byron.json
  • examples/v1/conway.json
  • examples/v1/dolos.toml
  • examples/v1/shelley.json
  • src/bin/dolos/banner.rs
  • src/bin/dolos/init.rs
  • src/bin/dolos/main.rs
💤 Files with no reviewable changes (5)
  • examples/v1/alonzo.json
  • examples/v1/dolos.toml
  • examples/v1/shelley.json
  • examples/v1/conway.json
  • examples/v1/byron.json

Comment on lines +243 to +280
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum AvailableApi {
UtxoRpc,
Minibf,
Minikupo,
Trp,
#[cfg(unix)]
Ouroboros,
}

impl Display for AvailableApi {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::UtxoRpc => f.write_str("UTxO RPC (gRPC): Performant API for UTxO blockchains"),
Self::Minibf => f.write_str("Mini-Blockfrost (HTTP): Blockfrost-compatible API"),
Self::Minikupo => f.write_str("Mini-Kupo (HTTP): Kupo-compatible API"),
Self::Trp => f.write_str("TRP (JSON-RPC): Tx3 transaction resolver protocol"),
#[cfg(unix)]
Self::Ouroboros => {
f.write_str("Ouroboros (unix socket): node-to-client compatible API")
}
}
}
}

impl AvailableApi {
#[cfg(unix)]
const VARIANTS: &'static [Self] = &[
Self::UtxoRpc,
Self::Minibf,
Self::Minikupo,
Self::Trp,
Self::Ouroboros,
];

#[cfg(windows)]
const VARIANTS: &'static [Self] = &[Self::UtxoRpc, Self::Minibf, Self::Minikupo, Self::Trp];
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Mirror Cargo feature gates in the API picker and defaults.

AvailableApi always includes Minibf/Minikupo/TRP, and ConfigEditor::default() pre-enables them, even though those services are optional Cargo features. A --no-default-features --features utils build will still advertise and persist configs for services the binary doesn't contain. Gate these variants and their default selections behind the same #[cfg(feature = "...")] conditions used by the actual service modules.

Also applies to: 350-381, 639-659

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/bin/dolos/init.rs` around lines 243 - 280, The API picker and defaults
expose Minibf/Minikupo/TRP even when those features are not compiled; update
AvailableApi, its Display impl, and the VARIANTS const as well as
ConfigEditor::default() to use the same feature gates as the actual service
modules (e.g. add #[cfg(feature = "minibf")] / #[cfg(feature = "minikupo")] /
#[cfg(feature = "trp")] around the enum variants, their Display arms, and
entries in VARIANTS, and wrap any default-enabled selections in
ConfigEditor::default() with the same #[cfg(feature = "...")] so the binary only
advertises and persists services that are actually compiled in.

@scarmuega scarmuega merged commit 400532b into main Mar 12, 2026
12 checks passed
@scarmuega scarmuega deleted the feat/improve-init branch March 12, 2026 20:45
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