Skip to content

fix(cli): apply bracketed default on empty interactive prompt#4389

Open
jason-ma-nv wants to merge 1 commit into
mainfrom
fix/4387-promptordefault-interactive-default
Open

fix(cli): apply bracketed default on empty interactive prompt#4389
jason-ma-nv wants to merge 1 commit into
mainfrom
fix/4387-promptordefault-interactive-default

Conversation

@jason-ma-nv
Copy link
Copy Markdown
Contributor

@jason-ma-nv jason-ma-nv commented May 28, 2026

Summary

promptOrDefault displayed the bracketed default value (e.g. Choose [6]:) but only substituted that default in non-interactive mode. In interactive mode it returned the raw deps.prompt() reply, which is the empty string on bare Enter — so every interactive caller had to re-implement the empty-reply fallback. The resource-profile prompt did not, so pressing Enter at Choose [6]: exited with Invalid resource profile selection ''. even though the prompt advertised 6 as the default.

Related Issue

Fixes #4387.

Changes

  • src/lib/onboard/prompt-helpers.ts: in the interactive branch of promptOrDefault, fall back to defaultValue when the reply is empty or whitespace-only. Callers that already had their own || "25%"-style fallback continue to work unchanged — the helper-level default fires first and their branch is now a redundant no-op.
  • src/lib/onboard/prompt-helpers.test.ts: new test file (promptOrDefault previously had no direct tests; the interactive branch was the untested path that hid this regression). Three #4387 tests pin empty → default, whitespace → default, non-empty → verbatim.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Jason Ma jama@nvidia.com

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of empty or whitespace-only responses in prompts to properly select default values.
  • Tests

    • Added comprehensive test coverage for prompt input behavior.

Review Change Stack

`promptOrDefault` displayed the default value in the prompt label
(e.g. `Choose [6]:`) but only substituted that default in
non-interactive mode. In interactive mode it returned the raw
`deps.prompt()` reply, which is the empty string on bare Enter,
leaving every interactive caller to re-implement the fallback. The
resource-profile prompt did not, so pressing Enter at `Choose [6]:`
exited with `Invalid resource profile selection ''.` even though
the prompt advertised 6 as the default.

Fall back to `defaultValue` when the interactive reply is empty or
whitespace-only. Callers that already had their own `|| "25%"`-style
fallback continue to work unchanged — the helper-level default fires
first and the caller's redundant branch never triggers.

Add `prompt-helpers.test.ts` pinning the new behavior (empty →
default, whitespace → default, non-empty → verbatim). The function
previously had no direct tests; the interactive branch was the
untested path that hid this regression.

Fixes #4387.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Jason Ma <jama@nvidia.com>
@jason-ma-nv jason-ma-nv self-assigned this May 28, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: cc4dbaf5-1430-4149-93f7-fa54e04d63df

📥 Commits

Reviewing files that changed from the base of the PR and between 1daf081 and 425b6b3.

📒 Files selected for processing (2)
  • src/lib/onboard/prompt-helpers.test.ts
  • src/lib/onboard/prompt-helpers.ts

📝 Walkthrough

Walkthrough

This PR fixes a bug where promptOrDefault in interactive mode failed to apply the displayed default value when the user pressed Enter without typing anything. The implementation now trims replies and treats empty/whitespace responses as selecting the default, with comprehensive test coverage validating all three input scenarios.

Changes

Prompt Default Value Fallback

Layer / File(s) Summary
promptOrDefault default-fallback logic and tests
src/lib/onboard/prompt-helpers.ts, src/lib/onboard/prompt-helpers.test.ts
Interactive path updated to trim the reply and return defaultValue when empty or whitespace; non-interactive path unchanged. Test suite covers empty input, whitespace-only input, and non-empty input with mocked dependencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

NemoClaw CLI, fix

Suggested reviewers

  • ericksoa
  • cv

Poem

🐰 Enter, and defaults appear—
no more blank rejections here!
Trim the whitespace, keep it lean,
the displayed [6] now reigns supreme.
Onboarding flows without a hitch,
your fallback values switch and switch! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: applying the bracketed default value when the user provides empty input in interactive prompt mode.
Linked Issues check ✅ Passed The PR fully addresses issue #4387: it trims user replies and returns defaultValue when empty/whitespace in interactive mode, matching the displayed bracketed default and fixing the resource-profile prompt failure.
Out of Scope Changes check ✅ Passed All changes are directly within scope: the fix applies empty-reply fallback in promptOrDefault and adds corresponding tests, with no unrelated modifications.

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

✨ 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 fix/4387-promptordefault-interactive-default

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

@github-actions
Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: cloud-onboard-e2e
Optional E2E: onboard-resume-e2e

Dispatch hint: cloud-onboard-e2e

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • cloud-onboard-e2e (medium): Runs install plus onboarding through the deployed CLI path and is the closest existing merge-blocking smoke for changes under src/lib/onboard. Although this PR targets interactive default handling, this E2E validates that the shared onboarding prompt helper change does not regress the standard cloud onboarding path.

Optional E2E

  • onboard-resume-e2e (medium): Optional adjacent coverage for onboarding state/resume behavior because promptOrDefault is a shared onboarding helper, but the specific change is limited to interactive empty replies and does not directly alter resume logic.

New E2E recommendations

  • interactive onboarding prompt defaults (high): Existing onboarding E2Es appear to run non-interactively and may not exercise pressing Enter in a TTY to accept displayed defaults. Add a lightweight pseudo-TTY onboarding prompt-default regression that drives an interactive flow far enough to verify default acceptance for resource profile and sandbox-name prompts without requiring every caller to reimplement fallback logic.
    • Suggested test: interactive-onboard-prompt-defaults-e2e

Dispatch hint

  • Workflow: nightly-e2e.yaml
  • jobs input: cloud-onboard-e2e

@github-actions
Copy link
Copy Markdown
Contributor

E2E Scenario Advisor Recommendation

Required scenario E2E: None
Optional scenario E2E: None

Workflow run

Full scenario advisor summary

E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required scenario E2E

  • None. No scenario workflow, scenario metadata, scenario runtime, or validation-suite files changed.

Optional scenario E2E

  • None.

Relevant changed files

  • None.

@github-actions
Copy link
Copy Markdown
Contributor

PR Review Advisor

Findings: 0 needs attention, 0 worth checking, 0 nice ideas
Top item: No actionable findings

Workflow run details

This is an automated advisory review. A human maintainer must make the final merge decision.

@jason-ma-nv jason-ma-nv added the v0.0.54 Release target label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v0.0.54 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux][CLI&UX] nemoclaw onboard --resume: pressing Enter at resource profile prompt rejects empty input instead of applying the displayed [6] default

1 participant