Skip to content

Remove orphaned code and consolidate image generation utilities#1647

Merged
DaFum merged 19 commits into
mainfrom
claude/review-integrate-subagent-REvMX
May 16, 2026
Merged

Remove orphaned code and consolidate image generation utilities#1647
DaFum merged 19 commits into
mainfrom
claude/review-integrate-subagent-REvMX

Conversation

@DaFum

@DaFum DaFum commented May 15, 2026

Copy link
Copy Markdown
Owner

Summary

This PR removes unused prototype components, orphaned utility functions, and deprecated shim files while consolidating image generation logic to reduce duplication across the codebase.

Key Changes

Removed Files

  • src/ui/prototypes/VisualPrototypes.tsx (432 LOC) — Orphaned UI prototype components (TerminalReadout, CorruptedText, RhythmMatrix, SelloutContract) with no production consumers
  • src/utils/randomUtils.ts — Orphaned pickRandomSubset utility; functionality is duplicated in MapGenerator class
  • src/utils/imageGen.ts — Removed fetchGenImage and fetchGenImageAsObjectUrl functions (unused; caching logic was dead code)
  • Deprecated shim filessrc/components/stage/utils.ts, src/hooks/minigames/constants.ts, src/scenes/kabelsalat/constants.ts, src/scenes/kabelsalat/utils.ts
  • Test filestests/node/imageGen.test.js, tests/node/randomUtils.test.js, tests/ui/BrutalistUI.test.jsx, tests/node/compatibilityShims.test.js
  • Unused error handler codeRenderError class and withRetry function from src/utils/errorHandler.ts
  • Unused storage functionremoveSafeStorageItem from src/utils/storage.ts

Consolidated Image Generation

  • Added resolveGenImageUrl(prompt, isOnline?) helper in src/utils/imageGen.ts to replace ~15 inline ternary expressions across the codebase
  • Updated 15+ callsites to use the new consolidated helper:
    • src/hooks/useGigVisuals.ts
    • src/ui/ContrabandStash.tsx, src/ui/BandHQ.tsx, src/ui/BloodBankModal.tsx, src/ui/MerchPressModal.tsx
    • src/components/postGig/ZealotryGauge.tsx, src/components/postGig/DealCard.tsx, src/components/postGig/CompletePhase.tsx, src/components/postGig/SocialOptionButton.tsx
    • src/components/stage/CrowdTextureManager.ts, src/components/stage/EffectTextureManager.ts, src/components/stage/NoteTextureManager.ts
    • src/scenes/MainMenu.tsx, src/scenes/PostGig.tsx
    • src/scenes/kabelsalat/hooks/useKabelsalatBackground.ts
    • src/ui/bandhq/ShopItem.tsx

Clamping Utility Consolidation

  • Exported clamp0to100 from src/utils/gameStateUtils.ts (was private)
  • Replaced inline Math.max(0, Math.min(100, …)) expressions with clamp0to100 in:
    • src/utils/economyEngine.ts, src/utils/gigStats.ts
    • src/hooks/minigames/useRoadieLogic.ts, src/hooks/minigames/useTourbusLogic.ts
    • src/components/stage/AmpStageController.ts
    • src/scenes/kabelsalat/components/KabelsalatBoard.tsx

Removed Unused Action Types

  • Removed UPDATE_VOID_STRESS action type and createUpdateVoidStressAction creator (no callers)
  • Updated action type definitions and tests accordingly

Minigame Registry Simplification

  • Removed unused startAction, completeAction, and result calculator imports from src/utils/minigameRegistry.ts
  • Simplified registry to focus on scene mapping only

Test Updates

  • Removed withRetry

https://claude.ai/code/session_017vEMpyJMqscvqwtY4kxhT8

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@vercel

vercel Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
neurotoxic-game Ready Ready Preview, Comment May 16, 2026 5:00am

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 877a3ccd-5b6f-4b86-9dd2-48b66ef9a370

📥 Commits

Reviewing files that changed from the base of the PR and between 9abbed5 and f1671a1.

📒 Files selected for processing (77)
  • .agents/skills/writing-skills/anthropic-best-practices.md
  • .claude/skills/writing-skills/anthropic-best-practices.md
  • docs/audits/2026-05-15-codebase-audit.md
  • src/components/PixiStageController.ts
  • src/components/postGig/CompletePhase.tsx
  • src/components/postGig/DealCard.tsx
  • src/components/postGig/SocialOptionButton.tsx
  • src/components/postGig/ZealotryGauge.tsx
  • src/components/stage/AmpStageController.ts
  • src/components/stage/CrowdTextureManager.ts
  • src/components/stage/EffectTextureManager.ts
  • src/components/stage/NoteTextureManager.ts
  • src/components/stage/utils.ts
  • src/context/actionCreators.ts
  • src/context/actionTypes.ts
  • src/context/reducers/systemReducer.ts
  • src/hooks/minigames/constants.ts
  • src/hooks/minigames/useRoadieLogic.ts
  • src/hooks/minigames/useTourbusLogic.ts
  • src/hooks/rhythmGame/useRhythmGameScoring.ts
  • src/hooks/useBloodBank.ts
  • src/hooks/useGigVisuals.ts
  • src/hooks/useMerchPress.ts
  • src/scenes/MainMenu.tsx
  • src/scenes/PostGig.tsx
  • src/scenes/kabelsalat/components/KabelsalatBoard.tsx
  • src/scenes/kabelsalat/constants.ts
  • src/scenes/kabelsalat/hooks/useKabelsalatBackground.ts
  • src/scenes/kabelsalat/utils.ts
  • src/types/game.d.ts
  • src/ui/BandHQ.tsx
  • src/ui/BloodBankModal.tsx
  • src/ui/ContrabandStash.tsx
  • src/ui/MerchPressModal.tsx
  • src/ui/bandhq/ShopItem.tsx
  • src/ui/prototypes/VisualPrototypes.tsx
  • src/utils/economyEngine.ts
  • src/utils/errorHandler.ts
  • src/utils/gameStateUtils.ts
  • src/utils/gigStats.ts
  • src/utils/imageGen.ts
  • src/utils/minigameRegistry.ts
  • src/utils/randomUtils.ts
  • src/utils/socialEngine.ts
  • src/utils/storage.ts
  • symbols.json
  • tests/integration/GigIntegration.test.jsx
  • tests/logic/AmpStageController.test.js
  • tests/minigameRegistry.test.js
  • tests/node/CrowdManager.test.js
  • tests/node/NoteManager.test.js
  • tests/node/NoteSpritePool.test.js
  • tests/node/TourbusStageController.test.js
  • tests/node/compatibilityShims.test.js
  • tests/node/errorHandler.test.js
  • tests/node/imageGen.test.js
  • tests/node/randomUtils.test.js
  • tests/performance/EffectManager.bench.test.js
  • tests/performance/MainMenuStability.test.jsx
  • tests/performance/proceedToTour.bench.jsx
  • tests/performance/proceedToTourTime.bench.test.jsx
  • tests/ui/BandHQ.test.jsx
  • tests/ui/BrutalistUI.test.jsx
  • tests/ui/Gig.optimization.test.jsx
  • tests/ui/Gig.scene.test.jsx
  • tests/ui/KabelsalatScene.test.jsx
  • tests/ui/MainMenu.identity.test.jsx
  • tests/ui/MainMenu.test.jsx
  • tests/ui/Overworld.test.jsx
  • tests/ui/OverworldMap.cityStates.test.jsx
  • tests/ui/PostGig.component.test.jsx
  • tests/ui/PostGig.leaderboard.test.jsx
  • tests/ui/ShopItem.test.jsx
  • tests/ui/ZealotryGauge.test.jsx
  • tests/ui/actionTypes.test.jsx
  • tests/ui/uiMissingTargets.test.jsx
  • tests/ui/useKabelsalatState.test.jsx
💤 Files with no reviewable changes (19)
  • src/components/stage/utils.ts
  • src/types/game.d.ts
  • tests/node/TourbusStageController.test.js
  • src/hooks/minigames/constants.ts
  • tests/node/imageGen.test.js
  • tests/ui/actionTypes.test.jsx
  • src/scenes/kabelsalat/utils.ts
  • src/utils/storage.ts
  • tests/minigameRegistry.test.js
  • src/scenes/kabelsalat/constants.ts
  • tests/ui/BrutalistUI.test.jsx
  • tests/node/compatibilityShims.test.js
  • tests/node/randomUtils.test.js
  • src/utils/randomUtils.ts
  • src/ui/prototypes/VisualPrototypes.tsx
  • tests/node/NoteSpritePool.test.js
  • src/context/actionTypes.ts
  • tests/node/errorHandler.test.js
  • src/utils/errorHandler.ts

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added unified image URL resolution system for generated images.
  • Bug Fixes

    • Fixed numeric value handling in several calculations to properly treat zero as valid (not falsy).
  • Refactoring

    • Simplified image generation and numeric clamping logic across components.
    • Extracted shared utility functions for consistency.
    • Consolidated deprecated module re-exports.
  • Removals

    • Removed the void stress mechanic and related action type.
    • Removed unused prototype UI components.
    • Removed obsolete utility functions and helpers.

Walkthrough

This PR consolidates image URL generation across 20+ components by introducing a new resolveGenImageUrl() helper, exports shared clamping utilities (clamp0to100, clampZealotry, clampRelationship), removes the void-stress action mechanic, eliminates deprecated module re-exports, clears prototype UI components, simplifies the minigame registry, and strips out unused utility exports while updating test coverage throughout—accompanied by an audit report documenting the cleanup.

Changes

Image URL & Clamping Consolidation

Layer / File(s) Summary
Image generation refactoring
src/utils/imageGen.ts
Introduces resolveGenImageUrl(description, isOnline?) to replace three removed fetch/caching exports (fetchGenImage, fetchGenImageAsObjectUrl, clearImageCache); updates module comment.
Clamping utilities export and usage
src/utils/gameStateUtils.ts, src/context/reducers/systemReducer.ts, src/hooks/minigames/useRoadieLogic.ts, src/hooks/minigames/useTourbusLogic.ts, src/scenes/kabelsalat/components/KabelsalatBoard.tsx, src/utils/economyEngine.ts, src/utils/gigStats.ts, src/utils/socialEngine.ts
Exports clamp0to100 from gameStateUtils; imports and uses clampZealotry, clampRelationship across modules; replaces inline Math.max/Math.min clamping with utility calls.
PostGig scene & components image refactoring
src/components/postGig/CompletePhase.tsx, src/components/postGig/DealCard.tsx, src/components/postGig/SocialOptionButton.tsx, src/components/postGig/ZealotryGauge.tsx
Updates components to use resolveGenImageUrl(IMG_PROMPTS.*) for watermark/image URLs; switches controversy-level and zealotry handling from || to ?? operator.
Stage texture managers image refactoring
src/components/stage/AmpStageController.ts, src/components/stage/CrowdTextureManager.ts, src/components/stage/EffectTextureManager.ts, src/components/stage/NoteTextureManager.ts
Updates texture managers to use resolveGenImageUrl(IMG_PROMPTS.*) for crowd, effect, note texture URLs; applies clamp0to100 for interference/damage clamping.
UI & scene image URL refactoring
src/scenes/MainMenu.tsx, src/scenes/PostGig.tsx, src/ui/BandHQ.tsx, src/ui/BloodBankModal.tsx, src/ui/ContrabandStash.tsx, src/ui/MerchPressModal.tsx, src/ui/bandhq/ShopItem.tsx, src/scenes/kabelsalat/hooks/useKabelsalatBackground.ts
Resolves image URLs via resolveGenImageUrl(IMG_PROMPTS.*) instead of conditional getGenImageUrl/getGeneratedImageFallbackUrl selection across scenes and modals.
Hooks updated for image & clamping utilities
src/hooks/useGigVisuals.ts, src/hooks/useBloodBank.ts, src/hooks/useMerchPress.ts
Updates useGigVisuals to use resolveGenImageUrl for venue/character images; updates useBloodBank and useMerchPress to use nullish coalescing for fameLevel/money/harmony fallback handling.

Void Stress Mechanic & Action Removal

Layer / File(s) Summary
Action type & creator removal
src/context/actionTypes.ts, src/context/actionCreators.ts, src/types/game.d.ts
Removes UPDATE_VOID_STRESS from ActionTypes; removes createUpdateVoidStressAction function; updates GameAction union type.
useRhythmGameScoring void stress removal
src/hooks/rhythmGame/useRhythmGameScoring.ts
Removes updateBand from contextActions parameter; removes handleMiss void-stress dispatch logic.

Deprecated Re-export & Barrel Export Cleanup

Layer / File(s) Summary
Deprecated re-export removal from barrel modules
src/components/stage/utils.ts, src/hooks/minigames/constants.ts, src/scenes/kabelsalat/constants.ts, src/scenes/kabelsalat/utils.ts
Removes wildcard re-exports that forwarded deprecated barrel module exports.
Stage import path updates
src/components/PixiStageController.ts, tests/node/NoteManager.test.js, tests/node/TourbusStageController.test.js
Updates imports to target stageRenderUtils directly instead of the deprecated stage/utils re-export barrel.

UI Prototype & Component Removals

Layer / File(s) Summary
Prototype UI components removal
src/ui/prototypes/VisualPrototypes.tsx
Removes 6 exported prototype components (TerminalReadout, CorruptedText, RhythmMatrix, SelloutContract, ToxicChatter, VoidDecryptor) and all supporting interfaces/constants.
BrutalistUI tests removal
tests/ui/BrutalistUI.test.jsx
Removes entire test file covering prototype component tests.

Minigame Registry Structure Simplification

Layer / File(s) Summary
Minigame registry entry simplification
src/utils/minigameRegistry.ts
Updates MinigameRegistryEntry interface and MINIGAME_REGISTRY constant to remove startAction, completeAction, calculateResult fields, leaving only scene.
Minigame registry test updates
tests/minigameRegistry.test.js
Removes assertions for removed action/result fields; adds scene presence check in GAME_PHASES; removes ActionTypes import.

Utility Export & Implementation Cleanup

Layer / File(s) Summary
Economy constants de-export
src/utils/economyEngine.ts
Changes BAR_RATE_VIP, BAR_RATE_NORMAL, AVG_SPEND_PER_PERSON_AT_BAR, GLOBAL_PAYOUT_NERF, calculateDistance from exported to internal-only; applies clamp0to100 in Amp Calibration processing.
Error handler utility cleanup
src/utils/errorHandler.ts
Removes GameError.Render(...) factory method, RenderError class, and withRetry async helper; updates safeStorageOperation to call handleError(...) on fallback.
Error handler test cleanup
tests/node/errorHandler.test.js
Removes withRetry import and entire test suite.
Random sampling utility removal
src/utils/randomUtils.ts
Removes pickRandomSubset function and entire tests/node/randomUtils.test.js test file.
Storage utility cleanup
src/utils/storage.ts
Removes removeSafeStorageItem and hasSafeStorageItem functions.

Test Mock Updates for New Image Resolution API

Layer / File(s) Summary
Image generation mock updates across test files
30+ test files (tests/integration/*, tests/performance/*, tests/ui/*, tests/node/*)
Adds resolveGenImageUrl mock returning deterministic URLs or conditional fallback URLs to support components under test.
Logger mock updates
tests/logic/AmpStageController.test.js, tests/ui/KabelsalatScene.test.jsx
Adds LOG_LEVELS export to mocked logger module.
Test assertion updates
tests/ui/actionTypes.test.jsx
Removes UPDATE_VOID_STRESS from expected action types array.
Sprite pool disposal test update
tests/node/NoteSpritePool.test.js
Updates disposal assertions to verify container is set to null and sprite destroy() is called exactly once.
Image generation test file removal
tests/node/imageGen.test.js
Removes entire test file covering image URL generation, caching, offline behavior tests.

Symbol Index & Documentation Updates

Layer / File(s) Summary
Symbol index update
symbols.json
Removes exportPath metadata from stage/minigame/kabelsalat symbols; removes prototype UI, action, economy, error, random, storage symbols; adds clamp0to100 and resolveGenImageUrl entries.
Codebase audit documentation
docs/audits/2026-05-15-codebase-audit.md
Adds audit report with categorized findings (Duplicates, Orphaned Code, Inconsistencies, Dead Code, Missing Integration), severity summary, and prioritized cleanup checklist.
Documentation fence formatting fix
.agents/skills/writing-skills/anthropic-best-practices.md, .claude/skills/writing-skills/anthropic-best-practices.md
Corrects Markdown code fence formatting for pypdf example.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes


Possibly related PRs

  • DaFum/neurotoxic-game#1615: Directly inverse—main PR removes the void-stress action/mechanic that this PR introduced, so review together for full impact understanding.
  • DaFum/neurotoxic-game#1646: Both add audit report documentation; related cleanup effort.
  • DaFum/neurotoxic-game#1493: Both modify src/utils/imageGen.ts—main PR builds on offline/availability helpers introduced in that PR with the new resolveGenImageUrl abstraction.

Suggested labels

cleanup, refactoring, testing


Poem

🐰 Whiskers twitch with joy, dear coder friend,
As images now resolve without conditionals to bend,
Clamps brought together, voids sent away,
Deprecated exports cleared in one glorious day!
Tests shimmer brighter—oh what a sight,
Your codebase hops forward into the light.

✨ 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 claude/review-integrate-subagent-REvMX

@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown

📝 PR Kommentar-Zusammenfassung

Wird automatisch aktualisiert, sobald sich Kommentare ändern.

- [gemini-code-assist]: Since 'zealotryLevel' is an optional prop (number | undefined), passing it directly to 'clampZealotry' might cause issues if the helper expects a strict 'number'. Providing an explicit fallback ensures the UI renders correctly (e.g., 0%) when the value is missing. \`\`\`suggestion width: clampZealotry(zealotryLevel ?? 0) + '%' \`\`\`
- [gemini-code-assist]: For consistency with the adjacent 'equipmentDamage' field and the project's goal of consolidating clamping logic (as noted in the audit report D2), consider using the 'clampNonNegative' helper here instead of an inline 'Math.max' expression. \`\`\`suggestion contrabandDelivered: clampNonNegative(Number(contrabandDelivered) || 0) \`\`\`
- [gemini-code-assist]: The 'getGeneratedImageFallbackUrl' utility is no longer used directly in this file as it has been encapsulated within the new 'resolveGenImageUrl' helper. Removing this unused import helps keep the codebase clean. \`\`\` import { IMG_PROMPTS, resolveGenImageUrl } from '../utils/imageGen' \`\`\`

@github-actions

Copy link
Copy Markdown

Lint Fix Preview

Target roots:

  • src/

No changes would be made by running either formatting or lint auto-fixes.

Duplicate code

No significant duplicates found (per jscpd thresholds).

@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown

❌ Vitest UI tests failed

Showing relevant failure lines (full log is attached to the workflow run):


�[31m�[1mAssertionError�[22m: expected 0 to be greater than or equal to 4�[39m
�[31m�[1mAssertionError�[22m: expected 'url("mock-url")' to contain 'mock-kaminstube.jpg'�[39m
�[31m�[1mAssertionError�[22m: expected 'http://localhost:3000/mock-url' to match /mock-matze\.jpg$/�[39m
::error file=/home/runner/work/neurotoxic-game/neurotoxic-game/src/context/initialState.ts,title=tests/logic/AmpStageController.test.js,line=193,column=9::Error: [vitest] No "LOG_LEVELS" export is defined on the "../../src/utils/logger" mock. Did you forget to return it from "vi.mock"?%0AIf you need to partially mock a module, you can use "importOriginal" helper inside:%0A%0Avi.mock(import("../../src/utils/logger"), async (importOriginal) => {%0A  const actual = await importOriginal()%0A  return {%0A    ...actual,%0A    // your mocked methods%0A  }%0A})%0A%0A ❯ src/context/initialState.ts:193:9%0A ❯ src/utils/socialEngine.ts:23:1%0A%0A
::error file=/home/runner/work/neurotoxic-game/neurotoxic-game/tests/ui/Gig.optimization.test.jsx,title=tests/ui/Gig.optimization.test.jsx > Gig Optimization > calls getGenImageUrl multiple times on render,line=137,column=26::AssertionError: expected 0 to be greater than or equal to 4%0A ❯ tests/ui/Gig.optimization.test.jsx:137:26%0A%0A
::error file=/home/runner/work/neurotoxic-game/neurotoxic-game/tests/ui/Gig.scene.test.jsx,title=tests/ui/Gig.scene.test.jsx > Gig Scene Component > Initial Rendering > renders appropriate backgrounds based on venue or difficulty,line=189,column=9::AssertionError: expected 'url("mock-url")' to contain 'mock-kaminstube.jpg'%0A%0AExpected: "mock-kaminstube.jpg"%0AReceived: "url("mock-url")"%0A%0A ❯ tests/ui/Gig.scene.test.jsx:189:9%0A%0A
::error file=/home/runner/work/neurotoxic-game/neurotoxic-game/tests/ui/Gig.scene.test.jsx,title=tests/ui/Gig.scene.test.jsx > Gig Scene Component > Band Member Display > shows correct band member moods based on harmony,line=241,column=65::AssertionError: expected 'http://localhost:3000/mock-url' to match /mock-matze\.jpg$/%0A%0A- Expected:%0A/mock-matze\.jpg$/%0A%0A+ Received:%0A"http://localhost:3000/mock-url"%0A%0A ❯ tests/ui/Gig.scene.test.jsx:241:65%0A%0A
::error file=/home/runner/work/neurotoxic-game/neurotoxic-game/src/context/initialState.ts,title=tests/ui/KabelsalatScene.test.jsx,line=193,column=9::Error: [vitest] No "LOG_LEVELS" export is defined on the "../../src/utils/logger" mock. Did you forget to return it from "vi.mock"?%0AIf you need to partially mock a module, you can use "importOriginal" helper inside:%0A%0Avi.mock(import("../../src/utils/logger"), async (importOriginal) => {%0A  const actual = await importOriginal()%0A  return {%0A    ...actual,%0A    // your mocked methods%0A  }%0A})%0A%0A ❯ src/context/initialState.ts:193:9%0A ❯ src/utils/socialEngine.ts:23:1%0A%0A

See the CI logs for full output.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements several high-leverage cleanups identified in a codebase audit, focusing on removing dead code, consolidating duplicate logic, and enforcing state consistency. Key changes include the removal of the unused 'Void Stress' mechanic, the deletion of orphaned utility files and UI prototypes, and the consolidation of image generation logic into a single helper. Additionally, the PR replaces various inline clamping expressions with canonical helper functions and updates numeric fallbacks to use nullish coalescing. Feedback suggests further refining the clamping logic for consistency and removing now-unused imports resulting from the refactoring.

className='bg-blood-red h-full transition-all duration-500'
style={{
width: `${Math.min(100, Math.max(0, zealotryLevel))}%`
width: `${clampZealotry(zealotryLevel)}%`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since 'zealotryLevel' is an optional prop (number | undefined), passing it directly to 'clampZealotry' might cause issues if the helper expects a strict 'number'. Providing an explicit fallback ensures the UI renders correctly (e.g., 0%) when the value is missing.

Suggested change
width: `${clampZealotry(zealotryLevel)}%`
width: clampZealotry(zealotryLevel ?? 0) + '%'

Comment thread src/context/actionCreators.ts Outdated
payload: {
equipmentDamage: Math.max(0, Math.min(100, Number(equipmentDamage) || 0)),
equipmentDamage: clamp0to100(Number(equipmentDamage) || 0),
contrabandDelivered: Math.max(0, Number(contrabandDelivered) || 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the adjacent 'equipmentDamage' field and the project's goal of consolidating clamping logic (as noted in the audit report D2), consider using the 'clampNonNegative' helper here instead of an inline 'Math.max' expression.

Suggested change
contrabandDelivered: Math.max(0, Number(contrabandDelivered) || 0)
contrabandDelivered: clampNonNegative(Number(contrabandDelivered) || 0)
References
  1. Consolidate clamping logic using the clampNonNegative helper as noted in audit report D2. (link)

Comment on lines 14 to 18
import {
getGenImageUrl,
IMG_PROMPTS,
isImageGenerationAvailable,
resolveGenImageUrl,
getGeneratedImageFallbackUrl
} from '../utils/imageGen'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'getGeneratedImageFallbackUrl' utility is no longer used directly in this file as it has been encapsulated within the new 'resolveGenImageUrl' helper. Removing this unused import helps keep the codebase clean.

import {
  IMG_PROMPTS,
  resolveGenImageUrl
} from '../utils/imageGen'

Comment on lines 4 to 8
import {
getGenImageUrl,
IMG_PROMPTS,
isImageGenerationAvailable,
resolveGenImageUrl,
getGeneratedImageFallbackUrl
} from '../../utils/imageGen'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'getGeneratedImageFallbackUrl' utility is no longer used directly in this file following the consolidation of image generation logic into 'resolveGenImageUrl'. This import can be safely removed.

import {
  IMG_PROMPTS,
  resolveGenImageUrl
} from '../../utils/imageGen'

Tests mocking src/utils/imageGen need the new resolveGenImageUrl export
introduced by the imageGen helper extraction; MainMenu and other scenes
now consume it.
DaFum and others added 3 commits May 16, 2026 01:15
…nd tests

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
fix: resolve PR feedback for clamping logic and image gen fallback
@DaFum DaFum merged commit eadde06 into main May 16, 2026
17 checks passed
@DaFum DaFum deleted the claude/review-integrate-subagent-REvMX branch May 22, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants