forked from vhaudiquet/rhema-together
feat: add static previews to the room pane
The preview tool could only name a port, so a static build needed a server the terminal had to keep alive. `preview` now accepts a path: the app reads the file or folder over the room's ssh sandbox and serves it from a signed host, with `..` and dotfiles refused and a 16 MiB cap. The target is stored with the room and replayed as a durable event. The pane shows a static path with a reload control and keeps the port field as a local fallback.
This commit is contained in:
1 parent
5be17cf4ef
commit
36de0aace7
20 files changed
+1046
-145
No files matched your search
@@ -9,7 +9,8 @@ The room is a browser workspace:
|
||||
- **Chat** with the room and with `@rhema`. Human messages carry their
|
||||
author's name; the agent speaks through a `message` tool so that its
|
||||
private reasoning never leaks into the room.
|
||||
- **Preview** iframe for a dev server running inside the sandbox.
|
||||
- **Preview** iframe for a dev server or a static build, set from the
|
||||
chat by the agent's `preview` tool.
|
||||
- **Files** pane: the tree, a read-only file view, `git status`, and
|
||||
`git diff`.
|
||||
- **Terminal**: a real PTY in the sandbox, same target and key as the
|
||||
@@ -120,6 +121,17 @@ boundary.
|
||||
|
||||
## Preview
|
||||
|
||||
The preview shows one target per room. It is either a port inside the
|
||||
sandbox, or a static HTML file or folder read over ssh and served by the
|
||||
app. The agent sets it with the `preview` tool, and the choice is stored
|
||||
with the room, so a later visitor sees the same target.
|
||||
|
||||
A static target does not start a process. Point it at a build folder
|
||||
(`dist`, `web/.output/public`) or a single HTML file. The app reads files
|
||||
over the same ssh target the agent uses, refuses `..` and dotfiles, and
|
||||
stops at 16 MiB per file. Point it at a build folder rather than the
|
||||
repository root unless the whole tree is meant to be public.
|
||||
|
||||
The preview host is a signed subdomain of `TOGETHER_PREVIEW_ORIGIN`:
|
||||
|
||||
```
|
||||
@@ -127,19 +139,24 @@ http://preview.localhost:7800 local development
|
||||
https://preview.together.example.com production
|
||||
```
|
||||
|
||||
Each preview is served from
|
||||
`<scheme>://r<room>-p<port>-<expiry>-<hmac>.<preview host>/`. The HMAC
|
||||
covers the room, port, and expiry and is derived from the server's
|
||||
master key, so a room id alone is not enough to reach a preview. The
|
||||
address expires after 24 hours; reloading the pane mints a new one. DNS
|
||||
must resolve every subdomain of the preview host to the server (a
|
||||
wildcard `*.preview` record), and TLS must cover the wildcard. A copied
|
||||
preview URL works for anyone who has it until it expires; treat it as a
|
||||
read capability for that port.
|
||||
A port is served from
|
||||
`<scheme>://r<room>-p<port>-<expiry>-<hmac>.<preview host>/`.
|
||||
A static target is served from
|
||||
`<scheme>://r<room>-s<hash>-<expiry>-<hmac>.<preview host>/`, where
|
||||
`hash` covers the target's root and entry file. A link minted for one
|
||||
static target stops working when the preview moves. The HMAC covers the
|
||||
target and expiry and is derived from the server's master key, so a room
|
||||
id alone is not enough to reach a preview. The address expires after 24
|
||||
hours; loading the pane mints a new one. DNS must resolve every subdomain
|
||||
of the preview host to the server (a wildcard `*.preview` record), and
|
||||
TLS must cover the wildcard. A copied preview URL works for anyone who
|
||||
has it until it expires; treat it as a read capability for that target.
|
||||
|
||||
The proxy forwards ordinary HTTP through an ssh `direct-tcpip` channel
|
||||
to `127.0.0.1:<port>` inside the sandbox. WebSocket upgrades (Vite HMR)
|
||||
are not forwarded in v1; reload the pane after an edit.
|
||||
For a port, the proxy forwards ordinary HTTP through an ssh
|
||||
`direct-tcpip` channel to `127.0.0.1:<port>` inside the sandbox. For a
|
||||
static target, each request runs one short read over ssh. WebSocket
|
||||
upgrades (Vite HMR) are not forwarded in v1; reload the pane after an
|
||||
edit, and disable HMR for the preview when a dev server insists on it.
|
||||
|
||||
### Caddy
|
||||
|
||||
@@ -190,9 +207,10 @@ Every field can be set in the YAML file (`TOGETHER_CONFIG`, default
|
||||
to a host it names, so open signup also makes the server reachable
|
||||
from anywhere as a port scanner. Turn it on only when you trust
|
||||
everyone who can reach `/register`.
|
||||
- A preview host is a signed capability for one room and port. It
|
||||
expires after 24 hours, and preview responses carry
|
||||
`Referrer-Policy: no-referrer`. A copied URL works until it expires.
|
||||
- A preview host is a signed capability for one room and one target,
|
||||
either a port or a static tree. It expires after 24 hours, and preview
|
||||
responses carry `Referrer-Policy: no-referrer`. A copied URL works
|
||||
until it expires.
|
||||
- Removing a member or archiving a room ends that account's event feed,
|
||||
presence socket, and terminal within a few seconds. The terminal and
|
||||
preview proxy pin the SSH host key on first login and refuse a
|
||||
|
||||
Reference in new issue
Block a user