Repository navigation
feat(mobile): browse and review pull requests natively #18126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+11,595
−378
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1eaab2a
feat(mobile): browse and review pull requests natively
juliusmarminge caf753e
fix(mobile): pin the rebuilt Screens archive integrity
juliusmarminge 3c20f43
fix(mobile): integrate PR navigation with shared validation
juliusmarminge f1cb633
fix(mobile): wait for layout before jumping to PR files
juliusmarminge 482125d
fix(mobile): use available Tabler icons in production bundles
juliusmarminge a23e2b0
ci(mobile): expose EAS preview publish diagnostics
juliusmarminge 4b9cf61
fix(mobile): keep PR stack loading layout stable
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
apps/mobile/modules/t3-markdown-text/src/githubAlert.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { describe, expect, it } from "vite-plus/test"; | ||
| import type { MarkdownNode } from "react-native-nitro-markdown/headless"; | ||
| import { githubAlert } from "./githubAlert"; | ||
|
|
||
| const quote = (...children: MarkdownNode[]): MarkdownNode => ({ | ||
| type: "blockquote", | ||
| children: [{ type: "paragraph", children }], | ||
| }); | ||
|
|
||
| describe("GitHub alerts in native Markdown", () => { | ||
| it.each(["NOTE", "TIP", "IMPORTANT", "WARNING", "CAUTION"])( | ||
| "recognizes %s and retains formatted content", | ||
| (marker) => { | ||
| const bold: MarkdownNode = { type: "bold", children: [{ type: "text", content: "Details" }] }; | ||
| const node = quote({ type: "text", content: `[!${marker}]` }, { type: "soft_break" }, bold); | ||
| const original = structuredClone(node); | ||
| const alert = githubAlert(node); | ||
| expect(alert?.title.toUpperCase()).toBe(marker); | ||
| expect(alert?.children[0]?.children).toEqual([bold]); | ||
| expect(node).toEqual(original); | ||
| }, | ||
| ); | ||
| it("handles text nodes containing the line break and following text", () => { | ||
| expect( | ||
| githubAlert(quote({ type: "text", content: "[!WARNING]\nKeep this text." }))?.children[0] | ||
| ?.children?.[0]?.content, | ||
| ).toBe("Keep this text."); | ||
| }); | ||
| it("leaves inline markers, code, and ordinary quotes alone", () => { | ||
| expect(githubAlert(quote({ type: "text", content: "[!WARNING] inline" }))).toBeNull(); | ||
| expect( | ||
| githubAlert( | ||
| quote( | ||
| { type: "text", content: "[!WARNING]" }, | ||
| { type: "bold", children: [{ type: "text", content: "inline" }] }, | ||
| ), | ||
| ), | ||
| ).toBeNull(); | ||
| expect(githubAlert({ type: "code_block", content: "> [!WARNING]" })).toBeNull(); | ||
| expect(githubAlert(quote({ type: "text", content: "Just a quote" }))).toBeNull(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import type { MarkdownNode } from "react-native-nitro-markdown/headless"; | ||
|
|
||
| const ALERTS = { | ||
| NOTE: { title: "Note", color: "#4493f8", lightColor: "#0969da", symbol: "info.circle" }, | ||
| TIP: { title: "Tip", color: "#3fb950", lightColor: "#1a7f37", symbol: "lightbulb" }, | ||
| IMPORTANT: { | ||
| title: "Important", | ||
| color: "#ab7df8", | ||
| lightColor: "#8250df", | ||
| symbol: "exclamationmark.bubble", | ||
| }, | ||
| WARNING: { | ||
| title: "Warning", | ||
| color: "#d29922", | ||
| lightColor: "#9a6700", | ||
| symbol: "exclamationmark.triangle", | ||
| }, | ||
| CAUTION: { | ||
| title: "Caution", | ||
| color: "#f85149", | ||
| lightColor: "#cf222e", | ||
| symbol: "exclamationmark.octagon", | ||
| }, | ||
| } as const; | ||
|
|
||
| /** GitHub alerts are blockquotes whose first line contains only the alert marker. */ | ||
| export function githubAlert(node: MarkdownNode) { | ||
| if (node.type !== "blockquote") return null; | ||
| const paragraph = node.children?.[0]; | ||
| const text = paragraph?.children?.[0]; | ||
| if (paragraph?.type !== "paragraph" || text?.type !== "text") return null; | ||
| const match = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\](\r?\n|$)/i.exec(text.content ?? ""); | ||
| if (!match) return null; | ||
| const rest = (text.content ?? "").slice(match[0].length); | ||
| const siblings = paragraph.children?.slice(1) ?? []; | ||
| if ( | ||
| !rest && | ||
| !match[2] && | ||
| siblings.length && | ||
| !["soft_break", "line_break"].includes(siblings[0]!.type) | ||
| ) | ||
| return null; | ||
| if (!rest && ["soft_break", "line_break"].includes(siblings[0]?.type ?? "")) siblings.shift(); | ||
| const children = [...(rest ? [{ ...text, content: rest }] : []), ...siblings]; | ||
| return { | ||
| ...ALERTS[match[1]!.toUpperCase() as keyof typeof ALERTS], | ||
| children: [ | ||
| ...(children.length ? [{ ...paragraph, children }] : []), | ||
| ...(node.children?.slice(1) ?? []), | ||
| ], | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Allow only safe schemes for HTML
<img src>values.markdownHtmlContentcopies any decodedsrcvalue into a Markdown image destination. PR descriptions are untrusted. Asrcsuch asjavascript:orfile:can therefore become animagenode. On the native path,NativeMarkdownImagepasseshrefdirectly toImage.markdownImageSourcesalso collects that value. On iOS, the Quick Look path can then copyfile:URLs.PullRequestMarkdownfilters tohttp(s)only on its own paths, so other consumers have no such guard. Allow onlyhttp,https, and relative sources here. Remove the tag for any other scheme.🛡️ Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Learnings