Skip to content

Commit 46a270f

Browse files
fix(mobile): filter badges only in the description attachments strip
Comments share the description extractor to decide whether to render a card, so filtering there could hide a comment whose only content is a badge. Inline images in comments and the description stay untouched. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 223892f commit 46a270f

5 files changed

Lines changed: 35 additions & 49 deletions

File tree

‎apps/mobile/src/features/pull-requests/PullRequestDescription.tsx‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { SymbolView } from "../../components/AppSymbol";
88
import { AppText as Text } from "../../components/AppText";
99
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
1010
import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
11+
import { isBotBadgeImage } from "./botBadgeImages";
1112
import { PullRequestMarkdown } from "./PullRequestMarkdown";
1213
import { pullRequestDescriptionContent } from "./pullRequestDescriptionContent";
1314

@@ -24,21 +25,23 @@ export function PullRequestDescription(props: {
2425
const [preview, setPreview] = useState<FilePreviewSource | null>(null);
2526
const openingUri = preview && "uri" in preview ? preview.uri : null;
2627
const { themeVariables: colors } = useAppearancePreferences();
27-
const content = useMemo(() => {
28+
const attachments = useMemo(() => {
2829
const document = nativeMarkdownWithHtml(
2930
parseMarkdownWithOptions(props.markdown, { gfm: true, html: true, math: false }),
3031
(markdown) => parseMarkdownWithOptions(markdown, { gfm: true, html: false, math: false }),
3132
);
32-
return pullRequestDescriptionContent(document);
33+
return pullRequestDescriptionContent(document).attachments.filter(
34+
(attachment) => !isBotBadgeImage(attachment.uri),
35+
);
3336
}, [props.markdown]);
3437
const gallery = useMemo(
3538
() =>
36-
content.attachments.map((attachment) => ({
39+
attachments.map((attachment) => ({
3740
kind: "image" as const,
3841
uri: attachment.uri,
3942
name: new URL(attachment.uri).pathname.split("/").pop() || "Image",
4043
})),
41-
[content],
44+
[attachments],
4245
);
4346
const canCollapse = bodyHeight > COLLAPSED_HEIGHT;
4447
const collapsed = canCollapse && !expanded;
@@ -128,7 +131,7 @@ export function PullRequestDescription(props: {
128131
<Text className="text-sm text-foreground-muted">No description provided.</Text>
129132
)}
130133
</View>
131-
{content.attachments.length ? (
134+
{attachments.length ? (
132135
<View className="gap-3">
133136
<Text className="text-base font-t3-semibold">Attachments</Text>
134137
<ScrollView
@@ -138,7 +141,7 @@ export function PullRequestDescription(props: {
138141
showsHorizontalScrollIndicator={false}
139142
contentContainerStyle={{ gap: 12 }}
140143
>
141-
{content.attachments.map((attachment) => (
144+
{attachments.map((attachment) => (
142145
<Pressable
143146
key={attachment.uri}
144147
accessibilityRole="imagebutton"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { describe, expect, it } from "vite-plus/test";
2+
import { isBotBadgeImage } from "./botBadgeImages";
3+
4+
describe("bot badge images", () => {
5+
it("matches bot badges but not screenshots hosted by the same services", () => {
6+
const badges = [
7+
"https://static.devin.ai/assets/gh-devin-review-light.svg?v=4",
8+
"https://cursor.com/assets/images/open-in-web-dark.png",
9+
"https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg",
10+
"https://img.shields.io/badge/P1-orange",
11+
"https://greptile-static-assets.s3.amazonaws.com/badges/ViewArtifacts.svg?v=4",
12+
"https://www.gstatic.com/codereviewagent/high-priority.svg",
13+
"https://user-images.githubusercontent.com/23264/106598434-9e719e00-654f-11eb-9e59-6167043cfa01.png",
14+
];
15+
const screenshots = [
16+
"https://cursor.com/artifacts/c/art-41567e7e-97f5-46ff-9e6e-df6a85723409",
17+
"https://app.devin.ai/attachments/abc/ss_1.png",
18+
"https://user-images.githubusercontent.com/23264/1-other-upload.png",
19+
"https://storage.googleapis.com/some-bucket/before.png",
20+
];
21+
expect(badges.filter(isBotBadgeImage)).toEqual(badges);
22+
expect(screenshots.filter(isBotBadgeImage)).toEqual([]);
23+
});
24+
});

‎apps/mobile/src/features/pull-requests/botBadgeImages.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Logos, buttons, and status icons that review bots, agents, and CI stamp into pull requests.
33
* Each entry is a host plus a path that only serves those assets, so screenshots uploaded to
44
* the same service (such as cursor.com/artifacts or app.devin.ai/attachments) stay visible.
5+
* Only the description's Attachments strip skips them; markdown still renders them inline.
56
*/
67
const BOT_BADGE_PREFIXES = [
78
// Coding agents and review bots

‎apps/mobile/src/features/pull-requests/pullRequestDescription.test.ts‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,6 @@ describe("PR description overview", () => {
2222
expect(result.preview).not.toContain("Duplicate");
2323
});
2424

25-
it("drops bot badges but keeps screenshots hosted by the same services", () => {
26-
const image = (href: string, alt: string) => ({ type: "image", href, alt }) as const;
27-
const result = pullRequestDescriptionContent({
28-
type: "document",
29-
children: [
30-
image("https://static.devin.ai/assets/gh-devin-review-light.svg?v=4", "Devin Review"),
31-
image("https://cursor.com/assets/images/open-in-web-dark.png", "Open in Web"),
32-
image(
33-
"https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg",
34-
"Review Change Stack",
35-
),
36-
image("https://img.shields.io/badge/P1-orange", "P1 Badge"),
37-
image(
38-
"https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=compression",
39-
"Dependabot compatibility score",
40-
),
41-
image(
42-
"https://greptile-static-assets.s3.amazonaws.com/badges/ViewArtifacts.svg?v=4",
43-
"View artifacts",
44-
),
45-
image(
46-
"https://user-images.githubusercontent.com/23264/106598434-9e719e00-654f-11eb-9e59-6167043cfa01.png",
47-
"Cloudflare Pages",
48-
),
49-
image("https://cursor.com/artifacts/c/art-41567e7e-97f5-46ff-9e6e-df6a85723409", "Before"),
50-
image("https://app.devin.ai/attachments/abc/ss_1.png", "After"),
51-
image("https://user-images.githubusercontent.com/23264/1-other-upload.png", "Detail"),
52-
],
53-
});
54-
expect(result.attachments.map((attachment) => attachment.caption)).toEqual([
55-
"Before",
56-
"After",
57-
"Detail",
58-
]);
59-
});
60-
6125
it("reads formatted prose and list items without leaking hidden HTML metadata", () => {
6226
const result = pullRequestDescriptionContent({
6327
type: "document",

‎apps/mobile/src/features/pull-requests/pullRequestDescriptionContent.ts‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import type { MarkdownNode } from "react-native-nitro-markdown/headless";
2-
import { isBotBadgeImage } from "./botBadgeImages";
32

43
/** Read media from the parsed document so code examples never become attachments. */
54
export function pullRequestDescriptionContent(document: MarkdownNode) {
65
const attachments = new Map<string, { readonly uri: string; readonly caption: string }>();
76
const text: string[] = [];
87
const visit = (node: MarkdownNode) => {
98
if (node.type === "image") {
10-
if (
11-
node.href &&
12-
/^https?:\/\//i.test(node.href) &&
13-
!isBotBadgeImage(node.href) &&
14-
!attachments.has(node.href)
15-
) {
9+
if (node.href && /^https?:\/\//i.test(node.href) && !attachments.has(node.href)) {
1610
attachments.set(node.href, { uri: node.href, caption: node.alt || node.title || "Image" });
1711
}
1812
return;

0 commit comments

Comments
 (0)