Skip to content

refactor(pnpr): source --listen default from Config::DEFAULT_LISTEN - #12629

Merged
zkochan merged 1 commit into
mainfrom
pnpr-listen-default-single-source
Jun 24, 2026
Merged

zkochan merged 1 commit into
mainfrom
pnpr-listen-default-single-source

Conversation

@zkochan

@zkochan zkochan commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to the merged #12622 (change pnpr's default port to 7677), addressing a CodeRabbit review comment on that PR.

The default listen address was duplicated: a string literal in the --listen CLI argument (pnpr/crates/pnpr/src/main.rs) and the Config::DEFAULT_LISTEN constant (pnpr/crates/pnpr/src/config.rs). This points the CLI default at the constant, so the two cannot drift apart — a single source of truth, which is stronger than a regression test guarding the parity.

Verified the resolved default is unchanged:

$ pnpr --help
      --listen <LISTEN>
          Address to bind to [default: 127.0.0.1:7677]

Squash Commit Body

Address a CodeRabbit review on pnpm/pnpm#12622: instead of duplicating the
default listen address as a string literal in the CLI arg, reference the
existing Config::DEFAULT_LISTEN constant so the CLI default and the config
default cannot drift apart.

Checklist

  • Updated the documentation if needed.

Written by an agent (Claude Code, claude-opus-4-8).

Summary by CodeRabbit

  • Bug Fixes
    • Updated the default server bind address used by the CLI to match the app’s configured default, keeping startup behavior consistent.

Address CodeRabbit review: instead of duplicating the default listen
address as a string literal in the CLI arg, reference the existing
Config::DEFAULT_LISTEN constant so the CLI default and the config default
cannot drift apart.
@zkochan zkochan mentioned this pull request Jun 24, 2026
1 task done
@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The --listen CLI argument's default_value in pnpr/crates/pnpr/src/main.rs is changed from the hard-coded string "127.0.0.1:7677" to the constant Config::DEFAULT_LISTEN.

Changes

CLI listen default update

Layer / File(s) Summary
Replace hard-coded --listen default with Config::DEFAULT_LISTEN
pnpr/crates/pnpr/src/main.rs
The default_value for the --listen clap argument is updated from the literal "127.0.0.1:7677" to Config::DEFAULT_LISTEN.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • pnpm/pnpm#12622: Introduced Config::DEFAULT_LISTEN (port 7677), which is the constant now referenced as the --listen argument default.

Suggested labels

product: pnpr

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pnpr-listen-default-single-source

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.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

pnpr: derive --listen CLI default from Config::DEFAULT_LISTEN
✨ Enhancement 🕐 Less than 5 minutes

Grey Divider

Description

• Use Config::DEFAULT_LISTEN as the --listen CLI default.
• Remove the duplicated listen-address literal to prevent CLI/config drift.
Diagram

graph TD
  cli["pnpr CLI (main.rs)"] --> arg["--listen default"] --> cfg["Config::DEFAULT_LISTEN (config.rs)"]
Loading
High-Level Assessment

Referencing Config::DEFAULT_LISTEN directly is the most robust approach because it eliminates the possibility of the CLI help/default drifting from the config default. A regression test could also catch drift, but a single source of truth prevents it outright.

Files changed (1) +1 / -1

Refactor (1) +1 / -1
main.rsSource '--listen' default from 'Config::DEFAULT_LISTEN' +1/-1

Source '--listen' default from 'Config::DEFAULT_LISTEN'

• Replaces the '--listen' clap 'default_value' string literal with 'Config::DEFAULT_LISTEN'. This keeps the CLI default bind address consistent with the config default and prevents future divergence.

pnpr/crates/pnpr/src/main.rs

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Auto-approved notes - no code review findings
- 'auto_approve_for_no_suggestions' flag enabled

Previous review results

Review updated until commit b802245

Results up to commit b802245


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Auto-approved notes - no code review findings
- 'auto_approve_for_no_suggestions' flag enabled

Qodo Logo

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pnpr/crates/pnpr/src/main.rs (1)

17-17: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression test for the --listen default/help contract.

Line 17 correctly removes duplication, but this user-visible default should be locked by a test that asserts help/default output stays aligned with Config::DEFAULT_LISTEN (127.0.0.1:7677).

As per path instructions, “add/adjust a regression test that would fail without the fix (e.g., asserting the --listen default value/help output matches Config::DEFAULT_LISTEN)”.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpr/crates/pnpr/src/main.rs` at line 17, Add a regression test that locks
the `--listen` default/help contract so it stays aligned with
`Config::DEFAULT_LISTEN`. Update or add a test around the CLI parsing/help
output for `main` and the `Config` default constant to assert the advertised
default for `--listen` matches `127.0.0.1:7677`, so the test fails if the help
text or default value diverges.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pnpr/crates/pnpr/src/main.rs`:
- Line 17: Add a regression test that locks the `--listen` default/help contract
so it stays aligned with `Config::DEFAULT_LISTEN`. Update or add a test around
the CLI parsing/help output for `main` and the `Config` default constant to
assert the advertised default for `--listen` matches `127.0.0.1:7677`, so the
test fails if the help text or default value diverges.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: df29393f-33d4-4975-a57c-2376a0e8085b

📥 Commits

Reviewing files that changed from the base of the PR and between 76461e0 and b802245.

📒 Files selected for processing (1)
  • pnpr/crates/pnpr/src/main.rs

@github-actions github-actions Bot added reviewed: qodo reviewed: coderabbit CodeRabbit submitted an approving review labels Jun 24, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit b802245

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.18%. Comparing base (76461e0) to head (b802245).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12629   +/-   ##
=======================================
  Coverage   88.18%   88.18%           
=======================================
  Files         329      329           
  Lines       47074    47074           
=======================================
+ Hits        41511    41513    +2     
+ Misses       5563     5561    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zkochan
zkochan merged commit 266c2fe into main Jun 24, 2026
38 checks passed
@zkochan
zkochan deleted the pnpr-listen-default-single-source branch June 24, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pnpr reviewed: coderabbit CodeRabbit submitted an approving review reviewed: qodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants