-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bidirectional clipboard for iOS Simulator, support multiline paste, show toast when copying/pasting #936
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments
// ignore sending C and V when meta key is pressed | ||
} else { | ||
this.preview?.sendKey(keyCode, direction); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why, did you move this code to deviceBase
I understand that is does not break android, as you pointed out in your comment, but it is still an ios specific workaround is it not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually applies to Android as well, otherwise it result in typing 'ccccc' or 'vvvvv' when trying to copy/paste to Android. And since it is a workaround for iOS and Android problems as well, I've elevated it higher
this.subprocess?.stdin?.write(`paste ${text}\n`); | ||
public sendClipboard(text: string) { | ||
// This is bad, but prevents simulator server going crazy with multiline pastes | ||
// If we want to support multiline pastes we need to change the communication protocol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what options do we have in regard to other protocols?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can either switch protocol completely, like move to GRPC or stay with communication via stdin-stdout, but add some markers for multiline commands, like this:
paste >>>STARTSIMSERVERPASTEhere is the
actual
multiline content
pasted by
the user<<<ENDSIMSERVERPASTE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened a PR in simulator-server to handle this properly software-mansion-labs/simulator-server#222
@@ -347,19 +347,24 @@ function Preview({ | |||
}, []); | |||
|
|||
useEffect(() => { | |||
function dispatchPaste(e: ClipboardEvent) { | |||
function synchronizeClipboard(e: ClipboardEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should inform user somehow that thay recived a clipboard?
Like in the example video:
Screen.Recording.2025-02-10.at.09.40.52.mov
I know that usually cmd+c does not trigger such a microinteraction, but this is a very specific case in witch user does not copy highlithed text but rather the contents of a clipboard on a simulated device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS. I don't necessary think it needs to be part of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, a small modal "device clipboard copied to host"/"host clipboard pasted to device" appearing on copy/paste would be sufficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a toast notification for copy/paste
copypaste.mov
13bb459
to
39b7592
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left an inline comment, but i am okay with the rest,
thank you
@@ -252,8 +260,31 @@ export class Project | |||
|
|||
//#endregion | |||
|
|||
async showToast(message: string, timeout: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be either part of UtilsInterface
or just an utill imported here
This PR introduces bidirectional clipboard support for iOS Simulator. The copying behaviour is similar to how cmd+v works, but instead of transferring hosts' clipboard content to the simulator, cmd+c transfers the simulator's clipboard to host's.
Apart from that, this PR prevents typing 'c' and 'v' when holding cmd and fixes multiline pastes (previously, newlines were recognized as starting separate commands, resulting in
unrecognized command
errors from simserver). It also adds a toast notifying user when copying/pasting is performed.copypaste.mov
Fixes #160, #701
How Has This Been Tested:
Verified that: