Skip to content

perf(compose): optimize UI rendering with Brush memoization#533

Merged
yacosta738 merged 1 commit into
mainfrom
perf/compose-brush-memoization-7053527566874741865
Apr 17, 2026
Merged

perf(compose): optimize UI rendering with Brush memoization#533
yacosta738 merged 1 commit into
mainfrom
perf/compose-brush-memoization-7053527566874741865

Conversation

@yacosta738
Copy link
Copy Markdown
Contributor

Identified and implemented memoization for expensive Brush (gradient) objects across multiple chat UI components in the Compose Multiplatform stack. This optimization reduces redundant object allocations and gradient calculations on every recomposition, leading to lower GC pressure and smoother UI interactions during typing and message scrolling.

Specifically:

  • Memoized gradients in GlassSurface, ChatBubbleBody, ChatHeader, and diagnosticsCard in ChatComponents.kt.
  • Memoized the WorkspaceDivider gradient in ChatWorkspace.kt.
  • Replaced a redundant Brush.linearGradient with SolidColor(Color.Gray) for the disabled SendButton state in ChatInputField.kt.
  • Updated the Bolt performance journal (.agents/journal/bolt-journal.md) with findings and benchmark results.
  • Verified project integrity with make check-format and ./gradlew :composeApp:allTests.

PR created automatically by Jules for task 7053527566874741865 started by @yacosta738

Identify and implement memoization for expensive Brush (gradient) objects
across the chat UI components to reduce GC pressure and improve frame
stability during interactions.

- Wrap vertical, horizontal, and linear gradients in 'remember' blocks.
- Use 'SolidColor' instead of redundant gradients for disabled button states.
- Update performance journal with benchmark metrics.
- Ensure all Kotlin/Compose checks and tests pass.
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3161a034-477b-4e54-b071-cd99496170ff

📥 Commits

Reviewing files that changed from the base of the PR and between ef205ee and 4de741c.

📒 Files selected for processing (4)
  • .agents/journal/bolt-journal.md
  • clients/composeApp/src/commonMain/kotlin/com/profiletailors/corvus/ui/chat/ChatComponents.kt
  • clients/composeApp/src/commonMain/kotlin/com/profiletailors/corvus/ui/chat/ChatInputField.kt
  • clients/composeApp/src/commonMain/kotlin/com/profiletailors/corvus/ui/chat/ChatWorkspace.kt

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

  • Performance

    • Optimized UI rendering performance for chat components and workspace divider.
  • Bug Fixes

    • Updated disabled send button styling for consistency.

Walkthrough

This PR optimizes Compose UI rendering performance by memoizing gradient Brush objects using remember blocks across multiple chat components to prevent unnecessary re-allocation on recomposition. Additionally, the send button's disabled state now uses SolidColor(Color.Gray) instead of a redundant gradient for the same color.

Changes

Cohort / File(s) Summary
Journal Entry
.agents/journal/bolt-journal.md
Added 2026-04-15 journal entry documenting the gradient caching optimizations and benchmark impacts.
Chat UI Component Optimizations
clients/composeApp/src/commonMain/kotlin/com/profiletailors/corvus/ui/chat/ChatComponents.kt, clients/composeApp/src/commonMain/kotlin/com/profiletailors/corvus/ui/chat/ChatWorkspace.kt
Wrapped gradient Brush objects in remember() blocks within GlassSurface, ChatBubbleBody, ChatHeader, diagnosticsCard, and WorkspaceDivider to prevent brush re-allocation on each recomposition.
Send Button Styling
clients/composeApp/src/commonMain/kotlin/com/profiletailors/corvus/ui/chat/ChatInputField.kt
Replaced Brush.linearGradient(listOf(Color.Gray, Color.Gray)) with SolidColor(Color.Gray) for disabled button background; added SolidColor import.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • dallay/corvus#80: Related prior PR implementing similar performance-minded caching of UI painting objects (brushes/border strokes) in chat components.

Suggested labels

area:kotlin, risk:performance, area:docs

Suggested reviewers

  • yuniel-acosta
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/compose-brush-memoization-7053527566874741865

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.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying corvus with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4de741c
Status: ✅  Deploy successful!
Preview URL: https://c4da3793.corvus-42x.pages.dev
Branch Preview URL: https://perf-compose-brush-memoizati.corvus-42x.pages.dev

View logs

@github-actions
Copy link
Copy Markdown
Contributor

✅ Contributor Report

User: @yacosta738
Status: Passed (12/13 metrics passed)

Metric Description Value Threshold Status
PR Merge Rate PRs merged vs closed 89% >= 30%
Repo Quality Repos with ≥100 stars 0 >= 0
Positive Reactions Positive reactions received 10 >= 1
Negative Reactions Negative reactions received 0 <= 5
Account Age GitHub account age 3091 days >= 30 days
Activity Consistency Regular activity over time 108% >= 0%
Issue Engagement Issues with community engagement 0 >= 0
Code Reviews Code reviews given to others 558 >= 0
Merger Diversity Unique maintainers who merged PRs 2 >= 0
Repo History Merge Rate Merge rate in this repo 92% >= 0%
Repo History Min PRs Previous PRs in this repo 242 >= 0
Profile Completeness Profile richness (bio, followers) 90 >= 0
Suspicious Patterns Spam-like activity detection 1 N/A

Contributor Report evaluates based on public GitHub activity. Analysis period: 2025-04-15 to 2026-04-15

@sonarqubecloud
Copy link
Copy Markdown

@yacosta738 yacosta738 marked this pull request as ready for review April 17, 2026 14:57
@yacosta738 yacosta738 enabled auto-merge April 17, 2026 14:57
@yacosta738 yacosta738 merged commit 3eff076 into main Apr 17, 2026
14 of 15 checks passed
@yacosta738 yacosta738 deleted the perf/compose-brush-memoization-7053527566874741865 branch April 17, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant