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

def check_thread_new_status():
    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/thread/new", wait_until="domcontentloaded", timeout=30000)
        time.sleep(4)
        
        page.screenshot(path="04_Assets/thread_new_status.png")
        print("Page URL:", page.url)
        print("Content has 'Đang kết nối':", "Đang kết nối" in page.content())
        
        # Check input box
        input_box = page.locator('textarea[placeholder*="Nhắn tin"], textarea').first
        print("Input box count:", input_box.count())
        
        # Check right panel text
        right_panel = page.locator('.hatch-root, [class*="companion"], aside').all_inner_texts()
        print("Right panel:", right_panel)

if __name__ == '__main__':
    check_thread_new_status()
