Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { githubRevalidationSignalKeys } from "#/lib/github-revalidation";
import { useGitHubSignalStream } from "#/lib/use-github-signal-stream";
import { useHasMounted } from "#/lib/use-has-mounted";
import { usePageTitle } from "#/lib/use-page-title";
import { useRegisterTab } from "#/lib/use-register-tab";
import { IssueDetailActivitySection } from "./issue-detail-activity";
import { getIssueStateConfig, IssueDetailHeader } from "./issue-detail-header";
Expand Down Expand Up @@ -89,6 +90,8 @@ export function IssueDetailContent({
const commentPagination = pageQuery.data?.commentPagination;
const eventPagination = pageQuery.data?.eventPagination;

usePageTitle(issue?.title);

useRegisterTab(
registerTab && issue
? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { githubRevalidationSignalKeys } from "#/lib/github-revalidation";
import { useGitHubSignalStream } from "#/lib/use-github-signal-stream";
import { useHasMounted } from "#/lib/use-has-mounted";
import { usePageTitle } from "#/lib/use-page-title";
import { useRegisterTab } from "#/lib/use-register-tab";
import { PullBodySection } from "./pull-body-section";
import { PullDetailActivitySection } from "./pull-detail-activity";
Expand Down Expand Up @@ -123,6 +124,8 @@ export function PullDetailContent({
const headRefDeleted = pageQuery.data?.headRefDeleted ?? false;
const viewer = viewerQuery.data ?? null;

usePageTitle(pr?.title);

useRegisterTab(
registerTab && pr
? {
Expand Down
3 changes: 3 additions & 0 deletions apps/dashboard/src/components/pulls/review/review-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import type {
} from "#/lib/github.types";
import { githubRevalidationSignalKeys } from "#/lib/github-revalidation";
import { useGitHubSignalStream } from "#/lib/use-github-signal-stream";
import { usePageTitle } from "#/lib/use-page-title";
import { useRegisterTab } from "#/lib/use-register-tab";
import { checkPermissionWarning } from "#/lib/warning-store";
import type { ReviewDiffPaneHandle } from "./review-diff-pane";
Expand Down Expand Up @@ -220,6 +221,8 @@ export function ReviewPage() {
);
const reviewComments = reviewCommentsQuery.data ?? [];

usePageTitle(pr ? `Review: ${pr.title}` : null);

// ── Mention support for inline comment forms ──────────────────────
const [mentionActivated, setMentionActivated] = useState(false);
const viewerQuery = useQuery(githubViewerQueryOptions(scope));
Expand Down
12 changes: 11 additions & 1 deletion apps/dashboard/src/lib/seo.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { buildSeo, summarizeText, toAbsoluteUrl } from "./seo";
import { buildSeo, formatPageTitle, summarizeText, toAbsoluteUrl } from "./seo";

describe("summarizeText", () => {
it("strips basic markdown and whitespace", () => {
Expand Down Expand Up @@ -46,3 +46,13 @@ describe("buildSeo", () => {
});
});
});

describe("formatPageTitle", () => {
it("adds the app name when it is missing", () => {
expect(formatPageTitle("Fix tab titles")).toBe("Fix tab titles | DiffKit");
});

it("does not duplicate the app name", () => {
expect(formatPageTitle("Inbox | DiffKit")).toBe("Inbox | DiffKit");
});
});
9 changes: 9 additions & 0 deletions apps/dashboard/src/lib/use-page-title.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useEffect } from "react";
import { formatPageTitle } from "./seo";

export function usePageTitle(title: string | null | undefined) {
useEffect(() => {
if (!title) return;
document.title = formatPageTitle(title);
}, [title]);
}
Loading