mobile-shell / mobile-shell/mosh

Mosh clipboard issue

Open
#1,090 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
14.5k
Forks
865
PR merge metrics
No merged PRs in 30d

Description

https://github.com/mobile-shell/mosh/blob/0cc492dbae2f6aaef9a54dc2a8ba3222868b150f/src/terminal/terminaldisplay.cc#L114

It seems like that mosh is trying to create a clipboard caching to avoid OSC 52 clipboard delivery if the text is the same with the last time. However, this introduces a problem. Think of the following scenario, I'm using emacs in a remote server from my laptop via mosh, and trying to copy texts with OSC 52. I took the following steps.

  1. My remote emacs sends a OSC 52 to deliver abc as the clipboard text. My local laptop clipboard and the mosh clipboard are both abc for now.
  2. I copy something else (e.g., xyz) from another application on my local side, say, chrome. My local laptop clipboard is now xyz. The mosh clipboard is unchanged, which is still abc.
  3. I went back to my remote emacs, and tries to send a OSC 52 to deliver abc to my local terminal again. However, this time, since the mosh clipboard still has the abc, it'll refuse to deliver OSC 52 with text abc to my terminal, which means that abc will not be copied to my local laptop clipboard.

I think the fundamental issue here is that mosh tries to do the clipboard caching, while there is no guarantee that the mosh cached clipboard is in sync with the local system clipboard. Anyone agree on this? Any workaround?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/terminal/terminaldisplay.cc at line 114 and inspect how OSC 52 clipboard caching decides whether to deliver text. Reproduce the documented sequence with abc, local clipboard replacement by xyz, and abc again; done means the second abc delivery reaches the local terminal despite the cached value.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.