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
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
25 changes: 16 additions & 9 deletions web-app/src/lib/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@

// Add attachments to content array
if (attachments) {
attachments.forEach((attachment) => {
if (attachment.type.startsWith('image/')) {
contentParts.push({
type: ContentType.Image,
image_url: {
url: `data:${attachment.type};base64,${attachment.base64}`,
detail: 'auto',
},
} as any)
}
})
}

Check warning on line 85 in web-app/src/lib/completion.ts

View workflow job for this annotation

GitHub Actions / coverage-check

74-85 lines are not covered with tests

Check warning on line 85 in web-app/src/lib/completion.ts

View workflow job for this annotation

GitHub Actions / coverage-check

74-85 lines are not covered with tests

return {
type: 'text',
Expand Down Expand Up @@ -169,11 +169,12 @@
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' && {
Expand All @@ -183,10 +184,11 @@
},
}),
// 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)
Expand Down Expand Up @@ -402,7 +404,10 @@
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 =
Expand All @@ -416,10 +421,12 @@
)
: 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)

Expand Down
1 change: 1 addition & 0 deletions web-app/src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions web-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,96 +1,97 @@
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import path from 'path'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import packageJson from './package.json'
const host = process.env.TAURI_DEV_HOST

Check warning on line 8 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

1-8 lines are not covered with tests

Check warning on line 8 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

1-8 lines are not covered with tests

// https://vite.dev/config/
export default defineConfig(({ mode }) => {

Check warning on line 11 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

11 line is not covered with tests

Check warning on line 11 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

11 line is not covered with tests
// Load env file based on `mode` in the current working directory.
const env = loadEnv(mode, process.cwd(), '')

Check warning on line 13 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

13 line is not covered with tests

Check warning on line 13 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

13 line is not covered with tests

return {
plugins: [
TanStackRouterVite({
target: 'react',
autoCodeSplitting: true,
routeFileIgnorePattern: '.((test).ts)|test-page',
}),
react(),
tailwindcss(),
nodePolyfills({
include: ['path'],
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
optimizeDeps: {
exclude: ['@jan/extensions-web'],
},
build: {
rollupOptions: {
external: ['@jan/extensions-web'],
},
},
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
),
IS_WINDOWS: JSON.stringify(
process.env.TAURI_ENV_PLATFORM?.includes('windows') ?? false
),
IS_LINUX: JSON.stringify(
process.env.TAURI_ENV_PLATFORM?.includes('linux') ?? false
),
IS_IOS: JSON.stringify(
process.env.TAURI_ENV_PLATFORM?.includes('ios') ?? false
),
IS_ANDROID: JSON.stringify(
process.env.TAURI_ENV_PLATFORM?.includes('android') ?? false
),
PLATFORM: JSON.stringify(process.env.TAURI_ENV_PLATFORM),

Check warning on line 60 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

15-60 lines are not covered with tests

Check warning on line 60 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

15-60 lines are not covered with tests

VERSION: JSON.stringify(packageJson.version),

Check warning on line 62 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

62 line is not covered with tests

Check warning on line 62 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

62 line is not covered with tests

POSTHOG_KEY: JSON.stringify(env.POSTHOG_KEY),
POSTHOG_HOST: JSON.stringify(env.POSTHOG_HOST),
GA_MEASUREMENT_ID: JSON.stringify(env.GA_MEASUREMENT_ID),
MODEL_CATALOG_URL: JSON.stringify(
'https://raw.githubusercontent.com/menloresearch/model-catalog/main/model_catalog.json'
),
AUTO_UPDATER_DISABLED: JSON.stringify(
env.AUTO_UPDATER_DISABLED === 'true'
),
},

Check warning on line 73 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

64-73 lines are not covered with tests

Check warning on line 73 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

64-73 lines are not covered with tests

// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,

Check warning on line 78 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

78 line is not covered with tests

Check warning on line 78 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

78 line is not covered with tests
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: 'ws',
host,
port: 1421,
}
: undefined,
watch: {

Check warning on line 91 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

80-91 lines are not covered with tests

Check warning on line 91 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

80-91 lines are not covered with tests
// 3. tell vite to ignore watching `src-tauri`
ignored: ['**/src-tauri/**'],
},
},
}
})

Check warning on line 97 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

93-97 lines are not covered with tests

Check warning on line 97 in web-app/vite.config.ts

View workflow job for this annotation

GitHub Actions / coverage-check

93-97 lines are not covered with tests
Loading