Merge pull request #703 from buster-so/staging

Staging
This commit is contained in:
dal 2025-08-11 17:54:19 -06:00 committed by GitHub
commit c4da2a6af3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 12 additions and 8 deletions

View File

@ -32,9 +32,9 @@ const useSupabaseContextInternal = ({
const decoded = jwtDecode(token || accessToken);
const expiresAtDecoded = (decoded as { exp?: number } | undefined)?.exp ?? 0;
const expiresAtMs = millisecondsFromUnixTimestamp(expiresAtDecoded);
const msUntilExpiry = Math.max(0, expiresAtMs - Date.now());
return msUntilExpiry;
return expiresAtMs;
} catch {
console.error('Error decoding token', token);
// If token is missing/invalid, report that it is effectively expired now
return 0;
}
@ -126,6 +126,7 @@ const useSupabaseContextInternal = ({
});
return { access_token: fallbackToken, isTokenValid: true };
}
console.error('Error refreshing session', err);
throw err;
}
}
@ -155,6 +156,7 @@ const useSupabaseContextInternal = ({
const setupRefreshTimer = () => {
const expiresInMs = getExpiresAt();
const refreshBuffer = PREEMTIVE_REFRESH_MINUTES * 60000; // Refresh minutes before expiration
const timeUntilRefresh = Math.max(0, expiresInMs - refreshBuffer);
if (refreshTimerRef.current) {
@ -181,14 +183,16 @@ const useSupabaseContextInternal = ({
// Keep access token in sync with Supabase client (captures auto-refresh events)
const { data: subscription } = supabase.auth.onAuthStateChange((event, session) => {
const newToken = session?.access_token;
if (event === 'SIGNED_OUT' || !newToken) {
if (event === 'SIGNED_OUT' || (!newToken && event !== 'INITIAL_SESSION')) {
setAccessToken('');
if (refreshTimerRef.current) {
clearTimeout(refreshTimerRef.current);
}
return;
}
void onUpdateToken({ accessToken: newToken, expiresAt: session?.expires_at ?? 0 });
if (newToken) {
void onUpdateToken({ accessToken: newToken, expiresAt: session?.expires_at ?? 0 });
}
});
return () => {

View File

@ -287,7 +287,7 @@ Today's date is ${new Date().toISOString().split('T')[0]}.
export const getAnalystInstructions = async ({
runtimeContext,
}: { runtimeContext: RuntimeContext<AnalystRuntimeContext> }): Promise<string> => {
const userId = runtimeContext.get('userId');
const _userId = runtimeContext.get('userId');
const dataSourceSyntax = runtimeContext.get('dataSourceSyntax');
// Get dialect-specific guidance

View File

@ -497,7 +497,7 @@ Today's date is ${new Date().toLocaleDateString()}.
export const getThinkAndPrepInstructions = async ({
runtimeContext,
}: { runtimeContext: RuntimeContext<AnalystRuntimeContext> }): Promise<string> => {
const userId = runtimeContext.get('userId');
const _userId = runtimeContext.get('userId');
const dataSourceSyntax = runtimeContext.get('dataSourceSyntax');
// Get dialect-specific guidance

View File

@ -271,7 +271,7 @@ const analystExecution = async ({
.join('\n---\n');
// Get dialect-specific guidance
const sqlDialectGuidance = getSqlDialectGuidance(dataSourceSyntax);
const _sqlDialectGuidance = getSqlDialectGuidance(dataSourceSyntax);
// Create dataset system message
const createDatasetSystemMessage = (databaseContext: string): string => {

View File

@ -186,7 +186,7 @@ const thinkAndPrepExecution = async ({
.join('\n---\n');
// Get dialect-specific guidance
const sqlDialectGuidance = getSqlDialectGuidance(dataSourceSyntax);
const _sqlDialectGuidance = getSqlDialectGuidance(dataSourceSyntax);
// Create dataset system message
const createDatasetSystemMessage = (databaseContext: string): string => {