Add Chrome profile support to fetch_html tool#45
Merged
Conversation
Allows users to configure a Chrome profile path in config.toml to share cookies and session data with the Codey browser. This enables accessing authenticated web pages through the fetch_html tool. Changes: - Add BrowserConfig struct with chrome_profile_path and chrome_executable options - Update fetch_html to read browser config and pass --user-data-dir to Chrome - Support ~ expansion in profile paths - Add configuration documentation in config.example.toml
- Add BrowserContext with OnceLock (matches spawn_agent pattern) - Initialize browser context at app startup - Simplify fetch_html API (no longer needs config params) - Add documentation for Chrome profile configuration - Reference issue #46 for future refactoring
- Rename chrome_profile_path to chrome_user_data_dir - Add chrome_profile field for --profile-directory flag - Update config.example.toml and README.md documentation
…essions
Fixes Chrome profile sharing for fetch_html by:
1. Copying the configured profile to /tmp/codey-browser-{pid}/Default/
- Avoids SingletonLock conflicts (Chrome locks at user-data-dir level)
- PID-based isolation allows concurrent Codey instances
2. Disabling chromiumoxide's default --password-store=basic and
--use-mock-keychain flags when using a profile
- These flags prevent Chrome from accessing macOS Keychain
- Chrome cookies are encrypted with Keychain key (app-wide, not per-profile)
- Without real Keychain access, copied cookies can't be decrypted
The profile copy approach works because:
- Cookie encryption key is shared across all Chrome profiles
- Key is stored in Keychain under 'Chrome Safe Storage'
- Copied Cookies SQLite DB has same encrypted values
- Chrome decrypts them as long as it has Keychain access
Extensive documentation added to fetch_with_browser() explaining the
Chrome profile, SingletonLock, and Keychain encryption details.
- Add viewport_width, viewport_height, page_load_wait_ms to BrowserConfig - Default viewport to 800x4000 (tall for infinite scroll pages) - Default page_load_wait_ms to 10000 (10s for SPAs) - Set both window_size and viewport in chromiumoxide config - Refactor fetch_with_browser to take BrowserContext directly These settings help with JavaScript-heavy sites like Twitter/X that need time to render and benefit from taller viewports to load more content.
895a71c to
bb1431a
Compare
- Add headless option - Add viewport_width/height options - Add page_load_wait_ms option - Improve documentation explaining profile copying approach
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allows users to configure a Chrome profile path in config.toml to share cookies and session data with the Codey browser. This enables accessing authenticated web pages through the fetch_html tool.
Changes: