Skip to content

Tommy/expand-list-discussions-tool #690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

tommaso-moro
Copy link
Contributor

@tommaso-moro tommaso-moro commented Jul 16, 2025

Addresses #670

Overview
This PR expands the functionality of the list_discussions tool. It adds

  • The updatedAt and author.login (i.e. username) fields to the discussions payload in the list_discussions tool
  • The ability to order discussions by field (updated_at and created_at) and direction (ascending order, descending order)

Refactoring
The PR includes extensive refactoring of the list_discussions tool to handle optional parameters in our graphql queries. This was needed because the githubv4 library requires GraphQL queries to be defined using Go struct tags that must be known at compile time, so we could not dynamically construct query strings at runtime based on user input.

The changes made include

  • Introduced reusable DiscussionFragment struct to avoid field duplication
  • Created 4 pre-defined query variants:
    • BasicNoOrder: No optional parameters (uses GitHub API's defaults)
    • BasicWithOrder: Only ordering parameters
    • WithCategoryNoOrder: Only category filtering
    • WithCategoryAndOrder: Both category and ordering
  • Added runtime query selection logic to choose the appropriate variant based on user input

Tests
I updated the tests in discussions_test.go to match the new queries, and to test the new ordering functionality with different sorting combinations.

Demo

Simple "list discussions" prompt

Screenshot 2025-07-17 at 17 37 47

 

Ordering: from most recently created to least recently created
Screenshot 2025-07-17 at 17 43 14

 

Ordering: from least recently updated to most recently updated
Screenshot 2025-07-17 at 17 44 05

 

Less explicit prompt: show me discussions from last 10 days
Screenshot 2025-07-17 at 17 47 09

 

Ordering with weaker model (GPT-4o)
Screenshot 2025-07-17 at 17 59 42


Note: this PR adds author data to the payload of the list_discussions tool but doesn't add support for filtering by author when listing discussions because that is not supported on the discussions field in the API, and it would need to be achieved in a separate search tool.

@tommaso-moro tommaso-moro marked this pull request as ready for review July 17, 2025 17:03
@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 17:03
@tommaso-moro tommaso-moro requested a review from a team as a code owner July 17, 2025 17:03
@tommaso-moro tommaso-moro requested a review from omgitsads July 17, 2025 17:03
Copy link
Contributor

@Copilot 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 enhances the list_discussions tool by adding ordering capabilities and expanding the discussion payload to include author information and updated timestamps. The changes enable users to sort discussions by creation or update date in ascending or descending order, while maintaining backward compatibility with existing functionality.

  • Added updatedAt and author.login fields to the discussion payload
  • Implemented ordering support with orderBy and direction parameters
  • Refactored GraphQL query handling to support optional parameters through pre-defined query variants

Reviewed Changes

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

File Description
pkg/github/discussions.go Added new query struct types, ordering logic, and GraphQL query selection based on parameters
pkg/github/discussions_test.go Updated test data and added comprehensive test cases for ordering functionality
README.md Updated documentation to reflect new ordering parameters

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.

1 participant