Preserve fractional leading zeros while editing float prompts - #6966
Conversation
🦋 Changeset detectedLatest commit: 9885caf The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
The reproduction test added by this PR currently fails because the implementation fix it describes has not yet been included.
Reviewed changes
- Added one regression test in
packages/effect/test/unstable/cli/Prompt.test.tsforPrompt.floatto verify that typing0.05submits0.05instead of5.
The new test is a sound, minimal regression spec: it exercises the exact keystroke sequence described in the PR body and asserts the precise numeric result. I ran it locally and confirmed it fails against the current defaultFloatProcessor implementation with AssertionError: expected 5 to equal 0.05, which matches the documented failure mode.
Because the PR body states the implementation fix should follow on this same branch and CI is expected to fail until then, this is not mergeable yet. Once the source fix lands and this test passes, the PR will be ready for another look.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Implemented the
defaultFloatProcessorfix inpackages/effect/src/unstable/cli/Prompt.tsso fractional leading zeros are preserved when the edit buffer already contains a decimal point and the next input is a digit. - Added a changeset describing the bug fix.
- Verified the regression test added in the prior commit now passes, and the existing
Prompt.floattests continue to pass.
The new implementation is minimal and targeted: it avoids re-serializing the parsed number when the user is typing the fractional part, while still falling back to the parsed string for all other inputs (including sign, decimal point insertion, and backspace-driven updates).
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
Typing a fractional value such as 0.05 mutates the edit buffer and submits 5 instead.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
Float entry drops fractional leading zeros
Module:
cli/PromptAudit ID:
unstable-ai-cli-prompt-float-leading-zeroSeverity / confidence: medium / high
What happens
Typing a fractional value such as 0.05 mutates the edit buffer and submits 5 instead.
Why it happens
Each keystroke is parsed and serialized; entering 0.0 is normalized back to 0 before the following digit is appended.
Expected behavior
The float prompt accepts floating-point input before applying configured rounding and validation.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/unstable/cli/Prompt.ts:2861-2883View problematic code at
packages/effect/src/unstable/cli/Prompt.ts:2861-2883View exact lines on GitHub
Reproduction
pnpm test --run packages/effect/test/unstable/cli/PromptFloatZero.audit.test.tsObserved failure: FAIL: 0.05 was submitted as 5.
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
pnpm test --run packages/effect/test/unstable/cli/PromptFloatZero.audit.test.tsAudit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715funstable-ai-cli-prompt-float-leading-zeroCloses EFF-412