Proposal: (p2p) collaborative Mogan/TeXmacs

What

Help improve the collaborative features of Mogan, in particular add user cursors to the live documents and improve performance or add peer-to-peer infrastructure to the live document handling.

Why

Mogan/TeXmacs has already collaborative capabilities. See e.g. the support in $TEXMACS_PATH/progs/server and $TEXMACS_PATH/progs/client.

We support live documents, chat rooms and shared file server. However these features are still experimental and need testing, some more security handling (authentication, etc…), etc…
and they depends on a central server (another TeXmacs instance) which should be publicly visible on the Internet (i.e. have its own IP address).

How

Various directions are possible:

  • Better UI: the current UI does not give much feedback to the user, especially wrt. problems in the connection to the server, successful connection, liveliness of the server, etc…

  • Implement user cursors in live documents : a users should be able to see where other users are actively working.

  • Investigate performance issue in the current implementation and improve on them. Also investigate other possible mechanism of synchronisation, e.g. the one used in Typst or other collaborative solutions.

  • Develop some server-side architecture and relative monitoring to run the Mogan server in a cloud solution like Amazon AWS or similar.

  • Alternatively (and much better than the central server solution), investigate the possibility to create a peer-to-peer network using modern internet technologies where clients can connect together and sync their content without the presence of a centralised authority. Some references:

2 Likes

Is it possible to let another tool do P2P etc, and exchange data with TeXmacs via tunnels, say?

It seems also possible to take advantage of IRC.

I’m open to suggestion. I found https://holepunch.to which has some tools like hyperbeam which opens a two-way communication via stdout/stdin. This looks as the simplest solution but requires the whole node environment to run, it is not exactly lightweight. Ideally I wanted a solution which is easy to deliver to a large base of users.

For the moment it seems to me that libdatachannel is quite easy to use. See example/client there. After some study seems that there is some intrinsic complexity in connecting two arbitrary computers which do not have public addresses (like most computers connected via wi-fi or home broadband connections).

We might create a simple standalone executable (e.g. via libdatachannel) which tunnels a connection via stdin/stdout and then use it from TeXmacs, but it is not substantially easier than include support directly in TeXmacs (or maybe as a plugin).

The point is to make it versatile — it would then work alongside any form of text chat channels (no matter whether it is P2P or server/client mode).

I managed to use p2p-socket to establish a connection between a TeXmacs client and server. Seems an easy way to get things going without need to implement an adhoc solution. It is a Node app, but should be possible to package it as an independent app.

NAT hole punching like these require the use of an intermediate server, not sure if this is what you want. Also whatever technology we use the connection should be put in a TLS tunnel

I see two possibilities, we can run a lightweight server (e.g. coded in Javascript) like here: https://medium.com/collaborne-engineering/serverless-yjs-72d0a84326a2

or use DHTs like the p2p-socket solution with uses holepunch.io to establish the connection.

My understanding is that you do not need security for the signalling server since it is only needed to find the peers. For example with p2p-socket the server needs to make public an ID and then clients can connect to it only knowing the ID. Authentication is to be performed after this step.

I planned to write a IRC plugin but haven’t started coding. I think implement it in Python would be a good idea. I guess there are many ready-to-use Python clients for IRC.

TeXmacs has already chat rooms in case you are interested. You find the implementation in progs/{client, server}/chat.scm. Interestingly they are just usual TeXmacs documents, I find the idea compelling, since you can use all the markup for usual documents.

I’ve recently found out that the GNU project has its own p2p communication platform called JAMI. Docs are here: https://docs.jami.net they have all the APIs and infrastructure which allow to connect two clients to exchange info, we could leverage that for TeXmacs, and maybe also write a TeXmacs plugin for JAMI so that one can collaborate via teleconferencing and work on the same document (to be seen, I’ve not yet looked in detail in their plugin system).

3 Likes