Skip to content

Commit

Permalink
Update to Jupyterlab 4.3 and fix prompt accept bug (#13)
Browse files Browse the repository at this point in the history
* Update to Jupyterlab 4.3 and fix prompt accept bug

This updates to Jupyterlab 4.3 and includes the fix for the
`postModelPromptAccept` edge case
  • Loading branch information
ajbozarth authored Oct 30, 2024
1 parent 47e8cd7 commit 84ceea3
Show file tree
Hide file tree
Showing 7 changed files with 720 additions and 750 deletions.
2 changes: 1 addition & 1 deletion GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Requirements

- JupyterLab >= 4.2.0
- JupyterLab >= 4.3.0
- An IBM Quantum premium account

## Install
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ for the frontend extension.

## Requirements

- JupyterLab >= 4.2.0
- JupyterLab >= 4.3.0
- An IBM Quantum premium account

## Install
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyterlab/application": "^4.2.0",
"@jupyterlab/apputils": "^4.2.0",
"@jupyterlab/completer": "^4.2.0",
"@jupyterlab/coreutils": "^6.2.0",
"@jupyterlab/notebook": "^4.2.0",
"@jupyterlab/services": "^7.2.0",
"@jupyterlab/settingregistry": "^4.2.0",
"@jupyterlab/statusbar": "^4.2.0",
"@jupyterlab/ui-components": "^4.2.0",
"@lumino/messaging": "^2.0.1",
"@lumino/widgets": "^2.3.2"
"@jupyterlab/application": "^4.3.0",
"@jupyterlab/apputils": "^4.4.0",
"@jupyterlab/completer": "^4.3.0",
"@jupyterlab/coreutils": "^6.3.0",
"@jupyterlab/notebook": "^4.3.0",
"@jupyterlab/services": "^7.3.0",
"@jupyterlab/settingregistry": "^4.3.0",
"@jupyterlab/statusbar": "^4.3.0",
"@jupyterlab/ui-components": "^4.3.0",
"@lumino/messaging": "^2.0.2",
"@lumino/widgets": "^2.5.0"
},
"devDependencies": {
"@jupyterlab/builder": "^4.2.0",
"@jupyterlab/builder": "^4.3.0",
"@types/json-schema": "^7.0.11",
"@types/react": "^18.0.26",
"@types/react-addons-linked-state-mixin": "^0.14.22",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version>=0.3.2"]
requires = ["hatchling>=1.5.0", "jupyterlab>=4.3.0,<5", "hatch-nodejs-version>=0.3.2"]
build-backend = "hatchling.build"

[project]
Expand Down
6 changes: 4 additions & 2 deletions src/QiskitCompletionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class QiskitCompletionProvider implements ICompletionProvider {

settings: ISettingRegistry.ISettings;
prompt_id: string = '';
results: string[] = [];

constructor(options: { settings: ISettingRegistry.ISettings }) {
this.settings = options.settings;
Expand All @@ -76,6 +77,7 @@ export class QiskitCompletionProvider implements ICompletionProvider {

return autoComplete(text).then(results => {
this.prompt_id = results.prompt_id;
this.results = results.items;
return {
start: request.offset,
end: request.offset,
Expand All @@ -97,8 +99,8 @@ export class QiskitCompletionProvider implements ICompletionProvider {
return this.settings.composite['enableCompleter'] as boolean;
}

accept() {
if (this.prompt_id) {
accept(text: string) {
if (this.prompt_id && this.results.includes(text)) {
postModelPromptAccept(this.prompt_id);
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ const plugin: JupyterFrontEndPlugin<void> = {
category: 'Qiskit Code Assistant'
});

completionProviderManager.selected.connect((completer, selection) =>
provider.accept(selection.insertText)
);

app.commands.commandExecuted.connect((registry, executed) => {
if (
executed.id === CommandIDs.selectCompleterFile ||
executed.id === CommandIDs.selectCompleterNotebook
) {
provider.accept();
} else if (executed.id === CommandIDs.acceptInline) {
if (executed.id === CommandIDs.acceptInline) {
inlineProvider.accept();
}
});
Expand Down
Loading

0 comments on commit 84ceea3

Please sign in to comment.