feat: more robust client initialization for the app (#3830)

This commit is contained in:
Alex Hancock
2025-08-04 12:56:47 -04:00
committed by GitHub
parent 162011fccb
commit 3f567efd9e
7 changed files with 101 additions and 35 deletions
-17
View File
@@ -1,6 +1,5 @@
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { client } from './api/client.gen';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
@@ -17,19 +16,3 @@ export function patchConsoleLogging() {
// Intercept console methods
return;
}
// This needs to be called before any API calls are made, but since we're using the client
// in multiple useEffect locations, we can't be sure who goes first.
let clientInitialized = false;
export async function ensureClientInitialized() {
if (clientInitialized) return;
client.setConfig({
baseUrl: window.appConfig.get('GOOSE_API_HOST') + ':' + window.appConfig.get('GOOSE_PORT'),
headers: {
'Content-Type': 'application/json',
'X-Secret-Key': await window.electron.getSecretKey(),
},
});
clientInitialized = true;
}