[CLI] Fix --session-name auto-restore, --state precedence, and --init-script ordering on launch#1387
Open
gaojude wants to merge 2 commits into
Open
[CLI] Fix --session-name auto-restore, --state precedence, and --init-script ordering on launch#1387gaojude wants to merge 2 commits into
gaojude wants to merge 2 commits into
Conversation
When --headed, --executable-path, --proxy, --user-agent, --args, or other flags trigger main.rs:1057's dispatch logic, the CLI sends an explicit `launch` command to the daemon before the first action. That routes through handle_launch instead of auto_launch — and only auto_launch was calling try_auto_restore_state. Result: --session-name silently failed to restore cookies and localStorage for any flag combination that hit the explicit-launch path. Mirror the four auto_launch call sites in handle_launch's five successful-launch paths (cdp_url, cdp_port, auto_connect, provider, local). Placed before load_storage_state_or_rollback so explicit --state still wins on conflicts, matching auto_launch's precedence. Add e2e_session_name_auto_restores_cookies_via_explicit_launch to cover the path that was missing — the existing test only exercised auto_launch via a bare navigate, which is why the gap slipped in. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…estore - Gate try_auto_restore_state on storage_state being None in every handle_launch and auto_launch branch so an explicit --state is the sole source of state (no silent merge of stale session-name data). - Move apply_launch_init_scripts ahead of restore in handle_launch so --init-script applies to restore-driven navigations (load_state navigates to each origin to replay localStorage). - Add regression tests: * e2e_explicit_state_skips_session_name_auto_restore * e2e_init_script_applies_to_restore_navigation
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.
--session-name <slug>silently failed to auto-restore cookies and localStorage whenever the CLI dispatched an explicitlaunchcommand — any of--headed,--executable-path,--proxy,--user-agent,--args,--profile,--state,--allow-file-access,--color-scheme,--download-path,--engine, or--extensions.try_auto_restore_statewas wired into the four branches ofauto_launchbut none of the five parallel branches ofhandle_launch. Now mirrored in each (cdp_url,cdp_port,auto_connect,provider, local).Two adjacent ordering bugs surfaced while testing.
--session-nameand explicit--stateboth loaded, merging stale auto-state into the explicit file —try_auto_restore_stateis now gated onstorage_state.is_none()so explicit--stateis the sole source.--init-scriptregistered viaPage.addScriptToEvaluateOnNewDocumentran after restore, missing the per-origin navigationsstate::load_stateperforms to replay localStorage —apply_launch_init_scriptsnow runs before restore inhandle_launch, matchingauto_launch's existing order. Addse2e_session_name_auto_restores_cookies_via_explicit_launch,e2e_explicit_state_skips_session_name_auto_restore, ande2e_init_script_applies_to_restore_navigation; the two new tests fail on the prior code.