[codex] Add native mobile composer and markdown #3101
Mergedjuliusmarmingemerged 13 commits into
main fromrefs/pull/3101/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- @@ -0,0 +413,21 @@413+ // Setting attributedText clears any active text selection, and re-assigning414+ // the frame triggers a layout flush that has the same effect. Bail out415+ // entirely when nothing actually changed so a JS-side state update made in416+ // response to onSelectionChange doesn't deselect what the user is selecting.417+ const BOOL textChanged = ![_textView.attributedText isEqualToAttributedString:convertedAttrString];418+ const BOOL frameChanged = !CGRectEqualToRect(_textView.frame, _view.frame);419+ if (!textChanged && !frameChanged) {420+ return;421+ }422+ if (textChanged) {423+ // Reassigning attributedText clears any active selection. Save it and424+ // restore after, while suppressing the synthetic textViewDidChangeSelection425+ // events the clear-then-restore would otherwise produce — those would426+ // round-trip to JS and re-trigger this same path, causing a loop.427+ const NSRange savedRange = _textView.selectedRange;428+ _suppressSelectionChange = YES;429+ _textView.attributedText = convertedAttrString;430+ if (savedRange.length > 0 && NSMaxRange(savedRange) <= _textView.attributedText.length) {431+ _textView.selectedRange = savedRange;432+ }433+ _suppressSelectionChange = NO;@@ -0,0 +31,21 @@31+ case "200":32+ return "ultraLight";33+ case 300:34+ case "300":35+ case "light":36+ return "light";37+ case 400:38+ case "400":39+ case "regular":40+ return "normal";41+ case 500:42+ case "500":43+ case "medium":44+ return "medium";45+ case 600:46+ case "600":47+ case "semibold":48+ return "semibold";49+ case 700:50+ case "700":51+ return "semibold";@@ -0,0 +366,21 @@366+ tokens = decode([ComposerTokenPayload].self, from: tokensJson) ?? []367+ tokensNeedRebuild = true368+ applyControlledDocument(force: true)369+ if tokensMatchCurrentValue() {370+ tokensNeedRebuild = false371+ }372+ }373+374+ func setSelectionJson(_ selectionJson: String) {375+ requestedSelection = decode(ComposerSelectionPayload.self, from: selectionJson)376+ applyRequestedSelection()377+ }378+379+ func setThemeJson(_ themeJson: String) {380+ guard let nextTheme = decode(ComposerThemePayload.self, from: themeJson) else {381+ return382+ }383+ theme = nextTheme384+ applyTheme()385+ applyControlledDocument(force: true)386+ }
- @@ -0,0 +78,21 @@78+ style={[flattenedStyle]}79+ // @ts-expect-error Weirdness80+ onPress={undefined}81+ onLongPress={undefined}82+ >83+ {nativeChildren}84+ </T3MarkdownTextNativeComponent>85+ </TextAncestorContext.Provider>86+ );87+ }88+89+ return <>{nativeChildren}</>;90+}91+92+function MarkdownTextPrimitiveInner(props: MarkdownTextPrimitiveProps) {93+ const [isAncestor] = useTextAncestorContext();94+95+ // Even if the uiTextView prop is set, we can still default to using96+ // normal selection (i.e. base RN text) if the text doesn't need to be97+ // selectable98+ if ((!props.selectable || !props.uiTextView) && !isAncestor) {@@ -21,6 +23,12 @@2123 import { RegistryContext } from "@effect/atom-react";2224 import { appAtomRegistry } from "../state/atom-registry";2325 import { CloudAuthProvider } from "../features/cloud/CloudAuthProvider";26+import {27+ ClerkSettingsSheetDetentProvider,28+ useClerkSettingsSheetDetent,29+} from "../features/cloud/ClerkSettingsSheetDetent";2430 import { useAgentNotificationNavigation } from "../features/agent-awareness/notificationNavigation";31+import { useThemeColor } from "../lib/useThemeColor";25322633 function AppNavigator() {34+ const pathname = usePathname();@@ -0,0 +31,21 @@31+ case "200":32+ return "ultraLight";33+ case 300:34+ case "300":35+ case "light":36+ return "light";37+ case 400:38+ case "400":39+ case "regular":40+ return "normal";41+ case 500:42+ case "500":43+ case "medium":44+ return "medium";45+ case 600:46+ case "600":47+ case "semibold":48+ return "semibold";49+ case 700:50+ case "700":51+ return "semibold";@@ -0,0 +53,21 @@53+ readonly externalHost?: string;54+ readonly fileIcon?: MarkdownFileIcon;55+ readonly role?: NativeMarkdownTextRun["role"];56+ readonly headingLevel?: number;57+ readonly depth?: number;58+ readonly spacing?: number;59+ readonly firstLineHeadIndent?: number;60+ readonly headIndent?: number;61+ readonly paragraphSpacing?: number;62+}63+64+const EMPTY_CONTEXT: RunContext = {65+ bold: false,66+ italic: false,67+ strikethrough: false,68+ code: false,69+};70+71+const INLINE_HTML_TAG_PATTERN = /<\/?(?:kbd|mark|sub|sup|u)(?:\s[^>]*)?>/gi;72+73+function decodeHtmlEntitiesOnce(value: string): string {@@ -0,0 +110,21 @@110+rmSync(outputDirectory, { recursive: true, force: true });111+mkdirSync(outputDirectory, { recursive: true });112+113+const builtInSprite = getBuiltInSpriteSheet("complete");114+const builtInTokens = [...builtInSprite.matchAll(/<symbol id="file-tree-builtin-([^"]+)"/g)]115+ .map((match) => match[1])116+ .sort();117+118+for (const token of builtInTokens) {119+ renderIcon(120+ token,121+ symbolFromSprite(builtInSprite, `file-tree-builtin-${token}`),122+ colors[token] ?? colors.default,123+ );124+}125+for (const [token, symbolId] of Object.entries(customIcons)) {126+ renderIcon(token, symbolFromSprite(customSprite, symbolId), colors[token] ?? colors.default);127+}128+129+const tokens = [...new Set([...builtInTokens, ...Object.keys(customIcons)])].sort();130+const generatedSource = `import type { ImageSourcePropType } from "react-native";\n\nexport const MARKDOWN_FILE_ICON_SOURCES = {\n${tokens
juliusmarminge merged this689a882
juliusmarminge closed this
Sign in to join this conversation.



Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
fef61048-d696-43ae-b7a9-ae2fe3151a37You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.