Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

Description

Failed fetch requests (404s, redirects) lack visual indication in the UI. Users must read the expanded content to discover errors.

Changes:

  • Tool metadata plumbing: Extended IChatToolInvocation with optional toolMetadata field. Flows through ChatToolInvocation class with serialization support.

  • Fetch tool error detection: FetchWebPageTool now sets { hasError: true } metadata when WebContentExtractResult status is error or redirect. Defined IFetchWebPageToolMetadata interface for type safety.

  • UI rendering: ChatCollapsibleContentPart accepts optional statusIcon (ThemeIcon). When present, renders inline with warning color. ChatToolInvocationPart checks metadata and passes Codicon.warning to ChatResultListSubPartChatCollapsibleListContentPart.

  • Test coverage: Added test verifying metadata correctly set for error/redirect/success/mixed scenarios.

Example:

// In fetchPageTool.ts
const hasError = webContents.some(e => e.status === 'error' || e.status === 'redirect');
return {
  content: this._getPromptPartsForResults(results),
  toolResultDetails: actuallyValidUris,
  toolMetadata: { hasError }
};

// In chatToolInvocationPart.ts
const metadata = this.toolInvocation.toolMetadata;
const hasError = metadata?.hasError === true;
// Passes warning icon to UI component when hasError is true

Fixes the issue where failed fetches appeared identical to successful ones in collapsed state.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fetch tool should better indicate in UI when the request fails</issue_title>
<issue_description>1. Ask the fetch tool to make a request that fails with a 404, such as fetch the contents of http://microsoft.com/no-such-link

Bug
Looking at the UI, it's not very clear that this request failed

Image

I'd expect some kind of warning/error icon</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 6, 2025 23:41
- Modified ChatCollapsibleContentPart to accept optional status icon parameter
- Updated ChatCollapsibleListContentPart and ChatUsedReferencesListContentPart to pass through status icon
- Added toolMetadata field to IChatToolInvocation and IChatToolInvocationSerialized interfaces
- Modified FetchWebPageTool to detect errors/redirects and store hasError in toolMetadata
- Updated ChatToolInvocationPart to check for error metadata and pass to ChatResultListSubPart
- Updated ChatResultListSubPart to accept hasError parameter and pass warning icon to collapsible list
- Added CSS styling for chat-used-context-status-icon with warning color
- Updated all instantiation sites to pass statusIcon parameter

Co-authored-by: dmitrivMS <[email protected]>
- Created TestWebContentExtractorServiceWithErrors class to test error and redirect scenarios
- Added test case "should set hasError metadata when web content extraction fails or redirects"
- Verified metadata is correctly set to true for error/redirect statuses
- Verified metadata is correctly set to false for successful fetches
- Verified metadata is correctly set to true when mix of success and errors

Co-authored-by: dmitrivMS <[email protected]>
- Defined IFetchWebPageToolMetadata interface with hasError property
- Updated fetchPageTool to use the new interface for metadata
- Improved type checking in chatToolInvocationPart to properly handle metadata
- Added comments explaining the tool-specific metadata structure
- Addressed code review feedback on type casting and robustness

Co-authored-by: dmitrivMS <[email protected]>
Copilot AI changed the title [WIP] Improve UI indication for fetch request failures Add warning icon for failed fetch tool requests Nov 6, 2025
Copilot AI requested a review from dmitrivMS November 6, 2025 23:53
Copilot finished work on behalf of dmitrivMS November 6, 2025 23:53
@TylerLeonhardt TylerLeonhardt added the ~copilot-video-please ⚠️WIP🏗️ Use in PRs. Runs Copilot CLI agent to record a video of "trying out the change" label Nov 7, 2025
@vs-code-engineering vs-code-engineering bot removed the ~copilot-video-please ⚠️WIP🏗️ Use in PRs. Runs Copilot CLI agent to record a video of "trying out the change" label Nov 7, 2025
@vs-code-engineering
Copy link

🤖 Copilot has tried out this change! Members of the team can view the recording here or download the Playwright trace here (run)

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.

Fetch tool should better indicate in UI when the request fails

3 participants