Skip to content

Conversation

@takaokouji
Copy link

Summary

Implements hex-based URL shortening for the only_blocks parameter to reduce URL length from ~1814 characters to approximately half size, and eliminates code duplication through refactoring.

Key Features

  • Hex format encoding: Uses binary bitmap (1=visible, 0=hidden) with hexadecimal representation
  • Backward compatibility: Legacy comma/period format still supported
  • URL identification: Hex format identified by leading '0' character
  • Block ordering: motion→looks→sound→events→control→sensing→operators
  • LSB-first bit ordering: Proper block-to-bit mapping

Implementation Details

URL Format Examples

  • Legacy: only_blocks=motion_movesteps,looks_say
  • Hex: only_blocks=01008000000000000000000000000000 (much shorter for complex selections)

Code Organization

  • src/lib/block-utils.js: Centralized block utilities and hex parsing logic
  • Eliminated duplication: Refactored shared code between make-toolbox-xml.js and block-display-modal.jsx
  • Test coverage: Comprehensive TDD approach with both unit and integration tests

Files Changed

  • src/lib/block-utils.js (new): Shared utility functions
  • src/lib/make-toolbox-xml.js: Added hex format support
  • src/components/block-display-modal/block-display-modal.jsx: Updated URL generation, removed duplicates
  • src/reducers/block-display.js: Updated imports
  • test/unit/only-blocks-initialization.test.js: Comprehensive hex format tests
  • test/unit/make-toolbox-xml-hex.test.js: Integration tests

Test Coverage

✅ All existing functionality preserved
✅ Hex format parsing and generation
✅ Block selection/deselection logic
✅ URL generation with proper encoding
✅ Backward compatibility with legacy formats
✅ Edge cases (empty selections, all selections)

🤖 Generated with Claude Code

takaokouji and others added 3 commits September 1, 2025 17:57
Implement hexadecimal encoding for only_blocks parameter to compress long URLs
from ~1814 characters to approximately half the size.

Features:
- Binary bitmap representation where 1=visible block, 0=hidden block
- Leading '0' identifier to distinguish hex format from block IDs
- Hexadecimal encoding with LSB-first bit ordering
- Full backward compatibility with comma/period separated format
- Block order follows categories: motion→looks→sound→events→control→sensing→operators

Implementation:
- Add parseHexFormat() function for hex to block selection conversion
- Add generateBlockOrder() function for consistent block ordering
- Update generateOnlyBlocksUrl() to generate hex format URLs
- Comprehensive test coverage with TDD approach

The hex format significantly reduces URL length while maintaining full
functionality and backward compatibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fix bug where hex format only_blocks parameter was not properly parsed
in make-toolbox-xml.js, causing blocks to disappear from the toolbox.

The issue was that parseOnlyBlocks() function in make-toolbox-xml.js only
supported legacy comma/period separated format, but not the new hex format.

Changes:
- Add hex format parsing support to parseOnlyBlocks() function
- Include binary-to-block mapping logic matching block-display-modal.jsx
- Add comprehensive test coverage for hex format in make-toolbox-xml.js
- Update existing test with better failure detection

This ensures that hex format URLs like '00048ffffffffffffffffffff7'
correctly display motion_setx block only + all blocks from other categories,
instead of hiding all blocks.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Create shared src/lib/block-utils.js with centralized block utilities
- Move CATEGORY_BLOCKS, parseHexFormatToSelectedBlocks, generateBlockOrder,
  and initializeBlockSelectionFromOnlyBlocks to shared location
- Update imports in make-toolbox-xml.js, block-display-modal.jsx,
  and block-display.js reducers
- Remove duplicate function definitions and unused imports
- All tests passing, no lint errors

Fixes code duplication between make-toolbox-xml.js and
block-display-modal.jsx

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@takaokouji takaokouji merged commit 27b73d0 into develop Sep 1, 2025
2 checks passed
@takaokouji takaokouji deleted the feature/hex-only-blocks-parameter branch September 1, 2025 14:28
github-actions bot pushed a commit that referenced this pull request Sep 1, 2025
…nly-blocks-parameter

feat: implement hex format for only_blocks URL parameter
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