-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add interruptPrompt()
method
#803
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, but could we make it simpler by just clearing inputRequests_
whenever an interrupt happens? (seems like no input request can/should survive an interrupt)
extensions/positron-r/src/runtime.ts
Outdated
@@ -76,6 +76,14 @@ export class RRuntime implements positron.LanguageRuntime, vscode.Disposable { | |||
this._kernel.replyToPrompt(id, reply); | |||
} | |||
|
|||
async interruptPrompt(id: string): Promise<void> { | |||
if (this._kernel.interruptPrompt) { | |||
await this._kernel.interruptPrompt!(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, here and elsewhere -- the !
assertion shouldn't be necessary inside an if block that tests to ensure the method exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I was expecting too but the LSP (or was it ESlint?) didn't seem to agree.
src/positron-dts/positron.d.ts
Outdated
@@ -442,6 +442,11 @@ declare module 'positron' { | |||
/** Reply to a prompt issued by the runtime */ | |||
replyToPrompt(id: string, reply: string): void; | |||
|
|||
/** Interrupt a prompt issued by the runtime. If not implemented, | |||
* `interrupt()` is called instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: spacing, the *
should be on the same line as the leading *
on the previous line for the comment documentation parser to work correctly
hmm... I thought this layer was responsible for multiple kernels but looking more closely that's not the case. Since there can only be one active input request at a time IIUC, do we need that |
abf3d16
to
aca1af1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels right, and yes, I think since we have only one input request at a time there isn't any need for a map. Thanks!
aca1af1
to
ee08ac0
Compare
Related to #535.
Interrupting a prompt request from the backend requires updating some state in JupyterKernel. To support this, a new
interruptPrompt()
is added to theLanguageRuntime
interface.This new method is optional. If not implemented,
interrupt()
is called just as before.