Skip to content
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

GhostText protocol wishlist #255

Open
fregante opened this issue Mar 13, 2023 · 2 comments
Open

GhostText protocol wishlist #255

fregante opened this issue Mar 13, 2023 · 2 comments

Comments

@fregante
Copy link
Owner

fregante commented Mar 13, 2023

Current

Future

  1. Just connect to WebSocket, no intermediary HTTP server
    • alternatively, just use EventSource and HTTP/2 instead of WebSocket
  2. Add timestamp to messages in order to discard messages that are out of order
  3. Send the full URL on connection so that the editor can use the filename and/or set the syntax
  4. the text selection can be sent separately from the content
  5. the editor should not send the syntax back
  6. send editor description/title/label (via label, [title], [aria-label], etc) to be used as tab title
@subnut
Copy link
Contributor

subnut commented Mar 16, 2023

My suggestion?

Implement diff mode.

First connection

Browser sends editor the metadata (title, url, etc.) and the full text

Rest of the lifetime

Every time text changes in either browser or editor, it sends out a message that contains the line numbers from which the change starts, and the line number at which the change stops, and the whole text between those line numbers.

e.g.

  • Say, currently the text is -
Lorem Ipsum
Dolor Sit
Consectetur
Adipiscing Elit
  • The user changes the text to -
Lorem Ipsum
Dolor Stand
Consectetur
Adipiscing Elit
  • A message containing the following details is sent out -
start: 2
end: 2
Dolor Stand
  • The user changes the text to -
sing with me, sing for the year,
sing for the laughter and sing for the tear.
sing with me, just for today,
maybe tomorrow the good lord will take you away
dream on, dream on, dream on,
dream until your dreams come true
Lorem Ipsum
Adipiscing Elit
  • A message containing the following details is sent out -
start: 1
end: 3
sing with me, sing for the year,
sing for the laughter and sing for the tear.
sing with me, just for today
maybe tomorrow the good lord will take you away
dream on, dream on, dream on,
dream until your dreams come true
Lorem Ipsum
  • The user changes the text to -
Lorem Ipsum
Adipiscing Elit
  • A message containing the following details is sent out -
start: 1
end: 6
  • The user changes the text to -
Lorem Ipsum
  • A message containing the following details is sent out -
start: 2
end: 2

This way, GhostText can work on big files without needing to consume a ton of CPU.

@fregante
Copy link
Owner Author

fregante commented Mar 16, 2023

Implement diff mode.

heh I was thinking about that earlier, but that complicates things a lot, because suddenly every message has to be delivered.

The other complication is that a diff algorithm, especially with multiple cursors, still doesn't come free (CPU), and has to be implemented by each editor plugin in different languages. One editor gets this wrong and people lose data and open issues here.

The only way I could do this would be with a standard, simple diffing algorithm available in multiple languages. This would avoid implementation errors and waste of dev time. I'd probably not implement this myself in any case due to the complexity, compared to just dynamic throttling (see the "updates" section in #256)

Browser sends editor the metadata (title, url, etc.) and the full text

Totally agree, the current setup is awkward. PR welcome for that (including protocol.md). I suppose it would need to be sent via URL parameter though, which means it's limited in length (32k) and therefore it would need to be skipped when too long.

I'm happy to make changes that are backwards compatible, I already made a couple of improvements this week: https://github.com/fregante/GhostText/commits/main/PROTOCOL.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants