feat(activity): add GitHub Discussions to RecentActivity#1939
Merged
Priyanshu-byte-coder merged 2 commits intoJun 3, 2026
Merged
Conversation
…iyanshu-byte-coder#1748) Root cause (confirmed) ---------------------- The initial migration created local_coding_api_keys with a single column api_key to store SHA-256 hashes. A later migration added api_key_hash as a nullable column. At the time issue Priyanshu-byte-coder#1748 was filed, the code was split: Creation → insert({ api_key: hash }) # only api_key written Auth → .eq("api_key_hash", hash) # only api_key_hash read Every key generated through the UI was therefore permanently invalid; authentication always returned "Invalid API key". Applied fix (in place on main branch) -------------------------------------- Key creation now writes the same SHA-256 hash to BOTH columns: insert({ api_key: hash, api_key_hash: hash }) Authentication queries BOTH columns with an OR filter so that pre-existing rows (with only api_key populated) and newly created rows (with both populated) authenticate identically: .or("api_key_hash.eq.<hash>,api_key.eq.<hash>") This preserves backward compatibility with any deployment that had keys created before the api_key_hash column existed. Regression test suite — test/local-coding-auth-regression.test.ts (9 tests) ----------------------------------------------------------------------------- Tests added in this commit provide explicit coverage that was absent: * Key creation writes hash to api_key AND api_key_hash. * POST /local-coding/sync uses OR filter across both columns. * Legacy row (api_key only, api_key_hash NULL) still authenticates. * Invalid key is rejected by both POST and GET sync handlers. * GET /local-coding/sync was previously untested; 4 tests now cover: - missing Authorization header → 401 - invalid key → 401 - valid key → 200 with session data - same OR filter used as POST * Hash function consistency: verifies the hash written during creation would satisfy the filter used during authentication. The pre-existing tests in test/local-coding-keys.test.ts and test/local-coding-sync.test.ts continue to pass unchanged. Closes Priyanshu-byte-coder#1748
Add parallel GraphQL fetch alongside the REST events endpoint to reliably surface discussion-comment activity in RecentActivity. - activity-formatter.ts: GraphQLDiscussionCommentNode interface, formatGraphQLDiscussionComment() normalizer, mergeActivityItems() dedup+sort helper - metrics/activity/route.ts: DISCUSSION_COMMENTS_QUERY via viewer.repositoryDiscussionComments(first:20); fetchDiscussionItems ViaGraphQL() silently returns [] on error; both fetchFormatted Activity() and the public-events fallback path run REST + GraphQL in parallel via Promise.all - test/activity-formatter.test.ts: 15 new tests for formatGraphQLDiscussionComment and mergeActivityItems
|
@Ridanshi is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
e493687
into
Priyanshu-byte-coder:main
10 of 11 checks passed
|
🎉 Merged! Thanks for contributing to DevTrack. If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers. Keep an eye on open issues for your next contribution! |
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.
Closes #1913
Implementation summary
The GitHub REST
/user/eventsendpoint does not reliably surfaceDiscussionEventandDiscussionCommentEvententries — they are absent from the events feed for many users even when they have active discussion participation. This PR adds a parallel GraphQL query to fill that gap without replacing the existing REST event flow.GraphQL integration details
A new
DISCUSSION_COMMENTS_QUERYtargetsviewer.repositoryDiscussionComments(first: 20), the most reliable GitHub GraphQL field for this purpose. The query returns the 20 most recent discussion comments the authenticated user has made across all repositories, each withcreatedAt, commenturl, and the parent discussion'stitle,number,url, andrepository.nameWithOwner.fetchDiscussionItemsViaGraphQL(token)wraps the call and always resolves — any error (rate limit, missing scope, disabled discussions) silently returns[]so discussion activity is never a hard dependency of the feed.The GraphQL fetch runs in parallel with the REST events fetch via
Promise.allin bothfetchFormattedActivity()and thefetchPublicEventsfallback path.Activity normalization changes
src/lib/activity-formatter.tsadditions:GraphQLDiscussionCommentNode— typed shape for a single GraphQL response nodeformatGraphQLDiscussionComment(node)— normalizes a GraphQL node into the sharedActivityItemformat; setstype: "discussion", builds the title asCommented on discussion #N, and links to the discussion URL (not the comment anchor)mergeActivityItems(restItems, discussionItems)— deduplicates bytype-repo-createdAt-titlekey and returns a newest-first sorted arraysrc/app/api/metrics/activity/route.tschanges:githubGraphQLfrom@/lib/github-fetchDISCUSSION_COMMENTS_QUERY,DiscussionCommentsQueryResult,fetchDiscussionItemsViaGraphQLfetchFormattedActivityand the fallback path usemergeActivityItemsto combine REST and GraphQL resultsUI updates
None required.
RecentActivity.tsxalready renders the"discussion"type with a chat-bubble SVG icon and a "Discussion" badge — the existing code handles discussion items from both REST and GraphQL sources identically.Tests added
test/activity-formatter.test.ts— 15 new tests (33 total):formatGraphQLDiscussionComment:"discussion"repository.nameWithOwner"gql-disc"and the comment URLmergeActivityItems:Verification