Skip to content

feat(web): tune carrot dwell + cap max zoom#134

Merged
naorsabag merged 8 commits into
masterfrom
feat/web-anim-pacing
May 11, 2026
Merged

feat(web): tune carrot dwell + cap max zoom#134
naorsabag merged 8 commits into
masterfrom
feat/web-anim-pacing

Conversation

@naorsabag
Copy link
Copy Markdown
Owner

@naorsabag naorsabag commented May 11, 2026

Summary

Two small UX tuning knobs on the canvas:

  • More dwell at the destination. STEP_DURATION_BASE 2500 → 2900 in useFlowAnimation.ts. The pixel-active phase (carrot travelling along the edge) stays at 1800 ms; only the gap between steps grows — from 700 ms to 1100 ms. The destination node has more breathing room after a carrot delivery before the next step lights up.
  • Less max zoom. maxZoom 6 → 5 in FlowCanvas.tsx. 6× was so close that the pixel-art sprites started feeling over-pixelated past the canvas's intended fidelity.

Test plan

  • Play any flow — the gap between steps feels a touch longer; carrot travel speed unchanged.
  • Pause / resume mid-step still picks up where it left off (gap-phase pause math reads from the same STEP_DURATION_BASE).
  • Cmd/Ctrl-scroll past prior max — wheel now caps at 5×; visual quality stays acceptable.

🤖 Generated with Claude Code

Summary by CodeRabbit

New Features

  • Added live-tunable maximum zoom control for camera movement during playback auto-focus sequences. Zoom levels can now be dynamically adjusted in real-time to suit viewing preferences, providing enhanced visual control without interrupting ongoing playback.

Chores

  • Optimized autoplay step duration timing to improve overall playback pacing and transition smoothness between steps.

Review Change Stack

- STEP_DURATION_BASE 2500 -> 2900: pixel travel stays at 1800ms but
  the gap between steps grows from 700ms to 1100ms. Gives the
  destination node more breathing room after a carrot delivery so
  the eye can register where it landed before the next step lights up.
- maxZoom 6 -> 5: 6x was so close the pixel-art sprites started to
  feel pixelated past the canvas's intended fidelity. Pulling it
  back keeps the zoom feel crisper at the upper end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Warning

Rate limit exceeded

@naorsabag has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 36 minutes and 46 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f0916af-f1bf-4824-97e1-70339131068d

📥 Commits

Reviewing files that changed from the base of the PR and between 7d72f3d and 738abde.

📒 Files selected for processing (1)
  • packages/web/src/components/FlowCanvas.tsx

Walkthrough

This PR adds runtime-tunable auto-zoom maximum value for playback camera movement, increases the base autoplay step duration for timing adjustments, and declares the console debug hook in types.

Changes

Canvas Zoom Tuning and Autoplay Timing

Layer / File(s) Summary
Type Declarations for Debug Hook
packages/web/src/globals.d.ts
Declares the optional window.__setMaxZoom function in the Window global interface to support the console debug hook.
Autoplay Step Duration
packages/web/src/hooks/useFlowAnimation.ts
Increases STEP_DURATION_BASE from 2500 to 2900 milliseconds, adjusting the base per-step duration used in autoplay phase transition timing calculations.
Auto-Zoom Cap State and Console Tuning
packages/web/src/components/FlowCanvas.tsx
Introduces autoZoomMax state in FlowCanvasInner and installs window.__setMaxZoom(n) hook to update the cap at runtime. Clears the focus guard (lastFocusKeyRef) on cap changes so the active-step focus effect re-applies immediately. The auto-zoom moveTo call now uses autoZoomMax as the zoom cap instead of a hardcoded value, with autoZoomMax added to the effect dependency array.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • naorsabag/openhop#112: Both PRs modify FlowCanvas playback auto-zoom camera behavior; the previous PR adds a capped per-step auto-zoom with UI, while this PR makes the max-zoom value live-tunable via console hook.
  • naorsabag/openhop#113: Both PRs modify FlowCanvas.tsx auto-zoom/focus logic and the focus guard lastFocusKeyRef state handling.
  • naorsabag/openhop#96: Both PRs modify useFlowAnimation.ts; this PR adjusts STEP_DURATION_BASE timing while the retrieved PR changes playback/resume logic in the same hook.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 two main changes: tuning carrot dwell time (STEP_DURATION_BASE increase) and capping max zoom (autoZoomMax state).
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/web-anim-pacing

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 and usage tips.

naorsabag and others added 7 commits May 11, 2026 16:42
Author feedback: 5x still felt too zoomed-in. 4x keeps headroom for
reading text on small nodes without crossing into pixel-art mush.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lift maxZoom from a hard-coded literal to component state so a
debug hook can change it from the browser console:

  __setMaxZoom(3)   // tighter cap
  __setMaxZoom(8)   // looser cap

Same shape as the existing __flowSpeed debug hook. Cleared on unmount.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@xyflow/react v12's ReactFlowInstance has no setMaxZoom method - only
the JSX prop drives the scaleExtent. State-driven approach already
covers it; the imperative call was a TypeScript error.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The state-only path didn't take effect at runtime - v12's maxZoom
prop is documented as reactive but the d3-zoom scaleExtent wasn't
updating live for this app's mounting setup. Pulling useStoreApi and
calling state.setMaxZoom(n) directly bypasses the prop-driven update
chain.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author clarified: the cap they wanted lower is the per-step auto-zoom
that fires during playback (moveTo(focusNodes, 0.5, 1.8)) - NOT the
wheel-zoom maxZoom prop on ReactFlow. Reverting earlier mis-targeted
edits and pointing the debug hook at the right knob.

Changes:
- Revert wheel maxZoom back to 6 (original).
- Drop the useStoreApi import + state binding for wheel maxZoom.
- New state `autoZoomMax` (default 1.4, down from 1.8). Drives the
  active-step moveTo() call.
- `window.__setMaxZoom(n)` now updates autoZoomMax AND clears
  lastFocusKeyRef so the new value applies to the current step
  immediately on the next render. Added autoZoomMax to the focus
  useEffect deps so the camera re-positions when the cap changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
User test confirmed the cap had no effect because the natural-fit
zoom was already below it (scale = 0.435 on their flow). Switching
semantics: __setMaxZoom(n) now forces the playback auto-zoom and the
paused-overview zoom to EXACTLY n on the next focus apply, bypassing
the bbox-fit calculation. Clamped to React Flow's scale extent
[0.1, 6] so wild inputs don't break the viewport.

Default behavior preserved when no override is set (autoZoomOverride
= null) - the natural fit math still runs at 1.8 cap for play and
1.5 for overview.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
User settled on 1.0 after live-tuning via __setMaxZoom. The bbox-fit
calc routinely landed at fractional zooms (~0.4 for wide flows) that
felt too far out for tight focus on a step's sender + receiver.

Scoping: override only applies to the playing branch's moveTo call.
The paused overview keeps its natural-fit calculation so the whole
flow still frames correctly when you stop playback.

__setMaxZoom hook stays in for further live tuning if 1.0 turns out
to need iteration; safe to strip once locked in.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@naorsabag naorsabag merged commit 46eb6d8 into master May 11, 2026
8 checks passed
@naorsabag naorsabag deleted the feat/web-anim-pacing branch May 15, 2026 16:00
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.

1 participant