diff --git a/apps/mobile/app/(authenticated)/(home)/filter/_layout.tsx b/apps/mobile/app/(authenticated)/(home)/filter/_layout.tsx
index d3658240cbb..2b0558bb07d 100644
--- a/apps/mobile/app/(authenticated)/(home)/filter/_layout.tsx
+++ b/apps/mobile/app/(authenticated)/(home)/filter/_layout.tsx
@@ -9,7 +9,6 @@ export default function FilterLayout() {
}}
>
-
diff --git a/apps/mobile/app/(authenticated)/(home)/filter/project.tsx b/apps/mobile/app/(authenticated)/(home)/filter/project.tsx
deleted file mode 100644
index 65924e59a74..00000000000
--- a/apps/mobile/app/(authenticated)/(home)/filter/project.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-import { ProjectFilterScreen } from "@/screens/(authenticated)/(home)/filter/project";
-
-export default ProjectFilterScreen;
diff --git a/apps/mobile/screens/(authenticated)/(home)/filter/FilterScreen.tsx b/apps/mobile/screens/(authenticated)/(home)/filter/FilterScreen.tsx
index 40b24f48781..8566aef8702 100644
--- a/apps/mobile/screens/(authenticated)/(home)/filter/FilterScreen.tsx
+++ b/apps/mobile/screens/(authenticated)/(home)/filter/FilterScreen.tsx
@@ -1,7 +1,6 @@
import Ionicons from "@expo/vector-icons/Ionicons";
import { Stack, useRouter } from "expo-router";
import { View } from "react-native";
-import { useHostProjects } from "@/hooks/useHostProjects";
import { useTheme } from "@/hooks/useTheme";
import {
SORT_OPTIONS,
@@ -11,26 +10,13 @@ import { useSelectedHost } from "@/screens/(authenticated)/(home)/hooks/useSelec
import { HostStatusDot } from "@/screens/(authenticated)/components/HostStatusDot";
import { ListRow } from "@/screens/(authenticated)/components/ListRow";
import { ListRowValue } from "@/screens/(authenticated)/components/ListRowValue";
-import { ProjectAvatar } from "./components/ProjectAvatar";
export function FilterScreen() {
const router = useRouter();
const theme = useTheme();
- const projectFilter = useWorkspacesFilterStore(
- (store) => store.projectFilter,
- );
const selectedHost = useSelectedHost();
const sort = useWorkspacesFilterStore((store) => store.sort);
- // Projects are fully local — served by the selected host, not the cloud.
- const { projects } = useHostProjects(selectedHost);
-
- const sortedProjects = [...projects].sort((a, b) =>
- a.name.localeCompare(b.name),
- );
- const selectedProject =
- sortedProjects.find((project) => project.id === projectFilter) ??
- sortedProjects[0];
const sortLabel =
SORT_OPTIONS.find((option) => option.value === sort)?.label ?? "";
@@ -39,31 +25,6 @@ export function FilterScreen() {
router.back()} />
-
- }
- label="Project"
- trailing={
-
- ) : undefined
- }
- />
- }
- onPress={() => router.push("/(authenticated)/(home)/filter/project")}
- />
store.projectFilter,
- );
- const setProjectFilter = useWorkspacesFilterStore(
- (store) => store.setProjectFilter,
- );
-
- // Projects are fully local — served by the selected host, not the cloud.
- const { projects } = useHostProjects(selectedHost);
-
- const sortedProjects = useMemo(
- () => [...projects].sort((a, b) => a.name.localeCompare(b.name)),
- [projects],
- );
-
- const workspaceCounts = useMemo(() => {
- const counts = new Map();
- for (const workspace of workspaces) {
- // Session workspaces (null projectId) don't belong to any project.
- if (workspace.projectId === null) continue;
- counts.set(
- workspace.projectId,
- (counts.get(workspace.projectId) ?? 0) + 1,
- );
- }
- return counts;
- }, [workspaces]);
-
- const selectedProjectId = projectFilter ?? sortedProjects[0]?.id ?? null;
-
- return (
-
- {sortedProjects.map((project, index) => (
-
- }
- label={project.name}
- trailing={
- <>
-
- {workspaceCounts.get(project.id) ?? 0}
-
-
- >
- }
- onPress={() => {
- setProjectFilter(project.id);
- router.back();
- }}
- isLast={index === sortedProjects.length - 1}
- />
- ))}
-
- );
-}
diff --git a/apps/mobile/screens/(authenticated)/(home)/filter/project/index.ts b/apps/mobile/screens/(authenticated)/(home)/filter/project/index.ts
deleted file mode 100644
index b4b861634f3..00000000000
--- a/apps/mobile/screens/(authenticated)/(home)/filter/project/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { ProjectFilterScreen } from "./ProjectFilterScreen";
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/HomeScreen.tsx b/apps/mobile/screens/(authenticated)/(home)/home/HomeScreen.tsx
index e035b44b235..8a22ba21cf9 100644
--- a/apps/mobile/screens/(authenticated)/(home)/home/HomeScreen.tsx
+++ b/apps/mobile/screens/(authenticated)/(home)/home/HomeScreen.tsx
@@ -13,7 +13,6 @@ import {
useHostWorkspaces,
} from "@/hooks/useHostWorkspaces";
import { THEME } from "@/lib/theme";
-import { cn } from "@/lib/utils";
import { useSelectedHost } from "@/screens/(authenticated)/(home)/hooks/useSelectedHost";
import { useOrganizations } from "@/screens/(authenticated)/hooks/useOrganizations";
import {
@@ -25,11 +24,19 @@ import { HostOfflineView } from "./components/HostOfflineView";
import { NewChatWidget } from "./components/NewChatWidget";
import { OrganizationHeaderButton } from "./components/OrganizationHeaderButton";
import { OrganizationSwitcherSheet } from "./components/OrganizationSwitcherSheet";
+import { ProjectSectionHeader } from "./components/ProjectSectionHeader";
+import { ScopeBar } from "./components/ScopeBar";
import { WorkspaceRow } from "./components/WorkspaceRow";
import { useHostTerminals } from "./hooks/useHostTerminals";
import { useVisibleDiffStats } from "./hooks/useVisibleDiffStats";
-import { useWorkspacesFilterStore } from "./stores/workspacesFilterStore";
-import { activityDateGroup } from "./utils/activityDateGroup";
+import {
+ collapsedProjectKey,
+ useCollapsedProjectsStore,
+} from "./stores/collapsedProjectsStore";
+import {
+ SORT_OPTIONS,
+ useWorkspacesFilterStore,
+} from "./stores/workspacesFilterStore";
import { prStateFor } from "./utils/prStateFor";
const VIEWABILITY_CONFIG = {
@@ -42,21 +49,31 @@ const MAX_VISIBLE_DIFF_STATS = 20;
const NAVIGATION_BAR_HEIGHT = 44;
type HomeListItem =
- | { kind: "dateHeader"; label: string }
- | { kind: "workspace"; workspace: HostWorkspaceItem };
+ | {
+ kind: "projectHeader";
+ projectId: string;
+ name: string;
+ iconUrl?: string | null;
+ count: number;
+ collapsed: boolean;
+ }
+ | { kind: "workspace"; workspace: HostWorkspaceItem }
+ | { kind: "note"; label: string };
function homeListItemKey(item: HomeListItem): string {
- return item.kind === "dateHeader"
- ? `date:${item.label}`
- : `ws:${item.workspace.id}`;
+ switch (item.kind) {
+ case "projectHeader":
+ return `project:${item.projectId}`;
+ case "workspace":
+ return `ws:${item.workspace.id}`;
+ default:
+ return `note:${item.label}`;
+ }
}
export function HomeScreen() {
const router = useRouter();
const [sheetOpen, setSheetOpen] = useState(false);
- const projectFilter = useWorkspacesFilterStore(
- (store) => store.projectFilter,
- );
const sort = useWorkspacesFilterStore((store) => store.sort);
const hasHydrated = useWorkspacesFilterStore((store) => store.hasHydrated);
const [searchQuery, setSearchQuery] = useState("");
@@ -82,37 +99,18 @@ export function HomeScreen() {
const { projects } = useHostProjects(selectedHost);
const pullRequests = usePullRequests();
- const sortedProjects = useMemo(
- () => [...projects].sort((a, b) => a.name.localeCompare(b.name)),
- [projects],
+ const collapsed = useCollapsedProjectsStore((state) => state.collapsed);
+ const collapseHydrated = useCollapsedProjectsStore(
+ (state) => state.hasHydrated,
);
-
- // Default to where the user actually works — the most recently updated
- // workspace's project — not the alphabetically first project.
- const defaultProjectId = useMemo(() => {
- let newest: HostWorkspaceItem | null = null;
- for (const workspace of workspaces) {
- if (!workspace.projectId) continue;
- if (!newest || isAfter(workspace.updatedAt, newest.updatedAt)) {
- newest = workspace;
- }
- }
- return newest?.projectId ?? sortedProjects[0]?.id ?? null;
- }, [workspaces, sortedProjects]);
-
- // The saved project arrives a beat after mount; picking a default before
- // then flashes the wrong project's list on every cold start.
- const selectedProjectId = hasHydrated
- ? (projectFilter ?? defaultProjectId)
- : null;
-
- const projectNamesById = useMemo(
- () => new Map(projects.map((project) => [project.id, project.name])),
- [projects],
+ const toggleProject = useCollapsedProjectsStore(
+ (state) => state.toggleProject,
);
- // Recency ranks a group by its latest activity — the newest of the
- // workspace's own update and its terminals' activity.
+ const searching = searchQuery.trim().length > 0;
+
+ // Recency ranks a workspace by its latest activity — the newest of its own
+ // update and its terminals'.
const activityTs = useCallback(
(workspace: HostWorkspaceItem) => {
const workspaceTs = new Date(workspace[sort]).getTime();
@@ -126,38 +124,9 @@ export function HomeScreen() {
[sort, terminalsByWorkspace],
);
- const visibleWorkspaces = useMemo(() => {
- const needle = searchQuery.trim().toLowerCase();
- const sessionsMatch = (workspaceId: string) =>
- (terminalsByWorkspace.get(workspaceId) ?? []).some((row) =>
- row.title.toLowerCase().includes(needle),
- );
- // A record whose worktree folder is gone from the host's disk is a
- // stale shell nothing can run in — not worth a list slot.
- const withWorktree = workspaces.filter(
- (workspace) => workspace.worktreeExists !== false,
- );
- const matches = needle
- ? withWorktree.filter(
- (workspace) =>
- workspace.name.toLowerCase().includes(needle) ||
- workspace.branch.toLowerCase().includes(needle) ||
- (
- (workspace.projectId
- ? projectNamesById.get(workspace.projectId)
- : undefined) ?? ""
- )
- .toLowerCase()
- .includes(needle) ||
- sessionsMatch(workspace.id),
- )
- : withWorktree.filter(
- (workspace) =>
- workspace.projectId === selectedProjectId &&
- workspace.hostId === selectedHost?.machineId,
- );
- // Pinned first (oldest pin leads, desktop's ordering), then activity.
- return matches.sort((a, b) => {
+ // Pinned first (oldest pin leads, desktop's ordering), then activity.
+ const byPinThenActivity = useCallback(
+ (a: HostWorkspaceItem, b: HostWorkspaceItem) => {
const aPin = pinnedAt[a.id];
const bPin = pinnedAt[b.id];
if (aPin !== undefined || bPin !== undefined) {
@@ -166,31 +135,145 @@ export function HomeScreen() {
return aPin - bPin;
}
return activityTs(b) - activityTs(a);
- });
- }, [
- workspaces,
- selectedProjectId,
- selectedHost,
- searchQuery,
- projectNamesById,
- terminalsByWorkspace,
- activityTs,
- pinnedAt,
- ]);
+ },
+ [pinnedAt, activityTs],
+ );
+
+ // A record whose worktree folder is gone from the host's disk is a stale
+ // shell nothing can run in — not worth a list slot.
+ const liveWorkspaces = useMemo(
+ () => workspaces.filter((workspace) => workspace.worktreeExists !== false),
+ [workspaces],
+ );
+
+ const projectNamesById = useMemo(
+ () => new Map(projects.map((project) => [project.id, project.name])),
+ [projects],
+ );
+
+ const matchesQuery = useCallback(
+ (workspace: HostWorkspaceItem) => {
+ const needle = searchQuery.trim().toLowerCase();
+ if (!needle) return true;
+ const sessions = terminalsByWorkspace.get(workspace.id) ?? [];
+ return (
+ workspace.name.toLowerCase().includes(needle) ||
+ workspace.branch.toLowerCase().includes(needle) ||
+ (
+ (workspace.projectId
+ ? projectNamesById.get(workspace.projectId)
+ : undefined) ?? ""
+ )
+ .toLowerCase()
+ .includes(needle) ||
+ sessions.some((row) => row.title.toLowerCase().includes(needle))
+ );
+ },
+ [searchQuery, projectNamesById, terminalsByWorkspace],
+ );
const listItems = useMemo(() => {
const items: HomeListItem[] = [];
- let lastGroup: string | null = null;
- for (const workspace of visibleWorkspaces) {
- const group = activityDateGroup(activityTs(workspace));
- if (group !== lastGroup) {
- items.push({ kind: "dateHeader", label: group });
- lastGroup = group;
+ const onThisHost = liveWorkspaces.filter(
+ (workspace) => workspace.hostId === selectedHost?.machineId,
+ );
+
+ // Search reaches every project on this host but no further — the
+ // workspace query is per-host, so other machines aren't in memory to
+ // search. The count says "on this host" rather than implying otherwise.
+ const pool = searching ? onThisHost.filter(matchesQuery) : onThisHost;
+
+ if (searching) {
+ items.push({
+ kind: "note",
+ label: `${pool.length} ${pool.length === 1 ? "result" : "results"} on this host`,
+ });
+ }
+
+ // A project id the host no longer reports is as good as none: grouping
+ // under it would render the workspace nowhere, since sections come from
+ // the reported list. Also covers the beat where workspaces have loaded
+ // and projects haven't.
+ const knownProjectIds = new Set(projects.map((project) => project.id));
+ const byProject = new Map();
+ for (const workspace of pool) {
+ const projectId =
+ workspace.projectId && knownProjectIds.has(workspace.projectId)
+ ? workspace.projectId
+ : "__none";
+ const group = byProject.get(projectId);
+ if (group) group.push(workspace);
+ else byProject.set(projectId, [workspace]);
+ }
+
+ const sections = projects
+ .map((project) => ({
+ project,
+ workspaces: (byProject.get(project.id) ?? []).sort(byPinThenActivity),
+ }))
+ // A search shouldn't advertise projects it found nothing in.
+ .filter((section) => !searching || section.workspaces.length > 0)
+ .sort((a, b) => {
+ // Sections rank by their liveliest workspace, so the project you
+ // were last in leads; empty ones fall to the bottom alphabetically.
+ const first = (section: (typeof sections)[number]) =>
+ section.workspaces[0];
+ const aFirst = first(a);
+ const bFirst = first(b);
+ const aTs = aFirst ? activityTs(aFirst) : 0;
+ const bTs = bFirst ? activityTs(bFirst) : 0;
+ if (aTs !== bTs) return bTs - aTs;
+ return a.project.name.localeCompare(b.project.name);
+ });
+
+ for (const section of sections) {
+ const isCollapsed =
+ !searching &&
+ collapseHydrated &&
+ !!collapsed[
+ collapsedProjectKey(selectedHost?.machineId ?? "", section.project.id)
+ ];
+ items.push({
+ kind: "projectHeader",
+ projectId: section.project.id,
+ name: section.project.name,
+ iconUrl: section.project.iconUrl,
+ count: section.workspaces.length,
+ collapsed: isCollapsed,
+ });
+ if (isCollapsed) continue;
+ for (const workspace of section.workspaces) {
+ items.push({ kind: "workspace", workspace });
}
- items.push({ kind: "workspace", workspace });
}
+
+ // Workspaces whose project the host no longer reports still need a home.
+ const orphans = (byProject.get("__none") ?? []).sort(byPinThenActivity);
+ if (orphans.length) {
+ items.push({
+ kind: "projectHeader",
+ projectId: "__none",
+ name: "No project",
+ count: orphans.length,
+ collapsed: false,
+ });
+ for (const workspace of orphans) {
+ items.push({ kind: "workspace", workspace });
+ }
+ }
+
return items;
- }, [visibleWorkspaces, activityTs]);
+ }, [
+ liveWorkspaces,
+ selectedHost,
+ projects,
+ searching,
+ matchesQuery,
+ byPinThenActivity,
+ activityTs,
+ collapsed,
+ collapseHydrated,
+ ]);
const workspacesById = useMemo(
() => new Map(workspaces.map((workspace) => [workspace.id, workspace])),
@@ -285,19 +368,28 @@ export function HomeScreen() {
);
const renderItem = useCallback(
- ({ item, index }: { item: HomeListItem; index: number }) => {
- if (item.kind === "dateHeader") {
+ ({ item }: { item: HomeListItem }) => {
+ if (item.kind === "note") {
return (
-
+
{item.label}
);
}
+ if (item.kind === "projectHeader") {
+ return (
+ {
+ void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
+ toggleProject(selectedHost?.machineId ?? "", item.projectId);
+ }}
+ />
+ );
+ }
const { workspace } = item;
const repoPrefix = workspace.projectId
? repoPrefixesByProject.get(workspace.projectId)
@@ -326,6 +418,8 @@ export function HomeScreen() {
cache,
attentionByWorkspace,
terminalsByWorkspace,
+ toggleProject,
+ selectedHost,
],
);
@@ -334,6 +428,24 @@ export function HomeScreen() {
switchOrganization(organizationId);
};
+ const scopeBar = (
+ option.value === sort)?.label ?? ""
+ }
+ onPressHost={() => {
+ void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
+ router.push("/(authenticated)/(home)/filter/host");
+ }}
+ onPressSort={() => {
+ void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
+ router.push("/(authenticated)/(home)/filter/sort");
+ }}
+ />
+ );
+
return (
<>
setSearchQuery(event.nativeEvent.text)}
onCancelButtonPress={() => setSearchQuery("")}
/>
-
- {
- void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
- router.push("/(authenticated)/(home)/filter");
- }}
- />
-
{selectedHost && !selectedHost.isOnline ? (
+ {scopeBar}
) : (
@@ -392,6 +496,7 @@ export function HomeScreen() {
extraData={renderItem}
keyExtractor={homeListItemKey}
renderItem={renderItem}
+ ListHeaderComponent={scopeBar}
viewabilityConfig={VIEWABILITY_CONFIG}
onViewableItemsChanged={onViewableItemsChanged}
refreshControl={
@@ -401,9 +506,9 @@ export function HomeScreen() {
isReady && hasHydrated ? (
- {searchQuery.trim()
+ {searching
? "No workspaces match your search"
- : "No workspaces in this project yet"}
+ : "No projects on this host yet"}
) : null
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/components/NewChatWidget/hooks/useNewChatTargets/useNewChatTargets.ts b/apps/mobile/screens/(authenticated)/(home)/home/components/NewChatWidget/hooks/useNewChatTargets/useNewChatTargets.ts
index 12da7a123e6..a2cd587b663 100644
--- a/apps/mobile/screens/(authenticated)/(home)/home/components/NewChatWidget/hooks/useNewChatTargets/useNewChatTargets.ts
+++ b/apps/mobile/screens/(authenticated)/(home)/home/components/NewChatWidget/hooks/useNewChatTargets/useNewChatTargets.ts
@@ -40,9 +40,6 @@ export function useNewChatTargets(workspaces: HostWorkspaceItem[] = []): {
const persistedTargetKey = useNewSessionPreferencesStore(
(state) => state.targetKey,
);
- const projectFilter = useWorkspacesFilterStore(
- (state) => state.projectFilter,
- );
const preferencesHydrated = useNewSessionPreferencesStore(
(state) => state.hasHydrated,
);
@@ -108,9 +105,9 @@ export function useNewChatTargets(workspaces: HostWorkspaceItem[] = []): {
const sortedWorkspaces = [...workspaces].sort((a, b) =>
compareDesc(a.updatedAt, b.updatedAt),
);
- const candidateProjectIds = projectFilter
- ? [projectFilter]
- : sortedWorkspaces.map((workspace) => workspace.projectId);
+ const candidateProjectIds = sortedWorkspaces.map(
+ (workspace) => workspace.projectId,
+ );
for (const projectId of candidateProjectIds) {
const recentWorkspace = sortedWorkspaces.find(
(workspace) => workspace.projectId === projectId,
@@ -127,7 +124,6 @@ export function useNewChatTargets(workspaces: HostWorkspaceItem[] = []): {
}, [
targets,
persistedTargetKey,
- projectFilter,
workspaces,
preferencesHydrated,
filtersHydrated,
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/components/ProjectSectionHeader/ProjectSectionHeader.tsx b/apps/mobile/screens/(authenticated)/(home)/home/components/ProjectSectionHeader/ProjectSectionHeader.tsx
new file mode 100644
index 00000000000..05d3d9dda2b
--- /dev/null
+++ b/apps/mobile/screens/(authenticated)/(home)/home/components/ProjectSectionHeader/ProjectSectionHeader.tsx
@@ -0,0 +1,53 @@
+import { ChevronDown, ChevronRight } from "lucide-react-native";
+import { Pressable, View } from "react-native";
+import { Text } from "@/components/ui/text";
+import { useTheme } from "@/hooks/useTheme";
+import { ProjectAvatar } from "@/screens/(authenticated)/(home)/filter/components/ProjectAvatar";
+
+interface ProjectSectionHeaderProps {
+ name: string;
+ iconUrl?: string | null;
+ count: number;
+ collapsed: boolean;
+ onToggle: () => void;
+}
+
+/**
+ * A quiet band, not a title: the workspaces under it are what you came to tap,
+ * so the header labels them rather than competing with them. The count is what
+ * keeps a collapsed section informative.
+ */
+export function ProjectSectionHeader({
+ name,
+ iconUrl,
+ count,
+ collapsed,
+ onToggle,
+}: ProjectSectionHeaderProps) {
+ const theme = useTheme();
+ const Caret = collapsed ? ChevronRight : ChevronDown;
+ return (
+
+ {/* Two icons rather than one rotated: a transform on the icon itself
+ doesn't reach the underlying SVG, so it renders nothing. */}
+
+
+
+
+
+ {name}
+
+
+ {count}
+
+
+ );
+}
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/components/ProjectSectionHeader/index.ts b/apps/mobile/screens/(authenticated)/(home)/home/components/ProjectSectionHeader/index.ts
new file mode 100644
index 00000000000..f4282755af4
--- /dev/null
+++ b/apps/mobile/screens/(authenticated)/(home)/home/components/ProjectSectionHeader/index.ts
@@ -0,0 +1 @@
+export { ProjectSectionHeader } from "./ProjectSectionHeader";
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/ScopeBar.tsx b/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/ScopeBar.tsx
new file mode 100644
index 00000000000..5f4f43ac4c8
--- /dev/null
+++ b/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/ScopeBar.tsx
@@ -0,0 +1,39 @@
+import { View } from "react-native";
+import { HostStatusDot } from "@/screens/(authenticated)/components/HostStatusDot";
+import { Chip } from "./components/Chip";
+
+interface ScopeBarProps {
+ hostName: string | null;
+ hostOnline: boolean;
+ sortLabel: string;
+ onPressHost: () => void;
+ onPressSort: () => void;
+}
+
+/**
+ * Names the scope the list is actually under. The host and sort were only ever
+ * legible from inside the filter sheet, which is why a cold start never told
+ * you which machine you were looking at. It holds during search too, because
+ * search is scoped to the same host — matches elsewhere are offered as a tail
+ * rather than silently mixed in.
+ */
+export function ScopeBar({
+ hostName,
+ hostOnline,
+ sortLabel,
+ onPressHost,
+ onPressSort,
+}: ScopeBarProps) {
+ return (
+
+ {hostName ? (
+ }
+ onPress={onPressHost}
+ />
+ ) : null}
+
+
+ );
+}
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/components/Chip/Chip.tsx b/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/components/Chip/Chip.tsx
new file mode 100644
index 00000000000..c1dd8c191c7
--- /dev/null
+++ b/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/components/Chip/Chip.tsx
@@ -0,0 +1,29 @@
+import { ChevronDown } from "lucide-react-native";
+import type { ReactNode } from "react";
+import { Pressable } from "react-native";
+import { Text } from "@/components/ui/text";
+import { useTheme } from "@/hooks/useTheme";
+
+interface ChipProps {
+ label: string;
+ leading?: ReactNode;
+ onPress: () => void;
+}
+
+/** One scope, named and tappable. */
+export function Chip({ label, leading, onPress }: ChipProps) {
+ const theme = useTheme();
+ return (
+
+ {leading}
+
+ {label}
+
+
+
+ );
+}
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/components/Chip/index.ts b/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/components/Chip/index.ts
new file mode 100644
index 00000000000..6a48c332383
--- /dev/null
+++ b/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/components/Chip/index.ts
@@ -0,0 +1 @@
+export { Chip } from "./Chip";
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/index.ts b/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/index.ts
new file mode 100644
index 00000000000..928eb75554c
--- /dev/null
+++ b/apps/mobile/screens/(authenticated)/(home)/home/components/ScopeBar/index.ts
@@ -0,0 +1 @@
+export { ScopeBar } from "./ScopeBar";
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/components/WorkspaceRow/WorkspaceRow.tsx b/apps/mobile/screens/(authenticated)/(home)/home/components/WorkspaceRow/WorkspaceRow.tsx
index 253c5c36560..532ca1e84ef 100644
--- a/apps/mobile/screens/(authenticated)/(home)/home/components/WorkspaceRow/WorkspaceRow.tsx
+++ b/apps/mobile/screens/(authenticated)/(home)/home/components/WorkspaceRow/WorkspaceRow.tsx
@@ -74,7 +74,7 @@ export function WorkspaceRow({
owns the hold animation, and custom press feedback fights it. */}
@@ -128,20 +128,26 @@ export function WorkspaceRow({
)}
-
+
{workspace.name}
-
- {workspace.branch}
-
+ {/* A workspace named after its branch says it twice otherwise —
+ common now that every project shows its `main`. */}
+ {workspace.branch === workspace.name ? null : (
+
+ {workspace.branch}
+
+ )}
{diffStats &&
(diffStats.additions > 0 || diffStats.deletions > 0) ? (
<>
- ·
+ {workspace.branch === workspace.name ? null : (
+ ·
+ )}
+{diffStats.additions} −{diffStats.deletions}
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/stores/collapsedProjectsStore/collapsedProjectsStore.ts b/apps/mobile/screens/(authenticated)/(home)/home/stores/collapsedProjectsStore/collapsedProjectsStore.ts
new file mode 100644
index 00000000000..0e89337166d
--- /dev/null
+++ b/apps/mobile/screens/(authenticated)/(home)/home/stores/collapsedProjectsStore/collapsedProjectsStore.ts
@@ -0,0 +1,65 @@
+import AsyncStorage from "@react-native-async-storage/async-storage";
+import { create } from "zustand";
+import { createJSONStorage, persist } from "zustand/middleware";
+
+/**
+ * Which project sections are shut, keyed `machineId:projectId` — collapse is
+ * per host because the same project can hold different work on each machine.
+ * Absent means expanded: a project you've never touched shows its workspaces
+ * rather than hiding them behind a caret.
+ */
+interface CollapsedProjectsStore {
+ collapsed: Record;
+ /** False until AsyncStorage answers — sections would flash open before it. */
+ hasHydrated: boolean;
+ toggleProject: (machineId: string, projectId: string) => void;
+ setAllCollapsed: (
+ machineId: string,
+ projectIds: string[],
+ collapsed: boolean,
+ ) => void;
+}
+
+export function collapsedProjectKey(machineId: string, projectId: string) {
+ return `${machineId}:${projectId}`;
+}
+
+export const useCollapsedProjectsStore = create()(
+ persist(
+ (set) => ({
+ collapsed: {},
+ hasHydrated: false,
+ toggleProject: (machineId, projectId) => {
+ set((state) => {
+ const key = collapsedProjectKey(machineId, projectId);
+ if (state.collapsed[key]) {
+ const { [key]: _removed, ...collapsed } = state.collapsed;
+ return { collapsed };
+ }
+ return { collapsed: { ...state.collapsed, [key]: true as const } };
+ });
+ },
+ setAllCollapsed: (machineId, projectIds, collapsed) => {
+ set((state) => {
+ const next = { ...state.collapsed };
+ for (const projectId of projectIds) {
+ const key = collapsedProjectKey(machineId, projectId);
+ if (collapsed) next[key] = true;
+ else delete next[key];
+ }
+ return { collapsed: next };
+ });
+ },
+ }),
+ {
+ name: "collapsed-projects-v1",
+ storage: createJSONStorage(() => AsyncStorage),
+ partialize: ({ collapsed }) => ({ collapsed }),
+ // Rehydration is async, so readers see {} first and every collapsed
+ // section would render expanded and then snap shut. Flips on storage
+ // errors too, so a failed read falls back to everything expanded.
+ onRehydrateStorage: () => () =>
+ useCollapsedProjectsStore.setState({ hasHydrated: true }),
+ },
+ ),
+);
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/stores/collapsedProjectsStore/index.ts b/apps/mobile/screens/(authenticated)/(home)/home/stores/collapsedProjectsStore/index.ts
new file mode 100644
index 00000000000..5f904765189
--- /dev/null
+++ b/apps/mobile/screens/(authenticated)/(home)/home/stores/collapsedProjectsStore/index.ts
@@ -0,0 +1,4 @@
+export {
+ collapsedProjectKey,
+ useCollapsedProjectsStore,
+} from "./collapsedProjectsStore";
diff --git a/apps/mobile/screens/(authenticated)/(home)/home/stores/workspacesFilterStore/workspacesFilterStore.ts b/apps/mobile/screens/(authenticated)/(home)/home/stores/workspacesFilterStore/workspacesFilterStore.ts
index 260780815a8..ffd35d570c1 100644
--- a/apps/mobile/screens/(authenticated)/(home)/home/stores/workspacesFilterStore/workspacesFilterStore.ts
+++ b/apps/mobile/screens/(authenticated)/(home)/home/stores/workspacesFilterStore/workspacesFilterStore.ts
@@ -10,12 +10,10 @@ export const SORT_OPTIONS: { value: WorkspaceSort; label: string }[] = [
];
interface WorkspacesFilterStore {
- projectFilter: string | null;
hostFilter: string | null;
sort: WorkspaceSort;
/** False until AsyncStorage has answered — the saved filter isn't here yet. */
hasHydrated: boolean;
- setProjectFilter: (projectId: string | null) => void;
setHostFilter: (machineId: string | null) => void;
setSort: (sort: WorkspaceSort) => void;
}
@@ -23,22 +21,16 @@ interface WorkspacesFilterStore {
export const useWorkspacesFilterStore = create()(
persist(
(set) => ({
- projectFilter: null,
hostFilter: null,
sort: "updatedAt",
hasHydrated: false,
- setProjectFilter: (projectId) => set({ projectFilter: projectId }),
setHostFilter: (machineId) => set({ hostFilter: machineId }),
setSort: (sort) => set({ sort }),
}),
{
name: "workspaces-filter",
storage: createJSONStorage(() => AsyncStorage),
- partialize: ({ projectFilter, hostFilter, sort }) => ({
- projectFilter,
- hostFilter,
- sort,
- }),
+ partialize: ({ hostFilter, sort }) => ({ hostFilter, sort }),
// Rehydration is async — measured at ~165ms on a cold start — so
// readers see the defaults first and the home screen would spend that
// window showing (and fetching) the wrong host's default project.