Skip to content

Fix data-correctness bugs and remove dead/debug code - #17

Merged
ImJakeDev merged 3 commits into
mainfrom
code-review
Jul 15, 2026
Merged

Fix data-correctness bugs and remove dead/debug code#17
ImJakeDev merged 3 commits into
mainfrom
code-review

Conversation

@ImJakeDev

Copy link
Copy Markdown
Owner

Summary

  • Fixes bugs surfaced by a full-codebase review: unguarded empty author_names arrays, unstable index-based React keys where stable slugs/ids were already available, sequential awaits for independent content loads, an empty search-param falling through the pokemon page's name fallback and its swallowed TCGdex error, a missing geolocation timeout, a missing axios timeout on the pokemon fetch, and invalid text-shadow CSS shorthand.
  • Removes useOpen5eSpecies.ts (confirmed unused anywhere, and it calls a v2 Open5e endpoint that 404s) and leftover debug console.log/commented-out JSX from the in-progress Profile character sheet component.
  • Incidental Prettier reformatting of Footer.tsx and Pokémon.tsx, required by the pre-commit hook's whole-tree format check (pre-existing formatting drift, unrelated to the logic changes).

Test plan

  • pnpm check:format / check:styles / check:lint / check:types all pass (via pre-commit hook)
  • vitest run — all existing tests pass
  • next build --webpack succeeds, all 15 routes generate (including /books/[book], /articles/[slug], /blog/[slug])
  • Manual smoke test in browser (dev server)

🤖 Generated with Claude Code

Fixes bugs surfaced by a full-codebase review: unguarded empty
author_names arrays, unstable index-based React keys where stable
slugs/ids were already available, sequential awaits for independent
content loads, an empty search-param falling through pokemon page's
name fallback and its swallowed TCGdex error, a missing geolocation
timeout, a missing axios timeout on the pokemon fetch, and invalid
text-shadow CSS shorthand.

Also removes useOpen5eSpecies.ts (unused everywhere, and calling a
v2 endpoint that 404s) and leftover debug console.log/commented-out
JSX from the in-progress Profile character sheet component.

Includes incidental Prettier reformatting of Footer.tsx and
Pokémon.tsx, required by the pre-commit hook's whole-tree format
check.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
jakes-digital-garden Ready Ready Preview, Comment Jul 15, 2026 7:53pm

Profile.tsx now builds a fully random level-1 character on load instead
of a static template: race + class from dnd5eapi.co's SRD data (ability
bonuses, saving throws, skill proficiency choices, hit die, starting
equipment, spellcasting), and background from Open5e (58 backgrounds,
filtered to the ~20 with parseable Personality/Ideal/Bond/Flaw tables
for the flavor fields). All values are placed into the existing sheet
inputs/textareas, no new UI elements.

Removes useRandom5eSpecies.ts and Open5eRacesResponse.ts, unused now
that race data comes from dnd5eapi.co instead of Open5e's species
endpoint.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ImJakeDev
ImJakeDev marked this pull request as ready for review July 15, 2026 19:30
@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR applies a set of targeted correctness fixes and removes confirmed-dead code across the codebase. The largest change is a substantial rewrite of Profile.tsx, replacing a stub with a functional D&D 5e character-sheet generator backed by three API hooks.

  • Bug fixes: guards for empty author_names arrays, stable slug/key-based React keys, Promise.all for parallelised home-page fetches, empty-string search-param handling on the Pokémon page, TCGdex error surfacing, geolocation and Axios timeouts, and a valid text-shadow CSS shorthand.
  • Dead-code removal: useOpen5eSpecies.ts (broken v2 endpoint), useRandom5eSpecies.ts (v1 endpoint), their shared type file, and all debug console.log/commented-out JSX blocks.
  • Profile.tsx rewrite: dice-rolling, race ability-score bonuses, class skill/save proficiencies, background characteristics, and spell-casting stats are now computed from live API data and bound as defaultValue props on the character-sheet form inputs.

Confidence Score: 5/5

Safe to merge — every changed path is either a well-scoped correctness fix, a cleanup of confirmed-dead code, or a Prettier reformat required by the pre-commit hook.

All bug fixes are narrow and additive (null-coalescing guards, key stabilisation, Promise.all, timeout options, CSS shorthand correction). The Profile rewrite is the most complex change, but the dependency graph through useMemo is sound: each random pick is computed exactly once per data-load, all getRandomArrayIndex call sites are guarded against empty inputs, and passive perception now correctly accounts for Perception proficiency. No correctness issues were found across the 16 changed files.

No files require special attention. Profile.tsx has the highest surface area but its logic holds up under scrutiny.

Important Files Changed

Filename Overview
src/components/Profile.tsx Major rewrite from stub to functional D&D 5e character-sheet generator; ability scores, saves, skills, HP, and background characteristics are all computed from live API data with appropriate guards.
src/services/hooks/useDnD5eClasses.ts New hook file; defines CLASSES const, Zod schemas, and useDnD5eClasses/useDnD5eClass queries with a 10 s Axios timeout and Infinity staleTime.
src/services/hooks/useOpen5eBackgrounds.ts New hook file; fetches Open5e backgrounds, parses Markdown personality/ideal/bond/flaw tables with proper regex escaping via escapeRegExp, and exports getSuggestedCharacteristics.
src/utils/getRandomArrayIndex.ts Now throws a descriptive error on empty input instead of silently returning undefined; accepts readonly arrays; all call sites are properly guarded.
src/app/pokemon/page.tsx Fixes empty-string search-param falling through the 'pikachu' fallback, aligns TCGdex queryKey with the resolved name, and surfaces TCGdex errors to the UI.
src/app/page.tsx Sequential awaits replaced with Promise.all; index-based React keys replaced with article.slug and post.slug; Prettier reformatting.
src/components/design-system/Colors.tsx Fixes invalid text-shadow shorthand — was a bare CSS variable, now correctly includes offset-x, offset-y, and blur-radius (0 0 2px).
src/services/hooks/usePokémon.ts Extracts a named axios instance with a 10 s timeout; eliminates the double-await anti-pattern in the original fetch call.
src/utils/useUserGeolocation.ts Adds a 10 s timeout option to getCurrentPosition, preventing the hook from hanging indefinitely when geolocation is slow or unavailable.
src/components/BookList.tsx Replaces index key with book.work.key and adds ?? 'Unknown' author fallback; both are correct fixes.
src/app/books/[book]/page.tsx Adds ?? 'Unknown' fallback for author_names[0] to handle books with an empty author array.

Reviews (2): Last reviewed commit: "Fix character sheet review issues" | Re-trigger Greptile

Comment thread src/components/Profile.tsx Outdated
Comment thread src/utils/getRandomArrayIndex.ts
Comment thread src/services/hooks/useOpen5eBackgrounds.ts Outdated
@ImJakeDev
ImJakeDev merged commit 826e763 into main Jul 15, 2026
4 checks passed
@ImJakeDev
ImJakeDev deleted the code-review branch July 15, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant