Skip to content

chat: remove waitForReady#277944

Merged
connor4312 merged 2 commits intomainfrom
connor4312/rm-chat-waitforready
Nov 17, 2025
Merged

chat: remove waitForReady#277944
connor4312 merged 2 commits intomainfrom
connor4312/rm-chat-waitforready

Conversation

@connor4312
Copy link
Member

@connor4312 connor4312 commented Nov 17, 2025

  • 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
Refs #277318

- Now that edit sessions are sync, we don't need to wait for them (just
  guard edits) as in microsoft/vscode-copilot#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
@connor4312 connor4312 enabled auto-merge (squash) November 17, 2025 21:36
@connor4312 connor4312 self-assigned this Nov 17, 2025
@vs-code-engineering
Copy link

vs-code-engineering bot commented Nov 17, 2025

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@jrieken

Matched files:

  • src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.ts
  • src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts
  • src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.ts

@bpasero

Matched files:

  • src/vs/workbench/contrib/chat/browser/chatSetup.ts
  • src/vs/workbench/contrib/chat/browser/chatWidget.ts

@lszomoru

Matched files:

  • src/vs/workbench/contrib/scm/browser/scmHistoryChatContext.ts


if (!opts.isPartialQuery) {
await chatWidget.waitForReady();
if (!chatWidget.viewModel) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the case where we do need to wait still, because we might change agents I believe

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the waitForReady() method from chat widgets now that edit sessions are synchronous. The key changes include:

  • Replaced the event-based onDidClear() pattern with a delegate-based approach for better async handling
  • Added view model waiting logic directly in acceptInput() instead of relying on external waitForReady() calls
  • Enhanced Event.toPromise to properly clean up disposables after settling, preventing resource leaks

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
chatWidget.ts Removed waitForReady() and onDidClear event; made clear() async and added view model waiting in acceptInput()
chat.ts Updated IChatWidget interface to remove waitForReady() and add clear delegate option
event.ts Enhanced Event.toPromise to clean up disposables from stores/arrays after resolution or cancellation
event.test.ts Added comprehensive tests for improved Event.toPromise cleanup behavior
chatViewPane.ts Migrated from onDidClear listener to clear delegate
chatQuick.ts Migrated from onDidClear listener to clear delegate
chatEditor.ts Migrated from onDidClear listener to clear delegate
inlineChatZoneWidget.ts Added clearDelegate parameter to support delegate pattern
inlineChatController.ts Refactored to pass clear logic as delegate instead of event listener
chatNewActions.ts Replaced clear() + waitForReady() with single await clear() call
chatMoveActions.ts Replaced clear() + waitForReady() with single await clear() call
chatExecuteActions.ts Replaced clear() + waitForReady() with single await clear() call
chatActions.ts Replaced waitForReady() with direct view model waiting; made clear operations properly await
chat.contribution.ts Removed unused waitForReady() call and IViewsService import
scmHistoryChatContext.ts Removed waitForReady() call before adding attachment
chatSetup.ts Made clear() call async
chatEditingSession.ts Added chatEditingSessionIsReady calls to guard edits as mentioned in PR description

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@connor4312 connor4312 mentioned this pull request Nov 17, 2025
21 tasks
@connor4312 connor4312 merged commit 798ef59 into main Nov 17, 2025
38 of 39 checks passed
@connor4312 connor4312 deleted the connor4312/rm-chat-waitforready branch November 17, 2025 22:55
pwang347 pushed a commit that referenced this pull request Nov 18, 2025
* chat: remove `waitForReady`

- Now that edit sessions are sync, we don't need to wait for them (just
  guard edits) as in microsoft/vscode-copilot#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>
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debt- clean up async ChatModel/IChatEditingSession initialization

3 participants