Skip to content

Commit 5efa2df

Browse files
author
Julius Marminge
committed
Address mobile review lifecycle issues
1 parent e4ec3cf commit 5efa2df

6 files changed

Lines changed: 60 additions & 19 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
492492
}
493493

494494
func setTokensPatchJson(_ tokensPatchJson: String) {
495+
let contentResetKey = self.contentResetKey
496+
495497
payloadDecodeQueue.async { [weak self] in
496498
guard let data = tokensPatchJson.data(using: .utf8) else {
497499
return
@@ -503,6 +505,9 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
503505
guard let self else {
504506
return
505507
}
508+
guard contentResetKey == self.contentResetKey else {
509+
return
510+
}
506511
// A highlighter request from the previous file can finish after the view has
507512
// already reset. Never let that stale patch roll the native token state back.
508513
if let resetKey = patch.resetKey, resetKey != self.tokensResetKey {
@@ -550,6 +555,7 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
550555
}
551556

552557
self.contentResetKey = contentResetKey
558+
rowsDecodeGeneration += 1
553559
tokensDecodeGeneration += 1
554560
contentView.tokensByRowId = [:]
555561
hasAppliedInitialRowIndex = false

‎apps/mobile/plugins/withIosSceneLifecycle.cjs‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,37 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1212
) {
1313
guard
1414
let windowScene = scene as? UIWindowScene,
15-
let appDelegate = UIApplication.shared.delegate as? AppDelegate,
16-
let appWindow = appDelegate.window
15+
let appDelegate = UIApplication.shared.delegate as? AppDelegate
1716
else {
1817
return
1918
}
2019
20+
let appWindow: UIWindow
21+
if let existingWindow = appDelegate.window {
22+
appWindow = existingWindow
23+
} else {
24+
appWindow = UIWindow(windowScene: windowScene)
25+
appDelegate.window = appWindow
26+
appDelegate.reactNativeFactory?.startReactNative(
27+
withModuleName: "main",
28+
in: appWindow,
29+
launchOptions: nil)
30+
}
31+
2132
window = appWindow
2233
appWindow.windowScene = windowScene
2334
appWindow.makeKeyAndVisible()
2435
2536
if let url = connectionOptions.urlContexts.first?.url {
2637
_ = appDelegate.application(UIApplication.shared, open: url, options: [:])
2738
}
39+
40+
if let userActivity = connectionOptions.userActivities.first {
41+
_ = appDelegate.application(
42+
UIApplication.shared,
43+
continue: userActivity,
44+
restorationHandler: { _ in })
45+
}
2846
}
2947
3048
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {

‎apps/mobile/src/app/_layout.tsx‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { useResolveClassNames } from "uniwind";
1616

1717
import { LoadingScreen } from "../components/LoadingScreen";
1818

19-
import { useWorkspaceState } from "../state/workspace";
2019
import { useThreadOutboxDrain } from "../state/use-thread-outbox-drain";
2120
import { RegistryContext } from "@effect/atom-react";
2221
import { appAtomRegistry } from "../state/atom-registry";
@@ -47,16 +46,11 @@ function AppNavigator() {
4746
}
4847

4948
function AppNavigatorContent() {
50-
const { state } = useWorkspaceState();
5149
const colorScheme = useColorScheme();
5250
const statusBarBg = useThemeColor("--color-status-bar");
5351
useAgentNotificationNavigation();
5452
useThreadOutboxDrain();
5553

56-
if (state.isLoadingConnections) {
57-
return <LoadingScreen message="Loading remote workspace…" />;
58-
}
59-
6054
return (
6155
<>
6256
<StatusBar

‎apps/mobile/src/app/new/_layout.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function NewTaskCloseButton() {
2222
accessibilityRole="button"
2323
className="h-9 w-9 items-center justify-center rounded-full bg-subtle active:opacity-70"
2424
hitSlop={8}
25-
onPress={() => router.back()}
25+
onPress={() => router.dismiss()}
2626
>
2727
<SymbolView name="xmark" size={14} tintColor={String(tintColor)} type="monochrome" />
2828
</Pressable>

‎apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,6 @@ export function ThreadFilesTreeScreen() {
538538
[projectName],
539539
);
540540

541-
if (selectedThread === null || environmentId === null || threadId === null) {
542-
return <LoadingScreen message="Opening files..." messagePlacement="above-spinner" />;
543-
}
544-
545-
if (cwd === null) {
546-
return <FilesUnavailable />;
547-
}
548-
549541
if (fileInspector.supported) {
550542
return (
551543
<ThreadRouteScreen
@@ -555,6 +547,14 @@ export function ThreadFilesTreeScreen() {
555547
);
556548
}
557549

550+
if (selectedThread === null || environmentId === null || threadId === null) {
551+
return <LoadingScreen message="Opening files..." messagePlacement="above-spinner" />;
552+
}
553+
554+
if (cwd === null) {
555+
return <FilesUnavailable />;
556+
}
557+
558558
return (
559559
<View className="flex-1 bg-sheet">
560560
<Stack.Screen
@@ -652,6 +652,15 @@ export function ThreadFileScreen() {
652652
assetPreviewUri === null || previewRevision === 0
653653
? assetPreviewUri
654654
: `${assetPreviewUri}${assetPreviewUri.includes("?") ? "&" : "?"}revision=${previewRevision}`;
655+
const handleReturnToThread = useCallback(() => {
656+
if (router.canGoBack()) {
657+
router.back();
658+
return;
659+
}
660+
if (environmentId !== null && threadId !== null) {
661+
router.replace(buildThreadRoutePath({ environmentId, threadId }));
662+
}
663+
}, [environmentId, router, threadId]);
655664
const needsFileContents =
656665
relativePath !== null &&
657666
(resolvedActiveMode === "source" || isMarkdownPreviewFile(relativePath));
@@ -692,6 +701,15 @@ export function ThreadFileScreen() {
692701
[cwd, environmentId, fileInspector.supported, handleSelectFile, projectName, relativePath],
693702
);
694703

704+
if (fileInspector.supported && environmentId !== null && threadId !== null) {
705+
return (
706+
<ThreadRouteScreen
707+
onReturnToThread={handleReturnToThread}
708+
renderInspector={renderInspector}
709+
/>
710+
);
711+
}
712+
695713
if (selectedThread === null || environmentId === null || threadId === null) {
696714
return <LoadingScreen message="Opening file..." messagePlacement="above-spinner" />;
697715
}

‎apps/mobile/src/features/threads/ThreadRouteScreen.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,14 @@ function ThreadRouteContent(
418418
if (selectedThread === null) {
419419
return;
420420
}
421-
router.push(buildThreadFilesNavigation(selectedThread, path));
421+
const navigation = buildThreadFilesNavigation(selectedThread, path);
422+
if (fileInspector.supported) {
423+
router.replace(navigation);
424+
return;
425+
}
426+
router.push(navigation);
422427
},
423-
[router, selectedThread],
428+
[fileInspector.supported, router, selectedThread],
424429
);
425430
const GitInspector = useCallback(
426431
() => <GitOverviewSheet headerInset={headerHeight} presentation="inspector" />,

0 commit comments

Comments
 (0)