chat: remove waitForReady (#277944)

* chat: remove `waitForReady`

- Now that edit sessions are sync, we don't need to wait for them (just
  guard edits) as in https://github.com/microsoft/vscode-copilot/issues/16060
- I noticed `widget.onDidClear()` listeners were actually async and we
  do need to wait for them before we can safely make new input. Revised
  this to a delegate pattern.
- Wait for a view model when sending chat. Also, improved Event.toPromise
  so it can safely be reused -- it now cleans up its own disposable from
  the disposable store or array after it settles.

Resolves #247484

* Update src/vs/base/common/event.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Connor Peet
2025-11-17 14:55:36 -08:00
committed by GitHub
parent c0c75f1968
commit 798ef59100
17 changed files with 284 additions and 188 deletions

View File

@@ -257,14 +257,14 @@ export class InlineChatController1 implements IEditorContribution {
location.location = ChatAgentLocation.Notebook;
}
const zone = _instaService.createInstance(InlineChatZoneWidget, location, undefined, { editor: this._editor, notebookEditor });
this._store.add(zone);
this._store.add(zone.widget.chatWidget.onDidClear(async () => {
const clear = async () => {
const r = this.joinCurrentRun();
this.cancelSession();
await r;
this.run();
}));
};
const zone = _instaService.createInstance(InlineChatZoneWidget, location, undefined, { editor: this._editor, notebookEditor }, clear);
this._store.add(zone);
return zone;
});
@@ -1332,6 +1332,7 @@ export class InlineChatController2 implements IEditorContribution {
defaultMode: ChatMode.Ask
},
{ editor: this._editor, notebookEditor },
() => Promise.resolve(),
);
result.domNode.classList.add('inline-chat-2');