Group header polish + second-round review fixes

- Replace the pencil icon with a larger plus, flush right with full-height
  padded hit area; drop the fold/unfold chevron (title press still toggles).
- Give the collapse toggle back its padded hit area (was reduced when
  padding moved to the outer View).
- Hide the quick new-thread button on synthetic pending-project groups.
- Environment picker: fall back to workspace basename/title matching when
  either side lacks repositoryIdentity, so still-indexing hosts stay visible.
- Deep-link/cold-start threads (no back stack) get an explicit header
  button to reach the threads list.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Theo BrowneandClaude Fable 5 committed 2026-07-04 06:29:21 -07:00
1 parent 3edb72e016
commit 3fd7f73c95
4 files changed
+81 -34

No files matched your search

+6 -2
View File
@@ -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}
@@ -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<NativeHeaderItems>(
() => [
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 <OpeningThreadLoadingScreen />;
@@ -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).
@@ -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<EnvironmentId>();
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,
@@ -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 (
<View
className={
compact
? `flex-row items-center gap-2.5 bg-screen px-5 pb-3 ${props.isFirst ? "pt-2" : "pt-6"}`
: `flex-row items-center gap-2 px-3 pb-2 ${props.isFirst ? "pt-1" : "pt-5"}`
}
className={compact ? "flex-row items-center bg-screen" : "flex-row items-center"}
style={{ minHeight: compact ? 44 : 36 }}
>
<Pressable
@@ -73,7 +69,9 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props:
accessibilityLabel={`${props.title}, ${props.threadCount} threads`}
accessibilityHint={props.collapsed ? "Expands the project" : "Collapses the project"}
className={
compact ? "flex-1 flex-row items-center gap-2.5" : "flex-1 flex-row items-center gap-2"
compact
? `flex-1 flex-row items-center gap-2.5 pl-5 pb-3 ${props.isFirst ? "pt-2" : "pt-6"}`
: `flex-1 flex-row items-center gap-2 pl-3 pb-2 ${props.isFirst ? "pt-1" : "pt-5"}`
}
onPress={handleToggle}
>
@@ -108,28 +106,26 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props:
<Pressable
accessibilityLabel={`Create new thread in ${props.title}`}
accessibilityRole="button"
className={
compact
? `pl-4 pr-5 pb-3 ${props.isFirst ? "pt-2" : "pt-6"}`
: `pl-3 pr-3 pb-2 ${props.isFirst ? "pt-1" : "pt-5"}`
}
hitSlop={8}
onPress={handleNewThread}
style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1, marginRight: compact ? 10 : 8 })}
style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1 })}
>
<SymbolView
name="square.and.pencil"
size={compact ? 16 : 14}
name="plus"
size={compact ? 20 : 16}
tintColor={iconMutedColor}
type="monochrome"
weight="medium"
/>
</Pressable>
) : null}
<Pressable accessible={false} hitSlop={8} onPress={handleToggle}>
<SymbolView
name={props.collapsed ? "chevron.right" : "chevron.down"}
size={compact ? 13 : 11}
tintColor={iconSubtleColor}
type="monochrome"
weight="semibold"
/>
</Pressable>
) : (
<View className={compact ? "w-5" : "w-3"} />
)}
</View>
);
});