fix(v0.4): mirror size-clamp bug + session manager page

The mirror looked broken because a backgrounded tab on one device still pinned
the shared PTY to its (default 80x24) size — so the device actively viewing got
a cramped terminal.

Fix: only an ACTIVELY-VIEWING client votes on PTY size.
- attachWs no longer seeds a default size vote (a join may be a hidden mirror)
- new 'blur' client message + clearClientDims(): a tab going hidden withdraws its
  size vote (still mirrors output); show() re-casts it
- PTY size = min cols/rows across clients that have actually reported dims
- session/protocol tests cover hidden-mirror-doesn't-clamp + blur

Session manager (separate page, for the 'too many sessions' problem):
- GET stays; add DELETE /live-sessions/:id and DELETE /live-sessions[?detached=1]
- manager.killById(); LiveSessionInfo gains cols/rows
- public/manage.html + manage.ts: list/open/kill sessions, kill-all / kill-detached,
  auto-refresh; 🗂 toolbar button; bundled as a 2nd esbuild entry

Verified: two concurrent clients mirror output + shared input; manage page
lists/kills (3→2→0). 225 tests green, tsc clean.
This commit is contained in:
Yaojia Wang
2026-06-19 11:04:38 +02:00
parent 22210fadbc
commit 021a514b2d
13 changed files with 467 additions and 44 deletions

View File

@@ -659,3 +659,144 @@ body {
background: var(--red);
color: #2a0808;
}
/* ── Session Manager page (manage.html) ──────────────────────────── */
#manage-root {
max-width: 760px;
margin: 0 auto;
padding: 24px 16px 60px;
}
.mg-header {
margin-bottom: 18px;
}
.mg-title {
font-size: 22px;
font-weight: 700;
color: #fff;
}
.mg-sub {
color: var(--text-dim);
font-size: 13px;
margin-top: 2px;
}
.mg-bar {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 14px;
}
.mg-btn {
background: var(--surface-2);
border: 1px solid var(--border-strong);
color: var(--text);
border-radius: 8px;
padding: 8px 14px;
cursor: pointer;
font: inherit;
font-size: 13px;
text-decoration: none;
transition: background 0.1s ease;
}
.mg-btn:hover {
background: var(--surface-3);
}
.mg-btn.warn {
border-color: rgba(245, 177, 76, 0.5);
color: var(--amber);
}
.mg-btn.danger {
border-color: rgba(255, 107, 107, 0.5);
color: var(--red);
}
.mg-list {
display: flex;
flex-direction: column;
gap: 8px;
}
.mg-row {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 14px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 10px;
}
.mg-main {
flex: 1 1 auto;
min-width: 0;
}
.mg-top {
display: flex;
align-items: center;
gap: 8px;
}
.mg-name {
color: #fff;
font-weight: 600;
}
.mg-watch {
font-size: 11px;
color: var(--text-faint);
background: var(--surface-3);
border-radius: 5px;
padding: 1px 6px;
}
.mg-watch.live {
color: var(--green);
background: rgba(70, 208, 127, 0.14);
}
.mg-status {
font-size: 11px;
color: var(--text-dim);
}
.mg-status.mg-waiting {
color: var(--amber);
font-weight: 600;
}
.mg-status.mg-working {
color: var(--accent);
}
.mg-meta {
color: var(--text-faint);
font-size: 12px;
margin-top: 3px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-family: Menlo, Consolas, monospace;
}
.mg-actions {
flex: none;
display: flex;
gap: 6px;
}
.mg-open {
background: var(--accent);
color: #fff;
border-radius: 8px;
padding: 7px 13px;
text-decoration: none;
font-size: 13px;
}
.mg-open:hover {
background: var(--accent-2);
}
.mg-kill {
background: transparent;
border: 1px solid rgba(255, 107, 107, 0.4);
color: var(--red);
border-radius: 8px;
padding: 7px 13px;
cursor: pointer;
font: inherit;
font-size: 13px;
}
.mg-kill:hover {
background: rgba(255, 107, 107, 0.14);
}
.mg-empty {
color: var(--text-dim);
padding: 30px 0;
text-align: center;
}