Fix blank project name prompt submit#472
Conversation
📝 WalkthroughWalkthroughThe PR fixes blank project name submission handling in the TanStack CLI interactive create prompts. It normalizes undefined/blank inputs to empty strings via null coalescing, validates and trims the results safely, and adds test coverage for both blank and undefined cases, with a patch release documented in the changeset. ChangesBlank Project Name Validation Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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
packages/cli/tests/ui-prompts.test.tsParsing error: "parserOptions.project" has been provided for Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@packages/cli/src/ui-prompts.ts`:
- Around line 70-71: Update the inline comment next to the placeholder: ''
setting to accurately describe why it's used with `@clack/prompts` v0.10.0:
explain that text() resolves to '' for a blank submit and that placeholders are
treated as an implicit default value, so setting placeholder: '' ensures a blank
submit yields an empty string (not an implicit placeholder value); remove the
incorrect claim that Clack “prints `undefined`” and mention the behavior is
specific to text() in v0.10.0.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f3da4210-b656-4f55-8900-af9ef47c8ea7
📒 Files selected for processing (3)
.changeset/quick-humans-sort.mdpackages/cli/src/ui-prompts.tspackages/cli/tests/ui-prompts.test.ts
| // Clack prints `undefined` on blank submit when placeholder is omitted. | ||
| placeholder: '', |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Does @clack/prompts text() function return undefined when the user submits a blank value and no placeholder is provided in version 0.10.0?
💡 Result:
In version 0.10.0 of @clack/prompts, the text function does not return undefined when a user submits a blank value without a placeholder; instead, it typically returns an empty string ('') [1]. Regarding the behavior of placeholders in version 0.10.0, the library's implementation at that time caused the placeholder value to be automatically used as the input value if the user submitted the prompt without typing anything [2][3][4]. This behavior was a known source of confusion and bugs, as it meant the placeholder was not merely a visual hint but also functioned as an implicit default value [4][5]. This behavior was subsequently addressed in later versions (starting after 0.10.1) by decoupling placeholders from the actual input value, ensuring that placeholders function solely as visual indicators [2][5]. For version 0.10.0, if no placeholder was provided and the user submitted a blank value, the result was an empty string [1].
Citations:
- 1: bombshell-dev/clack@bfe0dd3
- 2: [Bug] [Regression] Text Prompt Incorrectly Uses Placeholder Value as the Default Value bombshell-dev/clack#322
- 3: fix: use placeholder as value when input is empty bombshell-dev/clack#263
- 4: [Bug] Adding the placeholder attribute to the text method will affect the result of the validate method bombshell-dev/clack#282
- 5: fix: treat placeholders as visual element bombshell-dev/clack#323
Clarify the rationale for placeholder: '' in @clack/prompts v0.10.0
In @clack/prompts v0.10.0, text() doesn’t return undefined on a blank submit (it resolves to ''); instead, placeholders were treated as an implicit default input value. Using placeholder: '' ensures a blank submission yields '' (so trimming/validation stays consistent). Update the inline comment to remove the “prints undefined” claim.
🤖 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 `@packages/cli/src/ui-prompts.ts` around lines 70 - 71, Update the inline
comment next to the placeholder: '' setting to accurately describe why it's used
with `@clack/prompts` v0.10.0: explain that text() resolves to '' for a blank
submit and that placeholders are treated as an implicit default value, so
setting placeholder: '' ensures a blank submit yields an empty string (not an
implicit placeholder value); remove the incorrect claim that Clack “prints
`undefined`” and mention the behavior is specific to text() in v0.10.0.
What changed
undefinedis treated as an empty string.undefinedafter blank submit.@tanstack/cli.Why
On Windows with the VP/Vite runtime path, submitting an empty project-name prompt could surface
undefined, render that value in the prompt, and then crash when the CLI called.trim().Validation
pnpm --filter @tanstack/cli test -- ui-prompts.test.tspnpm --filter @tanstack/cli buildundefinedor a crash.Summary by CodeRabbit
Release Notes