GeezerVison is showing github.com — Merge remote-tracking branch 'origin/main' into fix/issue-23948 · pingdotgg/t3code@72af7df
File treeExpand file treeCollapse file tree Open diff view settings source-control-core/src/server source-control-gitcafe/src/server
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/diffs/nativeReviewDiffSource.test.ts +18-11Lines changed: 18 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -58,17 +58,24 @@ const failureKeys = [ | 58 | 58 | ["function", () => () => SOURCE], | 59 | 59 | ] as const; | 60 | 60 |
| 61 | | -it.each(failureKeys)("bounds transient retries for a %s key", async (_name, createKey) => { | 62 | | - const key = createKey(); | 63 | | - const fetch = vi.fn(async () => { | 64 | | - throw new Error("Offline"); | 65 | | - }); | 66 | | - const load = createNativeReviewDiffSourceLoader(fetch); | 67 | | - await expect(load(key)).rejects.toThrow("Offline"); | 68 | | - expect(await load(key)).toBeNull(); | 69 | | - expect(await load(key)).toBeNull(); | 70 | | - expect(fetch).toHaveBeenCalledTimes(2); | 71 | | -}); | | 61 | +it.each(failureKeys)( | | 62 | + "recovers after two transient failures on a later load for a %s key", | | 63 | + async (_name, createKey) => { | | 64 | + const key = createKey(); | | 65 | + const fetch = vi | | 66 | + .fn() | | 67 | + .mockRejectedValueOnce(new Error("Offline")) | | 68 | + .mockRejectedValueOnce(new Error("Still offline")) | | 69 | + .mockResolvedValue(SOURCE); | | 70 | + const load = createNativeReviewDiffSourceLoader(fetch); | | 71 | + await expect(load(key)).rejects.toThrow("Offline"); | | 72 | + await expect(load(key)).rejects.toThrow("Still offline"); | | 73 | + expect(fetch).toHaveBeenCalledTimes(2); | | 74 | + expect(await load(key)).toBe(SOURCE); | | 75 | + expect(await load(key)).toBe(SOURCE); | | 76 | + expect(fetch).toHaveBeenCalledTimes(3); | | 77 | + }, | | 78 | +); | 72 | 79 |
| 73 | 80 | it.each(failureKeys)( | 74 | 81 | "remembers permanent unavailability for a %s key", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/diffs/nativeReviewDiffSource.ts +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,6 @@ const MAX_SOURCE_FILES = 4; | 5 | 5 | // Bound retained UTF-16 text across files without discarding an already-fetched | 6 | 6 | // authoritative source just because it is large. Provider response limits still apply. | 7 | 7 | const MAX_CACHED_SOURCE_CHARACTERS = 8_000_000; | 8 | | -const MAX_SOURCE_ATTEMPTS = 2; | 9 | 8 |
| 10 | 9 | function isWeakKey(value: unknown): value is object { | 11 | 10 | return (typeof value === "object" && value !== null) || typeof value === "function"; | @@ -158,12 +157,12 @@ export function createNativeReviewDiffSourceLoader<FileId>( | 158 | 157 | permanent, | 159 | 158 | reason: reason ?? "transient", | 160 | 159 | }); | 161 | | - if (permanent || attempt >= MAX_SOURCE_ATTEMPTS) { | | 160 | + if (permanent) { | 162 | 161 | failure.unavailable = true; | 163 | 162 | traceDiffHighlight("source-unavailable", { | 164 | 163 | loader, | 165 | 164 | file, | 166 | | - reason: permanent ? "permanent-error" : "attempts", | | 165 | + reason: "permanent-error", | 167 | 166 | }); | 168 | 167 | return null; | 169 | 168 | } | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/home/thread-swipe-actions.tsx +77-40Lines changed: 77 additions & 40 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -121,6 +121,9 @@ function resolveSecondaryAction(input: { | 121 | 121 |
| 122 | 122 | /** Keep the scroll gate in context so scroll start cannot re-render every row and its subscriptions. */ | 123 | 123 | const SwipeableScrollGateContext = createContext(true); | | 124 | +// Swipeable rebuilds its native pan gesture whenever its config changes identity, so the props | | 125 | +// that feed it stay stable across row re-renders such as selection. | | 126 | +const FAIL_OFFSET_Y: [number, number] = [-10, 10]; | 124 | 127 |
| 125 | 128 | export function SwipeableScrollGateProvider(props: { | 126 | 129 | readonly enabled: boolean; | @@ -402,11 +405,77 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) { | 402 | 405 | }, | 403 | 406 | [content], | 404 | 407 | ); | 405 | | - const handleWillOpen = () => { | 406 | | - if (!props.dormant && !dismissalRef.current && swipeableRef.current) { | 407 | | - props.onSwipeableWillOpen?.(swipeableRef.current); | | 408 | + const { dormant, onSwipeableWillOpen, backgroundColor, containerStyle } = props; | | 409 | + const handleWillOpen = useCallback(() => { | | 410 | + if (!dormant && !dismissalRef.current && swipeableRef.current) { | | 411 | + onSwipeableWillOpen?.(swipeableRef.current); | 408 | 412 | } | | 413 | + }, [dormant, onSwipeableWillOpen]); | | 414 | + const handleSwipeableClose = useCallback(() => { | | 415 | + if (swipeableRef.current) onSwipeableClose?.(swipeableRef.current); | | 416 | + }, [onSwipeableClose]); | | 417 | + const compactActions = props.compactActions === true; | | 418 | + const { secondaryAction, threadTitle } = props; | | 419 | + // Swipeable calls this on every render; returning the previous element while nothing it shows | | 420 | + // changed keeps a selection change from re-rendering the hidden actions. | | 421 | + const rightActions = useRef<{ deps: readonly unknown[]; element: ReactNode } | null>(null); | | 422 | + const renderRightActions = ( | | 423 | + _progress: SharedValue<number>, | | 424 | + translation: SharedValue<number>, | | 425 | + methods: SwipeableMethods, | | 426 | + ) => { | | 427 | + const deps = [ | | 428 | + dormant, | | 429 | + translation, | | 430 | + methods, | | 431 | + actionStyle, | | 432 | + backgroundColor, | | 433 | + compactActions, | | 434 | + fullSwipeAction, | | 435 | + fullSwipeThreshold, | | 436 | + handleFullSwipeArmedChange, | | 437 | + primaryAction, | | 438 | + commitPrimaryAction, | | 439 | + onDelete, | | 440 | + secondaryAction, | | 441 | + threadTitle, | | 442 | + ]; | | 443 | + const cached = rightActions.current; | | 444 | + if (cached && deps.every((dep, index) => Object.is(dep, cached.deps[index]))) { | | 445 | + return cached.element; | | 446 | + } | | 447 | + const element = dormant ? null : ( | | 448 | + <Animated.View | | 449 | + ref={() => { | | 450 | + activeTranslationRef.current = translation; | | 451 | + }} | | 452 | + style={actionStyle} | | 453 | + > | | 454 | + <ThreadSwipeActions | | 455 | + backgroundColor={backgroundColor} | | 456 | + compact={compactActions} | | 457 | + fullSwipeAction={fullSwipeAction} | | 458 | + fullSwipeThreshold={fullSwipeThreshold} | | 459 | + onFullSwipeArmedChange={handleFullSwipeArmedChange} | | 460 | + primaryAction={{ ...primaryAction, onPress: commitPrimaryAction }} | | 461 | + secondaryAction={resolveSecondaryAction({ | | 462 | + close: () => methods.close(), | | 463 | + onDelete, | | 464 | + secondaryAction, | | 465 | + threadTitle, | | 466 | + })} | | 467 | + translation={translation} | | 468 | + /> | | 469 | + </Animated.View> | | 470 | + ); | | 471 | + rightActions.current = { deps, element }; | | 472 | + return element; | 409 | 473 | }; | | 474 | + const childrenContainerStyle = useMemo(() => ({ backgroundColor }), [backgroundColor]); | | 475 | + const swipeableContainerStyle = useMemo( | | 476 | + () => [{ backgroundColor }, containerStyle], | | 477 | + [backgroundColor, containerStyle], | | 478 | + ); | 410 | 479 |
| 411 | 480 | return ( | 412 | 481 | <Animated.View style={dismissStyle}> | @@ -419,53 +488,21 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) { | 419 | 488 | <ReanimatedSwipeable | 420 | 489 | ref={swipeableRef} | 421 | 490 | animationOptions={THREAD_SWIPE_SPRING} | 422 | | - childrenContainerStyle={{ backgroundColor: props.backgroundColor }} | 423 | | - containerStyle={[{ backgroundColor: props.backgroundColor }, props.containerStyle]} | | 491 | + childrenContainerStyle={childrenContainerStyle} | | 492 | + containerStyle={swipeableContainerStyle} | 424 | 493 | dragOffsetFromRight={-8} | 425 | 494 | enabled={!props.dormant && !isDismissing && props.enabled !== false && gateEnabled} | 426 | 495 | enableTrackpadTwoFingerGesture={props.enableTrackpadSwipe ?? true} | 427 | 496 | // Reject vertical pans via patched RNGH failOffsetY; simultaneous trackpad scrolls otherwise open rows on horizontal drift. | 428 | | - failOffsetY={[-10, 10]} | | 497 | + failOffsetY={FAIL_OFFSET_Y} | 429 | 498 | friction={1} | 430 | | - onSwipeableClose={() => { | 431 | | - if (swipeableRef.current) { | 432 | | - props.onSwipeableClose?.(swipeableRef.current); | 433 | | - } | 434 | | - }} | | 499 | + onSwipeableClose={handleSwipeableClose} | 435 | 500 | onSwipeableRelease={handleRelease} | 436 | 501 | onSwipeableOpenStartDrag={handleWillOpen} | 437 | 502 | onSwipeableWillOpen={handleWillOpen} | 438 | 503 | overshootFriction={1} | 439 | 504 | overshootRight | 440 | | - renderRightActions={(_progress, translation, methods) => | 441 | | - props.dormant ? null : ( | 442 | | - <Animated.View | 443 | | - ref={() => { | 444 | | - activeTranslationRef.current = translation; | 445 | | - }} | 446 | | - style={actionStyle} | 447 | | - > | 448 | | - <ThreadSwipeActions | 449 | | - backgroundColor={props.backgroundColor} | 450 | | - compact={props.compactActions === true} | 451 | | - fullSwipeAction={fullSwipeAction} | 452 | | - fullSwipeThreshold={fullSwipeThreshold} | 453 | | - onFullSwipeArmedChange={handleFullSwipeArmedChange} | 454 | | - primaryAction={{ | 455 | | - ...primaryAction, | 456 | | - onPress: commitPrimaryAction, | 457 | | - }} | 458 | | - secondaryAction={resolveSecondaryAction({ | 459 | | - close: () => methods.close(), | 460 | | - onDelete: props.onDelete, | 461 | | - secondaryAction: props.secondaryAction, | 462 | | - threadTitle: props.threadTitle, | 463 | | - })} | 464 | | - translation={translation} | 465 | | - /> | 466 | | - </Animated.View> | 467 | | - ) | 468 | | - } | | 505 | + renderRightActions={renderRightActions} | 469 | 506 | rightThreshold={actionsWidth * 0.42} | 470 | 507 | simultaneousWith={props.simultaneousWith} | 471 | 508 | > | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -66,6 +66,7 @@ import { | 66 | 66 | type WorkspaceDetail, | 67 | 67 | type WorkspaceDetailSheet, | 68 | 68 | } from "../workspace/workspace-detail-selection"; | | 69 | +import { startOpeningDetail } from "../workspace/useSelectWorkspaceDetail"; | 69 | 70 | import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext"; | 70 | 71 | import { HomeListOptionsProvider } from "../home/home-list-options"; | 71 | 72 | import { newTaskDestination } from "../threads/new-task-project-selection"; | @@ -498,6 +499,7 @@ function AdaptiveWorkspaceLayoutContent( | 498 | 499 | type: "select", | 499 | 500 | tab: detail.name === "Thread" ? "threads" : "pullRequests", | 500 | 501 | }); | | 502 | + startOpeningDetail(detail); | 501 | 503 | navigation.dispatch(selectWorkspaceDetail(detail, sheet)); | 502 | 504 | }); | 503 | 505 | } | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx +27-6Lines changed: 27 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,6 +43,7 @@ import { | 43 | 43 | import { usePullRequestDiffHighlightFiles } from "./usePullRequestDiffHighlightFiles"; | 44 | 44 | import { isPullRequestTestFile } from "./pullRequestFileFilters"; | 45 | 45 | import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native"; | | 46 | +import type { NativeStackNavigationProp } from "@react-navigation/native-stack"; | 46 | 47 | import { RegistryContext, useAtomRefresh, useAtomValue } from "@effect/atom-react"; | 47 | 48 | import { pullRequestReviewKey } from "./pullRequestReviewDrafts"; | 48 | 49 | import { type PullRequestDetail, type PullRequestListEntry } from "@t3tools/contracts"; | @@ -88,7 +89,7 @@ import { | 88 | 89 | type NativeReviewDiffViewProps, | 89 | 90 | } from "../diffs/nativeReviewDiffSurface"; | 90 | 91 | import { | 91 | | - buildNativeReviewDiffData, | | 92 | + getCachedNativeReviewDiffData, | 92 | 93 | NATIVE_REVIEW_DIFF_CONTENT_WIDTH, | 93 | 94 | } from "../review/nativeReviewDiffAdapter"; | 94 | 95 | import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider"; | @@ -99,6 +100,7 @@ import { PullRequestActionToolbar, PullRequestCardGroup } from "./PullRequestCon | 99 | 100 | import { | 100 | 101 | pullRequestTarget as requestTarget, | 101 | 102 | usePullRequestDiff, | | 103 | + usePullRequestDiffEntry, | 102 | 104 | type PullRequestDiffParams, | 103 | 105 | type PullRequestParams, | 104 | 106 | } from "./usePullRequestDiff"; | @@ -847,16 +849,35 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP | 847 | 849 | ); | 848 | 850 | } | 849 | 851 |
| 850 | | -export function PullRequestFileRouteScreen({ | 851 | | - route, | 852 | | -}: StaticScreenProps< | | 852 | +type PullRequestFileRouteProps = StaticScreenProps< | 853 | 853 | PullRequestDiffParams & { | 854 | 854 | readonly path: string; | 855 | 855 | readonly fileSelectionId?: string; | 856 | 856 | readonly replacingDraftId?: string; | 857 | 857 | readonly focus?: GuideDiffFocus; | 858 | 858 | } | 859 | | ->) { | | 859 | +>; | | 860 | + | | 861 | +export function PullRequestFileRouteScreen(props: PullRequestFileRouteProps) { | | 862 | + const navigation = | | 863 | + useNavigation<NativeStackNavigationProp<ReactNavigation.RootParamList, "PullRequestFile">>(); | | 864 | + const ready = usePullRequestDiffEntry(navigation); | | 865 | + if (ready) return <PullRequestFileRouteContent {...props} />; | | 866 | + const title = props.route.params.commit ? "Commit changes" : "Changes"; | | 867 | + return ( | | 868 | + <View className="flex-1 bg-screen"> | | 869 | + <NativeStackScreenOptions options={{ title, headerTitle: title }} /> | | 870 | + {Platform.OS === "android" ? ( | | 871 | + <AndroidScreenHeader title={title} onBack={() => navigation.goBack()} /> | | 872 | + ) : null} | | 873 | + <View className="flex-1 items-center justify-center"> | | 874 | + <AppActivityIndicator accessibilityLabel="Loading changes" /> | | 875 | + </View> | | 876 | + </View> | | 877 | + ); | | 878 | +} | | 879 | + | | 880 | +function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) { | 860 | 881 | const { layout } = useAdaptiveWorkspaceLayout(); | 861 | 882 | const navigation = useNavigation(); | 862 | 883 | const insets = useSafeAreaInsets(); | @@ -894,7 +915,7 @@ export function PullRequestFileRouteScreen({ | 894 | 915 | !result.isPending && | 895 | 916 | !result.error; | 896 | 917 | const activity = useEnvironmentQuery(composerPullRequests.activity(requestTarget(route.params))); | 897 | | - const baseData = useMemo(() => buildNativeReviewDiffData(parsed), [parsed]); | | 918 | + const baseData = useMemo(() => getCachedNativeReviewDiffData({ parsedDiff: parsed }), [parsed]); | 898 | 919 | const highlightFiles = usePullRequestDiffHighlightFiles(route.params, parsed, baseData.files); | 899 | 920 | const data = useMemo( | 900 | 921 | () => | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/pull-requests/pullRequestDiffHighlightFiles.test.ts +8-4Lines changed: 8 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -265,8 +265,12 @@ it.each(["permanent", "transient"])( | 265 | 265 | fetch.mockRejectedValueOnce(error); | 266 | 266 | if (failure === "transient") fetch.mockRejectedValueOnce(error); | 267 | 267 | const first = createPullRequestDiffHighlightFiles({ target }, parsed, files, fetch, cache); | 268 | | - if (failure === "transient") await expect(first[1]!.loadContents!()).rejects.toThrow("Offline"); | 269 | | - expect(await first[1]!.loadContents!()).toBeNull(); | | 268 | + if (failure === "transient") { | | 269 | + await expect(first[1]!.loadContents!()).rejects.toThrow("Offline"); | | 270 | + await expect(first[1]!.loadContents!()).rejects.toThrow("Offline"); | | 271 | + } else { | | 272 | + expect(await first[1]!.loadContents!()).toBeNull(); | | 273 | + } | 270 | 274 | const second = createPullRequestDiffHighlightFiles( | 271 | 275 | { target }, | 272 | 276 | { ...parsed, files: [parsed.files[0]!, { ...parsed.files[1]! }] }, | @@ -275,8 +279,8 @@ it.each(["permanent", "transient"])( | 275 | 279 | cache, | 276 | 280 | ); | 277 | 281 | expect(await second[1]!.loadContents!()).toBe(contents); | 278 | | - expect(await first[1]!.loadContents!()).toBeNull(); | 279 | | - expect(fetch).toHaveBeenCalledTimes(failure === "permanent" ? 2 : 3); | | 282 | + expect(await first[1]!.loadContents!()).toBe(failure === "permanent" ? null : contents); | | 283 | + expect(fetch).toHaveBeenCalledTimes(failure === "permanent" ? 2 : 4); | 280 | 284 | }, | 281 | 285 | ); | 282 | 286 |
| |
|