Skip to content

refactor: shrink YAGNI signatures - #194

Merged
EtienneLescot merged 2 commits into
release/v1.8.0from
ponytail/shrink-yagni-signatures
Jul 29, 2026
Merged

refactor: shrink YAGNI signatures#194
EtienneLescot merged 2 commits into
release/v1.8.0from
ponytail/shrink-yagni-signatures

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

refactor: shrink YAGNI signatures

Four mechanical shrinks from the v1.8.0 ponytail audit. Pure refactor, no
behavior change.

Changes

  1. Drop the single-impl cursor interface. CursorNativeAdapter had exactly one implementation (TelemetryCursorAdapter); the interface is gone and the class carries the shape directly. electron/native-bridge/cursor/adapter.ts is deleted; CursorTelemetryLoadResult now lives next to the class. cursorService.ts and ipc/nativeBridge.ts import the class (or the new type) instead.

  2. Remove unused parameters from clamp helpers.

    • clampFocusToDepth(focus, _depth)clampFocus(focus) (renamed; the depth argument was never read).
    • clampFocusToStage(focus, depth, _stageSize)clampFocusToStage(focus, depth) (the stage size was never read; depth is still required for the bounds).
  3. Collapse parseCustomPlaybackSpeedInput. The 22-line re-implementation of Number() + clamp (with a draft round-trip that stripped invalid characters and rebuilt the input) is replaced with the spec's one-liner and a single finite-check. The discriminated union keeps empty/too-fast/too-slow/valid; the only valid path now carries the speed. Two tests that pinned the old round-trip (the "1.2.3 → 1.23" parse and the "1,1 → draft: 1.1" normalization) are updated to match the new shape — the behavior change is exactly the spec's "drop the round-trip artifact" intent.

  4. NativeBridgeStateStore class → plain object factory. The 4-method class is replaced with a NativeBridgeState interface and a createNativeBridgeState(platform) factory. The returned object is a plain shape with the four setters as direct property assignments plus a getState() accessor. The data shape becomes an internal NativeBridgeStateData (not exported) since only the factory and the type need it.

Type of change

  • Refactor / maintenance

Release impact

  • Minor

Desktop impact

  • Not platform-specific

Testing

# Typecheck
npx tsc --noEmit       # exit 0

# Unit tests
npm run test           # 1144 / 1144 passed

# Lint
npm run lint           # 0 errors, 7 warnings (all pre-existing on
                       # release/v1.8.0: NewProjectModal.test.tsx,
                       # rafCoalesce.test.ts, useNativeCompositorView.ts)

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 549adf1e-da31-4665-bc37-dbf46ea9e767

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ponytail/shrink-yagni-signatures

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

EtienneLescot and others added 2 commits July 29, 2026 10:28
Four mechanical shrinks from the v1.8.0 ponytail audit. Pure refactor, no behavior change.

1. Drop the single-impl cursor interface. CursorNativeAdapter had exactly one implementation (TelemetryCursorAdapter); the interface is gone and the class carries the shape directly. electron/native-bridge/cursor/adapter.ts is deleted; CursorTelemetryLoadResult now lives next to the class. cursorService.ts and ipc/nativeBridge.ts import the class (or the new type) instead.

2. Remove unused parameters from clamp helpers. clampFocusToDepth(focus, _depth) becomes clampFocus(focus) (renamed; the depth argument was never read). clampFocusToStage(focus, depth, _stageSize) becomes clampFocusToStage(focus, depth) (the stage size was never read; depth is still required for the bounds).

3. Collapse parseCustomPlaybackSpeedInput. The 22-line re-implementation of Number() + clamp (with a draft round-trip that stripped invalid characters and rebuilt the input) is replaced with a one-liner and a single finite-check. The discriminated union keeps empty/too-fast/too-slow/valid; the only valid path now carries the speed. Two tests that pinned the old round-trip are updated to match the new shape.

4. NativeBridgeStateStore class -> plain object factory. The 4-method class is replaced with a NativeBridgeState interface and a createNativeBridgeState(platform) factory. The returned object is a plain shape with the four setters as direct property assignments plus a getState() accessor. The data shape becomes an internal NativeBridgeStateData (not exported) since only the factory and the type need it.
The clamp formula was re-inlined byte-identical to clampPlaybackSpeed, which is
still live in types.ts — two copies of the same rounding rule, and this one
feeds the native scene.

rawValue was also widened to string | null | undefined in a PR shrinking YAGNI
signatures; the sole caller passes a useState("") value that is never nullish.
@EtienneLescot
EtienneLescot force-pushed the ponytail/shrink-yagni-signatures branch from c1e653c to 9af8695 Compare July 29, 2026 08:33
@EtienneLescot
EtienneLescot merged commit 7547561 into release/v1.8.0 Jul 29, 2026
9 checks passed
@EtienneLescot
EtienneLescot deleted the ponytail/shrink-yagni-signatures branch July 29, 2026 08:38
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