diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index dd960fa5cc..6aaa66bb7f 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -6,7 +6,7 @@ "build": { "frontendDist": "../web-app/dist", "devUrl": "http://localhost:1420", - "beforeDevCommand": "cross-env IS_TAURI=true yarn dev:web", + "beforeDevCommand": "cross-env IS_TAURI=true IS_DEV=true yarn dev:web", "beforeBuildCommand": "cross-env IS_TAURI=true yarn build:web" }, "app": { diff --git a/web-app/src/lib/completion.ts b/web-app/src/lib/completion.ts index 023c394818..32f1bdc575 100644 --- a/web-app/src/lib/completion.ts +++ b/web-app/src/lib/completion.ts @@ -169,11 +169,12 @@ export const sendCompletion = async ( providerName = 'openai-compatible' const tokenJS = new TokenJS({ - apiKey: provider.api_key ?? (await getServiceHub().core().getAppToken()) ?? '', + apiKey: + provider.api_key ?? (await getServiceHub().core().getAppToken()) ?? '', // TODO: Retrieve from extension settings baseURL: provider.base_url, // Use Tauri's fetch to avoid CORS issues only for openai-compatible provider - ...(providerName === 'openai-compatible' && { fetch: getServiceHub().providers().fetch() }), + fetch: IS_DEV ? fetch : getServiceHub().providers().fetch(), // OpenRouter identification headers for Jan // ref: https://openrouter.ai/docs/api-reference/overview#headers ...(provider.provider === 'openrouter' && { @@ -183,10 +184,11 @@ export const sendCompletion = async ( }, }), // Add Origin header for local providers to avoid CORS issues - ...((provider.base_url?.includes('localhost:') || provider.base_url?.includes('127.0.0.1:')) && { + ...((provider.base_url?.includes('localhost:') || + provider.base_url?.includes('127.0.0.1:')) && { fetch: getServiceHub().providers().fetch(), defaultHeaders: { - 'Origin': 'tauri://localhost', + Origin: 'tauri://localhost', }, }), } as ExtendedConfigOptions) @@ -402,7 +404,10 @@ export const postMessageProcessing = async ( console.log('Parsed tool parameters:', toolParameters) } catch (error) { console.error('Failed to parse tool arguments:', error) - console.error('Raw arguments that failed:', toolCall.function.arguments) + console.error( + 'Raw arguments that failed:', + toolCall.function.arguments + ) } } const approved = @@ -416,10 +421,12 @@ export const postMessageProcessing = async ( ) : true) - const { promise, cancel } = getServiceHub().mcp().callToolWithCancellation({ - toolName: toolCall.function.name, - arguments: toolCall.function.arguments.length ? toolParameters : {}, - }) + const { promise, cancel } = getServiceHub() + .mcp() + .callToolWithCancellation({ + toolName: toolCall.function.name, + arguments: toolCall.function.arguments.length ? toolParameters : {}, + }) useAppState.getState().setCancelToolCall(cancel) diff --git a/web-app/src/types/global.d.ts b/web-app/src/types/global.d.ts index 9f0f30dff0..c22539146b 100644 --- a/web-app/src/types/global.d.ts +++ b/web-app/src/types/global.d.ts @@ -22,6 +22,7 @@ declare global { declare const MODEL_CATALOG_URL: string declare const AUTO_UPDATER_DISABLED: boolean declare const GA_MEASUREMENT_ID: string + declare const IS_DEV: boolean interface Window { core: AppCore | undefined gtag?: (...args: unknown[]) => void diff --git a/web-app/vite.config.ts b/web-app/vite.config.ts index efd3f8647f..317f219e21 100644 --- a/web-app/vite.config.ts +++ b/web-app/vite.config.ts @@ -40,6 +40,7 @@ export default defineConfig(({ mode }) => { }, define: { IS_TAURI: JSON.stringify(process.env.IS_TAURI), + IS_DEV: JSON.stringify(process.env.IS_DEV), IS_WEB_APP: JSON.stringify(false), IS_MACOS: JSON.stringify( process.env.TAURI_ENV_PLATFORM?.includes('darwin') ?? false