Improve Copilot Cloud Sessions error handling and messaging#325196
Draft
osortega wants to merge 1 commit into
Draft
Improve Copilot Cloud Sessions error handling and messaging#325196osortega wants to merge 1 commit into
osortega wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves error handling and messaging for the Copilot Cloud Sessions (Task API v2) feature. Previously, a task that terminally failed while its latest session state stayed in_progress/queued (e.g. "Failed to launch agent") would render a perpetual "Session is in progress…" spinner and cause the live streamer to poll forever. The change keys "is the task still running?" off the task-level state and surfaces a unified Copilot stopped: <reason> notice, where the reason is a concrete error detail when available, otherwise a state-derived word ("cancelled" / "timed out" / "an error occurred").
Changes:
- Adds shared
isActiveTaskState/isFailedTaskStatehelpers as the single source of truth for task-lifecycle state, replacing the localACTIVE_STATESset in the streamer. - Introduces
extractTaskErrorDetailandformatTaskStoppedMessage, and wires a terminal-stop notice into both the history builder and the liveTaskTurnStreamer(withrenderedErrorde-duplication). - Gates
activeResponseCallbackon the task-level active state so terminally-failed tasks don't stream/poll forever; updates and expands tests.
Show a summary per file
| File | Description |
|---|---|
extensions/copilot/src/extension/chatSessions/vscode/copilotCodingAgentUtils.ts |
Adds isActiveTaskState/isFailedTaskState shared helpers for task-state classification. |
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCloudSessionContentBuilder.ts |
Adds extractTaskErrorDetail/formatTaskStoppedMessage; renders a stop notice instead of a stuck spinner in history. |
extensions/copilot/src/extension/chatSessions/vscode-node/taskTurnStreamer.ts |
Settles the live stream on terminal task state and emits the stop notice; tracks renderedError to avoid duplicate detail. |
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts |
Gates the active-response streaming callback on isActiveTaskState(task.state). |
extensions/copilot/src/extension/chatSessions/vscode-node/test/copilotCloudSessionsProvider.spec.ts |
Adds/updates tests for the new stopped-notice behavior and helper functions. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Medium
Comment on lines
+294
to
+304
| // Only the latest turn can still be in-progress. When the task itself terminally | ||
| // failed, surface a failure notice (with any available error detail) instead of a | ||
| // stuck progress spinner — the latest session state can still read as active (e.g. | ||
| // "Failed to launch agent"). Detail is extracted from the full event list because a | ||
| // bootstrap `session.error` is suppressed from the rendered turns above. | ||
| // Only the latest turn can still be in-progress. When the task terminally stopped, | ||
| // surface a "Copilot stopped: <reason>" notice instead of a stuck progress spinner — | ||
| // the latest session state can still read as active (e.g. "Failed to launch agent" | ||
| // or a cancelled turn). Detail is extracted from the full event list because a | ||
| // bootstrap `session.error` is suppressed from the rendered turns above; a cancelled | ||
| // or timed-out task emits no error event, so the reason falls back to the task state. |
Comment on lines
+20
to
+31
| switch (state) { | ||
| case 'queued': | ||
| case 'in_progress': | ||
| case 'idle': | ||
| case 'waiting_for_user': | ||
| return true; | ||
| case 'completed': | ||
| case 'failed': | ||
| case 'timed_out': | ||
| case 'cancelled': | ||
| return false; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request enhances the error handling and messaging for the Copilot Cloud Sessions feature, specifically addressing how task states are communicated to users.
Changes Made:
Copilot stopped: <reason>, where<reason>is derived from the task state (e.g., "cancelled", "timed out", or specific error details).formatTaskStoppedMessagefunction to reflect the new messaging format.extractTaskErrorDetailfunction, removing unnecessary parameters and logs.Rationale:
These changes improve user experience by providing clearer and more accurate feedback regarding task states, particularly distinguishing between cancellation and failure. The logging cleanup also enhances maintainability by reducing noise in the logs. All tests have been updated and pass successfully, ensuring the reliability of the new implementation.