GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mobile): a Git confirmation only reuses the thread route that sho… · pingdotgg/t3code@31ff92c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/mobile/src/features/threads
    • git
      • GitConfirmSheet.tsx
    • thread-inspector-navigation.test.tsx
    • thread-inspector-navigation.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/src/features/threads/git/GitConfirmSheet.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { sourceControlClients } from "@t3tools/client-runtime/source-control-cli
33
import { resolveAutoFeatureBranchName } from "@t3tools/shared/git";
44
import * as Arr from "effect/Array";
55
import * as Result from "effect/Result";
6-
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
6+
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
77
import { useGT, useMessages } from "gt-react-native";
88
import { useCallback, useMemo } from "react";
99
import { View } from "react-native";
@@ -20,6 +20,7 @@ import {
2020
type GitRepositoryRouteParams,
2121
} from "../../../state/thread-git-target";
2222
import { vcsEnvironment } from "../../../state/vcs";
23+
import { useReturnToThread } from "../thread-inspector-navigation";
2324
import { SheetActionButton } from "./gitSheetComponents";
2425

2526
type GitConfirmSheetProps = StaticScreenProps<
@@ -38,6 +39,7 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
3839
const gt = useGT();
3940
const messages = useMessages();
4041
const navigation = useNavigation();
42+
const returnToThread = useReturnToThread();
4143
const repository = gitRepositoryTargetFromRoute(props.route.params);
4244
const gitState = useSelectedThreadGitState(repository);
4345
const gitActions = useSelectedThreadGitActions(repository);
@@ -89,7 +91,7 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
8991

9092
const continuePendingAction = async () => {
9193
if (!canWriteSourceControl || !confirmAction) return;
92-
navigation.dispatch(StackActions.popTo("Thread", { environmentId, threadId }, { merge: true }));
94+
returnToThread({ environmentId, threadId });
9395
await gitActions.onRunSelectedThreadGitAction({
9496
action: confirmAction,
9597
...(params.commitMessage ? { commitMessage: params.commitMessage } : {}),
@@ -99,7 +101,7 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
99101

100102
const movePendingActionToFeatureBranch = useCallback(async () => {
101103
if (!canCreateFeatureBranch || !confirmAction) return;
102-
navigation.dispatch(StackActions.popTo("Thread", { environmentId, threadId }, { merge: true }));
104+
returnToThread({ environmentId, threadId });
103105

104106
if (includesCommit) {
105107
await gitActions.onRunSelectedThreadGitAction({
@@ -131,7 +133,7 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
131133
gitState.selectedThreadBranches,
132134
includesCommit,
133135
params,
134-
navigation,
136+
returnToThread,
135137
environmentId,
136138
threadId,
137139
]);
Collapse file

‎apps/mobile/src/features/threads/thread-inspector-navigation.test.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/thread-inspector-navigation.test.tsx
+39-2Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ vi.mock("@react-navigation/native", async () => {
2929
};
3030
});
3131

32-
import { useOpenThreadInspector } from "./thread-inspector-navigation";
32+
import { useOpenThreadInspector, useReturnToThread } from "./thread-inspector-navigation";
3333
import { useOpenLinkedThread, useOpenLinkedThreadRead } from "./useOpenLinkedThread";
3434

3535
const requireNavigation = NodeModule.createRequire(
@@ -45,7 +45,15 @@ function setup(fromAgents: boolean, fullscreen = false, inspectorSupported = tru
4545
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
4646
const router = StackRouter({});
4747
const options = {
48-
routeNames: ["Home", "Thread", "ThreadAgents", "ThreadInspectorFullscreen", "LinkedThread"],
48+
routeNames: [
49+
"Home",
50+
"Thread",
51+
"ThreadAgents",
52+
"ThreadInspectorFullscreen",
53+
"LinkedThread",
54+
"ThreadReview",
55+
"GitConfirm",
56+
],
4957
routeParamList: {},
5058
routeGetIdList: {},
5159
};
@@ -70,14 +78,17 @@ function setup(fromAgents: boolean, fullscreen = false, inspectorSupported = tru
7078
let openInspector: ReturnType<typeof useOpenThreadInspector>;
7179
let openLinkedThread: ReturnType<typeof useOpenLinkedThread>;
7280
let openLinkedThreadRead: ReturnType<typeof useOpenLinkedThreadRead>;
81+
let returnToThread: ReturnType<typeof useReturnToThread>;
7382
function Probe() {
7483
const open = useOpenThreadInspector();
7584
const openLinked = useOpenLinkedThread();
7685
const openLinkedRead = useOpenLinkedThreadRead();
86+
const returnTo = useReturnToThread();
7787
useLayoutEffect(() => {
7888
openInspector = open;
7989
openLinkedThread = openLinked;
8090
openLinkedThreadRead = openLinkedRead;
91+
returnToThread = returnTo;
8192
});
8293
return null;
8394
}
@@ -103,6 +114,9 @@ function setup(fromAgents: boolean, fullscreen = false, inspectorSupported = tru
103114
openLinkedRead(...input: Parameters<typeof openLinkedThreadRead>) {
104115
act(() => openLinkedThreadRead(...input));
105116
},
117+
returnTo(thread: Parameters<typeof returnToThread>[0]) {
118+
act(() => returnToThread(thread));
119+
},
106120
[Symbol.dispose]() {
107121
act(() => root.unmount());
108122
},
@@ -190,6 +204,29 @@ it.each([
190204
},
191205
);
192206

207+
it.each([
208+
{ confirmFrom: "parent", routes: ["Home", "Thread"] },
209+
// A side thread's review, opened from the parent's inspector, sits above the parent's route.
210+
{ confirmFrom: "child", routes: ["Home", "Thread", "ThreadReview", "Thread"] },
211+
])(
212+
"returns from a Git confirmation to the $confirmFrom thread without replacing another",
213+
({ confirmFrom, routes }) => {
214+
using screen = setup(false);
215+
const inspector = { type: "device", ...screen.source } as const;
216+
screen.open(inspector);
217+
const thread = { ...screen.source, threadId: confirmFrom };
218+
if (confirmFrom !== "parent") screen.dispatch(StackActions.push("ThreadReview", thread));
219+
screen.dispatch(StackActions.push("GitConfirm", thread));
220+
screen.returnTo(thread);
221+
expect(screen.state.routes.map((route) => route.name)).toEqual(routes);
222+
expect(screen.state.routes[1]).toMatchObject({
223+
key: screen.parentKey,
224+
params: { ...screen.source, prompt: "retained prompt", inspector },
225+
});
226+
expect(screen.state.routes.at(-1)?.params).toMatchObject(thread);
227+
},
228+
);
229+
193230
it("switches between subagents and devices in the same parent route", () => {
194231
using screen = setup(false);
195232
screen.open({ type: "thread", environmentId: screen.source.environmentId, threadId: "child" });
Collapse file

‎apps/mobile/src/features/threads/thread-inspector-navigation.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/thread-inspector-navigation.ts
+29-9Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,39 @@ export function useOpenThreadInspector() {
4141
if (presentation === "full-screen") return false;
4242
if (openInInspector) openInInspector(target);
4343
else {
44-
const parent = navigation.getState()?.routes.findLast((route) => route.name === "Thread");
45-
if (
46-
!parent?.params ||
47-
!("environmentId" in parent.params) ||
48-
parent.params.environmentId !== source.environmentId ||
49-
!("threadId" in parent.params) ||
50-
parent.params.threadId !== source.threadId
51-
)
52-
return false;
44+
if (!isNearestThreadRoute(navigation.getState(), source)) return false;
5345
navigation.dispatch(
5446
StackActions.popTo("Thread", { ...source, inspector: target }, { merge: true }),
5547
);
5648
}
5749
return true;
5850
};
5951
}
52+
53+
/** Closes the screens above `thread`, or opens it when the nearest thread route is another one. */
54+
export function useReturnToThread() {
55+
const navigation = useNavigation();
56+
return (thread: { readonly environmentId: string; readonly threadId: string }) =>
57+
navigation.dispatch(
58+
isNearestThreadRoute(navigation.getState(), thread)
59+
? StackActions.popTo("Thread", thread, { merge: true })
60+
: StackActions.replace("Thread", thread),
61+
);
62+
}
63+
64+
// `Thread` has no `getId`, so `popTo("Thread")` lands on the nearest one whatever thread it shows.
65+
function isNearestThreadRoute(
66+
state:
67+
| { readonly routes: ReadonlyArray<{ readonly name: string; readonly params?: object }> }
68+
| undefined,
69+
thread: { readonly environmentId: string; readonly threadId: string },
70+
) {
71+
const params = state?.routes.findLast((route) => route.name === "Thread")?.params;
72+
return (
73+
params !== undefined &&
74+
"environmentId" in params &&
75+
params.environmentId === thread.environmentId &&
76+
"threadId" in params &&
77+
params.threadId === thread.threadId
78+
);
79+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.