perf(common): implement copy-on-write behavior in formatters - #1905
Draft
liangfung wants to merge 1 commit into
Draft
perf(common): implement copy-on-write behavior in formatters#1905liangfung wants to merge 1 commit into
liangfung wants to merge 1 commit into
Conversation
…nt mutation Introduce copy-on-write helper functions (mapOrOriginal, filterOrOriginal, mapMessagePartsOrOriginal) to avoid mutating message arrays and part objects in-place during formatters.ui processing. Isolate latest user messages and update checkpoint/renderWidget operations immutably to preserve reference equality for unmodified chat history parts, avoiding unnecessary re-renders. 🤖 Generated with [Pochi](https://getpochi.com) | [Task](https://app.getpochi.com/share/p-31f6de164c5d468584ff9b1236c9d519) Co-Authored-By: Pochi <noreply@getpochi.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1905 +/- ##
==========================================
+ Coverage 38.31% 38.39% +0.07%
==========================================
Files 772 772
Lines 82354 82447 +93
Branches 3951 4046 +95
==========================================
+ Hits 31556 31656 +100
+ Misses 50681 50674 -7
Partials 117 117 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mapOrOriginal,filterOrOriginal, andmapMessagePartsOrOriginalto replace in-place array/object mutations insideformatters.ui.compactTask,writeRenderWidgetOutput, andappendCheckpointto perform immutable updates onmessagesandpartsarrays instead of using in-place methods likeunshiftorpush.Perf
Before
After
Test plan
bun turbo test --filter=@getpochi/commonbun turbo test --filter=@getpochi/livekitbun turbo test --filter=@getpochi/vscode-webuibun tscbun check🤖 Generated with Pochi | Task