Skip to content

Commit afb272b

Browse files
authored
fix(desktop): render rich project work item content (#3100)
## Summary Project issues, pull requests, reviews, and commit details no longer flatten rich content into inert or plain text. They now share the message markdown and media pipeline, preserving NIP-92 `imeta` metadata so links, images, and videos render consistently. Commit bodies are fetched only when a single-commit detail view is opened, keeping list queries lightweight while exposing full context beside the diff. ### Related issue None found. ### Testing - Pre-push suite: `desktop-check`, `desktop-test`, `desktop-tauri-test`, `rust-tests`, and `mobile-test` - Project issue and pull request regression tests cover preserving attachment metadata on roots, updates, and comments - The project commit detail smoke scenario verifies linked text, images, and video in commit bodies Signed-off-by: Thomas Petersen <[email protected]>
1 parent 070fb6a commit afb272b

23 files changed

Lines changed: 200 additions & 43 deletions

‎desktop/src-tauri/src/commands/project_git_diff.rs‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct ProjectRepoDiffInfo {
2525
pub files: Vec<ProjectRepoDiffFileInfo>,
2626
pub additions: usize,
2727
pub deletions: usize,
28+
pub commit_body: Option<String>,
2829
}
2930

3031
fn clean_target_ref(value: Option<String>) -> Option<String> {
@@ -340,7 +341,25 @@ fn diff_from_repo(
340341
repo_dir: &std::path::Path,
341342
auth: &GitAuthConfig,
342343
range: &str,
344+
target_commit: Option<&str>,
343345
) -> Result<ProjectRepoDiffInfo, String> {
346+
let commit_body = target_commit
347+
.map(|commit| {
348+
run_git(
349+
&[
350+
"show",
351+
"--no-patch",
352+
"--format=%b",
353+
"--end-of-options",
354+
commit,
355+
],
356+
Some(repo_dir),
357+
auth,
358+
)
359+
.map(|body| body.trim_end().to_string())
360+
})
361+
.transpose()?
362+
.filter(|body| !body.is_empty());
344363
let numstat = run_git(&["diff", "--numstat", range], Some(repo_dir), auth)?;
345364
let files = parse_numstat(&numstat)
346365
.into_iter()
@@ -375,6 +394,7 @@ fn diff_from_repo(
375394
Ok(ProjectRepoDiffInfo {
376395
additions: files.iter().map(|file| file.additions).sum(),
377396
deletions: files.iter().map(|file| file.deletions).sum(),
397+
commit_body,
378398
files,
379399
})
380400
}
@@ -430,7 +450,12 @@ pub async fn get_project_repo_diff(
430450
diff_base_ref(&repo_dir, &auth, base_branch.as_deref()),
431451
),
432452
};
433-
diff_from_repo(&repo_dir, &auth, &range)
453+
let commit_body_ref = if target_ref.is_none() && base_branch.is_none() {
454+
target_commit.as_deref()
455+
} else {
456+
None
457+
};
458+
diff_from_repo(&repo_dir, &auth, &range, commit_body_ref)
434459
})
435460
.await
436461
.map_err(|error| format!("repo diff task failed: {error}"))?
@@ -468,7 +493,12 @@ pub async fn get_project_local_repo_diff(
468493
base_commit.as_deref(),
469494
target_commit.as_deref(),
470495
);
471-
diff_from_repo(&repo_dir, &auth, &range).map(Some)
496+
let commit_body_ref = if base_commit.is_none() && base_branch.is_none() {
497+
target_commit.as_deref()
498+
} else {
499+
None
500+
};
501+
diff_from_repo(&repo_dir, &auth, &range, commit_body_ref).map(Some)
472502
})
473503
.await
474504
.map_err(|error| format!("local repo diff task failed: {error}"))?

‎desktop/src/features/forum/ui/ForumPostCard.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { UserProfilePopover } from "@/features/profile/ui/UserProfilePopover";
99
import { UserAvatar } from "@/shared/ui/UserAvatar";
1010
import type { ForumPost } from "@/shared/api/types";
1111
import { cn } from "@/shared/lib/cn";
12-
import { parseImetaTags } from "@/features/messages/lib/parseImeta";
1312
import { resolveMentionProps } from "@/shared/lib/resolveMentionNames";
1413
import { Markdown } from "@/shared/ui/markdown";
14+
import { parseImetaTags } from "@/shared/ui/markdown/parseImeta";
1515

1616
import { formatRelativeTime } from "../lib/time";
1717
import { DeleteActionMenu } from "./DeleteActionMenu";

‎desktop/src/features/forum/ui/ForumThreadPanel.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import type { ForumThreadResponse, ThreadReply } from "@/shared/api/types";
1111
import { channelChrome } from "@/shared/layout/chromeLayout";
1212
import { cn } from "@/shared/lib/cn";
1313
import { useChannelNavigation } from "@/shared/context/ChannelNavigationContext";
14-
import { parseImetaTags } from "@/features/messages/lib/parseImeta";
1514
import { resolveMentionProps } from "@/shared/lib/resolveMentionNames";
1615
import { Button } from "@/shared/ui/button";
16+
import { parseImetaTags } from "@/shared/ui/markdown/parseImeta";
1717
import { Markdown } from "@/shared/ui/markdown";
1818
import { Skeleton } from "@/shared/ui/skeleton";
1919

‎desktop/src/features/messages/lib/imetaMediaMarkdown.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727

2828
import type { BlobDescriptor } from "@/shared/api/tauri";
29-
import { parseImetaTags } from "./parseImeta";
29+
import { parseImetaTags } from "@/shared/ui/markdown/parseImeta";
3030

3131
export type ImetaMedia = BlobDescriptor & {
3232
/** Composer-only label used for attachment links; not emitted in imeta. */

‎desktop/src/features/messages/lib/rowHeightEstimate.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type * as React from "react";
33
import { dimensionsFromDim } from "@/shared/ui/markdown/utils";
44
import type { TimelineItem } from "./timelineItems";
55
import type { TimelineMessage } from "../types";
6-
import { parseImetaTags } from "./parseImeta";
6+
import { parseImetaTags } from "@/shared/ui/markdown/parseImeta";
77

88
/**
99
* Estimate a timeline row's rendered height so its `content-visibility`

‎desktop/src/features/messages/lib/timelineImagePreload.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { rewriteRelayUrl } from "@/shared/lib/mediaUrl";
2+
import { parseImetaTags } from "@/shared/ui/markdown/parseImeta";
23
import type { TimelineMessage } from "../types";
3-
import { parseImetaTags } from "./parseImeta";
44

55
/**
66
* Return non-message-media image URLs worth warming before a virtualized row

‎desktop/src/features/messages/ui/MessageRow.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { cn } from "@/shared/lib/cn";
3232
import { normalizePubkey } from "@/shared/lib/pubkey";
3333
import { UserAvatar } from "@/shared/ui/UserAvatar";
3434
import { useChannelNavigation } from "@/shared/context/ChannelNavigationContext";
35-
import { parseImetaTags } from "@/features/messages/lib/parseImeta";
35+
import { parseImetaTags } from "@/shared/ui/markdown/parseImeta";
3636
import { useMessageEmoji } from "@/features/messages/lib/useMessageEmoji";
3737
import { parseWaveMessageContent } from "@/features/messages/lib/waveMessage";
3838
import { resolveSnapshotSharedBy } from "@/features/messages/lib/snapshotSharedBy";

‎desktop/src/features/projects/projectIssues.d.mts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type ProjectIssueStatus =
1111
export type ProjectIssueComment = {
1212
id: string;
1313
content: string;
14+
tags: string[][];
1415
author: string;
1516
createdAt: number;
1617
};
@@ -19,6 +20,7 @@ export type ProjectIssue = {
1920
id: string;
2021
title: string;
2122
content: string;
23+
tags: string[][];
2224
author: string;
2325
createdAt: number;
2426
repoAddress: string | null;
@@ -41,6 +43,7 @@ export const PROJECT_ISSUE_STATUS: {
4143

4244
export function getTag(event: RelayEvent, name: string): string | undefined;
4345
export function getAllTags(event: RelayEvent, name: string): string[];
46+
export function getImetaTags(event: RelayEvent): string[][];
4447
export function eventToProjectIssue(
4548
issue: RelayEvent,
4649
statusEvents?: RelayEvent[],

‎desktop/src/features/projects/projectIssues.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export function getAllTags(event, name) {
2222
.map((tag) => tag[1]);
2323
}
2424

25+
export function getImetaTags(event) {
26+
return event.tags.filter((tag) => tag[0] === "imeta");
27+
}
28+
2529
function repoOwnerFromAddress(repoAddress) {
2630
const owner = (repoAddress ?? "").split(":")[1] ?? "";
2731
return /^[a-fA-F0-9]{64}$/.test(owner) ? owner.toLowerCase() : null;
@@ -80,6 +84,7 @@ function commentsForIssue(issueId, commentEvents) {
8084
.map((event) => ({
8185
id: event.id,
8286
content: event.content,
87+
tags: getImetaTags(event),
8388
author: event.pubkey,
8489
createdAt: event.created_at,
8590
}));
@@ -101,6 +106,7 @@ export function eventToProjectIssue(
101106
id: issue.id,
102107
title,
103108
content: issue.content,
109+
tags: getImetaTags(issue),
104110
author: issue.pubkey,
105111
createdAt: issue.created_at,
106112
repoAddress: getTag(issue, "a") ?? null,

‎desktop/src/features/projects/projectIssues.test.mjs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,32 @@ test("tag helpers drop malformed value-less tags", () => {
9999
assert.equal(issue.title, "Something is broken");
100100
});
101101

102+
test("preserves root and comment tags for rich content rendering", () => {
103+
const root = issueEvent({
104+
tags: [
105+
["a", REPO_ADDRESS],
106+
["subject", "Something is broken"],
107+
["imeta", "url https://relay.example/media/root.png", "m image/png"],
108+
],
109+
});
110+
const comment = {
111+
id: "comment-rich-content",
112+
kind: 1,
113+
pubkey: ATTACKER,
114+
created_at: 200,
115+
content: "![Screenshot](https://relay.example/media/comment.png)",
116+
tags: [
117+
["e", root.id, "", "root"],
118+
["imeta", "url https://relay.example/media/comment.png", "m image/png"],
119+
],
120+
};
121+
122+
const issue = eventToProjectIssue(root, [], [comment]);
123+
124+
assert.deepEqual(issue.tags, [root.tags[2]]);
125+
assert.deepEqual(issue.comments[0].tags, [comment.tags[1]]);
126+
});
127+
102128
test("builds repository-scoped issue creation tags", () => {
103129
assert.deepEqual(
104130
buildGitIssueTags({

0 commit comments

Comments
 (0)