Here's a minimal GitHub Gist that runs on Electron Fiddle :
It's supposed to show GitHub Copilot (github.com/copilot) in a webview element as if it was in a normal browser :
Using the following code :
const webviewSession = session.fromPartition(`persist:${id}`); // <- `id` === 'githubCopilot', pointing to element `<webview partition="persist:githubCopilot"></webview>`
webviewSession.protocol.handle('https', request => new Promise(async resolve => {
const response = await net.fetch(request, { bypassCustomProtocolHandlers: true });
resolve(response);
}));
I'm intercepting the requests with the intent of doing something later, notably logging SSE chunks, but for now I want it working while doing nothing more.
However, after logging in, the chat history never loads :
I noticed there was a request that was failing with HTTP 422 :
Which return 200 in a normal browser :
Any idea what could be wrong here, considering I'm not even transforming the requests at all yet ?
Here's the code I will add for logging SSE below resolve(response) (already tested and working on a different website that uses SSE) :
if(response.headers.get('content-type') === 'text/event-stream'){
const
reader = response.clone().body.getReader(),
decoder = new TextDecoder();
while(true){
const { done, value } = await reader.read();
if(done) break;
const text = decoder.decode(value, { stream: true });
console.log({ text });
}
Whatever solution works for the primary issue should also either remain compatible with this or have an alternative for it.
Please don't mention AI, it always either suggests webviewSession.protocol.interceptStreamProtocol which is deprecated, or webviewSession.webRequest.filterResponseData which doesn't exist at all.
Thanks





webviewtag itself is deprecated these days. Is there a reason why you don't use aWebContentsViewinstead?webviewelements that I conditonally make (in)visible using a tabbed interface powered by Vue. The Fiddle example is just a minimal version using only one. The useless-lookingforloop is a remnant of that multi-webviewconfig actually. Anyways, would doing that switch solve my issue anyway ?