Match Mail sidebar selection on iPad

This commit is contained in:
Julius Marminge committed 2026-06-30 00:37:24 -07:00
1 parent f5d4d7b63c
commit b00deefb03
2 files changed
+170 -137

No files matched your search

@@ -69,6 +69,12 @@ function compactMenuStatus(gitStatus: VcsStatusResult | null): string {
type HeaderItems = ReturnType<
NonNullable<NativeStackNavigationOptions["unstable_headerRightItems"]>
>;
type HeaderItem = HeaderItems[number];
type ThreadGitHeaderActionItems = {
readonly terminal: HeaderItem;
readonly files: HeaderItem;
readonly git: HeaderItem;
};
type QuickActionIcon =
| "arrow.down.circle"
| "arrow.up.right.circle"
@@ -238,139 +244,138 @@ function useThreadGitControlModel(props: ThreadGitControlsProps) {
};
}
function useThreadGitHeaderActionItems(props: ThreadGitControlsProps): HeaderItems {
function useThreadGitHeaderActionItems(props: ThreadGitControlsProps): ThreadGitHeaderActionItems {
const model = useThreadGitControlModel(props);
return useMemo(
() =>
[
{
accessibilityLabel: "Open terminal",
disabled: !props.canOpenTerminal,
icon: { name: "terminal", type: "sfSymbol" },
identifier: "thread-right-terminal",
label: "Terminal",
menu: {
items: [
...props.projectScripts.map((script) => ({
description: script.command,
icon: { name: projectScriptMenuIcon(script.icon), type: "sfSymbol" as const },
label: projectScriptMenuLabel(script),
onPress: () => void props.onRunProjectScript(script),
type: "action" as const,
})),
...(props.projectScripts.length === 0
? [
{
description: "This project has no saved scripts yet",
disabled: true,
icon: { name: "play", type: "sfSymbol" as const },
label: "No project scripts",
onPress: () => {},
type: "action" as const,
},
]
: []),
...props.terminalSessions.map((session) => ({
description: [
getTerminalStatusLabel({
status: session.status,
hasRunningSubprocess: session.hasRunningSubprocess,
}),
basename(session.cwd),
() => ({
terminal: {
accessibilityLabel: "Open terminal",
disabled: !props.canOpenTerminal,
icon: { name: "terminal", type: "sfSymbol" },
identifier: "thread-right-terminal",
label: "Terminal",
menu: {
items: [
...props.projectScripts.map((script) => ({
description: script.command,
icon: { name: projectScriptMenuIcon(script.icon), type: "sfSymbol" as const },
label: projectScriptMenuLabel(script),
onPress: () => void props.onRunProjectScript(script),
type: "action" as const,
})),
...(props.projectScripts.length === 0
? [
{
description: "This project has no saved scripts yet",
disabled: true,
icon: { name: "play", type: "sfSymbol" as const },
label: "No project scripts",
onPress: () => {},
type: "action" as const,
},
]
.filter(Boolean)
.join(" · "),
icon: { name: "terminal", type: "sfSymbol" as const },
label: session.displayLabel,
onPress: () => props.onOpenTerminal(session.terminalId),
type: "action" as const,
})),
{
description: "Start another shell for this thread",
icon: { name: "plus", type: "sfSymbol" },
label: "Open new terminal",
onPress: props.onOpenNewTerminal,
type: "action",
},
],
title: "Terminal",
},
sharesBackground: true,
type: "menu",
variant: "prominent",
width: 58,
: []),
...props.terminalSessions.map((session) => ({
description: [
getTerminalStatusLabel({
status: session.status,
hasRunningSubprocess: session.hasRunningSubprocess,
}),
basename(session.cwd),
]
.filter(Boolean)
.join(" · "),
icon: { name: "terminal", type: "sfSymbol" as const },
label: session.displayLabel,
onPress: () => props.onOpenTerminal(session.terminalId),
type: "action" as const,
})),
{
description: "Start another shell for this thread",
icon: { name: "plus", type: "sfSymbol" },
label: "Open new terminal",
onPress: props.onOpenNewTerminal,
type: "action",
},
],
title: "Terminal",
},
{
accessibilityLabel: "Open files",
disabled: !props.canOpenFiles,
icon: { name: "folder", type: "sfSymbol" },
identifier: "thread-right-files",
label: "Files",
onPress: model.openFiles,
sharesBackground: true,
type: "button",
variant: "prominent",
width: 58,
sharesBackground: true,
type: "menu",
variant: "prominent",
width: 58,
},
files: {
accessibilityLabel: "Open files",
disabled: !props.canOpenFiles,
icon: { name: "folder", type: "sfSymbol" },
identifier: "thread-right-files",
label: "Files",
onPress: model.openFiles,
sharesBackground: true,
type: "button",
variant: "prominent",
width: 58,
},
git: {
accessibilityLabel: "Git actions",
icon: { name: "point.topleft.down.curvedto.point.bottomright.up", type: "sfSymbol" },
identifier: "thread-right-git",
label: "Git",
menu: {
items: [
{
description: compactMenuStatus(props.gitStatus),
disabled: true,
icon: {
name: "point.topleft.down.curvedto.point.bottomright.up",
type: "sfSymbol",
},
label: compactMenuBranchLabel(model.currentBranchLabel),
onPress: () => {},
type: "action",
},
{
description: model.quickActionHint ?? undefined,
disabled: model.quickAction.disabled,
icon: { name: model.quickActionIcon, type: "sfSymbol" },
label: model.quickAction.label,
onPress: () => void model.runQuickAction(),
type: "action",
},
{
description: "Turn diffs and worktree changes",
disabled: !model.isRepo,
icon: { name: "text.bubble", type: "sfSymbol" },
label: "Review changes",
onPress: model.openReview,
type: "action",
},
{
description: "Browse this workspace",
disabled: !props.canOpenFiles,
icon: { name: "folder", type: "sfSymbol" },
label: "Files",
onPress: model.openFiles,
type: "action",
},
{
description: "Commit, files, branches",
icon: { name: "ellipsis.circle", type: "sfSymbol" },
label: "More",
onPress: model.openGitInspector,
type: "action",
},
],
title: "Git",
},
{
accessibilityLabel: "Git actions",
icon: { name: "point.topleft.down.curvedto.point.bottomright.up", type: "sfSymbol" },
identifier: "thread-right-git",
label: "Git",
menu: {
items: [
{
description: compactMenuStatus(props.gitStatus),
disabled: true,
icon: {
name: "point.topleft.down.curvedto.point.bottomright.up",
type: "sfSymbol",
},
label: compactMenuBranchLabel(model.currentBranchLabel),
onPress: () => {},
type: "action",
},
{
description: model.quickActionHint ?? undefined,
disabled: model.quickAction.disabled,
icon: { name: model.quickActionIcon, type: "sfSymbol" },
label: model.quickAction.label,
onPress: () => void model.runQuickAction(),
type: "action",
},
{
description: "Turn diffs and worktree changes",
disabled: !model.isRepo,
icon: { name: "text.bubble", type: "sfSymbol" },
label: "Review changes",
onPress: model.openReview,
type: "action",
},
{
description: "Browse this workspace",
disabled: !props.canOpenFiles,
icon: { name: "folder", type: "sfSymbol" },
label: "Files",
onPress: model.openFiles,
type: "action",
},
{
description: "Commit, files, branches",
icon: { name: "ellipsis.circle", type: "sfSymbol" },
label: "More",
onPress: model.openGitInspector,
type: "action",
},
],
title: "Git",
},
sharesBackground: true,
type: "menu",
variant: "prominent",
width: 58,
},
] as HeaderItems,
sharesBackground: true,
type: "menu",
variant: "prominent",
width: 58,
},
}),
[
model.currentBranchLabel,
model.isRepo,
@@ -396,13 +401,16 @@ function useThreadGitHeaderActionItems(props: ThreadGitControlsProps): HeaderIte
export function useThreadGitRightHeaderItems(props: ThreadGitControlsProps): HeaderItems {
const actionItems = useThreadGitHeaderActionItems(props);
return useMemo(() => actionItems.toReversed() as HeaderItems, [actionItems]);
return useMemo(
() => [actionItems.git, actionItems.files, actionItems.terminal] as HeaderItems,
[actionItems],
);
}
export function useThreadGitCenterHeaderItems(props: ThreadGitControlsProps): HeaderItems {
const actionItems = useThreadGitHeaderActionItems(props);
return useMemo(
() => [actionItems[1], actionItems[2], actionItems[0]].filter(Boolean) as HeaderItems,
() => [actionItems.files, actionItems.git, actionItems.terminal] as HeaderItems,
[actionItems],
);
}
@@ -72,6 +72,9 @@ const ThreadNavigationRow = memo(function ThreadNavigationRow(props: {
readonly pressedBackgroundColor: ColorValue;
readonly selected: boolean;
readonly selectedBackgroundColor: ColorValue;
readonly selectedForegroundColor: ColorValue;
readonly selectedMutedColor: ColorValue;
readonly selectedPressedBackgroundColor: ColorValue;
readonly simultaneousSwipeGesture?: ComponentProps<
typeof ThreadSwipeable
>["simultaneousWithExternalGesture"];
@@ -93,10 +96,18 @@ const ThreadNavigationRow = memo(function ThreadNavigationRow(props: {
pressedBackgroundColor,
selected,
selectedBackgroundColor,
selectedForegroundColor,
selectedMutedColor,
selectedPressedBackgroundColor,
simultaneousSwipeGesture,
thread,
environmentLabel,
} = props;
const effectiveForegroundColor = selected ? selectedForegroundColor : foregroundColor;
const effectiveMutedColor = selected ? selectedMutedColor : mutedColor;
const effectivePressedBackgroundColor = selected
? selectedPressedBackgroundColor
: pressedBackgroundColor;
const handleArchive = useCallback(() => {
onArchiveThread(thread);
}, [onArchiveThread, thread]);
@@ -162,7 +173,8 @@ const ThreadNavigationRow = memo(function ThreadNavigationRow(props: {
style={({ pressed }) => [
styles.threadSelectionTarget,
{
backgroundColor: pressed || hovered ? pressedBackgroundColor : "transparent",
backgroundColor:
pressed || hovered ? effectivePressedBackgroundColor : "transparent",
cursor: "pointer",
},
]}
@@ -171,7 +183,7 @@ const ThreadNavigationRow = memo(function ThreadNavigationRow(props: {
<Text
className="text-base font-t3-medium"
numberOfLines={1}
style={{ color: foregroundColor }}
style={{ color: effectiveForegroundColor }}
>
{thread.title}
</Text>
@@ -180,12 +192,12 @@ const ThreadNavigationRow = memo(function ThreadNavigationRow(props: {
<Text
className="min-w-0 flex-1 text-xs"
numberOfLines={1}
style={{ color: mutedColor }}
style={{ color: effectiveMutedColor }}
>
{subtitle.join(" · ")}
</Text>
) : null}
<Text className="text-xs" numberOfLines={1} style={{ color: mutedColor }}>
<Text className="text-xs" numberOfLines={1} style={{ color: effectiveMutedColor }}>
{relativeTime(thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt)}
</Text>
</View>
@@ -199,10 +211,15 @@ const ThreadNavigationRow = memo(function ThreadNavigationRow(props: {
hitSlop={6}
style={({ pressed }) => [
styles.moreButton,
{ backgroundColor: pressed ? pressedBackgroundColor : "transparent" },
{ backgroundColor: pressed ? effectivePressedBackgroundColor : "transparent" },
]}
>
<SymbolView name="ellipsis" size={15} tintColor={iconColor} type="monochrome" />
<SymbolView
name="ellipsis"
size={15}
tintColor={selected ? effectiveMutedColor : iconColor}
type="monochrome"
/>
</Pressable>
</ControlPillMenu>
</View>
@@ -420,8 +437,10 @@ export function ThreadNavigationSidebar(props: {
const placeholderColor = useThemeColor("--color-placeholder");
const searchBackgroundColor =
colorScheme === "dark" ? IOS_SEARCH_FILL_DARK : IOS_SEARCH_FILL_LIGHT;
const selectedBackgroundColor =
colorScheme === "dark" ? "rgba(255,255,255,0.12)" : "rgba(0,0,0,0.08)";
const selectedBackgroundColor = useThemeColor("--color-user-bubble");
const selectedForegroundColor = useThemeColor("--color-user-bubble-foreground");
const selectedMutedColor = useThemeColor("--color-user-bubble-foreground-muted");
const selectedPressedBackgroundColor = "rgba(255,255,255,0.16)";
const pressedBackgroundColor = useThemeColor("--color-subtle");
const listThemeKey = `${colorScheme}:${String(backgroundColor)}:${String(selectedBackgroundColor)}`;
const listExtraData = `${listThemeKey}:${props.selectedThreadKey ?? ""}`;
@@ -501,6 +520,9 @@ export function ThreadNavigationSidebar(props: {
pressedBackgroundColor={pressedBackgroundColor}
selected={item.key === props.selectedThreadKey}
selectedBackgroundColor={selectedBackgroundColor}
selectedForegroundColor={selectedForegroundColor}
selectedMutedColor={selectedMutedColor}
selectedPressedBackgroundColor={selectedPressedBackgroundColor}
simultaneousSwipeGesture={sidebarScrollGesture}
thread={thread}
environmentLabel={savedConnectionsById[thread.environmentId]?.environmentLabel ?? null}
@@ -521,6 +543,9 @@ export function ThreadNavigationSidebar(props: {
props.width,
savedConnectionsById,
selectedBackgroundColor,
selectedForegroundColor,
selectedMutedColor,
selectedPressedBackgroundColor,
listThemeKey,
mutedColor,
],