Visitar URL original
perf(ui): cap pane animations at 30 fps by benvinegar · Pull Request #1036 · modem-dev/hunk · GitHub
Skip to content

perf(ui): cap pane animations at 30 fps - #1036

Merged
benvinegar merged 2 commits into
mainfrom
perf/cap-pane-animation-fps
Sep 7, 2026
Merged

benvinegar merged 2 commits into
mainfrom
perf/cap-pane-animation-fps

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • cap intermediate pane animation commits at 30 FPS
  • keep timeline progress wall-clock driven and always commit the exact final layout
  • cover the frame cadence policy and publish a patch changeset

Why

OpenTUI can drive timeline callbacks near 200 FPS. Pane animation geometry changes can rerender and reflow the review, so presenting every callback creates avoidable transient CPU work without useful terminal output.

Benchmark

One warmed local sample using Bun 1.4.2, a 240x28 viewport, and a synthetic 30-file review:

Transition Uncapped CPU Capped CPU Uncapped render Capped render
Close 278.26 ms 209.34 ms 88.33 ms 75.30 ms
Open 290.03 ms 194.76 ms 98.80 ms 74.09 ms

The cap reduced sampled animation CPU by about 25% while closing and 33% while opening. Open-transition p95 render time fell from 25.22 ms to 14.66 ms.

Verification

  • bun run typecheck
  • bun run lint -- packages/hunk/src/ui/hooks/usePaneSlideAnimation.ts packages/hunk/src/ui/lib/paneSlide.ts packages/hunk/src/ui/lib/paneSlide.test.ts
  • bun test packages/hunk/src/ui/lib/paneSlide.test.ts packages/hunk/src/ui/AppHost.interactions.test.tsx packages/hunk/src/ui/AppHost.sidebar-visibility.test.tsx packages/hunk/src/ui/AppHost.responsive.test.tsx packages/hunk/src/ui/AppHost.review-metadata.test.tsx (103 pass)
  • bun run test:integration (155 pass, 1 skip)
  • bun run test:tty-smoke (9 pass)
  • real TTY smoke run against the working-tree diff

bun run test reached 4,005 passes; two unrelated temporary-path isolation tests fail locally because an existing /tmp/node_modules/hunkdiff checkout is discovered from their fixtures.

@vercel

vercel Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hunk-web Ready Ready Preview Sep 7, 2026 6:55pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR caps intermediate pane-layout presentation at 30 FPS while retaining wall-clock timeline progress and an unconditional final-layout commit.

  • Adds a reusable frame-cadence predicate and 30 FPS policy.
  • Applies throttling to pane animation timeline updates.
  • Adds unit coverage for cadence arithmetic and publishes a patch changeset.
  • The runtime integration of throttling and final-layout completion still needs direct regression coverage.

Confidence Score: 4/5

The implementation appears behaviorally sound, but the repository's runtime-testing requirement must be satisfied with integration coverage before merging.

The throttle resets for each transition and completion commits the exact target layout, but the only new test validates helper arithmetic while test-mode animations bypass the modified callback path.

Files Needing Attention: packages/hunk/src/ui/hooks/usePaneSlideAnimation.ts, packages/hunk/src/ui/lib/paneSlide.test.ts

Important Files Changed

Filename Overview
packages/hunk/src/ui/hooks/usePaneSlideAnimation.ts Adds wall-clock throttling around intermediate timeline updates while preserving an unconditional destination-layout commit on completion.
packages/hunk/src/ui/lib/paneSlide.ts Defines the 30 FPS policy and a straightforward elapsed-time predicate.
packages/hunk/src/ui/lib/paneSlide.test.ts Covers predicate boundaries but does not exercise the changed hook behavior with a nonzero-duration timeline.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  T[Timeline update] --> D{Frame interval elapsed?}
  D -->|No| S[Skip intermediate commit]
  D -->|Yes| I[Interpolate pane geometry]
  I --> C[Commit presented layout]
  S --> N[Next timeline callback]
  C --> N
  N --> F{Timeline complete?}
  F -->|No| T
  F -->|Yes| E[Commit exact destination layout]
Loading
Prompt To Fix All With AI
### Issue 1
packages/hunk/src/ui/lib/paneSlide.test.ts:63-69
**Animation path remains untested**

This test checks only the frame-interval calculation. The runtime change also alters timeline callback throttling, timestamp resets, and the final-layout commit, but test mode sets animation duration to zero, so existing application tests bypass that path. The repository requires tests for modified runtime behavior, so this must be covered before merging with a controllable nonzero-duration timeline that verifies both the 30 FPS cap and the exact final layout.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "perf(ui): cap pane animations at 30 fps" | Re-trigger Greptile

Comment on lines +63 to +69
test("caps presentation commits at the configured frame rate", () => {
const frameInterval = 1_000 / PANE_SLIDE_MAX_FPS;

expect(paneSlideFrameDue(Number.NEGATIVE_INFINITY, 0)).toBe(true);
expect(paneSlideFrameDue(100, 100 + frameInterval - 0.01)).toBe(false);
expect(paneSlideFrameDue(100, 100 + frameInterval)).toBe(true);
});

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.

P2 Animation path remains untested

This test checks only the frame-interval calculation. The runtime change also alters timeline callback throttling, timestamp resets, and the final-layout commit, but test mode sets animation duration to zero, so existing application tests bypass that path. The repository requires tests for modified runtime behavior, so this must be covered before merging with a controllable nonzero-duration timeline that verifies both the 30 FPS cap and the exact final layout.

Context Used: guidelines.mdc Cursor rule (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/hunk/src/ui/lib/paneSlide.test.ts
Line: 63-69

Comment:
**Animation path remains untested**

This test checks only the frame-interval calculation. The runtime change also alters timeline callback throttling, timestamp resets, and the final-layout commit, but test mode sets animation duration to zero, so existing application tests bypass that path. The repository requires tests for modified runtime behavior, so this must be covered before merging with a controllable nonzero-duration timeline that verifies both the 30 FPS cap and the exact final layout.

**Context Used:** guidelines.mdc Cursor rule ([source](https://github.com/modem-dev/modem/blob/main/.cursor/rules/guidelines.mdc))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@benvinegar
benvinegar force-pushed the perf/cap-pane-animation-fps branch from cc3095f to 3a9739d Compare September 7, 2026 18:55
@benvinegar
benvinegar enabled auto-merge (squash) September 7, 2026 18:56
@benvinegar
benvinegar merged commit 7947ca9 into main Sep 7, 2026
17 of 18 checks passed

This branch was successfully deployed

1 active deployment
Preview — 3a9739da Deployed Sep 7, 2026 by vercel[bot]
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