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

Open
agent wants to merge 1 commit from session/add-repo into main
Member

Three things that were asked for together: add repos from the web page, stop making every click wait for a full reload, and redesign the page in the style of Expo's design language.

Add repository from the page

  • New remote verb add-repo KEY OWNER/NAME. Off by default. It's on only when config.toml has a [repo_add] section with base_url and owners. It's off on the dev box right now, see After merge below.
  • No URL crosses the SSH link. The dev box builds <base_url><owner>/<name>.git itself and accepts only listed owners. It checks the repo with git ls-remote (so the bot account must already have access), then appends the repo to [repos] under the lock and keeps the file at 0600.
  • repos now also reports add: {base_url, owners}. The page shows the Add repository form only when adding is on. It accepts owner/name or any ssh/https/scp clone URL on the same host. A URL on another host (say GitHub) is rejected on prod before any SSH call.
  • Security note: the allowlist is "the trust decision". With this turned on, a hijacked prod could allowlist repos that belong to a listed owner and that the bot account can already read. That set is already gated by Forgejo, but the decision moves from editing a file to clicking a button. This is spelled out in the README. Removing a repo is still a config edit.
  • set_toml_string now inserts a new key after the section's last key. Before, it went after trailing blank lines or the next section's comments.

Responsiveness

The wait came from POST → 303 → GET, and every GET made two SSH calls (list + repos), where list costs ~0.7 s on the box.

  • web/static/app.js, progressive enhancement. Every form still works with JS off. With JS on, forms are sent with fetch and the server answers {ok, message|error} as JSON instead of redirecting. The button and card change straight away (Stopping…, a dashed "Cloning" placeholder card for a new session), and a background refresh brings the real state. The list refreshes itself every 15 s, or every 3 s while something is starting or stopping or waiting for its Remote Control link. It refreshes only while the tab is visible. The archive section remembers whether it was open, and toasts replace the flash banner.
  • repos is cached for 5 min and updated straight from the add-repo answer, so a page view costs one SSH call.
  • list gets every unit's state from one systemctl show instead of one call per session: 676 → 374 ms on the dev box with 21 sessions. Output is identical to the installed version.
  • CSS and JS are served with a content-hash ?v= and immutable caching.
  • CSP adds only script-src 'self'; connect-src 'self'. There is no inline script and nothing third-party. The cross-site POST check and the Authelia header check apply to the fetch requests too (tested).

Redesign

The look follows Expo's design language. Slate greys, hairline borders, a black primary action (white in dark mode), tinted status badges with a dot, monospace repo/branch, and Inter/system type. On desktop it's two columns with a sticky side panel; on phones it stacks. Light and dark follow the system setting.

AGENTS.md changes

"No JavaScript" becomes "works without JavaScript; app.js is progressive enhancement" with the rules for keeping it that way. Invariant 2 now describes add-repo. The README and config.example.toml are updated to match.

Tested

  • python3 -m unittest discover -s dev/tests: 36 OK, 8 new (add-repo validation/owner/dupes/unreachable/off, unit_states batching, TOML placement).
  • python3 -m unittest discover -s web/tests: 21 OK, 11 new. These cover URL parsing, a real HTTP server with a fake dev box (JSON vs 303, CSP, asset caching, repos cache, cross-site/unauthenticated still refused, add-repo sends only owner/name).
  • Headless Chromium against the app with a stateful fake dev box: stop, create, add-repo (success and wrong-host error), start, and archive with the archive section open. All of these update in place and the page never reloads. No console errors. I checked screenshots at 1280 px and 390 px in light and dark.
  • list from the new code against the live dev box (read-only): same result as the installed version.
  • Not tested: the container build on prod, and the end-to-end path through Authelia with a real add-repo writing the live config.

After merge

  1. On the dev box: ./dev/install.sh (installs the new sessions-ctl).
  2. To turn on Add repository, add this to ~/.config/sessions/config.toml:
    [repo_add]
    base_url = "ssh://git@git.reudy.net:14922/"
    owners = ["reudy-net"]
    
  3. Redeploy the app on prod (the Containerfile now also copies web/static/).

🤖 Generated with Claude Code

https://claude.ai/code/session_01MCUMXh8zZConC75Mptbeou

Three things that were asked for together: add repos from the web page, stop making every click wait for a full reload, and redesign the page in the style of Expo's design language. ## Add repository from the page - New remote verb **`add-repo KEY OWNER/NAME`**. **Off by default.** It's on only when `config.toml` has a `[repo_add]` section with `base_url` and `owners`. It's off on the dev box right now, see *After merge* below. - No URL crosses the SSH link. The dev box builds `<base_url><owner>/<name>.git` itself and accepts only listed owners. It checks the repo with `git ls-remote` (so the bot account must already have access), then appends the repo to `[repos]` under the lock and keeps the file at 0600. - `repos` now also reports `add: {base_url, owners}`. The page shows the *Add repository* form only when adding is on. It accepts `owner/name` or any ssh/https/scp clone URL on the same host. A URL on another host (say GitHub) is rejected on prod before any SSH call. - **Security note:** the allowlist is "the trust decision". With this turned on, a hijacked prod could allowlist repos that belong to a listed owner *and* that the bot account can already read. That set is already gated by Forgejo, but the decision moves from editing a file to clicking a button. This is spelled out in the README. Removing a repo is still a config edit. - `set_toml_string` now inserts a new key after the section's last key. Before, it went after trailing blank lines or the next section's comments. ## Responsiveness The wait came from POST → 303 → GET, and every GET made two SSH calls (`list` + `repos`), where `list` costs ~0.7 s on the box. - **`web/static/app.js`, progressive enhancement.** Every form still works with JS off. With JS on, forms are sent with `fetch` and the server answers `{ok, message|error}` as JSON instead of redirecting. The button and card change straight away (Stopping…, a dashed "Cloning" placeholder card for a new session), and a background refresh brings the real state. The list refreshes itself every 15 s, or every 3 s while something is starting or stopping or waiting for its Remote Control link. It refreshes only while the tab is visible. The archive section remembers whether it was open, and toasts replace the flash banner. - `repos` is cached for 5 min and updated straight from the `add-repo` answer, so a page view costs one SSH call. - `list` gets every unit's state from **one** `systemctl show` instead of one call per session: **676 → 374 ms** on the dev box with 21 sessions. Output is identical to the installed version. - CSS and JS are served with a content-hash `?v=` and `immutable` caching. - CSP adds only `script-src 'self'; connect-src 'self'`. There is no inline script and nothing third-party. The cross-site POST check and the Authelia header check apply to the fetch requests too (tested). ## Redesign The look follows Expo's design language. Slate greys, hairline borders, a black primary action (white in dark mode), tinted status badges with a dot, monospace repo/branch, and Inter/system type. On desktop it's two columns with a sticky side panel; on phones it stacks. Light and dark follow the system setting. ## AGENTS.md changes "No JavaScript" becomes "works without JavaScript; `app.js` is progressive enhancement" with the rules for keeping it that way. Invariant 2 now describes `add-repo`. The README and `config.example.toml` are updated to match. ## Tested - `python3 -m unittest discover -s dev/tests`: 36 OK, 8 new (add-repo validation/owner/dupes/unreachable/off, unit_states batching, TOML placement). - `python3 -m unittest discover -s web/tests`: 21 OK, 11 new. These cover URL parsing, a real HTTP server with a fake dev box (JSON vs 303, CSP, asset caching, repos cache, cross-site/unauthenticated still refused, add-repo sends only owner/name). - Headless Chromium against the app with a stateful fake dev box: stop, create, add-repo (success and wrong-host error), start, and archive with the archive section open. All of these update in place and the page never reloads. No console errors. I checked screenshots at 1280 px and 390 px in light and dark. - `list` from the new code against the live dev box (read-only): same result as the installed version. - **Not tested:** the container build on prod, and the end-to-end path through Authelia with a real `add-repo` writing the live config. ## After merge 1. On the dev box: `./dev/install.sh` (installs the new `sessions-ctl`). 2. To turn on *Add repository*, add this to `~/.config/sessions/config.toml`: ```toml [repo_add] base_url = "ssh://git@git.reudy.net:14922/" owners = ["reudy-net"] ``` 3. Redeploy the app on prod (the Containerfile now also copies `web/static/`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01MCUMXh8zZConC75Mptbeou
agent added 1 commit 2026-11-10 23:17:59 +01:00
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 pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin session/add-repo:session/add-repo
git checkout session/add-repo
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: reudy-net/sessions#3
No description provided.