Skip to content

fix(installer): stop double-opening browser at the connect prompt#9

Closed
Harihara04sudhan wants to merge 1 commit into
mainfrom
fix/connect-double-login
Closed

fix(installer): stop double-opening browser at the connect prompt#9
Harihara04sudhan wants to merge 1 commit into
mainfrom
fix/connect-double-login

Conversation

@Harihara04sudhan

Copy link
Copy Markdown
Contributor

Bug

User presses Y at "Connect your ArmorIQ account now?" → two browser tabs open with two unrelated device codes:

  1. First tab: dev.armoriq.io/auth/device?code=2NWM-RK69&callback=http://localhost:55156/callback (no product param, generic "Authorize Device" page)
  2. Second tab: dev.armoriq.io/auth/device?code=NTUK-TE8D&callback=http://localhost:55164/callback&product=armorcopilot (branded "Authorize ArmorCopilot" page)

Different ports = two separate cmdLogin invocations spawning two local callback servers.

Root cause

The installer feature-detected --product support by running:

if armoriq-dev login --help 2>&1 | grep -q -- '--product'; then ...

But the SDK's login subcommand has no --help handler — it just runs the full device-code flow with --help parsed as an unknown flag. That's tab #1.

The grep then fails (the login flow's stdout doesn't contain "--product"), so the script falls into the else branch and runs the env-var fallback: ARMORIQ_PRODUCT=armorcopilot armoriq-dev login. That's tab #2.

Fix

Drop the probe entirely. Always pass --product as a flag AND export ARMORIQ_PRODUCT as a fallback. New SDKs prefer the flag, old SDKs ignore the unknown flag and pick up the env var. Either way: one CLI call, one device code, one browser tab.

-  if command -v armoriq-dev >/dev/null 2>&1; then
-    if armoriq-dev login --help 2>&1 | grep -q -- '--product'; then
-      armoriq-dev login --product "${product}" && login_ok=1 || login_ok=0
-    else
-      ARMORIQ_PRODUCT="${product}" armoriq-dev login && login_ok=1 || login_ok=0
-    fi
-  elif ...
+  export ARMORIQ_PRODUCT="${product}"
+  if command -v armoriq-dev >/dev/null 2>&1; then
+    armoriq-dev login --product "${product}" && login_ok=1 || login_ok=0
+  elif ...

Follow-ups

  1. armorCodex installer has the same probe pattern — mirror PR coming.
  2. SDK armoriq-sdk-customer-ts/dev should add a per-subcommand --help handler so future probes don't accidentally trigger the device-code flow. Separate PR.
  3. Landing repo install_armorcopilot.sh needs a sync PR after this merges.

Test plan

  • Clean local state (rm -rf ~/.armoriq/armorCopilot ~/.copilot/armorcopilot ~/.armoriq/credentials.json).
  • Run curl -fsSL https://armoriq.ai/install_armorcopilot.sh | bash (or sync this branch into landing first).
  • Press Y at the connect prompt → exactly one browser tab opens at dev.armoriq.io/auth/device?...&product=armorcopilot showing "Authorize ArmorCopilot".

🤖 Generated with Claude Code

The previous probe ran 'armoriq-dev login --help | grep -q -- "--product"'
to feature-detect the --product flag. The SDK's 'login' subcommand
ignores --help (no per-subcommand --help handler), so the probe actually
ran the full device-code flow as a side effect: opened browser tab #1,
spawned a local callback server on port A. The grep then failed because
the login flow's stdout doesn't contain '--product', so the script fell
to the env-var fallback branch and ran 'armoriq-dev login' AGAIN — second
browser tab, second device code, second local port.

Net: pressing Y at "Connect your ArmorIQ account now?" opened two
browser tabs with two unrelated device codes (one without product
context, one with it).

Fix: drop the probe. Always pass --product as a flag AND export
ARMORIQ_PRODUCT as a belt-and-braces fallback. Older SDKs without
--product support ignore the unknown flag and pick up the env var. New
SDKs prefer the flag, env var still works as backup. One CLI call,
one device code, one browser tab.

Companion SDK fix (per-subcommand --help handling) will be filed
separately on armoriq-sdk-customer-ts/dev.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

1 participant