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

Inline chat for direct single edit application #190239

Open
marrej opened this issue Aug 11, 2023 · 6 comments
Open

Inline chat for direct single edit application #190239

marrej opened this issue Aug 11, 2023 · 6 comments
Assignees
Labels
inline-chat under-discussion Issue is under discussion for relevance, priority, approach

Comments

@marrej
Copy link
Contributor

marrej commented Aug 11, 2023

Utilizing the Inline chat as means for showing edits.

TLDR; The Inline chat could be cheaply extended to provide In editor edits. (PR #190258 )

image

Intro

At the moment the experimental inline chat, provides very interesting way how to display edits that are restricted to a single file (TextEdits). And assuming that this API is something that the extension authors are interested in (e.g. see #85682 ) might provide a great addition to the extension author toolbelt.

The main benefits being (compared to Refactor Preview), that for small edits/single file edits:

  • the user focus is not broken by providing unnecessarily big context
  • suggested edits are editable
  • Reduces the amount of clicks the user needs, to view edits

At the same time, I realise that the Inline chat purpose is to Chat, but at the moment it seems that the edit preview logic is fused with the internals of the chat and can not be easily extracted.

Proposal

Extend the existing inlineChat.start (or introduce a new command e.g. inlineChat.showEdit) which would allow to take in edits: vscode.TextEdit[] (or vscode.WorkspaceEdit, and add additional checks in the inlineChat). The edits would be added to the options (which are passed to the InlineChatController), and would modify the state flow a bit.
After INIT_UI, break the _nextState and Attach the edit as a new response, then continue the _nextState with APPLY_EDIT
If edits are provided in the options, then hide parts of the toolbar (the conversational pieces), and keep only the actions.

Done in PR #190258

Additional nice to have

  • Allow to accept/reject the edit via command/api invocation from extension (only for the extension provided provider)
  • Ability to add Markdown info text inside the Action bar (e.g. to provide some helpful hint for the edit)
  • Ability to explicitly select visualisation mode (inline/side-by-side)

VS Code version: 1.81.1
OS version: ChromeOS 114.0.5735.239

@marrej marrej changed the title Inline chat - Single edit mode Inline chat for direct single edit application Aug 11, 2023
@hediet hediet assigned jrieken and unassigned hediet Aug 11, 2023
@jrieken jrieken added under-discussion Issue is under discussion for relevance, priority, approach inline-chat labels Aug 16, 2023
@luhc228
Copy link

luhc228 commented Nov 1, 2023

Will this PR merge in the future?

@marrej
Copy link
Contributor Author

marrej commented Nov 6, 2023

happy to update the PR to the latest version if @jrieken will agree to have it enabled.
Although lets note that this is not the clean way how this should be done.
Rather the functionality should be exposed via a dedicated API and best have the Inline diff totally separated (as a whole new Core Component).

That being said, the dedicated API could be added easily, with the provider being registered automatically for extensionHost (While allowing only the mentioned command to be called) as intermediate step, allowing then to switch the functionality in the background of the API to a separate inline Diff with edit panel.

(Happy to add that in if agreed :))

@jimmy-zhening-luo
Copy link

  1. Nice proposal, would love to see a dedicated API for inline edits and the nice code editing interface sugar that it would enable.

  2. Is this at all related to the editor.experimentalInlineEdit.enabled setting that I've seen recently? The reason I ask is because a bunch of conflicting System Keyboard Shortcuts (e.g. Ctrl + Space) for this experimental feature were silently added to my user settings during some update, quite annoying. I wouldn't be asking if I could find any public release notes on this experimental feature. Would love if someone from MS could explain what experimentalInlineEdit is and possibly respond to @marrej .

{
  // Controls whether to show inline edits in the editor.
  "editor.experimentalInlineEdit.enabled": false,
}

@jrieken
Copy link
Member

jrieken commented Aug 8, 2024

Is this at all related to the editor.experimentalInlineEdit.enabled setting that I've seen recently?

No

@sameemqiitm
Copy link

Any workarounds/examples how to implement this???

@qiyx2019
Copy link

easily

how to use inline-chat in my vscode-ext?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inline-chat under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

8 participants