Skip to content

Conversation

@marc-romu
Copy link
Member

@marc-romu marc-romu commented Oct 11, 2025

Description

Fixed an issue in the AIListFilter component where it was incorrectly looking for an indices key in the tool result when the actual response contains a result key. This was causing the component to return empty results even when the AI successfully identified matching indices.

Changes Made

  • Updated AIListFilter.cs to read from toolResult["result"] instead of toolResult["indices"]
  • Added better error handling and debug logging
  • Updated CHANGELOG.md to document the fix

Testing Done

  • Verified that the component correctly filters and returns items when using text-based criteria
  • Tested with various list filtering scenarios to ensure proper functionality
  • Confirmed that the debug logs now show the correct indices being processed

Breaking Changes

  • None. This is a bug fix that maintains backward compatibility.

Checklist

  • This PR is focused on a single feature or bug fix
  • Version in Solution.props was updated, if necessary, and follows semantic versioning
  • CHANGELOG.md has been updated
  • PR title follows Conventional Commits format
  • PR description follows Pull Request Description Template

Copilot AI review requested due to automatic review settings October 11, 2025 13:03
@github-actions github-actions bot added this to the 1.0.0-alpha milestone Oct 11, 2025
@github-actions
Copy link
Contributor

🏷️ This PR has been automatically assigned to milestone 1.0.0-alpha based on the version in Solution.props.

@marc-romu marc-romu added the component: AI ListFilter Issues related to the AI List Filter component label Oct 11, 2025
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 fixes a bug in the AIListFilter component where it was incorrectly looking for an indices key in the tool result when the actual response contains a result key. Additionally, it significantly enhances the parsing capabilities of the ParsingTools utility.

  • Fixed the key name from indices to result in AIListFilter component
  • Enhanced ParsingTools with comprehensive index parsing support for various formats
  • Added CHANGELOG entry documenting the fix

Reviewed Changes

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

File Description
src/SmartHopper.Components/List/AIListFilter.cs Fixed the key name from "indices" to "result" when parsing tool results
src/SmartHopper.Core.Grasshopper/Utils/ParsingTools.cs Significantly expanded index parsing capabilities with support for JSON arrays, objects, ranges, and various text formats
CHANGELOG.md Added entry documenting the AIListFilter bug fix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

/// </summary>
private static string ExtractFromMarkdownCodeBlock(string text)
{
var match = System.Text.RegularExpressions.Regex.Match(text, @"```(?:json|txt|text)?\s*\n?(.*?)\n?```", System.Text.RegularExpressions.RegexOptions.Singleline);
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

Consider caching this regex pattern as a static readonly field to avoid recompiling the pattern on every method call.

Copilot uses AI. Check for mistakes.
/// </summary>
private static string ExtractFirstBracketedArray(string text)
{
var match = System.Text.RegularExpressions.Regex.Match(text, @"\[([^\[\]]*)\]");
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

Consider caching this regex pattern as a static readonly field to avoid recompiling the pattern on every method call.

Copilot uses AI. Check for mistakes.
Comment on lines 273 to 275
private static string ExpandRanges(string text)
{
var result = System.Text.RegularExpressions.Regex.Replace(text, @"(\d+)(?:-|\.\.)(\d+)", match =>
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

Consider caching this regex pattern as a static readonly field to avoid recompiling the pattern on every method call.

Suggested change
private static string ExpandRanges(string text)
{
var result = System.Text.RegularExpressions.Regex.Replace(text, @"(\d+)(?:-|\.\.)(\d+)", match =>
private static readonly System.Text.RegularExpressions.Regex RangeRegex =
new System.Text.RegularExpressions.Regex(@"(\d+)(?:-|\.\.)(\d+)", System.Text.RegularExpressions.RegexOptions.Compiled);
private static string ExpandRanges(string text)
{
var result = RangeRegex.Replace(text, match =>

Copilot uses AI. Check for mistakes.
trimmed = ExpandRanges(trimmed);

// 6. Extract all numbers from comma/space/newline-separated text
var parts = System.Text.RegularExpressions.Regex.Split(trimmed, @"[,\s\n\r]+");
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

Consider caching this regex pattern as a static readonly field to avoid recompiling the pattern on every method call.

Copilot uses AI. Check for mistakes.
@marc-romu marc-romu merged commit 4d0799f into dev Oct 11, 2025
9 checks passed
@github-actions github-actions bot deleted the bugfix/1.0.0-fix-list-components branch October 11, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: AI ListFilter Issues related to the AI List Filter component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants