Add repos from the page, answer actions in place, Expo-style redesign

Add repository:
- New remote verb `add-repo KEY OWNER/NAME`. Off unless config.toml has
  [repo_add] (base_url + owners). Only listed owners; the dev box builds
  the URL itself, checks it with `git ls-remote` (bot access), then
  appends to [repos] under the lock. No URL crosses the SSH link.
- `repos` also reports where adding is allowed, so the page shows the
  form only when it's on and rejects other hosts before calling SSH.
- set_toml_string inserts after the section's last key, not after
  trailing blank lines / the next section's comments.

Responsiveness:
- web/static/app.js (progressive enhancement; every form still works
  without JS): forms go via fetch and get a JSON answer instead of
  POST-redirect-GET; buttons/cards show the change immediately; the
  list refreshes itself (15 s, 3 s while something is starting).
- `repos` is cached for 5 min (refreshed on add-repo), so a page view
  is one SSH call instead of two.
- `list` reads all unit states with one `systemctl show` instead of one
  per session: 676 -> 374 ms on the dev box with 21 sessions.
- Static assets are content-hashed and cached immutably.

Design: slate greys, hairline borders, black primary action, tinted
status badges, monospace repo/branch, two columns on desktop, stacked
on phones, light and dark.

Docs: README security model, AGENTS.md (JS convention, add-repo
invariant), config.example.toml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MCUMXh8zZConC75Mptbeou
This commit is contained in:
agent 2026-11-10 22:17:37 +00:00
parent 39997de1e8
commit 1b3172bd50
10 changed files with 1084 additions and 92 deletions

View file

@ -17,7 +17,7 @@ you then talk to it from the Claude app or the "Open in Claude" link.
|---|---|---|
| [`dev/sessions_ctl.py`](dev/sessions_ctl.py) | dev box, `~/.local/bin/sessions-ctl` | CLI + SSH forced command. Stdlib Python ≥ 3.11 |
| [`dev/systemd/`](dev/systemd) | dev box, `~/.config/systemd/user/` | one unit per session; hourly key-IP refresh |
| [`web/app.py`](web/app.py) | prod, container | session list + buttons; stdlib, no JS, no login of its own |
| [`web/app.py`](web/app.py), [`web/static/`](web/static) | prod, container | session list + buttons; stdlib, optional JS, no login of its own |
| [`compose.yaml`](compose.yaml) | prod, panel | how the panel builds and runs the container |
## Security model
@ -31,9 +31,10 @@ from="<IP of reudy.net>",restrict,command="…/sessions-ctl --remote" ssh-ed2551
- **`command=`**: whatever prod asks for, sshd runs `sessions-ctl --remote`. It
reads `$SSH_ORIGINAL_COMMAND`, splits it without a shell, and accepts only
`list repos status create start stop archive unarchive health`. Names,
titles and branches are checked against strict patterns; repos are picked by key from an allowlist
in the config, so no URL or path crosses the link.
`list repos add-repo status create start stop archive unarchive health`.
Names, titles and branches are checked against strict patterns; repos are
picked by key from an allowlist in the config, so no URL crosses the link.
`add-repo KEY OWNER/NAME` (see below) sends an owner/name path, never a URL.
- **`restrict`**: no PTY, no port/agent/X11 forwarding. (Tested: `-L` is refused.)
- **`from=`**: the key only works from the address `reudy.net` resolves to.
sshd runs with `UseDNS no`, so a hostname there would never match; instead
@ -51,8 +52,13 @@ from="<IP of reudy.net>",restrict,command="…/sessions-ctl --remote" ssh-ed2551
users. Authelia's policy for the domain should be `two_factor`. It is by
default on prod.
- Cross-site POSTs are refused by checking `Sec-Fetch-Site`/`Origin`, so no
CSRF secret is needed. The page has a strict CSP and no JavaScript. The dev
box host key is pinned (`StrictHostKeyChecking yes`).
CSRF secret is needed. The dev box host key is pinned (`StrictHostKeyChecking yes`).
- The page has a strict CSP: `script-src 'self'`, no inline script, no
third-party anything. `web/static/app.js` is progressive enhancement only:
every form also works with JavaScript off (POST, then redirect). With it,
forms are sent with `fetch` and answered as JSON, and the list refreshes
itself (every 15 s, every 3 s while a session is starting or stopping, and
only while the tab is visible).
- The container is configured only by environment variables, including the
SSH key (one base64 line). At start it writes the key to a 0600 file on its
`/tmp` tmpfs. It runs rootless with a read-only root filesystem and all
@ -68,6 +74,17 @@ instructions only arrive through Remote Control (your claude.ai account). The
remaining risk is prompt injection: a fetched page or a malicious repo file can
steer a session into running commands without anyone confirming them. Only
allowlist repos you trust, and treat the dev box as disposable.
**Adding repos from the page** is off unless `config.toml` has a `[repo_add]`
section. With it, the page's *Add repository* form sends `add-repo KEY
OWNER/NAME`. The dev box accepts only owners listed in `repo_add.owners`,
builds the URL itself from `repo_add.base_url`, checks with `git ls-remote`
that the bot account can read the repo, and then appends it to `[repos]`. So
a hijacked prod could at most allowlist repos that (a) belong to an owner you
listed and (b) the bot account was already given access to. That is the same
set you'd trust anyway, but it does move the decision for that set from
editing `config.toml` to clicking a button. Removing a repo is still a
config edit.
The one-time "Bypass Permissions mode" warning would block an unattended
session. `"skipDangerousModePermissionPrompt": true` in `~/.claude/settings.json`
suppresses it. Without that setting the page shows *"stuck on the
@ -189,7 +206,9 @@ sessions.reudy.net {
| Session `failed` | `journalctl --user -u claude-session@NAME -n 50`. After 5 crashes in 10 min systemd gives up; fix the cause, then Start again |
| "stuck on the folder-trust prompt" | `tmux -L claude-NAME attach`, accept, detach. Then the trust field has moved in a Claude Code update, so fix `trust_workspace()` |
| "stuck on the bypass-permissions warning" | Add `"skipDangerousModePermissionPrompt": true` to `~/.claude/settings.json`, then `tmux -L claude-NAME attach`, accept, detach |
| No "Open in Claude" link | The link is read from the pane once Remote Control is up; refresh after a few seconds |
| No "Open in Claude" link | The link is read from the pane once Remote Control is up; the page picks it up within seconds |
| *Add repository* missing | `[repo_add]` isn't set in `config.toml` (it's off by default). The page caches the repo list for 5 min |
| "can't reach OWNER/NAME" when adding | Typo, or the Forgejo bot account hasn't been added to that repo |
## Relation to `sess`