Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ReactElement, useState } from 'react';
import { AppButton } from '@open-webui-react-native/mobile/shared/ui/ui-kit';
import { authApi } from '@open-webui-react-native/shared/data-access/api';
import { appStorageService } from '@open-webui-react-native/shared/data-access/storage';
import { appEnv } from '@open-webui-react-native/shared/utils/app-env';
import { ronasApiUrl } from '@open-webui-react-native/shared/utils/config';
import { ToastService } from '@open-webui-react-native/shared/utils/toast-service';

Expand Down Expand Up @@ -35,7 +34,7 @@ export function GoogleSignInForm({ onSuccess }: GoogleSignInFormProps): ReactEle

if (email) {
appStorageService.apiUrl.set(ronasApiUrl);
signInWithGoogle({ email, isProduction: appEnv.current === 'production' });
signInWithGoogle({ email });
} else if (signInResponse.type !== 'cancelled') {
ToastService.showError();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ export function FormChatInput<T extends FieldValues>({
isSelected={options.includes(ChatGenerationOption.IMAGE_GENERATION)}
/>
)}
{config?.features.enableWebSearch && (
<SelectOptionIcon
disabled={isLoading}
iconName='web'
onPress={() => onGenerationOptionPress(ChatGenerationOption.WEB_SEARCH)}
isSelected={options.includes(ChatGenerationOption.WEB_SEARCH)}
/>
)}
</View>
<IconButton
disabled={isLoading}
Expand Down
8 changes: 6 additions & 2 deletions libs/mobile/shared/features/use-logout/src/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ export const useLogout = (): { logout: () => Promise<void>; isLoading: boolean }
const { mutateAsync: signOut, isPending } = authApi.useSignOut();

const logout = async (): Promise<void> => {
await signOut();
try {
await signOut();
} catch {
// Session may already be gone; still wipe client state and redirect.
}
authState$.logout();
queryClient.removeQueries();
cookieService.clearAll();
queryPersister.removeClient();
await queryPersister.removeClient();
};

return { logout, isLoading: isPending };
Expand Down
2 changes: 2 additions & 0 deletions libs/mobile/shared/ui/ui-kit/src/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import trashCan from './trash-can.svg';
import unarchive from './unarchive.svg';
import unpin from './unpin.svg';
import uploadFile from './upload-file.svg';
import web from './web.svg';

export const Icons = {
logoDark,
Expand Down Expand Up @@ -106,4 +107,5 @@ export const Icons = {
keyboard,
lessText,
moreText,
web,
};
4 changes: 4 additions & 0 deletions libs/mobile/shared/ui/ui-kit/src/assets/icons/web.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './error-catcher-interceptor';
export * from './profile-not-found-interceptor';
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { AxiosError, HttpStatusCode } from 'axios';
import { authState$ } from '@open-webui-react-native/shared/data-access/auth';
import { isGetProfileRequest } from '../utils/is-get-profile-request';

export const profileNotFoundInterceptor =
() =>
(error: AxiosError): Promise<never> => {
if (error.response?.status === HttpStatusCode.NotFound && isGetProfileRequest(error.config)) {
authState$.isUnauthorized.set(true);
}

return Promise.reject(error);
};
3 changes: 2 additions & 1 deletion libs/shared/data-access/api-client/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { appStorageService } from '@open-webui-react-native/shared/data-access/s
import { getApiUrl } from '@open-webui-react-native/shared/utils/config';
import { ToastService } from '@open-webui-react-native/shared/utils/toast-service';
import { apiConfig } from './config';
import { errorCatcherInterceptor } from './interceptors';
import { errorCatcherInterceptor, profileNotFoundInterceptor } from './interceptors';

const apiServiceCache = new Map<string, ApiService>();

Expand All @@ -29,6 +29,7 @@ const setupInterceptors = (service: ApiService): void => {
},
}),
],
[null, profileNotFoundInterceptor()],
[
null,
errorCatcherInterceptor({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { InternalAxiosRequestConfig } from 'axios';

//NOTE: GET current user — same resource as `authService.getProfile()` (`…/v1/auths/`).
export const isGetProfileRequest = (config?: InternalAxiosRequestConfig): boolean => {
if (!config || config.method?.toLowerCase() !== 'get') {
return false;
}
const joined = `${config.baseURL ?? ''}${config.url ?? ''}`.split('?')[0];
const path = joined.replace(/^https?:\/\/[^/]+/i, '');
const tail = path.replace(/\/+$/, '');

return /(^|\/)v1\/auths$/.test(tail);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ export class GoogleSignInRequest {
@Expose()
public email: string;

@Expose({ name: 'is_production' })
public isProduction?: boolean;

constructor(request: Partial<GoogleSignInRequest>) {
Object.assign(this, request);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum ChatGenerationOption {
IMAGE_GENERATION = 'imageGeneration',
CODE_INTERPRETER = 'codeInterpreter',
WEB_SEARCH = 'webSearch',
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function prepareCompleteChatPayload({
features: new Features({
codeInterpreter: generationOptions?.includes(ChatGenerationOption.CODE_INTERPRETER),
imageGeneration: generationOptions?.includes(ChatGenerationOption.IMAGE_GENERATION),
webSearch: generationOptions?.includes(ChatGenerationOption.WEB_SEARCH),
}),
stream: true,
model,
Expand Down
6 changes: 3 additions & 3 deletions libs/shared/utils/config/src/get-api-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { appStorageService } from '@open-webui-react-native/shared/data-access/s
import { appEnv } from '@open-webui-react-native/shared/utils/app-env';

export const ronasApiUrl = appEnv.select({
development: 'https://dev.ai.ronas.cloud',
staging: 'https://dev.ai.ronas.cloud',
production: 'https://ai.ronas.cloud',
development: 'https://ai.ronas.online',
staging: 'https://ai.ronas.online',
production: 'https://ai.ronas.online',
});

export const getApiUrl = (): string => {
Expand Down
Loading