Skip to content

Commit 0e5f133

Browse files
feat(mobile): stock tab bar, glass filter pills, and saved list filters
- Use UIKit's own tab bar with Threads/Pulls labels; compose is the native detached search-role tab instead of a custom trailing button - Filter pills use Liquid Glass and sit closer to the header and list - Thread and pull request list filters persist across launches Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ee2763e commit 0e5f133

16 files changed

Lines changed: 315 additions & 133 deletions

‎apps/mobile/src/features/home/HomeRouteScreen.tsx‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ export function HomeRouteScreen() {
127127
} = useHomeListOptions(availableEnvironmentIds);
128128
const selectedEnvironmentId = listOptions.selectedEnvironmentId;
129129
const projectScopeKey = listOptions.selectedProjectKey;
130-
const selectedProjectKey = resolveScratchProjectScopeKey(projectScopeKey, projects, {
130+
const resolvedProjectKey = resolveScratchProjectScopeKey(projectScopeKey, projects, {
131131
sidebarProjectGroupingMode: listOptions.projectGroupingMode,
132132
sidebarProjectGroupingOverrides: {},
133133
});
134134
useEffect(() => {
135-
if (selectedProjectKey !== projectScopeKey) {
136-
setSelectedProjectKey(selectedProjectKey);
135+
if (resolvedProjectKey !== projectScopeKey) {
136+
setSelectedProjectKey(resolvedProjectKey);
137137
}
138-
}, [projectScopeKey, selectedProjectKey, setSelectedProjectKey]);
138+
}, [projectScopeKey, resolvedProjectKey, setSelectedProjectKey]);
139139
const projectFilterOptions = useMemo(
140140
() =>
141141
buildHomeProjectScopes({
@@ -148,14 +148,12 @@ export function HomeRouteScreen() {
148148
})),
149149
[listOptions.projectGroupingMode, projects, selectedEnvironmentId],
150150
);
151-
useEffect(() => {
152-
if (
153-
selectedProjectKey !== null &&
154-
!projectFilterOptions.some((project) => project.key === selectedProjectKey)
155-
) {
156-
setSelectedProjectKey(null);
157-
}
158-
}, [projectFilterOptions, selectedProjectKey, setSelectedProjectKey]);
151+
// A saved project stays selected while its environment is offline or filtered out.
152+
const selectedProjectKey = projectFilterOptions.some(
153+
(project) => project.key === resolvedProjectKey,
154+
)
155+
? resolvedProjectKey
156+
: null;
159157

160158
// In split layouts the persistent sidebar IS the thread list — Home becomes
161159
// an empty detail pane so selecting a thread never transitions layouts.

‎apps/mobile/src/features/home/ThreadListFilters.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function ThreadListFilters(
2424
<ScrollView
2525
horizontal
2626
showsHorizontalScrollIndicator={false}
27-
contentContainerStyle={{ paddingHorizontal: 16, gap: 6, paddingBottom: 8 }}
27+
contentContainerStyle={{ paddingHorizontal: 16, paddingTop: 2, paddingBottom: 10, gap: 8 }}
2828
>
2929
<ListFilterMenu
3030
label={selectedEnvironment?.label ?? "All environments"}
@@ -85,7 +85,7 @@ export function ThreadListFilters(
8585
<Pressable
8686
accessibilityRole="button"
8787
accessibilityLabel="Reset thread filters"
88-
className="h-11 w-8 items-center justify-center"
88+
className="h-8 w-8 items-center justify-center"
8989
onPress={() => {
9090
props.onEnvironmentChange(null);
9191
props.onProjectChange(null);

‎apps/mobile/src/features/home/home-list-options.test.ts‎

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
import { RegistryContext } from "@effect/atom-react";
12
import { EnvironmentId } from "@t3tools/contracts";
3+
import { AtomRegistry } from "effect/reactivity";
24
import { act, createElement, useLayoutEffect } from "react";
35
import { createRoot, type Root } from "react-dom/client";
46
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
57

8+
const saved = vi.hoisted(() => [] as unknown[]);
9+
vi.mock("../../state/preferences", async () => {
10+
const { Atom } = await import("effect/reactivity");
11+
return {
12+
updateMobilePreferencesAtom: Atom.writable(
13+
() => null,
14+
(_ctx, patch: unknown) => {
15+
saved.push(patch);
16+
},
17+
),
18+
};
19+
});
20+
21+
import type { ThreadListFilters } from "../../persistence/mobile-preferences";
622
import { HomeListOptionsProvider, useHomeListOptions } from "./home-list-options";
723

824
describe("home list options across layout changes", () => {
@@ -19,14 +35,20 @@ describe("home list options across layout changes", () => {
1935
return null;
2036
}
2137

22-
async function showLayout(layout: "compact" | "sidebar") {
38+
const registry = AtomRegistry.make();
39+
40+
async function showLayout(layout: "compact" | "sidebar", savedFilters?: ThreadListFilters) {
2341
await act(() => {
2442
root.render(
2543
createElement(
26-
HomeListOptionsProvider,
27-
{ projectGroupingMode: "repository" },
28-
// Replace the list while keeping the workspace provider mounted.
29-
createElement(ThreadList, { key: layout }),
44+
RegistryContext,
45+
{ value: registry },
46+
createElement(
47+
HomeListOptionsProvider,
48+
{ projectGroupingMode: "repository", savedFilters },
49+
// Replace the list while keeping the workspace provider mounted.
50+
createElement(ThreadList, { key: layout }),
51+
),
3052
),
3153
);
3254
});
@@ -51,6 +73,7 @@ describe("home list options across layout changes", () => {
5173
vi.stubGlobal("window", { document, HTMLIFrameElement: EventTarget });
5274
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
5375
root = createRoot(container as unknown as HTMLElement);
76+
saved.length = 0;
5477
});
5578

5679
afterEach(async () => {
@@ -92,4 +115,16 @@ describe("home list options across layout changes", () => {
92115
}
93116
},
94117
);
118+
119+
it("restores saved filters on launch and saves only real changes", async () => {
120+
await showLayout("compact", { environmentId, projectKey: "repository:one" });
121+
expect(latest.options).toMatchObject({
122+
selectedEnvironmentId: environmentId,
123+
selectedProjectKey: "repository:one",
124+
});
125+
expect(saved).toEqual([]);
126+
127+
await act(() => latest.setSelectedProjectKey(null));
128+
expect(saved).toEqual([{ threadListFilters: { environmentId, projectKey: null } }]);
129+
});
95130
});

‎apps/mobile/src/features/home/home-list-options.ts‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
import type { EnvironmentId, SidebarProjectGroupingMode } from "@t3tools/contracts";
22
import { DEFAULT_SIDEBAR_PROJECT_SORT_ORDER } from "@t3tools/contracts";
3+
import { useAtomSet } from "@effect/atom-react";
34
import {
45
createContext,
56
createElement,
67
useCallback,
78
useContext,
9+
useEffect,
810
useMemo,
11+
useRef,
912
useState,
1013
type PropsWithChildren,
1114
type Dispatch,
1215
type SetStateAction,
1316
} from "react";
1417

18+
import type { ThreadListFilters } from "../../persistence/mobile-preferences";
19+
import { updateMobilePreferencesAtom } from "../../state/preferences";
1520
import type { HomeProjectSortOrder } from "./homeThreadList";
1621

1722
export interface HomeListOptions {
@@ -24,10 +29,10 @@ export interface ResolvedHomeListOptions extends HomeListOptions {
2429
readonly projectGroupingMode: SidebarProjectGroupingMode;
2530
}
2631

27-
function defaultHomeListOptions(): HomeListOptions {
32+
function defaultHomeListOptions(filters?: ThreadListFilters): HomeListOptions {
2833
return {
29-
selectedEnvironmentId: null,
30-
selectedProjectKey: null,
34+
selectedEnvironmentId: filters?.environmentId ?? null,
35+
selectedProjectKey: filters?.projectKey ?? null,
3136
projectSortOrder:
3237
DEFAULT_SIDEBAR_PROJECT_SORT_ORDER === "manual"
3338
? "updated_at"
@@ -43,14 +48,31 @@ interface HomeListOptionsContextValue {
4348

4449
const HomeListOptionsContext = createContext<HomeListOptionsContextValue | null>(null);
4550

46-
/** Keeps list preferences stable while the app moves between compact and split shells. */
51+
/**
52+
* Keeps list preferences stable while the app moves between compact and split shells.
53+
* Filters start from the saved preference, and changes are saved for the next launch.
54+
*/
4755
export function HomeListOptionsProvider({
4856
children,
4957
projectGroupingMode,
58+
savedFilters,
5059
}: PropsWithChildren<{
5160
readonly projectGroupingMode: SidebarProjectGroupingMode;
61+
readonly savedFilters?: ThreadListFilters | undefined;
5262
}>) {
53-
const [options, setOptions] = useState<HomeListOptions>(defaultHomeListOptions);
63+
const [options, setOptions] = useState(() => defaultHomeListOptions(savedFilters));
64+
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
65+
const saved = useRef(savedFilters);
66+
const { selectedEnvironmentId: environmentId, selectedProjectKey: projectKey } = options;
67+
useEffect(() => {
68+
if (
69+
(saved.current?.environmentId ?? null) === environmentId &&
70+
(saved.current?.projectKey ?? null) === projectKey
71+
)
72+
return;
73+
saved.current = { environmentId, projectKey };
74+
savePreferences({ threadListFilters: saved.current });
75+
}, [environmentId, projectKey, savePreferences]);
5476
const value = useMemo(
5577
() => ({ options, setOptions, projectGroupingMode }),
5678
[options, projectGroupingMode],

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
resolveThreadSelectionOverlayState,
4646
} from "../../lib/adaptive-navigation";
4747
import { scopedThreadKey } from "../../lib/scopedEntities";
48+
import type { ThreadListFilters } from "../../persistence/mobile-preferences";
4849
import { mobilePreferencesAtom } from "../../state/preferences";
4950
import {
5051
DEFAULT_MOBILE_PROJECT_GROUPING_SETTINGS,
@@ -226,6 +227,7 @@ export function AdaptiveWorkspaceLayout(props: {
226227
<AdaptiveWorkspaceLayoutContent
227228
{...props}
228229
projectGroupingMode={groupingSettings.sidebarProjectGroupingMode}
230+
savedThreadListFilters={preferencesResult.value.threadListFilters}
229231
/>
230232
);
231233
}
@@ -237,6 +239,7 @@ function AdaptiveWorkspaceLayoutContent(
237239
readonly workspaceRouteKey: string | undefined;
238240
} & {
239241
readonly projectGroupingMode: SidebarProjectGroupingMode;
242+
readonly savedThreadListFilters?: ThreadListFilters | undefined;
240243
},
241244
) {
242245
const projectGroupingMode = props.projectGroupingMode;
@@ -592,7 +595,10 @@ function AdaptiveWorkspaceLayoutContent(
592595

593596
if (nativeWorkspace) {
594597
return (
595-
<HomeListOptionsProvider projectGroupingMode={projectGroupingMode}>
598+
<HomeListOptionsProvider
599+
projectGroupingMode={projectGroupingMode}
600+
savedFilters={props.savedThreadListFilters}
601+
>
596602
<AdaptiveWorkspaceContext value={contextValue}>
597603
<NativeWorkspaceInspectorContext
598604
value={{ render: workspaceInspector?.render, visible: inspectorColumnTargetWidth > 0 }}
@@ -604,7 +610,10 @@ function AdaptiveWorkspaceLayoutContent(
604610
);
605611
}
606612
return (
607-
<HomeListOptionsProvider projectGroupingMode={projectGroupingMode}>
613+
<HomeListOptionsProvider
614+
projectGroupingMode={projectGroupingMode}
615+
savedFilters={props.savedThreadListFilters}
616+
>
608617
<AdaptiveWorkspaceContext.Provider value={contextValue}>
609618
<View testID="adaptive-workspace-layout" className="flex-1 flex-row">
610619
{shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (

‎apps/mobile/src/features/pull-requests/PullRequestListFilters.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export function PullRequestListFilters(props: {
196196
<ScrollView
197197
horizontal
198198
showsHorizontalScrollIndicator={false}
199-
contentContainerStyle={{ paddingHorizontal: 16, gap: 6, paddingBottom: 8 }}
199+
contentContainerStyle={{ paddingHorizontal: 16, paddingTop: 2, paddingBottom: 10, gap: 8 }}
200200
>
201201
<ListFilterMenu
202202
label={count ? String(count) : "Filters"}

‎apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LegendList, type LegendListRef } from "@legendapp/list/react-native";
22
import { useNavigation } from "@react-navigation/native";
33
import { use, useCallback, useEffect, useMemo, useRef, useState } from "react";
44
import { ProjectId } from "@t3tools/contracts";
5-
import { useAtomSet, useAtomValue } from "@effect/atom-react";
5+
import { useAtomValue } from "@effect/atom-react";
66
import {
77
ActivityIndicator,
88
Keyboard,
@@ -24,7 +24,8 @@ import { useProjects } from "../../state/entities";
2424
import { environmentServerConfigsAtom } from "../../state/server";
2525
import { PullRequestListRow } from "./PullRequestListRow";
2626
import { PullRequestListFilters } from "./PullRequestListFilters";
27-
import { pullRequestListControlsAtom, usePullRequestList } from "./usePullRequestList";
27+
import { usePullRequestList } from "./usePullRequestList";
28+
import { usePullRequestListControls } from "./usePullRequestListControls";
2829
import { usePullRequestListActions } from "./usePullRequestListActions";
2930
import {
3031
filterPullRequestList,
@@ -73,7 +74,8 @@ export function PullRequestsScreen() {
7374
const debouncedQuery = useDebouncedValue(tab.query.trim(), 180);
7475
// Dismissal must restore the cached unfiltered list before restoring its offset.
7576
const query = tab.searchMode === "resting" ? "" : debouncedQuery;
76-
const selectedEnvironmentId = workspace.pullRequestEnvironmentId;
77+
const listControls = usePullRequestListControls();
78+
const selectedEnvironmentId = listControls.environmentId;
7779
const environmentId = environments.some((item) => item.environmentId === selectedEnvironmentId)
7880
? selectedEnvironmentId
7981
: null;
@@ -91,9 +93,7 @@ export function PullRequestsScreen() {
9193
},
9294
[navigation],
9395
);
94-
const controlsAtom = pullRequestListControlsAtom(environmentId ?? "");
95-
const controls = useAtomValue(controlsAtom);
96-
const setControls = useAtomSet(controlsAtom);
96+
const controls = listControls.controlsFor(environmentId);
9797
const targets = useMemo(
9898
() =>
9999
environments
@@ -265,10 +265,10 @@ export function PullRequestsScreen() {
265265
label: item.environmentLabel,
266266
}))}
267267
environmentId={environmentId}
268-
onEnvironmentChange={workspace.setPullRequestEnvironmentId}
268+
onEnvironmentChange={listControls.setEnvironmentId}
269269
value={controls}
270270
onChange={(next) => {
271-
setControls(next);
271+
listControls.setControls(environmentId, next);
272272
void listRef.current?.scrollToOffset({
273273
offset: Platform.OS === "ios" ? -insets.top : 0,
274274
animated: false,

‎apps/mobile/src/features/pull-requests/pullRequestList.ts‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
import type {
22
EnvironmentId,
33
PullRequestListEntry,
4-
PullRequestListFilters,
54
PullRequestListInput,
65
PullRequestListResult,
7-
PullRequestInvolvement,
8-
PullRequestListState,
96
} from "@t3tools/contracts";
7+
import type { PullRequestListControls } from "../../persistence/mobile-preferences";
108

119
export const PR_LIST_PAGE_SIZE = 30;
12-
export interface PullRequestListControls {
13-
readonly state: PullRequestListState;
14-
readonly involvement: PullRequestInvolvement;
15-
readonly filters: PullRequestListFilters;
16-
readonly projectId?: string;
17-
readonly projectEnvironmentId?: string;
18-
readonly sort: "updated" | "created" | "oldest";
19-
}
10+
export type { PullRequestListControls } from "../../persistence/mobile-preferences";
2011
export const DEFAULT_PR_LIST_CONTROLS: PullRequestListControls = {
2112
state: "open",
2213
involvement: "all",

‎apps/mobile/src/features/pull-requests/usePullRequestList.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { use, useCallback, useEffect, useMemo, useRef, useState, useLayoutEffect
88
import { composerPullRequests } from "../../state/pull-requests";
99
import {
1010
appendPullRequestListPage,
11-
DEFAULT_PR_LIST_CONTROLS,
1211
mergeEnvironmentPullRequestPages,
1312
nextPullRequestListInput,
1413
pullRequestListHead,
@@ -28,10 +27,6 @@ const statsFamily = Atom.family((_environmentId: string) =>
2827
const statKey = (row: Pick<PullRequestDiffStat, "projectId" | "repository" | "number">) =>
2928
`${row.projectId}:${row.repository}:${row.number}`;
3029

31-
export const pullRequestListControlsAtom = Atom.family((_environmentId: string) =>
32-
Atom.make(DEFAULT_PR_LIST_CONTROLS),
33-
);
34-
3530
type ListTarget = { readonly environmentId: EnvironmentId; readonly input: PullRequestListInput };
3631
const sourcesFamily = Atom.family((key: string) => {
3732
const targets: readonly ListTarget[] = JSON.parse(key);

0 commit comments

Comments
 (0)