fix: show sats amount on fixed orders#852
Conversation
WalkthroughThe order title message generation in ChangesAmount-aware order title messages
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bot/ordersActions.ts (1)
286-288: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueWhitespace baked into interpolated value is fragile.
amountTextembeds a trailing space (`${numberFormat(fiatCode, amount)} `) so that locale strings like'Selling ${amount}sats'render correctly. This couples the JS logic to an undocumented assumption about every locale template's spacing (no space beforesats/equivalent). A future locale edit that adds a space before the placeholder will silently produce a double space.Consider keeping
amountTextas just the formatted number (or empty) and letting each locale template own the spacing, e.g.${amount} satswith a conditional/trim, or exposing a separatehasAmountflag to the templates.♻️ Possible approach
- const amountText = priceFromAPI ? '' : `${numberFormat(fiatCode, amount)} `; + const amountText = priceFromAPI ? '' : `${numberFormat(fiatCode, amount)}`;Then update locale strings to
'Selling ${amount} sats'and have market/range variants use a dedicated string without the amount placeholder, instead of relying on an empty interpolated value.🤖 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 `@bot/ordersActions.ts` around lines 286 - 288, The spacing for order amount rendering is currently baked into `amountText` in `ordersActions.ts`, which makes locale templates fragile. Update the `amountText` handling in the order formatting logic so it only returns the formatted number or an empty string, and move spacing decisions into the locale strings used by the sell/order templates. Adjust the relevant template entries and any callers in the order action flow so fixed orders and market/range orders render correctly without relying on a trailing space inside `amountText`.
🤖 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 `@bot/ordersActions.ts`:
- Around line 286-288: The spacing for order amount rendering is currently baked
into `amountText` in `ordersActions.ts`, which makes locale templates fragile.
Update the `amountText` handling in the order formatting logic so it only
returns the formatted number or an empty string, and move spacing decisions into
the locale strings used by the sell/order templates. Adjust the relevant
template entries and any callers in the order action flow so fixed orders and
market/range orders render correctly without relying on a trailing space inside
`amountText`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 672a802a-ca1c-40ff-83de-daf963947d86
📒 Files selected for processing (11)
bot/ordersActions.tslocales/de.yamllocales/en.yamllocales/es.yamllocales/fa.yamllocales/fr.yamllocales/it.yamllocales/ko.yamllocales/pt.yamllocales/ru.yamllocales/uk.yaml
PR #770 moved the order title into a single i18n string and dropped the sats amount, so fixed orders showed "Selling sats" instead of "Selling 100 sats".
Restores the amount via a ${amount} placeholder in the locale keys (all languages) and computes it in getOrderTitleMessage: shown for fixed orders, omitted for market/range orders.
Summary by CodeRabbit