Skip to content

Commit 63acf89

Browse files
authored
Merge branch 'main' into fix/canonicalize-checkout-paths
2 parents 7cc3c4d + 23bdb9e commit 63acf89

23 files changed

Lines changed: 474 additions & 59 deletions

File tree

‎apps/mobile/modules/t3-composer-editor/android/build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ android {
2020

2121
dependencies {
2222
implementation project(':expo-modules-core')
23+
implementation 'com.facebook.react:react-android'
2324
testImplementation 'junit:junit:4.13.2'
2425
testImplementation 'org.robolectric:robolectric:4.16.1'
2526
}

‎apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import android.view.inputmethod.InputConnection
3030
import android.view.inputmethod.InputConnectionWrapper
3131
import android.view.inputmethod.InputMethodManager
3232
import android.widget.EditText
33+
import com.facebook.react.common.assets.ReactFontManager
3334
import expo.modules.kotlin.AppContext
3435
import expo.modules.kotlin.viewevent.EventDispatcher
3536
import expo.modules.kotlin.views.ExpoView
@@ -276,8 +277,9 @@ class T3ComposerEditorView(context: Context, appContext: AppContext) : ExpoView(
276277
editor.typeface = if (fontFamily.contains("Mono", ignoreCase = true)) {
277278
Typeface.MONOSPACE
278279
} else {
279-
Typeface.DEFAULT
280+
ReactFontManager.getInstance().getTypeface(fontFamily, Typeface.NORMAL, context.assets)
280281
}
282+
applyLineHeight()
281283
editor.applyPlaceholder()
282284
}
283285

‎apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ContextChip.kt‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.graphics.RectF
99
import android.graphics.Typeface
1010
import android.text.TextPaint
1111
import android.text.TextUtils
12+
import com.facebook.react.common.assets.ReactFontManager
1213
import kotlin.math.ceil
1314
import kotlin.math.min
1415

@@ -29,14 +30,14 @@ class T3ContextChip(
2930

3031
private val paint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
3132
textSize = fontSize
32-
typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL)
33+
typeface = chipTypeface()
3334
color = this@T3ContextChip.color
3435
}
3536
private val em = fontSize
3637

3738
private val detailPaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
3839
textSize = fontSize * 0.84f
39-
typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL)
40+
typeface = chipTypeface()
4041
color = this@T3ContextChip.color
4142
}
4243
private val detailText = if (content.detail.isEmpty()) "" else " ${content.detail}"
@@ -86,6 +87,18 @@ class T3ContextChip(
8687
}
8788

8889
companion object {
90+
private const val CHIP_FONT_FAMILY = "DMSans-Medium"
91+
92+
// Matches the iOS chips; builds without the bundled font keep the platform medium.
93+
private fun chipTypeface(): Typeface {
94+
val fonts = ReactFontManager.getInstance()
95+
return if (CHIP_FONT_FAMILY in fonts.customFontFamilies) {
96+
fonts.getTypeface(CHIP_FONT_FAMILY, Typeface.NORMAL, null)
97+
} else {
98+
Typeface.create("sans-serif-medium", Typeface.NORMAL)
99+
}
100+
}
101+
89102
fun color(
90103
value: String,
91104
fallback: Int

‎apps/mobile/modules/t3-review-diff/android/src/main/java/expo/modules/t3reviewdiff/T3ReviewDiffModule.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class T3ReviewDiffModule : Module() {
6969
AsyncFunction("scrollToTop") { view: T3ReviewDiffView, animated: Boolean ->
7070
view.scrollToTop(animated)
7171
}
72-
AsyncFunction("setRowsJson") { view: T3ReviewDiffView, rowsJson: String ->
72+
AsyncFunction("setRowsJson") { view: T3ReviewDiffView, rowsJson: String, resetKey: String ->
73+
view.setContentResetKey(resetKey)
7374
view.setRowsJson(rowsJson)
7475
}
7576
AsyncFunction("setTokensJson") { view: T3ReviewDiffView, tokensJson: String ->

‎apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffModule.swift‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public class T3ReviewDiffModule: Module {
102102
// Large, frequently changing JSON values cannot be regular Fabric props. Expo's
103103
// prop adapter compares strings on the main thread before invoking a setter, which
104104
// makes a syntax-token patch capable of blocking a frame by itself.
105-
AsyncFunction("setRowsJson") { (view: T3ReviewDiffView, rowsJson: String) in
105+
AsyncFunction("setRowsJson") { (view: T3ReviewDiffView, rowsJson: String, contentResetKey: String) in
106+
view.setContentResetKey(contentResetKey)
106107
view.setRowsJson(rowsJson)
107108
}
108109

‎apps/mobile/src/features/diffs/nativeReviewDiffSurface.test.tsx‎

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const mocks = vi.hoisted(() => ({
2121
tokenCompletion: null as Promise<boolean> | null,
2222
onDebug: undefined as NativeReviewDiffViewProps["onDebug"],
2323
autoViewport: false,
24+
contentResetKeyLandsLate: false,
2425
rows: vi.fn(),
2526
tokens: vi.fn(),
2627
highlight: vi.fn(),
@@ -30,22 +31,30 @@ function RawView({
3031
ref: nativeRef,
3132
onDebug,
3233
initialFileId,
33-
contentResetKey,
34+
contentResetKey = "",
3435
}: NativeReviewDiffViewProps & { ref: Ref<unknown> }) {
3536
const [content, setContent] = useState({ resetKey: contentResetKey, rows: "" });
36-
const rows = content.resetKey === contentResetKey ? content.rows : "";
37+
// Native setContentResetKey clears rows unless the key is unchanged.
38+
const setContentResetKey = (resetKey: string) =>
39+
setContent((current) => (current.resetKey === resetKey ? current : { resetKey, rows: "" }));
3740
const [tokenRowIds, setTokenRowIds] = useState<string[]>([]);
41+
// Android Fabric can apply a prop update after an AsyncFunction call made later.
42+
if (!mocks.contentResetKeyLandsLate && content.resetKey !== contentResetKey) {
43+
setContentResetKey(contentResetKey);
44+
}
3845
useLayoutEffect(() => {
3946
mocks.onDebug = onDebug;
4047
});
4148
useImperativeHandle(nativeRef, () => ({
42-
async setRowsJson(value: string) {
49+
async setRowsJson(value: string, resetKey?: string) {
4350
mocks.rows(value);
4451
if (mocks.registrationFailures > 0) {
4552
mocks.registrationFailures -= 1;
4653
throw new Error("Unable to find the 'T3ReviewDiffSurface' view for this native tag");
4754
}
48-
setContent({ resetKey: contentResetKey, rows: value });
55+
if (resetKey !== undefined) setContentResetKey(resetKey);
56+
setContent((current) => ({ ...current, rows: value }));
57+
setContentResetKey(contentResetKey);
4958
if (mocks.autoViewport) {
5059
const decoded = JSON.parse(value) as NativeReviewDiffData["rows"];
5160
onDebug?.({
@@ -79,7 +88,7 @@ function RawView({
7988
}));
8089
return (
8190
<div data-token-rows={tokenRowIds.join(",")}>
82-
{rows ? "Rendered diff" : "Blank native surface"}
91+
{content.rows ? "Rendered diff" : "Blank native surface"}
8392
</div>
8493
);
8594
}
@@ -141,6 +150,7 @@ function setup(integrated = false) {
141150
mocks.tokenCompletion = null;
142151
mocks.onDebug = undefined;
143152
mocks.autoViewport = false;
153+
mocks.contentResetKeyLandsLate = false;
144154
mocks.rows.mockClear();
145155
mocks.tokens.mockClear();
146156
mocks.highlight
@@ -251,6 +261,20 @@ function setup(integrated = false) {
251261
async mountPullRequest(targetFileId?: string) {
252262
await act(async () => root.render(<PullRequestDiff targetFileId={targetFileId} />));
253263
},
264+
async showSection(contentResetKey: string) {
265+
await act(async () =>
266+
root.render(
267+
<NativeDiff
268+
rowsJson='[{"kind":"line","id":"r0"}]'
269+
contentResetKey={contentResetKey}
270+
appearanceScheme="light"
271+
themeJson="{}"
272+
rowHeight={20}
273+
contentWidth={300}
274+
/>,
275+
),
276+
);
277+
},
254278
async collapseFiles(fileIds: ReadonlyArray<string>) {
255279
collapsedFileIds = fileIds;
256280
await act(async () => root.render(<PullRequestDiff />));
@@ -321,6 +345,18 @@ it("retries transient native registration without replacing the diff with an err
321345
expect(screen.container.textContent).toBe("Rendered diff");
322346
});
323347

348+
it("renders identical rows after switching sections when the reset key prop lands late", async () => {
349+
using screen = setup(true);
350+
await screen.showSection("thread:git:changes");
351+
await screen.deliverPayloads();
352+
expect(screen.container.textContent).toBe("Rendered diff");
353+
354+
mocks.contentResetKeyLandsLate = true;
355+
await screen.showSection("thread:git:working-tree");
356+
await screen.deliverPayloads();
357+
expect(screen.container.textContent).toBe("Rendered diff");
358+
});
359+
324360
it.each([false, undefined])(
325361
"keeps colors queued until native accepts them and recovers rejected patches (%s)",
326362
async (rejected) => {

‎apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function isNativeReviewDiffDrawEvent(payload: Readonly<Record<string, unk
163163
}
164164

165165
interface NativeReviewDiffViewRef {
166-
readonly setRowsJson: (rowsJson: string) => Promise<void>;
166+
readonly setRowsJson: (rowsJson: string, contentResetKey: string) => Promise<void>;
167167
readonly setTokensJson: (tokensJson: string) => Promise<void>;
168168
readonly setTokensPatchJson: (tokensPatchJson: string) => Promise<boolean>;
169169
readonly scrollToFile: (fileId: string, animated: boolean) => Promise<void>;
@@ -216,8 +216,7 @@ function useNativeReviewDiffPayload(
216216
}
217217

218218
const view = nativeRef.current;
219-
const command: ((payload: string) => Promise<void | boolean>) | undefined = view?.[method];
220-
if (!view || !command) {
219+
if (!view?.[method]) {
221220
if (attempts < NATIVE_REVIEW_DIFF_PAYLOAD_RETRY_FRAMES) {
222221
attempts += 1;
223222
frame = requestAnimationFrame(dispatch);
@@ -229,8 +228,12 @@ function useNativeReviewDiffPayload(
229228
}
230229

231230
void Promise.resolve()
232-
.then(() => {
233-
if (!cancelled) return command.call(view, payload);
231+
.then((): Promise<void | boolean> | undefined => {
232+
if (cancelled) return;
233+
// Fabric can apply the contentResetKey prop after this call, so rows carry the key.
234+
return method === "setRowsJson"
235+
? view.setRowsJson(payload, resetKey ?? "")
236+
: view[method](payload);
234237
})
235238
.then((accepted) => {
236239
if (cancelled) return;
@@ -264,7 +267,6 @@ function useNativeReviewDiffPayload(
264267
cancelAnimationFrame(frame);
265268
}
266269
};
267-
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- A new resetKey redelivers an unchanged payload after the diff surface resets.
268270
}, [method, nativeRef, payload, resetKey, onFailure, onDelivered]);
269271
}
270272

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,8 @@ export function HomeScreen(props: HomeScreenProps) {
809809
recycleItems
810810
extraData={v2ExtraData}
811811
ListHeaderComponent={v2ListHeader}
812+
// Lifted above the rows so an iOS filter menu's dismissal morph is not covered.
813+
ListHeaderComponentStyle={{ zIndex: 1 }}
812814
ListFooterComponent={
813815
settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
814816
<ThreadListV2ShowMoreRow

‎apps/mobile/src/features/home/ThreadListFilters.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function ThreadListFilters(props: {
2727
<ScrollView
2828
horizontal
2929
showsHorizontalScrollIndicator={false}
30-
style={{ marginHorizontal: -props.gutter }}
30+
style={{ marginHorizontal: -props.gutter, overflow: "visible" }}
3131
contentContainerStyle={{ paddingHorizontal: 20, paddingTop: 2, paddingBottom: 10, gap: 8 }}
3232
>
3333
<ListFilterMenu

‎apps/mobile/src/features/pull-requests/PullRequestListFilters.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ export function PullRequestListFilters(props: {
357357
<ScrollView
358358
horizontal
359359
showsHorizontalScrollIndicator={false}
360+
style={{ overflow: "visible" }}
360361
// In the Android sidebar the first pill lines up with the rows' content instead
361362
// (8dp row margin + 12dp padding).
362363
contentContainerStyle={

0 commit comments

Comments
 (0)