feat(ui): differentiate issues and PRs in similar threads#75
feat(ui): differentiate issues and PRs in similar threads#75Kavirubc merged 2 commits intosimiligh:mainfrom
Conversation
📝 WalkthroughWalkthroughThe pull request adds visual differentiation between Issues and Pull Requests in similarity search results by introducing a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Mahsum Aktas <mahsum@mahsumaktas.com>
4d53518 to
71e3ec5
Compare
Kavirubc
left a comment
There was a problem hiding this comment.
Clean, well-scoped implementation. The three-layer change (struct → similarity step → response builder) is exactly right, and the defensive defaulting in normalizeSimilarThreadType() means no regressions for existing Qdrant payloads that lack a type field.
Two minor nits, neither blocking:
- The
"pull_request"and"pull request"cases insimilarThreadTypeIcon()are unreachable in practice sincenormalizeSimilarThreadType()always normalizes to"pr"before the icon function sees the value. Safe to simplify that switch to justcase "pr":if you want, or leave it as a defensive belt-and-suspenders — either is fine. - If more thread types (e.g.
"discussion") are added later, both switch blocks will need updating in sync. Worth a comment linking them or extracting a shared type constant at that point.
All CI green, tests cover the happy path, PR type, and missing type. Approving.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
internal/steps/similarity_test.go (1)
5-27: Good coverage — consider adding an uppercase PR variant.All documented variants and the default are exercised. One minor gap: while
"ISSUE"verifies case-folding for thedefaultbranch, there is no equivalent test (e.g."PR"or"PULL_REQUEST") verifying that the"pr"branch is also case-folded. Adding one case closes the symmetry.💡 Suggested additional case
{name: "pr stays pr", input: "pr", expected: "pr"}, +{name: "uppercase pr", input: "PR", expected: "pr"}, {name: "pull request alias", input: "pull_request", expected: "pr"},🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/steps/similarity_test.go` around lines 5 - 27, The test suite for normalizeSimilarThreadType is missing a case to verify case-folding for PR variants; add an extra test case in TestNormalizeSimilarThreadType (the tests slice) such as name: "uppercase pr", input: "PR" (or "PULL_REQUEST"), expected: "pr" so the normalizeSimilarThreadType function's PR branch is validated for uppercase inputs.internal/steps/response_builder.go (1)
264-271:similarThreadTypeIconre-encodes PR-variant matching thatnormalizeSimilarThreadTypealready handles.By the time
SimilarIssue.Typearrives here it is already canonical ("pr"or"issue"); the"pull_request"/"pull request"branches are dead code in the production call path. This duplicates the variant list fromsimilarity.go:39-41, so adding a new alias later (e.g."merge_request") requires updating two places.Consider simplifying to operate only on canonical values, which also explicitly documents the expected contract:
♻️ Proposed simplification
func similarThreadTypeIcon(threadType string) string { - switch strings.ToLower(strings.TrimSpace(threadType)) { - case "pr", "pull_request", "pull request": + switch threadType { + case "pr": return "🔀" default: return "📝" } }If defensive handling of raw payload values is intentional, at minimum extract the canonical PR-variant set into a shared constant or helper so both functions stay in sync.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/steps/response_builder.go` around lines 264 - 271, The similarThreadTypeIcon function duplicates PR-variant matching already performed by normalizeSimilarThreadType and receives canonical values via SimilarIssue.Type, so remove the dead branches and simplify similarThreadTypeIcon to switch only on canonical values (e.g., "pr" and default "issue") or, if you want defensive handling, pull the PR alias set into a shared constant/helper used by both similarThreadTypeIcon and normalizeSimilarThreadType (update similarity.go to expose the alias set or helper). Update references to similarThreadTypeIcon and normalizeSimilarThreadType to use the shared helper where applicable so adding new aliases requires changing only one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@internal/steps/response_builder.go`:
- Around line 264-271: The similarThreadTypeIcon function duplicates PR-variant
matching already performed by normalizeSimilarThreadType and receives canonical
values via SimilarIssue.Type, so remove the dead branches and simplify
similarThreadTypeIcon to switch only on canonical values (e.g., "pr" and default
"issue") or, if you want defensive handling, pull the PR alias set into a shared
constant/helper used by both similarThreadTypeIcon and
normalizeSimilarThreadType (update similarity.go to expose the alias set or
helper). Update references to similarThreadTypeIcon and
normalizeSimilarThreadType to use the shared helper where applicable so adding
new aliases requires changing only one place.
In `@internal/steps/similarity_test.go`:
- Around line 5-27: The test suite for normalizeSimilarThreadType is missing a
case to verify case-folding for PR variants; add an extra test case in
TestNormalizeSimilarThreadType (the tests slice) such as name: "uppercase pr",
input: "PR" (or "PULL_REQUEST"), expected: "pr" so the
normalizeSimilarThreadType function's PR branch is validated for uppercase
inputs.
🧪 E2E Test✅ Bot responded: yes Test repo → gh-simili-bot/simili-e2e-22168890067 Auto-generated by E2E pipeline |
… (similigh#75) Signed-off-by: Mahsum Aktas <mahsum@mahsumaktas.com> Co-authored-by: Kaviru Hapuarachchi <41495525+Kavirubc@users.noreply.github.com> Signed-off-by: Sachindu-Nethmin <sachindunethminweerasinghe@gmail.com>
Summary
Adds visual type differentiation in the Similar Threads table so users can instantly tell whether a match is an issue or a pull request.
Closes #49
Changes
internal/core/pipeline/pipeline.goType stringfield toSimilarIssuestruct ("issue"or"pr")internal/steps/similarity.gotypefrom Qdrant payload during similarity searchnormalizeSimilarThreadType()handles variants (pr,pull_request,pull request) and defaults to"issue"internal/steps/response_builder.go| Similarity | Type | Thread | Status |similarThreadTypeIcon()— returns 📝 for issues, 🔀 for PRsBefore / After
Before:
After:
Tests
TestNormalizeSimilarThreadType— 7 cases (empty, issue, PR, pull_request, unknown)TestResponseBuilder_buildSimilarSection_TypeIcons— verifies icons for issue/PR/missing typeTestResponseBuilder_buildTriageSummaryfor new table formatgo test ./...✅Summary by CodeRabbit
Release Notes