fix(tui): ~1800x times image pasting performance improvement #38880
Open
affanali2k3 wants to merge 2 commits into
Open
fix(tui): ~1800x times image pasting performance improvement #38880affanali2k3 wants to merge 2 commits into
affanali2k3 wants to merge 2 commits into
Conversation
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
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.
Issue for this PR
Closes #38879
Type of change
What does this PR do?
The old code for pasting image was really slow due to creating an external shell like osascript and powershell which adds unnecessary overhead. First I tried creating a binary for each platform and then using exec to execute it directly for reading image from clipboard but it wasnt a good solution as we had to ship binaries for each platform in codebase. Then I went around a bit and found out a really good package by mario which uses rust for this specific purpose. The package works really well and uses napi to execute rust code. I tried on all platforms and there are no errors. I also added proper test cases because the old ones werent really good. Now the speed is around 0.07ms its like a 1800x boost from the old one.
How did you verify your code works?
I ran it on all 3 platforms and copied and pasted images and also see if agent was able read them.
Screenshots / recordings
I enabled keystroke visualization look at bottom left corner and see how its literally instant the time I press and it displaying the image marker. Compare to the issue one it feels so good now.
Screen.Recording.2026-07-25.at.11.09.43.PM.mov
Checklist