Phase A: Extract duplicated functions - #707
Conversation
…/diffClass) Extract arrayBufferToBase64 from Table Seating (tsp.gts, analyze-floor-plan-command.gts) into utils/encoding.gts. Extract diffLabel and diffClass from Virtual Piano (virtual-piano.gts, music-sheet.gts) into utils/diff-helpers.gts. Both modules now import from their respective utils instead of duplicating code. Fixes: CS-12774 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Staging Submissions PreviewThis PR's content is pushed to the staging submissions realm: https://realms-staging.stack.cards/submissions/ Changed folders:
Updated at 2026-09-04 08:47:13 UTC for commit |
There was a problem hiding this comment.
🟡 Changes recommended
The extracted helpers introduce a confirmed performance regression for large buffers and a UI-visible behavior change for difficulty labels when no song is selected.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR reduces duplication by extracting common helper functions into shared utility modules within the Table Seating Planner and Virtual Piano packages, and updating the original call sites to import the shared helpers.
Changes:
- Added
utils/encoding.gtswitharrayBufferToBase64, and updated Table Seating Planner code to import it. - Added
utils/diff-helpers.gtswithdiffLabel/diffClass, and updated Virtual Piano + Music Sheet to import it. - Removed the now-duplicated in-file helper implementations.
File summaries
| File | Description |
|---|---|
| 41e20f-wedding-table-seating-planner/utils/encoding.gts | New shared encoding helper module for base64 conversion. |
| 41e20f-wedding-table-seating-planner/components/tsp.gts | Replaces local base64 helper with import from utils. |
| 41e20f-wedding-table-seating-planner/commands/analyze-floor-plan-command.gts | Replaces local base64 helper with import from utils. |
| 150b3a-virtual-piano/virtual-piano.gts | Replaces local difficulty helpers with import from utils. |
| 150b3a-virtual-piano/utils/diff-helpers.gts | New shared difficulty label/class helper module. |
| 150b3a-virtual-piano/music-sheet.gts | Replaces local difficulty helpers with import from utils. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ior change - utils/encoding.gts: restore tsp.gts's chunked implementation of arrayBufferToBase64 (the naive per-byte version regresses large buffers, up to 25MB floor plan uploads). - virtual-piano.gts: difficultyLabel now returns '' whenever difficulty is falsy (no song selected, or a song with no difficulty set), matching pre-extraction behavior instead of showing "UNKNOWN".
Summary
arrayBufferToBase64from Table Seating intoutils/encoding.gtsdiffLabel+diffClassfrom Virtual Piano intoutils/diff-helpers.gtsFixes: CS-12774
Part of: CS-12782 Master Catalog Refactor
Test plan
🤖 Generated with Claude Code