The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
fix(mobile): a changed-file pick no longer resets an earlier diff of the same PR (#39171)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 19, 2026 at 17:28 UTC
e231dafb7631f4ec50c4eba9c019649538a02bc1
4 files changed
+43
-32
apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
+2
-3
@@ -31,7 +31,7 @@ import {
31
} from "./usePullRequestDiff";
32
import { usePullRequestFileFilter } from "./usePullRequestFileFilter";
33
import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
34
-import { pullRequestFileJumpScope, requestPullRequestFileJump } from "./pullRequestFileJump";
34
+import { requestPullRequestFileJump } from "./pullRequestFileJump";
35
import type { MessageResolver } from "../../i18n/messages";
36
37
const BREAKDOWN_LABELS = {
@@ -442,7 +442,6 @@ export function PullRequestFilesSheet({ route }: StaticScreenProps<PullRequestDi
442
const navigation = useNavigation();
443
const gt = useGT();
444
const m = useMessages();
445
- const jumpScope = pullRequestFileJumpScope(params);
445
const files = useChangedFiles(params);
446
const { diff, filter, viewed, parsed, loading } = files;
447
const [collapsed, setCollapsed] = useState<ReadonlySet<string>>(() => new Set());
@@ -500,7 +499,7 @@ export function PullRequestFilesSheet({ route }: StaticScreenProps<PullRequestDi
499
file={item.file}
500
viewed={viewed.isViewed(item.file.path)}
501
onPress={() => {
503
- requestPullRequestFileJump(jumpScope, item.file.path);
502
+ requestPullRequestFileJump(navigation.getState()?.routes ?? [], item.file.path);
503
navigation.dispatch(
504
StackActions.popTo("PullRequestFile", {
505
...params,
apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+9
-4
@@ -51,7 +51,12 @@ import {
51
} from "./pullRequestDiffDebug";
52
import { usePullRequestDiffHighlightFiles } from "./usePullRequestDiffHighlightFiles";
53
import { isTestChangedFile } from "@t3tools/shared/changedFileKind";
54
-import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";
54
+import {
55
+ useFocusEffect,
56
+ useNavigation,
57
+ useRoute,
58
+ type StaticScreenProps,
59
+} from "@react-navigation/native";
60
import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
61
import { RegistryContext, useAtomRefresh, useAtomValue } from "@effect/atom-react";
62
import { pullRequestReviewKey } from "./pullRequestReviewDrafts";
@@ -134,7 +139,7 @@ import { PullRequestMergeControls } from "./PullRequestMergeControls";
139
import { PullRequestStackCard } from "./PullRequestStackCard";
140
import { usePullRequestStack, type PullRequestStackState } from "./usePullRequestStack";
141
import { usePullRequestEnvironmentFallback } from "./usePullRequestEnvironmentFallback";
137
-import { pullRequestFileJumpScope, subscribePullRequestFileJump } from "./pullRequestFileJump";
142
+import { subscribePullRequestFileJump } from "./pullRequestFileJump";
143
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
144
import { changeRequestTermKind } from "../../lib/changeRequestTerm";
145
@@ -1172,7 +1177,7 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
1177
jumpedUnder.current = null;
1178
});
1179
};
1175
- const jumpScope = pullRequestFileJumpScope(route.params);
1180
+ const routeKey = useRoute().key;
1181
const jumpToFile = useEffectEvent((path: string) => {
1182
setJumpPath(path);
1183
setSelectedRowId(null);
@@ -1185,7 +1190,7 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
1190
// Subscribed for the whole screen, so a pick made while the diff is still loading is kept for
1191
// the first draw.
1192
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to pull request file jump requests for the screen's lifetime
1188
- useEffect(() => subscribePullRequestFileJump(jumpScope, (path) => jumpToFile(path)), [jumpScope]);
1193
+ useEffect(() => subscribePullRequestFileJump(routeKey, (path) => jumpToFile(path)), [routeKey]);
1194
const { nativeReviewDiffStyle } = useAppearanceCodeSurface();
1195
const { themeAppearance, appearance, setCodeWordBreak } = useAppearancePreferences();
1196
const bridge = useNativeReviewDiffBridge({
apps/mobile/src/features/pull-requests/pullRequestFileJump.test.ts
+19
-12
@@ -2,17 +2,24 @@ import { describe, expect, it } from "vite-plus/test";
2
import { requestPullRequestFileJump, subscribePullRequestFileJump } from "./pullRequestFileJump";
3
4
describe("pull request file jumps", () => {
5
- it("delivers a pick to the screens of its scope, every time it is made", () => {
6
- const seen: string[] = [];
7
- const other: string[] = [];
8
- const stop = subscribePullRequestFileJump("a", (path) => seen.push(path));
9
- const stopOther = subscribePullRequestFileJump("b", (path) => other.push(path));
10
- requestPullRequestFileJump("a", "src/x.ts");
11
- requestPullRequestFileJump("a", "src/x.ts");
12
- stop();
13
- requestPullRequestFileJump("a", "src/y.ts");
14
- stopOther();
15
- expect(seen).toEqual(["src/x.ts", "src/x.ts"]);
16
- expect(other).toEqual([]);
5
+ it("delivers a pick only to the file diff the sheet returns to, every time it is made", () => {
6
+ const earlier: string[] = [];
7
+ const nearest: string[] = [];
8
+ const stopEarlier = subscribePullRequestFileJump("file-1", (path) => earlier.push(path));
9
+ const stopNearest = subscribePullRequestFileJump("file-2", (path) => nearest.push(path));
10
+ const routes = [
11
+ { key: "pr", name: "PullRequest" },
12
+ { key: "file-1", name: "PullRequestFile" },
13
+ { key: "discussion", name: "PullRequestDiscussion" },
14
+ { key: "file-2", name: "PullRequestFile" },
15
+ { key: "files", name: "PullRequestFiles" },
16
+ ];
17
+ requestPullRequestFileJump(routes, "src/x.ts");
18
+ requestPullRequestFileJump(routes, "src/x.ts");
19
+ stopNearest();
20
+ requestPullRequestFileJump(routes, "src/y.ts");
21
+ stopEarlier();
22
+ expect(nearest).toEqual(["src/x.ts", "src/x.ts"]);
23
+ expect(earlier).toEqual([]);
24
});
25
});
apps/mobile/src/features/pull-requests/pullRequestFileJump.ts
+13
-13
@@ -1,26 +1,26 @@
1
-import type { PullRequestDiffParams } from "./usePullRequestDiff";
2
-import { pullRequestReviewKey } from "./pullRequestReviewDrafts";
3
-
1
// The changed-files sheet hands its pick to the diff screen beneath it. Picking the file the
2
// screen already shows still jumps back to it, which a route param that did not change could not
3
// say. A screen that is not mounted yet opens at its `path` param instead.
4
type Listener = (path: string) => void;
5
const listeners = new Map<string, Set<Listener>>();
6
10
-export function pullRequestFileJumpScope(params: PullRequestDiffParams): string {
11
- return JSON.stringify([pullRequestReviewKey(params), params.commit ?? null]);
12
-}
13
-
14
-export function requestPullRequestFileJump(scope: string, path: string): void {
15
- for (const listener of listeners.get(scope) ?? []) listener(path);
7
+// The sheet pops to the nearest file diff (`StackActions.popTo`), so only that screen jumps; an
8
+// earlier diff of the same pull request further down the stack keeps its file and selection.
9
+export function requestPullRequestFileJump(
10
+ routes: ReadonlyArray<{ readonly key: string; readonly name: string }>,
11
+ path: string,
12
+): void {
13
+ const target = routes.findLast((route) => route.name === "PullRequestFile");
14
+ if (!target) return;
15
+ for (const listener of listeners.get(target.key) ?? []) listener(path);
16
}
17
18
-export function subscribePullRequestFileJump(scope: string, listener: Listener): () => void {
19
- let scoped = listeners.get(scope);
20
- if (!scoped) listeners.set(scope, (scoped = new Set()));
18
+export function subscribePullRequestFileJump(routeKey: string, listener: Listener): () => void {
19
+ let scoped = listeners.get(routeKey);
20
+ if (!scoped) listeners.set(routeKey, (scoped = new Set()));
21
scoped.add(listener);
22
return () => {
23
scoped.delete(listener);
24
- if (scoped.size === 0) listeners.delete(scope);
24
+ if (scoped.size === 0) listeners.delete(routeKey);
25
};
26
}