Title: perf(workflow): scope resize CSS-var writes to the container, not :root by waleedlatif1 · Pull Request #5738 · simstudioai/sim · GitHub
Open Graph Title: perf(workflow): scope resize CSS-var writes to the container, not :root by waleedlatif1 · Pull Request #5738 · simstudioai/sim
X Title: perf(workflow): scope resize CSS-var writes to the container, not :root by waleedlatif1 · Pull Request #5738 · simstudioai/sim
Description: Summary Resizing the editor panel, terminal, output panel, and sidebar on the workflow canvas was still laggy on real workflows even after the drag handles stopped re-rendering React per frame (#5730). A Chrome DevTools CPU/tracing capture showed the remaining cost is style recalculation, not JS or layout: ~3.9s of Document::recalcStyle over a 50-move panel drag. Root cause: each drag frame wrote its CSS variable to document.documentElement. On a large document (~42k elements) any inline custom-property write on the root recalculates style for the whole tree — measured at ~77ms per write, independent of what reads the variable (an unused --zzz var costs the same 77ms). Writing the same variable to the element that consumes it recalcs only that subtree (~0.5ms — a ~150x reduction). Fix: useDragResize now writes the variable to a caller-provided target element during the drag and reconciles to :root once on release (so on-demand readers, the pre-hydration blocking script, and rehydration are all unchanged). panel → .panel-container, terminal → .terminal-container, output panel → .terminal-container (both the panel and logs column inherit it), sidebar → .sidebar-shell-outer. The terminal's expanded-threshold sync writes store state directly instead of setTerminalHeight so it no longer touches :root mid-drag (that was a ~77ms hitch right at the collapse threshold). Measured (near-empty canvas, 50-move drag, CDP trace + rAF frame timing) Handle Before After Panel style+layout 3891ms 56ms Panel frame p95 / max 91.6 / 108ms 8.4 / 8.8ms Panel main-thread blocking 4566ms 0ms Terminal recalcStyle 3899ms 16ms Terminal blocking 5558ms 0ms Sidebar recalc ~77ms/frame ~1ms/frame Frames drop from ~11fps (91ms) to a solid 120fps (8.3ms) with zero long-tasks. Type of Change Performance improvement Testing Verified with Playwright + CDP against a live dev workflow: all four handles engage, drive their element's width/height live during the drag (scoped inline var), commit the final value to :root + the store on release, remove the scoped override (reconciled), and persist. Before/after CPU profiles and traces captured for each handle. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary Resizing the editor panel, terminal, output panel, and sidebar on the workflow canvas was still laggy on real workflows even after the drag handles stopped re-rendering React per frame (#5...
X Description: Summary Resizing the editor panel, terminal, output panel, and sidebar on the workflow canvas was still laggy on real workflows even after the drag handles stopped re-rendering React per frame (#5...
Opengraph URL: https://github.com/simstudioai/sim/pull/5738
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d45c203b-11bd-c810-78b7-beb61c7cb8ce |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C720:1B3B59:29F8543:3A3A266:6A632B58 |
| html-safe-nonce | 3d13c24a94534fed7bd2de42961a4eccf334b05443d9ace5f7b04f11b81eecdf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzIwOjFCM0I1OToyOUY4NTQzOjNBM0EyNjY6NkE2MzJCNTgiLCJ2aXNpdG9yX2lkIjoiMjUxOTA0OTUwODMwOTExNzc4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 412dd9eebd86a876a93f780df43333085cc0426bf472688df128506582f4e91b |
| hovercard-subject-tag | pull_request:4078898077 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/5738/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary Resizing the editor panel, terminal, output panel, and sidebar on the workflow canvas was still laggy on real workflows even after the drag handles stopped re-rendering React per frame (#5... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 30c644d502bce6cd2e59f9000b4744f2b64819abea8e8f959b18e3ad793125aa |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 331492a48ebd91d66ef2de38e1901bb911c9fe9b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width