diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx index 4b97b8f759..999cec2d66 100644 --- a/apps/mobile/src/features/home/HomeScreen.tsx +++ b/apps/mobile/src/features/home/HomeScreen.tsx @@ -250,9 +250,13 @@ export function HomeScreen(props: HomeScreenProps) { groupKey={item.group.key} onGroupAction={updateGroupDisplay} // Aggregated groups (same repo across machines) have no single - // target project, so the quick new-thread button is single-project only. + // target project, and `pending-project:` groups hold a placeholder + // built from queued-task metadata rather than a real project shell, + // so the quick new-thread button is single-real-project only. onNewThread={ - item.group.projects.length === 1 ? props.onNewThreadInProject : undefined + item.group.projects.length === 1 && !item.group.key.startsWith("pending-project:") + ? props.onNewThreadInProject + : undefined } project={item.group.representative} threadCount={item.group.threads.length + item.group.pendingTasks.length} diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx index 27b39c4f1b..5f5353c6ef 100644 --- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx @@ -1,5 +1,10 @@ import { NativeStackScreenOptions } from "../../native/StackHeader"; -import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native"; +import { + StackActions, + useFocusEffect, + useNavigation, + type StaticScreenProps, +} from "@react-navigation/native"; import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react"; import * as Option from "effect/Option"; import { EnvironmentId, ThreadId, type ProjectScript } from "@t3tools/contracts"; @@ -636,6 +641,22 @@ function ThreadRouteContent( ], [panes.primarySidebarVisible, props.onReturnToThread, navigation, togglePrimarySidebar], ); + // Deep links / cold starts land with Thread as the ONLY route, where the + // native back button does not render. Provide an explicit Home escape for + // that case; when history exists the native back button is used instead. + const canGoBack = navigation.canGoBack(); + const compactHomeHeaderItems = useMemo( + () => [ + withNativeGlassHeaderItem({ + accessibilityLabel: "Go to threads list", + icon: { name: "list.bullet", type: "sfSymbol" as const }, + identifier: "thread-left-home", + onPress: () => navigation.dispatch(StackActions.replace("Home")), + type: "button" as const, + }), + ], + [navigation], + ); if (!environmentId || !threadId) { return ; @@ -720,11 +741,17 @@ function ThreadRouteContent( : undefined, title: selectedThread.title, headerBackVisible: !layout.usesSplitView, - // Compact uses the NATIVE back button (Thread lives flat in the root - // stack now, so a real previous route exists); only split view needs - // custom left items. + // Compact uses the NATIVE back button when a previous route exists; + // deep links / cold starts get an explicit Home button instead. + // Split view always uses its custom left items. unstable_headerLeftItems: - Platform.OS === "ios" && layout.usesSplitView ? () => splitLeftHeaderItems : undefined, + Platform.OS === "ios" + ? layout.usesSplitView + ? () => splitLeftHeaderItems + : canGoBack + ? undefined + : () => compactHomeHeaderItems + : undefined, // Search lives in the persistent sidebar, so the split header keeps // the git controls on the RIGHT (no center items — center space is // reserved for future breadcrumbs/status). diff --git a/apps/mobile/src/features/threads/new-task-flow-provider.tsx b/apps/mobile/src/features/threads/new-task-flow-provider.tsx index 7c3759d2dd..1590728b92 100644 --- a/apps/mobile/src/features/threads/new-task-flow-provider.tsx +++ b/apps/mobile/src/features/threads/new-task-flow-provider.tsx @@ -279,19 +279,33 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) { // Only offer machines that actually host the currently selected repository, so // switching computers moves the same repo across machines instead of jumping to - // whatever unrelated project happens to be first on the other machine. + // whatever unrelated project happens to be first on the other machine. Repository + // identity is the primary signal; projects that haven't reported one yet (still + // indexing) fall back to workspace basename / title so a valid host isn't hidden. const selectedRepositoryKey = selectedProject?.repositoryIdentity?.canonicalKey ?? null; + const selectedWorkspaceBasename = selectedProject?.workspaceRoot.split("/").at(-1) ?? null; + const selectedProjectTitle = selectedProject?.title ?? null; const environments = useMemo(() => { const seen = new Set(); const result: Array<{ readonly environmentId: EnvironmentId; readonly environmentLabel: string; }> = []; + const hostsSelectedRepository = (project: EnvironmentProject) => { + if (selectedRepositoryKey === null && selectedWorkspaceBasename === null) { + return true; + } + const projectKey = project.repositoryIdentity?.canonicalKey ?? null; + if (selectedRepositoryKey !== null && projectKey !== null) { + return projectKey === selectedRepositoryKey; + } + return ( + project.workspaceRoot.split("/").at(-1) === selectedWorkspaceBasename || + (selectedProjectTitle !== null && project.title === selectedProjectTitle) + ); + }; for (const project of projects) { - if ( - selectedRepositoryKey !== null && - (project.repositoryIdentity?.canonicalKey ?? null) !== selectedRepositoryKey - ) { + if (!hostsSelectedRepository(project)) { continue; } if (seen.has(project.environmentId)) { @@ -308,7 +322,13 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) { }); } return result; - }, [projects, savedConnectionsById, selectedRepositoryKey]); + }, [ + projects, + savedConnectionsById, + selectedRepositoryKey, + selectedWorkspaceBasename, + selectedProjectTitle, + ]); const selectedEnvironmentServerConfig = useEnvironmentServerConfig( selectedProject?.environmentId ?? null, diff --git a/apps/mobile/src/features/threads/thread-list-items.tsx b/apps/mobile/src/features/threads/thread-list-items.tsx index dbb341111a..baea38bb47 100644 --- a/apps/mobile/src/features/threads/thread-list-items.tsx +++ b/apps/mobile/src/features/threads/thread-list-items.tsx @@ -45,7 +45,6 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props: readonly onGroupAction: (key: string, action: HomeGroupDisplayAction) => void; readonly onNewThread?: (project: EnvironmentProject) => void; }) { - const iconSubtleColor = useThemeColor("--color-icon-subtle"); const iconMutedColor = useThemeColor("--color-icon-muted"); const { groupKey, onGroupAction, onNewThread, project } = props; const compact = props.variant === "compact"; @@ -57,14 +56,11 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props: // The new-thread button is a SIBLING of the collapse toggle, not a child: // nested touchables are unreachable to VoiceOver/TalkBack (the parent - // swallows focus), so the row is a plain View with two adjacent pressables. + // swallows focus). The row padding lives on the pressables themselves so + // the whole padded strip is tappable, not just the inner content. return ( @@ -108,28 +106,26 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props: ({ opacity: pressed ? 0.5 : 1, marginRight: compact ? 10 : 8 })} + style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1 })} > - ) : null} - - - + ) : ( + + )} ); });