Skip to content

refactor(studio): extract pure helpers to src/util.js (step 2) - #17

Merged
byrongamatos merged 2 commits into
mainfrom
feat/es-module-split-util
Jul 8, 2026
Merged

refactor(studio): extract pure helpers to src/util.js (step 2)#17
byrongamatos merged 2 commits into
mainfrom
feat/es-module-split-util

Conversation

@byrongamatos

@byrongamatos byrongamatos commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

What

Step 2 of the studio migration. Moves 9 state-free helpers out of the IIFE into src/util.js:

_parseTimeInput, _formatTime, _formatDate, _esc, Path_stem, _eqLabel, _compLabel, _polarToCartesian, _describeArc

main.js imports them by the same names, so call sites are unchanged. Adds package.json (type:module, npm test) so the reusable CI runs the new tests/util.test.mjs real-import tests. main.js 2856 → 2799. Move-only, no behaviour change.

Tests

node --test 7/7, pytest 25/25 (backend unaffected). Codex preflight: 0.

Summary by CodeRabbit

  • New Features
    • Improved time entry support (e.g., M:SS with optional milliseconds) and consistent time display formatting.
    • More reliable, user-friendly date formatting.
  • Bug Fixes
    • Strengthened HTML escaping for safer interpolation.
    • More consistent filename stem handling, EQ/comp label summaries, and SVG arc geometry used in the interface.
  • Tests
    • Added automated coverage for parsing/formatting, escaping, path handling, and geometry helpers.
    • Tests can now be run via the standard Node test command.

Move 9 state-free helpers (_parseTimeInput, _formatTime, _formatDate, _esc,
Path_stem, _eqLabel, _compLabel, _polarToCartesian, _describeArc) out of the IIFE
into src/util.js, imported back by the same names (call sites unchanged). Adds
package.json (type:module, npm test) so the reusable CI runs the new
tests/util.test.mjs real-import tests. main.js 2856 -> 2799. Move-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 8, 2026 18:57
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fc274749-0136-4bbe-8016-3ca97ee40cee

📥 Commits

Reviewing files that changed from the base of the PR and between 8219625 and fc2a2f2.

📒 Files selected for processing (2)
  • package.json
  • src/util.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • src/util.js

📝 Walkthrough

Walkthrough

This PR extracts several state-free helper functions from src/main.js into src/util.js, updates main.js to import them, adds tests/util.test.mjs, a package.json test script, and a CHANGELOG entry.

Changes

Utility extraction cohort

Layer / File(s) Summary
New util.js helper module
src/util.js
Adds exported pure functions for time parsing/formatting, date formatting, HTML escaping, path stem extraction, EQ/comp labeling, and SVG arc geometry helpers.
main.js imports replace local helper definitions
src/main.js
Imports the helpers from ./util.js and removes the corresponding local function definitions at their former locations.
Tests, test tooling, and changelog
tests/util.test.mjs, package.json, CHANGELOG.md
Adds a Node test-runner suite for the new helpers, a package.json test script, and a CHANGELOG entry describing the move-only refactor.

Estimated code review effort: 2 (Simple) | ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: extracting pure studio helpers into src/util.js as a step-2 refactor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/es-module-split-util

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR continues the Studio ES-module migration by extracting a set of pure, state-free helper functions from src/main.js into a dedicated src/util.js module, then validating the new module via real ES-module imports using Node’s built-in test runner.

Changes:

  • Added src/util.js exporting nine pure helpers, keeping the original names to preserve existing call sites.
  • Updated src/main.js to import the extracted helpers and removed the inlined helper implementations.
  • Added Node test coverage for the helpers (tests/util.test.mjs) and introduced a minimal package.json to run those tests via npm test.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/util.test.mjs Adds Node node:test coverage for the extracted utility helpers via real ESM import.
src/util.js New module containing extracted pure helpers (exported under existing names).
src/main.js Imports helpers from ./util.js and removes their previous in-file definitions.
package.json Introduces ESM mode and an npm test script to run Node tests.
CHANGELOG.md Documents migration step 2 and the new test/CI entrypoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/util.js Outdated
Comment thread package.json Outdated
Address Copilot on #17: use 'node --test' (auto-discovery, no shell glob that
breaks on Windows); correct the _formatDate comment (new Date doesn't throw;
toLocaleDateString renders in host timezone, not UTC).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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