Skip to content

Commit e431e9d

Browse files
committed
pass IMagicContext to the magic method
1 parent 56c2fce commit e431e9d

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

src/celltracker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,11 @@ export class AICellTracker implements IAICellTracker {
355355

356356
const codeInput = cell?.model?.sharedModel.getSource() ?? '';
357357
const content = currentNotebook?.content.model?.toJSON();
358-
await this._magicProvider.magic(cellId, codeInput, content);
358+
await this._magicProvider.magic({
359+
cellId,
360+
codeInput,
361+
content
362+
});
359363

360364
this._commandRegistry.notifyCommandChanged(this.commandId);
361365
}

src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { IEventListener } from 'jupyterlab-eventlistener';
1818
import { ICellFooterTracker } from 'jupyterlab-cell-input-footer';
1919
import { requestAPI } from './handler';
2020
import { IMagicProvider } from './provider';
21-
import { PartialJSONValue } from '@lumino/coreutils';
2221

2322
const PLUGIN_ID = 'jupyterlab_magic_wand';
2423

@@ -138,11 +137,11 @@ const magicProviderPlugin: JupyterFrontEndPlugin<IMagicProvider> = {
138137
provides: IMagicProvider,
139138
activate: async app => {
140139
return {
141-
magic: async (
142-
cellId: string,
143-
codeInput: string,
144-
content: PartialJSONValue | undefined
145-
) => {
140+
magic: async ({
141+
codeInput,
142+
content,
143+
cellId
144+
}: IMagicProvider.IMagicContext) => {
146145
// Make the request.
147146
requestAPI('/api/ai/magic', {
148147
method: 'POST',

src/provider.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ export const IMagicProvider = new Token<IMagicProvider>(
55
);
66

77
export interface IMagicProvider {
8-
magic(
9-
cellId: string,
10-
codeInput: string,
11-
content: PartialJSONValue | undefined
12-
): Promise<void>;
8+
magic(context: IMagicProvider.IMagicContext): Promise<void>;
9+
}
10+
11+
export namespace IMagicProvider {
12+
export interface IMagicContext {
13+
cellId: string;
14+
codeInput: string;
15+
content: PartialJSONValue | undefined;
16+
}
1317
}

0 commit comments

Comments
 (0)