@devries-cameron20 / t3code-1 / commits / e428a2c1f5
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web,mobile): pull request text breaks lines when providers do (#26060)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Cody Ray Hoeft committed Oct 30, 2026 at 14:17 UTC e428a2c1f52bd2f694b2ddf466b5aac5bce414af
12 files changed +82 -9
apps/mobile/src/features/pull-requests/PullRequestMarkdown.tsx
+14 -2
@@ -11,7 +11,10 @@ import {
11 import { videoMimeType } from "@t3tools/shared/video";
12 import { createContext, useContext, useMemo, useState } from "react";
13 import { changeRequestReferenceAutolinker } from "@t3tools/client-runtime/pull-request-markdown";
14 -import type { ReferenceAutolink } from "@t3tools/client-runtime/source-control-clients";
14 +import {
15 + sourceControlClients,
16 + type ReferenceAutolink,
17 +} from "@t3tools/client-runtime/source-control-clients";
18 import { linkReferenceAutolinks } from "./pullRequestAutolinks";
19
20 import { useOpenPullRequest } from "../../native/useOpenPullRequest";
@@ -31,6 +34,7 @@ import type { MarkdownImageRenderer } from "../../native/SelectableMarkdownText"
34 const AutolinksContext = createContext<((text: string) => ReadonlyArray<ReferenceAutolink>) | null>(
35 null,
36 );
37 +const LineBreaksContext = createContext(false);
38
39 export function PullRequestMarkdownRepository(props: {
40 /** The change request the markdown belongs to, whose host decides what its text links. */
@@ -44,6 +48,7 @@ export function PullRequestMarkdownRepository(props: {
48 provider === undefined || url === undefined
49 ? null
50 : changeRequestReferenceAutolinker({ provider, url });
51 + const lineBreaks = sourceControlClients.find(provider ?? "")?.hardLineBreaks ?? false;
52 const target = pullRequestTarget(props.params);
53 const project = useProject({
54 environmentId: target.environmentId,
@@ -53,7 +58,9 @@ export function PullRequestMarkdownRepository(props: {
58 const media = cwd ? { environmentId: target.environmentId, cwd } : null;
59 return (
60 <AutolinksContext value={autolinks}>
56 - <PullRequestMediaContext value={media}>{props.children}</PullRequestMediaContext>
61 + <LineBreaksContext value={lineBreaks}>
62 + <PullRequestMediaContext value={media}>{props.children}</PullRequestMediaContext>
63 + </LineBreaksContext>
64 </AutolinksContext>
65 );
66 }
@@ -88,6 +95,7 @@ function MarkdownImage(props: {
95 export function PullRequestMarkdown(props: {
96 readonly markdown: string;
97 readonly imageGroupMarkdown?: string;
98 + readonly lineBreaks?: boolean;
99 }) {
100 const segments = useMemo(() => splitPullRequestBody(props.markdown), [props.markdown]);
101 return (
@@ -98,6 +106,7 @@ export function PullRequestMarkdown(props: {
106 key={segment.id}
107 markdown={segment.text}
108 imageGroupMarkdown={props.imageGroupMarkdown ?? props.markdown}
109 + lineBreaks={props.lineBreaks}
110 />
111 ) : (
112 <PullRequestMedia key={segment.id} url={segment.url} kind={segment.media} />
@@ -110,7 +119,9 @@ export function PullRequestMarkdown(props: {
119 function PullRequestMarkdownContent(props: {
120 readonly markdown: string;
121 readonly imageGroupMarkdown?: string;
122 + readonly lineBreaks: boolean | undefined;
123 }) {
124 + const hostLineBreaks = useContext(LineBreaksContext);
125 const autolinks = useContext(AutolinksContext);
126 const mediaContext = useContext(PullRequestMediaContext);
127 const markdown = linkReferenceAutolinks(props.markdown, autolinks);
@@ -136,6 +147,7 @@ function PullRequestMarkdownContent(props: {
147 <FilePreviewGallery value={gallery}>
148 <SelectableMarkdownText
149 markdown={markdown}
150 + preserveSoftBreaks={props.lineBreaks ?? hostLineBreaks}
151 textStyle={styles.nativeTextStyle}
152 onLinkPress={openLink}
153 renderImage={renderImage}
apps/mobile/src/features/pull-requests/guide/GuideOutline.tsx
+1 -1
@@ -59,7 +59,7 @@ export function GuideOutline({
59 </View>
60 {guide.stops[0]?.summary ? (
61 <View className="mb-6">
62 - <PullRequestMarkdown markdown={guide.stops[0].summary} />
62 + <PullRequestMarkdown lineBreaks={false} markdown={guide.stops[0].summary} />
63 </View>
64 ) : null}
65 {guide.stops.map((stop, position) => {
apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx
+4 -4
@@ -188,7 +188,7 @@ export function PullRequestGuideStopScreen({ route }: StaticScreenProps<GuideSto
188 <>
189 <GuideNotice state={state} />
190 <Text className="text-2xl leading-8 font-t3-semibold">{stop.title}</Text>
191 - <PullRequestMarkdown markdown={stop.summary} />
191 + <PullRequestMarkdown lineBreaks={false} markdown={stop.summary} />
192 {stop.attention ? (
193 <View className="gap-3 rounded-xl border border-border bg-grouped-card p-4">
194 <View className="flex-row items-center gap-2">
@@ -197,7 +197,7 @@ export function PullRequestGuideStopScreen({ route }: StaticScreenProps<GuideSto
197 {attentionLabels[stop.attention.kind]}
198 </Text>
199 </View>
200 - <PullRequestMarkdown markdown={stop.attention.note} />
200 + <PullRequestMarkdown lineBreaks={false} markdown={stop.attention.note} />
201 </View>
202 ) : null}
203 {stale ? (
@@ -237,7 +237,7 @@ export function PullRequestGuideStopScreen({ route }: StaticScreenProps<GuideSto
237 <Text className="text-xs text-foreground-muted">
238 {note.path.split("/").at(-1)}:{note.line}
239 </Text>
240 - <PullRequestMarkdown markdown={note.body} />
240 + <PullRequestMarkdown lineBreaks={false} markdown={note.body} />
241 </View>
242 </View>
243 ))}
@@ -266,7 +266,7 @@ export function PullRequestGuideStopScreen({ route }: StaticScreenProps<GuideSto
266 <View className="gap-3">
267 <Text className="font-t3-semibold">Questions to consider</Text>
268 {stop.questions.map((question) => (
269 - <PullRequestMarkdown key={question} markdown={question} />
269 + <PullRequestMarkdown key={question} lineBreaks={false} markdown={question} />
270 ))}
271 </View>
272 ) : null}
apps/mobile/src/features/pull-requests/guide/ReviewGuideExcerpt.tsx
+3 -1
@@ -55,7 +55,9 @@ export function ReviewGuideExcerpt({
55 const [NativeDiff] = useState(() => resolveNativeReviewDiffView());
56 return (
57 <View className="gap-3">
58 - {excerpt.caption.trim() ? <PullRequestMarkdown markdown={excerpt.caption} /> : null}
58 + {excerpt.caption.trim() ? (
59 + <PullRequestMarkdown lineBreaks={false} markdown={excerpt.caption} />
60 + ) : null}
61 <View className="overflow-hidden rounded-lg border border-border-subtle">
62 <Pressable
63 accessibilityRole="button"
apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+5 -1
@@ -239,7 +239,11 @@ function pullRequestMarkdownContext(
239 detail: Pick<PullRequestDetail, "provider" | "url"> | null,
240 threadRef: ScopedThreadRef | null,
241 ) {
242 - return { autolinks: changeRequestReferenceAutolinker(detail), threadRef };
242 + return {
243 + autolinks: changeRequestReferenceAutolinker(detail),
244 + lineBreaks: sourceControlClients.find(detail?.provider ?? "")?.hardLineBreaks ?? false,
245 + threadRef,
246 + };
247 }
248
249 function pullRequestStackReference(
apps/web/src/components/pullRequest/PullRequestMarkdown.browser.test.tsx new
+45
@@ -0,0 +1,45 @@
1 +import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
2 +import { EnvironmentId } from "@t3tools/contracts";
3 +import { expect, it } from "vite-plus/test";
4 +
5 +import { render } from "../../../test/render";
6 +import { PullRequestMarkdown, PullRequestMarkdownContext } from "./PullRequestMarkdown";
7 +
8 +async function renderBody(host: string, options: { lineBreaks?: boolean } = {}) {
9 + const context = {
10 + autolinks: null,
11 + lineBreaks: sourceControlClients.get(host).hardLineBreaks ?? false,
12 + threadRef: null,
13 + };
14 + return render(
15 + <PullRequestMarkdownContext value={context}>
16 + <PullRequestMarkdown
17 + text={"first line\nsecond line"}
18 + cwd="/repo"
19 + environmentId={EnvironmentId.make("local")}
20 + {...options}
21 + />
22 + </PullRequestMarkdownContext>,
23 + );
24 +}
25 +
26 +it.each(["github", "forgejo", "azure-devops"])("%s breaks a single newline", async (host) => {
27 + await using screen = await renderBody(host);
28 + await expect.element(screen.getByText(/first line/)).toBeInTheDocument();
29 + expect(screen.container.querySelectorAll("p br")).toHaveLength(1);
30 +});
31 +
32 +it.each(["gitlab", "bitbucket", "gitcafe", "unknown"])(
33 + "%s joins a single newline",
34 + async (host) => {
35 + await using screen = await renderBody(host);
36 + await expect.element(screen.getByText(/first line/)).toBeInTheDocument();
37 + expect(screen.container.querySelectorAll("p br")).toHaveLength(0);
38 + },
39 +);
40 +
41 +it("lets text the host did not write opt out of the host's breaks", async () => {
42 + await using screen = await renderBody("github", { lineBreaks: false });
43 + await expect.element(screen.getByText(/first line/)).toBeInTheDocument();
44 + expect(screen.container.querySelectorAll("p br")).toHaveLength(0);
45 +});
apps/web/src/components/pullRequest/PullRequestMarkdown.tsx
+4
@@ -23,6 +23,7 @@ import { remarkPullRequestAutolinks, splitPullRequestBody } from "./pullRequestM
23
24 export const PullRequestMarkdownContext = createContext<{
25 autolinks: ((text: string) => ReadonlyArray<ReferenceAutolink>) | null;
26 + lineBreaks: boolean;
27 threadRef: ScopedThreadRef | null;
28 } | null>(null);
29
@@ -59,12 +60,14 @@ export function PullRequestMarkdown({
60 cwd,
61 environmentId,
62 threadRef,
63 + lineBreaks,
64 className,
65 }: {
66 text: string;
67 cwd: string;
68 environmentId: EnvironmentId;
69 threadRef?: ScopedThreadRef | null;
70 + lineBreaks?: boolean;
71 className?: string;
72 }) {
73 const segments = splitPullRequestBody(text);
@@ -93,6 +96,7 @@ export function PullRequestMarkdown({
96 pullRequestPanelRef={resolvedThreadRef ?? PULL_REQUESTS_PANEL_REF}
97 environmentId={environmentId}
98 extraRemarkPlugins={extraRemarkPlugins}
99 + lineBreaks={lineBreaks ?? context?.lineBreaks ?? false}
100 sourceControlMedia
101 />
102 );
apps/web/src/components/pullRequest/guide/GuideProse.tsx
+1
@@ -26,6 +26,7 @@ export function GuideProse({
26 text={text}
27 cwd={context.cwd}
28 environmentId={context.environmentId}
29 + lineBreaks={false}
30 className={cn("space-y-0 [&_.chat-markdown]:text-inherit", className)}
31 />
32 );
packages/source-control-azure-devops/src/shared/definition.ts
+1
@@ -117,6 +117,7 @@ export const definition = defineSourceControl({
117 changeRequestCloseCommand:
118 /\baz\s+repos\s+pr\s+update\b[^;&|]*--status[\s=]+["']?(?:completed|abandoned)\b/u,
119 authorProfileUrl: () => null,
120 + hardLineBreaks: true,
121 reviewSummaryRequired: () => false,
122 checkoutCommandArgument: (input) => {
123 const args = CHECKOUT_COMMAND.exec(input)?.[1];
packages/source-control-core/src/shared/definition.ts
+2
@@ -286,6 +286,8 @@ export interface SourceControlDefinition {
286 text: string,
287 repositoryUrl: string,
288 ) => ReadonlyArray<ReferenceAutolink>;
289 + /** True when the host renders a single newline in change request text as a line break. */
290 + readonly hardLineBreaks?: boolean;
291 /** Where the host lists a change request's checks. Absent means the change request's own page. */
292 readonly changeRequestChecksUrl?: (changeRequestUrl: string) => string;
293 /**
packages/source-control-forgejo/src/shared/definition.ts
+1
@@ -95,6 +95,7 @@ export const definition = defineSourceControl({
95 : null,
96 changeRequestCloseCommand: /\b(?:tea\s+(?:pr|pulls)|fj\s+pr)\s+(?:merge|close)\b/u,
97 authorProfileUrl: () => null,
98 + hardLineBreaks: true,
99 // Forgejo refuses a change request review without a summary, even with inline comments.
100 reviewSummaryRequired: (verdict) => verdict === "request-changes",
101 checkoutCommandArgument: (input) => CHECKOUT_COMMAND.exec(input)?.[1]?.trim() ?? null,
packages/source-control-github/src/shared/definition.ts
+1
@@ -132,6 +132,7 @@ export const definition = defineSourceControl({
132 changeRequestActionsWhenUnreported: new Set(["close", "merge", "ready", "reopen"] as const),
133 // One search reads every repository on the host.
134 changeRequestListScope: "host",
135 + hardLineBreaks: true,
136 reviewSummaryRequired: () => false,
137 checkoutCommandArgument: (input) => CHECKOUT_COMMAND.exec(input)?.[1]?.trim() ?? null,
138 isChangeRequestReference: (url) => CHANGE_REQUEST_REFERENCE.test(url),