diff --git a/frontend/foyle/package.json b/frontend/foyle/package.json index c558e4b8..15ba7f9e 100644 --- a/frontend/foyle/package.json +++ b/frontend/foyle/package.json @@ -24,6 +24,10 @@ { "command": "foyle.helloWorld", "title": "Foyle HelloWorld" + }, + { + "command": "foyle.printCell", + "title": "Foyle Print Cell Metadata" } ], "keybindings": [ diff --git a/frontend/foyle/src/web/controller.ts b/frontend/foyle/src/web/controller.ts index 398c1ae1..bc862d69 100644 --- a/frontend/foyle/src/web/controller.ts +++ b/frontend/foyle/src/web/controller.ts @@ -66,6 +66,11 @@ export class Controller { } async function callExecute(cell: vscode.NotebookCell, client: client.FoyleClient): Promise { + 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(); diff --git a/frontend/foyle/src/web/debug.ts b/frontend/foyle/src/web/debug.ts new file mode 100644 index 00000000..1be92fe4 --- /dev/null +++ b/frontend/foyle/src/web/debug.ts @@ -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]}`); + }); +} \ No newline at end of file diff --git a/frontend/foyle/src/web/extension.ts b/frontend/foyle/src/web/extension.ts index cbba94a7..55d81617 100644 --- a/frontend/foyle/src/web/extension.ts +++ b/frontend/foyle/src/web/extension.ts @@ -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; @@ -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); }