Skip to content

Commit a280025

Browse files
committed
Fix GitHub assets not appearing
1 parent 36b94bf commit a280025

File tree

6 files changed

+269
-20
lines changed

6 files changed

+269
-20
lines changed

bunfig.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ plugins = ["bun-plugin-tailwind"]
33

44

55

6+

src/api/types.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
import { components } from "@octokit/openapi-types";
22

33
// REST API types - re-exported from Octokit schemas
4-
export type PullRequest = components["schemas"]["pull-request"];
4+
// Extended types include body_html from GitHub's HTML media type (application/vnd.github.html+json)
5+
export type PullRequest = components["schemas"]["pull-request"] & {
6+
body_html?: string;
7+
};
58
export type PullRequestFile = components["schemas"]["diff-entry"];
69
export type ReviewComment =
710
components["schemas"]["pull-request-review-comment"] & {
811
// Thread resolution info (enriched from GraphQL)
912
pull_request_review_thread_id?: string;
1013
is_resolved?: boolean;
1114
resolved_by?: { login: string; avatar_url: string } | null;
15+
/** Pre-rendered HTML with signed attachment URLs from GitHub's API */
16+
body_html?: string;
1217
};
13-
export type Review = components["schemas"]["pull-request-review"];
18+
export type Review = components["schemas"]["pull-request-review"] & {
19+
body_html?: string;
20+
};
1421
export type CheckRun = components["schemas"]["check-run"];
1522
export type CombinedStatus = components["schemas"]["combined-commit-status"];
16-
export type IssueComment = components["schemas"]["issue-comment"];
23+
export type IssueComment = components["schemas"]["issue-comment"] & {
24+
body_html?: string;
25+
};
1726
export type GitHubUser = components["schemas"]["public-user"];
1827

1928
// GraphQL-only types (not in REST API schemas)
@@ -34,6 +43,8 @@ export interface ReviewThread {
3443
id: string;
3544
databaseId: number;
3645
body: string;
46+
/** Pre-rendered HTML with signed attachment URLs from GitHub's GraphQL API */
47+
bodyHTML?: string;
3748
path: string;
3849
line: number | null;
3950
originalLine: number | null;

src/browser/components/pr-overview.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ export const PROverview = memo(function PROverview() {
922922
user={pr.user}
923923
createdAt={pr.created_at}
924924
body={pr.body}
925+
bodyHtml={pr.body_html}
925926
isAuthor
926927
reactions={reactions.issue}
927928
onAddReaction={canWrite ? handleAddPRReaction : undefined}
@@ -1066,6 +1067,7 @@ export const PROverview = memo(function PROverview() {
10661067
user={comment.user}
10671068
createdAt={comment.created_at}
10681069
body={comment.body ?? null}
1070+
bodyHtml={comment.body_html}
10691071
reactions={reactions[`comment-${comment.id}`]}
10701072
onAddReaction={
10711073
canWrite
@@ -2093,6 +2095,7 @@ function CommentBox({
20932095
user,
20942096
createdAt,
20952097
body,
2098+
bodyHtml,
20962099
isAuthor,
20972100
reactions,
20982101
onAddReaction,
@@ -2103,6 +2106,8 @@ function CommentBox({
21032106
user: { login: string; avatar_url: string } | null;
21042107
createdAt: string;
21052108
body: string | null;
2109+
/** Pre-rendered HTML with signed attachment URLs from GitHub's API */
2110+
bodyHtml?: string;
21062111
isAuthor?: boolean;
21072112
reactions?: Reaction[];
21082113
onAddReaction?: (content: ReactionContent) => void;
@@ -2146,15 +2151,16 @@ function CommentBox({
21462151
</div>
21472152
{/* Body */}
21482153
<div className="p-4 bg-card">
2149-
{body ? (
2154+
{body || bodyHtml ? (
21502155
<Markdown
2156+
html={bodyHtml}
21512157
emptyState={
21522158
<p className="text-sm text-muted-foreground italic">
21532159
No description provided.
21542160
</p>
21552161
}
21562162
>
2157-
{body}
2163+
{body ?? ""}
21582164
</Markdown>
21592165
) : (
21602166
<p className="text-sm text-muted-foreground italic">
@@ -2301,7 +2307,7 @@ function ReviewBox({ review }: { review: Review }) {
23012307
)}
23022308
</div>
23032309
<div className="p-4 bg-card">
2304-
<Markdown>{review.body}</Markdown>
2310+
<Markdown html={review.body_html}>{review.body}</Markdown>
23052311
</div>
23062312
</div>
23072313
)}
@@ -2621,7 +2627,7 @@ function ReviewThreadBox({
26212627
</span>
26222628
</div>
26232629
<div className="mt-2">
2624-
<Markdown>{comment.body}</Markdown>
2630+
<Markdown html={comment.bodyHTML}>{comment.body}</Markdown>
26252631
</div>
26262632
{/* Emoji reactions */}
26272633
<div className="mt-3">

src/browser/components/pr-review.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2885,7 +2885,7 @@ const CommentItem = memo(function CommentItem({
28852885
) : (
28862886
<>
28872887
<div className="mt-1 text-sm text-foreground/90">
2888-
<Markdown>{comment.body}</Markdown>
2888+
<Markdown html={comment.body_html}>{comment.body}</Markdown>
28892889
</div>
28902890

28912891
{/* Reactions */}

src/browser/contexts/github.tsx

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,26 @@ import type { components } from "@octokit/openapi-types";
1212
import { useAuth } from "./auth";
1313

1414
// Re-export types
15-
export type PullRequest = components["schemas"]["pull-request"];
15+
// Extended PullRequest with body_html from GitHub's HTML media type
16+
export type PullRequest = components["schemas"]["pull-request"] & {
17+
body_html?: string;
18+
};
1619
export type PullRequestFile = components["schemas"]["diff-entry"];
20+
// Extended ReviewComment with body_html from GitHub's HTML media type
1721
export type ReviewComment =
18-
components["schemas"]["pull-request-review-comment"];
19-
export type Review = components["schemas"]["pull-request-review"];
22+
components["schemas"]["pull-request-review-comment"] & {
23+
body_html?: string;
24+
};
25+
// Extended Review with body_html from GitHub's HTML media type
26+
export type Review = components["schemas"]["pull-request-review"] & {
27+
body_html?: string;
28+
};
2029
export type CheckRun = components["schemas"]["check-run"];
2130
export type CombinedStatus = components["schemas"]["combined-commit-status"];
22-
export type IssueComment = components["schemas"]["issue-comment"];
31+
// Extended IssueComment with body_html from GitHub's HTML media type
32+
export type IssueComment = components["schemas"]["issue-comment"] & {
33+
body_html?: string;
34+
};
2335
export type PRCommit = components["schemas"]["commit"];
2436
export type Collaborator = components["schemas"]["collaborator"];
2537
export type Reaction = components["schemas"]["reaction"];
@@ -118,6 +130,8 @@ export interface ReviewThread {
118130
id: string;
119131
databaseId: number;
120132
body: string;
133+
/** Pre-rendered HTML with signed attachment URLs from GitHub's GraphQL API */
134+
bodyHTML?: string;
121135
path: string;
122136
line: number | null;
123137
originalLine: number | null;
@@ -1009,10 +1023,14 @@ function createGitHubStore() {
10091023
owner,
10101024
repo,
10111025
pull_number: number,
1026+
headers: {
1027+
// Request full media type to get both body and body_html with signed attachment URLs
1028+
accept: "application/vnd.github.full+json",
1029+
},
10121030
})
10131031
.then((res) => {
1014-
cache.set(cacheKey, res.data);
1015-
return res.data;
1032+
cache.set(cacheKey, res.data as PullRequest);
1033+
return res.data as PullRequest;
10161034
});
10171035

10181036
cache.setPending(cacheKey, promise);
@@ -1090,9 +1108,13 @@ function createGitHubStore() {
10901108
pull_number: number,
10911109
per_page: 100,
10921110
page,
1111+
headers: {
1112+
// Request full media type to get both body and body_html with signed attachment URLs
1113+
accept: "application/vnd.github.full+json",
1114+
},
10931115
}
10941116
);
1095-
comments.push(...data);
1117+
comments.push(...(data as ReviewComment[]));
10961118
if (data.length < 100) break;
10971119
page++;
10981120
}
@@ -1175,10 +1197,14 @@ function createGitHubStore() {
11751197
owner,
11761198
repo,
11771199
pull_number: number,
1200+
headers: {
1201+
// Request full media type to get both body and body_html with signed attachment URLs
1202+
accept: "application/vnd.github.full+json",
1203+
},
11781204
})
11791205
.then((res) => {
1180-
cache.set(cacheKey, res.data);
1181-
return res.data;
1206+
cache.set(cacheKey, res.data as Review[]);
1207+
return res.data as Review[];
11821208
});
11831209

11841210
cache.setPending(cacheKey, promise);
@@ -2001,10 +2027,14 @@ function createGitHubStore() {
20012027
owner,
20022028
repo,
20032029
issue_number: number,
2030+
headers: {
2031+
// Request full media type to get both body and body_html with signed attachment URLs
2032+
accept: "application/vnd.github.full+json",
2033+
},
20042034
})
20052035
.then((res) => {
2006-
cache.set(cacheKey, res.data);
2007-
return res.data;
2036+
cache.set(cacheKey, res.data as IssueComment[]);
2037+
return res.data as IssueComment[];
20082038
});
20092039

20102040
cache.setPending(cacheKey, promise);
@@ -2321,6 +2351,7 @@ function createGitHubStore() {
23212351
id: string;
23222352
databaseId: number;
23232353
body: string;
2354+
bodyHTML: string;
23242355
path: string;
23252356
line: number | null;
23262357
originalLine: number | null;
@@ -2363,6 +2394,7 @@ function createGitHubStore() {
23632394
id
23642395
databaseId
23652396
body
2397+
bodyHTML
23662398
path
23672399
line
23682400
originalLine

0 commit comments

Comments
 (0)