Feat(website)dinonuggieUpgrades + gamesLayout#156
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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.
Actionable comments posted: 5
🤖 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 `@site_src/pages/games/dinonuggie_upgrades.ts`:
- Around line 176-188: Add a CSS rule for warning toasts so elements given
className 'toast warn' render with distinct styling: create a `.toast.warn`
selector alongside `.toast.error` and `.toast.ok` and set an appropriate warning
text color and border-color (and optionally background or min-height) to
visually distinguish warnings; update the styles block that defines `.toast` so
the new `.toast.warn` rule appears with the other toast modifiers.
- Around line 299-306: The api function currently throws on network/HTTP/JSON
failures causing callers that expect a resolved object to break; update
api(path, body) to always resolve to an object following the shared { error }
contract: perform the fetch as before, but catch network/errors and JSON parse
errors and return { error: <string> } (use a concise message), and for non-2xx
responses attempt to parse JSON and return its error field or fallback to {
error: response.statusText || 'Request failed' }; on success return the parsed
JSON; keep csrf merging behavior intact so callers using api(...) never receive
a thrown exception.
In `@utils/ascend.ts`:
- Around line 62-72: The current if-guard in processAscend lets multiple waiters
capture the same existing promise and race; change the pattern to a while loop
that repeatedly checks ascendLocks.get(userId) and, while an existing promise is
present, awaits it (with .catch(() => {}) to swallow errors) before re-checking,
then only when no existing promise set the new run via ascendLocks.set(userId,
run); apply the identical while-based re-check-and-wait fix to the analogous
functions buyAscLocks and buyLocks (and their respective lock maps) and keep the
finally block that deletes the lock only if the stored value equals run.
In `@utils/buyAscensionUpgrade.ts`:
- Around line 91-92: The two separate writes using client.db.user.addUserAttr
(debit 'heavenlyNuggies' then increment `${upgrade}Level`) are not atomic and
can leave users charged without receiving the upgrade; modify
buyAscensionUpgrade (and the same pattern in buyUpgrade) to perform both
mutations inside a single DB transaction or a single atomic update: either use
the DB client's transaction API (e.g., begin/commit/rollback or withTransaction)
to call both addUserAttr operations together, or add a new atomic method on
client.db.user (e.g., updateUserAttrs or changeCreditsAndLevel) that applies the
credit delta and level delta in one DB call and returns success/failure so you
can roll back on error.
In `@utils/eat.ts`:
- Around line 128-137: The current lock logic in processEat awaits an existing
promise (existing) and then starts a new processEatInner(), allowing concurrent
runs; instead, chain the new work onto the stored promise so B and C wait for A
and then run sequentially: replace the await-existing pattern by creating run as
either processEatInner(client, userId, amount) when no existing, or
existing.catch(()=>undefined).then(() => processEatInner(client, userId,
amount)) when there is an existing; keep eatLocks.set(userId, run) and the
finally cleanup unchanged (checking eatLocks.get(userId) === run) so the promise
chain is stored and removed correctly.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1b4a9f79-8818-4dcc-af0b-3ce6a787c3bc
⛔ Files ignored due to path filters (1)
site_src/Assets/svg/wrench-screwdriver-svgrepo-com.svgis excluded by!**/*.svg
📒 Files selected for processing (14)
commands/ascend.tscommands/buy_ascension.tscommands/buy_upgrades.tscommands/eat.tssite_src/bot-bridge.tssite_src/pages/games.tssite_src/pages/games/dinonuggie_upgrades.tssite_src/routes/games-api.tssite_src/routes/pages.tssite_src/routes/static.tsutils/ascend.tsutils/buyAscensionUpgrade.tsutils/buyUpgrade.tsutils/eat.ts
Summary by CodeRabbit
New Features
Refactor