Skip to content

Phase A: Extract duplicated functions - #707

Merged
lucaslyl merged 3 commits into
mainfrom
cs-12774-phase-a-quick-wins-extract-duplicated-functions
Sep 4, 2026
Merged

Phase A: Extract duplicated functions#707
lucaslyl merged 3 commits into
mainfrom
cs-12774-phase-a-quick-wins-extract-duplicated-functions

Conversation

@lucaslyl

@lucaslyl lucaslyl commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extract arrayBufferToBase64 from Table Seating into utils/encoding.gts
  • Extract diffLabel + diffClass from Virtual Piano into utils/diff-helpers.gts
  • Both modules now import from their respective utils, eliminating duplication

Fixes: CS-12774
Part of: CS-12782 Master Catalog Refactor

Test plan

  • Table Seating renders (check tsp component + floor plan analyzer)
  • Virtual Piano renders (check piano + music sheet)
  • No lint errors

🤖 Generated with Claude Code

…/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>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Staging Submissions Preview

This PR's content is pushed to the staging submissions realm: https://realms-staging.stack.cards/submissions/

Changed folders:

  • 150b3a-virtual-piano/
  • 41e20f-wedding-table-seating-planner/

Updated at 2026-09-04 08:47:13 UTC for commit 1626007. Shared realm: only this PR's changed files are pushed; files touched by multiple PRs reflect whichever pushed last, and deleted files are not removed.

@lucaslyl lucaslyl self-assigned this Sep 4, 2026
@lucaslyl
lucaslyl requested a review from a team September 4, 2026 07:46
@richardhjtan
richardhjtan requested a lite review from Copilot September 4, 2026 08:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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.gts with arrayBufferToBase64, and updated Table Seating Planner code to import it.
  • Added utils/diff-helpers.gts with diffLabel/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.

Comment thread 150b3a-virtual-piano/utils/diff-helpers.gts
Comment thread 41e20f-wedding-table-seating-planner/utils/encoding.gts
…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".
@lucaslyl
lucaslyl merged commit e0e6799 into main Sep 4, 2026
3 checks passed
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.

3 participants