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
1 change: 0 additions & 1 deletion packages/insomnia/src/entry.preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ const main: Window['main'] = {
useDynamicMockResponses,
mockServerAdditionalFiles,
),
getUserDataPath: () => ipcRenderer.invoke('getUserDataPath'),
};

ipcRenderer.on('hidden-browser-window-response-listener', event => {
Expand Down
1 change: 0 additions & 1 deletion packages/insomnia/src/main/ipc/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export type HandleChannels =
| 'extractJsonFileFromPostmanDataDumpArchive'
| 'getExecution'
| 'getLocalStorageDataFromFileOrigin'
| 'getUserDataPath'
| 'git.canPushLoader'
| 'git.checkoutGitBranch'
| 'git.cloneGitRepo'
Expand Down
5 changes: 0 additions & 5 deletions packages/insomnia/src/main/ipc/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export interface RendererToMainBridgeAPI {
useDynamicMockResponses: boolean,
mockServerAdditionalFiles: string[],
) => Promise<{ error: string; routes: MockRouteData[] }>;
getUserDataPath: () => Promise<string>;
}

export function registerMainHandlers() {
Expand Down Expand Up @@ -382,8 +381,4 @@ export function registerMainHandlers() {
}
},
);

ipcMainHandle('getUserDataPath', () => {
return app.getPath('userData');
});
}
7 changes: 3 additions & 4 deletions packages/insomnia/src/main/llm-config-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import path from 'node:path';

import { app } from 'electron';

import { ipcMainHandle } from '~/main/ipc/electron';

import * as models from '../models';
Expand Down Expand Up @@ -68,10 +70,7 @@ export const getBackendConfig = async (backend: LLMBackend): Promise<Partial<LLM
}

if (backend === 'gguf') {
// TODO front service with electron handlers so we can use the below
// const llmDir = path.join(process.env['INSOMNIA_DATA_PATH'] || app.getPath('userData'), 'llms');
const userDataPath = process.env['INSOMNIA_DATA_PATH'] || (await window.main.getUserDataPath());
const llmDir = path.join(userDataPath, 'llms');
const llmDir = path.join(process.env['INSOMNIA_DATA_PATH'] || app.getPath('userData'), 'llms');
config.modelDir = llmDir;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { href, redirect } from 'react-router';

import { getAppVersion, getMockServiceURL, METHOD_GET } from '~/common/constants';
import { database } from '~/common/database';
import { getCurrentConfig } from '~/main/llm-config-service';
import * as models from '~/models';
import { userSession } from '~/models';
import type { MockRoute } from '~/models/mock-route';
Expand Down Expand Up @@ -65,7 +64,7 @@ export async function clientAction({ request, params }: Route.ClientActionArgs)
const mockServerType = workspaceData.mockServerType;
invariant(mockServerType === 'cloud' || mockServerType === 'self-hosted', 'Mock Server type is required');

const modelConfig = await getCurrentConfig();
const modelConfig = await window.main.llm.getCurrentConfig();
if (workspaceData.mockServerCreationType === 'ai') {
invariant(modelConfig, 'You must setup LLM configuration in your Preferences before using AI features.');

Expand Down Expand Up @@ -267,7 +266,7 @@ async function continueMockServerCreation(
specText = workspaceData.mockServerSpecText!;
}

const modelConfig = await getCurrentConfig();
const modelConfig = await window.main.llm.getCurrentConfig();
const result = await window.main.generateMockRouteDataFromSpec(
openapiSpec,
specUrl,
Expand Down
Loading