|
| 1 | +import { chromium } from 'playwright'; |
| 2 | + |
| 3 | +const browser = await chromium.launch({ headless: true, deviceScaleFactor: 2 }); |
| 4 | +const page = await browser.newPage({ viewport: { width: 1400, height: 900 } }); |
| 5 | + |
| 6 | +await page.goto('http://localhost:3099', { waitUntil: 'domcontentloaded' }); |
| 7 | +await page.waitForTimeout(6000); |
| 8 | +await page.locator('.session-tab').first().click(); |
| 9 | +await page.waitForTimeout(4000); |
| 10 | + |
| 11 | +await page.evaluate(() => { |
| 12 | + const settings = JSON.parse(localStorage.getItem('codeman-settings') || '{}'); |
| 13 | + settings.localEchoEnabled = true; |
| 14 | + localStorage.setItem('codeman-settings', JSON.stringify(settings)); |
| 15 | + if (window.app?.updateLocalEchoState) window.app.updateLocalEchoState(); |
| 16 | +}); |
| 17 | +await page.waitForTimeout(500); |
| 18 | + |
| 19 | +// Force render and capture zoomed area of just the overlay |
| 20 | +const result = await page.evaluate(() => { |
| 21 | + const overlay = window.app?._localEchoOverlay; |
| 22 | + if (!overlay || !overlay._overlay) return { error: 'no overlay' }; |
| 23 | + |
| 24 | + overlay._lastPromptPos = { row: 5, col: 0 }; |
| 25 | + overlay._pendingText = 'h'; |
| 26 | + overlay._lastRenderKey = ''; |
| 27 | + overlay._render(); |
| 28 | + |
| 29 | + const container = overlay._overlay; |
| 30 | + const lineDiv = container.querySelector('div'); |
| 31 | + const charSpan = container.querySelector('div > span'); |
| 32 | + |
| 33 | + // Get precise rects |
| 34 | + const lineDivRect = lineDiv?.getBoundingClientRect(); |
| 35 | + const charSpanRect = charSpan?.getBoundingClientRect(); |
| 36 | + const screenRect = document.querySelector('.xterm-screen')?.getBoundingClientRect(); |
| 37 | + |
| 38 | + // Check what's right below the line div |
| 39 | + const belowY = (lineDivRect?.bottom || 0) + 1; |
| 40 | + const belowX = lineDivRect?.left || 0; |
| 41 | + const elBelow = document.elementFromPoint(belowX, belowY); |
| 42 | + |
| 43 | + return { |
| 44 | + dpr: window.devicePixelRatio, |
| 45 | + lineDiv: { |
| 46 | + rect: lineDivRect, |
| 47 | + bg: lineDiv?.style.backgroundColor, |
| 48 | + height: lineDiv?.style.height, |
| 49 | + }, |
| 50 | + charSpan: { |
| 51 | + rect: charSpanRect, |
| 52 | + transform: charSpan?.style.transform, |
| 53 | + // Check if span bottom exceeds lineDiv bottom |
| 54 | + extendsBelow: charSpanRect && lineDivRect ? |
| 55 | + (charSpanRect.bottom - lineDivRect.bottom).toFixed(2) : 'N/A', |
| 56 | + }, |
| 57 | + elBelow: elBelow ? { |
| 58 | + tag: elBelow.tagName, |
| 59 | + class: elBelow.className, |
| 60 | + } : null, |
| 61 | + // Check the exact background color of the canvas |
| 62 | + canvasBg: document.querySelector('.xterm-screen')?.style.backgroundColor, |
| 63 | + themeBg: window.app?.terminal?.options?.theme?.background, |
| 64 | + overlayBg: lineDiv?.style.backgroundColor, |
| 65 | + }; |
| 66 | +}); |
| 67 | +console.log(JSON.stringify(result, null, 2)); |
| 68 | + |
| 69 | +// Take tight screenshot around the first char area |
| 70 | +const screenEl = page.locator('.xterm-screen').first(); |
| 71 | +const screenBox = await screenEl.boundingBox(); |
| 72 | +if (screenBox) { |
| 73 | + // Crop to just the overlay area (row 5, first few columns) |
| 74 | + const cellH = 19; |
| 75 | + const promptRow = 5; |
| 76 | + const cropY = screenBox.y + (promptRow - 1) * cellH; |
| 77 | + const cropH = cellH * 3; |
| 78 | + await page.screenshot({ |
| 79 | + path: '/tmp/first-char-zoomed.png', |
| 80 | + clip: { x: screenBox.x, y: cropY, width: 200, height: cropH }, |
| 81 | + }); |
| 82 | + console.log('Zoomed screenshot saved'); |
| 83 | +} |
| 84 | + |
| 85 | +await page.evaluate(() => { window.app?._localEchoOverlay?.clear(); }); |
| 86 | +await browser.close(); |
| 87 | +console.log('Done'); |
0 commit comments