Skip to main content

Module open

Module open 

Source
Expand description

geop open [DIR]: the web editor in a browser, its kernel this process and its workspace the folder DIR.

The page is the web app as vite build --mode open builds it (web/src/backend.local.ts), embedded in the executable with the feature frontend. It talks to this process over HTTP on 127.0.0.1:

  • GET /ws?token=…: a WebSocket to the editor’s Session. Each text message is one command of the JSON protocol geop serve speaks on its stdin, and is answered, in order, by one message: the update.
  • GET /api/files: the folder’s program and data files, by their paths relative to it, with the one to edit first, if one was named.
  • PUT /api/file?path=… writes a file, DELETE removes one.
  • POST /api/raise brings the window showing the page to the front: only in geop app, where it is how a second geop app of the same folder hands over to the first (see app.rs).
  • Anything else is a file of the page itself.

What can reach 127.0.0.1 is more than the user: every page the browser has open can send requests to it, and a page of a name that resolves to 127.0.0.1 (DNS rebinding) can even read the answers. So every request must name this server as its Host, a request from a page must come from this server’s own origin, and the WebSocket and the file API take a token that is made afresh each run and given only in the URL printed (see Access). The file API reads and writes only files under DIR, of the kinds the explorer shows, never through a link out of it (see [Folder]).

The editor is one, for every WebSocket: a thread owns it and answers the commands the connections send it (SessionHandle). That is the session another front end would attach to — an MCP client driving what the page shows (geop mcp --attach, not yet written) would be another sender of commands to it.

Structs§

Access
Who this server answers: requests naming it as their host, from its own pages, and — for the editor and the files — knowing the token.
Claims
What a request says of where it comes from.
OpenArgs
Server 🔒
What every request is answered with.
Serving
The editor of a folder, served on 127.0.0.1: bound, and answering once Serving::run is.
SessionHandle
The editor’s session, answering the commands sent to it in the order they come, from whichever sender. Cloned for every connection.

Enums§

Route
How a request is let in.

Functions§

answer 🔒
folder_of
The folder path names — or the one a program path is in — with the program to edit first, if one was named.
header 🔒
json 🔒
media_type
What the page’s file path is, for its Content-Type.
open
open_browser
Open the default browser at url.
page_file 🔒
The file of the page at path, if the page was built in.
page_missing
Why this geop cannot serve the editor’s page, if it cannot: it was built without it.
percent_decoded
text with every %XX and + decoded, if it is UTF-8 then.
query_value
The value of key in the query query (a=1&b=2), percent-decoded.
same 🔒
Whether a and b are equal, in a time that does not tell how much of them is.
socket 🔒
Answer the commands of one WebSocket until it closes.
text 🔒

Type Aliases§

Call 🔒
A command to the session, and where its answer goes.
Raise
What a POST /api/raise does: bring the window showing the page to the front (geop app, asked by another geop app of the same folder).
Response 🔒