refactor(engine): tween-to-galaxy helper dedup#42
Merged
Conversation
Extract the cloud-row -> camera tween dispatch shared by selectFamous, selectByAlias, and focusOn into one helper. Cam-null guard included defensively for the post-destroy / pre-bootstrap race window. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…/focusOn Three duplicated cloud-row -> camera tween dispatches collapse to one helper call each. ~50 lines removed from engine.ts; focusOnHome keeps its bespoke tween (different toTarget / yaw / pitch shape). The cam-null guard stays in focusOn ahead of cb.onFocusChange so the URL-sync hook doesn't fire during the pre-bootstrap window; the helper's own guard absorbs the no-op for selectFamous and selectByAlias where the callback already fired. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
skymap | 50836c5 | Commit Preview URL Branch Preview URL |
May 07 2026, 11:36 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/services/engine/tweenToGalaxy.tscollapses three near-identical "build CameraTween from a galaxy + start it + requestRender" implementations into one helper.focusOn,selectFamous, andselectByAliaseach become a one-linertweenToGalaxy(state, info)after their existing pre-tween bookkeeping (selection, onFocusChange).focusOnHomekeeps its bespoke tween (different toTarget / yaw / pitch shape) — no duplication to dedup there.Implementation notes
TweenTarget = { x, y, z, diameterKpc }rather thanPointInfoso the contract documents exactly what the helper reads.PointInfois structurally compatible — production callers passinfodirectly.focusOnwe keep a separate early-return ahead ofcb.onFocusChangeso the URL-sync hook doesn't fire during the pre-bootstrap window; inselectFamous/selectByAliasthe callback already fires before the tween, so removing their local cam-null check changes nothing observable.cloud.x[localIdx]/cloud.y[localIdx]/ etc., butPointCloudactually stores positions as an interleavedpositions: Float32Array. Each call site already builds aPointInfo(for the InfoCard / focus callback), so taking the info directly is both more correct and cheaper than re-deriving xyz inside the helper.Test plan
tweenToGalaxy.test.ts(3/3): happy path, cam.target snapshot isolation, cam-null no-opnpx tsc --noEmitcleanSpec:
docs/superpowers/specs/2026-05-08-engine-internal-restructure-design.mdPlan:
docs/superpowers/plans/2026-05-08-engine-internal-restructure.md(Phase 2)Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com