mirror of
https://github.com/block/buzz.git
synced 2026-11-25 02:31:36 +00:00
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 <thomasp@squareup.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import type { ProjectRepoCommit, ProjectRepoDiff } from "@/shared/api/types";
|
||||
import { CopyCommitHashButton } from "./ProjectCommitCopyButton";
|
||||
import { ProfileIdentityButton } from "./ProjectProfileIdentity";
|
||||
import { ProjectDiffFilesPanel } from "./ProjectPullRequestFilesChangedPanel";
|
||||
import { ProjectRichContent } from "./ProjectRichContent";
|
||||
|
||||
function commitDateLabel(timestamp: number) {
|
||||
return new Date(timestamp * 1_000).toLocaleString(undefined, {
|
||||
@@ -98,6 +99,9 @@ export function ProjectCommitDetailPanel({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{diff?.commitBody ? (
|
||||
<ProjectRichContent content={diff.commitBody} />
|
||||
) : null}
|
||||
</header>
|
||||
|
||||
<ProjectDiffFilesPanel
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
import { relativeTime } from "@/features/projects/lib/projectsViewHelpers";
|
||||
import type { ChannelMember } from "@/shared/api/types";
|
||||
import { normalizePubkey } from "@/shared/lib/pubkey";
|
||||
import { Markdown } from "@/shared/ui/markdown";
|
||||
import {
|
||||
ProjectFeedRow,
|
||||
ProjectFeedRowCluster,
|
||||
@@ -24,6 +23,7 @@ import {
|
||||
} from "./ProjectFeedRow";
|
||||
import { OverviewRailSection } from "./ProjectOverviewPanel";
|
||||
import { ProfileIdentityButton } from "./ProjectProfileIdentity";
|
||||
import { ProjectRichContent } from "./ProjectRichContent";
|
||||
|
||||
export function issueStatusClassName(status: ProjectIssue["status"]) {
|
||||
if (status === "Done") return "text-purple-400";
|
||||
@@ -214,11 +214,7 @@ function IssueDetail({
|
||||
</h3>
|
||||
</div>
|
||||
{issue.content ? (
|
||||
<Markdown
|
||||
className="text-sm"
|
||||
content={issue.content}
|
||||
interactive={false}
|
||||
/>
|
||||
<ProjectRichContent content={issue.content} tags={issue.tags} />
|
||||
) : null}
|
||||
</header>
|
||||
|
||||
@@ -238,11 +234,7 @@ function IssueDetail({
|
||||
role={relativeTime(item.createdAt)}
|
||||
/>
|
||||
</div>
|
||||
<Markdown
|
||||
className="text-sm"
|
||||
content={item.content}
|
||||
interactive={false}
|
||||
/>
|
||||
<ProjectRichContent content={item.content} tags={item.tags} />
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
import { relativeTime } from "@/features/projects/lib/projectsViewHelpers";
|
||||
import type { UserProfileLookup } from "@/features/profile/lib/identity";
|
||||
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
|
||||
import { Markdown } from "@/shared/ui/markdown";
|
||||
import { ProjectRichContent } from "./ProjectRichContent";
|
||||
|
||||
function commentAuthor(
|
||||
pubkey: string,
|
||||
@@ -68,10 +68,9 @@ export function ProjectPullRequestInlineCommentThread({
|
||||
{relativeTime(comment.createdAt)}
|
||||
</span>
|
||||
</div>
|
||||
<Markdown
|
||||
className="text-sm"
|
||||
<ProjectRichContent
|
||||
content={comment.content}
|
||||
interactive={false}
|
||||
tags={comment.tags}
|
||||
/>
|
||||
</article>
|
||||
))}
|
||||
|
||||
@@ -36,7 +36,6 @@ import type { UserProfileLookup } from "@/features/profile/lib/identity";
|
||||
import { useIdentityQuery } from "@/shared/api/hooks";
|
||||
import type { ChannelMember } from "@/shared/api/types";
|
||||
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
|
||||
import { Markdown } from "@/shared/ui/markdown";
|
||||
import {
|
||||
ProjectFeedRow,
|
||||
ProjectFeedRowCluster,
|
||||
@@ -49,6 +48,7 @@ import {
|
||||
ProfileAuthorName,
|
||||
ProfileIdentityButton,
|
||||
} from "./ProjectProfileIdentity";
|
||||
import { ProjectRichContent } from "./ProjectRichContent";
|
||||
import { PullRequestReviewersRow } from "./PullRequestReviewersRow";
|
||||
import { PullRequestReviewCard } from "./PullRequestReviewCard";
|
||||
|
||||
@@ -639,10 +639,9 @@ function PullRequestDetail({
|
||||
<div>
|
||||
{pullRequest.content ? (
|
||||
<header className="p-4">
|
||||
<Markdown
|
||||
className="text-sm"
|
||||
<ProjectRichContent
|
||||
content={pullRequest.content}
|
||||
interactive={false}
|
||||
tags={pullRequest.tags}
|
||||
/>
|
||||
</header>
|
||||
) : null}
|
||||
@@ -670,9 +669,11 @@ function PullRequestDetail({
|
||||
) : null}
|
||||
</div>
|
||||
{update.content ? (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{update.content}
|
||||
</p>
|
||||
<ProjectRichContent
|
||||
className="text-sm text-muted-foreground"
|
||||
content={update.content}
|
||||
tags={update.tags}
|
||||
/>
|
||||
) : null}
|
||||
</article>
|
||||
))}
|
||||
@@ -829,10 +830,10 @@ function PullRequestDetail({
|
||||
</span>
|
||||
</div>
|
||||
{activityContent ? (
|
||||
<Markdown
|
||||
<ProjectRichContent
|
||||
className="mt-1 text-sm text-foreground/90"
|
||||
content={activityContent}
|
||||
interactive={false}
|
||||
tags={item.tags}
|
||||
/>
|
||||
) : null}
|
||||
{item.anchor ? (
|
||||
|
||||
27
desktop/src/features/projects/ui/ProjectRichContent.tsx
Normal file
27
desktop/src/features/projects/ui/ProjectRichContent.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { Markdown } from "@/shared/ui/markdown";
|
||||
import { parseImetaTags } from "@/shared/ui/markdown/parseImeta";
|
||||
|
||||
/**
|
||||
* Renders project event content with the same link and media support as
|
||||
* messages while retaining NIP-92 attachment metadata from the source event.
|
||||
*/
|
||||
export function ProjectRichContent({
|
||||
className = "text-sm",
|
||||
content,
|
||||
tags,
|
||||
}: {
|
||||
className?: string;
|
||||
content: string;
|
||||
tags?: string[][];
|
||||
}) {
|
||||
const imetaByUrl = React.useMemo(
|
||||
() => (tags ? parseImetaTags(tags) : undefined),
|
||||
[tags],
|
||||
);
|
||||
|
||||
return (
|
||||
<Markdown className={className} content={content} imetaByUrl={imetaByUrl} />
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user