Remove orphaned code and consolidate image generation utilities#1647
Conversation
Categorized findings (duplicates, orphaned code, inconsistencies, dead code, missing integration) used to drive the autonomous cleanup pass on this branch.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (77)
💤 Files with no reviewable changes (19)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR consolidates image URL generation across 20+ components by introducing a new ChangesImage URL & Clamping Consolidation
Void Stress Mechanic & Action Removal
Deprecated Re-export & Barrel Export Cleanup
UI Prototype & Component Removals
Minigame Registry Structure Simplification
Utility Export & Implementation Cleanup
Test Mock Updates for New Image Resolution API
Symbol Index & Documentation Updates
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
📝 PR Kommentar-ZusammenfassungWird automatisch aktualisiert, sobald sich Kommentare ändern. |
Lint Fix PreviewTarget roots:
No changes would be made by running either formatting or lint auto-fixes. Duplicate codeNo significant duplicates found (per jscpd thresholds). |
❌ Vitest UI tests failedShowing relevant failure lines (full log is attached to the workflow run): See the CI logs for full output. |
There was a problem hiding this comment.
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)}%` |
There was a problem hiding this comment.
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.
| width: `${clampZealotry(zealotryLevel)}%` | |
| width: clampZealotry(zealotryLevel ?? 0) + '%' |
| payload: { | ||
| equipmentDamage: Math.max(0, Math.min(100, Number(equipmentDamage) || 0)), | ||
| equipmentDamage: clamp0to100(Number(equipmentDamage) || 0), | ||
| contrabandDelivered: Math.max(0, Number(contrabandDelivered) || 0) |
There was a problem hiding this comment.
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.
| contrabandDelivered: Math.max(0, Number(contrabandDelivered) || 0) | |
| contrabandDelivered: clampNonNegative(Number(contrabandDelivered) || 0) |
References
- Consolidate clamping logic using the clampNonNegative helper as noted in audit report D2. (link)
| import { | ||
| getGenImageUrl, | ||
| IMG_PROMPTS, | ||
| isImageGenerationAvailable, | ||
| resolveGenImageUrl, | ||
| getGeneratedImageFallbackUrl | ||
| } from '../utils/imageGen' |
There was a problem hiding this comment.
| import { | ||
| getGenImageUrl, | ||
| IMG_PROMPTS, | ||
| isImageGenerationAvailable, | ||
| resolveGenImageUrl, | ||
| getGeneratedImageFallbackUrl | ||
| } from '../../utils/imageGen' |
There was a problem hiding this comment.
Tests mocking src/utils/imageGen need the new resolveGenImageUrl export introduced by the imageGen helper extraction; MainMenu and other scenes now consume it.
…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
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 consumerssrc/utils/randomUtils.ts— OrphanedpickRandomSubsetutility; functionality is duplicated inMapGeneratorclasssrc/utils/imageGen.ts— RemovedfetchGenImageandfetchGenImageAsObjectUrlfunctions (unused; caching logic was dead code)src/components/stage/utils.ts,src/hooks/minigames/constants.ts,src/scenes/kabelsalat/constants.ts,src/scenes/kabelsalat/utils.tstests/node/imageGen.test.js,tests/node/randomUtils.test.js,tests/ui/BrutalistUI.test.jsx,tests/node/compatibilityShims.test.jsRenderErrorclass andwithRetryfunction fromsrc/utils/errorHandler.tsremoveSafeStorageItemfromsrc/utils/storage.tsConsolidated Image Generation
resolveGenImageUrl(prompt, isOnline?)helper insrc/utils/imageGen.tsto replace ~15 inline ternary expressions across the codebasesrc/hooks/useGigVisuals.tssrc/ui/ContrabandStash.tsx,src/ui/BandHQ.tsx,src/ui/BloodBankModal.tsx,src/ui/MerchPressModal.tsxsrc/components/postGig/ZealotryGauge.tsx,src/components/postGig/DealCard.tsx,src/components/postGig/CompletePhase.tsx,src/components/postGig/SocialOptionButton.tsxsrc/components/stage/CrowdTextureManager.ts,src/components/stage/EffectTextureManager.ts,src/components/stage/NoteTextureManager.tssrc/scenes/MainMenu.tsx,src/scenes/PostGig.tsxsrc/scenes/kabelsalat/hooks/useKabelsalatBackground.tssrc/ui/bandhq/ShopItem.tsxClamping Utility Consolidation
clamp0to100fromsrc/utils/gameStateUtils.ts(was private)Math.max(0, Math.min(100, …))expressions withclamp0to100in:src/utils/economyEngine.ts,src/utils/gigStats.tssrc/hooks/minigames/useRoadieLogic.ts,src/hooks/minigames/useTourbusLogic.tssrc/components/stage/AmpStageController.tssrc/scenes/kabelsalat/components/KabelsalatBoard.tsxRemoved Unused Action Types
UPDATE_VOID_STRESSaction type andcreateUpdateVoidStressActioncreator (no callers)Minigame Registry Simplification
startAction,completeAction, and result calculator imports fromsrc/utils/minigameRegistry.tsTest Updates
withRetryhttps://claude.ai/code/session_017vEMpyJMqscvqwtY4kxhT8