From de7953b2fce8e7b4f423a4f0390a0bc48a994566 Mon Sep 17 00:00:00 2001 From: Ignaciobrenas Date: Sat, 14 Nov 2026 23:14:27 +0100 Subject: [PATCH] feat(rebase): complete interactive Rebase Studio with fixup, drag-and-drop, context menu & responsive checks (Refs #4) --- scripts/capture-screenshots.js | 411 +++++++++++++++-- scripts/verify-responsive.js | 705 ++++++++++++++++++++++++++++++ src/graph/graphWebviewProvider.ts | 14 +- src/webview/main.ts | 292 ++++++++++++- src/webview/style.css | 514 ++++++++++++++++++++-- test/runTests.ts | 47 +- 6 files changed, 1905 insertions(+), 78 deletions(-) create mode 100644 scripts/verify-responsive.js diff --git a/scripts/capture-screenshots.js b/scripts/capture-screenshots.js index 171c8ca..a1af7a7 100644 --- a/scripts/capture-screenshots.js +++ b/scripts/capture-screenshots.js @@ -1,6 +1,7 @@ const fs = require('fs'); const path = require('path'); -const { execFileSync } = require('child_process'); +const { spawn } = require('child_process'); +const os = require('os'); const edgePath = 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'; const outDir = path.resolve(__dirname, '..', 'docs', 'screenshots'); @@ -72,6 +73,7 @@ function buildGraphHtml(themeName) { + + + + + +`; +} + +function buildCommitDrawerHtml(themeName) { + return ` + + + + + + + +
+
+
+ Detalles del Commit + +
+
+
+ +
+ Ignacio Breñas + ignaciobrenas@gmail.com + Hace 5 minutos (cf4821a) +
+
+ +
+ + + + + + + +
+ +
+
Mensaje del commit
+
feat(responsive): complete responsive design and virtual DAG windowing engine
+
+ +
+
+ Archivos Modificados + 3 archivos +
+
+
+
+ M + src/webview/style.css +
+ +42 +
+
+
+ M + src/webview/main.ts +
+ +18 +
+
+
+
+
+
+ +`; +} + +function buildIssuesHubHtml(themeName) { + return ` + + + + + + + +
+
+
+ + + +
+
+ + +
+
+ +
+
+
+
+ #104 + open + Vinculado +
+
+ + +
+
+
Responsive UI overhaul for sidebars and auxiliary windows
+
+ frontend + v0.4.8 +
+ +
+
+
+ +`; +} + +function buildBisectViewHtml(themeName) { + return ` + + + + + + + +
+
+
+
+ + Git Bisect Activo +
+
+ Probando commit e4a19b8 (~2 pasos restantes) +
+
+ + + + +
+
+
+
+ +`; +} + const themes = ['dark', 'light', 'high-contrast']; const viewports = [ { name: 'narrow-280px', width: 280, height: 750 }, + { name: 'sidebar-360px', width: 360, height: 750 }, { name: 'medium-450px', width: 450, height: 800 }, + { name: 'split-750px', width: 750, height: 800 }, { name: 'full-1200px', width: 1200, height: 800 }, ]; -for (const theme of themes) { - const graphHtml = buildGraphHtml(theme); - const graphFile = path.join(outDir, `temp_graph_${theme}.html`); - fs.writeFileSync(graphFile, graphHtml); - - const aiHtml = buildAiStudioHtml(theme); - const aiFile = path.join(outDir, `temp_ai_${theme}.html`); - fs.writeFileSync(aiFile, aiHtml); - - for (const vp of viewports) { - const graphImg = path.join(outDir, `graph_${theme}_${vp.name}.png`); - execFileSync(edgePath, [ - '--headless', - '--disable-gpu', - `--screenshot=${graphImg}`, - `--window-size=${vp.width},${vp.height}`, - `file://${graphFile}`, - ]); - - const aiImg = path.join(outDir, `ai_studio_${theme}_${vp.name}.png`); - execFileSync(edgePath, [ - '--headless', - '--disable-gpu', - `--screenshot=${aiImg}`, - `--window-size=${vp.width},${vp.height}`, - `file://${aiFile}`, - ]); - - console.log(`Captured: graph & ai_studio for theme=${theme}, viewport=${vp.name}`); +const views = [ + { prefix: 'graph', builder: buildGraphHtml }, + { prefix: 'ai_studio', builder: buildAiStudioHtml }, + { prefix: 'rebase_studio', builder: buildRebaseStudioHtml }, + { prefix: 'commit_drawer', builder: buildCommitDrawerHtml }, + { prefix: 'issues_hub', builder: buildIssuesHubHtml }, + { prefix: 'bisect_view', builder: buildBisectViewHtml }, +]; + +async function captureAll() { + const profileDir = path.join(os.tmpdir(), 'commitflow_edge_cdp_' + Date.now()); + const edgeProc = spawn(edgePath, [ + '--headless=new', + '--remote-debugging-port=9222', + '--disable-gpu', + '--user-data-dir=' + profileDir, + 'about:blank' + ]); + + let wsUrl = ''; + for (let i = 0; i < 30; i++) { + await new Promise(r => setTimeout(r, 200)); + try { + const res = await fetch('http://127.0.0.1:9222/json/list'); + const data = await res.json(); + const page = data.find(p => p.type === 'page'); + if (page && page.webSocketDebuggerUrl) { + wsUrl = page.webSocketDebuggerUrl; + break; + } + } catch(e) {} } - fs.unlinkSync(graphFile); - fs.unlinkSync(aiFile); + if (!wsUrl) { + edgeProc.kill(); + throw new Error('Could not connect to Edge DevTools Protocol'); + } + + const ws = new WebSocket(wsUrl); + let id = 1; + const callbacks = new Map(); + + ws.onmessage = (event) => { + const msg = JSON.parse(event.data); + if (msg.id && callbacks.has(msg.id)) { + callbacks.get(msg.id)(msg.result); + callbacks.delete(msg.id); + } + }; + + await new Promise(r => ws.onopen = r); + + function send(method, params = {}) { + return new Promise((resolve) => { + const reqId = id++; + callbacks.set(reqId, resolve); + ws.send(JSON.stringify({ id: reqId, method, params })); + }); + } + + await send('Page.enable'); + const tree = await send('Page.getFrameTree'); + const frameId = tree.frameTree.frame.id; + + for (const theme of themes) { + for (const view of views) { + const html = view.builder(theme); + await send('Page.setDocumentContent', { frameId, html }); + + for (const vp of viewports) { + await send('Emulation.setDeviceMetricsOverride', { + width: vp.width, + height: vp.height, + deviceScaleFactor: 1, + mobile: false + }); + + // Small pause for layout calculation and fonts + await new Promise(r => setTimeout(r, 120)); + + const shot = await send('Page.captureScreenshot', { format: 'png' }); + const outImg = path.join(outDir, `${view.prefix}_${theme}_${vp.name}.png`); + fs.writeFileSync(outImg, Buffer.from(shot.data, 'base64')); + console.log(`Captured (CDP): ${view.prefix} for theme=${theme}, viewport=${vp.name} (${vp.width}x${vp.height})`); + } + } + } + + ws.close(); + edgeProc.kill(); + + setTimeout(() => { + try { fs.rmSync(profileDir, { recursive: true, force: true }); } catch(e) {} + }, 1000); + + console.log('All comprehensive screenshots captured successfully in docs/screenshots/'); } -console.log('All screenshots captured successfully in docs/screenshots/'); +captureAll().catch((err) => { + console.error('Capture error:', err); + process.exit(1); +}); diff --git a/scripts/verify-responsive.js b/scripts/verify-responsive.js new file mode 100644 index 0000000..b9ec7d8 --- /dev/null +++ b/scripts/verify-responsive.js @@ -0,0 +1,705 @@ +const fs = require('fs'); +const path = require('path'); +const { spawn } = require('child_process'); +const os = require('os'); + +const edgePath = 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'; + +const cssWebview = fs.readFileSync(path.resolve(__dirname, '..', 'dist', 'webview.css'), 'utf8'); +const cssCodicon = fs.readFileSync(path.resolve(__dirname, '..', 'dist', 'codicon.css'), 'utf8'); + +const themeVariables = { + dark: ` + --vscode-editor-background: #1e1e1e; + --vscode-editor-foreground: #d4d4d4; + --vscode-sideBar-background: #252526; + --vscode-sideBar-foreground: #cccccc; + --vscode-input-background: #3c3c3c; + --vscode-input-foreground: #cccccc; + --vscode-input-border: #3c3c3c; + --vscode-button-background: #007acc; + --vscode-button-foreground: #ffffff; + --vscode-button-hoverBackground: #0062a3; + --vscode-button-secondaryBackground: #3a3d41; + --vscode-button-secondaryForeground: #ffffff; + --vscode-errorForeground: #f48771; + --vscode-testing-iconPassed: #89d185; + --vscode-editorWarning-foreground: #cca700; + `, + light: ` + --vscode-editor-background: #ffffff; + --vscode-editor-foreground: #333333; + --vscode-sideBar-background: #f3f3f3; + --vscode-sideBar-foreground: #616161; + --vscode-input-background: #ffffff; + --vscode-input-foreground: #333333; + --vscode-input-border: #cecece; + --vscode-button-background: #007acc; + --vscode-button-foreground: #ffffff; + --vscode-button-hoverBackground: #0062a3; + --vscode-button-secondaryBackground: #e5e5e5; + --vscode-button-secondaryForeground: #333333; + --vscode-errorForeground: #e51400; + --vscode-testing-iconPassed: #388a34; + --vscode-editorWarning-foreground: #bf8803; + `, + 'high-contrast': ` + --vscode-editor-background: #000000; + --vscode-editor-foreground: #ffffff; + --vscode-sideBar-background: #000000; + --vscode-sideBar-foreground: #ffffff; + --vscode-input-background: #000000; + --vscode-input-foreground: #ffffff; + --vscode-input-border: #6fc3df; + --vscode-contrastActiveBorder: #f38518; + --vscode-button-background: #000000; + --vscode-button-foreground: #ffffff; + --vscode-button-border: #6fc3df; + --vscode-button-hoverBackground: #1a1a1a; + --vscode-button-secondaryBackground: #000000; + --vscode-button-secondaryForeground: #ffffff; + --vscode-errorForeground: #f48771; + --vscode-testing-iconPassed: #89d185; + --vscode-editorWarning-foreground: #cca700; + `, +}; + +function buildGraphHtml(themeName) { + return ` + + + + + + + +
+
+
+
+ CommitFlow +
+
+
+ main +
+
+ + + + + + + + + + + + +
+
+ +
+
+ + +
+ + +
+
+ +
+
Commits: 128
+
Autores: 4
+
Ramas: 6
+
Stashes: 1
+
+ +
+ + + + + + + + + + + + + + + + + +
cf4821amain feat(mcp): streamable HTTP and stdio authenticated serverIgnacioJust now
ab8291fdev feat(ai): Connect with your AI studio and key generatorIgnacio10m ago
+
+
+ +`; +} + +function buildRebaseStudioHtml(themeName) { + return ` + + + + + + + + + +`; +} + +function buildCommitDrawerHtml(themeName) { + return ` + + + + + + + +
+
+
+ Detalles del Commit + +
+
+
+ +
+ Ignacio Breñas + ignaciobrenas@gmail.com + Hace 5 minutos (cf4821a) +
+
+ +
+ + + + + + + + +
+ +
+
Mensaje del commit
+
feat(responsive): complete responsive design and virtual DAG windowing engine
+
+ +
+
+ Archivos Modificados + 3 archivos +
+
+
+
+ M + src/webview/style.css +
+ +42 +
+
+
+ M + src/webview/main.ts +
+ +18 +
+
+
+
+
+
+ +`; +} + +function buildAiStudioHtml(themeName) { + return ` + + + + + + + +
+
+
+
+ +

Conectar con tu IA

+ + + Activo en 127.0.0.1:47291 + +
+

Genera claves de acceso seguras y conecta Claude Code, Antigravity o cualquier IA mediante MCP.

+
+
+ +
+
+ + Generar Nueva Clave API +
+ +
+
+ + +
+ +
+ +
+ + +
+
+ +
+ + +
+
+ +
+ +
+
+ +
+
+ + Copia tu clave ahora. Por motivos de seguridad, no volverá a mostrarse. +
+
+ + +
+
+ +
+
+ + Comandos de Conexión Rápida +
+ +
+ + + + +
+ +
+
claude mcp add --transport sse commitflow http://127.0.0.1:47291/sse?token=cf_live_9b4e7a82c31045f918e9d023b7498c1a
+ +
+
+ +
+
+ + Claves API Generadas +
+
+ + + + + + + + + + + + + + + + + + + + + +
NombrePrefijoPermisosCreaciónEstadoAcciones
Antigravity Agentcf_live_9b4e...readNov 1, 2026Activa
+
+
+
+ +`; +} + +const viewports = [ + { name: 'nano-240px', width: 240, height: 700 }, + { name: 'narrow-280px', width: 280, height: 750 }, + { name: 'sidebar-360px', width: 360, height: 750 }, + { name: 'medium-450px', width: 450, height: 800 }, + { name: 'split-750px', width: 750, height: 800 }, + { name: 'full-1200px', width: 1200, height: 800 }, +]; + +const views = [ + { name: 'Graph View', builder: buildGraphHtml }, + { name: 'AI Studio', builder: buildAiStudioHtml }, + { name: 'Rebase Studio Modal', builder: buildRebaseStudioHtml }, + { name: 'Commit Drawer', builder: buildCommitDrawerHtml }, +]; + +async function verifyResponsiveAndButtons() { + console.log('=== CommitFlow Responsive & Button Interaction Verification ===\n'); + + const profileDir = path.join(os.tmpdir(), 'commitflow_verify_cdp_' + Date.now()); + const edgeProc = spawn(edgePath, [ + '--headless=new', + '--remote-debugging-port=9223', + '--disable-gpu', + '--user-data-dir=' + profileDir, + 'about:blank' + ]); + + let wsUrl = ''; + for (let i = 0; i < 30; i++) { + await new Promise(r => setTimeout(r, 200)); + try { + const res = await fetch('http://127.0.0.1:9223/json/list'); + const data = await res.json(); + const page = data.find(p => p.type === 'page'); + if (page && page.webSocketDebuggerUrl) { + wsUrl = page.webSocketDebuggerUrl; + break; + } + } catch(e) {} + } + + if (!wsUrl) { + edgeProc.kill(); + throw new Error('Could not connect to Edge DevTools Protocol on port 9223'); + } + + const ws = new WebSocket(wsUrl); + let id = 1; + const callbacks = new Map(); + + ws.onmessage = (event) => { + const msg = JSON.parse(event.data); + if (msg.id && callbacks.has(msg.id)) { + callbacks.get(msg.id)(msg.result); + callbacks.delete(msg.id); + } + }; + + await new Promise(r => ws.onopen = r); + + function send(method, params = {}) { + return new Promise((resolve) => { + const reqId = id++; + callbacks.set(reqId, resolve); + ws.send(JSON.stringify({ id: reqId, method, params })); + }); + } + + await send('Page.enable'); + await send('Runtime.enable'); + const tree = await send('Page.getFrameTree'); + const frameId = tree.frameTree.frame.id; + + let totalAudits = 0; + let passedAudits = 0; + let totalButtonsVerified = 0; + + for (const view of views) { + console.log(`\n▶ Auditing View: ${view.name}`); + const html = view.builder('dark'); + await send('Page.setDocumentContent', { frameId, html }); + + for (const vp of viewports) { + await send('Emulation.setDeviceMetricsOverride', { + width: vp.width, + height: vp.height, + deviceScaleFactor: 1, + mobile: false + }); + + await new Promise(r => setTimeout(r, 100)); + + const evalRes = await send('Runtime.evaluate', { + expression: ` + (function() { + const results = { + horizontalOverflows: [], + overlappingElements: [], + buttonsInfo: [] + }; + + // 1. Check for unintentional horizontal overflows + const bodyWidth = document.body.clientWidth; + const allElements = Array.from(document.querySelectorAll('*')); + for (const el of allElements) { + const cs = window.getComputedStyle(el); + if (cs.display === 'none' || cs.visibility === 'hidden') continue; + // Ignore intentional horizontal scroll containers, inputs, and ellipsis text + if (cs.overflowX === 'auto' || cs.overflowX === 'scroll') continue; + const tag = el.tagName.toLowerCase(); + if (tag === 'input' || tag === 'textarea') continue; + if (cs.textOverflow === 'ellipsis') continue; + if (cs.overflowX === 'hidden' && (cs.textOverflow === 'clip' || cs.textOverflow === 'ellipsis')) continue; + if (el.scrollWidth > el.clientWidth + 3 && el.clientWidth > 0) { + // Ignore small sub-pixel text rendering difference + const cls = (el.className && typeof el.className === 'string') ? el.className.slice(0, 30) : ''; + const id = el.id ? '#' + el.id : ''; + results.horizontalOverflows.push({ + selector: tag + id + (cls ? '.' + cls.split(' ').join('.') : ''), + clientWidth: el.clientWidth, + scrollWidth: el.scrollWidth + }); + } + } + + // 2. Check all interactive buttons & controls + const buttons = Array.from(document.querySelectorAll('button, select, input[type="text"]')); + for (const btn of buttons) { + const rect = btn.getBoundingClientRect(); + const cs = window.getComputedStyle(btn); + if (cs.display === 'none' || cs.visibility === 'hidden') continue; + + const isVisible = rect.width > 0 && rect.height > 0 && rect.bottom > 0 && rect.top < window.innerHeight; + let isObscured = false; + if (isVisible) { + const centerX = Math.min(Math.max(rect.left + rect.width / 2, 0), window.innerWidth - 1); + const centerY = Math.min(Math.max(rect.top + rect.height / 2, 0), window.innerHeight - 1); + const topEl = document.elementFromPoint(centerX, centerY); + if (topEl && !btn.contains(topEl) && !topEl.contains(btn)) { + isObscured = true; + } + } + + results.buttonsInfo.push({ + tag: btn.tagName.toLowerCase(), + id: btn.id || '', + text: (btn.textContent || btn.value || btn.title || '').trim().slice(0, 25), + width: Math.round(rect.width), + height: Math.round(rect.height), + isVisible, + isObscured + }); + } + + // 3. Collision/Overlap detection between direct siblings in flex/grid + const containers = Array.from(document.querySelectorAll('.drawer-action-buttons, .bisect-actions, .issues-filter-pills, .snippet-subtabs, .modal-footer, .header-row-primary')); + for (const container of containers) { + const children = Array.from(container.children).filter(c => { + const s = window.getComputedStyle(c); + return s.display !== 'none' && s.visibility !== 'hidden'; + }); + for (let i = 0; i < children.length; i++) { + for (let j = i + 1; j < children.length; j++) { + const r1 = children[i].getBoundingClientRect(); + const r2 = children[j].getBoundingClientRect(); + if (r1.width === 0 || r2.width === 0) continue; + // Check intersection with 3px tolerance + const overlapX = Math.max(0, Math.min(r1.right, r2.right) - Math.max(r1.left, r2.left)); + const overlapY = Math.max(0, Math.min(r1.bottom, r2.bottom) - Math.max(r1.top, r2.top)); + if (overlapX > 3 && overlapY > 3) { + results.overlappingElements.push({ + container: container.className, + el1: children[i].tagName + (children[i].id ? '#' + children[i].id : ''), + el2: children[j].tagName + (children[j].id ? '#' + children[j].id : ''), + overlapX, + overlapY + }); + } + } + } + } + + return results; + })() + `, + returnByValue: true + }); + + const res = evalRes.result.value; + totalAudits++; + + const hasOverflows = res.horizontalOverflows.length > 0; + const hasOverlaps = res.overlappingElements.length > 0; + const obscuredButtons = res.buttonsInfo.filter(b => b.isVisible && b.isObscured); + + if (!hasOverflows && !hasOverlaps && obscuredButtons.length === 0) { + passedAudits++; + console.log(` ✔ [PASS] Viewport ${vp.name.padEnd(14)} (${vp.width}x${vp.height}) - ${res.buttonsInfo.length} buttons OK, 0 overlaps, 0 overflows`); + } else { + console.log(` ✖ [WARN] Viewport ${vp.name} (${vp.width}x${vp.height}):`); + if (hasOverflows) { + console.log(` Overflows:`, res.horizontalOverflows); + } + if (hasOverlaps) { + console.log(` Overlaps ("se pisa"):`, res.overlappingElements); + } + if (obscuredButtons.length > 0) { + console.log(` Obscured buttons:`, obscuredButtons); + } + } + + totalButtonsVerified += res.buttonsInfo.length; + } + } + + ws.close(); + edgeProc.kill(); + + setTimeout(() => { + try { fs.rmSync(profileDir, { recursive: true, force: true }); } catch(e) {} + }, 1000); + + console.log(`\n======================================================`); + console.log(`AUDIT RESULTS: ${passedAudits}/${totalAudits} audits passed with zero collisions.`); + console.log(`TOTAL BUTTONS & CONTROLS VERIFIED: ${totalButtonsVerified}`); + console.log(`======================================================\n`); + + if (passedAudits !== totalAudits) { + throw new Error(`Some viewports have responsive or button layout issues`); + } +} + +verifyResponsiveAndButtons().catch((err) => { + console.error('Audit failed:', err); + process.exit(1); +}); diff --git a/src/graph/graphWebviewProvider.ts b/src/graph/graphWebviewProvider.ts index ba39d3d..f3db611 100644 --- a/src/graph/graphWebviewProvider.ts +++ b/src/graph/graphWebviewProvider.ts @@ -2184,7 +2184,7 @@ Always check repo state and active branch before making modifications.