Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with execute not sending blockIDs to the server #58

Merged
merged 2 commits into from
Apr 17, 2024
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
4 changes: 4 additions & 0 deletions frontend/foyle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
{
"command": "foyle.helloWorld",
"title": "Foyle HelloWorld"
},
{
"command": "foyle.printCell",
"title": "Foyle Print Cell Metadata"
}
],
"keybindings": [
Expand Down
12 changes: 8 additions & 4 deletions frontend/foyle/src/web/controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from "vscode";
import { promisify } from 'util';
import * as constants from './constants';
import * as converters from './converters';
import * as client from './client';
import * as agentpb from "../gen/foyle/v1alpha1/agent_pb";
import * as docpb from "../gen/foyle/v1alpha1/doc_pb";
Expand Down Expand Up @@ -66,14 +67,17 @@ export class Controller {
}

async function callExecute(cell: vscode.NotebookCell, client: client.FoyleClient): Promise<vscode.NotebookCellOutput[]> {
if (cell.metadata.hasOwnProperty("id")) {
console.log(`callExecute called on block id = ${cell.metadata["id"]}`);
} else {
console.log(`callExecute called on block without id`);
}
console.log(`callExecute called ${cell.document.getText()}`);

const request = new agentpb.ExecuteRequest();

request.block = new docpb.Block();
request.block.kind = docpb.BlockKind.CODE;
request.block.contents = cell.document.getText();

request.block = converters.cellDataToBlock(converters.cellToCellData(cell));

return client.Execute(request).then((response) => {
let output: vscode.NotebookCellOutput[] = [];

Expand Down
30 changes: 30 additions & 0 deletions frontend/foyle/src/web/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as vscode from 'vscode';
import {FoyleClient, getTraceID} from './client';
import * as converters from './converters';
import * as docpb from "../gen/foyle/v1alpha1/doc_pb";
import * as agentpb from "../gen/foyle/v1alpha1/agent_pb";
// printCell is a debug tool that prints the contents of a cell to the console
// Its purpose is to help us debug problems by printing the contents of a cell
// In particular the cell metadata
export async function printCell() {
const editor = vscode.window.activeNotebookEditor;

if (!editor) {
return;
}

if (editor?.selection.isEmpty) {
return;
}

// We subtract 1 because end is non-inclusive
const lastSelectedCell = editor?.selection.end - 1;
var lastActiveCell = editor?.notebook.cellAt(lastSelectedCell);
console.log(`Cell value: ${lastActiveCell.document.getText()}`);
console.log(`Cell language: ${lastActiveCell.document.languageId}`);
console.log(`Cell kind: ${lastActiveCell.kind}`);

Object.keys(lastActiveCell.metadata).forEach(key => {
console.log(`Cell Metadata key: ${key} value: ${lastActiveCell.metadata[key]}`);
});
}
3 changes: 3 additions & 0 deletions frontend/foyle/src/web/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Controller } from './controller';
import {FoyleClient} from './client';
import { Serializer } from './serializer';
import * as generate from './generate';
import * as debug from './debug';
// Create a client for the backend.
const client = new FoyleClient;

Expand Down Expand Up @@ -52,6 +53,8 @@ export function activate(context: vscode.ExtensionContext) {
// Here's where we register the command that will generate a completion using the AI model
// You can set a keybinding for this command in the package.json file
context.subscriptions.push(vscode.commands.registerCommand("foyle.generate", generate.generateCompletion));

context.subscriptions.push(vscode.commands.registerCommand("foyle.printCell", debug.printCell));
context.subscriptions.push(disposable);
}

Expand Down
Loading