Skip to content

fix(debug): Set fixed window size to prevent UI clipping#240

Merged
CJackHwang merged 3 commits intoCJackHwang:mainfrom
NikkeTryHard:fix-debug-window
Sep 21, 2025
Merged

fix(debug): Set fixed window size to prevent UI clipping#240
CJackHwang merged 3 commits intoCJackHwang:mainfrom
NikkeTryHard:fix-debug-window

Conversation

@NikkeTryHard
Copy link
Collaborator

When running the --debug flag, the Camoufox window often launches with dimensions larger than the physical screen, especially on laptops. This causes UI elements, like login boxes or page content, to be clipped and inaccessible.

Standard window resizing or maximizing does not resolve the issue due to Camoufox's anti-fingerprinting measures that lock the window dimensions which pisses me off.

This commit addresses the issue by leveraging a fixed, sensible default window size of (1280, 800).

This ensures the entire browser window is visible during debugging sessions on most standard displays, significantly improving the developer and testing experience without affecting headless runs.

@NikkeTryHard
Copy link
Collaborator Author

NikkeTryHard commented Sep 21, 2025

An initial fix to solve the window size issue (by setting a fixed resolution) exposed a fragility in the chat clearing logic. The original clear_chat_history function relied on finding and clicking UI buttons. With the new, smaller window size, this UI automation step began to fail, causing the script to incorrectly assume the chat was already clear, which made the proxy became stateful. All subsequent API requests were sent within the same ongoing conversation, breaking the intended "one request, one new chat" stateless model.

Solution: Robust Chat Clearing via Navigation:

The fragile, UI-based clearing logic in browser_utils/page_controller.py has been completely replaced.
The clear_chat_history function now performs a direct page.goto() navigation to the .../prompts/new_chat URL.
This action is a far more reliable method for resetting the chat state, as it is not dependent on UI element visibility or layout, making it resilient to future AI Studio updates.
The function also ensures the "Temporary Chat" mode is correctly re-enabled after navigation.

@NikkeTryHard
Copy link
Collaborator Author

During debug mode, the Camoufox window often launched oversized, causing UI clipping on smaller screens (e.g., laptops). This made elements inaccessible and broke chat clearing logic, leading to stateful behavior where requests appended to ongoing sessions instead of starting fresh.

Initial fix: Set fixed size to 1280x800 to fit most displays, but this exposed fragility in clear_chat_history()—UI buttons (e.g., "New chat") weren't always visible/clickable due to scrolling needs or layout shifts, sometimes misclicking "Run" and interrupting generation.

Attempts:

  • Enhanced scrolling (scroll_into_view_if_needed()) and timeouts in page_controller.py, but issues persisted in shorter heights.
  • Tried navigation to /prompt/new_chat as robust alternative, but introduced errors (e.g., model state loss, script re-injection).
  • Reverted to original UI-click approach; tested larger sizes.

Resolution: 1920x1080 didnt work. Settled on 1440x900 (16:10 ratio) which provides enough vertical space to avoid clipping/scrolling failures while fitting standard displays. No ratio-specific issues; problem was height constraining UI visibility.

@CJackHwang CJackHwang merged commit 7463ee1 into CJackHwang:main Sep 21, 2025
@NikkeTryHard NikkeTryHard deleted the fix-debug-window branch November 19, 2025 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants