Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Merge pull request #649 from codestoryai/features/pass-editor-url-to-…
Browse files Browse the repository at this point in the history
…agent

[ide] pass editor url to the agent
  • Loading branch information
theskcd authored Jun 3, 2024
2 parents b19f033 + 86318a3 commit 333cfe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export class CSChatAgentProvider implements vscode.Disposable {
private _sideCarClient: SideCarClient;
private _currentRepoRef: RepoRef;
private _projectContext: ProjectContext;
// Pass this when talking to the agent
private _editorUrl: string;

constructor(
workingDirectory: string,
Expand All @@ -85,6 +87,7 @@ export class CSChatAgentProvider implements vscode.Disposable {
sideCarClient: SideCarClient,
repoRef: RepoRef,
projectContext: ProjectContext,
editorUrl: string,
) {
this._workingDirectory = workingDirectory;
this._repoHash = repoHash;
Expand All @@ -93,6 +96,7 @@ export class CSChatAgentProvider implements vscode.Disposable {
this._sideCarClient = sideCarClient;
this._currentRepoRef = repoRef;
this._projectContext = projectContext;
this._editorUrl = editorUrl;

this.chatAgent = vscode.chat.createChatParticipant('aide', this.defaultAgentRequestHandler);
this.chatAgent.isDefault = true;
Expand Down
47 changes: 3 additions & 44 deletions extensions/codestory/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ export async function activate(context: ExtensionContext) {
}
});

const editorUrl = `http://localhost:${port}`;

// Register a disposable to stop the server when the extension is deactivated
context.subscriptions.push({
dispose: () => {
Expand Down Expand Up @@ -243,7 +245,7 @@ export async function activate(context: ExtensionContext) {
const chatAgentProvider = new CSChatAgentProvider(
rootPath, repoName, repoHash,
uniqueUserId,
sidecarClient, currentRepo, projectContext,
sidecarClient, currentRepo, projectContext, editorUrl,
);
context.subscriptions.push(chatAgentProvider);

Expand Down Expand Up @@ -289,47 +291,4 @@ export async function activate(context: ExtensionContext) {
);
}
});


// TODO(skcd): I promise to clean this up better, I am trying to see if things still
// work if I wait here and check the diagnostics and if its working
// await new Promise(resolve => setTimeout(resolve, 20000));
// // over here we will execute the code action provider
// try {
// const textDocumentUri = Uri.file('/Users/skcd/scratch/sidecar/llm_client/src/clients/types.rs');
// // opens the text document as required
// await workspace.openTextDocument(textDocumentUri);
// const range = new vscode.Range(new Position(571, 27), new Position(571, 28));
// const codeActions: vscode.CodeAction[] = await commands.executeCommand(
// 'vscode.executeCodeActionProvider',
// textDocumentUri,
// range,
// );
// console.log('code actions worked');
// // lets see what happens over here
// console.log(codeActions);
// const firstCodeActionCommand = codeActions[1].command;
// const firstCodeArguments = codeActions[1].command?.arguments;
// try {
// if (firstCodeActionCommand !== undefined && firstCodeArguments !== undefined) {
// // console.log(firstCodeAction.command);
// // console.log(firstCodeAction.arguments);
// console.log(firstCodeArguments[0]);
// const firstArgument = firstCodeArguments[0][0].arguments;
// console.log(firstArgument);
// const result = await commands.executeCommand('rust-analyzer.resolveCodeAction', firstArgument);
// // const result = await commands.executeCommand(firstCodeActionCommand.command, ...firstCodeArguments);
// console.log('sub results from result');
// console.log(result);
// } else {
// console.log('missing command');
// }
// } catch (exception) {
// console.log(exception);
// }
// // await commands.executeCommand(codeActions[0].command, ...codeActions[1].arguments);
// } catch (exception) {
// console.log('code action execution error');
// console.error(exception);
// }
}

0 comments on commit 333cfe1

Please sign in to comment.