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

254
web/static/app.css Normal file
View file

@ -0,0 +1,254 @@
/* sessions-web. A quiet, monochrome UI in the style of Expo's design language:
slate greys, hairline borders, a black primary action, soft tinted status badges. */
:root {
--bg: #ffffff;
--bg-subtle: #f8f9fa;
--bg-hover: #f1f3f5;
--line: #e6e8eb;
--line-strong: #d7dbdf;
--fg: #11181c;
--fg-2: #687076;
--fg-3: #889096;
--primary: #11181c;
--on-primary: #ffffff;
--ok: #18794e; --ok-bg: #e9f9ee;
--warn: #ad5700; --warn-bg: #fff4d5;
--bad: #cd2b31; --bad-bg: #ffefef;
--idle: #687076; --idle-bg: #f1f3f5;
--focus: #0091ff;
--shadow: 0 1px 2px rgba(17, 24, 28, .04), 0 1px 1px rgba(17, 24, 28, .03);
--shadow-lg: 0 10px 30px -10px rgba(17, 24, 28, .25);
--radius: 12px;
--radius-sm: 8px;
--font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
color-scheme: light;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #151718;
--bg-subtle: #1a1d1e;
--bg-hover: #202425;
--line: #2b2f31;
--line-strong: #393e40;
--fg: #ecedee;
--fg-2: #9ba1a6;
--fg-3: #787f85;
--primary: #ecedee;
--on-primary: #151718;
--ok: #4cc38a; --ok-bg: #0f291e;
--warn: #f1a10d; --warn-bg: #2c2100;
--bad: #ff6369; --bad-bg: #3c181a;
--idle: #9ba1a6; --idle-bg: #202425;
--focus: #52a9ff;
--shadow: 0 1px 2px rgba(0, 0, 0, .3);
--shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, .7);
color-scheme: dark;
}
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
margin: 0;
background: var(--bg);
color: var(--fg);
font: 15px/1.5 var(--font);
-webkit-font-smoothing: antialiased;
font-feature-settings: "cv11", "ss01";
}
a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
/* ---------------------------------------------------------------- top bar */
.top {
position: sticky; top: 0; z-index: 10;
background: color-mix(in srgb, var(--bg) 85%, transparent);
-webkit-backdrop-filter: saturate(180%) blur(12px);
backdrop-filter: saturate(180%) blur(12px);
border-bottom: 1px solid var(--line);
}
.top-inner { height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.mark { width: 24px; height: 24px; flex: none; }
.mark rect { fill: var(--primary); }
.mark path { stroke: var(--on-primary); }
.user {
font-size: 13px; color: var(--fg-2);
padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px;
max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* ---------------------------------------------------------------- layout */
.grid { display: grid; gap: 32px; padding-top: 32px; padding-bottom: 64px; }
@media (min-width: 900px) {
.grid { grid-template-columns: minmax(0, 1fr) 340px; gap: 48px; padding-top: 48px; }
.col-side { position: sticky; top: 88px; align-self: start; }
}
.intro h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
.intro p { margin: 6px 0 0; color: var(--fg-2); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 32px 0 12px; }
.section-head h2 { font-size: 17px; font-weight: 600; }
.counter { font-size: 13px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.list { display: grid; gap: 12px; }
/* ---------------------------------------------------------------- cards */
.card {
background: var(--bg);
border: 1px solid var(--line);
border-radius: var(--radius);
padding: 16px;
box-shadow: var(--shadow);
transition: border-color .15s, opacity .2s, transform .2s;
}
.card:hover { border-color: var(--line-strong); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.title { font-size: 16px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.meta { margin-top: 4px; font-size: 13px; color: var(--fg-2); display: flex; flex-wrap: wrap; gap: 0 6px; }
.mono { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.dim { color: var(--fg-3); }
.warn {
margin-top: 12px; padding: 8px 12px; border-radius: var(--radius-sm);
background: var(--warn-bg); color: var(--warn); font-size: 13px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.card.archived { background: var(--bg-subtle); box-shadow: none; }
.card.archived .title { color: var(--fg-2); }
.card.pending { opacity: .7; }
.card.leaving { opacity: 0; transform: scale(.98); }
.card.ghost { border-style: dashed; box-shadow: none; }
.card.ghost .title { color: var(--fg-2); }
.empty {
display: grid; gap: 4px; text-align: center; padding: 40px 16px;
border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--fg-2); font-size: 14px;
}
.empty strong { color: var(--fg); font-weight: 600; }
/* ---------------------------------------------------------------- badges */
.badge {
flex: none; display: inline-flex; align-items: center; gap: 6px;
font-size: 12px; font-weight: 500; line-height: 1;
padding: 5px 9px; border-radius: 99px;
background: var(--idle-bg); color: var(--idle);
}
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.activating, .badge.deactivating, .badge.reloading { background: var(--warn-bg); color: var(--warn); }
.badge.activating i, .badge.deactivating i, .badge.reloading i { animation: pulse 1s ease-in-out infinite; }
.badge.failed, .badge.unknown { background: var(--bad-bg); color: var(--bad); }
/* ---------------------------------------------------------------- buttons */
.btn {
font: inherit; font-size: 14px; font-weight: 500; line-height: 20px;
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
min-height: 36px; padding: 7px 14px;
border-radius: var(--radius-sm); border: 1px solid transparent;
background: var(--primary); color: var(--on-primary);
text-decoration: none; cursor: pointer; white-space: nowrap;
transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn:hover { opacity: .88; }
.btn.secondary { background: var(--bg); color: var(--fg); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--bg-hover); opacity: 1; }
.btn.ghost { background: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--fg); opacity: 1; }
.btn.wide { flex: 1; }
.btn:disabled { cursor: progress; opacity: .6; }
.btn.loading::before {
content: ""; width: 14px; height: 14px; border-radius: 50%;
border: 2px solid currentColor; border-right-color: transparent;
animation: spin .7s linear infinite;
}
form.inline { display: contents; }
/* ---------------------------------------------------------------- panels and forms */
.col-side { display: grid; gap: 16px; align-content: start; }
.panel {
background: var(--bg-subtle);
border: 1px solid var(--line);
border-radius: var(--radius);
padding: 20px;
}
.panel h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h2 { margin: 0; }
details.panel > summary::after { content: "+"; font-size: 18px; color: var(--fg-2); line-height: 1; }
details.panel[open] > summary::after { content: "–"; }
details.panel[open] > summary { margin-bottom: 4px; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--fg); margin: 14px 0 6px; }
.opt { font-weight: 400; color: var(--fg-3); }
input, select {
font: inherit; font-size: 15px; width: 100%;
min-height: 40px; padding: 8px 12px;
border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
background: var(--bg); color: var(--fg);
transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--fg-3); }
input:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
select {
appearance: none; -webkit-appearance: none; padding-right: 36px;
background-image: linear-gradient(45deg, transparent 50%, var(--fg-2) 50%), linear-gradient(135deg, var(--fg-2) 50%, transparent 50%);
background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
background-size: 5px 5px; background-repeat: no-repeat;
}
.panel .actions { margin-top: 20px; }
.hint { margin: 12px 0 0; font-size: 12.5px; color: var(--fg-2); }
.note { margin: 0; font-size: 12.5px; color: var(--fg-3); padding: 0 4px; }
/* ---------------------------------------------------------------- archive */
details.archive { margin-top: 28px; }
details.archive > summary {
cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px;
font-size: 14px; font-weight: 500; color: var(--fg-2); margin-bottom: 12px;
}
details.archive > summary::-webkit-details-marker { display: none; }
details.archive > summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 16px; }
details.archive[open] > summary::before { transform: rotate(90deg); }
.count { font-size: 12px; padding: 1px 7px; border-radius: 99px; background: var(--bg-hover); }
/* ---------------------------------------------------------------- messages */
.callout { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-top: 24px; }
.callout.err { background: var(--bad-bg); color: var(--bad); }
#toasts {
position: fixed; z-index: 20; left: 16px; right: 16px; bottom: 16px;
display: grid; gap: 8px; justify-items: center; pointer-events: none;
}
@media (min-width: 640px) { #toasts { left: auto; right: 24px; bottom: 24px; justify-items: end; } }
.toast {
pointer-events: auto; max-width: 420px;
padding: 12px 16px; border-radius: var(--radius-sm);
background: var(--primary); color: var(--on-primary);
font-size: 14px; box-shadow: var(--shadow-lg);
animation: rise .2s ease-out; transition: opacity .3s, transform .3s;
}
.toast.err { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}