fix: prefer active local browser profiles
Testing / remote-protocol-compat (0.9.3) (push) Successful in 30s
Testing / remote-protocol-compat (0.9.5) (push) Successful in 29s
Package Extension / package-extension (push) Successful in 29s
Build & Publish Package / publish (push) Successful in 33s
Testing / test (push) Successful in 25s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 30s
Testing / remote-protocol-compat (0.9.5) (push) Successful in 29s
Package Extension / package-extension (push) Successful in 29s
Build & Publish Package / publish (push) Successful in 33s
Testing / test (push) Successful in 25s
- Avoid resolving a saved remote alias when the requested profile is currently reachable as a local endpoint. - Add a helper that checks the registry and local socket path before remote alias discovery. - Cover the routing precedence with a client unit test. - Bump package and extension versions to 0.10.1.
This commit is contained in:
+17
-1
@@ -214,6 +214,22 @@ def active_browser_targets(*, include_remotes: bool = True, key=None) -> list[Br
|
||||
return targets
|
||||
|
||||
|
||||
def _is_active_local_profile(profile: str | None) -> bool:
|
||||
"""Return True when profile names a reachable local browser endpoint."""
|
||||
if not profile:
|
||||
return False
|
||||
if REGISTRY_PATH.exists():
|
||||
reg = load_registry(REGISTRY_PATH)
|
||||
if profile in _active_endpoints(reg):
|
||||
return True
|
||||
if not is_windows():
|
||||
try:
|
||||
return Path(endpoint_for_alias(profile)).exists()
|
||||
except Exception:
|
||||
return False
|
||||
return False
|
||||
|
||||
|
||||
def _resolve_socket(profile: str | None = None) -> str:
|
||||
"""Return the socket path for the given profile (or auto-detect)."""
|
||||
target = profile or os.environ.get("BROWSER_CLI_PROFILE")
|
||||
@@ -387,7 +403,7 @@ def send_command(command: str, args: dict | None = None, profile: str | None = N
|
||||
if remote_endpoint:
|
||||
remote_endpoint = _normalize_endpoint(remote_endpoint)
|
||||
remote_alias_target = None
|
||||
if not remote_endpoint and requested_profile:
|
||||
if not remote_endpoint and requested_profile and not _is_active_local_profile(requested_profile):
|
||||
remote_alias_target = remote_target_for_alias(requested_profile)
|
||||
if remote_alias_target:
|
||||
remote_endpoint = remote_alias_target.remote
|
||||
|
||||
Reference in New Issue
Block a user