Skip to content

Commit 06553ad

Browse files
perf(mobile): new task flow, git sheets, thread settings and work log compile with the React Compiler
The new task flow (provider, draft, route, context pickers), thread settings sheet, git overview and commit sheets, git controls, question attachments, usage-limit recovery card, work log and composer command menu. try/finally became .finally() on the async body, the draft's latest-value refs are written in a layout effect, the consumed share id is state, and the recovery card's reset-passed check is a timer-driven state instead of a render-time clock read. Manual useMemo/useCallback/memo are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 5ed0cf6 commit 06553ad

13 files changed

Lines changed: 1463 additions & 1965 deletions

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

Lines changed: 65 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from "@t3tools/client-runtime/state/runtime";
1414
import * as Haptics from "expo-haptics";
1515
import { useNavigation } from "@react-navigation/native";
16-
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
16+
import { useEffect, useRef, useState, type ReactNode } from "react";
1717
import { Platform, Pressable, ScrollView, TextInput, View } from "react-native";
1818
import { useSafeAreaInsets } from "react-native-safe-area-context";
1919

@@ -155,7 +155,7 @@ function BranchSelectionRow(props: {
155155
readonly onSelect: (branch: VcsRef) => void;
156156
readonly selected: boolean;
157157
}) {
158-
const onPress = useCallback(() => props.onSelect(props.branch), [props.branch, props.onSelect]);
158+
const onPress = () => props.onSelect(props.branch);
159159

160160
return (
161161
<View
@@ -290,67 +290,56 @@ export function NewTaskBranchPickerRouteScreen() {
290290
[navigation],
291291
);
292292

293-
const selectBranch = useCallback(
294-
async (branch: VcsRef) => {
295-
const needsCheckout = shouldCheckoutNewTaskBranch({
296-
branchIsCurrent: branch.current,
297-
branchWorktreePath: branch.worktreePath,
293+
const selectBranch = async (branch: VcsRef) => {
294+
const needsCheckout = shouldCheckoutNewTaskBranch({
295+
branchIsCurrent: branch.current,
296+
branchWorktreePath: branch.worktreePath,
297+
workspaceMode: flow.workspaceMode,
298+
});
299+
if (selectingBranchNameRef.current !== null || (needsCheckout && !canWriteSourceControl)) {
300+
return;
301+
}
302+
selectingBranchNameRef.current = branch.name;
303+
void Haptics.selectionAsync();
304+
305+
return await (async () => {
306+
if (!flow.selectedProject) return;
307+
setSwitchingBranchName(branch.name);
308+
const result = await checkoutNewTaskBranch({
309+
branch,
310+
project: flow.selectedProject,
298311
workspaceMode: flow.workspaceMode,
312+
switchRef,
299313
});
300-
if (selectingBranchNameRef.current !== null || (needsCheckout && !canWriteSourceControl)) {
314+
if (result._tag === "Failure") {
315+
if (mountedRef.current && navigation.isFocused() && !isAtomCommandInterrupted(result)) {
316+
const error = squashAtomCommandFailure(result);
317+
Dialog.alert(
318+
"Could not switch branch",
319+
error instanceof Error ? error.message : "The branch could not be checked out.",
320+
);
321+
}
301322
return;
302323
}
303-
selectingBranchNameRef.current = branch.name;
304-
void Haptics.selectionAsync();
305-
306-
try {
307-
if (!flow.selectedProject) return;
308-
setSwitchingBranchName(branch.name);
309-
const result = await checkoutNewTaskBranch({
310-
branch,
311-
project: flow.selectedProject,
312-
workspaceMode: flow.workspaceMode,
313-
switchRef,
314-
});
315-
if (result._tag === "Failure") {
316-
if (mountedRef.current && navigation.isFocused() && !isAtomCommandInterrupted(result)) {
317-
const error = squashAtomCommandFailure(result);
318-
Dialog.alert(
319-
"Could not switch branch",
320-
error instanceof Error ? error.message : "The branch could not be checked out.",
321-
);
322-
}
323-
return;
324-
}
325324

326-
// The checkout has already changed the repository. Persist the matching
327-
// draft selection even if the native sheet was dismissed while the
328-
// command was in flight; only visible-screen work is focus-gated below.
329-
flow.selectBranch(result.value);
330-
if (!mountedRef.current || !navigation.isFocused()) {
331-
return;
332-
}
333-
flow.setBranchQuery("");
334-
allowSelectionNavigationRef.current = true;
335-
navigation.goBack();
336-
} finally {
337-
selectingBranchNameRef.current = null;
338-
allowSelectionNavigationRef.current = false;
339-
if (mountedRef.current) {
340-
setSwitchingBranchName(null);
341-
}
325+
// The checkout has already changed the repository. Persist the matching
326+
// draft selection even if the native sheet was dismissed while the
327+
// command was in flight; only visible-screen work is focus-gated below.
328+
flow.selectBranch(result.value);
329+
if (!mountedRef.current || !navigation.isFocused()) {
330+
return;
342331
}
343-
},
344-
[
345-
canWriteSourceControl,
346-
flow.selectBranch,
347-
flow.selectedProject,
348-
flow.setBranchQuery,
349-
flow.workspaceMode,
350-
navigation,
351-
switchRef,
352-
],
353-
);
332+
flow.setBranchQuery("");
333+
allowSelectionNavigationRef.current = true;
334+
navigation.goBack();
335+
})().finally(() => {
336+
selectingBranchNameRef.current = null;
337+
allowSelectionNavigationRef.current = false;
338+
if (mountedRef.current) {
339+
setSwitchingBranchName(null);
340+
}
341+
});
342+
};
354343

355344
return (
356345
<BranchPickerScreen
@@ -413,38 +402,26 @@ export function BranchPickerScreen(props: {
413402
props.branches.find((branch) => branch.current)?.name ??
414403
props.branches.find((branch) => branch.isDefault)?.name ??
415404
null;
416-
const branchListContentStyle = useMemo(
417-
() => ({
418-
paddingBottom: usesNativeMailSearchToolbar
419-
? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16
420-
: Platform.OS === "ios"
421-
? 16
422-
: Math.max(insets.bottom, 16) + 16,
423-
paddingHorizontal: 16,
424-
paddingTop: 16,
425-
}),
426-
[insets.bottom, usesNativeMailSearchToolbar],
427-
);
405+
const branchListContentStyle = {
406+
paddingBottom: usesNativeMailSearchToolbar
407+
? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16
408+
: Platform.OS === "ios"
409+
? 16
410+
: Math.max(insets.bottom, 16) + 16,
411+
paddingHorizontal: 16,
412+
paddingTop: 16,
413+
};
428414

429-
const renderBranch = useCallback(
430-
({ item, index }: { readonly item: VcsRef; readonly index: number }) => (
431-
<BranchSelectionRow
432-
badge={branchBadgeLabel({ branch: item, project: props.project })}
433-
branch={item}
434-
disabled={props.selectionDisabled ?? false}
435-
isFirst={index === 0}
436-
isLast={index === props.branches.length - 1}
437-
onSelect={props.onSelect}
438-
selected={selectedBranchName === item.name}
439-
/>
440-
),
441-
[
442-
props.branches.length,
443-
props.project,
444-
props.onSelect,
445-
selectedBranchName,
446-
props.selectionDisabled,
447-
],
415+
const renderBranch = ({ item, index }: { readonly item: VcsRef; readonly index: number }) => (
416+
<BranchSelectionRow
417+
badge={branchBadgeLabel({ branch: item, project: props.project })}
418+
branch={item}
419+
disabled={props.selectionDisabled ?? false}
420+
isFirst={index === 0}
421+
isLast={index === props.branches.length - 1}
422+
onSelect={props.onSelect}
423+
selected={selectedBranchName === item.name}
424+
/>
448425
);
449426

450427
const branchListHeader = props.worktree ? (

0 commit comments

Comments
 (0)