Skip to content

Update terror zone configuration to support new expansion JSON format#63

Merged
hyperremix merged 4 commits into
mainfrom
feat/terror-zone-string-ids
Feb 23, 2026
Merged

Update terror zone configuration to support new expansion JSON format#63
hyperremix merged 4 commits into
mainfrom
feat/terror-zone-string-ids

Conversation

@hyperremix
Copy link
Copy Markdown
Owner

@hyperremix hyperremix commented Feb 22, 2026

Summary

Updates the terror zone configuration feature to support the new "Reign of the Warlock" expansion JSON format where zone IDs changed from numeric (1-36) to string identifiers (e.g., Act1-BurialGrounds).

Key Changes

Terror Zone Configuration

  • Changed TerrorZone.id from number to string
  • Changed Settings.terrorZoneConfig from Record<number, boolean> to Record<string, boolean>
  • Updated zone name mapping to use string zone IDs
  • Added NUMERIC_TO_STRING_ZONE_ID mapping for backward compatibility migration
  • Updated terrorZoneService to handle new JSON structure with type and name wrapper fields
  • Updated all IPC handlers and type definitions

Automatic Migration

  • Added migrateTerrorZoneConfig() function in electron/database/settings.ts
  • Automatically converts old numeric configuration keys to new string keys when loading settings
  • Ensures backward compatibility with existing user configurations

Code Quality Improvements

  • Fixed Base UI module imports to use main package export instead of subpath imports
    • Resolves test environment module resolution issues
    • Updated 13 UI component files
  • Fixed 15 non-null assertion warnings in test files
    • Replaced element! with proper null checks: expect(element).toBeTruthy(); element as Type
    • Updated test files: ItemCard.test.tsx, ItemDetailsDialog.test.tsx, RunList.test.tsx

Zone ID Mapping

All 36 terror zones now use string identifiers:

  • Act 1: Act1-BurialGrounds, Act1-Catacombs, Act1-ColdPlains, etc.
  • Act 2: Act2-Sewers, Act2-RockyWaste, Act2-DryHills, etc.
  • Act 3: Act3-SpiderForest, Act3-GreatMarsh, Act3-FlayerJungle, etc.
  • Act 4: Act4_OuterSteppes, Act4-RiverOfFlame, Act4-ChaosSanctuary
  • Act 5: Act5-BloodyFoothils, Act5-ArreatPlateau, Act5-CrystallinePassage, etc.

Test plan

  • All TypeScript type checking passes (bun run typecheck)
  • All code formatting passes (bun run format)
  • All linting passes without warnings (bun run lint)
  • All combined checks pass (bun run check)
  • All 637 tests pass across 33 test files (bun run test:run)
  • Terror zone service tests updated and passing
  • Manual test: Load app with existing numeric terrorZoneConfig - verify migration works
  • Manual test: Toggle zones on/off - verify game file is written correctly with new format
  • Manual test: Verify search works with new string IDs
  • Manual test: Verify "Restore Original" functionality works
  • Manual test: Test with actual expansion JSON file from D2R installation

🤖 Generated with Claude Code

Support the new "Reign of the Warlock" expansion JSON format where zone IDs
changed from numeric (1-36) to string identifiers (e.g., "Act1-BurialGrounds").

Key changes:
- Changed TerrorZone.id and Settings.terrorZoneConfig from number to string types
- Updated terrorZoneNames mapping to use string zone IDs
- Added NUMERIC_TO_STRING_ZONE_ID mapping for backward compatibility
- Updated terrorZoneService to handle new JSON structure with type and name fields
- Added automatic migration in settings.ts to convert old numeric configs to string IDs
- Fixed Base UI module imports to resolve test environment issues
- Fixed non-null assertion warnings in test files

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 22, 2026

hyperremix and others added 3 commits February 22, 2026 16:38
Add per-setting-key warning deduplication to prevent repeated
"[object Object]" warnings during application startup. Also add
automatic cleanup of corrupted settings from the database.

Changes:
- Add warnedKeys Set to track which settings have been warned about
- Modify parseJSON to accept optional settingKey parameter
- Update all parseJSONSetting calls to pass setting key name
- Add cleanupCorruptedSettings function to delete corrupted settings
- Call cleanup during database schema initialization
- Import eq from drizzle-orm for proper where clause syntax

This ensures users only see one warning per corrupted setting instead
of repeated spam, and corrupted settings are automatically cleaned up
on app start.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add conversion from legacy numeric zone IDs (1-36) to string zone IDs
(e.g., "Act1-BurialGrounds") to properly display zone names in the UI.
Previously, numeric IDs would fall back to "Zone X" display.

Changes:
- Update readZonesFromFile to detect numeric vs string zone IDs
- Convert numeric IDs using NUMERIC_TO_STRING_ZONE_ID mapping
- Assign proper human-readable names from TERROR_ZONE_NAMES
- Add tests for numeric ID conversion and unknown ID handling
- Update createZonesJson test helper to accept numeric IDs

This ensures users see proper zone names like "Burial Grounds, Crypt,
and Mausoleum" instead of "Zone 1" in the terror zone configuration UI.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update NUMERIC_TO_STRING_ZONE_ID to use 0-based indexing that matches
the actual zone indices in desecratedzones.json. Create exhaustive
mapping from 0-36 with no gaps.

Key fixes:
- Zone 18: 'Act2-AncientTunnels' → 'Act2-TalRashas'
- Zone 28: 'Act4-CityOfTheDamned' → 'Act4-ChaosSanctuary'
- Add missing zones 10, 12, 13 for backward compatibility:
  - Zone 10: 'Act1-StonyField'
  - Zone 12: 'Act1-BlackMarsh'
  - Zone 13: 'Act1-Pit'
- Changed from 1-based (1-36) to 0-based (0-36) indexing
- Updated terrorZoneService test to use correct zone IDs

This fixes the issue where zones 18, 28, and others were showing as
"Zone X" instead of their actual names in the terror zone configuration.
All zone indices now have proper mappings to display correct names.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@hyperremix hyperremix force-pushed the feat/terror-zone-string-ids branch from 0b20ecc to e13b96a Compare February 22, 2026 18:48
@hyperremix
Copy link
Copy Markdown
Owner Author

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e13b96af4d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

5: 'Act1-BloodMoor',
6: 'Act1-Jail',
7: 'Act1-MooMooFarm',
8: 'Act1-Tristram',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Map legacy numeric zone IDs by ID, not by array order

migrateTerrorZoneConfig in electron/database/settings.ts depends on NUMERIC_TO_STRING_ZONE_ID, but this table reassigns legacy ID 8 to Act1-Tristram even though prior numeric IDs in this codebase used 8 for Stony Field (and 12 for Tristram). That means upgrades with existing numeric terrorZoneConfig will silently disable/enable the wrong zones after migration. The conversion table needs to preserve the old numeric ID semantics, not the new array position.

Useful? React with 👍 / 👎.

Comment on lines +86 to 89
32: 'Act5-AncientsWay',
33: 'Act5-FrozenTundra',
34: 'Act5-WorldstoneKeep',
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add mappings for legacy terror zone IDs 35 and 36

The migration map ends at 34, but previous persisted configs could contain IDs 35 and 36. During migrateTerrorZoneConfig, those keys are left as '35'/'36', which do not match any current string zone IDs, so user preferences for those zones are dropped and they revert to defaults after upgrade. Include explicit conversions (or a deterministic fallback) for all legacy IDs to avoid silent data loss.

Useful? React with 👍 / 👎.

@hyperremix hyperremix merged commit 38da993 into main Feb 23, 2026
5 checks passed
@hyperremix hyperremix deleted the feat/terror-zone-string-ids branch February 23, 2026 05: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.

2 participants