Skip to content

perf(desktop): stop whole-document restyles and svg spinner churn - #91360

Merged
trunk-io[bot] merged 5 commits into
masterfrom
perf/desktop-render-churn
Aug 30, 2026
Merged

perf(desktop): stop whole-document restyles and svg spinner churn#91360
trunk-io[bot] merged 5 commits into
masterfrom
perf/desktop-render-churn

Conversation

@charlesvien

@charlesvien charlesvien commented Aug 30, 2026

Copy link
Copy Markdown
Member

Problem

Opening a session, Settings or "Back to app" stutters. In the packaged build each click froze the renderer for 300ms to 1.4s. Traced over CDP, three causes:

  • A body:has(...) [data-quill-portal] rule made Chromium restyle the whole document after almost every React commit. Opening one session ran 68 full-document recalcs (3.6s).
  • Spinners put animate-spin on an <svg>, which Chromium animates on the main thread. ConnectingToAgent stays mounted at opacity-0 behind the composer, so every open session paid a style recalc and layerize pass per frame.
  • The canvases loading bar animated left and width (layout every frame), even while collapsed.

Changes

  • The :has() rule now sets quill's --quill-z-* variables on body instead of restyling descendants. Popovers still sit above Settings and stay clickable under Radix dialogs.
  • New Spin and Spinner primitives put the animation on a wrapping span, which the compositor runs. All 41 spinners use them (mechanical). ConnectingToAgent stops spinning while hidden.
  • The loading bar animates transform only, and only while active.
  • docs/CONVENTIONS.md records the three rules.

Nothing looks different. Dev build, same clicks and state before and after:

Before After
Full-document recalcs opening one session 68 (3,579ms) 1 (9ms)
Idle session view, per-frame work over 3s 285ms 0
Four session clicks, main-thread blocking 5,657ms (max 866ms) 1,820ms (max 467ms)
Three Settings round trips, main-thread blocking 5,143ms (max 1,180ms) 2,840ms (max 695ms)

Packaged build before the change: "Back to app" 516 to 607ms per click, session switches 287 to 1,418ms. Not re-measured after.

How did you test this code?

  • CDP traces with style invalidation tracking and a long-animation-frame observer, before and after.
  • Injected the two :has() triggers into body and checked quill portals get z-index 101 and pointer-events auto, then revert.
  • One assertion in AutoresearchPanel.test.tsx moved to the wrapper span.
  • Not checked: the packaged build after the change, and a real Radix dialog with a quill popover open.

@charlesvien charlesvien self-assigned this Aug 30, 2026
@trunk-io

trunk-io Bot commented Aug 30, 2026

Copy link
Copy Markdown

😎 This pull request was merged.

@github-actions github-actions Bot added the feature/desktop Feature Tag: Desktop label Aug 30, 2026
@charlesvien
charlesvien marked this pull request as ready for review August 30, 2026 10:02
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team August 30, 2026 10:03
@github-actions

Copy link
Copy Markdown
Contributor

🤖 CI report

Trunk lane — non-backend lane

This PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes.

@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

React Doctor found 4 issues in 3 files · 4 warnings.

4 warnings

packages/ui/src/features/folder-picker/FolderPicker.tsx

packages/ui/src/features/sessions/components/SessionView.tsx

packages/ui/src/features/sessions/components/session-update/StatusNotificationView.tsx

Reviewed by React Doctor for commit 8dbaa6e.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
products/desktop/packages/ui/src/features/autoresearch/AutoresearchPanel.test.tsx:60-62
**Tailwind classes asserted in test**

This assertion couples the unit test to `animate-spin` and `motion-reduce:animate-none`, so a behavior-preserving styling refactor will fail the test while the assertion still does not verify that the spinner is visibly animated. Cover the visual behavior through an appropriate behavioral or visual test instead.

---

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

Reviews (1): Last reviewed commit: "Fix document-wide recalcs and svg spinne..." | Re-trigger Greptile

@hosthog

hosthog Bot commented Aug 30, 2026

Copy link
Copy Markdown

HostHog preview — posthog-desktop-web

The previews for this PR have been torn down and no longer serve.

Generated-By: PostHog Desktop
Task-Id: 77f7bbc8-7141-41b7-9bbb-639e04ee0878
@charlesvien charlesvien added the stamphog Request AI approval (no full review) label Aug 30, 2026
stamphog[bot]
stamphog Bot previously approved these changes Aug 30, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the diff against its perf claims: the new CSS variables set on body do match how quill's own layers.css consumes --quill-z-* and pointer-events, and the loading-bar/spinner refactors are consistent across the ~30 mechanically-updated files I sampled. No auth/billing/data/API/CI surface is touched, the author is on the owning team with very strong recent familiarity, and there are no unresolved review concerns or in-progress reviewers blocking merge.

  • Author wrote 78% of the modified lines and has 28 merged PRs in these paths (familiarity STRONG).
  • 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 314L, 29F substantive, 327L/31F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (327L, 31F, single-area, perf)
stamphog 2.0.0b4 .stamphog/policy.yml @ 2b1c6f8 · reviewed head 2b1c6f8

@charlesvien charlesvien changed the title perf(desktop): stop document-wide style recalcs and spinner churn perf(desktop): stop whole-document restyles and svg spinner churn Aug 30, 2026
@charlesvien charlesvien added the reviewhog ($$$) Reviews pull requests before humans do label Aug 30, 2026
@posthog

posthog Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦔 PostHog Review reviewed this pull request

Found 0 must fix, 1 should fix, 1 consider.

Published 2 findings (view the review).

Resolved comments: 2 fixed

@posthog

posthog Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

PostHog Review alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏

@posthog posthog Bot 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.

PostHog Review

Found 1 should fix, 1 consider.

@posthog posthog Bot removed the reviewhog ($$$) Reviews pull requests before humans do label Aug 30, 2026
The pending-link spinner moved size-3 to the Spin wrapper, leaving
CircleNotch at its 1em default. In the text-sm paragraph the icon
rendered at 14px inside a 12px wrapper, so it sat 1px low and wobbled
as the wrapper rotated about a different center.

Put the size on the icon (size={12}) and let the wrapper size to it,
matching the CliCheckPanel and PrChecksSection call sites.

Generated-By: PostHog Desktop
Task-Id: c28dac69-31ef-414a-bb15-4129aa1036ee
@stamphog
stamphog Bot dismissed their stale review August 30, 2026 11:31

A new stamphog review started for this PR — the fresh verdict replaces this approval.

stamphog[bot]
stamphog Bot previously approved these changes Aug 30, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contained, single-team desktop UI perf fix (CSS/animation-layer changes across 31 files, all owned by the author's team with STRONG familiarity) — no risky territory (no data model, API, billing, auth, crypto, dependency, or CI/build changes). The one unresolved inline thread flags a real but purely cosmetic double-speed spinner rotation in one loading state, which is fix-forward material, not a functional/security/data showstopper; the other flagged issue was already fixed in the current diff (ChatMarkdown now passes an explicit size prop) and a prior human review approved an earlier revision.

  • Author wrote 78% of the modified lines and has 28 merged PRs in these paths (familiarity STRONG).
  • 👍 on the PR from greptile-apps[bot].
  • Unresolved inline comment on PreBaselineState.tsx: nesting the new Spin wrapper around quill's own Spinner (which still carries its own CSS animation) produces a double-speed, 1px-offset rotation — confirmed present in the current diff. Cosmetic only, but worth a quick follow-up fix.
  • Greptile flagged that the AutoresearchPanel test now asserts Tailwind utility classes directly rather than visible spinning behavior — minor test-quality nit, not blocking.
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 314L, 29F substantive, 327L/31F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (327L, 31F, single-area, perf)
stamphog 2.0.0b4 .stamphog/policy.yml @ e5c3d35 · reviewed head e5c3d35

The pre-baseline card wraps quill's Spinner in Spin. Quill's Spinner
self-animates via .quill-spinner (components layer) and defaults to
16px. With no className on the child, the wrapper's animate-spin then
compounded quill's SVG animation, so the icon turned at double speed
and wobbled, shrank to 16px inside its 20px box, kept the main-thread
SVG animation this PR removes elsewhere, and ignored reduced motion
(the wrapper's motion-reduce:animate-none never reached the child).

Pass size-5 and animate-none to the child. Both are utilities, which
outrank the components-layer .quill-spinner, so the SVG is 20px again
and its own animation is cancelled — only the compositor-run wrapper
spins. Extend the existing test to assert both classes on the icon.

Generated-By: PostHog Desktop
Task-Id: c28dac69-31ef-414a-bb15-4129aa1036ee
@stamphog
stamphog Bot dismissed their stale review August 30, 2026 11:37

A new stamphog review started for this PR — the fresh verdict replaces this approval.

Generated-By: PostHog Desktop
Task-Id: a99f8e61-f6bc-4421-8fc7-63f1a2495487

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mechanical, well-verified perf refactor confined to desktop UI styling/animation; author owns this code with STRONG familiarity, tests were updated, and prior bot review comments were resolved with no unresolved concerns. No risky territory touched.

  • Author wrote 77% of the modified lines and has 28 merged PRs in these paths (familiarity STRONG).
  • 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 314L, 29F substantive, 327L/31F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (327L, 31F, single-area, perf)
stamphog 2.0.0b4 .stamphog/policy.yml @ 8dbaa6e · reviewed head 8dbaa6e

@trunk-io
trunk-io Bot merged commit 6ba1f62 into master Aug 30, 2026
186 checks passed
@trunk-io
trunk-io Bot deleted the perf/desktop-render-churn branch August 30, 2026 15:38
@trunk-io

trunk-io Bot commented Aug 30, 2026

Copy link
Copy Markdown

This pull request was merged into master as part of stacked PR 91362.

@deployment-status-posthog

deployment-status-posthog Bot commented Aug 30, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-08-30 15:58 UTC Run
prod-us ✅ Deployed 2026-08-30 16:11 UTC Run
prod-eu ✅ Deployed 2026-08-30 16:12 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/desktop Feature Tag: Desktop stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants