feat(v0.4): session manager grid with live preview thumbnails

The flat session list didn't tell you what each session was doing. Rebuild
/manage.html as a full-page grid where each card renders a LIVE preview
thumbnail — a read-only xterm showing the session's actual current screen,
scaled down like a screenshot — so you can recognize each at a glance.

- RingBuffer.tail(maxBytes): newest scrollback on chunk boundaries (no ANSI/UTF-8
  split); GET /live-sessions/:id/preview returns {cols,rows,data} (no attach, so
  it doesn't inflate watcher counts or keep sessions alive)
- manage.ts: card grid; per card a scaled read-only Terminal renders CLEAR+tail,
  auto-refresh every 4s, click thumbnail/Open to join, Kill / bulk kill
- bundles xterm into manage.js (+manage.css linked in manage.html)
- ring-buffer tail tests

Verified: 3 sessions rendered as recognizable thumbnails (top / git log / ls),
colored, with status/age; click opens. 228 tests green, tsc clean.
This commit is contained in:
Yaojia Wang
2026-06-19 11:37:32 +02:00
parent 199e29d15b
commit 787f806e02
7 changed files with 278 additions and 87 deletions

View File

@@ -662,9 +662,12 @@ body {
/* ── Session Manager page (manage.html) ──────────────────────────── */
#manage-root {
max-width: 760px;
max-width: 1200px;
margin: 0 auto;
padding: 24px 16px 60px;
height: 100%;
overflow-y: auto;
box-sizing: border-box;
}
.mg-header {
margin-bottom: 18px;
@@ -708,32 +711,54 @@ body {
border-color: rgba(255, 107, 107, 0.5);
color: var(--red);
}
.mg-list {
.mg-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
gap: 14px;
}
.mg-card {
display: flex;
flex-direction: column;
gap: 8px;
}
.mg-row {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 14px;
gap: 10px;
padding: 12px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
border-radius: 12px;
}
.mg-main {
flex: 1 1 auto;
min-width: 0;
}
.mg-top {
.mg-card-head {
display: flex;
align-items: center;
gap: 8px;
}
.mg-name {
flex: 1 1 auto;
min-width: 0;
color: #fff;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* Live preview thumbnail (scaled read-only xterm) */
.mg-thumb {
position: relative;
width: 100%;
min-height: 90px;
background: #0e0f13;
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
cursor: pointer;
}
.mg-thumb:hover {
border-color: var(--accent);
}
.mg-thumb-inner {
position: absolute;
top: 0;
left: 0;
transform-origin: top left;
padding: 4px;
}
.mg-watch {
font-size: 11px;
@@ -759,18 +784,20 @@ body {
}
.mg-meta {
color: var(--text-faint);
font-size: 12px;
margin-top: 3px;
font-size: 11px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-family: Menlo, Consolas, monospace;
}
.mg-actions {
flex: none;
display: flex;
gap: 6px;
}
.mg-actions .mg-open {
flex: 1 1 auto;
text-align: center;
}
.mg-open {
background: var(--accent);
color: #fff;