Skip to content

Commit 45eb239

Browse files
raifdmuellerclaude
andcommitted
feat: show discussion comments in anchor modal
- Fetch up to 10 recent comments per discussion (author, avatar, body, date) - Render comments above the Vote/Discuss buttons in the modal - Update feedback.json with comment content Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent def5fe8 commit 45eb239

4 files changed

Lines changed: 75 additions & 3 deletions

File tree

scripts/fetch-discussion-votes.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ function fetchAllDiscussions() {
3636
body
3737
url
3838
upvoteCount
39-
comments { totalCount }
39+
comments(first: 10) {
40+
totalCount
41+
nodes {
42+
author { login avatarUrl }
43+
body
44+
createdAt
45+
}
46+
}
4047
}
4148
pageInfo { hasNextPage endCursor }
4249
}
@@ -74,11 +81,22 @@ function main() {
7481
continue
7582
}
7683

77-
feedback[anchorId] = {
84+
const entry = {
7885
upvotes: d.upvoteCount,
7986
comments: d.comments.totalCount,
8087
url: d.url,
8188
}
89+
90+
if (d.comments.nodes && d.comments.nodes.length > 0) {
91+
entry.recentComments = d.comments.nodes.map((c) => ({
92+
author: c.author ? c.author.login : 'ghost',
93+
avatar: c.author ? c.author.avatarUrl : '',
94+
body: c.body,
95+
date: c.createdAt,
96+
}))
97+
}
98+
99+
feedback[anchorId] = entry
82100
mapped++
83101
}
84102

website/public/data/feedback.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22
"socratic-method": {
33
"upvotes": 2,
44
"comments": 1,
5-
"url": "https://github.com/LLM-Coding/Semantic-Anchors/discussions/291"
5+
"url": "https://github.com/LLM-Coding/Semantic-Anchors/discussions/291",
6+
"recentComments": [
7+
{
8+
"author": "rdmueller",
9+
"avatar": "https://avatars.githubusercontent.com/u/1856308?u=2c7443f52b575e8b3aefbc3007aea8b3cccac00f&v=4",
10+
"body": "works best for me to clarify requirements",
11+
"date": "2026-03-18T12:25:31Z"
12+
}
13+
]
614
},
715
"yagni": {
816
"upvotes": 1,

website/src/components/anchor-modal.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,30 @@ export async function loadAnchorContent(anchorId) {
277277
? fb.url
278278
: null
279279
if (safeFeedbackUrl) {
280+
const commentsHtml =
281+
fb.recentComments && fb.recentComments.length > 0
282+
? `
283+
<div class="feedback-comments">
284+
${fb.recentComments
285+
.map(
286+
(c) => `
287+
<div class="feedback-comment">
288+
<img src="${escapeHtml(c.avatar)}" alt="${escapeHtml(c.author)}" class="feedback-avatar" width="24" height="24" />
289+
<div class="feedback-comment-body">
290+
<span class="feedback-author">${escapeHtml(c.author)}</span>
291+
<p class="feedback-text">${escapeHtml(c.body)}</p>
292+
</div>
293+
</div>
294+
`
295+
)
296+
.join('')}
297+
</div>
298+
`
299+
: ''
300+
280301
const feedbackHtml = `
281302
<div class="feedback-section">
303+
${commentsHtml}
282304
<div class="feedback-actions">
283305
<a href="${escapeHtml(safeFeedbackUrl)}" target="_blank" rel="noopener noreferrer" class="feedback-btn feedback-btn-vote">
284306
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">

website/src/styles/main.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,30 @@ body {
196196
@apply dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700;
197197
}
198198

199+
.feedback-comments {
200+
@apply mb-4 space-y-3;
201+
}
202+
203+
.feedback-comment {
204+
@apply flex gap-3 items-start;
205+
}
206+
207+
.feedback-avatar {
208+
@apply rounded-full flex-shrink-0;
209+
}
210+
211+
.feedback-comment-body {
212+
@apply min-w-0;
213+
}
214+
215+
.feedback-author {
216+
@apply text-sm font-medium text-[var(--color-text)];
217+
}
218+
219+
.feedback-text {
220+
@apply text-sm text-[var(--color-text-secondary)] mt-0.5 mb-0;
221+
}
222+
199223
.feedback-hint {
200224
@apply mt-2 text-xs text-gray-400 dark:text-gray-500;
201225
}

0 commit comments

Comments
 (0)