Merge branch 'vk/53e9-pesquise-os-melh' into main
This commit is contained in:
commit
099671a4e5
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({
|
||||
queryKey: ['process', 'status'],
|
||||
queryFn: isProcessRunning,
|
||||
refetchInterval: 10000,
|
||||
refetchInterval: 30000,
|
||||
});
|
||||
|
||||
const startMutation = useMutation({
|
||||
|
||||
@@ -521,12 +521,20 @@ export class CloudAccountRepo {
|
||||
try {
|
||||
const rows = orm.select().from(accounts).orderBy(desc(accounts.lastUsed)).all();
|
||||
|
||||
// DEBUG LOGS
|
||||
const activeRows = rows.filter((r) => r.isActive);
|
||||
logger.info(
|
||||
`[DEBUG] getAccounts: Found ${rows.length} accounts, ${activeRows.length} active.`,
|
||||
logger.debug(
|
||||
`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[] = [];
|
||||
for (const normalizedRow of rows) {
|
||||
|
||||
@@ -848,6 +848,34 @@ export class GoogleAPIService {
|
||||
): Promise<{ credits: number; expiryDate: string } | null> {
|
||||
try {
|
||||
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, {
|
||||
method: 'POST',
|
||||
headers: buildInternalApiHeaders(accessToken),
|
||||
@@ -867,34 +895,7 @@ export class GoogleAPIService {
|
||||
return toAiCredits(data);
|
||||
}
|
||||
|
||||
if (response.status !== 404) {
|
||||
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);
|
||||
return null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user