Skip to content

[dotnet-code] Refactor Copilot session event dispatch#393

Merged
gdams merged 2 commits into
mainfrom
dotnet-code/copilot-event-dispatch-f1beb03e90e4da0a
Jun 30, 2026
Merged

[dotnet-code] Refactor Copilot session event dispatch#393
gdams merged 2 commits into
mainfrom
dotnet-code/copilot-event-dispatch-f1beb03e90e4da0a

Conversation

@michelle-clayton-work

Copy link
Copy Markdown
Contributor

This pull request refactors how session events are handled in the copilotagent provider by extracting the event-to-update logic into a new helper method. This makes the code easier to maintain and read by reducing the complexity of the main run loop.

Refactoring and Code Organization:

  • Extracted the switch-case logic for handling different copilot.SessionEvent types from the main run method into a new helper method responseUpdateForSessionEvent, which returns the appropriate ResponseUpdate, a done flag, and an error if present. [1] [2]
  • Simplified the run method by replacing the inline switch-case with a single call to responseUpdateForSessionEvent.

This change improves code readability and makes it easier to add or modify session event handling in the future.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 29, 2026 21:46
@michelle-clayton-work
michelle-clayton-work requested a review from a team as a code owner June 29, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors Copilot session event handling in copilotagent by extracting the event-to-ResponseUpdate conversion logic into a dedicated helper, keeping the run loop focused on queueing/yielding updates and termination/error handling.

Changes:

  • Extracted the session event switch from run into responseUpdateForSessionEvent.
  • Standardized event dispatch to return (update, done, err) for simpler control flow in the main loop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown
Contributor

Cross-Repo Consistency Review — No Parity Issues

This PR is an internal refactor only. The change extracts the switch-case session-event dispatch logic into a new unexported helper method responseUpdateForSessionEvent; the calling method run is also unexported.

No exported Go APIs, option types, or observable runtime behavior were changed. This refactoring is equivalent to moving private implementation details in .NET or Python, which carries no cross-SDK parity concern.

✅ No cross-repo consistency issues to report.

Generated by Go API Consistency Review Agent for #393 · 29.8 AIC · ⌖ 12.7 AIC · ⊞ 28.8K ·

@gdams
gdams added this pull request to the merge queue Jun 30, 2026
@gdams gdams linked an issue Jun 30, 2026 that may be closed by this pull request
Merged via the queue into main with commit f70545e Jun 30, 2026
19 checks passed
@gdams
gdams deleted the dotnet-code/copilot-event-dispatch-f1beb03e90e4da0a branch June 30, 2026 07:31
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.

[dotnet-code] Refactor Copilot session event dispatch

3 participants