fix: resolve startup issues with account activation, credit fetch and poll noise
- GoogleAPIService: try loadCodeAssist first for AI credits since fetchCredits returns 404 for many accounts; keep fetchCredits as fallback, removing the spurious warn on every poll cycle - CloudAccountRepo: auto-activate the most-recently-used account when no account has is_active=1; downgrade noisy [DEBUG] log from info to debug level - StatusBar: increase process-status refetch interval from 10s to 30s to reduce redundant IPC calls and log noise
This commit is contained in:
1 parent
83489d5084
commit
0f9d08018b
3 files changed
+42
-33
No files matched your search
@@ -18,7 +18,7 @@ export const StatusBar: React.FC<StatusBarProps> = ({ isCollapsed = false }) =>
|
|||||||
const { data: isRunning, isLoading } = useQuery({
|
const { data: isRunning, isLoading } = useQuery({
|
||||||
queryKey: ['process', 'status'],
|
queryKey: ['process', 'status'],
|
||||||
queryFn: isProcessRunning,
|
queryFn: isProcessRunning,
|
||||||
refetchInterval: 10000,
|
refetchInterval: 30000,
|
||||||
});
|
});
|
||||||
|
|
||||||
const startMutation = useMutation({
|
const startMutation = useMutation({
|
||||||
|
|||||||
@@ -521,12 +521,20 @@ export class CloudAccountRepo {
|
|||||||
try {
|
try {
|
||||||
const rows = orm.select().from(accounts).orderBy(desc(accounts.lastUsed)).all();
|
const rows = orm.select().from(accounts).orderBy(desc(accounts.lastUsed)).all();
|
||||||
|
|
||||||
// DEBUG LOGS
|
|
||||||
const activeRows = rows.filter((r) => r.isActive);
|
const activeRows = rows.filter((r) => r.isActive);
|
||||||
logger.info(
|
logger.debug(
|
||||||
`[DEBUG] getAccounts: Found ${rows.length} accounts, ${activeRows.length} active.`,
|
`getAccounts: Found ${rows.length} accounts, ${activeRows.length} active.`,
|
||||||
);
|
);
|
||||||
activeRows.forEach((r) => logger.info(`[DEBUG] Active Account: ${r.email} (${r.id})`));
|
|
||||||
|
// Auto-activate the single account if none are active
|
||||||
|
if (rows.length > 0 && activeRows.length === 0) {
|
||||||
|
const targetRow = rows[0];
|
||||||
|
logger.info(
|
||||||
|
`No active account found. Auto-activating account: ${targetRow.email} (${targetRow.id})`,
|
||||||
|
);
|
||||||
|
orm.update(accounts).set({ isActive: 1 }).where(eq(accounts.id, targetRow.id)).run();
|
||||||
|
targetRow.isActive = 1;
|
||||||
|
}
|
||||||
|
|
||||||
const cloudAccounts: CloudAccount[] = [];
|
const cloudAccounts: CloudAccount[] = [];
|
||||||
for (const normalizedRow of rows) {
|
for (const normalizedRow of rows) {
|
||||||
|
|||||||
@@ -848,6 +848,34 @@ export class GoogleAPIService {
|
|||||||
): Promise<{ credits: number; expiryDate: string } | null> {
|
): Promise<{ credits: number; expiryDate: string } | null> {
|
||||||
try {
|
try {
|
||||||
const fetchOptions = this.getFetchOptions(proxyUrl);
|
const fetchOptions = this.getFetchOptions(proxyUrl);
|
||||||
|
|
||||||
|
// Try loadCodeAssist first — fetchCredits returns 404 for many accounts
|
||||||
|
// and loadCodeAssist provides the same paid tier credit data.
|
||||||
|
const discoveryVersion = resolveLocalInstalledVersion() ?? FALLBACK_VERSION;
|
||||||
|
const loadAssistResponse = await fetch(URLS.DAILY_LOAD_PROJECT, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: buildInternalApiHeaders(accessToken),
|
||||||
|
body: JSON.stringify({
|
||||||
|
metadata: {
|
||||||
|
ide_type: 'ANTIGRAVITY',
|
||||||
|
ide_version: discoveryVersion,
|
||||||
|
ide_name: 'geminiNexus',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
signal: createTimeoutSignal(REQUEST_TIMEOUT_MS),
|
||||||
|
...fetchOptions,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (loadAssistResponse.ok) {
|
||||||
|
const loadAssistData = (await loadAssistResponse.json()) as LoadProjectResponse;
|
||||||
|
const credits = extractAiCreditsFromProjectContext(loadAssistData);
|
||||||
|
if (credits) {
|
||||||
|
return credits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to the legacy fetchCredits endpoint if loadCodeAssist
|
||||||
|
// did not return usable credit data.
|
||||||
const response = await fetch(URLS.FETCH_CREDITS, {
|
const response = await fetch(URLS.FETCH_CREDITS, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: buildInternalApiHeaders(accessToken),
|
headers: buildInternalApiHeaders(accessToken),
|
||||||
@@ -867,34 +895,7 @@ export class GoogleAPIService {
|
|||||||
return toAiCredits(data);
|
return toAiCredits(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.status !== 404) {
|
return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// `fetchCredits` has started returning 404 for some accounts. Reuse the
|
|
||||||
// internal `loadCodeAssist` payload, which also exposes paid tier credits.
|
|
||||||
logger.warn('[GoogleAPIService] fetchCredits returned 404, falling back to loadCodeAssist');
|
|
||||||
const discoveryVersion = resolveLocalInstalledVersion() ?? FALLBACK_VERSION;
|
|
||||||
const fallbackResponse = await fetch(URLS.DAILY_LOAD_PROJECT, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: buildInternalApiHeaders(accessToken),
|
|
||||||
body: JSON.stringify({
|
|
||||||
metadata: {
|
|
||||||
ide_type: 'ANTIGRAVITY',
|
|
||||||
ide_version: discoveryVersion,
|
|
||||||
ide_name: 'geminiNexus',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
signal: createTimeoutSignal(REQUEST_TIMEOUT_MS),
|
|
||||||
...fetchOptions,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!fallbackResponse.ok) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fallbackData = (await fallbackResponse.json()) as LoadProjectResponse;
|
|
||||||
return extractAiCreditsFromProjectContext(fallbackData);
|
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user