Unofficial, of course
Project URL: Glitch :・゚✧
There’s nothing special about this project. Rather, it’s a script that you can run in the dev console.
People asked about having chat in the editor. It seems like Glitch already has some of the facilities needed to support it. And here’s the bare minimum–no, far less than the bare minimum–built upon that.
What’s the backend
In Glitch’s collaboration system, there’s a service called “OT” that collects changes from all the users currently editing the project, resolves conflicts among them, and disseminates changes. But in addition to that, it also allows clients to “broadcast” data to each other, which Glitch uses to send out what file/position each user is on, as well as the container CPU/RAM/disk usage stats.
This OT service runs in the project container, and Glitch’s API server forwards websocket connections to it. From my reading of the software behind it, the “broadcast” functionality is fully transparent. Meanwhile, the editor seems to have routines that can pick out which kinds of broadcast messages pertain to which widgets, so that the editor can ignore unrelated messages.
The hypothesis in this project is that we can send a new kind of “broadcast” message containing chat that the rest of Glitch will ignore. We send messages like this:
{
type: 'x-chat',
message: 'hi',
}
What’s the frontend
I drafted up a little panel with a message display and a text input at the bottom. Glitch’s own frontend is built in react and JSX, but like, I don’t know of a way to link new react code with Glitch’s minified stuff, so instead of that, I used some vanilla JS.
But as as result, it’s not hooked in to any of the editor’s state machines, so you should assume that everything will break if you switch projects or something.
Access control and authenticity
Guests are allowed. Non-project members, including anonymous accounts (you get an anonymous account if you use Glitch not signed in), can broadcast.
Unfortunately for our use case, the system doesn’t provide any metadata about what user sent each message. There’s no telling who sent what.
Actually I wonder if this is true of the user position and container stats too
Message history
Eh nah.
Moderation
No lifeguard on duty.
But you can block everyone and delete all messages by pressing F5.
addendum: text input is all messed up in dark mode