From bc02ecc94c5120bb0a4491fd9f88c71fb9f26b7f Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Thu, 15 Jan 2026 11:46:02 -0500 Subject: [PATCH] fix(dashboard): harden projectId handling with edge case fixes - Validate empty string projectId with typeof check and trim() - Include projectId in registerAccount return value - Update projectId when changed (not just when missing) - Add aria-hidden/aria-label for accessibility - Add max-width + truncate for long projectId overflow --- src/cliproxy/account-manager.ts | 20 ++++++++++++++----- .../cliproxy/provider-editor/account-item.tsx | 12 ++++++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/cliproxy/account-manager.ts b/src/cliproxy/account-manager.ts index 7803b451..29ce11ba 100644 --- a/src/cliproxy/account-manager.ts +++ b/src/cliproxy/account-manager.ts @@ -384,6 +384,7 @@ export function registerAccount( tokenFile, createdAt: providerAccounts.accounts[accountId].createdAt, lastUsedAt: providerAccounts.accounts[accountId].lastUsedAt, + projectId: providerAccounts.accounts[accountId].projectId, }; } @@ -640,12 +641,17 @@ export function discoverExistingAccounts(): void { const existingTokenFiles = Object.values(providerAccounts.accounts).map((a) => a.tokenFile); if (existingTokenFiles.includes(file)) { // Token file exists - check if we need to update projectId for agy accounts - if (provider === 'agy' && data.project_id) { + const projectIdValue = + typeof data.project_id === 'string' && data.project_id.trim() + ? data.project_id.trim() + : null; + if (provider === 'agy' && projectIdValue) { const existingEntry = Object.entries(providerAccounts.accounts).find( ([, meta]) => meta.tokenFile === file ); - if (existingEntry && !existingEntry[1].projectId) { - existingEntry[1].projectId = data.project_id; + // Update if missing or changed + if (existingEntry && existingEntry[1].projectId !== projectIdValue) { + existingEntry[1].projectId = projectIdValue; } } continue; @@ -699,8 +705,12 @@ export function discoverExistingAccounts(): void { }; // Read project_id for Antigravity accounts (read-only field from auth token) - if (provider === 'agy' && data.project_id) { - accountMeta.projectId = data.project_id; + const discoveredProjectId = + typeof data.project_id === 'string' && data.project_id.trim() + ? data.project_id.trim() + : null; + if (provider === 'agy' && discoveredProjectId) { + accountMeta.projectId = discoveredProjectId; } providerAccounts.accounts[accountId] = accountMeta; diff --git a/ui/src/components/cliproxy/provider-editor/account-item.tsx b/ui/src/components/cliproxy/provider-editor/account-item.tsx index d61ea74d..2aec131d 100644 --- a/ui/src/components/cliproxy/provider-editor/account-item.tsx +++ b/ui/src/components/cliproxy/provider-editor/account-item.tsx @@ -177,8 +177,14 @@ export function AccountItem({
- - +
@@ -193,7 +199,7 @@ export function AccountItem({
- + Project ID: N/A