Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpareles committed Nov 25, 2024
1 parent aa95cea commit e6c779d
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 45 deletions.
20 changes: 18 additions & 2 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ import { normalizeNFC } from '../../base/common/normalization.js';
import { ICSSDevelopmentService, CSSDevelopmentService } from '../../platform/cssDev/node/cssDevService.js';
import { ExtensionSignatureVerificationService, IExtensionSignatureVerificationService } from '../../platform/extensionManagement/node/extensionSignatureVerificationService.js';

import { ISendLLMMessageService } from '../../platform/void/common/sendLLMMessage.js';
import { SendLLMMessageService } from '../../platform/void/electron-main/sendLLMMessage.js';

/**
* The main VS Code application. There will only ever be one instance,
* even if the user starts many instances (e.g. from the command line).
Expand Down Expand Up @@ -508,6 +511,16 @@ export class CodeApplication extends Disposable {
});

//#endregion

// //#region Void IPC
// validatedIpcMain.handle('vscode:sendLLMMessage', async (event, data) => {
// try {
// await this.sendLLMMessage(data);
// } catch (error) {
// console.error('Error sending LLM message:', error);
// }
// });
// //#endregion
}

private onUnexpectedError(error: Error): void {
Expand Down Expand Up @@ -998,6 +1011,9 @@ export class CodeApplication extends Disposable {
break;
}

// Void
services.set(ISendLLMMessageService, new SyncDescriptor(SendLLMMessageService));

// Windows
services.set(IWindowsMainService, new SyncDescriptor(WindowsMainService, [machineId, sqmId, devDeviceId, this.userEnv], false));
services.set(IAuxiliaryWindowsMainService, new SyncDescriptor(AuxiliaryWindowsMainService, undefined, false));
Expand Down Expand Up @@ -1182,8 +1198,8 @@ export class CodeApplication extends Disposable {
mainProcessElectronServer.registerChannel('keyboardLayout', keyboardLayoutChannel);

// Void
const sendLLMMessageChannel = ProxyChannel.fromService(accessor.get(IEncryptionMainService), disposables);
mainProcessElectronServer.registerChannel('sendLLMMessage', sendLLMMessageChannel);
const sendLLMMessageChannel = ProxyChannel.fromService(accessor.get(ISendLLMMessageService), disposables);
mainProcessElectronServer.registerChannel('void-channel-sendLLMMessage', sendLLMMessageChannel);

// Native host (main & shared process)
this.nativeHostMainService = accessor.get(INativeHostMainService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface IInlineDiffService {
removeDiffs(editor: ICodeEditor): void;
}

export const IInlineDiffService = createDecorator<IInlineDiffService>('inlineDiffService');
export const IInlineDiffService = createDecorator<IInlineDiffService>('inlineDiffServiceOld');

class InlineDiffService extends Disposable implements IInlineDiffService {
private readonly _diffDecorations = new Map<ICodeEditor, string[]>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/

import { ISendLLMMessageService, SendLLMMessageParams } from '../common/sendLLMMessage.js';
import { ProxyChannel } from '../../../../base/parts/ipc/common/ipc.js';
import { IMainProcessService } from '../../../../platform/ipc/common/mainProcessService.js';
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
import { ProxyChannel } from '../../../base/parts/ipc/common/ipc.js';
import { IMainProcessService } from '../../ipc/common/mainProcessService.js';
import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';


// BROWSER IMPLEMENTATION OF SENDLLMMESSAGE
Expand All @@ -22,7 +22,7 @@ export class SendLLMMessageService implements ISendLLMMessageService {
constructor(
@IMainProcessService mainProcessService: IMainProcessService
) {
this._proxySendLLMService = ProxyChannel.toService<ISendLLMMessageService>(mainProcessService.getChannel('sendLLMMessage'));
this._proxySendLLMService = ProxyChannel.toService<ISendLLMMessageService>(mainProcessService.getChannel('void-channel-sendLLMMessage'));
}

sendLLMMessage(params: SendLLMMessageParams) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// void/common/sendLLMMessage.ts

import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
import { VoidConfig } from '../../../contrib/void/browser/registerConfig.js';
import { createDecorator } from '../../instantiation/common/instantiation.js';
import { VoidConfig } from '../../../workbench/contrib/void/browser/registerConfig.js';



Expand Down
20 changes: 20 additions & 0 deletions src/vs/platform/void/electron-main/sendLLMMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
import { ISendLLMMessageService } from '../common/sendLLMMessage.js';
import { sendLLMMessage } from '../../../workbench/contrib/void/browser/react/out/util/sendLLMMessage.js';
// import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';
// import { ipcMain } from 'electron';

// NODE IMPLEMENTATION OF SENDLLMMESSAGE
export class SendLLMMessageService implements ISendLLMMessageService {
readonly _serviceBrand: undefined;

async sendLLMMessage(data: any) {
console.log('NODE sendLLMMessage', data);
// ipcMain.emit('vscode:sendLLMMessage', data)

return sendLLMMessage(data)
}
}

// we don't need to register this, it's registered in app.ts:
// registerSingleton(ISendLLMMessageService, SendLLMMessageService, InstantiationType.Delayed);
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/void/browser/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ A couple things to remember:

- Make sure to add .js at the end of any external imports used in here, e.g. ../../../../../my_file.js. If you don't do this, you will get untraceable errors.

- src/ needs to be shallow so the detection of externals works properly (see tsup.config.js).
- src/ needs to be shallow (1 folder deep) so the detection of externals works properly (see tsup.config.js).


Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import React, { FormEvent, Fragment, useCallback, useEffect, useRef, useState }


import { useConfigState, useService, useThreadsState } from '../util/services.js';
import { sendLLMMessage } from '../util/sendLLMMessage.js';
import { generateDiffInstructions } from '../../../prompt/systemPrompts.js';
import { userInstructionsStr } from '../../../prompt/stringifyFiles.js';
import { CodeSelection, CodeStagingSelection } from '../../../registerThreads.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Ollama } from 'ollama/browser'
import { Content, GoogleGenerativeAI, GoogleGenerativeAIFetchError } from '@google/generative-ai';
import { posthog } from 'posthog-js'
import type { VoidConfig } from '../../../registerConfig.js';
import type { LLMMessage, LLMMessageOnText, OnFinalMessage, } from '../../../../../../services/void/common/sendLLMMessage.js';
import { SendLLMMessageParams } from '../../../../../../services/void/common/sendLLMMessage.js';
import type { LLMMessage, LLMMessageOnText, OnFinalMessage, } from '../../../../../../../platform/void/common/sendLLMMessage.js';
import { SendLLMMessageParams } from '../../../../../../../platform/void/common/sendLLMMessage.js';

type SendLLMMessageFnTypeInternal = (params: {
messages: LLMMessage[];
Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import { ILanguageService } from '../../../../editor/common/languages/language.j
import * as dom from '../../../../base/browser/dom.js';
import { Widget } from '../../../../base/browser/ui/widget.js';
import { URI } from '../../../../base/common/uri.js';
import { ISendLLMMessageService } from '../../../services/void/common/sendLLMMessage.js';
import { ISendLLMMessageService } from '../../../../platform/void/common/sendLLMMessage.js';
// import { ISendLLMMessageService } from '../../../../platform/void/common/sendLLMMessage.js';
// import { sendLLMMessage } from './react/out/util/sendLLMMessage.js';


Expand Down Expand Up @@ -116,7 +117,7 @@ export interface IInlineDiffsService {

}

export const IInlineDiffsService = createDecorator<IInlineDiffsService>('inlineDiffsService');
export const IInlineDiffsService = createDecorator<IInlineDiffsService>('inlineDiffAreasService');

class InlineDiffsService extends Disposable implements IInlineDiffsService {
_serviceBrand: undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/void/browser/registerSidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { IVoidConfigStateService } from './registerConfig.js';
import { IFileService } from '../../../../platform/files/common/files.js';
import { IInlineDiffsService } from './registerInlineDiffs.js';
import { IModelService } from '../../../../editor/common/services/model.js';
import { ISendLLMMessageService } from '../../../services/void/common/sendLLMMessage.js';
import { ISendLLMMessageService } from '../../../../platform/void/common/sendLLMMessage.js';
// import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';


Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/electron-sandbox/desktop.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ export class DesktopMain extends Disposable {
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

// // Void
// const sendLLMMessageService = new SendLLMMessageService();
// serviceCollection.set(ISendLLMMessageService, sendLLMMessageService);



return { serviceCollection, logService, storageService, configurationService };
}
Expand Down
17 changes: 0 additions & 17 deletions src/vs/workbench/services/void/electron-sandbox/sendLLMMessage.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/vs/workbench/workbench.common.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import './browser/workbench.contribution.js';
//#region --- Void
// Void added this:
import './contrib/void/browser/void.contribution.js';
import '../platform/void/browser/sendLLMMessage.js';
//#endregion


Expand Down
11 changes: 4 additions & 7 deletions src/vs/workbench/workbench.desktop.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@ import './electron-sandbox/parts/dialogs/dialog.contribution.js';

//#endregion




//#region --- Void
// Void added this (modeling off of import '.*clipboardservice.js'):
import './services/void/electron-sandbox/sendLLMMessage.js';
//#endregion
// //#region --- Void
// // Void added this (modeling off of import '.*clipboardservice.js'):
// import './services/void/electron-main/sendLLMMessage.js';
// //#endregion



Expand Down
5 changes: 0 additions & 5 deletions src/vs/workbench/workbench.web.main.internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ import './browser/web.main.js';



//#region --- Void
// Void added this (modeling off of import '.*clipboardservice.js'):
import './services/void/browser/sendLLMMessage.js';
//#endregion



//#region --- workbench services
Expand Down
12 changes: 12 additions & 0 deletions test/unit/electron/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@
process.on(type, callback);
}
},

// Void : {
// /**
// * Send a message to the LLM.
// * @param {any} data The data to send to the LLM.
// * @returns {Promise<any>} The response from the LLM.
// */
// sendLLMMessage: async (data) => {
// // Use ipcRenderer.invoke to send the message to the main process (see app.ts)
// return await ipcRenderer.invoke('vscode:sendLLMMessage', data);
// }
// },
};

if (process.contextIsolated) {
Expand Down

0 comments on commit e6c779d

Please sign in to comment.