Skip to content

perf(ui): defer default-open tool bodies - #26813

Closed
Hona wants to merge 6 commits into
anomalyco:devfrom
Hona:perf/baseline-hotpath-wins
Closed

Hona wants to merge 6 commits into
anomalyco:devfrom
Hona:perf/baseline-hotpath-wins

Conversation

@Hona

@Hona Hona commented May 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Make BasicTool defer apply to default-open tools instead of mounting heavy children during session render.
  • Start initial deferred tool bodies after the first paint, then mount them FIFO one per frame.
  • Preserve open state and rendered output; user-opened deferred tools still mount on the normal next frame.

Verification

  • bun typecheck from packages/ui
  • bun typecheck from packages/app
  • Pre-push hook passed: bun turbo typecheck
  • bun bench:dribble from opencode-desktop-perf

Perf Notes

  • Current clean baseline trace: Timeline Ready ~4098ms, Max Long Task ~3267ms.
  • With this change: Timeline Ready ~1219-1494ms, Max Long Task ~1157-1414ms across two runs.

Risk

  • Default-open deferred tool contents now appear progressively after first paint instead of blocking the initial session render.
  • This is a UX timing change, but it matches the existing defer prop intent and does not change open state or diff rendering.

Copilot AI review requested due to automatic review settings May 11, 2026 04:29

Copilot AI left a comment

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.

Pull request overview

This PR updates the BasicTool component’s defer behavior so that default-open deferred tools no longer mount their (potentially heavy) children during the initial session render. Instead, initial deferred tool bodies begin mounting after first paint, then mount FIFO, one per animation frame, preserving open state and eventual rendered output while improving initial render performance.

Changes:

  • Introduce a global deferred-mount queue and RAF-driven flush to progressively mount default-open deferred tool bodies after first paint.
  • Change initial ready state so defaultOpen + defer starts closed-over-body (ready=false) until scheduled.
  • Refactor “ready” scheduling/cancellation logic and add an onMount hook to start the initial deferred mounting process.

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

@Hona Hona added the beta label May 11, 2026
@Hona
Hona requested a review from adamdotdevin as a code owner May 11, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants