From 5cbb40739fadb13fe49355298fdceb6cf840908f Mon Sep 17 00:00:00 2001 From: manuaudio Date: Fri, 2 Oct 2026 19:20:05 -0700 Subject: [PATCH] Refuse --reauth without an account instead of adding one Co-Authored-By: Claude Opus 5.5 --- bin/omarchy-agent-account-add | 4 ++++ test/shell.d/agent-account-test.sh | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/bin/omarchy-agent-account-add b/bin/omarchy-agent-account-add index d54bebadbf9e..f2dd2dd6f845 100755 --- a/bin/omarchy-agent-account-add +++ b/bin/omarchy-agent-account-add @@ -23,6 +23,10 @@ while [[ ${1:-} == --* ]]; do --events) events=true ;; --reauth) reauth="${2:-}" + if [[ -z $reauth || $reauth == --* ]]; then + echo "Usage: omarchy-agent-account-add --reauth [claude|codex|grok]" >&2 + exit 1 + fi shift ;; *) break ;; diff --git a/test/shell.d/agent-account-test.sh b/test/shell.d/agent-account-test.sh index 19cefe590644..52f9077aca8e 100644 --- a/test/shell.d/agent-account-test.sh +++ b/test/shell.d/agent-account-test.sh @@ -355,6 +355,20 @@ grep -qx "@@omarchy done Signed in to Claude again." "$test_tmp/reauth-output" | [[ $(omarchy-agent-account-list claude --json | jq '.[0].accounts | length') == "$before" ]] || fail "--reauth adds no account" grep -qx -- "--private https://claude.com/oauth/authorize" "$OMARCHY_TEST_BROWSER_LOG" || fail "--reauth of an added account uses a private window" +# --reauth without an account is a mistake, not a request to add one. +: >"$OMARCHY_TEST_BROWSER_LOG" +before=$(omarchy-agent-account-list claude --json | jq '.[0].accounts | length') +for args in "--reauth" "--reauth --events"; do + # shellcheck disable=SC2086 + if OMARCHY_TEST_LOGIN_UUID=u-stray OMARCHY_TEST_LOGIN_EMAIL=stray@example.com \ + omarchy-agent-account-add $args /dev/null 2>&1; then + fail "--reauth needs an account: $args" + fi +done +[[ $(omarchy-agent-account-list claude --json | jq '.[0].accounts | length') == "$before" && ! -s $OMARCHY_TEST_BROWSER_LOG ]] || + fail "--reauth without an account adds nothing and opens no sign-in" +pass "--reauth without an account is refused" + : >"$OMARCHY_TEST_BROWSER_LOG" OMARCHY_TEST_LOGIN_UUID=u-main OMARCHY_TEST_LOGIN_EMAIL=me@example.com \ omarchy-agent-account-add --reauth main claude /dev/null