Skip to content

Conversation

@gpetrov
Copy link

@gpetrov gpetrov commented Apr 29, 2025

improve the preloader to run also on windows without context isolation

improve the preloader to run also on windows without context isolation
@gpetrov gpetrov requested a review from a team as a code owner April 29, 2025 09:34
Copy link
Member

@felixrieseberg felixrieseberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this looks good!

@felixrieseberg felixrieseberg changed the title allow to run on windows without context isolation fix: allow to run on windows without context isolation May 2, 2025
@felixrieseberg
Copy link
Member

Please update the tests - once you do, I'm happy to merge it in!

gpetrov added 2 commits May 6, 2025 13:06
now all tests also test the case of no context isolated windows
Copy link
Member

@felixrieseberg felixrieseberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the tests! The actual code still looks good, but the tests probably need some work. I've left some comments!

@@ -1,7 +1,11 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { loadElectronLlm } from '../src/preload/index.ts';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, with this change we're no longer testing the actual file!

});

// Create a clean copy of the electronAi API to test with
const createElectronAiApi = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could and should import the actual API we're trying to test!

};

// Create our own loadElectronLlm function for testing
const loadElectronLlmForTests = async (contextIsolated: boolean) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the code we're actually trying to test, but a copy of it!

await loadElectronLlm();
ipcRenderer = (await import('electron')).ipcRenderer;
});
// Tests with context isolation enabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these tests do the exact same thing as without context isolation, so we should probably condense them into just one group of tests!

});

await (globalThis as any).electronAi.promptStreaming(input);
it('should handle errors during API exposure', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants