Skip to content

Conversation

@iitslamaa
Copy link
Contributor

Adds --print-url to promptfoo view. Prints the viewer URL to stdout and does not auto-open a browser.

  • --print-url implies no auto-open behavior
  • Still starts the local server
  • Useful for CI/headless scripts that need to capture the URL

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

📝 Walkthrough

Walkthrough

This pull request adds a new --print-url flag to the promptfoo view command. When enabled, the flag disables browser auto-opening behavior and prints the local web UI URL (http://localhost:) to stdout. This is useful for scripting and CI/CD environments. The implementation modifies the command option declaration and adds conditional logic in the view command handler to skip browser launching and output the URL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • The change is isolated to one primary file (src/commands/view.ts)
  • A new CLI flag is added with straightforward conditional behavior
  • The logic flow is linear: check for the flag, disable auto-opening, print the URL, then proceed
  • Documentation is updated consistently in CHANGELOG.md

Areas to review:

  • Verification that URL printing occurs at the correct execution point before server startup
  • Ensure the --print-url flag behaves correctly when combined with other existing options
  • Confirm the server still initializes properly when this flag is used

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "feat(cli): add --print-url flag to promptfoo view (implies no auto-open)" directly and clearly summarizes the main change in the changeset. It specifies the new CLI flag being added (--print-url), identifies the command it applies to (promptfoo view), and captures the key behavior change (no auto-open). The title follows conventional commit format and is concise and readable, making it easy for teammates to understand the primary change when scanning history. The title is fully aligned with the changes documented in the raw summary and PR description.
Description Check ✅ Passed The pull request description is clearly related to the changeset and provides meaningful information about the changes. It explains what is being added (--print-url flag), describes its primary behavior (prints URL to stdout, prevents auto-open), clarifies that the server still starts, and explains the use case (CI/headless scripts). The description directly corresponds to the changes shown in the raw summary and is specific enough to convey the intent and functionality, well exceeding the lenient threshold for this check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Contributor

@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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c367e25 and cf1b545.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/commands/view.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
CHANGELOG.md

📄 CodeRabbit inference engine (.cursor/rules/changelog.mdc)

CHANGELOG.md: Document all user-facing changes in CHANGELOG.md
Every pull request must add or update an entry in CHANGELOG.md under the [Unreleased] section
Follow Keep a Changelog structure under [Unreleased] with sections: Added, Changed, Fixed, Dependencies, Documentation, Tests, Removed
Each changelog entry must include the PR number formatted as (#1234) or temporary placeholder (#XXXX)
Each changelog entry must use a Conventional Commit prefix: feat:, fix:, chore:, docs:, test:, or refactor:
Each changelog entry must be concise and on a single line
Each changelog entry must be user-focused, describing what changed and why it matters to users
Each changelog entry must include a scope in parentheses, e.g., feat(providers): or fix(evaluator):
Use common scopes for consistency: providers, evaluator, webui or app, cli, redteam, core, assertions, config, database
Place all dependency updates under the Dependencies category
Place all test changes under the Tests category
Use categories consistently: Added for new features, Changed for modifications/refactors/CI, Fixed for bug fixes, Removed for removed features
After a PR number is assigned, replace (#XXXX) placeholders with the actual PR number
Be specific, use active voice, include context, and avoid repeating the PR title in changelog entries
Group related changes with multiple bullets in the same category when needed; use one entry per logical change

CHANGELOG.md: All user-facing changes require a CHANGELOG.md entry before creating a PR
Add entries under [Unreleased] in appropriate category (Added, Changed, Fixed, Dependencies, Documentation, Tests)
Each changelog entry must include PR number (#1234) or placeholder (#XXXX)
Use conventional commit prefixes in changelog entries (feat:, fix:, chore:, docs:, test:, refactor:)

CHANGELOG.md: Document all user-facing changes in CHANGELOG.md
Changelog entries must include the PR number in format (#1234)
Use conventional commit prefixes in changelog entries: feat:,...

Files:

  • CHANGELOG.md
src/commands/**/*.ts

📄 CodeRabbit inference engine (src/commands/CLAUDE.md)

src/commands/**/*.ts: Record telemetry at the start of each command action using telemetry.record('command_used', ...)
Validate user inputs with Zod schemas before use; log and exit early on validation failure
On errors in command handlers, log the error and set process.exitCode = 1; do not throw errors
Do not call process.exit() directly in commands; use process.exitCode instead
Define commands as functions that register with Commander.js and use .command().description().option().action()
Use Commander's .option() for flags and provide clear descriptions for commands and options
Call setupEnv() with the provided env path before command logic when applicable
Return early on errors from action handlers after setting exitCode (avoid continuing execution)

Files:

  • src/commands/view.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/gh-cli-workflow.mdc)

Prefer not to introduce new TypeScript types; reuse existing interfaces where possible

**/*.{ts,tsx}: Maintain consistent import order (Biome handles sorting)
Use consistent curly braces for all control statements
Prefer const over let and avoid var
Use object shorthand syntax when possible
Use async/await for asynchronous code
Use consistent error handling with proper type checks

**/*.{ts,tsx}: Use TypeScript with strict type checking enabled
Follow consistent import order (Biome will sort imports)
Use consistent curly braces for all control statements
Prefer const over let; avoid var
Use object property shorthand when possible
Use async/await for asynchronous code instead of raw promises/callbacks
When logging, pass sensitive data via the logger context object so it is auto-sanitized; avoid interpolating secrets into message strings
Manually sanitize sensitive objects with sanitizeObject before storing or emitting outside logging contexts

Files:

  • src/commands/view.ts
src/**

📄 CodeRabbit inference engine (AGENTS.md)

Place core application/library logic under src/

Files:

  • src/commands/view.ts
🧬 Code graph analysis (1)
src/commands/view.ts (1)
src/constants.ts (1)
  • getDefaultPort (39-41)
🔇 Additional comments (2)
src/commands/view.ts (2)

19-19: LGTM: Clear option declaration.

The --print-url option is properly declared with a clear description that communicates the behavior to users.


27-27: LGTM: Appropriate type addition.

The optional printUrl property is correctly typed and follows the pattern of other CLI flag properties.

### Added

- feat(redteam): add goal-misalignment plugin for detecting Goodhart's Law vulnerabilities (#6045)
- feat(cli): add `--print-url` flag to `promptfoo view` to print the local web UI URL without opening a browser
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Missing PR number and user-focused phrasing

Add the PR reference and tighten wording per changelog rules. Also include contributor attribution for consistency.

Apply this diff:

-- feat(cli): add `--print-url` flag to `promptfoo view` to print the local web UI URL without opening a browser
+- feat(cli): `promptfoo view --print-url` prints the viewer URL to stdout and skips browser auto-open; useful in CI/headless runs (#6071) by @iitslamaa

As per coding guidelines.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- feat(cli): add `--print-url` flag to `promptfoo view` to print the local web UI URL without opening a browser
- feat(cli): `promptfoo view --print-url` prints the viewer URL to stdout and skips browser auto-open; useful in CI/headless runs (#6071) by @iitslamaa
🤖 Prompt for AI Agents
In CHANGELOG.md around line 12, the entry lacks a PR reference, contributor
attribution, and user-focused wording; update the line to include the merged PR
number in parentheses (e.g., "(#NNNN)"), rephrase to a user-centric description
(e.g., "Add --print-url to promptfoo view to print the local web UI URL without
opening a browser"), and append contributor attribution (e.g., "Contributed by
@username") to follow changelog guidelines.

@iitslamaa
Copy link
Contributor Author

hey @mldangelo — this is ready. if alls good, i can update the docs to include it too.

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