import sys
import time
from pathlib import Path
sys.path.append(str(Path("05_Production_Pipeline").resolve()))
from invisible_playwright import InvisiblePlaywright
from muse_invpw_driver import sync_worker_profile, DEFAULT_PROFILE

def inspect_current():
    sync_worker_profile()
    with InvisiblePlaywright(profile_dir=DEFAULT_PROFILE, headless=True) as ctx:
        page = ctx.pages[0] if ctx.pages else ctx.new_page()
        page.goto("https://muse.ai", wait_until="domcontentloaded", timeout=30000)
        time.sleep(4)
        
        screenshot_path = Path("04_Assets/muse_shot11_state.png").resolve()
        page.screenshot(path=str(screenshot_path))
        print(f"Screenshot saved to: {screenshot_path}")
        
        # Check articles or messages
        articles = page.locator('[data-message-author="assistant"], [role="article"], .prose')
        print(f"Articles count: {articles.count()}")
        for i in range(articles.count()):
            print(f"--- Article {i} ---")
            print(articles.nth(i).inner_text()[:300])
            
        # Check modals or dialogs
        dialogs = page.locator('[role="dialog"]')
        print(f"Dialogs count: {dialogs.count()}")
        if dialogs.count() > 0:
            print("Dialog text:", dialogs.first.inner_text())

if __name__ == "__main__":
    inspect_current()
