fix: mobile terminal scroll - z-index viewport above screen rows

xterm.js has known limited mobile touch support because the viewport
sits underneath the screen rows. Fixed by:
- Setting xterm-viewport z-index: 10 on mobile to receive touch events
- Enabling native browser scrolling with touch-action: pan-y
- Adding -webkit-overflow-scrolling: touch for iOS momentum
- Skipping custom JS scroll handlers on mobile devices
- Moving wizard drag listeners to only attach during actual drag

See: https://github.com/xtermjs/xterm.js/issues/5377

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-31 05:36:12 +01:00
co-authored by Claude Opus 4.5
parent 6123ce8ba9
commit ad8410e29a
4 changed files with 279 additions and 130 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ When user says "COM":
1. Increment version in BOTH `package.json` AND `CLAUDE.md` 1. Increment version in BOTH `package.json` AND `CLAUDE.md`
2. Run: `git add -A && git commit -m "chore: bump version to X.XXXX" && git push && npm run build && systemctl --user restart claudeman-web` 2. Run: `git add -A && git commit -m "chore: bump version to X.XXXX" && git push && npm run build && systemctl --user restart claudeman-web`
**Version**: 0.1444 (must match `package.json`) **Version**: 0.1445 (must match `package.json`)
## Project Overview ## Project Overview
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "claudeman", "name": "claudeman",
"version": "0.1444", "version": "0.1445",
"description": "The missing control plane for Claude Code - run 20 autonomous agents with real-time monitoring and session persistence", "description": "The missing control plane for Claude Code - run 20 autonomous agents with real-time monitoring and session persistence",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",
+87 -6
View File
@@ -973,6 +973,81 @@ class ClaudemanApp {
this.terminal.scrollLines(lines); this.terminal.scrollLines(lines);
}, { passive: false }); }, { passive: false });
// Touch scrolling - only use custom JS scrolling on desktop
// Mobile uses native browser scrolling via CSS touch-action: pan-y
const isMobileDevice = MobileDetection.isTouchDevice() && window.innerWidth < 1024;
if (!isMobileDevice) {
// Desktop touch scrolling with custom momentum
let touchLastY = 0;
let pendingDelta = 0;
let velocity = 0;
let lastTime = 0;
let scrollFrame = null;
let isTouching = false;
const viewport = container.querySelector('.xterm-viewport');
// Single RAF loop handles both touch and momentum
const scrollLoop = (timestamp) => {
if (!viewport) return;
const dt = lastTime ? (timestamp - lastTime) / 16.67 : 1; // Normalize to 60fps
lastTime = timestamp;
if (isTouching) {
// During touch: apply pending delta
if (pendingDelta !== 0) {
viewport.scrollTop += pendingDelta;
pendingDelta = 0;
}
scrollFrame = requestAnimationFrame(scrollLoop);
} else if (Math.abs(velocity) > 0.1) {
// Momentum phase
viewport.scrollTop += velocity * dt;
velocity *= 0.94; // Smooth deceleration
scrollFrame = requestAnimationFrame(scrollLoop);
} else {
scrollFrame = null;
velocity = 0;
}
};
container.addEventListener('touchstart', (ev) => {
if (ev.touches.length === 1) {
touchLastY = ev.touches[0].clientY;
pendingDelta = 0;
velocity = 0;
isTouching = true;
lastTime = 0;
if (!scrollFrame) {
scrollFrame = requestAnimationFrame(scrollLoop);
}
}
}, { passive: true });
container.addEventListener('touchmove', (ev) => {
if (ev.touches.length === 1 && isTouching) {
const touchY = ev.touches[0].clientY;
const delta = touchLastY - touchY;
pendingDelta += delta;
velocity = delta * 1.2; // Track for momentum
touchLastY = touchY;
}
}, { passive: true });
container.addEventListener('touchend', () => {
isTouching = false;
// Momentum continues in scrollLoop
}, { passive: true });
container.addEventListener('touchcancel', () => {
isTouching = false;
velocity = 0;
}, { passive: true });
}
// Mobile: native scrolling handles touch via CSS
// Welcome message // Welcome message
this.showWelcome(); this.showWelcome();
@@ -5133,6 +5208,12 @@ class ClaudemanApp {
wizardContent.style.left = `${startLeft}px`; wizardContent.style.left = `${startLeft}px`;
wizardContent.style.top = `${startTop}px`; wizardContent.style.top = `${startTop}px`;
// Add move/end listeners only during drag (prevents blocking scroll)
document.addEventListener('mousemove', moveHandler);
document.addEventListener('mouseup', upHandler);
document.addEventListener('touchmove', moveHandler, { passive: false });
document.addEventListener('touchend', upHandler);
e.preventDefault(); e.preventDefault();
}; };
@@ -5171,19 +5252,19 @@ class ClaudemanApp {
const upHandler = () => { const upHandler = () => {
if (isDragging) { if (isDragging) {
isDragging = false; isDragging = false;
// Remove move/end listeners when drag ends
document.removeEventListener('mousemove', moveHandler);
document.removeEventListener('mouseup', upHandler);
document.removeEventListener('touchmove', moveHandler);
document.removeEventListener('touchend', upHandler);
// Save agent window positions for next drag // Save agent window positions for next drag
this.saveAgentWindowRelativePositions(); this.saveAgentWindowRelativePositions();
} }
}; };
// Mouse events // Only attach start handlers - move/end are added dynamically during drag
header.addEventListener('mousedown', startHandler); header.addEventListener('mousedown', startHandler);
document.addEventListener('mousemove', moveHandler);
document.addEventListener('mouseup', upHandler);
// Touch events
header.addEventListener('touchstart', startHandler, { passive: false }); header.addEventListener('touchstart', startHandler, { passive: false });
document.addEventListener('touchmove', moveHandler, { passive: false });
document.addEventListener('touchend', upHandler);
this.wizardDragListeners = { this.wizardDragListeners = {
header, header,
+190 -122
View File
@@ -1641,15 +1641,22 @@ body {
will-change: contents; will-change: contents;
/* Minimum width to prevent 0-column terminal on mobile */ /* Minimum width to prevent 0-column terminal on mobile */
min-width: 280px; min-width: 280px;
/* Allow touch scrolling */
touch-action: pan-y;
} }
.terminal-container .xterm { .terminal-container .xterm {
height: 100%; height: 100%;
padding: 0; padding: 0;
/* Allow touch scrolling in xterm */
touch-action: pan-y;
} }
.terminal-container .xterm-viewport { .terminal-container .xterm-viewport {
background: transparent !important; background: transparent !important;
/* Enable touch scrolling in viewport */
touch-action: pan-y;
-webkit-overflow-scrolling: touch;
} }
/* Welcome Overlay */ /* Welcome Overlay */
@@ -7852,17 +7859,13 @@ kbd {
Tablet Breakpoint (430px - 768px) Tablet Breakpoint (430px - 768px)
============================================================================ */ ============================================================================ */
@media (max-width: 768px) and (min-width: 430px) { @media (max-width: 768px) and (min-width: 430px) {
/* Safe area padding for iOS devices */ /* Compact header for tablet - includes safe area padding */
.ios-device .app {
padding-left: var(--safe-area-left);
padding-right: var(--safe-area-right);
}
/* Compact header for tablet */
.header { .header {
min-height: 44px; min-height: 44px;
max-height: 64px; max-height: 64px;
padding: 0.35rem 0.5rem; padding: 0.35rem 0.5rem;
padding-left: calc(0.5rem + var(--safe-area-left));
padding-right: calc(0.5rem + var(--safe-area-right));
} }
/* Hide some header elements on tablet for more space */ /* Hide some header elements on tablet for more space */
@@ -7902,9 +7905,11 @@ kbd {
max-width: 80px; max-width: 80px;
} }
/* Compact toolbar */ /* Compact toolbar - includes safe area padding */
.toolbar { .toolbar {
padding: 0.4rem 0.5rem; padding: 0.4rem 0.5rem;
padding-left: calc(0.5rem + var(--safe-area-left));
padding-right: calc(0.5rem + var(--safe-area-right));
gap: 0.4rem; gap: 0.4rem;
} }
@@ -7949,11 +7954,9 @@ kbd {
Phone Breakpoint (<430px) Phone Breakpoint (<430px)
============================================================================ */ ============================================================================ */
@media (max-width: 430px) { @media (max-width: 430px) {
/* Safe area padding for iOS devices */ /* iOS safe area - only top padding on app, sides go to header/toolbar */
.ios-device .app { .ios-device .app {
padding-top: var(--safe-area-top); padding-top: var(--safe-area-top);
padding-left: var(--safe-area-left);
padding-right: var(--safe-area-right);
} }
/* Hide header brand on phones */ /* Hide header brand on phones */
@@ -7976,32 +7979,48 @@ kbd {
display: none; display: none;
} }
/* Compact header */ /* Ultra-compact header for mobile */
.header { .header {
min-height: 40px; min-height: 32px;
max-height: 52px; /* Tighter max height for mobile */ max-height: 36px;
padding: 0.25rem 0.4rem; padding: 0.15rem 0.3rem;
gap: 0.2rem; padding-left: calc(0.3rem + var(--safe-area-left));
padding-right: calc(0.3rem + var(--safe-area-right));
gap: 0.15rem;
flex-shrink: 0; flex-shrink: 0;
overflow: hidden; overflow: hidden;
background: #0a0a0a;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
} }
.header-right { .header-right {
padding-left: 0.35rem; padding-left: 0.2rem;
gap: 0.15rem; gap: 0.1rem;
flex-shrink: 0; flex-shrink: 0;
border-left: none; border-left: none;
} }
/* Smaller header buttons on mobile */ /* Smaller header buttons on mobile */
.btn-icon-header { .btn-icon-header {
width: 26px;
height: 26px;
padding: 0;
}
.btn-icon-header svg {
width: 12px;
height: 12px;
}
/* Larger settings gear icon for visibility */
.btn-icon-header.btn-settings {
width: 32px; width: 32px;
height: 32px; height: 32px;
} }
.btn-icon-header.btn-settings { .btn-icon-header.btn-settings svg {
width: 32px; width: 16px;
height: 32px; height: 16px;
} }
/* App container - prevent scrolling, strict layout */ /* App container - prevent scrolling, strict layout */
@@ -8009,65 +8028,77 @@ kbd {
overflow: hidden; overflow: hidden;
} }
/* Compact session tabs - horizontal scroll, smaller */ /* Ultra-compact session tabs */
.session-tabs { .session-tabs {
flex: 1; flex: 1;
flex-wrap: nowrap; flex-wrap: nowrap;
overflow-x: auto; overflow-x: auto;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
scrollbar-width: none; scrollbar-width: none;
max-height: 44px; max-height: 36px;
gap: 2px; gap: 2px;
padding: 0.1rem 0.15rem; padding: 0;
} }
.session-tabs::-webkit-scrollbar { .session-tabs::-webkit-scrollbar {
display: none; display: none;
} }
/* Compact tabs for mobile */ /* Smaller tabs for mobile */
.session-tab { .session-tab {
flex-shrink: 0; flex-shrink: 0;
min-height: 36px; min-height: 22px;
max-height: 36px; max-height: 22px;
padding: 0.3rem 0.5rem; padding: 0.1rem 0.4rem;
font-size: 0.7rem; font-size: 0.65rem;
gap: 0.25rem; gap: 0.2rem;
border-radius: 3px; border-radius: 3px;
} }
/* Smaller status indicator on mobile */ /* Smaller status indicator on mobile */
.session-tab .tab-status { .session-tab .tab-status {
width: 5px; width: 4px;
height: 5px; height: 4px;
} }
/* Truncate tab names more aggressively on mobile */ /* Truncate tab names more aggressively on mobile */
.session-tab .tab-name { .session-tab .tab-name {
max-width: 60px; max-width: 50px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
/* Smaller close/gear buttons on mobile tabs */ /* Hide close/gear buttons on non-active tabs on mobile */
.session-tab .tab-close, .session-tab .tab-close,
.session-tab .tab-gear { .session-tab .tab-gear {
font-size: 0.75rem; display: none;
padding: 0.1rem 0.25rem;
} }
/* Compact toolbar - only essential buttons */ /* Only show close/gear buttons on active tab - smaller gear */
.session-tab.active .tab-close,
.session-tab.active .tab-gear {
display: inline-flex;
font-size: 0.55rem;
padding: 0.02rem 0.1rem;
min-width: 14px;
height: 14px;
}
/* Clean dark toolbar - simple black/gray with white text */
.toolbar { .toolbar {
height: 44px; height: 40px;
min-height: 44px; min-height: 40px;
max-height: 44px; max-height: 40px;
padding: 0.4rem 0.6rem; padding: 0.3rem 0.4rem;
padding-bottom: calc(0.4rem + var(--safe-area-bottom)); padding-left: calc(0.4rem + var(--safe-area-left));
padding-right: calc(0.4rem + var(--safe-area-right));
padding-bottom: calc(0.3rem + var(--safe-area-bottom));
flex-wrap: nowrap; flex-wrap: nowrap;
gap: 0.4rem; gap: 0.3rem;
align-items: center; align-items: center;
background: linear-gradient(180deg, var(--bg-card) 0%, rgba(20, 20, 25, 0.98) 100%); justify-content: space-between;
border-top: 1px solid rgba(255, 255, 255, 0.06); background: #111111;
border-top: 1px solid rgba(255, 255, 255, 0.1);
} }
/* Hide secondary toolbar groups */ /* Hide secondary toolbar groups */
@@ -8084,25 +8115,25 @@ kbd {
display: none !important; display: none !important;
} }
/* Full-width primary toolbar group - left-aligned for mobile */ /* Toolbar layout: case selector left, Run Claude center, Shell right */
.toolbar-left { .toolbar-left {
flex: 1; flex: 1;
justify-content: flex-start; justify-content: space-between;
width: 100%; width: 100%;
align-items: center; align-items: center;
gap: 0.4rem; gap: 0.3rem;
} }
.toolbar-left .toolbar-group { .toolbar-left .toolbar-group {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 0.4rem; gap: 0.3rem;
} }
.toolbar-left .toolbar-group:first-child { .toolbar-left .toolbar-group:first-child {
flex: 1; flex: 1;
justify-content: flex-start; justify-content: space-between;
gap: 0.4rem; gap: 0.3rem;
flex-wrap: nowrap; flex-wrap: nowrap;
align-items: center; align-items: center;
} }
@@ -8112,105 +8143,112 @@ kbd {
display: none !important; display: none !important;
} }
/* Sleek compact toolbar buttons for mobile */ /* Compact toolbar buttons for mobile - white text on dark */
.btn-toolbar { .btn-toolbar {
min-height: 28px !important; min-height: 26px !important;
max-height: 28px !important; max-height: 26px !important;
height: 28px !important; height: 26px !important;
padding: 0 0.6rem !important; padding: 0 0.5rem !important;
font-size: 0.7rem !important; font-size: 0.65rem !important;
border-radius: 6px; border-radius: 4px;
line-height: 28px; line-height: 26px;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-weight: 500; font-weight: 500;
letter-spacing: 0.01em; letter-spacing: 0.01em;
color: #fff;
} }
/* Primary action button - Run Claude */ /* Primary action button - Run Claude - centered prominent */
.btn-toolbar.btn-claude { .btn-toolbar.btn-claude {
flex: 0 0 auto; flex: 0 0 auto;
padding: 0 0.75rem !important; padding: 0 1rem !important;
background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%); background: #2563eb;
border: none; border: none;
box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3); color: #fff;
font-weight: 600;
order: 2; /* Center position */
} }
.btn-toolbar.btn-claude:hover { .btn-toolbar.btn-claude:hover,
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); .btn-toolbar.btn-claude:active {
box-shadow: 0 3px 8px rgba(37, 99, 235, 0.4); background: #3b82f6;
} }
.btn-toolbar.btn-claude svg { .btn-toolbar.btn-claude svg {
width: 11px; width: 10px;
height: 11px; height: 10px;
margin-right: 4px; margin-right: 4px;
} }
/* Secondary action - Run Shell */ /* Secondary action - Run Shell - right side */
.btn-toolbar.btn-shell { .btn-toolbar.btn-shell {
flex: 0 0 auto; flex: 0 0 auto;
background: rgba(34, 197, 94, 0.15); background: transparent;
border: 1px solid rgba(34, 197, 94, 0.3); border: 1px solid rgba(255, 255, 255, 0.2);
color: #4ade80; color: #9ca3af;
order: 3; /* Right position */
} }
.btn-toolbar.btn-shell:hover { .btn-toolbar.btn-shell:hover,
background: rgba(34, 197, 94, 0.25); .btn-toolbar.btn-shell:active {
border-color: rgba(34, 197, 94, 0.5); background: rgba(255, 255, 255, 0.1);
color: #fff;
} }
/* Compact case selector for mobile - centered in toolbar */ /* Case selector - fills available space on left */
.case-select-group { .case-select-group {
flex: 0 0 auto; flex: 1;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
/* Center in available space, not pushed to edge */ order: 1; /* Left position */
margin: 0 auto; min-width: 0;
} }
.toolbar-select { .toolbar-select {
font-size: 0.7rem !important; font-size: 0.65rem !important;
padding: 0 1.2rem 0 0.5rem !important; padding: 0 1.4rem 0 0.4rem !important;
min-height: 28px !important; min-height: 26px !important;
max-height: 28px !important; max-height: 26px !important;
height: 28px !important; height: 26px !important;
line-height: 28px; line-height: 26px;
border-radius: 6px; border-radius: 4px;
background: var(--bg-input); background: #1a1a1a;
border: 1px solid rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.15);
/* Limit width so long names don't overflow */ color: #e5e5e5;
max-width: 90px; flex: 1;
min-width: 0;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
} }
/* Add case button - always visible on mobile */ /* Add case button - compact */
.btn-case-add { .btn-case-add {
min-width: 28px !important; min-width: 26px !important;
max-width: 28px !important; max-width: 26px !important;
width: 28px !important; width: 26px !important;
min-height: 28px !important; min-height: 26px !important;
max-height: 28px !important; max-height: 26px !important;
height: 28px !important; height: 26px !important;
padding: 0 !important; padding: 0 !important;
font-size: 1rem; font-size: 0.9rem;
font-weight: bold; font-weight: bold;
display: inline-flex !important; display: inline-flex !important;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
line-height: 1; line-height: 1;
border-radius: 6px; border-radius: 4px;
background: rgba(34, 197, 94, 0.15); background: transparent;
border: 1px solid rgba(34, 197, 94, 0.3); border: 1px solid rgba(255, 255, 255, 0.15);
color: var(--success); color: #9ca3af;
} }
.btn-case-add:hover { .btn-case-add:hover,
background: rgba(34, 197, 94, 0.25); .btn-case-add:active {
border-color: rgba(34, 197, 94, 0.5); background: rgba(255, 255, 255, 0.1);
color: #fff;
} }
/* Full-width panels - hide on phones due to limited screen space and toolbar overlap */ /* Full-width panels - hide on phones due to limited screen space and toolbar overlap */
@@ -8244,10 +8282,12 @@ kbd {
margin: 0; margin: 0;
} }
/* Modal safe area padding */ /* Modal safe area padding - all sides for full-screen modals */
.ios-device .modal-content { .ios-device .modal-content {
padding-top: var(--safe-area-top); padding-top: var(--safe-area-top);
padding-bottom: var(--safe-area-bottom); padding-bottom: var(--safe-area-bottom);
padding-left: var(--safe-area-left);
padding-right: var(--safe-area-right);
} }
.modal-header { .modal-header {
@@ -8286,24 +8326,35 @@ kbd {
display: block; display: block;
} }
/* Mobile terminal - use native browser scrolling for smooth performance */
.terminal-container { .terminal-container {
height: calc(100% + 45px); /* Make taller so bottom is clipped */ height: 100%;
min-height: 0; min-height: 0;
position: relative; position: relative;
margin-bottom: -45px; /* Clip bottom - hides status line but keeps input visible */ overflow: hidden;
contain: layout style;
touch-action: pan-y; /* Allow native vertical scrolling */
} }
/* Gradient mask at bottom to smoothly fade content into clipped area */ .terminal-container .xterm {
.terminal-container::after { touch-action: pan-y;
content: ''; }
position: absolute;
bottom: 45px; /* Position above the clipped area */ /* Viewport scroll optimization - use native scrolling */
left: 0; /* CRITICAL: xterm-viewport must be above xterm-screen for touch scrolling to work */
right: 0; /* See: https://github.com/xtermjs/xterm.js/issues/5377 */
height: 20px; .terminal-container .xterm-viewport {
background: linear-gradient(to bottom, transparent 0%, #0d0d0d 100%); position: absolute !important;
pointer-events: none; z-index: 10 !important; /* Above xterm-screen so touch events hit the scrollable viewport */
z-index: 5; touch-action: pan-y;
-webkit-overflow-scrolling: touch; /* Enable iOS momentum scrolling */
overflow-y: scroll !important;
scroll-behavior: auto !important;
will-change: scroll-position;
}
.terminal-container .xterm-screen {
touch-action: pan-y;
} }
/* Compact welcome overlay for mobile */ /* Compact welcome overlay for mobile */
@@ -8364,9 +8415,17 @@ kbd {
display: none; display: none;
} }
/* Respawn/Ralph panels - more compact on mobile */ /* Timer banner - includes safe area padding */
.timer-banner {
padding-left: calc(0.5rem + var(--safe-area-left));
padding-right: calc(0.5rem + var(--safe-area-right));
}
/* Respawn/Ralph panels - more compact on mobile, includes safe area padding */
.respawn-banner { .respawn-banner {
padding: 0.4rem 0.5rem; padding: 0.4rem 0.5rem;
padding-left: calc(0.5rem + var(--safe-area-left));
padding-right: calc(0.5rem + var(--safe-area-right));
font-size: 0.7rem; font-size: 0.7rem;
} }
@@ -8376,6 +8435,8 @@ kbd {
.ralph-summary { .ralph-summary {
padding: 0.4rem 0.5rem; padding: 0.4rem 0.5rem;
padding-left: calc(0.5rem + var(--safe-area-left));
padding-right: calc(0.5rem + var(--safe-area-right));
} }
/* Project insights panel - hide on mobile */ /* Project insights panel - hide on mobile */
@@ -8388,12 +8449,15 @@ kbd {
display: none !important; display: none !important;
} }
/* Notification drawer - full width on mobile */ /* Notification drawer - full width on mobile, includes safe area padding */
.notification-drawer { .notification-drawer {
width: 100%; width: 100%;
max-width: 100%; max-width: 100%;
right: 0; right: 0;
border-radius: 0; border-radius: 0;
padding-left: var(--safe-area-left);
padding-right: var(--safe-area-right);
padding-bottom: var(--safe-area-bottom);
} }
} }
@@ -8423,8 +8487,12 @@ kbd {
} }
.ios-device.safari-browser .terminal-container { .ios-device.safari-browser .terminal-container {
/* Prevent rubber-banding in terminal */ /* Keep momentum scrolling but prevent page bounce */
-webkit-overflow-scrolling: auto; -webkit-overflow-scrolling: touch;
}
.ios-device.safari-browser .terminal-container .xterm-viewport {
-webkit-overflow-scrolling: touch;
} }
/* ============================================================================ /* ============================================================================