Add state metadata fields to get_discussion tool #1305
+141
−100
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.
Fixes #1303
Problem
The
get_discussiontool was missing important state metadata fields that are already available in theget_issuetool, making it difficult to determine discussion status.Solution
Added four state metadata fields to the
get_discussiontool:state- Discussion state (OPEN, CLOSED, etc.)isAnswered- Whether the discussion has an accepted answeransweredAt- Timestamp when the answer was provided (optional)answerChosenAt- Timestamp when the answer was selected (optional)Implementation
Modified
GetDiscussionto return these fields using amap[string]interface{}response instead of thegithub.Discussionstruct, since go-github v74'sDiscussiontype doesn't include theisAnsweredandansweredAtfields.This approach is consistent with existing functions in this codebase:
ListDiscussionsuses map response (discussions.go:244)GetDiscussionCommentsuses map response (discussions.go:448)All discussion-related tools now follow the same pattern due to GraphQL API limitations in the go-github library.
Changes
NodeFragmentstruct with new fieldsGetDiscussionGraphQL query to fetch state metadataTesting
All tests pass with updated snapshots. Linter reports no issues. Verified backward compatibility with existing
discussion functions.