Skip to content

Commit f46d2cf

Browse files
committed
feat: add web search option and update api url
1 parent b3f6c9e commit f46d2cf

13 files changed

Lines changed: 55 additions & 11 deletions

File tree

libs/mobile/auth/features/google-sign-in-form/src/lib/component.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { ReactElement, useState } from 'react';
55
import { AppButton } from '@open-webui-react-native/mobile/shared/ui/ui-kit';
66
import { authApi } from '@open-webui-react-native/shared/data-access/api';
77
import { appStorageService } from '@open-webui-react-native/shared/data-access/storage';
8-
import { appEnv } from '@open-webui-react-native/shared/utils/app-env';
98
import { ronasApiUrl } from '@open-webui-react-native/shared/utils/config';
109
import { ToastService } from '@open-webui-react-native/shared/utils/toast-service';
1110

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

3635
if (email) {
3736
appStorageService.apiUrl.set(ronasApiUrl);
38-
signInWithGoogle({ email, isProduction: appEnv.current === 'production' });
37+
signInWithGoogle({ email });
3938
} else if (signInResponse.type !== 'cancelled') {
4039
ToastService.showError();
4140
}

libs/mobile/chat/features/form-chat-input/src/lib/component.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ export function FormChatInput<T extends FieldValues>({
185185
isSelected={options.includes(ChatGenerationOption.IMAGE_GENERATION)}
186186
/>
187187
)}
188+
{config?.features.enableWebSearch && (
189+
<SelectOptionIcon
190+
disabled={isLoading}
191+
iconName='web'
192+
onPress={() => onGenerationOptionPress(ChatGenerationOption.WEB_SEARCH)}
193+
isSelected={options.includes(ChatGenerationOption.WEB_SEARCH)}
194+
/>
195+
)}
188196
</View>
189197
<IconButton
190198
disabled={isLoading}

libs/mobile/shared/features/use-logout/src/hook.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ export const useLogout = (): { logout: () => Promise<void>; isLoading: boolean }
99
const { mutateAsync: signOut, isPending } = authApi.useSignOut();
1010

1111
const logout = async (): Promise<void> => {
12-
await signOut();
12+
try {
13+
await signOut();
14+
} catch {
15+
// Session may already be gone; still wipe client state and redirect.
16+
}
1317
authState$.logout();
1418
queryClient.removeQueries();
1519
cookieService.clearAll();
16-
queryPersister.removeClient();
20+
await queryPersister.removeClient();
1721
};
1822

1923
return { logout, isLoading: isPending };

libs/mobile/shared/ui/ui-kit/src/assets/icons/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import trashCan from './trash-can.svg';
5151
import unarchive from './unarchive.svg';
5252
import unpin from './unpin.svg';
5353
import uploadFile from './upload-file.svg';
54+
import web from './web.svg';
5455

5556
export const Icons = {
5657
logoDark,
@@ -106,4 +107,5 @@ export const Icons = {
106107
keyboard,
107108
lessText,
108109
moreText,
110+
web,
109111
};
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './error-catcher-interceptor';
2+
export * from './profile-not-found-interceptor';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { AxiosError, HttpStatusCode } from 'axios';
2+
import { authState$ } from '@open-webui-react-native/shared/data-access/auth';
3+
import { isGetProfileRequest } from '../utils/is-get-profile-request';
4+
5+
export const profileNotFoundInterceptor =
6+
() =>
7+
(error: AxiosError): Promise<never> => {
8+
if (error.response?.status === HttpStatusCode.NotFound && isGetProfileRequest(error.config)) {
9+
authState$.isUnauthorized.set(true);
10+
}
11+
12+
return Promise.reject(error);
13+
};

libs/shared/data-access/api-client/src/service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { appStorageService } from '@open-webui-react-native/shared/data-access/s
55
import { getApiUrl } from '@open-webui-react-native/shared/utils/config';
66
import { ToastService } from '@open-webui-react-native/shared/utils/toast-service';
77
import { apiConfig } from './config';
8-
import { errorCatcherInterceptor } from './interceptors';
8+
import { errorCatcherInterceptor, profileNotFoundInterceptor } from './interceptors';
99

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

@@ -29,6 +29,7 @@ const setupInterceptors = (service: ApiService): void => {
2929
},
3030
}),
3131
],
32+
[null, profileNotFoundInterceptor()],
3233
[
3334
null,
3435
errorCatcherInterceptor({
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { InternalAxiosRequestConfig } from 'axios';
2+
3+
//NOTE: GET current user — same resource as `authService.getProfile()` (`…/v1/auths/`).
4+
export const isGetProfileRequest = (config?: InternalAxiosRequestConfig): boolean => {
5+
if (!config || config.method?.toLowerCase() !== 'get') {
6+
return false;
7+
}
8+
const joined = `${config.baseURL ?? ''}${config.url ?? ''}`.split('?')[0];
9+
const path = joined.replace(/^https?:\/\/[^/]+/i, '');
10+
const tail = path.replace(/\/+$/, '');
11+
12+
return /(^|\/)v1\/auths$/.test(tail);
13+
};

libs/shared/data-access/api/src/lib/auth/models/google-sign-in-request.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ export class GoogleSignInRequest {
44
@Expose()
55
public email: string;
66

7-
@Expose({ name: 'is_production' })
8-
public isProduction?: boolean;
9-
107
constructor(request: Partial<GoogleSignInRequest>) {
118
Object.assign(this, request);
129
}

0 commit comments

Comments
 (0)