From 81dedc9e4747b54f890fdeb2e5d8ac1951f558b7 Mon Sep 17 00:00:00 2001 From: Josh Salway Date: Mon, 16 Mar 2026 21:56:03 +1000 Subject: [PATCH] Fix duplicate organizations in selection prompt When authenticating multiple times, the same API tokens were appended to config.json without deduplication. Each duplicate token triggered a separate API call returning the same organization, causing the org selection prompt to show duplicate entries. Add unique() to both apiTokens() (to handle existing duplicated configs) and addApiToken() (to prevent future duplicates). Fixes #22 Co-Authored-By: Claude Opus 4.6 (1M context) --- app/ConfigRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/ConfigRepository.php b/app/ConfigRepository.php index f1738b25..e1bc15a1 100644 --- a/app/ConfigRepository.php +++ b/app/ConfigRepository.php @@ -35,12 +35,12 @@ public function get(string $key, mixed $default = null): mixed */ public function apiTokens(): Collection { - return collect($this->get('api_tokens', [])); + return collect($this->get('api_tokens', []))->unique()->values(); } public function addApiToken(string $token): void { - $this->config['api_tokens'] = $this->apiTokens()->push($token); + $this->config['api_tokens'] = $this->apiTokens()->push($token)->unique()->values(); $this->save(); }