Commit Graph

11 Commits

Author SHA1 Message Date
王性驊 3fec6e55eb fix: Always save diagnostics on any error
- Add saveDiagnostics method
- Use defer in Generate to catch all errors
- Simplify typeInput error handling
- Automatic screenshot and HTML dump on failure
2026-04-03 01:40:33 +08:00
王性驊 e245558f3d fix: Remove duplicate code and fix Evaluate error 2026-04-03 01:36:22 +08:00
王性驊 bef521504e feat: Add debug mode with screenshot and page analysis
Features:
- Wait for user ENTER in visible mode (GEMINI_BROWSER_VISIBLE=true)
- Save screenshot to /tmp/gemini-debug.png
- Save HTML to /tmp/gemini-debug.html
- JavaScript-based element detection
- Multi-strategy wait (A: selectors, B: time, C: JS, D: debug)
- Detailed logging of each strategy attempt
- Page structure dump in debug mode

This helps identify why input field is not found
2026-04-03 01:31:37 +08:00
王性驊 104e55d613 fix: Add proper page ready check before finding input
Key improvements:
- Wait for page to fully load (SPA needs time)
- Wait for input field to be visible before typing
- Check login status only after page is ready
- Add fallback wait (3 seconds) if first attempt fails
- Properly handle error messages

Based on project-golem's PageInteractor.waitForReady()
2026-04-03 01:26:43 +08:00
王性驊 3d5f2d91c0 feat: Switch to playwright-go for better DOM automation
Major refactor using Playwright (pure Go):
- Add playwright-go dependency (v0.5700.1)
- Create PlaywrightProvider with auto-wait for elements
- Use LaunchPersistentContext for session persistence
- Implement Locator-based element finding (auto-wait)
- Fill input using Playwright's built-in methods
- Add fallback selectors for input fields
- Better error messages with page URL and title

Key improvements over Rod:
- Auto-wait for elements (solves 'input field not found')
- More mature browser automation library
- Better documentation and examples
- Based on project-golem's proven strategies

Installation:
- Playwright driver and Chromium downloaded to ~/Library/Caches/ms-playwright/
- ~160MB download (one-time setup)
2026-04-03 01:20:42 +08:00
王性驊 17b001d8c2 fix: Add debug output and fallback selectors for input field detection 2026-04-03 01:11:02 +08:00
王性驊 32673c028e refactor: Complete rewrite of GeminiWeb provider
Based on project-golem implementation:

Phase 1: Browser Persistence
- Add BrowserManager singleton to manage browser lifecycle
- Use launchPersistentContext with UserDataDir
- Auto-save cookies and session state
- Clean Chrome lock files on startup
- Single browser instance reused across requests

Phase 2: Improved DOM Interaction
- Use correct input selectors (ProseMirror first)
- Implement 'Physical Enter' send method
- Trigger input/change/keyup events properly
- Check for 'Stop' button to detect busy state

Phase 3: Session Management
- No manual cookie saving/loading needed
- Session pool just manages userDataDir paths
- Default session directory structure

Breaking changes:
- Remove manual cookie management
- Browser stays open between requests
- Simpler session management
2026-04-03 01:05:54 +08:00
王性驊 24459ffcfe fix: Don't wait for user input during login flow
- Remove blocking 'Press Enter' prompt
- Continue without waiting when no session exists
- Save cookies asynchronously if user logs in during session
- Add debug output for finding input field and send button
- Try Enter key as fallback for sending message
2026-04-03 00:51:55 +08:00
王性驊 9f41d3b5b5 feat: Allow using Gemini Web without login
- Remove requirement to login before using Gemini Web
- If logged in (cookies exist), use the account
- If not logged in, continue without login (browser opens)
- When browser is visible, prompt user they can login or continue without
- Save cookies only if user actually logs in
2026-04-03 00:45:59 +08:00
王性驊 69df57555d fix: Improve Gemini Web DOM selectors and add debug output
- Make model selector optional (skip if not found, use current model)
- Add multiple fallback selectors for input field and send button
- Add debug logging to trace execution flow
- Improve error messages to suggest running gemini-login
2026-04-03 00:40:57 +08:00
王性驊 33a0e53709 feat: Add GeminiWeb provider foundation
- Add Provider interface and factory pattern
- Create apitypes package for shared types
- Implement GeminiWeb provider with:
  - Browser automation using Rod
  - Session pool management
  - Cookie persistence
  - DOM interaction for Gemini web interface
- Add gemini-login command for session setup
- Add CURSOR_BRIDGE_PROVIDER env variable

Remaining: Integration with chat.go handlers
2026-04-02 22:45:41 +08:00