File size: 2,819 Bytes
973a11d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { chromium } from 'playwright';
import dotenv from 'dotenv';
import fs from 'fs';

dotenv.config();

async function runDebug() {
  console.log('Starting Lovable workspace page diagnosis...');
  const cookieValue = process.env.LOVABLE_SESSION_COOKIE;
  const workspaceUrl = 'https://lovable.dev/projects/900f228d-d0c3-492e-ad6e-ce1a52f546e6';
  
  if (!cookieValue || cookieValue === 'your_session_cookie_value_here') {
    console.error('Error: LOVABLE_SESSION_COOKIE is not set inside the .env file!');
    process.exit(1);
  }

  const browser = await chromium.launch({ headless: true });
  const context = await browser.newContext({
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
    viewport: { width: 1440, height: 900 }
  });

  // Inject Cookie
  await context.addCookies([
    {
      name: 'lovable-session-id-v2',
      value: cookieValue,
      domain: '.lovable.dev',
      path: '/',
      httpOnly: true,
      secure: true,
      sameSite: 'Lax'
    }
  ]);

  const page = await context.newPage();
  console.log(`Navigating to workspace: ${workspaceUrl}...`);
  await page.goto(workspaceUrl, { waitUntil: 'domcontentloaded', timeout: 45000 });

  // Wait 10 seconds for the workspace SPA to fully load
  console.log('Waiting 10 seconds for workspace loading...');
  await page.waitForTimeout(10000);

  const url = page.url();
  console.log(`Current Page URL: ${url}`);

  // Take screenshot
  await page.screenshot({ path: 'workspace-debug.png', fullPage: true });
  console.log('Screenshot saved to workspace-debug.png');

  // Dump HTML
  const html = await page.content();
  fs.writeFileSync('workspace-debug.html', html);
  console.log('HTML content saved to workspace-debug.html');

  // Find all textareas, inputs, and editable divs
  const inputs = await page.evaluate(() => {
    const textareas = Array.from(document.querySelectorAll('textarea')).map(t => ({
      tagName: 'TEXTAREA',
      id: t.id,
      className: t.className,
      placeholder: t.getAttribute('placeholder'),
      value: t.value
    }));

    const editableDivs = Array.from(document.querySelectorAll('[contenteditable="true"]')).map(d => ({
      tagName: 'DIV[contenteditable]',
      id: d.id,
      className: d.className,
      text: d.innerText.substring(0, 100)
    }));

    const inputs = Array.from(document.querySelectorAll('input')).map(i => ({
      tagName: 'INPUT',
      id: i.id,
      type: i.type,
      className: i.className,
      placeholder: i.getAttribute('placeholder')
    }));

    return [...textareas, ...editableDivs, ...inputs];
  });

  console.log('Found Input elements in workspace:', inputs);

  await browser.close();
  console.log('Diagnosis complete.');
}

runDebug().catch(console.error);