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

Trigger Completion Generation On Cell Execution #1775

Merged
merged 2 commits into from
Nov 1, 2024

Conversation

jlewi
Copy link
Contributor

@jlewi jlewi commented Oct 30, 2024

Trigger Completion Generation On Cell Execution

This PR hooks into the runner code execution path to trigger completion generation when a cell finishes execution.
This works for both interactive and non-interactive cells.

This reverts the approach taken in #1744 of intercepting the OnDocumentChangeEvent and goes with the alternative approach of triggering events from _doExecuteCell. We use the event reporter which is already reporting executions to Foyle to also trigger completions.

The problem with relying on vscode DocumentChangeEvents is that it only works for non-interactive cells. For interactive cells, Runme uses a custom renderer to show an xterm.js widget for the terminal. As a result, we don't trigger vscode DocumentChangeEvents when the outputs get updated.

The approach of using doExecuteCell to trigger completions works for both interactive and non-interactive cells. Previously, the outputs for interactive cells wasn't included was due to a bug fixed in #1756.

In the current PR, completions are only generated when a cell completes execution. This means for long running commands (e.g. kubectl get pods -w) we wouldn't periodically generate completions as the output changes. I think that's a bit of an edge case that we don't need to support yet. The current approach should extend well to that use case because we are using the event reporter to trigger completions and @sourishkrout recently added an RXJS queue inside event reporter. So we are well setup to enqueuing updates on the client and debouncing them.

Other Fixes

Include the CELL_TRIGGER enum in Foyle completion requests. I think I dropped when resolving some of the merge conflicts.

Fix jlewi/foyle#309

@jlewi jlewi marked this pull request as ready for review October 30, 2024 14:34
@jlewi
Copy link
Contributor Author

jlewi commented Oct 30, 2024

@sourishkrout This is ready for review.

Copy link
Member

@sourishkrout sourishkrout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM

@sourishkrout sourishkrout merged commit 2bffd9d into main Nov 1, 2024
1 check passed
@sourishkrout sourishkrout deleted the jlewi/triggeronexec branch November 1, 2024 15:45
hotpocket pushed a commit to hotpocket/vscode-runme that referenced this pull request Nov 5, 2024
* * Intercept the execution path and use that to trigger completions
* jlewi/foyle#309

* Cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trigger Foyle Ghost Cell Updates When Cell Output Changes / Cell Is Executed
2 participants