stag of dead tulips

ghosting helix

i use a browser extension GhostText. tl;dr it lets you use a local text editor to edit browser text fields.

it has no first-party support for helix, so i use helix-ghost. as a bonus, it actually works with any terminal editor.

unfortunately, it opens the text editor in the tty it was spawned in, meaning in order to have it working you need to have a terminal window always open. i use a tiling wm and that's makes using it very annoying. to try to alleviate this i made a perl script (permalink). it listens on a socket for incoming connections and spawns a new terminal window running a command, giving it a port and log file. it forwards the socket to the port and tails the log file. when it finds a match in the log file the process is killed.

i had a very strange issue though. it worked, but after 115 seconds the terminal would close itself. i originally thought this was something with helix-ghost, but it wasn't. it didn't really help helix-ghost was written in go and i don't know golang.

turns out, 115 is the default value for firefox's (and by extension, librewolf's) network.http.keep-alive.timeout. what was happening is i mistakenly assumed that the ghosttext api communicated entirely over the initial connection with a websocket. instead, the intial connection just has the server respond with a JSON message containing a port to a websocket server. so apart from the intial handshake nothing was ever sent along the socket.

and as a result, firefox would idle out the socket. my script detected that and killed the terminal, taking down helix-ghost along with it. the fix was to simply remove the select handles, ie don't kill the terminal when the socket closes.

Thoughts? Leave a comment

Comments
  1. stagMay 4, 2026:

    i was going to write something else but i was using ghosttext to write this and got sidetracked by it not working.

    ill post it tonight or maybe never.