Recover stale mobile thread routes
This commit is contained in:
1 parent
a4472d0f49
commit
59af9dce68
4 files changed
+102
-18
No files matched your search
@@ -66,7 +66,7 @@ function compactMenuStatus(gitStatus: VcsStatusResult | null): string {
|
||||
return parts.join(" · ");
|
||||
}
|
||||
|
||||
type HeaderRightItems = ReturnType<
|
||||
type HeaderItems = ReturnType<
|
||||
NonNullable<NativeStackNavigationOptions["unstable_headerRightItems"]>
|
||||
>;
|
||||
type QuickActionIcon =
|
||||
@@ -238,7 +238,7 @@ function useThreadGitControlModel(props: ThreadGitControlsProps) {
|
||||
};
|
||||
}
|
||||
|
||||
export function useThreadGitRightHeaderItems(props: ThreadGitControlsProps): HeaderRightItems {
|
||||
function useThreadGitHeaderActionItems(props: ThreadGitControlsProps): HeaderItems {
|
||||
const model = useThreadGitControlModel(props);
|
||||
|
||||
return useMemo(
|
||||
@@ -370,7 +370,7 @@ export function useThreadGitRightHeaderItems(props: ThreadGitControlsProps): Hea
|
||||
variant: "prominent",
|
||||
width: 58,
|
||||
},
|
||||
].toReversed() as HeaderRightItems,
|
||||
] as HeaderItems,
|
||||
[
|
||||
model.currentBranchLabel,
|
||||
model.isRepo,
|
||||
@@ -394,6 +394,15 @@ export function useThreadGitRightHeaderItems(props: ThreadGitControlsProps): Hea
|
||||
);
|
||||
}
|
||||
|
||||
export function useThreadGitRightHeaderItems(props: ThreadGitControlsProps): HeaderItems {
|
||||
const actionItems = useThreadGitHeaderActionItems(props);
|
||||
return useMemo(() => actionItems.toReversed() as HeaderItems, [actionItems]);
|
||||
}
|
||||
|
||||
export function useThreadGitCenterHeaderItems(props: ThreadGitControlsProps): HeaderItems {
|
||||
return useThreadGitHeaderActionItems(props);
|
||||
}
|
||||
|
||||
export function ThreadGitControls(props: ThreadGitControlsProps) {
|
||||
const model = useThreadGitControlModel(props);
|
||||
const showActionControls = props.showActionControls ?? true;
|
||||
|
||||
@@ -2,12 +2,16 @@ import { useGlobalSearchParams } from "expo-router";
|
||||
import { createContext, createElement, use, useMemo, useRef, type ReactNode } from "react";
|
||||
import {
|
||||
EnvironmentId,
|
||||
type OrchestrationThread,
|
||||
ThreadId,
|
||||
type ScopedProjectRef,
|
||||
type ScopedThreadRef,
|
||||
} from "@t3tools/contracts";
|
||||
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
|
||||
import * as Option from "effect/Option";
|
||||
|
||||
import { useProject, useThreadShell } from "../state/entities";
|
||||
import { useEnvironmentThread } from "../state/threads";
|
||||
import {
|
||||
useRemoteEnvironmentRuntime,
|
||||
useSavedRemoteConnection,
|
||||
@@ -21,6 +25,43 @@ function firstRouteParam(value: string | string[] | undefined): string | null {
|
||||
return value ?? null;
|
||||
}
|
||||
|
||||
function latestUserMessageAt(thread: OrchestrationThread): OrchestrationThread["updatedAt"] | null {
|
||||
for (let index = thread.messages.length - 1; index >= 0; index -= 1) {
|
||||
const message = thread.messages[index];
|
||||
if (message?.role === "user") {
|
||||
return message.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function threadDetailToShell(
|
||||
environmentId: EnvironmentId,
|
||||
thread: OrchestrationThread,
|
||||
): EnvironmentThreadShell {
|
||||
return {
|
||||
environmentId,
|
||||
id: thread.id,
|
||||
projectId: thread.projectId,
|
||||
title: thread.title,
|
||||
modelSelection: thread.modelSelection,
|
||||
runtimeMode: thread.runtimeMode,
|
||||
interactionMode: thread.interactionMode,
|
||||
branch: thread.branch,
|
||||
worktreePath: thread.worktreePath,
|
||||
latestTurn: thread.latestTurn,
|
||||
createdAt: thread.createdAt,
|
||||
updatedAt: thread.updatedAt,
|
||||
archivedAt: thread.archivedAt,
|
||||
session: thread.session,
|
||||
latestUserMessageAt: latestUserMessageAt(thread),
|
||||
hasPendingApprovals: false,
|
||||
hasPendingUserInput: false,
|
||||
hasActionableProposedPlan: false,
|
||||
};
|
||||
}
|
||||
|
||||
function useResolvedThreadSelection() {
|
||||
const params = useGlobalSearchParams<{
|
||||
environmentId?: string | string[];
|
||||
@@ -43,7 +84,20 @@ function useResolvedThreadSelection() {
|
||||
lastRouteThreadRef.current = routeThreadRef;
|
||||
}
|
||||
const selectedThreadRef = routeThreadRef ?? lastRouteThreadRef.current;
|
||||
const selectedThread = useThreadShell(selectedThreadRef);
|
||||
const selectedThreadShell = useThreadShell(selectedThreadRef);
|
||||
const selectedThreadDetailState = useEnvironmentThread(
|
||||
selectedThreadRef?.environmentId ?? null,
|
||||
selectedThreadRef?.threadId ?? null,
|
||||
);
|
||||
const selectedThreadDetail = Option.getOrNull(selectedThreadDetailState.data);
|
||||
const selectedThread = useMemo(
|
||||
() =>
|
||||
selectedThreadShell ??
|
||||
(selectedThreadRef !== null && selectedThreadDetail !== null
|
||||
? threadDetailToShell(selectedThreadRef.environmentId, selectedThreadDetail)
|
||||
: null),
|
||||
[selectedThreadDetail, selectedThreadRef, selectedThreadShell],
|
||||
);
|
||||
const selectedProjectRef = useMemo<ScopedProjectRef | null>(
|
||||
() =>
|
||||
selectedThread === null
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
diff --git a/build/react-navigation/native-stack/types.d.ts b/build/react-navigation/native-stack/types.d.ts
|
||||
index 6de73e0c33cedbaaaffdcb092ba21fc9ff71862e..93845c781609c1a46bf71f2c30ef81432fb56bc2 100644
|
||||
index 6de73e0c33cedbaaaffdcb092ba21fc9ff71862e..78929fe237b7f9d7808f8de2b844e822976e0d69 100644
|
||||
--- a/build/react-navigation/native-stack/types.d.ts
|
||||
+++ b/build/react-navigation/native-stack/types.d.ts
|
||||
@@ -306,6 +306,22 @@ export type NativeStackNavigationOptions = {
|
||||
@@ -306,6 +306,31 @@ export type NativeStackNavigationOptions = {
|
||||
* @platform ios
|
||||
*/
|
||||
unstable_headerRightItems?: (props: NativeStackHeaderItemProps) => NativeStackHeaderItem[];
|
||||
+ /**
|
||||
+ * Function which returns an array of items to display as the centered item
|
||||
+ * group in modern iOS headers.
|
||||
+ *
|
||||
+ * This is an unstable API and might change in the future.
|
||||
+ *
|
||||
+ * @platform ios
|
||||
+ */
|
||||
+ unstable_headerCenterItems?: (props: NativeStackHeaderItemProps) => NativeStackHeaderItem[];
|
||||
+ /**
|
||||
+ * Function which returns an array of toolbar items for the current screen.
|
||||
+ *
|
||||
+ * This is an unstable API and might change in the future.
|
||||
@@ -25,18 +34,18 @@ index 6de73e0c33cedbaaaffdcb092ba21fc9ff71862e..93845c781609c1a46bf71f2c30ef8143
|
||||
/**
|
||||
* String or a function that returns a React Element to be used by the header.
|
||||
* Defaults to screen `title` or route name.
|
||||
@@ -1115,7 +1131,8 @@ export type NativeStackHeaderItemCustom = {
|
||||
@@ -1115,7 +1140,8 @@ export type NativeStackHeaderItemCustom = {
|
||||
* if the items don't fit the available space, they will be collapsed into a menu automatically.
|
||||
* Items with `type: 'custom'` will not be included in this automatic collapsing behavior.
|
||||
*/
|
||||
-export type NativeStackHeaderItem = NativeStackHeaderItemButton | NativeStackHeaderItemMenu | NativeStackHeaderItemSpacing | NativeStackHeaderItemCustom;
|
||||
+export type NativeStackHeaderRawRNSItem = NonNullable<ScreenStackHeaderConfigProps['headerLeftBarButtonItems']>[number] | NonNullable<ScreenStackHeaderConfigProps['headerRightBarButtonItems']>[number];
|
||||
+export type NativeStackHeaderRawRNSItem = NonNullable<ScreenStackHeaderConfigProps['headerLeftBarButtonItems']>[number] | NonNullable<ScreenStackHeaderConfigProps['headerRightBarButtonItems']>[number] | NonNullable<ScreenStackHeaderConfigProps['headerCenterBarButtonItems']>[number];
|
||||
+export type NativeStackHeaderItem = NativeStackHeaderItemButton | NativeStackHeaderItemMenu | NativeStackHeaderItemSpacing | NativeStackHeaderItemCustom | NativeStackHeaderRawRNSItem;
|
||||
export type NativeStackNavigatorProps = DefaultNavigatorOptions<ParamListBase, string | undefined, StackNavigationState<ParamListBase>, NativeStackNavigationOptions, NativeStackNavigationEventMap, NativeStackNavigationProp<ParamListBase>> & StackRouterOptions & NativeStackNavigationConfig;
|
||||
export type NativeStackDescriptor = Descriptor<NativeStackNavigationOptions, NativeStackNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;
|
||||
export type NativeStackDescriptorMap = {
|
||||
diff --git a/build/react-navigation/native-stack/views/useHeaderConfigProps.d.ts b/build/react-navigation/native-stack/views/useHeaderConfigProps.d.ts
|
||||
index 218c4291fdb57600a45d32fbcefe3707a520fe79..ce3bbadec2d52949d133401f1df01b95899aa5bf 100644
|
||||
index 218c4291fdb57600a45d32fbcefe3707a520fe79..5fdbb2754755a27589ad1555eae892b5fbee2c6a 100644
|
||||
--- a/build/react-navigation/native-stack/views/useHeaderConfigProps.d.ts
|
||||
+++ b/build/react-navigation/native-stack/views/useHeaderConfigProps.d.ts
|
||||
@@ -10,6 +10,6 @@ type Props = NativeStackNavigationOptions & {
|
||||
@@ -44,11 +53,11 @@ index 218c4291fdb57600a45d32fbcefe3707a520fe79..ce3bbadec2d52949d133401f1df01b95
|
||||
route: Route<string>;
|
||||
};
|
||||
-export declare function useHeaderConfigProps({ headerBackIcon, headerBackImageSource, headerBackButtonDisplayMode, headerBackButtonMenuEnabled, headerBackTitle, headerBackTitleStyle, headerBackVisible, headerShadowVisible, headerLargeStyle, headerLargeTitle: headerLargeTitleDeprecated, headerLargeTitleEnabled, headerLargeTitleShadowVisible, headerLargeTitleStyle, headerBackground, headerLeft, headerRight, headerShown, headerStyle, headerBlurEffect, headerTintColor, headerTitle, headerTitleAlign, headerTitleStyle, headerTransparent, headerSearchBarOptions, headerTopInsetEnabled, headerBack, route, title, unstable_headerLeftItems: headerLeftItems, unstable_headerRightItems: headerRightItems, }: Props): ScreenStackHeaderConfigProps;
|
||||
+export declare function useHeaderConfigProps({ headerBackIcon, headerBackImageSource, headerBackButtonDisplayMode, headerBackButtonMenuEnabled, headerBackTitle, headerBackTitleStyle, headerBackVisible, headerShadowVisible, headerLargeStyle, headerLargeTitle: headerLargeTitleDeprecated, headerLargeTitleEnabled, headerLargeTitleShadowVisible, headerLargeTitleStyle, headerBackground, headerLeft, headerRight, headerShown, headerStyle, headerBlurEffect, headerTintColor, headerTitle, headerTitleAlign, headerTitleStyle, headerTransparent, headerSearchBarOptions, headerTopInsetEnabled, headerBack, route, title, unstable_headerLeftItems: headerLeftItems, unstable_headerRightItems: headerRightItems, unstable_headerToolbarItems: headerToolbarItems, unstable_navigationItemStyle: navigationItemStyle, }: Props): ScreenStackHeaderConfigProps;
|
||||
+export declare function useHeaderConfigProps({ headerBackIcon, headerBackImageSource, headerBackButtonDisplayMode, headerBackButtonMenuEnabled, headerBackTitle, headerBackTitleStyle, headerBackVisible, headerShadowVisible, headerLargeStyle, headerLargeTitle: headerLargeTitleDeprecated, headerLargeTitleEnabled, headerLargeTitleShadowVisible, headerLargeTitleStyle, headerBackground, headerLeft, headerRight, headerShown, headerStyle, headerBlurEffect, headerTintColor, headerTitle, headerTitleAlign, headerTitleStyle, headerTransparent, headerSearchBarOptions, headerTopInsetEnabled, headerBack, route, title, unstable_headerLeftItems: headerLeftItems, unstable_headerRightItems: headerRightItems, unstable_headerCenterItems: headerCenterItems, unstable_headerToolbarItems: headerToolbarItems, unstable_navigationItemStyle: navigationItemStyle, }: Props): ScreenStackHeaderConfigProps;
|
||||
export {};
|
||||
//# sourceMappingURL=useHeaderConfigProps.d.ts.map
|
||||
diff --git a/build/react-navigation/native-stack/views/useHeaderConfigProps.js b/build/react-navigation/native-stack/views/useHeaderConfigProps.js
|
||||
index 2de6d160cedffb4ffb124adf7cd10979ec6ee778..ed9651d5bcce56594c6a1946b2cb6a8f11f80c7c 100644
|
||||
index 2de6d160cedffb4ffb124adf7cd10979ec6ee778..9d839442e00e136204630663f207a45c950dcd25 100644
|
||||
--- a/build/react-navigation/native-stack/views/useHeaderConfigProps.js
|
||||
+++ b/build/react-navigation/native-stack/views/useHeaderConfigProps.js
|
||||
@@ -22,6 +22,9 @@ const processBarButtonItems = (items, colors, fonts) => {
|
||||
@@ -66,14 +75,26 @@ index 2de6d160cedffb4ffb124adf7cd10979ec6ee778..ed9651d5bcce56594c6a1946b2cb6a8f
|
||||
};
|
||||
};
|
||||
-function useHeaderConfigProps({ headerBackIcon, headerBackImageSource, headerBackButtonDisplayMode, headerBackButtonMenuEnabled, headerBackTitle, headerBackTitleStyle, headerBackVisible, headerShadowVisible, headerLargeStyle, headerLargeTitle: headerLargeTitleDeprecated, headerLargeTitleEnabled = headerLargeTitleDeprecated, headerLargeTitleShadowVisible, headerLargeTitleStyle, headerBackground, headerLeft, headerRight, headerShown, headerStyle, headerBlurEffect, headerTintColor, headerTitle, headerTitleAlign, headerTitleStyle, headerTransparent, headerSearchBarOptions, headerTopInsetEnabled, headerBack, route, title, unstable_headerLeftItems: headerLeftItems, unstable_headerRightItems: headerRightItems, }) {
|
||||
+function useHeaderConfigProps({ headerBackIcon, headerBackImageSource, headerBackButtonDisplayMode, headerBackButtonMenuEnabled, headerBackTitle, headerBackTitleStyle, headerBackVisible, headerShadowVisible, headerLargeStyle, headerLargeTitle: headerLargeTitleDeprecated, headerLargeTitleEnabled = headerLargeTitleDeprecated, headerLargeTitleShadowVisible, headerLargeTitleStyle, headerBackground, headerLeft, headerRight, headerShown, headerStyle, headerBlurEffect, headerTintColor, headerTitle, headerTitleAlign, headerTitleStyle, headerTransparent, headerSearchBarOptions, headerTopInsetEnabled, headerBack, route, title, unstable_headerLeftItems: headerLeftItems, unstable_headerRightItems: headerRightItems, unstable_headerToolbarItems: headerToolbarItems, unstable_navigationItemStyle: navigationItemStyle, }) {
|
||||
+function useHeaderConfigProps({ headerBackIcon, headerBackImageSource, headerBackButtonDisplayMode, headerBackButtonMenuEnabled, headerBackTitle, headerBackTitleStyle, headerBackVisible, headerShadowVisible, headerLargeStyle, headerLargeTitle: headerLargeTitleDeprecated, headerLargeTitleEnabled = headerLargeTitleDeprecated, headerLargeTitleShadowVisible, headerLargeTitleStyle, headerBackground, headerLeft, headerRight, headerShown, headerStyle, headerBlurEffect, headerTintColor, headerTitle, headerTitleAlign, headerTitleStyle, headerTransparent, headerSearchBarOptions, headerTopInsetEnabled, headerBack, route, title, unstable_headerLeftItems: headerLeftItems, unstable_headerRightItems: headerRightItems, unstable_headerCenterItems: headerCenterItems, unstable_headerToolbarItems: headerToolbarItems, unstable_navigationItemStyle: navigationItemStyle, }) {
|
||||
const { direction } = (0, native_1.useLocale)();
|
||||
const { colors, fonts, dark } = (0, native_1.useTheme)();
|
||||
const tintColor = headerTintColor ?? (react_native_1.Platform.OS === 'ios' ? colors.primary : colors.text);
|
||||
@@ -270,6 +273,8 @@ function useHeaderConfigProps({ headerBackIcon, headerBackImageSource, headerBac
|
||||
@@ -216,6 +219,10 @@ function useHeaderConfigProps({ headerBackIcon, headerBackImageSource, headerBac
|
||||
tintColor,
|
||||
canGoBack,
|
||||
});
|
||||
+ const centerItems = headerCenterItems?.({
|
||||
+ tintColor,
|
||||
+ canGoBack,
|
||||
+ });
|
||||
if (rightItems) {
|
||||
// iOS renders right items in reverse order
|
||||
// So we need to reverse them here to match the order
|
||||
@@ -270,6 +277,9 @@ function useHeaderConfigProps({ headerBackIcon, headerBackImageSource, headerBac
|
||||
children,
|
||||
headerLeftBarButtonItems: processBarButtonItems(leftItems, colors, fonts),
|
||||
headerRightBarButtonItems: processBarButtonItems(rightItems, colors, fonts),
|
||||
+ headerCenterBarButtonItems: processBarButtonItems(centerItems, colors, fonts),
|
||||
+ headerToolbarItems,
|
||||
+ navigationItemStyle,
|
||||
experimental_userInterfaceStyle: dark ? 'dark' : 'light',
|
||||
|
||||
Generated
+5
-5
@@ -72,7 +72,7 @@ patchedDependencies:
|
||||
'@pierre/[email protected]': 7cb6da88544119adda056b2f46f43956f99326227732da0b345081e285a6c53a
|
||||
[email protected]: c502bc684210b707dfceb87d8fe6ad6843395af6e19cfc02cd65854898bde2c5
|
||||
[email protected]: 9170f8074ae4e35a0a086e756c8f815794fd3abe51eac67ca3ba02804225ec1f
|
||||
[email protected]: 7b915c5a27d2253e9770b92ebfcd8a9f85ebb849f07bdfa8d85af76ea0231215
|
||||
[email protected]: d63025d5ca8999d61e090361acb374aebe9917ae1da7c4d65c2cc44977bd844c
|
||||
[email protected]: 825622aae63a8fb5b904f3c77908a0e216261d727ea171709f2c0b6088422675
|
||||
[email protected]: 9a555061147ecd74107ca21a77697a0515cd6a9359abbe4baf8b44295565e61b
|
||||
|
||||
@@ -309,7 +309,7 @@ importers:
|
||||
version: 0.1.15([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
expo-router:
|
||||
specifier: ~56.2.11
|
||||
version: 56.2.11(patch_hash=7b915c5a27d2253e9770b92ebfcd8a9f85ebb849f07bdfa8d85af76ea0231215)(5cd69264394276d4731a5f991997a177)
|
||||
version: 56.2.11(patch_hash=d63025d5ca8999d61e090361acb374aebe9917ae1da7c4d65c2cc44977bd844c)(708fd680682731bfd53a5282341dd27a)
|
||||
expo-secure-store:
|
||||
specifier: ~56.0.4
|
||||
version: 56.0.4([email protected])
|
||||
@@ -12003,7 +12003,7 @@ snapshots:
|
||||
ws: 8.21.0([email protected])([email protected])
|
||||
zod: 3.25.76
|
||||
optionalDependencies:
|
||||
expo-router: 56.2.11(patch_hash=7b915c5a27d2253e9770b92ebfcd8a9f85ebb849f07bdfa8d85af76ea0231215)(5cd69264394276d4731a5f991997a177)
|
||||
expo-router: 56.2.11(patch_hash=d63025d5ca8999d61e090361acb374aebe9917ae1da7c4d65c2cc44977bd844c)(708fd680682731bfd53a5282341dd27a)
|
||||
react-native: 0.85.3(@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])
|
||||
transitivePeerDependencies:
|
||||
- '@expo/dom-webview'
|
||||
@@ -12301,7 +12301,7 @@ snapshots:
|
||||
react: 19.2.3
|
||||
optionalDependencies:
|
||||
'@expo/metro-runtime': 56.0.15(@expo/[email protected])([email protected])([email protected]([email protected]))([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
expo-router: 56.2.11(patch_hash=7b915c5a27d2253e9770b92ebfcd8a9f85ebb849f07bdfa8d85af76ea0231215)(5cd69264394276d4731a5f991997a177)
|
||||
expo-router: 56.2.11(patch_hash=d63025d5ca8999d61e090361acb374aebe9917ae1da7c4d65c2cc44977bd844c)(708fd680682731bfd53a5282341dd27a)
|
||||
react-dom: 19.2.3([email protected])
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -16217,7 +16217,7 @@ snapshots:
|
||||
react: 19.2.3
|
||||
react-native: 0.85.3(@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])
|
||||
|
||||
[email protected](patch_hash=7b915c5a27d2253e9770b92ebfcd8a9f85ebb849f07bdfa8d85af76ea0231215)(5cd69264394276d4731a5f991997a177):
|
||||
[email protected](patch_hash=d63025d5ca8999d61e090361acb374aebe9917ae1da7c4d65c2cc44977bd844c)(708fd680682731bfd53a5282341dd27a):
|
||||
dependencies:
|
||||
'@expo/log-box': 56.0.13(@expo/[email protected])([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
'@expo/metro-runtime': 56.0.15(@expo/[email protected])([email protected])([email protected]([email protected]))([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
|
||||
Reference in new issue
Block a user