diff --git a/CLAUDE.md b/CLAUDE.md index bb737c2f..628902c4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -35,7 +35,7 @@ When user says "COM": 1. Increment version in BOTH `package.json` AND `CLAUDE.md` (verify they match with `grep version package.json && grep Version 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` -**Version**: 0.1519 (must match `package.json` for npm publish) +**Version**: 0.1520 (must match `package.json` for npm publish) ## Project Overview diff --git a/mobile-test.mjs b/mobile-test.mjs new file mode 100644 index 00000000..ec18e851 --- /dev/null +++ b/mobile-test.mjs @@ -0,0 +1,174 @@ +import { chromium } from 'playwright'; + +const BASE = 'http://localhost:3000'; + +// iPhone 14 Pro viewport +const MOBILE_VP = { width: 393, height: 852 }; +// iPad viewport +const TABLET_VP = { width: 768, height: 1024 }; + +async function testMobile(page, label, vp) { + await page.setViewportSize(vp); + await page.goto(BASE, { waitUntil: 'domcontentloaded' }); + await page.waitForTimeout(2000); + + const results = []; + + // 1. Check settings modal renders and tabs are visible + // Open settings via mobile toolbar button or header button + const settingsBtn = await page.$('.btn-settings-mobile') || await page.$('.btn-settings'); + if (settingsBtn) { + await settingsBtn.click(); + await page.waitForTimeout(500); + + const modal = await page.$('#appSettingsModal.active'); + results.push({ test: `${label}: Settings modal opens`, pass: !!modal }); + + if (modal) { + // Check tab buttons are visible and not overflowing + const tabs = await page.$$('#appSettingsModal .modal-tab-btn'); + results.push({ test: `${label}: Settings has ${tabs.length} tabs`, pass: tabs.length === 5 }); + + // Check first tab (Display) content is visible + const displayTab = await page.$('#settings-display'); + const displayVisible = displayTab ? await displayTab.isVisible() : false; + results.push({ test: `${label}: Display tab content visible`, pass: displayVisible }); + + // Check settings-grid layout + const settingsGrid = await page.$('#settings-display .settings-grid'); + if (settingsGrid) { + const gridStyle = await settingsGrid.evaluate(el => { + const cs = window.getComputedStyle(el); + return cs.gridTemplateColumns; + }); + const isSingleCol = vp.width < 430; + if (isSingleCol) { + // On phone, should be single column + const colCount = gridStyle.split(' ').length; + results.push({ test: `${label}: Settings grid is single-col (${colCount} cols)`, pass: colCount === 1 }); + } else { + results.push({ test: `${label}: Settings grid columns = ${gridStyle}`, pass: true }); + } + } + + // Switch to notifications tab and check event grid + const notifTab = await page.$('[data-tab="settings-notifications"]'); + if (notifTab) { + await notifTab.click(); + await page.waitForTimeout(300); + const eventGrid = await page.$('.event-type-grid'); + if (eventGrid) { + const eventGridVisible = await eventGrid.isVisible(); + results.push({ test: `${label}: Event type grid visible`, pass: eventGridVisible }); + + const gridCols = await eventGrid.evaluate(el => { + return window.getComputedStyle(el).gridTemplateColumns; + }); + results.push({ test: `${label}: Event grid cols = ${gridCols}`, pass: true }); + } + } + + // Check modal tab scrollability + const tabsContainer = await page.$('#appSettingsModal .modal-tabs'); + if (tabsContainer) { + const overflow = await tabsContainer.evaluate(el => { + const cs = window.getComputedStyle(el); + return { overflowX: cs.overflowX, flexWrap: cs.flexWrap }; + }); + results.push({ test: `${label}: Tab bar overflow-x=${overflow.overflowX}, flex-wrap=${overflow.flexWrap}`, pass: overflow.overflowX === 'auto' || overflow.flexWrap === 'nowrap' }); + } + + // Close modal + const closeBtn = await page.$('#appSettingsModal .modal-close'); + if (closeBtn) await closeBtn.click(); + await page.waitForTimeout(300); + } + } else { + results.push({ test: `${label}: Settings button found`, pass: false }); + } + + // 2. Check subagent badge sizing + // We can check the CSS computed style for .tab-subagent-badge if any exist + const badges = await page.$$('.tab-subagent-badge'); + if (badges.length > 0) { + const badgeHeight = await badges[0].evaluate(el => { + return parseFloat(window.getComputedStyle(el).height); + }); + if (vp.width < 430) { + results.push({ test: `${label}: Subagent badge height=${badgeHeight}px (expect ~14)`, pass: badgeHeight <= 16 }); + } else { + results.push({ test: `${label}: Subagent badge height=${badgeHeight}px`, pass: true }); + } + } else { + results.push({ test: `${label}: No subagent badges to check (OK)`, pass: true }); + } + + // 3. Check subagent windows if any are open + const subWindows = await page.$$('.subagent-window'); + if (subWindows.length > 0 && vp.width < 430) { + for (const sw of subWindows) { + const swStyle = await sw.evaluate(el => { + const cs = window.getComputedStyle(el); + return { + position: cs.position, + width: cs.width, + borderRadius: cs.borderRadius, + }; + }); + results.push({ test: `${label}: Subagent window position=${swStyle.position}, width=${swStyle.width}`, pass: swStyle.position === 'fixed' }); + } + } + + // 4. Check header height + const header = await page.$('.header'); + if (header) { + const headerHeight = await header.evaluate(el => { + return parseFloat(window.getComputedStyle(el).height); + }); + const expectedMax = vp.width < 430 ? 40 : 55; + results.push({ test: `${label}: Header height=${headerHeight}px (max ${expectedMax})`, pass: headerHeight <= expectedMax }); + } + + // 5. Check toolbar is fixed at bottom on mobile + if (vp.width < 430) { + const toolbar = await page.$('.toolbar'); + if (toolbar) { + const toolbarPos = await toolbar.evaluate(el => { + return window.getComputedStyle(el).position; + }); + results.push({ test: `${label}: Toolbar position=${toolbarPos}`, pass: toolbarPos === 'fixed' }); + } + } + + return results; +} + +(async () => { + const browser = await chromium.launch({ headless: true }); + + try { + // Test mobile viewport + const mobilePage = await browser.newPage(); + const mobileResults = await testMobile(mobilePage, 'Phone (393px)', MOBILE_VP); + await mobilePage.close(); + + // Test tablet viewport + const tabletPage = await browser.newPage(); + const tabletResults = await testMobile(tabletPage, 'Tablet (768px)', TABLET_VP); + await tabletPage.close(); + + const all = [...mobileResults, ...tabletResults]; + const passed = all.filter(r => r.pass).length; + const failed = all.filter(r => !r.pass).length; + + console.log('\n=== Mobile Optimization Test Results ===\n'); + for (const r of all) { + console.log(` ${r.pass ? '✓' : '✗'} ${r.test}`); + } + console.log(`\n ${passed} passed, ${failed} failed out of ${all.length} tests\n`); + + if (failed > 0) process.exit(1); + } finally { + await browser.close(); + } +})(); diff --git a/package.json b/package.json index 56c172fc..41f824fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claudeman", - "version": "0.1519", + "version": "0.1520", "description": "The missing control plane for Claude Code - run 20 autonomous agents with real-time monitoring and session persistence", "type": "module", "main": "dist/index.js", diff --git a/src/web/public/app.js b/src/web/public/app.js index 6dbe0945..40162218 100644 --- a/src/web/public/app.js +++ b/src/web/public/app.js @@ -9436,7 +9436,7 @@ class ClaudemanApp { // Default model const defaultModelEl = document.getElementById('appSettingsDefaultModel'); if (defaultModelEl) { - defaultModelEl.value = config.defaultModel || 'sonnet'; + defaultModelEl.value = config.defaultModel || 'opus'; } // Show recommendations const showRecsEl = document.getElementById('appSettingsShowModelRecommendations'); @@ -9475,7 +9475,7 @@ class ClaudemanApp { if (reviewEl?.value) agentTypeOverrides.review = reviewEl.value; const config = { - defaultModel: defaultModelEl?.value || 'sonnet', + defaultModel: defaultModelEl?.value || 'opus', showRecommendations: showRecsEl?.checked ?? true, agentTypeOverrides, }; @@ -12286,60 +12286,77 @@ class ClaudemanApp { // Calculate final position - grid layout to avoid overlaps const windowCount = this.subagentWindows.size; - const windowWidth = 420; - const windowHeight = 350; + const isMobile = MobileDetection.getDeviceType() === 'mobile'; + const windowWidth = isMobile ? window.innerWidth : 420; + const windowHeight = isMobile ? Math.round(window.innerHeight * 0.4) : 350; const gap = 20; const viewportWidth = window.innerWidth; const viewportHeight = window.innerHeight; - // Check if Ralph wizard modal is open - if so, position windows on the sides - const wizardModal = document.getElementById('ralphWizardModal'); - const wizardOpen = wizardModal?.classList.contains('active'); + let finalX = 0; + let finalY = 0; - let startX, startY, maxCols; - - if (wizardOpen) { - // Wizard is ~720px wide, centered. Position windows on left/right sides - const wizardWidth = 720; - const centerX = viewportWidth / 2; - const wizardLeft = centerX - wizardWidth / 2; - const wizardRight = centerX + wizardWidth / 2; - - // Alternate between left and right sides of the wizard - const leftSideSpace = wizardLeft - 20; - const rightSideSpace = viewportWidth - wizardRight - 20; - - if (windowCount % 2 === 0 && rightSideSpace >= windowWidth) { - // Even windows go to the right - startX = wizardRight + 20; - maxCols = Math.floor(rightSideSpace / (windowWidth + gap)) || 1; - } else if (leftSideSpace >= windowWidth) { - // Odd windows go to the left - startX = Math.max(10, wizardLeft - windowWidth - 20); - maxCols = 1; // Usually only room for 1 column on left - } else { - // Not enough side space, use right side - startX = wizardRight + 20; - maxCols = 1; + if (isMobile) { + // Mobile: CSS handles full-width bottom-sheet positioning via .subagent-window rules. + // Only one window visible at a time on mobile — new window replaces the old. + // Minimize all existing windows first so only the latest is visible. + for (const [existingId, existingData] of this.subagentWindows) { + if (!existingData.minimized) { + this.minimizeSubagentWindow(existingId); + } } - startY = 80; // Start higher when wizard is open + finalX = 0; + finalY = viewportHeight - windowHeight - 40; // toolbar height } else { - // Normal positioning - startX = 50; - startY = 120; - maxCols = Math.floor((viewportWidth - startX - 50) / (windowWidth + gap)) || 1; + // Check if Ralph wizard modal is open - if so, position windows on the sides + const wizardModal = document.getElementById('ralphWizardModal'); + const wizardOpen = wizardModal?.classList.contains('active'); + + let startX, startY, maxCols; + + if (wizardOpen) { + // Wizard is ~720px wide, centered. Position windows on left/right sides + const wizardWidth = 720; + const centerX = viewportWidth / 2; + const wizardLeft = centerX - wizardWidth / 2; + const wizardRight = centerX + wizardWidth / 2; + + // Alternate between left and right sides of the wizard + const leftSideSpace = wizardLeft - 20; + const rightSideSpace = viewportWidth - wizardRight - 20; + + if (windowCount % 2 === 0 && rightSideSpace >= windowWidth) { + // Even windows go to the right + startX = wizardRight + 20; + maxCols = Math.floor(rightSideSpace / (windowWidth + gap)) || 1; + } else if (leftSideSpace >= windowWidth) { + // Odd windows go to the left + startX = Math.max(10, wizardLeft - windowWidth - 20); + maxCols = 1; // Usually only room for 1 column on left + } else { + // Not enough side space, use right side + startX = wizardRight + 20; + maxCols = 1; + } + startY = 80; // Start higher when wizard is open + } else { + // Normal positioning + startX = 50; + startY = 120; + maxCols = Math.floor((viewportWidth - startX - 50) / (windowWidth + gap)) || 1; + } + + const maxRows = Math.floor((viewportHeight - startY - 50) / (windowHeight + gap)) || 1; + const col = windowCount % maxCols; + const row = Math.floor(windowCount / maxCols) % maxRows; // Wrap rows to stay in viewport + finalX = startX + col * (windowWidth + gap); + finalY = startY + row * (windowHeight + gap); + + // Ensure window stays within viewport bounds + finalX = Math.max(10, Math.min(finalX, viewportWidth - windowWidth - 10)); + finalY = Math.max(10, Math.min(finalY, viewportHeight - windowHeight - 10)); } - const maxRows = Math.floor((viewportHeight - startY - 50) / (windowHeight + gap)) || 1; - const col = windowCount % maxCols; - const row = Math.floor(windowCount / maxCols) % maxRows; // Wrap rows to stay in viewport - let finalX = startX + col * (windowWidth + gap); - let finalY = startY + row * (windowHeight + gap); - - // Ensure window stays within viewport bounds - finalX = Math.max(10, Math.min(finalX, viewportWidth - windowWidth - 10)); - finalY = Math.max(10, Math.min(finalY, viewportHeight - windowHeight - 10)); - // Get parent session from PERSISTENT map (THE source of truth for tab connections) const parentSessionId = this.subagentParentMap.get(agentId) || agent.parentSessionId; let parentSessionName = null; @@ -12378,7 +12395,8 @@ class ClaudemanApp { const teammateInfo = this.getTeammateInfo(agent); const windowTitle = teammateInfo ? teammateInfo.name : (agent.description || agentId.substring(0, 7)); - const truncatedTitle = windowTitle.length > 50 ? windowTitle.substring(0, 50) + '...' : windowTitle; + const maxTitleLen = isMobile ? 30 : 50; + const truncatedTitle = windowTitle.length > maxTitleLen ? windowTitle.substring(0, maxTitleLen) + '...' : windowTitle; const modelBadge = agent.modelShort ? `${agent.modelShort}` : ''; @@ -12401,23 +12419,25 @@ class ClaudemanApp { `; // If we have a parent tab, start window at tab position for spawn animation - if (parentTab) { + // On mobile, skip spawn animation — CSS handles bottom-sheet positioning + if (parentTab && !isMobile) { const tabRect = parentTab.getBoundingClientRect(); win.style.left = `${tabRect.left}px`; win.style.top = `${tabRect.bottom}px`; win.style.transform = 'scale(0.3)'; win.style.opacity = '0'; win.classList.add('spawning'); - } else { - // No parent tab, just position normally + } else if (!isMobile) { + // No parent tab, just position normally (desktop/tablet) win.style.left = `${finalX}px`; win.style.top = `${finalY}px`; } + // On mobile: CSS positions via fixed bottom-sheet rules, no inline positioning needed document.body.appendChild(win); - // Make draggable (returns listener refs for cleanup) - const dragListeners = this.makeWindowDraggable(win, win.querySelector('.subagent-window-header')); + // Make draggable (returns listener refs for cleanup) — skip on mobile (bottom-sheet) + const dragListeners = isMobile ? null : this.makeWindowDraggable(win, win.querySelector('.subagent-window-header')); // Check if this window should be visible based on settings // Use the PERSISTENT parent map for accurate tab-based visibility @@ -12467,8 +12487,8 @@ class ClaudemanApp { // Store observer for cleanup this.subagentWindows.get(agentId).resizeObserver = resizeObserver; - // Animate to final position if spawning from tab - if (parentTab) { + // Animate to final position if spawning from tab (desktop only) + if (parentTab && !isMobile) { requestAnimationFrame(() => { win.style.transition = 'all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1)'; win.style.left = `${finalX}px`; @@ -12484,7 +12504,7 @@ class ClaudemanApp { }, 400); }); } else { - // No animation, just update connection lines + // No animation (mobile uses CSS positioning), just update connection lines this.updateConnectionLines(); } diff --git a/src/web/public/index.html b/src/web/public/index.html index d296b0cd..30809a60 100644 --- a/src/web/public/index.html +++ b/src/web/public/index.html @@ -897,8 +897,8 @@